Repository: shorepine/amy Branch: main Commit: a63d600c6007 Files: 156 Total size: 8.0 MB Directory structure: gitextract_vrmra0ai/ ├── .claude/ │ └── launch.json ├── .github/ │ └── workflows/ │ ├── arduino.yml │ ├── c-cpp.yml │ └── godot-addon.yml ├── .gitignore ├── CLAUDE.md ├── CODE_OF_CONDUCT.md ├── LICENSE ├── Makefile ├── README.md ├── amy/ │ ├── __init__.py │ ├── constants.py │ ├── examples.py │ ├── fm.py │ ├── headers.py │ ├── juno.py │ ├── piano.py │ ├── piano_params.py │ ├── sineclock.py │ ├── test.py │ ├── timing.py │ ├── wave.py │ └── xanadu.py ├── daisy/ │ ├── Makefile │ └── amy_daisy.cpp ├── docs/ │ ├── amy.aw.js │ ├── amy.graffle │ ├── amy.js │ ├── amy.wasm │ ├── amy.ww.js │ ├── amyrepl.css │ ├── amyrepl.js │ ├── api.md │ ├── arduino.md │ ├── billie_jean.md │ ├── chunk.py │ ├── enable-threads.js │ ├── godot.md │ ├── index.html │ ├── juno_patches.md │ ├── micropython.mjs │ ├── micropython.wasm │ ├── midi.md │ ├── minimal.html │ ├── piano.html │ ├── repl.html │ ├── server.py │ ├── style.css │ ├── synth.md │ ├── tutorial.html │ └── upgrading.md ├── examples/ │ ├── AMY_ESP32_manual_I2S/ │ │ └── AMY_ESP32_manual_I2S.ino │ ├── AMY_MIDI_Synth/ │ │ └── AMY_MIDI_Synth.ino │ ├── AMY_USB_Host_MIDI/ │ │ └── AMY_USB_Host_MIDI.ino │ ├── AMY_custom_osc/ │ │ └── AMY_custom_osc.ino │ ├── AMY_pico_PWM/ │ │ └── AMY_pico_PWM.ino │ ├── BillieJeanDrums/ │ │ └── BillieJeanDrums.ino │ ├── BillieJeanDrumsBass/ │ │ └── BillieJeanDrumsBass.ino │ └── BillieJeanScheduled/ │ └── BillieJeanScheduled.ino ├── experiments/ │ ├── Piano.ff.D5.json │ ├── compare_test_wavs.ipynb │ ├── dx7_simulator.py │ ├── make_piano_examples.ipynb │ ├── piano-params.json │ ├── piano-partials.ipynb │ ├── piano_examples.py │ ├── piano_heterodyne.ipynb │ ├── piano_params.py │ ├── track02-C4-bps.json │ └── tulip_piano.py ├── godot/ │ ├── SConstruct │ ├── amy.gd │ ├── amy.gdextension │ ├── install.gd │ ├── src/ │ │ ├── amy_gdextension.cpp │ │ ├── amy_gdextension.h │ │ ├── amy_platform_stubs.c │ │ ├── register_types.cpp │ │ └── register_types.h │ └── web/ │ ├── custom_shell.html │ └── godot_amy_bridge.js ├── library.properties ├── pyproject.toml ├── requirements.txt ├── scripts/ │ ├── gen_amy_js_api.py │ └── gen_patches_js.py ├── setup.py ├── setup_godot.sh ├── sounds/ │ └── HS-TR-808-Drums.sf2 ├── src/ │ ├── AMY-Arduino.h │ ├── algorithms.c │ ├── amy-example.c │ ├── amy-message.c │ ├── amy-piano.c │ ├── amy.c │ ├── amy.h │ ├── amy_connector.js │ ├── amy_fixedpoint.h │ ├── amy_midi.c │ ├── amy_midi.h │ ├── api.c │ ├── clipping_lookup_table.h │ ├── custom.c │ ├── delay.c │ ├── delay.h │ ├── envelope.c │ ├── examples.c │ ├── examples.h │ ├── filters.c │ ├── i2s.c │ ├── instrument.c │ ├── interp_partials.c │ ├── interp_partials.h │ ├── libminiaudio-audio.c │ ├── libminiaudio-audio.h │ ├── log2_exp2.c │ ├── log2_exp2_fxpt_lutable.h │ ├── macos_midi.m │ ├── midi_mappings.c │ ├── miniaudio.h │ ├── oscillators.c │ ├── parse.c │ ├── patches.c │ ├── patches.h │ ├── pcm.c │ ├── pcm_samples_tiny.h │ ├── pcm_tiny.h │ ├── pico-audio/ │ │ ├── audio.cpp │ │ ├── audio.h │ │ ├── audio_i2s.c │ │ ├── audio_i2s.h │ │ ├── audio_i2s.pio │ │ ├── audio_i2s.pio.h │ │ ├── buffer.c │ │ ├── buffer.h │ │ └── sample_conversion.h │ ├── pico_extras_import.cmake │ ├── pico_sdk_import.cmake │ ├── pico_support.cpp │ ├── pyamy.c │ ├── saw_lutset_fxpt.h │ ├── sequencer.c │ ├── sequencer.h │ ├── sine_lutset_fxpt.h │ ├── teensy_support.cpp │ ├── teensy_support.h │ ├── transfer.c │ ├── transfer.h │ ├── triangle_lutset_fxpt.h │ ├── usb.c │ └── usb.h ├── valgrind.suppressions └── windows/ ├── CMakeLists.txt ├── README.md ├── amy_sine.c └── build.bat ================================================ FILE CONTENTS ================================================ ================================================ FILE: .claude/launch.json ================================================ { "version": "0.0.1", "configurations": [ { "name": "amy-docs", "runtimeExecutable": "python3", "runtimeArgs": ["-m", "http.server", "8080", "-d", "docs"], "port": 8080 } ] } ================================================ FILE: .github/workflows/arduino.yml ================================================ name: Arduino CI on: push: branches: [ "main" ] pull_request: branches: [ "main" ] jobs: compile: runs-on: ubuntu-latest strategy: fail-fast: false matrix: include: - name: "ESP32-S3" fqbn: "esp32:esp32:esp32s3" platforms: | - name: esp32:esp32 source-url: https://espressif.github.io/arduino-esp32/package_esp32_index.json - name: "RP2040 (Pico)" fqbn: "rp2040:rp2040:rpipico" platforms: | - name: rp2040:rp2040 source-url: https://github.com/earlephilhower/arduino-pico/releases/download/4.5.3/package_rp2040_index.json - name: "RP2350 (Pico 2)" fqbn: "rp2040:rp2040:rpipico2" platforms: | - name: rp2040:rp2040 source-url: https://github.com/earlephilhower/arduino-pico/releases/download/4.5.3/package_rp2040_index.json - name: "Teensy 4.1" fqbn: "teensy:avr:teensy41" platforms: | - name: teensy:avr source-url: https://www.pjrc.com/teensy/package_teensy_index.json name: ${{ matrix.name }} steps: - uses: actions/checkout@v4 - uses: arduino/compile-sketches@v1 with: fqbn: ${{ matrix.fqbn }} platforms: ${{ matrix.platforms }} sketch-paths: | - examples/BillieJeanDrums enable-deltas-report: false ================================================ FILE: .github/workflows/c-cpp.yml ================================================ name: C/C++ CI on: push: branches: [ "main" ] pull_request: branches: [ "main" ] jobs: test: runs-on: ubuntu-latest strategy: fail-fast: false matrix: python-version: ['3.12', '3.13', '3.14'] steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Install dependencies run: pip install numpy scipy - name: Build and test env: AMY_TEST_THRESHOLD_DB: "-70.0" run: make test ================================================ FILE: .github/workflows/godot-addon.yml ================================================ name: Build Godot Addon on: push: tags: - '*' workflow_dispatch: permissions: contents: write jobs: build: strategy: fail-fast: false matrix: include: - name: macOS runner: macos-latest platform: macos arch: universal - name: Linux runner: ubuntu-22.04 platform: linux arch: x86_64 - name: Windows runner: windows-latest platform: windows arch: x86_64 runs-on: ${{ matrix.runner }} name: Build ${{ matrix.name }} steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 with: python-version: '3.12' - name: Install scons run: pip install scons - name: Checkout godot-cpp uses: actions/checkout@v4 with: repository: godotengine/godot-cpp ref: godot-4.4-stable path: godot-cpp submodules: true - name: Build debug working-directory: godot run: scons platform=${{ matrix.platform }} arch=${{ matrix.arch }} target=template_debug -j4 env: GODOT_CPP_PATH: ${{ github.workspace }}/godot-cpp AMY_SRC_PATH: ${{ github.workspace }}/src - name: Build release working-directory: godot run: scons platform=${{ matrix.platform }} arch=${{ matrix.arch }} target=template_release -j4 env: GODOT_CPP_PATH: ${{ github.workspace }}/godot-cpp AMY_SRC_PATH: ${{ github.workspace }}/src - name: Upload build artifacts uses: actions/upload-artifact@v4 with: name: bin-${{ matrix.platform }} path: godot/bin/ package: needs: build runs-on: ubuntu-latest name: Package Addon steps: - uses: actions/checkout@v4 - name: Download all build artifacts uses: actions/download-artifact@v4 with: path: collected-bins/ - name: Assemble addon zip run: | mkdir -p addons/amy/bin # Copy compiled binaries from all platforms cp -r collected-bins/bin-macos/* addons/amy/bin/ cp -r collected-bins/bin-linux/* addons/amy/bin/ cp -r collected-bins/bin-windows/* addons/amy/bin/ # Copy GDExtension config and scripts cp godot/amy.gdextension addons/amy/ cp godot/amy.gd addons/amy/ cp godot/install.gd addons/amy/ # Copy web export files mkdir -p addons/amy/web cp godot/web/godot_amy_bridge.js addons/amy/web/ cp godot/web/custom_shell.html addons/amy/web/ cp docs/amy.js addons/amy/web/ cp docs/amy.wasm addons/amy/web/ cp docs/amy.aw.js addons/amy/web/ cp docs/amy.ww.js addons/amy/web/ cp docs/enable-threads.js addons/amy/web/ cp docs/enable-threads.js addons/amy/web/enable-threads-root.js # Create the zip zip -r amy-godot-addon.zip addons/ - name: Upload addon zip uses: actions/upload-artifact@v4 with: name: amy-godot-addon path: amy-godot-addon.zip release: needs: package runs-on: ubuntu-latest if: startsWith(github.ref, 'refs/tags/') name: Create Release steps: - name: Download addon zip uses: actions/download-artifact@v4 with: name: amy-godot-addon - name: Attach addon to release uses: softprops/action-gh-release@v2 with: files: amy-godot-addon.zip ================================================ FILE: .gitignore ================================================ uv.lock amy-example amy-message tests/tst amy-piano src/build/ *.DS_Store* loris-1.8/ __pycache__/ src/dist/ src/amy.egg-info/ .python-version amy.egg-info/ build/ # Prerequisites *.d # Object files *.o *.ko *.obj *.elf # Linker output *.ilk *.map *.exp # Precompiled Headers *.gch *.pch # Libraries *.lib *.a *.la *.lo # Shared objects (inc. Windows DLLs) *.dll *.so *.so.* *.dylib # Executables *.exe *.out *.app *.i*86 *.x86_64 *.hex # Debug files *.dSYM/ *.su *.idb *.pdb # Kernel Module Compile Results *.mod* *.cmd .tmp_versions/ modules.order Module.symvers Mkfile.old dkms.conf godot/.sconsign.dblite godot/src/*.os ================================================ FILE: CLAUDE.md ================================================ # AMY Development Notes ## Releases When creating a new release: 1. Update the version in `library.properties` to match the release tag 2. Create the GitHub release with a plain version tag (e.g. `1.2.3`, NOT `v1.2.3`) — Arduino requires this format 3. The Godot addon build workflow triggers automatically on tag push and attaches `amy-godot-addon.zip` to the release ## Godot GDExtension - Local builds use `setup_godot.sh` which generates the SConstruct, C++ source, and GDScript wrapper inline - CI builds use the `godot/` directory (SConstruct, src/, etc.) directly via `.github/workflows/godot-addon.yml` - `amy_midi.c` is excluded from the Godot build because it conflicts with platform stubs. Any new functions added to `amy_midi.c` (or other excluded files) that are called from core AMY code need stub implementations added in both: - `godot/src/amy_platform_stubs.c` (for CI builds) - The `amy_platform_stubs.c` section of `setup_godot.sh` (for local builds) - macOS builds produce a `.framework` bundle; the `gh auth` token needs `workflow` scope to push workflow file changes ## Web REPL (tutorial & docs) The live Python REPL at `docs/tutorial.html` runs MicroPython in the browser with the `amy` Python module frozen in. Updating it requires rebuilding MicroPython from the `shorepine/tulipcc` repo: 1. In `tulipcc`, update the amy submodule to latest: `cd tulipcc && git submodule update --remote amy` 2. Rebuild MicroPython: `cd tulip/amyrepl && make clean && make` 3. Copy the output to amy's docs: `cp build-standard/tulip/obj/micropython.mjs build-standard/tulip/obj/micropython.wasm /docs/` 4. If the AMY C code or JS API also changed, rebuild those too: `cd && make web && make deploy-web` The `docs/amy.js` file is a concatenation of the Emscripten build (`build/amy.js`), `src/amy_connector.js`, and `build/amy_api.generated.js`. The JS API is auto-generated from `amy/__init__.py` by `scripts/gen_amy_js_api.py`. ## GitHub Auth - The `bwhitman` account needs `workflow` scope on its token to push changes to `.github/workflows/` files. Run `gh auth refresh -h github.com -s workflow` if pushes are rejected. - SSH pushes to `shorepine/amy` use the `brianklay` key by default; use HTTPS with `gh auth token` for `bwhitman` access. ================================================ FILE: CODE_OF_CONDUCT.md ================================================ # Contributor Covenant Code of Conduct ## Our Pledge In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation. ## Our Standards Examples of behavior that contributes to creating a positive environment include: * Using welcoming and inclusive language * Being respectful of differing viewpoints and experiences * Gracefully accepting constructive criticism * Focusing on what is best for the community * Showing empathy towards other community members Examples of unacceptable behavior by participants include: * The use of sexualized language or imagery and unwelcome sexual attention or advances * Trolling, insulting/derogatory comments, and personal or political attacks * Public or private harassment * Publishing others' private information, such as a physical or electronic address, without explicit permission * Other conduct which could reasonably be considered inappropriate in a professional setting ## Our Responsibilities Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior. Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. ## Scope This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. ## Enforcement Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at brian@variogr.am. All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. ## Attribution This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html [homepage]: https://www.contributor-covenant.org For answers to common questions about this code of conduct, see https://www.contributor-covenant.org/faq ================================================ FILE: LICENSE ================================================ MIT License Copyright (c) 2022 Brian Whitman and Daniel PW Ellis Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ================================================ FILE: Makefile ================================================ # Makefile for AMY , including an example TARGET = amy-example amy-message amy-piano LIBS = -lm -pthread UNAME_S := $(shell uname -s) ifeq ($(UNAME_S),Darwin) SOURCES = src/macos_midi.m CFLAGS += -DMACOS LIBS = -framework AudioUnit -framework CoreAudio -framework CoreFoundation -framework CoreMIDI -framework Cocoa -lstdc++ # Needed for brew's python3.12+ on MacOS EXTRA_PIP_ENV = PIP_BREAK_SYSTEM_PACKAGES=1 CC = clang else CC = gcc endif # on Raspberry Pi, at least under 32-bit mode, libatomic and libdl are needed. ifeq ($(shell uname -m), armv7l) LIBS += -ldl -latomic endif ifeq ($(shell uname -m), armv6l) LIBS += -ldl -latomic endif CFLAGS += -O3 -Wall -Wno-strict-aliasing -Wextra -Wno-unused-parameter -Wpointer-arith -Wno-float-conversion -Wno-missing-declarations -DAMY_WAVETABLE #CFLAGS += -DAMY_DEBUG # -Wdouble-promotion EMSCRIPTEN_OPTIONS = -s WASM=1 --bind \ -DMA_ENABLE_AUDIO_WORKLETS -sAUDIO_WORKLET=1 -sWASM_WORKERS=1 \ -sSTACK_SIZE=128000\ -sMODULARIZE -s 'EXPORT_NAME="amyModule"' \ -s EXPORTED_RUNTIME_METHODS="['cwrap','ccall', 'HEAPU8']" \ -s EXPORTED_FUNCTIONS="['_amy_add_message', '_amy_add_event', '_amy_reset_sysclock', '_amy_sysclock', '_amy_process_single_midi_byte', \ '_amy_live_stop', '_amy_get_input_buffer', '_amy_get_output_buffer', '_amy_set_external_input_buffer', '_amy_live_start_web', '_amy_live_start_web_audioin',\ '_amy_start_web', '_amy_start_web_no_synths', '_sequencer_ticks', '_malloc', '_free', '_amy_bleep', '_yield_patch_events', '_size_of_amy_event', '_yield_synth_commands', '_amy_dump_state_to_string']" \ -s SUPPORT_LONGJMP=emscripten \ -s INITIAL_MEMORY=128mb -s TOTAL_STACK=64mb -s ALLOW_MEMORY_GROWTH=1 \ -s ASYNCIFY -s ASYNCIFY_STACK_SIZE=128000 PYTHON = python3 .PHONY: default all clean amy-module test web deploy-web default: $(TARGET) all: default SOURCES += src/algorithms.c src/amy.c src/envelope.c src/examples.c src/parse.c \ src/filters.c src/oscillators.c src/pcm.c src/interp_partials.c src/custom.c \ src/delay.c src/log2_exp2.c src/patches.c src/transfer.c src/sequencer.c \ src/libminiaudio-audio.c src/instrument.c src/amy_midi.c src/api.c src/midi_mappings.c OBJECTS = $(patsubst %.c, %.o, $(SOURCES)) HEADERS = $(wildcard src/*.h) HEADERS_BUILD := $(filter-out src/patches.h,$(HEADERS)) PYTHONS = $(wildcard *.py) src/patches.h: $(PYTHONS) $(HEADERS_BUILD) cat src/amy.h | sed -e 's@^//.*@@' | egrep 'define +[^ ]+ +[.0-9-]+' | sed -e 's/\([.0-9]\)f$$/\1/' | awk '{print $$2 "=" $$3}' > amy/constants.py ${PYTHON} -m amy.headers %.o: %.c $(HEADERS) src/patches.h $(CC) $(CFLAGS) -c $< -o $@ %.o: %.mm $(HEADERS) clang $(CFLAGS) -c $< -o $@ %.o: %.m clang -I$(INC) $(CFLAGS) -c -o $@ $< .PRECIOUS: $(TARGET) $(OBJECTS) amy-example: $(OBJECTS) src/amy-example.o $(CC) $(CFLAGS) $(OBJECTS) src/amy-example.o -Wall $(LIBS) -o $@ amy-piano: $(OBJECTS) src/amy-piano.o $(CC) $(CFLAGS) $(OBJECTS) src/amy-piano.o -Wall $(LIBS) -o $@ amy-message: $(OBJECTS) src/amy-message.o $(CC) $(CFLAGS) $(OBJECTS) src/amy-message.o -Wall $(LIBS) -o $@ amy-module: amy-example ${EXTRA_PIP_ENV} ${PYTHON} -m pip install -r requirements.txt; touch src/amy.c; ${EXTRA_PIP_ENV} ${PYTHON} -m pip install . --force-reinstall --no-deps; cd .. test: amy-module ${PYTHON} -m amy.test qtest: amy-module ${PYTHON} -m amy.test quiet # Report the median FILTER_PROCESS timing over 50 runs. timing: amy-module for a in 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40; do ${PYTHON} -m amy.timing 2>&1 ; done > /tmp/timings.txt cat /tmp/timings.txt | grep AMY_RENDER: | sed -e 's/us//' | sort -n | awk ' { a[i++]=$$4; } END { print a[int(i/2)]; }' cat /tmp/timings.txt | grep FILTER_PROCESS: | sed -e 's/us//' | sort -n | awk ' { a[i++]=$$4; } END { print a[int(i/2)]; }' cat /tmp/timings.txt | grep PARAMETRIC_EQ_PROCESS: | sed -e 's/us//' | sort -n | awk ' { a[i++]=$$4; } END { print a[int(i/2)]; }' valgrind: amy-example valgrind --leak-check=full --show-reachable=yes --suppressions=valgrind.suppressions ./amy-example build/amy.js: $(TARGET) mkdir -p build emcc $(SOURCES) $(CFLAGS) $(EMSCRIPTEN_OPTIONS) -O3 -o $@ build/amy_api.generated.js: scripts/gen_amy_js_api.py amy/__init__.py src/patches.h mkdir -p build $(PYTHON) scripts/gen_amy_js_api.py build/patches.generated.js: scripts/gen_patches_js.py src/patches.h mkdir -p build $(PYTHON) scripts/gen_patches_js.py web: build/amy.js build/amy_api.generated.js build/patches.generated.js deploy-web: web cat build/amy.js src/amy_connector.js build/amy_api.generated.js > docs/amy.js cp build/amy.wasm build/amy.aw.js build/amy.ww.js docs/ clean: -rm -f src/*.o -rm -r src/patches.h -rm -f amy/constants.py -rm -f $(TARGET) ================================================ FILE: README.md ================================================ # AMY - The high-performance fixed-point music synthesizer library AMY is a fast and small music synthesizer library written in C with (so far) Python, Arduino, Javascript and GDScript bindings. It can easily be embedded into almost any program, architecture or microcontroller. It can be used as a very good analog-type synthesizer (Juno-6 style) a FM synthesizer (DX7 style), a partial breakpoint synthesizer (Alles machine or Atari AMY), a [very good synthesized piano](https://shorepine.github.io/amy/piano.html), a sampler or wavetable synth (where you load in your own PCM data), a drum machine (808-style PCM samples are included), or as a lower level toolkit to make your own combinations of oscillators, filters, LFOs and effects. AMY supports MIDI internally and can manage synthesizer note messages for you, including voice stealing and assigning controller changes. We've run AMY on: * [the web](https://shorepine.github.io/amy/) * Mac, Linux, and [Windows](windows/README.md), and small Linux devices like the Raspberry Pi * ESP32, ESP32S3 (Xtensa) * ESP32-P4, ESP32-C3, C6 (RISC-V) * Pi Pico RP2040, the Pi Pico 2 RP2350 * [NRF52 series](https://github.com/jgartrel/amy_synth_nrf52_example) * Teensy 3.6, Teensy 4.1 * Playdate and Electro-Smith Daisy (ARM Cortex M7) * iOS devices * [Godot game engine](docs/godot.md) * And certainly much more AMY is highly optimized for polyphony and poly-timbral operation on even the lowest power and constrained RAM microcontroller but can scale to as many oscillators as you want. AMY powers the multi-speaker mesh synthesizer [Alles](https://github.com/shorepine/alles), as well as the [Tulip Creative Computer](https:/tulip.computer). Let us know if you use AMY for your own projects and we'll add it here! AMY was built by [DAn Ellis](https://research.google/people/DanEllis/) and [Brian Whitman](https://notes.variogram.com), and would love your contributions. [![shore pine sound systems discord](https://raw.githubusercontent.com/shorepine/tulipcc/main/docs/pics/shorepine100.png) **Chat about AMY on our Discord!**](https://discord.gg/TzBFkUb8pG) ## More information * [**Interactive AMY tutorial**](https://shorepine.github.io/amy/tutorial.html) * [**AMY API**](docs/api.md) * [**AMY Synthesizer Details**](docs/synth.md) * [**AMY's MIDI specification**](docs/midi.md) * [**AMY in Arduino Getting Started**](docs/arduino.md) * [**Other AMY web demos**](https://shorepine.github.io/amy/) AMY supports * MIDI input support and synthesizer voice management, including voice stealing, controllers and per-channel multi-timbral operation * A strong Juno-6 style analog synthesizer * An operator / algorithm-based frequency modulation (FM) synth, modeled after the DX-7 * PCM sampler, reading from a baked-in buffer of percussive and misc samples, or by loading samples into RAM, or playing from files on disk directly, with loop points and base midi note * Wavetable oscillator * karplus-strong string with adjustable feedback * An arbitrary number of band-limited oscillators, each with adjustable frequency, pan, phase, amplitude: * pulse (+ adjustable duty cycle), sine, saw (up and down), triangle, noise * Stereo audio input or audio buffers in code can be used as an oscillator for real time audio effects * Biquad low-pass, bandpass or hi-pass filters with cutoff and resonance, can be assigned to any oscillator * Reverb, echo and chorus effects, set globally * An additive partial synthesizer * Each oscillator has 2 envelope generators, which can modify any combination of amplitude, frequency, PWM duty, filter cutoff, or pan over time * Each oscillator can also act as an modulator to modify any combination of parameters of another oscillator, for example, a bass drum can be indicated via a half phase sine wave at 0.25Hz modulating the frequency of another sine wave. * Control of overall gain and 3-band EQ * 300+ built in preset patches for PCM, DX7, piano and Juno-6 * A front end for DX7 and Juno-6 SYSEX patches and conversion setup commands * Built-in event clock and pattern sequencer, using hardware real time timers on microcontrollers * Multi-core (including microcontrollers) for rendering if available * File transfer to the host The FM synth provides a Python library, [`fm.py`](https://github.com/shorepine/amy/blob/main/amy/fm.py) that can convert any DX7 patch into an AMY patch. The Juno-6 emulation provides [`juno.py`](https://github.com/shorepine/amy/blob/main/amy/juno.py) and can read in Juno-6 SYSEX patches and convert them into AMY patches. [The partials-driven piano voice and the code to generate the partials are described here](https://shorepine.github.io/amy/piano.html). ## Using AMY in Arduino AMY will run on many modern microcontrollers under Arduino. On most platforms, we handle sending audio out to an I2S interface and handling MIDI input. Some platforms support more features than others. **Please see our more detailed [Getting Started on Arduino](docs/arduino.md) page for more details.** ## Using AMY in Python on any platform You can `import amy` in Python and have it render either out to your speakers or to a buffer of samples you can process on your own. To install the `amy` library, run `pip install .`. You can also run `make test` to install the library and run a series of tests. [**Please see our interactive AMY tutorial for more tips on using AMY**](https://shorepine.github.io/amy/tutorial.html) ## Using AMY on the web We provide an `emscripten` port of AMY that runs in Javascript. [See the AMY web demos](https://shorepine.github.io/amy/). To build for the web, use `make docs/amy.js`. It will generate `amy.js` in `docs/`. ## Using AMY in any other software To use AMY in your own software, simply copy the .c and .h files in `src` to your program and compile them. No other libraries should be required to synthesize audio in AMY. To run a simple C example on many platforms: ``` make ./amy-example # you should hear tones out your default speaker, use ./amy-example -h for options ``` # AMY quickstart [**Please see our interactive AMY tutorial for more tips on using AMY**](https://shorepine.github.io/amy/tutorial.html) ## MIDI mode AMY provides a [MIDI mode](docs/midi.md) by default that lets you control many parts of AMY over MIDI. You can even control the underlying oscillators over SYSEX. See our [MIDI documentation](docs/midi.md) for more details. The simplest way to use AMY is to start it and them play MIDI notes to it. By default, AMY boots with a Juno-6 patch 0 on MIDI channel 1. In Python: ```python >>> import amy; amy.live(default_synths=1) >>> # play MIDI notes using system MIDI ``` In C: ```c amy_config = amy_default_config() amy_start(amy_config); amy_live_start(); // play MIDI notes using system MIDI or UART MIDI on microcontrollers ``` In Javascript (see [minimal.html](docs/minimal.html) for the full example): ```html ``` AMY supports [note commands, some MIDI controllers, and program changes to change the patch.](docs/midi.md) ## Controlling AMY in code Presumably you'd like to explicitly tell AMY what to play. You can control AMY from almost anything. We mostly work in Python, C or Javascript, but AMY has been built to work with anything that can send a string. AMY has two API interfaces: _wire messages_ and `amy_event`. An AMY wire message is a string that looks like `v0n50l1K130r0Z`, with each letter corresponding to a field (like `v0` means `oscillator 0`, `n50` means midi note 50, `K130` means patch number 130, etc.) Wire messages are converted into `amy_event`s within AMY once received. So in C, or JS, you'd fill an `amy_event` struct to define a single event of the synthesizer. For example, that wire message above is: ```c amy_event e = amy_default_event(); e.osc = 0; e.patch_number = 130; e.velocity = 1; e.midi_note = 50; e.voices[0] = 0; amy_add_event(&e); ``` In Python, we provide the `amy` package that generates wire messages from a Pythonic `amy.send(**kwargs)`. In Python, you'd do ```python amy.send(osc=0, patch = 130, vel = 1, note = 50, voices = [0]) ``` Wire messages are used in AMY as a compact serialization of AMY events and become useful when communicating between AMY and other programs that may not be linked together. For example, [Alles](https://github.com/shorepine/alles) uses wire messages over Wi-Fi UDP to control a mesh of AMY synthesizers. [Tulip Web](https://tulip.computer/run) sends wire messages from the Micropython web process to the AudioWorklet running AMY on the web. We also store the Juno-6 and DX7 patches within AMY itself using wire messages, which helps keep the code size down. You can also send wire messages over SYSEX to AMY, if you want to control AMY over MIDI beyond the default MIDI mode. [See our MIDI documentation for more details.](docs/midi.md) It's good to understand what wire messages are but you don't need to construct them directly if you're linking AMY in your software. Use `amy_event` or `amy.send()` in Python to control AMY for almost all use cases. # More information * [**Interactive AMY tutorial**](https://shorepine.github.io/amy/tutorial.html) * [**AMY API**](docs/api.md) * [**AMY Synthesizer Details**](docs/synth.md) * [**AMY's MIDI specification**](docs/midi.md) * [**AMY in Arduino Getting Started**](docs/arduino.md) * [**AMY in Godot**](docs/godot.md) * [**AMY on Windows**](windows/README.md) * [**Other AMY web demos**](https://shorepine.github.io/amy/) [![shore pine sound systems discord](https://raw.githubusercontent.com/shorepine/tulipcc/main/docs/pics/shorepine100.png) **Chat about AMY on our Discord!**](https://discord.gg/TzBFkUb8pG) ================================================ FILE: amy/__init__.py ================================================ # AMY module from .constants import * from . import examples import collections import time def _get_synth_commands_stub(synth): return [] _get_synth_commands = _get_synth_commands_stub try: import c_amy as _amy # Import the C module live = _amy.live _get_synth_commands = _amy.get_synth_commands except (ImportError, AttributeError): # C module is not required? not available? # I'm guessing this might mean we're on Micropython? try: import tulip _get_synth_commands = tulip.amy_get_synth_commands except (ImportError, AttributeError): pass # Not available (e.g. web build); _get_synth_commands returns [] # If set, inserts func as time for every call to send(). Will not override an explicitly set time insert_time = None # If set, calls this instead of amy.send() override_send = None mess = [] log = False show_warnings = True block_cb = None # Return a millis() epoch number for use in AMY timing # On most computers, this uses ms since midnight using datetime # On things like Tulip, this use ms since boot def millis(): try: import datetime d = datetime.datetime.now() return int((datetime.datetime.utcnow() - datetime.datetime(d.year, d.month, d.day)).total_seconds()*1000) except ImportError: import tulip return tulip.ticks_ms() # Removes trailing 0s and x.0000s from floating point numbers to trim wire message size # Fun historical trivia: this function caused a bug so bad that Dan had to file a week-long PR for micropython # https://github.com/micropython/micropython/pull/8905 def trunc(number): if type(number) == str: if number.strip() == '': return '' number = float(number) if(type(number)==float): return ('%.6f' % number).rstrip('0').rstrip('.') return str(number) def trunc3(number): if(type(number)==float): return ('%.3f' % number).rstrip('0').rstrip('.') return str(number) def trim_trailing(vals, pred): """Remove any contiguous suffix of values that return False under pred.""" bools = [pred(x) for x in vals[::-1]] suffix_len = bools.index(True) if suffix_len: return vals[:-suffix_len] return vals def parse_ctrl_coefs(coefs): """Convert various acceptable forms of ControlCoefficient specs to the canonical string. ControlCoefficients determine how amplitude, frequency, filter frequency, PWM duty, and pan are calculated from underlying parameters on the fly. For each control input, they specify nine coefficients which are multiplied by (0) a constant value of 1, (1) the log-frequency from the note-on command, (2) the velocity from the note-on command, (3) Envelope Generator 0's value, (4) Envelope Generator 1's value, (5) the modulating oscillator input, (6) the global pitch bend value, (7) external input 0, and (8) external input 1. The sum of these scaled values is used as the control input. (Amplitude is a special case where the individual values are *multiplied* rather than added, and values whose coefficients are zero are skipped). The wire protocol expects these coefficients to be specified as a single vector, e.g. "f220,1,0,0,0,0,1". It also accepts some values to be left unspecified; only the specified values are changed. So "f,,,,0.01" will add EG1 modulation to pitch but not change its base value etc. As a special case, a single value (e.g. "f440") will change the constant offset for a parameter but leave its other modulations in place. The Python API accepts multiple kinds of input: * A scalar numeric value: freq=440 * A list of values in the format accepted by the wire protocol: freq=',,,,0.01'. * A Python list of values, where None can be used to indicate "unspecified": freq=[None, None, None, None, 0.01]. Where the list is shorter than the expected 7 values, the remainder are treated as None (analogous to the wire-protocol string). * A Python dict providing values for some subset of the coefficients. The only acceptable keys are 'const', 'note', 'vel', 'eg0', 'eg1', 'mod', 'bend', 'ext0', and 'ext1'. """ # Pass through ready-formed strings, and convert single values to single value strings if isinstance(coefs, str): return ','.join(trunc(x) for x in coefs.split(',')) if isinstance(coefs, int) or isinstance(coefs, float): return trunc(coefs) # Convert a dict into a list of values. dict_fields = ['const', 'note', 'vel', 'eg0', 'eg1', 'mod', 'bend', 'ext0', 'ext1'] if isinstance(coefs, dict): coef_list = [None] * len(dict_fields) for key, value in coefs.items(): if key not in dict_fields: raise ValueError('\'%s\' is not a recognized CtrlCoef field %s' % (key, str(dict_fields))) coef_list[dict_fields.index(key)] = value coefs = coef_list assert isinstance(coefs, list) coefs = trim_trailing(coefs, lambda x: x is not None) def to_str(x): if x is None: return '' return str(x) return ','.join([to_str(x) for x in coefs]) def parse_list_or_comma_string(obj): def str_none_is_empty(s): if s is None: return "" return str(s) if isinstance(obj, list): return ','.join(map(str_none_is_empty, obj)) return str(obj) def str_of_int(arg): """Cast arg to an int, but then convert it to a str for the wire string.""" return str(int(arg)) _KW_MAP_LIST = [ # Order matters because patch_string must come last. ('osc', 'vI'), ('wave', 'wI'), ('note', 'nF'), ('vel', 'lF'), ('amp', 'aC'), ('freq', 'fC'), ('duty', 'dC'), ('feedback', 'bF'), ('time', 'tI'), ('reset', 'SI'), ('phase', 'PF'), ('pan', 'QC'), ('client', 'gI'), ('volume', 'VF'), ('pitch_bend', 'sF'), ('filter_freq', 'FC'), ('resonance', 'RF'), ('bp0', 'AL'), ('bp1', 'BL'), ('eg0', 'AL'), ('eg1', 'BL'), # Aliases for bp0 and bp1 ('eg0_type', 'TI'), ('eg1_type', 'XI'), ('debug', 'DI'), ('chained_osc', 'cI'), ('mod_source', 'LI'), ('eq', 'xL'), ('filter_type', 'GI'), ('ratio', 'IF'), ('latency_ms', 'NI'), ('algo_source', 'OL'), ('load_sample', 'zL'), ('transfer_file', 'zTL'), ('disk_sample', 'zFL'), ('algorithm', 'oI'), ('chorus', 'kL'), ('reverb', 'hL'), ('echo', 'ML'), ('patch', 'KI'), ('voices', 'rL'), ('external_channel', 'WI'), ('portamento', 'mI'), ('sequence', 'HL'), ('tempo', 'jF'), ('synth', 'iI'), ('pedal', 'ipI'), ('synth_flags', 'ifI'), ('num_voices', 'ivI'), ('oscs_per_voice', 'inI'), ('to_synth', 'itI'), ('grab_midi_notes', 'imI'), ('synth_delay', 'idI'), ('preset', 'pI'), ('num_partials', 'pI'), # note aliasing ('start_sample', 'zSL'), ('stop_sample', 'zOI'), ('midi_cc', 'icL'), ('patch_string', 'uS'), # patch_string MUST be last because we can't identify when it ends except by end-of-message. ] _KW_PRIORITY = {k: i for i, (k, _) in enumerate(_KW_MAP_LIST)} # Maps each key to its index within _KW_MAP_LIST. _KW_MAP = dict(_KW_MAP_LIST) _ARG_HANDLERS = { 'I': str_of_int, 'F': trunc, 'S': str, 'L': parse_list_or_comma_string, 'C': parse_ctrl_coefs, } # Construct an AMY message def message(**kwargs): #print("message:", kwargs) # Each keyword maps to two or three chars, first one or two are the wire protocol prefix, last is an arg type code # I=int, F=float, S=str, L=list, C=ctrl_coefs global show_warnings, _KW_MAP, _KW_PRIORITY, _ARG_HANDLERS if show_warnings: # Check for possible user confusions. if 'voices' in kwargs and 'preset' in kwargs and 'osc' not in kwargs: print('You specified \'voices\' and \'preset\' but not \'osc\' so your command will apply to the voice\'s osc 0.') if 'voices' in kwargs and 'synth' in kwargs and not ('patch' in kwargs or 'patch_string' in kwargs): print('You specified both \'synth\' and \'voices\' in a non-\'patch\'/\'patch_string\' message, but \'synth\' defines the voices.') if 'patch_string' in kwargs and not ('patch' in kwargs or 'synth' in kwargs or 'voices' in kwargs): print('\'patch_string\' is only valid with a \'patch\' or to define a new \'synth\' or \'voices\'.') # And yet we plow ahead... if 'patch_string' in kwargs: # Try to avoid mistakenly calling 'patch_string' when you meant 'patch'. if not isinstance(kwargs['patch_string'], str): raise ValueError('\'patch_string\' should be a wire command string, not \'' + str(kwargs['patch_string']) + '\'.') if 'num_partials' in kwargs: if 'preset' in kwargs: raise ValueError('You cannot use \'num_partials\' and \'preset\' in the same message.') if 'wave' not in kwargs or kwargs['wave'] != BYO_PARTIALS: raise ValueError('\'num_partials\' must be used with \'wave\'=BYO_PARTIALS.') if(insert_time is not None and 'time' not in kwargs): kwargs['time'] = insert_time() # Validity check all the passed args. prioritized_keys = [] for key, arg in kwargs.items(): if key not in _KW_MAP: raise ValueError('Unknown keyword ' + key) priority = _KW_PRIORITY[key] if arg is None: # Ignore time=None or sequence=None if key != 'time' and key != 'sequence': raise ValueError('No arg for key ' + key) else: prioritized_keys.append((priority, key)) # Sort by priority, then strip the priority value. prioritized_keys = [e[1] for e in sorted(prioritized_keys)] # We process the passed args by testing each entry in the known keys in order, to make sure 'patch_string' is added last. m = '' for key in prioritized_keys: map_code = _KW_MAP[key] arg = kwargs[key] type_code = map_code[-1] wire_code = map_code[:-1] m += wire_code + _ARG_HANDLERS[type_code](arg) #print("message:", m) return m + 'Z' def send_raw(m): # override_send is used by e.g. Tulip, to send messages in a different way than C or UDP global mess, log global override_send if(override_send is not None): override_send(m) else: _amy.send_wire(m) if(log): mess.append(m) def log_patch(): global mess, log # start recording a patch log = True mess = [] def retrieve_patch(): global mess, log log = False s = "".join(mess) mess =[] return s # Convenience function to store an in-memory AMY patch # Call this, then call stop_store_patch(patch_number) when you're done saved_override = None def amy_do_nothing(message): return def start_store_patch(): global saved_override, override_send saved_override = override_send override_send = amy_do_nothing log_patch() def stop_store_patch(patch): global saved_override, override_send override_send = saved_override m = "u"+str(patch)+retrieve_patch() send_raw(m) # Send an AMY message to amy def send(**kwargs): m = message(**kwargs) send_raw(m) # Plots a time domain and spectra of audio def show(data): import matplotlib.pyplot as plt import numpy as np fftsize = len(data) windowlength = fftsize window = np.hanning(windowlength) wavepart = data[:len(window)] logspecmag = 20 * np.log10(np.maximum(1e-10, np.abs(np.fft.fft(wavepart * window)))[:(fftsize // 2 + 1)]) freqs = AMY_SAMPLE_RATE * np.arange(len(logspecmag)) / fftsize plt.subplot(211) times = np.arange(len(wavepart)) / AMY_SAMPLE_RATE plt.plot(times, wavepart, '.') plt.subplot(212) plt.plot(freqs, logspecmag, '.-') plt.ylim(np.array([-100, 0]) + np.max(logspecmag)) plt.show() # Writes a WAV file of rendered data def write(data, filename): import scipy.io.wavfile as wav import numpy as np wav.write(filename, int(AMY_SAMPLE_RATE), (32768.0 * data).astype(np.int16)) # Play a rendered sound out of default sounddevice def play(samples): import sounddevice as sd sd.play(samples) # Render AMY's internal buffer to a numpy array of floats def render(seconds): import numpy as np # Output a npy array of samples frame_count = int((seconds*AMY_SAMPLE_RATE)/AMY_BLOCK_SIZE) frames = [] for f in range(frame_count): frames.append( np.array(_amy.render_to_list())/32768.0 ) return np.hstack(frames).reshape((-1, AMY_NCHANS)) def restart(default_synths=0): _amy.stop() _amy.start(default_synths) def inject_midi(a, b, c, d=None): if d is None: _amy.inject_midi(a, b, c) else: _amy.inject_midi(a, b, c, d) def unload_sample(patch=0): s= "%d,%d" % (patch, 0) send(load_sample=s) print("Patch %d unloaded from RAM" % (patch)) # For AMYBoard and other AMYs that can get messages over MIDI sysex # AMYboard is the name of the default AMYboard USB over MIDI device. # If you're using another MIDI device, set output_name to it # Use this like amy.override_send = sysex_write def sysex_write(message, output_name='AMYboard'): import mido outputs = mido.get_output_names() target_name = None for name in outputs: if output_name in name: target_name = name break if target_name is None: print("Could not find %s MIDI") if isinstance(message, str): payload = message.encode('ascii') elif isinstance(message, bytes): payload = message # AMY sysex message data = [0x00, 0x03, 0x45] + list(payload) with mido.open_output(target_name) as out: m = mido.Message('sysex', data=data) out.send(m) # This sleep is because there's not really a buffer per-se for SYSEX over CDC time.sleep(0.01) try: import base64 def b64(b): return base64.b64encode(b) except ImportError: import ubinascii def b64(b): return ubinascii.b2a_base64(b)[:-1] def start_sample(preset=0, bus=1, max_frames=0, midinote=60, loopstart=0, loopend=0): s = "%d,%d,%d,%d,%d,%d" % (preset, bus, max_frames, midinote, loopstart, loopend) send(start_sample=s) def stop_sample(): send(stop_sample=1) def load_sample_bytes(b, stereo=False, preset=0, midinote=60, loopstart=0, loopend=0, sr=AMY_SAMPLE_RATE): # takes in a python bytes obj instead of filename from math import ceil if(stereo): # just choose first channel b = bytes([b[j] for i in range(0,len(b),4) for j in (i,i+1)]) n_frames = len(b)/2 s = "%d,%d,%d,%d,%d,%d" % (preset, n_frames, sr, midinote, loopstart, loopend) send(load_sample=s) last_f = 0 for i in range(ceil(n_frames/94)): frames_bytes = b[last_f:last_f+188] message = b64(frames_bytes) send_raw(message.decode('ascii')) last_f = last_f + 188 def disk_sample(wavfilename, preset=0, midinote=60): try: from tulip import board if board() == "WEB": # On web, we just use memorypcm as we can't directly accesss FS from amy-web load_sample(wavfilename, preset, midinote) return except ImportError: pass # It's ok, just means we are not under tulip or amyboard web s = "%d,%s,%d" % (preset, wavfilename, midinote) send(disk_sample=s) def transfer_file(source_filename, dest_filename=None): import os from math import ceil if(dest_filename is None): dest_filename = source_filename file_size = os.path.getsize(source_filename) s = "%s,%d" % (dest_filename, file_size) send(transfer_file=s) # Now generate the base64 encoded segments, 188 bytes at a time # why 188? that generates 252 bytes of base64 text. amy's max message size is currently 255. # Use the _from_sysex variant so the chunks are routed to # parse_transfer_message via the amy_parsing_from_sysex flag. Internal # amy.send() calls from other contexts (e.g. a sketch's loop() on # AMYboard hardware running during a live transfer) use the regular # path and won't be mis-interpreted as transfer data. w = open(source_filename, 'rb') for i in range(ceil(file_size/188)): file_bytes = w.read(188) message = b64(file_bytes) if override_send is not None: override_send(message.decode('ascii')) else: _amy.send_wire_from_sysex(message.decode('ascii')) w.close() def load_sample(wavfilename, preset=0, midinote=0, loopstart=0, loopend=0): from math import ceil from . import wave # tulip has ubinascii, normal has base64 w = wave.open(wavfilename, 'r') if(loopstart==0): if(hasattr(w,'_loopstart')): loopstart = w._loopstart if(loopend==0): if(hasattr(w,'_loopend')): loopend = w._loopend if(midinote==0): if(hasattr(w,'_midinote')): midinote = w._midinote else: midinote=60 # Tell AMY we're sending over a sample s = "%d,%d,%d,%d,%d,%d" % (preset, w.getnframes(), w.getframerate(), midinote, loopstart, loopend) send(load_sample=s) # Now generate the base64 encoded segments, 188 bytes / 94 frames at a time # why 188? that generates 252 bytes of base64 text. amy's max message size is currently 255. for i in range(ceil(w.getnframes()/94)): frames_bytes = w.readframes(94) if(w.getnchannels()==2): # de-interleave and just choose the first channel frames_bytes = bytes([frames_bytes[j] for i in range(0,len(frames_bytes),4) for j in (i,i+1)]) message = b64(frames_bytes) send_raw(message.decode('ascii')) print("Loaded sample over wire protocol. Preset #%d. %d bytes, %d frames, midinote %d" % (preset, w.getnframes()*2, w.getnframes(), midinote)) """ Convenience functions """ def reset(osc=None, **kwargs): if(osc is not None): send(reset=osc, **kwargs) else: send(reset=RESET_ALL_OSCS, **kwargs) """ Chorus control """ def chorus(level=-1, max_delay=-1, freq=-1, amp=-1): chorus_level = '' chorus_delay = '' chorus_freq = '' chorus_depth = '' if (level >= 0): chorus_level = str(level) if (max_delay >= 0): chorus_delay = str(max_delay) if (freq >= 0): chorus_freq = str(freq) if (amp >= 0): chorus_depth = str(amp) chorus_arg = "%s,%s,%s,%s" % (chorus_level, chorus_delay, chorus_freq, chorus_depth) send(chorus=chorus_arg) """ Reverb control """ def reverb(level=-1, liveness=-1, damping=-1, xover_hz=-1): reverb_level = '' reverb_liveness = '' reverb_damping = '' reverb_xover = '' if (level >= 0): reverb_level = str(level) if (liveness >= 0): reverb_liveness = str(liveness) if (damping >= 0): reverb_damping = str(damping) if (xover_hz >= 0): reverb_xover = str(xover_hz) reverb_arg = "%s,%s,%s,%s" % (reverb_level, reverb_liveness, reverb_damping, reverb_xover) send(reverb=reverb_arg) """ Echo control """ def echo(level=None, delay_ms=None, max_delay_ms=None, feedback=None, filter_coef=None): echo_level = '' echo_delay_ms = '' echo_max_delay_ms = '' echo_feedback = '' echo_filter_coef = '' if level is not None: echo_level = str(level) if delay_ms is not None: echo_delay_ms = str(delay_ms) if max_delay_ms is not None: echo_max_delay_ms = str(max_delay_ms) if feedback is not None: echo_feedback = str(feedback) if filter_coef is not None: echo_filter_coef = str(filter_coef) echo_arg = '%s,%s,%s,%s,%s' % (echo_level, echo_delay_ms, echo_max_delay_ms, echo_feedback, echo_filter_coef) send(echo=echo_arg) """ Reading back synth configuration """ def get_synth_commands(synth, patch_num=None, dest_synth=None, num_voices=6, include_fx=True, time=None): if patch_num is not None and dest_synth is not None: raise ValueError("At most one of patch_num and dest_synth can be specified") commands = _get_synth_commands(synth, include_fx) def len_digit_prefix(s): len = 0 while s[len] in '0123456789': len += 1 return len # Scan for number of oscs num_oscs = 0 for command in commands: if command[0] == 'v': osc_num = int(command[1: 1 + len_digit_prefix(command[1:])]) if num_oscs < osc_num + 1: num_oscs = osc_num + 1 # Build total command string including prefix depending on use. prefix = "t%d" % time if time is not None else "" prologue = [] if patch_num: # Start by resetting the patch. prologue = [prefix + "S%dk%dZ" % (RESET_PATCH, patch_num)] prefix += "K%d" % patch_num if dest_synth: # Prepend command to reset the synth. prologue = [prefix + "i%div%din%dZ" % (dest_synth, num_voices, num_oscs)] prefix += "i%d" % dest_synth return "\n".join(prologue + [prefix + command for command in commands]) ================================================ FILE: amy/constants.py ================================================ MAX_FILENAME_LEN=127 AMY_BLOCK_SIZE=128 BLOCK_SIZE_BITS=7 AMY_BLOCK_SIZE=256 BLOCK_SIZE_BITS=8 AMY_SAMPLE_RATE=48000 AMY_SAMPLE_RATE=48000 AMY_SAMPLE_RATE=44100 PCM_AMY_SAMPLE_RATE=22050 AMY_TRANSFER_TYPE_NONE=0 AMY_TRANSFER_TYPE_AUDIO=1 AMY_TRANSFER_TYPE_FILE=2 AMY_TRANSFER_TYPE_SAMPLE=3 AMY_PCM_TYPE_ROM=0 AMY_PCM_TYPE_FILE=1 AMY_PCM_TYPE_MEMORY=2 PCM_FILE_BUFFER_MULT=8 AMY_BUS_OUTPUT=1 AMY_BUS_AUDIO_IN=2 AMY_MAX_CORES=2 AMY_MAX_CHANNELS=2 AMY_NCHANS=2 AMY_CORES=2 AMY_CORES=1 AMY_MIDI_CHANNEL_DRUMS=10 MALLOC_CAP_DEFAULT=0 CHORUS_DEFAULT_LFO_FREQ=0.5 CHORUS_DEFAULT_MOD_DEPTH=0.5 CHORUS_DEFAULT_LEVEL=0 CHORUS_DEFAULT_MAX_DELAY=320 EQ_CENTER_LOW=800.0 EQ_CENTER_MED=2500.0 EQ_CENTER_HIGH=7000.0 REVERB_DEFAULT_LEVEL=0 REVERB_DEFAULT_LIVENESS=0.85 REVERB_DEFAULT_DAMPING=0.5 REVERB_DEFAULT_XOVER_HZ=3000.0 ECHO_DEFAULT_LEVEL=0 ECHO_DEFAULT_DELAY_MS=500. ECHO_DEFAULT_MAX_DELAY_MS=743. ECHO_DEFAULT_FEEDBACK=0 ECHO_DEFAULT_FILTER_COEF=0 AMY_SEQUENCER_PPQ=48 DELAY_LINE_LEN=512 CLIP_D=0.1 MAX_VOLUME=11.0 AMP_THRESH=0.001 AMP_THRESH_PLUS=0.0011 SAMPLE_MAX=32767 MAX_ALGO_OPS=6 DEFAULT_NUM_BREAKPOINTS=8 MAX_BREAKPOINTS=24 MAX_BREAKPOINT_SETS=2 THREAD_USLEEP=500 AMY_BYTES_PER_SAMPLE=2 MAX_VOICES_PER_INSTRUMENT=32 FILT_NUM_DELAYS=4 ZERO_HZ_LOG_VAL=-99.0 ZERO_LOGFREQ_IN_HZ=440.0 ZERO_MIDI_NOTE=69 MIN_FILTER_LOGFREQ=-2.75 NUM_COMBO_COEFS=9 MAX_MESSAGE_LEN=1024 MAX_PARAM_LEN=256 FILTER_NONE=0 FILTER_LPF=1 FILTER_BPF=2 FILTER_HPF=3 FILTER_LPF24=4 SINE=0 PULSE=1 SAW_DOWN=2 SAW_UP=3 TRIANGLE=4 NOISE=5 KS=6 PCM=7 ALGO=8 PARTIAL=9 BYO_PARTIALS=10 INTERP_PARTIALS=11 AUDIO_IN0=12 AUDIO_IN1=13 AUDIO_EXT0=14 AUDIO_EXT1=15 AMY_MIDI=16 PCM_LEFT=17 PCM_RIGHT=18 PCM_MIX=7 WAVETABLE=19 SILENT=20 CUSTOM=21 WAVE_OFF=22 SYNTH_OFF=0 SYNTH_AUDIBLE=1 SYNTH_INAUDIBLE=2 SYNTH_IS_MOD_SOURCE=3 SYNTH_IS_ALGO_SOURCE=4 EVENT_EMPTY=0 EVENT_SCHEDULED=1 EVENT_TRANSFER_DATA=2 EVENT_SEQUENCE=3 NOTE_SOURCE_MIDI=2 ENVELOPE_NORMAL=0 ENVELOPE_LINEAR=1 ENVELOPE_DX7=2 ENVELOPE_TRUE_EXPONENTIAL=3 SEQUENCE_TICK=0 SEQUENCE_PERIOD=1 SEQUENCE_TAG=2 RESET_SEQUENCER=4096 RESET_ALL_OSCS=8192 RESET_TIMEBASE=16384 RESET_AMY=32768 RESET_EVENTS=65536 RESET_ALL_NOTES=131072 RESET_SYNTHS=262144 RESET_PATCH=524288 RESET_QUEUE=1048576 true=1 false=0 AMY_OK=0 AMY_AUDIO_IS_NONE=0x00 AMY_AUDIO_IS_I2S=0x01 AMY_AUDIO_IS_USB_GADGET=0x02 AMY_AUDIO_IS_MINIAUDIO=0x04 AMY_MIDI_IS_NONE=0x0 AMY_MIDI_IS_UART=0x01 AMY_MIDI_IS_USB_GADGET=0x02 AMY_MIDI_IS_MACOS=0x04 AMY_MIDI_IS_WEBMIDI=0x08 AMYBOARD_LRC=2 AMYBOARD_BCLK=8 AMYBOARD_DOUT=6 AMYBOARD_DIN=9 AMYBOARD_MCLK=3 AMYBOARD_MIDI_OUT_TYPE_A=14 AMYBOARD_MIDI_OUT_TYPE_B=15 AMYBOARD_MIDI_IN=21 ================================================ FILE: amy/examples.py ================================================ #!/usr/bin/env python3 # examples.py # sound examples and patch examples import amy from time import sleep class Patch: """ Provides a collection of illustrations of different voice configurations with AMY. You use them like this: amy.send(synth=0, num_voices=4, patch=patches.filter_bass()) """ next_patch_number = 1024 @classmethod def _new_patch_number(cls): # just keep a global patch num around for these patches new_num = cls.next_patch_number cls.next_patch_number = cls.next_patch_number + 1 return new_num @classmethod def reset(cls): cls.next_patch_number = 1024 def __init__(self, **kwargs): self.patch_number = Patch._new_patch_number() self.setup(**kwargs) def __int__(self): # When amy.message() tries to convert this into an int, just return the patch number. return self.patch_number def setup(self, **kwargs): raise ValueError('Subclasses of Patch must define a setup(self, **kwargs) method.') class simple_sine(Patch): def setup(self, **kwargs): amy.send(patchr=self.patch_number, wave=amy.SINE, bp0="10,1,240,0.7,500,0", **kwargs) class filter_bass(Patch): def setup(self, **kwargs): amy.send(patch=self.patch_number, osc=0, filter_freq="100,0,0,5", resonance=5, wave=amy.SAW_DOWN, filter_type=amy.FILTER_LPF, bp0="0,1,1000,0,100,0", **kwargs) class amp_lfo(Patch): def setup(self, **kwargs): # Not clear what to do with kwargs. They probably don't want to apply to both oscs. amy.send(patch=self.patch_number, osc=1, wave=amy.SINE, amp=0.50, freq=1.5, **kwargs) amy.send(patch=self.patch_number, osc=0, wave=amy.PULSE, bp0="150,1,1850,0.25,250,0", amp="0,0,1,1,0,1", mod_source=1, **kwargs) class pitch_lfo(Patch): def setup(self, **kwargs): amy.send(patch=self.patch_number, osc=1, wave=amy.SINE, amp=0.50, freq=0.25, **kwargs) amy.send(patch=self.patch_number, osc=0, wave=amy.PULSE, bp0="150,1,250,0,0,0", freq="261.63,1,0,0,0,1", mod_source=1, **kwargs) class bass_drum(Patch): def setup(self, **kwargs): # Uses a 0.25Hz sine wave at 0.5 phase (going down) to modify frequency of another sine wave amy.send(patch=self.patch_number, osc=1, wave=amy.SINE, amp=0.50, freq=0.25, phase=0.5, **kwargs) amy.send(patch=self.patch_number, osc=0, wave=amy.SINE, bp0="0,1,500,0,0,0", freq="261.63,1,0,0,0,1", mod_source=1, **kwargs) class noise_snare(Patch): def setup(self, **kwargs): amy.send(patch=self.patch_number, osc=0, wave=amy.NOISE, bp0="0,1,250,0,0,0", **kwargs) class closed_hat(Patch): def setup(self, **kwargs): amy.send(patch=self.patch_number, osc=0, wave=amy.NOISE, bp0="5,1,30,0,0,0", filter_type=amy.FILTER_HPF, filter_freq=6000, **kwargs) """ Various python examples of using AMY, including the port of all the C examples.c """ # Plays the example patches defined in this file def play_example_patches(wait=1, **kwargs): from . import examples try: patchClasses = examples.Patch.__subclasses__() except AttributeError: # micropython does not have __subclasses__ patchClasses = [ examples.simple_sine, examples.filter_bass, examples.amp_lfo, examples.pitch_lfo, examples.bass_drum, examples.noise_snare, examples.closed_hat, ] for patchClass in patchClasses: print("Patch", patchClass.__name__) send(synth=0, num_voices=1, patch=patchClass()) time.sleep(wait/4.0) send(synth=0, note=50, vel=1, **kwargs) time.sleep(wait) send(synth=0, vel=0) time.sleep(wait/4.0) # Plays the baked in Juno, DX7 and piano patches def play_baked_patches(wait=1, patch_total = 256, **kwargs): import random patch_count = 0 while True: patch = random.randint(0,256) #patch_count % patch_total print("Sending patch %d" % patch) send(synth=0, num_voices=1, patch=patch) time.sleep(wait/4.0) send(synth=0, note=50, vel=1, **kwargs) time.sleep(wait) send(synth=0, vel=0) time.sleep(wait/4.0) def example_multimbral_synth(): amy.send(patch=4, num_voices=6, synth=1) # juno-6 preset 4 on MIDI channel 1 amy.send(patch=129, num_voices=2, synth=2) # dx7 preset 1 on MIDI channel 2 amy.send(synth=3, num_voices=4, patch=filter_bass()) # filter bass user patch on MIDI channel 3 amy.send(synth=4, num_voices=4, patch=pitch_lfo()) # pitch LFO user patch on MIDI channel 4 def example_reset(start=0): amy.send(osc=0, reset=amy.RESET_ALL_OSCS, time=start) def example_voice_alloc(): # alloc 2 juno voices, then try to alloc a dx7 voice on voice 0 amy.send(patch=1, voices=[0, 1]) sleep(0.25) amy.send(patch=131, voices=[0]) sleep(0.25) # play the same note on both amy.send(vel=1, note=60, voices=[0]) sleep(2) amy.send(vel=1, note=60, voices=[1]) sleep(2) # now try to alloc voice 0 with a juno, should use oscs 0-4 again amy.send(patch=2, voices=[0]) sleep(0.25) def example_voice_chord(patch=0): amy.send(patch=patch, voices=[0, 1, 2]) sleep(.250) amy.send(vel=0.5, voices=[0], note=50) sleep(1) amy.send(vel=0.5, voices=[1], note=54) sleep(1) amy.send(vel=0.5, voices=[2], note=56) sleep(2) amy.send(vel=0, voices=[0, 1, 2]) def example_synth_chord(patch=0): # Like example_voice_chord, but use 'synth' to avoid having to keep track of voices amy.send(patch=patch, num_voices=3, synth=0) sleep(1) amy.send(vel=0.5, synth=0, note=50) sleep(1) amy.send(vel=0.5, synth=0, note=54) sleep(1) amy.send(vel=0.5, synth=0, note=56) sleep(1) # Voices are referenced only by their note, so have to turn them off individually amy.send(vel=0, synth=0, note=50) amy.send(vel=0, synth=0, note=54) amy.send(vel=0, synth=0, note=56) def example_sustain_pedal(patch=0): # Reset all oscillators first amy.send(reset=amy.RESET_ALL_OSCS) amy.send(synth=1, num_voices=4, patch=patch) sleep(0.05) amy.send(synth=1, note=76, vel=1.0) sleep(0.05) amy.send(synth=1, note=76, vel=0) sleep(0.05) amy.send(synth=1, pedal=127) sleep(0.05) amy.send(synth=1, note=63, vel=1.0) sleep(0.05) amy.send(synth=1, note=63, vel=0) sleep(0.05) amy.send(synth=1, note=67, vel=1.0) sleep(0.05) amy.send(synth=1, note=67, vel=0) sleep(0.05) amy.send(synth=1, note=72, vel=1.0) sleep(0.05) amy.send(synth=1, pedal=0) sleep(0.05) amy.send(synth=1, note=72, vel=0) def example_patches(): for i in range(256): amy.send(patch=i, voices=[0]) print(f"sending patch {i}") sleep(0.25) amy.send(voices=[0], osc=0, note=50, vel=0.5) sleep(1) amy.send(voices=[0], vel=0) sleep(0.25) amy.reset() def example_reverb(): amy.reverb(2, amy.REVERB_DEFAULT_LIVENESS, amy.REVERB_DEFAULT_DAMPING, amy.REVERB_DEFAULT_XOVER_HZ) def example_chorus(): amy.chorus(0.8, amy.CHORUS_DEFAULT_MAX_DELAY, amy.CHORUS_DEFAULT_LFO_FREQ, amy.CHORUS_DEFAULT_MOD_DEPTH) def example_ks(): amy.send(vel=1, wave=amy.KS, feedback=0.996, preset=15, osc=0, note=60) def example_sine(): amy.send(freq=[440], wave=amy.SINE, vel=1) def example_multimbral_fm(): notes = [60, 70, 64, 68, 72, 82] for i, note in enumerate(notes): # Two amy sends, one to load the patch, one to play it amy.send(voices=[i], patch=128+i) amy.send(voices=[i], note=note, vel=0.5, pan=[i*2]) sleep(1) def example_sequencer_drums(): # Reset all oscillators amy.send(reset=amy.RESET_ALL_OSCS) amy.send(tempo=120.0) # Setup oscs for bd, snare, hat, cow, hicow oscs = [0, 1, 2, 3, 4] presets = [1, 5, 0, 10, 10] for osc, preset in zip(oscs, presets): amy.send(osc=osc, wave=amy.PCM, preset=preset) # Update high cowbell amy.send(osc=4, note=70) # Add patterns # Hi hat every 1/8th note amy.send(sequence=[0, 24, 0], osc=2, vel=2.0) # Bass drum every quarter note amy.send(sequence=[0, 96, 1], osc=0, vel=1.0) # Snare every quarter note, counterphase to BD amy.send(sequence=[24, 96, 2], osc=1, vel=1.0) # Cow once every other cycle amy.send(sequence=[0, 192, 3], osc=3, vel=1.0) def example_fm(): amy.reset() # Modulating oscillator (op 2) amy.send(osc=9, wave=amy.SINE, ratio=1.0, amp=[1.0, None, 0, 0]) # Output oscillator (op 1) amy.send(osc=8, wave=amy.SINE, ratio=0.2, amp=[1.0, None, 0, 1.0], bp0="0,1,1000,0,0,0") # ALGO control oscillator amy.send(osc=7, wave=amy.ALGO, algorithm=1, algo_source=[0, 0, 0, 0, 9, 8]) # Only indices 4 and 5 matter here # Add a note on event sleep(.1) amy.send(osc=7, note=60, vel=2.0) def example_patch_from_events(): number = 1039 amy.send(patch=number, reset=amy.RESET_PATCH) amy.send(patch=number, osc=0, wave=amy.SAW_DOWN, chained_osc=1, bp0="0,1,1000,0.1,200,0") amy.send(patch=number, osc=1, wave=amy.SINE, freq=[131.0], bp0="0,1,500,0,200,0") amy.send(synth=0, num_voices=4, patch=number) sleep(.1) amy.send(synth=0, note=60, vel=1.0) sleep(.3) amy.send(synth=0, note=64, vel=1.0) sleep(.2) amy.send(synth=0, note=67, vel=1.0) sleep(.3) amy.send(synth=0, vel=0.0) ================================================ FILE: amy/fm.py ================================================ # fm.py # Some code to try to convert DX7 patches into AMY commands import numpy as np import time import amy from dataclasses import dataclass from typing import List @dataclass class DX7Operator: """Per-operator parameters for DX7 patches.""" opnum: int = 0 rates: List[int] = None # 4 levels: List[int] = None # 4 breakpoint: int = 0 bp_depths: List[int] = None # 2 bp_curves: List[int] = None # 2 kbdratescaling: int = 0 ampmodsens: int = 0 keyvelsens: int = 0 ratiotuning: bool = False freq_coarse: int = 0 freq_fine: int = 0 freq_detune: int = 0 opamp: int = 0 @dataclass class DX7Patch: """Encapsulates information in a DX7 Patch.""" ops: List[DX7Operator] = None pitch_rates: List[int] = None # 4 pitch_levels: List[int] = None # 4 algo: int = 0 # 1-32 feedback: int = 0 oscsync: int = 0 lfospeed: int = 0 lfodelay: int = 0 lfopitchmoddepth: int = 0 lfoampmoddepth: int = 0 lfosync: int = 0 lfowaveform: int = 0 pitchmodsens: int = 0 transpose: int = 0 name: str = "" @staticmethod def from_patch_number(patch_number): # returns a patch (as in patches.h) from # default-dx7-patches.bin generated by dx7db, see https://github.com/bwhitman/learnfm f = bytes(open("amy/default-dx7-patches.bin", mode="rb").read()) patch_data = f[patch_number*156:patch_number*156+156] return DX7Patch.from_bytestream(bytearray(patch_data)) @staticmethod def from_bytestream(bytestream): """Simply reformat the bytestream into parameters.""" result = DX7Patch() bytestream = bytes(bytestream) byteno = 0 def nextbyte(count=1): nonlocal byteno if count > 1: # Return a list. return [nextbyte() for _ in range(count)] b = bytestream[byteno] byteno += 1 # Return a bare byte. return b ops = [] # Starts at op 6 for i in range(6, 0, -1): op = DX7Operator(opnum=i) op.rates = nextbyte(4) op.levels = nextbyte(4) op.breakpoint = nextbyte() op.bp_depths = nextbyte(2) op.bp_curves = nextbyte(2) op.kbdratescaling = nextbyte() op.ampmodsens = nextbyte() op.keyvelsens = nextbyte() op.opamp = nextbyte() op.ratiotuning = False if nextbyte() == 1 else True op.freq_coarse = nextbyte() op.freq_fine = nextbyte() op.freq_detune = nextbyte() ops.append(op) result.ops = ops result.pitch_rates = nextbyte(4) result.pitch_levels = nextbyte(4) result.algo = 1 + nextbyte() result.feedback = nextbyte() result.oscsync = nextbyte() result.lfospeed = nextbyte() result.lfodelay = nextbyte() result.lfopitchmoddepth = nextbyte() result.lfoampmoddepth = nextbyte() result.lfosync = nextbyte() result.lfowaveform = nextbyte() result.pitchmodsens = nextbyte() result.transpose = nextbyte() result.name = ''.join(chr(i) for i in nextbyte(10)) return result def get_bytestream(self): """Convert a decoded patch dict back to a bytestream.""" bytestream = [] for op in self.ops: # Assume ordering is right in ops list. bytestream.extend(op.rates) bytestream.extend(op.levels) bytestream.append(op.breakpoint) bytestream.extend(op.bp_depths) bytestream.extend(op.bp_curves) bytestream.append(op.kbdratescaling) bytestream.append(op.ampmodsens) bytestream.append(op.keyvelsens) bytestream.append(op.opamp) bytestream.append(0 if op.ratiotuning else 1) bytestream.append(op.freq_coarse) bytestream.append(op.freq_fine) bytestream.append(op.freq_detune) bytestream.extend(self.pitch_rates) bytestream.extend(self.pitch_levels) bytestream.append(self.algo - 1) bytestream.append(self.feedback) bytestream.append(self.oscsync) bytestream.append(self.lfospeed) bytestream.append(self.lfodelay) bytestream.append(self.lfopitchmoddepth) bytestream.append(self.lfoampmoddepth) bytestream.append(self.lfosync) bytestream.append(self.lfowaveform) bytestream.append(self.pitchmodsens) bytestream.append(self.transpose) bytestream.extend(ord(c) for c in self.name) return bytes(bytestream) @dataclass class AMYOscillator: op_num: int = 0 amp_levels: List[float] = None amp_times: List[float] = None op_amp: float = 0 ampmodsens: float = 0 frequency: float = 0 freq_is_ratio: bool = False @staticmethod def from_dx7_op(op): result = AMYOscillator() result.op_num = op.opnum result.amp_levels, result.amp_times = eg_to_bp(op.rates, op.levels) result.op_amp = 2 * dx7level_to_linear(op.opamp) if op.ratiotuning: result.frequency = coarse_fine_ratio(op.freq_coarse, op.freq_fine, op.freq_detune) result.freq_is_ratio = True else: result.frequency = coarse_fine_fixed_hz(op.freq_coarse, op.freq_fine, op.freq_detune) result.freq_is_ratio = False result.ampmodsens = float(op.ampmodsens) # Don't know scaling, just 0/nonzero. return result def fm_trunc(number): if(type(number)==float or type(number)==np.float64): return ('%.6f' % number).rstrip('0').rstrip('.') return str(number) @dataclass class AMYPatch: oscs: List[AMYOscillator] = None pitch_levels: List[float] = None pitch_times: List[float] = None algo: int = 0 feedback: float = 0 lfo_freq: float = 0 lfo_delay: float = 0 lfo_pitchmoddepth: float = 0 lfo_ampmoddepth: float = 0 lfo_waveform: int = 0 name: str = "" amp_lfo_amp: float = 0 pitch_lfo_amp: float = 0 @staticmethod def from_dx7(dx7_patch): result = AMYPatch() result.oscs = [] for op in dx7_patch.ops: result.oscs.append(AMYOscillator.from_dx7_op(op)) result.pitch_levels, result.pitch_times = eg_to_bp_pitch( dx7_patch.pitch_rates, dx7_patch.pitch_levels) result.algo = dx7_patch.algo result.feedback = 0.00125 * (2 ** dx7_patch.feedback) result.lfo_freq = lfo_speed_to_hz(dx7_patch.lfospeed) result.lfo_delay = dx7_patch.lfodelay #result.lfo_pitchmoddepth = dx7_patch.lfopitchmoddepth result.lfo_ampmoddepth = dx7_patch.lfoampmoddepth result.lfo_waveform = lfo_wave(dx7_patch.lfowaveform) result.amp_lfo_amp = dx7level_to_linear(result.lfo_ampmoddepth) # With pitchmodsens at max (7), and PMD at max (99), the pitch mod is +/- 1 octave (24 semis range) # PMS 7 / PMD 50 is 12 semis range # PMS 7 / PMD 25 is 6 semis # PMS 7 / PMD 12 is 2 semis # PMS 7 / PMD 6 is 1 semi .. really does look linear. # PMS 6 / PMD 99 is 14 semis range # PMS 5 / PMD 99 is ~8.5 semis # PMS 4 / PMD 99 is ~5.5 semis range # PMS 3 / PMD 99 is ~3.5 # PMS 2 / PMD 99 is ~2 semi # PMS 1 / PMD 99 is ~1.5 semi # PMS 0 is no semi # Finally, matching K128 by ear, PMS 3/PDM 05 should give pitch_lfo_amp about 0.008. # So total range is about 1.7 ^ (PMS - 1) * (PMD / 99) semis # So scaling from +/-1 LFO to octaves is pow(1.7, (PMS - 1)) * (PMD / 99) / 12 # 0.6 is a fudge factor. Seems way too large for small values of PMD, so maybe PMD is exp-lin or smt result.pitch_lfo_amp = ( 0 if dx7_patch.pitchmodsens == 0 else 0.6 * (1.7 ** (dx7_patch.pitchmodsens - 1)) * dx7_patch.lfopitchmoddepth / 1188.0 ) result.name = dx7_patch.name return result def send_to_AMY(self, reset=True): # Take a FM patch and output AMY commands to set up the patch. # Send amy.send(vel=1,osc=0,note=50) after t = fm_trunc if(reset): amy.reset() pitch_levels, pitch_times = self.pitch_levels, self.pitch_times pitchbp = "%d,%s,%d,%s,%d,%s,%d,%s,%d,%s" % ( pitch_times[0], t(pitch_levels[0]), pitch_times[1], t(pitch_levels[1]), pitch_times[2], t(pitch_levels[2]), pitch_times[3], t(pitch_levels[3]), pitch_times[4], t(pitch_levels[4]) ) # Set up each operator. last_release_time = 0 last_release_value = 0 # Oscs: 0 is algo, 1 is pitch LFO, 2 is amp LFO, 3-8 are ops 1-6 main_osc = 0 lfo_osc = 1 # The osc of op0 (they go up from here) op0_osc = 2 for op_num_from_0, osc in enumerate(self.oscs): osc_num = op0_osc + op_num_from_0 amp_levels, amp_times = osc.amp_levels, osc.amp_times oscbp = "%d,%s,%d,%s,%d,%s,%d,%s,%d,%s" % ( amp_times[0], t(amp_levels[0]), amp_times[1], t(amp_levels[1]), amp_times[2], t(amp_levels[2]), amp_times[3], t(amp_levels[3]), amp_times[4], t(amp_levels[4]) ) oscbpfmt = "%d,%s/%d,%s/%d,%s/%d,%s/%d,%s" % ( amp_times[0], t(amp_levels[0]), amp_times[1], t(amp_levels[1]), amp_times[2], t(amp_levels[2]), amp_times[3], t(amp_levels[3]), amp_times[4], t(amp_levels[4]) ) if(amp_times[4] > last_release_time): last_release_time = amp_times[4] last_release_value = amp_levels[4] #print("osc %d (op %d) freq %.6f ratio %d env %s amp %.6f amp_mod %d" % \ # (osc_num, osc.op_num_from_0, osc.frequency, osc.freq_is_ratio, oscbpfmt, # osc.op_amp, osc.ampmodsens)) # Make them all in cosine phase, to be like DX7. Important for slow oscs args = {"osc": osc_num, "bp0": oscbp, "phase": 0.25} if osc.freq_is_ratio: args["ratio"] = t(osc.frequency) else: args["freq"] = t(osc.frequency) # TODO: we xignore intensity of amp mod sens, just on/off args.update({"mod_source": lfo_osc, "amp": "%s,0,0,1,0,%s" % (t(osc.op_amp), t(self.amp_lfo_amp * (osc.ampmodsens > 0)))}) # We are _NOT_ updating operators with pitch bp, per dan tuesday 7/5 morning (but not monday 7/4 morning) #args.update({"bp1": pitchbp}) amy.send(**args) # Set up the LFO x #print("osc %d amp lfo wave %d freq %f amp %f" % ( # lfo_osc, self.lfo_waveform, self.lfo_freq, 1) amy.send(osc=lfo_osc, wave=self.lfo_waveform, freq=t(self.lfo_freq), amp=1, phase=0.25) #print("not used: lfo delay %d " % self.lfo_delay) #ampbp = "0,1,%d,%f" % (last_release_time, last_release_value) #print("osc 0 (main) algo %d feedback %f pitchenv %s ampenv %s" % ( # self.algo, self.feedback, pitchbp, ampbp)) amy.send(osc=main_osc, wave=amy.ALGO, algorithm=self.algo, feedback=t(self.feedback), algo_source=",".join(str(o) for o in range(op0_osc, op0_osc + 6)), #bp0=ampbp, #bp1=pitchbp, #freq="0,1,0,0,1,1", bp0=pitchbp, # bp1 is now ununsed. amp="1,0,1,0,0,0", # Turn off EG0 for amp freq="0,1,0,1,0,%s" % t(self.pitch_lfo_amp), # Turn on EG0 and LFO for freq mod_source=lfo_osc) def dx7level_to_linear(dx7level): """Map the dx7 0..99 levels to linear amplitude.""" return 2 ** ((dx7level - 99) / 8) def linear_to_dx7level(linear): """Map a linear amplitude to the dx7 0..99 scale.""" return np.log2(np.maximum(dx7level_to_linear(0), linear)) * 8 + 99 def pitchval_to_ratio(pitchval): """Map 0..99 DX7 pitch vals (e.g. from pitch_env) into f0 ratios.""" # Pitch map 0..99 actually becomes -128..127 via a symmetric map with 50->0, linear from 15 to 85, then # quadratic in the remainder. pitchsign = -1 + 2*(pitchval >= 50) semipitchval = np.abs(pitchval - 50).astype(float) # Above (50 + 36), Quadratic to reach 127 at level 99. semipitchval += (semipitchval > 36) * (((semipitchval - 34)**2) * 93/225 - semipitchval + 34) # DX7 manual states pitchmod range is +/- 4 octaves, so 32 steps/oct sounds right. return 2 ** ((pitchsign * semipitchval) / 32) def ratio_to_pitchval(ratio): semipitchval = 32 * np.log2(ratio) pitchsign = -1 + 2*(semipitchval >= 0) semipitchval = np.abs(semipitchval) # Vectorized conditional treatment of outside -36 to 36. semipitchval += (semipitchval > 36) * (34 + np.sqrt(np.abs(semipitchval - 34) * (225/93)) - semipitchval) return 50 + pitchsign * semipitchval def calc_loglin_eg_breakpoints(rates, levels, dx7_attacks=True, rate_double_interval=6, rate_scale=0.5, rate_offset=0.5): """Convert the DX7 rates/levels into (time, target) pairs (for amy)""" if dx7_attacks: level_to_lin_fn = dx7level_to_linear else: level_to_lin_fn = pitchval_to_ratio # This is the part we precompute in fm.py to get breakpoints to send to amy. current_level = levels[-1] # EG at time 0 has final value from release. breakpoints = [(0, level_to_lin_fn(current_level))] MIN_LEVEL = 34 ATTACK_RANGE = 75 def level_to_attack_time(level, t_const): """Return the time at which a paradigmatic DX7 attack envelope will reach a level (0..99 range)""" # Return the t0 that solves level = MIN_LEVEL + ATTACK_RANGE * (1 - exp(-t0 / t_const)) return -t_const * np.log((MIN_LEVEL + ATTACK_RANGE - np.maximum(MIN_LEVEL, level))/ATTACK_RANGE) for segment, (rate, target_level) in enumerate(zip(rates, levels)): release_segment = (segment == len(rates)-1) if dx7_attacks and target_level > current_level: # Attack segment # The attack envelopes L(t) appear to be ~ 34 + 75 * (1 - exp(t / t_const)), starting from L = 34 # i.e. they are rising exponentials (as in analog ADSR, but here in the log(amp) domain) # with an asymptote at 109 (i.e., 10 higher than the highest possible amp). # The time constant depends on the R (rate) parameter, and is well fit by: t_const = 0.008 * (2 ** ((65 - rate)/6)) # Total time for this segment is t1 - t0 where t0 and t1 solve # effective_start = 34 + 75 * (1 - np.exp(-t0 / t_const)) = 109 - 75 exp(-t0 / t_c) # target_level = 34 + 75 * (1 - np.exp(-t1 / t_const)) = 109 - 75 exp(-t1 / t_c) # so t1 - t0 = -t_c * [log((34 + 75 - target_level)/75) - log((34 + 75 - effective_start)/75)] effective_start_level = np.maximum(current_level, MIN_LEVEL) t0 = level_to_attack_time(effective_start_level, t_const) segment_duration = level_to_attack_time(target_level, t_const) - t0 #print("eff_st=", effective_start_level, "t_c=", t_const, "t0=", t0, "dur=", segment_duration) # Now amy's task will be to recover t0 and t_const from (time, target) pairs else: # Decay segment, or TRUE_EXPONENTIAL attack segment. direction = 1 if target_level > current_level else -1 # "A falling segment takes 3.5 mins" # so delta = 99 in 210 seconds -> level_change_per_sec = 0.5 # I think just offset everything by 0.5, avoids div0. level_change_per_sec = direction*(rate_offset + rate_scale * (2 ** (rate / rate_double_interval))) level_difference = target_level - current_level # Hack to cover for sustain = 0, release = 0 release segments which look like they should be zero long if release_segment and level_difference == 0: level_difference = direction * 60 # e.g. from a decayed level of 80 to zero. #print("** Goosing release amp") segment_duration = level_difference / level_change_per_sec #print("lcps=", level_change_per_sec, "dur=", segment_duration) breakpoints.append((segment_duration, level_to_lin_fn(target_level))) current_level = target_level return breakpoints def eg_to_bp(egrate, eglevel, calc_eg_args={}): breakpoints = calc_loglin_eg_breakpoints(egrate, eglevel, **calc_eg_args) rates = [] times = [] for time, level in breakpoints: times.append(int(1000 * time)) rates.append(level) return rates, times def eg_to_bp_pitch(egrate, eglevel): # Additional args to make breakpoint calculation to the right thing for pitch. calc_pitch_eg_args = {'dx7_attacks': False, 'rate_double_interval': 20, 'rate_scale': 11, 'rate_offset': -6} return eg_to_bp(egrate, eglevel, calc_pitch_eg_args) def coarse_fine_fixed_hz(coarse, fine, detune=7): coarse = coarse & 3 return 10 ** (coarse + (fine + ((detune - 7) / 8)) / 100 ) def coarse_fine_ratio(coarse, fine, detune=7): coarse = coarse & 31 if(coarse == 0): coarse = 0.5 return coarse * (1 + (fine + ((detune - 7) / 8)) / 100) def lfo_speed_to_hz(byte): # Measured values from TX802, linear fit by eye if byte == 0: return 0.064 if byte <= 64: return byte / 6.0 if byte <= 85: return byte - 64.0 * 5.0/6.0 # Byte > 85 return 31.67 + (byte - 85.0) * 1.33 def lfo_wave(byte): if byte > 5: return None return [ amy.TRIANGLE, amy.SAW_DOWN, amy.SAW_UP, amy.PULSE, amy.SINE, amy.NOISE ][byte] # Play a numpy array on an Apple Silicon mac without having to use an external library # (sounddevice is currently broken on AS macs) def play_np_array(np_array, samplerate=amy.AMY_SAMPLE_RATE): import wave, tempfile , os, struct tf = tempfile.NamedTemporaryFile() obj = wave.open(tf,'wb') obj.setnchannels(1) # mono obj.setsampwidth(2) obj.setframerate(samplerate) for i in range(np_array.shape[0]): value = int(np_array[i] * 32767.0) data = struct.pack(' 0: wavetable_tables, wavetable_len = _read_wavetables(wavetable_files) wavetable_count = len(wavetable_tables) base_samples = len(offsets) base_length = all_samples.shape[0] p = open("src/pcm_%s.h" % (name), "w") p.write("// Automatically generated by amy.headers.generate_pcm_header()\n") p.write("#ifndef __PCM_H\n#define __PCM_H\n") p.write("#define PCM_AMY_SAMPLE_RATE %d\n" % (pcm_AMY_SAMPLE_RATE)) p.write("#define PCM_BASE_SAMPLES %d\n" % (base_samples)) p.write("#define PCM_BASE_LENGTH %d\n" % (base_length)) if wavetable_count > 0: p.write("#if defined(AMY_WAVETABLE)\n") p.write("#define PCM_WAVETABLE_BASE PCM_BASE_SAMPLES\n") p.write("#define PCM_WAVETABLE_SAMPLES %d\n" % (wavetable_count)) p.write("#define PCM_WAVETABLE_LEN %d\n" % (wavetable_len)) p.write("#define PCM_LENGTH (PCM_BASE_LENGTH + (PCM_WAVETABLE_SAMPLES * PCM_WAVETABLE_LEN))\n") p.write("#define PCM_MAP_ENTRIES (PCM_BASE_SAMPLES + PCM_WAVETABLE_SAMPLES)\n") p.write("#else\n") p.write("#define PCM_WAVETABLE_BASE PCM_BASE_SAMPLES\n") p.write("#define PCM_WAVETABLE_SAMPLES 0\n") p.write("#define PCM_WAVETABLE_LEN 0\n") p.write("#define PCM_LENGTH PCM_BASE_LENGTH\n") p.write("#define PCM_MAP_ENTRIES PCM_BASE_SAMPLES\n") p.write("#endif\n") else: p.write("#define PCM_WAVETABLE_BASE PCM_BASE_SAMPLES\n") p.write("#define PCM_WAVETABLE_SAMPLES 0\n") p.write("#define PCM_WAVETABLE_LEN 0\n") p.write("#define PCM_LENGTH PCM_BASE_LENGTH\n") p.write("#define PCM_MAP_ENTRIES PCM_BASE_SAMPLES\n") p.write("#include \"pcm_samples_%s.h\"\n" % (name)) p.write("const uint16_t pcm_samples = PCM_MAP_ENTRIES;\n") p.write("const uint16_t pcm_wavetable_base = PCM_WAVETABLE_BASE;\n") p.write("const uint16_t pcm_wavetable_samples = PCM_WAVETABLE_SAMPLES;\n") p.write("const uint32_t pcm_wavetable_len = PCM_WAVETABLE_LEN;\n") p.write("const pcm_map_t pcm_map[PCM_MAP_ENTRIES] PROGMEM = {\n") for i,o in enumerate(offsets): p.write(" /* [%d] %d */ {%d, %d, %d, %d, %d}, /* %s */\n" %(i, orig_map[i], o["offset"], o["length"], o["loopstart"], o["loopend"], o["midinote"], o["name"])) if wavetable_count > 0: p.write("#if defined(AMY_WAVETABLE)\n") for i, (wavfile, wav_data) in enumerate(wavetable_tables): wav_index = base_samples + i wav_offset = base_length + i * wavetable_len wav_name = os.path.basename(wavfile) p.write(" /* [%d] WT */ {%d, %d, %d, %d, %d}, /* %s */\n" % ( wav_index, wav_offset, wavetable_len, 0, wavetable_len, 69, wav_name)) p.write("#endif\n") p.write("};\n") p.write("\n#endif // __PCM_H\n") p.close() p = open("src/pcm_samples_%s.h" % (name), 'w') p.write("// Automatically generated by amy.headers.generate_pcm_header()\n") p.write("#ifndef __PCM_SAMPLES_H\n#define __PCM_SAMPLES_H\n") p.write("const int16_t pcm[PCM_LENGTH] PROGMEM = {\n") column = 15 count = 0 for i in range(int(all_samples.shape[0]/column)): p.write(" %s,\n" % (",".join([("%d" % (d)).ljust(8) for d in all_samples[i*column:(i+1)*column]]))) count = count + column print("count %d all_samples.shape %d" % (count, all_samples.shape[0])) if(count != all_samples.shape[0]): p.write(" %s\n" % (",".join([("%d" % (d)).ljust(8) for d in all_samples[count:]]))) if wavetable_count > 0: p.write("#if defined(AMY_WAVETABLE)\n") for wavfile, wav_data in wavetable_tables: p.write(" // %s\n" % (wavfile)) for i in range(int(len(wav_data)/column)): p.write(" %s,\n" % (",".join([("%d" % (d)).ljust(8) for d in wav_data[i*column:(i+1)*column]]))) rem = int(len(wav_data) % column) if rem != 0: p.write(" %s,\n" % (",".join([("%d" % (d)).ljust(8) for d in wav_data[-rem:]]))) p.write("#endif\n") p.write("};\n") p.write("\n#endif // __PCM_SAMPLES_H\n") def generate_pcm_headers(): tiny = [0, 3, 8, 11, 14, 16, 17, 18, 20, 23, 25] wavetable_files = sorted(glob.glob('sounds/wavetables/*.WAV')) generate_amy_pcm_header(tiny, "tiny", wavetable_files=wavetable_files) def cos_lut(table_size, harmonics_weights, harmonics_phases=None): if harmonics_phases is None: harmonics_phases = np.zeros(len(harmonics_weights)) table = np.zeros(table_size) phases = np.arange(table_size) * 2 * np.pi / table_size for harmonic_number, harmonic_weight in enumerate(harmonics_weights): table += harmonic_weight * np.cos( phases * harmonic_number + harmonics_phases[harmonic_number]) return table # A LUTset is a list of LUTentries describing downsampled versions of the same # basic waveform, sorted with the longest (highest-bandwidth) first. def create_lutset(LUTentry, harmonic_weights, harmonic_phases=None, length_factor=8, bandwidth_factor=None): if bandwidth_factor is None: bandwidth_factor = np.sqrt(0.5) """Create an ordered list of LUTs with decreasing harmonic content. These can then be used in interp_from_lutset to make an adaptive-bandwidth interpolation. Args: harmonic_weights: vector of amplitudes for cosine harmonic components. harmonic_phases: initial phases for each harmonic, in radians. Zero (default) indicates cosine phase. length_factor: Each table's length is at least this factor times the order of the highest harmonic it contains. Thus, this is a lower bound on the number of samples per cycle for the highest harmonic. Higher factors make the interpolation easier. bandwidth_factor: Target ratio between the highest harmonics in successive table entries. Default is sqrt(0.5), so after two tables, bandwidth is reduced by 1/2 (and length with follow). Returns: A list of LUTentry objects, sorted in decreasing order of the highest harmonic they contain. Each LUT's length is a power of 2, and as small as possible while respecting the length_factor for the highest contained harmonic. """ if harmonic_phases is None: harmonic_phases = np.zeros(len(harmonic_weights)) # Calculate the length of the longest LUT we need. Must be a power of 2, # must have at least length_factor * highest_harmonic samples. # Harmonic 0 (dc) doesn't count. float_num_harmonics = float(len(harmonic_weights)) lutsets = [] done = False # harmonic 0 is DC; there's no point in generating that table. while float_num_harmonics >= 2: num_harmonics = int(round(float_num_harmonics)) highest_harmonic = num_harmonics - 1 # because zero doesn't count. lut_size = int(2 ** np.ceil(np.log(length_factor * highest_harmonic) / np.log(2))) lutsets.append(LUTentry( table=cos_lut(lut_size, harmonic_weights[:num_harmonics], harmonic_phases[:num_harmonics]), # / lut_size, highest_harmonic=highest_harmonic)) float_num_harmonics = bandwidth_factor * float_num_harmonics return lutsets def make_table(min_val, max_val, fn, table_size=257, dtype=np.int16): # The table includes the final value, so the actual number of steps is table_size - 1. steps = table_size - 1 stepsize = (max_val - min_val) / steps return fn(np.arange(min_val, max_val + stepsize, stepsize)).astype(dtype) def create_exp2_lut(npts): exp2_int16_fn = lambda x: np.round(-32768.0 * (np.exp2(x) - 1.0)) return make_table(0, 1, exp2_int16_fn, table_size=npts, dtype=np.int16) def create_log2_lut(npts): log2_int16_fn = lambda x: np.round(-32768.0 * (np.log2(x + 1.0))) return make_table(0, 1, log2_int16_fn, table_size=npts, dtype=np.int16) def write_lutset_to_h(filename, variable_base, lutset): """Savi out a lutset as a C-compatible header file.""" num_luts = len(lutset) with open(filename, "w") as f: f.write("// Automatically-generated LUTset\n") f.write("#ifndef LUTSET_{:s}_DEFINED\n".format(variable_base.upper())) f.write("#define LUTSET_{:s}_DEFINED\n".format(variable_base.upper())) f.write("\n") # Define the structure. f.write("#ifndef LUTENTRY_DEFINED\n") f.write("#define LUTENTRY_DEFINED\n") f.write("typedef struct {\n") f.write(" const float *table;\n") f.write(" int table_size;\n") f.write(" int highest_harmonic;\n") f.write("} lut_entry;\n") f.write("#endif // LUTENTRY_DEFINED\n") f.write("\n") # Define the content of the individual tables. samples_per_row = 8 for i in range(num_luts): table_size = len(lutset[i].table) f.write("const float {:s}_lutable_{:d}[{:d}] PROGMEM = {{\n".format( variable_base, i, table_size)) for row_start in range(0, table_size, samples_per_row): for sample_index in range(row_start, min(row_start + samples_per_row, table_size)): f.write("{:f},".format(lutset[i].table[sample_index])) f.write("\n") f.write("};\n") f.write("\n") # Define the table of LUTs. f.write("lut_entry {:s}_lutset[{:d}] = {{\n".format( variable_base, num_luts + 1)) for i in range(num_luts): f.write(" {{{:s}_lutable_{:d}, {:d}, {:d}}},\n".format( variable_base, i, len(lutset[i].table), lutset[i].highest_harmonic)) # Final entry is null to indicate end of table. f.write(" {NULL, 0, 0},\n") f.write("};\n") f.write("\n") f.write("#endif // LUTSET_x_DEFINED\n") print("wrote", filename) def write_fxpt_lutable(f, lutable, name, samples_per_row=8): """Write a single lutable to an open file.""" table_size = len(lutable) scale_factor = np.max(np.abs(lutable.astype(float))) f.write("const int16_t {:s}[{:d}] PROGMEM = {{\n".format( name, table_size)) for row_start in range(0, table_size, samples_per_row): for sample_index in range(row_start, min(row_start + samples_per_row, table_size)): f.write("{:d},".format( min(32767, max(-32768, int(round(32768 / scale_factor * lutable[sample_index])))))) f.write("\n") f.write("};\n") f.write("\n") return scale_factor def write_lutset_to_h_as_fxpt(filename, variable_base, lutset): """Save out a lutset as a C-compatible header file using ints.""" import math num_luts = len(lutset) with open(filename, "w") as f: f.write("// Automatically-generated LUTset\n") f.write("#ifndef LUTSET_{:s}_FXPT_DEFINED\n".format(variable_base.upper())) f.write("#define LUTSET_{:s}_FXPT_DEFINED\n".format(variable_base.upper())) f.write("\n") # Define the structure. f.write("#ifndef LUTENTRY_FXPT_DEFINED\n") f.write("#define LUTENTRY_FXPT_DEFINED\n") f.write("typedef struct {\n") f.write(" const int16_t *table;\n") f.write(" int table_size;\n") f.write(" int log_2_table_size;\n") f.write(" int highest_harmonic;\n") f.write(" float scale_factor;\n") f.write("} lut_entry_fxpt;\n") f.write("#endif // LUTENTRY_FXPT_DEFINED\n") f.write("\n") # Define the content of the individual tables. scale_factors = [] for i in range(num_luts): scale_factor = write_fxpt_lutable( f, lutset[i].table, '{:s}_fxpt_lutable_{:d}'.format(variable_base, i) ) scale_factors.append(scale_factor) # Define the table of LUTs. f.write("lut_entry_fxpt {:s}_fxpt_lutset[{:d}] = {{\n".format( variable_base, num_luts + 1)) for i in range(num_luts): table_size = len(lutset[i].table) # Provide the shift size corresponding to the lutset. log_2_table_size = int(round(math.log(table_size) / math.log(2.0))) f.write(" {{{:s}_fxpt_lutable_{:d}, {:d}, {:d}, {:d}, {:f}}},\n".format( variable_base, i, table_size, log_2_table_size, lutset[i].highest_harmonic, scale_factors[i])) # Final entry is null to indicate end of table. f.write(" {NULL, 0, 0, 0, 0.0},\n") f.write("};\n") f.write("\n") f.write("#endif // LUTSET_x_DEFINED\n") print("wrote", filename) def make_log2_exp2_luts(filename): """Write the fixed-point exp2 and log2 lookup tables.""" variable_base = 'exp_lut' with open(filename, "w") as f: f.write("// Automatically-generated LUTset\n") f.write("#ifndef LUTSET_{:s}_FXPT_DEFINED\n".format(variable_base.upper())) f.write("#define LUTSET_{:s}_FXPT_DEFINED\n".format(variable_base.upper())) f.write("\n") # Define the content of the individual tables. write_fxpt_lutable(f, create_log2_lut(257), 'log2_fxpt_lutable') write_fxpt_lutable(f, create_exp2_lut(257), 'exp2_fxpt_lutable') f.write("\n") f.write("#endif // LUTSET_x_DEFINED\n") print("wrote", filename) def make_clipping_lut(filename): # Soft clipping lookup table scratchpad. SAMPLE_MAX = 32767 linear_proportion = 0.9 # I tried 0.6 and you could hear the difference but not enough to matter. LIN_MAX = int(round(linear_proportion * 32768)) # 29491 NONLIN_RANGE = round(1.5 * (32767 - LIN_MAX)) # size of nonlinearity lookup table = 4915 clipping_lookup_table = np.arange(LIN_MAX + NONLIN_RANGE) for x in range(NONLIN_RANGE): x_dash = float(x) / NONLIN_RANGE clipping_lookup_table[x + LIN_MAX] = LIN_MAX + int(np.floor(NONLIN_RANGE * (x_dash - x_dash * x_dash * x_dash / 3.0))) with open(filename, "w") as f: f.write("// Automatically generated.\n// Clipping lookup table\n") f.write("#ifndef __CLIPPING_TABLE\n#define __CLIPPING_TABLE\n") f.write("#define FIRST_NONLIN %d\n" % LIN_MAX) f.write("#define NONLIN_RANGE %d\n" % NONLIN_RANGE) f.write("// First sample value beyond end of table (just clip to max).\n") f.write("#define FIRST_HARDCLIP (FIRST_NONLIN + NONLIN_RANGE)\n") f.write("const uint16_t clipping_lookup_table[NONLIN_RANGE] PROGMEM = {\n") samples_per_row = 8 for row_start in range(0, NONLIN_RANGE, samples_per_row): for sample in range(row_start, min(NONLIN_RANGE, row_start + samples_per_row)): f.write("%d," % clipping_lookup_table[LIN_MAX + sample]) f.write("\n") f.write("};\n") f.write("#endif\n") print("wrote", filename) def make_piano_patch(): import amy # This just allocates the 20 oscs needed for a INTERP_PARTIALS patch # dpwe wants to add a `num_suboscs` field to fix this behavior soon amy.send(chorus=0) # Piano sounds weird with chorus on amy.send(osc=0, wave=amy.INTERP_PARTIALS, preset=0, amp='1,0,0,0') # Parent osc amp applies, disconnect vel and eg0. #amy.send(osc=20, wave=amy.PARTIAL) # it's not 20, but it doesn't matter, voice is reallocated by interp_partials.c return 25 # We now use up to 24 partials per voice + 1 control osc. def make_amyboard_patch(): import amy # Modified for "silent control osc" ctl_osc = 0 lfo_osc = 1 osc_a = 2 osc_b = 3 message = amy.message(osc=ctl_osc, wave=amy.SILENT, mod_source=lfo_osc, chained_osc=osc_a, filter_type=amy.FILTER_LPF24, filter_freq={'const': 200.0, 'note': 1.0, 'eg1': 5.0}, resonance=0.7, bp0='0,1,1000,0.2,100,0', bp1='0,1,1000,0.2,1000,0') message += amy.message(osc=osc_a, wave=amy.PULSE, amp={'vel': 0, 'eg0': 0}, mod_source=lfo_osc, chained_osc=osc_b) message += amy.message(osc=osc_b, wave=amy.SAW_DOWN, amp={'vel': 0, 'eg0': 0}, mod_source=lfo_osc, freq={'const': constants.ZERO_LOGFREQ_IN_HZ / 2}) message += amy.message(osc=lfo_osc, wave=amy.TRIANGLE, amp={'vel': 0}, freq={'const': 4.0, 'note': 0, 'bend': 0}, bp0='0,1.0,10000,0') message += amy.message(eq=[0, 0, 0], chorus='0,,0.5,0.5') return 4, message # 4 oscs def make_patches(filename): def nothing(message): return from . import juno, fm num_oscs =[] # Don't make any noise amy.override_send = nothing with open(filename, "w") as f: f.write("// Automatically generated.\n// DX7 and juno 106 and custom patch table\n") f.write("#ifndef __PATCHESH\n#define __PATCHESH\n") f.write("static const char * const patch_commands[258] PROGMEM = {\n") # Do juno for i in range(128): amy.log_patch() j = juno.JunoPatch() j.set_patch(i) f.write("\t/* %d: Juno %s */ \"%s\",\n" % (i, j.name, amy.retrieve_patch())) num_oscs.append(6) # Do dx7 for i in range(128): amy.log_patch() p = fm.AMYPatch.from_dx7(fm.DX7Patch.from_patch_number(i)) p.send_to_AMY(reset=False) f.write("\t/* %d: DX7 %s */ \"%s\",\n" % (i+128, p.name, amy.retrieve_patch())) num_oscs.append(8) # do piano amy.log_patch() num_osc_piano = make_piano_patch() f.write("\t/* 256: dpwe piano */ \"%s\",\n" % (amy.retrieve_patch())) num_oscs.append(num_osc_piano) # do amyboard patch num_osc_amyboard, patch_string = make_amyboard_patch() f.write("\t/* 257: amyboard default */ \"%s\",\n" % (patch_string)) num_oscs.append(num_osc_amyboard) f.write("};\n") f.write("const uint16_t patch_oscs[258] PROGMEM = {\n") for i in num_oscs: f.write("%d," % (i)) f.write("\n};\n#endif\n") amy.override_send = None print("wrote", filename) def write_vector_as_c(f, data, name, dtype='uint8_t', items_per_row=20): num_name = "NUM_%s" % name.upper() f.write("#define %s %d\n" % (num_name, len(data))) f.write("const %s %s[%s] PROGMEM = {\n" % (dtype, name, num_name)) for start in range(0, len(data), items_per_row): data_row = data[start : start + items_per_row] f.write(" " + ", ".join("%d" % d for d in data_row) + ",\n") f.write("};\n\n") def make_interp_partials(filename, data_dict): """Write the json data from experiments/piano_heterodyne.ipynb into a C header.""" import itertools # data_dict is {instrument_tag: {'sample_times_ms': [], 'notes': [], 'velocities': [], 'num_harmonics': xx, 'harmonics_freq': [], 'harmonics_mags': []}, ...} with open(filename, "w") as f: f.write("// Automatically generated.\n// Piano interpolated partials data table\n") f.write("#ifndef __INTERP_PARTIALS_H\n#define __INTERP_PARTIALS_H\n\n") f.write("#define NUM_INTERP_PARTIALS_PRESETS %d\n\n" % len(data_dict)) map_contents = "" for tag, data in data_dict.items(): for varname, dtype in [('sample_times_ms', 'uint16_t'), ('velocities', 'uint8_t'), ('notes', 'uint8_t'), ('num_harmonics', 'uint8_t'), ('harmonics_freq', 'uint16_t')]: write_vector_as_c(f, data[varname], tag + "_" + varname, dtype=dtype) harmonics_mags = list(itertools.chain(*data['harmonics_mags'])) write_vector_as_c(f, harmonics_mags, tag + "_harmonics_mags") TAG = tag.upper() map_contents += """ { NUM_%s_SAMPLE_TIMES_MS, %s_sample_times_ms, NUM_%s_VELOCITIES, %s_velocities, NUM_%s_NOTES, %s_notes, %s_num_harmonics, %s_harmonics_freq, %s_harmonics_mags, }, """ % (TAG, tag, TAG, tag, TAG, tag, tag, tag, tag) f.write("const interp_partials_voice_t interp_partials_map[NUM_INTERP_PARTIALS_PRESETS] PROGMEM = {\n") f.write(map_contents) f.write("};\n\n") f.write("#endif // ndef __INTERP_PARTIALS_H\n\n") print("wrote", filename) import scipy.io.wavfile as wav import os """ Generate all the headers except for the partials headers """ def generate_all(): from . import fm import collections import json # Implement the multiple lookup tables. # A LUT is stored as an array of values (table) and the harmonic number of the # highest harmonic they contain (i.e., the number of cycles it completes in the # entire table, so must be <= len(table)/2.) LUTentry = collections.namedtuple('LUTentry', ['table', 'highest_harmonic']) # Impulses. #impulse_lutset = create_lutset(LUTentry, np.ones(128)) ##write_lutset_to_h('src/impulse_lutset.h', 'impulse', impulse_lutset) #write_lutset_to_h_as_fxpt('src/impulse_lutset_fxpt.h', 'impulse', impulse_lutset) # Saw_up. saw_lutset = create_lutset(LUTentry, [0] + list(-1 / np.arange(1, 256)), -np.pi/2 * np.ones(256)) #write_lutset_to_h('src/saw_lutset.h', 'saw', saw_lutset) write_lutset_to_h_as_fxpt('src/saw_lutset_fxpt.h', 'saw', saw_lutset) # Triangle wave lutset n_harms = 64 coefs = (np.arange(n_harms) % 2) * ( np.maximum(1, np.arange(n_harms, dtype=float))**(-2)) triangle_lutset = create_lutset(LUTentry, coefs, np.arange(len(coefs)) * -np.pi / 2) #write_lutset_to_h('src/triangle_lutset.h', 'triangle', triangle_lutset) write_lutset_to_h_as_fxpt('src/triangle_lutset_fxpt.h', 'triangle', triangle_lutset) # Sinusoid "lutset" (only one table) sine_lutset = create_lutset(LUTentry, np.array([0, 1]), harmonic_phases = -np.pi / 2 * np.ones(2), length_factor=256) #write_lutset_to_h('src/sine_lutset.h', 'sine', sine_lutset) write_lutset_to_h_as_fxpt('src/sine_lutset_fxpt.h', 'sine', sine_lutset) # log2/exp2 LUTs make_log2_exp2_luts('src/log2_exp2_fxpt_lutable.h') # Clipping LUT make_clipping_lut('src/clipping_lookup_table.h') # PCM LUT try: generate_pcm_headers() except ImportError: print("If you want to regenerate the PCM headers (not required!) you need to `pip install resampy sf2utils`.") # Juno & FM patches make_patches("src/patches.h") # interp_partials data table make_interp_partials("src/interp_partials.h", {'piano': json.load(open("experiments/piano-params.json", "r"))}) # Wavetable samples are appended to tiny PCM headers in generate_pcm_headers(). def main(): print("Generating all headers needed for AMY...") generate_all() print("Done.") if __name__ == '__main__': main() ================================================ FILE: amy/juno.py ================================================ # juno.py # Convert juno-106 sysex patches to Amy import amy import json import math import time from . import constants try: math.exp2(1) def exp2(x): return math.exp2(x) except AttributeError: def exp2(x): return math.pow(2.0, x) # Range is from 10 ms to 12 sec i.e. 1200. # (12 sec is allegedly the max decay time of the EG, see # page 32 of Juno-106 owner's manual, # https://cdn.roland.com/assets/media/pdf/JUNO-106_OM.pdf .) # Return int value in ms #time = 0.01 * np.exp(np.log(1e3) * midi / 127.0) # midi 30 is ~ 200 ms, 50 is ~ 1 sec, so # D=30 # # from demo at https://www.synthmania.com/Roland%20Juno-106/Audio/Juno-106%20Factory%20Preset%20Group%20A/14%20Flutes.mp3 # A11 Brass set A=3 D=49 S=45 R=32 -> # A14 Flute A=23 D=81 S=0 R=18 -> A=200ms, R=200ms, D=0.22 to 0.11 in 0.830 s / 0.28 to 0.14 in 0.92 R = 0.2 to 0.1 in 0.046 # A16 Brass & Strings A=44 D=66 S=53 R=44 -> A=355ms, R= # A15 Moving Strings A=13 D=87 R=35 -> A=100ms, R=600ms, # A26 Celeste A=0 D=44 S=0 R=81 -> A=2ms D=0.48 to 0.24 in 0.340 s R = 0.9 to 0.5 in 0.1s; R clearly faster than D # A27 Elect Piano A=1 D=85 S=43 R=40 -> A=14ms, R=300ms # A28 Elect. Piano II A=0 D=68 S=0 R=22 -> D=0.30 to 0.15 in 0.590 s R same as D? # A32 Steel Drums A=0 D=26 S=0 R=37 -> D=0.54 to 0.27 in 0.073 s # A34 Brass III A=58 D=100 S=94 R=37 -> A=440ms, R=1000ms # A35 Fanfare A=72 D=104 S=75 R=49 -> A=600ms, R=1200ms # A37 Pizzicato A=0 D=11 S=0 R=12 -> A=6ms, R=86ms D=0.66 to 0.33 in 0.013 s # A41 Bass Clarinet A=11 D=75 S=0 R=25 -> A=92ms, R=340ms, D=0.20 to 0.10 in 0.820 s / R = 0.9 to 0.45 in 0.070 # A42 English Horn A=8 D=81 S=21 R=16 -> A=68ms, R=240ms, # A45 Koto A=0 D=56 S=0 R=39 -> D=0.20 to 0.10 in 0.160 s # A46 Dark Pluck A=0 D=52 S=15 R=63 -> # A48 Synth Bass I A=0 D=34 S=0 R=36 -> D=0.60 to 0.30 in 0.096 s # A56 Funky III A=0 D=24 S=0 R=2 D 1/2 in 0.206 # A61 Piano II A=0 D=98 S=0 R=32 D 1/2 in 1.200 # A 0 1 8 11 13 23 44 58 # ms 6 14 68 92 100 200 355 440 # D 11 24 26 34 44 56 68 75 81 98 # 1/2 time ms 13 206 73 96 340 160 590 830 920 1200 # R 12 16 18 25 35 37 40 # ms 86 240 200 340 600 1000 300 # Notes from video https://www.youtube.com/watch?v=zWOs16ccB3M # A 0 -> 1ms 1.9 -> 30ms 3.1 -> 57ms 3.7 -> 68ms 5.4 -> 244 ms 6.0 -> 323ms 6.3 -> 462ms 6.5 -> 502ms # D 3.3 -> 750ms # Addendum: See online emulation # https://github.com/pendragon-andyh/junox # based on set of isolated samples # https://github.com/pendragon-andyh/Juno60 def to_attack_time(val): """Convert a midi value (0..127) to a time for ADSR.""" # From regression of sound examples return 6 + 8 * val * 127 # from Arturia video #return 12 * exp2(0.066 * midi) - 12 def to_decay_time(val): """Convert a midi value (0..127) to a time for ADSR.""" # time = 12 * np.exp(np.log(120) * midi/100) # time is time to decay to 1/2; Amy envelope times are to decay to exp(-3) = 0.05 # return np.log(0.05) / np.log(0.5) * time # from Arturia video #return 80 * exp2(0.066 * val * 127) - 80 return 80 * exp2(0.085 * val * 127) - 80 def to_release_time(val): """Convert a midi value (0..127) to a time for ADSR.""" #time = 100 * np.exp(np.log(16) * midi/100) #return np.log(0.05) / np.log(0.5) * time # from Arturia video #return 70 * exp2(0.066 * val * 127) - 70 return 70 * exp2(0.066 * val * 127) - 70 def to_level(val): # Map midi to 0..1, linearly. return val def level_to_amp(level): # level is 0.0 to 1.0; amp is 0.001 to 1.0 if level == 0.0: return 0.0 return float("%.3f" % (0.001 * np.exp(level * np.log(1000.0)))) def to_lfo_freq(val): # LFO frequency in Hz varies from 0.5 to 30 # from Arturia video return float("%.3f" % (0.6 * exp2(0.04 * val * 127) - 0.1)) def to_lfo_delay(val): """Convert a midi value (0..127) to a time for lfo_delay.""" #time = 100 * np.exp(np.log(16) * midi/100) #return float("%.3f" % (np.log(0.05) / np.log(0.5) * time)) # from Arturia video return float("%.3f" % (18 * exp2(0.066 * val * 127) - 13)) def to_resonance(val): # Q goes from 0.5 to 16 exponentially return float("%.3f" % (0.7 * exp2(4.0 * val))) def to_filter_freq(val): # filter_freq goes from ? 100 to 6400 Hz with 18 steps/octave #return float("%.3f" % (100 * np.exp2(midi / 20.0))) # from Arturia video #return float("%.3f" % (6.5 * exp2(0.11 * val * 127))) #return float("%.3f" % (25 * exp2(0.055 * val * 127))) #return float("%.3f" % (25 * exp2(0.083 * val * 127))) return float("%.3f" % (13 * exp2(0.0938 * val * 127))) def ffmt(val): """Format float values as max 3 dp, but less if possible.""" return "%.5g" % float("%.3f" % val) _PATCHES = [["A11 Brass Set 1", [20, 49, 0, 102, 0, 35, 13, 58, 0, 86, 108, 3, 49, 45, 32, 0, 81, 17]], ["A12 Brass Swell", [6, 48, 0, 56, 0, 43, 17, 26, 0, 84, 75, 64, 118, 38, 37, 70, 82, 25]], ["A13 Trumpet", [52, 45, 8, 102, 0, 55, 34, 24, 1, 59, 127, 5, 66, 48, 16, 0, 50, 9]], ["A14 Flutes", [60, 43, 1, 0, 0, 55, 32, 10, 11, 41, 127, 23, 81, 0, 18, 0, 50, 1]], ["A15 Moving Strings", [63, 0, 0, 39, 0, 77, 20, 4, 0, 111, 34, 13, 87, 88, 35, 14, 26, 16]], ["A16 Brass & Strings", [35, 0, 0, 56, 0, 76, 17, 4, 0, 41, 78, 44, 66, 53, 44, 23, 73, 24]], ["A17 Choir", [59, 14, 13, 25, 0, 59, 94, 2, 0, 62, 127, 68, 11, 127, 48, 0, 74, 9]], ["A18 Piano I", [20, 49, 0, 80, 0, 65, 12, 10, 0, 27, 103, 0, 66, 0, 30, 86, 42, 17]], ["A21 Organ I", [54, 15, 0, 53, 0, 43, 76, 14, 1, 127, 100, 0, 10, 82, 0, 23, 41, 28]], ["A22 Organ II", [44, 15, 0, 53, 0, 53, 76, 14, 1, 85, 74, 0, 10, 82, 0, 58, 74, 28]], ["A23 Combo Organ", [75, 21, 9, 57, 0, 63, 70, 4, 0, 109, 96, 0, 48, 43, 46, 61, 44, 13]], ["A24 Calliope", [82, 40, 11, 0, 0, 87, 27, 17, 0, 56, 89, 7, 127, 127, 6, 48, 74, 11]], ["A25 Donald Pluck", [76, 21, 9, 57, 0, 73, 105, 15, 0, 78, 82, 2, 5, 43, 10, 127, 44, 7]], ["A26 Celeste* (1 oct.up)", [28, 0, 0, 0, 0, 33, 24, 54, 0, 38, 96, 0, 44, 0, 81, 15, 44, 25]], ["A27 Elect. Piano I", [59, 0, 0, 0, 0, 16, 31, 61, 6, 35, 127, 1, 85, 43, 40, 0, 41, 1]], ["A28 Elect. Piano II", [0, 0, 0, 71, 0, 50, 69, 7, 0, 80, 102, 0, 68, 0, 22, 0, 73, 17]], ["A31 Clock Chimes* (1 oct. up)", [59, 0, 0, 0, 22, 44, 127, 0, 0, 127, 104, 0, 48, 0, 51, 127, 68, 27]], ["A32 Steel Drums", [33, 53, 0, 32, 9, 71, 46, 26, 0, 127, 127, 0, 26, 0, 37, 33, 74, 27]], ["A33 Xylophone", [0, 0, 0, 0, 0, 29, 24, 54, 0, 51, 127, 0, 29, 29, 38, 15, 44, 25]], ["A34 Brass III", [52, 20, 0, 35, 0, 66, 24, 11, 0, 12, 127, 58, 100, 94, 37, 22, 82, 25]], ["A35 Fanfare", [47, 0, 0, 70, 0, 44, 0, 32, 0, 67, 33, 72, 104, 75, 49, 50, 89, 24]], ["A36 String III", [48, 27, 0, 102, 0, 71, 14, 0, 0, 84, 73, 63, 31, 127, 45, 0, 26, 16]], ["A37 Pizzicato", [60, 18, 0, 102, 0, 66, 2, 5, 0, 42, 127, 0, 11, 0, 12, 0, 90, 0]], ["A38 High Strings", [58, 14, 0, 102, 0, 84, 8, 2, 0, 71, 77, 18, 44, 127, 40, 0, 12, 8]], ["A41 Bass clarinet", [52, 45, 8, 0, 0, 48, 36, 25, 8, 58, 104, 11, 75, 0, 25, 0, 41, 17]], ["A42 English Horn", [47, 45, 9, 102, 0, 70, 48, 7, 0, 27, 127, 8, 81, 26, 16, 0, 42, 1]], ["A43 Brass Ensemble", [52, 45, 0, 102, 0, 46, 44, 29, 1, 59, 103, 16, 103, 97, 34, 31, 82, 17]], ["A44 Guitar", [86, 58, 0, 65, 0, 12, 15, 71, 0, 30, 96, 0, 52, 54, 31, 0, 57, 17]], ["A45 Koto", [90, 28, 0, 94, 0, 40, 58, 29, 0, 75, 127, 0, 56, 0, 39, 2, 74, 1]], ["A46 Dark Pluck", [31, 0, 0, 87, 0, 38, 61, 27, 0, 71, 90, 0, 52, 15, 63, 97, 10, 25]], ["A47 Funky I", [4, 0, 0, 73, 0, 31, 23, 51, 0, 41, 71, 0, 30, 36, 2, 64, 89, 29]], ["A48 Synth Bass I (unison)", [58, 16, 1, 57, 50, 32, 0, 66, 0, 35, 75, 0, 34, 0, 36, 102, 41, 25]], ["A51 Lead I", [72, 88, 18, 0, 0, 40, 97, 36, 0, 52, 99, 0, 45, 73, 0, 0, 42, 29]], ["A52 Lead II", [24, 88, 0, 53, 0, 45, 0, 43, 0, 52, 56, 1, 23, 91, 75, 79, 57, 20]], ["A53 Lead III", [86, 71, 21, 102, 0, 60, 31, 18, 1, 76, 127, 0, 66, 48, 11, 0, 50, 21]], ["A54 Funky II", [4, 0, 0, 48, 0, 5, 23, 81, 0, 41, 100, 0, 30, 39, 2, 57, 74, 21]], ["A55 Synth Bass II", [90, 21, 0, 0, 0, 43, 0, 47, 0, 0, 78, 0, 37, 9, 22, 45, 49, 28]], ["A56 Funky III", [4, 0, 0, 9, 101, 38, 54, 45, 0, 10, 79, 0, 24, 0, 2, 127, 57, 29]], ["A57 Thud Wah", [62, 0, 0, 102, 8, 78, 89, 34, 0, 0, 106, 0, 0, 102, 45, 32, 26, 26]], ["A58 Going Up", [0, 0, 0, 100, 28, 79, 127, 37, 0, 65, 75, 0, 108, 18, 127, 0, 34, 19]], ["A61 Piano II", [1, 0, 0, 72, 0, 47, 0, 39, 0, 5, 78, 0, 98, 0, 32, 115, 42, 16]], ["A62 Clav", [66, 15, 1, 102, 0, 7, 11, 86, 2, 0, 120, 0, 39, 48, 14, 0, 73, 21]], ["A63 Frontier Organ", [79, 15, 3, 85, 0, 69, 54, 0, 0, 52, 127, 0, 0, 127, 0, 29, 42, 28]], ["A64 Snare Drum (unison)", [52, 27, 0, 0, 91, 94, 11, 17, 0, 0, 101, 0, 25, 0, 30, 64, 34, 17]], ["A65 Tom Toms (unison)", [62, 16, 8, 0, 127, 53, 4, 40, 0, 21, 101, 0, 30, 15, 40, 58, 33, 24]], ["A66 Timpani (unison)", [0, 0, 0, 35, 127, 25, 0, 54, 0, 24, 127, 1, 56, 26, 71, 47, 33, 17]], ["A67 Shaker", [21, 71, 0, 58, 127, 89, 45, 1, 17, 80, 127, 10, 9, 0, 0, 0, 34, 1]], ["A68 Synth Pad", [56, 0, 5, 43, 0, 37, 0, 84, 0, 127, 51, 0, 85, 75, 62, 37, 10, 24]], ["A71 Sweep I", [78, 0, 0, 102, 28, 115, 40, 67, 0, 0, 97, 0, 63, 127, 82, 42, 12, 18]], ["A72 Pluck Sweep", [68, 48, 0, 68, 0, 60, 111, 9, 6, 98, 45, 0, 91, 0, 77, 125, 26, 8]], ["A73 Repeater", [77, 20, 9, 101, 0, 97, 30, 56, 0, 57, 87, 14, 0, 41, 0, 44, 74, 23]], ["A74 Sweep II", [88, 72, 15, 97, 0, 66, 102, 68, 0, 70, 101, 0, 89, 53, 78, 48, 74, 25]], ["A75 Pluck Bell", [51, 0, 5, 17, 0, 39, 0, 49, 0, 127, 49, 0, 85, 75, 53, 49, 12, 24]], ["A76 Dark Synth Piano", [127, 0, 0, 0, 0, 56, 86, 6, 0, 71, 79, 0, 47, 0, 50, 127, 26, 26]], ["A77 Sustainer", [71, 0, 5, 46, 0, 39, 0, 84, 0, 127, 57, 0, 85, 75, 70, 49, 42, 24]], ["A78 Wah Release", [89, 14, 1, 25, 0, 72, 88, 19, 0, 66, 104, 0, 84, 0, 29, 87, 10, 19]], ["A81 Gong (play low chords)", [127, 0, 0, 102, 56, 70, 107, 5, 0, 72, 91, 3, 48, 127, 98, 0, 73, 19]], ["A82 Resonance Funk", [59, 0, 0, 0, 0, 26, 127, 45, 0, 89, 127, 0, 19, 0, 22, 0, 33, 17]], ["A83 Drum Booms* (1 oct. down)", [0, 0, 0, 102, 127, 42, 0, 34, 0, 58, 127, 0, 36, 15, 49, 46, 33, 25]], ["A84 Dust Storm", [0, 0, 0, 0, 127, 52, 85, 0, 44, 94, 127, 88, 91, 28, 85, 0, 33, 17]], ["A85 Rocket Men", [8, 32, 0, 102, 97, 73, 114, 8, 0, 56, 127, 0, 89, 127, 104, 0, 36, 3]], ["A86 Hand Claps", [59, 0, 0, 0, 127, 17, 88, 54, 0, 55, 127, 1, 11, 0, 8, 0, 33, 5]], ["A87 FX Sweep", [127, 65, 116, 102, 127, 71, 44, 83, 0, 94, 127, 0, 94, 0, 112, 127, 41, 18]], ["A88 Caverns", [0, 0, 0, 102, 127, 68, 118, 0, 0, 69, 107, 0, 13, 38, 47, 0, 33, 8]], ["B11 Strings", [57, 45, 0, 55, 0, 85, 0, 0, 0, 108, 52, 59, 32, 86, 40, 0, 26, 24]], ["B12 Violin", [66, 45, 20, 0, 0, 77, 0, 0, 0, 120, 110, 43, 45, 57, 26, 0, 50, 24]], ["B13 Chorus Vibes", [72, 45, 0, 0, 0, 10, 0, 59, 0, 23, 88, 0, 89, 47, 74, 0, 74, 25]], ["B14 Organ 1", [45, 42, 0, 73, 0, 60, 72, 14, 0, 127, 58, 0, 0, 0, 0, 97, 10, 29]], ["B15 Harpsichord 1", [23, 0, 0, 54, 0, 127, 127, 90, 0, 86, 125, 0, 60, 0, 31, 35, 44, 0]], ["B16 Recorder", [78, 0, 0, 8, 0, 6, 0, 46, 0, 127, 127, 5, 21, 127, 30, 0, 42, 17]], ["B17 Perc. Pluck", [62, 38, 8, 0, 0, 0, 0, 90, 0, 73, 65, 0, 16, 78, 116, 0, 74, 25]], ["B18 Noise Sweep", [127, 0, 0, 0, 127, 2, 0, 77, 0, 104, 92, 14, 78, 108, 120, 0, 33, 24]], ["B21 Space Chimes", [99, 0, 0, 0, 0, 70, 127, 0, 0, 74, 85, 0, 25, 0, 60, 0, 76, 24]], ["B22 Nylon Guitar", [72, 45, 0, 29, 0, 57, 0, 26, 0, 25, 115, 0, 89, 0, 32, 0, 42, 1]], ["B23 Orchestral Pad", [22, 45, 0, 105, 0, 33, 0, 55, 0, 36, 0, 29, 88, 50, 52, 127, 26, 24]], ["B24 Bright Pluck", [0, 0, 0, 58, 0, 57, 0, 40, 0, 86, 104, 0, 25, 42, 44, 0, 42, 17]], ["B25 Organ Bell", [78, 0, 6, 68, 0, 61, 0, 0, 0, 127, 62, 0, 0, 127, 26, 85, 90, 25]], ["B26 Accordion", [0, 0, 0, 64, 0, 77, 0, 14, 0, 74, 66, 8, 11, 110, 9, 80, 90, 1]], ["B27 FX Rise 1", [116, 0, 0, 0, 0, 108, 127, 16, 127, 64, 0, 0, 0, 127, 84, 0, 68, 26]], ["B28 FX Rise 2", [108, 0, 0, 0, 0, 94, 127, 80, 23, 127, 0, 0, 127, 51, 71, 0, 2, 26]], ["B31 Brass", [51, 127, 0, 73, 0, 0, 0, 94, 0, 127, 72, 3, 44, 51, 11, 0, 82, 28]], ["B32 Helicopter", [106, 0, 0, 48, 0, 82, 5, 93, 127, 0, 72, 0, 0, 35, 76, 127, 10, 27]], ["B33 Lute", [52, 0, 2, 105, 0, 29, 0, 35, 0, 86, 127, 0, 48, 34, 87, 0, 42, 25]], ["B34 Chorus Funk", [77, 94, 0, 73, 0, 47, 34, 53, 0, 65, 42, 0, 11, 34, 0, 79, 90, 29]], ["B35 Tomita", [78, 0, 0, 105, 0, 49, 125, 15, 2, 127, 57, 0, 14, 79, 0, 0, 36, 31]], ["B36 FX Sweep 1", [127, 0, 0, 0, 0, 58, 127, 16, 76, 64, 0, 0, 0, 127, 85, 0, 68, 24]], ["B37 Sharp Reed", [21, 0, 0, 73, 0, 33, 0, 53, 0, 65, 55, 2, 18, 112, 0, 0, 60, 28]], ["B38 Bass Pluck", [0, 0, 0, 60, 0, 37, 29, 28, 0, 43, 92, 0, 42, 35, 0, 0, 57, 24]], ["B41 Resonant Rise", [52, 0, 15, 0, 0, 66, 107, 31, 0, 73, 62, 0, 52, 39, 0, 0, 17, 30]], ["B42 Harpsichord 2", [0, 0, 0, 105, 0, 127, 95, 0, 0, 127, 107, 0, 45, 0, 0, 35, 60, 17]], ["B43 Dark Ensemble", [0, 0, 0, 57, 0, 55, 0, 0, 0, 107, 67, 21, 0, 127, 35, 75, 90, 27]], ["B44 Contact Wah", [78, 0, 0, 81, 0, 61, 101, 46, 0, 127, 127, 0, 0, 0, 0, 0, 42, 23]], ["B45 Noise Sweep 2", [127, 0, 0, 0, 127, 127, 0, 83, 0, 104, 116, 127, 79, 26, 83, 0, 68, 26]], ["B46 Glassy Wah", [0, 94, 0, 28, 0, 24, 34, 61, 0, 65, 112, 6, 18, 50, 38, 0, 42, 25]], ["B47 Phase Ensemble", [11, 45, 5, 105, 0, 79, 0, 0, 0, 127, 99, 84, 45, 57, 49, 0, 10, 24]], ["B48 Chorused Bell", [0, 11, 0, 105, 0, 59, 127, 0, 0, 127, 62, 0, 62, 0, 57, 101, 76, 24]], ["B51 Clav", [50, 11, 0, 91, 0, 32, 0, 63, 0, 0, 108, 0, 43, 55, 0, 7, 41, 9]], ["B52 Organ 2", [81, 0, 0, 104, 0, 54, 106, 7, 0, 127, 79, 0, 0, 0, 0, 0, 81, 29]], ["B53 Bassoon", [84, 38, 9, 90, 0, 35, 0, 43, 9, 98, 127, 5, 127, 106, 2, 0, 41, 1]], ["B54 Auto Release Noise Sweep", [127, 0, 0, 0, 127, 127, 0, 127, 0, 104, 107, 0, 79, 57, 83, 0, 68, 26]], ["B55 Brass Ensemble", [25, 94, 0, 73, 0, 47, 34, 35, 0, 65, 39, 6, 68, 67, 38, 0, 90, 24]], ["B56 Ethereal", [69, 0, 0, 105, 0, 47, 120, 0, 0, 127, 60, 92, 50, 127, 55, 59, 26, 24]], ["B57 Chorus Bell 2", [72, 45, 0, 29, 0, 0, 102, 62, 0, 90, 30, 0, 117, 0, 120, 0, 90, 25]], ["B58 Blizzard", [1, 0, 0, 105, 127, 56, 89, 7, 38, 121, 127, 78, 98, 87, 78, 0, 36, 0]], ["B61 E. Piano with Tremolo", [44, 0, 0, 21, 0, 22, 0, 35, 7, 107, 103, 0, 65, 60, 98, 127, 44, 16]], ["B62 Clarinet", [69, 22, 9, 0, 0, 35, 0, 43, 7, 98, 104, 5, 127, 106, 7, 0, 42, 1]], ["B63 Thunder", [127, 0, 0, 0, 127, 2, 0, 77, 0, 104, 107, 0, 22, 108, 120, 0, 33, 24]], ["B64 Reedy Organ", [35, 18, 0, 73, 0, 33, 0, 53, 0, 65, 69, 3, 44, 109, 0, 0, 42, 28]], ["B65 Flute / Horn", [34, 0, 0, 59, 0, 25, 0, 42, 0, 65, 22, 21, 73, 71, 48, 0, 25, 24]], ["B66 Toy Rhodes", [30, 45, 127, 0, 0, 58, 127, 0, 0, 127, 107, 0, 89, 0, 39, 0, 36, 0]], ["B67 Surf's Up", [1, 0, 0, 105, 127, 84, 11, 0, 49, 54, 75, 33, 97, 127, 121, 0, 36, 10]], ["B68 OW Bass", [50, 0, 0, 50, 0, 63, 84, 65, 0, 127, 70, 127, 0, 107, 0, 47, 57, 31]], ["B71 Piccolo", [70, 28, 0, 14, 0, 4, 0, 63, 16, 98, 87, 16, 103, 106, 21, 0, 60, 9]], ["B72 Melodic Taps", [99, 0, 0, 0, 127, 72, 112, 0, 0, 127, 127, 0, 24, 0, 24, 0, 65, 0]], ["B73 Meow Brass", [51, 127, 0, 73, 0, 45, 100, 35, 0, 65, 84, 4, 90, 0, 27, 0, 50, 28]], ["B74 Violin (high)", [71, 45, 22, 0, 0, 89, 0, 0, 3, 120, 85, 43, 45, 57, 26, 0, 52, 24]], ["B75 High Bells", [30, 45, 127, 0, 0, 76, 127, 0, 0, 127, 111, 0, 22, 52, 59, 0, 36, 0]], ["B76 Rolling Wah", [36, 0, 0, 105, 0, 60, 9, 0, 127, 0, 77, 34, 55, 127, 105, 0, 42, 24]], ["B77 Ping Bell", [0, 11, 0, 104, 0, 76, 127, 0, 0, 127, 83, 0, 23, 23, 57, 0, 76, 24]], ["B78 Brassy Organ", [16, 0, 0, 68, 0, 8, 0, 87, 0, 52, 14, 0, 36, 109, 0, 56, 89, 24]], ["B81 Low Dark Strings", [21, 45, 5, 81, 0, 71, 0, 0, 0, 103, 40, 83, 23, 109, 42, 0, 25, 24]], ["B82 Piccolo Trumpet", [51, 127, 0, 73, 0, 0, 0, 94, 0, 127, 97, 3, 44, 51, 11, 0, 50, 28]], ["B83 Cello", [57, 45, 21, 0, 0, 75, 0, 3, 1, 45, 109, 48, 65, 90, 34, 0, 49, 24]], ["B84 High Strings", [80, 0, 10, 70, 0, 92, 0, 0, 0, 71, 48, 27, 57, 57, 41, 0, 28, 24]], ["B85 Rocket Men", [108, 0, 0, 0, 0, 110, 127, 80, 63, 127, 0, 0, 127, 51, 89, 0, 2, 26]], ["B86 Forbidden Planet", [50, 11, 0, 44, 0, 29, 4, 88, 5, 95, 79, 0, 48, 23, 42, 9, 76, 1]], ["B87 Froggy", [78, 0, 0, 0, 0, 55, 127, 43, 0, 127, 77, 0, 0, 0, 0, 127, 41, 23]], ["B88 Owgan", [50, 0, 0, 45, 0, 38, 84, 32, 0, 127, 101, 0, 49, 55, 0, 56, 57, 25]]] def get_juno_patch(patch_number): # json was created by: # import javaobj, json # pobj = javaobj.load(open('juno106_factory_patches.ser', 'rb')) # patches = [(p.name, list(p.sysex)) for p in pobj.v.elementData if p is not None] # with open('juno106patches.json', 'w') as f: # f.write(json.dumps(patches)) #pobj = javaobj.load(open('juno106_factory_patches.ser', 'rb')) #patch = pobj.v.elementData[patch_number] global _PATCHES name, sysex = _PATCHES[patch_number] return name, bytes(sysex) class JunoPatch: """Encapsulates information in a Juno Patch.""" name = "" lfo_rate = 0 lfo_delay_time = 0 dco_lfo = 0 dco_pwm = 0 dco_noise = 0 vcf_freq = 0 vcf_res = 0 vcf_env = 0 vcf_lfo = 0 vcf_kbd = 0 vca_level = 0 env_a = 0 env_d = 0 env_s = 0 env_r = 0 dco_sub = 0 stop_16 = False stop_8 = False stop_4 = False pulse = False saw = False chorus = 0 pwm_manual = False # else lfo vca_gate = False # else env vcf_neg = False # else pos hpf = 0 portamento = 0 # Map of setup_fn: [params triggering setup] post_set_fn = {'lfo': ['lfo_rate', 'lfo_delay_time'], 'dco': ['dco_lfo', 'dco_pwm', 'dco_noise', 'dco_sub', 'stop_16', 'stop_8', 'stop_4', 'pulse', 'saw', 'pwm_manual', 'portamento'], 'vcf': ['vcf_neg', 'vcf_env', 'vcf_freq', 'vcf_lfo', 'vcf_res', 'vcf_kbd', 'vca_gate'], 'env': ['env_a', 'env_d', 'env_s', 'env_r', 'vca_level', 'vca_gate'], 'cho': ['chorus', 'hpf']} # These lists name the fields in the order they appear in the sysex. FIELDS = ['lfo_rate', 'lfo_delay_time', 'dco_lfo', 'dco_pwm', 'dco_noise', 'vcf_freq', 'vcf_res', 'vcf_env', 'vcf_lfo', 'vcf_kbd', 'vca_level', 'env_a', 'env_d', 'env_s', 'env_r', 'dco_sub'] # After the 16 integer values, there are two bytes of bits. BITS1 = ['stop_16', 'stop_8', 'stop_4', 'pulse', 'saw'] BITS2 = ['pwm_manual', 'vcf_neg', 'vca_gate'] # Non-sysex state: Do we use the cheaper 12 dB/oct VCF? cheap_filter = False # Patch number we're based on, if any. patch_number = None # Name, if any name = None # Params that have been changed since last send_to_AMY. dirty_params = set() # Flag to defer param updates. defer_param_updates = False # Amy synth amy_synth = None @staticmethod def from_patch_number(patch_number): name, sysexbytes = get_juno_patch(patch_number) return JunoPatch.from_sysex(sysexbytes, name, patch_number) @classmethod def from_sysex(cls, sysexbytes, name=None, patch_number=None): """Decode sysex bytestream into JunoPatch fields.""" assert len(sysexbytes) == 18 result = JunoPatch() result.name = name result.patch_number = patch_number result._init_from_sysex(sysexbytes) return result def _init_from_patch_number(self, patch_number): self.patch_number = patch_number self.name, sysexbytes = get_juno_patch(patch_number) self._init_from_sysex(sysexbytes) def _init_from_sysex(self, sysexbytes): # The first 16 bytes are sliders. for index, field in enumerate(self.FIELDS): setattr(self, field, int(sysexbytes[index])/127.0) # Then there are two bytes of switches. for index, field in enumerate(self.BITS1): setattr(self, field, (int(sysexbytes[16]) & (1 << index)) > 0) # Chorus has a weird mapping. Bit 5 is ~Chorus, bit 6 is ChorusI-notII setattr(self, 'chorus', [2, 0, 1, 0][int(sysexbytes[16]) >> 5]) for index, field in enumerate(self.BITS2): setattr(self, field, (int(sysexbytes[17]) & (1 << index)) > 0) # Bits 3 & 4 also have flipped endianness & sense. setattr(self, 'hpf', [3, 2, 1, 0][int(sysexbytes[17]) >> 3]) # Nonstandard extension: Put "cheap" flag in bit 5 of byte 2. self.cheap_filter = int(sysexbytes[17] & (1 << 5)) > 0 def to_sysex(self): """Return the 18 byte SYSEX corresponding to current object state.""" byte_values = [] # 16 continuous values in order specified by self.FIELDS. for field in self.FIELDS: byte_values.append(int(round(127.0 * getattr(self, field)))) # 2 bytes of booleans. val = 0 for index, field in enumerate(self.BITS1): val |= (1 << index) if getattr(self, field) else 0 # Chorus has a weird mapping. Bit 5 is ~Chorus, bit 6 is ChorusI-notII val |= ([1, 2, 0][getattr(self, 'chorus')]) << 5 byte_values.append(val) val = 0 for index, field in enumerate(self.BITS2): val |= (1 << index) if getattr(self, field) else 0 # Bits 3 & 4 also have flipped endianness & sense. val |= ([3, 2, 1, 0][getattr(self, 'hpf')]) << 3 # Nonstandard extension: Put "cheap" flag in bit 5 of byte 2. if self.cheap_filter: val |= (1 << 5) byte_values.append(val) return bytes(byte_values) def set_synth(self, amy_synth): self.amy_synth = amy_synth def _breakpoint_string(self): """Format a breakpoint string from the ADSR parameters reaching a peak.""" return "%d,%s,%d,%s,%d,0" % ( to_attack_time(self.env_a), ffmt(1.0), to_decay_time(self.env_d), ffmt(to_level(self.env_s)), to_release_time(self.env_r) ) def _amp_coef_string(self, level): return '%s,,1,1,0' % ffmt(to_level(level)) def _freq_coef_string(self, base_freq): return '%s,1,,,,%s,1' % ( ffmt(base_freq), ffmt(0.03 * to_level(self.dco_lfo))) def base_freq(self): # Only one of stop_{16,8,4} should be set. base_freq = constants.ZERO_LOGFREQ_IN_HZ # 261.63 # The mid note if self.stop_16: base_freq /= 2 elif self.stop_4: base_freq *= 2 return base_freq def _portamento_ms(self, port_val): # Portamento maps exponentially from 1 = 10 ms to 127 = 2560 ms if port_val == 0: return 0 return int(round(20 * math.pow(2, port_val * 127 / 30))) def init_AMY(self): """Output AMY commands to set up patches on all the allocated synth. Send amy.send(osc=0, note=50, vel=1) afterwards.""" #amy.reset() # base_osc is filter/VCA (AMYboard standard) # base_osc + 1 is LFO (AMYboard standard) # base_osc + 2 is pulse/PWM # base_osc + 3 is SAW # base_osc + 4 is SUBOCTAVE # base_osc + 5 is NOISE # env0 is VCA (on base_osc only) # env1 is VCF (on base_osc only) # These are the canonical oscs (to add to amy.send(synth=..)). self.ctl_osc = 0 self.pwm_osc = 2 self.saw_osc = 3 self.sub_osc = 4 self.nse_osc = 5 self.lfo_osc = 1 # One-time setup of oscs. self.amy_send(osc=self.lfo_osc, wave=amy.TRIANGLE, amp='1,,0,1') filter_type = amy.FILTER_LPF if self.cheap_filter else amy.FILTER_LPF24 self.amy_send(osc=self.ctl_osc, wave=amy.SILENT, filter_type=filter_type, mod_source=self.lfo_osc, chained_osc=self.pwm_osc) self.amy_send(osc=self.pwm_osc, wave=amy.PULSE, mod_source=self.lfo_osc, chained_osc=self.saw_osc) self.amy_send(osc=self.saw_osc, wave=amy.SAW_UP, mod_source=self.lfo_osc, chained_osc=self.sub_osc) self.amy_send(osc=self.sub_osc, wave=amy.PULSE, mod_source=self.lfo_osc, chained_osc=self.nse_osc) self.amy_send(osc=self.nse_osc, wave=amy.NOISE, mod_source=self.lfo_osc) # Setup all the variable params. self.update_lfo() self.update_dco() self.update_vcf() self.update_env() self.update_cho() def update_lfo(self): lfo_args = {'freq': to_lfo_freq(self.lfo_rate), 'bp0': '%i,1.0,10000,0' % to_lfo_delay(self.lfo_delay_time)} self.amy_send(osc=self.lfo_osc, **lfo_args) def update_dco(self): base_freq = self.base_freq() freq_str = self._freq_coef_string(base_freq) # PWM square wave. const_duty = 0 lfo_duty = to_level(self.dco_pwm) port_ms = self._portamento_ms(self.portamento) if self.pwm_manual: # Swap duty parameters. const_duty, lfo_duty = lfo_duty, const_duty self.amy_send( osc=self.pwm_osc, amp='%s,,0,0' % ffmt(to_level(self.pulse)), freq=freq_str, portamento=port_ms, duty='%s,,,,,%s' % ( ffmt(0.5 + 0.5 * const_duty), ffmt(0.5 * lfo_duty) ), ) self.amy_send( osc=self.saw_osc, amp='%s,,0,0' % ffmt(to_level(self.saw)), freq=freq_str, portamento=port_ms, ) self.amy_send( osc=self.sub_osc, amp='%s,,0,0' % ffmt(to_level(self.dco_sub)), freq=self._freq_coef_string(base_freq / 2.0), portamento=port_ms, ) self.amy_send( osc=self.nse_osc, amp='%s,,0,0' % ffmt(to_level(self.dco_noise)), ) def update_vcf(self): vcf_env_polarity = -1.0 if self.vcf_neg else 1.0 vcf_kbd_level = to_level(self.vcf_kbd) vcf_freq_hz = to_filter_freq(self.vcf_freq) # The Juno VCF kbd value is 0 for C4 (MIDI 60), but our scale has 0 at A4 (MIDI 69) # So when the filter freq depends on kbd contribution, it will be wrong. # We want log2(uncooked vcf_freq_hz) + vcf_kbd_level * (midi_note - 60) / 12 # to equal log2(cooked vcf_freq_hz) + vcf_kbd_level * (midi_note - 69) / 12 # So, cooked / uncooked) = exp2(vcf_kbd_level * 9 / 12) vcf_freq_hz *= (2.0 ** (0.75 * vcf_kbd_level)) eg0_coef = 11 * vcf_env_polarity * to_level(self.vcf_env) eg1_coef = 0 if self.vca_gate: eg1_coef = eg0_coef eg0_coef = 0 self.amy_send(osc=self.ctl_osc, resonance=to_resonance(self.vcf_res), filter_freq='%s,%s,,%s,%s,%s' % ( ffmt(vcf_freq_hz), ffmt(vcf_kbd_level), ffmt(eg0_coef), ffmt(eg1_coef), ffmt(1.25 * to_level(self.vcf_lfo)))) def update_env(self): coefs = {'osc': self.ctl_osc, 'amp': self._amp_coef_string(self.vca_level)} bp_coefs = self._breakpoint_string() if self.vca_gate: coefs |= {'bp0': '0,1,0,1,0,0', 'bp1': bp_coefs} else: coefs |= {'bp0': bp_coefs} self.amy_send(**coefs) def update_cho(self): # Chorus & HPF eq_l = eq_m = eq_h = 0 if self.hpf == 0: eq_l = 7 eq_m = -3 eq_h = -3 elif self.hpf == 1: pass elif self.hpf == 2: eq_l = -8 elif self.hpf == 3: eq_l = -15 eq_m = 8 eq_h = 8 cho_args = { 'eq': '%s,%s,%s' % (str(eq_l), str(eq_m), str(eq_h)), } if self.chorus == 0: cho_args['chorus'] = '0' else: # We choose juno 60-style I+II for chorus=3. Juno 6-style would be freq=8 depth=0.25 cho_args['chorus'] = '1,,%s,%s' % ( (0, 0.5, 0.83, 1)[self.chorus], # chorus_freq (0, 0.5, 0.5, 0.08)[self.chorus], # chorus_depth ) # *Don't* send to oscs, these ones are global. amy.send(**cho_args) # Setters for each Juno UI control def set_param(self, param, val): setattr(self, param, val) if self.defer_param_updates: self.dirty_params.add(param) else: for group, params in self.post_set_fn.items(): if param in params: getattr(self, 'update_' + group)() def send_deferred_params(self): for group, params in self.post_set_fn.items(): if self.dirty_params.intersection(params): getattr(self, 'update_' + group)() self.dirty_params = set() self.defer_param_updates = False def set_patch(self, patch): self._init_from_patch_number(patch) #print("New patch", patch, ":", self.name) self.init_AMY() def set_sysex(self, sysex): self._init_from_sysex(sysex) #print("New patch", patch, ":", self.name) self.init_AMY() def set_pitch_bend(self, value): # Global, not osc-specific. amy.send(pitch_bend=value) def amy_send(self, osc, **kwargs): if self.amy_synth: amy.send(synth=self.amy_synth, osc=osc, **kwargs) else: amy.send(osc=osc, **kwargs) ================================================ FILE: amy/piano.py ================================================ # piano.py # examples from piano.html import amy from . import piano_params def piano_example(base_note=72, volume=5, send_command=amy.send, init_command=lambda: None): amy.send(reset=amy.RESET_TIMEBASE) amy.send(time=0, volume=volume) init_command() send_command(time=50, voices='0', note=base_note, vel=0.05) send_command(time=435, voices='0', note=base_note, vel=0) send_command(time=450, voices='0', note=base_note, vel=0.63) send_command(time=835, voices='0', note=base_note, vel=0) send_command(time=850, voices='0', note=base_note, vel=1.0) send_command(time=1485, voices='0', note=base_note, vel=0) send_command(time=1500, voices='1', note=base_note - 24, vel=0.6) send_command(time=2100, voices='2', note=base_note + 24, vel=1.0) send_command(time=3000, voices='1', note=base_note - 24, vel=0) send_command(time=3000, voices='2', note=base_note + 24, vel=0) def juno_example(): piano_example(base_note=74, volume=10, init_command=lambda: amy.send(time=0, voices='0,1,2', patch=7)) def dx7_example(): piano_example(base_note=50, volume=25, init_command=lambda: amy.send(time=0, voices='0,1,2', patch=137)) """Piano notes generated on amy/tulip.""" # Uses the partials amplitude breakpoints and residual written by piano_heterodyne.ipynb. try: from ulab import numpy as np except ImportError: import numpy as np # Read in the params file written by piano_heterodyne.ipynb # Contents: # sample_times_ms - single vector of fixed log-spaced envelope sample times (in int16 integer ms). # notes - the MIDI numbers corresponding to each note described. # velocities - The (MIDI) strike velocities available for each note, the same for all notes. # num_harmonics - Array of (num_notes * num_velocities) counts of how many harmonics are defined for each note+vel combination. # harmonics_freq - Vector of (total_num_harmonics) int16s giving freq for each harmonic in "MIDI cents" i.e. 6900 = 440 Hz. # harmonics_mags - Array of (total_num_harmonics, num_sample_times) uint8s giving envelope samples for each harmonic. In dB, between 0 and 100. from amy.piano_params import notes_params NOTES = np.array(notes_params['notes'], dtype=np.int8) VELOCITIES = np.array(notes_params['velocities'], dtype=np.int8) NUM_HARMONICS = np.array(notes_params['num_harmonics'], dtype=np.int16) assert len(NUM_HARMONICS) == len(NOTES) * len(VELOCITIES) NUM_MAGS = len(notes_params['harmonics_mags'][0]) # Add in a derived diff-times and start-harmonic fields # Reintroduce the initial zero-time... SAMPLE_TIMES = np.array([0] + notes_params['sample_times_ms']) #.. so we can neatly calculate the time-deltas needed for BP strings. DIFF_TIMES = SAMPLE_TIMES[1:] - SAMPLE_TIMES[:-1] # Lookup to find first harmonic for nth note. START_HARMONIC = np.zeros(len(NUM_HARMONICS), dtype=np.int16) for i in range(len(NUM_HARMONICS)): # No cumsum in ulab.numpy START_HARMONIC[i] = np.sum(NUM_HARMONICS[:i]) # We build a single array for all the harmonics with the frequency as the # first column, followed by the envelope magnitudes. Then, we can pull # out the entire description for a given note/velocity pair simply by # pulling out NUM_HARMONICS[harmonic_index] rows starting at # START_HARMONIC[harmonic_index] FREQ_MAGS = np.zeros((np.sum(NUM_HARMONICS), 1 + NUM_MAGS), dtype=np.int16) FREQ_MAGS[:, 0] = np.array(notes_params['harmonics_freq'], dtype=np.int16) FREQ_MAGS[:, 1:] = np.array(notes_params['harmonics_mags'], dtype=np.int16) def harms_params_from_note_index_vel_index(note_index, vel_index): """Retrieve a (log-domain) harms_params list for a given note/vel index pair.""" # A harmonic is represented as a [freq_cents, mag1_db, mag2_db, .. mag20_db] row. # A note is represented as NUM_HARMONICS (usually 20) rows. note_vel_index = note_index * len(VELOCITIES) + vel_index num_harmonics = NUM_HARMONICS[note_vel_index] start_harmonic = START_HARMONIC[note_vel_index] harms_params = FREQ_MAGS[start_harmonic : start_harmonic + num_harmonics, :] return harms_params def interp_harms_params(hp0, hp1, alpha): """Return harm_param list that is alpha of the way to hp1 from hp0.""" # hp_ is [[freq_h1, mag1, mag2, ...], [freq_h2, mag1, mag2, ..], ...] num_harmonics = min(hp0.shape[0], hp1.shape[0]) # Assume the units are log-scale, so linear interpolation is good. return hp0[:num_harmonics] + alpha * (hp1[:num_harmonics] - hp0[:num_harmonics]) def cents_to_hz(cents): """Convert 'Midi cents' frequency to Hz. 6900 cents -> 440 Hz""" return 440 * (2 ** ((cents - 6900) / 1200.0)) def db_to_lin(d): """Convert the db-scale magnitudes to linear. 0 dB -> 0.00001, so 100 dB -> 1.0.""" # Clip anything below 0.001 to zero. return np.maximum(0, 10.0 ** ((d - 100) / 20.0) - 0.001) def harms_params_for_note_vel(note, vel): """Convert midi note and velocity into an interpolated harms_params list of harmonic specifications.""" note = np.clip(note, NOTES[0], NOTES[-1]) vel = np.clip(vel, VELOCITIES[0], VELOCITIES[-1]) note_index = -1 + np.sum(NOTES[:-1] <= note) # at most the last-but-one value. strike_index = -1 + np.sum(VELOCITIES[:-1] <= vel) lower_note = NOTES[note_index] upper_note = NOTES[note_index + 1] note_alpha = (note - lower_note) / (upper_note - lower_note) lower_strike = VELOCITIES[strike_index] upper_strike = VELOCITIES[strike_index + 1] strike_alpha = (vel - lower_strike) / (upper_strike - lower_strike) # We interpolate to describe a note at both strike indices, # then interpolate those to get the strike. harms_params = interp_harms_params( interp_harms_params( harms_params_from_note_index_vel_index(note_index, strike_index), harms_params_from_note_index_vel_index(note_index + 1, strike_index), note_alpha, ), interp_harms_params( harms_params_from_note_index_vel_index(note_index, strike_index + 1), harms_params_from_note_index_vel_index(note_index + 1, strike_index + 1), note_alpha, ), strike_alpha, ) return harms_params def init_piano_voice(num_partials, base_osc=0, **kwargs): """One-time initialization of the unchanging parts of the partials voices.""" amy.send(osc=base_osc, wave=amy.BYO_PARTIALS, num_partials=num_partials, amp={'eg0': 0}, **kwargs) for partial in range(1, num_partials + 1): bp_string = '0,0,' + ','.join("%d,0" % t for t in DIFF_TIMES) # We append a release segment to die away to silence over 200ms on note-off. bp_string += ',200,0' amy.send(osc=base_osc + partial, wave=amy.PARTIAL, bp0=bp_string, eg0_type=amy.ENVELOPE_TRUE_EXPONENTIAL, **kwargs) def setup_piano_voice(harms_params, base_osc=0, **kwargs): """Configure a set of PARTIALs oscs to play a particular note and velocity.""" num_partials = len(harms_params) amy.send(osc=base_osc, wave=amy.BYO_PARTIALS, num_partials=num_partials, **kwargs) for i in range(num_partials): f0_hz = cents_to_hz(harms_params[i, 0]) env_vals = db_to_lin(harms_params[i, 1:]) # Omit the time-deltas from the list to save space. The osc will keep the ones we set up in init_piano_voice. bp_string = ',,' + ','.join(",%.3f" % val for val in env_vals) # Add final release. bp_string += ',200,0' amy.send(osc=base_osc + 1 + i, freq=f0_hz, bp0=bp_string, **kwargs) patch_string = 'v0w10Zv%dw%dZ' % (NUM_HARMONICS[0] + 1, amy.PARTIAL) # The lowest note provides an upper-bound on the number of partials we need to allocate. def init_piano_voices(num_partials=NUM_HARMONICS[0]): amy.send(patch='1024', patch_string=patch_string) amy.send(voices='0,1,2', patch=1024) init_piano_voice(num_partials, voices='0,1,2') # piano_note_on (below) overwrites these settings before each note, # but pre-configure each note to C4.mf so we can experiment. setup_piano_voice(harms_params_for_note_vel(note=60, vel=80), voices='0,1,2') def play_piano_partials_1(): piano_example(base_note=62, volume=5, init_command=init_piano_voices) def piano_note_on(note=60, vel=1, **kwargs): if vel == 0: # Note off. amy.send(vel=0, **kwargs) else: setup_piano_voice(harms_params_for_note_vel(note, round(vel * 127)), **kwargs) # We already configured the pitches and magnitudes in setup, so # the note and vel of the note-on are always the same. amy.send(note=60, vel=1, **kwargs) def play_piano_partials_2(): piano_example(base_note=62, init_command=init_piano_voices, send_command=piano_note_on) ================================================ FILE: amy/piano_params.py ================================================ # Notes params generated by piano_heterodyne.ipynb notes_params = {"sample_times_ms": [4, 8, 12, 16, 24, 32, 48, 64, 96, 128, 192, 256, 384, 512, 768, 1024, 1536, 2048, 3072, 4096], "notes": [24, 28, 32, 36, 40, 44, 48, 52, 56, 60, 64, 68, 72, 76, 80, 84, 88, 92, 96, 100, 104], "velocities": [40, 80, 120], "num_harmonics": [20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 17, 17, 17, 13, 13, 13, 11, 11, 11, 9, 8, 9, 7, 7, 7, 6, 5, 5, 3, 4, 4], "harmonics_freq": [2363, 3491, 4191, 4691, 5081, 5398, 5667, 5899, 6109, 6297, 6466, 6621, 6765, 6899, 7024, 7142, 7255, 7361, 7462, 7559, 2172, 3587, 4287, 4787, 5175, 5493, 5762, 5996, 6205, 6393, 6561, 6716, 6860, 6993, 7118, 7238, 7349, 7456, 7556, 7653, 2394, 3588, 4289, 4787, 5176, 5495, 5764, 5998, 6207, 6395, 6564, 6717, 6862, 6995, 7120, 7241, 7351, 7458, 7557, 7654, 2851, 3989, 4692, 5187, 5576, 5893, 6161, 6394, 6600, 6785, 6952, 7105, 7246, 7379, 7501, 7616, 7724, 7828, 7925, 8019, 3069, 3987, 4692, 5187, 5577, 5892, 6161, 6393, 6600, 6784, 6952, 7105, 7246, 7379, 7501, 7616, 7725, 7828, 7926, 8019, 3008, 3989, 4693, 5188, 5577, 5894, 6162, 6395, 6601, 6785, 6953, 7106, 7247, 7379, 7502, 7617, 7726, 7829, 7927, 8019, 3114, 4391, 5094, 5596, 5984, 6300, 6567, 6804, 7008, 7191, 7358, 7512, 7653, 7784, 7906, 8022, 8130, 8233, 8330, 8424, 3224, 4390, 5096, 5595, 5983, 6299, 6567, 6800, 7006, 7190, 7358, 7512, 7653, 7784, 7906, 8022, 8130, 8232, 8330, 8422, 3275, 4391, 5099, 5598, 5985, 6300, 6567, 6805, 7008, 7191, 7358, 7513, 7654, 7785, 7907, 8022, 8130, 8233, 8330, 8423, 3610, 4789, 5497, 5999, 6386, 6702, 6972, 7205, 7411, 7596, 7763, 7916, 8055, 8189, 8314, 8427, 8551, 8655, 8819, 8852, 3623, 4792, 5493, 5999, 6385, 6702, 6972, 7205, 7411, 7596, 7763, 7916, 8054, 8189, 8313, 8426, 8538, 8639, 8737, 8831, 3646, 4792, 5491, 6000, 6386, 6703, 6973, 7206, 7412, 7597, 7764, 7919, 8054, 8190, 8313, 8427, 8540, 8641, 8739, 8832, 4008, 5200, 5904, 6402, 6790, 7106, 7376, 7608, 7815, 7998, 8165, 8318, 8460, 8591, 8716, 8828, 8942, 9042, 9140, 9229, 4008, 5200, 5903, 6403, 6789, 7106, 7376, 7607, 7815, 7999, 8165, 8318, 8460, 8591, 8714, 8828, 8937, 9040, 9137, 9228, 4010, 5201, 5903, 6404, 6790, 7108, 7376, 7608, 7816, 7999, 8166, 8318, 8461, 8592, 8714, 8829, 8938, 9040, 9137, 9228, 4398, 5600, 6302, 6802, 7189, 7506, 7774, 8007, 8213, 8398, 8566, 8720, 8860, 8992, 9130, 9234, 9347, 9448, 9543, 9645, 4398, 5599, 6303, 6801, 7188, 7507, 7773, 8006, 8213, 8397, 8565, 8717, 8858, 8990, 9112, 9227, 9334, 9438, 9536, 9629, 4400, 5598, 6304, 6803, 7190, 7508, 7775, 8008, 8215, 8398, 8566, 8718, 8860, 8991, 9113, 9228, 9337, 9440, 9536, 9629, 4782, 6001, 6703, 7203, 7591, 7907, 8175, 8410, 8623, 8800, 8966, 9124, 9265, 9407, 9526, 9658, 9778, 9886, 9995, 10084, 4797, 6000, 6702, 7204, 7591, 7907, 8174, 8407, 8615, 8797, 8964, 9117, 9258, 9389, 9511, 9625, 9735, 9837, 9934, 10027, 4801, 6002, 6703, 7205, 7592, 7908, 8176, 8408, 8616, 8798, 8966, 9118, 9259, 9390, 9512, 9626, 9736, 9838, 9934, 10028, 5204, 6408, 7107, 7608, 7994, 8311, 8580, 8812, 9020, 9202, 9373, 9527, 9666, 9802, 9927, 10042, 10158, 10256, 10348, 10446, 5206, 6408, 7107, 7608, 7994, 8311, 8580, 8812, 9019, 9205, 9372, 9526, 9667, 9799, 9916, 10038, 10147, 10251, 10349, 10444, 5208, 6409, 7108, 7609, 7995, 8312, 8581, 8812, 9020, 9205, 9373, 9527, 9668, 9800, 9921, 10039, 10147, 10252, 10351, 10443, 5606, 6807, 7508, 8009, 8396, 8714, 8994, 9205, 9428, 9629, 9787, 9941, 10072, 10212, 10347, 10463, 10569, 10668, 10765, 10858, 5603, 6807, 7509, 8009, 8396, 8714, 8983, 9216, 9423, 9609, 9778, 9932, 10072, 10209, 10335, 10452, 10563, 10667, 10767, 10863, 5599, 6808, 7510, 8010, 8397, 8715, 8984, 9217, 9425, 9611, 9779, 9934, 10075, 10210, 10334, 10451, 10562, 10667, 10767, 10862, 6002, 7204, 7909, 8408, 8797, 9126, 9394, 9638, 9844, 10034, 10201, 10348, 10493, 10621, 10748, 10862, 10970, 11069, 11174, 11257, 6003, 7204, 7908, 8408, 8796, 9115, 9385, 9621, 9828, 10021, 10187, 10345, 10491, 10627, 10753, 10871, 10986, 11088, 11192, 11288, 6004, 7205, 7909, 8408, 8797, 9115, 9386, 9621, 9829, 10018, 10187, 10344, 10489, 10624, 10751, 10871, 10984, 11092, 11195, 11293, 6406, 7603, 8310, 8811, 9197, 9528, 9807, 10043, 10310, 10430, 10611, 10767, 10911, 11047, 11174, 11285, 11400, 11508, 11611, 11699, 6409, 7602, 8310, 8811, 9201, 9522, 9794, 10031, 10263, 10429, 10610, 10767, 10921, 11054, 11187, 11305, 11406, 11526, 11633, 11728, 6410, 7602, 8310, 8812, 9202, 9522, 9795, 10031, 10241, 10432, 10606, 10764, 10909, 11053, 11183, 11307, 11421, 11535, 11641, 11743, 6806, 8006, 8712, 9210, 9616, 9933, 10237, 10412, 10652, 10840, 11011, 11164, 11299, 11410, 11549, 11675, 11779, 11888, 11975, 12073, 6807, 8006, 8713, 9214, 9606, 9928, 10202, 10441, 10658, 10855, 11030, 11209, 11350, 11483, 11616, 11733, 11855, 11956, 12071, 12180, 6808, 8007, 8714, 9215, 9607, 9929, 10203, 10442, 10656, 10850, 11025, 11260, 11338, 11485, 11618, 11744, 11868, 11975, 12091, 12198, 7203, 8404, 9117, 9628, 10035, 10354, 10659, 10914, 11147, 11380, 11552, 11716, 11904, 12052, 12205, 12350, 12490, 12629, 12753, 12885, 7203, 8405, 9112, 9616, 10012, 10339, 10621, 10863, 11067, 11254, 11419, 11587, 11729, 11876, 12000, 12124, 12241, 12353, 12456, 12562, 7203, 8406, 9112, 9617, 10012, 10337, 10615, 10859, 11077, 11248, 11460, 11652, 11791, 11940, 12076, 12212, 12324, 12430, 12541, 12648, 7606, 8805, 9529, 10039, 10389, 10754, 11037, 11275, 11460, 11674, 11852, 12002, 12155, 12296, 12430, 12553, 12680, 12791, 12898, 13007, 7607, 8809, 9516, 10022, 10413, 10745, 11028, 11274, 11465, 11672, 11849, 12002, 12160, 12296, 12430, 12553, 12673, 12793, 12899, 13003, 7607, 8809, 9516, 10020, 10415, 10744, 11025, 11273, 11492, 11680, 11880, 12068, 12212, 12358, 12494, 12627, 12752, 12878, 12993, 13110, 8006, 9206, 9946, 10405, 10854, 11193, 11444, 11706, 11936, 12136, 12320, 12490, 12660, 12814, 12959, 13093, 13237, 8007, 9203, 9925, 10423, 10846, 11183, 11436, 11694, 11926, 12117, 12295, 12461, 12621, 12767, 12911, 13051, 13177, 8008, 9212, 9921, 10428, 10830, 11162, 11443, 11703, 11930, 12135, 12321, 12495, 12659, 12815, 12960, 13102, 13241, 8400, 9616, 10349, 10895, 11315, 11634, 11922, 12169, 12402, 12618, 12813, 13015, 13183, 8398, 9607, 10331, 10859, 11293, 11620, 11911, 12158, 12386, 12597, 12790, 12979, 13148, 8400, 9614, 10323, 10842, 11255, 11606, 11902, 12163, 12395, 12617, 12820, 13012, 13186, 8802, 10047, 10789, 11338, 11714, 12032, 12335, 12599, 12833, 13055, 13264, 8809, 10024, 10758, 11307, 11704, 12027, 12332, 12600, 12838, 13051, 13262, 8810, 10018, 10730, 11263, 11677, 12025, 12336, 12607, 12848, 13066, 13282, 9119, 10411, 11221, 11722, 12116, 12449, 12735, 13015, 13246, 9211, 10418, 11212, 11719, 12131, 12476, 12767, 13048, 9216, 10420, 11163, 11688, 12105, 12453, 12745, 13030, 13271, 9341, 10828, 11588, 12106, 12512, 12830, 13106, 9578, 10866, 11617, 12155, 12598, 12960, 13292, 9613, 10827, 11575, 12112, 12547, 12902, 13211, 9520, 11256, 12011, 12541, 12935, 13269, 9943, 11276, 12039, 12603, 13022, 9996, 11242, 12016, 12585, 13016, 8908, 11863, 12902, 10199, 11574, 12376, 12924, 10409, 11646, 12421, 12947], "harmonics_mags": [[39, 40, 41, 41, 38, 38, 39, 40, 40, 46, 43, 40, 22, 40, 32, 31, 36, 34, 44, 37], [52, 53, 55, 56, 56, 52, 45, 53, 47, 50, 50, 53, 52, 53, 52, 52, 52, 50, 47, 46], [65, 68, 70, 72, 73, 73, 72, 73, 72, 72, 72, 73, 72, 72, 71, 71, 70, 70, 68, 67], [69, 71, 72, 73, 75, 76, 77, 77, 75, 75, 76, 75, 75, 74, 73, 71, 69, 68, 64, 59], [69, 71, 72, 73, 74, 73, 74, 74, 75, 74, 74, 74, 73, 73, 71, 70, 67, 64, 59, 55], [68, 70, 72, 73, 75, 76, 77, 76, 73, 73, 73, 73, 72, 72, 71, 70, 68, 66, 63, 59], [52, 52, 52, 52, 53, 53, 50, 52, 53, 51, 52, 52, 52, 52, 52, 51, 50, 50, 48, 44], [42, 41, 42, 47, 53, 56, 56, 57, 59, 59, 56, 55, 51, 47, 44, 44, 38, 31, 19, 32], [48, 52, 54, 56, 58, 60, 61, 63, 62, 63, 63, 63, 62, 62, 60, 59, 56, 54, 49, 43], [56, 57, 57, 58, 59, 60, 61, 62, 64, 64, 64, 63, 62, 61, 59, 57, 53, 51, 46, 43], [47, 44, 50, 56, 62, 65, 67, 67, 66, 65, 64, 63, 62, 62, 60, 58, 54, 50, 42, 36], [60, 63, 64, 65, 68, 69, 71, 71, 71, 72, 71, 71, 70, 70, 69, 67, 64, 61, 51, 43], [58, 60, 61, 62, 63, 64, 64, 64, 66, 66, 66, 66, 65, 64, 63, 62, 59, 56, 50, 43], [44, 50, 54, 57, 60, 62, 63, 63, 62, 62, 62, 61, 61, 60, 60, 59, 57, 55, 49, 44], [51, 53, 54, 56, 57, 58, 58, 58, 61, 61, 61, 61, 60, 59, 57, 55, 52, 48, 36, 44], [45, 46, 47, 47, 47, 47, 47, 47, 44, 39, 50, 51, 47, 44, 45, 45, 44, 43, 40, 38], [46, 48, 49, 50, 49, 48, 45, 41, 42, 43, 43, 37, 37, 34, 34, 29, 23, 33, 35, 34], [48, 49, 51, 52, 53, 54, 54, 55, 54, 54, 54, 55, 53, 53, 51, 49, 46, 40, 28, 38], [50, 51, 52, 53, 53, 53, 53, 53, 53, 52, 52, 52, 51, 51, 50, 49, 46, 43, 32, 25], [49, 51, 52, 53, 53, 53, 51, 49, 48, 49, 49, 48, 48, 48, 47, 46, 45, 44, 43, 42], [38, 36, 36, 36, 33, 30, 34, 44, 47, 42, 41, 35, 41, 39, 42, 37, 44, 42, 40, 38], [55, 59, 62, 64, 67, 66, 59, 57, 61, 59, 59, 59, 60, 58, 58, 57, 57, 56, 56, 53], [70, 73, 76, 79, 81, 82, 79, 79, 81, 80, 80, 79, 79, 79, 78, 77, 75, 74, 71, 68], [73, 76, 77, 78, 79, 79, 79, 76, 78, 77, 77, 77, 76, 76, 75, 75, 73, 71, 67, 61], [74, 77, 79, 81, 83, 84, 84, 82, 84, 83, 83, 83, 83, 82, 81, 80, 79, 77, 73, 69], [71, 73, 75, 76, 78, 79, 78, 79, 79, 79, 78, 78, 78, 78, 77, 76, 75, 74, 72, 69], [66, 68, 69, 69, 69, 68, 65, 64, 66, 69, 69, 69, 68, 68, 67, 66, 65, 63, 61, 58], [62, 62, 62, 62, 65, 68, 70, 71, 72, 71, 69, 68, 67, 65, 63, 61, 57, 51, 44, 43], [54, 58, 61, 64, 67, 66, 65, 67, 66, 66, 67, 66, 66, 65, 64, 63, 61, 59, 55, 51], [62, 63, 65, 66, 63, 50, 63, 61, 49, 44, 52, 50, 48, 50, 49, 48, 50, 51, 51, 51], [59, 62, 65, 67, 72, 75, 77, 77, 76, 74, 72, 70, 69, 68, 65, 63, 58, 52, 40, 47], [66, 68, 69, 70, 70, 70, 70, 72, 73, 74, 73, 72, 71, 70, 68, 66, 62, 60, 56, 52], [57, 60, 64, 67, 71, 72, 69, 67, 69, 71, 73, 72, 72, 71, 70, 69, 67, 64, 59, 54], [61, 64, 67, 69, 71, 73, 75, 74, 74, 75, 74, 74, 74, 73, 72, 71, 68, 66, 66, 64], [48, 48, 46, 44, 53, 59, 62, 64, 58, 56, 57, 52, 54, 53, 52, 53, 54, 54, 53, 49], [53, 55, 56, 58, 62, 65, 68, 67, 63, 42, 57, 46, 54, 57, 57, 50, 54, 51, 50, 48], [56, 59, 61, 62, 62, 58, 43, 50, 52, 51, 49, 47, 47, 47, 45, 45, 44, 44, 33, 34], [59, 60, 60, 60, 59, 55, 44, 48, 41, 44, 45, 46, 45, 43, 42, 44, 40, 39, 39, 32], [56, 59, 61, 63, 64, 65, 65, 64, 63, 63, 63, 62, 62, 62, 63, 62, 60, 57, 57, 51], [51, 55, 59, 61, 63, 64, 64, 62, 56, 50, 52, 54, 54, 52, 54, 52, 52, 51, 49, 45], [45, 45, 44, 49, 54, 58, 57, 42, 53, 50, 57, 43, 48, 54, 29, 47, 47, 48, 42, 42], [67, 70, 74, 76, 79, 80, 76, 69, 73, 71, 68, 69, 70, 69, 69, 69, 67, 66, 65, 63], [77, 81, 84, 86, 90, 92, 92, 91, 93, 92, 92, 91, 91, 91, 90, 89, 88, 86, 83, 80], [79, 84, 86, 88, 90, 90, 90, 88, 88, 87, 88, 87, 86, 86, 85, 84, 83, 81, 77, 72], [76, 82, 86, 89, 93, 95, 96, 95, 96, 96, 96, 95, 95, 94, 93, 92, 90, 88, 84, 80], [81, 84, 86, 88, 90, 91, 90, 89, 90, 89, 89, 88, 88, 88, 87, 87, 86, 85, 83, 81], [77, 79, 81, 82, 82, 81, 78, 76, 79, 80, 81, 80, 80, 79, 79, 78, 76, 74, 71, 68], [76, 77, 78, 78, 77, 79, 83, 85, 86, 85, 83, 83, 81, 79, 77, 75, 70, 62, 56, 52], [69, 69, 70, 73, 79, 81, 78, 76, 80, 78, 79, 78, 78, 78, 76, 75, 73, 70, 65, 61], [76, 78, 78, 79, 78, 69, 77, 76, 67, 67, 68, 70, 67, 67, 62, 58, 55, 57, 60, 62], [74, 76, 78, 80, 83, 85, 89, 89, 89, 88, 85, 83, 82, 81, 79, 78, 74, 70, 61, 54], [66, 72, 76, 79, 82, 84, 86, 87, 86, 86, 85, 85, 84, 83, 81, 80, 76, 74, 68, 64], [66, 67, 71, 76, 82, 85, 85, 82, 83, 84, 84, 83, 83, 83, 82, 80, 79, 76, 72, 67], [63, 68, 73, 76, 81, 84, 87, 87, 86, 86, 86, 87, 86, 85, 84, 83, 80, 76, 75, 75], [56, 56, 56, 55, 59, 67, 73, 77, 80, 79, 78, 70, 73, 73, 71, 66, 67, 67, 65, 61], [56, 53, 53, 61, 72, 78, 82, 80, 73, 77, 72, 74, 75, 76, 74, 56, 70, 64, 63, 61], [71, 74, 76, 78, 79, 77, 57, 70, 70, 70, 64, 63, 65, 66, 61, 63, 61, 59, 50, 50], [72, 74, 75, 76, 75, 73, 67, 72, 69, 68, 69, 70, 67, 66, 64, 64, 60, 58, 56, 51], [67, 71, 75, 77, 80, 81, 82, 82, 82, 81, 81, 80, 80, 80, 79, 78, 76, 73, 71, 66], [60, 65, 71, 74, 79, 81, 82, 81, 81, 79, 79, 77, 78, 76, 74, 71, 70, 68, 64, 61], [41, 41, 40, 38, 39, 38, 32, 40, 38, 46, 42, 32, 43, 38, 23, 41, 45, 37, 35, 45], [58, 63, 66, 69, 70, 70, 73, 73, 75, 76, 76, 76, 75, 74, 69, 63, 50, 43, 29, 34], [67, 70, 72, 73, 75, 76, 77, 77, 74, 74, 76, 75, 74, 73, 72, 70, 68, 65, 59, 52], [64, 68, 71, 72, 74, 74, 73, 72, 74, 74, 74, 74, 73, 73, 72, 72, 70, 69, 66, 64], [65, 67, 69, 70, 71, 71, 71, 71, 71, 71, 72, 71, 71, 70, 69, 68, 66, 64, 59, 51], [62, 64, 66, 67, 67, 66, 63, 65, 68, 68, 69, 70, 70, 69, 68, 66, 63, 60, 55, 50], [63, 65, 66, 67, 68, 67, 68, 67, 66, 67, 67, 67, 67, 66, 65, 64, 63, 61, 57, 53], [39, 39, 42, 45, 49, 50, 45, 44, 47, 48, 47, 48, 46, 46, 44, 45, 42, 39, 37, 33], [43, 44, 45, 47, 50, 51, 50, 52, 53, 50, 50, 50, 50, 47, 46, 46, 47, 43, 41, 40], [44, 43, 39, 24, 45, 50, 54, 54, 54, 55, 55, 56, 55, 54, 54, 53, 52, 51, 48, 45], [36, 46, 51, 55, 58, 60, 61, 63, 63, 63, 64, 63, 63, 63, 62, 61, 59, 57, 53, 50], [51, 54, 56, 57, 58, 59, 60, 60, 59, 60, 60, 59, 59, 58, 58, 56, 54, 53, 49, 46], [45, 48, 50, 52, 51, 53, 58, 58, 58, 59, 59, 59, 59, 59, 59, 58, 57, 54, 48, 40], [43, 46, 49, 51, 56, 60, 62, 61, 62, 62, 61, 60, 59, 58, 56, 55, 53, 49, 21, 35], [46, 47, 48, 49, 49, 50, 51, 52, 53, 53, 53, 53, 52, 51, 49, 47, 41, 35, 42, 42], [38, 40, 40, 41, 40, 40, 41, 38, 37, 39, 37, 35, 35, 33, 29, 19, 28, 32, 31, 14], [28, 28, 26, 23, 25, 28, 32, 30, 34, 31, 31, 29, 21, 31, 27, 18, 13, 19, 14, 10], [38, 40, 41, 41, 41, 42, 43, 43, 43, 43, 43, 43, 41, 38, 31, 18, 37, 38, 24, 30], [34, 37, 39, 40, 42, 41, 39, 41, 40, 40, 39, 38, 38, 36, 29, 26, 35, 33, 25, 22], [24, 27, 29, 30, 29, 29, 31, 28, 28, 30, 30, 32, 30, 32, 26, 20, 24, 24, 25, 21], [47, 48, 46, 41, 45, 42, 48, 47, 47, 48, 46, 51, 47, 43, 48, 38, 42, 27, 42, 34], [47, 60, 67, 71, 76, 77, 79, 80, 81, 82, 82, 81, 80, 78, 76, 73, 65, 51, 42, 38], [65, 71, 75, 77, 80, 82, 83, 83, 81, 81, 82, 81, 81, 79, 78, 76, 72, 70, 65, 60], [63, 69, 73, 76, 80, 81, 81, 79, 80, 81, 80, 80, 80, 79, 79, 78, 77, 75, 73, 71], [67, 71, 73, 75, 77, 78, 78, 78, 78, 78, 79, 78, 78, 77, 77, 76, 74, 72, 66, 59], [65, 69, 72, 74, 75, 75, 73, 72, 75, 77, 78, 78, 78, 78, 77, 75, 72, 69, 63, 57], [68, 71, 73, 75, 76, 76, 76, 76, 75, 76, 76, 76, 75, 75, 74, 73, 71, 69, 65, 62], [47, 45, 35, 42, 56, 59, 57, 53, 56, 55, 54, 55, 54, 55, 53, 52, 51, 50, 47, 44], [56, 56, 57, 57, 59, 60, 60, 62, 61, 61, 59, 60, 60, 59, 57, 58, 55, 54, 51, 48], [55, 57, 58, 56, 46, 57, 63, 65, 65, 66, 67, 66, 66, 66, 65, 64, 63, 62, 58, 55], [43, 51, 57, 62, 67, 70, 71, 73, 74, 74, 75, 74, 74, 74, 73, 72, 70, 69, 65, 61], [56, 61, 64, 67, 69, 70, 72, 72, 71, 71, 71, 71, 71, 70, 70, 69, 68, 66, 63, 60], [55, 58, 61, 63, 65, 63, 70, 71, 71, 72, 72, 72, 72, 72, 72, 71, 69, 67, 61, 56], [53, 56, 58, 61, 66, 71, 76, 76, 76, 76, 75, 75, 73, 72, 70, 69, 67, 62, 37, 51], [55, 59, 61, 63, 64, 64, 66, 66, 67, 67, 67, 67, 66, 65, 62, 60, 52, 50, 55, 56], [52, 54, 56, 57, 56, 55, 56, 55, 53, 54, 52, 52, 50, 49, 43, 31, 45, 48, 44, 28], [46, 47, 48, 47, 43, 44, 48, 49, 49, 48, 49, 47, 46, 45, 39, 28, 38, 42, 34, 34], [53, 57, 59, 61, 61, 61, 62, 62, 62, 61, 61, 60, 57, 55, 45, 45, 55, 54, 46, 46], [51, 54, 57, 59, 61, 62, 61, 61, 61, 60, 59, 59, 57, 55, 45, 46, 55, 52, 47, 42], [45, 48, 51, 52, 54, 55, 57, 56, 58, 59, 59, 59, 59, 57, 51, 47, 56, 48, 51, 47], [60, 59, 58, 56, 60, 63, 63, 44, 60, 60, 54, 53, 46, 40, 43, 44, 41, 40, 44, 47], [67, 73, 79, 82, 87, 88, 89, 92, 93, 93, 92, 91, 89, 87, 86, 85, 81, 76, 60, 44], [69, 77, 82, 86, 89, 92, 94, 94, 93, 93, 94, 93, 92, 92, 90, 88, 84, 80, 73, 66], [73, 78, 82, 86, 90, 92, 92, 90, 90, 92, 91, 91, 91, 90, 90, 88, 87, 86, 83, 80], [74, 78, 81, 83, 86, 88, 89, 89, 90, 89, 90, 89, 89, 88, 88, 87, 85, 84, 79, 72], [66, 74, 79, 82, 86, 88, 87, 84, 86, 87, 87, 88, 88, 87, 86, 84, 82, 80, 74, 68], [80, 83, 85, 87, 90, 90, 91, 90, 89, 90, 90, 90, 89, 89, 88, 87, 85, 83, 79, 76], [56, 56, 63, 68, 74, 77, 74, 67, 69, 69, 68, 68, 68, 68, 67, 65, 63, 62, 59, 55], [71, 73, 74, 75, 75, 75, 73, 74, 73, 75, 72, 72, 72, 71, 67, 71, 67, 65, 63, 60], [65, 68, 70, 70, 71, 76, 77, 79, 79, 80, 80, 80, 80, 80, 79, 78, 76, 75, 72, 68], [65, 70, 73, 76, 81, 83, 86, 87, 88, 89, 89, 88, 87, 87, 86, 85, 84, 83, 79, 76], [67, 73, 77, 80, 83, 83, 85, 86, 85, 84, 84, 84, 84, 83, 82, 81, 79, 78, 74, 72], [66, 70, 73, 77, 81, 80, 83, 86, 86, 84, 86, 85, 85, 84, 84, 83, 82, 80, 74, 68], [64, 69, 72, 76, 83, 88, 93, 93, 93, 93, 92, 92, 90, 88, 86, 85, 84, 80, 54, 66], [71, 76, 79, 81, 83, 83, 85, 85, 87, 87, 86, 85, 84, 82, 78, 74, 62, 70, 73, 71], [69, 72, 74, 75, 76, 76, 75, 73, 72, 69, 67, 64, 64, 61, 47, 51, 62, 64, 58, 50], [65, 67, 67, 66, 63, 64, 68, 69, 70, 71, 70, 69, 68, 67, 61, 44, 61, 64, 55, 55], [70, 74, 77, 79, 81, 81, 81, 80, 81, 81, 81, 81, 79, 77, 69, 61, 75, 75, 65, 67], [70, 73, 75, 77, 79, 80, 80, 79, 80, 78, 78, 76, 74, 72, 60, 64, 71, 69, 63, 58], [64, 68, 72, 74, 76, 77, 77, 74, 75, 75, 75, 75, 75, 75, 71, 67, 69, 66, 65, 59], [54, 54, 53, 50, 43, 45, 53, 42, 41, 37, 38, 44, 34, 43, 47, 41, 46, 45, 44, 45], [68, 72, 74, 75, 77, 77, 76, 75, 74, 75, 73, 72, 72, 71, 70, 68, 64, 61, 62, 63], [65, 67, 68, 67, 63, 60, 62, 61, 60, 56, 58, 56, 59, 58, 57, 56, 54, 55, 52, 50], [68, 70, 71, 72, 71, 70, 70, 70, 69, 68, 68, 68, 67, 66, 63, 60, 53, 52, 52, 47], [70, 72, 73, 73, 74, 75, 76, 76, 77, 77, 77, 77, 75, 74, 71, 68, 59, 55, 63, 63], [65, 66, 67, 67, 67, 67, 67, 69, 70, 70, 70, 70, 69, 68, 67, 66, 62, 54, 52, 57], [54, 56, 58, 59, 60, 61, 60, 58, 53, 53, 55, 55, 53, 53, 50, 48, 42, 32, 38, 41], [46, 48, 50, 49, 45, 44, 44, 36, 37, 38, 40, 39, 38, 37, 38, 32, 35, 32, 19, 24], [54, 54, 54, 55, 56, 57, 54, 50, 47, 48, 48, 48, 48, 45, 45, 42, 39, 34, 34, 40], [62, 64, 65, 65, 66, 67, 66, 67, 67, 67, 67, 66, 66, 65, 63, 62, 58, 55, 46, 38], [62, 63, 64, 64, 63, 62, 60, 60, 60, 60, 60, 59, 57, 55, 49, 31, 50, 52, 46, 43], [60, 61, 62, 63, 63, 63, 61, 61, 62, 61, 61, 60, 58, 56, 51, 44, 42, 47, 44, 36], [55, 56, 57, 58, 58, 58, 56, 56, 55, 55, 54, 52, 52, 50, 46, 42, 34, 38, 42, 40], [51, 52, 52, 52, 52, 51, 51, 51, 52, 53, 52, 52, 52, 52, 50, 49, 46, 46, 42, 10], [47, 49, 50, 51, 51, 50, 51, 51, 51, 50, 49, 48, 47, 45, 41, 38, 31, 36, 37, 34], [36, 37, 38, 38, 37, 37, 37, 36, 38, 37, 38, 38, 36, 33, 31, 30, 25, 22, 24, 23], [25, 26, 27, 27, 29, 28, 26, 29, 28, 26, 21, 23, 23, 20, 16, 16, 15, 21, 17, 18], [34, 35, 36, 37, 37, 36, 34, 35, 36, 36, 36, 35, 34, 34, 31, 28, 23, 20, 19, 20], [34, 35, 36, 36, 36, 37, 36, 35, 36, 34, 33, 32, 30, 24, 24, 27, 28, 27, 19, 18], [29, 31, 32, 32, 31, 31, 29, 33, 33, 30, 29, 31, 30, 30, 26, 27, 26, 16, 15, 19], [53, 60, 62, 64, 63, 58, 59, 56, 47, 56, 50, 56, 50, 53, 50, 48, 50, 41, 48, 44], [62, 69, 74, 78, 83, 85, 86, 84, 82, 83, 81, 81, 80, 79, 78, 76, 71, 68, 71, 70], [57, 62, 70, 74, 76, 72, 70, 69, 68, 64, 63, 64, 65, 65, 64, 63, 63, 62, 61, 59], [68, 74, 77, 79, 81, 81, 78, 78, 78, 76, 76, 75, 74, 73, 71, 68, 61, 58, 61, 58], [71, 76, 80, 82, 83, 84, 86, 86, 88, 87, 87, 86, 85, 84, 82, 79, 68, 66, 74, 74], [64, 70, 74, 77, 78, 78, 78, 79, 81, 81, 80, 80, 80, 79, 78, 76, 72, 66, 60, 67], [66, 68, 69, 70, 71, 72, 73, 72, 68, 65, 66, 66, 65, 65, 64, 62, 59, 54, 41, 50], [57, 59, 61, 61, 61, 57, 57, 53, 51, 53, 51, 53, 54, 50, 50, 49, 45, 40, 31, 29], [64, 67, 68, 68, 69, 70, 70, 67, 60, 61, 62, 62, 62, 59, 58, 57, 53, 50, 47, 52], [68, 73, 76, 78, 80, 81, 82, 82, 83, 83, 82, 82, 81, 80, 79, 77, 74, 70, 63, 57], [70, 75, 77, 78, 79, 79, 75, 75, 76, 75, 75, 74, 73, 71, 64, 53, 65, 66, 58, 57], [71, 75, 77, 78, 79, 80, 79, 78, 79, 79, 78, 78, 76, 74, 70, 64, 56, 63, 61, 55], [66, 71, 73, 75, 76, 77, 76, 72, 75, 73, 73, 73, 72, 71, 69, 65, 59, 42, 56, 56], [64, 68, 71, 72, 73, 73, 71, 71, 70, 71, 72, 72, 72, 72, 71, 70, 68, 67, 62, 49], [61, 65, 68, 70, 73, 73, 73, 74, 73, 73, 73, 72, 71, 69, 67, 63, 52, 51, 57, 54], [59, 61, 61, 61, 61, 62, 63, 63, 63, 63, 62, 62, 60, 59, 56, 53, 48, 29, 52, 49], [54, 56, 56, 56, 55, 53, 51, 54, 52, 52, 52, 51, 50, 49, 48, 45, 40, 38, 42, 39], [58, 61, 63, 63, 62, 61, 61, 62, 62, 62, 62, 61, 60, 58, 55, 52, 43, 44, 46, 45], [60, 64, 67, 68, 69, 69, 68, 67, 67, 66, 65, 64, 62, 60, 54, 48, 53, 55, 53, 43], [48, 55, 60, 62, 63, 63, 64, 64, 63, 62, 62, 62, 61, 60, 56, 56, 56, 46, 44, 35], [59, 67, 71, 73, 73, 68, 66, 67, 48, 65, 55, 66, 55, 63, 58, 53, 59, 47, 49, 54], [74, 80, 85, 88, 93, 95, 95, 93, 91, 92, 91, 91, 89, 89, 87, 85, 79, 77, 79, 77], [70, 73, 79, 84, 86, 83, 77, 80, 73, 65, 65, 65, 59, 64, 65, 68, 71, 72, 71, 69], [72, 80, 84, 87, 90, 91, 89, 90, 89, 87, 86, 85, 84, 82, 79, 74, 66, 63, 66, 64], [81, 86, 89, 91, 92, 93, 95, 96, 96, 96, 95, 94, 93, 92, 90, 87, 75, 75, 83, 83], [71, 78, 83, 86, 88, 88, 88, 88, 90, 90, 90, 89, 89, 88, 87, 86, 82, 77, 67, 75], [75, 78, 79, 81, 83, 84, 84, 83, 79, 79, 77, 78, 76, 74, 72, 69, 66, 61, 59, 62], [68, 70, 71, 70, 70, 69, 65, 67, 62, 65, 65, 66, 65, 64, 62, 60, 57, 53, 31, 47], [73, 77, 79, 80, 80, 81, 82, 78, 73, 75, 75, 74, 73, 72, 71, 68, 64, 60, 58, 61], [78, 83, 87, 89, 91, 92, 93, 93, 94, 94, 93, 93, 92, 91, 89, 87, 84, 80, 74, 69], [80, 85, 88, 89, 90, 90, 87, 87, 87, 87, 87, 85, 84, 82, 75, 67, 75, 77, 67, 66], [82, 86, 88, 89, 91, 91, 90, 89, 91, 91, 90, 89, 87, 86, 81, 74, 67, 74, 71, 65], [78, 82, 85, 87, 89, 90, 91, 86, 87, 83, 85, 84, 84, 82, 80, 76, 69, 55, 66, 67], [75, 81, 84, 85, 85, 85, 83, 82, 82, 84, 84, 85, 85, 85, 85, 84, 81, 79, 72, 59], [74, 79, 82, 85, 87, 87, 87, 87, 87, 86, 84, 84, 82, 81, 78, 75, 64, 60, 67, 64], [73, 75, 76, 76, 76, 78, 78, 77, 77, 76, 76, 75, 73, 71, 67, 65, 61, 53, 63, 61], [68, 70, 70, 70, 68, 66, 67, 69, 69, 68, 67, 68, 66, 65, 64, 60, 53, 53, 56, 51], [72, 76, 78, 78, 78, 77, 78, 79, 79, 79, 79, 77, 75, 74, 70, 67, 56, 58, 61, 62], [75, 79, 82, 83, 84, 84, 83, 83, 83, 83, 82, 81, 79, 77, 71, 55, 67, 69, 67, 55], [63, 71, 76, 79, 80, 80, 81, 81, 81, 81, 81, 81, 79, 78, 74, 73, 73, 65, 61, 52], [59, 63, 66, 67, 65, 61, 57, 44, 54, 53, 52, 53, 53, 51, 51, 48, 47, 50, 43, 39], [60, 62, 68, 70, 72, 74, 70, 70, 71, 69, 68, 68, 67, 65, 62, 58, 58, 50, 44, 42], [69, 73, 75, 76, 78, 79, 79, 78, 75, 73, 68, 67, 63, 58, 48, 43, 21, 36, 40, 43], [65, 69, 71, 71, 71, 72, 73, 73, 74, 74, 74, 73, 71, 69, 67, 65, 65, 62, 58, 56], [57, 59, 62, 64, 65, 64, 68, 71, 70, 71, 72, 71, 70, 68, 65, 62, 51, 53, 57, 55], [60, 62, 61, 57, 55, 60, 64, 65, 61, 62, 62, 61, 60, 59, 57, 55, 49, 45, 51, 52], [58, 61, 63, 66, 68, 69, 71, 71, 71, 71, 70, 69, 67, 64, 51, 60, 68, 66, 58, 59], [48, 52, 56, 60, 64, 63, 61, 60, 59, 59, 57, 55, 53, 53, 48, 41, 38, 27, 35, 37], [54, 56, 58, 57, 54, 53, 56, 54, 52, 48, 51, 51, 50, 47, 41, 41, 47, 48, 40, 42], [52, 53, 50, 42, 48, 52, 51, 51, 52, 54, 54, 53, 52, 51, 48, 46, 45, 45, 33, 34], [51, 53, 53, 55, 56, 57, 56, 55, 50, 46, 47, 49, 47, 47, 45, 44, 41, 38, 31, 21], [53, 56, 57, 57, 56, 52, 46, 33, 43, 41, 44, 47, 46, 45, 43, 41, 29, 20, 26, 26], [51, 52, 54, 56, 59, 59, 60, 60, 60, 61, 58, 60, 59, 58, 54, 51, 34, 32, 36, 41], [50, 54, 56, 57, 58, 58, 58, 58, 58, 59, 58, 57, 54, 50, 47, 49, 50, 48, 42, 39], [37, 42, 45, 46, 46, 45, 44, 44, 46, 46, 45, 44, 45, 44, 39, 36, 38, 28, 37, 36], [39, 42, 43, 44, 44, 43, 44, 45, 45, 45, 44, 44, 41, 37, 36, 39, 35, 39, 34, 29], [32, 33, 33, 30, 11, 20, 22, 21, 20, 25, 23, 20, 23, 10, 20, 11, 13, 18, 12, 9], [24, 23, 22, 22, 26, 28, 26, 25, 20, 23, 24, 22, 19, 17, 10, 18, 13, 20, 17, 7], [26, 30, 32, 34, 31, 27, 29, 32, 28, 27, 27, 13, 31, 30, 28, 21, 19, 26, 8, 12], [31, 33, 30, 19, 30, 13, 30, 29, 31, 26, 24, 25, 26, 23, 24, 23, 11, 22, 13, 0], [55, 63, 71, 75, 77, 73, 73, 45, 68, 65, 60, 60, 63, 64, 62, 62, 61, 58, 54, 54], [69, 71, 70, 77, 84, 85, 84, 82, 84, 82, 81, 80, 80, 78, 76, 73, 67, 59, 44, 50], [74, 81, 85, 87, 89, 90, 90, 90, 88, 84, 80, 77, 72, 66, 62, 54, 46, 33, 54, 59], [72, 79, 82, 84, 83, 83, 85, 86, 86, 86, 86, 86, 85, 84, 82, 80, 78, 74, 69, 63], [70, 71, 73, 76, 80, 79, 82, 84, 85, 85, 86, 86, 85, 84, 82, 79, 69, 64, 72, 68], [69, 75, 78, 77, 71, 73, 80, 81, 78, 78, 78, 77, 76, 76, 74, 73, 68, 63, 66, 67], [68, 74, 77, 79, 84, 86, 87, 87, 87, 86, 85, 85, 83, 80, 68, 72, 82, 80, 70, 71], [63, 67, 70, 73, 79, 81, 78, 78, 76, 76, 74, 70, 71, 70, 66, 59, 43, 49, 53, 54], [67, 72, 76, 77, 76, 75, 76, 75, 71, 69, 70, 69, 67, 64, 56, 56, 62, 64, 57, 61], [68, 73, 75, 73, 48, 70, 72, 72, 72, 73, 74, 74, 73, 72, 69, 66, 64, 65, 57, 52], [67, 72, 74, 74, 75, 77, 77, 75, 71, 66, 65, 68, 65, 67, 64, 62, 59, 57, 49, 40], [67, 73, 76, 77, 76, 73, 68, 62, 65, 59, 51, 62, 55, 52, 55, 50, 44, 43, 50, 53], [68, 72, 73, 75, 81, 83, 82, 82, 84, 85, 79, 85, 84, 82, 78, 77, 68, 60, 63, 58], [69, 74, 78, 81, 83, 83, 83, 83, 82, 83, 82, 80, 76, 67, 71, 69, 76, 70, 65, 62], [60, 62, 68, 72, 73, 73, 72, 71, 71, 70, 69, 68, 67, 64, 57, 59, 62, 61, 58, 60], [63, 68, 70, 71, 73, 73, 73, 73, 73, 73, 72, 70, 66, 57, 67, 69, 63, 66, 60, 52], [64, 67, 68, 68, 63, 56, 56, 57, 56, 58, 56, 54, 49, 40, 53, 52, 50, 42, 36, 40], [46, 50, 51, 43, 54, 56, 55, 55, 53, 51, 35, 38, 46, 50, 51, 37, 56, 49, 45, 44], [41, 52, 58, 58, 54, 55, 56, 58, 52, 51, 57, 59, 58, 54, 50, 50, 54, 50, 19, 44], [65, 70, 72, 73, 74, 74, 73, 72, 71, 70, 61, 66, 70, 63, 70, 68, 61, 66, 62, 55], [69, 73, 78, 82, 86, 84, 79, 61, 73, 61, 64, 53, 67, 67, 66, 67, 65, 64, 61, 57], [78, 82, 82, 84, 90, 92, 89, 86, 89, 88, 86, 86, 85, 84, 81, 79, 73, 66, 35, 56], [79, 85, 89, 91, 94, 95, 95, 93, 92, 87, 83, 81, 76, 70, 67, 61, 52, 29, 58, 63], [75, 82, 86, 87, 88, 89, 90, 91, 91, 91, 92, 92, 91, 90, 89, 88, 84, 81, 73, 67], [76, 78, 77, 77, 83, 85, 87, 89, 89, 89, 91, 90, 89, 88, 86, 83, 74, 71, 76, 73], [75, 80, 83, 84, 76, 78, 84, 86, 82, 80, 80, 80, 80, 79, 78, 76, 73, 68, 70, 72], [72, 78, 82, 84, 89, 92, 93, 93, 93, 92, 91, 91, 89, 86, 74, 78, 87, 86, 76, 76], [66, 70, 74, 78, 85, 87, 85, 85, 83, 84, 82, 80, 80, 76, 71, 66, 55, 53, 60, 62], [71, 78, 81, 83, 83, 82, 82, 81, 77, 78, 76, 76, 74, 70, 62, 63, 69, 70, 63, 66], [74, 79, 82, 81, 71, 75, 79, 78, 80, 81, 83, 83, 82, 81, 79, 75, 71, 70, 61, 58], [73, 78, 80, 81, 82, 84, 84, 83, 80, 78, 77, 80, 77, 78, 75, 75, 69, 67, 57, 53], [71, 78, 82, 83, 81, 79, 72, 58, 59, 66, 66, 68, 58, 61, 57, 47, 50, 51, 58, 59], [73, 77, 77, 78, 87, 90, 85, 86, 91, 92, 84, 90, 89, 87, 82, 82, 74, 63, 67, 65], [73, 79, 84, 87, 90, 90, 90, 89, 90, 89, 88, 87, 82, 72, 77, 75, 83, 77, 69, 66], [65, 68, 74, 78, 81, 81, 80, 80, 80, 79, 80, 79, 77, 74, 68, 69, 70, 70, 66, 68], [71, 76, 79, 80, 81, 81, 81, 82, 82, 82, 81, 80, 75, 65, 75, 77, 70, 75, 69, 63], [73, 76, 77, 77, 71, 65, 65, 64, 65, 65, 63, 61, 54, 51, 58, 56, 57, 51, 41, 46], [60, 60, 58, 52, 53, 61, 58, 61, 57, 48, 56, 56, 61, 59, 58, 37, 64, 53, 51, 51], [60, 57, 62, 64, 64, 67, 67, 68, 63, 68, 69, 68, 71, 67, 42, 53, 64, 62, 46, 56], [73, 78, 80, 81, 81, 82, 80, 80, 78, 77, 68, 72, 76, 71, 77, 74, 68, 72, 68, 61], [62, 67, 71, 73, 73, 73, 76, 76, 77, 78, 78, 77, 72, 62, 56, 48, 40, 43, 46, 45], [69, 70, 71, 71, 71, 70, 71, 68, 69, 70, 69, 67, 64, 60, 48, 50, 57, 56, 42, 37], [66, 70, 72, 73, 73, 72, 74, 74, 73, 72, 70, 69, 67, 66, 61, 56, 58, 61, 60, 50], [66, 70, 71, 71, 67, 56, 63, 67, 58, 54, 61, 58, 58, 58, 58, 57, 53, 50, 50, 46], [68, 71, 71, 68, 68, 66, 66, 65, 68, 68, 68, 67, 66, 65, 62, 59, 55, 48, 46, 48], [56, 53, 55, 65, 71, 73, 73, 70, 71, 69, 68, 66, 63, 60, 48, 52, 59, 59, 50, 43], [53, 56, 59, 62, 63, 64, 64, 64, 63, 63, 62, 62, 61, 60, 58, 56, 51, 43, 36, 33], [38, 37, 38, 41, 45, 42, 42, 43, 44, 44, 43, 38, 27, 26, 38, 39, 35, 30, 26, 23], [50, 53, 53, 53, 53, 52, 53, 51, 49, 49, 48, 45, 41, 34, 23, 36, 40, 38, 31, 25], [55, 56, 57, 57, 56, 55, 54, 54, 53, 52, 51, 51, 49, 47, 42, 33, 34, 29, 34, 33], [48, 50, 53, 55, 56, 52, 54, 53, 51, 50, 47, 41, 40, 47, 49, 45, 42, 45, 37, 37], [44, 46, 44, 39, 34, 42, 33, 40, 34, 31, 20, 25, 30, 33, 35, 33, 30, 30, 17, 18], [36, 38, 37, 36, 34, 32, 31, 33, 29, 27, 26, 31, 38, 41, 40, 37, 35, 31, 13, 31], [33, 37, 38, 39, 41, 40, 40, 40, 40, 38, 35, 30, 20, 33, 33, 21, 28, 15, 3, 21], [26, 30, 32, 33, 32, 33, 30, 31, 30, 31, 29, 24, 22, 25, 24, 19, 12, 21, 19, 17], [21, 24, 23, 16, 26, 32, 29, 26, 27, 25, 22, 19, 20, 16, 23, 25, 8, 24, 9, 9], [18, 14, 20, 21, 20, 21, 20, 18, 18, 21, 19, 21, 17, 10, 19, 17, 17, 19, 16, 0], [26, 27, 26, 28, 27, 28, 15, 26, 21, 19, 18, 14, 22, 23, 22, 22, 0, 13, 17, 12], [27, 24, 24, 24, 27, 18, 18, 21, 18, 26, 27, 29, 23, 16, 18, 15, 24, 19, 17, 5], [33, 32, 33, 34, 31, 26, 30, 28, 26, 23, 25, 26, 27, 28, 25, 22, 17, 17, 9, 11], [66, 72, 76, 79, 84, 84, 85, 86, 88, 89, 88, 87, 81, 76, 69, 59, 48, 45, 43, 46], [69, 78, 81, 83, 83, 82, 84, 83, 83, 85, 83, 82, 80, 77, 66, 65, 74, 73, 54, 55], [73, 76, 80, 83, 85, 85, 85, 86, 84, 83, 81, 79, 78, 77, 73, 67, 66, 71, 72, 66], [65, 75, 80, 82, 82, 77, 71, 78, 74, 73, 77, 76, 74, 73, 71, 68, 63, 60, 60, 59], [70, 78, 83, 84, 81, 80, 77, 78, 80, 81, 81, 80, 79, 77, 75, 72, 68, 64, 59, 58], [68, 73, 72, 60, 83, 87, 88, 86, 86, 84, 82, 81, 79, 76, 68, 55, 71, 73, 66, 60], [61, 69, 73, 76, 81, 82, 82, 82, 82, 80, 80, 80, 79, 77, 75, 74, 69, 63, 49, 53], [61, 62, 59, 59, 63, 64, 63, 66, 63, 62, 59, 57, 52, 42, 56, 57, 52, 47, 43, 45], [62, 71, 75, 77, 76, 76, 75, 73, 70, 71, 70, 68, 65, 60, 41, 51, 58, 58, 49, 45], [69, 77, 80, 81, 82, 80, 79, 79, 77, 76, 75, 74, 71, 69, 64, 61, 54, 44, 48, 50], [68, 73, 75, 78, 82, 81, 80, 79, 78, 78, 77, 73, 64, 61, 70, 68, 53, 67, 55, 52], [66, 72, 73, 71, 65, 66, 68, 70, 66, 61, 58, 50, 38, 53, 56, 54, 44, 48, 28, 33], [61, 68, 74, 77, 78, 77, 77, 78, 76, 76, 74, 72, 65, 58, 50, 66, 69, 65, 62, 45], [60, 68, 74, 76, 78, 79, 80, 79, 79, 79, 77, 76, 72, 69, 68, 67, 62, 64, 59, 48], [52, 49, 62, 67, 69, 70, 69, 70, 71, 70, 69, 68, 64, 60, 53, 47, 59, 60, 52, 44], [55, 60, 63, 65, 65, 64, 63, 64, 64, 63, 61, 58, 38, 53, 56, 58, 46, 54, 47, 36], [42, 44, 48, 52, 54, 57, 59, 58, 57, 56, 54, 52, 43, 39, 45, 49, 47, 38, 37, 26], [47, 49, 49, 48, 48, 46, 22, 48, 41, 49, 48, 49, 43, 36, 43, 48, 29, 27, 27, 0], [53, 55, 53, 49, 47, 52, 50, 52, 54, 53, 52, 53, 47, 30, 39, 36, 36, 38, 34, 24], [48, 56, 59, 61, 60, 58, 57, 57, 56, 54, 49, 43, 47, 53, 49, 49, 46, 37, 33, 30], [68, 74, 80, 85, 90, 91, 92, 94, 96, 95, 95, 94, 87, 82, 76, 68, 57, 40, 48, 41], [80, 87, 89, 90, 90, 91, 94, 92, 92, 93, 91, 90, 88, 85, 74, 71, 82, 81, 62, 63], [82, 85, 88, 91, 93, 93, 93, 94, 92, 90, 88, 87, 86, 85, 80, 73, 75, 80, 79, 70], [75, 84, 89, 91, 89, 85, 80, 85, 77, 78, 79, 76, 75, 75, 74, 72, 70, 68, 67, 66], [78, 86, 90, 92, 88, 87, 84, 85, 89, 88, 88, 88, 86, 85, 82, 79, 73, 69, 66, 66], [77, 81, 80, 65, 91, 96, 97, 95, 95, 94, 92, 90, 88, 85, 75, 68, 81, 81, 71, 67], [70, 78, 82, 85, 90, 91, 91, 90, 89, 89, 88, 88, 86, 84, 82, 81, 77, 69, 59, 56], [70, 72, 69, 70, 72, 75, 75, 78, 75, 75, 72, 69, 61, 49, 67, 68, 62, 57, 47, 51], [75, 83, 87, 87, 87, 87, 86, 85, 83, 82, 80, 78, 74, 69, 46, 62, 68, 67, 57, 51], [80, 88, 92, 93, 94, 92, 91, 91, 90, 89, 88, 87, 84, 81, 77, 73, 57, 64, 64, 63], [79, 84, 87, 91, 95, 93, 92, 90, 90, 90, 89, 86, 77, 70, 81, 80, 71, 79, 68, 66], [77, 82, 83, 81, 77, 77, 78, 78, 76, 74, 72, 69, 58, 58, 65, 68, 60, 61, 53, 36], [74, 79, 85, 88, 89, 88, 88, 89, 89, 89, 86, 85, 79, 72, 64, 79, 81, 72, 73, 64], [74, 82, 87, 90, 92, 93, 93, 92, 92, 92, 90, 89, 85, 82, 81, 80, 77, 77, 70, 61], [71, 70, 77, 81, 82, 83, 83, 84, 84, 82, 81, 79, 76, 73, 67, 67, 74, 73, 52, 63], [72, 77, 80, 81, 81, 80, 78, 80, 79, 78, 76, 74, 57, 67, 71, 71, 47, 67, 61, 53], [58, 60, 64, 65, 65, 70, 72, 72, 71, 70, 67, 66, 58, 54, 60, 63, 57, 47, 45, 42], [66, 66, 64, 60, 59, 63, 56, 63, 57, 66, 66, 69, 65, 53, 64, 68, 50, 50, 48, 33], [69, 73, 72, 70, 72, 73, 70, 73, 74, 74, 76, 75, 69, 60, 61, 58, 60, 61, 50, 48], [71, 75, 76, 77, 75, 72, 70, 70, 70, 70, 66, 62, 62, 67, 61, 61, 55, 53, 50, 43], [63, 70, 73, 74, 78, 80, 78, 76, 75, 78, 75, 73, 73, 73, 71, 70, 67, 65, 63, 57], [72, 74, 71, 60, 45, 51, 66, 64, 69, 66, 65, 65, 66, 65, 64, 62, 56, 52, 50, 47], [66, 68, 66, 61, 59, 64, 70, 66, 71, 70, 70, 70, 69, 68, 65, 63, 60, 53, 42, 53], [62, 66, 67, 66, 68, 68, 68, 69, 69, 69, 69, 68, 67, 66, 63, 59, 38, 55, 56, 51], [51, 51, 53, 60, 65, 66, 64, 64, 64, 63, 63, 62, 60, 59, 53, 44, 45, 47, 42, 50], [51, 49, 44, 39, 51, 56, 56, 53, 49, 46, 45, 47, 40, 30, 33, 37, 42, 39, 44, 43], [50, 50, 53, 56, 59, 57, 60, 58, 56, 56, 56, 54, 50, 44, 36, 46, 46, 38, 50, 43], [49, 51, 48, 45, 48, 45, 46, 48, 47, 46, 46, 44, 41, 39, 32, 33, 28, 30, 32, 33], [40, 42, 42, 44, 45, 46, 45, 45, 43, 42, 42, 39, 36, 31, 30, 34, 26, 31, 34, 28], [31, 37, 41, 43, 46, 46, 47, 46, 44, 43, 40, 33, 27, 36, 40, 38, 18, 38, 32, 19], [31, 31, 32, 32, 33, 33, 28, 30, 30, 30, 31, 27, 27, 31, 33, 21, 23, 24, 9, 18], [30, 24, 18, 15, 10, 25, 28, 30, 26, 20, 26, 26, 17, 13, 16, 13, 16, 21, 21, 8], [32, 35, 35, 35, 35, 34, 34, 32, 33, 29, 27, 18, 19, 12, 7, 27, 23, 23, 23, 20], [25, 21, 20, 22, 21, 17, 24, 24, 23, 23, 23, 14, 22, 24, 15, 14, 15, 19, 0, 5], [25, 21, 14, 5, 19, 20, 15, 22, 14, 20, 12, 23, 25, 24, 22, 9, 17, 12, 14, 14], [10, 15, 15, 20, 21, 19, 20, 13, 19, 19, 10, 21, 16, 3, 17, 13, 10, 0, 16, 17], [20, 17, 16, 10, 12, 24, 16, 15, 9, 9, 8, 10, 3, 13, 3, 4, 5, 5, 12, 7], [21, 16, 12, 21, 19, 17, 20, 16, 18, 20, 14, 9, 13, 4, 13, 0, 16, 0, 9, 9], [16, 22, 26, 26, 21, 23, 25, 24, 24, 25, 22, 23, 15, 14, 15, 14, 18, 13, 8, 7], [8, 14, 13, 13, 10, 16, 15, 13, 16, 13, 8, 6, 11, 16, 7, 5, 9, 7, 6, 8], [55, 68, 77, 82, 84, 89, 88, 87, 84, 87, 84, 84, 83, 82, 81, 79, 76, 74, 69, 63], [68, 79, 85, 85, 72, 65, 75, 79, 79, 78, 76, 77, 77, 76, 75, 72, 67, 62, 59, 59], [64, 75, 80, 80, 66, 71, 81, 76, 82, 80, 80, 80, 79, 78, 76, 74, 71, 66, 54, 64], [64, 72, 77, 78, 79, 79, 81, 81, 81, 81, 81, 80, 79, 77, 75, 71, 50, 65, 67, 60], [54, 61, 63, 65, 75, 78, 77, 77, 77, 77, 77, 76, 75, 74, 70, 64, 50, 61, 55, 62], [61, 66, 66, 64, 60, 69, 72, 68, 67, 69, 70, 68, 65, 62, 53, 33, 53, 52, 55, 56], [58, 67, 68, 70, 77, 78, 79, 79, 76, 76, 76, 75, 73, 69, 58, 61, 64, 58, 65, 59], [63, 68, 70, 70, 66, 69, 66, 68, 68, 67, 66, 64, 61, 58, 50, 49, 42, 46, 50, 52], [48, 60, 65, 67, 69, 68, 69, 69, 67, 65, 65, 64, 61, 57, 49, 55, 52, 52, 57, 49], [51, 44, 60, 66, 71, 74, 74, 76, 74, 73, 70, 67, 60, 52, 61, 63, 55, 60, 58, 46], [44, 51, 58, 61, 62, 64, 62, 62, 61, 62, 63, 62, 56, 47, 59, 56, 56, 50, 41, 37], [51, 52, 41, 52, 57, 57, 59, 60, 55, 56, 53, 53, 48, 43, 38, 31, 39, 45, 41, 24], [54, 62, 64, 65, 64, 64, 64, 64, 64, 62, 60, 57, 48, 39, 49, 47, 52, 47, 42, 40], [54, 59, 62, 62, 63, 61, 60, 57, 55, 53, 50, 48, 40, 45, 48, 40, 52, 41, 42, 20], [50, 56, 63, 64, 64, 63, 59, 60, 63, 63, 58, 56, 48, 47, 51, 49, 49, 41, 39, 34], [53, 58, 62, 62, 61, 60, 60, 61, 59, 59, 58, 55, 46, 36, 42, 50, 51, 37, 39, 26], [40, 50, 55, 55, 49, 58, 60, 54, 50, 43, 38, 45, 34, 37, 38, 36, 37, 20, 26, 9], [42, 47, 38, 47, 49, 46, 51, 49, 48, 42, 41, 42, 39, 33, 42, 35, 39, 30, 25, 23], [41, 49, 51, 51, 53, 53, 51, 52, 50, 47, 44, 45, 49, 50, 41, 37, 45, 39, 37, 27], [41, 47, 46, 42, 44, 41, 36, 32, 26, 27, 29, 30, 26, 29, 16, 36, 25, 17, 23, 19], [69, 87, 93, 96, 97, 102, 101, 99, 97, 97, 96, 96, 95, 94, 92, 90, 86, 83, 78, 70], [83, 93, 98, 96, 84, 81, 83, 88, 85, 86, 82, 83, 84, 83, 82, 80, 75, 67, 69, 69], [78, 89, 92, 91, 68, 85, 91, 84, 93, 94, 94, 94, 92, 91, 88, 86, 82, 76, 66, 75], [78, 86, 91, 92, 92, 92, 94, 95, 94, 94, 94, 94, 92, 91, 88, 84, 63, 77, 75, 72], [73, 78, 76, 76, 87, 89, 87, 86, 85, 84, 83, 83, 82, 80, 76, 70, 61, 68, 53, 70], [74, 79, 78, 74, 74, 81, 85, 82, 67, 71, 78, 75, 72, 68, 59, 53, 64, 60, 65, 65], [66, 75, 77, 83, 91, 92, 94, 93, 90, 88, 86, 84, 82, 78, 69, 71, 74, 68, 77, 66], [77, 82, 85, 86, 78, 83, 83, 83, 82, 83, 82, 81, 78, 74, 65, 63, 60, 63, 68, 65], [70, 73, 82, 85, 84, 83, 85, 86, 81, 80, 81, 79, 74, 71, 62, 65, 57, 67, 68, 58], [76, 73, 77, 82, 86, 89, 88, 90, 89, 88, 86, 84, 77, 63, 76, 78, 63, 78, 71, 54], [67, 71, 76, 77, 79, 81, 74, 73, 75, 75, 75, 73, 71, 71, 76, 76, 63, 55, 59, 54], [72, 74, 69, 57, 68, 70, 78, 79, 75, 77, 74, 72, 67, 65, 58, 53, 59, 70, 54, 52], [75, 80, 81, 80, 79, 79, 80, 81, 80, 79, 77, 76, 69, 60, 64, 63, 65, 64, 57, 57], [70, 75, 78, 80, 80, 77, 79, 81, 79, 81, 78, 76, 68, 61, 62, 64, 57, 68, 41, 53], [68, 78, 84, 86, 86, 85, 83, 81, 84, 81, 78, 77, 71, 47, 71, 70, 75, 67, 61, 52], [78, 82, 85, 85, 84, 83, 83, 85, 82, 81, 79, 75, 64, 54, 64, 68, 72, 64, 60, 49], [63, 75, 81, 80, 76, 83, 85, 78, 72, 76, 56, 66, 61, 43, 58, 55, 59, 50, 50, 44], [73, 76, 69, 76, 73, 73, 77, 74, 75, 71, 68, 66, 68, 68, 69, 64, 61, 48, 42, 45], [71, 77, 78, 77, 80, 81, 76, 81, 80, 79, 75, 69, 65, 73, 56, 68, 68, 58, 43, 52], [69, 73, 73, 72, 72, 66, 68, 71, 71, 69, 62, 57, 56, 54, 56, 62, 47, 52, 34, 20], [67, 71, 75, 76, 75, 73, 69, 67, 71, 67, 67, 66, 66, 64, 60, 58, 47, 28, 35, 25], [73, 75, 76, 78, 79, 79, 80, 81, 81, 81, 80, 80, 78, 77, 75, 72, 68, 61, 54, 59], [71, 74, 74, 74, 70, 68, 71, 69, 70, 70, 69, 68, 67, 65, 60, 55, 29, 46, 52, 50], [66, 66, 65, 68, 72, 72, 70, 68, 65, 64, 63, 61, 59, 56, 53, 52, 40, 47, 49, 24], [50, 52, 49, 47, 49, 44, 47, 36, 32, 49, 50, 49, 47, 46, 43, 35, 38, 41, 31, 35], [55, 56, 55, 54, 55, 56, 56, 53, 53, 50, 49, 48, 45, 43, 37, 28, 37, 38, 18, 32], [56, 58, 59, 59, 59, 59, 59, 59, 58, 58, 57, 56, 54, 52, 45, 34, 41, 36, 38, 34], [37, 38, 38, 40, 40, 42, 39, 40, 39, 41, 40, 38, 34, 34, 29, 26, 21, 25, 22, 21], [20, 29, 33, 34, 35, 31, 28, 19, 16, 27, 16, 8, 22, 21, 23, 20, 23, 25, 14, 20], [32, 36, 37, 34, 29, 33, 30, 29, 31, 33, 30, 27, 21, 16, 12, 27, 25, 18, 16, 7], [33, 37, 39, 38, 37, 38, 38, 38, 36, 35, 34, 31, 26, 12, 27, 31, 22, 16, 13, 0], [33, 38, 39, 38, 38, 36, 36, 36, 35, 35, 35, 33, 27, 10, 20, 17, 24, 15, 17, 18], [26, 28, 27, 25, 28, 27, 26, 27, 23, 27, 19, 23, 23, 11, 19, 20, 19, 17, 6, 13], [25, 21, 25, 18, 19, 22, 18, 21, 16, 18, 19, 20, 2, 14, 12, 11, 7, 15, 2, 0], [31, 30, 24, 26, 24, 26, 21, 25, 21, 20, 17, 18, 12, 12, 14, 10, 7, 11, 4, 17], [15, 11, 19, 13, 0, 0, 13, 11, 10, 12, 11, 4, 11, 12, 13, 11, 0, 10, 14, 11], [12, 11, 5, 10, 1, 9, 0, 18, 5, 14, 16, 13, 12, 0, 10, 11, 4, 7, 0, 12], [16, 13, 4, 0, 15, 7, 15, 0, 13, 18, 9, 9, 11, 9, 0, 0, 9, 13, 4, 10], [11, 13, 15, 12, 9, 8, 6, 16, 16, 7, 8, 8, 6, 1, 0, 7, 14, 15, 11, 1], [13, 19, 11, 10, 2, 3, 0, 11, 9, 0, 14, 1, 6, 7, 14, 1, 10, 0, 11, 16], [62, 78, 82, 86, 88, 85, 82, 82, 83, 80, 80, 78, 77, 76, 73, 70, 65, 60, 48, 43], [72, 83, 89, 89, 92, 92, 93, 93, 95, 94, 93, 93, 92, 91, 89, 86, 80, 72, 68, 73], [53, 81, 88, 89, 88, 84, 86, 85, 85, 86, 86, 84, 82, 80, 76, 70, 57, 63, 65, 63], [69, 80, 83, 82, 87, 88, 86, 86, 82, 81, 79, 77, 74, 72, 66, 65, 61, 53, 63, 53], [52, 66, 69, 67, 62, 62, 57, 56, 60, 67, 67, 67, 65, 64, 59, 53, 49, 55, 50, 41], [66, 74, 75, 76, 73, 75, 76, 73, 73, 69, 68, 67, 65, 63, 57, 41, 56, 57, 46, 52], [66, 78, 82, 83, 84, 83, 84, 84, 83, 83, 82, 81, 79, 76, 67, 62, 68, 64, 61, 58], [57, 61, 69, 65, 65, 66, 67, 68, 69, 69, 68, 68, 66, 62, 51, 52, 53, 34, 49, 43], [58, 60, 63, 67, 61, 64, 57, 53, 53, 54, 54, 52, 51, 47, 37, 42, 49, 43, 41, 32], [59, 68, 74, 76, 75, 74, 75, 74, 73, 72, 72, 70, 67, 63, 60, 63, 62, 53, 50, 41], [55, 65, 68, 70, 70, 70, 71, 70, 69, 68, 66, 64, 58, 45, 61, 63, 56, 45, 42, 42], [53, 61, 67, 68, 69, 68, 66, 67, 67, 67, 66, 66, 63, 59, 56, 54, 51, 45, 44, 29], [42, 59, 62, 60, 60, 59, 61, 64, 63, 60, 57, 57, 53, 40, 42, 41, 48, 42, 20, 25], [54, 68, 72, 72, 72, 71, 71, 71, 71, 71, 69, 67, 62, 52, 41, 54, 54, 46, 45, 38], [57, 68, 69, 63, 65, 64, 66, 67, 67, 63, 60, 56, 49, 47, 52, 54, 47, 41, 37, 29], [52, 52, 54, 56, 45, 49, 47, 49, 46, 33, 29, 33, 40, 44, 42, 40, 33, 29, 24, 19], [42, 47, 45, 46, 43, 43, 49, 46, 48, 47, 47, 45, 38, 40, 37, 35, 36, 28, 19, 9], [40, 48, 49, 49, 48, 48, 47, 44, 41, 42, 41, 35, 35, 36, 36, 33, 30, 24, 19, 11], [43, 49, 52, 51, 52, 54, 51, 52, 48, 50, 46, 40, 41, 47, 50, 47, 37, 35, 19, 20], [35, 30, 32, 35, 43, 45, 46, 47, 47, 46, 45, 43, 37, 34, 36, 35, 33, 18, 13, 13], [72, 86, 89, 94, 96, 93, 94, 89, 89, 89, 87, 87, 86, 85, 83, 80, 74, 68, 64, 55], [81, 91, 97, 97, 100, 101, 102, 102, 103, 103, 102, 102, 101, 99, 97, 95, 89, 80, 76, 80], [65, 91, 97, 98, 97, 94, 95, 94, 93, 93, 92, 91, 89, 87, 81, 75, 60, 69, 71, 72], [78, 89, 92, 91, 96, 97, 95, 95, 92, 93, 92, 91, 88, 86, 81, 77, 74, 68, 73, 62], [54, 75, 78, 78, 75, 73, 62, 68, 62, 72, 75, 72, 70, 68, 63, 55, 56, 61, 58, 50], [77, 82, 82, 83, 81, 83, 84, 80, 82, 80, 79, 79, 77, 75, 70, 62, 66, 68, 52, 60], [76, 88, 93, 94, 95, 94, 94, 94, 94, 94, 93, 92, 90, 87, 77, 73, 77, 73, 71, 68], [67, 74, 80, 74, 75, 79, 80, 80, 80, 79, 79, 79, 76, 72, 61, 63, 64, 45, 59, 51], [73, 76, 74, 80, 73, 78, 75, 72, 69, 66, 59, 49, 55, 51, 42, 60, 65, 61, 54, 39], [72, 81, 87, 89, 88, 87, 88, 87, 87, 87, 86, 85, 81, 76, 71, 76, 75, 66, 57, 59], [67, 78, 80, 82, 81, 81, 81, 81, 80, 79, 77, 76, 70, 63, 71, 73, 65, 55, 48, 48], [67, 76, 82, 84, 86, 85, 84, 84, 83, 82, 81, 80, 77, 71, 69, 68, 67, 62, 57, 34], [53, 72, 75, 76, 75, 75, 71, 74, 80, 74, 74, 74, 66, 58, 57, 60, 64, 56, 45, 37], [72, 83, 87, 87, 87, 86, 87, 87, 86, 85, 83, 81, 75, 62, 65, 70, 67, 61, 57, 51], [76, 86, 86, 79, 82, 80, 85, 84, 84, 80, 76, 70, 62, 66, 72, 70, 69, 53, 53, 36], [72, 70, 72, 75, 67, 68, 67, 65, 68, 63, 58, 29, 58, 62, 62, 58, 51, 50, 42, 36], [65, 71, 69, 69, 69, 68, 71, 71, 72, 72, 71, 68, 58, 59, 61, 55, 56, 50, 41, 25], [59, 69, 71, 73, 73, 73, 71, 70, 68, 68, 65, 61, 58, 59, 56, 54, 57, 45, 43, 34], [61, 68, 70, 69, 70, 74, 69, 70, 65, 68, 64, 60, 56, 64, 66, 62, 52, 52, 36, 30], [52, 45, 59, 63, 65, 67, 66, 68, 66, 64, 63, 61, 49, 56, 61, 58, 47, 40, 25, 35], [69, 79, 79, 76, 82, 80, 80, 78, 76, 79, 77, 77, 75, 74, 70, 65, 55, 49, 50, 51], [65, 74, 79, 79, 81, 83, 82, 83, 84, 84, 81, 79, 75, 70, 57, 58, 60, 55, 47, 34], [56, 53, 59, 67, 73, 75, 77, 76, 76, 75, 73, 73, 71, 69, 66, 62, 57, 61, 59, 56], [58, 66, 69, 67, 64, 61, 65, 64, 63, 65, 65, 64, 62, 60, 54, 43, 53, 42, 46, 34], [59, 57, 61, 64, 65, 65, 66, 67, 68, 68, 68, 67, 66, 63, 55, 51, 51, 52, 42, 40], [56, 64, 66, 67, 66, 66, 66, 67, 65, 65, 65, 64, 62, 60, 51, 50, 37, 52, 36, 40], [49, 51, 52, 52, 54, 55, 56, 56, 56, 56, 56, 56, 55, 53, 50, 50, 45, 37, 38, 32], [43, 40, 45, 45, 44, 44, 42, 43, 45, 44, 41, 39, 38, 29, 33, 34, 29, 21, 18, 16], [37, 40, 40, 43, 44, 44, 44, 45, 45, 44, 45, 42, 38, 30, 36, 32, 30, 24, 15, 17], [25, 29, 25, 12, 23, 23, 26, 23, 25, 21, 28, 28, 31, 30, 8, 23, 22, 20, 20, 0], [18, 31, 34, 35, 35, 37, 38, 39, 39, 40, 41, 41, 38, 30, 28, 17, 23, 15, 14, 7], [27, 33, 33, 31, 33, 33, 33, 33, 34, 34, 34, 34, 31, 21, 20, 21, 21, 18, 19, 9], [22, 25, 25, 28, 26, 23, 24, 24, 25, 25, 21, 24, 18, 18, 26, 12, 20, 7, 2, 8], [17, 6, 25, 28, 22, 27, 28, 27, 30, 31, 32, 32, 27, 14, 11, 14, 18, 5, 11, 2], [9, 19, 23, 21, 25, 25, 25, 22, 17, 19, 25, 9, 10, 19, 11, 5, 0, 0, 8, 5], [9, 1, 13, 10, 12, 8, 14, 9, 8, 11, 5, 15, 17, 6, 15, 3, 10, 8, 8, 15], [7, 7, 9, 1, 9, 20, 12, 14, 14, 8, 11, 11, 9, 14, 15, 1, 8, 7, 0, 7], [16, 20, 19, 23, 23, 21, 20, 23, 22, 21, 15, 12, 7, 0, 15, 14, 11, 8, 12, 6], [25, 22, 19, 22, 19, 15, 22, 14, 19, 12, 16, 10, 13, 14, 18, 18, 16, 18, 18, 17], [10, 3, 1, 14, 18, 15, 19, 4, 13, 9, 13, 13, 8, 8, 6, 8, 8, 11, 0, 15], [70, 84, 89, 87, 90, 90, 91, 88, 85, 89, 87, 87, 85, 83, 79, 75, 62, 60, 63, 54], [74, 81, 90, 91, 92, 94, 94, 94, 95, 95, 92, 90, 86, 81, 72, 71, 70, 66, 56, 52], [64, 74, 67, 79, 85, 88, 89, 88, 88, 87, 85, 84, 81, 77, 68, 64, 67, 68, 66, 65], [64, 78, 84, 85, 80, 79, 81, 81, 80, 81, 79, 77, 74, 70, 56, 61, 67, 51, 54, 55], [73, 73, 76, 79, 80, 80, 80, 82, 82, 82, 81, 80, 77, 72, 60, 69, 53, 68, 58, 60], [67, 79, 83, 84, 84, 84, 84, 85, 83, 83, 82, 80, 76, 69, 66, 68, 62, 65, 53, 45], [64, 73, 75, 74, 76, 76, 78, 79, 78, 77, 76, 76, 72, 69, 67, 58, 70, 58, 61, 54], [69, 67, 69, 74, 71, 73, 71, 71, 71, 70, 67, 61, 55, 57, 58, 44, 51, 42, 40, 41], [62, 72, 74, 75, 77, 76, 76, 77, 77, 76, 74, 71, 61, 63, 63, 60, 54, 53, 52, 43], [56, 58, 52, 59, 63, 65, 66, 65, 66, 66, 65, 63, 55, 53, 56, 50, 55, 53, 46, 34], [52, 64, 68, 69, 70, 70, 70, 70, 71, 70, 69, 67, 57, 52, 46, 59, 50, 42, 39, 33], [55, 65, 67, 66, 66, 66, 65, 66, 66, 66, 64, 61, 48, 55, 50, 49, 43, 33, 27, 29], [50, 60, 62, 63, 63, 65, 65, 63, 65, 65, 60, 52, 52, 56, 53, 44, 40, 38, 35, 20], [54, 48, 63, 64, 63, 64, 66, 66, 66, 67, 66, 63, 48, 51, 40, 43, 45, 43, 22, 27], [53, 53, 54, 59, 57, 61, 48, 55, 42, 52, 54, 49, 41, 49, 44, 41, 42, 29, 19, 19], [46, 43, 48, 46, 43, 44, 42, 40, 40, 40, 30, 21, 25, 25, 23, 12, 8, 12, 10, 11], [39, 37, 40, 39, 38, 36, 41, 41, 39, 41, 39, 31, 33, 35, 17, 29, 26, 14, 15, 8], [35, 45, 46, 46, 48, 48, 50, 50, 51, 51, 50, 45, 31, 40, 33, 37, 29, 25, 19, 7], [40, 46, 40, 38, 41, 34, 30, 29, 38, 40, 41, 41, 32, 24, 33, 26, 24, 11, 13, 14], [29, 32, 30, 27, 30, 34, 31, 32, 30, 23, 28, 30, 34, 33, 19, 24, 21, 18, 0, 14], [79, 89, 95, 94, 96, 99, 98, 98, 93, 95, 94, 94, 92, 91, 88, 84, 71, 67, 71, 62], [80, 88, 97, 98, 100, 102, 102, 103, 104, 103, 100, 98, 94, 89, 80, 80, 78, 73, 61, 56], [68, 82, 75, 86, 92, 95, 95, 95, 94, 93, 92, 90, 86, 80, 71, 74, 74, 74, 74, 71], [72, 86, 91, 92, 88, 88, 88, 87, 85, 87, 85, 83, 80, 75, 53, 70, 72, 48, 61, 57], [80, 82, 84, 87, 90, 89, 88, 90, 89, 89, 89, 88, 84, 78, 73, 78, 65, 77, 64, 68], [75, 87, 90, 91, 91, 91, 90, 90, 88, 88, 86, 84, 78, 67, 74, 71, 73, 70, 61, 55], [74, 82, 85, 83, 85, 86, 88, 88, 88, 88, 87, 86, 82, 79, 78, 62, 79, 71, 72, 63], [80, 77, 80, 85, 83, 84, 82, 82, 82, 81, 76, 65, 66, 63, 57, 56, 41, 55, 44, 32], [72, 84, 86, 87, 89, 88, 88, 88, 87, 86, 84, 80, 73, 77, 70, 75, 70, 62, 60, 55], [69, 72, 54, 71, 74, 78, 79, 79, 80, 80, 78, 73, 47, 69, 69, 62, 65, 66, 53, 51], [64, 77, 80, 81, 82, 82, 82, 83, 82, 81, 79, 75, 62, 69, 60, 72, 63, 57, 50, 44], [69, 79, 82, 80, 81, 81, 80, 80, 80, 80, 77, 72, 64, 71, 51, 65, 60, 56, 48, 41], [65, 73, 76, 76, 75, 76, 79, 75, 78, 76, 74, 66, 68, 66, 67, 54, 50, 38, 47, 26], [70, 68, 78, 79, 77, 77, 79, 78, 79, 79, 77, 73, 63, 67, 64, 62, 57, 36, 35, 31], [71, 69, 75, 79, 76, 82, 75, 79, 72, 67, 71, 63, 68, 69, 61, 57, 60, 49, 40, 22], [65, 65, 69, 68, 64, 66, 63, 64, 62, 57, 32, 51, 46, 53, 47, 42, 28, 36, 17, 12], [61, 62, 55, 57, 60, 47, 61, 61, 61, 61, 58, 50, 56, 48, 41, 47, 42, 31, 17, 11], [57, 64, 67, 69, 69, 69, 68, 68, 67, 65, 60, 55, 59, 50, 46, 51, 48, 17, 25, 22], [58, 63, 55, 50, 58, 57, 56, 61, 60, 58, 54, 55, 51, 38, 48, 50, 35, 36, 24, 22], [44, 54, 52, 53, 55, 56, 54, 54, 52, 52, 52, 54, 51, 50, 45, 47, 38, 30, 16, 1], [74, 74, 58, 70, 67, 62, 62, 67, 64, 64, 64, 65, 65, 64, 64, 63, 59, 56, 54, 55], [63, 71, 74, 72, 74, 75, 77, 77, 76, 75, 73, 71, 67, 63, 58, 56, 54, 57, 55, 51], [48, 53, 59, 63, 64, 63, 61, 62, 63, 61, 58, 54, 40, 51, 56, 55, 49, 48, 44, 47], [50, 53, 52, 51, 51, 51, 53, 54, 56, 56, 56, 56, 56, 52, 46, 48, 47, 32, 41, 41], [30, 40, 44, 47, 49, 50, 50, 49, 45, 40, 36, 44, 50, 52, 50, 45, 45, 46, 38, 36], [45, 48, 48, 50, 51, 50, 49, 49, 49, 48, 46, 45, 44, 43, 42, 41, 33, 39, 29, 28], [33, 26, 23, 30, 27, 29, 23, 31, 30, 27, 16, 14, 19, 22, 25, 23, 17, 17, 16, 8], [15, 2, 25, 19, 26, 26, 24, 22, 18, 20, 17, 23, 20, 21, 15, 15, 4, 19, 12, 21], [14, 10, 17, 9, 16, 15, 19, 13, 18, 19, 16, 18, 0, 9, 14, 18, 0, 5, 16, 0], [21, 19, 19, 24, 23, 22, 19, 17, 19, 14, 16, 16, 16, 17, 9, 8, 10, 9, 16, 8], [19, 22, 22, 25, 24, 24, 23, 21, 22, 22, 18, 16, 17, 13, 0, 0, 15, 5, 12, 8], [21, 21, 23, 17, 18, 20, 9, 9, 15, 20, 19, 17, 0, 14, 0, 9, 2, 8, 4, 3], [11, 20, 20, 21, 14, 17, 20, 20, 18, 14, 8, 0, 4, 9, 3, 16, 8, 15, 11, 7], [15, 20, 12, 8, 11, 14, 14, 15, 18, 15, 18, 8, 16, 5, 15, 8, 2, 8, 12, 7], [10, 17, 20, 21, 22, 15, 21, 18, 23, 21, 7, 18, 18, 16, 16, 18, 20, 11, 12, 0], [7, 12, 10, 16, 16, 10, 0, 13, 16, 1, 11, 4, 8, 9, 14, 0, 12, 3, 8, 7], [14, 13, 5, 7, 15, 15, 7, 2, 0, 16, 13, 18, 0, 9, 0, 7, 10, 11, 11, 4], [12, 11, 2, 12, 8, 9, 13, 15, 12, 15, 12, 17, 17, 4, 8, 6, 13, 13, 5, 2], [5, 14, 15, 17, 17, 13, 16, 14, 9, 0, 3, 12, 0, 4, 15, 7, 4, 3, 13, 13], [19, 19, 16, 11, 13, 16, 18, 7, 11, 15, 14, 13, 10, 8, 15, 2, 13, 9, 13, 0], [80, 87, 79, 80, 76, 66, 71, 80, 73, 70, 73, 73, 73, 73, 72, 71, 69, 65, 65, 67], [71, 84, 90, 90, 88, 92, 93, 93, 93, 92, 90, 89, 85, 80, 68, 54, 56, 67, 66, 59], [70, 59, 77, 81, 83, 83, 81, 82, 83, 82, 79, 77, 71, 62, 63, 65, 57, 66, 49, 52], [74, 80, 80, 80, 79, 77, 79, 80, 80, 77, 78, 78, 77, 74, 71, 71, 65, 60, 60, 59], [67, 68, 70, 68, 74, 78, 78, 78, 77, 76, 75, 75, 74, 73, 68, 68, 68, 62, 56, 42], [68, 71, 72, 73, 75, 75, 73, 75, 74, 73, 71, 67, 60, 52, 57, 48, 58, 57, 51, 47], [60, 52, 67, 63, 55, 58, 61, 61, 58, 56, 58, 60, 62, 60, 54, 53, 57, 50, 44, 42], [55, 53, 58, 60, 60, 60, 58, 57, 57, 57, 54, 54, 51, 50, 46, 26, 32, 31, 30, 16], [53, 56, 63, 65, 65, 63, 62, 61, 61, 60, 59, 57, 48, 53, 55, 45, 49, 32, 34, 30], [50, 52, 55, 57, 52, 51, 50, 51, 43, 38, 41, 40, 23, 35, 34, 41, 33, 32, 22, 19], [54, 59, 61, 60, 59, 60, 60, 60, 59, 58, 55, 45, 53, 55, 41, 49, 45, 38, 28, 24], [48, 52, 51, 51, 51, 51, 48, 49, 46, 46, 37, 25, 46, 50, 42, 41, 36, 29, 18, 16], [45, 51, 51, 49, 49, 34, 48, 33, 43, 46, 46, 46, 42, 36, 41, 20, 34, 24, 22, 12], [30, 27, 36, 39, 47, 49, 48, 50, 48, 42, 33, 27, 38, 41, 31, 37, 31, 26, 16, 13], [42, 39, 37, 35, 37, 45, 44, 45, 47, 46, 44, 36, 42, 35, 36, 25, 26, 20, 23, 17], [26, 31, 34, 32, 32, 31, 28, 27, 31, 30, 31, 32, 30, 26, 21, 17, 3, 1, 14, 10], [31, 36, 34, 30, 25, 29, 27, 21, 19, 24, 30, 31, 31, 21, 21, 18, 0, 11, 15, 11], [27, 40, 40, 38, 37, 38, 36, 35, 32, 33, 33, 32, 16, 26, 14, 19, 13, 16, 7, 5], [30, 33, 31, 30, 28, 28, 31, 29, 25, 22, 31, 32, 31, 24, 24, 17, 14, 13, 8, 6], [27, 26, 17, 25, 30, 30, 30, 28, 28, 30, 27, 23, 9, 22, 19, 5, 6, 6, 9, 10], [86, 96, 89, 93, 86, 80, 86, 82, 80, 78, 80, 81, 83, 82, 81, 81, 78, 75, 73, 75], [77, 93, 99, 99, 97, 101, 102, 101, 102, 101, 100, 99, 94, 89, 76, 69, 61, 75, 72, 70], [80, 67, 85, 90, 93, 93, 91, 91, 92, 89, 87, 84, 76, 64, 74, 72, 68, 73, 53, 55], [85, 89, 89, 91, 91, 90, 91, 92, 91, 89, 88, 87, 84, 82, 78, 80, 73, 71, 68, 66], [77, 81, 83, 80, 87, 90, 90, 90, 90, 88, 87, 84, 82, 81, 74, 76, 77, 69, 65, 53], [79, 83, 84, 84, 85, 86, 84, 84, 82, 81, 77, 72, 58, 62, 69, 61, 64, 62, 54, 50], [74, 64, 78, 73, 73, 72, 69, 74, 70, 63, 70, 72, 69, 65, 58, 63, 63, 50, 44, 43], [71, 64, 78, 78, 74, 76, 73, 72, 72, 70, 69, 66, 56, 55, 50, 51, 36, 40, 37, 28], [70, 75, 81, 84, 84, 81, 79, 77, 75, 69, 62, 59, 65, 70, 69, 49, 60, 42, 42, 39], [67, 71, 74, 75, 74, 72, 72, 72, 66, 70, 65, 58, 43, 51, 58, 55, 53, 47, 39, 33], [74, 79, 81, 79, 79, 79, 79, 79, 77, 74, 71, 66, 69, 70, 63, 58, 57, 50, 44, 28], [68, 70, 67, 68, 69, 68, 65, 66, 68, 67, 64, 58, 61, 63, 53, 55, 47, 39, 32, 19], [65, 73, 74, 72, 76, 70, 73, 61, 66, 70, 66, 61, 58, 59, 59, 49, 52, 45, 34, 26], [66, 70, 65, 67, 70, 70, 70, 72, 70, 67, 65, 55, 61, 63, 39, 57, 51, 45, 34, 22], [71, 68, 67, 67, 66, 74, 73, 73, 75, 74, 64, 59, 66, 56, 66, 47, 43, 36, 26, 21], [56, 62, 65, 66, 65, 64, 63, 62, 58, 55, 57, 58, 57, 55, 52, 44, 24, 20, 0, 4], [56, 63, 64, 57, 61, 59, 58, 56, 54, 52, 50, 55, 55, 34, 47, 37, 33, 28, 19, 3], [55, 61, 60, 61, 62, 61, 60, 59, 56, 47, 53, 53, 43, 48, 43, 32, 31, 24, 14, 15], [54, 57, 56, 59, 60, 58, 53, 52, 54, 51, 50, 51, 52, 41, 43, 31, 31, 22, 10, 7], [52, 58, 57, 56, 61, 62, 62, 62, 62, 60, 54, 55, 56, 49, 47, 36, 30, 27, 15, 13], [77, 82, 86, 87, 86, 86, 86, 87, 86, 85, 82, 80, 76, 73, 66, 59, 46, 52, 56, 52], [52, 57, 51, 62, 64, 65, 68, 68, 69, 69, 68, 66, 64, 65, 67, 66, 58, 56, 53, 36], [49, 37, 39, 42, 48, 51, 54, 54, 53, 52, 50, 48, 42, 40, 36, 37, 31, 32, 38, 34], [46, 49, 50, 53, 55, 55, 55, 55, 55, 54, 53, 50, 45, 46, 47, 40, 24, 40, 38, 27], [42, 47, 49, 50, 50, 51, 51, 50, 50, 48, 46, 44, 42, 42, 39, 39, 32, 31, 28, 25], [16, 21, 25, 29, 18, 28, 28, 25, 26, 29, 33, 31, 16, 27, 22, 18, 27, 20, 21, 13], [5, 24, 21, 27, 26, 22, 26, 29, 28, 29, 27, 27, 26, 22, 17, 16, 14, 8, 14, 10], [14, 21, 18, 17, 17, 8, 10, 19, 13, 7, 17, 17, 20, 16, 12, 8, 15, 12, 12, 18], [20, 23, 27, 28, 24, 26, 22, 20, 13, 21, 20, 21, 20, 17, 8, 16, 10, 13, 8, 12], [20, 18, 26, 23, 16, 23, 12, 10, 8, 5, 14, 13, 14, 10, 13, 15, 17, 14, 15, 18], [20, 22, 27, 12, 21, 12, 16, 21, 15, 14, 17, 12, 17, 15, 6, 17, 16, 14, 3, 5], [19, 22, 20, 22, 19, 23, 19, 22, 11, 22, 9, 23, 13, 14, 6, 14, 17, 18, 7, 17], [25, 14, 25, 24, 15, 22, 11, 22, 17, 9, 17, 14, 13, 10, 12, 14, 10, 14, 0, 4], [12, 7, 19, 22, 16, 8, 10, 0, 19, 6, 13, 5, 15, 17, 10, 13, 12, 7, 9, 6], [11, 10, 13, 24, 13, 20, 12, 12, 12, 5, 9, 10, 12, 12, 18, 17, 11, 8, 14, 11], [11, 14, 10, 18, 11, 13, 4, 3, 6, 14, 16, 14, 15, 11, 12, 12, 8, 0, 0, 12], [6, 15, 9, 13, 0, 12, 9, 2, 5, 12, 10, 5, 0, 11, 1, 16, 9, 18, 13, 7], [6, 16, 8, 17, 13, 14, 4, 4, 11, 11, 0, 9, 18, 6, 0, 6, 9, 18, 16, 10], [17, 9, 15, 21, 10, 10, 5, 14, 8, 11, 14, 8, 0, 9, 1, 6, 10, 6, 12, 2], [16, 19, 16, 10, 15, 14, 20, 8, 12, 9, 15, 15, 11, 17, 7, 16, 8, 5, 13, 15], [86, 91, 96, 99, 97, 97, 97, 97, 97, 96, 93, 91, 88, 84, 77, 69, 62, 58, 64, 62], [70, 72, 74, 80, 85, 85, 89, 89, 89, 89, 88, 86, 81, 77, 75, 75, 73, 73, 65, 56], [71, 66, 64, 67, 70, 75, 77, 78, 76, 76, 74, 72, 68, 66, 63, 58, 58, 45, 50, 43], [69, 70, 72, 76, 78, 78, 77, 77, 77, 76, 74, 72, 68, 68, 68, 62, 51, 57, 59, 47], [72, 77, 79, 80, 81, 82, 81, 81, 80, 79, 78, 76, 71, 63, 51, 52, 58, 52, 49, 44], [57, 59, 61, 66, 63, 66, 67, 67, 67, 67, 65, 63, 58, 51, 46, 41, 46, 48, 36, 30], [51, 62, 62, 62, 65, 66, 66, 67, 67, 67, 66, 65, 60, 52, 51, 44, 51, 35, 38, 31], [46, 47, 50, 45, 47, 47, 50, 50, 50, 49, 50, 49, 45, 40, 37, 33, 27, 26, 17, 17], [45, 53, 51, 50, 50, 48, 47, 45, 39, 45, 40, 40, 38, 25, 39, 32, 25, 17, 11, 8], [28, 38, 38, 36, 35, 36, 35, 29, 25, 25, 33, 32, 27, 20, 23, 22, 11, 9, 9, 17], [40, 38, 40, 44, 41, 41, 39, 37, 36, 35, 38, 43, 42, 34, 17, 29, 21, 23, 13, 11], [23, 32, 37, 41, 41, 42, 40, 40, 38, 32, 32, 37, 31, 32, 20, 25, 21, 23, 13, 21], [33, 29, 23, 32, 32, 37, 36, 35, 32, 29, 22, 21, 25, 26, 17, 23, 6, 12, 15, 9], [35, 38, 35, 16, 32, 27, 34, 28, 32, 25, 24, 20, 21, 18, 13, 18, 11, 13, 13, 11], [24, 31, 33, 34, 33, 33, 34, 33, 33, 29, 18, 16, 24, 8, 13, 9, 8, 3, 9, 3], [17, 16, 21, 16, 19, 22, 21, 22, 21, 20, 20, 18, 17, 8, 14, 11, 2, 13, 16, 8], [17, 1, 17, 15, 20, 17, 16, 19, 14, 16, 12, 15, 11, 0, 13, 4, 8, 9, 7, 11], [18, 20, 26, 24, 23, 22, 26, 23, 19, 20, 15, 16, 4, 17, 15, 14, 17, 13, 7, 3], [20, 14, 9, 15, 11, 15, 20, 19, 26, 23, 16, 10, 17, 11, 2, 17, 14, 5, 10, 14], [21, 24, 27, 27, 23, 27, 26, 27, 25, 22, 16, 21, 23, 10, 19, 10, 14, 11, 12, 16], [98, 105, 110, 112, 111, 111, 111, 111, 110, 109, 106, 105, 102, 98, 90, 81, 77, 73, 72, 72], [87, 85, 90, 94, 101, 103, 105, 106, 105, 104, 103, 101, 97, 92, 88, 88, 87, 87, 77, 71], [88, 82, 81, 85, 84, 90, 91, 91, 91, 89, 87, 85, 81, 78, 74, 63, 71, 62, 60, 57], [87, 87, 88, 93, 95, 95, 95, 95, 95, 93, 91, 88, 85, 83, 83, 79, 74, 63, 77, 64], [90, 95, 97, 99, 99, 100, 100, 99, 99, 97, 95, 93, 87, 80, 75, 76, 76, 66, 67, 60], [78, 79, 82, 86, 83, 87, 87, 83, 82, 81, 79, 76, 70, 60, 62, 63, 48, 63, 50, 39], [76, 85, 85, 83, 86, 85, 86, 87, 89, 88, 86, 84, 77, 76, 77, 63, 70, 60, 56, 48], [73, 78, 81, 77, 71, 75, 79, 76, 78, 78, 79, 77, 73, 67, 63, 61, 58, 46, 43, 38], [77, 86, 85, 82, 84, 83, 80, 67, 77, 77, 75, 78, 69, 73, 64, 68, 52, 51, 32, 14], [76, 68, 71, 70, 71, 76, 74, 75, 73, 75, 75, 74, 61, 54, 62, 52, 51, 46, 40, 28], [74, 74, 67, 74, 70, 70, 66, 61, 62, 66, 70, 72, 71, 62, 47, 56, 55, 46, 39, 32], [61, 62, 70, 75, 77, 76, 75, 74, 69, 63, 61, 64, 58, 56, 56, 51, 34, 42, 32, 20], [72, 70, 69, 69, 63, 73, 74, 75, 73, 71, 62, 48, 62, 59, 57, 56, 48, 44, 33, 25], [66, 75, 75, 68, 70, 70, 69, 72, 69, 68, 65, 63, 58, 57, 38, 51, 40, 31, 12, 16], [70, 74, 74, 75, 75, 76, 76, 76, 75, 75, 60, 62, 65, 59, 53, 51, 36, 36, 24, 15], [70, 71, 68, 66, 68, 68, 68, 64, 53, 55, 63, 65, 58, 52, 36, 38, 32, 26, 12, 6], [63, 58, 61, 59, 62, 63, 63, 61, 59, 52, 51, 57, 44, 45, 29, 36, 25, 11, 5, 19], [61, 67, 65, 66, 66, 66, 64, 62, 59, 55, 55, 53, 49, 47, 49, 36, 25, 27, 7, 12], [57, 60, 61, 62, 65, 65, 65, 65, 64, 61, 51, 50, 44, 35, 39, 39, 21, 13, 9, 5], [65, 66, 64, 63, 63, 64, 61, 60, 58, 58, 54, 50, 47, 47, 33, 36, 16, 12, 13, 14], [82, 78, 79, 83, 84, 83, 77, 82, 79, 80, 75, 74, 71, 67, 62, 47, 56, 54, 45, 51], [62, 72, 69, 69, 50, 44, 60, 58, 58, 54, 56, 58, 60, 61, 60, 58, 57, 54, 45, 47], [59, 63, 64, 65, 67, 67, 65, 65, 65, 63, 62, 60, 57, 55, 50, 49, 42, 43, 40, 45], [54, 56, 57, 57, 55, 54, 55, 54, 53, 51, 45, 42, 42, 38, 37, 37, 38, 36, 35, 27], [20, 33, 25, 22, 33, 34, 33, 30, 14, 26, 26, 26, 16, 26, 25, 21, 27, 29, 22, 15], [31, 34, 38, 35, 37, 35, 31, 34, 27, 26, 25, 22, 25, 29, 28, 26, 22, 5, 14, 13], [26, 20, 13, 12, 11, 15, 2, 7, 18, 16, 13, 21, 15, 13, 16, 8, 13, 3, 10, 21], [18, 14, 22, 12, 11, 8, 6, 16, 16, 14, 7, 14, 9, 15, 15, 15, 15, 9, 7, 17], [19, 19, 26, 18, 21, 19, 16, 19, 11, 10, 22, 1, 11, 19, 7, 16, 13, 16, 15, 20], [9, 20, 17, 23, 17, 19, 12, 17, 8, 19, 13, 4, 0, 16, 16, 8, 7, 12, 7, 17], [10, 22, 20, 10, 16, 15, 15, 14, 17, 7, 16, 7, 0, 14, 13, 12, 14, 10, 12, 13], [18, 21, 22, 16, 19, 16, 6, 20, 17, 21, 16, 11, 16, 12, 12, 12, 15, 8, 10, 7], [20, 20, 16, 22, 19, 14, 7, 7, 8, 15, 17, 14, 13, 13, 4, 15, 10, 0, 10, 11], [22, 22, 23, 13, 19, 19, 4, 15, 16, 1, 17, 7, 12, 14, 18, 6, 12, 14, 0, 10], [23, 22, 20, 22, 20, 23, 19, 22, 23, 18, 17, 15, 16, 6, 13, 3, 7, 15, 10, 9], [15, 10, 17, 15, 12, 16, 6, 15, 9, 10, 5, 15, 10, 11, 16, 11, 16, 16, 14, 3], [10, 23, 26, 17, 22, 20, 17, 12, 16, 18, 16, 12, 12, 8, 14, 13, 20, 16, 10, 20], [12, 21, 17, 16, 3, 1, 8, 17, 13, 7, 11, 4, 0, 10, 4, 8, 13, 4, 5, 14], [19, 16, 20, 18, 22, 18, 17, 19, 6, 9, 14, 8, 8, 11, 14, 2, 12, 15, 12, 2], [17, 23, 17, 18, 20, 19, 18, 4, 13, 10, 3, 17, 14, 6, 17, 11, 9, 12, 9, 13], [89, 86, 85, 91, 91, 91, 85, 89, 87, 88, 83, 82, 79, 75, 68, 61, 60, 60, 26, 55], [74, 83, 85, 82, 65, 67, 75, 75, 75, 74, 72, 69, 66, 67, 69, 67, 66, 65, 55, 57], [74, 81, 82, 83, 85, 85, 83, 83, 82, 81, 80, 79, 75, 72, 64, 67, 62, 49, 56, 54], [74, 78, 78, 79, 76, 76, 77, 77, 76, 75, 71, 68, 65, 62, 63, 62, 52, 40, 51, 46], [64, 68, 67, 70, 68, 69, 68, 67, 66, 65, 62, 59, 50, 47, 53, 51, 46, 40, 45, 32], [63, 64, 66, 65, 67, 67, 67, 67, 65, 64, 60, 56, 45, 34, 47, 46, 48, 41, 25, 23], [55, 51, 57, 60, 57, 59, 59, 59, 59, 57, 55, 52, 48, 48, 44, 46, 29, 39, 17, 23], [48, 56, 55, 52, 52, 50, 50, 51, 49, 46, 43, 39, 33, 36, 31, 17, 28, 21, 9, 17], [23, 41, 38, 37, 36, 35, 36, 37, 34, 34, 29, 27, 26, 25, 16, 17, 2, 8, 11, 17], [28, 32, 39, 38, 36, 37, 36, 33, 34, 29, 24, 14, 27, 27, 24, 0, 11, 14, 7, 14], [35, 38, 38, 33, 34, 35, 30, 27, 28, 26, 25, 26, 21, 18, 15, 20, 8, 8, 5, 14], [31, 33, 32, 31, 34, 33, 33, 33, 31, 30, 28, 26, 19, 12, 7, 15, 9, 13, 6, 9], [30, 30, 28, 26, 20, 8, 22, 20, 22, 18, 17, 18, 7, 10, 3, 15, 17, 14, 8, 11], [30, 29, 29, 30, 31, 30, 26, 19, 16, 15, 20, 19, 19, 17, 6, 6, 15, 15, 10, 0], [29, 28, 26, 25, 28, 28, 24, 23, 21, 16, 18, 10, 14, 17, 15, 13, 13, 7, 7, 6], [27, 25, 24, 22, 17, 12, 23, 15, 17, 14, 7, 14, 12, 18, 6, 11, 12, 14, 6, 13], [13, 15, 18, 12, 22, 13, 16, 15, 20, 17, 18, 9, 20, 5, 11, 15, 15, 0, 17, 5], [23, 24, 21, 26, 25, 22, 21, 23, 5, 18, 11, 14, 14, 15, 8, 10, 14, 12, 2, 2], [26, 27, 27, 27, 27, 22, 21, 19, 19, 20, 17, 17, 8, 8, 14, 18, 17, 11, 20, 0], [26, 30, 30, 29, 30, 24, 23, 18, 9, 20, 12, 13, 17, 13, 19, 19, 6, 9, 11, 11], [101, 97, 97, 103, 104, 103, 97, 102, 99, 101, 95, 95, 91, 88, 80, 68, 71, 70, 53, 66], [87, 96, 99, 95, 83, 82, 89, 91, 90, 90, 87, 85, 78, 71, 77, 77, 75, 76, 63, 66], [89, 96, 97, 98, 99, 100, 97, 97, 96, 95, 93, 91, 88, 83, 72, 78, 75, 59, 66, 65], [90, 94, 94, 95, 93, 93, 93, 94, 93, 91, 86, 83, 79, 70, 75, 75, 52, 67, 60, 57], [82, 86, 86, 88, 86, 87, 85, 85, 86, 85, 83, 81, 75, 67, 70, 70, 59, 53, 60, 46], [84, 86, 87, 87, 88, 88, 90, 88, 87, 85, 81, 77, 64, 55, 61, 64, 64, 62, 45, 37], [75, 78, 81, 82, 79, 81, 81, 80, 80, 78, 74, 68, 64, 68, 66, 64, 39, 55, 24, 39], [75, 87, 86, 83, 82, 81, 80, 81, 77, 77, 75, 74, 65, 61, 61, 45, 57, 48, 24, 33], [59, 79, 76, 75, 75, 73, 73, 70, 68, 63, 59, 57, 48, 56, 47, 53, 42, 33, 20, 22], [70, 79, 79, 79, 78, 78, 77, 76, 74, 72, 68, 63, 53, 60, 61, 40, 40, 35, 16, 13], [66, 72, 70, 65, 66, 64, 63, 63, 58, 58, 50, 38, 53, 52, 45, 38, 36, 30, 22, 0], [64, 68, 70, 70, 72, 72, 72, 71, 71, 68, 62, 61, 59, 52, 41, 40, 32, 11, 0, 5], [67, 72, 71, 73, 68, 65, 62, 59, 58, 58, 55, 40, 46, 40, 36, 32, 14, 7, 11, 4], [75, 76, 77, 76, 74, 74, 71, 66, 53, 59, 59, 47, 52, 55, 41, 46, 33, 27, 11, 7], [68, 65, 64, 66, 64, 64, 62, 60, 54, 48, 53, 51, 46, 39, 33, 27, 0, 22, 10, 12], [67, 65, 64, 63, 61, 59, 61, 61, 58, 58, 55, 47, 43, 39, 28, 26, 6, 8, 13, 12], [53, 56, 58, 59, 59, 51, 53, 50, 44, 47, 39, 42, 36, 31, 24, 25, 7, 15, 15, 10], [56, 57, 56, 53, 53, 54, 54, 53, 49, 48, 45, 39, 29, 27, 21, 15, 7, 13, 8, 12], [58, 59, 59, 59, 59, 58, 57, 55, 50, 46, 42, 29, 34, 28, 12, 17, 5, 6, 5, 6], [52, 53, 55, 54, 51, 48, 46, 40, 19, 28, 28, 29, 24, 21, 12, 15, 11, 12, 6, 8], [82, 86, 87, 89, 89, 91, 91, 91, 90, 89, 87, 85, 81, 77, 67, 43, 59, 55, 53, 56], [65, 69, 67, 67, 62, 62, 62, 61, 57, 55, 53, 55, 56, 55, 50, 51, 52, 45, 45, 41], [47, 51, 48, 52, 45, 50, 46, 47, 48, 47, 48, 46, 44, 41, 34, 31, 35, 33, 18, 27], [41, 49, 47, 48, 47, 47, 47, 47, 46, 46, 44, 39, 26, 18, 29, 22, 18, 23, 19, 16], [36, 37, 25, 34, 33, 32, 36, 38, 35, 30, 22, 29, 23, 13, 12, 18, 23, 10, 6, 12], [42, 44, 45, 45, 45, 46, 45, 45, 43, 41, 37, 29, 14, 22, 27, 22, 24, 21, 9, 15], [29, 31, 33, 33, 32, 31, 29, 30, 29, 24, 16, 22, 17, 17, 13, 15, 10, 14, 0, 9], [28, 28, 31, 33, 32, 28, 29, 29, 27, 25, 21, 21, 16, 10, 17, 11, 7, 6, 13, 13], [16, 16, 14, 20, 0, 11, 18, 6, 17, 18, 20, 0, 10, 10, 13, 2, 11, 10, 6, 19], [12, 21, 20, 16, 19, 9, 5, 4, 14, 16, 4, 9, 17, 10, 2, 11, 11, 12, 8, 4], [23, 18, 22, 15, 19, 7, 17, 18, 13, 16, 10, 13, 18, 14, 21, 8, 15, 14, 12, 10], [14, 7, 11, 16, 10, 0, 14, 11, 7, 17, 9, 10, 14, 11, 14, 14, 5, 8, 11, 16], [17, 16, 13, 18, 22, 21, 20, 18, 4, 11, 9, 14, 17, 14, 9, 15, 6, 7, 7, 15], [14, 10, 11, 16, 20, 13, 18, 4, 8, 17, 15, 15, 12, 12, 19, 8, 11, 20, 15, 19], [17, 10, 15, 5, 14, 10, 5, 7, 16, 0, 10, 16, 15, 13, 7, 12, 0, 17, 0, 14], [23, 20, 22, 14, 16, 15, 17, 16, 10, 10, 12, 18, 17, 18, 20, 19, 16, 10, 15, 0], [13, 13, 1, 2, 8, 12, 16, 19, 14, 16, 3, 10, 6, 13, 9, 11, 14, 12, 16, 14], [7, 16, 8, 13, 18, 11, 1, 1, 14, 18, 8, 7, 16, 14, 15, 1, 11, 19, 10, 14], [9, 11, 15, 17, 13, 22, 18, 7, 14, 17, 3, 17, 18, 10, 15, 10, 4, 16, 13, 13], [9, 13, 15, 10, 14, 14, 4, 13, 12, 11, 14, 13, 19, 13, 13, 10, 13, 6, 7, 9], [95, 98, 99, 103, 102, 104, 105, 104, 103, 102, 100, 98, 94, 90, 81, 67, 68, 66, 65, 66], [82, 88, 90, 87, 86, 87, 88, 88, 86, 85, 82, 79, 75, 71, 65, 63, 65, 61, 57, 52], [83, 81, 76, 80, 78, 76, 78, 78, 78, 77, 75, 73, 70, 65, 55, 56, 59, 54, 41, 41], [71, 78, 76, 76, 77, 76, 76, 76, 74, 72, 72, 68, 59, 58, 59, 55, 48, 44, 35, 22], [71, 71, 63, 71, 70, 70, 69, 70, 69, 67, 66, 63, 57, 48, 52, 53, 44, 38, 33, 28], [75, 79, 79, 79, 79, 79, 79, 79, 77, 76, 73, 69, 63, 60, 62, 56, 39, 44, 35, 30], [60, 63, 58, 61, 59, 59, 61, 62, 64, 64, 63, 61, 52, 36, 44, 39, 33, 27, 19, 6], [61, 65, 66, 67, 67, 66, 65, 64, 62, 60, 56, 51, 39, 47, 30, 33, 18, 20, 19, 14], [45, 48, 48, 43, 44, 43, 44, 43, 41, 41, 38, 30, 19, 19, 19, 16, 21, 15, 4, 9], [40, 39, 30, 36, 34, 25, 27, 33, 32, 33, 28, 23, 9, 23, 12, 13, 10, 0, 17, 21], [42, 45, 43, 41, 41, 41, 41, 41, 39, 36, 32, 25, 25, 21, 13, 9, 8, 13, 8, 20], [36, 33, 34, 35, 37, 38, 34, 31, 29, 27, 21, 23, 22, 19, 13, 14, 13, 12, 15, 20], [45, 48, 47, 46, 44, 46, 38, 39, 37, 33, 30, 23, 13, 17, 12, 3, 18, 17, 14, 16], [42, 42, 42, 40, 39, 38, 35, 32, 27, 8, 25, 25, 19, 18, 11, 3, 18, 15, 12, 16], [32, 31, 34, 32, 31, 32, 30, 28, 22, 17, 20, 16, 10, 13, 19, 6, 8, 3, 9, 16], [16, 24, 21, 28, 30, 23, 21, 17, 27, 24, 8, 19, 20, 11, 7, 12, 0, 20, 16, 7], [24, 12, 19, 5, 22, 11, 18, 12, 9, 9, 17, 15, 14, 20, 12, 15, 14, 7, 16, 11], [8, 12, 6, 15, 18, 18, 15, 8, 7, 17, 18, 7, 7, 14, 12, 11, 10, 3, 9, 11], [13, 19, 19, 25, 7, 18, 8, 12, 13, 7, 6, 6, 17, 16, 6, 5, 14, 15, 19, 8], [29, 24, 21, 25, 15, 14, 11, 9, 16, 14, 11, 13, 9, 0, 19, 8, 16, 3, 7, 7], [105, 109, 111, 114, 114, 115, 116, 115, 114, 113, 112, 110, 105, 100, 90, 75, 77, 75, 73, 74], [94, 99, 104, 100, 101, 100, 100, 100, 99, 98, 94, 91, 86, 84, 79, 76, 78, 74, 69, 60], [96, 96, 91, 93, 91, 91, 95, 96, 97, 95, 93, 91, 87, 82, 71, 70, 73, 69, 58, 55], [83, 88, 87, 88, 89, 89, 87, 87, 85, 82, 80, 80, 69, 69, 70, 67, 58, 54, 47, 29], [88, 88, 83, 90, 90, 89, 88, 89, 88, 85, 84, 81, 76, 64, 66, 68, 59, 54, 48, 39], [92, 96, 97, 97, 97, 97, 97, 97, 96, 94, 92, 88, 79, 72, 75, 69, 63, 55, 55, 39], [76, 82, 77, 78, 77, 74, 73, 76, 80, 80, 78, 75, 66, 54, 62, 52, 52, 38, 37, 3], [83, 87, 87, 89, 87, 87, 85, 84, 81, 79, 76, 73, 61, 66, 53, 50, 39, 33, 30, 13], [77, 77, 80, 75, 77, 76, 77, 78, 75, 72, 68, 62, 40, 46, 42, 42, 36, 26, 22, 10], [74, 79, 79, 78, 77, 77, 77, 77, 73, 68, 65, 65, 65, 61, 43, 40, 28, 13, 12, 8], [68, 73, 71, 70, 68, 68, 68, 67, 61, 61, 52, 53, 50, 50, 26, 32, 28, 22, 10, 12], [62, 75, 75, 76, 75, 73, 66, 64, 66, 53, 53, 55, 55, 42, 42, 25, 25, 8, 14, 14], [78, 80, 76, 74, 79, 74, 75, 72, 68, 61, 37, 38, 48, 43, 39, 31, 21, 17, 3, 10], [79, 77, 75, 77, 75, 71, 74, 68, 65, 60, 53, 49, 47, 36, 23, 7, 13, 6, 17, 16], [70, 70, 73, 70, 71, 72, 72, 69, 66, 62, 49, 50, 47, 42, 35, 28, 17, 17, 11, 9], [47, 65, 65, 67, 64, 56, 53, 57, 56, 53, 44, 47, 26, 23, 12, 13, 16, 19, 16, 15], [55, 47, 53, 56, 58, 48, 34, 51, 52, 48, 29, 36, 20, 17, 12, 14, 10, 10, 15, 3], [53, 48, 44, 47, 43, 34, 28, 32, 30, 23, 18, 18, 19, 13, 15, 3, 11, 16, 19, 19], [52, 45, 44, 43, 45, 22, 29, 33, 31, 27, 20, 5, 20, 18, 13, 16, 5, 16, 18, 12], [48, 46, 51, 47, 46, 41, 35, 32, 26, 24, 26, 12, 18, 18, 10, 16, 3, 8, 10, 18], [82, 87, 90, 92, 93, 93, 94, 94, 91, 90, 88, 85, 80, 73, 71, 75, 71, 68, 57, 59], [55, 51, 48, 51, 53, 57, 55, 56, 55, 55, 51, 45, 45, 46, 43, 40, 41, 29, 34, 26], [40, 40, 44, 44, 45, 48, 48, 48, 46, 45, 43, 40, 28, 32, 24, 26, 30, 16, 11, 22], [39, 43, 41, 36, 39, 39, 34, 37, 33, 33, 32, 26, 30, 33, 24, 9, 26, 7, 17, 21], [35, 32, 36, 33, 33, 31, 31, 30, 17, 26, 21, 24, 22, 13, 22, 17, 25, 11, 18, 12], [22, 33, 36, 33, 31, 28, 26, 28, 24, 21, 20, 19, 22, 11, 22, 16, 21, 19, 16, 22], [18, 19, 24, 21, 19, 18, 23, 20, 18, 19, 5, 15, 10, 9, 6, 16, 21, 11, 14, 22], [9, 19, 15, 19, 19, 19, 21, 15, 18, 18, 14, 18, 18, 6, 15, 18, 19, 16, 18, 5], [22, 12, 15, 9, 16, 16, 17, 17, 10, 21, 4, 13, 14, 10, 17, 9, 23, 7, 11, 17], [21, 13, 18, 16, 13, 11, 18, 16, 22, 14, 7, 14, 15, 11, 13, 17, 16, 20, 11, 6], [19, 3, 8, 16, 18, 12, 15, 11, 2, 7, 13, 18, 0, 12, 14, 19, 23, 6, 3, 13], [14, 21, 16, 13, 18, 11, 14, 13, 16, 17, 14, 13, 15, 17, 15, 19, 15, 9, 12, 8], [8, 10, 15, 10, 20, 18, 13, 13, 17, 10, 0, 12, 12, 11, 14, 12, 8, 8, 6, 18], [18, 16, 10, 13, 16, 16, 17, 18, 13, 14, 19, 6, 2, 12, 5, 9, 19, 15, 17, 14], [5, 18, 12, 17, 15, 16, 17, 20, 4, 16, 10, 15, 0, 20, 16, 11, 4, 0, 13, 13], [19, 17, 12, 18, 18, 15, 15, 13, 14, 20, 13, 14, 4, 1, 11, 7, 18, 14, 16, 13], [19, 15, 7, 15, 12, 20, 19, 9, 17, 19, 15, 16, 18, 16, 12, 22, 9, 17, 10, 12], [3, 5, 16, 0, 19, 19, 12, 15, 22, 15, 17, 14, 1, 13, 4, 13, 18, 4, 17, 12], [18, 15, 17, 17, 18, 12, 18, 17, 19, 7, 17, 20, 19, 16, 17, 6, 18, 15, 6, 11], [9, 13, 10, 19, 15, 15, 14, 9, 11, 7, 9, 5, 18, 5, 23, 10, 11, 21, 17, 18], [93, 98, 101, 103, 105, 104, 106, 105, 103, 102, 99, 96, 90, 82, 84, 87, 83, 77, 70, 71], [73, 76, 79, 77, 78, 78, 78, 77, 76, 76, 73, 70, 64, 70, 65, 69, 58, 63, 51, 48], [65, 72, 74, 74, 75, 75, 74, 72, 70, 68, 58, 55, 63, 60, 62, 54, 56, 51, 36, 31], [59, 62, 59, 56, 55, 55, 53, 55, 42, 38, 40, 37, 39, 46, 41, 38, 29, 23, 19, 16], [61, 63, 63, 62, 61, 60, 57, 56, 51, 49, 38, 44, 47, 51, 39, 49, 40, 34, 19, 13], [54, 50, 48, 49, 46, 47, 43, 43, 40, 35, 40, 35, 32, 40, 22, 31, 24, 23, 20, 18], [32, 36, 40, 39, 35, 36, 36, 36, 32, 30, 28, 31, 13, 21, 21, 17, 8, 8, 18, 17], [35, 38, 39, 39, 38, 38, 37, 35, 29, 23, 30, 26, 12, 9, 15, 16, 15, 14, 3, 8], [17, 20, 20, 22, 18, 22, 8, 10, 16, 17, 17, 12, 20, 15, 3, 13, 15, 9, 12, 0], [13, 18, 23, 13, 2, 21, 18, 19, 16, 17, 18, 14, 11, 22, 2, 15, 10, 9, 14, 19], [21, 6, 20, 16, 17, 20, 24, 19, 25, 24, 13, 20, 20, 0, 7, 7, 9, 10, 18, 18], [16, 3, 9, 11, 20, 11, 0, 9, 4, 4, 17, 17, 13, 12, 11, 9, 12, 14, 11, 18], [26, 19, 17, 19, 16, 6, 19, 14, 10, 14, 0, 20, 3, 12, 17, 20, 10, 10, 15, 0], [23, 20, 16, 10, 20, 4, 17, 17, 17, 1, 3, 14, 1, 12, 22, 11, 13, 13, 20, 8], [12, 10, 9, 17, 19, 8, 12, 16, 16, 16, 17, 19, 10, 20, 15, 15, 16, 12, 5, 19], [16, 17, 20, 15, 19, 15, 12, 16, 21, 12, 14, 19, 6, 17, 12, 15, 7, 11, 14, 10], [0, 26, 24, 19, 16, 9, 10, 16, 18, 5, 21, 13, 14, 16, 16, 14, 14, 14, 13, 7], [22, 3, 6, 18, 18, 12, 19, 16, 20, 8, 17, 4, 6, 12, 16, 13, 2, 11, 14, 19], [16, 22, 20, 16, 20, 18, 14, 13, 5, 13, 15, 10, 11, 17, 12, 21, 9, 14, 1, 13], [4, 8, 23, 14, 16, 16, 11, 12, 2, 18, 6, 16, 12, 22, 17, 9, 20, 1, 0, 5], [106, 110, 114, 117, 118, 117, 119, 118, 115, 114, 111, 108, 100, 84, 99, 99, 93, 85, 81, 81], [89, 91, 95, 92, 95, 92, 91, 92, 91, 90, 89, 85, 82, 88, 80, 83, 75, 71, 69, 63], [87, 94, 97, 97, 98, 98, 98, 97, 96, 93, 85, 82, 85, 82, 76, 63, 70, 66, 52, 34], [83, 91, 89, 87, 87, 85, 86, 85, 78, 77, 66, 70, 63, 70, 59, 61, 53, 48, 38, 21], [87, 91, 93, 92, 93, 91, 89, 88, 84, 80, 76, 79, 77, 68, 57, 71, 60, 44, 31, 21], [85, 85, 85, 84, 81, 79, 72, 75, 67, 66, 71, 72, 51, 65, 57, 58, 31, 35, 25, 5], [64, 69, 71, 69, 68, 62, 64, 65, 66, 64, 56, 53, 47, 49, 51, 38, 24, 24, 1, 8], [81, 83, 82, 82, 83, 81, 79, 77, 61, 65, 60, 61, 61, 59, 50, 51, 32, 25, 9, 6], [67, 61, 69, 66, 64, 65, 63, 63, 60, 58, 52, 44, 39, 42, 36, 30, 16, 17, 19, 18], [57, 59, 54, 52, 51, 48, 53, 57, 50, 50, 50, 43, 40, 38, 20, 27, 9, 17, 14, 17], [69, 71, 71, 70, 69, 68, 66, 63, 59, 54, 47, 44, 46, 49, 30, 29, 17, 14, 14, 10], [58, 61, 56, 47, 56, 56, 43, 49, 43, 42, 38, 44, 41, 44, 16, 12, 5, 19, 10, 10], [68, 68, 66, 64, 53, 51, 56, 56, 56, 52, 43, 32, 37, 43, 21, 19, 18, 11, 14, 18], [54, 59, 60, 61, 60, 58, 53, 38, 36, 39, 47, 43, 38, 42, 24, 10, 18, 9, 16, 16], [45, 50, 49, 48, 50, 46, 38, 42, 41, 32, 26, 22, 16, 41, 20, 8, 17, 17, 17, 12], [53, 56, 54, 52, 52, 51, 45, 42, 45, 37, 31, 31, 27, 41, 6, 20, 5, 11, 7, 13], [25, 31, 16, 33, 30, 22, 29, 34, 34, 28, 6, 16, 11, 40, 10, 12, 12, 18, 19, 16], [21, 31, 14, 25, 32, 22, 21, 16, 16, 24, 10, 13, 18, 40, 11, 11, 19, 11, 8, 15], [29, 25, 32, 29, 22, 23, 17, 5, 8, 23, 18, 13, 17, 40, 14, 7, 13, 1, 12, 11], [13, 24, 34, 24, 23, 12, 16, 18, 6, 9, 15, 12, 14, 40, 2, 14, 21, 16, 14, 15], [85, 88, 91, 93, 93, 93, 92, 90, 90, 88, 82, 78, 77, 75, 64, 59, 51, 70, 54, 60], [52, 48, 50, 55, 51, 50, 50, 48, 47, 45, 48, 47, 45, 43, 34, 32, 32, 37, 24, 30], [41, 47, 31, 20, 37, 36, 34, 28, 19, 25, 30, 30, 30, 21, 29, 21, 15, 13, 17, 4], [40, 35, 33, 36, 39, 40, 39, 39, 32, 27, 24, 28, 28, 24, 18, 23, 16, 17, 16, 12], [41, 36, 35, 29, 28, 26, 22, 30, 29, 28, 28, 18, 23, 19, 23, 18, 16, 18, 13, 14], [16, 27, 27, 22, 26, 25, 22, 24, 23, 24, 22, 24, 20, 9, 18, 18, 13, 15, 14, 12], [23, 27, 18, 26, 24, 24, 20, 7, 18, 23, 11, 20, 15, 16, 18, 16, 15, 10, 12, 18], [13, 13, 17, 21, 12, 18, 12, 0, 16, 18, 20, 17, 18, 10, 11, 8, 12, 12, 16, 19], [20, 12, 18, 12, 9, 14, 10, 15, 14, 16, 9, 1, 0, 10, 13, 8, 16, 12, 15, 19], [8, 13, 15, 13, 18, 21, 12, 16, 14, 23, 17, 16, 23, 15, 11, 10, 6, 11, 20, 8], [14, 13, 14, 15, 11, 11, 17, 21, 12, 12, 13, 8, 17, 13, 6, 14, 8, 21, 16, 7], [16, 12, 21, 23, 11, 22, 15, 22, 13, 4, 18, 20, 16, 15, 9, 20, 14, 12, 6, 8], [15, 13, 1, 2, 20, 21, 17, 6, 16, 8, 12, 17, 13, 20, 5, 18, 6, 16, 8, 16], [21, 23, 12, 18, 11, 15, 6, 20, 11, 12, 9, 12, 11, 15, 16, 17, 18, 8, 1, 15], [19, 18, 14, 18, 16, 13, 21, 12, 14, 7, 9, 16, 14, 15, 17, 15, 11, 12, 20, 16], [18, 16, 21, 17, 16, 15, 18, 7, 11, 19, 14, 16, 17, 14, 18, 0, 13, 20, 21, 20], [13, 15, 14, 17, 10, 18, 12, 5, 17, 22, 14, 11, 18, 4, 15, 10, 23, 15, 16, 12], [20, 15, 19, 7, 12, 11, 1, 20, 12, 18, 12, 15, 10, 22, 12, 18, 17, 8, 18, 16], [10, 12, 7, 8, 15, 7, 10, 6, 17, 0, 19, 8, 5, 12, 15, 7, 11, 18, 16, 13], [3, 11, 17, 19, 13, 11, 8, 11, 9, 19, 17, 8, 15, 18, 15, 18, 15, 5, 17, 16], [99, 102, 105, 107, 107, 106, 106, 105, 104, 102, 96, 90, 90, 89, 80, 74, 70, 82, 68, 70], [77, 80, 81, 83, 82, 83, 84, 82, 81, 80, 72, 73, 75, 63, 67, 64, 63, 64, 42, 41], [75, 66, 63, 63, 72, 72, 64, 67, 64, 58, 61, 60, 56, 49, 58, 52, 41, 34, 22, 18], [67, 57, 58, 61, 63, 63, 63, 62, 57, 48, 53, 48, 47, 46, 41, 41, 17, 23, 22, 13], [65, 63, 59, 55, 57, 57, 55, 54, 54, 47, 50, 49, 31, 46, 41, 22, 17, 21, 8, 21], [55, 59, 61, 60, 59, 58, 58, 57, 47, 47, 48, 40, 42, 29, 32, 18, 21, 16, 8, 4], [55, 54, 55, 56, 53, 53, 49, 46, 42, 36, 38, 38, 26, 30, 24, 18, 13, 14, 10, 1], [34, 44, 41, 40, 38, 42, 28, 30, 32, 27, 26, 30, 18, 24, 20, 15, 14, 6, 14, 14], [38, 18, 30, 21, 28, 23, 26, 23, 19, 24, 14, 18, 23, 12, 15, 18, 21, 17, 12, 9], [23, 27, 16, 24, 19, 17, 18, 22, 16, 16, 12, 18, 16, 18, 9, 17, 16, 19, 19, 15], [20, 22, 15, 19, 11, 18, 20, 14, 14, 19, 17, 9, 19, 8, 10, 13, 16, 19, 12, 15], [21, 26, 10, 17, 17, 2, 8, 21, 21, 21, 6, 16, 14, 13, 19, 15, 14, 18, 8, 0], [22, 26, 27, 25, 16, 17, 20, 14, 19, 19, 5, 23, 14, 11, 19, 18, 15, 17, 9, 15], [19, 15, 21, 20, 20, 12, 14, 12, 16, 16, 13, 12, 20, 21, 14, 18, 18, 7, 16, 12], [19, 19, 22, 17, 25, 18, 10, 19, 20, 11, 22, 8, 15, 21, 14, 15, 19, 18, 17, 14], [14, 20, 17, 14, 9, 21, 10, 16, 19, 16, 19, 16, 19, 6, 15, 16, 17, 18, 10, 16], [22, 19, 23, 17, 19, 17, 4, 17, 0, 8, 21, 3, 14, 18, 23, 1, 17, 0, 20, 9], [14, 14, 13, 8, 21, 10, 17, 16, 11, 15, 15, 12, 15, 17, 17, 14, 18, 21, 15, 20], [12, 13, 19, 17, 10, 16, 11, 18, 15, 4, 11, 8, 17, 14, 13, 17, 10, 21, 16, 18], [17, 17, 19, 18, 17, 15, 13, 14, 16, 20, 4, 16, 18, 14, 17, 10, 7, 11, 12, 18], [108, 111, 115, 116, 116, 116, 115, 113, 112, 110, 104, 99, 97, 97, 89, 87, 80, 88, 80, 75], [87, 92, 92, 94, 94, 95, 95, 93, 91, 89, 82, 84, 83, 77, 80, 76, 75, 71, 58, 50], [89, 81, 70, 72, 83, 84, 74, 77, 68, 73, 72, 70, 72, 67, 68, 62, 45, 46, 30, 24], [83, 78, 77, 80, 81, 80, 79, 78, 58, 70, 62, 64, 53, 63, 56, 55, 39, 37, 17, 22], [83, 82, 77, 72, 73, 70, 67, 59, 60, 69, 65, 60, 56, 62, 48, 49, 40, 28, 22, 18], [71, 76, 79, 79, 76, 76, 71, 70, 65, 69, 62, 56, 59, 48, 48, 36, 28, 24, 24, 18], [75, 75, 76, 77, 75, 75, 72, 68, 61, 64, 61, 53, 56, 51, 49, 32, 29, 23, 9, 12], [62, 63, 66, 67, 63, 62, 54, 61, 55, 51, 52, 50, 42, 26, 22, 19, 21, 6, 14, 14], [69, 66, 66, 64, 62, 62, 61, 63, 58, 55, 53, 47, 37, 36, 32, 25, 15, 17, 15, 18], [52, 51, 57, 48, 55, 51, 41, 43, 45, 37, 33, 23, 11, 18, 13, 14, 7, 18, 7, 16], [54, 46, 48, 50, 48, 44, 29, 43, 38, 21, 22, 18, 23, 23, 10, 11, 20, 22, 9, 18], [49, 49, 43, 50, 45, 42, 47, 46, 35, 39, 25, 28, 22, 19, 13, 14, 8, 15, 10, 6], [43, 46, 47, 51, 50, 50, 41, 27, 36, 29, 28, 20, 17, 23, 15, 18, 13, 19, 5, 6], [44, 46, 45, 46, 44, 41, 36, 34, 21, 16, 19, 15, 13, 21, 15, 20, 17, 15, 18, 12], [38, 31, 36, 34, 33, 23, 23, 13, 20, 11, 21, 18, 17, 19, 15, 18, 17, 4, 3, 7], [34, 26, 25, 16, 15, 16, 17, 12, 9, 17, 19, 14, 3, 16, 17, 0, 22, 9, 15, 19], [15, 29, 22, 25, 12, 20, 19, 13, 16, 20, 14, 15, 21, 0, 17, 16, 6, 10, 2, 10], [23, 27, 14, 21, 23, 13, 20, 24, 16, 12, 15, 13, 18, 18, 13, 12, 0, 19, 22, 11], [20, 19, 24, 17, 11, 16, 20, 21, 21, 10, 21, 21, 12, 13, 2, 19, 19, 19, 18, 10], [14, 28, 21, 21, 19, 18, 18, 9, 12, 3, 5, 14, 18, 18, 18, 6, 4, 18, 16, 11], [87, 88, 85, 85, 87, 86, 86, 85, 83, 78, 68, 71, 77, 76, 59, 68, 62, 58, 55, 40], [51, 48, 45, 51, 35, 46, 44, 45, 28, 40, 45, 41, 39, 39, 35, 24, 27, 16, 22, 21], [39, 35, 39, 38, 34, 32, 41, 38, 33, 36, 34, 30, 15, 28, 24, 16, 18, 22, 21, 7], [43, 43, 42, 40, 39, 38, 37, 33, 24, 15, 17, 26, 24, 22, 21, 23, 19, 23, 18, 13], [24, 25, 25, 12, 27, 20, 13, 22, 17, 23, 11, 15, 19, 11, 15, 19, 18, 13, 13, 9], [14, 23, 24, 16, 24, 21, 23, 12, 18, 21, 26, 17, 16, 3, 15, 11, 16, 13, 9, 20], [17, 29, 18, 22, 9, 11, 15, 17, 21, 20, 16, 16, 14, 16, 15, 8, 16, 12, 13, 15], [19, 17, 18, 26, 25, 8, 13, 9, 16, 12, 8, 11, 7, 16, 15, 9, 17, 18, 19, 16], [13, 13, 20, 11, 20, 19, 13, 19, 10, 13, 7, 19, 11, 17, 19, 16, 16, 21, 12, 20], [11, 14, 19, 15, 21, 15, 20, 10, 15, 18, 10, 16, 15, 13, 19, 9, 18, 13, 7, 18], [19, 12, 12, 17, 6, 18, 22, 20, 9, 22, 16, 16, 19, 7, 19, 9, 14, 18, 21, 19], [14, 16, 17, 17, 23, 17, 15, 18, 4, 15, 16, 6, 15, 18, 9, 13, 16, 15, 14, 3], [19, 18, 11, 12, 14, 22, 17, 9, 10, 10, 18, 23, 1, 18, 16, 8, 16, 7, 13, 21], [15, 12, 1, 22, 14, 16, 15, 22, 18, 19, 20, 19, 25, 14, 18, 13, 22, 20, 18, 18], [15, 13, 25, 13, 18, 18, 18, 13, 15, 17, 15, 9, 13, 14, 7, 13, 18, 12, 16, 10], [18, 17, 11, 15, 22, 18, 18, 11, 14, 16, 9, 22, 6, 14, 11, 11, 16, 24, 6, 13], [17, 16, 17, 16, 16, 20, 12, 13, 20, 21, 2, 20, 14, 18, 18, 16, 2, 14, 19, 19], [73, 98, 95, 94, 96, 95, 95, 95, 92, 88, 79, 81, 87, 85, 66, 76, 71, 67, 65, 53], [63, 60, 66, 68, 62, 64, 58, 63, 54, 39, 50, 49, 46, 44, 40, 36, 30, 22, 16, 24], [54, 42, 52, 39, 39, 42, 48, 42, 37, 42, 43, 23, 42, 38, 30, 24, 20, 18, 14, 15], [51, 60, 56, 55, 53, 49, 49, 45, 45, 44, 44, 41, 32, 26, 27, 26, 22, 22, 8, 14], [33, 29, 20, 31, 29, 13, 28, 36, 32, 27, 30, 11, 24, 18, 21, 12, 17, 19, 12, 16], [20, 24, 30, 22, 22, 21, 18, 23, 24, 12, 16, 15, 15, 15, 13, 17, 16, 10, 12, 21], [15, 25, 25, 21, 19, 16, 22, 24, 16, 15, 16, 17, 15, 16, 16, 18, 18, 19, 18, 12], [12, 22, 21, 11, 24, 15, 17, 18, 6, 14, 9, 17, 18, 16, 11, 15, 13, 10, 14, 10], [19, 18, 22, 7, 17, 18, 6, 21, 22, 10, 21, 14, 15, 10, 17, 14, 23, 17, 16, 16], [14, 16, 12, 22, 24, 21, 20, 13, 17, 19, 13, 14, 15, 8, 9, 18, 5, 6, 11, 21], [25, 21, 24, 12, 0, 20, 18, 13, 19, 22, 20, 22, 18, 19, 19, 16, 10, 15, 11, 16], [25, 17, 21, 20, 17, 19, 23, 10, 18, 23, 19, 16, 14, 7, 19, 11, 7, 19, 18, 5], [11, 12, 20, 11, 18, 13, 15, 15, 19, 10, 19, 20, 19, 15, 5, 18, 17, 19, 21, 15], [16, 13, 19, 12, 19, 20, 21, 12, 22, 12, 10, 18, 20, 18, 24, 13, 13, 16, 12, 13], [14, 16, 8, 17, 12, 20, 23, 19, 9, 9, 14, 16, 14, 16, 23, 21, 18, 13, 0, 20], [18, 12, 18, 11, 16, 15, 19, 19, 19, 15, 16, 8, 12, 16, 18, 10, 10, 18, 23, 18], [20, 4, 10, 21, 6, 14, 20, 17, 20, 20, 6, 21, 13, 16, 19, 23, 17, 14, 5, 6], [59, 105, 113, 108, 108, 109, 109, 108, 106, 101, 84, 96, 101, 97, 85, 88, 83, 80, 73, 64], [35, 87, 79, 83, 93, 87, 82, 85, 78, 81, 74, 84, 64, 69, 69, 60, 57, 52, 42, 35], [26, 79, 71, 81, 67, 75, 74, 65, 65, 72, 57, 68, 59, 44, 56, 47, 34, 29, 19, 16], [19, 84, 82, 78, 72, 72, 71, 69, 72, 72, 60, 53, 46, 39, 38, 35, 25, 22, 15, 18], [20, 65, 67, 67, 70, 66, 65, 64, 63, 60, 57, 49, 44, 41, 23, 14, 16, 22, 13, 11], [9, 59, 44, 58, 62, 60, 59, 57, 57, 53, 38, 38, 32, 19, 12, 22, 0, 5, 13, 19], [19, 66, 65, 63, 54, 51, 40, 58, 56, 50, 47, 47, 35, 14, 19, 10, 20, 18, 19, 20], [13, 60, 60, 50, 34, 38, 44, 36, 45, 42, 35, 28, 22, 17, 18, 2, 18, 12, 20, 13], [10, 55, 55, 56, 51, 49, 45, 42, 35, 38, 32, 35, 25, 20, 20, 16, 21, 16, 11, 18], [19, 44, 43, 48, 45, 40, 31, 16, 27, 19, 11, 10, 0, 19, 4, 10, 5, 11, 7, 4], [3, 33, 40, 38, 35, 34, 22, 31, 24, 22, 24, 13, 13, 12, 14, 23, 12, 19, 22, 18], [13, 35, 39, 41, 35, 31, 28, 28, 23, 22, 19, 14, 18, 18, 19, 21, 17, 20, 14, 22], [20, 32, 38, 34, 27, 21, 17, 9, 8, 15, 11, 18, 21, 13, 11, 25, 16, 12, 13, 15], [7, 32, 31, 28, 36, 33, 16, 25, 11, 17, 14, 10, 15, 19, 21, 18, 16, 12, 18, 17], [20, 21, 15, 19, 24, 21, 23, 22, 13, 20, 7, 10, 25, 17, 21, 21, 22, 19, 21, 9], [14, 25, 22, 20, 14, 12, 8, 13, 15, 23, 14, 23, 7, 10, 15, 19, 19, 14, 10, 7], [6, 27, 28, 24, 26, 11, 21, 16, 18, 13, 12, 15, 24, 11, 13, 18, 14, 12, 13, 13], [78, 77, 78, 78, 72, 63, 73, 72, 72, 72, 69, 67, 67, 68, 62, 61, 54, 35, 41, 38], [46, 47, 49, 53, 53, 52, 52, 51, 49, 45, 38, 42, 42, 36, 24, 29, 19, 19, 23, 12], [32, 37, 31, 26, 36, 27, 29, 28, 27, 19, 36, 34, 31, 21, 21, 26, 20, 17, 17, 14], [26, 28, 25, 23, 19, 20, 25, 24, 17, 21, 13, 23, 11, 21, 19, 16, 13, 13, 16, 20], [18, 22, 18, 21, 6, 16, 14, 11, 16, 11, 3, 18, 8, 20, 15, 19, 9, 26, 21, 15], [16, 16, 21, 15, 19, 13, 17, 7, 13, 20, 11, 11, 17, 11, 18, 14, 14, 20, 17, 10], [23, 23, 19, 18, 21, 13, 8, 13, 22, 6, 20, 20, 19, 14, 7, 10, 18, 8, 15, 19], [23, 20, 11, 14, 8, 16, 16, 13, 20, 9, 23, 18, 15, 17, 7, 13, 14, 11, 13, 14], [19, 15, 23, 19, 18, 23, 18, 26, 15, 16, 19, 17, 14, 6, 16, 19, 8, 23, 18, 18], [9, 14, 16, 11, 19, 7, 13, 16, 6, 21, 19, 18, 16, 19, 22, 19, 7, 6, 19, 22], [10, 7, 10, 20, 13, 12, 16, 13, 14, 23, 16, 15, 8, 21, 14, 16, 7, 19, 21, 7], [17, 4, 18, 12, 19, 15, 22, 23, 17, 7, 18, 7, 13, 23, 20, 17, 14, 18, 21, 21], [11, 10, 17, 9, 15, 8, 8, 20, 21, 16, 14, 22, 9, 18, 17, 11, 17, 15, 20, 11], [94, 92, 91, 93, 88, 80, 77, 75, 75, 72, 73, 72, 77, 76, 68, 70, 64, 47, 50, 43], [53, 59, 50, 59, 60, 55, 52, 50, 48, 54, 54, 41, 47, 49, 41, 35, 34, 26, 17, 24], [59, 51, 53, 55, 55, 52, 56, 55, 50, 51, 53, 45, 41, 41, 18, 22, 7, 0, 20, 20], [39, 41, 41, 37, 41, 41, 39, 39, 36, 33, 31, 9, 24, 6, 19, 9, 12, 20, 6, 19], [31, 33, 33, 25, 24, 30, 30, 23, 16, 13, 13, 19, 17, 16, 20, 12, 21, 17, 13, 9], [26, 20, 21, 20, 24, 18, 20, 16, 15, 17, 19, 20, 14, 8, 21, 15, 20, 14, 4, 11], [24, 22, 16, 20, 23, 17, 17, 22, 20, 16, 16, 20, 2, 15, 8, 19, 21, 21, 17, 14], [23, 26, 13, 12, 17, 19, 18, 21, 13, 20, 20, 13, 14, 8, 21, 9, 22, 14, 4, 14], [23, 14, 16, 18, 22, 16, 10, 13, 17, 22, 12, 19, 18, 22, 14, 16, 21, 19, 9, 15], [20, 22, 19, 22, 17, 13, 19, 17, 19, 22, 15, 19, 16, 20, 10, 18, 11, 21, 21, 12], [16, 16, 19, 16, 11, 13, 20, 9, 15, 18, 21, 17, 17, 19, 17, 21, 12, 10, 11, 24], [21, 14, 15, 15, 14, 14, 18, 14, 22, 21, 13, 18, 18, 19, 14, 16, 19, 21, 18, 9], [23, 21, 16, 23, 7, 19, 20, 19, 21, 18, 11, 18, 15, 10, 18, 20, 6, 17, 12, 23], [54, 103, 98, 103, 101, 100, 92, 89, 91, 89, 77, 86, 87, 85, 80, 78, 75, 66, 52, 51], [32, 88, 87, 86, 86, 86, 84, 86, 85, 80, 71, 68, 78, 70, 67, 63, 54, 41, 40, 30], [23, 80, 69, 69, 74, 70, 71, 67, 57, 63, 62, 58, 50, 51, 43, 44, 34, 27, 25, 24], [19, 65, 58, 65, 66, 66, 66, 59, 56, 45, 57, 51, 21, 42, 30, 29, 16, 16, 14, 20], [24, 58, 62, 61, 55, 46, 56, 51, 46, 49, 50, 47, 42, 29, 27, 23, 10, 22, 24, 18], [21, 51, 51, 32, 41, 36, 33, 31, 37, 36, 29, 25, 17, 20, 9, 20, 17, 12, 11, 18], [16, 55, 52, 50, 41, 42, 37, 42, 28, 29, 21, 21, 6, 10, 11, 18, 16, 17, 14, 16], [20, 38, 44, 43, 40, 42, 35, 36, 25, 32, 22, 23, 20, 8, 12, 16, 10, 17, 18, 20], [10, 48, 44, 39, 34, 21, 20, 26, 24, 27, 21, 21, 19, 13, 21, 17, 15, 19, 17, 16], [22, 34, 36, 30, 26, 27, 25, 13, 16, 22, 18, 17, 20, 18, 13, 21, 18, 9, 17, 18], [19, 18, 27, 21, 25, 20, 14, 13, 1, 10, 17, 20, 11, 21, 1, 15, 17, 19, 8, 26], [12, 28, 29, 23, 22, 16, 20, 24, 18, 10, 1, 21, 17, 17, 17, 8, 21, 12, 16, 18], [12, 27, 19, 19, 17, 16, 21, 15, 10, 20, 20, 17, 12, 20, 15, 20, 20, 24, 15, 19], [67, 70, 78, 81, 81, 78, 78, 78, 73, 71, 68, 63, 66, 67, 60, 56, 51, 50, 29, 37], [47, 52, 53, 56, 56, 55, 54, 53, 47, 40, 40, 41, 27, 30, 27, 25, 7, 16, 22, 18], [22, 33, 35, 36, 34, 37, 36, 35, 24, 17, 22, 18, 21, 23, 7, 16, 16, 19, 8, 15], [24, 26, 23, 20, 18, 18, 22, 24, 17, 17, 16, 19, 21, 13, 12, 16, 21, 24, 0, 12], [18, 20, 15, 26, 21, 22, 22, 16, 21, 11, 15, 17, 18, 17, 25, 24, 23, 18, 9, 12], [21, 7, 17, 16, 15, 16, 17, 20, 18, 13, 20, 16, 19, 20, 14, 8, 11, 18, 15, 18], [14, 13, 19, 18, 20, 19, 7, 15, 23, 21, 19, 18, 15, 16, 17, 18, 22, 15, 16, 13], [16, 26, 23, 21, 23, 9, 14, 22, 12, 16, 17, 23, 14, 16, 15, 13, 18, 21, 19, 15], [17, 6, 6, 15, 21, 25, 17, 23, 17, 20, 19, 16, 27, 18, 12, 14, 21, 10, 23, 11], [22, 11, 8, 20, 6, 21, 23, 17, 22, 20, 24, 22, 18, 24, 16, 11, 25, 17, 19, 20], [21, 14, 20, 22, 19, 26, 14, 18, 16, 12, 19, 24, 19, 24, 12, 20, 17, 23, 16, 21], [85, 90, 94, 96, 95, 95, 95, 95, 92, 89, 83, 77, 78, 79, 73, 72, 63, 63, 32, 46], [62, 61, 63, 63, 66, 65, 63, 63, 56, 46, 47, 52, 34, 38, 37, 34, 19, 18, 15, 21], [38, 48, 49, 49, 44, 43, 43, 41, 31, 31, 38, 35, 18, 30, 27, 22, 21, 17, 19, 23], [40, 40, 36, 30, 28, 24, 24, 30, 31, 27, 24, 21, 14, 17, 24, 10, 15, 13, 14, 22], [23, 34, 21, 26, 23, 28, 19, 20, 25, 20, 16, 15, 9, 12, 23, 3, 25, 7, 22, 7], [23, 19, 18, 20, 25, 16, 16, 19, 26, 20, 21, 18, 11, 19, 23, 21, 19, 17, 18, 22], [23, 26, 13, 20, 21, 18, 12, 9, 12, 12, 19, 19, 8, 19, 19, 16, 19, 18, 17, 19], [12, 20, 19, 18, 19, 14, 24, 15, 26, 16, 21, 8, 15, 16, 17, 20, 13, 15, 17, 20], [21, 17, 13, 18, 20, 17, 19, 23, 17, 22, 24, 1, 23, 14, 11, 12, 17, 16, 12, 12], [16, 5, 15, 20, 15, 14, 11, 20, 18, 14, 14, 12, 13, 19, 16, 13, 21, 5, 13, 11], [14, 21, 15, 20, 19, 17, 15, 19, 21, 18, 23, 7, 21, 8, 15, 17, 22, 14, 21, 22], [102, 107, 110, 112, 111, 111, 111, 111, 108, 105, 98, 91, 94, 93, 89, 84, 77, 76, 57, 57], [86, 86, 88, 89, 92, 91, 86, 77, 79, 68, 69, 74, 64, 67, 62, 56, 31, 37, 21, 16], [66, 72, 65, 53, 67, 64, 65, 60, 57, 47, 44, 49, 47, 42, 37, 29, 15, 20, 17, 18], [63, 64, 60, 37, 47, 52, 57, 55, 52, 49, 47, 47, 42, 24, 25, 18, 22, 13, 20, 16], [53, 52, 48, 45, 51, 52, 50, 49, 27, 42, 40, 29, 23, 12, 21, 8, 12, 22, 23, 10], [41, 44, 43, 38, 38, 28, 34, 30, 22, 21, 24, 18, 16, 10, 17, 17, 15, 20, 20, 12], [46, 43, 40, 29, 21, 30, 24, 28, 25, 23, 22, 11, 15, 16, 15, 18, 14, 16, 13, 18], [31, 37, 36, 35, 24, 29, 21, 20, 9, 20, 21, 16, 20, 16, 13, 20, 18, 20, 24, 22], [29, 25, 30, 18, 24, 12, 20, 24, 20, 18, 15, 19, 17, 13, 19, 10, 22, 8, 14, 20], [24, 28, 20, 18, 21, 16, 19, 2, 19, 13, 11, 21, 19, 20, 17, 25, 15, 20, 12, 14], [26, 28, 23, 23, 14, 18, 21, 23, 16, 13, 18, 23, 20, 14, 15, 19, 23, 19, 18, 19], [65, 73, 67, 72, 69, 67, 65, 65, 58, 54, 57, 48, 56, 37, 40, 42, 36, 31, 24, 19], [45, 45, 43, 42, 43, 40, 42, 41, 43, 42, 30, 36, 23, 15, 23, 8, 23, 21, 19, 22], [26, 21, 28, 26, 24, 20, 22, 20, 22, 14, 21, 20, 15, 20, 22, 11, 16, 21, 13, 18], [30, 32, 34, 35, 31, 32, 19, 18, 27, 15, 15, 11, 21, 18, 13, 12, 16, 18, 15, 11], [21, 25, 23, 22, 6, 12, 19, 12, 21, 21, 17, 20, 7, 19, 10, 23, 18, 17, 16, 10], [24, 25, 25, 26, 22, 18, 25, 23, 14, 21, 15, 21, 10, 15, 12, 12, 13, 17, 15, 19], [22, 13, 10, 21, 19, 22, 22, 21, 24, 8, 18, 19, 20, 14, 12, 19, 8, 19, 13, 16], [21, 25, 17, 13, 20, 18, 17, 23, 23, 23, 21, 14, 15, 20, 23, 16, 21, 18, 21, 21], [17, 14, 14, 12, 23, 15, 16, 15, 22, 13, 26, 23, 18, 23, 14, 12, 16, 19, 13, 19], [89, 93, 90, 92, 90, 87, 88, 85, 85, 82, 62, 72, 77, 71, 64, 58, 51, 41, 25, 26], [43, 59, 52, 46, 52, 48, 46, 50, 48, 50, 20, 46, 34, 13, 22, 26, 20, 22, 16, 18], [27, 36, 33, 37, 28, 31, 33, 31, 32, 21, 19, 20, 16, 17, 15, 20, 13, 23, 10, 13], [32, 42, 28, 27, 29, 32, 35, 33, 28, 31, 23, 19, 16, 20, 23, 23, 21, 16, 22, 20], [29, 22, 26, 33, 27, 24, 22, 24, 10, 15, 14, 16, 18, 17, 14, 5, 19, 14, 16, 23], [10, 22, 20, 13, 19, 21, 25, 20, 21, 23, 13, 9, 17, 17, 15, 20, 20, 21, 19, 10], [23, 18, 18, 22, 24, 29, 18, 15, 23, 21, 20, 20, 10, 15, 22, 16, 23, 17, 21, 18], [24, 11, 7, 8, 18, 17, 21, 16, 19, 24, 21, 23, 13, 22, 18, 19, 21, 16, 21, 27], [105, 107, 106, 106, 105, 104, 103, 101, 101, 97, 77, 91, 91, 86, 77, 70, 64, 54, 46, 40], [83, 80, 79, 68, 63, 78, 75, 73, 68, 72, 63, 66, 56, 56, 46, 31, 15, 8, 15, 18], [55, 51, 52, 56, 48, 51, 53, 47, 41, 40, 20, 34, 36, 28, 19, 20, 20, 19, 21, 19], [56, 53, 50, 40, 47, 54, 54, 49, 28, 50, 39, 40, 35, 30, 19, 26, 25, 28, 16, 21], [38, 43, 37, 41, 39, 39, 41, 40, 29, 20, 19, 20, 21, 21, 15, 12, 14, 17, 18, 11], [46, 38, 38, 33, 30, 29, 28, 22, 17, 17, 14, 12, 12, 15, 24, 18, 16, 19, 17, 15], [31, 38, 25, 27, 13, 21, 20, 19, 12, 15, 19, 24, 17, 13, 17, 20, 17, 18, 21, 16], [16, 23, 23, 27, 18, 26, 16, 15, 12, 8, 13, 22, 15, 15, 16, 18, 14, 22, 23, 22], [18, 24, 19, 25, 25, 21, 13, 12, 15, 19, 18, 23, 22, 12, 22, 16, 16, 26, 17, 20], [61, 58, 51, 66, 50, 61, 47, 51, 45, 56, 52, 50, 39, 48, 35, 37, 27, 31, 28, 25], [42, 43, 39, 37, 37, 42, 40, 29, 33, 23, 35, 29, 23, 23, 14, 21, 17, 17, 23, 21], [32, 23, 15, 21, 28, 32, 23, 25, 14, 25, 21, 20, 18, 23, 21, 18, 16, 8, 19, 12], [16, 18, 26, 24, 20, 24, 23, 19, 22, 17, 18, 19, 3, 19, 23, 18, 9, 11, 19, 14], [21, 24, 24, 14, 22, 13, 21, 24, 16, 25, 9, 16, 16, 20, 22, 18, 8, 23, 18, 15], [14, 21, 17, 25, 21, 18, 20, 20, 20, 24, 19, 18, 23, 20, 22, 15, 25, 18, 21, 18], [18, 18, 19, 23, 18, 16, 19, 14, 20, 22, 13, 19, 24, 19, 20, 23, 27, 20, 20, 23], [83, 78, 76, 78, 69, 69, 74, 77, 67, 77, 70, 70, 66, 66, 53, 52, 42, 32, 26, 23], [52, 53, 49, 49, 43, 35, 47, 42, 42, 40, 36, 37, 29, 23, 22, 19, 24, 25, 18, 19], [37, 39, 33, 34, 28, 33, 28, 27, 27, 27, 12, 24, 26, 19, 23, 20, 17, 18, 20, 14], [28, 24, 23, 28, 24, 22, 26, 26, 23, 24, 26, 26, 20, 20, 19, 22, 24, 13, 17, 20], [28, 15, 22, 23, 28, 25, 15, 25, 22, 20, 21, 20, 23, 21, 20, 27, 16, 19, 16, 19], [8, 19, 22, 25, 21, 25, 16, 21, 20, 20, 22, 26, 26, 19, 21, 14, 23, 23, 13, 16], [19, 14, 23, 25, 24, 24, 15, 26, 22, 20, 22, 22, 19, 21, 23, 22, 14, 18, 19, 21], [108, 106, 101, 101, 89, 89, 96, 101, 94, 98, 88, 90, 87, 76, 72, 69, 51, 51, 25, 21], [81, 73, 80, 81, 70, 77, 73, 64, 58, 60, 61, 52, 42, 46, 35, 28, 21, 20, 19, 15], [64, 60, 58, 61, 63, 56, 61, 52, 46, 43, 43, 23, 27, 21, 16, 23, 21, 21, 21, 11], [49, 54, 48, 58, 55, 33, 46, 48, 46, 25, 32, 27, 23, 20, 22, 18, 21, 12, 20, 13], [39, 43, 47, 37, 38, 29, 35, 32, 28, 20, 10, 16, 17, 12, 23, 13, 20, 17, 22, 22], [33, 32, 23, 34, 27, 29, 21, 16, 21, 18, 20, 14, 9, 19, 18, 22, 11, 21, 15, 20], [18, 27, 17, 24, 27, 18, 25, 24, 23, 20, 22, 16, 19, 24, 18, 21, 20, 21, 25, 16], [61, 71, 70, 72, 63, 58, 56, 54, 58, 50, 46, 50, 46, 34, 37, 28, 25, 26, 26, 25], [30, 40, 37, 38, 33, 31, 34, 31, 27, 30, 22, 22, 19, 25, 21, 21, 14, 17, 20, 25], [25, 30, 22, 26, 28, 24, 28, 24, 14, 20, 19, 19, 15, 23, 14, 18, 16, 16, 20, 18], [26, 19, 25, 22, 21, 20, 27, 16, 22, 15, 19, 18, 14, 22, 22, 22, 22, 18, 18, 22], [17, 23, 20, 20, 26, 21, 14, 23, 17, 8, 24, 21, 20, 8, 17, 20, 20, 20, 19, 24], [22, 23, 24, 23, 21, 20, 16, 27, 27, 18, 20, 18, 17, 19, 18, 14, 15, 19, 16, 19], [72, 82, 85, 83, 81, 79, 73, 68, 75, 69, 67, 69, 58, 51, 53, 46, 40, 35, 29, 25], [49, 49, 54, 52, 39, 45, 46, 37, 29, 40, 35, 28, 29, 26, 17, 23, 20, 27, 17, 20], [33, 36, 31, 33, 32, 35, 32, 35, 28, 28, 24, 23, 18, 22, 13, 19, 19, 22, 17, 19], [28, 28, 29, 27, 27, 25, 28, 21, 17, 20, 20, 24, 20, 23, 22, 19, 21, 15, 19, 22], [25, 26, 26, 22, 9, 24, 19, 20, 22, 23, 18, 14, 16, 22, 19, 26, 22, 22, 23, 21], [82, 93, 96, 100, 99, 94, 90, 83, 91, 79, 81, 80, 69, 66, 62, 54, 43, 35, 17, 21], [68, 66, 71, 61, 53, 64, 63, 57, 45, 51, 44, 40, 33, 28, 17, 25, 20, 24, 14, 16], [41, 51, 49, 50, 47, 48, 42, 39, 32, 29, 20, 23, 23, 22, 19, 20, 17, 27, 14, 12], [39, 43, 43, 37, 34, 36, 26, 26, 20, 17, 24, 21, 18, 21, 14, 11, 23, 16, 15, 23], [32, 30, 31, 26, 25, 21, 24, 23, 18, 16, 25, 25, 20, 17, 24, 24, 13, 19, 17, 23], [63, 69, 56, 66, 51, 62, 55, 47, 48, 45, 37, 37, 30, 28, 28, 23, 28, 23, 17, 25], [29, 28, 28, 34, 25, 32, 29, 28, 27, 21, 17, 20, 19, 22, 23, 19, 25, 16, 23, 21], [22, 23, 28, 28, 22, 27, 28, 20, 24, 22, 21, 23, 24, 24, 24, 25, 26, 15, 19, 27], [70, 84, 83, 83, 78, 70, 67, 64, 77, 66, 70, 66, 55, 52, 47, 35, 30, 26, 26, 25], [45, 55, 40, 47, 42, 46, 42, 36, 37, 37, 32, 22, 17, 24, 19, 14, 21, 27, 22, 18], [31, 32, 36, 34, 24, 23, 22, 19, 21, 24, 24, 20, 22, 23, 19, 15, 15, 20, 21, 21], [23, 24, 25, 29, 28, 22, 26, 22, 19, 25, 23, 22, 24, 24, 22, 23, 19, 18, 25, 23], [83, 91, 97, 98, 91, 90, 93, 89, 89, 78, 80, 76, 65, 65, 55, 41, 36, 27, 18, 22], [70, 68, 58, 58, 66, 61, 62, 53, 48, 47, 46, 33, 18, 24, 26, 20, 17, 16, 19, 16], [46, 52, 51, 47, 39, 41, 41, 27, 32, 29, 26, 22, 25, 17, 18, 19, 21, 16, 26, 24], [34, 36, 36, 36, 32, 27, 29, 23, 21, 21, 27, 17, 13, 26, 23, 19, 20, 25, 24, 18]]} ================================================ FILE: amy/sineclock.py ================================================ import amy, math, datetime try: amy.live(playback_device_id=1) running_amyboard = False except: running_amyboard = True # Reserve 3 oscs x 3 "hands" amy.send(synth=16, num_voices=1, oscs_per_voice=9) def setup_triple( synth=16, base_osc=0, base_freq=200.0, freq_dev=5.0, period_sec=60, phase=0, vel=1 ): # Osc+2 is the mod osc amy.send(synth=synth, osc=base_osc + 2, freq=1.0/period_sec, phase=phase - 0.25) # Want it at lowest value when phase = now. # Osc+1 is the moving sine mid_freq = base_freq + freq_dev / 2 mod_depth = math.log2(mid_freq / base_freq) # -1 x this deviation brings down to base_freq amy.send(synth=synth, osc=base_osc + 1, mod_source=base_osc + 2, freq={'const': mid_freq, 'mod': mod_depth}) # Osc+0 is the fixed sine amy.send(synth=synth, osc=base_osc, freq=base_freq) # Start the two sounding oscs amy.send(synth=synth, osc=base_osc, phase=0, vel=vel) amy.send(synth=synth, osc=base_osc + 1, phase=0, vel=vel) def start_sine_clock(hour, minute, second, vel=0.1): # One-minute cycle setup_triple(base_osc=0, vel=vel, base_freq=200, period_sec=60, phase=second / 60) # One-hour cycle setup_triple(base_osc=3, vel=vel, base_freq=300, period_sec=60 * 60, phase=(60 * minute + second) / (60 * 60)) # One day cycle setup_triple(base_osc=6, vel=vel, base_freq=450, period_sec=60 * 60 * 24, phase=(3600 * hour + 60 * minute + second) / (60 * 60 * 24)) try: import datetime vel = 0.1 now = datetime.datetime.now() print(now) start_sine_clock(hour=now.hour, minute=now.minute, second=now.second, vel=vel) except ImportError: pass ================================================ FILE: amy/test.py ================================================ import sys import os import random import string import tempfile import numpy as np import scipy.io.wavfile as wav import amy import c_amy as _amy import time from . import constants def wavread(filename): """Read in audio data from a wav file. Return d, sr.""" # Read in wav file. file_handle = open(filename, 'rb') samplerate, wave_data = wav.read(file_handle) # Normalize short ints to floats in range [-1..1). data = (wave_data.astype(np.float32)) / 32768.0 return data, samplerate def rms(samples): return np.sqrt(np.mean(samples ** 2)) def dB(level): return 20 * np.log10(level + 1e-5) class AmyTest: ref_dir = './tests/ref' test_dir = './tests/tst' def __init__(self): self.default_synths = False def test(self): name = self.__class__.__name__ _amy.stop() _amy.start(1 if self.default_synths else 0) self.run() samples = amy.render(1.0) amy.write(samples, os.path.join(self.test_dir, name + '.wav')) rms_x = dB(rms(samples)) message = ('%-32s:' % name) + (' signal=%5.1f dB' % rms_x) ref_file = os.path.join(self.ref_dir, name + '.wav') try: expected_samples, _ = wavread(ref_file) rms_n = dB(rms(samples - expected_samples)) message += (' err=%.1f dB' % rms_n) except FileNotFoundError: message += ' / Unable to read ' + ref_file rms_n = 0 # For now, any value above this threshold counts as a failed test threshold = float(os.environ.get('AMY_TEST_THRESHOLD_DB', '-100.0')) test_passed = (rms_n <= threshold) return test_passed, message class TestSineOsc(AmyTest): def run(self): amy.send(time=0, osc=0, wave=amy.SINE, freq=1000) amy.send(time=100, vel=1) amy.send(time=500, vel=0) class TestPulseOsc(AmyTest): def run(self): amy.send(time=0, osc=0, wave=amy.PULSE, freq=1000) amy.send(time=100, vel=1) amy.send(time=500, vel=0) class TestSawDownOsc(AmyTest): def run(self): amy.send(time=0, osc=0, wave=amy.SAW_DOWN) amy.send(time=100, note=48, vel=1) amy.send(time=900, vel=0) class TestSawUpOsc(AmyTest): def run(self): amy.send(time=0, osc=0, wave=amy.SAW_UP) amy.send(time=100, note=46, vel=1) amy.send(time=500, vel=0) class TestTriangleOsc(AmyTest): def run(self): amy.send(time=0, osc=0, wave=amy.TRIANGLE, freq=1000) amy.send(time=100, vel=1) amy.send(time=500, vel=0) class TestNoiseOsc(AmyTest): def run(self): # If this is the first time noise is called, the waveform should be deterministic. amy.send(time=0, osc=0, wave=amy.NOISE, freq=1000) amy.send(time=100, vel=1) amy.send(time=500, vel=0) class TestPcm(AmyTest): def run(self): amy.send(time=0, osc=0, wave=amy.PCM, preset=1) amy.send(time=100, vel=1) class TestPcmShift(AmyTest): def run(self): amy.send(time=0, osc=0, wave=amy.PCM, preset=10) # Cowbell with no note should play at "default" pitch, midi 69 (for that preset) amy.send(time=100, vel=1) # Specifying a note should shift its pitch. amy.send(time=500, note=70, vel=1) class TestPcmPatchChange(AmyTest): """There was a bug where switching PCM preset would persist the base note of the preceding preset.""" def run(self): amy.send(time=0, osc=0, wave=amy.PCM, preset=9) # Clap amy.send(time=100, vel=1) amy.send(time=450, preset=10) # Cowbell amy.send(time=500, vel=1) class TestPcmLoop(AmyTest): def run(self): amy.send(time=0, osc=0, wave=amy.PCM, preset=10, feedback=1) amy.send(time=100, osc=0, vel=1) amy.send(time=500, osc=0, vel=0) class TestPcmLoopEnvFilt(AmyTest): """Check that filter, amp-env, and pitch mod apply to PCM.""" def run(self): amy.send(time=0, osc=0, wave=amy.PCM, preset=10, feedback=1) amy.send(time=0, osc=0, filter_type=amy.FILTER_LPF24, filter_freq='200,0,0,0,3', bp1='0,1,500,0,200,0') amy.send(time=0, osc=0, bp0='100,1,1000,0,1000,0') amy.send(time=0, osc=1, freq='1') amy.send(time=0, osc=0, mod_source=1, freq=',,,,,-0.2') amy.send(time=100, osc=0, note=64, vel=5) amy.send(time=500, osc=0, vel=0) class TestBuildYourOwnPartials(AmyTest): def run(self): # PARTIALS but you have to configure the freq and amp of each partial yourself num_partials = 16 base_freq = constants.ZERO_LOGFREQ_IN_HZ base_osc = 0 amy.send(time=0, osc=base_osc, wave=amy.BYO_PARTIALS, num_partials=num_partials, eg0='0,1,30000,0') for i in range(1, num_partials + 1): # Set up each partial as the corresponding harmonic of the base_freq, with an amplitude of 1/N, 50ms attack, and a decay of 1 sec / N # Note that "vel sentivity" in amp actually means "Sensitivity to parent osc amplitude", since it is passed down through a modified vel. amy.send(osc=base_osc + i, wave=amy.PARTIAL, freq=base_freq * i, eg0='50,1,%d,0,50,0' % (1000 // i), amp='%.2f,0,1,1' % (1.0 / i)) amy.send(time=100, osc=0, note=60, vel=0.5) amy.send(time=200, osc=0, note=72, vel=1) amy.send(time=800, osc=0, note=72, vel=0) class TestBYOPVoices(AmyTest): def run(self): # Does build-your-own-partials work with the voices mechanism? num_partials = 4 base_freq = constants.ZERO_LOGFREQ_IN_HZ s = 'v0w%dp%dZ' % (amy.BYO_PARTIALS, num_partials) + ''.join(['v%dw%dZ' % (i + 1, amy.PARTIAL) for i in range(num_partials)]) #amy.send(patchr=1024, patch_string=s) #amy.send(time=0, voices='0,1,2,3', patch=1024) amy.send(time=0, voices='0,1,2,3', patch_string=s) for i in range(num_partials): amy.send(voices='0,1,2,3', osc=i + 1, freq=base_freq * (i + 1), bp0='50,1,%d,0,50,0' % (600 // (i + 1))) amy.send(time=100, voices=0, note=60, vel=1) amy.send(time=200, voices=1, note=63, vel=1) amy.send(time=300, voices=2, note=67, vel=1) amy.send(time=400, voices=3, note=70, vel=1) class TestBYOPNoteOff(AmyTest): def run(self): # Partials were not seeing note-offs. num_partials = 8 base_freq = constants.ZERO_LOGFREQ_IN_HZ s = 'v0w%dp%dZ' % (amy.BYO_PARTIALS, num_partials) + ''.join(['v%dw%dZ' % (i + 1, amy.PARTIAL) for i in range(num_partials)]) amy.send(patch=1024, patch_string=s) amy.send(time=0, voices='0,1', patch=1024) for i in range(num_partials): amy.send(voices='0,1', osc=i + 1, freq=base_freq * (i + 1), bp0='50,1,%d,%f,200,0' % (1000 // (i + 1), 1 / (i + 1))) amy.send(voices='0,1', bp0='0,1,1000,0') # Parent osc env is slow release to be able to see partials. amy.send(time=100, voices=1, note=60, vel=1) amy.send(time=700, voices=1, vel=0) class TestInterpPartials(AmyTest): def run(self): # PARTIALS but each partial is interpolated from a table of pre-analyzed harmonic-sets. base_osc = 0 num_partials = 25 # Doesn't do anything? amy.send(time=0, osc=base_osc, wave=amy.INTERP_PARTIALS, preset=0, amp='1,0,0,0') for i in range(1, num_partials + 1): amy.send(osc=base_osc + i, wave=amy.PARTIAL, amp='1,0,1,1') amy.send(time=50, osc=0, note=60, vel=0.1) amy.send(time=300, osc=0, note=67, vel=0.6) amy.send(time=550, osc=0, note=72, vel=1) amy.send(time=800, osc=0, vel=0) class TestInterpPartialsRetrigger(AmyTest): def run(self): base_osc = 0 num_partials = 20 amy.send(time=0, osc=base_osc, wave=amy.INTERP_PARTIALS, preset=0, amp='1,0,0,0') for i in range(1, num_partials + 1): amy.send(osc=base_osc + i, wave=amy.PARTIAL) amy.send(time=50, osc=0, note=52, vel=0.7) amy.send(time=200, osc=0, note=52, vel=0.8) amy.send(time=350, osc=0, note=52, vel=0.9) amy.send(time=500, osc=0, vel=0) amy.send(time=510, osc=100, wave=amy.SINE, bp0='3,1,500,0,50,0') amy.send(time=550, osc=100, note=76, vel=1) amy.send(time=700, osc=100, note=76, vel=1) amy.send(time=850, osc=100, vel=0) class TestSineEnv(AmyTest): def run(self): amy.send(time=0, osc=0, wave=amy.SINE, freq=1000) amy.send(time=0, osc=0, amp='1,0,1,1,0,0', bp0='50,1,200,0.1,50,0') amy.send(time=100, vel=.85) amy.send(time=500, vel=0) class TestSineEnv2(AmyTest): def run(self): amy.send(time=0, osc=0, wave=amy.SINE, freq=1000) amy.send(time=0, osc=0, amp='1.0,0,1,1,0,0', bp0='0,0,200,5,200,0,0,0') amy.send(time=100, vel=1) amy.send(time=500, vel=0) # The DX7 algo is weird - attack is different from decay, envelope is clipped to 1. amy.send(time=500, osc=0, eg0_type=amy.ENVELOPE_DX7) amy.send(time=550, vel=1) amy.send(time=950, vel=0) class TestSineAM(AmyTest): """Amplitude modulation was messed up by log-combination amp.""" def run(self): amy.send(time=0, osc=1, wave=amy.SINE, freq=5) amy.send(time=0, osc=0, wave=amy.SINE, freq=1000, mod_source=1, amp='1,0,0,0,0,0.05') amy.send(time=100, vel=1) # Needed to wake up osc, even though vel value is ignored amy.send(time=500, vel=0) # Will not turn off osc since vel value is ignored / eg0 not engaged. amy.send(time=600, amp=0) # Should silence osc. amy.send(time=800, amp=1) # osc ready to go, but will still wait for nonzero vel note-on class TestAlgo(AmyTest): def run(self): amy.send(time=0, voices="0", patch=21+128) amy.send(time=100, voices="0", note=58, vel=1) amy.send(time=500, voices="0", vel=0) class TestAlgo2(AmyTest): def run(self): amy.send(time=0, volume=0.5) # To counteract vel=2 without rewriting ref. amy.send(time=0, voices="0", patch=128+24) amy.send(time=100, voices="0", note=58, vel=2) amy.send(time=500, voices="0", vel=0) class TestWoodPiano(AmyTest): """Test 4-op FM voice to check unassigned voices behave OK.""" def run(self): # The four-op WOOD PIANO patch amy.send(time=0, synth=1, num_voices=6, oscs_per_voice=5) amy.send(time=0, synth=1, osc=4, wave=amy.SINE, ratio=1, bp0='10,1,1000,0.8,100,0', amp='0.4,0,0,1', eg0_type=2, phase=0) amy.send(time=0, synth=1, osc=3, wave=amy.SINE, ratio=0.5, bp0='0,1,1000,0,100,0', amp='1,0,0,1', eg0_type=2, phase=0) amy.send(time=0, synth=1, osc=2, wave=amy.SINE, ratio=1, bp0='0,1,300,0.5,500,0.3,1000,0', amp='0.8,0,0,1,0,0', eg0_type=2, phase=0) amy.send(time=0, synth=1, osc=1, wave=amy.SINE, ratio=0.495, bp0='0,1,2000,0,300,0', amp='1,0,0,1,0,0', eg0_type=2, phase=0) # Osc 0 amp envelope is just to avoid truncating the FM output. amy.send(time=0, synth=1, osc=0, wave=amy.ALGO, algorithm=2, algo_source=',,4,3,2,1', bp0='0,1,1000,1,300,0', amp='4,0,1,1', freq='220,1,0,0,0,0') # Notes amy.send(time=100, synth=1, note=48, vel=1) amy.send(time=350, synth=1, note=48, vel=0) amy.send(time=400, synth=1, note=48, vel=1) amy.send(time=650, synth=1, note=48, vel=0) amy.send(time=700, synth=1, note=58, vel=1) amy.send(time=800, synth=1, note=58, vel=0) amy.send(time=800, synth=1, note=60, vel=1) amy.send(time=900, synth=1, note=60, vel=0) class TestFMRepeat(AmyTest): """Douglas reports that the DX7 Marimba sometimes clicks at onset.""" def run(self): amy.send(time=0, voices="0", patch=128+21) for i in range(5): t = 100 + round(i * 51200 / 441) amy.send(time=t, voices="0", note=32, vel=1) amy.send(time=t + 20, voices="0", vel=0) class TestXanaduFM(AmyTest): """The Xanadu custom FM voice stopped working.""" def run(self): amy.send(volume=100) #amy.send(time=0, osc=3, wave=amy.SINE, freq=1/7.5, phase=0.75, amp=.99) amy.send(time=0, osc=2, wave=amy.SINE, ratio=1, amp='0.5,0,0,0,0,0') #, mod_source=3) amy.send(time=0, osc=1, wave=amy.SINE, ratio=1, amp='1,0,0,1', bp0='1000,1,1000,0') amy.send(time=0, osc=0, wave=amy.ALGO, algorithm=1, algo_source=',,,,2,1', bp0='0,1,1000,1,2000,0') amy.send(time=100, osc=0, note=49, vel=1) amy.send(time=450, osc=0, note=49, vel=0) amy.send(time=550, osc=0, note=49, vel=1) amy.send(time=900, osc=0, note=49, vel=0) class TestFilter(AmyTest): def run(self): amy.send(time=0, osc=0, wave=amy.SAW_DOWN, filter_type=amy.FILTER_LPF, resonance=8.0, filter_freq='300,0,0,0,3', bp1='0,1,800,0.1,50,0.0') amy.send(time=100, note=48, vel=1.0) amy.send(time=900, vel=0) class TestFilter24(AmyTest): def run(self): amy.send(time=0, osc=0, wave=amy.SAW_DOWN, filter_type=amy.FILTER_LPF24, resonance=8.0, filter_freq='300,0,0,0,3', bp1='0,1,800,0.1,50,0.0') amy.send(time=100, note=48, vel=1.0) amy.send(time=900, vel=0) class TestFilterLFO(AmyTest): def run(self): amy.send(time=0, osc=1, wave=amy.SINE, freq=6, amp=1.0) amy.send(time=0, osc=0, wave=amy.SAW_DOWN, filter_type=amy.FILTER_LPF, resonance=8.0, mod_source=1, filter_freq='400,0,0,0,3,0.5', bp1='0,1,500,0,100,0') amy.send(time=100, note=48, vel=1.0) amy.send(time=500, vel=0) class TestLFO(AmyTest): def run(self): # LFO mod used to be 1+x i.e. 0.9..1.1 #amy.send(time=0, osc=1, wave=amy.SINE, freq=4, amp=0.1) # With unit-per-octave scaling, that's approx log2(0.9) = -0.152, log2(1.1) = 0.138 amy.send(time=0, osc=1, wave=amy.SINE, freq=4, amp=0.138) amy.send(time=0, osc=0, wave=amy.SINE, mod_source=1, freq='0,1,0,0,0,1') amy.send(time=100, note=70, vel=1) amy.send(time=500, vel=0) class TestDuty(AmyTest): def run(self): amy.send(time=0, osc=0, wave=amy.PULSE, duty=0.1) amy.send(time=100, note=70, vel=1) amy.send(time=200, vel=0) amy.send(time=300, osc=0, wave=amy.PULSE, duty=0.9) amy.send(time=300, note=70, vel=1) amy.send(time=400, vel=0) class TestPWM(AmyTest): def run(self): amy.send(time=0, osc=0, wave=amy.PULSE, mod_source=1, duty='0.5,0,0,0,0,0.25') amy.send(time=0, osc=1, wave=amy.SINE, freq=4, amp=1) amy.send(time=100, note=70, vel=1) amy.send(time=500, vel=0) class TestGlobalEQ(AmyTest): def run(self): amy.send(time=0, eq="-10,10,3") amy.send(time=0, osc=0, wave=amy.SAW_UP) amy.send(time=100, note=46, vel=1) amy.send(time=500, vel=0) class TestChorus(AmyTest): def run(self): # Turn on chorus. amy.send(chorus=1) # Note from TestFilter. amy.send(time=0, osc=0, wave=amy.SAW_DOWN, filter_type=amy.FILTER_LPF, resonance=8.0, filter_freq='300,0,0,0,3', bp1='0,1,800,0.1,50,0.0') amy.send(time=100, note=48, vel=1.0) amy.send(time=900, vel=0) class TestBrass(AmyTest): """One of the Juno-6 patches, spelled out.""" def run(self): #amy.send(time=0, osc=0, wave=amy.SAW_UP, amp='0.85,0,1,1,0,0', freq='130.81,1,0,0,0,0', filter_type=amy.FILTER_LPF, # resonance=0.167, bp0='60,1,740,0.9,200,0', filter_freq='6000,0.5,0,0,1,0', # bp1='60,1,740,0.9,200,0') #amy.send(time=0, osc=0, wave=amy.SAW_UP, amp='0.85,0,1,1,0,0', freq='130.81,1,0,0,0,0', filter_type=amy.FILTER_LPF24, # resonance=0.167, bp0='60,1,340,0.3,200,0', filter_freq='2000,0.5,0,0,4,0', # bp1='60,1,340,0.3,200,0') osc_freq_str = str(constants.ZERO_LOGFREQ_IN_HZ / 2) amy.send(time=0, osc=1, wave=amy.SAW_UP, freq=osc_freq_str + ',1,0,0,0,0.02', amp='0.85,0,1,1,0,0', bp0='30,1,672,0.354,100,0', filter_type=amy.FILTER_LPF24, resonance=0.167, filter_freq='93.73,0.677,0,0,9.133,0', bp1='30,1,672,0.354,100,0', mod_source=2, ) # Osc 2 is LFO for vibrato amy.send(time=0, osc=2, wave=amy.SINE, freq=3, bp0='156,1.0,100,1.0,100,0') amy.send(time=100, osc=1, note=76, vel=1.0) amy.send(time=300, osc=1, vel=0) amy.send(time=600, osc=1, note=76, vel=1.0) amy.send(time=800, osc=1, vel=0) # 'filter_freq': '93.73,0.677,0,0,4.567,0', 'bp1': '30,1,672,0.354,232,0' class TestBrassAlt(AmyTest): """Reproduce TestBrass using the VCA on a SILENT osc.""" def run(self): osc_freq_str = str(constants.ZERO_LOGFREQ_IN_HZ / 2) # Osc 1 is waveform, with vibrato mod but no amp env amy.send(time=0, osc=1, wave=amy.SAW_UP, freq=osc_freq_str + ',1,0,0,0,0.02', amp='1,0,0,0,0,0', mod_source=2) # Osc 2 is LFO for vibrato amy.send(time=0, osc=2, wave=amy.SINE, freq=3, bp0='156,1.0,100,1.0,100,0') # Osc 0 is VCF and amplitude env amy.send(time=0, osc=0, wave=amy.SILENT, amp='0.85,0,1,1,0,0', bp0='30,1,672,0.354,100,0', filter_type=amy.FILTER_LPF24, resonance=0.167, filter_freq='93.73,0.677,0,0,9.133,0', bp1='30,1,672,0.354,100,0', mod_source=2, chained_osc=1) amy.send(time=100, osc=0, note=76, vel=1.0) amy.send(time=300, osc=0, vel=0) amy.send(time=600, osc=0, note=76, vel=1.0) amy.send(time=800, osc=0, vel=0) class TestBrass2(AmyTest): """Trying to catch the note-off thump.""" def run(self): osc_freq_str = str(constants.ZERO_LOGFREQ_IN_HZ / 2) amy.send(time=0, osc=0, wave=amy.SAW_UP, amp='0.85,0,1,1', freq=osc_freq_str + ',1', resonance=0.713, filter_type=amy.FILTER_LPF24, filter_freq='93.726,0.677,0,0,9.134', bp0='30,1,672,0.354,232,0', bp1='30,1,672,0.354,232,0') amy.send(time=100, osc=0, note=60, vel=1.0) amy.send(time=600, osc=0, vel=0) class TestGuitar(AmyTest): """Trying to catch the note-off zzzzzip.""" def run(self): base_freq_str = str(constants.ZERO_LOGFREQ_IN_HZ / 2) amy.send(time=0, osc=0, wave=amy.SAW_UP, amp='0.756,0,1,1', freq=base_freq_str + ',1', filter_freq='16.23,0.236,0,0,11.181', resonance=0.753, filter_type=amy.FILTER_LPF24, bp0='6,1,51,0.425,153,0', bp1='6,1,51,0.425,153,0') amy.send(time=100, osc=0, note=60, vel=4.0) amy.send(time=150, osc=0, vel=0) amy.send(time=500, osc=0, note=60, vel=4.0) amy.send(time=550, osc=0, vel=0) class TestBleep(AmyTest): """Test the tulip start-up beep.""" def run(self): amy.send(time=0, wave=amy.SINE, freq=220) amy.send(time=0, osc=0, pan=0.9, vel=1) amy.send(time=150, osc=0, pan=0.1, freq=440) amy.send(time=300, osc=0, pan=0.5, vel=0) class TestOverload(AmyTest): """Run the output very hot to check for clipping.""" def run(self): amy.send(time=0, osc=0, wave=amy.SAW_DOWN, filter_type=amy.FILTER_LPF, resonance=8.0, filter_freq='300,0,0,0,3', bp1='0,1,800,0.1,50,0.0') amy.send(time=0, eq="12") amy.send(time=0, chorus=1) amy.send(time=100, note=48, vel=8.0) amy.send(time=900, vel=0) class TestJunoPatch(AmyTest): """Known Juno patch.""" def run(self): # Also test the synth mechanism. amy.send(time=0, synth=1, num_voices=4, patch=20) amy.send(time=50, synth=1, note=48, vel=1) amy.send(time=150, synth=1, note=60, vel=1) amy.send(time=250, synth=1, note=63, vel=1) amy.send(time=350, synth=1, note=67, vel=1) amy.send(time=600, synth=1, note=48, vel=0) amy.send(time=700, synth=1, note=60, vel=0) amy.send(time=800, synth=1, note=63, vel=0) amy.send(time=900, synth=1, note=67, vel=0) class TestJunoClip(AmyTest): """Juno patch that clips.""" def run(self): amy.send(time=0, voices="0,1,2,3", patch=9) amy.send(time=50, voices="0", note=60, vel=1) amy.send(time=50, voices="1", note=57, vel=1) amy.send(time=50, voices="2", note=55, vel=1) amy.send(time=50, voices="3", note=52, vel=1) amy.send(time=800, voices="0", vel=0) amy.send(time=800, voices="1", vel=0) amy.send(time=800, voices="2", vel=0) amy.send(time=800, voices="3", vel=0) class TestLowVcf(AmyTest): """Weird fxpt warble when hitting fundamental.""" def run(self): amy.send(time=0, osc=0, wave=amy.SAW_DOWN, filter_type=amy.FILTER_LPF24, resonance=1.0, amp='0.85,0,1,1', filter_freq='161.28,0,0,0,5', bp0='0,1,0,0', bp1='0,1,600,0,1,0') amy.send(time=100, osc=0, note=48, vel=3) amy.send(time=800, osc=0, vel=0) class TestLowerVcf(AmyTest): """Top16 LPF24 has issues with cf below fundamental?""" def run(self): amy.send(time=0, osc=0, wave=amy.SAW_DOWN, filter_type=amy.FILTER_LPF24, resonance=4.0, amp='0.85,0,1,1', filter_freq='50,0,0,0,6', bp0='0,1,0,0', bp1='0,1,300,0,1,0') amy.send(time=100, osc=0, note=48, vel=3) amy.send(time=800, osc=0, vel=0) class TestFlutesEq(AmyTest): """VCF leaving almost pure sine + HPF2 -> noise, clicks?""" def run(self): amy.send(time=0, eq="-15,8,8") osc_args = {'time':0, 'wave':amy.SAW_UP, 'filter_type':amy.FILTER_LPF24, 'resonance':1.75, 'bp0':'200,1,9800,0,100,0', 'bp1':'200,1,9800,0,100,0', 'filter_freq':'242,0.323'} amy.send(osc=0, **osc_args) amy.send(osc=1, **osc_args) amy.send(osc=2, **osc_args) amy.send(time=100, osc=0, note=48, vel=0.5) amy.send(time=200, osc=1, note=52, vel=0.5) amy.send(time=300, osc=2, note=55, vel=0.5) amy.send(time=900, osc=0, vel=0) amy.send(time=900, osc=1, vel=0) amy.send(time=900, osc=2, vel=0) class TestOscBD(AmyTest): """Bass Drum as modulated sine-tone. amy.py:preset(5). """ def run(self): # Uses a 0.25Hz sine wave at 0.5 phase (going down) to modify frequency of another sine wave amy.send(time=0, osc=1, wave=amy.SINE, amp=1, freq=0.25, phase=0.5) # Sine waveform always starts at phase 0 after retrigger. amy.send(time=0, osc=0, wave=amy.SINE, phase=0, bp0="0,1,500,0,0,0", freq=str(constants.ZERO_LOGFREQ_IN_HZ) + ",1,0,0,0,2", mod_source=1) amy.send(time=100, osc=0, note=84, vel=1) amy.send(time=350, osc=0, note=84, vel=1) amy.send(time=600, osc=0, note=84, vel=1) class TestChainedOsc(AmyTest): """Two oscillators chained together behind a silent_osc.""" def run(self): # TestFilter but on Saw + subosc with same envelope. osc_freq_str = str(constants.ZERO_LOGFREQ_IN_HZ / 2) #amy.send(time=0, osc=0, wave=amy.SAW_DOWN, filter_type=amy.FILTER_LPF, resonance=8.0, filter_freq='300,0,0,0,3', bp1='0,1,800,0.1,50,0.0') #amy.send(time=0, osc=1, wave=amy.PULSE, filter_type=amy.FILTER_LPF, resonance=8.0, amp="0.2,0,1,1", freq="130.81,1", filter_freq='300,0,0,0,3', bp1='0,1,800,0.1,50,0.0') #amy.send(time=100, osc=0, note=48, vel=1.0) #amy.send(time=100, osc=1, note=48, vel=1.0) amy.send(time=0, osc=0, wave=amy.SILENT, filter_type=amy.FILTER_LPF, resonance=8.0, filter_freq='300,0,0,0,3', bp1='0,1,800,0.1,50,0.0', chained_osc=1) amy.send(time=0, osc=1, wave=amy.SAW_DOWN, chained_osc=2) amy.send(time=0, osc=2, wave=amy.PULSE, amp="0.2,0,1,1", freq=osc_freq_str + ',1,0,0,0,0,1') amy.send(time=100, osc=0, note=48, vel=1.0) #amy.send(time=100, osc=1, note=48, vel=1.0) amy.send(time=900, osc=0, vel=0) #amy.send(time=900, osc=1, vel=0) class TestJunoTrumpetPatch(AmyTest): """I'm hearing a click in the Juno Trumpet patch. Catch it.""" def run(self): amy.send(time=0, voices="0,1", patch=2) amy.send(time=50, voices="0", note=60, vel=1) amy.send(time=200, voices="0", vel=0) amy.send(time=300, voices="1", note=60, vel=1) amy.send(time=450, voices="1", vel=0) class TestJunoCheapTrumpetPatch(AmyTest): """Try out the 'cheap' LPF hack.""" def run(self): amy.send(time=0, voices="0,1", patch=2) amy.send(time=0, voices="0,1", filter_type=amy.FILTER_LPF) amy.send(time=50, voices="0", note=60, vel=1) amy.send(time=200, voices="0", vel=0) amy.send(time=300, voices="1", note=60, vel=1) amy.send(time=450, voices="1", vel=0) class TestFilterReleaseGlitch(AmyTest): """See https://github.com/shorepine/amy/issues/126.""" def run(self): amy.send(time=0, osc=0, wave=amy.SAW_DOWN, filter_type=amy.FILTER_LPF24, filter_freq='100,0,0,6') amy.send(time=100, note=64, vel=1) amy.send(time=500, vel=0) class TestPortamento(AmyTest): def run(self): amy.send(time=0, voices="0,1,2", patch=0) # Starting-point pitches... amy.send(time=50, voices="0", note=60, vel=1) amy.send(time=50, voices="1", note=64, vel=1) amy.send(time=50, voices="2", note=67, vel=1) # .. immediately start bending towards final pitches. amy.send(time=60, voices="0,1,2", osc=2, portamento=100) amy.send(time=60, voices="0,1,2", osc=3, portamento=100) amy.send(time=60, voices="0,1,2", osc=4, portamento=100) amy.send(time=60, voices="0", note=65) amy.send(time=60, voices="1", note=69) amy.send(time=60, voices="2", note=72) amy.send(time=800, voices="0,1,2", vel=0) class TestEcho(AmyTest): def run(self): amy.echo(level=0.5, delay_ms=200, feedback=0.7) amy.send(time=0, osc=0, bp0="0,1,200,0,0,0") amy.send(time=100, osc=0, note=48, vel=1) class TestEchoLPF(AmyTest): def run(self): amy.echo(level=0.5, delay_ms=200, feedback=0.7, filter_coef=0.9) amy.send(time=0, osc=0, wave=amy.SAW_DOWN, bp0="0,1,200,0,0,0") amy.send(time=100, osc=0, note=48, vel=1) class TestEchoHPF(AmyTest): def run(self): amy.echo(level=0.5, delay_ms=200, feedback=0.7, filter_coef=-0.9) amy.send(time=0, osc=0, wave=amy.SAW_DOWN, bp0="0,1,200,0,0,0") amy.send(time=100, osc=0, note=48, vel=1) class TestVoiceManagement(AmyTest): """The 'synth' structure manages a set of voices.""" def run(self): # Patch is bare sinewave oscillator but with a 100ms release. #amy.send(patch=1024, patch_string=amy.message(osc=0, wave=amy.SINE, bp0='0,1,1000,1,100,0')) #amy.send(time=10, synth=0, num_voices=3, patch=1024) patch_string = amy.message(osc=0, wave=amy.SINE, bp0='0,1,1000,0,100,0') amy.send(time=10, synth=0, num_voices=2, patch_string=patch_string) amy.send(time=100, synth=0, note=60, vel=1) amy.send(time=200, synth=0, note=72, vel=1) # Check if using the same string for a second synth reuses the same memory_patch (based on debug fprintfs). amy.send(time=200, synth=1, num_voices=1, patch_string=patch_string) amy.send(time=300, synth=1, note=84, vel=1) # We ran out of voices, this should steal the first one amy.send(time=400, synth=0, note=96, vel=1) # Stop one amy.send(time=500, synth=1, note=84, vel=0) # Stop all the rest - vel=0 without note= means all notes off. amy.send(time=600, synth=0, vel=0) class TestVoiceStealing(AmyTest): """There's a bug with the default 6 voices.""" def __init__(self): super().__init__() self.default_synths = True def run(self): # Default juno synth. amy.send(time=40, synth=1, note=60, vel=1) amy.send(time=120, synth=1, note=64, vel=1) amy.send(time=200, synth=1, note=67, vel=1) amy.send(time=280, synth=1, note=70, vel=1) amy.send(time=360, synth=1, note=72, vel=1) amy.send(time=440, synth=1, note=76, vel=1) amy.send(time=520, synth=1, note=79, vel=1) amy.send(time=600, synth=1, note=82, vel=1) amy.send(time=800, synth=1, note=60, vel=0) amy.send(time=820, synth=1, note=64, vel=0) amy.send(time=840, synth=1, note=67, vel=0) amy.send(time=860, synth=1, note=70, vel=0) amy.send(time=880, synth=1, note=72, vel=0) amy.send(time=900, synth=1, note=76, vel=0) amy.send(time=920, synth=1, note=79, vel=0) amy.send(time=940, synth=1, note=82, vel=0) # Sent spurious note-offs, just to check that error report works print("expect to see excess note-off for notes 64, 82, 99") amy.send(time=940, synth=1, note=64, vel=0) amy.send(time=940, synth=1, note=82, vel=0) amy.send(time=940, synth=1, note=99, vel=0) class TestVoiceStealDecay(AmyTest): """Issue #470 - voice stealing can cause clicks as note changes abruptly.""" def run(self): amy.send( synth=0, num_voices=2, patch_string=amy.message(osc=0, wave=amy.SINE, bp0='50,1,200,0.5,50,0'), ) amy.send(time=100, synth=0, note=40, vel=10) # voice 0 amy.send(time=200, synth=0, note=50, vel=2) # voice 1 amy.send(time=300, synth=0, note=60, vel=2) # Steal voice 0, big click at t=0.3 amy.send(time=400, synth=0, note=65, vel=2) # Steal voice 1 amy.send(time=500, synth=0, note=45, vel=10) # Steal voice 0 # Now add synth_delay amy.send(time=550, synth=0, synth_delay=50) amy.send(time=600, synth=0, note=70, vel=2) # Steal voice 1 amy.send(time=700, synth=0, note=75, vel=2) # Steal voice 0, but no big click (at t=0.75) amy.send(time=800, synth=0, note=80, vel=2) # Steal voice 1 amy.send(time=900, synth=0, vel=0) # All notes off class TestVoiceStealClick(AmyTest): """There are still clicks on voice stealing and it's not cool.""" def run(self): amy.send(time=0, synth=0, num_voices=1, oscs_per_voice=1) amy.send(time=0, synth=0, osc=0, wave=amy.SINE, bp0='0,0,100,1,200,0.8,500,0') # It's the filter being reset that's hurting us? amy.send(time=0, synth=0, osc=0, filter_type=amy.FILTER_LPF24, filter_freq='8000,0,0,0,0,0') # Send first chords amy.send(time=100, synth=0, note=60, vel=10) # Send second chords amy.send(time=500, synth=0, note=60, vel=10) # Notes off amy.send(time=800, synth=0, vel=0) class TestOwBassClick(AmyTest): """Hearing clicks on OwBass??. See https://github.com/shorepine/amy/issues/629. """ def run(self): amy.send(time=0, synth=0, num_voices=1, oscs_per_voice=4) # Ow Bass reproduced by hand on AMYboard Editor. amy.send(time=10, synth=0, osc=0, wave=amy.SILENT, amp='1,,1,1', freq=220, filter_freq='20,1,,,5.443', resonance=4.381, filter_type=amy.FILTER_LPF24, bp0='13,1,0,1,16,0', bp1='16,1,0,0.878,52,0', mod_source=1, chained_osc=2) amy.send(time=10, synth=0, osc=1, wave=amy.TRIANGLE, amp=',,0', freq='2.3,0,,,,,0', bp0='5,1,100,1,10000,0') amy.send(time=10, synth=0, osc=2, wave=amy.PULSE, amp='0.551,,0', freq=220, duty=0.697, chained_osc=3, mod_source=1) amy.send(time=10, synth=0, osc=3, wave=amy.SAW_UP, amp='0.551,,0', freq=110, mod_source=1) amy.send(time=10, eq='7,-3,-3', echo='M0,500,,0,0', chorus='0,320,0.5,0.5') # Rapid repeated notes. amy.send(time=100, synth=0, note=48, vel=1) amy.send(time=250, synth=0, note=48, vel=0) amy.send(time=350, synth=0, note=48, vel=1) amy.send(time=500, synth=0, note=48, vel=0) amy.send(time=600, synth=0, note=48, vel=1) amy.send(time=750, synth=0, note=48, vel=0) class TestMidiDrums(AmyTest): """Test MIDI drums on channel 10 via injection.""" def __init__(self): super().__init__() self.default_synths = True def run(self): # inject_midi args are (time, midi_event_chan, midi_note, midi_vel) amy.inject_midi(100, 0x99, 35, 100) # bass amy.inject_midi(400, 0x99, 35, 100) # bass amy.inject_midi(400, 0x99, 37, 100) # snare amy.inject_midi(700, 0x99, 37, 100) # snare amy.inject_midi(900, 0x89, 37, 100) # snare note off class TestDrumsVoiceStealing(AmyTest): """Drums ignore missing note offs, but should still notice excess note-offs.""" def __init__(self): super().__init__() self.default_synths = True def run(self): for i in range(14): amy.send(time=100 + i * 20, synth=10, note=40 + i // 2, vel=1) for i in range(14): amy.send(time=400 + i * 20, synth=10, note=40 + i // 2, vel=0) print("expect to see excess note-off for note 40") amy.send(time=900, synth=10, note=40, vel=0) class TestDefaultChan1Synth(AmyTest): """Test default setup of Juno synth on synth 1 (MIDI channel 1).""" def __init__(self): super().__init__() self.default_synths = True def run(self): amy.send(time=100, synth=1, note=60, vel=1) amy.send(time=300, synth=1, note=63, vel=1) amy.send(time=500, synth=1, note=67, vel=1) amy.send(time=700, synth=1, note=74, vel=1) amy.send(time=800, synth=1, note=60, vel=0) amy.send(time=850, synth=1, note=63, vel=0) amy.send(time=900, synth=1, note=67, vel=0) amy.send(time=950, synth=1, note=74, vel=0) class TestSynthProgChange(AmyTest): """Test switchting default synth to DX7, do oscs allocate OK?""" def __init__(self): super().__init__() self.default_synths = True def run(self): # DX7 first patch, uses 9 oscs/voice, num_voices is inherited from previous init. amy.send(time=0, synth=1, patch=128) amy.send(time=100, synth=1, note=60, vel=1) amy.send(time=300, synth=1, note=63, vel=1) amy.send(time=500, synth=1, note=67, vel=1) amy.send(time=700, synth=1, note=74, vel=1) amy.send(time=800, synth=1, note=60, vel=0) amy.send(time=850, synth=1, note=63, vel=0) amy.send(time=900, synth=1, note=67, vel=0) amy.send(time=950, synth=1, note=74, vel=0) class TestSynthDrums(AmyTest): """Test MIDI drums using synth-level note translation.""" def __init__(self): super().__init__() self.default_synths = True def run(self): amy.send(time=100, synth=10, note=35, vel=100/127) # bass amy.send(time=400, synth=10, note=35, vel=100/127) # bass amy.send(time=400, synth=10, note=37, vel=100/127) # snare amy.send(time=700, synth=10, note=37, vel=100/127) # snare amy.send(time=900, synth=10, note=37, vel=0) # snare note off - ignored with current setup. class TestSynthFlags(AmyTest): """Test setting up MIDI drums using synth_flags (alias). Slightly different waveform than TestSynthDrums because chorus is off.""" def run(self): # The default config is NOT set, set up MIDI drums on instrument 1 here. # synth_flags=3 means do MIDI drums note translation and ignore note-offs. amy.send(synth=1, synth_flags=3, num_voices=4, oscs_per_voice=1) amy.send(time=100, synth=1, note=35, vel=100/127) # bass amy.send(time=400, synth=1, note=35, vel=100/127) # bass amy.send(time=400, synth=1, note=37, vel=100/127) # snare amy.send(time=700, synth=1, note=37, vel=100/127) # snare amy.send(time=900, synth=1, note=37, vel=0) # snare note off - ignored with current setup. class TestDoubleNoteOff(AmyTest): """Test for bug where release restarts if a second note-off is received (#319).""" def run(self): amy.send(time=0, osc=0, wave=amy.SINE, bp0='0,1,100,1,1000,0') amy.send(time=100, osc=0, note=60, vel=1) amy.send(time=200, osc=0, vel=0) amy.send(time=600, osc=0, vel=0) class TestSustainPedal(AmyTest): """Test sustain pedal.""" def run(self): amy.send(time=0, reset=amy.RESET_SYNTHS) amy.send(time=0, synth=1, num_voices=4, patch=256) amy.send(time=50, synth=1, note=76, vel=1) amy.send(time=100, synth=1, note=76, vel=0) amy.send(time=150, synth=1, pedal=127) amy.send(time=250, synth=1, note=63, vel=1) amy.send(time=300, synth=1, note=63, vel=0) amy.send(time=450, synth=1, note=67, vel=1) amy.send(time=500, synth=1, note=67, vel=0) amy.send(time=650, synth=1, note=72, vel=1) # This note is held across the pedal release amy.send(time=750, synth=1, pedal=0) amy.send(time=900, synth=1, note=72, vel=0) class TestPatchFromEvents(AmyTest): """Test defining a patch from events with patch_number.""" def __init__(self): super().__init__() self.default_synths = True # So that the patch space is already partly populated. def run(self): osc_freq = constants.ZERO_LOGFREQ_IN_HZ / 2 amy.send(time=0, patch=1039, reset=amy.RESET_PATCH) amy.send(time=0, patch=1039, osc=0, wave=amy.SAW_DOWN, bp0='0,1,1000,0.1,200,0', chained_osc=1) amy.send(time=0, patch=1039, osc=1, wave=amy.SINE, freq=osc_freq, bp0='0,1,500,0,200,0') amy.send(time=0, synth=0, num_voices=4, patch=1039) amy.send(time=100, synth=0, note=60, vel=1) amy.send(time=300, synth=0, note=64, vel=1) amy.send(time=500, synth=0, note=67, vel=1) amy.send(time=800, synth=0, vel=0) class TestInvalidPatchNumber(AmyTest): """Test for crash with patch number out of range.""" def run(self): patch = 25 osc_freq = constants.ZERO_LOGFREQ_IN_HZ / 2 print("expect to see 'patch number %d is out of range' twice" % patch) amy.send(time=0, patch=patch, osc=0, wave=amy.SAW_DOWN, bp0='0,1,1000,0.1,200,0', chained_osc=1) amy.send(time=0, patch=patch, osc=1, wave=amy.SINE, freq=osc_freq, bp0='0,1,500,0,200,0') amy.send(time=0, synth=0, num_voices=4, patch=patch) amy.send(time=100, synth=0, note=60, vel=1) amy.send(time=300, synth=0, note=64, vel=1) amy.send(time=500, synth=0, note=67, vel=1) amy.send(time=800, synth=0, vel=0) class TestBreakpointsRealloc(AmyTest): """A default osc has only 8 breakpoints, but it should realloc to 24 if you try to set a long bpset.""" def run(self): amy.send(time=0, osc=0, wave=amy.SINE, bp0='100,1,100,0,100,1,100,0,100,1,100,0,100,1,100,0') amy.send(time=100, osc=0, note=60, vel=1) amy.send(time=900, osc=0, vel=0) class TestFileTransfer(AmyTest): def test(self): _amy.stop() _amy.start(0) payload = ''.join(random.choice(string.ascii_letters + string.digits) for _ in range(2048)) with tempfile.NamedTemporaryFile(mode='w', delete=True) as f: with tempfile.NamedTemporaryFile(mode='w+', delete=True) as g: f.write(payload) f.flush() os.fsync(f.fileno()) amy.transfer_file(f.name, g.name) amy.render(0.1) g.seek(0) transferred = g.read() if transferred != payload: is_ok = False message = 'transfer file contents mismatch' else: is_ok = True message = 'TestFileTransfer: ok' return is_ok, message class TestDiskSample(AmyTest): def run(self): amy.disk_sample('sounds/partial_sources/CL SHCI A3.wav', preset=1024, midinote=57) amy.send(time=50, osc=0, preset=1024, wave=amy.PCM_MIX, vel=2, note=57) class TestDiskSampleWithSilentGap(AmyTest): def run(self): amy.disk_sample('sounds/partial_sources/CL SHCI A3 with gap.wav', preset=1024, midinote=57) amy.send(time=50, osc=0, preset=1024, wave=amy.PCM_MIX, vel=2, note=63) class TestRestartFileSample(AmyTest): def run(self): amy.disk_sample('sounds/partial_sources/CL SHCI A3.wav', preset=1024, midinote=60) amy.send(time=50, osc=0, preset=1024, wave=amy.PCM_MIX, vel=2, note=72) amy.send(time=500, osc=0, preset=1024, wave=amy.PCM_MIX, vel=2, note=50) class TestDiskSampleStereo(AmyTest): def run(self): amy.disk_sample('sounds/220_440_stereo.wav', preset=1024, midinote=60) amy.disk_sample('sounds/220_440_stereo.wav', preset=1025, midinote=60) amy.send(time=50, osc=0, preset=1024, wave=amy.PCM_LEFT, pan=0, vel=1, note=60) amy.send(time=500, osc=1, preset=1025, wave=amy.PCM_RIGHT, pan=1, vel=1, note=60) class TestLoadSample(AmyTest): """amy.load_sample streams base64 chunks via send_raw -> amy_add_message (no sysex flag). Regression coverage for the parse.c transfer-routing guard: AUDIO transfers must route to parse_transfer_message even when amy_parsing_from_sysex is false, otherwise every chunk gets dropped as an "Unrecognized transfer-level command".""" def run(self): amy.load_sample('sounds/partial_sources/CL SHCI A3.wav', preset=1024, midinote=57) amy.send(time=50, osc=0, preset=1024, wave=amy.PCM_MIX, vel=2, note=57) class TestSample(AmyTest): def run(self): amy.start_sample(preset=1024,bus=1,max_frames=22050, midinote=60) amy.send(time=0, synth=1, num_voices=4, patch=20) amy.send(time=50, synth=1, note=48, vel=1) amy.send(time=150, synth=1, note=60, vel=1) amy.send(time=250, synth=1, note=63, vel=1) # notes off amy.send(time=400, synth=1, note=48, vel=0) amy.send(time=400, synth=1, note=60, vel=0) amy.send(time=400, synth=1, note=63, vel=0) # play a pitched up version amy.send(osc=116, time=400, preset=1024, wave=amy.PCM_MIX, vel=1, note=72) amy.send(osc=116, time=700, preset=1024, wave=amy.PCM_MIX, vel=2, note=84) class TestParamsInPatchCmd(AmyTest): def run(self): # Is it possible to *modify* a patch in the same command we install it? amy.send(time=0, synth=1, patch=0, num_voices=4, resonance=4) amy.send(time=50, synth=1, note=48, vel=1) amy.send(time=150, synth=1, note=60, vel=1) amy.send(time=250, synth=1, note=63, vel=1) # notes off amy.send(time=400, synth=1, note=48, vel=0) amy.send(time=400, synth=1, note=60, vel=0) amy.send(time=400, synth=1, note=63, vel=0) class TestHPFHighBaseFreq(AmyTest): def run(self): amy.send(time=0, synth=1, patch=0, num_voices=4) amy.send(time=10, synth=1, filter_type=amy.FILTER_HPF, filter_freq=1000) amy.send(time=50, synth=1, note=48, vel=10) amy.send(time=150, synth=1, note=60, vel=10) amy.send(time=250, synth=1, note=63, vel=10) # notes off amy.send(time=400, synth=1, note=48, vel=0) amy.send(time=400, synth=1, note=60, vel=0) amy.send(time=400, synth=1, note=63, vel=0) class TestWavetable(AmyTest): """Simple exercise of the wavetable oscillator, using default wavetable.""" def run(self): amy.send(time=0, osc=0, wave=amy.WAVETABLE, preset=0, duty='0.25,0,0,0,0.5', bp1='0,0,800,1,100,1', bp0='50,1,50,0') amy.send(time=50, note=50, vel=1) amy.send(time=850, vel=0) class TestCopyingSynthConfig(AmyTest): """Duplicates TestJunoPatch, but after copying synth 1 to synth 3.""" def __init__(self): super().__init__() self.default_synths = True def run(self): amy.render(1) # Let the system config commands play out, else get_synth_commands won't find anything commands = amy.get_synth_commands(synth=1, dest_synth=3, num_voices=4, time=0) #print(commands) amy.send_raw(commands) amy.send(time=1050, synth=3, note=48, vel=1) amy.send(time=1150, synth=3, note=60, vel=1) amy.send(time=1250, synth=3, note=63, vel=1) amy.send(time=1350, synth=3, note=67, vel=1) amy.send(time=1600, synth=3, note=48, vel=0) amy.send(time=1700, synth=3, note=60, vel=0) amy.send(time=1800, synth=3, note=63, vel=0) amy.send(time=1900, synth=3, note=67, vel=0) class TestGetSynthCommandsGetsMidiCcs(AmyTest): def test(self): _amy.stop() _amy.start(0) amy.send(time=0, synth=1, num_voices=4, oscs_per_voice=2) amy.send(time=0, synth=1, osc=0, wave=amy.SINE, freq=110, chained_osc=1) amy.send(time=0, synth=1, osc=1, wave=amy.SAW_UP, freq=500) amy.send_raw('i1ic5,0,0,10,0,hello') amy.send_raw('i1ic10,1,1,100,1,i%id%v') amy.render(1) # Let the events execute. commands = amy.get_synth_commands(1) expected = """v0f110.000c1T2X3Z v1w3f500.000Z V1.000x0.000,0.000,0.000M0.000,500.000,,0.000,0.000k0.000,320.000,0.500,0.500h0.000,0.850,0.500,3000.000Z ic5,0,0.000,10.000,0.000,helloZ ic10,1,1.000,100.000,1.000,i%id%vZ""" if commands != expected: is_ok = False message = 'TestGetSynthCommandsGetsMidiCcs: get_synth_commands mismatch: expected:\n++\n%s\n--\n;saw:\n++\n%s\n--;' % (expected, commands) else: is_ok = True message = 'TestGetSynthCommandsGetsMidiCcs : ok' return is_ok, message class TestClearMidiCCs(AmyTest): """Test that ic255 clears the MIDI CC settings.""" def test(self): _amy.stop() _amy.start(0) amy.send(time=0, synth=1, num_voices=4, oscs_per_voice=2) amy.send(time=0, synth=1, osc=0, wave=amy.SINE, freq=110, chained_osc=1) amy.send(time=0, synth=1, osc=1, wave=amy.SAW_UP, freq=500) amy.send_raw('i1ic5,0,0,10,0,hello') amy.send_raw('i1ic10,1,1,100,1,i%id%v') # Test that you can have other commands after the ic255 too. amy.send_raw('i1ic255v0f999') amy.render(1) # Let the events execute. commands = amy.get_synth_commands(1) expected = """v0f999.000c1T2X3Z v1w3f500.000Z V1.000x0.000,0.000,0.000M0.000,500.000,,0.000,0.000k0.000,320.000,0.500,0.500h0.000,0.850,0.500,3000.000Z""" if commands != expected: is_ok = False message = 'TestClearMidiCcs : get_synth_commands mismatch: expected:\n++\n%s\n--\n;saw:\n++\n%s\n--;' % (expected, commands) else: is_ok = True message = 'TestClearMidiCcs : ok' return is_ok, message class TestClearOneMidiCC(AmyTest): """Test that ic5 with no further args clears that MIDI CC.""" def test(self): _amy.stop() _amy.start(0) amy.send(time=0, synth=1, num_voices=4, oscs_per_voice=2) amy.send(time=0, synth=1, osc=0, wave=amy.SINE, freq=110, chained_osc=1) amy.send(time=0, synth=1, osc=1, wave=amy.SAW_UP, freq=500) amy.send_raw('i1ic5,0,0,10,0,hello') amy.send_raw('i1ic10,1,1,100,1,i%id%v') amy.send_raw('i1ic5v0f999') amy.render(1) # Let the events execute. commands = amy.get_synth_commands(1) expected = """v0f999.000c1T2X3Z v1w3f500.000Z V1.000x0.000,0.000,0.000M0.000,500.000,,0.000,0.000k0.000,320.000,0.500,0.500h0.000,0.850,0.500,3000.000Z ic10,1,1.000,100.000,1.000,i%id%vZ""" if commands != expected: is_ok = False message = 'TestClearOneMidiCC : get_synth_commands mismatch: expected:\n++\n%s\n--\n;saw:\n++\n%s\n--;' % (expected, commands) else: is_ok = True message = 'TestClearOneMidiCC : ok' return is_ok, message class TestResetOscs(AmyTest): """Test that setting the number of oscs per voice resets the oscs.""" def run(self): amy.send(time=0, synth=1, patch=0, num_voices=4) amy.send(time=10, synth=1, oscs_per_voice=5) # Should cause oscs to reset. amy.send(time=50, synth=1, note=48, vel=1) amy.send(time=400, synth=1, note=48, vel=0) class TestPreset257(AmyTest): """There was a bug in the setting of K257 (amyboard web editor baseline).""" def run(self): amy.send(time=0, synth=1, patch=257, num_voices=4) amy.send(time=100, synth=1, note=48, vel=1) amy.send(time=500, synth=1, vel=0) class TestChangeSustain(AmyTest): """Check that you can rewrite just the sustain level in an EG without rewriting it all.""" def run(self): amy.send(time=0, synth=1, patch=257, num_voices=4) amy.send(time=10, synth=1, bp0=',,,0.8', bp1=',,,0.8') amy.send(time=100, synth=1, note=48, vel=1) amy.send(time=500, synth=1, vel=0) def float_or_val(str, error_val=None): """Like float, but returns None if string doesn't parse.""" try: return float(str) except ValueError: return error_val class TestResetPreset(AmyTest): """Setting a synth to a patch should rewrite all the params even if it's the same patch.""" def run(self): amy.send(time=0, synth=1, patch=257, num_voices=4) amy.send(time=10, synth=1, bp0=',,,0.8', bp1=',,,0.8') amy.send(time=20, synth=1, patch=257) amy.send(time=100, synth=1, note=48, vel=1) amy.send(time=500, synth=1, vel=0) amy.send(time=750, synth=1, note=48, vel=1) amy.send(time=950, synth=1, vel=0) def main(argv): if len(argv) > 1 and argv[1] == 'quiet': quiet = True del argv[1] else: quiet = False if len(argv) > 1: # Override location of reference files. AmyTest.ref_dir = argv[1] do_all_tests = True oks = [] errors = [] if do_all_tests: for testClass in AmyTest.__subclasses__(): test_object = testClass() is_ok, message = test_object.test() if not quiet: print(message) if is_ok: oks.append(message) else: errors.append(message) else: #TestPcmShift().test() #TestChorus().test() #TestBleep().test() #TestBrass().test() #TestBrass2().test() #print(TestSineEnv().test()[1]) #TestSawDownOsc().test() print(TestGuitar().test()[1]) #TestFilter().test() #print(TestAlgo().test()[1]) #TestBleep().test() #TestChainedOsc().test() #TestJunoPatch().test() #TestJunoTrumpetPatch().test() #TestPcmLoop().test() #TestBYOPNoteOff().test() #TestInterpPartials().test() #TestVoiceStealing().test() #TestSustainPedal().test() #TestPatchFromEvents().test() #TestVoiceStealDecay().test() #TestRestartFileSample().test() #TestDiskSample().test() #print(TestFileTransfer().test()[1]) #print(TestVoiceStealClick().test()[1]) #print(TestOwBassClick().test()[1]) #print(TestXanaduFM().test()[1]) #print(TestInterpPartials().test()[1]) if not quiet: amy.send(debug=0) if errors: print(len(oks), "tests pass,", len(errors), "tests failed:") print('\n'.join(sorted(errors, key=lambda x: float_or_val(x.split(' ')[-2].split('=')[-1], error_val=1000), reverse=True))) sys.exit(1) else: print(len(oks), "tests pass") if __name__ == "__main__": main(sys.argv) ================================================ FILE: amy/timing.py ================================================ import sys import os import numpy as np import scipy.io.wavfile as wav import amy def wavread(filename): """Read in audio data from a wav file. Return d, sr.""" # Read in wav file. file_handle = open(filename, 'rb') samplerate, wave_data = wav.read(file_handle) # Normalize short ints to floats in range [-1..1). data = (wave_data.astype(np.float32)) / 32768.0 return data, samplerate def rms(samples): return np.sqrt(np.mean(samples ** 2)) def dB(level): return 20 * np.log10(level + 1e-5) class AmyTest: ref_dir = './tests/ref' test_dir = './tests/tst' def __init__(self): amy.restart() amy.send(reset=amy.RESET_TIMEBASE) # start from 0 def test(self): name = self.__class__.__name__ self.run() samples = amy.render(1.0) amy.write(samples, os.path.join(self.test_dir, name + '.wav')) rms_x = dB(rms(samples)) message = ('%-16s:' % name) + (' signal=%.1f dB' % rms_x) ref_file = os.path.join(self.ref_dir, name + '.wav') try: expected_samples, _ = wavread(ref_file) rms_n = dB(rms(samples - expected_samples)) message += (' err=%.1f dB' % rms_n) except FileNotFoundError: message += ' / Unable to read ' + ref_file print(message) class TestSineOsc(AmyTest): def run(self): amy.send(time=0, osc=0, wave=amy.SINE, freq=1000) amy.send(time=100, vel=1) amy.send(time=500, vel=0) class TestPulseOsc(AmyTest): def run(self): amy.send(time=0, osc=0, wave=amy.PULSE, freq=1000) amy.send(time=100, vel=1) amy.send(time=500, vel=0) class TestSawDownOsc(AmyTest): def run(self): amy.send(time=0, osc=0, wave=amy.SAW_DOWN) amy.send(time=100, note=48, vel=1) amy.send(time=900, vel=0) class TestSawUpOsc(AmyTest): def run(self): amy.send(time=0, osc=0, wave=amy.SAW_UP) amy.send(time=100, note=46, vel=1) amy.send(time=500, vel=0) class TestTriangleOsc(AmyTest): def run(self): amy.send(time=0, osc=0, wave=amy.TRIANGLE, freq=1000) amy.send(time=100, vel=1) amy.send(time=500, vel=0) class TestNoiseOsc(AmyTest): def run(self): # If this is the first time noise is called, the waveform should be deterministic. amy.send(time=0, osc=0, wave=amy.NOISE, freq=1000) amy.send(time=100, vel=1) amy.send(time=500, vel=0) class TestPcm(AmyTest): def run(self): amy.send(time=0, osc=0, wave=amy.PCM, preset=1) amy.send(time=100, vel=1) class TestPcmShift(AmyTest): def run(self): amy.send(time=0, osc=0, wave=amy.PCM, preset=10) # Cowbell with no note should play at "default" pitch, midi 69 (for that preset) amy.send(time=100, vel=1) # Specifying a note should shift its pitch. amy.send(time=500, note=70, vel=1) class TestSineEnv(AmyTest): def run(self): amy.send(time=0, osc=0, wave=amy.SINE, freq=1000) # amy.send(time=0, osc=0, bp0_target=amy.TARGET_AMP, bp0='50,1,250,0.1,50,0') amy.send(time=0, osc=0, amp='0,0,0.85,1,0,0', bp0='50,1,250,0.1,50,0') amy.send(time=100, vel=1) amy.send(time=500, vel=0) class TestFilter(AmyTest): def run(self): amy.send(time=0, osc=0, wave=amy.SAW_DOWN, filter_type=amy.FILTER_LPF, resonance=8.0, filter_freq='300,0,0,0,3', bp1='0,1,800,0.1,50,0.0') amy.send(time=100, note=48, vel=1.0) amy.send(time=900, vel=0) class TestFilterLFO(AmyTest): def run(self): amy.send(time=0, osc=1, wave=amy.SINE, freq=6, amp=1.0) amy.send(time=0, osc=0, wave=amy.SAW_DOWN, filter_type=amy.FILTER_LPF, resonance=8.0, mod_source=1, filter_freq='400,0,0,0,3,0.5', bp1='0,1,500,0,100,0') amy.send(time=100, note=48, vel=1.0) amy.send(time=500, vel=0) class TestLFO(AmyTest): def run(self): # LFO mod used to be 1+x i.e. 0.9..1.1 #amy.send(time=0, osc=1, wave=amy.SINE, freq=4, amp=0.1) # With unit-per-octave scaling, that's approx log2(0.9) = -0.152, log2(1.1) = 0.138 amy.send(time=0, osc=1, wave=amy.SINE, freq=4, amp=0.138) amy.send(time=0, osc=0, wave=amy.SINE, mod_source=1, mod_target=amy.TARGET_FREQ) amy.send(time=100, note=70, vel=1) amy.send(time=500, vel=0) class TestDuty(AmyTest): def run(self): amy.send(time=0, osc=0, wave=amy.PULSE, duty=0.1) amy.send(time=100, note=70, vel=1) amy.send(time=200, vel=0) amy.send(time=300, osc=0, wave=amy.PULSE, duty=0.9) amy.send(time=300, note=70, vel=1) amy.send(time=400, vel=0) class TestPWM(AmyTest): def run(self): amy.send(time=0, osc=0, wave=amy.PULSE, mod_source=1, duty='0.5,0,0,0,0,0.25') amy.send(time=0, osc=1, wave=amy.SINE, freq=4, amp=1) amy.send(time=100, note=70, vel=1) amy.send(time=500, vel=0) class TestGlobalEQ(AmyTest): def run(self): amy.send(time=0, eq_l=-10, eq_m=10, eq_h=3) amy.send(time=0, osc=0, wave=amy.SAW_UP) amy.send(time=100, note=46, vel=1) amy.send(time=500, vel=0) class TestChorus(AmyTest): def run(self): # Turn on chorus. amy.send(chorus=1) # Note from TestFilter. amy.send(time=0, osc=0, wave=amy.SAW_DOWN, filter_type=amy.FILTER_LPF, resonance=8.0, filter_freq='300,0,0,0,3', bp1='0,1,800,0.1,50,0.0') amy.send(time=100, note=48, vel=1.0) amy.send(time=900, vel=0) class TestBrass(AmyTest): """One of the Juno-6 patches, spelled out.""" def run(self): #amy.send(time=0, osc=0, wave=amy.SAW_UP, amp='0,0,0.85,1,0,0', freq='130.81,1,0,0,0,0', filter_type=amy.FILTER_LPF, # resonance=0.167, bp0='60,1,800,0.9,200,0', filter_freq='6000,0.5,0,0,1,0', # bp1='60,1,800,0.9,200,0') #amy.send(time=0, osc=0, wave=amy.SAW_UP, amp='0,0,0.85,1,0,0', freq='130.81,1,0,0,0,0', filter_type=amy.FILTER_LPF24, # resonance=0.167, bp0='60,1,400,0.3,200,0', filter_freq='2000,0.5,0,0,4,0', # bp1='60,1,400,0.3,200,0') amy.send(time=0, osc=1, wave=amy.SAW_UP, freq='130.81,1,0,0,0,0.0', amp='0,0,0.85,1,0,0', bp0='30,1,702,0.354,100,0', filter_type=amy.FILTER_LPF24, resonance=0.167, filter_freq='93.73,0.677,0,0,9.133,0', bp1='30,1,702,0.354,100,0', mod_source=2, ) amy.send(time=0, osc=2, wave=amy.SINE, freq=0.974, bp0='156,1.0,256,1.0,100,0') # amp='1,0,0,0,0,0') # amy.send(time=100, osc=1, note=76, vel=1.0) amy.send(time=300, osc=1, vel=0) amy.send(time=600, osc=1, note=76, vel=1.0) amy.send(time=800, osc=1, vel=0) # 'filter_freq': '93.73,0.677,0,0,4.567,0', 'bp1': '30,1,702,0.354,232,0' class TestBrass2(AmyTest): """Trying to catch the note-off thump.""" def run(self): amy.send(time=0, osc=0, wave=amy.SAW_UP, amp='0,0,0.85,1', freq='130.815,1', resonance=0.713, filter_type=amy.FILTER_LPF24, filter_freq='93.726,0.677,0,0,9.134', bp0='30,1,702,0.354,232,0', bp1='30,1,702,0.354,232,0') amy.send(time=100, osc=0, note=60, vel=1.0) amy.send(time=600, osc=0, vel=0) class TestGuitar(AmyTest): """Trying to catch the note-off zzzzzip.""" def run(self): amy.send(time=0, osc=0, wave=amy.SAW_UP, amp='0,0,0.756,1', freq='130.815,1', filter_freq='16.23,0.236,0,0,11.181', resonance=0.753, filter_type=amy.FILTER_LPF24, bp0='6,1,57,0.425,153,0', bp1='6,1,57,0.425,153,0') amy.send(time=100, osc=0, note=60, vel=4.0) amy.send(time=150, osc=0, vel=0) amy.send(time=500, osc=0, note=60, vel=4.0) amy.send(time=550, osc=0, vel=0) class TestBleep(AmyTest): """Test the tulip start-up beep.""" def run(self): amy.send(time=0, wave=amy.SINE, freq=220) amy.send(time=100, osc=0, pan=0.9, vel=1) amy.send(time=250, osc=0, pan=0.1, freq=440) amy.send(time=300, osc=0, pan=0.5, vel=0) class TestTiming(AmyTest): """Run LPF24 to see how it times.""" def run(self): osc_args = {"time":0, 'wave':amy.SAW_UP, 'filter_freq':'16,0,0,0,10', 'resonance':0.75, 'filter_type':amy.FILTER_LPF24, 'bp1':'3,1,200,0.5,200,0'} amy.send(osc=0, **osc_args) amy.send(osc=1, **osc_args) amy.send(osc=2, **osc_args) amy.send(osc=3, **osc_args) amy.send(osc=4, **osc_args) amy.send(time=50, osc=0, note=48, vel=1) amy.send(time=100, osc=1, note=51, vel=1) amy.send(time=150, osc=2, note=54, vel=1) amy.send(time=200, osc=3, note=57, vel=1) amy.send(time=250, osc=4, note=60, vel=1) amy.send(time=800, osc=0, vel=0) amy.send(time=820, osc=1, vel=0) amy.send(time=840, osc=2, vel=0) amy.send(time=860, osc=3, vel=0) amy.send(time=880, osc=4, vel=0) class TestJunoPatch(AmyTest): """Known Juno patch.""" def run(self): amy.send(time=0, voices="0,1,2,3", patch=20) amy.send(time=50, voices="0", note=48, vel=1) amy.send(time=50, voices="1", note=60, vel=1) amy.send(time=50, voices="2", note=63, vel=1) amy.send(time=50, voices="3", note=67, vel=1) amy.send(time=600, voices="0", vel=0) amy.send(time=600, voices="1", vel=0) amy.send(time=600, voices="2", vel=0) amy.send(time=600, voices="3", vel=0) class TestJunoPatch3(AmyTest): """Known Juno patch with parametric EQ.""" def run(self): amy.send(time=0, voices="0", patch=3) amy.send(time=50, voices="0", note=60, vel=1) amy.send(time=900, voices="0", vel=0) def main(argv): if len(argv) > 1: # Override location of reference files. AmyTest.ref_dir = argv[1] do_all_tests = False if do_all_tests: for testClass in AmyTest.__subclasses__(): test_object = testClass() test_object.test() else: #TestPcmShift().test() #TestChorus().test() #TestBleep().test() #TestBrass().test() #TestBrass2().test() #TestSineEnv().test() #TestSawDownOsc().test() #TestGuitar().test() #TestFilter().test() for _ in range(5): #TestTiming().test() TestJunoPatch3().test() amy.send(time=1001, debug=0) amy.render(0.01) print("tests done.") if __name__ == "__main__": main(sys.argv) ================================================ FILE: amy/wave.py ================================================ """Stuff to parse WAVE files. Usage. Reading WAVE files: f = wave.open(file, 'r') where file is either the name of a file or an open file pointer. The open file pointer must have methods read(), seek(), and close(). When the setpos() and rewind() methods are not used, the seek() method is not necessary. This returns an instance of a class with the following public methods: getnchannels() -- returns number of audio channels (1 for mono, 2 for stereo) getsampwidth() -- returns sample width in bytes getframerate() -- returns sampling frequency getnframes() -- returns number of audio frames getcomptype() -- returns compression type ('NONE' for linear samples) getcompname() -- returns human-readable version of compression type ('not compressed' linear samples) getparams() -- returns a namedtuple consisting of all of the above in the above order getmarkers() -- returns None (for compatibility with the aifc module) getmark(id) -- raises an error since the mark does not exist (for compatibility with the aifc module) readframes(n) -- returns at most n frames of audio rewind() -- rewind to the beginning of the audio stream setpos(pos) -- seek to the specified position tell() -- return the current position close() -- close the instance (make it unusable) The position returned by tell() and the position given to setpos() are compatible and have nothing to do with the actual position in the file. The close() method is called automatically when the class instance is destroyed. Writing WAVE files: f = wave.open(file, 'w') where file is either the name of a file or an open file pointer. The open file pointer must have methods write(), tell(), seek(), and close(). This returns an instance of a class with the following public methods: setnchannels(n) -- set the number of channels setsampwidth(n) -- set the sample width setframerate(n) -- set the frame rate setnframes(n) -- set the number of frames setcomptype(type, name) -- set the compression type and the human-readable compression type setparams(tuple) -- set all parameters at once tell() -- return current position in output file writeframesraw(data) -- write audio frames without pathing up the file header writeframes(data) -- write audio frames and patch up the file header close() -- patch up the file header and close the output file You should set the parameters before the first writeframesraw or writeframes. The total number of frames does not need to be set, but when it is set to the correct value, the header does not have to be patched up. It is best to first set all parameters, perhaps possibly the compression type, and then write audio frames using writeframesraw. When all frames have been written, either call writeframes('') or close() to patch up the sizes in the header. The close() method is called automatically when the class instance is destroyed. """ import builtins __all__ = ["open", "openfp", "Error"] class Error(Exception): pass WAVE_FORMAT_PCM = 0x0001 _array_fmts = None, 'b', 'h', None, 'i' #import audioop import struct import sys from collections import namedtuple # Vendored from CPython's chunk.py (removed in Python 3.13 by PEP 594). # Reads IFF-style chunks: 4-byte ID, 4-byte size, then `size` bytes of data. class Chunk: def __init__(self, file, align=True, bigendian=True, inclheader=False): self.closed = False self.align = align strflag = '>' if bigendian else '<' self.file = file self.chunkname = file.read(4) if len(self.chunkname) < 4: raise EOFError try: self.chunksize = struct.unpack_from(strflag + 'L', file.read(4))[0] except struct.error: raise EOFError if inclheader: self.chunksize = self.chunksize - 8 self.size_read = 0 try: self.offset = self.file.tell() except (AttributeError, OSError): self.seekable = False else: self.seekable = True def getname(self): return self.chunkname def getsize(self): return self.chunksize def close(self): if not self.closed: try: self.skip() finally: self.closed = True def isatty(self): if self.closed: raise ValueError("I/O operation on closed file") return False def seek(self, pos, whence=0): if self.closed: raise ValueError("I/O operation on closed file") if not self.seekable: raise OSError("cannot seek") if whence == 1: pos = pos + self.size_read elif whence == 2: pos = pos + self.chunksize if pos < 0 or pos > self.chunksize: raise RuntimeError self.file.seek(self.offset + pos, 0) self.size_read = pos def tell(self): if self.closed: raise ValueError("I/O operation on closed file") return self.size_read def read(self, size=-1): if self.closed: raise ValueError("I/O operation on closed file") if self.size_read >= self.chunksize: return b'' if size < 0: size = self.chunksize - self.size_read if size > self.chunksize - self.size_read: size = self.chunksize - self.size_read data = self.file.read(size) self.size_read = self.size_read + len(data) if (self.size_read == self.chunksize and self.align and (self.chunksize & 1)): dummy = self.file.read(1) self.size_read = self.size_read + len(dummy) return data def skip(self): if self.closed: raise ValueError("I/O operation on closed file") if self.seekable: try: n = self.chunksize - self.size_read if self.align and (self.chunksize & 1): n = n + 1 self.file.seek(n, 1) self.size_read = self.size_read + n return except OSError: pass while self.size_read < self.chunksize: n = min(8192, self.chunksize - self.size_read) dummy = self.read(n) if not dummy: raise EOFError _wave_params = namedtuple('_wave_params', 'nchannels sampwidth framerate nframes comptype compname') class Wave_read: """Variables used in this class: These variables are available to the user though appropriate methods of this class: _file -- the open file with methods read(), close(), and seek() set through the __init__() method _nchannels -- the number of audio channels available through the getnchannels() method _nframes -- the number of audio frames available through the getnframes() method _sampwidth -- the number of bytes per audio sample available through the getsampwidth() method _framerate -- the sampling frequency available through the getframerate() method _comptype -- the AIFF-C compression type ('NONE' if AIFF) available through the getcomptype() method _compname -- the human-readable AIFF-C compression type available through the getcomptype() method _soundpos -- the position in the audio stream available through the tell() method, set through the setpos() method These variables are used internally only: _fmt_chunk_read -- 1 iff the FMT chunk has been read _data_seek_needed -- 1 iff positioned correctly in audio file for readframes() _data_chunk -- instantiation of a chunk class for the DATA chunk _framesize -- size of one frame in the file """ def initfp(self, file): self._convert = None self._soundpos = 0 self._file = Chunk(file, bigendian = 0) if self._file.getname() != b'RIFF': raise Error('file does not start with RIFF id') if self._file.read(4) != b'WAVE': raise Error('not a WAVE file') self._fmt_chunk_read = 0 self._data_chunk = None while 1: self._data_seek_needed = 1 try: chunk = Chunk(self._file, bigendian = 0) except EOFError: break chunkname = chunk.getname() if chunkname == b'fmt ': self._read_fmt_chunk(chunk) self._fmt_chunk_read = 1 elif chunkname == b'data': if not self._fmt_chunk_read: raise Error('data chunk before fmt chunk') self._data_chunk = chunk self._nframes = chunk.chunksize // self._framesize self._data_seek_needed = 0 break elif chunkname == b'smpl': self._read_smpl_chunk(chunk) chunk.skip() if not self._fmt_chunk_read or not self._data_chunk: raise Error('fmt chunk and/or data chunk missing') def __init__(self, f): self._i_opened_the_file = None if isinstance(f, str): f = builtins.open(f, 'rb') self._i_opened_the_file = f # else, assume it is an open file object already try: self.initfp(f) except: if self._i_opened_the_file: f.close() raise def __del__(self): self.close() def __enter__(self): return self def __exit__(self, *args): self.close() # # User visible methods. # def getfp(self): return self._file def rewind(self): self._data_seek_needed = 1 self._soundpos = 0 def close(self): if self._i_opened_the_file: self._i_opened_the_file.close() self._i_opened_the_file = None self._file = None def tell(self): return self._soundpos def getnchannels(self): return self._nchannels def getnframes(self): return self._nframes def getsampwidth(self): return self._sampwidth def getframerate(self): return self._framerate def getcomptype(self): return self._comptype def getcompname(self): return self._compname def getparams(self): return _wave_params(self.getnchannels(), self.getsampwidth(), self.getframerate(), self.getnframes(), self.getcomptype(), self.getcompname()) def getmarkers(self): return None def getmark(self, id): raise Error('no marks') def setpos(self, pos): if pos < 0 or pos > self._nframes: raise Error('position not in range') self._soundpos = pos self._data_seek_needed = 1 def readframes(self, nframes): if self._data_seek_needed: self._data_chunk.seek(0, 0) pos = self._soundpos * self._framesize if pos: self._data_chunk.seek(pos, 0) self._data_seek_needed = 0 if nframes == 0: return b'' data = self._data_chunk.read(nframes * self._framesize) if self._sampwidth != 1 and sys.byteorder == 'big': data = audioop.byteswap(data, self._sampwidth) if self._convert and data: data = self._convert(data) self._soundpos = self._soundpos + len(data) // (self._nchannels * self._sampwidth) return data # # Internal methods. # def _read_smpl_chunk(self, chunk): _, _,_, self._midinote, _, _, _, self._loops, _ = struct.unpack('0): # read first loop _, _, self._loopstart, self._loopend = struct.unpack(' 4: raise Error('bad sample width') self._sampwidth = sampwidth def getsampwidth(self): if not self._sampwidth: raise Error('sample width not set') return self._sampwidth def setframerate(self, framerate): if self._datawritten: raise Error('cannot change parameters after starting to write') if framerate <= 0: raise Error('bad frame rate') self._framerate = int(round(framerate)) def getframerate(self): if not self._framerate: raise Error('frame rate not set') return self._framerate def setnframes(self, nframes): if self._datawritten: raise Error('cannot change parameters after starting to write') self._nframes = nframes def getnframes(self): return self._nframeswritten def setcomptype(self, comptype, compname): if self._datawritten: raise Error('cannot change parameters after starting to write') if comptype not in ('NONE',): raise Error('unsupported compression type') self._comptype = comptype self._compname = compname def getcomptype(self): return self._comptype def getcompname(self): return self._compname def setparams(self, params): nchannels, sampwidth, framerate, nframes, comptype, compname = params if self._datawritten: raise Error('cannot change parameters after starting to write') self.setnchannels(nchannels) self.setsampwidth(sampwidth) self.setframerate(framerate) self.setnframes(nframes) self.setcomptype(comptype, compname) def getparams(self): if not self._nchannels or not self._sampwidth or not self._framerate: raise Error('not all parameters set') return _wave_params(self._nchannels, self._sampwidth, self._framerate, self._nframes, self._comptype, self._compname) def setmark(self, id, pos, name): raise Error('setmark() not supported') def getmark(self, id): raise Error('no marks') def getmarkers(self): return None def tell(self): return self._nframeswritten def writeframesraw(self, data): if not isinstance(data, (bytes, bytearray)): data = memoryview(data).cast('B') self._ensure_header_written(len(data)) nframes = len(data) // (self._sampwidth * self._nchannels) if self._convert: data = self._convert(data) if self._sampwidth != 1 and sys.byteorder == 'big': data = audioop.byteswap(data, self._sampwidth) self._file.write(data) self._datawritten += len(data) self._nframeswritten = self._nframeswritten + nframes def writeframes(self, data): self.writeframesraw(data) if self._datalength != self._datawritten: self._patchheader() def close(self): if self._file: try: self._ensure_header_written(0) if self._datalength != self._datawritten: self._patchheader() self._file.flush() finally: self._file = None if self._i_opened_the_file: self._i_opened_the_file.close() self._i_opened_the_file = None # # Internal methods. # def _ensure_header_written(self, datasize): if not self._headerwritten: if not self._nchannels: raise Error('# channels not specified') if not self._sampwidth: raise Error('sample width not specified') if not self._framerate: raise Error('sampling rate not specified') self._write_header(datasize) def _write_header(self, initlength): assert not self._headerwritten self._file.write(b'RIFF') if not self._nframes: self._nframes = initlength // (self._nchannels * self._sampwidth) self._datalength = self._nframes * self._nchannels * self._sampwidth try: self._form_length_pos = self._file.tell() except (AttributeError, OSError): self._form_length_pos = None self._file.write(struct.pack('>> from amy import xanadu try: amy.live(playback_device_id=1) running_amyboard = False except: running_amyboard = True C0_FREQ = 440.0 / math.pow(2.0, 4 + 9/12) def pitch2freq(pitch): """Convert pitch in OCT.(STEP/100) to Hz.""" oct = math.floor(pitch) step = 100 * (pitch - oct) freq = C0_FREQ * math.pow(2.0, oct + step/12) return freq def pitch2note(pitch): """Convert pitch in OCT.(STEP/100) to midi.""" return int(round(12.0 * math.log2(pitch2freq(pitch) / C0_FREQ))) def shift_pitch(pitch, shift): """Shift a OCT.(STEP/100) pitch by shift (also OCT.STEP).""" oct = math.floor(pitch) step = 100 * (pitch - oct) s_oct = math.floor(shift) s_step = 100 * (shift - s_oct) final_step = step + s_step final_oct = oct + s_oct + (final_step // 12) final_step = final_step % 12 return final_oct + (final_step / 100) def amy_message_of_send_args(list_of_arg_dicts): """Convert a list of amy.send args into a message string.""" message = [] for arg_dict in list_of_arg_dicts: message.append(amy.message(**arg_dict)) return ''.join(message) def note1_patch(pan=0.5): """Return the setup string for note1 (guitar string).""" osc = 0 modosc = 1 message = [] return amy_message_of_send_args([ {'osc': modosc, 'wave': amy.SINE, 'freq': 5, 'amp': 0.005}, {'osc': osc, 'wave': amy.SAW_DOWN, 'freq': '440,1,0,0,0,1', 'mod_source': modosc, 'filter_freq': '200,0,0,0,4', 'filter_type': amy.FILTER_LPF24, 'resonance': 0.7, 'pan': pan}, {'osc': osc, 'bp0': '0,1,8000,0,100,0'}, {'osc': osc, 'bp1': '0,1,3000,0.1,100,0'}, ]) def note2_patch(pitch_dev=0.1, pan=0.5): """Return the setup string for note2 (guitar echo with pitch sigh).""" osc = 0 modosc = 1 return amy_message_of_send_args([ {'osc': modosc, 'wave': amy.SINE, 'freq': 0.1, 'phase': 0, 'amp': pitch_dev}, {'osc': osc, 'wave': amy.SAW_DOWN, 'freq': '440,1,0,0,0,-1', 'mod_source': modosc, 'filter_freq': '200,0,0,0,4', 'filter_type': amy.FILTER_LPF24, 'resonance': 0.7, 'pan': pan}, {'osc': osc, 'bp0': '0,1,8000,0,100,0'}, {'osc': osc, 'bp1': '0,1,3000,0.1,100,0'}, ]) def fm_note_patch(duration=7.5): """Patch for hand-made 2-operator FM note.""" return amy_message_of_send_args([ {'osc': 3, 'wave': amy.SINE, 'freq': '6.0,0.5', 'phase': 0.75, 'amp': 1}, {'osc': 2, 'wave': amy.SINE, 'ratio': 1, 'amp': '1.5,0,0,0.4,0,0.01', 'mod_source': 3, 'bp0': '4000,1,4000,0,1000,0'}, {'osc': 1, 'wave': amy.SINE, 'ratio': 1, 'amp': '1,0,0,1,', 'bp0': '0,0.1,1000,1,4000,0'}, {'osc': 0, 'wave': amy.ALGO, 'algorithm': 1, 'algo_source': ',,,,2,1', 'bp0': '0,1,1000,1,2000,0'}, ]) def synth_note_on(synth=0, note=60, vel=1, timestamp=0): amy.send(time=timestamp, synth=synth, note=note, vel=vel) def Note(pitch, vel=1.0, time=0, pitch_shift=0, second_delay=200, use_third=False): """Composite 'note' triggers up to 3 delayed instances.""" timestamp = time pitch += 1.0 # 1 octave up note = pitch2note(pitch) synth_note_on(0, note, vel, timestamp) if use_third: synth_note_on(1, pitch2note(shift_pitch(pitch, pitch_shift)), vel * 0.5, timestamp + second_delay) synth_note_on(2, pitch2note(pitch), vel * 0.25, timestamp + 2000) def NoteFM(pitch, vel=1.0, time=0, duration=8000): """Play a note on the FM voice.""" global synths synth_note_on(3, pitch2note(pitch), vel, time) # Note off synth_note_on(3, pitch2note(pitch), 0, time + duration) # Note off def broken_chord(base_pitch, intervals, start_time, **kwargs): """Emit a set of notes as a staggered chord.""" for index, interval in enumerate([0] + intervals): pitch = shift_pitch(base_pitch, interval) NoteFM(pitch - 1.0, 1, start_time) Note(pitch, 1, start_time + 100 * index, **kwargs) def xanadu_init(): amy.chorus(1) amy.send(synth=0, num_voices=6, patch_string=note1_patch()) amy.send(synth=1, num_voices=6, patch_string=note1_patch(pan=0.8)) amy.send(synth=2, num_voices=6, patch_string=note2_patch(pan=0.2)) amy.send(synth=3, num_voices=12, patch_string=fm_note_patch()) amy.send(volume=0.5) chords = [ # F#7addB chord on a guitar {'base_pitch': 4.06, 'intervals': [.07, 1.0, 1.04, 1.05, 1.10], 'start_time': 2000, 'pitch_shift': 0.029, 'second_delay': 1000, 'use_third' :True}, # D6add9 chord on a guitar {'base_pitch': 4.02, 'intervals': [.07, 1.0, 1.04, 0.09, 1.02], 'start_time': 9500}, # Bmajadd11 chord on a guitar {'base_pitch': 4.11, 'intervals': [.07, 1.0, 1.04, 2.00, 1.05], 'start_time': 17000}, # Amajadd9 chord on a guitar {'base_pitch': 4.09, 'intervals': [.07, 2.0, 1.04, 1.02, 1.07], 'start_time': 24500}, # Bmajadd11 chord on a guitar {'base_pitch': 4.11, 'intervals': [.07, 1.0, 1.04, 2.0, 1.05], 'start_time': 32000}, # Gmaj6 chord on a guitar {'base_pitch': 4.07, 'intervals': [.07, 1.0, 1.04, 2.04, 1.09], 'start_time': 39500}, # F#7addB chord on a guitar {'base_pitch': 5.06, 'intervals': [.07, 1.0, 1.04, 1.05, 1.10], 'start_time': 47000, 'pitch_shift': 0.029, 'second_delay': 1000, 'use_third': True}, ] amy.send(reset=amy.RESET_TIMEBASE) xanadu_init() chord_iterator = iter(chords) next_chord = next(chord_iterator) base_time = amy.millis() def loop(): global base_time, next_chord, chord_iterator time_ms = amy.millis() if next_chord and time_ms >= base_time + next_chord['start_time']: print(next_chord) broken_chord(**next_chord) try: next_chord = next(chord_iterator) except StopIteration: next_chord = None if not running_amyboard: # I think we are running in CPython AMY, so no-one is calling loop() for us. import time while next_chord: loop() time.sleep(0.02) # Do not edit. Set automatically by the knobs on AMYboard Online. _auto_generated_knobs = """ """ ================================================ FILE: daisy/Makefile ================================================ # Project Name TARGET = amy_daisy AMY = ${HOME}/github/shorepine/tulipcc/amy/src APP_TYPE=BOOT_SRAM OPT = -O3 # Sources CPP_SOURCES = amy_daisy.cpp C_SOURCES = ${AMY}/amy.c ${AMY}/oscillators.c ${AMY}/algorithms.c ${AMY}/envelope.c ${AMY}/examples.c ${AMY}/filters.c ${AMY}/pcm.c ${AMY}/custom.c ${AMY}/delay.c ${AMY}/log2_exp2.c ${AMY}/patches.c ${AMY}/api.c ${AMY}/sequencer.c ${AMY}/amy_midi.c ${AMY}/instrument.c ${AMY}/parse.c ${AMY}/transfer.c ${AMY}/interp_partials.c ${AMY}/midi_mappings.c C_INCLUDES += -I${AMY} -DAMY_DAISY -Wno-strict-aliasing -Wextra -Wno-unused-parameter -Wpointer-arith -Wno-float-conversion -Wno-missing-declarations # Library Locations LIBDAISY_DIR = ${HOME}/Desktop/DaisyExamples/libDaisy DAISYSP_DIR = ${HOME}/Desktop/DaisyExamples/DaisySP # Core location, and generic makefile. SYSTEM_FILES_DIR = $(LIBDAISY_DIR)/core include $(SYSTEM_FILES_DIR)/Makefile ================================================ FILE: daisy/amy_daisy.cpp ================================================ // amy_daisy.cpp // Core daisy function to run AMY on the Daisy hardware/firmware environment. #include "daisy_seed.h" #include "daisysp.h" extern "C" { #include "amy.h" #include "examples.h" extern void sequencer_check_and_fill(); } using namespace daisy; using namespace daisysp; DaisySeed hardware; MidiUartHandler midi; void AudioCallback(AudioHandle::InterleavingInputBuffer in, AudioHandle::InterleavingOutputBuffer out, size_t size) { amy_render(0, AMY_OSCS, 0); short int * block = amy_fill_buffer(); // Fill the block with samples. for(size_t i = 0; i < size; i += 2) { // Set the left and right outputs. out[i] = (block[i]/32767.0); out[i + 1] = (block[i+1]/32767.0); // Copy the inputs. amy_in_block[i] = (short int)(in[i] * 32767.0); amy_in_block[i + 1] = (short int)(in[i + 1] * 32767.0); } } void test_audio_in() { amy_event e = amy_default_event(); e.reset_osc = RESET_SYNTHS; amy_add_event(&e); e = amy_default_event(); e.osc = 80; e.wave = AUDIO_IN0; e.pan_coefs[COEF_CONST] = 0; e.velocity = 10.0f; amy_add_event(&e); e.osc = 81; e.wave = AUDIO_IN1; e.pan_coefs[COEF_CONST] = 1.0f; amy_add_event(&e); } void midi_polyphony(uint32_t start, uint16_t patch) { // Play mulitple notes via note-ons to MIDI channel 1. uint8_t data[3] = {0x90, 0x00, 0x7f}; uint8_t note = 40; for(uint8_t i=0;i<15;i++) { data[1] = note; amy_event_midi_message_received(data, 3, 0, start); start += 1000; note += 2; } } #define MAX_POLYPHONY 17 void event_polyphony(uint32_t start, uint16_t patch) { // Verify polyphony by directly configuring a lot of voices and playing them all at once. amy_event e = amy_default_event(); e.time = start; e.patch_number = patch; for (int i = 0; i < MAX_POLYPHONY; ++i) e.voices[i] = i; amy_add_event(&e); start += 250; uint8_t note = 40; for(uint8_t i=0;i> 2; dataPtr = inputsPtr + numInputs * 12; for (i of inputList) { // Write the AudioSampleFrame struct instance HEAPU32[k + 0] = i.length; HEAPU32[k + 1] = this.samplesPerChannel; HEAPU32[k + 2] = dataPtr; k += 3; // Marshal the input audio sample data for each audio channel of this input for (j of i) { HEAPF32.set(j, dataPtr>>2); dataPtr += bytesPerChannel; } } // Copy output audio descriptor structs to Wasm outputsPtr = dataPtr; k = outputsPtr >> 2; outputDataPtr = (dataPtr += numOutputs * 12) >> 2; for (i of outputList) { // Write the AudioSampleFrame struct instance HEAPU32[k + 0] = i.length; HEAPU32[k + 1] = this.samplesPerChannel; HEAPU32[k + 2] = dataPtr; k += 3; // Reserve space for the output data dataPtr += bytesPerChannel * i.length; } // Copy parameters descriptor structs and data to Wasm paramsPtr = dataPtr; k = paramsPtr >> 2; dataPtr += numParams * 8; for (i = 0; paramArray = parameters[i++];) { // Write the AudioParamFrame struct instance HEAPU32[k + 0] = paramArray.length; HEAPU32[k + 1] = dataPtr; k += 2; // Marshal the audio parameters array HEAPF32.set(paramArray, dataPtr>>2); dataPtr += paramArray.length*4; } // Call out to Wasm callback to perform audio processing if (didProduceAudio = this.callbackFunction(numInputs, inputsPtr, numOutputs, outputsPtr, numParams, paramsPtr, this.userData)) { // Read back the produced audio data to all outputs and their channels. // (A garbage-free function TypedArray.copy(dstTypedArray, dstOffset, // srcTypedArray, srcOffset, count) would sure be handy.. but web does // not have one, so manually copy all bytes in) for (i of outputList) { for (j of i) { for (k = 0; k < this.samplesPerChannel; ++k) { j[k] = HEAPF32[outputDataPtr++]; } } } } stackRestore(oldStackPtr); // Return 'true' to tell the browser to continue running this processor. // (Returning 1 or any other truthy value won't work in Chrome) return !!didProduceAudio; } } return WasmAudioWorkletProcessor; } // Specify a worklet processor that will be used to receive messages to this // AudioWorkletGlobalScope. We never connect this initial AudioWorkletProcessor // to the audio graph to do any audio processing. class BootstrapMessages extends AudioWorkletProcessor { constructor(arg) { super(); // Initialize the global Emscripten Module object that contains e.g. the // Wasm Module and Memory objects. After this we are ready to load in the // main application JS script, which the main thread will addModule() // to this scope. globalThis.Module = arg['processorOptions']; // Default runtime relies on an injected instantiateWasm() function to // initialize the Wasm Module. globalThis.Module['instantiateWasm'] = (info, receiveInstance) => { var instance = new WebAssembly.Instance(Module['wasm'], info); return receiveInstance(instance, Module['wasm']); }; // Listen to messages from the main thread. These messages will ask this // scope to create the real AudioWorkletProcessors that call out to Wasm to // do audio processing. let p = globalThis['messagePort'] = this.port; p.onmessage = async (msg) => { let d = msg.data; if (d['_wpn']) { // '_wpn' is short for 'Worklet Processor Node', using an identifier // that will never conflict with user messages // Instantiate the MODULARIZEd Module function, which is stored for us // under the special global name AudioWorkletModule in // MODULARIZE+AUDIO_WORKLET builds. if (globalThis.AudioWorkletModule) { // This populates the Module object with all the Wasm properties globalThis.Module = await AudioWorkletModule(Module); // We have now instantiated the Module function, can discard it from // global scope delete globalThis.AudioWorkletModule; } // Register a real AudioWorkletProcessor that will actually do audio processing. // 'ap' being the audio params registerProcessor(d['_wpn'], createWasmAudioWorkletProcessor(d['ap'])); // Post a Wasm Call message back telling that we have now registered the // AudioWorkletProcessor, and should trigger the user onSuccess callback // of the emscripten_create_wasm_audio_worklet_processor_async() call. // // '_wsc' is short for 'wasm call', using an identifier that will never // conflict with user messages // 'cb' the callback function // 'ch' the context handle // 'ud' the passed user data p.postMessage({'_wsc': d['cb'], 'x': [d['ch'], 1/*EM_TRUE*/, d['ud']] }); } else if (d['_wsc']) { var ptr = d['_wsc']; Module['wasmTable'].get(ptr)(...d['x']); }; } } // No-op, not doing audio processing in this processor. It is just for // receiving bootstrap messages. However browsers require it to still be // present. It should never be called because we never add a node to the graph // with this processor, although it does look like Chrome does still call this // function. process() { // keep this function a no-op. Chrome redundantly wants to call this even // though this processor is never added to the graph. } }; // Register the dummy processor that will just receive messages. registerProcessor('message', BootstrapMessages); ================================================ FILE: docs/amy.js ================================================ var amyModule=(()=>{var _scriptName=globalThis.document?.currentScript?.src;return async function(moduleArg={}){var moduleRtn;var Module=moduleArg;var ENVIRONMENT_IS_WASM_WORKER=globalThis.name=="em-ww";var ENVIRONMENT_IS_AUDIO_WORKLET=!!globalThis.AudioWorkletGlobalScope;if(ENVIRONMENT_IS_AUDIO_WORKLET)ENVIRONMENT_IS_WASM_WORKER=true;var ENVIRONMENT_IS_WEB=!!globalThis.window;var ENVIRONMENT_IS_WORKER=!!globalThis.WorkerGlobalScope;var ENVIRONMENT_IS_NODE=globalThis.process?.versions?.node&&globalThis.process?.type!="renderer";if(ENVIRONMENT_IS_NODE){var worker_threads=require("worker_threads");global.Worker=worker_threads.Worker;ENVIRONMENT_IS_WORKER=!worker_threads.isMainThread;ENVIRONMENT_IS_WASM_WORKER=ENVIRONMENT_IS_WORKER&&worker_threads["workerData"]=="em-ww"}var arguments_=[];var thisProgram="./this.program";var quit_=(status,toThrow)=>{throw toThrow};if(typeof __filename!="undefined"){_scriptName=__filename}else if(ENVIRONMENT_IS_WORKER){_scriptName=self.location.href}var scriptDirectory="";function locateFile(path){if(Module["locateFile"]){return Module["locateFile"](path,scriptDirectory)}return scriptDirectory+path}var readAsync,readBinary;if(ENVIRONMENT_IS_NODE){var fs=require("fs");scriptDirectory=__dirname+"/";readBinary=filename=>{filename=isFileURI(filename)?new URL(filename):filename;var ret=fs.readFileSync(filename);return ret};readAsync=async(filename,binary=true)=>{filename=isFileURI(filename)?new URL(filename):filename;var ret=fs.readFileSync(filename,binary?undefined:"utf8");return ret};if(process.argv.length>1){thisProgram=process.argv[1].replace(/\\/g,"/")}arguments_=process.argv.slice(2);quit_=(status,toThrow)=>{process.exitCode=status;throw toThrow}}else if(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER){try{scriptDirectory=new URL(".",_scriptName).href}catch{}{if(ENVIRONMENT_IS_WORKER){readBinary=url=>{var xhr=new XMLHttpRequest;xhr.open("GET",url,false);xhr.responseType="arraybuffer";xhr.send(null);return new Uint8Array(xhr.response)}}readAsync=async url=>{if(isFileURI(url)){return new Promise((resolve,reject)=>{var xhr=new XMLHttpRequest;xhr.open("GET",url,true);xhr.responseType="arraybuffer";xhr.onload=()=>{if(xhr.status==200||xhr.status==0&&xhr.response){resolve(xhr.response);return}reject(xhr.status)};xhr.onerror=reject;xhr.send(null)})}var response=await fetch(url,{credentials:"same-origin"});if(response.ok){return response.arrayBuffer()}throw new Error(response.status+" : "+response.url)}}}else{}var defaultPrint=console.log.bind(console);var defaultPrintErr=console.error.bind(console);if(ENVIRONMENT_IS_NODE){var utils=require("util");var stringify=a=>typeof a=="object"?utils.inspect(a):a;defaultPrint=(...args)=>fs.writeSync(1,args.map(stringify).join(" ")+"\n");defaultPrintErr=(...args)=>fs.writeSync(2,args.map(stringify).join(" ")+"\n")}var out=defaultPrint;var err=defaultPrintErr;var wasmBinary;var wasmModule;var ABORT=false;var EXITSTATUS;var isFileURI=filename=>filename.startsWith("file://");function growMemViews(){if(wasmMemory.buffer!=HEAP8.buffer){updateMemoryViews()}}var readyPromiseResolve,readyPromiseReject;if(ENVIRONMENT_IS_NODE&&ENVIRONMENT_IS_WASM_WORKER){var parentPort=worker_threads["parentPort"];parentPort.on("message",msg=>global.onmessage?.({data:msg}));Object.assign(globalThis,{self:global,postMessage:msg=>parentPort["postMessage"](msg)});process.on("uncaughtException",err=>{postMessage({cmd:"uncaughtException",error:err});process.exit(1)})}var wwParams;function startWasmWorker(props){wwParams=props;wasmMemory=props.wasmMemory;updateMemoryViews();wasmModule=props.wasm;createWasm();run();props.wasm=props.memMemory=0}if(ENVIRONMENT_IS_WASM_WORKER&&!ENVIRONMENT_IS_AUDIO_WORKLET){if(ENVIRONMENT_IS_NODE){var wrappedHandlers=new WeakMap;globalThis.onmessage=null;function wrapMsgHandler(h){var f=wrappedHandlers.get(h);if(!f){f=msg=>h({data:msg});wrappedHandlers.set(h,f)}return f}Object.assign(globalThis,{addEventListener:(name,handler)=>parentPort["on"](name,wrapMsgHandler(handler)),removeEventListener:(name,handler)=>parentPort["off"](name,wrapMsgHandler(handler))})}onmessage=d=>{onmessage=null;startWasmWorker(d.data)}}if(ENVIRONMENT_IS_AUDIO_WORKLET){function createWasmAudioWorkletProcessor(audioParams){class WasmAudioWorkletProcessor extends AudioWorkletProcessor{constructor(args){super();let opts=args.processorOptions;this.callback=(a1,a2,a3,a4,a5,a6,a7)=>dynCall_iiiiiiii(opts.callback,a1,a2,a3,a4,a5,a6,a7);this.userData=opts.userData;this.samplesPerChannel=opts.samplesPerChannel;this.bytesPerChannel=this.samplesPerChannel*4;this.outputViews=new Array(Math.min((wwParams.stackSize-16)/this.bytesPerChannel|0,64));this.createOutputViews()}createOutputViews(){var oldStackPtr=stackSave();var viewDataIdx=stackAlloc(this.outputViews.length*this.bytesPerChannel)>>2;for(var n=this.outputViews.length-1;n>=0;n--){this.outputViews[n]=(growMemViews(),HEAPF32).subarray(viewDataIdx,viewDataIdx+=this.samplesPerChannel)}stackRestore(oldStackPtr)}static get parameterDescriptors(){return audioParams}process(inputList,outputList,parameters){if((growMemViews(),HEAPF32).buffer!=this.outputViews[0].buffer){this.createOutputViews()}var numInputs=inputList.length;var numOutputs=outputList.length;var entry;var subentry;var stackMemoryStruct=(numInputs+numOutputs)*12;var stackMemoryData=0;for(entry of inputList){stackMemoryData+=entry.length}stackMemoryData*=this.bytesPerChannel;var outputViewsNeeded=0;for(entry of outputList){outputViewsNeeded+=entry.length}stackMemoryData+=outputViewsNeeded*this.bytesPerChannel;var numParams=0;for(entry in parameters){++numParams;stackMemoryStruct+=8;stackMemoryData+=parameters[entry].byteLength}var oldStackPtr=stackSave();var stackMemoryAligned=stackMemoryStruct+stackMemoryData+15&~15;var structPtr=stackAlloc(stackMemoryAligned);var dataPtr=structPtr+(stackMemoryAligned-stackMemoryData);var inputsPtr=structPtr;for(entry of inputList){(growMemViews(),HEAPU32)[structPtr>>2]=entry.length;(growMemViews(),HEAPU32)[structPtr+4>>2]=this.samplesPerChannel;(growMemViews(),HEAPU32)[structPtr+8>>2]=dataPtr;structPtr+=12;for(subentry of entry){(growMemViews(),HEAPF32).set(subentry,dataPtr>>2);dataPtr+=this.bytesPerChannel}}var paramsPtr=structPtr;for(entry=0;subentry=parameters[entry++];){(growMemViews(),HEAPU32)[structPtr>>2]=subentry.length;(growMemViews(),HEAPU32)[structPtr+4>>2]=dataPtr;structPtr+=8;(growMemViews(),HEAPF32).set(subentry,dataPtr>>2);dataPtr+=subentry.length*4}var outputsPtr=structPtr;for(entry of outputList){(growMemViews(),HEAPU32)[structPtr>>2]=entry.length;(growMemViews(),HEAPU32)[structPtr+4>>2]=this.samplesPerChannel;(growMemViews(),HEAPU32)[structPtr+8>>2]=dataPtr;structPtr+=12;dataPtr+=this.bytesPerChannel*entry.length}var didProduceAudio=this.callback(numInputs,inputsPtr,numOutputs,outputsPtr,numParams,paramsPtr,this.userData);if(didProduceAudio){for(entry of outputList){for(subentry of entry){subentry.set(this.outputViews[--outputViewsNeeded])}}}stackRestore(oldStackPtr);return!!didProduceAudio}}return WasmAudioWorkletProcessor}var port=globalThis.port||{};class BootstrapMessages extends AudioWorkletProcessor{constructor(arg){super();startWasmWorker(arg.processorOptions);if(!(port instanceof MessagePort)){this.port.onmessage=port.onmessage;port=this.port}}process(){}}registerProcessor("em-bootstrap",BootstrapMessages);port.onmessage=async msg=>{let d=msg.data;if(d["_boot"]){startWasmWorker(d)}else if(d["_wpn"]){registerProcessor(d["_wpn"],createWasmAudioWorkletProcessor(d.audioParams));port.postMessage({_wsc:d.callback,args:[d.contextHandle,1,d.userData]})}else if(d["_wsc"]){getWasmTableEntry(d["_wsc"])(...d.args)}}}var HEAP8,HEAPU8,HEAP16,HEAPU16,HEAP32,HEAPU32,HEAPF32,HEAPF64;var HEAP64,HEAPU64;var runtimeInitialized=false;function updateMemoryViews(){var b=wasmMemory.buffer;HEAP8=new Int8Array(b);HEAP16=new Int16Array(b);Module["HEAPU8"]=HEAPU8=new Uint8Array(b);HEAPU16=new Uint16Array(b);HEAP32=new Int32Array(b);HEAPU32=new Uint32Array(b);HEAPF32=new Float32Array(b);HEAPF64=new Float64Array(b);HEAP64=new BigInt64Array(b);HEAPU64=new BigUint64Array(b)}function initMemory(){if(ENVIRONMENT_IS_WASM_WORKER){return}if(Module["wasmMemory"]){wasmMemory=Module["wasmMemory"]}else{var INITIAL_MEMORY=Module["INITIAL_MEMORY"]||134217728;wasmMemory=new WebAssembly.Memory({initial:INITIAL_MEMORY/65536,maximum:32768,shared:true})}updateMemoryViews()}function preRun(){if(Module["preRun"]){if(typeof Module["preRun"]=="function")Module["preRun"]=[Module["preRun"]];while(Module["preRun"].length){addOnPreRun(Module["preRun"].shift())}}callRuntimeCallbacks(onPreRuns)}function initRuntime(){runtimeInitialized=true;if(ENVIRONMENT_IS_WASM_WORKER)return _wasmWorkerInitializeRuntime();wasmExports["D"]()}function postRun(){if(ENVIRONMENT_IS_WASM_WORKER){return}if(Module["postRun"]){if(typeof Module["postRun"]=="function")Module["postRun"]=[Module["postRun"]];while(Module["postRun"].length){addOnPostRun(Module["postRun"].shift())}}callRuntimeCallbacks(onPostRuns)}function abort(what){Module["onAbort"]?.(what);what="Aborted("+what+")";err(what);ABORT=true;what+=". Build with -sASSERTIONS for more info.";var e=new WebAssembly.RuntimeError(what);readyPromiseReject?.(e);throw e}var wasmBinaryFile;function findWasmBinary(){return locateFile("amy.wasm")}function getBinarySync(file){if(file==wasmBinaryFile&&wasmBinary){return new Uint8Array(wasmBinary)}if(readBinary){return readBinary(file)}throw"both async and sync fetching of the wasm failed"}async function getWasmBinary(binaryFile){if(!wasmBinary){try{var response=await readAsync(binaryFile);return new Uint8Array(response)}catch{}}return getBinarySync(binaryFile)}async function instantiateArrayBuffer(binaryFile,imports){try{var binary=await getWasmBinary(binaryFile);var instance=await WebAssembly.instantiate(binary,imports);return instance}catch(reason){err(`failed to asynchronously prepare wasm: ${reason}`);abort(reason)}}async function instantiateAsync(binary,binaryFile,imports){if(!binary&&!isFileURI(binaryFile)&&!ENVIRONMENT_IS_NODE){try{var response=fetch(binaryFile,{credentials:"same-origin"});var instantiationResult=await WebAssembly.instantiateStreaming(response,imports);return instantiationResult}catch(reason){err(`wasm streaming compile failed: ${reason}`);err("falling back to ArrayBuffer instantiation")}}return instantiateArrayBuffer(binaryFile,imports)}function getWasmImports(){assignWasmImports();var imports={a:wasmImports};return imports}async function createWasm(){function receiveInstance(instance,module){wasmExports=instance.exports;wasmExports=Asyncify.instrumentWasmExports(wasmExports);assignWasmExports(wasmExports);wasmModule=module;return wasmExports}function receiveInstantiationResult(result){return receiveInstance(result["instance"],result["module"])}var info=getWasmImports();if(Module["instantiateWasm"]){return new Promise((resolve,reject)=>{Module["instantiateWasm"](info,(inst,mod)=>{resolve(receiveInstance(inst,mod))})})}if(ENVIRONMENT_IS_WASM_WORKER){var instance=new WebAssembly.Instance(wasmModule,getWasmImports());return receiveInstance(instance,wasmModule)}wasmBinaryFile??=findWasmBinary();var result=await instantiateAsync(wasmBinary,wasmBinaryFile,info);var exports=receiveInstantiationResult(result);return exports}class ExitStatus{name="ExitStatus";constructor(status){this.message=`Program terminated with exit(${status})`;this.status=status}}var _wasmWorkerDelayedMessageQueue=[];var handleException=e=>{if(e instanceof ExitStatus||e=="unwind"){return EXITSTATUS}quit_(1,e)};var runtimeKeepaliveCounter=0;var keepRuntimeAlive=()=>noExitRuntime||runtimeKeepaliveCounter>0;var _proc_exit=code=>{EXITSTATUS=code;if(!keepRuntimeAlive()){Module["onExit"]?.(code);ABORT=true}quit_(code,new ExitStatus(code))};var exitJS=(status,implicit)=>{EXITSTATUS=status;_proc_exit(status)};var _exit=exitJS;var maybeExit=()=>{if(!keepRuntimeAlive()){try{_exit(EXITSTATUS)}catch(e){handleException(e)}}};var callUserCallback=func=>{if(ABORT){return}try{func();maybeExit()}catch(e){handleException(e)}};var wasmTableMirror=[];var getWasmTableEntry=funcPtr=>{var func=wasmTableMirror[funcPtr];if(!func){wasmTableMirror[funcPtr]=func=wasmTable.get(funcPtr)}return func};var _wasmWorkerRunPostMessage=e=>{let data=e.data;let wasmCall=data["_wsc"];wasmCall&&callUserCallback(()=>getWasmTableEntry(wasmCall)(...data["x"]))};var _wasmWorkerAppendToQueue=e=>{_wasmWorkerDelayedMessageQueue.push(e)};var _wasmWorkerInitializeRuntime=()=>{noExitRuntime=1;__emscripten_wasm_worker_initialize(wwParams.stackLowestAddress,wwParams.stackSize);__embind_initialize_bindings();if(!ENVIRONMENT_IS_AUDIO_WORKLET){removeEventListener("message",_wasmWorkerAppendToQueue);_wasmWorkerDelayedMessageQueue=_wasmWorkerDelayedMessageQueue.forEach(_wasmWorkerRunPostMessage);addEventListener("message",_wasmWorkerRunPostMessage)}};var callRuntimeCallbacks=callbacks=>{while(callbacks.length>0){callbacks.shift()(Module)}};var onPostRuns=[];var addOnPostRun=cb=>onPostRuns.push(cb);var onPreRuns=[];var addOnPreRun=cb=>onPreRuns.push(cb);var dynCalls={};var noExitRuntime=true;var stackRestore=val=>__emscripten_stack_restore(val);var stackSave=()=>_emscripten_stack_get_current();var wasmMemory;var UTF8Decoder=globalThis.TextDecoder&&new TextDecoder;var findStringEnd=(heapOrArray,idx,maxBytesToRead,ignoreNul)=>{var maxIdx=idx+maxBytesToRead;if(ignoreNul)return maxIdx;while(heapOrArray[idx]&&!(idx>=maxIdx))++idx;return idx};var UTF8ArrayToString=(heapOrArray,idx=0,maxBytesToRead,ignoreNul)=>{var endPtr=findStringEnd(heapOrArray,idx,maxBytesToRead,ignoreNul);if(endPtr-idx>16&&heapOrArray.buffer&&UTF8Decoder){return UTF8Decoder.decode(heapOrArray.buffer instanceof ArrayBuffer?heapOrArray.subarray(idx,endPtr):heapOrArray.slice(idx,endPtr))}var str="";while(idx>10,56320|ch&1023)}}return str};var UTF8ToString=(ptr,maxBytesToRead,ignoreNul)=>ptr?UTF8ArrayToString((growMemViews(),HEAPU8),ptr,maxBytesToRead,ignoreNul):"";var ___assert_fail=(condition,filename,line,func)=>abort(`Assertion failed: ${UTF8ToString(condition)}, at: `+[filename?UTF8ToString(filename):"unknown filename",line,func?UTF8ToString(func):"unknown function"]);var __abort_js=()=>abort("");var AsciiToString=ptr=>{var str="";while(1){var ch=(growMemViews(),HEAPU8)[ptr++];if(!ch)return str;str+=String.fromCharCode(ch)}};var awaitingDependencies={};var registeredTypes={};var typeDependencies={};var BindingError=class BindingError extends Error{constructor(message){super(message);this.name="BindingError"}};var throwBindingError=message=>{throw new BindingError(message)};function sharedRegisterType(rawType,registeredInstance,options={}){var name=registeredInstance.name;if(!rawType){throwBindingError(`type "${name}" must have a positive integer typeid pointer`)}if(registeredTypes.hasOwnProperty(rawType)){if(options.ignoreDuplicateRegistrations){return}else{throwBindingError(`Cannot register type '${name}' twice`)}}registeredTypes[rawType]=registeredInstance;delete typeDependencies[rawType];if(awaitingDependencies.hasOwnProperty(rawType)){var callbacks=awaitingDependencies[rawType];delete awaitingDependencies[rawType];callbacks.forEach(cb=>cb())}}function registerType(rawType,registeredInstance,options={}){return sharedRegisterType(rawType,registeredInstance,options)}var integerReadValueFromPointer=(name,width,signed)=>{switch(width){case 1:return signed?pointer=>(growMemViews(),HEAP8)[pointer]:pointer=>(growMemViews(),HEAPU8)[pointer];case 2:return signed?pointer=>(growMemViews(),HEAP16)[pointer>>1]:pointer=>(growMemViews(),HEAPU16)[pointer>>1];case 4:return signed?pointer=>(growMemViews(),HEAP32)[pointer>>2]:pointer=>(growMemViews(),HEAPU32)[pointer>>2];case 8:return signed?pointer=>(growMemViews(),HEAP64)[pointer>>3]:pointer=>(growMemViews(),HEAPU64)[pointer>>3];default:throw new TypeError(`invalid integer width (${width}): ${name}`)}};var __embind_register_bigint=(primitiveType,name,size,minRange,maxRange)=>{name=AsciiToString(name);const isUnsignedType=minRange===0n;let fromWireType=value=>value;if(isUnsignedType){const bitSize=size*8;fromWireType=value=>BigInt.asUintN(bitSize,value);maxRange=fromWireType(maxRange)}registerType(primitiveType,{name,fromWireType,toWireType:(destructors,value)=>{if(typeof value=="number"){value=BigInt(value)}return value},readValueFromPointer:integerReadValueFromPointer(name,size,!isUnsignedType),destructorFunction:null})};var __embind_register_bool=(rawType,name,trueValue,falseValue)=>{name=AsciiToString(name);registerType(rawType,{name,fromWireType:function(wt){return!!wt},toWireType:function(destructors,o){return o?trueValue:falseValue},readValueFromPointer:function(pointer){return this.fromWireType((growMemViews(),HEAPU8)[pointer])},destructorFunction:null})};var emval_freelist=[];var emval_handles=[0,1,,1,null,1,true,1,false,1];var __emval_decref=handle=>{if(handle>9&&0===--emval_handles[handle+1]){emval_handles[handle]=undefined;emval_freelist.push(handle)}};var Emval={toValue:handle=>{if(!handle){throwBindingError(`Cannot use deleted val. handle = ${handle}`)}return emval_handles[handle]},toHandle:value=>{switch(value){case undefined:return 2;case null:return 4;case true:return 6;case false:return 8;default:{const handle=emval_freelist.pop()||emval_handles.length;emval_handles[handle]=value;emval_handles[handle+1]=1;return handle}}}};function readPointer(pointer){return this.fromWireType((growMemViews(),HEAPU32)[pointer>>2])}var EmValType={name:"emscripten::val",fromWireType:handle=>{var rv=Emval.toValue(handle);__emval_decref(handle);return rv},toWireType:(destructors,value)=>Emval.toHandle(value),readValueFromPointer:readPointer,destructorFunction:null};var __embind_register_emval=rawType=>registerType(rawType,EmValType);var floatReadValueFromPointer=(name,width)=>{switch(width){case 4:return function(pointer){return this.fromWireType((growMemViews(),HEAPF32)[pointer>>2])};case 8:return function(pointer){return this.fromWireType((growMemViews(),HEAPF64)[pointer>>3])};default:throw new TypeError(`invalid float width (${width}): ${name}`)}};var __embind_register_float=(rawType,name,size)=>{name=AsciiToString(name);registerType(rawType,{name,fromWireType:value=>value,toWireType:(destructors,value)=>value,readValueFromPointer:floatReadValueFromPointer(name,size),destructorFunction:null})};var __embind_register_integer=(primitiveType,name,size,minRange,maxRange)=>{name=AsciiToString(name);const isUnsignedType=minRange===0;let fromWireType=value=>value;if(isUnsignedType){var bitshift=32-8*size;fromWireType=value=>value<>>bitshift;maxRange=fromWireType(maxRange)}registerType(primitiveType,{name,fromWireType,toWireType:(destructors,value)=>value,readValueFromPointer:integerReadValueFromPointer(name,size,minRange!==0),destructorFunction:null})};var __embind_register_memory_view=(rawType,dataTypeIndex,name)=>{var typeMapping=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array,BigInt64Array,BigUint64Array];var TA=typeMapping[dataTypeIndex];function decodeMemoryView(handle){var size=(growMemViews(),HEAPU32)[handle>>2];var data=(growMemViews(),HEAPU32)[handle+4>>2];return new TA((growMemViews(),HEAP8).buffer,data,size)}name=AsciiToString(name);registerType(rawType,{name,fromWireType:decodeMemoryView,readValueFromPointer:decodeMemoryView},{ignoreDuplicateRegistrations:true})};var stringToUTF8Array=(str,heap,outIdx,maxBytesToWrite)=>{if(!(maxBytesToWrite>0))return 0;var startIdx=outIdx;var endIdx=outIdx+maxBytesToWrite-1;for(var i=0;i=endIdx)break;heap[outIdx++]=u}else if(u<=2047){if(outIdx+1>=endIdx)break;heap[outIdx++]=192|u>>6;heap[outIdx++]=128|u&63}else if(u<=65535){if(outIdx+2>=endIdx)break;heap[outIdx++]=224|u>>12;heap[outIdx++]=128|u>>6&63;heap[outIdx++]=128|u&63}else{if(outIdx+3>=endIdx)break;heap[outIdx++]=240|u>>18;heap[outIdx++]=128|u>>12&63;heap[outIdx++]=128|u>>6&63;heap[outIdx++]=128|u&63;i++}}heap[outIdx]=0;return outIdx-startIdx};var stringToUTF8=(str,outPtr,maxBytesToWrite)=>stringToUTF8Array(str,(growMemViews(),HEAPU8),outPtr,maxBytesToWrite);var lengthBytesUTF8=str=>{var len=0;for(var i=0;i=55296&&c<=57343){len+=4;++i}else{len+=3}}return len};var __embind_register_std_string=(rawType,name)=>{name=AsciiToString(name);var stdStringIsUTF8=true;registerType(rawType,{name,fromWireType(value){var length=(growMemViews(),HEAPU32)[value>>2];var payload=value+4;var str;if(stdStringIsUTF8){str=UTF8ToString(payload,length,true)}else{str="";for(var i=0;i>2]=length;if(valueIsOfTypeString){if(stdStringIsUTF8){stringToUTF8(value,ptr,length+1)}else{for(var i=0;i255){_free(base);throwBindingError("String has UTF-16 code units that do not fit in 8 bits")}(growMemViews(),HEAPU8)[ptr+i]=charCode}}}else{(growMemViews(),HEAPU8).set(value,ptr)}if(destructors!==null){destructors.push(_free,base)}return base},readValueFromPointer:readPointer,destructorFunction(ptr){_free(ptr)}})};var UTF16Decoder=globalThis.TextDecoder?new TextDecoder("utf-16le"):undefined;var UTF16ToString=(ptr,maxBytesToRead,ignoreNul)=>{var idx=ptr>>1;var endIdx=findStringEnd((growMemViews(),HEAPU16),idx,maxBytesToRead/2,ignoreNul);if(endIdx-idx>16&&UTF16Decoder)return UTF16Decoder.decode((growMemViews(),HEAPU16).slice(idx,endIdx));var str="";for(var i=idx;i{maxBytesToWrite??=2147483647;if(maxBytesToWrite<2)return 0;maxBytesToWrite-=2;var startPtr=outPtr;var numCharsToWrite=maxBytesToWrite>1]=codeUnit;outPtr+=2}(growMemViews(),HEAP16)[outPtr>>1]=0;return outPtr-startPtr};var lengthBytesUTF16=str=>str.length*2;var UTF32ToString=(ptr,maxBytesToRead,ignoreNul)=>{var str="";var startIdx=ptr>>2;for(var i=0;!(i>=maxBytesToRead/4);i++){var utf32=(growMemViews(),HEAPU32)[startIdx+i];if(!utf32&&!ignoreNul)break;str+=String.fromCodePoint(utf32)}return str};var stringToUTF32=(str,outPtr,maxBytesToWrite)=>{maxBytesToWrite??=2147483647;if(maxBytesToWrite<4)return 0;var startPtr=outPtr;var endPtr=startPtr+maxBytesToWrite-4;for(var i=0;i65535){i++}(growMemViews(),HEAP32)[outPtr>>2]=codePoint;outPtr+=4;if(outPtr+4>endPtr)break}(growMemViews(),HEAP32)[outPtr>>2]=0;return outPtr-startPtr};var lengthBytesUTF32=str=>{var len=0;for(var i=0;i65535){i++}len+=4}return len};var __embind_register_std_wstring=(rawType,charSize,name)=>{name=AsciiToString(name);var decodeString,encodeString,lengthBytesUTF;if(charSize===2){decodeString=UTF16ToString;encodeString=stringToUTF16;lengthBytesUTF=lengthBytesUTF16}else{decodeString=UTF32ToString;encodeString=stringToUTF32;lengthBytesUTF=lengthBytesUTF32}registerType(rawType,{name,fromWireType:value=>{var length=(growMemViews(),HEAPU32)[value>>2];var str=decodeString(value+4,length*charSize,true);_free(value);return str},toWireType:(destructors,value)=>{if(!(typeof value=="string")){throwBindingError(`Cannot pass non-string to C++ string type ${name}`)}var length=lengthBytesUTF(value);var ptr=_malloc(4+length+charSize);(growMemViews(),HEAPU32)[ptr>>2]=length/charSize;encodeString(value,ptr+4,length+charSize);if(destructors!==null){destructors.push(_free,ptr)}return ptr},readValueFromPointer:readPointer,destructorFunction(ptr){_free(ptr)}})};var __embind_register_void=(rawType,name)=>{name=AsciiToString(name);registerType(rawType,{isVoid:true,name,fromWireType:()=>undefined,toWireType:(destructors,o)=>undefined})};var _emscripten_get_now;if(globalThis.performance&&performance.now){_emscripten_get_now=()=>performance.now()}else{_emscripten_get_now=Date.now}var nowIsMonotonic=!!globalThis.performance?.now;var INT53_MAX=9007199254740992;var INT53_MIN=-9007199254740992;var bigintToI53Checked=num=>numINT53_MAX?NaN:Number(num);var readEmAsmArgsArray=[];var readEmAsmArgs=(sigPtr,buf)=>{readEmAsmArgsArray.length=0;var ch;while(ch=(growMemViews(),HEAPU8)[sigPtr++]){var wide=ch!=105;wide&=ch!=112;buf+=wide&&buf%8?4:0;readEmAsmArgsArray.push(ch==112?(growMemViews(),HEAPU32)[buf>>2]:ch==106?(growMemViews(),HEAP64)[buf>>3]:ch==105?(growMemViews(),HEAP32)[buf>>2]:(growMemViews(),HEAPF64)[buf>>3]);buf+=wide?8:4}return readEmAsmArgsArray};var runEmAsmFunction=(code,sigPtr,argbuf)=>{var args=readEmAsmArgs(sigPtr,argbuf);return ASM_CONSTS[code](...args)};var _emscripten_asm_const_double=(code,sigPtr,argbuf)=>runEmAsmFunction(code,sigPtr,argbuf);var _emscripten_asm_const_int=(code,sigPtr,argbuf)=>runEmAsmFunction(code,sigPtr,argbuf);var _emscripten_set_main_loop_timing=(mode,value)=>{MainLoop.timingMode=mode;MainLoop.timingValue=value;if(!MainLoop.func){return 1}if(!MainLoop.running){MainLoop.running=true}if(mode==0){MainLoop.scheduler=function MainLoop_scheduler_setTimeout(){var timeUntilNextTick=Math.max(0,MainLoop.tickStartTime+value-_emscripten_get_now())|0;setTimeout(MainLoop.runner,timeUntilNextTick)};MainLoop.method="timeout"}else if(mode==1){MainLoop.scheduler=function MainLoop_scheduler_rAF(){MainLoop.requestAnimationFrame(MainLoop.runner)};MainLoop.method="rAF"}else if(mode==2){if(!MainLoop.setImmediate){if(globalThis.setImmediate){MainLoop.setImmediate=setImmediate}else{var setImmediates=[];var emscriptenMainLoopMessageId="setimmediate";var MainLoop_setImmediate_messageHandler=event=>{if(event.data===emscriptenMainLoopMessageId||event.data.target===emscriptenMainLoopMessageId){event.stopPropagation();setImmediates.shift()()}};addEventListener("message",MainLoop_setImmediate_messageHandler,true);MainLoop.setImmediate=func=>{setImmediates.push(func);if(ENVIRONMENT_IS_WORKER){Module["setImmediates"]??=[];Module["setImmediates"].push(func);postMessage({target:emscriptenMainLoopMessageId})}else postMessage(emscriptenMainLoopMessageId,"*")}}}MainLoop.scheduler=function MainLoop_scheduler_setImmediate(){MainLoop.setImmediate(MainLoop.runner)};MainLoop.method="immediate"}return 0};var setMainLoop=(iterFunc,fps,simulateInfiniteLoop,arg,noSetTiming)=>{MainLoop.func=iterFunc;MainLoop.arg=arg;var thisMainLoopId=MainLoop.currentlyRunningMainloop;function checkIsRunning(){if(thisMainLoopId0){var start=Date.now();var blocker=MainLoop.queue.shift();blocker.func(blocker.arg);if(MainLoop.remainingBlockers){var remaining=MainLoop.remainingBlockers;var next=remaining%1==0?remaining-1:Math.floor(remaining);if(blocker.counted){MainLoop.remainingBlockers=next}else{next=next+.5;MainLoop.remainingBlockers=(8*remaining+next)/9}}MainLoop.updateStatus();if(!checkIsRunning())return;setTimeout(MainLoop.runner,0);return}if(!checkIsRunning())return;MainLoop.currentFrameNumber=MainLoop.currentFrameNumber+1|0;if(MainLoop.timingMode==1&&MainLoop.timingValue>1&&MainLoop.currentFrameNumber%MainLoop.timingValue!=0){MainLoop.scheduler();return}else if(MainLoop.timingMode==0){MainLoop.tickStartTime=_emscripten_get_now()}MainLoop.runIter(iterFunc);if(!checkIsRunning())return;MainLoop.scheduler()};if(!noSetTiming){if(fps>0){_emscripten_set_main_loop_timing(0,1e3/fps)}else{_emscripten_set_main_loop_timing(1,1)}MainLoop.scheduler()}if(simulateInfiniteLoop){throw"unwind"}};var MainLoop={running:false,scheduler:null,method:"",currentlyRunningMainloop:0,func:null,arg:0,timingMode:0,timingValue:0,currentFrameNumber:0,queue:[],preMainLoop:[],postMainLoop:[],pause(){MainLoop.scheduler=null;MainLoop.currentlyRunningMainloop++},resume(){MainLoop.currentlyRunningMainloop++;var timingMode=MainLoop.timingMode;var timingValue=MainLoop.timingValue;var func=MainLoop.func;MainLoop.func=null;setMainLoop(func,0,false,MainLoop.arg,true);_emscripten_set_main_loop_timing(timingMode,timingValue);MainLoop.scheduler()},updateStatus(){if(Module["setStatus"]){var message=Module["statusMessage"]||"Please wait...";var remaining=MainLoop.remainingBlockers??0;var expected=MainLoop.expectedBlockers??0;if(remaining){if(remaining=MainLoop.nextRAF){MainLoop.nextRAF+=1e3/60}}var delay=Math.max(MainLoop.nextRAF-now,0);setTimeout(func,delay)},requestAnimationFrame(func){if(globalThis.requestAnimationFrame){requestAnimationFrame(func)}else{MainLoop.fakeRequestAnimationFrame(func)}}};var _emscripten_cancel_main_loop=()=>{MainLoop.pause();MainLoop.func=null};var emAudio={};var emAudioCounter=0;var emscriptenRegisterAudioObject=object=>{emAudio[++emAudioCounter]=object;return emAudioCounter};var emscriptenGetAudioObject=objectHandle=>emAudio[objectHandle];var _emscripten_create_audio_context=options=>{var ctx=window.AudioContext||window.webkitAudioContext;function readRenderSizeHint(val){return val<0?"hardware":val||"default"}var opts=options?{latencyHint:UTF8ToString((growMemViews(),HEAPU32)[options>>2])||undefined,sampleRate:(growMemViews(),HEAPU32)[options+4>>2]||undefined,renderSizeHint:readRenderSizeHint((growMemViews(),HEAP32)[options+8>>2])}:undefined;return ctx&&emscriptenRegisterAudioObject(new ctx(opts))};var emscriptenGetContextQuantumSize=contextHandle=>emAudio[contextHandle]["renderQuantumSize"]||128;var _emscripten_create_wasm_audio_worklet_node=(contextHandle,name,options,callback,userData)=>{function readChannelCountArray(heapIndex,numOutputs){if(!heapIndex)return undefined;heapIndex=heapIndex>>2;var channelCounts=[];while(numOutputs--)channelCounts.push((growMemViews(),HEAPU32)[heapIndex++]);return channelCounts}var optionsOutputs=options?(growMemViews(),HEAP32)[options+4>>2]:0;var opts=options?{numberOfInputs:(growMemViews(),HEAP32)[options>>2],numberOfOutputs:optionsOutputs,outputChannelCount:readChannelCountArray((growMemViews(),HEAPU32)[options+8>>2],optionsOutputs),channelCount:(growMemViews(),HEAPU32)[options+12>>2]||undefined,channelCountMode:[,"clamped-max","explicit"][(growMemViews(),HEAP32)[options+16>>2]],channelInterpretation:[,"discrete"][(growMemViews(),HEAP32)[options+20>>2]],processorOptions:{callback,userData,samplesPerChannel:emscriptenGetContextQuantumSize(contextHandle)}}:undefined;return emscriptenRegisterAudioObject(new AudioWorkletNode(emAudio[contextHandle],UTF8ToString(name),opts))};var _emscripten_create_wasm_audio_worklet_processor_async=(contextHandle,options,callback,userData)=>{var processorName=UTF8ToString((growMemViews(),HEAPU32)[options>>2]);var numAudioParams=(growMemViews(),HEAP32)[options+4>>2];var audioParamDescriptors=(growMemViews(),HEAPU32)[options+8>>2];var audioParams=[];var paramIndex=0;while(numAudioParams--){audioParams.push({name:paramIndex++,defaultValue:(growMemViews(),HEAPF32)[audioParamDescriptors>>2],minValue:(growMemViews(),HEAPF32)[audioParamDescriptors+4>>2],maxValue:(growMemViews(),HEAPF32)[audioParamDescriptors+8>>2],automationRate:((growMemViews(),HEAP32)[audioParamDescriptors+12>>2]?"k":"a")+"-rate"});audioParamDescriptors+=16}emAudio[contextHandle].audioWorklet["port"].postMessage({_wpn:processorName,audioParams,contextHandle,callback,userData})};var _emscripten_destroy_audio_context=contextHandle=>{emAudio[contextHandle].suspend();delete emAudio[contextHandle]};var _emscripten_destroy_web_audio_node=objectHandle=>{emAudio[objectHandle].disconnect();delete emAudio[objectHandle]};var getHeapMax=()=>2147483648;var alignMemory=(size,alignment)=>Math.ceil(size/alignment)*alignment;var growMemory=size=>{var oldHeapSize=wasmMemory.buffer.byteLength;var pages=(size-oldHeapSize+65535)/65536|0;try{wasmMemory.grow(pages);updateMemoryViews();return 1}catch(e){}};var _emscripten_resize_heap=requestedSize=>{var oldSize=(growMemViews(),HEAPU8).length;requestedSize>>>=0;if(requestedSize<=oldSize){return false}var maxHeapSize=getHeapMax();if(requestedSize>maxHeapSize){return false}for(var cutDown=1;cutDown<=4;cutDown*=2){var overGrownHeapSize=oldSize*(1+.2/cutDown);overGrownHeapSize=Math.min(overGrownHeapSize,requestedSize+100663296);var newSize=Math.min(maxHeapSize,alignMemory(Math.max(requestedSize,overGrownHeapSize),65536));var replacement=growMemory(newSize);if(replacement){return true}}return false};var _emscripten_set_main_loop=(func,fps,simulateInfiniteLoop)=>{var iterFunc=()=>dynCall_v(func);setMainLoop(iterFunc,fps,simulateInfiniteLoop)};var safeSetTimeout=(func,timeout)=>setTimeout(()=>{callUserCallback(func)},timeout);var _emscripten_sleep=ms=>Asyncify.handleSleep(wakeUp=>safeSetTimeout(wakeUp,ms));_emscripten_sleep.isAsync=true;var _wasmWorkersID=1;var _emAudioDispatchProcessorCallback=e=>{var data=e.data;var wasmCall=data["_wsc"];wasmCall&&getWasmTableEntry(wasmCall)(...data.args)};var stackAlloc=sz=>__emscripten_stack_alloc(sz);var _emscripten_start_wasm_audio_worklet_thread_async=(contextHandle,stackLowestAddress,stackSize,callback,userData)=>{var audioContext=emAudio[contextHandle];var audioWorklet=audioContext.audioWorklet;var audioWorkletCreationFailed=()=>{((a1,a2,a3)=>dynCall_viii(callback,a1,a2,a3))(contextHandle,0,userData)};if(!audioWorklet){return audioWorkletCreationFailed()}audioWorklet.addModule(locateFile("amy.js")).then(()=>{if(!audioWorklet["port"]){audioWorklet["port"]={postMessage:msg=>{if(msg["_boot"]){audioWorklet.bootstrapMessage=new AudioWorkletNode(audioContext,"em-bootstrap",{processorOptions:msg});audioWorklet.bootstrapMessage["port"].onmessage=msg=>{audioWorklet["port"].onmessage(msg)}}else{audioWorklet.bootstrapMessage["port"].postMessage(msg)}}}}audioWorklet["port"].postMessage({_boot:1,wwID:_wasmWorkersID++,wasm:wasmModule,wasmMemory,stackLowestAddress,stackSize});audioWorklet["port"].onmessage=_emAudioDispatchProcessorCallback;((a1,a2,a3)=>dynCall_viii(callback,a1,a2,a3))(contextHandle,1,userData)}).catch(audioWorkletCreationFailed)};var _fd_close=fd=>52;function _fd_seek(fd,offset,whence,newOffset){offset=bigintToI53Checked(offset);return 70}var printCharBuffers=[null,[],[]];var printChar=(stream,curr)=>{var buffer=printCharBuffers[stream];if(curr===0||curr===10){(stream===1?out:err)(UTF8ArrayToString(buffer));buffer.length=0}else{buffer.push(curr)}};var _fd_write=(fd,iov,iovcnt,pnum)=>{var num=0;for(var i=0;i>2];var len=(growMemViews(),HEAPU32)[iov+4>>2];iov+=8;for(var j=0;j>2]=num;return 0};var runAndAbortIfError=func=>{try{return func()}catch(e){abort(e)}};var runtimeKeepalivePush=()=>{runtimeKeepaliveCounter+=1};var runtimeKeepalivePop=()=>{runtimeKeepaliveCounter-=1};var Asyncify={instrumentWasmImports(imports){var importPattern=/^(invoke_.*|__asyncjs__.*)$/;for(let[x,original]of Object.entries(imports)){if(typeof original=="function"){let isAsyncifyImport=original.isAsync||importPattern.test(x)}}},instrumentFunction(original){var wrapper=(...args)=>{Asyncify.exportCallStack.push(original);try{return original(...args)}finally{if(!ABORT){var top=Asyncify.exportCallStack.pop();Asyncify.maybeStopUnwind()}}};Asyncify.funcWrappers.set(original,wrapper);return wrapper},instrumentWasmExports(exports){var ret={};for(let[x,original]of Object.entries(exports)){if(typeof original=="function"){var wrapper=Asyncify.instrumentFunction(original);ret[x]=wrapper}else{ret[x]=original}}return ret},State:{Normal:0,Unwinding:1,Rewinding:2,Disabled:3},state:0,StackSize:128e3,currData:null,handleSleepReturnValue:0,exportCallStack:[],callstackFuncToId:new Map,callStackIdToFunc:new Map,funcWrappers:new Map,callStackId:0,asyncPromiseHandlers:null,sleepCallbacks:[],getCallStackId(func){if(!Asyncify.callstackFuncToId.has(func)){var id=Asyncify.callStackId++;Asyncify.callstackFuncToId.set(func,id);Asyncify.callStackIdToFunc.set(id,func)}return Asyncify.callstackFuncToId.get(func)},maybeStopUnwind(){if(Asyncify.currData&&Asyncify.state===Asyncify.State.Unwinding&&Asyncify.exportCallStack.length===0){Asyncify.state=Asyncify.State.Normal;runAndAbortIfError(_asyncify_stop_unwind);if(typeof Fibers!="undefined"){Fibers.trampoline()}}},whenDone(){return new Promise((resolve,reject)=>{Asyncify.asyncPromiseHandlers={resolve,reject}})},allocateData(){var ptr=_malloc(12+Asyncify.StackSize);Asyncify.setDataHeader(ptr,ptr+12,Asyncify.StackSize);Asyncify.setDataRewindFunc(ptr);return ptr},setDataHeader(ptr,stack,stackSize){(growMemViews(),HEAPU32)[ptr>>2]=stack;(growMemViews(),HEAPU32)[ptr+4>>2]=stack+stackSize},setDataRewindFunc(ptr){var bottomOfCallStack=Asyncify.exportCallStack[0];var rewindId=Asyncify.getCallStackId(bottomOfCallStack);(growMemViews(),HEAP32)[ptr+8>>2]=rewindId},getDataRewindFunc(ptr){var id=(growMemViews(),HEAP32)[ptr+8>>2];var func=Asyncify.callStackIdToFunc.get(id);return func},doRewind(ptr){var original=Asyncify.getDataRewindFunc(ptr);var func=Asyncify.funcWrappers.get(original);return func()},handleSleep(startAsync){if(ABORT)return;if(Asyncify.state===Asyncify.State.Normal){var reachedCallback=false;var reachedAfterCallback=false;startAsync((handleSleepReturnValue=0)=>{if(ABORT)return;Asyncify.handleSleepReturnValue=handleSleepReturnValue;reachedCallback=true;if(!reachedAfterCallback){return}Asyncify.state=Asyncify.State.Rewinding;runAndAbortIfError(()=>_asyncify_start_rewind(Asyncify.currData));if(typeof MainLoop!="undefined"&&MainLoop.func){MainLoop.resume()}var asyncWasmReturnValue,isError=false;try{asyncWasmReturnValue=Asyncify.doRewind(Asyncify.currData)}catch(err){asyncWasmReturnValue=err;isError=true}var handled=false;if(!Asyncify.currData){var asyncPromiseHandlers=Asyncify.asyncPromiseHandlers;if(asyncPromiseHandlers){Asyncify.asyncPromiseHandlers=null;(isError?asyncPromiseHandlers.reject:asyncPromiseHandlers.resolve)(asyncWasmReturnValue);handled=true}}if(isError&&!handled){throw asyncWasmReturnValue}});reachedAfterCallback=true;if(!reachedCallback){Asyncify.state=Asyncify.State.Unwinding;Asyncify.currData=Asyncify.allocateData();if(typeof MainLoop!="undefined"&&MainLoop.func){MainLoop.pause()}runAndAbortIfError(()=>_asyncify_start_unwind(Asyncify.currData))}}else if(Asyncify.state===Asyncify.State.Rewinding){Asyncify.state=Asyncify.State.Normal;runAndAbortIfError(_asyncify_stop_rewind);_free(Asyncify.currData);Asyncify.currData=null;Asyncify.sleepCallbacks.forEach(callUserCallback)}else{abort(`invalid state: ${Asyncify.state}`)}return Asyncify.handleSleepReturnValue},handleAsync:startAsync=>Asyncify.handleSleep(wakeUp=>{startAsync().then(wakeUp)})};var getCFunc=ident=>{var func=Module["_"+ident];return func};var writeArrayToMemory=(array,buffer)=>{(growMemViews(),HEAP8).set(array,buffer)};var stringToUTF8OnStack=str=>{var size=lengthBytesUTF8(str)+1;var ret=stackAlloc(size);stringToUTF8(str,ret,size);return ret};var ccall=(ident,returnType,argTypes,args,opts)=>{var toC={string:str=>{var ret=0;if(str!==null&&str!==undefined&&str!==0){ret=stringToUTF8OnStack(str)}return ret},array:arr=>{var ret=stackAlloc(arr.length);writeArrayToMemory(arr,ret);return ret}};function convertReturnValue(ret){if(returnType==="string"){return UTF8ToString(ret)}if(returnType==="boolean")return Boolean(ret);return ret}var func=getCFunc(ident);var cArgs=[];var stack=0;if(args){for(var i=0;i{var numericArgs=!argTypes||argTypes.every(type=>type==="number"||type==="boolean");var numericRet=returnType!=="string";if(numericRet&&numericArgs&&!opts){return getCFunc(ident)}return(...args)=>ccall(ident,returnType,argTypes,args,opts)};Module["requestAnimationFrame"]=MainLoop.requestAnimationFrame;Module["pauseMainLoop"]=MainLoop.pause;Module["resumeMainLoop"]=MainLoop.resume;MainLoop.init();{initMemory();if(Module["noExitRuntime"])noExitRuntime=Module["noExitRuntime"];if(Module["print"])out=Module["print"];if(Module["printErr"])err=Module["printErr"];if(Module["wasmBinary"])wasmBinary=Module["wasmBinary"];if(Module["arguments"])arguments_=Module["arguments"];if(Module["thisProgram"])thisProgram=Module["thisProgram"];if(Module["preInit"]){if(typeof Module["preInit"]=="function")Module["preInit"]=[Module["preInit"]];while(Module["preInit"].length>0){Module["preInit"].shift()()}}}Module["ccall"]=ccall;Module["cwrap"]=cwrap;var ASM_CONSTS={480908:$0=>{if(typeof amy_shared_open==="function"){return amy_shared_open(UTF8ToString($0))}return 0},481011:$0=>{if(typeof amy_shared_close==="function"){amy_shared_close($0)}},481085:($0,$1,$2,$3)=>{if(typeof amy_shared_read==="function"){return amy_shared_read($0,$1,$2,$3)}return 0},481186:$0=>{if(typeof amy_shared_close==="function"){amy_shared_close($0)}},481260:$0=>{if(typeof amy_sequencer_js_hook==="function"){amy_sequencer_js_hook($0)}},481343:()=>{if(typeof cv_1_voltage!="undefined"){return cv_1_voltage}else{return 0}},481430:()=>{if(typeof cv_2_voltage!="undefined"){return cv_2_voltage}else{return 0}},481517:($0,$1,$2,$3,$4)=>{if(typeof window==="undefined"||(window.AudioContext||window.webkitAudioContext)===undefined){return 0}if(typeof window.miniaudio==="undefined"){window.miniaudio={referenceCount:0};window.miniaudio.device_type={};window.miniaudio.device_type.playback=$0;window.miniaudio.device_type.capture=$1;window.miniaudio.device_type.duplex=$2;window.miniaudio.device_state={};window.miniaudio.device_state.stopped=$3;window.miniaudio.device_state.started=$4;miniaudio.devices=[];miniaudio.track_device=function(device){for(var iDevice=0;iDevice0){if(miniaudio.devices[miniaudio.devices.length-1]==null){miniaudio.devices.pop()}else{break}}};miniaudio.untrack_device=function(device){for(var iDevice=0;iDevice{Module._ma_device__on_notification_unlocked(device.pDevice)},error=>{console.error("Failed to resume audiocontext",error)})}}miniaudio.unlock_event_types.map(function(event_type){document.removeEventListener(event_type,miniaudio.unlock,true)})};miniaudio.unlock_event_types.map(function(event_type){document.addEventListener(event_type,miniaudio.unlock,true)})}window.miniaudio.referenceCount+=1;return 1},483675:()=>{if(typeof window.miniaudio!=="undefined"){window.miniaudio.referenceCount-=1;if(window.miniaudio.referenceCount===0){delete window.miniaudio}}},483839:()=>navigator.mediaDevices!==undefined&&navigator.mediaDevices.getUserMedia!==undefined,483943:()=>{try{var temp=new(window.AudioContext||window.webkitAudioContext);var sampleRate=temp.sampleRate;temp.close();return sampleRate}catch(e){return 0}},484114:$0=>miniaudio.track_device({webaudio:emscriptenGetAudioObject($0),state:1}),484203:($0,$1)=>{var getUserMediaResult=0;var audioWorklet=emscriptenGetAudioObject($0);var audioContext=emscriptenGetAudioObject($1);navigator.mediaDevices.getUserMedia({audio:true,video:false}).then(function(stream){audioContext.streamNode=audioContext.createMediaStreamSource(stream);audioContext.streamNode.connect(audioWorklet);audioWorklet.connect(audioContext.destination);getUserMediaResult=0}).catch(function(error){console.log("navigator.mediaDevices.getUserMedia Failed: "+error);getUserMediaResult=-1});return getUserMediaResult},484765:($0,$1)=>{var audioWorklet=emscriptenGetAudioObject($0);var audioContext=emscriptenGetAudioObject($1);audioWorklet.connect(audioContext.destination);return 0},484925:$0=>emscriptenGetAudioObject($0).sampleRate,484977:$0=>{var device=miniaudio.get_device_by_index($0);if(device.streamNode!==undefined){device.streamNode.disconnect();device.streamNode=undefined}},485133:$0=>{miniaudio.untrack_device_by_index($0)},485176:$0=>{var device=miniaudio.get_device_by_index($0);device.webaudio.resume();device.state=miniaudio.device_state.started},485301:$0=>{var device=miniaudio.get_device_by_index($0);device.webaudio.suspend();device.state=miniaudio.device_state.stopped},485427:($0,$1,$2)=>{if(typeof amy_external_midi_input_js_hook==="function"){amy_external_midi_input_js_hook((growMemViews(),HEAPU8).subarray($0,$0+$1),$1,$2)}},485558:($0,$1)=>{if(midiOutputDevice!=null){midiOutputDevice.send((growMemViews(),HEAPU8).subarray($0,$0+$1))}}};var _free,_malloc,_amy_sysclock,_amy_reset_sysclock,_amy_add_event,_yield_patch_events,_yield_synth_commands,_size_of_amy_event,_sequencer_ticks,_ma_device__on_notification_unlocked,_ma_malloc_emscripten,_ma_free_emscripten,_ma_device_process_pcm_frames_capture__webaudio,_ma_device_process_pcm_frames_playback__webaudio,_amy_live_start_web_audioin,_amy_live_start_web,_amy_live_stop,_amy_add_message,_amy_process_single_midi_byte,_amy_get_input_buffer,_amy_set_external_input_buffer,_amy_start_web,_amy_bleep,_amy_start_web_no_synths,__embind_initialize_bindings,__emscripten_stack_restore,__emscripten_stack_alloc,_emscripten_stack_get_current,__emscripten_wasm_worker_initialize,dynCall_iiii,dynCall_iii,dynCall_vi,dynCall_vii,dynCall_ii,dynCall_iiiii,dynCall_viii,dynCall_viiii,dynCall_v,dynCall_iiiiiiii,dynCall_iiiji,dynCall_iiiiiii,dynCall_jii,dynCall_jiji,dynCall_iidiiii,dynCall_viiiiii,dynCall_viiiii,_asyncify_start_unwind,_asyncify_stop_unwind,_asyncify_start_rewind,_asyncify_stop_rewind,__indirect_function_table,wasmTable;function assignWasmExports(wasmExports){_free=Module["_free"]=wasmExports["E"];_malloc=Module["_malloc"]=wasmExports["F"];_amy_sysclock=Module["_amy_sysclock"]=wasmExports["H"];_amy_reset_sysclock=Module["_amy_reset_sysclock"]=wasmExports["I"];_amy_add_event=Module["_amy_add_event"]=wasmExports["J"];_yield_patch_events=Module["_yield_patch_events"]=wasmExports["K"];_yield_synth_commands=Module["_yield_synth_commands"]=wasmExports["L"];_size_of_amy_event=Module["_size_of_amy_event"]=wasmExports["M"];_sequencer_ticks=Module["_sequencer_ticks"]=wasmExports["N"];_ma_device__on_notification_unlocked=Module["_ma_device__on_notification_unlocked"]=wasmExports["O"];_ma_malloc_emscripten=Module["_ma_malloc_emscripten"]=wasmExports["P"];_ma_free_emscripten=Module["_ma_free_emscripten"]=wasmExports["Q"];_ma_device_process_pcm_frames_capture__webaudio=Module["_ma_device_process_pcm_frames_capture__webaudio"]=wasmExports["R"];_ma_device_process_pcm_frames_playback__webaudio=Module["_ma_device_process_pcm_frames_playback__webaudio"]=wasmExports["S"];_amy_live_start_web_audioin=Module["_amy_live_start_web_audioin"]=wasmExports["T"];_amy_live_start_web=Module["_amy_live_start_web"]=wasmExports["U"];_amy_live_stop=Module["_amy_live_stop"]=wasmExports["V"];_amy_add_message=Module["_amy_add_message"]=wasmExports["W"];_amy_process_single_midi_byte=Module["_amy_process_single_midi_byte"]=wasmExports["X"];_amy_get_input_buffer=Module["_amy_get_input_buffer"]=wasmExports["Y"];_amy_set_external_input_buffer=Module["_amy_set_external_input_buffer"]=wasmExports["Z"];_amy_start_web=Module["_amy_start_web"]=wasmExports["_"];_amy_bleep=Module["_amy_bleep"]=wasmExports["$"];_amy_start_web_no_synths=Module["_amy_start_web_no_synths"]=wasmExports["aa"];__embind_initialize_bindings=wasmExports["ba"];__emscripten_stack_restore=wasmExports["ca"];__emscripten_stack_alloc=wasmExports["da"];_emscripten_stack_get_current=wasmExports["ea"];__emscripten_wasm_worker_initialize=wasmExports["fa"];dynCall_iiii=dynCalls["iiii"]=wasmExports["ga"];dynCall_iii=dynCalls["iii"]=wasmExports["ha"];dynCall_vi=dynCalls["vi"]=wasmExports["ia"];dynCall_vii=dynCalls["vii"]=wasmExports["ja"];dynCall_ii=dynCalls["ii"]=wasmExports["ka"];dynCall_iiiii=dynCalls["iiiii"]=wasmExports["la"];dynCall_viii=dynCalls["viii"]=wasmExports["ma"];dynCall_viiii=dynCalls["viiii"]=wasmExports["na"];dynCall_v=dynCalls["v"]=wasmExports["oa"];dynCall_iiiiiiii=dynCalls["iiiiiiii"]=wasmExports["pa"];dynCall_iiiji=dynCalls["iiiji"]=wasmExports["qa"];dynCall_iiiiiii=dynCalls["iiiiiii"]=wasmExports["ra"];dynCall_jii=dynCalls["jii"]=wasmExports["sa"];dynCall_jiji=dynCalls["jiji"]=wasmExports["ta"];dynCall_iidiiii=dynCalls["iidiiii"]=wasmExports["ua"];dynCall_viiiiii=dynCalls["viiiiii"]=wasmExports["va"];dynCall_viiiii=dynCalls["viiiii"]=wasmExports["wa"];_asyncify_start_unwind=wasmExports["xa"];_asyncify_stop_unwind=wasmExports["ya"];_asyncify_start_rewind=wasmExports["za"];_asyncify_stop_rewind=wasmExports["Aa"];__indirect_function_table=wasmTable=wasmExports["G"]}var wasmImports;function assignWasmImports(){wasmImports={b:___assert_fail,A:__abort_js,l:__embind_register_bigint,v:__embind_register_bool,t:__embind_register_emval,k:__embind_register_float,f:__embind_register_integer,d:__embind_register_memory_view,u:__embind_register_std_string,i:__embind_register_std_wstring,w:__embind_register_void,m:_emscripten_asm_const_double,c:_emscripten_asm_const_int,h:_emscripten_cancel_main_loop,r:_emscripten_create_audio_context,B:_emscripten_create_wasm_audio_worklet_node,C:_emscripten_create_wasm_audio_worklet_processor_async,g:_emscripten_destroy_audio_context,o:_emscripten_destroy_web_audio_node,e:_emscripten_get_now,x:_emscripten_resize_heap,j:_emscripten_set_main_loop,p:_emscripten_sleep,q:_emscripten_start_wasm_audio_worklet_thread_async,s:_exit,z:_fd_close,y:_fd_seek,n:_fd_write,a:wasmMemory}}function run(){if(ENVIRONMENT_IS_WASM_WORKER){readyPromiseResolve?.(Module);initRuntime();return}preRun();function doRun(){Module["calledRun"]=true;if(ABORT)return;initRuntime();readyPromiseResolve?.(Module);Module["onRuntimeInitialized"]?.();postRun()}if(Module["setStatus"]){Module["setStatus"]("Running...");setTimeout(()=>{setTimeout(()=>Module["setStatus"](""),1);doRun()},1)}else{doRun()}}var wasmExports;if(!ENVIRONMENT_IS_WASM_WORKER){wasmExports=await (createWasm());run()}if(runtimeInitialized){moduleRtn=Module}else{moduleRtn=new Promise((resolve,reject)=>{readyPromiseResolve=resolve;readyPromiseReject=reject})} ;return moduleRtn}})();if(typeof exports==="object"&&typeof module==="object"){module.exports=amyModule;module.exports.default=amyModule}else if(typeof define==="function"&&define["amd"])define([],()=>amyModule);var isWW=globalThis.self?.name=="em-ww";var isNode=globalThis.process?.versions?.node&&globalThis.process?.type!="renderer";if(isNode)isWW=require("worker_threads").workerData==="em-ww";isWW||=!!globalThis.AudioWorkletGlobalScope;isWW&&amyModule(); // amy_connector.js // helpers for JS to communicate with AMY, including webMIDI var amy_add_message = null; var amy_reset_sysclock = null var amy_module = null; var amy_started = false; var amy_live_start_web = null; var audio_started = false; var amy_sysclock = null; var amy_module = null; var midiOutputDevice = null; var midiInputDevice = null; var amy_audioin_toggle = false; // Once AMY module is loaded, register its functions and start AMY (not yet audio, you need to click for that) amyModule().then(async function(am) { amy_live_start_web = am.cwrap( 'amy_live_start_web', null, null, {async: true} ); amy_live_start_web_audioin = am.cwrap( 'amy_live_start_web_audioin', null, null, {async: true} ); amy_live_stop = am.cwrap( 'amy_live_stop', null, null, {async: true} ); amy_start_web = am.cwrap( 'amy_start_web', null, null ); amy_start_web_no_synths = am.cwrap( 'amy_start_web_no_synths', null, null ); amy_add_message = am.cwrap( 'amy_add_message', null, ['string'] ); amy_reset_sysclock = am.cwrap( 'amy_reset_sysclock', null, null ); amy_ticks = am.cwrap( 'sequencer_ticks', 'number', [null] ); amy_sysclock = am.cwrap( 'amy_sysclock', 'number', [null] ); amy_process_single_midi_byte = am.cwrap( 'amy_process_single_midi_byte', null, ['number, number'] ); // If Godot bridge is present, let it control startup with config. // Otherwise start with defaults (standalone REPL mode). if (typeof window !== 'undefined' && window._amy_godot_bridge) { window._amy_godot_start_web = amy_start_web; window._amy_godot_start_web_no_synths = amy_start_web_no_synths; } else { amy_start_web(); } amy_module = am; }); async function amy_js_start() { // Don't run this twice if(amy_started) return; await start_midi(); await sleep_ms(200); // Start the audio worklet (miniaudio) if (amy_audioin_toggle) { await amy_live_start_web_audioin(); } else { await amy_live_start_web(); } await sleep_ms(200); amy_started = true; } async function setup_midi_devices() { var midi_in = document.amyboard_settings.midi_input; var midi_out = document.amyboard_settings.midi_output; if(WebMidi.inputs.length > midi_in.selectedIndex) { if(midiInputDevice != null) midiInputDevice.destroy(); midiInputDevice = WebMidi.getInputById(WebMidi.inputs[midi_in.selectedIndex].id); midiInputDevice.addListener("midimessage", e => { for(byte in e.message.data) { amy_process_single_midi_byte(e.message.data[byte], 1); } }); } if(WebMidi.outputs.length > midi_out.selectedIndex) { if(midiOutputDevice != null) midiOutputDevice.destroy(); midiOutputDevice = WebMidi.getOutputById(WebMidi.outputs[midi_out.selectedIndex].id); } } async function start_midi() { function onEnabled() { // Populate the dropdowns var midi_in = document.amyboard_settings.midi_input; var midi_out = document.amyboard_settings.midi_output; if(WebMidi.inputs.length>0) { midi_in.options.length = 0; WebMidi.inputs.forEach(input => { midi_in.options[midi_in.options.length] = new Option("MIDI in: " + input.name); }); } if(WebMidi.outputs.length>0) { midi_out.options.length = 0; WebMidi.outputs.forEach(output => { midi_out.options[midi_out.options.length] = new Option("MIDI out: "+ output.name); }); } // First run setup setup_midi_devices(); } if(typeof WebMidi != 'undefined') { if(WebMidi.supported) { WebMidi .enable({sysex:true}) .then(onEnabled) .catch(err => console.log("MIDI: " + err)); } else { document.getElementById('midi-input-panel').style.display='none'; document.getElementById('midi-output-panel').style.display='none'; } } } async function sleep_ms(ms) { await new Promise((r) => setTimeout(r, ms)); } async function toggle_audioin() { if(!amy_started) await sleep_ms(1000); await amy_live_stop(); if (document.getElementById('amy_audioin').checked) { amy_audioin_toggle = true; await amy_live_start_web_audioin(); } else { amy_audioin_toggle = false; await amy_live_start_web(); } } // AUTO-GENERATED by scripts/gen_amy_js_api.py — do not edit by hand. // Source: amy/__init__.py (function() { "use strict"; var AMY_KW_MAP = { osc: {wire: "v", type: "I"}, wave: {wire: "w", type: "I"}, note: {wire: "n", type: "F"}, vel: {wire: "l", type: "F"}, amp: {wire: "a", type: "C"}, freq: {wire: "f", type: "C"}, duty: {wire: "d", type: "C"}, feedback: {wire: "b", type: "F"}, time: {wire: "t", type: "I"}, reset: {wire: "S", type: "I"}, phase: {wire: "P", type: "F"}, pan: {wire: "Q", type: "C"}, client: {wire: "g", type: "I"}, volume: {wire: "V", type: "F"}, pitch_bend: {wire: "s", type: "F"}, filter_freq: {wire: "F", type: "C"}, resonance: {wire: "R", type: "F"}, bp0: {wire: "A", type: "L"}, bp1: {wire: "B", type: "L"}, eg0_type: {wire: "T", type: "I"}, eg1_type: {wire: "X", type: "I"}, debug: {wire: "D", type: "I"}, chained_osc: {wire: "c", type: "I"}, mod_source: {wire: "L", type: "I"}, eq: {wire: "x", type: "L"}, filter_type: {wire: "G", type: "I"}, ratio: {wire: "I", type: "F"}, latency_ms: {wire: "N", type: "I"}, algo_source: {wire: "O", type: "L"}, load_sample: {wire: "z", type: "L"}, transfer_file: {wire: "zT", type: "L"}, disk_sample: {wire: "zF", type: "L"}, algorithm: {wire: "o", type: "I"}, chorus: {wire: "k", type: "L"}, reverb: {wire: "h", type: "L"}, echo: {wire: "M", type: "L"}, patch: {wire: "K", type: "I"}, voices: {wire: "r", type: "L"}, external_channel: {wire: "W", type: "I"}, portamento: {wire: "m", type: "I"}, sequence: {wire: "H", type: "L"}, tempo: {wire: "j", type: "F"}, synth: {wire: "i", type: "I"}, pedal: {wire: "ip", type: "I"}, synth_flags: {wire: "if", type: "I"}, num_voices: {wire: "iv", type: "I"}, oscs_per_voice: {wire: "in", type: "I"}, to_synth: {wire: "it", type: "I"}, grab_midi_notes: {wire: "im", type: "I"}, synth_delay: {wire: "id", type: "I"}, preset: {wire: "p", type: "I"}, num_partials: {wire: "p", type: "I"}, start_sample: {wire: "zS", type: "L"}, stop_sample: {wire: "zO", type: "I"}, midi_cc: {wire: "ic", type: "L"}, patch_string: {wire: "u", type: "S"} }; var AMY_KW_PRIORITY = { osc: 0, wave: 1, note: 2, vel: 3, amp: 4, freq: 5, duty: 6, feedback: 7, time: 8, reset: 9, phase: 10, pan: 11, client: 12, volume: 13, pitch_bend: 14, filter_freq: 15, resonance: 16, bp0: 17, bp1: 18, eg0_type: 19, eg1_type: 20, debug: 21, chained_osc: 22, mod_source: 23, eq: 24, filter_type: 25, ratio: 26, latency_ms: 27, algo_source: 28, load_sample: 29, transfer_file: 30, disk_sample: 31, algorithm: 32, chorus: 33, reverb: 34, echo: 35, patch: 36, voices: 37, external_channel: 38, portamento: 39, sequence: 40, tempo: 41, synth: 42, pedal: 43, synth_flags: 44, num_voices: 45, oscs_per_voice: 46, to_synth: 47, grab_midi_notes: 48, synth_delay: 49, preset: 50, num_partials: 51, start_sample: 52, stop_sample: 53, midi_cc: 54, patch_string: 55 }; var AMY_COEF_FIELDS = ["const", "note", "vel", "eg0", "eg1", "mod", "bend", "ext0", "ext1"]; // --- type handlers (mirror Python's str_of_int, trunc, parse_list_or_comma_string, parse_ctrl_coefs) --- function _str_of_int(arg) { return String(Math.trunc(Number(arg))); } function _trunc(number) { if (typeof number === "string") { if (number.trim() === "") return ""; number = parseFloat(number); } if (typeof number === "number") { var s = number.toFixed(6); s = s.replace(/0+$/, ""); s = s.replace(/\.$/, ""); return s; } return String(number); } function _parse_list(obj) { if (Array.isArray(obj)) { return obj.map(function(v) { return v == null ? "" : String(v); }).join(","); } return String(obj); } function _trim_trailing(arr) { var end = arr.length; while (end > 0 && arr[end - 1] == null) end--; return arr.slice(0, end); } function _parse_ctrl_coefs(coefs) { if (typeof coefs === "string") { return coefs.split(",").map(function(x) { return _trunc(x); }).join(","); } if (typeof coefs === "number") { return _trunc(coefs); } if (!Array.isArray(coefs) && typeof coefs === "object" && coefs !== null) { var list = new Array(AMY_COEF_FIELDS.length).fill(null); for (var key in coefs) { if (!coefs.hasOwnProperty(key)) continue; var idx = AMY_COEF_FIELDS.indexOf(key); if (idx < 0) throw new Error("Unknown ctrl_coef field: " + key + ". Valid: " + AMY_COEF_FIELDS.join(", ")); list[idx] = coefs[key]; } coefs = list; } if (!Array.isArray(coefs)) { return String(coefs); } coefs = _trim_trailing(coefs); return coefs.map(function(v) { return v == null ? "" : _trunc(v); }).join(","); } var _ARG_HANDLERS = { I: _str_of_int, F: _trunc, S: String, L: _parse_list, C: _parse_ctrl_coefs }; /** * Build an AMY wire code string from named parameters. * * amy_message({osc: 0, wave: 1, freq: 440}) => "v0w1f440Z" * amy_message({synth: 1, patch: 257, num_voices: 6}) => "K257i1iv6Z" * * Control coefficient params (amp, freq, duty, pan, filter_freq) accept: * - A number: freq: 440 * - An array: freq: [440, 1, null, null, null, null, 1] * - An object: freq: {const: 440, bend: 1} */ function amy_message(params) { if (!params || typeof params !== "object") { throw new Error("amy_message requires an object of parameters"); } var keys = []; for (var key in params) { if (!params.hasOwnProperty(key)) continue; if (!(key in AMY_KW_MAP)) { throw new Error("Unknown AMY parameter: " + key); } var arg = params[key]; if (arg == null) { if (key !== "time" && key !== "sequence") { throw new Error("Null value for AMY parameter: " + key); } continue; } keys.push(key); } keys.sort(function(a, b) { return (AMY_KW_PRIORITY[a] || 0) - (AMY_KW_PRIORITY[b] || 0); }); var m = ""; for (var i = 0; i < keys.length; i++) { var k = keys[i]; var mapping = AMY_KW_MAP[k]; var handler = _ARG_HANDLERS[mapping.type]; m += mapping.wire + handler(params[k]); } return m + "Z"; } /** * Build and send an AMY wire code message. * Equivalent to Python's amy.send(). */ function amy_send(params, log) { var msg = amy_message(params); if (log && typeof amy_add_log_message === "function") { amy_add_log_message(msg); } else if (typeof amy_add_message === "function") { amy_add_message(msg); } else { console.warn("amy_send: no AMY message handler found (is amy.js loaded?)"); } return msg; } // Constants from amy/constants.py (mirrors amy.SINE, amy.FILTER_LPF, etc.) var AMY = { MAX_FILENAME_LEN: 127, AMY_BLOCK_SIZE: 256, BLOCK_SIZE_BITS: 8, AMY_SAMPLE_RATE: 44100, PCM_AMY_SAMPLE_RATE: 22050, AMY_TRANSFER_TYPE_NONE: 0, AMY_TRANSFER_TYPE_AUDIO: 1, AMY_TRANSFER_TYPE_FILE: 2, AMY_TRANSFER_TYPE_SAMPLE: 3, AMY_PCM_TYPE_ROM: 0, AMY_PCM_TYPE_FILE: 1, AMY_PCM_TYPE_MEMORY: 2, PCM_FILE_BUFFER_MULT: 8, AMY_BUS_OUTPUT: 1, AMY_BUS_AUDIO_IN: 2, AMY_MAX_CORES: 2, AMY_MAX_CHANNELS: 2, AMY_NCHANS: 2, AMY_CORES: 1, AMY_MIDI_CHANNEL_DRUMS: 10, MALLOC_CAP_DEFAULT: 0, CHORUS_DEFAULT_LFO_FREQ: 0.5, CHORUS_DEFAULT_MOD_DEPTH: 0.5, CHORUS_DEFAULT_LEVEL: 0, CHORUS_DEFAULT_MAX_DELAY: 320, EQ_CENTER_LOW: 800.0, EQ_CENTER_MED: 2500.0, EQ_CENTER_HIGH: 7000.0, REVERB_DEFAULT_LEVEL: 0, REVERB_DEFAULT_LIVENESS: 0.85, REVERB_DEFAULT_DAMPING: 0.5, REVERB_DEFAULT_XOVER_HZ: 3000.0, ECHO_DEFAULT_LEVEL: 0, ECHO_DEFAULT_DELAY_MS: 500.0, ECHO_DEFAULT_MAX_DELAY_MS: 743.0, ECHO_DEFAULT_FEEDBACK: 0, ECHO_DEFAULT_FILTER_COEF: 0, AMY_SEQUENCER_PPQ: 48, DELAY_LINE_LEN: 512, CLIP_D: 0.1, MAX_VOLUME: 11.0, AMP_THRESH: 0.001, AMP_THRESH_PLUS: 0.0011, SAMPLE_MAX: 32767, MAX_ALGO_OPS: 6, DEFAULT_NUM_BREAKPOINTS: 8, MAX_BREAKPOINTS: 24, MAX_BREAKPOINT_SETS: 2, THREAD_USLEEP: 500, AMY_BYTES_PER_SAMPLE: 2, MAX_VOICES_PER_INSTRUMENT: 32, FILT_NUM_DELAYS: 4, ZERO_HZ_LOG_VAL: -99.0, ZERO_LOGFREQ_IN_HZ: 440.0, ZERO_MIDI_NOTE: 69, MIN_FILTER_LOGFREQ: -2.75, NUM_COMBO_COEFS: 9, MAX_MESSAGE_LEN: 1024, MAX_PARAM_LEN: 256, FILTER_NONE: 0, FILTER_LPF: 1, FILTER_BPF: 2, FILTER_HPF: 3, FILTER_LPF24: 4, SINE: 0, PULSE: 1, SAW_DOWN: 2, SAW_UP: 3, TRIANGLE: 4, NOISE: 5, KS: 6, PCM: 7, ALGO: 8, PARTIAL: 9, BYO_PARTIALS: 10, INTERP_PARTIALS: 11, AUDIO_IN0: 12, AUDIO_IN1: 13, AUDIO_EXT0: 14, AUDIO_EXT1: 15, AMY_MIDI: 16, PCM_LEFT: 17, PCM_RIGHT: 18, PCM_MIX: 7, WAVETABLE: 19, CUSTOM: 20, WAVE_OFF: 21, SYNTH_OFF: 0, SYNTH_AUDIBLE: 1, SYNTH_AUDIBLE_SUSPENDED: 2, SYNTH_IS_MOD_SOURCE: 3, SYNTH_IS_ALGO_SOURCE: 4, EVENT_EMPTY: 0, EVENT_SCHEDULED: 1, EVENT_TRANSFER_DATA: 2, EVENT_SEQUENCE: 3, NOTE_SOURCE_MIDI: 2, ENVELOPE_NORMAL: 0, ENVELOPE_LINEAR: 1, ENVELOPE_DX7: 2, ENVELOPE_TRUE_EXPONENTIAL: 3, SEQUENCE_TICK: 0, SEQUENCE_PERIOD: 1, SEQUENCE_TAG: 2, RESET_SEQUENCER: 4096, RESET_ALL_OSCS: 8192, RESET_TIMEBASE: 16384, RESET_AMY: 32768, RESET_EVENTS: 65536, RESET_ALL_NOTES: 131072, RESET_SYNTHS: 262144, RESET_PATCH: 524288, AMY_OK: 0, AMY_AUDIO_IS_NONE: 0, AMY_AUDIO_IS_I2S: 1, AMY_AUDIO_IS_USB_GADGET: 2, AMY_AUDIO_IS_MINIAUDIO: 4, AMY_MIDI_IS_NONE: 0, AMY_MIDI_IS_UART: 1, AMY_MIDI_IS_USB_GADGET: 2, AMY_MIDI_IS_MACOS: 4, AMY_MIDI_IS_WEBMIDI: 8, AMYBOARD_LRC: 2, AMYBOARD_BCLK: 8, AMYBOARD_DOUT: 6, AMYBOARD_DIN: 9, AMYBOARD_MCLK: 3, AMYBOARD_MIDI_OUT_TYPE_A: 14, AMYBOARD_MIDI_OUT_TYPE_B: 15, AMYBOARD_MIDI_IN: 21 }; if (typeof globalThis !== "undefined") { globalThis.amy_message = amy_message; globalThis.amy_send = amy_send; globalThis.AMY = AMY; globalThis.AMY_KW_MAP = AMY_KW_MAP; globalThis.AMY_COEF_FIELDS = AMY_COEF_FIELDS; } })(); ================================================ FILE: docs/amy.ww.js ================================================ // N.B. The contents of this file are duplicated in src/library_wasm_worker.js // in variable "_wasmWorkerBlobUrl" (where the contents are pre-minified) If // doing any changes to this file, be sure to update the contents there too. 'use strict'; // Node.js support var ENVIRONMENT_IS_NODE = typeof process == 'object' && typeof process.versions == 'object' && typeof process.versions.node == 'string' && process.type != 'renderer'; if (ENVIRONMENT_IS_NODE) { // Create as web-worker-like an environment as we can. var nodeWorkerThreads = require('worker_threads'); var parentPort = nodeWorkerThreads.parentPort; parentPort.on('message', (msg) => global.onmessage?.({ data: msg })); // Weak map of handle functions to their wrapper. Used to implement // addEventListener/removeEventListener. var wrappedHandlers = new WeakMap(); function wrapMsgHandler(h) { var f = wrappedHandlers.get(h) if (!f) { f = (msg) => h({data: msg}); wrappedHandlers.set(h, f); } return f; } var fs = require('fs'); var vm = require('vm'); Object.assign(global, { self: global, require, __filename, __dirname, Worker: nodeWorkerThreads.Worker, importScripts: (f) => vm.runInThisContext(fs.readFileSync(f, 'utf8'), {filename: f}), postMessage: (msg) => parentPort.postMessage(msg), performance: global.performance || { now: Date.now }, addEventListener: (name, handler) => parentPort.on(name, wrapMsgHandler(handler)), removeEventListener: (name, handler) => parentPort.off(name, wrapMsgHandler(handler)), }); } self.onmessage = function(d) { // The first message sent to the Worker is always the bootstrap message. // Drop this message listener, it served its purpose of bootstrapping // the Wasm Module load, and is no longer needed. Let user code register // any desired message handlers from now on. self.onmessage = null; d = d.data; d['instantiateWasm'] = (info, receiveInstance) => { var instance = new WebAssembly.Instance(d['wasm'], info); return receiveInstance(instance, d['wasm']); } importScripts(d.js); amyModule(d); // Drop now unneeded references to from the Module object in this Worker, // these are not needed anymore. d.wasm = d.mem = d.js = 0; } ================================================ FILE: docs/amyrepl.css ================================================ /*.modal-backdrop.fade.show { z-index: inherit; }*/ /* Solarized theme for code-mirror http://ethanschoonover.com/solarized */ /* Solarized color palette http://ethanschoonover.com/solarized/img/solarized-palette.png */ .solarized.base03 { color: #002b36; } .solarized.base02 { color: #073642; } .solarized.base01 { color: #586e75; } .solarized.base00 { color: #657b83; } .solarized.base0 { color: #839496; } .solarized.base1 { color: #93a1a1; } .solarized.base2 { color: #eee8d5; } .solarized.base3 { color: #fdf6e3; } .solarized.solar-yellow { color: #b58900; } .solarized.solar-orange { color: #cb4b16; } .solarized.solar-red { color: #dc322f; } .solarized.solar-magenta { color: #d33682; } .solarized.solar-violet { color: #6c71c4; } .solarized.solar-blue { color: #268bd2; } .solarized.solar-cyan { color: #2aa198; } .solarized.solar-green { color: #859900; } /* Color scheme for code-mirror */ .cm-s-solarized { line-height: 1.45em; color-profile: sRGB; rendering-intent: auto; } .cm-s-solarized.cm-s-dark { color: #839496; background-color: #002b36; } .cm-s-solarized.cm-s-light { background-color: #fdf6e3; color: #657b83; } .cm-s-solarized .CodeMirror-widget { text-shadow: none; } .cm-s-solarized .cm-header { color: #586e75; } .cm-s-solarized .cm-quote { color: #93a1a1; } .cm-s-solarized .cm-keyword { color: #cb4b16; } .cm-s-solarized .cm-atom { color: #d33682; } .cm-s-solarized .cm-number { color: #d33682; } .cm-s-solarized .cm-def { color: #2aa198; } .cm-s-solarized .cm-variable { color: #839496; } .cm-s-solarized .cm-variable-2 { color: #b58900; } .cm-s-solarized .cm-variable-3, .cm-s-solarized .cm-type { color: #6c71c4; } .cm-s-solarized .cm-property { color: #2aa198; } .cm-s-solarized .cm-operator { color: #6c71c4; } .cm-s-solarized .cm-comment { color: #586e75; font-style:italic; } .cm-s-solarized .cm-string { color: #859900; } .cm-s-solarized .cm-string-2 { color: #b58900; } .cm-s-solarized .cm-meta { color: #859900; } .cm-s-solarized .cm-qualifier { color: #b58900; } .cm-s-solarized .cm-builtin { color: #d33682; } .cm-s-solarized .cm-bracket { color: #cb4b16; } .cm-s-solarized .CodeMirror-matchingbracket { color: #859900; } .cm-s-solarized .CodeMirror-nonmatchingbracket { color: #dc322f; } .cm-s-solarized .cm-tag { color: #93a1a1; } .cm-s-solarized .cm-attribute { color: #2aa198; } .cm-s-solarized .cm-hr { color: transparent; border-top: 1px solid #586e75; display: block; } .cm-s-solarized .cm-link { color: #93a1a1; cursor: pointer; } .cm-s-solarized .cm-special { color: #6c71c4; } .cm-s-solarized .cm-em { color: #999; text-decoration: underline; text-decoration-style: dotted; } .cm-s-solarized .cm-error, .cm-s-solarized .cm-invalidchar { /* color: #586e75; border-bottom: 1px dotted #dc322f; */ } .cm-s-solarized.cm-s-dark div.CodeMirror-selected { background: #073642; } .cm-s-solarized.cm-s-dark.CodeMirror ::selection { background: rgba(7, 54, 66, 0.99); } .cm-s-solarized.cm-s-dark .CodeMirror-line::-moz-selection, .cm-s-dark .CodeMirror-line > span::-moz-selection, .cm-s-dark .CodeMirror-line > span > span::-moz-selection { background: rgba(7, 54, 66, 0.99); } .cm-s-solarized.cm-s-light div.CodeMirror-selected { background: #eee8d5; } .cm-s-solarized.cm-s-light .CodeMirror-line::selection, .cm-s-light .CodeMirror-line > span::selection, .cm-s-light .CodeMirror-line > span > span::selection { background: #eee8d5; } .cm-s-solarized.cm-s-light .CodeMirror-line::-moz-selection, .cm-s-light .CodeMirror-line > span::-moz-selection, .cm-s-light .CodeMirror-line > span > span::-moz-selection { background: #eee8d5; } /* Editor styling */ /* Little shadow on the view-port of the buffer view */ .cm-s-solarized.CodeMirror { -moz-box-shadow: inset 7px 0 12px -6px #000; -webkit-box-shadow: inset 7px 0 12px -6px #000; box-shadow: inset 7px 0 12px -6px #000; } /* Remove gutter border */ .cm-s-solarized .CodeMirror-gutters { border-right: 0; } /* Gutter colors and line number styling based of color scheme (dark / light) */ /* Dark */ .cm-s-solarized.cm-s-dark .CodeMirror-gutters { background-color: #073642; } .cm-s-solarized.cm-s-dark .CodeMirror-linenumber { color: #586e75; } /* Light */ .cm-s-solarized.cm-s-light .CodeMirror-gutters { background-color: #eee8d5; } .cm-s-solarized.cm-s-light .CodeMirror-linenumber { color: #839496; } /* Common */ .cm-s-solarized .CodeMirror-linenumber { padding: 0 5px; } .cm-s-solarized .CodeMirror-guttermarker-subtle { color: #586e75; } .cm-s-solarized.cm-s-dark .CodeMirror-guttermarker { color: #ddd; } .cm-s-solarized.cm-s-light .CodeMirror-guttermarker { color: #cb4b16; } .cm-s-solarized .CodeMirror-gutter .CodeMirror-gutter-text { color: #586e75; } /* Cursor */ .cm-s-solarized .CodeMirror-cursor { border-left: 1px solid #819090; } /* Fat cursor */ .cm-s-solarized.cm-s-light.cm-fat-cursor .CodeMirror-cursor { background: #77ee77; } .cm-s-solarized.cm-s-light .cm-animate-fat-cursor { background-color: #77ee77; } .cm-s-solarized.cm-s-dark.cm-fat-cursor .CodeMirror-cursor { background: #586e75; } .cm-s-solarized.cm-s-dark .cm-animate-fat-cursor { background-color: #586e75; } /* Active line */ .cm-s-solarized.cm-s-dark .CodeMirror-activeline-background { background: rgba(255, 255, 255, 0.06); } .cm-s-solarized.cm-s-light .CodeMirror-activeline-background { background: rgba(0, 0, 0, 0.06); } ================================================ FILE: docs/amyrepl.js ================================================ // Manage Micropython and AMY running together, for a web REPL experience var mp = null; var editors = []; var run_at_starts = []; var python_started = false; async function start_python_and_amy() { await amy_js_start(); await start_python(); } async function run_async(code) { await mp.runPythonAsync(code); } async function start_python() { // Don't run this twice if(python_started) return; // Let micropython call an exported AMY function await mp.registerJsModule('amy_js_message', amy_add_message); // time.sleep on this would block the browser from executing anything, so we override it to a JS thing mp.registerJsModule("time", { sleep: async (s) => await new Promise((r) => setTimeout(r, s * 1000)), }); // Set up the micropython context, like _boot.py. await mp.runPythonAsync(` import amy, amy_js_message, time amy.override_send = amy_js_message `); await sleep_ms(200); python_started = true; for(i=0;i"; let myModal = new bootstrap.Modal(document.getElementById('myModal'), {backdrop:false}); myModal.show(); }; async function runCodeBlock(index) { // This is the case that someone clicks the green run button as their first click, so we have to wait for python/amy to start up if(!(python_started && amy_started)) await sleep_ms(1000); var py = editors[index].getValue(); await amy_add_message("S16384Z"); try { mp.runPythonAsync(py); } catch (e) { await print_error(e.message); } } // Create editor block for notebook mode. function create_editor(element, index) { code = element.textContent; element.innerHTML = `
`; const editor = CodeMirror.fromTextArea(document.getElementById(`code-${index}`), { mode: { name: "python", version: 3, singleLineStringErrors: false, lint: false }, lineNumbers: true, indentUnit: 4, matchBrackets: true, spellCheck: false, autocorrect: false, theme: "solarized dark", lint: false, }); run_at_start = false; if(element.classList.contains("preload-python")) { run_at_start = true; } editor.setSize(null,150); editor.setValue(code.trim()); run_at_starts.push(run_at_start); editors.push(editor); } // Called from AMY to update AMYboard about what tick it is, for the sequencer function amy_sequencer_js_hook(tick) { mp.tulipTick(tick); } ================================================ FILE: docs/api.md ================================================ # AMY synthesizer API This page collects the current API for [AMY](https://github.com/shorepine/amy). [**Please see our interactive AMY tutorial for more tips on using AMY**](https://shorepine.github.io/amy/tutorial.html) ## C / Arduino API Parsing, creating and adding events to AMY: ```c // returns default empty amy_event amy_event amy_default_event(); // clears an existing AMY event amy_clear_event(amy_event *e); // given an event play / schedule the event directly amy_add_event(amy_event *e); // given a wire message string play / schedule the event directly amy_add_message(char *message); ``` Get and set external audio buffers: ```c // get AUDIO_IN0 and AUDIO_IN1 amy_get_input_buffer(output_sample_type * samples); // set AUDIO_EXT0 and AUDIO_EXT1 amy_set_external_input_buffer(output_sample_type * samples); ``` If not running live, render a new block of AMY audio into a int16_t buffer: ```c output_sample_type * amy_simple_fill_buffer(); ``` Get the AMY time: ```c // on all platforms, sysclock is based on total samples played, using audio out (i2s or etc) as system clock uint32_t amy_sysclock(); ``` Start and stop AMY: ```c // Emscripten web start amy_start_web(); amy_start_web_no_synths(); // Start AMY with a config. If c.audio is set, will attempt to start live audio amy_start(amy_config_t c); // Stop AMY including any live audio output amy_stop(); ``` Default MIDI handlers: ```c void amy_enable_juno_filter_midi_handler(); // assigns the Juno-6 MIDI CC handler ``` ## JavaScript API AMY provides a high-level JavaScript API (`amy_send`) that mirrors the Python `amy.send()` interface. It is auto-generated from the same source of truth (`amy/__init__.py` and `amy/constants.py`) so parameter names are always identical to Python. The connector and API are bundled into `amy.js`, so you only need two includes: ```html ``` ### `amy_send(params)` Build and send an AMY wire message from a JS object. Parameter names and types are the same as Python `amy.send()`. ```js // Play a sine wave at 440 Hz amy_send({osc: 0, wave: AMY.SINE, freq: 440, vel: 1}) // Load a Juno-6 patch amy_send({patch: 0, synth: 1, num_voices: 6}) amy_send({synth: 1, vel: 1, note: 60}) // FM synthesis with CtrlCoef dict amy_send({osc: 0, amp: {const: 1, vel: 0, eg0: 2}, bp0: '0,0,5000,1,0,0'}) ``` ### `amy_message(params)` Like `amy_send` but returns the wire string without sending it. Useful for debugging or building messages to send later. ```js amy_message({osc: 0, wave: AMY.SINE, freq: 440}) // => "v0w0f440Z" ``` ### `AMY` constants All constants from `amy/constants.py` are available on the global `AMY` object: ```js AMY.SINE // 0 AMY.SAW_DOWN // 2 AMY.PULSE // 1 AMY.FILTER_LPF // 1 AMY.ALGO // 8 // ... all constants from amy/constants.py ``` ### Regenerating The JS API is generated during `make web` and bundled into `docs/amy.js` by `make deploy-web`. To regenerate after changing `amy/__init__.py` or `amy/constants.py`: ```bash make deploy-web ``` ### Try it live [**AMY JavaScript REPL**](https://shorepine.github.io/amy/repl.html) — write and run `amy_send()` commands in your browser. ## `amy_config_t` Use like: ```c amy_config_t amy_config = amy_default_config() amy_config.max_sequencer_tags = 128; amy_start(amy_config); ``` | Field | Values | Default | Notes | | ------ | ------ | -------- | -------- | | `features.chorus` | `0=off, 1=on` | On | If chorus is enabled (uses RAM) | | `features.reverb` | `0=off, 1=on` | On | If reverb is enabled (uses RAM) | | `features.echo` | `0=off, 1=on` | On | If echo is enabled (uses RAM) | | `features.partials` | `0=off, 1=on` | On | If partials are enabled | | `features.custom` | `0=off, 1=on` | On | If custom C oscillators are enabled | | `features.audio_in` | `0=off, 1=on` | Off | If audio_in gets processed via the audio interface. Must be 1 for AUDIO_IS_MINIAUDIO | | `features.default_synths` | `0=off, 1=on` | Off| If AMY boots with Juno-6 on `synth` 1 and GM drums on `synth` 10 | | `features.startup_bleep` | `0=off, 1=on` | Off | If AMY plays a startup sound on boot | | `platform.multicore` | `0=off, 1=on` | On | Attempts to use 2nd core if available | | `platform.multithread` | `0=off, 1=on` | On | Attempts to multithreading if available (ESP/RTOS) | | `midi` | `AMY_MIDI_IS_NONE`, `AMY_MIDI_IS_UART`, `AMY_MIDI_IS_USB_GADGET`, `AMY_MIDI_IS_WEBMIDI` | `AMY_MIDI_IS_NONE` | Which MIDI interface(s) are active | | `audio` | `AMY_AUDIO_IS_NONE`, `AMY_AUDIO_IS_I2S`, `AMY_AUDIO_IS_USB_GADGET`, `AMY_AUDIO_IS_MINIAUDIO`| I2S or miniaudio | Which audio interface(s) are active | | `write_samples_fn` | fn ptr | `NULL` | If provided, `amy_update` will call this with each new block of samples | | `max_oscs` | Int | 180 | How many oscillators to support | | `max_sequencer_tags` | Int | 256 | How many sequencer items to handle | | `max_voices` | Int | 64 | How many voices | | `max_synths` | Int | 64 | How many synths | | `max_memory_patches` | Int | 32 | How many in memory patches to supprot | | `i2s_lrc`, `i2s_dout`, `i2s_din`, `i2s_bclk`, `i2s_mclk` | Int | -1 | Pin numbers for the I2S interface | | `midi_out`, `midi_in` | Int | -1 | Pin number for the MIDI UART pins | | `midi_uart` | 0,1,[2] | -1 | UART device index for MCU. Default 1 (`UART1`) on Pi Pico and ESP. Teensy is always `8` | | `capture_device_id`, `playback_device_id` | Int | -1 | Which miniaudio device to use, -1 is auto | ## Hooks Hooks are configured on `amy_config_t` before calling `amy_start`: ```c amy_config_t amy_config = amy_default_config(); amy_config.amy_external_midi_input_hook = my_midi_hook; amy_config.amy_external_render_hook = my_render_hook; amy_start(amy_config); ``` Hook fields in `amy_config_t`: | Hook | Signature | Used by | Description | | ---- | --------- | ------- | ----------- | | `amy_external_render_hook` | `uint8_t (uint16_t osc, SAMPLE *buf, uint16_t len)` | — | Custom oscillator renderer for redirecting the output waveforms on an osc-by-osc level. Return 1 if handled, in which case that osc does not contribute to the normal output. | | `amy_external_coef_hook` | `float (uint16_t channel)` | — | Provide external coefficient values (e.g. CV input). | | `amy_external_block_done_hook` | `void (void)` | — | Called after each audio block is rendered. | | `amy_external_midi_input_hook` | `void (uint8_t *bytes, uint16_t len, uint8_t is_sysex)` | — | Called when MIDI bytes are received. | | `amy_external_sequencer_hook` | `void (uint32_t tick_count)` | — | Called on each sequencer tick. | | `amy_external_fopen_hook` | `uint32_t (char *filename, const char *mode)` | `zT`, `zD`, `zF` | Open a file on host disk. Returns opaque handle. | | `amy_external_fwrite_hook` | `uint32_t (uint32_t fptr, uint8_t *bytes, uint32_t len)` | `zT` | Write bytes to a file opened via fopen hook. | | `amy_external_fread_hook` | `uint32_t (uint32_t fptr, uint8_t *bytes, uint32_t len)` | `zD` | Read bytes from a file opened via fopen hook. | | `amy_external_fseek_hook` | `void (uint32_t fptr, uint32_t pos)` | `zD` | Seek to position in a file opened via fopen hook. | | `amy_external_fclose_hook` | `void (uint32_t fptr)` | `zT`, `zD`, `zF` | Close a file opened via fopen hook. | | `amy_external_file_transfer_done_hook` | `void (const char *filename)` | `zT` | Called after a `zT` file transfer completes. On AMYboard, restarts sketch.py. | | `amy_external_update_file_hook` | `void (const char *filename)` | `zA` | Called by `zA` to update a file with current AMY state. On AMYboard, splices live knob state into sketch.py. | | `amy_external_exec_hook` | `void (const char *code)` | `zP` | Called by `zP` to execute a string on the host. On AMYboard, runs the string as Python via `exec()`. | | `amy_external_reboot_hook` | `void (uint8_t mode)` | `zB` | Called by `zB` to reboot the host. `mode` selects which post-reboot state: `0` = bootloader (skip sketch on next boot), `1` = normal reboot (run sketch), `2` = ROM download / flash mode. Handled in pure C before `mp_sched_schedule`. On AMYboard, sets an RTC flag with the requested mode and calls `esp_restart()`. | All hook fields default to `NULL` in `amy_default_config()`. ## `amy_event`, `amy.send`, and `amy_send` API: AMY parameters can be set via three interfaces: - **C**: Set fields on `amy_event` structs - **Python**: `amy.send(param=value, ...)` - **JavaScript**: `amy_send({param: value, ...})` Python and JavaScript use identical parameter names (shown in the **Python / JS** column below). A few parameters are not yet available via C `amy_event` (marked **TODO**). Please see [AMY synthesizer details](synth.md) for more explanation on the synthesizer parameters. [**Please see our interactive AMY tutorial for more tips on using AMY**](https://shorepine.github.io/amy/tutorial.html) A note on list parameters: When an argument is a list of parameters, you can in general set any subset of those parameters by omitting the values you don't want to change - either by leaving them in their initial `AMY_UNSET` value in C, or by having missing values in Python lists. For instance, you can set up an envelope that moves immediately to 1, then decase to a sutain level of 0.5 over 200ms, then has a 300ms decay to zero on note-off, with `bp0='0,1,200,0.5,300,0'. Subsequently, you could change just the sustain level (the 4th value in the list) to 0.2 with `bp0=,,,0.2`. However, there's at present no way to say ".. and the list should now only be 4 items long. This only affects breakpoint sets which are variable length, but the net result is that once you have a certain number of breakpoints in a list, you cannot shorten it except by resetting the whole osc and building it all up again. ### `synth`s and `voice`s: | Wire code | C `amy_event` | Python / JS | Type-range | Notes | | ------ | -------- | ---------- | ---------- | ------------------------------------- | | `i` | `synth` | `synth` | 0-31 | Define a set of voices for voice management. | | `ic` | **TODO** | `midi_cc` | C,L,N,X,O,CMD | MIDI Control Code command for this synth (1-16). `C`=MIDI CC (0-127), `L`=log mapping (0/1), `N`=min val, `X`=max val, `O`=offset, `CMD`=wire command to execute, where `%i` is replaced by the channel number and `%v` is replaced by the value after min/max/offset/log mapping. Providing `C` with no further args deletes that CC. `C=255` deletes all CC mappings for the specified synth. See [#524](https://github.com/shorepine/amy/issues/524) | | `if` | `synth_flags` | `synth_flags` | uint | Flags for synth creation: 1 = Use MIDI drum note->preset translation; 2 = Drop note-off events. | | `id` | `synth_delay_ms` | `synth_delay` | uint | Delay (in ms) applied to synth note-ons. Gives time for decay of 'stolen' notes. | | `it` | `to_synth` | `to_synth` | 0-31 | New synth number, when changing the number (MIDI channel for n=1..16) of an entire synth. | | `iv` | `num_voices` | `num_voices` | int | The number of voices to allocate when defining a synth, alternative to directly specifying voice numbers with `voices=`. Only valid with `synth=X, patch[_number]=Y`. | | `in` | `oscs_per_voice` | `oscs_per_voice` | >0 | Reserve this many oscs for each voice. Needed when initializing a synth (or voice) withouth an initial patch. Setting `oscs_per_voice` on an existing synth resets all oscs to their default state. | | `im` | `grab_midi_notes` | `grab_midi_notes` | 0/1 | Use `amy.send(synth=CHANNEL, grab_midi_notes=0)` to prevent the default direct forwarding of MIDI note-on/offs to synth CHANNEL. | | `ip` | `pedal` | `pedal` | int | Non-zero means pedal is down (i.e., sustain). Must be used with `synth`. | | `K` | `patch_number` | `patch` | uint 0-X | Apply a saved or user patch to a specified synth or voice. | | `r` | `voices[]` | `voices` | int[,int] | Comma separated list of voices to send message to, or load patch into. | | `u` | **TODO**| `patch_string` | string | Provide AMY message to define up to 32 patches in RAM with ID numbers (1024-1055) provided via `patch_number`, or directly configure a `synth`. | ### Oscillator control | Wire code | C `amy_event` | Python / JS | Type-range | Notes | | ------ | -------- | ---------- | ---------- | ------------------------------------- | | `v` | `osc` | `osc` | uint 0 to OSCS-1 | Which oscillator to control | | `w` | `wave` | `wave` | uint 0-21 | Waveform: [0=SINE, PULSE, SAW_DOWN, SAW_UP, TRIANGLE, NOISE, KS, PCM, ALGO, PARTIAL, BYO_PARTIALS, INTERP_PARTIALS, AUDIO_IN0, AUDIO_IN1, AUDIO_EXT0, AUDIO_EXT1, AMY_MIDI, PCM_LEFT, PCM_RIGHT, WAVETABLE, CUSTOM, OFF]. default: 0/SINE | | `S` | `reset_osc`| `reset` | uint | Resets given oscillator. set to RESET_ALL_OSCS to reset all oscillators, gain and EQ. RESET_TIMEBASE resets the clock (immediately, ignoring `time`). RESET_AMY restarts AMY. RESET_SEQUENCER clears the sequencer.| | `A` | `eg0_times[]`, `eg0_values[]` | `bp0` | string (wire) / arrays (`amy_event`) | Envelope Generator 0 breakpoints as time(ms),value pairs. Wire/Python format remains comma-separated, e.g. `100,0.5,50,0.25,200,0`. In C `amy_event`, use typed arrays (`eg0_times[i]`, `eg0_values[i]`). The last pair is release (triggers on note off). | | `B` | `eg1_times[]`, `eg1_values[]` | `bp1` | string (wire) / arrays (`amy_event`) | Envelope Generator 1 breakpoints. Wire/Python format remains comma-separated; in C `amy_event`, use typed arrays (`eg1_times[i]`, `eg1_values[i]`). | | `b` | `feedback` | `feedback` | float 0-1 | Use for the ALGO synthesis type in FM or for karplus-strong, or to indicate PCM looping (0 off, >0, on) | | `c` | `chained_osc` | `chained_osc` | uint 0 to OSCS-1 | Chained oscillator. Note/velocity events to this oscillator will propagate to chained oscillators. VCF is run only for first osc in chain, but applies to all oscs in chain. | | `G` | `filter_type` | `filter_type` | 0-4 | Filter type: 0 = none (default.) 1 = lowpass, 2 = bandpass, 3 = highpass, 4 = double-order lowpass. | | `I` | `ratio` | `ratio` | float | For ALGO types, ratio of modulator frequency to base note frequency | | `L` | `mod_source` | `mod_source` | 0 to OSCS-1 | Which oscillator is used as an modulation/LFO source for this oscillator. Source oscillator will be silent. | | `m` | `portamento`| `portamento` | uint | Time constant (in ms) for pitch changes when note is changed without intervening note-off. default 0 (immediate), 100 is good. | | `n` | `midi_note` | `note` | float, but typ. uint 0-127 | Midi note, sets frequency. Fractional Midi notes are allowed. | | `o` | `algorithm` | `algorithm` | uint 1-32 | DX7 FM algorithm to use for ALGO type | | `O` | `algo_source[]`| `algo_source` | string | Which oscillators to use for the FM algorithm. list of six (starting with op 6), use empty for not used, e.g 0,1,2 or 0,1,2,,, | | `p` | `preset` | `preset` | int | Which predefined PCM or wavetable preset patch to use, or number of partials if < 0. For `wave=WAVETABLE`, use the wavetable presets appended to PCM. (Juno/DX7 patches are different - see `patch_number`). | | `p` | `preset` | `num_partials` | int | Alias for `preset`. Must be used with `wave=BYO_PARTIALS`. Cannot be combined with `preset` in the same message. | | `P` | `phase` | `phase` | float 0-1 | Where in the oscillator's cycle to begin the waveform (also works on the PCM buffer). default 0 | | `R` | `resonance` | `resonance` | float | Q factor of variable filter, 0.5-16.0. default 0.7 | | `T` | `eg_type[0]` | `eg0_type` | uint 0-3 | Type for Envelope Generator 0 - 0: Normal (RC-like) / 1: Linear / 2: DX7-style / 3: True exponential. | | `X` | `eg_type[1]` | `eg1_type` | uint 0-3 | Type for Envelope Generator 1 - 0: Normal (RC-like) / 1: Linear / 2: DX7-style / 3: True exponential. | | `l` | `velocity` | `vel` | float | Note on velocity. Use to start an envelope or set amplitude | ### CtrlCoefs These per-oscillator parameters use [CtrlCoefs](synth.md) notation | Wire code | C `amy_event` | Python / JS | Type-range | Notes | | ------ | -------- | ---------- | ---------- | ------------------------------------- | | `Q` | `pan_coefs[]` | `pan` | float[,float...] | Panning index ControlCoefficients (for stereo output), 0.0=left, 1.0=right. default 0.5. | | `a` | `amp_coefs[]` | `amp` | float[,float...] | Control the amplitude of a note; a set of ControlCoefficients. Default is 0,0,1,1 (i.e. the amplitude comes from the note velocity multiplied by by Envelope Generator 0.) | | `d` | `duty_coefs[]` | `duty` | float[,float...] | Duty cycle for pulse wave, ControlCoefficients, defaults to 0.5 | | `f` | `freq_coefs[]` | `freq` | float[,float...] | Frequency of oscillator, set of ControlCoefficients. Default is 0,1,0,0,0,0,1 (from `note` pitch plus `pitch_bend`) | | `F` | `filter_freq_coefs[]` | `filter_freq` | float[,float...] | Center/break frequency for variable filter, set of ControlCoefficients | ### PCM sampling | Wire code | C `amy_event` | Python / JS | Type-range | Notes | | ------ | -------- | ---------- | ---------- | ------------------------------------- | | `z` | **TODO**| `load_sample` | uint x 6 | Signal to start loading sample. preset number, length(frames), samplerate, channels, midinote, loopstart, loopend. All subsequent messages are base64 encoded WAVE-style frames of audio until `length` is reached. Set `preset` and `length=0` to unload a sample from RAM. | | `zF` | **TODO**| `disk_sample` | uint,string,uint | Set a PCM preset to play live from a WAV filename on AMY host disk. Params: preset number, filename, midinote. See `hooks` for reading files on host disk. **Only one file sample can be played at once per preset number. Use multiple presets if you want polyphony from a single sample.** | | `zS` | **TODO**| `start_sample` | uint x 6 | Start sampling to a stereo PCM preset from bus. Params: preset number, bus, max length in frames, midinote, loopstart, loopend. bus = 1 is AMY mixed output. bus = 2 is AUDIO_IN0 + 1. Will sample until max length is reached, `stop_sample` is issued, or a new `start_sample` is issued. | | `zO` | **TODO**| `stop_sample` | uint | Stop sampling. Does nothing if no sampling active. param ignored. | ### WAVETABLE wave type `wave=WAVETABLE` is available when AMY is built with `-DAMY_WAVETABLE`. - Wavetable samples are baked into `pcm_tiny` and exposed as contiguous PCM presets. - The preset range is dynamic at runtime: - start: `pcm_wavetable_base` - count: `pcm_wavetable_samples` - valid presets: `pcm_wavetable_base ... pcm_wavetable_base + pcm_wavetable_samples - 1` - Each wavetable preset is expected to be one 64-cycle table (normally `16384` samples total, `256` samples per cycle). - `duty` crossfades across the 64 cycles inside the selected wavetable preset. ### Other | Wire code | C `amy_event` | Python / JS | Type-range | Notes | | ------ | -------- | ---------- | ---------- | ------------------------------------- | | `H` | `sequence[3]` | `sequence` | int,int,int | Tick offset, period, tag for sequencing | | `h` | `reverb_level, reverb_liveness, reverb_damping, reverb_xover_hz` | `reverb` | float[,float,float,float] | Reverb parameters -- level, liveness, damping, xover: Level is for output mix; liveness controls decay time, 1 = longest, default 0.85; damping is extra decay of high frequencies, default 0.5; xover is damping crossover frequency, default 3000 Hz. | | `j` | `tempo` | `tempo` | float | The tempo (BPM, quarter notes) of the sequencer. Defaults to 108.0. | | `k` | `chorus_level, chorus_max_delay, chorus_lfo_freq, chorus_depth` | `chorus` | float[,float,float,float] | Chorus parameters -- level, delay, freq, depth: Level is for output mix (0 to turn off); delay is max in samples (320); freq is LFO rate in Hz (0.5); depth is proportion of max delay (0.5). | | `M` | `echo_level, echo_delay_ms, echo_max_delay_ms, echo_feedback, echo_filter_coef` | `echo` | float[,int,int,float,float] | Echo parameters -- level, delay_ms, max_delay_ms, feedback, filter_coef (-1 is HPF, 0 is flat, +1 is LPF). | | `N` | `latency_ms`| `latency_ms` | uint | Sets latency in ms. default 0 (see LATENCY) | | `s` | `pitch_bend` | `pitch_bend` | float | Sets the global pitch bend, by default modifying all note frequencies by (fractional) octaves up or down | | `t` | `time` | `time` | uint | Request playback time relative to some fixed start point on your host, in ms. Allows precise future scheduling. | | `V` | `volume`| `volume` | float 0-10 | Volume knob for entire synth, default 1.0 | | `x` | `eq_l, eq_m, eq_h` |`eq` | float,float,float | Equalization in dB low (~800Hz) / med (~2500Hz) / high (~7500Gz) -15 to 15. 0 is off. default 0. | | `g` | `client` | `client` | uint | Client number for Alles distributed synthesis. | | `W` | `external_channel` | `external_channel` | uint | External channel routing (used by Tulip for CV output). | | `D` | **TODO** | `debug` | uint, 2-4 | 2 shows queue sample, 3 shows oscillator data, 4 shows modified oscillator. Will interrupt audio! | | `zT` | **TODO**| `transfer_file` | string,uint | Transfer a file to the host. Params: destination filename, file size. See `hooks` for writing files on host disk. | | `zA` | **TODO**| `update_file` | string (optional) | Update a file on disk with current AMY state via `update_file_hook`. Default path: `/user/current/sketch.py`. On AMYboard, splices `_auto_generated_knobs` section with live state. The filename is "rest of message": a trailing `Z` end-of-message marker is stripped, so interior capital-`Z` characters (e.g. `/user/ZFILE.py`) are preserved. Filenames whose last character is `Z` are not addressable. | | `zD` | **TODO**| `dump_sysex` | string (optional) | Dump data over MIDI sysex (base64-encoded, wrapped with SPSS manufacturer ID `00 03 45`). With no params (`zDZ`): dumps all active instrument state. With a filename (`zD/user/current/sketch.pyZ`): reads file and sends it. The filename is "rest of message": a trailing `Z` end-of-message marker is stripped, so interior capital-`Z` characters (e.g. `/user/ZFILE.py`) are preserved. Filenames whose last character is `Z` are not addressable. | | `zP` | **TODO**| `exec` | string | Execute code on the host via `amy_external_exec_hook`. On AMYboard, runs the string as Python (e.g. `zPimport amyboard; amyboard.restart_sketch()`). Max 255 chars. The code string is "rest of message": a trailing `Z` end-of-message marker is stripped, so interior capital-`Z` characters in the code are preserved. Code whose last character is `Z` is not expressible. | | `zI` | **TODO**| `ping` | (none) | Ping the host. Replies with a short sysex frame `F0 00 03 45 'O' 'K' F7` so the caller can confirm the board is alive and sysex is flowing. Handled entirely in pure C (no scheduler needed). | | `zB` | **TODO**| `reboot` | uint (optional) | Reboot the host via `amy_external_reboot_hook`. Optional `mode` argument selects the post-reboot state: `zBZ` / `zB0Z` = bootloader mode (skip sketch on next boot), `zB1Z` = normal reboot (run sketch), `zB2Z` = ROM download / flash mode. Handled in pure C (no scheduler needed). On AMYboard, sets an RTC flag with the mode and calls `esp_restart()`. | ================================================ FILE: docs/arduino.md ================================================ # Arduino Setup for AMY AMY is on the Arduino Libraries repository. Simply search for "AMY" in the Library Manager and you should find us! You can run AMY on many types of Arduino boards. The simplest way is to get our new [AMYboard](https://amyboard.com) which is only US$29 and has a lot of great built-in features. But AMY also runs great on - Any esp32, esp32-s3, esp32-p4 or esp32-c6 - Teensy 4.x - Pi Pico RP2350 or RP2040 We recommend always using the latest released version in the Arduino Library Manager. However, if you are directed to a bleeding edge release of AMY, you can simply copy this repository to your `Arduino/libraries` folder as `Arduino/libraries/amy`. (Make sure you delete whatever you already had in `libraries/amy`.) To use AMY in Arduino, just `#include `. You need at a minimum the following code in your sketch, a call to `amy_start` with some options set in an `amy_config_t`, and then a call to `amy_update()` somewhere in your `loop()`. ```c #include void setup() { // .. in your setup ... amy_config_t amy_config = amy_default_config(); // set your pins, etc -- see the AMY_MIDI_Synth example amy_start(amy_config); } void loop() { // Your loop() must contain this call to amy: amy_update(); } ``` AMY in Arduino handles MIDI input and output as well as I2S and USB (where supported) audio. You do not need to set up an I2S interface, just the pins in `amy_config`. (For experts: if you're rendering AMY audio to your own audio hardware, you can set `amy_config.audio = AMY_AUDIO_IS_NONE` before calling `amy_start()`, then use the return value from `amy_update()` as a pointer to the next block of `AMY_BLOCK_SIZE` 16 bit stereo sample frames, to send out to whatever interface you set up.) [Please see our latest matrix of supported features per chip/board.](https://github.com/shorepine/amy/issues/354) We ship a single example in the Examples folder for AMY called `AMY_MIDI_Synth`. It receives MIDI input and plays a Juno-6 patch 0 in response. should work on all our supported boards. Make sure you've installed the board support package for the board / chip you are using: * RP2040 / RP2350 / Pi Pico: [`arduino-pico`](https://arduino-pico.readthedocs.io/en/latest/install.html#installing-via-arduino-boards-manager) * Teensy: [`teensyduino`](https://www.pjrc.com/teensy/td_download.html) * ESP32 / ESP32-S3 / etc: [`arduino-esp32`](https://espressif-docs.readthedocs-hosted.com/projects/arduino-esp32/en/latest/installing.html) You can use both cores of supported chips (RP2040, RP2350 or ESP32 variants) for more oscillators and voices. Once you've confirmed AMY is running on your chip, read our [tutorial](tutorial.html) or our [getting started](../README.md) page on how to control AMY in Arduino: ```c // Will play MIDI note 50 on patch 130 amy_event e = amy_default_event(); e.osc = 0; e.patch_number = 130; e.velocity = 1; e.midi_note = 50; e.voices[0] = 0; amy_add_event(&e); ``` ## Recommended DAC / ADC configurations The supported microcontrollers (excepting the Daisy, which is built in) use I2S as the default audio interface. I2S is a standard but some chips / boards may require setup beyond just wiring up the pins. For example, the [`WM8960`](https://www.waveshare.com/wiki/WM8960_Audio_HAT) and the `PCM9211` require registers to be set to route audio signals and amplification. We can recommend simpler audio out DACs that "just work" with AMY with no extra setup: * [PCM5101 / PCM5102](https://www.amazon.com/dp/B0DCGF2TN1?th=1) * [UDA1334](https://www.adafruit.com/product/3678) ### Audio input DACs Here's an example of a PCM1808 and PCM5101 working together to provide audio in and out for AMY on an ESP32S3: ## Per-board notes ### AMYboard Our built-for-AMY board [AMYboard](https://amyboard.com) should just work out of the box. You can find AMYboard in the Boards list of the espressif arduino-esp32 package. See the specific [AMYboard Arduino details](https://github.com/shorepine/tulipcc/blob/main/docs/amyboard/arduino.md) for more information. ### ESP32, ESP32-S3, ESP32-P4 Tested: Arduino IDE 2.3.6 (mac) + arduino-esp32 3.2.0 ### Teensy 4.0, 4.1 Tested: Arduino IDE 2.3.6 (mac) + [Teensy 1.59.0](https://www.pjrc.com/teensy/teensyduino.html) USB audio and i2s audio output happen at the same time if you set USB Type to Audio, it will appear as a USB audio device on your computer, called "AMY Synthesizer" Note: USB audio from Teensy is fiddly and often slow to enumerate, i have to wait a minute or two before it shows up on my Mac. This seems to be unrelated to AMY. Please ask on the Teensy forums if you're having trouble with USB Audio. Once it is enumerated and running, it does seem stable. For I2S, you have to use the default i2s1 pins. The pins you set in AMY config are ignored. That's `21 -> BLCK`, `20 -> LRC`, `DOUT -> 7`. This works with the [Teensy Audio Shield](https://www.pjrc.com/store/teensy3_audio.html) and the simpler [PT8211](https://www.pjrc.com/store/pt8211_kit.html). It will also work with other I2S DAC boards. For UART MIDI, we use Serial8, the pins you set in AMY config are ignored. That's `MIDI_OUT -> 35`, `MIDI_IN -> 34`. ### Pi Pico RP2040 and Pi Pico 2 RP2350 Tested: Arduino IDE 2.3.6 (mac) The `i2s_lrc` pin has to be `i2s_bclk` + 1. ### Electro-Smith Daisy Seed The Daisy works great with AMY. However, it does not work with the Arduino [DaisyDuino](https://daisy.audio/tutorials/arduino-dev-env/#welcome-to-daisyduino). The size of AMY plus the size of the DaisyDuino support exceeds the segment size that DaisyDuino currently supports. We hope they fix this! [See this thread for more information.](https://forum.electro-smith.com/t/arduino-how-to-use-512k-ram-area-for-program-space/4839). To use your Daisy with AMY, [you first have to set up the C/C++ toolchain.](https://daisy.audio/tutorials/cpp-dev-env/#follow-along-with-the-video-guide) It supports audio in, serial MIDI in, AMY sequencer. To use, get our [amy_daisy.cpp](https://github.com/shorepine/amy/raw/main/daisy/amy_daisy.cpp) and [Makefile](https://github.com/shorepine/amy/raw/main/daisy/Makefile), set your location of AMY in the `Makefile`, then set up your Daisy dev environment, then put the board into DFU mode, and run ``` make clean && make && make program-boot; sleep 1.5; make program-dfu ``` After it flashes, you should hear the AMY startup chime from the Daisy's line out. If you have a MIDI serial interface hooked up to the Daisy (D14 USART1Rx) you should be able to play the default Juno synth on channel 1. ================================================ FILE: docs/billie_jean.md ================================================ # Making "Billie Jean" with AMY_Arduino dan.ellis@gmail.com 2025-11-03 AMY is a music synthesizer library that allows you to generate studio-quality music with your microcontroller. It consists of a flexible synthesis engine capable of analog synthesizer emulation, FM-style sounds, additive synthesis, etc., as well as higher-level functions like MIDI input and polyphonic voice management. AMY can be controlled via a Micropython interface (it’s an important part of the [Tulip Creative Computer](https://tulip.computer)), but you can also drive it directly from C/C++. This tutorial shows you how to use AMY from Arduino to generate music audio. It’s inspired by the “Billie Jean” example that Floyd Steinberg [demo’d on the original Alles](https://youtu.be/8CmcsQXHVEo?si=VAA65qPmHA-Fq4k9). ## AMY Concepts At the highest level, AMY provides a “synth” interface where you send note events and configuration commands to individual polyphonic synthesizers, which also automatically handle MIDI events if MIDI input is configured. Each synth manages a set of a specific number of “voices”; A voice can generate one note event at a time. If the synth is configured with one voice, it is monophonic, so each successive note event changes its pitch. But you can configure each synth to have more voices so it can play chords polyphonically. The synth layer handles the reallocation of the voices (“voice stealing”) if there are too many active notes for the number of voices. A single voice consists of one or more “oscs” (oscillators). Oscillators are the basic building block in AMY, and include a single waveform generator (oscillator with a specific waveform, PCM sample, or external audio input) along with modulation, filtering, etc. Depending on your hardware and the complexity of processing, AMY can support more than 100 simultaneously-sounding oscillators, which might be configured as 12 analog synth voices, or six, 24-partial additive piano voices. Each osc within a voice may have a lot of individual parameters, but all the voices managed by a single synth will be identically configured, and you send the osc configuration commands to the synth, which then updates the oscs in all its voices. It’s possible to directly address individual oscs and voices using the AMY interface, but in most cases it’s easiest to control AMY through the synth layer. ## Playing a repeating pattern [Arduino Setup for AMY](https://github.com/shorepine/amy/blob/main/docs/arduino.md) covers configuring a microcontroller board to run AMY under the Arduino IDE. Once you have that ready, you should see three sketches with names beginning `BillieJean` in the Arduino `Examples > AMY Synthesizer` submenu. Open [BillieJeanDrums](https://github.com/shorepine/amy//blob/main/examples/BillieJeanDrums/BillieJeanDrums.ino), our first example sketch. This sketch uses AMY to play a simple repeating drum pattern using AMY’s built-in PCM drum samples. The `setup()` function configures and starts the AMY engine. We select the `default_synths`, which includes emulation of a MIDI drum machine on synth 10: ```C // BillieJeanDrums - Making a simple drum pattern with AMY. #include void setup() { amy_config_t amy_config = amy_default_config(); amy_config.features.startup_bleep = 1; // Install the default_synths on synths (MIDI chans) 1, 2, and 10. amy_config.features.default_synths = 1; amy_config.audio = AMY_AUDIO_IS_I2S; // Pins for i2s board amy_config.i2s_bclk = 8; amy_config.i2s_lrc = 9; amy_config.i2s_dout = 10; amy_start(amy_config); } ``` Now AMY is ready to play notes in response to note-on events: ```C // Time to play the note. amy_event e = amy_default_event(); e.synth = 10; // drums channel e.midi_note = midi_note; e.velocity = velocity; amy_add_event(&e); ``` The `midi_note` is usually a number that sets the pitch of a note, using the MIDI convention where 60 is middle C, 61 is C#, etc. For the drums channel, though, each note number corresponds to a different drum sound, so 35 is the bass drum, 42 is the closed hi-hat, etc. The `velocity` is how “hard” the note is played, i.e. it determines how loud it is. `amy_add_event()` is the main way to send commands (both note events and configuration) to AMY. To play a drum pattern, we need to send a series of events to AMY to command each note event at the appropriate time. We’ll need a table of data defining our desired pattern: ```C struct timed_note { float start_time; // In ticks int note; float velocity; }; // 35 is kick, 37 is snare, 42 is closed hat, 46 is open hat // Notes must be sorted in start_time order. timed_note notes[] = { { 0.0, 42, 1.0}, // 0 HH + BD { 0.0, 35, 1.0}, { 1.0, 42, 1.0}, // 1 HH { 2.0, 42, 1.0}, // 2 HH + SN { 2.0, 37, 1.0}, { 3.0, 42, 1.0}, // 3 HH { 4.0, 42, 1.0}, // 4 HH + BD { 4.0, 35, 1.0}, { 5.0, 42, 1.0}, // 5 HH { 6.0, 42, 1.0}, // 6 HH + SN { 6.0, 37, 1.0}, { 7.0, 46, 1.0}, // 7 OH }; // Time (in ticks) at which we reset to the start of the table. float cycle_len = 8.0; ``` We define a `timed_note` data structure to hold the time, the note number, and the velocity for each event, then we set up a table with a simple drum pattern using bass drum (kick), snare drum, and closed and open hi-hat. The times of each event are specified in “ticks”, corresponding to a quarter-note in this 2 bar pattern. We also specify that the pattern repeats after 8 ticks in `cycle_len`. Note that there are multiple events at some times (0, 2, 4, 6 ticks). Also notice that the table is sorted by `start_time` - this means we can step through it note by note without having to check for out-of-sequence notes. Now we can set up the loop to keep “tick” time and step through the note table, sending the note events to AMY at the appropriate times: ```C float millis_per_tick = 250; float base_tick = 0; // Time of beginning of current cycle. int note_tab_index = 0; int note_tab_len = sizeof(notes) / sizeof(timed_note); void loop() { // Your loop() must contain this call to amy: amy_update(); // Calculate "tick time" and choose note. float tick_in_cycle = millis() / millis_per_tick - base_tick; if (tick_in_cycle >= cycle_len) { // Start the next cycle - reset the cycle base_tick, reset the note_tab index. tick_in_cycle -= cycle_len; base_tick += cycle_len; note_tab_index = 0; } ``` `millis_per_tick` sets the tempo of our pattern, setting the duration of each tick. Here, we’ve defined a tick to be 250 milliseconds (a quarter of a second), for a 120 bpm feel. In the `loop()` function, we calculate `tick_in_cycle` - the current time relative to the start of the current cycle - by scaling Arduino’s `millis()` counter by `millis_per_tick`, then subtracting `base_tick`, the absolute time, in ticks, of the start of the currently-playing cycle. If `tick_in_cycle` is equal or larger than the `cycle_len`, we reset our index into the notes table, `note_tab_index`, to the beginning of the table, and move on the `base_tick` by one complete `cycle_len`. Finally, we send any note events from the table whose time has come: ```C // Play any notes for this moment from the note table. while(note_tab_index < note_tab_len && tick_in_cycle >= notes[note_tab_index].start_time) { // Grab the note parameters int midi_note = notes[note_tab_index].note; float velocity = notes[note_tab_index].velocity; // Time to play the note. amy_event e = amy_default_event(); e.synth = 10; // drums channel e.midi_note = midi_note; e.velocity = velocity; amy_add_event(&e); note_tab_index++; } ``` As long as our `note_tab_index` hasn’t run off the end of the table (as held in `note_tab_len`), and if the current `tick_in_cycle` is equal to or just past the `start_time` of that event from the table, we send an event with the corresponding `midi_note` and `velocity` to `amy_add_event()`, and move on to look at the next entry in the table by incrementing `note_tab_index`. That’s it! Running this sketch should immediately start a short drum pattern which will repeat indefinitely. ## Adding another instrument Drums are great, but we need more. Open the sketch [BillieJeanDrumsBass](https://github.com/shorepine/amy/blob/main/examples/BillieJeanDrumsBass/BillieJeanDrumsBass.ino) to see how we add the bass line. Firstly, we extend our setup to define `synth` 2 as a monophonic synth configured with one of the built-in Juno bass patches: ```C // Set up synth 2 as monophonic bass amy_event e = amy_default_event(); e.synth = 2; e.patch_number = 30; // Juno A47 Funky I e.num_voices = 1; amy_add_event(&e); ``` We’re now going to have multiple instruments in our table, so we add a `channel` field to our `timed_note` structure, and add the bass notes to the table: ```C struct timed_note { float start_time; // In ticks int channel; // 10 = drums, 2 = bass int note; float velocity; }; // Notes must be sorted in start_time order. timed_note notes[] = { { 0.0, 2, 43, 0.2}, // bass G2 { 0.0, 10, 42, 1.0}, // 0 HH + BD { 0.0, 10, 35, 1.0}, { 1.0, 2, 38, 0.2}, // bass D2 { 1.0, 10, 42, 1.0}, // 1 HH { 2.0, 2, 41, 0.2}, // bass F2 { 2.0, 10, 42, 1.0}, // 2 HH + SN { 2.0, 10, 37, 1.0}, { 3.0, 2, 43, 0.2}, // bass G2 { 3.0, 10, 42, 1.0}, // 3 HH { 4.0, 2, 41, 0.2}, // bass F2 { 4.0, 10, 42, 1.0}, // 4 HH + BD { 4.0, 10, 35, 1.0}, { 5.0, 2, 38, 0.2}, // bass D2 { 5.0, 10, 42, 1.0}, // 5 HH { 6.0, 2, 36, 0.2}, // bass C2 { 6.0, 10, 42, 1.0}, // 6 HH + SN { 6.0, 10, 37, 1.0}, { 7.0, 2, 38, 0.2}, // bass D2 { 7.0, 10, 46, 1.0}, // 7 OH }; // Time (in ticks) at which we reset to the start of the table. float cycle_len = 8.0; ``` Now we simply modify the code that sends the AMY events to also read the channel (i.e., the synth to which the note is directed) from the table: ```C // Play any notes for this moment from the note table. while(note_tab_index < note_tab_len && tick_in_cycle >= notes[note_tab_index].start_time) { // Time to play the note. amy_event e = amy_default_event(); e.synth = notes[note_tab_index].channel; e.midi_note = notes[note_tab_index].note; e.velocity = notes[note_tab_index].velocity; amy_add_event(&e); note_tab_index++; } ``` That’s it. Now we have both bass and drums. ## Using the AMY scheduler So far, we’ve been using AMY in “real time” - we time the note events by sending the `amy_add_event()` command just when we want the note to occur. This is not always convenient or precise, so AMY includes a scheduler so you can specify exactly *when* your new event is supposed to occur. Using the scheduler, we can send a bunch of note events all at once, including their timing, then sit back and wait as AMY works through the timeline - we don’t have to worry about implementing the timing in our `loop()` function. The third version, [BillieJeanScheduled](https://github.com/shorepine/amy/blob/main/examples/BillieJeanScheduled/BillieJeanScheduled.ino), uses AMY scheduling. Because we’re adding chords, we need to configure an additional synth. And just to make it sound a little more like the original, we also turn on AMY’s built-in reverb: ```C // Reconfigure synth 1 as a 6-note polyphonic synth (for chords) amy_event e = amy_default_event(); e.synth = 1; e.patch_number = 5; // Juno A16 Brass & Strings e.num_voices = 6; amy_add_event(&e); // Reconfigure synth 2 as monophonic bass e = amy_default_event(); e.synth = 2; e.patch_number = 30; // Juno A47 Funky I e.num_voices = 1; amy_add_event(&e); // Turn on reverb config_reverb(0.5f, 0.85f, 0.5f, 3000.0f); ``` This version tells AMY exactly what time (in milliseconds) it wants each note to occur. Because of this, we can send all the notes for an entire cycle at once (we could probably send an entire track at once, but for convenience we do it one cycle at a time), and we don’t have to worry about issuing them in order, so we can have different tables for the different instruments. This means we don’t store the channel (synth) number in the table, but it also means we can specify the duration for the non-drum notes because we can also schedule note-offs for each note we send: ```C struct timed_note { float start_time; // In ticks float duration; // In ticks int note; float velocity; }; // Cycle length (in ticks) for drums + bass float cycle_len = 8.0; // Drum notes have durations of 0 for no note-off timed_note drum_notes[] = { { 0.0, 0.0, 42, 1.0}, // 0 HH + BD { 0.0, 0.0, 35, 1.0}, { 1.0, 0.0, 42, 1.0}, // 1 HH { 2.0, 0.0, 42, 1.0}, // 2 HH + SN { 2.0, 0.0, 37, 1.0}, { 3.0, 0.0, 42, 1.0}, // 3 HH { 4.0, 0.0, 42, 1.0}, // 4 HH + BD { 4.0, 0.0, 35, 1.0}, { 5.0, 0.0, 42, 1.0}, // 5 HH { 6.0, 0.0, 42, 1.0}, // 6 HH + SN { 6.0, 0.0, 37, 1.0}, { 7.0, 0.0, 46, 1.0}, // 7 OH }; timed_note bass_notes[] = { { 0.0, 0.6, 43, 0.2}, // bass G2 { 1.0, 0.6, 38, 0.2}, // bass D2 { 2.0, 0.6, 41, 0.2}, // bass F2 { 3.0, 0.6, 43, 0.2}, // bass G2 { 4.0, 0.6, 41, 0.2}, // bass F2 { 5.0, 0.6, 38, 0.2}, // bass D2 { 6.0, 0.6, 36, 0.2}, // bass C2 { 7.0, 0.6, 38, 0.2}, // bass D2 }; timed_note chord_notes[] = { { 0.0, 0.2, 70, 1.0}, // Fmin:1 { 0.0, 0.2, 74, 1.0}, { 0.0, 0.2, 79, 1.0}, { 3.0, 0.2, 72, 1.0}, // Amin:1 { 3.0, 0.2, 76, 1.0}, { 3.0, 0.2, 81, 1.0}, { 8.0, 0.2, 74, 1.0}, // Bb:1 { 8.0, 0.2, 77, 1.0}, { 8.0, 0.2, 82, 1.0}, { 11.0, 0.2, 72, 1.0}, // Amin:1 { 11.0, 0.2, 76, 1.0}, { 11.0, 0.2, 81, 1.0}, }; ``` We have a new function that takes an entire table of `timed_notes` along with a start time offset and a channel (synth), and schedules them all, including note-offs if the table includes nonzero note durations. Note we reuse some fields in the `amy_event` structure. ```C void schedule_notes(int time, int channel, struct timed_note *notes, int num_notes) { amy_event e = amy_default_event(); e.synth = channel; for (int i = 0; i < num_notes; ++i) { e.midi_note = notes[i].note; e.velocity = notes[i].velocity; e.time = time + millis_per_tick * notes[i].start_time; amy_add_event(&e); // Add note-off too if duration > 0 if (notes[i].duration > 0) { e.time += millis_per_tick * notes[i].duration; e.velocity = 0; amy_add_event(&e); } } } ``` Now the main `loop()` simply spins (while calling `amy_update()`) until the timing indicates that we’re beginning a new cycle of the music, then issues all the notes associated with that cycle as it begins. We take advantage of this to gradually build the music, starting with the drums, then bringing in the bass, then finally the chords: ```C int start_millis = 3000; int last_cycle = -1; void loop() { // Let amy do its processing for this moment. amy_update(); int now = millis(); int current_cycle = floor((now - start_millis) / (millis_per_tick * cycle_len)); if (current_cycle > last_cycle) { // A new cycle began, issue notes. // Drums schedule_notes(now, 10, drum_notes, sizeof(drum_notes) / sizeof(timed_note)); // Bass comes in after two cycles of drums if (current_cycle >= 2) schedule_notes(now, 2, bass_notes, sizeof(bass_notes) / sizeof(timed_note)); // Chord sequence is 2 cycles long, so only schedule every other cycle if ((current_cycle >= 4) && ((current_cycle % 2) == 0)) schedule_notes(now, 1, chord_notes, sizeof(chord_notes) / sizeof(timed_note)); last_cycle = current_cycle; } } ``` And that’s really it! We now have a program that generates a serviceable reproduction of the opening of Billie Jean using just AMY for all the instruments. ================================================ FILE: docs/chunk.py ================================================ """Simple class to read IFF chunks. An IFF chunk (used in formats such as AIFF, TIFF, RMFF (RealMedia File Format)) has the following structure: +----------------+ | ID (4 bytes) | +----------------+ | size (4 bytes) | +----------------+ | data | | ... | +----------------+ The ID is a 4-byte string which identifies the type of chunk. The size field (a 32-bit value, encoded using big-endian byte order) gives the size of the whole chunk, including the 8-byte header. Usually an IFF-type file consists of one or more chunks. The proposed usage of the Chunk class defined here is to instantiate an instance at the start of each chunk and read from the instance until it reaches the end, after which a new instance can be instantiated. At the end of the file, creating a new instance will fail with a EOFError exception. Usage: while True: try: chunk = Chunk(file) except EOFError: break chunktype = chunk.getname() while True: data = chunk.read(nbytes) if not data: pass # do something with data The interface is file-like. The implemented methods are: read, close, seek, tell, isatty. Extra methods are: skip() (called by close, skips to the end of the chunk), getname() (returns the name (ID) of the chunk) The __init__ method has one required argument, a file-like object (including a chunk instance), and one optional argument, a flag which specifies whether or not chunks are aligned on 2-byte boundaries. The default is 1, i.e. aligned. """ class Chunk: def __init__(self, file, align=True, bigendian=True, inclheader=False): import struct self.closed = False self.align = align # whether to align to word (2-byte) boundaries if bigendian: strflag = '>' else: strflag = '<' self.file = file self.chunkname = file.read(4) if len(self.chunkname) < 4: raise EOFError try: data = file.read(4) self.chunksize = struct.unpack(strflag+'L', data)[0] except:# struct.error: raise EOFError if inclheader: self.chunksize = self.chunksize - 8 # subtract header self.size_read = 0 try: self.offset = self.file.tell() except: self.seekable = False else: self.seekable = True def getname(self): """Return the name (ID) of the current chunk.""" return self.chunkname def getsize(self): """Return the size of the current chunk.""" return self.chunksize def close(self): if not self.closed: self.skip() self.closed = True def isatty(self): if self.closed: raise ValueError("I/O operation on closed file") return False def seek(self, pos, whence=0): """Seek to specified position into the chunk. Default position is 0 (start of chunk). If the file is not seekable, this will result in an error. """ if self.closed: raise ValueError("I/O operation on closed file") if not self.seekable: raise OSError("cannot seek") if whence == 1: pos = pos + self.size_read elif whence == 2: pos = pos + self.chunksize if pos < 0 or pos > self.chunksize: raise RuntimeError self.file.seek(self.offset + pos, 0) self.size_read = pos def tell(self): if self.closed: raise ValueError("I/O operation on closed file") return self.size_read def read(self, size=-1): """Read at most size bytes from the chunk. If size is omitted or negative, read until the end of the chunk. """ if self.closed: raise ValueError("I/O operation on closed file") if self.size_read >= self.chunksize: return '' if size < 0: size = self.chunksize - self.size_read if size > self.chunksize - self.size_read: size = self.chunksize - self.size_read data = self.file.read(size) self.size_read = self.size_read + len(data) if self.size_read == self.chunksize and \ self.align and \ (self.chunksize & 1): dummy = self.file.read(1) self.size_read = self.size_read + len(dummy) return data def skip(self): """Skip the rest of the chunk. If you are not interested in the contents of the chunk, this method should be called so that the file points to the start of the next chunk. """ if self.closed: raise ValueError("I/O operation on closed file") if self.seekable: try: n = self.chunksize - self.size_read # maybe fix alignment if self.align and (self.chunksize & 1): n = n + 1 self.file.seek(n, 1) self.size_read = self.size_read + n return except OSError: pass while self.size_read < self.chunksize: n = min(8192, self.chunksize - self.size_read) dummy = self.read(n) if not dummy: raise EOFError ================================================ FILE: docs/enable-threads.js ================================================ // NOTE: This file creates a service worker that cross-origin-isolates the page (read more here: https://web.dev/coop-coep/) which allows us to use wasm threads. // Normally you would set the COOP and COEP headers on the server to do this, but Github Pages doesn't allow this, so this is a hack to do that. /* Edited version of: coi-serviceworker v0.1.6 - Guido Zuidhof, licensed under MIT */ // From here: https://github.com/gzuidhof/coi-serviceworker if(typeof window === 'undefined') { self.addEventListener("install", () => self.skipWaiting()); self.addEventListener("activate", e => e.waitUntil(self.clients.claim())); async function handleFetch(request) { if(request.cache === "only-if-cached" && request.mode !== "same-origin") { return; } if(request.mode === "no-cors") { // We need to set `credentials` to "omit" for no-cors requests, per this comment: https://bugs.chromium.org/p/chromium/issues/detail?id=1309901#c7 request = new Request(request.url, { cache: request.cache, credentials: "omit", headers: request.headers, integrity: request.integrity, destination: request.destination, keepalive: request.keepalive, method: request.method, mode: request.mode, redirect: request.redirect, referrer: request.referrer, referrerPolicy: request.referrerPolicy, signal: request.signal, }); } let r = await fetch(request).catch(e => console.error(e)); if(r.status === 0) { return r; } const headers = new Headers(r.headers); headers.set("Cross-Origin-Embedder-Policy", "require-corp"); // or: require-corp headers.set("Cross-Origin-Opener-Policy", "same-origin"); return new Response(r.body, { status: r.status, statusText: r.statusText, headers }); } self.addEventListener("fetch", function(e) { e.respondWith(handleFetch(e.request)); // respondWith must be executed synchonously (but can be passed a Promise) }); } else { (async function() { if(window.crossOriginIsolated !== false) return; let registration = await navigator.serviceWorker.register(window.document.currentScript.src).catch(e => console.error("COOP/COEP Service Worker failed to register:", e)); if(registration) { console.log("COOP/COEP Service Worker registered", registration.scope); registration.addEventListener("updatefound", () => { console.log("Reloading page to make use of updated COOP/COEP Service Worker."); window.location.reload(); }); // If the registration is active, but it's not controlling the page if(registration.active && !navigator.serviceWorker.controller) { console.log("Reloading page to make use of COOP/COEP Service Worker."); window.location.reload(); } } })(); } // Code to deregister: // let registrations = await navigator.serviceWorker.getRegistrations(); // for(let registration of registrations) { // await registration.unregister(); // } ================================================ FILE: docs/godot.md ================================================ # AMY in Godot The AMY synthesizer engine works as a [GDExtension](https://docs.godotengine.org/en/stable/tutorials/scripting/gdextension/index.html) addon for Godot 4.3+, with support for both **native** (macOS, Linux, Windows) and **web** exports. On native platforms, AMY runs as a C library via GDExtension and routes audio through Godot's `AudioStreamGenerator`. On web, AMY runs its own WASM module with AudioWorklet and the GDScript wrapper sends wire messages via `JavaScriptBridge`. ## Quick Start ### Option A: Download pre-built addon (easiest) Download [`amy-godot-addon.zip`](https://github.com/shorepine/amy/releases/latest/download/amy-godot-addon.zip) and unzip it into your Godot project root so you have `your_project/addons/amy/`. On **macOS**, you need to remove the quarantine flag from the downloaded binary: ```bash xattr -dr com.apple.quarantine addons/amy/bin/* ``` If you don't do this, you'll see a Godot error like "Apple could not verify 'libamy.macos.template_debug.universal.dylib' is free of malware that may harm your Mac or compromise your privacy." This command tells macOS you've chosen to trust the software yourself. ### Option B: Build from source Clone AMY and [godot-cpp](https://github.com/godotengine/godot-cpp), then run the setup script: ```bash git clone https://github.com/shorepine/amy.git cd amy # Clone godot-cpp next to your project (or wherever you like) git clone --branch godot-4.4-stable https://github.com/godotengine/godot-cpp.git ../godot-cpp # Build the addon and install it into your Godot project ./setup_godot.sh /path/to/your/godot/project ``` The script builds the native GDExtension library and copies everything into `your_project/addons/amy/`. If you want to point to a `godot-cpp` checkout in a different location: ```bash GODOT_CPP_PATH=/path/to/godot-cpp ./setup_godot.sh /path/to/your/godot/project ``` ### 2. Open the project in the Godot editor Open or reimport the project so Godot registers the `Amy` class. ### 3. Use AMY in your scripts ```gdscript var amy: Amy func _ready(): amy = Amy.new() add_child(amy) await get_tree().process_frame # let AMY initialize # Play a 440 Hz sine wave amy.send({"osc": 0, "wave": Amy.SINE, "freq": 440, "vel": 1.0}) # Play a MIDI note on a triangle wave amy.send({"osc": 1, "wave": Amy.TRIANGLE, "note": 60, "vel": 0.5}) # Stop oscillator 0 amy.send({"osc": 0, "vel": 0}) # Use a patch (preset instrument) amy.send({"synth": 1, "patch": 1, "num_voices": 6, "note": 48, "vel": 0.8}) # Or use wire protocol directly amy.send_raw("v3w0f880l0.5") ``` ### 4. Configure AMY (optional) Set [config properties](api.md) on the `Amy` node **before** adding it to the tree: ```gdscript var amy: Amy func _ready(): amy = Amy.new() amy.startup_bleep = false amy.default_synths = true add_child(amy) # config is applied when AMY starts in _ready() ``` ## Web Export AMY works on web exports. The native GDExtension isn't used on web — instead, AMY's pre-built WASM module runs via JavaScript and the `Amy` class automatically switches to using `JavaScriptBridge`. ### Setup steps 1. **Run the install script** in the Godot editor: - Open `addons/amy/install.gd` in the Script Editor - Run it via **File > Run** (or `Ctrl/Cmd+Shift+X`) - This copies web audio files to the right locations 2. **Configure the web export preset**: - Open **Project > Export > Web** - Set **Custom HTML Shell** to `res://export/custom_shell.html` - Set **Exclude Filter** to `addons/amy/bin/*,addons/amy/src/*,addons/amy/amy_src/*,addons/amy/web/*,addons/amy/SConstruct,addons/amy/install.gd,addons/amy/amy.gdextension` (exclude native libraries and build files, but keep `amy.gd`) 3. **Export to a separate folder** (e.g. `dist/` inside your project): - Click **Export Project** and save the `.html` file into a new folder (e.g. `dist/YourGame.html`) - Godot will place all its export files there automatically 4. **Copy AMY's web audio files** into the export folder: ```bash cp -r addons/amy/web/ dist/web_audio/ cp addons/amy/web/enable-threads.js dist/ ``` 5. **Deploy** — upload the contents of `dist/` to your web server. The folder should contain: ``` YourGame.html # main page YourGame.js # Godot engine YourGame.wasm # Godot WASM binary YourGame.pck # packed game assets YourGame.audio.worklet.js # Godot audio worklet YourGame.audio.position.worklet.js # Godot audio position worklet enable-threads.js # COOP/COEP service worker for AudioWorklet support web_audio/ # AMY audio engine amy.js amy.wasm amy.aw.js amy.ww.js godot_amy_bridge.js enable-threads.js ``` Or run locally: `python3 -m http.server` from your `dist` folder and go to `localhost:8000`. ## How It Works - **Native (macOS/Linux/Windows):** AMY runs as a GDExtension (`AmySynth` C++ class) compiled with `-DAMY_NO_MINIAUDIO` and `AMY_AUDIO_IS_NONE`. Audio is rendered via `amy_simple_fill_buffer()` and routed through Godot's `AudioStreamGenerator` at 44100 Hz. - **Web:** AMY runs as its own WASM module with Web Audio API AudioWorklets. The `Amy` GDScript class detects `OS.get_name() == "Web"` and sends wire messages via `JavaScriptBridge` instead of the native extension. ## API Reference ### `amy.send(params: Dictionary)` Send a message to AMY using named parameters. This mirrors AMY's Python API — the parameter names are the same as `amy.send()` in Python. **Common parameters:** | Parameter | Type | Description | |-----------|------|-------------| | `osc` | int | Oscillator number (0-63) | | `wave` | int | Wave type (use constants like `Amy.SINE`) | | `freq` | float | Frequency in Hz | | `note` | int/float | MIDI note number | | `vel` | float | Velocity / volume (0.0 = off, 1.0 = max) | | `amp` | float | Amplitude | | `duty` | float | Pulse width duty cycle | | `pan` | float | Stereo panning | | `patch` | int | Preset patch number | | `filter_freq` | float | Filter cutoff frequency | | `filter_type` | int | Filter type (use `Amy.FILTER_LPF` etc.) | | `resonance` | float | Filter resonance / Q | | `feedback` | float | FM feedback amount | | `ratio` | float | FM frequency ratio | | `algorithm` | int | FM algorithm number | | `bp0` | string | Breakpoint envelope 0 (time,val pairs) | | `bp1` | string | Breakpoint envelope 1 | | `volume` | float | Global volume | | `tempo` | float | Sequencer tempo in BPM | | `chorus` | string | Chorus settings | | `reverb` | string | Reverb settings | | `echo` | string | Echo/delay settings | See the full [AMY API reference](api.md) for all available parameters. ### `amy.send_raw(msg: String)` Send a raw AMY wire-protocol message (e.g. `"v0w0f440l1"`). ### `amy.panic()` Stop all sound immediately. ### Constants **Wave types:** `Amy.SINE`, `Amy.PULSE`, `Amy.SAW_DOWN`, `Amy.SAW_UP`, `Amy.TRIANGLE`, `Amy.NOISE`, `Amy.KS`, `Amy.PCM`, `Amy.ALGO`, `Amy.PARTIAL`, `Amy.WAVETABLE`, `Amy.CUSTOM`, `Amy.WAVE_OFF` **Filter types:** `Amy.FILTER_NONE`, `Amy.FILTER_LPF`, `Amy.FILTER_BPF`, `Amy.FILTER_HPF`, `Amy.FILTER_LPF24` **Envelope types:** `Amy.ENVELOPE_NORMAL`, `Amy.ENVELOPE_LINEAR`, `Amy.ENVELOPE_DX7`, `Amy.ENVELOPE_TRUE_EXPONENTIAL` ================================================ FILE: docs/index.html ================================================ AMY web examples

AMY - A high-performance fixed-point Music synthesizer librarY for microcontrollers

Try out some AMY examples on the web


AMY JavaScript REPL

Try AMY with JavaScript — write and run amy_send() commands live

AMY interactive tutorial

Python interactive AMY tutorial

Minimal AMY web synth

All you need to boot a synthesizer

Try Tulip voices app

Try AMY voices with a UI on the web

Try Tulip drums app

Try the AMY sampler on the web

Read about our piano voice in an interactive Python REPL

See a great blog post about our additive piano voice with live code.

================================================ FILE: docs/juno_patches.md ================================================ # Understanding Juno Patches [AMY](https://github.com/shorepine/amy) can be used to simulate many analog synthesizers, and it comes pre-installed with emulations of the 128 factory patches that came with the Juno-60 (the first MIDI-enabled Juno). This page explains how the Juno patches work, both for users who want to modify or manipulate Juno patches, but also as a case-study in how complex voices can be built from basic AMY oscillators. You may also want to look at the page on [AMY Synthesizer Details](synth.md) for a more detailed introduction of oscs, voices, synths, and parameters in AMY. ## Juno patches You can quickly configure a polyphonic Juno synthesizer by loading one of the Juno patches: ```python # Load the Juno A12 Brass Swell patch onto synth 1 with 6-note polyphony amy.send(synth=1, num_voices=6, patch=1) # Play a C major chord amy.send(synth=1, note=60, vel=1) amy.send(synth=1, note=64, vel=1) amy.send(synth=1, note=67, vel=1) # Stop the chord amy.send(synth=1, vel=0) # velocity of zero with no note means 'all notes off' ``` The `patch` argument refers to a set of "wire command strings" in [patches.h](https://github.com/shorepine/amy/blob/main/src/patches.h). (That file is itself written by [headers.py](https://github.com/shorepine/amy/blob/main/amy/headers.py), which uses [juno.py](https://github.com/shorepine/amy/blob/main/amy/juno.py) to translate the original Juno SYSEX strings into AMY commands). The wire string for patch 1 is: ``` v1w4a1,,0,1Z v0w20c2L1G4Z v2w1c3L1Z v3w3c4L1Z v4w1c5L1Z v5w5L1Z v1f0.609A148,1.0,10000,0Z v2a0.001,0,0,0,0,0f440,1,,,,0,1d0.72,,,,,0m0Z v3a1,0,0,0,0,0f440,1,,,,0,1m0Z v4a0.551,0,0,0,0,0f220,1,,,,0,1m0Z v5a0.001,0,0,0,0,0Z v0F300.23,0.661,,2.252,0,0R1.015Z v0a0.591,,1,1,0A518,1,83561,0.299,310,0Z x7,-3,-3k1,,0.5,0.5Z" ``` Wire strings consist of one or two-letter commands followed by an argument (documented on the [API page](api.md)), often a single numerical value, or a comma-separated list. `Z` is a separator, so I've broken the string into separate `Z`-terminated phrases; the stored string does not include any line breaks. All the settings in a single, `Z`-separated phrase apply to a single osc as specified (or zero by default; some commands like EQ and chorus apply to all oscs at once, so no osc needs to be indicated). But even broken up this way, the command strings are not very readable. However, each command phrase is equivalent to a single `amy.send()` command in the Python interface. Thus, the wire strings above correspond to: ```Python amy.send(osc=1, wave=amy.TRIANGLE, amp={'const':1, 'vel': 0, 'eg0': 1}) amy.send(osc=0, wave=amy.SILENT, chained_osc=2, mod_source=1, filter_type=amy.FILTER_LPF24) amy.send(osc=2, wave=amy.PULSE, chained_osc=3, mod_source=1) amy.send(osc=3, wave=amy.SAW_UP, chained_osc=4, mod_source=1) amy.send(osc=4, wave=amy.PULSE, chained_osc=5, mod_source=1) amy.send(osc=5, wave=amy.NOISE, mod_source=1) amy.send(osc=1, freq=0.609, bp1='148,1.0,10000,0') amy.send(osc=2, amp={'const': 0.001, 'note': 0, 'vel': 0, 'eg0': 0, 'eg1': 0, 'mod': 0'}, freq={'const': 440, 'note': 1, 'mod': 0, 'bend': 1}, duty={'const': 0.72, 'mod': 0}, portamento=0) amy.send(osc=3, amp={'const': 1, 'note': 0, 'vel': 0, 'eg0': 0, 'eg1': 0, 'mod': 0'}, freq={'const': 440, 'note': 1, 'mod': 0, 'bend': 1}, portamento=0) amy.send(osc=4, amp={'const': 0.551, 'note': 0, 'vel': 0, 'eg0': 0, 'eg1': 0, 'mod': 0'}, freq={'const': 220, 'note': 1, 'mod': 0, 'bend': 1}, portamento=0) amy.send(osc=5, amp={'const': 0.001, 'note': 0, 'vel': 0, 'eg0': 0, 'eg1': 0, 'mod': 0'}) amy.send(osc=0, amp={'const': 0.591, 'vel': 1, 'eg0': 1, 'eg1': 0}, bp0='518,1,83561,0.299,310,0') amy.send(eq='7,-3,-3', chorus='1,,0.5,0.5') ``` Now we can begin to understand how this patch works. The patch consists of six oscs: * Osc 0 is the `SILENT` osc, a special osc with gathers the summed outputs of all the oscs connected to it via a `chained_osc` chain. The first osc in its chain is 2. * Osc 1 is the LFO: It has a `TRIANGLE` waveform and a frequency of 0.609 Hz * Osc 2 (which is part of the chain starting with osc 0) has a `PULSE` waveform and continues the chain with osc 3. However it also a `const` term in its amplitude (`amp`) of 0.001, or -60 dB relative to 1.0, which makes it inaudible. * Osc 3 is a `SAW` (sawtooth), and chains forward to osc 4. * Osc 4 is another `PULSE` oscillator, but with a base frequency of 220 Hz, in contrast to the 440 Hz of oscs 2 and 3. It chains forward to osc 5. * Osc 5 has a `NOISE` waveform. Its amp is also 0.001, i.e. silenced. Oscs 2-5 correspond to the four waveform sources on the Juno: pulse/PWM, sawtooth, subosc (pulse one octave below), and noise. We see a chain: Osc 0 > Osc 2 > Osc 3 > Osc 4 > Osc 5. "Chaining" is a convenience to allow a single note-on/off event to be passed to multiple oscs in a single event. So `note` and `vel` parameters sent to osc 0 will propagate down the chain until all of oscs 2-5 see the same event. `SILENT` oscs, such as osc 0, are special-cases that gather the summed waveforms of all their chained oscs, then apply a single amplitude envelope (`bp0`, which contributes to `amp` via the `eg0` coefficient) and a filter (`filter_type`). We *could* put filters and envelopes on each osc indidually before they get summed through the chain, but its more efficient to do it once after summing the waveforms, since, for a Juno, all oscillator waveforms are subject to the same envelope and filtering. Each of the "sounding" oscs, 2-5, has its overall level set by its `amp['const']` coefficient, but no amplitude envelope or velocity scaling (since the envelope and velocity scaling are applied by osc 0). The LFO, osc 1, is connected to each of the sounding oscs by their `mod_source` argument. However, in this patch neither pitch, PWM duty, or filter frequency, are influenced by the LFO, because in each case their `mod` coefficients are zero. The LFO does have an amplitude envelope provided by `bp0`: it fades in over 148 ms (called 'LFO Delay Time' on the original Junos), then decays over 10 seconds, which stands in for endless sustain. Modulation oscs (i.e., those named as `mod_source` by some other osc) receive note-on events when the oscs they are modulating receive note-ons. The pitched sounding oscs, 2-4, have `portamento` time (in ms) set to 0, i.e., there's no pitch-slide portamento. Finally, the patch sets stationary EQ, in this case with a 7 dB boost for the low band, and -3 dB for the mid and high bands. The chorus is mixed at full amplitude (1), with 0.5 Hz modulating and a delay modulation depth of 0.5 of its maximum length. This corresponds to mode I of the Juno chorus. All Juno patches have the same structure, and vary only in the values of their parameters, corresponding more or less to the positioning of the sliders on the original Juno front-panel. Note that the commands above address explicit osc numbers. But when used to set up a synth (e.g., by including `synth=1` in each `amy.send()`), the commands refer to an osc relative to the base osc for each voice of the synth, and are thus applied to `num_voices` distinct oscs, one within each voice of the synth. ================================================ FILE: docs/micropython.mjs ================================================ // This code implements the `-sMODULARIZE` settings by taking the generated // JS program code (INNER_JS_CODE) and wrapping it in a factory function. // When targetting node and ES6 we use `await import ..` in the generated code // so the outer function needs to be marked as async. async function _createMicroPythonModule(moduleArg = {}) { var moduleRtn; // include: shell.js // include: minimum_runtime_check.js (function() { // "30.0.0" -> 300000 function humanReadableVersionToPacked(str) { str = str.split('-')[0]; // Remove any trailing part from e.g. "12.53.3-alpha" var vers = str.split('.').slice(0, 3); while(vers.length < 3) vers.push('00'); vers = vers.map((n, i, arr) => n.padStart(2, '0')); return vers.join(''); } // 300000 -> "30.0.0" var packedVersionToHumanReadable = n => [n / 10000 | 0, (n / 100 | 0) % 100, n % 100].join('.'); var TARGET_NOT_SUPPORTED = 2147483647; // Note: We use a typeof check here instead of optional chaining using // globalThis because older browsers might not have globalThis defined. var currentNodeVersion = typeof process !== 'undefined' && process.versions?.node ? humanReadableVersionToPacked(process.versions.node) : TARGET_NOT_SUPPORTED; if (currentNodeVersion < 160000) { throw new Error(`This emscripten-generated code requires node v${ packedVersionToHumanReadable(160000) } (detected v${packedVersionToHumanReadable(currentNodeVersion)})`); } var userAgent = typeof navigator !== 'undefined' && navigator.userAgent; if (!userAgent) { return; } var currentSafariVersion = userAgent.includes("Safari/") && !userAgent.includes("Chrome/") && userAgent.match(/Version\/(\d+\.?\d*\.?\d*)/) ? humanReadableVersionToPacked(userAgent.match(/Version\/(\d+\.?\d*\.?\d*)/)[1]) : TARGET_NOT_SUPPORTED; if (currentSafariVersion < 150000) { throw new Error(`This emscripten-generated code requires Safari v${ packedVersionToHumanReadable(150000) } (detected v${currentSafariVersion})`); } var currentFirefoxVersion = userAgent.match(/Firefox\/(\d+(?:\.\d+)?)/) ? parseFloat(userAgent.match(/Firefox\/(\d+(?:\.\d+)?)/)[1]) : TARGET_NOT_SUPPORTED; if (currentFirefoxVersion < 79) { throw new Error(`This emscripten-generated code requires Firefox v79 (detected v${currentFirefoxVersion})`); } var currentChromeVersion = userAgent.match(/Chrome\/(\d+(?:\.\d+)?)/) ? parseFloat(userAgent.match(/Chrome\/(\d+(?:\.\d+)?)/)[1]) : TARGET_NOT_SUPPORTED; if (currentChromeVersion < 85) { throw new Error(`This emscripten-generated code requires Chrome v85 (detected v${currentChromeVersion})`); } })(); // end include: minimum_runtime_check.js // The Module object: Our interface to the outside world. We import // and export values on it. There are various ways Module can be used: // 1. Not defined. We create it here // 2. A function parameter, function(moduleArg) => Promise // 3. pre-run appended it, var Module = {}; ..generated code.. // 4. External script tag defines var Module. // We need to check if Module already exists (e.g. case 3 above). // Substitution will be replaced with actual code on later stage of the build, // this way Closure Compiler will not mangle it (e.g. case 4. above). // Note that if you want to run closure, and also to use Module // after the generated code, you will need to define var Module = {}; // before the code. Then that object will be used in the code, and you // can continue to use Module afterwards as well. var Module = moduleArg; // Determine the runtime environment we are in. You can customize this by // setting the ENVIRONMENT setting at compile time (see settings.js). // Attempt to auto-detect the environment var ENVIRONMENT_IS_WEB = !!globalThis.window; var ENVIRONMENT_IS_WORKER = !!globalThis.WorkerGlobalScope; // N.b. Electron.js environment is simultaneously a NODE-environment, but // also a web environment. var ENVIRONMENT_IS_NODE = globalThis.process?.versions?.node && globalThis.process?.type != 'renderer'; var ENVIRONMENT_IS_SHELL = !ENVIRONMENT_IS_WEB && !ENVIRONMENT_IS_NODE && !ENVIRONMENT_IS_WORKER; if (ENVIRONMENT_IS_NODE) { // When building an ES module `require` is not normally available. // We need to use `createRequire()` to construct the require()` function. const { createRequire } = await import('module'); /** @suppress{duplicate} */ var require = createRequire(import.meta.url); } // --pre-jses are emitted after the Module integration code, so that they can // refer to Module (if they choose; they can also define Module) var arguments_ = []; var thisProgram = './this.program'; var quit_ = (status, toThrow) => { throw toThrow; }; var _scriptName = import.meta.url; // `/` should be present at the end if `scriptDirectory` is not empty var scriptDirectory = ''; function locateFile(path) { if (Module['locateFile']) { return Module['locateFile'](path, scriptDirectory); } return scriptDirectory + path; } // Hooks that are implemented differently in different runtime environments. var readAsync, readBinary; if (ENVIRONMENT_IS_NODE) { const isNode = globalThis.process?.versions?.node && globalThis.process?.type != 'renderer'; if (!isNode) throw new Error('not compiled for this environment (did you build to HTML and try to run it not on the web, or set ENVIRONMENT to something - like node - and run it someplace else - like on the web?)'); // These modules will usually be used on Node.js. Load them eagerly to avoid // the complexity of lazy-loading. var fs = require('fs'); if (_scriptName.startsWith('file:')) { scriptDirectory = require('path').dirname(require('url').fileURLToPath(_scriptName)) + '/'; } // include: node_shell_read.js readBinary = (filename) => { // We need to re-wrap `file://` strings to URLs. filename = isFileURI(filename) ? new URL(filename) : filename; var ret = fs.readFileSync(filename); assert(Buffer.isBuffer(ret)); return ret; }; readAsync = async (filename, binary = true) => { // See the comment in the `readBinary` function. filename = isFileURI(filename) ? new URL(filename) : filename; var ret = fs.readFileSync(filename, binary ? undefined : 'utf8'); assert(binary ? Buffer.isBuffer(ret) : typeof ret == 'string'); return ret; }; // end include: node_shell_read.js if (process.argv.length > 1) { thisProgram = process.argv[1].replace(/\\/g, '/'); } arguments_ = process.argv.slice(2); quit_ = (status, toThrow) => { process.exitCode = status; throw toThrow; }; } else if (ENVIRONMENT_IS_SHELL) { } else // Note that this includes Node.js workers when relevant (pthreads is enabled). // Node.js workers are detected as a combination of ENVIRONMENT_IS_WORKER and // ENVIRONMENT_IS_NODE. if (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER) { try { scriptDirectory = new URL('.', _scriptName).href; // includes trailing slash } catch { // Must be a `blob:` or `data:` URL (e.g. `blob:http://site.com/etc/etc`), we cannot // infer anything from them. } if (!(globalThis.window || globalThis.WorkerGlobalScope)) throw new Error('not compiled for this environment (did you build to HTML and try to run it not on the web, or set ENVIRONMENT to something - like node - and run it someplace else - like on the web?)'); { // include: web_or_worker_shell_read.js if (ENVIRONMENT_IS_WORKER) { readBinary = (url) => { var xhr = new XMLHttpRequest(); xhr.open('GET', url, false); xhr.responseType = 'arraybuffer'; xhr.send(null); return new Uint8Array(/** @type{!ArrayBuffer} */(xhr.response)); }; } readAsync = async (url) => { // Fetch has some additional restrictions over XHR, like it can't be used on a file:// url. // See https://github.com/github/fetch/pull/92#issuecomment-140665932 // Cordova or Electron apps are typically loaded from a file:// url. // So use XHR on webview if URL is a file URL. if (isFileURI(url)) { return new Promise((resolve, reject) => { var xhr = new XMLHttpRequest(); xhr.open('GET', url, true); xhr.responseType = 'arraybuffer'; xhr.onload = () => { if (xhr.status == 200 || (xhr.status == 0 && xhr.response)) { // file URLs can return 0 resolve(xhr.response); return; } reject(xhr.status); }; xhr.onerror = reject; xhr.send(null); }); } var response = await fetch(url, { credentials: 'same-origin' }); if (response.ok) { return response.arrayBuffer(); } throw new Error(response.status + ' : ' + response.url); }; // end include: web_or_worker_shell_read.js } } else { throw new Error('environment detection error'); } var out = console.log.bind(console); var err = console.error.bind(console); var IDBFS = 'IDBFS is no longer included by default; build with -lidbfs.js'; var PROXYFS = 'PROXYFS is no longer included by default; build with -lproxyfs.js'; var WORKERFS = 'WORKERFS is no longer included by default; build with -lworkerfs.js'; var FETCHFS = 'FETCHFS is no longer included by default; build with -lfetchfs.js'; var ICASEFS = 'ICASEFS is no longer included by default; build with -licasefs.js'; var JSFILEFS = 'JSFILEFS is no longer included by default; build with -ljsfilefs.js'; var OPFS = 'OPFS is no longer included by default; build with -lopfs.js'; var NODEFS = 'NODEFS is no longer included by default; build with -lnodefs.js'; // perform assertions in shell.js after we set up out() and err(), as otherwise // if an assertion fails it cannot print the message assert(!ENVIRONMENT_IS_SHELL, 'shell environment detected but not enabled at build time. Add `shell` to `-sENVIRONMENT` to enable.'); // end include: shell.js // include: preamble.js // === Preamble library stuff === // Documentation for the public APIs defined in this file must be updated in: // site/source/docs/api_reference/preamble.js.rst // A prebuilt local version of the documentation is available at: // site/build/text/docs/api_reference/preamble.js.txt // You can also build docs locally as HTML or other formats in site/ // An online HTML version (which may be of a different version of Emscripten) // is up at http://kripken.github.io/emscripten-site/docs/api_reference/preamble.js.html var wasmBinary; if (!globalThis.WebAssembly) { err('no native wasm support detected'); } // Wasm globals //======================================== // Runtime essentials //======================================== // whether we are quitting the application. no code should run after this. // set in exit() and abort() var ABORT = false; // set by exit() and abort(). Passed to 'onExit' handler. // NOTE: This is also used as the process return code code in shell environments // but only when noExitRuntime is false. var EXITSTATUS; // In STRICT mode, we only define assert() when ASSERTIONS is set. i.e. we // don't define it at all in release modes. This matches the behaviour of // MINIMAL_RUNTIME. // TODO(sbc): Make this the default even without STRICT enabled. /** @type {function(*, string=)} */ function assert(condition, text) { if (!condition) { abort('Assertion failed' + (text ? ': ' + text : '')); } } // We used to include malloc/free by default in the past. Show a helpful error in // builds with assertions. /** * Indicates whether filename is delivered via file protocol (as opposed to http/https) * @noinline */ var isFileURI = (filename) => filename.startsWith('file://'); // include: runtime_common.js // include: runtime_stack_check.js // Initializes the stack cookie. Called at the startup of main and at the startup of each thread in pthreads mode. function writeStackCookie() { var max = _emscripten_stack_get_end(); assert((max & 3) == 0); // If the stack ends at address zero we write our cookies 4 bytes into the // stack. This prevents interference with SAFE_HEAP and ASAN which also // monitor writes to address zero. if (max == 0) { max += 4; } // The stack grow downwards towards _emscripten_stack_get_end. // We write cookies to the final two words in the stack and detect if they are // ever overwritten. HEAPU32[((max)>>2)] = 0x02135467; HEAPU32[(((max)+(4))>>2)] = 0x89BACDFE; // Also test the global address 0 for integrity. HEAPU32[((0)>>2)] = 1668509029; } function checkStackCookie() { if (ABORT) return; var max = _emscripten_stack_get_end(); // See writeStackCookie(). if (max == 0) { max += 4; } var cookie1 = HEAPU32[((max)>>2)]; var cookie2 = HEAPU32[(((max)+(4))>>2)]; if (cookie1 != 0x02135467 || cookie2 != 0x89BACDFE) { abort(`Stack overflow! Stack cookie has been overwritten at ${ptrToString(max)}, expected hex dwords 0x89BACDFE and 0x2135467, but received ${ptrToString(cookie2)} ${ptrToString(cookie1)}`); } // Also test the global address 0 for integrity. if (HEAPU32[((0)>>2)] != 0x63736d65 /* 'emsc' */) { abort('Runtime error: The application has corrupted its heap memory area (address zero)!'); } } // end include: runtime_stack_check.js // include: runtime_exceptions.js // end include: runtime_exceptions.js // include: runtime_debug.js var runtimeDebug = true; // Switch to false at runtime to disable logging at the right times // Used by XXXXX_DEBUG settings to output debug messages. function dbg(...args) { if (!runtimeDebug && typeof runtimeDebug != 'undefined') return; // TODO(sbc): Make this configurable somehow. Its not always convenient for // logging to show up as warnings. console.warn(...args); } // Endianness check (() => { var h16 = new Int16Array(1); var h8 = new Int8Array(h16.buffer); h16[0] = 0x6373; if (h8[0] !== 0x73 || h8[1] !== 0x63) abort('Runtime error: expected the system to be little-endian! (Run with -sSUPPORT_BIG_ENDIAN to bypass)'); })(); function consumedModuleProp(prop) { if (!Object.getOwnPropertyDescriptor(Module, prop)) { Object.defineProperty(Module, prop, { configurable: true, set() { abort(`Attempt to set \`Module.${prop}\` after it has already been processed. This can happen, for example, when code is injected via '--post-js' rather than '--pre-js'`); } }); } } function makeInvalidEarlyAccess(name) { return () => assert(false, `call to '${name}' via reference taken before Wasm module initialization`); } function ignoredModuleProp(prop) { if (Object.getOwnPropertyDescriptor(Module, prop)) { abort(`\`Module.${prop}\` was supplied but \`${prop}\` not included in INCOMING_MODULE_JS_API`); } } // forcing the filesystem exports a few things by default function isExportedByForceFilesystem(name) { return name === 'FS_createPath' || name === 'FS_createDataFile' || name === 'FS_createPreloadedFile' || name === 'FS_preloadFile' || name === 'FS_unlink' || name === 'addRunDependency' || // The old FS has some functionality that WasmFS lacks. name === 'FS_createLazyFile' || name === 'FS_createDevice' || name === 'removeRunDependency'; } function missingLibrarySymbol(sym) { // Any symbol that is not included from the JS library is also (by definition) // not exported on the Module object. unexportedRuntimeSymbol(sym); } function unexportedRuntimeSymbol(sym) { if (!Object.getOwnPropertyDescriptor(Module, sym)) { Object.defineProperty(Module, sym, { configurable: true, get() { var msg = `'${sym}' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the Emscripten FAQ)`; if (isExportedByForceFilesystem(sym)) { msg += '. Alternatively, forcing filesystem support (-sFORCE_FILESYSTEM) can export this for you'; } abort(msg); }, }); } } // end include: runtime_debug.js var readyPromiseResolve, readyPromiseReject; // Memory management var /** @type {!Int8Array} */ HEAP8, /** @type {!Uint8Array} */ HEAPU8, /** @type {!Int16Array} */ HEAP16, /** @type {!Uint16Array} */ HEAPU16, /** @type {!Int32Array} */ HEAP32, /** @type {!Uint32Array} */ HEAPU32, /** @type {!Float32Array} */ HEAPF32, /** @type {!Float64Array} */ HEAPF64; // BigInt64Array type is not correctly defined in closure var /** not-@type {!BigInt64Array} */ HEAP64, /* BigUint64Array type is not correctly defined in closure /** not-@type {!BigUint64Array} */ HEAPU64; var runtimeInitialized = false; function updateMemoryViews() { var b = wasmMemory.buffer; HEAP8 = new Int8Array(b); HEAP16 = new Int16Array(b); HEAPU8 = new Uint8Array(b); HEAPU16 = new Uint16Array(b); HEAP32 = new Int32Array(b); HEAPU32 = new Uint32Array(b); HEAPF32 = new Float32Array(b); HEAPF64 = new Float64Array(b); HEAP64 = new BigInt64Array(b); HEAPU64 = new BigUint64Array(b); } // include: memoryprofiler.js // end include: memoryprofiler.js // end include: runtime_common.js assert(globalThis.Int32Array && globalThis.Float64Array && Int32Array.prototype.subarray && Int32Array.prototype.set, 'JS engine does not provide full typed array support'); function preRun() { if (Module['preRun']) { if (typeof Module['preRun'] == 'function') Module['preRun'] = [Module['preRun']]; while (Module['preRun'].length) { addOnPreRun(Module['preRun'].shift()); } } consumedModuleProp('preRun'); // Begin ATPRERUNS hooks callRuntimeCallbacks(onPreRuns); // End ATPRERUNS hooks } function initRuntime() { assert(!runtimeInitialized); runtimeInitialized = true; checkStackCookie(); // Begin ATINITS hooks if (!Module['noFSInit'] && !FS.initialized) FS.init(); TTY.init(); // End ATINITS hooks wasmExports['__wasm_call_ctors'](); // Begin ATPOSTCTORS hooks FS.ignorePermissions = false; // End ATPOSTCTORS hooks } function postRun() { checkStackCookie(); // PThreads reuse the runtime from the main thread. if (Module['postRun']) { if (typeof Module['postRun'] == 'function') Module['postRun'] = [Module['postRun']]; while (Module['postRun'].length) { addOnPostRun(Module['postRun'].shift()); } } consumedModuleProp('postRun'); // Begin ATPOSTRUNS hooks callRuntimeCallbacks(onPostRuns); // End ATPOSTRUNS hooks } /** @param {string|number=} what */ function abort(what) { Module['onAbort']?.(what); what = 'Aborted(' + what + ')'; // TODO(sbc): Should we remove printing and leave it up to whoever // catches the exception? err(what); ABORT = true; if (what.indexOf('RuntimeError: unreachable') >= 0) { what += '. "unreachable" may be due to ASYNCIFY_STACK_SIZE not being large enough (try increasing it)'; } // Use a wasm runtime error, because a JS error might be seen as a foreign // exception, which means we'd run destructors on it. We need the error to // simply make the program stop. // FIXME This approach does not work in Wasm EH because it currently does not assume // all RuntimeErrors are from traps; it decides whether a RuntimeError is from // a trap or not based on a hidden field within the object. So at the moment // we don't have a way of throwing a wasm trap from JS. TODO Make a JS API that // allows this in the wasm spec. // Suppress closure compiler warning here. Closure compiler's builtin extern // definition for WebAssembly.RuntimeError claims it takes no arguments even // though it can. // TODO(https://github.com/google/closure-compiler/pull/3913): Remove if/when upstream closure gets fixed. /** @suppress {checkTypes} */ var e = new WebAssembly.RuntimeError(what); readyPromiseReject?.(e); // Throw the error whether or not MODULARIZE is set because abort is used // in code paths apart from instantiation where an exception is expected // to be thrown when abort is called. throw e; } function createExportWrapper(name, nargs) { return (...args) => { assert(runtimeInitialized, `native function \`${name}\` called before runtime initialization`); var f = wasmExports[name]; assert(f, `exported native function \`${name}\` not found`); // Only assert for too many arguments. Too few can be valid since the missing arguments will be zero filled. assert(args.length <= nargs, `native function \`${name}\` called with ${args.length} args but expects ${nargs}`); return f(...args); }; } var wasmBinaryFile; function findWasmBinary() { if (Module['locateFile']) { return locateFile('micropython.wasm'); } // Use bundler-friendly `new URL(..., import.meta.url)` pattern; works in browsers too. return new URL('micropython.wasm', import.meta.url).href; } function getBinarySync(file) { if (file == wasmBinaryFile && wasmBinary) { return new Uint8Array(wasmBinary); } if (readBinary) { return readBinary(file); } // Throwing a plain string here, even though it not normally adviables since // this gets turning into an `abort` in instantiateArrayBuffer. throw 'both async and sync fetching of the wasm failed'; } async function getWasmBinary(binaryFile) { // If we don't have the binary yet, load it asynchronously using readAsync. if (!wasmBinary) { // Fetch the binary using readAsync try { var response = await readAsync(binaryFile); return new Uint8Array(response); } catch { // Fall back to getBinarySync below; } } // Otherwise, getBinarySync should be able to get it synchronously return getBinarySync(binaryFile); } async function instantiateArrayBuffer(binaryFile, imports) { try { var binary = await getWasmBinary(binaryFile); var instance = await WebAssembly.instantiate(binary, imports); return instance; } catch (reason) { err(`failed to asynchronously prepare wasm: ${reason}`); // Warn on some common problems. if (isFileURI(binaryFile)) { err(`warning: Loading from a file URI (${binaryFile}) is not supported in most browsers. See https://emscripten.org/docs/getting_started/FAQ.html#how-do-i-run-a-local-webserver-for-testing-why-does-my-program-stall-in-downloading-or-preparing`); } abort(reason); } } async function instantiateAsync(binary, binaryFile, imports) { if (!binary // Don't use streaming for file:// delivered objects in a webview, fetch them synchronously. && !isFileURI(binaryFile) // Avoid instantiateStreaming() on Node.js environment for now, as while // Node.js v18.1.0 implements it, it does not have a full fetch() // implementation yet. // // Reference: // https://github.com/emscripten-core/emscripten/pull/16917 && !ENVIRONMENT_IS_NODE ) { try { var response = fetch(binaryFile, { credentials: 'same-origin' }); var instantiationResult = await WebAssembly.instantiateStreaming(response, imports); return instantiationResult; } catch (reason) { // We expect the most common failure cause to be a bad MIME type for the binary, // in which case falling back to ArrayBuffer instantiation should work. err(`wasm streaming compile failed: ${reason}`); err('falling back to ArrayBuffer instantiation'); // fall back of instantiateArrayBuffer below }; } return instantiateArrayBuffer(binaryFile, imports); } function getWasmImports() { // instrumenting imports is used in asyncify in two ways: to add assertions // that check for proper import use, and for ASYNCIFY=2 we use them to set up // the Promise API on the import side. Asyncify.instrumentWasmImports(wasmImports); // prepare imports var imports = { 'env': wasmImports, 'wasi_snapshot_preview1': wasmImports, }; return imports; } // Create the wasm instance. // Receives the wasm imports, returns the exports. async function createWasm() { // Load the wasm module and create an instance of using native support in the JS engine. // handle a generated wasm instance, receiving its exports and // performing other necessary setup /** @param {WebAssembly.Module=} module*/ function receiveInstance(instance, module) { wasmExports = instance.exports; wasmExports = Asyncify.instrumentWasmExports(wasmExports); assignWasmExports(wasmExports); updateMemoryViews(); return wasmExports; } // Prefer streaming instantiation if available. // Async compilation can be confusing when an error on the page overwrites Module // (for example, if the order of elements is wrong, and the one defining Module is // later), so we save Module and check it later. var trueModule = Module; function receiveInstantiationResult(result) { // 'result' is a ResultObject object which has both the module and instance. // receiveInstance() will swap in the exports (to Module.asm) so they can be called assert(Module === trueModule, 'the Module object should not be replaced during async compilation - perhaps the order of HTML elements is wrong?'); trueModule = null; // TODO: Due to Closure regression https://github.com/google/closure-compiler/issues/3193, the above line no longer optimizes out down to the following line. // When the regression is fixed, can restore the above PTHREADS-enabled path. return receiveInstance(result['instance']); } var info = getWasmImports(); // User shell pages can write their own Module.instantiateWasm = function(imports, successCallback) callback // to manually instantiate the Wasm module themselves. This allows pages to // run the instantiation parallel to any other async startup actions they are // performing. // Also pthreads and wasm workers initialize the wasm instance through this // path. if (Module['instantiateWasm']) { return new Promise((resolve, reject) => { try { Module['instantiateWasm'](info, (inst, mod) => { resolve(receiveInstance(inst, mod)); }); } catch(e) { err(`Module.instantiateWasm callback failed with error: ${e}`); reject(e); } }); } wasmBinaryFile ??= findWasmBinary(); var result = await instantiateAsync(wasmBinary, wasmBinaryFile, info); var exports = receiveInstantiationResult(result); return exports; } // end include: preamble.js // Begin JS library code class ExitStatus { name = 'ExitStatus'; constructor(status) { this.message = `Program terminated with exit(${status})`; this.status = status; } } var callRuntimeCallbacks = (callbacks) => { while (callbacks.length > 0) { // Pass the module as the first argument. callbacks.shift()(Module); } }; var onPostRuns = []; var addOnPostRun = (cb) => onPostRuns.push(cb); var onPreRuns = []; var addOnPreRun = (cb) => onPreRuns.push(cb); var dynCalls = { }; var dynCallLegacy = (sig, ptr, args) => { sig = sig.replace(/p/g, 'i') assert(sig in dynCalls, `bad function pointer type - sig is not in dynCalls: '${sig}'`); if (args?.length) { // j (64-bit integer) is fine, and is implemented as a BigInt. Without // legalization, the number of parameters should match (j is not expanded // into two i's). assert(args.length === sig.length - 1); } else { assert(sig.length == 1); } var f = dynCalls[sig]; return f(ptr, ...args); }; var dynCall = (sig, ptr, args = [], promising = false) => { assert(ptr, `null function pointer in dynCall`); assert(!promising, 'async dynCall is not supported in this mode') var rtn = dynCallLegacy(sig, ptr, args); function convert(rtn) { return rtn; } return convert(rtn); }; /** * @param {number} ptr * @param {string} type */ function getValue(ptr, type = 'i8') { if (type.endsWith('*')) type = '*'; switch (type) { case 'i1': return HEAP8[ptr]; case 'i8': return HEAP8[ptr]; case 'i16': return HEAP16[((ptr)>>1)]; case 'i32': return HEAP32[((ptr)>>2)]; case 'i64': return HEAP64[((ptr)>>3)]; case 'float': return HEAPF32[((ptr)>>2)]; case 'double': return HEAPF64[((ptr)>>3)]; case '*': return HEAPU32[((ptr)>>2)]; default: abort(`invalid type for getValue: ${type}`); } } var noExitRuntime = true; var ptrToString = (ptr) => { assert(typeof ptr === 'number', `ptrToString expects a number, got ${typeof ptr}`); // Convert to 32-bit unsigned value ptr >>>= 0; return '0x' + ptr.toString(16).padStart(8, '0'); }; /** * @param {number} ptr * @param {number} value * @param {string} type */ function setValue(ptr, value, type = 'i8') { if (type.endsWith('*')) type = '*'; switch (type) { case 'i1': HEAP8[ptr] = value; break; case 'i8': HEAP8[ptr] = value; break; case 'i16': HEAP16[((ptr)>>1)] = value; break; case 'i32': HEAP32[((ptr)>>2)] = value; break; case 'i64': HEAP64[((ptr)>>3)] = BigInt(value); break; case 'float': HEAPF32[((ptr)>>2)] = value; break; case 'double': HEAPF64[((ptr)>>3)] = value; break; case '*': HEAPU32[((ptr)>>2)] = value; break; default: abort(`invalid type for setValue: ${type}`); } } var stackRestore = (val) => __emscripten_stack_restore(val); var stackSave = () => _emscripten_stack_get_current(); var warnOnce = (text) => { warnOnce.shown ||= {}; if (!warnOnce.shown[text]) { warnOnce.shown[text] = 1; if (ENVIRONMENT_IS_NODE) text = 'warning: ' + text; err(text); } }; var PATH = { isAbs:(path) => path.charAt(0) === '/', splitPath:(filename) => { var splitPathRe = /^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/; return splitPathRe.exec(filename).slice(1); }, normalizeArray:(parts, allowAboveRoot) => { // if the path tries to go above the root, `up` ends up > 0 var up = 0; for (var i = parts.length - 1; i >= 0; i--) { var last = parts[i]; if (last === '.') { parts.splice(i, 1); } else if (last === '..') { parts.splice(i, 1); up++; } else if (up) { parts.splice(i, 1); up--; } } // if the path is allowed to go above the root, restore leading ..s if (allowAboveRoot) { for (; up; up--) { parts.unshift('..'); } } return parts; }, normalize:(path) => { var isAbsolute = PATH.isAbs(path), trailingSlash = path.slice(-1) === '/'; // Normalize the path path = PATH.normalizeArray(path.split('/').filter((p) => !!p), !isAbsolute).join('/'); if (!path && !isAbsolute) { path = '.'; } if (path && trailingSlash) { path += '/'; } return (isAbsolute ? '/' : '') + path; }, dirname:(path) => { var result = PATH.splitPath(path), root = result[0], dir = result[1]; if (!root && !dir) { // No dirname whatsoever return '.'; } if (dir) { // It has a dirname, strip trailing slash dir = dir.slice(0, -1); } return root + dir; }, basename:(path) => path && path.match(/([^\/]+|\/)\/*$/)[1], join:(...paths) => PATH.normalize(paths.join('/')), join2:(l, r) => PATH.normalize(l + '/' + r), }; var initRandomFill = () => { // This block is not needed on v19+ since crypto.getRandomValues is builtin if (ENVIRONMENT_IS_NODE) { var nodeCrypto = require('crypto'); return (view) => nodeCrypto.randomFillSync(view); } return (view) => crypto.getRandomValues(view); }; var randomFill = (view) => { // Lazily init on the first invocation. (randomFill = initRandomFill())(view); }; var PATH_FS = { resolve:(...args) => { var resolvedPath = '', resolvedAbsolute = false; for (var i = args.length - 1; i >= -1 && !resolvedAbsolute; i--) { var path = (i >= 0) ? args[i] : FS.cwd(); // Skip empty and invalid entries if (typeof path != 'string') { throw new TypeError('Arguments to path.resolve must be strings'); } else if (!path) { return ''; // an invalid portion invalidates the whole thing } resolvedPath = path + '/' + resolvedPath; resolvedAbsolute = PATH.isAbs(path); } // At this point the path should be resolved to a full absolute path, but // handle relative paths to be safe (might happen when process.cwd() fails) resolvedPath = PATH.normalizeArray(resolvedPath.split('/').filter((p) => !!p), !resolvedAbsolute).join('/'); return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.'; }, relative:(from, to) => { from = PATH_FS.resolve(from).slice(1); to = PATH_FS.resolve(to).slice(1); function trim(arr) { var start = 0; for (; start < arr.length; start++) { if (arr[start] !== '') break; } var end = arr.length - 1; for (; end >= 0; end--) { if (arr[end] !== '') break; } if (start > end) return []; return arr.slice(start, end - start + 1); } var fromParts = trim(from.split('/')); var toParts = trim(to.split('/')); var length = Math.min(fromParts.length, toParts.length); var samePartsLength = length; for (var i = 0; i < length; i++) { if (fromParts[i] !== toParts[i]) { samePartsLength = i; break; } } var outputParts = []; for (var i = samePartsLength; i < fromParts.length; i++) { outputParts.push('..'); } outputParts = outputParts.concat(toParts.slice(samePartsLength)); return outputParts.join('/'); }, }; var UTF8Decoder = globalThis.TextDecoder && new TextDecoder(); var findStringEnd = (heapOrArray, idx, maxBytesToRead, ignoreNul) => { var maxIdx = idx + maxBytesToRead; if (ignoreNul) return maxIdx; // TextDecoder needs to know the byte length in advance, it doesn't stop on // null terminator by itself. // As a tiny code save trick, compare idx against maxIdx using a negation, // so that maxBytesToRead=undefined/NaN means Infinity. while (heapOrArray[idx] && !(idx >= maxIdx)) ++idx; return idx; }; /** * Given a pointer 'idx' to a null-terminated UTF8-encoded string in the given * array that contains uint8 values, returns a copy of that string as a * Javascript String object. * heapOrArray is either a regular array, or a JavaScript typed array view. * @param {number=} idx * @param {number=} maxBytesToRead * @param {boolean=} ignoreNul - If true, the function will not stop on a NUL character. * @return {string} */ var UTF8ArrayToString = (heapOrArray, idx = 0, maxBytesToRead, ignoreNul) => { var endPtr = findStringEnd(heapOrArray, idx, maxBytesToRead, ignoreNul); // When using conditional TextDecoder, skip it for short strings as the overhead of the native call is not worth it. if (endPtr - idx > 16 && heapOrArray.buffer && UTF8Decoder) { return UTF8Decoder.decode(heapOrArray.subarray(idx, endPtr)); } var str = ''; while (idx < endPtr) { // For UTF8 byte structure, see: // http://en.wikipedia.org/wiki/UTF-8#Description // https://www.ietf.org/rfc/rfc2279.txt // https://tools.ietf.org/html/rfc3629 var u0 = heapOrArray[idx++]; if (!(u0 & 0x80)) { str += String.fromCharCode(u0); continue; } var u1 = heapOrArray[idx++] & 63; if ((u0 & 0xE0) == 0xC0) { str += String.fromCharCode(((u0 & 31) << 6) | u1); continue; } var u2 = heapOrArray[idx++] & 63; if ((u0 & 0xF0) == 0xE0) { u0 = ((u0 & 15) << 12) | (u1 << 6) | u2; } else { if ((u0 & 0xF8) != 0xF0) warnOnce('Invalid UTF-8 leading byte ' + ptrToString(u0) + ' encountered when deserializing a UTF-8 string in wasm memory to a JS string!'); u0 = ((u0 & 7) << 18) | (u1 << 12) | (u2 << 6) | (heapOrArray[idx++] & 63); } if (u0 < 0x10000) { str += String.fromCharCode(u0); } else { var ch = u0 - 0x10000; str += String.fromCharCode(0xD800 | (ch >> 10), 0xDC00 | (ch & 0x3FF)); } } return str; }; var FS_stdin_getChar_buffer = []; var lengthBytesUTF8 = (str) => { var len = 0; for (var i = 0; i < str.length; ++i) { // Gotcha: charCodeAt returns a 16-bit word that is a UTF-16 encoded code // unit, not a Unicode code point of the character! So decode // UTF16->UTF32->UTF8. // See http://unicode.org/faq/utf_bom.html#utf16-3 var c = str.charCodeAt(i); // possibly a lead surrogate if (c <= 0x7F) { len++; } else if (c <= 0x7FF) { len += 2; } else if (c >= 0xD800 && c <= 0xDFFF) { len += 4; ++i; } else { len += 3; } } return len; }; var stringToUTF8Array = (str, heap, outIdx, maxBytesToWrite) => { assert(typeof str === 'string', `stringToUTF8Array expects a string (got ${typeof str})`); // Parameter maxBytesToWrite is not optional. Negative values, 0, null, // undefined and false each don't write out any bytes. if (!(maxBytesToWrite > 0)) return 0; var startIdx = outIdx; var endIdx = outIdx + maxBytesToWrite - 1; // -1 for string null terminator. for (var i = 0; i < str.length; ++i) { // For UTF8 byte structure, see http://en.wikipedia.org/wiki/UTF-8#Description // and https://www.ietf.org/rfc/rfc2279.txt // and https://tools.ietf.org/html/rfc3629 var u = str.codePointAt(i); if (u <= 0x7F) { if (outIdx >= endIdx) break; heap[outIdx++] = u; } else if (u <= 0x7FF) { if (outIdx + 1 >= endIdx) break; heap[outIdx++] = 0xC0 | (u >> 6); heap[outIdx++] = 0x80 | (u & 63); } else if (u <= 0xFFFF) { if (outIdx + 2 >= endIdx) break; heap[outIdx++] = 0xE0 | (u >> 12); heap[outIdx++] = 0x80 | ((u >> 6) & 63); heap[outIdx++] = 0x80 | (u & 63); } else { if (outIdx + 3 >= endIdx) break; if (u > 0x10FFFF) warnOnce('Invalid Unicode code point ' + ptrToString(u) + ' encountered when serializing a JS string to a UTF-8 string in wasm memory! (Valid unicode code points should be in range 0-0x10FFFF).'); heap[outIdx++] = 0xF0 | (u >> 18); heap[outIdx++] = 0x80 | ((u >> 12) & 63); heap[outIdx++] = 0x80 | ((u >> 6) & 63); heap[outIdx++] = 0x80 | (u & 63); // Gotcha: if codePoint is over 0xFFFF, it is represented as a surrogate pair in UTF-16. // We need to manually skip over the second code unit for correct iteration. i++; } } // Null-terminate the pointer to the buffer. heap[outIdx] = 0; return outIdx - startIdx; }; /** @type {function(string, boolean=, number=)} */ var intArrayFromString = (stringy, dontAddNull, length) => { var len = length > 0 ? length : lengthBytesUTF8(stringy)+1; var u8array = new Array(len); var numBytesWritten = stringToUTF8Array(stringy, u8array, 0, u8array.length); if (dontAddNull) u8array.length = numBytesWritten; return u8array; }; var FS_stdin_getChar = () => { if (!FS_stdin_getChar_buffer.length) { var result = null; if (ENVIRONMENT_IS_NODE) { // we will read data by chunks of BUFSIZE var BUFSIZE = 256; var buf = Buffer.alloc(BUFSIZE); var bytesRead = 0; // For some reason we must suppress a closure warning here, even though // fd definitely exists on process.stdin, and is even the proper way to // get the fd of stdin, // https://github.com/nodejs/help/issues/2136#issuecomment-523649904 // This started to happen after moving this logic out of library_tty.js, // so it is related to the surrounding code in some unclear manner. /** @suppress {missingProperties} */ var fd = process.stdin.fd; try { bytesRead = fs.readSync(fd, buf, 0, BUFSIZE); } catch(e) { // Cross-platform differences: on Windows, reading EOF throws an // exception, but on other OSes, reading EOF returns 0. Uniformize // behavior by treating the EOF exception to return 0. if (e.toString().includes('EOF')) bytesRead = 0; else throw e; } if (bytesRead > 0) { result = buf.slice(0, bytesRead).toString('utf-8'); } } else if (globalThis.window?.prompt) { // Browser. result = window.prompt('Input: '); // returns null on cancel if (result !== null) { result += '\n'; } } else {} if (!result) { return null; } FS_stdin_getChar_buffer = intArrayFromString(result, true); } return FS_stdin_getChar_buffer.shift(); }; var TTY = { ttys:[], init() { // https://github.com/emscripten-core/emscripten/pull/1555 // if (ENVIRONMENT_IS_NODE) { // // currently, FS.init does not distinguish if process.stdin is a file or TTY // // device, it always assumes it's a TTY device. because of this, we're forcing // // process.stdin to UTF8 encoding to at least make stdin reading compatible // // with text files until FS.init can be refactored. // process.stdin.setEncoding('utf8'); // } }, shutdown() { // https://github.com/emscripten-core/emscripten/pull/1555 // if (ENVIRONMENT_IS_NODE) { // // inolen: any idea as to why node -e 'process.stdin.read()' wouldn't exit immediately (with process.stdin being a tty)? // // isaacs: because now it's reading from the stream, you've expressed interest in it, so that read() kicks off a _read() which creates a ReadReq operation // // inolen: I thought read() in that case was a synchronous operation that just grabbed some amount of buffered data if it exists? // // isaacs: it is. but it also triggers a _read() call, which calls readStart() on the handle // // isaacs: do process.stdin.pause() and i'd think it'd probably close the pending call // process.stdin.pause(); // } }, register(dev, ops) { TTY.ttys[dev] = { input: [], output: [], ops: ops }; FS.registerDevice(dev, TTY.stream_ops); }, stream_ops:{ open(stream) { var tty = TTY.ttys[stream.node.rdev]; if (!tty) { throw new FS.ErrnoError(43); } stream.tty = tty; stream.seekable = false; }, close(stream) { // flush any pending line data stream.tty.ops.fsync(stream.tty); }, fsync(stream) { stream.tty.ops.fsync(stream.tty); }, read(stream, buffer, offset, length, pos /* ignored */) { if (!stream.tty || !stream.tty.ops.get_char) { throw new FS.ErrnoError(60); } var bytesRead = 0; for (var i = 0; i < length; i++) { var result; try { result = stream.tty.ops.get_char(stream.tty); } catch (e) { throw new FS.ErrnoError(29); } if (result === undefined && bytesRead === 0) { throw new FS.ErrnoError(6); } if (result === null || result === undefined) break; bytesRead++; buffer[offset+i] = result; } if (bytesRead) { stream.node.atime = Date.now(); } return bytesRead; }, write(stream, buffer, offset, length, pos) { if (!stream.tty || !stream.tty.ops.put_char) { throw new FS.ErrnoError(60); } try { for (var i = 0; i < length; i++) { stream.tty.ops.put_char(stream.tty, buffer[offset+i]); } } catch (e) { throw new FS.ErrnoError(29); } if (length) { stream.node.mtime = stream.node.ctime = Date.now(); } return i; }, }, default_tty_ops:{ get_char(tty) { return FS_stdin_getChar(); }, put_char(tty, val) { if (val === null || val === 10) { out(UTF8ArrayToString(tty.output)); tty.output = []; } else { if (val != 0) tty.output.push(val); // val == 0 would cut text output off in the middle. } }, fsync(tty) { if (tty.output?.length > 0) { out(UTF8ArrayToString(tty.output)); tty.output = []; } }, ioctl_tcgets(tty) { // typical setting return { c_iflag: 25856, c_oflag: 5, c_cflag: 191, c_lflag: 35387, c_cc: [ 0x03, 0x1c, 0x7f, 0x15, 0x04, 0x00, 0x01, 0x00, 0x11, 0x13, 0x1a, 0x00, 0x12, 0x0f, 0x17, 0x16, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ] }; }, ioctl_tcsets(tty, optional_actions, data) { // currently just ignore return 0; }, ioctl_tiocgwinsz(tty) { return [24, 80]; }, }, default_tty1_ops:{ put_char(tty, val) { if (val === null || val === 10) { err(UTF8ArrayToString(tty.output)); tty.output = []; } else { if (val != 0) tty.output.push(val); } }, fsync(tty) { if (tty.output?.length > 0) { err(UTF8ArrayToString(tty.output)); tty.output = []; } }, }, }; var mmapAlloc = (size) => { abort('internal error: mmapAlloc called but `emscripten_builtin_memalign` native symbol not exported'); }; var MEMFS = { ops_table:null, mount(mount) { return MEMFS.createNode(null, '/', 16895, 0); }, createNode(parent, name, mode, dev) { if (FS.isBlkdev(mode) || FS.isFIFO(mode)) { // no supported throw new FS.ErrnoError(63); } MEMFS.ops_table ||= { dir: { node: { getattr: MEMFS.node_ops.getattr, setattr: MEMFS.node_ops.setattr, lookup: MEMFS.node_ops.lookup, mknod: MEMFS.node_ops.mknod, rename: MEMFS.node_ops.rename, unlink: MEMFS.node_ops.unlink, rmdir: MEMFS.node_ops.rmdir, readdir: MEMFS.node_ops.readdir, symlink: MEMFS.node_ops.symlink }, stream: { llseek: MEMFS.stream_ops.llseek } }, file: { node: { getattr: MEMFS.node_ops.getattr, setattr: MEMFS.node_ops.setattr }, stream: { llseek: MEMFS.stream_ops.llseek, read: MEMFS.stream_ops.read, write: MEMFS.stream_ops.write, mmap: MEMFS.stream_ops.mmap, msync: MEMFS.stream_ops.msync } }, link: { node: { getattr: MEMFS.node_ops.getattr, setattr: MEMFS.node_ops.setattr, readlink: MEMFS.node_ops.readlink }, stream: {} }, chrdev: { node: { getattr: MEMFS.node_ops.getattr, setattr: MEMFS.node_ops.setattr }, stream: FS.chrdev_stream_ops } }; var node = FS.createNode(parent, name, mode, dev); if (FS.isDir(node.mode)) { node.node_ops = MEMFS.ops_table.dir.node; node.stream_ops = MEMFS.ops_table.dir.stream; node.contents = {}; } else if (FS.isFile(node.mode)) { node.node_ops = MEMFS.ops_table.file.node; node.stream_ops = MEMFS.ops_table.file.stream; node.usedBytes = 0; // The actual number of bytes used in the typed array, as opposed to contents.length which gives the whole capacity. // When the byte data of the file is populated, this will point to either a typed array, or a normal JS array. Typed arrays are preferred // for performance, and used by default. However, typed arrays are not resizable like normal JS arrays are, so there is a small disk size // penalty involved for appending file writes that continuously grow a file similar to std::vector capacity vs used -scheme. node.contents = null; } else if (FS.isLink(node.mode)) { node.node_ops = MEMFS.ops_table.link.node; node.stream_ops = MEMFS.ops_table.link.stream; } else if (FS.isChrdev(node.mode)) { node.node_ops = MEMFS.ops_table.chrdev.node; node.stream_ops = MEMFS.ops_table.chrdev.stream; } node.atime = node.mtime = node.ctime = Date.now(); // add the new node to the parent if (parent) { parent.contents[name] = node; parent.atime = parent.mtime = parent.ctime = node.atime; } return node; }, getFileDataAsTypedArray(node) { if (!node.contents) return new Uint8Array(0); if (node.contents.subarray) return node.contents.subarray(0, node.usedBytes); // Make sure to not return excess unused bytes. return new Uint8Array(node.contents); }, expandFileStorage(node, newCapacity) { var prevCapacity = node.contents ? node.contents.length : 0; if (prevCapacity >= newCapacity) return; // No need to expand, the storage was already large enough. // Don't expand strictly to the given requested limit if it's only a very small increase, but instead geometrically grow capacity. // For small filesizes (<1MB), perform size*2 geometric increase, but for large sizes, do a much more conservative size*1.125 increase to // avoid overshooting the allocation cap by a very large margin. var CAPACITY_DOUBLING_MAX = 1024 * 1024; newCapacity = Math.max(newCapacity, (prevCapacity * (prevCapacity < CAPACITY_DOUBLING_MAX ? 2.0 : 1.125)) >>> 0); if (prevCapacity != 0) newCapacity = Math.max(newCapacity, 256); // At minimum allocate 256b for each file when expanding. var oldContents = node.contents; node.contents = new Uint8Array(newCapacity); // Allocate new storage. if (node.usedBytes > 0) node.contents.set(oldContents.subarray(0, node.usedBytes), 0); // Copy old data over to the new storage. }, resizeFileStorage(node, newSize) { if (node.usedBytes == newSize) return; if (newSize == 0) { node.contents = null; // Fully decommit when requesting a resize to zero. node.usedBytes = 0; } else { var oldContents = node.contents; node.contents = new Uint8Array(newSize); // Allocate new storage. if (oldContents) { node.contents.set(oldContents.subarray(0, Math.min(newSize, node.usedBytes))); // Copy old data over to the new storage. } node.usedBytes = newSize; } }, node_ops:{ getattr(node) { var attr = {}; // device numbers reuse inode numbers. attr.dev = FS.isChrdev(node.mode) ? node.id : 1; attr.ino = node.id; attr.mode = node.mode; attr.nlink = 1; attr.uid = 0; attr.gid = 0; attr.rdev = node.rdev; if (FS.isDir(node.mode)) { attr.size = 4096; } else if (FS.isFile(node.mode)) { attr.size = node.usedBytes; } else if (FS.isLink(node.mode)) { attr.size = node.link.length; } else { attr.size = 0; } attr.atime = new Date(node.atime); attr.mtime = new Date(node.mtime); attr.ctime = new Date(node.ctime); // NOTE: In our implementation, st_blocks = Math.ceil(st_size/st_blksize), // but this is not required by the standard. attr.blksize = 4096; attr.blocks = Math.ceil(attr.size / attr.blksize); return attr; }, setattr(node, attr) { for (const key of ["mode", "atime", "mtime", "ctime"]) { if (attr[key] != null) { node[key] = attr[key]; } } if (attr.size !== undefined) { MEMFS.resizeFileStorage(node, attr.size); } }, lookup(parent, name) { throw new FS.ErrnoError(44); }, mknod(parent, name, mode, dev) { return MEMFS.createNode(parent, name, mode, dev); }, rename(old_node, new_dir, new_name) { var new_node; try { new_node = FS.lookupNode(new_dir, new_name); } catch (e) {} if (new_node) { if (FS.isDir(old_node.mode)) { // if we're overwriting a directory at new_name, make sure it's empty. for (var i in new_node.contents) { throw new FS.ErrnoError(55); } } FS.hashRemoveNode(new_node); } // do the internal rewiring delete old_node.parent.contents[old_node.name]; new_dir.contents[new_name] = old_node; old_node.name = new_name; new_dir.ctime = new_dir.mtime = old_node.parent.ctime = old_node.parent.mtime = Date.now(); }, unlink(parent, name) { delete parent.contents[name]; parent.ctime = parent.mtime = Date.now(); }, rmdir(parent, name) { var node = FS.lookupNode(parent, name); for (var i in node.contents) { throw new FS.ErrnoError(55); } delete parent.contents[name]; parent.ctime = parent.mtime = Date.now(); }, readdir(node) { return ['.', '..', ...Object.keys(node.contents)]; }, symlink(parent, newname, oldpath) { var node = MEMFS.createNode(parent, newname, 0o777 | 40960, 0); node.link = oldpath; return node; }, readlink(node) { if (!FS.isLink(node.mode)) { throw new FS.ErrnoError(28); } return node.link; }, }, stream_ops:{ read(stream, buffer, offset, length, position) { var contents = stream.node.contents; if (position >= stream.node.usedBytes) return 0; var size = Math.min(stream.node.usedBytes - position, length); assert(size >= 0); if (size > 8 && contents.subarray) { // non-trivial, and typed array buffer.set(contents.subarray(position, position + size), offset); } else { for (var i = 0; i < size; i++) buffer[offset + i] = contents[position + i]; } return size; }, write(stream, buffer, offset, length, position, canOwn) { // The data buffer should be a typed array view assert(!(buffer instanceof ArrayBuffer)); if (!length) return 0; var node = stream.node; node.mtime = node.ctime = Date.now(); if (buffer.subarray && (!node.contents || node.contents.subarray)) { // This write is from a typed array to a typed array? if (canOwn) { assert(position === 0, 'canOwn must imply no weird position inside the file'); node.contents = buffer.subarray(offset, offset + length); node.usedBytes = length; return length; } else if (node.usedBytes === 0 && position === 0) { // If this is a simple first write to an empty file, do a fast set since we don't need to care about old data. node.contents = buffer.slice(offset, offset + length); node.usedBytes = length; return length; } else if (position + length <= node.usedBytes) { // Writing to an already allocated and used subrange of the file? node.contents.set(buffer.subarray(offset, offset + length), position); return length; } } // Appending to an existing file and we need to reallocate, or source data did not come as a typed array. MEMFS.expandFileStorage(node, position+length); if (node.contents.subarray && buffer.subarray) { // Use typed array write which is available. node.contents.set(buffer.subarray(offset, offset + length), position); } else { for (var i = 0; i < length; i++) { node.contents[position + i] = buffer[offset + i]; // Or fall back to manual write if not. } } node.usedBytes = Math.max(node.usedBytes, position + length); return length; }, llseek(stream, offset, whence) { var position = offset; if (whence === 1) { position += stream.position; } else if (whence === 2) { if (FS.isFile(stream.node.mode)) { position += stream.node.usedBytes; } } if (position < 0) { throw new FS.ErrnoError(28); } return position; }, mmap(stream, length, position, prot, flags) { if (!FS.isFile(stream.node.mode)) { throw new FS.ErrnoError(43); } var ptr; var allocated; var contents = stream.node.contents; // Only make a new copy when MAP_PRIVATE is specified. if (!(flags & 2) && contents && contents.buffer === HEAP8.buffer) { // We can't emulate MAP_SHARED when the file is not backed by the // buffer we're mapping to (e.g. the HEAP buffer). allocated = false; ptr = contents.byteOffset; } else { allocated = true; ptr = mmapAlloc(length); if (!ptr) { throw new FS.ErrnoError(48); } if (contents) { // Try to avoid unnecessary slices. if (position > 0 || position + length < contents.length) { if (contents.subarray) { contents = contents.subarray(position, position + length); } else { contents = Array.prototype.slice.call(contents, position, position + length); } } HEAP8.set(contents, ptr); } } return { ptr, allocated }; }, msync(stream, buffer, offset, length, mmapFlags) { MEMFS.stream_ops.write(stream, buffer, 0, length, offset, false); // should we check if bytesWritten and length are the same? return 0; }, }, }; var FS_modeStringToFlags = (str) => { var flagModes = { 'r': 0, 'r+': 2, 'w': 512 | 64 | 1, 'w+': 512 | 64 | 2, 'a': 1024 | 64 | 1, 'a+': 1024 | 64 | 2, }; var flags = flagModes[str]; if (typeof flags == 'undefined') { throw new Error(`Unknown file open mode: ${str}`); } return flags; }; var FS_getMode = (canRead, canWrite) => { var mode = 0; if (canRead) mode |= 292 | 73; if (canWrite) mode |= 146; return mode; }; /** * Given a pointer 'ptr' to a null-terminated UTF8-encoded string in the * emscripten HEAP, returns a copy of that string as a Javascript String object. * * @param {number} ptr * @param {number=} maxBytesToRead - An optional length that specifies the * maximum number of bytes to read. You can omit this parameter to scan the * string until the first 0 byte. If maxBytesToRead is passed, and the string * at [ptr, ptr+maxBytesToReadr[ contains a null byte in the middle, then the * string will cut short at that byte index. * @param {boolean=} ignoreNul - If true, the function will not stop on a NUL character. * @return {string} */ var UTF8ToString = (ptr, maxBytesToRead, ignoreNul) => { assert(typeof ptr == 'number', `UTF8ToString expects a number (got ${typeof ptr})`); return ptr ? UTF8ArrayToString(HEAPU8, ptr, maxBytesToRead, ignoreNul) : ''; }; var strError = (errno) => UTF8ToString(_strerror(errno)); var ERRNO_CODES = { 'EPERM': 63, 'ENOENT': 44, 'ESRCH': 71, 'EINTR': 27, 'EIO': 29, 'ENXIO': 60, 'E2BIG': 1, 'ENOEXEC': 45, 'EBADF': 8, 'ECHILD': 12, 'EAGAIN': 6, 'EWOULDBLOCK': 6, 'ENOMEM': 48, 'EACCES': 2, 'EFAULT': 21, 'ENOTBLK': 105, 'EBUSY': 10, 'EEXIST': 20, 'EXDEV': 75, 'ENODEV': 43, 'ENOTDIR': 54, 'EISDIR': 31, 'EINVAL': 28, 'ENFILE': 41, 'EMFILE': 33, 'ENOTTY': 59, 'ETXTBSY': 74, 'EFBIG': 22, 'ENOSPC': 51, 'ESPIPE': 70, 'EROFS': 69, 'EMLINK': 34, 'EPIPE': 64, 'EDOM': 18, 'ERANGE': 68, 'ENOMSG': 49, 'EIDRM': 24, 'ECHRNG': 106, 'EL2NSYNC': 156, 'EL3HLT': 107, 'EL3RST': 108, 'ELNRNG': 109, 'EUNATCH': 110, 'ENOCSI': 111, 'EL2HLT': 112, 'EDEADLK': 16, 'ENOLCK': 46, 'EBADE': 113, 'EBADR': 114, 'EXFULL': 115, 'ENOANO': 104, 'EBADRQC': 103, 'EBADSLT': 102, 'EDEADLOCK': 16, 'EBFONT': 101, 'ENOSTR': 100, 'ENODATA': 116, 'ETIME': 117, 'ENOSR': 118, 'ENONET': 119, 'ENOPKG': 120, 'EREMOTE': 121, 'ENOLINK': 47, 'EADV': 122, 'ESRMNT': 123, 'ECOMM': 124, 'EPROTO': 65, 'EMULTIHOP': 36, 'EDOTDOT': 125, 'EBADMSG': 9, 'ENOTUNIQ': 126, 'EBADFD': 127, 'EREMCHG': 128, 'ELIBACC': 129, 'ELIBBAD': 130, 'ELIBSCN': 131, 'ELIBMAX': 132, 'ELIBEXEC': 133, 'ENOSYS': 52, 'ENOTEMPTY': 55, 'ENAMETOOLONG': 37, 'ELOOP': 32, 'EOPNOTSUPP': 138, 'EPFNOSUPPORT': 139, 'ECONNRESET': 15, 'ENOBUFS': 42, 'EAFNOSUPPORT': 5, 'EPROTOTYPE': 67, 'ENOTSOCK': 57, 'ENOPROTOOPT': 50, 'ESHUTDOWN': 140, 'ECONNREFUSED': 14, 'EADDRINUSE': 3, 'ECONNABORTED': 13, 'ENETUNREACH': 40, 'ENETDOWN': 38, 'ETIMEDOUT': 73, 'EHOSTDOWN': 142, 'EHOSTUNREACH': 23, 'EINPROGRESS': 26, 'EALREADY': 7, 'EDESTADDRREQ': 17, 'EMSGSIZE': 35, 'EPROTONOSUPPORT': 66, 'ESOCKTNOSUPPORT': 137, 'EADDRNOTAVAIL': 4, 'ENETRESET': 39, 'EISCONN': 30, 'ENOTCONN': 53, 'ETOOMANYREFS': 141, 'EUSERS': 136, 'EDQUOT': 19, 'ESTALE': 72, 'ENOTSUP': 138, 'ENOMEDIUM': 148, 'EILSEQ': 25, 'EOVERFLOW': 61, 'ECANCELED': 11, 'ENOTRECOVERABLE': 56, 'EOWNERDEAD': 62, 'ESTRPIPE': 135, }; var asyncLoad = async (url) => { var arrayBuffer = await readAsync(url); assert(arrayBuffer, `Loading data file "${url}" failed (no arrayBuffer).`); return new Uint8Array(arrayBuffer); }; var FS_createDataFile = (...args) => FS.createDataFile(...args); var getUniqueRunDependency = (id) => { var orig = id; while (1) { if (!runDependencyTracking[id]) return id; id = orig + Math.random(); } }; var runDependencies = 0; var dependenciesFulfilled = null; var runDependencyTracking = { }; var runDependencyWatcher = null; var removeRunDependency = (id) => { runDependencies--; Module['monitorRunDependencies']?.(runDependencies); assert(id, 'removeRunDependency requires an ID'); assert(runDependencyTracking[id]); delete runDependencyTracking[id]; if (runDependencies == 0) { if (runDependencyWatcher !== null) { clearInterval(runDependencyWatcher); runDependencyWatcher = null; } if (dependenciesFulfilled) { var callback = dependenciesFulfilled; dependenciesFulfilled = null; callback(); // can add another dependenciesFulfilled } } }; var addRunDependency = (id) => { runDependencies++; Module['monitorRunDependencies']?.(runDependencies); assert(id, 'addRunDependency requires an ID') assert(!runDependencyTracking[id]); runDependencyTracking[id] = 1; if (runDependencyWatcher === null && globalThis.setInterval) { // Check for missing dependencies every few seconds runDependencyWatcher = setInterval(() => { if (ABORT) { clearInterval(runDependencyWatcher); runDependencyWatcher = null; return; } var shown = false; for (var dep in runDependencyTracking) { if (!shown) { shown = true; err('still waiting on run dependencies:'); } err(`dependency: ${dep}`); } if (shown) { err('(end of list)'); } }, 10000); // Prevent this timer from keeping the runtime alive if nothing // else is. runDependencyWatcher.unref?.() } }; var preloadPlugins = []; var FS_handledByPreloadPlugin = async (byteArray, fullname) => { // Ensure plugins are ready. if (typeof Browser != 'undefined') Browser.init(); for (var plugin of preloadPlugins) { if (plugin['canHandle'](fullname)) { assert(plugin['handle'].constructor.name === 'AsyncFunction', 'Filesystem plugin handlers must be async functions (See #24914)') return plugin['handle'](byteArray, fullname); } } // In no plugin handled this file then return the original/unmodified // byteArray. return byteArray; }; var FS_preloadFile = async (parent, name, url, canRead, canWrite, dontCreateFile, canOwn, preFinish) => { // TODO we should allow people to just pass in a complete filename instead // of parent and name being that we just join them anyways var fullname = name ? PATH_FS.resolve(PATH.join2(parent, name)) : parent; var dep = getUniqueRunDependency(`cp ${fullname}`); // might have several active requests for the same fullname addRunDependency(dep); try { var byteArray = url; if (typeof url == 'string') { byteArray = await asyncLoad(url); } byteArray = await FS_handledByPreloadPlugin(byteArray, fullname); preFinish?.(); if (!dontCreateFile) { FS_createDataFile(parent, name, byteArray, canRead, canWrite, canOwn); } } finally { removeRunDependency(dep); } }; var FS_createPreloadedFile = (parent, name, url, canRead, canWrite, onload, onerror, dontCreateFile, canOwn, preFinish) => { FS_preloadFile(parent, name, url, canRead, canWrite, dontCreateFile, canOwn, preFinish).then(onload).catch(onerror); }; var FS = { root:null, mounts:[], devices:{ }, streams:[], nextInode:1, nameTable:null, currentPath:"/", initialized:false, ignorePermissions:true, filesystems:null, syncFSRequests:0, readFiles:{ }, ErrnoError:class extends Error { name = 'ErrnoError'; // We set the `name` property to be able to identify `FS.ErrnoError` // - the `name` is a standard ECMA-262 property of error objects. Kind of good to have it anyway. // - when using PROXYFS, an error can come from an underlying FS // as different FS objects have their own FS.ErrnoError each, // the test `err instanceof FS.ErrnoError` won't detect an error coming from another filesystem, causing bugs. // we'll use the reliable test `err.name == "ErrnoError"` instead constructor(errno) { super(runtimeInitialized ? strError(errno) : ''); this.errno = errno; for (var key in ERRNO_CODES) { if (ERRNO_CODES[key] === errno) { this.code = key; break; } } } }, FSStream:class { shared = {}; get object() { return this.node; } set object(val) { this.node = val; } get isRead() { return (this.flags & 2097155) !== 1; } get isWrite() { return (this.flags & 2097155) !== 0; } get isAppend() { return (this.flags & 1024); } get flags() { return this.shared.flags; } set flags(val) { this.shared.flags = val; } get position() { return this.shared.position; } set position(val) { this.shared.position = val; } }, FSNode:class { node_ops = {}; stream_ops = {}; readMode = 292 | 73; writeMode = 146; mounted = null; constructor(parent, name, mode, rdev) { if (!parent) { parent = this; // root node sets parent to itself } this.parent = parent; this.mount = parent.mount; this.id = FS.nextInode++; this.name = name; this.mode = mode; this.rdev = rdev; this.atime = this.mtime = this.ctime = Date.now(); } get read() { return (this.mode & this.readMode) === this.readMode; } set read(val) { val ? this.mode |= this.readMode : this.mode &= ~this.readMode; } get write() { return (this.mode & this.writeMode) === this.writeMode; } set write(val) { val ? this.mode |= this.writeMode : this.mode &= ~this.writeMode; } get isFolder() { return FS.isDir(this.mode); } get isDevice() { return FS.isChrdev(this.mode); } }, lookupPath(path, opts = {}) { if (!path) { throw new FS.ErrnoError(44); } opts.follow_mount ??= true if (!PATH.isAbs(path)) { path = FS.cwd() + '/' + path; } // limit max consecutive symlinks to 40 (SYMLOOP_MAX). linkloop: for (var nlinks = 0; nlinks < 40; nlinks++) { // split the absolute path var parts = path.split('/').filter((p) => !!p); // start at the root var current = FS.root; var current_path = '/'; for (var i = 0; i < parts.length; i++) { var islast = (i === parts.length-1); if (islast && opts.parent) { // stop resolving break; } if (parts[i] === '.') { continue; } if (parts[i] === '..') { current_path = PATH.dirname(current_path); if (FS.isRoot(current)) { path = current_path + '/' + parts.slice(i + 1).join('/'); // We're making progress here, don't let many consecutive ..'s // lead to ELOOP nlinks--; continue linkloop; } else { current = current.parent; } continue; } current_path = PATH.join2(current_path, parts[i]); try { current = FS.lookupNode(current, parts[i]); } catch (e) { // if noent_okay is true, suppress a ENOENT in the last component // and return an object with an undefined node. This is needed for // resolving symlinks in the path when creating a file. if ((e?.errno === 44) && islast && opts.noent_okay) { return { path: current_path }; } throw e; } // jump to the mount's root node if this is a mountpoint if (FS.isMountpoint(current) && (!islast || opts.follow_mount)) { current = current.mounted.root; } // by default, lookupPath will not follow a symlink if it is the final path component. // setting opts.follow = true will override this behavior. if (FS.isLink(current.mode) && (!islast || opts.follow)) { if (!current.node_ops.readlink) { throw new FS.ErrnoError(52); } var link = current.node_ops.readlink(current); if (!PATH.isAbs(link)) { link = PATH.dirname(current_path) + '/' + link; } path = link + '/' + parts.slice(i + 1).join('/'); continue linkloop; } } return { path: current_path, node: current }; } throw new FS.ErrnoError(32); }, getPath(node) { var path; while (true) { if (FS.isRoot(node)) { var mount = node.mount.mountpoint; if (!path) return mount; return mount[mount.length-1] !== '/' ? `${mount}/${path}` : mount + path; } path = path ? `${node.name}/${path}` : node.name; node = node.parent; } }, hashName(parentid, name) { var hash = 0; for (var i = 0; i < name.length; i++) { hash = ((hash << 5) - hash + name.charCodeAt(i)) | 0; } return ((parentid + hash) >>> 0) % FS.nameTable.length; }, hashAddNode(node) { var hash = FS.hashName(node.parent.id, node.name); node.name_next = FS.nameTable[hash]; FS.nameTable[hash] = node; }, hashRemoveNode(node) { var hash = FS.hashName(node.parent.id, node.name); if (FS.nameTable[hash] === node) { FS.nameTable[hash] = node.name_next; } else { var current = FS.nameTable[hash]; while (current) { if (current.name_next === node) { current.name_next = node.name_next; break; } current = current.name_next; } } }, lookupNode(parent, name) { var errCode = FS.mayLookup(parent); if (errCode) { throw new FS.ErrnoError(errCode); } var hash = FS.hashName(parent.id, name); for (var node = FS.nameTable[hash]; node; node = node.name_next) { var nodeName = node.name; if (node.parent.id === parent.id && nodeName === name) { return node; } } // if we failed to find it in the cache, call into the VFS return FS.lookup(parent, name); }, createNode(parent, name, mode, rdev) { assert(typeof parent == 'object') var node = new FS.FSNode(parent, name, mode, rdev); FS.hashAddNode(node); return node; }, destroyNode(node) { FS.hashRemoveNode(node); }, isRoot(node) { return node === node.parent; }, isMountpoint(node) { return !!node.mounted; }, isFile(mode) { return (mode & 61440) === 32768; }, isDir(mode) { return (mode & 61440) === 16384; }, isLink(mode) { return (mode & 61440) === 40960; }, isChrdev(mode) { return (mode & 61440) === 8192; }, isBlkdev(mode) { return (mode & 61440) === 24576; }, isFIFO(mode) { return (mode & 61440) === 4096; }, isSocket(mode) { return (mode & 49152) === 49152; }, flagsToPermissionString(flag) { var perms = ['r', 'w', 'rw'][flag & 3]; if ((flag & 512)) { perms += 'w'; } return perms; }, nodePermissions(node, perms) { if (FS.ignorePermissions) { return 0; } // return 0 if any user, group or owner bits are set. if (perms.includes('r') && !(node.mode & 292)) { return 2; } else if (perms.includes('w') && !(node.mode & 146)) { return 2; } else if (perms.includes('x') && !(node.mode & 73)) { return 2; } return 0; }, mayLookup(dir) { if (!FS.isDir(dir.mode)) return 54; var errCode = FS.nodePermissions(dir, 'x'); if (errCode) return errCode; if (!dir.node_ops.lookup) return 2; return 0; }, mayCreate(dir, name) { if (!FS.isDir(dir.mode)) { return 54; } try { var node = FS.lookupNode(dir, name); return 20; } catch (e) { } return FS.nodePermissions(dir, 'wx'); }, mayDelete(dir, name, isdir) { var node; try { node = FS.lookupNode(dir, name); } catch (e) { return e.errno; } var errCode = FS.nodePermissions(dir, 'wx'); if (errCode) { return errCode; } if (isdir) { if (!FS.isDir(node.mode)) { return 54; } if (FS.isRoot(node) || FS.getPath(node) === FS.cwd()) { return 10; } } else { if (FS.isDir(node.mode)) { return 31; } } return 0; }, mayOpen(node, flags) { if (!node) { return 44; } if (FS.isLink(node.mode)) { return 32; } else if (FS.isDir(node.mode)) { if (FS.flagsToPermissionString(flags) !== 'r' // opening for write || (flags & (512 | 64))) { // TODO: check for O_SEARCH? (== search for dir only) return 31; } } return FS.nodePermissions(node, FS.flagsToPermissionString(flags)); }, checkOpExists(op, err) { if (!op) { throw new FS.ErrnoError(err); } return op; }, MAX_OPEN_FDS:4096, nextfd() { for (var fd = 0; fd <= FS.MAX_OPEN_FDS; fd++) { if (!FS.streams[fd]) { return fd; } } throw new FS.ErrnoError(33); }, getStreamChecked(fd) { var stream = FS.getStream(fd); if (!stream) { throw new FS.ErrnoError(8); } return stream; }, getStream:(fd) => FS.streams[fd], createStream(stream, fd = -1) { assert(fd >= -1); // clone it, so we can return an instance of FSStream stream = Object.assign(new FS.FSStream(), stream); if (fd == -1) { fd = FS.nextfd(); } stream.fd = fd; FS.streams[fd] = stream; return stream; }, closeStream(fd) { FS.streams[fd] = null; }, dupStream(origStream, fd = -1) { var stream = FS.createStream(origStream, fd); stream.stream_ops?.dup?.(stream); return stream; }, doSetAttr(stream, node, attr) { var setattr = stream?.stream_ops.setattr; var arg = setattr ? stream : node; setattr ??= node.node_ops.setattr; FS.checkOpExists(setattr, 63) setattr(arg, attr); }, chrdev_stream_ops:{ open(stream) { var device = FS.getDevice(stream.node.rdev); // override node's stream ops with the device's stream.stream_ops = device.stream_ops; // forward the open call stream.stream_ops.open?.(stream); }, llseek() { throw new FS.ErrnoError(70); }, }, major:(dev) => ((dev) >> 8), minor:(dev) => ((dev) & 0xff), makedev:(ma, mi) => ((ma) << 8 | (mi)), registerDevice(dev, ops) { FS.devices[dev] = { stream_ops: ops }; }, getDevice:(dev) => FS.devices[dev], getMounts(mount) { var mounts = []; var check = [mount]; while (check.length) { var m = check.pop(); mounts.push(m); check.push(...m.mounts); } return mounts; }, syncfs(populate, callback) { if (typeof populate == 'function') { callback = populate; populate = false; } FS.syncFSRequests++; if (FS.syncFSRequests > 1) { err(`warning: ${FS.syncFSRequests} FS.syncfs operations in flight at once, probably just doing extra work`); } var mounts = FS.getMounts(FS.root.mount); var completed = 0; function doCallback(errCode) { assert(FS.syncFSRequests > 0); FS.syncFSRequests--; return callback(errCode); } function done(errCode) { if (errCode) { if (!done.errored) { done.errored = true; return doCallback(errCode); } return; } if (++completed >= mounts.length) { doCallback(null); } }; // sync all mounts for (var mount of mounts) { if (mount.type.syncfs) { mount.type.syncfs(mount, populate, done); } else { done(null); } } }, mount(type, opts, mountpoint) { if (typeof type == 'string') { // The filesystem was not included, and instead we have an error // message stored in the variable. throw type; } var root = mountpoint === '/'; var pseudo = !mountpoint; var node; if (root && FS.root) { throw new FS.ErrnoError(10); } else if (!root && !pseudo) { var lookup = FS.lookupPath(mountpoint, { follow_mount: false }); mountpoint = lookup.path; // use the absolute path node = lookup.node; if (FS.isMountpoint(node)) { throw new FS.ErrnoError(10); } if (!FS.isDir(node.mode)) { throw new FS.ErrnoError(54); } } var mount = { type, opts, mountpoint, mounts: [] }; // create a root node for the fs var mountRoot = type.mount(mount); mountRoot.mount = mount; mount.root = mountRoot; if (root) { FS.root = mountRoot; } else if (node) { // set as a mountpoint node.mounted = mount; // add the new mount to the current mount's children if (node.mount) { node.mount.mounts.push(mount); } } return mountRoot; }, unmount(mountpoint) { var lookup = FS.lookupPath(mountpoint, { follow_mount: false }); if (!FS.isMountpoint(lookup.node)) { throw new FS.ErrnoError(28); } // destroy the nodes for this mount, and all its child mounts var node = lookup.node; var mount = node.mounted; var mounts = FS.getMounts(mount); for (var [hash, current] of Object.entries(FS.nameTable)) { while (current) { var next = current.name_next; if (mounts.includes(current.mount)) { FS.destroyNode(current); } current = next; } } // no longer a mountpoint node.mounted = null; // remove this mount from the child mounts var idx = node.mount.mounts.indexOf(mount); assert(idx !== -1); node.mount.mounts.splice(idx, 1); }, lookup(parent, name) { return parent.node_ops.lookup(parent, name); }, mknod(path, mode, dev) { var lookup = FS.lookupPath(path, { parent: true }); var parent = lookup.node; var name = PATH.basename(path); if (!name) { throw new FS.ErrnoError(28); } if (name === '.' || name === '..') { throw new FS.ErrnoError(20); } var errCode = FS.mayCreate(parent, name); if (errCode) { throw new FS.ErrnoError(errCode); } if (!parent.node_ops.mknod) { throw new FS.ErrnoError(63); } return parent.node_ops.mknod(parent, name, mode, dev); }, statfs(path) { return FS.statfsNode(FS.lookupPath(path, {follow: true}).node); }, statfsStream(stream) { // We keep a separate statfsStream function because noderawfs overrides // it. In noderawfs, stream.node is sometimes null. Instead, we need to // look at stream.path. return FS.statfsNode(stream.node); }, statfsNode(node) { // NOTE: None of the defaults here are true. We're just returning safe and // sane values. Currently nodefs and rawfs replace these defaults, // other file systems leave them alone. var rtn = { bsize: 4096, frsize: 4096, blocks: 1e6, bfree: 5e5, bavail: 5e5, files: FS.nextInode, ffree: FS.nextInode - 1, fsid: 42, flags: 2, namelen: 255, }; if (node.node_ops.statfs) { Object.assign(rtn, node.node_ops.statfs(node.mount.opts.root)); } return rtn; }, create(path, mode = 0o666) { mode &= 4095; mode |= 32768; return FS.mknod(path, mode, 0); }, mkdir(path, mode = 0o777) { mode &= 511 | 512; mode |= 16384; return FS.mknod(path, mode, 0); }, mkdirTree(path, mode) { var dirs = path.split('/'); var d = ''; for (var dir of dirs) { if (!dir) continue; if (d || PATH.isAbs(path)) d += '/'; d += dir; try { FS.mkdir(d, mode); } catch(e) { if (e.errno != 20) throw e; } } }, mkdev(path, mode, dev) { if (typeof dev == 'undefined') { dev = mode; mode = 0o666; } mode |= 8192; return FS.mknod(path, mode, dev); }, symlink(oldpath, newpath) { if (!PATH_FS.resolve(oldpath)) { throw new FS.ErrnoError(44); } var lookup = FS.lookupPath(newpath, { parent: true }); var parent = lookup.node; if (!parent) { throw new FS.ErrnoError(44); } var newname = PATH.basename(newpath); var errCode = FS.mayCreate(parent, newname); if (errCode) { throw new FS.ErrnoError(errCode); } if (!parent.node_ops.symlink) { throw new FS.ErrnoError(63); } return parent.node_ops.symlink(parent, newname, oldpath); }, rename(old_path, new_path) { var old_dirname = PATH.dirname(old_path); var new_dirname = PATH.dirname(new_path); var old_name = PATH.basename(old_path); var new_name = PATH.basename(new_path); // parents must exist var lookup, old_dir, new_dir; // let the errors from non existent directories percolate up lookup = FS.lookupPath(old_path, { parent: true }); old_dir = lookup.node; lookup = FS.lookupPath(new_path, { parent: true }); new_dir = lookup.node; if (!old_dir || !new_dir) throw new FS.ErrnoError(44); // need to be part of the same mount if (old_dir.mount !== new_dir.mount) { throw new FS.ErrnoError(75); } // source must exist var old_node = FS.lookupNode(old_dir, old_name); // old path should not be an ancestor of the new path var relative = PATH_FS.relative(old_path, new_dirname); if (relative.charAt(0) !== '.') { throw new FS.ErrnoError(28); } // new path should not be an ancestor of the old path relative = PATH_FS.relative(new_path, old_dirname); if (relative.charAt(0) !== '.') { throw new FS.ErrnoError(55); } // see if the new path already exists var new_node; try { new_node = FS.lookupNode(new_dir, new_name); } catch (e) { // not fatal } // early out if nothing needs to change if (old_node === new_node) { return; } // we'll need to delete the old entry var isdir = FS.isDir(old_node.mode); var errCode = FS.mayDelete(old_dir, old_name, isdir); if (errCode) { throw new FS.ErrnoError(errCode); } // need delete permissions if we'll be overwriting. // need create permissions if new doesn't already exist. errCode = new_node ? FS.mayDelete(new_dir, new_name, isdir) : FS.mayCreate(new_dir, new_name); if (errCode) { throw new FS.ErrnoError(errCode); } if (!old_dir.node_ops.rename) { throw new FS.ErrnoError(63); } if (FS.isMountpoint(old_node) || (new_node && FS.isMountpoint(new_node))) { throw new FS.ErrnoError(10); } // if we are going to change the parent, check write permissions if (new_dir !== old_dir) { errCode = FS.nodePermissions(old_dir, 'w'); if (errCode) { throw new FS.ErrnoError(errCode); } } // remove the node from the lookup hash FS.hashRemoveNode(old_node); // do the underlying fs rename try { old_dir.node_ops.rename(old_node, new_dir, new_name); // update old node (we do this here to avoid each backend // needing to) old_node.parent = new_dir; } catch (e) { throw e; } finally { // add the node back to the hash (in case node_ops.rename // changed its name) FS.hashAddNode(old_node); } }, rmdir(path) { var lookup = FS.lookupPath(path, { parent: true }); var parent = lookup.node; var name = PATH.basename(path); var node = FS.lookupNode(parent, name); var errCode = FS.mayDelete(parent, name, true); if (errCode) { throw new FS.ErrnoError(errCode); } if (!parent.node_ops.rmdir) { throw new FS.ErrnoError(63); } if (FS.isMountpoint(node)) { throw new FS.ErrnoError(10); } parent.node_ops.rmdir(parent, name); FS.destroyNode(node); }, readdir(path) { var lookup = FS.lookupPath(path, { follow: true }); var node = lookup.node; var readdir = FS.checkOpExists(node.node_ops.readdir, 54); return readdir(node); }, unlink(path) { var lookup = FS.lookupPath(path, { parent: true }); var parent = lookup.node; if (!parent) { throw new FS.ErrnoError(44); } var name = PATH.basename(path); var node = FS.lookupNode(parent, name); var errCode = FS.mayDelete(parent, name, false); if (errCode) { // According to POSIX, we should map EISDIR to EPERM, but // we instead do what Linux does (and we must, as we use // the musl linux libc). throw new FS.ErrnoError(errCode); } if (!parent.node_ops.unlink) { throw new FS.ErrnoError(63); } if (FS.isMountpoint(node)) { throw new FS.ErrnoError(10); } parent.node_ops.unlink(parent, name); FS.destroyNode(node); }, readlink(path) { var lookup = FS.lookupPath(path); var link = lookup.node; if (!link) { throw new FS.ErrnoError(44); } if (!link.node_ops.readlink) { throw new FS.ErrnoError(28); } return link.node_ops.readlink(link); }, stat(path, dontFollow) { var lookup = FS.lookupPath(path, { follow: !dontFollow }); var node = lookup.node; var getattr = FS.checkOpExists(node.node_ops.getattr, 63); return getattr(node); }, fstat(fd) { var stream = FS.getStreamChecked(fd); var node = stream.node; var getattr = stream.stream_ops.getattr; var arg = getattr ? stream : node; getattr ??= node.node_ops.getattr; FS.checkOpExists(getattr, 63) return getattr(arg); }, lstat(path) { return FS.stat(path, true); }, doChmod(stream, node, mode, dontFollow) { FS.doSetAttr(stream, node, { mode: (mode & 4095) | (node.mode & ~4095), ctime: Date.now(), dontFollow }); }, chmod(path, mode, dontFollow) { var node; if (typeof path == 'string') { var lookup = FS.lookupPath(path, { follow: !dontFollow }); node = lookup.node; } else { node = path; } FS.doChmod(null, node, mode, dontFollow); }, lchmod(path, mode) { FS.chmod(path, mode, true); }, fchmod(fd, mode) { var stream = FS.getStreamChecked(fd); FS.doChmod(stream, stream.node, mode, false); }, doChown(stream, node, dontFollow) { FS.doSetAttr(stream, node, { timestamp: Date.now(), dontFollow // we ignore the uid / gid for now }); }, chown(path, uid, gid, dontFollow) { var node; if (typeof path == 'string') { var lookup = FS.lookupPath(path, { follow: !dontFollow }); node = lookup.node; } else { node = path; } FS.doChown(null, node, dontFollow); }, lchown(path, uid, gid) { FS.chown(path, uid, gid, true); }, fchown(fd, uid, gid) { var stream = FS.getStreamChecked(fd); FS.doChown(stream, stream.node, false); }, doTruncate(stream, node, len) { if (FS.isDir(node.mode)) { throw new FS.ErrnoError(31); } if (!FS.isFile(node.mode)) { throw new FS.ErrnoError(28); } var errCode = FS.nodePermissions(node, 'w'); if (errCode) { throw new FS.ErrnoError(errCode); } FS.doSetAttr(stream, node, { size: len, timestamp: Date.now() }); }, truncate(path, len) { if (len < 0) { throw new FS.ErrnoError(28); } var node; if (typeof path == 'string') { var lookup = FS.lookupPath(path, { follow: true }); node = lookup.node; } else { node = path; } FS.doTruncate(null, node, len); }, ftruncate(fd, len) { var stream = FS.getStreamChecked(fd); if (len < 0 || (stream.flags & 2097155) === 0) { throw new FS.ErrnoError(28); } FS.doTruncate(stream, stream.node, len); }, utime(path, atime, mtime) { var lookup = FS.lookupPath(path, { follow: true }); var node = lookup.node; var setattr = FS.checkOpExists(node.node_ops.setattr, 63); setattr(node, { atime: atime, mtime: mtime }); }, open(path, flags, mode = 0o666) { if (path === "") { throw new FS.ErrnoError(44); } flags = typeof flags == 'string' ? FS_modeStringToFlags(flags) : flags; if ((flags & 64)) { mode = (mode & 4095) | 32768; } else { mode = 0; } var node; var isDirPath; if (typeof path == 'object') { node = path; } else { isDirPath = path.endsWith("/"); // noent_okay makes it so that if the final component of the path // doesn't exist, lookupPath returns `node: undefined`. `path` will be // updated to point to the target of all symlinks. var lookup = FS.lookupPath(path, { follow: !(flags & 131072), noent_okay: true }); node = lookup.node; path = lookup.path; } // perhaps we need to create the node var created = false; if ((flags & 64)) { if (node) { // if O_CREAT and O_EXCL are set, error out if the node already exists if ((flags & 128)) { throw new FS.ErrnoError(20); } } else if (isDirPath) { throw new FS.ErrnoError(31); } else { // node doesn't exist, try to create it // Ignore the permission bits here to ensure we can `open` this new // file below. We use chmod below the apply the permissions once the // file is open. node = FS.mknod(path, mode | 0o777, 0); created = true; } } if (!node) { throw new FS.ErrnoError(44); } // can't truncate a device if (FS.isChrdev(node.mode)) { flags &= ~512; } // if asked only for a directory, then this must be one if ((flags & 65536) && !FS.isDir(node.mode)) { throw new FS.ErrnoError(54); } // check permissions, if this is not a file we just created now (it is ok to // create and write to a file with read-only permissions; it is read-only // for later use) if (!created) { var errCode = FS.mayOpen(node, flags); if (errCode) { throw new FS.ErrnoError(errCode); } } // do truncation if necessary if ((flags & 512) && !created) { FS.truncate(node, 0); } // we've already handled these, don't pass down to the underlying vfs flags &= ~(128 | 512 | 131072); // register the stream with the filesystem var stream = FS.createStream({ node, path: FS.getPath(node), // we want the absolute path to the node flags, seekable: true, position: 0, stream_ops: node.stream_ops, // used by the file family libc calls (fopen, fwrite, ferror, etc.) ungotten: [], error: false }); // call the new stream's open function if (stream.stream_ops.open) { stream.stream_ops.open(stream); } if (created) { FS.chmod(node, mode & 0o777); } if (Module['logReadFiles'] && !(flags & 1)) { if (!(path in FS.readFiles)) { FS.readFiles[path] = 1; } } return stream; }, close(stream) { if (FS.isClosed(stream)) { throw new FS.ErrnoError(8); } if (stream.getdents) stream.getdents = null; // free readdir state try { if (stream.stream_ops.close) { stream.stream_ops.close(stream); } } catch (e) { throw e; } finally { FS.closeStream(stream.fd); } stream.fd = null; }, isClosed(stream) { return stream.fd === null; }, llseek(stream, offset, whence) { if (FS.isClosed(stream)) { throw new FS.ErrnoError(8); } if (!stream.seekable || !stream.stream_ops.llseek) { throw new FS.ErrnoError(70); } if (whence != 0 && whence != 1 && whence != 2) { throw new FS.ErrnoError(28); } stream.position = stream.stream_ops.llseek(stream, offset, whence); stream.ungotten = []; return stream.position; }, read(stream, buffer, offset, length, position) { assert(offset >= 0); if (length < 0 || position < 0) { throw new FS.ErrnoError(28); } if (FS.isClosed(stream)) { throw new FS.ErrnoError(8); } if ((stream.flags & 2097155) === 1) { throw new FS.ErrnoError(8); } if (FS.isDir(stream.node.mode)) { throw new FS.ErrnoError(31); } if (!stream.stream_ops.read) { throw new FS.ErrnoError(28); } var seeking = typeof position != 'undefined'; if (!seeking) { position = stream.position; } else if (!stream.seekable) { throw new FS.ErrnoError(70); } var bytesRead = stream.stream_ops.read(stream, buffer, offset, length, position); if (!seeking) stream.position += bytesRead; return bytesRead; }, write(stream, buffer, offset, length, position, canOwn) { assert(offset >= 0); if (length < 0 || position < 0) { throw new FS.ErrnoError(28); } if (FS.isClosed(stream)) { throw new FS.ErrnoError(8); } if ((stream.flags & 2097155) === 0) { throw new FS.ErrnoError(8); } if (FS.isDir(stream.node.mode)) { throw new FS.ErrnoError(31); } if (!stream.stream_ops.write) { throw new FS.ErrnoError(28); } if (stream.seekable && stream.flags & 1024) { // seek to the end before writing in append mode FS.llseek(stream, 0, 2); } var seeking = typeof position != 'undefined'; if (!seeking) { position = stream.position; } else if (!stream.seekable) { throw new FS.ErrnoError(70); } var bytesWritten = stream.stream_ops.write(stream, buffer, offset, length, position, canOwn); if (!seeking) stream.position += bytesWritten; return bytesWritten; }, mmap(stream, length, position, prot, flags) { // User requests writing to file (prot & PROT_WRITE != 0). // Checking if we have permissions to write to the file unless // MAP_PRIVATE flag is set. According to POSIX spec it is possible // to write to file opened in read-only mode with MAP_PRIVATE flag, // as all modifications will be visible only in the memory of // the current process. if ((prot & 2) !== 0 && (flags & 2) === 0 && (stream.flags & 2097155) !== 2) { throw new FS.ErrnoError(2); } if ((stream.flags & 2097155) === 1) { throw new FS.ErrnoError(2); } if (!stream.stream_ops.mmap) { throw new FS.ErrnoError(43); } if (!length) { throw new FS.ErrnoError(28); } return stream.stream_ops.mmap(stream, length, position, prot, flags); }, msync(stream, buffer, offset, length, mmapFlags) { assert(offset >= 0); if (!stream.stream_ops.msync) { return 0; } return stream.stream_ops.msync(stream, buffer, offset, length, mmapFlags); }, ioctl(stream, cmd, arg) { if (!stream.stream_ops.ioctl) { throw new FS.ErrnoError(59); } return stream.stream_ops.ioctl(stream, cmd, arg); }, readFile(path, opts = {}) { opts.flags = opts.flags || 0; opts.encoding = opts.encoding || 'binary'; if (opts.encoding !== 'utf8' && opts.encoding !== 'binary') { abort(`Invalid encoding type "${opts.encoding}"`); } var stream = FS.open(path, opts.flags); var stat = FS.stat(path); var length = stat.size; var buf = new Uint8Array(length); FS.read(stream, buf, 0, length, 0); if (opts.encoding === 'utf8') { buf = UTF8ArrayToString(buf); } FS.close(stream); return buf; }, writeFile(path, data, opts = {}) { opts.flags = opts.flags || 577; var stream = FS.open(path, opts.flags, opts.mode); if (typeof data == 'string') { data = new Uint8Array(intArrayFromString(data, true)); } if (ArrayBuffer.isView(data)) { FS.write(stream, data, 0, data.byteLength, undefined, opts.canOwn); } else { abort('Unsupported data type'); } FS.close(stream); }, cwd:() => FS.currentPath, chdir(path) { var lookup = FS.lookupPath(path, { follow: true }); if (lookup.node === null) { throw new FS.ErrnoError(44); } if (!FS.isDir(lookup.node.mode)) { throw new FS.ErrnoError(54); } var errCode = FS.nodePermissions(lookup.node, 'x'); if (errCode) { throw new FS.ErrnoError(errCode); } FS.currentPath = lookup.path; }, createDefaultDirectories() { FS.mkdir('/tmp'); FS.mkdir('/home'); FS.mkdir('/home/web_user'); }, createDefaultDevices() { // create /dev FS.mkdir('/dev'); // setup /dev/null FS.registerDevice(FS.makedev(1, 3), { read: () => 0, write: (stream, buffer, offset, length, pos) => length, llseek: () => 0, }); FS.mkdev('/dev/null', FS.makedev(1, 3)); // setup /dev/tty and /dev/tty1 // stderr needs to print output using err() rather than out() // so we register a second tty just for it. TTY.register(FS.makedev(5, 0), TTY.default_tty_ops); TTY.register(FS.makedev(6, 0), TTY.default_tty1_ops); FS.mkdev('/dev/tty', FS.makedev(5, 0)); FS.mkdev('/dev/tty1', FS.makedev(6, 0)); // setup /dev/[u]random // use a buffer to avoid overhead of individual crypto calls per byte var randomBuffer = new Uint8Array(1024), randomLeft = 0; var randomByte = () => { if (randomLeft === 0) { randomFill(randomBuffer); randomLeft = randomBuffer.byteLength; } return randomBuffer[--randomLeft]; }; FS.createDevice('/dev', 'random', randomByte); FS.createDevice('/dev', 'urandom', randomByte); // we're not going to emulate the actual shm device, // just create the tmp dirs that reside in it commonly FS.mkdir('/dev/shm'); FS.mkdir('/dev/shm/tmp'); }, createSpecialDirectories() { // create /proc/self/fd which allows /proc/self/fd/6 => readlink gives the // name of the stream for fd 6 (see test_unistd_ttyname) FS.mkdir('/proc'); var proc_self = FS.mkdir('/proc/self'); FS.mkdir('/proc/self/fd'); FS.mount({ mount() { var node = FS.createNode(proc_self, 'fd', 16895, 73); node.stream_ops = { llseek: MEMFS.stream_ops.llseek, }; node.node_ops = { lookup(parent, name) { var fd = +name; var stream = FS.getStreamChecked(fd); var ret = { parent: null, mount: { mountpoint: 'fake' }, node_ops: { readlink: () => stream.path }, id: fd + 1, }; ret.parent = ret; // make it look like a simple root node return ret; }, readdir() { return Array.from(FS.streams.entries()) .filter(([k, v]) => v) .map(([k, v]) => k.toString()); } }; return node; } }, {}, '/proc/self/fd'); }, createStandardStreams(input, output, error) { // TODO deprecate the old functionality of a single // input / output callback and that utilizes FS.createDevice // and instead require a unique set of stream ops // by default, we symlink the standard streams to the // default tty devices. however, if the standard streams // have been overwritten we create a unique device for // them instead. if (input) { FS.createDevice('/dev', 'stdin', input); } else { FS.symlink('/dev/tty', '/dev/stdin'); } if (output) { FS.createDevice('/dev', 'stdout', null, output); } else { FS.symlink('/dev/tty', '/dev/stdout'); } if (error) { FS.createDevice('/dev', 'stderr', null, error); } else { FS.symlink('/dev/tty1', '/dev/stderr'); } // open default streams for the stdin, stdout and stderr devices var stdin = FS.open('/dev/stdin', 0); var stdout = FS.open('/dev/stdout', 1); var stderr = FS.open('/dev/stderr', 1); assert(stdin.fd === 0, `invalid handle for stdin (${stdin.fd})`); assert(stdout.fd === 1, `invalid handle for stdout (${stdout.fd})`); assert(stderr.fd === 2, `invalid handle for stderr (${stderr.fd})`); }, staticInit() { FS.nameTable = new Array(4096); FS.mount(MEMFS, {}, '/'); FS.createDefaultDirectories(); FS.createDefaultDevices(); FS.createSpecialDirectories(); FS.filesystems = { 'MEMFS': MEMFS, }; }, init(input, output, error) { assert(!FS.initialized, 'FS.init was previously called. If you want to initialize later with custom parameters, remove any earlier calls (note that one is automatically added to the generated code)'); FS.initialized = true; // Allow Module.stdin etc. to provide defaults, if none explicitly passed to us here input ??= Module['stdin']; output ??= Module['stdout']; error ??= Module['stderr']; FS.createStandardStreams(input, output, error); }, quit() { FS.initialized = false; // force-flush all streams, so we get musl std streams printed out _fflush(0); // close all of our streams for (var stream of FS.streams) { if (stream) { FS.close(stream); } } }, findObject(path, dontResolveLastLink) { var ret = FS.analyzePath(path, dontResolveLastLink); if (!ret.exists) { return null; } return ret.object; }, analyzePath(path, dontResolveLastLink) { // operate from within the context of the symlink's target try { var lookup = FS.lookupPath(path, { follow: !dontResolveLastLink }); path = lookup.path; } catch (e) { } var ret = { isRoot: false, exists: false, error: 0, name: null, path: null, object: null, parentExists: false, parentPath: null, parentObject: null }; try { var lookup = FS.lookupPath(path, { parent: true }); ret.parentExists = true; ret.parentPath = lookup.path; ret.parentObject = lookup.node; ret.name = PATH.basename(path); lookup = FS.lookupPath(path, { follow: !dontResolveLastLink }); ret.exists = true; ret.path = lookup.path; ret.object = lookup.node; ret.name = lookup.node.name; ret.isRoot = lookup.path === '/'; } catch (e) { ret.error = e.errno; }; return ret; }, createPath(parent, path, canRead, canWrite) { parent = typeof parent == 'string' ? parent : FS.getPath(parent); var parts = path.split('/').reverse(); while (parts.length) { var part = parts.pop(); if (!part) continue; var current = PATH.join2(parent, part); try { FS.mkdir(current); } catch (e) { if (e.errno != 20) throw e; } parent = current; } return current; }, createFile(parent, name, properties, canRead, canWrite) { var path = PATH.join2(typeof parent == 'string' ? parent : FS.getPath(parent), name); var mode = FS_getMode(canRead, canWrite); return FS.create(path, mode); }, createDataFile(parent, name, data, canRead, canWrite, canOwn) { var path = name; if (parent) { parent = typeof parent == 'string' ? parent : FS.getPath(parent); path = name ? PATH.join2(parent, name) : parent; } var mode = FS_getMode(canRead, canWrite); var node = FS.create(path, mode); if (data) { if (typeof data == 'string') { var arr = new Array(data.length); for (var i = 0, len = data.length; i < len; ++i) arr[i] = data.charCodeAt(i); data = arr; } // make sure we can write to the file FS.chmod(node, mode | 146); var stream = FS.open(node, 577); FS.write(stream, data, 0, data.length, 0, canOwn); FS.close(stream); FS.chmod(node, mode); } }, createDevice(parent, name, input, output) { var path = PATH.join2(typeof parent == 'string' ? parent : FS.getPath(parent), name); var mode = FS_getMode(!!input, !!output); FS.createDevice.major ??= 64; var dev = FS.makedev(FS.createDevice.major++, 0); // Create a fake device that a set of stream ops to emulate // the old behavior. FS.registerDevice(dev, { open(stream) { stream.seekable = false; }, close(stream) { // flush any pending line data if (output?.buffer?.length) { output(10); } }, read(stream, buffer, offset, length, pos /* ignored */) { var bytesRead = 0; for (var i = 0; i < length; i++) { var result; try { result = input(); } catch (e) { throw new FS.ErrnoError(29); } if (result === undefined && bytesRead === 0) { throw new FS.ErrnoError(6); } if (result === null || result === undefined) break; bytesRead++; buffer[offset+i] = result; } if (bytesRead) { stream.node.atime = Date.now(); } return bytesRead; }, write(stream, buffer, offset, length, pos) { for (var i = 0; i < length; i++) { try { output(buffer[offset+i]); } catch (e) { throw new FS.ErrnoError(29); } } if (length) { stream.node.mtime = stream.node.ctime = Date.now(); } return i; } }); return FS.mkdev(path, mode, dev); }, forceLoadFile(obj) { if (obj.isDevice || obj.isFolder || obj.link || obj.contents) return true; if (globalThis.XMLHttpRequest) { abort("Lazy loading should have been performed (contents set) in createLazyFile, but it was not. Lazy loading only works in web workers. Use --embed-file or --preload-file in emcc on the main thread."); } else { // Command-line. try { obj.contents = readBinary(obj.url); } catch (e) { throw new FS.ErrnoError(29); } } }, createLazyFile(parent, name, url, canRead, canWrite) { // Lazy chunked Uint8Array (implements get and length from Uint8Array). // Actual getting is abstracted away for eventual reuse. class LazyUint8Array { lengthKnown = false; chunks = []; // Loaded chunks. Index is the chunk number get(idx) { if (idx > this.length-1 || idx < 0) { return undefined; } var chunkOffset = idx % this.chunkSize; var chunkNum = (idx / this.chunkSize)|0; return this.getter(chunkNum)[chunkOffset]; } setDataGetter(getter) { this.getter = getter; } cacheLength() { // Find length var xhr = new XMLHttpRequest(); xhr.open('HEAD', url, false); xhr.send(null); if (!(xhr.status >= 200 && xhr.status < 300 || xhr.status === 304)) abort("Couldn't load " + url + ". Status: " + xhr.status); var datalength = Number(xhr.getResponseHeader("Content-length")); var header; var hasByteServing = (header = xhr.getResponseHeader("Accept-Ranges")) && header === "bytes"; var usesGzip = (header = xhr.getResponseHeader("Content-Encoding")) && header === "gzip"; var chunkSize = 1024*1024; // Chunk size in bytes if (!hasByteServing) chunkSize = datalength; // Function to get a range from the remote URL. var doXHR = (from, to) => { if (from > to) abort("invalid range (" + from + ", " + to + ") or no bytes requested!"); if (to > datalength-1) abort("only " + datalength + " bytes available! programmer error!"); // TODO: Use mozResponseArrayBuffer, responseStream, etc. if available. var xhr = new XMLHttpRequest(); xhr.open('GET', url, false); if (datalength !== chunkSize) xhr.setRequestHeader("Range", "bytes=" + from + "-" + to); // Some hints to the browser that we want binary data. xhr.responseType = 'arraybuffer'; if (xhr.overrideMimeType) { xhr.overrideMimeType('text/plain; charset=x-user-defined'); } xhr.send(null); if (!(xhr.status >= 200 && xhr.status < 300 || xhr.status === 304)) abort("Couldn't load " + url + ". Status: " + xhr.status); if (xhr.response !== undefined) { return new Uint8Array(/** @type{Array} */(xhr.response || [])); } return intArrayFromString(xhr.responseText || '', true); }; var lazyArray = this; lazyArray.setDataGetter((chunkNum) => { var start = chunkNum * chunkSize; var end = (chunkNum+1) * chunkSize - 1; // including this byte end = Math.min(end, datalength-1); // if datalength-1 is selected, this is the last block if (typeof lazyArray.chunks[chunkNum] == 'undefined') { lazyArray.chunks[chunkNum] = doXHR(start, end); } if (typeof lazyArray.chunks[chunkNum] == 'undefined') abort('doXHR failed!'); return lazyArray.chunks[chunkNum]; }); if (usesGzip || !datalength) { // if the server uses gzip or doesn't supply the length, we have to download the whole file to get the (uncompressed) length chunkSize = datalength = 1; // this will force getter(0)/doXHR do download the whole file datalength = this.getter(0).length; chunkSize = datalength; out("LazyFiles on gzip forces download of the whole file when length is accessed"); } this._length = datalength; this._chunkSize = chunkSize; this.lengthKnown = true; } get length() { if (!this.lengthKnown) { this.cacheLength(); } return this._length; } get chunkSize() { if (!this.lengthKnown) { this.cacheLength(); } return this._chunkSize; } } if (globalThis.XMLHttpRequest) { if (!ENVIRONMENT_IS_WORKER) abort('Cannot do synchronous binary XHRs outside webworkers in modern browsers. Use --embed-file or --preload-file in emcc'); var lazyArray = new LazyUint8Array(); var properties = { isDevice: false, contents: lazyArray }; } else { var properties = { isDevice: false, url: url }; } var node = FS.createFile(parent, name, properties, canRead, canWrite); // This is a total hack, but I want to get this lazy file code out of the // core of MEMFS. If we want to keep this lazy file concept I feel it should // be its own thin LAZYFS proxying calls to MEMFS. if (properties.contents) { node.contents = properties.contents; } else if (properties.url) { node.contents = null; node.url = properties.url; } // Add a function that defers querying the file size until it is asked the first time. Object.defineProperties(node, { usedBytes: { get: function() { return this.contents.length; } } }); // override each stream op with one that tries to force load the lazy file first var stream_ops = {}; for (const [key, fn] of Object.entries(node.stream_ops)) { stream_ops[key] = (...args) => { FS.forceLoadFile(node); return fn(...args); }; } function writeChunks(stream, buffer, offset, length, position) { var contents = stream.node.contents; if (position >= contents.length) return 0; var size = Math.min(contents.length - position, length); assert(size >= 0); if (contents.slice) { // normal array for (var i = 0; i < size; i++) { buffer[offset + i] = contents[position + i]; } } else { for (var i = 0; i < size; i++) { // LazyUint8Array from sync binary XHR buffer[offset + i] = contents.get(position + i); } } return size; } // use a custom read function stream_ops.read = (stream, buffer, offset, length, position) => { FS.forceLoadFile(node); return writeChunks(stream, buffer, offset, length, position) }; // use a custom mmap function stream_ops.mmap = (stream, length, position, prot, flags) => { FS.forceLoadFile(node); var ptr = mmapAlloc(length); if (!ptr) { throw new FS.ErrnoError(48); } writeChunks(stream, HEAP8, ptr, length, position); return { ptr, allocated: true }; }; node.stream_ops = stream_ops; return node; }, absolutePath() { abort('FS.absolutePath has been removed; use PATH_FS.resolve instead'); }, createFolder() { abort('FS.createFolder has been removed; use FS.mkdir instead'); }, createLink() { abort('FS.createLink has been removed; use FS.symlink instead'); }, joinPath() { abort('FS.joinPath has been removed; use PATH.join instead'); }, mmapAlloc() { abort('FS.mmapAlloc has been replaced by the top level function mmapAlloc'); }, standardizePath() { abort('FS.standardizePath has been removed; use PATH.normalize instead'); }, }; var SYSCALLS = { DEFAULT_POLLMASK:5, calculateAt(dirfd, path, allowEmpty) { if (PATH.isAbs(path)) { return path; } // relative path var dir; if (dirfd === -100) { dir = FS.cwd(); } else { var dirstream = SYSCALLS.getStreamFromFD(dirfd); dir = dirstream.path; } if (path.length == 0) { if (!allowEmpty) { throw new FS.ErrnoError(44);; } return dir; } return dir + '/' + path; }, writeStat(buf, stat) { HEAPU32[((buf)>>2)] = stat.dev; HEAPU32[(((buf)+(4))>>2)] = stat.mode; HEAPU32[(((buf)+(8))>>2)] = stat.nlink; HEAPU32[(((buf)+(12))>>2)] = stat.uid; HEAPU32[(((buf)+(16))>>2)] = stat.gid; HEAPU32[(((buf)+(20))>>2)] = stat.rdev; HEAP64[(((buf)+(24))>>3)] = BigInt(stat.size); HEAP32[(((buf)+(32))>>2)] = 4096; HEAP32[(((buf)+(36))>>2)] = stat.blocks; var atime = stat.atime.getTime(); var mtime = stat.mtime.getTime(); var ctime = stat.ctime.getTime(); HEAP64[(((buf)+(40))>>3)] = BigInt(Math.floor(atime / 1000)); HEAPU32[(((buf)+(48))>>2)] = (atime % 1000) * 1000 * 1000; HEAP64[(((buf)+(56))>>3)] = BigInt(Math.floor(mtime / 1000)); HEAPU32[(((buf)+(64))>>2)] = (mtime % 1000) * 1000 * 1000; HEAP64[(((buf)+(72))>>3)] = BigInt(Math.floor(ctime / 1000)); HEAPU32[(((buf)+(80))>>2)] = (ctime % 1000) * 1000 * 1000; HEAP64[(((buf)+(88))>>3)] = BigInt(stat.ino); return 0; }, writeStatFs(buf, stats) { HEAPU32[(((buf)+(4))>>2)] = stats.bsize; HEAPU32[(((buf)+(60))>>2)] = stats.bsize; HEAP64[(((buf)+(8))>>3)] = BigInt(stats.blocks); HEAP64[(((buf)+(16))>>3)] = BigInt(stats.bfree); HEAP64[(((buf)+(24))>>3)] = BigInt(stats.bavail); HEAP64[(((buf)+(32))>>3)] = BigInt(stats.files); HEAP64[(((buf)+(40))>>3)] = BigInt(stats.ffree); HEAPU32[(((buf)+(48))>>2)] = stats.fsid; HEAPU32[(((buf)+(64))>>2)] = stats.flags; // ST_NOSUID HEAPU32[(((buf)+(56))>>2)] = stats.namelen; }, doMsync(addr, stream, len, flags, offset) { if (!FS.isFile(stream.node.mode)) { throw new FS.ErrnoError(43); } if (flags & 2) { // MAP_PRIVATE calls need not to be synced back to underlying fs return 0; } var buffer = HEAPU8.slice(addr, addr + len); FS.msync(stream, buffer, offset, len, flags); }, getStreamFromFD(fd) { var stream = FS.getStreamChecked(fd); return stream; }, varargs:undefined, getStr(ptr) { var ret = UTF8ToString(ptr); return ret; }, }; function ___syscall_chdir(path) { try { path = SYSCALLS.getStr(path); FS.chdir(path); return 0; } catch (e) { if (typeof FS == 'undefined' || !(e.name === 'ErrnoError')) throw e; return -e.errno; } } function ___syscall_fstat64(fd, buf) { try { return SYSCALLS.writeStat(buf, FS.fstat(fd)); } catch (e) { if (typeof FS == 'undefined' || !(e.name === 'ErrnoError')) throw e; return -e.errno; } } var stringToUTF8 = (str, outPtr, maxBytesToWrite) => { assert(typeof maxBytesToWrite == 'number', 'stringToUTF8(str, outPtr, maxBytesToWrite) is missing the third parameter that specifies the length of the output buffer!'); return stringToUTF8Array(str, HEAPU8, outPtr, maxBytesToWrite); }; function ___syscall_getcwd(buf, size) { try { if (size === 0) return -28; var cwd = FS.cwd(); var cwdLengthInBytes = lengthBytesUTF8(cwd) + 1; if (size < cwdLengthInBytes) return -68; stringToUTF8(cwd, buf, size); return cwdLengthInBytes; } catch (e) { if (typeof FS == 'undefined' || !(e.name === 'ErrnoError')) throw e; return -e.errno; } } function ___syscall_getdents64(fd, dirp, count) { try { var stream = SYSCALLS.getStreamFromFD(fd) stream.getdents ||= FS.readdir(stream.path); var struct_size = 280; var pos = 0; var off = FS.llseek(stream, 0, 1); var startIdx = Math.floor(off / struct_size); var endIdx = Math.min(stream.getdents.length, startIdx + Math.floor(count/struct_size)) for (var idx = startIdx; idx < endIdx; idx++) { var id; var type; var name = stream.getdents[idx]; if (name === '.') { id = stream.node.id; type = 4; // DT_DIR } else if (name === '..') { var lookup = FS.lookupPath(stream.path, { parent: true }); id = lookup.node.id; type = 4; // DT_DIR } else { var child; try { child = FS.lookupNode(stream.node, name); } catch (e) { // If the entry is not a directory, file, or symlink, nodefs // lookupNode will raise EINVAL. Skip these and continue. if (e?.errno === 28) { continue; } throw e; } id = child.id; type = FS.isChrdev(child.mode) ? 2 : // DT_CHR, character device. FS.isDir(child.mode) ? 4 : // DT_DIR, directory. FS.isLink(child.mode) ? 10 : // DT_LNK, symbolic link. 8; // DT_REG, regular file. } assert(id); HEAP64[((dirp + pos)>>3)] = BigInt(id); HEAP64[(((dirp + pos)+(8))>>3)] = BigInt((idx + 1) * struct_size); HEAP16[(((dirp + pos)+(16))>>1)] = 280; HEAP8[(dirp + pos)+(18)] = type; stringToUTF8(name, dirp + pos + 19, 256); pos += struct_size; } FS.llseek(stream, idx * struct_size, 0); return pos; } catch (e) { if (typeof FS == 'undefined' || !(e.name === 'ErrnoError')) throw e; return -e.errno; } } function ___syscall_lstat64(path, buf) { try { path = SYSCALLS.getStr(path); return SYSCALLS.writeStat(buf, FS.lstat(path)); } catch (e) { if (typeof FS == 'undefined' || !(e.name === 'ErrnoError')) throw e; return -e.errno; } } function ___syscall_mkdirat(dirfd, path, mode) { try { path = SYSCALLS.getStr(path); path = SYSCALLS.calculateAt(dirfd, path); FS.mkdir(path, mode, 0); return 0; } catch (e) { if (typeof FS == 'undefined' || !(e.name === 'ErrnoError')) throw e; return -e.errno; } } function ___syscall_newfstatat(dirfd, path, buf, flags) { try { path = SYSCALLS.getStr(path); var nofollow = flags & 256; var allowEmpty = flags & 4096; flags = flags & (~6400); assert(!flags, `unknown flags in __syscall_newfstatat: ${flags}`); path = SYSCALLS.calculateAt(dirfd, path, allowEmpty); return SYSCALLS.writeStat(buf, nofollow ? FS.lstat(path) : FS.stat(path)); } catch (e) { if (typeof FS == 'undefined' || !(e.name === 'ErrnoError')) throw e; return -e.errno; } } var syscallGetVarargI = () => { assert(SYSCALLS.varargs != undefined); // the `+` prepended here is necessary to convince the JSCompiler that varargs is indeed a number. var ret = HEAP32[((+SYSCALLS.varargs)>>2)]; SYSCALLS.varargs += 4; return ret; }; function ___syscall_openat(dirfd, path, flags, varargs) { SYSCALLS.varargs = varargs; try { path = SYSCALLS.getStr(path); path = SYSCALLS.calculateAt(dirfd, path); var mode = varargs ? syscallGetVarargI() : 0; return FS.open(path, flags, mode).fd; } catch (e) { if (typeof FS == 'undefined' || !(e.name === 'ErrnoError')) throw e; return -e.errno; } } function ___syscall_poll(fds, nfds, timeout) { try { if (timeout != 0) warnOnce('non-zero poll() timeout not supported: ' + timeout) var nonzero = 0; for (var i = 0; i < nfds; i++) { var pollfd = fds + 8 * i; var fd = HEAP32[((pollfd)>>2)]; var events = HEAP16[(((pollfd)+(4))>>1)]; var mask = 32; var stream = FS.getStream(fd); if (stream) { mask = SYSCALLS.DEFAULT_POLLMASK; if (stream.stream_ops.poll) { mask = stream.stream_ops.poll(stream, -1); } } mask &= events | 8 | 16; if (mask) nonzero++; HEAP16[(((pollfd)+(6))>>1)] = mask; } return nonzero; } catch (e) { if (typeof FS == 'undefined' || !(e.name === 'ErrnoError')) throw e; return -e.errno; } } function ___syscall_renameat(olddirfd, oldpath, newdirfd, newpath) { try { oldpath = SYSCALLS.getStr(oldpath); newpath = SYSCALLS.getStr(newpath); oldpath = SYSCALLS.calculateAt(olddirfd, oldpath); newpath = SYSCALLS.calculateAt(newdirfd, newpath); FS.rename(oldpath, newpath); return 0; } catch (e) { if (typeof FS == 'undefined' || !(e.name === 'ErrnoError')) throw e; return -e.errno; } } function ___syscall_rmdir(path) { try { path = SYSCALLS.getStr(path); FS.rmdir(path); return 0; } catch (e) { if (typeof FS == 'undefined' || !(e.name === 'ErrnoError')) throw e; return -e.errno; } } function ___syscall_stat64(path, buf) { try { path = SYSCALLS.getStr(path); return SYSCALLS.writeStat(buf, FS.stat(path)); } catch (e) { if (typeof FS == 'undefined' || !(e.name === 'ErrnoError')) throw e; return -e.errno; } } function ___syscall_statfs64(path, size, buf) { try { assert(size === 88); SYSCALLS.writeStatFs(buf, FS.statfs(SYSCALLS.getStr(path))); return 0; } catch (e) { if (typeof FS == 'undefined' || !(e.name === 'ErrnoError')) throw e; return -e.errno; } } function ___syscall_unlinkat(dirfd, path, flags) { try { path = SYSCALLS.getStr(path); path = SYSCALLS.calculateAt(dirfd, path); if (!flags) { FS.unlink(path); } else if (flags === 512) { FS.rmdir(path); } else { return -28; } return 0; } catch (e) { if (typeof FS == 'undefined' || !(e.name === 'ErrnoError')) throw e; return -e.errno; } } var __abort_js = () => abort('native code called abort()'); var __emscripten_throw_longjmp = () => { throw Infinity; }; var abortOnCannotGrowMemory = (requestedSize) => { abort(`Cannot enlarge memory arrays to size ${requestedSize} bytes (OOM). Either (1) compile with -sINITIAL_MEMORY=X with X higher than the current value ${HEAP8.length}, (2) compile with -sALLOW_MEMORY_GROWTH which allows increasing the size at runtime, or (3) if you want malloc to return NULL (0) instead of this abort, compile with -sABORTING_MALLOC=0`); }; var _emscripten_resize_heap = (requestedSize) => { var oldSize = HEAPU8.length; // With CAN_ADDRESS_2GB or MEMORY64, pointers are already unsigned. requestedSize >>>= 0; abortOnCannotGrowMemory(requestedSize); }; var handleException = (e) => { // Certain exception types we do not treat as errors since they are used for // internal control flow. // 1. ExitStatus, which is thrown by exit() // 2. "unwind", which is thrown by emscripten_unwind_to_js_event_loop() and others // that wish to return to JS event loop. if (e instanceof ExitStatus || e == 'unwind') { return EXITSTATUS; } checkStackCookie(); if (e instanceof WebAssembly.RuntimeError) { if (_emscripten_stack_get_current() <= 0) { err('Stack overflow detected. You can try increasing -sSTACK_SIZE (currently set to 65536)'); } } quit_(1, e); }; var runtimeKeepaliveCounter = 0; var keepRuntimeAlive = () => noExitRuntime || runtimeKeepaliveCounter > 0; var _proc_exit = (code) => { EXITSTATUS = code; if (!keepRuntimeAlive()) { Module['onExit']?.(code); ABORT = true; } quit_(code, new ExitStatus(code)); }; /** @param {boolean|number=} implicit */ var exitJS = (status, implicit) => { EXITSTATUS = status; checkUnflushedContent(); // if exit() was called explicitly, warn the user if the runtime isn't actually being shut down if (keepRuntimeAlive() && !implicit) { var msg = `program exited (with status: ${status}), but keepRuntimeAlive() is set (counter=${runtimeKeepaliveCounter}) due to an async operation, so halting execution but not exiting the runtime or preventing further async execution (you can use emscripten_force_exit, if you want to force a true shutdown)`; readyPromiseReject?.(msg); err(msg); } _proc_exit(status); }; var _exit = exitJS; var maybeExit = () => { if (!keepRuntimeAlive()) { try { _exit(EXITSTATUS); } catch (e) { handleException(e); } } }; var callUserCallback = (func) => { if (ABORT) { err('user callback triggered after runtime exited or application aborted. Ignoring.'); return; } try { func(); maybeExit(); } catch (e) { handleException(e); } }; /** @param {number=} timeout */ var safeSetTimeout = (func, timeout) => { return setTimeout(() => { callUserCallback(func); }, timeout); }; var _emscripten_scan_registers = (func) => { return Asyncify.handleSleep((wakeUp) => { // We must first unwind, so things are spilled to the stack. Then while // we are pausing we do the actual scan. After that we can resume. Note // how using a timeout here avoids unbounded call stack growth, which // could happen if we tried to scan the stack immediately after unwinding. safeSetTimeout(() => { var stackBegin = Asyncify.currData + 12; var stackEnd = HEAPU32[((Asyncify.currData)>>2)]; ((a1, a2) => dynCall_vii(func, a1, a2))(stackBegin, stackEnd); wakeUp(); }, 0); }); }; _emscripten_scan_registers.isAsync = true; function _fd_close(fd) { try { var stream = SYSCALLS.getStreamFromFD(fd); FS.close(stream); return 0; } catch (e) { if (typeof FS == 'undefined' || !(e.name === 'ErrnoError')) throw e; return e.errno; } } /** @param {number=} offset */ var doReadv = (stream, iov, iovcnt, offset) => { var ret = 0; for (var i = 0; i < iovcnt; i++) { var ptr = HEAPU32[((iov)>>2)]; var len = HEAPU32[(((iov)+(4))>>2)]; iov += 8; var curr = FS.read(stream, HEAP8, ptr, len, offset); if (curr < 0) return -1; ret += curr; if (curr < len) break; // nothing more to read if (typeof offset != 'undefined') { offset += curr; } } return ret; }; function _fd_read(fd, iov, iovcnt, pnum) { try { var stream = SYSCALLS.getStreamFromFD(fd); var num = doReadv(stream, iov, iovcnt); HEAPU32[((pnum)>>2)] = num; return 0; } catch (e) { if (typeof FS == 'undefined' || !(e.name === 'ErrnoError')) throw e; return e.errno; } } var INT53_MAX = 9007199254740992; var INT53_MIN = -9007199254740992; var bigintToI53Checked = (num) => (num < INT53_MIN || num > INT53_MAX) ? NaN : Number(num); function _fd_seek(fd, offset, whence, newOffset) { offset = bigintToI53Checked(offset); try { if (isNaN(offset)) return 61; var stream = SYSCALLS.getStreamFromFD(fd); FS.llseek(stream, offset, whence); HEAP64[((newOffset)>>3)] = BigInt(stream.position); if (stream.getdents && offset === 0 && whence === 0) stream.getdents = null; // reset readdir state return 0; } catch (e) { if (typeof FS == 'undefined' || !(e.name === 'ErrnoError')) throw e; return e.errno; } ; } var _fd_sync = function (fd) { try { var stream = SYSCALLS.getStreamFromFD(fd); return Asyncify.handleSleep((wakeUp) => { var mount = stream.node.mount; if (!mount.type.syncfs) { // We write directly to the file system, so there's nothing to do here. wakeUp(0); return; } mount.type.syncfs(mount, false, (err) => { wakeUp(err ? 29 : 0); }); }); } catch (e) { if (typeof FS == 'undefined' || !(e.name === 'ErrnoError')) throw e; return e.errno; } }; _fd_sync.isAsync = true; /** @param {number=} offset */ var doWritev = (stream, iov, iovcnt, offset) => { var ret = 0; for (var i = 0; i < iovcnt; i++) { var ptr = HEAPU32[((iov)>>2)]; var len = HEAPU32[(((iov)+(4))>>2)]; iov += 8; var curr = FS.write(stream, HEAP8, ptr, len, offset); if (curr < 0) return -1; ret += curr; if (curr < len) { // No more space to write. break; } if (typeof offset != 'undefined') { offset += curr; } } return ret; }; function _fd_write(fd, iov, iovcnt, pnum) { try { var stream = SYSCALLS.getStreamFromFD(fd); var num = doWritev(stream, iov, iovcnt); HEAPU32[((pnum)>>2)] = num; return 0; } catch (e) { if (typeof FS == 'undefined' || !(e.name === 'ErrnoError')) throw e; return e.errno; } } var _mp_js_hook = () => { if (ENVIRONMENT_IS_NODE) { const mp_interrupt_char = Module.ccall( "mp_hal_get_interrupt_char", "number", ["number"], ["null"], ); const fs = require("fs"); const buf = Buffer.alloc(1); try { const n = fs.readSync(process.stdin.fd, buf, 0, 1); if (n > 0) { if (buf[0] === mp_interrupt_char) { Module.ccall( "mp_sched_keyboard_interrupt", "null", ["null"], ["null"], ); } else { process.stdout.write(String.fromCharCode(buf[0])); } } } catch (e) { if (e.code === "EAGAIN") { } else { throw e; } } } }; var _mp_js_random_u32 = () => globalThis.crypto.getRandomValues(new Uint32Array(1))[0]; var _mp_js_ticks_ms = () => Date.now() - MP_JS_EPOCH; var _mp_js_time_ms = () => Date.now(); var wasmTableMirror = []; var getWasmTableEntry = (funcPtr) => { var func = wasmTableMirror[funcPtr]; if (!func) { /** @suppress {checkTypes} */ wasmTableMirror[funcPtr] = func = wasmTable.get(funcPtr); } /** @suppress {checkTypes} */ assert(wasmTable.get(funcPtr) == func, 'JavaScript-side Wasm function table mirror is out of date!'); return func; }; var runAndAbortIfError = (func) => { try { return func(); } catch (e) { abort(e); } }; var createNamedFunction = (name, func) => Object.defineProperty(func, 'name', { value: name }); var runtimeKeepalivePush = () => { runtimeKeepaliveCounter += 1; }; var runtimeKeepalivePop = () => { assert(runtimeKeepaliveCounter > 0); runtimeKeepaliveCounter -= 1; }; var Asyncify = { instrumentWasmImports(imports) { var importPattern = /^(invoke_.*|__asyncjs__.*)$/; for (let [x, original] of Object.entries(imports)) { if (typeof original == 'function') { let isAsyncifyImport = original.isAsync || importPattern.test(x); imports[x] = (...args) => { var originalAsyncifyState = Asyncify.state; try { return original(...args); } finally { // Only asyncify-declared imports are allowed to change the // state. // Changing the state from normal to disabled is allowed (in any // function) as that is what shutdown does (and we don't have an // explicit list of shutdown imports). var changedToDisabled = originalAsyncifyState === Asyncify.State.Normal && Asyncify.state === Asyncify.State.Disabled; // invoke_* functions are allowed to change the state if we do // not ignore indirect calls. var ignoredInvoke = x.startsWith('invoke_') && true; if (Asyncify.state !== originalAsyncifyState && !isAsyncifyImport && !changedToDisabled && !ignoredInvoke) { abort(`import ${x} was not in ASYNCIFY_IMPORTS, but changed the state`); } } }; } } }, instrumentFunction(original) { var wrapper = (...args) => { Asyncify.exportCallStack.push(original); try { return original(...args); } finally { if (!ABORT) { var top = Asyncify.exportCallStack.pop(); assert(top === original); Asyncify.maybeStopUnwind(); } } }; Asyncify.funcWrappers.set(original, wrapper); wrapper = createNamedFunction(`__asyncify_wrapper_${original.name}`, wrapper); return wrapper; }, instrumentWasmExports(exports) { var ret = {}; for (let [x, original] of Object.entries(exports)) { if (typeof original == 'function') { var wrapper = Asyncify.instrumentFunction(original); ret[x] = wrapper; } else { ret[x] = original; } } return ret; }, State:{ Normal:0, Unwinding:1, Rewinding:2, Disabled:3, }, state:0, StackSize:128000, currData:null, handleSleepReturnValue:0, exportCallStack:[], callstackFuncToId:new Map, callStackIdToFunc:new Map, funcWrappers:new Map, callStackId:0, asyncPromiseHandlers:null, sleepCallbacks:[], getCallStackId(func) { assert(func); if (!Asyncify.callstackFuncToId.has(func)) { var id = Asyncify.callStackId++; Asyncify.callstackFuncToId.set(func, id); Asyncify.callStackIdToFunc.set(id, func); } return Asyncify.callstackFuncToId.get(func); }, maybeStopUnwind() { if (Asyncify.currData && Asyncify.state === Asyncify.State.Unwinding && Asyncify.exportCallStack.length === 0) { // We just finished unwinding. // Be sure to set the state before calling any other functions to avoid // possible infinite recursion here (For example in debug pthread builds // the dbg() function itself can call back into WebAssembly to get the // current pthread_self() pointer). Asyncify.state = Asyncify.State.Normal; // Keep the runtime alive so that a re-wind can be done later. runAndAbortIfError(_asyncify_stop_unwind); if (typeof Fibers != 'undefined') { Fibers.trampoline(); } } }, whenDone() { assert(Asyncify.currData, 'Tried to wait for an async operation when none is in progress.'); assert(!Asyncify.asyncPromiseHandlers, 'Cannot have multiple async operations in flight at once'); return new Promise((resolve, reject) => { Asyncify.asyncPromiseHandlers = { resolve, reject }; }); }, allocateData() { // An asyncify data structure has three fields: // 0 current stack pos // 4 max stack pos // 8 id of function at bottom of the call stack (callStackIdToFunc[id] == wasm func) // // The Asyncify ABI only interprets the first two fields, the rest is for the runtime. // We also embed a stack in the same memory region here, right next to the structure. // This struct is also defined as asyncify_data_t in emscripten/fiber.h var ptr = _malloc(12 + Asyncify.StackSize); Asyncify.setDataHeader(ptr, ptr + 12, Asyncify.StackSize); Asyncify.setDataRewindFunc(ptr); return ptr; }, setDataHeader(ptr, stack, stackSize) { HEAPU32[((ptr)>>2)] = stack; HEAPU32[(((ptr)+(4))>>2)] = stack + stackSize; }, setDataRewindFunc(ptr) { var bottomOfCallStack = Asyncify.exportCallStack[0]; assert(bottomOfCallStack, 'exportCallStack is empty'); var rewindId = Asyncify.getCallStackId(bottomOfCallStack); HEAP32[(((ptr)+(8))>>2)] = rewindId; }, getDataRewindFunc(ptr) { var id = HEAP32[(((ptr)+(8))>>2)]; var func = Asyncify.callStackIdToFunc.get(id); assert(func, `id ${id} not found in callStackIdToFunc`); return func; }, doRewind(ptr) { var original = Asyncify.getDataRewindFunc(ptr); var func = Asyncify.funcWrappers.get(original); assert(original); assert(func); // Once we have rewound and the stack we no longer need to artificially // keep the runtime alive. return func(); }, handleSleep(startAsync) { assert(Asyncify.state !== Asyncify.State.Disabled, 'Asyncify cannot be done during or after the runtime exits'); if (ABORT) return; if (Asyncify.state === Asyncify.State.Normal) { // Prepare to sleep. Call startAsync, and see what happens: // if the code decided to call our callback synchronously, // then no async operation was in fact begun, and we don't // need to do anything. var reachedCallback = false; var reachedAfterCallback = false; startAsync((handleSleepReturnValue = 0) => { assert(!handleSleepReturnValue || typeof handleSleepReturnValue == 'number' || typeof handleSleepReturnValue == 'boolean'); // old emterpretify API supported other stuff if (ABORT) return; Asyncify.handleSleepReturnValue = handleSleepReturnValue; reachedCallback = true; if (!reachedAfterCallback) { // We are happening synchronously, so no need for async. return; } // This async operation did not happen synchronously, so we did // unwind. In that case there can be no compiled code on the stack, // as it might break later operations (we can rewind ok now, but if // we unwind again, we would unwind through the extra compiled code // too). assert(!Asyncify.exportCallStack.length, 'Waking up (starting to rewind) must be done from JS, without compiled code on the stack.'); Asyncify.state = Asyncify.State.Rewinding; runAndAbortIfError(() => _asyncify_start_rewind(Asyncify.currData)); if (typeof MainLoop != 'undefined' && MainLoop.func) { MainLoop.resume(); } var asyncWasmReturnValue, isError = false; try { asyncWasmReturnValue = Asyncify.doRewind(Asyncify.currData); } catch (err) { asyncWasmReturnValue = err; isError = true; } // Track whether the return value was handled by any promise handlers. var handled = false; if (!Asyncify.currData) { // All asynchronous execution has finished. // `asyncWasmReturnValue` now contains the final // return value of the exported async WASM function. // // Note: `asyncWasmReturnValue` is distinct from // `Asyncify.handleSleepReturnValue`. // `Asyncify.handleSleepReturnValue` contains the return // value of the last C function to have executed // `Asyncify.handleSleep()`, where as `asyncWasmReturnValue` // contains the return value of the exported WASM function // that may have called C functions that // call `Asyncify.handleSleep()`. var asyncPromiseHandlers = Asyncify.asyncPromiseHandlers; if (asyncPromiseHandlers) { Asyncify.asyncPromiseHandlers = null; (isError ? asyncPromiseHandlers.reject : asyncPromiseHandlers.resolve)(asyncWasmReturnValue); handled = true; } } if (isError && !handled) { // If there was an error and it was not handled by now, we have no choice but to // rethrow that error into the global scope where it can be caught only by // `onerror` or `onunhandledpromiserejection`. throw asyncWasmReturnValue; } }); reachedAfterCallback = true; if (!reachedCallback) { // A true async operation was begun; start a sleep. Asyncify.state = Asyncify.State.Unwinding; // TODO: reuse, don't alloc/free every sleep Asyncify.currData = Asyncify.allocateData(); if (typeof MainLoop != 'undefined' && MainLoop.func) { MainLoop.pause(); } runAndAbortIfError(() => _asyncify_start_unwind(Asyncify.currData)); } } else if (Asyncify.state === Asyncify.State.Rewinding) { // Stop a resume. Asyncify.state = Asyncify.State.Normal; runAndAbortIfError(_asyncify_stop_rewind); _free(Asyncify.currData); Asyncify.currData = null; // Call all sleep callbacks now that the sleep-resume is all done. Asyncify.sleepCallbacks.forEach(callUserCallback); } else { abort(`invalid state: ${Asyncify.state}`); } return Asyncify.handleSleepReturnValue; }, handleAsync:(startAsync) => Asyncify.handleSleep((wakeUp) => { // TODO: add error handling as a second param when handleSleep implements it. startAsync().then(wakeUp); }), }; var getCFunc = (ident) => { var func = Module['_' + ident]; // closure exported function assert(func, 'Cannot call unknown function ' + ident + ', make sure it is exported'); return func; }; var writeArrayToMemory = (array, buffer) => { assert(array.length >= 0, 'writeArrayToMemory array must have a length (should be an array or typed array)') HEAP8.set(array, buffer); }; var stackAlloc = (sz) => __emscripten_stack_alloc(sz); var stringToUTF8OnStack = (str) => { var size = lengthBytesUTF8(str) + 1; var ret = stackAlloc(size); stringToUTF8(str, ret, size); return ret; }; /** * @param {string|null=} returnType * @param {Array=} argTypes * @param {Array=} args * @param {Object=} opts */ var ccall = (ident, returnType, argTypes, args, opts) => { // For fast lookup of conversion functions var toC = { 'string': (str) => { var ret = 0; if (str !== null && str !== undefined && str !== 0) { // null string ret = stringToUTF8OnStack(str); } return ret; }, 'array': (arr) => { var ret = stackAlloc(arr.length); writeArrayToMemory(arr, ret); return ret; } }; function convertReturnValue(ret) { if (returnType === 'string') { return UTF8ToString(ret); } if (returnType === 'boolean') return Boolean(ret); return ret; } var func = getCFunc(ident); var cArgs = []; var stack = 0; assert(returnType !== 'array', 'Return type should not be "array".'); if (args) { for (var i = 0; i < args.length; i++) { var converter = toC[argTypes[i]]; if (converter) { if (stack === 0) stack = stackSave(); cArgs[i] = converter(args[i]); } else { cArgs[i] = args[i]; } } } // Data for a previous async operation that was in flight before us. var previousAsync = Asyncify.currData; var ret = func(...cArgs); function onDone(ret) { runtimeKeepalivePop(); if (stack !== 0) stackRestore(stack); return convertReturnValue(ret); } var asyncMode = opts?.async; // Keep the runtime alive through all calls. Note that this call might not be // async, but for simplicity we push and pop in all calls. runtimeKeepalivePush(); if (Asyncify.currData != previousAsync) { // A change in async operation happened. If there was already an async // operation in flight before us, that is an error: we should not start // another async operation while one is active, and we should not stop one // either. The only valid combination is to have no change in the async // data (so we either had one in flight and left it alone, or we didn't have // one), or to have nothing in flight and to start one. assert(!(previousAsync && Asyncify.currData), 'We cannot start an async operation when one is already flight'); assert(!(previousAsync && !Asyncify.currData), 'We cannot stop an async operation in flight'); // This is a new async operation. The wasm is paused and has unwound its stack. // We need to return a Promise that resolves the return value // once the stack is rewound and execution finishes. assert(asyncMode, 'The call to ' + ident + ' is running asynchronously. If this was intended, add the async option to the ccall/cwrap call.'); return Asyncify.whenDone().then(onDone); } ret = onDone(ret); // If this is an async ccall, ensure we return a promise if (asyncMode) return Promise.resolve(ret); return ret; }; /** * @param {string=} returnType * @param {Array=} argTypes * @param {Object=} opts */ var cwrap = (ident, returnType, argTypes, opts) => { return (...args) => ccall(ident, returnType, argTypes, args, opts); }; FS.createPreloadedFile = FS_createPreloadedFile; FS.preloadFile = FS_preloadFile; FS.staticInit();; if (globalThis.crypto === undefined) { globalThis.crypto = require('crypto'); }; var MP_JS_EPOCH = Date.now(); // End JS library code // include: postlibrary.js // This file is included after the automatically-generated JS library code // but before the wasm module is created. { // Begin ATMODULES hooks if (Module['noExitRuntime']) noExitRuntime = Module['noExitRuntime']; if (Module['preloadPlugins']) preloadPlugins = Module['preloadPlugins']; if (Module['print']) out = Module['print']; if (Module['printErr']) err = Module['printErr']; if (Module['wasmBinary']) wasmBinary = Module['wasmBinary']; // End ATMODULES hooks checkIncomingModuleAPI(); if (Module['arguments']) arguments_ = Module['arguments']; if (Module['thisProgram']) thisProgram = Module['thisProgram']; // Assertions on removed incoming Module JS APIs. assert(typeof Module['memoryInitializerPrefixURL'] == 'undefined', 'Module.memoryInitializerPrefixURL option was removed, use Module.locateFile instead'); assert(typeof Module['pthreadMainPrefixURL'] == 'undefined', 'Module.pthreadMainPrefixURL option was removed, use Module.locateFile instead'); assert(typeof Module['cdInitializerPrefixURL'] == 'undefined', 'Module.cdInitializerPrefixURL option was removed, use Module.locateFile instead'); assert(typeof Module['filePackagePrefixURL'] == 'undefined', 'Module.filePackagePrefixURL option was removed, use Module.locateFile instead'); assert(typeof Module['read'] == 'undefined', 'Module.read option was removed'); assert(typeof Module['readAsync'] == 'undefined', 'Module.readAsync option was removed (modify readAsync in JS)'); assert(typeof Module['readBinary'] == 'undefined', 'Module.readBinary option was removed (modify readBinary in JS)'); assert(typeof Module['setWindowTitle'] == 'undefined', 'Module.setWindowTitle option was removed (modify emscripten_set_window_title in JS)'); assert(typeof Module['TOTAL_MEMORY'] == 'undefined', 'Module.TOTAL_MEMORY has been renamed Module.INITIAL_MEMORY'); assert(typeof Module['ENVIRONMENT'] == 'undefined', 'Module.ENVIRONMENT has been deprecated. To force the environment, use the ENVIRONMENT compile-time option (for example, -sENVIRONMENT=web or -sENVIRONMENT=node)'); assert(typeof Module['STACK_SIZE'] == 'undefined', 'STACK_SIZE can no longer be set at runtime. Use -sSTACK_SIZE at link time') // If memory is defined in wasm, the user can't provide it, or set INITIAL_MEMORY assert(typeof Module['wasmMemory'] == 'undefined', 'Use of `wasmMemory` detected. Use -sIMPORTED_MEMORY to define wasmMemory externally'); assert(typeof Module['INITIAL_MEMORY'] == 'undefined', 'Detected runtime INITIAL_MEMORY setting. Use -sIMPORTED_MEMORY to define wasmMemory dynamically'); if (Module['preInit']) { if (typeof Module['preInit'] == 'function') Module['preInit'] = [Module['preInit']]; while (Module['preInit'].length > 0) { Module['preInit'].shift()(); } } consumedModuleProp('preInit'); } // Begin runtime exports Module['ccall'] = ccall; Module['cwrap'] = cwrap; Module['setValue'] = setValue; Module['getValue'] = getValue; Module['PATH'] = PATH; Module['PATH_FS'] = PATH_FS; Module['UTF8ToString'] = UTF8ToString; Module['stringToUTF8'] = stringToUTF8; Module['lengthBytesUTF8'] = lengthBytesUTF8; Module['FS'] = FS; var missingLibrarySymbols = [ 'writeI53ToI64', 'writeI53ToI64Clamped', 'writeI53ToI64Signaling', 'writeI53ToU64Clamped', 'writeI53ToU64Signaling', 'readI53FromI64', 'readI53FromU64', 'convertI32PairToI53', 'convertI32PairToI53Checked', 'convertU32PairToI53', 'getTempRet0', 'setTempRet0', 'zeroMemory', 'getHeapMax', 'growMemory', 'withStackSave', 'inetPton4', 'inetNtop4', 'inetPton6', 'inetNtop6', 'readSockaddr', 'writeSockaddr', 'readEmAsmArgs', 'jstoi_q', 'getExecutableName', 'autoResumeAudioContext', 'getDynCaller', 'asmjsMangle', 'alignMemory', 'HandleAllocator', 'addOnInit', 'addOnPostCtor', 'addOnPreMain', 'addOnExit', 'STACK_SIZE', 'STACK_ALIGN', 'POINTER_SIZE', 'ASSERTIONS', 'convertJsFunctionToWasm', 'getEmptyTableSlot', 'updateTableMap', 'getFunctionAddress', 'addFunction', 'removeFunction', 'intArrayToString', 'AsciiToString', 'stringToAscii', 'UTF16ToString', 'stringToUTF16', 'lengthBytesUTF16', 'UTF32ToString', 'stringToUTF32', 'lengthBytesUTF32', 'stringToNewUTF8', 'registerKeyEventCallback', 'maybeCStringToJsString', 'findEventTarget', 'getBoundingClientRect', 'fillMouseEventData', 'registerMouseEventCallback', 'registerWheelEventCallback', 'registerUiEventCallback', 'registerFocusEventCallback', 'fillDeviceOrientationEventData', 'registerDeviceOrientationEventCallback', 'fillDeviceMotionEventData', 'registerDeviceMotionEventCallback', 'screenOrientation', 'fillOrientationChangeEventData', 'registerOrientationChangeEventCallback', 'fillFullscreenChangeEventData', 'registerFullscreenChangeEventCallback', 'JSEvents_requestFullscreen', 'JSEvents_resizeCanvasForFullscreen', 'registerRestoreOldStyle', 'hideEverythingExceptGivenElement', 'restoreHiddenElements', 'setLetterbox', 'softFullscreenResizeWebGLRenderTarget', 'doRequestFullscreen', 'fillPointerlockChangeEventData', 'registerPointerlockChangeEventCallback', 'registerPointerlockErrorEventCallback', 'requestPointerLock', 'fillVisibilityChangeEventData', 'registerVisibilityChangeEventCallback', 'registerTouchEventCallback', 'fillGamepadEventData', 'registerGamepadEventCallback', 'registerBeforeUnloadEventCallback', 'fillBatteryEventData', 'registerBatteryEventCallback', 'setCanvasElementSize', 'getCanvasElementSize', 'jsStackTrace', 'getCallstack', 'convertPCtoSourceLocation', 'getEnvStrings', 'checkWasiClock', 'wasiRightsToMuslOFlags', 'wasiOFlagsToMuslOFlags', 'setImmediateWrapped', 'safeRequestAnimationFrame', 'clearImmediateWrapped', 'registerPostMainLoop', 'registerPreMainLoop', 'getPromise', 'makePromise', 'idsToPromises', 'makePromiseCallback', 'ExceptionInfo', 'findMatchingCatch', 'Browser_asyncPrepareDataCounter', 'isLeapYear', 'ydayFromDate', 'arraySum', 'addDays', 'getSocketFromFD', 'getSocketAddress', 'FS_mkdirTree', '_setNetworkCallback', 'heapObjectForWebGLType', 'toTypedArrayIndex', 'webgl_enable_ANGLE_instanced_arrays', 'webgl_enable_OES_vertex_array_object', 'webgl_enable_WEBGL_draw_buffers', 'webgl_enable_WEBGL_multi_draw', 'webgl_enable_EXT_polygon_offset_clamp', 'webgl_enable_EXT_clip_control', 'webgl_enable_WEBGL_polygon_mode', 'emscriptenWebGLGet', 'computeUnpackAlignedImageSize', 'colorChannelsInGlTextureFormat', 'emscriptenWebGLGetTexPixelData', 'emscriptenWebGLGetUniform', 'webglGetUniformLocation', 'webglPrepareUniformLocationsBeforeFirstUse', 'webglGetLeftBracePos', 'emscriptenWebGLGetVertexAttrib', '__glGetActiveAttribOrUniform', 'writeGLArray', 'registerWebGlEventCallback', 'ALLOC_NORMAL', 'ALLOC_STACK', 'allocate', 'writeStringToMemory', 'writeAsciiToMemory', 'allocateUTF8', 'allocateUTF8OnStack', 'demangle', 'stackTrace', 'getNativeTypeSize', ]; missingLibrarySymbols.forEach(missingLibrarySymbol) var unexportedSymbols = [ 'run', 'out', 'err', 'callMain', 'abort', 'wasmExports', 'HEAPF32', 'HEAPF64', 'HEAP8', 'HEAPU8', 'HEAP16', 'HEAPU16', 'HEAP32', 'HEAPU32', 'HEAP64', 'HEAPU64', 'writeStackCookie', 'checkStackCookie', 'INT53_MAX', 'INT53_MIN', 'bigintToI53Checked', 'stackSave', 'stackRestore', 'stackAlloc', 'createNamedFunction', 'ptrToString', 'exitJS', 'abortOnCannotGrowMemory', 'ENV', 'ERRNO_CODES', 'strError', 'DNS', 'Protocols', 'Sockets', 'timers', 'warnOnce', 'readEmAsmArgsArray', 'dynCallLegacy', 'dynCall', 'handleException', 'keepRuntimeAlive', 'runtimeKeepalivePush', 'runtimeKeepalivePop', 'callUserCallback', 'maybeExit', 'asyncLoad', 'mmapAlloc', 'wasmTable', 'wasmMemory', 'getUniqueRunDependency', 'noExitRuntime', 'addRunDependency', 'removeRunDependency', 'addOnPreRun', 'addOnPostRun', 'freeTableIndexes', 'functionsInTableMap', 'UTF8Decoder', 'UTF8ArrayToString', 'stringToUTF8Array', 'intArrayFromString', 'UTF16Decoder', 'stringToUTF8OnStack', 'writeArrayToMemory', 'JSEvents', 'specialHTMLTargets', 'findCanvasEventTarget', 'currentFullscreenStrategy', 'restoreOldWindowedStyle', 'UNWIND_CACHE', 'ExitStatus', 'doReadv', 'doWritev', 'initRandomFill', 'randomFill', 'safeSetTimeout', 'emSetImmediate', 'emClearImmediate_deps', 'emClearImmediate', 'promiseMap', 'uncaughtExceptionCount', 'exceptionLast', 'exceptionCaught', 'Browser', 'requestFullscreen', 'requestFullScreen', 'setCanvasSize', 'getUserMedia', 'createContext', 'getPreloadedImageData__data', 'wget', 'MONTH_DAYS_REGULAR', 'MONTH_DAYS_LEAP', 'MONTH_DAYS_REGULAR_CUMULATIVE', 'MONTH_DAYS_LEAP_CUMULATIVE', 'SYSCALLS', 'preloadPlugins', 'FS_createPreloadedFile', 'FS_preloadFile', 'FS_modeStringToFlags', 'FS_getMode', 'FS_stdin_getChar_buffer', 'FS_stdin_getChar', 'FS_unlink', 'FS_createPath', 'FS_createDevice', 'FS_readFile', 'FS_root', 'FS_mounts', 'FS_devices', 'FS_streams', 'FS_nextInode', 'FS_nameTable', 'FS_currentPath', 'FS_initialized', 'FS_ignorePermissions', 'FS_filesystems', 'FS_syncFSRequests', 'FS_readFiles', 'FS_lookupPath', 'FS_getPath', 'FS_hashName', 'FS_hashAddNode', 'FS_hashRemoveNode', 'FS_lookupNode', 'FS_createNode', 'FS_destroyNode', 'FS_isRoot', 'FS_isMountpoint', 'FS_isFile', 'FS_isDir', 'FS_isLink', 'FS_isChrdev', 'FS_isBlkdev', 'FS_isFIFO', 'FS_isSocket', 'FS_flagsToPermissionString', 'FS_nodePermissions', 'FS_mayLookup', 'FS_mayCreate', 'FS_mayDelete', 'FS_mayOpen', 'FS_checkOpExists', 'FS_nextfd', 'FS_getStreamChecked', 'FS_getStream', 'FS_createStream', 'FS_closeStream', 'FS_dupStream', 'FS_doSetAttr', 'FS_chrdev_stream_ops', 'FS_major', 'FS_minor', 'FS_makedev', 'FS_registerDevice', 'FS_getDevice', 'FS_getMounts', 'FS_syncfs', 'FS_mount', 'FS_unmount', 'FS_lookup', 'FS_mknod', 'FS_statfs', 'FS_statfsStream', 'FS_statfsNode', 'FS_create', 'FS_mkdir', 'FS_mkdev', 'FS_symlink', 'FS_rename', 'FS_rmdir', 'FS_readdir', 'FS_readlink', 'FS_stat', 'FS_fstat', 'FS_lstat', 'FS_doChmod', 'FS_chmod', 'FS_lchmod', 'FS_fchmod', 'FS_doChown', 'FS_chown', 'FS_lchown', 'FS_fchown', 'FS_doTruncate', 'FS_truncate', 'FS_ftruncate', 'FS_utime', 'FS_open', 'FS_close', 'FS_isClosed', 'FS_llseek', 'FS_read', 'FS_write', 'FS_mmap', 'FS_msync', 'FS_ioctl', 'FS_writeFile', 'FS_cwd', 'FS_chdir', 'FS_createDefaultDirectories', 'FS_createDefaultDevices', 'FS_createSpecialDirectories', 'FS_createStandardStreams', 'FS_staticInit', 'FS_init', 'FS_quit', 'FS_findObject', 'FS_analyzePath', 'FS_createFile', 'FS_createDataFile', 'FS_forceLoadFile', 'FS_createLazyFile', 'FS_absolutePath', 'FS_createFolder', 'FS_createLink', 'FS_joinPath', 'FS_mmapAlloc', 'FS_standardizePath', 'MEMFS', 'TTY', 'PIPEFS', 'SOCKFS', 'tempFixedLengthArray', 'miniTempWebGLFloatBuffers', 'miniTempWebGLIntBuffers', 'GL', 'AL', 'GLUT', 'EGL', 'GLEW', 'IDBStore', 'runAndAbortIfError', 'Asyncify', 'Fibers', 'SDL', 'SDL_gfx', 'print', 'printErr', 'jstoi_s', ]; unexportedSymbols.forEach(unexportedRuntimeSymbol); // End runtime exports // Begin JS library exports // End JS library exports // end include: postlibrary.js function checkIncomingModuleAPI() { ignoredModuleProp('fetchSettings'); } function proxy_convert_mp_to_js_then_js_to_mp_obj_jsside(out) { const ret = proxy_convert_mp_to_js_obj_jsside(out); proxy_convert_js_to_mp_obj_jsside_force_double_proxy(ret, out); } function proxy_convert_mp_to_js_then_js_to_js_then_js_to_mp_obj_jsside(out) { const ret = proxy_convert_mp_to_js_obj_jsside(out); const js_obj = PyProxy.toJs(ret); proxy_convert_js_to_mp_obj_jsside(js_obj, out); } function js_get_proxy_js_ref_info(out) { let used = 0; for (const elem of proxy_js_ref) { if (elem !== undefined) { ++used; } } Module.setValue(out, proxy_js_ref.length, "i32"); Module.setValue(out + 4, used, "i32"); } function has_attr(jsref,str) { const base = proxy_js_ref[jsref]; const attr = UTF8ToString(str); if (attr in base) { return true; } else { return false; } } function lookup_attr(jsref,str,out) { const base = proxy_js_ref[jsref]; const attr = UTF8ToString(str); let value = base[attr]; if (value !== undefined || attr in base) { if (typeof value === "function") { if (base !== globalThis) { if ("_ref" in value) { } else { value = value.bind(base); } } } proxy_convert_js_to_mp_obj_jsside(value, out); return true; } else { return false; } } function store_attr(jsref,attr_ptr,value_ref) { const attr = UTF8ToString(attr_ptr); const value = proxy_convert_mp_to_js_obj_jsside(value_ref); proxy_js_ref[jsref][attr] = value; } function call0(f_ref,out) { const f = proxy_js_ref[f_ref]; const ret = f(); proxy_convert_js_to_mp_obj_jsside(ret, out); } function call1(f_ref,a0,out) { const a0_js = proxy_convert_mp_to_js_obj_jsside(a0); const f = proxy_js_ref[f_ref]; const ret = f(a0_js); proxy_convert_js_to_mp_obj_jsside(ret, out); } function call2(f_ref,a0,a1,out) { const a0_js = proxy_convert_mp_to_js_obj_jsside(a0); const a1_js = proxy_convert_mp_to_js_obj_jsside(a1); const f = proxy_js_ref[f_ref]; const ret = f(a0_js, a1_js); proxy_convert_js_to_mp_obj_jsside(ret, out); } function calln(f_ref,n_args,value,out) { const f = proxy_js_ref[f_ref]; const a = []; for (let i = 0; i < n_args; ++i) { const v = proxy_convert_mp_to_js_obj_jsside(value + i * 3 * 4); a.push(v); } const ret = f(... a); proxy_convert_js_to_mp_obj_jsside(ret, out); } function call0_kwarg(f_ref,n_kw,key,value,out) { const f = proxy_js_ref[f_ref]; const a = {}; for (let i = 0; i < n_kw; ++i) { const k = UTF8ToString(getValue(key + i * 4, "i32")); const v = proxy_convert_mp_to_js_obj_jsside(value + i * 3 * 4); a[k] = v; } const ret = f(a); proxy_convert_js_to_mp_obj_jsside(ret, out); } function call1_kwarg(f_ref,arg0,n_kw,key,value,out) { const f = proxy_js_ref[f_ref]; const a0 = proxy_convert_mp_to_js_obj_jsside(arg0); const a = {}; for (let i = 0; i < n_kw; ++i) { const k = UTF8ToString(getValue(key + i * 4, "i32")); const v = proxy_convert_mp_to_js_obj_jsside(value + i * 3 * 4); a[k] = v; } const ret = f(a0, a); proxy_convert_js_to_mp_obj_jsside(ret, out); } function js_reflect_construct(f_ref,n_args,args,out) { const f = proxy_js_ref[f_ref]; const as = []; for (let i = 0; i < n_args; ++i) { as.push(proxy_convert_mp_to_js_obj_jsside(args + i * 3 * 4)); } const ret = Reflect.construct(f, as); proxy_convert_js_to_mp_obj_jsside(ret, out); } function js_get_iter(f_ref,out) { const f = proxy_js_ref[f_ref]; const ret = f[Symbol.iterator](); proxy_convert_js_to_mp_obj_jsside(ret, out); } function js_iter_next(f_ref,out) { const f = proxy_js_ref[f_ref]; const ret = f.next(); if (ret.done) { return false; } else { proxy_convert_js_to_mp_obj_jsside(ret.value, out); return true; } } function js_subscr_load(f_ref,index_ref,out) { const target = proxy_js_ref[f_ref]; const index = python_index_semantics(target, proxy_convert_mp_to_js_obj_jsside(index_ref)); const ret = target[index]; proxy_convert_js_to_mp_obj_jsside(ret, out); } function js_subscr_store(f_ref,idx,value) { const f = proxy_js_ref[f_ref]; f[proxy_convert_mp_to_js_obj_jsside(idx)] = proxy_convert_mp_to_js_obj_jsside(value); } function proxy_js_free_obj(js_ref) { if (js_ref >= PROXY_JS_REF_NUM_STATIC) { proxy_js_ref[js_ref] = undefined; if (js_ref < proxy_js_ref_next) { proxy_js_ref_next = js_ref; } } } function js_check_existing(c_ref) { return proxy_js_check_existing(c_ref); } function js_get_error_info(jsref,out_name,out_message) { const error = proxy_js_ref[jsref]; proxy_convert_js_to_mp_obj_jsside(error.name, out_name); proxy_convert_js_to_mp_obj_jsside(error.message, out_message); } function js_then_resolve(ret_value,resolve) { const ret_value_js = proxy_convert_mp_to_js_obj_jsside(ret_value); const resolve_js = proxy_convert_mp_to_js_obj_jsside(resolve); resolve_js(ret_value_js); } function js_then_reject(ret_value,reject) { let ret_value_js; try { ret_value_js = proxy_convert_mp_to_js_obj_jsside(ret_value); } catch(error) { ret_value_js = error; } const reject_js = proxy_convert_mp_to_js_obj_jsside(reject); reject_js(ret_value_js); } function js_then_continue(jsref,py_resume,resolve,reject,out) { const py_resume_js = proxy_convert_mp_to_js_obj_jsside(py_resume); const resolve_js = proxy_convert_mp_to_js_obj_jsside(resolve); const reject_js = proxy_convert_mp_to_js_obj_jsside(reject); const ret = proxy_js_ref[jsref].then( (result) => { py_resume_js(result, null, resolve_js, reject_js); }, (reason) => { py_resume_js(null, reason, resolve_js, reject_js); }, ); proxy_convert_js_to_mp_obj_jsside(ret, out); } function create_promise(out_set,out_promise) { const out_set_js = proxy_convert_mp_to_js_obj_jsside(out_set); const promise = new Promise(out_set_js); proxy_convert_js_to_mp_obj_jsside(promise, out_promise); } // Imports from the Wasm binary. var _mp_sched_keyboard_interrupt = Module['_mp_sched_keyboard_interrupt'] = makeInvalidEarlyAccess('_mp_sched_keyboard_interrupt'); var _mp_js_init = Module['_mp_js_init'] = makeInvalidEarlyAccess('_mp_js_init'); var _malloc = Module['_malloc'] = makeInvalidEarlyAccess('_malloc'); var _mp_js_register_js_module = Module['_mp_js_register_js_module'] = makeInvalidEarlyAccess('_mp_js_register_js_module'); var _mp_js_do_import = Module['_mp_js_do_import'] = makeInvalidEarlyAccess('_mp_js_do_import'); var _proxy_convert_mp_to_js_obj_cside = Module['_proxy_convert_mp_to_js_obj_cside'] = makeInvalidEarlyAccess('_proxy_convert_mp_to_js_obj_cside'); var _mp_js_do_exec = Module['_mp_js_do_exec'] = makeInvalidEarlyAccess('_mp_js_do_exec'); var _mp_js_do_exec_async = Module['_mp_js_do_exec_async'] = makeInvalidEarlyAccess('_mp_js_do_exec_async'); var _mp_js_repl_init = Module['_mp_js_repl_init'] = makeInvalidEarlyAccess('_mp_js_repl_init'); var _mp_js_repl_process_char = Module['_mp_js_repl_process_char'] = makeInvalidEarlyAccess('_mp_js_repl_process_char'); var _mp_hal_get_interrupt_char = Module['_mp_hal_get_interrupt_char'] = makeInvalidEarlyAccess('_mp_hal_get_interrupt_char'); var _proxy_c_init = Module['_proxy_c_init'] = makeInvalidEarlyAccess('_proxy_c_init'); var _proxy_c_free_obj = Module['_proxy_c_free_obj'] = makeInvalidEarlyAccess('_proxy_c_free_obj'); var _free = Module['_free'] = makeInvalidEarlyAccess('_free'); var _proxy_c_to_js_call = Module['_proxy_c_to_js_call'] = makeInvalidEarlyAccess('_proxy_c_to_js_call'); var _proxy_c_to_js_dir = Module['_proxy_c_to_js_dir'] = makeInvalidEarlyAccess('_proxy_c_to_js_dir'); var _proxy_c_to_js_has_attr = Module['_proxy_c_to_js_has_attr'] = makeInvalidEarlyAccess('_proxy_c_to_js_has_attr'); var _proxy_c_to_js_lookup_attr = Module['_proxy_c_to_js_lookup_attr'] = makeInvalidEarlyAccess('_proxy_c_to_js_lookup_attr'); var _proxy_c_to_js_store_attr = Module['_proxy_c_to_js_store_attr'] = makeInvalidEarlyAccess('_proxy_c_to_js_store_attr'); var _proxy_c_to_js_delete_attr = Module['_proxy_c_to_js_delete_attr'] = makeInvalidEarlyAccess('_proxy_c_to_js_delete_attr'); var _proxy_c_to_js_get_type = Module['_proxy_c_to_js_get_type'] = makeInvalidEarlyAccess('_proxy_c_to_js_get_type'); var _proxy_c_to_js_get_array = Module['_proxy_c_to_js_get_array'] = makeInvalidEarlyAccess('_proxy_c_to_js_get_array'); var _proxy_c_to_js_get_dict = Module['_proxy_c_to_js_get_dict'] = makeInvalidEarlyAccess('_proxy_c_to_js_get_dict'); var _proxy_c_to_js_get_iter = Module['_proxy_c_to_js_get_iter'] = makeInvalidEarlyAccess('_proxy_c_to_js_get_iter'); var _proxy_c_to_js_iternext = Module['_proxy_c_to_js_iternext'] = makeInvalidEarlyAccess('_proxy_c_to_js_iternext'); var _proxy_c_to_js_resume = Module['_proxy_c_to_js_resume'] = makeInvalidEarlyAccess('_proxy_c_to_js_resume'); var _emscripten_stack_get_base = makeInvalidEarlyAccess('_emscripten_stack_get_base'); var _emscripten_stack_get_current = makeInvalidEarlyAccess('_emscripten_stack_get_current'); var _fflush = makeInvalidEarlyAccess('_fflush'); var _strerror = makeInvalidEarlyAccess('_strerror'); var _emscripten_stack_get_end = makeInvalidEarlyAccess('_emscripten_stack_get_end'); var _setThrew = makeInvalidEarlyAccess('_setThrew'); var _emscripten_stack_init = makeInvalidEarlyAccess('_emscripten_stack_init'); var _emscripten_stack_get_free = makeInvalidEarlyAccess('_emscripten_stack_get_free'); var __emscripten_stack_restore = makeInvalidEarlyAccess('__emscripten_stack_restore'); var __emscripten_stack_alloc = makeInvalidEarlyAccess('__emscripten_stack_alloc'); var dynCall_viii = makeInvalidEarlyAccess('dynCall_viii'); var dynCall_vi = makeInvalidEarlyAccess('dynCall_vi'); var dynCall_ii = makeInvalidEarlyAccess('dynCall_ii'); var dynCall_vii = makeInvalidEarlyAccess('dynCall_vii'); var dynCall_iii = makeInvalidEarlyAccess('dynCall_iii'); var dynCall_viiii = makeInvalidEarlyAccess('dynCall_viiii'); var dynCall_iiii = makeInvalidEarlyAccess('dynCall_iiii'); var dynCall_iiiii = makeInvalidEarlyAccess('dynCall_iiiii'); var dynCall_v = makeInvalidEarlyAccess('dynCall_v'); var dynCall_i = makeInvalidEarlyAccess('dynCall_i'); var dynCall_dd = makeInvalidEarlyAccess('dynCall_dd'); var dynCall_ddd = makeInvalidEarlyAccess('dynCall_ddd'); var dynCall_viiiiii = makeInvalidEarlyAccess('dynCall_viiiiii'); var dynCall_iiiiii = makeInvalidEarlyAccess('dynCall_iiiiii'); var dynCall_di = makeInvalidEarlyAccess('dynCall_di'); var dynCall_vid = makeInvalidEarlyAccess('dynCall_vid'); var dynCall_iidiiii = makeInvalidEarlyAccess('dynCall_iidiiii'); var dynCall_jiji = makeInvalidEarlyAccess('dynCall_jiji'); var _asyncify_start_unwind = makeInvalidEarlyAccess('_asyncify_start_unwind'); var _asyncify_stop_unwind = makeInvalidEarlyAccess('_asyncify_stop_unwind'); var _asyncify_start_rewind = makeInvalidEarlyAccess('_asyncify_start_rewind'); var _asyncify_stop_rewind = makeInvalidEarlyAccess('_asyncify_stop_rewind'); var memory = makeInvalidEarlyAccess('memory'); var __indirect_function_table = makeInvalidEarlyAccess('__indirect_function_table'); var wasmMemory = makeInvalidEarlyAccess('wasmMemory'); var wasmTable = makeInvalidEarlyAccess('wasmTable'); function assignWasmExports(wasmExports) { assert(typeof wasmExports['mp_sched_keyboard_interrupt'] != 'undefined', 'missing Wasm export: mp_sched_keyboard_interrupt'); assert(typeof wasmExports['mp_js_init'] != 'undefined', 'missing Wasm export: mp_js_init'); assert(typeof wasmExports['malloc'] != 'undefined', 'missing Wasm export: malloc'); assert(typeof wasmExports['mp_js_register_js_module'] != 'undefined', 'missing Wasm export: mp_js_register_js_module'); assert(typeof wasmExports['mp_js_do_import'] != 'undefined', 'missing Wasm export: mp_js_do_import'); assert(typeof wasmExports['proxy_convert_mp_to_js_obj_cside'] != 'undefined', 'missing Wasm export: proxy_convert_mp_to_js_obj_cside'); assert(typeof wasmExports['mp_js_do_exec'] != 'undefined', 'missing Wasm export: mp_js_do_exec'); assert(typeof wasmExports['mp_js_do_exec_async'] != 'undefined', 'missing Wasm export: mp_js_do_exec_async'); assert(typeof wasmExports['mp_js_repl_init'] != 'undefined', 'missing Wasm export: mp_js_repl_init'); assert(typeof wasmExports['mp_js_repl_process_char'] != 'undefined', 'missing Wasm export: mp_js_repl_process_char'); assert(typeof wasmExports['mp_hal_get_interrupt_char'] != 'undefined', 'missing Wasm export: mp_hal_get_interrupt_char'); assert(typeof wasmExports['proxy_c_init'] != 'undefined', 'missing Wasm export: proxy_c_init'); assert(typeof wasmExports['proxy_c_free_obj'] != 'undefined', 'missing Wasm export: proxy_c_free_obj'); assert(typeof wasmExports['free'] != 'undefined', 'missing Wasm export: free'); assert(typeof wasmExports['proxy_c_to_js_call'] != 'undefined', 'missing Wasm export: proxy_c_to_js_call'); assert(typeof wasmExports['proxy_c_to_js_dir'] != 'undefined', 'missing Wasm export: proxy_c_to_js_dir'); assert(typeof wasmExports['proxy_c_to_js_has_attr'] != 'undefined', 'missing Wasm export: proxy_c_to_js_has_attr'); assert(typeof wasmExports['proxy_c_to_js_lookup_attr'] != 'undefined', 'missing Wasm export: proxy_c_to_js_lookup_attr'); assert(typeof wasmExports['proxy_c_to_js_store_attr'] != 'undefined', 'missing Wasm export: proxy_c_to_js_store_attr'); assert(typeof wasmExports['proxy_c_to_js_delete_attr'] != 'undefined', 'missing Wasm export: proxy_c_to_js_delete_attr'); assert(typeof wasmExports['proxy_c_to_js_get_type'] != 'undefined', 'missing Wasm export: proxy_c_to_js_get_type'); assert(typeof wasmExports['proxy_c_to_js_get_array'] != 'undefined', 'missing Wasm export: proxy_c_to_js_get_array'); assert(typeof wasmExports['proxy_c_to_js_get_dict'] != 'undefined', 'missing Wasm export: proxy_c_to_js_get_dict'); assert(typeof wasmExports['proxy_c_to_js_get_iter'] != 'undefined', 'missing Wasm export: proxy_c_to_js_get_iter'); assert(typeof wasmExports['proxy_c_to_js_iternext'] != 'undefined', 'missing Wasm export: proxy_c_to_js_iternext'); assert(typeof wasmExports['proxy_c_to_js_resume'] != 'undefined', 'missing Wasm export: proxy_c_to_js_resume'); assert(typeof wasmExports['emscripten_stack_get_base'] != 'undefined', 'missing Wasm export: emscripten_stack_get_base'); assert(typeof wasmExports['emscripten_stack_get_current'] != 'undefined', 'missing Wasm export: emscripten_stack_get_current'); assert(typeof wasmExports['fflush'] != 'undefined', 'missing Wasm export: fflush'); assert(typeof wasmExports['strerror'] != 'undefined', 'missing Wasm export: strerror'); assert(typeof wasmExports['emscripten_stack_get_end'] != 'undefined', 'missing Wasm export: emscripten_stack_get_end'); assert(typeof wasmExports['setThrew'] != 'undefined', 'missing Wasm export: setThrew'); assert(typeof wasmExports['emscripten_stack_init'] != 'undefined', 'missing Wasm export: emscripten_stack_init'); assert(typeof wasmExports['emscripten_stack_get_free'] != 'undefined', 'missing Wasm export: emscripten_stack_get_free'); assert(typeof wasmExports['_emscripten_stack_restore'] != 'undefined', 'missing Wasm export: _emscripten_stack_restore'); assert(typeof wasmExports['_emscripten_stack_alloc'] != 'undefined', 'missing Wasm export: _emscripten_stack_alloc'); assert(typeof wasmExports['dynCall_viii'] != 'undefined', 'missing Wasm export: dynCall_viii'); assert(typeof wasmExports['dynCall_vi'] != 'undefined', 'missing Wasm export: dynCall_vi'); assert(typeof wasmExports['dynCall_ii'] != 'undefined', 'missing Wasm export: dynCall_ii'); assert(typeof wasmExports['dynCall_vii'] != 'undefined', 'missing Wasm export: dynCall_vii'); assert(typeof wasmExports['dynCall_iii'] != 'undefined', 'missing Wasm export: dynCall_iii'); assert(typeof wasmExports['dynCall_viiii'] != 'undefined', 'missing Wasm export: dynCall_viiii'); assert(typeof wasmExports['dynCall_iiii'] != 'undefined', 'missing Wasm export: dynCall_iiii'); assert(typeof wasmExports['dynCall_iiiii'] != 'undefined', 'missing Wasm export: dynCall_iiiii'); assert(typeof wasmExports['dynCall_v'] != 'undefined', 'missing Wasm export: dynCall_v'); assert(typeof wasmExports['dynCall_i'] != 'undefined', 'missing Wasm export: dynCall_i'); assert(typeof wasmExports['dynCall_dd'] != 'undefined', 'missing Wasm export: dynCall_dd'); assert(typeof wasmExports['dynCall_ddd'] != 'undefined', 'missing Wasm export: dynCall_ddd'); assert(typeof wasmExports['dynCall_viiiiii'] != 'undefined', 'missing Wasm export: dynCall_viiiiii'); assert(typeof wasmExports['dynCall_iiiiii'] != 'undefined', 'missing Wasm export: dynCall_iiiiii'); assert(typeof wasmExports['dynCall_di'] != 'undefined', 'missing Wasm export: dynCall_di'); assert(typeof wasmExports['dynCall_vid'] != 'undefined', 'missing Wasm export: dynCall_vid'); assert(typeof wasmExports['dynCall_iidiiii'] != 'undefined', 'missing Wasm export: dynCall_iidiiii'); assert(typeof wasmExports['dynCall_jiji'] != 'undefined', 'missing Wasm export: dynCall_jiji'); assert(typeof wasmExports['asyncify_start_unwind'] != 'undefined', 'missing Wasm export: asyncify_start_unwind'); assert(typeof wasmExports['asyncify_stop_unwind'] != 'undefined', 'missing Wasm export: asyncify_stop_unwind'); assert(typeof wasmExports['asyncify_start_rewind'] != 'undefined', 'missing Wasm export: asyncify_start_rewind'); assert(typeof wasmExports['asyncify_stop_rewind'] != 'undefined', 'missing Wasm export: asyncify_stop_rewind'); assert(typeof wasmExports['memory'] != 'undefined', 'missing Wasm export: memory'); assert(typeof wasmExports['__indirect_function_table'] != 'undefined', 'missing Wasm export: __indirect_function_table'); _mp_sched_keyboard_interrupt = Module['_mp_sched_keyboard_interrupt'] = createExportWrapper('mp_sched_keyboard_interrupt', 0); _mp_js_init = Module['_mp_js_init'] = createExportWrapper('mp_js_init', 2); _malloc = Module['_malloc'] = createExportWrapper('malloc', 1); _mp_js_register_js_module = Module['_mp_js_register_js_module'] = createExportWrapper('mp_js_register_js_module', 2); _mp_js_do_import = Module['_mp_js_do_import'] = createExportWrapper('mp_js_do_import', 2); _proxy_convert_mp_to_js_obj_cside = Module['_proxy_convert_mp_to_js_obj_cside'] = createExportWrapper('proxy_convert_mp_to_js_obj_cside', 2); _mp_js_do_exec = Module['_mp_js_do_exec'] = createExportWrapper('mp_js_do_exec', 3); _mp_js_do_exec_async = Module['_mp_js_do_exec_async'] = createExportWrapper('mp_js_do_exec_async', 3); _mp_js_repl_init = Module['_mp_js_repl_init'] = createExportWrapper('mp_js_repl_init', 0); _mp_js_repl_process_char = Module['_mp_js_repl_process_char'] = createExportWrapper('mp_js_repl_process_char', 1); _mp_hal_get_interrupt_char = Module['_mp_hal_get_interrupt_char'] = createExportWrapper('mp_hal_get_interrupt_char', 0); _proxy_c_init = Module['_proxy_c_init'] = createExportWrapper('proxy_c_init', 0); _proxy_c_free_obj = Module['_proxy_c_free_obj'] = createExportWrapper('proxy_c_free_obj', 1); _free = Module['_free'] = createExportWrapper('free', 1); _proxy_c_to_js_call = Module['_proxy_c_to_js_call'] = createExportWrapper('proxy_c_to_js_call', 4); _proxy_c_to_js_dir = Module['_proxy_c_to_js_dir'] = createExportWrapper('proxy_c_to_js_dir', 2); _proxy_c_to_js_has_attr = Module['_proxy_c_to_js_has_attr'] = createExportWrapper('proxy_c_to_js_has_attr', 2); _proxy_c_to_js_lookup_attr = Module['_proxy_c_to_js_lookup_attr'] = createExportWrapper('proxy_c_to_js_lookup_attr', 3); _proxy_c_to_js_store_attr = Module['_proxy_c_to_js_store_attr'] = createExportWrapper('proxy_c_to_js_store_attr', 3); _proxy_c_to_js_delete_attr = Module['_proxy_c_to_js_delete_attr'] = createExportWrapper('proxy_c_to_js_delete_attr', 2); _proxy_c_to_js_get_type = Module['_proxy_c_to_js_get_type'] = createExportWrapper('proxy_c_to_js_get_type', 1); _proxy_c_to_js_get_array = Module['_proxy_c_to_js_get_array'] = createExportWrapper('proxy_c_to_js_get_array', 2); _proxy_c_to_js_get_dict = Module['_proxy_c_to_js_get_dict'] = createExportWrapper('proxy_c_to_js_get_dict', 2); _proxy_c_to_js_get_iter = Module['_proxy_c_to_js_get_iter'] = createExportWrapper('proxy_c_to_js_get_iter', 1); _proxy_c_to_js_iternext = Module['_proxy_c_to_js_iternext'] = createExportWrapper('proxy_c_to_js_iternext', 2); _proxy_c_to_js_resume = Module['_proxy_c_to_js_resume'] = createExportWrapper('proxy_c_to_js_resume', 2); _emscripten_stack_get_base = wasmExports['emscripten_stack_get_base']; _emscripten_stack_get_current = wasmExports['emscripten_stack_get_current']; _fflush = createExportWrapper('fflush', 1); _strerror = createExportWrapper('strerror', 1); _emscripten_stack_get_end = wasmExports['emscripten_stack_get_end']; _setThrew = createExportWrapper('setThrew', 2); _emscripten_stack_init = wasmExports['emscripten_stack_init']; _emscripten_stack_get_free = wasmExports['emscripten_stack_get_free']; __emscripten_stack_restore = wasmExports['_emscripten_stack_restore']; __emscripten_stack_alloc = wasmExports['_emscripten_stack_alloc']; dynCall_viii = dynCalls['viii'] = createExportWrapper('dynCall_viii', 4); dynCall_vi = dynCalls['vi'] = createExportWrapper('dynCall_vi', 2); dynCall_ii = dynCalls['ii'] = createExportWrapper('dynCall_ii', 2); dynCall_vii = dynCalls['vii'] = createExportWrapper('dynCall_vii', 3); dynCall_iii = dynCalls['iii'] = createExportWrapper('dynCall_iii', 3); dynCall_viiii = dynCalls['viiii'] = createExportWrapper('dynCall_viiii', 5); dynCall_iiii = dynCalls['iiii'] = createExportWrapper('dynCall_iiii', 4); dynCall_iiiii = dynCalls['iiiii'] = createExportWrapper('dynCall_iiiii', 5); dynCall_v = dynCalls['v'] = createExportWrapper('dynCall_v', 1); dynCall_i = dynCalls['i'] = createExportWrapper('dynCall_i', 1); dynCall_dd = dynCalls['dd'] = createExportWrapper('dynCall_dd', 2); dynCall_ddd = dynCalls['ddd'] = createExportWrapper('dynCall_ddd', 3); dynCall_viiiiii = dynCalls['viiiiii'] = createExportWrapper('dynCall_viiiiii', 7); dynCall_iiiiii = dynCalls['iiiiii'] = createExportWrapper('dynCall_iiiiii', 6); dynCall_di = dynCalls['di'] = createExportWrapper('dynCall_di', 2); dynCall_vid = dynCalls['vid'] = createExportWrapper('dynCall_vid', 3); dynCall_iidiiii = dynCalls['iidiiii'] = createExportWrapper('dynCall_iidiiii', 7); dynCall_jiji = dynCalls['jiji'] = createExportWrapper('dynCall_jiji', 4); _asyncify_start_unwind = createExportWrapper('asyncify_start_unwind', 1); _asyncify_stop_unwind = createExportWrapper('asyncify_stop_unwind', 0); _asyncify_start_rewind = createExportWrapper('asyncify_start_rewind', 1); _asyncify_stop_rewind = createExportWrapper('asyncify_stop_rewind', 0); memory = wasmMemory = wasmExports['memory']; __indirect_function_table = wasmTable = wasmExports['__indirect_function_table']; } var wasmImports = { /** @export */ __syscall_chdir: ___syscall_chdir, /** @export */ __syscall_fstat64: ___syscall_fstat64, /** @export */ __syscall_getcwd: ___syscall_getcwd, /** @export */ __syscall_getdents64: ___syscall_getdents64, /** @export */ __syscall_lstat64: ___syscall_lstat64, /** @export */ __syscall_mkdirat: ___syscall_mkdirat, /** @export */ __syscall_newfstatat: ___syscall_newfstatat, /** @export */ __syscall_openat: ___syscall_openat, /** @export */ __syscall_poll: ___syscall_poll, /** @export */ __syscall_renameat: ___syscall_renameat, /** @export */ __syscall_rmdir: ___syscall_rmdir, /** @export */ __syscall_stat64: ___syscall_stat64, /** @export */ __syscall_statfs64: ___syscall_statfs64, /** @export */ __syscall_unlinkat: ___syscall_unlinkat, /** @export */ _abort_js: __abort_js, /** @export */ _emscripten_throw_longjmp: __emscripten_throw_longjmp, /** @export */ call0, /** @export */ call0_kwarg, /** @export */ call1, /** @export */ call1_kwarg, /** @export */ call2, /** @export */ calln, /** @export */ create_promise, /** @export */ emscripten_resize_heap: _emscripten_resize_heap, /** @export */ emscripten_scan_registers: _emscripten_scan_registers, /** @export */ fd_close: _fd_close, /** @export */ fd_read: _fd_read, /** @export */ fd_seek: _fd_seek, /** @export */ fd_sync: _fd_sync, /** @export */ fd_write: _fd_write, /** @export */ has_attr, /** @export */ invoke_i, /** @export */ invoke_ii, /** @export */ invoke_iii, /** @export */ invoke_iiii, /** @export */ invoke_iiiii, /** @export */ invoke_iiiiii, /** @export */ invoke_v, /** @export */ invoke_vi, /** @export */ invoke_vii, /** @export */ invoke_viii, /** @export */ invoke_viiii, /** @export */ js_check_existing, /** @export */ js_get_error_info, /** @export */ js_get_iter, /** @export */ js_get_proxy_js_ref_info, /** @export */ js_iter_next, /** @export */ js_reflect_construct, /** @export */ js_subscr_load, /** @export */ js_subscr_store, /** @export */ js_then_continue, /** @export */ js_then_reject, /** @export */ js_then_resolve, /** @export */ lookup_attr, /** @export */ mp_js_hook: _mp_js_hook, /** @export */ mp_js_random_u32: _mp_js_random_u32, /** @export */ mp_js_ticks_ms: _mp_js_ticks_ms, /** @export */ mp_js_time_ms: _mp_js_time_ms, /** @export */ proxy_convert_mp_to_js_then_js_to_js_then_js_to_mp_obj_jsside, /** @export */ proxy_convert_mp_to_js_then_js_to_mp_obj_jsside, /** @export */ proxy_js_free_obj, /** @export */ store_attr }; function invoke_ii(index,a1) { var sp = stackSave(); try { return dynCall_ii(index,a1); } catch(e) { stackRestore(sp); if (e !== e+0) throw e; _setThrew(1, 0); } } function invoke_viii(index,a1,a2,a3) { var sp = stackSave(); try { dynCall_viii(index,a1,a2,a3); } catch(e) { stackRestore(sp); if (e !== e+0) throw e; _setThrew(1, 0); } } function invoke_iiiii(index,a1,a2,a3,a4) { var sp = stackSave(); try { return dynCall_iiiii(index,a1,a2,a3,a4); } catch(e) { stackRestore(sp); if (e !== e+0) throw e; _setThrew(1, 0); } } function invoke_v(index) { var sp = stackSave(); try { dynCall_v(index); } catch(e) { stackRestore(sp); if (e !== e+0) throw e; _setThrew(1, 0); } } function invoke_iii(index,a1,a2) { var sp = stackSave(); try { return dynCall_iii(index,a1,a2); } catch(e) { stackRestore(sp); if (e !== e+0) throw e; _setThrew(1, 0); } } function invoke_vi(index,a1) { var sp = stackSave(); try { dynCall_vi(index,a1); } catch(e) { stackRestore(sp); if (e !== e+0) throw e; _setThrew(1, 0); } } function invoke_vii(index,a1,a2) { var sp = stackSave(); try { dynCall_vii(index,a1,a2); } catch(e) { stackRestore(sp); if (e !== e+0) throw e; _setThrew(1, 0); } } function invoke_iiii(index,a1,a2,a3) { var sp = stackSave(); try { return dynCall_iiii(index,a1,a2,a3); } catch(e) { stackRestore(sp); if (e !== e+0) throw e; _setThrew(1, 0); } } function invoke_i(index) { var sp = stackSave(); try { return dynCall_i(index); } catch(e) { stackRestore(sp); if (e !== e+0) throw e; _setThrew(1, 0); } } function invoke_viiii(index,a1,a2,a3,a4) { var sp = stackSave(); try { dynCall_viiii(index,a1,a2,a3,a4); } catch(e) { stackRestore(sp); if (e !== e+0) throw e; _setThrew(1, 0); } } function invoke_iiiiii(index,a1,a2,a3,a4,a5) { var sp = stackSave(); try { return dynCall_iiiiii(index,a1,a2,a3,a4,a5); } catch(e) { stackRestore(sp); if (e !== e+0) throw e; _setThrew(1, 0); } } // include: postamble.js // === Auto-generated postamble setup entry stuff === var calledRun; function stackCheckInit() { // This is normally called automatically during __wasm_call_ctors but need to // get these values before even running any of the ctors so we call it redundantly // here. _emscripten_stack_init(); // TODO(sbc): Move writeStackCookie to native to to avoid this. writeStackCookie(); } function run() { if (runDependencies > 0) { dependenciesFulfilled = run; return; } stackCheckInit(); preRun(); // a preRun added a dependency, run will be called later if (runDependencies > 0) { dependenciesFulfilled = run; return; } function doRun() { // run may have just been called through dependencies being fulfilled just in this very frame, // or while the async setStatus time below was happening assert(!calledRun); calledRun = true; Module['calledRun'] = true; if (ABORT) return; initRuntime(); readyPromiseResolve?.(Module); Module['onRuntimeInitialized']?.(); consumedModuleProp('onRuntimeInitialized'); assert(!Module['_main'], 'compiled without a main, but one is present. if you added it from JS, use Module["onRuntimeInitialized"]'); postRun(); } if (Module['setStatus']) { Module['setStatus']('Running...'); setTimeout(() => { setTimeout(() => Module['setStatus'](''), 1); doRun(); }, 1); } else { doRun(); } checkStackCookie(); } function checkUnflushedContent() { // Compiler settings do not allow exiting the runtime, so flushing // the streams is not possible. but in ASSERTIONS mode we check // if there was something to flush, and if so tell the user they // should request that the runtime be exitable. // Normally we would not even include flush() at all, but in ASSERTIONS // builds we do so just for this check, and here we see if there is any // content to flush, that is, we check if there would have been // something a non-ASSERTIONS build would have not seen. // How we flush the streams depends on whether we are in SYSCALLS_REQUIRE_FILESYSTEM=0 // mode (which has its own special function for this; otherwise, all // the code is inside libc) var oldOut = out; var oldErr = err; var has = false; out = err = (x) => { has = true; } try { // it doesn't matter if it fails _fflush(0); // also flush in the JS FS layer for (var name of ['stdout', 'stderr']) { var info = FS.analyzePath('/dev/' + name); if (!info) return; var stream = info.object; var rdev = stream.rdev; var tty = TTY.ttys[rdev]; if (tty?.output?.length) { has = true; } } } catch(e) {} out = oldOut; err = oldErr; if (has) { warnOnce('stdio streams had content in them that was not flushed. you should set EXIT_RUNTIME to 1 (see the Emscripten FAQ), or make sure to emit a newline when you printf etc.'); } } var wasmExports; // In modularize mode the generated code is within a factory function so we // can use await here (since it's not top-level-await). wasmExports = await (createWasm()); run(); // end include: postamble.js // include: postamble_modularize.js // In MODULARIZE mode we wrap the generated code in a factory function // and return either the Module itself, or a promise of the module. // // We assign to the `moduleRtn` global here and configure closure to see // this as and extern so it won't get minified. if (runtimeInitialized) { moduleRtn = Module; } else { // Set up the promise that indicates the Module is initialized moduleRtn = new Promise((resolve, reject) => { readyPromiseResolve = resolve; readyPromiseReject = reject; }); } // Assertion for attempting to access module properties on the incoming // moduleArg. In the past we used this object as the prototype of the module // and assigned properties to it, but now we return a distinct object. This // keeps the instance private until it is ready (i.e the promise has been // resolved). for (const prop of Object.keys(Module)) { if (!(prop in moduleArg)) { Object.defineProperty(moduleArg, prop, { configurable: true, get() { abort(`Access to module property ('${prop}') is no longer possible via the module constructor argument; Instead, use the result of the module constructor.`) } }); } } // end include: postamble_modularize.js return moduleRtn; } // Export using a UMD style export, or ES6 exports if selected export default _createMicroPythonModule; /* * This file is part of the MicroPython project, http://micropython.org/ * * The MIT License (MIT) * * Copyright (c) 2023-2024 Damien P. George * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ // Options: // - pystack: size in words of the MicroPython Python stack. // - heapsize: size in bytes of the MicroPython GC heap. // - url: location to load `micropython.mjs`. // - stdin: function to return input characters. // - stdout: function that takes one argument, and is passed lines of stdout // output as they are produced. By default this is handled by Emscripten // and in a browser goes to console, in node goes to process.stdout.write. // - stderr: same behaviour as stdout but for error output. // - linebuffer: whether to buffer line-by-line to stdout/stderr. export async function loadMicroPython(options) { const { pystack, heapsize, url, stdin, stdout, stderr, linebuffer } = Object.assign( { pystack: 2 * 1024, heapsize: 1024 * 1024, linebuffer: true }, options, ); let Module = {}; Module.locateFile = (path, scriptDirectory) => url || scriptDirectory + path; Module._textDecoder = new TextDecoder(); if (stdin !== undefined) { Module.stdin = stdin; } if (stdout !== undefined) { if (linebuffer) { Module._stdoutBuffer = []; Module.stdout = (c) => { if (c === 10) { stdout( Module._textDecoder.decode( new Uint8Array(Module._stdoutBuffer), ), ); Module._stdoutBuffer = []; } else { Module._stdoutBuffer.push(c); } }; } else { Module.stdout = (c) => stdout(new Uint8Array([c])); } } if (stderr !== undefined) { if (linebuffer) { Module._stderrBuffer = []; Module.stderr = (c) => { if (c === 10) { stderr( Module._textDecoder.decode( new Uint8Array(Module._stderrBuffer), ), ); Module._stderrBuffer = []; } else { Module._stderrBuffer.push(c); } }; } else { Module.stderr = (c) => stderr(new Uint8Array([c])); } } Module = await _createMicroPythonModule(Module); globalThis.Module = Module; proxy_js_init(); const pyimport = (name) => { const value = Module._malloc(3 * 4); Module.ccall( "mp_js_do_import", "null", ["string", "pointer"], [name, value], ); return proxy_convert_mp_to_js_obj_jsside_with_free(value); }; Module.ccall( "mp_js_init", "null", ["number", "number"], [pystack, heapsize], ); Module.ccall("proxy_c_init", "null", [], []); return { _module: Module, PyProxy: PyProxy, FS: Module.FS, globals: { __dict__: pyimport("__main__").__dict__, get(key) { return this.__dict__[key]; }, set(key, value) { this.__dict__[key] = value; }, delete(key) { delete this.__dict__[key]; }, }, registerJsModule(name, module) { const value = Module._malloc(3 * 4); proxy_convert_js_to_mp_obj_jsside(module, value); Module.ccall( "mp_js_register_js_module", "null", ["string", "pointer"], [name, value], ); Module._free(value); }, pyimport: pyimport, runPython(code) { const len = Module.lengthBytesUTF8(code); const buf = Module._malloc(len + 1); Module.stringToUTF8(code, buf, len + 1); const value = Module._malloc(3 * 4); Module.ccall( "mp_js_do_exec", "number", ["pointer", "number", "pointer"], [buf, len, value], ); Module._free(buf); return proxy_convert_mp_to_js_obj_jsside_with_free(value); }, runPythonAsync(code) { const len = Module.lengthBytesUTF8(code); const buf = Module._malloc(len + 1); Module.stringToUTF8(code, buf, len + 1); const value = Module._malloc(3 * 4); Module.ccall( "mp_js_do_exec_async", "number", ["pointer", "number", "pointer"], [buf, len, value], { async: true }, ); Module._free(buf); const ret = proxy_convert_mp_to_js_obj_jsside_with_free(value); if (ret instanceof PyProxyThenable) { return Promise.resolve(ret); } return ret; }, replInit() { Module.ccall("mp_js_repl_init", "null", ["null"]); }, replProcessChar(chr) { return Module.ccall( "mp_js_repl_process_char", "number", ["number"], [chr], ); }, // Needed if the GC/asyncify is enabled. async replProcessCharWithAsyncify(chr) { return Module.ccall( "mp_js_repl_process_char", "number", ["number"], [chr], { async: true }, ); }, }; } globalThis.loadMicroPython = loadMicroPython; async function runCLI() { const fs = await import("fs"); let heap_size = 128 * 1024; let contents = ""; let repl = true; for (let i = 2; i < process.argv.length; i++) { if (process.argv[i] === "-X" && i < process.argv.length - 1) { if (process.argv[i + 1].includes("heapsize=")) { heap_size = parseInt(process.argv[i + 1].split("heapsize=")[1]); const suffix = process.argv[i + 1].substr(-1).toLowerCase(); if (suffix === "k") { heap_size *= 1024; } else if (suffix === "m") { heap_size *= 1024 * 1024; } ++i; } } else { contents += fs.readFileSync(process.argv[i], "utf8"); repl = false; } } if (process.stdin.isTTY === false) { contents = fs.readFileSync(0, "utf8"); repl = false; } const mp = await loadMicroPython({ heapsize: heap_size, stdout: (data) => process.stdout.write(data), linebuffer: false, }); if (repl) { mp.replInit(); process.stdin.setRawMode(true); process.stdin.on("data", (data) => { for (let i = 0; i < data.length; i++) { mp.replProcessCharWithAsyncify(data[i]).then((result) => { if (result) { process.exit(); } }); } }); } else { // If the script to run ends with a running of the asyncio main loop, then inject // a simple `asyncio.run` hook that starts the main task. This is primarily to // support running the standard asyncio tests. if (contents.endsWith("asyncio.run(main())\n")) { const asyncio = mp.pyimport("asyncio"); asyncio.run = async (task) => { await asyncio.create_task(task); }; } try { mp.runPython(contents); } catch (error) { if (error.name === "PythonError") { if (error.type === "SystemExit") { // SystemExit, this is a valid exception to successfully end a script. } else { // An unhandled Python exception, print in out. console.error(error.message); } } else { // A non-Python exception. Re-raise it. throw error; } } } } // Check if Node is running (equivalent to ENVIRONMENT_IS_NODE). if ( typeof process === "object" && typeof process.versions === "object" && typeof process.versions.node === "string" ) { // Check if this module is run from the command line via `node micropython.mjs`. // // See https://stackoverflow.com/questions/6398196/detect-if-called-through-require-or-directly-by-command-line/66309132#66309132 // // Note: // - `resolve()` is used to handle symlinks // - `includes()` is used to handle cases where the file extension was omitted when passed to node if (process.argv.length > 1) { const path = await import("path"); const url = await import("url"); const pathToThisFile = path.resolve(url.fileURLToPath(import.meta.url)); const pathPassedToNode = path.resolve(process.argv[1]); const isThisFileBeingRunViaCLI = pathToThisFile.includes(pathPassedToNode); if (isThisFileBeingRunViaCLI) { runCLI(); } } } /* * This file is part of the MicroPython project, http://micropython.org/ * * The MIT License (MIT) * * Copyright (c) 2023-2024 Damien P. George * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ class PyProxy { constructor(ref) { this._ref = ref; } // Convert js_obj -- which is possibly a PyProxy -- to a JavaScript object. static toJs(js_obj) { if (!(js_obj instanceof PyProxy)) { return js_obj; } const type = Module.ccall( "proxy_c_to_js_get_type", "number", ["number"], [js_obj._ref], ); if (type === 1 || type === 2) { // List or tuple. const array_ref = Module._malloc(2 * 4); const item = Module._malloc(3 * 4); Module.ccall( "proxy_c_to_js_get_array", "null", ["number", "pointer"], [js_obj._ref, array_ref], ); const len = Module.getValue(array_ref, "i32"); const items_ptr = Module.getValue(array_ref + 4, "i32"); const js_array = []; for (let i = 0; i < len; ++i) { Module.ccall( "proxy_convert_mp_to_js_obj_cside", "null", ["pointer", "pointer"], [Module.getValue(items_ptr + i * 4, "i32"), item], ); const js_item = proxy_convert_mp_to_js_obj_jsside(item); js_array.push(PyProxy.toJs(js_item)); } Module._free(array_ref); Module._free(item); return js_array; } if (type === 3) { // Dict. const map_ref = Module._malloc(2 * 4); const item = Module._malloc(3 * 4); Module.ccall( "proxy_c_to_js_get_dict", "null", ["number", "pointer"], [js_obj._ref, map_ref], ); const alloc = Module.getValue(map_ref, "i32"); const table_ptr = Module.getValue(map_ref + 4, "i32"); const js_dict = {}; for (let i = 0; i < alloc; ++i) { const mp_key = Module.getValue(table_ptr + i * 8, "i32"); if (mp_key > 8) { // Convert key to JS object. Module.ccall( "proxy_convert_mp_to_js_obj_cside", "null", ["pointer", "pointer"], [mp_key, item], ); const js_key = proxy_convert_mp_to_js_obj_jsside(item); // Convert value to JS object. const mp_value = Module.getValue( table_ptr + i * 8 + 4, "i32", ); Module.ccall( "proxy_convert_mp_to_js_obj_cside", "null", ["pointer", "pointer"], [mp_value, item], ); const js_value = proxy_convert_mp_to_js_obj_jsside(item); // Populate JS dict. js_dict[js_key] = PyProxy.toJs(js_value); } } Module._free(map_ref); Module._free(item); return js_dict; } // Cannot convert to JS, leave as a PyProxy. return js_obj; } } // This handler's goal is to allow minimal introspection // of Python references from the JS world/utilities. const py_proxy_handler = { isExtensible() { return true; }, ownKeys(target) { const value = Module._malloc(3 * 4); Module.ccall( "proxy_c_to_js_dir", "null", ["number", "pointer"], [target._ref, value], ); const dir = proxy_convert_mp_to_js_obj_jsside_with_free(value); return PyProxy.toJs(dir).filter((attr) => !attr.startsWith("__")); }, getOwnPropertyDescriptor(target, prop) { return { value: target[prop], enumerable: true, writable: true, configurable: true, }; }, has(target, prop) { return Module.ccall( "proxy_c_to_js_has_attr", "number", ["number", "string"], [target._ref, prop], ); }, get(target, prop) { if (prop === "_ref") { return target._ref; } if (prop === "then") { return null; } if (prop === Symbol.iterator) { // Get the Python object iterator, and return a JavaScript generator. const iter_ref = Module.ccall( "proxy_c_to_js_get_iter", "number", ["number"], [target._ref], ); return function* () { const value = Module._malloc(3 * 4); while (true) { const valid = Module.ccall( "proxy_c_to_js_iternext", "number", ["number", "pointer"], [iter_ref, value], ); if (!valid) { break; } yield proxy_convert_mp_to_js_obj_jsside(value); } Module._free(value); }; } const value = Module._malloc(3 * 4); Module.ccall( "proxy_c_to_js_lookup_attr", "null", ["number", "string", "pointer"], [target._ref, prop, value], ); return proxy_convert_mp_to_js_obj_jsside_with_free(value); }, set(target, prop, value) { const value_conv = Module._malloc(3 * 4); proxy_convert_js_to_mp_obj_jsside(value, value_conv); const ret = Module.ccall( "proxy_c_to_js_store_attr", "number", ["number", "string", "number"], [target._ref, prop, value_conv], ); Module._free(value_conv); return ret; }, deleteProperty(target, prop) { return Module.ccall( "proxy_c_to_js_delete_attr", "number", ["number", "string"], [target._ref, prop], ); }, }; // PyProxy of a Python generator, that implements the thenable interface. class PyProxyThenable { constructor(ref) { this._ref = ref; } then(resolve, reject) { const values = Module._malloc(3 * 3 * 4); proxy_convert_js_to_mp_obj_jsside(resolve, values + 3 * 4); proxy_convert_js_to_mp_obj_jsside(reject, values + 2 * 3 * 4); Module.ccall( "proxy_c_to_js_resume", "null", ["number", "pointer"], [this._ref, values], ); return proxy_convert_mp_to_js_obj_jsside_with_free(values); } } /* * This file is part of the MicroPython project, http://micropython.org/ * * The MIT License (MIT) * * Copyright (c) 2023-2024 Damien P. George * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ // Number of static entries at the start of proxy_js_ref. const PROXY_JS_REF_NUM_STATIC = 2; // These constants should match the constants in proxy_c.c. const PROXY_KIND_MP_EXCEPTION = -1; const PROXY_KIND_MP_NULL = 0; const PROXY_KIND_MP_NONE = 1; const PROXY_KIND_MP_BOOL = 2; const PROXY_KIND_MP_INT = 3; const PROXY_KIND_MP_FLOAT = 4; const PROXY_KIND_MP_STR = 5; const PROXY_KIND_MP_CALLABLE = 6; const PROXY_KIND_MP_GENERATOR = 7; const PROXY_KIND_MP_OBJECT = 8; const PROXY_KIND_MP_JSPROXY = 9; const PROXY_KIND_MP_EXISTING = 10; const PROXY_KIND_JS_UNDEFINED = 0; const PROXY_KIND_JS_NULL = 1; const PROXY_KIND_JS_BOOLEAN = 2; const PROXY_KIND_JS_INTEGER = 3; const PROXY_KIND_JS_DOUBLE = 4; const PROXY_KIND_JS_STRING = 5; const PROXY_KIND_JS_OBJECT = 6; const PROXY_KIND_JS_PYPROXY = 7; class PythonError extends Error { constructor(exc_type, exc_details) { super(exc_details); this.name = "PythonError"; this.type = exc_type; } } function proxy_js_init() { globalThis.proxy_js_ref = [globalThis, undefined]; globalThis.proxy_js_ref_next = PROXY_JS_REF_NUM_STATIC; globalThis.proxy_js_map = new Map(); globalThis.proxy_js_existing = [undefined]; globalThis.pyProxyFinalizationRegistry = new FinalizationRegistry( (cRef) => { globalThis.proxy_js_map.delete(cRef); Module.ccall("proxy_c_free_obj", "null", ["number"], [cRef]); }, ); } // Check if the c_ref (Python proxy index) has a corresponding JavaScript-side PyProxy // associated with it. If so, take a concrete reference to this PyProxy from the WeakRef // and put it in proxy_js_existing, to be referenced and reused by PROXY_KIND_MP_EXISTING. function proxy_js_check_existing(c_ref) { const existing_obj = globalThis.proxy_js_map.get(c_ref)?.deref(); if (existing_obj === undefined) { return -1; } // Search for a free slot in proxy_js_existing. for (let i = 0; i < globalThis.proxy_js_existing.length; ++i) { if (globalThis.proxy_js_existing[i] === undefined) { // Free slot found, put existing_obj here and return the index. globalThis.proxy_js_existing[i] = existing_obj; return i; } } // No free slot, so append to proxy_js_existing and return the new index. globalThis.proxy_js_existing.push(existing_obj); return globalThis.proxy_js_existing.length - 1; } // js_obj cannot be undefined function proxy_js_add_obj(js_obj) { // Search for the first free slot in proxy_js_ref. while (proxy_js_ref_next < proxy_js_ref.length) { if (proxy_js_ref[proxy_js_ref_next] === undefined) { // Free slot found, reuse it. const id = proxy_js_ref_next; ++proxy_js_ref_next; proxy_js_ref[id] = js_obj; return id; } ++proxy_js_ref_next; } // No free slots, so grow proxy_js_ref by one (append at the end of the array). const id = proxy_js_ref.length; proxy_js_ref[id] = js_obj; proxy_js_ref_next = proxy_js_ref.length; return id; } function proxy_call_python(target, argumentsList) { let args = 0; // Strip trailing "undefined" arguments. while ( argumentsList.length > 0 && argumentsList[argumentsList.length - 1] === undefined ) { argumentsList.pop(); } if (argumentsList.length > 0) { // TODO use stackAlloc/stackRestore? args = Module._malloc(argumentsList.length * 3 * 4); for (const i in argumentsList) { proxy_convert_js_to_mp_obj_jsside( argumentsList[i], args + i * 3 * 4, ); } } const value = Module._malloc(3 * 4); Module.ccall( "proxy_c_to_js_call", "null", ["number", "number", "number", "pointer"], [target, argumentsList.length, args, value], ); if (argumentsList.length > 0) { Module._free(args); } const ret = proxy_convert_mp_to_js_obj_jsside_with_free(value); if (ret instanceof PyProxyThenable) { // In Python when an async function is called it creates the // corresponding "generator", which must then be executed at // the top level by an asyncio-like scheduler. In JavaScript // the semantics for async functions is that they are started // immediately (their non-async prefix code is executed immediately) // and only if they await do they return a Promise to delay the // execution of the remainder of the function. // // Emulate the JavaScript behaviour here by resolving the Python // async function. We assume that the caller who gets this // return is JavaScript. return Promise.resolve(ret); } return ret; } function proxy_convert_js_to_mp_obj_jsside(js_obj, out) { let kind; if (js_obj === undefined) { kind = PROXY_KIND_JS_UNDEFINED; } else if (js_obj === null) { kind = PROXY_KIND_JS_NULL; } else if (typeof js_obj === "boolean") { kind = PROXY_KIND_JS_BOOLEAN; Module.setValue(out + 4, js_obj, "i32"); } else if (typeof js_obj === "number") { if (Number.isInteger(js_obj)) { kind = PROXY_KIND_JS_INTEGER; Module.setValue(out + 4, js_obj, "i32"); } else { kind = PROXY_KIND_JS_DOUBLE; // double must be stored to an address that's a multiple of 8 const temp = (out + 4) & ~7; Module.setValue(temp, js_obj, "double"); const double_lo = Module.getValue(temp, "i32"); const double_hi = Module.getValue(temp + 4, "i32"); Module.setValue(out + 4, double_lo, "i32"); Module.setValue(out + 8, double_hi, "i32"); } } else if (typeof js_obj === "string") { kind = PROXY_KIND_JS_STRING; const len = Module.lengthBytesUTF8(js_obj); const buf = Module._malloc(len + 1); Module.stringToUTF8(js_obj, buf, len + 1); Module.setValue(out + 4, len, "i32"); Module.setValue(out + 8, buf, "i32"); } else if ( js_obj instanceof PyProxy || (typeof js_obj === "function" && "_ref" in js_obj) || js_obj instanceof PyProxyThenable ) { kind = PROXY_KIND_JS_PYPROXY; Module.setValue(out + 4, js_obj._ref, "i32"); } else { kind = PROXY_KIND_JS_OBJECT; const id = proxy_js_add_obj(js_obj); Module.setValue(out + 4, id, "i32"); } Module.setValue(out + 0, kind, "i32"); } function proxy_convert_js_to_mp_obj_jsside_force_double_proxy(js_obj, out) { if ( js_obj instanceof PyProxy || (typeof js_obj === "function" && "_ref" in js_obj) || js_obj instanceof PyProxyThenable ) { const kind = PROXY_KIND_JS_OBJECT; const id = proxy_js_add_obj(js_obj); Module.setValue(out + 4, id, "i32"); Module.setValue(out + 0, kind, "i32"); } else { proxy_convert_js_to_mp_obj_jsside(js_obj, out); } } function proxy_convert_mp_to_js_obj_jsside(value) { const kind = Module.getValue(value, "i32"); let obj; if (kind === PROXY_KIND_MP_EXCEPTION) { // Exception const str_len = Module.getValue(value + 4, "i32"); const str_ptr = Module.getValue(value + 8, "i32"); const str = Module.UTF8ToString(str_ptr, str_len); Module._free(str_ptr); const str_split = str.split("\x04"); throw new PythonError(str_split[0], str_split[1]); } if (kind === PROXY_KIND_MP_NULL) { // MP_OBJ_NULL throw new Error("NULL object"); } if (kind === PROXY_KIND_MP_NONE) { // None obj = null; } else if (kind === PROXY_KIND_MP_BOOL) { // bool obj = Module.getValue(value + 4, "i32") ? true : false; } else if (kind === PROXY_KIND_MP_INT) { // int obj = Module.getValue(value + 4, "i32"); } else if (kind === PROXY_KIND_MP_FLOAT) { // float // double must be loaded from an address that's a multiple of 8 const temp = (value + 4) & ~7; const double_lo = Module.getValue(value + 4, "i32"); const double_hi = Module.getValue(value + 8, "i32"); Module.setValue(temp, double_lo, "i32"); Module.setValue(temp + 4, double_hi, "i32"); obj = Module.getValue(temp, "double"); } else if (kind === PROXY_KIND_MP_STR) { // str const str_len = Module.getValue(value + 4, "i32"); const str_ptr = Module.getValue(value + 8, "i32"); obj = Module.UTF8ToString(str_ptr, str_len); } else if (kind === PROXY_KIND_MP_JSPROXY) { // js proxy const id = Module.getValue(value + 4, "i32"); obj = proxy_js_ref[id]; } else if (kind === PROXY_KIND_MP_EXISTING) { const id = Module.getValue(value + 4, "i32"); obj = globalThis.proxy_js_existing[id]; globalThis.proxy_js_existing[id] = undefined; } else { // obj const id = Module.getValue(value + 4, "i32"); if (kind === PROXY_KIND_MP_CALLABLE) { obj = (...args) => { return proxy_call_python(id, args); }; obj._ref = id; } else if (kind === PROXY_KIND_MP_GENERATOR) { obj = new PyProxyThenable(id); } else { // PROXY_KIND_MP_OBJECT const target = new PyProxy(id); obj = new Proxy(target, py_proxy_handler); } globalThis.pyProxyFinalizationRegistry.register(obj, id); globalThis.proxy_js_map.set(id, new WeakRef(obj)); } return obj; } function proxy_convert_mp_to_js_obj_jsside_with_free(value) { const ret = proxy_convert_mp_to_js_obj_jsside(value); Module._free(value); return ret; } function python_index_semantics(target, index_in) { let index = index_in; if (typeof index === "number") { if (index < 0) { index += target.length; } if (index < 0 || index >= target.length) { throw new PythonError("IndexError", "index out of range"); } } return index; } ================================================ FILE: docs/midi.md ================================================ # AMY MIDI Mode AMY assigns `synth`s between 1 and 16 to MIDI channels and listens to MIDI messages on those synths. For example, to set up a MIDI channel with a Juno-6 patch, you simply do ```python amy.send(synth=1, patch_number=3, num_voices=5) ``` Where `num_voices` indicates the polyphony supported for that channel. AMY will handle note stealing and voice allocation. ## Note ons, offs, pitch bend, sustain AMY responds to [MIDI note ons](http://midi.teragonaudio.com/tech/midispec/noteon.htm) and [note offs.](http://midi.teragonaudio.com/tech/midispec/noteoff.htm) AMY responds to [MIDI pitch bend messages.](http://midi.teragonaudio.com/tech/midispec/wheel.htm) This does apply to every note played on the entire AMY instance. AMY responds to [MIDI sustain pedal messages.](http://midi.teragonaudio.com/tech/midispec/hold.htm) ## Control changes AMY will turn off all notes when receiving an [All Notes Off control change.](http://midi.teragonaudio.com/tech/midispec/ntnoff.htm) If you enable a [MIDI input hook](api.md) you can add more controller mappings. In the AMY source we provide [midi_mappings.c](../src/midi_mappings.c) with examples. The `juno_filter_midi_handler` assigns MIDI CC 70 to `filter_freq` and 71 to `resonance`. You probably want to make your own [MIDI input hook](api.md) to expand on this for your use cases. AMY responds to a so far small set of [MIDI CC changes](http://midi.teragonaudio.com/tech/midispec/ctl.htm) to apply to [CtrlCoefs](synth.md) on that channel. **TODO: fill this in** ## Program changes AMY responds to [MIDI program changes](http://midi.teragonaudio.com/tech/midispec/pgm.htm). Since program changes are limited to 0-127, right now, we only support switching within an AMY "bank" -- if a synth is setup for Juno-6 (0-127), you can only change between other Juno-6 patches. If a synth is setup for DX-7 (128-255), you can set any DX-7 patch. For example, to change a DX7 patch from 5 to 3, send a program change to that synth with `128+3 = 131`. **TODO: BANKS** ## SYSEX AMY can receive its [wire messages](api.md) over [SYSEX](http://midi.teragonaudio.com/tech/midispec/sysex.htm). Since wire messages are always in lower ASCII, you do not need to encode your wire message before sending it to AMY. Preface your wire message with AMY's SYSEX manufacturer code: `0x00 0x03 0x45`. For example, to send the wire message `v0f440l1` (sine wave, 440Hz, note on) to AMY over SYSEX, you'd send `0xF0 0x00 0x03 0x45 v 0 f 4 4 0 l 1 0xF7`. ## Others AMY supports MIDI realtime transport for the internal sequencer: - `0xF8` (Timing Clock): advances the sequencer from external clock input. - `0xFA` (Start): starts sequencer playback from tick 0 in external clock mode. - `0xFC` (Stop): stops sequencer playback. MIDI Timing Clock is 24 PPQ. AMY's sequencer runs at 48 PPQ, so AMY advances two sequencer ticks per one MIDI clock pulse. If you stop the sequencer with MIDI (using `0xFC`) the only way to start the sequencer again is with MIDI `0xFA`. We don't (yet) have AMY controls to stop / start the sequencer. ================================================ FILE: docs/minimal.html ================================================ Minimal AMY web synth example

Minimal AMY web synth example

Click anywhere on the page, and then play your selected MIDI input to this page. You can use program changes to change patches.

================================================ FILE: docs/piano.html ================================================ The AMY Additive Piano Voice

The AMY Additive Piano Voice

The piano is a versatile and mature instrument. One reason for its popularity is its wide timbral range; in fact, its main innovation was the ability to play notes both loud and soft, hence "Pianoforte" (its full original name).

To make AMY into a truly general-purpose music synthesizer, we wanted to add a good piano voice. But it's not simple to synthesize a good piano voice. This page explains some of what makes piano synthesis challenging, and how we addressed it. Our approach was to use additive synthesis, which nicely fills out the demonstration of the primary synthesis techniques implemented in AMY, after subtractive (the Juno-6 patches) and FM (the DX7 patches).

The sound of a piano

Here's an example of 5 notes played on a real piano:

uiowa

This clip starts with a D4 note played at three loudnesses - pp, mf, and ff. These are followed by a D2 (two octaves lower), and a D6 (two octaves higher). (I made this example by adding together isolated recordings of single piano notes from the University of Iowa Electronic Music Studios Instrument Samples, which are the basis of the AMY piano. I combined them with the code in make_piano_examples.ipynb.)

Some things to notice:

  • Piano sounds consist of very strong, stable sets of harmonics (fixed-frequency Fourier components), visible as horizontal lines in the spectrogram. The harmonics appear mostly uniformly-spaced (as expected for a Fourier series of a periodic signal) (although there are a few extra components e.g. around 4.5 kHz at 0.8 seconds for the ff D4).
  • Each harmonic starts at its peak amplitude, then decays away. The higher harmonics decay more quickly. Higher notes, whose harmonics are naturally all at higher frequencies, die away more quickly than lower notes.
  • The first three notes have the same pitch, so the harmonics have the same frequencies. However, as the note gets louder, not only do the lower harmonics grow in intensity (brighter color), we also see additional higher harmonics appearing. This is the vital "brightening" of piano sounds as the strike strength increases.
  • The D2 is too low for the harmonics to be resolved in this spectrogam, but we can see a complex pattern of time modulation in its energy. We can also see a complex pattern of per-harmonic modulations in the D6.

Synthesizing piano sounds

Electronic musical instruments have always taken inspiration from their acoustic forbears, and most electronic keyboards will attempt to simulate a piano.

Let's set up a function in AMY (which runs in this web page in Python, you can edit the code!) that plays the recorded pattern above on some AMY presets:

def piano_example(base_note=72, volume=1, send_command=amy.send, init_command=lambda: None): amy.send(time=100, volume=volume) init_command() send_command(time=150, voices='0', note=base_note, vel=0.05) send_command(time=535, voices='0', note=base_note, vel=0) send_command(time=550, voices='0', note=base_note, vel=0.63) send_command(time=935, voices='0', note=base_note, vel=0) send_command(time=950, voices='0', note=base_note, vel=1.0) send_command(time=1585, voices='0', note=base_note, vel=0) send_command(time=1600, voices='1', note=base_note - 24, vel=0.6) send_command(time=2200, voices='2', note=base_note + 24, vel=1.0) send_command(time=3100, voices='1', note=base_note - 24, vel=0) send_command(time=3100, voices='2', note=base_note + 24, vel=0)

The Roland Juno-60 included a preset called Piano, which we can now hear with

piano_example(base_note=74, volume=1, init_command=lambda: amy.send(time=0, voices='0,1,2', patch=7))

(Try changing the base_note or volume or the patch number and running again)

This synthetic piano gets the stable harmonic structure and steady decay of each note, but there's no change in timbre with the different note velocities; every harmonic gets louder by the same factor. (In fact, the Juno-60 was not velocity sensitive, but its usual practice to scale the whole note in proportion to velocity). There's no complexity to the harmonic decays, they are uniformly monotonic. And the overall note decay time doesn't vary with the pitch.

The DX7 similarly provides a number of presets claiming to be pianos, including 135-137 (in our numbering which starts at 128):

piano_example(base_note=50, volume=2, init_command=lambda: amy.send(time=0, voices='0,1,2', patch=137))

This sounds more like a DX7 than any acoustic instrument. It does manage to bring some modulation on top of the decays of the harmonics (visible as gaps in the horizontal lines) but is not very convincing.

Additive synthesis

The horizontal lines in the spectrogram are simply sinusoids at fixed frequencies with slowly-varying amplitudes; the essence of Fourier analysis is that any periodic signal can be built up by summing sinusoids at integer multiples of the fundamental frequency (the lowest sinusoid). We can use this directly to synthesize musical sounds, so-called "additive synthesis", and AMY was originally designed for this very purpose. We use one oscillator for each harmonic, and set up its amplitude envelope to be a copy of the corresponding harmonic in a real piano signal. (I wrote code to analyze the UIowa piano sounds into harmonic envelopes in piano_heterodyne.ipynb.)

Let's start by loading in the analysis. We're using ulab, which is a numpy-like written for Micropython (what this web page is using.)

"""Piano notes generated on amy/tulip.""" # Uses the partials amplitude breakpoints and residual written by piano_heterodyne.ipynb. from ulab import numpy as np # Read in the params file written by piano_heterodyne.ipynb # Contents: # sample_times_ms - single vector of fixed log-spaced envelope sample times (in int16 integer ms). # notes - the MIDI numbers corresponding to each note described. # velocities - The (MIDI) strike velocities available for each note, the same for all notes. # num_harmonics - Array of (num_notes * num_velocities) counts of how many harmonics are defined for each note+vel combination. # harmonics_freq - Vector of (total_num_harmonics) int16s giving freq for each harmonic in "MIDI cents" i.e. 6900 = 440 Hz. # harmonics_mags - Array of (total_num_harmonics, num_sample_times) uint8s giving envelope samples for each harmonic. In dB, between 0 and 100. from amy.piano_params import notes_params NOTES = np.array(notes_params['notes'], dtype=np.int8) VELOCITIES = np.array(notes_params['velocities'], dtype=np.int8) NUM_HARMONICS = np.array(notes_params['num_harmonics'], dtype=np.int16) assert len(NUM_HARMONICS) == len(NOTES) * len(VELOCITIES) NUM_MAGS = len(notes_params['harmonics_mags'][0]) # Add in a derived diff-times and start-harmonic fields # Reintroduce the initial zero-time... SAMPLE_TIMES = np.array([0] + notes_params['sample_times_ms']) #.. so we can neatly calculate the time-deltas needed for BP strings. DIFF_TIMES = SAMPLE_TIMES[1:] - SAMPLE_TIMES[:-1] # Lookup to find first harmonic for nth note. START_HARMONIC = np.zeros(len(NUM_HARMONICS), dtype=np.int16) for i in range(len(NUM_HARMONICS)): # No cumsum in ulab.numpy START_HARMONIC[i] = np.sum(NUM_HARMONICS[:i]) # We build a single array for all the harmonics with the frequency as the # first column, followed by the envelope magnitudes. Then, we can pull # out the entire description for a given note/velocity pair simply by # pulling out NUM_HARMONICS[harmonic_index] rows starting at # START_HARMONIC[harmonic_index] FREQ_MAGS = np.zeros((np.sum(NUM_HARMONICS), 1 + NUM_MAGS), dtype=np.int16) FREQ_MAGS[:, 0] = np.array(notes_params['harmonics_freq'], dtype=np.int16) FREQ_MAGS[:, 1:] = np.array(notes_params['harmonics_mags'], dtype=np.int16)

Now, let's set up some code to return the interpolated harmonics from a MIDI note and velocity for the piano.

def harms_params_from_note_index_vel_index(note_index, vel_index): """Retrieve a (log-domain) harms_params list for a given note/vel index pair.""" # A harmonic is represented as a [freq_cents, mag1_db, mag2_db, .. mag20_db] row. # A note is represented as NUM_HARMONICS (usually 20) rows. note_vel_index = note_index * len(VELOCITIES) + vel_index num_harmonics = NUM_HARMONICS[note_vel_index] start_harmonic = START_HARMONIC[note_vel_index] harms_params = FREQ_MAGS[start_harmonic : start_harmonic + num_harmonics, :] return harms_params def interp_harms_params(hp0, hp1, alpha): """Return harm_param list that is alpha of the way to hp1 from hp0.""" # hp_ is [[freq_h1, mag1, mag2, ...], [freq_h2, mag1, mag2, ..], ...] num_harmonics = min(hp0.shape[0], hp1.shape[0]) # Assume the units are log-scale, so linear interpolation is good. return hp0[:num_harmonics] + alpha * (hp1[:num_harmonics] - hp0[:num_harmonics]) def cents_to_hz(cents): """Convert 'Midi cents' frequency to Hz. 6900 cents -> 440 Hz""" return 440 * (2 ** ((cents - 6900) / 1200.0)) def db_to_lin(d): """Convert the db-scale magnitudes to linear. 0 dB -> 0.00001, so 100 dB -> 1.0.""" # Clip anything below 0.001 to zero. return np.maximum(0, 10.0 ** ((d - 100) / 20.0) - 0.001) def harms_params_for_note_vel(note, vel): """Convert midi note and velocity into an interpolated harms_params list of harmonic specifications.""" note = np.clip(note, NOTES[0], NOTES[-1]) vel = np.clip(vel, VELOCITIES[0], VELOCITIES[-1]) note_index = -1 + np.sum(NOTES[:-1] <= note) # at most the last-but-one value. strike_index = -1 + np.sum(VELOCITIES[:-1] <= vel) lower_note = NOTES[note_index] upper_note = NOTES[note_index + 1] note_alpha = (note - lower_note) / (upper_note - lower_note) lower_strike = VELOCITIES[strike_index] upper_strike = VELOCITIES[strike_index + 1] strike_alpha = (vel - lower_strike) / (upper_strike - lower_strike) # We interpolate to describe a note at both strike indices, # then interpolate those to get the strike. harms_params = interp_harms_params( interp_harms_params( harms_params_from_note_index_vel_index(note_index, strike_index), harms_params_from_note_index_vel_index(note_index + 1, strike_index), note_alpha, ), interp_harms_params( harms_params_from_note_index_vel_index(note_index, strike_index + 1), harms_params_from_note_index_vel_index(note_index + 1, strike_index + 1), note_alpha, ), strike_alpha, ) return harms_params

And then some AMY helper code to send out these parameters to the right voices. We're using the BYO_PARTIALS type in AMY, which allows you set up your own partial synthesis breakpoints using envelopes.

def init_piano_voice(num_partials, base_osc=0, **kwargs): """One-time initialization of the unchanging parts of the partials voices.""" amy.send(osc=base_osc, wave=amy.BYO_PARTIALS, num_partials=num_partials, amp={'eg0': 0}, **kwargs) for partial in range(1, num_partials + 1): bp_string = '0,0,' + ','.join("%d,0" % t for t in DIFF_TIMES) # We append a release segment to die away to silence over 200ms on note-off. bp_string += ',200,0' amy.send(osc=base_osc + partial, wave=amy.PARTIAL, bp0=bp_string, eg0_type=amy.ENVELOPE_TRUE_EXPONENTIAL, **kwargs) def setup_piano_voice(harms_params, base_osc=0, **kwargs): """Configure a set of PARTIALs oscs to play a particular note and velocity.""" num_partials = len(harms_params) amy.send(osc=base_osc, wave=amy.BYO_PARTIALS, num_partials=num_partials, **kwargs) for i in range(num_partials): f0_hz = cents_to_hz(harms_params[i, 0]) env_vals = db_to_lin(harms_params[i, 1:]) # Omit the time-deltas from the list to save space. The osc will keep the ones we set up in init_piano_voice. bp_string = ',,' + ','.join(",%.3f" % val for val in env_vals) # Add final release. bp_string += ',200,0' amy.send(osc=base_osc + 1 + i, freq=f0_hz, bp0=bp_string, **kwargs)

We can now set up a BYO_PARTIALS patch #1024 in AMY with independent per-harmonic envelopes. We set up the piano once, pre-configured to C4.mf for each note and scaled during playback. We're setting 20 breakpoints independently for 20 harmonics with data read from the piano-params.json file written by piano_heterodyne.ipynb.

patch_string = 'v0w10Zv%dw%dZ' % (NUM_HARMONICS[0] + 1, amy.PARTIAL) # The lowest note provides an upper-bound on the number of partials we need to allocate. def init_piano_voices(num_partials=NUM_HARMONICS[0]): amy.send(patch='1024', patch_string=patch_string) amy.send(voices='0,1,2', patch=1024) init_piano_voice(num_partials, voices='0,1,2') # piano_note_on (below) overwrites these settings before each note, # but pre-configure each note to C4.mf so we can experiment. setup_piano_voice(harms_params_for_note_vel(note=60, vel=80), voices='0,1,2')

And play those:

piano_example(base_note=62, volume=2, init_command=init_piano_voices)

fixed

The mf D4 note now sounds quite realistic, because it's a reasonably accurate reproduction of the original recording. However, we're still simply scaling its overall magnitude in to get different veloicities. And when we change the pitch, we just squeeze or stretch the harmonics (and hence the notes' spectral envelopes), which is not at all realistic sounding.

Instead, we need to interpolate the real piano recordings at different notes and strikes to get the actual envelopes we synthesize. The UIowa samples provide recordings of all 88 notes on the piano they sampled, at three strike strengths. We could include harmonic data for all of them, but adjacent notes are quite similar, so instead we encode 3 notes per octave (C, E, and Ab) and interpolate the 3 semitones between each adjacent pair. (We currently store only 7 octaves, C1 to Ab7, so 21 pitches).

For velocity, we have no choice but to interpolate, since the three recorded strikes do not provide enough expressivity for performance. We analyze all three (for each pitch stored, so 63 notes total).

Playing a note, then, involves interpolating between four of the stored harmonic envelope sets (recall that each set consists of 20 breakpoints for up to 20 harmonics): To synthesize the D4 at, say, velocity 90, we use C4 at mf and ff (which I interpreted as velocities 80 and 120) as well as E4 mf and ff. By doing this interpolation separately for every (note, velocity) event, we get a much richer range of tones. In this case we recompute the piano voice on each note on, given the note number and velocity:

def piano_note_on(note=60, vel=1, **kwargs): if vel == 0: # Note off. amy.send(vel=0, **kwargs) else: setup_piano_voice(harms_params_for_note_vel(note, round(vel * 127)), **kwargs) # We already configured the pitches and magnitudes in setup, so # the note and vel of the note-on are always the same. amy.send(note=60, vel=1, **kwargs)

Let's hear this much nicer version:

piano_example(base_note=62, init_command=init_piano_voices, send_command=piano_note_on)

interpolated

This recovers both the spectral complexity of the original piano notes, and the variation of the spectrum both across the keyboard range and across strike intensities. The spectrogram of the original recordings is repeated below for comparison.

uiowa

While there are plenty of details that have not been exactly preserved (most notably the noisy "clunk" visible around each onset of the recordings, but also the cutoff at 20 harmonics, which loses a lot of high-frequency for the low note), this synthesis just feels much, much more realistic and "acoustic" than any of the previous syntheses.

Because we are representing each note as an explicit set of harmonics, we can do things that would be very hard with, e.g., a sample. By messing with the status of the PARTIALs oscs, we can listen to each partial individually:

# Configure the default voice for C4.ff init_piano_voices() setup_piano_voice(harms_params_for_note_vel(64, 120), time=0, voices='0') # Convert each PARTIAL osc into regular SINE oscs and play them in order. for partial in range(1, 20): time = partial * 400 amy.send(time=time, voices='0', osc=partial, wave=amy.SINE, note=60, vel=1) amy.send(time=time + 390, voices='0', osc=partial, vel=0)

By restricting the number of partials the control osc things it is driving, we can listen to syntheses with different numbers of partials:

# Re-initialize the voice (after flipping the oscs into SINEs). init_piano_voices() setup_piano_voice(harms_params_for_note_vel(64, 120), time=0, voices='0') # Add partials one by one for num_partials in range(1, 20): time = num_partials * 400 amy.send(time=time, voices='0', wave=amy.BYO_PARTIALS, num_partials=num_partials) amy.send(time=time + 15, voices='0', note=60, vel=1) amy.send(time=8500, voices='0', vel=0)

We can also change the tuning of each harmonic away from what was provided by the analysis. For instance, we can retune them to have different inharmonicities (see below for a discussion of piano inharmonicity):

def retune_partials(f0=263.3, beta=0.0003, num_partials=20, **kwargs): for partial in range(1, num_partials + 1): amy.send(osc=partial, freq=partial * f0 * np.sqrt(1 + beta * partial * partial), **kwargs) init_piano_voices() # Try it for a low note setup_piano_voice(harms_params_for_note_vel(32, 120), voices='0', time=0) # Tuning from analysis amy.send(time=0, voices='0', note=60, vel=1) amy.send(time=2000, voices='0', vel=0) # Unstretched tuning retune_partials(f0=cents_to_hz(3200), beta=0, voices='0', time=2200) amy.send(time=2210, voices='0', note=60, vel=1) amy.send(time=4200, voices='0', vel=0) # Parametric stretching tuning, exaggerated retune_partials(f0=cents_to_hz(3200), beta=0.0008, voices='0', time=4400) amy.send(time=4410, voices='0', note=60, vel=1) amy.send(time=6400, voices='0', vel=0)

We can also do interesting things with interpolation. For instance, we can interpolate pitches more finely than the standard semitones:

init_piano_voices() hps_c4 = harms_params_for_note_vel(60, 120) hps_c5 = harms_params_for_note_vel(72, 120) for quarter_tone in range(24): time = quarter_tone * 400 hps_interpolated = interp_harms_params(hps_c4, hps_c5, quarter_tone / 24) setup_piano_voice(hps_interpolated, time=time, voices='0') amy.send(time=time + 10, voices='0', note=60, vel=1) amy.send(time=time + 500, voices='0', vel=0)

By using interpolation factors outside the range (0, 1) we can even extrapolate the strike strength:

init_piano_voices() hps_pp = harms_params_for_note_vel(60, 40) hps_ff = harms_params_for_note_vel(60, 120) for strike in range(5): time = strike * 400 strike_alpha = 0.4 * (strike - 1) # strike_alpha ranges from -0.4 to +1.2 hps_interpolated = interp_harms_params(hps_pp, hps_ff, strike_alpha) setup_piano_voice(hps_interpolated, time=time, voices='0') amy.send(time=time + 10, voices='0', note=60, vel=1) amy.send(time=time + 500, voices='0', vel=0)

If you're curious about exactly how we extracted the harmonic frequencies and envelopes, the rest of this page provides an overview of the process implemented in piano_heterodyne.ipynb.

If you have a Tulip or want to try Tulip on the web, you can play this piano synthesis live with a MIDI device. Use the Voices app to switch to the dpwe piano (256) patch, or type midi.config.add_synth(channel=1, patch_number=256, num_voices=4).

Extracting harmonic envelopes

How exactly to we capture the envelopes for each harmonic in our additive model? In principle, this is simply a matter of dissecting a spectrogram of the individual note (like the images above) to measure the intensity of each individual horizontal line. In practice, however, I wanted something with finer resolution in time and frequency to obtain very accurate parameters. I used heterodyne analysis, which I'll now explain.

The Fourier series expresses a periodic waveform as the sum of sinusoids at multiples of the fundamental frequency ("harmonics"), with the phases as amplitudes of each harmonic determining the resulting waveform. It's mathematically convenient to describe these sinusoids with complex exponentials, essentially sinusoids with two-dimensional values at each moment, where the real axis part is our regular sine, and the imaginary (2nd) axis part is the cosine (sine phase-shifted by 90 degrees):

1*t6wVEZv6CkhACEyY2pFe2A

Each sinusoid is constructed as the sum of a pair of complex exponentials with positive and negative frequencies; the imaginary parts cancel out leaving the real sinusoid. Thus, the full Fourier spectrum of a real signal has mirror-image positive and negative parts (although we generally only plot the positive half):

download-2

The neat thing about this complex-exponential Fourier representation is that multiplying a signal by a complex exponential is a pure shift in the Fourier spectrum domain. So, by multiplying by the complex exponential at the negative of a particular harmonic frequency, we can shift that harmonic down to 0 Hz (d.c.). The spectrum is no longer mirrored around zero, so the imaginary parts won't cancel out, but we only want its magnitude anyway. Then, by low-pass filtering (i.e., smoothing) that waveform, we can cancel out all the other harmonics leaving only the envelope of the one harmonic we are targeting. By smoothing over a window that exactly matches the fundamental period, we can exactly cancel all the other sinusoid components because they will complete a whole number of cycles in that period. See make_piano_examples.ipynb for how these figures were prepared:

download-1

download

Finding harmonic frequencies and piano inharmonicity

The heterodyne extraction allows us to extract sample-precise envelopes for harmonics at specific frequencies, but we need to give it the exact frequencies we want it to extract. Again, in principle, this is straightforward: The harmonics should occur at integer-multiples of the fundamental frequency, and if the piano is tuned right, we already know the fundamental frequences for each note.

It turns out, however, that piano notes are not perfectly harmonic: They can be well modeled as the sum of fixed-frequency sinusoids, but those sinusoids are not exact integer multiples of a common fundamental. This is a consequence of the stiffness of the steel strings (I'm told!) which makes the speed of wave propagation down the strings higher for higher harmonics. This piano inharmonicity has been credited with some of the "warmth" of piano sounds, and is something we want to preserve in our synthesis. In order to precisely extract each harmonic for each note, we need to individually estimate the inharmonicity coefficient for each string (because the strings are all different thicknesses, the inharmonicity varies across the range of the piano).

I estimated the inharmonicity by extracting very precise peak frequencies from a long Fourier transform of the piano note, then fitting the theoretical equation f n n 1 + B n 2 (from this StackExchange explanation) to those values.

download-4

download-5

These plots come from the "Inharmonicity estimation" part of piano_heterodyne.ipynb. Estimating the inharmonicity for each note allowed me to extract harmonic envelopes precisely corresponding to each specific harmonic of each piano note. This was important because when we are interpolating between different harmonic envelopes, we want to be sure we're looking at the same harmonic in both notes.

Describing envelopes

We can extract sample-accurate envelopes for as many harmonics as we want for each of the real piano note recordings we have. But to turn them into a practical additive-synthesis instrument on AMY we need to think about efficiency. Right now, the harmonic envelopes are represented as 44,100 values per second of recording, and we're modeling something like the first 5 seconds of each note (the low notes can easily be 20 seconds long before they decay into oblivion). But the AMY envelopes can only handle up to 24 breakpoints (it used to be 8 before I changed it to serve this project!) so we need some way to summarize the envelopes in a smaller number of straight-line segments (which is what the envelope breakpoints define).

Additive synthesis of individual harmonics is so powerful because sounds like piano notes are so well described by a small number of harmonics with constant or slowly-changing frequency and amplitude. Looking at the four harmonic envelopes extracted in the previous section, it's obvious that the long tails are almost entirely smooth and could be described with a small number of parameters. The initial portions are more complex, however, including going up and down. Reproducing them will need more breakpoints, and it's not immediately obvious how to choose those breakpoints to give the best approximation.

I spent a while trying to come up with ad-hoc algorithms to accurately match an arbitrary envelope with a few line segments - see the "Adaptive magnitude sampling" section of piano_heterodyne.ipynb. The goal was to choose breakpoint times (and values) that preserved the most detail of the original envelope, even though I couldn't define exactly what I wanted. However, the outcome was naturally that there would be different breakpoint times for each note, which made interpolation between different notes very problematic - can we interpolate the breakpoint times too? (I tried it, and it fared badly in practice because of wildly varying allocations of breakpoints to different time regions).

In the end I gave up and used a much simpler strategy of predefining a set of breakpoint sample times that are constant for all notes. Although this is inevitably sub-optimal for any given note, it gives a much more solid foundation for interpolating between notes. And it turns out that the accuracy lost in modeling the envelopes doesn't seem to be too important perceptually. To respect the idea that the envelopes have an initial period of considerable detail, followed by a longer, smoother evolution, I used exponential spacing of the sampling times. Specifically each envelope is described by samples at 20 instants: 4, 8, 12, 16, 24, 32, 48, 64, 96, 128, 192, 256, 384, 512, 768, 1024, 1536, 2048, 3072, 4096 milliseconds after onset. After the initial value, these are in a pattern of 2 n and 1.5 2 n milliseconds, giving the exponential spacing. This plot shows the original envelope with the breakpoint approximation superimposed, on two timescales - the first 150 msec on the left, and the full 4.1 sec on the right (with the 150 msec edge of the left plot shown as a dotted line).

Although a bunch of detail has been lost, it still provides a suitably complex character to the resyntheses.

These 20 envelope samples, along with the measured center frequency, are then the description for each of the up-to 20 harmonics describing each of the (7 octaves x 3 chroma x 3 strike strengths) notes, or about 1200 envelopes total. This is the data stored in piano-params.json and read by tulip_piano.py.

This is a lot of data to get your head around! It's 4 dimensional - envelope magnitude as a function of time, harmonic number, fundamental pitch, and strike strength. There's still a lot of investigation to be done, but here's a 3D plot of the modeled harmonic envelopes (up to harmonic 20) for the three different strike strengths of C4 (261.63 Hz):

We can see the trend of energy dropping off with harmonic number in every case, and the harmonic magnitudes getting larger for stronger strikes. But notice also that while the max magnitude of the first harmonic (purple) increases from 85 dB for _pp_ to 110 dB for _ff_ (about 25 dB), the max energy of the 20th harmonic (red) increases from under 20 dB to over 60 dB - maybe a 45 dB increase. This is the relative "brightening" of the timbre for louder notes.

If you have a Tulip or want to try Tulip on the web, you can play this piano synthesis live with a MIDI device. Use the Voices app to switch to the dpwe piano (256) patch, or type midi.config.add_synth(channel=1, patch_number=256, num_voices=4).


DAn Ellis - dan.ellis@gmail.com

Want more? Try Tulip

Run more AMY experiments in a REPL with Tulip for the Web. Try the piano there!

Discord

Join the shore pine sound systems Discord to chat about Tulip, AMY and Alles. A fun small community!

Github

Check out the AMY Github page for issues, discussions and the code.

Join our email list

We'll send you very rare updates about Tulip, Alles, AMY and other projects we're working on.

================================================ FILE: docs/repl.html ================================================ AMY JavaScript REPL

AMY JavaScript REPL

Write JavaScript using amy_send() to control AMY synthesis in your browser. Back to examples

Click here to start audio
Quick reference: amy_send({osc: 0, wave: AMY.SINE, freq: 440, vel: 1}) — See the JS API docs and parameter reference.
Scratch pad
================================================ FILE: docs/server.py ================================================ #!/usr/bin/env python # Attribution: https://stackoverflow.com/questions/21956683/enable-access-control-on-simple-http-server try: # Python 3 from http.server import HTTPServer, SimpleHTTPRequestHandler, test as test_orig import sys def test (*args): test_orig(*args, port=int(sys.argv[1]) if len(sys.argv) > 1 else 8000) except ImportError: # Python 2 from BaseHTTPServer import HTTPServer, test from SimpleHTTPServer import SimpleHTTPRequestHandler class CORSRequestHandler (SimpleHTTPRequestHandler): def end_headers (self): self.send_header('Access-Control-Allow-Origin', '*') self.send_header('Cross-Origin-Embedder-Policy', 'require-corp') self.send_header('Cross-Origin-Opener-Policy', 'same-origin') SimpleHTTPRequestHandler.end_headers(self) if __name__ == '__main__': test(CORSRequestHandler, HTTPServer) ================================================ FILE: docs/style.css ================================================ body { font-family: Helvetica, Arial, sans-serif; margin:10px; /* display: flex; flex-direction: column; justify-content: center; align-items: center; background: #22475e; padding: 0.25rem 1rem; */ } * { box-sizing:border-box } ul { height:18.875em; width:34em; margin:5em auto; padding:3em 0 0 3em; position:relative; border:1px solid #160801; border-radius:1em; background:linear-gradient(to bottom right,rgba(0,0,0,0.3),rgba(0,0,0,0)),url(vwood.png); box-shadow:0 0 50px rgba(0,0,0,0.5) inset,0 1px rgba(212,152,125,0.2) inset,0 5px 15px rgba(0,0,0,0.5) } li { margin:0; padding:0; list-style:none; position:relative; float:left } ul .white { height:16em; width:4em; z-index:1; border-left:1px solid #bbb; border-bottom:1px solid #bbb; border-radius:0 0 5px 5px; box-shadow:-1px 0 0 rgba(255,255,255,0.8) inset,0 0 5px #ccc inset,0 0 3px rgba(0,0,0,0.2); background:linear-gradient(to bottom,#eee 0%,#fff 100%) } ul .white:active { border-top:1px solid #777; border-left:1px solid #999; border-bottom:1px solid #999; box-shadow:2px 0 3px rgba(0,0,0,0.1) inset,-5px 5px 20px rgba(0,0,0,0.2) inset,0 0 3px rgba(0,0,0,0.2); background:linear-gradient(to bottom,#fff 0%,#e9e9e9 100%) } .black { height:8em; width:2em; margin:0 0 0 -1em; z-index:2; border:1px solid #000; border-radius:0 0 3px 3px; box-shadow:-1px -1px 2px rgba(255,255,255,0.2) inset,0 -5px 2px 3px rgba(0,0,0,0.6) inset,0 2px 4px rgba(0,0,0,0.5); background:linear-gradient(45deg,#222 0%,#555 100%) } .black:active { box-shadow:-1px -1px 2px rgba(255,255,255,0.2) inset,0 -2px 2px 3px rgba(0,0,0,0.6) inset,0 1px 2px rgba(0,0,0,0.5); background:linear-gradient(to right,#444 0%,#222 100%) } .a,.g,.f,.d,.c { margin:0 0 0 -1em } ul li:first-child { border-radius:5px 0 5px 5px } ul li:last-child { border-radius:0 5px 5px 5px } /* h1, h2 { font-family: 'Quicksand', Helvetica, Sans-serif; background-color:#D90268; padding:0.5em; margin:0; color:white; } */ #startStop { text-align: center; border-radius: 0.5em; padding: 0.75em; color:white; font-weight: 400; text-decoration: none; background-color: #D90268; } #startStop:hover { background-color: black; } img { width: 100px; } #content { padding: 0.5em; } #footer { width: 100%; text-align: center; } .seqrow { display: flex; } .seqtitle { width:10px; } .LEDTitle { width:10px; } .LEDrow { display: flex; } .LED { border: 0.5px solid gray; border-radius: 2px; width: 16px; height: 10px; margin: 1.7px; background: lightgray; } ================================================ FILE: docs/synth.md ================================================ # AMY Synthesizer Details [**Please see our interactive AMY tutorial for more tips on using AMY**](https://shorepine.github.io/amy/tutorial.html) - [AMY Synthesizer Details](#amy-synthesizer-details) * [Oscillators, voices, patches and synths](#oscillators--voices--patches-and-synths) + [User patches](#user-patches) + [Synths](#synths) * [CtrlCoefficients](#ctrlcoefficients) * [AMY's sequencer and timestamps](#amy-s-sequencer-and-timestamps) + [The sequencer](#the-sequencer) * [Core oscillators](#core-oscillators) * [LFOs & modulators](#lfos---modulators) * [Filters](#filters) * [EQ & Volume](#eq---volume) * [Envelope Generators](#envelope-generators) * [Audio input and effects](#audio-input-and-effects) * [FM & ALGO type](#fm---algo-type) * [Build-your-own Partials](#build-your-own-partials) * [Interpolated partials](#interpolated-partials) * [PCM and Sampler](#pcm-and-sampler) ## Oscillators, voices, patches and synths Here's a diagram of how AMY manages oscillators, and synths. This is an example of a six polyphony Juno-6 synth. Each voice represents one unit of polyphony, and the 5 oscillators that are needed to make up the voice. The synth manages 6 voices: AMY's lowest level of control is the `osc`illator - a single waveform that you can define a number of parameters for, apply filters, frequency, pan, etc. By default AMY ships with support for 180 oscillators running at once. (You can increase this with [`amy_config`](api.md).) We then provide `voices`, to make it easier to configure and use groups of oscillators in coordination. For example, each Juno-6 note is generated by a single voice made from 5 oscillators. You then manage a set of `voices` using a `synth`, which takes care of allocating available voices to successive notes. For example a Juno-6 synth can play 6 notes of a patch at once. The `synth` in AMY allocates 6 `voices`, each with 5 `osc`, and handles note stealing and parameter changes. You configure the `voices` in a `synth` by using a `patch`, which is a number referring to a stored list of AMY commands that set up one or more oscillators. You can assign any patch to any synth, or set up multiple synths to have the same patch, and AMY will allocate the oscillators it needs under the hood. (Note that when you use voices/synths, you'll need to include the `synth` arg when addressing oscillators, and AMY will automatically route your command to the relevant oscillators in each voice of the synth's set -- there's no other way to tell which oscillators are being used by which voices.) To play a patch -- for instance the built-in patches emulating Juno and DX7 synthesizers and a piano -- you create a synth configured with that patch, then send note events, or parameter moidifications, to the synth. We ship patches 0-127 for Juno, 128-255 for DX7, and 256 for our [built-in piano](https://shorepine.github.io/amy/piano.html). For example, a multitimbral Juno/DX7 synth can be set up like this: ```python amy.send(synth=1, num_voices=4, patch=1) # 4 voices of Juno patch #1 on synth 1 amy.send(synth=2, num_voices=4, patch=129) # 4 voices of DX7 patch #2 on synth 2 amy.send(synth=1, note=60, vel=1) # Play note 60 on one of the Juno voices amy.send(synth=1, osc=0, filter_freq=8000) # Open up the filter on the Juno voices # (Juno patches implement the VCF on osc 0) ``` The code in `amy/headers.py` generates these patches and bakes them into AMY so they're ready for playback on any device. You can add your own patches at compile time by storing alternative wire-protocol setup strings in `patches.h`, or by making user patches at runtime (see [User patches](#user-patches) below). ### Synths A common use-case is to want a pool of voices which are allocated to a series of notes as-needed. This is accomplished with **synths**. You associate a synth number with a set of voices by providing the patch number when initializing the synth; the `synth` arg becomes a smart alias for passing note events to one of its voices (or configuration changes to all of them), e.g. ```python amy.send(synth=0, num_voices=3, patch=1) # 3-voice Juno patch #1 on synth 0 # Play three notes simultaneously amy.send(synth=0, note=60, vel=1) amy.send(synth=0, note=64, vel=1) amy.send(synth=0, note=67, vel=1) # To play a 4th note, the synth 'steals' the oldest voice, i.e. the one that was playing note 60 amy.send(synth=0, note=70, vel=1) # We can send note-offs to individual notes amy.send(synth=0, note=70, vel=0) # .. or we can send note-offs to all the currently-active synth voices by sending a note-off with no note. amy.send(synth=0, vel=0) # Once a synth has been initialized and associated with a set of voices, you can use it alone with patch amy.send(synth=0, patch=13) # Load a different Juno patch, it will remain 4-voice. # You can release all the voices/oscs being used by a synth by setting its num_voices to zero. amy.send(synth=0, num_voices=0) # As a special case, you can use `synth_flags` to set up a MIDI drum synth # that will translate note events into PCM presets. # You can also use `patch_string` to directly define a patch using a wire-command string. amy.send(synth=10, num_voices=3, patch_string='w7f0Z', synth_flags=3) amy.send(synth=10, note=40, vel=1) # MIDI drums 'electric snare' ``` (Note: Although `note` can take on real values -- e.g. `note=60.5` for 50 cents above C4 -- the voice management tracks voices by integer note numbers (i.e., midi notes) so it rounds note values to the nearest integer when deciding which note-off goes with which note-on. Note also that note-on events that also set the `preset` parameter (e.g. to select PCM samples) will fold the patch number into the note integer used as the key for note-on, note-off matching.) ### User patches You can create your own patches at runtime and use them for synths with a sequence of `amy.send(patch=PATCH_NUMBER, )` where `PATCH_NUMBER` is a number in the range 1024-1055. Without `patch=PATCH_NUMBER`, this command would directly configure an oscillator, but when `patch` is present, it instead appends the command to the stored patch configuration. You can accumulate any number of commands into a single patch; you reset the patch with `amy.send(patch=PATCH_NUMBER, reset=amy.RESET_PATCH)`. So you can do: ```python >>> import amy; amy.live() # Not needed on Tulip. >>> amy.send(patch=1024, reset=amy.RESET_PATCH) >>> amy.send(patch=1024, osc=1, wave=amy.SINE, freq=0.25, phase=0.5, amp=0.5) # "Pitch sigh" modulator. >>> amy.send(patch=1024, osc=0, wave=amy.SINE, freq='440,1,0,0,0,1', bp0='0,1,500,0,0,0', mod_source=1) # decaying sine modulated by sigh. >>> amy.send(synth=0, num_voices=1, patch=1024) >>> amy.send(synth=0, vel=2, note=50) ``` AMY infers the number of oscs needed for the patch from the cumulated commands. If you store a new patch over an old one, that old memory is freed and re-allocated. (We rely on `malloc` for all of this.) You can do something very similar directly into a synth, provided it has been initialized with the correct number of oscs. So we could get the same final synth as above with these commands: ```python >>> amy.send(synth=0, num_voices=1, oscs_per_voice=2) # We will be using 2 oscs per voice. >>> amy.send(synth=0, osc=1, wave=amy.SINE, freq=0.25, phase=0.5, amp=0.5) # "Pitch sigh" modulator. >>> amy.send(synth=0, osc=0, wave=amy.SINE, freq='440,1,0,0,0,1', bp0='0,1,500,0,0,0', mod_source=1) # decaying sine modulated by sigh. >>> # Ready to play! >>> amy.send(synth=0, vel=2, note=50) ``` ## Control Coefficients On many synths (like this SH-101), you'll see a row of sliders that impact which control signal(s) can modify a parameter. Here the SH-101 lets you control the VCF (filter) by a constant frequency (FREQ), ADSR envelope (ENV), LFO or mod wheel (MOD), and keyboard velocity (KYBD). These slider values impact the ratio of each source's strength in the output filter frequency. We use this style of control in AMY, called `CtrlCoef` or Control Coefficients. They are a list of up to 9 floats that are multiplied by a range of control signals, then summed up to give the final result (in this case, the filter frequency). The full set of parameters accepting **ControlCoefficients** is `amp`, `freq`, `filter_freq`, `duty`, and `pan`. The control signals are: * `const`: A constant value of 1 - so the first number in the control coefficient list is the default value if all the others are zero. * `note`: The frequency corresponding to the `note` parameter to the note-on event (converted to unit-per-octave relative to middle C). * `vel`: The velocity, from the note-on event. * `eg0`: The output of Envelope Generator 0. * `eg1`: The output of Envelope Generator 1. * `mod`: The output of the modulating oscillator, specified by the `mod_source` parameter. * `bend`: The current pitch bend value (from `amy.send(pitch_bend=0.5)` etc.). * `ext0`: An external parameter, [set by your code](api.md) or 3rd party CV input or sensor * `ext1`: An external parameter, [set by your code](api.md) or 3rd party CV input or sensor The set `50,0,0,0,1` means that we have a base frequency of 50 Hz, we ignore the note frequency and velocity and EG0, but we also add the output of EG1. Any coefficients that you do not specify, for instance by providing fewer than 7 values, are not modified. You can also use empty strings to skip positional values, so `filter_freq=',,,,1'` couples EG1 to the filter frequency without changing any of the other coefficients. (Note that when we passed `freq=220` in the first example, that was interpreted setting the `const` coefficient to 220, but leaving all the remaining coefficients untouched.) Because entering lists of commas is error prone, you can also specify control coefficients as Python dicts consisting of value with keys from the list above, i.e. `filter_freq={'const': 50, 'eg1': 1}` is equivalent to `filter_freq='50,,,,1'`. You can use the same EG to control several things at once. For example, we could include `freq=',,,,0.333'`, which says to modify the note frequency from the same EG1 as is controlling the filter frequency, but scaled down by 1/3rd so the initial decay is over 1 octave, not 3. Give it a go! The note frequency is scaled relative to a zero-point of middle A (MIDI note 69, 440 Hz), so to make the oscillator faithfully track the `note` parameter to the note-on event, you would use something like `freq='440,1'`. Setting it to `freq='880,1'` would make the oscillator always be one octave higher than the `note` MIDI number. Setting `freq='440,0.5'` would make the oscillator track the `note` parameter at half an octave per unit, so while `note=69` would still give middle A, `note=81` (A5) would make the oscillator run at D#5, and `note=93` (A6) would be required to get A5 from the oscillator. The default set of ControlCoefficients for `freq` is `'440,1,0,0,0,0,1'`, i.e. a base of middle A, tracking the MIDI note, plus pitch bend (at unit-per-octave). Because 440 is such an important value, as a special case, setting the first `freq` value to zero is magically rewritten as 440, so `freq='0,1,0,0,0,0,1'` also yields the default behavior. `amp` also has a set of defaults: `amp='0,0,1,1,0,0,0'`, i.e. tracking note-on velocity plus modulation by EG0 (which just tracks the note-on status if it has not been set up). `amp` is a little special because the individual components are *multiplied* together, instead of added together, for any control inputs with nonzero coefficients. Finally, an offset of 1.0 is added to the coefficient-scaled LFO modulator and pitch bend inputs before multiplying them into the amplitude, to allow small variations around unity e.g. for tremolo. These defaults are set up in [`src/amy.c:reset_osc()`](https://github.com/shorepine/amy/blob/b1ed189b01e6b908bc19f18a4e0a85761d739807/src/amy.c#L551). We also have LFOs, which are implemented as one oscillator modulating another (instead of sending its waveform to the output). You set up the low-frequency oscillator, then have it control a parameter of another audible oscillator. Let's make the classic 8-bit duty cycle pulse wave modulation, a favorite: ```python amy.reset() # Clear the state. amy.send(osc=1, wave=amy.SINE, freq=0.5, amp=1) # We set the amp but not the vel, so it doesn't sound. amy.send(osc=0, wave=amy.PULSE, duty={'const': 0.5, 'mod': 0.4}, mod_source=1) amy.send(osc=0, note=60, vel=0.5) ``` You see we first set up the modulation oscillator (a sine wave at 0.5Hz, with amplitude of 1). We do *not* send it a velocity, because that would make it start sending a 0.5 Hz sinewave to the audio output; we want its output only to be used internally. Then we set up the oscillator to be modulated, a pulse wave with a modulation source of oscillator 1 and the duty **ControlCoefficients** set to have a constant value of 0.5 plus 0.4 times the modulating input (i.e., the depth of the pulse width modulation, where 0.4 modulates between 0.1 and 0.9, almost the maximum depth). The initial duty cycle will start at 0.5 and be offset by the state of oscillator 1 every tick, to make that classic thick saw line from the C64 et al. The modulation will re-trigger every note on. Just like with envelope generators, the modulation oscillator has a 'slot' in the ControlCoefficients - the 6th coefficient, `mod` - so it can modulate PWM duty cycle, amplitude, frequency, filter frequency, or pan! And if you want to modulate more than one thing, like frequency and duty, just specify multiple ControlCoefficients: ```python amy.send(osc=1, wave=amy.TRIANGLE, freq=5, amp=1) amy.send(osc=0, wave=amy.PULSE, duty={'const': 0.5, 'mod': 0.25}, freq={'mod': 0.5}, mod_source=1) amy.send(osc=0, note=60, vel=0.5) ``` We have some helpful patches in `amy.examples`, if you want to use them, or add to them. To make that filter bass, just do `amy.send(synth=0, num_voices=4, patch=amy.examples.filter_bass())` and then `amy.send(synth=0,vel=1,note=50)` to hear it. ## AMY's sequencer and timestamps AMY can accept a `time` (in milliseconds) parameter to schedule events in the future, and also provides a pattern sequencer for repeating events. The scheduled events are very helpful in cases where you can't rely on an accurate clock from the client, or don't have one. The clock used internally by AMY is based on the audio samples being generated out the speakers, which should run at an accurate 44,100 times a second. This lets you do things like schedule fast moving parameter changes over short windows of time. ```python start = amy.millis() # arbitrary start timestamp amy.send(osc=0, note=50, vel=1, time=start) amy.send(osc=0, note=52, vel=1, time=start + 1000) ``` Both `amy.send()`s will return immediately, but you'll hear the second note play precisely a second after the first. AMY uses this internal clock to schedule step changes in breakpoints as well. ### The sequencer AMY starts a musical sequencer that works on `ticks` from startup. You can reset the `ticks` to 0 with an `amy.send(reset=amy.RESET_TIMEBASE)`. Note this will happen immediately, ignoring any `time` or `sequence`. Ticks run at 48 PPQ at the set tempo. The tempo defaults to 108 BPM. This means there are 108 quarter notes a minute, and `48 * 108 = 5184` ticks a minute, 86 ticks a second. The tempo can be changed with `amy.send(tempo=120)`. You can schedule an event to happen at a precise tick with `amy.send(... ,sequence="tick,period,tag")`. `tick` can be an absolute or offset tick number. If `period` is ommited or 0, `tick` is assumed to be absolute and once AMY reaches `tick`, the rest of your event will play and the saved event will be removed from memory. If an absolute `tick` is in the past, AMY will ignore it. You can schedule repeating events (like a step sequencer or drum machine) with `period`, which is the length of the sequence in ticks. For example a `period` of 48 with `ticks` omitted or 0 will trigger once every quarter note. A `period` of 24 will happen twice every quarter note. A `period` of 96 will happen every two quarter notes. `period` can be any whole number to allow for complex rhythms. For pattern sequencers like drum machines, you will also want to use `tick` alongside `period`. If both are given and nonzero, `tick` is assumed to be an offset on the `period`. For example, for a 16-step drum machine pattern running on eighth notes (PPQ/2), you would use a `period` of `16 * 24 = 384`. The first slot of the drum machine would have a `tick` of 0, the 2nd would have a `tick` offset of 24, and so on. `tag` should be given, and will be `0` if not. You should set `tag` to a random or incrementing number in your code that you can refer to later. `tag` allows you to replace or delete the event once scheduled. If you are including AMY in a program, you can set the [hook `void (*amy_external_sequencer_hook)(uint32_t)`](docs/api.md) to any function. This will be called at every tick with the current tick number as an argument. ## Core oscillators We support bandlimited saw, pulse/square and triangle waves, alongside sine and noise. Use the wave parameter: 0=SINE, PULSE, SAW_DOWN, SAW_UP, TRIANGLE, NOISE. Each oscillator can have a frequency (or set by midi note), amplitude and phase (set in 0-1.). You can also set `duty` for the pulse type. We also have a karplus-strong type (KS=6), plus `WAVETABLE` when compiled with `AMY_WAVETABLE` that plays back 16,384 sample long wavetable packs, such as those hosted on [waveeditonline.com](http://waveeditonline.com). Oscillators will not become audible until a `velocity` over 0 is set for the oscillator. This is a "note on" and will trigger any modulators or envelope generators set for that oscillator. Setting `velocity` to 0 sets a note off, which will stop modulators and also finish the envelopes at their release pair. `velocity` also internally sets `amplitude`, but you can manually set `amplitude` after `velocity` starts a note on. ### WAVETABLE `WAVETABLE` reads from wavetable presets appended to tiny PCM data at build time (guarded by `#if defined(AMY_WAVETABLE)`). - Pick the table with `preset`: `pcm_wavetable_base` to `pcm_wavetable_base + pcm_wavetable_samples - 1` - `duty` controls interpolation position across the 64 waveform cycles within one wavetable preset. - Internally each cycle is 256 samples; full table length is typically 16384 samples. - You can load new wavetables using `load_sample` and use your new preset number. Ensure they are 16,384 samples long. Find more on [waveeditonline.com](http://waveeditonline.com). ## LFOs & modulators Any oscillator can modulate any other oscillator. For example, a LFO can be specified by setting oscillator 0 to 0.25Hz sine, with oscillator 1 being a 440Hz sine. Using the 6th parameter of **ControlCoefficient** lists, you can have oscillator 0 modulate frequency, amplitude, filter frequency, or pan of oscillator 1. You can also add targets together, for example amplitude+frequency. Set the `mod_target` and `mod_source` on the audible oscillator (in this case, oscillator 1.) The source mod oscillator will not be audible once it is referred to as a `mod_source` by another oscillator. The amplitude of the modulating oscillator indicates how strong the modulation is (aka "LFO depth.") ## Filters We support lowpass, bandpass and hipass filters in AMY. You can set `resonance` and `filter_freq` per oscillator. ## EQ & Volume You can set a synth-wide volume (in practice, 0-10), or set the EQ of the entire synths's output. ## Envelope Generators AMY allows you to set 2 Envelope Generators (EGs) per oscillator. You can see these as ADSR / envelopes (and they can perform the same task), but they are slightly more capable. Breakpoints are defined as pairs of time deltas (specified in milliseconds) and target value. You can specify up to 8 pairs, but the last pair you specify will always be seen as the "release" pair, which doesn't trigger until note off. All preceding pairs have time deltas relative to the previous segment, so `100,1,100,0,0,0` goes up to 1 over 100 ms, then back down to zero over the next 100ms. The last "release" pair counts from ms from the note-off. An EG can control amplitude, frequency, filter frequency, duty or pan of an oscillator via the 4th (EG0) and 5th (EG1) entries in the corresponding ControlCoefficients. For example, to define a common ADSR curve where a sound sweeps up in volume from note on over 50ms, then has a 100ms decay stage to 50% of the volume, then is held until note off at which point it takes 250ms to trail off to 0, you'd set time to be 50ms and target to be 1.0, then 100ms with target .5, then a 250ms release with ratio 0. By default, amplitude is set up to be controlled by EG0. At every synthesizer tick, the given amplitude (default of 1.0) will be multiplied by the EG0 value. In AMY wire parlance, this would look like `v0f220w0A50,1.0,100,0.5,250,0` to specify a sine wave at 220Hz with this envelope. When using `amy.py`, use the string form of the breakpoint: `amy.send(osc=0, bp0='50,1.0,100,0.5,250,0')`. Every note on (specified by setting `vel` / `l` to anything > 0) will trigger this envelope, and setting velocity to 0 will trigger the note off / release section. You can set a completely separate envelope using the second envelope generator, for example, to change pitch and amplitude at different rates. As with ControlCoefficients, missing values in the comma-separated parameter strings mean to leave the existing value unchanged. However, unlike ControlCoefficients, it's important to explicitly indicate every value you want to leave unchanged, since the number of parameters provided determines the number of breakpoints in the set. So in the following sequence: ``` amy.send(osc=0, bp0='0,1,1000,0.1,200,0') amy.send(osc=0, bp0=',,,0.9,,') ``` .. we end up with the same effect as `bp0='0,1,1000,0.9,200,0`. However, if we do: ``` amy.send(osc=0, bp0='0,1,1000,0.1,200,0') amy.send(osc=0, bp0=',,,0.9') # No trailing commas. ``` .. we effectively end up with `bp0='0,1,1000,0.9`, i.e. the 4 elements in the second `bp0` string change the first breakpoint set to have only 2 breakpoints, meaning a constant amplitude during note-on, then a final slow release to 0.9 -- not at all like the first form, and likely not what we wanted. ## Audio input and effects By setting `wave` to `AUDIO_IN0` or `AUDIO_IN1`, you can have either channel of a stereo input act as an AMY oscillator. You can use this oscillator like you would any other in AMY, apply global effects to it, add filters, change amplitude, etc. ``` amy.send(osc=0, wave=amy.AUDIO_IN0, vel=1) amy.echo(1, 250, 250, 0.5, 0.5) ``` If you are building your own audio system around AMY you will want to fill in the buffer `amy_in_block` before rendering. Our included `miniaudio`-based system does this for you. See [`amychip`](https://github.com/shorepine/amychip) for a demo of this in hardware. ## FM & ALGO type Try default DX7 patches, from 128 to 256: ```python amy.send(synth=0, num_voices=1, patch=128) # Set up a voice. amy.send(synth=0, note=50, vel=1) # Play a note on the voice. ``` The `patch` lets you set which preset is used (0 to 127 are the Juno 106 analog synth presets, and 128 to 255 are the DX7 FM presets). But let's make the classic FM bell tone ourselves, without a patch. We'll just be using two operators (two sine waves), one modulating the other. ![DX7 Algorithms](https://raw.githubusercontent.com/shorepine/alles/main/pics/dx7_algorithms.jpg) When building your own algorithm sets, assign a separate oscillator as wave=`ALGO`, but the source oscillators as `SINE`. The algorithm #s are borrowed from the DX7. You don't have to use all 6 operators. Note that the `algo_source` parameter counts backwards from operator 6. When building operators, they can have their frequencies specified directly with `freq` or as a ratio of the root `ALGO` oscillator via `ratio`. [**Please see our interactive AMY tutorial for more on setting up ALGO tones**](https://shorepine.github.io/amy/tutorial.html#fm-tones) ## Build-your-own Partials You can also explicitly control partials in "build-your-own partials" mode, accessed via `wave=amy.BYO_PARTIALS`. This sets up a string of oscs as individual sinusoids, but it's up to you to control the details of each partial via its parameters, envelopes, etc. You just have to say how many partials you want with `num_partials`. You can then individually set up the amplitude `bp0` envelopes of the next `num_partials` oscs for arbitrary control, subject to the limit of 7 breakpoints plus release for each envelope. For instance, to get an 8-harmonic pluck tone with a 50 ms attack, and harmonic weights and decay times inversely proportional to to the harmonic number: ```python num_partials = 8 amy.send(osc=0, wave=amy.BYO_PARTIALS, num_partials=num_partials) for i in range(1, num_partials + 1): # Set up each partial as the corresponding harmonic of 440.0 # with an amplitude of 1/N, 50ms attack, and a decay of 1 sec / N. amy.send(osc=i, wave=amy.PARTIAL, freq=440.0 * i, bp0='50,%.2f,%d,0,0,0' % ((1.0 / i), 1000 // i)) amy.send(osc=0, note=60, vel=1) ``` You can add a filter (or an envelope etc.) to the sum of all the `PARTIAL` oscs by configuring it on the parent `BYO_PARTIALS` osc: ``` amy.send(osc=0, filter=amy.FILTER_HPF, resonance=4, filter_freq={'const': 200, 'eg1': 4}, bp1='0,0,1000,1,0,0') amy.send(osc=0, note=60, vel=1) # etc. ``` Note that the default `bp0` amplitude envelope of the `BYO_PARTIALS` osc is a gate, so if you want to have a nonzero release on your partials, you'll need to add a slower release to the `BYO_PARTIALS` osc to avoid it cutting them off. ## Interpolated partials Please see our [piano voice documentation](https://shorepine.github.io/amy/piano.html) for more on the `INTERP_PARTIALS` type. ## PCM and Sampler AMY comes with a set of 67 drum-like and instrument PCM samples to use as well, as they are normally hard to render with additive, subtractive or FM synthesis. You can use the type `PCM` and preset numbers 0-66 to explore them. Their native pitch is used if you don't give a frequency or note parameter. You can update the baked-in PCM sample bank using `amy_headers.py`. ```python amy.send(osc=0, wave=amy.PCM, vel=1, preset=10) # cowbell amy.send(osc=0, wave=amy.PCM, vel=1, preset=10, note=70) # higher cowbell! ``` You can turn on sample looping, helpful for instruments, using `feedback`: ```python amy.send(wave=amy.PCM,vel=1,preset=21,feedback=0) # clean guitar string, no looping amy.send(wave=amy.PCM,vel=1,preset=21,feedback=1) # loops forever until note off amy.send(vel=0) # note off amy.send(wave=amy.PCM,vel=1,preset=35,feedback=1) # nice violin ``` ### Sampler (aka Memory PCM) You can also load your own samples into AMY memory at runtime by sending PCM data over the wire protocol. Use `load_sample` in `amy.py` as an example: ```python amy.load_sample("G1.wav", preset=3) amy.send(osc=0, wave=amy.PCM, preset=3, vel=1) # plays the sample ``` You can use any preset number. If it overlaps with an existing PCM baked in number, it will play the memory sample instead of the baked in sample until you `unload_sample` the preset. If the WAV file has sampler metadata like loop points or base MIDI note, we use that in AMY. You can set it directly as well using `loopstart`, `loopend`, `channels`, `midinote` or `length` in the `load_sample` call. To unload a sample: ```python amy.unload_sample(3) # unloads the RAM for preset 3 ``` Under the hood, if AMY receives a `load_sample` message (with preset number and nonzero length), it will then pause all other message parsing until it has received `length` amount of base64 encoded bytes over the wire protocol. Each individual message must be base64 encoded. Since AMY's maximum message length is 255 bytes, there is logic in `load_sample` in `amy.py` to split the sample data into 188 byte chunks, which generates 252 bytes of base64 text. Please see `amy.load_sample` if you wish to load samples on other platforms. ### WAV file playback AMY support playing WAV files directly with pitching (but not looping!) if your host of MCU has file support. You can use this when the WAV files are bigger than available memory. We provide file reading hooks for POSIX platforms (Mac, Linux) and see [Hooks](api.md#Hooks) to build your own `fopen`, `fread` etc on other platforms like Arduino or Micropython. You can set an oscillator to play a channel of the file with `disk_sample`, e.g. ```python amy.disk_sample("G1.wav", preset=1024, midinote=31) amy.send(osc=0, wave=amy.PCM_LEFT, preset=1024, pan=0, note=60, vel=1) # plays sample from disk ``` Note that you can only play one instance of the file per **preset**. (We keep one file handle open per `disk_sample` preset.) If you want to play multiple copies of a WAV file at once (for instance, a polyphonic sampler), you should make multiple `preset`s: ```python amy.disk_sample("G1.wav", preset=1024, midinote=31) amy.disk_sample("G1.wav", preset=1025, midinote=31) amy.disk_sample("G1.wav", preset=1026, midinote=31) amy.send(osc=0, wave=amy.PCM_LEFT, preset=1024, pan=0, note=60, vel=1) # plays sample from disk amy.send(osc=0, wave=amy.PCM_LEFT, preset=1025, pan=0, note=72, vel=1) ``` ### Channels We support loading 1 or 2 channel WAV for `load_sample` and `disk_sample`. For `disk_sample`, channels are decoded from the WAV file metadata on disk. For `load_sample`, you should set the channels you're sending over. Each oscillator in AMY is mono, but you can hint it which channel of PCM to play back with `wave=PCM_LEFT` or `PCM_RIGHT`. `PCM` or `PCM_MIX` will average each channel if it was a two channel source. To play back stereo, set up two channels and use AMY's `pan`: ```python amy.disk_sample("G1.wav", preset=1024, midinote=31) amy.disk_sample("G1.wav", preset=1025, midinote=31) amy.send(osc=0, wave=amy.PCM_LEFT, preset=1024, pan=0, note=60, vel=1) amy.send(osc=1, wave=amy.PCM_RIGHT, preset=1025, pan=1, note=60, vel=1) ``` ### Sampling AMY can also sample directly into a PCM memory buffer from a `bus`. [A bus in AMY is a work in progress](https://github.com/shorepine/amy/issues/114) but for now we support two stereo buses: `bus=1` is the final AMY output and `bus=2` is just `AUDIO_IN0` and `AUDIO_IN1`. To start sampling to a PCM preset, use `start_sample`: ```python amy.start_sample(preset=1024, bus=0, max_frames=44100) # sample for one second amy.stop_sample() # stop all sampling, not needed if using max_frames amy.start_sample(preset=1024, bus=1, max_frames=11025, midinote=60) # set base midi note, looping, too amy.send(osc=0, wave=amy.PCM_LEFT, preset=1024, pan=0, note=72, vel=1) # play back AUDIO_IN sample an octave higher amy.send(osc=1, wave=amy.PCM_RIGHT, preset=1024, pan=1, note=72, vel=1) ``` ================================================ FILE: docs/tutorial.html ================================================ AMY Synthesizer Tutorial

AMY Synthesizer Tutorial

AMY Interactive Tutorial

This page will let you try out different AMY commands in live Python, running all in your browser. You can edit any of the examples and run them live.

If you're using C, Arduino or JS to control AMY, check out our API conversion table to go between Python amy.send and amy_event.

You can also run this tutorial on your computer within a Python shell by installing amy and running import amy; amy.live().

You can also try AMY in a more full featured REPL with Tulip Web.

AMY synth mode

AMY can receive MIDI messages while it is running and play just like a normal hardware synthesizer. You can send it note ons, offs, pitch bend, sustain, program changes and control change messages. Let's set up a synth to respond to MIDI channel 1. Make sure your MIDI devices are connected above at the top of this page (note: MIDI does not work on Safari, so try Chrome or Firefox.)

amy.send(patch=4, synth=1, num_voices=6)

Run that code block and play some notes on your MIDI keyboard. Try changing the patch and running again. The synth parameter tells AMY which synthesizer we are allocating (and if you give a synth number between 1 and 16, will respond to that MIDI channel), and num_voices tells AMY how much polyphony to allow per synthesizer. Keep track of num_voices is important for microcontrollers where you have limited CPU cycles. The patch can be any of AMY's built in Juno-6 (0-127), DX-7 (128-255), or partials (256) patches. (Later, we'll show you how to construct your own patches.)

No MIDI? That's ok, you can send the note on command to AMY directly:

amy.send(patch=4, synth=1, num_voices=6) amy.send(synth=1, vel=1, note=50)

Here you see we gave a synth number, and then vel for note on velocity and a MIDI note number of 50. vel in AMY is a signal to play a note on. If that note above is still playing, try `vel=0` to turn it off:

amy.send(synth=1, note=50, vel=0)

You can adjust parameters of an entire synth, like moving a knob, by addressing it. Here we'll change the filter cutoff frequency of the Juno-6 patch we loaded. Trying changing the values!

amy.send(patch=0, synth=1, num_voices=6) amy.send(synth=1, vel=1, note=50) amy.send(synth=1, filter_freq=[800], resonance=2.5)

AMY oscillators

Let's set a simple sine wave. We are simply telling oscillator 0 to be a sine wave at 220Hz and amplitude (specified as a note-on velocity) of 1. You can also try `amy.PULSE`, or `amy.SAW_DOWN`, etc.

amy.send(osc=0, wave=amy.SINE, freq=220, vel=1)

Now let's make more sine waves! We'll try using time to schedule events in the future. When you hit the play button on this page, AMY resets to time (in milliseconds) 0. In real use of AMY, you want to use amy_sysclock() to know what time it currently is. In this example we'll add a new sine wave every half second:

for i in range(16): amy.send(osc=i, wave=amy.SINE, freq=110+(i*80), vel=((16-i)/32.0), time=i*500)

A classic analog tone is the filtered saw wave. Let's make one.

amy.send(osc=0, wave=amy.SAW_DOWN, filter_freq=400, resonance=5, filter_type=amy.FILTER_LPF) amy.send(osc=0, vel=1, note=40)

Sounds nice. But we want that filter freq to go down over time, to make that classic filter sweep tone. Let's use an Envelope Generator! An Envelope Generator (EG) creates a smooth time envelope based on a breakpoint set, which is a simple list of (time-delta, target-value) pairs - you can have up to 8 of these per EG, and 2 different EGs to control different things. They're just like ADSRs, but more powerful. You can use an EG to control amplitude, oscillator frequency, filter cutoff frequency, PWM duty cycle, or stereo pan. The EG gets triggered when the note begins. So let's make an EG that turns the filter frequency down from its start at 3200 Hz to 400 Hz over 1000 milliseconds. And when the note goes off, it tapers the frequency to 50 Hz over 200 milliseconds.

amy.send(osc=0, wave=amy.SAW_DOWN, resonance=5, filter_type=amy.FILTER_LPF) amy.send(osc=0, filter_freq='50,0,0,0,1', bp1='0,6.0,1000,3.0,200,0') amy.send(osc=0, vel=1, note=40)

There are two things to note here: Firstly, the envelope is defined by the set of breakpoints in `bp1` (defining the second EG; the first is controlled by `bp0`). The `bp` strings alternate time intervals in milliseconds with target values. So `0,6.0,1000,3.0,200,0` means to move to 6.0 after 0 ms (i.e., the initial value is 6), then to decay to 3.0 over the next 1000 ms (1 second). The final pair is always taken as the "release", and does not begin until the note-off event is received. In this case, the EG decays to 0 in the 200 ms after the note-off.

Secondly, EG1 is coupled to the filter frequency with `filter_freq='50,0,0,0,1'`. `filter_freq` is an example of a set of **ControlCoefficients** where the control value is calculated on-the-fly by combining a set of inputs scaled by the coefficients. This is explained fully below, but for now the first coefficient (here 50) is taken as a constant, and the 5th coefficient (here 1) is applied to the output of EG1. To get good "musical" behavior, the filter frequency is controlled using a "unit per octave" rule. So if the envelope is zero, the filter is at its base frequency of 50 Hz. But the envelope starts at 6.0, which, after scaling by the control coefficient of 1, drives the filter frequency 6 octaves higher, or 2^6 = 64x the frequency -- 3200 Hz. As the envelope decays to 3.0 over the first 1000 ms, the filter moves to 2^3 = 8x the default frequency, giving 400 Hz. It's only during the final release of 200 ms that it falls back to 0, giving a final filter frequency of (2^0 = 1x) 50 Hz.

AMY sequencer

AMY is always running a musical sequencer. You can use it to schedule events using note lengths, or have a repeating (pattern) sequencer. Very useful for things like drum machines or MIDI playback.

amy.send(osc=0, vel=1, wave=amy.PCM, preset=0, sequence=",24,1") # play a PCM drum every eighth note. amy.send(osc=1, vel=1, wave=amy.PCM, preset=1, sequence=",48,2") # play a different PCM drum every quarter note.

You can remove or update sequence events by addressing their tag number

amy.send(sequence=",,1") # remove the eighth note sequence amy.send(osc=1, vel=1, wave=amy.PCM, preset=1, note=70, sequence=",48,2") # change the quarter note event

For patterns you want to also address their "slots", which is the offset within the pattern, like this

amy.send(osc=0, vel=1, wave=amy.PCM, preset=0, sequence="0,384,1") # first slot of a 16 1/8th note drum machine amy.send(osc=1, vel=1, wave=amy.PCM, preset=1, sequence="216,384,2") # ninth slot of a 16 1/8th note drum machine

Constructing FM tones

Let's set up a fully custom ALGO / FM patch, using two operators:
amy.send(osc=2, wave=amy.SINE, ratio=1, amp={'const': 1, 'vel': 0, 'eg0': 0}) amy.send(osc=1, wave=amy.SINE, ratio=0.2, amp={'const': 1, 'vel': 0, 'eg0': 1}, bp0='0,1,1000,0,0,0') amy.send(osc=0, wave=amy.ALGO, algorithm=1, algo_source=',,,,2,1') amy.send(osc=0, note=60, vel=1)

Let's unpack that last line: we're setting up a ALGO "oscillator" that controls up to 6 other oscillators. We only need two, so we set the `algo_source` to mostly not used and have oscillator 2 modulate oscillator 1. You can have the operators work with each other in all sorts of crazy ways. For this simple example, we just use the DX7 algorithm #1. And we'll use only operators 2 and 1. Therefore our `algo_source` lists the oscillators involved, counting backwards from 6. We're saying only have operator 2 (osc 2 in this case) and operator 1 (osc 1). From the algorithms picture, we see DX7 algorithm 1 has operator 2 feeding operator 1, so we have osc 2 providing the frequency-modulation input to osc 1.

What's going on with `ratio`? And `amp`? Ratio, for FM synthesis operators, means the ratio of the frequency for that operator relative to the base note. So oscillator 1 will be played at 20% of the base note frequency, and oscillator 2 will take the frequency of the base note. In FM synthesis, the `amp` of a modulator input is called "beta", which describes the strength of the modulation. Here, osc 2 is providing the modulation with a constant beta of 1, which will result in a range of sinusoids with frequencies around the carrier at multiples of the modulator. We set osc 2's amp ControlCoefficients for velocity and envelope generator 0 to 0 because they default to 1, but we don't want them for this example (FM sines don't receive the parent note's velocity, so we need to disable its influence). Osc 1 has `bp0` decaying its amplitude to 0 over 1000 ms, but because beta is fixed there's no other change to the sound over that time.

FM gets much more exciting when we vary beta, which just means varying the amplitide envelope of the modulator. The spectral effects of the frequency modulation depend on beta in a rich, nonlinear way, leading to the glistening FM sounds. Let's try fading in the modulator over 5 seconds. Just a refresher on envelope generators; here we are saying to set the beta parameter (amplitude of the modulating tone) to 2x envelope generator 0's output, which starts at 0 at time 0 (actually, this is the default), then grows to 1.0 at time 5000ms - so beta grows to 2.0. At the release of the note, beta immediately drops back to 0.

amy.send(osc=2, wave=amy.SINE, ratio=0.2, amp={'const': 1, 'vel': 0, 'eg0': 2}, bp0='0,0,5000,1,0,0') # Op 2, modulator amy.send(osc=1, wave=amy.SINE, ratio=1, amp={'const': 1, 'vel': 0, 'eg0': 0}) # Op 1, carrier amy.send(osc=0, wave=amy.ALGO, algorithm=1, algo_source=',,,,2,1') amy.send(osc=0, note=60, vel=1)

Want more? Try Tulip

Run more AMY experiments in a REPL with Tulip for the Web. Try the piano there!

Discord

Join the shore pine sound systems Discord to chat about Tulip, AMY and Alles. A fun small community!

Github

Check out the AMY Github page for issues, discussions and the code.

Join our email list

We'll send you very rare updates about Tulip, Alles, AMY and other projects we're working on.

< ================================================ FILE: docs/upgrading.md ================================================ # Upgrading between versions of AMY Here we will post breaking APIs between releases of AMY and tips on porting. ## 1.0.X -> 1.1.X This is a big change that moves a lot of stuff you used to have to do yourself into AMY itself -- voice and synth handling, note stealing, MIDI, I2S, sequencer. V1.1.0 is not backwards compatible with V1.0.3 Arduino scripts. We updated because we believe we have substantially improved the functionality under Arduino. In particular, we incorporated MIDI and I2S within AMY for common MCU boards. See the new [`AMY_MIDI_Synth.ino`](https://github.com/shorepine/amy/blob/main/examples/AMY_MIDI_Synth/AMY_MIDI_Synth.ino). To migrate your old AMY scripts: * There's no ``amy`` object. Instead, the API consists of a bunch of functions with ``amy_`` (underscore) prefix (defined in [`api.c`](https://github.com/shorepine/amy/blob/main/src/api.c)). * There's a new `amy_config` structure that you use to set startup options. You initialize it as, e.g.: ```c amy_config_t amy_config = amy_default_config(); amy_config.features.chorus = 0; // etc, as desired. amy_config.features.default_synths = 0; // If you want MIDI over UART (5-pin or 3-pin serial MIDI) amy_config.midi = AMY_MIDI_IS_UART; // Pins for i2s board amy_config.i2s_bclk = 8; amy_config.i2s_lrc = 9; amy_config.i2s_dout = 10; ... amy_start(amy_config); // instead of amy.begin() amy_live_start(); // performs I2S initialization ``` .. and (subject to several caveats and using supported hardware) MIDI input and I2S output will work. * `amy_add_event()` now takes a pointer to an event instead of the structure itself: ```c amy_event e = amy_default_event(); e.osc = 0; e.wave = SINE; e.freq_coefs[COEF_CONST] = 440; e.velocity = 1; amy_add_event(&e); // instead of amy.add_event(e) ``` * The main loop is intended to be very simple: ```c void loop() { amy_update(); } ``` But if you want to continue handling I2S and MIDI yourself, you can instead do something like: ```c I2S i2s(OUTPUT); void setup() { amy_config_t amy_config = amy_default_config(); amy_config.features.default_synths = 0; amy_start(amy_config); ... // Do your own i2s config i2s.begin(AMY_SAMPLE_RATE); } void loop() { int16_t * samples = amy_simple_fill_buffer(); for(int i = 0; i < AMY_BLOCK_SIZE; i++) { // AMY always renders in stereo. i2s.write16(samples[2 * i], samples[2 * i + 1]); } } ``` `patches_store_patch()` doesn't fit so well into our current API, and we're trying to make the use of wire string constants more of an exceptional case - you can do a similar thing by issuing a number of events with the `patch_number` set. However, you can still use `patches_store_patch()`, it's just that the syntax has changed - rather than having the patch number as a prefix to the string, it's provided in an event structure. So, ```c amy_event e = amy_default_event(); e.patch_number = 1024; patches_store_patch(&e, "v0w7f0"); // Or whatever the wire string defining your patch is. ``` ================================================ FILE: examples/AMY_ESP32_manual_I2S/AMY_ESP32_manual_I2S.ino ================================================ // AMY_MIDI_Synth modified to test out new amy_update that returns the pointer to samples. // It then handles passing off to I2S in-sketch rather than in the background. // ESP32-specific. #include // Should we use the transparent I2S driver in AMY? // Otherwise we'll handle passing samples to I2S ourselves. #define USE_AMY_FOR_I2S // If we're not USE_AMY_FOR_I2S, should we install our I2S output function using config.write_samples_fn? // Otherwise, we'll just get a pointer to samples from amy_update() and pass them on ourselves. // (Ignored if USE_AMY_FOR_I2S is defined). //#define USE_WRITE_SAMPLES_FN // Do we want a background task to do rendering? It's slightly more efficient under RTOS #define USE_MULTITHREAD // Do we want to split rendering between two cores? This works with or without MULTITHREAD. #define USE_MULTICORE // Here's how many simultaneous patch-1 voices I can get before dropouts on AMYBOARD: // USE_MULTITHREAD, USE_MULTICORE 9 // USE_MULTICORE 6 // USE_MULTITHREAD 6 // (neither) 4 // For convenience, we'll reuse AMY's ESP32 I2S setup and write functions. extern "C" { amy_err_t esp32_setup_i2s(); size_t amy_i2s_write(const uint8_t *buffer, size_t nbytes); }; void test_polyphony() { // Allocate a synth with lots of voices to test polyphony. // Increase the number of voices available to MIDI channel 1. amy_event e = amy_default_event(); e.reset_osc = RESET_AMY; amy_add_event(&e); e = amy_default_event(); e.synth = 1; e.patch_number = 1; e.num_voices = 12; // I get 12 simultaneous juno patch 0 voices on a 250 MHz RP2040. amy_add_event(&e); } // Support the NeoPixel on the ESP32-S3 dev board #include #define PIN 38 // 48 on some ESP32-S3 dev boards #define NUMPIXELS 1 Adafruit_NeoPixel pixels(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800); enum COLORS { BLACK, BLUE, GREEN, CYAN, RED, MAGENTA, YELLOW, WHITE }; void set_led(int val) { uint32_t c; switch(val) { case 0: c = pixels.Color(0, 0, 0); break; case 1: c = pixels.Color(0, 0, 100); break; case 2: c = pixels.Color(0, 100, 0); break; case 3: c = pixels.Color(0, 100, 100); break; case 4: c = pixels.Color(100, 0, 0); break; case 5: c = pixels.Color(100, 0, 100); break; case 6: c = pixels.Color(100, 100, 0); break; default: c = pixels.Color(100, 100, 100); break; } pixels.setPixelColor(0, c); pixels.show(); } // ------------------------------------- void setup() { pixels.begin(); pixels.clear(); set_led(GREEN); amy_config_t amy_config = amy_default_config(); amy_config.features.startup_bleep = 1; amy_config.features.default_synths = 0; // On RTOS, multithread runs audio rendering on its own thread. #ifdef USE_MULTITHREAD amy_config.platform.multithread = 1; #else amy_config.platform.multithread = 0; #endif // On ESP32, multicore will run a second rendering thread on core 1 even if multithread = 0. #ifdef USE_MULTICORE amy_config.platform.multicore = 1; #else amy_config.platform.multicore = 0; #endif #ifdef USE_AMY_FOR_I2S amy_config.audio = AMY_AUDIO_IS_I2S; #warning "Using AMY I2S" #else amy_config.audio = AMY_AUDIO_IS_NONE; #endif amy_config.features.audio_in = 0; // Pins for i2s board. // Because we're using AMY's setup_i2s, this also configures if !USE_AMY_FOR_I2S. #ifdef AMYBOARD_ARDUINO // These are the actual pins used on AMYboard. amy_config.i2s_mclk = 3; amy_config.i2s_bclk = 8; amy_config.i2s_lrc = 2; amy_config.i2s_dout = 6; #else amy_config.i2s_mclk = 7; amy_config.i2s_bclk = 8; amy_config.i2s_lrc = 9; amy_config.i2s_dout = 10; #endif // If you want MIDI over UART (5-pin or 3-pin serial MIDI) amy_config.midi = AMY_MIDI_IS_UART; // Pins for UART MIDI #ifdef AMYBOARD_ARDUINO amy_config.midi_out = 14; amy_config.midi_in = 21; #else amy_config.midi_out = 4; amy_config.midi_in = 5; #endif #ifndef USE_AMY_FOR_I2S #ifdef USE_WRITE_SAMPLES_FN // amy_update() will automatically pass the new samples to this fn, if provided. amy_config.write_samples_fn = amy_i2s_write; #warning "Using write_samples_fn" #endif #endif amy_start(amy_config); #ifndef USE_AMY_FOR_I2S esp32_setup_i2s(); // respects cached amy_config. #endif set_led(MAGENTA); test_polyphony(); set_led(YELLOW); } static long last_millis = 0; static const long millis_interval = 250; static bool led_state = 0; void loop() { // Your loop() must contain this call to amy: int16_t *buf = amy_update(); #ifndef USE_AMY_FOR_I2S #ifndef USE_WRITE_SAMPLES_FN amy_i2s_write((const uint8_t *)buf, AMY_BLOCK_SIZE * AMY_NCHANS * sizeof(int16_t)); #warning "Sending I2S explicitly in loop()" #endif #endif // Toggle on-board LED every 250ms int now_millis = millis(); if ((now_millis - last_millis) > millis_interval) { last_millis = now_millis; led_state = !led_state; if (led_state != 0) set_led(WHITE); else set_led(BLACK); } } ================================================ FILE: examples/AMY_MIDI_Synth/AMY_MIDI_Synth.ino ================================================ #include // Simple AMY synth setup that just sets up the default MIDI synth. // Plug a MIDI keyboard into the MIDI in port and play notes, send program changes, etc // We've tested this with the following boards: // // esp32s3 [n32r8] // rp2040 (Pi Pico) -- use 250Mhz and -O3 for 6 note juno polyphony and turn off serial debug if you have it on // rp2350 (Pi Pico) // teensy4 // Electrosmith Daisy // Please see https://github.com/shorepine/amy/issues/354 for the full list void test_polyphony() { // Allocate a synth with lots of voices to test polyphony. // Increase the number of voices available to MIDI channel 1. amy_event e = amy_default_event(); e.reset_osc = RESET_AMY; amy_add_event(&e); e = amy_default_event(); e.synth = 1; e.patch_number = 1; e.num_voices = 12; // I get 12 simultaneous juno patch 0 voices on a 250 MHz RP2040. amy_add_event(&e); } void test_sequencer() { amy_event e = amy_default_event(); e.sequence[0] = 0; e.sequence[1] = 48; e.sequence[2] = 1; e.velocity = 1; e.midi_note = 60; e.synth = 1; amy_add_event(&e); } void test_audio_in() { // Copy audio in to out, with echo. amy_event e = amy_default_event(); e.osc = 170; e.wave = AUDIO_IN0; e.pan_coefs[COEF_CONST] = 0.0f; e.velocity = 1.0f; amy_add_event(&e); e.osc = 171; e.wave = AUDIO_IN1; e.pan_coefs[COEF_CONST] = 1.0f; e.velocity = 1.0f; amy_add_event(&e); // Add echo to show that audio in is being processed. config_echo(0.5f, 150.0f, 160.0f, 0.5f, 0.0f); // I get errors on ESP32-S3 N8R8 if I go above 160.0ms // Turn off chorus, for better audio pass-through. config_chorus(0, 320, 0.5f, 0.5f); } // ------------------------------------- void setup() { #ifdef LED_BUILTIN pinMode(LED_BUILTIN, OUTPUT); digitalWrite(LED_BUILTIN, 1); #endif #ifdef HAS_SERIAL Serial.begin(115200); while (!Serial) { delay(10); } Serial.println("AMY_Synth"); #endif amy_config_t amy_config = amy_default_config(); amy_config.features.startup_bleep = 1; // Install the default_synths on synths (MIDI chans) 1, 2, and 10 (this is the default). amy_config.features.default_synths = 1; // If running an AMYboard, we set these parameters for you automatically. // For your own boards, set the pins and features you want. #ifndef AMYBOARD_ARDUINO // Pins for i2s board // Note: On the Teensy, all these settings are ignored, and blck = 21, lrc = 20, dout = 7. amy_config.audio = AMY_AUDIO_IS_I2S; amy_config.features.audio_in = 1; amy_config.i2s_mclk = 7; amy_config.i2s_bclk = 8; // On Pi Pico (RP2040, RP2350), i2s_lrc has to be i2s_bclk + 1, otherwise code will stop on an assert. amy_config.i2s_lrc = 9; amy_config.i2s_dout = 10; amy_config.i2s_din = 11; // If you want MIDI over UART (5-pin or 3-pin serial MIDI) amy_config.midi = AMY_MIDI_IS_UART; // Pins for UART MIDI // Note: On the Teensy, these are ignored and midi_out = 35, midi_in = 34. amy_config.midi_out = 4; amy_config.midi_in = 5; #endif amy_start(amy_config); //test_polyphony(); //test_sequencer(); test_audio_in(); } static long last_millis = 0; static const long millis_interval = 250; static bool led_state = 0; void loop() { // Your loop() must contain this call to amy: amy_update(); // Flash on-board LED every 250ms int now_millis = millis(); if ((now_millis - last_millis) > millis_interval) { last_millis = now_millis; led_state = !led_state; #ifdef LED_BUILTIN digitalWrite(LED_BUILTIN, led_state); // turn the LED on (HIGH is the voltage level) #endif } } ================================================ FILE: examples/AMY_USB_Host_MIDI/AMY_USB_Host_MIDI.ino ================================================ #include #include // ESP32_Host_MIDI // USB Host MIDI synth for ESP32-S3 / ESP32-S2 / ESP32-P4. // Plug a USB MIDI keyboard directly via USB OTG — no shields or adapters needed. // // The ESP32's USB OTG peripheral handles device enumeration, endpoint detection, // and hot-plug. Incoming USB-MIDI event packets are forwarded into AMY's MIDI // parser, which drives the default Juno-6 polyphonic synth. // // Hardware: // - ESP32-S3 board (LilyGO T-Display-S3, ESP32-S3 DevKit, etc.) // - I2S DAC (PCM5102, UDA1334, or similar) // - USB MIDI keyboard via OTG cable // // Required library: // - ESP32_Host_MIDI https://github.com/sauloverissimo/ESP32_Host_MIDI // // Tested with: // - LilyGO T-Display-S3 + PCM5102A DAC + Arturia Minilab 25 extern "C" { void convert_midi_bytes_to_messages(uint8_t *data, size_t len, uint8_t usb); } USBConnection usbMidi; // Bridge: forward USB-MIDI event packets into AMY's MIDI parser. // USB-MIDI packets are 4 bytes: [CIN+Cable, MIDI0, MIDI1, MIDI2]. // We pass bytes 1-3 as a group with the USB flag so AMY's parser can // exit early after completing the message, skipping padded bytes on // short messages (e.g. Program Change, Channel Pressure). void onUsbMidiData(void* ctx, const uint8_t* data, size_t length) { for (size_t i = 0; i + 4 <= length; i += 4) { if ((data[i] & 0x0F) == 0x00) continue; // Skip empty packets convert_midi_bytes_to_messages((uint8_t*)(data + i + 1), 3, 1); } } void setup() { Serial.begin(115200); amy_config_t amy_config = amy_default_config(); amy_config.features.startup_bleep = 1; // Install the default synths on MIDI channels 1, 2, and 10. amy_config.features.default_synths = 1; // I2S audio output — adjust pins for your board. amy_config.audio = AMY_AUDIO_IS_I2S; amy_config.i2s_bclk = 8; amy_config.i2s_lrc = 9; amy_config.i2s_dout = 10; // We handle MIDI ourselves via USB Host, so disable AMY's built-in MIDI. amy_config.midi = AMY_MIDI_IS_NONE; amy_start(amy_config); // Start USB Host MIDI and register the bridge callback. usbMidi.setMidiCallback(onUsbMidiData, NULL); usbMidi.begin(); Serial.println("AMY USB Host MIDI ready. Plug in a USB MIDI keyboard."); } void loop() { amy_update(); usbMidi.task(); } ================================================ FILE: examples/AMY_custom_osc/AMY_custom_osc.ino ================================================ #include // Example of using the AMY "custom oscillator" from Arduino. // Custom osc types are defined by 7 functions: void my_custom_init() { // Called once at synth setup. } void my_custom_deinit() { // Called at synth teardown, to release resources. } void my_custom_note_on(uint16_t osc, float freq) { // Called when note-on received, to set up any per-note state, with initial frequency value. } // Magic number AMY uses to indicate "unset" clocks. #define CLOCK_UNSET UINT32_MAX void my_custom_note_off(uint16_t osc) { // Called when note-off received. // If you want the built-in ADSR to work, the note-off has to signal that we've moved into release phase. synth[osc]->note_on_clock = CLOCK_UNSET; synth[osc]->note_off_clock = amy_global.total_blocks * AMY_BLOCK_SIZE; // time (in samples) that release began. } void my_custom_mod_trigger(uint16_t osc) { // Called when this osc is the mod_osc to another osc which receives a note-on. } // Non-anti-aliased square wave as an example custom oscillator. SAMPLE my_custom_render(SAMPLE *buf, uint16_t osc) { // Called to render the next block of AMY_BLOCK_SIZE samples. They should be summed into buf. Return the peak value. // We have access to the msynth[osc] parameters for this frame, and the persistent synth[osc] state. // Calculate the phase advance per sample. PHASOR is S.31 fixed point value, F2P converts a float to the PHASOR domain. float freq = freq_of_logfreq(msynth[osc]->logfreq); // Current pitch, including effects like pitch bend etc. PHASOR step = F2P(freq / (float)AMY_SAMPLE_RATE); // Phase advance per sample: cycles per sec / samples per sec -> cycles per sample SAMPLE amp = F2S(msynth[osc]->amp); // msynth params are floats, but buffer etc are in S8.23 fixed point. SAMPLE max_value = 0; for (int i = 0; i < AMY_BLOCK_SIZE; ++i) { SAMPLE value = MUL8_SS(amp, // MUL8_SS is fixed-point multiply, to apply ADSR envelope scaling in amp. (synth[osc]->phase >= F2P(0.5f)) ? F2S(0.5f) : F2S(-0.5f)); // Naive square wave. Causes harsh alias tones. buf[i] += value; // Add it into the output buffer. if (value < 0) value = -value; // i.e. calculate ABS(value) if (value > max_value) max_value = value; // track the max // Step on the phase variable. synth[osc]->phase = P_WRAPPED_SUM(synth[osc]->phase, step); } return max_value; } SAMPLE my_custom_compute_mod(uint16_t osc) { // Return the one value per block generated when this is mod_osc. return 0; } // ------------------------------------- void setup() { amy_config_t amy_config = amy_default_config(); amy_config.features.startup_bleep = 1; amy_config.features.default_synths = 0; // If running an AMYboard, we set these parameters for you automatically. // For your own boards, set the pins and features you want. #ifndef AMYBOARD_ARDUINO // Pins for i2s board // Note: On the Teensy, all these settings are ignored, and blck = 21, lrc = 20, dout = 7. amy_config.audio = AMY_AUDIO_IS_I2S; amy_config.i2s_mclk = 7; amy_config.i2s_bclk = 8; // On Pi Pico (RP2040, RP2350), i2s_lrc has to be i2s_bclk + 1, otherwise code will stop on an assert. amy_config.i2s_lrc = 9; amy_config.i2s_dout = 10; amy_config.i2s_din = 11; // If you want MIDI over UART (5-pin or 3-pin serial MIDI) amy_config.midi = AMY_MIDI_IS_UART; // Pins for UART MIDI // Note: On the Teensy, these are ignored and midi_out = 35, midi_in = 34. amy_config.midi_out = 4; amy_config.midi_in = 5; #endif amy_config.features.custom = 1; // We are using a custom oscillator. // Install the custom oscillator functions. struct custom_oscillator custom = { my_custom_init, my_custom_deinit, my_custom_note_on, my_custom_note_off, my_custom_mod_trigger, my_custom_render, my_custom_compute_mod, }; amy_set_custom(&custom); amy_start(amy_config); // Set up a single-osc synth using the custom osc. amy_event e = amy_default_event(); e.synth = 1; e.oscs_per_voice = 1; e.num_voices = 4; amy_add_event(&e); e = amy_default_event(); e.synth = 1; e.osc = 0; e.wave = CUSTOM; // Setup decaying ADSR e.eg0_times[0] = 10; // attack (in ms) e.eg0_times[1] = 1000; // decay e.eg0_times[2] = 1000; // release e.eg0_values[0] = 1.0f; // (attack target level) e.eg0_values[1] = 0.3f; // sustain e.eg0_values[2] = 0; // (release target level) amy_add_event(&e); } void loop() { // Your loop() must contain this call to amy: amy_update(); } ================================================ FILE: examples/AMY_pico_PWM/AMY_pico_PWM.ino ================================================ #include // AMY_pico_PWM // // Runs AMY using arduino-pico's PWM audio output. // This version responds to serial MIDI input. // dpwe 2025-10-26 // If you define this, we write to PWM using AMY's write_samples_fn hook // but leaving it undefined means we pass the sample block in our loop() fn. //#define USE_AMY_WRITE_SAMPLES_FN extern "C" { extern void example_sequencer_drums_synth(uint32_t start); } #include PWMAudio pwm(0, true); // PWM Stereo out on pins 0 and 1. // Have to introduce this function to work around virtual overloaded write function. size_t pwm_write(const uint8_t *buffer, size_t nbytes) { return pwm.write(buffer, nbytes); } void setup() { #ifdef LED_BUILTIN pinMode(LED_BUILTIN, OUTPUT); digitalWrite(LED_BUILTIN, 1); #endif // Setup PWM pwm.setBuffers(4, AMY_BLOCK_SIZE * AMY_NCHANS * sizeof(int16_t) / sizeof(int32_t)); pwm.begin(44100); amy_config_t amy_config = amy_default_config(); amy_config.features.startup_bleep = 1; amy_config.features.default_synths = 1; amy_config.midi = AMY_MIDI_IS_UART; // Pins for UART MIDI amy_config.midi_in = 5; #ifdef USE_AMY_WRITE_SAMPLES_FN // Configure to pass samples to PWM. amy_config.write_samples_fn = pwm_write; #endif amy_start(amy_config); // Set a drum loop going, as an example. example_sequencer_drums_synth(2000); } static long last_millis = 0; static const long millis_interval = 250; static bool led_state = 0; void loop() { int16_t *block = amy_update(); #ifndef USE_AMY_WRITE_SAMPLES_FN // We have opted to handle our own sample writing. pwm_write((uint8_t *)block, AMY_BLOCK_SIZE * AMY_NCHANS * sizeof(int16_t)); #endif // Flash on-board LED every 250ms int now_millis = millis(); if ((now_millis - last_millis) > millis_interval) { last_millis = now_millis; led_state = !led_state; #ifdef LED_BUILTIN digitalWrite(LED_BUILTIN, led_state); // turn the LED on (HIGH is the voltage level) #endif } } ================================================ FILE: examples/BillieJeanDrums/BillieJeanDrums.ino ================================================ // BillieJeanDrums - Making a simple drum pattern with AMY. // see https://github.com/shorepine/amy/blob/main/docs/billie_jean.md #include void setup() { amy_config_t amy_config = amy_default_config(); amy_config.features.startup_bleep = 1; // Install the default_synths on synths (MIDI chans) 1, 2, and 10. amy_config.features.default_synths = 1; // If running an AMYboard, we set these parameters for you automatically. // For your own boards, set the pins and features you want. #ifndef AMYBOARD_ARDUINO amy_config.audio = AMY_AUDIO_IS_I2S; // Pins for i2s board amy_config.i2s_bclk = 8; amy_config.i2s_lrc = 9; amy_config.i2s_dout = 10; #endif amy_start(amy_config); } struct timed_note { float start_time; // In ticks int note; float velocity; }; // 35 is kick, 37 is snare, 42 is closed hat, 46 is open hat // Notes must be sorted in start_time order. timed_note notes[] = { { 0.0, 42, 1.0}, // 0 HH + BD { 0.0, 35, 1.0}, { 1.0, 42, 1.0}, // 1 HH { 2.0, 42, 1.0}, // 2 HH + SN { 2.0, 37, 1.0}, { 3.0, 42, 1.0}, // 3 HH { 4.0, 42, 1.0}, // 4 HH + BD { 4.0, 35, 1.0}, { 5.0, 42, 1.0}, // 5 HH { 6.0, 42, 1.0}, // 6 HH + SN { 6.0, 37, 1.0}, { 7.0, 46, 1.0}, // 7 OH }; // Time (in ticks) at which we reset to the start of the table. float cycle_len = 8.0; float millis_per_tick = 250; float base_tick = 0; // Time of beginning of current cycle. int note_tab_index = 0; int note_tab_len = sizeof(notes) / sizeof(timed_note); void loop() { // Your loop() must contain this call to amy: amy_update(); // Calculate "tick time" and choose note. float tick_in_cycle = millis() / millis_per_tick - base_tick; if (tick_in_cycle >= cycle_len) { // Start the next cycle - reset the cycle base_tick, reset the note_tab index. tick_in_cycle -= cycle_len; base_tick += cycle_len; note_tab_index = 0; } // Play any notes for this moment from the note table. while(note_tab_index < note_tab_len && tick_in_cycle >= notes[note_tab_index].start_time) { // Grab the note parameters int midi_note = notes[note_tab_index].note; float velocity = notes[note_tab_index].velocity; // Time to play the note. amy_event e = amy_default_event(); e.synth = 10; // drums channel e.midi_note = midi_note; e.velocity = velocity; amy_add_event(&e); note_tab_index++; } } ================================================ FILE: examples/BillieJeanDrumsBass/BillieJeanDrumsBass.ino ================================================ // BillieJeanDrumsBass - Use different synthesizers to add a bass line along with the drums // see https://github.com/shorepine/amy/blob/main/docs/billie_jean.md #include void setup() { amy_config_t amy_config = amy_default_config(); amy_config.features.startup_bleep = 1; // Install the default_synths on synths (MIDI chans) 1, 2, and 10 (this is the default). amy_config.features.default_synths = 1; // If running an AMYboard, we set these parameters for you automatically. // For your own boards, set the pins and features you want. #ifndef AMYBOARD_ARDUINO amy_config.audio = AMY_AUDIO_IS_I2S; // Pins for i2s board amy_config.i2s_bclk = 8; amy_config.i2s_lrc = 9; amy_config.i2s_dout = 10; #endif amy_start(amy_config); // Set up synth 2 as monophonic bass amy_event e = amy_default_event(); e.synth = 2; e.patch_number = 30; // Juno A47 Funky I e.num_voices = 1; amy_add_event(&e); } struct timed_note { float start_time; // In ticks int channel; // 10 = drums, 2 = bass int note; float velocity; }; // Notes must be sorted in start_time order. timed_note notes[] = { { 0.0, 2, 43, 0.2}, // bass G2 { 0.0, 10, 42, 1.0}, // 0 HH + BD { 0.0, 10, 35, 1.0}, { 1.0, 2, 38, 0.2}, // bass D2 { 1.0, 10, 42, 1.0}, // 1 HH { 2.0, 2, 41, 0.2}, // bass F2 { 2.0, 10, 42, 1.0}, // 2 HH + SN { 2.0, 10, 37, 1.0}, { 3.0, 2, 43, 0.2}, // bass G2 { 3.0, 10, 42, 1.0}, // 3 HH { 4.0, 2, 41, 0.2}, // bass F2 { 4.0, 10, 42, 1.0}, // 4 HH + BD { 4.0, 10, 35, 1.0}, { 5.0, 2, 38, 0.2}, // bass D2 { 5.0, 10, 42, 1.0}, // 5 HH { 6.0, 2, 36, 0.2}, // bass C2 { 6.0, 10, 42, 1.0}, // 6 HH + SN { 6.0, 10, 37, 1.0}, { 7.0, 2, 38, 0.2}, // bass D2 { 7.0, 10, 46, 1.0}, // 7 OH }; // Time (in ticks) at which we reset to the start of the table. float cycle_len = 8.0; float millis_per_tick = 250; float base_tick = 0; // Time of beginning of current cycle. int note_tab_index = 0; int note_tab_len = sizeof(notes) / sizeof(timed_note); void loop() { // Let amy do its processing for this moment. amy_update(); // Calculate "tick time" and choose note. float tick_in_cycle = millis() / millis_per_tick - base_tick; if (tick_in_cycle >= cycle_len) { // Start the next cycle - reset the cycle base_tick, reset the note_tab index. tick_in_cycle -= cycle_len; base_tick += cycle_len; note_tab_index = 0; } // Play any notes for this moment from the note table. while(note_tab_index < note_tab_len && tick_in_cycle >= notes[note_tab_index].start_time) { // Time to play the note. amy_event e = amy_default_event(); e.synth = notes[note_tab_index].channel; e.midi_note = notes[note_tab_index].note; e.velocity = notes[note_tab_index].velocity; amy_add_event(&e); note_tab_index++; } } ================================================ FILE: examples/BillieJeanScheduled/BillieJeanScheduled.ino ================================================ // BillieJeanScheduled - playing drums, bass, and chords using the AMY scheduler for timing // see https://github.com/shorepine/amy/blob/main/docs/billie_jean.md // Note: On the RP2350, using arduino-pico v 5.5.1, I have trouble with this crashing when I compile -O3 (Optimize Even More). // It runs correctly with -O2 (Optimize More), but then it can't quite keep up during the chords at 150 MHz. // I ran at 176 MHz and it was fine. #include void setup() { amy_config_t amy_config = amy_default_config(); amy_config.features.startup_bleep = 1; // Install the default_synths on synths (MIDI chans) 1, 2, and 10 (this is the default). amy_config.features.default_synths = 1; // If running an AMYboard, we set these parameters for you automatically. // For your own boards, set the pins and features you want. #ifndef AMYBOARD_ARDUINO amy_config.audio = AMY_AUDIO_IS_I2S; // Pins for i2s board amy_config.i2s_bclk = 8; amy_config.i2s_lrc = 9; amy_config.i2s_dout = 10; #endif amy_start(amy_config); // Reconfigure synth 1 as a 6-note polyphonic synth (for chords) amy_event e = amy_default_event(); e.synth = 1; e.patch_number = 5; // Juno A16 Brass & Strings e.num_voices = 6; amy_add_event(&e); // Reconfigure synth 2 as monophonic bass e = amy_default_event(); e.synth = 2; e.patch_number = 30; // Juno A47 Funky I e.num_voices = 1; amy_add_event(&e); // Turn on reverb config_reverb(0.5f, 0.85f, 0.5f, 3000.0f); } struct timed_note { float start_time; // In ticks float duration; // In ticks int note; float velocity; }; // Cycle length (in ticks) for drums + bass float cycle_len = 8.0; // Drum notes have durations of 0 for no note-off timed_note drum_notes[] = { { 0.0, 0.0, 42, 1.0}, // 0 HH + BD { 0.0, 0.0, 35, 1.0}, { 1.0, 0.0, 42, 1.0}, // 1 HH { 2.0, 0.0, 42, 1.0}, // 2 HH + SN { 2.0, 0.0, 37, 1.0}, { 3.0, 0.0, 42, 1.0}, // 3 HH { 4.0, 0.0, 42, 1.0}, // 4 HH + BD { 4.0, 0.0, 35, 1.0}, { 5.0, 0.0, 42, 1.0}, // 5 HH { 6.0, 0.0, 42, 1.0}, // 6 HH + SN { 6.0, 0.0, 37, 1.0}, { 7.0, 0.0, 42, 2.0}, // 7 OH }; timed_note bass_notes[] = { { 0.0, 0.6, 43, 0.4}, // bass G2 { 1.0, 0.6, 38, 0.2}, // bass D2 { 2.0, 0.6, 41, 0.2}, // bass F2 { 3.0, 0.6, 43, 0.4}, // bass G2 { 4.0, 0.6, 41, 0.2}, // bass F2 { 5.0, 0.6, 38, 0.2}, // bass D2 { 6.0, 0.6, 36, 0.2}, // bass C2 { 7.0, 0.6, 38, 0.2}, // bass D2 }; timed_note chord_notes[] = { { 0.0, 0.2, 70, 1.0}, // Fmin:1 { 0.0, 0.2, 74, 1.0}, { 0.0, 0.2, 79, 1.0}, { 3.0, 0.2, 72, 1.0}, // Amin:1 { 3.0, 0.2, 76, 1.0}, { 3.0, 0.2, 81, 1.0}, { 8.0, 0.2, 74, 1.0}, // Bb:1 { 8.0, 0.2, 77, 1.0}, { 8.0, 0.2, 82, 1.0}, { 11.0, 0.2, 72, 1.0}, // Amin:1 { 11.0, 0.2, 76, 1.0}, { 11.0, 0.2, 81, 1.0}, }; float millis_per_tick = 250; void schedule_notes(int time, int channel, struct timed_note *notes, int num_notes) { amy_event e = amy_default_event(); e.synth = channel; for (int i = 0; i < num_notes; ++i) { e.midi_note = notes[i].note; e.velocity = notes[i].velocity; e.time = time + millis_per_tick * notes[i].start_time; amy_add_event(&e); // Add note-off too if duration > 0 if (notes[i].duration > 0) { e.time += millis_per_tick * notes[i].duration; e.velocity = 0; amy_add_event(&e); } } } int start_millis = 3000; int last_cycle = -1; void loop() { // Let amy do its processing for this moment. amy_update(); int now = millis(); int current_cycle = floor((now - start_millis) / (millis_per_tick * cycle_len)); if (current_cycle > last_cycle) { // A new cycle began, issue notes. // Drums schedule_notes(now, 10, drum_notes, sizeof(drum_notes) / sizeof(timed_note)); // Bass comes in after two cycles of drums if (current_cycle >= 2) schedule_notes(now, 2, bass_notes, sizeof(bass_notes) / sizeof(timed_note)); // Chord sequence is 2 cycles long, so only schedule every other cycle if ((current_cycle >= 4) && ((current_cycle % 2) == 0)) schedule_notes(now, 1, chord_notes, sizeof(chord_notes) / sizeof(timed_note)); last_cycle = current_cycle; } } ================================================ FILE: experiments/Piano.ff.D5.json ================================================ [[588.7303322461809, [[0, 0.0003183759280936712], [4, 0.05942463446834628], [4, 0.019017213920200938], [3, 0.07456424206062932], [4, 0.03211996948806711], [9, 0.09079206854603922], [10, 0.06417436882155676], [161, 0.04113575922530802], [305, 0.004179459444875219], [158, 0.00813364918970332], [196, 0.010624284144828064], [1118, 0.004947346497968808], [2694, 1e-05]]], [1178.3660903474083, [[0, 0.0002793690336819829], [2, 0.0021976588087683044], [5, 0.005838245531670097], [7, 0.003065981320912732], [2, 0.00024344445740237883], [1, 0.002553211144184102], [7, 0.007484968029050363], [333, 0.0012346672590791037], [858, 0.0018231277860990783], [229, 0.0001726784568776625], [144, 0.0006840286807119472], [386, 0.0001576030029091112], [1198, 1e-05]]], [1772.5545853634997, [[0, 0.00048131423642205136], [33, 0.00719299878102724], [75, 0.0001768071748645232], [12, 0.0008472834811783129], [118, 0.0029321302653307407], [121, 0.000189720888525554], [179, 0.0011122816882865238], [525, 0.00016483392244049223], [221, 0.0005263771715679324], [244, 4.1910230460678194e-05], [121, 0.00016824764395001002], [323, 9.051689571458068e-05], [957, 1e-05]]], [2374.9205859564886, [[0, 0.00040854494571732384], [21, 0.006788666604897345], [99, 0.002483659427166644], [53, 0.0004967051266348974], [75, 0.0011397418191588153], [54, 0.0005923056877930803], [49, 9.857045371694208e-05], [31, 0.00026888745271609366], [181, 0.0012074388136955837], [722, 5.063709278087347e-05], [373, 0.00011917943846409484], [314, 3.2917415177071816e-05], [517, 1e-05]]], [2981.9370771573363, [[0, 0.0005073219585854762], [6, 0.002143384810784923], [32, 0.004024571933991137], [285, 0.0002351915777234433], [124, 0.0013579525605566338], [301, 0.0006150344957094475], [68, 0.0002997373777975395], [50, 4.930451625695493e-05], [36, 0.0001914252284511738], [71, 0.0002832602455506109], [553, 2.6257331771361438e-05], [445, 4.718178010426903e-05], [674, 1e-05]]], [3593.434998085348, [[0, 6.997375523406293e-05], [30, 0.0003672613580250497], [59, 1e-05], [39, 0.0003087963384543869], [181, 7.321982209073097e-05], [145, 0.00017581312716484374], [94, 1e-05], [162, 5.273516649158518e-05], [30, 1e-05], [11, 4.2974849614082415e-05], [157, 1e-05]]], [4229.607048253364, [[0, 0.0012263153968680729], [351, 0.0005170348720433382], [78, 5.174146939791391e-05], [77, 0.00024400934372791023], [92, 3.6703629239340094e-05], [84, 0.00016773114275570467], [99, 3.940314967314563e-05], [287, 5.459729769062907e-05], [76, 1e-05], [220, 2.1806213411630582e-05], [71, 1e-05]]], [4866.529189545834, [[0, 0.00021436530674617154], [23, 0.0010886411168758124], [85, 0.0002189088689404475], [118, 0.0001570173342542884], [76, 1e-05], [38, 7.107607809852509e-05], [45, 0.00013357431542398312], [110, 4.2910776895418664e-05], [28, 1e-05], [58, 5.8987997112753885e-05], [152, 1.1173268184890341e-05], [1238, 1e-05]]], [5521.392895279753, [[0, 0.00016013734765617617], [8, 0.0004975265563792979], [10, 0.0006833277001297742], [37, 0.000264896745823349], [30, 8.671142225330706e-05], [270, 5.3786227338839034e-05], [18, 4.4295173867557845e-05], [21, 2.8534818068031998e-05], [14, 1.8271708646431397e-05], [12, 1e-05], [154, 1.2683788967847035e-05], [1397, 1e-05]]], [5993.211913877236, [[0, 4.133042658491698e-05], [22, 0.000193056979805458], [37, 1.3061329025907025e-05], [11, 7.91814895674594e-05], [29, 5.918314721471629e-05], [22, 0.0001157584923641241], [63, 6.695683184348423e-05], [16, 2.112169219787103e-05], [61, 5.137627711591517e-05], [41, 3.6974442496701866e-05], [48, 1e-05]]], [6209.506870265294, [[0, 9.291958727938869e-05], [15, 0.00021930507318906244], [39, 0.00011997407362446589], [21, 4.68708932347928e-05], [12, 1e-05], [27, 5.432638261152426e-05], [47, 8.72899821763702e-05], [62, 4.486696724761924e-05], [38, 1e-05], [79, 3.183736288763783e-05], [75, 1e-05]]], [6356.065185423214, [[0, 3.633852255495574e-05], [3, 3.975174300391418e-05], [2, 4.00886745226706e-05], [2, 3.778143907310652e-05], [2, 3.250107154949022e-05], [2, 2.7109423821887278e-05], [2, 2.1586212295343048e-05], [1, 1.8558128906342846e-05], [1, 1.5311792902188635e-05], [1, 1.2385712465424301e-05], [1, 1e-05]]], [6585.520493856969, [[0, 6.006105628595023e-05], [13, 0.00015760846518620355], [22, 0.00014423569295345435], [35, 5.331838169411088e-05], [19, 2.3889638460245353e-05], [25, 2.1337415630729035e-05], [31, 1e-05], [76, 3.8735759375888676e-05], [41, 2.8711399878871067e-05], [18, 1.916455403225273e-05], [15, 1e-05]]], [6888.576520028839, [[0, 0.00014039127451693454], [9, 0.00026923683913780087], [10, 0.0002758092931966771], [65, 3.4847972849235036e-05], [17, 1e-05], [38, 2.4417491911958504e-05], [38, 1e-05], [41, 2.890364448556149e-05], [54, 2.36684534907883e-05], [29, 1.573937352538402e-05], [18, 1e-05]]], [7827.142713846636, [[0, 0.00018695983279202859], [19, 0.000564160868984498], [28, 9.848553725709827e-05], [67, 0.00020968061803984522], [38, 8.576199191922773e-05], [60, 7.275483784498407e-05], [25, 3.8760196404909184e-05], [13, 1e-05], [22, 3.2295206688859795e-05], [33, 5.311960528626866e-05], [118, 1e-05]]], [8346.235419443556, [[0, 3.637160692920743e-05], [7, 5.283516088294488e-05], [24, 9.012950737578221e-05], [37, 5.2341215769926475e-05], [26, 5.369463010614086e-05], [19, 3.089664506374774e-05], [7, 1.875273725708021e-05], [5, 1e-05], [30, 1.7500754349057955e-05], [21, 1.368989908148391e-05], [8, 1e-05]]], [9094.51290753102, [[0, 7.60475041842041e-05], [11, 0.00016062186634294598], [12, 0.00019748916730596592], [16, 0.00013819533230118768], [27, 4.1180945396886185e-05], [49, 1.5380679972247693e-05], [98, 5.00075625196403e-05], [36, 2.4052771358767458e-05], [30, 3.57790440481162e-05], [17, 3.5759016848020335e-05], [111, 1e-05]]], [9844.880761675198, [[0, 2.499352791863241e-05], [5, 3.4248224453214005e-05], [5, 4.2341181196015786e-05], [5, 4.724566071182584e-05], [6, 4.775496768114255e-05], [16, 3.893789261059817e-05], [26, 3.617181353457996e-05], [19, 2.497797531884996e-05], [26, 1.108322208842994e-05], [27, 1.43151888036016e-05], [16, 1e-05]]]] ================================================ FILE: experiments/compare_test_wavs.ipynb ================================================ { "cells": [ { "cell_type": "code", "execution_count": 2, "id": "ad51c589-8c0c-4677-b145-ad5ab4710e70", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Requirement already satisfied: numpy in /opt/homebrew/lib/python3.12/site-packages (1.26.4)\n", "Collecting scipy\n", " Downloading scipy-1.13.1-cp312-cp312-macosx_12_0_arm64.whl.metadata (60 kB)\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m60.6/60.6 kB\u001b[0m \u001b[31m234.8 kB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0ma \u001b[36m0:00:01\u001b[0m\n", "\u001b[?25hRequirement already satisfied: numpy<2.3,>=1.22.4 in /opt/homebrew/lib/python3.12/site-packages (from scipy) (1.26.4)\n", "Downloading scipy-1.13.1-cp312-cp312-macosx_12_0_arm64.whl (30.4 MB)\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m30.4/30.4 MB\u001b[0m \u001b[31m13.1 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m00:01\u001b[0m00:01\u001b[0m\n", "\u001b[?25hInstalling collected packages: scipy\n", "Successfully installed scipy-1.13.1\n", "Collecting matplotlib\n", " Downloading matplotlib-3.9.0-cp312-cp312-macosx_11_0_arm64.whl.metadata (11 kB)\n", "Collecting contourpy>=1.0.1 (from matplotlib)\n", " Downloading contourpy-1.2.1-cp312-cp312-macosx_11_0_arm64.whl.metadata (5.8 kB)\n", "Collecting cycler>=0.10 (from matplotlib)\n", " Using cached cycler-0.12.1-py3-none-any.whl.metadata (3.8 kB)\n", "Collecting fonttools>=4.22.0 (from matplotlib)\n", " Downloading fonttools-4.53.0-cp312-cp312-macosx_11_0_arm64.whl.metadata (162 kB)\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m162.2/162.2 kB\u001b[0m \u001b[31m5.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", "\u001b[?25hCollecting kiwisolver>=1.3.1 (from matplotlib)\n", " Using cached kiwisolver-1.4.5-cp312-cp312-macosx_11_0_arm64.whl.metadata (6.4 kB)\n", "Requirement already satisfied: numpy>=1.23 in /opt/homebrew/lib/python3.12/site-packages (from matplotlib) (1.26.4)\n", "Requirement already satisfied: packaging>=20.0 in /opt/homebrew/Cellar/jupyterlab/4.1.6_1/libexec/lib/python3.12/site-packages (from matplotlib) (24.0)\n", "Collecting pillow>=8 (from matplotlib)\n", " Downloading pillow-10.3.0-cp312-cp312-macosx_11_0_arm64.whl.metadata (9.2 kB)\n", "Collecting pyparsing>=2.3.1 (from matplotlib)\n", " Downloading pyparsing-3.1.2-py3-none-any.whl.metadata (5.1 kB)\n", "Requirement already satisfied: python-dateutil>=2.7 in /opt/homebrew/Cellar/jupyterlab/4.1.6_1/libexec/lib/python3.12/site-packages (from matplotlib) (2.9.0.post0)\n", "Requirement already satisfied: six>=1.5 in /opt/homebrew/Cellar/jupyterlab/4.1.6_1/libexec/lib/python3.12/site-packages (from python-dateutil>=2.7->matplotlib) (1.16.0)\n", "Downloading matplotlib-3.9.0-cp312-cp312-macosx_11_0_arm64.whl (7.8 MB)\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m7.8/7.8 MB\u001b[0m \u001b[31m14.1 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m00:01\u001b[0m00:01\u001b[0m\n", "\u001b[?25hDownloading contourpy-1.2.1-cp312-cp312-macosx_11_0_arm64.whl (245 kB)\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m245.3/245.3 kB\u001b[0m \u001b[31m7.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", "\u001b[?25hUsing cached cycler-0.12.1-py3-none-any.whl (8.3 kB)\n", "Downloading fonttools-4.53.0-cp312-cp312-macosx_11_0_arm64.whl (2.2 MB)\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m2.2/2.2 MB\u001b[0m \u001b[31m13.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m00:01\u001b[0m00:01\u001b[0m\n", "\u001b[?25hUsing cached kiwisolver-1.4.5-cp312-cp312-macosx_11_0_arm64.whl (64 kB)\n", "Downloading pillow-10.3.0-cp312-cp312-macosx_11_0_arm64.whl (3.4 MB)\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m3.4/3.4 MB\u001b[0m \u001b[31m13.9 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m00:01\u001b[0m00:01\u001b[0m\n", "\u001b[?25hDownloading pyparsing-3.1.2-py3-none-any.whl (103 kB)\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m103.2/103.2 kB\u001b[0m \u001b[31m4.9 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", "\u001b[?25hInstalling collected packages: pyparsing, pillow, kiwisolver, fonttools, cycler, contourpy, matplotlib\n", "Successfully installed contourpy-1.2.1 cycler-0.12.1 fonttools-4.53.0 kiwisolver-1.4.5 matplotlib-3.9.0 pillow-10.3.0 pyparsing-3.1.2\n" ] } ], "source": [ "import sys\n", "!{sys.executable} -m pip install numpy\n", "!{sys.executable} -m pip install scipy\n", "!{sys.executable} -m pip install matplotlib\n" ] }, { "cell_type": "code", "execution_count": 1, "id": "3d02afe8-a522-4b2b-875a-2e3004634c30", "metadata": {}, "outputs": [], "source": [ "import scipy.io.wavfile as wav\n", "import numpy as np\n", "import matplotlib.pyplot as plt\n" ] }, { "cell_type": "code", "execution_count": 2, "id": "6b85a0d1-6f28-4b0e-b02d-8c61aa55ae7e", "metadata": {}, "outputs": [], "source": [ "# Writes a WAV file of rendered data\n", "def wavwrite(filename, samples, sample_rate):\n", " wav.write(filename, int(sample_rate), (32768.0 * samples).astype(np.int16))\n", "\n", "def wavread(filename):\n", " sample_rate, samples = wav.read(filename)\n", " return samples.astype(np.float32) / 32768.0, sample_rate\n" ] }, { "cell_type": "code", "execution_count": 36, "id": "d9f238c9-e5b6-4445-89df-768bb2dc23d8", "metadata": {}, "outputs": [], "source": [ "#test_name = 'TestSineOsc'\n", "#test_name = 'TestFilter'\n", "#test_name = 'TestFilter24'\n", "#test_name = 'TestFilterLFO'\n", "#test_name = 'TestChorus'\n", "#test_name = 'TestPulseOsc'\n", "#test_name = 'TestPcm'\n", "#test_name = 'TestSineEnv'\n", "#test_name = 'TestAlgo'\n", "#test_name = 'TestLFO'\n", "#test_name = 'TestPartial'\n", "#test_name = 'TestDuty'\n", "#test_name = 'TestBrass'\n", "#test_name = 'TestSawUpOsc'\n", "#test_name = 'TestGuitar'\n", "#test_name = 'TestPcmShift'\n", "#test_name = 'TestPcm'\n", "#test_name = 'TestOverload'\n", "#test_name = 'TestJunoPatch'\n", "#test_name = 'TestJunoClip'\n", "#test_name = 'TestLowVcf'\n", "#test_name = 'TestGlobalEQ'\n", "#test_name = 'TestFlutesEq'\n", "#test_name = 'TestChainedOsc'\n", "#test_name = 'TestPartial'\n", "#test_name = 'TestPartialNoteOff'\n", "test_name = 'TestInterpPartialsRetrigger'\n", "#d_ref, sr = wavread('tests/flt_ref/' + test_name + '.wav')\n", "d_ref, sr = wavread('../tests/ref/' + test_name + '.wav')\n", "d_tst, sr = wavread('../tests/tst/' + test_name + '.wav')\n", "# Scale waveforms up to int16 units.\n", "d_ref *= 32768\n", "d_tst *= 32768" ] }, { "cell_type": "code", "execution_count": 37, "id": "ba360672-c480-461b-9c94-30f916f15df8", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "(44032, 2)\n" ] } ], "source": [ "print(d_ref.shape)\n", "tt = np.arange(d_ref.shape[0]) / sr" ] }, { "cell_type": "code", "execution_count": 38, "id": "222aca09-2c6b-4344-80fd-0f87531aede2", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "" ] }, "execution_count": 38, "metadata": {}, "output_type": "execute_result" }, { "data": { "image/png": "iVBORw0KGgoAAAANSUhEUgAAA+4AAAFfCAYAAADQ7ZZHAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8hTgPZAAAACXBIWXMAAA9hAAAPYQGoP6dpAADA2UlEQVR4nOydd3wUZf7HP7ObRoCEkpAQCBBqgAAhBJJYsRyoeIq9t9Oz/FAPu955HId6nl30rHee5TzLedazIyq2JPRO6D0mFElCSd2d3x/J7j6z8519Zna2Jfm+Xy9088zzzPPs7uzufJ5vU1RVVcEwDMMwDMMwDMMwTEziiPYCGIZhGIZhGIZhGIYxhoU7wzAMwzAMwzAMw8QwLNwZhmEYhmEYhmEYJoZh4c4wDMMwDMMwDMMwMQwLd4ZhGIZhGIZhGIaJYVi4MwzDMAzDMAzDMEwMw8KdYRiGYRiGYRiGYWKYuGgvIBZwu92orKxE9+7doShKtJfDMAzDMAzDMAzDdHBUVcXBgweRlZUFhyOwTZ2FO4DKykpkZ2dHexkMwzAMwzAMwzBMJ2Pnzp3o379/wD4s3AF0794dQOsLlpKSEuXVMAzDMAzDMAzDMB2duro6ZGdne/VoIFi4A173+JSUFBbuDMMwDMMwDMMwTMQwE67N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Hxz4vwMHDoT8P/fy7FZUVJgFCxZcdZ9bbrnFuN1uk5OTY1555RXLc0cjwRjObQEAAAAAwKni5j3uAAAAAACMRBR3AAAAAAAcjOIOAAAAAICDUdwBAAAAAHAwijsAAAAAAA5GcQcAAAAAwMEo7gAAAAAAOBjFHQAAAAAAB6O4AwAAAADgYBR3AAAAAAAcjOIOAAAAAICD/Q/hhwn3U5+AkwAAAABJRU5ErkJggg==", "text/plain": [ "
" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "ii = np.arange(2000, 44000)\n", "#ii = np.arange(int(0.2 * sr), int(0.25 * sr))\n", "#ii = np.arange(38000, 42000)\n", "#ii = np.arange(24000, 28000)\n", "plt.figure(figsize=(12,4))\n", "plt.plot(tt[ii], d_ref[ii, 0], tt[ii], d_tst[ii, 0])\n", "plt.legend(['ref', 'tst'])" ] }, { "cell_type": "code", "execution_count": 39, "id": "ba7b1c1b-8b72-4363-af5a-1af66c4e8063", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "[]" ] }, "execution_count": 39, "metadata": {}, "output_type": "execute_result" }, { "data": { "image/png": "iVBORw0KGgoAAAANSUhEUgAAA+kAAAFfCAYAAAAyMY0+AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8hTgPZAAAACXBIWXMAAA9hAAAPYQGoP6dpAAAhRklEQVR4nO3df3TV5X3A8U8CJHGtCeVXYvRSq7WFKpUzkBjaHlbJmlVOW07xSJlD6uhYV3RqrBX8lf7GtXW1TpSj65nzWAbDVU9LOTiKWruR+iNgJwqsnVUoNEFmSSiUEMh3f3i4XWr4EcpNHvD1OuceD9/7PNzn0edwfPO9ubcoy7IsAAAAgH5X3N8LAAAAAF4n0gEAACARIh0AAAASIdIBAAAgESIdAAAAEiHSAQAAIBEiHQAAABIxsL8X0B+6urpi27Ztceqpp0ZRUVF/LwcAAICTXJZlsWvXrqiuro7i4kPfL39T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ePLjb9crKykPOWbNmTSxduvSIb6OfP39+tLW15R9btmw5+s0AAABAH+lVpM+bNy+KiooO+9i4cWOh1trN+vXr42Mf+1g0NjbGhz70ocOOLS0tjfLy8m4PAAAASM3A3gy+7rrr4pOf/ORhx5x11llRVVUV27dv73Z9//798dprr0VVVVWP86qqqmLfvn2xc+fObnfTW1tb3zDnxRdfjMmTJ8ecOXPi5ptv7s0WAAAAIFm9ivThw4fH8OHDjziutrY2du7cGc3NzTFu3LiIiHjssceiq6srampqepwzbty4GDRoUKxevTqmTZsWERGbNm2KzZs3R21tbX7cCy+8EBdddFHMmjUrvvKVr/Rm+QAAAJC0gny6e0TEhz/84WhtbY1FixZFZ2dnXHHFFTF+/PhYvHhxRERs3bo1Jk+eHA888EBMmDAhIiL+5m/+JlasWBH3339/lJeXx1VXXRURr//secTrb3G/6KKLor6+Pr7+9a/nX2vAgAFH9ZcHBx3tp+oBAADA8XC0HdqrO+m98Z3vfCeuvPLKmDx5chQXF8e0adPizjvvzD/f2dkZmzZtij179uSvffOb38yP7ejoiPr6+rj77rvzzz/00EPx6quvxoMPPhgPPvhg/vrb3/72ePnllwu1FQAAAOgTBbuTnjJ30gEAAOhL/fo96QAAAEDviXQAAABIhEgHAACARIh0AAAASIRIBwAAgESIdAAAAEiESAcAAIBEiHQAAABIhEgHAACARIh0AAAASIRIBwAAgESIdAAAAEiESAcAAIBEiHQAAABIhEgHAACARIh0AAAASIRIBwAAgESIdAAAAEiESAcAAIBEiHQAAABIhEgHAACARIh0AAAASIRIBwAAgESIdAAAAEiESAcAAIBEiHQAAABIhEgHAACARIh0AAAASIRIBwAAgESIdAAAAEiESAcAAIBEiHQAAABIhEgHAACARIh0AAAASIRIBwAAgESIdAAAAEiESAcAAIBEiHQAAABIhEgHAACARIh0AAAASIRIBwAAgESIdAAAAEiESAcAAIBEiHQAAABIhEgHAACARBQs0l977bW47LLLory8PAYPHhyzZ8+O3/zmN4eds3fv3pg7d24MHTo03vrWt8a0adOitbW1x7H/+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79+TzoAAADQeyIdAAAAEiHSAQAAIBEiHQAAABIh0gEAACARIh0AAAASIdIBAAAgESIdAAAAEiHSAQAAIBEiHQAAABIh0gEAACARIh0AAAASIdIBAAAgESIdAAAAEiHSAQAAIBEiHQAAABIh0gEAACARIh0AAAASIdIBAAAgESIdAAAAEiHSAQAAIBEiHQAAABIh0gEAACARIh0AAAASIdIBAAAgESIdAAAAEiHSAQAAIBEiHQAAABIh0gEAACARIh0AAAASIdIBAAAgESIdAAAAEiHSAQAAIBED+3sB/SHLsoiIaG9v7+eVAAAA8GZwsD8P9uihvCkjfdeuXRERkcvl+nklAAAAvJns2rUrKioqDvl8UXakjD8JdXV1xbZt2yLLshg5cmRs2bIlysvL+3tZcEza29sjl8s5x5ywnGFOBs4xJzpnmJNB6uc4y7LYtWtXVFdXR3HxoX/y/E15J724uDjOOOOM/NsNysvLk/yPCL3hHHOic4Y5GTjHnOicYU4GKZ/jw91BP8gHxwEAAEAiRDoAAAAk4k0d6aWlpdHY2BilpaX9vRQ4Zs4xJzpnmJOBc8yJzhnmZHCynOM35QfHAQAAQIre1HfSAQAAICUiHQAAABIh0gEAACARIh0AAAASIdIBAAAgESd9pC9cuDDOPPPMKCsri5qamnj66acPO37ZsmUxatSoKCsrizFjxsSKFSv6aKXQs96c4fvuuy8+8IEPxNve9rZ429veFnV1dUc889AXevtn8UFLliyJoqKimDp1amEXCEeht+d4586dMXfu3DjttNOitLQ03vWud/n/CvpVb8/wHXfcEe9+97vjlFNOiVwuF9dee23s3bu3j1YL3T355JPxkY98JKqrq6OoqCgeeeSRI8554okn4o//+I+jtLQ03vnOd8b9999f8HUeDyd1pC9dujQaGhqisbEx1q5dG+eff37U19fH9u3bexy/Zs2amDFjRsyePTvWrVsXU6dOjalTp8b69ev7eOXwut6e4SeeeCJmzJgRjz/+eDQ1NUUul4sPfehDsXXr1j5eOfxOb8/xQS+//HJ89rOfjQ984AN9tFI4tN6e43379sWf/umfxssvvxwPPfRQbNq0Ke677744/fTT+3jl8LrenuHFixfHvHnzorGxMTZs2BDf/va3Y+nSpXHjjTf28crhdbt3747zzz8/Fi5ceFTjf/GLX8SUKVPigx/8YDz33HNxzTXXxKc+9al49NFHC7zS4yA7iU2YMCGbO3du/tcHDhzIqqurswULFvQ4/tJLL82mTJnS7VpNTU3213/91wVdJxxKb8/w79u/f3926qmnZv/8z/9cqCXCER3LOd6/f382ceLE7B//8R+zWbNmZR/72Mf6YKVwaL09x/fcc0921llnZfv27eurJcJh9fYMz507N7vooou6XWtoaMje9773FXSdcDQiInv44YcPO+Zzn/tcdu6553a7Nn369Ky+vr6AKzs+Tto76fv27Yvm5uaoq6vLXysuLo66urpoamrqcU5TU1O38RER9fX1hxwPhXQsZ/j37dmzJzo7O2PIkCGFWiYc1rGe4y9+8YsxYsSImD17dl8sEw7rWM7x9773vaitrY25c+dGZWVlnHfeefHVr341Dhw40FfLhrxjOcMTJ06M5ubm/FviX3rppVixYkVcfPHFfbJm+EOdyG03sL8XUCg7duyIAwcORGVlZbfrlZWVsXHjxh7ntLS09Di+paWlYOuEQzmWM/z7brjhhqiurn7DH1DQV47lHP/Hf/xHfPvb347nnnuuD1YIR3Ys5/ill16Kxx57LC677LJYsWJF/PznP4/PfOYz0dnZGY2NjX2xbMg7ljP853/+57Fjx454//vfH1mWxf79++PTn/60t7tzwjhU27W3t8dvf/vbOOWUU/ppZUd20t5Jhze72267LZYsWRIPP/xwlJWV9fdy4Kjs2rUrZs6cGffdd18MGzasv5cDx6yrqytGjBgR9957b4wbNy6mT58eN910UyxatKi/lwZH5YknnoivfvWrcffdd8fatWvju9/9bvzgBz+IL33pS/29NDjpnbR30ocNGxYDBgyI1tbWbtdbW1ujqqqqxzlVVVW9Gg+FdCxn+KBvfOMbcdttt8UPf/jDeO9731vIZcJh9fYc/8///E+8/PLL8ZGPfCR/raurKyIiBg4cGJs2bYqzzz67sIuG33Msfx6fdtppMWjQoBgwYED+2ujRo6OlpSX27dsXJSUlBV0z/H/HcoZvueWWmDlzZnzqU5+KiIgxY8bE7t27Y86cOXHTTTdFcbF7faTtUG1XXl6e9F30iJP4TnpJSUmMGzcuVq9enb/W1dUVq1evjtra2h7n1NbWdhsfEbFq1apDjodCOpYzHBHxta99Lb70pS/FypUrY/z48X2xVDik3p7jUaNGxfPPPx/PPfdc/vHRj340/8msuVyuL5cPEXFsfx6/733vi5///Of5v2SKiPjv//7vOO200wQ6fe5YzvCePXveEOIH/9Ipy7LCLRaOkxO67fr7k+sKacmSJVlpaWl2//33Zy+++GI2Z86cbPDgwVlLS0uWZVk2c+bMbN68efnx//mf/5kNHDgw+8Y3vpFt2LAha2xszAYNGpQ9//zz/bUF3uR6e4Zvu+22rKSkJHvooYeyX/3qV/nHrl27+msL0Otz/Pt8ujsp6O053rx5c3bqqadmV155ZbZp06Zs+fLl2YgRI7Ivf/nL/bUF3uR6e4YbGxuzU089NfuXf/mX7KWXXsr+/d//PTv77LOzSy+9tL+2wJvcrl27snXr1mXr1q3LIiL7+7//+2zdunXZK6+8kmVZls2bNy+bOXNmfvxLL72U/dEf/VF2/fXXZxs2bMgWLlyYDRgwIFu5cmV/beGondSRnmVZ9g//8A/ZyJEjs5KSkmzChAnZT37yk/xzkyZNymbNmtVt/L/+679m73rXu7KSkpLs3HPPzX7wgx/08Yqhu96c4be//e1ZRLzh0djY2PcLh/+nt38W/38inVT09hyvWbMmq6mpyUpLS7Ozzjor+8pXvpLt37+/j1cNv9ObM9zZ2Zl9/vOfz84+++ysrKwsy+Vy2Wc+85ns17/+dd8vHLIse/zxx3v8/9yD53bWrFnZpEmT3jBn7NixWUlJSXbWWWdl//RP/9Tn6z4WRVnm/SoAAACQgpP2Z9IBAADgRCPSAQAAIBEiHQAAABIh0gEAACARIh0AAAASIdIBAAAgESIdAAAAEiHSAQAAIBEiHQAAABIh0gEAACARIh0AAAAS8X8hNNLlq5IQWgAAAABJRU5ErkJggg==", "text/plain": [ "
" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "plt.figure(figsize=(12,4))\n", "plt.plot(tt[ii], d_tst[ii, 0] - d_ref[ii, 0])" ] }, { "cell_type": "code", "execution_count": null, "id": "41731f4b-502b-4f04-914b-afe4d349cf72", "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": 39, "id": "275986c0-ec7f-46eb-bcd2-3f220a14ed65", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "0\n" ] }, { "data": { "text/plain": [ "" ] }, "execution_count": 39, "metadata": {}, "output_type": "execute_result" }, { "data": { "image/png": "iVBORw0KGgoAAAANSUhEUgAAAjwAAAGdCAYAAAAWp6lMAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy80BEi2AAAACXBIWXMAAA9hAAAPYQGoP6dpAAAlaUlEQVR4nO3de3BUZYL38V+nk064pbOQkCbSXLRQwkWjQUJ4VRhJGRzfMRmwBimG22ahxgJGjYMSVCiZS3TUFVA04g6ihWwYRgcdZOMygVVmyAAGcQUkIhsEwe7AYtJck5g+7x8W7duSxARycnny/VR1zXD6Od3Pk1PSX06f7jgsy7IEAABgsIi2ngAAAIDdCB4AAGA8ggcAABiP4AEAAMYjeAAAgPEIHgAAYDyCBwAAGI/gAQAAxots6wm0hWAwqOPHj6tHjx5yOBxtPR0AANAElmXp9OnTSkpKUkRE887ZdMrgOX78uLxeb1tPAwAAXIajR4+qb9++zdqnUwZPjx49JH37A4uNjW3j2QAAgKYIBALyer2h1/Hm6JTBc/FtrNjYWIIHAIAO5nIuR+GiZQAAYDyCBwAAGI/gAQAAxuuU1/AAANCeWJalb775RnV1dW09lTbldDoVGRlpy1fGEDwAALShmpoaffXVVzp37lxbT6Vd6Nq1q/r06SOXy9Wij0vwAADQRoLBoMrLy+V0OpWUlCSXy9VpvxDXsizV1NToxIkTKi8v16BBg5r95YKNIXgAAGgjNTU1CgaD8nq96tq1a1tPp8116dJFUVFR+uKLL1RTU6OYmJgWe2wuWgYAoI215JmMjs6unwU/YQAAYDyCBwAAGI/gAQAArcKyLM2ePVs9e/aUw+HQnj17Wu25uWgZAAC0iqKiIq1evVr/9V//pauvvlrx8fGt9twEDwAAuGI1NTU/+N05hw4dUp8+fTR69OhWmtV3CB4AANoRy7J0vrb1v3G5S5SzWd8BNHbsWA0bNkyRkZFas2aNhg8frueff17z58/Xtm3b1K1bN91xxx167rnnFB8frxkzZui1116T9O1vO+/fv78OHz5s02ouRfAAANCOnK+t05BF77X68+5fkqmuruZlwWuvvab77rtPf//731VZWanbb79d//Iv/6LnnntO58+f1yOPPKKf/exn2rJli5YtW6ZrrrlGK1eu1K5du+R0Om1aSf0IHgAAcFkGDRqk3//+95Kk3/zmN7rxxhv1u9/9LnT/qlWr5PV69dlnn+naa69Vjx495HQ65fF4Wn2uBA8AAO1Ilyin9i/JbJPnba7U1NTQ///444+1detWde/e/ZJxhw4d0rXXXntF87tSBA8AAO2Iw+Fo9ltLbaVbt26h/3/mzBn95Cc/0VNPPXXJuD59+rTmtOrVMX6iAACgXbvpppv05ptvasCAAYqMbH95wRcPAgCAKzZnzhydOnVKkydP1q5du3To0CG99957mjlzpurqWv9TZ99H8AAAgCuWlJSkv//976qrq9Mdd9yh4cOH64EHHlBcXFy7+OWoDsuyrLaeRGsLBAJyu92qqqpSbGxsW08HANBJXbhwQeXl5Ro4cKBiYmLaejrtQmM/kyt5/W775AIAALAZwQMAAIxH8AAAAOMRPAAAwHgEDwAAMB7BAwAAjEfwAAAA4xE8AADAeAQPAAAwHsEDAACabezYsXrggQeaNPbw4cNyOBzas2ePrXNqDMEDAACMR/AAAIBmmTFjht5//30tW7ZMDodDDodDH330kaZMmaKEhAR16dJFgwYN0quvvipJGjhwoCTpxhtvlMPh0NixY1t9zpGt/owAAKBhliXVnmv9543qKjkcTRq6bNkyffbZZxo2bJiWLFkiSXriiSe0f/9+/cd//Ifi4+P1+eef6/z585KknTt3auTIkfrrX/+qoUOHyuVy2baMhhA8AAC0J7XnpN8ltf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LtSf//xn3XXXXZKk66+/Xnv27NEzzzxD8DTCrv82UlNTtWfPHlVVVammpkYJCQlKS0vTiBEj7F1QB9bcY1GfqKgo3Xjjjfr8888lKbSf3+9Xnz59wh4zJSWlWfPjLS00yOVyKTU1VcXFxaFtwWBQxcXFYUV+0eDBg/XJJ59oz549odvdd9+tH/3oR9qzZ4+8Xq9cLpduvvlmlZWVhe372WefqX///ravqaOy41j8//7whz8oNTVVN9xwg+1r6ejsOBa1tbWqra1VRET4X8lOpzP0Yoz62f3fhtvtVkJCgg4ePKgPP/xQWVlZtq+po2rusahPXV2dPvnkk1DcDBw4UB6PJ+wxA4GAduzY0eTHDGnWJc7odAoLC63o6Ghr9erV1v79+63Zs2dbcXFxoY8NTp061VqwYEGD+9f3aZS33nrLioqKslauXGkdPHjQev755y2n02lt27bNzqV0eHYcC8uyrKqqKqtr167WSy+9ZNfUjWPHsRgzZow1dOhQa+vWrdb//M//WK+++qoVExNjvfjii3YuxQh2HI8//vGP1tatW61Dhw5ZGzZssPr3729NmDDBzmUYobnH4oknnrDee+8969ChQ1Zpaal17733WjExMda+fftCY5588kkrLi7Oevvtt63//u//trKysi7rY+m8pYVGTZo0SSdOnNCiRYvk8/mUkpKioqKi0AVkR44cueRfpT/kpz/9qQoKCpSfn69f/vKXuu666/Tmm2/qlltusWMJxrDjWEjffvGaZVmaPHlyS0/ZWHYci8LCQuXl5WnKlCk6deqU+vfvr9/+9rf6xS9+YccSjGLH8fjqq6+Um5sbeitl2rRpevzxx+2YvlGaeyy+/vprzZo1Sz6fT//0T/+k1NRUbd++Peyyh4cfflhnz57V7NmzVVlZqVtuuUVFRUXNvt7QYVlcgQUAAMzGNTwAAMB4BA8AADAewQMAAIxH8AAAAOMRPAAAwHgEDwAAMB7BAwAAjEfwAAAA4xE8AADAeAQPAAAwHsEDAACMR/AAAADj/T9Zuuq1ib3uAQAAAABJRU5ErkJggg==", "text/plain": [ "
" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "xcorr = np.correlate(np.mean(d_ref, axis=1), np.mean(d_tst, axis=1), mode='same')\n", "center = np.argmax(xcorr)\n", "offset = int(center - len(d_ref) / 2)\n", "print(offset)\n", "ii = np.arange(20000, 22000)\n", "plt.plot(tt[ii], d_ref[ii, 0], tt[ii], d_tst[ii - offset, 0])\n", "plt.legend(['ref', 'tst'])\n" ] }, { "cell_type": "code", "execution_count": 23, "id": "b8c11a9c-42a6-43f1-a7fd-7781043860c3", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "4.328085122666891\n" ] } ], "source": [ "print(np.log2(np.exp(3.0)))" ] }, { "cell_type": "code", "execution_count": 24, "id": "4b1108c2-d3de-4c10-871e-2101367150a4", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "-98.30169903639559\n", "4.25\n", "9.375\n" ] } ], "source": [ "print(np.log2(0.0002) * 8)\n", "print(34/8)\n", "print(75/8)" ] }, { "cell_type": "raw", "id": "f62ce11c-075c-4d9c-aed3-0e51fafee644", "metadata": {}, "source": [ "print(99/8)" ] }, { "cell_type": "code", "execution_count": null, "id": "f680446d-341c-4582-b06d-acf7f162c26d", "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.12.6" } }, "nbformat": 4, "nbformat_minor": 5 } ================================================ FILE: experiments/dx7_simulator.py ================================================ """Simulates the DX7 FM algorithms fully in Python.""" import numpy as np import fm # We add a (1 - z^-1)/(1 - 0.995 z^-1) HPF to remove low-frequency excursions. # Use scipy.signal if available, but emulate if not. try: import scipy.signal def final_hpf(x): return scipy.signal.sosfilt([[1, -1, 0, 1, -0.995, 0]], x) except ImportError: def final_hpf(x): state = 0 y = np.zeros(len(x)) # Sample-by-sample loop is slow in Python. for i in range(len(x)): new_state = x[i] + 0.995 * state y[i] = new_state - state state = new_state return y #### Pure-python DX7 simulation (emulates what AMY does). # import matplotlib.pyplot as plt # import fm # import dx7_simulator # # patch_num = 1 # E.PNO 13.1 # dx7_patch = fm.DX7Patch.from_patch_number(patch_num) # wave = dx7_simulator.synth_dx7_patch(dx7_patch) # plt.plot(wave) # fm.play_np_array(0.1*wave) def calc_loglin_eg_env(breakpoints, keyup_time=0.5, frame_rate=1000, do_exp=True, dx7_attacks=True): """Take AMY breakpoints derived from DX7 rate,level parameters and generate the actual envelope.""" # This is what amy has to do to reconstruct DX7 envelopes from the set of breakpoints. if dx7_attacks: lin_to_level_fn = fm.linear_to_dx7level level_to_lin_fn = fm.dx7level_to_linear else: lin_to_level_fn = fm.ratio_to_pitchval level_to_lin_fn = fm.pitchval_to_ratio current_level = lin_to_level_fn(breakpoints[-1][1]) current_time = 0 last_target_time = 0 output_levels = np.zeros(0) for segment, breakpoint in enumerate(breakpoints): # Work in DX7 levels. target_level = lin_to_level_fn(breakpoint[1]) target_time = breakpoint[0] release_segment = (segment == len(breakpoints) - 1) if release_segment: # Release time is diff between last two bps, regardless of elapsed time. segment_duration = target_time - last_target_time # Make the release segment have at least one sample segment_duration = np.maximum(segment_duration, 1/frame_rate) # If we've reached the release segment but the key is still down, # insert some constant-level envelope until we hit keyup time. if current_time < keyup_time: output_levels = np.concatenate( [output_levels, current_level * np.ones(int(frame_rate * (keyup_time - current_time)))]) current_time = keyup_time else: segment_duration = target_time - current_time segment_was_truncated = False if np.round(segment_duration * frame_rate) > 0: # Can be < 0 because current time is quantized. if target_time > keyup_time and not release_segment: # If we hit keyup_time but we're not yet in the release segment, # truncate this segment and move on (so we can get to release). actual_seg_duration = segment_duration - (target_time - keyup_time) segment_was_truncated = True else: actual_seg_duration = segment_duration sample_time_within_segment = np.arange(np.round(actual_seg_duration * frame_rate)) / frame_rate MIN_LEVEL = 34 ATTACK_RANGE = 75 def map_attack_level(level): """Convenience to map the upside-down offset attack exponential to the equivalent level on a decaying exponential.""" # This is used when calculating the time constant from the initial and final levels and the segment duration. return 1 - np.maximum(level - MIN_LEVEL, 0) / ATTACK_RANGE if dx7_attacks and target_level > current_level: # Attack segment # Derive t_const from delta_t and delta_level # if L = a.exp(-t/t_c) # then L1/L0 = exp(-t1/t_c)/exp(-t0/t_c) # so log(L1/L0) = (-t1/t_c) - (-t0/t_c) = (t0 - t1) /t_c # so t_c = (t1 - t0) / log(L0 / L1) # Have to convert the L = A + B (1 - exp(-kt)) levels into exp(-kt) = 1 - (L - A) / B levels mapped_current_level = map_attack_level(current_level) mapped_target_level = map_attack_level(target_level) t_const = segment_duration / np.log(mapped_current_level / mapped_target_level) # We start from the time that matches the current level. # L0 = exp(-t0 / t_c), so t0 = -t_c * log(L0) t0 = -t_const * np.log(mapped_current_level) # This is the magic equation that shapes the DX7 attack envelopes. samples = MIN_LEVEL + ATTACK_RANGE * (1 - np.exp(-(t0 + sample_time_within_segment)/t_const)) #print("current_level=", current_level, "target_level=", target_level, # "t0=", t0, "tc=", t_const, "time=", target_time) else: level_change_per_sec = (target_level - current_level) / segment_duration samples = current_level + level_change_per_sec * sample_time_within_segment #print("current_level=", current_level, "target_level=", target_level, # "chgpersec=", level_change_per_sec, "time=", target_time) output_levels = np.concatenate([output_levels, samples]) current_time = len(output_levels) / frame_rate if segment_was_truncated: # If we stopped early, start next segment from whereever we got to. current_level = output_levels[-1] else: # Normal segment completion, act like we got to the target level (to avoid errors sampling sharp peaks). current_level = target_level last_target_time = target_time if not do_exp: return output_levels else: return level_to_lin_fn(output_levels) # Basic FM with feedback, vectorized except when feedback is nonzero def fm_waveform(freq, amp=1.0, freq_mod=None, duration=1.0, sr=44100, feedback=0): """Render an FM waveform from raw parameters""" t = np.arange(int(sr * duration)) / sr if np.isscalar(amp): amp = amp * np.ones(len(t)) if np.isscalar(freq): freq = freq * np.ones(len(t)) dphi_dt = 2 * np.pi * freq / sr phi = np.cumsum(dphi_dt) if freq_mod is None: freq_mod = np.zeros(len(t)) if feedback == 0: # No feedback, vectorize. carrier = amp * np.cos(phi + 2 * np.pi * freq_mod) else: # Have to do slow loop to calculate feedback sample-by-sample. carrier = np.zeros(len(phi)) last_two = np.zeros(2) for i in range(len(phi)): sample = np.cos(phi[i] + 2 * np.pi * (freq_mod[i] + feedback * np.mean(last_two))) last_two[1] = last_two[0] last_two[0] = sample carrier[i] = amp[i] * sample return carrier def dx7_op_waveform(op, f0=440, mod=None, sr=44100, duration=1.0, keyup_time=0.5, feedback=0, lfo=None): """Render an FM waveform from the DX7Operator structure.""" n_samps = int(duration * sr) if op.ratiotuning: frequency = f0 * fm.coarse_fine_ratio(op.freq_coarse, op.freq_fine, op.freq_detune) else: frequency = fm.coarse_fine_fixed_hz(op.freq_coarse, op.freq_fine, op.freq_detune) if op.rates is not None: bps = fm.calc_loglin_eg_breakpoints(op.rates, op.levels) env = calc_loglin_eg_env(bps, frame_rate=sr, do_exp=True, keyup_time=keyup_time) else: env = np.ones(n_samps) if len(env) < n_samps: env = np.concatenate([env, fm.dx7level_to_linear(op.levels[-1]) * np.ones(n_samps - len(env))]) else: env = env[:n_samps] if lfo is not None: env = env * (1 + op.ampmodsens/3 * lfo) env *= 2 * fm.dx7level_to_linear(op.opamp) carrier = fm_waveform(frequency, amp=env, freq_mod=mod, sr=sr, duration=duration, feedback=feedback) #print("Op: rates:", op.rates, "levels:", op.levels, "freq: %.1f" % frequency, "fb", feedback, "amp:", op.opamp) return carrier # Thank you MFSA for the DX7 op structure , borrowed here \/ \/ \/ # algorithms[algo][operator] gives bits from FmOperatorFlags describing each algo algorithms = [ [0x00, 0x00, 0x00, 0x00, 0x00, 0x01], # 0 [0xc1, 0x11, 0x11, 0x14, 0x01, 0x14], # 1 [0x01, 0x11, 0x11, 0x14, 0xc1, 0x14], # 2 [0xc1, 0x11, 0x14, 0x01, 0x11, 0x14], # 3 [0x41, 0x11, 0x94, 0x01, 0x11, 0x14], # 4 [0xc1, 0x14, 0x01, 0x14, 0x01, 0x14], # 5 [0x41, 0x94, 0x01, 0x14, 0x01, 0x14], # 6 [0xc1, 0x11, 0x05, 0x14, 0x01, 0x14], # 7 [0x01, 0x11, 0xc5, 0x14, 0x01, 0x14], # 8 [0x01, 0x11, 0x05, 0x14, 0xc1, 0x14], # 9 [0x01, 0x05, 0x14, 0xc1, 0x11, 0x14], # 10 [0xc1, 0x05, 0x14, 0x01, 0x11, 0x14], # 11 [0x01, 0x05, 0x05, 0x14, 0xc1, 0x14], # 12 [0xc1, 0x05, 0x05, 0x14, 0x01, 0x14], # 13 [0xc1, 0x05, 0x11, 0x14, 0x01, 0x14], # 14 [0x01, 0x05, 0x11, 0x14, 0xc1, 0x14], # 15 [0xc1, 0x11, 0x02, 0x25, 0x05, 0x14], # 16 [0x01, 0x11, 0x02, 0x25, 0xc5, 0x14], # 17 [0x01, 0x11, 0x11, 0xc5, 0x05, 0x14], # 18 [0xc1, 0x14, 0x14, 0x01, 0x11, 0x14], # 19 [0x01, 0x05, 0x14, 0xc1, 0x14, 0x14], # 20 [0x01, 0x14, 0x14, 0xc1, 0x14, 0x14], # 21 [0xc1, 0x14, 0x14, 0x14, 0x01, 0x14], # 22 [0xc1, 0x14, 0x14, 0x01, 0x14, 0x04], # 23 [0xc1, 0x14, 0x14, 0x14, 0x04, 0x04], # 24 [0xc1, 0x14, 0x14, 0x04, 0x04, 0x04], # 25 [0xc1, 0x05, 0x14, 0x01, 0x14, 0x04], # 26 [0x01, 0x05, 0x14, 0xc1, 0x14, 0x04], # 27 [0x04, 0xc1, 0x11, 0x14, 0x01, 0x14], # 28 [0xc1, 0x14, 0x01, 0x14, 0x04, 0x04], # 29 [0x04, 0xc1, 0x11, 0x14, 0x04, 0x04], # 30 [0xc1, 0x14, 0x04, 0x04, 0x04, 0x04], # 31 [0xc4, 0x04, 0x04, 0x04, 0x04, 0x04], # 32 ] # FmOperatorFlags OUT_BUS_ONE = 0x01 OUT_BUS_TWO = 0x02 OUT_BUS_ADD = 0x04 # there is no 1 << 3 IN_BUS_ONE = 0x10 IN_BUS_TWO = 0x20 FB_IN = 0x40 FB_OUT = 0x80 # TODO: Fix pitchenv to be true_exponential # TODO: Calibrate pitchenv, lfopitchmod # TODO: Other LFO waveforms # TODO: LFO delay?? # TODO: LFO sync def dx7_f0_contour(patch, f0=440, sr=44100, duration=1.0, keyup_time=0.5): """Calculate the f0 contour including pitchenv.""" n_samps = int(sr * duration) # envelope rate scaling parameters for pitch_env timing. pitch_bps = fm.calc_loglin_eg_breakpoints(patch.pitch_rates, patch.pitch_levels, dx7_attacks=False, rate_double_interval=20, rate_scale=11, rate_offset=-6) pitch_env = calc_loglin_eg_env(pitch_bps, frame_rate=sr, keyup_time=keyup_time, dx7_attacks=False) if len(pitch_env) < n_samps: pitch_env = np.concatenate([pitch_env, pitch_bps[-1][1]*np.ones(n_samps - len(pitch_env))]) else: pitch_env = pitch_env[:n_samps] pitch_env = f0 * pitch_env return pitch_env def dx7_lfo(patch, sr=44100, duration=1.0): """Synthesize the lfo waveform for this patch.""" lfo_freq = fm.lfo_speed_to_hz(patch.lfospeed) amp = 1 feedback = 0 if patch.lfowaveform == 1: # Saw_down # High feedback makes a reasonable saw. feedback = 0.25 elif patch.lfowaveform == 2: # Saw_up feedback = 0.25 amp = -1 # Triangle, Pulse, and Sine are all just sine. lfo_wave = fm_waveform(lfo_freq, amp=amp, sr=sr, duration=duration, feedback=feedback) return lfo_wave def ampmoddepth_to_linear(ampmoddepth): """Convert ampmoddepth to linear gain on lfo waveform.""" if ampmoddepth < 40: ampmoddb = ampmoddepth / 10 elif ampmoddepth < 70: ampmoddb = ampmoddepth / 5 - 4 elif ampmoddepth < 90: ampmoddb = ampmoddepth / 2 - 25 else: ampmoddb = ampmoddepth - 70 # We want to return g : (1+g)/(1-g) = 10*(ampmoddb/20) = k # so 1 + g = k - kg # so g(1 + k) = k - 1 # so g = (k - 1)/(k + 1) k = 10 ** (ampmoddb/20) return (k - 1)/(k + 1) def synth_dx7_patch(patch, f0=440, sr=44100, duration=1.0, keyup_time=0.5): lfo_wave = dx7_lfo(patch, sr, duration) f0_contour = dx7_f0_contour(patch, f0, sr, duration, keyup_time) f0_contour *= 1 + 0.25 * fm.dx7level_to_linear(patch.lfopitchmoddepth) * lfo_wave num_samples = int(sr * duration) bus_one = np.zeros(num_samples) bus_two = np.zeros(num_samples) bus_add = np.zeros(num_samples) print('algo=', patch.algo) for opnum, op in enumerate(patch.ops): print('op=', 6 - opnum) opflags = algorithms[patch.algo][opnum] mod_in = np.zeros(num_samples) feedback = 0 if opflags & IN_BUS_ONE: mod_in = bus_one print('mod_in = bus_one') if opflags & IN_BUS_TWO: mod_in = bus_two print('mod_in = bus_two') if opflags & FB_IN: feedback = 0.00125 * (2 ** patch.feedback) print('fb=', feedback) if (opflags & FB_OUT) == 0: print("**warning: FB_OUT different from FB_IN") samples = dx7_op_waveform(op, f0=f0_contour, mod=mod_in, sr=sr, duration=duration, keyup_time=keyup_time, feedback=feedback, lfo=ampmoddepth_to_linear(patch.lfoampmoddepth)*lfo_wave) if opflags & OUT_BUS_ONE: if opflags & OUT_BUS_ADD: # OUT_BUS_ADD | OUT_BUS_X means add on to BUS_X bus_one = (bus_one + samples) print('bus_one = bus_one + samples') else: bus_one = samples print('bus_one = samples') if opflags & OUT_BUS_TWO: if opflags & OUT_BUS_ADD: # OUT_BUS_ADD | OUT_BUS_X means add on to BUS_X bus_two = (bus_two + samples) print('bus_two = bus_two + samples') else: bus_two = samples print('bus_two = samples') if (opflags & OUT_BUS_ADD) and ((opflags & (OUT_BUS_ONE | OUT_BUS_TWO)) == 0): # Bare OUT_BUS_ADD (0x4). bus_add += samples print('bus_add += samples') # Apply HPF - 0.003/3.14 * 22050 = 22 Hz bus_add = final_hpf(bus_add) return bus_add ================================================ FILE: experiments/make_piano_examples.ipynb ================================================ { "cells": [ { "cell_type": "markdown", "id": "e208aa51-4e26-4487-b80d-df83fdc00277", "metadata": {}, "source": [ "# make_piano_examples\n", "\n", "Quick notebook to compose sound examples for my planned blog post about piano synthesis." ] }, { "cell_type": "code", "execution_count": null, "id": "d83c04c3-309e-4364-a3cc-eb3d31ee2977", "metadata": {}, "outputs": [], "source": [ "import os\n", "import time\n", "\n", "import matplotlib.pyplot as plt\n", "import numpy as np\n", "import scipy.io.wavfile as wav\n", "import scipy.signal\n", "\n", "from IPython.display import Audio" ] }, { "cell_type": "code", "execution_count": null, "id": "4ec3aed7-be52-486d-974c-b927df746c7a", "metadata": {}, "outputs": [], "source": [ "# Spectrogram display, copied from piano_heterodyne.\n", "\n", "from scipy import fft\n", "\n", "def dB(x):\n", " return 20 * np.log10(np.abs(x))\n", "\n", "def spectrogram(x, fft_len=1024, win_len=None, hop_len=None, window_fn=np.hanning, sr=1, f_max=None, title=None):\n", " if win_len is None:\n", " win_len = fft_len\n", " if hop_len is None:\n", " hop_len = win_len // 2\n", " # Window.\n", " prepad_len = (fft_len - win_len) // 2\n", " win = np.hstack([np.zeros(prepad_len), window_fn(win_len), np.zeros(fft_len - win_len - prepad_len)])\n", " # Frame.\n", " frame_indices = np.arange(0, len(x) - win_len, hop_len)[:, np.newaxis] + np.arange(win_len)[np.newaxis, :]\n", " x_chunks_windowed = x[frame_indices] * win[np.newaxis, :]\n", " # Transform.\n", " stft_mag_db = dB(fft.fft(x_chunks_windowed, n=fft_len)[:, :(fft_len // 2 + 1)])\n", " num_frames, num_bins = stft_mag_db.shape\n", " t_base = np.arange(num_frames) * hop_len / sr\n", " f_base = np.arange(num_bins) * sr / fft_len\n", " plt.imshow(stft_mag_db.T, aspect='auto', origin='lower', extent=[t_base[0], t_base[-1], f_base[0], f_base[-1]])\n", " plt.clim(np.max(stft_mag_db) + [-80, 0])\n", " #plt.ylim([0, f_max / sr * fft_len])\n", " if f_max:\n", " plt.ylim([0, f_max])\n", " #x_times = np.arange(0, len(x) / sr, 0.25)\n", " #y_freqs = np.arange(0, 10000, 1000)\n", " #plt.xticks(x_times * sr / hop_len, x_times)\n", " #plt.yticks(y_freqs / sr * fft_len, y_freqs)\n", " plt.colorbar(label='level / dB')\n", " plt.xlabel('time / sec')\n", " plt.ylabel('freq / kHz')\n", " if title:\n", " plt.title(title)\n" ] }, { "cell_type": "code", "execution_count": null, "id": "d509e7f7-6f86-456b-a157-f2016154b793", "metadata": {}, "outputs": [], "source": [ "# Load in the original piano samples, copied from piano_heterodyne\n", "\n", "def wavread(filename):\n", " \"\"\"Read in audio data from a wav file. Return d, sr.\"\"\"\n", " # Read in wav file.\n", " file_handle = open(filename, 'rb')\n", " samplerate, wave_data = wav.read(file_handle)\n", " # Normalize short ints to floats in range [-1..1).\n", " data = np.asarray(wave_data, dtype=np.float32) / 32768.0\n", " return data, samplerate\n", "\n", "def wavwrite(data, samplerate, filename):\n", " \"\"\"Write a waveform to a WAV file.\"\"\"\n", " wav.write(filename, samplerate, (32768.0 * data).astype(np.int16))\n", "\n", "def read_and_trim(filename, duration=2.0, rel_threshold=0.015, abs_threshold=0.0006, sr=44100, channel=0, do_plot=False, pre_time=0.002):\n", " d, file_sr = wavread(filename)\n", " #print(\"d.shape=\", d.shape)\n", " if len(d.shape) > 1: # Stereo file\n", " if channel is None:\n", " d = np.mean(d, axis=-1)\n", " else:\n", " d = d[:, channel]\n", " assert file_sr == sr\n", " d = d - np.mean(d)\n", " threshold = np.maximum(np.max(np.abs(d)) * rel_threshold, abs_threshold)\n", " # Tight window at start?\n", " drop_initial_samps = np.maximum(0, -int(round(pre_time * sr)) + np.min(np.flatnonzero(np.abs(d) > threshold)))\n", " d_return = d[int(round(drop_initial_samps)) + np.arange(int(round(duration * sr)))]\n", " if do_plot:\n", " t = np.arange(len(d)) / sr\n", " plt.figure(figsize=(12, 4))\n", " plt.subplot(121)\n", " plt.plot(t[:50000], d[:50000])\n", " plt.ylim(threshold * np.array([-1, 1]))\n", " plt.subplot(122)\n", " plt.plot(t[:len(d_return)], d_return)\n", " plt.xlim([0, 0.1])\n", " print(\"drop initial\", drop_initial_samps / sr)\n", " return d_return\n", "\n", "def piano_filename(note='C', octave=4, strike='ff'):\n", " #filename = 'Piano.ff.D4.wav'\n", " directory = '/Users/dpwe/Downloads/uiowa-piano'\n", " #octave = 2\n", " #note = 'D'\n", " #octave = 4\n", " #note = 'Eb'\n", " #strike = 'ff' # ['pp', 'mf', 'ff']:\n", " filename = os.path.join(directory, '.'.join(['Piano', strike, note + str(octave), 'wav']))\n", " return filename\n", "\n", "filename = piano_filename('D', 4)\n", "print(filename)\n", "waveform = read_and_trim(filename)\n", "_, sr = wavread(filename)\n", "Audio(data=waveform.T, rate=sr)" ] }, { "cell_type": "code", "execution_count": null, "id": "d9a44a35-b787-433d-aaee-4f9525d5d178", "metadata": {}, "outputs": [], "source": [ "# Give it a 50ms fade-out\n", "def fade_out(waveform, fade_end_sec=0.5, fade_duration_sec=0.05, sample_rate=44100):\n", " \"\"\"Apply a fade-out to a waveform.\"\"\"\n", " fade_end_samples = int(round(fade_end_sec * sample_rate))\n", " fade_duration_samples = int(round(fade_duration_sec * sample_rate))\n", " fade_start_samples = fade_end_samples - fade_duration_samples\n", " mask = np.ones_like(waveform)\n", " mask[fade_start_samples : fade_start_samples + fade_duration_samples] = np.linspace(1, 0, fade_duration_samples)\n", " mask[fade_start_samples + fade_duration_samples:] = 0\n", " return mask * waveform\n", "\n", "fade_waveform = fade_out(waveform)\n", "#plt.plot(fade_waveform)\n", "Audio(data=fade_waveform.T, rate=sr)" ] }, { "cell_type": "code", "execution_count": null, "id": "dbcfeb1a-8d63-448b-9588-502a8a19340a", "metadata": {}, "outputs": [], "source": [ "# Compose the 3s (time, note, vel) sequence from piano_examples.py\n", "\n", "def emplace(main_waveform, waveform_to_add, start_time_sec, sample_rate=44100):\n", " \"\"\"Add-in a waveform to a background at a given time, truncate as needed.\"\"\"\n", " start_time_samples = int(round(start_time_sec * sample_rate))\n", " length_to_use = min(len(waveform_to_add), len(main_waveform) - start_time_samples)\n", " main_waveform[start_time_samples : start_time_samples + length_to_use] += waveform_to_add[:length_to_use]\n", " return main_waveform\n", "\n", "sr = 44100\n", "waveform = np.zeros(int(round(3.3 * sr)))\n", "\n", "waveform = emplace(waveform, fade_out(read_and_trim(piano_filename('D', 4, 'pp')), 0.4), 0.05)\n", "waveform = emplace(waveform, fade_out(read_and_trim(piano_filename('D', 4, 'mf')), 0.4), 0.45)\n", "waveform = emplace(waveform, fade_out(read_and_trim(piano_filename('D', 4, 'ff')), 0.65), 0.85)\n", "\n", "waveform = emplace(waveform, fade_out(read_and_trim(piano_filename('D', 2, 'mf')), 1.8), 1.5)\n", "waveform = emplace(waveform, fade_out(read_and_trim(piano_filename('D', 6, 'ff')), 1.2), 2.1)\n", "\n", "Audio(data=waveform.T, rate=sr) " ] }, { "cell_type": "code", "execution_count": null, "id": "9cdb36a0-50fa-46c0-8be0-308cf549eb13", "metadata": {}, "outputs": [], "source": [ "wavwrite(waveform, sr, '../sounds/piano_example_original.wav')" ] }, { "cell_type": "code", "execution_count": null, "id": "dad756fb-08e0-4653-8fa4-c7d495328f2d", "metadata": {}, "outputs": [], "source": [ "filename = '../sounds/piano_example_original.wav'\n", "waveform, sr = wavread(filename)\n", "plt.figure(figsize=(16, 4))\n", "spectrogram(waveform, sr=sr, f_max=8000, title='UIowa Samples')\n", "Audio(data=waveform, rate=sr)" ] }, { "cell_type": "code", "execution_count": null, "id": "79ab2480-bd38-4b53-b95e-83dd7c85dc45", "metadata": {}, "outputs": [], "source": [ "filename = '../sounds//piano_example_juno_patch_7.wav'\n", "waveform, sr = wavread(filename)\n", "plt.figure(figsize=(16, 4))\n", "spectrogram(waveform, sr=sr, f_max=8000, title='Juno-60 piano')\n", "Audio(data=waveform, rate=sr)" ] }, { "cell_type": "code", "execution_count": null, "id": "1436640c-56ca-4049-8ff2-d645ea39abe2", "metadata": {}, "outputs": [], "source": [ "filename = '../sounds//piano_example_dx7_patch_137.wav'\n", "waveform, sr = wavread(filename)\n", "plt.figure(figsize=(16, 4))\n", "spectrogram(waveform, sr=sr, f_max=8000, title='DX7 piano')\n", "Audio(data=waveform, rate=sr)" ] }, { "cell_type": "code", "execution_count": null, "id": "27ad0bd1-7b2d-45ab-9902-591cfd0d4691", "metadata": {}, "outputs": [], "source": [ "filename = '../sounds/piano_example_additive_fixed.wav'\n", "waveform, sr = wavread(filename)\n", "plt.figure(figsize=(16, 4))\n", "spectrogram(waveform, sr=sr, f_max=8000, title='Fixed-envelope additive piano')\n", "Audio(data=waveform, rate=sr)" ] }, { "cell_type": "code", "execution_count": null, "id": "06ff335b-4aba-437e-837b-ccbde61498ed", "metadata": {}, "outputs": [], "source": [ "filename = '../sounds//piano_example_additive_interpolated.wav'\n", "waveform, sr = wavread(filename)\n", "plt.figure(figsize=(16, 4))\n", "spectrogram(waveform, sr=sr, f_max=8000, title='Interpolated additive piano')\n", "Audio(data=waveform, rate=sr)" ] }, { "cell_type": "code", "execution_count": null, "id": "d0ee56a1-8391-42c8-b1ac-c9c193a6d02f", "metadata": {}, "outputs": [], "source": [ "# Repeat original again\n", "filename = '../sounds//piano_example_original.wav'\n", "waveform, sr = wavread(filename)\n", "plt.figure(figsize=(16, 4))\n", "spectrogram(waveform, sr=sr, f_max=8000, title='UIowa Samples')\n", "Audio(data=waveform, rate=sr)" ] }, { "cell_type": "code", "execution_count": null, "id": "c5825360-1d12-4694-b40d-b051406c7395", "metadata": {}, "outputs": [], "source": [ "# Plot FFT to illustrate two-sided spectrum\n", "from scipy import fft\n", "\n", "def plotspec(d, n_fft=4096, sr=44100, f_max=6000, title=None, db_range=80):\n", " X = fft.fft(d[:n_fft] * np.hanning(n_fft))\n", " # FFT shift to put zero in the middle.\n", " fft_keep_points = int(round(f_max / sr * n_fft))\n", " X = np.hstack([X[-fft_keep_points:], X[:fft_keep_points]])\n", " freqs = np.arange(-fft_keep_points, fft_keep_points) * sr / n_fft / 1000\n", " db_X = dB(X)\n", " plt.plot(freqs, db_X)\n", " db_max = 10 * np.ceil(np.max(db_X) / 10)\n", " plt.ylim([db_max - db_range, db_max])\n", " plt.xlabel('freq / kHz')\n", " plt.ylabel('level / dB')\n", " plt.grid()\n", " if title:\n", " plt.title(title)\n", "\n", "d = read_and_trim(piano_filename('D', 4, 'ff'))\n", "# Skip first 0.2 s to exclude \"thump\"\n", "plt.figure(figsize=(16, 4))\n", "plotspec(d[int(round(0.2 * sr)):], title='D4.ff spectrum', f_max=3000)" ] }, { "cell_type": "code", "execution_count": null, "id": "05d60937-faa2-4c92-b6be-9e7d088fdbfc", "metadata": {}, "outputs": [], "source": [ "# Demodulate by multiplying by complex exponential\n", "f0 = 293.665 # Nominal frequency of D4\n", "d_demod = d * np.exp(-1j * 2 * np.pi * f0 * np.arange(len(d))/ sr)\n", "plotspec(d_demod[int(round(0.2 * sr)):] , title='D4.ff shifted down by f0', f_max=3000)\n", "f0_on_2 = f0 / 2000\n", "plt.figure(figsize=(16, 4))\n", "plt.plot([-f0_on_2, f0_on_2, f0_on_2, -f0_on_2, -f0_on_2], [38, 38, -38, -38, 38], '--r')" ] }, { "cell_type": "code", "execution_count": null, "id": "f65bcd09-1940-40db-ba04-ef1b01ff726d", "metadata": {}, "outputs": [], "source": [ "# Low-pass demodulated waveform to recover harmonic envelope.\n", "\n", "def demod_and_smooth(d, f0, harmonic=1, sr=44100):\n", " d_demod = d * np.exp(-1j * 2 * np.pi * f0 * harmonic * np.arange(len(d))/ sr)\n", " fundamental_period_samples = int(round(sr / f0))\n", " d_demod_smoo = np.convolve(d_demod, np.hanning(2 * fundamental_period_samples), 'same')\n", " return d_demod_smoo\n", "\n", "t = np.arange(len(d)) / sr\n", "plt.figure(figsize=(16, 6))\n", "\n", "plt.subplot(211)\n", "plt.plot(t, d)\n", "plt.ylabel('amplitude')\n", "plt.title('D4.ff waveform')\n", "\n", "plt.subplot(212)\n", "plt.plot(t, dB(demod_and_smooth(d, f0)))\n", "plt.plot(t, dB(demod_and_smooth(d, f0, harmonic=2)))\n", "plt.plot(t, dB(demod_and_smooth(d, f0, harmonic=3)))\n", "plt.plot(t, dB(demod_and_smooth(d, f0, harmonic=4)))\n", "plt.ylim([-15, 25])\n", "plt.title('Extracted harmonic envelopes')\n", "plt.xlabel('time / sec')\n", "plt.ylabel('level / dB')\n", "plt.legend(['%d - %.2f Hz' % (n, n * f0) for n in range(1, 5)])" ] }, { "cell_type": "code", "execution_count": null, "id": "df559105-e346-45eb-bf66-7ee59c6da5b3", "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.12.6" } }, "nbformat": 4, "nbformat_minor": 5 } ================================================ FILE: experiments/piano-params.json ================================================ {"sample_times_ms": [4, 8, 12, 16, 24, 32, 48, 64, 96, 128, 192, 256, 384, 512, 768, 1024, 1536, 2048, 3072, 4096], "notes": [24, 28, 32, 36, 40, 44, 48, 52, 56, 60, 64, 68, 72, 76, 80, 84, 88, 92, 96, 100, 104], "velocities": [40, 80, 120], "num_harmonics": [40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 37, 33, 32, 23, 28, 26, 22, 22, 21, 17, 17, 17, 13, 13, 13, 11, 11, 11, 8, 8, 9, 7, 7, 7, 6, 5, 5, 3, 4, 4], "harmonics_freq": [2272, 3586, 4290, 4791, 5181, 5498, 5767, 5996, 6209, 6397, 6566, 6721, 6865, 6999, 7124, 7243, 7356, 7462, 7562, 7660, 7752, 7841, 7928, 8009, 8091, 8171, 8246, 8321, 8398, 8464, 8565, 8629, 8704, 8765, 8826, 8895, 8955, 9012, 9069, 9128, 2172, 3587, 4287, 4787, 5175, 5493, 5762, 5996, 6205, 6393, 6561, 6716, 6860, 6993, 7118, 7237, 7348, 7456, 7555, 7652, 7744, 7833, 7918, 8001, 8081, 8166, 8233, 8306, 8376, 8446, 8514, 8579, 8643, 8706, 8768, 8828, 8891, 8945, 8995, 9035, 2394, 3588, 4289, 4787, 5176, 5495, 5764, 5998, 6207, 6395, 6564, 6717, 6862, 6995, 7120, 7241, 7351, 7458, 7557, 7654, 7746, 7835, 7920, 8003, 8082, 8221, 8235, 8310, 8378, 8448, 8515, 8581, 8645, 8708, 8819, 8854, 8901, 8997, 9036, 9079, 2851, 3989, 4692, 5187, 5576, 5893, 6161, 6394, 6600, 6785, 6952, 7105, 7246, 7379, 7501, 7616, 7724, 7828, 7926, 8019, 8108, 8193, 8275, 8355, 8434, 8505, 8574, 8641, 8710, 8774, 8836, 8891, 8945, 8996, 9053, 9115, 9147, 9206, 9252, 9304, 3069, 3987, 4692, 5187, 5577, 5892, 6161, 6393, 6600, 6784, 6952, 7105, 7246, 7379, 7501, 7616, 7725, 7828, 7926, 8019, 8108, 8193, 8275, 8354, 8435, 8509, 8578, 8643, 8712, 8775, 8838, 8893, 8941, 9006, 9065, 9127, 9177, 9239, 9266, 9333, 3008, 3989, 4693, 5188, 5577, 5894, 6162, 6395, 6601, 6785, 6953, 7106, 7247, 7379, 7502, 7617, 7726, 7829, 7927, 8019, 8109, 8194, 8277, 8355, 8438, 8511, 8580, 8645, 8713, 8776, 8839, 8901, 8961, 9019, 9075, 9133, 9182, 9249, 9267, 9351, 3114, 4391, 5094, 5596, 5984, 6300, 6567, 6804, 7008, 7191, 7358, 7512, 7653, 7784, 7906, 8022, 8130, 8233, 8330, 8424, 8512, 8595, 8679, 8764, 8838, 8906, 8978, 9049, 9121, 9171, 9242, 9305, 9364, 9424, 9482, 9536, 9593, 9645, 9697, 9750, 3224, 4390, 5096, 5595, 5983, 6299, 6567, 6799, 7006, 7190, 7358, 7512, 7653, 7784, 7906, 8022, 8129, 8232, 8329, 8422, 8511, 8595, 8677, 8758, 8856, 8970, 8986, 9105, 9169, 9231, 9291, 9350, 9408, 9473, 9539, 9582, 9664, 9723, 9771, 9820, 3275, 4391, 5099, 5598, 5985, 6300, 6567, 6805, 7008, 7191, 7358, 7513, 7654, 7785, 7907, 8022, 8130, 8233, 8330, 8423, 8511, 8595, 8678, 8755, 8855, 8900, 8980, 9041, 9106, 9170, 9232, 9291, 9350, 9407, 9472, 9518, 9574, 9624, 9669, 9724, 3610, 4789, 5497, 5999, 6386, 6702, 6972, 7205, 7411, 7596, 7763, 7916, 8055, 8189, 8314, 8427, 8551, 8655, 8819, 8852, 8923, 9072, 9156, 9232, 9311, 9384, 9453, 9521, 9595, 9674, 9748, 9812, 9878, 9942, 10004, 10068, 10130, 10187, 10246, 10303, 3623, 4792, 5493, 5999, 6385, 6702, 6972, 7205, 7411, 7596, 7763, 7916, 8054, 8189, 8313, 8426, 8537, 8638, 8737, 8831, 8919, 9004, 9084, 9164, 9257, 9321, 9389, 9515, 9580, 9643, 9707, 9766, 9818, 9885, 9934, 9984, 10050, 10096, 10160, 10207, 3646, 4792, 5491, 6000, 6386, 6703, 6973, 7206, 7412, 7597, 7764, 7918, 8054, 8190, 8313, 8427, 8539, 8639, 8738, 8832, 8920, 9005, 9086, 9165, 9259, 9322, 9390, 9518, 9583, 9644, 9707, 9765, 9823, 9889, 9937, 9984, 10040, 10096, 10160, 10205, 4008, 5200, 5904, 6403, 6790, 7106, 7376, 7608, 7815, 7998, 8165, 8318, 8460, 8591, 8715, 8826, 8939, 9042, 9139, 9229, 9318, 9402, 9480, 9562, 9644, 9713, 9780, 9846, 9911, 9977, 10038, 10101, 10158, 10216, 10274, 10346, 10385, 10434, 10486, 10536, 4008, 5200, 5903, 6403, 6789, 7106, 7376, 7607, 7815, 7999, 8165, 8318, 8460, 8591, 8714, 8828, 8937, 9039, 9137, 9228, 9318, 9401, 9484, 9568, 9659, 9718, 9782, 9847, 9916, 9977, 10038, 10099, 10186, 10265, 10321, 10370, 10421, 10477, 10531, 10576, 4010, 5201, 5903, 6404, 6790, 7108, 7376, 7608, 7816, 7999, 8166, 8318, 8461, 8592, 8714, 8829, 8938, 9040, 9137, 9228, 9318, 9402, 9484, 9564, 9658, 9714, 9784, 9847, 9913, 9976, 10038, 10096, 10165, 10272, 10317, 10379, 10428, 10480, 10529, 10566, 4398, 5600, 6302, 6802, 7189, 7506, 7774, 8007, 8213, 8398, 8566, 8720, 8860, 8992, 9130, 9234, 9347, 9448, 9543, 9645, 9727, 9809, 9903, 9985, 10063, 10138, 10214, 10287, 10349, 10419, 10481, 10547, 10605, 10668, 10731, 10784, 10842, 10897, 10950, 11004, 4398, 5599, 6303, 6801, 7188, 7507, 7773, 8006, 8213, 8397, 8565, 8717, 8858, 8990, 9112, 9227, 9334, 9438, 9536, 9629, 9716, 9802, 9884, 9962, 10042, 10112, 10182, 10252, 10328, 10380, 10443, 10506, 10573, 10632, 10685, 10739, 10792, 10851, 10906, 10960, 4400, 5598, 6304, 6803, 7190, 7508, 7775, 8008, 8215, 8398, 8566, 8718, 8860, 8991, 9113, 9228, 9337, 9440, 9536, 9629, 9718, 9803, 9885, 9963, 10045, 10112, 10182, 10250, 10316, 10381, 10443, 10535, 10556, 10623, 10679, 10735, 10788, 10841, 10893, 10945, 4782, 6001, 6703, 7203, 7591, 7907, 8175, 8410, 8623, 8800, 8966, 9124, 9265, 9407, 9526, 9658, 9778, 9886, 9995, 10084, 10175, 10271, 10349, 10437, 10516, 10592, 10669, 10744, 10818, 10887, 10956, 11022, 11087, 11151, 11223, 11277, 11336, 11398, 11454, 11511, 4797, 6000, 6702, 7204, 7591, 7907, 8174, 8407, 8615, 8797, 8964, 9117, 9258, 9389, 9511, 9625, 9735, 9837, 9934, 10027, 10115, 10200, 10281, 10353, 10441, 10507, 10580, 10646, 10715, 10779, 10842, 10904, 10967, 11024, 11085, 11137, 11194, 11247, 11299, 11352, 4801, 6002, 6703, 7205, 7592, 7908, 8176, 8408, 8616, 8798, 8966, 9118, 9259, 9390, 9512, 9626, 9736, 9838, 9934, 10028, 10115, 10201, 10282, 10360, 10438, 10508, 10578, 10646, 10713, 10777, 10839, 10899, 10966, 11016, 11074, 11128, 11183, 11238, 11287, 11343, 5204, 6408, 7107, 7608, 7994, 8311, 8580, 8812, 9020, 9202, 9373, 9527, 9666, 9802, 9927, 10042, 10158, 10256, 10348, 10446, 10535, 10617, 10702, 10777, 10853, 10924, 10996, 11059, 11131, 11196, 11250, 11317, 11392, 11437, 11491, 11545, 11599, 11653, 11696, 11753, 5206, 6408, 7107, 7608, 7994, 8311, 8580, 8812, 9019, 9205, 9372, 9526, 9667, 9799, 9916, 10038, 10147, 10251, 10349, 10444, 10533, 10620, 10701, 10779, 10855, 10928, 11001, 11069, 11136, 11202, 11250, 11313, 11384, 11428, 11486, 11544, 11589, 11644, 11689, 11743, 5208, 6409, 7108, 7609, 7995, 8312, 8581, 8812, 9020, 9205, 9373, 9527, 9668, 9800, 9922, 10039, 10147, 10252, 10351, 10443, 10534, 10619, 10702, 10781, 10857, 10931, 11005, 11073, 11141, 11208, 11269, 11332, 11396, 11452, 11510, 11567, 11622, 11679, 11729, 11778, 5606, 6807, 7508, 8009, 8396, 8714, 8994, 9205, 9428, 9629, 9787, 9941, 10072, 10212, 10347, 10463, 10569, 10668, 10765, 10858, 10948, 11037, 11116, 11197, 11272, 11348, 11401, 11485, 11557, 11622, 11686, 11749, 11810, 11870, 11933, 11986, 12040, 12095, 12148, 12201, 5603, 6807, 7509, 8009, 8396, 8714, 8983, 9216, 9423, 9609, 9778, 9932, 10072, 10209, 10335, 10452, 10563, 10667, 10767, 10863, 10954, 11042, 11124, 11209, 11284, 11363, 11424, 11500, 11569, 11634, 11697, 11762, 11825, 11886, 11940, 12002, 12059, 12116, 12170, 12225, 5599, 6808, 7510, 8010, 8397, 8715, 8984, 9217, 9425, 9611, 9779, 9934, 10075, 10210, 10334, 10451, 10562, 10667, 10767, 10862, 10952, 11040, 11124, 11208, 11284, 11362, 11431, 11506, 11575, 11645, 11707, 11772, 11834, 11895, 11951, 12014, 12071, 12128, 12190, 12237, 6002, 7204, 7909, 8408, 8797, 9126, 9394, 9638, 9844, 10034, 10201, 10348, 10493, 10621, 10748, 10862, 10970, 11069, 11174, 11257, 11369, 11436, 11525, 11606, 11686, 11758, 11829, 11903, 11964, 12035, 12101, 12165, 12227, 12288, 12347, 12406, 12460, 12518, 12572, 12628, 6003, 7204, 7908, 8408, 8796, 9115, 9385, 9621, 9828, 10021, 10187, 10345, 10491, 10627, 10753, 10871, 10986, 11088, 11192, 11288, 11394, 11469, 11551, 11631, 11703, 11785, 11860, 11936, 12007, 12074, 12141, 12208, 12271, 12334, 12396, 12452, 12514, 12573, 12631, 12685, 6004, 7205, 7909, 8408, 8797, 9115, 9386, 9621, 9829, 10018, 10187, 10344, 10489, 10624, 10751, 10871, 10984, 11092, 11195, 11293, 11388, 11474, 11564, 11650, 11732, 11825, 11890, 11958, 12033, 12107, 12176, 12241, 12307, 12371, 12436, 12496, 12555, 12617, 12675, 12733, 6406, 7603, 8310, 8811, 9197, 9528, 9807, 10043, 10310, 10430, 10611, 10767, 10911, 11047, 11174, 11285, 11400, 11508, 11611, 11699, 11796, 11893, 11969, 12057, 12142, 12220, 12296, 12371, 12441, 12515, 12585, 12651, 12719, 12783, 12847, 12906, 12972, 13038, 13091, 13149, 6409, 7602, 8310, 8811, 9201, 9522, 9794, 10031, 10264, 10429, 10611, 10768, 10921, 11055, 11189, 11307, 11406, 11528, 11635, 11731, 11829, 11931, 12015, 12099, 12184, 12265, 12346, 12427, 12501, 12575, 12646, 12717, 12786, 12854, 12922, 12987, 13052, 13114, 13176, 13237, 6410, 7602, 8310, 8812, 9202, 9522, 9795, 10031, 10241, 10432, 10606, 10764, 10909, 11053, 11183, 11306, 11421, 11534, 11641, 11740, 11836, 11928, 12001, 12097, 12162, 12238, 12319, 12395, 12469, 12543, 12615, 12683, 12752, 12819, 12885, 12949, 13012, 13074, 13134, 13194, 6806, 8006, 8712, 9210, 9616, 9933, 10237, 10412, 10652, 10840, 11011, 11164, 11299, 11410, 11549, 11675, 11779, 11888, 11975, 12073, 12166, 12256, 12338, 12423, 12500, 12574, 12647, 12720, 12788, 12856, 12921, 12987, 13051, 13111, 13171, 13231, 13288, 6807, 8006, 8713, 9214, 9606, 9928, 10202, 10441, 10658, 10855, 11030, 11209, 11350, 11483, 11616, 11733, 11855, 11956, 12071, 12180, 12281, 12378, 12468, 12562, 12653, 12736, 12823, 12903, 12985, 13061, 13138, 13214, 13285, 6808, 8007, 8714, 9215, 9607, 9929, 10203, 10442, 10656, 10850, 11025, 11260, 11338, 11485, 11618, 11744, 11868, 11975, 12091, 12198, 12300, 12400, 12494, 12587, 12676, 12763, 12845, 12930, 13011, 13090, 13167, 13244, 7203, 8404, 9117, 9628, 10035, 10354, 10659, 10914, 11147, 11380, 11552, 11716, 11904, 12052, 12205, 12350, 12490, 12629, 12753, 12885, 13006, 13122, 13240, 7203, 8405, 9112, 9616, 10012, 10339, 10621, 10863, 11067, 11254, 11419, 11587, 11729, 11876, 12000, 12124, 12241, 12353, 12456, 12562, 12658, 12756, 12847, 12938, 13024, 13110, 13192, 13275, 7203, 8406, 9112, 9617, 10012, 10337, 10615, 10859, 11077, 11248, 11460, 11652, 11791, 11940, 12076, 12212, 12324, 12430, 12541, 12648, 12755, 12857, 12957, 13054, 13147, 13241, 7606, 8805, 9529, 10039, 10389, 10754, 11037, 11275, 11460, 11674, 11852, 12002, 12155, 12296, 12430, 12553, 12680, 12791, 12898, 13007, 13108, 13205, 7607, 8809, 9516, 10022, 10413, 10745, 11028, 11274, 11465, 11672, 11849, 12002, 12160, 12296, 12430, 12553, 12673, 12793, 12899, 13003, 13109, 13208, 7607, 8809, 9516, 10020, 10415, 10744, 11025, 11273, 11492, 11680, 11880, 12068, 12212, 12358, 12494, 12627, 12752, 12878, 12993, 13110, 13220, 8006, 9206, 9946, 10405, 10854, 11193, 11444, 11706, 11936, 12136, 12320, 12490, 12660, 12814, 12959, 13093, 13237, 8007, 9203, 9925, 10423, 10846, 11183, 11436, 11694, 11926, 12117, 12295, 12461, 12621, 12767, 12911, 13051, 13177, 8008, 9212, 9921, 10428, 10830, 11162, 11443, 11703, 11930, 12135, 12321, 12495, 12659, 12815, 12960, 13102, 13241, 8400, 9616, 10349, 10895, 11315, 11634, 11921, 12168, 12401, 12617, 12811, 13012, 13180, 8398, 9607, 10331, 10859, 11293, 11620, 11911, 12158, 12386, 12597, 12790, 12979, 13148, 8400, 9614, 10323, 10842, 11255, 11606, 11902, 12163, 12395, 12617, 12820, 13012, 13186, 8802, 10047, 10789, 11338, 11714, 12032, 12335, 12599, 12833, 13055, 13264, 8809, 10024, 10758, 11307, 11704, 12027, 12332, 12600, 12838, 13051, 13262, 8810, 10018, 10730, 11263, 11677, 12025, 12336, 12607, 12848, 13066, 13282, 9119, 10411, 11228, 11733, 12138, 12481, 12772, 13058, 9211, 10418, 11212, 11719, 12131, 12476, 12767, 13048, 9216, 10420, 11163, 11688, 12105, 12453, 12745, 13030, 13271, 9334, 10833, 11609, 12150, 12590, 12947, 13265, 9578, 10866, 11617, 12155, 12598, 12960, 13292, 9613, 10827, 11575, 12112, 12547, 12902, 13211, 9520, 11256, 12011, 12541, 12935, 13269, 9943, 11276, 12039, 12603, 13022, 9996, 11242, 12016, 12585, 13016, 8908, 11863, 12902, 10199, 11574, 12376, 12924, 10409, 11646, 12421, 12947], "harmonics_mags": [[39, 40, 41, 42, 37, 37, 40, 39, 42, 46, 41, 42, 44, 41, 41, 39, 42, 41, 40, 40], [51, 53, 55, 56, 55, 50, 48, 53, 49, 49, 51, 52, 53, 52, 52, 52, 53, 50, 52, 50], [65, 68, 70, 72, 73, 73, 73, 73, 73, 73, 72, 72, 72, 72, 71, 71, 70, 70, 68, 67], [69, 71, 73, 74, 75, 77, 77, 77, 74, 75, 75, 75, 75, 74, 72, 71, 69, 67, 62, 59], [69, 71, 73, 73, 74, 73, 74, 74, 75, 74, 74, 74, 73, 72, 71, 70, 67, 64, 58, 53], [68, 70, 72, 74, 75, 76, 77, 76, 72, 74, 72, 73, 72, 71, 71, 70, 68, 66, 62, 58], [52, 52, 52, 52, 53, 53, 49, 52, 53, 51, 52, 52, 52, 53, 52, 51, 51, 50, 46, 45], [43, 41, 44, 48, 54, 56, 56, 58, 59, 58, 56, 56, 50, 47, 47, 42, 39, 34, 29, 21], [48, 52, 55, 56, 59, 60, 62, 63, 62, 63, 63, 63, 62, 62, 60, 58, 56, 53, 49, 44], [56, 57, 57, 58, 59, 61, 61, 63, 63, 65, 64, 63, 62, 61, 59, 57, 53, 50, 45, 44], [47, 45, 51, 57, 62, 65, 67, 67, 66, 65, 64, 63, 62, 61, 59, 57, 53, 49, 41, 30], [61, 63, 64, 66, 68, 69, 71, 71, 71, 72, 71, 71, 70, 70, 68, 67, 64, 60, 48, 46], [58, 60, 61, 62, 63, 64, 64, 65, 66, 66, 66, 65, 65, 64, 62, 61, 58, 55, 49, 40], [45, 51, 55, 57, 61, 62, 63, 63, 62, 62, 62, 61, 61, 60, 60, 59, 57, 55, 48, 44], [51, 53, 54, 56, 57, 58, 58, 59, 61, 61, 61, 60, 60, 59, 57, 56, 51, 46, 38, 45], [45, 46, 47, 47, 47, 46, 47, 47, 42, 39, 51, 49, 46, 44, 45, 44, 43, 41, 39, 37], [46, 48, 49, 50, 50, 48, 44, 41, 42, 41, 40, 40, 37, 35, 33, 13, 29, 32, 35, 32], [48, 50, 51, 52, 53, 54, 55, 54, 54, 55, 54, 54, 53, 53, 51, 49, 45, 38, 30, 37], [50, 52, 52, 53, 53, 53, 53, 53, 52, 52, 52, 51, 51, 51, 50, 48, 45, 42, 33, 29], [49, 51, 52, 53, 53, 53, 51, 49, 48, 49, 48, 48, 48, 47, 47, 45, 44, 44, 42, 41], [35, 39, 41, 43, 45, 44, 38, 27, 15, 37, 36, 38, 40, 43, 44, 46, 47, 46, 41, 33], [36, 38, 39, 40, 42, 40, 33, 37, 43, 44, 43, 44, 43, 43, 43, 42, 41, 39, 36, 35], [39, 41, 43, 44, 45, 46, 47, 46, 45, 44, 44, 43, 41, 41, 34, 30, 31, 35, 38, 35], [38, 40, 42, 43, 43, 43, 44, 46, 47, 46, 46, 46, 46, 45, 43, 42, 40, 37, 34, 31], [36, 37, 38, 38, 38, 38, 38, 37, 39, 39, 38, 37, 38, 37, 34, 32, 25, 17, 26, 26], [30, 30, 28, 26, 24, 23, 29, 30, 31, 30, 25, 29, 27, 23, 23, 24, 24, 24, 13, 17], [26, 24, 21, 25, 31, 30, 35, 35, 32, 35, 34, 33, 33, 31, 28, 22, 22, 23, 19, 16], [26, 24, 23, 23, 26, 32, 32, 32, 33, 35, 35, 31, 31, 33, 29, 29, 26, 21, 0, 12], [41, 41, 40, 38, 37, 41, 31, 35, 24, 30, 31, 19, 32, 18, 27, 27, 21, 17, 8, 13], [38, 38, 37, 35, 19, 33, 35, 31, 34, 34, 31, 23, 25, 21, 21, 22, 19, 20, 5, 11], [27, 29, 30, 29, 21, 24, 9, 26, 21, 23, 22, 7, 25, 23, 21, 16, 20, 16, 12, 13], [19, 21, 22, 23, 22, 12, 16, 6, 20, 19, 14, 10, 16, 14, 12, 11, 11, 7, 13, 10], [12, 6, 0, 12, 19, 22, 24, 17, 23, 24, 21, 14, 21, 15, 11, 18, 17, 12, 14, 9], [3, 10, 14, 17, 17, 12, 5, 14, 1, 16, 13, 19, 10, 20, 11, 8, 12, 8, 15, 13], [15, 17, 18, 19, 20, 20, 18, 14, 12, 18, 14, 17, 21, 15, 15, 11, 11, 14, 14, 14], [27, 28, 29, 30, 29, 28, 28, 27, 28, 28, 27, 28, 30, 27, 23, 19, 21, 21, 16, 4], [20, 21, 20, 20, 17, 16, 25, 26, 23, 19, 24, 22, 25, 25, 18, 4, 21, 13, 2, 6], [20, 20, 20, 19, 20, 20, 19, 18, 20, 20, 23, 19, 23, 20, 17, 6, 0, 5, 7, 0], [17, 20, 22, 22, 22, 20, 22, 19, 23, 20, 18, 10, 3, 18, 14, 12, 8, 8, 0, 1], [28, 29, 30, 31, 31, 29, 24, 21, 20, 19, 18, 15, 19, 16, 10, 5, 7, 2, 3, 16], [38, 36, 36, 36, 33, 30, 34, 44, 47, 42, 41, 35, 41, 39, 42, 37, 44, 42, 40, 38], [55, 59, 62, 65, 67, 66, 59, 57, 61, 59, 59, 59, 60, 58, 58, 57, 57, 56, 56, 53], [70, 73, 76, 79, 81, 82, 79, 79, 81, 80, 80, 79, 79, 79, 78, 77, 75, 74, 71, 68], [73, 76, 77, 78, 79, 79, 79, 76, 78, 77, 77, 77, 76, 76, 75, 75, 73, 71, 67, 61], [74, 77, 79, 81, 83, 84, 84, 82, 84, 83, 83, 83, 83, 82, 81, 80, 79, 77, 73, 69], [71, 73, 75, 76, 78, 79, 78, 79, 79, 79, 78, 78, 78, 78, 77, 76, 75, 74, 72, 69], [66, 68, 69, 69, 69, 68, 65, 64, 66, 69, 69, 69, 68, 68, 67, 66, 65, 63, 61, 58], [62, 62, 62, 62, 65, 68, 70, 71, 72, 71, 69, 68, 67, 65, 63, 61, 57, 51, 44, 43], [54, 58, 61, 64, 67, 66, 65, 67, 66, 66, 67, 66, 66, 66, 64, 63, 61, 59, 55, 51], [62, 64, 65, 66, 63, 48, 63, 62, 49, 44, 52, 50, 48, 50, 49, 48, 50, 51, 51, 51], [59, 62, 65, 67, 72, 75, 78, 77, 76, 74, 72, 70, 69, 68, 65, 63, 58, 52, 40, 47], [66, 68, 69, 70, 70, 70, 70, 72, 73, 74, 73, 72, 71, 70, 68, 66, 62, 60, 56, 52], [57, 60, 64, 67, 71, 72, 69, 67, 69, 71, 73, 72, 72, 71, 70, 69, 67, 64, 59, 54], [61, 64, 67, 69, 71, 73, 75, 74, 74, 75, 74, 74, 74, 73, 72, 71, 68, 66, 66, 64], [48, 48, 47, 45, 53, 59, 62, 64, 58, 56, 57, 52, 54, 53, 52, 53, 54, 54, 53, 49], [53, 54, 55, 57, 61, 65, 68, 67, 63, 43, 57, 47, 54, 57, 57, 50, 54, 51, 50, 48], [56, 59, 61, 62, 62, 58, 43, 49, 52, 51, 49, 47, 47, 47, 45, 45, 44, 44, 34, 35], [59, 60, 61, 60, 59, 55, 42, 48, 40, 44, 46, 46, 46, 42, 43, 44, 40, 39, 39, 32], [56, 59, 61, 63, 64, 65, 65, 64, 63, 63, 63, 62, 62, 63, 63, 62, 60, 57, 57, 51], [51, 56, 59, 61, 63, 64, 63, 62, 57, 50, 53, 54, 54, 52, 54, 52, 52, 51, 49, 45], [61, 63, 64, 65, 66, 67, 67, 68, 68, 69, 69, 68, 67, 66, 65, 66, 65, 61, 60, 58], [56, 59, 62, 64, 66, 67, 67, 67, 67, 67, 68, 68, 67, 67, 66, 64, 62, 60, 56, 51], [55, 57, 57, 57, 57, 55, 55, 59, 61, 61, 60, 61, 60, 59, 57, 56, 55, 53, 50, 47], [55, 58, 60, 62, 63, 64, 64, 63, 63, 64, 63, 63, 62, 62, 61, 60, 58, 56, 53, 49], [59, 60, 61, 61, 61, 59, 57, 55, 55, 56, 54, 54, 54, 54, 52, 50, 50, 47, 43, 38], [51, 51, 50, 49, 50, 53, 45, 36, 38, 39, 40, 29, 34, 42, 37, 26, 26, 14, 18, 22], [57, 57, 57, 56, 54, 49, 55, 57, 54, 56, 56, 56, 55, 53, 52, 51, 48, 44, 39, 31], [57, 57, 56, 56, 59, 62, 65, 65, 61, 62, 60, 59, 59, 59, 59, 55, 54, 47, 43, 34], [55, 53, 48, 29, 53, 58, 59, 60, 57, 59, 58, 58, 58, 56, 54, 52, 46, 42, 32, 21], [58, 60, 61, 62, 63, 63, 61, 57, 61, 61, 59, 58, 57, 56, 54, 52, 49, 45, 37, 28], [51, 53, 54, 55, 56, 57, 58, 58, 59, 58, 58, 57, 53, 46, 51, 54, 42, 48, 40, 34], [46, 48, 49, 51, 52, 53, 54, 55, 55, 55, 55, 55, 54, 52, 51, 51, 47, 45, 39, 35], [49, 50, 50, 50, 49, 46, 45, 46, 47, 48, 47, 49, 47, 44, 44, 44, 39, 37, 32, 28], [42, 44, 45, 46, 46, 45, 44, 44, 44, 45, 45, 44, 44, 43, 42, 41, 38, 35, 27, 22], [35, 34, 32, 31, 31, 31, 28, 29, 34, 34, 37, 30, 34, 35, 23, 31, 27, 10, 15, 4], [45, 46, 47, 48, 48, 47, 44, 41, 48, 47, 49, 48, 45, 41, 41, 43, 39, 34, 29, 23], [33, 32, 30, 33, 40, 43, 42, 41, 45, 40, 45, 39, 40, 34, 43, 24, 36, 23, 17, 20], [36, 37, 39, 40, 42, 43, 44, 45, 45, 45, 45, 45, 43, 37, 35, 32, 34, 33, 24, 19], [41, 42, 43, 44, 45, 46, 45, 45, 40, 46, 35, 45, 47, 43, 37, 41, 28, 27, 15, 12], [39, 40, 41, 41, 40, 39, 40, 42, 39, 40, 37, 43, 37, 41, 35, 35, 25, 24, 19, 14], [45, 45, 44, 49, 54, 58, 57, 42, 53, 50, 57, 43, 48, 54, 29, 47, 47, 48, 42, 42], [67, 70, 74, 76, 79, 80, 76, 69, 73, 71, 68, 69, 70, 69, 69, 69, 67, 66, 65, 63], [77, 81, 84, 86, 90, 92, 92, 91, 93, 92, 92, 91, 91, 91, 90, 89, 88, 86, 83, 80], [79, 84, 86, 88, 90, 90, 90, 88, 88, 87, 88, 87, 86, 86, 85, 84, 83, 81, 77, 72], [76, 82, 86, 89, 93, 95, 96, 95, 96, 96, 96, 95, 95, 94, 93, 92, 90, 88, 84, 80], [81, 84, 86, 88, 90, 91, 90, 89, 90, 89, 89, 88, 88, 88, 87, 87, 86, 85, 83, 81], [77, 79, 81, 82, 82, 81, 78, 76, 79, 80, 81, 80, 80, 79, 79, 78, 76, 74, 71, 68], [76, 77, 78, 78, 77, 79, 83, 85, 86, 85, 83, 83, 81, 79, 77, 75, 70, 62, 56, 52], [69, 69, 70, 73, 79, 81, 78, 76, 80, 78, 79, 78, 78, 78, 76, 75, 73, 70, 65, 61], [76, 78, 78, 79, 78, 69, 77, 76, 67, 67, 68, 70, 67, 67, 62, 58, 55, 57, 60, 62], [74, 76, 78, 80, 83, 85, 89, 89, 89, 88, 85, 83, 82, 81, 79, 78, 74, 70, 61, 54], [66, 72, 76, 79, 82, 84, 86, 87, 86, 86, 85, 85, 84, 83, 81, 80, 76, 74, 68, 64], [66, 67, 71, 76, 82, 85, 85, 82, 83, 84, 84, 83, 83, 83, 82, 80, 79, 76, 72, 67], [63, 68, 73, 76, 81, 84, 87, 87, 86, 86, 86, 87, 86, 85, 84, 83, 80, 76, 75, 75], [56, 56, 56, 55, 59, 67, 73, 77, 80, 79, 78, 70, 73, 73, 71, 66, 67, 67, 65, 61], [56, 53, 53, 61, 72, 78, 82, 80, 73, 77, 72, 74, 75, 76, 74, 56, 70, 64, 63, 61], [71, 74, 76, 78, 79, 77, 57, 70, 70, 70, 64, 63, 65, 66, 61, 63, 61, 59, 50, 50], [72, 74, 75, 76, 75, 73, 67, 72, 69, 68, 69, 70, 67, 66, 64, 64, 60, 58, 56, 51], [67, 71, 75, 77, 80, 81, 82, 82, 82, 81, 81, 80, 80, 80, 79, 78, 76, 73, 71, 66], [60, 65, 71, 74, 79, 81, 82, 81, 81, 79, 79, 77, 78, 76, 74, 71, 70, 68, 64, 61], [71, 75, 78, 80, 82, 84, 85, 86, 84, 84, 84, 84, 83, 82, 81, 81, 79, 73, 71, 71], [67, 71, 75, 78, 82, 84, 85, 86, 85, 86, 85, 84, 83, 83, 82, 81, 77, 76, 71, 67], [70, 73, 75, 76, 77, 76, 70, 68, 73, 74, 75, 76, 75, 74, 70, 70, 68, 66, 59, 55], [70, 74, 77, 79, 82, 83, 83, 82, 81, 81, 82, 81, 81, 80, 78, 76, 74, 71, 66, 63], [75, 78, 80, 81, 81, 81, 77, 71, 67, 71, 67, 73, 69, 69, 68, 65, 63, 59, 51, 48], [74, 74, 73, 72, 69, 67, 73, 74, 59, 73, 57, 72, 57, 71, 44, 67, 59, 58, 46, 46], [75, 77, 77, 77, 76, 74, 76, 78, 75, 80, 79, 77, 74, 74, 72, 70, 65, 62, 54, 48], [77, 80, 81, 82, 83, 85, 88, 88, 82, 83, 85, 82, 81, 81, 78, 73, 64, 65, 63, 53], [71, 72, 74, 75, 77, 79, 79, 81, 79, 79, 77, 78, 77, 73, 70, 66, 61, 56, 41, 34], [76, 79, 82, 84, 86, 87, 86, 85, 84, 84, 82, 82, 81, 80, 76, 71, 67, 65, 50, 46], [72, 75, 77, 78, 80, 81, 81, 80, 80, 80, 79, 77, 72, 67, 72, 71, 64, 60, 55, 53], [74, 75, 77, 77, 78, 78, 79, 79, 77, 78, 77, 77, 76, 74, 70, 69, 62, 60, 48, 46], [70, 72, 72, 73, 73, 73, 74, 74, 74, 75, 73, 74, 72, 68, 64, 64, 58, 52, 48, 42], [64, 67, 69, 71, 73, 73, 70, 71, 72, 71, 70, 69, 69, 66, 64, 63, 58, 56, 52, 47], [62, 66, 69, 70, 68, 57, 68, 71, 67, 70, 66, 61, 67, 68, 67, 57, 61, 49, 34, 30], [68, 70, 71, 72, 73, 75, 77, 73, 76, 76, 77, 76, 73, 71, 65, 64, 58, 55, 50, 42], [61, 61, 59, 51, 62, 64, 61, 54, 68, 65, 70, 67, 72, 73, 70, 57, 61, 55, 49, 43], [69, 71, 71, 71, 76, 78, 79, 78, 71, 73, 75, 68, 74, 76, 64, 61, 62, 51, 43, 36], [60, 60, 62, 64, 68, 67, 70, 74, 72, 71, 72, 74, 72, 70, 62, 62, 55, 55, 43, 38], [63, 65, 67, 69, 69, 67, 58, 65, 64, 68, 69, 68, 69, 65, 60, 56, 52, 45, 35, 31], [41, 41, 40, 38, 39, 38, 32, 40, 38, 46, 42, 32, 43, 38, 23, 41, 45, 37, 35, 45], [58, 63, 66, 69, 70, 70, 73, 73, 75, 76, 76, 76, 75, 74, 69, 63, 50, 43, 29, 34], [67, 70, 72, 73, 75, 76, 77, 77, 74, 74, 76, 75, 74, 73, 72, 70, 68, 65, 59, 52], [64, 68, 71, 72, 74, 74, 73, 72, 74, 74, 74, 74, 73, 73, 72, 72, 70, 69, 66, 64], [65, 67, 69, 70, 71, 71, 71, 71, 71, 71, 72, 71, 71, 70, 69, 68, 66, 64, 59, 51], [62, 64, 66, 67, 67, 66, 63, 65, 68, 68, 69, 70, 70, 69, 68, 66, 63, 60, 55, 50], [63, 65, 66, 67, 68, 67, 68, 67, 66, 67, 67, 67, 67, 66, 65, 64, 63, 61, 57, 53], [39, 39, 42, 45, 49, 50, 45, 44, 47, 48, 47, 48, 46, 46, 44, 45, 42, 39, 37, 33], [43, 44, 45, 47, 49, 51, 50, 52, 53, 50, 50, 50, 50, 47, 46, 46, 47, 43, 41, 40], [44, 43, 39, 25, 45, 50, 54, 54, 54, 55, 55, 56, 55, 54, 54, 53, 52, 51, 48, 45], [36, 46, 51, 55, 58, 60, 61, 63, 63, 63, 64, 63, 63, 63, 62, 61, 59, 57, 53, 50], [51, 54, 56, 57, 58, 59, 60, 60, 59, 60, 60, 59, 59, 58, 58, 56, 54, 53, 49, 46], [45, 48, 50, 52, 51, 53, 58, 58, 58, 59, 59, 59, 59, 59, 58, 58, 57, 54, 48, 40], [43, 46, 49, 52, 56, 60, 62, 61, 62, 62, 61, 60, 59, 58, 56, 55, 53, 49, 21, 35], [46, 47, 48, 49, 49, 50, 51, 52, 53, 53, 53, 53, 52, 51, 49, 47, 41, 35, 41, 42], [38, 39, 40, 41, 40, 40, 41, 38, 37, 39, 37, 35, 35, 33, 29, 19, 28, 32, 31, 14], [28, 28, 26, 24, 25, 28, 31, 30, 34, 31, 31, 29, 22, 31, 27, 18, 13, 19, 13, 10], [38, 40, 41, 41, 41, 42, 43, 43, 43, 43, 43, 43, 41, 38, 31, 18, 37, 38, 24, 30], [34, 37, 39, 40, 42, 41, 39, 41, 40, 40, 39, 38, 38, 36, 29, 26, 35, 33, 25, 22], [24, 27, 29, 30, 29, 29, 31, 28, 28, 30, 30, 32, 30, 32, 26, 20, 24, 24, 25, 22], [21, 24, 26, 28, 32, 34, 35, 35, 34, 34, 34, 33, 32, 28, 14, 21, 27, 14, 20, 19], [30, 31, 32, 33, 33, 33, 32, 29, 29, 32, 33, 33, 34, 31, 26, 23, 29, 18, 11, 13], [33, 35, 35, 36, 36, 36, 34, 34, 36, 34, 34, 32, 27, 20, 31, 30, 4, 26, 25, 16], [25, 26, 27, 26, 23, 21, 16, 24, 25, 28, 28, 29, 31, 29, 19, 27, 18, 18, 15, 10], [17, 17, 15, 12, 10, 15, 16, 25, 15, 19, 21, 19, 11, 14, 15, 17, 5, 13, 14, 0], [28, 28, 27, 27, 25, 18, 28, 26, 22, 19, 8, 21, 21, 20, 16, 19, 19, 15, 8, 5], [34, 34, 33, 31, 34, 37, 36, 37, 34, 30, 26, 21, 22, 26, 20, 12, 12, 16, 7, 16], [29, 31, 32, 33, 33, 31, 18, 19, 18, 21, 21, 21, 21, 22, 21, 22, 16, 16, 1, 16], [23, 23, 22, 22, 21, 24, 25, 26, 26, 28, 27, 28, 27, 25, 24, 21, 20, 16, 13, 16], [27, 29, 30, 31, 31, 30, 32, 32, 31, 31, 30, 26, 13, 29, 30, 22, 23, 15, 9, 12], [24, 26, 28, 29, 29, 28, 25, 27, 28, 29, 28, 24, 19, 27, 19, 24, 20, 11, 4, 6], [14, 13, 11, 9, 0, 11, 19, 19, 10, 8, 7, 15, 20, 16, 10, 15, 7, 0, 0, 10], [15, 14, 12, 5, 10, 15, 8, 16, 0, 12, 6, 13, 5, 8, 13, 10, 5, 11, 6, 0], [6, 4, 7, 11, 12, 8, 6, 0, 9, 10, 0, 9, 0, 15, 10, 7, 7, 5, 7, 7], [7, 11, 13, 15, 15, 12, 8, 14, 10, 14, 5, 6, 12, 5, 5, 13, 5, 6, 2, 5], [15, 15, 14, 14, 13, 11, 10, 0, 12, 15, 15, 18, 16, 12, 10, 15, 14, 15, 0, 2], [17, 16, 13, 7, 15, 20, 16, 18, 14, 14, 13, 10, 12, 10, 11, 14, 16, 15, 15, 10], [23, 22, 22, 20, 13, 10, 23, 21, 15, 7, 16, 16, 10, 9, 15, 0, 0, 10, 9, 9], [31, 32, 33, 32, 30, 28, 26, 26, 19, 20, 18, 10, 14, 0, 13, 11, 10, 3, 8, 7], [15, 15, 13, 8, 2, 12, 17, 17, 5, 9, 11, 12, 10, 14, 8, 0, 10, 0, 6, 9], [47, 48, 46, 41, 45, 42, 48, 47, 47, 48, 46, 51, 47, 43, 48, 38, 42, 27, 42, 34], [47, 60, 67, 71, 76, 77, 79, 80, 81, 82, 82, 81, 80, 78, 76, 73, 65, 51, 42, 38], [65, 71, 75, 77, 80, 82, 83, 83, 81, 81, 82, 81, 81, 79, 78, 76, 72, 70, 65, 60], [63, 69, 73, 76, 80, 81, 81, 79, 80, 81, 80, 80, 80, 79, 79, 78, 77, 75, 73, 71], [67, 71, 73, 75, 77, 78, 78, 78, 78, 78, 79, 78, 78, 77, 77, 76, 74, 72, 66, 59], [65, 69, 72, 74, 75, 75, 73, 72, 75, 77, 78, 78, 78, 78, 77, 75, 72, 69, 63, 57], [68, 71, 73, 75, 76, 76, 76, 76, 75, 76, 76, 76, 75, 75, 74, 73, 71, 69, 65, 62], [47, 45, 35, 42, 56, 59, 57, 53, 56, 55, 54, 55, 54, 55, 53, 52, 51, 50, 47, 44], [56, 56, 57, 57, 59, 60, 60, 62, 61, 61, 59, 60, 60, 59, 57, 58, 55, 54, 51, 48], [55, 57, 58, 56, 46, 57, 63, 65, 65, 66, 67, 66, 66, 66, 65, 64, 63, 62, 58, 55], [43, 51, 57, 62, 67, 70, 71, 73, 74, 74, 75, 74, 74, 74, 73, 72, 70, 69, 65, 61], [56, 61, 64, 67, 69, 70, 72, 72, 71, 71, 71, 71, 71, 70, 70, 69, 68, 66, 63, 60], [55, 58, 61, 63, 65, 63, 70, 71, 71, 72, 72, 72, 72, 72, 72, 71, 69, 67, 61, 56], [53, 56, 58, 61, 66, 71, 76, 76, 76, 76, 75, 75, 73, 72, 70, 69, 67, 62, 37, 51], [55, 59, 61, 63, 64, 64, 66, 66, 67, 67, 67, 67, 66, 65, 62, 60, 52, 50, 55, 56], [52, 54, 56, 57, 56, 55, 56, 55, 53, 54, 52, 52, 50, 49, 43, 31, 45, 48, 44, 28], [46, 47, 48, 47, 43, 44, 48, 49, 49, 48, 49, 47, 46, 45, 39, 28, 38, 42, 34, 34], [53, 57, 59, 61, 61, 61, 62, 62, 62, 61, 61, 60, 57, 55, 45, 45, 55, 54, 46, 46], [51, 54, 57, 59, 61, 62, 61, 61, 61, 60, 59, 59, 57, 55, 45, 46, 55, 52, 47, 42], [45, 48, 51, 52, 54, 55, 57, 56, 58, 59, 59, 59, 59, 57, 51, 47, 56, 48, 51, 47], [49, 51, 53, 54, 55, 57, 59, 59, 57, 56, 56, 54, 53, 50, 34, 50, 51, 38, 36, 42], [52, 55, 56, 57, 58, 57, 57, 56, 58, 58, 58, 58, 57, 55, 34, 52, 52, 45, 37, 30], [51, 54, 56, 57, 58, 58, 59, 60, 59, 58, 56, 54, 50, 48, 54, 56, 44, 52, 48, 43], [47, 48, 49, 48, 42, 32, 42, 46, 49, 51, 52, 52, 51, 47, 40, 48, 31, 44, 36, 29], [44, 44, 42, 40, 34, 35, 30, 35, 45, 43, 42, 28, 39, 13, 39, 35, 29, 33, 11, 15], [39, 42, 46, 49, 51, 49, 37, 48, 40, 48, 39, 37, 34, 37, 33, 32, 32, 31, 19, 4], [54, 56, 57, 57, 51, 44, 48, 54, 55, 54, 55, 55, 53, 51, 44, 44, 40, 42, 37, 29], [48, 50, 51, 52, 52, 51, 41, 40, 33, 35, 37, 38, 36, 40, 39, 39, 35, 30, 27, 17], [42, 44, 44, 44, 44, 43, 44, 44, 43, 45, 45, 44, 43, 41, 41, 38, 36, 31, 27, 20], [41, 43, 44, 45, 44, 44, 45, 46, 47, 46, 46, 45, 33, 40, 43, 36, 32, 25, 19, 16], [26, 25, 28, 32, 36, 35, 34, 37, 38, 40, 38, 37, 24, 35, 28, 35, 31, 26, 17, 22], [28, 27, 26, 23, 18, 23, 32, 27, 26, 24, 22, 23, 27, 25, 21, 16, 11, 11, 6, 6], [24, 26, 28, 28, 26, 23, 26, 22, 22, 21, 23, 25, 22, 21, 21, 10, 15, 10, 11, 7], [31, 32, 32, 31, 27, 16, 25, 23, 10, 15, 22, 9, 1, 10, 14, 14, 15, 11, 14, 7], [12, 19, 22, 23, 21, 21, 16, 19, 14, 10, 10, 17, 12, 7, 11, 15, 14, 2, 1, 5], [28, 28, 30, 30, 29, 25, 25, 24, 25, 26, 27, 23, 27, 22, 24, 23, 20, 19, 11, 12], [37, 38, 37, 35, 24, 30, 34, 20, 24, 31, 6, 31, 27, 30, 22, 27, 12, 21, 13, 14], [47, 50, 51, 51, 50, 45, 41, 40, 36, 36, 29, 28, 31, 25, 24, 21, 24, 14, 9, 10], [41, 42, 42, 41, 38, 40, 40, 41, 39, 36, 38, 30, 27, 34, 36, 26, 27, 24, 13, 15], [31, 33, 32, 30, 20, 26, 27, 26, 22, 25, 13, 20, 23, 17, 13, 20, 4, 11, 6, 7], [60, 59, 58, 56, 60, 63, 63, 44, 60, 60, 54, 53, 46, 40, 43, 44, 41, 40, 44, 47], [67, 73, 79, 82, 87, 88, 89, 92, 93, 93, 92, 91, 89, 87, 86, 85, 81, 76, 60, 44], [69, 77, 82, 86, 89, 92, 94, 94, 93, 93, 94, 93, 92, 92, 90, 88, 84, 80, 73, 66], [73, 78, 82, 86, 90, 92, 92, 90, 90, 92, 91, 91, 91, 90, 90, 88, 87, 86, 83, 80], [74, 78, 81, 83, 86, 88, 89, 89, 90, 89, 90, 89, 89, 88, 88, 87, 85, 84, 79, 72], [66, 74, 79, 82, 86, 88, 87, 84, 86, 87, 87, 88, 88, 87, 86, 84, 82, 80, 74, 68], [80, 83, 85, 87, 90, 90, 91, 90, 89, 90, 90, 90, 89, 89, 88, 87, 85, 83, 79, 76], [56, 56, 63, 68, 74, 77, 74, 67, 69, 69, 68, 68, 68, 68, 67, 65, 63, 62, 59, 55], [71, 73, 74, 75, 75, 75, 73, 74, 73, 75, 72, 72, 72, 71, 67, 71, 67, 65, 63, 60], [65, 68, 70, 70, 71, 76, 77, 79, 79, 80, 80, 80, 80, 80, 79, 78, 76, 75, 72, 68], [65, 70, 73, 76, 81, 83, 86, 87, 88, 89, 89, 88, 87, 87, 86, 85, 84, 83, 79, 76], [67, 73, 77, 80, 83, 83, 85, 86, 85, 84, 84, 83, 84, 83, 82, 81, 79, 78, 74, 72], [66, 70, 73, 77, 81, 80, 83, 86, 86, 84, 86, 85, 85, 84, 84, 83, 82, 80, 74, 68], [64, 69, 72, 76, 83, 88, 93, 93, 93, 93, 92, 92, 90, 88, 86, 85, 84, 80, 54, 66], [71, 76, 79, 81, 83, 83, 85, 85, 87, 87, 86, 85, 84, 82, 78, 74, 62, 70, 73, 71], [69, 72, 74, 75, 76, 76, 75, 73, 72, 69, 67, 64, 64, 61, 47, 51, 62, 64, 58, 50], [65, 67, 67, 66, 63, 64, 68, 69, 70, 71, 70, 69, 68, 67, 61, 44, 61, 64, 55, 55], [70, 74, 77, 79, 81, 81, 81, 80, 81, 81, 81, 81, 79, 77, 69, 61, 75, 75, 65, 67], [70, 73, 75, 77, 79, 80, 80, 79, 80, 78, 78, 76, 74, 72, 60, 64, 71, 69, 63, 58], [64, 68, 72, 74, 76, 77, 77, 73, 75, 75, 75, 75, 75, 75, 71, 67, 69, 66, 65, 59], [68, 71, 73, 74, 76, 78, 79, 78, 75, 75, 74, 74, 73, 70, 62, 68, 71, 58, 56, 60], [76, 79, 80, 81, 82, 83, 83, 82, 83, 82, 82, 81, 78, 74, 69, 77, 72, 71, 64, 57], [75, 78, 80, 82, 83, 83, 85, 85, 83, 84, 82, 79, 73, 66, 78, 80, 60, 75, 71, 66], [70, 72, 73, 73, 69, 60, 67, 65, 69, 72, 74, 74, 73, 73, 56, 68, 58, 65, 59, 41], [60, 60, 51, 53, 67, 69, 64, 58, 69, 64, 62, 62, 63, 44, 61, 57, 54, 53, 42, 28], [70, 74, 77, 79, 81, 78, 68, 76, 72, 75, 66, 62, 62, 64, 55, 57, 52, 50, 42, 19], [78, 81, 82, 82, 72, 79, 85, 86, 88, 88, 88, 88, 86, 82, 78, 75, 75, 74, 64, 60], [72, 75, 77, 78, 78, 77, 60, 72, 66, 67, 71, 73, 74, 73, 70, 66, 66, 60, 56, 51], [72, 74, 75, 75, 76, 76, 80, 81, 82, 82, 83, 82, 77, 73, 78, 69, 64, 59, 51, 43], [72, 76, 79, 81, 82, 83, 83, 83, 84, 83, 82, 79, 72, 78, 76, 73, 68, 63, 48, 49], [66, 70, 73, 75, 77, 78, 76, 77, 77, 78, 78, 75, 59, 74, 60, 72, 68, 58, 56, 55], [64, 65, 65, 65, 66, 67, 69, 67, 69, 65, 55, 64, 70, 68, 64, 62, 54, 44, 51, 50], [54, 57, 59, 60, 59, 57, 55, 53, 51, 57, 60, 62, 57, 24, 57, 52, 52, 48, 27, 38], [60, 62, 63, 64, 62, 59, 50, 48, 54, 42, 47, 44, 44, 41, 45, 38, 41, 34, 30, 22], [61, 63, 65, 65, 63, 59, 54, 56, 61, 49, 61, 62, 59, 49, 53, 54, 49, 49, 40, 36], [49, 55, 60, 63, 65, 64, 59, 67, 69, 70, 74, 73, 64, 67, 61, 67, 55, 55, 48, 49], [62, 64, 65, 64, 58, 58, 63, 71, 76, 73, 74, 59, 67, 60, 71, 65, 62, 57, 34, 42], [64, 68, 72, 75, 77, 79, 86, 83, 83, 82, 60, 73, 66, 72, 69, 64, 63, 58, 43, 35], [69, 72, 74, 75, 76, 77, 80, 79, 80, 76, 74, 74, 69, 75, 71, 62, 60, 56, 48, 41], [62, 62, 61, 59, 61, 61, 52, 64, 67, 62, 53, 62, 59, 56, 59, 61, 42, 48, 44, 40], [54, 54, 53, 50, 43, 45, 53, 42, 41, 37, 38, 44, 34, 43, 47, 41, 46, 45, 44, 45], [68, 72, 74, 75, 77, 77, 76, 75, 74, 75, 73, 72, 72, 71, 70, 68, 64, 61, 62, 63], [65, 67, 68, 67, 63, 60, 62, 61, 60, 56, 58, 56, 59, 58, 57, 56, 54, 55, 52, 50], [68, 70, 71, 72, 71, 70, 70, 70, 69, 68, 68, 68, 67, 66, 63, 60, 53, 52, 52, 47], [70, 72, 73, 73, 74, 75, 76, 76, 77, 77, 77, 77, 75, 74, 71, 68, 59, 55, 63, 63], [65, 66, 67, 67, 67, 67, 67, 69, 70, 70, 70, 70, 69, 68, 67, 66, 62, 54, 52, 57], [54, 56, 58, 59, 60, 61, 60, 58, 53, 53, 55, 55, 53, 53, 50, 48, 42, 32, 38, 41], [46, 48, 50, 49, 45, 44, 44, 36, 37, 38, 40, 39, 38, 37, 38, 32, 35, 32, 19, 24], [54, 54, 54, 55, 56, 57, 54, 50, 47, 48, 48, 48, 48, 45, 45, 42, 39, 34, 34, 40], [62, 64, 65, 65, 66, 67, 66, 67, 67, 67, 67, 66, 66, 65, 63, 62, 58, 55, 46, 38], [62, 63, 64, 64, 63, 62, 60, 60, 60, 60, 60, 59, 57, 55, 49, 31, 50, 52, 46, 43], [60, 61, 62, 63, 63, 63, 61, 61, 62, 61, 61, 60, 58, 56, 51, 44, 42, 47, 44, 36], [55, 56, 57, 58, 58, 58, 56, 56, 55, 55, 54, 52, 52, 50, 46, 42, 34, 38, 42, 40], [51, 52, 52, 52, 52, 51, 51, 51, 52, 53, 52, 52, 52, 52, 50, 49, 46, 46, 42, 10], [47, 49, 50, 51, 51, 50, 51, 51, 51, 50, 49, 48, 47, 45, 41, 38, 31, 36, 37, 34], [36, 37, 38, 38, 37, 37, 37, 36, 38, 37, 38, 38, 36, 33, 31, 30, 25, 22, 24, 23], [25, 26, 27, 27, 29, 28, 26, 29, 28, 26, 21, 23, 23, 20, 16, 16, 15, 21, 17, 18], [34, 35, 36, 37, 37, 36, 34, 35, 36, 36, 36, 35, 34, 34, 31, 28, 23, 20, 19, 20], [34, 35, 36, 36, 36, 37, 36, 35, 36, 34, 33, 32, 30, 24, 24, 27, 28, 27, 19, 18], [29, 31, 32, 32, 31, 31, 29, 33, 33, 30, 29, 31, 30, 30, 26, 27, 26, 16, 15, 19], [24, 25, 27, 28, 29, 27, 29, 30, 29, 29, 28, 26, 21, 25, 15, 19, 18, 16, 10, 9], [30, 32, 34, 35, 34, 34, 36, 36, 37, 37, 36, 36, 32, 29, 25, 27, 30, 17, 13, 15], [22, 23, 24, 23, 21, 23, 26, 26, 29, 24, 25, 23, 20, 20, 23, 20, 15, 6, 16, 17], [14, 20, 23, 24, 24, 22, 27, 16, 23, 18, 19, 12, 16, 16, 3, 11, 14, 9, 19, 19], [25, 25, 23, 23, 28, 24, 18, 17, 22, 21, 15, 16, 13, 12, 14, 14, 12, 11, 12, 0], [22, 19, 17, 23, 28, 27, 25, 23, 23, 24, 20, 19, 14, 14, 12, 11, 9, 6, 5, 4], [13, 9, 15, 19, 21, 22, 21, 24, 13, 20, 18, 13, 3, 17, 19, 18, 11, 1, 0, 9], [19, 19, 17, 10, 12, 13, 19, 6, 15, 10, 16, 7, 12, 7, 19, 8, 4, 8, 12, 11], [14, 15, 17, 19, 21, 22, 20, 22, 16, 17, 19, 11, 16, 19, 16, 8, 12, 20, 17, 8], [24, 25, 25, 25, 23, 23, 24, 22, 18, 20, 16, 13, 21, 17, 18, 6, 19, 16, 3, 17], [18, 15, 9, 0, 13, 14, 15, 15, 9, 17, 13, 9, 10, 11, 13, 10, 11, 9, 0, 7], [17, 19, 20, 19, 9, 9, 11, 8, 12, 16, 9, 11, 6, 8, 8, 2, 0, 12, 7, 8], [19, 21, 21, 20, 13, 5, 5, 0, 16, 12, 10, 8, 13, 12, 10, 5, 9, 0, 8, 6], [21, 22, 21, 19, 7, 0, 12, 11, 3, 7, 0, 9, 13, 12, 6, 1, 8, 0, 6, 0], [16, 19, 20, 18, 18, 17, 10, 4, 16, 0, 6, 10, 5, 7, 0, 3, 9, 0, 3, 8], [13, 18, 20, 20, 5, 11, 11, 6, 3, 8, 5, 0, 0, 6, 0, 10, 10, 5, 5, 4], [19, 24, 26, 27, 22, 5, 9, 6, 12, 0, 5, 10, 6, 10, 6, 11, 5, 3, 0, 0], [21, 23, 24, 23, 20, 12, 16, 13, 14, 12, 11, 0, 3, 11, 3, 13, 7, 10, 2, 5], [16, 17, 18, 17, 13, 6, 7, 13, 10, 9, 7, 4, 4, 7, 9, 7, 3, 5, 6, 2], [15, 16, 14, 11, 8, 11, 5, 0, 12, 3, 6, 0, 8, 6, 9, 2, 2, 5, 0, 0], [53, 60, 62, 64, 63, 58, 59, 56, 47, 56, 50, 56, 50, 53, 50, 48, 50, 41, 48, 44], [62, 69, 74, 78, 83, 85, 86, 84, 82, 83, 81, 81, 80, 79, 78, 76, 71, 68, 71, 70], [57, 62, 70, 74, 76, 72, 70, 69, 68, 64, 63, 64, 65, 65, 64, 63, 63, 62, 61, 59], [68, 74, 77, 79, 81, 81, 78, 78, 78, 76, 76, 75, 74, 73, 71, 68, 61, 58, 61, 58], [71, 76, 80, 82, 83, 84, 86, 86, 88, 87, 87, 86, 85, 84, 82, 79, 68, 66, 74, 74], [64, 70, 74, 77, 78, 78, 78, 79, 81, 81, 80, 80, 80, 79, 78, 76, 72, 66, 60, 67], [66, 68, 69, 70, 71, 72, 73, 72, 68, 65, 66, 66, 65, 65, 64, 62, 59, 54, 41, 50], [57, 59, 61, 61, 61, 56, 57, 53, 51, 53, 51, 53, 54, 50, 50, 49, 45, 40, 31, 29], [64, 67, 68, 68, 69, 70, 71, 67, 60, 61, 62, 62, 62, 59, 58, 57, 53, 50, 48, 52], [68, 73, 76, 78, 80, 81, 82, 82, 83, 83, 82, 82, 81, 80, 79, 77, 74, 70, 63, 57], [70, 75, 77, 78, 79, 79, 75, 75, 76, 75, 75, 74, 73, 71, 64, 53, 65, 66, 58, 57], [71, 75, 77, 78, 79, 80, 79, 78, 79, 79, 78, 78, 76, 74, 70, 64, 56, 63, 61, 55], [66, 71, 73, 75, 76, 77, 76, 73, 75, 73, 73, 73, 72, 71, 69, 65, 59, 42, 56, 56], [64, 68, 71, 72, 73, 73, 71, 71, 70, 71, 72, 72, 72, 72, 71, 70, 68, 67, 62, 49], [61, 65, 68, 70, 73, 73, 73, 74, 73, 73, 73, 72, 71, 69, 67, 63, 52, 51, 57, 54], [59, 61, 61, 61, 61, 62, 63, 63, 63, 63, 62, 62, 60, 59, 56, 53, 48, 29, 52, 49], [54, 56, 56, 56, 55, 53, 51, 54, 52, 52, 52, 51, 50, 49, 48, 45, 40, 38, 42, 40], [58, 61, 63, 63, 62, 61, 61, 62, 62, 62, 62, 61, 60, 58, 55, 52, 43, 44, 47, 45], [60, 64, 67, 68, 69, 69, 68, 67, 67, 66, 65, 64, 63, 60, 54, 48, 53, 55, 53, 43], [48, 55, 60, 62, 63, 63, 64, 64, 63, 62, 62, 62, 61, 60, 57, 56, 56, 46, 44, 35], [58, 62, 63, 63, 63, 64, 64, 65, 65, 65, 63, 63, 61, 59, 54, 49, 51, 56, 49, 45], [57, 62, 65, 68, 70, 71, 70, 71, 71, 71, 70, 68, 65, 57, 59, 65, 62, 49, 50, 50], [48, 47, 49, 53, 56, 55, 57, 59, 60, 59, 55, 58, 56, 52, 50, 49, 43, 48, 47, 31], [58, 60, 60, 59, 50, 52, 52, 51, 43, 51, 40, 45, 30, 36, 40, 42, 43, 33, 36, 34], [59, 60, 61, 62, 60, 56, 58, 58, 57, 56, 54, 53, 50, 46, 14, 43, 41, 32, 32, 29], [58, 59, 59, 58, 56, 56, 45, 52, 49, 51, 35, 43, 43, 38, 43, 39, 32, 24, 17, 22], [45, 49, 50, 51, 52, 50, 46, 45, 41, 44, 39, 39, 39, 37, 35, 28, 26, 24, 17, 23], [43, 46, 47, 47, 46, 47, 51, 49, 48, 47, 45, 44, 40, 42, 39, 42, 33, 41, 31, 32], [46, 48, 50, 50, 50, 50, 49, 47, 44, 40, 35, 36, 45, 45, 35, 41, 40, 38, 34, 29], [35, 38, 41, 43, 44, 43, 40, 35, 37, 37, 34, 32, 28, 33, 30, 29, 24, 29, 19, 20], [40, 42, 43, 42, 40, 37, 32, 38, 36, 36, 35, 33, 26, 29, 31, 28, 22, 5, 4, 13], [21, 22, 32, 35, 35, 31, 34, 29, 29, 17, 8, 25, 31, 31, 20, 28, 26, 24, 18, 13], [39, 42, 43, 43, 40, 36, 36, 34, 29, 30, 23, 23, 29, 29, 18, 22, 13, 16, 15, 10], [34, 35, 35, 33, 29, 31, 27, 14, 3, 21, 20, 20, 14, 18, 17, 16, 13, 10, 5, 6], [24, 24, 24, 26, 31, 31, 11, 27, 26, 14, 12, 12, 17, 21, 7, 13, 11, 0, 2, 8], [40, 43, 44, 45, 41, 29, 27, 36, 34, 26, 25, 20, 20, 21, 17, 15, 13, 5, 0, 11], [38, 39, 38, 34, 29, 38, 32, 41, 28, 27, 34, 30, 25, 30, 30, 25, 25, 19, 9, 7], [25, 28, 30, 31, 31, 32, 31, 33, 32, 30, 12, 28, 23, 21, 26, 26, 19, 18, 10, 0], [22, 24, 31, 35, 36, 30, 29, 26, 25, 8, 23, 27, 15, 20, 22, 24, 18, 15, 11, 9], [33, 34, 33, 29, 23, 27, 23, 27, 19, 21, 24, 14, 23, 25, 18, 21, 9, 8, 4, 3], [59, 67, 71, 73, 73, 68, 66, 67, 48, 65, 55, 66, 55, 63, 58, 53, 59, 47, 49, 54], [74, 80, 85, 88, 93, 95, 95, 93, 91, 92, 91, 91, 89, 89, 87, 85, 79, 77, 79, 77], [70, 73, 79, 84, 86, 83, 77, 80, 73, 65, 65, 65, 59, 64, 65, 68, 71, 72, 71, 69], [72, 80, 84, 87, 90, 91, 89, 90, 89, 87, 86, 85, 84, 82, 79, 74, 66, 63, 66, 64], [81, 86, 89, 91, 92, 93, 95, 96, 96, 96, 95, 94, 93, 92, 90, 87, 75, 75, 83, 83], [71, 78, 83, 86, 88, 88, 88, 88, 90, 90, 90, 89, 89, 88, 87, 86, 82, 77, 67, 75], [75, 78, 79, 81, 83, 84, 84, 83, 79, 79, 77, 78, 76, 74, 72, 69, 66, 61, 59, 62], [68, 70, 71, 70, 70, 69, 65, 67, 62, 65, 65, 66, 65, 64, 62, 60, 57, 53, 31, 47], [73, 77, 79, 80, 80, 81, 82, 78, 73, 75, 75, 74, 73, 72, 71, 68, 64, 60, 58, 61], [78, 83, 87, 89, 91, 92, 93, 93, 94, 94, 93, 93, 92, 91, 89, 87, 84, 80, 74, 69], [80, 85, 88, 89, 90, 90, 87, 87, 87, 87, 87, 85, 84, 82, 75, 67, 75, 77, 67, 66], [82, 86, 88, 89, 91, 91, 90, 89, 91, 91, 90, 89, 87, 86, 81, 74, 67, 74, 71, 65], [78, 82, 85, 87, 89, 90, 91, 86, 87, 83, 85, 84, 84, 82, 80, 76, 69, 55, 66, 67], [75, 81, 84, 85, 85, 85, 83, 82, 82, 84, 84, 85, 85, 85, 85, 84, 81, 79, 72, 59], [74, 79, 82, 85, 87, 87, 87, 87, 87, 86, 84, 84, 82, 81, 78, 75, 64, 60, 67, 64], [73, 75, 76, 76, 76, 78, 78, 77, 77, 76, 76, 75, 73, 71, 67, 65, 61, 53, 63, 61], [68, 70, 70, 70, 68, 66, 67, 69, 69, 68, 67, 68, 66, 65, 64, 60, 53, 53, 56, 51], [72, 76, 78, 78, 78, 77, 78, 79, 79, 79, 79, 77, 75, 74, 70, 67, 56, 58, 61, 62], [75, 79, 82, 83, 84, 84, 83, 83, 83, 83, 82, 81, 79, 77, 71, 55, 67, 69, 67, 55], [63, 71, 76, 79, 80, 80, 81, 81, 81, 81, 81, 81, 79, 78, 74, 73, 73, 66, 61, 52], [74, 79, 81, 81, 81, 82, 82, 83, 82, 82, 81, 81, 79, 77, 71, 62, 62, 71, 64, 59], [76, 80, 84, 86, 89, 90, 89, 89, 89, 88, 87, 85, 81, 74, 76, 82, 79, 66, 62, 64], [67, 67, 69, 73, 75, 74, 78, 81, 81, 80, 74, 79, 75, 70, 66, 68, 61, 66, 65, 52], [76, 79, 79, 77, 59, 66, 72, 73, 67, 73, 67, 70, 61, 54, 60, 64, 63, 51, 58, 55], [78, 79, 79, 81, 82, 80, 77, 82, 81, 80, 78, 76, 74, 68, 57, 65, 62, 58, 54, 52], [78, 81, 82, 82, 79, 80, 79, 76, 66, 66, 65, 61, 57, 57, 58, 50, 52, 39, 40, 30], [73, 74, 71, 68, 79, 81, 78, 77, 77, 79, 73, 70, 71, 68, 69, 67, 58, 61, 52, 39], [58, 54, 58, 63, 67, 63, 54, 58, 48, 54, 58, 57, 62, 60, 61, 59, 57, 48, 47, 26], [67, 71, 73, 74, 75, 75, 77, 76, 72, 72, 71, 67, 60, 68, 68, 63, 59, 64, 53, 50], [73, 76, 78, 78, 79, 79, 79, 79, 77, 76, 72, 64, 71, 74, 61, 70, 68, 68, 63, 58], [57, 63, 67, 69, 70, 69, 68, 65, 65, 64, 61, 60, 48, 62, 64, 39, 57, 58, 41, 47], [63, 65, 66, 66, 62, 60, 64, 63, 56, 63, 64, 62, 54, 60, 56, 56, 51, 46, 42, 32], [54, 58, 61, 64, 68, 69, 68, 68, 67, 65, 62, 51, 61, 65, 49, 62, 58, 56, 51, 46], [61, 63, 65, 65, 63, 62, 64, 61, 60, 59, 55, 50, 51, 54, 49, 50, 44, 43, 42, 28], [61, 62, 62, 62, 59, 55, 41, 49, 48, 44, 50, 50, 51, 37, 38, 35, 44, 36, 32, 22], [42, 47, 51, 51, 48, 39, 41, 38, 34, 43, 48, 35, 42, 44, 40, 34, 28, 35, 30, 21], [55, 54, 53, 59, 67, 69, 67, 62, 53, 60, 62, 60, 57, 56, 51, 54, 57, 43, 41, 11], [60, 62, 62, 60, 56, 62, 65, 63, 61, 66, 65, 47, 60, 49, 50, 45, 40, 38, 30, 20], [52, 54, 55, 54, 54, 54, 61, 67, 62, 68, 62, 62, 57, 50, 60, 54, 51, 43, 30, 30], [52, 54, 56, 58, 63, 64, 64, 59, 59, 56, 61, 61, 52, 60, 59, 57, 50, 42, 25, 34], [59, 63, 66, 67, 65, 61, 57, 44, 54, 53, 52, 53, 53, 51, 51, 48, 47, 50, 43, 39], [60, 62, 68, 70, 72, 74, 70, 70, 71, 69, 68, 68, 67, 65, 62, 58, 58, 50, 44, 42], [69, 73, 75, 76, 78, 79, 79, 78, 75, 73, 68, 67, 63, 58, 48, 43, 21, 36, 40, 43], [65, 69, 71, 71, 71, 72, 73, 73, 74, 74, 74, 73, 71, 69, 67, 65, 65, 62, 58, 56], [57, 59, 62, 64, 65, 64, 68, 71, 70, 71, 72, 71, 70, 68, 65, 62, 51, 53, 57, 55], [60, 62, 61, 57, 55, 60, 64, 65, 61, 62, 62, 61, 60, 59, 57, 55, 49, 45, 51, 52], [58, 61, 63, 66, 68, 69, 71, 71, 71, 71, 70, 69, 67, 64, 51, 60, 68, 66, 58, 59], [48, 52, 56, 60, 64, 63, 61, 60, 59, 59, 57, 55, 53, 53, 48, 41, 38, 27, 35, 37], [54, 56, 58, 57, 54, 53, 56, 54, 52, 48, 51, 51, 50, 47, 41, 41, 47, 48, 40, 42], [52, 53, 50, 42, 48, 52, 51, 51, 52, 54, 54, 53, 52, 51, 48, 46, 45, 45, 33, 34], [51, 53, 53, 55, 56, 57, 56, 55, 50, 46, 47, 49, 47, 47, 45, 44, 41, 38, 31, 21], [53, 56, 57, 57, 56, 52, 46, 33, 43, 41, 44, 47, 46, 45, 43, 41, 29, 20, 26, 26], [51, 52, 54, 56, 59, 59, 60, 60, 60, 61, 58, 60, 59, 58, 54, 51, 34, 32, 36, 41], [50, 54, 56, 57, 58, 58, 58, 58, 58, 59, 58, 57, 54, 50, 47, 49, 50, 48, 42, 39], [37, 42, 45, 46, 46, 45, 44, 44, 46, 46, 45, 44, 45, 44, 39, 36, 38, 28, 37, 36], [39, 42, 43, 44, 44, 43, 44, 45, 45, 45, 44, 44, 41, 37, 36, 39, 35, 39, 34, 29], [32, 33, 33, 30, 11, 20, 22, 21, 20, 25, 23, 20, 23, 10, 20, 11, 13, 18, 12, 9], [24, 23, 22, 22, 26, 28, 26, 25, 20, 23, 24, 22, 19, 17, 10, 18, 13, 20, 17, 7], [26, 30, 32, 34, 31, 27, 29, 32, 28, 27, 27, 13, 31, 30, 28, 21, 19, 26, 8, 12], [31, 33, 30, 19, 30, 13, 30, 29, 31, 26, 24, 25, 26, 23, 24, 23, 11, 22, 13, 0], [15, 25, 29, 29, 29, 30, 31, 29, 31, 30, 28, 27, 27, 23, 14, 24, 16, 12, 12, 13], [21, 23, 23, 23, 23, 24, 27, 22, 24, 23, 11, 23, 19, 15, 17, 11, 10, 22, 13, 13], [27, 27, 26, 26, 27, 25, 26, 27, 27, 24, 16, 16, 22, 21, 11, 21, 18, 23, 13, 19], [23, 24, 21, 17, 20, 17, 14, 18, 12, 14, 12, 20, 12, 1, 13, 10, 8, 7, 10, 9], [28, 31, 32, 31, 25, 26, 31, 27, 27, 20, 24, 22, 21, 15, 15, 18, 5, 6, 4, 4], [24, 21, 17, 18, 19, 20, 19, 20, 7, 7, 19, 7, 17, 16, 16, 15, 10, 7, 0, 9], [0, 9, 10, 8, 12, 11, 10, 16, 22, 17, 19, 14, 9, 17, 13, 8, 13, 4, 10, 0], [15, 19, 22, 23, 24, 23, 19, 20, 11, 12, 11, 14, 21, 15, 19, 6, 15, 12, 3, 1], [14, 19, 22, 21, 18, 20, 21, 19, 15, 12, 14, 15, 18, 12, 19, 13, 11, 0, 6, 11], [17, 17, 17, 17, 10, 9, 13, 8, 1, 11, 0, 13, 16, 10, 9, 0, 7, 7, 9, 0], [15, 12, 5, 0, 10, 12, 6, 9, 6, 11, 13, 13, 15, 0, 12, 11, 2, 2, 6, 10], [11, 10, 9, 1, 4, 9, 11, 11, 12, 7, 14, 12, 10, 11, 0, 11, 6, 3, 0, 9], [16, 14, 9, 0, 1, 8, 0, 1, 11, 0, 0, 5, 5, 9, 13, 16, 12, 13, 13, 9], [14, 14, 11, 3, 5, 5, 5, 7, 0, 10, 7, 7, 10, 12, 4, 3, 8, 6, 0, 6], [19, 16, 8, 12, 10, 9, 13, 9, 13, 17, 11, 13, 4, 0, 0, 12, 10, 3, 8, 5], [14, 17, 21, 22, 15, 16, 18, 16, 11, 12, 14, 9, 11, 8, 14, 7, 0, 9, 6, 0], [8, 7, 8, 8, 15, 16, 11, 8, 12, 6, 8, 4, 6, 3, 11, 0, 4, 7, 7, 0], [12, 9, 7, 7, 9, 12, 0, 10, 12, 3, 0, 10, 8, 8, 12, 1, 1, 7, 0, 2], [5, 4, 7, 5, 6, 9, 0, 1, 9, 0, 7, 9, 8, 0, 4, 6, 0, 0, 7, 11], [9, 1, 2, 3, 0, 7, 10, 8, 10, 11, 0, 0, 7, 6, 7, 5, 0, 4, 0, 0], [55, 63, 71, 75, 77, 73, 73, 45, 68, 65, 60, 60, 63, 64, 62, 62, 61, 58, 54, 54], [69, 71, 70, 77, 84, 85, 84, 82, 84, 82, 81, 80, 80, 78, 76, 73, 67, 59, 44, 50], [74, 81, 85, 87, 89, 90, 90, 90, 88, 84, 80, 77, 72, 66, 62, 54, 46, 33, 54, 59], [72, 79, 82, 84, 83, 83, 85, 86, 86, 86, 86, 86, 85, 84, 82, 80, 78, 74, 69, 63], [70, 71, 73, 76, 80, 79, 82, 84, 85, 85, 86, 86, 85, 84, 82, 79, 69, 64, 72, 68], [69, 75, 78, 77, 71, 73, 80, 81, 78, 78, 78, 77, 76, 76, 74, 73, 68, 63, 66, 67], [68, 74, 77, 79, 84, 86, 87, 87, 87, 86, 85, 85, 83, 80, 68, 72, 82, 80, 70, 71], [63, 67, 70, 73, 79, 81, 78, 78, 76, 76, 74, 70, 71, 70, 66, 59, 43, 49, 53, 54], [67, 72, 76, 77, 76, 75, 76, 75, 71, 69, 70, 69, 67, 64, 56, 56, 62, 64, 57, 61], [68, 73, 75, 73, 48, 70, 72, 72, 72, 73, 74, 74, 73, 72, 69, 66, 64, 65, 57, 52], [67, 72, 74, 74, 75, 77, 77, 75, 71, 66, 65, 68, 65, 67, 64, 62, 59, 57, 49, 40], [67, 73, 76, 77, 76, 73, 68, 62, 65, 59, 51, 61, 56, 52, 55, 50, 45, 43, 50, 53], [68, 72, 73, 75, 81, 83, 82, 82, 84, 85, 79, 85, 84, 82, 78, 77, 68, 60, 63, 58], [69, 74, 78, 81, 83, 83, 83, 83, 82, 83, 82, 80, 76, 67, 71, 69, 76, 70, 65, 62], [60, 62, 68, 72, 73, 73, 72, 71, 71, 70, 69, 68, 67, 64, 57, 59, 62, 61, 59, 60], [63, 68, 70, 72, 73, 73, 73, 73, 73, 73, 72, 70, 66, 57, 67, 69, 63, 66, 60, 52], [64, 67, 68, 68, 63, 56, 56, 57, 56, 58, 56, 54, 49, 41, 53, 52, 50, 42, 36, 40], [47, 50, 51, 42, 54, 56, 55, 55, 53, 51, 35, 39, 46, 50, 52, 37, 56, 49, 45, 45], [35, 51, 57, 57, 56, 55, 56, 58, 52, 52, 57, 59, 58, 54, 51, 49, 54, 50, 26, 44], [65, 70, 72, 73, 74, 74, 73, 72, 71, 70, 61, 66, 70, 63, 70, 68, 61, 66, 62, 55], [57, 62, 67, 69, 69, 70, 70, 71, 70, 68, 57, 62, 70, 62, 61, 65, 63, 53, 59, 47], [56, 56, 50, 49, 61, 65, 64, 64, 64, 62, 58, 55, 61, 54, 59, 56, 55, 34, 46, 46], [48, 55, 59, 61, 57, 57, 60, 63, 67, 64, 48, 63, 67, 55, 56, 60, 62, 59, 43, 47], [65, 67, 67, 66, 60, 60, 62, 64, 62, 61, 54, 49, 53, 60, 53, 49, 55, 55, 35, 49], [59, 46, 59, 62, 32, 62, 66, 63, 63, 63, 62, 60, 56, 45, 49, 41, 52, 46, 40, 24], [68, 72, 74, 74, 68, 52, 63, 68, 54, 54, 49, 35, 52, 47, 43, 49, 43, 25, 23, 20], [53, 54, 46, 55, 63, 65, 65, 65, 64, 64, 60, 60, 57, 50, 50, 56, 35, 46, 30, 26], [43, 53, 60, 62, 60, 58, 55, 54, 53, 50, 56, 48, 54, 51, 52, 46, 47, 48, 35, 37], [44, 47, 52, 56, 59, 60, 58, 55, 42, 48, 54, 29, 53, 54, 49, 48, 41, 41, 42, 33], [46, 49, 48, 42, 40, 45, 39, 40, 34, 46, 48, 42, 30, 43, 46, 42, 40, 34, 24, 23], [43, 40, 40, 46, 48, 45, 44, 46, 44, 40, 42, 39, 42, 42, 39, 36, 34, 24, 21, 13], [46, 50, 50, 49, 50, 51, 48, 50, 49, 52, 45, 49, 48, 49, 48, 45, 40, 33, 27, 26], [36, 38, 38, 38, 41, 41, 31, 29, 23, 21, 8, 30, 25, 20, 30, 29, 17, 20, 9, 13], [48, 52, 53, 52, 43, 39, 37, 30, 29, 37, 28, 23, 29, 28, 32, 26, 21, 26, 21, 20], [44, 45, 47, 48, 40, 37, 38, 34, 42, 37, 24, 32, 29, 38, 33, 30, 22, 22, 7, 11], [48, 49, 52, 56, 58, 55, 53, 49, 51, 45, 52, 51, 48, 45, 39, 45, 47, 38, 35, 19], [49, 53, 55, 55, 50, 50, 42, 38, 42, 46, 47, 37, 35, 40, 32, 31, 7, 21, 16, 14], [40, 44, 46, 48, 47, 49, 46, 47, 45, 44, 48, 39, 43, 43, 39, 38, 27, 25, 24, 17], [31, 38, 42, 43, 38, 45, 48, 40, 37, 28, 43, 22, 33, 39, 32, 3, 20, 27, 7, 9], [25, 33, 37, 37, 28, 39, 39, 36, 22, 28, 36, 16, 32, 31, 30, 16, 10, 18, 11, 10], [69, 73, 78, 82, 86, 84, 79, 61, 73, 61, 64, 53, 67, 67, 66, 67, 65, 64, 61, 57], [78, 82, 82, 84, 90, 92, 89, 86, 89, 88, 86, 86, 85, 84, 81, 79, 73, 66, 35, 56], [79, 85, 89, 91, 94, 95, 95, 93, 92, 87, 83, 81, 76, 70, 67, 61, 52, 29, 58, 63], [75, 82, 86, 87, 88, 89, 90, 91, 91, 91, 92, 92, 91, 90, 89, 88, 84, 81, 73, 67], [76, 78, 77, 77, 83, 85, 87, 89, 89, 89, 91, 90, 89, 88, 86, 83, 74, 71, 76, 73], [75, 80, 83, 84, 76, 78, 84, 86, 82, 80, 80, 80, 80, 79, 78, 76, 73, 68, 70, 72], [72, 78, 82, 84, 89, 92, 93, 93, 93, 92, 91, 91, 89, 86, 74, 78, 87, 86, 76, 76], [66, 70, 74, 78, 85, 87, 85, 85, 83, 84, 82, 80, 80, 76, 71, 66, 55, 53, 60, 62], [71, 78, 81, 83, 83, 82, 82, 81, 77, 78, 76, 76, 74, 70, 62, 63, 69, 70, 63, 66], [74, 79, 82, 81, 71, 75, 79, 78, 80, 81, 83, 83, 82, 81, 79, 75, 71, 70, 61, 58], [73, 78, 80, 81, 82, 84, 84, 83, 80, 78, 77, 80, 77, 78, 75, 75, 69, 67, 57, 53], [71, 78, 82, 83, 81, 79, 71, 58, 59, 66, 66, 67, 59, 61, 57, 49, 50, 51, 58, 59], [73, 77, 77, 78, 87, 90, 86, 86, 91, 92, 84, 91, 89, 87, 82, 82, 74, 63, 67, 65], [73, 79, 84, 87, 90, 90, 90, 89, 90, 89, 88, 87, 82, 72, 78, 75, 83, 77, 69, 66], [65, 68, 74, 78, 81, 81, 80, 80, 80, 79, 80, 79, 77, 74, 68, 69, 70, 70, 66, 68], [70, 76, 79, 80, 81, 81, 81, 82, 82, 82, 81, 80, 75, 65, 75, 77, 70, 75, 69, 63], [73, 76, 77, 77, 71, 65, 65, 64, 65, 65, 63, 61, 54, 51, 58, 56, 57, 51, 41, 46], [60, 61, 58, 52, 54, 61, 58, 61, 57, 49, 56, 56, 61, 60, 58, 38, 64, 53, 51, 51], [59, 55, 61, 63, 65, 67, 67, 68, 64, 68, 69, 68, 71, 67, 42, 52, 64, 63, 47, 56], [73, 78, 80, 81, 81, 82, 80, 80, 78, 77, 68, 72, 76, 71, 77, 74, 68, 72, 68, 61], [62, 70, 75, 78, 79, 78, 78, 79, 80, 78, 72, 68, 79, 74, 71, 75, 71, 59, 67, 56], [67, 68, 64, 59, 72, 74, 74, 73, 71, 71, 67, 67, 71, 64, 66, 64, 61, 53, 55, 52], [43, 65, 71, 74, 71, 69, 75, 76, 78, 76, 63, 70, 75, 49, 67, 68, 71, 68, 41, 55], [77, 79, 80, 78, 72, 71, 76, 77, 75, 73, 64, 65, 65, 72, 60, 59, 67, 67, 48, 60], [75, 68, 66, 73, 65, 72, 76, 73, 73, 71, 73, 70, 66, 50, 58, 51, 61, 55, 48, 32], [80, 85, 87, 88, 83, 68, 77, 81, 58, 66, 58, 50, 65, 59, 53, 58, 52, 44, 25, 26], [66, 69, 66, 55, 74, 77, 77, 77, 75, 74, 71, 72, 63, 63, 57, 62, 51, 57, 41, 43], [50, 60, 71, 74, 73, 70, 69, 68, 63, 57, 70, 63, 67, 59, 66, 58, 60, 59, 40, 48], [57, 57, 64, 70, 73, 73, 71, 65, 58, 62, 67, 60, 64, 67, 61, 59, 46, 54, 53, 39], [61, 65, 66, 63, 47, 61, 60, 62, 57, 52, 66, 56, 58, 62, 62, 51, 58, 41, 21, 31], [53, 48, 59, 64, 66, 62, 57, 62, 58, 54, 60, 54, 56, 56, 57, 54, 47, 40, 23, 24], [62, 65, 65, 64, 66, 66, 62, 62, 58, 64, 53, 65, 61, 64, 62, 59, 50, 39, 41, 41], [50, 52, 49, 41, 53, 54, 52, 47, 22, 34, 43, 47, 38, 41, 41, 42, 34, 39, 30, 18], [63, 67, 69, 68, 61, 51, 53, 50, 54, 51, 46, 46, 47, 50, 45, 41, 35, 38, 32, 18], [58, 62, 64, 65, 58, 53, 54, 50, 57, 54, 44, 43, 46, 53, 51, 36, 34, 24, 25, 28], [51, 59, 70, 75, 76, 72, 69, 59, 70, 59, 70, 66, 63, 64, 61, 58, 60, 48, 48, 33], [58, 65, 66, 61, 68, 70, 62, 70, 55, 67, 65, 63, 62, 57, 47, 45, 39, 35, 23, 20], [58, 64, 67, 67, 64, 66, 62, 63, 65, 64, 66, 59, 61, 58, 55, 56, 43, 43, 34, 12], [47, 49, 58, 61, 55, 60, 65, 57, 50, 50, 60, 58, 50, 55, 52, 48, 37, 44, 24, 22], [43, 50, 54, 53, 41, 54, 57, 56, 33, 51, 56, 50, 53, 51, 47, 33, 28, 33, 26, 22], [62, 67, 71, 73, 73, 73, 76, 76, 77, 78, 78, 77, 72, 62, 56, 48, 40, 43, 46, 45], [69, 70, 71, 71, 71, 70, 71, 68, 69, 70, 69, 67, 64, 60, 48, 50, 57, 56, 42, 37], [66, 70, 72, 73, 73, 72, 74, 74, 73, 72, 70, 69, 67, 66, 61, 56, 58, 61, 60, 50], [66, 70, 71, 71, 67, 56, 63, 67, 58, 54, 61, 58, 58, 58, 58, 57, 53, 50, 50, 46], [68, 71, 71, 68, 68, 66, 66, 65, 68, 68, 68, 67, 66, 65, 62, 59, 55, 48, 46, 48], [56, 53, 55, 65, 71, 73, 73, 70, 71, 69, 68, 66, 63, 60, 48, 52, 59, 59, 50, 43], [53, 56, 59, 62, 63, 64, 64, 64, 63, 63, 62, 62, 61, 60, 58, 56, 51, 43, 36, 33], [38, 37, 38, 41, 45, 42, 42, 43, 44, 44, 43, 38, 27, 26, 38, 39, 35, 30, 26, 23], [50, 53, 53, 53, 53, 52, 53, 51, 49, 49, 48, 45, 41, 34, 23, 36, 40, 38, 31, 25], [55, 56, 57, 57, 56, 55, 54, 54, 53, 52, 51, 51, 49, 47, 42, 33, 34, 30, 34, 33], [48, 50, 53, 55, 56, 52, 54, 53, 51, 50, 47, 41, 40, 47, 49, 45, 42, 45, 37, 37], [44, 46, 44, 39, 34, 42, 33, 40, 34, 32, 20, 25, 30, 33, 35, 33, 30, 30, 17, 18], [36, 38, 37, 36, 34, 31, 31, 33, 29, 27, 26, 31, 38, 41, 40, 37, 35, 31, 13, 31], [33, 37, 38, 39, 41, 40, 40, 40, 40, 38, 35, 30, 20, 33, 33, 21, 28, 15, 4, 21], [26, 30, 32, 33, 32, 33, 31, 31, 30, 31, 29, 24, 22, 25, 24, 19, 12, 21, 18, 17], [20, 23, 23, 16, 26, 32, 30, 26, 27, 25, 21, 19, 19, 17, 23, 25, 9, 24, 10, 8], [19, 17, 20, 20, 21, 22, 20, 18, 18, 21, 19, 22, 18, 9, 19, 17, 16, 19, 15, 0], [26, 27, 27, 28, 27, 28, 16, 26, 21, 19, 17, 14, 22, 23, 22, 23, 0, 13, 17, 12], [27, 25, 24, 23, 26, 19, 18, 21, 18, 26, 27, 29, 23, 16, 18, 15, 24, 19, 18, 6], [33, 33, 34, 34, 31, 26, 30, 28, 26, 23, 25, 26, 28, 28, 25, 22, 17, 17, 9, 11], [28, 32, 34, 34, 33, 25, 24, 29, 29, 28, 25, 20, 29, 34, 33, 27, 29, 25, 22, 17], [25, 25, 23, 18, 16, 27, 30, 24, 28, 22, 0, 20, 24, 9, 27, 14, 22, 20, 13, 12], [16, 18, 20, 22, 21, 16, 14, 14, 11, 17, 18, 16, 11, 20, 12, 14, 11, 16, 8, 7], [29, 30, 29, 27, 15, 15, 14, 11, 17, 18, 15, 3, 15, 12, 14, 9, 0, 2, 0, 12], [27, 24, 17, 12, 11, 1, 18, 11, 16, 10, 13, 8, 13, 6, 7, 8, 2, 9, 9, 9], [20, 19, 17, 12, 18, 22, 13, 10, 18, 10, 10, 9, 12, 9, 8, 8, 10, 6, 7, 9], [24, 23, 17, 6, 18, 24, 12, 17, 7, 15, 17, 0, 8, 4, 13, 15, 11, 9, 1, 1], [23, 23, 20, 12, 9, 19, 7, 4, 15, 16, 16, 16, 13, 18, 12, 8, 8, 10, 8, 12], [19, 20, 16, 8, 17, 15, 11, 11, 12, 12, 19, 11, 17, 11, 9, 6, 10, 1, 12, 0], [20, 19, 13, 3, 9, 14, 19, 19, 18, 21, 21, 17, 22, 13, 7, 13, 11, 9, 10, 14], [18, 18, 18, 19, 16, 17, 19, 19, 16, 22, 18, 17, 16, 7, 17, 5, 9, 8, 14, 11], [25, 26, 24, 21, 16, 14, 18, 10, 7, 0, 11, 17, 12, 0, 12, 4, 0, 3, 7, 0], [17, 22, 21, 15, 3, 19, 7, 12, 8, 7, 2, 0, 0, 14, 7, 11, 10, 8, 4, 11], [19, 15, 13, 7, 9, 9, 10, 7, 6, 14, 6, 3, 0, 5, 7, 0, 7, 7, 8, 6], [22, 21, 19, 17, 11, 4, 11, 12, 0, 9, 8, 8, 7, 0, 7, 8, 0, 2, 9, 5], [20, 25, 27, 26, 18, 13, 10, 14, 18, 19, 18, 12, 15, 18, 15, 16, 14, 18, 18, 14], [0, 8, 11, 7, 11, 0, 12, 9, 6, 9, 11, 7, 0, 7, 0, 5, 0, 0, 0, 2], [17, 20, 22, 21, 4, 11, 9, 0, 10, 0, 10, 10, 0, 9, 11, 3, 4, 2, 2, 7], [6, 0, 7, 13, 11, 1, 5, 6, 4, 11, 15, 2, 1, 2, 1, 5, 5, 4, 2, 4], [12, 13, 10, 8, 11, 8, 5, 14, 4, 5, 9, 15, 9, 9, 7, 9, 11, 5, 11, 12], [66, 72, 76, 79, 84, 84, 85, 86, 88, 89, 88, 87, 81, 76, 69, 59, 48, 45, 43, 46], [69, 78, 81, 83, 83, 82, 84, 83, 83, 85, 83, 82, 80, 77, 66, 65, 74, 73, 54, 55], [73, 76, 80, 83, 85, 85, 85, 86, 84, 83, 81, 79, 78, 77, 73, 67, 66, 71, 72, 66], [65, 75, 80, 82, 82, 77, 71, 78, 74, 73, 77, 76, 74, 73, 71, 68, 63, 60, 60, 59], [70, 78, 83, 84, 81, 80, 77, 78, 80, 81, 81, 80, 79, 77, 75, 72, 68, 64, 59, 58], [68, 73, 72, 60, 83, 87, 88, 86, 86, 84, 82, 81, 79, 76, 68, 55, 71, 73, 66, 60], [61, 69, 73, 76, 81, 82, 82, 82, 82, 80, 80, 80, 79, 77, 75, 74, 69, 63, 49, 53], [61, 62, 59, 59, 63, 64, 63, 66, 63, 62, 59, 57, 52, 42, 56, 57, 52, 47, 43, 45], [62, 71, 75, 77, 76, 76, 75, 73, 70, 71, 70, 68, 65, 60, 41, 51, 58, 58, 49, 45], [69, 77, 80, 81, 82, 80, 79, 79, 77, 76, 75, 74, 71, 69, 64, 61, 54, 44, 48, 50], [68, 73, 75, 78, 82, 81, 80, 79, 78, 78, 77, 73, 64, 61, 70, 68, 53, 67, 55, 52], [66, 72, 73, 71, 65, 66, 68, 70, 66, 61, 58, 50, 38, 53, 56, 54, 44, 48, 28, 33], [62, 68, 74, 77, 78, 77, 77, 78, 76, 76, 74, 72, 65, 58, 50, 66, 69, 65, 62, 45], [60, 68, 74, 76, 78, 79, 80, 79, 79, 79, 77, 76, 72, 69, 68, 67, 62, 64, 59, 48], [52, 49, 62, 67, 69, 70, 69, 70, 71, 70, 69, 68, 64, 60, 53, 47, 59, 60, 52, 44], [55, 60, 63, 65, 65, 64, 63, 64, 64, 63, 61, 58, 38, 53, 56, 58, 46, 54, 47, 36], [42, 44, 48, 52, 54, 57, 59, 58, 58, 56, 54, 52, 43, 39, 45, 49, 47, 38, 37, 26], [47, 49, 50, 48, 48, 46, 22, 48, 41, 49, 48, 49, 43, 36, 43, 48, 28, 27, 27, 0], [53, 55, 53, 49, 47, 52, 50, 52, 54, 53, 52, 53, 47, 30, 39, 36, 36, 38, 34, 24], [48, 56, 59, 62, 60, 58, 57, 57, 56, 54, 49, 43, 47, 53, 49, 49, 46, 37, 33, 30], [54, 60, 63, 64, 66, 66, 67, 67, 66, 65, 61, 54, 38, 56, 63, 61, 51, 57, 52, 46], [36, 40, 53, 58, 61, 62, 61, 59, 60, 62, 63, 61, 53, 55, 50, 43, 49, 50, 44, 36], [39, 44, 52, 55, 55, 57, 55, 56, 49, 48, 43, 44, 43, 47, 44, 50, 35, 23, 36, 28], [43, 45, 46, 49, 45, 44, 29, 34, 39, 29, 32, 34, 33, 36, 36, 31, 24, 11, 3, 11], [45, 49, 50, 48, 48, 46, 43, 43, 41, 39, 38, 31, 34, 36, 36, 32, 33, 23, 13, 13], [40, 43, 43, 39, 35, 25, 36, 40, 35, 26, 25, 24, 24, 31, 33, 25, 29, 18, 13, 15], [38, 40, 36, 24, 41, 45, 46, 39, 46, 35, 34, 35, 32, 33, 42, 35, 26, 17, 14, 12], [38, 41, 41, 39, 32, 31, 26, 34, 39, 32, 31, 29, 36, 43, 35, 37, 24, 12, 15, 9], [21, 21, 29, 31, 27, 27, 25, 26, 27, 9, 20, 22, 32, 31, 29, 27, 13, 16, 10, 3], [38, 40, 40, 39, 39, 35, 36, 35, 36, 37, 37, 30, 42, 40, 31, 32, 16, 21, 21, 10], [41, 43, 41, 41, 40, 34, 39, 39, 40, 38, 25, 42, 40, 40, 34, 36, 32, 21, 11, 7], [34, 33, 33, 38, 40, 41, 37, 40, 34, 33, 30, 30, 39, 30, 26, 19, 17, 18, 11, 5], [34, 35, 31, 27, 26, 31, 20, 22, 10, 20, 18, 13, 12, 8, 9, 9, 6, 2, 7, 6], [42, 47, 47, 44, 26, 36, 37, 32, 27, 20, 34, 20, 20, 22, 24, 20, 3, 10, 1, 4], [43, 48, 49, 46, 28, 36, 36, 33, 39, 39, 32, 34, 29, 25, 21, 20, 12, 12, 11, 8], [35, 39, 40, 38, 35, 36, 33, 30, 19, 31, 31, 31, 21, 26, 18, 20, 3, 6, 6, 9], [29, 24, 14, 14, 19, 26, 26, 19, 16, 23, 22, 18, 22, 14, 17, 9, 5, 9, 11, 2], [20, 22, 19, 23, 29, 31, 32, 29, 23, 30, 32, 24, 25, 19, 19, 23, 17, 14, 12, 6], [25, 24, 26, 28, 31, 31, 31, 31, 28, 35, 38, 36, 24, 35, 31, 22, 7, 12, 10, 0], [25, 28, 28, 27, 21, 20, 20, 17, 7, 22, 19, 20, 4, 17, 13, 8, 13, 4, 7, 7], [68, 74, 80, 85, 90, 91, 92, 94, 96, 95, 95, 94, 87, 82, 76, 68, 57, 40, 48, 41], [80, 87, 89, 90, 90, 91, 94, 92, 92, 93, 91, 90, 88, 85, 74, 71, 82, 81, 62, 63], [82, 85, 88, 91, 93, 93, 93, 94, 92, 90, 88, 87, 86, 85, 80, 73, 75, 80, 79, 70], [75, 84, 89, 91, 89, 85, 80, 85, 77, 78, 79, 76, 75, 75, 74, 72, 70, 68, 67, 66], [78, 86, 90, 92, 88, 87, 84, 85, 89, 88, 88, 88, 86, 85, 82, 79, 73, 69, 66, 66], [77, 81, 80, 65, 91, 96, 97, 95, 95, 94, 92, 90, 88, 85, 75, 68, 81, 81, 71, 67], [70, 78, 82, 85, 90, 91, 91, 90, 89, 89, 88, 88, 86, 84, 82, 81, 77, 69, 59, 56], [70, 72, 69, 70, 72, 75, 75, 78, 75, 75, 72, 69, 61, 49, 67, 68, 62, 57, 47, 51], [75, 83, 86, 87, 87, 87, 86, 85, 83, 82, 80, 78, 74, 69, 46, 62, 68, 67, 57, 51], [80, 88, 92, 93, 94, 92, 91, 91, 90, 89, 88, 87, 84, 81, 77, 73, 57, 64, 64, 63], [79, 84, 87, 91, 95, 93, 92, 90, 90, 90, 89, 86, 77, 70, 81, 80, 71, 79, 68, 66], [77, 82, 83, 81, 77, 77, 78, 78, 76, 74, 73, 69, 58, 58, 65, 68, 60, 61, 53, 36], [74, 79, 85, 88, 89, 88, 89, 89, 89, 89, 86, 85, 79, 72, 64, 79, 81, 72, 73, 64], [74, 82, 87, 90, 92, 93, 93, 92, 92, 92, 90, 89, 85, 82, 81, 80, 77, 77, 70, 61], [71, 70, 77, 81, 82, 83, 83, 84, 84, 82, 81, 79, 76, 73, 67, 67, 74, 73, 52, 63], [72, 77, 80, 81, 81, 80, 78, 80, 79, 78, 76, 74, 57, 67, 71, 71, 47, 67, 61, 53], [58, 60, 64, 65, 65, 70, 72, 72, 71, 70, 67, 66, 58, 54, 60, 64, 57, 47, 45, 42], [66, 66, 65, 60, 59, 63, 56, 63, 57, 66, 66, 69, 65, 53, 64, 68, 50, 50, 48, 33], [69, 73, 72, 70, 72, 73, 70, 73, 74, 74, 76, 75, 69, 60, 61, 58, 60, 61, 50, 48], [71, 75, 76, 77, 75, 72, 70, 70, 70, 70, 66, 62, 62, 67, 61, 61, 55, 53, 50, 43], [69, 78, 82, 83, 84, 84, 85, 84, 84, 83, 79, 73, 61, 73, 80, 77, 72, 70, 65, 59], [68, 70, 75, 79, 82, 82, 81, 75, 76, 79, 81, 81, 74, 74, 73, 59, 71, 70, 58, 43], [51, 68, 76, 80, 81, 81, 79, 79, 74, 70, 61, 67, 63, 68, 65, 70, 56, 49, 54, 44], [72, 78, 79, 79, 79, 77, 70, 66, 64, 61, 61, 61, 55, 60, 62, 57, 53, 41, 38, 33], [68, 69, 67, 67, 69, 70, 70, 70, 66, 61, 61, 59, 58, 57, 56, 51, 48, 42, 32, 22], [63, 66, 65, 62, 50, 48, 63, 51, 54, 54, 44, 43, 45, 42, 49, 37, 45, 44, 35, 28], [62, 65, 66, 68, 71, 71, 68, 55, 68, 59, 63, 60, 42, 59, 57, 55, 45, 49, 35, 16], [63, 66, 65, 58, 53, 58, 65, 68, 67, 66, 60, 53, 61, 66, 54, 60, 52, 45, 15, 25], [55, 58, 62, 63, 60, 60, 62, 65, 68, 68, 64, 47, 54, 54, 62, 54, 38, 41, 33, 26], [60, 61, 60, 57, 57, 60, 68, 71, 72, 71, 64, 62, 67, 70, 62, 59, 58, 35, 49, 37], [63, 66, 67, 67, 66, 66, 67, 67, 65, 63, 60, 63, 65, 62, 58, 57, 54, 48, 32, 34], [53, 57, 62, 65, 67, 67, 63, 62, 54, 47, 52, 55, 59, 59, 53, 43, 43, 36, 37, 31], [41, 41, 49, 47, 47, 46, 48, 46, 45, 37, 30, 35, 38, 37, 37, 34, 26, 23, 16, 7], [54, 59, 59, 56, 56, 60, 50, 53, 54, 55, 50, 50, 51, 47, 50, 29, 27, 25, 15, 14], [56, 59, 61, 59, 57, 43, 55, 58, 61, 58, 55, 50, 55, 52, 42, 35, 32, 26, 11, 11], [53, 59, 60, 59, 53, 60, 64, 58, 60, 39, 46, 57, 54, 51, 48, 46, 38, 37, 15, 17], [45, 40, 38, 34, 45, 49, 48, 43, 43, 46, 46, 29, 38, 31, 33, 28, 16, 16, 16, 6], [49, 51, 52, 53, 54, 56, 52, 40, 41, 47, 49, 41, 42, 42, 19, 37, 37, 28, 18, 2], [45, 48, 49, 49, 46, 51, 50, 41, 39, 47, 53, 49, 40, 47, 40, 31, 29, 26, 16, 9], [36, 40, 41, 39, 40, 37, 36, 39, 43, 41, 39, 36, 41, 22, 32, 30, 24, 5, 4, 0], [63, 70, 73, 74, 78, 80, 78, 76, 75, 78, 75, 73, 73, 73, 71, 70, 67, 65, 63, 57], [72, 74, 71, 60, 45, 51, 66, 64, 69, 66, 65, 65, 66, 65, 64, 62, 56, 52, 50, 47], [66, 68, 66, 61, 59, 64, 70, 66, 71, 70, 70, 70, 69, 68, 65, 63, 60, 53, 42, 53], [62, 66, 67, 66, 68, 68, 68, 69, 69, 69, 69, 68, 67, 66, 63, 59, 38, 55, 56, 51], [51, 51, 53, 60, 65, 66, 64, 64, 64, 63, 63, 62, 60, 59, 53, 44, 45, 47, 42, 50], [51, 49, 44, 39, 51, 56, 56, 53, 49, 46, 45, 47, 40, 30, 33, 37, 42, 39, 44, 43], [50, 50, 53, 56, 59, 57, 60, 58, 56, 56, 56, 54, 50, 44, 36, 46, 46, 38, 50, 43], [49, 51, 48, 45, 48, 45, 46, 48, 47, 46, 46, 44, 41, 39, 32, 33, 28, 30, 32, 33], [40, 42, 42, 44, 45, 46, 45, 45, 43, 42, 42, 39, 36, 31, 30, 34, 26, 31, 34, 28], [31, 37, 41, 43, 46, 46, 47, 46, 44, 43, 40, 33, 27, 36, 40, 38, 18, 38, 32, 19], [31, 31, 32, 32, 33, 33, 28, 30, 30, 30, 31, 27, 27, 31, 33, 21, 23, 24, 9, 18], [30, 24, 18, 15, 10, 25, 28, 30, 26, 20, 26, 26, 17, 13, 16, 13, 16, 21, 21, 8], [32, 35, 35, 35, 35, 34, 34, 32, 33, 29, 27, 18, 19, 12, 7, 27, 23, 23, 23, 20], [25, 21, 20, 22, 21, 17, 24, 24, 23, 23, 23, 14, 22, 24, 15, 14, 15, 19, 0, 5], [25, 21, 14, 5, 19, 20, 15, 22, 14, 20, 12, 23, 25, 24, 22, 9, 17, 12, 14, 14], [10, 15, 15, 20, 21, 19, 20, 13, 19, 19, 10, 21, 16, 3, 17, 13, 10, 0, 16, 17], [20, 17, 16, 10, 12, 24, 16, 15, 9, 9, 8, 10, 3, 13, 3, 4, 5, 5, 12, 7], [21, 16, 12, 21, 19, 17, 20, 16, 18, 20, 14, 9, 13, 4, 13, 0, 16, 0, 9, 9], [16, 22, 26, 26, 21, 23, 25, 24, 24, 25, 22, 23, 15, 14, 15, 14, 18, 13, 8, 7], [8, 14, 13, 13, 10, 16, 15, 13, 16, 13, 8, 6, 11, 16, 7, 5, 9, 7, 6, 8], [20, 18, 18, 17, 21, 15, 19, 13, 18, 15, 15, 16, 19, 23, 10, 4, 11, 10, 6, 2], [25, 25, 26, 27, 26, 26, 27, 27, 24, 25, 21, 18, 12, 20, 14, 13, 10, 17, 8, 6], [7, 15, 14, 12, 10, 7, 14, 12, 15, 6, 8, 14, 0, 7, 0, 0, 5, 6, 1, 6], [15, 0, 4, 8, 11, 3, 8, 12, 17, 14, 7, 14, 2, 8, 9, 0, 10, 0, 9, 11], [19, 14, 1, 3, 2, 0, 10, 3, 15, 16, 2, 12, 12, 8, 10, 9, 14, 7, 16, 2], [18, 7, 11, 15, 15, 11, 2, 10, 16, 11, 9, 0, 8, 0, 8, 5, 11, 7, 10, 14], [4, 9, 6, 4, 10, 9, 4, 9, 5, 11, 16, 10, 4, 7, 5, 0, 12, 7, 11, 8], [18, 14, 10, 11, 10, 12, 14, 8, 0, 0, 14, 4, 0, 10, 8, 9, 4, 0, 8, 10], [18, 16, 16, 16, 18, 18, 13, 15, 17, 8, 20, 18, 20, 15, 20, 14, 15, 16, 17, 17], [8, 11, 0, 12, 3, 0, 7, 9, 10, 0, 1, 4, 15, 12, 9, 11, 0, 8, 0, 6], [12, 1, 8, 12, 11, 13, 13, 0, 6, 2, 12, 5, 6, 13, 0, 12, 0, 12, 11, 1], [12, 12, 3, 12, 6, 16, 12, 12, 4, 8, 0, 7, 11, 11, 0, 0, 0, 6, 8, 13], [10, 13, 14, 7, 0, 3, 10, 0, 10, 0, 0, 12, 13, 14, 0, 6, 5, 12, 11, 11], [10, 7, 9, 9, 12, 12, 6, 10, 14, 9, 11, 12, 5, 3, 0, 9, 9, 6, 0, 0], [8, 9, 10, 10, 1, 8, 0, 9, 2, 0, 1, 9, 10, 13, 5, 13, 5, 14, 10, 11], [15, 15, 13, 14, 13, 17, 12, 3, 6, 10, 6, 9, 4, 8, 5, 0, 0, 6, 3, 10], [12, 8, 7, 7, 0, 0, 6, 7, 0, 12, 11, 5, 6, 11, 6, 1, 11, 6, 6, 4], [0, 15, 15, 15, 16, 16, 16, 14, 10, 15, 12, 6, 5, 4, 10, 12, 7, 5, 0, 10], [2, 2, 13, 17, 1, 9, 11, 11, 10, 0, 1, 9, 1, 7, 7, 9, 10, 12, 8, 7], [16, 11, 9, 8, 0, 6, 3, 0, 0, 12, 3, 4, 5, 5, 4, 4, 4, 9, 9, 10], [55, 68, 77, 82, 84, 89, 88, 87, 84, 87, 84, 84, 83, 82, 81, 79, 76, 74, 69, 63], [68, 79, 85, 85, 72, 65, 75, 79, 79, 78, 76, 77, 77, 76, 75, 72, 67, 62, 59, 59], [64, 75, 80, 80, 66, 71, 81, 76, 82, 80, 80, 80, 79, 78, 76, 74, 71, 66, 54, 64], [64, 72, 77, 78, 79, 79, 81, 81, 81, 81, 81, 80, 79, 77, 75, 71, 50, 65, 67, 60], [54, 61, 63, 65, 75, 78, 77, 77, 77, 77, 77, 76, 75, 74, 70, 64, 50, 61, 55, 62], [61, 66, 66, 64, 60, 69, 72, 68, 67, 69, 70, 68, 65, 62, 53, 33, 53, 52, 55, 56], [58, 67, 68, 70, 77, 78, 79, 79, 76, 76, 76, 75, 73, 69, 58, 61, 64, 58, 65, 59], [63, 68, 70, 70, 66, 69, 66, 68, 68, 67, 66, 64, 61, 58, 50, 49, 42, 46, 50, 52], [48, 60, 65, 67, 69, 68, 69, 69, 67, 65, 65, 64, 61, 57, 49, 55, 52, 52, 57, 49], [51, 44, 60, 66, 71, 74, 74, 76, 74, 73, 70, 67, 60, 52, 61, 63, 55, 60, 58, 46], [44, 51, 58, 61, 62, 64, 62, 62, 61, 62, 63, 62, 56, 47, 59, 56, 56, 50, 41, 37], [51, 52, 41, 52, 57, 57, 59, 60, 55, 56, 53, 53, 48, 43, 38, 31, 39, 45, 41, 24], [54, 62, 64, 65, 64, 64, 64, 64, 64, 62, 60, 57, 48, 39, 49, 47, 52, 47, 42, 40], [54, 59, 62, 62, 63, 61, 60, 57, 55, 53, 50, 48, 40, 45, 48, 40, 52, 41, 42, 20], [50, 56, 63, 64, 64, 63, 59, 60, 63, 63, 58, 56, 48, 47, 51, 49, 49, 41, 39, 34], [53, 58, 62, 62, 61, 60, 60, 61, 59, 59, 58, 55, 46, 36, 42, 50, 51, 37, 39, 26], [40, 50, 55, 55, 49, 58, 60, 54, 50, 43, 38, 45, 34, 37, 38, 36, 37, 20, 26, 9], [42, 47, 38, 47, 49, 46, 51, 49, 48, 42, 41, 42, 39, 33, 42, 35, 39, 30, 25, 23], [41, 49, 51, 51, 53, 53, 51, 52, 50, 47, 44, 45, 49, 50, 41, 37, 45, 39, 37, 27], [41, 47, 46, 42, 44, 41, 36, 32, 26, 27, 29, 30, 26, 29, 16, 36, 25, 17, 23, 19], [36, 47, 47, 47, 48, 48, 46, 45, 45, 43, 37, 41, 46, 45, 35, 45, 36, 35, 31, 19], [39, 50, 55, 57, 58, 58, 57, 56, 54, 52, 48, 51, 53, 48, 50, 46, 46, 39, 38, 29], [37, 43, 44, 43, 40, 39, 35, 34, 30, 36, 36, 35, 32, 35, 35, 40, 15, 25, 17, 16], [29, 36, 37, 37, 37, 36, 31, 29, 29, 26, 22, 27, 29, 25, 27, 25, 19, 21, 12, 5], [26, 30, 29, 21, 23, 18, 21, 30, 23, 23, 20, 19, 23, 19, 18, 21, 8, 4, 10, 14], [24, 25, 29, 32, 29, 21, 31, 30, 31, 30, 13, 16, 25, 19, 28, 22, 3, 14, 7, 5], [8, 24, 26, 22, 32, 33, 34, 30, 14, 19, 15, 24, 25, 22, 29, 29, 17, 17, 9, 9], [12, 10, 27, 31, 27, 27, 28, 27, 27, 26, 25, 21, 18, 0, 12, 13, 0, 3, 2, 9], [20, 23, 24, 27, 33, 29, 29, 27, 27, 30, 25, 29, 21, 20, 24, 20, 19, 18, 16, 13], [21, 22, 18, 18, 24, 18, 20, 26, 28, 29, 30, 27, 28, 34, 26, 25, 21, 0, 9, 9], [18, 16, 21, 24, 28, 31, 29, 29, 26, 29, 32, 30, 23, 26, 29, 24, 17, 16, 8, 4], [20, 30, 32, 26, 33, 33, 22, 9, 18, 23, 14, 26, 26, 23, 24, 22, 12, 13, 3, 6], [16, 25, 29, 29, 25, 26, 25, 21, 8, 7, 17, 14, 4, 0, 9, 0, 0, 1, 10, 2], [17, 14, 6, 13, 13, 14, 10, 13, 8, 14, 7, 0, 14, 19, 0, 6, 1, 8, 5, 8], [10, 5, 17, 21, 15, 21, 18, 21, 14, 17, 13, 20, 19, 15, 5, 15, 1, 0, 11, 13], [16, 24, 23, 21, 21, 20, 24, 21, 20, 21, 15, 13, 19, 16, 15, 17, 12, 10, 8, 0], [12, 22, 28, 30, 30, 29, 26, 22, 24, 24, 25, 22, 15, 22, 17, 16, 16, 11, 10, 4], [6, 7, 13, 17, 15, 15, 11, 13, 18, 17, 22, 18, 11, 18, 13, 11, 7, 0, 2, 4], [0, 22, 26, 25, 17, 22, 23, 23, 24, 22, 19, 20, 11, 10, 3, 12, 13, 7, 13, 0], [16, 0, 19, 21, 21, 21, 18, 13, 10, 11, 8, 4, 9, 10, 10, 8, 13, 0, 8, 0], [69, 87, 93, 96, 97, 102, 101, 99, 97, 97, 96, 96, 95, 94, 92, 90, 86, 83, 78, 70], [83, 93, 98, 96, 84, 81, 83, 88, 85, 86, 82, 83, 84, 83, 82, 80, 75, 67, 69, 69], [78, 89, 92, 91, 68, 85, 91, 84, 93, 94, 94, 94, 92, 91, 88, 86, 82, 76, 66, 75], [78, 86, 91, 92, 92, 92, 94, 95, 94, 94, 94, 94, 92, 91, 88, 84, 63, 77, 75, 72], [73, 78, 76, 76, 87, 89, 87, 86, 85, 84, 83, 83, 82, 80, 76, 70, 61, 68, 53, 70], [74, 79, 78, 74, 74, 81, 85, 82, 67, 71, 78, 75, 72, 68, 59, 53, 64, 60, 65, 65], [66, 75, 77, 83, 91, 92, 94, 93, 90, 88, 86, 84, 82, 78, 69, 71, 74, 68, 77, 66], [77, 82, 85, 86, 78, 83, 83, 83, 82, 83, 82, 81, 78, 74, 65, 63, 60, 63, 68, 65], [70, 73, 82, 85, 84, 83, 85, 86, 81, 80, 81, 79, 74, 71, 62, 65, 57, 67, 68, 58], [76, 73, 77, 82, 86, 89, 88, 90, 89, 88, 86, 84, 77, 63, 76, 78, 63, 78, 71, 54], [67, 71, 76, 77, 79, 81, 74, 73, 75, 75, 75, 73, 71, 71, 76, 76, 63, 55, 59, 54], [72, 74, 69, 57, 68, 70, 78, 79, 75, 77, 74, 72, 67, 65, 58, 53, 59, 70, 54, 52], [75, 80, 81, 80, 79, 79, 80, 81, 80, 79, 77, 76, 69, 60, 64, 63, 65, 64, 57, 57], [70, 75, 78, 80, 80, 77, 79, 81, 79, 81, 78, 76, 68, 61, 62, 64, 57, 68, 41, 53], [68, 78, 84, 86, 86, 85, 83, 81, 84, 81, 78, 77, 71, 47, 71, 70, 75, 67, 61, 52], [78, 82, 85, 85, 84, 83, 83, 85, 82, 81, 79, 75, 64, 54, 64, 68, 72, 64, 60, 49], [63, 75, 81, 80, 76, 83, 85, 78, 72, 76, 56, 66, 61, 43, 58, 55, 59, 50, 50, 44], [73, 76, 69, 76, 73, 73, 77, 74, 75, 71, 68, 66, 68, 68, 69, 64, 61, 48, 42, 45], [71, 77, 78, 77, 80, 81, 76, 81, 80, 79, 75, 69, 65, 73, 56, 68, 68, 58, 43, 52], [69, 73, 73, 72, 72, 66, 68, 71, 71, 69, 62, 57, 56, 54, 57, 62, 47, 52, 34, 20], [66, 72, 70, 70, 65, 70, 66, 67, 65, 67, 64, 59, 55, 58, 43, 61, 54, 52, 45, 33], [68, 79, 83, 85, 86, 86, 85, 85, 82, 80, 71, 66, 76, 76, 75, 65, 67, 56, 41, 52], [71, 78, 79, 79, 79, 79, 75, 72, 73, 72, 71, 69, 54, 63, 70, 75, 52, 62, 49, 32], [69, 75, 77, 77, 76, 76, 74, 74, 70, 70, 60, 54, 63, 56, 67, 66, 38, 57, 47, 40], [60, 62, 55, 50, 59, 58, 56, 51, 48, 47, 45, 41, 44, 28, 50, 33, 23, 38, 23, 13], [53, 55, 62, 66, 64, 61, 61, 61, 62, 61, 56, 51, 44, 53, 57, 35, 47, 33, 36, 24], [61, 65, 64, 62, 67, 68, 68, 67, 67, 66, 60, 48, 57, 47, 64, 59, 45, 46, 38, 29], [60, 67, 69, 67, 67, 66, 65, 65, 64, 62, 56, 34, 50, 45, 54, 50, 42, 42, 35, 26], [55, 61, 62, 58, 52, 53, 58, 59, 58, 55, 29, 47, 50, 56, 56, 42, 47, 39, 32, 23], [63, 66, 65, 68, 72, 72, 70, 67, 68, 69, 69, 66, 55, 72, 67, 58, 56, 51, 35, 29], [65, 66, 59, 65, 70, 68, 61, 65, 59, 55, 58, 59, 64, 58, 59, 60, 43, 28, 12, 24], [68, 74, 76, 77, 78, 75, 71, 69, 63, 66, 61, 63, 51, 60, 55, 48, 44, 40, 29, 19], [63, 69, 70, 68, 65, 65, 65, 60, 50, 57, 47, 52, 30, 46, 37, 33, 26, 30, 7, 8], [53, 58, 57, 55, 49, 55, 48, 52, 44, 38, 25, 39, 36, 46, 39, 34, 33, 12, 15, 3], [53, 59, 61, 60, 58, 58, 57, 55, 51, 43, 48, 50, 52, 46, 41, 40, 38, 27, 14, 9], [58, 63, 63, 63, 64, 63, 63, 63, 58, 53, 45, 49, 48, 51, 40, 45, 32, 21, 17, 15], [59, 67, 70, 70, 68, 66, 64, 60, 48, 53, 53, 53, 42, 55, 43, 49, 41, 31, 18, 7], [54, 62, 64, 64, 64, 64, 64, 59, 56, 46, 51, 50, 54, 58, 29, 44, 39, 29, 16, 12], [61, 67, 70, 70, 70, 69, 67, 66, 62, 58, 47, 50, 46, 55, 45, 37, 37, 23, 3, 10], [55, 63, 67, 68, 65, 62, 55, 50, 53, 58, 57, 52, 50, 49, 45, 21, 28, 18, 0, 8], [67, 71, 75, 76, 75, 73, 69, 67, 71, 67, 67, 66, 66, 64, 60, 58, 47, 28, 35, 25], [73, 75, 76, 78, 79, 79, 80, 81, 81, 81, 80, 80, 78, 77, 75, 72, 68, 61, 54, 59], [71, 74, 74, 74, 70, 68, 71, 69, 70, 70, 69, 68, 67, 65, 60, 55, 29, 46, 52, 50], [66, 66, 65, 68, 72, 72, 70, 68, 65, 64, 63, 61, 59, 56, 53, 52, 40, 47, 49, 24], [50, 52, 49, 47, 49, 44, 47, 36, 32, 49, 50, 49, 47, 46, 43, 35, 38, 41, 31, 35], [55, 56, 55, 54, 55, 56, 56, 53, 53, 50, 49, 48, 45, 43, 37, 28, 37, 38, 18, 32], [56, 58, 59, 59, 59, 59, 59, 59, 58, 58, 57, 56, 54, 52, 45, 34, 41, 36, 38, 34], [37, 38, 38, 40, 40, 42, 39, 40, 39, 41, 40, 38, 34, 34, 29, 26, 21, 25, 22, 21], [20, 29, 33, 34, 35, 31, 28, 19, 16, 27, 16, 8, 22, 21, 23, 20, 23, 25, 14, 20], [32, 36, 37, 34, 29, 33, 30, 29, 31, 33, 30, 27, 21, 16, 12, 27, 25, 18, 16, 7], [33, 37, 39, 38, 37, 38, 38, 38, 36, 35, 34, 31, 26, 12, 27, 31, 22, 16, 13, 0], [33, 38, 39, 38, 38, 36, 36, 36, 35, 35, 35, 33, 27, 10, 20, 17, 24, 15, 17, 18], [26, 28, 27, 25, 28, 27, 26, 27, 23, 27, 19, 23, 23, 11, 19, 20, 19, 17, 6, 13], [25, 21, 25, 18, 19, 22, 18, 21, 16, 18, 19, 20, 2, 14, 12, 11, 7, 15, 2, 0], [31, 30, 24, 26, 24, 26, 21, 25, 21, 20, 17, 18, 12, 12, 14, 10, 7, 11, 4, 17], [15, 11, 19, 13, 0, 0, 13, 11, 10, 12, 11, 4, 11, 12, 13, 11, 0, 10, 14, 11], [12, 11, 5, 10, 1, 9, 0, 18, 5, 14, 16, 13, 12, 0, 10, 11, 4, 7, 0, 12], [16, 13, 4, 0, 15, 7, 15, 0, 13, 18, 9, 9, 11, 9, 0, 0, 9, 13, 4, 10], [11, 13, 15, 12, 9, 8, 6, 16, 16, 7, 8, 8, 6, 1, 0, 7, 14, 15, 11, 1], [13, 19, 11, 10, 2, 3, 0, 11, 9, 0, 14, 1, 6, 7, 14, 1, 10, 0, 11, 16], [23, 19, 21, 18, 22, 16, 13, 0, 14, 13, 10, 7, 11, 7, 12, 7, 13, 0, 12, 13], [14, 13, 20, 23, 22, 18, 11, 17, 17, 6, 12, 16, 12, 10, 10, 11, 12, 11, 6, 0], [15, 12, 21, 19, 16, 15, 17, 18, 16, 17, 14, 16, 15, 12, 15, 20, 19, 13, 19, 15], [21, 22, 21, 12, 0, 9, 0, 17, 11, 0, 9, 6, 6, 3, 4, 3, 6, 11, 0, 0], [13, 15, 13, 13, 10, 9, 9, 1, 9, 6, 5, 12, 10, 11, 3, 10, 8, 15, 3, 9], [17, 3, 17, 19, 7, 15, 4, 12, 8, 11, 12, 6, 0, 9, 5, 0, 2, 3, 13, 6], [15, 8, 14, 17, 9, 13, 7, 7, 8, 14, 2, 9, 6, 13, 7, 0, 6, 9, 11, 10], [0, 7, 6, 13, 16, 12, 7, 11, 12, 14, 5, 3, 11, 14, 0, 7, 4, 7, 11, 0], [14, 8, 13, 3, 12, 18, 9, 0, 13, 9, 7, 1, 10, 10, 0, 8, 9, 0, 0, 14], [15, 14, 12, 0, 8, 4, 11, 6, 10, 0, 0, 4, 10, 4, 2, 7, 8, 0, 6, 6], [11, 10, 9, 17, 12, 1, 6, 13, 2, 11, 13, 1, 6, 9, 11, 12, 6, 13, 4, 12], [12, 4, 7, 5, 2, 11, 6, 0, 6, 10, 14, 15, 14, 0, 11, 7, 0, 9, 14, 9], [10, 10, 0, 10, 5, 12, 0, 4, 11, 12, 8, 1, 6, 11, 6, 0, 4, 9, 12, 14], [9, 5, 11, 7, 12, 1, 10, 10, 12, 7, 7, 4, 7, 0, 5, 10, 10, 11, 10, 12], [13, 16, 9, 12, 6, 16, 11, 12, 3, 12, 10, 6, 0, 0, 12, 9, 14, 9, 7, 11], [10, 8, 13, 16, 8, 10, 12, 10, 6, 11, 14, 9, 0, 7, 3, 16, 12, 13, 11, 10], [2, 6, 11, 10, 0, 7, 2, 4, 8, 14, 6, 18, 13, 10, 9, 7, 7, 5, 12, 11], [19, 16, 13, 13, 12, 7, 8, 15, 13, 10, 3, 12, 10, 12, 14, 7, 18, 3, 11, 13], [15, 16, 18, 7, 11, 13, 10, 11, 11, 7, 15, 11, 13, 0, 11, 7, 9, 1, 6, 7], [19, 14, 15, 16, 12, 1, 12, 9, 10, 12, 5, 13, 0, 2, 14, 3, 11, 11, 1, 5], [62, 78, 82, 86, 88, 85, 82, 82, 83, 80, 80, 78, 77, 76, 73, 70, 65, 60, 48, 43], [72, 83, 89, 89, 92, 92, 93, 93, 95, 94, 93, 93, 92, 91, 89, 86, 80, 72, 68, 73], [53, 81, 88, 89, 88, 84, 86, 85, 85, 86, 86, 84, 82, 80, 76, 70, 57, 63, 65, 63], [69, 80, 83, 82, 87, 88, 86, 86, 82, 81, 79, 77, 74, 72, 66, 65, 61, 53, 63, 53], [52, 66, 69, 67, 62, 62, 57, 56, 60, 67, 67, 67, 65, 64, 59, 53, 49, 55, 50, 41], [66, 74, 75, 76, 73, 75, 76, 73, 73, 69, 68, 67, 65, 63, 57, 41, 56, 57, 46, 52], [66, 78, 82, 83, 84, 83, 84, 84, 83, 83, 82, 81, 79, 76, 67, 62, 68, 64, 61, 58], [57, 61, 69, 65, 65, 66, 67, 68, 69, 69, 68, 68, 66, 62, 51, 52, 53, 34, 49, 43], [58, 60, 63, 67, 61, 64, 57, 53, 53, 54, 54, 52, 51, 47, 37, 42, 49, 43, 41, 32], [59, 68, 74, 76, 75, 74, 75, 74, 73, 72, 72, 70, 67, 63, 60, 63, 62, 53, 50, 41], [55, 65, 68, 70, 70, 70, 71, 70, 69, 68, 66, 64, 58, 45, 61, 63, 56, 45, 42, 42], [53, 61, 67, 68, 69, 68, 66, 67, 67, 67, 66, 66, 63, 59, 56, 54, 51, 45, 44, 29], [42, 59, 62, 60, 60, 59, 61, 64, 63, 60, 57, 57, 53, 40, 42, 41, 48, 42, 20, 25], [54, 68, 72, 72, 72, 71, 71, 71, 71, 71, 69, 67, 62, 52, 41, 54, 54, 46, 45, 38], [57, 68, 69, 63, 65, 64, 66, 67, 67, 63, 60, 56, 49, 47, 52, 54, 47, 41, 37, 29], [52, 52, 54, 56, 45, 49, 47, 49, 46, 33, 29, 33, 40, 44, 42, 40, 33, 29, 24, 19], [42, 47, 45, 46, 43, 43, 49, 46, 48, 47, 47, 45, 38, 40, 37, 35, 36, 28, 19, 9], [40, 48, 49, 49, 48, 48, 47, 44, 41, 42, 41, 35, 35, 36, 36, 33, 30, 24, 19, 11], [43, 49, 52, 51, 52, 54, 51, 52, 48, 50, 46, 40, 41, 47, 50, 47, 37, 35, 19, 20], [35, 30, 32, 35, 43, 45, 46, 47, 47, 46, 45, 43, 37, 34, 36, 35, 33, 18, 13, 13], [41, 44, 42, 42, 42, 39, 42, 41, 38, 40, 37, 37, 34, 35, 35, 33, 25, 19, 11, 9], [38, 41, 39, 28, 34, 33, 40, 40, 40, 40, 38, 34, 30, 36, 40, 37, 30, 28, 21, 3], [30, 36, 39, 41, 40, 43, 43, 44, 43, 42, 39, 36, 34, 38, 33, 32, 29, 24, 15, 12], [29, 29, 13, 15, 21, 24, 28, 28, 26, 29, 29, 20, 24, 25, 19, 21, 14, 9, 18, 7], [34, 33, 29, 15, 26, 31, 25, 18, 21, 19, 14, 19, 10, 23, 15, 17, 10, 16, 2, 4], [31, 34, 30, 32, 36, 33, 34, 35, 36, 36, 33, 29, 21, 25, 24, 29, 3, 15, 6, 0], [22, 30, 33, 34, 36, 35, 35, 34, 32, 31, 26, 20, 21, 26, 22, 13, 12, 1, 3, 0], [23, 33, 37, 38, 39, 40, 40, 40, 39, 37, 34, 31, 29, 30, 13, 20, 17, 9, 8, 15], [8, 10, 25, 27, 27, 15, 25, 24, 21, 24, 20, 16, 13, 12, 18, 9, 13, 3, 0, 9], [14, 28, 33, 33, 32, 33, 35, 25, 26, 29, 28, 25, 11, 21, 15, 5, 1, 7, 7, 7], [17, 22, 27, 28, 26, 13, 23, 17, 21, 22, 23, 17, 18, 13, 16, 12, 14, 11, 10, 8], [25, 26, 27, 27, 24, 21, 28, 27, 27, 27, 26, 21, 18, 19, 17, 21, 4, 8, 0, 4], [6, 7, 10, 10, 13, 19, 0, 14, 5, 11, 9, 0, 0, 7, 6, 14, 2, 11, 3, 10], [6, 16, 23, 25, 21, 25, 22, 23, 21, 20, 15, 0, 6, 15, 13, 7, 0, 10, 10, 6], [19, 17, 10, 7, 11, 13, 0, 17, 12, 6, 10, 5, 5, 0, 10, 5, 9, 7, 0, 9], [16, 28, 29, 23, 17, 23, 14, 18, 15, 20, 19, 0, 16, 16, 1, 7, 4, 3, 16, 7], [22, 7, 1, 7, 18, 17, 21, 17, 17, 13, 15, 12, 15, 10, 4, 7, 5, 5, 10, 15], [19, 17, 4, 11, 7, 13, 11, 6, 7, 5, 6, 13, 4, 14, 11, 6, 5, 4, 5, 11], [16, 14, 17, 21, 16, 19, 14, 18, 15, 11, 5, 13, 9, 6, 5, 2, 3, 11, 13, 0], [8, 12, 9, 6, 16, 18, 16, 9, 8, 0, 11, 15, 10, 13, 12, 0, 13, 14, 4, 8], [72, 86, 89, 94, 96, 93, 94, 89, 89, 89, 87, 87, 86, 85, 83, 80, 74, 68, 64, 55], [81, 91, 97, 97, 100, 101, 102, 102, 103, 103, 102, 102, 101, 99, 97, 95, 89, 80, 76, 80], [65, 91, 97, 98, 97, 94, 95, 94, 93, 93, 92, 91, 89, 87, 81, 75, 60, 69, 71, 72], [78, 89, 92, 91, 96, 97, 95, 95, 92, 93, 92, 91, 88, 86, 81, 77, 74, 68, 73, 62], [54, 75, 78, 78, 75, 73, 62, 68, 62, 72, 75, 72, 70, 68, 63, 55, 56, 61, 58, 50], [77, 82, 82, 83, 81, 83, 84, 80, 82, 80, 79, 79, 77, 75, 70, 62, 66, 68, 52, 60], [76, 88, 93, 94, 95, 94, 94, 94, 94, 94, 93, 92, 90, 87, 77, 73, 77, 73, 71, 68], [67, 74, 80, 74, 75, 79, 80, 80, 80, 79, 79, 79, 76, 72, 61, 63, 64, 45, 59, 51], [73, 76, 74, 80, 73, 78, 75, 72, 69, 66, 59, 49, 55, 51, 42, 60, 65, 61, 54, 39], [72, 81, 87, 89, 88, 87, 88, 87, 87, 87, 86, 85, 81, 76, 71, 76, 75, 66, 57, 59], [67, 78, 80, 82, 81, 81, 81, 81, 80, 79, 77, 76, 70, 63, 71, 73, 65, 55, 48, 48], [67, 76, 82, 84, 86, 85, 84, 84, 83, 82, 81, 80, 77, 71, 69, 68, 67, 62, 57, 34], [53, 72, 75, 76, 75, 75, 71, 74, 80, 74, 74, 74, 66, 58, 57, 60, 64, 56, 45, 37], [72, 83, 87, 87, 87, 86, 87, 87, 86, 85, 83, 81, 75, 62, 65, 70, 67, 61, 57, 51], [76, 86, 86, 79, 82, 80, 85, 84, 84, 80, 76, 70, 62, 66, 72, 70, 69, 53, 53, 36], [72, 71, 72, 75, 67, 68, 67, 65, 68, 63, 58, 28, 58, 62, 62, 58, 51, 50, 42, 36], [65, 71, 69, 69, 69, 68, 71, 71, 72, 72, 71, 68, 58, 59, 61, 55, 56, 50, 41, 25], [59, 69, 71, 73, 73, 73, 71, 70, 68, 68, 65, 61, 58, 59, 56, 54, 57, 45, 43, 34], [61, 68, 70, 69, 70, 74, 69, 70, 65, 68, 64, 60, 56, 64, 66, 62, 52, 52, 36, 30], [52, 45, 59, 63, 65, 67, 66, 68, 66, 64, 63, 61, 49, 56, 61, 58, 47, 40, 25, 35], [60, 63, 60, 58, 56, 58, 57, 55, 44, 52, 51, 43, 46, 48, 52, 37, 31, 38, 30, 24], [59, 65, 66, 61, 63, 60, 65, 67, 67, 66, 65, 63, 53, 55, 61, 60, 49, 45, 33, 17], [58, 64, 67, 70, 71, 73, 74, 74, 74, 73, 70, 68, 64, 68, 67, 61, 57, 53, 40, 25], [57, 61, 57, 46, 53, 54, 54, 54, 55, 52, 52, 49, 41, 24, 48, 48, 38, 29, 28, 13], [44, 51, 57, 59, 46, 40, 44, 54, 35, 50, 50, 44, 43, 45, 41, 33, 36, 23, 6, 11], [55, 56, 56, 56, 58, 58, 56, 54, 54, 54, 50, 46, 38, 45, 46, 47, 21, 37, 25, 19], [50, 56, 58, 60, 61, 59, 60, 61, 60, 59, 56, 53, 44, 48, 49, 42, 34, 32, 17, 11], [51, 53, 54, 54, 58, 59, 57, 55, 57, 52, 50, 49, 43, 41, 36, 39, 32, 23, 13, 11], [52, 51, 52, 52, 54, 46, 50, 46, 49, 50, 47, 35, 48, 45, 37, 33, 23, 24, 15, 10], [39, 59, 63, 62, 64, 62, 61, 62, 59, 60, 47, 47, 48, 50, 41, 38, 2, 18, 10, 5], [48, 60, 62, 58, 50, 59, 57, 60, 59, 54, 51, 55, 50, 45, 44, 29, 31, 25, 13, 12], [29, 51, 52, 50, 52, 51, 53, 52, 51, 48, 43, 36, 28, 35, 45, 39, 31, 21, 14, 0], [36, 46, 40, 37, 30, 28, 37, 31, 27, 29, 24, 26, 20, 18, 20, 20, 13, 10, 10, 8], [41, 45, 47, 50, 51, 51, 51, 51, 49, 47, 42, 37, 40, 42, 36, 22, 22, 19, 10, 9], [34, 42, 46, 43, 43, 42, 41, 40, 36, 35, 27, 29, 33, 29, 25, 23, 16, 11, 9, 16], [41, 43, 42, 42, 39, 37, 40, 36, 37, 31, 32, 36, 39, 37, 27, 28, 13, 16, 10, 2], [37, 26, 33, 36, 42, 43, 29, 35, 39, 39, 38, 36, 32, 31, 19, 24, 18, 11, 13, 9], [46, 39, 43, 38, 23, 38, 34, 41, 36, 38, 35, 33, 31, 32, 24, 13, 1, 13, 7, 7], [44, 50, 52, 51, 51, 51, 48, 47, 44, 37, 32, 39, 38, 32, 29, 29, 19, 7, 8, 10], [32, 37, 38, 35, 36, 31, 38, 42, 36, 33, 36, 32, 12, 22, 24, 15, 0, 2, 11, 11], [69, 79, 79, 76, 82, 80, 80, 78, 76, 79, 77, 77, 75, 74, 70, 65, 55, 49, 50, 51], [65, 74, 79, 79, 81, 83, 82, 83, 84, 84, 81, 79, 75, 70, 57, 58, 60, 55, 47, 34], [56, 53, 59, 67, 73, 75, 77, 76, 76, 75, 73, 73, 71, 69, 66, 62, 57, 61, 59, 56], [58, 66, 69, 67, 64, 61, 65, 64, 63, 65, 65, 64, 62, 60, 54, 43, 53, 42, 46, 34], [59, 57, 61, 64, 65, 65, 66, 67, 68, 68, 68, 67, 66, 63, 55, 51, 51, 52, 42, 40], [56, 64, 66, 67, 66, 66, 66, 67, 65, 65, 65, 64, 62, 60, 51, 50, 37, 52, 36, 40], [49, 51, 52, 52, 54, 55, 56, 56, 56, 56, 56, 56, 55, 53, 50, 50, 45, 37, 38, 32], [43, 40, 45, 45, 44, 44, 42, 43, 45, 44, 41, 39, 38, 29, 33, 34, 29, 21, 18, 16], [37, 40, 40, 43, 44, 44, 44, 45, 45, 44, 45, 42, 38, 30, 36, 32, 30, 24, 15, 17], [25, 29, 25, 12, 23, 23, 26, 23, 25, 21, 28, 28, 31, 30, 8, 23, 22, 20, 20, 0], [18, 31, 34, 35, 35, 37, 38, 39, 39, 40, 41, 41, 38, 30, 28, 17, 23, 15, 14, 7], [27, 33, 33, 31, 33, 33, 33, 33, 34, 34, 34, 34, 31, 21, 20, 21, 21, 18, 19, 9], [22, 25, 25, 28, 26, 23, 24, 24, 25, 25, 21, 24, 18, 18, 26, 12, 20, 7, 2, 8], [17, 6, 25, 28, 22, 27, 28, 27, 30, 31, 32, 32, 27, 14, 11, 14, 18, 5, 11, 2], [9, 19, 23, 21, 25, 25, 25, 22, 17, 19, 25, 9, 10, 19, 11, 5, 0, 0, 8, 5], [9, 1, 13, 10, 12, 8, 14, 9, 8, 11, 5, 15, 17, 6, 15, 3, 10, 8, 8, 15], [7, 7, 9, 1, 9, 20, 12, 14, 14, 8, 11, 11, 9, 14, 15, 1, 8, 7, 0, 7], [16, 20, 19, 23, 23, 21, 20, 23, 22, 21, 15, 12, 7, 0, 15, 14, 11, 8, 12, 6], [25, 22, 19, 22, 19, 15, 22, 14, 19, 12, 16, 10, 13, 14, 18, 18, 16, 18, 18, 17], [10, 3, 1, 14, 18, 15, 19, 4, 13, 9, 13, 13, 8, 8, 6, 8, 8, 11, 0, 15], [15, 21, 24, 27, 26, 25, 26, 24, 23, 21, 18, 0, 9, 18, 10, 15, 9, 7, 9, 15], [2, 5, 9, 0, 13, 6, 10, 0, 12, 5, 13, 11, 13, 7, 9, 8, 9, 12, 8, 4], [18, 14, 15, 12, 12, 14, 6, 8, 13, 5, 10, 9, 11, 11, 15, 9, 9, 14, 0, 10], [13, 13, 12, 1, 6, 14, 0, 13, 11, 13, 0, 8, 8, 0, 0, 14, 0, 4, 10, 8], [6, 5, 0, 6, 17, 12, 7, 6, 15, 9, 5, 12, 0, 12, 0, 9, 1, 4, 7, 7], [14, 7, 16, 16, 5, 4, 13, 7, 18, 11, 0, 5, 6, 3, 6, 13, 6, 11, 9, 7], [12, 12, 12, 7, 13, 7, 15, 15, 9, 7, 13, 12, 9, 14, 13, 0, 13, 16, 3, 9], [7, 9, 13, 15, 17, 16, 13, 12, 12, 11, 10, 10, 14, 0, 7, 9, 12, 0, 13, 5], [19, 16, 19, 19, 8, 14, 4, 0, 13, 16, 2, 15, 1, 4, 13, 0, 7, 12, 4, 11], [22, 22, 20, 16, 15, 9, 17, 12, 15, 8, 9, 14, 17, 5, 0, 0, 7, 9, 7, 0], [9, 12, 1, 12, 7, 18, 3, 8, 7, 8, 7, 10, 11, 7, 10, 9, 9, 10, 10, 9], [15, 12, 10, 8, 6, 13, 5, 15, 13, 3, 11, 6, 6, 3, 7, 13, 12, 8, 6, 1], [15, 12, 15, 18, 11, 11, 12, 15, 14, 16, 11, 12, 14, 16, 12, 17, 10, 16, 20, 18], [8, 7, 4, 13, 9, 15, 12, 13, 3, 5, 8, 12, 3, 2, 8, 0, 6, 10, 5, 7], [14, 8, 7, 7, 2, 11, 13, 8, 12, 4, 11, 14, 12, 11, 4, 7, 5, 7, 5, 13], [17, 14, 10, 11, 6, 11, 4, 0, 11, 6, 10, 4, 13, 13, 4, 8, 0, 13, 12, 3], [9, 12, 13, 0, 5, 8, 5, 13, 0, 11, 16, 8, 15, 11, 7, 5, 0, 0, 11, 9], [16, 5, 11, 17, 13, 15, 15, 7, 0, 12, 12, 13, 4, 0, 14, 9, 7, 0, 3, 0], [12, 7, 0, 12, 10, 7, 0, 0, 13, 8, 0, 0, 11, 9, 5, 13, 0, 16, 9, 2], [0, 12, 12, 5, 10, 12, 13, 6, 3, 6, 7, 7, 10, 12, 0, 6, 6, 0, 0, 8], [70, 84, 89, 87, 90, 90, 91, 88, 85, 89, 87, 87, 85, 83, 79, 75, 62, 60, 63, 54], [74, 81, 90, 91, 92, 94, 94, 94, 95, 95, 92, 90, 86, 81, 72, 71, 70, 66, 56, 52], [64, 74, 67, 79, 85, 88, 89, 88, 88, 87, 85, 84, 81, 77, 68, 64, 67, 68, 66, 65], [64, 78, 84, 85, 80, 79, 81, 81, 80, 81, 79, 77, 74, 70, 56, 61, 67, 51, 54, 55], [73, 73, 76, 79, 80, 80, 80, 82, 82, 82, 81, 80, 77, 72, 60, 69, 53, 68, 58, 60], [67, 79, 83, 84, 84, 84, 84, 85, 83, 83, 82, 80, 76, 69, 66, 68, 62, 65, 53, 45], [64, 73, 75, 74, 76, 76, 78, 79, 78, 77, 76, 76, 72, 69, 67, 58, 70, 58, 61, 54], [69, 67, 69, 74, 71, 73, 71, 71, 71, 70, 67, 61, 55, 57, 58, 44, 51, 42, 40, 41], [62, 72, 74, 75, 77, 76, 76, 77, 77, 76, 74, 71, 61, 63, 63, 60, 54, 53, 52, 43], [56, 58, 52, 59, 63, 65, 66, 65, 66, 66, 65, 63, 55, 53, 56, 50, 55, 53, 46, 34], [52, 64, 68, 69, 70, 70, 70, 71, 71, 70, 69, 67, 57, 52, 46, 59, 50, 42, 39, 33], [55, 65, 67, 66, 66, 66, 65, 66, 66, 66, 64, 61, 48, 55, 50, 49, 43, 33, 27, 29], [50, 60, 62, 63, 63, 65, 65, 63, 65, 65, 60, 52, 52, 56, 53, 44, 40, 38, 35, 20], [54, 48, 63, 64, 63, 64, 66, 66, 66, 67, 66, 63, 48, 51, 40, 43, 45, 43, 22, 27], [53, 53, 54, 58, 57, 61, 48, 55, 42, 52, 54, 49, 41, 49, 44, 41, 42, 29, 19, 19], [46, 43, 48, 46, 43, 44, 42, 40, 40, 40, 30, 21, 25, 25, 23, 12, 8, 12, 10, 11], [39, 37, 40, 39, 38, 36, 41, 41, 39, 41, 39, 31, 33, 35, 17, 29, 26, 14, 15, 8], [35, 45, 46, 46, 48, 48, 50, 50, 51, 51, 50, 45, 31, 40, 33, 37, 29, 25, 19, 7], [40, 46, 40, 38, 41, 34, 30, 29, 38, 40, 41, 41, 32, 24, 33, 26, 24, 11, 13, 14], [29, 32, 30, 27, 30, 34, 31, 32, 30, 23, 28, 30, 34, 33, 19, 24, 21, 17, 0, 14], [24, 32, 38, 41, 42, 43, 43, 43, 44, 43, 41, 38, 38, 31, 22, 22, 15, 11, 7, 9], [24, 24, 25, 28, 19, 26, 11, 12, 14, 20, 26, 27, 25, 23, 15, 19, 16, 14, 12, 8], [27, 24, 22, 23, 27, 28, 21, 17, 13, 11, 24, 25, 21, 19, 20, 18, 6, 5, 16, 10], [23, 21, 25, 25, 25, 26, 23, 27, 25, 26, 21, 21, 15, 17, 14, 5, 5, 16, 14, 0], [24, 25, 28, 26, 24, 22, 22, 10, 17, 21, 23, 26, 16, 23, 12, 14, 5, 9, 12, 8], [18, 24, 32, 30, 27, 26, 27, 27, 20, 10, 13, 24, 19, 8, 11, 10, 0, 5, 9, 9], [27, 32, 33, 33, 32, 28, 31, 30, 27, 27, 26, 29, 19, 20, 20, 12, 12, 5, 2, 7], [33, 39, 40, 38, 38, 35, 31, 28, 20, 28, 28, 31, 25, 6, 10, 11, 13, 9, 15, 6], [22, 29, 20, 27, 26, 23, 26, 23, 22, 25, 25, 15, 18, 19, 8, 0, 14, 3, 0, 15], [25, 30, 31, 31, 32, 32, 32, 31, 30, 24, 19, 26, 17, 22, 16, 16, 11, 0, 14, 8], [26, 20, 21, 13, 18, 18, 15, 17, 18, 8, 6, 19, 8, 10, 6, 14, 0, 0, 13, 5], [15, 9, 14, 15, 20, 14, 9, 15, 15, 13, 6, 9, 14, 0, 5, 7, 0, 1, 9, 1], [19, 18, 21, 15, 20, 19, 18, 17, 12, 16, 1, 7, 7, 13, 7, 9, 12, 5, 0, 16], [20, 15, 6, 5, 23, 9, 15, 13, 15, 10, 15, 15, 6, 0, 3, 6, 4, 11, 11, 11], [14, 15, 13, 6, 14, 16, 7, 14, 8, 14, 9, 9, 9, 6, 10, 8, 1, 11, 7, 4], [24, 25, 14, 21, 15, 21, 23, 24, 21, 18, 8, 12, 9, 0, 13, 11, 1, 9, 5, 7], [17, 19, 18, 12, 20, 22, 18, 18, 20, 13, 12, 10, 9, 4, 9, 11, 0, 9, 1, 4], [5, 8, 16, 19, 15, 0, 14, 15, 14, 11, 6, 12, 3, 14, 17, 9, 14, 7, 2, 0], [13, 9, 18, 10, 15, 18, 18, 20, 21, 14, 0, 15, 7, 14, 12, 2, 17, 14, 11, 14], [10, 5, 16, 13, 16, 13, 17, 17, 19, 10, 15, 12, 2, 8, 12, 14, 13, 0, 2, 5], [79, 89, 95, 94, 96, 99, 98, 98, 93, 95, 94, 94, 92, 91, 88, 84, 71, 67, 71, 62], [80, 88, 97, 98, 100, 102, 102, 103, 104, 103, 100, 98, 94, 89, 80, 80, 78, 73, 61, 56], [68, 82, 75, 86, 92, 95, 95, 95, 94, 93, 92, 90, 86, 80, 71, 74, 74, 74, 74, 71], [72, 86, 91, 92, 88, 88, 88, 87, 85, 87, 85, 83, 80, 75, 53, 70, 72, 48, 61, 57], [80, 82, 84, 87, 90, 89, 88, 90, 89, 89, 89, 88, 84, 78, 73, 78, 65, 77, 64, 68], [75, 87, 90, 91, 91, 91, 90, 90, 88, 88, 86, 84, 78, 67, 74, 71, 73, 70, 61, 55], [74, 82, 85, 83, 85, 86, 88, 88, 88, 88, 87, 86, 82, 79, 78, 62, 79, 71, 72, 63], [80, 77, 80, 85, 83, 84, 82, 82, 82, 81, 76, 65, 66, 63, 57, 56, 41, 55, 44, 32], [72, 84, 86, 87, 89, 88, 88, 88, 87, 86, 84, 80, 73, 77, 70, 75, 70, 62, 60, 55], [69, 72, 54, 71, 74, 78, 79, 79, 80, 80, 78, 73, 47, 69, 69, 62, 65, 66, 53, 51], [64, 77, 80, 81, 82, 82, 82, 83, 82, 81, 79, 75, 62, 69, 60, 72, 63, 57, 50, 44], [69, 79, 82, 80, 81, 81, 80, 80, 80, 80, 77, 72, 64, 71, 51, 65, 60, 56, 48, 41], [65, 73, 76, 76, 75, 76, 79, 75, 78, 76, 74, 66, 68, 66, 67, 54, 50, 38, 47, 26], [70, 68, 78, 79, 77, 77, 79, 78, 79, 79, 77, 73, 63, 67, 64, 62, 57, 36, 35, 31], [71, 69, 75, 79, 76, 82, 75, 79, 72, 67, 71, 63, 68, 69, 61, 57, 60, 49, 40, 22], [65, 65, 69, 68, 64, 66, 63, 64, 62, 57, 32, 51, 46, 53, 47, 42, 28, 36, 17, 12], [61, 62, 55, 57, 60, 47, 61, 61, 61, 61, 58, 50, 56, 48, 41, 47, 42, 31, 17, 11], [57, 64, 67, 69, 69, 69, 68, 68, 67, 65, 60, 55, 59, 50, 46, 51, 48, 17, 25, 22], [58, 63, 55, 50, 58, 57, 56, 61, 60, 58, 54, 55, 51, 38, 48, 50, 35, 36, 24, 22], [44, 54, 52, 53, 55, 56, 54, 54, 52, 52, 52, 54, 51, 50, 45, 47, 38, 30, 16, 1], [56, 62, 63, 62, 64, 63, 63, 62, 60, 57, 47, 45, 49, 38, 37, 41, 36, 18, 12, 8], [41, 38, 54, 53, 47, 48, 49, 51, 58, 58, 55, 49, 44, 47, 33, 45, 36, 29, 14, 0], [57, 60, 61, 62, 63, 63, 63, 63, 60, 57, 47, 53, 48, 43, 40, 36, 32, 34, 19, 10], [42, 50, 53, 54, 53, 53, 52, 49, 48, 46, 38, 42, 39, 39, 32, 32, 24, 17, 9, 9], [45, 40, 47, 46, 50, 48, 35, 43, 37, 45, 46, 41, 36, 35, 0, 29, 20, 19, 4, 13], [36, 45, 52, 49, 45, 47, 46, 44, 41, 36, 42, 45, 26, 33, 26, 21, 20, 3, 5, 0], [51, 55, 58, 58, 57, 51, 44, 49, 51, 39, 42, 52, 43, 42, 29, 23, 15, 20, 13, 5], [50, 53, 53, 56, 55, 54, 48, 48, 50, 45, 38, 46, 37, 32, 31, 22, 5, 13, 10, 8], [47, 49, 52, 51, 50, 50, 44, 41, 44, 43, 35, 38, 31, 26, 33, 24, 15, 14, 9, 8], [40, 50, 49, 47, 50, 49, 49, 48, 42, 36, 37, 32, 34, 29, 28, 19, 0, 9, 4, 8], [42, 32, 36, 32, 35, 34, 37, 38, 39, 38, 34, 27, 25, 24, 18, 15, 14, 8, 5, 0], [33, 26, 29, 13, 27, 26, 31, 26, 30, 27, 23, 20, 18, 22, 18, 2, 10, 5, 13, 8], [29, 30, 37, 37, 37, 33, 33, 34, 32, 19, 30, 14, 13, 18, 10, 19, 14, 15, 13, 15], [28, 33, 38, 36, 35, 32, 28, 34, 35, 33, 15, 25, 26, 19, 14, 12, 11, 13, 4, 0], [37, 39, 33, 38, 38, 37, 37, 31, 16, 22, 12, 26, 10, 16, 17, 2, 9, 10, 10, 3], [33, 41, 41, 42, 42, 45, 45, 46, 43, 39, 29, 28, 29, 31, 27, 12, 14, 1, 4, 7], [28, 21, 29, 28, 28, 27, 29, 29, 25, 16, 21, 12, 18, 3, 10, 9, 8, 0, 12, 0], [29, 33, 28, 32, 32, 13, 26, 31, 34, 36, 25, 28, 24, 0, 7, 11, 13, 3, 0, 0], [32, 33, 33, 35, 36, 36, 36, 30, 28, 23, 29, 29, 16, 16, 6, 11, 2, 12, 8, 4], [35, 43, 38, 42, 45, 46, 47, 47, 45, 37, 39, 34, 37, 31, 24, 4, 11, 2, 7, 15], [74, 74, 58, 70, 67, 62, 62, 67, 64, 64, 64, 65, 65, 64, 64, 63, 59, 56, 54, 55], [63, 71, 74, 72, 74, 75, 77, 77, 76, 75, 73, 71, 67, 63, 58, 56, 54, 57, 55, 51], [48, 53, 59, 63, 64, 63, 61, 62, 63, 61, 58, 54, 40, 51, 56, 55, 49, 48, 44, 47], [50, 53, 52, 51, 51, 51, 53, 54, 56, 56, 56, 56, 56, 52, 46, 48, 47, 32, 41, 41], [30, 40, 44, 47, 49, 50, 50, 49, 45, 40, 36, 44, 50, 52, 50, 45, 45, 46, 38, 36], [45, 48, 48, 50, 51, 50, 49, 49, 49, 48, 46, 45, 44, 43, 42, 41, 33, 39, 29, 28], [33, 26, 23, 30, 27, 29, 23, 31, 30, 27, 16, 14, 19, 22, 25, 23, 17, 17, 16, 8], [15, 2, 25, 19, 26, 26, 24, 22, 18, 20, 17, 23, 20, 21, 15, 15, 4, 19, 12, 21], [14, 10, 17, 9, 16, 15, 19, 13, 18, 19, 16, 18, 0, 9, 14, 18, 0, 5, 16, 0], [21, 19, 19, 24, 23, 22, 19, 17, 19, 14, 16, 16, 16, 17, 9, 8, 10, 9, 16, 8], [19, 22, 22, 25, 24, 24, 23, 21, 22, 22, 18, 16, 17, 13, 0, 0, 15, 5, 12, 8], [21, 21, 23, 17, 18, 20, 9, 9, 15, 20, 19, 17, 0, 14, 0, 9, 2, 8, 4, 3], [11, 20, 20, 21, 14, 17, 20, 20, 18, 14, 8, 0, 4, 9, 3, 16, 8, 15, 11, 7], [15, 20, 12, 8, 11, 14, 14, 15, 18, 15, 18, 8, 16, 5, 15, 8, 2, 8, 12, 7], [10, 17, 20, 21, 22, 15, 21, 18, 23, 21, 7, 18, 18, 16, 16, 18, 20, 11, 12, 0], [7, 12, 10, 16, 16, 10, 0, 13, 16, 1, 11, 4, 8, 9, 14, 0, 12, 3, 8, 7], [14, 13, 5, 7, 15, 15, 7, 2, 0, 16, 13, 18, 0, 9, 0, 7, 10, 11, 11, 4], [12, 11, 2, 12, 8, 9, 13, 15, 12, 15, 12, 17, 17, 4, 8, 6, 13, 13, 5, 2], [5, 14, 15, 17, 17, 13, 16, 14, 9, 0, 3, 12, 0, 4, 15, 7, 4, 3, 13, 13], [19, 19, 16, 11, 13, 16, 18, 7, 11, 15, 14, 13, 10, 8, 15, 2, 13, 9, 13, 0], [18, 18, 10, 18, 19, 19, 10, 16, 11, 17, 22, 12, 13, 11, 8, 1, 1, 14, 15, 7], [13, 17, 19, 6, 15, 17, 9, 14, 9, 5, 12, 9, 8, 5, 11, 12, 8, 1, 5, 5], [16, 7, 18, 17, 18, 12, 10, 2, 0, 17, 0, 14, 7, 11, 3, 11, 14, 6, 8, 12], [14, 0, 7, 11, 0, 1, 8, 1, 11, 9, 17, 3, 6, 0, 8, 1, 2, 8, 6, 9], [5, 14, 15, 16, 10, 13, 15, 16, 16, 15, 15, 15, 10, 6, 12, 7, 2, 7, 4, 15], [2, 14, 14, 13, 16, 15, 15, 10, 14, 6, 7, 11, 2, 15, 9, 10, 7, 8, 6, 10], [17, 7, 16, 14, 21, 18, 4, 15, 9, 8, 5, 12, 16, 17, 11, 13, 12, 11, 14, 10], [19, 16, 21, 14, 11, 15, 16, 15, 17, 10, 0, 12, 8, 12, 10, 2, 4, 12, 5, 5], [20, 17, 19, 16, 14, 19, 18, 15, 15, 0, 7, 13, 12, 1, 0, 8, 5, 8, 12, 13], [17, 11, 5, 11, 5, 13, 10, 14, 5, 13, 12, 13, 9, 17, 0, 6, 6, 13, 10, 2], [17, 16, 16, 14, 9, 8, 12, 8, 9, 16, 1, 10, 6, 14, 12, 12, 16, 15, 7, 4], [21, 16, 14, 15, 6, 4, 9, 12, 7, 11, 16, 8, 5, 4, 17, 9, 4, 13, 15, 6], [6, 8, 8, 0, 7, 15, 0, 3, 4, 8, 11, 0, 13, 12, 16, 10, 12, 12, 4, 8], [8, 9, 1, 10, 12, 10, 3, 0, 7, 5, 16, 16, 13, 9, 5, 7, 9, 8, 12, 6], [11, 6, 0, 15, 10, 13, 19, 15, 16, 7, 12, 6, 9, 9, 8, 18, 12, 11, 10, 14], [10, 14, 14, 19, 8, 6, 7, 8, 16, 6, 5, 7, 8, 6, 5, 9, 8, 6, 15, 8], [18, 9, 2, 4, 15, 8, 12, 6, 5, 7, 6, 17, 0, 9, 5, 7, 7, 7, 11, 6], [9, 4, 10, 7, 14, 13, 8, 6, 8, 15, 5, 9, 1, 9, 7, 16, 11, 9, 14, 0], [9, 8, 17, 12, 3, 3, 0, 10, 9, 7, 8, 9, 0, 8, 11, 0, 11, 4, 11, 6], [18, 10, 13, 7, 6, 8, 15, 15, 12, 16, 4, 7, 3, 13, 12, 6, 2, 0, 13, 8], [80, 87, 79, 80, 76, 66, 71, 80, 73, 70, 73, 73, 73, 73, 72, 71, 69, 65, 65, 67], [71, 84, 90, 90, 88, 92, 93, 93, 93, 92, 90, 89, 85, 80, 68, 54, 56, 67, 66, 59], [70, 59, 77, 81, 83, 83, 81, 82, 83, 82, 79, 77, 71, 62, 63, 65, 57, 66, 49, 52], [74, 80, 80, 80, 79, 77, 79, 80, 80, 77, 78, 78, 77, 74, 71, 71, 65, 60, 60, 59], [67, 68, 70, 68, 74, 78, 78, 78, 77, 76, 75, 75, 74, 73, 68, 68, 68, 62, 56, 42], [68, 71, 72, 73, 75, 75, 73, 75, 74, 73, 71, 67, 60, 52, 57, 48, 58, 57, 51, 47], [60, 52, 67, 63, 55, 58, 61, 61, 58, 56, 58, 60, 62, 60, 54, 53, 57, 50, 44, 42], [55, 53, 58, 60, 60, 60, 58, 57, 57, 57, 54, 54, 51, 50, 46, 26, 32, 31, 30, 16], [53, 56, 63, 65, 65, 63, 62, 61, 61, 60, 59, 57, 48, 53, 55, 45, 49, 32, 34, 30], [50, 52, 55, 57, 52, 51, 50, 51, 43, 38, 41, 40, 23, 35, 34, 41, 33, 32, 22, 19], [54, 59, 61, 60, 59, 60, 60, 60, 59, 58, 55, 45, 53, 55, 41, 49, 45, 38, 28, 24], [48, 52, 51, 51, 51, 51, 48, 49, 46, 46, 37, 25, 46, 50, 42, 41, 36, 29, 18, 16], [45, 51, 51, 49, 49, 34, 48, 33, 43, 46, 46, 46, 42, 36, 41, 20, 34, 24, 22, 12], [30, 27, 36, 39, 47, 49, 48, 50, 48, 42, 33, 27, 38, 41, 31, 37, 31, 26, 16, 13], [42, 39, 37, 35, 37, 45, 44, 45, 47, 46, 44, 36, 42, 35, 36, 25, 26, 20, 23, 17], [26, 31, 34, 32, 32, 31, 28, 27, 31, 30, 31, 32, 30, 26, 21, 17, 3, 1, 14, 10], [31, 36, 34, 30, 25, 29, 27, 21, 19, 24, 30, 31, 31, 21, 21, 18, 0, 11, 15, 11], [27, 40, 40, 38, 37, 38, 36, 35, 32, 33, 33, 32, 16, 26, 14, 19, 13, 16, 7, 5], [30, 33, 31, 30, 28, 28, 31, 29, 25, 22, 31, 32, 31, 24, 24, 17, 14, 13, 8, 6], [27, 26, 17, 25, 30, 30, 30, 28, 28, 30, 27, 23, 9, 22, 19, 5, 6, 6, 9, 10], [21, 25, 29, 30, 27, 24, 25, 19, 26, 29, 33, 32, 23, 21, 17, 7, 13, 11, 11, 14], [28, 19, 18, 13, 21, 29, 27, 24, 22, 27, 26, 25, 24, 9, 18, 8, 10, 13, 2, 0], [27, 26, 30, 30, 32, 32, 31, 31, 31, 29, 26, 19, 13, 18, 11, 10, 9, 0, 13, 1], [23, 5, 19, 27, 23, 22, 25, 22, 11, 17, 4, 17, 17, 13, 6, 0, 16, 9, 12, 12], [25, 10, 14, 18, 27, 20, 27, 23, 21, 19, 15, 12, 20, 11, 13, 13, 8, 14, 0, 9], [24, 24, 22, 21, 22, 24, 23, 23, 17, 16, 12, 17, 16, 10, 16, 13, 6, 0, 3, 0], [23, 27, 31, 18, 25, 16, 22, 9, 16, 17, 18, 9, 14, 8, 11, 14, 10, 0, 7, 14], [25, 24, 20, 17, 22, 19, 20, 19, 6, 1, 18, 10, 15, 12, 11, 12, 8, 11, 4, 12], [21, 19, 5, 16, 17, 19, 20, 19, 20, 15, 8, 18, 16, 16, 12, 10, 18, 15, 10, 8], [13, 13, 20, 22, 13, 16, 13, 16, 13, 18, 15, 17, 15, 9, 1, 11, 12, 10, 2, 10], [20, 25, 27, 24, 24, 24, 23, 23, 18, 19, 12, 14, 13, 15, 17, 16, 4, 12, 8, 12], [14, 8, 14, 6, 10, 10, 9, 17, 7, 8, 6, 0, 11, 16, 14, 3, 5, 13, 7, 11], [17, 10, 5, 12, 10, 11, 13, 13, 3, 6, 13, 14, 8, 4, 8, 15, 11, 0, 15, 10], [14, 9, 5, 7, 19, 24, 7, 9, 8, 5, 5, 13, 0, 12, 16, 13, 14, 4, 14, 8], [18, 25, 21, 15, 15, 18, 13, 16, 6, 17, 8, 13, 11, 5, 13, 10, 10, 3, 13, 19], [12, 0, 16, 18, 18, 19, 13, 8, 13, 17, 10, 5, 12, 6, 9, 2, 5, 9, 10, 7], [0, 15, 22, 19, 4, 19, 13, 12, 14, 10, 4, 17, 11, 15, 4, 7, 12, 9, 14, 9], [15, 11, 0, 17, 23, 10, 16, 7, 12, 12, 12, 15, 12, 5, 8, 18, 13, 10, 9, 7], [5, 9, 6, 1, 23, 6, 17, 20, 1, 14, 16, 11, 0, 12, 13, 7, 5, 5, 9, 18], [13, 15, 7, 11, 0, 16, 10, 11, 7, 15, 5, 12, 13, 8, 0, 10, 13, 0, 8, 8], [86, 96, 89, 93, 86, 80, 86, 82, 80, 78, 80, 81, 83, 82, 81, 81, 78, 75, 73, 75], [77, 93, 99, 99, 97, 101, 102, 101, 102, 101, 100, 99, 94, 89, 76, 69, 61, 75, 72, 70], [80, 67, 85, 90, 93, 93, 91, 91, 92, 89, 87, 84, 76, 64, 74, 72, 68, 73, 53, 55], [85, 89, 89, 91, 91, 90, 91, 92, 91, 89, 88, 87, 84, 82, 78, 80, 73, 71, 68, 66], [77, 81, 83, 80, 87, 90, 90, 90, 90, 88, 87, 84, 82, 81, 74, 76, 77, 69, 65, 53], [79, 83, 84, 84, 85, 86, 84, 84, 82, 81, 77, 72, 58, 62, 69, 61, 64, 62, 54, 50], [74, 64, 78, 73, 73, 72, 69, 74, 70, 63, 70, 72, 69, 65, 58, 63, 63, 50, 44, 43], [71, 64, 78, 78, 74, 76, 73, 72, 72, 70, 69, 66, 56, 55, 50, 51, 36, 40, 37, 28], [70, 75, 81, 84, 84, 81, 79, 77, 75, 69, 62, 59, 65, 70, 69, 49, 60, 42, 42, 39], [67, 71, 74, 75, 74, 72, 72, 72, 66, 70, 65, 58, 43, 51, 58, 55, 53, 47, 39, 33], [74, 79, 81, 79, 79, 79, 79, 79, 77, 74, 71, 66, 69, 70, 63, 58, 57, 50, 44, 28], [68, 70, 67, 68, 69, 68, 65, 66, 68, 67, 64, 58, 61, 63, 53, 55, 47, 39, 32, 19], [65, 73, 74, 72, 76, 70, 73, 61, 66, 70, 66, 61, 58, 59, 59, 49, 52, 45, 34, 26], [66, 70, 65, 67, 70, 70, 70, 72, 70, 67, 65, 55, 61, 63, 39, 57, 51, 45, 34, 22], [71, 68, 67, 67, 66, 74, 73, 73, 75, 74, 64, 59, 66, 56, 66, 47, 43, 36, 26, 21], [56, 62, 65, 66, 65, 64, 63, 62, 58, 55, 57, 58, 57, 55, 52, 44, 24, 20, 0, 4], [56, 63, 64, 57, 61, 59, 58, 56, 54, 52, 50, 55, 55, 34, 47, 37, 33, 28, 19, 3], [55, 61, 60, 61, 62, 61, 60, 59, 56, 47, 53, 53, 43, 48, 43, 32, 31, 24, 14, 15], [54, 57, 56, 59, 60, 58, 53, 52, 54, 51, 50, 51, 52, 41, 43, 31, 31, 22, 10, 7], [52, 58, 57, 56, 61, 62, 62, 62, 62, 60, 54, 55, 56, 49, 47, 36, 30, 27, 15, 13], [54, 56, 56, 55, 56, 54, 52, 47, 40, 48, 53, 53, 39, 44, 34, 26, 16, 9, 4, 7], [58, 57, 56, 58, 60, 58, 60, 59, 57, 54, 51, 56, 50, 46, 47, 38, 33, 25, 13, 9], [59, 62, 63, 62, 61, 62, 61, 59, 56, 50, 44, 46, 47, 43, 36, 16, 20, 18, 4, 8], [50, 47, 50, 50, 44, 44, 42, 35, 26, 28, 26, 28, 29, 24, 19, 12, 10, 13, 15, 10], [50, 46, 51, 55, 55, 53, 51, 53, 49, 47, 37, 40, 43, 40, 28, 26, 1, 9, 12, 1], [53, 53, 49, 51, 44, 46, 41, 39, 39, 28, 35, 35, 30, 29, 22, 10, 6, 11, 7, 9], [52, 48, 62, 59, 57, 58, 51, 54, 50, 46, 41, 44, 45, 32, 32, 15, 5, 11, 0, 12], [50, 49, 48, 52, 47, 47, 47, 46, 43, 42, 33, 38, 22, 11, 24, 7, 11, 9, 9, 4], [47, 42, 42, 43, 43, 40, 45, 47, 49, 50, 42, 32, 37, 33, 3, 13, 15, 6, 9, 13], [27, 40, 36, 31, 34, 38, 24, 32, 19, 19, 27, 19, 15, 14, 17, 6, 9, 10, 5, 6], [49, 52, 50, 49, 48, 47, 46, 41, 40, 36, 36, 28, 30, 30, 26, 14, 15, 8, 10, 9], [30, 40, 39, 34, 22, 23, 19, 26, 22, 25, 13, 20, 21, 15, 0, 5, 14, 13, 16, 0], [14, 33, 31, 30, 20, 24, 29, 33, 31, 27, 24, 12, 12, 0, 0, 10, 12, 13, 12, 16], [23, 41, 38, 30, 31, 31, 27, 29, 23, 16, 27, 21, 18, 18, 5, 16, 12, 13, 6, 9], [27, 41, 35, 37, 37, 37, 38, 39, 39, 35, 25, 29, 21, 15, 8, 15, 4, 14, 6, 4], [24, 42, 37, 35, 31, 30, 25, 27, 30, 30, 31, 26, 19, 4, 9, 14, 0, 17, 9, 12], [33, 43, 45, 41, 35, 31, 28, 26, 17, 7, 15, 8, 17, 12, 12, 4, 10, 7, 12, 9], [30, 39, 28, 30, 34, 30, 31, 29, 26, 31, 22, 14, 2, 2, 18, 4, 11, 12, 9, 12], [35, 38, 39, 39, 40, 32, 35, 38, 23, 27, 28, 26, 21, 17, 13, 13, 12, 13, 7, 7], [35, 28, 18, 31, 31, 31, 26, 20, 18, 9, 14, 3, 5, 12, 1, 8, 13, 9, 0, 0], [77, 82, 86, 87, 86, 86, 86, 87, 86, 85, 82, 80, 76, 73, 66, 59, 46, 52, 56, 52], [52, 57, 51, 62, 64, 65, 68, 68, 69, 69, 68, 66, 64, 65, 67, 66, 58, 56, 53, 36], [49, 37, 39, 42, 48, 51, 54, 54, 53, 52, 50, 48, 42, 40, 36, 37, 31, 32, 38, 34], [46, 49, 50, 53, 55, 55, 55, 55, 55, 54, 53, 50, 45, 46, 47, 40, 24, 40, 38, 27], [42, 47, 49, 50, 50, 51, 51, 50, 50, 48, 46, 44, 42, 42, 39, 39, 32, 31, 28, 25], [16, 21, 25, 29, 18, 28, 28, 25, 26, 29, 33, 31, 16, 27, 22, 18, 27, 20, 21, 13], [5, 24, 21, 27, 26, 22, 26, 29, 28, 29, 27, 27, 26, 22, 17, 16, 14, 8, 14, 10], [14, 21, 18, 17, 17, 8, 10, 19, 13, 7, 17, 17, 20, 16, 12, 8, 15, 12, 12, 18], [20, 23, 27, 28, 24, 26, 22, 20, 13, 21, 20, 21, 20, 17, 8, 16, 10, 13, 8, 12], [20, 18, 26, 23, 16, 23, 12, 10, 8, 5, 14, 13, 14, 10, 13, 15, 17, 14, 15, 18], [20, 22, 27, 12, 21, 12, 16, 21, 15, 14, 17, 12, 17, 15, 6, 17, 16, 14, 3, 5], [19, 22, 20, 22, 19, 23, 19, 22, 11, 22, 9, 23, 13, 14, 6, 14, 17, 18, 7, 17], [25, 14, 25, 24, 15, 22, 11, 22, 17, 9, 17, 14, 13, 10, 12, 14, 10, 14, 0, 4], [12, 7, 19, 22, 16, 8, 10, 0, 19, 6, 13, 5, 15, 17, 10, 13, 12, 7, 9, 6], [11, 10, 13, 24, 13, 20, 12, 12, 12, 5, 9, 10, 12, 12, 18, 17, 11, 8, 14, 11], [11, 14, 10, 18, 11, 13, 4, 3, 6, 14, 16, 14, 15, 11, 12, 12, 8, 0, 0, 12], [6, 15, 9, 13, 0, 12, 9, 2, 5, 12, 10, 5, 0, 11, 1, 16, 9, 18, 13, 7], [6, 16, 8, 17, 13, 14, 4, 4, 11, 11, 0, 9, 18, 6, 0, 6, 9, 18, 16, 10], [17, 9, 15, 21, 10, 10, 5, 14, 8, 11, 14, 8, 0, 9, 1, 6, 10, 6, 12, 2], [16, 19, 16, 10, 15, 14, 20, 8, 12, 9, 15, 15, 11, 17, 7, 16, 8, 5, 13, 15], [19, 1, 11, 6, 0, 16, 9, 14, 15, 14, 16, 14, 3, 13, 11, 11, 3, 10, 10, 1], [8, 12, 9, 14, 0, 14, 8, 9, 0, 11, 7, 14, 14, 2, 4, 6, 7, 11, 5, 12], [15, 13, 4, 16, 4, 0, 14, 6, 15, 3, 5, 11, 11, 16, 11, 14, 6, 11, 10, 14], [15, 5, 10, 14, 10, 19, 7, 17, 9, 12, 11, 7, 14, 18, 5, 15, 13, 16, 11, 4], [19, 11, 13, 13, 0, 8, 14, 0, 15, 12, 12, 0, 15, 14, 13, 16, 0, 13, 9, 14], [13, 9, 17, 15, 11, 14, 11, 10, 13, 14, 14, 10, 13, 8, 8, 10, 0, 9, 0, 16], [12, 7, 16, 19, 11, 0, 9, 13, 10, 8, 7, 10, 13, 1, 12, 9, 11, 1, 12, 8], [8, 6, 0, 22, 13, 8, 16, 6, 0, 12, 12, 11, 9, 0, 10, 13, 17, 11, 10, 15], [3, 17, 21, 12, 19, 20, 19, 16, 15, 8, 8, 10, 7, 0, 10, 8, 16, 10, 4, 11], [1, 16, 15, 13, 15, 16, 13, 17, 13, 7, 14, 3, 5, 16, 16, 15, 17, 5, 0, 9], [15, 17, 20, 20, 18, 13, 11, 10, 6, 8, 14, 11, 10, 8, 12, 10, 3, 13, 3, 11], [16, 7, 12, 20, 14, 17, 11, 16, 12, 7, 14, 9, 4, 8, 4, 11, 13, 11, 3, 13], [7, 5, 17, 9, 9, 16, 16, 1, 10, 0, 9, 17, 9, 7, 10, 9, 8, 18, 8, 8], [19, 9, 5, 15, 10, 17, 2, 5, 5, 8, 11, 14, 14, 11, 8, 0, 10, 17, 10, 18], [14, 10, 0, 12, 14, 13, 18, 9, 5, 6, 6, 20, 10, 7, 11, 4, 5, 18, 0, 9], [5, 18, 4, 16, 15, 11, 10, 11, 5, 7, 12, 6, 8, 13, 14, 6, 6, 4, 9, 4], [7, 15, 0, 0, 15, 15, 12, 9, 16, 11, 17, 13, 5, 10, 15, 9, 18, 9, 11, 14], [14, 11, 16, 6, 2, 2, 12, 5, 7, 13, 9, 0, 8, 7, 8, 8, 15, 6, 5, 18], [13, 15, 0, 11, 9, 3, 6, 9, 9, 12, 4, 13, 0, 5, 6, 15, 12, 11, 5, 15], [15, 9, 17, 14, 17, 1, 2, 7, 6, 0, 4, 12, 17, 15, 5, 5, 15, 10, 5, 5], [86, 91, 96, 99, 97, 97, 97, 97, 97, 96, 93, 91, 88, 84, 77, 69, 62, 58, 64, 62], [70, 72, 74, 80, 85, 85, 89, 89, 89, 89, 88, 86, 81, 77, 75, 75, 73, 73, 65, 56], [71, 66, 64, 67, 70, 75, 77, 78, 76, 76, 74, 72, 68, 66, 63, 58, 58, 45, 50, 43], [69, 70, 72, 76, 78, 78, 77, 77, 77, 76, 74, 72, 68, 68, 68, 62, 51, 57, 59, 47], [72, 77, 79, 80, 81, 82, 81, 81, 80, 79, 78, 76, 71, 63, 51, 52, 58, 52, 49, 44], [57, 59, 61, 66, 63, 66, 67, 67, 67, 67, 65, 63, 58, 51, 46, 41, 46, 48, 36, 30], [51, 62, 62, 62, 65, 66, 66, 67, 67, 67, 66, 65, 60, 52, 51, 44, 51, 35, 38, 31], [46, 47, 50, 45, 47, 47, 50, 50, 50, 49, 50, 49, 45, 40, 37, 33, 27, 26, 17, 17], [45, 53, 51, 50, 50, 48, 47, 45, 39, 45, 40, 40, 38, 25, 39, 32, 25, 17, 11, 8], [28, 38, 38, 36, 35, 36, 35, 29, 25, 25, 33, 32, 27, 20, 23, 22, 11, 9, 9, 17], [40, 38, 40, 44, 41, 41, 39, 37, 36, 35, 38, 43, 42, 34, 17, 29, 21, 23, 13, 11], [23, 32, 37, 41, 41, 42, 40, 40, 38, 32, 32, 37, 31, 32, 20, 25, 21, 23, 13, 21], [33, 29, 23, 32, 32, 37, 36, 35, 32, 29, 22, 21, 25, 26, 17, 23, 6, 12, 15, 9], [35, 38, 35, 16, 32, 27, 34, 28, 32, 25, 24, 20, 21, 18, 13, 18, 11, 13, 13, 11], [24, 31, 33, 34, 33, 33, 34, 33, 33, 29, 18, 16, 24, 8, 13, 9, 8, 3, 9, 3], [17, 16, 21, 16, 19, 22, 21, 22, 21, 20, 20, 18, 17, 8, 14, 11, 2, 13, 16, 8], [17, 1, 17, 15, 20, 17, 16, 19, 14, 16, 12, 15, 11, 0, 13, 4, 8, 9, 7, 11], [18, 20, 26, 24, 23, 22, 26, 23, 19, 20, 15, 16, 4, 17, 15, 14, 17, 13, 7, 3], [20, 14, 9, 15, 11, 15, 20, 19, 26, 23, 16, 10, 17, 11, 2, 17, 14, 5, 10, 14], [21, 24, 27, 27, 23, 27, 26, 27, 25, 22, 16, 21, 23, 10, 19, 10, 14, 11, 12, 16], [4, 19, 15, 0, 18, 17, 19, 8, 18, 14, 22, 8, 16, 14, 3, 16, 13, 12, 16, 12], [26, 27, 27, 26, 27, 23, 24, 19, 16, 11, 13, 18, 14, 11, 5, 8, 8, 15, 12, 7], [23, 18, 25, 22, 14, 22, 16, 15, 2, 4, 13, 0, 15, 13, 9, 9, 9, 2, 6, 13], [16, 12, 21, 12, 14, 14, 18, 6, 8, 13, 9, 4, 8, 16, 7, 4, 6, 15, 10, 2], [20, 0, 19, 14, 8, 9, 7, 4, 15, 10, 14, 14, 1, 8, 14, 11, 4, 2, 15, 11], [24, 25, 18, 4, 16, 15, 16, 8, 12, 4, 10, 12, 15, 0, 12, 3, 13, 14, 16, 4], [15, 16, 11, 8, 14, 18, 6, 11, 5, 5, 8, 12, 15, 1, 11, 0, 9, 7, 1, 14], [19, 3, 24, 18, 16, 19, 12, 12, 9, 17, 9, 15, 14, 14, 14, 11, 14, 15, 10, 19], [19, 10, 5, 20, 4, 4, 15, 12, 15, 13, 10, 12, 11, 15, 12, 14, 12, 8, 14, 10], [9, 8, 5, 8, 7, 4, 17, 19, 7, 17, 10, 13, 7, 12, 17, 1, 10, 16, 12, 9], [8, 14, 11, 9, 4, 11, 12, 15, 10, 20, 16, 11, 10, 13, 15, 13, 12, 14, 11, 12], [15, 13, 0, 2, 13, 10, 6, 18, 16, 3, 15, 0, 6, 10, 5, 14, 9, 12, 12, 9], [7, 6, 10, 6, 16, 7, 12, 9, 10, 16, 4, 11, 13, 6, 12, 16, 16, 7, 17, 1], [13, 5, 13, 1, 13, 13, 8, 12, 12, 14, 8, 0, 15, 5, 0, 2, 14, 11, 7, 5], [15, 6, 0, 10, 15, 18, 8, 14, 16, 14, 13, 8, 19, 1, 13, 18, 5, 0, 10, 11], [16, 15, 15, 4, 6, 14, 7, 9, 0, 9, 17, 10, 14, 16, 6, 15, 5, 18, 0, 9], [11, 14, 11, 3, 13, 15, 15, 0, 14, 0, 15, 12, 8, 12, 7, 5, 8, 17, 13, 11], [12, 16, 8, 16, 10, 8, 14, 18, 6, 11, 10, 7, 7, 11, 14, 13, 10, 22, 18, 15], [15, 14, 1, 8, 9, 8, 14, 11, 9, 12, 1, 19, 13, 9, 0, 15, 14, 18, 16, 8], [8, 13, 15, 11, 14, 12, 4, 4, 16, 10, 14, 11, 11, 16, 9, 19, 0, 11, 18, 12], [98, 105, 110, 112, 111, 111, 111, 111, 110, 109, 106, 105, 102, 98, 90, 81, 77, 73, 72, 72], [87, 85, 90, 94, 101, 103, 105, 106, 105, 104, 103, 101, 97, 92, 88, 88, 87, 87, 77, 71], [88, 82, 81, 85, 84, 90, 91, 91, 91, 89, 87, 85, 81, 78, 74, 63, 71, 62, 60, 57], [87, 87, 88, 93, 95, 95, 95, 95, 95, 93, 91, 88, 85, 83, 83, 79, 74, 63, 77, 64], [90, 95, 97, 99, 99, 100, 100, 99, 99, 97, 95, 93, 87, 80, 75, 76, 76, 66, 67, 60], [78, 79, 82, 86, 83, 87, 87, 83, 82, 81, 79, 76, 70, 60, 62, 63, 48, 63, 50, 39], [76, 85, 85, 83, 86, 85, 86, 87, 89, 88, 86, 84, 77, 76, 77, 63, 70, 60, 56, 48], [73, 78, 81, 77, 71, 75, 79, 76, 78, 78, 79, 77, 73, 67, 63, 61, 58, 46, 43, 38], [77, 86, 85, 82, 84, 83, 80, 67, 77, 77, 75, 78, 69, 73, 64, 68, 52, 51, 32, 14], [76, 68, 71, 70, 71, 76, 74, 75, 73, 75, 75, 74, 61, 54, 62, 52, 51, 46, 40, 28], [74, 74, 67, 74, 70, 70, 66, 61, 62, 66, 70, 72, 71, 62, 47, 56, 55, 46, 39, 32], [61, 62, 70, 75, 77, 76, 75, 74, 69, 63, 61, 64, 58, 56, 56, 51, 34, 42, 32, 20], [72, 70, 69, 69, 63, 73, 74, 75, 73, 71, 62, 48, 62, 59, 57, 56, 48, 44, 33, 25], [66, 75, 75, 68, 70, 70, 69, 72, 69, 68, 65, 63, 58, 57, 38, 51, 40, 31, 12, 16], [70, 74, 74, 75, 75, 76, 76, 76, 75, 75, 60, 62, 65, 59, 53, 51, 36, 36, 24, 15], [70, 71, 68, 66, 68, 68, 68, 64, 53, 55, 63, 65, 58, 52, 36, 38, 32, 26, 12, 6], [63, 58, 61, 59, 62, 63, 63, 61, 59, 52, 51, 57, 44, 45, 29, 36, 25, 11, 5, 19], [61, 67, 65, 66, 66, 66, 64, 62, 59, 55, 55, 53, 49, 47, 49, 36, 25, 27, 7, 12], [57, 60, 61, 62, 65, 65, 65, 65, 64, 61, 51, 50, 44, 35, 39, 39, 21, 13, 9, 5], [65, 66, 64, 63, 63, 64, 61, 60, 58, 58, 54, 50, 47, 47, 33, 36, 16, 12, 13, 14], [63, 66, 66, 67, 67, 66, 64, 62, 59, 59, 55, 40, 42, 29, 36, 34, 6, 15, 8, 20], [61, 56, 47, 45, 50, 51, 31, 46, 41, 37, 34, 39, 30, 28, 24, 21, 20, 6, 9, 15], [64, 62, 59, 57, 60, 55, 53, 57, 56, 51, 56, 49, 47, 41, 27, 28, 9, 11, 4, 10], [59, 58, 60, 59, 58, 57, 56, 53, 46, 37, 43, 30, 38, 34, 23, 14, 18, 12, 11, 12], [54, 52, 46, 46, 44, 47, 41, 43, 43, 20, 21, 32, 30, 15, 11, 12, 9, 14, 6, 19], [56, 54, 53, 58, 64, 56, 55, 57, 52, 50, 48, 46, 40, 38, 24, 22, 4, 5, 14, 12], [44, 54, 47, 49, 44, 34, 43, 45, 42, 30, 40, 38, 33, 25, 20, 15, 5, 3, 9, 5], [50, 52, 51, 47, 51, 47, 44, 40, 48, 42, 40, 30, 29, 24, 8, 16, 15, 13, 19, 8], [40, 35, 40, 40, 27, 29, 24, 29, 24, 18, 18, 23, 3, 13, 12, 15, 20, 16, 11, 15], [44, 44, 44, 46, 47, 48, 50, 49, 44, 38, 18, 32, 27, 11, 14, 12, 16, 3, 15, 1], [42, 41, 46, 44, 45, 45, 44, 44, 41, 37, 34, 26, 20, 14, 5, 10, 0, 13, 7, 7], [18, 43, 35, 26, 32, 33, 29, 21, 27, 28, 20, 15, 8, 13, 13, 18, 1, 11, 6, 8], [30, 25, 37, 31, 16, 27, 31, 27, 15, 14, 22, 10, 9, 9, 4, 0, 18, 14, 10, 12], [26, 35, 36, 15, 17, 24, 27, 25, 25, 18, 22, 18, 12, 18, 10, 10, 0, 10, 9, 0], [30, 39, 36, 38, 36, 34, 31, 30, 31, 25, 27, 24, 8, 12, 8, 17, 10, 10, 19, 18], [23, 28, 20, 29, 21, 25, 21, 26, 16, 17, 22, 10, 15, 10, 9, 18, 4, 13, 11, 10], [21, 28, 25, 24, 18, 24, 20, 23, 17, 17, 7, 19, 0, 2, 13, 5, 16, 6, 11, 18], [21, 28, 26, 27, 34, 33, 31, 27, 19, 10, 15, 15, 11, 16, 17, 12, 16, 14, 17, 14], [30, 35, 35, 32, 20, 21, 21, 16, 0, 23, 16, 14, 11, 0, 15, 11, 13, 9, 12, 7], [32, 29, 25, 28, 27, 26, 24, 9, 0, 14, 10, 14, 6, 8, 10, 12, 10, 10, 13, 16], [82, 78, 79, 83, 84, 83, 77, 82, 79, 80, 75, 74, 71, 67, 62, 47, 56, 54, 45, 51], [62, 72, 69, 69, 50, 44, 60, 58, 58, 54, 56, 58, 60, 61, 60, 58, 57, 54, 45, 47], [59, 63, 64, 65, 67, 67, 65, 65, 65, 63, 62, 60, 57, 55, 50, 49, 42, 43, 40, 45], [54, 56, 57, 57, 55, 54, 55, 54, 53, 51, 45, 42, 42, 38, 37, 37, 38, 36, 35, 27], [20, 33, 25, 22, 33, 34, 33, 30, 14, 26, 26, 26, 16, 26, 25, 21, 27, 29, 22, 15], [31, 34, 38, 35, 37, 35, 31, 34, 27, 26, 25, 22, 25, 29, 28, 26, 22, 5, 14, 13], [26, 20, 13, 12, 11, 15, 2, 7, 18, 16, 13, 21, 15, 13, 16, 8, 13, 3, 10, 21], [18, 14, 22, 12, 11, 8, 6, 16, 16, 14, 7, 14, 9, 15, 15, 15, 15, 9, 7, 17], [19, 19, 26, 18, 21, 19, 16, 19, 11, 10, 22, 1, 11, 19, 7, 16, 13, 16, 15, 20], [9, 20, 17, 23, 17, 19, 12, 17, 8, 19, 13, 4, 0, 16, 16, 8, 7, 12, 7, 17], [10, 22, 20, 10, 16, 15, 15, 14, 17, 7, 16, 7, 0, 14, 13, 12, 14, 10, 12, 13], [18, 21, 22, 16, 19, 16, 6, 20, 17, 21, 16, 11, 16, 12, 12, 12, 15, 8, 10, 7], [20, 20, 16, 22, 19, 14, 7, 7, 8, 15, 17, 14, 13, 13, 4, 15, 10, 0, 10, 11], [22, 22, 23, 13, 19, 19, 4, 15, 16, 1, 17, 7, 12, 14, 18, 6, 12, 14, 0, 10], [23, 22, 20, 22, 20, 23, 19, 22, 23, 18, 17, 15, 16, 6, 13, 3, 7, 15, 10, 9], [15, 10, 17, 15, 12, 16, 6, 15, 9, 10, 5, 15, 10, 11, 16, 11, 16, 16, 14, 3], [10, 23, 26, 17, 22, 20, 17, 12, 16, 18, 16, 12, 12, 8, 14, 13, 20, 16, 10, 20], [12, 21, 17, 16, 3, 1, 8, 17, 13, 7, 11, 4, 0, 10, 4, 8, 13, 4, 5, 14], [19, 16, 20, 18, 22, 18, 17, 19, 6, 9, 14, 8, 8, 11, 14, 2, 12, 15, 12, 2], [17, 23, 17, 18, 20, 19, 18, 4, 13, 10, 3, 17, 14, 6, 17, 11, 9, 12, 9, 13], [14, 11, 12, 15, 19, 13, 12, 9, 16, 10, 10, 14, 16, 12, 1, 13, 7, 13, 11, 9], [11, 14, 22, 15, 12, 4, 11, 15, 0, 14, 15, 10, 5, 11, 11, 14, 1, 15, 17, 13], [19, 9, 2, 16, 15, 1, 14, 11, 17, 6, 0, 21, 14, 2, 13, 14, 7, 15, 11, 11], [9, 14, 0, 8, 9, 9, 19, 10, 14, 14, 10, 7, 15, 9, 19, 17, 0, 12, 13, 13], [1, 13, 16, 21, 9, 9, 15, 17, 12, 8, 6, 16, 9, 3, 0, 8, 14, 18, 10, 20], [13, 19, 13, 7, 8, 22, 19, 13, 14, 15, 9, 12, 10, 14, 2, 18, 15, 4, 18, 6], [15, 16, 14, 9, 14, 7, 15, 14, 17, 8, 0, 10, 16, 13, 14, 6, 14, 2, 14, 7], [14, 16, 15, 0, 7, 0, 13, 8, 12, 16, 12, 19, 10, 10, 19, 18, 3, 14, 14, 11], [18, 16, 13, 15, 14, 11, 14, 13, 14, 14, 12, 1, 10, 15, 19, 13, 16, 6, 0, 6], [10, 11, 17, 21, 13, 17, 13, 16, 13, 14, 14, 8, 8, 2, 15, 18, 15, 14, 10, 3], [15, 11, 0, 14, 13, 8, 11, 16, 13, 9, 15, 10, 14, 0, 13, 13, 18, 11, 0, 7], [14, 13, 5, 20, 16, 13, 15, 17, 16, 4, 14, 18, 3, 3, 12, 12, 13, 8, 5, 15], [15, 9, 15, 13, 15, 9, 8, 6, 16, 11, 13, 10, 22, 9, 13, 11, 5, 16, 9, 20], [20, 2, 8, 16, 14, 8, 4, 13, 17, 3, 18, 16, 14, 4, 21, 10, 0, 9, 17, 13], [7, 11, 7, 16, 20, 11, 17, 5, 14, 15, 0, 15, 10, 8, 16, 14, 17, 10, 0, 10], [19, 8, 10, 16, 15, 9, 15, 14, 11, 17, 15, 13, 11, 7, 14, 11, 9, 6, 0, 15], [13, 3, 16, 15, 0, 12, 11, 12, 8, 6, 14, 9, 1, 0, 14, 18, 11, 9, 0, 11], [10, 14, 12, 7, 16, 0, 8, 20, 10, 13, 17, 12, 13, 5, 19, 17, 9, 13, 16, 17], [12, 15, 15, 12, 11, 10, 12, 13, 6, 10, 10, 16, 12, 21, 16, 17, 12, 16, 15, 7], [7, 17, 0, 6, 19, 6, 12, 12, 16, 12, 10, 14, 8, 8, 15, 14, 12, 11, 10, 15], [89, 86, 85, 91, 91, 91, 85, 89, 87, 88, 83, 82, 79, 75, 68, 61, 60, 60, 26, 55], [74, 83, 85, 82, 65, 67, 75, 75, 75, 74, 72, 69, 66, 67, 69, 67, 66, 65, 55, 57], [74, 81, 82, 83, 85, 85, 83, 83, 82, 81, 80, 79, 75, 72, 64, 67, 62, 49, 56, 54], [74, 78, 78, 79, 76, 76, 77, 77, 76, 75, 71, 68, 65, 62, 63, 62, 52, 40, 51, 46], [64, 68, 67, 70, 68, 69, 68, 67, 66, 65, 62, 59, 50, 47, 53, 51, 46, 40, 45, 32], [63, 64, 66, 65, 67, 67, 67, 67, 65, 64, 60, 56, 45, 34, 47, 46, 48, 41, 25, 23], [55, 51, 57, 60, 57, 59, 59, 59, 59, 57, 55, 52, 48, 48, 44, 46, 29, 39, 17, 23], [48, 56, 55, 52, 52, 50, 50, 51, 49, 46, 43, 39, 33, 36, 31, 17, 28, 21, 9, 17], [23, 41, 38, 37, 36, 35, 36, 37, 34, 34, 29, 27, 26, 25, 16, 17, 2, 8, 11, 17], [28, 32, 39, 38, 36, 37, 36, 33, 34, 29, 24, 14, 27, 27, 24, 0, 11, 14, 7, 14], [35, 38, 38, 33, 34, 35, 30, 27, 28, 26, 25, 26, 21, 18, 15, 20, 9, 8, 5, 14], [31, 33, 32, 31, 34, 33, 33, 33, 31, 30, 28, 26, 19, 12, 7, 15, 9, 13, 6, 9], [30, 30, 28, 26, 20, 8, 22, 20, 22, 18, 17, 18, 6, 10, 3, 15, 17, 15, 8, 11], [30, 29, 29, 30, 31, 30, 26, 19, 16, 15, 20, 19, 19, 17, 6, 6, 15, 16, 10, 0], [29, 28, 26, 25, 28, 28, 24, 23, 21, 16, 18, 10, 14, 17, 15, 13, 13, 7, 7, 6], [27, 25, 24, 22, 17, 11, 23, 15, 17, 14, 7, 14, 13, 18, 6, 11, 12, 14, 6, 13], [12, 15, 18, 12, 22, 13, 16, 15, 20, 17, 18, 8, 20, 5, 11, 15, 15, 0, 17, 5], [23, 24, 22, 26, 25, 22, 21, 23, 6, 18, 11, 14, 14, 15, 9, 10, 14, 12, 3, 3], [26, 27, 27, 27, 27, 22, 21, 20, 19, 20, 17, 17, 9, 7, 14, 19, 17, 11, 20, 1], [27, 30, 30, 29, 31, 24, 23, 18, 9, 20, 12, 14, 17, 13, 20, 19, 6, 9, 12, 12], [21, 18, 24, 17, 15, 21, 11, 12, 12, 15, 10, 10, 6, 14, 10, 10, 15, 6, 13, 13], [18, 22, 20, 17, 24, 19, 17, 13, 4, 18, 14, 17, 8, 15, 10, 11, 12, 2, 4, 4], [14, 0, 18, 14, 20, 5, 12, 0, 8, 9, 12, 10, 10, 9, 17, 19, 13, 1, 8, 19], [22, 20, 12, 13, 18, 11, 17, 15, 13, 12, 15, 18, 10, 0, 4, 16, 13, 9, 15, 12], [10, 15, 10, 10, 11, 3, 0, 12, 12, 4, 12, 8, 2, 6, 16, 7, 9, 13, 11, 11], [7, 13, 18, 7, 13, 20, 12, 9, 7, 12, 16, 8, 9, 11, 11, 6, 6, 5, 16, 10], [12, 17, 3, 12, 3, 8, 12, 10, 17, 18, 11, 6, 0, 13, 15, 15, 9, 3, 12, 11], [6, 8, 16, 11, 13, 10, 0, 10, 6, 15, 7, 12, 6, 1, 4, 16, 15, 17, 21, 6], [14, 15, 13, 13, 17, 15, 0, 12, 8, 15, 12, 0, 13, 16, 14, 12, 12, 16, 15, 12], [6, 4, 6, 10, 18, 11, 15, 10, 0, 3, 11, 4, 11, 12, 17, 18, 16, 15, 18, 16], [17, 8, 13, 10, 15, 13, 12, 9, 4, 18, 0, 9, 15, 9, 7, 10, 9, 7, 3, 0], [14, 9, 3, 19, 14, 0, 16, 3, 2, 4, 9, 13, 9, 6, 5, 21, 7, 21, 15, 17], [16, 14, 9, 13, 11, 13, 12, 15, 13, 10, 15, 0, 14, 17, 14, 6, 17, 6, 8, 19], [7, 10, 11, 9, 8, 11, 8, 20, 9, 11, 0, 16, 5, 0, 0, 8, 18, 19, 13, 15], [4, 11, 10, 11, 15, 7, 13, 9, 19, 9, 8, 11, 20, 12, 11, 17, 3, 6, 15, 0], [10, 8, 16, 12, 20, 15, 7, 17, 6, 4, 10, 17, 13, 6, 12, 11, 18, 1, 8, 9], [15, 17, 3, 10, 7, 6, 15, 5, 8, 18, 12, 4, 11, 13, 13, 20, 14, 11, 10, 5], [18, 15, 11, 5, 14, 8, 15, 7, 11, 15, 14, 18, 8, 16, 19, 13, 16, 9, 10, 13], [16, 5, 18, 5, 17, 14, 14, 11, 15, 4, 14, 16, 15, 3, 14, 12, 0, 15, 8, 15], [10, 15, 16, 8, 1, 8, 7, 0, 16, 6, 19, 16, 18, 2, 8, 13, 18, 13, 13, 13], [101, 97, 97, 103, 104, 103, 97, 102, 99, 101, 95, 95, 91, 88, 80, 68, 71, 70, 53, 66], [87, 96, 99, 95, 83, 82, 89, 91, 90, 90, 87, 85, 78, 71, 77, 77, 75, 76, 63, 66], [89, 96, 97, 98, 99, 100, 97, 97, 96, 95, 93, 91, 88, 83, 72, 78, 75, 59, 66, 65], [90, 94, 94, 95, 93, 93, 93, 94, 93, 91, 86, 83, 79, 70, 75, 75, 52, 67, 60, 57], [82, 86, 86, 88, 86, 87, 85, 85, 86, 85, 83, 81, 75, 67, 70, 70, 59, 53, 60, 46], [84, 86, 87, 87, 88, 88, 90, 88, 87, 85, 81, 77, 64, 55, 61, 64, 64, 62, 45, 37], [75, 78, 81, 82, 79, 81, 81, 80, 80, 78, 74, 68, 64, 68, 66, 64, 39, 55, 24, 39], [75, 87, 86, 83, 82, 81, 80, 81, 77, 77, 75, 74, 65, 61, 61, 45, 57, 48, 24, 33], [59, 79, 76, 75, 75, 73, 73, 70, 68, 63, 59, 57, 48, 56, 47, 53, 42, 33, 20, 22], [70, 79, 79, 79, 78, 78, 77, 76, 74, 72, 68, 63, 53, 60, 61, 40, 40, 35, 16, 13], [66, 72, 70, 65, 66, 64, 63, 63, 58, 58, 50, 38, 53, 52, 45, 38, 36, 30, 22, 0], [64, 68, 70, 70, 72, 72, 72, 71, 71, 68, 62, 61, 59, 52, 41, 40, 32, 11, 0, 5], [67, 72, 71, 73, 68, 65, 62, 59, 58, 58, 55, 40, 46, 40, 36, 33, 14, 8, 11, 5], [75, 76, 77, 76, 74, 74, 71, 66, 53, 59, 59, 47, 52, 55, 41, 46, 33, 27, 11, 7], [68, 65, 64, 66, 64, 64, 62, 60, 54, 48, 53, 51, 46, 39, 33, 27, 0, 22, 10, 12], [67, 65, 64, 63, 61, 59, 61, 61, 58, 58, 55, 47, 43, 39, 28, 26, 6, 8, 13, 12], [53, 56, 58, 59, 59, 51, 53, 50, 44, 47, 39, 42, 36, 31, 24, 25, 7, 15, 15, 9], [56, 57, 56, 53, 53, 54, 54, 53, 49, 48, 45, 39, 28, 27, 21, 15, 8, 13, 7, 12], [58, 59, 59, 59, 59, 58, 57, 54, 50, 46, 42, 29, 34, 28, 11, 17, 5, 5, 6, 4], [52, 53, 55, 53, 51, 47, 46, 40, 15, 27, 28, 29, 24, 21, 11, 15, 10, 12, 4, 5], [54, 57, 57, 51, 44, 40, 41, 41, 35, 33, 17, 27, 6, 21, 5, 7, 15, 13, 9, 12], [51, 47, 51, 45, 40, 32, 34, 30, 28, 20, 16, 17, 23, 20, 15, 16, 15, 18, 2, 18], [37, 39, 42, 36, 35, 19, 26, 22, 21, 19, 20, 18, 3, 17, 14, 13, 14, 11, 15, 14], [36, 42, 45, 45, 41, 40, 39, 35, 27, 22, 23, 27, 18, 18, 12, 12, 12, 16, 15, 19], [38, 33, 36, 28, 29, 28, 25, 25, 20, 16, 12, 15, 13, 2, 10, 14, 9, 12, 11, 7], [41, 44, 46, 37, 30, 33, 29, 22, 17, 19, 24, 14, 12, 2, 1, 12, 9, 14, 13, 0], [30, 34, 35, 32, 21, 21, 23, 19, 17, 15, 16, 15, 10, 13, 6, 13, 18, 12, 5, 1], [35, 27, 30, 26, 23, 23, 19, 22, 12, 19, 15, 4, 13, 14, 7, 17, 8, 13, 17, 16], [28, 29, 18, 20, 30, 22, 10, 14, 19, 16, 10, 17, 9, 11, 22, 17, 5, 4, 8, 11], [23, 26, 34, 19, 22, 19, 23, 22, 11, 7, 11, 13, 10, 6, 14, 13, 6, 19, 8, 12], [26, 18, 5, 24, 21, 22, 17, 15, 11, 16, 1, 11, 9, 11, 8, 13, 9, 17, 19, 11], [33, 34, 28, 30, 29, 18, 14, 17, 21, 18, 18, 2, 9, 10, 14, 17, 6, 16, 16, 20], [27, 29, 21, 27, 23, 24, 23, 20, 0, 1, 10, 12, 11, 15, 16, 5, 10, 17, 16, 20], [19, 23, 24, 14, 13, 20, 8, 18, 12, 15, 15, 9, 17, 16, 6, 15, 9, 12, 21, 20], [18, 21, 25, 27, 7, 22, 17, 9, 13, 19, 16, 13, 4, 1, 8, 0, 7, 10, 15, 13], [8, 18, 21, 19, 20, 13, 11, 13, 10, 15, 9, 17, 12, 14, 13, 6, 15, 15, 4, 11], [14, 24, 27, 23, 22, 13, 11, 14, 18, 1, 17, 15, 12, 11, 16, 14, 18, 10, 12, 1], [17, 25, 26, 18, 18, 12, 11, 10, 4, 10, 5, 14, 15, 15, 4, 15, 12, 15, 12, 17], [15, 17, 21, 10, 7, 9, 8, 16, 14, 13, 11, 11, 10, 15, 15, 6, 7, 11, 18, 14], [14, 27, 26, 17, 18, 1, 9, 1, 11, 10, 3, 10, 6, 9, 4, 8, 10, 12, 8, 14], [82, 86, 87, 89, 89, 91, 91, 91, 90, 89, 87, 85, 81, 77, 67, 43, 59, 55, 53, 56], [65, 69, 67, 67, 62, 62, 62, 61, 57, 55, 53, 55, 56, 55, 50, 51, 52, 45, 45, 41], [47, 51, 48, 52, 45, 50, 46, 47, 48, 47, 48, 46, 44, 41, 34, 31, 35, 33, 18, 27], [41, 49, 47, 48, 47, 47, 47, 47, 46, 46, 44, 39, 26, 18, 29, 22, 18, 23, 19, 16], [36, 37, 25, 34, 33, 32, 36, 38, 35, 30, 22, 29, 23, 13, 12, 18, 23, 10, 6, 12], [42, 44, 45, 45, 45, 46, 45, 45, 43, 41, 37, 29, 14, 22, 27, 22, 24, 21, 9, 15], [29, 31, 33, 33, 32, 31, 29, 30, 29, 24, 16, 22, 17, 17, 13, 15, 10, 14, 0, 9], [28, 28, 31, 33, 32, 28, 29, 29, 27, 25, 21, 21, 16, 10, 17, 11, 7, 6, 13, 13], [16, 16, 14, 20, 0, 11, 18, 6, 17, 18, 20, 0, 10, 10, 13, 2, 11, 10, 6, 19], [12, 21, 20, 16, 19, 9, 5, 4, 14, 16, 4, 9, 17, 10, 2, 11, 11, 12, 8, 4], [23, 18, 22, 15, 19, 7, 17, 18, 13, 16, 10, 13, 18, 14, 21, 8, 15, 14, 12, 10], [14, 7, 11, 16, 10, 0, 14, 11, 7, 17, 9, 10, 14, 11, 14, 14, 5, 8, 11, 16], [17, 16, 13, 18, 22, 21, 20, 18, 4, 11, 9, 14, 17, 14, 9, 15, 6, 7, 7, 15], [14, 10, 11, 16, 20, 13, 18, 4, 8, 17, 15, 15, 12, 12, 19, 8, 11, 20, 15, 19], [17, 10, 15, 5, 14, 10, 5, 7, 16, 0, 10, 16, 15, 13, 7, 12, 0, 17, 0, 14], [23, 20, 22, 14, 16, 15, 17, 16, 10, 10, 12, 18, 17, 18, 20, 19, 16, 10, 15, 0], [13, 13, 1, 2, 8, 12, 16, 19, 14, 16, 3, 10, 6, 13, 9, 11, 14, 12, 16, 14], [7, 16, 8, 13, 18, 11, 1, 1, 14, 18, 8, 7, 16, 14, 15, 1, 11, 19, 10, 14], [9, 11, 15, 17, 13, 22, 18, 7, 14, 17, 3, 17, 18, 10, 15, 10, 4, 16, 13, 13], [9, 13, 15, 10, 14, 14, 4, 13, 12, 11, 14, 13, 19, 13, 13, 10, 13, 6, 7, 9], [10, 15, 11, 17, 14, 19, 11, 17, 7, 12, 12, 15, 10, 16, 10, 14, 20, 17, 8, 9], [12, 0, 7, 7, 7, 16, 13, 7, 9, 23, 6, 7, 17, 12, 0, 13, 16, 15, 7, 6], [19, 14, 0, 11, 10, 14, 8, 11, 7, 10, 12, 15, 12, 20, 13, 11, 12, 12, 12, 0], [14, 11, 20, 1, 9, 13, 14, 18, 18, 15, 13, 3, 16, 15, 10, 15, 15, 12, 14, 14], [12, 10, 15, 10, 16, 8, 11, 3, 0, 13, 7, 16, 10, 7, 0, 10, 14, 12, 2, 17], [12, 11, 0, 14, 15, 7, 14, 13, 15, 11, 16, 13, 6, 16, 11, 0, 0, 3, 4, 16], [11, 0, 16, 4, 17, 13, 7, 12, 8, 16, 12, 15, 9, 19, 12, 15, 17, 5, 9, 0], [9, 12, 11, 0, 5, 1, 3, 15, 16, 15, 10, 10, 9, 14, 14, 17, 16, 20, 14, 14], [2, 22, 5, 11, 11, 12, 15, 16, 5, 14, 8, 14, 17, 14, 7, 10, 9, 13, 10, 8], [18, 15, 8, 6, 4, 17, 7, 9, 8, 8, 7, 13, 16, 11, 15, 11, 16, 11, 13, 9], [5, 4, 9, 8, 15, 0, 14, 15, 14, 8, 10, 15, 12, 15, 9, 0, 12, 12, 12, 12], [18, 5, 21, 14, 4, 13, 18, 0, 17, 4, 11, 6, 16, 14, 16, 16, 6, 21, 15, 9], [9, 13, 14, 7, 14, 18, 13, 16, 15, 11, 19, 18, 10, 8, 13, 15, 6, 12, 15, 14], [9, 11, 17, 9, 9, 17, 10, 14, 17, 16, 18, 1, 14, 0, 10, 13, 5, 11, 15, 4], [16, 4, 16, 19, 15, 7, 15, 11, 14, 14, 9, 0, 14, 14, 12, 15, 17, 4, 10, 14], [19, 2, 7, 14, 9, 0, 12, 12, 15, 18, 16, 14, 8, 16, 18, 13, 10, 9, 9, 11], [18, 14, 15, 12, 11, 3, 19, 14, 12, 8, 14, 10, 10, 16, 10, 9, 10, 14, 0, 11], [95, 98, 99, 103, 102, 104, 105, 104, 103, 102, 100, 98, 94, 90, 81, 67, 68, 66, 65, 66], [82, 88, 90, 87, 86, 87, 88, 88, 86, 85, 82, 79, 75, 71, 65, 63, 65, 61, 57, 52], [83, 81, 76, 80, 78, 76, 78, 78, 78, 77, 75, 73, 70, 65, 55, 56, 59, 54, 41, 41], [71, 78, 76, 76, 77, 76, 76, 76, 74, 72, 72, 68, 59, 58, 59, 55, 48, 44, 35, 22], [71, 71, 63, 71, 70, 70, 69, 70, 69, 67, 66, 63, 57, 48, 52, 53, 44, 38, 33, 28], [75, 79, 79, 79, 79, 79, 79, 79, 77, 76, 73, 69, 63, 60, 62, 56, 39, 44, 35, 30], [60, 63, 58, 61, 59, 59, 61, 62, 64, 64, 63, 61, 52, 36, 44, 39, 33, 27, 19, 6], [61, 65, 66, 67, 67, 66, 65, 64, 62, 60, 56, 51, 39, 47, 30, 33, 18, 20, 19, 14], [45, 48, 48, 43, 44, 43, 44, 43, 41, 41, 38, 30, 19, 19, 19, 16, 21, 15, 4, 9], [40, 39, 30, 36, 34, 25, 27, 33, 32, 33, 28, 23, 9, 23, 12, 13, 10, 0, 17, 21], [42, 45, 43, 41, 41, 41, 41, 41, 39, 36, 32, 25, 25, 21, 13, 9, 8, 13, 8, 20], [36, 33, 34, 35, 37, 38, 34, 31, 29, 27, 21, 23, 22, 19, 13, 14, 13, 12, 15, 20], [45, 48, 47, 46, 44, 46, 38, 39, 37, 33, 30, 23, 13, 17, 12, 3, 18, 17, 14, 16], [42, 42, 42, 40, 39, 38, 35, 32, 27, 8, 25, 25, 19, 18, 11, 3, 18, 15, 12, 16], [32, 31, 34, 32, 31, 32, 30, 28, 22, 17, 20, 16, 10, 13, 19, 6, 8, 3, 9, 16], [16, 24, 21, 28, 30, 23, 21, 17, 27, 24, 8, 19, 20, 11, 7, 12, 0, 20, 16, 7], [24, 12, 19, 5, 22, 11, 18, 12, 9, 9, 17, 15, 14, 20, 12, 15, 14, 7, 16, 11], [8, 12, 6, 15, 18, 18, 15, 8, 7, 17, 18, 7, 7, 14, 12, 11, 10, 3, 9, 11], [13, 19, 19, 25, 7, 18, 8, 12, 13, 7, 6, 6, 17, 16, 6, 5, 14, 15, 19, 8], [29, 24, 21, 25, 15, 14, 11, 9, 16, 14, 11, 13, 9, 0, 19, 8, 16, 3, 7, 7], [18, 21, 16, 26, 3, 17, 17, 5, 0, 0, 10, 16, 16, 17, 8, 16, 10, 8, 11, 14], [19, 22, 19, 1, 12, 6, 12, 2, 5, 10, 3, 18, 9, 8, 9, 0, 18, 7, 11, 15], [18, 17, 7, 19, 9, 15, 6, 15, 8, 14, 16, 4, 5, 11, 8, 1, 13, 5, 13, 17], [16, 16, 12, 19, 16, 11, 6, 11, 0, 20, 9, 18, 0, 12, 13, 14, 11, 19, 20, 10], [17, 15, 18, 13, 13, 16, 19, 8, 0, 6, 8, 2, 10, 2, 6, 16, 16, 13, 17, 11], [8, 7, 15, 4, 17, 16, 17, 9, 20, 9, 14, 5, 17, 13, 18, 3, 5, 11, 14, 16], [12, 18, 17, 15, 12, 7, 17, 17, 11, 20, 13, 14, 17, 19, 12, 20, 16, 17, 16, 15], [18, 17, 8, 10, 4, 14, 11, 11, 6, 18, 19, 17, 16, 21, 17, 17, 1, 17, 15, 15], [10, 12, 13, 13, 16, 8, 14, 12, 15, 13, 15, 12, 15, 12, 7, 13, 13, 15, 8, 17], [12, 5, 6, 21, 11, 18, 8, 16, 13, 21, 19, 15, 20, 14, 13, 15, 9, 17, 14, 16], [10, 16, 8, 15, 15, 1, 20, 17, 15, 16, 9, 13, 17, 13, 17, 14, 9, 12, 14, 0], [17, 9, 5, 14, 20, 16, 13, 15, 10, 15, 0, 11, 4, 11, 9, 15, 14, 17, 21, 15], [19, 5, 8, 5, 12, 8, 19, 10, 12, 14, 14, 8, 14, 7, 6, 3, 0, 14, 9, 4], [105, 109, 111, 114, 114, 115, 116, 115, 114, 113, 112, 110, 105, 100, 90, 75, 77, 75, 73, 74], [94, 99, 104, 100, 101, 100, 100, 100, 99, 98, 94, 91, 86, 84, 79, 76, 78, 74, 69, 60], [96, 96, 91, 93, 91, 91, 95, 96, 97, 95, 93, 91, 87, 82, 71, 70, 73, 69, 58, 55], [83, 88, 87, 88, 89, 89, 87, 87, 85, 82, 80, 80, 69, 69, 70, 67, 58, 54, 47, 29], [88, 88, 83, 90, 90, 89, 88, 89, 88, 85, 84, 81, 76, 64, 66, 68, 59, 54, 48, 39], [92, 96, 97, 97, 97, 97, 97, 97, 96, 94, 92, 88, 79, 72, 75, 69, 63, 55, 55, 39], [76, 82, 77, 78, 77, 74, 73, 76, 80, 80, 78, 75, 66, 54, 62, 52, 52, 38, 37, 3], [83, 87, 87, 89, 87, 87, 85, 84, 81, 79, 76, 73, 61, 66, 53, 50, 39, 33, 30, 13], [77, 77, 80, 75, 77, 76, 77, 78, 75, 72, 68, 62, 40, 46, 42, 42, 36, 26, 22, 10], [74, 79, 79, 78, 77, 77, 77, 77, 73, 68, 65, 65, 65, 61, 43, 40, 28, 13, 12, 8], [68, 73, 71, 70, 68, 68, 68, 67, 61, 61, 52, 53, 50, 50, 26, 32, 28, 22, 10, 12], [62, 75, 75, 76, 75, 73, 66, 64, 66, 53, 53, 55, 55, 42, 42, 25, 25, 8, 14, 14], [78, 80, 76, 74, 79, 74, 75, 72, 68, 61, 37, 38, 48, 43, 39, 31, 21, 17, 3, 10], [79, 77, 75, 77, 75, 71, 74, 68, 65, 60, 53, 49, 47, 36, 23, 7, 13, 6, 17, 16], [70, 70, 73, 70, 71, 72, 72, 69, 66, 62, 49, 50, 47, 42, 35, 28, 17, 17, 11, 9], [47, 65, 65, 67, 64, 56, 53, 57, 56, 53, 44, 47, 26, 23, 12, 13, 16, 19, 16, 15], [55, 47, 53, 56, 58, 48, 34, 51, 52, 48, 29, 36, 20, 17, 12, 14, 10, 10, 15, 3], [53, 48, 44, 47, 43, 34, 28, 32, 30, 23, 18, 18, 19, 13, 15, 3, 11, 16, 19, 19], [52, 45, 44, 43, 45, 22, 29, 33, 31, 27, 20, 5, 20, 18, 13, 16, 5, 16, 18, 12], [48, 46, 51, 47, 46, 41, 35, 32, 26, 24, 26, 12, 18, 18, 10, 16, 3, 8, 10, 18], [55, 54, 53, 52, 50, 47, 42, 35, 30, 35, 24, 8, 16, 12, 11, 14, 14, 14, 19, 13], [48, 51, 49, 49, 46, 45, 42, 36, 29, 7, 26, 16, 1, 14, 14, 4, 8, 10, 10, 18], [48, 47, 46, 39, 38, 33, 26, 14, 13, 20, 7, 10, 11, 15, 3, 13, 13, 7, 17, 9], [45, 50, 49, 50, 47, 38, 31, 32, 25, 19, 18, 14, 17, 5, 10, 17, 12, 17, 9, 0], [44, 39, 41, 32, 30, 36, 33, 28, 17, 27, 18, 12, 11, 12, 10, 10, 7, 12, 15, 20], [43, 43, 38, 36, 31, 30, 30, 29, 15, 9, 18, 4, 14, 14, 9, 12, 11, 2, 13, 12], [35, 39, 29, 25, 26, 9, 13, 13, 11, 13, 9, 9, 13, 16, 4, 20, 18, 17, 11, 17], [21, 34, 24, 28, 16, 18, 20, 15, 17, 19, 5, 18, 9, 18, 11, 19, 1, 19, 17, 18], [31, 30, 22, 16, 19, 22, 18, 23, 11, 11, 18, 15, 7, 14, 9, 16, 11, 19, 5, 7], [32, 20, 31, 3, 20, 14, 21, 17, 10, 11, 19, 13, 15, 12, 15, 15, 1, 18, 15, 13], [20, 31, 26, 24, 10, 16, 16, 12, 6, 0, 17, 7, 6, 11, 9, 2, 18, 19, 11, 18], [28, 25, 18, 21, 17, 12, 10, 12, 13, 16, 5, 9, 4, 9, 14, 10, 15, 18, 18, 8], [82, 87, 90, 92, 93, 93, 94, 94, 91, 90, 88, 85, 80, 73, 71, 75, 71, 68, 57, 59], [55, 51, 48, 51, 53, 57, 55, 56, 55, 55, 51, 45, 45, 46, 43, 40, 41, 29, 34, 26], [40, 40, 44, 44, 45, 48, 48, 48, 46, 45, 43, 40, 28, 32, 24, 26, 30, 16, 11, 22], [39, 43, 41, 36, 39, 39, 34, 37, 33, 33, 32, 26, 30, 33, 24, 9, 26, 7, 17, 21], [35, 32, 36, 33, 33, 31, 31, 30, 17, 26, 21, 24, 22, 13, 22, 17, 25, 11, 18, 12], [22, 33, 36, 33, 31, 28, 26, 28, 24, 21, 20, 19, 22, 11, 22, 16, 21, 19, 16, 22], [18, 19, 24, 21, 19, 18, 23, 20, 18, 19, 5, 15, 10, 9, 6, 16, 21, 11, 14, 22], [9, 19, 15, 19, 19, 19, 21, 15, 18, 18, 14, 18, 18, 6, 15, 18, 19, 16, 18, 5], [22, 12, 15, 9, 16, 16, 17, 17, 10, 21, 4, 13, 14, 10, 17, 9, 23, 7, 11, 17], [21, 13, 18, 16, 13, 11, 18, 16, 22, 14, 7, 14, 15, 11, 13, 17, 16, 20, 11, 6], [19, 3, 8, 16, 18, 12, 15, 11, 2, 7, 13, 18, 0, 12, 14, 19, 23, 6, 3, 13], [14, 21, 16, 13, 18, 11, 14, 13, 16, 17, 14, 13, 15, 17, 15, 19, 15, 9, 12, 8], [8, 10, 15, 10, 20, 18, 13, 13, 17, 10, 0, 12, 12, 11, 14, 12, 8, 8, 6, 18], [18, 16, 10, 13, 16, 16, 17, 18, 13, 14, 19, 6, 2, 12, 5, 9, 19, 15, 17, 14], [5, 18, 12, 17, 15, 16, 17, 20, 4, 16, 10, 15, 0, 20, 16, 11, 4, 0, 13, 13], [19, 17, 12, 18, 18, 15, 15, 13, 14, 20, 13, 14, 4, 1, 11, 7, 18, 14, 16, 13], [19, 15, 7, 15, 12, 20, 19, 9, 17, 19, 15, 16, 18, 16, 12, 22, 9, 17, 10, 12], [3, 5, 16, 0, 19, 19, 12, 15, 22, 15, 17, 14, 1, 13, 4, 13, 18, 4, 17, 12], [18, 15, 17, 17, 18, 12, 18, 17, 19, 7, 17, 20, 19, 16, 17, 6, 18, 15, 6, 11], [9, 13, 10, 19, 15, 15, 14, 9, 11, 7, 9, 5, 18, 5, 23, 10, 11, 21, 17, 18], [16, 15, 17, 18, 20, 18, 14, 16, 14, 19, 12, 16, 9, 17, 7, 17, 22, 8, 15, 10], [7, 6, 13, 15, 18, 22, 18, 18, 16, 19, 19, 17, 23, 13, 19, 18, 13, 10, 17, 8], [14, 21, 12, 19, 16, 21, 10, 21, 16, 11, 15, 17, 25, 15, 16, 10, 15, 14, 3, 17], [93, 98, 101, 103, 105, 104, 106, 105, 103, 102, 99, 96, 90, 82, 84, 87, 83, 77, 70, 71], [73, 76, 79, 77, 78, 78, 78, 77, 76, 76, 73, 70, 64, 70, 65, 69, 58, 63, 51, 48], [65, 72, 74, 74, 75, 75, 74, 72, 70, 68, 58, 55, 63, 60, 62, 54, 56, 51, 36, 31], [59, 62, 59, 56, 55, 55, 53, 55, 42, 38, 40, 37, 39, 46, 41, 38, 29, 23, 19, 16], [61, 63, 63, 62, 61, 60, 57, 56, 51, 49, 38, 44, 47, 51, 39, 49, 40, 34, 19, 13], [54, 50, 48, 49, 46, 47, 43, 43, 40, 35, 40, 35, 32, 40, 22, 31, 24, 23, 20, 18], [32, 36, 40, 39, 35, 36, 36, 36, 32, 30, 28, 31, 13, 21, 21, 17, 8, 8, 18, 17], [35, 38, 39, 39, 38, 38, 37, 35, 29, 23, 30, 26, 12, 9, 15, 16, 15, 14, 3, 8], [17, 20, 20, 22, 18, 22, 8, 10, 16, 17, 17, 12, 20, 15, 3, 13, 15, 9, 12, 0], [13, 18, 23, 13, 2, 21, 18, 19, 16, 17, 18, 14, 11, 22, 2, 15, 10, 9, 14, 19], [21, 6, 20, 16, 17, 20, 24, 19, 25, 24, 13, 20, 20, 0, 7, 7, 9, 10, 18, 18], [16, 3, 9, 11, 20, 11, 0, 9, 4, 4, 17, 17, 13, 12, 11, 9, 12, 14, 11, 18], [26, 19, 17, 19, 16, 6, 19, 14, 10, 14, 0, 20, 3, 12, 17, 20, 10, 10, 15, 0], [23, 20, 16, 10, 20, 4, 17, 17, 17, 1, 3, 14, 1, 12, 22, 11, 13, 13, 20, 8], [12, 10, 9, 17, 19, 8, 12, 16, 16, 16, 17, 19, 10, 20, 15, 15, 16, 12, 5, 19], [16, 17, 20, 15, 19, 15, 12, 16, 21, 12, 14, 19, 6, 17, 12, 15, 7, 11, 14, 10], [0, 26, 24, 19, 16, 9, 10, 16, 18, 5, 21, 13, 14, 16, 16, 14, 14, 14, 13, 7], [22, 3, 6, 18, 18, 12, 19, 16, 20, 8, 17, 4, 6, 12, 16, 13, 2, 11, 14, 19], [16, 22, 20, 16, 20, 18, 14, 13, 5, 13, 15, 10, 11, 17, 12, 21, 9, 14, 1, 13], [4, 8, 23, 14, 16, 16, 11, 12, 2, 18, 6, 16, 12, 22, 17, 9, 20, 1, 0, 5], [0, 8, 15, 14, 9, 15, 8, 0, 16, 16, 16, 18, 16, 13, 4, 19, 16, 11, 13, 4], [14, 8, 16, 5, 5, 18, 14, 11, 19, 11, 12, 20, 20, 20, 18, 14, 14, 10, 14, 3], [12, 3, 14, 10, 17, 16, 17, 17, 13, 12, 12, 1, 8, 16, 17, 14, 12, 8, 18, 21], [11, 17, 13, 8, 12, 20, 15, 11, 13, 9, 12, 7, 18, 12, 8, 5, 7, 16, 16, 15], [12, 14, 16, 12, 18, 9, 18, 18, 13, 16, 16, 17, 13, 8, 10, 14, 21, 15, 18, 16], [22, 15, 16, 12, 19, 12, 19, 4, 16, 10, 14, 5, 3, 16, 6, 4, 9, 8, 20, 21], [12, 19, 22, 14, 11, 4, 0, 13, 11, 1, 12, 10, 13, 17, 16, 13, 11, 15, 5, 8], [11, 6, 17, 19, 16, 13, 16, 16, 18, 11, 4, 16, 21, 16, 15, 13, 12, 17, 14, 8], [106, 110, 114, 117, 118, 117, 119, 118, 115, 114, 111, 108, 100, 84, 99, 99, 93, 85, 81, 81], [89, 91, 95, 92, 95, 92, 91, 92, 91, 90, 89, 85, 82, 88, 80, 83, 75, 71, 69, 63], [87, 94, 97, 97, 98, 98, 98, 97, 96, 93, 85, 82, 85, 82, 76, 63, 70, 66, 52, 34], [83, 91, 89, 87, 87, 85, 86, 85, 78, 77, 66, 70, 63, 70, 59, 61, 53, 48, 38, 21], [87, 91, 93, 92, 93, 91, 89, 88, 84, 80, 76, 79, 77, 68, 57, 71, 60, 44, 31, 21], [85, 85, 85, 84, 81, 79, 72, 75, 67, 66, 71, 72, 51, 65, 57, 58, 31, 35, 25, 5], [64, 69, 71, 69, 68, 62, 64, 65, 66, 64, 56, 53, 47, 49, 51, 38, 24, 24, 1, 8], [81, 83, 82, 82, 83, 81, 79, 77, 61, 65, 60, 61, 61, 59, 50, 51, 32, 25, 9, 6], [67, 61, 69, 66, 64, 65, 63, 63, 60, 58, 52, 44, 39, 42, 36, 30, 16, 17, 19, 18], [57, 59, 54, 52, 51, 48, 53, 57, 50, 50, 50, 43, 40, 38, 20, 27, 9, 17, 14, 17], [69, 71, 71, 70, 69, 68, 66, 63, 59, 54, 47, 44, 46, 49, 30, 29, 17, 14, 14, 10], [58, 61, 56, 47, 56, 56, 43, 49, 43, 42, 38, 44, 41, 44, 16, 12, 5, 19, 10, 10], [68, 68, 66, 64, 53, 51, 56, 56, 56, 52, 43, 32, 37, 43, 21, 19, 18, 11, 14, 18], [54, 59, 60, 61, 60, 58, 53, 38, 36, 39, 47, 43, 38, 42, 24, 10, 18, 9, 16, 16], [45, 50, 49, 48, 50, 46, 38, 42, 41, 32, 26, 22, 16, 41, 20, 8, 17, 17, 17, 12], [53, 56, 54, 52, 52, 51, 45, 42, 45, 37, 31, 31, 27, 41, 6, 20, 5, 11, 7, 13], [25, 31, 16, 33, 30, 22, 29, 34, 34, 28, 6, 16, 11, 40, 10, 12, 12, 18, 19, 16], [21, 31, 14, 25, 32, 22, 21, 16, 16, 24, 10, 13, 18, 40, 11, 11, 19, 11, 8, 15], [29, 25, 32, 29, 22, 23, 17, 5, 8, 23, 18, 13, 17, 40, 14, 7, 13, 1, 12, 11], [13, 24, 34, 24, 23, 12, 16, 18, 6, 9, 15, 12, 14, 40, 2, 14, 21, 16, 14, 15], [25, 30, 15, 21, 21, 14, 20, 10, 13, 11, 9, 15, 5, 39, 8, 18, 12, 15, 12, 17], [18, 21, 16, 16, 11, 21, 16, 16, 19, 20, 10, 13, 21, 39, 7, 4, 18, 16, 11, 16], [22, 14, 22, 13, 20, 21, 19, 17, 10, 17, 15, 21, 15, 39, 14, 17, 13, 12, 17, 17], [21, 13, 23, 18, 18, 17, 11, 12, 16, 9, 10, 10, 8, 39, 10, 4, 9, 5, 1, 15], [25, 20, 18, 8, 23, 22, 4, 18, 13, 11, 16, 15, 7, 38, 15, 17, 20, 16, 18, 18], [12, 17, 17, 17, 18, 18, 22, 20, 9, 20, 14, 0, 1, 38, 11, 4, 12, 20, 21, 9], [85, 88, 91, 93, 93, 93, 92, 90, 90, 88, 82, 78, 77, 75, 64, 59, 51, 70, 54, 60], [52, 48, 50, 55, 51, 50, 50, 48, 47, 45, 48, 47, 45, 43, 34, 32, 32, 37, 24, 30], [41, 47, 31, 20, 37, 36, 34, 28, 19, 25, 30, 30, 30, 21, 29, 21, 15, 13, 17, 4], [40, 35, 33, 36, 39, 40, 39, 39, 32, 27, 24, 28, 28, 24, 18, 23, 16, 17, 16, 12], [41, 36, 35, 29, 28, 26, 22, 30, 29, 28, 28, 18, 23, 19, 23, 18, 16, 18, 13, 14], [16, 27, 27, 22, 26, 25, 22, 24, 23, 24, 22, 24, 20, 9, 18, 18, 13, 15, 14, 12], [23, 27, 18, 26, 24, 24, 20, 7, 18, 23, 11, 20, 15, 16, 18, 16, 15, 10, 12, 18], [13, 13, 17, 21, 12, 18, 12, 0, 16, 18, 20, 17, 18, 10, 11, 8, 12, 12, 16, 19], [20, 12, 18, 12, 9, 14, 10, 15, 14, 16, 9, 1, 0, 10, 13, 8, 16, 12, 15, 19], [8, 13, 15, 13, 18, 21, 12, 16, 14, 23, 17, 16, 23, 15, 11, 10, 6, 11, 20, 8], [14, 13, 14, 15, 11, 11, 17, 21, 12, 12, 13, 8, 17, 13, 6, 14, 8, 21, 16, 7], [16, 12, 21, 23, 11, 22, 15, 22, 13, 4, 18, 20, 16, 15, 9, 20, 14, 12, 6, 8], [15, 13, 1, 2, 20, 21, 17, 6, 16, 8, 12, 17, 13, 20, 5, 18, 6, 16, 8, 16], [21, 23, 12, 18, 11, 15, 6, 20, 11, 12, 9, 12, 11, 15, 16, 17, 18, 8, 1, 15], [19, 18, 14, 18, 16, 13, 21, 12, 14, 7, 9, 16, 14, 15, 17, 15, 11, 12, 20, 16], [18, 16, 21, 17, 16, 15, 18, 7, 11, 19, 14, 16, 17, 14, 18, 0, 13, 20, 21, 20], [13, 15, 14, 17, 10, 18, 12, 5, 17, 22, 14, 11, 18, 4, 15, 10, 23, 15, 16, 12], [20, 15, 19, 7, 12, 11, 1, 20, 12, 18, 12, 15, 10, 22, 12, 18, 17, 8, 18, 16], [10, 12, 7, 8, 15, 7, 10, 6, 17, 0, 19, 8, 5, 12, 15, 7, 11, 18, 16, 13], [3, 11, 17, 19, 13, 11, 8, 11, 9, 19, 17, 8, 15, 18, 15, 18, 15, 5, 17, 16], [8, 13, 18, 11, 13, 8, 11, 6, 19, 14, 18, 13, 14, 19, 10, 19, 11, 17, 9, 18], [14, 18, 15, 14, 12, 18, 16, 10, 20, 15, 0, 13, 14, 18, 3, 15, 10, 13, 17, 18], [99, 102, 105, 107, 107, 106, 106, 105, 104, 102, 96, 90, 90, 89, 80, 74, 70, 82, 68, 70], [77, 80, 81, 83, 82, 83, 84, 82, 81, 80, 72, 73, 75, 63, 67, 64, 63, 64, 42, 41], [75, 66, 63, 63, 72, 72, 64, 67, 64, 58, 61, 60, 56, 49, 58, 52, 41, 34, 22, 18], [67, 57, 58, 61, 63, 63, 63, 62, 57, 48, 53, 48, 47, 46, 41, 41, 17, 23, 22, 13], [65, 63, 59, 55, 57, 57, 55, 54, 54, 47, 50, 49, 31, 46, 41, 22, 17, 21, 8, 21], [55, 59, 61, 60, 59, 58, 58, 57, 47, 47, 48, 40, 42, 29, 32, 18, 21, 16, 8, 4], [55, 54, 55, 56, 53, 53, 49, 46, 42, 36, 38, 38, 26, 30, 24, 18, 13, 14, 10, 1], [34, 44, 41, 40, 38, 42, 28, 30, 32, 27, 26, 30, 18, 24, 20, 15, 14, 6, 14, 14], [38, 18, 30, 21, 28, 23, 26, 23, 19, 24, 14, 18, 23, 12, 15, 18, 21, 17, 12, 9], [23, 27, 16, 24, 19, 17, 18, 22, 16, 16, 12, 18, 16, 18, 9, 17, 16, 19, 19, 15], [20, 22, 15, 19, 11, 18, 20, 14, 14, 19, 17, 9, 19, 8, 10, 13, 16, 19, 12, 15], [21, 26, 10, 17, 17, 2, 8, 21, 21, 21, 6, 16, 14, 13, 19, 15, 14, 18, 8, 0], [22, 26, 27, 25, 16, 17, 20, 14, 19, 19, 5, 23, 14, 11, 19, 18, 15, 17, 9, 15], [19, 15, 21, 20, 20, 12, 14, 12, 16, 16, 13, 12, 20, 21, 14, 18, 18, 7, 16, 12], [19, 19, 22, 17, 25, 18, 10, 19, 20, 11, 22, 8, 15, 21, 14, 15, 19, 18, 17, 14], [14, 20, 17, 14, 9, 21, 10, 16, 19, 16, 19, 16, 19, 6, 15, 16, 17, 18, 10, 16], [22, 19, 23, 17, 19, 17, 4, 17, 0, 8, 21, 3, 14, 18, 23, 1, 17, 0, 20, 9], [14, 14, 13, 8, 21, 10, 17, 16, 11, 15, 15, 12, 15, 17, 17, 14, 18, 21, 15, 20], [12, 13, 19, 17, 10, 16, 11, 18, 15, 4, 11, 8, 17, 14, 13, 17, 10, 21, 16, 18], [17, 17, 19, 18, 17, 15, 13, 14, 16, 20, 4, 16, 18, 14, 17, 10, 7, 11, 12, 18], [20, 20, 13, 19, 9, 17, 21, 6, 20, 9, 15, 19, 20, 10, 15, 22, 14, 16, 16, 20], [17, 21, 14, 5, 11, 0, 6, 23, 21, 5, 10, 21, 19, 0, 20, 17, 24, 13, 8, 22], [108, 111, 115, 116, 116, 116, 115, 113, 112, 110, 104, 99, 97, 97, 89, 87, 80, 88, 80, 75], [87, 92, 92, 94, 94, 95, 95, 93, 91, 89, 82, 84, 83, 77, 80, 76, 75, 71, 58, 50], [89, 81, 70, 72, 83, 84, 74, 77, 68, 73, 72, 70, 72, 67, 68, 62, 45, 46, 30, 24], [83, 78, 77, 80, 81, 80, 79, 78, 58, 70, 62, 64, 53, 63, 56, 55, 39, 37, 17, 22], [83, 82, 77, 72, 73, 70, 67, 59, 60, 69, 65, 60, 56, 62, 48, 49, 40, 28, 22, 18], [71, 76, 79, 79, 76, 76, 71, 70, 65, 69, 62, 56, 59, 48, 48, 36, 28, 24, 24, 18], [75, 75, 76, 77, 75, 75, 72, 68, 61, 64, 61, 53, 56, 51, 49, 32, 29, 23, 9, 12], [62, 63, 66, 67, 63, 62, 54, 61, 55, 51, 52, 50, 42, 26, 22, 19, 21, 6, 14, 14], [69, 66, 66, 64, 62, 62, 61, 63, 58, 55, 53, 47, 37, 36, 32, 25, 15, 17, 15, 18], [52, 51, 57, 48, 55, 51, 41, 43, 45, 37, 33, 23, 11, 18, 13, 14, 7, 18, 7, 16], [54, 46, 48, 50, 48, 44, 29, 43, 38, 21, 22, 18, 23, 23, 10, 11, 20, 22, 9, 18], [49, 49, 43, 50, 45, 42, 47, 46, 35, 39, 25, 28, 22, 19, 13, 14, 8, 15, 10, 6], [43, 46, 47, 51, 50, 50, 41, 27, 36, 29, 28, 20, 17, 23, 15, 18, 13, 19, 5, 6], [44, 46, 45, 46, 44, 41, 36, 34, 21, 16, 19, 15, 13, 21, 15, 20, 17, 15, 18, 12], [38, 31, 36, 34, 33, 23, 23, 13, 20, 11, 21, 18, 17, 19, 15, 18, 17, 4, 3, 7], [34, 26, 25, 16, 15, 16, 17, 12, 9, 17, 19, 14, 3, 16, 17, 0, 22, 9, 15, 19], [15, 29, 22, 25, 12, 20, 19, 13, 16, 20, 14, 15, 21, 0, 17, 16, 6, 10, 2, 10], [23, 27, 14, 21, 23, 13, 20, 24, 16, 12, 15, 13, 18, 18, 13, 12, 0, 19, 22, 11], [20, 19, 24, 17, 11, 16, 20, 21, 21, 10, 21, 21, 12, 13, 2, 19, 19, 19, 18, 10], [14, 28, 21, 21, 19, 18, 18, 9, 12, 3, 5, 14, 18, 18, 18, 6, 4, 18, 16, 11], [20, 20, 12, 14, 17, 8, 20, 17, 13, 11, 10, 14, 7, 7, 16, 19, 9, 9, 17, 17], [87, 88, 85, 85, 87, 86, 86, 85, 83, 78, 68, 71, 77, 76, 59, 68, 62, 58, 55, 40], [51, 48, 45, 51, 35, 46, 44, 45, 28, 40, 45, 41, 39, 39, 35, 24, 27, 16, 22, 21], [39, 35, 39, 38, 34, 32, 41, 38, 33, 36, 34, 30, 15, 28, 24, 16, 18, 22, 21, 7], [43, 43, 42, 40, 39, 38, 37, 33, 24, 15, 17, 26, 24, 22, 21, 23, 19, 23, 18, 13], [24, 25, 25, 12, 27, 20, 13, 22, 17, 23, 11, 15, 19, 11, 15, 19, 18, 13, 13, 9], [14, 23, 24, 16, 24, 21, 23, 12, 18, 21, 26, 17, 16, 3, 15, 11, 16, 13, 9, 20], [17, 29, 18, 22, 9, 11, 15, 17, 21, 20, 16, 16, 14, 16, 15, 8, 16, 12, 13, 15], [19, 17, 18, 26, 25, 8, 13, 9, 16, 12, 8, 11, 7, 16, 15, 9, 17, 18, 19, 16], [13, 13, 20, 11, 20, 19, 13, 19, 10, 13, 7, 19, 11, 17, 19, 16, 16, 21, 12, 20], [11, 14, 19, 15, 21, 15, 20, 10, 15, 18, 10, 16, 15, 13, 19, 9, 18, 13, 7, 18], [19, 12, 12, 17, 6, 18, 22, 20, 9, 22, 16, 16, 19, 7, 19, 9, 14, 18, 21, 19], [14, 16, 17, 17, 23, 17, 15, 18, 4, 15, 16, 6, 15, 18, 9, 13, 16, 15, 14, 3], [19, 18, 11, 12, 14, 22, 17, 9, 10, 10, 18, 23, 1, 18, 16, 8, 16, 7, 13, 21], [15, 12, 1, 22, 14, 16, 15, 22, 18, 19, 20, 19, 25, 14, 18, 13, 22, 20, 18, 18], [15, 13, 25, 13, 18, 18, 18, 13, 15, 17, 15, 9, 13, 14, 7, 13, 18, 12, 16, 10], [18, 17, 11, 15, 22, 18, 18, 11, 14, 16, 9, 22, 6, 14, 11, 11, 16, 24, 6, 13], [17, 16, 17, 16, 16, 20, 12, 13, 20, 21, 2, 20, 14, 18, 18, 16, 2, 14, 19, 19], [73, 98, 95, 94, 96, 95, 95, 95, 92, 88, 79, 81, 87, 85, 66, 76, 71, 67, 65, 53], [63, 60, 66, 68, 62, 64, 58, 63, 54, 39, 50, 49, 46, 44, 40, 36, 30, 22, 16, 24], [54, 42, 52, 39, 39, 42, 48, 42, 37, 42, 43, 23, 42, 38, 30, 24, 20, 18, 14, 15], [51, 60, 56, 55, 53, 49, 49, 45, 45, 44, 44, 41, 32, 26, 27, 26, 22, 22, 8, 14], [33, 29, 20, 31, 29, 13, 28, 36, 32, 27, 30, 11, 24, 18, 21, 12, 17, 19, 12, 16], [20, 24, 30, 22, 22, 21, 18, 23, 24, 12, 16, 15, 15, 15, 13, 17, 16, 10, 12, 21], [15, 25, 25, 21, 19, 16, 22, 24, 16, 15, 16, 17, 15, 16, 16, 18, 18, 19, 18, 12], [12, 22, 21, 11, 24, 15, 17, 18, 6, 14, 9, 17, 18, 16, 11, 15, 13, 10, 14, 10], [19, 18, 22, 7, 17, 18, 6, 21, 22, 10, 21, 14, 15, 10, 17, 14, 23, 17, 16, 16], [14, 16, 12, 22, 24, 21, 20, 13, 17, 19, 13, 14, 15, 8, 9, 18, 5, 6, 11, 21], [25, 21, 24, 12, 0, 20, 18, 13, 19, 22, 20, 22, 18, 19, 19, 16, 10, 15, 11, 16], [25, 17, 21, 20, 17, 19, 23, 10, 18, 23, 19, 16, 14, 7, 19, 11, 7, 19, 18, 5], [11, 12, 20, 11, 18, 13, 15, 15, 19, 10, 19, 20, 19, 15, 5, 18, 17, 19, 21, 15], [16, 13, 19, 12, 19, 20, 21, 12, 22, 12, 10, 18, 20, 18, 24, 13, 13, 16, 12, 13], [14, 16, 8, 17, 12, 20, 23, 19, 9, 9, 14, 16, 14, 16, 23, 21, 18, 13, 0, 20], [18, 12, 18, 11, 16, 15, 19, 19, 19, 15, 16, 8, 12, 16, 18, 10, 10, 18, 23, 18], [20, 4, 10, 21, 6, 14, 20, 17, 20, 20, 6, 21, 13, 16, 19, 23, 17, 14, 5, 6], [59, 105, 113, 108, 108, 109, 109, 108, 106, 101, 84, 96, 101, 97, 85, 88, 83, 80, 73, 64], [35, 87, 79, 83, 93, 87, 82, 85, 78, 81, 74, 84, 64, 69, 69, 60, 57, 52, 42, 35], [26, 79, 71, 81, 67, 75, 74, 65, 65, 72, 57, 68, 59, 44, 56, 47, 34, 29, 19, 16], [19, 84, 82, 78, 72, 72, 71, 69, 72, 72, 60, 53, 46, 39, 38, 35, 25, 22, 15, 18], [20, 65, 67, 67, 70, 66, 65, 64, 63, 60, 57, 49, 44, 41, 23, 14, 16, 22, 13, 11], [9, 59, 44, 58, 62, 60, 59, 57, 57, 53, 38, 38, 32, 19, 12, 22, 0, 5, 13, 19], [19, 66, 65, 63, 54, 51, 40, 58, 56, 50, 47, 47, 35, 14, 19, 10, 20, 18, 19, 20], [13, 60, 60, 50, 34, 38, 44, 36, 45, 42, 35, 28, 22, 17, 18, 2, 18, 12, 20, 13], [10, 55, 55, 56, 51, 49, 45, 42, 35, 38, 32, 35, 25, 20, 20, 16, 21, 16, 11, 18], [19, 44, 43, 48, 45, 40, 31, 16, 27, 19, 11, 10, 0, 19, 4, 10, 5, 11, 7, 4], [3, 33, 40, 38, 35, 34, 22, 31, 24, 22, 24, 13, 13, 12, 14, 23, 12, 19, 22, 18], [13, 35, 39, 41, 35, 31, 28, 28, 23, 22, 19, 14, 18, 18, 19, 21, 17, 20, 14, 22], [20, 32, 38, 34, 27, 21, 17, 9, 8, 15, 11, 18, 21, 13, 11, 25, 16, 12, 13, 15], [7, 32, 31, 28, 36, 33, 16, 25, 11, 17, 14, 10, 15, 19, 21, 18, 16, 12, 18, 17], [20, 21, 15, 19, 24, 21, 23, 22, 13, 20, 7, 10, 25, 17, 21, 21, 22, 19, 21, 9], [14, 25, 22, 20, 14, 12, 8, 13, 15, 23, 14, 23, 7, 10, 15, 19, 19, 14, 10, 7], [6, 27, 28, 24, 26, 11, 21, 16, 18, 13, 12, 15, 24, 11, 13, 18, 14, 12, 13, 13], [78, 77, 78, 78, 72, 63, 73, 72, 72, 72, 69, 67, 67, 68, 62, 61, 54, 35, 41, 38], [46, 47, 49, 53, 53, 52, 52, 51, 49, 45, 38, 42, 42, 36, 24, 29, 19, 19, 23, 12], [32, 37, 31, 26, 36, 27, 29, 28, 27, 19, 36, 34, 31, 21, 21, 26, 20, 17, 17, 14], [26, 28, 25, 23, 19, 20, 25, 24, 17, 21, 13, 23, 11, 21, 19, 16, 13, 13, 16, 20], [18, 22, 17, 21, 6, 16, 14, 11, 16, 11, 3, 18, 8, 20, 15, 19, 9, 26, 21, 15], [16, 16, 21, 15, 19, 13, 17, 7, 13, 20, 11, 11, 17, 11, 18, 14, 13, 20, 17, 10], [23, 23, 19, 18, 21, 13, 8, 13, 22, 6, 20, 20, 19, 14, 6, 10, 18, 8, 15, 19], [23, 20, 11, 14, 8, 16, 16, 13, 20, 9, 23, 18, 15, 17, 7, 13, 14, 11, 13, 14], [19, 15, 23, 19, 18, 23, 18, 26, 15, 16, 19, 17, 14, 6, 16, 19, 8, 23, 18, 18], [9, 14, 16, 10, 19, 7, 13, 16, 6, 21, 19, 18, 16, 19, 22, 19, 7, 7, 19, 22], [10, 7, 10, 20, 13, 12, 16, 14, 13, 23, 15, 15, 8, 21, 14, 16, 7, 19, 21, 7], [17, 5, 18, 12, 20, 16, 22, 23, 17, 7, 19, 6, 13, 23, 20, 18, 13, 18, 21, 21], [11, 10, 18, 9, 16, 9, 8, 20, 21, 16, 14, 21, 8, 18, 17, 12, 17, 15, 20, 11], [94, 92, 91, 93, 88, 80, 77, 75, 75, 72, 73, 72, 77, 76, 68, 70, 64, 47, 50, 43], [53, 59, 50, 59, 60, 55, 52, 50, 48, 54, 54, 41, 47, 49, 41, 35, 34, 26, 17, 24], [59, 51, 53, 55, 55, 52, 56, 55, 50, 51, 53, 45, 41, 41, 18, 22, 7, 0, 20, 20], [39, 41, 41, 37, 41, 41, 39, 39, 36, 33, 31, 9, 24, 6, 19, 9, 12, 20, 6, 19], [31, 33, 33, 25, 24, 30, 30, 23, 16, 13, 13, 19, 17, 16, 20, 12, 21, 17, 13, 9], [26, 20, 21, 20, 24, 18, 20, 16, 15, 17, 19, 20, 14, 8, 21, 15, 20, 14, 4, 11], [24, 22, 16, 20, 23, 17, 17, 22, 20, 16, 16, 20, 2, 15, 8, 19, 21, 21, 17, 14], [23, 26, 13, 12, 17, 19, 18, 21, 13, 20, 20, 13, 14, 8, 21, 9, 22, 14, 4, 14], [23, 14, 16, 18, 22, 16, 10, 13, 17, 22, 12, 19, 18, 22, 14, 16, 21, 19, 9, 15], [20, 22, 19, 22, 17, 13, 19, 17, 19, 22, 15, 19, 16, 20, 10, 18, 11, 21, 21, 12], [16, 16, 19, 16, 11, 13, 20, 9, 15, 18, 21, 17, 17, 19, 17, 21, 12, 10, 11, 24], [21, 14, 15, 15, 14, 14, 18, 14, 22, 21, 13, 18, 18, 19, 14, 16, 19, 21, 18, 9], [23, 21, 16, 23, 7, 19, 20, 19, 21, 18, 11, 18, 15, 10, 18, 20, 6, 17, 12, 23], [54, 103, 98, 103, 101, 100, 92, 89, 91, 89, 77, 86, 87, 85, 80, 78, 75, 66, 52, 51], [32, 88, 87, 86, 86, 86, 84, 86, 85, 80, 71, 68, 78, 70, 67, 63, 54, 41, 40, 30], [23, 80, 69, 69, 74, 70, 71, 67, 57, 63, 62, 58, 50, 51, 43, 44, 34, 27, 25, 24], [19, 65, 58, 65, 66, 66, 66, 59, 56, 45, 57, 51, 21, 42, 30, 29, 16, 16, 14, 20], [24, 58, 62, 61, 55, 46, 56, 51, 46, 49, 50, 47, 42, 29, 27, 23, 10, 22, 24, 18], [21, 51, 51, 32, 41, 36, 33, 31, 37, 36, 29, 25, 17, 20, 9, 20, 17, 12, 11, 18], [16, 55, 52, 50, 41, 42, 37, 42, 28, 29, 21, 21, 6, 10, 11, 18, 16, 17, 14, 16], [20, 38, 44, 43, 40, 42, 35, 36, 25, 32, 22, 23, 20, 8, 12, 16, 10, 17, 18, 20], [10, 48, 44, 39, 34, 21, 20, 26, 24, 27, 21, 21, 19, 13, 21, 17, 15, 19, 17, 16], [22, 34, 36, 30, 26, 27, 25, 13, 16, 22, 18, 17, 20, 18, 13, 21, 18, 9, 17, 18], [19, 18, 27, 21, 25, 20, 14, 13, 1, 10, 17, 20, 11, 21, 1, 15, 17, 19, 8, 26], [12, 28, 29, 23, 22, 16, 20, 24, 18, 10, 1, 21, 17, 17, 17, 8, 21, 12, 16, 18], [12, 27, 19, 19, 17, 16, 21, 15, 10, 20, 20, 17, 12, 20, 15, 20, 20, 24, 15, 19], [67, 70, 78, 81, 81, 78, 78, 78, 73, 71, 68, 63, 66, 67, 60, 56, 51, 50, 29, 37], [47, 52, 53, 56, 56, 55, 54, 53, 47, 40, 40, 41, 27, 30, 27, 25, 7, 16, 22, 18], [22, 33, 35, 36, 34, 37, 36, 35, 24, 17, 22, 18, 21, 23, 7, 16, 16, 19, 8, 15], [24, 26, 23, 20, 18, 18, 22, 24, 17, 17, 16, 19, 21, 13, 12, 16, 21, 24, 0, 12], [18, 20, 15, 26, 21, 22, 22, 16, 21, 11, 15, 17, 18, 17, 25, 24, 23, 18, 9, 12], [21, 7, 17, 16, 15, 16, 17, 20, 18, 13, 20, 16, 19, 20, 14, 8, 11, 18, 15, 18], [14, 13, 19, 18, 20, 19, 7, 15, 23, 21, 19, 18, 15, 16, 17, 18, 22, 15, 16, 13], [16, 26, 23, 21, 23, 9, 14, 22, 12, 16, 17, 23, 14, 16, 15, 13, 18, 21, 19, 15], [17, 6, 6, 15, 21, 25, 17, 23, 17, 20, 19, 16, 27, 18, 12, 14, 21, 10, 23, 11], [22, 11, 8, 20, 6, 21, 23, 17, 22, 20, 24, 22, 18, 24, 16, 11, 25, 17, 19, 20], [21, 14, 20, 22, 19, 26, 14, 18, 16, 12, 19, 24, 19, 24, 12, 20, 17, 23, 16, 21], [85, 90, 94, 96, 95, 95, 95, 95, 92, 89, 83, 77, 78, 79, 73, 72, 63, 63, 32, 46], [62, 61, 63, 63, 66, 65, 63, 63, 56, 46, 47, 52, 34, 38, 37, 34, 19, 18, 15, 21], [38, 48, 49, 49, 44, 43, 43, 41, 31, 31, 38, 35, 18, 30, 27, 22, 21, 17, 19, 23], [40, 40, 36, 30, 28, 24, 24, 30, 31, 27, 24, 21, 14, 17, 24, 10, 15, 13, 14, 22], [23, 34, 21, 26, 23, 28, 19, 20, 25, 20, 16, 15, 9, 12, 23, 3, 25, 7, 22, 7], [23, 19, 18, 20, 25, 16, 16, 19, 26, 20, 21, 18, 11, 19, 23, 21, 19, 17, 18, 22], [23, 26, 13, 20, 21, 18, 12, 9, 12, 12, 19, 19, 8, 19, 19, 16, 19, 18, 17, 19], [12, 20, 19, 18, 19, 14, 24, 15, 26, 16, 21, 8, 15, 16, 17, 20, 13, 15, 17, 20], [21, 17, 13, 18, 20, 17, 19, 23, 17, 22, 24, 1, 23, 14, 11, 12, 17, 16, 12, 12], [16, 5, 15, 20, 15, 14, 11, 20, 18, 14, 14, 12, 13, 19, 16, 13, 21, 5, 13, 11], [14, 21, 15, 20, 19, 17, 15, 19, 21, 18, 23, 7, 21, 8, 15, 17, 22, 14, 21, 22], [102, 107, 110, 112, 111, 111, 111, 111, 108, 105, 98, 91, 94, 93, 89, 84, 77, 76, 57, 57], [86, 86, 88, 89, 92, 91, 86, 77, 79, 68, 69, 74, 64, 67, 62, 56, 31, 37, 21, 16], [66, 72, 65, 53, 67, 64, 65, 60, 57, 47, 44, 49, 47, 42, 37, 29, 15, 20, 17, 18], [63, 64, 60, 37, 47, 52, 57, 55, 52, 49, 47, 47, 42, 24, 25, 18, 22, 13, 20, 16], [53, 52, 48, 45, 51, 52, 50, 49, 27, 42, 40, 29, 23, 12, 21, 8, 12, 22, 23, 10], [41, 44, 43, 38, 38, 28, 34, 30, 22, 21, 24, 18, 16, 10, 17, 17, 15, 20, 20, 12], [46, 43, 40, 29, 21, 30, 24, 28, 25, 23, 22, 11, 15, 16, 15, 18, 14, 16, 13, 18], [31, 37, 36, 35, 24, 29, 21, 20, 9, 20, 21, 16, 20, 16, 13, 20, 18, 20, 24, 22], [29, 25, 30, 18, 24, 12, 20, 24, 20, 18, 15, 19, 17, 13, 19, 10, 22, 8, 14, 20], [24, 28, 20, 18, 21, 16, 19, 2, 19, 13, 11, 21, 19, 20, 17, 25, 15, 20, 12, 14], [26, 28, 23, 23, 14, 18, 21, 23, 16, 13, 18, 23, 20, 14, 15, 19, 23, 19, 18, 19], [65, 73, 67, 72, 69, 67, 65, 65, 58, 54, 57, 48, 56, 37, 40, 42, 36, 31, 24, 19], [45, 45, 43, 42, 43, 40, 42, 41, 43, 42, 30, 36, 23, 15, 23, 8, 23, 21, 19, 22], [26, 21, 28, 26, 24, 19, 22, 20, 22, 15, 21, 20, 15, 20, 22, 11, 16, 22, 13, 18], [30, 32, 34, 35, 31, 32, 19, 18, 26, 15, 14, 11, 21, 18, 13, 13, 17, 17, 15, 12], [21, 25, 24, 22, 5, 12, 19, 14, 21, 20, 17, 20, 8, 18, 12, 24, 18, 17, 17, 10], [23, 25, 24, 26, 22, 16, 24, 22, 13, 22, 14, 22, 12, 15, 9, 14, 15, 18, 15, 18], [23, 11, 11, 22, 22, 20, 23, 22, 26, 11, 18, 20, 18, 10, 15, 19, 11, 17, 16, 17], [15, 22, 15, 19, 17, 20, 18, 25, 21, 22, 20, 17, 20, 21, 26, 19, 22, 18, 20, 20], [89, 93, 90, 92, 90, 87, 88, 85, 85, 82, 62, 72, 77, 71, 64, 58, 51, 41, 25, 26], [43, 59, 52, 46, 52, 48, 46, 50, 48, 50, 20, 46, 34, 13, 22, 26, 20, 22, 16, 18], [27, 36, 33, 37, 28, 31, 33, 31, 32, 21, 19, 20, 16, 17, 15, 20, 13, 23, 10, 13], [32, 42, 28, 27, 29, 32, 35, 33, 28, 31, 23, 19, 16, 20, 23, 23, 21, 16, 22, 20], [29, 22, 26, 33, 27, 24, 22, 24, 10, 15, 14, 16, 18, 17, 14, 5, 19, 14, 16, 23], [10, 22, 20, 13, 19, 21, 25, 20, 21, 23, 13, 9, 17, 17, 15, 20, 20, 21, 19, 10], [23, 18, 18, 22, 24, 29, 18, 15, 23, 21, 20, 20, 10, 15, 22, 16, 23, 17, 21, 18], [24, 11, 7, 8, 18, 17, 21, 16, 19, 24, 21, 23, 13, 22, 18, 19, 21, 16, 21, 27], [105, 107, 106, 106, 105, 104, 103, 101, 101, 97, 77, 91, 91, 86, 77, 70, 64, 54, 46, 40], [83, 80, 79, 68, 63, 78, 75, 73, 68, 72, 63, 66, 56, 56, 46, 31, 15, 8, 15, 18], [55, 51, 52, 56, 48, 51, 53, 47, 41, 40, 20, 34, 36, 28, 19, 20, 20, 19, 21, 19], [56, 53, 50, 40, 47, 54, 54, 49, 28, 50, 39, 40, 35, 30, 19, 26, 25, 28, 16, 21], [38, 43, 37, 41, 39, 39, 41, 40, 29, 20, 19, 20, 21, 21, 15, 12, 14, 17, 18, 11], [46, 38, 38, 33, 30, 29, 28, 22, 17, 17, 14, 12, 12, 15, 24, 18, 16, 19, 17, 15], [31, 38, 25, 27, 13, 21, 20, 19, 12, 15, 19, 24, 17, 13, 17, 20, 17, 18, 21, 16], [16, 23, 23, 27, 18, 26, 16, 15, 12, 8, 13, 22, 15, 15, 16, 18, 14, 22, 23, 22], [18, 24, 19, 25, 25, 21, 13, 12, 15, 19, 18, 23, 22, 12, 22, 16, 16, 26, 17, 20], [60, 58, 51, 66, 50, 61, 47, 51, 45, 56, 52, 50, 39, 48, 35, 36, 27, 31, 28, 25], [42, 43, 39, 37, 37, 42, 40, 29, 33, 23, 35, 29, 23, 23, 14, 21, 17, 17, 23, 21], [32, 23, 15, 21, 28, 32, 23, 25, 14, 25, 21, 20, 19, 23, 21, 18, 16, 9, 19, 13], [15, 18, 26, 24, 20, 24, 23, 18, 22, 16, 17, 20, 4, 20, 24, 18, 12, 11, 18, 12], [22, 25, 19, 18, 20, 16, 22, 26, 16, 24, 13, 19, 14, 17, 26, 17, 6, 21, 23, 18], [24, 19, 19, 26, 21, 18, 22, 17, 21, 23, 17, 19, 26, 21, 18, 24, 24, 23, 15, 23], [28, 18, 20, 29, 17, 22, 20, 16, 19, 22, 23, 19, 21, 15, 20, 11, 19, 21, 19, 21], [83, 78, 76, 78, 69, 69, 74, 77, 67, 77, 70, 70, 66, 66, 53, 52, 42, 32, 26, 23], [52, 53, 49, 49, 43, 35, 47, 42, 42, 40, 36, 37, 29, 23, 22, 19, 24, 25, 18, 19], [37, 39, 33, 34, 28, 33, 28, 27, 27, 27, 12, 24, 26, 19, 23, 20, 17, 18, 20, 14], [28, 24, 23, 28, 24, 22, 26, 26, 23, 24, 26, 26, 20, 20, 19, 22, 24, 13, 17, 20], [28, 15, 22, 23, 28, 25, 15, 25, 22, 20, 21, 20, 23, 21, 20, 27, 16, 19, 16, 19], [8, 19, 22, 25, 21, 25, 16, 21, 20, 20, 22, 26, 26, 19, 21, 14, 23, 23, 13, 16], [19, 14, 23, 25, 24, 24, 15, 26, 22, 20, 22, 22, 19, 21, 23, 22, 14, 18, 19, 21], [108, 106, 101, 101, 89, 89, 96, 101, 94, 98, 88, 90, 87, 76, 72, 69, 51, 51, 25, 21], [81, 73, 80, 81, 70, 77, 73, 64, 58, 60, 61, 52, 42, 46, 35, 28, 21, 20, 19, 15], [64, 60, 58, 61, 63, 56, 61, 52, 46, 43, 43, 23, 27, 21, 16, 23, 21, 21, 21, 11], [49, 54, 48, 58, 55, 33, 46, 48, 46, 25, 32, 27, 23, 20, 22, 18, 21, 12, 20, 13], [39, 43, 47, 37, 38, 29, 35, 32, 28, 20, 10, 16, 17, 12, 23, 13, 20, 17, 22, 22], [33, 32, 23, 34, 27, 29, 21, 16, 21, 18, 20, 14, 9, 19, 18, 22, 11, 21, 15, 20], [18, 27, 17, 24, 27, 18, 25, 24, 23, 20, 22, 16, 19, 24, 18, 21, 20, 21, 25, 16], [61, 71, 70, 72, 63, 58, 56, 54, 58, 50, 46, 50, 46, 34, 37, 28, 25, 26, 26, 25], [30, 40, 37, 38, 33, 31, 34, 31, 27, 30, 22, 22, 19, 25, 21, 21, 14, 17, 20, 25], [25, 30, 22, 26, 28, 24, 28, 24, 14, 20, 19, 19, 15, 23, 14, 18, 16, 16, 20, 18], [26, 19, 25, 22, 21, 20, 27, 16, 22, 15, 19, 18, 14, 22, 22, 22, 22, 18, 18, 22], [17, 23, 20, 20, 26, 21, 14, 23, 17, 8, 24, 21, 20, 8, 17, 20, 20, 20, 19, 24], [22, 23, 24, 23, 21, 20, 16, 27, 27, 18, 20, 18, 17, 19, 18, 14, 15, 19, 16, 19], [72, 82, 85, 83, 81, 79, 73, 68, 75, 69, 67, 69, 58, 51, 53, 46, 40, 35, 29, 25], [49, 49, 54, 52, 39, 45, 46, 37, 29, 40, 35, 28, 29, 26, 17, 23, 20, 27, 17, 20], [33, 36, 31, 33, 32, 35, 32, 35, 28, 28, 24, 23, 18, 22, 13, 19, 19, 22, 17, 19], [28, 28, 29, 27, 27, 25, 28, 21, 17, 20, 20, 24, 20, 23, 22, 19, 21, 15, 19, 22], [25, 26, 26, 22, 9, 24, 19, 20, 22, 23, 18, 14, 16, 22, 19, 26, 22, 22, 23, 21], [82, 93, 96, 100, 99, 94, 90, 83, 91, 79, 81, 80, 69, 66, 62, 54, 43, 35, 17, 21], [68, 66, 71, 61, 53, 64, 63, 57, 45, 51, 44, 40, 33, 28, 17, 25, 20, 24, 14, 16], [41, 51, 49, 50, 47, 48, 42, 39, 32, 29, 20, 23, 23, 22, 19, 20, 17, 27, 14, 12], [39, 43, 43, 37, 34, 36, 26, 26, 20, 17, 24, 21, 18, 21, 14, 11, 23, 16, 15, 23], [32, 30, 31, 26, 25, 21, 24, 23, 18, 16, 25, 25, 20, 17, 24, 24, 13, 19, 17, 23], [63, 69, 56, 66, 51, 62, 55, 47, 48, 45, 37, 37, 30, 28, 28, 23, 28, 23, 17, 25], [29, 28, 28, 34, 25, 32, 29, 28, 27, 21, 17, 20, 19, 22, 23, 19, 25, 16, 23, 21], [22, 23, 28, 28, 22, 27, 28, 20, 24, 22, 21, 23, 24, 24, 24, 25, 26, 15, 19, 27], [70, 84, 83, 83, 78, 70, 67, 64, 77, 66, 70, 66, 55, 52, 47, 35, 30, 26, 26, 25], [45, 55, 40, 47, 42, 46, 42, 36, 37, 37, 32, 22, 17, 24, 19, 14, 21, 27, 22, 18], [31, 32, 36, 34, 24, 23, 22, 19, 21, 24, 24, 20, 22, 23, 19, 15, 15, 20, 21, 21], [23, 24, 25, 29, 28, 22, 26, 22, 19, 25, 23, 22, 24, 24, 22, 23, 19, 18, 25, 23], [83, 91, 97, 98, 91, 90, 93, 89, 89, 78, 80, 76, 65, 65, 55, 41, 36, 27, 18, 22], [70, 68, 58, 58, 66, 61, 62, 53, 48, 47, 46, 33, 18, 24, 26, 20, 17, 16, 19, 16], [46, 52, 51, 47, 39, 41, 41, 27, 32, 29, 26, 22, 25, 17, 18, 19, 21, 16, 26, 24], [34, 36, 36, 36, 32, 27, 29, 23, 21, 21, 27, 17, 13, 26, 23, 19, 20, 25, 24, 18]]} ================================================ FILE: experiments/piano-partials.ipynb ================================================ { "cells": [ { "cell_type": "code", "execution_count": 2, "id": "f3feaa02", "metadata": {}, "outputs": [], "source": [ "import numpy as np\n", "import matplotlib.pyplot as plt\n", "import scipy.signal\n", "from smstools.models import utilFunctions as UF\n", "from smstools.models import hprModel as HPR\n", "from smstools.models import stft as STFT" ] }, { "cell_type": "code", "execution_count": 309, "id": "fd2ff249", "metadata": {}, "outputs": [], "source": [ "#inputFile = '/Users/dpwe/Downloads/M1_Piano_C3.wav'\n", "inputFile = '/Users/dpwe/Downloads/track02-C4.wav'\n", "window = 'hamming'\n", "M = 1001\n", "N = 1024\n", "t = -100\n", "minSineDur = 0.1\n", "nH = 100\n", "minf0 = 100\n", "maxf0 = 700\n", "f0et = 5\n", "harmDevSlope = 0.1\n", "H = 128\n", "fs, x = UF.wavread(inputFile)\n" ] }, { "cell_type": "code", "execution_count": 310, "id": "ae53fa36-c9b6-4ca8-9b56-c362209ce8fd", "metadata": {}, "outputs": [], "source": [ "w = scipy.signal.get_window(window, M)" ] }, { "cell_type": "code", "execution_count": 311, "id": "8bb42fc3-622f-43b3-9175-09e1090c9bd6", "metadata": {}, "outputs": [], "source": [ "hfreq, hmag, hphase, xr = HPR.hprModelAnal(x, fs, w, N, H, t, minSineDur, nH, minf0, maxf0, f0et, harmDevSlope)\n" ] }, { "cell_type": "code", "execution_count": 317, "id": "a82911f6-8cf1-417c-b80a-660c5333fe5e", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "(1498, 100)\n", "0 26\n", "1 26\n", "2 26\n", "3 26\n", "4 26\n", "5 26\n", "6 26\n", "7 26\n", "8 26\n", "9 26\n" ] } ], "source": [ "print(hmag.shape)\n", "for h in range(10):\n", " initialzeros = 1 + min(np.flatnonzero(hmag[1:, h] != 0))\n", " print(h, initialzeros)" ] }, { "cell_type": "code", "execution_count": 322, "id": "bc8a0b4e-d7a3-4f36-b021-1b8c69254b77", "metadata": {}, "outputs": [], "source": [ "start_frame = 1 + min(np.flatnonzero(hmag[1:, 0] != 0))\n", "hfreq = hfreq[start_frame:, :]\n", "hmag = hmag[start_frame:, :]\n", "hphase = hphase[start_frame:, :]\n", "xr = xr[start_frame * H:]" ] }, { "cell_type": "code", "execution_count": 323, "id": "821a4fe1-565b-45ef-b8b0-885065c35452", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "0.0029024943310657597\n" ] } ], "source": [ "frmTime = H * np.arange(hfreq.shape[0]) / fs\n", "print(H/fs)" ] }, { "cell_type": "code", "execution_count": 324,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74Y2bMmPGfb5DKGU9FRQW33HILpaWlREZG0r9/f5YsWcKUKVNOd9NUVFRQ8/SrqKioqKioqKionPWoPv0qKioqKioqKioqZzmq6FdRUVFRUVFRUVE5y1FFv4qKioqKioqKispZjir6VVRUVFRUVFRUVM5yVNGvoqKioqKioqKicpajin4VFRUVFRUVFRWVsxxV9KuoqKioqKioqKic5aiiX0VFRUVFRUVFReUsRxX9KioqKioqKioqKmc5quhXUVFRUVFRUVFROctRRb+KioqKioqKiorKWc7/A/0VrhUCqPj/AAAAAElFTkSuQmCC", "text/plain": [ "
" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "plt.figure(figsize=(9,4))\n", "\n", "_ = plt.plot(frmTime, hmag)" ] }, { "cell_type": "code", "execution_count": 325, "id": "d96eb81a-5d05-4832-968b-e35a24b92dd6", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[-35.87356989 -35.75437815 -35.63138572 -35.59504185 -35.55262465\n", " -35.66215248 -35.70126739]\n" ] }, { "data": { "image/png": "iVBORw0KGgoAAAANSUhEUgAAAwgAAAFfCAYAAADqEetxAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8hTgPZAAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOydeXgb1bn/vzOyZMmKLVveZHm3szjO7sQJWRu25LY07W1IoYWS0rK0lFIClL2XEFpIKZTl3t7+WrbecqEtBXLbphsJSxqWQBJCICErTrwktrzEtpx4laX5/SFrrOWcMz6T8SLnfJ6Hh3hG55yZsSy93/NukqIoCgQCgUAgEAgEAoEAgDzaFyAQCAQCgUAgEAjGDkIgCAQCgUAgEAgEAhUhEAQCgUAgEAgEAoGKEAgCgUAgEAgEAoFARQgEgUAgEAgEAoFAoCIEgkAgEAgEAoFAIFARAkEgEAgEAoFAIBCoJIz2BYwEgUAA9fX1SE5OhiRJo305AoFAIBAIBALBW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DkeEKAofD4XA4HA6Hw5HhCgKHw+FwOBwOh8OR4QoCh8PhcDgcDofDkeEKAofD4XA4HA6Hw5HhCgKHw+FwOBwOh8OR4QoCh8PhcDgcDofDkfn/JwebZtd/F80AAAAASUVORK5CYII=", "text/plain": [ "
" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "plt.figure(figsize=(9,4))\n", "nfrm = 100\n", "harms = np.arange(20)\n", "_ = plt.plot(frmTime[:nfrm], hmag[:nfrm, harms], '.')\n", "print(hmag[23:30, 0])" ] }, { "cell_type": "code", "execution_count": 305, "id": "3f2a10ec-68ea-4a28-a108-e9e4d293662b", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[-36.11649069 -36.10783732 -36.01133083 -35.97299792 -35.82352828\n", " -35.82202464 -35.76556586]\n" ] }, { "data": { "image/png": "iVBORw0KGgoAAAANSUhEUgAAAwgAAAFfCAYAAADqEetxAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8hTgPZAAAACXBIWXMAAA9hAAAPYQGoP6dpAAD5TElEQVR4nOydeXgb1bn/vzOyLMmyLVve5H2L4+yLs5GFECCQthDahhQKLdCWQi+XtlBaWpb+CKEttEAptHRv6W0vXbiFdAktS4CyBxJIILvjxGtiy4432fEuaX5/yBpb0jlHnsnYsp338zx5Yp/ROTMja3m/590kRVEUEARBEARBEARBAJBjfQEEQRAEQRAEQUweSCAQBEEQBEEQBKFCAoEgCIIgCIIgCBUSCARBEARBEARBqJBAIAiCIAiCIAhChQQCQRAEQRAEQRAqJBAIgiAIgiAIglCJi/UFTAR+vx+NjY1ISkqCJEmxvhyCIAiCIAiCOGMURUF3dzdycnIgy8bt+58VAqGxsRH5+fmxvgyCIAiCIAiCMJyGhgbk5eUZtt5ZIRCSkpIABJ685OTkGF8NQRAEQRAEQZw5XV1dyM/PV21dozgrBEIwrCg5OZkEAkEQBEEQBDG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8N8NyEBgMBoPBYDAYDIYIEwgMBoPBYDAYDAZDhAkEBoPBYDAYDAaDIcIEAoPBYDAYDAaDwRBhAoHBYDAYDAaDwWCIMIHAYDAYDAaDwWAwRJhAYDAYDAaDwWAwGCJMIDAYDAaDwWAwGAwRJhAYDAaDwWAwGAyGCBMIDAaDwWAwGAwGQ4QJBAaDwWAwGAwGgyHy/wP8HR2D2InE0QAAAABJRU5ErkJggg==", "text/plain": [ "
" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "plt.figure(figsize=(9,4))\n", "nfrm = 100\n", "harms = np.arange(20)\n", "_ = plt.plot(frmTime[:nfrm], hmag[:nfrm, harms], '.')\n", "print(hmag[23:30, 0])" ] }, { "cell_type": "code", "execution_count": 345, "id": "57027011-5416-4bc3-bef0-9380bca1cac5", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "gap pts= 13\n", "1 5 -95.6759394757419 -67.29312852125533 [-95.67593948 -89.99937728 -84.32281509 -78.6462529 -72.96969071\n", " -67.29312852]\n", "14 15 -63.08312297032608 -63.64564259062086 [-63.08312297 -63.36438278 -63.64564259]\n", "385 386 -84.14279598769993 -84.86145226400278 [-84.14279599 -84.50212413 -84.86145226]\n", "539 540 -93.16739575413963 -92.96213625036776 [-93.16739575 -93.064766 -92.96213625]\n", "543 544 -92.84918199222236 -92.84107881666823 [-92.84918199 -92.8451304 -92.84107882]\n", "601 602 -96.02129230774719 -94.59367647879212 [-96.02129231 -95.30748439 -94.59367648]\n", "614 615 -97.03655381632625 -96.27676149098369 [-97.03655382 -96.65665765 -96.27676149]\n", "618 619 -96.49443157880766 -95.49824232942824 [-96.49443158 -95.99633695 -95.49824233]\n", "622 623 -96.0680696584656 -96.3327623756881 [-96.06806966 -96.20041602 -96.33276238]\n", "676 677 -96.6318706913761 -96.58321217258334 [-96.63187069 -96.60754143 -96.58321217]\n" ] }, { "data": { "image/png": "iVBORw0KGgoAAAANSUhEUgAAAioAAAGdCAYAAAA8F1jjA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7Z86darVs2dPa+PGjVZpaam1ePFiKzEx0Vq1alW0mmVLpG3fsmWL9eCDD1ovvviilZ2dXed/z5GeM1bcaPvIkSOt4uJia+fOndb27dutf/zHf7S6du1qHT9+3OXWRM6N9p97bPfu3a3LL7/cuv/++91pwHlaTFC5+uqrrYKCguDzs2fPWp06dbKKiorqPP6nP/2pNWrUqJDXBg0aZP3iF7+wLMuyqqurrezsbGvBggXB9//6179aXq/XevHFF11oQeM53fa6bNmyxZJkffXVV84U7SC32v/1119bnTt3tnbu3Gl169bNyKDiRtsnTJhg/fznP3enYIe50f6+fftac+fODTmmf//+1sMPP+xg5U0XadvPVd9/z005ZzS50fbzHTlyxJJkvf32200p1RVutf/YsWPWxRdfbJWUlFhDhw6NWlBpEUM/p06d0kcffaThw4cHX0tISNDw4cO1efPmOr9n8+bNIcdL0siRI4PHl5aWqry8POQYn8+nQYMG1XvOWHCj7XXx+/3yeDxKT093pG6nuNX+6upqTZw4UTNmzFDfvn3dKb6J3Gh7dXW11q1bp0suuUQjR45UVlaWBg0apFdeecW1djSWW7/7wYMHa/Xq1Tp06JAsy9LGjRu1Z88ejRgxwp2GNEJj2h6Lc7ohWnX6/X5JUvv27R07pxPcbH9BQYFGjRp1wf8jbmsRQaWyslJnz55Vx44dQ17v2LGjysvL6/ye8vLysMfXfo3knLHgRtvP97e//U0zZ87Uv/7rvxq3mZdb7X/iiSeUlJSk++67z/miHeJG248cOaLjx49r/vz5uvHGG/X666/rn/7pnzR+/Hi9/fbb7jSkkdz63T/77LPq06ePunTpouTkZN1444167rnndN111znfiEZqTNtjcU43RKPO6upqTZs2Tddee60uu+wyR87pFLfav3z5cm3btk1FRUVNLTFicb97MmLr9OnT+ulPfyrLsvQ///M/sS4nKj766CM988wz2rZtmzweT6zLiarq6mpJ0k033aQHHnhAkvSjH/1ImzZt0qJFizR06NBYlhcVzz77rD744AOtXr1a3bp10zvvvKOCggJ16tQp6v/SRGwUFBRo586deu+992JdSlQcPHhQ999/v0pKSpSSkhL1n98ielQyMjKUmJioioqKkNcrKiqUnZ1d5/dkZ2eHPb72ayTnjAU32l6rNqR89dVXKikpMa43RXKn/e+++66OHDmirl27KikpSUlJSfrqq680ffp0de/e3ZV2NIYbbc/IyFBSUpL69OkTcszf/d3fGXfXjxvtP3nypB566CEtXLhQY8aM0eWXX657771XEyZM0G9+8xt3GtIIjWl7LM7pBrfrvPfee7V27Vpt3LhRXbp0afL5nOZG+z/66CMdOXJE/fv3D/7Ne/vtt/Xf//3fSkpK0tmzZ50ovV4tIqgkJydrwIABevPNN4OvVVdX680331R+fn6d35Ofnx9yvCSVlJQEj+/Ro4eys7NDjgkEAvrwww/rPWcsuNF26YeQsnfvXr3xxhvq0KGDOw1oIjfaP3HiRH366afavn178NGpUyfNmDFDr732mnuNiZAbbU9OTtbAgQMvuC1zz5496tatm8MtaBo32n/69GmdPn1aCQmhfzoTExODvU0maEzbY3FON7hVp2VZuvfee/V///d/2rBhg3r06OFEuY5zo/3XX3+9duzYEfI376qrrtLPfvYzbd++XYmJiU6VX7eoTNk1wPLlyy2v12u98MIL1l/+8hfrzjvvtNLT063y8nLLsixr4sSJVmFhYfD4999/30pKSrJ+85vfWJ999pk1Z86cOm9PTk9Pt1atWmV9+umn1k033WTs7clOtv3UqVPW2LFjrS5duljbt2+3ysrKgo+qqqqYtDEcN3735zP1rh832r5y5UqrVatW1u9//3tr79691rPPPmslJiZa7777btTb1xA32j906FCrb9++1saNG60vv/zSKi4utlJSUqzf/e53UW9fOJG2vaqqyvr444+tjz/+2MrJybEefPBB6+OPP7b27t1r+5ymcKPtd999t+Xz+ay33nor5G/eiRMnot6+hrjR/vNF866fFhNULMuynn32Watr165WcnKydfXVV1sffPBB8L2hQ4dakydPDjn+pZdesi655BIrOTnZ6tu3r7Vu3bqQ96urq61HH33U6tixo+X1eq3rr7/e+vzzz6PRlIg52fbS0lJLUp2PjRs3RqlFkXH6d38+U4OKZbnT9ueff97q1auXlZKSYl1xxRXWK6+84nYzGs3p9peVlVlTpkyxOnXqZKWkpFiXXnqp9dRTT1nV1dXRaE5EIml7ff9fDx061PY5TeJ02+v7m1dcXBy9RkXAjd/9uaIZVDyWZVnu9tkAAAA0TouYowIAAOITQQUAABiLoAIAAIxFUAEAAMYiqAAAAGMRVAAAgLEIKgAAwFgEFQAAYCyCCgAAMBZBBQAAGIugAgAAjEVQAQAAxvp/eBSgNMmyK3sAAAAASUVORK5CYII=", "text/plain": [ "
" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "def lin_fit(x):\n", " \"\"\"Least-squares linear fit to points.\"\"\"\n", " # xhat = a + b.index\n", " # err = x[i] - (a + b.i)\n", " # err^2 = x[i]^2 - 2 x[i] (a + b.i) + (a^2 + 2 a b i +b^2 i^2)\n", " # Define axes around midpoint.\n", " lenx = len(x)\n", " if not lenx:\n", " return []\n", " index = np.arange(lenx) - (lenx - 1) / 2\n", " # Make x zero mean\n", " a = np.mean(x)\n", " x_z = x - a\n", " b = 0\n", " if lenx > 1:\n", " # Linear fit is normalized inner product\n", " b = np.sum(x_z * index) / np.sum(index * index)\n", " return a + b * index\n", "\n", "def fit_2_segs(x):\n", " \"\"\"Fit x with 2 linear segments, searching all divisions.\"\"\"\n", " # Try every poss division of remainder.\n", " besterr = np.sum(np.abs(x))\n", " besterrpt = 0\n", " bestxhat = []\n", " bestseg1 = []\n", " bestseg2 = []\n", " for divpt in np.arange(0, len(x)):\n", " seg1 = lin_fit(x[:divpt + 1])\n", " seg2 = lin_fit(x[divpt:])\n", " xhat = np.hstack([seg1[:-1], seg2])\n", " abserr = np.sum(np.abs(xhat - x))\n", " if abserr < besterr:\n", " besterr = abserr\n", " besterrpt = divpt\n", " bestseg1 = seg1\n", " bestseg2 = seg2\n", " bestxhat = xhat\n", " # Parameterization is [value, interval, value interval, value...]\n", " parameters = [bestseg1[0], len(bestseg1), 0.5 * (bestseg1[-1] + bestseg2[0]), len(bestseg2), bestseg2[-1]]\n", " #print(bestseg1, bestseg2, parameters)\n", " #print(\"parameters=\", parameters)\n", " return bestxhat, parameters\n", "\n", "def expand_params(params):\n", " \"\"\"Convert [val, npts, val, npts, val] sequence to points.\"\"\"\n", " val0 = params[0]\n", " outpts = [[val0]]\n", " npts_val_pairs = np.vstack([params[1::2], params[2::2]])\n", " for npts, val in npts_val_pairs.transpose():\n", " outpts.append(np.linspace(val0, val, int(npts))[1:])\n", " val0 = val\n", " return np.concatenate(outpts)\n", " \n", "\n", "def median(x):\n", " npts2 = (len(x) - 1) // 2\n", " return np.sort(x)[npts2]\n", "\n", "def median_filter(x, npts):\n", " npts2 = (npts - 1) // 2\n", " padded_x = np.hstack([x[0] * np.ones(npts2), x, x[-1] * np.ones(npts2)])\n", " y = np.zeros_like(x)\n", " for i in range(len(x)):\n", " y[i] = median(padded_x[i : i + npts])\n", " return y\n", "\n", "def linseg_fit(x):\n", " \"\"\"Approximate sequence x as a set of line segments.\"\"\"\n", " # Start with onset slope\n", " maxpt = np.argmax(x)\n", " #print(\"maxpt=\", maxpt)\n", " initial, i_params = fit_2_segs(x[:maxpt + 1])\n", " tail, t_params = fit_2_segs(x[maxpt:])\n", " params = i_params[:-1] + [0.5 * (i_params[-1] + t_params[0])] + t_params[1:]\n", " #print(initial.shape, tail.shape)\n", " #print(params)\n", " return np.hstack([initial, tail[1:]]), expand_params(params), params\n", "\n", "def fill_gaps(x):\n", " \"\"\"Bridge parts of x that are nan with linear interpolation.\"\"\"\n", " gaps = np.isnan(x)\n", " x_out = np.array(x)\n", " gap_starts = np.flatnonzero(np.logical_and(gaps, np.hstack([[1], 1 - gaps[:-1]])))\n", " gap_ends = np.flatnonzero(np.logical_and(1 - np.hstack([gaps, [0]]), np.hstack([[0], gaps])))\n", " #print(gap_starts, gap_ends)\n", " for gap_start, gap_end in zip(gap_starts, gap_ends):\n", " if gap_start == 0:\n", " start_val = x[gap_end]\n", " else:\n", " start_val = x[gap_start - 1]\n", " if gap_end == len(x):\n", " end_val = x[gap_start - 1]\n", " else:\n", " end_val = x[gap_end]\n", " fill = np.linspace(start_val, end_val, gap_end - gap_start + 2)\n", " print(gap_start, gap_end, start_val, end_val, fill)\n", " x_out[gap_start:gap_end] = fill[1:-1]\n", " return x_out\n", " \n", "def mend_gaps(x, threshold=2, filter_len=9):\n", " \"\"\"Interpolate portions of x that are too wide.\"\"\"\n", " gaps = np.flatnonzero(np.isnan(x))\n", " x_patched = fill_gaps(x)\n", " smoothed = median_filter(x_patched, filter_len)\n", " delta = np.abs(x_patched - smoothed)\n", " x_patched[np.flatnonzero(delta > threshold)] = np.nan\n", " x_patched[gaps] = np.nan\n", " print(\"gap pts=\", np.sum(np.isnan(x_patched)))\n", " return fill_gaps(x_patched)\n", " #return smoothed\n", "\n", "hnum = 10\n", "analysis_time = 2.0\n", "nfrm = int(analysis_time * fs/H) # ~300 analysis_time\n", "hh = np.array(hmag[:nfrm, hnum])\n", "hh[np.flatnonzero(hh == 0)] = np.nan\n", "#hh = median_filter(hh, 3)\n", "\n", "npts = 50\n", "_ = plt.plot(frmTime[:npts], hh[:npts] + 2, '.', frmTime[:npts], mend_gaps(hh)[:npts], '.')\n", "\n", "if False:\n", " xhat, xhat2, params = linseg_fit(median_filter(hh, 5))\n", " #print(xhat.shape, xhat2.shape)\n", " \n", " plt.figure(figsize=(9, 4))\n", " _ = plt.plot(frmTime[:nfrm], hh, '.', frmTime[:nfrm], xhat, '.', frmTime[:nfrm], xhat2, '.')\n", " print(np.sum(np.isnan(hh)))\n", " maxval = np.max(hh[np.flatnonzero(np.isnan(hh) == 0)])\n", " print(maxval)\n", " plt.ylim([maxval - 25, maxval + 5])" ] }, { "cell_type": "code", "execution_count": 277, "id": "bb7428f9-e060-4f41-8ad1-4b8ab43a578e", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "nan\n", "0 1 1.0 1.0 [1. 1. 1.]\n", "2 4 1.0 4.0 [1. 2. 3. 4.]\n", "7 8 6.0 8.0 [6. 7. 8.]\n", "9 10 8.0 8.0 [8. 8. 8.]\n", "[1. 1. 2. 3. 4. 5. 6. 7. 8. 8.]\n", "[1.] [4. 5.]\n" ] } ], "source": [ "x = np.arange(10, dtype=np.float32)\n", "x[2] = np.nan\n", "x[3] = np.nan\n", "x[7] = np.nan\n", "x[9] = np.nan\n", "x[0] = np.nan\n", "print(x[-1])\n", "print(fill_gaps(x))\n", "print(x[1:2], x[4:6])\n" ] }, { "cell_type": "code", "execution_count": 356, "id": "7eeb6d86-52bf-4467-b4b5-13ca96243bbb", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[ 100. 316.22776602 1000. ]\n", "h 1 [[0, 0.03646117968209008], (17, 1.4790503289019412), (116, 1.7464818747653081), (1364, 0.32805053827525693), (511, 0.1609264966801982), (2207, 0.0009999999999999998)]\n", "h 2 [[0, 0.0012634508047348386], (9, 0.21596971199840045), (32, 2.404807458377003), (729, 0.5502459191358052), (1239, 0.03756845077976835), (1575, 0.0009999999999999998)]\n", "h 3 [[0, 0.01254349241718219], (15, 0.15099185596710532), (26, 0.3421051478156847), (804, 0.051061292632147516), (1164, 0.0047740936634367475), (679, 0.0009999999999999998)]\n", "h 4 [[0, 0.004250878808238577], (9, 0.057457146712061244), (32, 0.5554119700653773), (1434, 0.018122634597003563), (534, 0.025025024003812353), (1398, 0.0009999999999999998)]\n", "h 5 [[0, 0.0009999999999999998], (6, 0.01816626570185348), (20, 0.08438815335232426), (624, 0.006071196966144399), (1358, 0.002903916392093575), (463, 0.0009999999999999998)]\n", "h 6 [[0, 0.002161710338513421], (12, 0.15650724904503518), (20, 0.5925248800917347), (1245, 0.011559939842952675), (731, 0.015835095979827792), (1200, 0.0009999999999999998)]\n", "h 7 [[0, 0.0023404483051654946], (15, 0.08542249910042937), (17, 0.1666895668496017), (853, 0.0021358280107708454), (1123, 0.0033970486787507984), (531, 0.0009999999999999998)]\n", "h 8 [[0, 0.0020843732849860934], (17, 0.12346736808924237), (29, 0.18170621956830013), (1016, 0.010201883691495973), (946, 0.005236696363962163), (719, 0.0009999999999999998)]\n", "h 9 [[0, 0.0030655166217990527], (17, 0.13600540298075547), (64, 0.1831798098530581), (641, 0.014173570743211048), (1286, 0.0019437161448920615), (289, 0.0009999999999999998)]\n", "h 10 [[0, 0.00479559610080011], (29, 0.06072650347041644), (61, 0.0798317372027684), (816, 0.0046354272307415414), (1103, 0.003714921017812922), (570, 0.0009999999999999998)]\n", "h 11 [[0, 0.002712805431040445], (20, 0.058009604750650895), (17, 0.07063250568468678), (746, 0.008931881841216528), (1225, 0.001201477179802048), (80, 0.0009999999999999998)]\n", "h 12 [[0, 0.0011411701775337058], (9, 0.01821003171882191), (20, 0.07124145242041195), (795, 0.006330355307626967), (1184, 0.002254072162494906), (353, 0.0009999999999999998)]\n", "h 13 [[0, 0.0012512680959778542], (9, 0.012546514343345075), (9, 0.01494232149421479), (746, 0.0020352720499251602), (1245, 0.0021786470499486742), (338, 0.0009999999999999998)]\n", "h 14 [[0, 0.0009952115977475834], (12, 0.022746594188342958), (110, 0.03291419108007345), (139, 0.006637951769233443), (1747, 0.0007961189128058337)]\n", "h 15 [[0, 0.0008774321388499404], (12, 0.010222851979210086), (20, 0.013301383595068267), (572, 0.0028869457800665983), (1405, 0.0008797187781985485)]\n", "h 16 [[0, 0.0009241395135334805], (12, 0.017513958907860068), (9, 0.006637052937096589), (853, 0.00367677018607421), (1135, 0.0010606068054344045), (26, 0.0009999999999999998)]\n", "h 17 [[0, 0.0009050618790137055], (15, 0.029306767939208236), (23, 0.01078682206955967), (827, 0.003994973109065478), (1144, 0.0009003742241215998)]\n", "h 18 [[0, 0.0012493200902472551], (26, 0.01674550900239793), (29, 0.01147113903438373), (232, 0.0032622576962070475), (1721, 0.00103090043200766), (13, 0.0009999999999999998)]\n", "h 19 [[0, 0.001157202173287927], (17, 0.024463638969512314), (17, 0.027302180375823496), (906, 0.0012095650014134092), (1068, 0.0008644430911523587)]\n", "h 20 [[0, 0.0029782923681902418], (223, 0.0026139493226257425), (168, 0.0015766931903501277), (842, 0.0011388221206957768), (775, 0.0009999999999999998)]\n" ] } ], "source": [ "# Convert sinusoids into bp sets\n", "\n", "SCALEUP = 100.0\n", "\n", "def lin_of_db(dbval):\n", " return SCALEUP * np.exp(np.log(10) * dbval / 20.0)\n", "\n", "def db_of_lin(linval):\n", " return 20.0 * np.log10(linval / SCALEUP)\n", "\n", "print(lin_of_db(np.array([0, 10 ,20])))\n", "\n", "analysis_time = 2.0\n", "dt = H / fs\n", "nfrm = int(analysis_time / dt) # 300 * analysis_time\n", "\n", "harms_params = {}\n", "\n", "max_harmonic = 20\n", "\n", "for hnum in range(max_harmonic):\n", " x = hmag[:nfrm, hnum]\n", " x[np.flatnonzero(x == 0)] = np.nan\n", " xhat, xhat2, params = linseg_fit(median_filter(x, 5))\n", " #print(xhat.shape, xhat2.shape)\n", " val0 = params[0]\n", " nvals = zip(params[1::2], params[2::2])\n", " bp_list = [[0, lin_of_db(params[0])]] + [(int(round(n * dt * 1000)), lin_of_db(val)) for n, val in nvals]\n", " last_time, last_mag = bp_list[-1]\n", " last_mag_db = db_of_lin(last_mag)\n", " final_mag_db = -100.0\n", " if last_mag_db > final_mag_db:\n", " terminal_slope = 20.0 # -db/sec\n", " final_dur = (last_mag_db - final_mag_db) / terminal_slope\n", " bp_list.append((int(round(1000*final_dur)), lin_of_db(final_mag_db)))\n", " print(\"h\", hnum + 1, bp_list)\n", " harms_params[hnum + 1] = bp_list\n", " " ] }, { "cell_type": "code", "execution_count": 362, "id": "2cdc7dde-c1a7-4d84-82cb-0d2af75e130d", "metadata": {}, "outputs": [ { "data": { "image/png": "iVBORw0KGgoAAAANSUhEUgAABM4AAAH/CAYAAACvl5H6AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8hTgPZAAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOzdeViU5ffH8fczw44wIiCgLO67pmIqmvuCWqmZbVZmmUuZlmuaX5fqV5aaS2am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nz+fxsZGvvzyS1555RVWrFjBgw8+6GzTF9bs32Y6W48oG/Y+vK21lC2bkYpOmThxorzrrruc7+12u0xISJCPPPKIx/Y/+MEP5Pz58122TZo0Sd5xxx3ndJw9RVfn+/LLL0uLxXKeRnfuAOS7777bYZtf/OIXctiwYS7brr32WpmVlXUOR3bu8GXO69atk4AsLy8/L2M6l5SUlEhArl+/3mub3n7/tsWX+faV+7eF8PBw+eKLL3rc15ds25aO5twX7FtdXS0HDRoks7Oz5UUXXSTvuecer237qo0VF4aurocU55f2axhd12VcXJx8/PHHndsqKiqkyWSSb7zxhpRSyn379klAbt261dnmk08+kUIIeerUKSmllH/9619leHi4bGhocLZ54IEHZHp6+jme0XeT9muViooK6efnJ9966y1nm/3790tAbt68WUop5ccffyw1TZNFRUXONn/7299kaGio0259bc3eG2hZjygb9j68rbWULVtRHmed0NjYyPbt25kzZ45zm6ZpzJkzh82bN3s8ZvPmzS7tAbKysry2/zZxNvMFqKmpoX///iQlJXXq/dCb6c227S6jR48mPj6euXPn8sUXX1zo4ZwVlZWVAERERHht05ds7Mt8oW/cv3a7nTfffBOr1UpmZqbHNn3JtuDbnKH32/euu+5i/vz5brbzRF+zseLCcbbrIcWF49ixYxQVFbnYzGKxMGnSJKfNNm/eTFhYGOPHj3e2mTNnDpqmsWXLFmebGTNm4O/v72yTlZXFwYMHKS8vP0+z+e7Qfq2yfft2mpqaXOw4ZMgQkpOTXew4YsQIYmNjnW2ysrKoqqpy/o5Tvw/OH+3XI8qGvQ9vay1ly1aUcNYJpaWl2O12lw8CQGxsrNccT0VFRV1q/23ibOabnp7OP/7xD95//31ef/11dF1nypQpnDx58nwM+bzizbZVVVXU1dVdoFGdW+Lj43nuued45513eOedd0hKSmLmzJns2LHjQg+tS+i6ztKlS5k6dSrDhw/32q43379t8XW+vf3+3b17N8HBwZhMJpYsWcK7775LRkaGx7Z9xbZdmXNvt++bb77Jjh07eOSRR3xq31dsrLjwnM16SHFhabFLRzYrKipySzVhNBqJiIhw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UKhUCgUCoVCoVAoFAoPKOFMoVAoFAqFQqFQKBQKhUKh8IASzhQKhUKhUCgUCoVCoVAoFAoPKOFMoVAoFAqFQqFQKBQKhUKh8IASzhQKhUKhUCgUCoVCoVAoFAoPKOFMoVAoFAqFQqFQKBQKhUKh8IASzhQKhUKhUCgUCoVCoVAoFAoP/H++RBqezZlWHgAAAABJRU5ErkJggg==", "text/plain": [ "
" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "plt.figure(figsize=(15, 6))\n", "plt.subplot(1,2,1)\n", "nfrm = int(2 * analysis_time / dt) # 300 * analysis_time\n", "harms = np.arange(20)\n", "_ = plt.plot(frmTime[:nfrm], hmag[:nfrm, harms], '.')\n", "plt.ylim([-100, -30])\n", "\n", "plt.subplot(1,2,2)\n", "for i in range(len(harms_params)):\n", " hnum = i + 1\n", " times, vals = zip(*np.array(harms_params[hnum]))\n", " times = np.cumsum(times)\n", " vals = np.array(vals)\n", " plt.plot(times, db_of_lin(vals))" ] }, { "cell_type": "code", "execution_count": 358, "id": "f6f120e8-d3a0-4aec-bc41-8f7dcfd012b2", "metadata": {}, "outputs": [], "source": [ "import json\n", "params_file = 'track02-C4-bps.json'\n", "with open(params_file, 'w') as f:\n", " f.write(json.dumps(harms_params))" ] }, { "cell_type": "code", "execution_count": 360, "id": "57ac32b2-5880-4084-8318-2de9542e691b", "metadata": {}, "outputs": [], "source": [ "#UF.wavwrite(SCALEUP * xr, fs, 'track02-C4-resid.wav')\n", "UF.wavwrite(xr, fs, 'track02-C4-resid.wav')" ] }, { "cell_type": "code", "execution_count": 401, "id": "7edbbbfd-0016-4319-802a-bac7d9c2e9bc", "metadata": {}, "outputs": [], "source": [ "# Look at frequencies of harmonics - are they slightly inharmonic?" ] }, { "cell_type": "code", "execution_count": 384, "id": "8222c865-0ca9-4757-9d99-e301809ce839", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "" ] }, "execution_count": 384, "metadata": {}, "output_type": "execute_result" }, { "data": { "image/png": "iVBOR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abb0SPHj3ESy+9JH788Ufx9NNPi549e4qysjJPFcEmR8v37LPPii+++EJUVFSI4uJicf/994uAgADxww8/eKoINl26dEkcPHhQHDx4UAAQL7/8sjh48KA4efKkEEKIJUuWiFmzZunTHz9+XAQFBYlFixaJH3/8Uaxdu1YolUqxfft2TxXBJkfL98orr4jNmzeLo0ePirKyMrFgwQKhUCjEV1995aki2DRv3jyhUqnEzp07RU1Njf7R1NSkT+Ptn0FnyuhNn8MlS5aIoqIiUVlZKQ4dOiSWLFkiJEkSX375pRDC+6+fEI6X0ZuunzWmo3jkcB27XYAihBCvvfaaSEhIEH5+fmL06NFi3759+tduu+02MWfOHKP0H330kRg0aJDw8/MTw4YNE5999pmbc+wYR8qXl5enTxsdHS3uuusuUVJS4oFc26d9WK3po71Mc+bMEbfddpvZPiNGjBB+fn5iwIABYt26dW7Pt70cLd9f/vIXkZycLAICAkRERITIzMwUhYWFnsm8HSyVDYDRNfH2z6AzZfSmz+GDDz4oEhMThZ+fn+jTp4+YMGGC/sYthPdfPyEcL6M3XT9rTAMUOVxHSQghXFc/Q0REROS4btUHhYiIiLwDAxQiIiKSHQYoREREJDsMUIiIiEh2GKAQERGR7DBAISIiItlhgEJERESywwCFiIiIZIcBChEREckOAxQiIiKSHQYoREREJDv/H+Ga6NaFIxDpAAAAAElFTkSuQmCC", "text/plain": [ "
" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "nharms = 12\n", "_ = plt.plot(frmTime[:nfrm], hfreq[:nfrm, np.arange(nharms)] / (np.arange(nharms) + 1)[np.newaxis, :], '.')\n", "plt.ylim([240, 275])\n", "plt.legend(np.arange(nharms) + 1)" ] }, { "cell_type": "code", "execution_count": 400, "id": "ac358412-131d-43df-a5d4-1c4f2ebdf63c", "metadata": {}, "outputs": [ { "data": { "image/png": "iVBORw0KGgoAAAANSUhEUgAAAjUAAAGdCAYAAADqsoKGAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMiwgaH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zZs354477mDTpk2296SnpxMUFGQLNACDBg3Cw8ODrVu3VnicjIwMSkpKGDRokG1du3btaNmyJenp6RW+p7i4mLy8PLuXiIhIXRMe6EviqE54WszbKRdDR032dxkT3ZJNT/fn3Um3sunp/i4TaBxV7Y7CVquVqVOn0rdvXzp27AjA999/D8DMmTN54YUX6Nq1K4sWLWLgwIFkZmZy4403kpOTQ2hoqH0RDRoQHBxMTk5OhcfKycnB29uboKAgu/XNmzev9D2JiYnMmjWruqcnIiJyzYyJbknMTc04cKqA1k0b1UoH3vBAX7frGPxz1b5TExcXR2ZmJkuWLLGts1qtADz66KM8/PDDdOvWjZdeeom2bdsyf/78q6/WAdOnTyc3N9f2Onz48DU9voiIiCPCA33p3SbE7YNHbarWnZr4+HhbB98WLVrY1oeHhwPQoUMHu/bt27fn0KFDAISFhXHixAm77aWlpZw+fZqwsLAKjxcWFsb58+c5c+aM3d2a48ePV/oeHx8ffHx8HD43ERERcU0O3akxDIP4+HhWrlxJamoqUVFRdttbt25NREREuce8v/32W1q1agVA7969OXPmDBkZGbbtqampWK1WevXqVeFxe/TogZeXF+vWrbOty8rK4tChQ/Tu3duRUxARERE35dCdmri4OJKTk1m1ahX+/v62/iyBgYH4+vpisVh48sknmTFjBl26dKFr1668/fbb7Nmzh+XLlwPmXZshQ4YwadIkXn/9dUpKSoiPj+f++++3Pfl09OhRBg4cyKJFi+jZsyeBgYFMnDiRadOmERwcTEBAAFOmTKF3795X9OSTiIiIuD+HQs28efMA6Nevn936BQsWMGHCBACmTp1KUVERCQkJnD59mi5dupCSkkKbNm1s7d955x3i4+MZOHAgHh4ejB49mn/84x+27SUlJWRlZVFQcOkZ/ZdeesnWtri4mMGDB/Paa685er4iIiLipq5qnBpXonFqREREXM81G6dGREREpK5QqBERERG3oFAjIiIibkGhRkRERNyCQo2IiIi4BYUaERERcQsKNSIiIuIWFGpERETELSjUiIiIiFtQqBERERG3oFAjIiIibkGhRkRERNyCQo2IiIi4BYUaERERcQsKNSIiIuIWF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AOvpZqCuGDBnCokWLWLduHX/9619JS0tj6NChlJWVVdjeXa4rwNtvv42/v/9lv5Kp69e2ot81OTk5eHt7lwviVV2n6nzOq6PezNLtbuLi4sjMzLzsd6+9e/emd+/etuU+ffrQvn173njjDf70pz/VdplXZejQobafO3fuTK9evWjVqhXvvffeFf3rx1UlJSUxdOhQIiIiKm3jytdVTCUlJdx3330YhsG8efOqbOuqn4X777/f9nOnTp3o3Lkzbdq0YcOGDQwcONCJldW++fPnM3bs2Mt24K/r1/ZKf9fUFbpT44Li4+NZvXo169evp0WLFg6918vLi27durF3795aqq72BAUFcdNNN1Vae1hYWLne98ePHycsLOxalFcjDh48yNq1a3nkkUccep8rX9eL18eRa9e0aVM8PT1d9npfDDQHDx4kJSWlyrs0FbncZ6Guuv7662natGmldbv6db3os88+Iysry+HPMdSta1vZ75qwsDDOnz/PmTNn7NpXdZ2q8zmvDoUaF2IYBvHx8axcuZLU1FSioqIc3kdZWRlff/014eHhtVBh7Tp37hz79u2rtPbevXuzbt06u3UpKSl2dzTqugULFhAaGsrw4cMdep8rX9eoqCjCwsLsrl1eXh5bt26t9Np5e3vTo0cPu/dYrVbWrVtX56/3xUDz3XffsXbtWkJCQhzex+U+C3XVkSNH+OGHHyqt25Wv608lJSXRo0cPunTp4vB768K1vdzvmh49euDl5WV3nbKysjh06FCl16k6n/PqFi8u4vHHHzcCAwONDRs2GNnZ2bZXQUGBrc2vfvUr4+mnn7Ytz5o1y/j000+Nffv2GRkZGcb9999vNGzY0Ni1a5czTsEhv/vd74wNGzYY+/fvNz7//HNj0KBBRtOmTY0TJ04YhlH+XD///HOjQYMGxgsvvGB88803xowZMwwvLy/j66+/dtYpOKSsrMxo2bKl8dRTT5Xb5urX9ezZs8aXX35pfPnllwZgvPjii8aXX35pe+Jnzpw5RlBQkLFq1Spj586dxt13321ERUUZhYWFtn0MGDDAeOWVV2zLS5YsMXx8fIyFCxcau3fvNiZPnmwEBQUZOTk51/z8fqqqcz1//rwxYsQIo0WLFsaOHTvsPsfFxcW2ffz8XC/3WXCWqs717Nmzxu9//3sjPT3d2L9/v7F27Vqje/fuxo033mgUFRXZ9uEq19UwLv/n2DAMIzc312jUqJExb968CvfhCtf2Sn7XPPbYY0bLli2N1NRU43//+5/Ru3dvo3fv3nb7adu2rbFixQrb8pV8zq+WQo0LASp8LViwwNbmjjvuMB566CHb8tSpU42WLVsa3t7eRvPmzY1hw4YZX3zxxbUvvhrGjBljhIeHG97e3sZ1111njBkzxti7d69t+8/P1TAM47333jNuuukmw9vb27j55puNjz766BpXXX2ffvqpARhZWVnltrn6dV2/fn2Ff3YvnpPVajWee+45o3nz5oaPj48xcODAcv8fWrVqZcyYMcNu3SuvvGL7/9CzZ09jy5Yt1+iMKlfVue7fv7/Sz/H69ett+/j5uV7us+AsVZ1rQUGBERsbazRr1szw8vIyWrVqZUyaNKlcOHGV62oYl/9zbBiG8cYbbxi+vr7GmTNnKtyHK1zbK/ldU1hYaPzmN78xmjRpYjRq1Mi45557jOzs7HL7+el7ruRzfrUsFw4sIiIi4tLUp0ZERETcgkKNiIiIuAWFGhEREXELCjUiIiLiFhRqRERExC0o1IiIiIhbUKgRERERt6BQIyIiIm5BoUZERETcgkKNiIiIuAWFGhEREXELCjUiIiLiFv4/aanS/I3JclkAAAAASUVORK5CYII=", "text/plain": [ "
" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "nharms = 20\n", "lfrm = 20\n", "hfrm = 120\n", "_ = plt.plot(np.arange(nharms) + 1, np.mean(hfreq[lfrm:hfrm, np.arange(nharms)] / (np.arange(nharms) + 1)[np.newaxis, :], axis=0), '.')\n", "hnums = np.arange(nharms) + 1\n", "# Slight quadratic term to harmonic frequencies\n", "_ = plt.plot(hnums, 261.8 + 0.038 * hnums*hnums)" ] }, { "cell_type": "code", "execution_count": null, "id": "c64c448a-6cf2-41be-bcbc-8d24108e192e", "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.12.6" } }, "nbformat": 4, "nbformat_minor": 5 } ================================================ FILE: experiments/piano_examples.py ================================================ import sys import os import numpy as np import scipy.io.wavfile as wav import amy from experiments import tulip_piano import scipy.io.wavfile as wav def wavwrite(filename, data, samplerate=44100, force_mono=True): """Write a waveform to a WAV file.""" if force_mono and len(data.shape) > 1: data = np.mean(data, axis=-1) wav.write(filename, samplerate, (32768.0 * data).astype(np.int16)) def piano_example(base_note=72, filename='piano_examples.wav', volume=5, send_command=amy.send, init_command=lambda: None): amy.restart() amy.send(time=0, volume=volume) #amy.send(time=0, voices="0,1,2,3", load_patch=patch_num) init_command() send_command(time=50, voices="0", note=base_note, vel=0.05) send_command(time=435, voices="0", note=base_note, vel=0) send_command(time=450, voices="0", note=base_note, vel=0.63) send_command(time=835, voices="0", note=base_note, vel=0) send_command(time=850, voices="0", note=base_note, vel=1.0) send_command(time=1485, voices="0", note=base_note, vel=0) send_command(time=1500, voices="1", note=base_note - 24, vel=0.6) send_command(time=2100, voices="2", note=base_note + 24, vel=1.0) send_command(time=3000, voices="1", note=base_note - 24, vel=0) send_command(time=3000, voices="2", note=base_note + 24, vel=0) samples = amy.render(3.3) #amy.write(samples, filename) wavwrite(filename, samples) print('Wrote', len(samples), 'samples to', filename) def init_piano_voices(): amy.send(store_patch='1024,' + tulip_piano.patch_string) amy.send(time=0, voices='0,1,2', load_patch=1024) tulip_piano.init_piano_voice(tulip_piano.num_partials, voices='0,1,2', time=0) # additive_interpolated overwrites these settings before each note, # but pre-configure each note to C4.mf for additive_fixed. tulip_piano.setup_piano_voice_for_note_vel(note=60, vel=80, voices='0,1,2') def main(argv): piano_example(base_note=74, volume=10, filename='piano_example_juno_patch_7.wav', init_command=lambda: amy.send(time=0, voices='0,1,2', load_patch=7)) piano_example(base_note=50, volume=25, filename='piano_example_dx7_patch_137.wav', init_command=lambda: amy.send(time=0, voices='0,1,2', load_patch=137)) piano_example(base_note=62, volume=5, filename='piano_example_additive_fixed.wav', init_command=init_piano_voices) piano_example(base_note=62, filename='piano_example_additive_interpolated.wav', init_command=init_piano_voices, send_command=tulip_piano.piano_note_on) print("done.") if __name__ == "__main__": main(sys.argv) ================================================ FILE: experiments/piano_heterodyne.ipynb ================================================ { "cells": [ { "cell_type": "code", "execution_count": null, "id": "11018e82-afc7-4937-8914-a23d5286f656", "metadata": {}, "outputs": [], "source": [ "!pip3 install matplotlib --break-system-packages" ] }, { "cell_type": "code", "execution_count": null, "id": "005e6c38-f394-45b7-b890-ed1b72bf3995", "metadata": {}, "outputs": [], "source": [ "import os\n", "import time\n", "\n", "import matplotlib.pyplot as plt\n", "import numpy as np\n", "import scipy.io.wavfile as wav\n", "import scipy.signal\n", "\n", "from IPython.display import Audio\n" ] }, { "cell_type": "markdown", "id": "ae1158c3-aa77-4c23-a93d-f0a4854ac6c2", "metadata": {}, "source": [ "# Utility functions" ] }, { "cell_type": "code", "execution_count": null, "id": "7e97b1b2-d8b4-475d-9638-f3e239c9b414", "metadata": {}, "outputs": [], "source": [ "def lin_to_db(l):\n", " return 20 * np.log10(l)\n", "\n", "def db_to_lin(d):\n", " return np.pow(10.0, d / 20.0)" ] }, { "cell_type": "code", "execution_count": null, "id": "12559a5a-067c-485a-8f36-61b3cc5c4fb5", "metadata": {}, "outputs": [], "source": [ "print(np.reshape(np.tile(np.array([[1,2,3,4],[5,6,7,8]])[:,:, np.newaxis], [1, 1, 2]), shape=(2, 8)))\n", "\n", "# I think replicate_last is not currently used.\n", "\n", "def replicate_last(x, num_reps):\n", " \"\"\"Replicate the last dimension of an array num_reps times.\"\"\"\n", " shape_in = x.shape\n", " shape_out = np.array(shape_in)\n", " shape_out[-1] *= num_reps\n", " return np.reshape(np.tile(x[..., np.newaxis], list(np.ones_like(shape_in)) + [num_reps]), shape=shape_out)\n", "\n", "print(replicate_last(np.array([[1,2,3,4],[5,6,7,8]]), 5))" ] }, { "cell_type": "code", "execution_count": null, "id": "292a19ac-6fce-477e-8a69-ca8d40fa238d", "metadata": {}, "outputs": [], "source": [ "w = np.hanning(256)\n", "x = np.random.rand(1000)\n", "print(np.convolve(w, x, 'same').shape)\n", "print(scipy.signal.convolve(x, w, 'same').shape)\n", "# \"same\" means \"same as 1st arg\" for scipy, but \"same as longer arg\" for numpy.\n", "#convolve = np.convolve\n", "convolve = scipy.signal.convolve" ] }, { "cell_type": "code", "execution_count": null, "id": "954bd4ca-1290-4282-90e4-31ed7c7b3530", "metadata": {}, "outputs": [], "source": [ "def old_slinterp(x, interp, truncate=False):\n", " \"\"\"Linear interpolation of vector. Ramps down to implicit zero at end unless truncate.\"\"\"\n", " x_shape = list(x.shape)\n", " x_out_shape = list(x.shape)\n", " x_out_shape[-1] *= interp\n", " x_in_flat = np.reshape(x, (np.prod([1] + x_shape[:-1]), x_shape[-1]))\n", " n_rows, n_cols = x_in_flat.shape\n", " x_out_flat = np.zeros((n_rows, interp * n_cols))\n", " interpolation_window = np.hstack([np.linspace(0, 1, 1 + interp)[1:], np.linspace(1, 0, 1 + interp)[1:]])\n", " for i in range(x_in_flat.shape[0]):\n", " x_atrous = np.reshape(np.hstack([x_in_flat[[i], :].T, np.zeros((n_cols, interp - 1))]), (n_cols * interp,))\n", " x_out_flat[i] = convolve(x_atrous, interpolation_window, 'same')\n", " if truncate:\n", " if interp > 1: # Skip for degenerate interp == 1; indexing by [:, :-(1 - 1)] deletes the entire array.\n", " x_out_flat = x_out_flat[:, :-(interp - 1)]\n", " x_out_shape[-1] -= (interp - 1)\n", " #print(f'{x_out_flat.shape=}, {x_out_shape=}')\n", " return np.reshape(x_out_flat, x_out_shape)\n", "\n", "def slinterp(x, interp, truncate=False):\n", " \"\"\"Linear interpolation of vector. Ramps down to implicit zero at end unless truncate. CONV-FREE VERSION.\"\"\"\n", " x_shape = list(x.shape)\n", " x_out_shape = list(x.shape)\n", " x_out_shape[-1] *= interp\n", " x_in_flat = np.reshape(x, (np.prod([1] + x_shape[:-1]), x_shape[-1]))\n", " n_rows, n_cols = x_in_flat.shape\n", " x_out_flat = np.zeros((n_rows, interp * (n_cols + 1)))\n", " interpolation_window = np.expand_dims(np.hstack([np.linspace(0, 1, 1 + interp)[1:], np.linspace(1, 0, 1 + interp)[1:]]), 0)\n", " for i in range(x_in_flat.shape[-1]):\n", " #x_atrous = np.reshape(np.hstack([x_in_flat[[i], :].T, np.zeros((n_cols, interp - 1))]), (n_cols * interp,))\n", " #x_out_flat[i] = convolve(x_atrous, interpolation_window, 'same')\n", " x_out_flat[..., i * interp : (i + 2) * interp] += x_in_flat[..., i] * interpolation_window\n", " x_out_flat = x_out_flat[..., (interp - 1):-1]\n", " if truncate:\n", " if interp > 1: # Skip for degenerate interp == 1; indexing by [:, :-(1 - 1)] deletes the entire array.\n", " x_out_flat = x_out_flat[:, :-(interp - 1)]\n", " x_out_shape[-1] -= (interp - 1)\n", " #print(f'{x_out_flat.shape=}, {x_out_shape=}')\n", " return np.reshape(x_out_flat, x_out_shape)\n", "\n", "print(slinterp(np.arange(4), 4, truncate=True).shape)\n", "print(slinterp(np.arange(4), 4, truncate=False).shape)\n", "print(slinterp(np.arange(4), 1, truncate=True).shape)\n", "print(slinterp(np.arange(4), 1, truncate=False).shape)\n", "\n", "plt.plot(np.arange(25), slinterp(np.array([[1, 1, 0, 2, 2]]), 5).T, '.',\n", " np.arange(21), slinterp(np.array([[1, 1, 0, 2, 2]]), 5, truncate=True).T, '.')\n", "plt.grid()" ] }, { "cell_type": "code", "execution_count": null, "id": "bb0499fb-3721-409a-ac1e-7f56e785b4a1", "metadata": {}, "outputs": [], "source": [ "from scipy import fft\n", "\n", "def spectrogram(x, fft_len=4096, win_len=None, hop_len=None, window_fn=np.hanning, sr=1, f_max=None, title=None):\n", " if win_len is None:\n", " win_len = fft_len\n", " if hop_len is None:\n", " hop_len = win_len // 2\n", " # Window.\n", " prepad_len = (fft_len - win_len) // 2\n", " win = np.hstack([np.zeros(prepad_len), window_fn(win_len), np.zeros(fft_len - win_len - prepad_len)])\n", " # Frame.\n", " frame_indices = np.arange(0, len(x) - win_len, hop_len)[:, np.newaxis] + np.arange(win_len)[np.newaxis, :]\n", " x_chunks_windowed = x[frame_indices] * win[np.newaxis, :]\n", " # Transform.\n", " stft_mag_db = 20 * np.log10(np.abs(fft.fft(x_chunks_windowed, n=fft_len)[:, :(fft_len // 2 + 1)]))\n", " num_frames, num_bins = stft_mag_db.shape\n", " t_base = np.arange(num_frames) * hop_len / sr\n", " f_base = np.arange(num_bins) * sr / fft_len\n", " plt.imshow(stft_mag_db.T, aspect='auto', origin='lower', extent=[t_base[0], t_base[-1], f_base[0], f_base[-1]])\n", " plt.clim(np.max(stft_mag_db) + [-80, 0])\n", " #plt.ylim([0, f_max / sr * fft_len])\n", " if f_max:\n", " plt.ylim([0, f_max])\n", " #x_times = np.arange(0, len(x) / sr, 0.25)\n", " #y_freqs = np.arange(0, 10000, 1000)\n", " #plt.xticks(x_times * sr / hop_len, x_times)\n", " #plt.yticks(y_freqs / sr * fft_len, y_freqs)\n", " plt.colorbar()\n", " if title:\n", " plt.title(title)\n" ] }, { "cell_type": "code", "execution_count": null, "id": "e1b105f4-c55c-49e1-8f29-2d30a32a787b", "metadata": {}, "outputs": [], "source": [ "def synth_partial(mag, freq, frame_rate, sr):\n", " \"\"\"Reconstruct audio waveform at sr from mag and freq 1-row arrays at frame_rate.\"\"\"\n", " # Linear interpolation of both amplitude and frequency.\n", " samps_per_frame = int(round(sr / frame_rate))\n", " num_partials, num_frames = mag.shape\n", " output_samples = num_frames * samps_per_frame\n", " t = np.arange(output_samples) / sr\n", " dt = 1 / sr\n", " phase = np.cumsum(slinterp(2 * np.pi * freq * dt, samps_per_frame))\n", " carrier = np.cos(phase)\n", " return slinterp(mag, samps_per_frame) * carrier\n", "\n", "x = synth_partial(np.array([[1, 2, 3, 2]]), np.array([[40, 80, 120, 20]]), 10, 1000)\n", "plt.figure(figsize=(18, 4))\n", "plt.plot(x.T)\n", "plt.grid()\n", "print(x.shape)" ] }, { "cell_type": "code", "execution_count": null, "id": "48b4585d-36ac-4633-a27a-b0fec2da930f", "metadata": {}, "outputs": [], "source": [ "# Synthesize from (possibly downsampled) mag and freq contours.\n", "\n", "def synth_harmonic(freq, mag, interp_factor=1, sample_rate=44100, mag_is_db=True, truncate=True):\n", " \"\"\"Convert a single pair of frequency and magnitude vectors to an audio waveform.\"\"\"\n", " # As a special case, freq can be a scalar indicating a constant frequency.\n", " carrier = None\n", " if isinstance(freq, (list, np.ndarray)):\n", " if len(freq) == 1:\n", " freq = freq[0]\n", " else:\n", " assert len(freq) == len(mag)\n", " # Ignore the final freq value, which tends to go crazy. Replicate the preceding one.\n", " #freq[-1] = freq[-2]\n", " if interp_factor > 1:\n", " freq = slinterp(freq, interp_factor, truncate=truncate)\n", " carrier = np.cos(np.cumsum(2 * np.pi / sample_rate * freq))\n", " if carrier is None:\n", " # freq must be a scalar\n", " #freq = freq * np.ones(1 + (len(mag) - 1) * interp_factor)\n", " carrier = np.cos(2 * np.pi * freq / sample_rate * np.arange(truncate + (len(mag) - truncate) * interp_factor))\n", "\n", " # Can now expand mag to match.\n", " if interp_factor > 1:\n", " mag = slinterp(mag, interp_factor, truncate=truncate)\n", " # freq is cycles per sec. We want radians per sample\n", " if mag_is_db:\n", " mag = db_to_lin(mag)\n", " return mag * carrier\n", "\n", "x1 = synth_harmonic(40, np.array([1, 2, 3, 2]), 100, 1000, truncate=False, mag_is_db=False)\n", "x2 = synth_harmonic(np.array([40, 80, 120, 20]), np.array([1, 2, 3, 2]), 100, 1000, truncate=False, mag_is_db=False)\n", "plt.figure(figsize=(18, 4))\n", "plt.plot(x2.T)\n", "plt.plot(x.T)\n", "plt.plot(x1.T)\n", "plt.grid()\n", "print(x2.shape)\n", "\n", "def synth_harmonics(freqs, mags, interp_factor=1, sample_rate=44100):\n", " \"\"\"Convert arrays where each row is a freq or mag vector to a waveform.\"\"\"\n", " n_harms, n_frames = mags.shape\n", " n_samps = 1 + interp_factor * (n_frames - 1)\n", " result = np.zeros(n_samps)\n", " for freq, mag in zip(freqs, mags):\n", " result += synth_harmonic(freq, mag, interp_factor, sample_rate)\n", " return result\n", " " ] }, { "cell_type": "code", "execution_count": null, "id": "3bff32a8-278f-4d9b-9068-435506d12b93", "metadata": {}, "outputs": [], "source": [ "# Helpers from piano-partials.ipynb\n", "\n", "def lin_fit(x):\n", " \"\"\"Least-squares linear fit to points.\"\"\"\n", " # xhat = a + b.index\n", " # err = x[i] - (a + b.i)\n", " # err^2 = x[i]^2 - 2 x[i] (a + b.i) + (a^2 + 2 a b i +b^2 i^2)\n", " # Define axes around midpoint.\n", " lenx = len(x)\n", " if not lenx:\n", " return []\n", " index = np.arange(lenx) - (lenx - 1) / 2\n", " # Make x zero mean\n", " a = np.mean(x)\n", " x_z = x - a\n", " b = 0\n", " if lenx > 1:\n", " # Linear fit is normalized inner product\n", " b = np.sum(x_z * index) / np.sum(index * index)\n", " return a + b * index\n", "\n", "def expand_params(params):\n", " \"\"\"Convert [val, npts, val, npts, val] sequence to points.\"\"\"\n", " val0 = params[0]\n", " outpts = [[val0]]\n", " npts_val_pairs = np.vstack([params[1::2], params[2::2]])\n", " for npts, val in npts_val_pairs.transpose():\n", " outpts.append(np.linspace(val0, val, int(npts + 1))[1:])\n", " val0 = val\n", " return np.concatenate(outpts)\n", "\n", "plt.plot(expand_params([0, 1, 1, 2, 0, 4, 1]), '.-')\n" ] }, { "cell_type": "markdown", "id": "08a7c732-6d39-4a9a-ae17-b123bf5fa580", "metadata": {}, "source": [ "# Read waveforms" ] }, { "cell_type": "code", "execution_count": null, "id": "25c4d418-462a-4300-ae5c-9879c9402647", "metadata": {}, "outputs": [], "source": [ "def wavread(filename):\n", " \"\"\"Read in audio data from a wav file. Return d, sr.\"\"\"\n", " # Read in wav file.\n", " file_handle = open(filename, 'rb')\n", " samplerate, wave_data = wav.read(file_handle)\n", " # Normalize short ints to floats in range [-1..1).\n", " data = np.asarray(wave_data, dtype=np.float32) / 32768.0\n", " return data, samplerate\n", "\n", "def wavwrite(data, samplerate, filename):\n", " \"\"\"Write a waveform to a WAV file.\"\"\"\n", " wav.write(filename, samplerate, (32768.0 * data).astype(np.int16))\n", "\n", "def read_and_trim(filename, duration=2.0, rel_threshold=0.005, abs_threshold=0, sr=44100, channel=None, do_plot=False, pre_time=0.010):\n", " d, file_sr = wavread(filename)\n", " #print(\"d.shape=\", d.shape)\n", " if len(d.shape) > 1: # Stereo file\n", " if channel is None:\n", " d = np.mean(d, axis=-1)\n", " else:\n", " d = d[:, channel]\n", " assert file_sr == sr\n", " d = d - np.mean(d)\n", " threshold = np.maximum(np.max(np.abs(d)) * rel_threshold, abs_threshold)\n", " # Tight window at start?\n", " drop_initial_samps = np.maximum(0, -int(round(pre_time * sr)) + np.min(np.flatnonzero(np.abs(d) > threshold)))\n", " d_return = d[int(round(drop_initial_samps)) + np.arange(int(round(duration * sr)))]\n", " if do_plot:\n", " t = np.arange(len(d)) / sr\n", " plt.figure(figsize=(12, 4))\n", " plt.subplot(121)\n", " plt.plot(t[:50000], d[:50000])\n", " plt.ylim(threshold * np.array([-1, 1]))\n", " plt.subplot(122)\n", " plt.plot(t[:len(d_return)], d_return)\n", " plt.xlim([0, 0.1])\n", " print(\"drop initial\", drop_initial_samps / sr)\n", " return d_return, sr\n", "\n", "def filename_for_note(note, octave, strike='ff', directory=None):\n", " filename = '.'.join(['Piano', strike, note + str(octave), 'wav'])\n", " if directory:\n", " filename = os.path.join(directory, filename)\n", " return filename\n", "\n", "#filename = 'Piano.ff.D4.wav'\n", "directory = '/Users/dpwe/Downloads/uiowa-piano'\n", "#note = 'C'\n", "#octave = 3\n", "note = 'Ab'\n", "octave = 1\n", "strike = 'pp' # ['pp', 'mf', 'ff']:\n", "filename = filename_for_note(note, octave, strike, directory)\n", "print(filename)\n", "waveform, sr = read_and_trim(filename, channel=0, duration=5.0, rel_threshold=0.015, abs_threshold=0.0007, do_plot=True, pre_time=0.002)\n", "\n", "Audio(data=waveform.T, rate=sr)" ] }, { "cell_type": "markdown", "id": "b613b2b0-a4f5-452f-877d-3ce01fa1ae2b", "metadata": {}, "source": [ "# Fundamental estimation from autocorrelation" ] }, { "cell_type": "code", "execution_count": null, "id": "1a051178-a322-4102-baf8-cf86932d1564", "metadata": {}, "outputs": [], "source": [ "def freq_from_autoco(d, sr=44100, max_duration=1.0, drop_initial_sec=0.05, do_plot=False, prop_max_thresh=0.75):\n", " # Estimate fundamental by autocorrelation.\n", " min_period = int(round(sr / 4000.0))\n", " max_period = int(round(sr / 20.0))\n", " drop_initial_samples = int(round(drop_initial_sec * sr))\n", " d = d[drop_initial_samples : drop_initial_samples + int(round(sr * max_duration))]\n", " #acr = np.correlate(d, d, 'full')[len(d) - 1:]\n", " # Using FFT makes it 1000x faster, seconds to milliseconds. Identical result.\n", " acr = np.real(np.fft.ifft(np.abs(np.fft.fft(d, len(d) * 2)**2)))[:len(d)]\n", " acr = acr[:10 * max_period]\n", " # Find Nth peak, divide by N\n", " maxima = scipy.signal.argrelextrema(acr, np.greater)[0]\n", " # Keep only peaks at least 75% of largest peak below 4kHz.\n", " maxima = maxima[np.flatnonzero(maxima >= min_period)]\n", " max_acr_peak = np.max(acr[maxima])\n", " maxima = maxima[np.flatnonzero(acr[maxima] > prop_max_thresh * max_acr_peak)]\n", " npeaks = np.minimum(30, len(maxima))\n", " # Assume first peak corresponds to fundamental, keep peaks that are close to integer multiples.\n", " est_period = maxima[0]\n", " #print(sr / est_period)\n", " multiples = maxima / est_period\n", " #print(multiples)\n", " #print(np.abs((multiples - np.round(multiples)) / multiples))\n", " # Max 2% relative error\n", " good_multiples = np.flatnonzero(np.abs((multiples - np.round(multiples)) / multiples) < 0.02)\n", " if do_plot:\n", " plt.plot(acr)\n", " plt.plot(maxima[:npeaks], acr[maxima[:npeaks]], 'or')\n", " plt.plot([0, len(acr)], prop_max_thresh * max_acr_peak * np.array([1, 1]), '--')\n", " plt.plot(maxima[good_multiples], acr[maxima[good_multiples]], 'ob')\n", " plt.xlim([0, 10*est_period])\n", " #freqs = sr * np.arange(1, npeaks + 1) / maxima[:npeaks]\n", " freqs = (sr / (maxima / np.round(multiples)))[good_multiples]\n", " #print(freqs)\n", " freq = np.mean(freqs[-40:])\n", " return freq\n", "\n", "\n", "%time freq = freq_from_autoco(waveform[8000:32000], do_plot=True, prop_max_thresh=0.81)\n", "print(freq)\n", "# Nominal: D5= 587.3295\n", "# C2 = 65.89466739451501\n", "# Db6 = 1108.73 Hz (we get 1113.37 for ff, 1114.50 for pp)" ] }, { "cell_type": "markdown", "id": "5ea80ccb-d182-40bb-a673-5616fa1331fd", "metadata": {}, "source": [ "# Find frequency peaks in long Fourier transform" ] }, { "cell_type": "code", "execution_count": null, "id": "1a4ff398-98d8-4e3d-b80e-de85482c09ac", "metadata": {}, "outputs": [], "source": [ "from scipy import fft\n", "\n", "def localmax(x, npts):\n", " \"\"\"Return indices of x where value is largest among nearest npts.\"\"\"\n", " maxima = []\n", " padval = np.array([np.min(x) - 1])\n", " padded_x = np.hstack([padval, x, padval])\n", " localmaxes = np.flatnonzero(np.logical_and(padded_x[1:-1]> padded_x[:-2], padded_x[1:-1] >= padded_x[2:]))\n", " #for i in np.arange(1, len(x)):\n", " for i in localmaxes: \n", " locality = x[np.maximum(0, i - npts // 2) : np.minimum(len(x), i + npts // 2)]\n", " if x[i] == np.max(locality) and x[i] > x[i - 1]:\n", " maxima.append(i)\n", " return np.array(maxima)\n", "\n", "np.random.seed(57730)\n", "print(localmax(np.random.rand(32), npts=6))\n", "\n", "\n", "def peak_freqs(x, n_fft=65536, f_max=10000.0, depth_db=20.0, local_smooth_points=2047, local_max_points=100, sr=44100, est_f0=None, do_plot=False):\n", " \"\"\"Return frequencies of local maxima from a long FFT.\"\"\"\n", " # Provided f0 estimate is solely used to set the exclusion window for local max picking.\n", " if est_f0:\n", " # Use expected f_0 to set local_max_points.\n", " f0_in_bins = est_f0 / (sr / n_fft)\n", " local_max_points = int(round(f0_in_bins / 1))\n", " if do_plot:\n", " print(\"local_max_points=\", local_max_points)\n", " long_fft = fft.fft(x[:n_fft])\n", " long_fft = long_fft[:(n_fft // 2)]\n", " freqs = np.arange(n_fft // 2) * sr / n_fft\n", " n_bins = np.sum(freqs < f_max)\n", " X_spec = 20 * np.log10(np.abs(long_fft[:n_bins]))\n", " # Local average\n", " smoo_X_spec = convolve(X_spec, np.ones(local_smooth_points) / local_smooth_points, 'same')\n", " unsmoo_X_spec = X_spec - smoo_X_spec\n", "\n", " #peaks = scipy.signal.argrelextrema(np.maximum(np.max(unsmoo_X_spec) - 30, unsmoo_X_spec), np.greater)[0]\n", " peaks = localmax(np.maximum(np.max(unsmoo_X_spec) - depth_db, unsmoo_X_spec), local_max_points)\n", "\n", " # Remove peaks more than 1 octave below expected F0.\n", " peaks = peaks[peaks > f0_in_bins / 2.5]\n", "\n", " if do_plot:\n", " plt.figure(figsize=(20, 6))\n", " plt.plot(freqs[:n_bins], unsmoo_X_spec)\n", " plt.plot(freqs[:n_bins], smoo_X_spec)\n", " plt.plot(freqs[peaks], unsmoo_X_spec[peaks], 'or')\n", " plt.xlim((0, 4000))\n", " \n", " return peaks * sr / n_fft\n", "\n", "est_f0 = freq_from_autoco(waveform, drop_initial_sec=0.1)\n", "print('f0_from_autoco=', est_f0)\n", "#pk_frqs = peak_freqs(waveform[8000:], n_fft=32768, depth_db=30, do_plot=True, est_f0=est_f0)\n", "\n", "pk_frqs = peak_freqs(waveform[2000:80000], n_fft=32768, depth_db=40, do_plot=True, est_f0=est_f0)\n", "\n", "plt.grid()\n", "plt.xlabel('freq / Hz')\n", "plt.ylabel('level / dB')\n", "plt.title('Spectral peaks for ' + os.path.basename(filename))\n", "\n", "print(pk_frqs[:6])\n", "print(pk_frqs[:6] / est_f0)\n", "\n" ] }, { "cell_type": "markdown", "id": "0e8da7ea-cc11-4452-a6a6-bfd8f22bd6be", "metadata": {}, "source": [ "# Inharmonicity estimation" ] }, { "cell_type": "code", "execution_count": null, "id": "f27957df-3219-475d-a966-9009561564a1", "metadata": { "scrolled": true }, "outputs": [], "source": [ "# Manual search for lowest-error f0 and beta\n", "# Error is (measured_freq / pred_harm_freq) - 1.\n", "avg_freqs = pk_frqs\n", "hn = 1 + np.arange(len(avg_freqs))\n", "beta = 0.0003128\n", "f0 = est_f0 # 262.2118\n", "print(f0, avg_freqs)\n", "prop_err = avg_freqs / (f0 * hn * np.sqrt(1 + beta * hn * hn)) - 1\n", "#plt.plot(hn, avg_freqs / hn, hn, f0 * np.sqrt(1 + beta * hn * hn))\n", "plt.plot(hn, prop_err)\n", "print(\"rms prop err =\", np.sqrt(np.mean(prop_err ** 2)))\n", "f0= 253.68557562939364\n", "beta= 0.0008292878905710716\n", "#plt.plot(hn, f0 * np.sqrt(1 + beta * hn * hn))" ] }, { "cell_type": "code", "execution_count": null, "id": "3e1a0bac-26b2-4310-b180-ea2a086d6493", "metadata": {}, "outputs": [], "source": [ "def est_inharmonicity(freqs, f0=None, beta=0, tolerance=0.2, verbose=False):\n", " \"\"\"Estimate an inharmonicity beta for a series of harmonic frequencies.\"\"\"\n", " freq_order = np.argsort(freqs)\n", " if not f0:\n", " f0 = freqs[freq_order[0]]\n", " # Find harmonic numbers sequentially.\n", " h_nums = np.zeros_like(freqs, dtype=int)\n", " valid = np.zeros_like(freqs, dtype=bool)\n", " f0s = np.zeros_like(freqs)\n", " freq_errs = np.zeros_like(freqs)\n", " last_freq = 0\n", " last_hnum = 0\n", " # Try every harmonic up to the largest candidate.\n", " last_harm_freq = 0\n", " for cand_hnum in 1 + np.arange(np.ceil(np.max(freqs) / f0)):\n", " stretched_df = f0 * np.sqrt(1 + beta * cand_hnum * cand_hnum)\n", " expected_freq = last_harm_freq + stretched_df\n", " # Find actual freq closest to this.\n", " best_freq_index = np.argmin(np.abs(freqs - expected_freq))\n", " found_freq = freqs[best_freq_index]\n", " delta_freq = expected_freq - found_freq\n", " if np.abs(delta_freq / f0) > 0.1:\n", " if verbose:\n", " print(\"Closest harmonic to %d (%.1f) is %.1f Hz - reject\" % (cand_hnum, expected_freq, freqs[best_freq_index]))\n", " last_harm_freq = expected_freq\n", " else:\n", " if verbose:\n", " print(\"Found harmonic %d expected %.1f Hz got %.1f Hz\" % (cand_hnum, expected_freq, found_freq))\n", " last_harm_freq = found_freq\n", " h_nums[best_freq_index] = cand_hnum\n", " valid[best_freq_index] = True\n", " if verbose and np.sum(valid == False):\n", " print(np.sum(valid == False), \"values invalid\");\n", " #print(\"h_nums=\", h_nums)\n", " #print(\"freq_errs=\", freq_err)\n", " # We expect (f / h.f0) = sqrt(1 + beta h^2)\n", " betas = (((freqs / (f0 * h_nums + (h_nums==0))) ** 2) - 1) / (h_nums ** 2 + (h_nums == 0))\n", " #print(\"betas=\", betas)\n", " weights = h_nums * h_nums * valid * (betas > 0) # Increase weighting in proportion to harmonic num for valid harmonics\n", " #print(\"weights=\", weights)\n", " # Weights can be all zero if all the calculated betas are <= 0.\n", " if np.sum(weights):\n", " beta = np.sum(weights * betas) / np.sum(weights)\n", " # Now figure implied f0s\n", " valid_ixs = np.flatnonzero(valid)\n", " f0s = freqs / (h_nums * np.sqrt(1 + beta * (h_nums ** 2)) + (h_nums==0))\n", " #print(\"f0s=\", f0s)\n", " weights = valid / ((h_nums ** 2) + (valid == False)) # Downweight high harmonics for f0.\n", " if np.sum(weights):\n", " f0 = np.sum(weights * f0s) / np.sum(weights)\n", " #f0 = np.median(f0s[valid])\n", "\n", " if verbose:\n", " plt.subplot(211)\n", " plt.plot(h_nums, betas, '.')\n", " plt.subplot(212)\n", " plt.plot(h_nums, f0s, '.')\n", " \n", " return f0, beta, h_nums * valid\n", " \n", " # We are fitting freqs[h_num] = f0 * h_num * sqrt(1 + beta * (h_num ^ 2))\n", " # Given beta, what is the (non-integral) h such that \n", " # freq = f0 * h * sqrt(1 + beta * h^2)\n", " # => freq/f0 = h sqrt(1 + beta h^2)\n", " # => (f/f0)^2 = h^2 (1 + beta h^2) => (f/(h.f0))^2 = 1 + beta h^2 => beta = ((f/(h.f0))^2 - 1) / h^2\n", " # => (f/f0)^2 = h^2 + beta h^4\n", " # => beta h^4 + h^2 - (f/f0)^2 = 0\n", " # => h^2 = (-1 +/- sqrt(1 - 4 * beta * (-(f/f0)^2))) / (2 * beta)\n", " # => h = sqrt( 1/(2 beta) * ( - 1))\n", " # => freq^2 = f0^2 * h^2 * (1 + beta h^2) => beta h^4 + h^2 - (freq / f0)^2 = 0\n", " # => h^2 = [-1 +/- sqrt(1 + 4 beta ((freq/f0) ^ 2) )] / 2 beta\n", " # => h = sqrt( 1/(2 beta) sqrt(1 + 4 beta ((freq/f0) ^ 2)) )\n", " #h_nums = np.sqrt( (1 / (2 * beta)) * (np.sqrt(1 + 4 * beta * ((freqs / f0) ** 2)) - 1))\n", " #h_nums_q = np.round(h_nums)\n", " #valid_wts = (np.abs(h_nums - h_nums_q) < 0.2) * (0 + np.arange(len(h_nums)))\n", " #betas = (((freqs / (f0 * h_nums_q)) ** 2) - 1) / (h_nums_q ** 2)\n", " #new_f0s = freqs / (h_nums_q * np.sqrt(1 + beta * (h_nums_q ** 2)))\n", "\n", "est_f0 = freq_from_autoco(waveform, sr, drop_initial_sec=0.1)\n", "# Trim transient based on fundamental frequency duration\n", "skip_initial_cycles = 10\n", "skip_initial_time = skip_initial_cycles / est_f0\n", "skip_initial_samples = int(round(skip_initial_time *sr))\n", "\n", "f0 = est_f0 # avg_freqs[0]\n", "beta = 0\n", "#f0 = 262.2118\n", "#beta = 0.0003128\n", "#freqs = avg_freqs[:25]\n", "#freqs = peak_freqs(d[8000:80000], n_fft=32768, depth_db=32, est_f0=est_f0)[:25]\n", "freqs = peak_freqs(waveform[skip_initial_samples:], n_fft=32768, depth_db=40, est_f0=est_f0)[:25]\n", "print(freqs)\n", "#del freqs[13]\n", "for _ in range(5):\n", " print(f0, beta)\n", " f0, beta, h_nums = est_inharmonicity(np.array(freqs), f0=f0, beta=beta, verbose=0)\n", "#for h_num, freq in zip(h_nums, avg_freqs):\n", "# print(freq, h_num)\n", "print(h_nums)" ] }, { "cell_type": "code", "execution_count": null, "id": "abe281f7-a747-4b40-998d-546073f9b5aa", "metadata": {}, "outputs": [], "source": [ "#f0 = 32.4\n", "#beta = 0.00025\n", "valid = np.flatnonzero(h_nums > 0)\n", "plt.plot(h_nums[valid], freqs[valid] / h_nums[valid], '.')\n", "\n", "_ = plt.plot(h_nums, f0 * np.sqrt(1 + beta * h_nums * h_nums), '.')\n", "#print(freqs[12])\n", "\n", "plt.legend(['Measured equivalent fundamentals of harmonics', 'Fundamentals for inharmonicity parameter %f' % beta])\n", "plt.xlabel('harmonic number')\n", "plt.ylabel('fundamental frequency / Hz for ' + os.path.basename(filename))\n", "plt.grid()" ] }, { "cell_type": "markdown", "id": "8dd7d682-63ca-4267-9393-7180bf00159c", "metadata": {}, "source": [ "# Calculate fundamental and inharmonicity across whole range" ] }, { "cell_type": "code", "execution_count": null, "id": "590179f0-f908-4048-a0d4-6cbca93fe627", "metadata": {}, "outputs": [], "source": [ "def expected_f0_hz(note, octave):\n", " semis = {'C': 0, 'C#': 1, 'Db': 1, 'D': 2, 'D#': 3, 'Eb': 3, 'E': 4, 'F': 5, 'F#': 6, 'Gb': 6, 'G': 7, \n", " 'G#': 8, 'Ab': 8, 'A': 9, 'A#': 10, 'Bb': 10, 'B': 11}[note[0].upper() + note[1:]]\n", " semis += (octave + 1) * 12 # semis is midi note number, C4 = 60.\n", " return 440 * (2 ** ((semis - 69) / 12))\n", "\n", "print(expected_f0_hz('C', 4))\n", "print(expected_f0_hz('A', 4))\n", "print(expected_f0_hz('C', 5))" ] }, { "cell_type": "code", "execution_count": null, "id": "4be2a0c6-f4cd-48ac-8a55-42d7c7eb3cb2", "metadata": {}, "outputs": [], "source": [ "directory = '/Users/dpwe/Downloads/uiowa-piano'\n", "strike = 'ff' # ['pp', 'mf', 'ff']:\n", "\n", "filenames = []\n", "est_f0s = []\n", "f0s = []\n", "betas = []\n", "\n", "for octave in [1, 2, 3, 4, 5, 6]:\n", " #for note in ['C', 'D', 'E', 'Gb', 'Ab', 'Bb']:\n", " for note in ['C', 'Db', 'D', 'Eb', 'E', 'F', 'Gb', 'G', 'Ab', 'A', 'Bb', 'B']:\n", " for strike in ['pp', 'mf', 'ff']:\n", " filename = filename_for_note(note, octave, strike)\n", " #print(filename)\n", " #d, sr = read_and_trim(os.path.join(directory, filename), channel=0, duration=5.0, \n", " # rel_threshold=0.010, abs_threshold=0.0001, pre_time=0.01)\n", " d, sr = read_and_trim(os.path.join(directory, filename), channel=0, duration=5.0, \n", " rel_threshold=0.015, abs_threshold=0.0007, pre_time=0.002)\n", " drop_initial_samps = 8000 # int(round(drop_initial_sec * sr))\n", " est_f0 = freq_from_autoco(d[drop_initial_samps : 32000], sr, prop_max_thresh=0.81)\n", " est_f0s.append(est_f0)\n", " filenames.append(filename)\n", " freqs = peak_freqs(d[drop_initial_samps : 80000], n_fft=32768, depth_db=32, est_f0=est_f0)[:25]\n", " f0 = est_f0\n", " beta = 0\n", " for _ in range(10):\n", " f0, beta, h_nums = est_inharmonicity(np.array(freqs), f0=f0, beta=beta)\n", " f0s.append(f0)\n", " betas.append(beta)\n", "\n", "plt.plot(1200 * (np.log2(np.array(est_f0s) / (261.626 * 2)) - replicate_last(np.linspace(-4, 2, 72, endpoint=False), 3)), '.')\n", "plt.ylabel('tuning error / cents')\n", "_ = plt.xlabel('key number')" ] }, { "cell_type": "code", "execution_count": null, "id": "c004668c-2064-4f43-8d89-80ba2e7f0eba", "metadata": {}, "outputs": [], "source": [ "for octave in [1, 2, 3, 4, 5, 6]:\n", " #for note in ['C', 'D', 'E', 'Gb', 'Ab', 'Bb']:\n", " for note in ['C', 'Db', 'D', 'Eb', 'E', 'F', 'Gb', 'G', 'Ab', 'A', 'Bb', 'B']:\n", " for strike in ['pp', 'mf', 'ff']:\n", " filename = filename_for_note(note, octave, strike)\n", " #print(filename)\n", " d, sr = read_and_trim(os.path.join(directory, filename), channel=0, duration=5.0, \n", " rel_threshold=0.015, abs_threshold=0.0007, pre_time=0.002)\n", " est_f0 = freq_from_autoco(d[8000:32000], sr, prop_max_thresh=0.81)\n", " if np.abs(np.log2(est_f0 / expected_f0_hz(note, octave))) > 0.5/12:\n", " print(filename, 'expected f0 %.1f, observed %.1f (%.1f cents)' % (\n", " expected_f0_hz(note, octave), est_f0, 1200 * np.log2(est_f0 / expected_f0_hz(note, octave))))\n", "\n", "# Piano.pp.C1.wav was the same recording as Piano.pp.B0.wav, it's a data error. \n", "# The error is present on the UIowa site, but I can't find any mention.\n", "# I resampled it up 100 cents with sox and rewrote it." ] }, { "cell_type": "code", "execution_count": null, "id": "a33d8b44-bdf5-4dc5-82ce-535cadef3b53", "metadata": {}, "outputs": [], "source": [ "#plt.plot(np.log2(np.array(est_f0s) / 440), '.')\n", "#print(len(est_f0s))\n", "#print(est_f0s)\n", "plt.plot(betas, '.-')\n", "print(filenames[5], est_f0s[5], betas[5])\n", "print(filenames[6], est_f0s[6], betas[6])" ] }, { "cell_type": "markdown", "id": "656b5fbc-c091-4d2e-888d-468d28d1912d", "metadata": {}, "source": [ "# Extract magnitude and frequency contours for a single harmonic\n", "\n", "`heterodyne_extract` extracts sample-by-sample magnitude and frequency contours for a single harmonic in the neighborhood of a specified input frequency (specified by a fundamental and a real-valued harmonic number, so the actual center frequency is simply the product of the two). This is done by 'heterodyne extraction' - frequency-shifting the signal by multiplying it by the conjugate complex sinusoid at the center frequency (which shifts the center frequency down to 0 Hz), then low-pass filtering with a hanning window whose length is `smooth_cycles` times the fundamental period corresponding to `fundamental_freq`. This window has zeros at the fundamental, so modulation at the fundamental rate is completely canceled. This gives smooth contours for true harmonics of a fundamental." ] }, { "cell_type": "code", "execution_count": null, "id": "5278f393-a5b0-48ee-8b23-74293225a815", "metadata": {}, "outputs": [], "source": [ "#convolve = scipy.signal.convolve\n", "\n", "def heterodyne_extract(waveform, fundamental_freq, harmonic_number=1.0, sr=44100, smooth_cycles=2.0):\n", " \"\"\"Return a full-sample-rate amplitude and frequency envelope near the specified frequency.\"\"\"\n", " t = np.arange(len(waveform)) / sr\n", " h_freq = harmonic_number * fundamental_freq\n", " # Conjugate complex exponential at center freq.\n", " complex_exp = np.exp(-1j * 2 * np.pi * h_freq * t)\n", " f_period = sr / fundamental_freq\n", " # Smoothing over e.g. 2 cycles of fundamental cancels periodic components, leaving only the DC shifted down from h_freq.\n", " smooth_len = int(round(smooth_cycles * f_period))\n", " #print(\"f_period=\", f_period, \"sm_len=\", smooth_len)\n", " smooth_win = np.hanning(smooth_len)\n", " smooth_win = smooth_win / np.sum(smooth_win)\n", " smoothed_heterodyne_waveform = convolve(waveform * complex_exp, smooth_win, 'same')\n", " heterodyne_magnitude = np.abs(smoothed_heterodyne_waveform)\n", " # Unwrap the phase of the near-DC component, then also smooth at ~fundamental to get freq deviation.\n", " unwrapped_phase = np.hstack([[0], np.unwrap(np.angle(smoothed_heterodyne_waveform))])\n", " smoothed_dphi_dt = np.diff(convolve(unwrapped_phase, smooth_win, 'same'))\n", " inst_freq = h_freq + smoothed_dphi_dt / (2 * np.pi) * sr\n", " #plt.plot(unwrapped_phase[-10000:])\n", " #plt.plot(np.angle((waveform * complex_exp)[-1000:]))\n", " #plt.plot(np.imag(smoothed_heterodyne_waveform)[-1000:])\n", " # If it moves more than 0.5 rad/sample, it's not tracking well.\n", " dphi_dt_valid = (np.abs(smoothed_dphi_dt) < 0.5)\n", " dphi_dt_weighting = heterodyne_magnitude * dphi_dt_valid\n", " weighted_mean_dphi_dt = np.sum(dphi_dt_weighting * smoothed_dphi_dt) / np.sum(dphi_dt_weighting) # radians / sample\n", " avg_freq = h_freq + weighted_mean_dphi_dt / (2 * np.pi) * sr # cycles / second\n", " reconstructed_waveform = 2 * np.real(smoothed_heterodyne_waveform * np.conj(complex_exp)) # Smoothed complex waveform remodulated.\n", " return lin_to_db(heterodyne_magnitude), inst_freq, avg_freq, reconstructed_waveform\n", "\n", "#f_freq = freq_from_autoco(waveform) # 589.232\n", "#harmonic_num = 1\n", "#sm_cyc = 2.0\n", "#mag, freq, avg_freq, recons_waveform = heterodyne_extract(waveform, f_freq, harmonic_num, sr, sm_cyc)\n" ] }, { "cell_type": "code", "execution_count": null, "id": "d4fd5f4e-8901-4a5b-8a52-0888dcd1dfd1", "metadata": {}, "outputs": [], "source": [ "# Heterodyne\n", "# h_num delta_f\n", "# 1 -0.63\n", "# 2 -6.5\n", "# 3 4.1\n", "# 4 18.7\n", "# 5 35.3\n", "# 6 61.4\n", "# 7 104 4229\n", "# 8.2 31.4 4863\n", "# 9.3 97.1 5518\n", "# 10.2 6003\n", "# 10.8 6222\n", "# 11.2 6593\n", "# 11.7 6890\n", "# 13.3 7830\n", "# 14.15 8343\n", "# 15.45 9097\n", "# 16.7 9845\n", "\n", "f_freq = freq_from_autoco(waveform, drop_initial_sec=0.18) # 589.232\n", "harmonic_num = 1\n", "sm_cyc = 2.0\n", "\n", "mag, freq, avg_freq, recons_waveform = heterodyne_extract(waveform, f_freq, harmonic_num, sr, sm_cyc)\n", "\n", "t = np.arange(len(waveform)) / sr\n", "ii = np.arange(22000) # \n", "#ii = np.arange(len(mag)-1000,len(mag))\n", "\n", "print(mag.shape)\n", "print(freq.shape)\n", "\n", "plt.subplot(211)\n", "#plt.plot(t[ii], db_to_lin(mag[ii]), '.')\n", "plt.plot(t[ii], mag[ii], '.')\n", "plt.grid()\n", "#plt.ylim([-60, -20])\n", "plt.title(f'harmonic {harmonic_num} - mag / dB')\n", "\n", "plt.subplot(212)\n", "plt.plot(t[ii], freq[ii], '.')\n", "plt.ylim([0.9 * avg_freq, 1.1 * avg_freq])\n", "plt.grid()\n", "plt.title(f'harmonic {harmonic_num} - freq / Hz')\n", "\n", "print(\"pre_freq=%.2f\" % (f_freq * harmonic_num), \"post_freq=%.2f\" % avg_freq, \"diff=%.2f\" % (avg_freq - f_freq * harmonic_num))\n", "\n", "#Audio(data=synth_partial(np.array([db_to_lin(mag)]), np.array([freq]), sr, sr), rate=sr)\n", "#Audio(data=synth_partial(np.array([db_to_lin(mag)]), avg_freq * np.ones((1, len(freq))), sr, sr), rate=sr)" ] }, { "cell_type": "code", "execution_count": null, "id": "2617c691-9aa2-4776-ae0b-e27df473f486", "metadata": {}, "outputs": [], "source": [ "interp_factor = 44 * 10 # 10 ms sample period for parameters\n", "f_down = freq[::interp_factor]\n", "m_down = mag[::interp_factor]\n", "print(f'{f_down.shape=} {m_down.shape=}')\n", "h_recon = synth_harmonic(f_down, m_down, interp_factor=interp_factor, sample_rate=sr)\n", "plt.subplot(311)\n", "plt.plot(f_down)\n", "plt.subplot(312)\n", "plt.plot(m_down)\n", "plt.subplot(313)\n", "spectrogram(h_recon, sr=sr, f_max=4 * avg_freq) #, fft_len=fft_len, f_max=f_max, title='original')\n", "#plt.plot(h_recon[-1000:])\n", "Audio(data=(h_recon).T, rate=sr)" ] }, { "cell_type": "markdown", "id": "407b7b6e-e3f8-4ee4-9b47-c58b2154f17b", "metadata": {}, "source": [ "# Parent function extracts all harmonic envelopes for a note\n", "\n", "`extract_harmonics` goes through multiple steps to model a fixed-frequency note as a set of harmonics.\n", "* It makes an initial estimate of the fundamental from the autocorrelation of the whole note (with `freq_from_autoco`)\n", "* It finds all the most prominent peaks in the Fourier transform of the entire note. The estimated fundamental is used here to set a local-dominance region so only the largest peak within one harmonics-spacing is returned.\n", "* It finds a best-fit for the inharmonicity of the upper harmonics by repeated application of `est_inharmonicity`.\n", "* It calls `heterodyne_extract` for up to the lowest `num_harms` harmonics, calculating a magnitude and (time-varying) frequency estimate for each one, then, for harmonics above `lowest_retry_harmonic`, extracts again based on the average of the extracted frequency.\n", "* The estimated harmonic is subtracted from the residual then goes on to extract the next harmonic. The estimated harmonics are also accumulated to return a sinusoidal-model estimate of the input.\n", "* The final residual (aspects of the waveform not captured by the harmonics) is also returned." ] }, { "cell_type": "code", "execution_count": null, "id": "4f2d892b-2ec0-4437-b3b4-1867b64b3a5d", "metadata": {}, "outputs": [], "source": [ "def extract_harmonics(d, sr=44100, num_harms=8, skip_initial_cycles=10, verbose=False, lowest_retry_harmonic=0, est_f0=None):\n", " \"\"\"Model a waveform with a set of harmonics.\"\"\"\n", "\n", " recons_d = np.zeros_like(d)\n", " recons_d_flat_f = np.zeros_like(d)\n", "\n", " sm_cyc = 2.0\n", "\n", " d_remaining = np.array(d)\n", "\n", " mags = []\n", " freqs = []\n", " avg_freqs = []\n", "\n", " # Initial F0 estimation from autocorrelation unless one was passed in.\n", " if est_f0 is None:\n", " est_f0 = freq_from_autoco(d, sr)\n", " if verbose:\n", " print('est_f0=', est_f0)\n", " # Trim transient based on fundamental frequency duration\n", " skip_initial_time = skip_initial_cycles / est_f0\n", " skip_initial_samples = int(round(skip_initial_time * sr))\n", " # Find all the prominent spectral peaks. est_f0 is just for local max exclusion region.\n", " f_peaks = peak_freqs(d[skip_initial_samples:], n_fft=32768, depth_db=32, est_f0=est_f0)[:num_harms]\n", " if verbose:\n", " print(\"f_peaks=\", f_peaks)\n", "\n", " # We will extract tracks for each peak, but we will reference them to the independent f0 estimate.\n", " #h_num_list = f_peaks / est_f0\n", " max_inharm_peaks = 25 # Too many peaks messes up inharmonicity estimation for lower freqs.\n", " f0 = est_f0\n", " beta = 0\n", " for _ in range(10):\n", " # Iterate estimaing f0 and beta multiple times for covergence.\n", " #print(f0, beta)\n", " f0, beta, h_num_list = est_inharmonicity(f_peaks[:max_inharm_peaks], f0=f0, beta=beta)\n", " # Use the fundamental extraction from the inharmonicity estimation.\n", " est_f0 = f0\n", " if verbose:\n", " print('inh est_f0=', est_f0, 'beta=', beta)\n", " \n", " # Clip num_harmonics at 0.8 F_nyq\n", " h_nums = (1 + np.arange(num_harms))\n", " h_freqs = est_f0 * h_nums * np.sqrt(1 + beta * h_nums * h_nums)\n", " num_harmonics_below_nyq = np.sum(h_freqs < 0.8 * sr / 2)\n", " if num_harms > num_harmonics_below_nyq:\n", " if verbose:\n", " print('Clamping num_harms from', num_harms, 'to', num_harmonics_below_nyq)\n", " num_harms = num_harmonics_below_nyq\n", " h_nums = h_nums[:num_harms]\n", " \n", " for h_num in h_nums:\n", " # Extract one harmonic from the residual so far.\n", " stretched_hnum = h_num * np.sqrt(1 + beta * h_num * h_num)\n", " # Oblige the search to be at the predicted frequency, incorporating inharmonic stretching\n", " mag, freq, avg_freq, recons_waveform = heterodyne_extract(d_remaining, est_f0, stretched_hnum, sr, sm_cyc)\n", " if verbose:\n", " print(' h_num={:.3f}, imp_f0={:.1f}, f={:.1f} err_f={:.1f}, max_mag={:.1f} dB'.format(\n", " h_num, avg_freq / stretched_hnum, avg_freq, avg_freq - est_f0 * stretched_hnum, max(mag)))\n", "\n", " # Repeat with estimated frequency for higher harmonics.\n", " if h_num > lowest_retry_harmonic:\n", " mag, freq, avg_freq, recons_waveform = heterodyne_extract(d_remaining, avg_freq / h_num, h_num, sr, sm_cyc)\n", " if verbose:\n", " print('*h_num={:.3f}, imp_f0={:.1f}, f={:.1f} err_f={:.1f}, max_mag={:.1f} dB'.format(\n", " h_num, avg_freq / h_num, avg_freq, avg_freq - est_f0 * h_num, max(mag)))\n", "\n", " recons_d += recons_waveform\n", " d_remaining -= recons_waveform\n", " #recons_d_flat_f += synth_partial(np.array([db_to_lin(mag)]), avg_freq * np.ones((1, len(freq))), sr, sr)[0]\n", " recons_d_flat_f += synth_harmonic(avg_freq, np.array([db_to_lin(mag)]), 1, sr)[0]\n", " mags.append(mag)\n", " freqs.append(freq)\n", " avg_freqs.append(avg_freq)\n", "\n", " mags = np.array(mags)\n", " freqs = np.array(freqs)\n", " if verbose:\n", " print(mags.shape)\n", "\n", " return mags, recons_d, freqs, avg_freqs, est_f0\n", "\n", "#filename = filename_for_note('D', 4, 'ff')\n", "filename = filename_for_note('Ab', 1, 'pp')\n", "waveform, sr = read_and_trim(os.path.join(directory, filename), channel=0, duration=5.0, rel_threshold=0.015, abs_threshold=0.0007, pre_time=0.002)\n", "\n", "d = waveform\n", "\n", "mags, recons_d, freqs, avg_freqs, est_f0 = extract_harmonics(d, num_harms=40, lowest_retry_harmonic=0, verbose=1)\n", "# extract_harmonics(d, num_harms=num_harms, est_f0=est_f0)\n", "print(f'{mags.shape=}, {freqs.shape=}')\n", "print(f'{avg_freqs=}')\n", "resid = d - recons_d\n", "\n", "t = np.arange(len(d)) / sr\n", "ii = np.arange(14000, 14200)\n", "plt.plot(t[ii], d[ii], '.', t[ii], recons_d[ii], '.', t[ii], resid[ii])\n", "#Audio(data=d.T, rate=sr)\n", "#Audio(data=recons_d.T, rate=sr)\n", "Audio(data=(resid).T, rate=sr)\n", "#Audio(data=recons_d_flat_f.T, rate=sr)" ] }, { "cell_type": "code", "execution_count": null, "id": "0be16166-d18b-457d-8f6c-89eeea6f502f", "metadata": {}, "outputs": [], "source": [ "plt.figure(figsize=(20, 5))\n", "plt.imshow(mags, aspect='auto', origin='lower', interpolation='nearest')\n", "plt.colorbar()" ] }, { "cell_type": "code", "execution_count": null, "id": "de0bf77e-8d15-4707-88f4-d9293865f7b6", "metadata": {}, "outputs": [], "source": [ "wavwrite(resid, sr, 'resid.wav')\n", "wavwrite(recons_d, sr, 'recons.wav')" ] }, { "cell_type": "code", "execution_count": null, "id": "1a7ee247-10c1-47c2-8a5d-2cb00f711002", "metadata": {}, "outputs": [], "source": [ "f_max = 2000\n", "fft_len = 2 * 4096\n", "\n", "plt.figure(figsize=(18, 12))\n", "plt.subplot(311)\n", "spectrogram(d, sr=sr, fft_len=fft_len, f_max=f_max, title='original')\n", "plt.subplot(312)\n", "spectrogram(recons_d, sr=sr, fft_len=fft_len, f_max=f_max, title='partials')\n", "plt.subplot(313)\n", "spectrogram(resid, sr=sr, fft_len=fft_len, f_max=f_max, title='residual')\n", "#spectrogram(recons_d_flat_f, sr=sr, f_max=10000, title='flat_f partials')\n" ] }, { "cell_type": "code", "execution_count": null, "id": "12bfb193-1ba6-4f84-9bc8-897a7afa9bdd", "metadata": {}, "outputs": [], "source": [ "# Resynthesize downsampled mags and freqs\n", "interp_factor = 44 * 10 # 10 ms sample period for parameters\n", "fs_down = freqs[:, ::interp_factor]\n", "ms_down = mags[:, ::interp_factor]\n", "print(f'{ms_down.shape=}')\n", "# Variable frequencies\n", "#print('frame-rate frequencies')\n", "#audio = synth_harmonics(fs_down, ms_down, interp_factor)\n", "# Fixed frequency per harmonic\n", "print('Constant frequencies')\n", "audio = synth_harmonics(avg_freqs, ms_down, interp_factor)\n", "\n", "spectrogram(audio, sr=sr, f_max=8000) #, fft_len=fft_len, f_max=f_max, title='original')\n", "#plt.plot(h_recon[-1000:])\n", "Audio(data=(audio).T, rate=sr)" ] }, { "cell_type": "code", "execution_count": null, "id": "89829014-3f7e-4f39-8242-7d5d2a31b043", "metadata": {}, "outputs": [], "source": [ "f = avg_freqs[0]\n", "ms = mags[0]\n", "%timeit a = synth_harmonic(f, ms, 1)\n", "plt.plot(synth_harmonic(f, ms[::2], 2))" ] }, { "cell_type": "markdown", "id": "cf340f1a-993c-4447-b993-ef65bdf74627", "metadata": {}, "source": [ "# Fixed log-time sampling\n", "\n", "We sample the magnitude contours at 21 log-spaced times (in milliseconds):\n", "```\n", "0, 4, 8, 12, 16, 24, 32, 48, 64, 96, 128, 192, 256, 384, 512, 768, 1024, 1536, 2048, 3072, 4096\n", "```" ] }, { "cell_type": "code", "execution_count": null, "id": "03fd6ceb-e399-4d03-be42-9ea078f054c9", "metadata": {}, "outputs": [], "source": [ "sample_times_ms = np.array([0, 4, 8, 12, 16, 24, 32, 48, 64, 96, 128, 192, 256, 384, 512, 768, 1024, 1536, 2048, 3072, 4096])\n" ] }, { "cell_type": "markdown", "id": "d8c09ace-f8fd-44cb-9a73-f43f21e781d2", "metadata": {}, "source": [ "# Adaptive magnitude sampling as convex hull" ] }, { "cell_type": "code", "execution_count": null, "id": "426cec34-6786-4bc2-b07f-f55ff5bf0636", "metadata": {}, "outputs": [], "source": [ "# New approach to linseg fitting - take all extrema, then filter down.\n", "filt_len = 31 # for D5\n", "#filt_len = 127 # for D4\n", "#filt_len = 1023\n", "filt_win = np.hanning(filt_len)/np.sum(np.hanning(filt_len))\n", "\n", "def lin_hull(x, ends=None):\n", " \"\"\"Return a linear interpolation between the first and last values of x (or ends[0], ends[1]), of the same length as x.\"\"\"\n", " if ends is None:\n", " ends = (x[0], x[-1])\n", " npts = len(x)\n", " return np.linspace(ends[0], ends[1], npts)\n", "\n", "def max_prominence(x, ends=None, polarity=1):\n", " \"\"\"Return index of point in x that is furthest above (below if polarity=-1) a line connecting the end points of x.\"\"\"\n", " prominence = polarity * (x - lin_hull(x, ends))\n", " argmax_prominence = np.argmax(prominence)\n", " if np.max(prominence) > 0:\n", " return argmax_prominence\n", " return None\n", "\n", "def err_from_line(x, ends=None, abs_fn=np.abs):\n", " \"\"\"Return sum(abs(error)) between x and line seg defined by ends.\"\"\"\n", " return np.sum(abs_fn(x - lin_hull(x, ends)))\n", "\n", "def convex_hull(x, points=None, polarity=1):\n", " \"\"\"Attempt to insert one new convex hull point in every interval defined by points.\"\"\"\n", " if points is None:\n", " points = [0, len(x) - 1]\n", " new_points = [0]\n", " for start in range(len(points) - 1):\n", " new_point = max_prominence(x[points[start]:points[start + 1] + 1], polarity)\n", " if new_point:\n", " new_points.append(points[start] + int(new_point))\n", " new_points.append(points[start + 1])\n", " return new_points\n", "\n", "def hull(x, npoints):\n", " \"\"\"Return npoints indices into x which attempt to provide a convex hull.\"\"\"\n", " points = [0, len(x) - 1]\n", " while len(points) < npoints:\n", " max_err = 0\n", " for i in range(len(points) - 1):\n", " start = points[i]\n", " end = points[i + 1]\n", " err = err_from_line(x[start : end]) / np.sqrt((end - start))\n", " #print(points, start, end, err, max_err)\n", " if abs(err) > max_err:\n", " max_err = abs(err)\n", " worst_seg_ix = i\n", " worst_start = points[worst_seg_ix]\n", " worst_end = points[worst_seg_ix + 1]\n", " polarity = 1 if err_from_line(x[worst_start : worst_end], abs_fn=np.asarray) > 0 else -1\n", " points.insert(worst_seg_ix + 1, int(worst_start + max_prominence(x[worst_start : worst_end], polarity=polarity)))\n", " return np.array(points)\n", "\n", "#h = convex_hull(mag_trim)\n", "#print(h)\n", "#h = convex_hull(mag_trim, h, -1)\n", "#print(h)\n", "#h = convex_hull(mag_trim, h)\n", "#print(h)\n", "#h = convex_hull(mag_trim, h, -1)\n", "#print(h)\n", "#h = convex_hull(mag_trim, h)\n", "#print(h)\n", "\n", "trim_start_samps = 128\n", "trim_end_samps = 1024\n", "\n", "hnum = 1\n", "mag_filt = lin_to_db(convolve(db_to_lin(mags[hnum]), filt_win, 'same'))\n", "mag_filt_trim = mag_filt[trim_start_samps:-trim_end_samps]\n", "max_times = scipy.signal.argrelmax(mag_filt_trim)[0]\n", "max_vals = mag_filt_trim[max_times]\n", "t = np.arange(len(mag_filt_trim)) / sr\n", "mmag = np.maximum(-130.0, mag_filt_trim)\n", "\n", "# Adaptive timing\n", "#h = hull(mmag, 12)\n", "# Fixed log-spaced timing\n", "h = np.round(sample_times_ms * 44.1).astype(np.int32)\n", "\n", "plt.figure(figsize=(16, 5))\n", "plt.subplot(121)\n", "#plt.plot(t, mmag, t[max_times], max_vals, 'o-')\n", "plt.plot(1000 * t, mmag)\n", "plt.plot(1000 * h / sr, mmag[h], 'o-')\n", "ylims = [-80, -20]\n", "t_lim = 0.15\n", "plt.xlim([0, 1000 * t_lim])\n", "#plt.legend(['mag', 'max_vals', 'hull'])\n", "plt.legend(['mag', 'hull'])\n", "plt.xlabel('time / ms')\n", "plt.ylabel('level / dB')\n", "plt.title('Envelope for harmonic %d of %s (%.1f Hz)' % (hnum, filename, est_f0))\n", "plt.ylim(ylims)\n", "plt.grid()\n", "plt.subplot(122)\n", "plt.plot(t, mmag)\n", "#plt.plot(t[max_times], max_vals, 'o-')\n", "plt.plot(h / sr, mmag[h], 'o-')\n", "# Line showing limit of left plot\n", "plt.plot([t_lim, t_lim], ylims, ':k')\n", "plt.xlim([0, 4.1])\n", "plt.ylim(ylims)\n", "plt.grid()\n", "plt.xlabel('time / s')\n", "print(h / 44.1)" ] }, { "cell_type": "code", "execution_count": null, "id": "758f0649-c7d5-4c2a-89e4-80a11689ff65", "metadata": {}, "outputs": [], "source": [ "# Convert sinusoids into bp sets\n", "\n", "# harms_params is a list of harmonic descriptions\n", "# each harmonic description is [const_freq, [(delta_time_ms, lin_mag), (delta_time_ms, lin_mag), ...]]\n", "\n", "def make_harms_params(mags, avg_freqs, max_harmonic=None, sr=44100, mag_floor=-100.0, terminal_slope=20.0, \n", " filt_len=31, adaptive_timing=True, verbose=False):\n", " if not max_harmonic:\n", " max_harmonic = mags.shape[0]\n", " \n", " dt = 1 / sr\n", " sm_cyc = 2.0\n", "\n", " #trim_ends_sec = 0.014\n", " #trim_ends_samps = int(round(trim_ends_sec * sr))\n", " trim_start_samps = 0 # 128\n", " trim_end_samps = 1024\n", "\n", " #filt_len = 31\n", " filt_win = np.hanning(filt_len)/np.sum(np.hanning(filt_len))\n", "\n", " harms_params = []\n", "\n", " for hnum in range(max_harmonic):\n", " mag_filt = lin_to_db(convolve(db_to_lin(mags[hnum]), filt_win, 'same'))\n", " mag_filt_trim = mag_filt[trim_start_samps : -trim_end_samps]\n", " #mag_filt_trim = mag_filt\n", " mmag = np.maximum(mag_floor, mag_filt_trim)\n", " if adaptive_timing:\n", " # Adaptive timing\n", " anchor_times = hull(mmag, 12)\n", " else:\n", " # Fixed log-spaced timing\n", " sample_times_ms = np.array([0, 4, 8, 12, 16, 24, 32, 48, 64, 96, 128, 192, 256, 384, 512, 768, 1024, 1536, 2048, 3072, 4096])\n", " anchor_times = np.round(sample_times_ms * 44.1).astype(np.int32)\n", " anchor_vals = mmag[anchor_times]\n", " nvals = list(zip([0] + list(np.diff(anchor_times)), anchor_vals))\n", " bp_list = [(int(round(n * dt * 1000)), float(db_to_lin(val))) \n", " for n, val in nvals]\n", " last_time, last_mag = bp_list[-1]\n", " last_mag_db = lin_to_db(last_mag)\n", " final_mag_db = mag_floor\n", " if adaptive_timing:\n", " if last_mag_db > final_mag_db:\n", " terminal_slope = terminal_slope # -db/sec\n", " final_dur = (last_mag_db - final_mag_db) / terminal_slope\n", " bp_list.append((int(round(1000 * final_dur)), float(db_to_lin(final_mag_db))))\n", " if adaptive_timing and bp_list[-1][1] == bp_list[-2][1]: # Final points have same mag\n", " bp_list = bp_list[:-1]\n", " bp_list_pair = [float(avg_freqs[hnum]), bp_list]\n", " if verbose:\n", " print(\"h\", hnum + 1, bp_list_pair)\n", " harms_params.append(bp_list_pair)\n", " return harms_params\n", "\n", "harms_params = make_harms_params(mags, avg_freqs, mag_floor=-130, verbose=False, adaptive_timing=False)\n", "for hp in harms_params:\n", " print(hp[0], len(hp[1]))\n" ] }, { "cell_type": "code", "execution_count": null, "id": "54a807c3-0072-45b4-a05a-226e1e0ba54c", "metadata": {}, "outputs": [], "source": [ "mags_dict = {}\n", "harms_dict = {}" ] }, { "cell_type": "code", "execution_count": null, "id": "43c1c74e-80e7-46a8-a663-6b759b86e424", "metadata": {}, "outputs": [], "source": [ "# Filename to parameters set\n", "#filenames = ['Piano.mf.C5.wav', 'Piano.ff.C5.wav', 'Piano.mf.D5.wav', 'Piano.ff.D5.wav']\n", "#filenames = ['Piano.pp.D4.wav', 'Piano.pp.D5.wav', 'Piano.mf.D4.wav', 'Piano.mf.D5.wav', 'Piano.ff.D4.wav', 'Piano.ff.D5.wav']\n", "\n", "# Original U Iowa piano samples from https://theremin.music.uiowa.edu/mispiano.html converted to wav format.\n", "# Note: The file called Piano.pp.C0.wav was actually just a copy of Piano.pp.B1.wav (with different cropping).\n", "# I fixed its pitch by resampling:\n", "# dpwe@dpwe-macbookpro:~/Downloads$ sox uiowa-piano/Piano.pp.C1.wav piano.wav speed 100c \n", "# dpwe@dpwe-macbookpro:~/Downloads$ cp piano.wav uiowa-piano/Piano.pp.C1.wav \n", "\n", "directory = '/Users/dpwe/Downloads/uiowa-piano'\n", "\n", "num_harms = 40 # was 20\n", "\n", "filenames = []\n", "\n", "for octave in range(1, 8):\n", " for note in ['C', 'E', 'Ab']:\n", " est_f0 = None\n", " for strike in ['ff', 'mf', 'pp']:\n", " filename = filename = filename_for_note(note, octave, strike)\n", " filenames.append(filename)\n", " d, sr = read_and_trim(os.path.join(directory, filename), \n", " channel=0, rel_threshold=0.015, abs_threshold=0.001, duration=5.0, pre_time=0.002)\n", " #print(d.shape)\n", " mags_dict[filename], recons_d, freqs, avg_freqs, est_f0 = extract_harmonics(d, num_harms=num_harms, est_f0=est_f0)\n", " print(time.ctime(), filename, '%.1f' % est_f0, ['%.1f' % float(v) for v in avg_freqs[:4]])\n", " #resid = d - recons_d\n", " harms_dict[filename] = make_harms_params(mags_dict[filename], avg_freqs, mag_floor=-130, adaptive_timing=False)" ] }, { "cell_type": "code", "execution_count": null, "id": "336ae992-222f-4fe9-9016-b9704d1734ec", "metadata": {}, "outputs": [], "source": [ "# Describe note as initial amp + dB slope for single linear fit.\n", "filt_len = 31\n", "filt_win = np.hanning(filt_len)/np.sum(np.hanning(filt_len))\n", "\n", "plt.figure(figsize=(12, 6))\n", "colors = plt.cm.rainbow(np.linspace(0, 1, 21))\n", "avg_h_decay = np.zeros(len(filenames))\n", "avg_h_mag = np.zeros(len(filenames))\n", "for i, filename in enumerate(filenames):\n", " #print(filename)\n", " #plt.subplot(1, 3, (i % 3) + 1)\n", " mags = mags_dict[filename]\n", "\n", " num_harmonics = min(12, mags.shape[0])\n", " h_init_amp = np.zeros(num_harmonics)\n", " h_decay = np.zeros(num_harmonics)\n", " h_nums = range(num_harmonics)\n", " for h in h_nums:\n", " mag_filt = lin_to_db(convolve(db_to_lin(mags[h]), filt_win, 'same'))\n", " mag_filt_trim = mag_filt[trim_end_samps:-trim_end_samps]\n", " t = np.arange(len(mag_filt_trim)) / sr\n", " linfit = lin_fit(mag_filt_trim)\n", " h_init_amp[h] = linfit[0]\n", " h_decay[h] = (linfit[-1] - linfit[0]) / (t[-1] - t[0])\n", " plt.plot(h_nums, h_decay, color=colors[i % len(colors)])\n", " plt.ylim([-20, 10])\n", " #plt.plot(h_nums, h_init_amp, color=colors[i])\n", " #\n", " #plt.plot(h_nums, lin_fit(h_decay), '--', h_nums, lin_fit(h_init_amp), '--', color=colors[i])\n", " #plt.plot(h_nums, h_decay, color=colors[i])\n", " #plt.plot(h_nums, lin_fit(h_decay), '--', color=colors[i])\n", " #plt.legend(['decay dB/sec', 'init amp/dB'])\n", " if i < 3:\n", " plt.grid()\n", " _ = plt.title(filename + ' avg dB/sec decay lin_fit harmonics')\n", " avg_h_decay[i] = np.mean(h_decay)\n", " avg_h_mag[i] = np.mean(h_init_amp)\n", "plt.legend(filenames)" ] }, { "cell_type": "code", "execution_count": null, "id": "48d1ba1b-4cac-449c-a6db-dc10186342d8", "metadata": {}, "outputs": [], "source": [ "note_indices = np.arange(len(avg_h_decay))\n", "plt.figure(figsize=(16, 4))\n", "plt.plot(note_indices, avg_h_decay, '.-')\n", "plt.plot(note_indices, avg_h_mag, '.-')\n", "plt.legend(['avg_h_decay', 'avg_h_mag'])\n", "plt.grid()" ] }, { "cell_type": "code", "execution_count": null, "id": "913bdbce-c0ed-4750-8f06-0366dc56ff05", "metadata": {}, "outputs": [], "source": [ "# Mapping here is 1/8 shrunk after the first 250 ms.\n", "def time_mapper(t, boundary=0.25, magnification=8.0):\n", " \"\"\"Convert time in secs to a nonlinear projection.\"\"\"\n", " #return np.log10(0.01 + t)\n", " t = np.asarray(t)\n", " magnified = (t < boundary)\n", " return magnified * t + (1 - magnified) * (boundary + (t - boundary) / magnification)\n", "\n", "def plot_mags(mags, filename, nharms=None, hop_len=64, sr=44100, mag_floor=-130.0, mag_ceil=-20.0, show_lin_fit=False):\n", " if not nharms:\n", " nharms = mags.shape[0]\n", " nfrm = mags[:nharms, ::hop_len].shape[-1]\n", " frmTime = np.arange(nfrm) * hop_len / sr\n", " colors = plt.cm.rainbow(np.linspace(0, 1, max(12, nharms)))\n", "\n", " boundary = 0.25\n", " magnification = 8.0\n", "\n", " for i in range(nharms):\n", " plt.plot(time_mapper(frmTime[:nfrm]), mags[i, ::hop_len].T, '.', color=colors[i])\n", " if show_lin_fit:\n", " lin_fit_mag = lin_fit(mags[i, ::hop_len])\n", " plt.plot(time_mapper(frmTime[:nfrm]), lin_fit_mag, '--', color=colors[i])\n", "\n", " plt.plot(time_mapper([boundary, boundary]), [mag_floor, mag_ceil], '--k')\n", " plt.ylim([mag_floor, mag_ceil])\n", " xtimes = np.hstack([np.arange(0, 0.25, 0.0625), np.arange(0.5, 5.0, 0.5)])\n", " plt.xlim([0, time_mapper(5.0)])\n", " plt.xticks(time_mapper(xtimes), xtimes)\n", " plt.legend(1 + np.arange(nharms), loc='upper right')\n", " _ = plt.title((filename + ' - ' + str(nharms) + ' harmonics'))\n", " \n", "\n", "def plot_harms(harms_params, filename, nharms=None, hop_len=64, sr=44100, mag_floor=-130.0, mag_ceil=-20.0):\n", " if not nharms:\n", " nharms = len(harms_params)\n", " nfrm = mags[:nharms, ::hop_len].shape[-1]\n", " frmTime = np.arange(nfrm) * hop_len / sr\n", " colors = plt.cm.rainbow(np.linspace(0, 1, max(12, nharms)))\n", "\n", " # Mapping here is 1/8 shrunk after the first 250 ms.\n", " boundary = 0.25\n", " magnification = 8.0\n", "\n", " for i, hp in enumerate(harms_params):\n", " times, vals = zip(*np.array(hp[1]))\n", " times = np.cumsum(times) / 1000\n", " vals = np.array(vals)\n", " plt.fill_between(time_mapper(times), mag_floor, lin_to_db(vals), alpha=0.8, color=colors[i])\n", " plt.plot(time_mapper([boundary, boundary]), [mag_floor, -mag_ceil], '--k')\n", " plt.ylim([mag_floor, mag_ceil])\n", " plt.legend(1 + np.arange(nharms))\n", " xtimes = np.hstack([np.arange(0, 0.25, 0.0625), np.arange(0.5, 5.0, 0.5)])\n", " plt.xticks(time_mapper(xtimes), xtimes)\n", " plt.xlim([0, time_mapper(5.0)])\n", " _ = plt.title((filename + ' - ' + str(nharms) + ' harmonics'))\n" ] }, { "cell_type": "code", "execution_count": null, "id": "bbd3fe33-19d5-4712-b652-76800dd98ba2", "metadata": { "scrolled": true }, "outputs": [], "source": [ "plt.figure(figsize=(15, 15))\n", "for i, filename in enumerate(filenames[:9]):\n", " plt.subplot(3, 3, i + 1)\n", " plot_mags(mags_dict[filename], filename, show_lin_fit=True)\n", " #plot_harms(harms_dict[filename], filename)" ] }, { "cell_type": "code", "execution_count": null, "id": "babe00ef-9fd2-4e74-aace-5beeec878f25", "metadata": {}, "outputs": [], "source": [ "plt.figure(figsize=(15, 15))\n", "for i, filename in enumerate(filenames[:9]):\n", " plt.subplot(3, 3, i + 1)\n", " #plot_mags(mags_dict[filename], filename)\n", " plot_harms(harms_dict[filename], filename)" ] }, { "cell_type": "code", "execution_count": null, "id": "5ae6a2d7-3fbd-4a87-8b10-7ba588892260", "metadata": {}, "outputs": [], "source": [ "def time_mapper(t, boundary=0.25, magnification=8.0):\n", " \"\"\"Convert time in secs to a nonlinear projection.\"\"\"\n", " return np.log10(0.01 + t)\n", " #t = np.asarray(t)\n", " #magnified = (t < boundary)\n", " #return magnified * t + (1 - magnified) * (boundary + (t - boundary) / magnification)\n", "\n", "def inv_time_mapper(mapped_t, boundary=0.25, magnification=8.0):\n", " magnified = mapped_t < boundary\n", " return magnified * mapped_t + (1 - magnified) * (boundary + magnification * (mapped_t - boundary))\n", "\n", "from matplotlib.collections import PolyCollection\n", "\n", "def polygon_under_graph(x, y):\n", " return [(x[0], 0.), *zip(x, y), (x[-1], 0.)]\n", "\n", "#filename = filename_for_note(note='C', octave=4, strike='ff')\n", "\n", "def harmonics_waterfall_plot(filename, axes=None):\n", " global harms_dict\n", " if axes == None:\n", " axes = fig.add_subplot(projection='3d')\n", " verts = []\n", " mag_floor = -130\n", " for i, hp in list(enumerate(harms_dict[filename])):\n", " times, vals = zip(*np.array(hp[1]))\n", " times = np.cumsum(times) / 1000\n", " vals = np.array(vals)\n", " times = np.hstack([[times[0]], times])\n", " vals = np.hstack([[db_to_lin(mag_floor)], vals])\n", " #plt.plot(np.log10(0.01 + times), lin_to_db(vals), zs=-i, zdir='y', alpha=0.8, color=colors[i])\n", " #poly = axes.add_collection3d(plt.fill_between(2 + np.log10(0.01 + times), -100, lin_to_db(vals), alpha=0.8, color=colors[i]), \n", " # zs=(i + 1), zdir='y')\n", " verts.append(polygon_under_graph(time_mapper(times), -mag_floor + lin_to_db(vals)))\n", " facecolors = plt.colormaps['rainbow'](np.linspace(0, 1, len(verts)))\n", " poly = PolyCollection(verts, facecolors=facecolors, alpha=.7)\n", " axes.add_collection3d(poly, zs=np.arange(len(harms_dict[filename]), 0, -1), zdir='y')\n", " axes.set_zlim(0, 120)\n", " axes.set_zlabel('level / dB')\n", " \n", " plt.title(filename)\n", " plt.xlabel('time / s')\n", " #tick_times = np.array([0, 0.1, 0.2, 1.0, 2.0, 3.0, 4.0])\n", " tick_times = np.array([0, 0.02, 0.05, 0.1, 0.2, 0.5, 1.0, 2.0, 5.0])\n", " plt.xticks(time_mapper(tick_times), tick_times)\n", " #plt.xlim([-0.05, 0.8])\n", " plt.ylabel('harm #')\n", " plt.yticks(np.arange(2, 22, 2), np.arange(19, -1, -2))\n", " #plt.zlabel('level / dB')\n", "\n", " #plt.zlim([-100, -20])\n", " #plt.legend(1 + np.arange(nharms))\n", " #plt.xticks(np.log10(0.01 + xtimes), xtimes)\n", " #plt.xlim([0, 3000])\n", " #_ = plt.title((filename + ' - ' + str(nharms) + ' harmonics'))\n", " axes.view_init(elev=20., azim=-115, roll=0)\n", "\n", "#fig = plt.figure(figsize=(8, 6))\n", "\n", "plt.figure(figsize=(18, 6))\n", "axes = plt.subplot(131, projection='3d')\n", "note = 'C'\n", "octave = 4\n", "harmonics_waterfall_plot(filename_for_note(note, octave, 'pp'), axes=axes)\n", "axes = plt.subplot(132, projection='3d')\n", "harmonics_waterfall_plot(filename_for_note(note, octave, 'mf'), axes=axes)\n", "axes = plt.subplot(133, projection='3d')\n", "harmonics_waterfall_plot(filename_for_note(note, octave, 'ff'), axes=axes)" ] }, { "cell_type": "code", "execution_count": null, "id": "a332f17f-5863-4a99-8399-3dc7c5661f9d", "metadata": {}, "outputs": [], "source": [ "import json\n", "print(filename.split('.'))\n", "params_file = '.'.join(filename.split('.', -1)[:-1]) + '.json'\n", "print(params_file)\n", "with open(params_file, 'w') as f:\n", " f.write(json.dumps(harms_params))\n", "print('saved to', params_file)" ] }, { "cell_type": "code", "execution_count": null, "id": "63de5760-ec44-4246-8ede-17050a2ede1d", "metadata": {}, "outputs": [], "source": [ "import itertools\n", "\n", "hps = harms_params[0]\n", "bps = np.array(hps[1])\n", "print(bps[:, 0])\n", "plt.plot(expand_params(list(itertools.chain.from_iterable(bps))[1:]))\n", "plt.plot(np.cumsum(bps[:, 0]), bps[:, 1], '.')\n", "_ = plt.xlim(0, 10000)" ] }, { "cell_type": "code", "execution_count": null, "id": "e346232b-bddf-45cc-929a-c9d90d859efc", "metadata": {}, "outputs": [], "source": [ "# Synthesize various versions.\n", "# Original magnitudes, fixed frequencies\n", "\n", "def synth_harm_param(harm_param, sr=44100):\n", " \"\"\"Synthesize a single harmonic described by a harm_param structure.\"\"\"\n", " # harm_param is [freq, [(dtime_ms, mag), (dtime_ms, mag), ...]]\n", " freq, breakpoints = harm_param\n", " breakpoints = np.array(breakpoints)\n", " breakpoints[:, 1] = lin_to_db(breakpoints[:, 1])\n", " # magnitudes interpolated on millisecond scale in log domain.\n", " # First value is assumed to be zero, so dropped.\n", " mags = expand_params(list(itertools.chain.from_iterable(breakpoints))[1:])\n", " return synth_harmonic(freq, mags, interp_factor=int(round(sr / 1000)), sample_rate=sr, mag_is_db=True)\n", "\n", "\n", "def synth_params(harms_params, verbose=False):\n", " \"\"\"Synthesize a note described by a list of harm_param structures.\"\"\"\n", " upper_bound_len_samples = 44100 * 10\n", " result = np.zeros(upper_bound_len_samples)\n", " max_harm_len_samples = 0\n", " for hp in harms_params:\n", " harm_audio = synth_harm_param(hp)\n", " harm_len_samples = len(harm_audio)\n", " result[:harm_len_samples] += harm_audio\n", " max_harm_len_samples = np.maximum(max_harm_len_samples, harm_len_samples)\n", " return result[:max_harm_len_samples], harm_audio\n", "\n", "\n", "def synth_params_orig(harms_params, verbose=False):\n", " # Older version does not use the common synth_harmonic function.\n", " result = np.zeros(0)\n", " for f0, hp in harms_params:\n", " # ignore first time, start list with first value.\n", " params = [lin_to_db(hp[0][1])]\n", " # Step through remaining pairs, converting times in ms to samples\n", " for bpp in hp[1:]:\n", " params.extend([int(round(bpp[0] * sr/1000)), lin_to_db(bpp[1])])\n", " # Expand (val, npoints, val, npoints..., val) list\n", " ep = expand_params(params)\n", " carrier = np.cos(2 * np.pi * f0 * np.arange(len(ep)) / sr)\n", " ep_len = len(ep)\n", " if ep_len > len(result):\n", " result = np.hstack([result, np.zeros(ep_len - len(result))])\n", " result[:ep_len] += db_to_lin(ep) * carrier\n", " if verbose:\n", " print(f0)\n", " return result, ep\n", "\n", "#audio, ep = synth_params([harms_params[i] for i in 1 + np.arange(10)])\n", "#filename = 'Piano.ff.C4.wav'\n", "filename = 'Piano.ff.C3.wav'\n", "#hd = harms_dict[filename][:40]\n", "# How does it sound if we skip some of the higher harmonics?\n", "# In particular, above the 16th harmonic, skip harmonics that are 2.n.f0 and 3.n.f0. This lets us get higher, for brighter sounds, \n", "# and the missing harmonics aren't particularly noticeable in those regions.\n", "hd = [harms_dict[filename][i] for i in [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 18, 22, 24, 28, 30, 34, 36]]\n", "h_audio, ep = synth_params(hd)\n", "#h_audio, ep = synth_params(harms_params)\n", "\n", "#f0 = harms_params[0][0]\n", "#carrier = np.cos(2 * np.pi * f0 * np.arange(len(ep)) / sr)\n", "\n", "#ii = np.arange(20000)\n", "ii = np.arange(4000)\n", "#plt.plot(t[ii], db_to_lin(mags[h_num - 1][ii]))\n", "#plt.plot(t[ii], db_to_lin(ep[ii]))\n", "#plt.title(filename)\n", "npts = len(resid)\n", "audio = h_audio[:npts] # + resid\n", "Audio(data=audio, rate=sr)\n", "print(audio.shape, resid.shape, sr)\n", "#old_audio = audio\n", "start_pt = 950\n", "npts = 100\n", "plt.plot((start_pt + np.arange(npts)) / sr, audio[start_pt : start_pt + npts])\n", "# (start_pt + np.arange(npts)) / sr, old_audio[start_pt : start_pt + npts])\n" ] }, { "cell_type": "code", "execution_count": null, "id": "ad4e2638-a2e3-48ac-a0af-e26085bb9646", "metadata": {}, "outputs": [], "source": [ "print(filename, len(audio), sr)\n", "Audio(data=audio, rate=sr)" ] }, { "cell_type": "code", "execution_count": null, "id": "a32e7895-40b6-4ce3-ba32-cadfa79d2eec", "metadata": {}, "outputs": [], "source": [ "print(filename, len(audio), sr)\n", "Audio(data=audio, rate=sr)" ] }, { "cell_type": "code", "execution_count": null, "id": "ff874fcf-dc6a-49e0-b144-74580dc34f28", "metadata": {}, "outputs": [], "source": [ "waveform, sr = read_and_trim(os.path.join(directory, filename), channel=0, duration=5.0, rel_threshold=0.010, abs_threshold=0.001, do_plot=False, pre_time=0.01)\n", "Audio(data=waveform, rate=sr)" ] }, { "cell_type": "code", "execution_count": null, "id": "147eba90-e290-4f3f-b62a-7c082249da3b", "metadata": {}, "outputs": [], "source": [ "def interp_harm_param(hp0, hp1, alpha):\n", " \"\"\"Return harm_param list that is alpha of the way to hp1 from hp0.\"\"\"\n", " hp = []\n", " for h0, h1 in zip(hp0, hp1):\n", " f_a = np.exp(np.log(h0[0]) + alpha * (np.log(h1[0]) - np.log(h0[0])))\n", " #if (abs(h0[0] - h1[0]) / (0.5 * (h0[0] + h1[0]))) > 0.1:\n", " # print(\"warn: interpolating\", h0[0], \"and\", h1[0])\n", " # Don't warn since we're interpolating between notes too.\n", " bps = []\n", " eps = 1e-9\n", " for bp0, bp1 in zip(h0[1], h1[1]):\n", " bp = (bp0[0] + alpha * (bp1[0] - bp0[0]), np.exp(-eps + np.log(bp0[1] + eps) + alpha * (np.log(bp1[1] + eps) - np.log(bp0[1] + eps))))\n", " bps.append(bp)\n", " hp.append((f_a, bps))\n", " return hp\n", "\n", "def print_hp(harm_params, max_harms=8):\n", " print('***')\n", " for harm_param in harm_params[:max_harms]:\n", " s = '%.1f ' % harm_param[0]\n", " for bp in harm_param[1][:8]:\n", " s += '%d, %.1f / ' % (bp[0], 1000 * bp[1])\n", " print(s)\n", "\n", "alpha = 0.9\n", "#ns = ['Piano.mf.E3.wav', 'Piano.mf.Ab3.wav', 'Piano.mf.C4.wav']\n", "ns = ['Piano.pp.C4.wav', 'Piano.mf.C4.wav', 'Piano.ff.C4.wav']\n", "\n", "#print_hp(harms_dict[n1])\n", "#print_hp(harms_dict[n2])\n", "#print_hp(interp_harm_param(harms_dict[n1], harms_dict[n2], alpha))\n", "#Audio(data=synth_params(interp_harm_param(harms_dict[n1], harms_dict[n2], alpha))[0], rate=sr)\n", "w = []\n", "for start in [0, 1]:\n", " n1 = ns[start]\n", " n2 = ns[start + 1]\n", " for alpha in np.linspace(0, 1, 4, endpoint=False):\n", " w.append(synth_params(interp_harm_param(harms_dict[n1], harms_dict[n2], alpha))[0][:sr])\n", "w = np.concat(w)\n", "Audio(data=w, rate=sr)" ] }, { "cell_type": "code", "execution_count": null, "id": "06082d70-e4f1-4471-ba16-b20af0fc7121", "metadata": {}, "outputs": [], "source": [ "wavwrite(w, sr, '/tmp/tmp.wav')" ] }, { "cell_type": "code", "execution_count": null, "id": "38a1588a-90b0-4e59-ad33-b38455c83db6", "metadata": {}, "outputs": [], "source": [ "# Compare to pure scaling\n", "audio = synth_params(harms_dict[ns[1]])[0][:sr]\n", "ww = []\n", "for alpha in np.linspace(0, np.log(100/7), 10):\n", " ww.append(np.exp(alpha) * 0.2 * audio)\n", "ww = np.concat(ww)\n", "wavwrite(ww, sr, '/tmp/tmp2.wav')" ] }, { "cell_type": "markdown", "id": "0d1e2e2e-70d3-4447-aee5-c67b0fdb94e7", "metadata": {}, "source": [ "# New plan:\n", "- Each note is described by a conformal set of parameters\n", " - exactly one param set per harmonic (so harmonics of different notes are always in the same place)\n", " - harmonic envelopes are sampled at a fixed set of log-spaced times (so we can interpolate notes without changing timing)\n", "We write the analysis out as a big blob:\n", " - A single vector of harmonic envelope time intervals (odd-numbered values of BP lists, e.g. 20 of them)\n", " - An array giving the base note, base velocity, and # harmonics for all the described notes. For octaves 1-7 with 3 notes/oct ('C', 'E', 'Ab') and 3 velocities ('pp', 'mf', 'ff'), that's 63 notes. At up to 20 harmonics per ote, that's 1260 harmonics.\n", " - A big array giving the 20 target values per harmonic per note. Maybe these should be in dB, and 8 bit integers? With 1260 harmonics, that's a total of 25,200 values (100 kB in float32)." ] }, { "cell_type": "code", "execution_count": null, "id": "14e41472-4bdc-45e1-9544-7e7785669527", "metadata": {}, "outputs": [], "source": [ "# Construct the piano-params.json file.\n", "# Contents are:\n", "# sample_times_ms - single vector of fixed log-spaced envelope sample times (in int16 integer ms)\n", "# notes - Array of MIDI notes\n", "# velocities - Array of strike velocities available for each note, the same for all notes\n", "# num_harmonics - Array of (num_notes * num_velocities) counts of how many harmonics are defined for each note.\n", "# harmonics_freq - Vector of (total_num_harmonics) int16s giving freq for each harmonic in cents 6900 = 440 Hz.\n", "# harmonics_mags - Array of (total_num_harmonics, 20) uint8s giving 20 envelope samples for each harmonic. In dB re: -130.\n", "\n", "# sample_times_ms is defined upscript.\n", "#print(f'{len(sample_times_ms)=}')\n", "#print(sample_times_ms)\n", "\n", "def filename_of_note_vel(note, vel):\n", " return ('Piano.' + \n", " {40: 'pp', 80: 'mf', 120: 'ff'}[velocity] + \n", " '.' +\n", " {0: 'C', 4: 'E', 8: 'Ab'}[note % 12] + str((note - 12) // 12) + \n", " '.wav')\n", "\n", "def note_vel_of_filename(filename):\n", " _, vel, note, _ = filename.split('.')\n", " vel_val = {'pp': 40, 'mf': 80, 'ff': 120}[vel]\n", " note_name = note[:-1]\n", " note_oct = int(note[-1])\n", " note_val = {'C': 0, 'E': 4, 'Ab': 8}[note_name] + 12 * note_oct + 12 # C4 is midi note 60.\n", " return note_val, vel_val\n", "\n", "# Extract notes from filenames.\n", "assert set(filenames) == set(harms_dict.keys())\n", "velocities = set()\n", "notes = set()\n", "for filename in filenames:\n", " note_val, strike_val = note_vel_of_filename(filename)\n", " velocities.add(strike_val)\n", " notes.add(note_val)\n", "\n", "notes = sorted(notes)\n", "velocities = sorted(velocities)\n", "#print(notes)\n", "\n", "num_harmonics = []\n", "\n", "for note in notes:\n", " for velocity in velocities:\n", " filename = filename_of_note_vel(note, velocity)\n", " num_harmonics.append(len(harms_dict[filename]))\n", "\n", "total_num_harmonics = sum(num_harmonics)\n", "\n", "harmonics_freq = np.zeros(total_num_harmonics, dtype=int)\n", "harmonics_mags = np.zeros((total_num_harmonics, len(sample_times_ms) - 1), dtype=int)\n", "harmonic_index = 0\n", "\n", "def hz_to_cents(freq_hz):\n", " \"\"\"Convert freq in hz to cents: 6000 = C4 = 261.63, 6900 = A4 = 440.0.\"\"\"\n", " return np.round(1200 * np.log2(freq_hz / 440.0) + 6900).astype(int)\n", "\n", "def cents_to_hz(cents):\n", " \"\"\"Convert freq cents back to Hzin hz to real-valued midi: 60 = C4 = 261.63, 69 = A4 = 440.0.\"\"\"\n", " return 440 * np.exp2((cents - 6900) / 1200)\n", "\n", "\n", "print(hz_to_cents(440))\n", "print(hz_to_cents(444))\n", "print(cents_to_hz(hz_to_cents(444)))\n", "\n", "for note in notes:\n", " for velocity in velocities:\n", " filename = filename_of_note_vel(note, velocity)\n", " harm_data = harms_dict[filename]\n", " print(filename, \":\", len(harm_data), \"harmonics\")\n", " for harm in harm_data:\n", " # harm is [freq, [(time, mag), (time, mag), ...]]\n", " # Round to 1 dp.\n", " #harmonics_freq[harmonic_index] = np.round(10 * harm[0]) / 10.0\n", " # Store freq in \"midi cents\" (a440 = 6900)\n", " harmonics_freq[harmonic_index] = hz_to_cents(harm[0])\n", " mag_info = np.array(harm[1])\n", " # mag_info may include a final value which is not at a fixed time if it needed a \"run out\" to get down to -60dB.\n", " len_mag_info = mag_info.shape[0]\n", " if len_mag_info > len(sample_times_ms):\n", " # print(f'{len_mag_info=} {len(sample_times_ms) + 1=}')\n", " mag_info = mag_info[:-1]\n", " #print(mag_info.T)\n", " assert np.all(np.cumsum(mag_info[:, 0]) == sample_times_ms)\n", " # Offset all harmonics mags as rounded to dB re: -130, the min from above.\n", " harmonics_mags[harmonic_index] = 130 + np.round(lin_to_db(mag_info[1:, 1])).astype(int)\n", " harmonic_index += 1\n", "\n", "# 3 notes per octave; 20 harmonics per note (for low notes), so C4 = 3 octaves in = 180 harmonics in.\n", "print(harmonics_freq[178:190])\n", "print(harmonics_mags[178:190])\n", "print(harmonic_index, \"total harmonics in\", len(notes) * len(velocities), \"notes\")" ] }, { "cell_type": "code", "execution_count": null, "id": "a012cd30-f232-4c00-a7d9-5d4437e351f5", "metadata": {}, "outputs": [], "source": [ "# Save out the json file.\n", "data = {\n", " # Drop the initial zero in sample_times_ms. Initial sample is always 0.\n", " 'sample_times_ms': sample_times_ms[1:].tolist(),\n", " 'notes': notes,\n", " 'velocities': velocities,\n", " 'num_harmonics': num_harmonics,\n", " 'harmonics_freq': harmonics_freq.tolist(),\n", " 'harmonics_mags': harmonics_mags.tolist(),\n", "}\n", "json_file = 'piano-params.json'\n", "with open(json_file, 'w') as f:\n", " f.write(json.dumps(data))\n", "print('saved to', json_file)" ] }, { "cell_type": "code", "execution_count": null, "id": "e2a8b257-09fa-4b6d-b1f6-62e238138151", "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.12.6" } }, "nbformat": 4, "nbformat_minor": 5 } ================================================ FILE: experiments/piano_params.py ================================================ # Notes params generated by piano_heterodyne.ipynb notes_params = {"sample_times_ms": [4, 8, 12, 16, 24, 32, 48, 64, 96, 128, 192, 256, 384, 512, 768, 1024, 1536, 2048, 3072, 4096], "notes": [24, 28, 32, 36, 40, 44, 48, 52, 56, 60, 64, 68, 72, 76, 80, 84, 88, 92, 96, 100, 104], "velocities": [40, 80, 120], "num_harmonics": [20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 17, 17, 17, 13, 13, 13, 11, 11, 11, 9, 8, 9, 7, 7, 7, 6, 5, 5, 3, 4, 4], "harmonics_freq": [2363, 3491, 4191, 4691, 5081, 5398, 5667, 5899, 6109, 6297, 6466, 6621, 6765, 6899, 7024, 7142, 7255, 7361, 7462, 7559, 2172, 3587, 4287, 4787, 5175, 5493, 5762, 5996, 6205, 6393, 6561, 6716, 6860, 6993, 7118, 7238, 7349, 7456, 7556, 7653, 2394, 3588, 4289, 4787, 5176, 5495, 5764, 5998, 6207, 6395, 6564, 6717, 6862, 6995, 7120, 7241, 7351, 7458, 7557, 7654, 2851, 3989, 4692, 5187, 5576, 5893, 6161, 6394, 6600, 6785, 6952, 7105, 7246, 7379, 7501, 7616, 7724, 7828, 7925, 8019, 3069, 3987, 4692, 5187, 5577, 5892, 6161, 6393, 6600, 6784, 6952, 7105, 7246, 7379, 7501, 7616, 7725, 7828, 7926, 8019, 3008, 3989, 4693, 5188, 5577, 5894, 6162, 6395, 6601, 6785, 6953, 7106, 7247, 7379, 7502, 7617, 7726, 7829, 7927, 8019, 3114, 4391, 5094, 5596, 5984, 6300, 6567, 6804, 7008, 7191, 7358, 7512, 7653, 7784, 7906, 8022, 8130, 8233, 8330, 8424, 3224, 4390, 5096, 5595, 5983, 6299, 6567, 6800, 7006, 7190, 7358, 7512, 7653, 7784, 7906, 8022, 8130, 8232, 8330, 8422, 3275, 4391, 5099, 5598, 5985, 6300, 6567, 6805, 7008, 7191, 7358, 7513, 7654, 7785, 7907, 8022, 8130, 8233, 8330, 8423, 3610, 4789, 5497, 5999, 6386, 6702, 6972, 7205, 7411, 7596, 7763, 7916, 8055, 8189, 8314, 8427, 8551, 8655, 8819, 8852, 3623, 4792, 5493, 5999, 6385, 6702, 6972, 7205, 7411, 7596, 7763, 7916, 8054, 8189, 8313, 8426, 8538, 8639, 8737, 8831, 3646, 4792, 5491, 6000, 6386, 6703, 6973, 7206, 7412, 7597, 7764, 7919, 8054, 8190, 8313, 8427, 8540, 8641, 8739, 8832, 4008, 5200, 5904, 6402, 6790, 7106, 7376, 7608, 7815, 7998, 8165, 8318, 8460, 8591, 8716, 8828, 8942, 9042, 9140, 9229, 4008, 5200, 5903, 6403, 6789, 7106, 7376, 7607, 7815, 7999, 8165, 8318, 8460, 8591, 8714, 8828, 8937, 9040, 9137, 9228, 4010, 5201, 5903, 6404, 6790, 7108, 7376, 7608, 7816, 7999, 8166, 8318, 8461, 8592, 8714, 8829, 8938, 9040, 9137, 9228, 4398, 5600, 6302, 6802, 7189, 7506, 7774, 8007, 8213, 8398, 8566, 8720, 8860, 8992, 9130, 9234, 9347, 9448, 9543, 9645, 4398, 5599, 6303, 6801, 7188, 7507, 7773, 8006, 8213, 8397, 8565, 8717, 8858, 8990, 9112, 9227, 9334, 9438, 9536, 9629, 4400, 5598, 6304, 6803, 7190, 7508, 7775, 8008, 8215, 8398, 8566, 8718, 8860, 8991, 9113, 9228, 9337, 9440, 9536, 9629, 4782, 6001, 6703, 7203, 7591, 7907, 8175, 8410, 8623, 8800, 8966, 9124, 9265, 9407, 9526, 9658, 9778, 9886, 9995, 10084, 4797, 6000, 6702, 7204, 7591, 7907, 8174, 8407, 8615, 8797, 8964, 9117, 9258, 9389, 9511, 9625, 9735, 9837, 9934, 10027, 4801, 6002, 6703, 7205, 7592, 7908, 8176, 8408, 8616, 8798, 8966, 9118, 9259, 9390, 9512, 9626, 9736, 9838, 9934, 10028, 5204, 6408, 7107, 7608, 7994, 8311, 8580, 8812, 9020, 9202, 9373, 9527, 9666, 9802, 9927, 10042, 10158, 10256, 10348, 10446, 5206, 6408, 7107, 7608, 7994, 8311, 8580, 8812, 9019, 9205, 9372, 9526, 9667, 9799, 9916, 10038, 10147, 10251, 10349, 10444, 5208, 6409, 7108, 7609, 7995, 8312, 8581, 8812, 9020, 9205, 9373, 9527, 9668, 9800, 9921, 10039, 10147, 10252, 10351, 10443, 5606, 6807, 7508, 8009, 8396, 8714, 8994, 9205, 9428, 9629, 9787, 9941, 10072, 10212, 10347, 10463, 10569, 10668, 10765, 10858, 5603, 6807, 7509, 8009, 8396, 8714, 8983, 9216, 9423, 9609, 9778, 9932, 10072, 10209, 10335, 10452, 10563, 10667, 10767, 10863, 5599, 6808, 7510, 8010, 8397, 8715, 8984, 9217, 9425, 9611, 9779, 9934, 10075, 10210, 10334, 10451, 10562, 10667, 10767, 10862, 6002, 7204, 7909, 8408, 8797, 9126, 9394, 9638, 9844, 10034, 10201, 10348, 10493, 10621, 10748, 10862, 10970, 11069, 11174, 11257, 6003, 7204, 7908, 8408, 8796, 9115, 9385, 9621, 9828, 10021, 10187, 10345, 10491, 10627, 10753, 10871, 10986, 11088, 11192, 11288, 6004, 7205, 7909, 8408, 8797, 9115, 9386, 9621, 9829, 10018, 10187, 10344, 10489, 10624, 10751, 10871, 10984, 11092, 11195, 11293, 6406, 7603, 8310, 8811, 9197, 9528, 9807, 10043, 10310, 10430, 10611, 10767, 10911, 11047, 11174, 11285, 11400, 11508, 11611, 11699, 6409, 7602, 8310, 8811, 9201, 9522, 9794, 10031, 10263, 10429, 10610, 10767, 10921, 11054, 11187, 11305, 11406, 11526, 11633, 11728, 6410, 7602, 8310, 8812, 9202, 9522, 9795, 10031, 10241, 10432, 10606, 10764, 10909, 11053, 11183, 11307, 11421, 11535, 11641, 11743, 6806, 8006, 8712, 9210, 9616, 9933, 10237, 10412, 10652, 10840, 11011, 11164, 11299, 11410, 11549, 11675, 11779, 11888, 11975, 12073, 6807, 8006, 8713, 9214, 9606, 9928, 10202, 10441, 10658, 10855, 11030, 11209, 11350, 11483, 11616, 11733, 11855, 11956, 12071, 12180, 6808, 8007, 8714, 9215, 9607, 9929, 10203, 10442, 10656, 10850, 11025, 11260, 11338, 11485, 11618, 11744, 11868, 11975, 12091, 12198, 7203, 8404, 9117, 9628, 10035, 10354, 10659, 10914, 11147, 11380, 11552, 11716, 11904, 12052, 12205, 12350, 12490, 12629, 12753, 12885, 7203, 8405, 9112, 9616, 10012, 10339, 10621, 10863, 11067, 11254, 11419, 11587, 11729, 11876, 12000, 12124, 12241, 12353, 12456, 12562, 7203, 8406, 9112, 9617, 10012, 10337, 10615, 10859, 11077, 11248, 11460, 11652, 11791, 11940, 12076, 12212, 12324, 12430, 12541, 12648, 7606, 8805, 9529, 10039, 10389, 10754, 11037, 11275, 11460, 11674, 11852, 12002, 12155, 12296, 12430, 12553, 12680, 12791, 12898, 13007, 7607, 8809, 9516, 10022, 10413, 10745, 11028, 11274, 11465, 11672, 11849, 12002, 12160, 12296, 12430, 12553, 12673, 12793, 12899, 13003, 7607, 8809, 9516, 10020, 10415, 10744, 11025, 11273, 11492, 11680, 11880, 12068, 12212, 12358, 12494, 12627, 12752, 12878, 12993, 13110, 8006, 9206, 9946, 10405, 10854, 11193, 11444, 11706, 11936, 12136, 12320, 12490, 12660, 12814, 12959, 13093, 13237, 8007, 9203, 9925, 10423, 10846, 11183, 11436, 11694, 11926, 12117, 12295, 12461, 12621, 12767, 12911, 13051, 13177, 8008, 9212, 9921, 10428, 10830, 11162, 11443, 11703, 11930, 12135, 12321, 12495, 12659, 12815, 12960, 13102, 13241, 8400, 9616, 10349, 10895, 11315, 11634, 11922, 12169, 12402, 12618, 12813, 13015, 13183, 8398, 9607, 10331, 10859, 11293, 11620, 11911, 12158, 12386, 12597, 12790, 12979, 13148, 8400, 9614, 10323, 10842, 11255, 11606, 11902, 12163, 12395, 12617, 12820, 13012, 13186, 8802, 10047, 10789, 11338, 11714, 12032, 12335, 12599, 12833, 13055, 13264, 8809, 10024, 10758, 11307, 11704, 12027, 12332, 12600, 12838, 13051, 13262, 8810, 10018, 10730, 11263, 11677, 12025, 12336, 12607, 12848, 13066, 13282, 9119, 10411, 11221, 11722, 12116, 12449, 12735, 13015, 13246, 9211, 10418, 11212, 11719, 12131, 12476, 12767, 13048, 9216, 10420, 11163, 11688, 12105, 12453, 12745, 13030, 13271, 9341, 10828, 11588, 12106, 12512, 12830, 13106, 9578, 10866, 11617, 12155, 12598, 12960, 13292, 9613, 10827, 11575, 12112, 12547, 12902, 13211, 9520, 11256, 12011, 12541, 12935, 13269, 9943, 11276, 12039, 12603, 13022, 9996, 11242, 12016, 12585, 13016, 8908, 11863, 12902, 10199, 11574, 12376, 12924, 10409, 11646, 12421, 12947], "harmonics_mags": [[39, 40, 41, 41, 38, 38, 39, 40, 40, 46, 43, 40, 22, 40, 32, 31, 36, 34, 44, 37], [52, 53, 55, 56, 56, 52, 45, 53, 47, 50, 50, 53, 52, 53, 52, 52, 52, 50, 47, 46], [65, 68, 70, 72, 73, 73, 72, 73, 72, 72, 72, 73, 72, 72, 71, 71, 70, 70, 68, 67], [69, 71, 72, 73, 75, 76, 77, 77, 75, 75, 76, 75, 75, 74, 73, 71, 69, 68, 64, 59], [69, 71, 72, 73, 74, 73, 74, 74, 75, 74, 74, 74, 73, 73, 71, 70, 67, 64, 59, 55], [68, 70, 72, 73, 75, 76, 77, 76, 73, 73, 73, 73, 72, 72, 71, 70, 68, 66, 63, 59], [52, 52, 52, 52, 53, 53, 50, 52, 53, 51, 52, 52, 52, 52, 52, 51, 50, 50, 48, 44], [42, 41, 42, 47, 53, 56, 56, 57, 59, 59, 56, 55, 51, 47, 44, 44, 38, 31, 19, 32], [48, 52, 54, 56, 58, 60, 61, 63, 62, 63, 63, 63, 62, 62, 60, 59, 56, 54, 49, 43], [56, 57, 57, 58, 59, 60, 61, 62, 64, 64, 64, 63, 62, 61, 59, 57, 53, 51, 46, 43], [47, 44, 50, 56, 62, 65, 67, 67, 66, 65, 64, 63, 62, 62, 60, 58, 54, 50, 42, 36], [60, 63, 64, 65, 68, 69, 71, 71, 71, 72, 71, 71, 70, 70, 69, 67, 64, 61, 51, 43], [58, 60, 61, 62, 63, 64, 64, 64, 66, 66, 66, 66, 65, 64, 63, 62, 59, 56, 50, 43], [44, 50, 54, 57, 60, 62, 63, 63, 62, 62, 62, 61, 61, 60, 60, 59, 57, 55, 49, 44], [51, 53, 54, 56, 57, 58, 58, 58, 61, 61, 61, 61, 60, 59, 57, 55, 52, 48, 36, 44], [45, 46, 47, 47, 47, 47, 47, 47, 44, 39, 50, 51, 47, 44, 45, 45, 44, 43, 40, 38], [46, 48, 49, 50, 49, 48, 45, 41, 42, 43, 43, 37, 37, 34, 34, 29, 23, 33, 35, 34], [48, 49, 51, 52, 53, 54, 54, 55, 54, 54, 54, 55, 53, 53, 51, 49, 46, 40, 28, 38], [50, 51, 52, 53, 53, 53, 53, 53, 53, 52, 52, 52, 51, 51, 50, 49, 46, 43, 32, 25], [49, 51, 52, 53, 53, 53, 51, 49, 48, 49, 49, 48, 48, 48, 47, 46, 45, 44, 43, 42], [38, 36, 36, 36, 33, 30, 34, 44, 47, 42, 41, 35, 41, 39, 42, 37, 44, 42, 40, 38], [55, 59, 62, 64, 67, 66, 59, 57, 61, 59, 59, 59, 60, 58, 58, 57, 57, 56, 56, 53], [70, 73, 76, 79, 81, 82, 79, 79, 81, 80, 80, 79, 79, 79, 78, 77, 75, 74, 71, 68], [73, 76, 77, 78, 79, 79, 79, 76, 78, 77, 77, 77, 76, 76, 75, 75, 73, 71, 67, 61], [74, 77, 79, 81, 83, 84, 84, 82, 84, 83, 83, 83, 83, 82, 81, 80, 79, 77, 73, 69], [71, 73, 75, 76, 78, 79, 78, 79, 79, 79, 78, 78, 78, 78, 77, 76, 75, 74, 72, 69], [66, 68, 69, 69, 69, 68, 65, 64, 66, 69, 69, 69, 68, 68, 67, 66, 65, 63, 61, 58], [62, 62, 62, 62, 65, 68, 70, 71, 72, 71, 69, 68, 67, 65, 63, 61, 57, 51, 44, 43], [54, 58, 61, 64, 67, 66, 65, 67, 66, 66, 67, 66, 66, 65, 64, 63, 61, 59, 55, 51], [62, 63, 65, 66, 63, 50, 63, 61, 49, 44, 52, 50, 48, 50, 49, 48, 50, 51, 51, 51], [59, 62, 65, 67, 72, 75, 77, 77, 76, 74, 72, 70, 69, 68, 65, 63, 58, 52, 40, 47], [66, 68, 69, 70, 70, 70, 70, 72, 73, 74, 73, 72, 71, 70, 68, 66, 62, 60, 56, 52], [57, 60, 64, 67, 71, 72, 69, 67, 69, 71, 73, 72, 72, 71, 70, 69, 67, 64, 59, 54], [61, 64, 67, 69, 71, 73, 75, 74, 74, 75, 74, 74, 74, 73, 72, 71, 68, 66, 66, 64], [48, 48, 46, 44, 53, 59, 62, 64, 58, 56, 57, 52, 54, 53, 52, 53, 54, 54, 53, 49], [53, 55, 56, 58, 62, 65, 68, 67, 63, 42, 57, 46, 54, 57, 57, 50, 54, 51, 50, 48], [56, 59, 61, 62, 62, 58, 43, 50, 52, 51, 49, 47, 47, 47, 45, 45, 44, 44, 33, 34], [59, 60, 60, 60, 59, 55, 44, 48, 41, 44, 45, 46, 45, 43, 42, 44, 40, 39, 39, 32], [56, 59, 61, 63, 64, 65, 65, 64, 63, 63, 63, 62, 62, 62, 63, 62, 60, 57, 57, 51], [51, 55, 59, 61, 63, 64, 64, 62, 56, 50, 52, 54, 54, 52, 54, 52, 52, 51, 49, 45], [45, 45, 44, 49, 54, 58, 57, 42, 53, 50, 57, 43, 48, 54, 29, 47, 47, 48, 42, 42], [67, 70, 74, 76, 79, 80, 76, 69, 73, 71, 68, 69, 70, 69, 69, 69, 67, 66, 65, 63], [77, 81, 84, 86, 90, 92, 92, 91, 93, 92, 92, 91, 91, 91, 90, 89, 88, 86, 83, 80], [79, 84, 86, 88, 90, 90, 90, 88, 88, 87, 88, 87, 86, 86, 85, 84, 83, 81, 77, 72], [76, 82, 86, 89, 93, 95, 96, 95, 96, 96, 96, 95, 95, 94, 93, 92, 90, 88, 84, 80], [81, 84, 86, 88, 90, 91, 90, 89, 90, 89, 89, 88, 88, 88, 87, 87, 86, 85, 83, 81], [77, 79, 81, 82, 82, 81, 78, 76, 79, 80, 81, 80, 80, 79, 79, 78, 76, 74, 71, 68], [76, 77, 78, 78, 77, 79, 83, 85, 86, 85, 83, 83, 81, 79, 77, 75, 70, 62, 56, 52], [69, 69, 70, 73, 79, 81, 78, 76, 80, 78, 79, 78, 78, 78, 76, 75, 73, 70, 65, 61], [76, 78, 78, 79, 78, 69, 77, 76, 67, 67, 68, 70, 67, 67, 62, 58, 55, 57, 60, 62], [74, 76, 78, 80, 83, 85, 89, 89, 89, 88, 85, 83, 82, 81, 79, 78, 74, 70, 61, 54], [66, 72, 76, 79, 82, 84, 86, 87, 86, 86, 85, 85, 84, 83, 81, 80, 76, 74, 68, 64], [66, 67, 71, 76, 82, 85, 85, 82, 83, 84, 84, 83, 83, 83, 82, 80, 79, 76, 72, 67], [63, 68, 73, 76, 81, 84, 87, 87, 86, 86, 86, 87, 86, 85, 84, 83, 80, 76, 75, 75], [56, 56, 56, 55, 59, 67, 73, 77, 80, 79, 78, 70, 73, 73, 71, 66, 67, 67, 65, 61], [56, 53, 53, 61, 72, 78, 82, 80, 73, 77, 72, 74, 75, 76, 74, 56, 70, 64, 63, 61], [71, 74, 76, 78, 79, 77, 57, 70, 70, 70, 64, 63, 65, 66, 61, 63, 61, 59, 50, 50], [72, 74, 75, 76, 75, 73, 67, 72, 69, 68, 69, 70, 67, 66, 64, 64, 60, 58, 56, 51], [67, 71, 75, 77, 80, 81, 82, 82, 82, 81, 81, 80, 80, 80, 79, 78, 76, 73, 71, 66], [60, 65, 71, 74, 79, 81, 82, 81, 81, 79, 79, 77, 78, 76, 74, 71, 70, 68, 64, 61], [41, 41, 40, 38, 39, 38, 32, 40, 38, 46, 42, 32, 43, 38, 23, 41, 45, 37, 35, 45], [58, 63, 66, 69, 70, 70, 73, 73, 75, 76, 76, 76, 75, 74, 69, 63, 50, 43, 29, 34], [67, 70, 72, 73, 75, 76, 77, 77, 74, 74, 76, 75, 74, 73, 72, 70, 68, 65, 59, 52], [64, 68, 71, 72, 74, 74, 73, 72, 74, 74, 74, 74, 73, 73, 72, 72, 70, 69, 66, 64], [65, 67, 69, 70, 71, 71, 71, 71, 71, 71, 72, 71, 71, 70, 69, 68, 66, 64, 59, 51], [62, 64, 66, 67, 67, 66, 63, 65, 68, 68, 69, 70, 70, 69, 68, 66, 63, 60, 55, 50], [63, 65, 66, 67, 68, 67, 68, 67, 66, 67, 67, 67, 67, 66, 65, 64, 63, 61, 57, 53], [39, 39, 42, 45, 49, 50, 45, 44, 47, 48, 47, 48, 46, 46, 44, 45, 42, 39, 37, 33], [43, 44, 45, 47, 50, 51, 50, 52, 53, 50, 50, 50, 50, 47, 46, 46, 47, 43, 41, 40], [44, 43, 39, 24, 45, 50, 54, 54, 54, 55, 55, 56, 55, 54, 54, 53, 52, 51, 48, 45], [36, 46, 51, 55, 58, 60, 61, 63, 63, 63, 64, 63, 63, 63, 62, 61, 59, 57, 53, 50], [51, 54, 56, 57, 58, 59, 60, 60, 59, 60, 60, 59, 59, 58, 58, 56, 54, 53, 49, 46], [45, 48, 50, 52, 51, 53, 58, 58, 58, 59, 59, 59, 59, 59, 59, 58, 57, 54, 48, 40], [43, 46, 49, 51, 56, 60, 62, 61, 62, 62, 61, 60, 59, 58, 56, 55, 53, 49, 21, 35], [46, 47, 48, 49, 49, 50, 51, 52, 53, 53, 53, 53, 52, 51, 49, 47, 41, 35, 42, 42], [38, 40, 40, 41, 40, 40, 41, 38, 37, 39, 37, 35, 35, 33, 29, 19, 28, 32, 31, 14], [28, 28, 26, 23, 25, 28, 32, 30, 34, 31, 31, 29, 21, 31, 27, 18, 13, 19, 14, 10], [38, 40, 41, 41, 41, 42, 43, 43, 43, 43, 43, 43, 41, 38, 31, 18, 37, 38, 24, 30], [34, 37, 39, 40, 42, 41, 39, 41, 40, 40, 39, 38, 38, 36, 29, 26, 35, 33, 25, 22], [24, 27, 29, 30, 29, 29, 31, 28, 28, 30, 30, 32, 30, 32, 26, 20, 24, 24, 25, 21], [47, 48, 46, 41, 45, 42, 48, 47, 47, 48, 46, 51, 47, 43, 48, 38, 42, 27, 42, 34], [47, 60, 67, 71, 76, 77, 79, 80, 81, 82, 82, 81, 80, 78, 76, 73, 65, 51, 42, 38], [65, 71, 75, 77, 80, 82, 83, 83, 81, 81, 82, 81, 81, 79, 78, 76, 72, 70, 65, 60], [63, 69, 73, 76, 80, 81, 81, 79, 80, 81, 80, 80, 80, 79, 79, 78, 77, 75, 73, 71], [67, 71, 73, 75, 77, 78, 78, 78, 78, 78, 79, 78, 78, 77, 77, 76, 74, 72, 66, 59], [65, 69, 72, 74, 75, 75, 73, 72, 75, 77, 78, 78, 78, 78, 77, 75, 72, 69, 63, 57], [68, 71, 73, 75, 76, 76, 76, 76, 75, 76, 76, 76, 75, 75, 74, 73, 71, 69, 65, 62], [47, 45, 35, 42, 56, 59, 57, 53, 56, 55, 54, 55, 54, 55, 53, 52, 51, 50, 47, 44], [56, 56, 57, 57, 59, 60, 60, 62, 61, 61, 59, 60, 60, 59, 57, 58, 55, 54, 51, 48], [55, 57, 58, 56, 46, 57, 63, 65, 65, 66, 67, 66, 66, 66, 65, 64, 63, 62, 58, 55], [43, 51, 57, 62, 67, 70, 71, 73, 74, 74, 75, 74, 74, 74, 73, 72, 70, 69, 65, 61], [56, 61, 64, 67, 69, 70, 72, 72, 71, 71, 71, 71, 71, 70, 70, 69, 68, 66, 63, 60], [55, 58, 61, 63, 65, 63, 70, 71, 71, 72, 72, 72, 72, 72, 72, 71, 69, 67, 61, 56], [53, 56, 58, 61, 66, 71, 76, 76, 76, 76, 75, 75, 73, 72, 70, 69, 67, 62, 37, 51], [55, 59, 61, 63, 64, 64, 66, 66, 67, 67, 67, 67, 66, 65, 62, 60, 52, 50, 55, 56], [52, 54, 56, 57, 56, 55, 56, 55, 53, 54, 52, 52, 50, 49, 43, 31, 45, 48, 44, 28], [46, 47, 48, 47, 43, 44, 48, 49, 49, 48, 49, 47, 46, 45, 39, 28, 38, 42, 34, 34], [53, 57, 59, 61, 61, 61, 62, 62, 62, 61, 61, 60, 57, 55, 45, 45, 55, 54, 46, 46], [51, 54, 57, 59, 61, 62, 61, 61, 61, 60, 59, 59, 57, 55, 45, 46, 55, 52, 47, 42], [45, 48, 51, 52, 54, 55, 57, 56, 58, 59, 59, 59, 59, 57, 51, 47, 56, 48, 51, 47], [60, 59, 58, 56, 60, 63, 63, 44, 60, 60, 54, 53, 46, 40, 43, 44, 41, 40, 44, 47], [67, 73, 79, 82, 87, 88, 89, 92, 93, 93, 92, 91, 89, 87, 86, 85, 81, 76, 60, 44], [69, 77, 82, 86, 89, 92, 94, 94, 93, 93, 94, 93, 92, 92, 90, 88, 84, 80, 73, 66], [73, 78, 82, 86, 90, 92, 92, 90, 90, 92, 91, 91, 91, 90, 90, 88, 87, 86, 83, 80], [74, 78, 81, 83, 86, 88, 89, 89, 90, 89, 90, 89, 89, 88, 88, 87, 85, 84, 79, 72], [66, 74, 79, 82, 86, 88, 87, 84, 86, 87, 87, 88, 88, 87, 86, 84, 82, 80, 74, 68], [80, 83, 85, 87, 90, 90, 91, 90, 89, 90, 90, 90, 89, 89, 88, 87, 85, 83, 79, 76], [56, 56, 63, 68, 74, 77, 74, 67, 69, 69, 68, 68, 68, 68, 67, 65, 63, 62, 59, 55], [71, 73, 74, 75, 75, 75, 73, 74, 73, 75, 72, 72, 72, 71, 67, 71, 67, 65, 63, 60], [65, 68, 70, 70, 71, 76, 77, 79, 79, 80, 80, 80, 80, 80, 79, 78, 76, 75, 72, 68], [65, 70, 73, 76, 81, 83, 86, 87, 88, 89, 89, 88, 87, 87, 86, 85, 84, 83, 79, 76], [67, 73, 77, 80, 83, 83, 85, 86, 85, 84, 84, 84, 84, 83, 82, 81, 79, 78, 74, 72], [66, 70, 73, 77, 81, 80, 83, 86, 86, 84, 86, 85, 85, 84, 84, 83, 82, 80, 74, 68], [64, 69, 72, 76, 83, 88, 93, 93, 93, 93, 92, 92, 90, 88, 86, 85, 84, 80, 54, 66], [71, 76, 79, 81, 83, 83, 85, 85, 87, 87, 86, 85, 84, 82, 78, 74, 62, 70, 73, 71], [69, 72, 74, 75, 76, 76, 75, 73, 72, 69, 67, 64, 64, 61, 47, 51, 62, 64, 58, 50], [65, 67, 67, 66, 63, 64, 68, 69, 70, 71, 70, 69, 68, 67, 61, 44, 61, 64, 55, 55], [70, 74, 77, 79, 81, 81, 81, 80, 81, 81, 81, 81, 79, 77, 69, 61, 75, 75, 65, 67], [70, 73, 75, 77, 79, 80, 80, 79, 80, 78, 78, 76, 74, 72, 60, 64, 71, 69, 63, 58], [64, 68, 72, 74, 76, 77, 77, 74, 75, 75, 75, 75, 75, 75, 71, 67, 69, 66, 65, 59], [54, 54, 53, 50, 43, 45, 53, 42, 41, 37, 38, 44, 34, 43, 47, 41, 46, 45, 44, 45], [68, 72, 74, 75, 77, 77, 76, 75, 74, 75, 73, 72, 72, 71, 70, 68, 64, 61, 62, 63], [65, 67, 68, 67, 63, 60, 62, 61, 60, 56, 58, 56, 59, 58, 57, 56, 54, 55, 52, 50], [68, 70, 71, 72, 71, 70, 70, 70, 69, 68, 68, 68, 67, 66, 63, 60, 53, 52, 52, 47], [70, 72, 73, 73, 74, 75, 76, 76, 77, 77, 77, 77, 75, 74, 71, 68, 59, 55, 63, 63], [65, 66, 67, 67, 67, 67, 67, 69, 70, 70, 70, 70, 69, 68, 67, 66, 62, 54, 52, 57], [54, 56, 58, 59, 60, 61, 60, 58, 53, 53, 55, 55, 53, 53, 50, 48, 42, 32, 38, 41], [46, 48, 50, 49, 45, 44, 44, 36, 37, 38, 40, 39, 38, 37, 38, 32, 35, 32, 19, 24], [54, 54, 54, 55, 56, 57, 54, 50, 47, 48, 48, 48, 48, 45, 45, 42, 39, 34, 34, 40], [62, 64, 65, 65, 66, 67, 66, 67, 67, 67, 67, 66, 66, 65, 63, 62, 58, 55, 46, 38], [62, 63, 64, 64, 63, 62, 60, 60, 60, 60, 60, 59, 57, 55, 49, 31, 50, 52, 46, 43], [60, 61, 62, 63, 63, 63, 61, 61, 62, 61, 61, 60, 58, 56, 51, 44, 42, 47, 44, 36], [55, 56, 57, 58, 58, 58, 56, 56, 55, 55, 54, 52, 52, 50, 46, 42, 34, 38, 42, 40], [51, 52, 52, 52, 52, 51, 51, 51, 52, 53, 52, 52, 52, 52, 50, 49, 46, 46, 42, 10], [47, 49, 50, 51, 51, 50, 51, 51, 51, 50, 49, 48, 47, 45, 41, 38, 31, 36, 37, 34], [36, 37, 38, 38, 37, 37, 37, 36, 38, 37, 38, 38, 36, 33, 31, 30, 25, 22, 24, 23], [25, 26, 27, 27, 29, 28, 26, 29, 28, 26, 21, 23, 23, 20, 16, 16, 15, 21, 17, 18], [34, 35, 36, 37, 37, 36, 34, 35, 36, 36, 36, 35, 34, 34, 31, 28, 23, 20, 19, 20], [34, 35, 36, 36, 36, 37, 36, 35, 36, 34, 33, 32, 30, 24, 24, 27, 28, 27, 19, 18], [29, 31, 32, 32, 31, 31, 29, 33, 33, 30, 29, 31, 30, 30, 26, 27, 26, 16, 15, 19], [53, 60, 62, 64, 63, 58, 59, 56, 47, 56, 50, 56, 50, 53, 50, 48, 50, 41, 48, 44], [62, 69, 74, 78, 83, 85, 86, 84, 82, 83, 81, 81, 80, 79, 78, 76, 71, 68, 71, 70], [57, 62, 70, 74, 76, 72, 70, 69, 68, 64, 63, 64, 65, 65, 64, 63, 63, 62, 61, 59], [68, 74, 77, 79, 81, 81, 78, 78, 78, 76, 76, 75, 74, 73, 71, 68, 61, 58, 61, 58], [71, 76, 80, 82, 83, 84, 86, 86, 88, 87, 87, 86, 85, 84, 82, 79, 68, 66, 74, 74], [64, 70, 74, 77, 78, 78, 78, 79, 81, 81, 80, 80, 80, 79, 78, 76, 72, 66, 60, 67], [66, 68, 69, 70, 71, 72, 73, 72, 68, 65, 66, 66, 65, 65, 64, 62, 59, 54, 41, 50], [57, 59, 61, 61, 61, 57, 57, 53, 51, 53, 51, 53, 54, 50, 50, 49, 45, 40, 31, 29], [64, 67, 68, 68, 69, 70, 70, 67, 60, 61, 62, 62, 62, 59, 58, 57, 53, 50, 47, 52], [68, 73, 76, 78, 80, 81, 82, 82, 83, 83, 82, 82, 81, 80, 79, 77, 74, 70, 63, 57], [70, 75, 77, 78, 79, 79, 75, 75, 76, 75, 75, 74, 73, 71, 64, 53, 65, 66, 58, 57], [71, 75, 77, 78, 79, 80, 79, 78, 79, 79, 78, 78, 76, 74, 70, 64, 56, 63, 61, 55], [66, 71, 73, 75, 76, 77, 76, 72, 75, 73, 73, 73, 72, 71, 69, 65, 59, 42, 56, 56], [64, 68, 71, 72, 73, 73, 71, 71, 70, 71, 72, 72, 72, 72, 71, 70, 68, 67, 62, 49], [61, 65, 68, 70, 73, 73, 73, 74, 73, 73, 73, 72, 71, 69, 67, 63, 52, 51, 57, 54], [59, 61, 61, 61, 61, 62, 63, 63, 63, 63, 62, 62, 60, 59, 56, 53, 48, 29, 52, 49], [54, 56, 56, 56, 55, 53, 51, 54, 52, 52, 52, 51, 50, 49, 48, 45, 40, 38, 42, 39], [58, 61, 63, 63, 62, 61, 61, 62, 62, 62, 62, 61, 60, 58, 55, 52, 43, 44, 46, 45], [60, 64, 67, 68, 69, 69, 68, 67, 67, 66, 65, 64, 62, 60, 54, 48, 53, 55, 53, 43], [48, 55, 60, 62, 63, 63, 64, 64, 63, 62, 62, 62, 61, 60, 56, 56, 56, 46, 44, 35], [59, 67, 71, 73, 73, 68, 66, 67, 48, 65, 55, 66, 55, 63, 58, 53, 59, 47, 49, 54], [74, 80, 85, 88, 93, 95, 95, 93, 91, 92, 91, 91, 89, 89, 87, 85, 79, 77, 79, 77], [70, 73, 79, 84, 86, 83, 77, 80, 73, 65, 65, 65, 59, 64, 65, 68, 71, 72, 71, 69], [72, 80, 84, 87, 90, 91, 89, 90, 89, 87, 86, 85, 84, 82, 79, 74, 66, 63, 66, 64], [81, 86, 89, 91, 92, 93, 95, 96, 96, 96, 95, 94, 93, 92, 90, 87, 75, 75, 83, 83], [71, 78, 83, 86, 88, 88, 88, 88, 90, 90, 90, 89, 89, 88, 87, 86, 82, 77, 67, 75], [75, 78, 79, 81, 83, 84, 84, 83, 79, 79, 77, 78, 76, 74, 72, 69, 66, 61, 59, 62], [68, 70, 71, 70, 70, 69, 65, 67, 62, 65, 65, 66, 65, 64, 62, 60, 57, 53, 31, 47], [73, 77, 79, 80, 80, 81, 82, 78, 73, 75, 75, 74, 73, 72, 71, 68, 64, 60, 58, 61], [78, 83, 87, 89, 91, 92, 93, 93, 94, 94, 93, 93, 92, 91, 89, 87, 84, 80, 74, 69], [80, 85, 88, 89, 90, 90, 87, 87, 87, 87, 87, 85, 84, 82, 75, 67, 75, 77, 67, 66], [82, 86, 88, 89, 91, 91, 90, 89, 91, 91, 90, 89, 87, 86, 81, 74, 67, 74, 71, 65], [78, 82, 85, 87, 89, 90, 91, 86, 87, 83, 85, 84, 84, 82, 80, 76, 69, 55, 66, 67], [75, 81, 84, 85, 85, 85, 83, 82, 82, 84, 84, 85, 85, 85, 85, 84, 81, 79, 72, 59], [74, 79, 82, 85, 87, 87, 87, 87, 87, 86, 84, 84, 82, 81, 78, 75, 64, 60, 67, 64], [73, 75, 76, 76, 76, 78, 78, 77, 77, 76, 76, 75, 73, 71, 67, 65, 61, 53, 63, 61], [68, 70, 70, 70, 68, 66, 67, 69, 69, 68, 67, 68, 66, 65, 64, 60, 53, 53, 56, 51], [72, 76, 78, 78, 78, 77, 78, 79, 79, 79, 79, 77, 75, 74, 70, 67, 56, 58, 61, 62], [75, 79, 82, 83, 84, 84, 83, 83, 83, 83, 82, 81, 79, 77, 71, 55, 67, 69, 67, 55], [63, 71, 76, 79, 80, 80, 81, 81, 81, 81, 81, 81, 79, 78, 74, 73, 73, 65, 61, 52], [59, 63, 66, 67, 65, 61, 57, 44, 54, 53, 52, 53, 53, 51, 51, 48, 47, 50, 43, 39], [60, 62, 68, 70, 72, 74, 70, 70, 71, 69, 68, 68, 67, 65, 62, 58, 58, 50, 44, 42], [69, 73, 75, 76, 78, 79, 79, 78, 75, 73, 68, 67, 63, 58, 48, 43, 21, 36, 40, 43], [65, 69, 71, 71, 71, 72, 73, 73, 74, 74, 74, 73, 71, 69, 67, 65, 65, 62, 58, 56], [57, 59, 62, 64, 65, 64, 68, 71, 70, 71, 72, 71, 70, 68, 65, 62, 51, 53, 57, 55], [60, 62, 61, 57, 55, 60, 64, 65, 61, 62, 62, 61, 60, 59, 57, 55, 49, 45, 51, 52], [58, 61, 63, 66, 68, 69, 71, 71, 71, 71, 70, 69, 67, 64, 51, 60, 68, 66, 58, 59], [48, 52, 56, 60, 64, 63, 61, 60, 59, 59, 57, 55, 53, 53, 48, 41, 38, 27, 35, 37], [54, 56, 58, 57, 54, 53, 56, 54, 52, 48, 51, 51, 50, 47, 41, 41, 47, 48, 40, 42], [52, 53, 50, 42, 48, 52, 51, 51, 52, 54, 54, 53, 52, 51, 48, 46, 45, 45, 33, 34], [51, 53, 53, 55, 56, 57, 56, 55, 50, 46, 47, 49, 47, 47, 45, 44, 41, 38, 31, 21], [53, 56, 57, 57, 56, 52, 46, 33, 43, 41, 44, 47, 46, 45, 43, 41, 29, 20, 26, 26], [51, 52, 54, 56, 59, 59, 60, 60, 60, 61, 58, 60, 59, 58, 54, 51, 34, 32, 36, 41], [50, 54, 56, 57, 58, 58, 58, 58, 58, 59, 58, 57, 54, 50, 47, 49, 50, 48, 42, 39], [37, 42, 45, 46, 46, 45, 44, 44, 46, 46, 45, 44, 45, 44, 39, 36, 38, 28, 37, 36], [39, 42, 43, 44, 44, 43, 44, 45, 45, 45, 44, 44, 41, 37, 36, 39, 35, 39, 34, 29], [32, 33, 33, 30, 11, 20, 22, 21, 20, 25, 23, 20, 23, 10, 20, 11, 13, 18, 12, 9], [24, 23, 22, 22, 26, 28, 26, 25, 20, 23, 24, 22, 19, 17, 10, 18, 13, 20, 17, 7], [26, 30, 32, 34, 31, 27, 29, 32, 28, 27, 27, 13, 31, 30, 28, 21, 19, 26, 8, 12], [31, 33, 30, 19, 30, 13, 30, 29, 31, 26, 24, 25, 26, 23, 24, 23, 11, 22, 13, 0], [55, 63, 71, 75, 77, 73, 73, 45, 68, 65, 60, 60, 63, 64, 62, 62, 61, 58, 54, 54], [69, 71, 70, 77, 84, 85, 84, 82, 84, 82, 81, 80, 80, 78, 76, 73, 67, 59, 44, 50], [74, 81, 85, 87, 89, 90, 90, 90, 88, 84, 80, 77, 72, 66, 62, 54, 46, 33, 54, 59], [72, 79, 82, 84, 83, 83, 85, 86, 86, 86, 86, 86, 85, 84, 82, 80, 78, 74, 69, 63], [70, 71, 73, 76, 80, 79, 82, 84, 85, 85, 86, 86, 85, 84, 82, 79, 69, 64, 72, 68], [69, 75, 78, 77, 71, 73, 80, 81, 78, 78, 78, 77, 76, 76, 74, 73, 68, 63, 66, 67], [68, 74, 77, 79, 84, 86, 87, 87, 87, 86, 85, 85, 83, 80, 68, 72, 82, 80, 70, 71], [63, 67, 70, 73, 79, 81, 78, 78, 76, 76, 74, 70, 71, 70, 66, 59, 43, 49, 53, 54], [67, 72, 76, 77, 76, 75, 76, 75, 71, 69, 70, 69, 67, 64, 56, 56, 62, 64, 57, 61], [68, 73, 75, 73, 48, 70, 72, 72, 72, 73, 74, 74, 73, 72, 69, 66, 64, 65, 57, 52], [67, 72, 74, 74, 75, 77, 77, 75, 71, 66, 65, 68, 65, 67, 64, 62, 59, 57, 49, 40], [67, 73, 76, 77, 76, 73, 68, 62, 65, 59, 51, 62, 55, 52, 55, 50, 44, 43, 50, 53], [68, 72, 73, 75, 81, 83, 82, 82, 84, 85, 79, 85, 84, 82, 78, 77, 68, 60, 63, 58], [69, 74, 78, 81, 83, 83, 83, 83, 82, 83, 82, 80, 76, 67, 71, 69, 76, 70, 65, 62], [60, 62, 68, 72, 73, 73, 72, 71, 71, 70, 69, 68, 67, 64, 57, 59, 62, 61, 58, 60], [63, 68, 70, 71, 73, 73, 73, 73, 73, 73, 72, 70, 66, 57, 67, 69, 63, 66, 60, 52], [64, 67, 68, 68, 63, 56, 56, 57, 56, 58, 56, 54, 49, 40, 53, 52, 50, 42, 36, 40], [46, 50, 51, 43, 54, 56, 55, 55, 53, 51, 35, 38, 46, 50, 51, 37, 56, 49, 45, 44], [41, 52, 58, 58, 54, 55, 56, 58, 52, 51, 57, 59, 58, 54, 50, 50, 54, 50, 19, 44], [65, 70, 72, 73, 74, 74, 73, 72, 71, 70, 61, 66, 70, 63, 70, 68, 61, 66, 62, 55], [69, 73, 78, 82, 86, 84, 79, 61, 73, 61, 64, 53, 67, 67, 66, 67, 65, 64, 61, 57], [78, 82, 82, 84, 90, 92, 89, 86, 89, 88, 86, 86, 85, 84, 81, 79, 73, 66, 35, 56], [79, 85, 89, 91, 94, 95, 95, 93, 92, 87, 83, 81, 76, 70, 67, 61, 52, 29, 58, 63], [75, 82, 86, 87, 88, 89, 90, 91, 91, 91, 92, 92, 91, 90, 89, 88, 84, 81, 73, 67], [76, 78, 77, 77, 83, 85, 87, 89, 89, 89, 91, 90, 89, 88, 86, 83, 74, 71, 76, 73], [75, 80, 83, 84, 76, 78, 84, 86, 82, 80, 80, 80, 80, 79, 78, 76, 73, 68, 70, 72], [72, 78, 82, 84, 89, 92, 93, 93, 93, 92, 91, 91, 89, 86, 74, 78, 87, 86, 76, 76], [66, 70, 74, 78, 85, 87, 85, 85, 83, 84, 82, 80, 80, 76, 71, 66, 55, 53, 60, 62], [71, 78, 81, 83, 83, 82, 82, 81, 77, 78, 76, 76, 74, 70, 62, 63, 69, 70, 63, 66], [74, 79, 82, 81, 71, 75, 79, 78, 80, 81, 83, 83, 82, 81, 79, 75, 71, 70, 61, 58], [73, 78, 80, 81, 82, 84, 84, 83, 80, 78, 77, 80, 77, 78, 75, 75, 69, 67, 57, 53], [71, 78, 82, 83, 81, 79, 72, 58, 59, 66, 66, 68, 58, 61, 57, 47, 50, 51, 58, 59], [73, 77, 77, 78, 87, 90, 85, 86, 91, 92, 84, 90, 89, 87, 82, 82, 74, 63, 67, 65], [73, 79, 84, 87, 90, 90, 90, 89, 90, 89, 88, 87, 82, 72, 77, 75, 83, 77, 69, 66], [65, 68, 74, 78, 81, 81, 80, 80, 80, 79, 80, 79, 77, 74, 68, 69, 70, 70, 66, 68], [71, 76, 79, 80, 81, 81, 81, 82, 82, 82, 81, 80, 75, 65, 75, 77, 70, 75, 69, 63], [73, 76, 77, 77, 71, 65, 65, 64, 65, 65, 63, 61, 54, 51, 58, 56, 57, 51, 41, 46], [60, 60, 58, 52, 53, 61, 58, 61, 57, 48, 56, 56, 61, 59, 58, 37, 64, 53, 51, 51], [60, 57, 62, 64, 64, 67, 67, 68, 63, 68, 69, 68, 71, 67, 42, 53, 64, 62, 46, 56], [73, 78, 80, 81, 81, 82, 80, 80, 78, 77, 68, 72, 76, 71, 77, 74, 68, 72, 68, 61], [62, 67, 71, 73, 73, 73, 76, 76, 77, 78, 78, 77, 72, 62, 56, 48, 40, 43, 46, 45], [69, 70, 71, 71, 71, 70, 71, 68, 69, 70, 69, 67, 64, 60, 48, 50, 57, 56, 42, 37], [66, 70, 72, 73, 73, 72, 74, 74, 73, 72, 70, 69, 67, 66, 61, 56, 58, 61, 60, 50], [66, 70, 71, 71, 67, 56, 63, 67, 58, 54, 61, 58, 58, 58, 58, 57, 53, 50, 50, 46], [68, 71, 71, 68, 68, 66, 66, 65, 68, 68, 68, 67, 66, 65, 62, 59, 55, 48, 46, 48], [56, 53, 55, 65, 71, 73, 73, 70, 71, 69, 68, 66, 63, 60, 48, 52, 59, 59, 50, 43], [53, 56, 59, 62, 63, 64, 64, 64, 63, 63, 62, 62, 61, 60, 58, 56, 51, 43, 36, 33], [38, 37, 38, 41, 45, 42, 42, 43, 44, 44, 43, 38, 27, 26, 38, 39, 35, 30, 26, 23], [50, 53, 53, 53, 53, 52, 53, 51, 49, 49, 48, 45, 41, 34, 23, 36, 40, 38, 31, 25], [55, 56, 57, 57, 56, 55, 54, 54, 53, 52, 51, 51, 49, 47, 42, 33, 34, 29, 34, 33], [48, 50, 53, 55, 56, 52, 54, 53, 51, 50, 47, 41, 40, 47, 49, 45, 42, 45, 37, 37], [44, 46, 44, 39, 34, 42, 33, 40, 34, 31, 20, 25, 30, 33, 35, 33, 30, 30, 17, 18], [36, 38, 37, 36, 34, 32, 31, 33, 29, 27, 26, 31, 38, 41, 40, 37, 35, 31, 13, 31], [33, 37, 38, 39, 41, 40, 40, 40, 40, 38, 35, 30, 20, 33, 33, 21, 28, 15, 3, 21], [26, 30, 32, 33, 32, 33, 30, 31, 30, 31, 29, 24, 22, 25, 24, 19, 12, 21, 19, 17], [21, 24, 23, 16, 26, 32, 29, 26, 27, 25, 22, 19, 20, 16, 23, 25, 8, 24, 9, 9], [18, 14, 20, 21, 20, 21, 20, 18, 18, 21, 19, 21, 17, 10, 19, 17, 17, 19, 16, 0], [26, 27, 26, 28, 27, 28, 15, 26, 21, 19, 18, 14, 22, 23, 22, 22, 0, 13, 17, 12], [27, 24, 24, 24, 27, 18, 18, 21, 18, 26, 27, 29, 23, 16, 18, 15, 24, 19, 17, 5], [33, 32, 33, 34, 31, 26, 30, 28, 26, 23, 25, 26, 27, 28, 25, 22, 17, 17, 9, 11], [66, 72, 76, 79, 84, 84, 85, 86, 88, 89, 88, 87, 81, 76, 69, 59, 48, 45, 43, 46], [69, 78, 81, 83, 83, 82, 84, 83, 83, 85, 83, 82, 80, 77, 66, 65, 74, 73, 54, 55], [73, 76, 80, 83, 85, 85, 85, 86, 84, 83, 81, 79, 78, 77, 73, 67, 66, 71, 72, 66], [65, 75, 80, 82, 82, 77, 71, 78, 74, 73, 77, 76, 74, 73, 71, 68, 63, 60, 60, 59], [70, 78, 83, 84, 81, 80, 77, 78, 80, 81, 81, 80, 79, 77, 75, 72, 68, 64, 59, 58], [68, 73, 72, 60, 83, 87, 88, 86, 86, 84, 82, 81, 79, 76, 68, 55, 71, 73, 66, 60], [61, 69, 73, 76, 81, 82, 82, 82, 82, 80, 80, 80, 79, 77, 75, 74, 69, 63, 49, 53], [61, 62, 59, 59, 63, 64, 63, 66, 63, 62, 59, 57, 52, 42, 56, 57, 52, 47, 43, 45], [62, 71, 75, 77, 76, 76, 75, 73, 70, 71, 70, 68, 65, 60, 41, 51, 58, 58, 49, 45], [69, 77, 80, 81, 82, 80, 79, 79, 77, 76, 75, 74, 71, 69, 64, 61, 54, 44, 48, 50], [68, 73, 75, 78, 82, 81, 80, 79, 78, 78, 77, 73, 64, 61, 70, 68, 53, 67, 55, 52], [66, 72, 73, 71, 65, 66, 68, 70, 66, 61, 58, 50, 38, 53, 56, 54, 44, 48, 28, 33], [61, 68, 74, 77, 78, 77, 77, 78, 76, 76, 74, 72, 65, 58, 50, 66, 69, 65, 62, 45], [60, 68, 74, 76, 78, 79, 80, 79, 79, 79, 77, 76, 72, 69, 68, 67, 62, 64, 59, 48], [52, 49, 62, 67, 69, 70, 69, 70, 71, 70, 69, 68, 64, 60, 53, 47, 59, 60, 52, 44], [55, 60, 63, 65, 65, 64, 63, 64, 64, 63, 61, 58, 38, 53, 56, 58, 46, 54, 47, 36], [42, 44, 48, 52, 54, 57, 59, 58, 57, 56, 54, 52, 43, 39, 45, 49, 47, 38, 37, 26], [47, 49, 49, 48, 48, 46, 22, 48, 41, 49, 48, 49, 43, 36, 43, 48, 29, 27, 27, 0], [53, 55, 53, 49, 47, 52, 50, 52, 54, 53, 52, 53, 47, 30, 39, 36, 36, 38, 34, 24], [48, 56, 59, 61, 60, 58, 57, 57, 56, 54, 49, 43, 47, 53, 49, 49, 46, 37, 33, 30], [68, 74, 80, 85, 90, 91, 92, 94, 96, 95, 95, 94, 87, 82, 76, 68, 57, 40, 48, 41], [80, 87, 89, 90, 90, 91, 94, 92, 92, 93, 91, 90, 88, 85, 74, 71, 82, 81, 62, 63], [82, 85, 88, 91, 93, 93, 93, 94, 92, 90, 88, 87, 86, 85, 80, 73, 75, 80, 79, 70], [75, 84, 89, 91, 89, 85, 80, 85, 77, 78, 79, 76, 75, 75, 74, 72, 70, 68, 67, 66], [78, 86, 90, 92, 88, 87, 84, 85, 89, 88, 88, 88, 86, 85, 82, 79, 73, 69, 66, 66], [77, 81, 80, 65, 91, 96, 97, 95, 95, 94, 92, 90, 88, 85, 75, 68, 81, 81, 71, 67], [70, 78, 82, 85, 90, 91, 91, 90, 89, 89, 88, 88, 86, 84, 82, 81, 77, 69, 59, 56], [70, 72, 69, 70, 72, 75, 75, 78, 75, 75, 72, 69, 61, 49, 67, 68, 62, 57, 47, 51], [75, 83, 87, 87, 87, 87, 86, 85, 83, 82, 80, 78, 74, 69, 46, 62, 68, 67, 57, 51], [80, 88, 92, 93, 94, 92, 91, 91, 90, 89, 88, 87, 84, 81, 77, 73, 57, 64, 64, 63], [79, 84, 87, 91, 95, 93, 92, 90, 90, 90, 89, 86, 77, 70, 81, 80, 71, 79, 68, 66], [77, 82, 83, 81, 77, 77, 78, 78, 76, 74, 72, 69, 58, 58, 65, 68, 60, 61, 53, 36], [74, 79, 85, 88, 89, 88, 88, 89, 89, 89, 86, 85, 79, 72, 64, 79, 81, 72, 73, 64], [74, 82, 87, 90, 92, 93, 93, 92, 92, 92, 90, 89, 85, 82, 81, 80, 77, 77, 70, 61], [71, 70, 77, 81, 82, 83, 83, 84, 84, 82, 81, 79, 76, 73, 67, 67, 74, 73, 52, 63], [72, 77, 80, 81, 81, 80, 78, 80, 79, 78, 76, 74, 57, 67, 71, 71, 47, 67, 61, 53], [58, 60, 64, 65, 65, 70, 72, 72, 71, 70, 67, 66, 58, 54, 60, 63, 57, 47, 45, 42], [66, 66, 64, 60, 59, 63, 56, 63, 57, 66, 66, 69, 65, 53, 64, 68, 50, 50, 48, 33], [69, 73, 72, 70, 72, 73, 70, 73, 74, 74, 76, 75, 69, 60, 61, 58, 60, 61, 50, 48], [71, 75, 76, 77, 75, 72, 70, 70, 70, 70, 66, 62, 62, 67, 61, 61, 55, 53, 50, 43], [63, 70, 73, 74, 78, 80, 78, 76, 75, 78, 75, 73, 73, 73, 71, 70, 67, 65, 63, 57], [72, 74, 71, 60, 45, 51, 66, 64, 69, 66, 65, 65, 66, 65, 64, 62, 56, 52, 50, 47], [66, 68, 66, 61, 59, 64, 70, 66, 71, 70, 70, 70, 69, 68, 65, 63, 60, 53, 42, 53], [62, 66, 67, 66, 68, 68, 68, 69, 69, 69, 69, 68, 67, 66, 63, 59, 38, 55, 56, 51], [51, 51, 53, 60, 65, 66, 64, 64, 64, 63, 63, 62, 60, 59, 53, 44, 45, 47, 42, 50], [51, 49, 44, 39, 51, 56, 56, 53, 49, 46, 45, 47, 40, 30, 33, 37, 42, 39, 44, 43], [50, 50, 53, 56, 59, 57, 60, 58, 56, 56, 56, 54, 50, 44, 36, 46, 46, 38, 50, 43], [49, 51, 48, 45, 48, 45, 46, 48, 47, 46, 46, 44, 41, 39, 32, 33, 28, 30, 32, 33], [40, 42, 42, 44, 45, 46, 45, 45, 43, 42, 42, 39, 36, 31, 30, 34, 26, 31, 34, 28], [31, 37, 41, 43, 46, 46, 47, 46, 44, 43, 40, 33, 27, 36, 40, 38, 18, 38, 32, 19], [31, 31, 32, 32, 33, 33, 28, 30, 30, 30, 31, 27, 27, 31, 33, 21, 23, 24, 9, 18], [30, 24, 18, 15, 10, 25, 28, 30, 26, 20, 26, 26, 17, 13, 16, 13, 16, 21, 21, 8], [32, 35, 35, 35, 35, 34, 34, 32, 33, 29, 27, 18, 19, 12, 7, 27, 23, 23, 23, 20], [25, 21, 20, 22, 21, 17, 24, 24, 23, 23, 23, 14, 22, 24, 15, 14, 15, 19, 0, 5], [25, 21, 14, 5, 19, 20, 15, 22, 14, 20, 12, 23, 25, 24, 22, 9, 17, 12, 14, 14], [10, 15, 15, 20, 21, 19, 20, 13, 19, 19, 10, 21, 16, 3, 17, 13, 10, 0, 16, 17], [20, 17, 16, 10, 12, 24, 16, 15, 9, 9, 8, 10, 3, 13, 3, 4, 5, 5, 12, 7], [21, 16, 12, 21, 19, 17, 20, 16, 18, 20, 14, 9, 13, 4, 13, 0, 16, 0, 9, 9], [16, 22, 26, 26, 21, 23, 25, 24, 24, 25, 22, 23, 15, 14, 15, 14, 18, 13, 8, 7], [8, 14, 13, 13, 10, 16, 15, 13, 16, 13, 8, 6, 11, 16, 7, 5, 9, 7, 6, 8], [55, 68, 77, 82, 84, 89, 88, 87, 84, 87, 84, 84, 83, 82, 81, 79, 76, 74, 69, 63], [68, 79, 85, 85, 72, 65, 75, 79, 79, 78, 76, 77, 77, 76, 75, 72, 67, 62, 59, 59], [64, 75, 80, 80, 66, 71, 81, 76, 82, 80, 80, 80, 79, 78, 76, 74, 71, 66, 54, 64], [64, 72, 77, 78, 79, 79, 81, 81, 81, 81, 81, 80, 79, 77, 75, 71, 50, 65, 67, 60], [54, 61, 63, 65, 75, 78, 77, 77, 77, 77, 77, 76, 75, 74, 70, 64, 50, 61, 55, 62], [61, 66, 66, 64, 60, 69, 72, 68, 67, 69, 70, 68, 65, 62, 53, 33, 53, 52, 55, 56], [58, 67, 68, 70, 77, 78, 79, 79, 76, 76, 76, 75, 73, 69, 58, 61, 64, 58, 65, 59], [63, 68, 70, 70, 66, 69, 66, 68, 68, 67, 66, 64, 61, 58, 50, 49, 42, 46, 50, 52], [48, 60, 65, 67, 69, 68, 69, 69, 67, 65, 65, 64, 61, 57, 49, 55, 52, 52, 57, 49], [51, 44, 60, 66, 71, 74, 74, 76, 74, 73, 70, 67, 60, 52, 61, 63, 55, 60, 58, 46], [44, 51, 58, 61, 62, 64, 62, 62, 61, 62, 63, 62, 56, 47, 59, 56, 56, 50, 41, 37], [51, 52, 41, 52, 57, 57, 59, 60, 55, 56, 53, 53, 48, 43, 38, 31, 39, 45, 41, 24], [54, 62, 64, 65, 64, 64, 64, 64, 64, 62, 60, 57, 48, 39, 49, 47, 52, 47, 42, 40], [54, 59, 62, 62, 63, 61, 60, 57, 55, 53, 50, 48, 40, 45, 48, 40, 52, 41, 42, 20], [50, 56, 63, 64, 64, 63, 59, 60, 63, 63, 58, 56, 48, 47, 51, 49, 49, 41, 39, 34], [53, 58, 62, 62, 61, 60, 60, 61, 59, 59, 58, 55, 46, 36, 42, 50, 51, 37, 39, 26], [40, 50, 55, 55, 49, 58, 60, 54, 50, 43, 38, 45, 34, 37, 38, 36, 37, 20, 26, 9], [42, 47, 38, 47, 49, 46, 51, 49, 48, 42, 41, 42, 39, 33, 42, 35, 39, 30, 25, 23], [41, 49, 51, 51, 53, 53, 51, 52, 50, 47, 44, 45, 49, 50, 41, 37, 45, 39, 37, 27], [41, 47, 46, 42, 44, 41, 36, 32, 26, 27, 29, 30, 26, 29, 16, 36, 25, 17, 23, 19], [69, 87, 93, 96, 97, 102, 101, 99, 97, 97, 96, 96, 95, 94, 92, 90, 86, 83, 78, 70], [83, 93, 98, 96, 84, 81, 83, 88, 85, 86, 82, 83, 84, 83, 82, 80, 75, 67, 69, 69], [78, 89, 92, 91, 68, 85, 91, 84, 93, 94, 94, 94, 92, 91, 88, 86, 82, 76, 66, 75], [78, 86, 91, 92, 92, 92, 94, 95, 94, 94, 94, 94, 92, 91, 88, 84, 63, 77, 75, 72], [73, 78, 76, 76, 87, 89, 87, 86, 85, 84, 83, 83, 82, 80, 76, 70, 61, 68, 53, 70], [74, 79, 78, 74, 74, 81, 85, 82, 67, 71, 78, 75, 72, 68, 59, 53, 64, 60, 65, 65], [66, 75, 77, 83, 91, 92, 94, 93, 90, 88, 86, 84, 82, 78, 69, 71, 74, 68, 77, 66], [77, 82, 85, 86, 78, 83, 83, 83, 82, 83, 82, 81, 78, 74, 65, 63, 60, 63, 68, 65], [70, 73, 82, 85, 84, 83, 85, 86, 81, 80, 81, 79, 74, 71, 62, 65, 57, 67, 68, 58], [76, 73, 77, 82, 86, 89, 88, 90, 89, 88, 86, 84, 77, 63, 76, 78, 63, 78, 71, 54], [67, 71, 76, 77, 79, 81, 74, 73, 75, 75, 75, 73, 71, 71, 76, 76, 63, 55, 59, 54], [72, 74, 69, 57, 68, 70, 78, 79, 75, 77, 74, 72, 67, 65, 58, 53, 59, 70, 54, 52], [75, 80, 81, 80, 79, 79, 80, 81, 80, 79, 77, 76, 69, 60, 64, 63, 65, 64, 57, 57], [70, 75, 78, 80, 80, 77, 79, 81, 79, 81, 78, 76, 68, 61, 62, 64, 57, 68, 41, 53], [68, 78, 84, 86, 86, 85, 83, 81, 84, 81, 78, 77, 71, 47, 71, 70, 75, 67, 61, 52], [78, 82, 85, 85, 84, 83, 83, 85, 82, 81, 79, 75, 64, 54, 64, 68, 72, 64, 60, 49], [63, 75, 81, 80, 76, 83, 85, 78, 72, 76, 56, 66, 61, 43, 58, 55, 59, 50, 50, 44], [73, 76, 69, 76, 73, 73, 77, 74, 75, 71, 68, 66, 68, 68, 69, 64, 61, 48, 42, 45], [71, 77, 78, 77, 80, 81, 76, 81, 80, 79, 75, 69, 65, 73, 56, 68, 68, 58, 43, 52], [69, 73, 73, 72, 72, 66, 68, 71, 71, 69, 62, 57, 56, 54, 56, 62, 47, 52, 34, 20], [67, 71, 75, 76, 75, 73, 69, 67, 71, 67, 67, 66, 66, 64, 60, 58, 47, 28, 35, 25], [73, 75, 76, 78, 79, 79, 80, 81, 81, 81, 80, 80, 78, 77, 75, 72, 68, 61, 54, 59], [71, 74, 74, 74, 70, 68, 71, 69, 70, 70, 69, 68, 67, 65, 60, 55, 29, 46, 52, 50], [66, 66, 65, 68, 72, 72, 70, 68, 65, 64, 63, 61, 59, 56, 53, 52, 40, 47, 49, 24], [50, 52, 49, 47, 49, 44, 47, 36, 32, 49, 50, 49, 47, 46, 43, 35, 38, 41, 31, 35], [55, 56, 55, 54, 55, 56, 56, 53, 53, 50, 49, 48, 45, 43, 37, 28, 37, 38, 18, 32], [56, 58, 59, 59, 59, 59, 59, 59, 58, 58, 57, 56, 54, 52, 45, 34, 41, 36, 38, 34], [37, 38, 38, 40, 40, 42, 39, 40, 39, 41, 40, 38, 34, 34, 29, 26, 21, 25, 22, 21], [20, 29, 33, 34, 35, 31, 28, 19, 16, 27, 16, 8, 22, 21, 23, 20, 23, 25, 14, 20], [32, 36, 37, 34, 29, 33, 30, 29, 31, 33, 30, 27, 21, 16, 12, 27, 25, 18, 16, 7], [33, 37, 39, 38, 37, 38, 38, 38, 36, 35, 34, 31, 26, 12, 27, 31, 22, 16, 13, 0], [33, 38, 39, 38, 38, 36, 36, 36, 35, 35, 35, 33, 27, 10, 20, 17, 24, 15, 17, 18], [26, 28, 27, 25, 28, 27, 26, 27, 23, 27, 19, 23, 23, 11, 19, 20, 19, 17, 6, 13], [25, 21, 25, 18, 19, 22, 18, 21, 16, 18, 19, 20, 2, 14, 12, 11, 7, 15, 2, 0], [31, 30, 24, 26, 24, 26, 21, 25, 21, 20, 17, 18, 12, 12, 14, 10, 7, 11, 4, 17], [15, 11, 19, 13, 0, 0, 13, 11, 10, 12, 11, 4, 11, 12, 13, 11, 0, 10, 14, 11], [12, 11, 5, 10, 1, 9, 0, 18, 5, 14, 16, 13, 12, 0, 10, 11, 4, 7, 0, 12], [16, 13, 4, 0, 15, 7, 15, 0, 13, 18, 9, 9, 11, 9, 0, 0, 9, 13, 4, 10], [11, 13, 15, 12, 9, 8, 6, 16, 16, 7, 8, 8, 6, 1, 0, 7, 14, 15, 11, 1], [13, 19, 11, 10, 2, 3, 0, 11, 9, 0, 14, 1, 6, 7, 14, 1, 10, 0, 11, 16], [62, 78, 82, 86, 88, 85, 82, 82, 83, 80, 80, 78, 77, 76, 73, 70, 65, 60, 48, 43], [72, 83, 89, 89, 92, 92, 93, 93, 95, 94, 93, 93, 92, 91, 89, 86, 80, 72, 68, 73], [53, 81, 88, 89, 88, 84, 86, 85, 85, 86, 86, 84, 82, 80, 76, 70, 57, 63, 65, 63], [69, 80, 83, 82, 87, 88, 86, 86, 82, 81, 79, 77, 74, 72, 66, 65, 61, 53, 63, 53], [52, 66, 69, 67, 62, 62, 57, 56, 60, 67, 67, 67, 65, 64, 59, 53, 49, 55, 50, 41], [66, 74, 75, 76, 73, 75, 76, 73, 73, 69, 68, 67, 65, 63, 57, 41, 56, 57, 46, 52], [66, 78, 82, 83, 84, 83, 84, 84, 83, 83, 82, 81, 79, 76, 67, 62, 68, 64, 61, 58], [57, 61, 69, 65, 65, 66, 67, 68, 69, 69, 68, 68, 66, 62, 51, 52, 53, 34, 49, 43], [58, 60, 63, 67, 61, 64, 57, 53, 53, 54, 54, 52, 51, 47, 37, 42, 49, 43, 41, 32], [59, 68, 74, 76, 75, 74, 75, 74, 73, 72, 72, 70, 67, 63, 60, 63, 62, 53, 50, 41], [55, 65, 68, 70, 70, 70, 71, 70, 69, 68, 66, 64, 58, 45, 61, 63, 56, 45, 42, 42], [53, 61, 67, 68, 69, 68, 66, 67, 67, 67, 66, 66, 63, 59, 56, 54, 51, 45, 44, 29], [42, 59, 62, 60, 60, 59, 61, 64, 63, 60, 57, 57, 53, 40, 42, 41, 48, 42, 20, 25], [54, 68, 72, 72, 72, 71, 71, 71, 71, 71, 69, 67, 62, 52, 41, 54, 54, 46, 45, 38], [57, 68, 69, 63, 65, 64, 66, 67, 67, 63, 60, 56, 49, 47, 52, 54, 47, 41, 37, 29], [52, 52, 54, 56, 45, 49, 47, 49, 46, 33, 29, 33, 40, 44, 42, 40, 33, 29, 24, 19], [42, 47, 45, 46, 43, 43, 49, 46, 48, 47, 47, 45, 38, 40, 37, 35, 36, 28, 19, 9], [40, 48, 49, 49, 48, 48, 47, 44, 41, 42, 41, 35, 35, 36, 36, 33, 30, 24, 19, 11], [43, 49, 52, 51, 52, 54, 51, 52, 48, 50, 46, 40, 41, 47, 50, 47, 37, 35, 19, 20], [35, 30, 32, 35, 43, 45, 46, 47, 47, 46, 45, 43, 37, 34, 36, 35, 33, 18, 13, 13], [72, 86, 89, 94, 96, 93, 94, 89, 89, 89, 87, 87, 86, 85, 83, 80, 74, 68, 64, 55], [81, 91, 97, 97, 100, 101, 102, 102, 103, 103, 102, 102, 101, 99, 97, 95, 89, 80, 76, 80], [65, 91, 97, 98, 97, 94, 95, 94, 93, 93, 92, 91, 89, 87, 81, 75, 60, 69, 71, 72], [78, 89, 92, 91, 96, 97, 95, 95, 92, 93, 92, 91, 88, 86, 81, 77, 74, 68, 73, 62], [54, 75, 78, 78, 75, 73, 62, 68, 62, 72, 75, 72, 70, 68, 63, 55, 56, 61, 58, 50], [77, 82, 82, 83, 81, 83, 84, 80, 82, 80, 79, 79, 77, 75, 70, 62, 66, 68, 52, 60], [76, 88, 93, 94, 95, 94, 94, 94, 94, 94, 93, 92, 90, 87, 77, 73, 77, 73, 71, 68], [67, 74, 80, 74, 75, 79, 80, 80, 80, 79, 79, 79, 76, 72, 61, 63, 64, 45, 59, 51], [73, 76, 74, 80, 73, 78, 75, 72, 69, 66, 59, 49, 55, 51, 42, 60, 65, 61, 54, 39], [72, 81, 87, 89, 88, 87, 88, 87, 87, 87, 86, 85, 81, 76, 71, 76, 75, 66, 57, 59], [67, 78, 80, 82, 81, 81, 81, 81, 80, 79, 77, 76, 70, 63, 71, 73, 65, 55, 48, 48], [67, 76, 82, 84, 86, 85, 84, 84, 83, 82, 81, 80, 77, 71, 69, 68, 67, 62, 57, 34], [53, 72, 75, 76, 75, 75, 71, 74, 80, 74, 74, 74, 66, 58, 57, 60, 64, 56, 45, 37], [72, 83, 87, 87, 87, 86, 87, 87, 86, 85, 83, 81, 75, 62, 65, 70, 67, 61, 57, 51], [76, 86, 86, 79, 82, 80, 85, 84, 84, 80, 76, 70, 62, 66, 72, 70, 69, 53, 53, 36], [72, 70, 72, 75, 67, 68, 67, 65, 68, 63, 58, 29, 58, 62, 62, 58, 51, 50, 42, 36], [65, 71, 69, 69, 69, 68, 71, 71, 72, 72, 71, 68, 58, 59, 61, 55, 56, 50, 41, 25], [59, 69, 71, 73, 73, 73, 71, 70, 68, 68, 65, 61, 58, 59, 56, 54, 57, 45, 43, 34], [61, 68, 70, 69, 70, 74, 69, 70, 65, 68, 64, 60, 56, 64, 66, 62, 52, 52, 36, 30], [52, 45, 59, 63, 65, 67, 66, 68, 66, 64, 63, 61, 49, 56, 61, 58, 47, 40, 25, 35], [69, 79, 79, 76, 82, 80, 80, 78, 76, 79, 77, 77, 75, 74, 70, 65, 55, 49, 50, 51], [65, 74, 79, 79, 81, 83, 82, 83, 84, 84, 81, 79, 75, 70, 57, 58, 60, 55, 47, 34], [56, 53, 59, 67, 73, 75, 77, 76, 76, 75, 73, 73, 71, 69, 66, 62, 57, 61, 59, 56], [58, 66, 69, 67, 64, 61, 65, 64, 63, 65, 65, 64, 62, 60, 54, 43, 53, 42, 46, 34], [59, 57, 61, 64, 65, 65, 66, 67, 68, 68, 68, 67, 66, 63, 55, 51, 51, 52, 42, 40], [56, 64, 66, 67, 66, 66, 66, 67, 65, 65, 65, 64, 62, 60, 51, 50, 37, 52, 36, 40], [49, 51, 52, 52, 54, 55, 56, 56, 56, 56, 56, 56, 55, 53, 50, 50, 45, 37, 38, 32], [43, 40, 45, 45, 44, 44, 42, 43, 45, 44, 41, 39, 38, 29, 33, 34, 29, 21, 18, 16], [37, 40, 40, 43, 44, 44, 44, 45, 45, 44, 45, 42, 38, 30, 36, 32, 30, 24, 15, 17], [25, 29, 25, 12, 23, 23, 26, 23, 25, 21, 28, 28, 31, 30, 8, 23, 22, 20, 20, 0], [18, 31, 34, 35, 35, 37, 38, 39, 39, 40, 41, 41, 38, 30, 28, 17, 23, 15, 14, 7], [27, 33, 33, 31, 33, 33, 33, 33, 34, 34, 34, 34, 31, 21, 20, 21, 21, 18, 19, 9], [22, 25, 25, 28, 26, 23, 24, 24, 25, 25, 21, 24, 18, 18, 26, 12, 20, 7, 2, 8], [17, 6, 25, 28, 22, 27, 28, 27, 30, 31, 32, 32, 27, 14, 11, 14, 18, 5, 11, 2], [9, 19, 23, 21, 25, 25, 25, 22, 17, 19, 25, 9, 10, 19, 11, 5, 0, 0, 8, 5], [9, 1, 13, 10, 12, 8, 14, 9, 8, 11, 5, 15, 17, 6, 15, 3, 10, 8, 8, 15], [7, 7, 9, 1, 9, 20, 12, 14, 14, 8, 11, 11, 9, 14, 15, 1, 8, 7, 0, 7], [16, 20, 19, 23, 23, 21, 20, 23, 22, 21, 15, 12, 7, 0, 15, 14, 11, 8, 12, 6], [25, 22, 19, 22, 19, 15, 22, 14, 19, 12, 16, 10, 13, 14, 18, 18, 16, 18, 18, 17], [10, 3, 1, 14, 18, 15, 19, 4, 13, 9, 13, 13, 8, 8, 6, 8, 8, 11, 0, 15], [70, 84, 89, 87, 90, 90, 91, 88, 85, 89, 87, 87, 85, 83, 79, 75, 62, 60, 63, 54], [74, 81, 90, 91, 92, 94, 94, 94, 95, 95, 92, 90, 86, 81, 72, 71, 70, 66, 56, 52], [64, 74, 67, 79, 85, 88, 89, 88, 88, 87, 85, 84, 81, 77, 68, 64, 67, 68, 66, 65], [64, 78, 84, 85, 80, 79, 81, 81, 80, 81, 79, 77, 74, 70, 56, 61, 67, 51, 54, 55], [73, 73, 76, 79, 80, 80, 80, 82, 82, 82, 81, 80, 77, 72, 60, 69, 53, 68, 58, 60], [67, 79, 83, 84, 84, 84, 84, 85, 83, 83, 82, 80, 76, 69, 66, 68, 62, 65, 53, 45], [64, 73, 75, 74, 76, 76, 78, 79, 78, 77, 76, 76, 72, 69, 67, 58, 70, 58, 61, 54], [69, 67, 69, 74, 71, 73, 71, 71, 71, 70, 67, 61, 55, 57, 58, 44, 51, 42, 40, 41], [62, 72, 74, 75, 77, 76, 76, 77, 77, 76, 74, 71, 61, 63, 63, 60, 54, 53, 52, 43], [56, 58, 52, 59, 63, 65, 66, 65, 66, 66, 65, 63, 55, 53, 56, 50, 55, 53, 46, 34], [52, 64, 68, 69, 70, 70, 70, 70, 71, 70, 69, 67, 57, 52, 46, 59, 50, 42, 39, 33], [55, 65, 67, 66, 66, 66, 65, 66, 66, 66, 64, 61, 48, 55, 50, 49, 43, 33, 27, 29], [50, 60, 62, 63, 63, 65, 65, 63, 65, 65, 60, 52, 52, 56, 53, 44, 40, 38, 35, 20], [54, 48, 63, 64, 63, 64, 66, 66, 66, 67, 66, 63, 48, 51, 40, 43, 45, 43, 22, 27], [53, 53, 54, 59, 57, 61, 48, 55, 42, 52, 54, 49, 41, 49, 44, 41, 42, 29, 19, 19], [46, 43, 48, 46, 43, 44, 42, 40, 40, 40, 30, 21, 25, 25, 23, 12, 8, 12, 10, 11], [39, 37, 40, 39, 38, 36, 41, 41, 39, 41, 39, 31, 33, 35, 17, 29, 26, 14, 15, 8], [35, 45, 46, 46, 48, 48, 50, 50, 51, 51, 50, 45, 31, 40, 33, 37, 29, 25, 19, 7], [40, 46, 40, 38, 41, 34, 30, 29, 38, 40, 41, 41, 32, 24, 33, 26, 24, 11, 13, 14], [29, 32, 30, 27, 30, 34, 31, 32, 30, 23, 28, 30, 34, 33, 19, 24, 21, 18, 0, 14], [79, 89, 95, 94, 96, 99, 98, 98, 93, 95, 94, 94, 92, 91, 88, 84, 71, 67, 71, 62], [80, 88, 97, 98, 100, 102, 102, 103, 104, 103, 100, 98, 94, 89, 80, 80, 78, 73, 61, 56], [68, 82, 75, 86, 92, 95, 95, 95, 94, 93, 92, 90, 86, 80, 71, 74, 74, 74, 74, 71], [72, 86, 91, 92, 88, 88, 88, 87, 85, 87, 85, 83, 80, 75, 53, 70, 72, 48, 61, 57], [80, 82, 84, 87, 90, 89, 88, 90, 89, 89, 89, 88, 84, 78, 73, 78, 65, 77, 64, 68], [75, 87, 90, 91, 91, 91, 90, 90, 88, 88, 86, 84, 78, 67, 74, 71, 73, 70, 61, 55], [74, 82, 85, 83, 85, 86, 88, 88, 88, 88, 87, 86, 82, 79, 78, 62, 79, 71, 72, 63], [80, 77, 80, 85, 83, 84, 82, 82, 82, 81, 76, 65, 66, 63, 57, 56, 41, 55, 44, 32], [72, 84, 86, 87, 89, 88, 88, 88, 87, 86, 84, 80, 73, 77, 70, 75, 70, 62, 60, 55], [69, 72, 54, 71, 74, 78, 79, 79, 80, 80, 78, 73, 47, 69, 69, 62, 65, 66, 53, 51], [64, 77, 80, 81, 82, 82, 82, 83, 82, 81, 79, 75, 62, 69, 60, 72, 63, 57, 50, 44], [69, 79, 82, 80, 81, 81, 80, 80, 80, 80, 77, 72, 64, 71, 51, 65, 60, 56, 48, 41], [65, 73, 76, 76, 75, 76, 79, 75, 78, 76, 74, 66, 68, 66, 67, 54, 50, 38, 47, 26], [70, 68, 78, 79, 77, 77, 79, 78, 79, 79, 77, 73, 63, 67, 64, 62, 57, 36, 35, 31], [71, 69, 75, 79, 76, 82, 75, 79, 72, 67, 71, 63, 68, 69, 61, 57, 60, 49, 40, 22], [65, 65, 69, 68, 64, 66, 63, 64, 62, 57, 32, 51, 46, 53, 47, 42, 28, 36, 17, 12], [61, 62, 55, 57, 60, 47, 61, 61, 61, 61, 58, 50, 56, 48, 41, 47, 42, 31, 17, 11], [57, 64, 67, 69, 69, 69, 68, 68, 67, 65, 60, 55, 59, 50, 46, 51, 48, 17, 25, 22], [58, 63, 55, 50, 58, 57, 56, 61, 60, 58, 54, 55, 51, 38, 48, 50, 35, 36, 24, 22], [44, 54, 52, 53, 55, 56, 54, 54, 52, 52, 52, 54, 51, 50, 45, 47, 38, 30, 16, 1], [74, 74, 58, 70, 67, 62, 62, 67, 64, 64, 64, 65, 65, 64, 64, 63, 59, 56, 54, 55], [63, 71, 74, 72, 74, 75, 77, 77, 76, 75, 73, 71, 67, 63, 58, 56, 54, 57, 55, 51], [48, 53, 59, 63, 64, 63, 61, 62, 63, 61, 58, 54, 40, 51, 56, 55, 49, 48, 44, 47], [50, 53, 52, 51, 51, 51, 53, 54, 56, 56, 56, 56, 56, 52, 46, 48, 47, 32, 41, 41], [30, 40, 44, 47, 49, 50, 50, 49, 45, 40, 36, 44, 50, 52, 50, 45, 45, 46, 38, 36], [45, 48, 48, 50, 51, 50, 49, 49, 49, 48, 46, 45, 44, 43, 42, 41, 33, 39, 29, 28], [33, 26, 23, 30, 27, 29, 23, 31, 30, 27, 16, 14, 19, 22, 25, 23, 17, 17, 16, 8], [15, 2, 25, 19, 26, 26, 24, 22, 18, 20, 17, 23, 20, 21, 15, 15, 4, 19, 12, 21], [14, 10, 17, 9, 16, 15, 19, 13, 18, 19, 16, 18, 0, 9, 14, 18, 0, 5, 16, 0], [21, 19, 19, 24, 23, 22, 19, 17, 19, 14, 16, 16, 16, 17, 9, 8, 10, 9, 16, 8], [19, 22, 22, 25, 24, 24, 23, 21, 22, 22, 18, 16, 17, 13, 0, 0, 15, 5, 12, 8], [21, 21, 23, 17, 18, 20, 9, 9, 15, 20, 19, 17, 0, 14, 0, 9, 2, 8, 4, 3], [11, 20, 20, 21, 14, 17, 20, 20, 18, 14, 8, 0, 4, 9, 3, 16, 8, 15, 11, 7], [15, 20, 12, 8, 11, 14, 14, 15, 18, 15, 18, 8, 16, 5, 15, 8, 2, 8, 12, 7], [10, 17, 20, 21, 22, 15, 21, 18, 23, 21, 7, 18, 18, 16, 16, 18, 20, 11, 12, 0], [7, 12, 10, 16, 16, 10, 0, 13, 16, 1, 11, 4, 8, 9, 14, 0, 12, 3, 8, 7], [14, 13, 5, 7, 15, 15, 7, 2, 0, 16, 13, 18, 0, 9, 0, 7, 10, 11, 11, 4], [12, 11, 2, 12, 8, 9, 13, 15, 12, 15, 12, 17, 17, 4, 8, 6, 13, 13, 5, 2], [5, 14, 15, 17, 17, 13, 16, 14, 9, 0, 3, 12, 0, 4, 15, 7, 4, 3, 13, 13], [19, 19, 16, 11, 13, 16, 18, 7, 11, 15, 14, 13, 10, 8, 15, 2, 13, 9, 13, 0], [80, 87, 79, 80, 76, 66, 71, 80, 73, 70, 73, 73, 73, 73, 72, 71, 69, 65, 65, 67], [71, 84, 90, 90, 88, 92, 93, 93, 93, 92, 90, 89, 85, 80, 68, 54, 56, 67, 66, 59], [70, 59, 77, 81, 83, 83, 81, 82, 83, 82, 79, 77, 71, 62, 63, 65, 57, 66, 49, 52], [74, 80, 80, 80, 79, 77, 79, 80, 80, 77, 78, 78, 77, 74, 71, 71, 65, 60, 60, 59], [67, 68, 70, 68, 74, 78, 78, 78, 77, 76, 75, 75, 74, 73, 68, 68, 68, 62, 56, 42], [68, 71, 72, 73, 75, 75, 73, 75, 74, 73, 71, 67, 60, 52, 57, 48, 58, 57, 51, 47], [60, 52, 67, 63, 55, 58, 61, 61, 58, 56, 58, 60, 62, 60, 54, 53, 57, 50, 44, 42], [55, 53, 58, 60, 60, 60, 58, 57, 57, 57, 54, 54, 51, 50, 46, 26, 32, 31, 30, 16], [53, 56, 63, 65, 65, 63, 62, 61, 61, 60, 59, 57, 48, 53, 55, 45, 49, 32, 34, 30], [50, 52, 55, 57, 52, 51, 50, 51, 43, 38, 41, 40, 23, 35, 34, 41, 33, 32, 22, 19], [54, 59, 61, 60, 59, 60, 60, 60, 59, 58, 55, 45, 53, 55, 41, 49, 45, 38, 28, 24], [48, 52, 51, 51, 51, 51, 48, 49, 46, 46, 37, 25, 46, 50, 42, 41, 36, 29, 18, 16], [45, 51, 51, 49, 49, 34, 48, 33, 43, 46, 46, 46, 42, 36, 41, 20, 34, 24, 22, 12], [30, 27, 36, 39, 47, 49, 48, 50, 48, 42, 33, 27, 38, 41, 31, 37, 31, 26, 16, 13], [42, 39, 37, 35, 37, 45, 44, 45, 47, 46, 44, 36, 42, 35, 36, 25, 26, 20, 23, 17], [26, 31, 34, 32, 32, 31, 28, 27, 31, 30, 31, 32, 30, 26, 21, 17, 3, 1, 14, 10], [31, 36, 34, 30, 25, 29, 27, 21, 19, 24, 30, 31, 31, 21, 21, 18, 0, 11, 15, 11], [27, 40, 40, 38, 37, 38, 36, 35, 32, 33, 33, 32, 16, 26, 14, 19, 13, 16, 7, 5], [30, 33, 31, 30, 28, 28, 31, 29, 25, 22, 31, 32, 31, 24, 24, 17, 14, 13, 8, 6], [27, 26, 17, 25, 30, 30, 30, 28, 28, 30, 27, 23, 9, 22, 19, 5, 6, 6, 9, 10], [86, 96, 89, 93, 86, 80, 86, 82, 80, 78, 80, 81, 83, 82, 81, 81, 78, 75, 73, 75], [77, 93, 99, 99, 97, 101, 102, 101, 102, 101, 100, 99, 94, 89, 76, 69, 61, 75, 72, 70], [80, 67, 85, 90, 93, 93, 91, 91, 92, 89, 87, 84, 76, 64, 74, 72, 68, 73, 53, 55], [85, 89, 89, 91, 91, 90, 91, 92, 91, 89, 88, 87, 84, 82, 78, 80, 73, 71, 68, 66], [77, 81, 83, 80, 87, 90, 90, 90, 90, 88, 87, 84, 82, 81, 74, 76, 77, 69, 65, 53], [79, 83, 84, 84, 85, 86, 84, 84, 82, 81, 77, 72, 58, 62, 69, 61, 64, 62, 54, 50], [74, 64, 78, 73, 73, 72, 69, 74, 70, 63, 70, 72, 69, 65, 58, 63, 63, 50, 44, 43], [71, 64, 78, 78, 74, 76, 73, 72, 72, 70, 69, 66, 56, 55, 50, 51, 36, 40, 37, 28], [70, 75, 81, 84, 84, 81, 79, 77, 75, 69, 62, 59, 65, 70, 69, 49, 60, 42, 42, 39], [67, 71, 74, 75, 74, 72, 72, 72, 66, 70, 65, 58, 43, 51, 58, 55, 53, 47, 39, 33], [74, 79, 81, 79, 79, 79, 79, 79, 77, 74, 71, 66, 69, 70, 63, 58, 57, 50, 44, 28], [68, 70, 67, 68, 69, 68, 65, 66, 68, 67, 64, 58, 61, 63, 53, 55, 47, 39, 32, 19], [65, 73, 74, 72, 76, 70, 73, 61, 66, 70, 66, 61, 58, 59, 59, 49, 52, 45, 34, 26], [66, 70, 65, 67, 70, 70, 70, 72, 70, 67, 65, 55, 61, 63, 39, 57, 51, 45, 34, 22], [71, 68, 67, 67, 66, 74, 73, 73, 75, 74, 64, 59, 66, 56, 66, 47, 43, 36, 26, 21], [56, 62, 65, 66, 65, 64, 63, 62, 58, 55, 57, 58, 57, 55, 52, 44, 24, 20, 0, 4], [56, 63, 64, 57, 61, 59, 58, 56, 54, 52, 50, 55, 55, 34, 47, 37, 33, 28, 19, 3], [55, 61, 60, 61, 62, 61, 60, 59, 56, 47, 53, 53, 43, 48, 43, 32, 31, 24, 14, 15], [54, 57, 56, 59, 60, 58, 53, 52, 54, 51, 50, 51, 52, 41, 43, 31, 31, 22, 10, 7], [52, 58, 57, 56, 61, 62, 62, 62, 62, 60, 54, 55, 56, 49, 47, 36, 30, 27, 15, 13], [77, 82, 86, 87, 86, 86, 86, 87, 86, 85, 82, 80, 76, 73, 66, 59, 46, 52, 56, 52], [52, 57, 51, 62, 64, 65, 68, 68, 69, 69, 68, 66, 64, 65, 67, 66, 58, 56, 53, 36], [49, 37, 39, 42, 48, 51, 54, 54, 53, 52, 50, 48, 42, 40, 36, 37, 31, 32, 38, 34], [46, 49, 50, 53, 55, 55, 55, 55, 55, 54, 53, 50, 45, 46, 47, 40, 24, 40, 38, 27], [42, 47, 49, 50, 50, 51, 51, 50, 50, 48, 46, 44, 42, 42, 39, 39, 32, 31, 28, 25], [16, 21, 25, 29, 18, 28, 28, 25, 26, 29, 33, 31, 16, 27, 22, 18, 27, 20, 21, 13], [5, 24, 21, 27, 26, 22, 26, 29, 28, 29, 27, 27, 26, 22, 17, 16, 14, 8, 14, 10], [14, 21, 18, 17, 17, 8, 10, 19, 13, 7, 17, 17, 20, 16, 12, 8, 15, 12, 12, 18], [20, 23, 27, 28, 24, 26, 22, 20, 13, 21, 20, 21, 20, 17, 8, 16, 10, 13, 8, 12], [20, 18, 26, 23, 16, 23, 12, 10, 8, 5, 14, 13, 14, 10, 13, 15, 17, 14, 15, 18], [20, 22, 27, 12, 21, 12, 16, 21, 15, 14, 17, 12, 17, 15, 6, 17, 16, 14, 3, 5], [19, 22, 20, 22, 19, 23, 19, 22, 11, 22, 9, 23, 13, 14, 6, 14, 17, 18, 7, 17], [25, 14, 25, 24, 15, 22, 11, 22, 17, 9, 17, 14, 13, 10, 12, 14, 10, 14, 0, 4], [12, 7, 19, 22, 16, 8, 10, 0, 19, 6, 13, 5, 15, 17, 10, 13, 12, 7, 9, 6], [11, 10, 13, 24, 13, 20, 12, 12, 12, 5, 9, 10, 12, 12, 18, 17, 11, 8, 14, 11], [11, 14, 10, 18, 11, 13, 4, 3, 6, 14, 16, 14, 15, 11, 12, 12, 8, 0, 0, 12], [6, 15, 9, 13, 0, 12, 9, 2, 5, 12, 10, 5, 0, 11, 1, 16, 9, 18, 13, 7], [6, 16, 8, 17, 13, 14, 4, 4, 11, 11, 0, 9, 18, 6, 0, 6, 9, 18, 16, 10], [17, 9, 15, 21, 10, 10, 5, 14, 8, 11, 14, 8, 0, 9, 1, 6, 10, 6, 12, 2], [16, 19, 16, 10, 15, 14, 20, 8, 12, 9, 15, 15, 11, 17, 7, 16, 8, 5, 13, 15], [86, 91, 96, 99, 97, 97, 97, 97, 97, 96, 93, 91, 88, 84, 77, 69, 62, 58, 64, 62], [70, 72, 74, 80, 85, 85, 89, 89, 89, 89, 88, 86, 81, 77, 75, 75, 73, 73, 65, 56], [71, 66, 64, 67, 70, 75, 77, 78, 76, 76, 74, 72, 68, 66, 63, 58, 58, 45, 50, 43], [69, 70, 72, 76, 78, 78, 77, 77, 77, 76, 74, 72, 68, 68, 68, 62, 51, 57, 59, 47], [72, 77, 79, 80, 81, 82, 81, 81, 80, 79, 78, 76, 71, 63, 51, 52, 58, 52, 49, 44], [57, 59, 61, 66, 63, 66, 67, 67, 67, 67, 65, 63, 58, 51, 46, 41, 46, 48, 36, 30], [51, 62, 62, 62, 65, 66, 66, 67, 67, 67, 66, 65, 60, 52, 51, 44, 51, 35, 38, 31], [46, 47, 50, 45, 47, 47, 50, 50, 50, 49, 50, 49, 45, 40, 37, 33, 27, 26, 17, 17], [45, 53, 51, 50, 50, 48, 47, 45, 39, 45, 40, 40, 38, 25, 39, 32, 25, 17, 11, 8], [28, 38, 38, 36, 35, 36, 35, 29, 25, 25, 33, 32, 27, 20, 23, 22, 11, 9, 9, 17], [40, 38, 40, 44, 41, 41, 39, 37, 36, 35, 38, 43, 42, 34, 17, 29, 21, 23, 13, 11], [23, 32, 37, 41, 41, 42, 40, 40, 38, 32, 32, 37, 31, 32, 20, 25, 21, 23, 13, 21], [33, 29, 23, 32, 32, 37, 36, 35, 32, 29, 22, 21, 25, 26, 17, 23, 6, 12, 15, 9], [35, 38, 35, 16, 32, 27, 34, 28, 32, 25, 24, 20, 21, 18, 13, 18, 11, 13, 13, 11], [24, 31, 33, 34, 33, 33, 34, 33, 33, 29, 18, 16, 24, 8, 13, 9, 8, 3, 9, 3], [17, 16, 21, 16, 19, 22, 21, 22, 21, 20, 20, 18, 17, 8, 14, 11, 2, 13, 16, 8], [17, 1, 17, 15, 20, 17, 16, 19, 14, 16, 12, 15, 11, 0, 13, 4, 8, 9, 7, 11], [18, 20, 26, 24, 23, 22, 26, 23, 19, 20, 15, 16, 4, 17, 15, 14, 17, 13, 7, 3], [20, 14, 9, 15, 11, 15, 20, 19, 26, 23, 16, 10, 17, 11, 2, 17, 14, 5, 10, 14], [21, 24, 27, 27, 23, 27, 26, 27, 25, 22, 16, 21, 23, 10, 19, 10, 14, 11, 12, 16], [98, 105, 110, 112, 111, 111, 111, 111, 110, 109, 106, 105, 102, 98, 90, 81, 77, 73, 72, 72], [87, 85, 90, 94, 101, 103, 105, 106, 105, 104, 103, 101, 97, 92, 88, 88, 87, 87, 77, 71], [88, 82, 81, 85, 84, 90, 91, 91, 91, 89, 87, 85, 81, 78, 74, 63, 71, 62, 60, 57], [87, 87, 88, 93, 95, 95, 95, 95, 95, 93, 91, 88, 85, 83, 83, 79, 74, 63, 77, 64], [90, 95, 97, 99, 99, 100, 100, 99, 99, 97, 95, 93, 87, 80, 75, 76, 76, 66, 67, 60], [78, 79, 82, 86, 83, 87, 87, 83, 82, 81, 79, 76, 70, 60, 62, 63, 48, 63, 50, 39], [76, 85, 85, 83, 86, 85, 86, 87, 89, 88, 86, 84, 77, 76, 77, 63, 70, 60, 56, 48], [73, 78, 81, 77, 71, 75, 79, 76, 78, 78, 79, 77, 73, 67, 63, 61, 58, 46, 43, 38], [77, 86, 85, 82, 84, 83, 80, 67, 77, 77, 75, 78, 69, 73, 64, 68, 52, 51, 32, 14], [76, 68, 71, 70, 71, 76, 74, 75, 73, 75, 75, 74, 61, 54, 62, 52, 51, 46, 40, 28], [74, 74, 67, 74, 70, 70, 66, 61, 62, 66, 70, 72, 71, 62, 47, 56, 55, 46, 39, 32], [61, 62, 70, 75, 77, 76, 75, 74, 69, 63, 61, 64, 58, 56, 56, 51, 34, 42, 32, 20], [72, 70, 69, 69, 63, 73, 74, 75, 73, 71, 62, 48, 62, 59, 57, 56, 48, 44, 33, 25], [66, 75, 75, 68, 70, 70, 69, 72, 69, 68, 65, 63, 58, 57, 38, 51, 40, 31, 12, 16], [70, 74, 74, 75, 75, 76, 76, 76, 75, 75, 60, 62, 65, 59, 53, 51, 36, 36, 24, 15], [70, 71, 68, 66, 68, 68, 68, 64, 53, 55, 63, 65, 58, 52, 36, 38, 32, 26, 12, 6], [63, 58, 61, 59, 62, 63, 63, 61, 59, 52, 51, 57, 44, 45, 29, 36, 25, 11, 5, 19], [61, 67, 65, 66, 66, 66, 64, 62, 59, 55, 55, 53, 49, 47, 49, 36, 25, 27, 7, 12], [57, 60, 61, 62, 65, 65, 65, 65, 64, 61, 51, 50, 44, 35, 39, 39, 21, 13, 9, 5], [65, 66, 64, 63, 63, 64, 61, 60, 58, 58, 54, 50, 47, 47, 33, 36, 16, 12, 13, 14], [82, 78, 79, 83, 84, 83, 77, 82, 79, 80, 75, 74, 71, 67, 62, 47, 56, 54, 45, 51], [62, 72, 69, 69, 50, 44, 60, 58, 58, 54, 56, 58, 60, 61, 60, 58, 57, 54, 45, 47], [59, 63, 64, 65, 67, 67, 65, 65, 65, 63, 62, 60, 57, 55, 50, 49, 42, 43, 40, 45], [54, 56, 57, 57, 55, 54, 55, 54, 53, 51, 45, 42, 42, 38, 37, 37, 38, 36, 35, 27], [20, 33, 25, 22, 33, 34, 33, 30, 14, 26, 26, 26, 16, 26, 25, 21, 27, 29, 22, 15], [31, 34, 38, 35, 37, 35, 31, 34, 27, 26, 25, 22, 25, 29, 28, 26, 22, 5, 14, 13], [26, 20, 13, 12, 11, 15, 2, 7, 18, 16, 13, 21, 15, 13, 16, 8, 13, 3, 10, 21], [18, 14, 22, 12, 11, 8, 6, 16, 16, 14, 7, 14, 9, 15, 15, 15, 15, 9, 7, 17], [19, 19, 26, 18, 21, 19, 16, 19, 11, 10, 22, 1, 11, 19, 7, 16, 13, 16, 15, 20], [9, 20, 17, 23, 17, 19, 12, 17, 8, 19, 13, 4, 0, 16, 16, 8, 7, 12, 7, 17], [10, 22, 20, 10, 16, 15, 15, 14, 17, 7, 16, 7, 0, 14, 13, 12, 14, 10, 12, 13], [18, 21, 22, 16, 19, 16, 6, 20, 17, 21, 16, 11, 16, 12, 12, 12, 15, 8, 10, 7], [20, 20, 16, 22, 19, 14, 7, 7, 8, 15, 17, 14, 13, 13, 4, 15, 10, 0, 10, 11], [22, 22, 23, 13, 19, 19, 4, 15, 16, 1, 17, 7, 12, 14, 18, 6, 12, 14, 0, 10], [23, 22, 20, 22, 20, 23, 19, 22, 23, 18, 17, 15, 16, 6, 13, 3, 7, 15, 10, 9], [15, 10, 17, 15, 12, 16, 6, 15, 9, 10, 5, 15, 10, 11, 16, 11, 16, 16, 14, 3], [10, 23, 26, 17, 22, 20, 17, 12, 16, 18, 16, 12, 12, 8, 14, 13, 20, 16, 10, 20], [12, 21, 17, 16, 3, 1, 8, 17, 13, 7, 11, 4, 0, 10, 4, 8, 13, 4, 5, 14], [19, 16, 20, 18, 22, 18, 17, 19, 6, 9, 14, 8, 8, 11, 14, 2, 12, 15, 12, 2], [17, 23, 17, 18, 20, 19, 18, 4, 13, 10, 3, 17, 14, 6, 17, 11, 9, 12, 9, 13], [89, 86, 85, 91, 91, 91, 85, 89, 87, 88, 83, 82, 79, 75, 68, 61, 60, 60, 26, 55], [74, 83, 85, 82, 65, 67, 75, 75, 75, 74, 72, 69, 66, 67, 69, 67, 66, 65, 55, 57], [74, 81, 82, 83, 85, 85, 83, 83, 82, 81, 80, 79, 75, 72, 64, 67, 62, 49, 56, 54], [74, 78, 78, 79, 76, 76, 77, 77, 76, 75, 71, 68, 65, 62, 63, 62, 52, 40, 51, 46], [64, 68, 67, 70, 68, 69, 68, 67, 66, 65, 62, 59, 50, 47, 53, 51, 46, 40, 45, 32], [63, 64, 66, 65, 67, 67, 67, 67, 65, 64, 60, 56, 45, 34, 47, 46, 48, 41, 25, 23], [55, 51, 57, 60, 57, 59, 59, 59, 59, 57, 55, 52, 48, 48, 44, 46, 29, 39, 17, 23], [48, 56, 55, 52, 52, 50, 50, 51, 49, 46, 43, 39, 33, 36, 31, 17, 28, 21, 9, 17], [23, 41, 38, 37, 36, 35, 36, 37, 34, 34, 29, 27, 26, 25, 16, 17, 2, 8, 11, 17], [28, 32, 39, 38, 36, 37, 36, 33, 34, 29, 24, 14, 27, 27, 24, 0, 11, 14, 7, 14], [35, 38, 38, 33, 34, 35, 30, 27, 28, 26, 25, 26, 21, 18, 15, 20, 8, 8, 5, 14], [31, 33, 32, 31, 34, 33, 33, 33, 31, 30, 28, 26, 19, 12, 7, 15, 9, 13, 6, 9], [30, 30, 28, 26, 20, 8, 22, 20, 22, 18, 17, 18, 7, 10, 3, 15, 17, 14, 8, 11], [30, 29, 29, 30, 31, 30, 26, 19, 16, 15, 20, 19, 19, 17, 6, 6, 15, 15, 10, 0], [29, 28, 26, 25, 28, 28, 24, 23, 21, 16, 18, 10, 14, 17, 15, 13, 13, 7, 7, 6], [27, 25, 24, 22, 17, 12, 23, 15, 17, 14, 7, 14, 12, 18, 6, 11, 12, 14, 6, 13], [13, 15, 18, 12, 22, 13, 16, 15, 20, 17, 18, 9, 20, 5, 11, 15, 15, 0, 17, 5], [23, 24, 21, 26, 25, 22, 21, 23, 5, 18, 11, 14, 14, 15, 8, 10, 14, 12, 2, 2], [26, 27, 27, 27, 27, 22, 21, 19, 19, 20, 17, 17, 8, 8, 14, 18, 17, 11, 20, 0], [26, 30, 30, 29, 30, 24, 23, 18, 9, 20, 12, 13, 17, 13, 19, 19, 6, 9, 11, 11], [101, 97, 97, 103, 104, 103, 97, 102, 99, 101, 95, 95, 91, 88, 80, 68, 71, 70, 53, 66], [87, 96, 99, 95, 83, 82, 89, 91, 90, 90, 87, 85, 78, 71, 77, 77, 75, 76, 63, 66], [89, 96, 97, 98, 99, 100, 97, 97, 96, 95, 93, 91, 88, 83, 72, 78, 75, 59, 66, 65], [90, 94, 94, 95, 93, 93, 93, 94, 93, 91, 86, 83, 79, 70, 75, 75, 52, 67, 60, 57], [82, 86, 86, 88, 86, 87, 85, 85, 86, 85, 83, 81, 75, 67, 70, 70, 59, 53, 60, 46], [84, 86, 87, 87, 88, 88, 90, 88, 87, 85, 81, 77, 64, 55, 61, 64, 64, 62, 45, 37], [75, 78, 81, 82, 79, 81, 81, 80, 80, 78, 74, 68, 64, 68, 66, 64, 39, 55, 24, 39], [75, 87, 86, 83, 82, 81, 80, 81, 77, 77, 75, 74, 65, 61, 61, 45, 57, 48, 24, 33], [59, 79, 76, 75, 75, 73, 73, 70, 68, 63, 59, 57, 48, 56, 47, 53, 42, 33, 20, 22], [70, 79, 79, 79, 78, 78, 77, 76, 74, 72, 68, 63, 53, 60, 61, 40, 40, 35, 16, 13], [66, 72, 70, 65, 66, 64, 63, 63, 58, 58, 50, 38, 53, 52, 45, 38, 36, 30, 22, 0], [64, 68, 70, 70, 72, 72, 72, 71, 71, 68, 62, 61, 59, 52, 41, 40, 32, 11, 0, 5], [67, 72, 71, 73, 68, 65, 62, 59, 58, 58, 55, 40, 46, 40, 36, 32, 14, 7, 11, 4], [75, 76, 77, 76, 74, 74, 71, 66, 53, 59, 59, 47, 52, 55, 41, 46, 33, 27, 11, 7], [68, 65, 64, 66, 64, 64, 62, 60, 54, 48, 53, 51, 46, 39, 33, 27, 0, 22, 10, 12], [67, 65, 64, 63, 61, 59, 61, 61, 58, 58, 55, 47, 43, 39, 28, 26, 6, 8, 13, 12], [53, 56, 58, 59, 59, 51, 53, 50, 44, 47, 39, 42, 36, 31, 24, 25, 7, 15, 15, 10], [56, 57, 56, 53, 53, 54, 54, 53, 49, 48, 45, 39, 29, 27, 21, 15, 7, 13, 8, 12], [58, 59, 59, 59, 59, 58, 57, 55, 50, 46, 42, 29, 34, 28, 12, 17, 5, 6, 5, 6], [52, 53, 55, 54, 51, 48, 46, 40, 19, 28, 28, 29, 24, 21, 12, 15, 11, 12, 6, 8], [82, 86, 87, 89, 89, 91, 91, 91, 90, 89, 87, 85, 81, 77, 67, 43, 59, 55, 53, 56], [65, 69, 67, 67, 62, 62, 62, 61, 57, 55, 53, 55, 56, 55, 50, 51, 52, 45, 45, 41], [47, 51, 48, 52, 45, 50, 46, 47, 48, 47, 48, 46, 44, 41, 34, 31, 35, 33, 18, 27], [41, 49, 47, 48, 47, 47, 47, 47, 46, 46, 44, 39, 26, 18, 29, 22, 18, 23, 19, 16], [36, 37, 25, 34, 33, 32, 36, 38, 35, 30, 22, 29, 23, 13, 12, 18, 23, 10, 6, 12], [42, 44, 45, 45, 45, 46, 45, 45, 43, 41, 37, 29, 14, 22, 27, 22, 24, 21, 9, 15], [29, 31, 33, 33, 32, 31, 29, 30, 29, 24, 16, 22, 17, 17, 13, 15, 10, 14, 0, 9], [28, 28, 31, 33, 32, 28, 29, 29, 27, 25, 21, 21, 16, 10, 17, 11, 7, 6, 13, 13], [16, 16, 14, 20, 0, 11, 18, 6, 17, 18, 20, 0, 10, 10, 13, 2, 11, 10, 6, 19], [12, 21, 20, 16, 19, 9, 5, 4, 14, 16, 4, 9, 17, 10, 2, 11, 11, 12, 8, 4], [23, 18, 22, 15, 19, 7, 17, 18, 13, 16, 10, 13, 18, 14, 21, 8, 15, 14, 12, 10], [14, 7, 11, 16, 10, 0, 14, 11, 7, 17, 9, 10, 14, 11, 14, 14, 5, 8, 11, 16], [17, 16, 13, 18, 22, 21, 20, 18, 4, 11, 9, 14, 17, 14, 9, 15, 6, 7, 7, 15], [14, 10, 11, 16, 20, 13, 18, 4, 8, 17, 15, 15, 12, 12, 19, 8, 11, 20, 15, 19], [17, 10, 15, 5, 14, 10, 5, 7, 16, 0, 10, 16, 15, 13, 7, 12, 0, 17, 0, 14], [23, 20, 22, 14, 16, 15, 17, 16, 10, 10, 12, 18, 17, 18, 20, 19, 16, 10, 15, 0], [13, 13, 1, 2, 8, 12, 16, 19, 14, 16, 3, 10, 6, 13, 9, 11, 14, 12, 16, 14], [7, 16, 8, 13, 18, 11, 1, 1, 14, 18, 8, 7, 16, 14, 15, 1, 11, 19, 10, 14], [9, 11, 15, 17, 13, 22, 18, 7, 14, 17, 3, 17, 18, 10, 15, 10, 4, 16, 13, 13], [9, 13, 15, 10, 14, 14, 4, 13, 12, 11, 14, 13, 19, 13, 13, 10, 13, 6, 7, 9], [95, 98, 99, 103, 102, 104, 105, 104, 103, 102, 100, 98, 94, 90, 81, 67, 68, 66, 65, 66], [82, 88, 90, 87, 86, 87, 88, 88, 86, 85, 82, 79, 75, 71, 65, 63, 65, 61, 57, 52], [83, 81, 76, 80, 78, 76, 78, 78, 78, 77, 75, 73, 70, 65, 55, 56, 59, 54, 41, 41], [71, 78, 76, 76, 77, 76, 76, 76, 74, 72, 72, 68, 59, 58, 59, 55, 48, 44, 35, 22], [71, 71, 63, 71, 70, 70, 69, 70, 69, 67, 66, 63, 57, 48, 52, 53, 44, 38, 33, 28], [75, 79, 79, 79, 79, 79, 79, 79, 77, 76, 73, 69, 63, 60, 62, 56, 39, 44, 35, 30], [60, 63, 58, 61, 59, 59, 61, 62, 64, 64, 63, 61, 52, 36, 44, 39, 33, 27, 19, 6], [61, 65, 66, 67, 67, 66, 65, 64, 62, 60, 56, 51, 39, 47, 30, 33, 18, 20, 19, 14], [45, 48, 48, 43, 44, 43, 44, 43, 41, 41, 38, 30, 19, 19, 19, 16, 21, 15, 4, 9], [40, 39, 30, 36, 34, 25, 27, 33, 32, 33, 28, 23, 9, 23, 12, 13, 10, 0, 17, 21], [42, 45, 43, 41, 41, 41, 41, 41, 39, 36, 32, 25, 25, 21, 13, 9, 8, 13, 8, 20], [36, 33, 34, 35, 37, 38, 34, 31, 29, 27, 21, 23, 22, 19, 13, 14, 13, 12, 15, 20], [45, 48, 47, 46, 44, 46, 38, 39, 37, 33, 30, 23, 13, 17, 12, 3, 18, 17, 14, 16], [42, 42, 42, 40, 39, 38, 35, 32, 27, 8, 25, 25, 19, 18, 11, 3, 18, 15, 12, 16], [32, 31, 34, 32, 31, 32, 30, 28, 22, 17, 20, 16, 10, 13, 19, 6, 8, 3, 9, 16], [16, 24, 21, 28, 30, 23, 21, 17, 27, 24, 8, 19, 20, 11, 7, 12, 0, 20, 16, 7], [24, 12, 19, 5, 22, 11, 18, 12, 9, 9, 17, 15, 14, 20, 12, 15, 14, 7, 16, 11], [8, 12, 6, 15, 18, 18, 15, 8, 7, 17, 18, 7, 7, 14, 12, 11, 10, 3, 9, 11], [13, 19, 19, 25, 7, 18, 8, 12, 13, 7, 6, 6, 17, 16, 6, 5, 14, 15, 19, 8], [29, 24, 21, 25, 15, 14, 11, 9, 16, 14, 11, 13, 9, 0, 19, 8, 16, 3, 7, 7], [105, 109, 111, 114, 114, 115, 116, 115, 114, 113, 112, 110, 105, 100, 90, 75, 77, 75, 73, 74], [94, 99, 104, 100, 101, 100, 100, 100, 99, 98, 94, 91, 86, 84, 79, 76, 78, 74, 69, 60], [96, 96, 91, 93, 91, 91, 95, 96, 97, 95, 93, 91, 87, 82, 71, 70, 73, 69, 58, 55], [83, 88, 87, 88, 89, 89, 87, 87, 85, 82, 80, 80, 69, 69, 70, 67, 58, 54, 47, 29], [88, 88, 83, 90, 90, 89, 88, 89, 88, 85, 84, 81, 76, 64, 66, 68, 59, 54, 48, 39], [92, 96, 97, 97, 97, 97, 97, 97, 96, 94, 92, 88, 79, 72, 75, 69, 63, 55, 55, 39], [76, 82, 77, 78, 77, 74, 73, 76, 80, 80, 78, 75, 66, 54, 62, 52, 52, 38, 37, 3], [83, 87, 87, 89, 87, 87, 85, 84, 81, 79, 76, 73, 61, 66, 53, 50, 39, 33, 30, 13], [77, 77, 80, 75, 77, 76, 77, 78, 75, 72, 68, 62, 40, 46, 42, 42, 36, 26, 22, 10], [74, 79, 79, 78, 77, 77, 77, 77, 73, 68, 65, 65, 65, 61, 43, 40, 28, 13, 12, 8], [68, 73, 71, 70, 68, 68, 68, 67, 61, 61, 52, 53, 50, 50, 26, 32, 28, 22, 10, 12], [62, 75, 75, 76, 75, 73, 66, 64, 66, 53, 53, 55, 55, 42, 42, 25, 25, 8, 14, 14], [78, 80, 76, 74, 79, 74, 75, 72, 68, 61, 37, 38, 48, 43, 39, 31, 21, 17, 3, 10], [79, 77, 75, 77, 75, 71, 74, 68, 65, 60, 53, 49, 47, 36, 23, 7, 13, 6, 17, 16], [70, 70, 73, 70, 71, 72, 72, 69, 66, 62, 49, 50, 47, 42, 35, 28, 17, 17, 11, 9], [47, 65, 65, 67, 64, 56, 53, 57, 56, 53, 44, 47, 26, 23, 12, 13, 16, 19, 16, 15], [55, 47, 53, 56, 58, 48, 34, 51, 52, 48, 29, 36, 20, 17, 12, 14, 10, 10, 15, 3], [53, 48, 44, 47, 43, 34, 28, 32, 30, 23, 18, 18, 19, 13, 15, 3, 11, 16, 19, 19], [52, 45, 44, 43, 45, 22, 29, 33, 31, 27, 20, 5, 20, 18, 13, 16, 5, 16, 18, 12], [48, 46, 51, 47, 46, 41, 35, 32, 26, 24, 26, 12, 18, 18, 10, 16, 3, 8, 10, 18], [82, 87, 90, 92, 93, 93, 94, 94, 91, 90, 88, 85, 80, 73, 71, 75, 71, 68, 57, 59], [55, 51, 48, 51, 53, 57, 55, 56, 55, 55, 51, 45, 45, 46, 43, 40, 41, 29, 34, 26], [40, 40, 44, 44, 45, 48, 48, 48, 46, 45, 43, 40, 28, 32, 24, 26, 30, 16, 11, 22], [39, 43, 41, 36, 39, 39, 34, 37, 33, 33, 32, 26, 30, 33, 24, 9, 26, 7, 17, 21], [35, 32, 36, 33, 33, 31, 31, 30, 17, 26, 21, 24, 22, 13, 22, 17, 25, 11, 18, 12], [22, 33, 36, 33, 31, 28, 26, 28, 24, 21, 20, 19, 22, 11, 22, 16, 21, 19, 16, 22], [18, 19, 24, 21, 19, 18, 23, 20, 18, 19, 5, 15, 10, 9, 6, 16, 21, 11, 14, 22], [9, 19, 15, 19, 19, 19, 21, 15, 18, 18, 14, 18, 18, 6, 15, 18, 19, 16, 18, 5], [22, 12, 15, 9, 16, 16, 17, 17, 10, 21, 4, 13, 14, 10, 17, 9, 23, 7, 11, 17], [21, 13, 18, 16, 13, 11, 18, 16, 22, 14, 7, 14, 15, 11, 13, 17, 16, 20, 11, 6], [19, 3, 8, 16, 18, 12, 15, 11, 2, 7, 13, 18, 0, 12, 14, 19, 23, 6, 3, 13], [14, 21, 16, 13, 18, 11, 14, 13, 16, 17, 14, 13, 15, 17, 15, 19, 15, 9, 12, 8], [8, 10, 15, 10, 20, 18, 13, 13, 17, 10, 0, 12, 12, 11, 14, 12, 8, 8, 6, 18], [18, 16, 10, 13, 16, 16, 17, 18, 13, 14, 19, 6, 2, 12, 5, 9, 19, 15, 17, 14], [5, 18, 12, 17, 15, 16, 17, 20, 4, 16, 10, 15, 0, 20, 16, 11, 4, 0, 13, 13], [19, 17, 12, 18, 18, 15, 15, 13, 14, 20, 13, 14, 4, 1, 11, 7, 18, 14, 16, 13], [19, 15, 7, 15, 12, 20, 19, 9, 17, 19, 15, 16, 18, 16, 12, 22, 9, 17, 10, 12], [3, 5, 16, 0, 19, 19, 12, 15, 22, 15, 17, 14, 1, 13, 4, 13, 18, 4, 17, 12], [18, 15, 17, 17, 18, 12, 18, 17, 19, 7, 17, 20, 19, 16, 17, 6, 18, 15, 6, 11], [9, 13, 10, 19, 15, 15, 14, 9, 11, 7, 9, 5, 18, 5, 23, 10, 11, 21, 17, 18], [93, 98, 101, 103, 105, 104, 106, 105, 103, 102, 99, 96, 90, 82, 84, 87, 83, 77, 70, 71], [73, 76, 79, 77, 78, 78, 78, 77, 76, 76, 73, 70, 64, 70, 65, 69, 58, 63, 51, 48], [65, 72, 74, 74, 75, 75, 74, 72, 70, 68, 58, 55, 63, 60, 62, 54, 56, 51, 36, 31], [59, 62, 59, 56, 55, 55, 53, 55, 42, 38, 40, 37, 39, 46, 41, 38, 29, 23, 19, 16], [61, 63, 63, 62, 61, 60, 57, 56, 51, 49, 38, 44, 47, 51, 39, 49, 40, 34, 19, 13], [54, 50, 48, 49, 46, 47, 43, 43, 40, 35, 40, 35, 32, 40, 22, 31, 24, 23, 20, 18], [32, 36, 40, 39, 35, 36, 36, 36, 32, 30, 28, 31, 13, 21, 21, 17, 8, 8, 18, 17], [35, 38, 39, 39, 38, 38, 37, 35, 29, 23, 30, 26, 12, 9, 15, 16, 15, 14, 3, 8], [17, 20, 20, 22, 18, 22, 8, 10, 16, 17, 17, 12, 20, 15, 3, 13, 15, 9, 12, 0], [13, 18, 23, 13, 2, 21, 18, 19, 16, 17, 18, 14, 11, 22, 2, 15, 10, 9, 14, 19], [21, 6, 20, 16, 17, 20, 24, 19, 25, 24, 13, 20, 20, 0, 7, 7, 9, 10, 18, 18], [16, 3, 9, 11, 20, 11, 0, 9, 4, 4, 17, 17, 13, 12, 11, 9, 12, 14, 11, 18], [26, 19, 17, 19, 16, 6, 19, 14, 10, 14, 0, 20, 3, 12, 17, 20, 10, 10, 15, 0], [23, 20, 16, 10, 20, 4, 17, 17, 17, 1, 3, 14, 1, 12, 22, 11, 13, 13, 20, 8], [12, 10, 9, 17, 19, 8, 12, 16, 16, 16, 17, 19, 10, 20, 15, 15, 16, 12, 5, 19], [16, 17, 20, 15, 19, 15, 12, 16, 21, 12, 14, 19, 6, 17, 12, 15, 7, 11, 14, 10], [0, 26, 24, 19, 16, 9, 10, 16, 18, 5, 21, 13, 14, 16, 16, 14, 14, 14, 13, 7], [22, 3, 6, 18, 18, 12, 19, 16, 20, 8, 17, 4, 6, 12, 16, 13, 2, 11, 14, 19], [16, 22, 20, 16, 20, 18, 14, 13, 5, 13, 15, 10, 11, 17, 12, 21, 9, 14, 1, 13], [4, 8, 23, 14, 16, 16, 11, 12, 2, 18, 6, 16, 12, 22, 17, 9, 20, 1, 0, 5], [106, 110, 114, 117, 118, 117, 119, 118, 115, 114, 111, 108, 100, 84, 99, 99, 93, 85, 81, 81], [89, 91, 95, 92, 95, 92, 91, 92, 91, 90, 89, 85, 82, 88, 80, 83, 75, 71, 69, 63], [87, 94, 97, 97, 98, 98, 98, 97, 96, 93, 85, 82, 85, 82, 76, 63, 70, 66, 52, 34], [83, 91, 89, 87, 87, 85, 86, 85, 78, 77, 66, 70, 63, 70, 59, 61, 53, 48, 38, 21], [87, 91, 93, 92, 93, 91, 89, 88, 84, 80, 76, 79, 77, 68, 57, 71, 60, 44, 31, 21], [85, 85, 85, 84, 81, 79, 72, 75, 67, 66, 71, 72, 51, 65, 57, 58, 31, 35, 25, 5], [64, 69, 71, 69, 68, 62, 64, 65, 66, 64, 56, 53, 47, 49, 51, 38, 24, 24, 1, 8], [81, 83, 82, 82, 83, 81, 79, 77, 61, 65, 60, 61, 61, 59, 50, 51, 32, 25, 9, 6], [67, 61, 69, 66, 64, 65, 63, 63, 60, 58, 52, 44, 39, 42, 36, 30, 16, 17, 19, 18], [57, 59, 54, 52, 51, 48, 53, 57, 50, 50, 50, 43, 40, 38, 20, 27, 9, 17, 14, 17], [69, 71, 71, 70, 69, 68, 66, 63, 59, 54, 47, 44, 46, 49, 30, 29, 17, 14, 14, 10], [58, 61, 56, 47, 56, 56, 43, 49, 43, 42, 38, 44, 41, 44, 16, 12, 5, 19, 10, 10], [68, 68, 66, 64, 53, 51, 56, 56, 56, 52, 43, 32, 37, 43, 21, 19, 18, 11, 14, 18], [54, 59, 60, 61, 60, 58, 53, 38, 36, 39, 47, 43, 38, 42, 24, 10, 18, 9, 16, 16], [45, 50, 49, 48, 50, 46, 38, 42, 41, 32, 26, 22, 16, 41, 20, 8, 17, 17, 17, 12], [53, 56, 54, 52, 52, 51, 45, 42, 45, 37, 31, 31, 27, 41, 6, 20, 5, 11, 7, 13], [25, 31, 16, 33, 30, 22, 29, 34, 34, 28, 6, 16, 11, 40, 10, 12, 12, 18, 19, 16], [21, 31, 14, 25, 32, 22, 21, 16, 16, 24, 10, 13, 18, 40, 11, 11, 19, 11, 8, 15], [29, 25, 32, 29, 22, 23, 17, 5, 8, 23, 18, 13, 17, 40, 14, 7, 13, 1, 12, 11], [13, 24, 34, 24, 23, 12, 16, 18, 6, 9, 15, 12, 14, 40, 2, 14, 21, 16, 14, 15], [85, 88, 91, 93, 93, 93, 92, 90, 90, 88, 82, 78, 77, 75, 64, 59, 51, 70, 54, 60], [52, 48, 50, 55, 51, 50, 50, 48, 47, 45, 48, 47, 45, 43, 34, 32, 32, 37, 24, 30], [41, 47, 31, 20, 37, 36, 34, 28, 19, 25, 30, 30, 30, 21, 29, 21, 15, 13, 17, 4], [40, 35, 33, 36, 39, 40, 39, 39, 32, 27, 24, 28, 28, 24, 18, 23, 16, 17, 16, 12], [41, 36, 35, 29, 28, 26, 22, 30, 29, 28, 28, 18, 23, 19, 23, 18, 16, 18, 13, 14], [16, 27, 27, 22, 26, 25, 22, 24, 23, 24, 22, 24, 20, 9, 18, 18, 13, 15, 14, 12], [23, 27, 18, 26, 24, 24, 20, 7, 18, 23, 11, 20, 15, 16, 18, 16, 15, 10, 12, 18], [13, 13, 17, 21, 12, 18, 12, 0, 16, 18, 20, 17, 18, 10, 11, 8, 12, 12, 16, 19], [20, 12, 18, 12, 9, 14, 10, 15, 14, 16, 9, 1, 0, 10, 13, 8, 16, 12, 15, 19], [8, 13, 15, 13, 18, 21, 12, 16, 14, 23, 17, 16, 23, 15, 11, 10, 6, 11, 20, 8], [14, 13, 14, 15, 11, 11, 17, 21, 12, 12, 13, 8, 17, 13, 6, 14, 8, 21, 16, 7], [16, 12, 21, 23, 11, 22, 15, 22, 13, 4, 18, 20, 16, 15, 9, 20, 14, 12, 6, 8], [15, 13, 1, 2, 20, 21, 17, 6, 16, 8, 12, 17, 13, 20, 5, 18, 6, 16, 8, 16], [21, 23, 12, 18, 11, 15, 6, 20, 11, 12, 9, 12, 11, 15, 16, 17, 18, 8, 1, 15], [19, 18, 14, 18, 16, 13, 21, 12, 14, 7, 9, 16, 14, 15, 17, 15, 11, 12, 20, 16], [18, 16, 21, 17, 16, 15, 18, 7, 11, 19, 14, 16, 17, 14, 18, 0, 13, 20, 21, 20], [13, 15, 14, 17, 10, 18, 12, 5, 17, 22, 14, 11, 18, 4, 15, 10, 23, 15, 16, 12], [20, 15, 19, 7, 12, 11, 1, 20, 12, 18, 12, 15, 10, 22, 12, 18, 17, 8, 18, 16], [10, 12, 7, 8, 15, 7, 10, 6, 17, 0, 19, 8, 5, 12, 15, 7, 11, 18, 16, 13], [3, 11, 17, 19, 13, 11, 8, 11, 9, 19, 17, 8, 15, 18, 15, 18, 15, 5, 17, 16], [99, 102, 105, 107, 107, 106, 106, 105, 104, 102, 96, 90, 90, 89, 80, 74, 70, 82, 68, 70], [77, 80, 81, 83, 82, 83, 84, 82, 81, 80, 72, 73, 75, 63, 67, 64, 63, 64, 42, 41], [75, 66, 63, 63, 72, 72, 64, 67, 64, 58, 61, 60, 56, 49, 58, 52, 41, 34, 22, 18], [67, 57, 58, 61, 63, 63, 63, 62, 57, 48, 53, 48, 47, 46, 41, 41, 17, 23, 22, 13], [65, 63, 59, 55, 57, 57, 55, 54, 54, 47, 50, 49, 31, 46, 41, 22, 17, 21, 8, 21], [55, 59, 61, 60, 59, 58, 58, 57, 47, 47, 48, 40, 42, 29, 32, 18, 21, 16, 8, 4], [55, 54, 55, 56, 53, 53, 49, 46, 42, 36, 38, 38, 26, 30, 24, 18, 13, 14, 10, 1], [34, 44, 41, 40, 38, 42, 28, 30, 32, 27, 26, 30, 18, 24, 20, 15, 14, 6, 14, 14], [38, 18, 30, 21, 28, 23, 26, 23, 19, 24, 14, 18, 23, 12, 15, 18, 21, 17, 12, 9], [23, 27, 16, 24, 19, 17, 18, 22, 16, 16, 12, 18, 16, 18, 9, 17, 16, 19, 19, 15], [20, 22, 15, 19, 11, 18, 20, 14, 14, 19, 17, 9, 19, 8, 10, 13, 16, 19, 12, 15], [21, 26, 10, 17, 17, 2, 8, 21, 21, 21, 6, 16, 14, 13, 19, 15, 14, 18, 8, 0], [22, 26, 27, 25, 16, 17, 20, 14, 19, 19, 5, 23, 14, 11, 19, 18, 15, 17, 9, 15], [19, 15, 21, 20, 20, 12, 14, 12, 16, 16, 13, 12, 20, 21, 14, 18, 18, 7, 16, 12], [19, 19, 22, 17, 25, 18, 10, 19, 20, 11, 22, 8, 15, 21, 14, 15, 19, 18, 17, 14], [14, 20, 17, 14, 9, 21, 10, 16, 19, 16, 19, 16, 19, 6, 15, 16, 17, 18, 10, 16], [22, 19, 23, 17, 19, 17, 4, 17, 0, 8, 21, 3, 14, 18, 23, 1, 17, 0, 20, 9], [14, 14, 13, 8, 21, 10, 17, 16, 11, 15, 15, 12, 15, 17, 17, 14, 18, 21, 15, 20], [12, 13, 19, 17, 10, 16, 11, 18, 15, 4, 11, 8, 17, 14, 13, 17, 10, 21, 16, 18], [17, 17, 19, 18, 17, 15, 13, 14, 16, 20, 4, 16, 18, 14, 17, 10, 7, 11, 12, 18], [108, 111, 115, 116, 116, 116, 115, 113, 112, 110, 104, 99, 97, 97, 89, 87, 80, 88, 80, 75], [87, 92, 92, 94, 94, 95, 95, 93, 91, 89, 82, 84, 83, 77, 80, 76, 75, 71, 58, 50], [89, 81, 70, 72, 83, 84, 74, 77, 68, 73, 72, 70, 72, 67, 68, 62, 45, 46, 30, 24], [83, 78, 77, 80, 81, 80, 79, 78, 58, 70, 62, 64, 53, 63, 56, 55, 39, 37, 17, 22], [83, 82, 77, 72, 73, 70, 67, 59, 60, 69, 65, 60, 56, 62, 48, 49, 40, 28, 22, 18], [71, 76, 79, 79, 76, 76, 71, 70, 65, 69, 62, 56, 59, 48, 48, 36, 28, 24, 24, 18], [75, 75, 76, 77, 75, 75, 72, 68, 61, 64, 61, 53, 56, 51, 49, 32, 29, 23, 9, 12], [62, 63, 66, 67, 63, 62, 54, 61, 55, 51, 52, 50, 42, 26, 22, 19, 21, 6, 14, 14], [69, 66, 66, 64, 62, 62, 61, 63, 58, 55, 53, 47, 37, 36, 32, 25, 15, 17, 15, 18], [52, 51, 57, 48, 55, 51, 41, 43, 45, 37, 33, 23, 11, 18, 13, 14, 7, 18, 7, 16], [54, 46, 48, 50, 48, 44, 29, 43, 38, 21, 22, 18, 23, 23, 10, 11, 20, 22, 9, 18], [49, 49, 43, 50, 45, 42, 47, 46, 35, 39, 25, 28, 22, 19, 13, 14, 8, 15, 10, 6], [43, 46, 47, 51, 50, 50, 41, 27, 36, 29, 28, 20, 17, 23, 15, 18, 13, 19, 5, 6], [44, 46, 45, 46, 44, 41, 36, 34, 21, 16, 19, 15, 13, 21, 15, 20, 17, 15, 18, 12], [38, 31, 36, 34, 33, 23, 23, 13, 20, 11, 21, 18, 17, 19, 15, 18, 17, 4, 3, 7], [34, 26, 25, 16, 15, 16, 17, 12, 9, 17, 19, 14, 3, 16, 17, 0, 22, 9, 15, 19], [15, 29, 22, 25, 12, 20, 19, 13, 16, 20, 14, 15, 21, 0, 17, 16, 6, 10, 2, 10], [23, 27, 14, 21, 23, 13, 20, 24, 16, 12, 15, 13, 18, 18, 13, 12, 0, 19, 22, 11], [20, 19, 24, 17, 11, 16, 20, 21, 21, 10, 21, 21, 12, 13, 2, 19, 19, 19, 18, 10], [14, 28, 21, 21, 19, 18, 18, 9, 12, 3, 5, 14, 18, 18, 18, 6, 4, 18, 16, 11], [87, 88, 85, 85, 87, 86, 86, 85, 83, 78, 68, 71, 77, 76, 59, 68, 62, 58, 55, 40], [51, 48, 45, 51, 35, 46, 44, 45, 28, 40, 45, 41, 39, 39, 35, 24, 27, 16, 22, 21], [39, 35, 39, 38, 34, 32, 41, 38, 33, 36, 34, 30, 15, 28, 24, 16, 18, 22, 21, 7], [43, 43, 42, 40, 39, 38, 37, 33, 24, 15, 17, 26, 24, 22, 21, 23, 19, 23, 18, 13], [24, 25, 25, 12, 27, 20, 13, 22, 17, 23, 11, 15, 19, 11, 15, 19, 18, 13, 13, 9], [14, 23, 24, 16, 24, 21, 23, 12, 18, 21, 26, 17, 16, 3, 15, 11, 16, 13, 9, 20], [17, 29, 18, 22, 9, 11, 15, 17, 21, 20, 16, 16, 14, 16, 15, 8, 16, 12, 13, 15], [19, 17, 18, 26, 25, 8, 13, 9, 16, 12, 8, 11, 7, 16, 15, 9, 17, 18, 19, 16], [13, 13, 20, 11, 20, 19, 13, 19, 10, 13, 7, 19, 11, 17, 19, 16, 16, 21, 12, 20], [11, 14, 19, 15, 21, 15, 20, 10, 15, 18, 10, 16, 15, 13, 19, 9, 18, 13, 7, 18], [19, 12, 12, 17, 6, 18, 22, 20, 9, 22, 16, 16, 19, 7, 19, 9, 14, 18, 21, 19], [14, 16, 17, 17, 23, 17, 15, 18, 4, 15, 16, 6, 15, 18, 9, 13, 16, 15, 14, 3], [19, 18, 11, 12, 14, 22, 17, 9, 10, 10, 18, 23, 1, 18, 16, 8, 16, 7, 13, 21], [15, 12, 1, 22, 14, 16, 15, 22, 18, 19, 20, 19, 25, 14, 18, 13, 22, 20, 18, 18], [15, 13, 25, 13, 18, 18, 18, 13, 15, 17, 15, 9, 13, 14, 7, 13, 18, 12, 16, 10], [18, 17, 11, 15, 22, 18, 18, 11, 14, 16, 9, 22, 6, 14, 11, 11, 16, 24, 6, 13], [17, 16, 17, 16, 16, 20, 12, 13, 20, 21, 2, 20, 14, 18, 18, 16, 2, 14, 19, 19], [73, 98, 95, 94, 96, 95, 95, 95, 92, 88, 79, 81, 87, 85, 66, 76, 71, 67, 65, 53], [63, 60, 66, 68, 62, 64, 58, 63, 54, 39, 50, 49, 46, 44, 40, 36, 30, 22, 16, 24], [54, 42, 52, 39, 39, 42, 48, 42, 37, 42, 43, 23, 42, 38, 30, 24, 20, 18, 14, 15], [51, 60, 56, 55, 53, 49, 49, 45, 45, 44, 44, 41, 32, 26, 27, 26, 22, 22, 8, 14], [33, 29, 20, 31, 29, 13, 28, 36, 32, 27, 30, 11, 24, 18, 21, 12, 17, 19, 12, 16], [20, 24, 30, 22, 22, 21, 18, 23, 24, 12, 16, 15, 15, 15, 13, 17, 16, 10, 12, 21], [15, 25, 25, 21, 19, 16, 22, 24, 16, 15, 16, 17, 15, 16, 16, 18, 18, 19, 18, 12], [12, 22, 21, 11, 24, 15, 17, 18, 6, 14, 9, 17, 18, 16, 11, 15, 13, 10, 14, 10], [19, 18, 22, 7, 17, 18, 6, 21, 22, 10, 21, 14, 15, 10, 17, 14, 23, 17, 16, 16], [14, 16, 12, 22, 24, 21, 20, 13, 17, 19, 13, 14, 15, 8, 9, 18, 5, 6, 11, 21], [25, 21, 24, 12, 0, 20, 18, 13, 19, 22, 20, 22, 18, 19, 19, 16, 10, 15, 11, 16], [25, 17, 21, 20, 17, 19, 23, 10, 18, 23, 19, 16, 14, 7, 19, 11, 7, 19, 18, 5], [11, 12, 20, 11, 18, 13, 15, 15, 19, 10, 19, 20, 19, 15, 5, 18, 17, 19, 21, 15], [16, 13, 19, 12, 19, 20, 21, 12, 22, 12, 10, 18, 20, 18, 24, 13, 13, 16, 12, 13], [14, 16, 8, 17, 12, 20, 23, 19, 9, 9, 14, 16, 14, 16, 23, 21, 18, 13, 0, 20], [18, 12, 18, 11, 16, 15, 19, 19, 19, 15, 16, 8, 12, 16, 18, 10, 10, 18, 23, 18], [20, 4, 10, 21, 6, 14, 20, 17, 20, 20, 6, 21, 13, 16, 19, 23, 17, 14, 5, 6], [59, 105, 113, 108, 108, 109, 109, 108, 106, 101, 84, 96, 101, 97, 85, 88, 83, 80, 73, 64], [35, 87, 79, 83, 93, 87, 82, 85, 78, 81, 74, 84, 64, 69, 69, 60, 57, 52, 42, 35], [26, 79, 71, 81, 67, 75, 74, 65, 65, 72, 57, 68, 59, 44, 56, 47, 34, 29, 19, 16], [19, 84, 82, 78, 72, 72, 71, 69, 72, 72, 60, 53, 46, 39, 38, 35, 25, 22, 15, 18], [20, 65, 67, 67, 70, 66, 65, 64, 63, 60, 57, 49, 44, 41, 23, 14, 16, 22, 13, 11], [9, 59, 44, 58, 62, 60, 59, 57, 57, 53, 38, 38, 32, 19, 12, 22, 0, 5, 13, 19], [19, 66, 65, 63, 54, 51, 40, 58, 56, 50, 47, 47, 35, 14, 19, 10, 20, 18, 19, 20], [13, 60, 60, 50, 34, 38, 44, 36, 45, 42, 35, 28, 22, 17, 18, 2, 18, 12, 20, 13], [10, 55, 55, 56, 51, 49, 45, 42, 35, 38, 32, 35, 25, 20, 20, 16, 21, 16, 11, 18], [19, 44, 43, 48, 45, 40, 31, 16, 27, 19, 11, 10, 0, 19, 4, 10, 5, 11, 7, 4], [3, 33, 40, 38, 35, 34, 22, 31, 24, 22, 24, 13, 13, 12, 14, 23, 12, 19, 22, 18], [13, 35, 39, 41, 35, 31, 28, 28, 23, 22, 19, 14, 18, 18, 19, 21, 17, 20, 14, 22], [20, 32, 38, 34, 27, 21, 17, 9, 8, 15, 11, 18, 21, 13, 11, 25, 16, 12, 13, 15], [7, 32, 31, 28, 36, 33, 16, 25, 11, 17, 14, 10, 15, 19, 21, 18, 16, 12, 18, 17], [20, 21, 15, 19, 24, 21, 23, 22, 13, 20, 7, 10, 25, 17, 21, 21, 22, 19, 21, 9], [14, 25, 22, 20, 14, 12, 8, 13, 15, 23, 14, 23, 7, 10, 15, 19, 19, 14, 10, 7], [6, 27, 28, 24, 26, 11, 21, 16, 18, 13, 12, 15, 24, 11, 13, 18, 14, 12, 13, 13], [78, 77, 78, 78, 72, 63, 73, 72, 72, 72, 69, 67, 67, 68, 62, 61, 54, 35, 41, 38], [46, 47, 49, 53, 53, 52, 52, 51, 49, 45, 38, 42, 42, 36, 24, 29, 19, 19, 23, 12], [32, 37, 31, 26, 36, 27, 29, 28, 27, 19, 36, 34, 31, 21, 21, 26, 20, 17, 17, 14], [26, 28, 25, 23, 19, 20, 25, 24, 17, 21, 13, 23, 11, 21, 19, 16, 13, 13, 16, 20], [18, 22, 18, 21, 6, 16, 14, 11, 16, 11, 3, 18, 8, 20, 15, 19, 9, 26, 21, 15], [16, 16, 21, 15, 19, 13, 17, 7, 13, 20, 11, 11, 17, 11, 18, 14, 14, 20, 17, 10], [23, 23, 19, 18, 21, 13, 8, 13, 22, 6, 20, 20, 19, 14, 7, 10, 18, 8, 15, 19], [23, 20, 11, 14, 8, 16, 16, 13, 20, 9, 23, 18, 15, 17, 7, 13, 14, 11, 13, 14], [19, 15, 23, 19, 18, 23, 18, 26, 15, 16, 19, 17, 14, 6, 16, 19, 8, 23, 18, 18], [9, 14, 16, 11, 19, 7, 13, 16, 6, 21, 19, 18, 16, 19, 22, 19, 7, 6, 19, 22], [10, 7, 10, 20, 13, 12, 16, 13, 14, 23, 16, 15, 8, 21, 14, 16, 7, 19, 21, 7], [17, 4, 18, 12, 19, 15, 22, 23, 17, 7, 18, 7, 13, 23, 20, 17, 14, 18, 21, 21], [11, 10, 17, 9, 15, 8, 8, 20, 21, 16, 14, 22, 9, 18, 17, 11, 17, 15, 20, 11], [94, 92, 91, 93, 88, 80, 77, 75, 75, 72, 73, 72, 77, 76, 68, 70, 64, 47, 50, 43], [53, 59, 50, 59, 60, 55, 52, 50, 48, 54, 54, 41, 47, 49, 41, 35, 34, 26, 17, 24], [59, 51, 53, 55, 55, 52, 56, 55, 50, 51, 53, 45, 41, 41, 18, 22, 7, 0, 20, 20], [39, 41, 41, 37, 41, 41, 39, 39, 36, 33, 31, 9, 24, 6, 19, 9, 12, 20, 6, 19], [31, 33, 33, 25, 24, 30, 30, 23, 16, 13, 13, 19, 17, 16, 20, 12, 21, 17, 13, 9], [26, 20, 21, 20, 24, 18, 20, 16, 15, 17, 19, 20, 14, 8, 21, 15, 20, 14, 4, 11], [24, 22, 16, 20, 23, 17, 17, 22, 20, 16, 16, 20, 2, 15, 8, 19, 21, 21, 17, 14], [23, 26, 13, 12, 17, 19, 18, 21, 13, 20, 20, 13, 14, 8, 21, 9, 22, 14, 4, 14], [23, 14, 16, 18, 22, 16, 10, 13, 17, 22, 12, 19, 18, 22, 14, 16, 21, 19, 9, 15], [20, 22, 19, 22, 17, 13, 19, 17, 19, 22, 15, 19, 16, 20, 10, 18, 11, 21, 21, 12], [16, 16, 19, 16, 11, 13, 20, 9, 15, 18, 21, 17, 17, 19, 17, 21, 12, 10, 11, 24], [21, 14, 15, 15, 14, 14, 18, 14, 22, 21, 13, 18, 18, 19, 14, 16, 19, 21, 18, 9], [23, 21, 16, 23, 7, 19, 20, 19, 21, 18, 11, 18, 15, 10, 18, 20, 6, 17, 12, 23], [54, 103, 98, 103, 101, 100, 92, 89, 91, 89, 77, 86, 87, 85, 80, 78, 75, 66, 52, 51], [32, 88, 87, 86, 86, 86, 84, 86, 85, 80, 71, 68, 78, 70, 67, 63, 54, 41, 40, 30], [23, 80, 69, 69, 74, 70, 71, 67, 57, 63, 62, 58, 50, 51, 43, 44, 34, 27, 25, 24], [19, 65, 58, 65, 66, 66, 66, 59, 56, 45, 57, 51, 21, 42, 30, 29, 16, 16, 14, 20], [24, 58, 62, 61, 55, 46, 56, 51, 46, 49, 50, 47, 42, 29, 27, 23, 10, 22, 24, 18], [21, 51, 51, 32, 41, 36, 33, 31, 37, 36, 29, 25, 17, 20, 9, 20, 17, 12, 11, 18], [16, 55, 52, 50, 41, 42, 37, 42, 28, 29, 21, 21, 6, 10, 11, 18, 16, 17, 14, 16], [20, 38, 44, 43, 40, 42, 35, 36, 25, 32, 22, 23, 20, 8, 12, 16, 10, 17, 18, 20], [10, 48, 44, 39, 34, 21, 20, 26, 24, 27, 21, 21, 19, 13, 21, 17, 15, 19, 17, 16], [22, 34, 36, 30, 26, 27, 25, 13, 16, 22, 18, 17, 20, 18, 13, 21, 18, 9, 17, 18], [19, 18, 27, 21, 25, 20, 14, 13, 1, 10, 17, 20, 11, 21, 1, 15, 17, 19, 8, 26], [12, 28, 29, 23, 22, 16, 20, 24, 18, 10, 1, 21, 17, 17, 17, 8, 21, 12, 16, 18], [12, 27, 19, 19, 17, 16, 21, 15, 10, 20, 20, 17, 12, 20, 15, 20, 20, 24, 15, 19], [67, 70, 78, 81, 81, 78, 78, 78, 73, 71, 68, 63, 66, 67, 60, 56, 51, 50, 29, 37], [47, 52, 53, 56, 56, 55, 54, 53, 47, 40, 40, 41, 27, 30, 27, 25, 7, 16, 22, 18], [22, 33, 35, 36, 34, 37, 36, 35, 24, 17, 22, 18, 21, 23, 7, 16, 16, 19, 8, 15], [24, 26, 23, 20, 18, 18, 22, 24, 17, 17, 16, 19, 21, 13, 12, 16, 21, 24, 0, 12], [18, 20, 15, 26, 21, 22, 22, 16, 21, 11, 15, 17, 18, 17, 25, 24, 23, 18, 9, 12], [21, 7, 17, 16, 15, 16, 17, 20, 18, 13, 20, 16, 19, 20, 14, 8, 11, 18, 15, 18], [14, 13, 19, 18, 20, 19, 7, 15, 23, 21, 19, 18, 15, 16, 17, 18, 22, 15, 16, 13], [16, 26, 23, 21, 23, 9, 14, 22, 12, 16, 17, 23, 14, 16, 15, 13, 18, 21, 19, 15], [17, 6, 6, 15, 21, 25, 17, 23, 17, 20, 19, 16, 27, 18, 12, 14, 21, 10, 23, 11], [22, 11, 8, 20, 6, 21, 23, 17, 22, 20, 24, 22, 18, 24, 16, 11, 25, 17, 19, 20], [21, 14, 20, 22, 19, 26, 14, 18, 16, 12, 19, 24, 19, 24, 12, 20, 17, 23, 16, 21], [85, 90, 94, 96, 95, 95, 95, 95, 92, 89, 83, 77, 78, 79, 73, 72, 63, 63, 32, 46], [62, 61, 63, 63, 66, 65, 63, 63, 56, 46, 47, 52, 34, 38, 37, 34, 19, 18, 15, 21], [38, 48, 49, 49, 44, 43, 43, 41, 31, 31, 38, 35, 18, 30, 27, 22, 21, 17, 19, 23], [40, 40, 36, 30, 28, 24, 24, 30, 31, 27, 24, 21, 14, 17, 24, 10, 15, 13, 14, 22], [23, 34, 21, 26, 23, 28, 19, 20, 25, 20, 16, 15, 9, 12, 23, 3, 25, 7, 22, 7], [23, 19, 18, 20, 25, 16, 16, 19, 26, 20, 21, 18, 11, 19, 23, 21, 19, 17, 18, 22], [23, 26, 13, 20, 21, 18, 12, 9, 12, 12, 19, 19, 8, 19, 19, 16, 19, 18, 17, 19], [12, 20, 19, 18, 19, 14, 24, 15, 26, 16, 21, 8, 15, 16, 17, 20, 13, 15, 17, 20], [21, 17, 13, 18, 20, 17, 19, 23, 17, 22, 24, 1, 23, 14, 11, 12, 17, 16, 12, 12], [16, 5, 15, 20, 15, 14, 11, 20, 18, 14, 14, 12, 13, 19, 16, 13, 21, 5, 13, 11], [14, 21, 15, 20, 19, 17, 15, 19, 21, 18, 23, 7, 21, 8, 15, 17, 22, 14, 21, 22], [102, 107, 110, 112, 111, 111, 111, 111, 108, 105, 98, 91, 94, 93, 89, 84, 77, 76, 57, 57], [86, 86, 88, 89, 92, 91, 86, 77, 79, 68, 69, 74, 64, 67, 62, 56, 31, 37, 21, 16], [66, 72, 65, 53, 67, 64, 65, 60, 57, 47, 44, 49, 47, 42, 37, 29, 15, 20, 17, 18], [63, 64, 60, 37, 47, 52, 57, 55, 52, 49, 47, 47, 42, 24, 25, 18, 22, 13, 20, 16], [53, 52, 48, 45, 51, 52, 50, 49, 27, 42, 40, 29, 23, 12, 21, 8, 12, 22, 23, 10], [41, 44, 43, 38, 38, 28, 34, 30, 22, 21, 24, 18, 16, 10, 17, 17, 15, 20, 20, 12], [46, 43, 40, 29, 21, 30, 24, 28, 25, 23, 22, 11, 15, 16, 15, 18, 14, 16, 13, 18], [31, 37, 36, 35, 24, 29, 21, 20, 9, 20, 21, 16, 20, 16, 13, 20, 18, 20, 24, 22], [29, 25, 30, 18, 24, 12, 20, 24, 20, 18, 15, 19, 17, 13, 19, 10, 22, 8, 14, 20], [24, 28, 20, 18, 21, 16, 19, 2, 19, 13, 11, 21, 19, 20, 17, 25, 15, 20, 12, 14], [26, 28, 23, 23, 14, 18, 21, 23, 16, 13, 18, 23, 20, 14, 15, 19, 23, 19, 18, 19], [65, 73, 67, 72, 69, 67, 65, 65, 58, 54, 57, 48, 56, 37, 40, 42, 36, 31, 24, 19], [45, 45, 43, 42, 43, 40, 42, 41, 43, 42, 30, 36, 23, 15, 23, 8, 23, 21, 19, 22], [26, 21, 28, 26, 24, 20, 22, 20, 22, 14, 21, 20, 15, 20, 22, 11, 16, 21, 13, 18], [30, 32, 34, 35, 31, 32, 19, 18, 27, 15, 15, 11, 21, 18, 13, 12, 16, 18, 15, 11], [21, 25, 23, 22, 6, 12, 19, 12, 21, 21, 17, 20, 7, 19, 10, 23, 18, 17, 16, 10], [24, 25, 25, 26, 22, 18, 25, 23, 14, 21, 15, 21, 10, 15, 12, 12, 13, 17, 15, 19], [22, 13, 10, 21, 19, 22, 22, 21, 24, 8, 18, 19, 20, 14, 12, 19, 8, 19, 13, 16], [21, 25, 17, 13, 20, 18, 17, 23, 23, 23, 21, 14, 15, 20, 23, 16, 21, 18, 21, 21], [17, 14, 14, 12, 23, 15, 16, 15, 22, 13, 26, 23, 18, 23, 14, 12, 16, 19, 13, 19], [89, 93, 90, 92, 90, 87, 88, 85, 85, 82, 62, 72, 77, 71, 64, 58, 51, 41, 25, 26], [43, 59, 52, 46, 52, 48, 46, 50, 48, 50, 20, 46, 34, 13, 22, 26, 20, 22, 16, 18], [27, 36, 33, 37, 28, 31, 33, 31, 32, 21, 19, 20, 16, 17, 15, 20, 13, 23, 10, 13], [32, 42, 28, 27, 29, 32, 35, 33, 28, 31, 23, 19, 16, 20, 23, 23, 21, 16, 22, 20], [29, 22, 26, 33, 27, 24, 22, 24, 10, 15, 14, 16, 18, 17, 14, 5, 19, 14, 16, 23], [10, 22, 20, 13, 19, 21, 25, 20, 21, 23, 13, 9, 17, 17, 15, 20, 20, 21, 19, 10], [23, 18, 18, 22, 24, 29, 18, 15, 23, 21, 20, 20, 10, 15, 22, 16, 23, 17, 21, 18], [24, 11, 7, 8, 18, 17, 21, 16, 19, 24, 21, 23, 13, 22, 18, 19, 21, 16, 21, 27], [105, 107, 106, 106, 105, 104, 103, 101, 101, 97, 77, 91, 91, 86, 77, 70, 64, 54, 46, 40], [83, 80, 79, 68, 63, 78, 75, 73, 68, 72, 63, 66, 56, 56, 46, 31, 15, 8, 15, 18], [55, 51, 52, 56, 48, 51, 53, 47, 41, 40, 20, 34, 36, 28, 19, 20, 20, 19, 21, 19], [56, 53, 50, 40, 47, 54, 54, 49, 28, 50, 39, 40, 35, 30, 19, 26, 25, 28, 16, 21], [38, 43, 37, 41, 39, 39, 41, 40, 29, 20, 19, 20, 21, 21, 15, 12, 14, 17, 18, 11], [46, 38, 38, 33, 30, 29, 28, 22, 17, 17, 14, 12, 12, 15, 24, 18, 16, 19, 17, 15], [31, 38, 25, 27, 13, 21, 20, 19, 12, 15, 19, 24, 17, 13, 17, 20, 17, 18, 21, 16], [16, 23, 23, 27, 18, 26, 16, 15, 12, 8, 13, 22, 15, 15, 16, 18, 14, 22, 23, 22], [18, 24, 19, 25, 25, 21, 13, 12, 15, 19, 18, 23, 22, 12, 22, 16, 16, 26, 17, 20], [61, 58, 51, 66, 50, 61, 47, 51, 45, 56, 52, 50, 39, 48, 35, 37, 27, 31, 28, 25], [42, 43, 39, 37, 37, 42, 40, 29, 33, 23, 35, 29, 23, 23, 14, 21, 17, 17, 23, 21], [32, 23, 15, 21, 28, 32, 23, 25, 14, 25, 21, 20, 18, 23, 21, 18, 16, 8, 19, 12], [16, 18, 26, 24, 20, 24, 23, 19, 22, 17, 18, 19, 3, 19, 23, 18, 9, 11, 19, 14], [21, 24, 24, 14, 22, 13, 21, 24, 16, 25, 9, 16, 16, 20, 22, 18, 8, 23, 18, 15], [14, 21, 17, 25, 21, 18, 20, 20, 20, 24, 19, 18, 23, 20, 22, 15, 25, 18, 21, 18], [18, 18, 19, 23, 18, 16, 19, 14, 20, 22, 13, 19, 24, 19, 20, 23, 27, 20, 20, 23], [83, 78, 76, 78, 69, 69, 74, 77, 67, 77, 70, 70, 66, 66, 53, 52, 42, 32, 26, 23], [52, 53, 49, 49, 43, 35, 47, 42, 42, 40, 36, 37, 29, 23, 22, 19, 24, 25, 18, 19], [37, 39, 33, 34, 28, 33, 28, 27, 27, 27, 12, 24, 26, 19, 23, 20, 17, 18, 20, 14], [28, 24, 23, 28, 24, 22, 26, 26, 23, 24, 26, 26, 20, 20, 19, 22, 24, 13, 17, 20], [28, 15, 22, 23, 28, 25, 15, 25, 22, 20, 21, 20, 23, 21, 20, 27, 16, 19, 16, 19], [8, 19, 22, 25, 21, 25, 16, 21, 20, 20, 22, 26, 26, 19, 21, 14, 23, 23, 13, 16], [19, 14, 23, 25, 24, 24, 15, 26, 22, 20, 22, 22, 19, 21, 23, 22, 14, 18, 19, 21], [108, 106, 101, 101, 89, 89, 96, 101, 94, 98, 88, 90, 87, 76, 72, 69, 51, 51, 25, 21], [81, 73, 80, 81, 70, 77, 73, 64, 58, 60, 61, 52, 42, 46, 35, 28, 21, 20, 19, 15], [64, 60, 58, 61, 63, 56, 61, 52, 46, 43, 43, 23, 27, 21, 16, 23, 21, 21, 21, 11], [49, 54, 48, 58, 55, 33, 46, 48, 46, 25, 32, 27, 23, 20, 22, 18, 21, 12, 20, 13], [39, 43, 47, 37, 38, 29, 35, 32, 28, 20, 10, 16, 17, 12, 23, 13, 20, 17, 22, 22], [33, 32, 23, 34, 27, 29, 21, 16, 21, 18, 20, 14, 9, 19, 18, 22, 11, 21, 15, 20], [18, 27, 17, 24, 27, 18, 25, 24, 23, 20, 22, 16, 19, 24, 18, 21, 20, 21, 25, 16], [61, 71, 70, 72, 63, 58, 56, 54, 58, 50, 46, 50, 46, 34, 37, 28, 25, 26, 26, 25], [30, 40, 37, 38, 33, 31, 34, 31, 27, 30, 22, 22, 19, 25, 21, 21, 14, 17, 20, 25], [25, 30, 22, 26, 28, 24, 28, 24, 14, 20, 19, 19, 15, 23, 14, 18, 16, 16, 20, 18], [26, 19, 25, 22, 21, 20, 27, 16, 22, 15, 19, 18, 14, 22, 22, 22, 22, 18, 18, 22], [17, 23, 20, 20, 26, 21, 14, 23, 17, 8, 24, 21, 20, 8, 17, 20, 20, 20, 19, 24], [22, 23, 24, 23, 21, 20, 16, 27, 27, 18, 20, 18, 17, 19, 18, 14, 15, 19, 16, 19], [72, 82, 85, 83, 81, 79, 73, 68, 75, 69, 67, 69, 58, 51, 53, 46, 40, 35, 29, 25], [49, 49, 54, 52, 39, 45, 46, 37, 29, 40, 35, 28, 29, 26, 17, 23, 20, 27, 17, 20], [33, 36, 31, 33, 32, 35, 32, 35, 28, 28, 24, 23, 18, 22, 13, 19, 19, 22, 17, 19], [28, 28, 29, 27, 27, 25, 28, 21, 17, 20, 20, 24, 20, 23, 22, 19, 21, 15, 19, 22], [25, 26, 26, 22, 9, 24, 19, 20, 22, 23, 18, 14, 16, 22, 19, 26, 22, 22, 23, 21], [82, 93, 96, 100, 99, 94, 90, 83, 91, 79, 81, 80, 69, 66, 62, 54, 43, 35, 17, 21], [68, 66, 71, 61, 53, 64, 63, 57, 45, 51, 44, 40, 33, 28, 17, 25, 20, 24, 14, 16], [41, 51, 49, 50, 47, 48, 42, 39, 32, 29, 20, 23, 23, 22, 19, 20, 17, 27, 14, 12], [39, 43, 43, 37, 34, 36, 26, 26, 20, 17, 24, 21, 18, 21, 14, 11, 23, 16, 15, 23], [32, 30, 31, 26, 25, 21, 24, 23, 18, 16, 25, 25, 20, 17, 24, 24, 13, 19, 17, 23], [63, 69, 56, 66, 51, 62, 55, 47, 48, 45, 37, 37, 30, 28, 28, 23, 28, 23, 17, 25], [29, 28, 28, 34, 25, 32, 29, 28, 27, 21, 17, 20, 19, 22, 23, 19, 25, 16, 23, 21], [22, 23, 28, 28, 22, 27, 28, 20, 24, 22, 21, 23, 24, 24, 24, 25, 26, 15, 19, 27], [70, 84, 83, 83, 78, 70, 67, 64, 77, 66, 70, 66, 55, 52, 47, 35, 30, 26, 26, 25], [45, 55, 40, 47, 42, 46, 42, 36, 37, 37, 32, 22, 17, 24, 19, 14, 21, 27, 22, 18], [31, 32, 36, 34, 24, 23, 22, 19, 21, 24, 24, 20, 22, 23, 19, 15, 15, 20, 21, 21], [23, 24, 25, 29, 28, 22, 26, 22, 19, 25, 23, 22, 24, 24, 22, 23, 19, 18, 25, 23], [83, 91, 97, 98, 91, 90, 93, 89, 89, 78, 80, 76, 65, 65, 55, 41, 36, 27, 18, 22], [70, 68, 58, 58, 66, 61, 62, 53, 48, 47, 46, 33, 18, 24, 26, 20, 17, 16, 19, 16], [46, 52, 51, 47, 39, 41, 41, 27, 32, 29, 26, 22, 25, 17, 18, 19, 21, 16, 26, 24], [34, 36, 36, 36, 32, 27, 29, 23, 21, 21, 27, 17, 13, 26, 23, 19, 20, 25, 24, 18]]} ================================================ FILE: experiments/track02-C4-bps.json ================================================ {"1": [[0, 0.03646117968209008], [17, 1.4790503289019412], [116, 1.7464818747653081], [1364, 0.32805053827525693], [511, 0.1609264966801982], [2207, 0.0009999999999999998]], "2": [[0, 0.0012634508047348386], [9, 0.21596971199840045], [32, 2.404807458377003], [729, 0.5502459191358052], [1239, 0.03756845077976835], [1575, 0.0009999999999999998]], "3": [[0, 0.01254349241718219], [15, 0.15099185596710532], [26, 0.3421051478156847], [804, 0.051061292632147516], [1164, 0.0047740936634367475], [679, 0.0009999999999999998]], "4": [[0, 0.004250878808238577], [9, 0.057457146712061244], [32, 0.5554119700653773], [1434, 0.018122634597003563], [534, 0.025025024003812353], [1398, 0.0009999999999999998]], "5": [[0, 0.0009999999999999998], [6, 0.01816626570185348], [20, 0.08438815335232426], [624, 0.006071196966144399], [1358, 0.002903916392093575], [463, 0.0009999999999999998]], "6": [[0, 0.002161710338513421], [12, 0.15650724904503518], [20, 0.5925248800917347], [1245, 0.011559939842952675], [731, 0.015835095979827792], [1200, 0.0009999999999999998]], "7": [[0, 0.0023404483051654946], [15, 0.08542249910042937], [17, 0.1666895668496017], [853, 0.0021358280107708454], [1123, 0.0033970486787507984], [531, 0.0009999999999999998]], "8": [[0, 0.0020843732849860934], [17, 0.12346736808924237], [29, 0.18170621956830013], [1016, 0.010201883691495973], [946, 0.005236696363962163], [719, 0.0009999999999999998]], "9": [[0, 0.0030655166217990527], [17, 0.13600540298075547], [64, 0.1831798098530581], [641, 0.014173570743211048], [1286, 0.0019437161448920615], [289, 0.0009999999999999998]], "10": [[0, 0.00479559610080011], [29, 0.06072650347041644], [61, 0.0798317372027684], [816, 0.0046354272307415414], [1103, 0.003714921017812922], [570, 0.0009999999999999998]], "11": [[0, 0.002712805431040445], [20, 0.058009604750650895], [17, 0.07063250568468678], [746, 0.008931881841216528], [1225, 0.001201477179802048], [80, 0.0009999999999999998]], "12": [[0, 0.0011411701775337058], [9, 0.01821003171882191], [20, 0.07124145242041195], [795, 0.006330355307626967], [1184, 0.002254072162494906], [353, 0.0009999999999999998]], "13": [[0, 0.0012512680959778542], [9, 0.012546514343345075], [9, 0.01494232149421479], [746, 0.0020352720499251602], [1245, 0.0021786470499486742], [338, 0.0009999999999999998]], "14": [[0, 0.0009952115977475834], [12, 0.022746594188342958], [110, 0.03291419108007345], [139, 0.006637951769233443], [1747, 0.0007961189128058337]], "15": [[0, 0.0008774321388499404], [12, 0.010222851979210086], [20, 0.013301383595068267], [572, 0.0028869457800665983], [1405, 0.0008797187781985485]], "16": [[0, 0.0009241395135334805], [12, 0.017513958907860068], [9, 0.006637052937096589], [853, 0.00367677018607421], [1135, 0.0010606068054344045], [26, 0.0009999999999999998]], "17": [[0, 0.0009050618790137055], [15, 0.029306767939208236], [23, 0.01078682206955967], [827, 0.003994973109065478], [1144, 0.0009003742241215998]], "18": [[0, 0.0012493200902472551], [26, 0.01674550900239793], [29, 0.01147113903438373], [232, 0.0032622576962070475], [1721, 0.00103090043200766], [13, 0.0009999999999999998]], "19": [[0, 0.001157202173287927], [17, 0.024463638969512314], [17, 0.027302180375823496], [906, 0.0012095650014134092], [1068, 0.0008644430911523587]], "20": [[0, 0.0029782923681902418], [223, 0.0026139493226257425], [168, 0.0015766931903501277], [842, 0.0011388221206957768], [775, 0.0009999999999999998]]} ================================================ FILE: experiments/tulip_piano.py ================================================ """Piano notes generated on amy/tulip.""" # Uses the partials amplitude breakpoints and residual written by piano-partials.ipynb. import json import time import amy try: import midi have_midi = True except: print("midi not found") have_midi = False try: from ulab import numpy as np except: import numpy as np # Read in the params file written by piano_heterodyne.ipynb # Contents: # sample_times_ms - single vector of fixed log-spaced envelope sample times (in int16 integer ms). # notes - the MIDI numbers corresponding to each note described. # velocities - The (MIDI) strike velocities available for each note, the same for all notes. # num_harmonics - Array of (num_notes * num_velocities) counts of how many harmonics are defined for each note+vel combination. # harmonics_freq - Vector of (total_num_harmonics) int16s giving freq for each harmonic in "MIDI cents" i.e. 6900 = 440 Hz. # harmonics_mags - Array of (total_num_harmonics, num_sample_times) uint8s giving envelope samples for each harmonic. In dB, between 0 and 100. # We load this in as a python file, it's easier for porting to systems without filesystems from piano_params import notes_params NOTES = np.array(notes_params['notes'], dtype=np.int8) VELOCITIES = np.array(notes_params['velocities'], dtype=np.int8) NUM_HARMONICS = np.array(notes_params['num_harmonics'], dtype=np.int16) assert len(NUM_HARMONICS) == len(NOTES) * len(VELOCITIES) NUM_MAGS = len(notes_params['harmonics_mags'][0]) # Add in a derived diff-times and start-harmonic fields # Reintroduce the initial zero-time... SAMPLE_TIMES = np.array([0] + notes_params['sample_times_ms']) #.. so we can neatly calculate the time-deltas needed for BP strings. DIFF_TIMES = SAMPLE_TIMES[1:] - SAMPLE_TIMES[:-1] # Lookup to find first harmonic for nth note. START_HARMONIC = np.zeros(len(NUM_HARMONICS), dtype=np.int16) for i in range(len(NUM_HARMONICS)): # (No cumsum in ulab.numpy) START_HARMONIC[i] = np.sum(NUM_HARMONICS[:i]) # We build a single array for all the harmonics with the frequency as the # first column, followed by the envelope magnitudes. Then, we can pull # out the entire description for a given note/velocity pair simply by # pulling out NUM_HARMONICS[harmonic_index] rows starting at # START_HARMONIC[harmonic_index] FREQ_MAGS = np.zeros((np.sum(NUM_HARMONICS), 1 + NUM_MAGS), dtype=np.int16) FREQ_MAGS[:, 0] = np.array(notes_params['harmonics_freq'], dtype=np.int16) FREQ_MAGS[:, 1:] = np.array(notes_params['harmonics_mags'], dtype=np.int16) def harms_params_from_note_index_vel_index(note_index, vel_index): """Retrieve a (log-domain) harms_params list for a given note/vel index pair.""" # A harmonic is represented as a [freq_cents, mag1_db, mag2_db, .. mag20_db] row. # A note is represented as NUM_HARMONICS (usually 20) rows. note_vel_index = note_index * len(VELOCITIES) + vel_index num_harmonics = NUM_HARMONICS[note_vel_index] start_harmonic = START_HARMONIC[note_vel_index] harms_params = FREQ_MAGS[start_harmonic : start_harmonic + num_harmonics, :] return harms_params def interp_harms_params(hp0, hp1, alpha): """Return harm_param list that is alpha of the way to hp1 from hp0.""" # hp_ is [[freq_h1, mag1, mag2, ...], [freq_h2, mag1, mag2, ..], ...] num_harmonics = min(hp0.shape[0], hp1.shape[0]) # Assume the units are log-scale, so linear interpolation is good. return hp0[:num_harmonics] + alpha * (hp1[:num_harmonics] - hp0[:num_harmonics]) def cents_to_hz(cents): """Convert 'Midi cents' frequency to Hz. 6900 cents -> 440 Hz""" return 440 * (2 ** ((cents - 6900) / 1200.0)) def db_to_lin(d): """Convert the db-scale magnitudes to linear. 0 dB -> 0.00001, so 100 dB -> 1.0.""" # Clip anything below 0.001 to zero. return np.maximum(0, 10.0 ** ((d - 100) / 20.0) - 0.001) def harms_params_for_note_vel(note, vel): """Convert midi note and velocity into an interpolated harms_params list of harmonic specifications.""" note = np.clip(note, NOTES[0], NOTES[-1]) vel = np.clip(vel, VELOCITIES[0], VELOCITIES[-1]) note_index = -1 + np.sum(NOTES[:-1] <= note) # at most the last-but-one value. strike_index = -1 + np.sum(VELOCITIES[:-1] <= vel) lower_note = NOTES[note_index] upper_note = NOTES[note_index + 1] note_alpha = (note - lower_note) / (upper_note - lower_note) lower_strike = VELOCITIES[strike_index] upper_strike = VELOCITIES[strike_index + 1] strike_alpha = (vel - lower_strike) / (upper_strike - lower_strike) # We interpolate to describe a note at both strike indices, # then interpolate those to get the strike. harms_params = interp_harms_params( interp_harms_params( harms_params_from_note_index_vel_index(note_index, strike_index), harms_params_from_note_index_vel_index(note_index + 1, strike_index), note_alpha, ), interp_harms_params( harms_params_from_note_index_vel_index(note_index, strike_index + 1), harms_params_from_note_index_vel_index(note_index + 1, strike_index + 1), note_alpha, ), strike_alpha, ) return harms_params def init_piano_voice(num_partials, base_osc=0, **kwargs): """One-time initialization of the unchanging parts of the partials voices.""" amy_send(osc=base_osc, wave=amy.BYO_PARTIALS, num_partials=num_partials, amp={'eg0': 0}, **kwargs) for partial in range(1, num_partials + 1): bp_string = '0,0,' + ','.join("%d,0" % t for t in DIFF_TIMES) # We append a release segment to die away to silence over 200ms on note-off. bp_string += ',200,0' amy_send(osc=base_osc + partial, wave=amy.PARTIAL, bp0=bp_string, eg0_type=amy.ENVELOPE_TRUE_EXPONENTIAL, **kwargs) def setup_piano_voice(harms_params, base_osc=0, voices=None, time=None, sequence=None): """Configure a set of PARTIALs oscs to play a particular note and velocity.""" num_partials = len(harms_params) amy_send(osc=base_osc, wave=amy.BYO_PARTIALS, num_partials=num_partials, voices=voices, time=time, sequence=sequence) if time is not None: base_cmd = 't' + str(time) else: base_cmd = '' if voices is not None: base_cmd += 'r' + str(voices) if sequence is not None: base_cmd += 'H' + str(sequence) for i in range(num_partials): # Omit the time-deltas from the list to save space. The osc will keep the ones we set up in init_piano_voice. #env_vals = db_to_lin(harms_params[i, 1:]) #bp_string = ',,' + ','.join(",%.3f" % val for val in env_vals) # bp_strings beginning with ".." are in special integer-dB format for fast transcoding. env_vals = harms_params[i, 1:] bp_string = '..,,' + ','.join(",%d" % val for val in env_vals) # Add final release. bp_string += ',200,0' f0_hz = cents_to_hz(harms_params[i, 0]) #amy_send(osc=base_osc + 1 + i, freq=f0_hz, bp0=bp_string, voices=voices, time=time) # Special-case construction of the Wire Protocol message to save time amy.send_raw( base_cmd + 'v' + str(base_osc + i + 1) + ('f%.1f' % f0_hz) + 'A' + bp_string + 'Z' ) def piano_note_on(note=60, vel=1, **kwargs): if vel == 0: # Note off. amy.send(vel=0, **kwargs) else: hps = harms_params_for_note_vel(note, round(vel * 127)) setup_piano_voice(hps, **kwargs) # We already configured the freuquencies and magnitudes in setup, so # the note on is completely neutral. amy_send(note=60, vel=1, **kwargs) def amy_send(**kwargs): amy.send(**kwargs) amy.reset() time.sleep(0.1) # to let reset happen. amy.send(store_patch='1024,v0w10Zv%dw%dZ') amy.send(voices='0,1,2,3', load_patch=1024) num_partials = NUM_HARMONICS[0] patch_string = 'v0w10Zv%dw%dZ' % (num_partials + 1, amy.PARTIAL) print("Loaded dpwe piano on patch #1024, AMY voices 0,1,2,3") if have_midi: synth_obj = midi.Synth(num_voices=4, patch_string=patch_string) #voices = '0,1,2,3' voices = ",".join([str(a) for a in synth_obj.amy_voice_nums]) #print("voices=", voices) # We have to intercept the note-on events of the Synth voice objects. class PianoVoiceObject: """Substitute for midi.VoiceObject for Piano voices.""" def __init__(self, amy_voice): self.amy_voice = amy_voice def note_on(self, note, vel, time=None, sequence=None): #amy.send(time=time, voices=self.amy_voice, note=note, vel=vel, sequence=sequence) piano_note_on(note, vel, voices=self.amy_voice, time=time, sequence=sequence) def note_off(self, time=None, sequence=None): amy.send(time=time, voices=self.amy_voice, vel=0, sequence=sequence) # Intercept the voice objects for our synth synth_obj.voice_objs = [PianoVoiceObject(obj.amy_voice) for obj in synth_obj.voice_objs] for voice_obj in synth_obj.voice_objs: init_piano_voice(num_partials, voices=voice_obj.amy_voice) time.sleep(0.05) # Let the amy queue catch up. midi.config.add_synth_object(channel=1, synth_object=synth_obj) print("Added Tulip synth object to respond to MIDI channel 1") ================================================ FILE: godot/SConstruct ================================================ #!/usr/bin/env python """ Build script for the AMY Synthesizer GDExtension. AMY C source lookup order: 1. AMY_SRC_PATH environment variable (if set) 2. ../src/ (AMY repo source, when building from the repo) 3. ./amy_src/ (vendored source, when installed via setup_godot.sh) """ import os import sys # Find godot-cpp godot_cpp_path = os.environ.get("GODOT_CPP_PATH", os.path.join(os.path.dirname(os.path.abspath(".")), "godot-cpp")) # Find AMY C source: env var > repo source > vendored copy amy_src_path = os.environ.get("AMY_SRC_PATH", None) if amy_src_path is None: # Try repo layout first (godot/ is sibling to src/) repo_src = os.path.join(os.path.dirname(os.path.abspath(".")), "src") if os.path.isdir(repo_src): amy_src_path = repo_src elif os.path.isdir("amy_src"): amy_src_path = "amy_src" else: print("ERROR: AMY source not found. Either:") print(" - Build from the AMY repo (godot/ directory)") print(" - Place AMY source in amy_src/") print(" - Or set AMY_SRC_PATH environment variable") Exit(1) env = SConscript(os.path.join(godot_cpp_path, "SConstruct")) # AMY C source files (core synthesis - no platform-specific I2S, no example mains) amy_sources = [ "algorithms.c", "amy.c", "api.c", "custom.c", "delay.c", "envelope.c", "examples.c", "filters.c", "instrument.c", "interp_partials.c", "log2_exp2.c", "midi_mappings.c", "oscillators.c", "parse.c", "patches.c", "pcm.c", "sequencer.c", "transfer.c", ] # Add AMY include path env.Append(CPPPATH=[amy_src_path]) # AMY compile flags env.Append(CCFLAGS=["-DAMY_WAVETABLE", "-DAMY_NO_MINIAUDIO"]) # Suppress warnings from AMY's C code (GCC/Clang vs MSVC) is_msvc = env.get("is_msvc", False) or (env["platform"] == "windows" and not env.get("use_mingw", False)) if is_msvc: env.Append(CFLAGS=["/std:c11", "/wd4244", "/wd4267", "/wd4996", "/wd4100"]) else: env.Append(CFLAGS=["-Wno-unused-parameter", "-Wno-sign-compare", "-Wno-missing-field-initializers"]) # Platform-specific flags (use target platform, not build machine) target_platform = env["platform"] if target_platform == "macos": env.Append(CCFLAGS=["-DMACOS"]) env.Append(LINKFLAGS=["-framework", "CoreFoundation"]) elif target_platform == "linux": env.Append(LIBS=["pthread", "m"]) elif target_platform == "windows": if is_msvc: env.Append(CCFLAGS=["-DWINDOWS"]) else: env.Append(CCFLAGS=["-DWINDOWS"]) # Build all sources together - AMY C files + GDExtension C++ files all_sources = [] for src in amy_sources: src_path = os.path.join(amy_src_path, src) if os.path.exists(src_path): all_sources.append(src_path) # GDExtension C++ sources + platform stubs all_sources += [ "src/amy_platform_stubs.c", "src/amy_gdextension.cpp", "src/register_types.cpp", ] # Add our source include path env.Append(CPPPATH=["src"]) # Build shared library directly from all sources if target_platform == "macos": # Build as dylib for macOS (not framework - NSBundle crashes on macOS 26+) # godot-cpp strips SHLIBSUFFIX for macOS framework builds, so add .dylib explicitly library = env.SharedLibrary( target="bin/libamy{}.dylib".format(env["suffix"]), source=all_sources, ) else: library = env.SharedLibrary( target="bin/libamy{}{}".format(env["suffix"], env["SHLIBSUFFIX"]), source=all_sources, ) Default(library) ================================================ FILE: godot/amy.gd ================================================ class_name Amy extends Node ## AMY Synthesizer for Godot. ## ## High-level GDScript API that mirrors AMY's Python interface. ## Works on native (GDExtension) and web (WASM via JavaScriptBridge). ## ## Usage: ## var amy := Amy.new() ## add_child(amy) ## await get_tree().process_frame ## amy.send({"osc": 0, "wave": Amy.SINE, "freq": 440, "vel": 1.0}) ## ## Or use wire protocol directly: ## amy.send_raw("v0w0f440l1") # ============================================================ # Wave types # ============================================================ const SINE: int = 0 const PULSE: int = 1 const SAW_DOWN: int = 2 const SAW_UP: int = 3 const TRIANGLE: int = 4 const NOISE: int = 5 const KS: int = 6 const PCM: int = 7 const ALGO: int = 8 const PARTIAL: int = 9 const BYO_PARTIALS: int = 10 const INTERP_PARTIALS: int = 11 const AUDIO_IN0: int = 12 const AUDIO_IN1: int = 13 const WAVETABLE: int = 19 const CUSTOM: int = 20 const WAVE_OFF: int = 21 # ============================================================ # Filter types # ============================================================ const FILTER_NONE: int = 0 const FILTER_LPF: int = 1 const FILTER_BPF: int = 2 const FILTER_HPF: int = 3 const FILTER_LPF24: int = 4 # ============================================================ # Envelope types # ============================================================ const ENVELOPE_NORMAL: int = 0 const ENVELOPE_LINEAR: int = 1 const ENVELOPE_DX7: int = 2 const ENVELOPE_TRUE_EXPONENTIAL: int = 3 # ============================================================ # Config — set these before adding to the tree (before _ready) # ============================================================ ## Enable chorus effect. @export var chorus: bool = true ## Enable reverb effect. @export var reverb: bool = true ## Enable echo/delay effect. @export var echo: bool = true ## Load default GM synth patches on startup. @export var default_synths: bool = false ## Enable partial synthesis. @export var partials: bool = true ## Enable custom oscillator type. @export var custom: bool = true ## Play a short bleep on startup. @export var startup_bleep: bool = false ## Enable audio input. @export var audio_in: bool = false ## Maximum number of oscillators. @export var max_oscs: int = 180 ## Maximum number of voices. @export var max_voices: int = 64 ## Maximum number of synths. @export var max_synths: int = 64 # ============================================================ # Internals — audio bridge # ============================================================ var _synth: Node = null var _stream_player: AudioStreamPlayer = null var _playback: AudioStreamGeneratorPlayback = null var _started: bool = false var _is_web: bool = false func _ready() -> void: _is_web = OS.get_name() == "Web" if _is_web: _init_web() else: _init_native() func _init_native() -> void: if ClassDB.class_exists(&"AmySynth"): _synth = ClassDB.instantiate(&"AmySynth") add_child(_synth) else: push_warning("AmySynth GDExtension not loaded — audio disabled") return # Apply config before starting _synth.set("chorus", chorus) _synth.set("reverb", reverb) _synth.set("echo", echo) _synth.set("default_synths", default_synths) _synth.set("partials", partials) _synth.set("custom", custom) _synth.set("startup_bleep", startup_bleep) _synth.set("audio_in", audio_in) _synth.set("max_oscs", max_oscs) _synth.set("max_voices", max_voices) _synth.set("max_synths", max_synths) _stream_player = AudioStreamPlayer.new() var stream := AudioStreamGenerator.new() stream.mix_rate = 44100.0 stream.buffer_length = 0.1 _stream_player.stream = stream _stream_player.bus = "Master" add_child(_stream_player) _synth.call("start") _stream_player.play() _playback = _stream_player.get_stream_playback() as AudioStreamGeneratorPlayback _started = true func _init_web() -> void: # Pass config to JS bridge before AMY starts var ds := "true" if default_synths else "false" var sb := "true" if startup_bleep else "false" JavaScriptBridge.eval("godot_amy_configure(%s, %s)" % [ds, sb]) for i in range(100): var ready: Variant = JavaScriptBridge.eval("godot_amy_is_ready()", true) if ready: _started = true print("AMY web synth ready") return await get_tree().create_timer(0.1).timeout push_warning("AMY web module failed to load after 10 s") func _process(_delta: float) -> void: if _started and not _is_web: _fill_audio() func _fill_audio() -> void: if _playback == null or _synth == null: return var block_size: Variant = _synth.call("get_block_size") var bs: int = block_size as int while _playback.can_push_buffer(bs): var buffer: Variant = _synth.call("fill_buffer") _playback.push_buffer(buffer as PackedVector2Array) func _exit_tree() -> void: if not _is_web and _synth: _synth.call("stop") # ============================================================ # Public API # ============================================================ ## Send an AMY message using keyword-style parameters. ## Example: ## amy.send({"osc": 0, "wave": Amy.SINE, "freq": 440, "vel": 1}) ## amy.send({"osc": 0, "vel": 0}) # note off func send(params: Dictionary = {}) -> void: send_raw(message(params)) ## Build an AMY wire message from a dictionary without sending it. ## Returns the wire string (e.g. "v0w0f440l1"). func message(params: Dictionary) -> String: var wire: String = "" for key: Variant in params: var key_str: String = str(key) if not _KW_MAP.has(key_str): push_warning("AMY: unknown parameter '%s'" % key_str) continue var mapping: Variant = _KW_MAP[key_str] var m: Array = mapping as Array var code: String = str(m[0]) var type: String = str(m[1]) var val: Variant = params[key] wire += code + _format_value(val, type) return wire ## Send a raw AMY wire-protocol string. ## Example: amy.send_raw("v0w0f440l1") func send_raw(msg: String) -> void: if not _started or msg.is_empty(): return if _is_web: var safe: String = msg.replace("\\", "\\\\").replace("'", "\\'") JavaScriptBridge.eval("godot_amy_send('%s')" % safe) else: if _synth: _synth.call("send", msg) ## Stop all sound immediately. func panic() -> void: send_raw("S") # ============================================================ # Value formatting helpers # ============================================================ func _format_value(val: Variant, type: String) -> String: match type: "I": return str(int(val)) "F": return _trunc(float(val)) "S": return str(val) "L": return _format_list(val) "C": return _format_ctrl(val) return str(val) ## Truncate a float to 4 decimal places, strip trailing zeros. func _trunc(f: float) -> String: if f == int(f): return str(int(f)) var s: String = "%.4f" % f while s.ends_with("0"): s = s.substr(0, s.length() - 1) if s.ends_with("."): s = s.substr(0, s.length() - 1) return s ## Format a list/array as comma-separated values. func _format_list(val: Variant) -> String: if val is String: return str(val) if val is Array: var parts: PackedStringArray = PackedStringArray() for item: Variant in val: parts.append(_trunc(float(item))) return ",".join(parts) return str(val) ## Format a control coefficient value. ## Can be a number (treated as const), a string, or an array. func _format_ctrl(val: Variant) -> String: if val is float or val is int: return _trunc(float(val)) if val is String: return str(val) if val is Array: var parts: PackedStringArray = PackedStringArray() for item: Variant in val: parts.append(_trunc(float(item))) return ",".join(parts) return str(val) # ============================================================ # Parameter → wire-code mapping (matches AMY Python API) # ============================================================ var _KW_MAP: Dictionary = { "osc": ["v", "I"], "wave": ["w", "I"], "note": ["n", "F"], "vel": ["l", "F"], "amp": ["a", "C"], "freq": ["f", "C"], "duty": ["d", "C"], "feedback": ["b", "F"], "time": ["t", "I"], "reset": ["S", "I"], "phase": ["P", "F"], "pan": ["Q", "C"], "client": ["g", "I"], "volume": ["V", "F"], "pitch_bend": ["s", "F"], "filter_freq": ["F", "C"], "resonance": ["R", "F"], "bp0": ["A", "L"], "bp1": ["B", "L"], "eg0_type": ["T", "I"], "eg1_type": ["X", "I"], "debug": ["D", "I"], "chained_osc": ["c", "I"], "mod_source": ["L", "I"], "eq": ["x", "L"], "filter_type": ["G", "I"], "ratio": ["I", "F"], "latency_ms": ["N", "I"], "algo_source": ["O", "L"], "algorithm": ["o", "I"], "chorus": ["k", "L"], "reverb": ["h", "L"], "echo": ["M", "L"], "patch": ["K", "I"], "voices": ["r", "L"], "external_channel": ["W", "I"], "portamento": ["m", "I"], "sequence": ["H", "L"], "tempo": ["j", "F"], "synth": ["i", "I"], "num_voices": ["iv", "I"], "preset": ["p", "I"], "num_partials": ["p", "I"], } ================================================ FILE: godot/amy.gdextension ================================================ [configuration] entry_symbol = "amy_library_init" compatibility_minimum = "4.3" [libraries] macos.debug = "res://addons/amy/bin/libamy.macos.template_debug.universal.dylib" macos.release = "res://addons/amy/bin/libamy.macos.template_release.universal.dylib" linux.debug.x86_64 = "res://addons/amy/bin/libamy.linux.template_debug.x86_64.so" linux.release.x86_64 = "res://addons/amy/bin/libamy.linux.template_release.x86_64.so" windows.debug.x86_64 = "res://addons/amy/bin/libamy.windows.template_debug.x86_64.dll" windows.release.x86_64 = "res://addons/amy/bin/libamy.windows.template_release.x86_64.dll" ================================================ FILE: godot/install.gd ================================================ @tool extends EditorScript ## AMY Synthesizer Addon - Web Export Setup ## ## Run this script once (via File > Run) to copy web export files ## to the correct locations in your project. ## ## It copies: ## - enable-threads.js → project root (service worker needs root scope) ## - web_audio/ → project root (referenced by custom HTML shell) ## - Sets up export preset if one doesn't exist func _run() -> void: var addon_dir: String = "res://addons/amy/web/" var dst_web: String = "res://web_audio/" var dst_root: String = "res://" print("=== AMY Web Export Setup ===") # Copy enable-threads.js to project root _copy_file(addon_dir + "enable-threads-root.js", dst_root + "enable-threads.js") # Copy web audio files var web_files: Array[String] = [ "amy.js", "amy.wasm", "amy.aw.js", "amy.ww.js", "godot_amy_bridge.js", "enable-threads.js" ] # Create web_audio directory DirAccess.make_dir_absolute(ProjectSettings.globalize_path(dst_web)) # Create .gdignore in web_audio var gdignore: FileAccess = FileAccess.open(dst_web + ".gdignore", FileAccess.WRITE) if gdignore: gdignore.close() print(" Created web_audio/.gdignore") for fname in web_files: _copy_file(addon_dir + fname, dst_web + fname) # Copy custom HTML shell to export/ DirAccess.make_dir_absolute(ProjectSettings.globalize_path("res://export/")) _copy_file(addon_dir + "custom_shell.html", "res://export/custom_shell.html") print("") print("=== Setup Complete ===") print("") print("Next steps:") print(" 1. In Export dialog, set Custom HTML Shell to: res://export/custom_shell.html") print(" 2. Set Exclude Filter to: addons/amy/bin/*,addons/amy/src/*,addons/amy/amy_src/*,addons/amy/web/*,addons/amy/SConstruct,addons/amy/install.gd,addons/amy/amy.gdextension") print(" 3. Export for Web as usual!") print("") func _copy_file(src: String, dst: String) -> void: var src_path: String = ProjectSettings.globalize_path(src) var dst_path: String = ProjectSettings.globalize_path(dst) var file_in: FileAccess = FileAccess.open(src, FileAccess.READ) if file_in == null: push_warning("Could not read: " + src) return var content: PackedByteArray = file_in.get_buffer(file_in.get_length()) file_in.close() var file_out: FileAccess = FileAccess.open(dst, FileAccess.WRITE) if file_out == null: push_warning("Could not write: " + dst) return file_out.store_buffer(content) file_out.close() print(" Copied: " + src.get_file() + " -> " + dst) ================================================ FILE: godot/src/amy_gdextension.cpp ================================================ #include "amy_gdextension.h" #include #include // AMY is a C library extern "C" { #include "amy.h" } using namespace godot; AmySynth::AmySynth() {} AmySynth::~AmySynth() { if (initialized) { amy_stop(); initialized = false; } } void AmySynth::_bind_methods() { ClassDB::bind_method(D_METHOD("start"), &AmySynth::start); ClassDB::bind_method(D_METHOD("stop"), &AmySynth::stop); ClassDB::bind_method(D_METHOD("send", "message"), &AmySynth::send); ClassDB::bind_method(D_METHOD("send_note", "osc", "midi_note", "velocity", "duration_ms"), &AmySynth::send_note); ClassDB::bind_method(D_METHOD("fill_buffer"), &AmySynth::fill_buffer); ClassDB::bind_method(D_METHOD("get_sample_rate"), &AmySynth::get_sample_rate); ClassDB::bind_method(D_METHOD("get_block_size"), &AmySynth::get_block_size); ClassDB::bind_method(D_METHOD("get_sysclock"), &AmySynth::get_sysclock); ClassDB::bind_method(D_METHOD("is_running"), &AmySynth::is_running); // Config property bindings — set before calling start() ClassDB::bind_method(D_METHOD("set_chorus", "enabled"), &AmySynth::set_chorus); ClassDB::bind_method(D_METHOD("get_chorus"), &AmySynth::get_chorus); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "chorus"), "set_chorus", "get_chorus"); ClassDB::bind_method(D_METHOD("set_reverb", "enabled"), &AmySynth::set_reverb); ClassDB::bind_method(D_METHOD("get_reverb"), &AmySynth::get_reverb); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "reverb"), "set_reverb", "get_reverb"); ClassDB::bind_method(D_METHOD("set_echo", "enabled"), &AmySynth::set_echo); ClassDB::bind_method(D_METHOD("get_echo"), &AmySynth::get_echo); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "echo"), "set_echo", "get_echo"); ClassDB::bind_method(D_METHOD("set_default_synths", "enabled"), &AmySynth::set_default_synths); ClassDB::bind_method(D_METHOD("get_default_synths"), &AmySynth::get_default_synths); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "default_synths"), "set_default_synths", "get_default_synths"); ClassDB::bind_method(D_METHOD("set_partials", "enabled"), &AmySynth::set_partials); ClassDB::bind_method(D_METHOD("get_partials"), &AmySynth::get_partials); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "partials"), "set_partials", "get_partials"); ClassDB::bind_method(D_METHOD("set_custom", "enabled"), &AmySynth::set_custom); ClassDB::bind_method(D_METHOD("get_custom"), &AmySynth::get_custom); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "custom"), "set_custom", "get_custom"); ClassDB::bind_method(D_METHOD("set_startup_bleep", "enabled"), &AmySynth::set_startup_bleep); ClassDB::bind_method(D_METHOD("get_startup_bleep"), &AmySynth::get_startup_bleep); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "startup_bleep"), "set_startup_bleep", "get_startup_bleep"); ClassDB::bind_method(D_METHOD("set_audio_in", "enabled"), &AmySynth::set_audio_in); ClassDB::bind_method(D_METHOD("get_audio_in"), &AmySynth::get_audio_in); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "audio_in"), "set_audio_in", "get_audio_in"); ClassDB::bind_method(D_METHOD("set_max_oscs", "count"), &AmySynth::set_max_oscs); ClassDB::bind_method(D_METHOD("get_max_oscs"), &AmySynth::get_max_oscs); ADD_PROPERTY(PropertyInfo(Variant::INT, "max_oscs"), "set_max_oscs", "get_max_oscs"); ClassDB::bind_method(D_METHOD("set_max_voices", "count"), &AmySynth::set_max_voices); ClassDB::bind_method(D_METHOD("get_max_voices"), &AmySynth::get_max_voices); ADD_PROPERTY(PropertyInfo(Variant::INT, "max_voices"), "set_max_voices", "get_max_voices"); ClassDB::bind_method(D_METHOD("set_max_synths", "count"), &AmySynth::set_max_synths); ClassDB::bind_method(D_METHOD("get_max_synths"), &AmySynth::get_max_synths); ADD_PROPERTY(PropertyInfo(Variant::INT, "max_synths"), "set_max_synths", "get_max_synths"); } void AmySynth::start() { if (initialized) return; amy_config_t config = amy_default_config(); config.audio = AMY_AUDIO_IS_NONE; // We handle audio output ourselves via Godot config.features.chorus = chorus ? 1 : 0; config.features.reverb = reverb ? 1 : 0; config.features.echo = echo ? 1 : 0; config.features.default_synths = default_synths ? 1 : 0; config.features.partials = partials ? 1 : 0; config.features.custom = custom ? 1 : 0; config.features.startup_bleep = startup_bleep ? 1 : 0; config.features.audio_in = audio_in ? 1 : 0; config.max_oscs = max_oscs; config.max_voices = max_voices; config.max_synths = max_synths; amy_start(config); initialized = true; sample_rate = AMY_SAMPLE_RATE; block_size = AMY_BLOCK_SIZE; UtilityFunctions::print("AMY synth started (", sample_rate, " Hz, block size ", block_size, ")"); } void AmySynth::stop() { if (!initialized) return; amy_stop(); initialized = false; UtilityFunctions::print("AMY synth stopped"); } void AmySynth::send(const String &message) { if (!initialized) return; CharString cs = message.utf8(); amy_add_message(const_cast(cs.get_data())); } void AmySynth::send_note(int osc, int midi_note, float velocity, int duration_ms) { if (!initialized) return; char msg[128]; if (duration_ms > 0) { snprintf(msg, sizeof(msg), "v%dw0n%dl%fd%d", osc, midi_note, velocity, duration_ms); } else { snprintf(msg, sizeof(msg), "v%dw0n%dl%f", osc, midi_note, velocity); } amy_add_message(msg); } PackedVector2Array AmySynth::fill_buffer() { PackedVector2Array buffer; if (!initialized) { buffer.resize(block_size); buffer.fill(Vector2(0, 0)); return buffer; } int16_t *samples = amy_simple_fill_buffer(); buffer.resize(block_size); const float scale = 1.0f / 32768.0f; for (int i = 0; i < block_size; i++) { float left = static_cast(samples[i * 2]) * scale; float right = static_cast(samples[i * 2 + 1]) * scale; buffer.set(i, Vector2(left, right)); } return buffer; } int AmySynth::get_sample_rate() const { return sample_rate; } int AmySynth::get_block_size() const { return block_size; } uint64_t AmySynth::get_sysclock() const { if (!initialized) return 0; return amy_sysclock(); } bool AmySynth::is_running() const { return initialized; } // Config setters/getters void AmySynth::set_chorus(bool p_val) { chorus = p_val; } bool AmySynth::get_chorus() const { return chorus; } void AmySynth::set_reverb(bool p_val) { reverb = p_val; } bool AmySynth::get_reverb() const { return reverb; } void AmySynth::set_echo(bool p_val) { echo = p_val; } bool AmySynth::get_echo() const { return echo; } void AmySynth::set_default_synths(bool p_val) { default_synths = p_val; } bool AmySynth::get_default_synths() const { return default_synths; } void AmySynth::set_partials(bool p_val) { partials = p_val; } bool AmySynth::get_partials() const { return partials; } void AmySynth::set_custom(bool p_val) { custom = p_val; } bool AmySynth::get_custom() const { return custom; } void AmySynth::set_startup_bleep(bool p_val) { startup_bleep = p_val; } bool AmySynth::get_startup_bleep() const { return startup_bleep; } void AmySynth::set_audio_in(bool p_val) { audio_in = p_val; } bool AmySynth::get_audio_in() const { return audio_in; } void AmySynth::set_max_oscs(int p_val) { max_oscs = p_val; } int AmySynth::get_max_oscs() const { return max_oscs; } void AmySynth::set_max_voices(int p_val) { max_voices = p_val; } int AmySynth::get_max_voices() const { return max_voices; } void AmySynth::set_max_synths(int p_val) { max_synths = p_val; } int AmySynth::get_max_synths() const { return max_synths; } ================================================ FILE: godot/src/amy_gdextension.h ================================================ #ifndef AMY_GDEXTENSION_H #define AMY_GDEXTENSION_H #include #include #include #include namespace godot { class AmySynth : public Node { GDCLASS(AmySynth, Node) private: bool initialized = false; int sample_rate = 44100; int block_size = 256; // Config properties — set these before calling start() bool chorus = true; bool reverb = true; bool echo = true; bool default_synths = false; bool partials = true; bool custom = true; bool startup_bleep = false; bool audio_in = false; int max_oscs = 180; int max_voices = 64; int max_synths = 64; protected: static void _bind_methods(); public: AmySynth(); ~AmySynth(); void start(); void stop(); void send(const String &message); void send_note(int osc, int midi_note, float velocity, int duration_ms); PackedVector2Array fill_buffer(); int get_sample_rate() const; int get_block_size() const; uint64_t get_sysclock() const; bool is_running() const; // Config setters/getters void set_chorus(bool p_val); bool get_chorus() const; void set_reverb(bool p_val); bool get_reverb() const; void set_echo(bool p_val); bool get_echo() const; void set_default_synths(bool p_val); bool get_default_synths() const; void set_partials(bool p_val); bool get_partials() const; void set_custom(bool p_val); bool get_custom() const; void set_startup_bleep(bool p_val); bool get_startup_bleep() const; void set_audio_in(bool p_val); bool get_audio_in() const; void set_max_oscs(int p_val); int get_max_oscs() const; void set_max_voices(int p_val); int get_max_voices() const; void set_max_synths(int p_val); int get_max_synths() const; }; } // namespace godot #endif // AMY_GDEXTENSION_H ================================================ FILE: godot/src/amy_platform_stubs.c ================================================ // Stub implementations for AMY platform/hardware functions. // We don't need I2S or MIDI hardware - Godot handles all audio. // miniaudio stubs are no longer needed thanks to -DAMY_NO_MINIAUDIO. // amy_midi.c is excluded from the build to avoid conflicts, so we // stub the MIDI functions here. #include #include // --- i2s.c stubs --- void amy_platform_init(void) {} void amy_platform_deinit(void) {} void amy_update_tasks(void) {} int16_t *amy_render_audio(void) { return (int16_t *)0; } size_t amy_i2s_write(const uint8_t *buffer, size_t nbytes) { (void)buffer; (void)nbytes; return nbytes; } // --- amy_midi.c stubs --- void stop_midi(void) {} void run_midi(void) {} void amy_send_midi_note_on(uint8_t channel, uint8_t note, uint8_t velocity) { (void)channel; (void)note; (void)velocity; } void amy_send_midi_note_off(uint8_t channel, uint8_t note, uint8_t velocity) { (void)channel; (void)note; (void)velocity; } // Called from parse.c zD handler; no MIDI output on Godot so this is a no-op. void midi_out(uint8_t *bytes, uint16_t len) { (void)bytes; (void)len; } // --- examples.c stubs --- void delay_ms(uint32_t ms) { (void)ms; } ================================================ FILE: godot/src/register_types.cpp ================================================ #include "register_types.h" #include "amy_gdextension.h" #include #include #include #include using namespace godot; void initialize_amy_module(ModuleInitializationLevel p_level) { if (p_level != MODULE_INITIALIZATION_LEVEL_SCENE) { return; } GDREGISTER_CLASS(AmySynth); } void uninitialize_amy_module(ModuleInitializationLevel p_level) { if (p_level != MODULE_INITIALIZATION_LEVEL_SCENE) { return; } } extern "C" { GDExtensionBool GDE_EXPORT amy_library_init( GDExtensionInterfaceGetProcAddress p_get_proc_address, const GDExtensionClassLibraryPtr p_library, GDExtensionInitialization *r_initialization ) { godot::GDExtensionBinding::InitObject init_obj(p_get_proc_address, p_library, r_initialization); init_obj.register_initializer(initialize_amy_module); init_obj.register_terminator(uninitialize_amy_module); init_obj.set_minimum_library_initialization_level(MODULE_INITIALIZATION_LEVEL_SCENE); return init_obj.init(); } } // extern "C" ================================================ FILE: godot/src/register_types.h ================================================ #ifndef AMY_REGISTER_TYPES_H #define AMY_REGISTER_TYPES_H #include using namespace godot; void initialize_amy_module(ModuleInitializationLevel p_level); void uninitialize_amy_module(ModuleInitializationLevel p_level); #endif // AMY_REGISTER_TYPES_H ================================================ FILE: godot/web/custom_shell.html ================================================ $GODOT_PROJECT_NAME $GODOT_HEAD_INCLUDE Your browser does not support the canvas tag.
================================================ FILE: godot/web/godot_amy_bridge.js ================================================ // godot_amy_bridge.js // Thin bridge between Godot's JavaScriptBridge and AMY's WASM module. // AMY handles its own audio output via AudioWorklet on web — // this bridge just provides init/send functions for GDScript to call. (function() { var _audio_started = false; var _amy_configured = false; // Tell amy_connector.js we're in Godot mode — don't auto-start AMY. window._amy_godot_bridge = true; // Start AMY's AudioWorklet (must be called from user gesture context) async function _try_start_audio() { if (_audio_started) return; if (typeof amy_live_start_web !== 'function') return; try { await amy_live_start_web(); _audio_started = true; console.log("[AMY Bridge] Audio started via user gesture"); // Remove listeners once started document.removeEventListener('click', _try_start_audio); document.removeEventListener('keydown', _try_start_audio); document.removeEventListener('touchstart', _try_start_audio); } catch(e) { console.error("[AMY Bridge] Audio start failed:", e); } } // Register for user gesture events (Web Audio API requirement) document.addEventListener('click', _try_start_audio); document.addEventListener('keydown', _try_start_audio); document.addEventListener('touchstart', _try_start_audio); // -- Functions called from GDScript via JavaScriptBridge.eval() -- // Configure and start AMY with Godot config options. // Called from _init_web() before checking ready state. // default_synths: bool, startup_bleep: bool window.godot_amy_configure = function(default_synths, startup_bleep) { if (_amy_configured) return; _amy_configured = true; // Wait for WASM module to expose the start functions, then call function _try_configure() { if (window._amy_godot_start_web && window._amy_godot_start_web_no_synths) { if (default_synths) { if (!startup_bleep) { // Start with synths but no bleep: use amy_start_web then // immediately silence the bleep osc window._amy_godot_start_web(); if (typeof amy_add_message === 'function') { amy_add_message("v0l0"); } } else { window._amy_godot_start_web(); } } else { window._amy_godot_start_web_no_synths(); } console.log("[AMY Bridge] Configured: default_synths=" + default_synths + " startup_bleep=" + startup_bleep); } else { setTimeout(_try_configure, 50); } } _try_configure(); }; // Check if AMY WASM module is initialized and ready window.godot_amy_is_ready = function() { return _amy_configured && typeof amy_add_message === 'function'; }; // Check if AudioWorklet is running window.godot_amy_audio_started = function() { return _audio_started; }; // Send a wire message to AMY (e.g. "v0w0f440l1") window.godot_amy_send = function(msg) { if (typeof amy_add_message === 'function') { amy_add_message(msg); } }; })(); ================================================ FILE: library.properties ================================================ name=AMY Synthesizer version=1.2.4 author=Brian Whitman , DAn Ellis maintainer=Brian Whitman sentence=AMY, the Music Synthesizer Library paragraph=AMY supports many types of oscillators, filters, envelopes, analog, FM, PCM, Karplus-strong, reverb, chorus, echo category=Signal Input/Output url=http://github.com/shorepine/amy architectures=esp32,stm32,rp2040,mbed_rp2040,rp2350,mbed_rp2350,teensy,STM32F1,STM32F4,STM32H7,nrf52,samd,avr includes=AMY-Arduino.h depends= ================================================ FILE: pyproject.toml ================================================ [project] name = "amy" version = "0.1.0" description = "AMY synthesizer" readme = "README.md" dependencies = ['numpy', 'scipy'] ================================================ FILE: requirements.txt ================================================ numpy scipy ================================================ FILE: scripts/gen_amy_js_api.py ================================================ #!/usr/bin/env python3 """Generate amy_api.generated.js from amy/__init__.py and amy/constants.py. Reads the _KW_MAP_LIST and ctrl_coefs dict_fields from the Python AMY API, plus all constants from amy/constants.py, and generates a self-contained JS module with amy_message(), amy_send(), and an AMY constants object. """ import ast import re import textwrap from pathlib import Path ROOT = Path(__file__).resolve().parents[1] AMY_INIT = ROOT / "amy" / "__init__.py" AMY_CONSTANTS = ROOT / "amy" / "constants.py" OUTPUT = ROOT / "build" / "amy_api.generated.js" def extract_kw_map_list(source: str): """Parse _KW_MAP_LIST from the Python source.""" match = re.search( r"_KW_MAP_LIST\s*=\s*\[(.+?)\]\s*\n", source, re.DOTALL, ) if not match: raise RuntimeError("Could not find _KW_MAP_LIST in AMY __init__.py") raw = "[" + match.group(1) + "]" raw = re.sub(r"#[^\n]*", "", raw) entries = ast.literal_eval(raw) return entries def extract_coef_fields(source: str): """Parse the dict_fields list from parse_ctrl_coefs.""" match = re.search(r"dict_fields\s*=\s*(\[[^\]]+\])", source) if not match: raise RuntimeError("Could not find dict_fields in AMY __init__.py") return ast.literal_eval(match.group(1)) def extract_constants(source: str): """Parse all NAME=VALUE constants from constants.py. Keeps only simple integer/float assignments. When a name is assigned multiple times (e.g. AMY_BLOCK_SIZE), the last value wins (matching Python's runtime behaviour with conditional re-assignments). """ constants = {} for line in source.splitlines(): line = line.strip() if not line or line.startswith('#'): continue m = re.match(r'^([A-Z][A-Z0-9_]*)\s*=\s*(.+)$', line) if not m: continue name, val_str = m.group(1), m.group(2).strip() # Skip true/false pseudo-constants if name in ('true', 'false'): continue try: val = ast.literal_eval(val_str) except Exception: continue if isinstance(val, (int, float)): constants[name] = val return constants def generate_js(kw_map_list, coef_fields, constants=None): """Build the complete JS source.""" map_entries = [] priority_entries = [] for i, (name, code) in enumerate(kw_map_list): wire = code[:-1] type_code = code[-1] map_entries.append(f' {name}: {{wire: "{wire}", type: "{type_code}"}}') priority_entries.append(f" {name}: {i}") kw_map_js = "{\n" + ",\n".join(map_entries) + "\n}" kw_priority_js = "{\n" + ",\n".join(priority_entries) + "\n}" coef_fields_js = "[" + ", ".join(f'"{f}"' for f in coef_fields) + "]" js = textwrap.dedent("""\ // AUTO-GENERATED by scripts/gen_amy_js_api.py — do not edit by hand. // Source: amy/__init__.py (function() { "use strict"; var AMY_KW_MAP = %KW_MAP%; var AMY_KW_PRIORITY = %KW_PRIORITY%; var AMY_COEF_FIELDS = %COEF_FIELDS%; // --- type handlers (mirror Python's str_of_int, trunc, parse_list_or_comma_string, parse_ctrl_coefs) --- function _str_of_int(arg) { return String(Math.trunc(Number(arg))); } function _trunc(number) { if (typeof number === "string") { if (number.trim() === "") return ""; number = parseFloat(number); } if (typeof number === "number") { var s = number.toFixed(6); s = s.replace(/0+$/, ""); s = s.replace(/\\.$/, ""); return s; } return String(number); } function _parse_list(obj) { if (Array.isArray(obj)) { return obj.map(function(v) { return v == null ? "" : String(v); }).join(","); } return String(obj); } function _trim_trailing(arr) { var end = arr.length; while (end > 0 && arr[end - 1] == null) end--; return arr.slice(0, end); } function _parse_ctrl_coefs(coefs) { if (typeof coefs === "string") { return coefs.split(",").map(function(x) { return _trunc(x); }).join(","); } if (typeof coefs === "number") { return _trunc(coefs); } if (!Array.isArray(coefs) && typeof coefs === "object" && coefs !== null) { var list = new Array(AMY_COEF_FIELDS.length).fill(null); for (var key in coefs) { if (!coefs.hasOwnProperty(key)) continue; var idx = AMY_COEF_FIELDS.indexOf(key); if (idx < 0) throw new Error("Unknown ctrl_coef field: " + key + ". Valid: " + AMY_COEF_FIELDS.join(", ")); list[idx] = coefs[key]; } coefs = list; } if (!Array.isArray(coefs)) { return String(coefs); } coefs = _trim_trailing(coefs); return coefs.map(function(v) { return v == null ? "" : _trunc(v); }).join(","); } var _ARG_HANDLERS = { I: _str_of_int, F: _trunc, S: String, L: _parse_list, C: _parse_ctrl_coefs }; /** * Build an AMY wire code string from named parameters. * * amy_message({osc: 0, wave: 1, freq: 440}) => "v0w1f440Z" * amy_message({synth: 1, patch: 257, num_voices: 6}) => "K257i1iv6Z" * * Control coefficient params (amp, freq, duty, pan, filter_freq) accept: * - A number: freq: 440 * - An array: freq: [440, 1, null, null, null, null, 1] * - An object: freq: {const: 440, bend: 1} */ function amy_message(params) { if (!params || typeof params !== "object") { throw new Error("amy_message requires an object of parameters"); } var keys = []; for (var key in params) { if (!params.hasOwnProperty(key)) continue; if (!(key in AMY_KW_MAP)) { throw new Error("Unknown AMY parameter: " + key); } var arg = params[key]; if (arg == null) { if (key !== "time" && key !== "sequence") { throw new Error("Null value for AMY parameter: " + key); } continue; } keys.push(key); } keys.sort(function(a, b) { return (AMY_KW_PRIORITY[a] || 0) - (AMY_KW_PRIORITY[b] || 0); }); var m = ""; for (var i = 0; i < keys.length; i++) { var k = keys[i]; var mapping = AMY_KW_MAP[k]; var handler = _ARG_HANDLERS[mapping.type]; m += mapping.wire + handler(params[k]); } return m + "Z"; } /** * Build and send an AMY wire code message. * Equivalent to Python's amy.send(). */ function amy_send(params, log) { var msg = amy_message(params); if (log && typeof amy_add_log_message === "function") { amy_add_log_message(msg); } else if (typeof amy_add_message === "function") { amy_add_message(msg); } else { console.warn("amy_send: no AMY message handler found (is amy.js loaded?)"); } return msg; } // Constants from amy/constants.py (mirrors amy.SINE, amy.FILTER_LPF, etc.) var AMY = %CONSTANTS%; if (typeof globalThis !== "undefined") { globalThis.amy_message = amy_message; globalThis.amy_send = amy_send; globalThis.AMY = AMY; globalThis.AMY_KW_MAP = AMY_KW_MAP; globalThis.AMY_COEF_FIELDS = AMY_COEF_FIELDS; } })(); """) # Build constants object if constants: const_entries = [] for name, val in constants.items(): if isinstance(val, float): const_entries.append(f" {name}: {val}") else: const_entries.append(f" {name}: {val}") constants_js = "{\n" + ",\n".join(const_entries) + "\n}" else: constants_js = "{}" js = js.replace("%KW_MAP%", kw_map_js) js = js.replace("%KW_PRIORITY%", kw_priority_js) js = js.replace("%COEF_FIELDS%", coef_fields_js) js = js.replace("%CONSTANTS%", constants_js) return js def main(): source = AMY_INIT.read_text() kw_map_list = extract_kw_map_list(source) coef_fields = extract_coef_fields(source) constants = extract_constants(AMY_CONSTANTS.read_text()) js = generate_js(kw_map_list, coef_fields, constants) OUTPUT.write_text(js) print(f"Generated {OUTPUT.relative_to(ROOT)} ({len(kw_map_list)} parameters, {len(coef_fields)} coef fields, {len(constants)} constants)") if __name__ == "__main__": main() ================================================ FILE: scripts/gen_patches_js.py ================================================ #!/usr/bin/env python3 """Generate patches.generated.js from src/patches.h. Parses patch names and patch command strings from the C header and emits a self-contained JS module that exposes them to the AMYboard web editor. """ import re from pathlib import Path ROOT = Path(__file__).resolve().parents[1] PATCHES_H = ROOT / "src" / "patches.h" OUTPUT = ROOT / "build" / "patches.generated.js" # Regex to match each entry in patch_commands[]: # /* 0: Juno A11 Brass Set 1 */ "v1w4a1,...Z", ENTRY_RE = re.compile( r'/\*\s*\d+:\s*(.+?)\s*\*/\s*"((?:[^"\\]|\\.)*)"' ) def parse_patches(source: str): """Return list of (name, code) tuples from patches.h.""" patches = [] for m in ENTRY_RE.finditer(source): patches.append((m.group(1), m.group(2))) return patches def generate_js(patches): """Build the complete JS source.""" names_js = ",\n".join(f' "{name}"' for name, _ in patches) codes_js = ",\n".join(f' "{code}"' for _, code in patches) # The last patch is the amyboard default amyboard_default = patches[-1][1] if patches else "" return f"""\ // AUTO-GENERATED by scripts/gen_patches_js.py — do not edit by hand. // Source: src/patches.h (function() {{ const patches = [ {names_js}, ]; const patchCodes = [ {codes_js}, ]; window.amy_patches = patches; window.patch_code_for_patch_number = patchCodes; window.amyboard_patch_string = "{amyboard_default}"; if (typeof window.onPatchChange !== "function") {{ window.onPatchChange = function(_patchIndex) {{}}; }} window.init_patches_select = function(selectId) {{ const select = document.getElementById(selectId); if (!select) {{ return; }} select.innerHTML = ""; var groups = [ {{ label: "AMYboard", start: 0, end: Math.min(patches.length, 128) }}, {{ label: "DX7", start: 128, end: patches.length }}, ]; for (var g = 0; g < groups.length; g++) {{ var grp = groups[g]; if (grp.start >= patches.length) continue; var optgroup = document.createElement("optgroup"); optgroup.label = grp.label; for (var index = grp.start; index < grp.end; index++) {{ var option = document.createElement("option"); option.value = String(index); option.textContent = patches[index]; optgroup.appendChild(option); }} select.appendChild(optgroup); }} }}; window.init_patches_select_range = function(selectId, rangeStart, rangeEnd) {{ const select = document.getElementById(selectId); if (!select) {{ return; }} select.innerHTML = ""; var start = Math.max(0, rangeStart || 0); var end = Math.min(patches.length, rangeEnd || patches.length); for (var index = start; index < end; index++) {{ var option = document.createElement("option"); option.value = String(index); option.textContent = patches[index]; select.appendChild(option); }} }}; }})(); """ def main(): source = PATCHES_H.read_text() patches = parse_patches(source) OUTPUT.parent.mkdir(parents=True, exist_ok=True) OUTPUT.write_text(generate_js(patches)) print(f"Generated {OUTPUT.relative_to(ROOT)} ({len(patches)} patches)") if __name__ == "__main__": main() ================================================ FILE: setup.py ================================================ from distutils.core import setup, Extension from setuptools import find_packages import glob import os # the c++ extension module sources = ['algorithms.c', 'amy.c', 'delay.c', 'envelope.c', 'filters.c', 'parse.c', 'sequencer.c', 'transfer.c', 'midi_mappings.c', 'custom.c', 'patches.c', 'libminiaudio-audio.c', 'oscillators.c', 'interp_partials.c', 'pcm.c', 'pyamy.c', 'log2_exp2.c', 'instrument.c', 'amy_midi.c', 'api.c'] for i in range(len(sources)): sources[i] = "src/"+sources[i] os.environ["CC"] = "gcc" os.environ["CXX"] = "g++" comp_args = ["-I/opt/homebrew/include", "-DAMY_DEBUG", "-Wno-unused-but-set-variable", "-Wno-unreachable-code", "-DAMY_WAVETABLE"] link_args = ["-L/opt/homebrew/lib","-lpthread"] if os.uname()[0] == 'Darwin': frameworks = ['CoreAudio', 'AudioToolbox', 'AudioUnit', 'CoreFoundation', 'CoreMIDI', 'Cocoa'] sources += ['src/macos_midi.m'] for f in frameworks: link_args += ['-framework', f, '-lstdc++'] comp_args += ['-DMACOS'] if os.uname()[4] == 'armv7l' or os.uname()[4] == 'armv6l': link_args += ['-latomic', '-ldl'] extension_mod = Extension("c_amy", sources=sources, \ extra_compile_args=comp_args, \ extra_link_args=link_args) setup(name = "amy", packages=find_packages(include=['amy']), ext_modules=[extension_mod]) ================================================ FILE: setup_godot.sh ================================================ #!/usr/bin/env bash # # setup_godot.sh — Build and install the AMY GDExtension addon into a Godot project. # # Usage: # ./setup_godot.sh /path/to/your/godot/project # # Environment variables: # GODOT_CPP_PATH Path to godot-cpp checkout (default: ../godot-cpp) # JOBS Parallel build jobs (default: 8) # # This script: # 1. Builds the native GDExtension library using scons # 2. Creates addons/amy/ in your Godot project with: # - The GDScript Amy class (amy.gd) # - The GDExtension config and compiled library # - Web export support files # - The install.gd editor script for web setup set -euo pipefail AMY_DIR="$(cd "$(dirname "$0")" && pwd)" GODOT_CPP_PATH="${GODOT_CPP_PATH:-${AMY_DIR}/../godot-cpp}" JOBS="${JOBS:-8}" # ── Check arguments ────────────────────────────────────────────── if [ $# -lt 1 ]; then echo "Usage: $0 " echo "" echo " Builds the AMY GDExtension and installs it into a Godot project." echo "" echo " Environment variables:" echo " GODOT_CPP_PATH Path to godot-cpp (default: ../godot-cpp)" echo " JOBS Parallel jobs (default: 8)" exit 1 fi PROJECT_DIR="$(cd "$1" && pwd)" ADDON_DIR="${PROJECT_DIR}/addons/amy" if [ ! -f "${PROJECT_DIR}/project.godot" ]; then echo "ERROR: ${PROJECT_DIR} does not look like a Godot project (no project.godot found)" exit 1 fi if [ ! -d "${GODOT_CPP_PATH}" ]; then echo "ERROR: godot-cpp not found at ${GODOT_CPP_PATH}" echo " Clone it: git clone --branch godot-4.4-stable https://github.com/godotengine/godot-cpp.git ${GODOT_CPP_PATH}" echo " Or set: GODOT_CPP_PATH=/path/to/godot-cpp $0 $1" exit 1 fi echo "=== AMY Godot Addon Setup ===" echo " AMY source: ${AMY_DIR}/src" echo " godot-cpp: ${GODOT_CPP_PATH}" echo " Godot project: ${PROJECT_DIR}" echo " Addon output: ${ADDON_DIR}" echo "" # ── Create addon directory structure ───────────────────────────── echo "Creating addon directory structure..." mkdir -p "${ADDON_DIR}/src" mkdir -p "${ADDON_DIR}/bin" mkdir -p "${ADDON_DIR}/web" # ── Copy AMY C source (symlink-free, for scons) ───────────────── echo "Copying AMY source..." mkdir -p "${ADDON_DIR}/amy_src" cp "${AMY_DIR}"/src/*.c "${ADDON_DIR}/amy_src/" 2>/dev/null || true cp "${AMY_DIR}"/src/*.h "${ADDON_DIR}/amy_src/" 2>/dev/null || true # Godot shouldn't try to import C files touch "${ADDON_DIR}/amy_src/.gdignore" # ── Copy GDExtension wrapper source ───────────────────────────── echo "Copying GDExtension source..." cat > "${ADDON_DIR}/src/amy_gdextension.h" << 'HEADER_EOF' #ifndef AMY_GDEXTENSION_H #define AMY_GDEXTENSION_H #include #include #include #include namespace godot { class AmySynth : public Node { GDCLASS(AmySynth, Node) private: bool initialized = false; int sample_rate = 44100; int block_size = 256; // Config properties — set these before calling start() bool chorus = true; bool reverb = true; bool echo = true; bool default_synths = false; bool partials = true; bool custom = true; bool startup_bleep = false; bool audio_in = false; int max_oscs = 180; int max_voices = 64; int max_synths = 64; protected: static void _bind_methods(); public: AmySynth(); ~AmySynth(); void start(); void stop(); void send(const String &message); void send_note(int osc, int midi_note, float velocity, int duration_ms); PackedVector2Array fill_buffer(); int get_sample_rate() const; int get_block_size() const; uint64_t get_sysclock() const; bool is_running() const; // Config setters/getters void set_chorus(bool p_val); bool get_chorus() const; void set_reverb(bool p_val); bool get_reverb() const; void set_echo(bool p_val); bool get_echo() const; void set_default_synths(bool p_val); bool get_default_synths() const; void set_partials(bool p_val); bool get_partials() const; void set_custom(bool p_val); bool get_custom() const; void set_startup_bleep(bool p_val); bool get_startup_bleep() const; void set_audio_in(bool p_val); bool get_audio_in() const; void set_max_oscs(int p_val); int get_max_oscs() const; void set_max_voices(int p_val); int get_max_voices() const; void set_max_synths(int p_val); int get_max_synths() const; }; } // namespace godot #endif // AMY_GDEXTENSION_H HEADER_EOF cat > "${ADDON_DIR}/src/amy_gdextension.cpp" << 'CPP_EOF' #include "amy_gdextension.h" #include #include // AMY is a C library extern "C" { #include "amy.h" } using namespace godot; AmySynth::AmySynth() {} AmySynth::~AmySynth() { if (initialized) { amy_stop(); initialized = false; } } void AmySynth::_bind_methods() { ClassDB::bind_method(D_METHOD("start"), &AmySynth::start); ClassDB::bind_method(D_METHOD("stop"), &AmySynth::stop); ClassDB::bind_method(D_METHOD("send", "message"), &AmySynth::send); ClassDB::bind_method(D_METHOD("send_note", "osc", "midi_note", "velocity", "duration_ms"), &AmySynth::send_note); ClassDB::bind_method(D_METHOD("fill_buffer"), &AmySynth::fill_buffer); ClassDB::bind_method(D_METHOD("get_sample_rate"), &AmySynth::get_sample_rate); ClassDB::bind_method(D_METHOD("get_block_size"), &AmySynth::get_block_size); ClassDB::bind_method(D_METHOD("get_sysclock"), &AmySynth::get_sysclock); ClassDB::bind_method(D_METHOD("is_running"), &AmySynth::is_running); // Config property bindings — set before calling start() ClassDB::bind_method(D_METHOD("set_chorus", "enabled"), &AmySynth::set_chorus); ClassDB::bind_method(D_METHOD("get_chorus"), &AmySynth::get_chorus); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "chorus"), "set_chorus", "get_chorus"); ClassDB::bind_method(D_METHOD("set_reverb", "enabled"), &AmySynth::set_reverb); ClassDB::bind_method(D_METHOD("get_reverb"), &AmySynth::get_reverb); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "reverb"), "set_reverb", "get_reverb"); ClassDB::bind_method(D_METHOD("set_echo", "enabled"), &AmySynth::set_echo); ClassDB::bind_method(D_METHOD("get_echo"), &AmySynth::get_echo); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "echo"), "set_echo", "get_echo"); ClassDB::bind_method(D_METHOD("set_default_synths", "enabled"), &AmySynth::set_default_synths); ClassDB::bind_method(D_METHOD("get_default_synths"), &AmySynth::get_default_synths); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "default_synths"), "set_default_synths", "get_default_synths"); ClassDB::bind_method(D_METHOD("set_partials", "enabled"), &AmySynth::set_partials); ClassDB::bind_method(D_METHOD("get_partials"), &AmySynth::get_partials); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "partials"), "set_partials", "get_partials"); ClassDB::bind_method(D_METHOD("set_custom", "enabled"), &AmySynth::set_custom); ClassDB::bind_method(D_METHOD("get_custom"), &AmySynth::get_custom); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "custom"), "set_custom", "get_custom"); ClassDB::bind_method(D_METHOD("set_startup_bleep", "enabled"), &AmySynth::set_startup_bleep); ClassDB::bind_method(D_METHOD("get_startup_bleep"), &AmySynth::get_startup_bleep); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "startup_bleep"), "set_startup_bleep", "get_startup_bleep"); ClassDB::bind_method(D_METHOD("set_audio_in", "enabled"), &AmySynth::set_audio_in); ClassDB::bind_method(D_METHOD("get_audio_in"), &AmySynth::get_audio_in); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "audio_in"), "set_audio_in", "get_audio_in"); ClassDB::bind_method(D_METHOD("set_max_oscs", "count"), &AmySynth::set_max_oscs); ClassDB::bind_method(D_METHOD("get_max_oscs"), &AmySynth::get_max_oscs); ADD_PROPERTY(PropertyInfo(Variant::INT, "max_oscs"), "set_max_oscs", "get_max_oscs"); ClassDB::bind_method(D_METHOD("set_max_voices", "count"), &AmySynth::set_max_voices); ClassDB::bind_method(D_METHOD("get_max_voices"), &AmySynth::get_max_voices); ADD_PROPERTY(PropertyInfo(Variant::INT, "max_voices"), "set_max_voices", "get_max_voices"); ClassDB::bind_method(D_METHOD("set_max_synths", "count"), &AmySynth::set_max_synths); ClassDB::bind_method(D_METHOD("get_max_synths"), &AmySynth::get_max_synths); ADD_PROPERTY(PropertyInfo(Variant::INT, "max_synths"), "set_max_synths", "get_max_synths"); } void AmySynth::start() { if (initialized) return; amy_config_t config = amy_default_config(); config.audio = AMY_AUDIO_IS_NONE; // We handle audio output ourselves via Godot config.features.chorus = chorus ? 1 : 0; config.features.reverb = reverb ? 1 : 0; config.features.echo = echo ? 1 : 0; config.features.default_synths = default_synths ? 1 : 0; config.features.partials = partials ? 1 : 0; config.features.custom = custom ? 1 : 0; config.features.startup_bleep = startup_bleep ? 1 : 0; config.features.audio_in = audio_in ? 1 : 0; config.max_oscs = max_oscs; config.max_voices = max_voices; config.max_synths = max_synths; amy_start(config); initialized = true; sample_rate = AMY_SAMPLE_RATE; block_size = AMY_BLOCK_SIZE; UtilityFunctions::print("AMY synth started (", sample_rate, " Hz, block size ", block_size, ")"); } void AmySynth::stop() { if (!initialized) return; amy_stop(); initialized = false; UtilityFunctions::print("AMY synth stopped"); } void AmySynth::send(const String &message) { if (!initialized) return; CharString cs = message.utf8(); amy_add_message(const_cast(cs.get_data())); } void AmySynth::send_note(int osc, int midi_note, float velocity, int duration_ms) { if (!initialized) return; char msg[128]; if (duration_ms > 0) { snprintf(msg, sizeof(msg), "v%dw0n%dl%fd%d", osc, midi_note, velocity, duration_ms); } else { snprintf(msg, sizeof(msg), "v%dw0n%dl%f", osc, midi_note, velocity); } amy_add_message(msg); } PackedVector2Array AmySynth::fill_buffer() { PackedVector2Array buffer; if (!initialized) { buffer.resize(block_size); buffer.fill(Vector2(0, 0)); return buffer; } int16_t *samples = amy_simple_fill_buffer(); buffer.resize(block_size); const float scale = 1.0f / 32768.0f; for (int i = 0; i < block_size; i++) { float left = static_cast(samples[i * 2]) * scale; float right = static_cast(samples[i * 2 + 1]) * scale; buffer.set(i, Vector2(left, right)); } return buffer; } int AmySynth::get_sample_rate() const { return sample_rate; } int AmySynth::get_block_size() const { return block_size; } uint64_t AmySynth::get_sysclock() const { if (!initialized) return 0; return amy_sysclock(); } bool AmySynth::is_running() const { return initialized; } // Config setters/getters void AmySynth::set_chorus(bool p_val) { chorus = p_val; } bool AmySynth::get_chorus() const { return chorus; } void AmySynth::set_reverb(bool p_val) { reverb = p_val; } bool AmySynth::get_reverb() const { return reverb; } void AmySynth::set_echo(bool p_val) { echo = p_val; } bool AmySynth::get_echo() const { return echo; } void AmySynth::set_default_synths(bool p_val) { default_synths = p_val; } bool AmySynth::get_default_synths() const { return default_synths; } void AmySynth::set_partials(bool p_val) { partials = p_val; } bool AmySynth::get_partials() const { return partials; } void AmySynth::set_custom(bool p_val) { custom = p_val; } bool AmySynth::get_custom() const { return custom; } void AmySynth::set_startup_bleep(bool p_val) { startup_bleep = p_val; } bool AmySynth::get_startup_bleep() const { return startup_bleep; } void AmySynth::set_audio_in(bool p_val) { audio_in = p_val; } bool AmySynth::get_audio_in() const { return audio_in; } void AmySynth::set_max_oscs(int p_val) { max_oscs = p_val; } int AmySynth::get_max_oscs() const { return max_oscs; } void AmySynth::set_max_voices(int p_val) { max_voices = p_val; } int AmySynth::get_max_voices() const { return max_voices; } void AmySynth::set_max_synths(int p_val) { max_synths = p_val; } int AmySynth::get_max_synths() const { return max_synths; } CPP_EOF cat > "${ADDON_DIR}/src/register_types.h" << 'RTHEOF' #ifndef AMY_REGISTER_TYPES_H #define AMY_REGISTER_TYPES_H #include using namespace godot; void initialize_amy_module(ModuleInitializationLevel p_level); void uninitialize_amy_module(ModuleInitializationLevel p_level); #endif // AMY_REGISTER_TYPES_H RTHEOF cat > "${ADDON_DIR}/src/register_types.cpp" << 'RTCEOF' #include "register_types.h" #include "amy_gdextension.h" #include #include #include #include using namespace godot; void initialize_amy_module(ModuleInitializationLevel p_level) { if (p_level != MODULE_INITIALIZATION_LEVEL_SCENE) { return; } GDREGISTER_CLASS(AmySynth); } void uninitialize_amy_module(ModuleInitializationLevel p_level) { if (p_level != MODULE_INITIALIZATION_LEVEL_SCENE) { return; } } extern "C" { GDExtensionBool GDE_EXPORT amy_library_init( GDExtensionInterfaceGetProcAddress p_get_proc_address, const GDExtensionClassLibraryPtr p_library, GDExtensionInitialization *r_initialization ) { godot::GDExtensionBinding::InitObject init_obj(p_get_proc_address, p_library, r_initialization); init_obj.register_initializer(initialize_amy_module); init_obj.register_terminator(uninitialize_amy_module); init_obj.set_minimum_library_initialization_level(MODULE_INITIALIZATION_LEVEL_SCENE); return init_obj.init(); } } // extern "C" RTCEOF cat > "${ADDON_DIR}/src/amy_platform_stubs.c" << 'STUBEOF' // Stub implementations for AMY platform/hardware functions. // We don't need I2S or MIDI hardware - Godot handles all audio. // miniaudio stubs are no longer needed thanks to -DAMY_NO_MINIAUDIO. #include #include // --- i2s.c stubs --- void amy_platform_init(void) {} void amy_platform_deinit(void) {} void amy_update_tasks(void) {} int16_t *amy_render_audio(void) { return (int16_t *)0; } size_t amy_i2s_write(const uint8_t *buffer, size_t nbytes) { (void)buffer; (void)nbytes; return nbytes; } // --- MIDI stubs (amy_midi.c / macos_midi.m) --- void midi_out(uint8_t *bytes, uint16_t len) { (void)bytes; (void)len; } void midi_local(uint8_t *bytes, uint16_t len) { (void)bytes; (void)len; } void run_midi(void) {} void stop_midi(void) {} void amy_send_midi_note_on(uint16_t osc) { (void)osc; } void amy_send_midi_note_off(uint16_t osc) { (void)osc; } void *run_midi_macos(void *vargp) { (void)vargp; return (void *)0; } void check_tusb_midi(void) {} void init_tusb_midi(void) {} STUBEOF # ── Copy SConstruct ────────────────────────────────────────────── echo "Copying SConstruct..." cat > "${ADDON_DIR}/SConstruct" << 'SCONSEOF' #!/usr/bin/env python """ Build script for the AMY Synthesizer GDExtension. AMY C source lookup order: 1. AMY_SRC_PATH environment variable (if set) 2. ./amy_src/ (vendored source, included in this addon) """ import os import sys # Find godot-cpp (two levels up from addons/amy/) godot_cpp_path = os.environ.get("GODOT_CPP_PATH", "../../godot-cpp") # Find AMY C source: env var > vendored copy amy_src_path = os.environ.get("AMY_SRC_PATH", "amy_src") if not os.path.isdir(amy_src_path): print("ERROR: AMY source not found at '{}'. Either:") print(" - Place AMY source in addons/amy/amy_src/") print(" - Or set AMY_SRC_PATH environment variable") Exit(1) env = SConscript(os.path.join(godot_cpp_path, "SConstruct")) # AMY C source files (core synthesis - no platform-specific I2S, no example mains) amy_sources = [ "algorithms.c", "amy.c", "api.c", "custom.c", "delay.c", "envelope.c", "examples.c", "filters.c", "instrument.c", "interp_partials.c", "log2_exp2.c", "midi_mappings.c", "oscillators.c", "parse.c", "patches.c", "pcm.c", "sequencer.c", "transfer.c", ] # Add AMY include path env.Append(CPPPATH=[amy_src_path]) # AMY compile flags - suppress warnings from AMY's C code env.Append(CFLAGS=["-Wno-unused-parameter", "-Wno-sign-compare", "-Wno-missing-field-initializers"]) env.Append(CCFLAGS=["-DAMY_WAVETABLE", "-DAMY_NO_MINIAUDIO"]) # On macOS, we need some frameworks for threading if sys.platform == "darwin": env.Append(CCFLAGS=["-DMACOS"]) env.Append(LINKFLAGS=["-framework", "CoreFoundation"]) # Build all sources together - AMY C files + GDExtension C++ files all_sources = [] for src in amy_sources: src_path = os.path.join(amy_src_path, src) if os.path.exists(src_path): all_sources.append(src_path) # GDExtension C++ sources + platform stubs all_sources += [ "src/amy_platform_stubs.c", "src/amy_gdextension.cpp", "src/register_types.cpp", ] # Add our source include path env.Append(CPPPATH=["src"]) # Build shared library directly from all sources if sys.platform == "darwin": # Build as framework for macOS lib_name = "libamy{}".format(env["suffix"]) framework_dir = "bin/{}.framework".format(lib_name) library = env.SharedLibrary( target=os.path.join(framework_dir, lib_name), source=all_sources, ) else: library = env.SharedLibrary( target="bin/libamy{}{}".format(env["suffix"], env["SHLIBSUFFIX"]), source=all_sources, ) Default(library) SCONSEOF # ── Copy GDExtension config ───────────────────────────────────── echo "Copying GDExtension config..." cat > "${ADDON_DIR}/amy.gdextension" << 'GDEXTEOF' [configuration] entry_symbol = "amy_library_init" compatibility_minimum = "4.3" [libraries] macos.debug = "res://addons/amy/bin/libamy.macos.template_debug.universal.framework" macos.release = "res://addons/amy/bin/libamy.macos.template_debug.universal.framework" linux.debug.x86_64 = "res://addons/amy/bin/libamy.linux.template_debug.x86_64.so" linux.release.x86_64 = "res://addons/amy/bin/libamy.linux.template_release.x86_64.so" windows.debug.x86_64 = "res://addons/amy/bin/libamy.windows.template_debug.x86_64.dll" windows.release.x86_64 = "res://addons/amy/bin/libamy.windows.template_release.x86_64.dll" GDEXTEOF # ── Build native library ──────────────────────────────────────── echo "" echo "Building native GDExtension library..." cd "${ADDON_DIR}" GODOT_CPP_PATH="${GODOT_CPP_PATH}" scons -j"${JOBS}" 2>&1 | tail -5 BUILD_STATUS=${PIPESTATUS[0]} if [ ${BUILD_STATUS} -ne 0 ]; then echo "" echo "ERROR: Build failed. Check the output above." exit 1 fi echo "" echo "Build successful!" # ── Copy GDScript wrapper (amy.gd) ────────────────────────────── echo "Copying GDScript files..." cat > "${ADDON_DIR}/amy.gd" << 'GDEOF' class_name Amy extends Node ## AMY Synthesizer for Godot. ## ## High-level GDScript API that mirrors AMY's Python interface. ## Works on native (GDExtension) and web (WASM via JavaScriptBridge). ## ## Usage: ## var amy := Amy.new() ## add_child(amy) ## await get_tree().process_frame ## amy.send({"osc": 0, "wave": Amy.SINE, "freq": 440, "vel": 1.0}) ## ## Or use wire protocol directly: ## amy.send_raw("v0w0f440l1") # ============================================================ # Wave types # ============================================================ const SINE: int = 0 const PULSE: int = 1 const SAW_DOWN: int = 2 const SAW_UP: int = 3 const TRIANGLE: int = 4 const NOISE: int = 5 const KS: int = 6 const PCM: int = 7 const ALGO: int = 8 const PARTIAL: int = 9 const BYO_PARTIALS: int = 10 const INTERP_PARTIALS: int = 11 const AUDIO_IN0: int = 12 const AUDIO_IN1: int = 13 const WAVETABLE: int = 19 const CUSTOM: int = 20 const WAVE_OFF: int = 21 # ============================================================ # Filter types # ============================================================ const FILTER_NONE: int = 0 const FILTER_LPF: int = 1 const FILTER_BPF: int = 2 const FILTER_HPF: int = 3 const FILTER_LPF24: int = 4 # ============================================================ # Envelope types # ============================================================ const ENVELOPE_NORMAL: int = 0 const ENVELOPE_LINEAR: int = 1 const ENVELOPE_DX7: int = 2 const ENVELOPE_TRUE_EXPONENTIAL: int = 3 # ============================================================ # Config — set these before adding to the tree (before _ready) # ============================================================ ## Enable chorus effect. @export var chorus: bool = true ## Enable reverb effect. @export var reverb: bool = true ## Enable echo/delay effect. @export var echo: bool = true ## Load default GM synth patches on startup. @export var default_synths: bool = false ## Enable partial synthesis. @export var partials: bool = true ## Enable custom oscillator type. @export var custom: bool = true ## Play a short bleep on startup. @export var startup_bleep: bool = false ## Enable audio input. @export var audio_in: bool = false ## Maximum number of oscillators. @export var max_oscs: int = 180 ## Maximum number of voices. @export var max_voices: int = 64 ## Maximum number of synths. @export var max_synths: int = 64 # ============================================================ # Internals — audio bridge # ============================================================ var _synth: Node = null var _stream_player: AudioStreamPlayer = null var _playback: AudioStreamGeneratorPlayback = null var _started: bool = false var _is_web: bool = false func _ready() -> void: _is_web = OS.get_name() == "Web" if _is_web: _init_web() else: _init_native() func _init_native() -> void: if ClassDB.class_exists(&"AmySynth"): _synth = ClassDB.instantiate(&"AmySynth") add_child(_synth) else: push_warning("AmySynth GDExtension not loaded — audio disabled") return # Apply config before starting _synth.set("chorus", chorus) _synth.set("reverb", reverb) _synth.set("echo", echo) _synth.set("default_synths", default_synths) _synth.set("partials", partials) _synth.set("custom", custom) _synth.set("startup_bleep", startup_bleep) _synth.set("audio_in", audio_in) _synth.set("max_oscs", max_oscs) _synth.set("max_voices", max_voices) _synth.set("max_synths", max_synths) _stream_player = AudioStreamPlayer.new() var stream := AudioStreamGenerator.new() stream.mix_rate = 44100.0 stream.buffer_length = 0.1 _stream_player.stream = stream _stream_player.bus = "Master" add_child(_stream_player) _synth.call("start") _stream_player.play() _playback = _stream_player.get_stream_playback() as AudioStreamGeneratorPlayback _started = true func _init_web() -> void: for i in range(100): var ready: Variant = JavaScriptBridge.eval("godot_amy_is_ready()", true) if ready: _started = true print("AMY web synth ready") return await get_tree().create_timer(0.1).timeout push_warning("AMY web module failed to load after 10 s") func _process(_delta: float) -> void: if _started and not _is_web: _fill_audio() func _fill_audio() -> void: if _playback == null or _synth == null: return var block_size: Variant = _synth.call("get_block_size") var bs: int = block_size as int while _playback.can_push_buffer(bs): var buffer: Variant = _synth.call("fill_buffer") _playback.push_buffer(buffer as PackedVector2Array) func _exit_tree() -> void: if not _is_web and _synth: _synth.call("stop") # ============================================================ # Public API # ============================================================ ## Send an AMY message using keyword-style parameters. ## Example: ## amy.send({"osc": 0, "wave": Amy.SINE, "freq": 440, "vel": 1}) ## amy.send({"osc": 0, "vel": 0}) # note off func send(params: Dictionary = {}) -> void: send_raw(message(params)) ## Build an AMY wire message from a dictionary without sending it. ## Returns the wire string (e.g. "v0w0f440l1"). func message(params: Dictionary) -> String: var wire: String = "" for key: Variant in params: var key_str: String = str(key) if not _KW_MAP.has(key_str): push_warning("AMY: unknown parameter '%s'" % key_str) continue var mapping: Variant = _KW_MAP[key_str] var m: Array = mapping as Array var code: String = str(m[0]) var type: String = str(m[1]) var val: Variant = params[key] wire += code + _format_value(val, type) return wire ## Send a raw AMY wire-protocol string. ## Example: amy.send_raw("v0w0f440l1") func send_raw(msg: String) -> void: if not _started or msg.is_empty(): return if _is_web: var safe: String = msg.replace("\\", "\\\\").replace("'", "\\'") JavaScriptBridge.eval("godot_amy_send('%s')" % safe) else: if _synth: _synth.call("send", msg) ## Stop all sound immediately. func panic() -> void: send_raw("S") # ============================================================ # Value formatting helpers # ============================================================ func _format_value(val: Variant, type: String) -> String: match type: "I": return str(int(val)) "F": return _trunc(float(val)) "S": return str(val) "L": return _format_list(val) "C": return _format_ctrl(val) return str(val) ## Truncate a float to 4 decimal places, strip trailing zeros. func _trunc(f: float) -> String: if f == int(f): return str(int(f)) var s: String = "%.4f" % f while s.ends_with("0"): s = s.substr(0, s.length() - 1) if s.ends_with("."): s = s.substr(0, s.length() - 1) return s ## Format a list/array as comma-separated values. func _format_list(val: Variant) -> String: if val is String: return str(val) if val is Array: var parts: PackedStringArray = PackedStringArray() for item: Variant in val: parts.append(_trunc(float(item))) return ",".join(parts) return str(val) ## Format a control coefficient value. ## Can be a number (treated as const), a string, or an array. func _format_ctrl(val: Variant) -> String: if val is float or val is int: return _trunc(float(val)) if val is String: return str(val) if val is Array: var parts: PackedStringArray = PackedStringArray() for item: Variant in val: parts.append(_trunc(float(item))) return ",".join(parts) return str(val) # ============================================================ # Parameter → wire-code mapping (matches AMY Python API) # ============================================================ var _KW_MAP: Dictionary = { "osc": ["v", "I"], "wave": ["w", "I"], "note": ["n", "F"], "vel": ["l", "F"], "amp": ["a", "C"], "freq": ["f", "C"], "duty": ["d", "C"], "feedback": ["b", "F"], "time": ["t", "I"], "reset": ["S", "I"], "phase": ["P", "F"], "pan": ["Q", "C"], "client": ["g", "I"], "volume": ["V", "F"], "pitch_bend": ["s", "F"], "filter_freq": ["F", "C"], "resonance": ["R", "F"], "bp0": ["A", "L"], "bp1": ["B", "L"], "eg0_type": ["T", "I"], "eg1_type": ["X", "I"], "debug": ["D", "I"], "chained_osc": ["c", "I"], "mod_source": ["L", "I"], "eq": ["x", "L"], "filter_type": ["G", "I"], "ratio": ["I", "F"], "latency_ms": ["N", "I"], "algo_source": ["O", "L"], "algorithm": ["o", "I"], "chorus": ["k", "L"], "reverb": ["h", "L"], "echo": ["M", "L"], "patch": ["K", "I"], "voices": ["r", "L"], "external_channel": ["W", "I"], "portamento": ["m", "I"], "sequence": ["H", "L"], "tempo": ["j", "F"], "synth": ["i", "I"], "num_voices": ["iv", "I"], "preset": ["p", "I"], "num_partials": ["p", "I"], } GDEOF # ── Copy web export files ──────────────────────────────────────── echo "Copying web export files..." WEB_SRC="${AMY_DIR}/docs" cp "${WEB_SRC}/amy.js" "${ADDON_DIR}/web/" cp "${WEB_SRC}/amy.wasm" "${ADDON_DIR}/web/" cp "${WEB_SRC}/amy.aw.js" "${ADDON_DIR}/web/" cp "${WEB_SRC}/amy.ww.js" "${ADDON_DIR}/web/" cp "${WEB_SRC}/enable-threads.js" "${ADDON_DIR}/web/" # A copy for project root (service worker needs root scope) cp "${WEB_SRC}/enable-threads.js" "${ADDON_DIR}/web/enable-threads-root.js" # Godot<->AMY bridge cat > "${ADDON_DIR}/web/godot_amy_bridge.js" << 'BRIDGEEOF' // godot_amy_bridge.js // Thin bridge between Godot's JavaScriptBridge and AMY's WASM module. // AMY handles its own audio output via AudioWorklet on web — // this bridge just provides init/send functions for GDScript to call. (function() { var _audio_started = false; // Start AMY's AudioWorklet (must be called from user gesture context) async function _try_start_audio() { if (_audio_started) return; if (typeof amy_live_start_web !== 'function') return; try { await amy_live_start_web(); _audio_started = true; console.log("[AMY Bridge] Audio started via user gesture"); // Remove listeners once started document.removeEventListener('click', _try_start_audio); document.removeEventListener('keydown', _try_start_audio); document.removeEventListener('touchstart', _try_start_audio); } catch(e) { console.error("[AMY Bridge] Audio start failed:", e); } } // Register for user gesture events (Web Audio API requirement) document.addEventListener('click', _try_start_audio); document.addEventListener('keydown', _try_start_audio); document.addEventListener('touchstart', _try_start_audio); // -- Functions called from GDScript via JavaScriptBridge.eval() -- // Check if AMY WASM module is initialized and ready window.godot_amy_is_ready = function() { return typeof amy_add_message === 'function'; }; // Check if AudioWorklet is running window.godot_amy_audio_started = function() { return _audio_started; }; // Send a wire message to AMY (e.g. "v0w0f440l1") window.godot_amy_send = function(msg) { if (typeof amy_add_message === 'function') { amy_add_message(msg); } }; })(); BRIDGEEOF # Custom HTML shell for web export cat > "${ADDON_DIR}/web/custom_shell.html" << 'SHELLEOF' $GODOT_PROJECT_NAME $GODOT_HEAD_INCLUDE Your browser does not support the canvas tag.
SHELLEOF # ── Copy install.gd editor script ─────────────────────────────── echo "Copying install.gd..." cat > "${ADDON_DIR}/install.gd" << 'INSTALLEOF' @tool extends EditorScript ## AMY Synthesizer Addon - Web Export Setup ## ## Run this script once (via File > Run) to copy web export files ## to the correct locations in your project. ## ## It copies: ## - enable-threads.js → project root (service worker needs root scope) ## - web_audio/ → project root (referenced by custom HTML shell) ## - Sets up export preset if one doesn't exist func _run() -> void: var addon_dir: String = "res://addons/amy/web/" var dst_web: String = "res://web_audio/" var dst_root: String = "res://" print("=== AMY Web Export Setup ===") # Copy enable-threads.js to project root _copy_file(addon_dir + "enable-threads-root.js", dst_root + "enable-threads.js") # Copy web audio files var web_files: Array[String] = [ "amy.js", "amy.wasm", "amy.aw.js", "amy.ww.js", "godot_amy_bridge.js", "enable-threads.js" ] # Create web_audio directory DirAccess.make_dir_absolute(ProjectSettings.globalize_path(dst_web)) # Create .gdignore in web_audio var gdignore: FileAccess = FileAccess.open(dst_web + ".gdignore", FileAccess.WRITE) if gdignore: gdignore.close() print(" Created web_audio/.gdignore") for fname in web_files: _copy_file(addon_dir + fname, dst_web + fname) # Copy custom HTML shell to export/ DirAccess.make_dir_absolute(ProjectSettings.globalize_path("res://export/")) _copy_file(addon_dir + "custom_shell.html", "res://export/custom_shell.html") print("") print("=== Setup Complete ===") print("") print("Next steps:") print(" 1. In Export dialog, set Custom HTML Shell to: res://export/custom_shell.html") print(" 2. Set Exclude Filter to: addons/amy/bin/*,addons/amy/src/*,addons/amy/amy_src/*,addons/amy/web/*,addons/amy/SConstruct,addons/amy/install.gd,addons/amy/amy.gdextension") print(" 3. Export for Web as usual!") print("") func _copy_file(src: String, dst: String) -> void: var src_path: String = ProjectSettings.globalize_path(src) var dst_path: String = ProjectSettings.globalize_path(dst) var file_in: FileAccess = FileAccess.open(src, FileAccess.READ) if file_in == null: push_warning("Could not read: " + src) return var content: PackedByteArray = file_in.get_buffer(file_in.get_length()) file_in.close() var file_out: FileAccess = FileAccess.open(dst, FileAccess.WRITE) if file_out == null: push_warning("Could not write: " + dst) return file_out.store_buffer(content) file_out.close() print(" Copied: " + src.get_file() + " -> " + dst) INSTALLEOF # ── Clean up build artifacts from addon ────────────────────────── echo "Cleaning build artifacts..." find "${ADDON_DIR}/amy_src" -name "*.os" -delete 2>/dev/null || true find "${ADDON_DIR}/src" -name "*.os" -delete 2>/dev/null || true # ── Done ───────────────────────────────────────────────────────── echo "" echo "=== Done! ===" echo "" echo "The AMY addon has been installed to: ${ADDON_DIR}" echo "" echo "Next steps:" echo " 1. Open the project in the Godot editor" echo " 2. Use Amy in your scripts:" echo " var amy := Amy.new()" echo " add_child(amy)" echo " await get_tree().process_frame" echo " amy.send({\"osc\": 0, \"wave\": Amy.SINE, \"freq\": 440, \"vel\": 1.0})" echo "" echo " For web export setup, see: https://github.com/shorepine/amy/blob/main/docs/godot.md" ================================================ FILE: src/AMY-Arduino.h ================================================ // AMY-Arduino.h // connector for Arduino #ifndef AMYARDUINOH #define AMYARDUINOH #include "Arduino.h" extern "C" { #include "amy.h" } #endif ================================================ FILE: src/algorithms.c ================================================ // algorithms.c #include "amy.h" // Thank you MFSA for the DX7 op structure , borrowed here \/ \/ \/ enum FmOperatorFlags { OUT_BUS_ONE = 1 << 0, OUT_BUS_TWO = 1 << 1, OUT_BUS_ADD = 1 << 2, // there is no 1 << 3 IN_BUS_ONE = 1 << 4, IN_BUS_TWO = 1 << 5, FB_IN = 1 << 6, FB_OUT = 1 << 7 }; // We never see 0x?6 (add to bus two) // There are just instances of 0x?2 (write to bus two) and they are both 0x02 // We never see input BUS_ONE output ADD BUS_ONE // algo feedback input output // 0x01 - BUS_ONE // 0x41 IN - BUS_ONE // 0xc1 IN OUT - BUS_ONE // 0x11 BUS_ONE BUS_ONE // This is the only case when we can't directly accumulate the (possibly zero'd) output because it's the input // 0x05 - ADD BUS_ONE // 0xc5 IN OUT - ADD BUS_ONE // 0x25 BUS_TWO ADD BUS_ONE // 0x02 - BUS_TWO // 0x04 - ADD op // 0x14 BUS_ONE ADD op // 0x94 OUT BUS_ONE ADD op // 0xC4 IN OUT BUS_ONE ADD op struct FmAlgorithm { uint8_t ops[MAX_ALGO_OPS]; }; const struct FmAlgorithm algorithms[33] = { // 6 5 4 3 2 1 { { 0xc1, 0x11, 0x11, 0x14, 0x01, 0x14 } }, // 0 { { 0xc1, 0x11, 0x11, 0x14, 0x01, 0x14 } }, // 1 { { 0x01, 0x11, 0x11, 0x14, 0xc1, 0x14 } }, // 2 { { 0xc1, 0x11, 0x14, 0x01, 0x11, 0x14 } }, // 3 { { 0x41, 0x11, 0x94, 0x01, 0x11, 0x14 } }, // 4 { { 0xc1, 0x14, 0x01, 0x14, 0x01, 0x14 } }, // 5 { { 0x41, 0x94, 0x01, 0x14, 0x01, 0x14 } }, // 6 { { 0xc1, 0x11, 0x05, 0x14, 0x01, 0x14 } }, // 7 { { 0x01, 0x11, 0xc5, 0x14, 0x01, 0x14 } }, // 8 { { 0x01, 0x11, 0x05, 0x14, 0xc1, 0x14 } }, // 9 { { 0x01, 0x05, 0x14, 0xc1, 0x11, 0x14 } }, // 10 { { 0xc1, 0x05, 0x14, 0x01, 0x11, 0x14 } }, // 11 { { 0x01, 0x05, 0x05, 0x14, 0xc1, 0x14 } }, // 12 { { 0xc1, 0x05, 0x05, 0x14, 0x01, 0x14 } }, // 13 { { 0xc1, 0x05, 0x11, 0x14, 0x01, 0x14 } }, // 14 { { 0x01, 0x05, 0x11, 0x14, 0xc1, 0x14 } }, // 15 { { 0xc1, 0x11, 0x02, 0x25, 0x05, 0x14 } }, // 16 { { 0x01, 0x11, 0x02, 0x25, 0xc5, 0x14 } }, // 17 { { 0x01, 0x11, 0x11, 0xc5, 0x05, 0x14 } }, // 18 { { 0xc1, 0x14, 0x14, 0x01, 0x11, 0x14 } }, // 19 { { 0x01, 0x05, 0x14, 0xc1, 0x14, 0x14 } }, // 20 { { 0x01, 0x14, 0x14, 0xc1, 0x14, 0x14 } }, // 21 { { 0xc1, 0x14, 0x14, 0x14, 0x01, 0x14 } }, // 22 { { 0xc1, 0x14, 0x14, 0x01, 0x14, 0x04 } }, // 23 { { 0xc1, 0x14, 0x14, 0x14, 0x04, 0x04 } }, // 24 { { 0xc1, 0x14, 0x14, 0x04, 0x04, 0x04 } }, // 25 { { 0xc1, 0x05, 0x14, 0x01, 0x14, 0x04 } }, // 26 { { 0x01, 0x05, 0x14, 0xc1, 0x14, 0x04 } }, // 27 { { 0x04, 0xc1, 0x11, 0x14, 0x01, 0x14 } }, // 28 { { 0xc1, 0x14, 0x01, 0x14, 0x04, 0x04 } }, // 29 { { 0x04, 0xc1, 0x11, 0x14, 0x04, 0x04 } }, // 30 { { 0xc1, 0x14, 0x04, 0x04, 0x04, 0x04 } }, // 31 { { 0xc4, 0x04, 0x04, 0x04, 0x04, 0x04 } }, // 32 }; // End of MSFA stuff // a = 0 static inline void zero(SAMPLE* a) { bzero((void *)a, AMY_BLOCK_SIZE * sizeof(SAMPLE)); } // b = a static inline void copy(SAMPLE* a, SAMPLE* b) { bcopy((void *)a, (void *)b, AMY_BLOCK_SIZE * sizeof(SAMPLE)); } SAMPLE render_mod(SAMPLE *in, SAMPLE* out, uint16_t osc, SAMPLE feedback_level, uint16_t algo_osc, SAMPLE amp) { hold_and_modify(osc); //printf("render_mod: osc %d msynth.amp %f\n", osc, msynth[osc]->amp); // out = buf // in = mod // so render_mod is mod, buf (out) SAMPLE max_value = 0; if(synth[osc]->wave == SINE) max_value = render_fm_sine(out, osc, in, feedback_level, algo_osc, amp); return max_value; } void note_on_mod(uint16_t osc, uint16_t algo_osc) { // Perform the vital parts of amy.c:1089 ff since these oscs aren't turned on elsewhere. synth[osc]->note_on_clock = amy_global.total_blocks * AMY_BLOCK_SIZE; synth[osc]->status = SYNTH_IS_ALGO_SOURCE; // to ensure it's rendered if (AMY_IS_SET(synth[osc]->trigger_phase)) synth[osc]->phase = F2P(synth[osc]->trigger_phase); if(synth[osc]->wave==SINE) fm_sine_note_on(osc, algo_osc); } void algo_note_off(uint16_t osc) { for(uint8_t i=0;ialgo_source[i])) { uint16_t o = synth[osc]->algo_source[i]; AMY_UNSET(synth[o]->note_on_clock); synth[o]->note_off_clock = amy_global.total_blocks * AMY_BLOCK_SIZE; } } // osc note off, start release AMY_UNSET(synth[osc]->note_on_clock); synth[osc]->note_off_clock = amy_global.total_blocks * AMY_BLOCK_SIZE; } void algo_note_on(uint16_t osc, float freq) { msynth[osc]->logfreq = logfreq_of_freq(freq); for(uint8_t i=0;ialgo_source[i])) { note_on_mod(synth[osc]->algo_source[i], osc); } } } SAMPLE *** scratch; void algo_deinit() { for(uint16_t i=0;ialgorithm]; SAMPLE max_value = 0; // starts at op 6 SAMPLE* in_buf; SAMPLE* out_buf = NULL; SAMPLE* const BUS_ONE = scratch[core][0]; SAMPLE* const BUS_TWO = scratch[core][1]; SAMPLE* const SCRATCH = scratch[core][2]; //for (int i = 0; i < 3; ++i) // zero(scratch[core][i]); SAMPLE amp = SHIFTR(F2S(msynth[osc]->amp), 2); // Arbitrarily divide FM voice output by 4 to make it more in line with other oscs. for(uint8_t op=0;opfeedback); } // main algo voice stores feedback, not the op if(algo.ops[op] & IN_BUS_ONE) { in_buf = BUS_ONE; } else if(algo.ops[op] & IN_BUS_TWO) { in_buf = BUS_TWO; } else { // no in_buf in_buf = NULL; } if ( (algo.ops[op] & IN_BUS_ONE) && (algo.ops[op] & OUT_BUS_ONE) /* && !(algo.ops[op] & OUT_BUS_ADD) */ ) { // IN_BUS_ONE + OUT_BUS_ONE is never ADD // Input is BUS_ONE and output overwrites it, use a temp buffer. out_buf = SCRATCH; } else if (algo.ops[op] & OUT_BUS_ONE) { out_buf = BUS_ONE; } else if (algo.ops[op] & OUT_BUS_TWO) { out_buf = BUS_TWO; } else { out_buf = buf; // We apply the msynth amp to every buf that goes into the final output buffer. mod_amp = amp; } if (!(algo.ops[op] & OUT_BUS_ADD)) { // Output is not being accumulated, so have to clear it first. zero(out_buf); } SAMPLE value = 0; if(AMY_IS_SET(synth[osc]->algo_source[op]) && synth[synth[osc]->algo_source[op]]->status == SYNTH_IS_ALGO_SOURCE) { value = render_mod(in_buf, out_buf, synth[osc]->algo_source[op], feedback_level, osc, mod_amp); } // If osc is not set, output has already been cleared. if (out_buf == buf && value > max_value) max_value = value; if (out_buf == SCRATCH) { // We had to invoke the spare buffer, meaning we're overwriting BUS_ONE copy(out_buf, BUS_ONE); } } //fprintf(stderr, "render_algo: time %.3f osc %d last_amp %f amp %f max_val=%f\n", amy_global.time, osc, (msynth[osc]->last_amp), (msynth[osc]->amp), S2F(max_value)); // TODO, i need to figure out what happens on note offs for algo_sources.. they should still render.. return max_value; } ================================================ FILE: src/amy-example.c ================================================ // amy-example.c // a simple C example that plays audio using AMY out your speaker #ifndef ARDUINO #include "amy.h" #include "examples.h" #include "miniaudio.h" #include "libminiaudio-audio.h" void delay_ms(uint32_t ms) { uint32_t start = amy_sysclock(); while(amy_sysclock() - start < ms) usleep(THREAD_USLEEP); } // Example how to use external render hook uint8_t render(uint16_t osc, SAMPLE * buf, uint16_t len) { //fprintf(stderr, "render hook %d\n", osc); return 0; // 0 means, ignore this. 1 means, i handled this and don't mix it in with the audio } void print_events_for_patch_number(int patch_number) { void *state = NULL; fprintf(stderr, "start delta_num_free = %d\n", delta_num_free()); amy_event event = amy_default_event(); char s[MAX_MESSAGE_LEN]; do { state = yield_patch_events(patch_number, &event, state); sprint_event(&event, s, MAX_MESSAGE_LEN, false); fprintf(stderr, "%s\n", s); } while (state != NULL); fprintf(stderr, "end delta_num_free = %d\n", delta_num_free()); } void print_events_for_synth(int synth, bool wirecode) { fprintf(stderr, "synth %d:\n", synth); void * state = NULL; amy_event event = amy_default_event(); char s[MAX_MESSAGE_LEN]; do { state = yield_synth_events(synth, &event, true, state); sprint_event(&event, s, MAX_MESSAGE_LEN, wirecode); fprintf(stderr, "%s\n", s); } while(state != NULL); } void print_events_for_synth_2(int synth, bool wirecode) { fprintf(stderr, "pefs2: synth %d:\n", synth); void * state = NULL; char s[MAX_MESSAGE_LEN]; do { state = yield_synth_commands(synth, s, MAX_MESSAGE_LEN, true, state); fprintf(stderr, "%s\n", s); } while(state != NULL); } void test_patch_set() { // Check that trying to program a non-user patch doesn't crash amy_event e = amy_default_event(); e.patch_number = 25; e.osc = 0; e.wave = SINE; amy_add_event(&e); // Change the global volume. e = amy_default_event(); e.volume = 2.0f; amy_add_event(&e); } void test_loop_env_filt() { // After amy/test.py:TestLoopEnvFilt //amy.send(time=0, osc=0, wave=amy.PCM, preset=10, feedback=1) amy_add_message("t0v0w7p10b1Z"); //amy.send(time=0, osc=0, filter_type=amy.FILTER_LPF24, filter_freq='200,0,0,0,3', bp1='0,1,500,0,200,0') amy_add_message("t0v0G4F200,0,0,0,3B0,1,500,0,200,0Z"); //amy.send(time=0, osc=0, bp0='100,1,1000,0,1000,0') amy_add_message("t0v0A100,1,1000,0,1000,0Z"); //amy.send(time=0, osc=1, freq='1') amy_add_message("t0v1f1Z"); //amy.send(time=0, osc=0, mod_source=1, freq=',,,,,-0.2') amy_add_message("t0v0L1f,,,,,-0.2Z"); //amy.send(time=100, osc=0, note=64, vel=5) amy_add_message("t100v0n64l5Z"); //amy.send(time=500, osc=0, vel=0) amy_add_message("t500v0l0Z"); } void test_algo() { //amy.send(time=0, voices="0", patch=21+128) amy_add_message("t0r0K149Z"); //amy.send(time=100, voices="0", note=58, vel=1) amy_add_message("t100r0n58l1Z"); //amy.send(time=500, voices="0", vel=0) amy_add_message("t400r0l0Z"); } void test_stored_patch() { // Reading back a stored patch int patch_number = 0; print_events_for_patch_number(patch_number); // Reading back a user-defined patch patch_number = 1024; amy_event e = amy_default_event(); e.patch_number = patch_number; e.osc = 0; e.wave = PULSE; e.mod_source = 2; e.amp_coefs[COEF_VEL] = 1.0f; e.amp_coefs[COEF_EG0] = 1.0f; e.amp_coefs[COEF_EG1] = 0; e.freq_coefs[COEF_CONST] = 130.81f; e.freq_coefs[COEF_NOTE] = 1.f; e.portamento_ms = 0; e.eg0_times[0] = 30; e.eg0_values[0] = 1.0f; e.eg0_times[1] = 1355; e.eg0_values[1] = 0.354f; e.eg0_times[2] = 232; e.eg0_values[2] = 0.0f; amy_add_event(&e); e = amy_default_event(); e.patch_number = patch_number; e.osc = 0; e.chained_osc = 1; e.filter_type = FILTER_LPF24; e.filter_freq_coefs[COEF_CONST] = 126.54f; e.filter_freq_coefs[COEF_NOTE] = 0.677f; e.filter_freq_coefs[COEF_EG1] = 5.024f; e.resonance = 0.93f; e.eg1_times[0] = 30; e.eg1_values[0] = 1.0f; e.eg1_times[1] = 1355; e.eg1_values[1] = 0.354f; e.eg1_times[2] = 232; e.eg1_values[2] = 0.0f; amy_add_event(&e); e = amy_default_event(); e.patch_number = patch_number; e.osc = 1; e.wave = SAW_UP; e.mod_source = 2; e.amp_coefs[COEF_VEL] = 1.0f; e.amp_coefs[COEF_EG0] = 1.0f; e.amp_coefs[COEF_EG1] = 0; e.freq_coefs[COEF_CONST] = 130.81f; e.freq_coefs[COEF_NOTE] = 1.f; e.portamento_ms = 0; e.eg0_times[0] = 30; e.eg0_values[0] = 1.0f; e.eg0_times[1] = 1355; e.eg0_values[1] = 0.354f; e.eg0_times[2] = 232; e.eg0_values[2] = 0.0f; amy_add_event(&e); e = amy_default_event(); e.patch_number = patch_number; e.osc = 2; e.wave = TRIANGLE; e.mod_source = 2; e.amp_coefs[COEF_CONST] = 1.f; e.amp_coefs[COEF_VEL] = 0; e.amp_coefs[COEF_EG0] = 1.0f; e.freq_coefs[COEF_CONST] = 4.0f; e.freq_coefs[COEF_NOTE] = 0; e.eg0_times[0] = 0; e.eg0_values[0] = 1.0f; e.eg0_times[1] = 10000; e.eg0_values[1] = 0.0f; amy_add_event(&e); e = amy_default_event(); e.patch_number = patch_number; e.eq_l = 0; e.eq_m = 0; e.eq_h = 0; e.chorus_level = 0; e.chorus_lfo_freq = 0.5f; e.chorus_depth = 0.5f; amy_add_event(&e); print_events_for_patch_number(patch_number); } int main(int argc, char ** argv) { int8_t playback_device_id = -1; int8_t capture_device_id = -1; int opt; while((opt = getopt(argc, argv, ":d:o:lh")) != -1) { switch(opt) { case 'd': playback_device_id = atoi(optarg); break; case 'c': capture_device_id = atoi(optarg); break; case 'l': amy_print_devices(); return 0; break; case 'h': printf("usage: amy-example\n"); printf("\t[-d playback sound device id, use -l to list, default, autodetect]\n"); printf("\t[-c capture sound device id, use -l to list, default, autodetect]\n"); printf("\t[-l list all sound devices and exit]\n"); printf("\t[-o filename.wav - write to filename.wav instead of playing live]\n"); printf("\t[-h show this help and exit]\n"); return 0; break; case ':': printf("option needs a value\n"); break; case '?': printf("unknown option: %c\n", optopt); break; } } amy_config_t amy_config = amy_default_config(); amy_config.amy_external_render_hook = render; amy_config.audio = AMY_AUDIO_IS_MINIAUDIO; amy_config.playback_device_id = playback_device_id; fprintf(stderr, "playback_device_id=%d\n", playback_device_id); amy_config.capture_device_id = capture_device_id; //amy_config.features.default_synths = 1; amy_config.features.default_synths = 0; for (int tries = 0; tries < 2; ++tries) { amy_start(amy_config); //example_synth_chord(0, /* patch */ 1); //example_fm(0); //example_voice_chord(0,0); //example_sustain_pedal(0, /* patch */ 256); //example_sequencer_drums(0); //example_patch_from_events(); //test_loop_env_filt(); test_algo(); // Now just spin for a while uint32_t start = amy_sysclock(); while(amy_sysclock() - start < 5000) { usleep(THREAD_USLEEP); } print_events_for_synth(/* synth */ 0, /* wirecode */ true); print_events_for_synth_2(/* synth */ 0, /* wirecode */ true); //show_debug(99); amy_stop(); // Make sure libminiaudio has time to clean up. sleep(2); } return 0; } #endif ================================================ FILE: src/amy-message.c ================================================ // amy-message.c // hacked from amy-example.c, this code shows using miniaudio and allows entry it AMY ASCII commands. #ifndef ARDUINO #include "amy.h" #include "libminiaudio-audio.h" void delay_ms(uint32_t ms) { uint32_t start = amy_sysclock(); while(amy_sysclock() - start < ms) usleep(THREAD_USLEEP); } int main(int argc, char ** argv) { int8_t playback_device_id = -1; int8_t capture_device_id = -1; int opt; while((opt = getopt(argc, argv, ":d:lh")) != -1) { switch(opt) { case 'd': playback_device_id = atoi(optarg); break; case 'c': capture_device_id = atoi(optarg); break; case 'l': amy_print_devices(); return 0; break; case 'h': printf("usage: amy-message\n"); printf("\t[-d sound device id, use -l to list, default, autodetect]\n"); printf("\t[-l list all sound devices and exit]\n"); printf("\t[-h show this help and exit]\n"); return 0; break; case ':': printf("option needs a value\n"); break; case '?': printf("unknown option: %c\n", optopt); break; } } amy_config_t amy_config = amy_default_config(); amy_config.audio = AMY_AUDIO_IS_MINIAUDIO; amy_config.features.audio_in = 1; // Run with audio in. amy_config.features.default_synths = 0; amy_config.playback_device_id = playback_device_id; amy_config.capture_device_id = capture_device_id; amy_start(amy_config); while (1) { char input[1024]; fprintf(stdout, "#;\n"); if (fgets(input, sizeof(input)-1, stdin) == NULL) break; if (input[0] == '?') { switch (input[1]) { case 'c': fprintf(stdout, "%" PRIu32 "\n", amy_sysclock()); break; case 's': fprintf(stdout, "%" PRIu32 "\n", amy_global.total_blocks); break; default: fprintf(stdout, "?\n"); break; } } else { amy_add_message(input); } } return 0; } #endif ================================================ FILE: src/amy-piano.c ================================================ // amy-example.c // a simple C example that plays audio using AMY out your speaker #ifndef ARDUINO #include "amy.h" #include "examples.h" #include "libminiaudio-audio.h" void delay_ms(uint32_t ms) { uint32_t start = amy_sysclock(); while(amy_sysclock() - start < ms) usleep(THREAD_USLEEP); } int main(int argc, char ** argv) { amy_config_t amy_config = amy_default_config(); amy_config.audio = AMY_AUDIO_IS_MINIAUDIO; //amy_config.playback_device_id = -1; //amy_config.capture_device_id = -1; amy_config.features.default_synths = 0; amy_start(amy_config); amy_add_message("S16384Z"); amy_add_message("t0V5Z"); amy_add_message("K1024uv0w10Zv21w9ZZ"); amy_add_message("K1024r0,1,2Z"); amy_add_message("v0w11a,,,0r0,1,2p20Z"); amy_add_message("v1w9A0,0,4,0,4,0,4,0,4,0,8,0,8,0,16,0,16,0,32,0,32,0,64,0,64,0,128,0,128,0,256,0,256,0,512,0,512,0,1024,0,1024,0,200,0T3r0,1,2Z"); amy_add_message("v2w9A0,0,4,0,4,0,4,0,4,0,8,0,8,0,16,0,16,0,32,0,32,0,64,0,64,0,128,0,128,0,256,0,256,0,512,0,512,0,1024,0,1024,0,200,0T3r0,1,2Z"); amy_add_message("v3w9A0,0,4,0,4,0,4,0,4,0,8,0,8,0,16,0,16,0,32,0,32,0,64,0,64,0,128,0,128,0,256,0,256,0,512,0,512,0,1024,0,1024,0,200,0T3r0,1,2Z"); amy_add_message("v4w9A0,0,4,0,4,0,4,0,4,0,8,0,8,0,16,0,16,0,32,0,32,0,64,0,64,0,128,0,128,0,256,0,256,0,512,0,512,0,1024,0,1024,0,200,0T3r0,1,2Z"); amy_add_message("v5w9A0,0,4,0,4,0,4,0,4,0,8,0,8,0,16,0,16,0,32,0,32,0,64,0,64,0,128,0,128,0,256,0,256,0,512,0,512,0,1024,0,1024,0,200,0T3r0,1,2Z"); amy_add_message("v6w9A0,0,4,0,4,0,4,0,4,0,8,0,8,0,16,0,16,0,32,0,32,0,64,0,64,0,128,0,128,0,256,0,256,0,512,0,512,0,1024,0,1024,0,200,0T3r0,1,2Z"); amy_add_message("v7w9A0,0,4,0,4,0,4,0,4,0,8,0,8,0,16,0,16,0,32,0,32,0,64,0,64,0,128,0,128,0,256,0,256,0,512,0,512,0,1024,0,1024,0,200,0T3r0,1,2Z"); amy_add_message("v8w9A0,0,4,0,4,0,4,0,4,0,8,0,8,0,16,0,16,0,32,0,32,0,64,0,64,0,128,0,128,0,256,0,256,0,512,0,512,0,1024,0,1024,0,200,0T3r0,1,2Z"); amy_add_message("v9w9A0,0,4,0,4,0,4,0,4,0,8,0,8,0,16,0,16,0,32,0,32,0,64,0,64,0,128,0,128,0,256,0,256,0,512,0,512,0,1024,0,1024,0,200,0T3r0,1,2Z"); amy_add_message("v10w9A0,0,4,0,4,0,4,0,4,0,8,0,8,0,16,0,16,0,32,0,32,0,64,0,64,0,128,0,128,0,256,0,256,0,512,0,512,0,1024,0,1024,0,200,0T3r0,1,2Z"); amy_add_message("v11w9A0,0,4,0,4,0,4,0,4,0,8,0,8,0,16,0,16,0,32,0,32,0,64,0,64,0,128,0,128,0,256,0,256,0,512,0,512,0,1024,0,1024,0,200,0T3r0,1,2Z"); amy_add_message("v12w9A0,0,4,0,4,0,4,0,4,0,8,0,8,0,16,0,16,0,32,0,32,0,64,0,64,0,128,0,128,0,256,0,256,0,512,0,512,0,1024,0,1024,0,200,0T3r0,1,2Z"); amy_add_message("v13w9A0,0,4,0,4,0,4,0,4,0,8,0,8,0,16,0,16,0,32,0,32,0,64,0,64,0,128,0,128,0,256,0,256,0,512,0,512,0,1024,0,1024,0,200,0T3r0,1,2Z"); amy_add_message("v14w9A0,0,4,0,4,0,4,0,4,0,8,0,8,0,16,0,16,0,32,0,32,0,64,0,64,0,128,0,128,0,256,0,256,0,512,0,512,0,1024,0,1024,0,200,0T3r0,1,2Z"); amy_add_message("v15w9A0,0,4,0,4,0,4,0,4,0,8,0,8,0,16,0,16,0,32,0,32,0,64,0,64,0,128,0,128,0,256,0,256,0,512,0,512,0,1024,0,1024,0,200,0T3r0,1,2Z"); amy_add_message("v16w9A0,0,4,0,4,0,4,0,4,0,8,0,8,0,16,0,16,0,32,0,32,0,64,0,64,0,128,0,128,0,256,0,256,0,512,0,512,0,1024,0,1024,0,200,0T3r0,1,2Z"); amy_add_message("v17w9A0,0,4,0,4,0,4,0,4,0,8,0,8,0,16,0,16,0,32,0,32,0,64,0,64,0,128,0,128,0,256,0,256,0,512,0,512,0,1024,0,1024,0,200,0T3r0,1,2Z"); amy_add_message("v18w9A0,0,4,0,4,0,4,0,4,0,8,0,8,0,16,0,16,0,32,0,32,0,64,0,64,0,128,0,128,0,256,0,256,0,512,0,512,0,1024,0,1024,0,200,0T3r0,1,2Z"); amy_add_message("v19w9A0,0,4,0,4,0,4,0,4,0,8,0,8,0,16,0,16,0,32,0,32,0,64,0,64,0,128,0,128,0,256,0,256,0,512,0,512,0,1024,0,1024,0,200,0T3r0,1,2Z"); amy_add_message("v20w9A0,0,4,0,4,0,4,0,4,0,8,0,8,0,16,0,16,0,32,0,32,0,64,0,64,0,128,0,128,0,256,0,256,0,512,0,512,0,1024,0,1024,0,200,0T3r0,1,2Z"); amy_add_message("v0w11r0,1,2p20Z"); amy_add_message("v1f262.07932089369143A,,,0.199,,0.354,,0.630,,0.890,,0.707,,0.707,,0.707,,0.707,,0.707,,0.630,,0.446,,0.354,,0.250,,0.157,,0.070,,0.027,,0.012,,0.007,,0.015,,0.012,200,0r0,1,2Z"); amy_add_message("v2f524.4614951503778A,,,0.031,,0.039,,0.049,,0.099,,0.177,,0.177,,0.281,,0.281,,0.281,,0.281,,0.250,,0.199,,0.111,,0.070,,0.055,,0.055,,0.044,,0.044,,0.017,,0.005,200,0r0,1,2Z"); amy_add_message("v3f787.6220624166158A,,,0.034,,0.019,,0.015,,0.021,,0.031,,0.055,,0.070,,0.078,,0.062,,0.062,,0.049,,0.039,,0.024,,0.019,,0.013,,0.007,,0.007,,0.001,,0.002,,0.000,200,0r0,1,2Z"); amy_add_message("v4f1051.3493189372969A,,,0.027,,0.031,,0.039,,0.062,,0.078,,0.078,,0.070,,0.070,,0.070,,0.062,,0.049,,0.039,,0.024,,0.024,,0.024,,0.012,,0.003,,0.006,,0.008,,0.001,200,0r0,1,2Z"); amy_add_message("v5f1315.467338798746A,,,0.039,,0.070,,0.088,,0.099,,0.111,,0.125,,0.111,,0.111,,0.099,,0.088,,0.078,,0.062,,0.034,,0.013,,0.003,,0.003,,0.007,,0.003,,0.002,,0.001,200,0r0,1,2Z"); amy_add_message("v6f1581.6262956462915A,,,0.006,,0.008,,0.010,,0.019,,0.013,,0.019,,0.021,,0.021,,0.021,,0.021,,0.017,,0.013,,0.007,,0.003,,0.001,,0.000,,0.001,,0.002,,0.000,,0.000,200,0r0,1,2Z"); amy_add_message("v7f1848.5688300775876A,,,0.003,,0.012,,0.012,,0.012,,0.017,,0.019,,0.019,,0.021,,0.021,,0.021,,0.019,,0.017,,0.009,,0.003,,0.003,,0.001,,0.003,,0.000,,0.000,,0.000,200,0r0,1,2Z"); amy_add_message("v8f2118.547431130394A,,,0.001,,0.001,,0.002,,0.001,,0.001,,0.001,,0.002,,0.002,,0.002,,0.002,,0.002,,0.002,,0.001,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,200,0r0,1,2Z"); amy_add_message("v9f2387.6236163079025A,,,0.001,,0.003,,0.003,,0.002,,0.002,,0.002,,0.001,,0.001,,0.000,,0.001,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,200,0r0,1,2Z"); amy_add_message("v10f2669.2025036818936A,,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,200,0r0,1,2Z"); amy_add_message("v11f2937.8120394192533A,,,0.000,,0.000,,0.000,,0.001,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,200,0r0,1,2Z"); amy_add_message("v12f3218.545272631402A,,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,200,0r0,1,2Z"); amy_add_message("v13f3501.7483969650048A,,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,200,0r0,1,2Z"); amy_add_message("v14f3787.9276154035115A,,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,200,0r0,1,2Z"); amy_add_message("v15f4073.89490182507A,,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,200,0r0,1,2Z"); amy_add_message("v16f4361.251218595678A,,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,200,0r0,1,2Z"); amy_add_message("v17f4660.7929645917975A,,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,200,0r0,1,2Z"); amy_add_message("v18f4943.645962597751A,,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,200,0r0,1,2Z"); amy_add_message("v19f5249.725889585327A,,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,200,0r0,1,2Z"); amy_add_message("v20f5549.0549732938325A,,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,200,0r0,1,2Z"); amy_add_message("v0w11t50r0p20Z"); amy_add_message("v1f294.34406205294465t50A,,,0.093,,0.099,,0.132,,0.177,,0.177,,0.167,,0.118,,0.167,,0.132,,0.132,,0.083,,0.070,,0.046,,0.031,,0.015,,0.003,,0.003,,0.003,,0.002,,0.003,200,0r0Z"); amy_add_message("v2f588.5181288580752t50A,,,0.006,,0.016,,0.009,,0.018,,0.006,,0.004,,0.015,,0.013,,0.014,,0.011,,0.012,,0.012,,0.012,,0.013,,0.014,,0.012,,0.006,,0.005,,0.002,,0.000,200,0r0Z"); amy_add_message("v3f884.842198784884t50A,,,0.004,,0.002,,0.003,,0.004,,0.006,,0.008,,0.008,,0.008,,0.008,,0.006,,0.005,,0.004,,0.002,,0.001,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,200,0r0Z"); amy_add_message("v4f1181.1226315895071t50A,,,0.002,,0.003,,0.004,,0.005,,0.005,,0.004,,0.005,,0.004,,0.004,,0.003,,0.002,,0.001,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,200,0r0Z"); amy_add_message("v5f1477.4153057160197t50A,,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,200,0r0Z"); amy_add_message("v6f1787.6637872384977t50A,,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,200,0r0Z"); amy_add_message("v7f2093.6090931138556t50A,,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,200,0r0Z"); amy_add_message("v8f2404.92532126672t50A,,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,200,0r0Z"); amy_add_message("v9f2756.9544448689694t50A,,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,200,0r0Z"); amy_add_message("v10f3015.1757467760062t50A,,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,200,0r0Z"); amy_add_message("v11f3333.972248358063t50A,,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,200,0r0Z"); amy_add_message("v12f3638.8739959179798t50A,,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,200,0r0Z"); amy_add_message("v13f3955.6334984986797t50A,,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,200,0r0Z"); amy_add_message("v14f4269.031364842567t50A,,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,200,0r0Z"); amy_add_message("v15f4593.972101679235t50A,,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,200,0r0Z"); amy_add_message("v16f4902.413229284128t50A,,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,200,0r0Z"); amy_add_message("v17f5228.542220951779t50A,,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,200,0r0Z"); amy_add_message("v18f5550.65783466558t50A,,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,200,0r0Z"); amy_add_message("v19f5894.3201757031875t50A,,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,200,0r0Z"); amy_add_message("v20f6192.729494493947t50A,,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,200,0r0Z"); amy_add_message("n60l1t50r0Z"); amy_add_message("l0t435r0Z"); amy_add_message("v0w11t450r0p20Z"); amy_add_message("v1f294.68429813771826t450A,,,0.236,,0.265,,0.334,,0.561,,0.500,,0.500,,0.354,,0.446,,0.397,,0.397,,0.250,,0.210,,0.149,,0.093,,0.041,,0.017,,0.010,,0.008,,0.001,,0.007,200,0r0Z"); amy_add_message("v2f588.3481826997248t450A,,,0.039,,0.074,,0.093,,0.111,,0.055,,0.062,,0.125,,0.125,,0.125,,0.118,,0.099,,0.074,,0.046,,0.039,,0.039,,0.034,,0.029,,0.027,,0.009,,0.006,200,0r0Z"); amy_add_message("v3f884.5866832364989t450A,,,0.041,,0.046,,0.044,,0.055,,0.074,,0.099,,0.099,,0.105,,0.088,,0.083,,0.070,,0.059,,0.037,,0.027,,0.014,,0.012,,0.009,,0.001,,0.003,,0.002,200,0r0Z"); amy_add_message("v4f1181.1226315895071t450A,,,0.037,,0.049,,0.055,,0.074,,0.070,,0.070,,0.070,,0.070,,0.066,,0.059,,0.041,,0.031,,0.020,,0.017,,0.018,,0.012,,0.003,,0.002,,0.005,,0.001,200,0r0Z"); amy_add_message("v5f1478.6959432469293t450A,,,0.024,,0.041,,0.044,,0.055,,0.052,,0.059,,0.052,,0.049,,0.044,,0.039,,0.031,,0.023,,0.010,,0.005,,0.003,,0.003,,0.003,,0.001,,0.001,,0.000,200,0r0Z"); amy_add_message("v6f1778.908240479117t450A,,,0.009,,0.011,,0.014,,0.018,,0.017,,0.020,,0.021,,0.021,,0.019,,0.018,,0.012,,0.008,,0.003,,0.000,,0.001,,0.000,,0.001,,0.001,,0.000,,0.000,200,0r0Z"); amy_add_message("v7f2080.34878834591t450A,,,0.003,,0.006,,0.008,,0.010,,0.010,,0.012,,0.012,,0.013,,0.013,,0.012,,0.010,,0.007,,0.004,,0.002,,0.001,,0.001,,0.000,,0.000,,0.000,,0.000,200,0r0Z"); amy_add_message("v8f2384.8669179827475t450A,,,0.001,,0.003,,0.003,,0.002,,0.002,,0.002,,0.002,,0.002,,0.002,,0.001,,0.001,,0.001,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,200,0r0Z"); amy_add_message("v9f2707.244952192445t450A,,,0.000,,0.001,,0.001,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,200,0r0Z"); amy_add_message("v10f3003.008924119927t450A,,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,200,0r0Z"); amy_add_message("v11f3319.5601545674176t450A,,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,200,0r0Z"); amy_add_message("v12f3635.7225173258425t450A,,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,200,0r0Z"); amy_add_message("v13f3964.7835189690277t450A,,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,200,0r0Z"); amy_add_message("v14f4285.0897718795295t450A,,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,200,0r0Z"); amy_add_message("v15f4617.91652761982t450A,,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,200,0r0Z"); amy_add_message("v16f4943.645962597751t450A,,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,200,0r0Z"); amy_add_message("v17f5261.869355194984t450A,,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,200,0r0Z"); amy_add_message("v18f5610.290319412823t450A,,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,200,0r0Z"); amy_add_message("v19f5962.808877105187t450A,,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,200,0r0Z"); amy_add_message("v20f6300.976499332925t450A,,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,200,0r0Z"); amy_add_message("n60l1t450r0Z"); amy_add_message("l0t835r0Z"); amy_add_message("v0w11t850r0p20Z"); amy_add_message("v1f294.8545636329288t850A,,,0.943,,1.121,,1.495,,2.370,,2.370,,2.238,,1.584,,2.112,,1.678,,1.777,,1.058,,0.999,,0.667,,0.446,,0.177,,0.052,,0.049,,0.037,,0.012,,0.027,200,0r0Z"); amy_add_message("v2f588.5181288580752t850A,,,0.223,,0.334,,0.530,,0.530,,0.397,,0.421,,0.707,,0.840,,0.749,,0.707,,0.561,,0.446,,0.236,,0.118,,0.132,,0.132,,0.111,,0.118,,0.031,,0.026,200,0r0Z"); amy_add_message("v3f884.842198784884t850A,,,0.265,,0.281,,0.281,,0.375,,0.375,,0.561,,0.500,,0.500,,0.472,,0.397,,0.315,,0.250,,0.167,,0.105,,0.044,,0.032,,0.044,,0.010,,0.013,,0.010,200,0r0Z"); amy_add_message("v4f1181.463802446632t850A,,,0.265,,0.334,,0.354,,0.500,,0.500,,0.500,,0.500,,0.530,,0.500,,0.397,,0.265,,0.187,,0.125,,0.066,,0.088,,0.070,,0.013,,0.017,,0.026,,0.010,200,0r0Z"); amy_add_message("v5f1479.5503182463226t850A,,,0.199,,0.334,,0.375,,0.472,,0.421,,0.472,,0.421,,0.397,,0.421,,0.354,,0.281,,0.223,,0.111,,0.046,,0.041,,0.044,,0.023,,0.008,,0.014,,0.003,200,0r0Z"); amy_add_message("v6f1778.908240479117t850A,,,0.111,,0.132,,0.167,,0.210,,0.187,,0.236,,0.265,,0.187,,0.167,,0.140,,0.099,,0.066,,0.021,,0.006,,0.011,,0.014,,0.005,,0.012,,0.001,,0.000,200,0r0Z"); amy_add_message("v7f2081.550792045791t850A,,,0.059,,0.118,,0.140,,0.132,,0.132,,0.140,,0.149,,0.149,,0.167,,0.140,,0.099,,0.062,,0.032,,0.039,,0.037,,0.014,,0.004,,0.006,,0.000,,0.000,200,0r0Z"); amy_add_message("v8f2384.8669179827475t850A,,,0.049,,0.132,,0.149,,0.099,,0.066,,0.078,,0.093,,0.083,,0.074,,0.074,,0.070,,0.059,,0.027,,0.015,,0.012,,0.003,,0.006,,0.001,,0.000,,0.000,200,0r0Z"); amy_add_message("v9f2690.875101205299t850A,,,0.024,,0.132,,0.105,,0.083,,0.093,,0.078,,0.066,,0.026,,0.041,,0.031,,0.021,,0.023,,0.007,,0.016,,0.005,,0.010,,0.001,,0.000,,0.000,,0.000,200,0r0Z"); amy_add_message("v10f3003.008924119927t850A,,,0.044,,0.046,,0.055,,0.052,,0.052,,0.070,,0.059,,0.059,,0.046,,0.046,,0.037,,0.026,,0.006,,0.006,,0.011,,0.001,,0.001,,0.000,,0.000,,0.000,200,0r0Z"); amy_add_message("v11f3315.7274625736522t850A,,,0.031,,0.044,,0.026,,0.029,,0.024,,0.021,,0.016,,0.012,,0.009,,0.012,,0.009,,0.005,,0.012,,0.006,,0.001,,0.001,,0.001,,0.000,,0.000,,0.000,200,0r0Z"); amy_add_message("v12f3631.524791140783t850A,,,0.012,,0.017,,0.031,,0.041,,0.052,,0.049,,0.046,,0.041,,0.031,,0.018,,0.011,,0.012,,0.007,,0.004,,0.002,,0.001,,0.000,,0.000,,0.000,,0.000,200,0r0Z"); amy_add_message("v13f3948.7848436027166t850A,,,0.029,,0.034,,0.031,,0.034,,0.018,,0.027,,0.024,,0.021,,0.018,,0.016,,0.007,,0.001,,0.004,,0.002,,0.001,,0.001,,0.000,,0.000,,0.000,,0.000,200,0r0Z"); amy_add_message("v14f4280.142300378328t850A,,,0.032,,0.059,,0.062,,0.039,,0.039,,0.039,,0.031,,0.027,,0.010,,0.014,,0.012,,0.005,,0.005,,0.005,,0.000,,0.002,,0.000,,0.000,,0.000,,0.000,200,0r0Z"); amy_add_message("v15f4609.921217475937t850A,,,0.027,,0.029,,0.027,,0.032,,0.029,,0.031,,0.027,,0.024,,0.016,,0.011,,0.006,,0.006,,0.005,,0.002,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,200,0r0Z"); amy_add_message("v16f4946.502349359061t850A,,,0.026,,0.024,,0.019,,0.016,,0.016,,0.014,,0.016,,0.012,,0.005,,0.006,,0.008,,0.005,,0.002,,0.001,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,200,0r0Z"); amy_add_message("v17f5281.662425954995t850A,,,0.007,,0.006,,0.008,,0.008,,0.010,,0.006,,0.007,,0.005,,0.003,,0.002,,0.001,,0.002,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,200,0r0Z"); amy_add_message("v18f5631.394011994379t850A,,,0.007,,0.012,,0.010,,0.008,,0.008,,0.009,,0.008,,0.006,,0.004,,0.003,,0.002,,0.001,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,200,0r0Z"); amy_add_message("v19f5981.782393936098t850A,,,0.006,,0.008,,0.009,,0.010,,0.012,,0.011,,0.010,,0.009,,0.006,,0.004,,0.001,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,200,0r0Z"); amy_add_message("v20f6337.47768486349t850A,,,0.007,,0.008,,0.008,,0.007,,0.006,,0.005,,0.004,,0.002,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,200,0r0Z"); amy_add_message("n60l1t850r0Z"); amy_add_message("l0t1485r0Z"); amy_add_message("v0w11t1500r1p20Z"); amy_add_message("v1f74.04864238799458t1500A,,,0.010,,0.022,,0.044,,0.064,,0.092,,0.073,,0.076,,0.017,,0.068,,0.061,,0.044,,0.042,,0.035,,0.026,,0.015,,0.008,,0.004,,0.003,,0.002,,0.002,200,0r1Z"); amy_add_message("v2f146.48082858990549t1500A,,,0.026,,0.047,,0.055,,0.089,,0.129,,0.130,,0.135,,0.113,,0.127,,0.126,,0.107,,0.095,,0.084,,0.062,,0.029,,0.023,,0.028,,0.016,,0.002,,0.003,200,0r1Z"); amy_add_message("v3f219.77772763935312t1500A,,,0.043,,0.077,,0.119,,0.157,,0.195,,0.206,,0.208,,0.218,,0.173,,0.131,,0.092,,0.070,,0.049,,0.033,,0.019,,0.008,,0.004,,0.003,,0.011,,0.010,200,0r1Z"); amy_add_message("v4f293.8259581897736t1500A,,,0.025,,0.064,,0.099,,0.122,,0.113,,0.082,,0.070,,0.109,,0.084,,0.078,,0.100,,0.093,,0.078,,0.070,,0.056,,0.042,,0.028,,0.019,,0.014,,0.009,200,0r1Z"); amy_add_message("v5f367.2477173747501t1500A,,,0.028,,0.047,,0.069,,0.084,,0.089,,0.079,,0.081,,0.096,,0.113,,0.120,,0.127,,0.119,,0.106,,0.089,,0.070,,0.049,,0.021,,0.013,,0.015,,0.011,200,0r1Z"); amy_add_message("v6f441.017791210556t1500A,,,0.023,,0.040,,0.045,,0.023,,0.059,,0.085,,0.132,,0.123,,0.104,,0.093,,0.083,,0.074,,0.061,,0.051,,0.028,,0.013,,0.024,,0.020,,0.016,,0.011,200,0r1Z"); amy_add_message("v7f515.4515605776315t1500A,,,0.014,,0.031,,0.047,,0.063,,0.109,,0.129,,0.137,,0.137,,0.136,,0.116,,0.109,,0.109,,0.091,,0.069,,0.030,,0.037,,0.049,,0.030,,0.007,,0.009,200,0r1Z"); amy_add_message("v8f589.3856181537751t1500A,,,0.009,,0.012,,0.013,,0.016,,0.028,,0.032,,0.026,,0.030,,0.023,,0.022,,0.016,,0.011,,0.008,,0.004,,0.008,,0.005,,0.001,,0.001,,0.001,,0.001,200,0r1Z"); amy_add_message("v9f664.2241559003637t1500A,,,0.014,,0.030,,0.046,,0.054,,0.048,,0.045,,0.046,,0.038,,0.026,,0.024,,0.024,,0.020,,0.015,,0.009,,0.001,,0.003,,0.007,,0.008,,0.003,,0.003,200,0r1Z"); amy_add_message("v10f738.8996902376488t1500A,,,0.021,,0.043,,0.056,,0.051,,0.014,,0.043,,0.045,,0.045,,0.040,,0.040,,0.040,,0.038,,0.030,,0.025,,0.016,,0.010,,0.006,,0.003,,0.002,,0.002,200,0r1Z"); amy_add_message("v11f813.5157009859971t1500A,,,0.018,,0.032,,0.040,,0.049,,0.064,,0.066,,0.063,,0.053,,0.039,,0.029,,0.026,,0.024,,0.012,,0.012,,0.017,,0.013,,0.004,,0.009,,0.002,,0.001,200,0r1Z"); amy_add_message("v12f888.6838007336429t1500A,,,0.016,,0.032,,0.039,,0.036,,0.024,,0.022,,0.017,,0.013,,0.013,,0.007,,0.003,,0.004,,0.001,,0.003,,0.004,,0.002,,0.000,,0.000,,0.000,,0.000,200,0r1Z"); amy_add_message("v13f963.562684336728t1500A,,,0.012,,0.023,,0.033,,0.044,,0.064,,0.066,,0.063,,0.067,,0.065,,0.069,,0.044,,0.057,,0.038,,0.024,,0.012,,0.026,,0.017,,0.008,,0.008,,0.002,200,0r1Z"); amy_add_message("v14f1040.4748517038904t1500A,,,0.012,,0.025,,0.044,,0.058,,0.073,,0.077,,0.081,,0.077,,0.073,,0.076,,0.064,,0.052,,0.032,,0.018,,0.020,,0.016,,0.019,,0.014,,0.007,,0.003,200,0r1Z"); amy_add_message("v15f1117.5069177375879t1500A,,,0.004,,0.004,,0.012,,0.020,,0.024,,0.025,,0.022,,0.022,,0.023,,0.021,,0.018,,0.016,,0.012,,0.008,,0.003,,0.002,,0.006,,0.006,,0.003,,0.002,200,0r1Z"); amy_add_message("v16f1193.156893756t1500A,,,0.005,,0.010,,0.013,,0.015,,0.018,,0.018,,0.016,,0.017,,0.017,,0.016,,0.013,,0.010,,0.002,,0.003,,0.007,,0.009,,0.003,,0.006,,0.002,,0.000,200,0r1Z"); amy_add_message("v17f1272.4204192002574t1500A,,,0.002,,0.003,,0.005,,0.006,,0.004,,0.003,,0.004,,0.004,,0.003,,0.004,,0.003,,0.002,,0.000,,0.000,,0.001,,0.001,,0.001,,0.000,,0.000,,0.000,200,0r1Z"); amy_add_message("v18f1349.640740512321t1500A,,,0.001,,0.001,,0.001,,0.000,,0.002,,0.002,,0.000,,0.002,,0.001,,0.001,,0.000,,0.000,,0.000,,0.000,,0.001,,0.000,,0.000,,0.000,,0.000,,0.000,200,0r1Z"); amy_add_message("v19f1430.5967761508439t1500A,,,0.001,,0.002,,0.003,,0.003,,0.002,,0.002,,0.002,,0.003,,0.002,,0.002,,0.003,,0.003,,0.002,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,200,0r1Z"); amy_add_message("v20f1506.3692225341174t1500A,,,0.004,,0.009,,0.012,,0.013,,0.014,,0.011,,0.011,,0.010,,0.009,,0.007,,0.003,,0.003,,0.005,,0.004,,0.005,,0.005,,0.002,,0.002,,0.001,,0.000,200,0r1Z"); amy_add_message("n60l1t1500r1Z"); amy_add_message("v0w11t2100r2p11Z"); amy_add_message("v1f1178.0565238532624t2100A,,,0.078,,1.777,,1.584,,2.370,,1.994,,1.883,,1.188,,0.999,,0.943,,0.707,,0.236,,0.265,,0.334,,0.281,,0.167,,0.111,,0.062,,0.034,,0.004,,0.004,200,0r2Z"); amy_add_message("v2f2371.131095283615t2100A,,,0.008,,0.223,,0.236,,0.236,,0.281,,0.265,,0.177,,0.118,,0.125,,0.049,,0.031,,0.034,,0.034,,0.026,,0.016,,0.008,,0.000,,0.000,,0.000,,0.000,200,0r2Z"); amy_add_message("v3f3574.2951284802925t2100A,,,0.001,,0.062,,0.021,,0.010,,0.032,,0.021,,0.024,,0.014,,0.006,,0.005,,0.003,,0.004,,0.002,,0.001,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,200,0r2Z"); amy_add_message("v4f4843.305799442923t2100A,,,0.000,,0.016,,0.008,,0.003,,0.006,,0.008,,0.011,,0.006,,0.004,,0.001,,0.003,,0.002,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,200,0r2Z"); amy_add_message("v5f6149.953187253529t2100A,,,0.000,,0.005,,0.005,,0.003,,0.003,,0.002,,0.003,,0.002,,0.000,,0.001,,0.001,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,200,0r2Z"); amy_add_message("v6f7525.698169256955t2100A,,,0.000,,0.001,,0.001,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,200,0r2Z"); amy_add_message("v7f8967.725358717675t2100A,,,0.000,,0.002,,0.001,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,200,0r2Z"); amy_add_message("v8f10457.084441903562t2100A,,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,200,0r2Z"); amy_add_message("v9f11987.775744026429t2100A,,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,200,0r2Z"); amy_add_message("v10f13612.172452050445t2100A,,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,200,0r2Z"); amy_add_message("v11f15363.220457587324t2100A,,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,,0.000,200,0r2Z"); amy_add_message("n60l1t2100r2Z"); amy_add_message("l0t3000r1Z"); amy_add_message("l0t3000r2Z"); show_debug(99); // Now just spin for 15s uint32_t start = amy_sysclock(); while(amy_sysclock() - start < 5000) { usleep(THREAD_USLEEP); } show_debug(99); return 0; } #endif ================================================ FILE: src/amy.c ================================================ // DAn Ellis and Brian Whitman // brian@variogr.am / dan.ellis@gmail.com #include "amy.h" #ifdef AMY_DEBUG const char* profile_tag_name(enum itags tag) { switch (tag) { case RENDER_OSC_WAVE: return "RENDER_OSC_WAVE"; case COMPUTE_BREAKPOINT_SCALE: return "COMPUTE_BREAKPOINT_SCALE"; case HOLD_AND_MODIFY: return "HOLD_AND_MODIFY"; case FILTER_PROCESS: return "FILTER_PROCESS"; case FILTER_PROCESS_STAGE0: return "FILTER_PROCESS_STAGE0"; case FILTER_PROCESS_STAGE1: return "FILTER_PROCESS_STAGE1"; case ADD_DELTA_TO_QUEUE: return "ADD_DELTA_TO_QUEUE"; case AMY_ADD_DELTA: return "AMY_ADD_DELTA"; case PLAY_DELTA: return "PLAY_DELTA"; case MIX_WITH_PAN: return "MIX_WITH_PAN"; case AMY_RENDER: return "AMY_RENDER"; case AMY_EXECUTE_DELTAS: return "AMY_EXECUTE_DELTAS"; case AMY_FILL_BUFFER: return "AMY_FILL_BUFFER"; case RENDER_LUT_FM: return "RENDER_LUT_FM"; case RENDER_LUT_FB: return "RENDER_LUT_FB"; case RENDER_LUT: return "RENDER_LUT"; case RENDER_LUT_CUB: return "RENDER_LUT_CUB"; case RENDER_LUT_FM_FB: return "RENDER_LUT_FM_FB"; case RENDER_LPF_LUT: return "RENDER_LPF_LUT"; case DSPS_BIQUAD_F32_ANSI_SPLIT_FB: return "DSPS_BIQUAD_F32_ANSI_SPLIT_FB"; case DSPS_BIQUAD_F32_ANSI_SPLIT_FB_TWICE: return "DSPS_BIQUAD_F32_ANSI_SPLIT_FB_TWICE"; case DSPS_BIQUAD_F32_ANSI_COMMUTED: return "DSPS_BIQUAD_F32_ANSI_COMMUTED"; case PARAMETRIC_EQ_PROCESS: return "PARAMETRIC_EQ_PROCESS"; case HPF_BUF: return "HPF_BUF"; case SCAN_MAX: return "SCAN_MAX"; case DSPS_BIQUAD_F32_ANSI: return "DSPS_BIQUAD_F32_ANSI"; case BLOCK_NORM: return "BLOCK_NORM"; case CALIBRATE: return "CALIBRATE"; case AMY_ESP_FILL_BUFFER: return "AMY_ESP_FILL_BUFFER"; case NO_TAG: return "NO_TAG"; } return "ERROR"; } struct profile profiles[NO_TAG]; uint64_t profile_start_us = 0; #ifdef ESP_PLATFORM #include "esp_timer.h" int64_t amy_get_us() { return esp_timer_get_time(); } #elif defined PICO_ON_DEVICE int64_t amy_get_us() { return to_us_since_boot(get_absolute_time()); } #elif defined(_WIN32) #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN #endif #include int64_t amy_get_us() { LARGE_INTEGER freq, count; QueryPerformanceFrequency(&freq); QueryPerformanceCounter(&count); return (int64_t)(count.QuadPart * 1000000LL / freq.QuadPart); } #else #include int64_t amy_get_us() { struct timeval tv; gettimeofday(&tv,NULL); return tv.tv_sec*(uint64_t)1000000+tv.tv_usec; } #endif void amy_profiles_init() { for(uint8_t i=0;i #include emscripten_lock_t amy_queue_lock = EMSCRIPTEN_LOCK_T_STATIC_INITIALIZER; void amy_grab_lock() { emscripten_lock_busyspin_wait_acquire(&amy_queue_lock, 100); } void amy_release_lock() { emscripten_lock_release(&amy_queue_lock); } void amy_init_lock() { } #elif defined _WIN32 CRITICAL_SECTION amy_queue_lock; void amy_grab_lock() { EnterCriticalSection(&amy_queue_lock); } void amy_release_lock() { LeaveCriticalSection(&amy_queue_lock); } void amy_init_lock() { InitializeCriticalSection(&amy_queue_lock); } #elif defined _POSIX_THREADS pthread_mutex_t amy_queue_lock; void amy_grab_lock() { pthread_mutex_lock(&amy_queue_lock); } void amy_release_lock() { pthread_mutex_unlock(&amy_queue_lock); } void amy_init_lock() { pthread_mutex_init(&amy_queue_lock, NULL); } #elif defined ESP_PLATFORM #include "freertos/FreeRTOS.h" #include "freertos/task.h" #include "freertos/semphr.h" SemaphoreHandle_t amy_queue_lock; void amy_grab_lock() { xSemaphoreTake(amy_queue_lock, portMAX_DELAY); } void amy_release_lock() { xSemaphoreGive( amy_queue_lock ); } void amy_init_lock() { amy_queue_lock = xSemaphoreCreateMutex(); } #else void amy_grab_lock() { } void amy_release_lock() { } void amy_init_lock() { } #endif // Global state struct state amy_global; // set of deltas for the fifo to be played struct delta * deltas; // state per osc as multi-channel synthesizer that the scheduler renders into struct synthinfo ** synth; // envelope-modified per-osc state struct mod_synthinfo ** msynth; // Two mixing blocks, one per core of rendering SAMPLE *fbl[AMY_MAX_CORES]; SAMPLE *per_osc_fb[AMY_MAX_CORES]; SAMPLE core_max[AMY_MAX_CORES]; // Public pointer to recently-emitted waveform block. output_sample_type * amy_out_block = NULL; // Audio input blocks. Filled by the audio implementation before rendering. // For live audio input from a codec, AUDIO_IN0 / 1 output_sample_type * amy_in_block; // For generated audio streams, AUDIO_EXT0 / 1 output_sample_type * amy_external_in_block; // output_block -- what gets sent to the dac -- -32768...32767 (int16 le) output_sample_type * output_block_0; output_sample_type * output_block_1; output_sample_type * output_block; #ifndef MALLOC_CAPS_DEFINED #define MALLOC_CAPS_DEFINED void * malloc_caps(uint32_t size, uint32_t flags) { void *result; #ifdef ESP_PLATFORM result = heap_caps_malloc(size, flags); #else // ignore flags result = malloc(size); #endif //if (size > 400000) abort(); //fprintf(stderr, "malloc(%ld) @0x%lx\n", size, result); return result; } #endif void dealloc_echo_delay_lines(void) { for (int c = AMY_NCHANS - 1; c >= 0; --c) { if (echo_delay_lines[c]) free_delay_line(echo_delay_lines[c]); echo_delay_lines[c] = NULL; } } bool alloc_echo_delay_lines(uint32_t max_delay_samples) { bool success = true; for (int c = 0; c < AMY_NCHANS; ++c) { delay_line_t *delay_line = new_delay_line(max_delay_samples, 0, amy_global.config.ram_caps_delay); if (delay_line) { echo_delay_lines[c] = delay_line; } else { success = false; break; } } if (!success) { fprintf(stderr, "unable to alloc echo of %d samples\n", (int)max_delay_samples); dealloc_echo_delay_lines(); return false; } return true; } uint32_t enclosing_power_of_2(uint32_t n) { uint32_t result = 1; while (result < n) result <<= 1; return result; } void config_echo(float level, float delay_ms, float max_delay_ms, float feedback, float filter_coef) { if (AMY_IS_UNSET(level)) level = S2F(amy_global.echo.level); if (AMY_IS_UNSET(delay_ms)) delay_ms = (amy_global.echo.delay_samples + 0.5f) / (AMY_SAMPLE_RATE / 1000.f); if (AMY_IS_UNSET(max_delay_ms)) max_delay_ms = (amy_global.echo.max_delay_samples + 0.5f) / (AMY_SAMPLE_RATE / 1000.f); if (AMY_IS_UNSET(feedback)) feedback = S2F(amy_global.echo.feedback); if (AMY_IS_UNSET(filter_coef)) filter_coef = S2F(amy_global.echo.filter_coef); uint32_t delay_samples = (uint32_t)(delay_ms / 1000.f * AMY_SAMPLE_RATE); //fprintf(stderr, "config_echo: delay_ms=%.3f max_delay_ms=%.3f delay_samples=%d echo.max_delay_samples=%d\n", delay_ms, max_delay_ms, delay_samples, echo.max_delay_samples); if (level > 0) { if (echo_delay_lines[0] == NULL) { // Delay line len must be power of 2. uint32_t max_delay_samples = enclosing_power_of_2((uint32_t)(max_delay_ms / 1000.f * AMY_SAMPLE_RATE)); if (!alloc_echo_delay_lines(max_delay_samples)) return; amy_global.echo.max_delay_samples = max_delay_samples; //fprintf(stderr, "config_echo: max_delay_samples=%d\n", max_delay_samples); } // Apply delay. We have to stay 1 sample less than delay line length for FIR EQ delay. if (delay_samples > amy_global.echo.max_delay_samples - 1) delay_samples = amy_global.echo.max_delay_samples - 1; for (int c = 0; c < AMY_NCHANS; ++c) { echo_delay_lines[c]->fixed_delay = delay_samples; } } amy_global.echo.level = F2S(level); amy_global.echo.delay_samples = delay_samples; // Filter is IIR [1, filter_coef] normalized for filter_coef > 0 (LPF), or FIR [1, filter_coef] normalized for filter_coef < 0 (HPF). if (filter_coef > 0.99) filter_coef = 0.99; // Avoid unstable filters. amy_global.echo.filter_coef = F2S(filter_coef); // FIR filter potentially has gain > 1 for high frequencies, so discount the loop feedback to stop things exploding. if (filter_coef < 0) feedback /= 1.f - filter_coef; amy_global.echo.feedback = F2S(feedback); //fprintf(stderr, "config_echo: delay_samples=%d level=%.3f feedback=%.3f filter_coef=%.3f fc0=%.3f\n", delay_samples, level, feedback, filter_coef, S2F(echo.filter_coef)); } void dealloc_chorus_delay_lines(void) { for(int c = AMY_NCHANS - 1; c >= 0; --c) { if (chorus_delay_lines[c]) free_delay_line(chorus_delay_lines[c]); chorus_delay_lines[c] = NULL; } free(delay_mod); delay_mod = NULL; } void alloc_chorus_delay_lines(void) { delay_mod = (SAMPLE *)malloc_caps(sizeof(SAMPLE) * AMY_BLOCK_SIZE, amy_global.config.ram_caps_delay); bool success = true; for(int c = 0; c < AMY_NCHANS; ++c) { delay_line_t *delay_line = new_delay_line(DELAY_LINE_LEN, DELAY_LINE_LEN / 2, amy_global.config.ram_caps_delay); if (delay_line) { chorus_delay_lines[c] = delay_line; } else { success = false; break; } } if (!success) { fprintf(stderr, "unable to alloc chorus of %d samples\n", (int)DELAY_LINE_LEN); dealloc_chorus_delay_lines(); } } void config_chorus(float level, uint16_t max_delay, float lfo_freq, float depth) { if (AMY_IS_UNSET(level)) level = S2F(amy_global.chorus.level); if (AMY_IS_UNSET(max_delay)) max_delay = amy_global.chorus.max_delay; if (AMY_IS_UNSET(lfo_freq)) lfo_freq = amy_global.chorus.lfo_freq; if (AMY_IS_UNSET(depth)) depth = amy_global.chorus.depth; //fprintf(stderr, "config_chorus: osc %d level %.3f max_del %d lfo_freq %.3f depth %.3f\n", // CHORUS_MOD_SOURCE, level, max_delay, lfo_freq, depth); if (level > 0) { ensure_osc_allocd(CHORUS_MOD_SOURCE, NULL); // only allocate delay lines if chorus is more than inaudible. if (chorus_delay_lines[0] == NULL) { alloc_chorus_delay_lines(); } // if we're turning on for the first time, start the oscillator. if (synth[CHORUS_MOD_SOURCE]->status == SYNTH_OFF) { //chorus.level == 0) { // Setup chorus oscillator. synth[CHORUS_MOD_SOURCE]->logfreq_coefs[COEF_CONST] = logfreq_of_freq(lfo_freq); synth[CHORUS_MOD_SOURCE]->logfreq_coefs[COEF_NOTE] = 0; // Turn off default. synth[CHORUS_MOD_SOURCE]->logfreq_coefs[COEF_BEND] = 0; // Turn off default. synth[CHORUS_MOD_SOURCE]->amp_coefs[COEF_CONST] = depth; synth[CHORUS_MOD_SOURCE]->amp_coefs[COEF_VEL] = 0; // Turn off default. synth[CHORUS_MOD_SOURCE]->amp_coefs[COEF_EG0] = 0; // Turn off default. synth[CHORUS_MOD_SOURCE]->wave = TRIANGLE; osc_note_on(CHORUS_MOD_SOURCE, freq_of_logfreq(synth[CHORUS_MOD_SOURCE]->logfreq_coefs[COEF_CONST])); // Stop us from doing this again. synth[CHORUS_MOD_SOURCE]->status = SYNTH_IS_MOD_SOURCE; } // apply max_delay. for (int chan=0; chanmax_delay = max_delay; chorus_delay_lines[chan]->fixed_delay = (int)max_delay / 2; } } amy_global.chorus.max_delay = max_delay; amy_global.chorus.level = F2S(level); amy_global.chorus.lfo_freq = lfo_freq; amy_global.chorus.depth = depth; } void config_reverb(float level, float liveness, float damping, float xover_hz) { if (AMY_IS_UNSET(level)) level = S2F(amy_global.reverb.level); if (AMY_IS_UNSET(liveness)) liveness = amy_global.reverb.liveness; if (AMY_IS_UNSET(damping)) damping = amy_global.reverb.damping; if (AMY_IS_UNSET(xover_hz)) xover_hz = amy_global.reverb.xover_hz; if (level > 0) { //printf("config_reverb: level %f liveness %f xover %f damping %f\n", // level, liveness, xover_hz, damping); if (amy_global.reverb.level == 0) { init_stereo_reverb(); // In case it's the first time } config_stereo_reverb(liveness, xover_hz, damping); } amy_global.reverb.level = F2S(level); amy_global.reverb.liveness = liveness; amy_global.reverb.damping = damping; amy_global.reverb.xover_hz = xover_hz; } int8_t check_init(amy_err_t (*fn)(), const char *name) { //fprintf(stderr,"starting %s: ", name); const amy_err_t ret = (*fn)(); if(ret != AMY_OK) { fprintf(stderr,"[error:%i]\n", ret); return -1; } //fprintf(stderr,"[ok]\n"); return 0; } #ifdef DEBUG_STACK static uint8_t *stack_baseline = NULL; uint8_t *get_sp() { uint8_t d[64]; return (uint8_t *)&d; //return NULL; } int peek_stack(const char *tag) { if (stack_baseline == NULL) { stack_baseline = get_sp(); } int stack_depth = (int)(stack_baseline - get_sp()); fprintf(stderr, "stack: '%s': %d\n", tag, stack_depth); return stack_depth; } #else // !DEBUG_STACK int peek_stack(const char *tag) { return 0; } #endif int8_t global_init(amy_config_t c) { peek_stack("init"); amy_global.config = c; amy_global.i2s_is_in_background = 0; amy_global.delta_queue = NULL; amy_global.delta_qsize = 0; amy_global.volume = 1.0f; amy_global.pitch_bend = 0; amy_global.latency_ms = 0; amy_global.tempo = 108.0; amy_global.eq[0] = F2S(1.0f); amy_global.eq[1] = F2S(1.0f); amy_global.eq[2] = F2S(1.0f); amy_global.hpf_state = 0; amy_global.transfer_flag = AMY_TRANSFER_TYPE_NONE; amy_global.transfer_storage = NULL; amy_global.transfer_length_bytes = 0; amy_global.transfer_stored_bytes = 0; amy_global.transfer_file_handle = 0; amy_global.transfer_filename[0] = '\0'; amy_global.debug_flag = 0; amy_global.sequencer_tick_count = 0; amy_global.next_amy_tick_us = 0; amy_global.us_per_tick = 0; amy_global.sequence_entry_ll_start = NULL; amy_global.reverb.level = F2S(REVERB_DEFAULT_LEVEL); amy_global.reverb.liveness= REVERB_DEFAULT_LIVENESS; amy_global.reverb.damping = REVERB_DEFAULT_DAMPING; amy_global.reverb.xover_hz = REVERB_DEFAULT_XOVER_HZ; amy_global.chorus.level = F2S(CHORUS_DEFAULT_LEVEL); amy_global.chorus.max_delay = CHORUS_DEFAULT_MAX_DELAY; amy_global.chorus.lfo_freq = CHORUS_DEFAULT_LFO_FREQ; amy_global.chorus.depth = CHORUS_DEFAULT_MOD_DEPTH; amy_global.echo.level = F2S(ECHO_DEFAULT_LEVEL); amy_global.echo.delay_samples = (uint32_t)(ECHO_DEFAULT_DELAY_MS / 1000.f * AMY_SAMPLE_RATE); amy_global.echo.max_delay_samples = 65536; amy_global.echo.feedback = F2S(ECHO_DEFAULT_FEEDBACK); amy_global.echo.filter_coef = ECHO_DEFAULT_FILTER_COEF; amy_init_lock(); return 0; } // Convert to and from the log-frequency scale. // A log-frequency scale is good for summing control inputs. float logfreq_of_freq(float freq) { // logfreq is defined as log_2(freq / 8.18 Hz) //if (freq==0) return ZERO_HZ_LOG_VAL; // Actually, special-case zero to mean middle C, for convenience. if (freq==0) return 0; // i.e. == logfreq_of_freq(ZERO_LOGFREQ_IN_HZ). return log2f(freq / ZERO_LOGFREQ_IN_HZ); } float freq_of_logfreq(float logfreq) { if (logfreq==ZERO_HZ_LOG_VAL) return 0; return ZERO_LOGFREQ_IN_HZ * exp2f(logfreq); } float freq_for_midi_note(float midi_note) { return 440.0f*powf(2.f, (midi_note - 69.0f) / 12.0f); } float logfreq_for_midi_note(float midi_note) { // TODO: Precompensate for EPS_FOR_LOG return (midi_note - ZERO_MIDI_NOTE) / 12.0f; } float midi_note_for_logfreq(float logfreq) { return 12.0f * logfreq + ZERO_MIDI_NOTE; } void add_delta_to_queue(struct delta *d, struct delta **queue) { AMY_PROFILE_START(ADD_DELTA_TO_QUEUE) amy_grab_lock(); // hack. Update the (decorative) global queue size if we're adding to the global queue. if (queue == &amy_global.delta_queue) amy_global.delta_qsize++; struct delta *new_d = delta_get(d); // insert it into the sorted list for fast playback struct delta **pptr = queue; while(*pptr && d->time >= (*pptr)->time) pptr = &(*pptr)->next; new_d->next = *pptr; *pptr = new_d; amy_release_lock(); AMY_PROFILE_STOP(ADD_DELTA_TO_QUEUE) } float map_60dB_to_01f(float lin) { // Map .001 to 0, 1 to 1 logarithmically. if (lin == 0) return -10.0f; float result = 1.0f + 0.10034333188799373f * log2f(lin); // 0.100343 = 1 / (3 * log2(10)) return result; } float map_01_to_60dBf(float log) { // Inverse of map_60dB_to_01f - Map (0, 1) to (.001, 1) exponentially if (log <= -10.0f) return 0; float result = exp2f((log - 1.0f) / 0.10034333188799373f); return result; } #define EVENT_TO_DELTA_F(FIELD, FLAG) if(AMY_IS_SET(e->FIELD)) { d.param=FLAG; d.data.f = e->FIELD; add_delta_to_queue(&d, queue); } #define EVENT_TO_DELTA_I(FIELD, FLAG) if(AMY_IS_SET(e->FIELD)) { d.param=FLAG; d.data.i = e->FIELD; add_delta_to_queue(&d, queue); } #define EVENT_TO_DELTA_WITH_BASEOSC(FIELD, FLAG) if(AMY_IS_SET(e->FIELD)) { d.param=FLAG; d.data.i = e->FIELD + base_osc; if (FLAG != RESET_OSC && d.data.i < (uint32_t)AMY_OSCS + 1) ensure_osc_allocd(d.data.i, NULL); add_delta_to_queue(&d, queue);} #define EVENT_TO_DELTA_LOG(FIELD, FLAG) if(AMY_IS_SET(e->FIELD)) { d.param=FLAG; d.data.f = log2f(e->FIELD); add_delta_to_queue(&d, queue);} #define EVENT_TO_DELTA_COEFS(FIELD, FLAG) \ for (int i = 0; i < NUM_COMBO_COEFS; ++i) \ EVENT_TO_DELTA_F(FIELD[i], FLAG + i) // Const freq coef is in Hz, rest are linear. #define EVENT_TO_DELTA_COEFS_COEF0_SPECIAL(FIELD, FLAG, COEF0_FN) \ for (int i = 0; i < NUM_COMBO_COEFS; ++i) { \ if (AMY_IS_SET(e->FIELD[i])) { \ d.param = FLAG + i; \ if (i == COEF_CONST) \ d.data.f = COEF0_FN(e->FIELD[i]); \ else \ d.data.f = e->FIELD[i]; \ add_delta_to_queue(&d, queue); \ } \ } #define EVENT_TO_DELTA_FREQ_COEFS(FIELD, FLAG) \ EVENT_TO_DELTA_COEFS_COEF0_SPECIAL(FIELD, FLAG, logfreq_of_freq) // Add a API facing event, convert into delta directly void amy_event_to_deltas_queue(amy_event *e, uint16_t base_osc, struct delta **queue) { AMY_PROFILE_START(AMY_ADD_DELTA) struct delta d; peek_stack("event_to_deltas"); // Synth defaults if not set, these are required for the delta struct d.time = e->time; d.osc = e->osc; if(AMY_IS_UNSET(e->osc)) { d.osc = 0; } if(AMY_IS_UNSET(e->time)) { d.time = 0; } // First, adapt the osc in this event with base_osc offsets for voices d.osc += base_osc; // Ensure this osc has its synthinfo allocated. ensure_osc_allocd(d.osc, NULL); // Voices / patches gets set up here // you must set both voices & load_patch together to load a patch if (AMY_IS_SET(e->voices[0]) || AMY_IS_SET(e->synth)) { if (AMY_IS_SET(e->patch_number) || AMY_IS_SET(e->num_voices) || AMY_IS_SET(e->oscs_per_voice)) { amy_execute_deltas(); patches_load_patch(e); } // Execute any other commands in this event. patches_event_has_voices(e, queue); goto end; } // Is this, in fact, a non-load_patch or store_patch event that has patch_number set? // If so, add the event to the stored patch queue, not the execution queue. if (AMY_IS_SET(e->patch_number)) { queue = queue_for_patch_number(e->patch_number); //fprintf(stderr, "event added to patch %d: osc %d wave %d...\n", e->patch_number, e->osc, e->wave); if (queue == NULL) { // The patch number was invalid (e.g., not in user range 1024+), so we got no queue, so ignore the event. fprintf(stderr, "event ignored\n"); goto end; } } // Everything else only added to queue if set EVENT_TO_DELTA_I(wave, WAVE) EVENT_TO_DELTA_I(preset, PRESET) EVENT_TO_DELTA_F(midi_note, MIDI_NOTE) EVENT_TO_DELTA_COEFS(amp_coefs, AMP) EVENT_TO_DELTA_FREQ_COEFS(freq_coefs, FREQ) EVENT_TO_DELTA_FREQ_COEFS(filter_freq_coefs, FILTER_FREQ) EVENT_TO_DELTA_COEFS(duty_coefs, DUTY) EVENT_TO_DELTA_COEFS(pan_coefs, PAN) EVENT_TO_DELTA_F(feedback, FEEDBACK) EVENT_TO_DELTA_F(trigger_phase, PHASE) EVENT_TO_DELTA_F(volume, VOLUME) EVENT_TO_DELTA_F(pitch_bend, PITCH_BEND) EVENT_TO_DELTA_I(latency_ms, LATENCY) EVENT_TO_DELTA_F(tempo, TEMPO) EVENT_TO_DELTA_LOG(ratio, RATIO) EVENT_TO_DELTA_F(resonance, RESONANCE) EVENT_TO_DELTA_I(portamento_ms, PORTAMENTO) EVENT_TO_DELTA_WITH_BASEOSC(chained_osc, CHAINED_OSC) EVENT_TO_DELTA_WITH_BASEOSC(reset_osc, RESET_OSC) EVENT_TO_DELTA_WITH_BASEOSC(mod_source, MOD_SOURCE) EVENT_TO_DELTA_I(note_source, NOTE_SOURCE) EVENT_TO_DELTA_I(filter_type, FILTER_TYPE) EVENT_TO_DELTA_I(algorithm, ALGORITHM) EVENT_TO_DELTA_F(eq_l, EQ_L) EVENT_TO_DELTA_F(eq_m, EQ_M) EVENT_TO_DELTA_F(eq_h, EQ_H) EVENT_TO_DELTA_F(echo_max_delay_ms, ECHO_MAX_DELAY_MS) // set MAX_DELAY first EVENT_TO_DELTA_F(echo_level, ECHO_LEVEL) EVENT_TO_DELTA_F(echo_delay_ms, ECHO_DELAY_MS) EVENT_TO_DELTA_F(echo_feedback, ECHO_FEEDBACK) EVENT_TO_DELTA_F(echo_filter_coef, ECHO_FILTER_COEF) EVENT_TO_DELTA_F(chorus_max_delay, CHORUS_MAX_DELAY) // set MAX_DELAY first EVENT_TO_DELTA_F(chorus_level, CHORUS_LEVEL) EVENT_TO_DELTA_F(chorus_lfo_freq, CHORUS_LFO_FREQ) EVENT_TO_DELTA_F(chorus_depth, CHORUS_DEPTH) EVENT_TO_DELTA_F(reverb_level, REVERB_LEVEL) EVENT_TO_DELTA_F(reverb_liveness, REVERB_LIVENESS) EVENT_TO_DELTA_F(reverb_damping, REVERB_DAMPING) EVENT_TO_DELTA_F(reverb_xover_hz, REVERB_XOVER_HZ) EVENT_TO_DELTA_I(eg_type[0], EG0_TYPE) EVENT_TO_DELTA_I(eg_type[1], EG1_TYPE) bool algo_ops_set = false; for (int i = 0; i < MAX_ALGO_OPS; ++i) { if(AMY_IS_SET(e->algo_source[i])) { algo_ops_set = true; break; } } if (algo_ops_set) { for(uint8_t i = 0; i < MAX_ALGO_OPS; i++) { d.param = ALGO_SOURCE_START + i; if (AMY_IS_SET(e->algo_source[i])) { d.data.i = e->algo_source[i] + base_osc; } else{ d.data.i = e->algo_source[i]; } add_delta_to_queue(&d, queue); } } uint32_t *bp_times_ms[MAX_BREAKPOINT_SETS] = {e->eg0_times, e->eg1_times}; float *bp_values[MAX_BREAKPOINT_SETS] = {e->eg0_values, e->eg1_values}; for (uint8_t i = 0; i < MAX_BREAKPOINT_SETS; i++) { // amy_parse_message sets bp_is_set for anything including an empty bp string. // Direct API calls can set typed breakpoint arrays without touching bp_is_set. bool bp_arrays_set = AMY_IS_SET(bp_times_ms[i][0]) || AMY_IS_SET(bp_values[i][0]); if(AMY_IS_SET(e->bp_is_set[i]) || bp_arrays_set) { int num_bps = 0; for (int j = 0; j < MAX_BREAKPOINTS; ++j) { if (AMY_IS_SET(bp_times_ms[i][j]) || AMY_IS_SET(bp_values[i][j])) { num_bps = j + 1; } } for(uint8_t j = 0; j < num_bps; j++) { if(AMY_IS_SET(bp_times_ms[i][j])) { d.param = BP_START + (j * 2) + (i * MAX_BREAKPOINTS * 2); d.data.i = ms_to_samples((uint32_t)bp_times_ms[i][j]); add_delta_to_queue(&d, queue); } if(AMY_IS_SET(bp_values[i][j])) { d.param = BP_START + (j * 2 + 1) + (i * MAX_BREAKPOINTS * 2); d.data.f = bp_values[i][j]; add_delta_to_queue(&d, queue); } } // Send an unset value as the last + 1 breakpoint time to indicate the end of the BP set. //if (num_bps < MAX_BREAKPOINTS) { // d.param = BP_START + (num_bps * 2) + (i * MAX_BREAKPOINTS * 2); // d.data.i = AMY_UNSET_VALUE(d.data.i); // add_delta_to_queue(&d, queue); //} // If we do this, then you can't set one value in the middle of a BP set without // setting all the rest, because at this point we can't distinguish trailing // commas from a truncated list. // If we *don't* do this, you can't truncate an existing BP list, because the // trailing part you don't overwrite never gets removed. However, it seems like // we don't have any use-cases where someone wants to curtail a BP list - but // we *do* have use-cases for wanting to change the sustain level without // re-specifying the release, so *don't* do this wins for now. } } // add this last -- this is a trigger, that if sent alongside osc setup parameters, you want to run after those EVENT_TO_DELTA_F(velocity, VELOCITY) if (AMY_IS_SET(e->patch_number)) { // If this was an event with a patch number, maybe we increased the number of oscs for this patch, update it. update_num_oscs_for_patch_number(e->patch_number); } end: AMY_PROFILE_STOP(AMY_ADD_DELTA); } void reset_modosc(struct mod_synthinfo *pmsynth) { if (pmsynth != NULL) { pmsynth->last_duty = 0.5f; pmsynth->amp = 0; // This matters for wave=PARTIAL, where msynth amp is effectively 1-frame delayed. pmsynth->last_amp = 0; pmsynth->logfreq = 0; pmsynth->filter_logfreq = 0; AMY_UNSET(pmsynth->last_filter_logfreq); pmsynth->duty = 0.5f; pmsynth->pan = 0.5f; pmsynth->feedback = F2S(0); //.996; todo ks feedback is v different from fm feedback pmsynth->resonance = 0.7f; } } void reset_osc_params(struct synthinfo *psynth) { // osc params are the things set through the amy_event API // Event-derived config psynth->wave = SINE; AMY_UNSET(psynth->preset); AMY_UNSET(psynth->note_source); AMY_UNSET(psynth->midi_note); psynth->velocity = 0; for (int j = 0; j < NUM_COMBO_COEFS; ++j) psynth->amp_coefs[j] = 0; psynth->amp_coefs[COEF_CONST] = 1.0f; // Default overall gain psynth->amp_coefs[COEF_VEL] = 1.0f; // Default sensitive to vel psynth->amp_coefs[COEF_EG0] = 1.0f; // Default gate by eg0 for (int j = 0; j < NUM_COMBO_COEFS; ++j) psynth->logfreq_coefs[j] = 0; psynth->logfreq_coefs[COEF_NOTE] = 1.0; psynth->logfreq_coefs[COEF_BEND] = 1.0; for (int j = 0; j < NUM_COMBO_COEFS; ++j) psynth->filter_logfreq_coefs[j] = 0; for (int j = 0; j < NUM_COMBO_COEFS; ++j) psynth->duty_coefs[j] = 0; psynth->duty_coefs[COEF_CONST] = 0.5f; for (int j = 0; j < NUM_COMBO_COEFS; ++j) psynth->pan_coefs[j] = 0; psynth->pan_coefs[COEF_CONST] = 0.5f; psynth->feedback = F2S(0); //.996; todo ks feedback is v different from fm feedback AMY_UNSET(psynth->trigger_phase); AMY_UNSET(psynth->logratio); psynth->portamento_alpha = 0; psynth->resonance = 0.7f; psynth->filter_type = FILTER_NONE; AMY_UNSET(psynth->chained_osc); AMY_UNSET(psynth->mod_source); psynth->algorithm = 0; for(uint8_t j=0;jalgo_source[j]); for(uint8_t j=0;jmax_num_breakpoints[j];k++) { AMY_UNSET(psynth->breakpoint_times[j][k]); AMY_UNSET(psynth->breakpoint_values[j][k]); } psynth->eg_type[j] = ENVELOPE_NORMAL; // ENVELOPE_LINEAR; // no_amp_001: was ENVELOPE_NORMAL } // Default EG0 setup to be key gate psynth->breakpoint_times[0][0] = 0; psynth->breakpoint_values[0][0] = 1.0f; psynth->breakpoint_times[0][1] = 0; psynth->breakpoint_values[0][1] = 0; // Not part of event-driven config, but still stable through the evolution of a note. psynth->terminate_on_silence = 1; // This is what we do, *except* for PCM. psynth->lut = NULL; } void reset_osc_state(struct synthinfo *psynth) { // osc state are the internal values that keep track of the osc evolution in time. psynth->status = SYNTH_OFF; psynth->phase = F2P(0); psynth->step = 0; psynth->substep = 0; AMY_UNSET(psynth->render_clock); AMY_UNSET(psynth->note_on_clock); psynth->note_off_clock = 0; // Used to check that last event seen by note was off. AMY_UNSET(psynth->zero_amp_clock); AMY_UNSET(psynth->mod_value_clock); psynth->mod_value = F2S(0); for(uint8_t j=0;jlast_scale[j] = 0; } psynth->last_two[0] = 0; psynth->last_two[1] = 0; for(int j = 0; j < 2 * FILT_NUM_DELAYS; ++j) psynth->filter_delay[j] = 0; psynth->last_filt_norm_bits = 0; } void reset_osc_by_pointer(struct synthinfo *psynth, struct mod_synthinfo *pmsynth) { // set synth state to defaults given a pointer // Current state reset_osc_params(psynth); reset_osc_state(psynth); reset_modosc(pmsynth); } void reset_osc(uint16_t i ) { // set all the synth state to defaults if (synth[i] == NULL) return; reset_osc_by_pointer(synth[i], msynth[i]); synth[i]->osc = i; // self-reference to make updating oscs easier } void amy_reset_oscs() { // Put the noise generator into a known state. srand48(517730); // We reset oscs by freeing them. // Include chorus osc (osc=AMY_OSCS) for(uint16_t i=0;imax_num_breakpoints[i] = max_num_breakpoints[i]; synth[osc]->breakpoint_times[i] = (uint32_t *)breakpoint_area; breakpoint_area += max_num_breakpoints[i] * sizeof(uint32_t); // must be a multiple of 4 bytes synth[osc]->breakpoint_values[i] = (float *)breakpoint_area; breakpoint_area += sizeof(float) * max_num_breakpoints[i]; } reset_osc(osc); //fprintf(stderr, "alloc_osc %d (0x%lx) num_breakpoints %d,%d\n", osc, (long)synth[osc], synth[osc]->max_num_breakpoints[0], synth[osc]->max_num_breakpoints[1]); } void free_osc(int osc) { if (synth[osc] != NULL) { //fprintf(stderr, "free_osc %d (0x%lx)\n", osc, (long)synth[osc]); free(synth[osc]); } synth[osc] = NULL; msynth[osc] = NULL; } void ensure_osc_allocd(int osc, uint8_t *max_num_breakpoints) { if (synth[osc] == NULL) alloc_osc(osc, max_num_breakpoints); else if (max_num_breakpoints) { bool realloc_needed = false; uint8_t new_max_num_breakpoints[MAX_BREAKPOINT_SETS]; for (int i = 0; i < MAX_BREAKPOINT_SETS; ++i) { new_max_num_breakpoints[i] = DEFAULT_NUM_BREAKPOINTS; if (synth[osc]->max_num_breakpoints[i] < max_num_breakpoints[i]) { realloc_needed = true; // Increase num_breakpoints in blocks of DEFAULT_NUM_BREAKPOINTS. new_max_num_breakpoints[i] = MIN(MAX_BREAKPOINTS, DEFAULT_NUM_BREAKPOINTS * ((max_num_breakpoints[i] + DEFAULT_NUM_BREAKPOINTS - 1) / DEFAULT_NUM_BREAKPOINTS)); } } if (realloc_needed) { //fprintf(stderr, "realloc for osc %d (breakpoints %d, %d -> %d, %d (wave=%d)\n", osc, synth[osc]->max_num_breakpoints[0], synth[osc]->max_num_breakpoints[1], max_num_breakpoints[0], max_num_breakpoints[1], synth[osc]->wave); // Save the current values in the structure. struct synthinfo saved_values = *synth[osc]; int32_t breakpoint_times[MAX_BREAKPOINT_SETS][MAX_BREAKPOINTS]; float breakpoint_values[MAX_BREAKPOINT_SETS][MAX_BREAKPOINTS]; int num_old_breakpoints[MAX_BREAKPOINT_SETS]; for (int i = 0; i < MAX_BREAKPOINT_SETS; ++i) { num_old_breakpoints[i] = synth[osc]->max_num_breakpoints[i]; for (int j = 0; j < num_old_breakpoints[i]; ++j) { breakpoint_times[i][j] = synth[osc]->breakpoint_times[i][j]; breakpoint_values[i][j] = synth[osc]->breakpoint_values[i][j]; } } // Reallocate the structure. free_osc(osc); alloc_osc(osc, new_max_num_breakpoints); // Save the pointers to the newly-alloc'd vectors. uint32_t *saved_breakpoint_times[MAX_BREAKPOINT_SETS]; float *saved_breakpoint_values[MAX_BREAKPOINT_SETS]; int saved_max_num_breakpoints[MAX_BREAKPOINT_SETS]; for (int i = 0; i < MAX_BREAKPOINT_SETS; ++i) { saved_breakpoint_times[i] = synth[osc]->breakpoint_times[i]; saved_breakpoint_values[i]= synth[osc]->breakpoint_values[i]; saved_max_num_breakpoints[i] = synth[osc]->max_num_breakpoints[i]; } // Copy all the values from the previous alloc. (*synth[osc]) = saved_values; // Restore the new breakpoint vectors. for (int i = 0; i < MAX_BREAKPOINT_SETS; ++i) { synth[osc]->breakpoint_times[i] = saved_breakpoint_times[i]; synth[osc]->breakpoint_values[i] = saved_breakpoint_values[i]; synth[osc]->max_num_breakpoints[i] = saved_max_num_breakpoints[i]; } // And, to be conservative, the breakpoint values themselves. for (int i = 0; i < MAX_BREAKPOINT_SETS; ++i) { for (int j = 0; j < num_old_breakpoints[i]; ++j) { synth[osc]->breakpoint_times[i][j] = breakpoint_times[i][j]; synth[osc]->breakpoint_values[i][j] = breakpoint_values[i][j]; } // And clear the ones beyond for (int j = num_old_breakpoints[i]; j < synth[osc]->max_num_breakpoints[i]; ++j) { AMY_UNSET(synth[osc]->breakpoint_times[i][j]); AMY_UNSET(synth[osc]->breakpoint_values[i][j]); } } } } } // the synth object keeps held state, whereas deltas are only deltas/changes int8_t oscs_init() { if(amy_global.config.ks_oscs>0) ks_init(); filters_init(); algo_init(); patches_init(amy_global.config.max_memory_patches); instruments_init(amy_global.config.max_synths); sequencer_init(amy_global.config.max_sequencer_tags); if(pcm_samples) pcm_init(); if(AMY_HAS_CUSTOM) custom_init(); // synth and msynth are now pointers to arrays of pointers to dynamically-allocated synth structures. synth = (struct synthinfo **) malloc_caps(sizeof(struct synthinfo *) * (AMY_OSCS+1), amy_global.config.ram_caps_synth); bzero(synth, sizeof(struct synthinfo *) * (AMY_OSCS+1)); msynth = (struct mod_synthinfo **) malloc_caps(sizeof(struct mod_synthinfo *) * (AMY_OSCS+1), amy_global.config.ram_caps_synth); output_block_0 = (output_sample_type *) malloc_caps(sizeof(output_sample_type) * AMY_BLOCK_SIZE * AMY_NCHANS, amy_global.config.ram_caps_block); output_block_1 = (output_sample_type *) malloc_caps(sizeof(output_sample_type) * AMY_BLOCK_SIZE * AMY_NCHANS, amy_global.config.ram_caps_block); output_block = output_block_0; amy_in_block = (output_sample_type*)malloc_caps(sizeof(output_sample_type)*AMY_BLOCK_SIZE*AMY_NCHANS, amy_global.config.ram_caps_block); amy_external_in_block = (output_sample_type*)malloc_caps(sizeof(output_sample_type)*AMY_BLOCK_SIZE*AMY_NCHANS, amy_global.config.ram_caps_block); // set all oscillators to their default values amy_reset_oscs(); // reset the deltas queue deltas_pool_init(); amy_deltas_reset(); midi_mappings_init(); // clear out both as local mode won't use fbl[1] for(uint16_t core=0;corestatus, synth[i]->wave, synth[i]->mod_source, synth[i]->velocity, synth[i]->logratio, synth[i]->feedback, synth[i]->filter_type, synth[i]->resonance, synth[i]->portamento_alpha, P2F(synth[i]->step), synth[i]->chained_osc, synth[i]->algorithm, synth[i]->algo_source[0], synth[i]->algo_source[1], synth[i]->algo_source[2], synth[i]->algo_source[3], synth[i]->algo_source[4], synth[i]->algo_source[5] ); fprintf(stderr, " amp_coefs: %.3f %.3f %.3f %.3f %.3f %.3f %.3f\n", synth[i]->amp_coefs[0], synth[i]->amp_coefs[1], synth[i]->amp_coefs[2], synth[i]->amp_coefs[3], synth[i]->amp_coefs[4], synth[i]->amp_coefs[5], synth[i]->amp_coefs[6]); fprintf(stderr, " lfr_coefs: %.3f %.3f %.3f %.3f %.3f %.3f %.3f\n", synth[i]->logfreq_coefs[0], synth[i]->logfreq_coefs[1], synth[i]->logfreq_coefs[2], synth[i]->logfreq_coefs[3], synth[i]->logfreq_coefs[4], synth[i]->logfreq_coefs[5], synth[i]->logfreq_coefs[6]); fprintf(stderr, " flf_coefs: %.3f %.3f %.3f %.3f %.3f %.3f %.3f\n", synth[i]->filter_logfreq_coefs[0], synth[i]->filter_logfreq_coefs[1], synth[i]->filter_logfreq_coefs[2], synth[i]->filter_logfreq_coefs[3], synth[i]->filter_logfreq_coefs[4], synth[i]->filter_logfreq_coefs[5], synth[i]->filter_logfreq_coefs[6]); fprintf(stderr, " dut_coefs: %.3f %.3f %.3f %.3f %.3f %.3f %.3f\n", synth[i]->duty_coefs[0], synth[i]->duty_coefs[1], synth[i]->duty_coefs[2], synth[i]->duty_coefs[3], synth[i]->duty_coefs[4], synth[i]->duty_coefs[5], synth[i]->duty_coefs[6]); fprintf(stderr, " pan_coefs: %.3f %.3f %.3f %.3f %.3f %.3f %.3f\n", synth[i]->pan_coefs[0], synth[i]->pan_coefs[1], synth[i]->pan_coefs[2], synth[i]->pan_coefs[3], synth[i]->pan_coefs[4], synth[i]->pan_coefs[5], synth[i]->pan_coefs[6]); if(show_eg) { for(uint8_t j=0;jeg_type[j]); for(uint8_t k=0;kmax_num_breakpoints[j];k++) { fprintf(stderr,"%" PRIi32 ": %f ", synth[i]->breakpoint_times[j][k], synth[i]->breakpoint_values[j][k]); } fprintf(stderr,"\n"); } fprintf(stderr,"mod osc %d: amp: %f, logfreq %f duty %f filter_logfreq %f resonance %f fb/bw %f pan %f \n", i, msynth[i]->amp, msynth[i]->logfreq, msynth[i]->duty, msynth[i]->filter_logfreq, msynth[i]->resonance, msynth[i]->feedback, msynth[i]->pan); } } // types: 0 - show profile if set // 1 - show profile, queue // 2 - show profile, queue, osc data void show_debug(uint8_t type) { amy_global.debug_flag = type; amy_profiles_print(); #ifdef ALLES esp_show_debug(); #endif if(type>0) { struct delta * ptr = amy_global.delta_queue; uint16_t q = amy_global.delta_qsize; if(q > 25) q = 25; for(uint16_t i=0;itime, ptr->osc, ptr->param, ptr->data.f, ptr->data.i); ptr = ptr->next; } fprintf(stderr, "deltas_queue len %" PRIi32 ", free len %" PRIi32 "\n", delta_list_len(amy_global.delta_queue), delta_num_free()); sequencer_debug(); } if(type>1) { // print out all the osc data //printf("global: filter %f resonance %f volume %f bend %f status %d\n", amy_global.filter_freq, amy_global.resonance, amy_global.volume, amy_global.pitch_bend, amy_global.status); fprintf(stderr,"global: volume %f bend %f eq: %f %f %f \n", amy_global.volume, amy_global.pitch_bend, S2F(amy_global.eq[0]), S2F(amy_global.eq[1]), S2F(amy_global.eq[2])); for(uint16_t i=0;i<10 /* AMY_OSCS */;i++) { print_osc_debug(i, (type > 3) /* show_eg */); } if (type > 4) { patches_debug(); } if (type > 5) { cc_mapping_debug(); } if (type > 6) { for (int synth = 0; synth < 32 /* MAX_INSTRUMENTS */; ++synth) { if (instrument_number_exists(synth, NULL)) { fprintf(stderr, "synth %d:\n", synth); void * state = NULL; amy_event event = amy_default_event(); char s[MAX_MESSAGE_LEN]; bool include_fx = true; do { state = yield_synth_events(synth, &event, include_fx, state); sprint_event(&event, s, MAX_MESSAGE_LEN, false); fprintf(stderr, "%s\n", s); } while(state != NULL); } } } fprintf(stderr, "\n"); } } void oscs_deinit() { midi_mappings_deinit(); dealloc_chorus_delay_lines(); dealloc_echo_delay_lines(); for(int core = 0; core < AMY_CORES; ++core) { free(fbl[core]); free(per_osc_fb[core]); } deltas_pool_free(); // Include chorus osc (osc=AMY_OSCS) for (int i = 0; i < AMY_OSCS + 1; ++i) free_osc(i); free(amy_external_in_block); free(amy_in_block); free(output_block_1); free(output_block_0); free(msynth); free(synth); if(AMY_HAS_CUSTOM) custom_deinit(); if(pcm_samples) pcm_deinit(); sequencer_deinit(); instruments_deinit(); patches_deinit(); algo_deinit(); filters_deinit(); if(amy_global.config.ks_oscs > 0) ks_deinit(); } void osc_note_on(uint16_t osc, float initial_freq) { //fprintf(stderr,"Note on: osc %d wav %d note %.3f vel %.3f\n", // osc, synth[osc]->wave, // synth[osc]->midi_note, synth[osc]->velocity); // take care of fm & ks first -- no special treatment for bp/mod switch (synth[osc]->wave) { case KS: if(amy_global.config.ks_oscs) ks_note_on(osc); break; case SINE: sine_note_on(osc, initial_freq); break; case SAW_DOWN: saw_down_note_on(osc, initial_freq); break; case SAW_UP: saw_up_note_on(osc, initial_freq); break; case TRIANGLE: triangle_note_on(osc, initial_freq); break; case PULSE: pulse_note_on(osc, initial_freq); break; case PCM: case PCM_LEFT: case PCM_RIGHT: pcm_note_on(osc); break; case ALGO: algo_note_on(osc, initial_freq); break; case NOISE: noise_note_on(osc); break; case AUDIO_IN0: audio_in_note_on(osc, 0); break; case AUDIO_IN1: audio_in_note_on(osc, 1); break; case AUDIO_EXT0: external_audio_in_note_on(osc, 0); break; case AUDIO_EXT1: external_audio_in_note_on(osc, 1); break; case AMY_MIDI: amy_send_midi_note_on(osc); break; case BYO_PARTIALS: if(AMY_HAS_PARTIALS) partials_note_on(osc); break; case INTERP_PARTIALS: if(AMY_HAS_PARTIALS) interp_partials_note_on(osc); break; #ifdef AMY_WAVETABLE case WAVETABLE: wavetable_note_on(osc, initial_freq); break; #endif case SILENT: /* nothing */ break; case CUSTOM: if(AMY_HAS_CUSTOM) custom_note_on(osc, initial_freq); break; default: break; } } int chained_osc_would_cause_loop(uint16_t osc, uint16_t chained_osc) { // Check to see if chaining this osc would cause a loop. uint16_t next_osc = chained_osc; do { ensure_osc_allocd(chained_osc, NULL); if (next_osc == osc) { fprintf(stderr, "chaining osc %d to osc %d would cause loop.\n", chained_osc, osc); return true; } next_osc = synth[next_osc]->chained_osc; } while(AMY_IS_SET(next_osc)); return false; } float portamento_ms_to_alpha(uint16_t portamento_ms) { return 1.0f - 1.0f / (1 + portamento_ms * AMY_SAMPLE_RATE / 1000 / AMY_BLOCK_SIZE); } uint16_t alpha_to_portamento_ms(float alpha) { return (int)roundf(1000.0f * AMY_BLOCK_SIZE / AMY_SAMPLE_RATE / (1.0f - alpha)) - 1; } #define DELTA_TO_SYNTH_I(FLAG, FIELD) if (d->param == FLAG) synth[d->osc]->FIELD = d->data.i; #define DELTA_TO_SYNTH_F(FLAG, FIELD) if (d->param == FLAG) synth[d->osc]->FIELD = d->data.f; #define DELTA_TO_COEFS(FLAG, FIELD) \ if (PARAM_IS_COMBO_COEF(d->param, FLAG)) \ synth[d->osc]->FIELD[d->param - FLAG] = d->data.f; // play an delta, now -- tell the audio loop to start making noise void play_delta(struct delta *d) { AMY_PROFILE_START(PLAY_DELTA) //fprintf(stderr,"play_delta: time %d osc %d param %d val 0x%x, qsize %d\n", amy_global.total_blocks, d->osc, d->param, d->data.i, amy_global.delta_qsize); //uint8_t trig=0; // todo: delta-only side effect, remove if (d->param != RESET_OSC) ensure_osc_allocd(d->osc, NULL); if(d->param == MIDI_NOTE) { // Midi note and Velocity are propagated to chained_osc. uint16_t osc = d->osc; while(AMY_IS_SET(osc)) { synth[osc]->midi_note = d->data.f; osc = synth[osc]->chained_osc; } } if(d->param == WAVE) { synth[d->osc]->wave = d->data.i; // todo: delta-only side effect, remove // we do this because we need to set up LUTs for FM oscs. it's a TODO to make this cleaner if(synth[d->osc]->wave == SINE) { sine_note_on(d->osc, freq_of_logfreq(synth[d->osc]->logfreq_coefs[COEF_CONST])); } } DELTA_TO_SYNTH_F(FEEDBACK, feedback) DELTA_TO_SYNTH_F(RATIO, logratio) DELTA_TO_SYNTH_F(RESONANCE, resonance) DELTA_TO_SYNTH_I(FILTER_TYPE, filter_type) DELTA_TO_SYNTH_I(NOTE_SOURCE, note_source) DELTA_TO_SYNTH_I(EG0_TYPE, eg_type[0]) DELTA_TO_SYNTH_I(EG1_TYPE, eg_type[1]) if (d->param == PRESET) { synth[d->osc]->preset = (uint16_t)d->data.i; } if (d->param == PORTAMENTO) synth[d->osc]->portamento_alpha = portamento_ms_to_alpha(d->data.i); if (d->param == PHASE) synth[d->osc]->trigger_phase = d->data.f; DELTA_TO_COEFS(AMP, amp_coefs) DELTA_TO_COEFS(FREQ, logfreq_coefs) DELTA_TO_COEFS(FILTER_FREQ, filter_logfreq_coefs) DELTA_TO_COEFS(DUTY, duty_coefs) DELTA_TO_COEFS(PAN, pan_coefs) // todo, i really should clean this up if (PARAM_IS_BP_COEF(d->param)) { uint8_t pos = d->param - BP_START; uint8_t bp_set = 0; while(pos >= (MAX_BREAKPOINTS * 2)) { ++bp_set; pos -= (MAX_BREAKPOINTS * 2); } int bp_index = pos / 2; if (bp_index + 1 > synth[d->osc]->max_num_breakpoints[bp_set]) { uint8_t max_num_breakpoints[MAX_BREAKPOINT_SETS]; for (int i = 0; i < MAX_BREAKPOINT_SETS; ++i) max_num_breakpoints[i] = synth[d->osc]->max_num_breakpoints[i]; max_num_breakpoints[bp_set] = bp_index + 1; // realloc rounds up in blocks of DEFAULT_NUM_BREAKPOINTS (8). ensure_osc_allocd(d->osc, max_num_breakpoints); } if(pos % 2 == 0) { synth[d->osc]->breakpoint_times[bp_set][pos / 2] = d->data.i; } else { synth[d->osc]->breakpoint_values[bp_set][(pos-1) / 2] = d->data.f; } } if (PARAM_IS_COMBO_COEF(d->param, AMP) || PARAM_IS_BP_COEF(d->param)) { // Changes to Amp/filter/EGs can potentially make a silence-suspended note come back. // Revive the note if it hasn't seen a note_off since the last note_on. if (synth[d->osc]->status == SYNTH_INAUDIBLE && AMY_IS_UNSET(synth[d->osc]->note_off_clock)) synth[d->osc]->status = SYNTH_AUDIBLE; // In theory, changing the amp coefs away from their defaults could turn on an osc. But we won't // But it won't get started without a note-on. Unfortunately, we can't call hold_and_modify first. // (if the osc has a modulator, we call the modulator in hold_and_modify, but the LUT hasn't been // set up yet, so we get an access error.) //else if (synth[d->osc]->status == SYNTH_OFF) { // hold_and_modify(d->osc); // if (msynth[d->osc]->amp > 0) { // osc_note_on(d->osc, freq_of_logfreq(msynth[d->osc]->logfreq)); // } //} } if(d->param == CHAINED_OSC) { int chained_osc = d->data.i; if (chained_osc >=0 && chained_osc < AMY_OSCS && !chained_osc_would_cause_loop(d->osc, chained_osc)) synth[d->osc]->chained_osc = chained_osc; else AMY_UNSET(synth[d->osc]->chained_osc); } if(d->param == RESET_OSC) { // Remember that RESET_AMY, RESET_TIMEBASE and RESET_EVENTS happens immediately in the parse, so we don't deal with it here. if(d->data.i & RESET_ALL_OSCS) { amy_reset_oscs(); } if(d->data.i & RESET_SEQUENCER) { sequencer_reset(); } if(d->data.i & RESET_ALL_NOTES) { all_notes_off(); } if(d->data.i & RESET_PATCH) { // If we got here, it's a full reset of patches. patches_reset(); } if(d->data.i < (uint32_t)AMY_OSCS + 1) { reset_osc(d->data.i); } } if(d->param == MOD_SOURCE) { uint16_t mod_osc = d->data.i; synth[d->osc]->mod_source = mod_osc; // NOTE: These are delta-only side effects. A purist would strive to remove them. // When an oscillator is named as a modulator, we change its state. ensure_osc_allocd(mod_osc, NULL); synth[mod_osc]->status = SYNTH_IS_MOD_SOURCE; // No longer record this osc in note_off state. AMY_UNSET(synth[mod_osc]->note_off_clock); // Remove default amplitude dependence on velocity when an oscillator is made a modulator. synth[mod_osc]->amp_coefs[COEF_VEL] = 0; } if(d->param == ALGORITHM) { synth[d->osc]->algorithm = d->data.i; // This is a DX7-style control osc; ensure eg_types are set // but only when ALGO is specified, so user can override later if desired-> synth[d->osc]->eg_type[0] = ENVELOPE_DX7; synth[d->osc]->eg_type[1] = ENVELOPE_TRUE_EXPONENTIAL; } if(d->param >= ALGO_SOURCE_START && d->param < ALGO_SOURCE_END) { uint16_t which_source = d->param - ALGO_SOURCE_START; synth[d->osc]->algo_source[which_source] = d->data.i; if(AMY_IS_SET(synth[d->osc]->algo_source[which_source])) { int osc = synth[d->osc]->algo_source[which_source]; ensure_osc_allocd(osc, NULL); synth[osc]->status = SYNTH_IS_ALGO_SOURCE; // Configure the amp envelope appropriately, just once when named as an algo_source. synth[osc]->eg_type[0] = ENVELOPE_DX7; } } // for global changes, just make the change, no need to update the per-osc synth if(d->param == VOLUME) amy_global.volume = d->data.f; if(d->param == PITCH_BEND) amy_global.pitch_bend = d->data.f; if(d->param == LATENCY) amy_global.latency_ms = d->data.i; if(d->param == TEMPO) { amy_global.tempo = d->data.f; sequencer_recompute(); } if(d->param == EQ_L) amy_global.eq[0] = F2S(powf(10, d->data.f / 20.0)); if(d->param == EQ_M) amy_global.eq[1] = F2S(powf(10, d->data.f / 20.0)); if(d->param == EQ_H) amy_global.eq[2] = F2S(powf(10, d->data.f / 20.0)); if(d->param == ECHO_LEVEL) config_echo(d->data.f, AMY_UNSET_FLOAT, AMY_UNSET_FLOAT, AMY_UNSET_FLOAT, AMY_UNSET_FLOAT); if(d->param == ECHO_DELAY_MS) config_echo(AMY_UNSET_FLOAT, d->data.f, AMY_UNSET_FLOAT, AMY_UNSET_FLOAT, AMY_UNSET_FLOAT); if(d->param == ECHO_MAX_DELAY_MS) config_echo(AMY_UNSET_FLOAT, AMY_UNSET_FLOAT, d->data.f, AMY_UNSET_FLOAT, AMY_UNSET_FLOAT); if(d->param == ECHO_FEEDBACK) config_echo(AMY_UNSET_FLOAT, AMY_UNSET_FLOAT, AMY_UNSET_FLOAT, d->data.f, AMY_UNSET_FLOAT); if(d->param == ECHO_FILTER_COEF) config_echo(AMY_UNSET_FLOAT, AMY_UNSET_FLOAT, AMY_UNSET_FLOAT, AMY_UNSET_FLOAT, d->data.f); if(d->param == CHORUS_LEVEL) config_chorus(d->data.f, UINT16_MAX, AMY_UNSET_FLOAT, AMY_UNSET_FLOAT); if(d->param == CHORUS_MAX_DELAY) config_chorus(AMY_UNSET_FLOAT, AMY_IS_UNSET(d->data.f)?UINT16_MAX : (uint16_t)roundf(d->data.f), AMY_UNSET_FLOAT, AMY_UNSET_FLOAT); if(d->param == CHORUS_LFO_FREQ) config_chorus(AMY_UNSET_FLOAT, UINT16_MAX, d->data.f, AMY_UNSET_FLOAT); if(d->param == CHORUS_DEPTH) config_chorus(AMY_UNSET_FLOAT, UINT16_MAX, AMY_UNSET_FLOAT, d->data.f); if(d->param == REVERB_LEVEL) config_reverb(d->data.f, AMY_UNSET_FLOAT, AMY_UNSET_FLOAT, AMY_UNSET_FLOAT); if(d->param == REVERB_LIVENESS) config_reverb(AMY_UNSET_FLOAT, d->data.f, AMY_UNSET_FLOAT, AMY_UNSET_FLOAT); if(d->param == REVERB_DAMPING) config_reverb(AMY_UNSET_FLOAT, AMY_UNSET_FLOAT, d->data.f, AMY_UNSET_FLOAT); if(d->param == REVERB_XOVER_HZ) config_reverb(AMY_UNSET_FLOAT, AMY_UNSET_FLOAT, AMY_UNSET_FLOAT, d->data.f); // triggers / envelopes // the only way a sound is made is if velocity (note on) is >0. // Ignore velocity deltas if we've already received one this frame. This may be due to a loop in chained_oscs. if(d->param == VELOCITY) { //fprintf(stderr, "play_delta velocity %.1f osc %d note %.1f time %d\n", d->data.f, d->osc, synth[d->osc]->midi_note, d->time); if (d->data.f > 0) { // new note on (even if something is already playing on this osc) // Calculation common to all chained oscs. float note_logfreq = 0; if (AMY_IS_SET(synth[d->osc]->midi_note)) { // synth[osc]->logfreq_coefs[COEF_CONST] = 0; note_logfreq = logfreq_for_midi_note(synth[d->osc]->midi_note); } // Loop through chained oscs uint16_t osc = d->osc; while(AMY_IS_SET(osc)) { synth[osc]->velocity = d->data.f; // was map_60dB_to_01f if (AMY_IS_SET(synth[osc]->chained_osc) || synth[osc]->amp_coefs[COEF_VEL] == 0 || synth[osc]->amp_coefs[COEF_VEL] > AMP_THRESH) { synth[osc]->status = SYNTH_AUDIBLE; // ** no_amp_001 // an osc came in with a note on. // start the bp clock synth[osc]->note_on_clock = amy_global.total_blocks*AMY_BLOCK_SIZE; //esp_timer_get_time() / 1000; // if there was a filter active for this voice, reset it //if(synth[osc]->filter_type != FILTER_NONE) reset_filter(osc); // We no longer reset the phase here; instead, we reset phase when an oscillator falls silent. // But if a trigger_phase is set, use that. if (AMY_IS_SET(synth[osc]->trigger_phase)) synth[osc]->phase = F2P(synth[osc]->trigger_phase); // restart the waveforms // Guess at the initial frequency depending only on const & note. Envelopes not "developed" yet. float initial_logfreq = synth[osc]->logfreq_coefs[COEF_CONST] + synth[osc]->logfreq_coefs[COEF_NOTE] * note_logfreq; // If we're coming out of note-off, set the freq history for portamento. //if (AMY_IS_SET(synth[osc]->note_off_clock)) // msynth[osc]->last_logfreq = initial_logfreq; // Now we've tested that, we can reset note-off clocks. AMY_UNSET(synth[osc]->note_off_clock); // Most recent note event is not note-off. //AMY_UNSET(synth[osc]->zero_amp_clock); // Actually, start with an expectation that the voice will be zero amp, give it one frame to prove otherwise. #define MIN_ZERO_AMP_TIME_SAMPS (10 * AMY_BLOCK_SIZE) synth[osc]->zero_amp_clock = amy_global.total_blocks*AMY_BLOCK_SIZE - MIN_ZERO_AMP_TIME_SAMPS + 1 * AMY_BLOCK_SIZE; float initial_freq = freq_of_logfreq(initial_logfreq); osc_note_on(osc, initial_freq); // trigger the mod source, if we have one uint16_t mod_osc = synth[osc]->mod_source; if(AMY_IS_SET(mod_osc)) { if (AMY_IS_SET(synth[mod_osc]->trigger_phase)) synth[mod_osc]->phase = F2P(synth[mod_osc]->trigger_phase); synth[mod_osc]->note_on_clock = amy_global.total_blocks*AMY_BLOCK_SIZE; // Need a note_on_clock to have envelope work correctly. switch(synth[mod_osc]->wave) { case SINE: sine_mod_trigger(mod_osc); break; case SAW_DOWN: saw_up_mod_trigger(mod_osc); break; case SAW_UP: saw_down_mod_trigger(mod_osc); break; case TRIANGLE: triangle_mod_trigger(mod_osc); break; case PULSE: pulse_mod_trigger(mod_osc); break; case PCM: case PCM_LEFT: case PCM_RIGHT: pcm_mod_trigger(mod_osc); break; case CUSTOM: custom_mod_trigger(mod_osc); break; } } } osc = synth[osc]->chained_osc; } } else if(synth[d->osc]->velocity > 0 && d->data.f == 0) { // new note off uint16_t osc = d->osc; while(AMY_IS_SET(osc)) { // DON'T clear velocity, we still need to reference it in decay. //synth[osc]->velocity = 0; switch(synth[osc]->wave) { case KS: ks_note_off(osc); break; case ALGO: algo_note_off(osc); break; case PCM: case PCM_LEFT: case PCM_RIGHT: pcm_note_off(osc); break; case AMY_MIDI: amy_send_midi_note_off(osc); break; case CUSTOM: custom_note_off(osc); break; case BYO_PARTIALS: case INTERP_PARTIALS: AMY_UNSET(synth[osc]->note_on_clock); synth[osc]->note_off_clock = amy_global.total_blocks*AMY_BLOCK_SIZE; if(synth[osc]->wave==INTERP_PARTIALS) interp_partials_note_off(osc); else partials_note_off(osc); break; default: // ** no_amp_001 // osc note off, start release // For now, note_off_clock signals note off BUT ONLY IF IT'S NOT KS, ALGO, PARTIAL, PCM, or CUSTOM. // I'm not crazy about this, but if we apply it in those cases, the default bp0 amp envelope immediately zeros-out // those waves on note-off. AMY_UNSET(synth[osc]->note_on_clock); if (AMY_IS_UNSET(synth[osc]->note_off_clock)) { // Only set the note_off_clock (start of release) if we don't already have one. synth[osc]->note_off_clock = amy_global.total_blocks*AMY_BLOCK_SIZE; } } osc = synth[osc]->chained_osc; } } } AMY_PROFILE_STOP(PLAY_DELTA) } float combine_controls(float *controls, float *coefs) { float result = 0; for (int i = 0; i < NUM_COMBO_COEFS; ++i) result += coefs[i] * controls[i]; return result; } float amp_combine_controls(float *controls, float *coefs) { // Linear combination of amp coefs is then mapped so that 0 -> 0.001 and 1 -> 1 exponentially. float result = 0; for (int i = 0; i < NUM_COMBO_COEFS; ++i) { float coef = coefs[i]; float val = controls[i]; if (i == COEF_CONST) {val = coef; coef = 1.0f;} // coef[CONST] is always 1.0f, so swap them. We're going to map the val. if (i != COEF_MOD) { val = map_60dB_to_01f(MAX(0, val)) - 1.0; // const, vel, eg0, eg1 get log-compressed. // make 0 mean "no amp" and 1 mean "regular (full) amp". } result += coef * val; } result = 3.0f * (result); //if (log_amp < -2.0f) { // // Double the slope below 0.01. // log_amp = -2.0f + 2.0f * (log_amp + 2.0f); //} result = powf(10.0f, result); if (result <= AMP_THRESH_PLUS) result = 0; return result; } // apply an mod & bp, if any, to the osc #ifdef __EMSCRIPTEN__ #include "emscripten/webaudio.h" extern float amy_web_cv_1; extern float amy_web_cv_2; #endif void hold_and_modify(uint16_t osc) { AMY_PROFILE_START(HOLD_AND_MODIFY) float ctrl_inputs[NUM_COMBO_COEFS]; ctrl_inputs[COEF_CONST] = 1.0f; ctrl_inputs[COEF_NOTE] = (AMY_IS_SET(synth[osc]->midi_note)) ? logfreq_for_midi_note(synth[osc]->midi_note) : 0; ctrl_inputs[COEF_VEL] = synth[osc]->velocity; ctrl_inputs[COEF_EG0] = S2F(compute_breakpoint_scale(osc, 0, 0)); ctrl_inputs[COEF_EG1] = S2F(compute_breakpoint_scale(osc, 1, 0)); ctrl_inputs[COEF_MOD] = S2F(compute_mod_scale(osc)); ctrl_inputs[COEF_BEND] = amy_global.pitch_bend; if(amy_global.config.amy_external_coef_hook != NULL) { ctrl_inputs[COEF_EXT0] = amy_global.config.amy_external_coef_hook(0); ctrl_inputs[COEF_EXT1] = amy_global.config.amy_external_coef_hook(1); } else { #ifdef __EMSCRIPTEN__ ctrl_inputs[COEF_EXT0] = amy_web_cv_1; ctrl_inputs[COEF_EXT1] = amy_web_cv_2; #else ctrl_inputs[COEF_EXT0] = 0; ctrl_inputs[COEF_EXT1] = 0; #endif } msynth[osc]->last_pan = msynth[osc]->pan; // copy all the modifier variables float logfreq = combine_controls(ctrl_inputs, synth[osc]->logfreq_coefs); if (synth[osc]->portamento_alpha == 0) { msynth[osc]->logfreq = logfreq; } else { msynth[osc]->logfreq = logfreq + synth[osc]->portamento_alpha * (msynth[osc]->last_logfreq - logfreq); } msynth[osc]->last_logfreq = msynth[osc]->logfreq; float filter_logfreq = combine_controls(ctrl_inputs, synth[osc]->filter_logfreq_coefs); if (filter_logfreq < MIN_FILTER_LOGFREQ) filter_logfreq = MIN_FILTER_LOGFREQ; if (AMY_IS_SET(msynth[osc]->last_filter_logfreq)) { #define MAX_DELTA_FILTER_LOGFREQ_DOWN 2.0 float last_logfreq = msynth[osc]->last_filter_logfreq; if (filter_logfreq < last_logfreq - MAX_DELTA_FILTER_LOGFREQ_DOWN) { // Filter cutoff downward slew-rate limit. // See https://github.com/shorepine/amy/issues/126 filter_logfreq = last_logfreq - MAX_DELTA_FILTER_LOGFREQ_DOWN; } } msynth[osc]->last_filter_logfreq = filter_logfreq; msynth[osc]->filter_logfreq = filter_logfreq; msynth[osc]->duty = combine_controls(ctrl_inputs, synth[osc]->duty_coefs); msynth[osc]->pan = combine_controls(ctrl_inputs, synth[osc]->pan_coefs); // amp is a special case - coeffs apply in log domain. float new_amp = amp_combine_controls(ctrl_inputs, synth[osc]->amp_coefs); // Also, we advance one frame by writing both last_amp and amp (=next amp) // *Except* for partials, where we allow one frame of ramp-on. if (synth[osc]->wave == PARTIAL) { msynth[osc]->last_amp = msynth[osc]->amp; msynth[osc]->amp = new_amp; } else { // Prevent hard-off on transition to release by updating last_amp only for nonzero new_last_amp. if (new_amp > msynth[osc]->last_amp) { // was > 0 msynth[osc]->last_amp = new_amp; } // Advance the envelopes to the beginning of the next frame. ctrl_inputs[COEF_EG0] = S2F(compute_breakpoint_scale(osc, 0, AMY_BLOCK_SIZE)); ctrl_inputs[COEF_EG1] = S2F(compute_breakpoint_scale(osc, 1, AMY_BLOCK_SIZE)); msynth[osc]->amp = amp_combine_controls(ctrl_inputs, synth[osc]->amp_coefs); } // synth[osc]->feedback is copied to msynth in pcm_note_on, then used to track note-off for looping PCM. // For PCM, don't re-copy it every loop, or we'd lose track of that flag. (This means you can't change feedback mid-playback for PCM). // we also check for custom, for tulips' memorypcm if (synth[osc]->wave != PCM && synth[osc]->wave != CUSTOM) msynth[osc]->feedback = synth[osc]->feedback; msynth[osc]->resonance = synth[osc]->resonance; if (osc == 999) { fprintf(stderr, "h&m: time %f osc %d note %f vel %f eg0 %f eg1 %f ampc %.3f %.3f %.3f %.3f %.3f %.3f lfqc %.3f %.3f %.3f %.3f %.3f %.3f amp %f logfreq %f\n", amy_global.total_blocks*AMY_BLOCK_SIZE / (float)AMY_SAMPLE_RATE, osc, ctrl_inputs[COEF_NOTE], ctrl_inputs[COEF_VEL], ctrl_inputs[COEF_EG0], ctrl_inputs[COEF_EG1], synth[osc]->amp_coefs[0], synth[osc]->amp_coefs[1], synth[osc]->amp_coefs[2], synth[osc]->amp_coefs[3], synth[osc]->amp_coefs[4], synth[osc]->amp_coefs[5], synth[osc]->logfreq_coefs[0], synth[osc]->logfreq_coefs[1], synth[osc]->logfreq_coefs[2], synth[osc]->logfreq_coefs[3], synth[osc]->logfreq_coefs[4], synth[osc]->logfreq_coefs[5], msynth[osc]->amp, msynth[osc]->logfreq); } AMY_PROFILE_STOP(HOLD_AND_MODIFY) } static inline float lgain_of_pan(float pan) { if(pan > 1.f) pan = 1.f; if(pan < 0) pan = 0; return dsps_sqrtf_f32_ansi(1.f - pan); } static inline float rgain_of_pan(float pan) { if(pan > 1.f) pan = 1.f; if(pan < 0) pan = 0; return dsps_sqrtf_f32_ansi(pan); } void mix_with_pan(SAMPLE *stereo_dest, SAMPLE *mono_src, float pan_start, float pan_end) { AMY_PROFILE_START(MIX_WITH_PAN) /* copy a block_size of mono samples into an interleaved stereo buffer, applying pan */ if(AMY_NCHANS==1) { // actually dest is mono, pan is ignored. for(uint16_t i=0;irender_clock); SAMPLE max_val = 0; // Only render if osc has not already been rendered this time step e.g. by chained_osc. if (synth[osc]->render_clock != amy_global.total_blocks*AMY_BLOCK_SIZE) { synth[osc]->render_clock = amy_global.total_blocks*AMY_BLOCK_SIZE; // fill buf with next block_size of samples for specified osc. hold_and_modify(osc); // apply bp / mod if(!(msynth[osc]->amp == 0 && msynth[osc]->last_amp == 0)) { if(synth[osc]->wave == NOISE) max_val = render_noise(buf, osc); if(synth[osc]->wave == SAW_DOWN) max_val = render_saw_down(buf, osc); if(synth[osc]->wave == SAW_UP) max_val = render_saw_up(buf, osc); if(synth[osc]->wave == PULSE) max_val = render_pulse(buf, osc); if(synth[osc]->wave == TRIANGLE) max_val = render_triangle(buf, osc); if(synth[osc]->wave == SINE) max_val = render_sine(buf, osc); #ifdef AMY_WAVETABLE if(synth[osc]->wave == WAVETABLE) max_val = render_wavetable(buf, osc); #endif if(synth[osc]->wave == AUDIO_IN0) max_val = render_audio_in(buf, osc, 0); if(synth[osc]->wave == AUDIO_IN1) max_val = render_audio_in(buf, osc, 1); if(synth[osc]->wave == AUDIO_EXT0) max_val = render_external_audio_in(buf, osc, 0); if(synth[osc]->wave == AUDIO_EXT1) max_val = render_external_audio_in(buf, osc, 1); if(synth[osc]->wave == AMY_MIDI) max_val = 1; if(synth[osc]->wave == KS) { if(amy_global.config.ks_oscs) { max_val = render_ks(buf, osc); } } if(pcm_samples) if (AMY_WAVE_IS_PCM(synth[osc]->wave)) max_val = render_pcm(buf, osc); if(synth[osc]->wave == ALGO) max_val = render_algo(buf, osc, core); if(AMY_HAS_PARTIALS) { if(synth[osc]->wave == BYO_PARTIALS || synth[osc]->wave == INTERP_PARTIALS) max_val = render_partials(buf, osc); } } if(AMY_HAS_CUSTOM) { if(synth[osc]->wave == CUSTOM) max_val = render_custom(buf, osc); } if (synth[osc]->wave != SILENT) { // apply filter to osc if set if (synth[osc]->filter_type != FILTER_NONE) { max_val = filter_process(per_osc_fb[core], osc, max_val); // Maybe clear filter state here if we've finshed this osc. if (synth[osc]->status != SYNTH_AUDIBLE) { reset_filter(osc); // (f) } } } if(AMY_IS_SET(synth[osc]->chained_osc)) { // Stack oscillators - render next osc into same buffer. uint16_t chained_osc = synth[osc]->chained_osc; if (synth[chained_osc]->status == SYNTH_AUDIBLE) { // We have to recheck this since we're bypassing the skip in amy_render. SAMPLE new_max_val = render_osc_wave(chained_osc, core, buf); if (new_max_val > max_val) max_val = new_max_val; } } // Unlike other oscs, SILENT osc is processed *after* collecting chained_oscs if (synth[osc]->wave == SILENT) { max_val = render_envelope(buf, osc); // apply filter to osc if set if (synth[osc]->filter_type != FILTER_NONE) { max_val = filter_process(per_osc_fb[core], osc, max_val); // Maybe clear filter state here if we've finshed this osc. if (synth[osc]->status != SYNTH_AUDIBLE) { reset_filter(osc); // (f) } } } // note: Code transplanted here from hold_and_modify() to distinguish actual zero output // from zero-amplitude (but maybe inheriting values from chained_oscs). // Stop oscillators if amp is zero for several frames in a row. // Note: We can't wait for the note off because we need to turn off PARTIAL oscs when envelopes end, even if no note off. //#define MIN_ZERO_AMP_TIME_SAMPS (5 * AMY_BLOCK_SIZE) if(AMY_IS_SET(synth[osc]->zero_amp_clock)) { // We terminate zero_amp_clock if the max_val goes above threshold *or* if it's the start of the note and it's above zero. if (max_val >= F2S(AMP_THRESH) || (max_val > 0 && ((amy_global.total_blocks * AMY_BLOCK_SIZE) < (synth[osc]->note_on_clock + AMY_BLOCK_SIZE)))) { AMY_UNSET(synth[osc]->zero_amp_clock); } else { if ( synth[osc]->terminate_on_silence && ((amy_global.total_blocks*AMY_BLOCK_SIZE - synth[osc]->zero_amp_clock) >= MIN_ZERO_AMP_TIME_SAMPS)) { //printf("h&m: time %.3f osc %d OFF\n", amy_global.time, osc); // Oscillator has fallen silent, stop executing it. uint16_t osc_to_stop = osc; // Type must match synthinfo.chained_osc while (AMY_IS_SET(osc_to_stop)) { synth[osc_to_stop]->status = SYNTH_INAUDIBLE; // It *could* come back... // 2026-03-22: It's necessary to reset these two fields in msynth to get OwBass to restart without click... msynth[osc_to_stop]->filter_logfreq = 0; // (a) msynth[osc_to_stop]->resonance = 0.7f; // (b) //reset_filter(osc_to_stop); // (c) //AMY_UNSET(msynth[osc_to_stop]->last_filter_logfreq); // (d) // .. but force it to start at zero phase next time. synth[osc_to_stop]->phase = 0; osc_to_stop = synth[osc_to_stop]->chained_osc; } // err=-33.6 dB // (d) err=-33.6 dB // (e) err=-35.6 dB // (a) + (b) + (e) err=-35.6 dB // (a) err=-41.1 dB // (b) err=-37.7 dB // (a) + (b) err=-100.0 dB // (a) + (b) + (d) err=-100.0 dB // (c) err=-50.5 dB // (c) + (e) err=-50.5 dB // (a) + (c) err=-50.5 dB // (a) + (c) + (e) err=-50.5 dB // (a) + (b) + (c) err=-50.5 dB // (a) + (b) + (c) + (e) err=-50.5 dB // (a) + (b) + (c) + (d) + (e) err=-50.5 dB // // Preserve the open-filter ring-out, then clear the filter state: // (a) + (b) + (f) err=-87.8 dB just as good as -100 // (f) err=-35.8 dB cutoff delayed, same prob // // (c) always gives -50.5 .. so emptying the filter state negates the impact of a,b,e // (d) never makes any difference .. so it's not slew rate? } } } else if (max_val < F2S(AMP_THRESH)) { synth[osc]->zero_amp_clock = amy_global.total_blocks*AMY_BLOCK_SIZE; } //fprintf(stderr, "render_osc_wave: t=%.3f osc=%d max_val %.6f\n", amy_global.time, osc, S2F(max_val)); } AMY_PROFILE_STOP(RENDER_OSC_WAVE) //fprintf(stderr, "-render_osc_wave: t=%ld core=%d buf=0x%lx (%f, %f, %f, %f...) osc=%d osc_t=%ld\n", // amy_global.total_blocks*AMY_BLOCK_SIZE, core, buf, S2F(buf[0]), S2F(buf[1]), S2F(buf[2]), S2F(buf[3]), // osc, synth[osc]->render_clock); return max_val; } void amy_render(uint16_t start, uint16_t end, uint8_t core) { AMY_PROFILE_START(AMY_RENDER) for(uint16_t i=0;istatus == SYNTH_AUDIBLE) { // skip oscs that are silent or mod sources from playback bzero(per_osc_fb[core], AMY_BLOCK_SIZE * sizeof(SAMPLE)); SAMPLE max_val = render_osc_wave(osc, core, per_osc_fb[core]); // check it's not off, just in case. todo, why do i care? // apply filter to osc if set if(//synth[osc]->status == SYNTH_AUDIBLE && // (e) synth[osc]->filter_type != FILTER_NONE) { //fprintf(stderr, "time %.3f osc %d filter_type %d\n", // (float)amy_global.total_blocks*AMY_BLOCK_SIZE / AMY_SAMPLE_RATE, // osc, synth[osc]->filter_type); //max_val = filter_process(per_osc_fb[core], osc, max_val); //// Maybe clear filter state here if we've finshed this osc. //if (synth[osc]->status != SYNTH_AUDIBLE) { // reset_filter(osc); // (f) //} } if (synth[osc]->status != SYNTH_AUDIBLE) { reset_modosc(msynth[osc]); // (g) This makes a difference, but not clicks reset_osc_state(synth[osc]); } uint8_t handled = 0; if(amy_global.config.amy_external_render_hook != NULL) { handled = amy_global.config.amy_external_render_hook(osc, per_osc_fb[core], AMY_BLOCK_SIZE); } else { #ifdef __EMSCRIPTEN__ // TODO -- pass the buffer to a JS shim using the new bytes support, we could use this to visualize CV output #endif } // only mix the audio in if the external hook did not handle it if(!handled) mix_with_pan(fbl[core], per_osc_fb[core], msynth[osc]->last_pan, msynth[osc]->pan); if (max_val > max_max) max_max = max_val; } // end if audible } core_max[core] = max_max; if(AMY_HAS_CHORUS && core == 0) { ensure_osc_allocd(CHORUS_MOD_SOURCE, NULL); hold_and_modify(CHORUS_MOD_SOURCE); if(amy_global.chorus.level!=0) { bzero(delay_mod, AMY_BLOCK_SIZE * sizeof(SAMPLE)); render_osc_wave(CHORUS_MOD_SOURCE, 0 /* core */, delay_mod); } } if (amy_global.debug_flag) { amy_global.debug_flag = 0; // Only do this once each time debug_flag is set. SAMPLE smax = scan_max(fbl[core], AMY_BLOCK_SIZE); fprintf(stderr, "time %" PRIu32 " core %d max_max=%.3f post-eq max=%.3f\n", amy_global.total_blocks*AMY_BLOCK_SIZE, core, S2F(max_max), S2F(smax)); } AMY_PROFILE_STOP(AMY_RENDER) } // this plays just the next delta if it's time. void amy_execute_delta() { AMY_PROFILE_START(AMY_EXECUTE_DELTAS) // check to see which sounds to play uint32_t sysclock = amy_sysclock(); amy_grab_lock(); // find any deltas that need to be played from the (in-order) queue struct delta *d = amy_global.delta_queue; if(d && sysclock >= d->time) { play_delta(d); d = delta_release(d); amy_global.delta_qsize--; } amy_global.delta_queue = d; amy_release_lock(); AMY_PROFILE_STOP(AMY_EXECUTE_DELTAS) } // this takes scheduled deltas and plays them at the right time void amy_execute_deltas() { AMY_PROFILE_START(AMY_EXECUTE_DELTAS) // check to see which sounds to play uint32_t sysclock = amy_sysclock(); amy_grab_lock(); // find any deltas that need to be played from the (in-order) queue struct delta *d = amy_global.delta_queue; while(d && sysclock >= d->time) { play_delta(d); d = delta_release(d); amy_global.delta_qsize--; } amy_global.delta_queue = d; amy_release_lock(); AMY_PROFILE_STOP(AMY_EXECUTE_DELTAS) } // called by the audio render loop to alert JS (and then python) that a block has been rendered void amy_block_processed(void) { #ifdef __EMSCRIPTEN__ EM_ASM({ if(typeof amy_block_processed_js_hook === 'function') { amy_block_processed_js_hook(); } }); #else if(amy_global.config.amy_external_block_done_hook != NULL) { amy_global.config.amy_external_block_done_hook(); } #endif } void amy_process_event(amy_event *e) { peek_stack("process_event"); if(AMY_IS_SET(e->sequence[SEQUENCE_TICK]) || AMY_IS_SET(e->sequence[SEQUENCE_PERIOD]) || AMY_IS_SET(e->sequence[SEQUENCE_TAG])) { uint8_t added = sequencer_add_event(e); (void)added; // we don't need to do anything with this info at this time e->status = EVENT_SEQUENCE; } else if (AMY_IS_SET(e->reset_osc) && (e->reset_osc & RESET_PATCH) && AMY_IS_SET(e->patch_number)) { // We're resetting just one patch, do it now. But RESET_PATCH with no patch_number should propagate to deltas. patches_reset_patch(e->patch_number); AMY_UNSET(e->reset_osc); } else { // if time is set, play then // if time and latency is set, play in time + latency // if time is not set, play now // if time is not set + latency is set, play in latency uint32_t playback_time = amy_sysclock(); if(AMY_IS_SET(e->time)) playback_time = e->time; playback_time += amy_global.latency_ms; e->time = playback_time; e->status = EVENT_SCHEDULED; } } int16_t * amy_fill_buffer() { AMY_PROFILE_START(AMY_FILL_BUFFER) #ifdef __EMSCRIPTEN__ // post a message to the main thread of the audioworklet (amy main, in this case) that a block has been finished //emscripten_audio_worklet_post_function_v(0, amy_block_processed); #else amy_block_processed(); #endif // Double-buffer the output block. if (output_block == output_block_0) output_block = output_block_1; else output_block = output_block_0; // mix results from both cores. //SAMPLE max_val = core_max[0]; #ifdef AMY_DUALCORE for (int16_t i=0; i < AMY_BLOCK_SIZE * AMY_NCHANS; ++i) fbl[0][i] += fbl[1][i]; // if (core_max[1] > max_val) max_val = core_max[1]; #endif // Apply global processing only if there is some signal. //if (max_val > 0) { // NO - see #629 // apply the eq filters if there is some signal and EQ is non-default. if (amy_global.eq[0] != F2S(1.0f) || amy_global.eq[1] != F2S(1.0f) || amy_global.eq[2] != F2S(1.0f)) { parametric_eq_process(fbl[0]); } if(AMY_HAS_CHORUS) { // apply chorus. if(amy_global.chorus.level > 0 && chorus_delay_lines[0] != NULL) { // apply time-varying delays to both chans. // delay_mod_val, the modulated delay amount, is set up before calling render_*. SAMPLE scale = F2S(1.0f); for (int16_t c=0; c < AMY_NCHANS; ++c) { apply_variable_delay(fbl[0] + c * AMY_BLOCK_SIZE, chorus_delay_lines[c], delay_mod, scale, amy_global.chorus.level, 0); // flip delay direction for alternating channels. scale = -scale; } } } //} if (AMY_HAS_ECHO) { // Apply echo. if (amy_global.echo.level > 0 && echo_delay_lines[0] != NULL ) { for (int16_t c=0; c < AMY_NCHANS; ++c) { apply_fixed_delay(fbl[0] + c * AMY_BLOCK_SIZE, echo_delay_lines[c], amy_global.echo.delay_samples, amy_global.echo.level, amy_global.echo.feedback, amy_global.echo.filter_coef); } } } if(AMY_HAS_REVERB) { // apply reverb. if(amy_global.reverb.level > 0) { if(AMY_NCHANS == 1) { stereo_reverb(fbl[0], NULL, fbl[0], NULL, AMY_BLOCK_SIZE, amy_global.reverb.level); } else { stereo_reverb(fbl[0], fbl[0] + AMY_BLOCK_SIZE, fbl[0], fbl[0] + AMY_BLOCK_SIZE, AMY_BLOCK_SIZE, amy_global.reverb.level); } } } // global volume is supposed to max out at 10, so scale by 0.1. SAMPLE volume_scale = MUL4_SS(F2S(0.1f), F2S(amy_global.volume)); for(int16_t i=0; i < AMY_BLOCK_SIZE; ++i) { for (int16_t c=0; c < AMY_NCHANS; ++c) { // Convert the mixed sample into the int16 range, applying overall gain. SAMPLE fsample = MUL8_SS(volume_scale, fbl[0][i + c * AMY_BLOCK_SIZE]); // One-pole high-pass filter to remove large low-frequency excursions from // some FM patches. b = [1 -1]; a = [1 -0.995] //SAMPLE new_state = fsample + SMULR6(F2S(0.995f), amy_global.hpf_state); // High-output-range, rounded MUL is critical here. #ifdef AMY_HPF_OUTPUT SAMPLE new_state = fsample + amy_global.hpf_state - SHIFTR(amy_global.hpf_state + SHIFTR(F2S(1.0), 16), 8); // i.e. 0.9961*hpf_state fsample = new_state - amy_global.hpf_state; amy_global.hpf_state = new_state; #endif // soft clipping. int positive = 1; if (fsample < 0) { positive = 0; // avoid fabs() fsample = -fsample; } int32_t uintval = S2L(fsample); if (uintval >= FIRST_NONLIN) { if (uintval >= FIRST_HARDCLIP) { uintval = SAMPLE_MAX; } else { uintval = clipping_lookup_table[uintval - FIRST_NONLIN]; } } int16_t sample; // TODO -- the esp stuff here could sit outside of AMY // For some reason, have to drop a bit to stop hard wrapping on esp? #if defined(ESP_PLATFORM) || defined(__IMXRT1062__) uintval >>= 1; #endif if (positive) { sample = uintval; } else { sample = -uintval; } if(AMY_NCHANS == 1) { #ifdef ESP_PLATFORM // esp32's i2s driver has this bug output_block[i ^ 0x01] = sample; #else output_block[i] = sample; #endif } else { output_block[(AMY_NCHANS * i) + c] = sample; } } } // Handle sampling after block is rendered if(amy_global.transfer_flag==AMY_TRANSFER_TYPE_SAMPLE) { uint32_t bytes_per_frame = AMY_NCHANS * sizeof(int16_t); uint32_t byte_offset = amy_global.transfer_stored_bytes; uint32_t bytes_to_copy = AMY_BLOCK_SIZE * bytes_per_frame; // Crop the bytes to copy if this block would exceed the requested length. if(byte_offset + bytes_to_copy >= amy_global.transfer_length_bytes) { bytes_to_copy = amy_global.transfer_length_bytes - byte_offset; } if(amy_global.transfer_file_handle==AMY_BUS_OUTPUT) { // copy block[] to amy_global.transfer_storage memcpy(amy_global.transfer_storage + byte_offset, output_block, bytes_to_copy); } else if(amy_global.transfer_file_handle==AMY_BUS_AUDIO_IN) { // copy audio input buffer to storage memcpy(amy_global.transfer_storage + byte_offset, amy_in_block, bytes_to_copy); } amy_global.transfer_stored_bytes += AMY_BLOCK_SIZE * AMY_NCHANS * sizeof(int16_t); if(amy_global.transfer_stored_bytes >= amy_global.transfer_length_bytes) { amy_global.transfer_flag = AMY_TRANSFER_TYPE_NONE; } } amy_global.total_blocks++; amy_global.time = amy_global.total_blocks*AMY_BLOCK_SIZE / (float)AMY_SAMPLE_RATE; AMY_PROFILE_STOP(AMY_FILL_BUFFER) amy_out_block = output_block; return output_block; } void amy_reset_sysclock() { amy_global.total_blocks = 0; amy_global.time = 0; amy_global.sequencer_tick_count = 0; sequencer_recompute(); } /// Delta pool management struct delta *free_deltas_pool = NULL; #define MAX_DELTA_BLOCKS 16 struct delta *delta_blocks[MAX_DELTA_BLOCKS]; int next_delta_block = 0; #define DELTA_BLOCK_SIZE 2048 struct delta *deltas_pool_alloc(int max_delta_pool_size, struct delta *tail) { struct delta *new_pool = (struct delta *)malloc_caps(max_delta_pool_size * sizeof(struct delta), amy_global.config.ram_caps_synth); struct delta *d = new_pool; // Link all the deltas together for (int i = 1; i < max_delta_pool_size; ++i) { d->next = d + 1; d->osc = 0; d->data.i = 0; d->param = NO_PARAM; d->time = UINT32_MAX - 1; d = d->next; } d->next = tail; // join up the end of the chain with passed-in chain (or NULL). return new_pool; } void deltas_add_pool_block(void) { //fprintf(stderr, "deltas_add_pool_block %d\n", next_delta_block); if (next_delta_block >= MAX_DELTA_BLOCKS) { fprintf(stderr, "**PANIC: Ran out of deltas (%d blocks of %d deltas)\n", MAX_DELTA_BLOCKS, DELTA_BLOCK_SIZE); abort(); } free_deltas_pool = delta_blocks[next_delta_block++] = deltas_pool_alloc(DELTA_BLOCK_SIZE, free_deltas_pool); } void deltas_pool_init() { deltas_pool_free(); deltas_add_pool_block(); } void deltas_pool_free() { for (int i = 0; i < next_delta_block; ++i) { free(delta_blocks[i]); } next_delta_block = 0; free_deltas_pool = NULL; } struct delta *delta_get(struct delta *from) { // fetch the next free delta, copy in values if a reference is provided. struct delta *d = free_deltas_pool; if (d == NULL) { deltas_add_pool_block(); d = free_deltas_pool; } free_deltas_pool = d->next; if (from != NULL) { d->data.i = from->data.i; d->param = from->param; d->time = from->time; d->osc = from->osc; // don't copy from->next } d->next = NULL; return d; } struct delta *delta_release(struct delta *d) { // return a delta to the pool. Returns the next value, for ease closing up struct delta *next_delta = d->next; d->next = free_deltas_pool; d->osc = 0; d->data.i = 0; d->param = NO_PARAM; d->time = UINT32_MAX - 1; free_deltas_pool = d; return next_delta; } void delta_release_list(struct delta *d) { // return a delta and all its sequestrae to the pool. while(d) d = delta_release(d); } int32_t delta_list_len(struct delta *d) { int32_t len = 0; while(d) { ++len; d = d->next; } return len; } int32_t delta_num_free() { return delta_list_len(free_deltas_pool); } ================================================ FILE: src/amy.h ================================================ #ifndef __AMY_H #define __AMY_H #include #include #include #include #include #include #include #ifdef _WIN32 #include #include #define bzero(b,len) memset((b), 0, (len)) #define bcopy(src,dest,len) memmove((dest), (src), (len)) #define srand48(x) srand((unsigned int)(x)) #define drand48() ((double)rand() / RAND_MAX) static inline int __builtin_clz(unsigned int x) { unsigned long index; return _BitScanReverse(&index, x) ? (31 - (int)index) : 32; } #else #include #endif #include #ifndef __EMSCRIPTEN__ #ifdef _WIN32 #include extern CRITICAL_SECTION amy_queue_lock; #elif defined _POSIX_THREADS #include extern pthread_mutex_t amy_queue_lock; #endif #endif // This is for baked in samples that come with AMY. The header file written by `amy/headers.py` writes this. typedef struct { uint32_t offset; uint32_t length; uint32_t loopstart; uint32_t loopend; uint8_t midinote; } pcm_map_t; // Built-in PCM data declarations (provided by src/pcm_tiny.h). extern const int16_t pcm[]; extern const pcm_map_t pcm_map[]; extern const uint16_t pcm_samples; extern const uint16_t pcm_wavetable_base; extern const uint16_t pcm_wavetable_samples; extern const uint32_t pcm_wavetable_len; #if (defined(ESP_PLATFORM) || defined(PICO_ON_DEVICE) || defined(ARDUINO) || defined(__IMXRT1062__) || defined(ARDUINO_ARCH_RP2040) ||defined(ARDUINO_ARCH_RP2350)) #define AMY_MCU #endif #define MAX_FILENAME_LEN 127 // Set block size and SR. We try for 256/44100, but some platforms don't let us: #ifdef AMY_DAISY #define AMY_BLOCK_SIZE 128 #define BLOCK_SIZE_BITS 7 // log2 of BLOCK_SIZE #else #define AMY_BLOCK_SIZE 256 #define BLOCK_SIZE_BITS 8 // log2 of BLOCK_SIZE #endif #ifdef AMY_DAISY #define AMY_SAMPLE_RATE 48000 #elif defined __EMSCRIPTEN__ #define AMY_SAMPLE_RATE 48000 #else #define AMY_SAMPLE_RATE 44100 #endif #define PCM_AMY_SAMPLE_RATE 22050 // Transfer types. #define AMY_TRANSFER_TYPE_NONE 0 #define AMY_TRANSFER_TYPE_AUDIO 1 #define AMY_TRANSFER_TYPE_FILE 2 #define AMY_TRANSFER_TYPE_SAMPLE 3 #define AMY_PCM_TYPE_ROM 0 #define AMY_PCM_TYPE_FILE 1 #define AMY_PCM_TYPE_MEMORY 2 // File-streaming buffer size multiplier (in blocks). #define PCM_FILE_BUFFER_MULT 8 #define AMY_BUS_OUTPUT 1 #define AMY_BUS_AUDIO_IN 2 // Always use fixed point. You can remove this if you want float #define AMY_USE_FIXEDPOINT // upper bounds for static arrays. #define AMY_MAX_CORES 2 #define AMY_MAX_CHANNELS 2 // Always use 2 channels. Clients that want mono can deinterleave #define AMY_NCHANS 2 // Use dual cores on supported platforms #if (defined (ESP_PLATFORM) || defined (ARDUINO_ARCH_RP2040) ||defined(ARDUINO_ARCH_RP2350)) #define AMY_DUALCORE #define AMY_CORES 2 #else #define AMY_CORES 1 #endif #define AMY_HAS_STARTUP_BLEEP (amy_global.config.features.startup_bleep) #define AMY_HAS_REVERB (amy_global.config.features.reverb) #define AMY_HAS_AUDIO_IN (amy_global.config.features.audio_in) #define AMY_HAS_I2S (amy_global.config.audio == AMY_AUDIO_IS_I2S) #define AMY_HAS_DEFAULT_SYNTHS (amy_global.config.features.default_synths) #define AMY_HAS_CHORUS (amy_global.config.features.chorus) #define AMY_HAS_ECHO (amy_global.config.features.echo) #define AMY_KS_OSCS amy_global.config.ks_oscs #define AMY_HAS_PARTIALS (amy_global.config.features.partials) #define AMY_HAS_CUSTOM (amy_global.config.features.custom) #define AMY_OSCS amy_global.config.max_oscs // On which MIDI channel to install the default MIDI drums handler. #define AMY_MIDI_CHANNEL_DRUMS 10 #ifdef ESP_PLATFORM #include #endif #ifndef MALLOC_CAP_DEFAULT #define MALLOC_CAP_DEFAULT 0 #endif // 0.5 Hz modulation at 50% depth of 320 samples (i.e., 80..240 samples = 2..6 ms), mix at 0 (inaudible). #define CHORUS_DEFAULT_LFO_FREQ 0.5 #define CHORUS_DEFAULT_MOD_DEPTH 0.5 #define CHORUS_DEFAULT_LEVEL 0 #define CHORUS_DEFAULT_MAX_DELAY 320 // Chorus gets is modulator from a special osc one beyond the normal range. #define CHORUS_MOD_SOURCE AMY_OSCS // center frequencies for the EQ #define EQ_CENTER_LOW 800.0 #define EQ_CENTER_MED 2500.0 #define EQ_CENTER_HIGH 7000.0 // reverb setup #define REVERB_DEFAULT_LEVEL 0 #define REVERB_DEFAULT_LIVENESS 0.85f #define REVERB_DEFAULT_DAMPING 0.5f #define REVERB_DEFAULT_XOVER_HZ 3000.0f // echo setup, Levels etc are SAMPLE (fxpoint), delays are in samples. #define ECHO_DEFAULT_LEVEL 0 #define ECHO_DEFAULT_DELAY_MS 500.f // Delay line allocates in 2^n samples at 44k; 743ms is just under 32768 samples. #define ECHO_DEFAULT_MAX_DELAY_MS 743.f #define ECHO_DEFAULT_FEEDBACK 0 #define ECHO_DEFAULT_FILTER_COEF 0 #define AMY_SEQUENCER_PPQ 48 #define DELAY_LINE_LEN 512 // 11 ms @ 44 kHz // D is how close the sample gets to the clip limit before the nonlinearity engages. // So D=0.1 means output is linear for -0.9..0.9, then starts clipping. #define CLIP_D 0.1 #define MAX_VOLUME 11.0 #define AMP_THRESH 0.001f // A little bit more than 0.001 to avoid FP issues with exactly 0.001. #define AMP_THRESH_PLUS 0.0011f // Rest of amy setup #define SAMPLE_MAX 32767 #define MAX_ALGO_OPS 6 #define DEFAULT_NUM_BREAKPOINTS 8 // We need a max on the number of breakpoints to lay out the params enum statically. Otherwise, it's dynamic. #define MAX_BREAKPOINTS 24 #define MAX_BPS MAX_BREAKPOINTS #define MAX_BREAKPOINT_SETS 2 #define THREAD_USLEEP 500 #define AMY_BYTES_PER_SAMPLE 2 // We need some fixed vectors of per-instrument vectors. #define MAX_VOICES_PER_INSTRUMENT 32 // Constants for filters.c, needed for synth structure. #define FILT_NUM_DELAYS 4 // Need 4 memories for DFI filters, if used (only 2 for DFII). typedef int16_t output_sample_type; // Magic value for "0 Hz" in log-scale. #define ZERO_HZ_LOG_VAL -99.0 // Frequency of Midi note 0, used to make logfreq scales. // Have 0 be midi 69, A4, 440.0 #define ZERO_LOGFREQ_IN_HZ 440.0 // 261.63 #define ZERO_MIDI_NOTE 69 // 60 #define MIN_FILTER_LOGFREQ -2.75 // -2.0 // LPF cutoff cannot go below w = 0.01 rad/samp in filters.c = 72 Hz, so clip it here at ~65 Hz. #define NUM_COMBO_COEFS 9 // 9 control-mixing params: const, note, velocity, env1, env2, mod, pitchbend, ext0, ext1 enum coefs{ COEF_CONST = 0, COEF_NOTE = 1, COEF_VEL = 2, COEF_EG0 = 3, COEF_EG1 = 4, COEF_MOD = 5, COEF_BEND = 6, COEF_EXT0 = 7, COEF_EXT1 = 8, }; #define MAX_MESSAGE_LEN 1024 #define MAX_PARAM_LEN 256 // synth[].filter_type values #define FILTER_NONE 0 #define FILTER_LPF 1 #define FILTER_BPF 2 #define FILTER_HPF 3 #define FILTER_LPF24 4 // synth[].wave values #define SINE 0 #define PULSE 1 #define SAW_DOWN 2 #define SAW_UP 3 #define TRIANGLE 4 #define NOISE 5 #define KS 6 #define PCM 7 #define ALGO 8 #define PARTIAL 9 #define BYO_PARTIALS 10 #define INTERP_PARTIALS 11 #define AUDIO_IN0 12 #define AUDIO_IN1 13 #define AUDIO_EXT0 14 #define AUDIO_EXT1 15 #define AMY_MIDI 16 #define PCM_LEFT 17 #define PCM_RIGHT 18 #define PCM_MIX 7 // same as PCM #define WAVETABLE 19 #define SILENT 20 // A control osc for applying filte and env without contributing waveform #define CUSTOM 21 #define WAVE_OFF 22 #define AMY_WAVE_IS_PCM(w) ((w) == PCM || (w) == PCM_LEFT || (w) == PCM_RIGHT) // synth[].status values #define SYNTH_OFF 0 #define SYNTH_AUDIBLE 1 #define SYNTH_INAUDIBLE 2 #define SYNTH_IS_MOD_SOURCE 3 #define SYNTH_IS_ALGO_SOURCE 4 // event.status values #define EVENT_EMPTY 0 #define EVENT_SCHEDULED 1 #define EVENT_TRANSFER_DATA 2 #define EVENT_SEQUENCE 3 // note_source values #define NOTE_SOURCE_MIDI 2 // Envelope generator types (for synth[osc].env_type[eg]). #define ENVELOPE_NORMAL 0 #define ENVELOPE_LINEAR 1 #define ENVELOPE_DX7 2 #define ENVELOPE_TRUE_EXPONENTIAL 3 // Sequence enum #define SEQUENCE_TICK 0 #define SEQUENCE_PERIOD 1 #define SEQUENCE_TAG 2 // Reset masks #define RESET_SEQUENCER 4096 #define RESET_ALL_OSCS 8192 #define RESET_TIMEBASE 16384 #define RESET_AMY 32768 #define RESET_EVENTS 65536 #define RESET_ALL_NOTES 131072 #define RESET_SYNTHS 262144 // Non-scheduled release of all synths, voices, oscs prior to load_patch #define RESET_PATCH 524288 // Clear one patch if patch_number provided, otherwise clear all patches. #define RESET_QUEUE 1048576 // resets the amy queue #define true 1 #define false 0 #define AMY_OK 0 typedef int amy_err_t; #ifndef MAX #define MAX(a, b) ((a) > (b) ? (a) : (b)) #endif #ifndef MIN #define MIN(a, b) ((a) < (b) ? (a) : (b)) #endif #include "amy_fixedpoint.h" #if defined ARDUINO && !defined TLONG && !defined ESP_PLATFORM #include "avr/pgmspace.h" // for PROGMEM, DMAMEM, FASTRUN #else #define PROGMEM #endif enum params{ WAVE, PRESET, MIDI_NOTE, // 0, 1, 2 AMP, // 3..11 DUTY=AMP + NUM_COMBO_COEFS, // 12..20 FEEDBACK=DUTY + NUM_COMBO_COEFS, // 21 FREQ, // 22..30 VELOCITY=FREQ + NUM_COMBO_COEFS, // 31 PHASE, DETUNE, VOLUME, PITCH_BEND, // 32, 33, 34, 35 PAN, // 36..44 FILTER_FREQ=PAN + NUM_COMBO_COEFS, // 45..53 RATIO=FILTER_FREQ + NUM_COMBO_COEFS, // 54 RESONANCE, PORTAMENTO, CHAINED_OSC, // 55, 56, 57 MOD_SOURCE, FILTER_TYPE, // 58, 59 EQ_L, EQ_M, EQ_H, // 60, 61, 62 ALGORITHM, LATENCY, TEMPO, // 63, 64, 65 ALGO_SOURCE_START=100, // 100..105 ALGO_SOURCE_END=100+MAX_ALGO_OPS, // 106 BP_START=ALGO_SOURCE_END + 1, // 107..202 BP_END=BP_START + (MAX_BREAKPOINT_SETS * MAX_BREAKPOINTS * 2), // 203 EG0_TYPE, EG1_TYPE, // 204, 205 CLONE_OSC, // 206 RESET_OSC, // 207 NOTE_SOURCE, // 208 ECHO_LEVEL, ECHO_DELAY_MS, ECHO_MAX_DELAY_MS, ECHO_FEEDBACK, ECHO_FILTER_COEF, CHORUS_LEVEL, CHORUS_MAX_DELAY, CHORUS_LFO_FREQ, CHORUS_DEPTH, REVERB_LEVEL, REVERB_LIVENESS, REVERB_DAMPING, REVERB_XOVER_HZ, NO_PARAM // 209 }; /////////////////////////////////////// // Profiler setup #ifdef AMY_DEBUG enum itags{ RENDER_OSC_WAVE, COMPUTE_BREAKPOINT_SCALE, HOLD_AND_MODIFY, FILTER_PROCESS, FILTER_PROCESS_STAGE0, FILTER_PROCESS_STAGE1, ADD_DELTA_TO_QUEUE, AMY_ADD_DELTA, PLAY_DELTA, MIX_WITH_PAN, AMY_RENDER, AMY_EXECUTE_DELTAS, AMY_FILL_BUFFER, RENDER_LUT_FM, RENDER_LUT_FB, RENDER_LUT, RENDER_LUT_CUB, RENDER_LUT_FM_FB, RENDER_LPF_LUT, DSPS_BIQUAD_F32_ANSI_SPLIT_FB, DSPS_BIQUAD_F32_ANSI_SPLIT_FB_TWICE, DSPS_BIQUAD_F32_ANSI_COMMUTED, PARAMETRIC_EQ_PROCESS, HPF_BUF, SCAN_MAX, DSPS_BIQUAD_F32_ANSI, BLOCK_NORM, CALIBRATE, AMY_ESP_FILL_BUFFER, NO_TAG }; struct profile { uint32_t calls; uint64_t us_total; uint64_t start; }; extern uint64_t profile_start_us; #define AMY_PROFILE_INIT(tag) \ profiles[tag].start = 0; \ profiles[tag].calls = 0; \ profiles[tag].us_total = 0; \ profile_start_us = amy_get_us(); #define AMY_PROFILE_START(tag) \ profiles[tag].start = amy_get_us(); #define AMY_PROFILE_STOP(tag) \ profiles[tag].us_total += (amy_get_us()-profiles[tag].start); \ profiles[tag].calls++; #define AMY_PROFILE_PRINT(tag) \ if(profiles[tag].calls) {\ fprintf(stderr,"%40s: %10"PRIu32" calls %10"PRIu64"us total [%6.2f%% wall %6.2f%% render] %9"PRIu64"us per call\n", \ profile_tag_name(tag), profiles[tag].calls, profiles[tag].us_total, \ ((float)(profiles[tag].us_total) / (float)(amy_get_us() - profile_start_us))*100.0, \ ((float)(profiles[tag].us_total) / (float)(profiles[AMY_RENDER].us_total))*100.0, \ (profiles[tag].us_total)/profiles[tag].calls);\ } extern struct profile profiles[NO_TAG]; extern int64_t amy_get_us(); #else #define AMY_PROFILE_START(tag) #define AMY_PROFILE_STOP(tag) #endif // AMY_DEBUG extern void amy_profiles_init(); extern void amy_profiles_print(); /////////////////////////////////////// // Default values setup #include static inline int isnan_c11(float test) { return isnan(test); } #define AMY_UNSET_FLOAT nanf("") #define AMY_UNSET_VALUE(var) _Generic((var), \ float: AMY_UNSET_FLOAT, \ uint32_t: UINT32_MAX, \ uint16_t: UINT16_MAX, \ int16_t: SHRT_MAX, \ uint8_t: UINT8_MAX, \ int8_t: SCHAR_MAX, \ int32_t: INT_MAX \ ) #define AMY_UNSET(var) var = AMY_UNSET_VALUE(var) #define AMY_IS_UNSET(var) _Generic((var), \ float: isnan_c11(var), \ default: var==AMY_UNSET_VALUE(var) \ ) // char*: *(uint8_t *)var == 0, #define AMY_IS_SET(var) !AMY_IS_UNSET(var) // Helpers to identify if param is in a range. #define PARAM_IS_COMBO_COEF(param, base) ((param) >= (base) && (param) < (base) + NUM_COMBO_COEFS) #define PARAM_IS_BP_COEF(param) ((param) >= BP_START && (param) < BP_END) /////////////////////////////////////// // Events & deltas // Delta holds the individual changes from an event, it's sorted in order of playback time // this is more efficient in memory than storing entire events per message struct delta { union d { uint32_t i; float f; } data; enum params param; // which parameter is being changed uint32_t time; // what time to play / change this parameter uint16_t osc; // which oscillator it impacts struct delta * next; // the next delta, in time }; // API accessible events, are converted to delta types for the synth to play back typedef struct amy_event { uint32_t time; // event only uint16_t osc; uint16_t wave; int16_t preset; // Negative preset is voice count for build-your-own PARTIALS float midi_note; uint16_t patch_number; // event only float amp_coefs[NUM_COMBO_COEFS]; float freq_coefs[NUM_COMBO_COEFS]; // synth is log float filter_freq_coefs[NUM_COMBO_COEFS]; // synth is log float duty_coefs[NUM_COMBO_COEFS]; float pan_coefs[NUM_COMBO_COEFS]; float feedback; float velocity; float trigger_phase; float volume; // event_only float pitch_bend; // event_only float tempo; // event_only uint16_t latency_ms; // event_only float ratio; // synth is log float resonance; uint16_t portamento_ms; // synth is alpha uint16_t chained_osc; uint16_t mod_source; uint8_t algorithm; uint8_t filter_type; float eq_l; // not in synth float eq_m; // not in synth float eq_h; // not in synth uint16_t bp_is_set[MAX_BREAKPOINT_SETS]; // Convert these two at least to vectors of ints, save several hundred bytes int16_t algo_source[MAX_ALGO_OPS]; uint16_t voices[MAX_VOICES_PER_INSTRUMENT]; uint32_t eg0_times[MAX_BPS]; float eg0_values[MAX_BPS]; uint32_t eg1_times[MAX_BPS]; float eg1_values[MAX_BPS]; uint8_t eg_type[MAX_BREAKPOINT_SETS]; // Instrument-layer values. uint8_t synth; uint32_t synth_flags; // Special flags to set when defining instruments. uint16_t synth_delay_ms; // Extra delay added to synth note-ons to allow decay on voice-stealing. uint8_t to_synth; // For moving setup between synth numbers. uint8_t grab_midi_notes; // To enable/disable automatic MIDI note-on/off generating note-on/off. uint8_t pedal; // MIDI pedal value. uint16_t num_voices; uint32_t sequence[3]; // tick, period, tag // uint8_t status; uint8_t note_source; // .. to mark note on/offs that come from MIDI so we don't send them back out again. uint32_t reset_osc; // Global effects float echo_level; float echo_delay_ms; float echo_max_delay_ms; float echo_feedback; float echo_filter_coef; float chorus_level; float chorus_max_delay; float chorus_lfo_freq; float chorus_depth; float reverb_level; float reverb_liveness; float reverb_damping; float reverb_xover_hz; uint8_t oscs_per_voice; // Used when initializing a synth without a patch. } amy_event; // This is the state of each oscillator, set by the sequencer from deltas struct synthinfo { uint16_t osc; // self-reference // Configuration (can be fixed during oscillation) uint16_t wave; int16_t preset; // Negative preset is voice count for build-your-own PARTIALS uint8_t note_source; // Was the most recent note on/off received e.g. from MIDI? float midi_note; float velocity; float amp_coefs[NUM_COMBO_COEFS]; float logfreq_coefs[NUM_COMBO_COEFS]; float filter_logfreq_coefs[NUM_COMBO_COEFS]; float duty_coefs[NUM_COMBO_COEFS]; float pan_coefs[NUM_COMBO_COEFS]; float feedback; float trigger_phase; float logratio; float portamento_alpha; float resonance; uint8_t filter_type; uint16_t chained_osc; uint16_t mod_source; uint8_t algorithm; int16_t algo_source[MAX_ALGO_OPS]; // int16 not uint because -1 specified to indicate no osc uint8_t eg_type[MAX_BREAKPOINT_SETS]; // one of the ENVELOPE_ values uint8_t max_num_breakpoints[MAX_BREAKPOINT_SETS]; // alloc'd length of breakpoint_times/vals uint32_t *breakpoint_times[MAX_BREAKPOINT_SETS]; // (in samples) dynamically sized. float *breakpoint_values[MAX_BREAKPOINT_SETS]; // dynamically sized. // Per-note state (set on initialization, does not change during note) uint8_t terminate_on_silence; // Usually yes, not for PCM. not in event. const LUT *lut; // Selected lookup table and size. // Per-block state (changes with time) uint8_t status; // not in event PHASOR phase; // not in event float step; // not in event float substep; // not in event uint32_t render_clock; uint32_t note_on_clock; uint32_t note_off_clock; uint32_t zero_amp_clock; // Time amplitude hits zero. uint32_t mod_value_clock; // Only calculate mod_value once per frame (for mod_source). SAMPLE mod_value; // last value returned by this oscillator when acting as a MOD_SOURCE, not in event SAMPLE last_scale[MAX_BREAKPOINT_SETS]; // remembers current envelope level, to use as start point in release. SAMPLE last_two[2]; // For ALGO feedback ops // For filters. Need 2x because LPF24 uses two instances of filter. SAMPLE filter_delay[2 * FILT_NUM_DELAYS]; // The block-floating-point shift of the filter delay values. int last_filt_norm_bits; }; // synthinfo, but only the things that mods/env can change. one per osc struct mod_synthinfo { float amp; float last_amp; // amplitude smoother float pan; float last_pan; // Pan history for interpolation. float duty; float last_duty; // Duty history for interpolation. float logfreq; float last_logfreq; // for portamento float filter_logfreq; float last_filter_logfreq; // filter freq history for smoothing. float resonance; float feedback; }; typedef struct sequence_entry_ll_t { struct delta d; uint32_t tag; uint32_t tick; // 0 means not used uint32_t period; // 0 means not used struct sequence_entry_ll_t *next; } sequence_entry_ll_t; typedef struct delay_line { SAMPLE *samples; int len; int log_2_len; int fixed_delay; int next_in; } delay_line_t; #include "delay.h" #include "sequencer.h" #include "amy_midi.h" #include "transfer.h" /////////////////////////////////////// // config #define AMY_AUDIO_IS_NONE 0x00 #define AMY_AUDIO_IS_I2S 0x01 #define AMY_AUDIO_IS_USB_GADGET 0x02 #define AMY_AUDIO_IS_MINIAUDIO 0x04 #define AMY_MIDI_IS_NONE 0x0 #define AMY_MIDI_IS_UART 0x01 #define AMY_MIDI_IS_USB_GADGET 0x02 #define AMY_MIDI_IS_MACOS 0x04 #define AMY_MIDI_IS_WEBMIDI 0x08 // AMYboard pins #define AMYBOARD_LRC 2 #define AMYBOARD_BCLK 8 #define AMYBOARD_DOUT 6 #define AMYBOARD_DIN 9 #define AMYBOARD_MCLK 3 #define AMYBOARD_MIDI_OUT_TYPE_A 14 #define AMYBOARD_MIDI_OUT_TYPE_B 15 #define AMYBOARD_MIDI_IN 21 typedef struct { struct { uint8_t chorus : 1; uint8_t reverb : 1; uint8_t echo : 1; uint8_t audio_in : 1; uint8_t default_synths : 1; uint8_t partials : 1; uint8_t custom : 1; uint8_t startup_bleep : 1; } features; struct { uint8_t multicore : 1; // Use secondary cores if available. uint8_t multithread : 1; // Use multitasking (e.g. RTOS threads) if available. } platform; // midi and audio are potentially bitmasks indicating data routing. uint8_t midi; uint8_t audio; // variables uint16_t max_oscs; uint8_t ks_oscs; uint32_t max_sequencer_tags; uint32_t max_voices; uint32_t max_synths; uint32_t max_memory_patches; // alternative audio output function size_t (*write_samples_fn)(const uint8_t *buffer, size_t buffer_size); // Optional hooks for host/platform integration. uint8_t (*amy_external_render_hook)(uint16_t osc, SAMPLE *, uint16_t len); float (*amy_external_coef_hook)(uint16_t channel); void (*amy_external_block_done_hook)(void); void (*amy_external_midi_input_hook)(uint8_t *bytes, uint16_t len, uint8_t is_sysex); void (*amy_external_sequencer_hook)(uint32_t tick_count); uint32_t (*amy_external_fopen_hook)(char *filename, const char *mode); uint32_t (*amy_external_fwrite_hook)(uint32_t fptr, uint8_t *bytes, uint32_t len); uint32_t (*amy_external_fread_hook)(uint32_t fptr, uint8_t *bytes, uint32_t len); void (*amy_external_fseek_hook)(uint32_t fptr, uint32_t pos); void (*amy_external_fclose_hook)(uint32_t fptr); void (*amy_external_file_transfer_done_hook)(const char *filename); void (*amy_external_update_file_hook)(const char *filename); void (*amy_external_exec_hook)(const char *code); void (*amy_external_reboot_hook)(uint8_t mode); // pins for MCU platforms int8_t i2s_lrc; int8_t i2s_dout; int8_t i2s_din; int8_t i2s_bclk; int8_t i2s_mclk; uint16_t i2s_mclk_mult; int8_t midi_out; int8_t midi_in; int8_t midi_uart; // memory caps for MCUs uint32_t ram_caps_events; uint32_t ram_caps_sysex; uint32_t ram_caps_synth; uint32_t ram_caps_block; uint32_t ram_caps_fbl; uint32_t ram_caps_delay; uint32_t ram_caps_sample; // device ids for miniaudio platforms int8_t capture_device_id; int8_t playback_device_id; } amy_config_t; typedef struct reverb_state { SAMPLE level; float liveness; float damping; float xover_hz; } reverb_state_t; typedef struct chorus_config { SAMPLE level; // How much of the delayed signal to mix in to the output, typ F2S(0.5). int32_t max_delay; // Max delay when modulating. Must be <= DELAY_LINE_LEN float lfo_freq; float depth; } chorus_config_t; typedef struct echo_config { SAMPLE level; // Mix of echo into output. 0 = Echo off. uint32_t delay_samples; // Current delay, quantized to samples. uint32_t max_delay_samples; // Maximum delay, i.e. size of allocated delay line. SAMPLE feedback; // Gain applied when feeding back output to input. SAMPLE filter_coef; // Echo is filtered by a two-point normalize IIR. This is the real pole location. } echo_config_t; // global synth state struct state { amy_config_t config; uint8_t running; uint8_t i2s_is_in_background; // Flag not to handle I2S in amy_update. float volume; float pitch_bend; // State of fixed dc-blocking HPF SAMPLE hpf_state; SAMPLE eq[3]; uint16_t delta_qsize; struct delta * delta_queue; // start of the sorted queue of deltas to execute. int16_t latency_ms; float tempo; uint32_t total_blocks; float time; uint8_t debug_flag; reverb_state_t reverb; chorus_config_t chorus; echo_config_t echo; // Transfer uint8_t transfer_flag; uint8_t * transfer_storage; uint32_t transfer_length_bytes; uint32_t transfer_stored_bytes; // using this for midi note before file load uint32_t transfer_file_handle; // using this for preset number before file load char transfer_filename[MAX_FILENAME_LEN]; // Sequencer uint32_t sequencer_tick_count; uint64_t next_amy_tick_us; uint32_t us_per_tick; sequence_entry_ll_t * sequence_entry_ll_start; }; // custom oscillator struct custom_oscillator { void (*init)(void); void (*deinit)(void); void (*note_on)(uint16_t osc, float freq); void (*note_off)(uint16_t osc); void (*mod_trigger)(uint16_t osc); SAMPLE (*render)(SAMPLE* buf, uint16_t osc); SAMPLE (*compute_mod)(uint16_t osc); }; // Shared structures extern struct synthinfo** synth; extern struct mod_synthinfo** msynth; extern struct state amy_global; extern output_sample_type * amy_out_block; extern output_sample_type * amy_in_block; extern output_sample_type * amy_external_in_block; int8_t global_init(amy_config_t c); void amy_deltas_reset(); void add_delta_to_queue(struct delta *d, struct delta **queue); void amy_add_event_internal(amy_event *e, uint16_t base_osc); void amy_event_to_deltas_queue(amy_event *e, uint16_t base_osc, struct delta **queue); int web_audio_buffer(float *samples, int length); void amy_render(uint16_t start, uint16_t end, uint8_t core); void print_osc_debug(int i /* osc */, bool show_eg); void show_debug(uint8_t type) ; void oscs_deinit() ; float freq_for_midi_note(float midi_note); float logfreq_for_midi_note(float midi_note); float midi_note_for_logfreq(float logfreq); float logfreq_of_freq(float freq); float freq_of_logfreq(float logfreq); float portamento_ms_to_alpha(uint16_t portamento_ms); uint16_t alpha_to_portamento_ms(float alpha); int8_t check_init(amy_err_t (*fn)(), const char *name); void * malloc_caps(uint32_t size, uint32_t flags); void config_reverb(float level, float liveness, float damping, float xover_hz); void config_chorus(float level, uint16_t max_delay, float lfo_freq, float depth); void config_echo(float level, float delay_ms, float max_delay_ms, float feedback, float filter_coef); void osc_note_on(uint16_t osc, float initial_freq); void chorus_note_on(float initial_freq); float map_60dB_to_01f(float lin); float map_01_to_60dBf(float log); SAMPLE log2_lut(SAMPLE x); SAMPLE exp2_lut(SAMPLE x); float atoff(const char *s); int8_t oscs_init(); void alloc_osc(int osc, uint8_t *max_num_breakpoints_per_bpset_or_null); void free_osc(int osc); void ensure_osc_allocd(int osc, uint8_t *max_num_breakpoints_per_bpset_or_null); void patches_init(int max_memory_patches); void patches_deinit(); void parse_algo_source(char* message, int16_t *vals); void hold_and_modify(uint16_t osc) ; void amy_execute_delta(); void amy_execute_deltas(); int16_t * amy_fill_buffer(); int16_t * amy_simple_fill_buffer(); // excute_deltas + render + fill_buffer uint32_t ms_to_samples(uint32_t ms) ; // API void amy_add_message(char *message); // Like amy_add_message but the data is treated as coming from an external // sysex source, so file transfer routing (transfer_flag) applies. void amy_add_message_from_sysex(char *message); void amy_add_event(amy_event *e); int amy_parse_message(char * message, int length, amy_event *e); void amy_start(amy_config_t); void amy_stop(); int16_t *amy_update(); // in api.c void amy_platform_init(); // in i2s.c void amy_platform_deinit(); // in i2s.c void amy_update_tasks(); // in i2s.c int16_t *amy_render_audio(); // in i2s.c size_t amy_i2s_write(const uint8_t *buffer, size_t nbytes); // in i2s.c amy_config_t amy_default_config(); void amy_clear_event(amy_event *e); amy_event amy_default_event(); uint32_t amy_sysclock(); int amy_get_output_buffer(output_sample_type * samples); int amy_get_input_buffer(output_sample_type * samples); void amy_set_external_input_buffer(output_sample_type * samples); #ifdef __EMSCRIPTEN__ void amy_start_web(); void amy_start_web_no_synths(); #endif // external functions void amy_process_event(amy_event *e); void amy_restart(); void amy_reset_oscs(); void amy_print_devices(); void amy_set_custom(struct custom_oscillator* custom); void amy_reset_sysclock(); extern int parse_int_list_message32(char *message, int32_t *vals, int max_num_vals, int32_t skipped_val); extern int parse_int_list_message16(char *message, int16_t *vals, int max_num_vals, int16_t skipped_val); extern void reset_osc_by_pointer(struct synthinfo *psynth, struct mod_synthinfo *pmsynth); extern void reset_osc(uint16_t i ); extern int midi_store_control_code(int channel, int code, int is_log, float min_val, float max_val, float offset_val, char *message); extern int midi_clear_control_code(int channel, int code); extern bool midi_fetch_control_code_command(int channel, int code, char *s, size_t len); extern void cc_mapping_debug(); extern void midi_mappings_init(); extern void midi_mappings_deinit(); extern void midi_clear_channel_mappings(int channel); extern float render_am_lut(float * buf, float step, float skip, float incoming_amp, float ending_amp, const float* lut, int16_t lut_size, float *mod, float bandwidth); extern void ks_init(); extern void ks_deinit(); extern void algo_init(); extern void algo_deinit(); extern void pcm_init(); extern void pcm_deinit(); extern void custom_init(); extern void custom_deinit(); void my_srand48(uint32_t seedval); void audio_in_note_on(uint16_t osc, uint8_t channel); void external_audio_in_note_on(uint16_t osc, uint8_t channel); SAMPLE render_audio_in(SAMPLE * buf, uint16_t osc, uint8_t channel); SAMPLE render_external_audio_in(SAMPLE *buf, uint16_t osc, uint8_t channel); extern SAMPLE render_ks(SAMPLE * buf, uint16_t osc); extern SAMPLE render_sine(SAMPLE * buf, uint16_t osc); #ifdef AMY_WAVETABLE extern SAMPLE render_wavetable(SAMPLE * buf, uint16_t osc); #endif extern SAMPLE render_fm_sine(SAMPLE *buf, uint16_t osc, SAMPLE *mod, SAMPLE feedback_level, uint16_t algo_osc, SAMPLE mod_amp); extern SAMPLE render_pulse(SAMPLE * buf, uint16_t osc); extern SAMPLE render_saw_down(SAMPLE * buf, uint16_t osc); extern SAMPLE render_saw_up(SAMPLE * buf, uint16_t osc); extern SAMPLE render_triangle(SAMPLE * buf, uint16_t osc); extern SAMPLE render_noise(SAMPLE * buf, uint16_t osc); extern SAMPLE render_envelope(SAMPLE *buf, uint16_t osc); extern SAMPLE render_pcm(SAMPLE * buf, uint16_t osc); extern SAMPLE render_algo(SAMPLE * buf, uint16_t osc, uint8_t core) ; extern SAMPLE render_partial(SAMPLE *buf, uint16_t osc) ; extern void partials_note_on(uint16_t osc); extern void partials_note_off(uint16_t osc); extern void interp_partials_note_on(uint16_t osc); extern void interp_partials_note_off(uint16_t osc); extern int interp_partials_max_partials_for_patch(int interp_partials_patch_number); extern void patches_load_patch(amy_event *e); extern void patches_event_has_voices(amy_event *e, struct delta **queue); extern void patches_reset_patch(int patch_number); extern void patches_reset(); extern int sprint_event(amy_event *e, char *s, size_t len, bool wirecode); extern void *yield_patch_events(uint16_t patch_number, struct amy_event *event, void *state); extern void *yield_synth_events(uint8_t synth, struct amy_event *event, bool include_fx, void *state); extern void *yield_synth_commands(uint8_t synth, char *s, size_t len, bool include_fx, void *state); extern int size_of_amy_event(void); extern struct delta **queue_for_patch_number(int patch_number); extern void update_num_oscs_for_patch_number(int patch_number); extern void all_notes_off(); extern void patches_debug(); extern void patches_store_patch(amy_event *e, char * message); #define _SYNTH_FLAGS_MIDI_DRUMS (0x01) #define _SYNTH_FLAGS_IGNORE_NOTE_OFFS (0x02) #define _SYNTH_FLAGS_NEGATE_PEDAL (0x04) extern int instruments_max_instruments(); extern void instruments_init(int num_instruments); extern void instruments_deinit(); extern void instruments_reset(); extern void instrument_add_new(int instrument_number, int num_voices, uint16_t *amy_voices, uint16_t patch_number, uint16_t oscs_per_voice, uint32_t flags); extern void instrument_release(int instrument_number); extern void instrument_change_number(int old_instrument_number, int new_instrument_number); #define _INSTRUMENT_NO_VOICE (255) extern uint16_t instrument_voice_for_note_event(int instrument_number, int note, bool is_note_off, bool *pstolen); extern bool instrument_number_exists(int instrument_number, const char *tag); extern int instrument_get_num_voices(int instrument_number, uint16_t *amy_voices); extern int instrument_all_notes_off(int instrument_number, uint16_t *amy_voices); extern int instrument_sustain(int instrument_number, bool sustain, uint16_t *amy_voices); extern int instrument_get_patch_number(int instrument_number); extern int instrument_get_oscs_per_voice(int instrument_number); extern uint32_t instrument_get_flags(int instrument_number); extern uint16_t instrument_noteon_delay_ms(int instrument_number); extern void instrument_set_noteon_delay_ms(int instrument_number, uint16_t noteon_delay_ms); extern bool instrument_grab_midi_notes(int instrument_number); extern void instrument_set_grab_midi_notes(int instrument_number, bool grab_midi_notes); extern int instrument_bank_number(int instrument_number); extern void instrument_set_bank_number(int instrument_number, int bank_number); extern SAMPLE render_partials(SAMPLE *buf, uint16_t osc); extern SAMPLE render_custom(SAMPLE *buf, uint16_t osc) ; extern SAMPLE compute_mod_pulse(uint16_t osc); extern SAMPLE compute_mod_noise(uint16_t osc); extern SAMPLE compute_mod_sine(uint16_t osc); extern SAMPLE compute_mod_saw_up(uint16_t osc); extern SAMPLE compute_mod_saw_down(uint16_t osc); extern SAMPLE compute_mod_triangle(uint16_t osc); extern SAMPLE compute_mod_pcm(uint16_t osc); extern SAMPLE compute_mod_custom(uint16_t osc); extern void sine_note_on(uint16_t osc, float initial_freq); extern void wavetable_note_on(uint16_t osc, float initial_freq); extern void fm_sine_note_on(uint16_t osc, uint16_t algo_osc); extern void saw_down_note_on(uint16_t osc, float initial_freq); extern void saw_up_note_on(uint16_t osc, float initial_freq); extern void triangle_note_on(uint16_t osc, float initial_freq); extern void pulse_note_on(uint16_t osc, float initial_freq); extern void noise_note_on(uint16_t osc); extern void pcm_note_on(uint16_t osc); extern void pcm_note_off(uint16_t osc); extern void custom_note_on(uint16_t osc, float freq); extern void custom_note_off(uint16_t osc); extern void partial_note_on(uint16_t osc); extern void partial_note_off(uint16_t osc); extern void algo_note_on(uint16_t osc, float freq); extern void algo_note_off(uint16_t osc); extern void ks_note_on(uint16_t osc); extern void ks_note_off(uint16_t osc); extern void sine_mod_trigger(uint16_t osc); extern void saw_down_mod_trigger(uint16_t osc); extern void saw_up_mod_trigger(uint16_t osc); extern void triangle_mod_trigger(uint16_t osc); extern void pulse_mod_trigger(uint16_t osc); extern void pcm_mod_trigger(uint16_t osc); extern void custom_mod_trigger(uint16_t osc); extern int16_t * pcm_load(uint16_t preset_number, uint32_t length, uint32_t samplerate, uint8_t channels, uint8_t midinote, uint32_t loopstart, uint32_t loopend); extern const int16_t *pcm_get_sample_ram_for_preset(uint16_t preset_number, uint32_t *length); extern int pcm_load_file(); extern void pcm_unload_preset(uint16_t preset_number); extern void pcm_unload_all_presets(); // filters extern void filters_init(); extern void filters_deinit(); extern SAMPLE filter_process(SAMPLE * block, uint16_t osc, SAMPLE max_value); extern void parametric_eq_process(SAMPLE *block); extern void reset_filter(uint16_t osc); extern void reset_parametric(void); extern float dsps_sqrtf_f32_ansi(float f); extern int8_t dsps_biquad_gen_lpf_f32(SAMPLE *coeffs, float f, float qFactor); extern int8_t dsps_biquad_f32_ansi(const SAMPLE *input, SAMPLE *output, int len, SAMPLE *coef, SAMPLE *w); extern SAMPLE scan_max(SAMPLE* block, int len); // Use the esp32 optimized biquad filter if available #ifdef ESP_PLATFORM // On Arduino, something doesn't allow ESP_TASK_PRIO_MAX in tasks #ifdef ARDUINO #define AMY_RENDER_TASK_PRIORITY (20) #define AMY_FILL_BUFFER_TASK_PRIORITY (20) #else #define AMY_RENDER_TASK_PRIORITY (ESP_TASK_PRIO_MAX) #define AMY_FILL_BUFFER_TASK_PRIORITY (ESP_TASK_PRIO_MAX) #endif #define AMY_RENDER_TASK_COREID (0) #define AMY_FILL_BUFFER_TASK_COREID (1) #define AMY_RENDER_TASK_STACK_SIZE (12 * 1024) // 8 #define AMY_FILL_BUFFER_TASK_STACK_SIZE (16 * 1024) // 16 #define AMY_RENDER_TASK_NAME "amy_r_task" #define AMY_FILL_BUFFER_TASK_NAME "amy_fb_task" #include "esp_err.h" #endif // envelopes extern SAMPLE compute_breakpoint_scale(uint16_t osc, uint8_t bp_set, uint16_t sample_offset); extern SAMPLE compute_mod_scale(uint16_t osc); extern SAMPLE compute_mod_value(uint16_t mod_osc); extern void retrigger_mod_source(uint16_t osc); // deltas extern void deltas_pool_init(); extern void deltas_pool_free(); extern struct delta *delta_get(struct delta *d); // clone existing delta values if d not NULL. extern struct delta *delta_release(struct delta *d); // returns d->next of the node just released. extern void delta_release_list(struct delta *d); // releases a whole list of deltas. extern int32_t delta_list_len(struct delta *d); extern int32_t delta_num_free(); // The size of the remaining pool. extern int peek_stack(const char *tag); #endif ================================================ FILE: src/amy_connector.js ================================================ // amy_connector.js // helpers for JS to communicate with AMY, including webMIDI var amy_add_message = null; var amy_reset_sysclock = null var amy_module = null; var amy_started = false; var amy_live_start_web = null; var audio_started = false; var amy_sysclock = null; var amy_module = null; var midiOutputDevice = null; var midiInputDevice = null; var amy_audioin_toggle = false; // Once AMY module is loaded, register its functions and start AMY (not yet audio, you need to click for that) amyModule().then(async function(am) { amy_live_start_web = am.cwrap( 'amy_live_start_web', null, null, {async: true} ); amy_live_start_web_audioin = am.cwrap( 'amy_live_start_web_audioin', null, null, {async: true} ); amy_live_stop = am.cwrap( 'amy_live_stop', null, null, {async: true} ); amy_start_web = am.cwrap( 'amy_start_web', null, null ); amy_start_web_no_synths = am.cwrap( 'amy_start_web_no_synths', null, null ); amy_add_message = am.cwrap( 'amy_add_message', null, ['string'] ); amy_reset_sysclock = am.cwrap( 'amy_reset_sysclock', null, null ); amy_ticks = am.cwrap( 'sequencer_ticks', 'number', [null] ); amy_sysclock = am.cwrap( 'amy_sysclock', 'number', [null] ); amy_process_single_midi_byte = am.cwrap( 'amy_process_single_midi_byte', null, ['number, number'] ); // If Godot bridge is present, let it control startup with config. // Otherwise start with defaults (standalone REPL mode). if (typeof window !== 'undefined' && window._amy_godot_bridge) { window._amy_godot_start_web = amy_start_web; window._amy_godot_start_web_no_synths = amy_start_web_no_synths; } else { amy_start_web(); } amy_module = am; }); async function amy_js_start() { // Don't run this twice if(amy_started) return; await start_midi(); await sleep_ms(200); // Start the audio worklet (miniaudio) if (amy_audioin_toggle) { await amy_live_start_web_audioin(); } else { await amy_live_start_web(); } await sleep_ms(200); amy_started = true; } async function setup_midi_devices() { var midi_in = document.amyboard_settings.midi_input; var midi_out = document.amyboard_settings.midi_output; if(WebMidi.inputs.length > midi_in.selectedIndex) { if(midiInputDevice != null) midiInputDevice.destroy(); midiInputDevice = WebMidi.getInputById(WebMidi.inputs[midi_in.selectedIndex].id); midiInputDevice.addListener("midimessage", e => { for(byte in e.message.data) { amy_process_single_midi_byte(e.message.data[byte], 1); } }); } if(WebMidi.outputs.length > midi_out.selectedIndex) { if(midiOutputDevice != null) midiOutputDevice.destroy(); midiOutputDevice = WebMidi.getOutputById(WebMidi.outputs[midi_out.selectedIndex].id); } } async function start_midi() { function onEnabled() { // Populate the dropdowns var midi_in = document.amyboard_settings.midi_input; var midi_out = document.amyboard_settings.midi_output; if(WebMidi.inputs.length>0) { midi_in.options.length = 0; WebMidi.inputs.forEach(input => { midi_in.options[midi_in.options.length] = new Option("MIDI in: " + input.name); }); } if(WebMidi.outputs.length>0) { midi_out.options.length = 0; WebMidi.outputs.forEach(output => { midi_out.options[midi_out.options.length] = new Option("MIDI out: "+ output.name); }); } // First run setup setup_midi_devices(); } if(typeof WebMidi != 'undefined') { if(WebMidi.supported) { WebMidi .enable({sysex:true}) .then(onEnabled) .catch(err => console.log("MIDI: " + err)); } else { document.getElementById('midi-input-panel').style.display='none'; document.getElementById('midi-output-panel').style.display='none'; } } } async function sleep_ms(ms) { await new Promise((r) => setTimeout(r, ms)); } async function toggle_audioin() { if(!amy_started) await sleep_ms(1000); await amy_live_stop(); if (document.getElementById('amy_audioin').checked) { amy_audioin_toggle = true; await amy_live_start_web_audioin(); } else { amy_audioin_toggle = false; await amy_live_start_web(); } } ================================================ FILE: src/amy_fixedpoint.h ================================================ // amy_fixedpoint.h - common definitions for fixed-point arithmetic. // We use 3 fixed-point formats: // - Lookup tables are stored as int16_t, using s.15 (one sign bit, then 15 bits expressing the fractional part, for [-1.0, 1.0) range). // - Oscillator phases and increments are stored as int32_t using s.31 (since these implicitly cannot exceed 1.0) // - Samples and other arguments are stored as int32_t using s8.23 (23 fractional bits, range [-256.0, 256.0) to permit headroom. // s.15 conforms to ANSI "_Fract" type, s.31 to "long _Fract", and s8.23 to "long _Accum" // (see https://www.open-std.org/jtc1/sc22/wg14/www/docs/n1169.pdf). // Fixed point multiply is accomplished by standard integer multiply followed by a right-shift to re-center the decimal point. // In general, (w.x) * (y.z) will yeild a (w+y).(x+z) result, which will need to be shifted right by, for instance z bits to // regain a *.x representation. For example, multiplying two s8.23 values, using an int32 x int32 -> int64 multiplication, // would give a s16.46 result, which would need to be right-shifted by 23 bits to realign the "decimal point" to be left of the // 23rd bit. // // In this example, even after the shift, we'd still have potentially 16 significant bits above the point, which might not // fit in the 8 bits for the integral part of s8.23 (depending on the actual values of the original factors). And if the multiply // is actuall int32 x int32 -> int32 (a common case), that overflow can happen during the multiply itself. // // The overall right-shift needed to realign the point can be applied either before or after the multiplication as long as the total // number of bits is achieved, where the total shift is the sum of the shifts to each input factor and the output result. Applying // shifts to a factor before the multiply discards that many bits of resolution (the bits at the bottom that are shifted out before // calculation); applying it after multiplication limits the range of the result (since that many of the top bits will be // uninformative/sign extension). In general, then, we want to apply enough shifts to the factors to avoid overflow in the multiply, // but otherwise as few as possible. // By limiting ourselves to the 32x32 -> 32 hardware multiplier in the RP2040, we have to decide which parameters to shift. // Without knowing anything about the input values, we should shift down the bits on the operands, so the result will not overflow // and will be correctly aligned on output. This means discarding lots of input bits, however, which could be harmful if we are // multiplying a large and a small value: right-shifting the small value will lose resolution, and after multiplying by the large // value, that lost resolution could again become significant. // Without assumptions, we apply the right-shift to the operands before multiplication, so the result needs no further adjustment: // mul_kk(a, b) = ((a >> 12) * (b >> 11) // If, however, we assume the result of the product is not going to exceed some value, we can reserve some of the right-shift for // the result, preserving more bits for the input. For instance, if we assume an s8.23 result has its magnitude bounded by 16 // (4 bits left of the point), we could do // mul_kk(a, b) = ((a >> 10) * (b >> 9)) >> 4. // If we further assume that a is large but b is always less than 1, we can prefer to shift it down less, e.g. // mul_kk(a, b) = ((a >> 12) * (b >> 7)) >> 4 // If we know that a and b are smaller than 1 (15 bits each), the result must also be less than 1, so we can sign-extend the // top 8 bits: // mul_kk(a, b) = ((a >> 8) * (b >> 7)) >> 8 // In general, then, the multiply operation has three parameters: // - max value of result -> number of right-shift bits applied to result // - resolution sensitivity of first factor -> right-shift applied before mult // - resolution sensitivity of second factor -> right-shift applied to it before mult // These parameters are in fact constrained since the total number of right-shifts must match the needed alignment. // We can directly parameterize these as: // accum mulN_kAkB(x, y) { return ( (x >> A) * (y >> B) ) >> N; } // where N + A + B must equal the number of fraction bits (23). // How best to express these? // - we can define a range, e.g. -16 to 16, dictating the number of bits applied after multiplication, and thus the // remaining number of bits that need to be applied to the operands. // - we can define a "sensitive" arg, meaning we discard fewer bits for that arg. But that makes the other arg less sensitive. // ROUNDING: If we use integer multiplication, then shift down the result to realign, we are effectively truncating the bit // representation. For positive numbers, this is rounding down: both (6 >> 1) and (7 >> 1) give 3. For negative values, // this is actually rounding towards negative infinity: In 8 bits, -6 is 0xfa; sign-extended shift right is 0xfd or -3, // but -7 is 0xf9 and its sign-extended shift right is 0xfc or -4. // // This systematic bias can cause problems, particularly in feedback systems (like IIR filter). We can restore conventional // rounding by adding 1 to the value just before the final right-shift: ((6 + 1) >> 1) is 3, but ((7 + 1) >> 1) is 4. // (-6 + 1) >> 1 = -3 and (-7 + 1) >> 1 = -4. When the final right-shift is by k bits, we should add (1 << (k - 1)) // immediately before the shift to achieve rounding. But this adds several instructions to each multiply, so we only // do it for the multplies used in digital filtering, where failure to round can cause issues. #ifndef AMY_USE_FIXEDPOINT //#warning "floating point calc" #define ARITH "float" #define GENFXP float #define LUTSAMPLE int16_t #define PHASOR float #define SAMPLE float #define S2P(s) (s) #define P2S(p) (p) #define L2S(l) ((l) / 32768.0f) #define S2L(s) ((int)floorf(s * 32768.0f)) #define S2F(s) (s) #define F2S(f) (f) #define G2F(g) (g) #define F2G(f) (f) #define P2F(p) (p) #define F2P(f) ((f) - floorf(f)) #define AMY_I2S(i, b) ((i) / (float)(1 << (b))) // Integer part of s interpreted as a proportion of a b-bit table. #define INT_OF_S(s, b) ((int)floorf((s) * (float)(1 << (b)))) #define S_FRAC_OF_S(s, b) ((s) * (1 << (b)) - floorf((s) * (1 << (b)))) #define MUL0_SS(a, b) ((a) * (b)) #define MUL4_SS(a, b) ((a) * (b)) #define MUL8_SS(a, b) ((a) * (b)) #define MUL8F_SS(a, b) ((a) * (b)) #define MUL4E_SS(a, b) ((a) * (b)) #define MUL4_SP_S(a, b) ((a) * (b)) #define SMULR6(a, b) ((a) * (b)) #define SMULR7(a, b) ((a) * (b)) #define SHIFTR(s, b) ((s) * exp2f(-(b))) #define SHIFTL(s, b) ((s) * exp2f(b)) #define INT_OF_P(p, b) (((int)floorf((p) * (float)(1 << (b))) + (1 << (b))) % (1 <<(b))) #define I2P(i, b) ((i) / (float)(1 << (b))) #define S_FRAC_OF_P(p, b) ((p) * (1 << (b)) - floorf((p) * (1 << (b)))) #define P_WRAPPED_SUM(p, i) ((p) + (i) - floorf((p) + (i))) #else //#warning "FIXED point calc" #define ARITH "FIXED" typedef int16_t s_15; // s.15 LUT sample typedef int32_t s_31; // s.31 phasor typedef int32_t s8_23; // s8.23 sample typedef int32_t s16_15; // s16.15 general #define LUTSAMPLE s_15 #define PHASOR s_31 #define SAMPLE s8_23 #define GENFXP s16_15 // "65536 Hz should be enough for anyone?" -- dpwe #define L_FRAC_BITS 15 #define P_FRAC_BITS 31 #define S_FRAC_BITS 23 #define G_FRAC_BITS 15 // Convert a SAMPLE to a PHASOR #define S2P(s) ((s) << (P_FRAC_BITS - S_FRAC_BITS)) // Convert a PHASOR to a SAMPLE #define P2S(p) ((p) >> (P_FRAC_BITS - S_FRAC_BITS)) // Convert a LUTSAMPLE (s.15) to a SAMPLE (s8.23) #define L2S(l) (((int32_t)(l)) << (S_FRAC_BITS - L_FRAC_BITS)) // L is also the format used in the final output. #define S2L(s) ((s) >> (S_FRAC_BITS - L_FRAC_BITS)) // s >> 8 // Scale an integer into a SAMPLE, where integer is a numerator and 2**B is denominator. #define AMY_I2S(I, B) ((I) << (S_FRAC_BITS - (B))) // Regard SAMPLE as index into B-bit table, return integer (floor) index, strip sign bit. #define INT_OF_S(S, B) (int32_t)(S >> (S_FRAC_BITS - B)) // Fractonal part of SAMPLE within a B bit table, returns a SAMPLE. // Add 1 to B shift-up and cast to uint32_t to strip sign bit, pad a zero sign bit on way down. #define S_FRAC_OF_S(S, B) (((S) & ((1 << (S_FRAC_BITS - (B))) - 1)) << (B)) // Convert between SAMPLE and float #define S2F(s) ((float)(s) / (float)(1 << S_FRAC_BITS)) #define F2S(f) (SAMPLE)((f) * (float)(1 << S_FRAC_BITS)) // Convert between GENFXP and float #define G2F(s) ((float)(s) / (float)(1 << G_FRAC_BITS)) #define F2G(f) (GENFXP)((f) * (float)(1 << G_FRAC_BITS)) // Convert between PHASOR and float // 1 << P_FRAC_BITS is 1 << 31 which actually flips to (-2^31). // So make the constant one less and do the last power of 2 in float. #define P2F(s) ((float)(s) / (2.0 * (float)(1 << (P_FRAC_BITS - 1)))) #define F2P(f) ((PHASOR)((f) * 2.0 * (float)(1 << (P_FRAC_BITS - 1)))) // Fixed-point multiply routines #define FXMUL_TEMPLATE(a, b, a_bitloss, b_bitloss, reqd_bitloss) ((((a) >> a_bitloss) * ((b) >> b_bitloss)) >> (reqd_bitloss - a_bitloss - b_bitloss)) // from https://colab.research.google.com/drive/1_uQto5WSVMiSPHQ34cHbCC6qkF614EoN#scrollTo=73JbLFhg44QG static inline SAMPLE SMULR6(SAMPLE a, SAMPLE b) { // s8.23 fixed-point multiplication with rounding, 1 zero on output (-128..128) SAMPLE r = 1 + ((a + (1 << 10)) >> 11) * ((b + (1 << 10)) >> 11); return r >> 1; } static inline SAMPLE SMULR7(SAMPLE a, SAMPLE b) { // Rounding on input and output; 3 zeros on output (so output is limited to -32.0 .. 32.0). SAMPLE r = 4 + ((a + (1 << 9)) >> 10) * ((b + (1 << 9)) >> 10); return r >> 3; } // Multiply two SAMPLE values when the result will always be [-1.0, 1.0). #define MUL0_SS(a, b) FXMUL_TEMPLATE(a, b, 8, 7, S_FRAC_BITS) // 8+7 = 15, so additional 8 bits shift right on output to make 23 req'd total. // Multiply two SAMPLE values when the result will always be [-16.0, 16.0). #define MUL4_SS(a, b) FXMUL_TEMPLATE(a, b, 10, 9, S_FRAC_BITS) // 10+9 = 19, so result is >>4, leaving 4 bits integer part. // Multiply two SAMPLE values when the result will always be [-64.0, 64.0). // Assume first arg is an unscaled sample and second is an amplitude which can be much larger. // This is the one used in the interpolating LUT oscillators for (sample, amp) #define MUL6A_SS(a, b) FXMUL_TEMPLATE(a, b, 8, 13, S_FRAC_BITS) // 8+13 = 21, so result is >>2, leaving 6 bits integer part. // Output in [-32, 32), more resolution kept for first arg (sample) than 2nd (scale) #define MUL5A_SS(a, b) FXMUL_TEMPLATE(a, b, 9, 11, S_FRAC_BITS) // 9+11 = 20, so result is >>3, leaving 5 bits integer part. // Multiply two SAMPLE values and allow result to occupy full [-256, 256) range #define MUL8_SS(a, b) FXMUL_TEMPLATE(a, b, 12, 11, S_FRAC_BITS) // 12+11 = 23, so no more shift on result. // Shifts #define SHIFTR(s, b) ((s) >> (b)) #define SHIFTL(s, b) ((s) << (b)) // Regard PHASOR as index into B-bit table, return integer (floor) index, strip sign bit. #define INT_OF_P(P, B) (int32_t)((((uint32_t)((P) << 1)) >> (P_FRAC_BITS + 1 - (B)))) // Scale an integer into a phasor, where integer is index into a B-bit table. #define I2P(I, B) ((I) << (P_FRAC_BITS - (B))) // Fractonal part of phasor within B bits, returns a SAMPLE. // Add 1 to B shift-up and cast to uint32_t to strip sign bit, pad a zero sign bit on way down. #define S_FRAC_OF_P(P, B) (int32_t)(((uint32_t)(((P) << ((B) + 1)))) >> (1 + P_FRAC_BITS - S_FRAC_BITS)) // Increment phasor but wrap at +1.0 #define P_WRAPPED_SUM(P, I) (int32_t)(((uint32_t)((((uint32_t)(P)) + ((uint32_t)(I))) << 1)) >> 1) #endif // AMY_USED_FIXEDPOINT // Fixed-point lookup table structure (copied from e.g. sine_lutset_fxpt.h). #ifndef LUTENTRY_FXPT_DEFINED #define LUTENTRY_FXPT_DEFINED typedef struct { const int16_t *table; int table_size; int log_2_table_size; int highest_harmonic; float scale_factor; } lut_entry_fxpt; #endif // LUTENTRY_FXPT_DEFINED #define LUT lut_entry_fxpt ================================================ FILE: src/amy_midi.c ================================================ // midi.c // i deal with parsing and receiving midi on many platforms #include "amy.h" #if defined(TULIP) || defined(AMYBOARD) #include "py/runtime.h" // Forward-declare to avoid including the shared tinyusb header path. Defined // in micropython/shared/tinyusb/mp_usbd_runtime.c and safe to call from the MP // main thread to drain USB events (e.g. flush the MIDI IN endpoint FIFO). extern void mp_usbd_task(void); #endif #ifdef __EMSCRIPTEN__ #include #endif #if defined(ESP_PLATFORM) #include "freertos/FreeRTOS.h" #include "freertos/task.h" #endif #if (defined ARDUINO_ARCH_RP2040) || (defined ARDUINO_ARCH_RP2350) //#define TUD_USB_GADGET #include "tusb.h" #include "class/midi/midi.h" #include "class/midi/midi_device.h" #include "pico/stdlib.h" #include "hardware/uart.h" #include "hardware/irq.h" #endif #include "amy_midi.h" uint8_t current_midi_message[3] = {0,0,0}; uint8_t midi_message_slot = 0; uint8_t sysex_flag = 0; static uint8_t external_midi_sync_enabled = 0; void amy_external_midi_sync(uint8_t enabled) { external_midi_sync_enabled = enabled ? 1 : 0; } #if 0 static void debug_print_midi_hex(const uint8_t *data, uint32_t len, uint8_t sysex) { fprintf(stderr, "MIDI %s len=%u:", sysex ? "sysex" : "msg", (unsigned)len); for (uint32_t i = 0; i < len; ++i) { fprintf(stderr, " %02X", data[i]); } fprintf(stderr, "\n"); } #endif // Send a MIDI note on OUT void amy_send_midi_note_on(uint16_t osc) { // don't forward on a note coming in through MIDI IN if(synth[osc]->note_source != NOTE_SOURCE_MIDI) { uint8_t bytes[3]; bytes[0] = 0x90; bytes[1] = (uint8_t)roundf(synth[osc]->midi_note); bytes[2] = (uint8_t)roundf(synth[osc]->velocity*127.0f); midi_out(bytes, 3); } } // Send a MIDI note off OUT void amy_send_midi_note_off(uint16_t osc) { // don't forward on a note coming in through MIDI IN if(synth[osc]->note_source != NOTE_SOURCE_MIDI) { uint8_t bytes[3]; bytes[0] = 0x80; bytes[1] = (uint8_t)roundf(synth[osc]->midi_note); bytes[2] = (uint8_t)roundf(synth[osc]->velocity*127.0f); midi_out(bytes, 3); } } // Given a MIDI note on IN, create a AMY message on that instrument and play it void amy_received_note_on(uint8_t channel, uint8_t note, uint8_t vel, uint32_t time) { if (!instrument_grab_midi_notes(channel)) return; amy_event e = amy_default_event(); e.time = time; e.synth = channel; e.note_source = NOTE_SOURCE_MIDI; e.midi_note = note; e.velocity = ((float)vel/127.0f); amy_add_event(&e); } // Given a MIDI note off IN, create a AMY message on that instrument and play it void amy_received_note_off(uint8_t channel, uint8_t note, uint8_t vel, uint32_t time) { if (!instrument_grab_midi_notes(channel)) return; amy_event e = amy_default_event(); e.time = time; e.synth = channel; e.note_source = NOTE_SOURCE_MIDI; e.midi_note = note; e.velocity = 0; amy_add_event(&e); } void amy_received_control_change(uint8_t channel, uint8_t control, uint8_t value, uint32_t time) { if (control == 0) { // Bank select coarse. instrument_set_bank_number(channel, value); } else if (control == 7) { // Use CC 7 for global volume control (on any channel). //amy_event e = amy_default_event(); //e.volume = (float)value/12.7; // Max volume is 10. //e.note_source = NOTE_SOURCE_MIDI; //amy_add_event(&e); amy_global.volume = (float)value/12.7; // Max volume is 10. } } void amy_received_program_change(uint8_t channel, uint8_t program, uint32_t time) { amy_event e = amy_default_event(); e.time = time; e.synth = channel; e.note_source = NOTE_SOURCE_MIDI; // MIDI patches are in blocks of 128, potentially set by an earlier CC0. int bank_number = instrument_bank_number(channel); if (bank_number < 0) { // If the bank hasn't been set, stay within the block of 128 of the current patch // (so e.g. DX7 voices remain DX7). bank_number = (instrument_get_patch_number(e.synth) & 0xFF80) >> 7; } e.patch_number = program + 128 * bank_number; if (channel != AMY_MIDI_CHANNEL_DRUMS) { // What would that even mean? amy_add_event(&e); } } void amy_received_pedal(uint8_t channel, uint8_t value, uint32_t time) { amy_event e = amy_default_event(); e.time = time; e.synth = channel; e.note_source = NOTE_SOURCE_MIDI; e.pedal = value; amy_add_event(&e); } void amy_received_all_notes_off(uint8_t channel, uint32_t time) { amy_event e = amy_default_event(); e.time = time; e.synth = channel; e.note_source = NOTE_SOURCE_MIDI; // All notes off is indicated by vel = 0 and note = 0 e.velocity = 0; e.midi_note = 0; amy_add_event(&e); } void amy_received_pitch_bend(uint8_t channel, uint8_t low_byte, uint8_t high_byte, uint32_t time) { amy_event e = amy_default_event(); e.time = time; // Currently, pitch bend is global and not applied per-channel, but preserve the info. e.synth = channel; e.note_source = NOTE_SOURCE_MIDI; // The integer range is -8192 to 8191, the float range is -1/6th to +1/6th, // units are octaves, so +/- 2 semitones. e.pitch_bend = ((float)(((int)((high_byte << 7) | low_byte)) - 8192)) / (6.0f * 8192.0f); amy_add_event(&e); } // I'm called when we get a fully formed MIDI message from any interface -- usb, gadget, uart, mac, and either sysex or normal void amy_event_midi_message_received(uint8_t * data, uint32_t len, uint8_t sysex, uint32_t time) { if(!sysex) { uint8_t status_byte = data[0]; uint8_t status = status_byte & 0xF0; uint8_t channel = status_byte & 0x0F; // Do the AMY instrument things here if(status == 0x80) amy_received_note_off(channel+1, data[1], data[2], time); else if(status == 0x90) amy_received_note_on(channel+1, data[1], data[2], time); else if(status == 0xB0 && data[1] == 0x40) amy_received_pedal(channel+1, data[2], time); else if(status == 0xB0 && data[1] == 0x7B) amy_received_all_notes_off(channel+1, time); else if(status == 0XB0) amy_received_control_change(channel+1, data[1], data[2], time); else if(status == 0xC0) amy_received_program_change(channel+1, data[1], time); else if(status == 0xE0) amy_received_pitch_bend(channel+1, data[1], data[2], time); else if(status_byte == 0xFA) sequencer_midi_start(); else if(status_byte == 0xFC) sequencer_midi_stop(); } // Also send the external hooks if set if(amy_global.config.amy_external_midi_input_hook != NULL) { amy_global.config.amy_external_midi_input_hook(data, len, sysex); } // Update web MIDI out hook if set #ifdef __EMSCRIPTEN__ EM_ASM( if(typeof amy_external_midi_input_js_hook === 'function') { amy_external_midi_input_js_hook(HEAPU8.subarray($0, $0+$1), $1, $2); }, data, len, sysex); #endif } void midi_clock_received() { if (external_midi_sync_enabled) { sequencer_midi_clock_tick(); } } /* 3 0x8X - note off | note number | velocity 3 0x9X - note on | note number | velocity 3 0xAX - Paftertouch | note number | pressure 3 0xBX - CC | controller # | value 2 0xCX - PC | program | XXXX 2 0xDX - Caftertouch | pressure | XXXX 3 0xEX - pitch bend | LSB. | MSB X 0xF0 - sysex start| ... wait until F7 2 0xF1 - time code | data 3 0xF2 song pos | lsb | msb 2 0xF3 song sel | data 1 0xF4 reserved | XXXX 1 0xF5 reserved. | XXXX 1 0xF6 tune request | XXXX X 0xF7 end of sysex | XXXX 1 0xF8 timing clock | XXXX 1 0xF9 reserved. | XXXX 1 0xFA start | XXXX 1 0xFB continue | XXXX 1 0xFC stop | XXXX 1 0xFD reserved | XXXX 1 0xFE sensing | XXXX 1 0xFF reset | XXXX */ uint16_t sysex_len = 0; #if defined(TULIP) || defined(AMYBOARD) extern const mp_obj_fun_builtin_var_t tulip_amy_send_sysex_obj; #endif uint8_t * sysex_buffer = NULL; // Ring buffer of sysex payload snapshots for deferred MicroPython processing. // parse_sysex() copies each payload into a separate slot so that a new sysex // arriving before the scheduled callback fires doesn't overwrite the previous // message. This matters when the sketch's loop() is CPU-heavy and the // mp_sched callback is delayed. char * sysex_message_copies[SYSEX_COPY_SLOTS] = {NULL}; uint8_t sysex_copy_write_idx = 0; // MIDI task writes here uint8_t sysex_copy_read_idx = 0; // MP callback reads here void parse_sysex() { uint32_t time = AMY_UNSET_VALUE(time); if(sysex_len>3) { // let's use 0x00 0x03 0x45 for SPSS if(sysex_buffer[0] == 0x00 && sysex_buffer[1] == 0x03 && sysex_buffer[2] == 0x45) { sysex_buffer[sysex_len] = 0; // zB[mode]: Reboot. Handled in pure C — no mp_sched_schedule // needed, works even when loop() is hogging the scheduler. // zBZ / zB0Z — bootloader mode (skip sketch.py) // zB1Z — normal reboot (run sketch.py) // zB2Z — ROM download/flash mode if (sysex_len > 4 && sysex_buffer[3] == 'z' && sysex_buffer[4] == 'B') { uint8_t mode = 0; if (sysex_len > 5 && sysex_buffer[5] >= '0' && sysex_buffer[5] <= '9') { mode = sysex_buffer[5] - '0'; } if (amy_global.config.amy_external_reboot_hook) { amy_global.config.amy_external_reboot_hook(mode); } sysex_len = 0; return; } // zI: Ping/identity — reply with a short sysex so the web side // knows the board is alive and ready. Pure C, no scheduler needed. if (sysex_len > 4 && sysex_buffer[3] == 'z' && sysex_buffer[4] == 'I') { uint8_t frame[] = { 0xF0, 0x00, 0x03, 0x45, 'O', 'K', 0xF7 }; midi_out(frame, sizeof(frame)); sysex_len = 0; return; } // For Micropython hosted systems, we run MIDI on a separate "thread" (task) // than MP, so just calling amy_send_message here can fail if it needs to access // underlying MP resources. So we schedule it to run in the MP main loop instead. // Each message gets its own ring-buffer slot so a fast-arriving next sysex // doesn't overwrite an unprocessed message. #if defined(TULIP) || defined(AMYBOARD) { // NOTE: ACK is sent from the callback (tulip_amy_send_sysex) // AFTER the message is processed, not here in parse_sysex. // This ensures the sender only proceeds once the ring buffer // slot has been drained — receiving the ACK here would just // confirm receipt, allowing the ring buffer to overflow if // callbacks are slow. // // Do NOT stop the sequencer here. We used to do that to // prevent loop() from stealing MP scheduler slots during // large file transfers, but it caused sequencer_midi_start // to reset next_amy_tick_us on every sysex, effectively // speeding up the sequencer when knob updates arrive. char *slot = sysex_message_copies[sysex_copy_write_idx]; if(slot) { uint16_t payload_len = sysex_len - 3; memcpy(slot, (char*)sysex_buffer + 3, payload_len); slot[payload_len] = '\0'; sysex_copy_write_idx = (sysex_copy_write_idx + 1) % SYSEX_COPY_SLOTS; } mp_sched_schedule(MP_OBJ_FROM_PTR(&tulip_amy_send_sysex_obj), mp_const_none); } #else amy_add_message((char*)sysex_buffer+3); #endif sysex_len = 0; // handled } else { amy_event_midi_message_received(sysex_buffer, sysex_len, 1, time); } } } void convert_midi_bytes_to_messages(uint8_t * data, size_t len, uint8_t usb) { // i take any amount of bytes and add messages // remember this can start in the middle of a midi message, so act accordingly // running status is handled by keeping the status byte around after getting a message. // remember that USB midi always comes in groups of 3 here, even if it's just a one byte message // so we have USB (and mac IAC) set a usb flag so we know to end the loop once a message is parsed uint32_t time = AMY_UNSET_VALUE(time); for(size_t i=0;i 0) { convert_midi_bytes_to_messages(data,length,0); } } void run_midi_task() { while(1) { esp_poll_midi(); #if defined (AMYBOARD) || defined(AMYBOARD_ARDUINO) check_tusb_midi(); #endif } // end loop forever } void run_midi() { if (sysex_buffer == NULL) { sysex_buffer = malloc_caps(MAX_SYSEX_BYTES, amy_global.config.ram_caps_sysex); for (int i = 0; i < SYSEX_COPY_SLOTS; i++) { sysex_message_copies[i] = malloc_caps(MAX_SYSEX_BYTES, amy_global.config.ram_caps_sysex); } #if defined(AMYBOARD_ARDUINO) // Initialize TinyUSB with amy's MIDI+CDC descriptors before starting MIDI polling if(amy_global.config.midi & AMY_MIDI_IS_USB_GADGET) { amy_arduino_usb_setup(); } #endif if(amy_global.config.midi & AMY_MIDI_IS_UART) { esp_init_midi(); if (amy_global.config.platform.multithread) { xTaskCreatePinnedToCore(run_midi_task, MIDI_TASK_NAME, (MIDI_TASK_STACK_SIZE) / sizeof(StackType_t), NULL, MIDI_TASK_PRIORITY, &midi_handle, MIDI_TASK_COREID); } // otherwise esp_poll_midi is called from amy_update_tasks() } } } void stop_midi() { if(amy_global.config.midi & AMY_MIDI_IS_UART) { if (amy_global.config.platform.multithread) { vTaskDelete(midi_handle); } esp_deinit_midi(); } free(sysex_buffer); sysex_buffer = NULL; for (int i = 0; i < SYSEX_COPY_SLOTS; i++) { free(sysex_message_copies[i]); sysex_message_copies[i] = NULL; } } #endif #if (defined ARDUINO_ARCH_RP2040) || (defined ARDUINO_ARCH_RP2350) uart_inst_t * rp_get_uart(int8_t index) { if(index==0) return uart0; if(index==1) return uart1; return NULL; } // RX interrupt handler void on_pico_uart_rx() { const int midi_buffer_size = 16; uint8_t bytes[midi_buffer_size]; uint8_t i = 0; while (uart_is_readable(rp_get_uart(amy_global.config.midi_uart)) && i < midi_buffer_size) { uart_read_blocking (rp_get_uart(amy_global.config.midi_uart), bytes + i, 1); i++; } //if (i >= midi_buffer_size) // fprintf(stderr, "midi_buffer_size %d of %d\n", i, midi_buffer_size); convert_midi_bytes_to_messages(bytes,i,0); } extern void pico_setup_midi(); extern void pico_teardown_midi(); void run_midi() { if (sysex_buffer == NULL) { sysex_buffer = malloc_caps(MAX_SYSEX_BYTES, amy_global.config.ram_caps_sysex); for (int i = 0; i < SYSEX_COPY_SLOTS; i++) { sysex_message_copies[i] = malloc_caps(MAX_SYSEX_BYTES, amy_global.config.ram_caps_sysex); } if(amy_global.config.midi & AMY_MIDI_IS_UART) { uart_init(rp_get_uart(amy_global.config.midi_uart), 31250); gpio_set_function(amy_global.config.midi_out, UART_FUNCSEL_NUM(rp_get_uart(amy_global.config.midi_uart), amy_global.config.midi_out)); gpio_set_function(amy_global.config.midi_in, UART_FUNCSEL_NUM(rp_get_uart(amy_global.config.midi_uart), amy_global.config.midi_in)); uart_set_hw_flow(rp_get_uart(amy_global.config.midi_uart), false, false); uart_set_format(rp_get_uart(amy_global.config.midi_uart), 8, 1, UART_PARITY_NONE); uart_set_fifo_enabled(rp_get_uart(amy_global.config.midi_uart), true); } else if(amy_global.config.midi & AMY_MIDI_IS_USB_GADGET) { pico_setup_midi(); } } } void stop_midi() { if (sysex_buffer) { if(amy_global.config.midi & AMY_MIDI_IS_UART) { uart_set_fifo_enabled(rp_get_uart(amy_global.config.midi_uart), false); uart_deinit(rp_get_uart(amy_global.config.midi_uart)); } else if(amy_global.config.midi & AMY_MIDI_IS_USB_GADGET) { pico_teardown_midi(); } free(sysex_buffer); sysex_buffer = NULL; for (int i = 0; i < SYSEX_COPY_SLOTS; i++) { free(sysex_message_copies[i]); sysex_message_copies[i] = NULL; } } } #endif #ifdef __IMXRT1062__ extern void teensy_start_midi(); void run_midi() { if(amy_global.config.midi & AMY_MIDI_IS_UART) teensy_start_midi(); } void stop_midi() { } #endif #ifdef __linux__ void stop_midi() { } void run_midi() { //fprintf(stderr, "no MIDI support on linux yet\n"); } #endif #ifdef AMY_DAISY // Daisy seed void run_midi() { // MIDI handled in main. } #endif #ifdef _WIN32 void stop_midi() { } void run_midi() { } #endif void midi_out(uint8_t * bytes, uint16_t len) { // Is there USB gadget midi? Send it #if defined TUD_USB_GADGET if(amy_global.config.midi & AMY_MIDI_IS_USB_GADGET) { // tud_midi_stream_write uses a small FIFO (e.g. 64 bytes). For long // messages (e.g. zD sysex dumps) we must loop and yield until the // USB task flushes the FIFO, otherwise bytes are silently dropped. if (len > 64) fprintf(stderr, "midi_out: USB gadget, want to send %d bytes\n", (int)len); uint32_t sent = 0; int stall_ticks = 0; while (sent < len) { uint32_t n = tud_midi_stream_write(0, bytes + sent, len - sent); if (n == 0) { #if defined(TULIP) || defined(AMYBOARD) // We're running on the MP main thread; the USB task also runs // here, so vTaskDelay alone won't drain the FIFO. Pump USB // events directly. mp_usbd_task(); #endif #if defined ESP_PLATFORM vTaskDelay(pdMS_TO_TICKS(1)); #endif if (++stall_ticks > 1000) { fprintf(stderr, "midi_out: STALLED after %u of %u bytes\n", (unsigned)sent, (unsigned)len); break; } } else { stall_ticks = 0; } sent += n; } if (len > 64) fprintf(stderr, "midi_out: USB gadget sent %u/%u bytes\n", (unsigned)sent, (unsigned)len); } #endif // Also do UART midi on supported platforms #if defined ESP_PLATFORM if(amy_global.config.midi & AMY_MIDI_IS_UART) { uart_write_bytes(esp_get_uart(amy_global.config.midi_uart), bytes, len); } #elif (defined ARDUINO_ARCH_RP2040) || (defined ARDUINO_ARCH_RP2350) if(amy_global.config.midi & AMY_MIDI_IS_UART) uart_write_blocking(rp_get_uart(amy_global.config.midi_uart), bytes, len); #else // teensy // linux #endif } #endif // check for macos desktop ================================================ FILE: src/amy_midi.h ================================================ // midi.h #ifndef __MIDI_H #define __MIDI_H #ifdef ESP_PLATFORM #include "driver/uart.h" #include "soc/uart_reg.h" #include "esp_task.h" #else // virtualmidi Cocoa stubs #endif #define MIDI_SLOTS 4 void convert_midi_bytes_to_messages(uint8_t * data, size_t len, uint8_t usb); void amy_process_single_midi_byte(uint8_t byte, uint8_t from_web_or_usb); void amy_external_midi_output(uint8_t * data, uint32_t len); void amy_external_midi_sync(uint8_t enabled); #define MAX_MIDI_BYTES_TO_PARSE 1024 #define MAX_MIDI_BYTES_PER_MESSAGE 3 #define MIDI_QUEUE_DEPTH 1024 #define MAX_SYSEX_BYTES (16384) extern uint8_t *sysex_buffer; #define SYSEX_COPY_SLOTS 32 extern char *sysex_message_copies[SYSEX_COPY_SLOTS]; extern uint8_t sysex_copy_write_idx; extern uint8_t sysex_copy_read_idx; extern uint16_t sysex_len; extern void parse_sysex(); extern uint8_t last_midi[MIDI_QUEUE_DEPTH][MAX_MIDI_BYTES_PER_MESSAGE]; extern uint8_t last_midi_len[MIDI_QUEUE_DEPTH]; extern int16_t midi_queue_tail; extern int16_t midi_queue_head; void midi_out(uint8_t * bytes, uint16_t len); void midi_local(uint8_t * bytes, uint16_t len); void amy_send_midi_note_off(uint16_t osc); void amy_send_midi_note_on(uint16_t osc); // For pyamy inject_midi void amy_event_midi_message_received(uint8_t * data, uint32_t len, uint8_t sysex, uint32_t time); #ifdef ESP_PLATFORM #define MIDI_TASK_COREID (0) #define MIDI_TASK_STACK_SIZE (8 * 1024) #define MIDI_TASK_NAME "amy_midi_task" #define MIDI_TASK_PRIORITY (ESP_TASK_PRIO_MAX - 2) #endif void run_midi(); void stop_midi(); #ifdef MACOS void *run_midi_macos(void*vargp); #endif void check_tusb_midi(); void init_tusb_midi(); #endif // __MIDI_H ================================================ FILE: src/api.c ================================================ // api.c // C callable entry points to amy #include "amy.h" amy_config_t amy_default_config() { amy_config_t c; c.features.reverb = 1; c.features.echo = 1; c.features.chorus = 1; c.features.partials = 1; c.features.custom = 1; c.features.default_synths = 0; c.features.audio_in = 0; c.features.startup_bleep = 0; // Use all platform features by default. c.platform.multicore = 1; c.platform.multithread = 1; c.write_samples_fn = NULL; c.amy_external_render_hook = NULL; c.amy_external_coef_hook = NULL; c.amy_external_block_done_hook = NULL; c.amy_external_midi_input_hook = NULL; c.amy_external_sequencer_hook = NULL; c.amy_external_fopen_hook = NULL; c.amy_external_fwrite_hook = NULL; c.amy_external_fread_hook = NULL; c.amy_external_fseek_hook = NULL; c.amy_external_fclose_hook = NULL; c.amy_external_file_transfer_done_hook = NULL; c.midi = AMY_MIDI_IS_NONE; c.audio = AMY_AUDIO_IS_NONE; c.ks_oscs = 1; c.max_oscs = 250; c.max_sequencer_tags = 256; c.max_voices = 64; c.max_synths = 64; c.max_memory_patches = 32; // caps #if defined(TULIP) || defined(AMYBOARD) || defined(AMYBOARD_ARDUINO) c.ram_caps_events = MALLOC_CAP_SPIRAM; c.ram_caps_synth = MALLOC_CAP_SPIRAM; c.ram_caps_block = MALLOC_CAP_DEFAULT; c.ram_caps_fbl = MALLOC_CAP_DEFAULT; c.ram_caps_delay = MALLOC_CAP_SPIRAM; c.ram_caps_sample = MALLOC_CAP_SPIRAM; c.ram_caps_sysex = MALLOC_CAP_SPIRAM; #else c.ram_caps_events = MALLOC_CAP_DEFAULT; c.ram_caps_synth = MALLOC_CAP_DEFAULT; c.ram_caps_block = MALLOC_CAP_DEFAULT; c.ram_caps_fbl = MALLOC_CAP_DEFAULT; c.ram_caps_delay = MALLOC_CAP_DEFAULT; c.ram_caps_sample = MALLOC_CAP_DEFAULT; c.ram_caps_sysex = MALLOC_CAP_DEFAULT; #endif c.capture_device_id = -1; c.playback_device_id = -1; c.i2s_lrc = -1; c.i2s_dout = -1; c.i2s_din = -1; c.i2s_bclk = -1; c.i2s_mclk = -1; c.i2s_mclk_mult = 256; // MCLK = mclk_mult * Fs. c.midi_out = -1; c.midi_in = -1; c.midi_uart = -1; #if defined(AMYBOARD_ARDUINO) || defined(AMYBOARD) // Set default pins c.features.audio_in = 1; c.audio = AMY_AUDIO_IS_I2S; c.midi = AMY_MIDI_IS_UART | AMY_MIDI_IS_USB_GADGET; c.i2s_lrc = AMYBOARD_LRC; c.i2s_bclk = AMYBOARD_BCLK; c.i2s_dout = AMYBOARD_DOUT; c.i2s_din = AMYBOARD_DIN; c.i2s_mclk = AMYBOARD_MCLK; c.midi_out = AMYBOARD_MIDI_OUT_TYPE_A; // TYPE A. User can set type B with 15 c.midi_in = AMYBOARD_MIDI_IN; #endif #ifdef ESP_PLATFORM c.midi_uart = 1; // This is MIDI UART _number_, like index #endif #if (defined ARDUINO_ARCH_RP2040) || (defined ARDUINO_ARCH_RP2350) c.midi_uart = 1; // This is MIDI UART _number_, like index #endif return c; } // create a new default API accessible event amy_event amy_default_event() { amy_event e; amy_clear_event(&e); return e; } void amy_clear_event(amy_event *e) { e->status = EVENT_EMPTY; AMY_UNSET(e->time); AMY_UNSET(e->osc); AMY_UNSET(e->preset); AMY_UNSET(e->wave); AMY_UNSET(e->patch_number); AMY_UNSET(e->trigger_phase); AMY_UNSET(e->feedback); AMY_UNSET(e->velocity); AMY_UNSET(e->midi_note); AMY_UNSET(e->volume); AMY_UNSET(e->pitch_bend); AMY_UNSET(e->tempo); AMY_UNSET(e->latency_ms); AMY_UNSET(e->ratio); for (int i = 0; i < NUM_COMBO_COEFS; ++i) { AMY_UNSET(e->amp_coefs[i]); AMY_UNSET(e->freq_coefs[i]); AMY_UNSET(e->filter_freq_coefs[i]); AMY_UNSET(e->duty_coefs[i]); AMY_UNSET(e->pan_coefs[i]); } AMY_UNSET(e->resonance); AMY_UNSET(e->portamento_ms); AMY_UNSET(e->filter_type); AMY_UNSET(e->chained_osc); AMY_UNSET(e->mod_source); AMY_UNSET(e->algorithm); AMY_UNSET(e->bp_is_set[0]); AMY_UNSET(e->bp_is_set[1]); AMY_UNSET(e->eg_type[0]); AMY_UNSET(e->eg_type[1]); AMY_UNSET(e->reset_osc); AMY_UNSET(e->note_source); for (int i = 0; i < MAX_ALGO_OPS; ++i) { AMY_UNSET(e->algo_source[i]); } for (int i = 0; i < MAX_VOICES_PER_INSTRUMENT; ++i) { AMY_UNSET(e->voices[i]); } for (int i = 0; i < MAX_BPS; ++i) { AMY_UNSET(e->eg0_times[i]); AMY_UNSET(e->eg0_values[i]); AMY_UNSET(e->eg1_times[i]); AMY_UNSET(e->eg1_values[i]); } AMY_UNSET(e->synth); AMY_UNSET(e->synth_flags); AMY_UNSET(e->to_synth); AMY_UNSET(e->synth_delay_ms); AMY_UNSET(e->grab_midi_notes); AMY_UNSET(e->pedal); AMY_UNSET(e->num_voices); AMY_UNSET(e->sequence[SEQUENCE_TICK]); AMY_UNSET(e->sequence[SEQUENCE_PERIOD]); AMY_UNSET(e->sequence[SEQUENCE_TAG]); AMY_UNSET(e->eq_l); AMY_UNSET(e->eq_m); AMY_UNSET(e->eq_h); AMY_UNSET(e->echo_level); AMY_UNSET(e->echo_delay_ms); AMY_UNSET(e->echo_max_delay_ms); AMY_UNSET(e->echo_feedback); AMY_UNSET(e->echo_filter_coef); AMY_UNSET(e->chorus_level); AMY_UNSET(e->chorus_max_delay); AMY_UNSET(e->chorus_lfo_freq); AMY_UNSET(e->chorus_depth); AMY_UNSET(e->reverb_level); AMY_UNSET(e->reverb_liveness); AMY_UNSET(e->reverb_damping); AMY_UNSET(e->reverb_xover_hz); AMY_UNSET(e->oscs_per_voice); } // get last-written output, returns number of bytes written. int amy_get_output_buffer(output_sample_type * samples) { if (amy_out_block == NULL) return 0; // amy_fill_buffer has not yet run. for(uint16_t i=0;i 0) { amy_clear_event(&e); int pos = amy_parse_message(remains, length, &e); amy_add_event(&e); remains += pos; length -= pos; } } // Like amy_add_message but marks the message as coming from an external // sysex source so the file transfer routing in amy_parse_message applies. void amy_add_message_from_sysex(char *message) { amy_parsing_from_sysex = true; amy_add_message(message); amy_parsing_from_sysex = false; } // given an event play / schedule the event directly (C API) void amy_add_event(amy_event *e) { peek_stack("add_event"); amy_process_event(e); // Do not "play" events that are not sent directly to the AMY synthesizer, e.g. sequencer events or stored patches if(e->status == EVENT_SCHEDULED) { amy_event_to_deltas_queue(e, 0, &amy_global.delta_queue); } } // defined in midi_mappings.c extern void juno_filter_midi_handler(uint8_t * bytes, uint16_t len, uint8_t is_sysex); extern void midi_cc_handler(uint8_t * bytes, uint16_t len, uint8_t is_sysex); #ifdef __EMSCRIPTEN__ void amy_start_web() { // a shim for web AMY, as it's annoying to build structs in js amy_config_t amy_config = amy_default_config(); amy_config.midi = AMY_MIDI_IS_WEBMIDI; amy_config.features.default_synths = 1; amy_config.features.startup_bleep = 1; amy_config.amy_external_midi_input_hook = midi_cc_handler; amy_start(amy_config); } void amy_start_web_no_synths() { // a shim for web AMY, as it's annoying to build structs in js amy_config_t amy_config = amy_default_config(); amy_config.midi = AMY_MIDI_IS_WEBMIDI; amy_config.features.default_synths = 0; amy_config.amy_external_midi_input_hook = midi_cc_handler; amy_start(amy_config); } #endif void amy_default_synths() { // Configure several default synthesizers for "out of box" playability. // sine wave "bleeper" on ch 0 (not a MIDI channel) amy_event e = amy_default_event(); // osc=0 sinewave. e.synth = 0; e.num_voices = 1; e.oscs_per_voice = 1; e.wave = SINE; amy_add_event(&e); // GM drum synth on channel 10 e = amy_default_event(); e.synth = 10; e.num_voices = 6; e.oscs_per_voice = 1; e.wave = PCM; e.amp_coefs[COEF_CONST] = 5.0; // MIDI drums need to be louder to match juno patches. // Flag to perform note -> drum PCM patch translation. e.synth_flags = _SYNTH_FLAGS_MIDI_DRUMS | _SYNTH_FLAGS_IGNORE_NOTE_OFFS; amy_add_event(&e); // DX7 6 note poly on channel 2 e = amy_default_event(); e.num_voices = 6; e.patch_number = 128; e.synth = 2; amy_add_event(&e); // Juno 6 poly on channel 1 // Define this last so if we release it, the oscs aren't fragmented. e = amy_default_event(); e.num_voices = 6; e.patch_number = 0; e.synth = 1; amy_add_event(&e); // Add some MIDI CCs for the Juno (defined in midi_mappings.c). amy_global.config.amy_external_midi_input_hook = juno_filter_midi_handler; } // Schedule a bleep now void amy_bleep(uint32_t start) { amy_event e = amy_default_event(); e.osc = AMY_OSCS - 1; // Use a high-up osc to avoid collisions? e.time = start; e.wave = SINE; e.freq_coefs[COEF_CONST] = 220; e.pan_coefs[COEF_CONST] = 0.9; e.velocity = 1; amy_add_event(&e); e.time = start + 150; e.freq_coefs[COEF_CONST] = 440; e.pan_coefs[COEF_CONST] = 0.1; amy_add_event(&e); e.time = start + 300; e.velocity = 0; e.pan_coefs[COEF_CONST] = 0.5; // Restore default pan to osc. amy_add_event(&e); } // Schedule a bleep now using default bleep synth (0) void amy_bleep_synth(uint32_t start) { amy_event e = amy_default_event(); e.synth = 0; e.time = start; // you have to use notes with synths, so the voice manager can grok. e.midi_note = 57; e.pan_coefs[COEF_CONST] = 0.9; e.velocity = 1; amy_add_event(&e); e.time = start + 150; e.midi_note = 69; e.pan_coefs[COEF_CONST] = 0.1; amy_add_event(&e); e.time = start + 300; e.velocity = 0; e.pan_coefs[COEF_CONST] = 0.5; // Restore default pan to osc 0. amy_add_event(&e); } #ifndef AMY_NO_MINIAUDIO extern void miniaudio_start(); extern void miniaudio_stop(); #endif void amy_start(amy_config_t c) { global_init(c); amy_profiles_init(); transfer_init(); oscs_init(); amy_platform_init(); run_midi(); // Must be after platform_init in case F_CPU is modified on RP2040 Arduino. if(AMY_HAS_DEFAULT_SYNTHS) amy_default_synths(); if(AMY_HAS_STARTUP_BLEEP) { if(AMY_HAS_DEFAULT_SYNTHS) amy_bleep_synth(0); // bleep using the default sinewave synth voice. else amy_bleep(0); // bleep using raw oscs. } #if !defined(ESP_PLATFORM) && !defined(PICO_ON_DEVICE) && !defined(ARDUINO) && !defined(__EMSCRIPTEN__) && !defined(AMY_NO_MINIAUDIO) if (amy_global.config.audio == AMY_AUDIO_IS_MINIAUDIO) miniaudio_start(); #endif if (amy_global.config.amy_external_midi_input_hook == NULL) { amy_global.config.amy_external_midi_input_hook = midi_cc_handler; } } void amy_stop() { #if !defined(ESP_PLATFORM) && !defined(PICO_ON_DEVICE) && !defined(ARDUINO) && !defined(AMY_NO_MINIAUDIO) if (amy_global.config.audio == AMY_AUDIO_IS_MINIAUDIO) miniaudio_stop(); #endif stop_midi(); amy_platform_deinit(); oscs_deinit(); } int16_t *amy_update() { // Single function to update buffers. amy_update_tasks(); int16_t *block = amy_render_audio(); if (AMY_HAS_I2S && !amy_global.i2s_is_in_background) { amy_i2s_write( (uint8_t *)block, AMY_BLOCK_SIZE * AMY_NCHANS * sizeof(int16_t) ); } if (amy_global.config.write_samples_fn) { amy_global.config.write_samples_fn( (uint8_t *)block, AMY_BLOCK_SIZE * AMY_NCHANS * sizeof(int16_t) ); } return block; } ================================================ FILE: src/clipping_lookup_table.h ================================================ // Automatically generated. // Clipping lookup table #ifndef __CLIPPING_TABLE #define __CLIPPING_TABLE #define FIRST_NONLIN 29491 #define NONLIN_RANGE 4914 // First sample value beyond end of table (just clip to max). #define FIRST_HARDCLIP (FIRST_NONLIN + NONLIN_RANGE) const uint16_t clipping_lookup_table[NONLIN_RANGE] PROGMEM = { 29491,29491,29492,29493,29494,29495,29496,29497, 29498,29499,29500,29501,29502,29503,29504,29505, 29506,29507,29508,29509,29510,29511,29512,29513, 29514,29515,29516,29517,29518,29519,29520,29521, 29522,29523,29524,29525,29526,29527,29528,29529, 29530,29531,29532,29533,29534,29535,29536,29537, 29538,29539,29540,29541,29542,29543,29544,29545, 29546,29547,29548,29549,29550,29551,29552,29553, 29554,29555,29556,29557,29558,29559,29560,29561, 29562,29563,29564,29565,29566,29567,29568,29569, 29570,29571,29572,29573,29574,29575,29576,29577, 29578,29579,29580,29581,29582,29583,29584,29585, 29586,29587,29588,29589,29590,29591,29592,29593, 29594,29595,29596,29597,29598,29599,29600,29601, 29602,29603,29604,29605,29606,29607,29608,29609, 29610,29611,29612,29613,29614,29615,29616,29617, 29618,29619,29620,29621,29622,29623,29624,29625, 29626,29627,29628,29629,29630,29631,29632,29633, 29634,29635,29636,29637,29638,29639,29640,29641, 29642,29643,29644,29645,29646,29647,29648,29649, 29650,29651,29652,29653,29654,29655,29656,29657, 29658,29659,29660,29661,29662,29663,29664,29665, 29666,29667,29668,29669,29670,29671,29672,29673, 29674,29675,29676,29677,29678,29679,29680,29681, 29682,29683,29684,29685,29686,29687,29688,29689, 29690,29691,29692,29693,29694,29695,29696,29697, 29698,29699,29700,29701,29702,29703,29704,29705, 29706,29707,29708,29709,29710,29711,29712,29713, 29714,29715,29716,29717,29718,29719,29720,29721, 29722,29723,29724,29725,29726,29727,29728,29729, 29730,29731,29732,29733,29734,29735,29736,29737, 29738,29739,29740,29741,29742,29743,29744,29745, 29746,29747,29748,29749,29750,29751,29752,29753, 29754,29755,29756,29757,29758,29759,29760,29761, 29762,29763,29764,29765,29766,29767,29768,29769, 29770,29771,29772,29773,29774,29775,29776,29777, 29778,29779,29780,29781,29782,29783,29784,29785, 29786,29787,29788,29789,29790,29791,29792,29793, 29794,29795,29796,29797,29798,29799,29800,29801, 29802,29803,29804,29805,29806,29807,29808,29809, 29810,29811,29812,29813,29814,29815,29816,29817, 29818,29819,29820,29821,29822,29823,29824,29825, 29826,29827,29828,29829,29830,29831,29832,29833, 29834,29835,29836,29837,29838,29839,29840,29841, 29842,29843,29844,29845,29846,29847,29848,29849, 29850,29851,29852,29853,29854,29855,29856,29857, 29858,29859,29860,29861,29862,29863,29864,29865, 29866,29867,29868,29869,29870,29871,29872,29873, 29874,29875,29876,29877,29878,29879,29880,29881, 29882,29883,29884,29885,29886,29887,29888,29889, 29890,29891,29892,29893,29894,29895,29896,29897, 29898,29899,29900,29901,29902,29903,29904,29905, 29906,29906,29907,29908,29909,29910,29911,29912, 29913,29914,29915,29916,29917,29918,29919,29920, 29921,29922,29923,29924,29925,29926,29927,29928, 29929,29930,29931,29932,29933,29934,29935,29936, 29937,29938,29939,29940,29941,29942,29943,29944, 29945,29946,29947,29948,29949,29950,29951,29952, 29953,29954,29955,29956,29957,29958,29959,29960, 29961,29962,29963,29964,29965,29966,29967,29968, 29969,29970,29971,29972,29973,29974,29975,29976, 29977,29978,29979,29980,29981,29982,29983,29984, 29985,29986,29987,29988,29989,29990,29991,29992, 29993,29994,29995,29996,29997,29998,29999,30000, 30001,30002,30003,30004,30005,30006,30007,30008, 30009,30010,30011,30012,30013,30014,30014,30015, 30016,30017,30018,30019,30020,30021,30022,30023, 30024,30025,30026,30027,30028,30029,30030,30031, 30032,30033,30034,30035,30036,30037,30038,30039, 30040,30041,30042,30043,30044,30045,30046,30047, 30048,30049,30050,30051,30052,30053,30054,30055, 30056,30057,30058,30059,30060,30061,30062,30063, 30064,30065,30066,30067,30068,30069,30070,30071, 30072,30073,30074,30075,30076,30077,30078,30079, 30080,30081,30082,30083,30084,30085,30086,30087, 30088,30089,30089,30090,30091,30092,30093,30094, 30095,30096,30097,30098,30099,30100,30101,30102, 30103,30104,30105,30106,30107,30108,30109,30110, 30111,30112,30113,30114,30115,30116,30117,30118, 30119,30120,30121,30122,30123,30124,30125,30126, 30127,30128,30129,30130,30131,30132,30133,30134, 30135,30136,30137,30138,30139,30140,30141,30142, 30143,30144,30145,30146,30147,30148,30148,30149, 30150,30151,30152,30153,30154,30155,30156,30157, 30158,30159,30160,30161,30162,30163,30164,30165, 30166,30167,30168,30169,30170,30171,30172,30173, 30174,30175,30176,30177,30178,30179,30180,30181, 30182,30183,30184,30185,30186,30187,30188,30189, 30190,30191,30192,30193,30194,30195,30196,30197, 30198,30198,30199,30200,30201,30202,30203,30204, 30205,30206,30207,30208,30209,30210,30211,30212, 30213,30214,30215,30216,30217,30218,30219,30220, 30221,30222,30223,30224,30225,30226,30227,30228, 30229,30230,30231,30232,30233,30234,30235,30236, 30237,30238,30239,30240,30241,30242,30242,30243, 30244,30245,30246,30247,30248,30249,30250,30251, 30252,30253,30254,30255,30256,30257,30258,30259, 30260,30261,30262,30263,30264,30265,30266,30267, 30268,30269,30270,30271,30272,30273,30274,30275, 30276,30277,30278,30279,30280,30281,30281,30282, 30283,30284,30285,30286,30287,30288,30289,30290, 30291,30292,30293,30294,30295,30296,30297,30298, 30299,30300,30301,30302,30303,30304,30305,30306, 30307,30308,30309,30310,30311,30312,30313,30314, 30315,30316,30316,30317,30318,30319,30320,30321, 30322,30323,30324,30325,30326,30327,30328,30329, 30330,30331,30332,30333,30334,30335,30336,30337, 30338,30339,30340,30341,30342,30343,30344,30345, 30346,30347,30348,30349,30349,30350,30351,30352, 30353,30354,30355,30356,30357,30358,30359,30360, 30361,30362,30363,30364,30365,30366,30367,30368, 30369,30370,30371,30372,30373,30374,30375,30376, 30377,30378,30379,30379,30380,30381,30382,30383, 30384,30385,30386,30387,30388,30389,30390,30391, 30392,30393,30394,30395,30396,30397,30398,30399, 30400,30401,30402,30403,30404,30405,30406,30407, 30407,30408,30409,30410,30411,30412,30413,30414, 30415,30416,30417,30418,30419,30420,30421,30422, 30423,30424,30425,30426,30427,30428,30429,30430, 30431,30432,30433,30433,30434,30435,30436,30437, 30438,30439,30440,30441,30442,30443,30444,30445, 30446,30447,30448,30449,30450,30451,30452,30453, 30454,30455,30456,30457,30458,30458,30459,30460, 30461,30462,30463,30464,30465,30466,30467,30468, 30469,30470,30471,30472,30473,30474,30475,30476, 30477,30478,30479,30480,30481,30481,30482,30483, 30484,30485,30486,30487,30488,30489,30490,30491, 30492,30493,30494,30495,30496,30497,30498,30499, 30500,30501,30502,30503,30504,30504,30505,30506, 30507,30508,30509,30510,30511,30512,30513,30514, 30515,30516,30517,30518,30519,30520,30521,30522, 30523,30524,30525,30525,30526,30527,30528,30529, 30530,30531,30532,30533,30534,30535,30536,30537, 30538,30539,30540,30541,30542,30543,30544,30545, 30545,30546,30547,30548,30549,30550,30551,30552, 30553,30554,30555,30556,30557,30558,30559,30560, 30561,30562,30563,30564,30565,30565,30566,30567, 30568,30569,30570,30571,30572,30573,30574,30575, 30576,30577,30578,30579,30580,30581,30582,30583, 30584,30584,30585,30586,30587,30588,30589,30590, 30591,30592,30593,30594,30595,30596,30597,30598, 30599,30600,30601,30602,30602,30603,30604,30605, 30606,30607,30608,30609,30610,30611,30612,30613, 30614,30615,30616,30617,30618,30619,30620,30620, 30621,30622,30623,30624,30625,30626,30627,30628, 30629,30630,30631,30632,30633,30634,30635,30636, 30637,30637,30638,30639,30640,30641,30642,30643, 30644,30645,30646,30647,30648,30649,30650,30651, 30652,30653,30653,30654,30655,30656,30657,30658, 30659,30660,30661,30662,30663,30664,30665,30666, 30667,30668,30669,30669,30670,30671,30672,30673, 30674,30675,30676,30677,30678,30679,30680,30681, 30682,30683,30684,30684,30685,30686,30687,30688, 30689,30690,30691,30692,30693,30694,30695,30696, 30697,30698,30699,30699,30700,30701,30702,30703, 30704,30705,30706,30707,30708,30709,30710,30711, 30712,30713,30714,30714,30715,30716,30717,30718, 30719,30720,30721,30722,30723,30724,30725,30726, 30727,30728,30728,30729,30730,30731,30732,30733, 30734,30735,30736,30737,30738,30739,30740,30741, 30742,30742,30743,30744,30745,30746,30747,30748, 30749,30750,30751,30752,30753,30754,30755,30756, 30756,30757,30758,30759,30760,30761,30762,30763, 30764,30765,30766,30767,30768,30769,30769,30770, 30771,30772,30773,30774,30775,30776,30777,30778, 30779,30780,30781,30782,30782,30783,30784,30785, 30786,30787,30788,30789,30790,30791,30792,30793, 30794,30795,30795,30796,30797,30798,30799,30800, 30801,30802,30803,30804,30805,30806,30807,30807, 30808,30809,30810,30811,30812,30813,30814,30815, 30816,30817,30818,30819,30819,30820,30821,30822, 30823,30824,30825,30826,30827,30828,30829,30830, 30831,30831,30832,30833,30834,30835,30836,30837, 30838,30839,30840,30841,30842,30843,30843,30844, 30845,30846,30847,30848,30849,30850,30851,30852, 30853,30854,30854,30855,30856,30857,30858,30859, 30860,30861,30862,30863,30864,30865,30865,30866, 30867,30868,30869,30870,30871,30872,30873,30874, 30875,30876,30876,30877,30878,30879,30880,30881, 30882,30883,30884,30885,30886,30887,30887,30888, 30889,30890,30891,30892,30893,30894,30895,30896, 30897,30898,30898,30899,30900,30901,30902,30903, 30904,30905,30906,30907,30908,30908,30909,30910, 30911,30912,30913,30914,30915,30916,30917,30918, 30918,30919,30920,30921,30922,30923,30924,30925, 30926,30927,30928,30928,30929,30930,30931,30932, 30933,30934,30935,30936,30937,30938,30938,30939, 30940,30941,30942,30943,30944,30945,30946,30947, 30948,30948,30949,30950,30951,30952,30953,30954, 30955,30956,30957,30957,30958,30959,30960,30961, 30962,30963,30964,30965,30966,30967,30967,30968, 30969,30970,30971,30972,30973,30974,30975,30976, 30976,30977,30978,30979,30980,30981,30982,30983, 30984,30985,30985,30986,30987,30988,30989,30990, 30991,30992,30993,30994,30994,30995,30996,30997, 30998,30999,31000,31001,31002,31003,31003,31004, 31005,31006,31007,31008,31009,31010,31011,31012, 31012,31013,31014,31015,31016,31017,31018,31019, 31020,31021,31021,31022,31023,31024,31025,31026, 31027,31028,31029,31029,31030,31031,31032,31033, 31034,31035,31036,31037,31038,31038,31039,31040, 31041,31042,31043,31044,31045,31046,31046,31047, 31048,31049,31050,31051,31052,31053,31054,31054, 31055,31056,31057,31058,31059,31060,31061,31062, 31062,31063,31064,31065,31066,31067,31068,31069, 31070,31070,31071,31072,31073,31074,31075,31076, 31077,31078,31078,31079,31080,31081,31082,31083, 31084,31085,31086,31086,31087,31088,31089,31090, 31091,31092,31093,31094,31094,31095,31096,31097, 31098,31099,31100,31101,31102,31102,31103,31104, 31105,31106,31107,31108,31109,31109,31110,31111, 31112,31113,31114,31115,31116,31117,31117,31118, 31119,31120,31121,31122,31123,31124,31124,31125, 31126,31127,31128,31129,31130,31131,31131,31132, 31133,31134,31135,31136,31137,31138,31139,31139, 31140,31141,31142,31143,31144,31145,31146,31146, 31147,31148,31149,31150,31151,31152,31153,31153, 31154,31155,31156,31157,31158,31159,31160,31160, 31161,31162,31163,31164,31165,31166,31167,31167, 31168,31169,31170,31171,31172,31173,31173,31174, 31175,31176,31177,31178,31179,31180,31180,31181, 31182,31183,31184,31185,31186,31187,31187,31188, 31189,31190,31191,31192,31193,31194,31194,31195, 31196,31197,31198,31199,31200,31200,31201,31202, 31203,31204,31205,31206,31207,31207,31208,31209, 31210,31211,31212,31213,31213,31214,31215,31216, 31217,31218,31219,31220,31220,31221,31222,31223, 31224,31225,31226,31226,31227,31228,31229,31230, 31231,31232,31232,31233,31234,31235,31236,31237, 31238,31238,31239,31240,31241,31242,31243,31244, 31245,31245,31246,31247,31248,31249,31250,31251, 31251,31252,31253,31254,31255,31256,31257,31257, 31258,31259,31260,31261,31262,31263,31263,31264, 31265,31266,31267,31268,31269,31269,31270,31271, 31272,31273,31274,31275,31275,31276,31277,31278, 31279,31280,31280,31281,31282,31283,31284,31285, 31286,31286,31287,31288,31289,31290,31291,31292, 31292,31293,31294,31295,31296,31297,31298,31298, 31299,31300,31301,31302,31303,31303,31304,31305, 31306,31307,31308,31309,31309,31310,31311,31312, 31313,31314,31314,31315,31316,31317,31318,31319, 31320,31320,31321,31322,31323,31324,31325,31325, 31326,31327,31328,31329,31330,31331,31331,31332, 31333,31334,31335,31336,31336,31337,31338,31339, 31340,31341,31342,31342,31343,31344,31345,31346, 31347,31347,31348,31349,31350,31351,31352,31352, 31353,31354,31355,31356,31357,31357,31358,31359, 31360,31361,31362,31363,31363,31364,31365,31366, 31367,31368,31368,31369,31370,31371,31372,31373, 31373,31374,31375,31376,31377,31378,31378,31379, 31380,31381,31382,31383,31383,31384,31385,31386, 31387,31388,31388,31389,31390,31391,31392,31393, 31393,31394,31395,31396,31397,31398,31398,31399, 31400,31401,31402,31403,31403,31404,31405,31406, 31407,31408,31408,31409,31410,31411,31412,31412, 31413,31414,31415,31416,31417,31417,31418,31419, 31420,31421,31422,31422,31423,31424,31425,31426, 31427,31427,31428,31429,31430,31431,31431,31432, 31433,31434,31435,31436,31436,31437,31438,31439, 31440,31441,31441,31442,31443,31444,31445,31445, 31446,31447,31448,31449,31450,31450,31451,31452, 31453,31454,31454,31455,31456,31457,31458,31459, 31459,31460,31461,31462,31463,31463,31464,31465, 31466,31467,31468,31468,31469,31470,31471,31472, 31472,31473,31474,31475,31476,31477,31477,31478, 31479,31480,31481,31481,31482,31483,31484,31485, 31485,31486,31487,31488,31489,31490,31490,31491, 31492,31493,31494,31494,31495,31496,31497,31498, 31498,31499,31500,31501,31502,31503,31503,31504, 31505,31506,31507,31507,31508,31509,31510,31511, 31511,31512,31513,31514,31515,31515,31516,31517, 31518,31519,31519,31520,31521,31522,31523,31523, 31524,31525,31526,31527,31527,31528,31529,31530, 31531,31531,31532,31533,31534,31535,31536,31536, 31537,31538,31539,31540,31540,31541,31542,31543, 31544,31544,31545,31546,31547,31548,31548,31549, 31550,31551,31552,31552,31553,31554,31555,31555, 31556,31557,31558,31559,31559,31560,31561,31562, 31563,31563,31564,31565,31566,31567,31567,31568, 31569,31570,31571,31571,31572,31573,31574,31575, 31575,31576,31577,31578,31579,31579,31580,31581, 31582,31582,31583,31584,31585,31586,31586,31587, 31588,31589,31590,31590,31591,31592,31593,31594, 31594,31595,31596,31597,31597,31598,31599,31600, 31601,31601,31602,31603,31604,31605,31605,31606, 31607,31608,31608,31609,31610,31611,31612,31612, 31613,31614,31615,31616,31616,31617,31618,31619, 31619,31620,31621,31622,31623,31623,31624,31625, 31626,31626,31627,31628,31629,31630,31630,31631, 31632,31633,31633,31634,31635,31636,31637,31637, 31638,31639,31640,31640,31641,31642,31643,31644, 31644,31645,31646,31647,31647,31648,31649,31650, 31651,31651,31652,31653,31654,31654,31655,31656, 31657,31657,31658,31659,31660,31661,31661,31662, 31663,31664,31664,31665,31666,31667,31668,31668, 31669,31670,31671,31671,31672,31673,31674,31674, 31675,31676,31677,31678,31678,31679,31680,31681, 31681,31682,31683,31684,31684,31685,31686,31687, 31687,31688,31689,31690,31691,31691,31692,31693, 31694,31694,31695,31696,31697,31697,31698,31699, 31700,31700,31701,31702,31703,31703,31704,31705, 31706,31707,31707,31708,31709,31710,31710,31711, 31712,31713,31713,31714,31715,31716,31716,31717, 31718,31719,31719,31720,31721,31722,31722,31723, 31724,31725,31725,31726,31727,31728,31728,31729, 31730,31731,31731,31732,31733,31734,31734,31735, 31736,31737,31737,31738,31739,31740,31740,31741, 31742,31743,31743,31744,31745,31746,31746,31747, 31748,31749,31749,31750,31751,31752,31752,31753, 31754,31755,31755,31756,31757,31758,31758,31759, 31760,31761,31761,31762,31763,31764,31764,31765, 31766,31767,31767,31768,31769,31770,31770,31771, 31772,31773,31773,31774,31775,31776,31776,31777, 31778,31779,31779,31780,31781,31781,31782,31783, 31784,31784,31785,31786,31787,31787,31788,31789, 31790,31790,31791,31792,31793,31793,31794,31795, 31795,31796,31797,31798,31798,31799,31800,31801, 31801,31802,31803,31804,31804,31805,31806,31806, 31807,31808,31809,31809,31810,31811,31812,31812, 31813,31814,31815,31815,31816,31817,31817,31818, 31819,31820,31820,31821,31822,31823,31823,31824, 31825,31825,31826,31827,31828,31828,31829,31830, 31831,31831,31832,31833,31833,31834,31835,31836, 31836,31837,31838,31839,31839,31840,31841,31841, 31842,31843,31844,31844,31845,31846,31846,31847, 31848,31849,31849,31850,31851,31851,31852,31853, 31854,31854,31855,31856,31857,31857,31858,31859, 31859,31860,31861,31862,31862,31863,31864,31864, 31865,31866,31867,31867,31868,31869,31869,31870, 31871,31872,31872,31873,31874,31874,31875,31876, 31877,31877,31878,31879,31879,31880,31881,31881, 31882,31883,31884,31884,31885,31886,31886,31887, 31888,31889,31889,31890,31891,31891,31892,31893, 31894,31894,31895,31896,31896,31897,31898,31898, 31899,31900,31901,31901,31902,31903,31903,31904, 31905,31905,31906,31907,31908,31908,31909,31910, 31910,31911,31912,31913,31913,31914,31915,31915, 31916,31917,31917,31918,31919,31919,31920,31921, 31922,31922,31923,31924,31924,31925,31926,31926, 31927,31928,31929,31929,31930,31931,31931,31932, 31933,31933,31934,31935,31935,31936,31937,31938, 31938,31939,31940,31940,31941,31942,31942,31943, 31944,31944,31945,31946,31947,31947,31948,31949, 31949,31950,31951,31951,31952,31953,31953,31954, 31955,31955,31956,31957,31958,31958,31959,31960, 31960,31961,31962,31962,31963,31964,31964,31965, 31966,31966,31967,31968,31968,31969,31970,31971, 31971,31972,31973,31973,31974,31975,31975,31976, 31977,31977,31978,31979,31979,31980,31981,31981, 31982,31983,31983,31984,31985,31985,31986,31987, 31987,31988,31989,31989,31990,31991,31992,31992, 31993,31994,31994,31995,31996,31996,31997,31998, 31998,31999,32000,32000,32001,32002,32002,32003, 32004,32004,32005,32006,32006,32007,32008,32008, 32009,32010,32010,32011,32012,32012,32013,32014, 32014,32015,32016,32016,32017,32018,32018,32019, 32020,32020,32021,32022,32022,32023,32024,32024, 32025,32026,32026,32027,32028,32028,32029,32030, 32030,32031,32032,32032,32033,32034,32034,32035, 32035,32036,32037,32037,32038,32039,32039,32040, 32041,32041,32042,32043,32043,32044,32045,32045, 32046,32047,32047,32048,32049,32049,32050,32051, 32051,32052,32053,32053,32054,32054,32055,32056, 32056,32057,32058,32058,32059,32060,32060,32061, 32062,32062,32063,32064,32064,32065,32066,32066, 32067,32067,32068,32069,32069,32070,32071,32071, 32072,32073,32073,32074,32075,32075,32076,32076, 32077,32078,32078,32079,32080,32080,32081,32082, 32082,32083,32084,32084,32085,32085,32086,32087, 32087,32088,32089,32089,32090,32091,32091,32092, 32092,32093,32094,32094,32095,32096,32096,32097, 32098,32098,32099,32099,32100,32101,32101,32102, 32103,32103,32104,32105,32105,32106,32106,32107, 32108,32108,32109,32110,32110,32111,32112,32112, 32113,32113,32114,32115,32115,32116,32117,32117, 32118,32118,32119,32120,32120,32121,32122,32122, 32123,32123,32124,32125,32125,32126,32127,32127, 32128,32128,32129,32130,32130,32131,32132,32132, 32133,32133,32134,32135,32135,32136,32136,32137, 32138,32138,32139,32140,32140,32141,32141,32142, 32143,32143,32144,32145,32145,32146,32146,32147, 32148,32148,32149,32149,32150,32151,32151,32152, 32153,32153,32154,32154,32155,32156,32156,32157, 32157,32158,32159,32159,32160,32160,32161,32162, 32162,32163,32164,32164,32165,32165,32166,32167, 32167,32168,32168,32169,32170,32170,32171,32171, 32172,32173,32173,32174,32174,32175,32176,32176, 32177,32177,32178,32179,32179,32180,32180,32181, 32182,32182,32183,32183,32184,32185,32185,32186, 32186,32187,32188,32188,32189,32189,32190,32191, 32191,32192,32192,32193,32194,32194,32195,32195, 32196,32197,32197,32198,32198,32199,32200,32200, 32201,32201,32202,32203,32203,32204,32204,32205, 32206,32206,32207,32207,32208,32208,32209,32210, 32210,32211,32211,32212,32213,32213,32214,32214, 32215,32216,32216,32217,32217,32218,32218,32219, 32220,32220,32221,32221,32222,32223,32223,32224, 32224,32225,32225,32226,32227,32227,32228,32228, 32229,32229,32230,32231,32231,32232,32232,32233, 32234,32234,32235,32235,32236,32236,32237,32238, 32238,32239,32239,32240,32240,32241,32242,32242, 32243,32243,32244,32244,32245,32246,32246,32247, 32247,32248,32248,32249,32250,32250,32251,32251, 32252,32252,32253,32254,32254,32255,32255,32256, 32256,32257,32258,32258,32259,32259,32260,32260, 32261,32262,32262,32263,32263,32264,32264,32265, 32266,32266,32267,32267,32268,32268,32269,32269, 32270,32271,32271,32272,32272,32273,32273,32274, 32274,32275,32276,32276,32277,32277,32278,32278, 32279,32279,32280,32281,32281,32282,32282,32283, 32283,32284,32284,32285,32286,32286,32287,32287, 32288,32288,32289,32289,32290,32291,32291,32292, 32292,32293,32293,32294,32294,32295,32296,32296, 32297,32297,32298,32298,32299,32299,32300,32300, 32301,32302,32302,32303,32303,32304,32304,32305, 32305,32306,32306,32307,32308,32308,32309,32309, 32310,32310,32311,32311,32312,32312,32313,32313, 32314,32315,32315,32316,32316,32317,32317,32318, 32318,32319,32319,32320,32320,32321,32322,32322, 32323,32323,32324,32324,32325,32325,32326,32326, 32327,32327,32328,32328,32329,32330,32330,32331, 32331,32332,32332,32333,32333,32334,32334,32335, 32335,32336,32336,32337,32337,32338,32339,32339, 32340,32340,32341,32341,32342,32342,32343,32343, 32344,32344,32345,32345,32346,32346,32347,32347, 32348,32348,32349,32350,32350,32351,32351,32352, 32352,32353,32353,32354,32354,32355,32355,32356, 32356,32357,32357,32358,32358,32359,32359,32360, 32360,32361,32361,32362,32362,32363,32363,32364, 32364,32365,32366,32366,32367,32367,32368,32368, 32369,32369,32370,32370,32371,32371,32372,32372, 32373,32373,32374,32374,32375,32375,32376,32376, 32377,32377,32378,32378,32379,32379,32380,32380, 32381,32381,32382,32382,32383,32383,32384,32384, 32385,32385,32386,32386,32387,32387,32388,32388, 32389,32389,32390,32390,32391,32391,32392,32392, 32393,32393,32394,32394,32395,32395,32396,32396, 32397,32397,32398,32398,32399,32399,32400,32400, 32401,32401,32402,32402,32403,32403,32404,32404, 32405,32405,32406,32406,32406,32407,32407,32408, 32408,32409,32409,32410,32410,32411,32411,32412, 32412,32413,32413,32414,32414,32415,32415,32416, 32416,32417,32417,32418,32418,32419,32419,32420, 32420,32421,32421,32421,32422,32422,32423,32423, 32424,32424,32425,32425,32426,32426,32427,32427, 32428,32428,32429,32429,32430,32430,32431,32431, 32431,32432,32432,32433,32433,32434,32434,32435, 32435,32436,32436,32437,32437,32438,32438,32439, 32439,32439,32440,32440,32441,32441,32442,32442, 32443,32443,32444,32444,32445,32445,32446,32446, 32446,32447,32447,32448,32448,32449,32449,32450, 32450,32451,32451,32452,32452,32452,32453,32453, 32454,32454,32455,32455,32456,32456,32457,32457, 32457,32458,32458,32459,32459,32460,32460,32461, 32461,32462,32462,32462,32463,32463,32464,32464, 32465,32465,32466,32466,32467,32467,32467,32468, 32468,32469,32469,32470,32470,32471,32471,32471, 32472,32472,32473,32473,32474,32474,32475,32475, 32475,32476,32476,32477,32477,32478,32478,32479, 32479,32479,32480,32480,32481,32481,32482,32482, 32483,32483,32483,32484,32484,32485,32485,32486, 32486,32486,32487,32487,32488,32488,32489,32489, 32490,32490,32490,32491,32491,32492,32492,32493, 32493,32493,32494,32494,32495,32495,32496,32496, 32496,32497,32497,32498,32498,32499,32499,32499, 32500,32500,32501,32501,32502,32502,32502,32503, 32503,32504,32504,32505,32505,32505,32506,32506, 32507,32507,32508,32508,32508,32509,32509,32510, 32510,32510,32511,32511,32512,32512,32513,32513, 32513,32514,32514,32515,32515,32515,32516,32516, 32517,32517,32518,32518,32518,32519,32519,32520, 32520,32520,32521,32521,32522,32522,32522,32523, 32523,32524,32524,32525,32525,32525,32526,32526, 32527,32527,32527,32528,32528,32529,32529,32529, 32530,32530,32531,32531,32531,32532,32532,32533, 32533,32533,32534,32534,32535,32535,32535,32536, 32536,32537,32537,32537,32538,32538,32539,32539, 32539,32540,32540,32541,32541,32541,32542,32542, 32543,32543,32543,32544,32544,32545,32545,32545, 32546,32546,32547,32547,32547,32548,32548,32548, 32549,32549,32550,32550,32550,32551,32551,32552, 32552,32552,32553,32553,32554,32554,32554,32555, 32555,32555,32556,32556,32557,32557,32557,32558, 32558,32559,32559,32559,32560,32560,32560,32561, 32561,32562,32562,32562,32563,32563,32563,32564, 32564,32565,32565,32565,32566,32566,32566,32567, 32567,32568,32568,32568,32569,32569,32569,32570, 32570,32571,32571,32571,32572,32572,32572,32573, 32573,32574,32574,32574,32575,32575,32575,32576, 32576,32576,32577,32577,32578,32578,32578,32579, 32579,32579,32580,32580,32580,32581,32581,32582, 32582,32582,32583,32583,32583,32584,32584,32584, 32585,32585,32585,32586,32586,32587,32587,32587, 32588,32588,32588,32589,32589,32589,32590,32590, 32590,32591,32591,32592,32592,32592,32593,32593, 32593,32594,32594,32594,32595,32595,32595,32596, 32596,32596,32597,32597,32597,32598,32598,32598, 32599,32599,32600,32600,32600,32601,32601,32601, 32602,32602,32602,32603,32603,32603,32604,32604, 32604,32605,32605,32605,32606,32606,32606,32607, 32607,32607,32608,32608,32608,32609,32609,32609, 32610,32610,32610,32611,32611,32611,32612,32612, 32612,32613,32613,32613,32614,32614,32614,32615, 32615,32615,32616,32616,32616,32617,32617,32617, 32618,32618,32618,32619,32619,32619,32620,32620, 32620,32621,32621,32621,32622,32622,32622,32623, 32623,32623,32623,32624,32624,32624,32625,32625, 32625,32626,32626,32626,32627,32627,32627,32628, 32628,32628,32629,32629,32629,32630,32630,32630, 32630,32631,32631,32631,32632,32632,32632,32633, 32633,32633,32634,32634,32634,32635,32635,32635, 32635,32636,32636,32636,32637,32637,32637,32638, 32638,32638,32638,32639,32639,32639,32640,32640, 32640,32641,32641,32641,32642,32642,32642,32642, 32643,32643,32643,32644,32644,32644,32645,32645, 32645,32645,32646,32646,32646,32647,32647,32647, 32647,32648,32648,32648,32649,32649,32649,32650, 32650,32650,32650,32651,32651,32651,32652,32652, 32652,32652,32653,32653,32653,32654,32654,32654, 32654,32655,32655,32655,32656,32656,32656,32656, 32657,32657,32657,32658,32658,32658,32658,32659, 32659,32659,32660,32660,32660,32660,32661,32661, 32661,32661,32662,32662,32662,32663,32663,32663, 32663,32664,32664,32664,32665,32665,32665,32665, 32666,32666,32666,32666,32667,32667,32667,32668, 32668,32668,32668,32669,32669,32669,32669,32670, 32670,32670,32670,32671,32671,32671,32672,32672, 32672,32672,32673,32673,32673,32673,32674,32674, 32674,32674,32675,32675,32675,32675,32676,32676, 32676,32676,32677,32677,32677,32678,32678,32678, 32678,32679,32679,32679,32679,32680,32680,32680, 32680,32681,32681,32681,32681,32682,32682,32682, 32682,32683,32683,32683,32683,32684,32684,32684, 32684,32685,32685,32685,32685,32686,32686,32686, 32686,32687,32687,32687,32687,32687,32688,32688, 32688,32688,32689,32689,32689,32689,32690,32690, 32690,32690,32691,32691,32691,32691,32692,32692, 32692,32692,32693,32693,32693,32693,32693,32694, 32694,32694,32694,32695,32695,32695,32695,32696, 32696,32696,32696,32696,32697,32697,32697,32697, 32698,32698,32698,32698,32698,32699,32699,32699, 32699,32700,32700,32700,32700,32701,32701,32701, 32701,32701,32702,32702,32702,32702,32703,32703, 32703,32703,32703,32704,32704,32704,32704,32704, 32705,32705,32705,32705,32706,32706,32706,32706, 32706,32707,32707,32707,32707,32707,32708,32708, 32708,32708,32708,32709,32709,32709,32709,32710, 32710,32710,32710,32710,32711,32711,32711,32711, 32711,32712,32712,32712,32712,32712,32713,32713, 32713,32713,32713,32714,32714,32714,32714,32714, 32715,32715,32715,32715,32715,32716,32716,32716, 32716,32716,32717,32717,32717,32717,32717,32718, 32718,32718,32718,32718,32719,32719,32719,32719, 32719,32719,32720,32720,32720,32720,32720,32721, 32721,32721,32721,32721,32722,32722,32722,32722, 32722,32722,32723,32723,32723,32723,32723,32724, 32724,32724,32724,32724,32724,32725,32725,32725, 32725,32725,32725,32726,32726,32726,32726,32726, 32727,32727,32727,32727,32727,32727,32728,32728, 32728,32728,32728,32728,32729,32729,32729,32729, 32729,32729,32730,32730,32730,32730,32730,32730, 32731,32731,32731,32731,32731,32731,32732,32732, 32732,32732,32732,32732,32733,32733,32733,32733, 32733,32733,32734,32734,32734,32734,32734,32734, 32735,32735,32735,32735,32735,32735,32735,32736, 32736,32736,32736,32736,32736,32737,32737,32737, 32737,32737,32737,32737,32738,32738,32738,32738, 32738,32738,32738,32739,32739,32739,32739,32739, 32739,32739,32740,32740,32740,32740,32740,32740, 32740,32741,32741,32741,32741,32741,32741,32741, 32742,32742,32742,32742,32742,32742,32742,32743, 32743,32743,32743,32743,32743,32743,32744,32744, 32744,32744,32744,32744,32744,32744,32745,32745, 32745,32745,32745,32745,32745,32745,32746,32746, 32746,32746,32746,32746,32746,32746,32747,32747, 32747,32747,32747,32747,32747,32747,32748,32748, 32748,32748,32748,32748,32748,32748,32749,32749, 32749,32749,32749,32749,32749,32749,32749,32750, 32750,32750,32750,32750,32750,32750,32750,32751, 32751,32751,32751,32751,32751,32751,32751,32751, 32752,32752,32752,32752,32752,32752,32752,32752, 32752,32752,32753,32753,32753,32753,32753,32753, 32753,32753,32753,32753,32754,32754,32754,32754, 32754,32754,32754,32754,32754,32754,32755,32755, 32755,32755,32755,32755,32755,32755,32755,32755, 32756,32756,32756,32756,32756,32756,32756,32756, 32756,32756,32756,32757,32757,32757,32757,32757, 32757,32757,32757,32757,32757,32757,32757,32758, 32758,32758,32758,32758,32758,32758,32758,32758, 32758,32758,32758,32759,32759,32759,32759,32759, 32759,32759,32759,32759,32759,32759,32759,32759, 32760,32760,32760,32760,32760,32760,32760,32760, 32760,32760,32760,32760,32760,32760,32761,32761, 32761,32761,32761,32761,32761,32761,32761,32761, 32761,32761,32761,32761,32761,32762,32762,32762, 32762,32762,32762,32762,32762,32762,32762,32762, 32762,32762,32762,32762,32762,32762,32763,32763, 32763,32763,32763,32763,32763,32763,32763,32763, 32763,32763,32763,32763,32763,32763,32763,32763, 32763,32764,32764,32764,32764,32764,32764,32764, 32764,32764,32764,32764,32764,32764,32764,32764, 32764,32764,32764,32764,32764,32764,32764,32765, 32765,32765,32765,32765,32765,32765,32765,32765, 32765,32765,32765,32765,32765,32765,32765,32765, 32765,32765,32765,32765,32765,32765,32765,32765, 32765,32765,32765,32765,32766,32766,32766,32766, 32766,32766,32766,32766,32766,32766,32766,32766, 32766,32766,32766,32766,32766,32766,32766,32766, 32766,32766,32766,32766,32766,32766,32766,32766, 32766,32766,32766,32766,32766,32766,32766,32766, 32766,32766,32766,32766,32766,32766,32766,32766, 32766,32766,32766,32766,32766,32766,32766,32766, 32766,32766,32766,32766,32766,32766,32766,32766, 32766,32766,32766,32766,32766,32766,32766,32766, 32766,32766, }; #endif ================================================ FILE: src/custom.c ================================================ // custom.c #include "amy.h" #include struct custom_oscillator* custom_osc = NULL; void amy_set_custom(struct custom_oscillator* custom) { assert(custom_osc == NULL); custom_osc = custom; } void custom_init() { if (custom_osc != NULL) { custom_osc->init(); } } void custom_deinit() { if (custom_osc != NULL) { custom_osc->deinit(); } } void custom_note_on(uint16_t osc, float freq) { assert(custom_osc != NULL); custom_osc->note_on(osc, freq); } void custom_note_off(uint16_t osc) { assert(custom_osc != NULL); custom_osc->note_off(osc); } void custom_mod_trigger(uint16_t osc) { assert(custom_osc != NULL); custom_osc->mod_trigger(osc); } SAMPLE render_custom(SAMPLE* buf, uint16_t osc) { assert(custom_osc != NULL); return custom_osc->render(buf, osc); } SAMPLE compute_mod_custom(uint16_t osc) { assert(custom_osc != NULL); return custom_osc->compute_mod(osc); } ================================================ FILE: src/delay.c ================================================ #include "amy.h" #include "delay.h" int is_power_of_two(int val) { // Returns log_2(val) if val == 2**n, else -1. int log_2_val = 0; while(val) { if (val == 1) return log_2_val; if (val & 1) return -1; val >>= 1; ++log_2_val; } return -1; // zero is not a power of 2. } #ifdef AMY_DAISY // Put delay lines in QSPI on Daisy #define QSPI_HEAP_SIZE 1048576 uint8_t __attribute__((section((".sdram_bss")))) qspi_heap[QSPI_HEAP_SIZE]; uint32_t qspi_used = 0; void *qspi_malloc(size_t num_bytes) { //fprintf(stderr, "qspi_malloc: %d bytes, used = %d\n", num_bytes, qspi_used); if ((qspi_used + num_bytes) >= QSPI_HEAP_SIZE) { fprintf(stderr, "qspi_malloc: out of heap\n"); abort(); } // Save the size of this block. *(uint32_t *)(qspi_heap + qspi_used) = num_bytes; qspi_used += sizeof(uint32_t); void *result = (void *)(qspi_heap + qspi_used); qspi_used += num_bytes; return result; } void qspi_free(void *ptr) { uint32_t last_alloc = *(uint32_t *)((uint8_t*)ptr - sizeof(uint32_t)); if (ptr == (void *)(qspi_heap + (qspi_used - last_alloc))) { // We're just freeing the last alloc, yay. qspi_used -= last_alloc + sizeof(uint32_t); //fprintf(stderr, "qspi_free: %ld bytes, used = %d\n", last_alloc, qspi_used); } else { fprintf(stderr, "qspi_free: punt (ptr = qspi_heap + %d)\n", (uint8_t*)ptr - (uint8_t *)qspi_heap); // Don't actually recover the memory. } } #define malloc_caps(a, b) qspi_malloc(a) #define free(a) qspi_free(a) #endif delay_line_t *new_delay_line(int len, int fixed_delay, int ram_type) { // Check that len is a power of 2. //printf("new_delay_line: len %d fixed_del %d\n", len, fixed_delay); int log_2_len = is_power_of_two(len); if (log_2_len < 0) { fprintf(stderr, "delay line len must be power of 2, not %d\n", len); abort(); } delay_line_t *delay_line = (delay_line_t*)malloc_caps(sizeof(delay_line_t) + len * sizeof(SAMPLE), ram_type); if (delay_line == NULL) { fprintf(stderr, "unable to alloc delay line of %d samples\n", len); return NULL; } delay_line->samples = (SAMPLE*)(((uint8_t*)delay_line) + sizeof(delay_line_t)); delay_line->len = len; delay_line->log_2_len = log_2_len; delay_line->fixed_delay = fixed_delay; delay_line->next_in = 0; for (int i = 0; i < len; ++i) { delay_line->samples[i] = 0; } //fprintf(stderr, "new_delay_line: len %d fixed_del %d ->0x%x\n", len, fixed_delay, (uint32_t)delay_line); return delay_line; } void free_delay_line(delay_line_t *delay_line) { //printf("free_delay_line: 0x%x\n", (uint32_t)delay_line); free(delay_line); // the samples are part of the same malloc. } static SAMPLE FRACTIONAL_SAMPLE(PHASOR phase, const SAMPLE *delay, int index_mask, int index_bits) { // Interpolated sample copied from oscillators.c:render_lut uint32_t base_index = INT_OF_P(phase, index_bits); SAMPLE frac = S_FRAC_OF_P(phase, index_bits); SAMPLE b = delay[base_index]; SAMPLE c = delay[(base_index + 1) & index_mask]; // linear interpolation. SAMPLE sample = b + MUL8_SS((c - b), frac); return sample; } void delay_line_in_out(SAMPLE *in, SAMPLE *out, int n_samples, SAMPLE* mod_in, SAMPLE mod_scale, delay_line_t *delay_line, SAMPLE mix_level, SAMPLE feedback_level) { // Read and write the next n_samples from/to the delay line. // mod_in is a per-sample modulation of the maximum delay, where 1 gives // the max delay, -1 gives no delay, and 0 gives max_delay/2. // mod_scale is a constant scale factor applied to each value in mod_in, // used e.g. to flip the sign of the delay. // Also supports input feedback from a non-modulated feedback delay output. int delay_len = delay_line->len; int index_mask = delay_len - 1; // will be all 1s because len is guaranteed 2**n. int index_bits = delay_line->log_2_len; int index_in = delay_line->next_in; int index_feedback = (index_in - delay_line->fixed_delay) & index_mask; SAMPLE *delay = delay_line->samples; SAMPLE half_mod_scale = SHIFTR(mod_scale, 1); while(n_samples-- > 0) { SAMPLE next_in = *in++ + MUL8_SS(feedback_level, delay[index_feedback++]); index_feedback &= index_mask; PHASOR phase_out = I2P(index_in, index_bits) - S2P(F2S(0.5) + MUL8_SS(half_mod_scale, *mod_in++)); //if(index_out >= delay_len) index_out -= delay_len; //if(index_out < 0) index_out += delay_len; SAMPLE sample = FRACTIONAL_SAMPLE(phase_out, delay, index_mask, index_bits); *out++ += MUL8_SS(mix_level, sample); // mix delayed + original. delay[index_in++] = next_in; index_in &= index_mask; } delay_line->next_in = index_in; } static inline SAMPLE DEL_OUT(delay_line_t *delay_line, int extra_delay) { int out_index = (delay_line->next_in - (delay_line->fixed_delay + extra_delay)) & (delay_line->len - 1); return delay_line->samples[out_index]; } static inline void DEL_IN(delay_line_t *delay_line, SAMPLE val) { delay_line->samples[delay_line->next_in++] = val; delay_line->next_in &= (delay_line->len - 1); } static inline SAMPLE LPF(SAMPLE samp, SAMPLE state, SAMPLE lpcoef, SAMPLE lpgain, SAMPLE gain) { // 1-pole lowpass filter (exponential smoothing). // Smoothing. lpcoef=1 => no smoothing; lpcoef=0.001 => much smoothing. state += SMULR6(lpcoef, samp - state); // Cross-fade between smoothed and original. lpgain=0 => all smoothed, 1 => all dry. return SMULR6(SHIFTR(gain, 1), state + SMULR6(lpgain, samp - state)); } void delay_line_in_out_fixed_delay(SAMPLE *in, SAMPLE *out, int n_samples, int delay_samples, delay_line_t *delay_line, SAMPLE mix_level, SAMPLE feedback_level, SAMPLE filter_coef) { // Read and write the next n_samples from/to the delay line. // Simplified version of delay_line_in_out() that uses a fixed integer delay // for the whole block. if (filter_coef == 0) { while(n_samples-- > 0) { SAMPLE delay_out = DEL_OUT(delay_line, 0); SAMPLE next_in = *in++ + SMULR6(feedback_level, delay_out); DEL_IN(delay_line, next_in); *out++ += MUL8_SS(mix_level, delay_out); } } else if (filter_coef > 0) { // Positive filter coef is a pole on the positive real line, to get low-pass effect. // We apply the filter on the way *in* to the delay line. while(n_samples-- > 0) { SAMPLE delay_out = DEL_OUT(delay_line, 0); SAMPLE next_in = *in++ + SMULR6(feedback_level, delay_out); // Peek at the last value we wrote to the delay line to get the most recent filter output. SAMPLE last_filter_result = delay_line->samples[(delay_line->next_in - 1) & (delay_line->len - 1)]; SAMPLE filter_result = next_in + SMULR6(filter_coef, last_filter_result - next_in); DEL_IN(delay_line, filter_result); *out++ += MUL8_SS(mix_level, delay_out); } } else { // Negative filter coef is a zero on the positive real axis to get high-pass. // We apply the FIR zero on the way *out* of the delay line. while(n_samples-- > 0) { SAMPLE delay_out = DEL_OUT(delay_line, 0); SAMPLE prev_delay_out = DEL_OUT(delay_line, 1); SAMPLE output = delay_out + SMULR6(filter_coef, prev_delay_out); SAMPLE next_in = *in++ + SMULR6(feedback_level, output); DEL_IN(delay_line, next_in); *out++ += MUL8_SS(mix_level, output); } } } void apply_variable_delay(SAMPLE *block, delay_line_t *delay_line, SAMPLE *delay_mod, SAMPLE delay_scale, SAMPLE mix_level, SAMPLE feedback_level) { delay_line_in_out(block, block, AMY_BLOCK_SIZE, delay_mod, delay_scale, delay_line, mix_level, feedback_level); } void apply_fixed_delay(SAMPLE *block, delay_line_t *delay_line, uint32_t delay_samples, SAMPLE mix_level, SAMPLE feedback, SAMPLE filter_coef) { delay_line_in_out_fixed_delay(block, block, AMY_BLOCK_SIZE, delay_samples, delay_line, mix_level, feedback, filter_coef); } SAMPLE f1state = 0, f2state = 0, f3state = 0, f4state = 0; delay_line_t *delay_1 = NULL, *delay_2 = NULL, *delay_3 = NULL, *delay_4 = NULL; delay_line_t *ref_1 = NULL, *ref_2 = NULL, *ref_3= NULL, *ref_4 = NULL, *ref_5 = NULL, *ref_6 = NULL; #define INITIAL_XOVER_HZ 3000.0 #define INITIAL_LIVENESS 0.85 #define INITIAL_DAMPING 0.5 SAMPLE lpfcoef; SAMPLE lpfgain; SAMPLE liveness; void config_stereo_reverb(float a_liveness, float crossover_hz, float damping) { //printf("config_stereo_reverb: liveness %f xover %f damping %f\n", // a_liveness, crossover_hz, damping); // liveness (0..1) controls how much energy is preserved (larger = longer reverb). liveness = F2S(a_liveness); // crossover_hz is 3dB point of 1-pole lowpass freq. lpfcoef = F2S(6.2832f * crossover_hz / AMY_SAMPLE_RATE); if (lpfcoef > F2S(1.f)) lpfcoef = F2S(1.f); if (lpfcoef < 0) lpfcoef = 0; lpfgain = F2S(1.f - damping); } // Delay 1 is 58.6435 ms #define DELAY1SAMPS 2586 // Delay 2 is 69.4325 ms #define DELAY2SAMPS 3062 // Delay 3 is 74.5234 ms #define DELAY3SAMPS 3286 // Delay 4 is 86.1244 ms #define DELAY4SAMPS 3798 // Power of 2 that encloses all the delays. #define DELAY_POW2 4096 // Early reflections delays #define REF1SAMPS 3319 // 75.2546 ms #define REF2SAMPS 1920 // 43.5337 ms #define REF3SAMPS 1138 // 25.796 ms #define REF4SAMPS 855 // 19.392 ms #define REF5SAMPS 722 // 16.364 ms #define REF6SAMPS 602 // 13.645 ms void init_stereo_reverb(void) { if (delay_1 == NULL) { delay_1 = new_delay_line(DELAY_POW2, DELAY1SAMPS, amy_global.config.ram_caps_delay); delay_2 = new_delay_line(DELAY_POW2, DELAY2SAMPS, amy_global.config.ram_caps_delay); delay_3 = new_delay_line(DELAY_POW2, DELAY3SAMPS, amy_global.config.ram_caps_delay); delay_4 = new_delay_line(DELAY_POW2, DELAY4SAMPS, amy_global.config.ram_caps_delay); ref_1 = new_delay_line(4096, REF1SAMPS, amy_global.config.ram_caps_delay); ref_2 = new_delay_line(2048, REF2SAMPS, amy_global.config.ram_caps_delay); ref_3 = new_delay_line(2048, REF3SAMPS, amy_global.config.ram_caps_delay); ref_4 = new_delay_line(1024, REF4SAMPS, amy_global.config.ram_caps_delay); ref_5 = new_delay_line(1024, REF5SAMPS, amy_global.config.ram_caps_delay); ref_6 = new_delay_line(1024, REF6SAMPS, amy_global.config.ram_caps_delay); config_stereo_reverb(INITIAL_LIVENESS, INITIAL_XOVER_HZ, INITIAL_DAMPING); } } void stereo_reverb(SAMPLE *r_in, SAMPLE *l_in, SAMPLE *r_out, SAMPLE *l_out, int n_samples, SAMPLE level) { // Stereo reverb. *{r,l}_in each point to n_samples input samples. // n_samples are written to {r,l}_out. // Recreate // https://github.com/duvtedudug/Pure-Data/blob/master/extra/rev2%7E.pd // an instance of the Stautner-Puckette multichannel reverberator from // https://www.ee.columbia.edu/~dpwe/e4896/papers/StautP82-reverb.pdf while(n_samples--) { // Early echo reflections. SAMPLE in_r = *r_in++; SAMPLE in_l; if (l_in) in_l = *l_in++; else in_l = in_r; SAMPLE r_acc, l_acc; r_acc = MUL0_SS(F2S(0.0625f), in_r); l_acc = MUL0_SS(F2S(0.0625f), in_l); DEL_IN(ref_1, l_acc); SAMPLE d_out = DEL_OUT(ref_1, 0); l_acc = r_acc - d_out; r_acc += d_out; DEL_IN(ref_2, l_acc); d_out = DEL_OUT(ref_2, 0); l_acc = r_acc - d_out; r_acc += d_out; DEL_IN(ref_3, l_acc); d_out = DEL_OUT(ref_3, 0); l_acc = r_acc - d_out; r_acc += d_out; DEL_IN(ref_4, l_acc); d_out = DEL_OUT(ref_4, 0); l_acc = r_acc - d_out; r_acc += d_out; DEL_IN(ref_5, l_acc); d_out = DEL_OUT(ref_5, 0); l_acc = r_acc - d_out; r_acc += d_out; DEL_IN(ref_6, l_acc); l_acc = DEL_OUT(ref_6, 0); // Reverb delays & matrix. SAMPLE d1 = DEL_OUT(delay_1, 0); d1 = LPF(d1, f1state, lpfcoef, lpfgain, liveness); d1 += r_acc; *r_out++ = in_r + MUL8_SS(level, d1); SAMPLE d2 = DEL_OUT(delay_2, 0); d2 = LPF(d2, f2state, lpfcoef, lpfgain, liveness); d2 += l_acc; if (l_out != NULL) *l_out++ = in_l + MUL8_SS(level, d2); SAMPLE d3 = DEL_OUT(delay_3, 0); d3 = LPF(d3, f3state, lpfcoef, lpfgain, liveness); SAMPLE d4 = DEL_OUT(delay_4, 0); d4 = LPF(d4, f3state, lpfcoef, lpfgain, liveness); // Mixing and feedback. DEL_IN(delay_1, d1 + d2 + d3 + d4); DEL_IN(delay_2, d1 - d2 + d3 - d4); DEL_IN(delay_3, d1 + d2 - d3 - d4); DEL_IN(delay_4, d1 - d2 - d3 + d4); } } ================================================ FILE: src/delay.h ================================================ #ifndef _DELAY_H // How many bits used for fractional part of delay line index. #define DELAY_INDEX_FRAC_BITS 15 // The number of bits used to hold the delay line index. #define DELAY_INDEX_BITS (31 - DELAY_INDEX_FRAC_BITS) #include "amy.h" delay_line_t *new_delay_line(int len, int fixed_delay, int ram_type /* e.g. MALLOC_CAP_INTERNAL */); void free_delay_line(delay_line_t *d); void apply_variable_delay(SAMPLE *block, delay_line_t *delay_line, SAMPLE *delay_samples, SAMPLE mod_scale, SAMPLE mix_level, SAMPLE feedback_level); void apply_fixed_delay(SAMPLE *block, delay_line_t *delay_line, uint32_t delay_samples, SAMPLE mix_level, SAMPLE feedback, SAMPLE filter_coef); void config_stereo_reverb(float a_liveness, float crossover_hz, float damping); void init_stereo_reverb(void); void stereo_reverb(SAMPLE *r_in, SAMPLE *l_in, SAMPLE *r_out, SAMPLE *l_out, int n_samples, SAMPLE level); #endif // !_DELAY_H ================================================ FILE: src/envelope.c ================================================ // envelope.c // VCA -- handle modulation and ADSR #include "amy.h" extern const int16_t pcm[]; SAMPLE compute_mod_value(uint16_t mod_osc) { // Return the modulation-rate value for the specified oscillator. // i.e., this oscillator is acting as modulation for something, so // just calculate that modulation rate (without knowing what it // modulates). // Has this mod value already been calculated this frame? Can't // recalculate, because compute_mod advance phase internally. if (synth[mod_osc]->mod_value_clock == amy_global.total_blocks*AMY_BLOCK_SIZE) return synth[mod_osc]->mod_value; synth[mod_osc]->mod_value_clock = amy_global.total_blocks*AMY_BLOCK_SIZE; SAMPLE value = 0; if(synth[mod_osc]->wave == NOISE) value = compute_mod_noise(mod_osc); if(synth[mod_osc]->wave == SAW_DOWN) value = compute_mod_saw_down(mod_osc); if(synth[mod_osc]->wave == SAW_UP) value = compute_mod_saw_up(mod_osc); if(synth[mod_osc]->wave == PULSE) value = compute_mod_pulse(mod_osc); if(synth[mod_osc]->wave == TRIANGLE) value = compute_mod_triangle(mod_osc); if(synth[mod_osc]->wave == SINE) value = compute_mod_sine(mod_osc); if(pcm_samples) if(synth[mod_osc]->wave == PCM) value = compute_mod_pcm(mod_osc); if(AMY_HAS_CUSTOM) { if(synth[mod_osc]->wave == CUSTOM) value = compute_mod_custom(mod_osc); } synth[mod_osc]->mod_value = value; return value; } SAMPLE compute_mod_scale(uint16_t osc) { uint16_t source = synth[osc]->mod_source; if(AMY_IS_SET(source)) { if(source != osc) { // that would be weird hold_and_modify(source); return compute_mod_value(source); } } return 0; // 0 is no change, unlike bp scale } // sample_offset allows you to probe the EG output at some point this many samples into the future. SAMPLE compute_breakpoint_scale(uint16_t osc, uint8_t bp_set, uint16_t sample_offset) { AMY_PROFILE_START(COMPUTE_BREAKPOINT_SCALE) // given a breakpoint list, compute the scale // we first see how many BPs are defined, and where we are in them? int8_t found = -1; int8_t release = 0; uint32_t t1 = 0, t0 = 0; SAMPLE v1 = 0, v0 = 0; int8_t bp_r = 0; t0 = 0; v0 = 0; // exp2(4.328085) = exp(3.0) #define EXP_RATE_VAL -4.328085 const SAMPLE exponential_rate = F2S(EXP_RATE_VAL); // We have to aim to overshoot to the desired gap so that we hit the target by exponential_rate time. const SAMPLE exponential_rate_overshoot_factor = F2S(1.0f / (1.0f - exp2f(EXP_RATE_VAL))); uint32_t elapsed = 0; SAMPLE scale = F2S(1.0f); int eg_type = synth[osc]->eg_type[bp_set]; uint32_t bp_end_times[MAX_BREAKPOINTS]; uint32_t cumulated_time = 0; int sign = 1; // Scan breakpoints to find which one is release (the last one) bp_r = -1; for(int i = 0; i < synth[osc]->max_num_breakpoints[bp_set]; ++i) { uint32_t this_seg_time = synth[osc]->breakpoint_times[bp_set][i]; if (!AMY_IS_SET(this_seg_time)) break; bp_r = i; // Last good segment. cumulated_time += this_seg_time; bp_end_times[i] = cumulated_time; } if(bp_r < 0) { // no breakpoints, return key gate. // Change: Now an empty env reads as 1.0 *all the time*. // If you want a key gate, define bpX='0,1,0,1,0,0' (or maybe just '0,1,0,0'). //if(AMY_IS_SET(synth[osc]->note_off_clock)) scale = 0; synth[osc]->last_scale[bp_set] = scale; //return scale; goto return_label; } // Fix up bp_end_times for release segment to be relative to note-off time. bp_end_times[bp_r] = synth[osc]->breakpoint_times[bp_set][bp_r]; // Find out which BP we're in if(AMY_IS_SET(synth[osc]->note_on_clock)) { elapsed = (amy_global.total_blocks*AMY_BLOCK_SIZE - synth[osc]->note_on_clock + sample_offset) + 1; for(uint8_t i = 0; i < bp_r; i++) { if(elapsed < bp_end_times[i]) { // We found a segment. found = i; break; } } if(found < 0) { // We didn't find anything, so we are in sustain. found = bp_r - 1; // segment before release defines sustain scale = F2S(synth[osc]->breakpoint_values[bp_set][found]); synth[osc]->last_scale[bp_set] = scale; //printf("env: time %lld bpset %d seg %d SUSTAIN %f\n", amy_global.total_blocks*AMY_BLOCK_SIZE, bp_set, found, S2F(scale)); //return scale; goto return_label; } } else if(AMY_IS_SET(synth[osc]->note_off_clock)) { release = 1; elapsed = (amy_global.total_blocks*AMY_BLOCK_SIZE - synth[osc]->note_off_clock + sample_offset); // Get the last t/v pair , for release found = bp_r; t0 = 0; // start the elapsed clock again // Release starts from wherever we got to v0 = synth[osc]->last_scale[bp_set]; if(elapsed > synth[osc]->breakpoint_times[bp_set][bp_r]) { //printf("cbp: time %f osc %d amp %f OFF\n", amy_global.total_blocks*AMY_BLOCK_SIZE / (float)AMY_SAMPLE_RATE, osc, msynth[osc]->amp); // Synth is now turned off in hold_and_modify, which tracks when the amplitude goes to zero (and waits a bit). //synth[osc]->status=SYNTH_OFF; //AMY_UNSET(synth[osc]->note_off_clock); scale = F2S(synth[osc]->breakpoint_values[bp_set][bp_r]); synth[osc]->last_scale[bp_set] = scale; //return scale; goto return_label; } } if(found<0) return scale; t1 = bp_end_times[found]; v1 = F2S(synth[osc]->breakpoint_values[bp_set][found]); if(found>0 && bp_r != found && !release) { t0 = bp_end_times[found-1]; v0 = F2S(synth[osc]->breakpoint_values[bp_set][found-1]); } scale = v0; if (v0 < 0 || v1 < 0) { sign = -1; v0 = -v0; v1 = -v1; } if(t1==t0 || elapsed==t1) { // This way we return exact zero for v1 at the end of the segment, rather than BREAKPOINT_EPS scale = v1; } else { #define BREAKPOINT_EPS 0.0002 // OK, we are transition from v0 to v1 , and we're at elapsed time between t0 and t1 float time_ratio = ((float)(elapsed - t0) / (float)(t1 - t0)); // Compute scale based on which type we have if(eg_type == ENVELOPE_LINEAR) { scale = v0 + MUL4_SS(v1 - v0, F2S(time_ratio)); } else if(eg_type == ENVELOPE_TRUE_EXPONENTIAL) { v0 = MAX(v0, F2S(BREAKPOINT_EPS)); v1 = MAX(v1, F2S(BREAKPOINT_EPS)); SAMPLE dx7_exponential_rate = F2S(S2F(log2_lut(v1) - log2_lut(v0)) / (0.001f * (t1 - t0))); scale = MUL4_SS(v0, exp2_lut(MUL4_SS(dx7_exponential_rate, F2S(0.001f * (elapsed - t0))))); } else if(eg_type == ENVELOPE_DX7) { // Somewhat complicated relationship, see https://colab.research.google.com/drive/1qZmOw4r24IDijUFlel_eSoWEf3L5VSok#scrollTo=F5zkeACrOlum // in SAMPLE version, DX7 levels are div 8 i.e. 0 to 12.375 instead of 0 to 99. #define LINEAR_SAMP_TO_DX7_LEVEL(samp) (S2F(log2_lut(MAX(F2S(BREAKPOINT_EPS), samp))) + 12.375) #define DX7_LEVEL_TO_LINEAR_SAMP(level) (exp2_lut(F2S(level - 12.375))) #define MIN_LEVEL_S 4.25 #define ATTACK_RANGE_S 9.375 #define MAP_ATTACK_LEVEL_S(level) (1 - MAX(level - MIN_LEVEL_S, 0) / ATTACK_RANGE_S) // DX7 is only defined for amps up to 1.0, clip to avoid negative values (which caused a math panic when using float math). v0 = MIN(F2S(1.0f), v0); v1 = MIN(F2S(1.0f), v1); SAMPLE mapped_current_level = F2S(MAP_ATTACK_LEVEL_S(LINEAR_SAMP_TO_DX7_LEVEL(v0))); SAMPLE mapped_target_level = F2S(MAP_ATTACK_LEVEL_S(LINEAR_SAMP_TO_DX7_LEVEL(v1))); float t_const = (t1 - t0) / S2F(log2_lut(mapped_current_level) - log2_lut(mapped_target_level)); float my_t0 = -t_const * S2F(log2_lut(mapped_current_level)); if (v1 > v0) { // This is the magic equation that shapes the DX7 attack envelopes. scale = DX7_LEVEL_TO_LINEAR_SAMP(MIN_LEVEL_S + ATTACK_RANGE_S * S2F(F2S(1.0f) - exp2_lut(-F2S((my_t0 + elapsed)/t_const)))); } else { // Decay is regular true_exponential v0 = MAX(v0, F2S(BREAKPOINT_EPS)); v1 = MAX(v1, F2S(BREAKPOINT_EPS)); //float dx7_exponential_rate = -logf(S2F(v1)/S2F(v0)) / (t1 - t0); //scale = MUL4_SS(v0, F2S(expf(-dx7_exponential_rate * (elapsed - t0)))); SAMPLE dx7_exponential_rate = F2S(S2F(log2_lut(v1) - log2_lut(v0)) / (0.001f * (t1 - t0))); scale = MUL4_SS(v0, exp2_lut(MUL4_SS(dx7_exponential_rate, F2S(0.001f * (elapsed - t0))))); } } else { // ENVELOPE_NORMAL - "false exponential"? or ENVELOPE_DB // After the full amount of time, the exponential decay will reach (1 - expf(-3)) = 0.95 // so make the target gap a little bit bigger, to ensure we meet v1 //scale = v0 + MUL4_SS(v1 - v0, F2S(exponential_rate_overshoot_factor * (1.0f - exp2f(-exponential_rate * time_ratio)))); scale = v0 + MUL4_SS(v1 - v0, MUL4_SS(exponential_rate_overshoot_factor, F2S(1.0f) - exp2_lut(MUL4_SS(exponential_rate, F2S(time_ratio))))); if (scale < 0) scale = 0; // Overshoot ramp-to-zero from limited resolution? //printf("false_exponential time %lld bpset %d seg %d time_ratio %f scale %f\n", amy_global.total_blocks*AMY_BLOCK_SIZE, bp_set, found, time_ratio, S2F(scale)); } } return_label: if (!release) synth[osc]->last_scale[bp_set] = scale; // If sign is negative, flip it back again. if (sign < 0) { scale = -scale; // does not mix well with no_amp_001 } // Keep track of the most-recently returned non-release scale. //if (osc < AMY_OSCS && found != -1) // fprintf(stderr, "env: time %f osc %d bpset %d seg %d type %d t0 %d t1 %d elapsed %d v0 %f v1 %f scale %f\n", amy_global.total_blocks*AMY_BLOCK_SIZE / (float)AMY_SAMPLE_RATE, osc, bp_set, found, eg_type, t0, t1, elapsed, S2F(v0), S2F(v1), S2F(scale)); AMY_PROFILE_STOP(COMPUTE_BREAKPOINT_SCALE) return scale; } ================================================ FILE: src/examples.c ================================================ // examples.c // sound examples #include "amy.h" // set by the arch extern void delay_ms(uint32_t ms); void example_reset(uint32_t start) { amy_event e = amy_default_event(); e.osc = 0; e.reset_osc = RESET_ALL_OSCS; e.time = start; amy_add_event(&e); } void example_voice_alloc() { // alloc 2 juno voices, then try to alloc a dx7 voice on voice 0 amy_event e = amy_default_event(); e.patch_number = 1; e.voices[0] = 0; e.voices[1] = 1; amy_add_event(&e); delay_ms(250); e = amy_default_event(); e.patch_number = 131; e.voices[0] = 0; amy_add_event(&e); delay_ms(250); // play the same note on both e = amy_default_event(); e.velocity = 1; e.midi_note = 60; e.voices[0] = 0; amy_add_event(&e); delay_ms(2000); e = amy_default_event(); e.velocity = 1; e.midi_note = 60; e.voices[0] = 1; amy_add_event(&e); delay_ms(2000); // now try to alloc voice 0 with a juno, should use oscs 0-4 again e = amy_default_event(); e.patch_number = 2; e.voices[0] = 0; amy_add_event(&e); delay_ms(250); } void example_voice_chord(uint32_t start, uint16_t patch_number) { amy_event e = amy_default_event(); e.time = start; e.patch_number = patch_number; e.voices[0] = 0; e.voices[1] = 1; e.voices[2] = 2; amy_add_event(&e); start += 250; e = amy_default_event(); e.time = start; e.velocity=0.5; e.voices[0] = 0; e.midi_note = 50; amy_add_event(&e); start += 1000; e.voices[0] = 1; e.midi_note = 54; e.time = start; amy_add_event(&e); start += 1000; e.voices[0] = 2; e.midi_note = 56; e.time = start; amy_add_event(&e); start += 2000; e.voices[0] = 0; e.voices[1] = 1; e.voices[2] = 2; e.velocity = 0; e.time = start; amy_add_event(&e); } void example_synth_chord(uint32_t start, uint16_t patch_number) { // Like example_voice_chord, but use 'synth' to avoid having to keep track of voices. amy_event e = amy_default_event(); e.time = start; e.patch_number = patch_number; e.num_voices = 3; e.synth = 0; amy_add_event(&e); start += 250; e = amy_default_event(); e.velocity = 0.5; e.synth = 0; e.time = start; e.midi_note = 50; amy_add_event(&e); e.time += 1000; e.midi_note = 54; // Will get a new voice. amy_add_event(&e); e.time += 1000; e.midi_note = 56; amy_add_event(&e); e.time += 2000; e.velocity = 0; // Voices are referenced only by their note, so have to turn them off individually. e.midi_note = 50; amy_add_event(&e); e.midi_note = 54; amy_add_event(&e); e.midi_note = 56; amy_add_event(&e); } void example_sustain_pedal(uint32_t start, uint16_t patch_number) { // Reproduce TestSustainPedal, to track segfault. amy_event e = amy_default_event(); e.time = start; e.reset_osc = RESET_ALL_OSCS; amy_add_event(&e); e = amy_default_event(); e.time = start; e.synth = 1; e.num_voices = 4; e.patch_number = patch_number; amy_add_event(&e); start += 50; e = amy_default_event(); e.time = start; e.synth = 1; e.midi_note = 76; e.velocity = 1.0f; amy_add_event(&e); start += 50; e = amy_default_event(); e.time = start; e.synth = 1; e.midi_note = 76; e.velocity = 0; amy_add_event(&e); start += 50; e = amy_default_event(); e.time = start; e.synth = 1; e.pedal = 127; amy_add_event(&e); start += 50; e = amy_default_event(); e.time = start; e.synth = 1; e.midi_note = 63; e.velocity = 1.0f; amy_add_event(&e); start += 50; e = amy_default_event(); e.time = start; e.synth = 1; e.midi_note = 63; e.velocity = 0; amy_add_event(&e); start += 50; e = amy_default_event(); e.time = start; e.synth = 1; e.midi_note = 67; e.velocity = 1.0f; amy_add_event(&e); start += 50; e = amy_default_event(); e.time = start; e.synth = 1; e.midi_note = 67; e.velocity = 0; amy_add_event(&e); start += 50; e = amy_default_event(); e.time = start; e.synth = 1; e.midi_note = 72; e.velocity = 1.0f; amy_add_event(&e); start += 50; e = amy_default_event(); e.time = start; e.synth = 1; e.pedal = 0; amy_add_event(&e); start += 50; e = amy_default_event(); e.time = start; e.synth = 1; e.midi_note = 72; e.velocity = 0; amy_add_event(&e); } void example_patches() { amy_event e = amy_default_event(); for(uint16_t i=0;i<256;i++) { e.patch_number = i; e.voices[0] = 0; fprintf(stderr, "sending patch %d\n", i); amy_add_event(&e); delay_ms(250); e = amy_default_event(); e.voices[0] = 0; e.osc = 0; e.midi_note = 50; e.velocity = 0.5; amy_add_event(&e); delay_ms(1000); e.voices[0] = 0; e.velocity = 0; amy_add_event(&e); delay_ms(250); amy_reset_oscs(); } } void example_reverb() { if(AMY_HAS_REVERB) { config_reverb(2, REVERB_DEFAULT_LIVENESS, REVERB_DEFAULT_DAMPING, REVERB_DEFAULT_XOVER_HZ); } } void example_chorus() { if(AMY_HAS_CHORUS) { config_chorus(0.8, CHORUS_DEFAULT_MAX_DELAY, CHORUS_DEFAULT_LFO_FREQ, CHORUS_DEFAULT_MOD_DEPTH); } } // Play a KS tone void example_ks(uint32_t start) { amy_event e = amy_default_event(); e.time = start; e.velocity = 1; e.wave = KS; e.feedback = 0.996f; e.preset = 15; e.osc = 0; e.midi_note = 60; amy_add_event(&e); } // make a 440hz sine void example_sine(uint32_t start) { amy_event e = amy_default_event(); e.time = start; e.freq_coefs[0] = 440; e.wave = SINE; e.velocity = 1; amy_add_event(&e); } void example_multimbral_fm() { amy_event e0 = amy_default_event(); amy_event e1 = amy_default_event(); int notes[] = {60, 70, 64, 68, 72, 82}; e1.velocity = 0.5; e0.patch_number = 128; for (unsigned int i = 0; i < sizeof(notes) / sizeof(int); ++i) { e1.midi_note = notes[i]; e1.pan_coefs[0] = (i%2); e0.patch_number++; e0.voices[0] = i; amy_add_event(&e0); amy_add_event(&e1); delay_ms(1000); } } // Emulate the Tulip "drums()" example via event calls. void example_drums(uint32_t start, int loops) { // bd, snare, hat, cow, hicow int oscs[] = {0, 1, 2, 3, 4}; int presets[] = {1, 5, 0, 10, 10}; // Reset all used oscs first, just in case for (unsigned int i = 0; i < sizeof(oscs) / sizeof(int); ++i) { amy_event e_reset = amy_default_event(); e_reset.time = start; e_reset.osc = oscs[i]; e_reset.reset_osc = oscs[i]; amy_add_event(&e_reset); } amy_event e = amy_default_event(); e.time = start + 1; float volume = 0.5; e.wave = PCM; e.velocity = 0; for (unsigned int i = 0; i < sizeof(oscs) / sizeof(int); ++i) { e.osc = oscs[i]; e.preset = presets[i]; amy_add_event(&e); } // Update high cowbell. e = amy_default_event(); e.time = start+1; e.osc = 4; e.midi_note = 70; amy_add_event(&e); // osc 5 : bass e = amy_default_event(); e.time = start+1; e.osc = 5; e.wave = SAW_DOWN; e.filter_freq_coefs[COEF_CONST] = 650.0; // LOWEST filter center frequency. e.filter_freq_coefs[COEF_EG0] = 2.0; // When env0 is 1.0, filter is shifted up by 2.0 octaves (x4, so 2600.0). e.resonance = 5.0; e.filter_type = FILTER_LPF; e.eg0_times[0] = 0; e.eg0_values[0] = 1.0f; e.eg0_times[1] = 500; e.eg0_values[1] = 0.2f; e.eg0_times[2] = 25; e.eg0_values[2] = 0.0f; amy_add_event(&e); const int bd = 1 << 0; const int snare = 1 << 1; const int hat = 1 << 2; const int cow = 1 << 3; const int hicow = 1 << 4; int pattern[] = {bd+hat, hat+hicow, bd+hat+snare, hat+cow, hat, bd+hat, snare+hat, hat}; int bassline[] = {50, 0, 0, 0, 50, 52, 51, 0}; e = amy_default_event(); e.time = start+1; while (loops--) { for (unsigned int i = 0; i < sizeof(pattern) / sizeof(int); ++i) { e.time += 250; AMY_UNSET(e.freq_coefs[0]); AMY_UNSET(e.midi_note); int x = pattern[i]; if(x & bd) { e.osc = 0; e.velocity = 4.0 * volume; amy_add_event(&e); } if(x & snare) { e.osc = 1; e.velocity = 1.5 * volume; amy_add_event(&e); } if(x & hat) { e.osc = 2; e.velocity = 1 * volume; amy_add_event(&e); } if(x & cow) { e.osc = 3; e.velocity = 1 * volume; amy_add_event(&e); } if(x & hicow) { e.osc = 4; e.velocity = 1 * volume; amy_add_event(&e); } e.osc = 5; if(bassline[i]>0) { e.velocity = 0.5 * volume; e.midi_note = bassline[i] - 12; } else { e.velocity = 0; } amy_add_event(&e); } } } void example_sequencer_drums(uint32_t start) { // Play a drum pattern using the low-level sequencer structure amy_event e = amy_default_event(); e.time = start; e.reset_osc = RESET_ALL_OSCS; amy_add_event(&e); // Set tempo so 16 ticks is 108 BPM (not 48 as default). So we make the BPM one-sixth e = amy_default_event(); e.tempo = 108.0f/3; amy_add_event(&e); // Setup oscs for bd, snare, hat, cow, hicow int oscs[] = {0, 1, 2, 3, 4}; int presets[] = {1, 5, 0, 10, 10}; e = amy_default_event(); e.time = start + 1; e.wave = PCM; for (unsigned int i = 0; i < sizeof(oscs) / sizeof(int); ++i) { e.osc = oscs[i]; e.preset = presets[i]; amy_add_event(&e); } // Update high cowbell. e = amy_default_event(); e.time = start + 1; e.osc = 4; e.midi_note = 70; amy_add_event(&e); // Add patterns. // Hi hat every 8 ticks. e = amy_default_event(); e.sequence[SEQUENCE_TAG] = 0; e.sequence[SEQUENCE_PERIOD] = 8; e.sequence[SEQUENCE_TICK] = 0; e.osc = 2; e.velocity = 1.0; amy_add_event(&e); // Bass drum every 32 ticks. e.sequence[SEQUENCE_TAG] = 1; e.sequence[SEQUENCE_PERIOD] = 32; e.sequence[SEQUENCE_TICK] = 0; e.osc = 0; e.velocity = 1.0; amy_add_event(&e); // Snare every 32 ticks, counterphase to BD. e.sequence[SEQUENCE_TAG] = 2; e.sequence[SEQUENCE_PERIOD] = 32; e.sequence[SEQUENCE_TICK] = 16; e.osc = 1; e.velocity = 1.0; amy_add_event(&e); // Cow once every other cycle. e.sequence[SEQUENCE_TAG] = 3; e.sequence[SEQUENCE_PERIOD] = 64; e.sequence[SEQUENCE_TICK] = 60; e.osc = 3; e.velocity = 1.0; amy_add_event(&e); } void example_sequencer_drums_synth(uint32_t start) { // Play a drum pattern using the low-level sequencer structure driving default system drums synth (10) amy_event e; // Add patterns. // Hi hat every 8 ticks. e = amy_default_event(); e.sequence[SEQUENCE_TAG] = 0; e.sequence[SEQUENCE_PERIOD] = 24; e.sequence[SEQUENCE_TICK] = 0; e.synth = 10; e.midi_note = 42; // Closed Hat e.velocity = 1.0; amy_add_event(&e); // Bass drum every 32 ticks. e.sequence[SEQUENCE_TAG] = 1; e.sequence[SEQUENCE_PERIOD] = 96; e.sequence[SEQUENCE_TICK] = 0; e.synth = 10; e.midi_note = 35; // Std kick e.velocity = 1.0; amy_add_event(&e); // Snare every 32 ticks, counterphase to BD. e.sequence[SEQUENCE_TAG] = 2; e.sequence[SEQUENCE_PERIOD] = 96; e.sequence[SEQUENCE_TICK] = 48; e.synth = 10; e.midi_note = 38; // Snare e.velocity = 1.0; amy_add_event(&e); // Cow once every other cycle. e.sequence[SEQUENCE_TAG] = 3; e.sequence[SEQUENCE_PERIOD] = 192; e.sequence[SEQUENCE_TICK] = 180; e.synth = 10; e.midi_note = 56; // Cowbell e.velocity = 1.0; amy_add_event(&e); } void example_fm(uint32_t start) { // Direct construction of an FM tone, as in the documentation. amy_event e; // Modulating oscillator (op 2) e = amy_default_event(); e.time = start; e.osc = 9; e.wave = SINE; e.ratio = 1.0f; e.amp_coefs[COEF_CONST] = 1.0f; e.amp_coefs[COEF_VEL] = 0; e.amp_coefs[COEF_EG0] = 0; amy_add_event(&e); // Output oscillator (op 1) e = amy_default_event(); e.time = start; e.osc = 8; e.wave = SINE; e.ratio = 0.2f; e.amp_coefs[COEF_CONST] = 1.0f; e.amp_coefs[COEF_VEL] = 0; e.amp_coefs[COEF_EG0] = 1.0f; e.eg0_times[0] = 0; e.eg0_values[0] = 1.0f; e.eg0_times[1] = 1000; e.eg0_values[1] = 0.0f; e.eg0_times[2] = 0; e.eg0_values[2] = 0.0f; amy_add_event(&e); // ALGO control oscillator e = amy_default_event(); e.time = start; e.osc = 7; e.wave = ALGO; e.algorithm = 1; // algo 1 has op 2 driving op 1 driving output (plus a second chain for ops 6,5,4,3). e.algo_source[4] = 9; e.algo_source[5] = 8; amy_add_event(&e); // Add a note on event. e = amy_default_event(); e.time = start + 100; e.osc = 7; e.midi_note = 60; e.velocity = 1.0f; amy_add_event(&e); } // Minimal custom oscillator void beeper_init(void) { //printf("Beeper init\n"); } void beeper_deinit(void) { //printf("Beeper deinit\n"); } void beeper_note_on(uint16_t osc, float freq) { saw_down_note_on(osc, freq); } void beeper_note_off(uint16_t osc) { synth[osc]->note_off_clock = amy_global.total_blocks*AMY_BLOCK_SIZE; } void beeper_mod_trigger(uint16_t osc) { saw_down_mod_trigger(osc); } SAMPLE beeper_render(SAMPLE* buf, uint16_t osc) { return render_saw_down(buf, osc); } SAMPLE beeper_compute_mod(uint16_t osc) { return compute_mod_saw_down(osc); } struct custom_oscillator beeper = { beeper_init, beeper_deinit, beeper_note_on, beeper_note_off, beeper_mod_trigger, beeper_render, beeper_compute_mod }; void example_init_custom() { amy_set_custom(&beeper); } void example_custom_beep() { amy_event e = amy_default_event(); e.osc = 50; e.time = amy_sysclock(); e.freq_coefs[0] = 880; e.wave = CUSTOM; e.velocity = 1; amy_add_event(&e); e.velocity = 0; e.time += 500; amy_add_event(&e); } void example_patch_from_events() { int time = amy_sysclock(); int number = 1039; amy_event e = amy_default_event(); e.time = time; e.patch_number = number; e.reset_osc = RESET_PATCH; amy_add_event(&e); e = amy_default_event(); e.time = time; e.patch_number = number; e.osc = 0; e.wave = SAW_DOWN; e.chained_osc = 1; e.eg0_times[0] = 0; e.eg0_values[0] = 1.0f; e.eg0_times[1] = 1000; e.eg0_values[1] = 0.1f; e.eg0_times[2] = 200; e.eg0_values[2] = 0.0f; amy_add_event(&e); e = amy_default_event(); e.time = time; e.patch_number = number; e.osc = 1; e.wave = SINE; e.freq_coefs[COEF_CONST] = 131.0f; e.eg0_times[0] = 0; e.eg0_values[0] = 1.0f; e.eg0_times[1] = 500; e.eg0_values[1] = 0.0f; e.eg0_times[2] = 200; e.eg0_values[2] = 0.0f; amy_add_event(&e); e = amy_default_event(); e.time = time; e.synth = 0; e.num_voices = 4; e.patch_number = number; amy_add_event(&e); e = amy_default_event(); e.time = time + 100; e.synth = 0; e.midi_note = 60.0f; e.velocity = 1.0f; amy_add_event(&e); e = amy_default_event(); e.time = time + 300; e.synth = 0; e.midi_note = 64.0f; e.velocity = 1.0f; amy_add_event(&e); e = amy_default_event(); e.time = time + 500; e.synth = 0; e.midi_note = 67.0f; e.velocity = 1.0f; amy_add_event(&e); e = amy_default_event(); e.time = time + 800; e.synth = 0; e.velocity = 0.0f; amy_add_event(&e); } ================================================ FILE: src/examples.h ================================================ // examples.h // examples.c // sound examples #include "amy.h" void example_reverb(); void example_chorus(); void example_ks(uint32_t start); void bleep(uint32_t start); void bleep_synth(uint32_t start); void example_fm(uint32_t start); void example_multimbral_fm(); void example_drums(uint32_t start, int loops); void example_sequencer_drums(uint32_t start); void example_sequencer_drums_synth(uint32_t start); void example_sine(uint32_t start); void example_init_custom(); void example_custom_beep(); void example_patches(); void example_voice_chord(uint32_t start, uint16_t patch_number); void example_synth_chord(uint32_t start, uint16_t patch_number); void example_sustain_pedal(uint32_t start, uint16_t patch_number); void example_voice_alloc(); void example_reset(uint32_t start); void example_patch_from_events(); ================================================ FILE: src/filters.c ================================================ #include "amy.h" #include "assert.h" #ifndef M_PI #define M_PI 3.14159265358979323846 #endif // Filters tend to get weird under this ratio -- this corresponds to 4.4Hz #define LOWEST_RATIO 0.0001 #define FILT_NUM_DELAYS 4 // Need 4 memories for DFI filters, if used (only 2 for DFII). SAMPLE ** eq_coeffs; SAMPLE *** eq_delay; #ifdef __GNUC__ #pragma GCC diagnostic push // save the actual diag context #pragma GCC diagnostic ignored "-Wuninitialized" // disable maybe warnings #endif float dsps_sqrtf_f32_ansi(float f) { int* f_ptr = (int*)&f; const int result = 0x1fbb4000 + (*f_ptr >> 1); float* f_result = (float*)&result; return *f_result; } #ifdef __GNUC__ #pragma GCC diagnostic pop #endif int8_t dsps_biquad_gen_lpf_f32(SAMPLE *coeffs, float f, float qFactor) { //qFactor = sqrtf(qFactor); if (qFactor < 0.51) { qFactor = 0.51; } if (f > 0.45) { f = 0.45; } float Fs = 1; float w0 = 2 * M_PI * f / Fs; w0 = MAX(0.01, w0); // so f >= Fs * 0.01 / (2 pi) = 70.2 Hz float c = cosf(w0); float s = sinf(w0); float alpha = s / (2 * qFactor); // sin w0 / (2 Q) < 1 // => sin w0 < 2 Q // If Q >= 0.5, no problem. float b0 = (1 - c) / 2; float b1 = 1 - c; float b2 = b0; float a0 = 1 + alpha; float a1 = -2 * c; float a2 = 1 - alpha; // Where exactly are those poles? Impose minima on (1 - r) and w0. float r = -99, ww = 0; if (false && a2 > 0) { printf("before: r %f a %f %f %f\n", sqrtf(a2 / a0), a0, a1, a2); // Limit how close complex poles can get to the unit circle. r = MIN(0.99, sqrtf(a2 / a0)); float alphadash = (1 - r * r) / (1 + r * r); float cosww = c / sqrtf(1 - alphadash * alphadash); if (fabs(cosww) < 1.0) { ww = acosf(cosww); a1 = a0 * (-2 * r * cosf(ww)); a2 = a0 * r * r; printf(" after: r %f a %f %f %f\n", r, a0, a1, a2); } } coeffs[0] = F2S(-b0 / a0); coeffs[1] = F2S(-b1 / a0); coeffs[2] = F2S(-b2 / a0); coeffs[3] = F2S(a1 / a0); coeffs[4] = F2S(a2 / a0); //printf("Flpf t=%f f=%f q=%f alpha %f b0 %f b1 %f b2 %f a1 %f a2 %f r %f theta %f\n", amy_global.total_blocks*AMY_BLOCK_SIZE / (float)AMY_SAMPLE_RATE, f * AMY_SAMPLE_RATE, qFactor, alpha, // b0 / a0, b1 / a0, b2 / a0, a1 / a0, a2 / a0, r, w0); //printf("Slpf t=%f f=%f q=%f b0 %f b1 %f b2 %f a1 %f a2 %f\n", amy_global.total_blocks*AMY_BLOCK_SIZE / (float)AMY_SAMPLE_RATE, f * AMY_SAMPLE_RATE, qFactor, // S2F(coeffs[0]), S2F(coeffs[1]), S2F(coeffs[2]), S2F(coeffs[3]), S2F(coeffs[4])); return 0; } int8_t dsps_biquad_gen_hpf_f32(SAMPLE *coeffs, float f, float qFactor) { if (qFactor <= 0.0001) { qFactor = 0.0001; } if (f > 0.45) { f = 0.45; } float Fs = 1; float w0 = 2 * M_PI * f / Fs; float c = cosf(w0); float s = sinf(w0); float alpha = s / (2 * qFactor); float b0 = (1 + c) / 2; float b1 = -(1 + c); float b2 = b0; float a0 = 1 + alpha; float a1 = -2 * c; float a2 = 1 - alpha; coeffs[0] = F2S(b0 / a0); coeffs[1] = F2S(b1 / a0); coeffs[2] = F2S(b2 / a0); coeffs[3] = F2S(a1 / a0); coeffs[4] = F2S(a2 / a0); return 0; } int8_t dsps_biquad_gen_bpf_f32(SAMPLE *coeffs, float f, float qFactor) { if (qFactor <= 0.0001) { qFactor = 0.0001; } if (f > 0.45) { f = 0.45; } float Fs = 1; float w0 = 2 * M_PI * f / Fs; float c = cosf(w0); float s = sinf(w0); float alpha = s / (2 * qFactor); float b0 = s / 2; float b1 = 0; float b2 = -b0; float a0 = 1 + alpha; float a1 = -2 * c; float a2 = 1 - alpha; coeffs[0] = F2S(b0 / a0); coeffs[1] = F2S(b1 / a0); coeffs[2] = F2S(b2 / a0); coeffs[3] = F2S(a1 / a0); coeffs[4] = F2S(a2 / a0); return 0; } // Stick to the faster mult for biquad, hpf etc, since the parameters aren't so sensitive, and parametric_eq was chewing major CPU. #define FILT_MUL_SS(a, b) SMULR6(a, b) #define FILTER_SCALEUP_BITS 0 // Apply this gain to input before filtering to avoid underflow in intermediate value. #define FILTER_BIQUAD_SCALEUP_BITS 0 // Apply this gain to input before filtering to avoid underflow in intermediate value. #define FILTER_BIQUAD_SCALEDOWN_BITS 0 // Extra headroom for EQ filters to avoid clipping on loud signals. int8_t dsps_biquad_f32_ansi(const SAMPLE *input, SAMPLE *output, int len, SAMPLE *coef, SAMPLE *w) { AMY_PROFILE_START(DSPS_BIQUAD_F32_ANSI) // Zeros then poles - Direct Form I // We need 2 memories for input, and 2 for output. SAMPLE x1 = w[0]; SAMPLE x2 = w[1]; SAMPLE y1 = w[2]; SAMPLE y2 = w[3]; for (int i = 0 ; i < len ; i++) { SAMPLE x0 = SHIFTL(input[i], FILTER_BIQUAD_SCALEUP_BITS); // SAMPLE x0 = SHIFTR(input[i], FILTER_BIQUAD_SCALEDOWN_BITS); SAMPLE w0 = FILT_MUL_SS(coef[0], x0) + FILT_MUL_SS(coef[1], x1) + FILT_MUL_SS(coef[2], x2); SAMPLE y0 = w0 - FILT_MUL_SS(coef[3], y1) - FILT_MUL_SS(coef[4], y2); x2 = x1; x1 = x0; y2 = y1; y1 = y0; output[i] = SHIFTR(y0, FILTER_BIQUAD_SCALEUP_BITS); //output[i] = SHIFTL(y0, FILTER_BIQUAD_SCALEDOWN_BITS); } w[0] = x1; w[1] = x2; w[2] = y1; w[3] = y2; AMY_PROFILE_STOP(DSPS_BIQUAD_F32_ANSI) return 0; } int8_t dsps_biquad_f32_ansi_split_fb(const SAMPLE *input, SAMPLE *output, int len, SAMPLE *coef, SAMPLE *w) { AMY_PROFILE_START(DSPS_BIQUAD_F32_ANSI_SPLIT_FB) // Rewrite the feeedback coefficients as a1 = -2 + e and a2 = 1 - f SAMPLE x1 = w[0]; SAMPLE x2 = w[1]; SAMPLE y1 = w[2]; SAMPLE y2 = w[3]; SAMPLE e = F2S(2.0f) + coef[3]; // So coef[3] = -2 + e SAMPLE f = F2S(1.0f) - coef[4]; // So coef[4] = 1 - f //fprintf(stderr, "e=%f (%d) f=%f\n", S2F(e), (e < F2S(0.0625)), S2F(f)); for (int i = 0 ; i < len ; i++) { SAMPLE x0 = SHIFTL(input[i], FILTER_SCALEUP_BITS); SAMPLE w0 = FILT_MUL_SS(coef[0], x0) + FILT_MUL_SS(coef[1], x1) + FILT_MUL_SS(coef[2], x2); SAMPLE y0 = w0 + SHIFTL(y1, 1) - y2; y0 = y0 - FILT_MUL_SS(e, y1) + FILT_MUL_SS(f, y2); x2 = x1; x1 = x0; y2 = y1; y1 = y0; output[i] = SHIFTR(y0, FILTER_SCALEUP_BITS); } w[0] = x1; w[1] = x2; w[2] = y1; w[3] = y2; AMY_PROFILE_STOP(DSPS_BIQUAD_F32_ANSI_SPLIT_FB) return 0; } // 16 bit pseudo floating-point multiply. // See https://colab.research.google.com/drive/1_uQto5WSVMiSPHQ34cHbCC6qkF614EoN#scrollTo=njPHwSB9VIJi static inline SAMPLE ABS(SAMPLE a) { if (a > 0) return a; else return -a; } static inline int headroom(SAMPLE a) { // How many bits bigger can this value get before overflow? #ifdef AMY_USE_FIXEDPOINT return __builtin_clz(ABS(a) | 1) - 1; // -1 for sign bit. #else // !AMY_USE_FIXEDPOINT // How many bits can you shift before this max overflows? int bits = 0; while(a < F2S(128.0) && bits < 32) { a = SHIFTL(a, 1); ++bits; } return bits; #endif // AMY_USE_FIXEDPOINT } static inline int nheadroom16(SAMPLE a) { // Headroom with MAX(0, 16 - headroom(a)) precomputed. #ifdef AMY_USE_FIXEDPOINT return MAX(0, 16 - (__builtin_clz(ABS(a) | 1) - 1)); // -1 for sign bit. #else // !AMY_USE_FIXEDPOINT // How many bits can you shift before this max overflows? int bits = 0; while(a < F2S(128.0) && bits < 32) { a = SHIFTL(a, 1); ++bits; } return bits; #endif // AMY_USE_FIXEDPOINT } #ifdef AMY_USE_FIXEDPOINT SAMPLE top16SMUL(SAMPLE a, SAMPLE b) { // Multiply the top 15 bits of a and b. //int adropped = MAX(0, 16 - headroom(a)); int adropped = nheadroom16(a); //MAX(0, 16 - headroom(a)); if (adropped) { a = SHIFTR(SHIFTR(a, adropped - 1) + 1, 1); } int resultdrop = 23 - adropped; int bdropped = MIN(resultdrop, nheadroom16(b)); // MAX(0, 16 - headroom(b))); if (bdropped) { //b = SHIFTR(b + (1 << (bdropped - 1)), bdropped); b = SHIFTR(SHIFTR(b, bdropped - 1) + 1, 1); } resultdrop -= bdropped; SAMPLE result = a * b; if (resultdrop) { //return SHIFTR(result + (1 << (resultdrop - 1)), resultdrop); return SHIFTR(SHIFTR(result, resultdrop - 1) + 1, 1); } return result; } SAMPLE top16SMUL_a_part(SAMPLE a, int *p_resultdrop) { // Just the processing of a, so we can split it out int adropped = nheadroom16(a); if (adropped) { //a = SHIFTR(a + (1 << (adropped - 1)), adropped); a = SHIFTR(SHIFTR(a, adropped - 1) + 1, 1); } *p_resultdrop = 23 - adropped; return a; } SAMPLE top16SMUL_after_a(SAMPLE a_processed, SAMPLE b, int resultdrop, int bnheadroom16) { // The rest of top16SMUL after a has been preprocessed by top16SML_a_part. //int bdropped = MIN(resultdrop, MAX(0, 16 - bheadroom)); int bdrop = MIN(resultdrop, bnheadroom16); if (bdrop) { //b = SHIFTR(b + (1 << (bdrop - 1)), bdrop); b = SHIFTR(SHIFTR(b, bdrop - 1) + 1, 1); resultdrop -= bdrop; } SAMPLE result = a_processed * b; if (resultdrop) { //return SHIFTR(result + (1 << (resultdrop - 1)), resultdrop); return SHIFTR(SHIFTR(result, resultdrop - 1) + 1, 1); } return result; } #else // !AMY_USE_FIXEDPOINT // Sidestep all this logic for SAMPLE == float. SAMPLE top16SMUL(SAMPLE a, SAMPLE b) { return a * b; } SAMPLE top16SMUL_a_part(SAMPLE a, int *p_adropped) { *p_adropped = 0; // dropped_bits registration unused in float. return a; } SAMPLE top16SMUL_after_a(SAMPLE a_processed, SAMPLE b, int adropped_unused, int bheadroom_unused) { return a_processed * b; } #endif // AMY_USE_FIXEDPOINT SAMPLE scan_max(SAMPLE* block, int len) { AMY_PROFILE_START(SCAN_MAX) // Find the max abs sample value in a block. SAMPLE max = 0; while (len--) { SAMPLE val = *block++; if (val > max) max = val; else if ((-val) > max) max = -val; } AMY_PROFILE_STOP(SCAN_MAX) return max; } // This is the multiply just for dsps_biquad_f32_ansi_split_fb_twice, which is only used for FILTER_LPF24. #define FILT_MUL_SS_24(a, b) top16SMUL(a, b) SAMPLE dsps_biquad_f32_ansi_split_fb_once(const SAMPLE *input, SAMPLE *output, int len, SAMPLE *coef, SAMPLE *w, SAMPLE max_val) { // Apply the filter once (for 12 dB/oct LPF) AMY_PROFILE_START(DSPS_BIQUAD_F32_ANSI_SPLIT_FB) // Rewrite the feeedback coefficients as a1 = -2 + e and a2 = 1 - f SAMPLE x1 = w[0]; SAMPLE x2 = w[1]; SAMPLE y1 = w[2]; SAMPLE y2 = w[3]; SAMPLE state_max = scan_max(w, 4); int abits, bbits, cbits, ebits, fbits; SAMPLE a = top16SMUL_a_part(coef[0], &abits); SAMPLE e = top16SMUL_a_part(F2S(2.0f) + coef[3], &ebits); // So coef[3] = -2 + e SAMPLE f = top16SMUL_a_part(F2S(1.0f) - coef[4], &fbits); // So coef[4] = 1 - f assert(FILTER_SCALEUP_BITS == 0); bbits = nheadroom16(max_val); cbits = nheadroom16(SHIFTL(MAX(state_max, max_val), 2)); SAMPLE max_out = 0; for (int i = 0 ; i < len ; i++) { SAMPLE x0 = top16SMUL_after_a(a, input[i], abits, bbits); // headroom(input[i]); SAMPLE w0 = x0 + SHIFTL(x1, 1) + x2; SAMPLE y0 = w0 + SHIFTL(y1, 1) - y2; y0 = y0 - top16SMUL_after_a(e, y1, ebits, cbits) //headroom(y1)) + top16SMUL_after_a(f, y2, fbits, cbits); //headroom(y2)); x2 = x1; x1 = x0; y2 = y1; y1 = y0; output[i] = y0; if (y0 < 0) y0 = -y0; if (y0 > 0) { if (y0 > max_out) max_out = y0; } else { if (-y0 > max_out) max_out = -y0; } } w[0] = x1; w[1] = x2; w[2] = y1; w[3] = y2; AMY_PROFILE_STOP(DSPS_BIQUAD_F32_ANSI_SPLIT_FB) return max_out; } SAMPLE dsps_biquad_f32_ansi_split_fb_twice(const SAMPLE *input, SAMPLE *output, int len, SAMPLE *coef, SAMPLE *w, SAMPLE max_val) { // Apply the filter twice AMY_PROFILE_START(DSPS_BIQUAD_F32_ANSI_SPLIT_FB_TWICE) // Rewrite the feeedback coefficients as a1 = -2 + e and a2 = 1 - f SAMPLE x1 = w[0]; SAMPLE x2 = w[1]; SAMPLE y1 = w[2]; SAMPLE y2 = w[3]; SAMPLE v1 = w[4]; SAMPLE v2 = w[5]; SAMPLE state_max = scan_max(w, 6); int abits, bbits, cbits, ebits, fbits; SAMPLE a = top16SMUL_a_part(coef[0], &abits); SAMPLE e = top16SMUL_a_part(F2S(2.0f) + coef[3], &ebits); // So coef[3] = -2 + e SAMPLE f = top16SMUL_a_part(F2S(1.0f) - coef[4], &fbits); // So coef[4] = 1 - f assert(FILTER_SCALEUP_BITS == 0); bbits = nheadroom16(max_val); cbits = nheadroom16(SHIFTL(MAX(state_max, max_val), 2)); SAMPLE max_out = 0; for (int i = 0 ; i < len ; i++) { SAMPLE x0, w0, v0; x0 = top16SMUL_after_a(a, input[i], abits, bbits); // headroom(input[i]); w0 = x0 + SHIFTL(x1, 1) + x2; v0 = w0 + SHIFTL(v1, 1) - v2; v0 = v0 - top16SMUL_after_a(e, v1, ebits, cbits) //headroom(v1)) + top16SMUL_after_a(f, v2, fbits, cbits); //headroom(v2)); w0 = v0 + SHIFTL(v1, 1) + v2; w0 = top16SMUL_after_a(a, w0, abits, cbits); //headroom(w0)); SAMPLE y0 = w0 + SHIFTL(y1, 1) - y2; y0 = y0 - top16SMUL_after_a(e, y1, ebits, cbits) //headroom(y1)) + top16SMUL_after_a(f, y2, fbits, cbits); //headroom(y2)); x2 = x1; x1 = x0; v2 = v1; v1 = v0; y2 = y1; y1 = y0; output[i] = y0; if (y0 < 0) y0 = -y0; if (y0 > 0) { if (y0 > max_out) max_out = y0; } else { if (-y0 > max_out) max_out = -y0; } } w[0] = x1; w[1] = x2; w[2] = y1; w[3] = y2; w[4] = v1; w[5] = v2; AMY_PROFILE_STOP(DSPS_BIQUAD_F32_ANSI_SPLIT_FB_TWICE) return max_out; } int8_t dsps_biquad_f32_ansi_commuted(const SAMPLE *input, SAMPLE *output, int len, SAMPLE *coef, SAMPLE *w) { AMY_PROFILE_START(DSPS_BIQUAD_F32_ANSI_COMMUTED) // poles before zeros, for Direct Form II for (int i = 0 ; i < len ; i++) { SAMPLE d0 = input[i] - FILT_MUL_SS(coef[3], w[0]) - FILT_MUL_SS(coef[4], w[1]); output[i] = FILT_MUL_SS(coef[0], d0) + FILT_MUL_SS(coef[1], w[0]) + FILT_MUL_SS(coef[2], w[1]); w[1] = w[0]; w[0] = d0; } AMY_PROFILE_STOP(DSPS_BIQUAD_F32_ANSI_COMMUTED) return 0; } void filters_deinit() { for(uint16_t i=0;i b) return a; return b; } void parametric_eq_process_top16block(SAMPLE *block) { // Optimized to run all 3 filters interleaved, to avoid extra buffers/buf accesses. AMY_PROFILE_START(PARAMETRIC_EQ_PROCESS) for(int c = 0; c < AMY_NCHANS; ++c) { SAMPLE *cblock = block + c * AMY_BLOCK_SIZE; // Zeros then poles - Direct Form I // We need 2 memories for input, and 2 for output. SAMPLE x1 = eq_delay[c][0][0]; SAMPLE x2 = eq_delay[c][0][1]; SAMPLE y01 = eq_delay[c][0][2]; SAMPLE y02 = eq_delay[c][0][3]; SAMPLE y11 = eq_delay[c][1][2]; SAMPLE y12 = eq_delay[c][1][3]; SAMPLE y21 = eq_delay[c][2][2]; SAMPLE y22 = eq_delay[c][2][3]; int c00bits, c03bits, c04bits; int c10bits, c13bits, c14bits; int c20bits, c23bits, c24bits; // int c21bits, c22bits, c11bits, c12bits, c01bits, c02bits; // Fold the global EQ parameters into the forward-gains of each stage. SAMPLE c00 = top16SMUL_a_part(top16SMUL(amy_global.eq[0], eq_coeffs[0][0]), &c00bits); SAMPLE c03 = top16SMUL_a_part(eq_coeffs[0][3], &c03bits); SAMPLE c04 = top16SMUL_a_part(eq_coeffs[0][4], &c04bits); SAMPLE c10 = top16SMUL_a_part(top16SMUL(amy_global.eq[1], eq_coeffs[1][0]), &c10bits); SAMPLE c13 = top16SMUL_a_part(eq_coeffs[1][3], &c13bits); SAMPLE c14 = top16SMUL_a_part(eq_coeffs[1][4], &c14bits); SAMPLE c20 = top16SMUL_a_part(top16SMUL(amy_global.eq[2], eq_coeffs[2][0]), &c20bits); SAMPLE c23 = top16SMUL_a_part(eq_coeffs[2][3], &c23bits); SAMPLE c24 = top16SMUL_a_part(eq_coeffs[2][4], &c24bits); for (int i = 0 ; i < AMY_BLOCK_SIZE ; i++) { SAMPLE x0 = cblock[i]; SAMPLE x1times2 = SHIFTL(x1, 1); int xbits = nheadroom16(MAXABS2(x0, MAXABS2(x1times2, x2))); // Optimize the FIR multiplies for the known structure of the zeros in LPF/BPF/HPF. SAMPLE w00 = top16SMUL_after_a(c00, x0 + x1times2 + x2, c00bits, xbits); int y0bits = nheadroom16(MAXABS2(y01, y02)); SAMPLE y00 = w00 - top16SMUL_after_a(c03, y01, c03bits, y0bits) - top16SMUL_after_a(c04, y02, c04bits, y0bits); SAMPLE w10 = top16SMUL_after_a(c10, x0 - x2, c10bits, xbits); int y1bits = nheadroom16(MAXABS2(y11, y12)); SAMPLE y10 = w10 - top16SMUL_after_a(c13, y11, c13bits, y1bits) - top16SMUL_after_a(c14, y12, c14bits, y1bits); SAMPLE w20 = top16SMUL_after_a(c20, x0 - x1times2 + x2, c20bits, xbits); int y2bits = nheadroom16(MAXABS2(y21, y22)); SAMPLE y20 = w20 - top16SMUL_after_a(c23, y21, c23bits, y2bits) - top16SMUL_after_a(c24, y22, c24bits, y2bits); x2 = x1; x1 = x0; y02 = y01; y01 = y00; y12 = y11; y11 = y10; y22 = y21; y21 = y20; cblock[i] = y00 - y10 + y20; } eq_delay[c][0][0] = x1; eq_delay[c][0][1] = x2; eq_delay[c][0][2] = y01; eq_delay[c][0][3] = y02; eq_delay[c][1][2] = y11; eq_delay[c][1][3] = y12; eq_delay[c][2][2] = y21; eq_delay[c][2][3] = y22; } AMY_PROFILE_STOP(PARAMETRIC_EQ_PROCESS) } void hpf_buf(SAMPLE *buf, SAMPLE *state) { AMY_PROFILE_START(HPF_BUF) // Implement a dc-blocking HPF with a pole at (decay + 0j) and a zero at (1 + 0j). SAMPLE pole = F2S(0.99); SAMPLE xn1 = state[0]; SAMPLE yn1 = state[1]; for (uint16_t i = 0; i < AMY_BLOCK_SIZE; ++i) { SAMPLE w = buf[i] - xn1; xn1 = buf[i]; buf[i] = w + FILT_MUL_SS(pole, yn1); yn1 = buf[i]; } state[0] = xn1; state[1] = yn1; AMY_PROFILE_STOP(HPF_BUF) } void check_overflow(SAMPLE* block, int osc, char *msg) { // Search for overflow in a sample buffer as an unusually large sample-to-sample delta. #ifdef AMY_DEBUG SAMPLE last = block[0]; SAMPLE max = 0; SAMPLE maxdiff = 0; int len = AMY_BLOCK_SIZE; while (len--) { SAMPLE val = *block++; SAMPLE diff = val - last; if (diff < 0) diff = -diff; if (diff > maxdiff) maxdiff = diff; last = val; if (val < 0) val = -val; if (val > max) max = val; } if (maxdiff > F2S(0.2f)) fprintf(stderr, "Overflow at timeframe %.3f max=%.3f maxdiff=%.3f osc=%d msg=%s\n", (float)(amy_global.total_blocks*AMY_BLOCK_SIZE) / AMY_SAMPLE_RATE, S2F(max), S2F(maxdiff), osc, msg); #endif // AMY_DEBUG } SAMPLE block_norm(SAMPLE* block, int len, int bits) { AMY_PROFILE_START(BLOCK_NORM) SAMPLE max_val = 0; if (bits >= 0) { // do this even if bits == 0 to ensure max_val is set. while(len--) { *block = SHIFTL(*block, bits); if (*block > 0) { if (*block > max_val) max_val = *block; } else { if (-*block > max_val) max_val = -*block; } ++block; } } else { // bits is negative - right-shift. bits = -bits; while(len--) { *block = SHIFTR(*block, bits); if (*block > 0) { if (*block > max_val) max_val = *block; } else { if (-*block > max_val) max_val = -*block; } ++block; } } AMY_PROFILE_STOP(BLOCK_NORM) return max_val; } SAMPLE block_denorm(SAMPLE* block, int len, int bits) { return block_norm(block, len, -bits); } SAMPLE filter_process(SAMPLE * block, uint16_t osc, SAMPLE max_val) { SAMPLE coeffs[5]; SAMPLE filtmax = scan_max(synth[osc]->filter_delay, 2 * FILT_NUM_DELAYS); if (max_val == 0 && filtmax == 0) return 0; AMY_PROFILE_START(FILTER_PROCESS) AMY_PROFILE_START(FILTER_PROCESS_STAGE0) float ratio = freq_of_logfreq(msynth[osc]->filter_logfreq)/(float)AMY_SAMPLE_RATE; if(ratio < LOWEST_RATIO) ratio = LOWEST_RATIO; if(synth[osc]->filter_type==FILTER_LPF || synth[osc]->filter_type==FILTER_LPF24) dsps_biquad_gen_lpf_f32(coeffs, ratio, msynth[osc]->resonance); else if(synth[osc]->filter_type==FILTER_BPF) dsps_biquad_gen_bpf_f32(coeffs, ratio, msynth[osc]->resonance); else if(synth[osc]->filter_type==FILTER_HPF) dsps_biquad_gen_hpf_f32(coeffs, ratio, msynth[osc]->resonance); else { fprintf(stderr, "Unrecognized filter type %d\n", synth[osc]->filter_type); return 0; } AMY_PROFILE_STOP(FILTER_PROCESS_STAGE0) #ifdef NOTDEF printf("FlPr t=%.3f f=%.3f q=%.3f %.3f %.3f %.3f %.3f %.3f ST %.6f %.6f %.6f %.6f %.6f %.6f %.6f %.6f B %.6f %.6f %.6f %.6f\n", amy_global.total_blocks*AMY_BLOCK_SIZE / (float)AMY_SAMPLE_RATE, ratio * AMY_SAMPLE_RATE, msynth[osc]->resonance, S2F(coeffs[0]), S2F(coeffs[1]), S2F(coeffs[2]), S2F(coeffs[3]), S2F(coeffs[4]), S2F(synth[osc]->filter_delay[0]), S2F(synth[osc]->filter_delay[1]), S2F(synth[osc]->filter_delay[2]), S2F(synth[osc]->filter_delay[3]), S2F(synth[osc]->filter_delay[4]), S2F(synth[osc]->filter_delay[5]), S2F(synth[osc]->filter_delay[6]), S2F(synth[osc]->filter_delay[7]), S2F(block[0]), S2F(block[1]), S2F(block[2]), S2F(block[3]) ); #endif AMY_PROFILE_START(FILTER_PROCESS_STAGE1) //SAMPLE max_val = scan_max(block, AMY_BLOCK_SIZE); // Also have to consider the filter state. #define USE_BLOCK_FLOATING_POINT #ifdef USE_BLOCK_FLOATING_POINT int filtnormbits = synth[osc]->last_filt_norm_bits + headroom(filtmax); #define HEADROOM_BITS 6 #define STATE_HEADROOM_BITS 2 int normbits = MIN(MAX(0, headroom(max_val) - HEADROOM_BITS), MAX(0, filtnormbits - STATE_HEADROOM_BITS)); normbits = MIN(normbits, synth[osc]->last_filt_norm_bits + 1); // Increase at most one bit per block. normbits = MIN(8, normbits); // Without this, I get a weird sign flip at the end of TestLFO - intermediate overflow? #else // No block floating point const int normbits = 0; // defeat BFP #endif //printf("time %f max_val %f filtmax %f lastfiltnormbits %d filtnormbits %d normbits %d\n", amy_global.total_blocks*AMY_BLOCK_SIZE / (float)AMY_SAMPLE_RATE, S2F(max_val), S2F(filtmax), synth[osc]->last_filt_norm_bits, filtnormbits, normbits); if(synth[osc]->filter_type==FILTER_LPF24) { // 24 dB/oct by running the same filter twice. max_val = dsps_biquad_f32_ansi_split_fb_twice(block, block, AMY_BLOCK_SIZE, coeffs, synth[osc]->filter_delay, max_val); //} else if(synth[osc]->filter_type==FILTER_LPF) { // Optimized block-floating point 12 dB/oct LPF //max_val = dsps_biquad_f32_ansi_split_fb_once(block, block, AMY_BLOCK_SIZE, coeffs, synth[osc]->filter_delay, max_val); } else { block_norm(synth[osc]->filter_delay, 2 * FILT_NUM_DELAYS, normbits - synth[osc]->last_filt_norm_bits); block_norm(block, AMY_BLOCK_SIZE, normbits); dsps_biquad_f32_ansi_split_fb(block, block, AMY_BLOCK_SIZE, coeffs, synth[osc]->filter_delay); max_val = block_denorm(block, AMY_BLOCK_SIZE, normbits); synth[osc]->last_filt_norm_bits = normbits; } //dsps_biquad_f32_ansi_commuted(block, block, AMY_BLOCK_SIZE, coeffs, synth[osc]->filter_delay); //block_denorm(synth[osc]->filter_delay, 2 * FILT_NUM_DELAYS, normbits); // Final high-pass to remove residual DC offset from sub-fundamental LPF. (Not needed now source waveforms are zero-mean). AMY_PROFILE_STOP(FILTER_PROCESS_STAGE1) AMY_PROFILE_STOP(FILTER_PROCESS) #ifdef NOTDEF printf("FlP2 t=%.3f f=%.3f q=%.3f %.3f %.3f %.3f %.3f %.3f ST %.6f %.6f %.6f %.6f %.6f %.6f %.6f %.6f B %.6f %.6f %.6f %.6f\n", amy_global.total_blocks*AMY_BLOCK_SIZE / (float)AMY_SAMPLE_RATE, ratio * AMY_SAMPLE_RATE, msynth[osc]->resonance, S2F(coeffs[0]), S2F(coeffs[1]), S2F(coeffs[2]), S2F(coeffs[3]), S2F(coeffs[4]), S2F(synth[osc]->filter_delay[0]), S2F(synth[osc]->filter_delay[1]), S2F(synth[osc]->filter_delay[2]), S2F(synth[osc]->filter_delay[3]), S2F(synth[osc]->filter_delay[4]), S2F(synth[osc]->filter_delay[5]), S2F(synth[osc]->filter_delay[6]), S2F(synth[osc]->filter_delay[7]), S2F(block[0]), S2F(block[1]), S2F(block[2]), S2F(block[3]) ); #endif return max_val; } void reset_filter(uint16_t osc) { // Reset all the filter state to zero. // The LPF has typically accumulated a large DC offset, so you have to reset both // the LPF *and* the dc-blocking HPF at the same time. for(int i = 0; i < 2 * FILT_NUM_DELAYS; ++i) synth[osc]->filter_delay[i] = 0; synth[osc]->last_filt_norm_bits = 0; } void reset_parametric(void) { for (int c = 0; c < AMY_NCHANS; ++c) { for (int b = 0; b < 3; ++b) { for (int d = 0; d < FILT_NUM_DELAYS; ++d) { eq_delay[c][b][d] = 0; } } } } ================================================ FILE: src/i2s.c ================================================ // i2s.c // handle i2s audio in & out on many platforms // esp32 --> esp32, esp32-s3, esp32-p4 // AMYBOARD, which is a esp32s3 but with special i2s setup // rp2350, rp2040 // teensy 3.6, 4.0, 4.1 // Only run this code on MCUs #if defined(ESP_PLATFORM) || defined(ARDUINO_ARCH_RP2040) || defined(ARDUINO) || defined(ARDUINO_ARCH_RP2350) #include "amy.h" #ifdef ESP_PLATFORM #include /////////////////////////////////////////////////////////////// // ESP32, S3, P4 (maybe others) // A note on RTOS synchronization: // For maximumum flexibility, AMY offers two flags: // - config.platform.multicore - whether to use a second core, if avaliable. // - config.platform.multithread - whether to use RTOS multithreading, if avaliable. // (ESP32 is the only platform where we've tried RTOS, so it's the only context where multithread matters). // When using RTOS threads (tasks), synchronization is handled by xTaskNotifyGive(task_handle) / ulTaskNotifyTake(): // A service task waits to be notified by calling ulTaskNotifyTake(); that call does not specify where that // notification comes from. Another task calls xTaskNotifyGive() naming the particular task to be notified, // which then releases the ulTaskNotifyTake() in that task. // We use this mechanism as follows: // * esp_render_task (the task that runs on the second core): // - Waits for notification (from main fill_audio thread) // - renders half the oscs // - notifies either fill_buffer (multithread) or amy_update (single thread) when done. // - loop // * esp_fill_audio_buffer_task (launched as one parallel task): // - if not using I2S, waits for notification (from amy_update task) // - read I2S input (if used) // - execute AMY command updates (deltas) // - Notify esp_render_task // - render the other half of oscs // - Wait for notification (indicating that esp_render_task is done) // - call amy_fill_buffer (to combine the rendered oscs into output samples) // - Notify amy_update_handle that the new block is ready // - If I2S enabled, write samples to I2S. // - loop // * ESP's amy_platform_init // - if multicore, launch esp_render_task // - if multithread, launch esp_fill_audio_buffer_task // - if not I2S, Notify fill_buffer to get it started // * ESP's amy_render_audio // - If multithread, wait for Notification (from fill_audio_buffer) // - If not I2S, Notify fill_buffer // - If not multithread // - If multicore, Notify amy_render_handle to get task on second core to render // - wait for Notification indicating esp_render_task is done // - else render all oscs // - call amy_fill_buffer #include "driver/i2s_std.h" #ifdef AMYBOARD_ARDUINO #include "driver/i2c.h" #endif i2s_chan_handle_t tx_handle; i2s_chan_handle_t rx_handle; #if !defined(AMYBOARD) && !defined(AMYBOARD_ARDUINO) // default ESP setup i2s amy_err_t esp32_setup_i2s(void) { i2s_chan_config_t chan_cfg = I2S_CHANNEL_DEFAULT_CONFIG(I2S_NUM_AUTO, I2S_ROLE_MASTER); if(AMY_HAS_AUDIO_IN) { i2s_new_channel(&chan_cfg, &tx_handle, &rx_handle); } else { i2s_new_channel(&chan_cfg, &tx_handle, NULL); } // PCM5101 DAC works at either 32 bit or (default) 16 bit // PCM1808 ADC needs I2S_32BIT to work #define I2S_32BIT #ifdef I2S_32BIT i2s_std_config_t std_cfg = { .clk_cfg = I2S_STD_CLK_DEFAULT_CONFIG(AMY_SAMPLE_RATE), .slot_cfg = I2S_STD_MSB_SLOT_DEFAULT_CONFIG(I2S_DATA_BIT_WIDTH_32BIT, I2S_SLOT_MODE_STEREO), .gpio_cfg = { .mclk = (amy_global.config.i2s_mclk == -1)? I2S_GPIO_UNUSED : amy_global.config.i2s_mclk, .bclk = amy_global.config.i2s_bclk, .ws = amy_global.config.i2s_lrc, .dout = amy_global.config.i2s_dout, .din = amy_global.config.i2s_din, .invert_flags = { .mclk_inv = false, .bclk_inv = false, .ws_inv = false, }, }, }; #else // 16 bit I2S i2s_std_config_t std_cfg = { .clk_cfg = I2S_STD_CLK_DEFAULT_CONFIG(AMY_SAMPLE_RATE), .slot_cfg = I2S_STD_MSB_SLOT_DEFAULT_CONFIG(I2S_DATA_BIT_WIDTH_16BIT, I2S_SLOT_MODE_STEREO), .gpio_cfg = { .mclk = (amy_global.config.i2s_mclk == -1)? I2S_GPIO_UNUSED : amy_global.config.i2s_mclk, .bclk = amy_global.config.i2s_bclk, .ws = amy_global.config.i2s_lrc, .dout = amy_global.config.i2s_dout, .din = amy_global.config.i2s_din, .invert_flags = { .mclk_inv = false, .bclk_inv = false, .ws_inv = false, }, }, }; #endif /* Initialize the channel */ i2s_channel_init_std_mode(tx_handle, &std_cfg); if(AMY_HAS_AUDIO_IN) i2s_channel_init_std_mode(rx_handle, &std_cfg); /* Before writing data, start the TX channel first */ i2s_channel_enable(tx_handle); if(AMY_HAS_AUDIO_IN) i2s_channel_enable(rx_handle); return AMY_OK; } #else // AMYBOARD or AMYBOARD_ARDUINO i2s setup, which uses two audio codecs, for audio in and SPDIF amy_err_t esp32_setup_i2s(void) { i2s_chan_config_t chan_cfg = I2S_CHANNEL_DEFAULT_CONFIG(I2S_NUM_AUTO, I2S_ROLE_SLAVE); // ************* I2S_ROLE_SLAVE - needs external I2S clock input. i2s_new_channel(&chan_cfg, &tx_handle, &rx_handle); #define I2S_32BIT i2s_std_config_t std_cfg = { .clk_cfg = { .sample_rate_hz = AMY_SAMPLE_RATE, .clk_src = I2S_CLK_SRC_EXTERNAL, .ext_clk_freq_hz = AMY_SAMPLE_RATE * 512, .mclk_multiple = 512, }, .slot_cfg = { .data_bit_width = I2S_DATA_BIT_WIDTH_32BIT, .slot_bit_width = I2S_SLOT_BIT_WIDTH_32BIT, .slot_mode = I2S_SLOT_MODE_STEREO, .slot_mask = I2S_STD_SLOT_BOTH, .ws_width = 32, .ws_pol = false, // false in STD_PHILIPS macro .bit_shift = false, // true for STD_PHILIPS macro, but that results in *2* bits delay of dout vs lrclk in Follower mode. false gives 1 bit delay, as expected for i2s. .left_align = false, .big_endian = false, .bit_order_lsb = false, }, .gpio_cfg = { .mclk = amy_global.config.i2s_mclk, .bclk = amy_global.config.i2s_bclk, .ws = amy_global.config.i2s_lrc, .dout = amy_global.config.i2s_dout, .din = amy_global.config.i2s_din, .invert_flags = { .mclk_inv = false, .bclk_inv = true, // invert bclk for pcm9211 .ws_inv = false, }, }, }; /* Initialize the channel */ i2s_channel_init_std_mode(tx_handle, &std_cfg); i2s_channel_init_std_mode(rx_handle, &std_cfg); /* Before writing data, start the TX channel first */ i2s_channel_enable(tx_handle); i2s_channel_enable(rx_handle); #ifdef AMYBOARD_ARDUINO // Initialize PCM9211 SPDIF transceiver via I2C. // On the MicroPython AMYBOARD path this is done in Python (amyboard.py). { #define PCM9211_I2C_ADDR 0x40 #define PCM9211_I2C_SDA 17 #define PCM9211_I2C_SCL 18 #define PCM9211_I2C_FREQ 400000 i2c_config_t i2c_conf = { .mode = I2C_MODE_MASTER, .sda_io_num = PCM9211_I2C_SDA, .scl_io_num = PCM9211_I2C_SCL, .sda_pullup_en = GPIO_PULLUP_ENABLE, .scl_pullup_en = GPIO_PULLUP_ENABLE, .master.clk_speed = PCM9211_I2C_FREQ, }; i2c_param_config(I2C_NUM_0, &i2c_conf); i2c_driver_install(I2C_NUM_0, I2C_MODE_MASTER, 0, 0, 0); static const uint8_t pcm9211_regs[][2] = { { 0x40, 0x33 }, // Power down ADC, DIR, DIT, OSC { 0x40, 0xC0 }, // Normal operation for all { 0x34, 0x00 }, // Initialize DIR - biphase amps on, input from RXIN0 { 0x26, 0x01 }, // Main Out is DIR/ADC if no DIR sync { 0x6B, 0x00 }, // Main output pins are DIR/ADC AUTO { 0x30, 0x04 }, // PLL sends 512fs as SCK { 0x31, 0x0A }, // XTI SCK as 512fs too { 0x60, 0x44 }, // DIT sends SPDIF from AUXIN1 through MPO0 { 0x61, 0x20 }, // DIT SCK ratio = 512fs (must match PLL config in 0x30/0x31) { 0x78, 0x3D }, // MPO0 = TXOUT, MPO1 = VOUT { 0x6F, 0x40 }, // MPIO_A = CLKST / MPIO_B = AUXIN2 / MPIO_C = AUXIN1 }; for (int i = 0; i < sizeof(pcm9211_regs) / sizeof(pcm9211_regs[0]); i++) { uint8_t buf[2] = { pcm9211_regs[i][0], pcm9211_regs[i][1] }; esp_err_t ret = i2c_master_write_to_device( I2C_NUM_0, PCM9211_I2C_ADDR, buf, 2, pdMS_TO_TICKS(100)); if (ret != ESP_OK) { fprintf(stderr, "PCM9211: reg 0x%02x write 0x%02x failed: %s\n", buf[0], buf[1], esp_err_to_name(ret)); } } // Tear down the I2C driver so Arduino Wire can use bus 0 later i2c_driver_delete(I2C_NUM_0); } #endif // AMYBOARD_ARDUINO return AMY_OK; } #endif amy_err_t esp32_teardown_i2s(void) { i2s_channel_disable(tx_handle); if(AMY_HAS_AUDIO_IN) i2s_channel_disable(rx_handle); i2s_del_channel(tx_handle); if(AMY_HAS_AUDIO_IN) i2s_del_channel(rx_handle); return AMY_OK; } ///////////////////////////////////// // ESP mulithread/multicore rendering TaskHandle_t amy_render_handle; TaskHandle_t amy_fill_buffer_handle; // Task to notify when amy_update is waiting for a completed buffer TaskHandle_t amy_update_handle = NULL; // Who esp_render_task tells that it is done. TaskHandle_t amy_render_task_done_handle = NULL; // Render the second core void esp_render_task( void * pvParameters) { while(1) { ulTaskNotifyTake(pdTRUE, portMAX_DELAY); // from esp_render_on_cores amy_render(0, AMY_OSCS/2, 1); // Tell (someone) we're done. xTaskNotifyGive(amy_render_task_done_handle); // to esp_render_on_cores } } void esp_render_on_cores() { // Call amy_render on all the oscs, using multicore if available. if (amy_global.config.platform.multicore) { // Tell the esp_render_task to inform *us* when it's done. amy_render_task_done_handle = xTaskGetCurrentTaskHandle(); // Tell the other core to start rendering. xTaskNotifyGive(amy_render_handle); // to esp_render_task // Render me amy_render(AMY_OSCS/2, AMY_OSCS, 0); // Wait for the other core to finish ulTaskNotifyTake(pdTRUE, portMAX_DELAY); // from esp_render_task } else { // We render everything on this core. amy_render(0, AMY_OSCS, 0); } } #ifdef I2S_32BIT static int32_t block32[AMY_BLOCK_SIZE * AMY_NCHANS]; #define I2S_BYTES_PER_SAMPLE 4 #else #define I2S_BYTES_PER_SAMPLE AMY_BYTES_PER_SAMPLE #endif extern output_sample_type * amy_in_block; // Place where render thread leaves address of samples. // Set by esp_fill_audio_buffer_task, cleared when returned by amy_render_audio (if used). int16_t *volatile last_audio_buffer = NULL; // (see also amy_get_output_buffer, I should choose only one of these) void esp_read_i2s_input() { // Read a block of i2s input. Separated to isolate noise from different i2s formats. size_t read = 0; #ifdef I2S_32BIT i2s_channel_read(rx_handle, block32, AMY_BLOCK_SIZE * AMY_NCHANS * sizeof(int32_t), &read, portMAX_DELAY); for (int i = 0; i < AMY_BLOCK_SIZE * AMY_NCHANS; ++i) amy_in_block[i] = (block32[i] >> 16); #else i2s_channel_read(rx_handle, amy_in_block, AMY_BLOCK_SIZE * AMY_NCHANS * sizeof(output_sample_type), &read, portMAX_DELAY); #endif if(read != AMY_BLOCK_SIZE * AMY_NCHANS * I2S_BYTES_PER_SAMPLE) { fprintf(stderr,"i2s input underrun: %d vs %d\n", read, AMY_BLOCK_SIZE * AMY_NCHANS * I2S_BYTES_PER_SAMPLE); } } // Make AMY's FABT run forever , as a FreeRTOS task void esp_fill_audio_buffer_task() { while(1) { AMY_PROFILE_START(AMY_ESP_FILL_BUFFER) if(AMY_HAS_I2S && AMY_HAS_AUDIO_IN) { esp_read_i2s_input(); } // Get ready to render amy_execute_deltas(); // Render on whichever cores we have available. esp_render_on_cores(); // Write to i2s output_sample_type *block = amy_fill_buffer(); AMY_PROFILE_STOP(AMY_ESP_FILL_BUFFER) last_audio_buffer = block; // Notify amy_update() that a block is ready (so it can return from amy_render_audio). if (amy_update_handle) xTaskNotifyGive(amy_update_handle); // to amy_render_audio if (AMY_HAS_I2S) { amy_i2s_write((uint8_t *)block, AMY_BLOCK_SIZE * AMY_NCHANS * sizeof(int16_t)); } else { // Wait for update sync. ulTaskNotifyTake(pdTRUE, portMAX_DELAY); // from amy_render_audio:!AMY_HAS_I2S } } } // init AMY from the esp. wraps some amy funcs in a task to do multicore rendering on the ESP32 void amy_platform_init() { // If we're running amy_update, this should be the task we need to return to. // However, if we're not using amy_update (e.g., Tulip/AMYboard native), we don't // want to do this - the un-handled xTaskNotifyGives cause Tulip to crash when it // turns on WiFi. #ifdef ARDUINO amy_update_handle = xTaskGetCurrentTaskHandle(); #endif if (AMY_HAS_I2S) { // Start i2s esp32_setup_i2s(); } if (amy_global.config.platform.multicore) { // On ESP, multicore starts a second thread even if multithread is not requested. // Create the second core rendering task xTaskCreatePinnedToCore(&esp_render_task, AMY_RENDER_TASK_NAME, AMY_RENDER_TASK_STACK_SIZE, NULL, AMY_RENDER_TASK_PRIORITY, &amy_render_handle, AMY_RENDER_TASK_COREID); } if (amy_global.config.platform.multithread) { // Create the fill audio buffer thread, combines, does volume & filters xTaskCreatePinnedToCore(&esp_fill_audio_buffer_task, AMY_FILL_BUFFER_TASK_NAME, AMY_FILL_BUFFER_TASK_STACK_SIZE, NULL, AMY_FILL_BUFFER_TASK_PRIORITY, &amy_fill_buffer_handle, AMY_FILL_BUFFER_TASK_COREID); // Let amy_update know we have I2S covered. if (AMY_HAS_I2S) { amy_global.i2s_is_in_background = 1; } } } void amy_platform_deinit() { if (AMY_HAS_I2S) { esp32_teardown_i2s(); } if (amy_global.config.platform.multicore) { vTaskDelete(amy_render_handle); } if (amy_global.config.platform.multithread) { vTaskDelete(amy_fill_buffer_handle); } } extern void esp_poll_midi(void); void amy_update_tasks() { if (!amy_global.config.platform.multithread) { amy_execute_deltas(); esp_poll_midi(); } else{ // Rendering is happening on separate thread, nothing to do. } } int16_t *amy_render_audio() { // Called by api.amy_update() to render the audio. Not used for non-Arduino. int16_t *buf = NULL; if (amy_global.config.platform.multithread) { // Wait for esp_fill_audio_buffer_task to indicate a buffer is ready. ulTaskNotifyTake(pdTRUE, portMAX_DELAY); // from esp_fill_audio_buffer_task buf = last_audio_buffer; // Allow the FABT to generate another block if (!AMY_HAS_I2S) { xTaskNotifyGive(amy_fill_buffer_handle); // to esp_fill_audio_buffer_task:!AMY_HAS_I2S } } else { // No multithread, we have to render here. esp_render_on_cores(); buf = amy_fill_buffer(); } return buf; } size_t amy_i2s_write(const uint8_t *buffer, size_t nbytes) { size_t written = 0; int16_t *block = (int16_t *)buffer; #ifdef I2S_32BIT // including AMYBOARD // Convert to 32 bits for (int i = 0; i < AMY_BLOCK_SIZE * AMY_NCHANS; ++i) block32[i] = ((int32_t)block[i]) << 16; i2s_channel_write(tx_handle, block32, AMY_BLOCK_SIZE * AMY_NCHANS * I2S_BYTES_PER_SAMPLE, &written, portMAX_DELAY); #else // 16 bit I2S i2s_channel_write(tx_handle, block, AMY_BLOCK_SIZE * AMY_NCHANS * I2S_BYTES_PER_SAMPLE, &written, portMAX_DELAY); #endif if(written != AMY_BLOCK_SIZE * AMY_NCHANS * I2S_BYTES_PER_SAMPLE) { fprintf(stderr,"i2s output underrun: %d vs %d\n", written, AMY_BLOCK_SIZE * AMY_NCHANS * I2S_BYTES_PER_SAMPLE); } return 1; } #elif (defined ARDUINO_ARCH_RP2040) || (defined ARDUINO_ARCH_RP2350) #include "hardware/clocks.h" #include "hardware/structs/clocks.h" #include "pico/multicore.h" #include "pico/stdlib.h" #include "pico-audio/audio_i2s.h" #include "pico/binary_info.h" #include "pico/util/queue.h" // Provided by pico_support.cpp extern void pico_setup_i2s(amy_config_t *config); extern void pico_teardown_i2s(amy_config_t *config); extern void pico_i2s_read_write_buffer(int16_t *in_samples, const int16_t *out_samples, int nframes); struct audio_buffer_pool *ap; static inline uint32_t _millis(void) { return to_ms_since_boot(get_absolute_time()); } typedef struct { int32_t (*func)(int32_t); int32_t data; } queue_entry_t; queue_t call_queue; queue_t results_queue; volatile bool core1_running = true; // This is the ram allocated for the core1 stack. // It's also the flag that core1 task is running, if non-NULL. uint32_t * my_core1_separate_stack_address = NULL; extern void on_pico_uart_rx(); void amy_update_tasks() { amy_execute_deltas(); if(amy_global.config.midi & AMY_MIDI_IS_UART) on_pico_uart_rx(); #ifdef TUD_USB_GADGET if(amy_global.config.midi & AMY_MIDI_IS_USB_GADGET) on_pico_uart_rx(); #endif } #define USE_SECOND_CORE int32_t render_other_core(int32_t data) { amy_render(AMY_OSCS/2, AMY_OSCS, 1); return AMY_OK; } int16_t *amy_render_audio() { #ifdef USE_SECOND_CORE if (amy_global.config.platform.multicore) { int32_t res; queue_entry_t entry = {render_other_core, AMY_OK}; queue_add_blocking(&call_queue, &entry); amy_render(0, AMY_OSCS/2, 0); queue_remove_blocking(&results_queue, &res); } else #endif amy_render(0, AMY_OSCS, 0); int16_t *block = amy_fill_buffer(); return block; } size_t amy_i2s_write(const uint8_t *buffer, size_t nbytes) { // Single function to update buffers. // len is the number of int16 sample frames. pico_i2s_read_write_buffer(amy_in_block, (const int16_t *)buffer, AMY_BLOCK_SIZE); return nbytes; } struct audio_buffer_pool *init_audio() { static audio_format_t audio_format = { .format = AUDIO_BUFFER_FORMAT_PCM_S16, .sample_freq = AMY_SAMPLE_RATE, .channel_count = AMY_NCHANS, }; static struct audio_buffer_format producer_format = { .format = &audio_format, .sample_stride = sizeof(int16_t) * AMY_NCHANS, }; struct audio_buffer_pool *producer_pool = audio_new_producer_pool(&producer_format, 3, AMY_BLOCK_SIZE); bool __unused ok; const struct audio_format *output_format; struct audio_i2s_config config = { .data_pin = amy_global.config.i2s_dout, .clock_pin_base = amy_global.config.i2s_bclk, .dma_channel = 0, .pio_sm = 0, }; output_format = audio_i2s_setup(&audio_format, &config); if (!output_format) { panic("PicoAudio: Unable to open audio device.\n"); } ok = audio_i2s_connect(producer_pool); assert(ok); audio_i2s_set_enabled(true); return producer_pool; } void core1_main() { while (core1_running) { queue_entry_t entry; queue_remove_blocking(&call_queue, &entry); int32_t result = entry.func(entry.data); queue_add_blocking(&results_queue, &result); } } void amy_platform_init() { if (AMY_HAS_I2S) { pico_setup_i2s(&amy_global.config); } #ifdef USE_SECOND_CORE if (amy_global.config.platform.multicore) { if (my_core1_separate_stack_address == NULL) { // Task is not already running. my_core1_separate_stack_address = (uint32_t*)malloc(0x2000); queue_init(&call_queue, sizeof(queue_entry_t), 2); queue_init(&results_queue, sizeof(int32_t), 2); core1_running = true; multicore_launch_core1_with_stack(core1_main, my_core1_separate_stack_address, 0x2000); sleep_ms(500); } } #endif } void amy_platform_deinit() { #ifdef USE_SECOND_CORE if (amy_global.config.platform.multicore) { if (my_core1_separate_stack_address) { // Task is actually running. core1_running = false; // signal the core1 task to exit. sleep_ms(100); // time for it to exit queue_free(&results_queue); queue_free(&call_queue); free(my_core1_separate_stack_address); my_core1_separate_stack_address = NULL; } } #endif pico_teardown_i2s(&amy_global.config); } #elif defined __IMXRT1062__ extern void teensy_setup_i2s(); extern void teensy_teardown_i2s(); extern size_t teensy_i2s_write(const uint8_t *buffer, size_t nbytes); extern int16_t teensy_get_serial_byte(); void amy_platform_init() { if (AMY_HAS_I2S) { teensy_setup_i2s(); } } void amy_platform_deinit() { if (AMY_HAS_I2S) { teensy_teardown_i2s(); } } void amy_update_tasks() { if(amy_global.config.midi & AMY_MIDI_IS_UART) { // do midi in here uint8_t bytes[1]; int t; while((t = teensy_get_serial_byte()) >= 0) { bytes[0] = t; convert_midi_bytes_to_messages(bytes,1,0); } } amy_execute_deltas(); } int16_t *amy_render_audio() { amy_render(0, AMY_OSCS, 0); int16_t *block = amy_fill_buffer(); return block; } size_t amy_i2s_write(const uint8_t *buffer, size_t nbytes) { return teensy_i2s_write(buffer, nbytes); } #else //... #endif #endif ================================================ FILE: src/instrument.c ================================================ // instrument.c // // An instrument is a set of voices with voice-allocation logic. // The user calls instrument_note_on(), and this logic chooses one of the // preallocated voices to play the note on. // // This is a replacement in C for the functionality in // tulip/shared/py/synth.py. #include "amy.h" #include #define INSTRUMENT_RAM_CAPS SYNTH_RAM_CAPS struct voice_fifo { const char *name; uint8_t length; uint8_t entries[MAX_VOICES_PER_INSTRUMENT + 1]; // fifo has one extra element to distinguish empty and full. uint8_t head; uint8_t tail; }; // Fifo must provide init, put, get, remove, empty void voice_fifo_debug(struct voice_fifo *fifo) { fprintf(stderr, "fifo %s entries 0x%lx len %d head %d tail %d: ", fifo->name, (long)fifo->entries, fifo->length, fifo->head, fifo->tail); uint8_t current = fifo->tail; while(current != fifo->head) { fprintf(stderr, "%d ", fifo->entries[current]); current = (current + 1) % fifo->length; } fprintf(stderr, "\n"); } struct voice_fifo *voice_fifo_init(int size, const char *name) { if (size <=0 || size > MAX_VOICES_PER_INSTRUMENT) { fprintf(stderr, "init_voice_fifo: size %d value error (max size is %d)\n", size, MAX_VOICES_PER_INSTRUMENT); return NULL; } struct voice_fifo *result = (struct voice_fifo *)malloc_caps(sizeof(struct voice_fifo), amy_global.config.ram_caps_synth); result->head = 0; result->tail = 0; result->length = MAX_VOICES_PER_INSTRUMENT + 1; // One more than max size. fixed in this implementation. result->name = name; // very dicey - only works because I'm passing statically-allocated names. return result; } void voice_fifo_free(struct voice_fifo *fifo) { free(fifo); } bool voice_fifo_empty(struct voice_fifo *fifo) { return (fifo->head == fifo->tail); } void voice_fifo_put(struct voice_fifo *fifo, uint8_t val) { fifo->entries[fifo->head++] = val; if (fifo->head == fifo->length) fifo->head = 0; if (fifo->head == fifo->tail) { fprintf(stderr, "**fifo %s: overflow\n", fifo->name); // Drop the entry we just overwrote. fifo->tail = (fifo->tail + 1) % fifo->length; } //fprintf(stderr, "I: fifo %s: put %d\n", fifo->name, val); } uint8_t voice_fifo_get(struct voice_fifo *fifo) { if (voice_fifo_empty(fifo)) { fprintf(stderr, "**fifo %s: get on empty\n", fifo->name); return 0; } uint8_t val = fifo->entries[fifo->tail++]; if (fifo->tail == fifo->length) fifo->tail = 0; //fprintf(stderr, "I: fifo %s: get %d\n", fifo->name, val); return val; } void voice_fifo_remove(struct voice_fifo *fifo, uint8_t val) { // Remove the oldest instance of val in the fifo and close up. //fprintf(stderr, "I: fifo %s: remove %d\n", fifo->name, val); uint8_t index; for (index = fifo->tail; index != fifo->head; index = (index + 1) % fifo->length) { if (fifo->entries[index] == val) { // Copy entries beyond the value to remove back one position. uint8_t new_head = (fifo->head + fifo->length - 1) % fifo->length; while (index != new_head) { uint8_t next_index = (index + 1) % fifo->length; fifo->entries[index] = fifo->entries[next_index]; index = next_index; } fifo->head = new_head; return; } } fprintf(stderr, "**fifo %s: remove did not find %d (#entries=%d)\n", fifo->name, val, (fifo->head - fifo->tail) % fifo->length); } // How many forgotten note-ons (due to repeated onsets, or note stealing) do we remember // (to match their note-offs) #define FORGOTTEN_POOL_SIZE 16 struct instrument_info { struct voice_fifo *released_voices; struct voice_fifo *active_voices; uint8_t num_voices; uint8_t oscs_per_voice; // How many oscs each voice uses. Stored for convenience. uint8_t id; // synth number assigned by client. uint16_t patch_number; // What patch this instrument is currently set to. Stored for convenience. int16_t bank_number; // Optional top-7-bit word of Program, set by MIDI CC 0 (-1 if not set). uint32_t flags; // Bitmask of special instrument properties (for MIDI Drums translation). // AMY "voice" index for each of the num_voices allocated voices. uint16_t amy_voices[MAX_VOICES_PER_INSTRUMENT]; // Track which note each voice is sounding. We use int16 so we can store PCM_PRESET *127 + midi_note uint16_t note_per_voice[MAX_VOICES_PER_INSTRUMENT]; // A buffer of forgotten notes, so we don't complain about their note-offs. uint16_t forgotten_notes[FORGOTTEN_POOL_SIZE]; // We have a max capacity for forgotten notes. uint16_t forgotten_note_count[FORGOTTEN_POOL_SIZE]; // Count mulitple onsets per forgotten note. // Delay added to note-ons. Permits some decay for voice stealing. uint16_t noteon_delay_ms; // Sustain tracking bool in_sustain; // Pedal is down. bool pending_release[MAX_VOICES_PER_INSTRUMENT]; bool grab_midi_notes; // Flag to automatically play midi notes. }; void instrument_debug(struct instrument_info *instrument) { fprintf(stderr, "**instrument 0x%lx id %d num_voices %d patch %d oscs %d bank %d flags %" PRIu32 " noteon_delay_ms %d in_sustain %d grab_midi %d\n", (unsigned long)instrument, instrument->id, instrument->num_voices, instrument->patch_number, instrument->oscs_per_voice, instrument->bank_number, instrument->flags, instrument->noteon_delay_ms, instrument->in_sustain, instrument->grab_midi_notes); for (int i = 0; i < instrument->num_voices; ++i) fprintf(stderr, "voice %d amy_voice %d note_per_voice %d pending_release %d\n", i, instrument->amy_voices[i], instrument->note_per_voice[i], instrument->pending_release[i]); voice_fifo_debug(instrument->active_voices); voice_fifo_debug(instrument->released_voices); } // Instrument provides note_on, note_off, all_notes_off, sustain(bool) #define _INSTRUMENT_NO_NOTE 255 // Defined in amy.h because patches.c needs to know it. //#define _INSTRUMENT_NO_VOICE 255 void _instrument_reset_forgotten_pool(struct instrument_info *instrument) { for (int i = 0; i < FORGOTTEN_POOL_SIZE; ++i) { instrument->forgotten_notes[i] = _INSTRUMENT_NO_NOTE; instrument->forgotten_note_count[i] = 0; } } struct instrument_info *instrument_init(int id, int num_voices, uint16_t* amy_voices, uint16_t patch_number, uint16_t oscs_per_voice, uint32_t flags) { struct instrument_info *instrument = (struct instrument_info *)malloc_caps(sizeof(struct instrument_info), amy_global.config.ram_caps_synth); instrument->id = id; if (num_voices <= 0 || num_voices > MAX_VOICES_PER_INSTRUMENT) { fprintf(stderr, "num_voices %d not within 1 .. MAX_VOICES_PER_INSTRUMENT %d\n", num_voices, MAX_VOICES_PER_INSTRUMENT); abort(); return NULL; } instrument->num_voices = num_voices; instrument->patch_number = patch_number; instrument->oscs_per_voice = oscs_per_voice; instrument->bank_number = -1; instrument->flags = flags; instrument->noteon_delay_ms = 0; instrument->in_sustain = false; instrument->grab_midi_notes = true; instrument->released_voices = voice_fifo_init(num_voices, "released"); instrument->active_voices = voice_fifo_init(num_voices, "active"); for (uint8_t voice = 0; voice < num_voices; ++voice) { instrument->amy_voices[voice] = amy_voices[voice]; voice_fifo_put(instrument->released_voices, voice); instrument->note_per_voice[voice] = _INSTRUMENT_NO_NOTE; instrument->pending_release[voice] = false; } _instrument_reset_forgotten_pool(instrument); return instrument; } void instrument_free(struct instrument_info *instrument) { voice_fifo_free(instrument->active_voices); voice_fifo_free(instrument->released_voices); free(instrument); } void _instrument_push_note_forgotten(struct instrument_info *instrument, uint16_t note) { int available_index = -1; for (int i = 0; i < FORGOTTEN_POOL_SIZE; ++i) { if (instrument->forgotten_notes[i] == note) { ++instrument->forgotten_note_count[i]; //fprintf(stderr, "synth %d: caching existing forgotten note %d/%d (%d, count %d)\n", // instrument->id, note / 128, note & 0x7F, i, instrument->forgotten_note_count[i]); return; } if (available_index < 0 && instrument->forgotten_notes[i] == _INSTRUMENT_NO_NOTE) { available_index = i; } } // We didn't find the note, hopefully we saw an empty slot. if (available_index >= 0) { instrument->forgotten_notes[available_index] = note; instrument->forgotten_note_count[available_index] = 1; //fprintf(stderr, "synth %d: caching new forgotten note %d/%d (%d, count %d)\n", // instrument->id, note / 128, note & 0x7F, available_index, instrument->forgotten_note_count[available_index]); } else { fprintf(stderr, "**_instrument_push_forgotten_note: forgotten pool overflow synth %d note %d/%d\n", instrument->id, note / 128, note & 0x7F); } } bool _instrument_pop_note_forgotten(struct instrument_info *instrument, uint16_t note) { // Checks forgotten_notes for this note; if found, remove it and return true; else false. for (int i = 0; i < FORGOTTEN_POOL_SIZE; ++i) { if (instrument->forgotten_notes[i] == note) { //fprintf(stderr, "synth %d: uncaching forgotten note %d/%d (%d, count %d)\n", // instrument->id, note / 128, note & 0x7F, i, instrument->forgotten_note_count[i]); --instrument->forgotten_note_count[i]; if (instrument->forgotten_note_count[i] == 0) instrument->forgotten_notes[i] = _INSTRUMENT_NO_NOTE; return true; } } return false; } uint16_t _instrument_get_voice(struct instrument_info *instrument, bool *pstolen) { if (!voice_fifo_empty(instrument->released_voices)) { return voice_fifo_get(instrument->released_voices); } // No released voices, have to steal. if (pstolen) *pstolen = true; // *pstolen is set if steal occurs, otherwise not touched. // Mark this note as one that got stolen, so we can absorb its eventual note-off. uint16_t voice = voice_fifo_get(instrument->active_voices); _instrument_push_note_forgotten(instrument, instrument->note_per_voice[voice]); return voice; } uint16_t _instrument_voice_for_note(struct instrument_info *instrument, uint16_t note) { // Linear search through note_per_voice to see if this note is present. for (uint16_t voice = 0; voice < instrument->num_voices; ++voice) if (instrument->note_per_voice[voice] == note) return voice; return _INSTRUMENT_NO_VOICE; } uint16_t _instrument_voice_off(struct instrument_info *instrument, uint16_t voice) { instrument->note_per_voice[voice] = _INSTRUMENT_NO_NOTE; instrument->pending_release[voice] = false; voice_fifo_remove(instrument->active_voices, voice); voice_fifo_put(instrument->released_voices, voice); return instrument->amy_voices[voice]; } uint16_t instrument_note_off(struct instrument_info *instrument, uint16_t note) { uint16_t voice = _instrument_voice_for_note(instrument, note); if (voice == _INSTRUMENT_NO_VOICE) { // Don't report an unmatched note-off if it was a victim of stealing. if (!_instrument_pop_note_forgotten(instrument, note)) fprintf(stderr, "note off for %d/%d does not match note on\n", note / 128, note & 0x7F); //instrument_debug(instrument); return _INSTRUMENT_NO_VOICE; // We could just fall through, but this is more explicit. } if (instrument->in_sustain) { instrument->pending_release[voice] = true; return _INSTRUMENT_NO_VOICE; } //fprintf(stderr, "instr 0x%lx: patch %d voice %d note %d/%d off\n", (unsigned long)instrument, instrument->patch_number, instrument->amy_voices[voice], note / 128, note & 0x7F); return _instrument_voice_off(instrument, voice); } int _instrument_all_notes_off(struct instrument_info *instrument, uint16_t *amy_voices) { // Register any active voices as inactive; return those voices. int num_voices_turned_off = 0; for (uint16_t voice = 0; voice < instrument->num_voices; ++voice) if (instrument->note_per_voice[voice] != _INSTRUMENT_NO_NOTE) { //fprintf(stderr, "voice %d note %d/%d all-off\n", instrument->amy_voices[voice], instrument->note_per_voice[voice] / 128, instrument->note_per_voice[voice] & 0x7F); _instrument_voice_off(instrument, voice); *amy_voices++ = instrument->amy_voices[voice]; ++num_voices_turned_off; } _instrument_reset_forgotten_pool(instrument); return num_voices_turned_off; } uint16_t instrument_note_on(struct instrument_info *instrument, uint16_t note, bool *pstolen) { if ((note & 0x7F) == 0) { // note == 0 is for all-notes-off, it's not allowed for note-on (sorry, C-1). fprintf(stderr, "note-on for note 0: ignored.\n"); return _INSTRUMENT_NO_VOICE; } uint16_t voice = _instrument_voice_for_note(instrument, note); if (voice == _INSTRUMENT_NO_VOICE) { // Not a re-onset, need to allocate a new voice. voice = _instrument_get_voice(instrument, pstolen); voice_fifo_put(instrument->active_voices, voice); } else { // If re-onset, push the previous onset _instrument_push_note_forgotten(instrument, note); } instrument->note_per_voice[voice] = note; instrument->pending_release[voice] = false; //fprintf(stderr, "instr 0x%lx: patch %d voice %d note %d/%d on\n", (unsigned long)instrument, instrument->patch_number, instrument->amy_voices[voice], note); //instrument_debug(instrument); return instrument->amy_voices[voice]; } ////// Interface of instrument mechanism to AMY records. //#define MAX_INSTRUMENTS 32 //struct instrument_info *instruments[MAX_INSTRUMENTS]; struct instrument_info **instruments = NULL; int max_instruments = 0; void instruments_deinit() { if (instruments != NULL) { instruments_reset(); free(instruments); } } void instruments_init(int num_instruments) { max_instruments = num_instruments; instruments = (struct instrument_info **)malloc_caps(max_instruments * sizeof(struct instrument_info *), amy_global.config.ram_caps_synth); for(uint16_t i = 0; i < max_instruments; i++) { instruments[i] = NULL; } } void instruments_reset() { for(uint16_t i = 0; i < max_instruments; i++) instrument_release(i); } int instruments_max_instruments() { return max_instruments; } void instrument_release(int instrument_number) { if(instrument_number < max_instruments && instruments[instrument_number]) { instrument_free(instruments[instrument_number]); } instruments[instrument_number] = NULL; } bool instrument_number_ok(int instrument_number, const char *tag) { if (instrument_number < 0 || instrument_number >= max_instruments) { if (tag) fprintf(stderr, "instrument_number %d is out of range 0..%d (%s)\n", instrument_number, max_instruments, tag); return false; } return true; } bool instrument_number_exists(int instrument_number, const char *tag) { if (instrument_number_ok(instrument_number, tag)) { if (instruments[instrument_number]) return true; if (tag) fprintf(stderr, "synth %d not defined (%s)\n", instrument_number, tag); } return false; } void instrument_add_new(int instrument_number, int num_voices, uint16_t *amy_voices, uint16_t patch_number, uint16_t oscs_per_voice, uint32_t flags) { if (!instrument_number_ok(instrument_number, "add_new")) return; if(instruments[instrument_number]) { instrument_free(instruments[instrument_number]); } instruments[instrument_number] = instrument_init(instrument_number, num_voices, amy_voices, patch_number, oscs_per_voice, flags); } void instrument_change_number(int old_instrument_number, int new_instrument_number) { if (!instrument_number_exists(old_instrument_number, NULL)) return; // no error msg. if (!instrument_number_ok(new_instrument_number, "change:new")) return; if (old_instrument_number == new_instrument_number) return; // Degenerate change. if (instruments[new_instrument_number]) { instrument_free(instruments[new_instrument_number]); } instruments[new_instrument_number] = instruments[old_instrument_number]; instruments[old_instrument_number] = NULL; } int instrument_get_num_voices(int instrument_number, uint16_t *amy_voices) { // instrument_get_num_voices is used to test if an instrument is set or not, so no error message if it doesn't exist, only if the number is out of range. if (!instrument_number_ok(instrument_number, "get_num_voices")) return 0; int num_voices = 0; struct instrument_info *instrument = instruments[instrument_number]; if (instrument == NULL) { //fprintf(stderr, "get_num_voices: instrument_number %d is not defined.\n", instrument_number); } else { num_voices = instrument->num_voices; if (amy_voices != NULL) for (int i = 0; i < num_voices; ++i) amy_voices[i] = instrument->amy_voices[i]; } return num_voices; } uint16_t instrument_voice_for_note_event(int instrument_number, int note, bool is_note_off, bool *pstolen) { // Called from patches_event_has_voices for events including an instrument, velocity, and note (note-on/note-off). // *pstolen is set (if pstolen is nonnull) if the note is stolen, otherwise not touched. if (!instrument_number_exists(instrument_number, "voice_for_event")) return _INSTRUMENT_NO_VOICE; struct instrument_info *instrument = instruments[instrument_number]; if (instrument->num_voices == 1) { // If there's only one voice, we can skip the voice management. return instrument->amy_voices[0]; } if (is_note_off) { // Note off. if (note == 0) { uint16_t amy_voices[MAX_VOICES_PER_INSTRUMENT]; _instrument_all_notes_off(instrument, amy_voices); return _INSTRUMENT_NO_VOICE; } return instrument_note_off(instrument, note); } else { // Note on. return instrument_note_on(instrument, note, pstolen); } } int instrument_all_notes_off(int instrument_number, uint16_t *amy_voices) { if (!instrument_number_exists(instrument_number, "all_off")) return 0; struct instrument_info *instrument = instruments[instrument_number]; return _instrument_all_notes_off(instrument, amy_voices); } int instrument_sustain(int instrument_number, bool sustain, uint16_t *amy_voices) { // Will return nonzero voices if the result is to release multiple notes. if (!instrument_number_exists(instrument_number, "sustain")) return 0; struct instrument_info *instrument = instruments[instrument_number]; if (sustain) { instrument->in_sustain = true; return 0; } // Sustain pedal released - return multiple note-offs. Like all notes off, but a different criterion. instrument->in_sustain = false; int num_voices_turned_off = 0; for (uint16_t voice = 0; voice < instrument->num_voices; ++voice) if (instrument->pending_release[voice]) { //fprintf(stderr, "voice %d note %d pedal-released\n", instrument->amy_voices[voice], instrument->note_per_voice[voice]); _instrument_voice_off(instrument, voice); *amy_voices++ = instrument->amy_voices[voice]; ++num_voices_turned_off; } return num_voices_turned_off; } int instrument_get_patch_number(int instrument_number) { if (!instrument_number_exists(instrument_number, "get_patch")) return -1; struct instrument_info *instrument = instruments[instrument_number]; return instrument->patch_number; } int instrument_get_oscs_per_voice(int instrument_number) { if (!instrument_number_exists(instrument_number, "get_patch")) return -1; struct instrument_info *instrument = instruments[instrument_number]; return instrument->oscs_per_voice; } uint32_t instrument_get_flags(int instrument_number) { if (!instrument_number_exists(instrument_number, "get_flags")) return (uint32_t)-1; struct instrument_info *instrument = instruments[instrument_number]; return instrument->flags; } uint16_t instrument_noteon_delay_ms(int instrument_number) { if (!instrument_number_exists(instrument_number, "noteon_delay")) return 0; struct instrument_info *instrument = instruments[instrument_number]; if (instrument == NULL) { return 0; } return instrument->noteon_delay_ms; } void instrument_set_noteon_delay_ms(int instrument_number, uint16_t noteon_delay_ms) { if (!instrument_number_exists(instrument_number, "set_noteon_delay")) return; struct instrument_info *instrument = instruments[instrument_number]; instrument->noteon_delay_ms = noteon_delay_ms; } bool instrument_grab_midi_notes(int instrument_number) { if (!instrument_number_exists(instrument_number, "grab_midi")) return false; struct instrument_info *instrument = instruments[instrument_number]; if (instrument == NULL) { return false; } return instrument->grab_midi_notes; } void instrument_set_grab_midi_notes(int instrument_number, bool grab_midi_notes) { if (!instrument_number_exists(instrument_number, "set_grab")) return; struct instrument_info *instrument = instruments[instrument_number]; instrument->grab_midi_notes = grab_midi_notes; } int instrument_bank_number(int instrument_number) { if (!instrument_number_exists(instrument_number, "bank_number")) return -1; struct instrument_info *instrument = instruments[instrument_number]; if (instrument == NULL) { return -1; } return instrument->bank_number; } void instrument_set_bank_number(int instrument_number, int bank_number) { if (!instrument_number_exists(instrument_number, "set_bank_number")) return; struct instrument_info *instrument = instruments[instrument_number]; instrument->bank_number = bank_number; } ================================================ FILE: src/interp_partials.c ================================================ // interp_partials - AMY kernel-side implementation of the interpolated partials-based synthesis originally implemented in tulip_piano.py. #include "amy.h" #include typedef struct { // How many sample_times_ms are there? uint16_t num_sample_times_ms; // Pointer to an array of the sample_times_ms const uint16_t *sample_times_ms; // How many velocities are defined for this voice (same for all notes) uint16_t num_velocities; // Pointer to a array of the MIDI velocities. const uint8_t *velocities; // How many different pitches do we define? (All velocities are provided for each) uint16_t num_pitches; // Pointer to array of structures defining each note (pitch + velocity) entry. const uint8_t *pitches; // How many harmonics are allocated for each of the num_velocities * num_pitches notes. const uint8_t *num_harmonics; // MIDI Cents freqs for each harmonic. const uint16_t *harmonics_freq; // num_sample_times_ms uint8_t dB envelope values for each harmonic. const uint8_t *harmonics_mags; } interp_partials_voice_t; #include "interp_partials.h" #define MAX_NUM_MAGNITUDES 24 #define MAX_NUM_HARMONICS 40 // Map to drop out some higher harmonics, namely the 2x and 3x overtones above 16th harmonic const bool use_this_partial_map[MAX_NUM_HARMONICS] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 1-10 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, // 11-20 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, // 21-30 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, // 31-40 }; // choose a preset from the .h file void partials_note_on(uint16_t osc) { int num_partials = synth[osc]->preset; for (int i = 0; i < num_partials; ++i) { int o = osc + 1 + i; ensure_osc_allocd(o, NULL); if (synth[o]->wave == PARTIAL) { // User has marked this as a partial. // Mark this PARTIAL as part of a build-your own with a flag value in its preset field. // This is used I think only at envelope.c:121 to avoid the normal partial preset special-case for PARTIALs. synth[o]->preset = synth[osc]->preset; synth[o]->logfreq_coefs[COEF_BEND] = 0; // Each PARTIAL will receive pitch bend via the midi_note modulation from the parent osc, don't add it twice. synth[o]->status = SYNTH_IS_ALGO_SOURCE; synth[o]->note_on_clock = amy_global.total_blocks*AMY_BLOCK_SIZE; AMY_UNSET(synth[o]->note_off_clock); msynth[o]->logfreq = synth[o]->logfreq_coefs[COEF_CONST] + msynth[osc]->logfreq; partial_note_on(o); } } } void partials_note_off(uint16_t osc) { int num_oscs = synth[osc]->preset; for(uint16_t i = osc + 1; i < osc + 1 + num_oscs; i++) { uint16_t o = i % AMY_OSCS; AMY_UNSET(synth[o]->note_on_clock); synth[o]->note_off_clock = amy_global.total_blocks*AMY_BLOCK_SIZE; } } // render a full partial set at offset osc (with preset) // freq controls pitch_ratio, amp amp_ratio, ratio controls time ratio // do all presets have sustain point? SAMPLE render_partials(SAMPLE *buf, uint16_t osc) { SAMPLE max_value = 0; uint16_t num_oscs = 0; // No preset partials map, we are in "build-your-own". The max number of oscs is taken from algo_source[0]. num_oscs = synth[osc]->preset; if (synth[osc]->wave == INTERP_PARTIALS) { //const interp_partials_voice_t *partials_voice = &interp_partials_map[synth[osc]->preset % NUM_INTERP_PARTIALS_PRESETS]; //num_oscs = partials_voice->num_harmonics[0]; // Assume first preset has the max #harmonics. num_oscs = interp_partials_max_partials_for_patch(synth[osc]->preset); } // now, render everything, add it up float midi_note = midi_note_for_logfreq(msynth[osc]->logfreq); //fprintf(stderr, "t=%u partials o=%d msynth[osc]->logfreq=%f midi_note=%f msynth[amp]=%f\n", amy_global.total_blocks*AMY_BLOCK_SIZE, osc, msynth[osc]->logfreq, midi_note, msynth[osc]->amp); for(uint16_t i = osc + 1; i < osc + 1 + num_oscs; i++) { uint16_t o = i % AMY_OSCS; if(synth[o]->status ==SYNTH_IS_ALGO_SOURCE) { // We vary each partial's "velocity" on-the-fly as the way the parent osc's amplitude envelope contributes to the partials. synth[o]->velocity = msynth[osc]->amp; // We also use dynamic, fractional note to propagate parent freq modulation. synth[o]->midi_note = midi_note; // hold_and_modify contains a special case for wave == PARTIAL so that // envelope value are delayed by 1 frame compared to other oscs // so that partials fade in over one frame from zero amp. hold_and_modify(o); //printf("[%d %d] %d amp %f (%f) freq %f (%f) on %d off %d bp0 %d %f bp1 %d %f wave %d\n", amy_global.total_blocks*AMY_BLOCK_SIZE, ms_since_started, o, synth[o]->amp, msynth[o]->amp, synth[o]->freq, msynth[o]->freq, synth[o]->note_on_clock, synth[o]->note_off_clock, synth[o]->breakpoint_times[0][0], // synth[o]->breakpoint_values[0][0], synth[o]->breakpoint_times[1][0], synth[o]->breakpoint_values[1][0], synth[o]->wave); SAMPLE value = render_partial(buf, o); //fprintf(stderr, "render_partials: time %.3f osc %d ctl ampt %.6f msynth_amp %.6f max_val=%.6f\n", amy_global.time, o, msynth[osc]->amp, msynth[o]->amp, S2F(value)); if (value > max_value) max_value = value; } } return max_value; } int _max_partials_for_partials_voice(const interp_partials_voice_t *partials_voice) { int max_num_partials = 0; for (int h = 0; h < partials_voice->num_harmonics[0]; ++h) { if (use_this_partial_map[h]) ++max_num_partials; } return max_num_partials; } int interp_partials_max_partials_for_patch(int interp_partials_patch_number) { const interp_partials_voice_t *partials_voice = &interp_partials_map[interp_partials_patch_number % NUM_INTERP_PARTIALS_PRESETS]; return _max_partials_for_partials_voice(partials_voice); } void _cumulate_scaled_harmonic_params(float *harm_param, int harmonic_index, float alpha, const interp_partials_voice_t *partials_voice) { int num_bps = partials_voice->num_sample_times_ms; // Pitch harm_param[0] += alpha * partials_voice->harmonics_freq[harmonic_index]; // Envelope magnitudes for (int i = 0; i < num_bps; ++i) harm_param[1 + i] += alpha * partials_voice->harmonics_mags[harmonic_index * num_bps + i]; } int _harmonic_base_index_for_pitch_vel(int pitch_index, int vel_index, const interp_partials_voice_t *partials_voice) { int note_number = partials_voice->num_velocities * pitch_index + vel_index; int harmonic_index = 0; for (int i = 0; i < note_number; ++i) harmonic_index += partials_voice->num_harmonics[i]; return harmonic_index; } float _logfreq_of_midi_cents(float midi_cents) { // Frequency is already log scaled, but need to re-center and change from 1200/oct to 1.0/oct. return (midi_cents - (100 * ZERO_MIDI_NOTE)) / 1200.f; } float _env_lin_of_db(float db) { float lin = powf(10.f, MIN(20.f, (db - 100.f)) / 20.f) - 0.001; if (lin < 0) return 0; return lin; } void _osc_on_with_harm_param(uint16_t o, float *harm_param, const interp_partials_voice_t *partials_voice) { // We coerce this voice into being a partial, regardless of user wishes. synth[o]->wave = PARTIAL; synth[o]->preset = 1; // Flag that this is an envelope-based partial // Setup the specified frequency. synth[o]->logfreq_coefs[COEF_CONST] = _logfreq_of_midi_cents(harm_param[0]); // Setup envelope. //synth[o]->eg_type[0] = ENVELOPE_DB; synth[o]->breakpoint_times[0][0] = 0; synth[o]->breakpoint_values[0][0] = 0; int last_time = 0; for (int bp = 0; bp < partials_voice->num_sample_times_ms; ++bp) { synth[o]->breakpoint_times[0][bp + 1] = (partials_voice->sample_times_ms[bp] - last_time) * AMY_SAMPLE_RATE / 1000; synth[o]->breakpoint_values[0][bp + 1] = _env_lin_of_db(harm_param[bp + 1]); last_time = partials_voice->sample_times_ms[bp]; } // Final release synth[o]->breakpoint_times[0][partials_voice->num_sample_times_ms + 1] = 200 * AMY_SAMPLE_RATE / 1000; synth[o]->breakpoint_values[0][partials_voice->num_sample_times_ms + 1] = 0; // Decouple osc freq and amp from note and amp. synth[o]->logfreq_coefs[COEF_NOTE] = 0; synth[o]->amp_coefs[COEF_VEL] = 1.0; // velocity is modified on-the-fly by the control osc to vary global amplitude. // Other osc params. synth[o]->status = SYNTH_IS_ALGO_SOURCE; synth[o]->note_on_clock = amy_global.total_blocks*AMY_BLOCK_SIZE; AMY_UNSET(synth[o]->note_off_clock); partial_note_on(o); } // HOW DOES INTERP_PARTIALS (e.g. DPWE_PIANO) WORK? // The special thing about interp_partials is that the harmonic envelopes depend on the note velocity, // so they all have to be recomputed in response at note_on time. Then, because their values have been // determined to reflect velocity via the note_on calculation, the parent osc should not use velocity // as part of its overall scaling calculation, since it would otherwise be applied twice. // Thus, when setting up a control osc for piano, we set amp_coef[COEF_VELOCITY] = 0. void interp_partials_note_on(uint16_t osc) { // Choose the interp_partials preset. const interp_partials_voice_t *partials_voice = &interp_partials_map[synth[osc]->preset % NUM_INTERP_PARTIALS_PRESETS]; float midi_note = synth[osc]->midi_note; float midi_vel = (int)roundf(synth[osc]->velocity * 127.f); // Clip if (midi_vel < partials_voice->velocities[0]) midi_vel = partials_voice->velocities[0]; if (midi_vel > partials_voice->velocities[partials_voice->num_velocities - 1]) midi_vel = partials_voice->velocities[partials_voice->num_velocities - 1]; // Find the lower bound pitch/velocity indices. uint8_t pitch_index = 0, vel_index = 0; while(pitch_index < partials_voice->num_pitches - 1 && partials_voice->pitches[pitch_index + 1] < midi_note) ++pitch_index; while(vel_index < partials_voice->num_velocities - 1 && partials_voice->velocities[vel_index + 1] < midi_vel) ++vel_index; // Interp weights float pitch_alpha = (midi_note - partials_voice->pitches[pitch_index]) / (float)(partials_voice->pitches[pitch_index + 1] - partials_voice->pitches[pitch_index]); float vel_alpha = (midi_vel - partials_voice->velocities[vel_index]) / (float)(partials_voice->velocities[vel_index + 1] - partials_voice->velocities[vel_index]); float harm_param[MAX_NUM_MAGNITUDES + 1]; // frequency + harmonic magnitudes. int note_number = partials_voice->num_velocities * pitch_index + vel_index; // Find the least number of harmonics across everything we're interpolating. int num_harmonics = MIN(MAX_NUM_HARMONICS, partials_voice->num_harmonics[note_number]); // pl_vl note num_harmonics = MIN(num_harmonics, partials_voice->num_harmonics[note_number + 1]); // pl_vh note num_harmonics = MIN(num_harmonics, partials_voice->num_harmonics[note_number + partials_voice->num_velocities]); // ph_vl note num_harmonics = MIN(num_harmonics, partials_voice->num_harmonics[note_number + partials_voice->num_velocities + 1]); // ph_vh note // Interpolate the 4 notes. int harmonic_base_index_pl_vl = _harmonic_base_index_for_pitch_vel(pitch_index, vel_index, partials_voice); float alpha_pl_vl = (1.f - pitch_alpha) * (1.f - vel_alpha); int harmonic_base_index_pl_vh = _harmonic_base_index_for_pitch_vel(pitch_index, vel_index + 1, partials_voice); float alpha_pl_vh = (1.f - pitch_alpha) * (vel_alpha); int harmonic_base_index_ph_vl = _harmonic_base_index_for_pitch_vel(pitch_index + 1, vel_index, partials_voice); float alpha_ph_vl = (pitch_alpha) * (1.f - vel_alpha); int harmonic_base_index_ph_vh = _harmonic_base_index_for_pitch_vel(pitch_index + 1, vel_index + 1, partials_voice); float alpha_ph_vh = (pitch_alpha) * (vel_alpha); //fprintf(stderr, "interp_partials@%u: osc %d note %.1f vel %.1f pitch_x %d vel_x %d numh %d harm_bi_ll %d pitch_a %.3f vel_a %.3f alphas %.2f %.2f %.2f %.2f\n", // amy_global.total_blocks*AMY_BLOCK_SIZE, osc, midi_note, midi_vel, pitch_index, vel_index, num_harmonics, // harmonic_base_index_pl_vl, pitch_alpha, vel_alpha, // alpha_pl_vl, alpha_pl_vh, alpha_ph_vl, alpha_ph_vh); // Make sure enough oscs are alloc'd in our dynamic osc alloc world. // This has to be enough for any note in this map. Assume num_harmonics[0] is largest (lowest pitch). uint8_t max_num_partials = _max_partials_for_partials_voice(partials_voice); uint8_t max_num_breakpoints[MAX_BREAKPOINT_SETS] = {2 + partials_voice->num_sample_times_ms, DEFAULT_NUM_BREAKPOINTS}; for (int o = 0; o < max_num_partials; ++o) { ensure_osc_allocd(osc + 1 + o, max_num_breakpoints); } for (int h = 0; h < num_harmonics; ++h) { if (use_this_partial_map[h]) { for (int i = 0; i < MAX_NUM_MAGNITUDES + 1; ++i) harm_param[i] = 0; _cumulate_scaled_harmonic_params(harm_param, harmonic_base_index_pl_vl + h, alpha_pl_vl, partials_voice); _cumulate_scaled_harmonic_params(harm_param, harmonic_base_index_pl_vh + h, alpha_pl_vh, partials_voice); _cumulate_scaled_harmonic_params(harm_param, harmonic_base_index_ph_vl + h, alpha_ph_vl, partials_voice); _cumulate_scaled_harmonic_params(harm_param, harmonic_base_index_ph_vh + h, alpha_ph_vh, partials_voice); //fprintf(stderr, "harm %d freq %.2f bps %.3f %.3f %.3f %.3f\n", h, harm_param[0], harm_param[1], harm_param[2], harm_param[3], harm_param[4]); ++osc; _osc_on_with_harm_param(osc, harm_param, partials_voice); } } } void interp_partials_note_off(uint16_t osc) { //const interp_partials_voice_t *partials_voice = &interp_partials_map[synth[osc]->preset % NUM_INTERP_PARTIALS_PRESETS]; //int num_oscs = partials_voice->num_harmonics[0]; // Assume first preset has the max #harmonics. int num_oscs = 0; //MAX_NUM_HARMONICS; // Actual max num harmonics we may use is the number of 1s in the use_this_partial_map. for (int i = 0; i < MAX_NUM_HARMONICS; ++i) num_oscs += use_this_partial_map[i]; for(uint16_t i = osc + 1; i < osc + 1 + num_oscs; i++) { uint16_t o = i % AMY_OSCS; if (synth[o]) { // For high notes, some partials may be unused, unintialized (?) AMY_UNSET(synth[o]->note_on_clock); synth[o]->note_off_clock = amy_global.total_blocks*AMY_BLOCK_SIZE; } } } ================================================ FILE: src/interp_partials.h ================================================ // Automatically generated. // Piano interpolated partials data table #ifndef __INTERP_PARTIALS_H #define __INTERP_PARTIALS_H #define NUM_INTERP_PARTIALS_PRESETS 1 #define NUM_PIANO_SAMPLE_TIMES_MS 20 const uint16_t piano_sample_times_ms[NUM_PIANO_SAMPLE_TIMES_MS] PROGMEM = { 4, 8, 12, 16, 24, 32, 48, 64, 96, 128, 192, 256, 384, 512, 768, 1024, 1536, 2048, 3072, 4096, }; #define NUM_PIANO_VELOCITIES 3 const uint8_t piano_velocities[NUM_PIANO_VELOCITIES] PROGMEM = { 40, 80, 120, }; #define NUM_PIANO_NOTES 21 const uint8_t piano_notes[NUM_PIANO_NOTES] PROGMEM = { 24, 28, 32, 36, 40, 44, 48, 52, 56, 60, 64, 68, 72, 76, 80, 84, 88, 92, 96, 100, 104, }; #define NUM_PIANO_NUM_HARMONICS 63 const uint8_t piano_num_harmonics[NUM_PIANO_NUM_HARMONICS] PROGMEM = { 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 37, 33, 32, 23, 28, 26, 22, 22, 21, 17, 17, 17, 13, 13, 13, 11, 11, 11, 8, 8, 9, 7, 7, 7, 6, 5, 5, 3, 4, 4, }; #define NUM_PIANO_HARMONICS_FREQ 1760 const uint16_t piano_harmonics_freq[NUM_PIANO_HARMONICS_FREQ] PROGMEM = { 2272, 3586, 4290, 4791, 5181, 5498, 5767, 5996, 6209, 6397, 6566, 6721, 6865, 6999, 7124, 7243, 7356, 7462, 7562, 7660, 7752, 7841, 7928, 8009, 8091, 8171, 8246, 8321, 8398, 8464, 8565, 8629, 8704, 8765, 8826, 8895, 8955, 9012, 9069, 9128, 2172, 3587, 4287, 4787, 5175, 5493, 5762, 5996, 6205, 6393, 6561, 6716, 6860, 6993, 7118, 7237, 7348, 7456, 7555, 7652, 7744, 7833, 7918, 8001, 8081, 8166, 8233, 8306, 8376, 8446, 8514, 8579, 8643, 8706, 8768, 8828, 8891, 8945, 8995, 9035, 2394, 3588, 4289, 4787, 5176, 5495, 5764, 5998, 6207, 6395, 6564, 6717, 6862, 6995, 7120, 7241, 7351, 7458, 7557, 7654, 7746, 7835, 7920, 8003, 8082, 8221, 8235, 8310, 8378, 8448, 8515, 8581, 8645, 8708, 8819, 8854, 8901, 8997, 9036, 9079, 2851, 3989, 4692, 5187, 5576, 5893, 6161, 6394, 6600, 6785, 6952, 7105, 7246, 7379, 7501, 7616, 7724, 7828, 7926, 8019, 8108, 8193, 8275, 8355, 8434, 8505, 8574, 8641, 8710, 8774, 8836, 8891, 8945, 8996, 9053, 9115, 9147, 9206, 9252, 9304, 3069, 3987, 4692, 5187, 5577, 5892, 6161, 6393, 6600, 6784, 6952, 7105, 7246, 7379, 7501, 7616, 7725, 7828, 7926, 8019, 8108, 8193, 8275, 8354, 8435, 8509, 8578, 8643, 8712, 8775, 8838, 8893, 8941, 9006, 9065, 9127, 9177, 9239, 9266, 9333, 3008, 3989, 4693, 5188, 5577, 5894, 6162, 6395, 6601, 6785, 6953, 7106, 7247, 7379, 7502, 7617, 7726, 7829, 7927, 8019, 8109, 8194, 8277, 8355, 8438, 8511, 8580, 8645, 8713, 8776, 8839, 8901, 8961, 9019, 9075, 9133, 9182, 9249, 9267, 9351, 3114, 4391, 5094, 5596, 5984, 6300, 6567, 6804, 7008, 7191, 7358, 7512, 7653, 7784, 7906, 8022, 8130, 8233, 8330, 8424, 8512, 8595, 8679, 8764, 8838, 8906, 8978, 9049, 9121, 9171, 9242, 9305, 9364, 9424, 9482, 9536, 9593, 9645, 9697, 9750, 3224, 4390, 5096, 5595, 5983, 6299, 6567, 6799, 7006, 7190, 7358, 7512, 7653, 7784, 7906, 8022, 8129, 8232, 8329, 8422, 8511, 8595, 8677, 8758, 8856, 8970, 8986, 9105, 9169, 9231, 9291, 9350, 9408, 9473, 9539, 9582, 9664, 9723, 9771, 9820, 3275, 4391, 5099, 5598, 5985, 6300, 6567, 6805, 7008, 7191, 7358, 7513, 7654, 7785, 7907, 8022, 8130, 8233, 8330, 8423, 8511, 8595, 8678, 8755, 8855, 8900, 8980, 9041, 9106, 9170, 9232, 9291, 9350, 9407, 9472, 9518, 9574, 9624, 9669, 9724, 3610, 4789, 5497, 5999, 6386, 6702, 6972, 7205, 7411, 7596, 7763, 7916, 8055, 8189, 8314, 8427, 8551, 8655, 8819, 8852, 8923, 9072, 9156, 9232, 9311, 9384, 9453, 9521, 9595, 9674, 9748, 9812, 9878, 9942, 10004, 10068, 10130, 10187, 10246, 10303, 3623, 4792, 5493, 5999, 6385, 6702, 6972, 7205, 7411, 7596, 7763, 7916, 8054, 8189, 8313, 8426, 8537, 8638, 8737, 8831, 8919, 9004, 9084, 9164, 9257, 9321, 9389, 9515, 9580, 9643, 9707, 9766, 9818, 9885, 9934, 9984, 10050, 10096, 10160, 10207, 3646, 4792, 5491, 6000, 6386, 6703, 6973, 7206, 7412, 7597, 7764, 7918, 8054, 8190, 8313, 8427, 8539, 8639, 8738, 8832, 8920, 9005, 9086, 9165, 9259, 9322, 9390, 9518, 9583, 9644, 9707, 9765, 9823, 9889, 9937, 9984, 10040, 10096, 10160, 10205, 4008, 5200, 5904, 6403, 6790, 7106, 7376, 7608, 7815, 7998, 8165, 8318, 8460, 8591, 8715, 8826, 8939, 9042, 9139, 9229, 9318, 9402, 9480, 9562, 9644, 9713, 9780, 9846, 9911, 9977, 10038, 10101, 10158, 10216, 10274, 10346, 10385, 10434, 10486, 10536, 4008, 5200, 5903, 6403, 6789, 7106, 7376, 7607, 7815, 7999, 8165, 8318, 8460, 8591, 8714, 8828, 8937, 9039, 9137, 9228, 9318, 9401, 9484, 9568, 9659, 9718, 9782, 9847, 9916, 9977, 10038, 10099, 10186, 10265, 10321, 10370, 10421, 10477, 10531, 10576, 4010, 5201, 5903, 6404, 6790, 7108, 7376, 7608, 7816, 7999, 8166, 8318, 8461, 8592, 8714, 8829, 8938, 9040, 9137, 9228, 9318, 9402, 9484, 9564, 9658, 9714, 9784, 9847, 9913, 9976, 10038, 10096, 10165, 10272, 10317, 10379, 10428, 10480, 10529, 10566, 4398, 5600, 6302, 6802, 7189, 7506, 7774, 8007, 8213, 8398, 8566, 8720, 8860, 8992, 9130, 9234, 9347, 9448, 9543, 9645, 9727, 9809, 9903, 9985, 10063, 10138, 10214, 10287, 10349, 10419, 10481, 10547, 10605, 10668, 10731, 10784, 10842, 10897, 10950, 11004, 4398, 5599, 6303, 6801, 7188, 7507, 7773, 8006, 8213, 8397, 8565, 8717, 8858, 8990, 9112, 9227, 9334, 9438, 9536, 9629, 9716, 9802, 9884, 9962, 10042, 10112, 10182, 10252, 10328, 10380, 10443, 10506, 10573, 10632, 10685, 10739, 10792, 10851, 10906, 10960, 4400, 5598, 6304, 6803, 7190, 7508, 7775, 8008, 8215, 8398, 8566, 8718, 8860, 8991, 9113, 9228, 9337, 9440, 9536, 9629, 9718, 9803, 9885, 9963, 10045, 10112, 10182, 10250, 10316, 10381, 10443, 10535, 10556, 10623, 10679, 10735, 10788, 10841, 10893, 10945, 4782, 6001, 6703, 7203, 7591, 7907, 8175, 8410, 8623, 8800, 8966, 9124, 9265, 9407, 9526, 9658, 9778, 9886, 9995, 10084, 10175, 10271, 10349, 10437, 10516, 10592, 10669, 10744, 10818, 10887, 10956, 11022, 11087, 11151, 11223, 11277, 11336, 11398, 11454, 11511, 4797, 6000, 6702, 7204, 7591, 7907, 8174, 8407, 8615, 8797, 8964, 9117, 9258, 9389, 9511, 9625, 9735, 9837, 9934, 10027, 10115, 10200, 10281, 10353, 10441, 10507, 10580, 10646, 10715, 10779, 10842, 10904, 10967, 11024, 11085, 11137, 11194, 11247, 11299, 11352, 4801, 6002, 6703, 7205, 7592, 7908, 8176, 8408, 8616, 8798, 8966, 9118, 9259, 9390, 9512, 9626, 9736, 9838, 9934, 10028, 10115, 10201, 10282, 10360, 10438, 10508, 10578, 10646, 10713, 10777, 10839, 10899, 10966, 11016, 11074, 11128, 11183, 11238, 11287, 11343, 5204, 6408, 7107, 7608, 7994, 8311, 8580, 8812, 9020, 9202, 9373, 9527, 9666, 9802, 9927, 10042, 10158, 10256, 10348, 10446, 10535, 10617, 10702, 10777, 10853, 10924, 10996, 11059, 11131, 11196, 11250, 11317, 11392, 11437, 11491, 11545, 11599, 11653, 11696, 11753, 5206, 6408, 7107, 7608, 7994, 8311, 8580, 8812, 9019, 9205, 9372, 9526, 9667, 9799, 9916, 10038, 10147, 10251, 10349, 10444, 10533, 10620, 10701, 10779, 10855, 10928, 11001, 11069, 11136, 11202, 11250, 11313, 11384, 11428, 11486, 11544, 11589, 11644, 11689, 11743, 5208, 6409, 7108, 7609, 7995, 8312, 8581, 8812, 9020, 9205, 9373, 9527, 9668, 9800, 9922, 10039, 10147, 10252, 10351, 10443, 10534, 10619, 10702, 10781, 10857, 10931, 11005, 11073, 11141, 11208, 11269, 11332, 11396, 11452, 11510, 11567, 11622, 11679, 11729, 11778, 5606, 6807, 7508, 8009, 8396, 8714, 8994, 9205, 9428, 9629, 9787, 9941, 10072, 10212, 10347, 10463, 10569, 10668, 10765, 10858, 10948, 11037, 11116, 11197, 11272, 11348, 11401, 11485, 11557, 11622, 11686, 11749, 11810, 11870, 11933, 11986, 12040, 12095, 12148, 12201, 5603, 6807, 7509, 8009, 8396, 8714, 8983, 9216, 9423, 9609, 9778, 9932, 10072, 10209, 10335, 10452, 10563, 10667, 10767, 10863, 10954, 11042, 11124, 11209, 11284, 11363, 11424, 11500, 11569, 11634, 11697, 11762, 11825, 11886, 11940, 12002, 12059, 12116, 12170, 12225, 5599, 6808, 7510, 8010, 8397, 8715, 8984, 9217, 9425, 9611, 9779, 9934, 10075, 10210, 10334, 10451, 10562, 10667, 10767, 10862, 10952, 11040, 11124, 11208, 11284, 11362, 11431, 11506, 11575, 11645, 11707, 11772, 11834, 11895, 11951, 12014, 12071, 12128, 12190, 12237, 6002, 7204, 7909, 8408, 8797, 9126, 9394, 9638, 9844, 10034, 10201, 10348, 10493, 10621, 10748, 10862, 10970, 11069, 11174, 11257, 11369, 11436, 11525, 11606, 11686, 11758, 11829, 11903, 11964, 12035, 12101, 12165, 12227, 12288, 12347, 12406, 12460, 12518, 12572, 12628, 6003, 7204, 7908, 8408, 8796, 9115, 9385, 9621, 9828, 10021, 10187, 10345, 10491, 10627, 10753, 10871, 10986, 11088, 11192, 11288, 11394, 11469, 11551, 11631, 11703, 11785, 11860, 11936, 12007, 12074, 12141, 12208, 12271, 12334, 12396, 12452, 12514, 12573, 12631, 12685, 6004, 7205, 7909, 8408, 8797, 9115, 9386, 9621, 9829, 10018, 10187, 10344, 10489, 10624, 10751, 10871, 10984, 11092, 11195, 11293, 11388, 11474, 11564, 11650, 11732, 11825, 11890, 11958, 12033, 12107, 12176, 12241, 12307, 12371, 12436, 12496, 12555, 12617, 12675, 12733, 6406, 7603, 8310, 8811, 9197, 9528, 9807, 10043, 10310, 10430, 10611, 10767, 10911, 11047, 11174, 11285, 11400, 11508, 11611, 11699, 11796, 11893, 11969, 12057, 12142, 12220, 12296, 12371, 12441, 12515, 12585, 12651, 12719, 12783, 12847, 12906, 12972, 13038, 13091, 13149, 6409, 7602, 8310, 8811, 9201, 9522, 9794, 10031, 10264, 10429, 10611, 10768, 10921, 11055, 11189, 11307, 11406, 11528, 11635, 11731, 11829, 11931, 12015, 12099, 12184, 12265, 12346, 12427, 12501, 12575, 12646, 12717, 12786, 12854, 12922, 12987, 13052, 13114, 13176, 13237, 6410, 7602, 8310, 8812, 9202, 9522, 9795, 10031, 10241, 10432, 10606, 10764, 10909, 11053, 11183, 11306, 11421, 11534, 11641, 11740, 11836, 11928, 12001, 12097, 12162, 12238, 12319, 12395, 12469, 12543, 12615, 12683, 12752, 12819, 12885, 12949, 13012, 13074, 13134, 13194, 6806, 8006, 8712, 9210, 9616, 9933, 10237, 10412, 10652, 10840, 11011, 11164, 11299, 11410, 11549, 11675, 11779, 11888, 11975, 12073, 12166, 12256, 12338, 12423, 12500, 12574, 12647, 12720, 12788, 12856, 12921, 12987, 13051, 13111, 13171, 13231, 13288, 6807, 8006, 8713, 9214, 9606, 9928, 10202, 10441, 10658, 10855, 11030, 11209, 11350, 11483, 11616, 11733, 11855, 11956, 12071, 12180, 12281, 12378, 12468, 12562, 12653, 12736, 12823, 12903, 12985, 13061, 13138, 13214, 13285, 6808, 8007, 8714, 9215, 9607, 9929, 10203, 10442, 10656, 10850, 11025, 11260, 11338, 11485, 11618, 11744, 11868, 11975, 12091, 12198, 12300, 12400, 12494, 12587, 12676, 12763, 12845, 12930, 13011, 13090, 13167, 13244, 7203, 8404, 9117, 9628, 10035, 10354, 10659, 10914, 11147, 11380, 11552, 11716, 11904, 12052, 12205, 12350, 12490, 12629, 12753, 12885, 13006, 13122, 13240, 7203, 8405, 9112, 9616, 10012, 10339, 10621, 10863, 11067, 11254, 11419, 11587, 11729, 11876, 12000, 12124, 12241, 12353, 12456, 12562, 12658, 12756, 12847, 12938, 13024, 13110, 13192, 13275, 7203, 8406, 9112, 9617, 10012, 10337, 10615, 10859, 11077, 11248, 11460, 11652, 11791, 11940, 12076, 12212, 12324, 12430, 12541, 12648, 12755, 12857, 12957, 13054, 13147, 13241, 7606, 8805, 9529, 10039, 10389, 10754, 11037, 11275, 11460, 11674, 11852, 12002, 12155, 12296, 12430, 12553, 12680, 12791, 12898, 13007, 13108, 13205, 7607, 8809, 9516, 10022, 10413, 10745, 11028, 11274, 11465, 11672, 11849, 12002, 12160, 12296, 12430, 12553, 12673, 12793, 12899, 13003, 13109, 13208, 7607, 8809, 9516, 10020, 10415, 10744, 11025, 11273, 11492, 11680, 11880, 12068, 12212, 12358, 12494, 12627, 12752, 12878, 12993, 13110, 13220, 8006, 9206, 9946, 10405, 10854, 11193, 11444, 11706, 11936, 12136, 12320, 12490, 12660, 12814, 12959, 13093, 13237, 8007, 9203, 9925, 10423, 10846, 11183, 11436, 11694, 11926, 12117, 12295, 12461, 12621, 12767, 12911, 13051, 13177, 8008, 9212, 9921, 10428, 10830, 11162, 11443, 11703, 11930, 12135, 12321, 12495, 12659, 12815, 12960, 13102, 13241, 8400, 9616, 10349, 10895, 11315, 11634, 11921, 12168, 12401, 12617, 12811, 13012, 13180, 8398, 9607, 10331, 10859, 11293, 11620, 11911, 12158, 12386, 12597, 12790, 12979, 13148, 8400, 9614, 10323, 10842, 11255, 11606, 11902, 12163, 12395, 12617, 12820, 13012, 13186, 8802, 10047, 10789, 11338, 11714, 12032, 12335, 12599, 12833, 13055, 13264, 8809, 10024, 10758, 11307, 11704, 12027, 12332, 12600, 12838, 13051, 13262, 8810, 10018, 10730, 11263, 11677, 12025, 12336, 12607, 12848, 13066, 13282, 9119, 10411, 11228, 11733, 12138, 12481, 12772, 13058, 9211, 10418, 11212, 11719, 12131, 12476, 12767, 13048, 9216, 10420, 11163, 11688, 12105, 12453, 12745, 13030, 13271, 9334, 10833, 11609, 12150, 12590, 12947, 13265, 9578, 10866, 11617, 12155, 12598, 12960, 13292, 9613, 10827, 11575, 12112, 12547, 12902, 13211, 9520, 11256, 12011, 12541, 12935, 13269, 9943, 11276, 12039, 12603, 13022, 9996, 11242, 12016, 12585, 13016, 8908, 11863, 12902, 10199, 11574, 12376, 12924, 10409, 11646, 12421, 12947, }; #define NUM_PIANO_HARMONICS_MAGS 35200 const uint8_t piano_harmonics_mags[NUM_PIANO_HARMONICS_MAGS] PROGMEM = { 39, 40, 41, 42, 37, 37, 40, 39, 42, 46, 41, 42, 44, 41, 41, 39, 42, 41, 40, 40, 51, 53, 55, 56, 55, 50, 48, 53, 49, 49, 51, 52, 53, 52, 52, 52, 53, 50, 52, 50, 65, 68, 70, 72, 73, 73, 73, 73, 73, 73, 72, 72, 72, 72, 71, 71, 70, 70, 68, 67, 69, 71, 73, 74, 75, 77, 77, 77, 74, 75, 75, 75, 75, 74, 72, 71, 69, 67, 62, 59, 69, 71, 73, 73, 74, 73, 74, 74, 75, 74, 74, 74, 73, 72, 71, 70, 67, 64, 58, 53, 68, 70, 72, 74, 75, 76, 77, 76, 72, 74, 72, 73, 72, 71, 71, 70, 68, 66, 62, 58, 52, 52, 52, 52, 53, 53, 49, 52, 53, 51, 52, 52, 52, 53, 52, 51, 51, 50, 46, 45, 43, 41, 44, 48, 54, 56, 56, 58, 59, 58, 56, 56, 50, 47, 47, 42, 39, 34, 29, 21, 48, 52, 55, 56, 59, 60, 62, 63, 62, 63, 63, 63, 62, 62, 60, 58, 56, 53, 49, 44, 56, 57, 57, 58, 59, 61, 61, 63, 63, 65, 64, 63, 62, 61, 59, 57, 53, 50, 45, 44, 47, 45, 51, 57, 62, 65, 67, 67, 66, 65, 64, 63, 62, 61, 59, 57, 53, 49, 41, 30, 61, 63, 64, 66, 68, 69, 71, 71, 71, 72, 71, 71, 70, 70, 68, 67, 64, 60, 48, 46, 58, 60, 61, 62, 63, 64, 64, 65, 66, 66, 66, 65, 65, 64, 62, 61, 58, 55, 49, 40, 45, 51, 55, 57, 61, 62, 63, 63, 62, 62, 62, 61, 61, 60, 60, 59, 57, 55, 48, 44, 51, 53, 54, 56, 57, 58, 58, 59, 61, 61, 61, 60, 60, 59, 57, 56, 51, 46, 38, 45, 45, 46, 47, 47, 47, 46, 47, 47, 42, 39, 51, 49, 46, 44, 45, 44, 43, 41, 39, 37, 46, 48, 49, 50, 50, 48, 44, 41, 42, 41, 40, 40, 37, 35, 33, 13, 29, 32, 35, 32, 48, 50, 51, 52, 53, 54, 55, 54, 54, 55, 54, 54, 53, 53, 51, 49, 45, 38, 30, 37, 50, 52, 52, 53, 53, 53, 53, 53, 52, 52, 52, 51, 51, 51, 50, 48, 45, 42, 33, 29, 49, 51, 52, 53, 53, 53, 51, 49, 48, 49, 48, 48, 48, 47, 47, 45, 44, 44, 42, 41, 35, 39, 41, 43, 45, 44, 38, 27, 15, 37, 36, 38, 40, 43, 44, 46, 47, 46, 41, 33, 36, 38, 39, 40, 42, 40, 33, 37, 43, 44, 43, 44, 43, 43, 43, 42, 41, 39, 36, 35, 39, 41, 43, 44, 45, 46, 47, 46, 45, 44, 44, 43, 41, 41, 34, 30, 31, 35, 38, 35, 38, 40, 42, 43, 43, 43, 44, 46, 47, 46, 46, 46, 46, 45, 43, 42, 40, 37, 34, 31, 36, 37, 38, 38, 38, 38, 38, 37, 39, 39, 38, 37, 38, 37, 34, 32, 25, 17, 26, 26, 30, 30, 28, 26, 24, 23, 29, 30, 31, 30, 25, 29, 27, 23, 23, 24, 24, 24, 13, 17, 26, 24, 21, 25, 31, 30, 35, 35, 32, 35, 34, 33, 33, 31, 28, 22, 22, 23, 19, 16, 26, 24, 23, 23, 26, 32, 32, 32, 33, 35, 35, 31, 31, 33, 29, 29, 26, 21, 0, 12, 41, 41, 40, 38, 37, 41, 31, 35, 24, 30, 31, 19, 32, 18, 27, 27, 21, 17, 8, 13, 38, 38, 37, 35, 19, 33, 35, 31, 34, 34, 31, 23, 25, 21, 21, 22, 19, 20, 5, 11, 27, 29, 30, 29, 21, 24, 9, 26, 21, 23, 22, 7, 25, 23, 21, 16, 20, 16, 12, 13, 19, 21, 22, 23, 22, 12, 16, 6, 20, 19, 14, 10, 16, 14, 12, 11, 11, 7, 13, 10, 12, 6, 0, 12, 19, 22, 24, 17, 23, 24, 21, 14, 21, 15, 11, 18, 17, 12, 14, 9, 3, 10, 14, 17, 17, 12, 5, 14, 1, 16, 13, 19, 10, 20, 11, 8, 12, 8, 15, 13, 15, 17, 18, 19, 20, 20, 18, 14, 12, 18, 14, 17, 21, 15, 15, 11, 11, 14, 14, 14, 27, 28, 29, 30, 29, 28, 28, 27, 28, 28, 27, 28, 30, 27, 23, 19, 21, 21, 16, 4, 20, 21, 20, 20, 17, 16, 25, 26, 23, 19, 24, 22, 25, 25, 18, 4, 21, 13, 2, 6, 20, 20, 20, 19, 20, 20, 19, 18, 20, 20, 23, 19, 23, 20, 17, 6, 0, 5, 7, 0, 17, 20, 22, 22, 22, 20, 22, 19, 23, 20, 18, 10, 3, 18, 14, 12, 8, 8, 0, 1, 28, 29, 30, 31, 31, 29, 24, 21, 20, 19, 18, 15, 19, 16, 10, 5, 7, 2, 3, 16, 38, 36, 36, 36, 33, 30, 34, 44, 47, 42, 41, 35, 41, 39, 42, 37, 44, 42, 40, 38, 55, 59, 62, 65, 67, 66, 59, 57, 61, 59, 59, 59, 60, 58, 58, 57, 57, 56, 56, 53, 70, 73, 76, 79, 81, 82, 79, 79, 81, 80, 80, 79, 79, 79, 78, 77, 75, 74, 71, 68, 73, 76, 77, 78, 79, 79, 79, 76, 78, 77, 77, 77, 76, 76, 75, 75, 73, 71, 67, 61, 74, 77, 79, 81, 83, 84, 84, 82, 84, 83, 83, 83, 83, 82, 81, 80, 79, 77, 73, 69, 71, 73, 75, 76, 78, 79, 78, 79, 79, 79, 78, 78, 78, 78, 77, 76, 75, 74, 72, 69, 66, 68, 69, 69, 69, 68, 65, 64, 66, 69, 69, 69, 68, 68, 67, 66, 65, 63, 61, 58, 62, 62, 62, 62, 65, 68, 70, 71, 72, 71, 69, 68, 67, 65, 63, 61, 57, 51, 44, 43, 54, 58, 61, 64, 67, 66, 65, 67, 66, 66, 67, 66, 66, 66, 64, 63, 61, 59, 55, 51, 62, 64, 65, 66, 63, 48, 63, 62, 49, 44, 52, 50, 48, 50, 49, 48, 50, 51, 51, 51, 59, 62, 65, 67, 72, 75, 78, 77, 76, 74, 72, 70, 69, 68, 65, 63, 58, 52, 40, 47, 66, 68, 69, 70, 70, 70, 70, 72, 73, 74, 73, 72, 71, 70, 68, 66, 62, 60, 56, 52, 57, 60, 64, 67, 71, 72, 69, 67, 69, 71, 73, 72, 72, 71, 70, 69, 67, 64, 59, 54, 61, 64, 67, 69, 71, 73, 75, 74, 74, 75, 74, 74, 74, 73, 72, 71, 68, 66, 66, 64, 48, 48, 47, 45, 53, 59, 62, 64, 58, 56, 57, 52, 54, 53, 52, 53, 54, 54, 53, 49, 53, 54, 55, 57, 61, 65, 68, 67, 63, 43, 57, 47, 54, 57, 57, 50, 54, 51, 50, 48, 56, 59, 61, 62, 62, 58, 43, 49, 52, 51, 49, 47, 47, 47, 45, 45, 44, 44, 34, 35, 59, 60, 61, 60, 59, 55, 42, 48, 40, 44, 46, 46, 46, 42, 43, 44, 40, 39, 39, 32, 56, 59, 61, 63, 64, 65, 65, 64, 63, 63, 63, 62, 62, 63, 63, 62, 60, 57, 57, 51, 51, 56, 59, 61, 63, 64, 63, 62, 57, 50, 53, 54, 54, 52, 54, 52, 52, 51, 49, 45, 61, 63, 64, 65, 66, 67, 67, 68, 68, 69, 69, 68, 67, 66, 65, 66, 65, 61, 60, 58, 56, 59, 62, 64, 66, 67, 67, 67, 67, 67, 68, 68, 67, 67, 66, 64, 62, 60, 56, 51, 55, 57, 57, 57, 57, 55, 55, 59, 61, 61, 60, 61, 60, 59, 57, 56, 55, 53, 50, 47, 55, 58, 60, 62, 63, 64, 64, 63, 63, 64, 63, 63, 62, 62, 61, 60, 58, 56, 53, 49, 59, 60, 61, 61, 61, 59, 57, 55, 55, 56, 54, 54, 54, 54, 52, 50, 50, 47, 43, 38, 51, 51, 50, 49, 50, 53, 45, 36, 38, 39, 40, 29, 34, 42, 37, 26, 26, 14, 18, 22, 57, 57, 57, 56, 54, 49, 55, 57, 54, 56, 56, 56, 55, 53, 52, 51, 48, 44, 39, 31, 57, 57, 56, 56, 59, 62, 65, 65, 61, 62, 60, 59, 59, 59, 59, 55, 54, 47, 43, 34, 55, 53, 48, 29, 53, 58, 59, 60, 57, 59, 58, 58, 58, 56, 54, 52, 46, 42, 32, 21, 58, 60, 61, 62, 63, 63, 61, 57, 61, 61, 59, 58, 57, 56, 54, 52, 49, 45, 37, 28, 51, 53, 54, 55, 56, 57, 58, 58, 59, 58, 58, 57, 53, 46, 51, 54, 42, 48, 40, 34, 46, 48, 49, 51, 52, 53, 54, 55, 55, 55, 55, 55, 54, 52, 51, 51, 47, 45, 39, 35, 49, 50, 50, 50, 49, 46, 45, 46, 47, 48, 47, 49, 47, 44, 44, 44, 39, 37, 32, 28, 42, 44, 45, 46, 46, 45, 44, 44, 44, 45, 45, 44, 44, 43, 42, 41, 38, 35, 27, 22, 35, 34, 32, 31, 31, 31, 28, 29, 34, 34, 37, 30, 34, 35, 23, 31, 27, 10, 15, 4, 45, 46, 47, 48, 48, 47, 44, 41, 48, 47, 49, 48, 45, 41, 41, 43, 39, 34, 29, 23, 33, 32, 30, 33, 40, 43, 42, 41, 45, 40, 45, 39, 40, 34, 43, 24, 36, 23, 17, 20, 36, 37, 39, 40, 42, 43, 44, 45, 45, 45, 45, 45, 43, 37, 35, 32, 34, 33, 24, 19, 41, 42, 43, 44, 45, 46, 45, 45, 40, 46, 35, 45, 47, 43, 37, 41, 28, 27, 15, 12, 39, 40, 41, 41, 40, 39, 40, 42, 39, 40, 37, 43, 37, 41, 35, 35, 25, 24, 19, 14, 45, 45, 44, 49, 54, 58, 57, 42, 53, 50, 57, 43, 48, 54, 29, 47, 47, 48, 42, 42, 67, 70, 74, 76, 79, 80, 76, 69, 73, 71, 68, 69, 70, 69, 69, 69, 67, 66, 65, 63, 77, 81, 84, 86, 90, 92, 92, 91, 93, 92, 92, 91, 91, 91, 90, 89, 88, 86, 83, 80, 79, 84, 86, 88, 90, 90, 90, 88, 88, 87, 88, 87, 86, 86, 85, 84, 83, 81, 77, 72, 76, 82, 86, 89, 93, 95, 96, 95, 96, 96, 96, 95, 95, 94, 93, 92, 90, 88, 84, 80, 81, 84, 86, 88, 90, 91, 90, 89, 90, 89, 89, 88, 88, 88, 87, 87, 86, 85, 83, 81, 77, 79, 81, 82, 82, 81, 78, 76, 79, 80, 81, 80, 80, 79, 79, 78, 76, 74, 71, 68, 76, 77, 78, 78, 77, 79, 83, 85, 86, 85, 83, 83, 81, 79, 77, 75, 70, 62, 56, 52, 69, 69, 70, 73, 79, 81, 78, 76, 80, 78, 79, 78, 78, 78, 76, 75, 73, 70, 65, 61, 76, 78, 78, 79, 78, 69, 77, 76, 67, 67, 68, 70, 67, 67, 62, 58, 55, 57, 60, 62, 74, 76, 78, 80, 83, 85, 89, 89, 89, 88, 85, 83, 82, 81, 79, 78, 74, 70, 61, 54, 66, 72, 76, 79, 82, 84, 86, 87, 86, 86, 85, 85, 84, 83, 81, 80, 76, 74, 68, 64, 66, 67, 71, 76, 82, 85, 85, 82, 83, 84, 84, 83, 83, 83, 82, 80, 79, 76, 72, 67, 63, 68, 73, 76, 81, 84, 87, 87, 86, 86, 86, 87, 86, 85, 84, 83, 80, 76, 75, 75, 56, 56, 56, 55, 59, 67, 73, 77, 80, 79, 78, 70, 73, 73, 71, 66, 67, 67, 65, 61, 56, 53, 53, 61, 72, 78, 82, 80, 73, 77, 72, 74, 75, 76, 74, 56, 70, 64, 63, 61, 71, 74, 76, 78, 79, 77, 57, 70, 70, 70, 64, 63, 65, 66, 61, 63, 61, 59, 50, 50, 72, 74, 75, 76, 75, 73, 67, 72, 69, 68, 69, 70, 67, 66, 64, 64, 60, 58, 56, 51, 67, 71, 75, 77, 80, 81, 82, 82, 82, 81, 81, 80, 80, 80, 79, 78, 76, 73, 71, 66, 60, 65, 71, 74, 79, 81, 82, 81, 81, 79, 79, 77, 78, 76, 74, 71, 70, 68, 64, 61, 71, 75, 78, 80, 82, 84, 85, 86, 84, 84, 84, 84, 83, 82, 81, 81, 79, 73, 71, 71, 67, 71, 75, 78, 82, 84, 85, 86, 85, 86, 85, 84, 83, 83, 82, 81, 77, 76, 71, 67, 70, 73, 75, 76, 77, 76, 70, 68, 73, 74, 75, 76, 75, 74, 70, 70, 68, 66, 59, 55, 70, 74, 77, 79, 82, 83, 83, 82, 81, 81, 82, 81, 81, 80, 78, 76, 74, 71, 66, 63, 75, 78, 80, 81, 81, 81, 77, 71, 67, 71, 67, 73, 69, 69, 68, 65, 63, 59, 51, 48, 74, 74, 73, 72, 69, 67, 73, 74, 59, 73, 57, 72, 57, 71, 44, 67, 59, 58, 46, 46, 75, 77, 77, 77, 76, 74, 76, 78, 75, 80, 79, 77, 74, 74, 72, 70, 65, 62, 54, 48, 77, 80, 81, 82, 83, 85, 88, 88, 82, 83, 85, 82, 81, 81, 78, 73, 64, 65, 63, 53, 71, 72, 74, 75, 77, 79, 79, 81, 79, 79, 77, 78, 77, 73, 70, 66, 61, 56, 41, 34, 76, 79, 82, 84, 86, 87, 86, 85, 84, 84, 82, 82, 81, 80, 76, 71, 67, 65, 50, 46, 72, 75, 77, 78, 80, 81, 81, 80, 80, 80, 79, 77, 72, 67, 72, 71, 64, 60, 55, 53, 74, 75, 77, 77, 78, 78, 79, 79, 77, 78, 77, 77, 76, 74, 70, 69, 62, 60, 48, 46, 70, 72, 72, 73, 73, 73, 74, 74, 74, 75, 73, 74, 72, 68, 64, 64, 58, 52, 48, 42, 64, 67, 69, 71, 73, 73, 70, 71, 72, 71, 70, 69, 69, 66, 64, 63, 58, 56, 52, 47, 62, 66, 69, 70, 68, 57, 68, 71, 67, 70, 66, 61, 67, 68, 67, 57, 61, 49, 34, 30, 68, 70, 71, 72, 73, 75, 77, 73, 76, 76, 77, 76, 73, 71, 65, 64, 58, 55, 50, 42, 61, 61, 59, 51, 62, 64, 61, 54, 68, 65, 70, 67, 72, 73, 70, 57, 61, 55, 49, 43, 69, 71, 71, 71, 76, 78, 79, 78, 71, 73, 75, 68, 74, 76, 64, 61, 62, 51, 43, 36, 60, 60, 62, 64, 68, 67, 70, 74, 72, 71, 72, 74, 72, 70, 62, 62, 55, 55, 43, 38, 63, 65, 67, 69, 69, 67, 58, 65, 64, 68, 69, 68, 69, 65, 60, 56, 52, 45, 35, 31, 41, 41, 40, 38, 39, 38, 32, 40, 38, 46, 42, 32, 43, 38, 23, 41, 45, 37, 35, 45, 58, 63, 66, 69, 70, 70, 73, 73, 75, 76, 76, 76, 75, 74, 69, 63, 50, 43, 29, 34, 67, 70, 72, 73, 75, 76, 77, 77, 74, 74, 76, 75, 74, 73, 72, 70, 68, 65, 59, 52, 64, 68, 71, 72, 74, 74, 73, 72, 74, 74, 74, 74, 73, 73, 72, 72, 70, 69, 66, 64, 65, 67, 69, 70, 71, 71, 71, 71, 71, 71, 72, 71, 71, 70, 69, 68, 66, 64, 59, 51, 62, 64, 66, 67, 67, 66, 63, 65, 68, 68, 69, 70, 70, 69, 68, 66, 63, 60, 55, 50, 63, 65, 66, 67, 68, 67, 68, 67, 66, 67, 67, 67, 67, 66, 65, 64, 63, 61, 57, 53, 39, 39, 42, 45, 49, 50, 45, 44, 47, 48, 47, 48, 46, 46, 44, 45, 42, 39, 37, 33, 43, 44, 45, 47, 49, 51, 50, 52, 53, 50, 50, 50, 50, 47, 46, 46, 47, 43, 41, 40, 44, 43, 39, 25, 45, 50, 54, 54, 54, 55, 55, 56, 55, 54, 54, 53, 52, 51, 48, 45, 36, 46, 51, 55, 58, 60, 61, 63, 63, 63, 64, 63, 63, 63, 62, 61, 59, 57, 53, 50, 51, 54, 56, 57, 58, 59, 60, 60, 59, 60, 60, 59, 59, 58, 58, 56, 54, 53, 49, 46, 45, 48, 50, 52, 51, 53, 58, 58, 58, 59, 59, 59, 59, 59, 58, 58, 57, 54, 48, 40, 43, 46, 49, 52, 56, 60, 62, 61, 62, 62, 61, 60, 59, 58, 56, 55, 53, 49, 21, 35, 46, 47, 48, 49, 49, 50, 51, 52, 53, 53, 53, 53, 52, 51, 49, 47, 41, 35, 41, 42, 38, 39, 40, 41, 40, 40, 41, 38, 37, 39, 37, 35, 35, 33, 29, 19, 28, 32, 31, 14, 28, 28, 26, 24, 25, 28, 31, 30, 34, 31, 31, 29, 22, 31, 27, 18, 13, 19, 13, 10, 38, 40, 41, 41, 41, 42, 43, 43, 43, 43, 43, 43, 41, 38, 31, 18, 37, 38, 24, 30, 34, 37, 39, 40, 42, 41, 39, 41, 40, 40, 39, 38, 38, 36, 29, 26, 35, 33, 25, 22, 24, 27, 29, 30, 29, 29, 31, 28, 28, 30, 30, 32, 30, 32, 26, 20, 24, 24, 25, 22, 21, 24, 26, 28, 32, 34, 35, 35, 34, 34, 34, 33, 32, 28, 14, 21, 27, 14, 20, 19, 30, 31, 32, 33, 33, 33, 32, 29, 29, 32, 33, 33, 34, 31, 26, 23, 29, 18, 11, 13, 33, 35, 35, 36, 36, 36, 34, 34, 36, 34, 34, 32, 27, 20, 31, 30, 4, 26, 25, 16, 25, 26, 27, 26, 23, 21, 16, 24, 25, 28, 28, 29, 31, 29, 19, 27, 18, 18, 15, 10, 17, 17, 15, 12, 10, 15, 16, 25, 15, 19, 21, 19, 11, 14, 15, 17, 5, 13, 14, 0, 28, 28, 27, 27, 25, 18, 28, 26, 22, 19, 8, 21, 21, 20, 16, 19, 19, 15, 8, 5, 34, 34, 33, 31, 34, 37, 36, 37, 34, 30, 26, 21, 22, 26, 20, 12, 12, 16, 7, 16, 29, 31, 32, 33, 33, 31, 18, 19, 18, 21, 21, 21, 21, 22, 21, 22, 16, 16, 1, 16, 23, 23, 22, 22, 21, 24, 25, 26, 26, 28, 27, 28, 27, 25, 24, 21, 20, 16, 13, 16, 27, 29, 30, 31, 31, 30, 32, 32, 31, 31, 30, 26, 13, 29, 30, 22, 23, 15, 9, 12, 24, 26, 28, 29, 29, 28, 25, 27, 28, 29, 28, 24, 19, 27, 19, 24, 20, 11, 4, 6, 14, 13, 11, 9, 0, 11, 19, 19, 10, 8, 7, 15, 20, 16, 10, 15, 7, 0, 0, 10, 15, 14, 12, 5, 10, 15, 8, 16, 0, 12, 6, 13, 5, 8, 13, 10, 5, 11, 6, 0, 6, 4, 7, 11, 12, 8, 6, 0, 9, 10, 0, 9, 0, 15, 10, 7, 7, 5, 7, 7, 7, 11, 13, 15, 15, 12, 8, 14, 10, 14, 5, 6, 12, 5, 5, 13, 5, 6, 2, 5, 15, 15, 14, 14, 13, 11, 10, 0, 12, 15, 15, 18, 16, 12, 10, 15, 14, 15, 0, 2, 17, 16, 13, 7, 15, 20, 16, 18, 14, 14, 13, 10, 12, 10, 11, 14, 16, 15, 15, 10, 23, 22, 22, 20, 13, 10, 23, 21, 15, 7, 16, 16, 10, 9, 15, 0, 0, 10, 9, 9, 31, 32, 33, 32, 30, 28, 26, 26, 19, 20, 18, 10, 14, 0, 13, 11, 10, 3, 8, 7, 15, 15, 13, 8, 2, 12, 17, 17, 5, 9, 11, 12, 10, 14, 8, 0, 10, 0, 6, 9, 47, 48, 46, 41, 45, 42, 48, 47, 47, 48, 46, 51, 47, 43, 48, 38, 42, 27, 42, 34, 47, 60, 67, 71, 76, 77, 79, 80, 81, 82, 82, 81, 80, 78, 76, 73, 65, 51, 42, 38, 65, 71, 75, 77, 80, 82, 83, 83, 81, 81, 82, 81, 81, 79, 78, 76, 72, 70, 65, 60, 63, 69, 73, 76, 80, 81, 81, 79, 80, 81, 80, 80, 80, 79, 79, 78, 77, 75, 73, 71, 67, 71, 73, 75, 77, 78, 78, 78, 78, 78, 79, 78, 78, 77, 77, 76, 74, 72, 66, 59, 65, 69, 72, 74, 75, 75, 73, 72, 75, 77, 78, 78, 78, 78, 77, 75, 72, 69, 63, 57, 68, 71, 73, 75, 76, 76, 76, 76, 75, 76, 76, 76, 75, 75, 74, 73, 71, 69, 65, 62, 47, 45, 35, 42, 56, 59, 57, 53, 56, 55, 54, 55, 54, 55, 53, 52, 51, 50, 47, 44, 56, 56, 57, 57, 59, 60, 60, 62, 61, 61, 59, 60, 60, 59, 57, 58, 55, 54, 51, 48, 55, 57, 58, 56, 46, 57, 63, 65, 65, 66, 67, 66, 66, 66, 65, 64, 63, 62, 58, 55, 43, 51, 57, 62, 67, 70, 71, 73, 74, 74, 75, 74, 74, 74, 73, 72, 70, 69, 65, 61, 56, 61, 64, 67, 69, 70, 72, 72, 71, 71, 71, 71, 71, 70, 70, 69, 68, 66, 63, 60, 55, 58, 61, 63, 65, 63, 70, 71, 71, 72, 72, 72, 72, 72, 72, 71, 69, 67, 61, 56, 53, 56, 58, 61, 66, 71, 76, 76, 76, 76, 75, 75, 73, 72, 70, 69, 67, 62, 37, 51, 55, 59, 61, 63, 64, 64, 66, 66, 67, 67, 67, 67, 66, 65, 62, 60, 52, 50, 55, 56, 52, 54, 56, 57, 56, 55, 56, 55, 53, 54, 52, 52, 50, 49, 43, 31, 45, 48, 44, 28, 46, 47, 48, 47, 43, 44, 48, 49, 49, 48, 49, 47, 46, 45, 39, 28, 38, 42, 34, 34, 53, 57, 59, 61, 61, 61, 62, 62, 62, 61, 61, 60, 57, 55, 45, 45, 55, 54, 46, 46, 51, 54, 57, 59, 61, 62, 61, 61, 61, 60, 59, 59, 57, 55, 45, 46, 55, 52, 47, 42, 45, 48, 51, 52, 54, 55, 57, 56, 58, 59, 59, 59, 59, 57, 51, 47, 56, 48, 51, 47, 49, 51, 53, 54, 55, 57, 59, 59, 57, 56, 56, 54, 53, 50, 34, 50, 51, 38, 36, 42, 52, 55, 56, 57, 58, 57, 57, 56, 58, 58, 58, 58, 57, 55, 34, 52, 52, 45, 37, 30, 51, 54, 56, 57, 58, 58, 59, 60, 59, 58, 56, 54, 50, 48, 54, 56, 44, 52, 48, 43, 47, 48, 49, 48, 42, 32, 42, 46, 49, 51, 52, 52, 51, 47, 40, 48, 31, 44, 36, 29, 44, 44, 42, 40, 34, 35, 30, 35, 45, 43, 42, 28, 39, 13, 39, 35, 29, 33, 11, 15, 39, 42, 46, 49, 51, 49, 37, 48, 40, 48, 39, 37, 34, 37, 33, 32, 32, 31, 19, 4, 54, 56, 57, 57, 51, 44, 48, 54, 55, 54, 55, 55, 53, 51, 44, 44, 40, 42, 37, 29, 48, 50, 51, 52, 52, 51, 41, 40, 33, 35, 37, 38, 36, 40, 39, 39, 35, 30, 27, 17, 42, 44, 44, 44, 44, 43, 44, 44, 43, 45, 45, 44, 43, 41, 41, 38, 36, 31, 27, 20, 41, 43, 44, 45, 44, 44, 45, 46, 47, 46, 46, 45, 33, 40, 43, 36, 32, 25, 19, 16, 26, 25, 28, 32, 36, 35, 34, 37, 38, 40, 38, 37, 24, 35, 28, 35, 31, 26, 17, 22, 28, 27, 26, 23, 18, 23, 32, 27, 26, 24, 22, 23, 27, 25, 21, 16, 11, 11, 6, 6, 24, 26, 28, 28, 26, 23, 26, 22, 22, 21, 23, 25, 22, 21, 21, 10, 15, 10, 11, 7, 31, 32, 32, 31, 27, 16, 25, 23, 10, 15, 22, 9, 1, 10, 14, 14, 15, 11, 14, 7, 12, 19, 22, 23, 21, 21, 16, 19, 14, 10, 10, 17, 12, 7, 11, 15, 14, 2, 1, 5, 28, 28, 30, 30, 29, 25, 25, 24, 25, 26, 27, 23, 27, 22, 24, 23, 20, 19, 11, 12, 37, 38, 37, 35, 24, 30, 34, 20, 24, 31, 6, 31, 27, 30, 22, 27, 12, 21, 13, 14, 47, 50, 51, 51, 50, 45, 41, 40, 36, 36, 29, 28, 31, 25, 24, 21, 24, 14, 9, 10, 41, 42, 42, 41, 38, 40, 40, 41, 39, 36, 38, 30, 27, 34, 36, 26, 27, 24, 13, 15, 31, 33, 32, 30, 20, 26, 27, 26, 22, 25, 13, 20, 23, 17, 13, 20, 4, 11, 6, 7, 60, 59, 58, 56, 60, 63, 63, 44, 60, 60, 54, 53, 46, 40, 43, 44, 41, 40, 44, 47, 67, 73, 79, 82, 87, 88, 89, 92, 93, 93, 92, 91, 89, 87, 86, 85, 81, 76, 60, 44, 69, 77, 82, 86, 89, 92, 94, 94, 93, 93, 94, 93, 92, 92, 90, 88, 84, 80, 73, 66, 73, 78, 82, 86, 90, 92, 92, 90, 90, 92, 91, 91, 91, 90, 90, 88, 87, 86, 83, 80, 74, 78, 81, 83, 86, 88, 89, 89, 90, 89, 90, 89, 89, 88, 88, 87, 85, 84, 79, 72, 66, 74, 79, 82, 86, 88, 87, 84, 86, 87, 87, 88, 88, 87, 86, 84, 82, 80, 74, 68, 80, 83, 85, 87, 90, 90, 91, 90, 89, 90, 90, 90, 89, 89, 88, 87, 85, 83, 79, 76, 56, 56, 63, 68, 74, 77, 74, 67, 69, 69, 68, 68, 68, 68, 67, 65, 63, 62, 59, 55, 71, 73, 74, 75, 75, 75, 73, 74, 73, 75, 72, 72, 72, 71, 67, 71, 67, 65, 63, 60, 65, 68, 70, 70, 71, 76, 77, 79, 79, 80, 80, 80, 80, 80, 79, 78, 76, 75, 72, 68, 65, 70, 73, 76, 81, 83, 86, 87, 88, 89, 89, 88, 87, 87, 86, 85, 84, 83, 79, 76, 67, 73, 77, 80, 83, 83, 85, 86, 85, 84, 84, 83, 84, 83, 82, 81, 79, 78, 74, 72, 66, 70, 73, 77, 81, 80, 83, 86, 86, 84, 86, 85, 85, 84, 84, 83, 82, 80, 74, 68, 64, 69, 72, 76, 83, 88, 93, 93, 93, 93, 92, 92, 90, 88, 86, 85, 84, 80, 54, 66, 71, 76, 79, 81, 83, 83, 85, 85, 87, 87, 86, 85, 84, 82, 78, 74, 62, 70, 73, 71, 69, 72, 74, 75, 76, 76, 75, 73, 72, 69, 67, 64, 64, 61, 47, 51, 62, 64, 58, 50, 65, 67, 67, 66, 63, 64, 68, 69, 70, 71, 70, 69, 68, 67, 61, 44, 61, 64, 55, 55, 70, 74, 77, 79, 81, 81, 81, 80, 81, 81, 81, 81, 79, 77, 69, 61, 75, 75, 65, 67, 70, 73, 75, 77, 79, 80, 80, 79, 80, 78, 78, 76, 74, 72, 60, 64, 71, 69, 63, 58, 64, 68, 72, 74, 76, 77, 77, 73, 75, 75, 75, 75, 75, 75, 71, 67, 69, 66, 65, 59, 68, 71, 73, 74, 76, 78, 79, 78, 75, 75, 74, 74, 73, 70, 62, 68, 71, 58, 56, 60, 76, 79, 80, 81, 82, 83, 83, 82, 83, 82, 82, 81, 78, 74, 69, 77, 72, 71, 64, 57, 75, 78, 80, 82, 83, 83, 85, 85, 83, 84, 82, 79, 73, 66, 78, 80, 60, 75, 71, 66, 70, 72, 73, 73, 69, 60, 67, 65, 69, 72, 74, 74, 73, 73, 56, 68, 58, 65, 59, 41, 60, 60, 51, 53, 67, 69, 64, 58, 69, 64, 62, 62, 63, 44, 61, 57, 54, 53, 42, 28, 70, 74, 77, 79, 81, 78, 68, 76, 72, 75, 66, 62, 62, 64, 55, 57, 52, 50, 42, 19, 78, 81, 82, 82, 72, 79, 85, 86, 88, 88, 88, 88, 86, 82, 78, 75, 75, 74, 64, 60, 72, 75, 77, 78, 78, 77, 60, 72, 66, 67, 71, 73, 74, 73, 70, 66, 66, 60, 56, 51, 72, 74, 75, 75, 76, 76, 80, 81, 82, 82, 83, 82, 77, 73, 78, 69, 64, 59, 51, 43, 72, 76, 79, 81, 82, 83, 83, 83, 84, 83, 82, 79, 72, 78, 76, 73, 68, 63, 48, 49, 66, 70, 73, 75, 77, 78, 76, 77, 77, 78, 78, 75, 59, 74, 60, 72, 68, 58, 56, 55, 64, 65, 65, 65, 66, 67, 69, 67, 69, 65, 55, 64, 70, 68, 64, 62, 54, 44, 51, 50, 54, 57, 59, 60, 59, 57, 55, 53, 51, 57, 60, 62, 57, 24, 57, 52, 52, 48, 27, 38, 60, 62, 63, 64, 62, 59, 50, 48, 54, 42, 47, 44, 44, 41, 45, 38, 41, 34, 30, 22, 61, 63, 65, 65, 63, 59, 54, 56, 61, 49, 61, 62, 59, 49, 53, 54, 49, 49, 40, 36, 49, 55, 60, 63, 65, 64, 59, 67, 69, 70, 74, 73, 64, 67, 61, 67, 55, 55, 48, 49, 62, 64, 65, 64, 58, 58, 63, 71, 76, 73, 74, 59, 67, 60, 71, 65, 62, 57, 34, 42, 64, 68, 72, 75, 77, 79, 86, 83, 83, 82, 60, 73, 66, 72, 69, 64, 63, 58, 43, 35, 69, 72, 74, 75, 76, 77, 80, 79, 80, 76, 74, 74, 69, 75, 71, 62, 60, 56, 48, 41, 62, 62, 61, 59, 61, 61, 52, 64, 67, 62, 53, 62, 59, 56, 59, 61, 42, 48, 44, 40, 54, 54, 53, 50, 43, 45, 53, 42, 41, 37, 38, 44, 34, 43, 47, 41, 46, 45, 44, 45, 68, 72, 74, 75, 77, 77, 76, 75, 74, 75, 73, 72, 72, 71, 70, 68, 64, 61, 62, 63, 65, 67, 68, 67, 63, 60, 62, 61, 60, 56, 58, 56, 59, 58, 57, 56, 54, 55, 52, 50, 68, 70, 71, 72, 71, 70, 70, 70, 69, 68, 68, 68, 67, 66, 63, 60, 53, 52, 52, 47, 70, 72, 73, 73, 74, 75, 76, 76, 77, 77, 77, 77, 75, 74, 71, 68, 59, 55, 63, 63, 65, 66, 67, 67, 67, 67, 67, 69, 70, 70, 70, 70, 69, 68, 67, 66, 62, 54, 52, 57, 54, 56, 58, 59, 60, 61, 60, 58, 53, 53, 55, 55, 53, 53, 50, 48, 42, 32, 38, 41, 46, 48, 50, 49, 45, 44, 44, 36, 37, 38, 40, 39, 38, 37, 38, 32, 35, 32, 19, 24, 54, 54, 54, 55, 56, 57, 54, 50, 47, 48, 48, 48, 48, 45, 45, 42, 39, 34, 34, 40, 62, 64, 65, 65, 66, 67, 66, 67, 67, 67, 67, 66, 66, 65, 63, 62, 58, 55, 46, 38, 62, 63, 64, 64, 63, 62, 60, 60, 60, 60, 60, 59, 57, 55, 49, 31, 50, 52, 46, 43, 60, 61, 62, 63, 63, 63, 61, 61, 62, 61, 61, 60, 58, 56, 51, 44, 42, 47, 44, 36, 55, 56, 57, 58, 58, 58, 56, 56, 55, 55, 54, 52, 52, 50, 46, 42, 34, 38, 42, 40, 51, 52, 52, 52, 52, 51, 51, 51, 52, 53, 52, 52, 52, 52, 50, 49, 46, 46, 42, 10, 47, 49, 50, 51, 51, 50, 51, 51, 51, 50, 49, 48, 47, 45, 41, 38, 31, 36, 37, 34, 36, 37, 38, 38, 37, 37, 37, 36, 38, 37, 38, 38, 36, 33, 31, 30, 25, 22, 24, 23, 25, 26, 27, 27, 29, 28, 26, 29, 28, 26, 21, 23, 23, 20, 16, 16, 15, 21, 17, 18, 34, 35, 36, 37, 37, 36, 34, 35, 36, 36, 36, 35, 34, 34, 31, 28, 23, 20, 19, 20, 34, 35, 36, 36, 36, 37, 36, 35, 36, 34, 33, 32, 30, 24, 24, 27, 28, 27, 19, 18, 29, 31, 32, 32, 31, 31, 29, 33, 33, 30, 29, 31, 30, 30, 26, 27, 26, 16, 15, 19, 24, 25, 27, 28, 29, 27, 29, 30, 29, 29, 28, 26, 21, 25, 15, 19, 18, 16, 10, 9, 30, 32, 34, 35, 34, 34, 36, 36, 37, 37, 36, 36, 32, 29, 25, 27, 30, 17, 13, 15, 22, 23, 24, 23, 21, 23, 26, 26, 29, 24, 25, 23, 20, 20, 23, 20, 15, 6, 16, 17, 14, 20, 23, 24, 24, 22, 27, 16, 23, 18, 19, 12, 16, 16, 3, 11, 14, 9, 19, 19, 25, 25, 23, 23, 28, 24, 18, 17, 22, 21, 15, 16, 13, 12, 14, 14, 12, 11, 12, 0, 22, 19, 17, 23, 28, 27, 25, 23, 23, 24, 20, 19, 14, 14, 12, 11, 9, 6, 5, 4, 13, 9, 15, 19, 21, 22, 21, 24, 13, 20, 18, 13, 3, 17, 19, 18, 11, 1, 0, 9, 19, 19, 17, 10, 12, 13, 19, 6, 15, 10, 16, 7, 12, 7, 19, 8, 4, 8, 12, 11, 14, 15, 17, 19, 21, 22, 20, 22, 16, 17, 19, 11, 16, 19, 16, 8, 12, 20, 17, 8, 24, 25, 25, 25, 23, 23, 24, 22, 18, 20, 16, 13, 21, 17, 18, 6, 19, 16, 3, 17, 18, 15, 9, 0, 13, 14, 15, 15, 9, 17, 13, 9, 10, 11, 13, 10, 11, 9, 0, 7, 17, 19, 20, 19, 9, 9, 11, 8, 12, 16, 9, 11, 6, 8, 8, 2, 0, 12, 7, 8, 19, 21, 21, 20, 13, 5, 5, 0, 16, 12, 10, 8, 13, 12, 10, 5, 9, 0, 8, 6, 21, 22, 21, 19, 7, 0, 12, 11, 3, 7, 0, 9, 13, 12, 6, 1, 8, 0, 6, 0, 16, 19, 20, 18, 18, 17, 10, 4, 16, 0, 6, 10, 5, 7, 0, 3, 9, 0, 3, 8, 13, 18, 20, 20, 5, 11, 11, 6, 3, 8, 5, 0, 0, 6, 0, 10, 10, 5, 5, 4, 19, 24, 26, 27, 22, 5, 9, 6, 12, 0, 5, 10, 6, 10, 6, 11, 5, 3, 0, 0, 21, 23, 24, 23, 20, 12, 16, 13, 14, 12, 11, 0, 3, 11, 3, 13, 7, 10, 2, 5, 16, 17, 18, 17, 13, 6, 7, 13, 10, 9, 7, 4, 4, 7, 9, 7, 3, 5, 6, 2, 15, 16, 14, 11, 8, 11, 5, 0, 12, 3, 6, 0, 8, 6, 9, 2, 2, 5, 0, 0, 53, 60, 62, 64, 63, 58, 59, 56, 47, 56, 50, 56, 50, 53, 50, 48, 50, 41, 48, 44, 62, 69, 74, 78, 83, 85, 86, 84, 82, 83, 81, 81, 80, 79, 78, 76, 71, 68, 71, 70, 57, 62, 70, 74, 76, 72, 70, 69, 68, 64, 63, 64, 65, 65, 64, 63, 63, 62, 61, 59, 68, 74, 77, 79, 81, 81, 78, 78, 78, 76, 76, 75, 74, 73, 71, 68, 61, 58, 61, 58, 71, 76, 80, 82, 83, 84, 86, 86, 88, 87, 87, 86, 85, 84, 82, 79, 68, 66, 74, 74, 64, 70, 74, 77, 78, 78, 78, 79, 81, 81, 80, 80, 80, 79, 78, 76, 72, 66, 60, 67, 66, 68, 69, 70, 71, 72, 73, 72, 68, 65, 66, 66, 65, 65, 64, 62, 59, 54, 41, 50, 57, 59, 61, 61, 61, 56, 57, 53, 51, 53, 51, 53, 54, 50, 50, 49, 45, 40, 31, 29, 64, 67, 68, 68, 69, 70, 71, 67, 60, 61, 62, 62, 62, 59, 58, 57, 53, 50, 48, 52, 68, 73, 76, 78, 80, 81, 82, 82, 83, 83, 82, 82, 81, 80, 79, 77, 74, 70, 63, 57, 70, 75, 77, 78, 79, 79, 75, 75, 76, 75, 75, 74, 73, 71, 64, 53, 65, 66, 58, 57, 71, 75, 77, 78, 79, 80, 79, 78, 79, 79, 78, 78, 76, 74, 70, 64, 56, 63, 61, 55, 66, 71, 73, 75, 76, 77, 76, 73, 75, 73, 73, 73, 72, 71, 69, 65, 59, 42, 56, 56, 64, 68, 71, 72, 73, 73, 71, 71, 70, 71, 72, 72, 72, 72, 71, 70, 68, 67, 62, 49, 61, 65, 68, 70, 73, 73, 73, 74, 73, 73, 73, 72, 71, 69, 67, 63, 52, 51, 57, 54, 59, 61, 61, 61, 61, 62, 63, 63, 63, 63, 62, 62, 60, 59, 56, 53, 48, 29, 52, 49, 54, 56, 56, 56, 55, 53, 51, 54, 52, 52, 52, 51, 50, 49, 48, 45, 40, 38, 42, 40, 58, 61, 63, 63, 62, 61, 61, 62, 62, 62, 62, 61, 60, 58, 55, 52, 43, 44, 47, 45, 60, 64, 67, 68, 69, 69, 68, 67, 67, 66, 65, 64, 63, 60, 54, 48, 53, 55, 53, 43, 48, 55, 60, 62, 63, 63, 64, 64, 63, 62, 62, 62, 61, 60, 57, 56, 56, 46, 44, 35, 58, 62, 63, 63, 63, 64, 64, 65, 65, 65, 63, 63, 61, 59, 54, 49, 51, 56, 49, 45, 57, 62, 65, 68, 70, 71, 70, 71, 71, 71, 70, 68, 65, 57, 59, 65, 62, 49, 50, 50, 48, 47, 49, 53, 56, 55, 57, 59, 60, 59, 55, 58, 56, 52, 50, 49, 43, 48, 47, 31, 58, 60, 60, 59, 50, 52, 52, 51, 43, 51, 40, 45, 30, 36, 40, 42, 43, 33, 36, 34, 59, 60, 61, 62, 60, 56, 58, 58, 57, 56, 54, 53, 50, 46, 14, 43, 41, 32, 32, 29, 58, 59, 59, 58, 56, 56, 45, 52, 49, 51, 35, 43, 43, 38, 43, 39, 32, 24, 17, 22, 45, 49, 50, 51, 52, 50, 46, 45, 41, 44, 39, 39, 39, 37, 35, 28, 26, 24, 17, 23, 43, 46, 47, 47, 46, 47, 51, 49, 48, 47, 45, 44, 40, 42, 39, 42, 33, 41, 31, 32, 46, 48, 50, 50, 50, 50, 49, 47, 44, 40, 35, 36, 45, 45, 35, 41, 40, 38, 34, 29, 35, 38, 41, 43, 44, 43, 40, 35, 37, 37, 34, 32, 28, 33, 30, 29, 24, 29, 19, 20, 40, 42, 43, 42, 40, 37, 32, 38, 36, 36, 35, 33, 26, 29, 31, 28, 22, 5, 4, 13, 21, 22, 32, 35, 35, 31, 34, 29, 29, 17, 8, 25, 31, 31, 20, 28, 26, 24, 18, 13, 39, 42, 43, 43, 40, 36, 36, 34, 29, 30, 23, 23, 29, 29, 18, 22, 13, 16, 15, 10, 34, 35, 35, 33, 29, 31, 27, 14, 3, 21, 20, 20, 14, 18, 17, 16, 13, 10, 5, 6, 24, 24, 24, 26, 31, 31, 11, 27, 26, 14, 12, 12, 17, 21, 7, 13, 11, 0, 2, 8, 40, 43, 44, 45, 41, 29, 27, 36, 34, 26, 25, 20, 20, 21, 17, 15, 13, 5, 0, 11, 38, 39, 38, 34, 29, 38, 32, 41, 28, 27, 34, 30, 25, 30, 30, 25, 25, 19, 9, 7, 25, 28, 30, 31, 31, 32, 31, 33, 32, 30, 12, 28, 23, 21, 26, 26, 19, 18, 10, 0, 22, 24, 31, 35, 36, 30, 29, 26, 25, 8, 23, 27, 15, 20, 22, 24, 18, 15, 11, 9, 33, 34, 33, 29, 23, 27, 23, 27, 19, 21, 24, 14, 23, 25, 18, 21, 9, 8, 4, 3, 59, 67, 71, 73, 73, 68, 66, 67, 48, 65, 55, 66, 55, 63, 58, 53, 59, 47, 49, 54, 74, 80, 85, 88, 93, 95, 95, 93, 91, 92, 91, 91, 89, 89, 87, 85, 79, 77, 79, 77, 70, 73, 79, 84, 86, 83, 77, 80, 73, 65, 65, 65, 59, 64, 65, 68, 71, 72, 71, 69, 72, 80, 84, 87, 90, 91, 89, 90, 89, 87, 86, 85, 84, 82, 79, 74, 66, 63, 66, 64, 81, 86, 89, 91, 92, 93, 95, 96, 96, 96, 95, 94, 93, 92, 90, 87, 75, 75, 83, 83, 71, 78, 83, 86, 88, 88, 88, 88, 90, 90, 90, 89, 89, 88, 87, 86, 82, 77, 67, 75, 75, 78, 79, 81, 83, 84, 84, 83, 79, 79, 77, 78, 76, 74, 72, 69, 66, 61, 59, 62, 68, 70, 71, 70, 70, 69, 65, 67, 62, 65, 65, 66, 65, 64, 62, 60, 57, 53, 31, 47, 73, 77, 79, 80, 80, 81, 82, 78, 73, 75, 75, 74, 73, 72, 71, 68, 64, 60, 58, 61, 78, 83, 87, 89, 91, 92, 93, 93, 94, 94, 93, 93, 92, 91, 89, 87, 84, 80, 74, 69, 80, 85, 88, 89, 90, 90, 87, 87, 87, 87, 87, 85, 84, 82, 75, 67, 75, 77, 67, 66, 82, 86, 88, 89, 91, 91, 90, 89, 91, 91, 90, 89, 87, 86, 81, 74, 67, 74, 71, 65, 78, 82, 85, 87, 89, 90, 91, 86, 87, 83, 85, 84, 84, 82, 80, 76, 69, 55, 66, 67, 75, 81, 84, 85, 85, 85, 83, 82, 82, 84, 84, 85, 85, 85, 85, 84, 81, 79, 72, 59, 74, 79, 82, 85, 87, 87, 87, 87, 87, 86, 84, 84, 82, 81, 78, 75, 64, 60, 67, 64, 73, 75, 76, 76, 76, 78, 78, 77, 77, 76, 76, 75, 73, 71, 67, 65, 61, 53, 63, 61, 68, 70, 70, 70, 68, 66, 67, 69, 69, 68, 67, 68, 66, 65, 64, 60, 53, 53, 56, 51, 72, 76, 78, 78, 78, 77, 78, 79, 79, 79, 79, 77, 75, 74, 70, 67, 56, 58, 61, 62, 75, 79, 82, 83, 84, 84, 83, 83, 83, 83, 82, 81, 79, 77, 71, 55, 67, 69, 67, 55, 63, 71, 76, 79, 80, 80, 81, 81, 81, 81, 81, 81, 79, 78, 74, 73, 73, 66, 61, 52, 74, 79, 81, 81, 81, 82, 82, 83, 82, 82, 81, 81, 79, 77, 71, 62, 62, 71, 64, 59, 76, 80, 84, 86, 89, 90, 89, 89, 89, 88, 87, 85, 81, 74, 76, 82, 79, 66, 62, 64, 67, 67, 69, 73, 75, 74, 78, 81, 81, 80, 74, 79, 75, 70, 66, 68, 61, 66, 65, 52, 76, 79, 79, 77, 59, 66, 72, 73, 67, 73, 67, 70, 61, 54, 60, 64, 63, 51, 58, 55, 78, 79, 79, 81, 82, 80, 77, 82, 81, 80, 78, 76, 74, 68, 57, 65, 62, 58, 54, 52, 78, 81, 82, 82, 79, 80, 79, 76, 66, 66, 65, 61, 57, 57, 58, 50, 52, 39, 40, 30, 73, 74, 71, 68, 79, 81, 78, 77, 77, 79, 73, 70, 71, 68, 69, 67, 58, 61, 52, 39, 58, 54, 58, 63, 67, 63, 54, 58, 48, 54, 58, 57, 62, 60, 61, 59, 57, 48, 47, 26, 67, 71, 73, 74, 75, 75, 77, 76, 72, 72, 71, 67, 60, 68, 68, 63, 59, 64, 53, 50, 73, 76, 78, 78, 79, 79, 79, 79, 77, 76, 72, 64, 71, 74, 61, 70, 68, 68, 63, 58, 57, 63, 67, 69, 70, 69, 68, 65, 65, 64, 61, 60, 48, 62, 64, 39, 57, 58, 41, 47, 63, 65, 66, 66, 62, 60, 64, 63, 56, 63, 64, 62, 54, 60, 56, 56, 51, 46, 42, 32, 54, 58, 61, 64, 68, 69, 68, 68, 67, 65, 62, 51, 61, 65, 49, 62, 58, 56, 51, 46, 61, 63, 65, 65, 63, 62, 64, 61, 60, 59, 55, 50, 51, 54, 49, 50, 44, 43, 42, 28, 61, 62, 62, 62, 59, 55, 41, 49, 48, 44, 50, 50, 51, 37, 38, 35, 44, 36, 32, 22, 42, 47, 51, 51, 48, 39, 41, 38, 34, 43, 48, 35, 42, 44, 40, 34, 28, 35, 30, 21, 55, 54, 53, 59, 67, 69, 67, 62, 53, 60, 62, 60, 57, 56, 51, 54, 57, 43, 41, 11, 60, 62, 62, 60, 56, 62, 65, 63, 61, 66, 65, 47, 60, 49, 50, 45, 40, 38, 30, 20, 52, 54, 55, 54, 54, 54, 61, 67, 62, 68, 62, 62, 57, 50, 60, 54, 51, 43, 30, 30, 52, 54, 56, 58, 63, 64, 64, 59, 59, 56, 61, 61, 52, 60, 59, 57, 50, 42, 25, 34, 59, 63, 66, 67, 65, 61, 57, 44, 54, 53, 52, 53, 53, 51, 51, 48, 47, 50, 43, 39, 60, 62, 68, 70, 72, 74, 70, 70, 71, 69, 68, 68, 67, 65, 62, 58, 58, 50, 44, 42, 69, 73, 75, 76, 78, 79, 79, 78, 75, 73, 68, 67, 63, 58, 48, 43, 21, 36, 40, 43, 65, 69, 71, 71, 71, 72, 73, 73, 74, 74, 74, 73, 71, 69, 67, 65, 65, 62, 58, 56, 57, 59, 62, 64, 65, 64, 68, 71, 70, 71, 72, 71, 70, 68, 65, 62, 51, 53, 57, 55, 60, 62, 61, 57, 55, 60, 64, 65, 61, 62, 62, 61, 60, 59, 57, 55, 49, 45, 51, 52, 58, 61, 63, 66, 68, 69, 71, 71, 71, 71, 70, 69, 67, 64, 51, 60, 68, 66, 58, 59, 48, 52, 56, 60, 64, 63, 61, 60, 59, 59, 57, 55, 53, 53, 48, 41, 38, 27, 35, 37, 54, 56, 58, 57, 54, 53, 56, 54, 52, 48, 51, 51, 50, 47, 41, 41, 47, 48, 40, 42, 52, 53, 50, 42, 48, 52, 51, 51, 52, 54, 54, 53, 52, 51, 48, 46, 45, 45, 33, 34, 51, 53, 53, 55, 56, 57, 56, 55, 50, 46, 47, 49, 47, 47, 45, 44, 41, 38, 31, 21, 53, 56, 57, 57, 56, 52, 46, 33, 43, 41, 44, 47, 46, 45, 43, 41, 29, 20, 26, 26, 51, 52, 54, 56, 59, 59, 60, 60, 60, 61, 58, 60, 59, 58, 54, 51, 34, 32, 36, 41, 50, 54, 56, 57, 58, 58, 58, 58, 58, 59, 58, 57, 54, 50, 47, 49, 50, 48, 42, 39, 37, 42, 45, 46, 46, 45, 44, 44, 46, 46, 45, 44, 45, 44, 39, 36, 38, 28, 37, 36, 39, 42, 43, 44, 44, 43, 44, 45, 45, 45, 44, 44, 41, 37, 36, 39, 35, 39, 34, 29, 32, 33, 33, 30, 11, 20, 22, 21, 20, 25, 23, 20, 23, 10, 20, 11, 13, 18, 12, 9, 24, 23, 22, 22, 26, 28, 26, 25, 20, 23, 24, 22, 19, 17, 10, 18, 13, 20, 17, 7, 26, 30, 32, 34, 31, 27, 29, 32, 28, 27, 27, 13, 31, 30, 28, 21, 19, 26, 8, 12, 31, 33, 30, 19, 30, 13, 30, 29, 31, 26, 24, 25, 26, 23, 24, 23, 11, 22, 13, 0, 15, 25, 29, 29, 29, 30, 31, 29, 31, 30, 28, 27, 27, 23, 14, 24, 16, 12, 12, 13, 21, 23, 23, 23, 23, 24, 27, 22, 24, 23, 11, 23, 19, 15, 17, 11, 10, 22, 13, 13, 27, 27, 26, 26, 27, 25, 26, 27, 27, 24, 16, 16, 22, 21, 11, 21, 18, 23, 13, 19, 23, 24, 21, 17, 20, 17, 14, 18, 12, 14, 12, 20, 12, 1, 13, 10, 8, 7, 10, 9, 28, 31, 32, 31, 25, 26, 31, 27, 27, 20, 24, 22, 21, 15, 15, 18, 5, 6, 4, 4, 24, 21, 17, 18, 19, 20, 19, 20, 7, 7, 19, 7, 17, 16, 16, 15, 10, 7, 0, 9, 0, 9, 10, 8, 12, 11, 10, 16, 22, 17, 19, 14, 9, 17, 13, 8, 13, 4, 10, 0, 15, 19, 22, 23, 24, 23, 19, 20, 11, 12, 11, 14, 21, 15, 19, 6, 15, 12, 3, 1, 14, 19, 22, 21, 18, 20, 21, 19, 15, 12, 14, 15, 18, 12, 19, 13, 11, 0, 6, 11, 17, 17, 17, 17, 10, 9, 13, 8, 1, 11, 0, 13, 16, 10, 9, 0, 7, 7, 9, 0, 15, 12, 5, 0, 10, 12, 6, 9, 6, 11, 13, 13, 15, 0, 12, 11, 2, 2, 6, 10, 11, 10, 9, 1, 4, 9, 11, 11, 12, 7, 14, 12, 10, 11, 0, 11, 6, 3, 0, 9, 16, 14, 9, 0, 1, 8, 0, 1, 11, 0, 0, 5, 5, 9, 13, 16, 12, 13, 13, 9, 14, 14, 11, 3, 5, 5, 5, 7, 0, 10, 7, 7, 10, 12, 4, 3, 8, 6, 0, 6, 19, 16, 8, 12, 10, 9, 13, 9, 13, 17, 11, 13, 4, 0, 0, 12, 10, 3, 8, 5, 14, 17, 21, 22, 15, 16, 18, 16, 11, 12, 14, 9, 11, 8, 14, 7, 0, 9, 6, 0, 8, 7, 8, 8, 15, 16, 11, 8, 12, 6, 8, 4, 6, 3, 11, 0, 4, 7, 7, 0, 12, 9, 7, 7, 9, 12, 0, 10, 12, 3, 0, 10, 8, 8, 12, 1, 1, 7, 0, 2, 5, 4, 7, 5, 6, 9, 0, 1, 9, 0, 7, 9, 8, 0, 4, 6, 0, 0, 7, 11, 9, 1, 2, 3, 0, 7, 10, 8, 10, 11, 0, 0, 7, 6, 7, 5, 0, 4, 0, 0, 55, 63, 71, 75, 77, 73, 73, 45, 68, 65, 60, 60, 63, 64, 62, 62, 61, 58, 54, 54, 69, 71, 70, 77, 84, 85, 84, 82, 84, 82, 81, 80, 80, 78, 76, 73, 67, 59, 44, 50, 74, 81, 85, 87, 89, 90, 90, 90, 88, 84, 80, 77, 72, 66, 62, 54, 46, 33, 54, 59, 72, 79, 82, 84, 83, 83, 85, 86, 86, 86, 86, 86, 85, 84, 82, 80, 78, 74, 69, 63, 70, 71, 73, 76, 80, 79, 82, 84, 85, 85, 86, 86, 85, 84, 82, 79, 69, 64, 72, 68, 69, 75, 78, 77, 71, 73, 80, 81, 78, 78, 78, 77, 76, 76, 74, 73, 68, 63, 66, 67, 68, 74, 77, 79, 84, 86, 87, 87, 87, 86, 85, 85, 83, 80, 68, 72, 82, 80, 70, 71, 63, 67, 70, 73, 79, 81, 78, 78, 76, 76, 74, 70, 71, 70, 66, 59, 43, 49, 53, 54, 67, 72, 76, 77, 76, 75, 76, 75, 71, 69, 70, 69, 67, 64, 56, 56, 62, 64, 57, 61, 68, 73, 75, 73, 48, 70, 72, 72, 72, 73, 74, 74, 73, 72, 69, 66, 64, 65, 57, 52, 67, 72, 74, 74, 75, 77, 77, 75, 71, 66, 65, 68, 65, 67, 64, 62, 59, 57, 49, 40, 67, 73, 76, 77, 76, 73, 68, 62, 65, 59, 51, 61, 56, 52, 55, 50, 45, 43, 50, 53, 68, 72, 73, 75, 81, 83, 82, 82, 84, 85, 79, 85, 84, 82, 78, 77, 68, 60, 63, 58, 69, 74, 78, 81, 83, 83, 83, 83, 82, 83, 82, 80, 76, 67, 71, 69, 76, 70, 65, 62, 60, 62, 68, 72, 73, 73, 72, 71, 71, 70, 69, 68, 67, 64, 57, 59, 62, 61, 59, 60, 63, 68, 70, 72, 73, 73, 73, 73, 73, 73, 72, 70, 66, 57, 67, 69, 63, 66, 60, 52, 64, 67, 68, 68, 63, 56, 56, 57, 56, 58, 56, 54, 49, 41, 53, 52, 50, 42, 36, 40, 47, 50, 51, 42, 54, 56, 55, 55, 53, 51, 35, 39, 46, 50, 52, 37, 56, 49, 45, 45, 35, 51, 57, 57, 56, 55, 56, 58, 52, 52, 57, 59, 58, 54, 51, 49, 54, 50, 26, 44, 65, 70, 72, 73, 74, 74, 73, 72, 71, 70, 61, 66, 70, 63, 70, 68, 61, 66, 62, 55, 57, 62, 67, 69, 69, 70, 70, 71, 70, 68, 57, 62, 70, 62, 61, 65, 63, 53, 59, 47, 56, 56, 50, 49, 61, 65, 64, 64, 64, 62, 58, 55, 61, 54, 59, 56, 55, 34, 46, 46, 48, 55, 59, 61, 57, 57, 60, 63, 67, 64, 48, 63, 67, 55, 56, 60, 62, 59, 43, 47, 65, 67, 67, 66, 60, 60, 62, 64, 62, 61, 54, 49, 53, 60, 53, 49, 55, 55, 35, 49, 59, 46, 59, 62, 32, 62, 66, 63, 63, 63, 62, 60, 56, 45, 49, 41, 52, 46, 40, 24, 68, 72, 74, 74, 68, 52, 63, 68, 54, 54, 49, 35, 52, 47, 43, 49, 43, 25, 23, 20, 53, 54, 46, 55, 63, 65, 65, 65, 64, 64, 60, 60, 57, 50, 50, 56, 35, 46, 30, 26, 43, 53, 60, 62, 60, 58, 55, 54, 53, 50, 56, 48, 54, 51, 52, 46, 47, 48, 35, 37, 44, 47, 52, 56, 59, 60, 58, 55, 42, 48, 54, 29, 53, 54, 49, 48, 41, 41, 42, 33, 46, 49, 48, 42, 40, 45, 39, 40, 34, 46, 48, 42, 30, 43, 46, 42, 40, 34, 24, 23, 43, 40, 40, 46, 48, 45, 44, 46, 44, 40, 42, 39, 42, 42, 39, 36, 34, 24, 21, 13, 46, 50, 50, 49, 50, 51, 48, 50, 49, 52, 45, 49, 48, 49, 48, 45, 40, 33, 27, 26, 36, 38, 38, 38, 41, 41, 31, 29, 23, 21, 8, 30, 25, 20, 30, 29, 17, 20, 9, 13, 48, 52, 53, 52, 43, 39, 37, 30, 29, 37, 28, 23, 29, 28, 32, 26, 21, 26, 21, 20, 44, 45, 47, 48, 40, 37, 38, 34, 42, 37, 24, 32, 29, 38, 33, 30, 22, 22, 7, 11, 48, 49, 52, 56, 58, 55, 53, 49, 51, 45, 52, 51, 48, 45, 39, 45, 47, 38, 35, 19, 49, 53, 55, 55, 50, 50, 42, 38, 42, 46, 47, 37, 35, 40, 32, 31, 7, 21, 16, 14, 40, 44, 46, 48, 47, 49, 46, 47, 45, 44, 48, 39, 43, 43, 39, 38, 27, 25, 24, 17, 31, 38, 42, 43, 38, 45, 48, 40, 37, 28, 43, 22, 33, 39, 32, 3, 20, 27, 7, 9, 25, 33, 37, 37, 28, 39, 39, 36, 22, 28, 36, 16, 32, 31, 30, 16, 10, 18, 11, 10, 69, 73, 78, 82, 86, 84, 79, 61, 73, 61, 64, 53, 67, 67, 66, 67, 65, 64, 61, 57, 78, 82, 82, 84, 90, 92, 89, 86, 89, 88, 86, 86, 85, 84, 81, 79, 73, 66, 35, 56, 79, 85, 89, 91, 94, 95, 95, 93, 92, 87, 83, 81, 76, 70, 67, 61, 52, 29, 58, 63, 75, 82, 86, 87, 88, 89, 90, 91, 91, 91, 92, 92, 91, 90, 89, 88, 84, 81, 73, 67, 76, 78, 77, 77, 83, 85, 87, 89, 89, 89, 91, 90, 89, 88, 86, 83, 74, 71, 76, 73, 75, 80, 83, 84, 76, 78, 84, 86, 82, 80, 80, 80, 80, 79, 78, 76, 73, 68, 70, 72, 72, 78, 82, 84, 89, 92, 93, 93, 93, 92, 91, 91, 89, 86, 74, 78, 87, 86, 76, 76, 66, 70, 74, 78, 85, 87, 85, 85, 83, 84, 82, 80, 80, 76, 71, 66, 55, 53, 60, 62, 71, 78, 81, 83, 83, 82, 82, 81, 77, 78, 76, 76, 74, 70, 62, 63, 69, 70, 63, 66, 74, 79, 82, 81, 71, 75, 79, 78, 80, 81, 83, 83, 82, 81, 79, 75, 71, 70, 61, 58, 73, 78, 80, 81, 82, 84, 84, 83, 80, 78, 77, 80, 77, 78, 75, 75, 69, 67, 57, 53, 71, 78, 82, 83, 81, 79, 71, 58, 59, 66, 66, 67, 59, 61, 57, 49, 50, 51, 58, 59, 73, 77, 77, 78, 87, 90, 86, 86, 91, 92, 84, 91, 89, 87, 82, 82, 74, 63, 67, 65, 73, 79, 84, 87, 90, 90, 90, 89, 90, 89, 88, 87, 82, 72, 78, 75, 83, 77, 69, 66, 65, 68, 74, 78, 81, 81, 80, 80, 80, 79, 80, 79, 77, 74, 68, 69, 70, 70, 66, 68, 70, 76, 79, 80, 81, 81, 81, 82, 82, 82, 81, 80, 75, 65, 75, 77, 70, 75, 69, 63, 73, 76, 77, 77, 71, 65, 65, 64, 65, 65, 63, 61, 54, 51, 58, 56, 57, 51, 41, 46, 60, 61, 58, 52, 54, 61, 58, 61, 57, 49, 56, 56, 61, 60, 58, 38, 64, 53, 51, 51, 59, 55, 61, 63, 65, 67, 67, 68, 64, 68, 69, 68, 71, 67, 42, 52, 64, 63, 47, 56, 73, 78, 80, 81, 81, 82, 80, 80, 78, 77, 68, 72, 76, 71, 77, 74, 68, 72, 68, 61, 62, 70, 75, 78, 79, 78, 78, 79, 80, 78, 72, 68, 79, 74, 71, 75, 71, 59, 67, 56, 67, 68, 64, 59, 72, 74, 74, 73, 71, 71, 67, 67, 71, 64, 66, 64, 61, 53, 55, 52, 43, 65, 71, 74, 71, 69, 75, 76, 78, 76, 63, 70, 75, 49, 67, 68, 71, 68, 41, 55, 77, 79, 80, 78, 72, 71, 76, 77, 75, 73, 64, 65, 65, 72, 60, 59, 67, 67, 48, 60, 75, 68, 66, 73, 65, 72, 76, 73, 73, 71, 73, 70, 66, 50, 58, 51, 61, 55, 48, 32, 80, 85, 87, 88, 83, 68, 77, 81, 58, 66, 58, 50, 65, 59, 53, 58, 52, 44, 25, 26, 66, 69, 66, 55, 74, 77, 77, 77, 75, 74, 71, 72, 63, 63, 57, 62, 51, 57, 41, 43, 50, 60, 71, 74, 73, 70, 69, 68, 63, 57, 70, 63, 67, 59, 66, 58, 60, 59, 40, 48, 57, 57, 64, 70, 73, 73, 71, 65, 58, 62, 67, 60, 64, 67, 61, 59, 46, 54, 53, 39, 61, 65, 66, 63, 47, 61, 60, 62, 57, 52, 66, 56, 58, 62, 62, 51, 58, 41, 21, 31, 53, 48, 59, 64, 66, 62, 57, 62, 58, 54, 60, 54, 56, 56, 57, 54, 47, 40, 23, 24, 62, 65, 65, 64, 66, 66, 62, 62, 58, 64, 53, 65, 61, 64, 62, 59, 50, 39, 41, 41, 50, 52, 49, 41, 53, 54, 52, 47, 22, 34, 43, 47, 38, 41, 41, 42, 34, 39, 30, 18, 63, 67, 69, 68, 61, 51, 53, 50, 54, 51, 46, 46, 47, 50, 45, 41, 35, 38, 32, 18, 58, 62, 64, 65, 58, 53, 54, 50, 57, 54, 44, 43, 46, 53, 51, 36, 34, 24, 25, 28, 51, 59, 70, 75, 76, 72, 69, 59, 70, 59, 70, 66, 63, 64, 61, 58, 60, 48, 48, 33, 58, 65, 66, 61, 68, 70, 62, 70, 55, 67, 65, 63, 62, 57, 47, 45, 39, 35, 23, 20, 58, 64, 67, 67, 64, 66, 62, 63, 65, 64, 66, 59, 61, 58, 55, 56, 43, 43, 34, 12, 47, 49, 58, 61, 55, 60, 65, 57, 50, 50, 60, 58, 50, 55, 52, 48, 37, 44, 24, 22, 43, 50, 54, 53, 41, 54, 57, 56, 33, 51, 56, 50, 53, 51, 47, 33, 28, 33, 26, 22, 62, 67, 71, 73, 73, 73, 76, 76, 77, 78, 78, 77, 72, 62, 56, 48, 40, 43, 46, 45, 69, 70, 71, 71, 71, 70, 71, 68, 69, 70, 69, 67, 64, 60, 48, 50, 57, 56, 42, 37, 66, 70, 72, 73, 73, 72, 74, 74, 73, 72, 70, 69, 67, 66, 61, 56, 58, 61, 60, 50, 66, 70, 71, 71, 67, 56, 63, 67, 58, 54, 61, 58, 58, 58, 58, 57, 53, 50, 50, 46, 68, 71, 71, 68, 68, 66, 66, 65, 68, 68, 68, 67, 66, 65, 62, 59, 55, 48, 46, 48, 56, 53, 55, 65, 71, 73, 73, 70, 71, 69, 68, 66, 63, 60, 48, 52, 59, 59, 50, 43, 53, 56, 59, 62, 63, 64, 64, 64, 63, 63, 62, 62, 61, 60, 58, 56, 51, 43, 36, 33, 38, 37, 38, 41, 45, 42, 42, 43, 44, 44, 43, 38, 27, 26, 38, 39, 35, 30, 26, 23, 50, 53, 53, 53, 53, 52, 53, 51, 49, 49, 48, 45, 41, 34, 23, 36, 40, 38, 31, 25, 55, 56, 57, 57, 56, 55, 54, 54, 53, 52, 51, 51, 49, 47, 42, 33, 34, 30, 34, 33, 48, 50, 53, 55, 56, 52, 54, 53, 51, 50, 47, 41, 40, 47, 49, 45, 42, 45, 37, 37, 44, 46, 44, 39, 34, 42, 33, 40, 34, 32, 20, 25, 30, 33, 35, 33, 30, 30, 17, 18, 36, 38, 37, 36, 34, 31, 31, 33, 29, 27, 26, 31, 38, 41, 40, 37, 35, 31, 13, 31, 33, 37, 38, 39, 41, 40, 40, 40, 40, 38, 35, 30, 20, 33, 33, 21, 28, 15, 4, 21, 26, 30, 32, 33, 32, 33, 31, 31, 30, 31, 29, 24, 22, 25, 24, 19, 12, 21, 18, 17, 20, 23, 23, 16, 26, 32, 30, 26, 27, 25, 21, 19, 19, 17, 23, 25, 9, 24, 10, 8, 19, 17, 20, 20, 21, 22, 20, 18, 18, 21, 19, 22, 18, 9, 19, 17, 16, 19, 15, 0, 26, 27, 27, 28, 27, 28, 16, 26, 21, 19, 17, 14, 22, 23, 22, 23, 0, 13, 17, 12, 27, 25, 24, 23, 26, 19, 18, 21, 18, 26, 27, 29, 23, 16, 18, 15, 24, 19, 18, 6, 33, 33, 34, 34, 31, 26, 30, 28, 26, 23, 25, 26, 28, 28, 25, 22, 17, 17, 9, 11, 28, 32, 34, 34, 33, 25, 24, 29, 29, 28, 25, 20, 29, 34, 33, 27, 29, 25, 22, 17, 25, 25, 23, 18, 16, 27, 30, 24, 28, 22, 0, 20, 24, 9, 27, 14, 22, 20, 13, 12, 16, 18, 20, 22, 21, 16, 14, 14, 11, 17, 18, 16, 11, 20, 12, 14, 11, 16, 8, 7, 29, 30, 29, 27, 15, 15, 14, 11, 17, 18, 15, 3, 15, 12, 14, 9, 0, 2, 0, 12, 27, 24, 17, 12, 11, 1, 18, 11, 16, 10, 13, 8, 13, 6, 7, 8, 2, 9, 9, 9, 20, 19, 17, 12, 18, 22, 13, 10, 18, 10, 10, 9, 12, 9, 8, 8, 10, 6, 7, 9, 24, 23, 17, 6, 18, 24, 12, 17, 7, 15, 17, 0, 8, 4, 13, 15, 11, 9, 1, 1, 23, 23, 20, 12, 9, 19, 7, 4, 15, 16, 16, 16, 13, 18, 12, 8, 8, 10, 8, 12, 19, 20, 16, 8, 17, 15, 11, 11, 12, 12, 19, 11, 17, 11, 9, 6, 10, 1, 12, 0, 20, 19, 13, 3, 9, 14, 19, 19, 18, 21, 21, 17, 22, 13, 7, 13, 11, 9, 10, 14, 18, 18, 18, 19, 16, 17, 19, 19, 16, 22, 18, 17, 16, 7, 17, 5, 9, 8, 14, 11, 25, 26, 24, 21, 16, 14, 18, 10, 7, 0, 11, 17, 12, 0, 12, 4, 0, 3, 7, 0, 17, 22, 21, 15, 3, 19, 7, 12, 8, 7, 2, 0, 0, 14, 7, 11, 10, 8, 4, 11, 19, 15, 13, 7, 9, 9, 10, 7, 6, 14, 6, 3, 0, 5, 7, 0, 7, 7, 8, 6, 22, 21, 19, 17, 11, 4, 11, 12, 0, 9, 8, 8, 7, 0, 7, 8, 0, 2, 9, 5, 20, 25, 27, 26, 18, 13, 10, 14, 18, 19, 18, 12, 15, 18, 15, 16, 14, 18, 18, 14, 0, 8, 11, 7, 11, 0, 12, 9, 6, 9, 11, 7, 0, 7, 0, 5, 0, 0, 0, 2, 17, 20, 22, 21, 4, 11, 9, 0, 10, 0, 10, 10, 0, 9, 11, 3, 4, 2, 2, 7, 6, 0, 7, 13, 11, 1, 5, 6, 4, 11, 15, 2, 1, 2, 1, 5, 5, 4, 2, 4, 12, 13, 10, 8, 11, 8, 5, 14, 4, 5, 9, 15, 9, 9, 7, 9, 11, 5, 11, 12, 66, 72, 76, 79, 84, 84, 85, 86, 88, 89, 88, 87, 81, 76, 69, 59, 48, 45, 43, 46, 69, 78, 81, 83, 83, 82, 84, 83, 83, 85, 83, 82, 80, 77, 66, 65, 74, 73, 54, 55, 73, 76, 80, 83, 85, 85, 85, 86, 84, 83, 81, 79, 78, 77, 73, 67, 66, 71, 72, 66, 65, 75, 80, 82, 82, 77, 71, 78, 74, 73, 77, 76, 74, 73, 71, 68, 63, 60, 60, 59, 70, 78, 83, 84, 81, 80, 77, 78, 80, 81, 81, 80, 79, 77, 75, 72, 68, 64, 59, 58, 68, 73, 72, 60, 83, 87, 88, 86, 86, 84, 82, 81, 79, 76, 68, 55, 71, 73, 66, 60, 61, 69, 73, 76, 81, 82, 82, 82, 82, 80, 80, 80, 79, 77, 75, 74, 69, 63, 49, 53, 61, 62, 59, 59, 63, 64, 63, 66, 63, 62, 59, 57, 52, 42, 56, 57, 52, 47, 43, 45, 62, 71, 75, 77, 76, 76, 75, 73, 70, 71, 70, 68, 65, 60, 41, 51, 58, 58, 49, 45, 69, 77, 80, 81, 82, 80, 79, 79, 77, 76, 75, 74, 71, 69, 64, 61, 54, 44, 48, 50, 68, 73, 75, 78, 82, 81, 80, 79, 78, 78, 77, 73, 64, 61, 70, 68, 53, 67, 55, 52, 66, 72, 73, 71, 65, 66, 68, 70, 66, 61, 58, 50, 38, 53, 56, 54, 44, 48, 28, 33, 62, 68, 74, 77, 78, 77, 77, 78, 76, 76, 74, 72, 65, 58, 50, 66, 69, 65, 62, 45, 60, 68, 74, 76, 78, 79, 80, 79, 79, 79, 77, 76, 72, 69, 68, 67, 62, 64, 59, 48, 52, 49, 62, 67, 69, 70, 69, 70, 71, 70, 69, 68, 64, 60, 53, 47, 59, 60, 52, 44, 55, 60, 63, 65, 65, 64, 63, 64, 64, 63, 61, 58, 38, 53, 56, 58, 46, 54, 47, 36, 42, 44, 48, 52, 54, 57, 59, 58, 58, 56, 54, 52, 43, 39, 45, 49, 47, 38, 37, 26, 47, 49, 50, 48, 48, 46, 22, 48, 41, 49, 48, 49, 43, 36, 43, 48, 28, 27, 27, 0, 53, 55, 53, 49, 47, 52, 50, 52, 54, 53, 52, 53, 47, 30, 39, 36, 36, 38, 34, 24, 48, 56, 59, 62, 60, 58, 57, 57, 56, 54, 49, 43, 47, 53, 49, 49, 46, 37, 33, 30, 54, 60, 63, 64, 66, 66, 67, 67, 66, 65, 61, 54, 38, 56, 63, 61, 51, 57, 52, 46, 36, 40, 53, 58, 61, 62, 61, 59, 60, 62, 63, 61, 53, 55, 50, 43, 49, 50, 44, 36, 39, 44, 52, 55, 55, 57, 55, 56, 49, 48, 43, 44, 43, 47, 44, 50, 35, 23, 36, 28, 43, 45, 46, 49, 45, 44, 29, 34, 39, 29, 32, 34, 33, 36, 36, 31, 24, 11, 3, 11, 45, 49, 50, 48, 48, 46, 43, 43, 41, 39, 38, 31, 34, 36, 36, 32, 33, 23, 13, 13, 40, 43, 43, 39, 35, 25, 36, 40, 35, 26, 25, 24, 24, 31, 33, 25, 29, 18, 13, 15, 38, 40, 36, 24, 41, 45, 46, 39, 46, 35, 34, 35, 32, 33, 42, 35, 26, 17, 14, 12, 38, 41, 41, 39, 32, 31, 26, 34, 39, 32, 31, 29, 36, 43, 35, 37, 24, 12, 15, 9, 21, 21, 29, 31, 27, 27, 25, 26, 27, 9, 20, 22, 32, 31, 29, 27, 13, 16, 10, 3, 38, 40, 40, 39, 39, 35, 36, 35, 36, 37, 37, 30, 42, 40, 31, 32, 16, 21, 21, 10, 41, 43, 41, 41, 40, 34, 39, 39, 40, 38, 25, 42, 40, 40, 34, 36, 32, 21, 11, 7, 34, 33, 33, 38, 40, 41, 37, 40, 34, 33, 30, 30, 39, 30, 26, 19, 17, 18, 11, 5, 34, 35, 31, 27, 26, 31, 20, 22, 10, 20, 18, 13, 12, 8, 9, 9, 6, 2, 7, 6, 42, 47, 47, 44, 26, 36, 37, 32, 27, 20, 34, 20, 20, 22, 24, 20, 3, 10, 1, 4, 43, 48, 49, 46, 28, 36, 36, 33, 39, 39, 32, 34, 29, 25, 21, 20, 12, 12, 11, 8, 35, 39, 40, 38, 35, 36, 33, 30, 19, 31, 31, 31, 21, 26, 18, 20, 3, 6, 6, 9, 29, 24, 14, 14, 19, 26, 26, 19, 16, 23, 22, 18, 22, 14, 17, 9, 5, 9, 11, 2, 20, 22, 19, 23, 29, 31, 32, 29, 23, 30, 32, 24, 25, 19, 19, 23, 17, 14, 12, 6, 25, 24, 26, 28, 31, 31, 31, 31, 28, 35, 38, 36, 24, 35, 31, 22, 7, 12, 10, 0, 25, 28, 28, 27, 21, 20, 20, 17, 7, 22, 19, 20, 4, 17, 13, 8, 13, 4, 7, 7, 68, 74, 80, 85, 90, 91, 92, 94, 96, 95, 95, 94, 87, 82, 76, 68, 57, 40, 48, 41, 80, 87, 89, 90, 90, 91, 94, 92, 92, 93, 91, 90, 88, 85, 74, 71, 82, 81, 62, 63, 82, 85, 88, 91, 93, 93, 93, 94, 92, 90, 88, 87, 86, 85, 80, 73, 75, 80, 79, 70, 75, 84, 89, 91, 89, 85, 80, 85, 77, 78, 79, 76, 75, 75, 74, 72, 70, 68, 67, 66, 78, 86, 90, 92, 88, 87, 84, 85, 89, 88, 88, 88, 86, 85, 82, 79, 73, 69, 66, 66, 77, 81, 80, 65, 91, 96, 97, 95, 95, 94, 92, 90, 88, 85, 75, 68, 81, 81, 71, 67, 70, 78, 82, 85, 90, 91, 91, 90, 89, 89, 88, 88, 86, 84, 82, 81, 77, 69, 59, 56, 70, 72, 69, 70, 72, 75, 75, 78, 75, 75, 72, 69, 61, 49, 67, 68, 62, 57, 47, 51, 75, 83, 86, 87, 87, 87, 86, 85, 83, 82, 80, 78, 74, 69, 46, 62, 68, 67, 57, 51, 80, 88, 92, 93, 94, 92, 91, 91, 90, 89, 88, 87, 84, 81, 77, 73, 57, 64, 64, 63, 79, 84, 87, 91, 95, 93, 92, 90, 90, 90, 89, 86, 77, 70, 81, 80, 71, 79, 68, 66, 77, 82, 83, 81, 77, 77, 78, 78, 76, 74, 73, 69, 58, 58, 65, 68, 60, 61, 53, 36, 74, 79, 85, 88, 89, 88, 89, 89, 89, 89, 86, 85, 79, 72, 64, 79, 81, 72, 73, 64, 74, 82, 87, 90, 92, 93, 93, 92, 92, 92, 90, 89, 85, 82, 81, 80, 77, 77, 70, 61, 71, 70, 77, 81, 82, 83, 83, 84, 84, 82, 81, 79, 76, 73, 67, 67, 74, 73, 52, 63, 72, 77, 80, 81, 81, 80, 78, 80, 79, 78, 76, 74, 57, 67, 71, 71, 47, 67, 61, 53, 58, 60, 64, 65, 65, 70, 72, 72, 71, 70, 67, 66, 58, 54, 60, 64, 57, 47, 45, 42, 66, 66, 65, 60, 59, 63, 56, 63, 57, 66, 66, 69, 65, 53, 64, 68, 50, 50, 48, 33, 69, 73, 72, 70, 72, 73, 70, 73, 74, 74, 76, 75, 69, 60, 61, 58, 60, 61, 50, 48, 71, 75, 76, 77, 75, 72, 70, 70, 70, 70, 66, 62, 62, 67, 61, 61, 55, 53, 50, 43, 69, 78, 82, 83, 84, 84, 85, 84, 84, 83, 79, 73, 61, 73, 80, 77, 72, 70, 65, 59, 68, 70, 75, 79, 82, 82, 81, 75, 76, 79, 81, 81, 74, 74, 73, 59, 71, 70, 58, 43, 51, 68, 76, 80, 81, 81, 79, 79, 74, 70, 61, 67, 63, 68, 65, 70, 56, 49, 54, 44, 72, 78, 79, 79, 79, 77, 70, 66, 64, 61, 61, 61, 55, 60, 62, 57, 53, 41, 38, 33, 68, 69, 67, 67, 69, 70, 70, 70, 66, 61, 61, 59, 58, 57, 56, 51, 48, 42, 32, 22, 63, 66, 65, 62, 50, 48, 63, 51, 54, 54, 44, 43, 45, 42, 49, 37, 45, 44, 35, 28, 62, 65, 66, 68, 71, 71, 68, 55, 68, 59, 63, 60, 42, 59, 57, 55, 45, 49, 35, 16, 63, 66, 65, 58, 53, 58, 65, 68, 67, 66, 60, 53, 61, 66, 54, 60, 52, 45, 15, 25, 55, 58, 62, 63, 60, 60, 62, 65, 68, 68, 64, 47, 54, 54, 62, 54, 38, 41, 33, 26, 60, 61, 60, 57, 57, 60, 68, 71, 72, 71, 64, 62, 67, 70, 62, 59, 58, 35, 49, 37, 63, 66, 67, 67, 66, 66, 67, 67, 65, 63, 60, 63, 65, 62, 58, 57, 54, 48, 32, 34, 53, 57, 62, 65, 67, 67, 63, 62, 54, 47, 52, 55, 59, 59, 53, 43, 43, 36, 37, 31, 41, 41, 49, 47, 47, 46, 48, 46, 45, 37, 30, 35, 38, 37, 37, 34, 26, 23, 16, 7, 54, 59, 59, 56, 56, 60, 50, 53, 54, 55, 50, 50, 51, 47, 50, 29, 27, 25, 15, 14, 56, 59, 61, 59, 57, 43, 55, 58, 61, 58, 55, 50, 55, 52, 42, 35, 32, 26, 11, 11, 53, 59, 60, 59, 53, 60, 64, 58, 60, 39, 46, 57, 54, 51, 48, 46, 38, 37, 15, 17, 45, 40, 38, 34, 45, 49, 48, 43, 43, 46, 46, 29, 38, 31, 33, 28, 16, 16, 16, 6, 49, 51, 52, 53, 54, 56, 52, 40, 41, 47, 49, 41, 42, 42, 19, 37, 37, 28, 18, 2, 45, 48, 49, 49, 46, 51, 50, 41, 39, 47, 53, 49, 40, 47, 40, 31, 29, 26, 16, 9, 36, 40, 41, 39, 40, 37, 36, 39, 43, 41, 39, 36, 41, 22, 32, 30, 24, 5, 4, 0, 63, 70, 73, 74, 78, 80, 78, 76, 75, 78, 75, 73, 73, 73, 71, 70, 67, 65, 63, 57, 72, 74, 71, 60, 45, 51, 66, 64, 69, 66, 65, 65, 66, 65, 64, 62, 56, 52, 50, 47, 66, 68, 66, 61, 59, 64, 70, 66, 71, 70, 70, 70, 69, 68, 65, 63, 60, 53, 42, 53, 62, 66, 67, 66, 68, 68, 68, 69, 69, 69, 69, 68, 67, 66, 63, 59, 38, 55, 56, 51, 51, 51, 53, 60, 65, 66, 64, 64, 64, 63, 63, 62, 60, 59, 53, 44, 45, 47, 42, 50, 51, 49, 44, 39, 51, 56, 56, 53, 49, 46, 45, 47, 40, 30, 33, 37, 42, 39, 44, 43, 50, 50, 53, 56, 59, 57, 60, 58, 56, 56, 56, 54, 50, 44, 36, 46, 46, 38, 50, 43, 49, 51, 48, 45, 48, 45, 46, 48, 47, 46, 46, 44, 41, 39, 32, 33, 28, 30, 32, 33, 40, 42, 42, 44, 45, 46, 45, 45, 43, 42, 42, 39, 36, 31, 30, 34, 26, 31, 34, 28, 31, 37, 41, 43, 46, 46, 47, 46, 44, 43, 40, 33, 27, 36, 40, 38, 18, 38, 32, 19, 31, 31, 32, 32, 33, 33, 28, 30, 30, 30, 31, 27, 27, 31, 33, 21, 23, 24, 9, 18, 30, 24, 18, 15, 10, 25, 28, 30, 26, 20, 26, 26, 17, 13, 16, 13, 16, 21, 21, 8, 32, 35, 35, 35, 35, 34, 34, 32, 33, 29, 27, 18, 19, 12, 7, 27, 23, 23, 23, 20, 25, 21, 20, 22, 21, 17, 24, 24, 23, 23, 23, 14, 22, 24, 15, 14, 15, 19, 0, 5, 25, 21, 14, 5, 19, 20, 15, 22, 14, 20, 12, 23, 25, 24, 22, 9, 17, 12, 14, 14, 10, 15, 15, 20, 21, 19, 20, 13, 19, 19, 10, 21, 16, 3, 17, 13, 10, 0, 16, 17, 20, 17, 16, 10, 12, 24, 16, 15, 9, 9, 8, 10, 3, 13, 3, 4, 5, 5, 12, 7, 21, 16, 12, 21, 19, 17, 20, 16, 18, 20, 14, 9, 13, 4, 13, 0, 16, 0, 9, 9, 16, 22, 26, 26, 21, 23, 25, 24, 24, 25, 22, 23, 15, 14, 15, 14, 18, 13, 8, 7, 8, 14, 13, 13, 10, 16, 15, 13, 16, 13, 8, 6, 11, 16, 7, 5, 9, 7, 6, 8, 20, 18, 18, 17, 21, 15, 19, 13, 18, 15, 15, 16, 19, 23, 10, 4, 11, 10, 6, 2, 25, 25, 26, 27, 26, 26, 27, 27, 24, 25, 21, 18, 12, 20, 14, 13, 10, 17, 8, 6, 7, 15, 14, 12, 10, 7, 14, 12, 15, 6, 8, 14, 0, 7, 0, 0, 5, 6, 1, 6, 15, 0, 4, 8, 11, 3, 8, 12, 17, 14, 7, 14, 2, 8, 9, 0, 10, 0, 9, 11, 19, 14, 1, 3, 2, 0, 10, 3, 15, 16, 2, 12, 12, 8, 10, 9, 14, 7, 16, 2, 18, 7, 11, 15, 15, 11, 2, 10, 16, 11, 9, 0, 8, 0, 8, 5, 11, 7, 10, 14, 4, 9, 6, 4, 10, 9, 4, 9, 5, 11, 16, 10, 4, 7, 5, 0, 12, 7, 11, 8, 18, 14, 10, 11, 10, 12, 14, 8, 0, 0, 14, 4, 0, 10, 8, 9, 4, 0, 8, 10, 18, 16, 16, 16, 18, 18, 13, 15, 17, 8, 20, 18, 20, 15, 20, 14, 15, 16, 17, 17, 8, 11, 0, 12, 3, 0, 7, 9, 10, 0, 1, 4, 15, 12, 9, 11, 0, 8, 0, 6, 12, 1, 8, 12, 11, 13, 13, 0, 6, 2, 12, 5, 6, 13, 0, 12, 0, 12, 11, 1, 12, 12, 3, 12, 6, 16, 12, 12, 4, 8, 0, 7, 11, 11, 0, 0, 0, 6, 8, 13, 10, 13, 14, 7, 0, 3, 10, 0, 10, 0, 0, 12, 13, 14, 0, 6, 5, 12, 11, 11, 10, 7, 9, 9, 12, 12, 6, 10, 14, 9, 11, 12, 5, 3, 0, 9, 9, 6, 0, 0, 8, 9, 10, 10, 1, 8, 0, 9, 2, 0, 1, 9, 10, 13, 5, 13, 5, 14, 10, 11, 15, 15, 13, 14, 13, 17, 12, 3, 6, 10, 6, 9, 4, 8, 5, 0, 0, 6, 3, 10, 12, 8, 7, 7, 0, 0, 6, 7, 0, 12, 11, 5, 6, 11, 6, 1, 11, 6, 6, 4, 0, 15, 15, 15, 16, 16, 16, 14, 10, 15, 12, 6, 5, 4, 10, 12, 7, 5, 0, 10, 2, 2, 13, 17, 1, 9, 11, 11, 10, 0, 1, 9, 1, 7, 7, 9, 10, 12, 8, 7, 16, 11, 9, 8, 0, 6, 3, 0, 0, 12, 3, 4, 5, 5, 4, 4, 4, 9, 9, 10, 55, 68, 77, 82, 84, 89, 88, 87, 84, 87, 84, 84, 83, 82, 81, 79, 76, 74, 69, 63, 68, 79, 85, 85, 72, 65, 75, 79, 79, 78, 76, 77, 77, 76, 75, 72, 67, 62, 59, 59, 64, 75, 80, 80, 66, 71, 81, 76, 82, 80, 80, 80, 79, 78, 76, 74, 71, 66, 54, 64, 64, 72, 77, 78, 79, 79, 81, 81, 81, 81, 81, 80, 79, 77, 75, 71, 50, 65, 67, 60, 54, 61, 63, 65, 75, 78, 77, 77, 77, 77, 77, 76, 75, 74, 70, 64, 50, 61, 55, 62, 61, 66, 66, 64, 60, 69, 72, 68, 67, 69, 70, 68, 65, 62, 53, 33, 53, 52, 55, 56, 58, 67, 68, 70, 77, 78, 79, 79, 76, 76, 76, 75, 73, 69, 58, 61, 64, 58, 65, 59, 63, 68, 70, 70, 66, 69, 66, 68, 68, 67, 66, 64, 61, 58, 50, 49, 42, 46, 50, 52, 48, 60, 65, 67, 69, 68, 69, 69, 67, 65, 65, 64, 61, 57, 49, 55, 52, 52, 57, 49, 51, 44, 60, 66, 71, 74, 74, 76, 74, 73, 70, 67, 60, 52, 61, 63, 55, 60, 58, 46, 44, 51, 58, 61, 62, 64, 62, 62, 61, 62, 63, 62, 56, 47, 59, 56, 56, 50, 41, 37, 51, 52, 41, 52, 57, 57, 59, 60, 55, 56, 53, 53, 48, 43, 38, 31, 39, 45, 41, 24, 54, 62, 64, 65, 64, 64, 64, 64, 64, 62, 60, 57, 48, 39, 49, 47, 52, 47, 42, 40, 54, 59, 62, 62, 63, 61, 60, 57, 55, 53, 50, 48, 40, 45, 48, 40, 52, 41, 42, 20, 50, 56, 63, 64, 64, 63, 59, 60, 63, 63, 58, 56, 48, 47, 51, 49, 49, 41, 39, 34, 53, 58, 62, 62, 61, 60, 60, 61, 59, 59, 58, 55, 46, 36, 42, 50, 51, 37, 39, 26, 40, 50, 55, 55, 49, 58, 60, 54, 50, 43, 38, 45, 34, 37, 38, 36, 37, 20, 26, 9, 42, 47, 38, 47, 49, 46, 51, 49, 48, 42, 41, 42, 39, 33, 42, 35, 39, 30, 25, 23, 41, 49, 51, 51, 53, 53, 51, 52, 50, 47, 44, 45, 49, 50, 41, 37, 45, 39, 37, 27, 41, 47, 46, 42, 44, 41, 36, 32, 26, 27, 29, 30, 26, 29, 16, 36, 25, 17, 23, 19, 36, 47, 47, 47, 48, 48, 46, 45, 45, 43, 37, 41, 46, 45, 35, 45, 36, 35, 31, 19, 39, 50, 55, 57, 58, 58, 57, 56, 54, 52, 48, 51, 53, 48, 50, 46, 46, 39, 38, 29, 37, 43, 44, 43, 40, 39, 35, 34, 30, 36, 36, 35, 32, 35, 35, 40, 15, 25, 17, 16, 29, 36, 37, 37, 37, 36, 31, 29, 29, 26, 22, 27, 29, 25, 27, 25, 19, 21, 12, 5, 26, 30, 29, 21, 23, 18, 21, 30, 23, 23, 20, 19, 23, 19, 18, 21, 8, 4, 10, 14, 24, 25, 29, 32, 29, 21, 31, 30, 31, 30, 13, 16, 25, 19, 28, 22, 3, 14, 7, 5, 8, 24, 26, 22, 32, 33, 34, 30, 14, 19, 15, 24, 25, 22, 29, 29, 17, 17, 9, 9, 12, 10, 27, 31, 27, 27, 28, 27, 27, 26, 25, 21, 18, 0, 12, 13, 0, 3, 2, 9, 20, 23, 24, 27, 33, 29, 29, 27, 27, 30, 25, 29, 21, 20, 24, 20, 19, 18, 16, 13, 21, 22, 18, 18, 24, 18, 20, 26, 28, 29, 30, 27, 28, 34, 26, 25, 21, 0, 9, 9, 18, 16, 21, 24, 28, 31, 29, 29, 26, 29, 32, 30, 23, 26, 29, 24, 17, 16, 8, 4, 20, 30, 32, 26, 33, 33, 22, 9, 18, 23, 14, 26, 26, 23, 24, 22, 12, 13, 3, 6, 16, 25, 29, 29, 25, 26, 25, 21, 8, 7, 17, 14, 4, 0, 9, 0, 0, 1, 10, 2, 17, 14, 6, 13, 13, 14, 10, 13, 8, 14, 7, 0, 14, 19, 0, 6, 1, 8, 5, 8, 10, 5, 17, 21, 15, 21, 18, 21, 14, 17, 13, 20, 19, 15, 5, 15, 1, 0, 11, 13, 16, 24, 23, 21, 21, 20, 24, 21, 20, 21, 15, 13, 19, 16, 15, 17, 12, 10, 8, 0, 12, 22, 28, 30, 30, 29, 26, 22, 24, 24, 25, 22, 15, 22, 17, 16, 16, 11, 10, 4, 6, 7, 13, 17, 15, 15, 11, 13, 18, 17, 22, 18, 11, 18, 13, 11, 7, 0, 2, 4, 0, 22, 26, 25, 17, 22, 23, 23, 24, 22, 19, 20, 11, 10, 3, 12, 13, 7, 13, 0, 16, 0, 19, 21, 21, 21, 18, 13, 10, 11, 8, 4, 9, 10, 10, 8, 13, 0, 8, 0, 69, 87, 93, 96, 97, 102, 101, 99, 97, 97, 96, 96, 95, 94, 92, 90, 86, 83, 78, 70, 83, 93, 98, 96, 84, 81, 83, 88, 85, 86, 82, 83, 84, 83, 82, 80, 75, 67, 69, 69, 78, 89, 92, 91, 68, 85, 91, 84, 93, 94, 94, 94, 92, 91, 88, 86, 82, 76, 66, 75, 78, 86, 91, 92, 92, 92, 94, 95, 94, 94, 94, 94, 92, 91, 88, 84, 63, 77, 75, 72, 73, 78, 76, 76, 87, 89, 87, 86, 85, 84, 83, 83, 82, 80, 76, 70, 61, 68, 53, 70, 74, 79, 78, 74, 74, 81, 85, 82, 67, 71, 78, 75, 72, 68, 59, 53, 64, 60, 65, 65, 66, 75, 77, 83, 91, 92, 94, 93, 90, 88, 86, 84, 82, 78, 69, 71, 74, 68, 77, 66, 77, 82, 85, 86, 78, 83, 83, 83, 82, 83, 82, 81, 78, 74, 65, 63, 60, 63, 68, 65, 70, 73, 82, 85, 84, 83, 85, 86, 81, 80, 81, 79, 74, 71, 62, 65, 57, 67, 68, 58, 76, 73, 77, 82, 86, 89, 88, 90, 89, 88, 86, 84, 77, 63, 76, 78, 63, 78, 71, 54, 67, 71, 76, 77, 79, 81, 74, 73, 75, 75, 75, 73, 71, 71, 76, 76, 63, 55, 59, 54, 72, 74, 69, 57, 68, 70, 78, 79, 75, 77, 74, 72, 67, 65, 58, 53, 59, 70, 54, 52, 75, 80, 81, 80, 79, 79, 80, 81, 80, 79, 77, 76, 69, 60, 64, 63, 65, 64, 57, 57, 70, 75, 78, 80, 80, 77, 79, 81, 79, 81, 78, 76, 68, 61, 62, 64, 57, 68, 41, 53, 68, 78, 84, 86, 86, 85, 83, 81, 84, 81, 78, 77, 71, 47, 71, 70, 75, 67, 61, 52, 78, 82, 85, 85, 84, 83, 83, 85, 82, 81, 79, 75, 64, 54, 64, 68, 72, 64, 60, 49, 63, 75, 81, 80, 76, 83, 85, 78, 72, 76, 56, 66, 61, 43, 58, 55, 59, 50, 50, 44, 73, 76, 69, 76, 73, 73, 77, 74, 75, 71, 68, 66, 68, 68, 69, 64, 61, 48, 42, 45, 71, 77, 78, 77, 80, 81, 76, 81, 80, 79, 75, 69, 65, 73, 56, 68, 68, 58, 43, 52, 69, 73, 73, 72, 72, 66, 68, 71, 71, 69, 62, 57, 56, 54, 57, 62, 47, 52, 34, 20, 66, 72, 70, 70, 65, 70, 66, 67, 65, 67, 64, 59, 55, 58, 43, 61, 54, 52, 45, 33, 68, 79, 83, 85, 86, 86, 85, 85, 82, 80, 71, 66, 76, 76, 75, 65, 67, 56, 41, 52, 71, 78, 79, 79, 79, 79, 75, 72, 73, 72, 71, 69, 54, 63, 70, 75, 52, 62, 49, 32, 69, 75, 77, 77, 76, 76, 74, 74, 70, 70, 60, 54, 63, 56, 67, 66, 38, 57, 47, 40, 60, 62, 55, 50, 59, 58, 56, 51, 48, 47, 45, 41, 44, 28, 50, 33, 23, 38, 23, 13, 53, 55, 62, 66, 64, 61, 61, 61, 62, 61, 56, 51, 44, 53, 57, 35, 47, 33, 36, 24, 61, 65, 64, 62, 67, 68, 68, 67, 67, 66, 60, 48, 57, 47, 64, 59, 45, 46, 38, 29, 60, 67, 69, 67, 67, 66, 65, 65, 64, 62, 56, 34, 50, 45, 54, 50, 42, 42, 35, 26, 55, 61, 62, 58, 52, 53, 58, 59, 58, 55, 29, 47, 50, 56, 56, 42, 47, 39, 32, 23, 63, 66, 65, 68, 72, 72, 70, 67, 68, 69, 69, 66, 55, 72, 67, 58, 56, 51, 35, 29, 65, 66, 59, 65, 70, 68, 61, 65, 59, 55, 58, 59, 64, 58, 59, 60, 43, 28, 12, 24, 68, 74, 76, 77, 78, 75, 71, 69, 63, 66, 61, 63, 51, 60, 55, 48, 44, 40, 29, 19, 63, 69, 70, 68, 65, 65, 65, 60, 50, 57, 47, 52, 30, 46, 37, 33, 26, 30, 7, 8, 53, 58, 57, 55, 49, 55, 48, 52, 44, 38, 25, 39, 36, 46, 39, 34, 33, 12, 15, 3, 53, 59, 61, 60, 58, 58, 57, 55, 51, 43, 48, 50, 52, 46, 41, 40, 38, 27, 14, 9, 58, 63, 63, 63, 64, 63, 63, 63, 58, 53, 45, 49, 48, 51, 40, 45, 32, 21, 17, 15, 59, 67, 70, 70, 68, 66, 64, 60, 48, 53, 53, 53, 42, 55, 43, 49, 41, 31, 18, 7, 54, 62, 64, 64, 64, 64, 64, 59, 56, 46, 51, 50, 54, 58, 29, 44, 39, 29, 16, 12, 61, 67, 70, 70, 70, 69, 67, 66, 62, 58, 47, 50, 46, 55, 45, 37, 37, 23, 3, 10, 55, 63, 67, 68, 65, 62, 55, 50, 53, 58, 57, 52, 50, 49, 45, 21, 28, 18, 0, 8, 67, 71, 75, 76, 75, 73, 69, 67, 71, 67, 67, 66, 66, 64, 60, 58, 47, 28, 35, 25, 73, 75, 76, 78, 79, 79, 80, 81, 81, 81, 80, 80, 78, 77, 75, 72, 68, 61, 54, 59, 71, 74, 74, 74, 70, 68, 71, 69, 70, 70, 69, 68, 67, 65, 60, 55, 29, 46, 52, 50, 66, 66, 65, 68, 72, 72, 70, 68, 65, 64, 63, 61, 59, 56, 53, 52, 40, 47, 49, 24, 50, 52, 49, 47, 49, 44, 47, 36, 32, 49, 50, 49, 47, 46, 43, 35, 38, 41, 31, 35, 55, 56, 55, 54, 55, 56, 56, 53, 53, 50, 49, 48, 45, 43, 37, 28, 37, 38, 18, 32, 56, 58, 59, 59, 59, 59, 59, 59, 58, 58, 57, 56, 54, 52, 45, 34, 41, 36, 38, 34, 37, 38, 38, 40, 40, 42, 39, 40, 39, 41, 40, 38, 34, 34, 29, 26, 21, 25, 22, 21, 20, 29, 33, 34, 35, 31, 28, 19, 16, 27, 16, 8, 22, 21, 23, 20, 23, 25, 14, 20, 32, 36, 37, 34, 29, 33, 30, 29, 31, 33, 30, 27, 21, 16, 12, 27, 25, 18, 16, 7, 33, 37, 39, 38, 37, 38, 38, 38, 36, 35, 34, 31, 26, 12, 27, 31, 22, 16, 13, 0, 33, 38, 39, 38, 38, 36, 36, 36, 35, 35, 35, 33, 27, 10, 20, 17, 24, 15, 17, 18, 26, 28, 27, 25, 28, 27, 26, 27, 23, 27, 19, 23, 23, 11, 19, 20, 19, 17, 6, 13, 25, 21, 25, 18, 19, 22, 18, 21, 16, 18, 19, 20, 2, 14, 12, 11, 7, 15, 2, 0, 31, 30, 24, 26, 24, 26, 21, 25, 21, 20, 17, 18, 12, 12, 14, 10, 7, 11, 4, 17, 15, 11, 19, 13, 0, 0, 13, 11, 10, 12, 11, 4, 11, 12, 13, 11, 0, 10, 14, 11, 12, 11, 5, 10, 1, 9, 0, 18, 5, 14, 16, 13, 12, 0, 10, 11, 4, 7, 0, 12, 16, 13, 4, 0, 15, 7, 15, 0, 13, 18, 9, 9, 11, 9, 0, 0, 9, 13, 4, 10, 11, 13, 15, 12, 9, 8, 6, 16, 16, 7, 8, 8, 6, 1, 0, 7, 14, 15, 11, 1, 13, 19, 11, 10, 2, 3, 0, 11, 9, 0, 14, 1, 6, 7, 14, 1, 10, 0, 11, 16, 23, 19, 21, 18, 22, 16, 13, 0, 14, 13, 10, 7, 11, 7, 12, 7, 13, 0, 12, 13, 14, 13, 20, 23, 22, 18, 11, 17, 17, 6, 12, 16, 12, 10, 10, 11, 12, 11, 6, 0, 15, 12, 21, 19, 16, 15, 17, 18, 16, 17, 14, 16, 15, 12, 15, 20, 19, 13, 19, 15, 21, 22, 21, 12, 0, 9, 0, 17, 11, 0, 9, 6, 6, 3, 4, 3, 6, 11, 0, 0, 13, 15, 13, 13, 10, 9, 9, 1, 9, 6, 5, 12, 10, 11, 3, 10, 8, 15, 3, 9, 17, 3, 17, 19, 7, 15, 4, 12, 8, 11, 12, 6, 0, 9, 5, 0, 2, 3, 13, 6, 15, 8, 14, 17, 9, 13, 7, 7, 8, 14, 2, 9, 6, 13, 7, 0, 6, 9, 11, 10, 0, 7, 6, 13, 16, 12, 7, 11, 12, 14, 5, 3, 11, 14, 0, 7, 4, 7, 11, 0, 14, 8, 13, 3, 12, 18, 9, 0, 13, 9, 7, 1, 10, 10, 0, 8, 9, 0, 0, 14, 15, 14, 12, 0, 8, 4, 11, 6, 10, 0, 0, 4, 10, 4, 2, 7, 8, 0, 6, 6, 11, 10, 9, 17, 12, 1, 6, 13, 2, 11, 13, 1, 6, 9, 11, 12, 6, 13, 4, 12, 12, 4, 7, 5, 2, 11, 6, 0, 6, 10, 14, 15, 14, 0, 11, 7, 0, 9, 14, 9, 10, 10, 0, 10, 5, 12, 0, 4, 11, 12, 8, 1, 6, 11, 6, 0, 4, 9, 12, 14, 9, 5, 11, 7, 12, 1, 10, 10, 12, 7, 7, 4, 7, 0, 5, 10, 10, 11, 10, 12, 13, 16, 9, 12, 6, 16, 11, 12, 3, 12, 10, 6, 0, 0, 12, 9, 14, 9, 7, 11, 10, 8, 13, 16, 8, 10, 12, 10, 6, 11, 14, 9, 0, 7, 3, 16, 12, 13, 11, 10, 2, 6, 11, 10, 0, 7, 2, 4, 8, 14, 6, 18, 13, 10, 9, 7, 7, 5, 12, 11, 19, 16, 13, 13, 12, 7, 8, 15, 13, 10, 3, 12, 10, 12, 14, 7, 18, 3, 11, 13, 15, 16, 18, 7, 11, 13, 10, 11, 11, 7, 15, 11, 13, 0, 11, 7, 9, 1, 6, 7, 19, 14, 15, 16, 12, 1, 12, 9, 10, 12, 5, 13, 0, 2, 14, 3, 11, 11, 1, 5, 62, 78, 82, 86, 88, 85, 82, 82, 83, 80, 80, 78, 77, 76, 73, 70, 65, 60, 48, 43, 72, 83, 89, 89, 92, 92, 93, 93, 95, 94, 93, 93, 92, 91, 89, 86, 80, 72, 68, 73, 53, 81, 88, 89, 88, 84, 86, 85, 85, 86, 86, 84, 82, 80, 76, 70, 57, 63, 65, 63, 69, 80, 83, 82, 87, 88, 86, 86, 82, 81, 79, 77, 74, 72, 66, 65, 61, 53, 63, 53, 52, 66, 69, 67, 62, 62, 57, 56, 60, 67, 67, 67, 65, 64, 59, 53, 49, 55, 50, 41, 66, 74, 75, 76, 73, 75, 76, 73, 73, 69, 68, 67, 65, 63, 57, 41, 56, 57, 46, 52, 66, 78, 82, 83, 84, 83, 84, 84, 83, 83, 82, 81, 79, 76, 67, 62, 68, 64, 61, 58, 57, 61, 69, 65, 65, 66, 67, 68, 69, 69, 68, 68, 66, 62, 51, 52, 53, 34, 49, 43, 58, 60, 63, 67, 61, 64, 57, 53, 53, 54, 54, 52, 51, 47, 37, 42, 49, 43, 41, 32, 59, 68, 74, 76, 75, 74, 75, 74, 73, 72, 72, 70, 67, 63, 60, 63, 62, 53, 50, 41, 55, 65, 68, 70, 70, 70, 71, 70, 69, 68, 66, 64, 58, 45, 61, 63, 56, 45, 42, 42, 53, 61, 67, 68, 69, 68, 66, 67, 67, 67, 66, 66, 63, 59, 56, 54, 51, 45, 44, 29, 42, 59, 62, 60, 60, 59, 61, 64, 63, 60, 57, 57, 53, 40, 42, 41, 48, 42, 20, 25, 54, 68, 72, 72, 72, 71, 71, 71, 71, 71, 69, 67, 62, 52, 41, 54, 54, 46, 45, 38, 57, 68, 69, 63, 65, 64, 66, 67, 67, 63, 60, 56, 49, 47, 52, 54, 47, 41, 37, 29, 52, 52, 54, 56, 45, 49, 47, 49, 46, 33, 29, 33, 40, 44, 42, 40, 33, 29, 24, 19, 42, 47, 45, 46, 43, 43, 49, 46, 48, 47, 47, 45, 38, 40, 37, 35, 36, 28, 19, 9, 40, 48, 49, 49, 48, 48, 47, 44, 41, 42, 41, 35, 35, 36, 36, 33, 30, 24, 19, 11, 43, 49, 52, 51, 52, 54, 51, 52, 48, 50, 46, 40, 41, 47, 50, 47, 37, 35, 19, 20, 35, 30, 32, 35, 43, 45, 46, 47, 47, 46, 45, 43, 37, 34, 36, 35, 33, 18, 13, 13, 41, 44, 42, 42, 42, 39, 42, 41, 38, 40, 37, 37, 34, 35, 35, 33, 25, 19, 11, 9, 38, 41, 39, 28, 34, 33, 40, 40, 40, 40, 38, 34, 30, 36, 40, 37, 30, 28, 21, 3, 30, 36, 39, 41, 40, 43, 43, 44, 43, 42, 39, 36, 34, 38, 33, 32, 29, 24, 15, 12, 29, 29, 13, 15, 21, 24, 28, 28, 26, 29, 29, 20, 24, 25, 19, 21, 14, 9, 18, 7, 34, 33, 29, 15, 26, 31, 25, 18, 21, 19, 14, 19, 10, 23, 15, 17, 10, 16, 2, 4, 31, 34, 30, 32, 36, 33, 34, 35, 36, 36, 33, 29, 21, 25, 24, 29, 3, 15, 6, 0, 22, 30, 33, 34, 36, 35, 35, 34, 32, 31, 26, 20, 21, 26, 22, 13, 12, 1, 3, 0, 23, 33, 37, 38, 39, 40, 40, 40, 39, 37, 34, 31, 29, 30, 13, 20, 17, 9, 8, 15, 8, 10, 25, 27, 27, 15, 25, 24, 21, 24, 20, 16, 13, 12, 18, 9, 13, 3, 0, 9, 14, 28, 33, 33, 32, 33, 35, 25, 26, 29, 28, 25, 11, 21, 15, 5, 1, 7, 7, 7, 17, 22, 27, 28, 26, 13, 23, 17, 21, 22, 23, 17, 18, 13, 16, 12, 14, 11, 10, 8, 25, 26, 27, 27, 24, 21, 28, 27, 27, 27, 26, 21, 18, 19, 17, 21, 4, 8, 0, 4, 6, 7, 10, 10, 13, 19, 0, 14, 5, 11, 9, 0, 0, 7, 6, 14, 2, 11, 3, 10, 6, 16, 23, 25, 21, 25, 22, 23, 21, 20, 15, 0, 6, 15, 13, 7, 0, 10, 10, 6, 19, 17, 10, 7, 11, 13, 0, 17, 12, 6, 10, 5, 5, 0, 10, 5, 9, 7, 0, 9, 16, 28, 29, 23, 17, 23, 14, 18, 15, 20, 19, 0, 16, 16, 1, 7, 4, 3, 16, 7, 22, 7, 1, 7, 18, 17, 21, 17, 17, 13, 15, 12, 15, 10, 4, 7, 5, 5, 10, 15, 19, 17, 4, 11, 7, 13, 11, 6, 7, 5, 6, 13, 4, 14, 11, 6, 5, 4, 5, 11, 16, 14, 17, 21, 16, 19, 14, 18, 15, 11, 5, 13, 9, 6, 5, 2, 3, 11, 13, 0, 8, 12, 9, 6, 16, 18, 16, 9, 8, 0, 11, 15, 10, 13, 12, 0, 13, 14, 4, 8, 72, 86, 89, 94, 96, 93, 94, 89, 89, 89, 87, 87, 86, 85, 83, 80, 74, 68, 64, 55, 81, 91, 97, 97, 100, 101, 102, 102, 103, 103, 102, 102, 101, 99, 97, 95, 89, 80, 76, 80, 65, 91, 97, 98, 97, 94, 95, 94, 93, 93, 92, 91, 89, 87, 81, 75, 60, 69, 71, 72, 78, 89, 92, 91, 96, 97, 95, 95, 92, 93, 92, 91, 88, 86, 81, 77, 74, 68, 73, 62, 54, 75, 78, 78, 75, 73, 62, 68, 62, 72, 75, 72, 70, 68, 63, 55, 56, 61, 58, 50, 77, 82, 82, 83, 81, 83, 84, 80, 82, 80, 79, 79, 77, 75, 70, 62, 66, 68, 52, 60, 76, 88, 93, 94, 95, 94, 94, 94, 94, 94, 93, 92, 90, 87, 77, 73, 77, 73, 71, 68, 67, 74, 80, 74, 75, 79, 80, 80, 80, 79, 79, 79, 76, 72, 61, 63, 64, 45, 59, 51, 73, 76, 74, 80, 73, 78, 75, 72, 69, 66, 59, 49, 55, 51, 42, 60, 65, 61, 54, 39, 72, 81, 87, 89, 88, 87, 88, 87, 87, 87, 86, 85, 81, 76, 71, 76, 75, 66, 57, 59, 67, 78, 80, 82, 81, 81, 81, 81, 80, 79, 77, 76, 70, 63, 71, 73, 65, 55, 48, 48, 67, 76, 82, 84, 86, 85, 84, 84, 83, 82, 81, 80, 77, 71, 69, 68, 67, 62, 57, 34, 53, 72, 75, 76, 75, 75, 71, 74, 80, 74, 74, 74, 66, 58, 57, 60, 64, 56, 45, 37, 72, 83, 87, 87, 87, 86, 87, 87, 86, 85, 83, 81, 75, 62, 65, 70, 67, 61, 57, 51, 76, 86, 86, 79, 82, 80, 85, 84, 84, 80, 76, 70, 62, 66, 72, 70, 69, 53, 53, 36, 72, 71, 72, 75, 67, 68, 67, 65, 68, 63, 58, 28, 58, 62, 62, 58, 51, 50, 42, 36, 65, 71, 69, 69, 69, 68, 71, 71, 72, 72, 71, 68, 58, 59, 61, 55, 56, 50, 41, 25, 59, 69, 71, 73, 73, 73, 71, 70, 68, 68, 65, 61, 58, 59, 56, 54, 57, 45, 43, 34, 61, 68, 70, 69, 70, 74, 69, 70, 65, 68, 64, 60, 56, 64, 66, 62, 52, 52, 36, 30, 52, 45, 59, 63, 65, 67, 66, 68, 66, 64, 63, 61, 49, 56, 61, 58, 47, 40, 25, 35, 60, 63, 60, 58, 56, 58, 57, 55, 44, 52, 51, 43, 46, 48, 52, 37, 31, 38, 30, 24, 59, 65, 66, 61, 63, 60, 65, 67, 67, 66, 65, 63, 53, 55, 61, 60, 49, 45, 33, 17, 58, 64, 67, 70, 71, 73, 74, 74, 74, 73, 70, 68, 64, 68, 67, 61, 57, 53, 40, 25, 57, 61, 57, 46, 53, 54, 54, 54, 55, 52, 52, 49, 41, 24, 48, 48, 38, 29, 28, 13, 44, 51, 57, 59, 46, 40, 44, 54, 35, 50, 50, 44, 43, 45, 41, 33, 36, 23, 6, 11, 55, 56, 56, 56, 58, 58, 56, 54, 54, 54, 50, 46, 38, 45, 46, 47, 21, 37, 25, 19, 50, 56, 58, 60, 61, 59, 60, 61, 60, 59, 56, 53, 44, 48, 49, 42, 34, 32, 17, 11, 51, 53, 54, 54, 58, 59, 57, 55, 57, 52, 50, 49, 43, 41, 36, 39, 32, 23, 13, 11, 52, 51, 52, 52, 54, 46, 50, 46, 49, 50, 47, 35, 48, 45, 37, 33, 23, 24, 15, 10, 39, 59, 63, 62, 64, 62, 61, 62, 59, 60, 47, 47, 48, 50, 41, 38, 2, 18, 10, 5, 48, 60, 62, 58, 50, 59, 57, 60, 59, 54, 51, 55, 50, 45, 44, 29, 31, 25, 13, 12, 29, 51, 52, 50, 52, 51, 53, 52, 51, 48, 43, 36, 28, 35, 45, 39, 31, 21, 14, 0, 36, 46, 40, 37, 30, 28, 37, 31, 27, 29, 24, 26, 20, 18, 20, 20, 13, 10, 10, 8, 41, 45, 47, 50, 51, 51, 51, 51, 49, 47, 42, 37, 40, 42, 36, 22, 22, 19, 10, 9, 34, 42, 46, 43, 43, 42, 41, 40, 36, 35, 27, 29, 33, 29, 25, 23, 16, 11, 9, 16, 41, 43, 42, 42, 39, 37, 40, 36, 37, 31, 32, 36, 39, 37, 27, 28, 13, 16, 10, 2, 37, 26, 33, 36, 42, 43, 29, 35, 39, 39, 38, 36, 32, 31, 19, 24, 18, 11, 13, 9, 46, 39, 43, 38, 23, 38, 34, 41, 36, 38, 35, 33, 31, 32, 24, 13, 1, 13, 7, 7, 44, 50, 52, 51, 51, 51, 48, 47, 44, 37, 32, 39, 38, 32, 29, 29, 19, 7, 8, 10, 32, 37, 38, 35, 36, 31, 38, 42, 36, 33, 36, 32, 12, 22, 24, 15, 0, 2, 11, 11, 69, 79, 79, 76, 82, 80, 80, 78, 76, 79, 77, 77, 75, 74, 70, 65, 55, 49, 50, 51, 65, 74, 79, 79, 81, 83, 82, 83, 84, 84, 81, 79, 75, 70, 57, 58, 60, 55, 47, 34, 56, 53, 59, 67, 73, 75, 77, 76, 76, 75, 73, 73, 71, 69, 66, 62, 57, 61, 59, 56, 58, 66, 69, 67, 64, 61, 65, 64, 63, 65, 65, 64, 62, 60, 54, 43, 53, 42, 46, 34, 59, 57, 61, 64, 65, 65, 66, 67, 68, 68, 68, 67, 66, 63, 55, 51, 51, 52, 42, 40, 56, 64, 66, 67, 66, 66, 66, 67, 65, 65, 65, 64, 62, 60, 51, 50, 37, 52, 36, 40, 49, 51, 52, 52, 54, 55, 56, 56, 56, 56, 56, 56, 55, 53, 50, 50, 45, 37, 38, 32, 43, 40, 45, 45, 44, 44, 42, 43, 45, 44, 41, 39, 38, 29, 33, 34, 29, 21, 18, 16, 37, 40, 40, 43, 44, 44, 44, 45, 45, 44, 45, 42, 38, 30, 36, 32, 30, 24, 15, 17, 25, 29, 25, 12, 23, 23, 26, 23, 25, 21, 28, 28, 31, 30, 8, 23, 22, 20, 20, 0, 18, 31, 34, 35, 35, 37, 38, 39, 39, 40, 41, 41, 38, 30, 28, 17, 23, 15, 14, 7, 27, 33, 33, 31, 33, 33, 33, 33, 34, 34, 34, 34, 31, 21, 20, 21, 21, 18, 19, 9, 22, 25, 25, 28, 26, 23, 24, 24, 25, 25, 21, 24, 18, 18, 26, 12, 20, 7, 2, 8, 17, 6, 25, 28, 22, 27, 28, 27, 30, 31, 32, 32, 27, 14, 11, 14, 18, 5, 11, 2, 9, 19, 23, 21, 25, 25, 25, 22, 17, 19, 25, 9, 10, 19, 11, 5, 0, 0, 8, 5, 9, 1, 13, 10, 12, 8, 14, 9, 8, 11, 5, 15, 17, 6, 15, 3, 10, 8, 8, 15, 7, 7, 9, 1, 9, 20, 12, 14, 14, 8, 11, 11, 9, 14, 15, 1, 8, 7, 0, 7, 16, 20, 19, 23, 23, 21, 20, 23, 22, 21, 15, 12, 7, 0, 15, 14, 11, 8, 12, 6, 25, 22, 19, 22, 19, 15, 22, 14, 19, 12, 16, 10, 13, 14, 18, 18, 16, 18, 18, 17, 10, 3, 1, 14, 18, 15, 19, 4, 13, 9, 13, 13, 8, 8, 6, 8, 8, 11, 0, 15, 15, 21, 24, 27, 26, 25, 26, 24, 23, 21, 18, 0, 9, 18, 10, 15, 9, 7, 9, 15, 2, 5, 9, 0, 13, 6, 10, 0, 12, 5, 13, 11, 13, 7, 9, 8, 9, 12, 8, 4, 18, 14, 15, 12, 12, 14, 6, 8, 13, 5, 10, 9, 11, 11, 15, 9, 9, 14, 0, 10, 13, 13, 12, 1, 6, 14, 0, 13, 11, 13, 0, 8, 8, 0, 0, 14, 0, 4, 10, 8, 6, 5, 0, 6, 17, 12, 7, 6, 15, 9, 5, 12, 0, 12, 0, 9, 1, 4, 7, 7, 14, 7, 16, 16, 5, 4, 13, 7, 18, 11, 0, 5, 6, 3, 6, 13, 6, 11, 9, 7, 12, 12, 12, 7, 13, 7, 15, 15, 9, 7, 13, 12, 9, 14, 13, 0, 13, 16, 3, 9, 7, 9, 13, 15, 17, 16, 13, 12, 12, 11, 10, 10, 14, 0, 7, 9, 12, 0, 13, 5, 19, 16, 19, 19, 8, 14, 4, 0, 13, 16, 2, 15, 1, 4, 13, 0, 7, 12, 4, 11, 22, 22, 20, 16, 15, 9, 17, 12, 15, 8, 9, 14, 17, 5, 0, 0, 7, 9, 7, 0, 9, 12, 1, 12, 7, 18, 3, 8, 7, 8, 7, 10, 11, 7, 10, 9, 9, 10, 10, 9, 15, 12, 10, 8, 6, 13, 5, 15, 13, 3, 11, 6, 6, 3, 7, 13, 12, 8, 6, 1, 15, 12, 15, 18, 11, 11, 12, 15, 14, 16, 11, 12, 14, 16, 12, 17, 10, 16, 20, 18, 8, 7, 4, 13, 9, 15, 12, 13, 3, 5, 8, 12, 3, 2, 8, 0, 6, 10, 5, 7, 14, 8, 7, 7, 2, 11, 13, 8, 12, 4, 11, 14, 12, 11, 4, 7, 5, 7, 5, 13, 17, 14, 10, 11, 6, 11, 4, 0, 11, 6, 10, 4, 13, 13, 4, 8, 0, 13, 12, 3, 9, 12, 13, 0, 5, 8, 5, 13, 0, 11, 16, 8, 15, 11, 7, 5, 0, 0, 11, 9, 16, 5, 11, 17, 13, 15, 15, 7, 0, 12, 12, 13, 4, 0, 14, 9, 7, 0, 3, 0, 12, 7, 0, 12, 10, 7, 0, 0, 13, 8, 0, 0, 11, 9, 5, 13, 0, 16, 9, 2, 0, 12, 12, 5, 10, 12, 13, 6, 3, 6, 7, 7, 10, 12, 0, 6, 6, 0, 0, 8, 70, 84, 89, 87, 90, 90, 91, 88, 85, 89, 87, 87, 85, 83, 79, 75, 62, 60, 63, 54, 74, 81, 90, 91, 92, 94, 94, 94, 95, 95, 92, 90, 86, 81, 72, 71, 70, 66, 56, 52, 64, 74, 67, 79, 85, 88, 89, 88, 88, 87, 85, 84, 81, 77, 68, 64, 67, 68, 66, 65, 64, 78, 84, 85, 80, 79, 81, 81, 80, 81, 79, 77, 74, 70, 56, 61, 67, 51, 54, 55, 73, 73, 76, 79, 80, 80, 80, 82, 82, 82, 81, 80, 77, 72, 60, 69, 53, 68, 58, 60, 67, 79, 83, 84, 84, 84, 84, 85, 83, 83, 82, 80, 76, 69, 66, 68, 62, 65, 53, 45, 64, 73, 75, 74, 76, 76, 78, 79, 78, 77, 76, 76, 72, 69, 67, 58, 70, 58, 61, 54, 69, 67, 69, 74, 71, 73, 71, 71, 71, 70, 67, 61, 55, 57, 58, 44, 51, 42, 40, 41, 62, 72, 74, 75, 77, 76, 76, 77, 77, 76, 74, 71, 61, 63, 63, 60, 54, 53, 52, 43, 56, 58, 52, 59, 63, 65, 66, 65, 66, 66, 65, 63, 55, 53, 56, 50, 55, 53, 46, 34, 52, 64, 68, 69, 70, 70, 70, 71, 71, 70, 69, 67, 57, 52, 46, 59, 50, 42, 39, 33, 55, 65, 67, 66, 66, 66, 65, 66, 66, 66, 64, 61, 48, 55, 50, 49, 43, 33, 27, 29, 50, 60, 62, 63, 63, 65, 65, 63, 65, 65, 60, 52, 52, 56, 53, 44, 40, 38, 35, 20, 54, 48, 63, 64, 63, 64, 66, 66, 66, 67, 66, 63, 48, 51, 40, 43, 45, 43, 22, 27, 53, 53, 54, 58, 57, 61, 48, 55, 42, 52, 54, 49, 41, 49, 44, 41, 42, 29, 19, 19, 46, 43, 48, 46, 43, 44, 42, 40, 40, 40, 30, 21, 25, 25, 23, 12, 8, 12, 10, 11, 39, 37, 40, 39, 38, 36, 41, 41, 39, 41, 39, 31, 33, 35, 17, 29, 26, 14, 15, 8, 35, 45, 46, 46, 48, 48, 50, 50, 51, 51, 50, 45, 31, 40, 33, 37, 29, 25, 19, 7, 40, 46, 40, 38, 41, 34, 30, 29, 38, 40, 41, 41, 32, 24, 33, 26, 24, 11, 13, 14, 29, 32, 30, 27, 30, 34, 31, 32, 30, 23, 28, 30, 34, 33, 19, 24, 21, 17, 0, 14, 24, 32, 38, 41, 42, 43, 43, 43, 44, 43, 41, 38, 38, 31, 22, 22, 15, 11, 7, 9, 24, 24, 25, 28, 19, 26, 11, 12, 14, 20, 26, 27, 25, 23, 15, 19, 16, 14, 12, 8, 27, 24, 22, 23, 27, 28, 21, 17, 13, 11, 24, 25, 21, 19, 20, 18, 6, 5, 16, 10, 23, 21, 25, 25, 25, 26, 23, 27, 25, 26, 21, 21, 15, 17, 14, 5, 5, 16, 14, 0, 24, 25, 28, 26, 24, 22, 22, 10, 17, 21, 23, 26, 16, 23, 12, 14, 5, 9, 12, 8, 18, 24, 32, 30, 27, 26, 27, 27, 20, 10, 13, 24, 19, 8, 11, 10, 0, 5, 9, 9, 27, 32, 33, 33, 32, 28, 31, 30, 27, 27, 26, 29, 19, 20, 20, 12, 12, 5, 2, 7, 33, 39, 40, 38, 38, 35, 31, 28, 20, 28, 28, 31, 25, 6, 10, 11, 13, 9, 15, 6, 22, 29, 20, 27, 26, 23, 26, 23, 22, 25, 25, 15, 18, 19, 8, 0, 14, 3, 0, 15, 25, 30, 31, 31, 32, 32, 32, 31, 30, 24, 19, 26, 17, 22, 16, 16, 11, 0, 14, 8, 26, 20, 21, 13, 18, 18, 15, 17, 18, 8, 6, 19, 8, 10, 6, 14, 0, 0, 13, 5, 15, 9, 14, 15, 20, 14, 9, 15, 15, 13, 6, 9, 14, 0, 5, 7, 0, 1, 9, 1, 19, 18, 21, 15, 20, 19, 18, 17, 12, 16, 1, 7, 7, 13, 7, 9, 12, 5, 0, 16, 20, 15, 6, 5, 23, 9, 15, 13, 15, 10, 15, 15, 6, 0, 3, 6, 4, 11, 11, 11, 14, 15, 13, 6, 14, 16, 7, 14, 8, 14, 9, 9, 9, 6, 10, 8, 1, 11, 7, 4, 24, 25, 14, 21, 15, 21, 23, 24, 21, 18, 8, 12, 9, 0, 13, 11, 1, 9, 5, 7, 17, 19, 18, 12, 20, 22, 18, 18, 20, 13, 12, 10, 9, 4, 9, 11, 0, 9, 1, 4, 5, 8, 16, 19, 15, 0, 14, 15, 14, 11, 6, 12, 3, 14, 17, 9, 14, 7, 2, 0, 13, 9, 18, 10, 15, 18, 18, 20, 21, 14, 0, 15, 7, 14, 12, 2, 17, 14, 11, 14, 10, 5, 16, 13, 16, 13, 17, 17, 19, 10, 15, 12, 2, 8, 12, 14, 13, 0, 2, 5, 79, 89, 95, 94, 96, 99, 98, 98, 93, 95, 94, 94, 92, 91, 88, 84, 71, 67, 71, 62, 80, 88, 97, 98, 100, 102, 102, 103, 104, 103, 100, 98, 94, 89, 80, 80, 78, 73, 61, 56, 68, 82, 75, 86, 92, 95, 95, 95, 94, 93, 92, 90, 86, 80, 71, 74, 74, 74, 74, 71, 72, 86, 91, 92, 88, 88, 88, 87, 85, 87, 85, 83, 80, 75, 53, 70, 72, 48, 61, 57, 80, 82, 84, 87, 90, 89, 88, 90, 89, 89, 89, 88, 84, 78, 73, 78, 65, 77, 64, 68, 75, 87, 90, 91, 91, 91, 90, 90, 88, 88, 86, 84, 78, 67, 74, 71, 73, 70, 61, 55, 74, 82, 85, 83, 85, 86, 88, 88, 88, 88, 87, 86, 82, 79, 78, 62, 79, 71, 72, 63, 80, 77, 80, 85, 83, 84, 82, 82, 82, 81, 76, 65, 66, 63, 57, 56, 41, 55, 44, 32, 72, 84, 86, 87, 89, 88, 88, 88, 87, 86, 84, 80, 73, 77, 70, 75, 70, 62, 60, 55, 69, 72, 54, 71, 74, 78, 79, 79, 80, 80, 78, 73, 47, 69, 69, 62, 65, 66, 53, 51, 64, 77, 80, 81, 82, 82, 82, 83, 82, 81, 79, 75, 62, 69, 60, 72, 63, 57, 50, 44, 69, 79, 82, 80, 81, 81, 80, 80, 80, 80, 77, 72, 64, 71, 51, 65, 60, 56, 48, 41, 65, 73, 76, 76, 75, 76, 79, 75, 78, 76, 74, 66, 68, 66, 67, 54, 50, 38, 47, 26, 70, 68, 78, 79, 77, 77, 79, 78, 79, 79, 77, 73, 63, 67, 64, 62, 57, 36, 35, 31, 71, 69, 75, 79, 76, 82, 75, 79, 72, 67, 71, 63, 68, 69, 61, 57, 60, 49, 40, 22, 65, 65, 69, 68, 64, 66, 63, 64, 62, 57, 32, 51, 46, 53, 47, 42, 28, 36, 17, 12, 61, 62, 55, 57, 60, 47, 61, 61, 61, 61, 58, 50, 56, 48, 41, 47, 42, 31, 17, 11, 57, 64, 67, 69, 69, 69, 68, 68, 67, 65, 60, 55, 59, 50, 46, 51, 48, 17, 25, 22, 58, 63, 55, 50, 58, 57, 56, 61, 60, 58, 54, 55, 51, 38, 48, 50, 35, 36, 24, 22, 44, 54, 52, 53, 55, 56, 54, 54, 52, 52, 52, 54, 51, 50, 45, 47, 38, 30, 16, 1, 56, 62, 63, 62, 64, 63, 63, 62, 60, 57, 47, 45, 49, 38, 37, 41, 36, 18, 12, 8, 41, 38, 54, 53, 47, 48, 49, 51, 58, 58, 55, 49, 44, 47, 33, 45, 36, 29, 14, 0, 57, 60, 61, 62, 63, 63, 63, 63, 60, 57, 47, 53, 48, 43, 40, 36, 32, 34, 19, 10, 42, 50, 53, 54, 53, 53, 52, 49, 48, 46, 38, 42, 39, 39, 32, 32, 24, 17, 9, 9, 45, 40, 47, 46, 50, 48, 35, 43, 37, 45, 46, 41, 36, 35, 0, 29, 20, 19, 4, 13, 36, 45, 52, 49, 45, 47, 46, 44, 41, 36, 42, 45, 26, 33, 26, 21, 20, 3, 5, 0, 51, 55, 58, 58, 57, 51, 44, 49, 51, 39, 42, 52, 43, 42, 29, 23, 15, 20, 13, 5, 50, 53, 53, 56, 55, 54, 48, 48, 50, 45, 38, 46, 37, 32, 31, 22, 5, 13, 10, 8, 47, 49, 52, 51, 50, 50, 44, 41, 44, 43, 35, 38, 31, 26, 33, 24, 15, 14, 9, 8, 40, 50, 49, 47, 50, 49, 49, 48, 42, 36, 37, 32, 34, 29, 28, 19, 0, 9, 4, 8, 42, 32, 36, 32, 35, 34, 37, 38, 39, 38, 34, 27, 25, 24, 18, 15, 14, 8, 5, 0, 33, 26, 29, 13, 27, 26, 31, 26, 30, 27, 23, 20, 18, 22, 18, 2, 10, 5, 13, 8, 29, 30, 37, 37, 37, 33, 33, 34, 32, 19, 30, 14, 13, 18, 10, 19, 14, 15, 13, 15, 28, 33, 38, 36, 35, 32, 28, 34, 35, 33, 15, 25, 26, 19, 14, 12, 11, 13, 4, 0, 37, 39, 33, 38, 38, 37, 37, 31, 16, 22, 12, 26, 10, 16, 17, 2, 9, 10, 10, 3, 33, 41, 41, 42, 42, 45, 45, 46, 43, 39, 29, 28, 29, 31, 27, 12, 14, 1, 4, 7, 28, 21, 29, 28, 28, 27, 29, 29, 25, 16, 21, 12, 18, 3, 10, 9, 8, 0, 12, 0, 29, 33, 28, 32, 32, 13, 26, 31, 34, 36, 25, 28, 24, 0, 7, 11, 13, 3, 0, 0, 32, 33, 33, 35, 36, 36, 36, 30, 28, 23, 29, 29, 16, 16, 6, 11, 2, 12, 8, 4, 35, 43, 38, 42, 45, 46, 47, 47, 45, 37, 39, 34, 37, 31, 24, 4, 11, 2, 7, 15, 74, 74, 58, 70, 67, 62, 62, 67, 64, 64, 64, 65, 65, 64, 64, 63, 59, 56, 54, 55, 63, 71, 74, 72, 74, 75, 77, 77, 76, 75, 73, 71, 67, 63, 58, 56, 54, 57, 55, 51, 48, 53, 59, 63, 64, 63, 61, 62, 63, 61, 58, 54, 40, 51, 56, 55, 49, 48, 44, 47, 50, 53, 52, 51, 51, 51, 53, 54, 56, 56, 56, 56, 56, 52, 46, 48, 47, 32, 41, 41, 30, 40, 44, 47, 49, 50, 50, 49, 45, 40, 36, 44, 50, 52, 50, 45, 45, 46, 38, 36, 45, 48, 48, 50, 51, 50, 49, 49, 49, 48, 46, 45, 44, 43, 42, 41, 33, 39, 29, 28, 33, 26, 23, 30, 27, 29, 23, 31, 30, 27, 16, 14, 19, 22, 25, 23, 17, 17, 16, 8, 15, 2, 25, 19, 26, 26, 24, 22, 18, 20, 17, 23, 20, 21, 15, 15, 4, 19, 12, 21, 14, 10, 17, 9, 16, 15, 19, 13, 18, 19, 16, 18, 0, 9, 14, 18, 0, 5, 16, 0, 21, 19, 19, 24, 23, 22, 19, 17, 19, 14, 16, 16, 16, 17, 9, 8, 10, 9, 16, 8, 19, 22, 22, 25, 24, 24, 23, 21, 22, 22, 18, 16, 17, 13, 0, 0, 15, 5, 12, 8, 21, 21, 23, 17, 18, 20, 9, 9, 15, 20, 19, 17, 0, 14, 0, 9, 2, 8, 4, 3, 11, 20, 20, 21, 14, 17, 20, 20, 18, 14, 8, 0, 4, 9, 3, 16, 8, 15, 11, 7, 15, 20, 12, 8, 11, 14, 14, 15, 18, 15, 18, 8, 16, 5, 15, 8, 2, 8, 12, 7, 10, 17, 20, 21, 22, 15, 21, 18, 23, 21, 7, 18, 18, 16, 16, 18, 20, 11, 12, 0, 7, 12, 10, 16, 16, 10, 0, 13, 16, 1, 11, 4, 8, 9, 14, 0, 12, 3, 8, 7, 14, 13, 5, 7, 15, 15, 7, 2, 0, 16, 13, 18, 0, 9, 0, 7, 10, 11, 11, 4, 12, 11, 2, 12, 8, 9, 13, 15, 12, 15, 12, 17, 17, 4, 8, 6, 13, 13, 5, 2, 5, 14, 15, 17, 17, 13, 16, 14, 9, 0, 3, 12, 0, 4, 15, 7, 4, 3, 13, 13, 19, 19, 16, 11, 13, 16, 18, 7, 11, 15, 14, 13, 10, 8, 15, 2, 13, 9, 13, 0, 18, 18, 10, 18, 19, 19, 10, 16, 11, 17, 22, 12, 13, 11, 8, 1, 1, 14, 15, 7, 13, 17, 19, 6, 15, 17, 9, 14, 9, 5, 12, 9, 8, 5, 11, 12, 8, 1, 5, 5, 16, 7, 18, 17, 18, 12, 10, 2, 0, 17, 0, 14, 7, 11, 3, 11, 14, 6, 8, 12, 14, 0, 7, 11, 0, 1, 8, 1, 11, 9, 17, 3, 6, 0, 8, 1, 2, 8, 6, 9, 5, 14, 15, 16, 10, 13, 15, 16, 16, 15, 15, 15, 10, 6, 12, 7, 2, 7, 4, 15, 2, 14, 14, 13, 16, 15, 15, 10, 14, 6, 7, 11, 2, 15, 9, 10, 7, 8, 6, 10, 17, 7, 16, 14, 21, 18, 4, 15, 9, 8, 5, 12, 16, 17, 11, 13, 12, 11, 14, 10, 19, 16, 21, 14, 11, 15, 16, 15, 17, 10, 0, 12, 8, 12, 10, 2, 4, 12, 5, 5, 20, 17, 19, 16, 14, 19, 18, 15, 15, 0, 7, 13, 12, 1, 0, 8, 5, 8, 12, 13, 17, 11, 5, 11, 5, 13, 10, 14, 5, 13, 12, 13, 9, 17, 0, 6, 6, 13, 10, 2, 17, 16, 16, 14, 9, 8, 12, 8, 9, 16, 1, 10, 6, 14, 12, 12, 16, 15, 7, 4, 21, 16, 14, 15, 6, 4, 9, 12, 7, 11, 16, 8, 5, 4, 17, 9, 4, 13, 15, 6, 6, 8, 8, 0, 7, 15, 0, 3, 4, 8, 11, 0, 13, 12, 16, 10, 12, 12, 4, 8, 8, 9, 1, 10, 12, 10, 3, 0, 7, 5, 16, 16, 13, 9, 5, 7, 9, 8, 12, 6, 11, 6, 0, 15, 10, 13, 19, 15, 16, 7, 12, 6, 9, 9, 8, 18, 12, 11, 10, 14, 10, 14, 14, 19, 8, 6, 7, 8, 16, 6, 5, 7, 8, 6, 5, 9, 8, 6, 15, 8, 18, 9, 2, 4, 15, 8, 12, 6, 5, 7, 6, 17, 0, 9, 5, 7, 7, 7, 11, 6, 9, 4, 10, 7, 14, 13, 8, 6, 8, 15, 5, 9, 1, 9, 7, 16, 11, 9, 14, 0, 9, 8, 17, 12, 3, 3, 0, 10, 9, 7, 8, 9, 0, 8, 11, 0, 11, 4, 11, 6, 18, 10, 13, 7, 6, 8, 15, 15, 12, 16, 4, 7, 3, 13, 12, 6, 2, 0, 13, 8, 80, 87, 79, 80, 76, 66, 71, 80, 73, 70, 73, 73, 73, 73, 72, 71, 69, 65, 65, 67, 71, 84, 90, 90, 88, 92, 93, 93, 93, 92, 90, 89, 85, 80, 68, 54, 56, 67, 66, 59, 70, 59, 77, 81, 83, 83, 81, 82, 83, 82, 79, 77, 71, 62, 63, 65, 57, 66, 49, 52, 74, 80, 80, 80, 79, 77, 79, 80, 80, 77, 78, 78, 77, 74, 71, 71, 65, 60, 60, 59, 67, 68, 70, 68, 74, 78, 78, 78, 77, 76, 75, 75, 74, 73, 68, 68, 68, 62, 56, 42, 68, 71, 72, 73, 75, 75, 73, 75, 74, 73, 71, 67, 60, 52, 57, 48, 58, 57, 51, 47, 60, 52, 67, 63, 55, 58, 61, 61, 58, 56, 58, 60, 62, 60, 54, 53, 57, 50, 44, 42, 55, 53, 58, 60, 60, 60, 58, 57, 57, 57, 54, 54, 51, 50, 46, 26, 32, 31, 30, 16, 53, 56, 63, 65, 65, 63, 62, 61, 61, 60, 59, 57, 48, 53, 55, 45, 49, 32, 34, 30, 50, 52, 55, 57, 52, 51, 50, 51, 43, 38, 41, 40, 23, 35, 34, 41, 33, 32, 22, 19, 54, 59, 61, 60, 59, 60, 60, 60, 59, 58, 55, 45, 53, 55, 41, 49, 45, 38, 28, 24, 48, 52, 51, 51, 51, 51, 48, 49, 46, 46, 37, 25, 46, 50, 42, 41, 36, 29, 18, 16, 45, 51, 51, 49, 49, 34, 48, 33, 43, 46, 46, 46, 42, 36, 41, 20, 34, 24, 22, 12, 30, 27, 36, 39, 47, 49, 48, 50, 48, 42, 33, 27, 38, 41, 31, 37, 31, 26, 16, 13, 42, 39, 37, 35, 37, 45, 44, 45, 47, 46, 44, 36, 42, 35, 36, 25, 26, 20, 23, 17, 26, 31, 34, 32, 32, 31, 28, 27, 31, 30, 31, 32, 30, 26, 21, 17, 3, 1, 14, 10, 31, 36, 34, 30, 25, 29, 27, 21, 19, 24, 30, 31, 31, 21, 21, 18, 0, 11, 15, 11, 27, 40, 40, 38, 37, 38, 36, 35, 32, 33, 33, 32, 16, 26, 14, 19, 13, 16, 7, 5, 30, 33, 31, 30, 28, 28, 31, 29, 25, 22, 31, 32, 31, 24, 24, 17, 14, 13, 8, 6, 27, 26, 17, 25, 30, 30, 30, 28, 28, 30, 27, 23, 9, 22, 19, 5, 6, 6, 9, 10, 21, 25, 29, 30, 27, 24, 25, 19, 26, 29, 33, 32, 23, 21, 17, 7, 13, 11, 11, 14, 28, 19, 18, 13, 21, 29, 27, 24, 22, 27, 26, 25, 24, 9, 18, 8, 10, 13, 2, 0, 27, 26, 30, 30, 32, 32, 31, 31, 31, 29, 26, 19, 13, 18, 11, 10, 9, 0, 13, 1, 23, 5, 19, 27, 23, 22, 25, 22, 11, 17, 4, 17, 17, 13, 6, 0, 16, 9, 12, 12, 25, 10, 14, 18, 27, 20, 27, 23, 21, 19, 15, 12, 20, 11, 13, 13, 8, 14, 0, 9, 24, 24, 22, 21, 22, 24, 23, 23, 17, 16, 12, 17, 16, 10, 16, 13, 6, 0, 3, 0, 23, 27, 31, 18, 25, 16, 22, 9, 16, 17, 18, 9, 14, 8, 11, 14, 10, 0, 7, 14, 25, 24, 20, 17, 22, 19, 20, 19, 6, 1, 18, 10, 15, 12, 11, 12, 8, 11, 4, 12, 21, 19, 5, 16, 17, 19, 20, 19, 20, 15, 8, 18, 16, 16, 12, 10, 18, 15, 10, 8, 13, 13, 20, 22, 13, 16, 13, 16, 13, 18, 15, 17, 15, 9, 1, 11, 12, 10, 2, 10, 20, 25, 27, 24, 24, 24, 23, 23, 18, 19, 12, 14, 13, 15, 17, 16, 4, 12, 8, 12, 14, 8, 14, 6, 10, 10, 9, 17, 7, 8, 6, 0, 11, 16, 14, 3, 5, 13, 7, 11, 17, 10, 5, 12, 10, 11, 13, 13, 3, 6, 13, 14, 8, 4, 8, 15, 11, 0, 15, 10, 14, 9, 5, 7, 19, 24, 7, 9, 8, 5, 5, 13, 0, 12, 16, 13, 14, 4, 14, 8, 18, 25, 21, 15, 15, 18, 13, 16, 6, 17, 8, 13, 11, 5, 13, 10, 10, 3, 13, 19, 12, 0, 16, 18, 18, 19, 13, 8, 13, 17, 10, 5, 12, 6, 9, 2, 5, 9, 10, 7, 0, 15, 22, 19, 4, 19, 13, 12, 14, 10, 4, 17, 11, 15, 4, 7, 12, 9, 14, 9, 15, 11, 0, 17, 23, 10, 16, 7, 12, 12, 12, 15, 12, 5, 8, 18, 13, 10, 9, 7, 5, 9, 6, 1, 23, 6, 17, 20, 1, 14, 16, 11, 0, 12, 13, 7, 5, 5, 9, 18, 13, 15, 7, 11, 0, 16, 10, 11, 7, 15, 5, 12, 13, 8, 0, 10, 13, 0, 8, 8, 86, 96, 89, 93, 86, 80, 86, 82, 80, 78, 80, 81, 83, 82, 81, 81, 78, 75, 73, 75, 77, 93, 99, 99, 97, 101, 102, 101, 102, 101, 100, 99, 94, 89, 76, 69, 61, 75, 72, 70, 80, 67, 85, 90, 93, 93, 91, 91, 92, 89, 87, 84, 76, 64, 74, 72, 68, 73, 53, 55, 85, 89, 89, 91, 91, 90, 91, 92, 91, 89, 88, 87, 84, 82, 78, 80, 73, 71, 68, 66, 77, 81, 83, 80, 87, 90, 90, 90, 90, 88, 87, 84, 82, 81, 74, 76, 77, 69, 65, 53, 79, 83, 84, 84, 85, 86, 84, 84, 82, 81, 77, 72, 58, 62, 69, 61, 64, 62, 54, 50, 74, 64, 78, 73, 73, 72, 69, 74, 70, 63, 70, 72, 69, 65, 58, 63, 63, 50, 44, 43, 71, 64, 78, 78, 74, 76, 73, 72, 72, 70, 69, 66, 56, 55, 50, 51, 36, 40, 37, 28, 70, 75, 81, 84, 84, 81, 79, 77, 75, 69, 62, 59, 65, 70, 69, 49, 60, 42, 42, 39, 67, 71, 74, 75, 74, 72, 72, 72, 66, 70, 65, 58, 43, 51, 58, 55, 53, 47, 39, 33, 74, 79, 81, 79, 79, 79, 79, 79, 77, 74, 71, 66, 69, 70, 63, 58, 57, 50, 44, 28, 68, 70, 67, 68, 69, 68, 65, 66, 68, 67, 64, 58, 61, 63, 53, 55, 47, 39, 32, 19, 65, 73, 74, 72, 76, 70, 73, 61, 66, 70, 66, 61, 58, 59, 59, 49, 52, 45, 34, 26, 66, 70, 65, 67, 70, 70, 70, 72, 70, 67, 65, 55, 61, 63, 39, 57, 51, 45, 34, 22, 71, 68, 67, 67, 66, 74, 73, 73, 75, 74, 64, 59, 66, 56, 66, 47, 43, 36, 26, 21, 56, 62, 65, 66, 65, 64, 63, 62, 58, 55, 57, 58, 57, 55, 52, 44, 24, 20, 0, 4, 56, 63, 64, 57, 61, 59, 58, 56, 54, 52, 50, 55, 55, 34, 47, 37, 33, 28, 19, 3, 55, 61, 60, 61, 62, 61, 60, 59, 56, 47, 53, 53, 43, 48, 43, 32, 31, 24, 14, 15, 54, 57, 56, 59, 60, 58, 53, 52, 54, 51, 50, 51, 52, 41, 43, 31, 31, 22, 10, 7, 52, 58, 57, 56, 61, 62, 62, 62, 62, 60, 54, 55, 56, 49, 47, 36, 30, 27, 15, 13, 54, 56, 56, 55, 56, 54, 52, 47, 40, 48, 53, 53, 39, 44, 34, 26, 16, 9, 4, 7, 58, 57, 56, 58, 60, 58, 60, 59, 57, 54, 51, 56, 50, 46, 47, 38, 33, 25, 13, 9, 59, 62, 63, 62, 61, 62, 61, 59, 56, 50, 44, 46, 47, 43, 36, 16, 20, 18, 4, 8, 50, 47, 50, 50, 44, 44, 42, 35, 26, 28, 26, 28, 29, 24, 19, 12, 10, 13, 15, 10, 50, 46, 51, 55, 55, 53, 51, 53, 49, 47, 37, 40, 43, 40, 28, 26, 1, 9, 12, 1, 53, 53, 49, 51, 44, 46, 41, 39, 39, 28, 35, 35, 30, 29, 22, 10, 6, 11, 7, 9, 52, 48, 62, 59, 57, 58, 51, 54, 50, 46, 41, 44, 45, 32, 32, 15, 5, 11, 0, 12, 50, 49, 48, 52, 47, 47, 47, 46, 43, 42, 33, 38, 22, 11, 24, 7, 11, 9, 9, 4, 47, 42, 42, 43, 43, 40, 45, 47, 49, 50, 42, 32, 37, 33, 3, 13, 15, 6, 9, 13, 27, 40, 36, 31, 34, 38, 24, 32, 19, 19, 27, 19, 15, 14, 17, 6, 9, 10, 5, 6, 49, 52, 50, 49, 48, 47, 46, 41, 40, 36, 36, 28, 30, 30, 26, 14, 15, 8, 10, 9, 30, 40, 39, 34, 22, 23, 19, 26, 22, 25, 13, 20, 21, 15, 0, 5, 14, 13, 16, 0, 14, 33, 31, 30, 20, 24, 29, 33, 31, 27, 24, 12, 12, 0, 0, 10, 12, 13, 12, 16, 23, 41, 38, 30, 31, 31, 27, 29, 23, 16, 27, 21, 18, 18, 5, 16, 12, 13, 6, 9, 27, 41, 35, 37, 37, 37, 38, 39, 39, 35, 25, 29, 21, 15, 8, 15, 4, 14, 6, 4, 24, 42, 37, 35, 31, 30, 25, 27, 30, 30, 31, 26, 19, 4, 9, 14, 0, 17, 9, 12, 33, 43, 45, 41, 35, 31, 28, 26, 17, 7, 15, 8, 17, 12, 12, 4, 10, 7, 12, 9, 30, 39, 28, 30, 34, 30, 31, 29, 26, 31, 22, 14, 2, 2, 18, 4, 11, 12, 9, 12, 35, 38, 39, 39, 40, 32, 35, 38, 23, 27, 28, 26, 21, 17, 13, 13, 12, 13, 7, 7, 35, 28, 18, 31, 31, 31, 26, 20, 18, 9, 14, 3, 5, 12, 1, 8, 13, 9, 0, 0, 77, 82, 86, 87, 86, 86, 86, 87, 86, 85, 82, 80, 76, 73, 66, 59, 46, 52, 56, 52, 52, 57, 51, 62, 64, 65, 68, 68, 69, 69, 68, 66, 64, 65, 67, 66, 58, 56, 53, 36, 49, 37, 39, 42, 48, 51, 54, 54, 53, 52, 50, 48, 42, 40, 36, 37, 31, 32, 38, 34, 46, 49, 50, 53, 55, 55, 55, 55, 55, 54, 53, 50, 45, 46, 47, 40, 24, 40, 38, 27, 42, 47, 49, 50, 50, 51, 51, 50, 50, 48, 46, 44, 42, 42, 39, 39, 32, 31, 28, 25, 16, 21, 25, 29, 18, 28, 28, 25, 26, 29, 33, 31, 16, 27, 22, 18, 27, 20, 21, 13, 5, 24, 21, 27, 26, 22, 26, 29, 28, 29, 27, 27, 26, 22, 17, 16, 14, 8, 14, 10, 14, 21, 18, 17, 17, 8, 10, 19, 13, 7, 17, 17, 20, 16, 12, 8, 15, 12, 12, 18, 20, 23, 27, 28, 24, 26, 22, 20, 13, 21, 20, 21, 20, 17, 8, 16, 10, 13, 8, 12, 20, 18, 26, 23, 16, 23, 12, 10, 8, 5, 14, 13, 14, 10, 13, 15, 17, 14, 15, 18, 20, 22, 27, 12, 21, 12, 16, 21, 15, 14, 17, 12, 17, 15, 6, 17, 16, 14, 3, 5, 19, 22, 20, 22, 19, 23, 19, 22, 11, 22, 9, 23, 13, 14, 6, 14, 17, 18, 7, 17, 25, 14, 25, 24, 15, 22, 11, 22, 17, 9, 17, 14, 13, 10, 12, 14, 10, 14, 0, 4, 12, 7, 19, 22, 16, 8, 10, 0, 19, 6, 13, 5, 15, 17, 10, 13, 12, 7, 9, 6, 11, 10, 13, 24, 13, 20, 12, 12, 12, 5, 9, 10, 12, 12, 18, 17, 11, 8, 14, 11, 11, 14, 10, 18, 11, 13, 4, 3, 6, 14, 16, 14, 15, 11, 12, 12, 8, 0, 0, 12, 6, 15, 9, 13, 0, 12, 9, 2, 5, 12, 10, 5, 0, 11, 1, 16, 9, 18, 13, 7, 6, 16, 8, 17, 13, 14, 4, 4, 11, 11, 0, 9, 18, 6, 0, 6, 9, 18, 16, 10, 17, 9, 15, 21, 10, 10, 5, 14, 8, 11, 14, 8, 0, 9, 1, 6, 10, 6, 12, 2, 16, 19, 16, 10, 15, 14, 20, 8, 12, 9, 15, 15, 11, 17, 7, 16, 8, 5, 13, 15, 19, 1, 11, 6, 0, 16, 9, 14, 15, 14, 16, 14, 3, 13, 11, 11, 3, 10, 10, 1, 8, 12, 9, 14, 0, 14, 8, 9, 0, 11, 7, 14, 14, 2, 4, 6, 7, 11, 5, 12, 15, 13, 4, 16, 4, 0, 14, 6, 15, 3, 5, 11, 11, 16, 11, 14, 6, 11, 10, 14, 15, 5, 10, 14, 10, 19, 7, 17, 9, 12, 11, 7, 14, 18, 5, 15, 13, 16, 11, 4, 19, 11, 13, 13, 0, 8, 14, 0, 15, 12, 12, 0, 15, 14, 13, 16, 0, 13, 9, 14, 13, 9, 17, 15, 11, 14, 11, 10, 13, 14, 14, 10, 13, 8, 8, 10, 0, 9, 0, 16, 12, 7, 16, 19, 11, 0, 9, 13, 10, 8, 7, 10, 13, 1, 12, 9, 11, 1, 12, 8, 8, 6, 0, 22, 13, 8, 16, 6, 0, 12, 12, 11, 9, 0, 10, 13, 17, 11, 10, 15, 3, 17, 21, 12, 19, 20, 19, 16, 15, 8, 8, 10, 7, 0, 10, 8, 16, 10, 4, 11, 1, 16, 15, 13, 15, 16, 13, 17, 13, 7, 14, 3, 5, 16, 16, 15, 17, 5, 0, 9, 15, 17, 20, 20, 18, 13, 11, 10, 6, 8, 14, 11, 10, 8, 12, 10, 3, 13, 3, 11, 16, 7, 12, 20, 14, 17, 11, 16, 12, 7, 14, 9, 4, 8, 4, 11, 13, 11, 3, 13, 7, 5, 17, 9, 9, 16, 16, 1, 10, 0, 9, 17, 9, 7, 10, 9, 8, 18, 8, 8, 19, 9, 5, 15, 10, 17, 2, 5, 5, 8, 11, 14, 14, 11, 8, 0, 10, 17, 10, 18, 14, 10, 0, 12, 14, 13, 18, 9, 5, 6, 6, 20, 10, 7, 11, 4, 5, 18, 0, 9, 5, 18, 4, 16, 15, 11, 10, 11, 5, 7, 12, 6, 8, 13, 14, 6, 6, 4, 9, 4, 7, 15, 0, 0, 15, 15, 12, 9, 16, 11, 17, 13, 5, 10, 15, 9, 18, 9, 11, 14, 14, 11, 16, 6, 2, 2, 12, 5, 7, 13, 9, 0, 8, 7, 8, 8, 15, 6, 5, 18, 13, 15, 0, 11, 9, 3, 6, 9, 9, 12, 4, 13, 0, 5, 6, 15, 12, 11, 5, 15, 15, 9, 17, 14, 17, 1, 2, 7, 6, 0, 4, 12, 17, 15, 5, 5, 15, 10, 5, 5, 86, 91, 96, 99, 97, 97, 97, 97, 97, 96, 93, 91, 88, 84, 77, 69, 62, 58, 64, 62, 70, 72, 74, 80, 85, 85, 89, 89, 89, 89, 88, 86, 81, 77, 75, 75, 73, 73, 65, 56, 71, 66, 64, 67, 70, 75, 77, 78, 76, 76, 74, 72, 68, 66, 63, 58, 58, 45, 50, 43, 69, 70, 72, 76, 78, 78, 77, 77, 77, 76, 74, 72, 68, 68, 68, 62, 51, 57, 59, 47, 72, 77, 79, 80, 81, 82, 81, 81, 80, 79, 78, 76, 71, 63, 51, 52, 58, 52, 49, 44, 57, 59, 61, 66, 63, 66, 67, 67, 67, 67, 65, 63, 58, 51, 46, 41, 46, 48, 36, 30, 51, 62, 62, 62, 65, 66, 66, 67, 67, 67, 66, 65, 60, 52, 51, 44, 51, 35, 38, 31, 46, 47, 50, 45, 47, 47, 50, 50, 50, 49, 50, 49, 45, 40, 37, 33, 27, 26, 17, 17, 45, 53, 51, 50, 50, 48, 47, 45, 39, 45, 40, 40, 38, 25, 39, 32, 25, 17, 11, 8, 28, 38, 38, 36, 35, 36, 35, 29, 25, 25, 33, 32, 27, 20, 23, 22, 11, 9, 9, 17, 40, 38, 40, 44, 41, 41, 39, 37, 36, 35, 38, 43, 42, 34, 17, 29, 21, 23, 13, 11, 23, 32, 37, 41, 41, 42, 40, 40, 38, 32, 32, 37, 31, 32, 20, 25, 21, 23, 13, 21, 33, 29, 23, 32, 32, 37, 36, 35, 32, 29, 22, 21, 25, 26, 17, 23, 6, 12, 15, 9, 35, 38, 35, 16, 32, 27, 34, 28, 32, 25, 24, 20, 21, 18, 13, 18, 11, 13, 13, 11, 24, 31, 33, 34, 33, 33, 34, 33, 33, 29, 18, 16, 24, 8, 13, 9, 8, 3, 9, 3, 17, 16, 21, 16, 19, 22, 21, 22, 21, 20, 20, 18, 17, 8, 14, 11, 2, 13, 16, 8, 17, 1, 17, 15, 20, 17, 16, 19, 14, 16, 12, 15, 11, 0, 13, 4, 8, 9, 7, 11, 18, 20, 26, 24, 23, 22, 26, 23, 19, 20, 15, 16, 4, 17, 15, 14, 17, 13, 7, 3, 20, 14, 9, 15, 11, 15, 20, 19, 26, 23, 16, 10, 17, 11, 2, 17, 14, 5, 10, 14, 21, 24, 27, 27, 23, 27, 26, 27, 25, 22, 16, 21, 23, 10, 19, 10, 14, 11, 12, 16, 4, 19, 15, 0, 18, 17, 19, 8, 18, 14, 22, 8, 16, 14, 3, 16, 13, 12, 16, 12, 26, 27, 27, 26, 27, 23, 24, 19, 16, 11, 13, 18, 14, 11, 5, 8, 8, 15, 12, 7, 23, 18, 25, 22, 14, 22, 16, 15, 2, 4, 13, 0, 15, 13, 9, 9, 9, 2, 6, 13, 16, 12, 21, 12, 14, 14, 18, 6, 8, 13, 9, 4, 8, 16, 7, 4, 6, 15, 10, 2, 20, 0, 19, 14, 8, 9, 7, 4, 15, 10, 14, 14, 1, 8, 14, 11, 4, 2, 15, 11, 24, 25, 18, 4, 16, 15, 16, 8, 12, 4, 10, 12, 15, 0, 12, 3, 13, 14, 16, 4, 15, 16, 11, 8, 14, 18, 6, 11, 5, 5, 8, 12, 15, 1, 11, 0, 9, 7, 1, 14, 19, 3, 24, 18, 16, 19, 12, 12, 9, 17, 9, 15, 14, 14, 14, 11, 14, 15, 10, 19, 19, 10, 5, 20, 4, 4, 15, 12, 15, 13, 10, 12, 11, 15, 12, 14, 12, 8, 14, 10, 9, 8, 5, 8, 7, 4, 17, 19, 7, 17, 10, 13, 7, 12, 17, 1, 10, 16, 12, 9, 8, 14, 11, 9, 4, 11, 12, 15, 10, 20, 16, 11, 10, 13, 15, 13, 12, 14, 11, 12, 15, 13, 0, 2, 13, 10, 6, 18, 16, 3, 15, 0, 6, 10, 5, 14, 9, 12, 12, 9, 7, 6, 10, 6, 16, 7, 12, 9, 10, 16, 4, 11, 13, 6, 12, 16, 16, 7, 17, 1, 13, 5, 13, 1, 13, 13, 8, 12, 12, 14, 8, 0, 15, 5, 0, 2, 14, 11, 7, 5, 15, 6, 0, 10, 15, 18, 8, 14, 16, 14, 13, 8, 19, 1, 13, 18, 5, 0, 10, 11, 16, 15, 15, 4, 6, 14, 7, 9, 0, 9, 17, 10, 14, 16, 6, 15, 5, 18, 0, 9, 11, 14, 11, 3, 13, 15, 15, 0, 14, 0, 15, 12, 8, 12, 7, 5, 8, 17, 13, 11, 12, 16, 8, 16, 10, 8, 14, 18, 6, 11, 10, 7, 7, 11, 14, 13, 10, 22, 18, 15, 15, 14, 1, 8, 9, 8, 14, 11, 9, 12, 1, 19, 13, 9, 0, 15, 14, 18, 16, 8, 8, 13, 15, 11, 14, 12, 4, 4, 16, 10, 14, 11, 11, 16, 9, 19, 0, 11, 18, 12, 98, 105, 110, 112, 111, 111, 111, 111, 110, 109, 106, 105, 102, 98, 90, 81, 77, 73, 72, 72, 87, 85, 90, 94, 101, 103, 105, 106, 105, 104, 103, 101, 97, 92, 88, 88, 87, 87, 77, 71, 88, 82, 81, 85, 84, 90, 91, 91, 91, 89, 87, 85, 81, 78, 74, 63, 71, 62, 60, 57, 87, 87, 88, 93, 95, 95, 95, 95, 95, 93, 91, 88, 85, 83, 83, 79, 74, 63, 77, 64, 90, 95, 97, 99, 99, 100, 100, 99, 99, 97, 95, 93, 87, 80, 75, 76, 76, 66, 67, 60, 78, 79, 82, 86, 83, 87, 87, 83, 82, 81, 79, 76, 70, 60, 62, 63, 48, 63, 50, 39, 76, 85, 85, 83, 86, 85, 86, 87, 89, 88, 86, 84, 77, 76, 77, 63, 70, 60, 56, 48, 73, 78, 81, 77, 71, 75, 79, 76, 78, 78, 79, 77, 73, 67, 63, 61, 58, 46, 43, 38, 77, 86, 85, 82, 84, 83, 80, 67, 77, 77, 75, 78, 69, 73, 64, 68, 52, 51, 32, 14, 76, 68, 71, 70, 71, 76, 74, 75, 73, 75, 75, 74, 61, 54, 62, 52, 51, 46, 40, 28, 74, 74, 67, 74, 70, 70, 66, 61, 62, 66, 70, 72, 71, 62, 47, 56, 55, 46, 39, 32, 61, 62, 70, 75, 77, 76, 75, 74, 69, 63, 61, 64, 58, 56, 56, 51, 34, 42, 32, 20, 72, 70, 69, 69, 63, 73, 74, 75, 73, 71, 62, 48, 62, 59, 57, 56, 48, 44, 33, 25, 66, 75, 75, 68, 70, 70, 69, 72, 69, 68, 65, 63, 58, 57, 38, 51, 40, 31, 12, 16, 70, 74, 74, 75, 75, 76, 76, 76, 75, 75, 60, 62, 65, 59, 53, 51, 36, 36, 24, 15, 70, 71, 68, 66, 68, 68, 68, 64, 53, 55, 63, 65, 58, 52, 36, 38, 32, 26, 12, 6, 63, 58, 61, 59, 62, 63, 63, 61, 59, 52, 51, 57, 44, 45, 29, 36, 25, 11, 5, 19, 61, 67, 65, 66, 66, 66, 64, 62, 59, 55, 55, 53, 49, 47, 49, 36, 25, 27, 7, 12, 57, 60, 61, 62, 65, 65, 65, 65, 64, 61, 51, 50, 44, 35, 39, 39, 21, 13, 9, 5, 65, 66, 64, 63, 63, 64, 61, 60, 58, 58, 54, 50, 47, 47, 33, 36, 16, 12, 13, 14, 63, 66, 66, 67, 67, 66, 64, 62, 59, 59, 55, 40, 42, 29, 36, 34, 6, 15, 8, 20, 61, 56, 47, 45, 50, 51, 31, 46, 41, 37, 34, 39, 30, 28, 24, 21, 20, 6, 9, 15, 64, 62, 59, 57, 60, 55, 53, 57, 56, 51, 56, 49, 47, 41, 27, 28, 9, 11, 4, 10, 59, 58, 60, 59, 58, 57, 56, 53, 46, 37, 43, 30, 38, 34, 23, 14, 18, 12, 11, 12, 54, 52, 46, 46, 44, 47, 41, 43, 43, 20, 21, 32, 30, 15, 11, 12, 9, 14, 6, 19, 56, 54, 53, 58, 64, 56, 55, 57, 52, 50, 48, 46, 40, 38, 24, 22, 4, 5, 14, 12, 44, 54, 47, 49, 44, 34, 43, 45, 42, 30, 40, 38, 33, 25, 20, 15, 5, 3, 9, 5, 50, 52, 51, 47, 51, 47, 44, 40, 48, 42, 40, 30, 29, 24, 8, 16, 15, 13, 19, 8, 40, 35, 40, 40, 27, 29, 24, 29, 24, 18, 18, 23, 3, 13, 12, 15, 20, 16, 11, 15, 44, 44, 44, 46, 47, 48, 50, 49, 44, 38, 18, 32, 27, 11, 14, 12, 16, 3, 15, 1, 42, 41, 46, 44, 45, 45, 44, 44, 41, 37, 34, 26, 20, 14, 5, 10, 0, 13, 7, 7, 18, 43, 35, 26, 32, 33, 29, 21, 27, 28, 20, 15, 8, 13, 13, 18, 1, 11, 6, 8, 30, 25, 37, 31, 16, 27, 31, 27, 15, 14, 22, 10, 9, 9, 4, 0, 18, 14, 10, 12, 26, 35, 36, 15, 17, 24, 27, 25, 25, 18, 22, 18, 12, 18, 10, 10, 0, 10, 9, 0, 30, 39, 36, 38, 36, 34, 31, 30, 31, 25, 27, 24, 8, 12, 8, 17, 10, 10, 19, 18, 23, 28, 20, 29, 21, 25, 21, 26, 16, 17, 22, 10, 15, 10, 9, 18, 4, 13, 11, 10, 21, 28, 25, 24, 18, 24, 20, 23, 17, 17, 7, 19, 0, 2, 13, 5, 16, 6, 11, 18, 21, 28, 26, 27, 34, 33, 31, 27, 19, 10, 15, 15, 11, 16, 17, 12, 16, 14, 17, 14, 30, 35, 35, 32, 20, 21, 21, 16, 0, 23, 16, 14, 11, 0, 15, 11, 13, 9, 12, 7, 32, 29, 25, 28, 27, 26, 24, 9, 0, 14, 10, 14, 6, 8, 10, 12, 10, 10, 13, 16, 82, 78, 79, 83, 84, 83, 77, 82, 79, 80, 75, 74, 71, 67, 62, 47, 56, 54, 45, 51, 62, 72, 69, 69, 50, 44, 60, 58, 58, 54, 56, 58, 60, 61, 60, 58, 57, 54, 45, 47, 59, 63, 64, 65, 67, 67, 65, 65, 65, 63, 62, 60, 57, 55, 50, 49, 42, 43, 40, 45, 54, 56, 57, 57, 55, 54, 55, 54, 53, 51, 45, 42, 42, 38, 37, 37, 38, 36, 35, 27, 20, 33, 25, 22, 33, 34, 33, 30, 14, 26, 26, 26, 16, 26, 25, 21, 27, 29, 22, 15, 31, 34, 38, 35, 37, 35, 31, 34, 27, 26, 25, 22, 25, 29, 28, 26, 22, 5, 14, 13, 26, 20, 13, 12, 11, 15, 2, 7, 18, 16, 13, 21, 15, 13, 16, 8, 13, 3, 10, 21, 18, 14, 22, 12, 11, 8, 6, 16, 16, 14, 7, 14, 9, 15, 15, 15, 15, 9, 7, 17, 19, 19, 26, 18, 21, 19, 16, 19, 11, 10, 22, 1, 11, 19, 7, 16, 13, 16, 15, 20, 9, 20, 17, 23, 17, 19, 12, 17, 8, 19, 13, 4, 0, 16, 16, 8, 7, 12, 7, 17, 10, 22, 20, 10, 16, 15, 15, 14, 17, 7, 16, 7, 0, 14, 13, 12, 14, 10, 12, 13, 18, 21, 22, 16, 19, 16, 6, 20, 17, 21, 16, 11, 16, 12, 12, 12, 15, 8, 10, 7, 20, 20, 16, 22, 19, 14, 7, 7, 8, 15, 17, 14, 13, 13, 4, 15, 10, 0, 10, 11, 22, 22, 23, 13, 19, 19, 4, 15, 16, 1, 17, 7, 12, 14, 18, 6, 12, 14, 0, 10, 23, 22, 20, 22, 20, 23, 19, 22, 23, 18, 17, 15, 16, 6, 13, 3, 7, 15, 10, 9, 15, 10, 17, 15, 12, 16, 6, 15, 9, 10, 5, 15, 10, 11, 16, 11, 16, 16, 14, 3, 10, 23, 26, 17, 22, 20, 17, 12, 16, 18, 16, 12, 12, 8, 14, 13, 20, 16, 10, 20, 12, 21, 17, 16, 3, 1, 8, 17, 13, 7, 11, 4, 0, 10, 4, 8, 13, 4, 5, 14, 19, 16, 20, 18, 22, 18, 17, 19, 6, 9, 14, 8, 8, 11, 14, 2, 12, 15, 12, 2, 17, 23, 17, 18, 20, 19, 18, 4, 13, 10, 3, 17, 14, 6, 17, 11, 9, 12, 9, 13, 14, 11, 12, 15, 19, 13, 12, 9, 16, 10, 10, 14, 16, 12, 1, 13, 7, 13, 11, 9, 11, 14, 22, 15, 12, 4, 11, 15, 0, 14, 15, 10, 5, 11, 11, 14, 1, 15, 17, 13, 19, 9, 2, 16, 15, 1, 14, 11, 17, 6, 0, 21, 14, 2, 13, 14, 7, 15, 11, 11, 9, 14, 0, 8, 9, 9, 19, 10, 14, 14, 10, 7, 15, 9, 19, 17, 0, 12, 13, 13, 1, 13, 16, 21, 9, 9, 15, 17, 12, 8, 6, 16, 9, 3, 0, 8, 14, 18, 10, 20, 13, 19, 13, 7, 8, 22, 19, 13, 14, 15, 9, 12, 10, 14, 2, 18, 15, 4, 18, 6, 15, 16, 14, 9, 14, 7, 15, 14, 17, 8, 0, 10, 16, 13, 14, 6, 14, 2, 14, 7, 14, 16, 15, 0, 7, 0, 13, 8, 12, 16, 12, 19, 10, 10, 19, 18, 3, 14, 14, 11, 18, 16, 13, 15, 14, 11, 14, 13, 14, 14, 12, 1, 10, 15, 19, 13, 16, 6, 0, 6, 10, 11, 17, 21, 13, 17, 13, 16, 13, 14, 14, 8, 8, 2, 15, 18, 15, 14, 10, 3, 15, 11, 0, 14, 13, 8, 11, 16, 13, 9, 15, 10, 14, 0, 13, 13, 18, 11, 0, 7, 14, 13, 5, 20, 16, 13, 15, 17, 16, 4, 14, 18, 3, 3, 12, 12, 13, 8, 5, 15, 15, 9, 15, 13, 15, 9, 8, 6, 16, 11, 13, 10, 22, 9, 13, 11, 5, 16, 9, 20, 20, 2, 8, 16, 14, 8, 4, 13, 17, 3, 18, 16, 14, 4, 21, 10, 0, 9, 17, 13, 7, 11, 7, 16, 20, 11, 17, 5, 14, 15, 0, 15, 10, 8, 16, 14, 17, 10, 0, 10, 19, 8, 10, 16, 15, 9, 15, 14, 11, 17, 15, 13, 11, 7, 14, 11, 9, 6, 0, 15, 13, 3, 16, 15, 0, 12, 11, 12, 8, 6, 14, 9, 1, 0, 14, 18, 11, 9, 0, 11, 10, 14, 12, 7, 16, 0, 8, 20, 10, 13, 17, 12, 13, 5, 19, 17, 9, 13, 16, 17, 12, 15, 15, 12, 11, 10, 12, 13, 6, 10, 10, 16, 12, 21, 16, 17, 12, 16, 15, 7, 7, 17, 0, 6, 19, 6, 12, 12, 16, 12, 10, 14, 8, 8, 15, 14, 12, 11, 10, 15, 89, 86, 85, 91, 91, 91, 85, 89, 87, 88, 83, 82, 79, 75, 68, 61, 60, 60, 26, 55, 74, 83, 85, 82, 65, 67, 75, 75, 75, 74, 72, 69, 66, 67, 69, 67, 66, 65, 55, 57, 74, 81, 82, 83, 85, 85, 83, 83, 82, 81, 80, 79, 75, 72, 64, 67, 62, 49, 56, 54, 74, 78, 78, 79, 76, 76, 77, 77, 76, 75, 71, 68, 65, 62, 63, 62, 52, 40, 51, 46, 64, 68, 67, 70, 68, 69, 68, 67, 66, 65, 62, 59, 50, 47, 53, 51, 46, 40, 45, 32, 63, 64, 66, 65, 67, 67, 67, 67, 65, 64, 60, 56, 45, 34, 47, 46, 48, 41, 25, 23, 55, 51, 57, 60, 57, 59, 59, 59, 59, 57, 55, 52, 48, 48, 44, 46, 29, 39, 17, 23, 48, 56, 55, 52, 52, 50, 50, 51, 49, 46, 43, 39, 33, 36, 31, 17, 28, 21, 9, 17, 23, 41, 38, 37, 36, 35, 36, 37, 34, 34, 29, 27, 26, 25, 16, 17, 2, 8, 11, 17, 28, 32, 39, 38, 36, 37, 36, 33, 34, 29, 24, 14, 27, 27, 24, 0, 11, 14, 7, 14, 35, 38, 38, 33, 34, 35, 30, 27, 28, 26, 25, 26, 21, 18, 15, 20, 9, 8, 5, 14, 31, 33, 32, 31, 34, 33, 33, 33, 31, 30, 28, 26, 19, 12, 7, 15, 9, 13, 6, 9, 30, 30, 28, 26, 20, 8, 22, 20, 22, 18, 17, 18, 6, 10, 3, 15, 17, 15, 8, 11, 30, 29, 29, 30, 31, 30, 26, 19, 16, 15, 20, 19, 19, 17, 6, 6, 15, 16, 10, 0, 29, 28, 26, 25, 28, 28, 24, 23, 21, 16, 18, 10, 14, 17, 15, 13, 13, 7, 7, 6, 27, 25, 24, 22, 17, 11, 23, 15, 17, 14, 7, 14, 13, 18, 6, 11, 12, 14, 6, 13, 12, 15, 18, 12, 22, 13, 16, 15, 20, 17, 18, 8, 20, 5, 11, 15, 15, 0, 17, 5, 23, 24, 22, 26, 25, 22, 21, 23, 6, 18, 11, 14, 14, 15, 9, 10, 14, 12, 3, 3, 26, 27, 27, 27, 27, 22, 21, 20, 19, 20, 17, 17, 9, 7, 14, 19, 17, 11, 20, 1, 27, 30, 30, 29, 31, 24, 23, 18, 9, 20, 12, 14, 17, 13, 20, 19, 6, 9, 12, 12, 21, 18, 24, 17, 15, 21, 11, 12, 12, 15, 10, 10, 6, 14, 10, 10, 15, 6, 13, 13, 18, 22, 20, 17, 24, 19, 17, 13, 4, 18, 14, 17, 8, 15, 10, 11, 12, 2, 4, 4, 14, 0, 18, 14, 20, 5, 12, 0, 8, 9, 12, 10, 10, 9, 17, 19, 13, 1, 8, 19, 22, 20, 12, 13, 18, 11, 17, 15, 13, 12, 15, 18, 10, 0, 4, 16, 13, 9, 15, 12, 10, 15, 10, 10, 11, 3, 0, 12, 12, 4, 12, 8, 2, 6, 16, 7, 9, 13, 11, 11, 7, 13, 18, 7, 13, 20, 12, 9, 7, 12, 16, 8, 9, 11, 11, 6, 6, 5, 16, 10, 12, 17, 3, 12, 3, 8, 12, 10, 17, 18, 11, 6, 0, 13, 15, 15, 9, 3, 12, 11, 6, 8, 16, 11, 13, 10, 0, 10, 6, 15, 7, 12, 6, 1, 4, 16, 15, 17, 21, 6, 14, 15, 13, 13, 17, 15, 0, 12, 8, 15, 12, 0, 13, 16, 14, 12, 12, 16, 15, 12, 6, 4, 6, 10, 18, 11, 15, 10, 0, 3, 11, 4, 11, 12, 17, 18, 16, 15, 18, 16, 17, 8, 13, 10, 15, 13, 12, 9, 4, 18, 0, 9, 15, 9, 7, 10, 9, 7, 3, 0, 14, 9, 3, 19, 14, 0, 16, 3, 2, 4, 9, 13, 9, 6, 5, 21, 7, 21, 15, 17, 16, 14, 9, 13, 11, 13, 12, 15, 13, 10, 15, 0, 14, 17, 14, 6, 17, 6, 8, 19, 7, 10, 11, 9, 8, 11, 8, 20, 9, 11, 0, 16, 5, 0, 0, 8, 18, 19, 13, 15, 4, 11, 10, 11, 15, 7, 13, 9, 19, 9, 8, 11, 20, 12, 11, 17, 3, 6, 15, 0, 10, 8, 16, 12, 20, 15, 7, 17, 6, 4, 10, 17, 13, 6, 12, 11, 18, 1, 8, 9, 15, 17, 3, 10, 7, 6, 15, 5, 8, 18, 12, 4, 11, 13, 13, 20, 14, 11, 10, 5, 18, 15, 11, 5, 14, 8, 15, 7, 11, 15, 14, 18, 8, 16, 19, 13, 16, 9, 10, 13, 16, 5, 18, 5, 17, 14, 14, 11, 15, 4, 14, 16, 15, 3, 14, 12, 0, 15, 8, 15, 10, 15, 16, 8, 1, 8, 7, 0, 16, 6, 19, 16, 18, 2, 8, 13, 18, 13, 13, 13, 101, 97, 97, 103, 104, 103, 97, 102, 99, 101, 95, 95, 91, 88, 80, 68, 71, 70, 53, 66, 87, 96, 99, 95, 83, 82, 89, 91, 90, 90, 87, 85, 78, 71, 77, 77, 75, 76, 63, 66, 89, 96, 97, 98, 99, 100, 97, 97, 96, 95, 93, 91, 88, 83, 72, 78, 75, 59, 66, 65, 90, 94, 94, 95, 93, 93, 93, 94, 93, 91, 86, 83, 79, 70, 75, 75, 52, 67, 60, 57, 82, 86, 86, 88, 86, 87, 85, 85, 86, 85, 83, 81, 75, 67, 70, 70, 59, 53, 60, 46, 84, 86, 87, 87, 88, 88, 90, 88, 87, 85, 81, 77, 64, 55, 61, 64, 64, 62, 45, 37, 75, 78, 81, 82, 79, 81, 81, 80, 80, 78, 74, 68, 64, 68, 66, 64, 39, 55, 24, 39, 75, 87, 86, 83, 82, 81, 80, 81, 77, 77, 75, 74, 65, 61, 61, 45, 57, 48, 24, 33, 59, 79, 76, 75, 75, 73, 73, 70, 68, 63, 59, 57, 48, 56, 47, 53, 42, 33, 20, 22, 70, 79, 79, 79, 78, 78, 77, 76, 74, 72, 68, 63, 53, 60, 61, 40, 40, 35, 16, 13, 66, 72, 70, 65, 66, 64, 63, 63, 58, 58, 50, 38, 53, 52, 45, 38, 36, 30, 22, 0, 64, 68, 70, 70, 72, 72, 72, 71, 71, 68, 62, 61, 59, 52, 41, 40, 32, 11, 0, 5, 67, 72, 71, 73, 68, 65, 62, 59, 58, 58, 55, 40, 46, 40, 36, 33, 14, 8, 11, 5, 75, 76, 77, 76, 74, 74, 71, 66, 53, 59, 59, 47, 52, 55, 41, 46, 33, 27, 11, 7, 68, 65, 64, 66, 64, 64, 62, 60, 54, 48, 53, 51, 46, 39, 33, 27, 0, 22, 10, 12, 67, 65, 64, 63, 61, 59, 61, 61, 58, 58, 55, 47, 43, 39, 28, 26, 6, 8, 13, 12, 53, 56, 58, 59, 59, 51, 53, 50, 44, 47, 39, 42, 36, 31, 24, 25, 7, 15, 15, 9, 56, 57, 56, 53, 53, 54, 54, 53, 49, 48, 45, 39, 28, 27, 21, 15, 8, 13, 7, 12, 58, 59, 59, 59, 59, 58, 57, 54, 50, 46, 42, 29, 34, 28, 11, 17, 5, 5, 6, 4, 52, 53, 55, 53, 51, 47, 46, 40, 15, 27, 28, 29, 24, 21, 11, 15, 10, 12, 4, 5, 54, 57, 57, 51, 44, 40, 41, 41, 35, 33, 17, 27, 6, 21, 5, 7, 15, 13, 9, 12, 51, 47, 51, 45, 40, 32, 34, 30, 28, 20, 16, 17, 23, 20, 15, 16, 15, 18, 2, 18, 37, 39, 42, 36, 35, 19, 26, 22, 21, 19, 20, 18, 3, 17, 14, 13, 14, 11, 15, 14, 36, 42, 45, 45, 41, 40, 39, 35, 27, 22, 23, 27, 18, 18, 12, 12, 12, 16, 15, 19, 38, 33, 36, 28, 29, 28, 25, 25, 20, 16, 12, 15, 13, 2, 10, 14, 9, 12, 11, 7, 41, 44, 46, 37, 30, 33, 29, 22, 17, 19, 24, 14, 12, 2, 1, 12, 9, 14, 13, 0, 30, 34, 35, 32, 21, 21, 23, 19, 17, 15, 16, 15, 10, 13, 6, 13, 18, 12, 5, 1, 35, 27, 30, 26, 23, 23, 19, 22, 12, 19, 15, 4, 13, 14, 7, 17, 8, 13, 17, 16, 28, 29, 18, 20, 30, 22, 10, 14, 19, 16, 10, 17, 9, 11, 22, 17, 5, 4, 8, 11, 23, 26, 34, 19, 22, 19, 23, 22, 11, 7, 11, 13, 10, 6, 14, 13, 6, 19, 8, 12, 26, 18, 5, 24, 21, 22, 17, 15, 11, 16, 1, 11, 9, 11, 8, 13, 9, 17, 19, 11, 33, 34, 28, 30, 29, 18, 14, 17, 21, 18, 18, 2, 9, 10, 14, 17, 6, 16, 16, 20, 27, 29, 21, 27, 23, 24, 23, 20, 0, 1, 10, 12, 11, 15, 16, 5, 10, 17, 16, 20, 19, 23, 24, 14, 13, 20, 8, 18, 12, 15, 15, 9, 17, 16, 6, 15, 9, 12, 21, 20, 18, 21, 25, 27, 7, 22, 17, 9, 13, 19, 16, 13, 4, 1, 8, 0, 7, 10, 15, 13, 8, 18, 21, 19, 20, 13, 11, 13, 10, 15, 9, 17, 12, 14, 13, 6, 15, 15, 4, 11, 14, 24, 27, 23, 22, 13, 11, 14, 18, 1, 17, 15, 12, 11, 16, 14, 18, 10, 12, 1, 17, 25, 26, 18, 18, 12, 11, 10, 4, 10, 5, 14, 15, 15, 4, 15, 12, 15, 12, 17, 15, 17, 21, 10, 7, 9, 8, 16, 14, 13, 11, 11, 10, 15, 15, 6, 7, 11, 18, 14, 14, 27, 26, 17, 18, 1, 9, 1, 11, 10, 3, 10, 6, 9, 4, 8, 10, 12, 8, 14, 82, 86, 87, 89, 89, 91, 91, 91, 90, 89, 87, 85, 81, 77, 67, 43, 59, 55, 53, 56, 65, 69, 67, 67, 62, 62, 62, 61, 57, 55, 53, 55, 56, 55, 50, 51, 52, 45, 45, 41, 47, 51, 48, 52, 45, 50, 46, 47, 48, 47, 48, 46, 44, 41, 34, 31, 35, 33, 18, 27, 41, 49, 47, 48, 47, 47, 47, 47, 46, 46, 44, 39, 26, 18, 29, 22, 18, 23, 19, 16, 36, 37, 25, 34, 33, 32, 36, 38, 35, 30, 22, 29, 23, 13, 12, 18, 23, 10, 6, 12, 42, 44, 45, 45, 45, 46, 45, 45, 43, 41, 37, 29, 14, 22, 27, 22, 24, 21, 9, 15, 29, 31, 33, 33, 32, 31, 29, 30, 29, 24, 16, 22, 17, 17, 13, 15, 10, 14, 0, 9, 28, 28, 31, 33, 32, 28, 29, 29, 27, 25, 21, 21, 16, 10, 17, 11, 7, 6, 13, 13, 16, 16, 14, 20, 0, 11, 18, 6, 17, 18, 20, 0, 10, 10, 13, 2, 11, 10, 6, 19, 12, 21, 20, 16, 19, 9, 5, 4, 14, 16, 4, 9, 17, 10, 2, 11, 11, 12, 8, 4, 23, 18, 22, 15, 19, 7, 17, 18, 13, 16, 10, 13, 18, 14, 21, 8, 15, 14, 12, 10, 14, 7, 11, 16, 10, 0, 14, 11, 7, 17, 9, 10, 14, 11, 14, 14, 5, 8, 11, 16, 17, 16, 13, 18, 22, 21, 20, 18, 4, 11, 9, 14, 17, 14, 9, 15, 6, 7, 7, 15, 14, 10, 11, 16, 20, 13, 18, 4, 8, 17, 15, 15, 12, 12, 19, 8, 11, 20, 15, 19, 17, 10, 15, 5, 14, 10, 5, 7, 16, 0, 10, 16, 15, 13, 7, 12, 0, 17, 0, 14, 23, 20, 22, 14, 16, 15, 17, 16, 10, 10, 12, 18, 17, 18, 20, 19, 16, 10, 15, 0, 13, 13, 1, 2, 8, 12, 16, 19, 14, 16, 3, 10, 6, 13, 9, 11, 14, 12, 16, 14, 7, 16, 8, 13, 18, 11, 1, 1, 14, 18, 8, 7, 16, 14, 15, 1, 11, 19, 10, 14, 9, 11, 15, 17, 13, 22, 18, 7, 14, 17, 3, 17, 18, 10, 15, 10, 4, 16, 13, 13, 9, 13, 15, 10, 14, 14, 4, 13, 12, 11, 14, 13, 19, 13, 13, 10, 13, 6, 7, 9, 10, 15, 11, 17, 14, 19, 11, 17, 7, 12, 12, 15, 10, 16, 10, 14, 20, 17, 8, 9, 12, 0, 7, 7, 7, 16, 13, 7, 9, 23, 6, 7, 17, 12, 0, 13, 16, 15, 7, 6, 19, 14, 0, 11, 10, 14, 8, 11, 7, 10, 12, 15, 12, 20, 13, 11, 12, 12, 12, 0, 14, 11, 20, 1, 9, 13, 14, 18, 18, 15, 13, 3, 16, 15, 10, 15, 15, 12, 14, 14, 12, 10, 15, 10, 16, 8, 11, 3, 0, 13, 7, 16, 10, 7, 0, 10, 14, 12, 2, 17, 12, 11, 0, 14, 15, 7, 14, 13, 15, 11, 16, 13, 6, 16, 11, 0, 0, 3, 4, 16, 11, 0, 16, 4, 17, 13, 7, 12, 8, 16, 12, 15, 9, 19, 12, 15, 17, 5, 9, 0, 9, 12, 11, 0, 5, 1, 3, 15, 16, 15, 10, 10, 9, 14, 14, 17, 16, 20, 14, 14, 2, 22, 5, 11, 11, 12, 15, 16, 5, 14, 8, 14, 17, 14, 7, 10, 9, 13, 10, 8, 18, 15, 8, 6, 4, 17, 7, 9, 8, 8, 7, 13, 16, 11, 15, 11, 16, 11, 13, 9, 5, 4, 9, 8, 15, 0, 14, 15, 14, 8, 10, 15, 12, 15, 9, 0, 12, 12, 12, 12, 18, 5, 21, 14, 4, 13, 18, 0, 17, 4, 11, 6, 16, 14, 16, 16, 6, 21, 15, 9, 9, 13, 14, 7, 14, 18, 13, 16, 15, 11, 19, 18, 10, 8, 13, 15, 6, 12, 15, 14, 9, 11, 17, 9, 9, 17, 10, 14, 17, 16, 18, 1, 14, 0, 10, 13, 5, 11, 15, 4, 16, 4, 16, 19, 15, 7, 15, 11, 14, 14, 9, 0, 14, 14, 12, 15, 17, 4, 10, 14, 19, 2, 7, 14, 9, 0, 12, 12, 15, 18, 16, 14, 8, 16, 18, 13, 10, 9, 9, 11, 18, 14, 15, 12, 11, 3, 19, 14, 12, 8, 14, 10, 10, 16, 10, 9, 10, 14, 0, 11, 95, 98, 99, 103, 102, 104, 105, 104, 103, 102, 100, 98, 94, 90, 81, 67, 68, 66, 65, 66, 82, 88, 90, 87, 86, 87, 88, 88, 86, 85, 82, 79, 75, 71, 65, 63, 65, 61, 57, 52, 83, 81, 76, 80, 78, 76, 78, 78, 78, 77, 75, 73, 70, 65, 55, 56, 59, 54, 41, 41, 71, 78, 76, 76, 77, 76, 76, 76, 74, 72, 72, 68, 59, 58, 59, 55, 48, 44, 35, 22, 71, 71, 63, 71, 70, 70, 69, 70, 69, 67, 66, 63, 57, 48, 52, 53, 44, 38, 33, 28, 75, 79, 79, 79, 79, 79, 79, 79, 77, 76, 73, 69, 63, 60, 62, 56, 39, 44, 35, 30, 60, 63, 58, 61, 59, 59, 61, 62, 64, 64, 63, 61, 52, 36, 44, 39, 33, 27, 19, 6, 61, 65, 66, 67, 67, 66, 65, 64, 62, 60, 56, 51, 39, 47, 30, 33, 18, 20, 19, 14, 45, 48, 48, 43, 44, 43, 44, 43, 41, 41, 38, 30, 19, 19, 19, 16, 21, 15, 4, 9, 40, 39, 30, 36, 34, 25, 27, 33, 32, 33, 28, 23, 9, 23, 12, 13, 10, 0, 17, 21, 42, 45, 43, 41, 41, 41, 41, 41, 39, 36, 32, 25, 25, 21, 13, 9, 8, 13, 8, 20, 36, 33, 34, 35, 37, 38, 34, 31, 29, 27, 21, 23, 22, 19, 13, 14, 13, 12, 15, 20, 45, 48, 47, 46, 44, 46, 38, 39, 37, 33, 30, 23, 13, 17, 12, 3, 18, 17, 14, 16, 42, 42, 42, 40, 39, 38, 35, 32, 27, 8, 25, 25, 19, 18, 11, 3, 18, 15, 12, 16, 32, 31, 34, 32, 31, 32, 30, 28, 22, 17, 20, 16, 10, 13, 19, 6, 8, 3, 9, 16, 16, 24, 21, 28, 30, 23, 21, 17, 27, 24, 8, 19, 20, 11, 7, 12, 0, 20, 16, 7, 24, 12, 19, 5, 22, 11, 18, 12, 9, 9, 17, 15, 14, 20, 12, 15, 14, 7, 16, 11, 8, 12, 6, 15, 18, 18, 15, 8, 7, 17, 18, 7, 7, 14, 12, 11, 10, 3, 9, 11, 13, 19, 19, 25, 7, 18, 8, 12, 13, 7, 6, 6, 17, 16, 6, 5, 14, 15, 19, 8, 29, 24, 21, 25, 15, 14, 11, 9, 16, 14, 11, 13, 9, 0, 19, 8, 16, 3, 7, 7, 18, 21, 16, 26, 3, 17, 17, 5, 0, 0, 10, 16, 16, 17, 8, 16, 10, 8, 11, 14, 19, 22, 19, 1, 12, 6, 12, 2, 5, 10, 3, 18, 9, 8, 9, 0, 18, 7, 11, 15, 18, 17, 7, 19, 9, 15, 6, 15, 8, 14, 16, 4, 5, 11, 8, 1, 13, 5, 13, 17, 16, 16, 12, 19, 16, 11, 6, 11, 0, 20, 9, 18, 0, 12, 13, 14, 11, 19, 20, 10, 17, 15, 18, 13, 13, 16, 19, 8, 0, 6, 8, 2, 10, 2, 6, 16, 16, 13, 17, 11, 8, 7, 15, 4, 17, 16, 17, 9, 20, 9, 14, 5, 17, 13, 18, 3, 5, 11, 14, 16, 12, 18, 17, 15, 12, 7, 17, 17, 11, 20, 13, 14, 17, 19, 12, 20, 16, 17, 16, 15, 18, 17, 8, 10, 4, 14, 11, 11, 6, 18, 19, 17, 16, 21, 17, 17, 1, 17, 15, 15, 10, 12, 13, 13, 16, 8, 14, 12, 15, 13, 15, 12, 15, 12, 7, 13, 13, 15, 8, 17, 12, 5, 6, 21, 11, 18, 8, 16, 13, 21, 19, 15, 20, 14, 13, 15, 9, 17, 14, 16, 10, 16, 8, 15, 15, 1, 20, 17, 15, 16, 9, 13, 17, 13, 17, 14, 9, 12, 14, 0, 17, 9, 5, 14, 20, 16, 13, 15, 10, 15, 0, 11, 4, 11, 9, 15, 14, 17, 21, 15, 19, 5, 8, 5, 12, 8, 19, 10, 12, 14, 14, 8, 14, 7, 6, 3, 0, 14, 9, 4, 105, 109, 111, 114, 114, 115, 116, 115, 114, 113, 112, 110, 105, 100, 90, 75, 77, 75, 73, 74, 94, 99, 104, 100, 101, 100, 100, 100, 99, 98, 94, 91, 86, 84, 79, 76, 78, 74, 69, 60, 96, 96, 91, 93, 91, 91, 95, 96, 97, 95, 93, 91, 87, 82, 71, 70, 73, 69, 58, 55, 83, 88, 87, 88, 89, 89, 87, 87, 85, 82, 80, 80, 69, 69, 70, 67, 58, 54, 47, 29, 88, 88, 83, 90, 90, 89, 88, 89, 88, 85, 84, 81, 76, 64, 66, 68, 59, 54, 48, 39, 92, 96, 97, 97, 97, 97, 97, 97, 96, 94, 92, 88, 79, 72, 75, 69, 63, 55, 55, 39, 76, 82, 77, 78, 77, 74, 73, 76, 80, 80, 78, 75, 66, 54, 62, 52, 52, 38, 37, 3, 83, 87, 87, 89, 87, 87, 85, 84, 81, 79, 76, 73, 61, 66, 53, 50, 39, 33, 30, 13, 77, 77, 80, 75, 77, 76, 77, 78, 75, 72, 68, 62, 40, 46, 42, 42, 36, 26, 22, 10, 74, 79, 79, 78, 77, 77, 77, 77, 73, 68, 65, 65, 65, 61, 43, 40, 28, 13, 12, 8, 68, 73, 71, 70, 68, 68, 68, 67, 61, 61, 52, 53, 50, 50, 26, 32, 28, 22, 10, 12, 62, 75, 75, 76, 75, 73, 66, 64, 66, 53, 53, 55, 55, 42, 42, 25, 25, 8, 14, 14, 78, 80, 76, 74, 79, 74, 75, 72, 68, 61, 37, 38, 48, 43, 39, 31, 21, 17, 3, 10, 79, 77, 75, 77, 75, 71, 74, 68, 65, 60, 53, 49, 47, 36, 23, 7, 13, 6, 17, 16, 70, 70, 73, 70, 71, 72, 72, 69, 66, 62, 49, 50, 47, 42, 35, 28, 17, 17, 11, 9, 47, 65, 65, 67, 64, 56, 53, 57, 56, 53, 44, 47, 26, 23, 12, 13, 16, 19, 16, 15, 55, 47, 53, 56, 58, 48, 34, 51, 52, 48, 29, 36, 20, 17, 12, 14, 10, 10, 15, 3, 53, 48, 44, 47, 43, 34, 28, 32, 30, 23, 18, 18, 19, 13, 15, 3, 11, 16, 19, 19, 52, 45, 44, 43, 45, 22, 29, 33, 31, 27, 20, 5, 20, 18, 13, 16, 5, 16, 18, 12, 48, 46, 51, 47, 46, 41, 35, 32, 26, 24, 26, 12, 18, 18, 10, 16, 3, 8, 10, 18, 55, 54, 53, 52, 50, 47, 42, 35, 30, 35, 24, 8, 16, 12, 11, 14, 14, 14, 19, 13, 48, 51, 49, 49, 46, 45, 42, 36, 29, 7, 26, 16, 1, 14, 14, 4, 8, 10, 10, 18, 48, 47, 46, 39, 38, 33, 26, 14, 13, 20, 7, 10, 11, 15, 3, 13, 13, 7, 17, 9, 45, 50, 49, 50, 47, 38, 31, 32, 25, 19, 18, 14, 17, 5, 10, 17, 12, 17, 9, 0, 44, 39, 41, 32, 30, 36, 33, 28, 17, 27, 18, 12, 11, 12, 10, 10, 7, 12, 15, 20, 43, 43, 38, 36, 31, 30, 30, 29, 15, 9, 18, 4, 14, 14, 9, 12, 11, 2, 13, 12, 35, 39, 29, 25, 26, 9, 13, 13, 11, 13, 9, 9, 13, 16, 4, 20, 18, 17, 11, 17, 21, 34, 24, 28, 16, 18, 20, 15, 17, 19, 5, 18, 9, 18, 11, 19, 1, 19, 17, 18, 31, 30, 22, 16, 19, 22, 18, 23, 11, 11, 18, 15, 7, 14, 9, 16, 11, 19, 5, 7, 32, 20, 31, 3, 20, 14, 21, 17, 10, 11, 19, 13, 15, 12, 15, 15, 1, 18, 15, 13, 20, 31, 26, 24, 10, 16, 16, 12, 6, 0, 17, 7, 6, 11, 9, 2, 18, 19, 11, 18, 28, 25, 18, 21, 17, 12, 10, 12, 13, 16, 5, 9, 4, 9, 14, 10, 15, 18, 18, 8, 82, 87, 90, 92, 93, 93, 94, 94, 91, 90, 88, 85, 80, 73, 71, 75, 71, 68, 57, 59, 55, 51, 48, 51, 53, 57, 55, 56, 55, 55, 51, 45, 45, 46, 43, 40, 41, 29, 34, 26, 40, 40, 44, 44, 45, 48, 48, 48, 46, 45, 43, 40, 28, 32, 24, 26, 30, 16, 11, 22, 39, 43, 41, 36, 39, 39, 34, 37, 33, 33, 32, 26, 30, 33, 24, 9, 26, 7, 17, 21, 35, 32, 36, 33, 33, 31, 31, 30, 17, 26, 21, 24, 22, 13, 22, 17, 25, 11, 18, 12, 22, 33, 36, 33, 31, 28, 26, 28, 24, 21, 20, 19, 22, 11, 22, 16, 21, 19, 16, 22, 18, 19, 24, 21, 19, 18, 23, 20, 18, 19, 5, 15, 10, 9, 6, 16, 21, 11, 14, 22, 9, 19, 15, 19, 19, 19, 21, 15, 18, 18, 14, 18, 18, 6, 15, 18, 19, 16, 18, 5, 22, 12, 15, 9, 16, 16, 17, 17, 10, 21, 4, 13, 14, 10, 17, 9, 23, 7, 11, 17, 21, 13, 18, 16, 13, 11, 18, 16, 22, 14, 7, 14, 15, 11, 13, 17, 16, 20, 11, 6, 19, 3, 8, 16, 18, 12, 15, 11, 2, 7, 13, 18, 0, 12, 14, 19, 23, 6, 3, 13, 14, 21, 16, 13, 18, 11, 14, 13, 16, 17, 14, 13, 15, 17, 15, 19, 15, 9, 12, 8, 8, 10, 15, 10, 20, 18, 13, 13, 17, 10, 0, 12, 12, 11, 14, 12, 8, 8, 6, 18, 18, 16, 10, 13, 16, 16, 17, 18, 13, 14, 19, 6, 2, 12, 5, 9, 19, 15, 17, 14, 5, 18, 12, 17, 15, 16, 17, 20, 4, 16, 10, 15, 0, 20, 16, 11, 4, 0, 13, 13, 19, 17, 12, 18, 18, 15, 15, 13, 14, 20, 13, 14, 4, 1, 11, 7, 18, 14, 16, 13, 19, 15, 7, 15, 12, 20, 19, 9, 17, 19, 15, 16, 18, 16, 12, 22, 9, 17, 10, 12, 3, 5, 16, 0, 19, 19, 12, 15, 22, 15, 17, 14, 1, 13, 4, 13, 18, 4, 17, 12, 18, 15, 17, 17, 18, 12, 18, 17, 19, 7, 17, 20, 19, 16, 17, 6, 18, 15, 6, 11, 9, 13, 10, 19, 15, 15, 14, 9, 11, 7, 9, 5, 18, 5, 23, 10, 11, 21, 17, 18, 16, 15, 17, 18, 20, 18, 14, 16, 14, 19, 12, 16, 9, 17, 7, 17, 22, 8, 15, 10, 7, 6, 13, 15, 18, 22, 18, 18, 16, 19, 19, 17, 23, 13, 19, 18, 13, 10, 17, 8, 14, 21, 12, 19, 16, 21, 10, 21, 16, 11, 15, 17, 25, 15, 16, 10, 15, 14, 3, 17, 93, 98, 101, 103, 105, 104, 106, 105, 103, 102, 99, 96, 90, 82, 84, 87, 83, 77, 70, 71, 73, 76, 79, 77, 78, 78, 78, 77, 76, 76, 73, 70, 64, 70, 65, 69, 58, 63, 51, 48, 65, 72, 74, 74, 75, 75, 74, 72, 70, 68, 58, 55, 63, 60, 62, 54, 56, 51, 36, 31, 59, 62, 59, 56, 55, 55, 53, 55, 42, 38, 40, 37, 39, 46, 41, 38, 29, 23, 19, 16, 61, 63, 63, 62, 61, 60, 57, 56, 51, 49, 38, 44, 47, 51, 39, 49, 40, 34, 19, 13, 54, 50, 48, 49, 46, 47, 43, 43, 40, 35, 40, 35, 32, 40, 22, 31, 24, 23, 20, 18, 32, 36, 40, 39, 35, 36, 36, 36, 32, 30, 28, 31, 13, 21, 21, 17, 8, 8, 18, 17, 35, 38, 39, 39, 38, 38, 37, 35, 29, 23, 30, 26, 12, 9, 15, 16, 15, 14, 3, 8, 17, 20, 20, 22, 18, 22, 8, 10, 16, 17, 17, 12, 20, 15, 3, 13, 15, 9, 12, 0, 13, 18, 23, 13, 2, 21, 18, 19, 16, 17, 18, 14, 11, 22, 2, 15, 10, 9, 14, 19, 21, 6, 20, 16, 17, 20, 24, 19, 25, 24, 13, 20, 20, 0, 7, 7, 9, 10, 18, 18, 16, 3, 9, 11, 20, 11, 0, 9, 4, 4, 17, 17, 13, 12, 11, 9, 12, 14, 11, 18, 26, 19, 17, 19, 16, 6, 19, 14, 10, 14, 0, 20, 3, 12, 17, 20, 10, 10, 15, 0, 23, 20, 16, 10, 20, 4, 17, 17, 17, 1, 3, 14, 1, 12, 22, 11, 13, 13, 20, 8, 12, 10, 9, 17, 19, 8, 12, 16, 16, 16, 17, 19, 10, 20, 15, 15, 16, 12, 5, 19, 16, 17, 20, 15, 19, 15, 12, 16, 21, 12, 14, 19, 6, 17, 12, 15, 7, 11, 14, 10, 0, 26, 24, 19, 16, 9, 10, 16, 18, 5, 21, 13, 14, 16, 16, 14, 14, 14, 13, 7, 22, 3, 6, 18, 18, 12, 19, 16, 20, 8, 17, 4, 6, 12, 16, 13, 2, 11, 14, 19, 16, 22, 20, 16, 20, 18, 14, 13, 5, 13, 15, 10, 11, 17, 12, 21, 9, 14, 1, 13, 4, 8, 23, 14, 16, 16, 11, 12, 2, 18, 6, 16, 12, 22, 17, 9, 20, 1, 0, 5, 0, 8, 15, 14, 9, 15, 8, 0, 16, 16, 16, 18, 16, 13, 4, 19, 16, 11, 13, 4, 14, 8, 16, 5, 5, 18, 14, 11, 19, 11, 12, 20, 20, 20, 18, 14, 14, 10, 14, 3, 12, 3, 14, 10, 17, 16, 17, 17, 13, 12, 12, 1, 8, 16, 17, 14, 12, 8, 18, 21, 11, 17, 13, 8, 12, 20, 15, 11, 13, 9, 12, 7, 18, 12, 8, 5, 7, 16, 16, 15, 12, 14, 16, 12, 18, 9, 18, 18, 13, 16, 16, 17, 13, 8, 10, 14, 21, 15, 18, 16, 22, 15, 16, 12, 19, 12, 19, 4, 16, 10, 14, 5, 3, 16, 6, 4, 9, 8, 20, 21, 12, 19, 22, 14, 11, 4, 0, 13, 11, 1, 12, 10, 13, 17, 16, 13, 11, 15, 5, 8, 11, 6, 17, 19, 16, 13, 16, 16, 18, 11, 4, 16, 21, 16, 15, 13, 12, 17, 14, 8, 106, 110, 114, 117, 118, 117, 119, 118, 115, 114, 111, 108, 100, 84, 99, 99, 93, 85, 81, 81, 89, 91, 95, 92, 95, 92, 91, 92, 91, 90, 89, 85, 82, 88, 80, 83, 75, 71, 69, 63, 87, 94, 97, 97, 98, 98, 98, 97, 96, 93, 85, 82, 85, 82, 76, 63, 70, 66, 52, 34, 83, 91, 89, 87, 87, 85, 86, 85, 78, 77, 66, 70, 63, 70, 59, 61, 53, 48, 38, 21, 87, 91, 93, 92, 93, 91, 89, 88, 84, 80, 76, 79, 77, 68, 57, 71, 60, 44, 31, 21, 85, 85, 85, 84, 81, 79, 72, 75, 67, 66, 71, 72, 51, 65, 57, 58, 31, 35, 25, 5, 64, 69, 71, 69, 68, 62, 64, 65, 66, 64, 56, 53, 47, 49, 51, 38, 24, 24, 1, 8, 81, 83, 82, 82, 83, 81, 79, 77, 61, 65, 60, 61, 61, 59, 50, 51, 32, 25, 9, 6, 67, 61, 69, 66, 64, 65, 63, 63, 60, 58, 52, 44, 39, 42, 36, 30, 16, 17, 19, 18, 57, 59, 54, 52, 51, 48, 53, 57, 50, 50, 50, 43, 40, 38, 20, 27, 9, 17, 14, 17, 69, 71, 71, 70, 69, 68, 66, 63, 59, 54, 47, 44, 46, 49, 30, 29, 17, 14, 14, 10, 58, 61, 56, 47, 56, 56, 43, 49, 43, 42, 38, 44, 41, 44, 16, 12, 5, 19, 10, 10, 68, 68, 66, 64, 53, 51, 56, 56, 56, 52, 43, 32, 37, 43, 21, 19, 18, 11, 14, 18, 54, 59, 60, 61, 60, 58, 53, 38, 36, 39, 47, 43, 38, 42, 24, 10, 18, 9, 16, 16, 45, 50, 49, 48, 50, 46, 38, 42, 41, 32, 26, 22, 16, 41, 20, 8, 17, 17, 17, 12, 53, 56, 54, 52, 52, 51, 45, 42, 45, 37, 31, 31, 27, 41, 6, 20, 5, 11, 7, 13, 25, 31, 16, 33, 30, 22, 29, 34, 34, 28, 6, 16, 11, 40, 10, 12, 12, 18, 19, 16, 21, 31, 14, 25, 32, 22, 21, 16, 16, 24, 10, 13, 18, 40, 11, 11, 19, 11, 8, 15, 29, 25, 32, 29, 22, 23, 17, 5, 8, 23, 18, 13, 17, 40, 14, 7, 13, 1, 12, 11, 13, 24, 34, 24, 23, 12, 16, 18, 6, 9, 15, 12, 14, 40, 2, 14, 21, 16, 14, 15, 25, 30, 15, 21, 21, 14, 20, 10, 13, 11, 9, 15, 5, 39, 8, 18, 12, 15, 12, 17, 18, 21, 16, 16, 11, 21, 16, 16, 19, 20, 10, 13, 21, 39, 7, 4, 18, 16, 11, 16, 22, 14, 22, 13, 20, 21, 19, 17, 10, 17, 15, 21, 15, 39, 14, 17, 13, 12, 17, 17, 21, 13, 23, 18, 18, 17, 11, 12, 16, 9, 10, 10, 8, 39, 10, 4, 9, 5, 1, 15, 25, 20, 18, 8, 23, 22, 4, 18, 13, 11, 16, 15, 7, 38, 15, 17, 20, 16, 18, 18, 12, 17, 17, 17, 18, 18, 22, 20, 9, 20, 14, 0, 1, 38, 11, 4, 12, 20, 21, 9, 85, 88, 91, 93, 93, 93, 92, 90, 90, 88, 82, 78, 77, 75, 64, 59, 51, 70, 54, 60, 52, 48, 50, 55, 51, 50, 50, 48, 47, 45, 48, 47, 45, 43, 34, 32, 32, 37, 24, 30, 41, 47, 31, 20, 37, 36, 34, 28, 19, 25, 30, 30, 30, 21, 29, 21, 15, 13, 17, 4, 40, 35, 33, 36, 39, 40, 39, 39, 32, 27, 24, 28, 28, 24, 18, 23, 16, 17, 16, 12, 41, 36, 35, 29, 28, 26, 22, 30, 29, 28, 28, 18, 23, 19, 23, 18, 16, 18, 13, 14, 16, 27, 27, 22, 26, 25, 22, 24, 23, 24, 22, 24, 20, 9, 18, 18, 13, 15, 14, 12, 23, 27, 18, 26, 24, 24, 20, 7, 18, 23, 11, 20, 15, 16, 18, 16, 15, 10, 12, 18, 13, 13, 17, 21, 12, 18, 12, 0, 16, 18, 20, 17, 18, 10, 11, 8, 12, 12, 16, 19, 20, 12, 18, 12, 9, 14, 10, 15, 14, 16, 9, 1, 0, 10, 13, 8, 16, 12, 15, 19, 8, 13, 15, 13, 18, 21, 12, 16, 14, 23, 17, 16, 23, 15, 11, 10, 6, 11, 20, 8, 14, 13, 14, 15, 11, 11, 17, 21, 12, 12, 13, 8, 17, 13, 6, 14, 8, 21, 16, 7, 16, 12, 21, 23, 11, 22, 15, 22, 13, 4, 18, 20, 16, 15, 9, 20, 14, 12, 6, 8, 15, 13, 1, 2, 20, 21, 17, 6, 16, 8, 12, 17, 13, 20, 5, 18, 6, 16, 8, 16, 21, 23, 12, 18, 11, 15, 6, 20, 11, 12, 9, 12, 11, 15, 16, 17, 18, 8, 1, 15, 19, 18, 14, 18, 16, 13, 21, 12, 14, 7, 9, 16, 14, 15, 17, 15, 11, 12, 20, 16, 18, 16, 21, 17, 16, 15, 18, 7, 11, 19, 14, 16, 17, 14, 18, 0, 13, 20, 21, 20, 13, 15, 14, 17, 10, 18, 12, 5, 17, 22, 14, 11, 18, 4, 15, 10, 23, 15, 16, 12, 20, 15, 19, 7, 12, 11, 1, 20, 12, 18, 12, 15, 10, 22, 12, 18, 17, 8, 18, 16, 10, 12, 7, 8, 15, 7, 10, 6, 17, 0, 19, 8, 5, 12, 15, 7, 11, 18, 16, 13, 3, 11, 17, 19, 13, 11, 8, 11, 9, 19, 17, 8, 15, 18, 15, 18, 15, 5, 17, 16, 8, 13, 18, 11, 13, 8, 11, 6, 19, 14, 18, 13, 14, 19, 10, 19, 11, 17, 9, 18, 14, 18, 15, 14, 12, 18, 16, 10, 20, 15, 0, 13, 14, 18, 3, 15, 10, 13, 17, 18, 99, 102, 105, 107, 107, 106, 106, 105, 104, 102, 96, 90, 90, 89, 80, 74, 70, 82, 68, 70, 77, 80, 81, 83, 82, 83, 84, 82, 81, 80, 72, 73, 75, 63, 67, 64, 63, 64, 42, 41, 75, 66, 63, 63, 72, 72, 64, 67, 64, 58, 61, 60, 56, 49, 58, 52, 41, 34, 22, 18, 67, 57, 58, 61, 63, 63, 63, 62, 57, 48, 53, 48, 47, 46, 41, 41, 17, 23, 22, 13, 65, 63, 59, 55, 57, 57, 55, 54, 54, 47, 50, 49, 31, 46, 41, 22, 17, 21, 8, 21, 55, 59, 61, 60, 59, 58, 58, 57, 47, 47, 48, 40, 42, 29, 32, 18, 21, 16, 8, 4, 55, 54, 55, 56, 53, 53, 49, 46, 42, 36, 38, 38, 26, 30, 24, 18, 13, 14, 10, 1, 34, 44, 41, 40, 38, 42, 28, 30, 32, 27, 26, 30, 18, 24, 20, 15, 14, 6, 14, 14, 38, 18, 30, 21, 28, 23, 26, 23, 19, 24, 14, 18, 23, 12, 15, 18, 21, 17, 12, 9, 23, 27, 16, 24, 19, 17, 18, 22, 16, 16, 12, 18, 16, 18, 9, 17, 16, 19, 19, 15, 20, 22, 15, 19, 11, 18, 20, 14, 14, 19, 17, 9, 19, 8, 10, 13, 16, 19, 12, 15, 21, 26, 10, 17, 17, 2, 8, 21, 21, 21, 6, 16, 14, 13, 19, 15, 14, 18, 8, 0, 22, 26, 27, 25, 16, 17, 20, 14, 19, 19, 5, 23, 14, 11, 19, 18, 15, 17, 9, 15, 19, 15, 21, 20, 20, 12, 14, 12, 16, 16, 13, 12, 20, 21, 14, 18, 18, 7, 16, 12, 19, 19, 22, 17, 25, 18, 10, 19, 20, 11, 22, 8, 15, 21, 14, 15, 19, 18, 17, 14, 14, 20, 17, 14, 9, 21, 10, 16, 19, 16, 19, 16, 19, 6, 15, 16, 17, 18, 10, 16, 22, 19, 23, 17, 19, 17, 4, 17, 0, 8, 21, 3, 14, 18, 23, 1, 17, 0, 20, 9, 14, 14, 13, 8, 21, 10, 17, 16, 11, 15, 15, 12, 15, 17, 17, 14, 18, 21, 15, 20, 12, 13, 19, 17, 10, 16, 11, 18, 15, 4, 11, 8, 17, 14, 13, 17, 10, 21, 16, 18, 17, 17, 19, 18, 17, 15, 13, 14, 16, 20, 4, 16, 18, 14, 17, 10, 7, 11, 12, 18, 20, 20, 13, 19, 9, 17, 21, 6, 20, 9, 15, 19, 20, 10, 15, 22, 14, 16, 16, 20, 17, 21, 14, 5, 11, 0, 6, 23, 21, 5, 10, 21, 19, 0, 20, 17, 24, 13, 8, 22, 108, 111, 115, 116, 116, 116, 115, 113, 112, 110, 104, 99, 97, 97, 89, 87, 80, 88, 80, 75, 87, 92, 92, 94, 94, 95, 95, 93, 91, 89, 82, 84, 83, 77, 80, 76, 75, 71, 58, 50, 89, 81, 70, 72, 83, 84, 74, 77, 68, 73, 72, 70, 72, 67, 68, 62, 45, 46, 30, 24, 83, 78, 77, 80, 81, 80, 79, 78, 58, 70, 62, 64, 53, 63, 56, 55, 39, 37, 17, 22, 83, 82, 77, 72, 73, 70, 67, 59, 60, 69, 65, 60, 56, 62, 48, 49, 40, 28, 22, 18, 71, 76, 79, 79, 76, 76, 71, 70, 65, 69, 62, 56, 59, 48, 48, 36, 28, 24, 24, 18, 75, 75, 76, 77, 75, 75, 72, 68, 61, 64, 61, 53, 56, 51, 49, 32, 29, 23, 9, 12, 62, 63, 66, 67, 63, 62, 54, 61, 55, 51, 52, 50, 42, 26, 22, 19, 21, 6, 14, 14, 69, 66, 66, 64, 62, 62, 61, 63, 58, 55, 53, 47, 37, 36, 32, 25, 15, 17, 15, 18, 52, 51, 57, 48, 55, 51, 41, 43, 45, 37, 33, 23, 11, 18, 13, 14, 7, 18, 7, 16, 54, 46, 48, 50, 48, 44, 29, 43, 38, 21, 22, 18, 23, 23, 10, 11, 20, 22, 9, 18, 49, 49, 43, 50, 45, 42, 47, 46, 35, 39, 25, 28, 22, 19, 13, 14, 8, 15, 10, 6, 43, 46, 47, 51, 50, 50, 41, 27, 36, 29, 28, 20, 17, 23, 15, 18, 13, 19, 5, 6, 44, 46, 45, 46, 44, 41, 36, 34, 21, 16, 19, 15, 13, 21, 15, 20, 17, 15, 18, 12, 38, 31, 36, 34, 33, 23, 23, 13, 20, 11, 21, 18, 17, 19, 15, 18, 17, 4, 3, 7, 34, 26, 25, 16, 15, 16, 17, 12, 9, 17, 19, 14, 3, 16, 17, 0, 22, 9, 15, 19, 15, 29, 22, 25, 12, 20, 19, 13, 16, 20, 14, 15, 21, 0, 17, 16, 6, 10, 2, 10, 23, 27, 14, 21, 23, 13, 20, 24, 16, 12, 15, 13, 18, 18, 13, 12, 0, 19, 22, 11, 20, 19, 24, 17, 11, 16, 20, 21, 21, 10, 21, 21, 12, 13, 2, 19, 19, 19, 18, 10, 14, 28, 21, 21, 19, 18, 18, 9, 12, 3, 5, 14, 18, 18, 18, 6, 4, 18, 16, 11, 20, 20, 12, 14, 17, 8, 20, 17, 13, 11, 10, 14, 7, 7, 16, 19, 9, 9, 17, 17, 87, 88, 85, 85, 87, 86, 86, 85, 83, 78, 68, 71, 77, 76, 59, 68, 62, 58, 55, 40, 51, 48, 45, 51, 35, 46, 44, 45, 28, 40, 45, 41, 39, 39, 35, 24, 27, 16, 22, 21, 39, 35, 39, 38, 34, 32, 41, 38, 33, 36, 34, 30, 15, 28, 24, 16, 18, 22, 21, 7, 43, 43, 42, 40, 39, 38, 37, 33, 24, 15, 17, 26, 24, 22, 21, 23, 19, 23, 18, 13, 24, 25, 25, 12, 27, 20, 13, 22, 17, 23, 11, 15, 19, 11, 15, 19, 18, 13, 13, 9, 14, 23, 24, 16, 24, 21, 23, 12, 18, 21, 26, 17, 16, 3, 15, 11, 16, 13, 9, 20, 17, 29, 18, 22, 9, 11, 15, 17, 21, 20, 16, 16, 14, 16, 15, 8, 16, 12, 13, 15, 19, 17, 18, 26, 25, 8, 13, 9, 16, 12, 8, 11, 7, 16, 15, 9, 17, 18, 19, 16, 13, 13, 20, 11, 20, 19, 13, 19, 10, 13, 7, 19, 11, 17, 19, 16, 16, 21, 12, 20, 11, 14, 19, 15, 21, 15, 20, 10, 15, 18, 10, 16, 15, 13, 19, 9, 18, 13, 7, 18, 19, 12, 12, 17, 6, 18, 22, 20, 9, 22, 16, 16, 19, 7, 19, 9, 14, 18, 21, 19, 14, 16, 17, 17, 23, 17, 15, 18, 4, 15, 16, 6, 15, 18, 9, 13, 16, 15, 14, 3, 19, 18, 11, 12, 14, 22, 17, 9, 10, 10, 18, 23, 1, 18, 16, 8, 16, 7, 13, 21, 15, 12, 1, 22, 14, 16, 15, 22, 18, 19, 20, 19, 25, 14, 18, 13, 22, 20, 18, 18, 15, 13, 25, 13, 18, 18, 18, 13, 15, 17, 15, 9, 13, 14, 7, 13, 18, 12, 16, 10, 18, 17, 11, 15, 22, 18, 18, 11, 14, 16, 9, 22, 6, 14, 11, 11, 16, 24, 6, 13, 17, 16, 17, 16, 16, 20, 12, 13, 20, 21, 2, 20, 14, 18, 18, 16, 2, 14, 19, 19, 73, 98, 95, 94, 96, 95, 95, 95, 92, 88, 79, 81, 87, 85, 66, 76, 71, 67, 65, 53, 63, 60, 66, 68, 62, 64, 58, 63, 54, 39, 50, 49, 46, 44, 40, 36, 30, 22, 16, 24, 54, 42, 52, 39, 39, 42, 48, 42, 37, 42, 43, 23, 42, 38, 30, 24, 20, 18, 14, 15, 51, 60, 56, 55, 53, 49, 49, 45, 45, 44, 44, 41, 32, 26, 27, 26, 22, 22, 8, 14, 33, 29, 20, 31, 29, 13, 28, 36, 32, 27, 30, 11, 24, 18, 21, 12, 17, 19, 12, 16, 20, 24, 30, 22, 22, 21, 18, 23, 24, 12, 16, 15, 15, 15, 13, 17, 16, 10, 12, 21, 15, 25, 25, 21, 19, 16, 22, 24, 16, 15, 16, 17, 15, 16, 16, 18, 18, 19, 18, 12, 12, 22, 21, 11, 24, 15, 17, 18, 6, 14, 9, 17, 18, 16, 11, 15, 13, 10, 14, 10, 19, 18, 22, 7, 17, 18, 6, 21, 22, 10, 21, 14, 15, 10, 17, 14, 23, 17, 16, 16, 14, 16, 12, 22, 24, 21, 20, 13, 17, 19, 13, 14, 15, 8, 9, 18, 5, 6, 11, 21, 25, 21, 24, 12, 0, 20, 18, 13, 19, 22, 20, 22, 18, 19, 19, 16, 10, 15, 11, 16, 25, 17, 21, 20, 17, 19, 23, 10, 18, 23, 19, 16, 14, 7, 19, 11, 7, 19, 18, 5, 11, 12, 20, 11, 18, 13, 15, 15, 19, 10, 19, 20, 19, 15, 5, 18, 17, 19, 21, 15, 16, 13, 19, 12, 19, 20, 21, 12, 22, 12, 10, 18, 20, 18, 24, 13, 13, 16, 12, 13, 14, 16, 8, 17, 12, 20, 23, 19, 9, 9, 14, 16, 14, 16, 23, 21, 18, 13, 0, 20, 18, 12, 18, 11, 16, 15, 19, 19, 19, 15, 16, 8, 12, 16, 18, 10, 10, 18, 23, 18, 20, 4, 10, 21, 6, 14, 20, 17, 20, 20, 6, 21, 13, 16, 19, 23, 17, 14, 5, 6, 59, 105, 113, 108, 108, 109, 109, 108, 106, 101, 84, 96, 101, 97, 85, 88, 83, 80, 73, 64, 35, 87, 79, 83, 93, 87, 82, 85, 78, 81, 74, 84, 64, 69, 69, 60, 57, 52, 42, 35, 26, 79, 71, 81, 67, 75, 74, 65, 65, 72, 57, 68, 59, 44, 56, 47, 34, 29, 19, 16, 19, 84, 82, 78, 72, 72, 71, 69, 72, 72, 60, 53, 46, 39, 38, 35, 25, 22, 15, 18, 20, 65, 67, 67, 70, 66, 65, 64, 63, 60, 57, 49, 44, 41, 23, 14, 16, 22, 13, 11, 9, 59, 44, 58, 62, 60, 59, 57, 57, 53, 38, 38, 32, 19, 12, 22, 0, 5, 13, 19, 19, 66, 65, 63, 54, 51, 40, 58, 56, 50, 47, 47, 35, 14, 19, 10, 20, 18, 19, 20, 13, 60, 60, 50, 34, 38, 44, 36, 45, 42, 35, 28, 22, 17, 18, 2, 18, 12, 20, 13, 10, 55, 55, 56, 51, 49, 45, 42, 35, 38, 32, 35, 25, 20, 20, 16, 21, 16, 11, 18, 19, 44, 43, 48, 45, 40, 31, 16, 27, 19, 11, 10, 0, 19, 4, 10, 5, 11, 7, 4, 3, 33, 40, 38, 35, 34, 22, 31, 24, 22, 24, 13, 13, 12, 14, 23, 12, 19, 22, 18, 13, 35, 39, 41, 35, 31, 28, 28, 23, 22, 19, 14, 18, 18, 19, 21, 17, 20, 14, 22, 20, 32, 38, 34, 27, 21, 17, 9, 8, 15, 11, 18, 21, 13, 11, 25, 16, 12, 13, 15, 7, 32, 31, 28, 36, 33, 16, 25, 11, 17, 14, 10, 15, 19, 21, 18, 16, 12, 18, 17, 20, 21, 15, 19, 24, 21, 23, 22, 13, 20, 7, 10, 25, 17, 21, 21, 22, 19, 21, 9, 14, 25, 22, 20, 14, 12, 8, 13, 15, 23, 14, 23, 7, 10, 15, 19, 19, 14, 10, 7, 6, 27, 28, 24, 26, 11, 21, 16, 18, 13, 12, 15, 24, 11, 13, 18, 14, 12, 13, 13, 78, 77, 78, 78, 72, 63, 73, 72, 72, 72, 69, 67, 67, 68, 62, 61, 54, 35, 41, 38, 46, 47, 49, 53, 53, 52, 52, 51, 49, 45, 38, 42, 42, 36, 24, 29, 19, 19, 23, 12, 32, 37, 31, 26, 36, 27, 29, 28, 27, 19, 36, 34, 31, 21, 21, 26, 20, 17, 17, 14, 26, 28, 25, 23, 19, 20, 25, 24, 17, 21, 13, 23, 11, 21, 19, 16, 13, 13, 16, 20, 18, 22, 17, 21, 6, 16, 14, 11, 16, 11, 3, 18, 8, 20, 15, 19, 9, 26, 21, 15, 16, 16, 21, 15, 19, 13, 17, 7, 13, 20, 11, 11, 17, 11, 18, 14, 13, 20, 17, 10, 23, 23, 19, 18, 21, 13, 8, 13, 22, 6, 20, 20, 19, 14, 6, 10, 18, 8, 15, 19, 23, 20, 11, 14, 8, 16, 16, 13, 20, 9, 23, 18, 15, 17, 7, 13, 14, 11, 13, 14, 19, 15, 23, 19, 18, 23, 18, 26, 15, 16, 19, 17, 14, 6, 16, 19, 8, 23, 18, 18, 9, 14, 16, 10, 19, 7, 13, 16, 6, 21, 19, 18, 16, 19, 22, 19, 7, 7, 19, 22, 10, 7, 10, 20, 13, 12, 16, 14, 13, 23, 15, 15, 8, 21, 14, 16, 7, 19, 21, 7, 17, 5, 18, 12, 20, 16, 22, 23, 17, 7, 19, 6, 13, 23, 20, 18, 13, 18, 21, 21, 11, 10, 18, 9, 16, 9, 8, 20, 21, 16, 14, 21, 8, 18, 17, 12, 17, 15, 20, 11, 94, 92, 91, 93, 88, 80, 77, 75, 75, 72, 73, 72, 77, 76, 68, 70, 64, 47, 50, 43, 53, 59, 50, 59, 60, 55, 52, 50, 48, 54, 54, 41, 47, 49, 41, 35, 34, 26, 17, 24, 59, 51, 53, 55, 55, 52, 56, 55, 50, 51, 53, 45, 41, 41, 18, 22, 7, 0, 20, 20, 39, 41, 41, 37, 41, 41, 39, 39, 36, 33, 31, 9, 24, 6, 19, 9, 12, 20, 6, 19, 31, 33, 33, 25, 24, 30, 30, 23, 16, 13, 13, 19, 17, 16, 20, 12, 21, 17, 13, 9, 26, 20, 21, 20, 24, 18, 20, 16, 15, 17, 19, 20, 14, 8, 21, 15, 20, 14, 4, 11, 24, 22, 16, 20, 23, 17, 17, 22, 20, 16, 16, 20, 2, 15, 8, 19, 21, 21, 17, 14, 23, 26, 13, 12, 17, 19, 18, 21, 13, 20, 20, 13, 14, 8, 21, 9, 22, 14, 4, 14, 23, 14, 16, 18, 22, 16, 10, 13, 17, 22, 12, 19, 18, 22, 14, 16, 21, 19, 9, 15, 20, 22, 19, 22, 17, 13, 19, 17, 19, 22, 15, 19, 16, 20, 10, 18, 11, 21, 21, 12, 16, 16, 19, 16, 11, 13, 20, 9, 15, 18, 21, 17, 17, 19, 17, 21, 12, 10, 11, 24, 21, 14, 15, 15, 14, 14, 18, 14, 22, 21, 13, 18, 18, 19, 14, 16, 19, 21, 18, 9, 23, 21, 16, 23, 7, 19, 20, 19, 21, 18, 11, 18, 15, 10, 18, 20, 6, 17, 12, 23, 54, 103, 98, 103, 101, 100, 92, 89, 91, 89, 77, 86, 87, 85, 80, 78, 75, 66, 52, 51, 32, 88, 87, 86, 86, 86, 84, 86, 85, 80, 71, 68, 78, 70, 67, 63, 54, 41, 40, 30, 23, 80, 69, 69, 74, 70, 71, 67, 57, 63, 62, 58, 50, 51, 43, 44, 34, 27, 25, 24, 19, 65, 58, 65, 66, 66, 66, 59, 56, 45, 57, 51, 21, 42, 30, 29, 16, 16, 14, 20, 24, 58, 62, 61, 55, 46, 56, 51, 46, 49, 50, 47, 42, 29, 27, 23, 10, 22, 24, 18, 21, 51, 51, 32, 41, 36, 33, 31, 37, 36, 29, 25, 17, 20, 9, 20, 17, 12, 11, 18, 16, 55, 52, 50, 41, 42, 37, 42, 28, 29, 21, 21, 6, 10, 11, 18, 16, 17, 14, 16, 20, 38, 44, 43, 40, 42, 35, 36, 25, 32, 22, 23, 20, 8, 12, 16, 10, 17, 18, 20, 10, 48, 44, 39, 34, 21, 20, 26, 24, 27, 21, 21, 19, 13, 21, 17, 15, 19, 17, 16, 22, 34, 36, 30, 26, 27, 25, 13, 16, 22, 18, 17, 20, 18, 13, 21, 18, 9, 17, 18, 19, 18, 27, 21, 25, 20, 14, 13, 1, 10, 17, 20, 11, 21, 1, 15, 17, 19, 8, 26, 12, 28, 29, 23, 22, 16, 20, 24, 18, 10, 1, 21, 17, 17, 17, 8, 21, 12, 16, 18, 12, 27, 19, 19, 17, 16, 21, 15, 10, 20, 20, 17, 12, 20, 15, 20, 20, 24, 15, 19, 67, 70, 78, 81, 81, 78, 78, 78, 73, 71, 68, 63, 66, 67, 60, 56, 51, 50, 29, 37, 47, 52, 53, 56, 56, 55, 54, 53, 47, 40, 40, 41, 27, 30, 27, 25, 7, 16, 22, 18, 22, 33, 35, 36, 34, 37, 36, 35, 24, 17, 22, 18, 21, 23, 7, 16, 16, 19, 8, 15, 24, 26, 23, 20, 18, 18, 22, 24, 17, 17, 16, 19, 21, 13, 12, 16, 21, 24, 0, 12, 18, 20, 15, 26, 21, 22, 22, 16, 21, 11, 15, 17, 18, 17, 25, 24, 23, 18, 9, 12, 21, 7, 17, 16, 15, 16, 17, 20, 18, 13, 20, 16, 19, 20, 14, 8, 11, 18, 15, 18, 14, 13, 19, 18, 20, 19, 7, 15, 23, 21, 19, 18, 15, 16, 17, 18, 22, 15, 16, 13, 16, 26, 23, 21, 23, 9, 14, 22, 12, 16, 17, 23, 14, 16, 15, 13, 18, 21, 19, 15, 17, 6, 6, 15, 21, 25, 17, 23, 17, 20, 19, 16, 27, 18, 12, 14, 21, 10, 23, 11, 22, 11, 8, 20, 6, 21, 23, 17, 22, 20, 24, 22, 18, 24, 16, 11, 25, 17, 19, 20, 21, 14, 20, 22, 19, 26, 14, 18, 16, 12, 19, 24, 19, 24, 12, 20, 17, 23, 16, 21, 85, 90, 94, 96, 95, 95, 95, 95, 92, 89, 83, 77, 78, 79, 73, 72, 63, 63, 32, 46, 62, 61, 63, 63, 66, 65, 63, 63, 56, 46, 47, 52, 34, 38, 37, 34, 19, 18, 15, 21, 38, 48, 49, 49, 44, 43, 43, 41, 31, 31, 38, 35, 18, 30, 27, 22, 21, 17, 19, 23, 40, 40, 36, 30, 28, 24, 24, 30, 31, 27, 24, 21, 14, 17, 24, 10, 15, 13, 14, 22, 23, 34, 21, 26, 23, 28, 19, 20, 25, 20, 16, 15, 9, 12, 23, 3, 25, 7, 22, 7, 23, 19, 18, 20, 25, 16, 16, 19, 26, 20, 21, 18, 11, 19, 23, 21, 19, 17, 18, 22, 23, 26, 13, 20, 21, 18, 12, 9, 12, 12, 19, 19, 8, 19, 19, 16, 19, 18, 17, 19, 12, 20, 19, 18, 19, 14, 24, 15, 26, 16, 21, 8, 15, 16, 17, 20, 13, 15, 17, 20, 21, 17, 13, 18, 20, 17, 19, 23, 17, 22, 24, 1, 23, 14, 11, 12, 17, 16, 12, 12, 16, 5, 15, 20, 15, 14, 11, 20, 18, 14, 14, 12, 13, 19, 16, 13, 21, 5, 13, 11, 14, 21, 15, 20, 19, 17, 15, 19, 21, 18, 23, 7, 21, 8, 15, 17, 22, 14, 21, 22, 102, 107, 110, 112, 111, 111, 111, 111, 108, 105, 98, 91, 94, 93, 89, 84, 77, 76, 57, 57, 86, 86, 88, 89, 92, 91, 86, 77, 79, 68, 69, 74, 64, 67, 62, 56, 31, 37, 21, 16, 66, 72, 65, 53, 67, 64, 65, 60, 57, 47, 44, 49, 47, 42, 37, 29, 15, 20, 17, 18, 63, 64, 60, 37, 47, 52, 57, 55, 52, 49, 47, 47, 42, 24, 25, 18, 22, 13, 20, 16, 53, 52, 48, 45, 51, 52, 50, 49, 27, 42, 40, 29, 23, 12, 21, 8, 12, 22, 23, 10, 41, 44, 43, 38, 38, 28, 34, 30, 22, 21, 24, 18, 16, 10, 17, 17, 15, 20, 20, 12, 46, 43, 40, 29, 21, 30, 24, 28, 25, 23, 22, 11, 15, 16, 15, 18, 14, 16, 13, 18, 31, 37, 36, 35, 24, 29, 21, 20, 9, 20, 21, 16, 20, 16, 13, 20, 18, 20, 24, 22, 29, 25, 30, 18, 24, 12, 20, 24, 20, 18, 15, 19, 17, 13, 19, 10, 22, 8, 14, 20, 24, 28, 20, 18, 21, 16, 19, 2, 19, 13, 11, 21, 19, 20, 17, 25, 15, 20, 12, 14, 26, 28, 23, 23, 14, 18, 21, 23, 16, 13, 18, 23, 20, 14, 15, 19, 23, 19, 18, 19, 65, 73, 67, 72, 69, 67, 65, 65, 58, 54, 57, 48, 56, 37, 40, 42, 36, 31, 24, 19, 45, 45, 43, 42, 43, 40, 42, 41, 43, 42, 30, 36, 23, 15, 23, 8, 23, 21, 19, 22, 26, 21, 28, 26, 24, 19, 22, 20, 22, 15, 21, 20, 15, 20, 22, 11, 16, 22, 13, 18, 30, 32, 34, 35, 31, 32, 19, 18, 26, 15, 14, 11, 21, 18, 13, 13, 17, 17, 15, 12, 21, 25, 24, 22, 5, 12, 19, 14, 21, 20, 17, 20, 8, 18, 12, 24, 18, 17, 17, 10, 23, 25, 24, 26, 22, 16, 24, 22, 13, 22, 14, 22, 12, 15, 9, 14, 15, 18, 15, 18, 23, 11, 11, 22, 22, 20, 23, 22, 26, 11, 18, 20, 18, 10, 15, 19, 11, 17, 16, 17, 15, 22, 15, 19, 17, 20, 18, 25, 21, 22, 20, 17, 20, 21, 26, 19, 22, 18, 20, 20, 89, 93, 90, 92, 90, 87, 88, 85, 85, 82, 62, 72, 77, 71, 64, 58, 51, 41, 25, 26, 43, 59, 52, 46, 52, 48, 46, 50, 48, 50, 20, 46, 34, 13, 22, 26, 20, 22, 16, 18, 27, 36, 33, 37, 28, 31, 33, 31, 32, 21, 19, 20, 16, 17, 15, 20, 13, 23, 10, 13, 32, 42, 28, 27, 29, 32, 35, 33, 28, 31, 23, 19, 16, 20, 23, 23, 21, 16, 22, 20, 29, 22, 26, 33, 27, 24, 22, 24, 10, 15, 14, 16, 18, 17, 14, 5, 19, 14, 16, 23, 10, 22, 20, 13, 19, 21, 25, 20, 21, 23, 13, 9, 17, 17, 15, 20, 20, 21, 19, 10, 23, 18, 18, 22, 24, 29, 18, 15, 23, 21, 20, 20, 10, 15, 22, 16, 23, 17, 21, 18, 24, 11, 7, 8, 18, 17, 21, 16, 19, 24, 21, 23, 13, 22, 18, 19, 21, 16, 21, 27, 105, 107, 106, 106, 105, 104, 103, 101, 101, 97, 77, 91, 91, 86, 77, 70, 64, 54, 46, 40, 83, 80, 79, 68, 63, 78, 75, 73, 68, 72, 63, 66, 56, 56, 46, 31, 15, 8, 15, 18, 55, 51, 52, 56, 48, 51, 53, 47, 41, 40, 20, 34, 36, 28, 19, 20, 20, 19, 21, 19, 56, 53, 50, 40, 47, 54, 54, 49, 28, 50, 39, 40, 35, 30, 19, 26, 25, 28, 16, 21, 38, 43, 37, 41, 39, 39, 41, 40, 29, 20, 19, 20, 21, 21, 15, 12, 14, 17, 18, 11, 46, 38, 38, 33, 30, 29, 28, 22, 17, 17, 14, 12, 12, 15, 24, 18, 16, 19, 17, 15, 31, 38, 25, 27, 13, 21, 20, 19, 12, 15, 19, 24, 17, 13, 17, 20, 17, 18, 21, 16, 16, 23, 23, 27, 18, 26, 16, 15, 12, 8, 13, 22, 15, 15, 16, 18, 14, 22, 23, 22, 18, 24, 19, 25, 25, 21, 13, 12, 15, 19, 18, 23, 22, 12, 22, 16, 16, 26, 17, 20, 60, 58, 51, 66, 50, 61, 47, 51, 45, 56, 52, 50, 39, 48, 35, 36, 27, 31, 28, 25, 42, 43, 39, 37, 37, 42, 40, 29, 33, 23, 35, 29, 23, 23, 14, 21, 17, 17, 23, 21, 32, 23, 15, 21, 28, 32, 23, 25, 14, 25, 21, 20, 19, 23, 21, 18, 16, 9, 19, 13, 15, 18, 26, 24, 20, 24, 23, 18, 22, 16, 17, 20, 4, 20, 24, 18, 12, 11, 18, 12, 22, 25, 19, 18, 20, 16, 22, 26, 16, 24, 13, 19, 14, 17, 26, 17, 6, 21, 23, 18, 24, 19, 19, 26, 21, 18, 22, 17, 21, 23, 17, 19, 26, 21, 18, 24, 24, 23, 15, 23, 28, 18, 20, 29, 17, 22, 20, 16, 19, 22, 23, 19, 21, 15, 20, 11, 19, 21, 19, 21, 83, 78, 76, 78, 69, 69, 74, 77, 67, 77, 70, 70, 66, 66, 53, 52, 42, 32, 26, 23, 52, 53, 49, 49, 43, 35, 47, 42, 42, 40, 36, 37, 29, 23, 22, 19, 24, 25, 18, 19, 37, 39, 33, 34, 28, 33, 28, 27, 27, 27, 12, 24, 26, 19, 23, 20, 17, 18, 20, 14, 28, 24, 23, 28, 24, 22, 26, 26, 23, 24, 26, 26, 20, 20, 19, 22, 24, 13, 17, 20, 28, 15, 22, 23, 28, 25, 15, 25, 22, 20, 21, 20, 23, 21, 20, 27, 16, 19, 16, 19, 8, 19, 22, 25, 21, 25, 16, 21, 20, 20, 22, 26, 26, 19, 21, 14, 23, 23, 13, 16, 19, 14, 23, 25, 24, 24, 15, 26, 22, 20, 22, 22, 19, 21, 23, 22, 14, 18, 19, 21, 108, 106, 101, 101, 89, 89, 96, 101, 94, 98, 88, 90, 87, 76, 72, 69, 51, 51, 25, 21, 81, 73, 80, 81, 70, 77, 73, 64, 58, 60, 61, 52, 42, 46, 35, 28, 21, 20, 19, 15, 64, 60, 58, 61, 63, 56, 61, 52, 46, 43, 43, 23, 27, 21, 16, 23, 21, 21, 21, 11, 49, 54, 48, 58, 55, 33, 46, 48, 46, 25, 32, 27, 23, 20, 22, 18, 21, 12, 20, 13, 39, 43, 47, 37, 38, 29, 35, 32, 28, 20, 10, 16, 17, 12, 23, 13, 20, 17, 22, 22, 33, 32, 23, 34, 27, 29, 21, 16, 21, 18, 20, 14, 9, 19, 18, 22, 11, 21, 15, 20, 18, 27, 17, 24, 27, 18, 25, 24, 23, 20, 22, 16, 19, 24, 18, 21, 20, 21, 25, 16, 61, 71, 70, 72, 63, 58, 56, 54, 58, 50, 46, 50, 46, 34, 37, 28, 25, 26, 26, 25, 30, 40, 37, 38, 33, 31, 34, 31, 27, 30, 22, 22, 19, 25, 21, 21, 14, 17, 20, 25, 25, 30, 22, 26, 28, 24, 28, 24, 14, 20, 19, 19, 15, 23, 14, 18, 16, 16, 20, 18, 26, 19, 25, 22, 21, 20, 27, 16, 22, 15, 19, 18, 14, 22, 22, 22, 22, 18, 18, 22, 17, 23, 20, 20, 26, 21, 14, 23, 17, 8, 24, 21, 20, 8, 17, 20, 20, 20, 19, 24, 22, 23, 24, 23, 21, 20, 16, 27, 27, 18, 20, 18, 17, 19, 18, 14, 15, 19, 16, 19, 72, 82, 85, 83, 81, 79, 73, 68, 75, 69, 67, 69, 58, 51, 53, 46, 40, 35, 29, 25, 49, 49, 54, 52, 39, 45, 46, 37, 29, 40, 35, 28, 29, 26, 17, 23, 20, 27, 17, 20, 33, 36, 31, 33, 32, 35, 32, 35, 28, 28, 24, 23, 18, 22, 13, 19, 19, 22, 17, 19, 28, 28, 29, 27, 27, 25, 28, 21, 17, 20, 20, 24, 20, 23, 22, 19, 21, 15, 19, 22, 25, 26, 26, 22, 9, 24, 19, 20, 22, 23, 18, 14, 16, 22, 19, 26, 22, 22, 23, 21, 82, 93, 96, 100, 99, 94, 90, 83, 91, 79, 81, 80, 69, 66, 62, 54, 43, 35, 17, 21, 68, 66, 71, 61, 53, 64, 63, 57, 45, 51, 44, 40, 33, 28, 17, 25, 20, 24, 14, 16, 41, 51, 49, 50, 47, 48, 42, 39, 32, 29, 20, 23, 23, 22, 19, 20, 17, 27, 14, 12, 39, 43, 43, 37, 34, 36, 26, 26, 20, 17, 24, 21, 18, 21, 14, 11, 23, 16, 15, 23, 32, 30, 31, 26, 25, 21, 24, 23, 18, 16, 25, 25, 20, 17, 24, 24, 13, 19, 17, 23, 63, 69, 56, 66, 51, 62, 55, 47, 48, 45, 37, 37, 30, 28, 28, 23, 28, 23, 17, 25, 29, 28, 28, 34, 25, 32, 29, 28, 27, 21, 17, 20, 19, 22, 23, 19, 25, 16, 23, 21, 22, 23, 28, 28, 22, 27, 28, 20, 24, 22, 21, 23, 24, 24, 24, 25, 26, 15, 19, 27, 70, 84, 83, 83, 78, 70, 67, 64, 77, 66, 70, 66, 55, 52, 47, 35, 30, 26, 26, 25, 45, 55, 40, 47, 42, 46, 42, 36, 37, 37, 32, 22, 17, 24, 19, 14, 21, 27, 22, 18, 31, 32, 36, 34, 24, 23, 22, 19, 21, 24, 24, 20, 22, 23, 19, 15, 15, 20, 21, 21, 23, 24, 25, 29, 28, 22, 26, 22, 19, 25, 23, 22, 24, 24, 22, 23, 19, 18, 25, 23, 83, 91, 97, 98, 91, 90, 93, 89, 89, 78, 80, 76, 65, 65, 55, 41, 36, 27, 18, 22, 70, 68, 58, 58, 66, 61, 62, 53, 48, 47, 46, 33, 18, 24, 26, 20, 17, 16, 19, 16, 46, 52, 51, 47, 39, 41, 41, 27, 32, 29, 26, 22, 25, 17, 18, 19, 21, 16, 26, 24, 34, 36, 36, 36, 32, 27, 29, 23, 21, 21, 27, 17, 13, 26, 23, 19, 20, 25, 24, 18, }; const interp_partials_voice_t interp_partials_map[NUM_INTERP_PARTIALS_PRESETS] PROGMEM = { { NUM_PIANO_SAMPLE_TIMES_MS, piano_sample_times_ms, NUM_PIANO_VELOCITIES, piano_velocities, NUM_PIANO_NOTES, piano_notes, piano_num_harmonics, piano_harmonics_freq, piano_harmonics_mags, }, }; #endif // ndef __INTERP_PARTIALS_H ================================================ FILE: src/libminiaudio-audio.c ================================================ // libminiaudio-audio.c // functions for running AMY on a computer #if !defined(ESP_PLATFORM) && !defined(PICO_ON_DEVICE) && !defined(ARDUINO) #include "amy.h" #define MA_NO_FLAC #define MA_NO_MP3 #define MA_NO_RESOURCE_MANAGER #define MA_NO_NODE_GRAPH #define MA_NO_ENGINE #define MA_NO_GENERATION extern SAMPLE ** fbl; #ifdef __APPLE__ #define MA_NO_RUNTIME_LINKING #endif #define MINIAUDIO_IMPLEMENTATION #define MA_AUDIO_WORKLETS_THREAD_STACK_SIZE 131072 #define MINIAUDIO_IMPLEMENTATION #include "miniaudio.h" #include #ifdef _WIN32 #include #else #include #endif #define DEVICE_FORMAT ma_format_s16 int16_t * leftover_buf; uint16_t leftover_samples = 0; //pthread_t amy_live_thread; #ifdef __EMSCRIPTEN__ #include float amy_web_cv_1 = 0; float amy_web_cv_2 = 0; extern void sequencer_check_and_fill(); void main_loop__em() { // We call repeatedly here to fill the sequencer, for webassembly (no threads) sequencer_check_and_fill(); amy_web_cv_1 = EM_ASM_DOUBLE({ if(typeof cv_1_voltage != 'undefined') { return cv_1_voltage; } else { return 0; } }); amy_web_cv_2 = EM_ASM_DOUBLE({ if(typeof cv_2_voltage != 'undefined') { return cv_2_voltage; } else { return 0; } }); } #endif // Semaphore for passing most recent audio buffer to amy_update. // It's the pointer that's volatile, not the data it points to. int16_t *volatile last_audio_buffer = NULL; void amy_update_tasks() { } void amy_platform_init() { } void amy_platform_deinit() { } size_t amy_i2s_write(const uint8_t *buffer, size_t nbytes) { return 0; } int16_t *amy_render_audio() { // For miniaudio, we just return a semaphore buffer. while (last_audio_buffer == NULL) ; int16_t *buf = last_audio_buffer; last_audio_buffer = NULL; return buf; } void amy_print_devices() { ma_context context; if (ma_context_init(NULL, 0, NULL, &context) != MA_SUCCESS) { fprintf(stderr,"Failed to setup context for device list.\n"); exit(1); } ma_device_info* pPlaybackInfos; ma_uint32 playbackCount; ma_device_info* pCaptureInfos; ma_uint32 captureCount; if (ma_context_get_devices(&context, &pPlaybackInfos, &playbackCount, &pCaptureInfos, &captureCount) != MA_SUCCESS) { fprintf(stderr,"Failed to get device list.\n"); exit(1); } fprintf(stderr, "output devices:\n"); for (ma_uint32 iDevice = 0; iDevice < playbackCount; iDevice += 1) { fprintf(stderr,"\t%d - %s\n", iDevice, pPlaybackInfos[iDevice].name); } fprintf(stderr, "input devices:\n"); for (ma_uint32 iDevice = 0; iDevice < captureCount; iDevice += 1) { fprintf(stderr,"\t%d - %s\n", iDevice, pCaptureInfos[iDevice].name); } ma_context_uninit(&context); } // I've seen frame counts as big as 1440, I think *8 is enough room (2048) #define OUTPUT_RING_FRAMES (AMY_BLOCK_SIZE*8) #define OUTPUT_RING_LENGTH (OUTPUT_RING_FRAMES*AMY_NCHANS) int16_t output_ring[OUTPUT_RING_LENGTH]; uint16_t ring_write_ptr = AMY_BLOCK_SIZE*AMY_NCHANS; // start after one AMY frame uint16_t ring_read_ptr = 0 ; uint16_t in_ptr = 0; extern output_sample_type *amy_in_block; static void data_callback(ma_device* pDevice, void* pOutput, const void* pInput, ma_uint32 frame_count) { short int *poke = (short *)pOutput; short int *peek = (short *)pInput; // We lag a AMY block behind input here because our frame size is never a multiple of AMY block size for(uint16_t frame=0;frame= (int32_t)playbackCount || amy_global.config.capture_device_id >= (int32_t)captureCount) { printf("invalid device\n"); exit(1); } } else { if (amy_global.config.playback_device_id >= (int32_t)playbackCount) { printf("invalid device\n"); exit(1); } } if(AMY_HAS_AUDIO_IN) { deviceConfig = ma_device_config_init(ma_device_type_duplex); } else { deviceConfig = ma_device_config_init(ma_device_type_playback); } if(amy_global.config.playback_device_id >= 0) { deviceConfig.playback.pDeviceID = &pPlaybackInfos[amy_global.config.playback_device_id].id; } else { deviceConfig.playback.pDeviceID = NULL; // system default } deviceConfig.playback.format = DEVICE_FORMAT; deviceConfig.playback.channels = AMY_NCHANS; if(AMY_HAS_AUDIO_IN) { if(amy_global.config.capture_device_id >= 0) { deviceConfig.capture.pDeviceID = &pCaptureInfos[amy_global.config.capture_device_id].id; } else { deviceConfig.capture.pDeviceID = NULL; // system default } deviceConfig.capture.format = DEVICE_FORMAT; deviceConfig.capture.channels = AMY_NCHANS; } deviceConfig.sampleRate = AMY_SAMPLE_RATE; deviceConfig.dataCallback = data_callback; deviceConfig.pUserData = _custom; // Force miniaudio's callback to be the same size as AMY. This helps us not loop too many fill_buffer calls deviceConfig.periodSizeInFrames = AMY_BLOCK_SIZE; if (ma_device_init(&context, &deviceConfig, &device) != MA_SUCCESS) { printf("Failed to open playback device.\n"); exit(1); } if (ma_device_start(&device) != MA_SUCCESS) { printf("Failed to start playback device.\n"); ma_device_uninit(&device); exit(1); } for(uint16_t i=0;i 0); int scale = 0; while (x < F2S(1.0f)) { x = SHIFTL(x, 1); --scale; } while (x >= F2S(2.0f)) { x = SHIFTR(x, 1); ++scale; } // lut_val is negated because table is stored as negative (to reach 1.0). return AMY_I2S(scale, 0) - lut_val(x - F2S(1.0f), log2_fxpt_lutable, 8 /* =log_2(256) */); } SAMPLE exp2_lut(SAMPLE x) { int offset = INT_OF_S(x, 0); SAMPLE x_frac = S_FRAC_OF_S(x, 0); // lut_val is negated because table is stored as negative (to reach 1.0). SAMPLE unnorm = F2S(1.0f) - lut_val(x_frac, exp2_fxpt_lutable, 8 /* =log_2(256) */); if (offset > 0) return SHIFTL(unnorm, offset); else return SHIFTR(unnorm, -offset); } ================================================ FILE: src/log2_exp2_fxpt_lutable.h ================================================ // Automatically-generated LUTset #ifndef LUTSET_EXP_LUT_FXPT_DEFINED #define LUTSET_EXP_LUT_FXPT_DEFINED const int16_t log2_fxpt_lutable[257] PROGMEM = { 0,-184,-368,-551,-733,-914,-1095,-1275, -1455,-1633,-1811,-1989,-2166,-2342,-2517,-2692, -2866,-3039,-3212,-3385,-3556,-3727,-3897,-4067, -4236,-4405,-4573,-4740,-4907,-5073,-5239,-5404, -5568,-5732,-5895,-6058,-6220,-6382,-6543,-6703, -6863,-7023,-7182,-7340,-7498,-7655,-7812,-7968, -8124,-8279,-8434,-8588,-8742,-8895,-9048,-9200, -9352,-9503,-9654,-9804,-9954,-10104,-10253,-10401, -10549,-10696,-10843,-10990,-11136,-11282,-11427,-11572, -11716,-11860,-12004,-12147,-12289,-12431,-12573,-12715, -12855,-12996,-13136,-13276,-13415,-13554,-13692,-13830, -13968,-14105,-14242,-14378,-14514,-14650,-14785,-14920, -15055,-15189,-15322,-15456,-15589,-15721,-15854,-15986, -16117,-16248,-16379,-16509,-16639,-16769,-16898,-17027, -17156,-17284,-17412,-17540,-17667,-17794,-17921,-18047, -18173,-18298,-18424,-18548,-18673,-18797,-18921,-19045, -19168,-19291,-19414,-19536,-19658,-19780,-19901,-20022, -20143,-20263,-20383,-20503,-20623,-20742,-20861,-20980, -21098,-21216,-21334,-21451,-21568,-21685,-21802,-21918, -22034,-22150,-22265,-22380,-22495,-22610,-22724,-22838, -22952,-23066,-23179,-23292,-23404,-23517,-23629,-23741, -23852,-23964,-24075,-24186,-24296,-24407,-24517,-24627, -24736,-24845,-24955,-25063,-25172,-25280,-25388,-25496, -25604,-25711,-25818,-25925,-26031,-26138,-26244,-26350, -26455,-26561,-26666,-26771,-26876,-26980,-27084,-27188, -27292,-27396,-27499,-27602,-27705,-27808,-27910,-28012, -28114,-28216,-28318,-28419,-28520,-28621,-28722,-28822, -28922,-29022,-29122,-29222,-29321,-29421,-29520,-29618, -29717,-29815,-29914,-30012,-30109,-30207,-30304,-30401, -30498,-30595,-30692,-30788,-30884,-30980,-31076,-31172, -31267,-31362,-31457,-31552,-31647,-31741,-31836,-31930, -32024,-32117,-32211,-32304,-32397,-32490,-32583,-32676, -32768, }; const int16_t exp2_fxpt_lutable[257] PROGMEM = { 0,-89,-178,-267,-357,-447,-537,-627, -718,-808,-899,-991,-1082,-1174,-1266,-1358, -1451,-1544,-1637,-1730,-1823,-1917,-2011,-2106, -2200,-2295,-2390,-2485,-2581,-2677,-2773,-2869, -2966,-3063,-3160,-3257,-3355,-3453,-3551,-3649, -3748,-3847,-3947,-4046,-4146,-4246,-4346,-4447, -4548,-4649,-4750,-4852,-4954,-5056,-5159,-5262, -5365,-5468,-5572,-5676,-5780,-5885,-5989,-6095, -6200,-6306,-6412,-6518,-6624,-6731,-6838,-6946, -7053,-7161,-7269,-7378,-7487,-7596,-7705,-7815, -7925,-8036,-8146,-8257,-8368,-8480,-8592,-8704, -8816,-8929,-9042,-9155,-9269,-9383,-9497,-9612, -9727,-9842,-9958,-10073,-10190,-10306,-10423,-10540, -10657,-10775,-10893,-11012,-11130,-11249,-11369,-11488, -11608,-11729,-11849,-11970,-12091,-12213,-12335,-12457, -12580,-12703,-12826,-12950,-13074,-13198,-13323,-13448, -13573,-13699,-13825,-13951,-14078,-14205,-14332,-14460, -14588,-14716,-14845,-14974,-15103,-15233,-15363,-15494, -15625,-15756,-15887,-16019,-16152,-16284,-16417,-16551, -16684,-16818,-16953,-17088,-17223,-17358,-17494,-17631, -17767,-17904,-18042,-18179,-18317,-18456,-18595,-18734, -18874,-19014,-19154,-19295,-19436,-19578,-19720,-19862, -20005,-20148,-20291,-20435,-20579,-20724,-20869,-21014, -21160,-21306,-21453,-21600,-21747,-21895,-22043,-22192, -22341,-22490,-22640,-22790,-22941,-23092,-23244,-23395, -23548,-23700,-23854,-24007,-24161,-24315,-24470,-24625, -24781,-24937,-25093,-25250,-25408,-25565,-25723,-25882, -26041,-26200,-26360,-26521,-26681,-26843,-27004,-27166, -27329,-27492,-27655,-27819,-27983,-28148,-28313,-28479, -28645,-28811,-28978,-29146,-29313,-29482,-29651,-29820, -29989,-30160,-30330,-30501,-30673,-30845,-31017,-31190, -31364,-31538,-31712,-31887,-32062,-32238,-32414,-32591, -32768, }; #endif // LUTSET_x_DEFINED ================================================ FILE: src/macos_midi.m ================================================ #ifndef __EMSCRIPTEN__ #define unichar OSX_UNICHAR #import #import #import #include #include #undef unichar #import "amy_midi.h" static CGEventSourceRef eventSource; MIDIClientRef midi_client; MIDIPortRef out_port; static void NotifyProc(const MIDINotification *message, void *refCon) { } static uint8_t midi_status_len(uint8_t status) { // MIDI realtime/system common lengths. if (status >= 0xF8) return 1; if (status == 0xF6) return 1; if (status == 0xF1 || status == 0xF3) return 2; if (status == 0xF2) return 3; if (status == 0xF4 || status == 0xF5 || status == 0xF9 || status == 0xFD) return 1; // Channel voice lengths. switch (status & 0xF0) { case 0x80: case 0x90: case 0xA0: case 0xB0: case 0xE0: return 3; case 0xC0: case 0xD0: return 2; default: return 0; } } void midi_out(uint8_t * bytes, uint16_t len) { if (@available(macOS 11, *)) { MIDIPacketList pl; MIDIPacket *p; p = MIDIPacketListInit(&pl); p = MIDIPacketListAdd(&pl, 1024, p, 0, len, bytes); for (NSUInteger endpointRefIndex = 0; endpointRefIndex < MIDIGetNumberOfDestinations(); ++endpointRefIndex) { MIDIObjectRef destinationEndpoint = MIDIGetDestination(endpointRefIndex); MIDISend(out_port, destinationEndpoint, &pl); } } else { fprintf(stderr, "Can only run MIDI on macOS Big Sur (11.0) or later, sorry\n"); } } int midi_macos_should_exit = false; void* run_midi_macos(void*argp){ //sysex_buffer = malloc(MAX_SYSEX_BYTES); if (@available(macOS 11, *)) { @autoreleasepool { //py_midi_callback = 0; OSStatus status = MIDIClientCreate((__bridge CFStringRef)@"Tulip", NotifyProc, NULL, &midi_client); if (status != noErr) { fprintf(stderr, "Error %d while setting up handlers\n", status); } status = MIDIOutputPortCreate(midi_client, (__bridge CFStringRef)[NSString stringWithFormat:@"Tulip Output"], &out_port ); if(status != noErr) { fprintf(stderr, "Error %d while setting up MIDI output port\n", status); } eventSource = CGEventSourceCreate(kCGEventSourceStatePrivate); ItemCount number_sources = MIDIGetNumberOfSources(); for (unsigned long i = 0; i < number_sources; i++) { MIDIEndpointRef source = MIDIGetSource(i); MIDIPortRef in_port; status = MIDIInputPortCreateWithProtocol(midi_client, (__bridge CFStringRef)[NSString stringWithFormat:@"Tulip Input %lu", i], kMIDIProtocol_1_0, &in_port, ^(const MIDIEventList *evtlist, void *srcConnRefCon) { OSStatus sysex_status = -1; for (uint32_t i = 0; i < evtlist->numPackets; i++) { const MIDIEventPacket* packet = &evtlist->packet[i]; if(@available(macos 14, *)) { CFDataRef outData; sysex_status = MIDIEventPacketSysexBytesForGroup(packet,0, &outData); if(sysex_status == noErr) { const uint8_t * sysex_bytes = CFDataGetBytePtr(outData); for(uint16_t i=0;iwordCount; j++) { const unsigned char *bytes = (unsigned char*)(&packet->words[j]); uint8_t mt = bytes[3] >> 4; // Accept MIDI 1.0 Channel Voice (0x2) and System (0x1) UMP words. if (mt == 0x1 || mt == 0x2) { uint8_t data[3] = { bytes[2], bytes[1], bytes[0] }; uint8_t len = midi_status_len(data[0]); if (len > 0) { convert_midi_bytes_to_messages(data, len, 1); } } } } } }); if (status != noErr) { fprintf(stderr, "Error %d while setting up MIDI input port\n", status); } status = MIDIPortConnectSource(in_port, source, NULL); if (status != noErr) { fprintf(stderr, "Error %d while connecting MIDI input port to source\n", status); } } CFRunLoopRun(); } } else { fprintf(stderr, "Can only run MIDI on macOS Big Sur (11.0) or later, sorry\n"); } return NULL; } void run_midi() { if (sysex_buffer == NULL) { // has not been started yet. sysex_buffer = malloc(MAX_SYSEX_BYTES); pthread_t midi_thread_id; pthread_create(&midi_thread_id, NULL, run_midi_macos, NULL); } } void stop_midi() { // Normally, we'd have to remove all the sources and timers from the CFRunLoop, but we'll fudge it. } #endif ================================================ FILE: src/midi_mappings.c ================================================ // midi_mappings.c // example midi mappings for controllers #include "amy.h" #include // for buffer overruns in midi_fetch_control_code_command. void juno_filter_midi_handler(uint8_t * bytes, uint16_t len, uint8_t is_sysex) { // An example of adding a handler for MIDI CCs. Can't really build this in because it depends on your synth/patch config, controllers, wishes... // Here, we use MIDI CC 70 to modify the Juno VCF center freq, and 71 for resonance. amy_event e; if (bytes[0] == 0xB0) { // Channel 1 CC if (bytes[1] == 70) { // Modify Synth 0 filter_freq. /* def to_filter_freq(val): */ /* # filter_freq goes from ? 100 to 6400 Hz with 18 steps/octave */ /* return float("%.3f" % (13 * exp2(0.0938 * val * 127))) */ e = amy_default_event(); e.synth = 1; e.filter_freq_coefs[COEF_CONST] = exp2f(0.0938f * (float)bytes[2]); amy_add_event(&e); } else if (bytes[1] == 71) { /* def to_resonance(val): */ /* # Q goes from 0.5 to 16 exponentially */ /* return float("%.3f" % (0.7 * exp2(4.0 * val))) */ e = amy_default_event(); e.synth = 1; e.resonance = 0.7f * exp2f(0.03125f * (float)bytes[2]); amy_add_event(&e); } } } struct cc_mapping { struct cc_mapping *next; int channel; int code; int is_log; float min_val; float max_val; float offset_val; char *message_template; }; struct cc_mapping *cc_mapping_root = NULL; void cc_mapping_print(struct cc_mapping *mapping) { fprintf(stderr, "mapping 0x%lx chan %d code 0x%x log %d min %.1f max %.1f offs %.1f msg %s\n", (unsigned long)mapping, mapping->channel, mapping->code, mapping->is_log, mapping->min_val, mapping->max_val, mapping->offset_val, mapping->message_template); } struct cc_mapping *cc_mapping_init(struct cc_mapping **p_root, int channel, int code, int is_log, float min_val, float max_val, float offset_val, char *message_template) { struct cc_mapping *result = (struct cc_mapping *)malloc_caps(sizeof(struct cc_mapping) + strlen(message_template) + 1, amy_global.config.ram_caps_synth); result->message_template = ((char *)result) + sizeof(struct cc_mapping); result->channel = channel; result->code = code; result->is_log = is_log; result->min_val = min_val; result->max_val = max_val; result->offset_val = offset_val; strcpy(result->message_template, message_template); // Insert into the linked list at the head. result->next = *p_root; *p_root = result; return result; } void cc_mapping_debug(void) { fprintf(stderr, "cc_mapping_debug:\n"); struct cc_mapping **p_mapping = &cc_mapping_root; while (*p_mapping != NULL) { cc_mapping_print(*p_mapping); p_mapping = &((*p_mapping)->next); } } void cc_mapping_free(struct cc_mapping **p_mapping) { // Close up the linked list. struct cc_mapping *doomed = *p_mapping; *p_mapping = doomed->next; // Return the memory free(doomed); } void midi_mappings_init(void) { cc_mapping_root = NULL; } void midi_mappings_deinit(void) { struct cc_mapping **p_mapping = &cc_mapping_root; while (*p_mapping != NULL) { cc_mapping_free(p_mapping); } } void midi_clear_channel_mappings(int channel) { struct cc_mapping **p_mapping = &cc_mapping_root; while (*p_mapping != NULL) { if ((*p_mapping)->channel == channel) { cc_mapping_free(p_mapping); } else { p_mapping = &((*p_mapping)->next); } } } struct cc_mapping **cc_mapping_find(int channel, int code) { // Retrieve the mapping associated with a midi channel + code, if any. struct cc_mapping **p_mapping = &cc_mapping_root; while (*p_mapping != NULL) { if ((*p_mapping)->channel == channel && (*p_mapping)->code == code) return p_mapping; p_mapping = &((*p_mapping)->next); } return NULL; } int midi_clear_control_code(int channel, int code) { if (code == 255) { // Magic value means clear all MIDI CCs for this channel midi_clear_channel_mappings(channel); return 1; } struct cc_mapping **p_mapping = cc_mapping_find(channel, code); if (p_mapping) { cc_mapping_free(p_mapping); return 1; } return 0; // nothing found. } int midi_store_control_code(int channel, int code, int is_log, float min_val, float max_val, float offset_val, char *message) { // Register a MIDI control code and mapping and a wire code template. // Strip trailing wire protocol terminator(s) so they don't accumulate on round-trips. size_t mlen = strlen(message); while (mlen > 0 && message[mlen - 1] == 'Z') { message[--mlen] = '\0'; } struct cc_mapping **p_mapping = cc_mapping_find(channel, code); if (p_mapping) cc_mapping_free(p_mapping); // store with an empty string removes mapping if (mlen) { /* struct cc_mapping *mapping = */ cc_mapping_init(&cc_mapping_root, channel, code, is_log, min_val, max_val, offset_val, message); //cc_mapping_debug(); } return 1; } bool midi_fetch_control_code_command(int channel, int code, char *s, size_t len) { struct cc_mapping **p_mapping = cc_mapping_find(channel, code); //fprintf(stderr, "midi_fetch_control_code chan %d code %d mapping 0x%llx\n", channel, code, (uint64_t)p_mapping); if (p_mapping == NULL) return false; // Format the control code - ic,,,,, sprintf(s, "ic%d,%d,%.3f,%.3f,%.3f,%sZ", (*p_mapping)->code, (*p_mapping)->is_log, (*p_mapping)->min_val, (*p_mapping)->max_val, (*p_mapping)->offset_val, (*p_mapping)->message_template); assert(strlen(s) < len); return true; } float map_cc_value(struct cc_mapping *mapping, uint8_t value) { if (mapping->is_log != 0) { return (mapping->min_val + mapping->offset_val) * expf( logf((mapping->max_val + mapping->offset_val) / (mapping->min_val + mapping->offset_val)) * (float)value / 127.0f ) - mapping->offset_val; } else { // Linear. return mapping->min_val + (mapping->max_val - mapping->min_val) * (float)value / 127.0f; } } #define WIRE_COMMAND_LEN 256 void substitute_cc_special_values(char *dest, const char *src, int channel, float value) { // Copy src string to dest, but replace "%i" with channel and "%v" with value. const char *s; const char *entry_src = src; int n_remain = WIRE_COMMAND_LEN - 1; while((s = strchr(src, '%')) != NULL && n_remain > (int)strlen(src)) { // Copy up to the %. int nchars = s - src; strncpy(dest, src, nchars); dest += nchars; n_remain -= nchars; src += nchars; ++src; // skip over the '%' dest[0] = '\0'; if (src[0] == 'v') { sprintf(dest, "%.3f", value); } else if (src[0] == 'V') { sprintf(dest, "%d", (int)value); } else if (src[0] == 'i') { sprintf(dest, "%d", channel); } else { fprintf(stderr, "substitute_cc: unrecognized '%%%c' in %s\n", src[0], entry_src); } ++src; // skip over the code char nchars = strlen(dest); dest += nchars; n_remain -= nchars; } // Copy anything left in the string. if (n_remain > (int)strlen(src)) strcpy(dest, src); } void midi_cc_handler(uint8_t * bytes, uint16_t len, uint8_t is_sysex) { if ((bytes[0] & 0xF0) == 0xB0) { // CC int channel = (bytes[0] & 0x0F) + 1; int code = bytes[1]; struct cc_mapping **p_mapping = cc_mapping_find(channel, code); if (p_mapping != NULL) { float value = map_cc_value(*p_mapping, bytes[2]); char message[WIRE_COMMAND_LEN]; substitute_cc_special_values(message, (*p_mapping)->message_template, channel, value); //fprintf(stderr, "midi_cc_handler: message %s\n", message); amy_add_message(message); } } } ================================================ FILE: src/miniaudio.h ================================================ /* Audio playback and capture library. Choice of public domain or MIT-0. See license statements at the end of this file. miniaudio - v0.11.21 - 2023-11-15 David Reid - mackron@gmail.com Website: https://miniaud.io Documentation: https://miniaud.io/docs GitHub: https://github.com/mackron/miniaudio */ /* 1. Introduction =============== miniaudio is a single file library for audio playback and capture. To use it, do the following in one .c file: ```c #define MINIAUDIO_IMPLEMENTATION #include "miniaudio.h" ``` You can do `#include "miniaudio.h"` in other parts of the program just like any other header. miniaudio includes both low level and high level APIs. The low level API is good for those who want to do all of their mixing themselves and only require a light weight interface to the underlying audio device. The high level API is good for those who have complex mixing and effect requirements. In miniaudio, objects are transparent structures. Unlike many other libraries, there are no handles to opaque objects which means you need to allocate memory for objects yourself. In the examples presented in this documentation you will often see objects declared on the stack. You need to be careful when translating these examples to your own code so that you don't accidentally declare your objects on the stack and then cause them to become invalid once the function returns. In addition, you must ensure the memory address of your objects remain the same throughout their lifetime. You therefore cannot be making copies of your objects. A config/init pattern is used throughout the entire library. The idea is that you set up a config object and pass that into the initialization routine. The advantage to this system is that the config object can be initialized with logical defaults and new properties added to it without breaking the API. The config object can be allocated on the stack and does not need to be maintained after initialization of the corresponding object. 1.1. Low Level API ------------------ The low level API gives you access to the raw audio data of an audio device. It supports playback, capture, full-duplex and loopback (WASAPI only). You can enumerate over devices to determine which physical device(s) you want to connect to. The low level API uses the concept of a "device" as the abstraction for physical devices. The idea is that you choose a physical device to emit or capture audio from, and then move data to/from the device when miniaudio tells you to. Data is delivered to and from devices asynchronously via a callback which you specify when initializing the device. When initializing the device you first need to configure it. The device configuration allows you to specify things like the format of the data delivered via the callback, the size of the internal buffer and the ID of the device you want to emit or capture audio from. Once you have the device configuration set up you can initialize the device. When initializing a device you need to allocate memory for the device object beforehand. This gives the application complete control over how the memory is allocated. In the example below we initialize a playback device on the stack, but you could allocate it on the heap if that suits your situation better. ```c void data_callback(ma_device* pDevice, void* pOutput, const void* pInput, ma_uint32 frameCount) { // In playback mode copy data to pOutput. In capture mode read data from pInput. In full-duplex mode, both // pOutput and pInput will be valid and you can move data from pInput into pOutput. Never process more than // frameCount frames. } int main() { ma_device_config config = ma_device_config_init(ma_device_type_playback); config.playback.format = ma_format_f32; // Set to ma_format_unknown to use the device's native format. config.playback.channels = 2; // Set to 0 to use the device's native channel count. config.sampleRate = 48000; // Set to 0 to use the device's native sample rate. config.dataCallback = data_callback; // This function will be called when miniaudio needs more data. config.pUserData = pMyCustomData; // Can be accessed from the device object (device.pUserData). ma_device device; if (ma_device_init(NULL, &config, &device) != MA_SUCCESS) { return -1; // Failed to initialize the device. } ma_device_start(&device); // The device is sleeping by default so you'll need to start it manually. // Do something here. Probably your program's main loop. ma_device_uninit(&device); return 0; } ``` In the example above, `data_callback()` is where audio data is written and read from the device. The idea is in playback mode you cause sound to be emitted from the speakers by writing audio data to the output buffer (`pOutput` in the example). In capture mode you read data from the input buffer (`pInput`) to extract sound captured by the microphone. The `frameCount` parameter tells you how many frames can be written to the output buffer and read from the input buffer. A "frame" is one sample for each channel. For example, in a stereo stream (2 channels), one frame is 2 samples: one for the left, one for the right. The channel count is defined by the device config. The size in bytes of an individual sample is defined by the sample format which is also specified in the device config. Multi-channel audio data is always interleaved, which means the samples for each frame are stored next to each other in memory. For example, in a stereo stream the first pair of samples will be the left and right samples for the first frame, the second pair of samples will be the left and right samples for the second frame, etc. The configuration of the device is defined by the `ma_device_config` structure. The config object is always initialized with `ma_device_config_init()`. It's important to always initialize the config with this function as it initializes it with logical defaults and ensures your program doesn't break when new members are added to the `ma_device_config` structure. The example above uses a fairly simple and standard device configuration. The call to `ma_device_config_init()` takes a single parameter, which is whether or not the device is a playback, capture, duplex or loopback device (loopback devices are not supported on all backends). The `config.playback.format` member sets the sample format which can be one of the following (all formats are native-endian): +---------------+----------------------------------------+---------------------------+ | Symbol | Description | Range | +---------------+----------------------------------------+---------------------------+ | ma_format_f32 | 32-bit floating point | [-1, 1] | | ma_format_s16 | 16-bit signed integer | [-32768, 32767] | | ma_format_s24 | 24-bit signed integer (tightly packed) | [-8388608, 8388607] | | ma_format_s32 | 32-bit signed integer | [-2147483648, 2147483647] | | ma_format_u8 | 8-bit unsigned integer | [0, 255] | +---------------+----------------------------------------+---------------------------+ The `config.playback.channels` member sets the number of channels to use with the device. The channel count cannot exceed MA_MAX_CHANNELS. The `config.sampleRate` member sets the sample rate (which must be the same for both playback and capture in full-duplex configurations). This is usually set to 44100 or 48000, but can be set to anything. It's recommended to keep this between 8000 and 384000, however. Note that leaving the format, channel count and/or sample rate at their default values will result in the internal device's native configuration being used which is useful if you want to avoid the overhead of miniaudio's automatic data conversion. In addition to the sample format, channel count and sample rate, the data callback and user data pointer are also set via the config. The user data pointer is not passed into the callback as a parameter, but is instead set to the `pUserData` member of `ma_device` which you can access directly since all miniaudio structures are transparent. Initializing the device is done with `ma_device_init()`. This will return a result code telling you what went wrong, if anything. On success it will return `MA_SUCCESS`. After initialization is complete the device will be in a stopped state. To start it, use `ma_device_start()`. Uninitializing the device will stop it, which is what the example above does, but you can also stop the device with `ma_device_stop()`. To resume the device simply call `ma_device_start()` again. Note that it's important to never stop or start the device from inside the callback. This will result in a deadlock. Instead you set a variable or signal an event indicating that the device needs to stop and handle it in a different thread. The following APIs must never be called inside the callback: ```c ma_device_init() ma_device_init_ex() ma_device_uninit() ma_device_start() ma_device_stop() ``` You must never try uninitializing and reinitializing a device inside the callback. You must also never try to stop and start it from inside the callback. There are a few other things you shouldn't do in the callback depending on your requirements, however this isn't so much a thread-safety thing, but rather a real-time processing thing which is beyond the scope of this introduction. The example above demonstrates the initialization of a playback device, but it works exactly the same for capture. All you need to do is change the device type from `ma_device_type_playback` to `ma_device_type_capture` when setting up the config, like so: ```c ma_device_config config = ma_device_config_init(ma_device_type_capture); config.capture.format = MY_FORMAT; config.capture.channels = MY_CHANNEL_COUNT; ``` In the data callback you just read from the input buffer (`pInput` in the example above) and leave the output buffer alone (it will be set to NULL when the device type is set to `ma_device_type_capture`). These are the available device types and how you should handle the buffers in the callback: +-------------------------+--------------------------------------------------------+ | Device Type | Callback Behavior | +-------------------------+--------------------------------------------------------+ | ma_device_type_playback | Write to output buffer, leave input buffer untouched. | | ma_device_type_capture | Read from input buffer, leave output buffer untouched. | | ma_device_type_duplex | Read from input buffer, write to output buffer. | | ma_device_type_loopback | Read from input buffer, leave output buffer untouched. | +-------------------------+--------------------------------------------------------+ You will notice in the example above that the sample format and channel count is specified separately for playback and capture. This is to support different data formats between the playback and capture devices in a full-duplex system. An example may be that you want to capture audio data as a monaural stream (one channel), but output sound to a stereo speaker system. Note that if you use different formats between playback and capture in a full-duplex configuration you will need to convert the data yourself. There are functions available to help you do this which will be explained later. The example above did not specify a physical device to connect to which means it will use the operating system's default device. If you have multiple physical devices connected and you want to use a specific one you will need to specify the device ID in the configuration, like so: ```c config.playback.pDeviceID = pMyPlaybackDeviceID; // Only if requesting a playback or duplex device. config.capture.pDeviceID = pMyCaptureDeviceID; // Only if requesting a capture, duplex or loopback device. ``` To retrieve the device ID you will need to perform device enumeration, however this requires the use of a new concept called the "context". Conceptually speaking the context sits above the device. There is one context to many devices. The purpose of the context is to represent the backend at a more global level and to perform operations outside the scope of an individual device. Mainly it is used for performing run-time linking against backend libraries, initializing backends and enumerating devices. The example below shows how to enumerate devices. ```c ma_context context; if (ma_context_init(NULL, 0, NULL, &context) != MA_SUCCESS) { // Error. } ma_device_info* pPlaybackInfos; ma_uint32 playbackCount; ma_device_info* pCaptureInfos; ma_uint32 captureCount; if (ma_context_get_devices(&context, &pPlaybackInfos, &playbackCount, &pCaptureInfos, &captureCount) != MA_SUCCESS) { // Error. } // Loop over each device info and do something with it. Here we just print the name with their index. You may want // to give the user the opportunity to choose which device they'd prefer. for (ma_uint32 iDevice = 0; iDevice < playbackCount; iDevice += 1) { printf("%d - %s\n", iDevice, pPlaybackInfos[iDevice].name); } ma_device_config config = ma_device_config_init(ma_device_type_playback); config.playback.pDeviceID = &pPlaybackInfos[chosenPlaybackDeviceIndex].id; config.playback.format = MY_FORMAT; config.playback.channels = MY_CHANNEL_COUNT; config.sampleRate = MY_SAMPLE_RATE; config.dataCallback = data_callback; config.pUserData = pMyCustomData; ma_device device; if (ma_device_init(&context, &config, &device) != MA_SUCCESS) { // Error } ... ma_device_uninit(&device); ma_context_uninit(&context); ``` The first thing we do in this example is initialize a `ma_context` object with `ma_context_init()`. The first parameter is a pointer to a list of `ma_backend` values which are used to override the default backend priorities. When this is NULL, as in this example, miniaudio's default priorities are used. The second parameter is the number of backends listed in the array pointed to by the first parameter. The third parameter is a pointer to a `ma_context_config` object which can be NULL, in which case defaults are used. The context configuration is used for setting the logging callback, custom memory allocation callbacks, user-defined data and some backend-specific configurations. Once the context has been initialized you can enumerate devices. In the example above we use the simpler `ma_context_get_devices()`, however you can also use a callback for handling devices by using `ma_context_enumerate_devices()`. When using `ma_context_get_devices()` you provide a pointer to a pointer that will, upon output, be set to a pointer to a buffer containing a list of `ma_device_info` structures. You also provide a pointer to an unsigned integer that will receive the number of items in the returned buffer. Do not free the returned buffers as their memory is managed internally by miniaudio. The `ma_device_info` structure contains an `id` member which is the ID you pass to the device config. It also contains the name of the device which is useful for presenting a list of devices to the user via the UI. When creating your own context you will want to pass it to `ma_device_init()` when initializing the device. Passing in NULL, like we do in the first example, will result in miniaudio creating the context for you, which you don't want to do since you've already created a context. Note that internally the context is only tracked by it's pointer which means you must not change the location of the `ma_context` object. If this is an issue, consider using `malloc()` to allocate memory for the context. 1.2. High Level API ------------------- The high level API consists of three main parts: * Resource management for loading and streaming sounds. * A node graph for advanced mixing and effect processing. * A high level "engine" that wraps around the resource manager and node graph. The resource manager (`ma_resource_manager`) is used for loading sounds. It supports loading sounds fully into memory and also streaming. It will also deal with reference counting for you which avoids the same sound being loaded multiple times. The node graph is used for mixing and effect processing. The idea is that you connect a number of nodes into the graph by connecting each node's outputs to another node's inputs. Each node can implement it's own effect. By chaining nodes together, advanced mixing and effect processing can be achieved. The engine encapsulates both the resource manager and the node graph to create a simple, easy to use high level API. The resource manager and node graph APIs are covered in more later sections of this manual. The code below shows how you can initialize an engine using it's default configuration. ```c ma_result result; ma_engine engine; result = ma_engine_init(NULL, &engine); if (result != MA_SUCCESS) { return result; // Failed to initialize the engine. } ``` This creates an engine instance which will initialize a device internally which you can access with `ma_engine_get_device()`. It will also initialize a resource manager for you which can be accessed with `ma_engine_get_resource_manager()`. The engine itself is a node graph (`ma_node_graph`) which means you can pass a pointer to the engine object into any of the `ma_node_graph` APIs (with a cast). Alternatively, you can use `ma_engine_get_node_graph()` instead of a cast. Note that all objects in miniaudio, including the `ma_engine` object in the example above, are transparent structures. There are no handles to opaque structures in miniaudio which means you need to be mindful of how you declare them. In the example above we are declaring it on the stack, but this will result in the struct being invalidated once the function encapsulating it returns. If allocating the engine on the heap is more appropriate, you can easily do so with a standard call to `malloc()` or whatever heap allocation routine you like: ```c ma_engine* pEngine = malloc(sizeof(*pEngine)); ``` The `ma_engine` API uses the same config/init pattern used all throughout miniaudio. To configure an engine, you can fill out a `ma_engine_config` object and pass it into the first parameter of `ma_engine_init()`: ```c ma_result result; ma_engine engine; ma_engine_config engineConfig; engineConfig = ma_engine_config_init(); engineConfig.pResourceManager = &myCustomResourceManager; // <-- Initialized as some earlier stage. result = ma_engine_init(&engineConfig, &engine); if (result != MA_SUCCESS) { return result; } ``` This creates an engine instance using a custom config. In this particular example it's showing how you can specify a custom resource manager rather than having the engine initialize one internally. This is particularly useful if you want to have multiple engine's share the same resource manager. The engine must be uninitialized with `ma_engine_uninit()` when it's no longer needed. By default the engine will be started, but nothing will be playing because no sounds have been initialized. The easiest but least flexible way of playing a sound is like so: ```c ma_engine_play_sound(&engine, "my_sound.wav", NULL); ``` This plays what miniaudio calls an "inline" sound. It plays the sound once, and then puts the internal sound up for recycling. The last parameter is used to specify which sound group the sound should be associated with which will be explained later. This particular way of playing a sound is simple, but lacks flexibility and features. A more flexible way of playing a sound is to first initialize a sound: ```c ma_result result; ma_sound sound; result = ma_sound_init_from_file(&engine, "my_sound.wav", 0, NULL, NULL, &sound); if (result != MA_SUCCESS) { return result; } ma_sound_start(&sound); ``` This returns a `ma_sound` object which represents a single instance of the specified sound file. If you want to play the same file multiple times simultaneously, you need to create one sound for each instance. Sounds should be uninitialized with `ma_sound_uninit()`. Sounds are not started by default. Start a sound with `ma_sound_start()` and stop it with `ma_sound_stop()`. When a sound is stopped, it is not rewound to the start. Use `ma_sound_seek_to_pcm_frame(&sound, 0)` to seek back to the start of a sound. By default, starting and stopping sounds happens immediately, but sometimes it might be convenient to schedule the sound the be started and/or stopped at a specific time. This can be done with the following functions: ```c ma_sound_set_start_time_in_pcm_frames() ma_sound_set_start_time_in_milliseconds() ma_sound_set_stop_time_in_pcm_frames() ma_sound_set_stop_time_in_milliseconds() ``` The start/stop time needs to be specified based on the absolute timer which is controlled by the engine. The current global time time in PCM frames can be retrieved with `ma_engine_get_time_in_pcm_frames()`. The engine's global time can be changed with `ma_engine_set_time_in_pcm_frames()` for synchronization purposes if required. Note that scheduling a start time still requires an explicit call to `ma_sound_start()` before anything will play: ```c ma_sound_set_start_time_in_pcm_frames(&sound, ma_engine_get_time_in_pcm_frames(&engine) + (ma_engine_get_sample_rate(&engine) * 2); ma_sound_start(&sound); ``` The third parameter of `ma_sound_init_from_file()` is a set of flags that control how the sound be loaded and a few options on which features should be enabled for that sound. By default, the sound is synchronously loaded fully into memory straight from the file system without any kind of decoding. If you want to decode the sound before storing it in memory, you need to specify the `MA_SOUND_FLAG_DECODE` flag. This is useful if you want to incur the cost of decoding at an earlier stage, such as a loading stage. Without this option, decoding will happen dynamically at mixing time which might be too expensive on the audio thread. If you want to load the sound asynchronously, you can specify the `MA_SOUND_FLAG_ASYNC` flag. This will result in `ma_sound_init_from_file()` returning quickly, but the sound will not start playing until the sound has had some audio decoded. The fourth parameter is a pointer to sound group. A sound group is used as a mechanism to organise sounds into groups which have their own effect processing and volume control. An example is a game which might have separate groups for sfx, voice and music. Each of these groups have their own independent volume control. Use `ma_sound_group_init()` or `ma_sound_group_init_ex()` to initialize a sound group. Sounds and sound groups are nodes in the engine's node graph and can be plugged into any `ma_node` API. This makes it possible to connect sounds and sound groups to effect nodes to produce complex effect chains. A sound can have it's volume changed with `ma_sound_set_volume()`. If you prefer decibel volume control you can use `ma_volume_db_to_linear()` to convert from decibel representation to linear. Panning and pitching is supported with `ma_sound_set_pan()` and `ma_sound_set_pitch()`. If you know a sound will never have it's pitch changed with `ma_sound_set_pitch()` or via the doppler effect, you can specify the `MA_SOUND_FLAG_NO_PITCH` flag when initializing the sound for an optimization. By default, sounds and sound groups have spatialization enabled. If you don't ever want to spatialize your sounds, initialize the sound with the `MA_SOUND_FLAG_NO_SPATIALIZATION` flag. The spatialization model is fairly simple and is roughly on feature parity with OpenAL. HRTF and environmental occlusion are not currently supported, but planned for the future. The supported features include: * Sound and listener positioning and orientation with cones * Attenuation models: none, inverse, linear and exponential * Doppler effect Sounds can be faded in and out with `ma_sound_set_fade_in_pcm_frames()`. To check if a sound is currently playing, you can use `ma_sound_is_playing()`. To check if a sound is at the end, use `ma_sound_at_end()`. Looping of a sound can be controlled with `ma_sound_set_looping()`. Use `ma_sound_is_looping()` to check whether or not the sound is looping. 2. Building =========== miniaudio should work cleanly out of the box without the need to download or install any dependencies. See below for platform-specific details. Note that GCC and Clang require `-msse2`, `-mavx2`, etc. for SIMD optimizations. If you get errors about undefined references to `__sync_val_compare_and_swap_8`, `__atomic_load_8`, etc. you need to link with `-latomic`. 2.1. Windows ------------ The Windows build should compile cleanly on all popular compilers without the need to configure any include paths nor link to any libraries. The UWP build may require linking to mmdevapi.lib if you get errors about an unresolved external symbol for `ActivateAudioInterfaceAsync()`. 2.2. macOS and iOS ------------------ The macOS build should compile cleanly without the need to download any dependencies nor link to any libraries or frameworks. The iOS build needs to be compiled as Objective-C and will need to link the relevant frameworks but should compile cleanly out of the box with Xcode. Compiling through the command line requires linking to `-lpthread` and `-lm`. Due to the way miniaudio links to frameworks at runtime, your application may not pass Apple's notarization process. To fix this there are two options. The first is to use the `MA_NO_RUNTIME_LINKING` option, like so: ```c #ifdef __APPLE__ #define MA_NO_RUNTIME_LINKING #endif #define MINIAUDIO_IMPLEMENTATION #include "miniaudio.h" ``` This will require linking with `-framework CoreFoundation -framework CoreAudio -framework AudioToolbox`. If you get errors about AudioToolbox, try with `-framework AudioUnit` instead. You may get this when using older versions of iOS. Alternatively, if you would rather keep using runtime linking you can add the following to your entitlements.xcent file: ``` com.apple.security.cs.allow-dyld-environment-variables com.apple.security.cs.allow-unsigned-executable-memory ``` See this discussion for more info: https://github.com/mackron/miniaudio/issues/203. 2.3. Linux ---------- The Linux build only requires linking to `-ldl`, `-lpthread` and `-lm`. You do not need any development packages. You may need to link with `-latomic` if you're compiling for 32-bit ARM. 2.4. BSD -------- The BSD build only requires linking to `-lpthread` and `-lm`. NetBSD uses audio(4), OpenBSD uses sndio and FreeBSD uses OSS. You may need to link with `-latomic` if you're compiling for 32-bit ARM. 2.5. Android ------------ AAudio is the highest priority backend on Android. This should work out of the box without needing any kind of compiler configuration. Support for AAudio starts with Android 8 which means older versions will fall back to OpenSL|ES which requires API level 16+. There have been reports that the OpenSL|ES backend fails to initialize on some Android based devices due to `dlopen()` failing to open "libOpenSLES.so". If this happens on your platform you'll need to disable run-time linking with `MA_NO_RUNTIME_LINKING` and link with -lOpenSLES. 2.6. Emscripten --------------- The Emscripten build emits Web Audio JavaScript directly and should compile cleanly out of the box. You cannot use `-std=c*` compiler flags, nor `-ansi`. You can enable the use of AudioWorkets by defining `MA_ENABLE_AUDIO_WORKLETS` and then compiling with the following options: -sAUDIO_WORKLET=1 -sWASM_WORKERS=1 -sASYNCIFY An example for compiling with AudioWorklet support might look like this: emcc program.c -o bin/program.html -DMA_ENABLE_AUDIO_WORKLETS -sAUDIO_WORKLET=1 -sWASM_WORKERS=1 -sASYNCIFY To run locally, you'll need to use emrun: emrun bin/program.html 2.7. Build Options ------------------ `#define` these options before including miniaudio.h. +----------------------------------+--------------------------------------------------------------------+ | Option | Description | +----------------------------------+--------------------------------------------------------------------+ | MA_NO_WASAPI | Disables the WASAPI backend. | +----------------------------------+--------------------------------------------------------------------+ | MA_NO_DSOUND | Disables the DirectSound backend. | +----------------------------------+--------------------------------------------------------------------+ | MA_NO_WINMM | Disables the WinMM backend. | +----------------------------------+--------------------------------------------------------------------+ | MA_NO_ALSA | Disables the ALSA backend. | +----------------------------------+--------------------------------------------------------------------+ | MA_NO_PULSEAUDIO | Disables the PulseAudio backend. | +----------------------------------+--------------------------------------------------------------------+ | MA_NO_JACK | Disables the JACK backend. | +----------------------------------+--------------------------------------------------------------------+ | MA_NO_COREAUDIO | Disables the Core Audio backend. | +----------------------------------+--------------------------------------------------------------------+ | MA_NO_SNDIO | Disables the sndio backend. | +----------------------------------+--------------------------------------------------------------------+ | MA_NO_AUDIO4 | Disables the audio(4) backend. | +----------------------------------+--------------------------------------------------------------------+ | MA_NO_OSS | Disables the OSS backend. | +----------------------------------+--------------------------------------------------------------------+ | MA_NO_AAUDIO | Disables the AAudio backend. | +----------------------------------+--------------------------------------------------------------------+ | MA_NO_OPENSL | Disables the OpenSL|ES backend. | +----------------------------------+--------------------------------------------------------------------+ | MA_NO_WEBAUDIO | Disables the Web Audio backend. | +----------------------------------+--------------------------------------------------------------------+ | MA_NO_NULL | Disables the null backend. | +----------------------------------+--------------------------------------------------------------------+ | MA_ENABLE_ONLY_SPECIFIC_BACKENDS | Disables all backends by default and requires `MA_ENABLE_*` to | | | enable specific backends. | +----------------------------------+--------------------------------------------------------------------+ | MA_ENABLE_WASAPI | Used in conjunction with MA_ENABLE_ONLY_SPECIFIC_BACKENDS to | | | enable the WASAPI backend. | +----------------------------------+--------------------------------------------------------------------+ | MA_ENABLE_DSOUND | Used in conjunction with MA_ENABLE_ONLY_SPECIFIC_BACKENDS to | | | enable the DirectSound backend. | +----------------------------------+--------------------------------------------------------------------+ | MA_ENABLE_WINMM | Used in conjunction with MA_ENABLE_ONLY_SPECIFIC_BACKENDS to | | | enable the WinMM backend. | +----------------------------------+--------------------------------------------------------------------+ | MA_ENABLE_ALSA | Used in conjunction with MA_ENABLE_ONLY_SPECIFIC_BACKENDS to | | | enable the ALSA backend. | +----------------------------------+--------------------------------------------------------------------+ | MA_ENABLE_PULSEAUDIO | Used in conjunction with MA_ENABLE_ONLY_SPECIFIC_BACKENDS to | | | enable the PulseAudio backend. | +----------------------------------+--------------------------------------------------------------------+ | MA_ENABLE_JACK | Used in conjunction with MA_ENABLE_ONLY_SPECIFIC_BACKENDS to | | | enable the JACK backend. | +----------------------------------+--------------------------------------------------------------------+ | MA_ENABLE_COREAUDIO | Used in conjunction with MA_ENABLE_ONLY_SPECIFIC_BACKENDS to | | | enable the Core Audio backend. | +----------------------------------+--------------------------------------------------------------------+ | MA_ENABLE_SNDIO | Used in conjunction with MA_ENABLE_ONLY_SPECIFIC_BACKENDS to | | | enable the sndio backend. | +----------------------------------+--------------------------------------------------------------------+ | MA_ENABLE_AUDIO4 | Used in conjunction with MA_ENABLE_ONLY_SPECIFIC_BACKENDS to | | | enable the audio(4) backend. | +----------------------------------+--------------------------------------------------------------------+ | MA_ENABLE_OSS | Used in conjunction with MA_ENABLE_ONLY_SPECIFIC_BACKENDS to | | | enable the OSS backend. | +----------------------------------+--------------------------------------------------------------------+ | MA_ENABLE_AAUDIO | Used in conjunction with MA_ENABLE_ONLY_SPECIFIC_BACKENDS to | | | enable the AAudio backend. | +----------------------------------+--------------------------------------------------------------------+ | MA_ENABLE_OPENSL | Used in conjunction with MA_ENABLE_ONLY_SPECIFIC_BACKENDS to | | | enable the OpenSL|ES backend. | +----------------------------------+--------------------------------------------------------------------+ | MA_ENABLE_WEBAUDIO | Used in conjunction with MA_ENABLE_ONLY_SPECIFIC_BACKENDS to | | | enable the Web Audio backend. | +----------------------------------+--------------------------------------------------------------------+ | MA_ENABLE_NULL | Used in conjunction with MA_ENABLE_ONLY_SPECIFIC_BACKENDS to | | | enable the null backend. | +----------------------------------+--------------------------------------------------------------------+ | MA_NO_DECODING | Disables decoding APIs. | +----------------------------------+--------------------------------------------------------------------+ | MA_NO_ENCODING | Disables encoding APIs. | +----------------------------------+--------------------------------------------------------------------+ | MA_NO_WAV | Disables the built-in WAV decoder and encoder. | +----------------------------------+--------------------------------------------------------------------+ | MA_NO_FLAC | Disables the built-in FLAC decoder. | +----------------------------------+--------------------------------------------------------------------+ | MA_NO_MP3 | Disables the built-in MP3 decoder. | +----------------------------------+--------------------------------------------------------------------+ | MA_NO_DEVICE_IO | Disables playback and recording. This will disable `ma_context` | | | and `ma_device` APIs. This is useful if you only want to use | | | miniaudio's data conversion and/or decoding APIs. | +----------------------------------+--------------------------------------------------------------------+ | MA_NO_RESOURCE_MANAGER | Disables the resource manager. When using the engine this will | | | also disable the following functions: | | | | | | ``` | | | ma_sound_init_from_file() | | | ma_sound_init_from_file_w() | | | ma_sound_init_copy() | | | ma_engine_play_sound_ex() | | | ma_engine_play_sound() | | | ``` | | | | | | The only way to initialize a `ma_sound` object is to initialize it | | | from a data source. | +----------------------------------+--------------------------------------------------------------------+ | MA_NO_NODE_GRAPH | Disables the node graph API. This will also disable the engine API | | | because it depends on the node graph. | +----------------------------------+--------------------------------------------------------------------+ | MA_NO_ENGINE | Disables the engine API. | +----------------------------------+--------------------------------------------------------------------+ | MA_NO_THREADING | Disables the `ma_thread`, `ma_mutex`, `ma_semaphore` and | | | `ma_event` APIs. This option is useful if you only need to use | | | miniaudio for data conversion, decoding and/or encoding. Some | | | families of APIs require threading which means the following | | | options must also be set: | | | | | | ``` | | | MA_NO_DEVICE_IO | | | ``` | +----------------------------------+--------------------------------------------------------------------+ | MA_NO_GENERATION | Disables generation APIs such a `ma_waveform` and `ma_noise`. | +----------------------------------+--------------------------------------------------------------------+ | MA_NO_SSE2 | Disables SSE2 optimizations. | +----------------------------------+--------------------------------------------------------------------+ | MA_NO_AVX2 | Disables AVX2 optimizations. | +----------------------------------+--------------------------------------------------------------------+ | MA_NO_NEON | Disables NEON optimizations. | +----------------------------------+--------------------------------------------------------------------+ | MA_NO_RUNTIME_LINKING | Disables runtime linking. This is useful for passing Apple's | | | notarization process. When enabling this, you may need to avoid | | | using `-std=c89` or `-std=c99` on Linux builds or else you may end | | | up with compilation errors due to conflicts with `timespec` and | | | `timeval` data types. | | | | | | You may need to enable this if your target platform does not allow | | | runtime linking via `dlopen()`. | +----------------------------------+--------------------------------------------------------------------+ | MA_DEBUG_OUTPUT | Enable `printf()` output of debug logs (`MA_LOG_LEVEL_DEBUG`). | +----------------------------------+--------------------------------------------------------------------+ | MA_COINIT_VALUE | Windows only. The value to pass to internal calls to | | | `CoInitializeEx()`. Defaults to `COINIT_MULTITHREADED`. | +----------------------------------+--------------------------------------------------------------------+ | MA_API | Controls how public APIs should be decorated. Default is `extern`. | +----------------------------------+--------------------------------------------------------------------+ 3. Definitions ============== This section defines common terms used throughout miniaudio. Unfortunately there is often ambiguity in the use of terms throughout the audio space, so this section is intended to clarify how miniaudio uses each term. 3.1. Sample ----------- A sample is a single unit of audio data. If the sample format is f32, then one sample is one 32-bit floating point number. 3.2. Frame / PCM Frame ---------------------- A frame is a group of samples equal to the number of channels. For a stereo stream a frame is 2 samples, a mono frame is 1 sample, a 5.1 surround sound frame is 6 samples, etc. The terms "frame" and "PCM frame" are the same thing in miniaudio. Note that this is different to a compressed frame. If ever miniaudio needs to refer to a compressed frame, such as a FLAC frame, it will always clarify what it's referring to with something like "FLAC frame". 3.3. Channel ------------ A stream of monaural audio that is emitted from an individual speaker in a speaker system, or received from an individual microphone in a microphone system. A stereo stream has two channels (a left channel, and a right channel), a 5.1 surround sound system has 6 channels, etc. Some audio systems refer to a channel as a complex audio stream that's mixed with other channels to produce the final mix - this is completely different to miniaudio's use of the term "channel" and should not be confused. 3.4. Sample Rate ---------------- The sample rate in miniaudio is always expressed in Hz, such as 44100, 48000, etc. It's the number of PCM frames that are processed per second. 3.5. Formats ------------ Throughout miniaudio you will see references to different sample formats: +---------------+----------------------------------------+---------------------------+ | Symbol | Description | Range | +---------------+----------------------------------------+---------------------------+ | ma_format_f32 | 32-bit floating point | [-1, 1] | | ma_format_s16 | 16-bit signed integer | [-32768, 32767] | | ma_format_s24 | 24-bit signed integer (tightly packed) | [-8388608, 8388607] | | ma_format_s32 | 32-bit signed integer | [-2147483648, 2147483647] | | ma_format_u8 | 8-bit unsigned integer | [0, 255] | +---------------+----------------------------------------+---------------------------+ All formats are native-endian. 4. Data Sources =============== The data source abstraction in miniaudio is used for retrieving audio data from some source. A few examples include `ma_decoder`, `ma_noise` and `ma_waveform`. You will need to be familiar with data sources in order to make sense of some of the higher level concepts in miniaudio. The `ma_data_source` API is a generic interface for reading from a data source. Any object that implements the data source interface can be plugged into any `ma_data_source` function. To read data from a data source: ```c ma_result result; ma_uint64 framesRead; result = ma_data_source_read_pcm_frames(pDataSource, pFramesOut, frameCount, &framesRead); if (result != MA_SUCCESS) { return result; // Failed to read data from the data source. } ``` If you don't need the number of frames that were successfully read you can pass in `NULL` to the `pFramesRead` parameter. If this returns a value less than the number of frames requested it means the end of the file has been reached. `MA_AT_END` will be returned only when the number of frames read is 0. When calling any data source function, with the exception of `ma_data_source_init()` and `ma_data_source_uninit()`, you can pass in any object that implements a data source. For example, you could plug in a decoder like so: ```c ma_result result; ma_uint64 framesRead; ma_decoder decoder; // <-- This would be initialized with `ma_decoder_init_*()`. result = ma_data_source_read_pcm_frames(&decoder, pFramesOut, frameCount, &framesRead); if (result != MA_SUCCESS) { return result; // Failed to read data from the decoder. } ``` If you want to seek forward you can pass in `NULL` to the `pFramesOut` parameter. Alternatively you can use `ma_data_source_seek_pcm_frames()`. To seek to a specific PCM frame: ```c result = ma_data_source_seek_to_pcm_frame(pDataSource, frameIndex); if (result != MA_SUCCESS) { return result; // Failed to seek to PCM frame. } ``` You can retrieve the total length of a data source in PCM frames, but note that some data sources may not have the notion of a length, such as noise and waveforms, and others may just not have a way of determining the length such as some decoders. To retrieve the length: ```c ma_uint64 length; result = ma_data_source_get_length_in_pcm_frames(pDataSource, &length); if (result != MA_SUCCESS) { return result; // Failed to retrieve the length. } ``` Care should be taken when retrieving the length of a data source where the underlying decoder is pulling data from a data stream with an undefined length, such as internet radio or some kind of broadcast. If you do this, `ma_data_source_get_length_in_pcm_frames()` may never return. The current position of the cursor in PCM frames can also be retrieved: ```c ma_uint64 cursor; result = ma_data_source_get_cursor_in_pcm_frames(pDataSource, &cursor); if (result != MA_SUCCESS) { return result; // Failed to retrieve the cursor. } ``` You will often need to know the data format that will be returned after reading. This can be retrieved like so: ```c ma_format format; ma_uint32 channels; ma_uint32 sampleRate; ma_channel channelMap[MA_MAX_CHANNELS]; result = ma_data_source_get_data_format(pDataSource, &format, &channels, &sampleRate, channelMap, MA_MAX_CHANNELS); if (result != MA_SUCCESS) { return result; // Failed to retrieve data format. } ``` If you do not need a specific data format property, just pass in NULL to the respective parameter. There may be cases where you want to implement something like a sound bank where you only want to read data within a certain range of the underlying data. To do this you can use a range: ```c result = ma_data_source_set_range_in_pcm_frames(pDataSource, rangeBegInFrames, rangeEndInFrames); if (result != MA_SUCCESS) { return result; // Failed to set the range. } ``` This is useful if you have a sound bank where many sounds are stored in the same file and you want the data source to only play one of those sub-sounds. Note that once the range is set, everything that takes a position, such as cursors and loop points, should always be relatvie to the start of the range. When the range is set, any previously defined loop point will be reset. Custom loop points can also be used with data sources. By default, data sources will loop after they reach the end of the data source, but if you need to loop at a specific location, you can do the following: ```c result = ma_data_set_loop_point_in_pcm_frames(pDataSource, loopBegInFrames, loopEndInFrames); if (result != MA_SUCCESS) { return result; // Failed to set the loop point. } ``` The loop point is relative to the current range. It's sometimes useful to chain data sources together so that a seamless transition can be achieved. To do this, you can use chaining: ```c ma_decoder decoder1; ma_decoder decoder2; // ... initialize decoders with ma_decoder_init_*() ... result = ma_data_source_set_next(&decoder1, &decoder2); if (result != MA_SUCCESS) { return result; // Failed to set the next data source. } result = ma_data_source_read_pcm_frames(&decoder1, pFramesOut, frameCount, pFramesRead); if (result != MA_SUCCESS) { return result; // Failed to read from the decoder. } ``` In the example above we're using decoders. When reading from a chain, you always want to read from the top level data source in the chain. In the example above, `decoder1` is the top level data source in the chain. When `decoder1` reaches the end, `decoder2` will start seamlessly without any gaps. Note that when looping is enabled, only the current data source will be looped. You can loop the entire chain by linking in a loop like so: ```c ma_data_source_set_next(&decoder1, &decoder2); // decoder1 -> decoder2 ma_data_source_set_next(&decoder2, &decoder1); // decoder2 -> decoder1 (loop back to the start). ``` Note that setting up chaining is not thread safe, so care needs to be taken if you're dynamically changing links while the audio thread is in the middle of reading. Do not use `ma_decoder_seek_to_pcm_frame()` as a means to reuse a data source to play multiple instances of the same sound simultaneously. This can be extremely inefficient depending on the type of data source and can result in glitching due to subtle changes to the state of internal filters. Instead, initialize multiple data sources for each instance. 4.1. Custom Data Sources ------------------------ You can implement a custom data source by implementing the functions in `ma_data_source_vtable`. Your custom object must have `ma_data_source_base` as it's first member: ```c struct my_data_source { ma_data_source_base base; ... }; ``` In your initialization routine, you need to call `ma_data_source_init()` in order to set up the base object (`ma_data_source_base`): ```c static ma_result my_data_source_read(ma_data_source* pDataSource, void* pFramesOut, ma_uint64 frameCount, ma_uint64* pFramesRead) { // Read data here. Output in the same format returned by my_data_source_get_data_format(). } static ma_result my_data_source_seek(ma_data_source* pDataSource, ma_uint64 frameIndex) { // Seek to a specific PCM frame here. Return MA_NOT_IMPLEMENTED if seeking is not supported. } static ma_result my_data_source_get_data_format(ma_data_source* pDataSource, ma_format* pFormat, ma_uint32* pChannels, ma_uint32* pSampleRate, ma_channel* pChannelMap, size_t channelMapCap) { // Return the format of the data here. } static ma_result my_data_source_get_cursor(ma_data_source* pDataSource, ma_uint64* pCursor) { // Retrieve the current position of the cursor here. Return MA_NOT_IMPLEMENTED and set *pCursor to 0 if there is no notion of a cursor. } static ma_result my_data_source_get_length(ma_data_source* pDataSource, ma_uint64* pLength) { // Retrieve the length in PCM frames here. Return MA_NOT_IMPLEMENTED and set *pLength to 0 if there is no notion of a length or if the length is unknown. } static ma_data_source_vtable g_my_data_source_vtable = { my_data_source_read, my_data_source_seek, my_data_source_get_data_format, my_data_source_get_cursor, my_data_source_get_length }; ma_result my_data_source_init(my_data_source* pMyDataSource) { ma_result result; ma_data_source_config baseConfig; baseConfig = ma_data_source_config_init(); baseConfig.vtable = &g_my_data_source_vtable; result = ma_data_source_init(&baseConfig, &pMyDataSource->base); if (result != MA_SUCCESS) { return result; } // ... do the initialization of your custom data source here ... return MA_SUCCESS; } void my_data_source_uninit(my_data_source* pMyDataSource) { // ... do the uninitialization of your custom data source here ... // You must uninitialize the base data source. ma_data_source_uninit(&pMyDataSource->base); } ``` Note that `ma_data_source_init()` and `ma_data_source_uninit()` are never called directly outside of the custom data source. It's up to the custom data source itself to call these within their own init/uninit functions. 5. Engine ========= The `ma_engine` API is a high level API for managing and mixing sounds and effect processing. The `ma_engine` object encapsulates a resource manager and a node graph, both of which will be explained in more detail later. Sounds are called `ma_sound` and are created from an engine. Sounds can be associated with a mixing group called `ma_sound_group` which are also created from the engine. Both `ma_sound` and `ma_sound_group` objects are nodes within the engine's node graph. When the engine is initialized, it will normally create a device internally. If you would rather manage the device yourself, you can do so and just pass a pointer to it via the engine config when you initialize the engine. You can also just use the engine without a device, which again can be configured via the engine config. The most basic way to initialize the engine is with a default config, like so: ```c ma_result result; ma_engine engine; result = ma_engine_init(NULL, &engine); if (result != MA_SUCCESS) { return result; // Failed to initialize the engine. } ``` This will result in the engine initializing a playback device using the operating system's default device. This will be sufficient for many use cases, but if you need more flexibility you'll want to configure the engine with an engine config: ```c ma_result result; ma_engine engine; ma_engine_config engineConfig; engineConfig = ma_engine_config_init(); engineConfig.pDevice = &myDevice; result = ma_engine_init(&engineConfig, &engine); if (result != MA_SUCCESS) { return result; // Failed to initialize the engine. } ``` In the example above we're passing in a pre-initialized device. Since the caller is the one in control of the device's data callback, it's their responsibility to manually call `ma_engine_read_pcm_frames()` from inside their data callback: ```c void playback_data_callback(ma_device* pDevice, void* pOutput, const void* pInput, ma_uint32 frameCount) { ma_engine_read_pcm_frames(&g_Engine, pOutput, frameCount, NULL); } ``` You can also use the engine independent of a device entirely: ```c ma_result result; ma_engine engine; ma_engine_config engineConfig; engineConfig = ma_engine_config_init(); engineConfig.noDevice = MA_TRUE; engineConfig.channels = 2; // Must be set when not using a device. engineConfig.sampleRate = 48000; // Must be set when not using a device. result = ma_engine_init(&engineConfig, &engine); if (result != MA_SUCCESS) { return result; // Failed to initialize the engine. } ``` Note that when you're not using a device, you must set the channel count and sample rate in the config or else miniaudio won't know what to use (miniaudio will use the device to determine this normally). When not using a device, you need to use `ma_engine_read_pcm_frames()` to process audio data from the engine. This kind of setup is useful if you want to do something like offline processing or want to use a different audio system for playback such as SDL. When a sound is loaded it goes through a resource manager. By default the engine will initialize a resource manager internally, but you can also specify a pre-initialized resource manager: ```c ma_result result; ma_engine engine1; ma_engine engine2; ma_engine_config engineConfig; engineConfig = ma_engine_config_init(); engineConfig.pResourceManager = &myResourceManager; ma_engine_init(&engineConfig, &engine1); ma_engine_init(&engineConfig, &engine2); ``` In this example we are initializing two engines, both of which are sharing the same resource manager. This is especially useful for saving memory when loading the same file across multiple engines. If you were not to use a shared resource manager, each engine instance would use their own which would result in any sounds that are used between both engine's being loaded twice. By using a shared resource manager, it would only be loaded once. Using multiple engine's is useful when you need to output to multiple playback devices, such as in a local multiplayer game where each player is using their own set of headphones. By default an engine will be in a started state. To make it so the engine is not automatically started you can configure it as such: ```c engineConfig.noAutoStart = MA_TRUE; // The engine will need to be started manually. ma_engine_start(&engine); // Later on the engine can be stopped with ma_engine_stop(). ma_engine_stop(&engine); ``` The concept of starting or stopping an engine is only relevant when using the engine with a device. Attempting to start or stop an engine that is not associated with a device will result in `MA_INVALID_OPERATION`. The master volume of the engine can be controlled with `ma_engine_set_volume()` which takes a linear scale, with 0 resulting in silence and anything above 1 resulting in amplification. If you prefer decibel based volume control, use `ma_volume_db_to_linear()` to convert from dB to linear. When a sound is spatialized, it is done so relative to a listener. An engine can be configured to have multiple listeners which can be configured via the config: ```c engineConfig.listenerCount = 2; ``` The maximum number of listeners is restricted to `MA_ENGINE_MAX_LISTENERS`. By default, when a sound is spatialized, it will be done so relative to the closest listener. You can also pin a sound to a specific listener which will be explained later. Listener's have a position, direction, cone, and velocity (for doppler effect). A listener is referenced by an index, the meaning of which is up to the caller (the index is 0 based and cannot go beyond the listener count, minus 1). The position, direction and velocity are all specified in absolute terms: ```c ma_engine_listener_set_position(&engine, listenerIndex, worldPosX, worldPosY, worldPosZ); ``` The direction of the listener represents it's forward vector. The listener's up vector can also be specified and defaults to +1 on the Y axis. ```c ma_engine_listener_set_direction(&engine, listenerIndex, forwardX, forwardY, forwardZ); ma_engine_listener_set_world_up(&engine, listenerIndex, 0, 1, 0); ``` The engine supports directional attenuation. The listener can have a cone the controls how sound is attenuated based on the listener's direction. When a sound is between the inner and outer cones, it will be attenuated between 1 and the cone's outer gain: ```c ma_engine_listener_set_cone(&engine, listenerIndex, innerAngleInRadians, outerAngleInRadians, outerGain); ``` When a sound is inside the inner code, no directional attenuation is applied. When the sound is outside of the outer cone, the attenuation will be set to `outerGain` in the example above. When the sound is in between the inner and outer cones, the attenuation will be interpolated between 1 and the outer gain. The engine's coordinate system follows the OpenGL coordinate system where positive X points right, positive Y points up and negative Z points forward. The simplest and least flexible way to play a sound is like so: ```c ma_engine_play_sound(&engine, "my_sound.wav", pGroup); ``` This is a "fire and forget" style of function. The engine will manage the `ma_sound` object internally. When the sound finishes playing, it'll be put up for recycling. For more flexibility you'll want to initialize a sound object: ```c ma_sound sound; result = ma_sound_init_from_file(&engine, "my_sound.wav", flags, pGroup, NULL, &sound); if (result != MA_SUCCESS) { return result; // Failed to load sound. } ``` Sounds need to be uninitialized with `ma_sound_uninit()`. The example above loads a sound from a file. If the resource manager has been disabled you will not be able to use this function and instead you'll need to initialize a sound directly from a data source: ```c ma_sound sound; result = ma_sound_init_from_data_source(&engine, &dataSource, flags, pGroup, &sound); if (result != MA_SUCCESS) { return result; } ``` Each `ma_sound` object represents a single instance of the sound. If you want to play the same sound multiple times at the same time, you need to initialize a separate `ma_sound` object. For the most flexibility when initializing sounds, use `ma_sound_init_ex()`. This uses miniaudio's standard config/init pattern: ```c ma_sound sound; ma_sound_config soundConfig; soundConfig = ma_sound_config_init(); soundConfig.pFilePath = NULL; // Set this to load from a file path. soundConfig.pDataSource = NULL; // Set this to initialize from an existing data source. soundConfig.pInitialAttachment = &someNodeInTheNodeGraph; soundConfig.initialAttachmentInputBusIndex = 0; soundConfig.channelsIn = 1; soundConfig.channelsOut = 0; // Set to 0 to use the engine's native channel count. result = ma_sound_init_ex(&soundConfig, &sound); if (result != MA_SUCCESS) { return result; } ``` In the example above, the sound is being initialized without a file nor a data source. This is valid, in which case the sound acts as a node in the middle of the node graph. This means you can connect other sounds to this sound and allow it to act like a sound group. Indeed, this is exactly what a `ma_sound_group` is. When loading a sound, you specify a set of flags that control how the sound is loaded and what features are enabled for that sound. When no flags are set, the sound will be fully loaded into memory in exactly the same format as how it's stored on the file system. The resource manager will allocate a block of memory and then load the file directly into it. When reading audio data, it will be decoded dynamically on the fly. In order to save processing time on the audio thread, it might be beneficial to pre-decode the sound. You can do this with the `MA_SOUND_FLAG_DECODE` flag: ```c ma_sound_init_from_file(&engine, "my_sound.wav", MA_SOUND_FLAG_DECODE, pGroup, NULL, &sound); ``` By default, sounds will be loaded synchronously, meaning `ma_sound_init_*()` will not return until the sound has been fully loaded. If this is prohibitive you can instead load sounds asynchronously by specifying the `MA_SOUND_FLAG_ASYNC` flag: ```c ma_sound_init_from_file(&engine, "my_sound.wav", MA_SOUND_FLAG_DECODE | MA_SOUND_FLAG_ASYNC, pGroup, NULL, &sound); ``` This will result in `ma_sound_init_*()` returning quickly, but the sound won't yet have been fully loaded. When you start the sound, it won't output anything until some sound is available. The sound will start outputting audio before the sound has been fully decoded when the `MA_SOUND_FLAG_DECODE` is specified. If you need to wait for an asynchronously loaded sound to be fully loaded, you can use a fence. A fence in miniaudio is a simple synchronization mechanism which simply blocks until it's internal counter hit's zero. You can specify a fence like so: ```c ma_result result; ma_fence fence; ma_sound sounds[4]; result = ma_fence_init(&fence); if (result != MA_SUCCESS) { return result; } // Load some sounds asynchronously. for (int iSound = 0; iSound < 4; iSound += 1) { ma_sound_init_from_file(&engine, mySoundFilesPaths[iSound], MA_SOUND_FLAG_DECODE | MA_SOUND_FLAG_ASYNC, pGroup, &fence, &sounds[iSound]); } // ... do some other stuff here in the mean time ... // Wait for all sounds to finish loading. ma_fence_wait(&fence); ``` If loading the entire sound into memory is prohibitive, you can also configure the engine to stream the audio data: ```c ma_sound_init_from_file(&engine, "my_sound.wav", MA_SOUND_FLAG_STREAM, pGroup, NULL, &sound); ``` When streaming sounds, 2 seconds worth of audio data is stored in memory. Although it should work fine, it's inefficient to use streaming for short sounds. Streaming is useful for things like music tracks in games. When loading a sound from a file path, the engine will reference count the file to prevent it from being loaded if it's already in memory. When you uninitialize a sound, the reference count will be decremented, and if it hits zero, the sound will be unloaded from memory. This reference counting system is not used for streams. The engine will use a 64-bit hash of the file name when comparing file paths which means there's a small chance you might encounter a name collision. If this is an issue, you'll need to use a different name for one of the colliding file paths, or just not load from files and instead load from a data source. You can use `ma_sound_init_copy()` to initialize a copy of another sound. Note, however, that this only works for sounds that were initialized with `ma_sound_init_from_file()` and without the `MA_SOUND_FLAG_STREAM` flag. When you initialize a sound, if you specify a sound group the sound will be attached to that group automatically. If you set it to NULL, it will be automatically attached to the engine's endpoint. If you would instead rather leave the sound unattached by default, you can can specify the `MA_SOUND_FLAG_NO_DEFAULT_ATTACHMENT` flag. This is useful if you want to set up a complex node graph. Sounds are not started by default. To start a sound, use `ma_sound_start()`. Stop a sound with `ma_sound_stop()`. Sounds can have their volume controlled with `ma_sound_set_volume()` in the same way as the engine's master volume. Sounds support stereo panning and pitching. Set the pan with `ma_sound_set_pan()`. Setting the pan to 0 will result in an unpanned sound. Setting it to -1 will shift everything to the left, whereas +1 will shift it to the right. The pitch can be controlled with `ma_sound_set_pitch()`. A larger value will result in a higher pitch. The pitch must be greater than 0. The engine supports 3D spatialization of sounds. By default sounds will have spatialization enabled, but if a sound does not need to be spatialized it's best to disable it. There are two ways to disable spatialization of a sound: ```c // Disable spatialization at initialization time via a flag: ma_sound_init_from_file(&engine, "my_sound.wav", MA_SOUND_FLAG_NO_SPATIALIZATION, NULL, NULL, &sound); // Dynamically disable or enable spatialization post-initialization: ma_sound_set_spatialization_enabled(&sound, isSpatializationEnabled); ``` By default sounds will be spatialized based on the closest listener. If a sound should always be spatialized relative to a specific listener it can be pinned to one: ```c ma_sound_set_pinned_listener_index(&sound, listenerIndex); ``` Like listeners, sounds have a position. By default, the position of a sound is in absolute space, but it can be changed to be relative to a listener: ```c ma_sound_set_positioning(&sound, ma_positioning_relative); ``` Note that relative positioning of a sound only makes sense if there is either only one listener, or the sound is pinned to a specific listener. To set the position of a sound: ```c ma_sound_set_position(&sound, posX, posY, posZ); ``` The direction works the same way as a listener and represents the sound's forward direction: ```c ma_sound_set_direction(&sound, forwardX, forwardY, forwardZ); ``` Sound's also have a cone for controlling directional attenuation. This works exactly the same as listeners: ```c ma_sound_set_cone(&sound, innerAngleInRadians, outerAngleInRadians, outerGain); ``` The velocity of a sound is used for doppler effect and can be set as such: ```c ma_sound_set_velocity(&sound, velocityX, velocityY, velocityZ); ``` The engine supports different attenuation models which can be configured on a per-sound basis. By default the attenuation model is set to `ma_attenuation_model_inverse` which is the equivalent to OpenAL's `AL_INVERSE_DISTANCE_CLAMPED`. Configure the attenuation model like so: ```c ma_sound_set_attenuation_model(&sound, ma_attenuation_model_inverse); ``` The supported attenuation models include the following: +----------------------------------+----------------------------------------------+ | ma_attenuation_model_none | No distance attenuation. | +----------------------------------+----------------------------------------------+ | ma_attenuation_model_inverse | Equivalent to `AL_INVERSE_DISTANCE_CLAMPED`. | +----------------------------------+----------------------------------------------+ | ma_attenuation_model_linear | Linear attenuation. | +----------------------------------+----------------------------------------------+ | ma_attenuation_model_exponential | Exponential attenuation. | +----------------------------------+----------------------------------------------+ To control how quickly a sound rolls off as it moves away from the listener, you need to configure the rolloff: ```c ma_sound_set_rolloff(&sound, rolloff); ``` You can control the minimum and maximum gain to apply from spatialization: ```c ma_sound_set_min_gain(&sound, minGain); ma_sound_set_max_gain(&sound, maxGain); ``` Likewise, in the calculation of attenuation, you can control the minimum and maximum distances for the attenuation calculation. This is useful if you want to ensure sounds don't drop below a certain volume after the listener moves further away and to have sounds play a maximum volume when the listener is within a certain distance: ```c ma_sound_set_min_distance(&sound, minDistance); ma_sound_set_max_distance(&sound, maxDistance); ``` The engine's spatialization system supports doppler effect. The doppler factor can be configure on a per-sound basis like so: ```c ma_sound_set_doppler_factor(&sound, dopplerFactor); ``` You can fade sounds in and out with `ma_sound_set_fade_in_pcm_frames()` and `ma_sound_set_fade_in_milliseconds()`. Set the volume to -1 to use the current volume as the starting volume: ```c // Fade in over 1 second. ma_sound_set_fade_in_milliseconds(&sound, 0, 1, 1000); // ... sometime later ... // Fade out over 1 second, starting from the current volume. ma_sound_set_fade_in_milliseconds(&sound, -1, 0, 1000); ``` By default sounds will start immediately, but sometimes for timing and synchronization purposes it can be useful to schedule a sound to start or stop: ```c // Start the sound in 1 second from now. ma_sound_set_start_time_in_pcm_frames(&sound, ma_engine_get_time_in_pcm_frames(&engine) + (ma_engine_get_sample_rate(&engine) * 1)); // Stop the sound in 2 seconds from now. ma_sound_set_stop_time_in_pcm_frames(&sound, ma_engine_get_time_in_pcm_frames(&engine) + (ma_engine_get_sample_rate(&engine) * 2)); ``` Note that scheduling a start time still requires an explicit call to `ma_sound_start()` before anything will play. The time is specified in global time which is controlled by the engine. You can get the engine's current time with `ma_engine_get_time_in_pcm_frames()`. The engine's global time is incremented automatically as audio data is read, but it can be reset with `ma_engine_set_time_in_pcm_frames()` in case it needs to be resynchronized for some reason. To determine whether or not a sound is currently playing, use `ma_sound_is_playing()`. This will take the scheduled start and stop times into account. Whether or not a sound should loop can be controlled with `ma_sound_set_looping()`. Sounds will not be looping by default. Use `ma_sound_is_looping()` to determine whether or not a sound is looping. Use `ma_sound_at_end()` to determine whether or not a sound is currently at the end. For a looping sound this should never return true. Alternatively, you can configure a callback that will be fired when the sound reaches the end. Note that the callback is fired from the audio thread which means you cannot be uninitializing sound from the callback. To set the callback you can use `ma_sound_set_end_callback()`. Alternatively, if you're using `ma_sound_init_ex()`, you can pass it into the config like so: ```c soundConfig.endCallback = my_end_callback; soundConfig.pEndCallbackUserData = pMyEndCallbackUserData; ``` The end callback is declared like so: ```c void my_end_callback(void* pUserData, ma_sound* pSound) { ... } ``` Internally a sound wraps around a data source. Some APIs exist to control the underlying data source, mainly for convenience: ```c ma_sound_seek_to_pcm_frame(&sound, frameIndex); ma_sound_get_data_format(&sound, &format, &channels, &sampleRate, pChannelMap, channelMapCapacity); ma_sound_get_cursor_in_pcm_frames(&sound, &cursor); ma_sound_get_length_in_pcm_frames(&sound, &length); ``` Sound groups have the same API as sounds, only they are called `ma_sound_group`, and since they do not have any notion of a data source, anything relating to a data source is unavailable. Internally, sound data is loaded via the `ma_decoder` API which means by default it only supports file formats that have built-in support in miniaudio. You can extend this to support any kind of file format through the use of custom decoders. To do this you'll need to use a self-managed resource manager and configure it appropriately. See the "Resource Management" section below for details on how to set this up. 6. Resource Management ====================== Many programs will want to manage sound resources for things such as reference counting and streaming. This is supported by miniaudio via the `ma_resource_manager` API. The resource manager is mainly responsible for the following: * Loading of sound files into memory with reference counting. * Streaming of sound data. When loading a sound file, the resource manager will give you back a `ma_data_source` compatible object called `ma_resource_manager_data_source`. This object can be passed into any `ma_data_source` API which is how you can read and seek audio data. When loading a sound file, you specify whether or not you want the sound to be fully loaded into memory (and optionally pre-decoded) or streamed. When loading into memory, you can also specify whether or not you want the data to be loaded asynchronously. The example below is how you can initialize a resource manager using it's default configuration: ```c ma_resource_manager_config config; ma_resource_manager resourceManager; config = ma_resource_manager_config_init(); result = ma_resource_manager_init(&config, &resourceManager); if (result != MA_SUCCESS) { ma_device_uninit(&device); printf("Failed to initialize the resource manager."); return -1; } ``` You can configure the format, channels and sample rate of the decoded audio data. By default it will use the file's native data format, but you can configure it to use a consistent format. This is useful for offloading the cost of data conversion to load time rather than dynamically converting at mixing time. To do this, you configure the decoded format, channels and sample rate like the code below: ```c config = ma_resource_manager_config_init(); config.decodedFormat = device.playback.format; config.decodedChannels = device.playback.channels; config.decodedSampleRate = device.sampleRate; ``` In the code above, the resource manager will be configured so that any decoded audio data will be pre-converted at load time to the device's native data format. If instead you used defaults and the data format of the file did not match the device's data format, you would need to convert the data at mixing time which may be prohibitive in high-performance and large scale scenarios like games. Internally the resource manager uses the `ma_decoder` API to load sounds. This means by default it only supports decoders that are built into miniaudio. It's possible to support additional encoding formats through the use of custom decoders. To do so, pass in your `ma_decoding_backend_vtable` vtables into the resource manager config: ```c ma_decoding_backend_vtable* pCustomBackendVTables[] = { &g_ma_decoding_backend_vtable_libvorbis, &g_ma_decoding_backend_vtable_libopus }; ... resourceManagerConfig.ppCustomDecodingBackendVTables = pCustomBackendVTables; resourceManagerConfig.customDecodingBackendCount = sizeof(pCustomBackendVTables) / sizeof(pCustomBackendVTables[0]); resourceManagerConfig.pCustomDecodingBackendUserData = NULL; ``` This system can allow you to support any kind of file format. See the "Decoding" section for details on how to implement custom decoders. The miniaudio repository includes examples for Opus via libopus and libopusfile and Vorbis via libvorbis and libvorbisfile. Asynchronicity is achieved via a job system. When an operation needs to be performed, such as the decoding of a page, a job will be posted to a queue which will then be processed by a job thread. By default there will be only one job thread running, but this can be configured, like so: ```c config = ma_resource_manager_config_init(); config.jobThreadCount = MY_JOB_THREAD_COUNT; ``` By default job threads are managed internally by the resource manager, however you can also self manage your job threads if, for example, you want to integrate the job processing into your existing job infrastructure, or if you simply don't like the way the resource manager does it. To do this, just set the job thread count to 0 and process jobs manually. To process jobs, you first need to retrieve a job using `ma_resource_manager_next_job()` and then process it using `ma_job_process()`: ```c config = ma_resource_manager_config_init(); config.jobThreadCount = 0; // Don't manage any job threads internally. config.flags = MA_RESOURCE_MANAGER_FLAG_NON_BLOCKING; // Optional. Makes `ma_resource_manager_next_job()` non-blocking. // ... Initialize your custom job threads ... void my_custom_job_thread(...) { for (;;) { ma_job job; ma_result result = ma_resource_manager_next_job(pMyResourceManager, &job); if (result != MA_SUCCESS) { if (result == MA_NO_DATA_AVAILABLE) { // No jobs are available. Keep going. Will only get this if the resource manager was initialized // with MA_RESOURCE_MANAGER_FLAG_NON_BLOCKING. continue; } else if (result == MA_CANCELLED) { // MA_JOB_TYPE_QUIT was posted. Exit. break; } else { // Some other error occurred. break; } } ma_job_process(&job); } } ``` In the example above, the `MA_JOB_TYPE_QUIT` event is the used as the termination indicator, but you can use whatever you would like to terminate the thread. The call to `ma_resource_manager_next_job()` is blocking by default, but can be configured to be non-blocking by initializing the resource manager with the `MA_RESOURCE_MANAGER_FLAG_NON_BLOCKING` configuration flag. Note that the `MA_JOB_TYPE_QUIT` will never be removed from the job queue. This is to give every thread the opportunity to catch the event and terminate naturally. When loading a file, it's sometimes convenient to be able to customize how files are opened and read instead of using standard `fopen()`, `fclose()`, etc. which is what miniaudio will use by default. This can be done by setting `pVFS` member of the resource manager's config: ```c // Initialize your custom VFS object. See documentation for VFS for information on how to do this. my_custom_vfs vfs = my_custom_vfs_init(); config = ma_resource_manager_config_init(); config.pVFS = &vfs; ``` This is particularly useful in programs like games where you want to read straight from an archive rather than the normal file system. If you do not specify a custom VFS, the resource manager will use the operating system's normal file operations. To load a sound file and create a data source, call `ma_resource_manager_data_source_init()`. When loading a sound you need to specify the file path and options for how the sounds should be loaded. By default a sound will be loaded synchronously. The returned data source is owned by the caller which means the caller is responsible for the allocation and freeing of the data source. Below is an example for initializing a data source: ```c ma_resource_manager_data_source dataSource; ma_result result = ma_resource_manager_data_source_init(pResourceManager, pFilePath, flags, &dataSource); if (result != MA_SUCCESS) { // Error. } // ... // A ma_resource_manager_data_source object is compatible with the `ma_data_source` API. To read data, just call // the `ma_data_source_read_pcm_frames()` like you would with any normal data source. result = ma_data_source_read_pcm_frames(&dataSource, pDecodedData, frameCount, &framesRead); if (result != MA_SUCCESS) { // Failed to read PCM frames. } // ... ma_resource_manager_data_source_uninit(&dataSource); ``` The `flags` parameter specifies how you want to perform loading of the sound file. It can be a combination of the following flags: ``` MA_RESOURCE_MANAGER_DATA_SOURCE_FLAG_STREAM MA_RESOURCE_MANAGER_DATA_SOURCE_FLAG_DECODE MA_RESOURCE_MANAGER_DATA_SOURCE_FLAG_ASYNC MA_RESOURCE_MANAGER_DATA_SOURCE_FLAG_WAIT_INIT ``` When no flags are specified (set to 0), the sound will be fully loaded into memory, but not decoded, meaning the raw file data will be stored in memory, and then dynamically decoded when `ma_data_source_read_pcm_frames()` is called. To instead decode the audio data before storing it in memory, use the `MA_RESOURCE_MANAGER_DATA_SOURCE_FLAG_DECODE` flag. By default, the sound file will be loaded synchronously, meaning `ma_resource_manager_data_source_init()` will only return after the entire file has been loaded. This is good for simplicity, but can be prohibitively slow. You can instead load the sound asynchronously using the `MA_RESOURCE_MANAGER_DATA_SOURCE_ASYNC` flag. This will result in `ma_resource_manager_data_source_init()` returning quickly, but no data will be returned by `ma_data_source_read_pcm_frames()` until some data is available. When no data is available because the asynchronous decoding hasn't caught up, `MA_BUSY` will be returned by `ma_data_source_read_pcm_frames()`. For large sounds, it's often prohibitive to store the entire file in memory. To mitigate this, you can instead stream audio data which you can do by specifying the `MA_RESOURCE_MANAGER_DATA_SOURCE_FLAG_STREAM` flag. When streaming, data will be decoded in 1 second pages. When a new page needs to be decoded, a job will be posted to the job queue and then subsequently processed in a job thread. For in-memory sounds, reference counting is used to ensure the data is loaded only once. This means multiple calls to `ma_resource_manager_data_source_init()` with the same file path will result in the file data only being loaded once. Each call to `ma_resource_manager_data_source_init()` must be matched up with a call to `ma_resource_manager_data_source_uninit()`. Sometimes it can be useful for a program to register self-managed raw audio data and associate it with a file path. Use the `ma_resource_manager_register_*()` and `ma_resource_manager_unregister_*()` APIs to do this. `ma_resource_manager_register_decoded_data()` is used to associate a pointer to raw, self-managed decoded audio data in the specified data format with the specified name. Likewise, `ma_resource_manager_register_encoded_data()` is used to associate a pointer to raw self-managed encoded audio data (the raw file data) with the specified name. Note that these names need not be actual file paths. When `ma_resource_manager_data_source_init()` is called (without the `MA_RESOURCE_MANAGER_DATA_SOURCE_FLAG_STREAM` flag), the resource manager will look for these explicitly registered data buffers and, if found, will use it as the backing data for the data source. Note that the resource manager does *not* make a copy of this data so it is up to the caller to ensure the pointer stays valid for it's lifetime. Use `ma_resource_manager_unregister_data()` to unregister the self-managed data. You can also use `ma_resource_manager_register_file()` and `ma_resource_manager_unregister_file()` to register and unregister a file. It does not make sense to use the `MA_RESOURCE_MANAGER_DATA_SOURCE_FLAG_STREAM` flag with a self-managed data pointer. 6.1. Asynchronous Loading and Synchronization --------------------------------------------- When loading asynchronously, it can be useful to poll whether or not loading has finished. Use `ma_resource_manager_data_source_result()` to determine this. For in-memory sounds, this will return `MA_SUCCESS` when the file has been *entirely* decoded. If the sound is still being decoded, `MA_BUSY` will be returned. Otherwise, some other error code will be returned if the sound failed to load. For streaming data sources, `MA_SUCCESS` will be returned when the first page has been decoded and the sound is ready to be played. If the first page is still being decoded, `MA_BUSY` will be returned. Otherwise, some other error code will be returned if the sound failed to load. In addition to polling, you can also use a simple synchronization object called a "fence" to wait for asynchronously loaded sounds to finish. This is called `ma_fence`. The advantage to using a fence is that it can be used to wait for a group of sounds to finish loading rather than waiting for sounds on an individual basis. There are two stages to loading a sound: * Initialization of the internal decoder; and * Completion of decoding of the file (the file is fully decoded) You can specify separate fences for each of the different stages. Waiting for the initialization of the internal decoder is important for when you need to know the sample format, channels and sample rate of the file. The example below shows how you could use a fence when loading a number of sounds: ```c // This fence will be released when all sounds are finished loading entirely. ma_fence fence; ma_fence_init(&fence); // This will be passed into the initialization routine for each sound. ma_resource_manager_pipeline_notifications notifications = ma_resource_manager_pipeline_notifications_init(); notifications.done.pFence = &fence; // Now load a bunch of sounds: for (iSound = 0; iSound < soundCount; iSound += 1) { ma_resource_manager_data_source_init(pResourceManager, pSoundFilePaths[iSound], flags, ¬ifications, &pSoundSources[iSound]); } // ... DO SOMETHING ELSE WHILE SOUNDS ARE LOADING ... // Wait for loading of sounds to finish. ma_fence_wait(&fence); ``` In the example above we used a fence for waiting until the entire file has been fully decoded. If you only need to wait for the initialization of the internal decoder to complete, you can use the `init` member of the `ma_resource_manager_pipeline_notifications` object: ```c notifications.init.pFence = &fence; ``` If a fence is not appropriate for your situation, you can instead use a callback that is fired on an individual sound basis. This is done in a very similar way to fences: ```c typedef struct { ma_async_notification_callbacks cb; void* pMyData; } my_notification; void my_notification_callback(ma_async_notification* pNotification) { my_notification* pMyNotification = (my_notification*)pNotification; // Do something in response to the sound finishing loading. } ... my_notification myCallback; myCallback.cb.onSignal = my_notification_callback; myCallback.pMyData = pMyData; ma_resource_manager_pipeline_notifications notifications = ma_resource_manager_pipeline_notifications_init(); notifications.done.pNotification = &myCallback; ma_resource_manager_data_source_init(pResourceManager, "my_sound.wav", flags, ¬ifications, &mySound); ``` In the example above we just extend the `ma_async_notification_callbacks` object and pass an instantiation into the `ma_resource_manager_pipeline_notifications` in the same way as we did with the fence, only we set `pNotification` instead of `pFence`. You can set both of these at the same time and they should both work as expected. If using the `pNotification` system, you need to ensure your `ma_async_notification_callbacks` object stays valid. 6.2. Resource Manager Implementation Details -------------------------------------------- Resources are managed in two main ways: * By storing the entire sound inside an in-memory buffer (referred to as a data buffer) * By streaming audio data on the fly (referred to as a data stream) A resource managed data source (`ma_resource_manager_data_source`) encapsulates a data buffer or data stream, depending on whether or not the data source was initialized with the `MA_RESOURCE_MANAGER_DATA_SOURCE_FLAG_STREAM` flag. If so, it will make use of a `ma_resource_manager_data_stream` object. Otherwise it will use a `ma_resource_manager_data_buffer` object. Both of these objects are data sources which means they can be used with any `ma_data_source_*()` API. Another major feature of the resource manager is the ability to asynchronously decode audio files. This relieves the audio thread of time-consuming decoding which can negatively affect scalability due to the audio thread needing to complete it's work extremely quickly to avoid glitching. Asynchronous decoding is achieved through a job system. There is a central multi-producer, multi-consumer, fixed-capacity job queue. When some asynchronous work needs to be done, a job is posted to the queue which is then read by a job thread. The number of job threads can be configured for improved scalability, and job threads can all run in parallel without needing to worry about the order of execution (how this is achieved is explained below). When a sound is being loaded asynchronously, playback can begin before the sound has been fully decoded. This enables the application to start playback of the sound quickly, while at the same time allowing to resource manager to keep loading in the background. Since there may be less threads than the number of sounds being loaded at a given time, a simple scheduling system is used to keep decoding time balanced and fair. The resource manager solves this by splitting decoding into chunks called pages. By default, each page is 1 second long. When a page has been decoded, a new job will be posted to start decoding the next page. By dividing up decoding into pages, an individual sound shouldn't ever delay every other sound from having their first page decoded. Of course, when loading many sounds at the same time, there will always be an amount of time required to process jobs in the queue so in heavy load situations there will still be some delay. To determine if a data source is ready to have some frames read, use `ma_resource_manager_data_source_get_available_frames()`. This will return the number of frames available starting from the current position. 6.2.1. Job Queue ---------------- The resource manager uses a job queue which is multi-producer, multi-consumer, and fixed-capacity. This job queue is not currently lock-free, and instead uses a spinlock to achieve thread-safety. Only a fixed number of jobs can be allocated and inserted into the queue which is done through a lock-free data structure for allocating an index into a fixed sized array, with reference counting for mitigation of the ABA problem. The reference count is 32-bit. For many types of jobs it's important that they execute in a specific order. In these cases, jobs are executed serially. For the resource manager, serial execution of jobs is only required on a per-object basis (per data buffer or per data stream). Each of these objects stores an execution counter. When a job is posted it is associated with an execution counter. When the job is processed, it checks if the execution counter of the job equals the execution counter of the owning object and if so, processes the job. If the counters are not equal, the job will be posted back onto the job queue for later processing. When the job finishes processing the execution order of the main object is incremented. This system means the no matter how many job threads are executing, decoding of an individual sound will always get processed serially. The advantage to having multiple threads comes into play when loading multiple sounds at the same time. The resource manager's job queue is not 100% lock-free and will use a spinlock to achieve thread-safety for a very small section of code. This is only relevant when the resource manager uses more than one job thread. If only using a single job thread, which is the default, the lock should never actually wait in practice. The amount of time spent locking should be quite short, but it's something to be aware of for those who have pedantic lock-free requirements and need to use more than one job thread. There are plans to remove this lock in a future version. In addition, posting a job will release a semaphore, which on Win32 is implemented with `ReleaseSemaphore` and on POSIX platforms via a condition variable: ```c pthread_mutex_lock(&pSemaphore->lock); { pSemaphore->value += 1; pthread_cond_signal(&pSemaphore->cond); } pthread_mutex_unlock(&pSemaphore->lock); ``` Again, this is relevant for those with strict lock-free requirements in the audio thread. To avoid this, you can use non-blocking mode (via the `MA_JOB_QUEUE_FLAG_NON_BLOCKING` flag) and implement your own job processing routine (see the "Resource Manager" section above for details on how to do this). 6.2.2. Data Buffers ------------------- When the `MA_RESOURCE_MANAGER_DATA_SOURCE_FLAG_STREAM` flag is excluded at initialization time, the resource manager will try to load the data into an in-memory data buffer. Before doing so, however, it will first check if the specified file is already loaded. If so, it will increment a reference counter and just use the already loaded data. This saves both time and memory. When the data buffer is uninitialized, the reference counter will be decremented. If the counter hits zero, the file will be unloaded. This is a detail to keep in mind because it could result in excessive loading and unloading of a sound. For example, the following sequence will result in a file be loaded twice, once after the other: ```c ma_resource_manager_data_source_init(pResourceManager, "my_file", ..., &myDataBuffer0); // Refcount = 1. Initial load. ma_resource_manager_data_source_uninit(&myDataBuffer0); // Refcount = 0. Unloaded. ma_resource_manager_data_source_init(pResourceManager, "my_file", ..., &myDataBuffer1); // Refcount = 1. Reloaded because previous uninit() unloaded it. ma_resource_manager_data_source_uninit(&myDataBuffer1); // Refcount = 0. Unloaded. ``` A binary search tree (BST) is used for storing data buffers as it has good balance between efficiency and simplicity. The key of the BST is a 64-bit hash of the file path that was passed into `ma_resource_manager_data_source_init()`. The advantage of using a hash is that it saves memory over storing the entire path, has faster comparisons, and results in a mostly balanced BST due to the random nature of the hash. The disadvantages are that file names are case-sensitive and there's a small chance of name collisions. If case-sensitivity is an issue, you should normalize your file names to upper- or lower-case before initializing your data sources. If name collisions become an issue, you'll need to change the name of one of the colliding names or just not use the resource manager. When a sound file has not already been loaded and the `MA_RESOURCE_MANAGER_DATA_SOURCE_FLAG_ASYNC` flag is excluded, the file will be decoded synchronously by the calling thread. There are two options for controlling how the audio is stored in the data buffer - encoded or decoded. When the `MA_RESOURCE_MANAGER_DATA_SOURCE_FLAG_DECODE` option is excluded, the raw file data will be stored in memory. Otherwise the sound will be decoded before storing it in memory. Synchronous loading is a very simple and standard process of simply adding an item to the BST, allocating a block of memory and then decoding (if `MA_RESOURCE_MANAGER_DATA_SOURCE_FLAG_DECODE` is specified). When the `MA_RESOURCE_MANAGER_DATA_SOURCE_FLAG_ASYNC` flag is specified, loading of the data buffer is done asynchronously. In this case, a job is posted to the queue to start loading and then the function immediately returns, setting an internal result code to `MA_BUSY`. This result code is returned when the program calls `ma_resource_manager_data_source_result()`. When decoding has fully completed `MA_SUCCESS` will be returned. This can be used to know if loading has fully completed. When loading asynchronously, a single job is posted to the queue of the type `MA_JOB_TYPE_RESOURCE_MANAGER_LOAD_DATA_BUFFER_NODE`. This involves making a copy of the file path and associating it with job. When the job is processed by the job thread, it will first load the file using the VFS associated with the resource manager. When using a custom VFS, it's important that it be completely thread-safe because it will be used from one or more job threads at the same time. Individual files should only ever be accessed by one thread at a time, however. After opening the file via the VFS, the job will determine whether or not the file is being decoded. If not, it simply allocates a block of memory and loads the raw file contents into it and returns. On the other hand, when the file is being decoded, it will first allocate a decoder on the heap and initialize it. Then it will check if the length of the file is known. If so it will allocate a block of memory to store the decoded output and initialize it to silence. If the size is unknown, it will allocate room for one page. After memory has been allocated, the first page will be decoded. If the sound is shorter than a page, the result code will be set to `MA_SUCCESS` and the completion event will be signalled and loading is now complete. If, however, there is more to decode, a job with the code `MA_JOB_TYPE_RESOURCE_MANAGER_PAGE_DATA_BUFFER_NODE` is posted. This job will decode the next page and perform the same process if it reaches the end. If there is more to decode, the job will post another `MA_JOB_TYPE_RESOURCE_MANAGER_PAGE_DATA_BUFFER_NODE` job which will keep on happening until the sound has been fully decoded. For sounds of an unknown length, each page will be linked together as a linked list. Internally this is implemented via the `ma_paged_audio_buffer` object. 6.2.3. Data Streams ------------------- Data streams only ever store two pages worth of data for each instance. They are most useful for large sounds like music tracks in games that would consume too much memory if fully decoded in memory. After every frame from a page has been read, a job will be posted to load the next page which is done from the VFS. For data streams, the `MA_RESOURCE_MANAGER_DATA_SOURCE_FLAG_ASYNC` flag will determine whether or not initialization of the data source waits until the two pages have been decoded. When unset, `ma_resource_manager_data_source_init()` will wait until the two pages have been loaded, otherwise it will return immediately. When frames are read from a data stream using `ma_resource_manager_data_source_read_pcm_frames()`, `MA_BUSY` will be returned if there are no frames available. If there are some frames available, but less than the number requested, `MA_SUCCESS` will be returned, but the actual number of frames read will be less than the number requested. Due to the asynchronous nature of data streams, seeking is also asynchronous. If the data stream is in the middle of a seek, `MA_BUSY` will be returned when trying to read frames. When `ma_resource_manager_data_source_read_pcm_frames()` results in a page getting fully consumed a job is posted to load the next page. This will be posted from the same thread that called `ma_resource_manager_data_source_read_pcm_frames()`. Data streams are uninitialized by posting a job to the queue, but the function won't return until that job has been processed. The reason for this is that the caller owns the data stream object and therefore miniaudio needs to ensure everything completes before handing back control to the caller. Also, if the data stream is uninitialized while pages are in the middle of decoding, they must complete before destroying any underlying object and the job system handles this cleanly. Note that when a new page needs to be loaded, a job will be posted to the resource manager's job thread from the audio thread. You must keep in mind the details mentioned in the "Job Queue" section above regarding locking when posting an event if you require a strictly lock-free audio thread. 7. Node Graph ============= miniaudio's routing infrastructure follows a node graph paradigm. The idea is that you create a node whose outputs are attached to inputs of another node, thereby creating a graph. There are different types of nodes, with each node in the graph processing input data to produce output, which is then fed through the chain. Each node in the graph can apply their own custom effects. At the start of the graph will usually be one or more data source nodes which have no inputs and instead pull their data from a data source. At the end of the graph is an endpoint which represents the end of the chain and is where the final output is ultimately extracted from. Each node has a number of input buses and a number of output buses. An output bus from a node is attached to an input bus of another. Multiple nodes can connect their output buses to another node's input bus, in which case their outputs will be mixed before processing by the node. Below is a diagram that illustrates a hypothetical node graph setup: ``` >>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Data flows left to right >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +---------------+ +-----------------+ | Data Source 1 =----+ +----------+ +----= Low Pass Filter =----+ +---------------+ | | =----+ +-----------------+ | +----------+ +----= Splitter | +----= ENDPOINT | +---------------+ | | =----+ +-----------------+ | +----------+ | Data Source 2 =----+ +----------+ +----= Echo / Delay =----+ +---------------+ +-----------------+ ``` In the above graph, it starts with two data sources whose outputs are attached to the input of a splitter node. It's at this point that the two data sources are mixed. After mixing, the splitter performs it's processing routine and produces two outputs which is simply a duplication of the input stream. One output is attached to a low pass filter, whereas the other output is attached to a echo/delay. The outputs of the the low pass filter and the echo are attached to the endpoint, and since they're both connected to the same input bus, they'll be mixed. Each input bus must be configured to accept the same number of channels, but the number of channels used by input buses can be different to the number of channels for output buses in which case miniaudio will automatically convert the input data to the output channel count before processing. The number of channels of an output bus of one node must match the channel count of the input bus it's attached to. The channel counts cannot be changed after the node has been initialized. If you attempt to attach an output bus to an input bus with a different channel count, attachment will fail. To use a node graph, you first need to initialize a `ma_node_graph` object. This is essentially a container around the entire graph. The `ma_node_graph` object is required for some thread-safety issues which will be explained later. A `ma_node_graph` object is initialized using miniaudio's standard config/init system: ```c ma_node_graph_config nodeGraphConfig = ma_node_graph_config_init(myChannelCount); result = ma_node_graph_init(&nodeGraphConfig, NULL, &nodeGraph); // Second parameter is a pointer to allocation callbacks. if (result != MA_SUCCESS) { // Failed to initialize node graph. } ``` When you initialize the node graph, you're specifying the channel count of the endpoint. The endpoint is a special node which has one input bus and one output bus, both of which have the same channel count, which is specified in the config. Any nodes that connect directly to the endpoint must be configured such that their output buses have the same channel count. When you read audio data from the node graph, it'll have the channel count you specified in the config. To read data from the graph: ```c ma_uint32 framesRead; result = ma_node_graph_read_pcm_frames(&nodeGraph, pFramesOut, frameCount, &framesRead); if (result != MA_SUCCESS) { // Failed to read data from the node graph. } ``` When you read audio data, miniaudio starts at the node graph's endpoint node which then pulls in data from it's input attachments, which in turn recursively pull in data from their inputs, and so on. At the start of the graph there will be some kind of data source node which will have zero inputs and will instead read directly from a data source. The base nodes don't literally need to read from a `ma_data_source` object, but they will always have some kind of underlying object that sources some kind of audio. The `ma_data_source_node` node can be used to read from a `ma_data_source`. Data is always in floating-point format and in the number of channels you specified when the graph was initialized. The sample rate is defined by the underlying data sources. It's up to you to ensure they use a consistent and appropriate sample rate. The `ma_node` API is designed to allow custom nodes to be implemented with relative ease, but miniaudio includes a few stock nodes for common functionality. This is how you would initialize a node which reads directly from a data source (`ma_data_source_node`) which is an example of one of the stock nodes that comes with miniaudio: ```c ma_data_source_node_config config = ma_data_source_node_config_init(pMyDataSource); ma_data_source_node dataSourceNode; result = ma_data_source_node_init(&nodeGraph, &config, NULL, &dataSourceNode); if (result != MA_SUCCESS) { // Failed to create data source node. } ``` The data source node will use the output channel count to determine the channel count of the output bus. There will be 1 output bus and 0 input buses (data will be drawn directly from the data source). The data source must output to floating-point (`ma_format_f32`) or else an error will be returned from `ma_data_source_node_init()`. By default the node will not be attached to the graph. To do so, use `ma_node_attach_output_bus()`: ```c result = ma_node_attach_output_bus(&dataSourceNode, 0, ma_node_graph_get_endpoint(&nodeGraph), 0); if (result != MA_SUCCESS) { // Failed to attach node. } ``` The code above connects the data source node directly to the endpoint. Since the data source node has only a single output bus, the index will always be 0. Likewise, the endpoint only has a single input bus which means the input bus index will also always be 0. To detach a specific output bus, use `ma_node_detach_output_bus()`. To detach all output buses, use `ma_node_detach_all_output_buses()`. If you want to just move the output bus from one attachment to another, you do not need to detach first. You can just call `ma_node_attach_output_bus()` and it'll deal with it for you. Less frequently you may want to create a specialized node. This will be a node where you implement your own processing callback to apply a custom effect of some kind. This is similar to initializing one of the stock node types, only this time you need to specify a pointer to a vtable containing a pointer to the processing function and the number of input and output buses. Example: ```c static void my_custom_node_process_pcm_frames(ma_node* pNode, const float** ppFramesIn, ma_uint32* pFrameCountIn, float** ppFramesOut, ma_uint32* pFrameCountOut) { // Do some processing of ppFramesIn (one stream of audio data per input bus) const float* pFramesIn_0 = ppFramesIn[0]; // Input bus @ index 0. const float* pFramesIn_1 = ppFramesIn[1]; // Input bus @ index 1. float* pFramesOut_0 = ppFramesOut[0]; // Output bus @ index 0. // Do some processing. On input, `pFrameCountIn` will be the number of input frames in each // buffer in `ppFramesIn` and `pFrameCountOut` will be the capacity of each of the buffers // in `ppFramesOut`. On output, `pFrameCountIn` should be set to the number of input frames // your node consumed and `pFrameCountOut` should be set the number of output frames that // were produced. // // You should process as many frames as you can. If your effect consumes input frames at the // same rate as output frames (always the case, unless you're doing resampling), you need // only look at `ppFramesOut` and process that exact number of frames. If you're doing // resampling, you'll need to be sure to set both `pFrameCountIn` and `pFrameCountOut` // properly. } static ma_node_vtable my_custom_node_vtable = { my_custom_node_process_pcm_frames, // The function that will be called to process your custom node. This is where you'd implement your effect processing. NULL, // Optional. A callback for calculating the number of input frames that are required to process a specified number of output frames. 2, // 2 input buses. 1, // 1 output bus. 0 // Default flags. }; ... // Each bus needs to have a channel count specified. To do this you need to specify the channel // counts in an array and then pass that into the node config. ma_uint32 inputChannels[2]; // Equal in size to the number of input channels specified in the vtable. ma_uint32 outputChannels[1]; // Equal in size to the number of output channels specified in the vtable. inputChannels[0] = channelsIn; inputChannels[1] = channelsIn; outputChannels[0] = channelsOut; ma_node_config nodeConfig = ma_node_config_init(); nodeConfig.vtable = &my_custom_node_vtable; nodeConfig.pInputChannels = inputChannels; nodeConfig.pOutputChannels = outputChannels; ma_node_base node; result = ma_node_init(&nodeGraph, &nodeConfig, NULL, &node); if (result != MA_SUCCESS) { // Failed to initialize node. } ``` When initializing a custom node, as in the code above, you'll normally just place your vtable in static space. The number of input and output buses are specified as part of the vtable. If you need a variable number of buses on a per-node bases, the vtable should have the relevant bus count set to `MA_NODE_BUS_COUNT_UNKNOWN`. In this case, the bus count should be set in the node config: ```c static ma_node_vtable my_custom_node_vtable = { my_custom_node_process_pcm_frames, // The function that will be called process your custom node. This is where you'd implement your effect processing. NULL, // Optional. A callback for calculating the number of input frames that are required to process a specified number of output frames. MA_NODE_BUS_COUNT_UNKNOWN, // The number of input buses is determined on a per-node basis. 1, // 1 output bus. 0 // Default flags. }; ... ma_node_config nodeConfig = ma_node_config_init(); nodeConfig.vtable = &my_custom_node_vtable; nodeConfig.inputBusCount = myBusCount; // <-- Since the vtable specifies MA_NODE_BUS_COUNT_UNKNOWN, the input bus count should be set here. nodeConfig.pInputChannels = inputChannels; // <-- Make sure there are nodeConfig.inputBusCount elements in this array. nodeConfig.pOutputChannels = outputChannels; // <-- The vtable specifies 1 output bus, so there must be 1 element in this array. ``` In the above example it's important to never set the `inputBusCount` and `outputBusCount` members to anything other than their defaults if the vtable specifies an explicit count. They can only be set if the vtable specifies MA_NODE_BUS_COUNT_UNKNOWN in the relevant bus count. Most often you'll want to create a structure to encapsulate your node with some extra data. You need to make sure the `ma_node_base` object is your first member of the structure: ```c typedef struct { ma_node_base base; // <-- Make sure this is always the first member. float someCustomData; } my_custom_node; ``` By doing this, your object will be compatible with all `ma_node` APIs and you can attach it to the graph just like any other node. In the custom processing callback (`my_custom_node_process_pcm_frames()` in the example above), the number of channels for each bus is what was specified by the config when the node was initialized with `ma_node_init()`. In addition, all attachments to each of the input buses will have been pre-mixed by miniaudio. The config allows you to specify different channel counts for each individual input and output bus. It's up to the effect to handle it appropriate, and if it can't, return an error in it's initialization routine. Custom nodes can be assigned some flags to describe their behaviour. These are set via the vtable and include the following: +-----------------------------------------+---------------------------------------------------+ | Flag Name | Description | +-----------------------------------------+---------------------------------------------------+ | MA_NODE_FLAG_PASSTHROUGH | Useful for nodes that do not do any kind of audio | | | processing, but are instead used for tracking | | | time, handling events, etc. Also used by the | | | internal endpoint node. It reads directly from | | | the input bus to the output bus. Nodes with this | | | flag must have exactly 1 input bus and 1 output | | | bus, and both buses must have the same channel | | | counts. | +-----------------------------------------+---------------------------------------------------+ | MA_NODE_FLAG_CONTINUOUS_PROCESSING | Causes the processing callback to be called even | | | when no data is available to be read from input | | | attachments. When a node has at least one input | | | bus, but there are no inputs attached or the | | | inputs do not deliver any data, the node's | | | processing callback will not get fired. This flag | | | will make it so the callback is always fired | | | regardless of whether or not any input data is | | | received. This is useful for effects like | | | echos where there will be a tail of audio data | | | that still needs to be processed even when the | | | original data sources have reached their ends. It | | | may also be useful for nodes that must always | | | have their processing callback fired when there | | | are no inputs attached. | +-----------------------------------------+---------------------------------------------------+ | MA_NODE_FLAG_ALLOW_NULL_INPUT | Used in conjunction with | | | `MA_NODE_FLAG_CONTINUOUS_PROCESSING`. When this | | | is set, the `ppFramesIn` parameter of the | | | processing callback will be set to NULL when | | | there are no input frames are available. When | | | this is unset, silence will be posted to the | | | processing callback. | +-----------------------------------------+---------------------------------------------------+ | MA_NODE_FLAG_DIFFERENT_PROCESSING_RATES | Used to tell miniaudio that input and output | | | frames are processed at different rates. You | | | should set this for any nodes that perform | | | resampling. | +-----------------------------------------+---------------------------------------------------+ | MA_NODE_FLAG_SILENT_OUTPUT | Used to tell miniaudio that a node produces only | | | silent output. This is useful for nodes where you | | | don't want the output to contribute to the final | | | mix. An example might be if you want split your | | | stream and have one branch be output to a file. | | | When using this flag, you should avoid writing to | | | the output buffer of the node's processing | | | callback because miniaudio will ignore it anyway. | +-----------------------------------------+---------------------------------------------------+ If you need to make a copy of an audio stream for effect processing you can use a splitter node called `ma_splitter_node`. This takes has 1 input bus and splits the stream into 2 output buses. You can use it like this: ```c ma_splitter_node_config splitterNodeConfig = ma_splitter_node_config_init(channels); ma_splitter_node splitterNode; result = ma_splitter_node_init(&nodeGraph, &splitterNodeConfig, NULL, &splitterNode); if (result != MA_SUCCESS) { // Failed to create node. } // Attach your output buses to two different input buses (can be on two different nodes). ma_node_attach_output_bus(&splitterNode, 0, ma_node_graph_get_endpoint(&nodeGraph), 0); // Attach directly to the endpoint. ma_node_attach_output_bus(&splitterNode, 1, &myEffectNode, 0); // Attach to input bus 0 of some effect node. ``` The volume of an output bus can be configured on a per-bus basis: ```c ma_node_set_output_bus_volume(&splitterNode, 0, 0.5f); ma_node_set_output_bus_volume(&splitterNode, 1, 0.5f); ``` In the code above we're using the splitter node from before and changing the volume of each of the copied streams. You can start and stop a node with the following: ```c ma_node_set_state(&splitterNode, ma_node_state_started); // The default state. ma_node_set_state(&splitterNode, ma_node_state_stopped); ``` By default the node is in a started state, but since it won't be connected to anything won't actually be invoked by the node graph until it's connected. When you stop a node, data will not be read from any of it's input connections. You can use this property to stop a group of sounds atomically. You can configure the initial state of a node in it's config: ```c nodeConfig.initialState = ma_node_state_stopped; ``` Note that for the stock specialized nodes, all of their configs will have a `nodeConfig` member which is the config to use with the base node. This is where the initial state can be configured for specialized nodes: ```c dataSourceNodeConfig.nodeConfig.initialState = ma_node_state_stopped; ``` When using a specialized node like `ma_data_source_node` or `ma_splitter_node`, be sure to not modify the `vtable` member of the `nodeConfig` object. 7.1. Timing ----------- The node graph supports starting and stopping nodes at scheduled times. This is especially useful for data source nodes where you want to get the node set up, but only start playback at a specific time. There are two clocks: local and global. A local clock is per-node, whereas the global clock is per graph. Scheduling starts and stops can only be done based on the global clock because the local clock will not be running while the node is stopped. The global clocks advances whenever `ma_node_graph_read_pcm_frames()` is called. On the other hand, the local clock only advances when the node's processing callback is fired, and is advanced based on the output frame count. To retrieve the global time, use `ma_node_graph_get_time()`. The global time can be set with `ma_node_graph_set_time()` which might be useful if you want to do seeking on a global timeline. Getting and setting the local time is similar. Use `ma_node_get_time()` to retrieve the local time, and `ma_node_set_time()` to set the local time. The global and local times will be advanced by the audio thread, so care should be taken to avoid data races. Ideally you should avoid calling these outside of the node processing callbacks which are always run on the audio thread. There is basic support for scheduling the starting and stopping of nodes. You can only schedule one start and one stop at a time. This is mainly intended for putting nodes into a started or stopped state in a frame-exact manner. Without this mechanism, starting and stopping of a node is limited to the resolution of a call to `ma_node_graph_read_pcm_frames()` which would typically be in blocks of several milliseconds. The following APIs can be used for scheduling node states: ```c ma_node_set_state_time() ma_node_get_state_time() ``` The time is absolute and must be based on the global clock. An example is below: ```c ma_node_set_state_time(&myNode, ma_node_state_started, sampleRate*1); // Delay starting to 1 second. ma_node_set_state_time(&myNode, ma_node_state_stopped, sampleRate*5); // Delay stopping to 5 seconds. ``` An example for changing the state using a relative time. ```c ma_node_set_state_time(&myNode, ma_node_state_started, sampleRate*1 + ma_node_graph_get_time(&myNodeGraph)); ma_node_set_state_time(&myNode, ma_node_state_stopped, sampleRate*5 + ma_node_graph_get_time(&myNodeGraph)); ``` Note that due to the nature of multi-threading the times may not be 100% exact. If this is an issue, consider scheduling state changes from within a processing callback. An idea might be to have some kind of passthrough trigger node that is used specifically for tracking time and handling events. 7.2. Thread Safety and Locking ------------------------------ When processing audio, it's ideal not to have any kind of locking in the audio thread. Since it's expected that `ma_node_graph_read_pcm_frames()` would be run on the audio thread, it does so without the use of any locks. This section discusses the implementation used by miniaudio and goes over some of the compromises employed by miniaudio to achieve this goal. Note that the current implementation may not be ideal - feedback and critiques are most welcome. The node graph API is not *entirely* lock-free. Only `ma_node_graph_read_pcm_frames()` is expected to be lock-free. Attachment, detachment and uninitialization of nodes use locks to simplify the implementation, but are crafted in a way such that such locking is not required when reading audio data from the graph. Locking in these areas are achieved by means of spinlocks. The main complication with keeping `ma_node_graph_read_pcm_frames()` lock-free stems from the fact that a node can be uninitialized, and it's memory potentially freed, while in the middle of being processed on the audio thread. There are times when the audio thread will be referencing a node, which means the uninitialization process of a node needs to make sure it delays returning until the audio thread is finished so that control is not handed back to the caller thereby giving them a chance to free the node's memory. When the audio thread is processing a node, it does so by reading from each of the output buses of the node. In order for a node to process data for one of it's output buses, it needs to read from each of it's input buses, and so on an so forth. It follows that once all output buses of a node are detached, the node as a whole will be disconnected and no further processing will occur unless it's output buses are reattached, which won't be happening when the node is being uninitialized. By having `ma_node_detach_output_bus()` wait until the audio thread is finished with it, we can simplify a few things, at the expense of making `ma_node_detach_output_bus()` a bit slower. By doing this, the implementation of `ma_node_uninit()` becomes trivial - just detach all output nodes, followed by each of the attachments to each of it's input nodes, and then do any final clean up. With the above design, the worst-case scenario is `ma_node_detach_output_bus()` taking as long as it takes to process the output bus being detached. This will happen if it's called at just the wrong moment where the audio thread has just iterated it and has just started processing. The caller of `ma_node_detach_output_bus()` will stall until the audio thread is finished, which includes the cost of recursively processing it's inputs. This is the biggest compromise made with the approach taken by miniaudio for it's lock-free processing system. The cost of detaching nodes earlier in the pipeline (data sources, for example) will be cheaper than the cost of detaching higher level nodes, such as some kind of final post-processing endpoint. If you need to do mass detachments, detach starting from the lowest level nodes and work your way towards the final endpoint node (but don't try detaching the node graph's endpoint). If the audio thread is not running, detachment will be fast and detachment in any order will be the same. The reason nodes need to wait for their input attachments to complete is due to the potential for desyncs between data sources. If the node was to terminate processing mid way through processing it's inputs, there's a chance that some of the underlying data sources will have been read, but then others not. That will then result in a potential desynchronization when detaching and reattaching higher-level nodes. A possible solution to this is to have an option when detaching to terminate processing before processing all input attachments which should be fairly simple. Another compromise, albeit less significant, is locking when attaching and detaching nodes. This locking is achieved by means of a spinlock in order to reduce memory overhead. A lock is present for each input bus and output bus. When an output bus is connected to an input bus, both the output bus and input bus is locked. This locking is specifically for attaching and detaching across different threads and does not affect `ma_node_graph_read_pcm_frames()` in any way. The locking and unlocking is mostly self-explanatory, but a slightly less intuitive aspect comes into it when considering that iterating over attachments must not break as a result of attaching or detaching a node while iteration is occurring. Attaching and detaching are both quite simple. When an output bus of a node is attached to an input bus of another node, it's added to a linked list. Basically, an input bus is a linked list, where each item in the list is and output bus. We have some intentional (and convenient) restrictions on what can done with the linked list in order to simplify the implementation. First of all, whenever something needs to iterate over the list, it must do so in a forward direction. Backwards iteration is not supported. Also, items can only be added to the start of the list. The linked list is a doubly-linked list where each item in the list (an output bus) holds a pointer to the next item in the list, and another to the previous item. A pointer to the previous item is only required for fast detachment of the node - it is never used in iteration. This is an important property because it means from the perspective of iteration, attaching and detaching of an item can be done with a single atomic assignment. This is exploited by both the attachment and detachment process. When attaching the node, the first thing that is done is the setting of the local "next" and "previous" pointers of the node. After that, the item is "attached" to the list by simply performing an atomic exchange with the head pointer. After that, the node is "attached" to the list from the perspective of iteration. Even though the "previous" pointer of the next item hasn't yet been set, from the perspective of iteration it's been attached because iteration will only be happening in a forward direction which means the "previous" pointer won't actually ever get used. The same general process applies to detachment. See `ma_node_attach_output_bus()` and `ma_node_detach_output_bus()` for the implementation of this mechanism. 8. Decoding =========== The `ma_decoder` API is used for reading audio files. Decoders are completely decoupled from devices and can be used independently. Built-in support is included for the following formats: +---------+ | Format | +---------+ | WAV | | MP3 | | FLAC | +---------+ You can disable the built-in decoders by specifying one or more of the following options before the miniaudio implementation: ```c #define MA_NO_WAV #define MA_NO_MP3 #define MA_NO_FLAC ``` miniaudio supports the ability to plug in custom decoders. See the section below for details on how to use custom decoders. A decoder can be initialized from a file with `ma_decoder_init_file()`, a block of memory with `ma_decoder_init_memory()`, or from data delivered via callbacks with `ma_decoder_init()`. Here is an example for loading a decoder from a file: ```c ma_decoder decoder; ma_result result = ma_decoder_init_file("MySong.mp3", NULL, &decoder); if (result != MA_SUCCESS) { return false; // An error occurred. } ... ma_decoder_uninit(&decoder); ``` When initializing a decoder, you can optionally pass in a pointer to a `ma_decoder_config` object (the `NULL` argument in the example above) which allows you to configure the output format, channel count, sample rate and channel map: ```c ma_decoder_config config = ma_decoder_config_init(ma_format_f32, 2, 48000); ``` When passing in `NULL` for decoder config in `ma_decoder_init*()`, the output format will be the same as that defined by the decoding backend. Data is read from the decoder as PCM frames. This will output the number of PCM frames actually read. If this is less than the requested number of PCM frames it means you've reached the end. The return value will be `MA_AT_END` if no samples have been read and the end has been reached. ```c ma_result result = ma_decoder_read_pcm_frames(pDecoder, pFrames, framesToRead, &framesRead); if (framesRead < framesToRead) { // Reached the end. } ``` You can also seek to a specific frame like so: ```c ma_result result = ma_decoder_seek_to_pcm_frame(pDecoder, targetFrame); if (result != MA_SUCCESS) { return false; // An error occurred. } ``` If you want to loop back to the start, you can simply seek back to the first PCM frame: ```c ma_decoder_seek_to_pcm_frame(pDecoder, 0); ``` When loading a decoder, miniaudio uses a trial and error technique to find the appropriate decoding backend. This can be unnecessarily inefficient if the type is already known. In this case you can use `encodingFormat` variable in the device config to specify a specific encoding format you want to decode: ```c decoderConfig.encodingFormat = ma_encoding_format_wav; ``` See the `ma_encoding_format` enum for possible encoding formats. The `ma_decoder_init_file()` API will try using the file extension to determine which decoding backend to prefer. 8.1. Custom Decoders -------------------- It's possible to implement a custom decoder and plug it into miniaudio. This is extremely useful when you want to use the `ma_decoder` API, but need to support an encoding format that's not one of the stock formats supported by miniaudio. This can be put to particularly good use when using the `ma_engine` and/or `ma_resource_manager` APIs because they use `ma_decoder` internally. If, for example, you wanted to support Opus, you can do so with a custom decoder (there if a reference Opus decoder in the "extras" folder of the miniaudio repository which uses libopus + libopusfile). A custom decoder must implement a data source. A vtable called `ma_decoding_backend_vtable` needs to be implemented which is then passed into the decoder config: ```c ma_decoding_backend_vtable* pCustomBackendVTables[] = { &g_ma_decoding_backend_vtable_libvorbis, &g_ma_decoding_backend_vtable_libopus }; ... decoderConfig = ma_decoder_config_init_default(); decoderConfig.pCustomBackendUserData = NULL; decoderConfig.ppCustomBackendVTables = pCustomBackendVTables; decoderConfig.customBackendCount = sizeof(pCustomBackendVTables) / sizeof(pCustomBackendVTables[0]); ``` The `ma_decoding_backend_vtable` vtable has the following functions: ``` onInit onInitFile onInitFileW onInitMemory onUninit ``` There are only two functions that must be implemented - `onInit` and `onUninit`. The other functions can be implemented for a small optimization for loading from a file path or memory. If these are not specified, miniaudio will deal with it for you via a generic implementation. When you initialize a custom data source (by implementing the `onInit` function in the vtable) you will need to output a pointer to a `ma_data_source` which implements your custom decoder. See the section about data sources for details on how to implement this. Alternatively, see the "custom_decoders" example in the miniaudio repository. The `onInit` function takes a pointer to some callbacks for the purpose of reading raw audio data from some arbitrary source. You'll use these functions to read from the raw data and perform the decoding. When you call them, you will pass in the `pReadSeekTellUserData` pointer to the relevant parameter. The `pConfig` parameter in `onInit` can be used to configure the backend if appropriate. It's only used as a hint and can be ignored. However, if any of the properties are relevant to your decoder, an optimal implementation will handle the relevant properties appropriately. If memory allocation is required, it should be done so via the specified allocation callbacks if possible (the `pAllocationCallbacks` parameter). If an error occurs when initializing the decoder, you should leave `ppBackend` unset, or set to NULL, and make sure everything is cleaned up appropriately and an appropriate result code returned. When multiple custom backends are specified, miniaudio will cycle through the vtables in the order they're listed in the array that's passed into the decoder config so it's important that your initialization routine is clean. When a decoder is uninitialized, the `onUninit` callback will be fired which will give you an opportunity to clean up and internal data. 9. Encoding =========== The `ma_encoding` API is used for writing audio files. The only supported output format is WAV. This can be disabled by specifying the following option before the implementation of miniaudio: ```c #define MA_NO_WAV ``` An encoder can be initialized to write to a file with `ma_encoder_init_file()` or from data delivered via callbacks with `ma_encoder_init()`. Below is an example for initializing an encoder to output to a file. ```c ma_encoder_config config = ma_encoder_config_init(ma_encoding_format_wav, FORMAT, CHANNELS, SAMPLE_RATE); ma_encoder encoder; ma_result result = ma_encoder_init_file("my_file.wav", &config, &encoder); if (result != MA_SUCCESS) { // Error } ... ma_encoder_uninit(&encoder); ``` When initializing an encoder you must specify a config which is initialized with `ma_encoder_config_init()`. Here you must specify the file type, the output sample format, output channel count and output sample rate. The following file types are supported: +------------------------+-------------+ | Enum | Description | +------------------------+-------------+ | ma_encoding_format_wav | WAV | +------------------------+-------------+ If the format, channel count or sample rate is not supported by the output file type an error will be returned. The encoder will not perform data conversion so you will need to convert it before outputting any audio data. To output audio data, use `ma_encoder_write_pcm_frames()`, like in the example below: ```c ma_uint64 framesWritten; result = ma_encoder_write_pcm_frames(&encoder, pPCMFramesToWrite, framesToWrite, &framesWritten); if (result != MA_SUCCESS) { ... handle error ... } ``` The `framesWritten` variable will contain the number of PCM frames that were actually written. This is optionally and you can pass in `NULL` if you need this. Encoders must be uninitialized with `ma_encoder_uninit()`. 10. Data Conversion =================== A data conversion API is included with miniaudio which supports the majority of data conversion requirements. This supports conversion between sample formats, channel counts (with channel mapping) and sample rates. 10.1. Sample Format Conversion ------------------------------ Conversion between sample formats is achieved with the `ma_pcm_*_to_*()`, `ma_pcm_convert()` and `ma_convert_pcm_frames_format()` APIs. Use `ma_pcm_*_to_*()` to convert between two specific formats. Use `ma_pcm_convert()` to convert based on a `ma_format` variable. Use `ma_convert_pcm_frames_format()` to convert PCM frames where you want to specify the frame count and channel count as a variable instead of the total sample count. 10.1.1. Dithering ----------------- Dithering can be set using the ditherMode parameter. The different dithering modes include the following, in order of efficiency: +-----------+--------------------------+ | Type | Enum Token | +-----------+--------------------------+ | None | ma_dither_mode_none | | Rectangle | ma_dither_mode_rectangle | | Triangle | ma_dither_mode_triangle | +-----------+--------------------------+ Note that even if the dither mode is set to something other than `ma_dither_mode_none`, it will be ignored for conversions where dithering is not needed. Dithering is available for the following conversions: ``` s16 -> u8 s24 -> u8 s32 -> u8 f32 -> u8 s24 -> s16 s32 -> s16 f32 -> s16 ``` Note that it is not an error to pass something other than ma_dither_mode_none for conversions where dither is not used. It will just be ignored. 10.2. Channel Conversion ------------------------ Channel conversion is used for channel rearrangement and conversion from one channel count to another. The `ma_channel_converter` API is used for channel conversion. Below is an example of initializing a simple channel converter which converts from mono to stereo. ```c ma_channel_converter_config config = ma_channel_converter_config_init( ma_format, // Sample format 1, // Input channels NULL, // Input channel map 2, // Output channels NULL, // Output channel map ma_channel_mix_mode_default); // The mixing algorithm to use when combining channels. result = ma_channel_converter_init(&config, NULL, &converter); if (result != MA_SUCCESS) { // Error. } ``` To perform the conversion simply call `ma_channel_converter_process_pcm_frames()` like so: ```c ma_result result = ma_channel_converter_process_pcm_frames(&converter, pFramesOut, pFramesIn, frameCount); if (result != MA_SUCCESS) { // Error. } ``` It is up to the caller to ensure the output buffer is large enough to accommodate the new PCM frames. Input and output PCM frames are always interleaved. Deinterleaved layouts are not supported. 10.2.1. Channel Mapping ----------------------- In addition to converting from one channel count to another, like the example above, the channel converter can also be used to rearrange channels. When initializing the channel converter, you can optionally pass in channel maps for both the input and output frames. If the channel counts are the same, and each channel map contains the same channel positions with the exception that they're in a different order, a simple shuffling of the channels will be performed. If, however, there is not a 1:1 mapping of channel positions, or the channel counts differ, the input channels will be mixed based on a mixing mode which is specified when initializing the `ma_channel_converter_config` object. When converting from mono to multi-channel, the mono channel is simply copied to each output channel. When going the other way around, the audio of each output channel is simply averaged and copied to the mono channel. In more complicated cases blending is used. The `ma_channel_mix_mode_simple` mode will drop excess channels and silence extra channels. For example, converting from 4 to 2 channels, the 3rd and 4th channels will be dropped, whereas converting from 2 to 4 channels will put silence into the 3rd and 4th channels. The `ma_channel_mix_mode_rectangle` mode uses spacial locality based on a rectangle to compute a simple distribution between input and output. Imagine sitting in the middle of a room, with speakers on the walls representing channel positions. The `MA_CHANNEL_FRONT_LEFT` position can be thought of as being in the corner of the front and left walls. Finally, the `ma_channel_mix_mode_custom_weights` mode can be used to use custom user-defined weights. Custom weights can be passed in as the last parameter of `ma_channel_converter_config_init()`. Predefined channel maps can be retrieved with `ma_channel_map_init_standard()`. This takes a `ma_standard_channel_map` enum as it's first parameter, which can be one of the following: +-----------------------------------+-----------------------------------------------------------+ | Name | Description | +-----------------------------------+-----------------------------------------------------------+ | ma_standard_channel_map_default | Default channel map used by miniaudio. See below. | | ma_standard_channel_map_microsoft | Channel map used by Microsoft's bitfield channel maps. | | ma_standard_channel_map_alsa | Default ALSA channel map. | | ma_standard_channel_map_rfc3551 | RFC 3551. Based on AIFF. | | ma_standard_channel_map_flac | FLAC channel map. | | ma_standard_channel_map_vorbis | Vorbis channel map. | | ma_standard_channel_map_sound4 | FreeBSD's sound(4). | | ma_standard_channel_map_sndio | sndio channel map. http://www.sndio.org/tips.html. | | ma_standard_channel_map_webaudio | https://webaudio.github.io/web-audio-api/#ChannelOrdering | +-----------------------------------+-----------------------------------------------------------+ Below are the channel maps used by default in miniaudio (`ma_standard_channel_map_default`): +---------------+---------------------------------+ | Channel Count | Mapping | +---------------+---------------------------------+ | 1 (Mono) | 0: MA_CHANNEL_MONO | +---------------+---------------------------------+ | 2 (Stereo) | 0: MA_CHANNEL_FRONT_LEFT
| | | 1: MA_CHANNEL_FRONT_RIGHT | +---------------+---------------------------------+ | 3 | 0: MA_CHANNEL_FRONT_LEFT
| | | 1: MA_CHANNEL_FRONT_RIGHT
| | | 2: MA_CHANNEL_FRONT_CENTER | +---------------+---------------------------------+ | 4 (Surround) | 0: MA_CHANNEL_FRONT_LEFT
| | | 1: MA_CHANNEL_FRONT_RIGHT
| | | 2: MA_CHANNEL_FRONT_CENTER
| | | 3: MA_CHANNEL_BACK_CENTER | +---------------+---------------------------------+ | 5 | 0: MA_CHANNEL_FRONT_LEFT
| | | 1: MA_CHANNEL_FRONT_RIGHT
| | | 2: MA_CHANNEL_FRONT_CENTER
| | | 3: MA_CHANNEL_BACK_LEFT
| | | 4: MA_CHANNEL_BACK_RIGHT | +---------------+---------------------------------+ | 6 (5.1) | 0: MA_CHANNEL_FRONT_LEFT
| | | 1: MA_CHANNEL_FRONT_RIGHT
| | | 2: MA_CHANNEL_FRONT_CENTER
| | | 3: MA_CHANNEL_LFE
| | | 4: MA_CHANNEL_SIDE_LEFT
| | | 5: MA_CHANNEL_SIDE_RIGHT | +---------------+---------------------------------+ | 7 | 0: MA_CHANNEL_FRONT_LEFT
| | | 1: MA_CHANNEL_FRONT_RIGHT
| | | 2: MA_CHANNEL_FRONT_CENTER
| | | 3: MA_CHANNEL_LFE
| | | 4: MA_CHANNEL_BACK_CENTER
| | | 4: MA_CHANNEL_SIDE_LEFT
| | | 5: MA_CHANNEL_SIDE_RIGHT | +---------------+---------------------------------+ | 8 (7.1) | 0: MA_CHANNEL_FRONT_LEFT
| | | 1: MA_CHANNEL_FRONT_RIGHT
| | | 2: MA_CHANNEL_FRONT_CENTER
| | | 3: MA_CHANNEL_LFE
| | | 4: MA_CHANNEL_BACK_LEFT
| | | 5: MA_CHANNEL_BACK_RIGHT
| | | 6: MA_CHANNEL_SIDE_LEFT
| | | 7: MA_CHANNEL_SIDE_RIGHT | +---------------+---------------------------------+ | Other | All channels set to 0. This | | | is equivalent to the same | | | mapping as the device. | +---------------+---------------------------------+ 10.3. Resampling ---------------- Resampling is achieved with the `ma_resampler` object. To create a resampler object, do something like the following: ```c ma_resampler_config config = ma_resampler_config_init( ma_format_s16, channels, sampleRateIn, sampleRateOut, ma_resample_algorithm_linear); ma_resampler resampler; ma_result result = ma_resampler_init(&config, &resampler); if (result != MA_SUCCESS) { // An error occurred... } ``` Do the following to uninitialize the resampler: ```c ma_resampler_uninit(&resampler); ``` The following example shows how data can be processed ```c ma_uint64 frameCountIn = 1000; ma_uint64 frameCountOut = 2000; ma_result result = ma_resampler_process_pcm_frames(&resampler, pFramesIn, &frameCountIn, pFramesOut, &frameCountOut); if (result != MA_SUCCESS) { // An error occurred... } // At this point, frameCountIn contains the number of input frames that were consumed and frameCountOut contains the // number of output frames written. ``` To initialize the resampler you first need to set up a config (`ma_resampler_config`) with `ma_resampler_config_init()`. You need to specify the sample format you want to use, the number of channels, the input and output sample rate, and the algorithm. The sample format can be either `ma_format_s16` or `ma_format_f32`. If you need a different format you will need to perform pre- and post-conversions yourself where necessary. Note that the format is the same for both input and output. The format cannot be changed after initialization. The resampler supports multiple channels and is always interleaved (both input and output). The channel count cannot be changed after initialization. The sample rates can be anything other than zero, and are always specified in hertz. They should be set to something like 44100, etc. The sample rate is the only configuration property that can be changed after initialization. The miniaudio resampler has built-in support for the following algorithms: +-----------+------------------------------+ | Algorithm | Enum Token | +-----------+------------------------------+ | Linear | ma_resample_algorithm_linear | | Custom | ma_resample_algorithm_custom | +-----------+------------------------------+ The algorithm cannot be changed after initialization. Processing always happens on a per PCM frame basis and always assumes interleaved input and output. De-interleaved processing is not supported. To process frames, use `ma_resampler_process_pcm_frames()`. On input, this function takes the number of output frames you can fit in the output buffer and the number of input frames contained in the input buffer. On output these variables contain the number of output frames that were written to the output buffer and the number of input frames that were consumed in the process. You can pass in NULL for the input buffer in which case it will be treated as an infinitely large buffer of zeros. The output buffer can also be NULL, in which case the processing will be treated as seek. The sample rate can be changed dynamically on the fly. You can change this with explicit sample rates with `ma_resampler_set_rate()` and also with a decimal ratio with `ma_resampler_set_rate_ratio()`. The ratio is in/out. Sometimes it's useful to know exactly how many input frames will be required to output a specific number of frames. You can calculate this with `ma_resampler_get_required_input_frame_count()`. Likewise, it's sometimes useful to know exactly how many frames would be output given a certain number of input frames. You can do this with `ma_resampler_get_expected_output_frame_count()`. Due to the nature of how resampling works, the resampler introduces some latency. This can be retrieved in terms of both the input rate and the output rate with `ma_resampler_get_input_latency()` and `ma_resampler_get_output_latency()`. 10.3.1. Resampling Algorithms ----------------------------- The choice of resampling algorithm depends on your situation and requirements. 10.3.1.1. Linear Resampling --------------------------- The linear resampler is the fastest, but comes at the expense of poorer quality. There is, however, some control over the quality of the linear resampler which may make it a suitable option depending on your requirements. The linear resampler performs low-pass filtering before or after downsampling or upsampling, depending on the sample rates you're converting between. When decreasing the sample rate, the low-pass filter will be applied before downsampling. When increasing the rate it will be performed after upsampling. By default a fourth order low-pass filter will be applied. This can be configured via the `lpfOrder` configuration variable. Setting this to 0 will disable filtering. The low-pass filter has a cutoff frequency which defaults to half the sample rate of the lowest of the input and output sample rates (Nyquist Frequency). The API for the linear resampler is the same as the main resampler API, only it's called `ma_linear_resampler`. 10.3.2. Custom Resamplers ------------------------- You can implement a custom resampler by using the `ma_resample_algorithm_custom` resampling algorithm and setting a vtable in the resampler config: ```c ma_resampler_config config = ma_resampler_config_init(..., ma_resample_algorithm_custom); config.pBackendVTable = &g_customResamplerVTable; ``` Custom resamplers are useful if the stock algorithms are not appropriate for your use case. You need to implement the required functions in `ma_resampling_backend_vtable`. Note that not all functions in the vtable need to be implemented, but if it's possible to implement, they should be. You can use the `ma_linear_resampler` object for an example on how to implement the vtable. The `onGetHeapSize` callback is used to calculate the size of any internal heap allocation the custom resampler will need to make given the supplied config. When you initialize the resampler via the `onInit` callback, you'll be given a pointer to a heap allocation which is where you should store the heap allocated data. You should not free this data in `onUninit` because miniaudio will manage it for you. The `onProcess` callback is where the actual resampling takes place. On input, `pFrameCountIn` points to a variable containing the number of frames in the `pFramesIn` buffer and `pFrameCountOut` points to a variable containing the capacity in frames of the `pFramesOut` buffer. On output, `pFrameCountIn` should be set to the number of input frames that were fully consumed, whereas `pFrameCountOut` should be set to the number of frames that were written to `pFramesOut`. The `onSetRate` callback is optional and is used for dynamically changing the sample rate. If dynamic rate changes are not supported, you can set this callback to NULL. The `onGetInputLatency` and `onGetOutputLatency` functions are used for retrieving the latency in input and output rates respectively. These can be NULL in which case latency calculations will be assumed to be NULL. The `onGetRequiredInputFrameCount` callback is used to give miniaudio a hint as to how many input frames are required to be available to produce the given number of output frames. Likewise, the `onGetExpectedOutputFrameCount` callback is used to determine how many output frames will be produced given the specified number of input frames. miniaudio will use these as a hint, but they are optional and can be set to NULL if you're unable to implement them. 10.4. General Data Conversion ----------------------------- The `ma_data_converter` API can be used to wrap sample format conversion, channel conversion and resampling into one operation. This is what miniaudio uses internally to convert between the format requested when the device was initialized and the format of the backend's native device. The API for general data conversion is very similar to the resampling API. Create a `ma_data_converter` object like this: ```c ma_data_converter_config config = ma_data_converter_config_init( inputFormat, outputFormat, inputChannels, outputChannels, inputSampleRate, outputSampleRate ); ma_data_converter converter; ma_result result = ma_data_converter_init(&config, NULL, &converter); if (result != MA_SUCCESS) { // An error occurred... } ``` In the example above we use `ma_data_converter_config_init()` to initialize the config, however there's many more properties that can be configured, such as channel maps and resampling quality. Something like the following may be more suitable depending on your requirements: ```c ma_data_converter_config config = ma_data_converter_config_init_default(); config.formatIn = inputFormat; config.formatOut = outputFormat; config.channelsIn = inputChannels; config.channelsOut = outputChannels; config.sampleRateIn = inputSampleRate; config.sampleRateOut = outputSampleRate; ma_channel_map_init_standard(ma_standard_channel_map_flac, config.channelMapIn, sizeof(config.channelMapIn)/sizeof(config.channelMapIn[0]), config.channelCountIn); config.resampling.linear.lpfOrder = MA_MAX_FILTER_ORDER; ``` Do the following to uninitialize the data converter: ```c ma_data_converter_uninit(&converter, NULL); ``` The following example shows how data can be processed ```c ma_uint64 frameCountIn = 1000; ma_uint64 frameCountOut = 2000; ma_result result = ma_data_converter_process_pcm_frames(&converter, pFramesIn, &frameCountIn, pFramesOut, &frameCountOut); if (result != MA_SUCCESS) { // An error occurred... } // At this point, frameCountIn contains the number of input frames that were consumed and frameCountOut contains the number // of output frames written. ``` The data converter supports multiple channels and is always interleaved (both input and output). The channel count cannot be changed after initialization. Sample rates can be anything other than zero, and are always specified in hertz. They should be set to something like 44100, etc. The sample rate is the only configuration property that can be changed after initialization, but only if the `resampling.allowDynamicSampleRate` member of `ma_data_converter_config` is set to `MA_TRUE`. To change the sample rate, use `ma_data_converter_set_rate()` or `ma_data_converter_set_rate_ratio()`. The ratio must be in/out. The resampling algorithm cannot be changed after initialization. Processing always happens on a per PCM frame basis and always assumes interleaved input and output. De-interleaved processing is not supported. To process frames, use `ma_data_converter_process_pcm_frames()`. On input, this function takes the number of output frames you can fit in the output buffer and the number of input frames contained in the input buffer. On output these variables contain the number of output frames that were written to the output buffer and the number of input frames that were consumed in the process. You can pass in NULL for the input buffer in which case it will be treated as an infinitely large buffer of zeros. The output buffer can also be NULL, in which case the processing will be treated as seek. Sometimes it's useful to know exactly how many input frames will be required to output a specific number of frames. You can calculate this with `ma_data_converter_get_required_input_frame_count()`. Likewise, it's sometimes useful to know exactly how many frames would be output given a certain number of input frames. You can do this with `ma_data_converter_get_expected_output_frame_count()`. Due to the nature of how resampling works, the data converter introduces some latency if resampling is required. This can be retrieved in terms of both the input rate and the output rate with `ma_data_converter_get_input_latency()` and `ma_data_converter_get_output_latency()`. 11. Filtering ============= 11.1. Biquad Filtering ---------------------- Biquad filtering is achieved with the `ma_biquad` API. Example: ```c ma_biquad_config config = ma_biquad_config_init(ma_format_f32, channels, b0, b1, b2, a0, a1, a2); ma_result result = ma_biquad_init(&config, &biquad); if (result != MA_SUCCESS) { // Error. } ... ma_biquad_process_pcm_frames(&biquad, pFramesOut, pFramesIn, frameCount); ``` Biquad filtering is implemented using transposed direct form 2. The numerator coefficients are b0, b1 and b2, and the denominator coefficients are a0, a1 and a2. The a0 coefficient is required and coefficients must not be pre-normalized. Supported formats are `ma_format_s16` and `ma_format_f32`. If you need to use a different format you need to convert it yourself beforehand. When using `ma_format_s16` the biquad filter will use fixed point arithmetic. When using `ma_format_f32`, floating point arithmetic will be used. Input and output frames are always interleaved. Filtering can be applied in-place by passing in the same pointer for both the input and output buffers, like so: ```c ma_biquad_process_pcm_frames(&biquad, pMyData, pMyData, frameCount); ``` If you need to change the values of the coefficients, but maintain the values in the registers you can do so with `ma_biquad_reinit()`. This is useful if you need to change the properties of the filter while keeping the values of registers valid to avoid glitching. Do not use `ma_biquad_init()` for this as it will do a full initialization which involves clearing the registers to 0. Note that changing the format or channel count after initialization is invalid and will result in an error. 11.2. Low-Pass Filtering ------------------------ Low-pass filtering is achieved with the following APIs: +---------+------------------------------------------+ | API | Description | +---------+------------------------------------------+ | ma_lpf1 | First order low-pass filter | | ma_lpf2 | Second order low-pass filter | | ma_lpf | High order low-pass filter (Butterworth) | +---------+------------------------------------------+ Low-pass filter example: ```c ma_lpf_config config = ma_lpf_config_init(ma_format_f32, channels, sampleRate, cutoffFrequency, order); ma_result result = ma_lpf_init(&config, &lpf); if (result != MA_SUCCESS) { // Error. } ... ma_lpf_process_pcm_frames(&lpf, pFramesOut, pFramesIn, frameCount); ``` Supported formats are `ma_format_s16` and` ma_format_f32`. If you need to use a different format you need to convert it yourself beforehand. Input and output frames are always interleaved. Filtering can be applied in-place by passing in the same pointer for both the input and output buffers, like so: ```c ma_lpf_process_pcm_frames(&lpf, pMyData, pMyData, frameCount); ``` The maximum filter order is limited to `MA_MAX_FILTER_ORDER` which is set to 8. If you need more, you can chain first and second order filters together. ```c for (iFilter = 0; iFilter < filterCount; iFilter += 1) { ma_lpf2_process_pcm_frames(&lpf2[iFilter], pMyData, pMyData, frameCount); } ``` If you need to change the configuration of the filter, but need to maintain the state of internal registers you can do so with `ma_lpf_reinit()`. This may be useful if you need to change the sample rate and/or cutoff frequency dynamically while maintaining smooth transitions. Note that changing the format or channel count after initialization is invalid and will result in an error. The `ma_lpf` object supports a configurable order, but if you only need a first order filter you may want to consider using `ma_lpf1`. Likewise, if you only need a second order filter you can use `ma_lpf2`. The advantage of this is that they're lighter weight and a bit more efficient. If an even filter order is specified, a series of second order filters will be processed in a chain. If an odd filter order is specified, a first order filter will be applied, followed by a series of second order filters in a chain. 11.3. High-Pass Filtering ------------------------- High-pass filtering is achieved with the following APIs: +---------+-------------------------------------------+ | API | Description | +---------+-------------------------------------------+ | ma_hpf1 | First order high-pass filter | | ma_hpf2 | Second order high-pass filter | | ma_hpf | High order high-pass filter (Butterworth) | +---------+-------------------------------------------+ High-pass filters work exactly the same as low-pass filters, only the APIs are called `ma_hpf1`, `ma_hpf2` and `ma_hpf`. See example code for low-pass filters for example usage. 11.4. Band-Pass Filtering ------------------------- Band-pass filtering is achieved with the following APIs: +---------+-------------------------------+ | API | Description | +---------+-------------------------------+ | ma_bpf2 | Second order band-pass filter | | ma_bpf | High order band-pass filter | +---------+-------------------------------+ Band-pass filters work exactly the same as low-pass filters, only the APIs are called `ma_bpf2` and `ma_hpf`. See example code for low-pass filters for example usage. Note that the order for band-pass filters must be an even number which means there is no first order band-pass filter, unlike low-pass and high-pass filters. 11.5. Notch Filtering --------------------- Notch filtering is achieved with the following APIs: +-----------+------------------------------------------+ | API | Description | +-----------+------------------------------------------+ | ma_notch2 | Second order notching filter | +-----------+------------------------------------------+ 11.6. Peaking EQ Filtering ------------------------- Peaking filtering is achieved with the following APIs: +----------+------------------------------------------+ | API | Description | +----------+------------------------------------------+ | ma_peak2 | Second order peaking filter | +----------+------------------------------------------+ 11.7. Low Shelf Filtering ------------------------- Low shelf filtering is achieved with the following APIs: +-------------+------------------------------------------+ | API | Description | +-------------+------------------------------------------+ | ma_loshelf2 | Second order low shelf filter | +-------------+------------------------------------------+ Where a high-pass filter is used to eliminate lower frequencies, a low shelf filter can be used to just turn them down rather than eliminate them entirely. 11.8. High Shelf Filtering -------------------------- High shelf filtering is achieved with the following APIs: +-------------+------------------------------------------+ | API | Description | +-------------+------------------------------------------+ | ma_hishelf2 | Second order high shelf filter | +-------------+------------------------------------------+ The high shelf filter has the same API as the low shelf filter, only you would use `ma_hishelf` instead of `ma_loshelf`. Where a low shelf filter is used to adjust the volume of low frequencies, the high shelf filter does the same thing for high frequencies. 12. Waveform and Noise Generation ================================= 12.1. Waveforms --------------- miniaudio supports generation of sine, square, triangle and sawtooth waveforms. This is achieved with the `ma_waveform` API. Example: ```c ma_waveform_config config = ma_waveform_config_init( FORMAT, CHANNELS, SAMPLE_RATE, ma_waveform_type_sine, amplitude, frequency); ma_waveform waveform; ma_result result = ma_waveform_init(&config, &waveform); if (result != MA_SUCCESS) { // Error. } ... ma_waveform_read_pcm_frames(&waveform, pOutput, frameCount); ``` The amplitude, frequency, type, and sample rate can be changed dynamically with `ma_waveform_set_amplitude()`, `ma_waveform_set_frequency()`, `ma_waveform_set_type()`, and `ma_waveform_set_sample_rate()` respectively. You can invert the waveform by setting the amplitude to a negative value. You can use this to control whether or not a sawtooth has a positive or negative ramp, for example. Below are the supported waveform types: +---------------------------+ | Enum Name | +---------------------------+ | ma_waveform_type_sine | | ma_waveform_type_square | | ma_waveform_type_triangle | | ma_waveform_type_sawtooth | +---------------------------+ 12.2. Noise ----------- miniaudio supports generation of white, pink and Brownian noise via the `ma_noise` API. Example: ```c ma_noise_config config = ma_noise_config_init( FORMAT, CHANNELS, ma_noise_type_white, SEED, amplitude); ma_noise noise; ma_result result = ma_noise_init(&config, &noise); if (result != MA_SUCCESS) { // Error. } ... ma_noise_read_pcm_frames(&noise, pOutput, frameCount); ``` The noise API uses simple LCG random number generation. It supports a custom seed which is useful for things like automated testing requiring reproducibility. Setting the seed to zero will default to `MA_DEFAULT_LCG_SEED`. The amplitude and seed can be changed dynamically with `ma_noise_set_amplitude()` and `ma_noise_set_seed()` respectively. By default, the noise API will use different values for different channels. So, for example, the left side in a stereo stream will be different to the right side. To instead have each channel use the same random value, set the `duplicateChannels` member of the noise config to true, like so: ```c config.duplicateChannels = MA_TRUE; ``` Below are the supported noise types. +------------------------+ | Enum Name | +------------------------+ | ma_noise_type_white | | ma_noise_type_pink | | ma_noise_type_brownian | +------------------------+ 13. Audio Buffers ================= miniaudio supports reading from a buffer of raw audio data via the `ma_audio_buffer` API. This can read from memory that's managed by the application, but can also handle the memory management for you internally. Memory management is flexible and should support most use cases. Audio buffers are initialized using the standard configuration system used everywhere in miniaudio: ```c ma_audio_buffer_config config = ma_audio_buffer_config_init( format, channels, sizeInFrames, pExistingData, &allocationCallbacks); ma_audio_buffer buffer; result = ma_audio_buffer_init(&config, &buffer); if (result != MA_SUCCESS) { // Error. } ... ma_audio_buffer_uninit(&buffer); ``` In the example above, the memory pointed to by `pExistingData` will *not* be copied and is how an application can do self-managed memory allocation. If you would rather make a copy of the data, use `ma_audio_buffer_init_copy()`. To uninitialize the buffer, use `ma_audio_buffer_uninit()`. Sometimes it can be convenient to allocate the memory for the `ma_audio_buffer` structure and the raw audio data in a contiguous block of memory. That is, the raw audio data will be located immediately after the `ma_audio_buffer` structure. To do this, use `ma_audio_buffer_alloc_and_init()`: ```c ma_audio_buffer_config config = ma_audio_buffer_config_init( format, channels, sizeInFrames, pExistingData, &allocationCallbacks); ma_audio_buffer* pBuffer result = ma_audio_buffer_alloc_and_init(&config, &pBuffer); if (result != MA_SUCCESS) { // Error } ... ma_audio_buffer_uninit_and_free(&buffer); ``` If you initialize the buffer with `ma_audio_buffer_alloc_and_init()` you should uninitialize it with `ma_audio_buffer_uninit_and_free()`. In the example above, the memory pointed to by `pExistingData` will be copied into the buffer, which is contrary to the behavior of `ma_audio_buffer_init()`. An audio buffer has a playback cursor just like a decoder. As you read frames from the buffer, the cursor moves forward. The last parameter (`loop`) can be used to determine if the buffer should loop. The return value is the number of frames actually read. If this is less than the number of frames requested it means the end has been reached. This should never happen if the `loop` parameter is set to true. If you want to manually loop back to the start, you can do so with with `ma_audio_buffer_seek_to_pcm_frame(pAudioBuffer, 0)`. Below is an example for reading data from an audio buffer. ```c ma_uint64 framesRead = ma_audio_buffer_read_pcm_frames(pAudioBuffer, pFramesOut, desiredFrameCount, isLooping); if (framesRead < desiredFrameCount) { // If not looping, this means the end has been reached. This should never happen in looping mode with valid input. } ``` Sometimes you may want to avoid the cost of data movement between the internal buffer and the output buffer. Instead you can use memory mapping to retrieve a pointer to a segment of data: ```c void* pMappedFrames; ma_uint64 frameCount = frameCountToTryMapping; ma_result result = ma_audio_buffer_map(pAudioBuffer, &pMappedFrames, &frameCount); if (result == MA_SUCCESS) { // Map was successful. The value in frameCount will be how many frames were _actually_ mapped, which may be // less due to the end of the buffer being reached. ma_copy_pcm_frames(pFramesOut, pMappedFrames, frameCount, pAudioBuffer->format, pAudioBuffer->channels); // You must unmap the buffer. ma_audio_buffer_unmap(pAudioBuffer, frameCount); } ``` When you use memory mapping, the read cursor is increment by the frame count passed in to `ma_audio_buffer_unmap()`. If you decide not to process every frame you can pass in a value smaller than the value returned by `ma_audio_buffer_map()`. The disadvantage to using memory mapping is that it does not handle looping for you. You can determine if the buffer is at the end for the purpose of looping with `ma_audio_buffer_at_end()` or by inspecting the return value of `ma_audio_buffer_unmap()` and checking if it equals `MA_AT_END`. You should not treat `MA_AT_END` as an error when returned by `ma_audio_buffer_unmap()`. 14. Ring Buffers ================ miniaudio supports lock free (single producer, single consumer) ring buffers which are exposed via the `ma_rb` and `ma_pcm_rb` APIs. The `ma_rb` API operates on bytes, whereas the `ma_pcm_rb` operates on PCM frames. They are otherwise identical as `ma_pcm_rb` is just a wrapper around `ma_rb`. Unlike most other APIs in miniaudio, ring buffers support both interleaved and deinterleaved streams. The caller can also allocate their own backing memory for the ring buffer to use internally for added flexibility. Otherwise the ring buffer will manage it's internal memory for you. The examples below use the PCM frame variant of the ring buffer since that's most likely the one you will want to use. To initialize a ring buffer, do something like the following: ```c ma_pcm_rb rb; ma_result result = ma_pcm_rb_init(FORMAT, CHANNELS, BUFFER_SIZE_IN_FRAMES, NULL, NULL, &rb); if (result != MA_SUCCESS) { // Error } ``` The `ma_pcm_rb_init()` function takes the sample format and channel count as parameters because it's the PCM variant of the ring buffer API. For the regular ring buffer that operates on bytes you would call `ma_rb_init()` which leaves these out and just takes the size of the buffer in bytes instead of frames. The fourth parameter is an optional pre-allocated buffer and the fifth parameter is a pointer to a `ma_allocation_callbacks` structure for custom memory allocation routines. Passing in `NULL` for this results in `MA_MALLOC()` and `MA_FREE()` being used. Use `ma_pcm_rb_init_ex()` if you need a deinterleaved buffer. The data for each sub-buffer is offset from each other based on the stride. To manage your sub-buffers you can use `ma_pcm_rb_get_subbuffer_stride()`, `ma_pcm_rb_get_subbuffer_offset()` and `ma_pcm_rb_get_subbuffer_ptr()`. Use `ma_pcm_rb_acquire_read()` and `ma_pcm_rb_acquire_write()` to retrieve a pointer to a section of the ring buffer. You specify the number of frames you need, and on output it will set to what was actually acquired. If the read or write pointer is positioned such that the number of frames requested will require a loop, it will be clamped to the end of the buffer. Therefore, the number of frames you're given may be less than the number you requested. After calling `ma_pcm_rb_acquire_read()` or `ma_pcm_rb_acquire_write()`, you do your work on the buffer and then "commit" it with `ma_pcm_rb_commit_read()` or `ma_pcm_rb_commit_write()`. This is where the read/write pointers are updated. When you commit you need to pass in the buffer that was returned by the earlier call to `ma_pcm_rb_acquire_read()` or `ma_pcm_rb_acquire_write()` and is only used for validation. The number of frames passed to `ma_pcm_rb_commit_read()` and `ma_pcm_rb_commit_write()` is what's used to increment the pointers, and can be less that what was originally requested. If you want to correct for drift between the write pointer and the read pointer you can use a combination of `ma_pcm_rb_pointer_distance()`, `ma_pcm_rb_seek_read()` and `ma_pcm_rb_seek_write()`. Note that you can only move the pointers forward, and you should only move the read pointer forward via the consumer thread, and the write pointer forward by the producer thread. If there is too much space between the pointers, move the read pointer forward. If there is too little space between the pointers, move the write pointer forward. You can use a ring buffer at the byte level instead of the PCM frame level by using the `ma_rb` API. This is exactly the same, only you will use the `ma_rb` functions instead of `ma_pcm_rb` and instead of frame counts you will pass around byte counts. The maximum size of the buffer in bytes is `0x7FFFFFFF-(MA_SIMD_ALIGNMENT-1)` due to the most significant bit being used to encode a loop flag and the internally managed buffers always being aligned to `MA_SIMD_ALIGNMENT`. Note that the ring buffer is only thread safe when used by a single consumer thread and single producer thread. 15. Backends ============ The following backends are supported by miniaudio. These are listed in order of default priority. When no backend is specified when initializing a context or device, miniaudio will attempt to use each of these backends in the order listed in the table below. Note that backends that are not usable by the build target will not be included in the build. For example, ALSA, which is specific to Linux, will not be included in the Windows build. +-------------+-----------------------+--------------------------------------------------------+ | Name | Enum Name | Supported Operating Systems | +-------------+-----------------------+--------------------------------------------------------+ | WASAPI | ma_backend_wasapi | Windows Vista+ | | DirectSound | ma_backend_dsound | Windows XP+ | | WinMM | ma_backend_winmm | Windows 95+ | | Core Audio | ma_backend_coreaudio | macOS, iOS | | sndio | ma_backend_sndio | OpenBSD | | audio(4) | ma_backend_audio4 | NetBSD, OpenBSD | | OSS | ma_backend_oss | FreeBSD | | PulseAudio | ma_backend_pulseaudio | Cross Platform (disabled on Windows, BSD and Android) | | ALSA | ma_backend_alsa | Linux | | JACK | ma_backend_jack | Cross Platform (disabled on BSD and Android) | | AAudio | ma_backend_aaudio | Android 8+ | | OpenSL ES | ma_backend_opensl | Android (API level 16+) | | Web Audio | ma_backend_webaudio | Web (via Emscripten) | | Custom | ma_backend_custom | Cross Platform | | Null | ma_backend_null | Cross Platform (not used on Web) | +-------------+-----------------------+--------------------------------------------------------+ Some backends have some nuance details you may want to be aware of. 15.1. WASAPI ------------ - Low-latency shared mode will be disabled when using an application-defined sample rate which is different to the device's native sample rate. To work around this, set `wasapi.noAutoConvertSRC` to true in the device config. This is due to IAudioClient3_InitializeSharedAudioStream() failing when the `AUDCLNT_STREAMFLAGS_AUTOCONVERTPCM` flag is specified. Setting wasapi.noAutoConvertSRC will result in miniaudio's internal resampler being used instead which will in turn enable the use of low-latency shared mode. 15.2. PulseAudio ---------------- - If you experience bad glitching/noise on Arch Linux, consider this fix from the Arch wiki: https://wiki.archlinux.org/index.php/PulseAudio/Troubleshooting#Glitches,_skips_or_crackling. Alternatively, consider using a different backend such as ALSA. 15.3. Android ------------- - To capture audio on Android, remember to add the RECORD_AUDIO permission to your manifest: `` - With OpenSL|ES, only a single ma_context can be active at any given time. This is due to a limitation with OpenSL|ES. - With AAudio, only default devices are enumerated. This is due to AAudio not having an enumeration API (devices are enumerated through Java). You can however perform your own device enumeration through Java and then set the ID in the ma_device_id structure (ma_device_id.aaudio) and pass it to ma_device_init(). - The backend API will perform resampling where possible. The reason for this as opposed to using miniaudio's built-in resampler is to take advantage of any potential device-specific optimizations the driver may implement. BSD --- - The sndio backend is currently only enabled on OpenBSD builds. - The audio(4) backend is supported on OpenBSD, but you may need to disable sndiod before you can use it. 15.4. UWP --------- - UWP only supports default playback and capture devices. - UWP requires the Microphone capability to be enabled in the application's manifest (Package.appxmanifest): ``` ... ``` 15.5. Web Audio / Emscripten ---------------------------- - You cannot use `-std=c*` compiler flags, nor `-ansi`. This only applies to the Emscripten build. - The first time a context is initialized it will create a global object called "miniaudio" whose primary purpose is to act as a factory for device objects. - Currently the Web Audio backend uses ScriptProcessorNode's, but this may need to change later as they've been deprecated. - Google has implemented a policy in their browsers that prevent automatic media output without first receiving some kind of user input. The following web page has additional details: https://developers.google.com/web/updates/2017/09/autoplay-policy-changes. Starting the device may fail if you try to start playback without first handling some kind of user input. 16. Optimization Tips ===================== See below for some tips on improving performance. 16.1. Low Level API ------------------- - In the data callback, if your data is already clipped prior to copying it into the output buffer, set the `noClip` config option in the device config to true. This will disable miniaudio's built in clipping function. - By default, miniaudio will pre-silence the data callback's output buffer. If you know that you will always write valid data to the output buffer you can disable pre-silencing by setting the `noPreSilence` config option in the device config to true. 16.2. High Level API -------------------- - If a sound does not require doppler or pitch shifting, consider disabling pitching by initializing the sound with the `MA_SOUND_FLAG_NO_PITCH` flag. - If a sound does not require spatialization, disable it by initializing the sound with the `MA_SOUND_FLAG_NO_SPATIALIZATION` flag. It can be re-enabled again post-initialization with `ma_sound_set_spatialization_enabled()`. - If you know all of your sounds will always be the same sample rate, set the engine's sample rate to match that of the sounds. Likewise, if you're using a self-managed resource manager, consider setting the decoded sample rate to match your sounds. By configuring everything to use a consistent sample rate, sample rate conversion can be avoided. 17. Miscellaneous Notes ======================= - Automatic stream routing is enabled on a per-backend basis. Support is explicitly enabled for WASAPI and Core Audio, however other backends such as PulseAudio may naturally support it, though not all have been tested. - When compiling with VC6 and earlier, decoding is restricted to files less than 2GB in size. This is due to 64-bit file APIs not being available. */ #ifndef miniaudio_h #define miniaudio_h #ifdef __cplusplus extern "C" { #endif #define MA_STRINGIFY(x) #x #define MA_XSTRINGIFY(x) MA_STRINGIFY(x) #define MA_VERSION_MAJOR 0 #define MA_VERSION_MINOR 11 #define MA_VERSION_REVISION 21 #define MA_VERSION_STRING MA_XSTRINGIFY(MA_VERSION_MAJOR) "." MA_XSTRINGIFY(MA_VERSION_MINOR) "." MA_XSTRINGIFY(MA_VERSION_REVISION) #if defined(_MSC_VER) && !defined(__clang__) #pragma warning(push) #pragma warning(disable:4201) /* nonstandard extension used: nameless struct/union */ #pragma warning(disable:4214) /* nonstandard extension used: bit field types other than int */ #pragma warning(disable:4324) /* structure was padded due to alignment specifier */ #elif defined(__clang__) || (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8))) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wpedantic" /* For ISO C99 doesn't support unnamed structs/unions [-Wpedantic] */ #if defined(__clang__) #pragma GCC diagnostic ignored "-Wc11-extensions" /* anonymous unions are a C11 extension */ #endif #endif #if defined(__LP64__) || defined(_WIN64) || (defined(__x86_64__) && !defined(__ILP32__)) || defined(_M_X64) || defined(__ia64) || defined(_M_IA64) || defined(__aarch64__) || defined(_M_ARM64) || defined(__powerpc64__) #define MA_SIZEOF_PTR 8 #else #define MA_SIZEOF_PTR 4 #endif #include /* For size_t. */ /* Sized types. */ #if defined(MA_USE_STDINT) #include typedef int8_t ma_int8; typedef uint8_t ma_uint8; typedef int16_t ma_int16; typedef uint16_t ma_uint16; typedef int32_t ma_int32; typedef uint32_t ma_uint32; typedef int64_t ma_int64; typedef uint64_t ma_uint64; #else typedef signed char ma_int8; typedef unsigned char ma_uint8; typedef signed short ma_int16; typedef unsigned short ma_uint16; typedef signed int ma_int32; typedef unsigned int ma_uint32; #if defined(_MSC_VER) && !defined(__clang__) typedef signed __int64 ma_int64; typedef unsigned __int64 ma_uint64; #else #if defined(__clang__) || (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wlong-long" #if defined(__clang__) #pragma GCC diagnostic ignored "-Wc++11-long-long" #endif #endif typedef signed long long ma_int64; typedef unsigned long long ma_uint64; #if defined(__clang__) || (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))) #pragma GCC diagnostic pop #endif #endif #endif /* MA_USE_STDINT */ #if MA_SIZEOF_PTR == 8 typedef ma_uint64 ma_uintptr; #else typedef ma_uint32 ma_uintptr; #endif typedef ma_uint8 ma_bool8; typedef ma_uint32 ma_bool32; #define MA_TRUE 1 #define MA_FALSE 0 /* These float types are not used universally by miniaudio. It's to simplify some macro expansion for atomic types. */ typedef float ma_float; typedef double ma_double; typedef void* ma_handle; typedef void* ma_ptr; /* ma_proc is annoying because when compiling with GCC we get pendantic warnings about converting between `void*` and `void (*)()`. We can't use `void (*)()` with MSVC however, because we'll get warning C4191 about "type cast between incompatible function types". To work around this I'm going to use a different data type depending on the compiler. */ #if defined(__GNUC__) typedef void (*ma_proc)(void); #else typedef void* ma_proc; #endif #if defined(_MSC_VER) && !defined(_WCHAR_T_DEFINED) typedef ma_uint16 wchar_t; #endif /* Define NULL for some compilers. */ #ifndef NULL #define NULL 0 #endif #if defined(SIZE_MAX) #define MA_SIZE_MAX SIZE_MAX #else #define MA_SIZE_MAX 0xFFFFFFFF /* When SIZE_MAX is not defined by the standard library just default to the maximum 32-bit unsigned integer. */ #endif /* Platform/backend detection. */ #if defined(_WIN32) || defined(__COSMOPOLITAN__) #define MA_WIN32 #if defined(MA_FORCE_UWP) || (defined(WINAPI_FAMILY) && ((defined(WINAPI_FAMILY_PC_APP) && WINAPI_FAMILY == WINAPI_FAMILY_PC_APP) || (defined(WINAPI_FAMILY_PHONE_APP) && WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP))) #define MA_WIN32_UWP #elif defined(WINAPI_FAMILY) && (defined(WINAPI_FAMILY_GAMES) && WINAPI_FAMILY == WINAPI_FAMILY_GAMES) #define MA_WIN32_GDK #else #define MA_WIN32_DESKTOP #endif #endif #if !defined(_WIN32) /* If it's not Win32, assume POSIX. */ #define MA_POSIX /* Use the MA_NO_PTHREAD_IN_HEADER option at your own risk. This is intentionally undocumented. You can use this to avoid including pthread.h in the header section. The downside is that it results in some fixed sized structures being declared for the various types that are used in miniaudio. The risk here is that these types might be too small for a given platform. This risk is yours to take and no support will be offered if you enable this option. */ #ifndef MA_NO_PTHREAD_IN_HEADER #include /* Unfortunate #include, but needed for pthread_t, pthread_mutex_t and pthread_cond_t types. */ typedef pthread_t ma_pthread_t; typedef pthread_mutex_t ma_pthread_mutex_t; typedef pthread_cond_t ma_pthread_cond_t; #else typedef ma_uintptr ma_pthread_t; typedef union ma_pthread_mutex_t { char __data[40]; ma_uint64 __alignment; } ma_pthread_mutex_t; typedef union ma_pthread_cond_t { char __data[48]; ma_uint64 __alignment; } ma_pthread_cond_t; #endif #if defined(__unix__) #define MA_UNIX #endif #if defined(__linux__) #define MA_LINUX #endif #if defined(__APPLE__) #define MA_APPLE #endif #if defined(__DragonFly__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) #define MA_BSD #endif #if defined(__ANDROID__) #define MA_ANDROID #endif #if defined(__EMSCRIPTEN__) #define MA_EMSCRIPTEN #endif #if defined(__ORBIS__) #define MA_ORBIS #endif #if defined(__PROSPERO__) #define MA_PROSPERO #endif #if defined(__NX__) #define MA_NX #endif #if defined(__BEOS__) || defined(__HAIKU__) #define MA_BEOS #endif #if defined(__HAIKU__) #define MA_HAIKU #endif #endif #if defined(__has_c_attribute) #if __has_c_attribute(fallthrough) #define MA_FALLTHROUGH [[fallthrough]] #endif #endif #if !defined(MA_FALLTHROUGH) && defined(__has_attribute) && (defined(__clang__) || defined(__GNUC__)) #if __has_attribute(fallthrough) #define MA_FALLTHROUGH __attribute__((fallthrough)) #endif #endif #if !defined(MA_FALLTHROUGH) #define MA_FALLTHROUGH ((void)0) #endif #ifdef _MSC_VER #define MA_INLINE __forceinline /* noinline was introduced in Visual Studio 2005. */ #if _MSC_VER >= 1400 #define MA_NO_INLINE __declspec(noinline) #else #define MA_NO_INLINE #endif #elif defined(__GNUC__) /* I've had a bug report where GCC is emitting warnings about functions possibly not being inlineable. This warning happens when the __attribute__((always_inline)) attribute is defined without an "inline" statement. I think therefore there must be some case where "__inline__" is not always defined, thus the compiler emitting these warnings. When using -std=c89 or -ansi on the command line, we cannot use the "inline" keyword and instead need to use "__inline__". In an attempt to work around this issue I am using "__inline__" only when we're compiling in strict ANSI mode. */ #if defined(__STRICT_ANSI__) #define MA_GNUC_INLINE_HINT __inline__ #else #define MA_GNUC_INLINE_HINT inline #endif #if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 2)) || defined(__clang__) #define MA_INLINE MA_GNUC_INLINE_HINT __attribute__((always_inline)) #define MA_NO_INLINE __attribute__((noinline)) #else #define MA_INLINE MA_GNUC_INLINE_HINT #define MA_NO_INLINE __attribute__((noinline)) #endif #elif defined(__WATCOMC__) #define MA_INLINE __inline #define MA_NO_INLINE #else #define MA_INLINE #define MA_NO_INLINE #endif /* MA_DLL is not officially supported. You're on your own if you want to use this. */ #if defined(MA_DLL) #if defined(_WIN32) #define MA_DLL_IMPORT __declspec(dllimport) #define MA_DLL_EXPORT __declspec(dllexport) #define MA_DLL_PRIVATE static #else #if defined(__GNUC__) && __GNUC__ >= 4 #define MA_DLL_IMPORT __attribute__((visibility("default"))) #define MA_DLL_EXPORT __attribute__((visibility("default"))) #define MA_DLL_PRIVATE __attribute__((visibility("hidden"))) #else #define MA_DLL_IMPORT #define MA_DLL_EXPORT #define MA_DLL_PRIVATE static #endif #endif #endif #if !defined(MA_API) #if defined(MA_DLL) #if defined(MINIAUDIO_IMPLEMENTATION) || defined(MA_IMPLEMENTATION) #define MA_API MA_DLL_EXPORT #else #define MA_API MA_DLL_IMPORT #endif #else #define MA_API extern #endif #endif #if !defined(MA_STATIC) #if defined(MA_DLL) #define MA_PRIVATE MA_DLL_PRIVATE #else #define MA_PRIVATE static #endif #endif /* SIMD alignment in bytes. Currently set to 32 bytes in preparation for future AVX optimizations. */ #define MA_SIMD_ALIGNMENT 32 /* Special wchar_t type to ensure any structures in the public sections that reference it have a consistent size across all platforms. On Windows, wchar_t is 2 bytes, whereas everywhere else it's 4 bytes. Since Windows likes to use wchar_t for it's IDs, we need a special explicitly sized wchar type that is always 2 bytes on all platforms. */ #if !defined(MA_POSIX) && defined(MA_WIN32) typedef wchar_t ma_wchar_win32; #else typedef ma_uint16 ma_wchar_win32; #endif /* Logging Levels ============== Log levels are only used to give logging callbacks some context as to the severity of a log message so they can do filtering. All log levels will be posted to registered logging callbacks. If you don't want to output a certain log level you can discriminate against the log level in the callback. MA_LOG_LEVEL_DEBUG Used for debugging. Useful for debug and test builds, but should be disabled in release builds. MA_LOG_LEVEL_INFO Informational logging. Useful for debugging. This will never be called from within the data callback. MA_LOG_LEVEL_WARNING Warnings. You should enable this in you development builds and action them when encounted. These logs usually indicate a potential problem or misconfiguration, but still allow you to keep running. This will never be called from within the data callback. MA_LOG_LEVEL_ERROR Error logging. This will be fired when an operation fails and is subsequently aborted. This can be fired from within the data callback, in which case the device will be stopped. You should always have this log level enabled. */ typedef enum { MA_LOG_LEVEL_DEBUG = 4, MA_LOG_LEVEL_INFO = 3, MA_LOG_LEVEL_WARNING = 2, MA_LOG_LEVEL_ERROR = 1 } ma_log_level; /* Variables needing to be accessed atomically should be declared with this macro for two reasons: 1) It allows people who read the code to identify a variable as such; and 2) It forces alignment on platforms where it's required or optimal. Note that for x86/64, alignment is not strictly necessary, but does have some performance implications. Where supported by the compiler, alignment will be used, but otherwise if the CPU architecture does not require it, it will simply leave it unaligned. This is the case with old versions of Visual Studio, which I've confirmed with at least VC6. */ #if !defined(_MSC_VER) && defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) #include #define MA_ATOMIC(alignment, type) _Alignas(alignment) type #else #if defined(__GNUC__) /* GCC-style compilers. */ #define MA_ATOMIC(alignment, type) type __attribute__((aligned(alignment))) #elif defined(_MSC_VER) && _MSC_VER > 1200 /* 1200 = VC6. Alignment not supported, but not necessary because x86 is the only supported target. */ /* MSVC. */ #define MA_ATOMIC(alignment, type) __declspec(align(alignment)) type #else /* Other compilers. */ #define MA_ATOMIC(alignment, type) type #endif #endif typedef struct ma_context ma_context; typedef struct ma_device ma_device; typedef ma_uint8 ma_channel; typedef enum { MA_CHANNEL_NONE = 0, MA_CHANNEL_MONO = 1, MA_CHANNEL_FRONT_LEFT = 2, MA_CHANNEL_FRONT_RIGHT = 3, MA_CHANNEL_FRONT_CENTER = 4, MA_CHANNEL_LFE = 5, MA_CHANNEL_BACK_LEFT = 6, MA_CHANNEL_BACK_RIGHT = 7, MA_CHANNEL_FRONT_LEFT_CENTER = 8, MA_CHANNEL_FRONT_RIGHT_CENTER = 9, MA_CHANNEL_BACK_CENTER = 10, MA_CHANNEL_SIDE_LEFT = 11, MA_CHANNEL_SIDE_RIGHT = 12, MA_CHANNEL_TOP_CENTER = 13, MA_CHANNEL_TOP_FRONT_LEFT = 14, MA_CHANNEL_TOP_FRONT_CENTER = 15, MA_CHANNEL_TOP_FRONT_RIGHT = 16, MA_CHANNEL_TOP_BACK_LEFT = 17, MA_CHANNEL_TOP_BACK_CENTER = 18, MA_CHANNEL_TOP_BACK_RIGHT = 19, MA_CHANNEL_AUX_0 = 20, MA_CHANNEL_AUX_1 = 21, MA_CHANNEL_AUX_2 = 22, MA_CHANNEL_AUX_3 = 23, MA_CHANNEL_AUX_4 = 24, MA_CHANNEL_AUX_5 = 25, MA_CHANNEL_AUX_6 = 26, MA_CHANNEL_AUX_7 = 27, MA_CHANNEL_AUX_8 = 28, MA_CHANNEL_AUX_9 = 29, MA_CHANNEL_AUX_10 = 30, MA_CHANNEL_AUX_11 = 31, MA_CHANNEL_AUX_12 = 32, MA_CHANNEL_AUX_13 = 33, MA_CHANNEL_AUX_14 = 34, MA_CHANNEL_AUX_15 = 35, MA_CHANNEL_AUX_16 = 36, MA_CHANNEL_AUX_17 = 37, MA_CHANNEL_AUX_18 = 38, MA_CHANNEL_AUX_19 = 39, MA_CHANNEL_AUX_20 = 40, MA_CHANNEL_AUX_21 = 41, MA_CHANNEL_AUX_22 = 42, MA_CHANNEL_AUX_23 = 43, MA_CHANNEL_AUX_24 = 44, MA_CHANNEL_AUX_25 = 45, MA_CHANNEL_AUX_26 = 46, MA_CHANNEL_AUX_27 = 47, MA_CHANNEL_AUX_28 = 48, MA_CHANNEL_AUX_29 = 49, MA_CHANNEL_AUX_30 = 50, MA_CHANNEL_AUX_31 = 51, MA_CHANNEL_LEFT = MA_CHANNEL_FRONT_LEFT, MA_CHANNEL_RIGHT = MA_CHANNEL_FRONT_RIGHT, MA_CHANNEL_POSITION_COUNT = (MA_CHANNEL_AUX_31 + 1) } _ma_channel_position; /* Do not use `_ma_channel_position` directly. Use `ma_channel` instead. */ typedef enum { MA_SUCCESS = 0, MA_ERROR = -1, /* A generic error. */ MA_INVALID_ARGS = -2, MA_INVALID_OPERATION = -3, MA_OUT_OF_MEMORY = -4, MA_OUT_OF_RANGE = -5, MA_ACCESS_DENIED = -6, MA_DOES_NOT_EXIST = -7, MA_ALREADY_EXISTS = -8, MA_TOO_MANY_OPEN_FILES = -9, MA_INVALID_FILE = -10, MA_TOO_BIG = -11, MA_PATH_TOO_LONG = -12, MA_NAME_TOO_LONG = -13, MA_NOT_DIRECTORY = -14, MA_IS_DIRECTORY = -15, MA_DIRECTORY_NOT_EMPTY = -16, MA_AT_END = -17, MA_NO_SPACE = -18, MA_BUSY = -19, MA_IO_ERROR = -20, MA_INTERRUPT = -21, MA_UNAVAILABLE = -22, MA_ALREADY_IN_USE = -23, MA_BAD_ADDRESS = -24, MA_BAD_SEEK = -25, MA_BAD_PIPE = -26, MA_DEADLOCK = -27, MA_TOO_MANY_LINKS = -28, MA_NOT_IMPLEMENTED = -29, MA_NO_MESSAGE = -30, MA_BAD_MESSAGE = -31, MA_NO_DATA_AVAILABLE = -32, MA_INVALID_DATA = -33, MA_TIMEOUT = -34, MA_NO_NETWORK = -35, MA_NOT_UNIQUE = -36, MA_NOT_SOCKET = -37, MA_NO_ADDRESS = -38, MA_BAD_PROTOCOL = -39, MA_PROTOCOL_UNAVAILABLE = -40, MA_PROTOCOL_NOT_SUPPORTED = -41, MA_PROTOCOL_FAMILY_NOT_SUPPORTED = -42, MA_ADDRESS_FAMILY_NOT_SUPPORTED = -43, MA_SOCKET_NOT_SUPPORTED = -44, MA_CONNECTION_RESET = -45, MA_ALREADY_CONNECTED = -46, MA_NOT_CONNECTED = -47, MA_CONNECTION_REFUSED = -48, MA_NO_HOST = -49, MA_IN_PROGRESS = -50, MA_CANCELLED = -51, MA_MEMORY_ALREADY_MAPPED = -52, /* General non-standard errors. */ MA_CRC_MISMATCH = -100, /* General miniaudio-specific errors. */ MA_FORMAT_NOT_SUPPORTED = -200, MA_DEVICE_TYPE_NOT_SUPPORTED = -201, MA_SHARE_MODE_NOT_SUPPORTED = -202, MA_NO_BACKEND = -203, MA_NO_DEVICE = -204, MA_API_NOT_FOUND = -205, MA_INVALID_DEVICE_CONFIG = -206, MA_LOOP = -207, MA_BACKEND_NOT_ENABLED = -208, /* State errors. */ MA_DEVICE_NOT_INITIALIZED = -300, MA_DEVICE_ALREADY_INITIALIZED = -301, MA_DEVICE_NOT_STARTED = -302, MA_DEVICE_NOT_STOPPED = -303, /* Operation errors. */ MA_FAILED_TO_INIT_BACKEND = -400, MA_FAILED_TO_OPEN_BACKEND_DEVICE = -401, MA_FAILED_TO_START_BACKEND_DEVICE = -402, MA_FAILED_TO_STOP_BACKEND_DEVICE = -403 } ma_result; #define MA_MIN_CHANNELS 1 #ifndef MA_MAX_CHANNELS #define MA_MAX_CHANNELS 254 #endif #ifndef MA_MAX_FILTER_ORDER #define MA_MAX_FILTER_ORDER 8 #endif typedef enum { ma_stream_format_pcm = 0 } ma_stream_format; typedef enum { ma_stream_layout_interleaved = 0, ma_stream_layout_deinterleaved } ma_stream_layout; typedef enum { ma_dither_mode_none = 0, ma_dither_mode_rectangle, ma_dither_mode_triangle } ma_dither_mode; typedef enum { /* I like to keep these explicitly defined because they're used as a key into a lookup table. When items are added to this, make sure there are no gaps and that they're added to the lookup table in ma_get_bytes_per_sample(). */ ma_format_unknown = 0, /* Mainly used for indicating an error, but also used as the default for the output format for decoders. */ ma_format_u8 = 1, ma_format_s16 = 2, /* Seems to be the most widely supported format. */ ma_format_s24 = 3, /* Tightly packed. 3 bytes per sample. */ ma_format_s32 = 4, ma_format_f32 = 5, ma_format_count } ma_format; typedef enum { /* Standard rates need to be in priority order. */ ma_standard_sample_rate_48000 = 48000, /* Most common */ ma_standard_sample_rate_44100 = 44100, ma_standard_sample_rate_32000 = 32000, /* Lows */ ma_standard_sample_rate_24000 = 24000, ma_standard_sample_rate_22050 = 22050, ma_standard_sample_rate_88200 = 88200, /* Highs */ ma_standard_sample_rate_96000 = 96000, ma_standard_sample_rate_176400 = 176400, ma_standard_sample_rate_192000 = 192000, ma_standard_sample_rate_16000 = 16000, /* Extreme lows */ ma_standard_sample_rate_11025 = 11025, ma_standard_sample_rate_8000 = 8000, ma_standard_sample_rate_352800 = 352800, /* Extreme highs */ ma_standard_sample_rate_384000 = 384000, ma_standard_sample_rate_min = ma_standard_sample_rate_8000, ma_standard_sample_rate_max = ma_standard_sample_rate_384000, ma_standard_sample_rate_count = 14 /* Need to maintain the count manually. Make sure this is updated if items are added to enum. */ } ma_standard_sample_rate; typedef enum { ma_channel_mix_mode_rectangular = 0, /* Simple averaging based on the plane(s) the channel is sitting on. */ ma_channel_mix_mode_simple, /* Drop excess channels; zeroed out extra channels. */ ma_channel_mix_mode_custom_weights, /* Use custom weights specified in ma_channel_converter_config. */ ma_channel_mix_mode_default = ma_channel_mix_mode_rectangular } ma_channel_mix_mode; typedef enum { ma_standard_channel_map_microsoft, ma_standard_channel_map_alsa, ma_standard_channel_map_rfc3551, /* Based off AIFF. */ ma_standard_channel_map_flac, ma_standard_channel_map_vorbis, ma_standard_channel_map_sound4, /* FreeBSD's sound(4). */ ma_standard_channel_map_sndio, /* www.sndio.org/tips.html */ ma_standard_channel_map_webaudio = ma_standard_channel_map_flac, /* https://webaudio.github.io/web-audio-api/#ChannelOrdering. Only 1, 2, 4 and 6 channels are defined, but can fill in the gaps with logical assumptions. */ ma_standard_channel_map_default = ma_standard_channel_map_microsoft } ma_standard_channel_map; typedef enum { ma_performance_profile_low_latency = 0, ma_performance_profile_conservative } ma_performance_profile; typedef struct { void* pUserData; void* (* onMalloc)(size_t sz, void* pUserData); void* (* onRealloc)(void* p, size_t sz, void* pUserData); void (* onFree)(void* p, void* pUserData); } ma_allocation_callbacks; typedef struct { ma_int32 state; } ma_lcg; /* Atomics. These are typesafe structures to prevent errors as a result of forgetting to reference variables atomically. It's too easy to introduce subtle bugs where you accidentally do a regular assignment instead of an atomic load/store, etc. By using a struct we can enforce the use of atomics at compile time. These types are declared in the header section because we need to reference them in structs below, but functions for using them are only exposed in the implementation section. I do not want these to be part of the public API. There's a few downsides to this system. The first is that you need to declare a new struct for each type. Below are some macros to help with the declarations. They will be named like so: ma_atomic_uint32 - atomic ma_uint32 ma_atomic_int32 - atomic ma_int32 ma_atomic_uint64 - atomic ma_uint64 ma_atomic_float - atomic float ma_atomic_bool32 - atomic ma_bool32 The other downside is that atomic pointers are extremely messy. You need to declare a new struct for each specific type of pointer you need to make atomic. For example, an atomic ma_node* will look like this: MA_ATOMIC_SAFE_TYPE_IMPL_PTR(node) Which will declare a type struct that's named like so: ma_atomic_ptr_node Functions to use the atomic types are declared in the implementation section. All atomic functions are prefixed with the name of the struct. For example: ma_atomic_uint32_set() - Atomic store of ma_uint32 ma_atomic_uint32_get() - Atomic load of ma_uint32 etc. For pointer types it's the same, which makes them a bit messy to use due to the length of each function name, but in return you get type safety and enforcement of atomic operations. */ #define MA_ATOMIC_SAFE_TYPE_DECL(c89TypeExtension, typeSize, type) \ typedef struct \ { \ MA_ATOMIC(typeSize, ma_##type) value; \ } ma_atomic_##type; \ #define MA_ATOMIC_SAFE_TYPE_DECL_PTR(type) \ typedef struct \ { \ MA_ATOMIC(MA_SIZEOF_PTR, ma_##type*) value; \ } ma_atomic_ptr_##type; \ MA_ATOMIC_SAFE_TYPE_DECL(32, 4, uint32) MA_ATOMIC_SAFE_TYPE_DECL(i32, 4, int32) MA_ATOMIC_SAFE_TYPE_DECL(64, 8, uint64) MA_ATOMIC_SAFE_TYPE_DECL(f32, 4, float) MA_ATOMIC_SAFE_TYPE_DECL(32, 4, bool32) /* Spinlocks are 32-bit for compatibility reasons. */ typedef ma_uint32 ma_spinlock; #ifndef MA_NO_THREADING /* Thread priorities should be ordered such that the default priority of the worker thread is 0. */ typedef enum { ma_thread_priority_idle = -5, ma_thread_priority_lowest = -4, ma_thread_priority_low = -3, ma_thread_priority_normal = -2, ma_thread_priority_high = -1, ma_thread_priority_highest = 0, ma_thread_priority_realtime = 1, ma_thread_priority_default = 0 } ma_thread_priority; #if defined(MA_POSIX) typedef ma_pthread_t ma_thread; #elif defined(MA_WIN32) typedef ma_handle ma_thread; #endif #if defined(MA_POSIX) typedef ma_pthread_mutex_t ma_mutex; #elif defined(MA_WIN32) typedef ma_handle ma_mutex; #endif #if defined(MA_POSIX) typedef struct { ma_uint32 value; ma_pthread_mutex_t lock; ma_pthread_cond_t cond; } ma_event; #elif defined(MA_WIN32) typedef ma_handle ma_event; #endif #if defined(MA_POSIX) typedef struct { int value; ma_pthread_mutex_t lock; ma_pthread_cond_t cond; } ma_semaphore; #elif defined(MA_WIN32) typedef ma_handle ma_semaphore; #endif #else /* MA_NO_THREADING is set which means threading is disabled. Threading is required by some API families. If any of these are enabled we need to throw an error. */ #ifndef MA_NO_DEVICE_IO #error "MA_NO_THREADING cannot be used without MA_NO_DEVICE_IO"; #endif #endif /* MA_NO_THREADING */ /* Retrieves the version of miniaudio as separated integers. Each component can be NULL if it's not required. */ MA_API void ma_version(ma_uint32* pMajor, ma_uint32* pMinor, ma_uint32* pRevision); /* Retrieves the version of miniaudio as a string which can be useful for logging purposes. */ MA_API const char* ma_version_string(void); /************************************************************************************************************************************************************** Logging **************************************************************************************************************************************************************/ #include /* For va_list. */ #if defined(__has_attribute) #if __has_attribute(format) #define MA_ATTRIBUTE_FORMAT(fmt, va) __attribute__((format(printf, fmt, va))) #endif #endif #ifndef MA_ATTRIBUTE_FORMAT #define MA_ATTRIBUTE_FORMAT(fmt, va) #endif #ifndef MA_MAX_LOG_CALLBACKS #define MA_MAX_LOG_CALLBACKS 4 #endif /* The callback for handling log messages. Parameters ---------- pUserData (in) The user data pointer that was passed into ma_log_register_callback(). logLevel (in) The log level. This can be one of the following: +----------------------+ | Log Level | +----------------------+ | MA_LOG_LEVEL_DEBUG | | MA_LOG_LEVEL_INFO | | MA_LOG_LEVEL_WARNING | | MA_LOG_LEVEL_ERROR | +----------------------+ pMessage (in) The log message. */ typedef void (* ma_log_callback_proc)(void* pUserData, ma_uint32 level, const char* pMessage); typedef struct { ma_log_callback_proc onLog; void* pUserData; } ma_log_callback; MA_API ma_log_callback ma_log_callback_init(ma_log_callback_proc onLog, void* pUserData); typedef struct { ma_log_callback callbacks[MA_MAX_LOG_CALLBACKS]; ma_uint32 callbackCount; ma_allocation_callbacks allocationCallbacks; /* Need to store these persistently because ma_log_postv() might need to allocate a buffer on the heap. */ #ifndef MA_NO_THREADING ma_mutex lock; /* For thread safety just to make it easier and safer for the logging implementation. */ #endif } ma_log; MA_API ma_result ma_log_init(const ma_allocation_callbacks* pAllocationCallbacks, ma_log* pLog); MA_API void ma_log_uninit(ma_log* pLog); MA_API ma_result ma_log_register_callback(ma_log* pLog, ma_log_callback callback); MA_API ma_result ma_log_unregister_callback(ma_log* pLog, ma_log_callback callback); MA_API ma_result ma_log_post(ma_log* pLog, ma_uint32 level, const char* pMessage); MA_API ma_result ma_log_postv(ma_log* pLog, ma_uint32 level, const char* pFormat, va_list args); MA_API ma_result ma_log_postf(ma_log* pLog, ma_uint32 level, const char* pFormat, ...) MA_ATTRIBUTE_FORMAT(3, 4); /************************************************************************************************************************************************************** Biquad Filtering **************************************************************************************************************************************************************/ typedef union { float f32; ma_int32 s32; } ma_biquad_coefficient; typedef struct { ma_format format; ma_uint32 channels; double b0; double b1; double b2; double a0; double a1; double a2; } ma_biquad_config; MA_API ma_biquad_config ma_biquad_config_init(ma_format format, ma_uint32 channels, double b0, double b1, double b2, double a0, double a1, double a2); typedef struct { ma_format format; ma_uint32 channels; ma_biquad_coefficient b0; ma_biquad_coefficient b1; ma_biquad_coefficient b2; ma_biquad_coefficient a1; ma_biquad_coefficient a2; ma_biquad_coefficient* pR1; ma_biquad_coefficient* pR2; /* Memory management. */ void* _pHeap; ma_bool32 _ownsHeap; } ma_biquad; MA_API ma_result ma_biquad_get_heap_size(const ma_biquad_config* pConfig, size_t* pHeapSizeInBytes); MA_API ma_result ma_biquad_init_preallocated(const ma_biquad_config* pConfig, void* pHeap, ma_biquad* pBQ); MA_API ma_result ma_biquad_init(const ma_biquad_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_biquad* pBQ); MA_API void ma_biquad_uninit(ma_biquad* pBQ, const ma_allocation_callbacks* pAllocationCallbacks); MA_API ma_result ma_biquad_reinit(const ma_biquad_config* pConfig, ma_biquad* pBQ); MA_API ma_result ma_biquad_clear_cache(ma_biquad* pBQ); MA_API ma_result ma_biquad_process_pcm_frames(ma_biquad* pBQ, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount); MA_API ma_uint32 ma_biquad_get_latency(const ma_biquad* pBQ); /************************************************************************************************************************************************************** Low-Pass Filtering **************************************************************************************************************************************************************/ typedef struct { ma_format format; ma_uint32 channels; ma_uint32 sampleRate; double cutoffFrequency; double q; } ma_lpf1_config, ma_lpf2_config; MA_API ma_lpf1_config ma_lpf1_config_init(ma_format format, ma_uint32 channels, ma_uint32 sampleRate, double cutoffFrequency); MA_API ma_lpf2_config ma_lpf2_config_init(ma_format format, ma_uint32 channels, ma_uint32 sampleRate, double cutoffFrequency, double q); typedef struct { ma_format format; ma_uint32 channels; ma_biquad_coefficient a; ma_biquad_coefficient* pR1; /* Memory management. */ void* _pHeap; ma_bool32 _ownsHeap; } ma_lpf1; MA_API ma_result ma_lpf1_get_heap_size(const ma_lpf1_config* pConfig, size_t* pHeapSizeInBytes); MA_API ma_result ma_lpf1_init_preallocated(const ma_lpf1_config* pConfig, void* pHeap, ma_lpf1* pLPF); MA_API ma_result ma_lpf1_init(const ma_lpf1_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_lpf1* pLPF); MA_API void ma_lpf1_uninit(ma_lpf1* pLPF, const ma_allocation_callbacks* pAllocationCallbacks); MA_API ma_result ma_lpf1_reinit(const ma_lpf1_config* pConfig, ma_lpf1* pLPF); MA_API ma_result ma_lpf1_clear_cache(ma_lpf1* pLPF); MA_API ma_result ma_lpf1_process_pcm_frames(ma_lpf1* pLPF, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount); MA_API ma_uint32 ma_lpf1_get_latency(const ma_lpf1* pLPF); typedef struct { ma_biquad bq; /* The second order low-pass filter is implemented as a biquad filter. */ } ma_lpf2; MA_API ma_result ma_lpf2_get_heap_size(const ma_lpf2_config* pConfig, size_t* pHeapSizeInBytes); MA_API ma_result ma_lpf2_init_preallocated(const ma_lpf2_config* pConfig, void* pHeap, ma_lpf2* pHPF); MA_API ma_result ma_lpf2_init(const ma_lpf2_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_lpf2* pLPF); MA_API void ma_lpf2_uninit(ma_lpf2* pLPF, const ma_allocation_callbacks* pAllocationCallbacks); MA_API ma_result ma_lpf2_reinit(const ma_lpf2_config* pConfig, ma_lpf2* pLPF); MA_API ma_result ma_lpf2_clear_cache(ma_lpf2* pLPF); MA_API ma_result ma_lpf2_process_pcm_frames(ma_lpf2* pLPF, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount); MA_API ma_uint32 ma_lpf2_get_latency(const ma_lpf2* pLPF); typedef struct { ma_format format; ma_uint32 channels; ma_uint32 sampleRate; double cutoffFrequency; ma_uint32 order; /* If set to 0, will be treated as a passthrough (no filtering will be applied). */ } ma_lpf_config; MA_API ma_lpf_config ma_lpf_config_init(ma_format format, ma_uint32 channels, ma_uint32 sampleRate, double cutoffFrequency, ma_uint32 order); typedef struct { ma_format format; ma_uint32 channels; ma_uint32 sampleRate; ma_uint32 lpf1Count; ma_uint32 lpf2Count; ma_lpf1* pLPF1; ma_lpf2* pLPF2; /* Memory management. */ void* _pHeap; ma_bool32 _ownsHeap; } ma_lpf; MA_API ma_result ma_lpf_get_heap_size(const ma_lpf_config* pConfig, size_t* pHeapSizeInBytes); MA_API ma_result ma_lpf_init_preallocated(const ma_lpf_config* pConfig, void* pHeap, ma_lpf* pLPF); MA_API ma_result ma_lpf_init(const ma_lpf_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_lpf* pLPF); MA_API void ma_lpf_uninit(ma_lpf* pLPF, const ma_allocation_callbacks* pAllocationCallbacks); MA_API ma_result ma_lpf_reinit(const ma_lpf_config* pConfig, ma_lpf* pLPF); MA_API ma_result ma_lpf_clear_cache(ma_lpf* pLPF); MA_API ma_result ma_lpf_process_pcm_frames(ma_lpf* pLPF, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount); MA_API ma_uint32 ma_lpf_get_latency(const ma_lpf* pLPF); /************************************************************************************************************************************************************** High-Pass Filtering **************************************************************************************************************************************************************/ typedef struct { ma_format format; ma_uint32 channels; ma_uint32 sampleRate; double cutoffFrequency; double q; } ma_hpf1_config, ma_hpf2_config; MA_API ma_hpf1_config ma_hpf1_config_init(ma_format format, ma_uint32 channels, ma_uint32 sampleRate, double cutoffFrequency); MA_API ma_hpf2_config ma_hpf2_config_init(ma_format format, ma_uint32 channels, ma_uint32 sampleRate, double cutoffFrequency, double q); typedef struct { ma_format format; ma_uint32 channels; ma_biquad_coefficient a; ma_biquad_coefficient* pR1; /* Memory management. */ void* _pHeap; ma_bool32 _ownsHeap; } ma_hpf1; MA_API ma_result ma_hpf1_get_heap_size(const ma_hpf1_config* pConfig, size_t* pHeapSizeInBytes); MA_API ma_result ma_hpf1_init_preallocated(const ma_hpf1_config* pConfig, void* pHeap, ma_hpf1* pLPF); MA_API ma_result ma_hpf1_init(const ma_hpf1_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_hpf1* pHPF); MA_API void ma_hpf1_uninit(ma_hpf1* pHPF, const ma_allocation_callbacks* pAllocationCallbacks); MA_API ma_result ma_hpf1_reinit(const ma_hpf1_config* pConfig, ma_hpf1* pHPF); MA_API ma_result ma_hpf1_process_pcm_frames(ma_hpf1* pHPF, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount); MA_API ma_uint32 ma_hpf1_get_latency(const ma_hpf1* pHPF); typedef struct { ma_biquad bq; /* The second order high-pass filter is implemented as a biquad filter. */ } ma_hpf2; MA_API ma_result ma_hpf2_get_heap_size(const ma_hpf2_config* pConfig, size_t* pHeapSizeInBytes); MA_API ma_result ma_hpf2_init_preallocated(const ma_hpf2_config* pConfig, void* pHeap, ma_hpf2* pHPF); MA_API ma_result ma_hpf2_init(const ma_hpf2_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_hpf2* pHPF); MA_API void ma_hpf2_uninit(ma_hpf2* pHPF, const ma_allocation_callbacks* pAllocationCallbacks); MA_API ma_result ma_hpf2_reinit(const ma_hpf2_config* pConfig, ma_hpf2* pHPF); MA_API ma_result ma_hpf2_process_pcm_frames(ma_hpf2* pHPF, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount); MA_API ma_uint32 ma_hpf2_get_latency(const ma_hpf2* pHPF); typedef struct { ma_format format; ma_uint32 channels; ma_uint32 sampleRate; double cutoffFrequency; ma_uint32 order; /* If set to 0, will be treated as a passthrough (no filtering will be applied). */ } ma_hpf_config; MA_API ma_hpf_config ma_hpf_config_init(ma_format format, ma_uint32 channels, ma_uint32 sampleRate, double cutoffFrequency, ma_uint32 order); typedef struct { ma_format format; ma_uint32 channels; ma_uint32 sampleRate; ma_uint32 hpf1Count; ma_uint32 hpf2Count; ma_hpf1* pHPF1; ma_hpf2* pHPF2; /* Memory management. */ void* _pHeap; ma_bool32 _ownsHeap; } ma_hpf; MA_API ma_result ma_hpf_get_heap_size(const ma_hpf_config* pConfig, size_t* pHeapSizeInBytes); MA_API ma_result ma_hpf_init_preallocated(const ma_hpf_config* pConfig, void* pHeap, ma_hpf* pLPF); MA_API ma_result ma_hpf_init(const ma_hpf_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_hpf* pHPF); MA_API void ma_hpf_uninit(ma_hpf* pHPF, const ma_allocation_callbacks* pAllocationCallbacks); MA_API ma_result ma_hpf_reinit(const ma_hpf_config* pConfig, ma_hpf* pHPF); MA_API ma_result ma_hpf_process_pcm_frames(ma_hpf* pHPF, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount); MA_API ma_uint32 ma_hpf_get_latency(const ma_hpf* pHPF); /************************************************************************************************************************************************************** Band-Pass Filtering **************************************************************************************************************************************************************/ typedef struct { ma_format format; ma_uint32 channels; ma_uint32 sampleRate; double cutoffFrequency; double q; } ma_bpf2_config; MA_API ma_bpf2_config ma_bpf2_config_init(ma_format format, ma_uint32 channels, ma_uint32 sampleRate, double cutoffFrequency, double q); typedef struct { ma_biquad bq; /* The second order band-pass filter is implemented as a biquad filter. */ } ma_bpf2; MA_API ma_result ma_bpf2_get_heap_size(const ma_bpf2_config* pConfig, size_t* pHeapSizeInBytes); MA_API ma_result ma_bpf2_init_preallocated(const ma_bpf2_config* pConfig, void* pHeap, ma_bpf2* pBPF); MA_API ma_result ma_bpf2_init(const ma_bpf2_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_bpf2* pBPF); MA_API void ma_bpf2_uninit(ma_bpf2* pBPF, const ma_allocation_callbacks* pAllocationCallbacks); MA_API ma_result ma_bpf2_reinit(const ma_bpf2_config* pConfig, ma_bpf2* pBPF); MA_API ma_result ma_bpf2_process_pcm_frames(ma_bpf2* pBPF, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount); MA_API ma_uint32 ma_bpf2_get_latency(const ma_bpf2* pBPF); typedef struct { ma_format format; ma_uint32 channels; ma_uint32 sampleRate; double cutoffFrequency; ma_uint32 order; /* If set to 0, will be treated as a passthrough (no filtering will be applied). */ } ma_bpf_config; MA_API ma_bpf_config ma_bpf_config_init(ma_format format, ma_uint32 channels, ma_uint32 sampleRate, double cutoffFrequency, ma_uint32 order); typedef struct { ma_format format; ma_uint32 channels; ma_uint32 bpf2Count; ma_bpf2* pBPF2; /* Memory management. */ void* _pHeap; ma_bool32 _ownsHeap; } ma_bpf; MA_API ma_result ma_bpf_get_heap_size(const ma_bpf_config* pConfig, size_t* pHeapSizeInBytes); MA_API ma_result ma_bpf_init_preallocated(const ma_bpf_config* pConfig, void* pHeap, ma_bpf* pBPF); MA_API ma_result ma_bpf_init(const ma_bpf_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_bpf* pBPF); MA_API void ma_bpf_uninit(ma_bpf* pBPF, const ma_allocation_callbacks* pAllocationCallbacks); MA_API ma_result ma_bpf_reinit(const ma_bpf_config* pConfig, ma_bpf* pBPF); MA_API ma_result ma_bpf_process_pcm_frames(ma_bpf* pBPF, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount); MA_API ma_uint32 ma_bpf_get_latency(const ma_bpf* pBPF); /************************************************************************************************************************************************************** Notching Filter **************************************************************************************************************************************************************/ typedef struct { ma_format format; ma_uint32 channels; ma_uint32 sampleRate; double q; double frequency; } ma_notch2_config, ma_notch_config; MA_API ma_notch2_config ma_notch2_config_init(ma_format format, ma_uint32 channels, ma_uint32 sampleRate, double q, double frequency); typedef struct { ma_biquad bq; } ma_notch2; MA_API ma_result ma_notch2_get_heap_size(const ma_notch2_config* pConfig, size_t* pHeapSizeInBytes); MA_API ma_result ma_notch2_init_preallocated(const ma_notch2_config* pConfig, void* pHeap, ma_notch2* pFilter); MA_API ma_result ma_notch2_init(const ma_notch2_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_notch2* pFilter); MA_API void ma_notch2_uninit(ma_notch2* pFilter, const ma_allocation_callbacks* pAllocationCallbacks); MA_API ma_result ma_notch2_reinit(const ma_notch2_config* pConfig, ma_notch2* pFilter); MA_API ma_result ma_notch2_process_pcm_frames(ma_notch2* pFilter, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount); MA_API ma_uint32 ma_notch2_get_latency(const ma_notch2* pFilter); /************************************************************************************************************************************************************** Peaking EQ Filter **************************************************************************************************************************************************************/ typedef struct { ma_format format; ma_uint32 channels; ma_uint32 sampleRate; double gainDB; double q; double frequency; } ma_peak2_config, ma_peak_config; MA_API ma_peak2_config ma_peak2_config_init(ma_format format, ma_uint32 channels, ma_uint32 sampleRate, double gainDB, double q, double frequency); typedef struct { ma_biquad bq; } ma_peak2; MA_API ma_result ma_peak2_get_heap_size(const ma_peak2_config* pConfig, size_t* pHeapSizeInBytes); MA_API ma_result ma_peak2_init_preallocated(const ma_peak2_config* pConfig, void* pHeap, ma_peak2* pFilter); MA_API ma_result ma_peak2_init(const ma_peak2_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_peak2* pFilter); MA_API void ma_peak2_uninit(ma_peak2* pFilter, const ma_allocation_callbacks* pAllocationCallbacks); MA_API ma_result ma_peak2_reinit(const ma_peak2_config* pConfig, ma_peak2* pFilter); MA_API ma_result ma_peak2_process_pcm_frames(ma_peak2* pFilter, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount); MA_API ma_uint32 ma_peak2_get_latency(const ma_peak2* pFilter); /************************************************************************************************************************************************************** Low Shelf Filter **************************************************************************************************************************************************************/ typedef struct { ma_format format; ma_uint32 channels; ma_uint32 sampleRate; double gainDB; double shelfSlope; double frequency; } ma_loshelf2_config, ma_loshelf_config; MA_API ma_loshelf2_config ma_loshelf2_config_init(ma_format format, ma_uint32 channels, ma_uint32 sampleRate, double gainDB, double shelfSlope, double frequency); typedef struct { ma_biquad bq; } ma_loshelf2; MA_API ma_result ma_loshelf2_get_heap_size(const ma_loshelf2_config* pConfig, size_t* pHeapSizeInBytes); MA_API ma_result ma_loshelf2_init_preallocated(const ma_loshelf2_config* pConfig, void* pHeap, ma_loshelf2* pFilter); MA_API ma_result ma_loshelf2_init(const ma_loshelf2_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_loshelf2* pFilter); MA_API void ma_loshelf2_uninit(ma_loshelf2* pFilter, const ma_allocation_callbacks* pAllocationCallbacks); MA_API ma_result ma_loshelf2_reinit(const ma_loshelf2_config* pConfig, ma_loshelf2* pFilter); MA_API ma_result ma_loshelf2_process_pcm_frames(ma_loshelf2* pFilter, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount); MA_API ma_uint32 ma_loshelf2_get_latency(const ma_loshelf2* pFilter); /************************************************************************************************************************************************************** High Shelf Filter **************************************************************************************************************************************************************/ typedef struct { ma_format format; ma_uint32 channels; ma_uint32 sampleRate; double gainDB; double shelfSlope; double frequency; } ma_hishelf2_config, ma_hishelf_config; MA_API ma_hishelf2_config ma_hishelf2_config_init(ma_format format, ma_uint32 channels, ma_uint32 sampleRate, double gainDB, double shelfSlope, double frequency); typedef struct { ma_biquad bq; } ma_hishelf2; MA_API ma_result ma_hishelf2_get_heap_size(const ma_hishelf2_config* pConfig, size_t* pHeapSizeInBytes); MA_API ma_result ma_hishelf2_init_preallocated(const ma_hishelf2_config* pConfig, void* pHeap, ma_hishelf2* pFilter); MA_API ma_result ma_hishelf2_init(const ma_hishelf2_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_hishelf2* pFilter); MA_API void ma_hishelf2_uninit(ma_hishelf2* pFilter, const ma_allocation_callbacks* pAllocationCallbacks); MA_API ma_result ma_hishelf2_reinit(const ma_hishelf2_config* pConfig, ma_hishelf2* pFilter); MA_API ma_result ma_hishelf2_process_pcm_frames(ma_hishelf2* pFilter, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount); MA_API ma_uint32 ma_hishelf2_get_latency(const ma_hishelf2* pFilter); /* Delay */ typedef struct { ma_uint32 channels; ma_uint32 sampleRate; ma_uint32 delayInFrames; ma_bool32 delayStart; /* Set to true to delay the start of the output; false otherwise. */ float wet; /* 0..1. Default = 1. */ float dry; /* 0..1. Default = 1. */ float decay; /* 0..1. Default = 0 (no feedback). Feedback decay. Use this for echo. */ } ma_delay_config; MA_API ma_delay_config ma_delay_config_init(ma_uint32 channels, ma_uint32 sampleRate, ma_uint32 delayInFrames, float decay); typedef struct { ma_delay_config config; ma_uint32 cursor; /* Feedback is written to this cursor. Always equal or in front of the read cursor. */ ma_uint32 bufferSizeInFrames; float* pBuffer; } ma_delay; MA_API ma_result ma_delay_init(const ma_delay_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_delay* pDelay); MA_API void ma_delay_uninit(ma_delay* pDelay, const ma_allocation_callbacks* pAllocationCallbacks); MA_API ma_result ma_delay_process_pcm_frames(ma_delay* pDelay, void* pFramesOut, const void* pFramesIn, ma_uint32 frameCount); MA_API void ma_delay_set_wet(ma_delay* pDelay, float value); MA_API float ma_delay_get_wet(const ma_delay* pDelay); MA_API void ma_delay_set_dry(ma_delay* pDelay, float value); MA_API float ma_delay_get_dry(const ma_delay* pDelay); MA_API void ma_delay_set_decay(ma_delay* pDelay, float value); MA_API float ma_delay_get_decay(const ma_delay* pDelay); /* Gainer for smooth volume changes. */ typedef struct { ma_uint32 channels; ma_uint32 smoothTimeInFrames; } ma_gainer_config; MA_API ma_gainer_config ma_gainer_config_init(ma_uint32 channels, ma_uint32 smoothTimeInFrames); typedef struct { ma_gainer_config config; ma_uint32 t; float masterVolume; float* pOldGains; float* pNewGains; /* Memory management. */ void* _pHeap; ma_bool32 _ownsHeap; } ma_gainer; MA_API ma_result ma_gainer_get_heap_size(const ma_gainer_config* pConfig, size_t* pHeapSizeInBytes); MA_API ma_result ma_gainer_init_preallocated(const ma_gainer_config* pConfig, void* pHeap, ma_gainer* pGainer); MA_API ma_result ma_gainer_init(const ma_gainer_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_gainer* pGainer); MA_API void ma_gainer_uninit(ma_gainer* pGainer, const ma_allocation_callbacks* pAllocationCallbacks); MA_API ma_result ma_gainer_process_pcm_frames(ma_gainer* pGainer, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount); MA_API ma_result ma_gainer_set_gain(ma_gainer* pGainer, float newGain); MA_API ma_result ma_gainer_set_gains(ma_gainer* pGainer, float* pNewGains); MA_API ma_result ma_gainer_set_master_volume(ma_gainer* pGainer, float volume); MA_API ma_result ma_gainer_get_master_volume(const ma_gainer* pGainer, float* pVolume); /* Stereo panner. */ typedef enum { ma_pan_mode_balance = 0, /* Does not blend one side with the other. Technically just a balance. Compatible with other popular audio engines and therefore the default. */ ma_pan_mode_pan /* A true pan. The sound from one side will "move" to the other side and blend with it. */ } ma_pan_mode; typedef struct { ma_format format; ma_uint32 channels; ma_pan_mode mode; float pan; } ma_panner_config; MA_API ma_panner_config ma_panner_config_init(ma_format format, ma_uint32 channels); typedef struct { ma_format format; ma_uint32 channels; ma_pan_mode mode; float pan; /* -1..1 where 0 is no pan, -1 is left side, +1 is right side. Defaults to 0. */ } ma_panner; MA_API ma_result ma_panner_init(const ma_panner_config* pConfig, ma_panner* pPanner); MA_API ma_result ma_panner_process_pcm_frames(ma_panner* pPanner, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount); MA_API void ma_panner_set_mode(ma_panner* pPanner, ma_pan_mode mode); MA_API ma_pan_mode ma_panner_get_mode(const ma_panner* pPanner); MA_API void ma_panner_set_pan(ma_panner* pPanner, float pan); MA_API float ma_panner_get_pan(const ma_panner* pPanner); /* Fader. */ typedef struct { ma_format format; ma_uint32 channels; ma_uint32 sampleRate; } ma_fader_config; MA_API ma_fader_config ma_fader_config_init(ma_format format, ma_uint32 channels, ma_uint32 sampleRate); typedef struct { ma_fader_config config; float volumeBeg; /* If volumeBeg and volumeEnd is equal to 1, no fading happens (ma_fader_process_pcm_frames() will run as a passthrough). */ float volumeEnd; ma_uint64 lengthInFrames; /* The total length of the fade. */ ma_int64 cursorInFrames; /* The current time in frames. Incremented by ma_fader_process_pcm_frames(). Signed because it'll be offset by startOffsetInFrames in set_fade_ex(). */ } ma_fader; MA_API ma_result ma_fader_init(const ma_fader_config* pConfig, ma_fader* pFader); MA_API ma_result ma_fader_process_pcm_frames(ma_fader* pFader, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount); MA_API void ma_fader_get_data_format(const ma_fader* pFader, ma_format* pFormat, ma_uint32* pChannels, ma_uint32* pSampleRate); MA_API void ma_fader_set_fade(ma_fader* pFader, float volumeBeg, float volumeEnd, ma_uint64 lengthInFrames); MA_API void ma_fader_set_fade_ex(ma_fader* pFader, float volumeBeg, float volumeEnd, ma_uint64 lengthInFrames, ma_int64 startOffsetInFrames); MA_API float ma_fader_get_current_volume(const ma_fader* pFader); /* Spatializer. */ typedef struct { float x; float y; float z; } ma_vec3f; typedef struct { ma_vec3f v; ma_spinlock lock; } ma_atomic_vec3f; typedef enum { ma_attenuation_model_none, /* No distance attenuation and no spatialization. */ ma_attenuation_model_inverse, /* Equivalent to OpenAL's AL_INVERSE_DISTANCE_CLAMPED. */ ma_attenuation_model_linear, /* Linear attenuation. Equivalent to OpenAL's AL_LINEAR_DISTANCE_CLAMPED. */ ma_attenuation_model_exponential /* Exponential attenuation. Equivalent to OpenAL's AL_EXPONENT_DISTANCE_CLAMPED. */ } ma_attenuation_model; typedef enum { ma_positioning_absolute, ma_positioning_relative } ma_positioning; typedef enum { ma_handedness_right, ma_handedness_left } ma_handedness; typedef struct { ma_uint32 channelsOut; ma_channel* pChannelMapOut; ma_handedness handedness; /* Defaults to right. Forward is -1 on the Z axis. In a left handed system, forward is +1 on the Z axis. */ float coneInnerAngleInRadians; float coneOuterAngleInRadians; float coneOuterGain; float speedOfSound; ma_vec3f worldUp; } ma_spatializer_listener_config; MA_API ma_spatializer_listener_config ma_spatializer_listener_config_init(ma_uint32 channelsOut); typedef struct { ma_spatializer_listener_config config; ma_atomic_vec3f position; /* The absolute position of the listener. */ ma_atomic_vec3f direction; /* The direction the listener is facing. The world up vector is config.worldUp. */ ma_atomic_vec3f velocity; ma_bool32 isEnabled; /* Memory management. */ ma_bool32 _ownsHeap; void* _pHeap; } ma_spatializer_listener; MA_API ma_result ma_spatializer_listener_get_heap_size(const ma_spatializer_listener_config* pConfig, size_t* pHeapSizeInBytes); MA_API ma_result ma_spatializer_listener_init_preallocated(const ma_spatializer_listener_config* pConfig, void* pHeap, ma_spatializer_listener* pListener); MA_API ma_result ma_spatializer_listener_init(const ma_spatializer_listener_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_spatializer_listener* pListener); MA_API void ma_spatializer_listener_uninit(ma_spatializer_listener* pListener, const ma_allocation_callbacks* pAllocationCallbacks); MA_API ma_channel* ma_spatializer_listener_get_channel_map(ma_spatializer_listener* pListener); MA_API void ma_spatializer_listener_set_cone(ma_spatializer_listener* pListener, float innerAngleInRadians, float outerAngleInRadians, float outerGain); MA_API void ma_spatializer_listener_get_cone(const ma_spatializer_listener* pListener, float* pInnerAngleInRadians, float* pOuterAngleInRadians, float* pOuterGain); MA_API void ma_spatializer_listener_set_position(ma_spatializer_listener* pListener, float x, float y, float z); MA_API ma_vec3f ma_spatializer_listener_get_position(const ma_spatializer_listener* pListener); MA_API void ma_spatializer_listener_set_direction(ma_spatializer_listener* pListener, float x, float y, float z); MA_API ma_vec3f ma_spatializer_listener_get_direction(const ma_spatializer_listener* pListener); MA_API void ma_spatializer_listener_set_velocity(ma_spatializer_listener* pListener, float x, float y, float z); MA_API ma_vec3f ma_spatializer_listener_get_velocity(const ma_spatializer_listener* pListener); MA_API void ma_spatializer_listener_set_speed_of_sound(ma_spatializer_listener* pListener, float speedOfSound); MA_API float ma_spatializer_listener_get_speed_of_sound(const ma_spatializer_listener* pListener); MA_API void ma_spatializer_listener_set_world_up(ma_spatializer_listener* pListener, float x, float y, float z); MA_API ma_vec3f ma_spatializer_listener_get_world_up(const ma_spatializer_listener* pListener); MA_API void ma_spatializer_listener_set_enabled(ma_spatializer_listener* pListener, ma_bool32 isEnabled); MA_API ma_bool32 ma_spatializer_listener_is_enabled(const ma_spatializer_listener* pListener); typedef struct { ma_uint32 channelsIn; ma_uint32 channelsOut; ma_channel* pChannelMapIn; ma_attenuation_model attenuationModel; ma_positioning positioning; ma_handedness handedness; /* Defaults to right. Forward is -1 on the Z axis. In a left handed system, forward is +1 on the Z axis. */ float minGain; float maxGain; float minDistance; float maxDistance; float rolloff; float coneInnerAngleInRadians; float coneOuterAngleInRadians; float coneOuterGain; float dopplerFactor; /* Set to 0 to disable doppler effect. */ float directionalAttenuationFactor; /* Set to 0 to disable directional attenuation. */ float minSpatializationChannelGain; /* The minimal scaling factor to apply to channel gains when accounting for the direction of the sound relative to the listener. Must be in the range of 0..1. Smaller values means more aggressive directional panning, larger values means more subtle directional panning. */ ma_uint32 gainSmoothTimeInFrames; /* When the gain of a channel changes during spatialization, the transition will be linearly interpolated over this number of frames. */ } ma_spatializer_config; MA_API ma_spatializer_config ma_spatializer_config_init(ma_uint32 channelsIn, ma_uint32 channelsOut); typedef struct { ma_uint32 channelsIn; ma_uint32 channelsOut; ma_channel* pChannelMapIn; ma_attenuation_model attenuationModel; ma_positioning positioning; ma_handedness handedness; /* Defaults to right. Forward is -1 on the Z axis. In a left handed system, forward is +1 on the Z axis. */ float minGain; float maxGain; float minDistance; float maxDistance; float rolloff; float coneInnerAngleInRadians; float coneOuterAngleInRadians; float coneOuterGain; float dopplerFactor; /* Set to 0 to disable doppler effect. */ float directionalAttenuationFactor; /* Set to 0 to disable directional attenuation. */ ma_uint32 gainSmoothTimeInFrames; /* When the gain of a channel changes during spatialization, the transition will be linearly interpolated over this number of frames. */ ma_atomic_vec3f position; ma_atomic_vec3f direction; ma_atomic_vec3f velocity; /* For doppler effect. */ float dopplerPitch; /* Will be updated by ma_spatializer_process_pcm_frames() and can be used by higher level functions to apply a pitch shift for doppler effect. */ float minSpatializationChannelGain; ma_gainer gainer; /* For smooth gain transitions. */ float* pNewChannelGainsOut; /* An offset of _pHeap. Used by ma_spatializer_process_pcm_frames() to store new channel gains. The number of elements in this array is equal to config.channelsOut. */ /* Memory management. */ void* _pHeap; ma_bool32 _ownsHeap; } ma_spatializer; MA_API ma_result ma_spatializer_get_heap_size(const ma_spatializer_config* pConfig, size_t* pHeapSizeInBytes); MA_API ma_result ma_spatializer_init_preallocated(const ma_spatializer_config* pConfig, void* pHeap, ma_spatializer* pSpatializer); MA_API ma_result ma_spatializer_init(const ma_spatializer_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_spatializer* pSpatializer); MA_API void ma_spatializer_uninit(ma_spatializer* pSpatializer, const ma_allocation_callbacks* pAllocationCallbacks); MA_API ma_result ma_spatializer_process_pcm_frames(ma_spatializer* pSpatializer, ma_spatializer_listener* pListener, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount); MA_API ma_result ma_spatializer_set_master_volume(ma_spatializer* pSpatializer, float volume); MA_API ma_result ma_spatializer_get_master_volume(const ma_spatializer* pSpatializer, float* pVolume); MA_API ma_uint32 ma_spatializer_get_input_channels(const ma_spatializer* pSpatializer); MA_API ma_uint32 ma_spatializer_get_output_channels(const ma_spatializer* pSpatializer); MA_API void ma_spatializer_set_attenuation_model(ma_spatializer* pSpatializer, ma_attenuation_model attenuationModel); MA_API ma_attenuation_model ma_spatializer_get_attenuation_model(const ma_spatializer* pSpatializer); MA_API void ma_spatializer_set_positioning(ma_spatializer* pSpatializer, ma_positioning positioning); MA_API ma_positioning ma_spatializer_get_positioning(const ma_spatializer* pSpatializer); MA_API void ma_spatializer_set_rolloff(ma_spatializer* pSpatializer, float rolloff); MA_API float ma_spatializer_get_rolloff(const ma_spatializer* pSpatializer); MA_API void ma_spatializer_set_min_gain(ma_spatializer* pSpatializer, float minGain); MA_API float ma_spatializer_get_min_gain(const ma_spatializer* pSpatializer); MA_API void ma_spatializer_set_max_gain(ma_spatializer* pSpatializer, float maxGain); MA_API float ma_spatializer_get_max_gain(const ma_spatializer* pSpatializer); MA_API void ma_spatializer_set_min_distance(ma_spatializer* pSpatializer, float minDistance); MA_API float ma_spatializer_get_min_distance(const ma_spatializer* pSpatializer); MA_API void ma_spatializer_set_max_distance(ma_spatializer* pSpatializer, float maxDistance); MA_API float ma_spatializer_get_max_distance(const ma_spatializer* pSpatializer); MA_API void ma_spatializer_set_cone(ma_spatializer* pSpatializer, float innerAngleInRadians, float outerAngleInRadians, float outerGain); MA_API void ma_spatializer_get_cone(const ma_spatializer* pSpatializer, float* pInnerAngleInRadians, float* pOuterAngleInRadians, float* pOuterGain); MA_API void ma_spatializer_set_doppler_factor(ma_spatializer* pSpatializer, float dopplerFactor); MA_API float ma_spatializer_get_doppler_factor(const ma_spatializer* pSpatializer); MA_API void ma_spatializer_set_directional_attenuation_factor(ma_spatializer* pSpatializer, float directionalAttenuationFactor); MA_API float ma_spatializer_get_directional_attenuation_factor(const ma_spatializer* pSpatializer); MA_API void ma_spatializer_set_position(ma_spatializer* pSpatializer, float x, float y, float z); MA_API ma_vec3f ma_spatializer_get_position(const ma_spatializer* pSpatializer); MA_API void ma_spatializer_set_direction(ma_spatializer* pSpatializer, float x, float y, float z); MA_API ma_vec3f ma_spatializer_get_direction(const ma_spatializer* pSpatializer); MA_API void ma_spatializer_set_velocity(ma_spatializer* pSpatializer, float x, float y, float z); MA_API ma_vec3f ma_spatializer_get_velocity(const ma_spatializer* pSpatializer); MA_API void ma_spatializer_get_relative_position_and_direction(const ma_spatializer* pSpatializer, const ma_spatializer_listener* pListener, ma_vec3f* pRelativePos, ma_vec3f* pRelativeDir); /************************************************************************************************************************************************************ ************************************************************************************************************************************************************* DATA CONVERSION =============== This section contains the APIs for data conversion. You will find everything here for channel mapping, sample format conversion, resampling, etc. ************************************************************************************************************************************************************* ************************************************************************************************************************************************************/ /************************************************************************************************************************************************************** Resampling **************************************************************************************************************************************************************/ typedef struct { ma_format format; ma_uint32 channels; ma_uint32 sampleRateIn; ma_uint32 sampleRateOut; ma_uint32 lpfOrder; /* The low-pass filter order. Setting this to 0 will disable low-pass filtering. */ double lpfNyquistFactor; /* 0..1. Defaults to 1. 1 = Half the sampling frequency (Nyquist Frequency), 0.5 = Quarter the sampling frequency (half Nyquest Frequency), etc. */ } ma_linear_resampler_config; MA_API ma_linear_resampler_config ma_linear_resampler_config_init(ma_format format, ma_uint32 channels, ma_uint32 sampleRateIn, ma_uint32 sampleRateOut); typedef struct { ma_linear_resampler_config config; ma_uint32 inAdvanceInt; ma_uint32 inAdvanceFrac; ma_uint32 inTimeInt; ma_uint32 inTimeFrac; union { float* f32; ma_int16* s16; } x0; /* The previous input frame. */ union { float* f32; ma_int16* s16; } x1; /* The next input frame. */ ma_lpf lpf; /* Memory management. */ void* _pHeap; ma_bool32 _ownsHeap; } ma_linear_resampler; MA_API ma_result ma_linear_resampler_get_heap_size(const ma_linear_resampler_config* pConfig, size_t* pHeapSizeInBytes); MA_API ma_result ma_linear_resampler_init_preallocated(const ma_linear_resampler_config* pConfig, void* pHeap, ma_linear_resampler* pResampler); MA_API ma_result ma_linear_resampler_init(const ma_linear_resampler_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_linear_resampler* pResampler); MA_API void ma_linear_resampler_uninit(ma_linear_resampler* pResampler, const ma_allocation_callbacks* pAllocationCallbacks); MA_API ma_result ma_linear_resampler_process_pcm_frames(ma_linear_resampler* pResampler, const void* pFramesIn, ma_uint64* pFrameCountIn, void* pFramesOut, ma_uint64* pFrameCountOut); MA_API ma_result ma_linear_resampler_set_rate(ma_linear_resampler* pResampler, ma_uint32 sampleRateIn, ma_uint32 sampleRateOut); MA_API ma_result ma_linear_resampler_set_rate_ratio(ma_linear_resampler* pResampler, float ratioInOut); MA_API ma_uint64 ma_linear_resampler_get_input_latency(const ma_linear_resampler* pResampler); MA_API ma_uint64 ma_linear_resampler_get_output_latency(const ma_linear_resampler* pResampler); MA_API ma_result ma_linear_resampler_get_required_input_frame_count(const ma_linear_resampler* pResampler, ma_uint64 outputFrameCount, ma_uint64* pInputFrameCount); MA_API ma_result ma_linear_resampler_get_expected_output_frame_count(const ma_linear_resampler* pResampler, ma_uint64 inputFrameCount, ma_uint64* pOutputFrameCount); MA_API ma_result ma_linear_resampler_reset(ma_linear_resampler* pResampler); typedef struct ma_resampler_config ma_resampler_config; typedef void ma_resampling_backend; typedef struct { ma_result (* onGetHeapSize )(void* pUserData, const ma_resampler_config* pConfig, size_t* pHeapSizeInBytes); ma_result (* onInit )(void* pUserData, const ma_resampler_config* pConfig, void* pHeap, ma_resampling_backend** ppBackend); void (* onUninit )(void* pUserData, ma_resampling_backend* pBackend, const ma_allocation_callbacks* pAllocationCallbacks); ma_result (* onProcess )(void* pUserData, ma_resampling_backend* pBackend, const void* pFramesIn, ma_uint64* pFrameCountIn, void* pFramesOut, ma_uint64* pFrameCountOut); ma_result (* onSetRate )(void* pUserData, ma_resampling_backend* pBackend, ma_uint32 sampleRateIn, ma_uint32 sampleRateOut); /* Optional. Rate changes will be disabled. */ ma_uint64 (* onGetInputLatency )(void* pUserData, const ma_resampling_backend* pBackend); /* Optional. Latency will be reported as 0. */ ma_uint64 (* onGetOutputLatency )(void* pUserData, const ma_resampling_backend* pBackend); /* Optional. Latency will be reported as 0. */ ma_result (* onGetRequiredInputFrameCount )(void* pUserData, const ma_resampling_backend* pBackend, ma_uint64 outputFrameCount, ma_uint64* pInputFrameCount); /* Optional. Latency mitigation will be disabled. */ ma_result (* onGetExpectedOutputFrameCount)(void* pUserData, const ma_resampling_backend* pBackend, ma_uint64 inputFrameCount, ma_uint64* pOutputFrameCount); /* Optional. Latency mitigation will be disabled. */ ma_result (* onReset )(void* pUserData, ma_resampling_backend* pBackend); } ma_resampling_backend_vtable; typedef enum { ma_resample_algorithm_linear = 0, /* Fastest, lowest quality. Optional low-pass filtering. Default. */ ma_resample_algorithm_custom, } ma_resample_algorithm; struct ma_resampler_config { ma_format format; /* Must be either ma_format_f32 or ma_format_s16. */ ma_uint32 channels; ma_uint32 sampleRateIn; ma_uint32 sampleRateOut; ma_resample_algorithm algorithm; /* When set to ma_resample_algorithm_custom, pBackendVTable will be used. */ ma_resampling_backend_vtable* pBackendVTable; void* pBackendUserData; struct { ma_uint32 lpfOrder; } linear; }; MA_API ma_resampler_config ma_resampler_config_init(ma_format format, ma_uint32 channels, ma_uint32 sampleRateIn, ma_uint32 sampleRateOut, ma_resample_algorithm algorithm); typedef struct { ma_resampling_backend* pBackend; ma_resampling_backend_vtable* pBackendVTable; void* pBackendUserData; ma_format format; ma_uint32 channels; ma_uint32 sampleRateIn; ma_uint32 sampleRateOut; union { ma_linear_resampler linear; } state; /* State for stock resamplers so we can avoid a malloc. For stock resamplers, pBackend will point here. */ /* Memory management. */ void* _pHeap; ma_bool32 _ownsHeap; } ma_resampler; MA_API ma_result ma_resampler_get_heap_size(const ma_resampler_config* pConfig, size_t* pHeapSizeInBytes); MA_API ma_result ma_resampler_init_preallocated(const ma_resampler_config* pConfig, void* pHeap, ma_resampler* pResampler); /* Initializes a new resampler object from a config. */ MA_API ma_result ma_resampler_init(const ma_resampler_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_resampler* pResampler); /* Uninitializes a resampler. */ MA_API void ma_resampler_uninit(ma_resampler* pResampler, const ma_allocation_callbacks* pAllocationCallbacks); /* Converts the given input data. Both the input and output frames must be in the format specified in the config when the resampler was initialized. On input, [pFrameCountOut] contains the number of output frames to process. On output it contains the number of output frames that were actually processed, which may be less than the requested amount which will happen if there's not enough input data. You can use ma_resampler_get_expected_output_frame_count() to know how many output frames will be processed for a given number of input frames. On input, [pFrameCountIn] contains the number of input frames contained in [pFramesIn]. On output it contains the number of whole input frames that were actually processed. You can use ma_resampler_get_required_input_frame_count() to know how many input frames you should provide for a given number of output frames. [pFramesIn] can be NULL, in which case zeroes will be used instead. If [pFramesOut] is NULL, a seek is performed. In this case, if [pFrameCountOut] is not NULL it will seek by the specified number of output frames. Otherwise, if [pFramesCountOut] is NULL and [pFrameCountIn] is not NULL, it will seek by the specified number of input frames. When seeking, [pFramesIn] is allowed to NULL, in which case the internal timing state will be updated, but no input will be processed. In this case, any internal filter state will be updated as if zeroes were passed in. It is an error for [pFramesOut] to be non-NULL and [pFrameCountOut] to be NULL. It is an error for both [pFrameCountOut] and [pFrameCountIn] to be NULL. */ MA_API ma_result ma_resampler_process_pcm_frames(ma_resampler* pResampler, const void* pFramesIn, ma_uint64* pFrameCountIn, void* pFramesOut, ma_uint64* pFrameCountOut); /* Sets the input and output sample rate. */ MA_API ma_result ma_resampler_set_rate(ma_resampler* pResampler, ma_uint32 sampleRateIn, ma_uint32 sampleRateOut); /* Sets the input and output sample rate as a ratio. The ration is in/out. */ MA_API ma_result ma_resampler_set_rate_ratio(ma_resampler* pResampler, float ratio); /* Retrieves the latency introduced by the resampler in input frames. */ MA_API ma_uint64 ma_resampler_get_input_latency(const ma_resampler* pResampler); /* Retrieves the latency introduced by the resampler in output frames. */ MA_API ma_uint64 ma_resampler_get_output_latency(const ma_resampler* pResampler); /* Calculates the number of whole input frames that would need to be read from the client in order to output the specified number of output frames. The returned value does not include cached input frames. It only returns the number of extra frames that would need to be read from the input buffer in order to output the specified number of output frames. */ MA_API ma_result ma_resampler_get_required_input_frame_count(const ma_resampler* pResampler, ma_uint64 outputFrameCount, ma_uint64* pInputFrameCount); /* Calculates the number of whole output frames that would be output after fully reading and consuming the specified number of input frames. */ MA_API ma_result ma_resampler_get_expected_output_frame_count(const ma_resampler* pResampler, ma_uint64 inputFrameCount, ma_uint64* pOutputFrameCount); /* Resets the resampler's timer and clears it's internal cache. */ MA_API ma_result ma_resampler_reset(ma_resampler* pResampler); /************************************************************************************************************************************************************** Channel Conversion **************************************************************************************************************************************************************/ typedef enum { ma_channel_conversion_path_unknown, ma_channel_conversion_path_passthrough, ma_channel_conversion_path_mono_out, /* Converting to mono. */ ma_channel_conversion_path_mono_in, /* Converting from mono. */ ma_channel_conversion_path_shuffle, /* Simple shuffle. Will use this when all channels are present in both input and output channel maps, but just in a different order. */ ma_channel_conversion_path_weights /* Blended based on weights. */ } ma_channel_conversion_path; typedef enum { ma_mono_expansion_mode_duplicate = 0, /* The default. */ ma_mono_expansion_mode_average, /* Average the mono channel across all channels. */ ma_mono_expansion_mode_stereo_only, /* Duplicate to the left and right channels only and ignore the others. */ ma_mono_expansion_mode_default = ma_mono_expansion_mode_duplicate } ma_mono_expansion_mode; typedef struct { ma_format format; ma_uint32 channelsIn; ma_uint32 channelsOut; const ma_channel* pChannelMapIn; const ma_channel* pChannelMapOut; ma_channel_mix_mode mixingMode; ma_bool32 calculateLFEFromSpatialChannels; /* When an output LFE channel is present, but no input LFE, set to true to set the output LFE to the average of all spatial channels (LR, FR, etc.). Ignored when an input LFE is present. */ float** ppWeights; /* [in][out]. Only used when mixingMode is set to ma_channel_mix_mode_custom_weights. */ } ma_channel_converter_config; MA_API ma_channel_converter_config ma_channel_converter_config_init(ma_format format, ma_uint32 channelsIn, const ma_channel* pChannelMapIn, ma_uint32 channelsOut, const ma_channel* pChannelMapOut, ma_channel_mix_mode mixingMode); typedef struct { ma_format format; ma_uint32 channelsIn; ma_uint32 channelsOut; ma_channel_mix_mode mixingMode; ma_channel_conversion_path conversionPath; ma_channel* pChannelMapIn; ma_channel* pChannelMapOut; ma_uint8* pShuffleTable; /* Indexed by output channel index. */ union { float** f32; ma_int32** s16; } weights; /* [in][out] */ /* Memory management. */ void* _pHeap; ma_bool32 _ownsHeap; } ma_channel_converter; MA_API ma_result ma_channel_converter_get_heap_size(const ma_channel_converter_config* pConfig, size_t* pHeapSizeInBytes); MA_API ma_result ma_channel_converter_init_preallocated(const ma_channel_converter_config* pConfig, void* pHeap, ma_channel_converter* pConverter); MA_API ma_result ma_channel_converter_init(const ma_channel_converter_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_channel_converter* pConverter); MA_API void ma_channel_converter_uninit(ma_channel_converter* pConverter, const ma_allocation_callbacks* pAllocationCallbacks); MA_API ma_result ma_channel_converter_process_pcm_frames(ma_channel_converter* pConverter, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount); MA_API ma_result ma_channel_converter_get_input_channel_map(const ma_channel_converter* pConverter, ma_channel* pChannelMap, size_t channelMapCap); MA_API ma_result ma_channel_converter_get_output_channel_map(const ma_channel_converter* pConverter, ma_channel* pChannelMap, size_t channelMapCap); /************************************************************************************************************************************************************** Data Conversion **************************************************************************************************************************************************************/ typedef struct { ma_format formatIn; ma_format formatOut; ma_uint32 channelsIn; ma_uint32 channelsOut; ma_uint32 sampleRateIn; ma_uint32 sampleRateOut; ma_channel* pChannelMapIn; ma_channel* pChannelMapOut; ma_dither_mode ditherMode; ma_channel_mix_mode channelMixMode; ma_bool32 calculateLFEFromSpatialChannels; /* When an output LFE channel is present, but no input LFE, set to true to set the output LFE to the average of all spatial channels (LR, FR, etc.). Ignored when an input LFE is present. */ float** ppChannelWeights; /* [in][out]. Only used when mixingMode is set to ma_channel_mix_mode_custom_weights. */ ma_bool32 allowDynamicSampleRate; ma_resampler_config resampling; } ma_data_converter_config; MA_API ma_data_converter_config ma_data_converter_config_init_default(void); MA_API ma_data_converter_config ma_data_converter_config_init(ma_format formatIn, ma_format formatOut, ma_uint32 channelsIn, ma_uint32 channelsOut, ma_uint32 sampleRateIn, ma_uint32 sampleRateOut); typedef enum { ma_data_converter_execution_path_passthrough, /* No conversion. */ ma_data_converter_execution_path_format_only, /* Only format conversion. */ ma_data_converter_execution_path_channels_only, /* Only channel conversion. */ ma_data_converter_execution_path_resample_only, /* Only resampling. */ ma_data_converter_execution_path_resample_first, /* All conversions, but resample as the first step. */ ma_data_converter_execution_path_channels_first /* All conversions, but channels as the first step. */ } ma_data_converter_execution_path; typedef struct { ma_format formatIn; ma_format formatOut; ma_uint32 channelsIn; ma_uint32 channelsOut; ma_uint32 sampleRateIn; ma_uint32 sampleRateOut; ma_dither_mode ditherMode; ma_data_converter_execution_path executionPath; /* The execution path the data converter will follow when processing. */ ma_channel_converter channelConverter; ma_resampler resampler; ma_bool8 hasPreFormatConversion; ma_bool8 hasPostFormatConversion; ma_bool8 hasChannelConverter; ma_bool8 hasResampler; ma_bool8 isPassthrough; /* Memory management. */ ma_bool8 _ownsHeap; void* _pHeap; } ma_data_converter; MA_API ma_result ma_data_converter_get_heap_size(const ma_data_converter_config* pConfig, size_t* pHeapSizeInBytes); MA_API ma_result ma_data_converter_init_preallocated(const ma_data_converter_config* pConfig, void* pHeap, ma_data_converter* pConverter); MA_API ma_result ma_data_converter_init(const ma_data_converter_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_data_converter* pConverter); MA_API void ma_data_converter_uninit(ma_data_converter* pConverter, const ma_allocation_callbacks* pAllocationCallbacks); MA_API ma_result ma_data_converter_process_pcm_frames(ma_data_converter* pConverter, const void* pFramesIn, ma_uint64* pFrameCountIn, void* pFramesOut, ma_uint64* pFrameCountOut); MA_API ma_result ma_data_converter_set_rate(ma_data_converter* pConverter, ma_uint32 sampleRateIn, ma_uint32 sampleRateOut); MA_API ma_result ma_data_converter_set_rate_ratio(ma_data_converter* pConverter, float ratioInOut); MA_API ma_uint64 ma_data_converter_get_input_latency(const ma_data_converter* pConverter); MA_API ma_uint64 ma_data_converter_get_output_latency(const ma_data_converter* pConverter); MA_API ma_result ma_data_converter_get_required_input_frame_count(const ma_data_converter* pConverter, ma_uint64 outputFrameCount, ma_uint64* pInputFrameCount); MA_API ma_result ma_data_converter_get_expected_output_frame_count(const ma_data_converter* pConverter, ma_uint64 inputFrameCount, ma_uint64* pOutputFrameCount); MA_API ma_result ma_data_converter_get_input_channel_map(const ma_data_converter* pConverter, ma_channel* pChannelMap, size_t channelMapCap); MA_API ma_result ma_data_converter_get_output_channel_map(const ma_data_converter* pConverter, ma_channel* pChannelMap, size_t channelMapCap); MA_API ma_result ma_data_converter_reset(ma_data_converter* pConverter); /************************************************************************************************************************************************************ Format Conversion ************************************************************************************************************************************************************/ MA_API void ma_pcm_u8_to_s16(void* pOut, const void* pIn, ma_uint64 count, ma_dither_mode ditherMode); MA_API void ma_pcm_u8_to_s24(void* pOut, const void* pIn, ma_uint64 count, ma_dither_mode ditherMode); MA_API void ma_pcm_u8_to_s32(void* pOut, const void* pIn, ma_uint64 count, ma_dither_mode ditherMode); MA_API void ma_pcm_u8_to_f32(void* pOut, const void* pIn, ma_uint64 count, ma_dither_mode ditherMode); MA_API void ma_pcm_s16_to_u8(void* pOut, const void* pIn, ma_uint64 count, ma_dither_mode ditherMode); MA_API void ma_pcm_s16_to_s24(void* pOut, const void* pIn, ma_uint64 count, ma_dither_mode ditherMode); MA_API void ma_pcm_s16_to_s32(void* pOut, const void* pIn, ma_uint64 count, ma_dither_mode ditherMode); MA_API void ma_pcm_s16_to_f32(void* pOut, const void* pIn, ma_uint64 count, ma_dither_mode ditherMode); MA_API void ma_pcm_s24_to_u8(void* pOut, const void* pIn, ma_uint64 count, ma_dither_mode ditherMode); MA_API void ma_pcm_s24_to_s16(void* pOut, const void* pIn, ma_uint64 count, ma_dither_mode ditherMode); MA_API void ma_pcm_s24_to_s32(void* pOut, const void* pIn, ma_uint64 count, ma_dither_mode ditherMode); MA_API void ma_pcm_s24_to_f32(void* pOut, const void* pIn, ma_uint64 count, ma_dither_mode ditherMode); MA_API void ma_pcm_s32_to_u8(void* pOut, const void* pIn, ma_uint64 count, ma_dither_mode ditherMode); MA_API void ma_pcm_s32_to_s16(void* pOut, const void* pIn, ma_uint64 count, ma_dither_mode ditherMode); MA_API void ma_pcm_s32_to_s24(void* pOut, const void* pIn, ma_uint64 count, ma_dither_mode ditherMode); MA_API void ma_pcm_s32_to_f32(void* pOut, const void* pIn, ma_uint64 count, ma_dither_mode ditherMode); MA_API void ma_pcm_f32_to_u8(void* pOut, const void* pIn, ma_uint64 count, ma_dither_mode ditherMode); MA_API void ma_pcm_f32_to_s16(void* pOut, const void* pIn, ma_uint64 count, ma_dither_mode ditherMode); MA_API void ma_pcm_f32_to_s24(void* pOut, const void* pIn, ma_uint64 count, ma_dither_mode ditherMode); MA_API void ma_pcm_f32_to_s32(void* pOut, const void* pIn, ma_uint64 count, ma_dither_mode ditherMode); MA_API void ma_pcm_convert(void* pOut, ma_format formatOut, const void* pIn, ma_format formatIn, ma_uint64 sampleCount, ma_dither_mode ditherMode); MA_API void ma_convert_pcm_frames_format(void* pOut, ma_format formatOut, const void* pIn, ma_format formatIn, ma_uint64 frameCount, ma_uint32 channels, ma_dither_mode ditherMode); /* Deinterleaves an interleaved buffer. */ MA_API void ma_deinterleave_pcm_frames(ma_format format, ma_uint32 channels, ma_uint64 frameCount, const void* pInterleavedPCMFrames, void** ppDeinterleavedPCMFrames); /* Interleaves a group of deinterleaved buffers. */ MA_API void ma_interleave_pcm_frames(ma_format format, ma_uint32 channels, ma_uint64 frameCount, const void** ppDeinterleavedPCMFrames, void* pInterleavedPCMFrames); /************************************************************************************************************************************************************ Channel Maps ************************************************************************************************************************************************************/ /* This is used in the shuffle table to indicate that the channel index is undefined and should be ignored. */ #define MA_CHANNEL_INDEX_NULL 255 /* Retrieves the channel position of the specified channel in the given channel map. The pChannelMap parameter can be null, in which case miniaudio's default channel map will be assumed. */ MA_API ma_channel ma_channel_map_get_channel(const ma_channel* pChannelMap, ma_uint32 channelCount, ma_uint32 channelIndex); /* Initializes a blank channel map. When a blank channel map is specified anywhere it indicates that the native channel map should be used. */ MA_API void ma_channel_map_init_blank(ma_channel* pChannelMap, ma_uint32 channels); /* Helper for retrieving a standard channel map. The output channel map buffer must have a capacity of at least `channelMapCap`. */ MA_API void ma_channel_map_init_standard(ma_standard_channel_map standardChannelMap, ma_channel* pChannelMap, size_t channelMapCap, ma_uint32 channels); /* Copies a channel map. Both input and output channel map buffers must have a capacity of at at least `channels`. */ MA_API void ma_channel_map_copy(ma_channel* pOut, const ma_channel* pIn, ma_uint32 channels); /* Copies a channel map if one is specified, otherwise copies the default channel map. The output buffer must have a capacity of at least `channels`. If not NULL, the input channel map must also have a capacity of at least `channels`. */ MA_API void ma_channel_map_copy_or_default(ma_channel* pOut, size_t channelMapCapOut, const ma_channel* pIn, ma_uint32 channels); /* Determines whether or not a channel map is valid. A blank channel map is valid (all channels set to MA_CHANNEL_NONE). The way a blank channel map is handled is context specific, but is usually treated as a passthrough. Invalid channel maps: - A channel map with no channels - A channel map with more than one channel and a mono channel The channel map buffer must have a capacity of at least `channels`. */ MA_API ma_bool32 ma_channel_map_is_valid(const ma_channel* pChannelMap, ma_uint32 channels); /* Helper for comparing two channel maps for equality. This assumes the channel count is the same between the two. Both channels map buffers must have a capacity of at least `channels`. */ MA_API ma_bool32 ma_channel_map_is_equal(const ma_channel* pChannelMapA, const ma_channel* pChannelMapB, ma_uint32 channels); /* Helper for determining if a channel map is blank (all channels set to MA_CHANNEL_NONE). The channel map buffer must have a capacity of at least `channels`. */ MA_API ma_bool32 ma_channel_map_is_blank(const ma_channel* pChannelMap, ma_uint32 channels); /* Helper for determining whether or not a channel is present in the given channel map. The channel map buffer must have a capacity of at least `channels`. */ MA_API ma_bool32 ma_channel_map_contains_channel_position(ma_uint32 channels, const ma_channel* pChannelMap, ma_channel channelPosition); /* Find a channel position in the given channel map. Returns MA_TRUE if the channel is found; MA_FALSE otherwise. The index of the channel is output to `pChannelIndex`. The channel map buffer must have a capacity of at least `channels`. */ MA_API ma_bool32 ma_channel_map_find_channel_position(ma_uint32 channels, const ma_channel* pChannelMap, ma_channel channelPosition, ma_uint32* pChannelIndex); /* Generates a string representing the given channel map. This is for printing and debugging purposes, not serialization/deserialization. Returns the length of the string, not including the null terminator. */ MA_API size_t ma_channel_map_to_string(const ma_channel* pChannelMap, ma_uint32 channels, char* pBufferOut, size_t bufferCap); /* Retrieves a human readable version of a channel position. */ MA_API const char* ma_channel_position_to_string(ma_channel channel); /************************************************************************************************************************************************************ Conversion Helpers ************************************************************************************************************************************************************/ /* High-level helper for doing a full format conversion in one go. Returns the number of output frames. Call this with pOut set to NULL to determine the required size of the output buffer. frameCountOut should be set to the capacity of pOut. If pOut is NULL, frameCountOut is ignored. A return value of 0 indicates an error. This function is useful for one-off bulk conversions, but if you're streaming data you should use the ma_data_converter APIs instead. */ MA_API ma_uint64 ma_convert_frames(void* pOut, ma_uint64 frameCountOut, ma_format formatOut, ma_uint32 channelsOut, ma_uint32 sampleRateOut, const void* pIn, ma_uint64 frameCountIn, ma_format formatIn, ma_uint32 channelsIn, ma_uint32 sampleRateIn); MA_API ma_uint64 ma_convert_frames_ex(void* pOut, ma_uint64 frameCountOut, const void* pIn, ma_uint64 frameCountIn, const ma_data_converter_config* pConfig); /************************************************************************************************************************************************************ Data Source ************************************************************************************************************************************************************/ typedef void ma_data_source; #define MA_DATA_SOURCE_SELF_MANAGED_RANGE_AND_LOOP_POINT 0x00000001 typedef struct { ma_result (* onRead)(ma_data_source* pDataSource, void* pFramesOut, ma_uint64 frameCount, ma_uint64* pFramesRead); ma_result (* onSeek)(ma_data_source* pDataSource, ma_uint64 frameIndex); ma_result (* onGetDataFormat)(ma_data_source* pDataSource, ma_format* pFormat, ma_uint32* pChannels, ma_uint32* pSampleRate, ma_channel* pChannelMap, size_t channelMapCap); ma_result (* onGetCursor)(ma_data_source* pDataSource, ma_uint64* pCursor); ma_result (* onGetLength)(ma_data_source* pDataSource, ma_uint64* pLength); ma_result (* onSetLooping)(ma_data_source* pDataSource, ma_bool32 isLooping); ma_uint32 flags; } ma_data_source_vtable; typedef ma_data_source* (* ma_data_source_get_next_proc)(ma_data_source* pDataSource); typedef struct { const ma_data_source_vtable* vtable; } ma_data_source_config; MA_API ma_data_source_config ma_data_source_config_init(void); typedef struct { const ma_data_source_vtable* vtable; ma_uint64 rangeBegInFrames; ma_uint64 rangeEndInFrames; /* Set to -1 for unranged (default). */ ma_uint64 loopBegInFrames; /* Relative to rangeBegInFrames. */ ma_uint64 loopEndInFrames; /* Relative to rangeBegInFrames. Set to -1 for the end of the range. */ ma_data_source* pCurrent; /* When non-NULL, the data source being initialized will act as a proxy and will route all operations to pCurrent. Used in conjunction with pNext/onGetNext for seamless chaining. */ ma_data_source* pNext; /* When set to NULL, onGetNext will be used. */ ma_data_source_get_next_proc onGetNext; /* Will be used when pNext is NULL. If both are NULL, no next will be used. */ MA_ATOMIC(4, ma_bool32) isLooping; } ma_data_source_base; MA_API ma_result ma_data_source_init(const ma_data_source_config* pConfig, ma_data_source* pDataSource); MA_API void ma_data_source_uninit(ma_data_source* pDataSource); MA_API ma_result ma_data_source_read_pcm_frames(ma_data_source* pDataSource, void* pFramesOut, ma_uint64 frameCount, ma_uint64* pFramesRead); /* Must support pFramesOut = NULL in which case a forward seek should be performed. */ MA_API ma_result ma_data_source_seek_pcm_frames(ma_data_source* pDataSource, ma_uint64 frameCount, ma_uint64* pFramesSeeked); /* Can only seek forward. Equivalent to ma_data_source_read_pcm_frames(pDataSource, NULL, frameCount, &framesRead); */ MA_API ma_result ma_data_source_seek_to_pcm_frame(ma_data_source* pDataSource, ma_uint64 frameIndex); MA_API ma_result ma_data_source_get_data_format(ma_data_source* pDataSource, ma_format* pFormat, ma_uint32* pChannels, ma_uint32* pSampleRate, ma_channel* pChannelMap, size_t channelMapCap); MA_API ma_result ma_data_source_get_cursor_in_pcm_frames(ma_data_source* pDataSource, ma_uint64* pCursor); MA_API ma_result ma_data_source_get_length_in_pcm_frames(ma_data_source* pDataSource, ma_uint64* pLength); /* Returns MA_NOT_IMPLEMENTED if the length is unknown or cannot be determined. Decoders can return this. */ MA_API ma_result ma_data_source_get_cursor_in_seconds(ma_data_source* pDataSource, float* pCursor); MA_API ma_result ma_data_source_get_length_in_seconds(ma_data_source* pDataSource, float* pLength); MA_API ma_result ma_data_source_set_looping(ma_data_source* pDataSource, ma_bool32 isLooping); MA_API ma_bool32 ma_data_source_is_looping(const ma_data_source* pDataSource); MA_API ma_result ma_data_source_set_range_in_pcm_frames(ma_data_source* pDataSource, ma_uint64 rangeBegInFrames, ma_uint64 rangeEndInFrames); MA_API void ma_data_source_get_range_in_pcm_frames(const ma_data_source* pDataSource, ma_uint64* pRangeBegInFrames, ma_uint64* pRangeEndInFrames); MA_API ma_result ma_data_source_set_loop_point_in_pcm_frames(ma_data_source* pDataSource, ma_uint64 loopBegInFrames, ma_uint64 loopEndInFrames); MA_API void ma_data_source_get_loop_point_in_pcm_frames(const ma_data_source* pDataSource, ma_uint64* pLoopBegInFrames, ma_uint64* pLoopEndInFrames); MA_API ma_result ma_data_source_set_current(ma_data_source* pDataSource, ma_data_source* pCurrentDataSource); MA_API ma_data_source* ma_data_source_get_current(const ma_data_source* pDataSource); MA_API ma_result ma_data_source_set_next(ma_data_source* pDataSource, ma_data_source* pNextDataSource); MA_API ma_data_source* ma_data_source_get_next(const ma_data_source* pDataSource); MA_API ma_result ma_data_source_set_next_callback(ma_data_source* pDataSource, ma_data_source_get_next_proc onGetNext); MA_API ma_data_source_get_next_proc ma_data_source_get_next_callback(const ma_data_source* pDataSource); typedef struct { ma_data_source_base ds; ma_format format; ma_uint32 channels; ma_uint32 sampleRate; ma_uint64 cursor; ma_uint64 sizeInFrames; const void* pData; } ma_audio_buffer_ref; MA_API ma_result ma_audio_buffer_ref_init(ma_format format, ma_uint32 channels, const void* pData, ma_uint64 sizeInFrames, ma_audio_buffer_ref* pAudioBufferRef); MA_API void ma_audio_buffer_ref_uninit(ma_audio_buffer_ref* pAudioBufferRef); MA_API ma_result ma_audio_buffer_ref_set_data(ma_audio_buffer_ref* pAudioBufferRef, const void* pData, ma_uint64 sizeInFrames); MA_API ma_uint64 ma_audio_buffer_ref_read_pcm_frames(ma_audio_buffer_ref* pAudioBufferRef, void* pFramesOut, ma_uint64 frameCount, ma_bool32 loop); MA_API ma_result ma_audio_buffer_ref_seek_to_pcm_frame(ma_audio_buffer_ref* pAudioBufferRef, ma_uint64 frameIndex); MA_API ma_result ma_audio_buffer_ref_map(ma_audio_buffer_ref* pAudioBufferRef, void** ppFramesOut, ma_uint64* pFrameCount); MA_API ma_result ma_audio_buffer_ref_unmap(ma_audio_buffer_ref* pAudioBufferRef, ma_uint64 frameCount); /* Returns MA_AT_END if the end has been reached. This should be considered successful. */ MA_API ma_bool32 ma_audio_buffer_ref_at_end(const ma_audio_buffer_ref* pAudioBufferRef); MA_API ma_result ma_audio_buffer_ref_get_cursor_in_pcm_frames(const ma_audio_buffer_ref* pAudioBufferRef, ma_uint64* pCursor); MA_API ma_result ma_audio_buffer_ref_get_length_in_pcm_frames(const ma_audio_buffer_ref* pAudioBufferRef, ma_uint64* pLength); MA_API ma_result ma_audio_buffer_ref_get_available_frames(const ma_audio_buffer_ref* pAudioBufferRef, ma_uint64* pAvailableFrames); typedef struct { ma_format format; ma_uint32 channels; ma_uint32 sampleRate; ma_uint64 sizeInFrames; const void* pData; /* If set to NULL, will allocate a block of memory for you. */ ma_allocation_callbacks allocationCallbacks; } ma_audio_buffer_config; MA_API ma_audio_buffer_config ma_audio_buffer_config_init(ma_format format, ma_uint32 channels, ma_uint64 sizeInFrames, const void* pData, const ma_allocation_callbacks* pAllocationCallbacks); typedef struct { ma_audio_buffer_ref ref; ma_allocation_callbacks allocationCallbacks; ma_bool32 ownsData; /* Used to control whether or not miniaudio owns the data buffer. If set to true, pData will be freed in ma_audio_buffer_uninit(). */ ma_uint8 _pExtraData[1]; /* For allocating a buffer with the memory located directly after the other memory of the structure. */ } ma_audio_buffer; MA_API ma_result ma_audio_buffer_init(const ma_audio_buffer_config* pConfig, ma_audio_buffer* pAudioBuffer); MA_API ma_result ma_audio_buffer_init_copy(const ma_audio_buffer_config* pConfig, ma_audio_buffer* pAudioBuffer); MA_API ma_result ma_audio_buffer_alloc_and_init(const ma_audio_buffer_config* pConfig, ma_audio_buffer** ppAudioBuffer); /* Always copies the data. Doesn't make sense to use this otherwise. Use ma_audio_buffer_uninit_and_free() to uninit. */ MA_API void ma_audio_buffer_uninit(ma_audio_buffer* pAudioBuffer); MA_API void ma_audio_buffer_uninit_and_free(ma_audio_buffer* pAudioBuffer); MA_API ma_uint64 ma_audio_buffer_read_pcm_frames(ma_audio_buffer* pAudioBuffer, void* pFramesOut, ma_uint64 frameCount, ma_bool32 loop); MA_API ma_result ma_audio_buffer_seek_to_pcm_frame(ma_audio_buffer* pAudioBuffer, ma_uint64 frameIndex); MA_API ma_result ma_audio_buffer_map(ma_audio_buffer* pAudioBuffer, void** ppFramesOut, ma_uint64* pFrameCount); MA_API ma_result ma_audio_buffer_unmap(ma_audio_buffer* pAudioBuffer, ma_uint64 frameCount); /* Returns MA_AT_END if the end has been reached. This should be considered successful. */ MA_API ma_bool32 ma_audio_buffer_at_end(const ma_audio_buffer* pAudioBuffer); MA_API ma_result ma_audio_buffer_get_cursor_in_pcm_frames(const ma_audio_buffer* pAudioBuffer, ma_uint64* pCursor); MA_API ma_result ma_audio_buffer_get_length_in_pcm_frames(const ma_audio_buffer* pAudioBuffer, ma_uint64* pLength); MA_API ma_result ma_audio_buffer_get_available_frames(const ma_audio_buffer* pAudioBuffer, ma_uint64* pAvailableFrames); /* Paged Audio Buffer ================== A paged audio buffer is made up of a linked list of pages. It's expandable, but not shrinkable. It can be used for cases where audio data is streamed in asynchronously while allowing data to be read at the same time. This is lock-free, but not 100% thread safe. You can append a page and read from the buffer across simultaneously across different threads, however only one thread at a time can append, and only one thread at a time can read and seek. */ typedef struct ma_paged_audio_buffer_page ma_paged_audio_buffer_page; struct ma_paged_audio_buffer_page { MA_ATOMIC(MA_SIZEOF_PTR, ma_paged_audio_buffer_page*) pNext; ma_uint64 sizeInFrames; ma_uint8 pAudioData[1]; }; typedef struct { ma_format format; ma_uint32 channels; ma_paged_audio_buffer_page head; /* Dummy head for the lock-free algorithm. Always has a size of 0. */ MA_ATOMIC(MA_SIZEOF_PTR, ma_paged_audio_buffer_page*) pTail; /* Never null. Initially set to &head. */ } ma_paged_audio_buffer_data; MA_API ma_result ma_paged_audio_buffer_data_init(ma_format format, ma_uint32 channels, ma_paged_audio_buffer_data* pData); MA_API void ma_paged_audio_buffer_data_uninit(ma_paged_audio_buffer_data* pData, const ma_allocation_callbacks* pAllocationCallbacks); MA_API ma_paged_audio_buffer_page* ma_paged_audio_buffer_data_get_head(ma_paged_audio_buffer_data* pData); MA_API ma_paged_audio_buffer_page* ma_paged_audio_buffer_data_get_tail(ma_paged_audio_buffer_data* pData); MA_API ma_result ma_paged_audio_buffer_data_get_length_in_pcm_frames(ma_paged_audio_buffer_data* pData, ma_uint64* pLength); MA_API ma_result ma_paged_audio_buffer_data_allocate_page(ma_paged_audio_buffer_data* pData, ma_uint64 pageSizeInFrames, const void* pInitialData, const ma_allocation_callbacks* pAllocationCallbacks, ma_paged_audio_buffer_page** ppPage); MA_API ma_result ma_paged_audio_buffer_data_free_page(ma_paged_audio_buffer_data* pData, ma_paged_audio_buffer_page* pPage, const ma_allocation_callbacks* pAllocationCallbacks); MA_API ma_result ma_paged_audio_buffer_data_append_page(ma_paged_audio_buffer_data* pData, ma_paged_audio_buffer_page* pPage); MA_API ma_result ma_paged_audio_buffer_data_allocate_and_append_page(ma_paged_audio_buffer_data* pData, ma_uint32 pageSizeInFrames, const void* pInitialData, const ma_allocation_callbacks* pAllocationCallbacks); typedef struct { ma_paged_audio_buffer_data* pData; /* Must not be null. */ } ma_paged_audio_buffer_config; MA_API ma_paged_audio_buffer_config ma_paged_audio_buffer_config_init(ma_paged_audio_buffer_data* pData); typedef struct { ma_data_source_base ds; ma_paged_audio_buffer_data* pData; /* Audio data is read from here. Cannot be null. */ ma_paged_audio_buffer_page* pCurrent; ma_uint64 relativeCursor; /* Relative to the current page. */ ma_uint64 absoluteCursor; } ma_paged_audio_buffer; MA_API ma_result ma_paged_audio_buffer_init(const ma_paged_audio_buffer_config* pConfig, ma_paged_audio_buffer* pPagedAudioBuffer); MA_API void ma_paged_audio_buffer_uninit(ma_paged_audio_buffer* pPagedAudioBuffer); MA_API ma_result ma_paged_audio_buffer_read_pcm_frames(ma_paged_audio_buffer* pPagedAudioBuffer, void* pFramesOut, ma_uint64 frameCount, ma_uint64* pFramesRead); /* Returns MA_AT_END if no more pages available. */ MA_API ma_result ma_paged_audio_buffer_seek_to_pcm_frame(ma_paged_audio_buffer* pPagedAudioBuffer, ma_uint64 frameIndex); MA_API ma_result ma_paged_audio_buffer_get_cursor_in_pcm_frames(ma_paged_audio_buffer* pPagedAudioBuffer, ma_uint64* pCursor); MA_API ma_result ma_paged_audio_buffer_get_length_in_pcm_frames(ma_paged_audio_buffer* pPagedAudioBuffer, ma_uint64* pLength); /************************************************************************************************************************************************************ Ring Buffer ************************************************************************************************************************************************************/ typedef struct { void* pBuffer; ma_uint32 subbufferSizeInBytes; ma_uint32 subbufferCount; ma_uint32 subbufferStrideInBytes; MA_ATOMIC(4, ma_uint32) encodedReadOffset; /* Most significant bit is the loop flag. Lower 31 bits contains the actual offset in bytes. Must be used atomically. */ MA_ATOMIC(4, ma_uint32) encodedWriteOffset; /* Most significant bit is the loop flag. Lower 31 bits contains the actual offset in bytes. Must be used atomically. */ ma_bool8 ownsBuffer; /* Used to know whether or not miniaudio is responsible for free()-ing the buffer. */ ma_bool8 clearOnWriteAcquire; /* When set, clears the acquired write buffer before returning from ma_rb_acquire_write(). */ ma_allocation_callbacks allocationCallbacks; } ma_rb; MA_API ma_result ma_rb_init_ex(size_t subbufferSizeInBytes, size_t subbufferCount, size_t subbufferStrideInBytes, void* pOptionalPreallocatedBuffer, const ma_allocation_callbacks* pAllocationCallbacks, ma_rb* pRB); MA_API ma_result ma_rb_init(size_t bufferSizeInBytes, void* pOptionalPreallocatedBuffer, const ma_allocation_callbacks* pAllocationCallbacks, ma_rb* pRB); MA_API void ma_rb_uninit(ma_rb* pRB); MA_API void ma_rb_reset(ma_rb* pRB); MA_API ma_result ma_rb_acquire_read(ma_rb* pRB, size_t* pSizeInBytes, void** ppBufferOut); MA_API ma_result ma_rb_commit_read(ma_rb* pRB, size_t sizeInBytes); MA_API ma_result ma_rb_acquire_write(ma_rb* pRB, size_t* pSizeInBytes, void** ppBufferOut); MA_API ma_result ma_rb_commit_write(ma_rb* pRB, size_t sizeInBytes); MA_API ma_result ma_rb_seek_read(ma_rb* pRB, size_t offsetInBytes); MA_API ma_result ma_rb_seek_write(ma_rb* pRB, size_t offsetInBytes); MA_API ma_int32 ma_rb_pointer_distance(ma_rb* pRB); /* Returns the distance between the write pointer and the read pointer. Should never be negative for a correct program. Will return the number of bytes that can be read before the read pointer hits the write pointer. */ MA_API ma_uint32 ma_rb_available_read(ma_rb* pRB); MA_API ma_uint32 ma_rb_available_write(ma_rb* pRB); MA_API size_t ma_rb_get_subbuffer_size(ma_rb* pRB); MA_API size_t ma_rb_get_subbuffer_stride(ma_rb* pRB); MA_API size_t ma_rb_get_subbuffer_offset(ma_rb* pRB, size_t subbufferIndex); MA_API void* ma_rb_get_subbuffer_ptr(ma_rb* pRB, size_t subbufferIndex, void* pBuffer); typedef struct { ma_data_source_base ds; ma_rb rb; ma_format format; ma_uint32 channels; ma_uint32 sampleRate; /* Not required for the ring buffer itself, but useful for associating the data with some sample rate, particularly for data sources. */ } ma_pcm_rb; MA_API ma_result ma_pcm_rb_init_ex(ma_format format, ma_uint32 channels, ma_uint32 subbufferSizeInFrames, ma_uint32 subbufferCount, ma_uint32 subbufferStrideInFrames, void* pOptionalPreallocatedBuffer, const ma_allocation_callbacks* pAllocationCallbacks, ma_pcm_rb* pRB); MA_API ma_result ma_pcm_rb_init(ma_format format, ma_uint32 channels, ma_uint32 bufferSizeInFrames, void* pOptionalPreallocatedBuffer, const ma_allocation_callbacks* pAllocationCallbacks, ma_pcm_rb* pRB); MA_API void ma_pcm_rb_uninit(ma_pcm_rb* pRB); MA_API void ma_pcm_rb_reset(ma_pcm_rb* pRB); MA_API ma_result ma_pcm_rb_acquire_read(ma_pcm_rb* pRB, ma_uint32* pSizeInFrames, void** ppBufferOut); MA_API ma_result ma_pcm_rb_commit_read(ma_pcm_rb* pRB, ma_uint32 sizeInFrames); MA_API ma_result ma_pcm_rb_acquire_write(ma_pcm_rb* pRB, ma_uint32* pSizeInFrames, void** ppBufferOut); MA_API ma_result ma_pcm_rb_commit_write(ma_pcm_rb* pRB, ma_uint32 sizeInFrames); MA_API ma_result ma_pcm_rb_seek_read(ma_pcm_rb* pRB, ma_uint32 offsetInFrames); MA_API ma_result ma_pcm_rb_seek_write(ma_pcm_rb* pRB, ma_uint32 offsetInFrames); MA_API ma_int32 ma_pcm_rb_pointer_distance(ma_pcm_rb* pRB); /* Return value is in frames. */ MA_API ma_uint32 ma_pcm_rb_available_read(ma_pcm_rb* pRB); MA_API ma_uint32 ma_pcm_rb_available_write(ma_pcm_rb* pRB); MA_API ma_uint32 ma_pcm_rb_get_subbuffer_size(ma_pcm_rb* pRB); MA_API ma_uint32 ma_pcm_rb_get_subbuffer_stride(ma_pcm_rb* pRB); MA_API ma_uint32 ma_pcm_rb_get_subbuffer_offset(ma_pcm_rb* pRB, ma_uint32 subbufferIndex); MA_API void* ma_pcm_rb_get_subbuffer_ptr(ma_pcm_rb* pRB, ma_uint32 subbufferIndex, void* pBuffer); MA_API ma_format ma_pcm_rb_get_format(const ma_pcm_rb* pRB); MA_API ma_uint32 ma_pcm_rb_get_channels(const ma_pcm_rb* pRB); MA_API ma_uint32 ma_pcm_rb_get_sample_rate(const ma_pcm_rb* pRB); MA_API void ma_pcm_rb_set_sample_rate(ma_pcm_rb* pRB, ma_uint32 sampleRate); /* The idea of the duplex ring buffer is to act as the intermediary buffer when running two asynchronous devices in a duplex set up. The capture device writes to it, and then a playback device reads from it. At the moment this is just a simple naive implementation, but in the future I want to implement some dynamic resampling to seamlessly handle desyncs. Note that the API is work in progress and may change at any time in any version. The size of the buffer is based on the capture side since that's what'll be written to the buffer. It is based on the capture period size in frames. The internal sample rate of the capture device is also needed in order to calculate the size. */ typedef struct { ma_pcm_rb rb; } ma_duplex_rb; MA_API ma_result ma_duplex_rb_init(ma_format captureFormat, ma_uint32 captureChannels, ma_uint32 sampleRate, ma_uint32 captureInternalSampleRate, ma_uint32 captureInternalPeriodSizeInFrames, const ma_allocation_callbacks* pAllocationCallbacks, ma_duplex_rb* pRB); MA_API ma_result ma_duplex_rb_uninit(ma_duplex_rb* pRB); /************************************************************************************************************************************************************ Miscellaneous Helpers ************************************************************************************************************************************************************/ /* Retrieves a human readable description of the given result code. */ MA_API const char* ma_result_description(ma_result result); /* malloc() */ MA_API void* ma_malloc(size_t sz, const ma_allocation_callbacks* pAllocationCallbacks); /* calloc() */ MA_API void* ma_calloc(size_t sz, const ma_allocation_callbacks* pAllocationCallbacks); /* realloc() */ MA_API void* ma_realloc(void* p, size_t sz, const ma_allocation_callbacks* pAllocationCallbacks); /* free() */ MA_API void ma_free(void* p, const ma_allocation_callbacks* pAllocationCallbacks); /* Performs an aligned malloc, with the assumption that the alignment is a power of 2. */ MA_API void* ma_aligned_malloc(size_t sz, size_t alignment, const ma_allocation_callbacks* pAllocationCallbacks); /* Free's an aligned malloc'd buffer. */ MA_API void ma_aligned_free(void* p, const ma_allocation_callbacks* pAllocationCallbacks); /* Retrieves a friendly name for a format. */ MA_API const char* ma_get_format_name(ma_format format); /* Blends two frames in floating point format. */ MA_API void ma_blend_f32(float* pOut, float* pInA, float* pInB, float factor, ma_uint32 channels); /* Retrieves the size of a sample in bytes for the given format. This API is efficient and is implemented using a lookup table. Thread Safety: SAFE This API is pure. */ MA_API ma_uint32 ma_get_bytes_per_sample(ma_format format); static MA_INLINE ma_uint32 ma_get_bytes_per_frame(ma_format format, ma_uint32 channels) { return ma_get_bytes_per_sample(format) * channels; } /* Converts a log level to a string. */ MA_API const char* ma_log_level_to_string(ma_uint32 logLevel); /************************************************************************************************************************************************************ Synchronization ************************************************************************************************************************************************************/ /* Locks a spinlock. */ MA_API ma_result ma_spinlock_lock(volatile ma_spinlock* pSpinlock); /* Locks a spinlock, but does not yield() when looping. */ MA_API ma_result ma_spinlock_lock_noyield(volatile ma_spinlock* pSpinlock); /* Unlocks a spinlock. */ MA_API ma_result ma_spinlock_unlock(volatile ma_spinlock* pSpinlock); #ifndef MA_NO_THREADING /* Creates a mutex. A mutex must be created from a valid context. A mutex is initially unlocked. */ MA_API ma_result ma_mutex_init(ma_mutex* pMutex); /* Deletes a mutex. */ MA_API void ma_mutex_uninit(ma_mutex* pMutex); /* Locks a mutex with an infinite timeout. */ MA_API void ma_mutex_lock(ma_mutex* pMutex); /* Unlocks a mutex. */ MA_API void ma_mutex_unlock(ma_mutex* pMutex); /* Initializes an auto-reset event. */ MA_API ma_result ma_event_init(ma_event* pEvent); /* Uninitializes an auto-reset event. */ MA_API void ma_event_uninit(ma_event* pEvent); /* Waits for the specified auto-reset event to become signalled. */ MA_API ma_result ma_event_wait(ma_event* pEvent); /* Signals the specified auto-reset event. */ MA_API ma_result ma_event_signal(ma_event* pEvent); #endif /* MA_NO_THREADING */ /* Fence ===== This locks while the counter is larger than 0. Counter can be incremented and decremented by any thread, but care needs to be taken when waiting. It is possible for one thread to acquire the fence just as another thread returns from ma_fence_wait(). The idea behind a fence is to allow you to wait for a group of operations to complete. When an operation starts, the counter is incremented which locks the fence. When the operation completes, the fence will be released which decrements the counter. ma_fence_wait() will block until the counter hits zero. If threading is disabled, ma_fence_wait() will spin on the counter. */ typedef struct { #ifndef MA_NO_THREADING ma_event e; #endif ma_uint32 counter; } ma_fence; MA_API ma_result ma_fence_init(ma_fence* pFence); MA_API void ma_fence_uninit(ma_fence* pFence); MA_API ma_result ma_fence_acquire(ma_fence* pFence); /* Increment counter. */ MA_API ma_result ma_fence_release(ma_fence* pFence); /* Decrement counter. */ MA_API ma_result ma_fence_wait(ma_fence* pFence); /* Wait for counter to reach 0. */ /* Notification callback for asynchronous operations. */ typedef void ma_async_notification; typedef struct { void (* onSignal)(ma_async_notification* pNotification); } ma_async_notification_callbacks; MA_API ma_result ma_async_notification_signal(ma_async_notification* pNotification); /* Simple polling notification. This just sets a variable when the notification has been signalled which is then polled with ma_async_notification_poll_is_signalled() */ typedef struct { ma_async_notification_callbacks cb; ma_bool32 signalled; } ma_async_notification_poll; MA_API ma_result ma_async_notification_poll_init(ma_async_notification_poll* pNotificationPoll); MA_API ma_bool32 ma_async_notification_poll_is_signalled(const ma_async_notification_poll* pNotificationPoll); /* Event Notification This uses an ma_event. If threading is disabled (MA_NO_THREADING), initialization will fail. */ typedef struct { ma_async_notification_callbacks cb; #ifndef MA_NO_THREADING ma_event e; #endif } ma_async_notification_event; MA_API ma_result ma_async_notification_event_init(ma_async_notification_event* pNotificationEvent); MA_API ma_result ma_async_notification_event_uninit(ma_async_notification_event* pNotificationEvent); MA_API ma_result ma_async_notification_event_wait(ma_async_notification_event* pNotificationEvent); MA_API ma_result ma_async_notification_event_signal(ma_async_notification_event* pNotificationEvent); /************************************************************************************************************************************************************ Job Queue ************************************************************************************************************************************************************/ /* Slot Allocator -------------- The idea of the slot allocator is for it to be used in conjunction with a fixed sized buffer. You use the slot allocator to allocator an index that can be used as the insertion point for an object. Slots are reference counted to help mitigate the ABA problem in the lock-free queue we use for tracking jobs. The slot index is stored in the low 32 bits. The reference counter is stored in the high 32 bits: +-----------------+-----------------+ | 32 Bits | 32 Bits | +-----------------+-----------------+ | Reference Count | Slot Index | +-----------------+-----------------+ */ typedef struct { ma_uint32 capacity; /* The number of slots to make available. */ } ma_slot_allocator_config; MA_API ma_slot_allocator_config ma_slot_allocator_config_init(ma_uint32 capacity); typedef struct { MA_ATOMIC(4, ma_uint32) bitfield; /* Must be used atomically because the allocation and freeing routines need to make copies of this which must never be optimized away by the compiler. */ } ma_slot_allocator_group; typedef struct { ma_slot_allocator_group* pGroups; /* Slots are grouped in chunks of 32. */ ma_uint32* pSlots; /* 32 bits for reference counting for ABA mitigation. */ ma_uint32 count; /* Allocation count. */ ma_uint32 capacity; /* Memory management. */ ma_bool32 _ownsHeap; void* _pHeap; } ma_slot_allocator; MA_API ma_result ma_slot_allocator_get_heap_size(const ma_slot_allocator_config* pConfig, size_t* pHeapSizeInBytes); MA_API ma_result ma_slot_allocator_init_preallocated(const ma_slot_allocator_config* pConfig, void* pHeap, ma_slot_allocator* pAllocator); MA_API ma_result ma_slot_allocator_init(const ma_slot_allocator_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_slot_allocator* pAllocator); MA_API void ma_slot_allocator_uninit(ma_slot_allocator* pAllocator, const ma_allocation_callbacks* pAllocationCallbacks); MA_API ma_result ma_slot_allocator_alloc(ma_slot_allocator* pAllocator, ma_uint64* pSlot); MA_API ma_result ma_slot_allocator_free(ma_slot_allocator* pAllocator, ma_uint64 slot); typedef struct ma_job ma_job; /* Callback for processing a job. Each job type will have their own processing callback which will be called by ma_job_process(). */ typedef ma_result (* ma_job_proc)(ma_job* pJob); /* When a job type is added here an callback needs to be added go "g_jobVTable" in the implementation section. */ typedef enum { /* Miscellaneous. */ MA_JOB_TYPE_QUIT = 0, MA_JOB_TYPE_CUSTOM, /* Resource Manager. */ MA_JOB_TYPE_RESOURCE_MANAGER_LOAD_DATA_BUFFER_NODE, MA_JOB_TYPE_RESOURCE_MANAGER_FREE_DATA_BUFFER_NODE, MA_JOB_TYPE_RESOURCE_MANAGER_PAGE_DATA_BUFFER_NODE, MA_JOB_TYPE_RESOURCE_MANAGER_LOAD_DATA_BUFFER, MA_JOB_TYPE_RESOURCE_MANAGER_FREE_DATA_BUFFER, MA_JOB_TYPE_RESOURCE_MANAGER_LOAD_DATA_STREAM, MA_JOB_TYPE_RESOURCE_MANAGER_FREE_DATA_STREAM, MA_JOB_TYPE_RESOURCE_MANAGER_PAGE_DATA_STREAM, MA_JOB_TYPE_RESOURCE_MANAGER_SEEK_DATA_STREAM, /* Device. */ MA_JOB_TYPE_DEVICE_AAUDIO_REROUTE, /* Count. Must always be last. */ MA_JOB_TYPE_COUNT } ma_job_type; struct ma_job { union { struct { ma_uint16 code; /* Job type. */ ma_uint16 slot; /* Index into a ma_slot_allocator. */ ma_uint32 refcount; } breakup; ma_uint64 allocation; } toc; /* 8 bytes. We encode the job code into the slot allocation data to save space. */ MA_ATOMIC(8, ma_uint64) next; /* refcount + slot for the next item. Does not include the job code. */ ma_uint32 order; /* Execution order. Used to create a data dependency and ensure a job is executed in order. Usage is contextual depending on the job type. */ union { /* Miscellaneous. */ struct { ma_job_proc proc; ma_uintptr data0; ma_uintptr data1; } custom; /* Resource Manager */ union { struct { /*ma_resource_manager**/ void* pResourceManager; /*ma_resource_manager_data_buffer_node**/ void* pDataBufferNode; char* pFilePath; wchar_t* pFilePathW; ma_uint32 flags; /* Resource manager data source flags that were used when initializing the data buffer. */ ma_async_notification* pInitNotification; /* Signalled when the data buffer has been initialized and the format/channels/rate can be retrieved. */ ma_async_notification* pDoneNotification; /* Signalled when the data buffer has been fully decoded. Will be passed through to MA_JOB_TYPE_RESOURCE_MANAGER_PAGE_DATA_BUFFER_NODE when decoding. */ ma_fence* pInitFence; /* Released when initialization of the decoder is complete. */ ma_fence* pDoneFence; /* Released if initialization of the decoder fails. Passed through to PAGE_DATA_BUFFER_NODE untouched if init is successful. */ } loadDataBufferNode; struct { /*ma_resource_manager**/ void* pResourceManager; /*ma_resource_manager_data_buffer_node**/ void* pDataBufferNode; ma_async_notification* pDoneNotification; ma_fence* pDoneFence; } freeDataBufferNode; struct { /*ma_resource_manager**/ void* pResourceManager; /*ma_resource_manager_data_buffer_node**/ void* pDataBufferNode; /*ma_decoder**/ void* pDecoder; ma_async_notification* pDoneNotification; /* Signalled when the data buffer has been fully decoded. */ ma_fence* pDoneFence; /* Passed through from LOAD_DATA_BUFFER_NODE and released when the data buffer completes decoding or an error occurs. */ } pageDataBufferNode; struct { /*ma_resource_manager_data_buffer**/ void* pDataBuffer; ma_async_notification* pInitNotification; /* Signalled when the data buffer has been initialized and the format/channels/rate can be retrieved. */ ma_async_notification* pDoneNotification; /* Signalled when the data buffer has been fully decoded. */ ma_fence* pInitFence; /* Released when the data buffer has been initialized and the format/channels/rate can be retrieved. */ ma_fence* pDoneFence; /* Released when the data buffer has been fully decoded. */ ma_uint64 rangeBegInPCMFrames; ma_uint64 rangeEndInPCMFrames; ma_uint64 loopPointBegInPCMFrames; ma_uint64 loopPointEndInPCMFrames; ma_uint32 isLooping; } loadDataBuffer; struct { /*ma_resource_manager_data_buffer**/ void* pDataBuffer; ma_async_notification* pDoneNotification; ma_fence* pDoneFence; } freeDataBuffer; struct { /*ma_resource_manager_data_stream**/ void* pDataStream; char* pFilePath; /* Allocated when the job is posted, freed by the job thread after loading. */ wchar_t* pFilePathW; /* ^ As above ^. Only used if pFilePath is NULL. */ ma_uint64 initialSeekPoint; ma_async_notification* pInitNotification; /* Signalled after the first two pages have been decoded and frames can be read from the stream. */ ma_fence* pInitFence; } loadDataStream; struct { /*ma_resource_manager_data_stream**/ void* pDataStream; ma_async_notification* pDoneNotification; ma_fence* pDoneFence; } freeDataStream; struct { /*ma_resource_manager_data_stream**/ void* pDataStream; ma_uint32 pageIndex; /* The index of the page to decode into. */ } pageDataStream; struct { /*ma_resource_manager_data_stream**/ void* pDataStream; ma_uint64 frameIndex; } seekDataStream; } resourceManager; /* Device. */ union { union { struct { /*ma_device**/ void* pDevice; /*ma_device_type*/ ma_uint32 deviceType; } reroute; } aaudio; } device; } data; }; MA_API ma_job ma_job_init(ma_uint16 code); MA_API ma_result ma_job_process(ma_job* pJob); /* When set, ma_job_queue_next() will not wait and no semaphore will be signaled in ma_job_queue_post(). ma_job_queue_next() will return MA_NO_DATA_AVAILABLE if nothing is available. This flag should always be used for platforms that do not support multithreading. */ typedef enum { MA_JOB_QUEUE_FLAG_NON_BLOCKING = 0x00000001 } ma_job_queue_flags; typedef struct { ma_uint32 flags; ma_uint32 capacity; /* The maximum number of jobs that can fit in the queue at a time. */ } ma_job_queue_config; MA_API ma_job_queue_config ma_job_queue_config_init(ma_uint32 flags, ma_uint32 capacity); typedef struct { ma_uint32 flags; /* Flags passed in at initialization time. */ ma_uint32 capacity; /* The maximum number of jobs that can fit in the queue at a time. Set by the config. */ MA_ATOMIC(8, ma_uint64) head; /* The first item in the list. Required for removing from the top of the list. */ MA_ATOMIC(8, ma_uint64) tail; /* The last item in the list. Required for appending to the end of the list. */ #ifndef MA_NO_THREADING ma_semaphore sem; /* Only used when MA_JOB_QUEUE_FLAG_NON_BLOCKING is unset. */ #endif ma_slot_allocator allocator; ma_job* pJobs; #ifndef MA_USE_EXPERIMENTAL_LOCK_FREE_JOB_QUEUE ma_spinlock lock; #endif /* Memory management. */ void* _pHeap; ma_bool32 _ownsHeap; } ma_job_queue; MA_API ma_result ma_job_queue_get_heap_size(const ma_job_queue_config* pConfig, size_t* pHeapSizeInBytes); MA_API ma_result ma_job_queue_init_preallocated(const ma_job_queue_config* pConfig, void* pHeap, ma_job_queue* pQueue); MA_API ma_result ma_job_queue_init(const ma_job_queue_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_job_queue* pQueue); MA_API void ma_job_queue_uninit(ma_job_queue* pQueue, const ma_allocation_callbacks* pAllocationCallbacks); MA_API ma_result ma_job_queue_post(ma_job_queue* pQueue, const ma_job* pJob); MA_API ma_result ma_job_queue_next(ma_job_queue* pQueue, ma_job* pJob); /* Returns MA_CANCELLED if the next job is a quit job. */ /************************************************************************************************************************************************************ ************************************************************************************************************************************************************* DEVICE I/O ========== This section contains the APIs for device playback and capture. Here is where you'll find ma_device_init(), etc. ************************************************************************************************************************************************************* ************************************************************************************************************************************************************/ #ifndef MA_NO_DEVICE_IO /* Some backends are only supported on certain platforms. */ #if defined(MA_WIN32) #define MA_SUPPORT_WASAPI #if defined(MA_WIN32_DESKTOP) /* DirectSound and WinMM backends are only supported on desktops. */ #define MA_SUPPORT_DSOUND #define MA_SUPPORT_WINMM /* Don't enable JACK here if compiling with Cosmopolitan. It'll be enabled in the Linux section below. */ #if !defined(__COSMOPOLITAN__) #define MA_SUPPORT_JACK /* JACK is technically supported on Windows, but I don't know how many people use it in practice... */ #endif #endif #endif #if defined(MA_UNIX) && !defined(MA_ORBIS) && !defined(MA_PROSPERO) #if defined(MA_LINUX) #if !defined(MA_ANDROID) && !defined(__COSMOPOLITAN__) /* ALSA is not supported on Android. */ #define MA_SUPPORT_ALSA #endif #endif #if !defined(MA_BSD) && !defined(MA_ANDROID) && !defined(MA_EMSCRIPTEN) #define MA_SUPPORT_PULSEAUDIO #define MA_SUPPORT_JACK #endif #if defined(__OpenBSD__) /* <-- Change this to "#if defined(MA_BSD)" to enable sndio on all BSD flavors. */ #define MA_SUPPORT_SNDIO /* sndio is only supported on OpenBSD for now. May be expanded later if there's demand. */ #endif #if defined(__NetBSD__) || defined(__OpenBSD__) #define MA_SUPPORT_AUDIO4 /* Only support audio(4) on platforms with known support. */ #endif #if defined(__FreeBSD__) || defined(__DragonFly__) #define MA_SUPPORT_OSS /* Only support OSS on specific platforms with known support. */ #endif #endif #if defined(MA_ANDROID) #define MA_SUPPORT_AAUDIO #define MA_SUPPORT_OPENSL #endif #if defined(MA_APPLE) #define MA_SUPPORT_COREAUDIO #endif #if defined(MA_EMSCRIPTEN) #define MA_SUPPORT_WEBAUDIO #endif /* All platforms should support custom backends. */ #define MA_SUPPORT_CUSTOM /* Explicitly disable the Null backend for Emscripten because it uses a background thread which is not properly supported right now. */ #if !defined(MA_EMSCRIPTEN) #define MA_SUPPORT_NULL #endif #if defined(MA_SUPPORT_WASAPI) && !defined(MA_NO_WASAPI) && (!defined(MA_ENABLE_ONLY_SPECIFIC_BACKENDS) || defined(MA_ENABLE_WASAPI)) #define MA_HAS_WASAPI #endif #if defined(MA_SUPPORT_DSOUND) && !defined(MA_NO_DSOUND) && (!defined(MA_ENABLE_ONLY_SPECIFIC_BACKENDS) || defined(MA_ENABLE_DSOUND)) #define MA_HAS_DSOUND #endif #if defined(MA_SUPPORT_WINMM) && !defined(MA_NO_WINMM) && (!defined(MA_ENABLE_ONLY_SPECIFIC_BACKENDS) || defined(MA_ENABLE_WINMM)) #define MA_HAS_WINMM #endif #if defined(MA_SUPPORT_ALSA) && !defined(MA_NO_ALSA) && (!defined(MA_ENABLE_ONLY_SPECIFIC_BACKENDS) || defined(MA_ENABLE_ALSA)) #define MA_HAS_ALSA #endif #if defined(MA_SUPPORT_PULSEAUDIO) && !defined(MA_NO_PULSEAUDIO) && (!defined(MA_ENABLE_ONLY_SPECIFIC_BACKENDS) || defined(MA_ENABLE_PULSEAUDIO)) #define MA_HAS_PULSEAUDIO #endif #if defined(MA_SUPPORT_JACK) && !defined(MA_NO_JACK) && (!defined(MA_ENABLE_ONLY_SPECIFIC_BACKENDS) || defined(MA_ENABLE_JACK)) #define MA_HAS_JACK #endif #if defined(MA_SUPPORT_COREAUDIO) && !defined(MA_NO_COREAUDIO) && (!defined(MA_ENABLE_ONLY_SPECIFIC_BACKENDS) || defined(MA_ENABLE_COREAUDIO)) #define MA_HAS_COREAUDIO #endif #if defined(MA_SUPPORT_SNDIO) && !defined(MA_NO_SNDIO) && (!defined(MA_ENABLE_ONLY_SPECIFIC_BACKENDS) || defined(MA_ENABLE_SNDIO)) #define MA_HAS_SNDIO #endif #if defined(MA_SUPPORT_AUDIO4) && !defined(MA_NO_AUDIO4) && (!defined(MA_ENABLE_ONLY_SPECIFIC_BACKENDS) || defined(MA_ENABLE_AUDIO4)) #define MA_HAS_AUDIO4 #endif #if defined(MA_SUPPORT_OSS) && !defined(MA_NO_OSS) && (!defined(MA_ENABLE_ONLY_SPECIFIC_BACKENDS) || defined(MA_ENABLE_OSS)) #define MA_HAS_OSS #endif #if defined(MA_SUPPORT_AAUDIO) && !defined(MA_NO_AAUDIO) && (!defined(MA_ENABLE_ONLY_SPECIFIC_BACKENDS) || defined(MA_ENABLE_AAUDIO)) #define MA_HAS_AAUDIO #endif #if defined(MA_SUPPORT_OPENSL) && !defined(MA_NO_OPENSL) && (!defined(MA_ENABLE_ONLY_SPECIFIC_BACKENDS) || defined(MA_ENABLE_OPENSL)) #define MA_HAS_OPENSL #endif #if defined(MA_SUPPORT_WEBAUDIO) && !defined(MA_NO_WEBAUDIO) && (!defined(MA_ENABLE_ONLY_SPECIFIC_BACKENDS) || defined(MA_ENABLE_WEBAUDIO)) #define MA_HAS_WEBAUDIO #endif #if defined(MA_SUPPORT_CUSTOM) && !defined(MA_NO_CUSTOM) && (!defined(MA_ENABLE_ONLY_SPECIFIC_BACKENDS) || defined(MA_ENABLE_CUSTOM)) #define MA_HAS_CUSTOM #endif #if defined(MA_SUPPORT_NULL) && !defined(MA_NO_NULL) && (!defined(MA_ENABLE_ONLY_SPECIFIC_BACKENDS) || defined(MA_ENABLE_NULL)) #define MA_HAS_NULL #endif typedef enum { ma_device_state_uninitialized = 0, ma_device_state_stopped = 1, /* The device's default state after initialization. */ ma_device_state_started = 2, /* The device is started and is requesting and/or delivering audio data. */ ma_device_state_starting = 3, /* Transitioning from a stopped state to started. */ ma_device_state_stopping = 4 /* Transitioning from a started state to stopped. */ } ma_device_state; MA_ATOMIC_SAFE_TYPE_DECL(i32, 4, device_state) #ifdef MA_SUPPORT_WASAPI /* We need a IMMNotificationClient object for WASAPI. */ typedef struct { void* lpVtbl; ma_uint32 counter; ma_device* pDevice; } ma_IMMNotificationClient; #endif /* Backend enums must be in priority order. */ typedef enum { ma_backend_wasapi, ma_backend_dsound, ma_backend_winmm, ma_backend_coreaudio, ma_backend_sndio, ma_backend_audio4, ma_backend_oss, ma_backend_pulseaudio, ma_backend_alsa, ma_backend_jack, ma_backend_aaudio, ma_backend_opensl, ma_backend_webaudio, ma_backend_custom, /* <-- Custom backend, with callbacks defined by the context config. */ ma_backend_null /* <-- Must always be the last item. Lowest priority, and used as the terminator for backend enumeration. */ } ma_backend; #define MA_BACKEND_COUNT (ma_backend_null+1) /* Device job thread. This is used by backends that require asynchronous processing of certain operations. It is not used by all backends. The device job thread is made up of a thread and a job queue. You can post a job to the thread with ma_device_job_thread_post(). The thread will do the processing of the job. */ typedef struct { ma_bool32 noThread; /* Set this to true if you want to process jobs yourself. */ ma_uint32 jobQueueCapacity; ma_uint32 jobQueueFlags; } ma_device_job_thread_config; MA_API ma_device_job_thread_config ma_device_job_thread_config_init(void); typedef struct { ma_thread thread; ma_job_queue jobQueue; ma_bool32 _hasThread; } ma_device_job_thread; MA_API ma_result ma_device_job_thread_init(const ma_device_job_thread_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_device_job_thread* pJobThread); MA_API void ma_device_job_thread_uninit(ma_device_job_thread* pJobThread, const ma_allocation_callbacks* pAllocationCallbacks); MA_API ma_result ma_device_job_thread_post(ma_device_job_thread* pJobThread, const ma_job* pJob); MA_API ma_result ma_device_job_thread_next(ma_device_job_thread* pJobThread, ma_job* pJob); /* Device notification types. */ typedef enum { ma_device_notification_type_started, ma_device_notification_type_stopped, ma_device_notification_type_rerouted, ma_device_notification_type_interruption_began, ma_device_notification_type_interruption_ended, ma_device_notification_type_unlocked } ma_device_notification_type; typedef struct { ma_device* pDevice; ma_device_notification_type type; union { struct { int _unused; } started; struct { int _unused; } stopped; struct { int _unused; } rerouted; struct { int _unused; } interruption; } data; } ma_device_notification; /* The notification callback for when the application should be notified of a change to the device. This callback is used for notifying the application of changes such as when the device has started, stopped, rerouted or an interruption has occurred. Note that not all backends will post all notification types. For example, some backends will perform automatic stream routing without any kind of notification to the host program which means miniaudio will never know about it and will never be able to fire the rerouted notification. You should keep this in mind when designing your program. The stopped notification will *not* get fired when a device is rerouted. Parameters ---------- pNotification (in) A pointer to a structure containing information about the event. Use the `pDevice` member of this object to retrieve the relevant device. The `type` member can be used to discriminate against each of the notification types. Remarks ------- Do not restart or uninitialize the device from the callback. Not all notifications will be triggered by all backends, however the started and stopped events should be reliable for all backends. Some backends do not have a good way to detect device stoppages due to unplugging the device which may result in the stopped callback not getting fired. This has been observed with at least one BSD variant. The rerouted notification is fired *after* the reroute has occurred. The stopped notification will *not* get fired when a device is rerouted. The following backends are known to do automatic stream rerouting, but do not have a way to be notified of the change: * DirectSound The interruption notifications are used on mobile platforms for detecting when audio is interrupted due to things like an incoming phone call. Currently this is only implemented on iOS. None of the Android backends will report this notification. */ typedef void (* ma_device_notification_proc)(const ma_device_notification* pNotification); /* The callback for processing audio data from the device. The data callback is fired by miniaudio whenever the device needs to have more data delivered to a playback device, or when a capture device has some data available. This is called as soon as the backend asks for more data which means it may be called with inconsistent frame counts. You cannot assume the callback will be fired with a consistent frame count. Parameters ---------- pDevice (in) A pointer to the relevant device. pOutput (out) A pointer to the output buffer that will receive audio data that will later be played back through the speakers. This will be non-null for a playback or full-duplex device and null for a capture and loopback device. pInput (in) A pointer to the buffer containing input data from a recording device. This will be non-null for a capture, full-duplex or loopback device and null for a playback device. frameCount (in) The number of PCM frames to process. Note that this will not necessarily be equal to what you requested when you initialized the device. The `periodSizeInFrames` and `periodSizeInMilliseconds` members of the device config are just hints, and are not necessarily exactly what you'll get. You must not assume this will always be the same value each time the callback is fired. Remarks ------- You cannot stop and start the device from inside the callback or else you'll get a deadlock. You must also not uninitialize the device from inside the callback. The following APIs cannot be called from inside the callback: ma_device_init() ma_device_init_ex() ma_device_uninit() ma_device_start() ma_device_stop() The proper way to stop the device is to call `ma_device_stop()` from a different thread, normally the main application thread. */ typedef void (* ma_device_data_proc)(ma_device* pDevice, void* pOutput, const void* pInput, ma_uint32 frameCount); /* DEPRECATED. Use ma_device_notification_proc instead. The callback for when the device has been stopped. This will be called when the device is stopped explicitly with `ma_device_stop()` and also called implicitly when the device is stopped through external forces such as being unplugged or an internal error occurring. Parameters ---------- pDevice (in) A pointer to the device that has just stopped. Remarks ------- Do not restart or uninitialize the device from the callback. */ typedef void (* ma_stop_proc)(ma_device* pDevice); /* DEPRECATED. Use ma_device_notification_proc instead. */ typedef enum { ma_device_type_playback = 1, ma_device_type_capture = 2, ma_device_type_duplex = ma_device_type_playback | ma_device_type_capture, /* 3 */ ma_device_type_loopback = 4 } ma_device_type; typedef enum { ma_share_mode_shared = 0, ma_share_mode_exclusive } ma_share_mode; /* iOS/tvOS/watchOS session categories. */ typedef enum { ma_ios_session_category_default = 0, /* AVAudioSessionCategoryPlayAndRecord. */ ma_ios_session_category_none, /* Leave the session category unchanged. */ ma_ios_session_category_ambient, /* AVAudioSessionCategoryAmbient */ ma_ios_session_category_solo_ambient, /* AVAudioSessionCategorySoloAmbient */ ma_ios_session_category_playback, /* AVAudioSessionCategoryPlayback */ ma_ios_session_category_record, /* AVAudioSessionCategoryRecord */ ma_ios_session_category_play_and_record, /* AVAudioSessionCategoryPlayAndRecord */ ma_ios_session_category_multi_route /* AVAudioSessionCategoryMultiRoute */ } ma_ios_session_category; /* iOS/tvOS/watchOS session category options */ typedef enum { ma_ios_session_category_option_mix_with_others = 0x01, /* AVAudioSessionCategoryOptionMixWithOthers */ ma_ios_session_category_option_duck_others = 0x02, /* AVAudioSessionCategoryOptionDuckOthers */ ma_ios_session_category_option_allow_bluetooth = 0x04, /* AVAudioSessionCategoryOptionAllowBluetooth */ ma_ios_session_category_option_default_to_speaker = 0x08, /* AVAudioSessionCategoryOptionDefaultToSpeaker */ ma_ios_session_category_option_interrupt_spoken_audio_and_mix_with_others = 0x11, /* AVAudioSessionCategoryOptionInterruptSpokenAudioAndMixWithOthers */ ma_ios_session_category_option_allow_bluetooth_a2dp = 0x20, /* AVAudioSessionCategoryOptionAllowBluetoothA2DP */ ma_ios_session_category_option_allow_air_play = 0x40, /* AVAudioSessionCategoryOptionAllowAirPlay */ } ma_ios_session_category_option; /* OpenSL stream types. */ typedef enum { ma_opensl_stream_type_default = 0, /* Leaves the stream type unset. */ ma_opensl_stream_type_voice, /* SL_ANDROID_STREAM_VOICE */ ma_opensl_stream_type_system, /* SL_ANDROID_STREAM_SYSTEM */ ma_opensl_stream_type_ring, /* SL_ANDROID_STREAM_RING */ ma_opensl_stream_type_media, /* SL_ANDROID_STREAM_MEDIA */ ma_opensl_stream_type_alarm, /* SL_ANDROID_STREAM_ALARM */ ma_opensl_stream_type_notification /* SL_ANDROID_STREAM_NOTIFICATION */ } ma_opensl_stream_type; /* OpenSL recording presets. */ typedef enum { ma_opensl_recording_preset_default = 0, /* Leaves the input preset unset. */ ma_opensl_recording_preset_generic, /* SL_ANDROID_RECORDING_PRESET_GENERIC */ ma_opensl_recording_preset_camcorder, /* SL_ANDROID_RECORDING_PRESET_CAMCORDER */ ma_opensl_recording_preset_voice_recognition, /* SL_ANDROID_RECORDING_PRESET_VOICE_RECOGNITION */ ma_opensl_recording_preset_voice_communication, /* SL_ANDROID_RECORDING_PRESET_VOICE_COMMUNICATION */ ma_opensl_recording_preset_voice_unprocessed /* SL_ANDROID_RECORDING_PRESET_UNPROCESSED */ } ma_opensl_recording_preset; /* WASAPI audio thread priority characteristics. */ typedef enum { ma_wasapi_usage_default = 0, ma_wasapi_usage_games, ma_wasapi_usage_pro_audio, } ma_wasapi_usage; /* AAudio usage types. */ typedef enum { ma_aaudio_usage_default = 0, /* Leaves the usage type unset. */ ma_aaudio_usage_media, /* AAUDIO_USAGE_MEDIA */ ma_aaudio_usage_voice_communication, /* AAUDIO_USAGE_VOICE_COMMUNICATION */ ma_aaudio_usage_voice_communication_signalling, /* AAUDIO_USAGE_VOICE_COMMUNICATION_SIGNALLING */ ma_aaudio_usage_alarm, /* AAUDIO_USAGE_ALARM */ ma_aaudio_usage_notification, /* AAUDIO_USAGE_NOTIFICATION */ ma_aaudio_usage_notification_ringtone, /* AAUDIO_USAGE_NOTIFICATION_RINGTONE */ ma_aaudio_usage_notification_event, /* AAUDIO_USAGE_NOTIFICATION_EVENT */ ma_aaudio_usage_assistance_accessibility, /* AAUDIO_USAGE_ASSISTANCE_ACCESSIBILITY */ ma_aaudio_usage_assistance_navigation_guidance, /* AAUDIO_USAGE_ASSISTANCE_NAVIGATION_GUIDANCE */ ma_aaudio_usage_assistance_sonification, /* AAUDIO_USAGE_ASSISTANCE_SONIFICATION */ ma_aaudio_usage_game, /* AAUDIO_USAGE_GAME */ ma_aaudio_usage_assitant, /* AAUDIO_USAGE_ASSISTANT */ ma_aaudio_usage_emergency, /* AAUDIO_SYSTEM_USAGE_EMERGENCY */ ma_aaudio_usage_safety, /* AAUDIO_SYSTEM_USAGE_SAFETY */ ma_aaudio_usage_vehicle_status, /* AAUDIO_SYSTEM_USAGE_VEHICLE_STATUS */ ma_aaudio_usage_announcement /* AAUDIO_SYSTEM_USAGE_ANNOUNCEMENT */ } ma_aaudio_usage; /* AAudio content types. */ typedef enum { ma_aaudio_content_type_default = 0, /* Leaves the content type unset. */ ma_aaudio_content_type_speech, /* AAUDIO_CONTENT_TYPE_SPEECH */ ma_aaudio_content_type_music, /* AAUDIO_CONTENT_TYPE_MUSIC */ ma_aaudio_content_type_movie, /* AAUDIO_CONTENT_TYPE_MOVIE */ ma_aaudio_content_type_sonification /* AAUDIO_CONTENT_TYPE_SONIFICATION */ } ma_aaudio_content_type; /* AAudio input presets. */ typedef enum { ma_aaudio_input_preset_default = 0, /* Leaves the input preset unset. */ ma_aaudio_input_preset_generic, /* AAUDIO_INPUT_PRESET_GENERIC */ ma_aaudio_input_preset_camcorder, /* AAUDIO_INPUT_PRESET_CAMCORDER */ ma_aaudio_input_preset_voice_recognition, /* AAUDIO_INPUT_PRESET_VOICE_RECOGNITION */ ma_aaudio_input_preset_voice_communication, /* AAUDIO_INPUT_PRESET_VOICE_COMMUNICATION */ ma_aaudio_input_preset_unprocessed, /* AAUDIO_INPUT_PRESET_UNPROCESSED */ ma_aaudio_input_preset_voice_performance /* AAUDIO_INPUT_PRESET_VOICE_PERFORMANCE */ } ma_aaudio_input_preset; typedef enum { ma_aaudio_allow_capture_default = 0, /* Leaves the allowed capture policy unset. */ ma_aaudio_allow_capture_by_all, /* AAUDIO_ALLOW_CAPTURE_BY_ALL */ ma_aaudio_allow_capture_by_system, /* AAUDIO_ALLOW_CAPTURE_BY_SYSTEM */ ma_aaudio_allow_capture_by_none /* AAUDIO_ALLOW_CAPTURE_BY_NONE */ } ma_aaudio_allowed_capture_policy; typedef union { ma_int64 counter; double counterD; } ma_timer; typedef union { ma_wchar_win32 wasapi[64]; /* WASAPI uses a wchar_t string for identification. */ ma_uint8 dsound[16]; /* DirectSound uses a GUID for identification. */ /*UINT_PTR*/ ma_uint32 winmm; /* When creating a device, WinMM expects a Win32 UINT_PTR for device identification. In practice it's actually just a UINT. */ char alsa[256]; /* ALSA uses a name string for identification. */ char pulse[256]; /* PulseAudio uses a name string for identification. */ int jack; /* JACK always uses default devices. */ char coreaudio[256]; /* Core Audio uses a string for identification. */ char sndio[256]; /* "snd/0", etc. */ char audio4[256]; /* "/dev/audio", etc. */ char oss[64]; /* "dev/dsp0", etc. "dev/dsp" for the default device. */ ma_int32 aaudio; /* AAudio uses a 32-bit integer for identification. */ ma_uint32 opensl; /* OpenSL|ES uses a 32-bit unsigned integer for identification. */ char webaudio[32]; /* Web Audio always uses default devices for now, but if this changes it'll be a GUID. */ union { int i; char s[256]; void* p; } custom; /* The custom backend could be anything. Give them a few options. */ int nullbackend; /* The null backend uses an integer for device IDs. */ } ma_device_id; typedef struct ma_context_config ma_context_config; typedef struct ma_device_config ma_device_config; typedef struct ma_backend_callbacks ma_backend_callbacks; #define MA_DATA_FORMAT_FLAG_EXCLUSIVE_MODE (1U << 1) /* If set, this is supported in exclusive mode. Otherwise not natively supported by exclusive mode. */ #ifndef MA_MAX_DEVICE_NAME_LENGTH #define MA_MAX_DEVICE_NAME_LENGTH 255 #endif typedef struct { /* Basic info. This is the only information guaranteed to be filled in during device enumeration. */ ma_device_id id; char name[MA_MAX_DEVICE_NAME_LENGTH + 1]; /* +1 for null terminator. */ ma_bool32 isDefault; ma_uint32 nativeDataFormatCount; struct { ma_format format; /* Sample format. If set to ma_format_unknown, all sample formats are supported. */ ma_uint32 channels; /* If set to 0, all channels are supported. */ ma_uint32 sampleRate; /* If set to 0, all sample rates are supported. */ ma_uint32 flags; /* A combination of MA_DATA_FORMAT_FLAG_* flags. */ } nativeDataFormats[/*ma_format_count * ma_standard_sample_rate_count * MA_MAX_CHANNELS*/ 64]; /* Not sure how big to make this. There can be *many* permutations for virtual devices which can support anything. */ } ma_device_info; struct ma_device_config { ma_device_type deviceType; ma_uint32 sampleRate; ma_uint32 periodSizeInFrames; ma_uint32 periodSizeInMilliseconds; ma_uint32 periods; ma_performance_profile performanceProfile; ma_bool8 noPreSilencedOutputBuffer; /* When set to true, the contents of the output buffer passed into the data callback will be left undefined rather than initialized to silence. */ ma_bool8 noClip; /* When set to true, the contents of the output buffer passed into the data callback will not be clipped after returning. Only applies when the playback sample format is f32. */ ma_bool8 noDisableDenormals; /* Do not disable denormals when firing the data callback. */ ma_bool8 noFixedSizedCallback; /* Disables strict fixed-sized data callbacks. Setting this to true will result in the period size being treated only as a hint to the backend. This is an optimization for those who don't need fixed sized callbacks. */ ma_device_data_proc dataCallback; ma_device_notification_proc notificationCallback; ma_stop_proc stopCallback; void* pUserData; ma_resampler_config resampling; struct { const ma_device_id* pDeviceID; ma_format format; ma_uint32 channels; ma_channel* pChannelMap; ma_channel_mix_mode channelMixMode; ma_bool32 calculateLFEFromSpatialChannels; /* When an output LFE channel is present, but no input LFE, set to true to set the output LFE to the average of all spatial channels (LR, FR, etc.). Ignored when an input LFE is present. */ ma_share_mode shareMode; } playback; struct { const ma_device_id* pDeviceID; ma_format format; ma_uint32 channels; ma_channel* pChannelMap; ma_channel_mix_mode channelMixMode; ma_bool32 calculateLFEFromSpatialChannels; /* When an output LFE channel is present, but no input LFE, set to true to set the output LFE to the average of all spatial channels (LR, FR, etc.). Ignored when an input LFE is present. */ ma_share_mode shareMode; } capture; struct { ma_wasapi_usage usage; /* When configured, uses Avrt APIs to set the thread characteristics. */ ma_bool8 noAutoConvertSRC; /* When set to true, disables the use of AUDCLNT_STREAMFLAGS_AUTOCONVERTPCM. */ ma_bool8 noDefaultQualitySRC; /* When set to true, disables the use of AUDCLNT_STREAMFLAGS_SRC_DEFAULT_QUALITY. */ ma_bool8 noAutoStreamRouting; /* Disables automatic stream routing. */ ma_bool8 noHardwareOffloading; /* Disables WASAPI's hardware offloading feature. */ ma_uint32 loopbackProcessID; /* The process ID to include or exclude for loopback mode. Set to 0 to capture audio from all processes. Ignored when an explicit device ID is specified. */ ma_bool8 loopbackProcessExclude; /* When set to true, excludes the process specified by loopbackProcessID. By default, the process will be included. */ } wasapi; struct { ma_bool32 noMMap; /* Disables MMap mode. */ ma_bool32 noAutoFormat; /* Opens the ALSA device with SND_PCM_NO_AUTO_FORMAT. */ ma_bool32 noAutoChannels; /* Opens the ALSA device with SND_PCM_NO_AUTO_CHANNELS. */ ma_bool32 noAutoResample; /* Opens the ALSA device with SND_PCM_NO_AUTO_RESAMPLE. */ } alsa; struct { const char* pStreamNamePlayback; const char* pStreamNameCapture; } pulse; struct { ma_bool32 allowNominalSampleRateChange; /* Desktop only. When enabled, allows changing of the sample rate at the operating system level. */ } coreaudio; struct { ma_opensl_stream_type streamType; ma_opensl_recording_preset recordingPreset; ma_bool32 enableCompatibilityWorkarounds; } opensl; struct { ma_aaudio_usage usage; ma_aaudio_content_type contentType; ma_aaudio_input_preset inputPreset; ma_aaudio_allowed_capture_policy allowedCapturePolicy; ma_bool32 noAutoStartAfterReroute; ma_bool32 enableCompatibilityWorkarounds; } aaudio; }; /* The callback for handling device enumeration. This is fired from `ma_context_enumerate_devices()`. Parameters ---------- pContext (in) A pointer to the context performing the enumeration. deviceType (in) The type of the device being enumerated. This will always be either `ma_device_type_playback` or `ma_device_type_capture`. pInfo (in) A pointer to a `ma_device_info` containing the ID and name of the enumerated device. Note that this will not include detailed information about the device, only basic information (ID and name). The reason for this is that it would otherwise require opening the backend device to probe for the information which is too inefficient. pUserData (in) The user data pointer passed into `ma_context_enumerate_devices()`. */ typedef ma_bool32 (* ma_enum_devices_callback_proc)(ma_context* pContext, ma_device_type deviceType, const ma_device_info* pInfo, void* pUserData); /* Describes some basic details about a playback or capture device. */ typedef struct { const ma_device_id* pDeviceID; ma_share_mode shareMode; ma_format format; ma_uint32 channels; ma_uint32 sampleRate; ma_channel channelMap[MA_MAX_CHANNELS]; ma_uint32 periodSizeInFrames; ma_uint32 periodSizeInMilliseconds; ma_uint32 periodCount; } ma_device_descriptor; /* These are the callbacks required to be implemented for a backend. These callbacks are grouped into two parts: context and device. There is one context to many devices. A device is created from a context. The general flow goes like this: 1) A context is created with `onContextInit()` 1a) Available devices can be enumerated with `onContextEnumerateDevices()` if required. 1b) Detailed information about a device can be queried with `onContextGetDeviceInfo()` if required. 2) A device is created from the context that was created in the first step using `onDeviceInit()`, and optionally a device ID that was selected from device enumeration via `onContextEnumerateDevices()`. 3) A device is started or stopped with `onDeviceStart()` / `onDeviceStop()` 4) Data is delivered to and from the device by the backend. This is always done based on the native format returned by the prior call to `onDeviceInit()`. Conversion between the device's native format and the format requested by the application will be handled by miniaudio internally. Initialization of the context is quite simple. You need to do any necessary initialization of internal objects and then output the callbacks defined in this structure. Once the context has been initialized you can initialize a device. Before doing so, however, the application may want to know which physical devices are available. This is where `onContextEnumerateDevices()` comes in. This is fairly simple. For each device, fire the given callback with, at a minimum, the basic information filled out in `ma_device_info`. When the callback returns `MA_FALSE`, enumeration needs to stop and the `onContextEnumerateDevices()` function returns with a success code. Detailed device information can be retrieved from a device ID using `onContextGetDeviceInfo()`. This takes as input the device type and ID, and on output returns detailed information about the device in `ma_device_info`. The `onContextGetDeviceInfo()` callback must handle the case when the device ID is NULL, in which case information about the default device needs to be retrieved. Once the context has been created and the device ID retrieved (if using anything other than the default device), the device can be created. This is a little bit more complicated than initialization of the context due to it's more complicated configuration. When initializing a device, a duplex device may be requested. This means a separate data format needs to be specified for both playback and capture. On input, the data format is set to what the application wants. On output it's set to the native format which should match as closely as possible to the requested format. The conversion between the format requested by the application and the device's native format will be handled internally by miniaudio. On input, if the sample format is set to `ma_format_unknown`, the backend is free to use whatever sample format it desires, so long as it's supported by miniaudio. When the channel count is set to 0, the backend should use the device's native channel count. The same applies for sample rate. For the channel map, the default should be used when `ma_channel_map_is_blank()` returns true (all channels set to `MA_CHANNEL_NONE`). On input, the `periodSizeInFrames` or `periodSizeInMilliseconds` option should always be set. The backend should inspect both of these variables. If `periodSizeInFrames` is set, it should take priority, otherwise it needs to be derived from the period size in milliseconds (`periodSizeInMilliseconds`) and the sample rate, keeping in mind that the sample rate may be 0, in which case the sample rate will need to be determined before calculating the period size in frames. On output, all members of the `ma_device_descriptor` object should be set to a valid value, except for `periodSizeInMilliseconds` which is optional (`periodSizeInFrames` *must* be set). Starting and stopping of the device is done with `onDeviceStart()` and `onDeviceStop()` and should be self-explanatory. If the backend uses asynchronous reading and writing, `onDeviceStart()` and `onDeviceStop()` should always be implemented. The handling of data delivery between the application and the device is the most complicated part of the process. To make this a bit easier, some helper callbacks are available. If the backend uses a blocking read/write style of API, the `onDeviceRead()` and `onDeviceWrite()` callbacks can optionally be implemented. These are blocking and work just like reading and writing from a file. If the backend uses a callback for data delivery, that callback must call `ma_device_handle_backend_data_callback()` from within it's callback. This allows miniaudio to then process any necessary data conversion and then pass it to the miniaudio data callback. If the backend requires absolute flexibility with it's data delivery, it can optionally implement the `onDeviceDataLoop()` callback which will allow it to implement the logic that will run on the audio thread. This is much more advanced and is completely optional. The audio thread should run data delivery logic in a loop while `ma_device_get_state() == ma_device_state_started` and no errors have been encountered. Do not start or stop the device here. That will be handled from outside the `onDeviceDataLoop()` callback. The invocation of the `onDeviceDataLoop()` callback will be handled by miniaudio. When you start the device, miniaudio will fire this callback. When the device is stopped, the `ma_device_get_state() == ma_device_state_started` condition will fail and the loop will be terminated which will then fall through to the part that stops the device. For an example on how to implement the `onDeviceDataLoop()` callback, look at `ma_device_audio_thread__default_read_write()`. Implement the `onDeviceDataLoopWakeup()` callback if you need a mechanism to wake up the audio thread. If the backend supports an optimized retrieval of device information from an initialized `ma_device` object, it should implement the `onDeviceGetInfo()` callback. This is optional, in which case it will fall back to `onContextGetDeviceInfo()` which is less efficient. */ struct ma_backend_callbacks { ma_result (* onContextInit)(ma_context* pContext, const ma_context_config* pConfig, ma_backend_callbacks* pCallbacks); ma_result (* onContextUninit)(ma_context* pContext); ma_result (* onContextEnumerateDevices)(ma_context* pContext, ma_enum_devices_callback_proc callback, void* pUserData); ma_result (* onContextGetDeviceInfo)(ma_context* pContext, ma_device_type deviceType, const ma_device_id* pDeviceID, ma_device_info* pDeviceInfo); ma_result (* onDeviceInit)(ma_device* pDevice, const ma_device_config* pConfig, ma_device_descriptor* pDescriptorPlayback, ma_device_descriptor* pDescriptorCapture); ma_result (* onDeviceUninit)(ma_device* pDevice); ma_result (* onDeviceStart)(ma_device* pDevice); ma_result (* onDeviceStop)(ma_device* pDevice); ma_result (* onDeviceRead)(ma_device* pDevice, void* pFrames, ma_uint32 frameCount, ma_uint32* pFramesRead); ma_result (* onDeviceWrite)(ma_device* pDevice, const void* pFrames, ma_uint32 frameCount, ma_uint32* pFramesWritten); ma_result (* onDeviceDataLoop)(ma_device* pDevice); ma_result (* onDeviceDataLoopWakeup)(ma_device* pDevice); ma_result (* onDeviceGetInfo)(ma_device* pDevice, ma_device_type type, ma_device_info* pDeviceInfo); }; struct ma_context_config { ma_log* pLog; ma_thread_priority threadPriority; size_t threadStackSize; void* pUserData; ma_allocation_callbacks allocationCallbacks; struct { ma_bool32 useVerboseDeviceEnumeration; } alsa; struct { const char* pApplicationName; const char* pServerName; ma_bool32 tryAutoSpawn; /* Enables autospawning of the PulseAudio daemon if necessary. */ } pulse; struct { ma_ios_session_category sessionCategory; ma_uint32 sessionCategoryOptions; ma_bool32 noAudioSessionActivate; /* iOS only. When set to true, does not perform an explicit [[AVAudioSession sharedInstace] setActive:true] on initialization. */ ma_bool32 noAudioSessionDeactivate; /* iOS only. When set to true, does not perform an explicit [[AVAudioSession sharedInstace] setActive:false] on uninitialization. */ } coreaudio; struct { const char* pClientName; ma_bool32 tryStartServer; } jack; ma_backend_callbacks custom; }; /* WASAPI specific structure for some commands which must run on a common thread due to bugs in WASAPI. */ typedef struct { int code; ma_event* pEvent; /* This will be signalled when the event is complete. */ union { struct { int _unused; } quit; struct { ma_device_type deviceType; void* pAudioClient; void** ppAudioClientService; ma_result* pResult; /* The result from creating the audio client service. */ } createAudioClient; struct { ma_device* pDevice; ma_device_type deviceType; } releaseAudioClient; } data; } ma_context_command__wasapi; struct ma_context { ma_backend_callbacks callbacks; ma_backend backend; /* DirectSound, ALSA, etc. */ ma_log* pLog; ma_log log; /* Only used if the log is owned by the context. The pLog member will be set to &log in this case. */ ma_thread_priority threadPriority; size_t threadStackSize; void* pUserData; ma_allocation_callbacks allocationCallbacks; ma_mutex deviceEnumLock; /* Used to make ma_context_get_devices() thread safe. */ ma_mutex deviceInfoLock; /* Used to make ma_context_get_device_info() thread safe. */ ma_uint32 deviceInfoCapacity; /* Total capacity of pDeviceInfos. */ ma_uint32 playbackDeviceInfoCount; ma_uint32 captureDeviceInfoCount; ma_device_info* pDeviceInfos; /* Playback devices first, then capture. */ union { #ifdef MA_SUPPORT_WASAPI struct { ma_thread commandThread; ma_mutex commandLock; ma_semaphore commandSem; ma_uint32 commandIndex; ma_uint32 commandCount; ma_context_command__wasapi commands[4]; ma_handle hAvrt; ma_proc AvSetMmThreadCharacteristicsA; ma_proc AvRevertMmThreadcharacteristics; ma_handle hMMDevapi; ma_proc ActivateAudioInterfaceAsync; } wasapi; #endif #ifdef MA_SUPPORT_DSOUND struct { ma_handle hDSoundDLL; ma_proc DirectSoundCreate; ma_proc DirectSoundEnumerateA; ma_proc DirectSoundCaptureCreate; ma_proc DirectSoundCaptureEnumerateA; } dsound; #endif #ifdef MA_SUPPORT_WINMM struct { ma_handle hWinMM; ma_proc waveOutGetNumDevs; ma_proc waveOutGetDevCapsA; ma_proc waveOutOpen; ma_proc waveOutClose; ma_proc waveOutPrepareHeader; ma_proc waveOutUnprepareHeader; ma_proc waveOutWrite; ma_proc waveOutReset; ma_proc waveInGetNumDevs; ma_proc waveInGetDevCapsA; ma_proc waveInOpen; ma_proc waveInClose; ma_proc waveInPrepareHeader; ma_proc waveInUnprepareHeader; ma_proc waveInAddBuffer; ma_proc waveInStart; ma_proc waveInReset; } winmm; #endif #ifdef MA_SUPPORT_ALSA struct { ma_handle asoundSO; ma_proc snd_pcm_open; ma_proc snd_pcm_close; ma_proc snd_pcm_hw_params_sizeof; ma_proc snd_pcm_hw_params_any; ma_proc snd_pcm_hw_params_set_format; ma_proc snd_pcm_hw_params_set_format_first; ma_proc snd_pcm_hw_params_get_format_mask; ma_proc snd_pcm_hw_params_set_channels; ma_proc snd_pcm_hw_params_set_channels_near; ma_proc snd_pcm_hw_params_set_channels_minmax; ma_proc snd_pcm_hw_params_set_rate_resample; ma_proc snd_pcm_hw_params_set_rate; ma_proc snd_pcm_hw_params_set_rate_near; ma_proc snd_pcm_hw_params_set_buffer_size_near; ma_proc snd_pcm_hw_params_set_periods_near; ma_proc snd_pcm_hw_params_set_access; ma_proc snd_pcm_hw_params_get_format; ma_proc snd_pcm_hw_params_get_channels; ma_proc snd_pcm_hw_params_get_channels_min; ma_proc snd_pcm_hw_params_get_channels_max; ma_proc snd_pcm_hw_params_get_rate; ma_proc snd_pcm_hw_params_get_rate_min; ma_proc snd_pcm_hw_params_get_rate_max; ma_proc snd_pcm_hw_params_get_buffer_size; ma_proc snd_pcm_hw_params_get_periods; ma_proc snd_pcm_hw_params_get_access; ma_proc snd_pcm_hw_params_test_format; ma_proc snd_pcm_hw_params_test_channels; ma_proc snd_pcm_hw_params_test_rate; ma_proc snd_pcm_hw_params; ma_proc snd_pcm_sw_params_sizeof; ma_proc snd_pcm_sw_params_current; ma_proc snd_pcm_sw_params_get_boundary; ma_proc snd_pcm_sw_params_set_avail_min; ma_proc snd_pcm_sw_params_set_start_threshold; ma_proc snd_pcm_sw_params_set_stop_threshold; ma_proc snd_pcm_sw_params; ma_proc snd_pcm_format_mask_sizeof; ma_proc snd_pcm_format_mask_test; ma_proc snd_pcm_get_chmap; ma_proc snd_pcm_state; ma_proc snd_pcm_prepare; ma_proc snd_pcm_start; ma_proc snd_pcm_drop; ma_proc snd_pcm_drain; ma_proc snd_pcm_reset; ma_proc snd_device_name_hint; ma_proc snd_device_name_get_hint; ma_proc snd_card_get_index; ma_proc snd_device_name_free_hint; ma_proc snd_pcm_mmap_begin; ma_proc snd_pcm_mmap_commit; ma_proc snd_pcm_recover; ma_proc snd_pcm_readi; ma_proc snd_pcm_writei; ma_proc snd_pcm_avail; ma_proc snd_pcm_avail_update; ma_proc snd_pcm_wait; ma_proc snd_pcm_nonblock; ma_proc snd_pcm_info; ma_proc snd_pcm_info_sizeof; ma_proc snd_pcm_info_get_name; ma_proc snd_pcm_poll_descriptors; ma_proc snd_pcm_poll_descriptors_count; ma_proc snd_pcm_poll_descriptors_revents; ma_proc snd_config_update_free_global; ma_mutex internalDeviceEnumLock; ma_bool32 useVerboseDeviceEnumeration; } alsa; #endif #ifdef MA_SUPPORT_PULSEAUDIO struct { ma_handle pulseSO; ma_proc pa_mainloop_new; ma_proc pa_mainloop_free; ma_proc pa_mainloop_quit; ma_proc pa_mainloop_get_api; ma_proc pa_mainloop_iterate; ma_proc pa_mainloop_wakeup; ma_proc pa_threaded_mainloop_new; ma_proc pa_threaded_mainloop_free; ma_proc pa_threaded_mainloop_start; ma_proc pa_threaded_mainloop_stop; ma_proc pa_threaded_mainloop_lock; ma_proc pa_threaded_mainloop_unlock; ma_proc pa_threaded_mainloop_wait; ma_proc pa_threaded_mainloop_signal; ma_proc pa_threaded_mainloop_accept; ma_proc pa_threaded_mainloop_get_retval; ma_proc pa_threaded_mainloop_get_api; ma_proc pa_threaded_mainloop_in_thread; ma_proc pa_threaded_mainloop_set_name; ma_proc pa_context_new; ma_proc pa_context_unref; ma_proc pa_context_connect; ma_proc pa_context_disconnect; ma_proc pa_context_set_state_callback; ma_proc pa_context_get_state; ma_proc pa_context_get_sink_info_list; ma_proc pa_context_get_source_info_list; ma_proc pa_context_get_sink_info_by_name; ma_proc pa_context_get_source_info_by_name; ma_proc pa_operation_unref; ma_proc pa_operation_get_state; ma_proc pa_channel_map_init_extend; ma_proc pa_channel_map_valid; ma_proc pa_channel_map_compatible; ma_proc pa_stream_new; ma_proc pa_stream_unref; ma_proc pa_stream_connect_playback; ma_proc pa_stream_connect_record; ma_proc pa_stream_disconnect; ma_proc pa_stream_get_state; ma_proc pa_stream_get_sample_spec; ma_proc pa_stream_get_channel_map; ma_proc pa_stream_get_buffer_attr; ma_proc pa_stream_set_buffer_attr; ma_proc pa_stream_get_device_name; ma_proc pa_stream_set_write_callback; ma_proc pa_stream_set_read_callback; ma_proc pa_stream_set_suspended_callback; ma_proc pa_stream_set_moved_callback; ma_proc pa_stream_is_suspended; ma_proc pa_stream_flush; ma_proc pa_stream_drain; ma_proc pa_stream_is_corked; ma_proc pa_stream_cork; ma_proc pa_stream_trigger; ma_proc pa_stream_begin_write; ma_proc pa_stream_write; ma_proc pa_stream_peek; ma_proc pa_stream_drop; ma_proc pa_stream_writable_size; ma_proc pa_stream_readable_size; /*pa_mainloop**/ ma_ptr pMainLoop; /*pa_context**/ ma_ptr pPulseContext; char* pApplicationName; /* Set when the context is initialized. Used by devices for their local pa_context objects. */ char* pServerName; /* Set when the context is initialized. Used by devices for their local pa_context objects. */ } pulse; #endif #ifdef MA_SUPPORT_JACK struct { ma_handle jackSO; ma_proc jack_client_open; ma_proc jack_client_close; ma_proc jack_client_name_size; ma_proc jack_set_process_callback; ma_proc jack_set_buffer_size_callback; ma_proc jack_on_shutdown; ma_proc jack_get_sample_rate; ma_proc jack_get_buffer_size; ma_proc jack_get_ports; ma_proc jack_activate; ma_proc jack_deactivate; ma_proc jack_connect; ma_proc jack_port_register; ma_proc jack_port_name; ma_proc jack_port_get_buffer; ma_proc jack_free; char* pClientName; ma_bool32 tryStartServer; } jack; #endif #ifdef MA_SUPPORT_COREAUDIO struct { ma_handle hCoreFoundation; ma_proc CFStringGetCString; ma_proc CFRelease; ma_handle hCoreAudio; ma_proc AudioObjectGetPropertyData; ma_proc AudioObjectGetPropertyDataSize; ma_proc AudioObjectSetPropertyData; ma_proc AudioObjectAddPropertyListener; ma_proc AudioObjectRemovePropertyListener; ma_handle hAudioUnit; /* Could possibly be set to AudioToolbox on later versions of macOS. */ ma_proc AudioComponentFindNext; ma_proc AudioComponentInstanceDispose; ma_proc AudioComponentInstanceNew; ma_proc AudioOutputUnitStart; ma_proc AudioOutputUnitStop; ma_proc AudioUnitAddPropertyListener; ma_proc AudioUnitGetPropertyInfo; ma_proc AudioUnitGetProperty; ma_proc AudioUnitSetProperty; ma_proc AudioUnitInitialize; ma_proc AudioUnitRender; /*AudioComponent*/ ma_ptr component; ma_bool32 noAudioSessionDeactivate; /* For tracking whether or not the iOS audio session should be explicitly deactivated. Set from the config in ma_context_init__coreaudio(). */ } coreaudio; #endif #ifdef MA_SUPPORT_SNDIO struct { ma_handle sndioSO; ma_proc sio_open; ma_proc sio_close; ma_proc sio_setpar; ma_proc sio_getpar; ma_proc sio_getcap; ma_proc sio_start; ma_proc sio_stop; ma_proc sio_read; ma_proc sio_write; ma_proc sio_onmove; ma_proc sio_nfds; ma_proc sio_pollfd; ma_proc sio_revents; ma_proc sio_eof; ma_proc sio_setvol; ma_proc sio_onvol; ma_proc sio_initpar; } sndio; #endif #ifdef MA_SUPPORT_AUDIO4 struct { int _unused; } audio4; #endif #ifdef MA_SUPPORT_OSS struct { int versionMajor; int versionMinor; } oss; #endif #ifdef MA_SUPPORT_AAUDIO struct { ma_handle hAAudio; /* libaaudio.so */ ma_proc AAudio_createStreamBuilder; ma_proc AAudioStreamBuilder_delete; ma_proc AAudioStreamBuilder_setDeviceId; ma_proc AAudioStreamBuilder_setDirection; ma_proc AAudioStreamBuilder_setSharingMode; ma_proc AAudioStreamBuilder_setFormat; ma_proc AAudioStreamBuilder_setChannelCount; ma_proc AAudioStreamBuilder_setSampleRate; ma_proc AAudioStreamBuilder_setBufferCapacityInFrames; ma_proc AAudioStreamBuilder_setFramesPerDataCallback; ma_proc AAudioStreamBuilder_setDataCallback; ma_proc AAudioStreamBuilder_setErrorCallback; ma_proc AAudioStreamBuilder_setPerformanceMode; ma_proc AAudioStreamBuilder_setUsage; ma_proc AAudioStreamBuilder_setContentType; ma_proc AAudioStreamBuilder_setInputPreset; ma_proc AAudioStreamBuilder_setAllowedCapturePolicy; ma_proc AAudioStreamBuilder_openStream; ma_proc AAudioStream_close; ma_proc AAudioStream_getState; ma_proc AAudioStream_waitForStateChange; ma_proc AAudioStream_getFormat; ma_proc AAudioStream_getChannelCount; ma_proc AAudioStream_getSampleRate; ma_proc AAudioStream_getBufferCapacityInFrames; ma_proc AAudioStream_getFramesPerDataCallback; ma_proc AAudioStream_getFramesPerBurst; ma_proc AAudioStream_requestStart; ma_proc AAudioStream_requestStop; ma_device_job_thread jobThread; /* For processing operations outside of the error callback, specifically device disconnections and rerouting. */ } aaudio; #endif #ifdef MA_SUPPORT_OPENSL struct { ma_handle libOpenSLES; ma_handle SL_IID_ENGINE; ma_handle SL_IID_AUDIOIODEVICECAPABILITIES; ma_handle SL_IID_ANDROIDSIMPLEBUFFERQUEUE; ma_handle SL_IID_RECORD; ma_handle SL_IID_PLAY; ma_handle SL_IID_OUTPUTMIX; ma_handle SL_IID_ANDROIDCONFIGURATION; ma_proc slCreateEngine; } opensl; #endif #ifdef MA_SUPPORT_WEBAUDIO struct { int _unused; } webaudio; #endif #ifdef MA_SUPPORT_NULL struct { int _unused; } null_backend; #endif }; union { #if defined(MA_WIN32) struct { /*HMODULE*/ ma_handle hOle32DLL; ma_proc CoInitialize; ma_proc CoInitializeEx; ma_proc CoUninitialize; ma_proc CoCreateInstance; ma_proc CoTaskMemFree; ma_proc PropVariantClear; ma_proc StringFromGUID2; /*HMODULE*/ ma_handle hUser32DLL; ma_proc GetForegroundWindow; ma_proc GetDesktopWindow; /*HMODULE*/ ma_handle hAdvapi32DLL; ma_proc RegOpenKeyExA; ma_proc RegCloseKey; ma_proc RegQueryValueExA; /*HRESULT*/ long CoInitializeResult; } win32; #endif #ifdef MA_POSIX struct { int _unused; } posix; #endif int _unused; }; }; struct ma_device { ma_context* pContext; ma_device_type type; ma_uint32 sampleRate; ma_atomic_device_state state; /* The state of the device is variable and can change at any time on any thread. Must be used atomically. */ ma_device_data_proc onData; /* Set once at initialization time and should not be changed after. */ ma_device_notification_proc onNotification; /* Set once at initialization time and should not be changed after. */ ma_stop_proc onStop; /* DEPRECATED. Use the notification callback instead. Set once at initialization time and should not be changed after. */ void* pUserData; /* Application defined data. */ ma_mutex startStopLock; ma_event wakeupEvent; ma_event startEvent; ma_event stopEvent; ma_thread thread; ma_result workResult; /* This is set by the worker thread after it's finished doing a job. */ ma_bool8 isOwnerOfContext; /* When set to true, uninitializing the device will also uninitialize the context. Set to true when NULL is passed into ma_device_init(). */ ma_bool8 noPreSilencedOutputBuffer; ma_bool8 noClip; ma_bool8 noDisableDenormals; ma_bool8 noFixedSizedCallback; ma_atomic_float masterVolumeFactor; /* Linear 0..1. Can be read and written simultaneously by different threads. Must be used atomically. */ ma_duplex_rb duplexRB; /* Intermediary buffer for duplex device on asynchronous backends. */ struct { ma_resample_algorithm algorithm; ma_resampling_backend_vtable* pBackendVTable; void* pBackendUserData; struct { ma_uint32 lpfOrder; } linear; } resampling; struct { ma_device_id* pID; /* Set to NULL if using default ID, otherwise set to the address of "id". */ ma_device_id id; /* If using an explicit device, will be set to a copy of the ID used for initialization. Otherwise cleared to 0. */ char name[MA_MAX_DEVICE_NAME_LENGTH + 1]; /* Maybe temporary. Likely to be replaced with a query API. */ ma_share_mode shareMode; /* Set to whatever was passed in when the device was initialized. */ ma_format format; ma_uint32 channels; ma_channel channelMap[MA_MAX_CHANNELS]; ma_format internalFormat; ma_uint32 internalChannels; ma_uint32 internalSampleRate; ma_channel internalChannelMap[MA_MAX_CHANNELS]; ma_uint32 internalPeriodSizeInFrames; ma_uint32 internalPeriods; ma_channel_mix_mode channelMixMode; ma_bool32 calculateLFEFromSpatialChannels; ma_data_converter converter; void* pIntermediaryBuffer; /* For implementing fixed sized buffer callbacks. Will be null if using variable sized callbacks. */ ma_uint32 intermediaryBufferCap; ma_uint32 intermediaryBufferLen; /* How many valid frames are sitting in the intermediary buffer. */ void* pInputCache; /* In external format. Can be null. */ ma_uint64 inputCacheCap; ma_uint64 inputCacheConsumed; ma_uint64 inputCacheRemaining; } playback; struct { ma_device_id* pID; /* Set to NULL if using default ID, otherwise set to the address of "id". */ ma_device_id id; /* If using an explicit device, will be set to a copy of the ID used for initialization. Otherwise cleared to 0. */ char name[MA_MAX_DEVICE_NAME_LENGTH + 1]; /* Maybe temporary. Likely to be replaced with a query API. */ ma_share_mode shareMode; /* Set to whatever was passed in when the device was initialized. */ ma_format format; ma_uint32 channels; ma_channel channelMap[MA_MAX_CHANNELS]; ma_format internalFormat; ma_uint32 internalChannels; ma_uint32 internalSampleRate; ma_channel internalChannelMap[MA_MAX_CHANNELS]; ma_uint32 internalPeriodSizeInFrames; ma_uint32 internalPeriods; ma_channel_mix_mode channelMixMode; ma_bool32 calculateLFEFromSpatialChannels; ma_data_converter converter; void* pIntermediaryBuffer; /* For implementing fixed sized buffer callbacks. Will be null if using variable sized callbacks. */ ma_uint32 intermediaryBufferCap; ma_uint32 intermediaryBufferLen; /* How many valid frames are sitting in the intermediary buffer. */ } capture; union { #ifdef MA_SUPPORT_WASAPI struct { /*IAudioClient**/ ma_ptr pAudioClientPlayback; /*IAudioClient**/ ma_ptr pAudioClientCapture; /*IAudioRenderClient**/ ma_ptr pRenderClient; /*IAudioCaptureClient**/ ma_ptr pCaptureClient; /*IMMDeviceEnumerator**/ ma_ptr pDeviceEnumerator; /* Used for IMMNotificationClient notifications. Required for detecting default device changes. */ ma_IMMNotificationClient notificationClient; /*HANDLE*/ ma_handle hEventPlayback; /* Auto reset. Initialized to signaled. */ /*HANDLE*/ ma_handle hEventCapture; /* Auto reset. Initialized to unsignaled. */ ma_uint32 actualBufferSizeInFramesPlayback; /* Value from GetBufferSize(). internalPeriodSizeInFrames is not set to the _actual_ buffer size when low-latency shared mode is being used due to the way the IAudioClient3 API works. */ ma_uint32 actualBufferSizeInFramesCapture; ma_uint32 originalPeriodSizeInFrames; ma_uint32 originalPeriodSizeInMilliseconds; ma_uint32 originalPeriods; ma_performance_profile originalPerformanceProfile; ma_uint32 periodSizeInFramesPlayback; ma_uint32 periodSizeInFramesCapture; void* pMappedBufferCapture; ma_uint32 mappedBufferCaptureCap; ma_uint32 mappedBufferCaptureLen; void* pMappedBufferPlayback; ma_uint32 mappedBufferPlaybackCap; ma_uint32 mappedBufferPlaybackLen; ma_atomic_bool32 isStartedCapture; /* Can be read and written simultaneously across different threads. Must be used atomically, and must be 32-bit. */ ma_atomic_bool32 isStartedPlayback; /* Can be read and written simultaneously across different threads. Must be used atomically, and must be 32-bit. */ ma_uint32 loopbackProcessID; ma_bool8 loopbackProcessExclude; ma_bool8 noAutoConvertSRC; /* When set to true, disables the use of AUDCLNT_STREAMFLAGS_AUTOCONVERTPCM. */ ma_bool8 noDefaultQualitySRC; /* When set to true, disables the use of AUDCLNT_STREAMFLAGS_SRC_DEFAULT_QUALITY. */ ma_bool8 noHardwareOffloading; ma_bool8 allowCaptureAutoStreamRouting; ma_bool8 allowPlaybackAutoStreamRouting; ma_bool8 isDetachedPlayback; ma_bool8 isDetachedCapture; ma_wasapi_usage usage; void* hAvrtHandle; ma_mutex rerouteLock; } wasapi; #endif #ifdef MA_SUPPORT_DSOUND struct { /*LPDIRECTSOUND*/ ma_ptr pPlayback; /*LPDIRECTSOUNDBUFFER*/ ma_ptr pPlaybackPrimaryBuffer; /*LPDIRECTSOUNDBUFFER*/ ma_ptr pPlaybackBuffer; /*LPDIRECTSOUNDCAPTURE*/ ma_ptr pCapture; /*LPDIRECTSOUNDCAPTUREBUFFER*/ ma_ptr pCaptureBuffer; } dsound; #endif #ifdef MA_SUPPORT_WINMM struct { /*HWAVEOUT*/ ma_handle hDevicePlayback; /*HWAVEIN*/ ma_handle hDeviceCapture; /*HANDLE*/ ma_handle hEventPlayback; /*HANDLE*/ ma_handle hEventCapture; ma_uint32 fragmentSizeInFrames; ma_uint32 iNextHeaderPlayback; /* [0,periods). Used as an index into pWAVEHDRPlayback. */ ma_uint32 iNextHeaderCapture; /* [0,periods). Used as an index into pWAVEHDRCapture. */ ma_uint32 headerFramesConsumedPlayback; /* The number of PCM frames consumed in the buffer in pWAVEHEADER[iNextHeader]. */ ma_uint32 headerFramesConsumedCapture; /* ^^^ */ /*WAVEHDR**/ ma_uint8* pWAVEHDRPlayback; /* One instantiation for each period. */ /*WAVEHDR**/ ma_uint8* pWAVEHDRCapture; /* One instantiation for each period. */ ma_uint8* pIntermediaryBufferPlayback; ma_uint8* pIntermediaryBufferCapture; ma_uint8* _pHeapData; /* Used internally and is used for the heap allocated data for the intermediary buffer and the WAVEHDR structures. */ } winmm; #endif #ifdef MA_SUPPORT_ALSA struct { /*snd_pcm_t**/ ma_ptr pPCMPlayback; /*snd_pcm_t**/ ma_ptr pPCMCapture; /*struct pollfd**/ void* pPollDescriptorsPlayback; /*struct pollfd**/ void* pPollDescriptorsCapture; int pollDescriptorCountPlayback; int pollDescriptorCountCapture; int wakeupfdPlayback; /* eventfd for waking up from poll() when the playback device is stopped. */ int wakeupfdCapture; /* eventfd for waking up from poll() when the capture device is stopped. */ ma_bool8 isUsingMMapPlayback; ma_bool8 isUsingMMapCapture; } alsa; #endif #ifdef MA_SUPPORT_PULSEAUDIO struct { /*pa_mainloop**/ ma_ptr pMainLoop; /*pa_context**/ ma_ptr pPulseContext; /*pa_stream**/ ma_ptr pStreamPlayback; /*pa_stream**/ ma_ptr pStreamCapture; } pulse; #endif #ifdef MA_SUPPORT_JACK struct { /*jack_client_t**/ ma_ptr pClient; /*jack_port_t**/ ma_ptr* ppPortsPlayback; /*jack_port_t**/ ma_ptr* ppPortsCapture; float* pIntermediaryBufferPlayback; /* Typed as a float because JACK is always floating point. */ float* pIntermediaryBufferCapture; } jack; #endif #ifdef MA_SUPPORT_COREAUDIO struct { ma_uint32 deviceObjectIDPlayback; ma_uint32 deviceObjectIDCapture; /*AudioUnit*/ ma_ptr audioUnitPlayback; /*AudioUnit*/ ma_ptr audioUnitCapture; /*AudioBufferList**/ ma_ptr pAudioBufferList; /* Only used for input devices. */ ma_uint32 audioBufferCapInFrames; /* Only used for input devices. The capacity in frames of each buffer in pAudioBufferList. */ ma_event stopEvent; ma_uint32 originalPeriodSizeInFrames; ma_uint32 originalPeriodSizeInMilliseconds; ma_uint32 originalPeriods; ma_performance_profile originalPerformanceProfile; ma_bool32 isDefaultPlaybackDevice; ma_bool32 isDefaultCaptureDevice; ma_bool32 isSwitchingPlaybackDevice; /* <-- Set to true when the default device has changed and miniaudio is in the process of switching. */ ma_bool32 isSwitchingCaptureDevice; /* <-- Set to true when the default device has changed and miniaudio is in the process of switching. */ void* pNotificationHandler; /* Only used on mobile platforms. Obj-C object for handling route changes. */ } coreaudio; #endif #ifdef MA_SUPPORT_SNDIO struct { ma_ptr handlePlayback; ma_ptr handleCapture; ma_bool32 isStartedPlayback; ma_bool32 isStartedCapture; } sndio; #endif #ifdef MA_SUPPORT_AUDIO4 struct { int fdPlayback; int fdCapture; } audio4; #endif #ifdef MA_SUPPORT_OSS struct { int fdPlayback; int fdCapture; } oss; #endif #ifdef MA_SUPPORT_AAUDIO struct { /*AAudioStream**/ ma_ptr pStreamPlayback; /*AAudioStream**/ ma_ptr pStreamCapture; ma_aaudio_usage usage; ma_aaudio_content_type contentType; ma_aaudio_input_preset inputPreset; ma_aaudio_allowed_capture_policy allowedCapturePolicy; ma_bool32 noAutoStartAfterReroute; } aaudio; #endif #ifdef MA_SUPPORT_OPENSL struct { /*SLObjectItf*/ ma_ptr pOutputMixObj; /*SLOutputMixItf*/ ma_ptr pOutputMix; /*SLObjectItf*/ ma_ptr pAudioPlayerObj; /*SLPlayItf*/ ma_ptr pAudioPlayer; /*SLObjectItf*/ ma_ptr pAudioRecorderObj; /*SLRecordItf*/ ma_ptr pAudioRecorder; /*SLAndroidSimpleBufferQueueItf*/ ma_ptr pBufferQueuePlayback; /*SLAndroidSimpleBufferQueueItf*/ ma_ptr pBufferQueueCapture; ma_bool32 isDrainingCapture; ma_bool32 isDrainingPlayback; ma_uint32 currentBufferIndexPlayback; ma_uint32 currentBufferIndexCapture; ma_uint8* pBufferPlayback; /* This is malloc()'d and is used for storing audio data. Typed as ma_uint8 for easy offsetting. */ ma_uint8* pBufferCapture; } opensl; #endif #ifdef MA_SUPPORT_WEBAUDIO struct { /* AudioWorklets path. */ /* EMSCRIPTEN_WEBAUDIO_T */ int audioContext; /* EMSCRIPTEN_WEBAUDIO_T */ int audioWorklet; float* pIntermediaryBuffer; void* pStackBuffer; ma_result initResult; /* Set to MA_BUSY while initialization is in progress. */ int deviceIndex; /* We store the device in a list on the JavaScript side. This is used to map our C object to the JS object. */ } webaudio; #endif #ifdef MA_SUPPORT_NULL struct { ma_thread deviceThread; ma_event operationEvent; ma_event operationCompletionEvent; ma_semaphore operationSemaphore; ma_uint32 operation; ma_result operationResult; ma_timer timer; double priorRunTime; ma_uint32 currentPeriodFramesRemainingPlayback; ma_uint32 currentPeriodFramesRemainingCapture; ma_uint64 lastProcessedFramePlayback; ma_uint64 lastProcessedFrameCapture; ma_atomic_bool32 isStarted; /* Read and written by multiple threads. Must be used atomically, and must be 32-bit for compiler compatibility. */ } null_device; #endif }; }; #if defined(_MSC_VER) && !defined(__clang__) #pragma warning(pop) #elif defined(__clang__) || (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8))) #pragma GCC diagnostic pop /* For ISO C99 doesn't support unnamed structs/unions [-Wpedantic] */ #endif /* Initializes a `ma_context_config` object. Return Value ------------ A `ma_context_config` initialized to defaults. Remarks ------- You must always use this to initialize the default state of the `ma_context_config` object. Not using this will result in your program breaking when miniaudio is updated and new members are added to `ma_context_config`. It also sets logical defaults. You can override members of the returned object by changing it's members directly. See Also -------- ma_context_init() */ MA_API ma_context_config ma_context_config_init(void); /* Initializes a context. The context is used for selecting and initializing an appropriate backend and to represent the backend at a more global level than that of an individual device. There is one context to many devices, and a device is created from a context. A context is required to enumerate devices. Parameters ---------- backends (in, optional) A list of backends to try initializing, in priority order. Can be NULL, in which case it uses default priority order. backendCount (in, optional) The number of items in `backend`. Ignored if `backend` is NULL. pConfig (in, optional) The context configuration. pContext (in) A pointer to the context object being initialized. Return Value ------------ MA_SUCCESS if successful; any other error code otherwise. Thread Safety ------------- Unsafe. Do not call this function across multiple threads as some backends read and write to global state. Remarks ------- When `backends` is NULL, the default priority order will be used. Below is a list of backends in priority order: |-------------|-----------------------|--------------------------------------------------------| | Name | Enum Name | Supported Operating Systems | |-------------|-----------------------|--------------------------------------------------------| | WASAPI | ma_backend_wasapi | Windows Vista+ | | DirectSound | ma_backend_dsound | Windows XP+ | | WinMM | ma_backend_winmm | Windows XP+ (may work on older versions, but untested) | | Core Audio | ma_backend_coreaudio | macOS, iOS | | ALSA | ma_backend_alsa | Linux | | PulseAudio | ma_backend_pulseaudio | Cross Platform (disabled on Windows, BSD and Android) | | JACK | ma_backend_jack | Cross Platform (disabled on BSD and Android) | | sndio | ma_backend_sndio | OpenBSD | | audio(4) | ma_backend_audio4 | NetBSD, OpenBSD | | OSS | ma_backend_oss | FreeBSD | | AAudio | ma_backend_aaudio | Android 8+ | | OpenSL|ES | ma_backend_opensl | Android (API level 16+) | | Web Audio | ma_backend_webaudio | Web (via Emscripten) | | Null | ma_backend_null | Cross Platform (not used on Web) | |-------------|-----------------------|--------------------------------------------------------| The context can be configured via the `pConfig` argument. The config object is initialized with `ma_context_config_init()`. Individual configuration settings can then be set directly on the structure. Below are the members of the `ma_context_config` object. pLog A pointer to the `ma_log` to post log messages to. Can be NULL if the application does not require logging. See the `ma_log` API for details on how to use the logging system. threadPriority The desired priority to use for the audio thread. Allowable values include the following: |--------------------------------------| | Thread Priority | |--------------------------------------| | ma_thread_priority_idle | | ma_thread_priority_lowest | | ma_thread_priority_low | | ma_thread_priority_normal | | ma_thread_priority_high | | ma_thread_priority_highest (default) | | ma_thread_priority_realtime | | ma_thread_priority_default | |--------------------------------------| threadStackSize The desired size of the stack for the audio thread. Defaults to the operating system's default. pUserData A pointer to application-defined data. This can be accessed from the context object directly such as `context.pUserData`. allocationCallbacks Structure containing custom allocation callbacks. Leaving this at defaults will cause it to use MA_MALLOC, MA_REALLOC and MA_FREE. These allocation callbacks will be used for anything tied to the context, including devices. alsa.useVerboseDeviceEnumeration ALSA will typically enumerate many different devices which can be intrusive and not user-friendly. To combat this, miniaudio will enumerate only unique card/device pairs by default. The problem with this is that you lose a bit of flexibility and control. Setting alsa.useVerboseDeviceEnumeration makes it so the ALSA backend includes all devices. Defaults to false. pulse.pApplicationName PulseAudio only. The application name to use when initializing the PulseAudio context with `pa_context_new()`. pulse.pServerName PulseAudio only. The name of the server to connect to with `pa_context_connect()`. pulse.tryAutoSpawn PulseAudio only. Whether or not to try automatically starting the PulseAudio daemon. Defaults to false. If you set this to true, keep in mind that miniaudio uses a trial and error method to find the most appropriate backend, and this will result in the PulseAudio daemon starting which may be intrusive for the end user. coreaudio.sessionCategory iOS only. The session category to use for the shared AudioSession instance. Below is a list of allowable values and their Core Audio equivalents. |-----------------------------------------|-------------------------------------| | miniaudio Token | Core Audio Token | |-----------------------------------------|-------------------------------------| | ma_ios_session_category_ambient | AVAudioSessionCategoryAmbient | | ma_ios_session_category_solo_ambient | AVAudioSessionCategorySoloAmbient | | ma_ios_session_category_playback | AVAudioSessionCategoryPlayback | | ma_ios_session_category_record | AVAudioSessionCategoryRecord | | ma_ios_session_category_play_and_record | AVAudioSessionCategoryPlayAndRecord | | ma_ios_session_category_multi_route | AVAudioSessionCategoryMultiRoute | | ma_ios_session_category_none | AVAudioSessionCategoryAmbient | | ma_ios_session_category_default | AVAudioSessionCategoryAmbient | |-----------------------------------------|-------------------------------------| coreaudio.sessionCategoryOptions iOS only. Session category options to use with the shared AudioSession instance. Below is a list of allowable values and their Core Audio equivalents. |---------------------------------------------------------------------------|------------------------------------------------------------------| | miniaudio Token | Core Audio Token | |---------------------------------------------------------------------------|------------------------------------------------------------------| | ma_ios_session_category_option_mix_with_others | AVAudioSessionCategoryOptionMixWithOthers | | ma_ios_session_category_option_duck_others | AVAudioSessionCategoryOptionDuckOthers | | ma_ios_session_category_option_allow_bluetooth | AVAudioSessionCategoryOptionAllowBluetooth | | ma_ios_session_category_option_default_to_speaker | AVAudioSessionCategoryOptionDefaultToSpeaker | | ma_ios_session_category_option_interrupt_spoken_audio_and_mix_with_others | AVAudioSessionCategoryOptionInterruptSpokenAudioAndMixWithOthers | | ma_ios_session_category_option_allow_bluetooth_a2dp | AVAudioSessionCategoryOptionAllowBluetoothA2DP | | ma_ios_session_category_option_allow_air_play | AVAudioSessionCategoryOptionAllowAirPlay | |---------------------------------------------------------------------------|------------------------------------------------------------------| coreaudio.noAudioSessionActivate iOS only. When set to true, does not perform an explicit [[AVAudioSession sharedInstace] setActive:true] on initialization. coreaudio.noAudioSessionDeactivate iOS only. When set to true, does not perform an explicit [[AVAudioSession sharedInstace] setActive:false] on uninitialization. jack.pClientName The name of the client to pass to `jack_client_open()`. jack.tryStartServer Whether or not to try auto-starting the JACK server. Defaults to false. It is recommended that only a single context is active at any given time because it's a bulky data structure which performs run-time linking for the relevant backends every time it's initialized. The location of the context cannot change throughout it's lifetime. Consider allocating the `ma_context` object with `malloc()` if this is an issue. The reason for this is that a pointer to the context is stored in the `ma_device` structure. Example 1 - Default Initialization ---------------------------------- The example below shows how to initialize the context using the default configuration. ```c ma_context context; ma_result result = ma_context_init(NULL, 0, NULL, &context); if (result != MA_SUCCESS) { // Error. } ``` Example 2 - Custom Configuration -------------------------------- The example below shows how to initialize the context using custom backend priorities and a custom configuration. In this hypothetical example, the program wants to prioritize ALSA over PulseAudio on Linux. They also want to avoid using the WinMM backend on Windows because it's latency is too high. They also want an error to be returned if no valid backend is available which they achieve by excluding the Null backend. For the configuration, the program wants to capture any log messages so they can, for example, route it to a log file and user interface. ```c ma_backend backends[] = { ma_backend_alsa, ma_backend_pulseaudio, ma_backend_wasapi, ma_backend_dsound }; ma_log log; ma_log_init(&log); ma_log_register_callback(&log, ma_log_callback_init(my_log_callbac, pMyLogUserData)); ma_context_config config = ma_context_config_init(); config.pLog = &log; // Specify a custom log object in the config so any logs that are posted from ma_context_init() are captured. ma_context context; ma_result result = ma_context_init(backends, sizeof(backends)/sizeof(backends[0]), &config, &context); if (result != MA_SUCCESS) { // Error. if (result == MA_NO_BACKEND) { // Couldn't find an appropriate backend. } } // You could also attach a log callback post-initialization: ma_log_register_callback(ma_context_get_log(&context), ma_log_callback_init(my_log_callback, pMyLogUserData)); ``` See Also -------- ma_context_config_init() ma_context_uninit() */ MA_API ma_result ma_context_init(const ma_backend backends[], ma_uint32 backendCount, const ma_context_config* pConfig, ma_context* pContext); /* Uninitializes a context. Return Value ------------ MA_SUCCESS if successful; any other error code otherwise. Thread Safety ------------- Unsafe. Do not call this function across multiple threads as some backends read and write to global state. Remarks ------- Results are undefined if you call this while any device created by this context is still active. See Also -------- ma_context_init() */ MA_API ma_result ma_context_uninit(ma_context* pContext); /* Retrieves the size of the ma_context object. This is mainly for the purpose of bindings to know how much memory to allocate. */ MA_API size_t ma_context_sizeof(void); /* Retrieves a pointer to the log object associated with this context. Remarks ------- Pass the returned pointer to `ma_log_post()`, `ma_log_postv()` or `ma_log_postf()` to post a log message. You can attach your own logging callback to the log with `ma_log_register_callback()` Return Value ------------ A pointer to the `ma_log` object that the context uses to post log messages. If some error occurs, NULL will be returned. */ MA_API ma_log* ma_context_get_log(ma_context* pContext); /* Enumerates over every device (both playback and capture). This is a lower-level enumeration function to the easier to use `ma_context_get_devices()`. Use `ma_context_enumerate_devices()` if you would rather not incur an internal heap allocation, or it simply suits your code better. Note that this only retrieves the ID and name/description of the device. The reason for only retrieving basic information is that it would otherwise require opening the backend device in order to probe it for more detailed information which can be inefficient. Consider using `ma_context_get_device_info()` for this, but don't call it from within the enumeration callback. Returning false from the callback will stop enumeration. Returning true will continue enumeration. Parameters ---------- pContext (in) A pointer to the context performing the enumeration. callback (in) The callback to fire for each enumerated device. pUserData (in) A pointer to application-defined data passed to the callback. Return Value ------------ MA_SUCCESS if successful; any other error code otherwise. Thread Safety ------------- Safe. This is guarded using a simple mutex lock. Remarks ------- Do _not_ assume the first enumerated device of a given type is the default device. Some backends and platforms may only support default playback and capture devices. In general, you should not do anything complicated from within the callback. In particular, do not try initializing a device from within the callback. Also, do not try to call `ma_context_get_device_info()` from within the callback. Consider using `ma_context_get_devices()` for a simpler and safer API, albeit at the expense of an internal heap allocation. Example 1 - Simple Enumeration ------------------------------ ma_bool32 ma_device_enum_callback(ma_context* pContext, ma_device_type deviceType, const ma_device_info* pInfo, void* pUserData) { printf("Device Name: %s\n", pInfo->name); return MA_TRUE; } ma_result result = ma_context_enumerate_devices(&context, my_device_enum_callback, pMyUserData); if (result != MA_SUCCESS) { // Error. } See Also -------- ma_context_get_devices() */ MA_API ma_result ma_context_enumerate_devices(ma_context* pContext, ma_enum_devices_callback_proc callback, void* pUserData); /* Retrieves basic information about every active playback and/or capture device. This function will allocate memory internally for the device lists and return a pointer to them through the `ppPlaybackDeviceInfos` and `ppCaptureDeviceInfos` parameters. If you do not want to incur the overhead of these allocations consider using `ma_context_enumerate_devices()` which will instead use a callback. Parameters ---------- pContext (in) A pointer to the context performing the enumeration. ppPlaybackDeviceInfos (out) A pointer to a pointer that will receive the address of a buffer containing the list of `ma_device_info` structures for playback devices. pPlaybackDeviceCount (out) A pointer to an unsigned integer that will receive the number of playback devices. ppCaptureDeviceInfos (out) A pointer to a pointer that will receive the address of a buffer containing the list of `ma_device_info` structures for capture devices. pCaptureDeviceCount (out) A pointer to an unsigned integer that will receive the number of capture devices. Return Value ------------ MA_SUCCESS if successful; any other error code otherwise. Thread Safety ------------- Unsafe. Since each call to this function invalidates the pointers from the previous call, you should not be calling this simultaneously across multiple threads. Instead, you need to make a copy of the returned data with your own higher level synchronization. Remarks ------- It is _not_ safe to assume the first device in the list is the default device. You can pass in NULL for the playback or capture lists in which case they'll be ignored. The returned pointers will become invalid upon the next call this this function, or when the context is uninitialized. Do not free the returned pointers. See Also -------- ma_context_get_devices() */ MA_API ma_result ma_context_get_devices(ma_context* pContext, ma_device_info** ppPlaybackDeviceInfos, ma_uint32* pPlaybackDeviceCount, ma_device_info** ppCaptureDeviceInfos, ma_uint32* pCaptureDeviceCount); /* Retrieves information about a device of the given type, with the specified ID and share mode. Parameters ---------- pContext (in) A pointer to the context performing the query. deviceType (in) The type of the device being queried. Must be either `ma_device_type_playback` or `ma_device_type_capture`. pDeviceID (in) The ID of the device being queried. pDeviceInfo (out) A pointer to the `ma_device_info` structure that will receive the device information. Return Value ------------ MA_SUCCESS if successful; any other error code otherwise. Thread Safety ------------- Safe. This is guarded using a simple mutex lock. Remarks ------- Do _not_ call this from within the `ma_context_enumerate_devices()` callback. It's possible for a device to have different information and capabilities depending on whether or not it's opened in shared or exclusive mode. For example, in shared mode, WASAPI always uses floating point samples for mixing, but in exclusive mode it can be anything. Therefore, this function allows you to specify which share mode you want information for. Note that not all backends and devices support shared or exclusive mode, in which case this function will fail if the requested share mode is unsupported. This leaves pDeviceInfo unmodified in the result of an error. */ MA_API ma_result ma_context_get_device_info(ma_context* pContext, ma_device_type deviceType, const ma_device_id* pDeviceID, ma_device_info* pDeviceInfo); /* Determines if the given context supports loopback mode. Parameters ---------- pContext (in) A pointer to the context getting queried. Return Value ------------ MA_TRUE if the context supports loopback mode; MA_FALSE otherwise. */ MA_API ma_bool32 ma_context_is_loopback_supported(ma_context* pContext); /* Initializes a device config with default settings. Parameters ---------- deviceType (in) The type of the device this config is being initialized for. This must set to one of the following: |-------------------------| | Device Type | |-------------------------| | ma_device_type_playback | | ma_device_type_capture | | ma_device_type_duplex | | ma_device_type_loopback | |-------------------------| Return Value ------------ A new device config object with default settings. You will typically want to adjust the config after this function returns. See remarks. Thread Safety ------------- Safe. Callback Safety --------------- Safe, but don't try initializing a device in a callback. Remarks ------- The returned config will be initialized to defaults. You will normally want to customize a few variables before initializing the device. See Example 1 for a typical configuration which sets the sample format, channel count, sample rate, data callback and user data. These are usually things you will want to change before initializing the device. See `ma_device_init()` for details on specific configuration options. Example 1 - Simple Configuration -------------------------------- The example below is what a program will typically want to configure for each device at a minimum. Notice how `ma_device_config_init()` is called first, and then the returned object is modified directly. This is important because it ensures that your program continues to work as new configuration options are added to the `ma_device_config` structure. ```c ma_device_config config = ma_device_config_init(ma_device_type_playback); config.playback.format = ma_format_f32; config.playback.channels = 2; config.sampleRate = 48000; config.dataCallback = ma_data_callback; config.pUserData = pMyUserData; ``` See Also -------- ma_device_init() ma_device_init_ex() */ MA_API ma_device_config ma_device_config_init(ma_device_type deviceType); /* Initializes a device. A device represents a physical audio device. The idea is you send or receive audio data from the device to either play it back through a speaker, or capture it from a microphone. Whether or not you should send or receive data from the device (or both) depends on the type of device you are initializing which can be playback, capture, full-duplex or loopback. (Note that loopback mode is only supported on select backends.) Sending and receiving audio data to and from the device is done via a callback which is fired by miniaudio at periodic time intervals. The frequency at which data is delivered to and from a device depends on the size of it's period. The size of the period can be defined in terms of PCM frames or milliseconds, whichever is more convenient. Generally speaking, the smaller the period, the lower the latency at the expense of higher CPU usage and increased risk of glitching due to the more frequent and granular data deliver intervals. The size of a period will depend on your requirements, but miniaudio's defaults should work fine for most scenarios. If you're building a game you should leave this fairly small, whereas if you're building a simple media player you can make it larger. Note that the period size you request is actually just a hint - miniaudio will tell the backend what you want, but the backend is ultimately responsible for what it gives you. You cannot assume you will get exactly what you ask for. When delivering data to and from a device you need to make sure it's in the correct format which you can set through the device configuration. You just set the format that you want to use and miniaudio will perform all of the necessary conversion for you internally. When delivering data to and from the callback you can assume the format is the same as what you requested when you initialized the device. See Remarks for more details on miniaudio's data conversion pipeline. Parameters ---------- pContext (in, optional) A pointer to the context that owns the device. This can be null, in which case it creates a default context internally. pConfig (in) A pointer to the device configuration. Cannot be null. See remarks for details. pDevice (out) A pointer to the device object being initialized. Return Value ------------ MA_SUCCESS if successful; any other error code otherwise. Thread Safety ------------- Unsafe. It is not safe to call this function simultaneously for different devices because some backends depend on and mutate global state. The same applies to calling this at the same time as `ma_device_uninit()`. Callback Safety --------------- Unsafe. It is not safe to call this inside any callback. Remarks ------- Setting `pContext` to NULL will result in miniaudio creating a default context internally and is equivalent to passing in a context initialized like so: ```c ma_context_init(NULL, 0, NULL, &context); ``` Do not set `pContext` to NULL if you are needing to open multiple devices. You can, however, use NULL when initializing the first device, and then use device.pContext for the initialization of other devices. The device can be configured via the `pConfig` argument. The config object is initialized with `ma_device_config_init()`. Individual configuration settings can then be set directly on the structure. Below are the members of the `ma_device_config` object. deviceType Must be `ma_device_type_playback`, `ma_device_type_capture`, `ma_device_type_duplex` of `ma_device_type_loopback`. sampleRate The sample rate, in hertz. The most common sample rates are 48000 and 44100. Setting this to 0 will use the device's native sample rate. periodSizeInFrames The desired size of a period in PCM frames. If this is 0, `periodSizeInMilliseconds` will be used instead. If both are 0 the default buffer size will be used depending on the selected performance profile. This value affects latency. See below for details. periodSizeInMilliseconds The desired size of a period in milliseconds. If this is 0, `periodSizeInFrames` will be used instead. If both are 0 the default buffer size will be used depending on the selected performance profile. The value affects latency. See below for details. periods The number of periods making up the device's entire buffer. The total buffer size is `periodSizeInFrames` or `periodSizeInMilliseconds` multiplied by this value. This is just a hint as backends will be the ones who ultimately decide how your periods will be configured. performanceProfile A hint to miniaudio as to the performance requirements of your program. Can be either `ma_performance_profile_low_latency` (default) or `ma_performance_profile_conservative`. This mainly affects the size of default buffers and can usually be left at it's default value. noPreSilencedOutputBuffer When set to true, the contents of the output buffer passed into the data callback will be left undefined. When set to false (default), the contents of the output buffer will be cleared the zero. You can use this to avoid the overhead of zeroing out the buffer if you can guarantee that your data callback will write to every sample in the output buffer, or if you are doing your own clearing. noClip When set to true, the contents of the output buffer are left alone after returning and it will be left up to the backend itself to decide whether or not to clip. When set to false (default), the contents of the output buffer passed into the data callback will be clipped after returning. This only applies when the playback sample format is f32. noDisableDenormals By default, miniaudio will disable denormals when the data callback is called. Setting this to true will prevent the disabling of denormals. noFixedSizedCallback Allows miniaudio to fire the data callback with any frame count. When this is set to false (the default), the data callback will be fired with a consistent frame count as specified by `periodSizeInFrames` or `periodSizeInMilliseconds`. When set to true, miniaudio will fire the callback with whatever the backend requests, which could be anything. dataCallback The callback to fire whenever data is ready to be delivered to or from the device. notificationCallback The callback to fire when something has changed with the device, such as whether or not it has been started or stopped. pUserData The user data pointer to use with the device. You can access this directly from the device object like `device.pUserData`. resampling.algorithm The resampling algorithm to use when miniaudio needs to perform resampling between the rate specified by `sampleRate` and the device's native rate. The default value is `ma_resample_algorithm_linear`, and the quality can be configured with `resampling.linear.lpfOrder`. resampling.pBackendVTable A pointer to an optional vtable that can be used for plugging in a custom resampler. resampling.pBackendUserData A pointer that will passed to callbacks in pBackendVTable. resampling.linear.lpfOrder The linear resampler applies a low-pass filter as part of it's processing for anti-aliasing. This setting controls the order of the filter. The higher the value, the better the quality, in general. Setting this to 0 will disable low-pass filtering altogether. The maximum value is `MA_MAX_FILTER_ORDER`. The default value is `min(4, MA_MAX_FILTER_ORDER)`. playback.pDeviceID A pointer to a `ma_device_id` structure containing the ID of the playback device to initialize. Setting this NULL (default) will use the system's default playback device. Retrieve the device ID from the `ma_device_info` structure, which can be retrieved using device enumeration. playback.format The sample format to use for playback. When set to `ma_format_unknown` the device's native format will be used. This can be retrieved after initialization from the device object directly with `device.playback.format`. playback.channels The number of channels to use for playback. When set to 0 the device's native channel count will be used. This can be retrieved after initialization from the device object directly with `device.playback.channels`. playback.pChannelMap The channel map to use for playback. When left empty, the device's native channel map will be used. This can be retrieved after initialization from the device object direct with `device.playback.pChannelMap`. When set, the buffer should contain `channels` items. playback.shareMode The preferred share mode to use for playback. Can be either `ma_share_mode_shared` (default) or `ma_share_mode_exclusive`. Note that if you specify exclusive mode, but it's not supported by the backend, initialization will fail. You can then fall back to shared mode if desired by changing this to ma_share_mode_shared and reinitializing. capture.pDeviceID A pointer to a `ma_device_id` structure containing the ID of the capture device to initialize. Setting this NULL (default) will use the system's default capture device. Retrieve the device ID from the `ma_device_info` structure, which can be retrieved using device enumeration. capture.format The sample format to use for capture. When set to `ma_format_unknown` the device's native format will be used. This can be retrieved after initialization from the device object directly with `device.capture.format`. capture.channels The number of channels to use for capture. When set to 0 the device's native channel count will be used. This can be retrieved after initialization from the device object directly with `device.capture.channels`. capture.pChannelMap The channel map to use for capture. When left empty, the device's native channel map will be used. This can be retrieved after initialization from the device object direct with `device.capture.pChannelMap`. When set, the buffer should contain `channels` items. capture.shareMode The preferred share mode to use for capture. Can be either `ma_share_mode_shared` (default) or `ma_share_mode_exclusive`. Note that if you specify exclusive mode, but it's not supported by the backend, initialization will fail. You can then fall back to shared mode if desired by changing this to ma_share_mode_shared and reinitializing. wasapi.noAutoConvertSRC WASAPI only. When set to true, disables WASAPI's automatic resampling and forces the use of miniaudio's resampler. Defaults to false. wasapi.noDefaultQualitySRC WASAPI only. Only used when `wasapi.noAutoConvertSRC` is set to false. When set to true, disables the use of `AUDCLNT_STREAMFLAGS_SRC_DEFAULT_QUALITY`. You should usually leave this set to false, which is the default. wasapi.noAutoStreamRouting WASAPI only. When set to true, disables automatic stream routing on the WASAPI backend. Defaults to false. wasapi.noHardwareOffloading WASAPI only. When set to true, disables the use of WASAPI's hardware offloading feature. Defaults to false. alsa.noMMap ALSA only. When set to true, disables MMap mode. Defaults to false. alsa.noAutoFormat ALSA only. When set to true, disables ALSA's automatic format conversion by including the SND_PCM_NO_AUTO_FORMAT flag. Defaults to false. alsa.noAutoChannels ALSA only. When set to true, disables ALSA's automatic channel conversion by including the SND_PCM_NO_AUTO_CHANNELS flag. Defaults to false. alsa.noAutoResample ALSA only. When set to true, disables ALSA's automatic resampling by including the SND_PCM_NO_AUTO_RESAMPLE flag. Defaults to false. pulse.pStreamNamePlayback PulseAudio only. Sets the stream name for playback. pulse.pStreamNameCapture PulseAudio only. Sets the stream name for capture. coreaudio.allowNominalSampleRateChange Core Audio only. Desktop only. When enabled, allows the sample rate of the device to be changed at the operating system level. This is disabled by default in order to prevent intrusive changes to the user's system. This is useful if you want to use a sample rate that is known to be natively supported by the hardware thereby avoiding the cost of resampling. When set to true, miniaudio will find the closest match between the sample rate requested in the device config and the sample rates natively supported by the hardware. When set to false, the sample rate currently set by the operating system will always be used. opensl.streamType OpenSL only. Explicitly sets the stream type. If left unset (`ma_opensl_stream_type_default`), the stream type will be left unset. Think of this as the type of audio you're playing. opensl.recordingPreset OpenSL only. Explicitly sets the type of recording your program will be doing. When left unset, the recording preset will be left unchanged. aaudio.usage AAudio only. Explicitly sets the nature of the audio the program will be consuming. When left unset, the usage will be left unchanged. aaudio.contentType AAudio only. Sets the content type. When left unset, the content type will be left unchanged. aaudio.inputPreset AAudio only. Explicitly sets the type of recording your program will be doing. When left unset, the input preset will be left unchanged. aaudio.noAutoStartAfterReroute AAudio only. Controls whether or not the device should be automatically restarted after a stream reroute. When set to false (default) the device will be restarted automatically; otherwise the device will be stopped. Once initialized, the device's config is immutable. If you need to change the config you will need to initialize a new device. After initializing the device it will be in a stopped state. To start it, use `ma_device_start()`. If both `periodSizeInFrames` and `periodSizeInMilliseconds` are set to zero, it will default to `MA_DEFAULT_PERIOD_SIZE_IN_MILLISECONDS_LOW_LATENCY` or `MA_DEFAULT_PERIOD_SIZE_IN_MILLISECONDS_CONSERVATIVE`, depending on whether or not `performanceProfile` is set to `ma_performance_profile_low_latency` or `ma_performance_profile_conservative`. If you request exclusive mode and the backend does not support it an error will be returned. For robustness, you may want to first try initializing the device in exclusive mode, and then fall back to shared mode if required. Alternatively you can just request shared mode (the default if you leave it unset in the config) which is the most reliable option. Some backends do not have a practical way of choosing whether or not the device should be exclusive or not (ALSA, for example) in which case it just acts as a hint. Unless you have special requirements you should try avoiding exclusive mode as it's intrusive to the user. Starting with Windows 10, miniaudio will use low-latency shared mode where possible which may make exclusive mode unnecessary. When sending or receiving data to/from a device, miniaudio will internally perform a format conversion to convert between the format specified by the config and the format used internally by the backend. If you pass in 0 for the sample format, channel count, sample rate _and_ channel map, data transmission will run on an optimized pass-through fast path. You can retrieve the format, channel count and sample rate by inspecting the `playback/capture.format`, `playback/capture.channels` and `sampleRate` members of the device object. When compiling for UWP you must ensure you call this function on the main UI thread because the operating system may need to present the user with a message asking for permissions. Please refer to the official documentation for ActivateAudioInterfaceAsync() for more information. ALSA Specific: When initializing the default device, requesting shared mode will try using the "dmix" device for playback and the "dsnoop" device for capture. If these fail it will try falling back to the "hw" device. Example 1 - Simple Initialization --------------------------------- This example shows how to initialize a simple playback device using a standard configuration. If you are just needing to do simple playback from the default playback device this is usually all you need. ```c ma_device_config config = ma_device_config_init(ma_device_type_playback); config.playback.format = ma_format_f32; config.playback.channels = 2; config.sampleRate = 48000; config.dataCallback = ma_data_callback; config.pMyUserData = pMyUserData; ma_device device; ma_result result = ma_device_init(NULL, &config, &device); if (result != MA_SUCCESS) { // Error } ``` Example 2 - Advanced Initialization ----------------------------------- This example shows how you might do some more advanced initialization. In this hypothetical example we want to control the latency by setting the buffer size and period count. We also want to allow the user to be able to choose which device to output from which means we need a context so we can perform device enumeration. ```c ma_context context; ma_result result = ma_context_init(NULL, 0, NULL, &context); if (result != MA_SUCCESS) { // Error } ma_device_info* pPlaybackDeviceInfos; ma_uint32 playbackDeviceCount; result = ma_context_get_devices(&context, &pPlaybackDeviceInfos, &playbackDeviceCount, NULL, NULL); if (result != MA_SUCCESS) { // Error } // ... choose a device from pPlaybackDeviceInfos ... ma_device_config config = ma_device_config_init(ma_device_type_playback); config.playback.pDeviceID = pMyChosenDeviceID; // <-- Get this from the `id` member of one of the `ma_device_info` objects returned by ma_context_get_devices(). config.playback.format = ma_format_f32; config.playback.channels = 2; config.sampleRate = 48000; config.dataCallback = ma_data_callback; config.pUserData = pMyUserData; config.periodSizeInMilliseconds = 10; config.periods = 3; ma_device device; result = ma_device_init(&context, &config, &device); if (result != MA_SUCCESS) { // Error } ``` See Also -------- ma_device_config_init() ma_device_uninit() ma_device_start() ma_context_init() ma_context_get_devices() ma_context_enumerate_devices() */ MA_API ma_result ma_device_init(ma_context* pContext, const ma_device_config* pConfig, ma_device* pDevice); /* Initializes a device without a context, with extra parameters for controlling the configuration of the internal self-managed context. This is the same as `ma_device_init()`, only instead of a context being passed in, the parameters from `ma_context_init()` are passed in instead. This function allows you to configure the internally created context. Parameters ---------- backends (in, optional) A list of backends to try initializing, in priority order. Can be NULL, in which case it uses default priority order. backendCount (in, optional) The number of items in `backend`. Ignored if `backend` is NULL. pContextConfig (in, optional) The context configuration. pConfig (in) A pointer to the device configuration. Cannot be null. See remarks for details. pDevice (out) A pointer to the device object being initialized. Return Value ------------ MA_SUCCESS if successful; any other error code otherwise. Thread Safety ------------- Unsafe. It is not safe to call this function simultaneously for different devices because some backends depend on and mutate global state. The same applies to calling this at the same time as `ma_device_uninit()`. Callback Safety --------------- Unsafe. It is not safe to call this inside any callback. Remarks ------- You only need to use this function if you want to configure the context differently to it's defaults. You should never use this function if you want to manage your own context. See the documentation for `ma_context_init()` for information on the different context configuration options. See Also -------- ma_device_init() ma_device_uninit() ma_device_config_init() ma_context_init() */ MA_API ma_result ma_device_init_ex(const ma_backend backends[], ma_uint32 backendCount, const ma_context_config* pContextConfig, const ma_device_config* pConfig, ma_device* pDevice); /* Uninitializes a device. This will explicitly stop the device. You do not need to call `ma_device_stop()` beforehand, but it's harmless if you do. Parameters ---------- pDevice (in) A pointer to the device to stop. Return Value ------------ Nothing Thread Safety ------------- Unsafe. As soon as this API is called the device should be considered undefined. Callback Safety --------------- Unsafe. It is not safe to call this inside any callback. Doing this will result in a deadlock. See Also -------- ma_device_init() ma_device_stop() */ MA_API void ma_device_uninit(ma_device* pDevice); /* Retrieves a pointer to the context that owns the given device. */ MA_API ma_context* ma_device_get_context(ma_device* pDevice); /* Helper function for retrieving the log object associated with the context that owns this device. */ MA_API ma_log* ma_device_get_log(ma_device* pDevice); /* Retrieves information about the device. Parameters ---------- pDevice (in) A pointer to the device whose information is being retrieved. type (in) The device type. This parameter is required for duplex devices. When retrieving device information, you are doing so for an individual playback or capture device. pDeviceInfo (out) A pointer to the `ma_device_info` that will receive the device information. Return Value ------------ MA_SUCCESS if successful; any other error code otherwise. Thread Safety ------------- Unsafe. This should be considered unsafe because it may be calling into the backend which may or may not be safe. Callback Safety --------------- Unsafe. You should avoid calling this in the data callback because it may call into the backend which may or may not be safe. */ MA_API ma_result ma_device_get_info(ma_device* pDevice, ma_device_type type, ma_device_info* pDeviceInfo); /* Retrieves the name of the device. Parameters ---------- pDevice (in) A pointer to the device whose information is being retrieved. type (in) The device type. This parameter is required for duplex devices. When retrieving device information, you are doing so for an individual playback or capture device. pName (out) A pointer to the buffer that will receive the name. nameCap (in) The capacity of the output buffer, including space for the null terminator. pLengthNotIncludingNullTerminator (out, optional) A pointer to the variable that will receive the length of the name, not including the null terminator. Return Value ------------ MA_SUCCESS if successful; any other error code otherwise. Thread Safety ------------- Unsafe. This should be considered unsafe because it may be calling into the backend which may or may not be safe. Callback Safety --------------- Unsafe. You should avoid calling this in the data callback because it may call into the backend which may or may not be safe. Remarks ------- If the name does not fully fit into the output buffer, it'll be truncated. You can pass in NULL to `pName` if you want to first get the length of the name for the purpose of memory allocation of the output buffer. Allocating a buffer of size `MA_MAX_DEVICE_NAME_LENGTH + 1` should be enough for most cases and will avoid the need for the inefficiency of calling this function twice. This is implemented in terms of `ma_device_get_info()`. */ MA_API ma_result ma_device_get_name(ma_device* pDevice, ma_device_type type, char* pName, size_t nameCap, size_t* pLengthNotIncludingNullTerminator); /* Starts the device. For playback devices this begins playback. For capture devices it begins recording. Use `ma_device_stop()` to stop the device. Parameters ---------- pDevice (in) A pointer to the device to start. Return Value ------------ MA_SUCCESS if successful; any other error code otherwise. Thread Safety ------------- Safe. It's safe to call this from any thread with the exception of the callback thread. Callback Safety --------------- Unsafe. It is not safe to call this inside any callback. Remarks ------- For a playback device, this will retrieve an initial chunk of audio data from the client before returning. The reason for this is to ensure there is valid audio data in the buffer, which needs to be done before the device begins playback. This API waits until the backend device has been started for real by the worker thread. It also waits on a mutex for thread-safety. Do not call this in any callback. See Also -------- ma_device_stop() */ MA_API ma_result ma_device_start(ma_device* pDevice); /* Stops the device. For playback devices this stops playback. For capture devices it stops recording. Use `ma_device_start()` to start the device again. Parameters ---------- pDevice (in) A pointer to the device to stop. Return Value ------------ MA_SUCCESS if successful; any other error code otherwise. Thread Safety ------------- Safe. It's safe to call this from any thread with the exception of the callback thread. Callback Safety --------------- Unsafe. It is not safe to call this inside any callback. Doing this will result in a deadlock. Remarks ------- This API needs to wait on the worker thread to stop the backend device properly before returning. It also waits on a mutex for thread-safety. In addition, some backends need to wait for the device to finish playback/recording of the current fragment which can take some time (usually proportionate to the buffer size that was specified at initialization time). Backends are required to either pause the stream in-place or drain the buffer if pausing is not possible. The reason for this is that stopping the device and the resuming it with ma_device_start() (which you might do when your program loses focus) may result in a situation where those samples are never output to the speakers or received from the microphone which can in turn result in de-syncs. Do not call this in any callback. See Also -------- ma_device_start() */ MA_API ma_result ma_device_stop(ma_device* pDevice); /* Determines whether or not the device is started. Parameters ---------- pDevice (in) A pointer to the device whose start state is being retrieved. Return Value ------------ True if the device is started, false otherwise. Thread Safety ------------- Safe. If another thread calls `ma_device_start()` or `ma_device_stop()` at this same time as this function is called, there's a very small chance the return value will be out of sync. Callback Safety --------------- Safe. This is implemented as a simple accessor. See Also -------- ma_device_start() ma_device_stop() */ MA_API ma_bool32 ma_device_is_started(const ma_device* pDevice); /* Retrieves the state of the device. Parameters ---------- pDevice (in) A pointer to the device whose state is being retrieved. Return Value ------------ The current state of the device. The return value will be one of the following: +-------------------------------+------------------------------------------------------------------------------+ | ma_device_state_uninitialized | Will only be returned if the device is in the middle of initialization. | +-------------------------------+------------------------------------------------------------------------------+ | ma_device_state_stopped | The device is stopped. The initial state of the device after initialization. | +-------------------------------+------------------------------------------------------------------------------+ | ma_device_state_started | The device started and requesting and/or delivering audio data. | +-------------------------------+------------------------------------------------------------------------------+ | ma_device_state_starting | The device is in the process of starting. | +-------------------------------+------------------------------------------------------------------------------+ | ma_device_state_stopping | The device is in the process of stopping. | +-------------------------------+------------------------------------------------------------------------------+ Thread Safety ------------- Safe. This is implemented as a simple accessor. Note that if the device is started or stopped at the same time as this function is called, there's a possibility the return value could be out of sync. See remarks. Callback Safety --------------- Safe. This is implemented as a simple accessor. Remarks ------- The general flow of a devices state goes like this: ``` ma_device_init() -> ma_device_state_uninitialized -> ma_device_state_stopped ma_device_start() -> ma_device_state_starting -> ma_device_state_started ma_device_stop() -> ma_device_state_stopping -> ma_device_state_stopped ``` When the state of the device is changed with `ma_device_start()` or `ma_device_stop()` at this same time as this function is called, the value returned by this function could potentially be out of sync. If this is significant to your program you need to implement your own synchronization. */ MA_API ma_device_state ma_device_get_state(const ma_device* pDevice); /* Performs post backend initialization routines for setting up internal data conversion. This should be called whenever the backend is initialized. The only time this should be called from outside of miniaudio is if you're implementing a custom backend, and you would only do it if you are reinitializing the backend due to rerouting or reinitializing for some reason. Parameters ---------- pDevice [in] A pointer to the device. deviceType [in] The type of the device that was just reinitialized. pPlaybackDescriptor [in] The descriptor of the playback device containing the internal data format and buffer sizes. pPlaybackDescriptor [in] The descriptor of the capture device containing the internal data format and buffer sizes. Return Value ------------ MA_SUCCESS if successful; any other error otherwise. Thread Safety ------------- Unsafe. This will be reinitializing internal data converters which may be in use by another thread. Callback Safety --------------- Unsafe. This will be reinitializing internal data converters which may be in use by the callback. Remarks ------- For a duplex device, you can call this for only one side of the system. This is why the deviceType is specified as a parameter rather than deriving it from the device. You do not need to call this manually unless you are doing a custom backend, in which case you need only do it if you're manually performing rerouting or reinitialization. */ MA_API ma_result ma_device_post_init(ma_device* pDevice, ma_device_type deviceType, const ma_device_descriptor* pPlaybackDescriptor, const ma_device_descriptor* pCaptureDescriptor); /* Sets the master volume factor for the device. The volume factor must be between 0 (silence) and 1 (full volume). Use `ma_device_set_master_volume_db()` to use decibel notation, where 0 is full volume and values less than 0 decreases the volume. Parameters ---------- pDevice (in) A pointer to the device whose volume is being set. volume (in) The new volume factor. Must be >= 0. Return Value ------------ MA_SUCCESS if the volume was set successfully. MA_INVALID_ARGS if pDevice is NULL. MA_INVALID_ARGS if volume is negative. Thread Safety ------------- Safe. This just sets a local member of the device object. Callback Safety --------------- Safe. If you set the volume in the data callback, that data written to the output buffer will have the new volume applied. Remarks ------- This applies the volume factor across all channels. This does not change the operating system's volume. It only affects the volume for the given `ma_device` object's audio stream. See Also -------- ma_device_get_master_volume() ma_device_set_master_volume_db() ma_device_get_master_volume_db() */ MA_API ma_result ma_device_set_master_volume(ma_device* pDevice, float volume); /* Retrieves the master volume factor for the device. Parameters ---------- pDevice (in) A pointer to the device whose volume factor is being retrieved. pVolume (in) A pointer to the variable that will receive the volume factor. The returned value will be in the range of [0, 1]. Return Value ------------ MA_SUCCESS if successful. MA_INVALID_ARGS if pDevice is NULL. MA_INVALID_ARGS if pVolume is NULL. Thread Safety ------------- Safe. This just a simple member retrieval. Callback Safety --------------- Safe. Remarks ------- If an error occurs, `*pVolume` will be set to 0. See Also -------- ma_device_set_master_volume() ma_device_set_master_volume_gain_db() ma_device_get_master_volume_gain_db() */ MA_API ma_result ma_device_get_master_volume(ma_device* pDevice, float* pVolume); /* Sets the master volume for the device as gain in decibels. A gain of 0 is full volume, whereas a gain of < 0 will decrease the volume. Parameters ---------- pDevice (in) A pointer to the device whose gain is being set. gainDB (in) The new volume as gain in decibels. Must be less than or equal to 0, where 0 is full volume and anything less than 0 decreases the volume. Return Value ------------ MA_SUCCESS if the volume was set successfully. MA_INVALID_ARGS if pDevice is NULL. MA_INVALID_ARGS if the gain is > 0. Thread Safety ------------- Safe. This just sets a local member of the device object. Callback Safety --------------- Safe. If you set the volume in the data callback, that data written to the output buffer will have the new volume applied. Remarks ------- This applies the gain across all channels. This does not change the operating system's volume. It only affects the volume for the given `ma_device` object's audio stream. See Also -------- ma_device_get_master_volume_gain_db() ma_device_set_master_volume() ma_device_get_master_volume() */ MA_API ma_result ma_device_set_master_volume_db(ma_device* pDevice, float gainDB); /* Retrieves the master gain in decibels. Parameters ---------- pDevice (in) A pointer to the device whose gain is being retrieved. pGainDB (in) A pointer to the variable that will receive the gain in decibels. The returned value will be <= 0. Return Value ------------ MA_SUCCESS if successful. MA_INVALID_ARGS if pDevice is NULL. MA_INVALID_ARGS if pGainDB is NULL. Thread Safety ------------- Safe. This just a simple member retrieval. Callback Safety --------------- Safe. Remarks ------- If an error occurs, `*pGainDB` will be set to 0. See Also -------- ma_device_set_master_volume_db() ma_device_set_master_volume() ma_device_get_master_volume() */ MA_API ma_result ma_device_get_master_volume_db(ma_device* pDevice, float* pGainDB); /* Called from the data callback of asynchronous backends to allow miniaudio to process the data and fire the miniaudio data callback. Parameters ---------- pDevice (in) A pointer to device whose processing the data callback. pOutput (out) A pointer to the buffer that will receive the output PCM frame data. On a playback device this must not be NULL. On a duplex device this can be NULL, in which case pInput must not be NULL. pInput (in) A pointer to the buffer containing input PCM frame data. On a capture device this must not be NULL. On a duplex device this can be NULL, in which case `pOutput` must not be NULL. frameCount (in) The number of frames being processed. Return Value ------------ MA_SUCCESS if successful; any other result code otherwise. Thread Safety ------------- This function should only ever be called from the internal data callback of the backend. It is safe to call this simultaneously between a playback and capture device in duplex setups. Callback Safety --------------- Do not call this from the miniaudio data callback. It should only ever be called from the internal data callback of the backend. Remarks ------- If both `pOutput` and `pInput` are NULL, and error will be returned. In duplex scenarios, both `pOutput` and `pInput` can be non-NULL, in which case `pInput` will be processed first, followed by `pOutput`. If you are implementing a custom backend, and that backend uses a callback for data delivery, you'll need to call this from inside that callback. */ MA_API ma_result ma_device_handle_backend_data_callback(ma_device* pDevice, void* pOutput, const void* pInput, ma_uint32 frameCount); /* Calculates an appropriate buffer size from a descriptor, native sample rate and performance profile. This function is used by backends for helping determine an appropriately sized buffer to use with the device depending on the values of `periodSizeInFrames` and `periodSizeInMilliseconds` in the `pDescriptor` object. Since buffer size calculations based on time depends on the sample rate, a best guess at the device's native sample rate is also required which is where `nativeSampleRate` comes in. In addition, the performance profile is also needed for cases where both the period size in frames and milliseconds are both zero. Parameters ---------- pDescriptor (in) A pointer to device descriptor whose `periodSizeInFrames` and `periodSizeInMilliseconds` members will be used for the calculation of the buffer size. nativeSampleRate (in) The device's native sample rate. This is only ever used when the `periodSizeInFrames` member of `pDescriptor` is zero. In this case, `periodSizeInMilliseconds` will be used instead, in which case a sample rate is required to convert to a size in frames. performanceProfile (in) When both the `periodSizeInFrames` and `periodSizeInMilliseconds` members of `pDescriptor` are zero, miniaudio will fall back to a buffer size based on the performance profile. The profile to use for this calculation is determine by this parameter. Return Value ------------ The calculated buffer size in frames. Thread Safety ------------- This is safe so long as nothing modifies `pDescriptor` at the same time. However, this function should only ever be called from within the backend's device initialization routine and therefore shouldn't have any multithreading concerns. Callback Safety --------------- This is safe to call within the data callback, but there is no reason to ever do this. Remarks ------- If `nativeSampleRate` is zero, this function will fall back to `pDescriptor->sampleRate`. If that is also zero, `MA_DEFAULT_SAMPLE_RATE` will be used instead. */ MA_API ma_uint32 ma_calculate_buffer_size_in_frames_from_descriptor(const ma_device_descriptor* pDescriptor, ma_uint32 nativeSampleRate, ma_performance_profile performanceProfile); /* Retrieves a friendly name for a backend. */ MA_API const char* ma_get_backend_name(ma_backend backend); /* Retrieves the backend enum from the given name. */ MA_API ma_result ma_get_backend_from_name(const char* pBackendName, ma_backend* pBackend); /* Determines whether or not the given backend is available by the compilation environment. */ MA_API ma_bool32 ma_is_backend_enabled(ma_backend backend); /* Retrieves compile-time enabled backends. Parameters ---------- pBackends (out, optional) A pointer to the buffer that will receive the enabled backends. Set to NULL to retrieve the backend count. Setting the capacity of the buffer to `MA_BUFFER_COUNT` will guarantee it's large enough for all backends. backendCap (in) The capacity of the `pBackends` buffer. pBackendCount (out) A pointer to the variable that will receive the enabled backend count. Return Value ------------ MA_SUCCESS if successful. MA_INVALID_ARGS if `pBackendCount` is NULL. MA_NO_SPACE if the capacity of `pBackends` is not large enough. If `MA_NO_SPACE` is returned, the `pBackends` buffer will be filled with `*pBackendCount` values. Thread Safety ------------- Safe. Callback Safety --------------- Safe. Remarks ------- If you want to retrieve the number of backends so you can determine the capacity of `pBackends` buffer, you can call this function with `pBackends` set to NULL. This will also enumerate the null backend. If you don't want to include this you need to check for `ma_backend_null` when you enumerate over the returned backends and handle it appropriately. Alternatively, you can disable it at compile time with `MA_NO_NULL`. The returned backends are determined based on compile time settings, not the platform it's currently running on. For example, PulseAudio will be returned if it was enabled at compile time, even when the user doesn't actually have PulseAudio installed. Example 1 --------- The example below retrieves the enabled backend count using a fixed sized buffer allocated on the stack. The buffer is given a capacity of `MA_BACKEND_COUNT` which will guarantee it'll be large enough to store all available backends. Since `MA_BACKEND_COUNT` is always a relatively small value, this should be suitable for most scenarios. ``` ma_backend enabledBackends[MA_BACKEND_COUNT]; size_t enabledBackendCount; result = ma_get_enabled_backends(enabledBackends, MA_BACKEND_COUNT, &enabledBackendCount); if (result != MA_SUCCESS) { // Failed to retrieve enabled backends. Should never happen in this example since all inputs are valid. } ``` See Also -------- ma_is_backend_enabled() */ MA_API ma_result ma_get_enabled_backends(ma_backend* pBackends, size_t backendCap, size_t* pBackendCount); /* Determines whether or not loopback mode is support by a backend. */ MA_API ma_bool32 ma_is_loopback_supported(ma_backend backend); #endif /* MA_NO_DEVICE_IO */ /************************************************************************************************************************************************************ Utilities ************************************************************************************************************************************************************/ /* Calculates a buffer size in milliseconds from the specified number of frames and sample rate. */ MA_API ma_uint32 ma_calculate_buffer_size_in_milliseconds_from_frames(ma_uint32 bufferSizeInFrames, ma_uint32 sampleRate); /* Calculates a buffer size in frames from the specified number of milliseconds and sample rate. */ MA_API ma_uint32 ma_calculate_buffer_size_in_frames_from_milliseconds(ma_uint32 bufferSizeInMilliseconds, ma_uint32 sampleRate); /* Copies PCM frames from one buffer to another. */ MA_API void ma_copy_pcm_frames(void* dst, const void* src, ma_uint64 frameCount, ma_format format, ma_uint32 channels); /* Copies silent frames into the given buffer. Remarks ------- For all formats except `ma_format_u8`, the output buffer will be filled with 0. For `ma_format_u8` it will be filled with 128. The reason for this is that it makes more sense for the purpose of mixing to initialize it to the center point. */ MA_API void ma_silence_pcm_frames(void* p, ma_uint64 frameCount, ma_format format, ma_uint32 channels); /* Offsets a pointer by the specified number of PCM frames. */ MA_API void* ma_offset_pcm_frames_ptr(void* p, ma_uint64 offsetInFrames, ma_format format, ma_uint32 channels); MA_API const void* ma_offset_pcm_frames_const_ptr(const void* p, ma_uint64 offsetInFrames, ma_format format, ma_uint32 channels); static MA_INLINE float* ma_offset_pcm_frames_ptr_f32(float* p, ma_uint64 offsetInFrames, ma_uint32 channels) { return (float*)ma_offset_pcm_frames_ptr((void*)p, offsetInFrames, ma_format_f32, channels); } static MA_INLINE const float* ma_offset_pcm_frames_const_ptr_f32(const float* p, ma_uint64 offsetInFrames, ma_uint32 channels) { return (const float*)ma_offset_pcm_frames_const_ptr((const void*)p, offsetInFrames, ma_format_f32, channels); } /* Clips samples. */ MA_API void ma_clip_samples_u8(ma_uint8* pDst, const ma_int16* pSrc, ma_uint64 count); MA_API void ma_clip_samples_s16(ma_int16* pDst, const ma_int32* pSrc, ma_uint64 count); MA_API void ma_clip_samples_s24(ma_uint8* pDst, const ma_int64* pSrc, ma_uint64 count); MA_API void ma_clip_samples_s32(ma_int32* pDst, const ma_int64* pSrc, ma_uint64 count); MA_API void ma_clip_samples_f32(float* pDst, const float* pSrc, ma_uint64 count); MA_API void ma_clip_pcm_frames(void* pDst, const void* pSrc, ma_uint64 frameCount, ma_format format, ma_uint32 channels); /* Helper for applying a volume factor to samples. Note that the source and destination buffers can be the same, in which case it'll perform the operation in-place. */ MA_API void ma_copy_and_apply_volume_factor_u8(ma_uint8* pSamplesOut, const ma_uint8* pSamplesIn, ma_uint64 sampleCount, float factor); MA_API void ma_copy_and_apply_volume_factor_s16(ma_int16* pSamplesOut, const ma_int16* pSamplesIn, ma_uint64 sampleCount, float factor); MA_API void ma_copy_and_apply_volume_factor_s24(void* pSamplesOut, const void* pSamplesIn, ma_uint64 sampleCount, float factor); MA_API void ma_copy_and_apply_volume_factor_s32(ma_int32* pSamplesOut, const ma_int32* pSamplesIn, ma_uint64 sampleCount, float factor); MA_API void ma_copy_and_apply_volume_factor_f32(float* pSamplesOut, const float* pSamplesIn, ma_uint64 sampleCount, float factor); MA_API void ma_apply_volume_factor_u8(ma_uint8* pSamples, ma_uint64 sampleCount, float factor); MA_API void ma_apply_volume_factor_s16(ma_int16* pSamples, ma_uint64 sampleCount, float factor); MA_API void ma_apply_volume_factor_s24(void* pSamples, ma_uint64 sampleCount, float factor); MA_API void ma_apply_volume_factor_s32(ma_int32* pSamples, ma_uint64 sampleCount, float factor); MA_API void ma_apply_volume_factor_f32(float* pSamples, ma_uint64 sampleCount, float factor); MA_API void ma_copy_and_apply_volume_factor_pcm_frames_u8(ma_uint8* pFramesOut, const ma_uint8* pFramesIn, ma_uint64 frameCount, ma_uint32 channels, float factor); MA_API void ma_copy_and_apply_volume_factor_pcm_frames_s16(ma_int16* pFramesOut, const ma_int16* pFramesIn, ma_uint64 frameCount, ma_uint32 channels, float factor); MA_API void ma_copy_and_apply_volume_factor_pcm_frames_s24(void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount, ma_uint32 channels, float factor); MA_API void ma_copy_and_apply_volume_factor_pcm_frames_s32(ma_int32* pFramesOut, const ma_int32* pFramesIn, ma_uint64 frameCount, ma_uint32 channels, float factor); MA_API void ma_copy_and_apply_volume_factor_pcm_frames_f32(float* pFramesOut, const float* pFramesIn, ma_uint64 frameCount, ma_uint32 channels, float factor); MA_API void ma_copy_and_apply_volume_factor_pcm_frames(void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount, ma_format format, ma_uint32 channels, float factor); MA_API void ma_apply_volume_factor_pcm_frames_u8(ma_uint8* pFrames, ma_uint64 frameCount, ma_uint32 channels, float factor); MA_API void ma_apply_volume_factor_pcm_frames_s16(ma_int16* pFrames, ma_uint64 frameCount, ma_uint32 channels, float factor); MA_API void ma_apply_volume_factor_pcm_frames_s24(void* pFrames, ma_uint64 frameCount, ma_uint32 channels, float factor); MA_API void ma_apply_volume_factor_pcm_frames_s32(ma_int32* pFrames, ma_uint64 frameCount, ma_uint32 channels, float factor); MA_API void ma_apply_volume_factor_pcm_frames_f32(float* pFrames, ma_uint64 frameCount, ma_uint32 channels, float factor); MA_API void ma_apply_volume_factor_pcm_frames(void* pFrames, ma_uint64 frameCount, ma_format format, ma_uint32 channels, float factor); MA_API void ma_copy_and_apply_volume_factor_per_channel_f32(float* pFramesOut, const float* pFramesIn, ma_uint64 frameCount, ma_uint32 channels, float* pChannelGains); MA_API void ma_copy_and_apply_volume_and_clip_samples_u8(ma_uint8* pDst, const ma_int16* pSrc, ma_uint64 count, float volume); MA_API void ma_copy_and_apply_volume_and_clip_samples_s16(ma_int16* pDst, const ma_int32* pSrc, ma_uint64 count, float volume); MA_API void ma_copy_and_apply_volume_and_clip_samples_s24(ma_uint8* pDst, const ma_int64* pSrc, ma_uint64 count, float volume); MA_API void ma_copy_and_apply_volume_and_clip_samples_s32(ma_int32* pDst, const ma_int64* pSrc, ma_uint64 count, float volume); MA_API void ma_copy_and_apply_volume_and_clip_samples_f32(float* pDst, const float* pSrc, ma_uint64 count, float volume); MA_API void ma_copy_and_apply_volume_and_clip_pcm_frames(void* pDst, const void* pSrc, ma_uint64 frameCount, ma_format format, ma_uint32 channels, float volume); /* Helper for converting a linear factor to gain in decibels. */ MA_API float ma_volume_linear_to_db(float factor); /* Helper for converting gain in decibels to a linear factor. */ MA_API float ma_volume_db_to_linear(float gain); /* Mixes the specified number of frames in floating point format with a volume factor. This will run on an optimized path when the volume is equal to 1. */ MA_API ma_result ma_mix_pcm_frames_f32(float* pDst, const float* pSrc, ma_uint64 frameCount, ma_uint32 channels, float volume); /************************************************************************************************************************************************************ VFS === The VFS object (virtual file system) is what's used to customize file access. This is useful in cases where stdio FILE* based APIs may not be entirely appropriate for a given situation. ************************************************************************************************************************************************************/ typedef void ma_vfs; typedef ma_handle ma_vfs_file; typedef enum { MA_OPEN_MODE_READ = 0x00000001, MA_OPEN_MODE_WRITE = 0x00000002 } ma_open_mode_flags; typedef enum { ma_seek_origin_start, ma_seek_origin_current, ma_seek_origin_end /* Not used by decoders. */ } ma_seek_origin; typedef struct { ma_uint64 sizeInBytes; } ma_file_info; typedef struct { ma_result (* onOpen) (ma_vfs* pVFS, const char* pFilePath, ma_uint32 openMode, ma_vfs_file* pFile); ma_result (* onOpenW)(ma_vfs* pVFS, const wchar_t* pFilePath, ma_uint32 openMode, ma_vfs_file* pFile); ma_result (* onClose)(ma_vfs* pVFS, ma_vfs_file file); ma_result (* onRead) (ma_vfs* pVFS, ma_vfs_file file, void* pDst, size_t sizeInBytes, size_t* pBytesRead); ma_result (* onWrite)(ma_vfs* pVFS, ma_vfs_file file, const void* pSrc, size_t sizeInBytes, size_t* pBytesWritten); ma_result (* onSeek) (ma_vfs* pVFS, ma_vfs_file file, ma_int64 offset, ma_seek_origin origin); ma_result (* onTell) (ma_vfs* pVFS, ma_vfs_file file, ma_int64* pCursor); ma_result (* onInfo) (ma_vfs* pVFS, ma_vfs_file file, ma_file_info* pInfo); } ma_vfs_callbacks; MA_API ma_result ma_vfs_open(ma_vfs* pVFS, const char* pFilePath, ma_uint32 openMode, ma_vfs_file* pFile); MA_API ma_result ma_vfs_open_w(ma_vfs* pVFS, const wchar_t* pFilePath, ma_uint32 openMode, ma_vfs_file* pFile); MA_API ma_result ma_vfs_close(ma_vfs* pVFS, ma_vfs_file file); MA_API ma_result ma_vfs_read(ma_vfs* pVFS, ma_vfs_file file, void* pDst, size_t sizeInBytes, size_t* pBytesRead); MA_API ma_result ma_vfs_write(ma_vfs* pVFS, ma_vfs_file file, const void* pSrc, size_t sizeInBytes, size_t* pBytesWritten); MA_API ma_result ma_vfs_seek(ma_vfs* pVFS, ma_vfs_file file, ma_int64 offset, ma_seek_origin origin); MA_API ma_result ma_vfs_tell(ma_vfs* pVFS, ma_vfs_file file, ma_int64* pCursor); MA_API ma_result ma_vfs_info(ma_vfs* pVFS, ma_vfs_file file, ma_file_info* pInfo); MA_API ma_result ma_vfs_open_and_read_file(ma_vfs* pVFS, const char* pFilePath, void** ppData, size_t* pSize, const ma_allocation_callbacks* pAllocationCallbacks); typedef struct { ma_vfs_callbacks cb; ma_allocation_callbacks allocationCallbacks; /* Only used for the wchar_t version of open() on non-Windows platforms. */ } ma_default_vfs; MA_API ma_result ma_default_vfs_init(ma_default_vfs* pVFS, const ma_allocation_callbacks* pAllocationCallbacks); typedef ma_result (* ma_read_proc)(void* pUserData, void* pBufferOut, size_t bytesToRead, size_t* pBytesRead); typedef ma_result (* ma_seek_proc)(void* pUserData, ma_int64 offset, ma_seek_origin origin); typedef ma_result (* ma_tell_proc)(void* pUserData, ma_int64* pCursor); #if !defined(MA_NO_DECODING) || !defined(MA_NO_ENCODING) typedef enum { ma_encoding_format_unknown = 0, ma_encoding_format_wav, ma_encoding_format_flac, ma_encoding_format_mp3, ma_encoding_format_vorbis } ma_encoding_format; #endif /************************************************************************************************************************************************************ Decoding ======== Decoders are independent of the main device API. Decoding APIs can be called freely inside the device's data callback, but they are not thread safe unless you do your own synchronization. ************************************************************************************************************************************************************/ #ifndef MA_NO_DECODING typedef struct ma_decoder ma_decoder; typedef struct { ma_format preferredFormat; ma_uint32 seekPointCount; /* Set to > 0 to generate a seektable if the decoding backend supports it. */ } ma_decoding_backend_config; MA_API ma_decoding_backend_config ma_decoding_backend_config_init(ma_format preferredFormat, ma_uint32 seekPointCount); typedef struct { ma_result (* onInit )(void* pUserData, ma_read_proc onRead, ma_seek_proc onSeek, ma_tell_proc onTell, void* pReadSeekTellUserData, const ma_decoding_backend_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_data_source** ppBackend); ma_result (* onInitFile )(void* pUserData, const char* pFilePath, const ma_decoding_backend_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_data_source** ppBackend); /* Optional. */ ma_result (* onInitFileW )(void* pUserData, const wchar_t* pFilePath, const ma_decoding_backend_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_data_source** ppBackend); /* Optional. */ ma_result (* onInitMemory)(void* pUserData, const void* pData, size_t dataSize, const ma_decoding_backend_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_data_source** ppBackend); /* Optional. */ void (* onUninit )(void* pUserData, ma_data_source* pBackend, const ma_allocation_callbacks* pAllocationCallbacks); } ma_decoding_backend_vtable; typedef ma_result (* ma_decoder_read_proc)(ma_decoder* pDecoder, void* pBufferOut, size_t bytesToRead, size_t* pBytesRead); /* Returns the number of bytes read. */ typedef ma_result (* ma_decoder_seek_proc)(ma_decoder* pDecoder, ma_int64 byteOffset, ma_seek_origin origin); typedef ma_result (* ma_decoder_tell_proc)(ma_decoder* pDecoder, ma_int64* pCursor); typedef struct { ma_format format; /* Set to 0 or ma_format_unknown to use the stream's internal format. */ ma_uint32 channels; /* Set to 0 to use the stream's internal channels. */ ma_uint32 sampleRate; /* Set to 0 to use the stream's internal sample rate. */ ma_channel* pChannelMap; ma_channel_mix_mode channelMixMode; ma_dither_mode ditherMode; ma_resampler_config resampling; ma_allocation_callbacks allocationCallbacks; ma_encoding_format encodingFormat; ma_uint32 seekPointCount; /* When set to > 0, specifies the number of seek points to use for the generation of a seek table. Not all decoding backends support this. */ ma_decoding_backend_vtable** ppCustomBackendVTables; ma_uint32 customBackendCount; void* pCustomBackendUserData; } ma_decoder_config; struct ma_decoder { ma_data_source_base ds; ma_data_source* pBackend; /* The decoding backend we'll be pulling data from. */ const ma_decoding_backend_vtable* pBackendVTable; /* The vtable for the decoding backend. This needs to be stored so we can access the onUninit() callback. */ void* pBackendUserData; ma_decoder_read_proc onRead; ma_decoder_seek_proc onSeek; ma_decoder_tell_proc onTell; void* pUserData; ma_uint64 readPointerInPCMFrames; /* In output sample rate. Used for keeping track of how many frames are available for decoding. */ ma_format outputFormat; ma_uint32 outputChannels; ma_uint32 outputSampleRate; ma_data_converter converter; /* Data conversion is achieved by running frames through this. */ void* pInputCache; /* In input format. Can be null if it's not needed. */ ma_uint64 inputCacheCap; /* The capacity of the input cache. */ ma_uint64 inputCacheConsumed; /* The number of frames that have been consumed in the cache. Used for determining the next valid frame. */ ma_uint64 inputCacheRemaining; /* The number of valid frames remaining in the cahce. */ ma_allocation_callbacks allocationCallbacks; union { struct { ma_vfs* pVFS; ma_vfs_file file; } vfs; struct { const ma_uint8* pData; size_t dataSize; size_t currentReadPos; } memory; /* Only used for decoders that were opened against a block of memory. */ } data; }; MA_API ma_decoder_config ma_decoder_config_init(ma_format outputFormat, ma_uint32 outputChannels, ma_uint32 outputSampleRate); MA_API ma_decoder_config ma_decoder_config_init_default(void); MA_API ma_result ma_decoder_init(ma_decoder_read_proc onRead, ma_decoder_seek_proc onSeek, void* pUserData, const ma_decoder_config* pConfig, ma_decoder* pDecoder); MA_API ma_result ma_decoder_init_memory(const void* pData, size_t dataSize, const ma_decoder_config* pConfig, ma_decoder* pDecoder); MA_API ma_result ma_decoder_init_vfs(ma_vfs* pVFS, const char* pFilePath, const ma_decoder_config* pConfig, ma_decoder* pDecoder); MA_API ma_result ma_decoder_init_vfs_w(ma_vfs* pVFS, const wchar_t* pFilePath, const ma_decoder_config* pConfig, ma_decoder* pDecoder); MA_API ma_result ma_decoder_init_file(const char* pFilePath, const ma_decoder_config* pConfig, ma_decoder* pDecoder); MA_API ma_result ma_decoder_init_file_w(const wchar_t* pFilePath, const ma_decoder_config* pConfig, ma_decoder* pDecoder); /* Uninitializes a decoder. */ MA_API ma_result ma_decoder_uninit(ma_decoder* pDecoder); /* Reads PCM frames from the given decoder. This is not thread safe without your own synchronization. */ MA_API ma_result ma_decoder_read_pcm_frames(ma_decoder* pDecoder, void* pFramesOut, ma_uint64 frameCount, ma_uint64* pFramesRead); /* Seeks to a PCM frame based on it's absolute index. This is not thread safe without your own synchronization. */ MA_API ma_result ma_decoder_seek_to_pcm_frame(ma_decoder* pDecoder, ma_uint64 frameIndex); /* Retrieves the decoder's output data format. */ MA_API ma_result ma_decoder_get_data_format(ma_decoder* pDecoder, ma_format* pFormat, ma_uint32* pChannels, ma_uint32* pSampleRate, ma_channel* pChannelMap, size_t channelMapCap); /* Retrieves the current position of the read cursor in PCM frames. */ MA_API ma_result ma_decoder_get_cursor_in_pcm_frames(ma_decoder* pDecoder, ma_uint64* pCursor); /* Retrieves the length of the decoder in PCM frames. Do not call this on streams of an undefined length, such as internet radio. If the length is unknown or an error occurs, 0 will be returned. This will always return 0 for Vorbis decoders. This is due to a limitation with stb_vorbis in push mode which is what miniaudio uses internally. For MP3's, this will decode the entire file. Do not call this in time critical scenarios. This function is not thread safe without your own synchronization. */ MA_API ma_result ma_decoder_get_length_in_pcm_frames(ma_decoder* pDecoder, ma_uint64* pLength); /* Retrieves the number of frames that can be read before reaching the end. This calls `ma_decoder_get_length_in_pcm_frames()` so you need to be aware of the rules for that function, in particular ensuring you do not call it on streams of an undefined length, such as internet radio. If the total length of the decoder cannot be retrieved, such as with Vorbis decoders, `MA_NOT_IMPLEMENTED` will be returned. */ MA_API ma_result ma_decoder_get_available_frames(ma_decoder* pDecoder, ma_uint64* pAvailableFrames); /* Helper for opening and decoding a file into a heap allocated block of memory. Free the returned pointer with ma_free(). On input, pConfig should be set to what you want. On output it will be set to what you got. */ MA_API ma_result ma_decode_from_vfs(ma_vfs* pVFS, const char* pFilePath, ma_decoder_config* pConfig, ma_uint64* pFrameCountOut, void** ppPCMFramesOut); MA_API ma_result ma_decode_file(const char* pFilePath, ma_decoder_config* pConfig, ma_uint64* pFrameCountOut, void** ppPCMFramesOut); MA_API ma_result ma_decode_memory(const void* pData, size_t dataSize, ma_decoder_config* pConfig, ma_uint64* pFrameCountOut, void** ppPCMFramesOut); #endif /* MA_NO_DECODING */ /************************************************************************************************************************************************************ Encoding ======== Encoders do not perform any format conversion for you. If your target format does not support the format, and error will be returned. ************************************************************************************************************************************************************/ #ifndef MA_NO_ENCODING typedef struct ma_encoder ma_encoder; typedef ma_result (* ma_encoder_write_proc) (ma_encoder* pEncoder, const void* pBufferIn, size_t bytesToWrite, size_t* pBytesWritten); typedef ma_result (* ma_encoder_seek_proc) (ma_encoder* pEncoder, ma_int64 offset, ma_seek_origin origin); typedef ma_result (* ma_encoder_init_proc) (ma_encoder* pEncoder); typedef void (* ma_encoder_uninit_proc) (ma_encoder* pEncoder); typedef ma_result (* ma_encoder_write_pcm_frames_proc)(ma_encoder* pEncoder, const void* pFramesIn, ma_uint64 frameCount, ma_uint64* pFramesWritten); typedef struct { ma_encoding_format encodingFormat; ma_format format; ma_uint32 channels; ma_uint32 sampleRate; ma_allocation_callbacks allocationCallbacks; } ma_encoder_config; MA_API ma_encoder_config ma_encoder_config_init(ma_encoding_format encodingFormat, ma_format format, ma_uint32 channels, ma_uint32 sampleRate); struct ma_encoder { ma_encoder_config config; ma_encoder_write_proc onWrite; ma_encoder_seek_proc onSeek; ma_encoder_init_proc onInit; ma_encoder_uninit_proc onUninit; ma_encoder_write_pcm_frames_proc onWritePCMFrames; void* pUserData; void* pInternalEncoder; union { struct { ma_vfs* pVFS; ma_vfs_file file; } vfs; } data; }; MA_API ma_result ma_encoder_init(ma_encoder_write_proc onWrite, ma_encoder_seek_proc onSeek, void* pUserData, const ma_encoder_config* pConfig, ma_encoder* pEncoder); MA_API ma_result ma_encoder_init_vfs(ma_vfs* pVFS, const char* pFilePath, const ma_encoder_config* pConfig, ma_encoder* pEncoder); MA_API ma_result ma_encoder_init_vfs_w(ma_vfs* pVFS, const wchar_t* pFilePath, const ma_encoder_config* pConfig, ma_encoder* pEncoder); MA_API ma_result ma_encoder_init_file(const char* pFilePath, const ma_encoder_config* pConfig, ma_encoder* pEncoder); MA_API ma_result ma_encoder_init_file_w(const wchar_t* pFilePath, const ma_encoder_config* pConfig, ma_encoder* pEncoder); MA_API void ma_encoder_uninit(ma_encoder* pEncoder); MA_API ma_result ma_encoder_write_pcm_frames(ma_encoder* pEncoder, const void* pFramesIn, ma_uint64 frameCount, ma_uint64* pFramesWritten); #endif /* MA_NO_ENCODING */ /************************************************************************************************************************************************************ Generation ************************************************************************************************************************************************************/ #ifndef MA_NO_GENERATION typedef enum { ma_waveform_type_sine, ma_waveform_type_square, ma_waveform_type_triangle, ma_waveform_type_sawtooth } ma_waveform_type; typedef struct { ma_format format; ma_uint32 channels; ma_uint32 sampleRate; ma_waveform_type type; double amplitude; double frequency; } ma_waveform_config; MA_API ma_waveform_config ma_waveform_config_init(ma_format format, ma_uint32 channels, ma_uint32 sampleRate, ma_waveform_type type, double amplitude, double frequency); typedef struct { ma_data_source_base ds; ma_waveform_config config; double advance; double time; } ma_waveform; MA_API ma_result ma_waveform_init(const ma_waveform_config* pConfig, ma_waveform* pWaveform); MA_API void ma_waveform_uninit(ma_waveform* pWaveform); MA_API ma_result ma_waveform_read_pcm_frames(ma_waveform* pWaveform, void* pFramesOut, ma_uint64 frameCount, ma_uint64* pFramesRead); MA_API ma_result ma_waveform_seek_to_pcm_frame(ma_waveform* pWaveform, ma_uint64 frameIndex); MA_API ma_result ma_waveform_set_amplitude(ma_waveform* pWaveform, double amplitude); MA_API ma_result ma_waveform_set_frequency(ma_waveform* pWaveform, double frequency); MA_API ma_result ma_waveform_set_type(ma_waveform* pWaveform, ma_waveform_type type); MA_API ma_result ma_waveform_set_sample_rate(ma_waveform* pWaveform, ma_uint32 sampleRate); typedef struct { ma_format format; ma_uint32 channels; ma_uint32 sampleRate; double dutyCycle; double amplitude; double frequency; } ma_pulsewave_config; MA_API ma_pulsewave_config ma_pulsewave_config_init(ma_format format, ma_uint32 channels, ma_uint32 sampleRate, double dutyCycle, double amplitude, double frequency); typedef struct { ma_waveform waveform; ma_pulsewave_config config; } ma_pulsewave; MA_API ma_result ma_pulsewave_init(const ma_pulsewave_config* pConfig, ma_pulsewave* pWaveform); MA_API void ma_pulsewave_uninit(ma_pulsewave* pWaveform); MA_API ma_result ma_pulsewave_read_pcm_frames(ma_pulsewave* pWaveform, void* pFramesOut, ma_uint64 frameCount, ma_uint64* pFramesRead); MA_API ma_result ma_pulsewave_seek_to_pcm_frame(ma_pulsewave* pWaveform, ma_uint64 frameIndex); MA_API ma_result ma_pulsewave_set_amplitude(ma_pulsewave* pWaveform, double amplitude); MA_API ma_result ma_pulsewave_set_frequency(ma_pulsewave* pWaveform, double frequency); MA_API ma_result ma_pulsewave_set_sample_rate(ma_pulsewave* pWaveform, ma_uint32 sampleRate); MA_API ma_result ma_pulsewave_set_duty_cycle(ma_pulsewave* pWaveform, double dutyCycle); typedef enum { ma_noise_type_white, ma_noise_type_pink, ma_noise_type_brownian } ma_noise_type; typedef struct { ma_format format; ma_uint32 channels; ma_noise_type type; ma_int32 seed; double amplitude; ma_bool32 duplicateChannels; } ma_noise_config; MA_API ma_noise_config ma_noise_config_init(ma_format format, ma_uint32 channels, ma_noise_type type, ma_int32 seed, double amplitude); typedef struct { ma_data_source_base ds; ma_noise_config config; ma_lcg lcg; union { struct { double** bin; double* accumulation; ma_uint32* counter; } pink; struct { double* accumulation; } brownian; } state; /* Memory management. */ void* _pHeap; ma_bool32 _ownsHeap; } ma_noise; MA_API ma_result ma_noise_get_heap_size(const ma_noise_config* pConfig, size_t* pHeapSizeInBytes); MA_API ma_result ma_noise_init_preallocated(const ma_noise_config* pConfig, void* pHeap, ma_noise* pNoise); MA_API ma_result ma_noise_init(const ma_noise_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_noise* pNoise); MA_API void ma_noise_uninit(ma_noise* pNoise, const ma_allocation_callbacks* pAllocationCallbacks); MA_API ma_result ma_noise_read_pcm_frames(ma_noise* pNoise, void* pFramesOut, ma_uint64 frameCount, ma_uint64* pFramesRead); MA_API ma_result ma_noise_set_amplitude(ma_noise* pNoise, double amplitude); MA_API ma_result ma_noise_set_seed(ma_noise* pNoise, ma_int32 seed); MA_API ma_result ma_noise_set_type(ma_noise* pNoise, ma_noise_type type); #endif /* MA_NO_GENERATION */ /************************************************************************************************************************************************************ Resource Manager ************************************************************************************************************************************************************/ /* The resource manager cannot be enabled if there is no decoder. */ #if !defined(MA_NO_RESOURCE_MANAGER) && defined(MA_NO_DECODING) #define MA_NO_RESOURCE_MANAGER #endif #ifndef MA_NO_RESOURCE_MANAGER typedef struct ma_resource_manager ma_resource_manager; typedef struct ma_resource_manager_data_buffer_node ma_resource_manager_data_buffer_node; typedef struct ma_resource_manager_data_buffer ma_resource_manager_data_buffer; typedef struct ma_resource_manager_data_stream ma_resource_manager_data_stream; typedef struct ma_resource_manager_data_source ma_resource_manager_data_source; typedef enum { MA_RESOURCE_MANAGER_DATA_SOURCE_FLAG_STREAM = 0x00000001, /* When set, does not load the entire data source in memory. Disk I/O will happen on job threads. */ MA_RESOURCE_MANAGER_DATA_SOURCE_FLAG_DECODE = 0x00000002, /* Decode data before storing in memory. When set, decoding is done at the resource manager level rather than the mixing thread. Results in faster mixing, but higher memory usage. */ MA_RESOURCE_MANAGER_DATA_SOURCE_FLAG_ASYNC = 0x00000004, /* When set, the resource manager will load the data source asynchronously. */ MA_RESOURCE_MANAGER_DATA_SOURCE_FLAG_WAIT_INIT = 0x00000008, /* When set, waits for initialization of the underlying data source before returning from ma_resource_manager_data_source_init(). */ MA_RESOURCE_MANAGER_DATA_SOURCE_FLAG_UNKNOWN_LENGTH = 0x00000010 /* Gives the resource manager a hint that the length of the data source is unknown and calling `ma_data_source_get_length_in_pcm_frames()` should be avoided. */ } ma_resource_manager_data_source_flags; /* Pipeline notifications used by the resource manager. Made up of both an async notification and a fence, both of which are optional. */ typedef struct { ma_async_notification* pNotification; ma_fence* pFence; } ma_resource_manager_pipeline_stage_notification; typedef struct { ma_resource_manager_pipeline_stage_notification init; /* Initialization of the decoder. */ ma_resource_manager_pipeline_stage_notification done; /* Decoding fully completed. */ } ma_resource_manager_pipeline_notifications; MA_API ma_resource_manager_pipeline_notifications ma_resource_manager_pipeline_notifications_init(void); /* BEGIN BACKWARDS COMPATIBILITY */ /* TODO: Remove this block in version 0.12. */ #if 1 #define ma_resource_manager_job ma_job #define ma_resource_manager_job_init ma_job_init #define MA_JOB_TYPE_RESOURCE_MANAGER_QUEUE_FLAG_NON_BLOCKING MA_JOB_QUEUE_FLAG_NON_BLOCKING #define ma_resource_manager_job_queue_config ma_job_queue_config #define ma_resource_manager_job_queue_config_init ma_job_queue_config_init #define ma_resource_manager_job_queue ma_job_queue #define ma_resource_manager_job_queue_get_heap_size ma_job_queue_get_heap_size #define ma_resource_manager_job_queue_init_preallocated ma_job_queue_init_preallocated #define ma_resource_manager_job_queue_init ma_job_queue_init #define ma_resource_manager_job_queue_uninit ma_job_queue_uninit #define ma_resource_manager_job_queue_post ma_job_queue_post #define ma_resource_manager_job_queue_next ma_job_queue_next #endif /* END BACKWARDS COMPATIBILITY */ /* Maximum job thread count will be restricted to this, but this may be removed later and replaced with a heap allocation thereby removing any limitation. */ #ifndef MA_RESOURCE_MANAGER_MAX_JOB_THREAD_COUNT #define MA_RESOURCE_MANAGER_MAX_JOB_THREAD_COUNT 64 #endif typedef enum { /* Indicates ma_resource_manager_next_job() should not block. Only valid when the job thread count is 0. */ MA_RESOURCE_MANAGER_FLAG_NON_BLOCKING = 0x00000001, /* Disables any kind of multithreading. Implicitly enables MA_RESOURCE_MANAGER_FLAG_NON_BLOCKING. */ MA_RESOURCE_MANAGER_FLAG_NO_THREADING = 0x00000002 } ma_resource_manager_flags; typedef struct { const char* pFilePath; const wchar_t* pFilePathW; const ma_resource_manager_pipeline_notifications* pNotifications; ma_uint64 initialSeekPointInPCMFrames; ma_uint64 rangeBegInPCMFrames; ma_uint64 rangeEndInPCMFrames; ma_uint64 loopPointBegInPCMFrames; ma_uint64 loopPointEndInPCMFrames; ma_bool32 isLooping; ma_uint32 flags; } ma_resource_manager_data_source_config; MA_API ma_resource_manager_data_source_config ma_resource_manager_data_source_config_init(void); typedef enum { ma_resource_manager_data_supply_type_unknown = 0, /* Used for determining whether or the data supply has been initialized. */ ma_resource_manager_data_supply_type_encoded, /* Data supply is an encoded buffer. Connector is ma_decoder. */ ma_resource_manager_data_supply_type_decoded, /* Data supply is a decoded buffer. Connector is ma_audio_buffer. */ ma_resource_manager_data_supply_type_decoded_paged /* Data supply is a linked list of decoded buffers. Connector is ma_paged_audio_buffer. */ } ma_resource_manager_data_supply_type; typedef struct { MA_ATOMIC(4, ma_resource_manager_data_supply_type) type; /* Read and written from different threads so needs to be accessed atomically. */ union { struct { const void* pData; size_t sizeInBytes; } encoded; struct { const void* pData; ma_uint64 totalFrameCount; ma_uint64 decodedFrameCount; ma_format format; ma_uint32 channels; ma_uint32 sampleRate; } decoded; struct { ma_paged_audio_buffer_data data; ma_uint64 decodedFrameCount; ma_uint32 sampleRate; } decodedPaged; } backend; } ma_resource_manager_data_supply; struct ma_resource_manager_data_buffer_node { ma_uint32 hashedName32; /* The hashed name. This is the key. */ ma_uint32 refCount; MA_ATOMIC(4, ma_result) result; /* Result from asynchronous loading. When loading set to MA_BUSY. When fully loaded set to MA_SUCCESS. When deleting set to MA_UNAVAILABLE. */ MA_ATOMIC(4, ma_uint32) executionCounter; /* For allocating execution orders for jobs. */ MA_ATOMIC(4, ma_uint32) executionPointer; /* For managing the order of execution for asynchronous jobs relating to this object. Incremented as jobs complete processing. */ ma_bool32 isDataOwnedByResourceManager; /* Set to true when the underlying data buffer was allocated the resource manager. Set to false if it is owned by the application (via ma_resource_manager_register_*()). */ ma_resource_manager_data_supply data; ma_resource_manager_data_buffer_node* pParent; ma_resource_manager_data_buffer_node* pChildLo; ma_resource_manager_data_buffer_node* pChildHi; }; struct ma_resource_manager_data_buffer { ma_data_source_base ds; /* Base data source. A data buffer is a data source. */ ma_resource_manager* pResourceManager; /* A pointer to the resource manager that owns this buffer. */ ma_resource_manager_data_buffer_node* pNode; /* The data node. This is reference counted and is what supplies the data. */ ma_uint32 flags; /* The flags that were passed used to initialize the buffer. */ MA_ATOMIC(4, ma_uint32) executionCounter; /* For allocating execution orders for jobs. */ MA_ATOMIC(4, ma_uint32) executionPointer; /* For managing the order of execution for asynchronous jobs relating to this object. Incremented as jobs complete processing. */ ma_uint64 seekTargetInPCMFrames; /* Only updated by the public API. Never written nor read from the job thread. */ ma_bool32 seekToCursorOnNextRead; /* On the next read we need to seek to the frame cursor. */ MA_ATOMIC(4, ma_result) result; /* Keeps track of a result of decoding. Set to MA_BUSY while the buffer is still loading. Set to MA_SUCCESS when loading is finished successfully. Otherwise set to some other code. */ MA_ATOMIC(4, ma_bool32) isLooping; /* Can be read and written by different threads at the same time. Must be used atomically. */ ma_atomic_bool32 isConnectorInitialized; /* Used for asynchronous loading to ensure we don't try to initialize the connector multiple times while waiting for the node to fully load. */ union { ma_decoder decoder; /* Supply type is ma_resource_manager_data_supply_type_encoded */ ma_audio_buffer buffer; /* Supply type is ma_resource_manager_data_supply_type_decoded */ ma_paged_audio_buffer pagedBuffer; /* Supply type is ma_resource_manager_data_supply_type_decoded_paged */ } connector; /* Connects this object to the node's data supply. */ }; struct ma_resource_manager_data_stream { ma_data_source_base ds; /* Base data source. A data stream is a data source. */ ma_resource_manager* pResourceManager; /* A pointer to the resource manager that owns this data stream. */ ma_uint32 flags; /* The flags that were passed used to initialize the stream. */ ma_decoder decoder; /* Used for filling pages with data. This is only ever accessed by the job thread. The public API should never touch this. */ ma_bool32 isDecoderInitialized; /* Required for determining whether or not the decoder should be uninitialized in MA_JOB_TYPE_RESOURCE_MANAGER_FREE_DATA_STREAM. */ ma_uint64 totalLengthInPCMFrames; /* This is calculated when first loaded by the MA_JOB_TYPE_RESOURCE_MANAGER_LOAD_DATA_STREAM. */ ma_uint32 relativeCursor; /* The playback cursor, relative to the current page. Only ever accessed by the public API. Never accessed by the job thread. */ MA_ATOMIC(8, ma_uint64) absoluteCursor; /* The playback cursor, in absolute position starting from the start of the file. */ ma_uint32 currentPageIndex; /* Toggles between 0 and 1. Index 0 is the first half of pPageData. Index 1 is the second half. Only ever accessed by the public API. Never accessed by the job thread. */ MA_ATOMIC(4, ma_uint32) executionCounter; /* For allocating execution orders for jobs. */ MA_ATOMIC(4, ma_uint32) executionPointer; /* For managing the order of execution for asynchronous jobs relating to this object. Incremented as jobs complete processing. */ /* Written by the public API, read by the job thread. */ MA_ATOMIC(4, ma_bool32) isLooping; /* Whether or not the stream is looping. It's important to set the looping flag at the data stream level for smooth loop transitions. */ /* Written by the job thread, read by the public API. */ void* pPageData; /* Buffer containing the decoded data of each page. Allocated once at initialization time. */ MA_ATOMIC(4, ma_uint32) pageFrameCount[2]; /* The number of valid PCM frames in each page. Used to determine the last valid frame. */ /* Written and read by both the public API and the job thread. These must be atomic. */ MA_ATOMIC(4, ma_result) result; /* Result from asynchronous loading. When loading set to MA_BUSY. When initialized set to MA_SUCCESS. When deleting set to MA_UNAVAILABLE. If an error occurs when loading, set to an error code. */ MA_ATOMIC(4, ma_bool32) isDecoderAtEnd; /* Whether or not the decoder has reached the end. */ MA_ATOMIC(4, ma_bool32) isPageValid[2]; /* Booleans to indicate whether or not a page is valid. Set to false by the public API, set to true by the job thread. Set to false as the pages are consumed, true when they are filled. */ MA_ATOMIC(4, ma_bool32) seekCounter; /* When 0, no seeking is being performed. When > 0, a seek is being performed and reading should be delayed with MA_BUSY. */ }; struct ma_resource_manager_data_source { union { ma_resource_manager_data_buffer buffer; ma_resource_manager_data_stream stream; } backend; /* Must be the first item because we need the first item to be the data source callbacks for the buffer or stream. */ ma_uint32 flags; /* The flags that were passed in to ma_resource_manager_data_source_init(). */ MA_ATOMIC(4, ma_uint32) executionCounter; /* For allocating execution orders for jobs. */ MA_ATOMIC(4, ma_uint32) executionPointer; /* For managing the order of execution for asynchronous jobs relating to this object. Incremented as jobs complete processing. */ }; typedef struct { ma_allocation_callbacks allocationCallbacks; ma_log* pLog; ma_format decodedFormat; /* The decoded format to use. Set to ma_format_unknown (default) to use the file's native format. */ ma_uint32 decodedChannels; /* The decoded channel count to use. Set to 0 (default) to use the file's native channel count. */ ma_uint32 decodedSampleRate; /* the decoded sample rate to use. Set to 0 (default) to use the file's native sample rate. */ ma_uint32 jobThreadCount; /* Set to 0 if you want to self-manage your job threads. Defaults to 1. */ size_t jobThreadStackSize; ma_uint32 jobQueueCapacity; /* The maximum number of jobs that can fit in the queue at a time. Defaults to MA_JOB_TYPE_RESOURCE_MANAGER_QUEUE_CAPACITY. Cannot be zero. */ ma_uint32 flags; ma_vfs* pVFS; /* Can be NULL in which case defaults will be used. */ ma_decoding_backend_vtable** ppCustomDecodingBackendVTables; ma_uint32 customDecodingBackendCount; void* pCustomDecodingBackendUserData; } ma_resource_manager_config; MA_API ma_resource_manager_config ma_resource_manager_config_init(void); struct ma_resource_manager { ma_resource_manager_config config; ma_resource_manager_data_buffer_node* pRootDataBufferNode; /* The root buffer in the binary tree. */ #ifndef MA_NO_THREADING ma_mutex dataBufferBSTLock; /* For synchronizing access to the data buffer binary tree. */ ma_thread jobThreads[MA_RESOURCE_MANAGER_MAX_JOB_THREAD_COUNT]; /* The threads for executing jobs. */ #endif ma_job_queue jobQueue; /* Multi-consumer, multi-producer job queue for managing jobs for asynchronous decoding and streaming. */ ma_default_vfs defaultVFS; /* Only used if a custom VFS is not specified. */ ma_log log; /* Only used if no log was specified in the config. */ }; /* Init. */ MA_API ma_result ma_resource_manager_init(const ma_resource_manager_config* pConfig, ma_resource_manager* pResourceManager); MA_API void ma_resource_manager_uninit(ma_resource_manager* pResourceManager); MA_API ma_log* ma_resource_manager_get_log(ma_resource_manager* pResourceManager); /* Registration. */ MA_API ma_result ma_resource_manager_register_file(ma_resource_manager* pResourceManager, const char* pFilePath, ma_uint32 flags); MA_API ma_result ma_resource_manager_register_file_w(ma_resource_manager* pResourceManager, const wchar_t* pFilePath, ma_uint32 flags); MA_API ma_result ma_resource_manager_register_decoded_data(ma_resource_manager* pResourceManager, const char* pName, const void* pData, ma_uint64 frameCount, ma_format format, ma_uint32 channels, ma_uint32 sampleRate); /* Does not copy. Increments the reference count if already exists and returns MA_SUCCESS. */ MA_API ma_result ma_resource_manager_register_decoded_data_w(ma_resource_manager* pResourceManager, const wchar_t* pName, const void* pData, ma_uint64 frameCount, ma_format format, ma_uint32 channels, ma_uint32 sampleRate); MA_API ma_result ma_resource_manager_register_encoded_data(ma_resource_manager* pResourceManager, const char* pName, const void* pData, size_t sizeInBytes); /* Does not copy. Increments the reference count if already exists and returns MA_SUCCESS. */ MA_API ma_result ma_resource_manager_register_encoded_data_w(ma_resource_manager* pResourceManager, const wchar_t* pName, const void* pData, size_t sizeInBytes); MA_API ma_result ma_resource_manager_unregister_file(ma_resource_manager* pResourceManager, const char* pFilePath); MA_API ma_result ma_resource_manager_unregister_file_w(ma_resource_manager* pResourceManager, const wchar_t* pFilePath); MA_API ma_result ma_resource_manager_unregister_data(ma_resource_manager* pResourceManager, const char* pName); MA_API ma_result ma_resource_manager_unregister_data_w(ma_resource_manager* pResourceManager, const wchar_t* pName); /* Data Buffers. */ MA_API ma_result ma_resource_manager_data_buffer_init_ex(ma_resource_manager* pResourceManager, const ma_resource_manager_data_source_config* pConfig, ma_resource_manager_data_buffer* pDataBuffer); MA_API ma_result ma_resource_manager_data_buffer_init(ma_resource_manager* pResourceManager, const char* pFilePath, ma_uint32 flags, const ma_resource_manager_pipeline_notifications* pNotifications, ma_resource_manager_data_buffer* pDataBuffer); MA_API ma_result ma_resource_manager_data_buffer_init_w(ma_resource_manager* pResourceManager, const wchar_t* pFilePath, ma_uint32 flags, const ma_resource_manager_pipeline_notifications* pNotifications, ma_resource_manager_data_buffer* pDataBuffer); MA_API ma_result ma_resource_manager_data_buffer_init_copy(ma_resource_manager* pResourceManager, const ma_resource_manager_data_buffer* pExistingDataBuffer, ma_resource_manager_data_buffer* pDataBuffer); MA_API ma_result ma_resource_manager_data_buffer_uninit(ma_resource_manager_data_buffer* pDataBuffer); MA_API ma_result ma_resource_manager_data_buffer_read_pcm_frames(ma_resource_manager_data_buffer* pDataBuffer, void* pFramesOut, ma_uint64 frameCount, ma_uint64* pFramesRead); MA_API ma_result ma_resource_manager_data_buffer_seek_to_pcm_frame(ma_resource_manager_data_buffer* pDataBuffer, ma_uint64 frameIndex); MA_API ma_result ma_resource_manager_data_buffer_get_data_format(ma_resource_manager_data_buffer* pDataBuffer, ma_format* pFormat, ma_uint32* pChannels, ma_uint32* pSampleRate, ma_channel* pChannelMap, size_t channelMapCap); MA_API ma_result ma_resource_manager_data_buffer_get_cursor_in_pcm_frames(ma_resource_manager_data_buffer* pDataBuffer, ma_uint64* pCursor); MA_API ma_result ma_resource_manager_data_buffer_get_length_in_pcm_frames(ma_resource_manager_data_buffer* pDataBuffer, ma_uint64* pLength); MA_API ma_result ma_resource_manager_data_buffer_result(const ma_resource_manager_data_buffer* pDataBuffer); MA_API ma_result ma_resource_manager_data_buffer_set_looping(ma_resource_manager_data_buffer* pDataBuffer, ma_bool32 isLooping); MA_API ma_bool32 ma_resource_manager_data_buffer_is_looping(const ma_resource_manager_data_buffer* pDataBuffer); MA_API ma_result ma_resource_manager_data_buffer_get_available_frames(ma_resource_manager_data_buffer* pDataBuffer, ma_uint64* pAvailableFrames); /* Data Streams. */ MA_API ma_result ma_resource_manager_data_stream_init_ex(ma_resource_manager* pResourceManager, const ma_resource_manager_data_source_config* pConfig, ma_resource_manager_data_stream* pDataStream); MA_API ma_result ma_resource_manager_data_stream_init(ma_resource_manager* pResourceManager, const char* pFilePath, ma_uint32 flags, const ma_resource_manager_pipeline_notifications* pNotifications, ma_resource_manager_data_stream* pDataStream); MA_API ma_result ma_resource_manager_data_stream_init_w(ma_resource_manager* pResourceManager, const wchar_t* pFilePath, ma_uint32 flags, const ma_resource_manager_pipeline_notifications* pNotifications, ma_resource_manager_data_stream* pDataStream); MA_API ma_result ma_resource_manager_data_stream_uninit(ma_resource_manager_data_stream* pDataStream); MA_API ma_result ma_resource_manager_data_stream_read_pcm_frames(ma_resource_manager_data_stream* pDataStream, void* pFramesOut, ma_uint64 frameCount, ma_uint64* pFramesRead); MA_API ma_result ma_resource_manager_data_stream_seek_to_pcm_frame(ma_resource_manager_data_stream* pDataStream, ma_uint64 frameIndex); MA_API ma_result ma_resource_manager_data_stream_get_data_format(ma_resource_manager_data_stream* pDataStream, ma_format* pFormat, ma_uint32* pChannels, ma_uint32* pSampleRate, ma_channel* pChannelMap, size_t channelMapCap); MA_API ma_result ma_resource_manager_data_stream_get_cursor_in_pcm_frames(ma_resource_manager_data_stream* pDataStream, ma_uint64* pCursor); MA_API ma_result ma_resource_manager_data_stream_get_length_in_pcm_frames(ma_resource_manager_data_stream* pDataStream, ma_uint64* pLength); MA_API ma_result ma_resource_manager_data_stream_result(const ma_resource_manager_data_stream* pDataStream); MA_API ma_result ma_resource_manager_data_stream_set_looping(ma_resource_manager_data_stream* pDataStream, ma_bool32 isLooping); MA_API ma_bool32 ma_resource_manager_data_stream_is_looping(const ma_resource_manager_data_stream* pDataStream); MA_API ma_result ma_resource_manager_data_stream_get_available_frames(ma_resource_manager_data_stream* pDataStream, ma_uint64* pAvailableFrames); /* Data Sources. */ MA_API ma_result ma_resource_manager_data_source_init_ex(ma_resource_manager* pResourceManager, const ma_resource_manager_data_source_config* pConfig, ma_resource_manager_data_source* pDataSource); MA_API ma_result ma_resource_manager_data_source_init(ma_resource_manager* pResourceManager, const char* pName, ma_uint32 flags, const ma_resource_manager_pipeline_notifications* pNotifications, ma_resource_manager_data_source* pDataSource); MA_API ma_result ma_resource_manager_data_source_init_w(ma_resource_manager* pResourceManager, const wchar_t* pName, ma_uint32 flags, const ma_resource_manager_pipeline_notifications* pNotifications, ma_resource_manager_data_source* pDataSource); MA_API ma_result ma_resource_manager_data_source_init_copy(ma_resource_manager* pResourceManager, const ma_resource_manager_data_source* pExistingDataSource, ma_resource_manager_data_source* pDataSource); MA_API ma_result ma_resource_manager_data_source_uninit(ma_resource_manager_data_source* pDataSource); MA_API ma_result ma_resource_manager_data_source_read_pcm_frames(ma_resource_manager_data_source* pDataSource, void* pFramesOut, ma_uint64 frameCount, ma_uint64* pFramesRead); MA_API ma_result ma_resource_manager_data_source_seek_to_pcm_frame(ma_resource_manager_data_source* pDataSource, ma_uint64 frameIndex); MA_API ma_result ma_resource_manager_data_source_get_data_format(ma_resource_manager_data_source* pDataSource, ma_format* pFormat, ma_uint32* pChannels, ma_uint32* pSampleRate, ma_channel* pChannelMap, size_t channelMapCap); MA_API ma_result ma_resource_manager_data_source_get_cursor_in_pcm_frames(ma_resource_manager_data_source* pDataSource, ma_uint64* pCursor); MA_API ma_result ma_resource_manager_data_source_get_length_in_pcm_frames(ma_resource_manager_data_source* pDataSource, ma_uint64* pLength); MA_API ma_result ma_resource_manager_data_source_result(const ma_resource_manager_data_source* pDataSource); MA_API ma_result ma_resource_manager_data_source_set_looping(ma_resource_manager_data_source* pDataSource, ma_bool32 isLooping); MA_API ma_bool32 ma_resource_manager_data_source_is_looping(const ma_resource_manager_data_source* pDataSource); MA_API ma_result ma_resource_manager_data_source_get_available_frames(ma_resource_manager_data_source* pDataSource, ma_uint64* pAvailableFrames); /* Job management. */ MA_API ma_result ma_resource_manager_post_job(ma_resource_manager* pResourceManager, const ma_job* pJob); MA_API ma_result ma_resource_manager_post_job_quit(ma_resource_manager* pResourceManager); /* Helper for posting a quit job. */ MA_API ma_result ma_resource_manager_next_job(ma_resource_manager* pResourceManager, ma_job* pJob); MA_API ma_result ma_resource_manager_process_job(ma_resource_manager* pResourceManager, ma_job* pJob); /* DEPRECATED. Use ma_job_process(). Will be removed in version 0.12. */ MA_API ma_result ma_resource_manager_process_next_job(ma_resource_manager* pResourceManager); /* Returns MA_CANCELLED if a MA_JOB_TYPE_QUIT job is found. In non-blocking mode, returns MA_NO_DATA_AVAILABLE if no jobs are available. */ #endif /* MA_NO_RESOURCE_MANAGER */ /************************************************************************************************************************************************************ Node Graph ************************************************************************************************************************************************************/ #ifndef MA_NO_NODE_GRAPH /* Must never exceed 254. */ #ifndef MA_MAX_NODE_BUS_COUNT #define MA_MAX_NODE_BUS_COUNT 254 #endif /* Used internally by miniaudio for memory management. Must never exceed MA_MAX_NODE_BUS_COUNT. */ #ifndef MA_MAX_NODE_LOCAL_BUS_COUNT #define MA_MAX_NODE_LOCAL_BUS_COUNT 2 #endif /* Use this when the bus count is determined by the node instance rather than the vtable. */ #define MA_NODE_BUS_COUNT_UNKNOWN 255 typedef struct ma_node_graph ma_node_graph; typedef void ma_node; /* Node flags. */ typedef enum { MA_NODE_FLAG_PASSTHROUGH = 0x00000001, MA_NODE_FLAG_CONTINUOUS_PROCESSING = 0x00000002, MA_NODE_FLAG_ALLOW_NULL_INPUT = 0x00000004, MA_NODE_FLAG_DIFFERENT_PROCESSING_RATES = 0x00000008, MA_NODE_FLAG_SILENT_OUTPUT = 0x00000010 } ma_node_flags; /* The playback state of a node. Either started or stopped. */ typedef enum { ma_node_state_started = 0, ma_node_state_stopped = 1 } ma_node_state; typedef struct { /* Extended processing callback. This callback is used for effects that process input and output at different rates (i.e. they perform resampling). This is similar to the simple version, only they take two separate frame counts: one for input, and one for output. On input, `pFrameCountOut` is equal to the capacity of the output buffer for each bus, whereas `pFrameCountIn` will be equal to the number of PCM frames in each of the buffers in `ppFramesIn`. On output, set `pFrameCountOut` to the number of PCM frames that were actually output and set `pFrameCountIn` to the number of input frames that were consumed. */ void (* onProcess)(ma_node* pNode, const float** ppFramesIn, ma_uint32* pFrameCountIn, float** ppFramesOut, ma_uint32* pFrameCountOut); /* A callback for retrieving the number of a input frames that are required to output the specified number of output frames. You would only want to implement this when the node performs resampling. This is optional, even for nodes that perform resampling, but it does offer a small reduction in latency as it allows miniaudio to calculate the exact number of input frames to read at a time instead of having to estimate. */ ma_result (* onGetRequiredInputFrameCount)(ma_node* pNode, ma_uint32 outputFrameCount, ma_uint32* pInputFrameCount); /* The number of input buses. This is how many sub-buffers will be contained in the `ppFramesIn` parameters of the callbacks above. */ ma_uint8 inputBusCount; /* The number of output buses. This is how many sub-buffers will be contained in the `ppFramesOut` parameters of the callbacks above. */ ma_uint8 outputBusCount; /* Flags describing characteristics of the node. This is currently just a placeholder for some ideas for later on. */ ma_uint32 flags; } ma_node_vtable; typedef struct { const ma_node_vtable* vtable; /* Should never be null. Initialization of the node will fail if so. */ ma_node_state initialState; /* Defaults to ma_node_state_started. */ ma_uint32 inputBusCount; /* Only used if the vtable specifies an input bus count of `MA_NODE_BUS_COUNT_UNKNOWN`, otherwise must be set to `MA_NODE_BUS_COUNT_UNKNOWN` (default). */ ma_uint32 outputBusCount; /* Only used if the vtable specifies an output bus count of `MA_NODE_BUS_COUNT_UNKNOWN`, otherwise be set to `MA_NODE_BUS_COUNT_UNKNOWN` (default). */ const ma_uint32* pInputChannels; /* The number of elements are determined by the input bus count as determined by the vtable, or `inputBusCount` if the vtable specifies `MA_NODE_BUS_COUNT_UNKNOWN`. */ const ma_uint32* pOutputChannels; /* The number of elements are determined by the output bus count as determined by the vtable, or `outputBusCount` if the vtable specifies `MA_NODE_BUS_COUNT_UNKNOWN`. */ } ma_node_config; MA_API ma_node_config ma_node_config_init(void); /* A node has multiple output buses. An output bus is attached to an input bus as an item in a linked list. Think of the input bus as a linked list, with the output bus being an item in that list. */ typedef struct ma_node_output_bus ma_node_output_bus; struct ma_node_output_bus { /* Immutable. */ ma_node* pNode; /* The node that owns this output bus. The input node. Will be null for dummy head and tail nodes. */ ma_uint8 outputBusIndex; /* The index of the output bus on pNode that this output bus represents. */ ma_uint8 channels; /* The number of channels in the audio stream for this bus. */ /* Mutable via multiple threads. Must be used atomically. The weird ordering here is for packing reasons. */ ma_uint8 inputNodeInputBusIndex; /* The index of the input bus on the input. Required for detaching. Will only be used within the spinlock so does not need to be atomic. */ MA_ATOMIC(4, ma_uint32) flags; /* Some state flags for tracking the read state of the output buffer. A combination of MA_NODE_OUTPUT_BUS_FLAG_*. */ MA_ATOMIC(4, ma_uint32) refCount; /* Reference count for some thread-safety when detaching. */ MA_ATOMIC(4, ma_bool32) isAttached; /* This is used to prevent iteration of nodes that are in the middle of being detached. Used for thread safety. */ MA_ATOMIC(4, ma_spinlock) lock; /* Unfortunate lock, but significantly simplifies the implementation. Required for thread-safe attaching and detaching. */ MA_ATOMIC(4, float) volume; /* Linear. */ MA_ATOMIC(MA_SIZEOF_PTR, ma_node_output_bus*) pNext; /* If null, it's the tail node or detached. */ MA_ATOMIC(MA_SIZEOF_PTR, ma_node_output_bus*) pPrev; /* If null, it's the head node or detached. */ MA_ATOMIC(MA_SIZEOF_PTR, ma_node*) pInputNode; /* The node that this output bus is attached to. Required for detaching. */ }; /* A node has multiple input buses. The output buses of a node are connecting to the input busses of another. An input bus is essentially just a linked list of output buses. */ typedef struct ma_node_input_bus ma_node_input_bus; struct ma_node_input_bus { /* Mutable via multiple threads. */ ma_node_output_bus head; /* Dummy head node for simplifying some lock-free thread-safety stuff. */ MA_ATOMIC(4, ma_uint32) nextCounter; /* This is used to determine whether or not the input bus is finding the next node in the list. Used for thread safety when detaching output buses. */ MA_ATOMIC(4, ma_spinlock) lock; /* Unfortunate lock, but significantly simplifies the implementation. Required for thread-safe attaching and detaching. */ /* Set once at startup. */ ma_uint8 channels; /* The number of channels in the audio stream for this bus. */ }; typedef struct ma_node_base ma_node_base; struct ma_node_base { /* These variables are set once at startup. */ ma_node_graph* pNodeGraph; /* The graph this node belongs to. */ const ma_node_vtable* vtable; float* pCachedData; /* Allocated on the heap. Fixed size. Needs to be stored on the heap because reading from output buses is done in separate function calls. */ ma_uint16 cachedDataCapInFramesPerBus; /* The capacity of the input data cache in frames, per bus. */ /* These variables are read and written only from the audio thread. */ ma_uint16 cachedFrameCountOut; ma_uint16 cachedFrameCountIn; ma_uint16 consumedFrameCountIn; /* These variables are read and written between different threads. */ MA_ATOMIC(4, ma_node_state) state; /* When set to stopped, nothing will be read, regardless of the times in stateTimes. */ MA_ATOMIC(8, ma_uint64) stateTimes[2]; /* Indexed by ma_node_state. Specifies the time based on the global clock that a node should be considered to be in the relevant state. */ MA_ATOMIC(8, ma_uint64) localTime; /* The node's local clock. This is just a running sum of the number of output frames that have been processed. Can be modified by any thread with `ma_node_set_time()`. */ ma_uint32 inputBusCount; ma_uint32 outputBusCount; ma_node_input_bus* pInputBuses; ma_node_output_bus* pOutputBuses; /* Memory management. */ ma_node_input_bus _inputBuses[MA_MAX_NODE_LOCAL_BUS_COUNT]; ma_node_output_bus _outputBuses[MA_MAX_NODE_LOCAL_BUS_COUNT]; void* _pHeap; /* A heap allocation for internal use only. pInputBuses and/or pOutputBuses will point to this if the bus count exceeds MA_MAX_NODE_LOCAL_BUS_COUNT. */ ma_bool32 _ownsHeap; /* If set to true, the node owns the heap allocation and _pHeap will be freed in ma_node_uninit(). */ }; MA_API ma_result ma_node_get_heap_size(ma_node_graph* pNodeGraph, const ma_node_config* pConfig, size_t* pHeapSizeInBytes); MA_API ma_result ma_node_init_preallocated(ma_node_graph* pNodeGraph, const ma_node_config* pConfig, void* pHeap, ma_node* pNode); MA_API ma_result ma_node_init(ma_node_graph* pNodeGraph, const ma_node_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_node* pNode); MA_API void ma_node_uninit(ma_node* pNode, const ma_allocation_callbacks* pAllocationCallbacks); MA_API ma_node_graph* ma_node_get_node_graph(const ma_node* pNode); MA_API ma_uint32 ma_node_get_input_bus_count(const ma_node* pNode); MA_API ma_uint32 ma_node_get_output_bus_count(const ma_node* pNode); MA_API ma_uint32 ma_node_get_input_channels(const ma_node* pNode, ma_uint32 inputBusIndex); MA_API ma_uint32 ma_node_get_output_channels(const ma_node* pNode, ma_uint32 outputBusIndex); MA_API ma_result ma_node_attach_output_bus(ma_node* pNode, ma_uint32 outputBusIndex, ma_node* pOtherNode, ma_uint32 otherNodeInputBusIndex); MA_API ma_result ma_node_detach_output_bus(ma_node* pNode, ma_uint32 outputBusIndex); MA_API ma_result ma_node_detach_all_output_buses(ma_node* pNode); MA_API ma_result ma_node_set_output_bus_volume(ma_node* pNode, ma_uint32 outputBusIndex, float volume); MA_API float ma_node_get_output_bus_volume(const ma_node* pNode, ma_uint32 outputBusIndex); MA_API ma_result ma_node_set_state(ma_node* pNode, ma_node_state state); MA_API ma_node_state ma_node_get_state(const ma_node* pNode); MA_API ma_result ma_node_set_state_time(ma_node* pNode, ma_node_state state, ma_uint64 globalTime); MA_API ma_uint64 ma_node_get_state_time(const ma_node* pNode, ma_node_state state); MA_API ma_node_state ma_node_get_state_by_time(const ma_node* pNode, ma_uint64 globalTime); MA_API ma_node_state ma_node_get_state_by_time_range(const ma_node* pNode, ma_uint64 globalTimeBeg, ma_uint64 globalTimeEnd); MA_API ma_uint64 ma_node_get_time(const ma_node* pNode); MA_API ma_result ma_node_set_time(ma_node* pNode, ma_uint64 localTime); typedef struct { ma_uint32 channels; ma_uint16 nodeCacheCapInFrames; } ma_node_graph_config; MA_API ma_node_graph_config ma_node_graph_config_init(ma_uint32 channels); struct ma_node_graph { /* Immutable. */ ma_node_base base; /* The node graph itself is a node so it can be connected as an input to different node graph. This has zero inputs and calls ma_node_graph_read_pcm_frames() to generate it's output. */ ma_node_base endpoint; /* Special node that all nodes eventually connect to. Data is read from this node in ma_node_graph_read_pcm_frames(). */ ma_uint16 nodeCacheCapInFrames; /* Read and written by multiple threads. */ MA_ATOMIC(4, ma_bool32) isReading; }; MA_API ma_result ma_node_graph_init(const ma_node_graph_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_node_graph* pNodeGraph); MA_API void ma_node_graph_uninit(ma_node_graph* pNodeGraph, const ma_allocation_callbacks* pAllocationCallbacks); MA_API ma_node* ma_node_graph_get_endpoint(ma_node_graph* pNodeGraph); MA_API ma_result ma_node_graph_read_pcm_frames(ma_node_graph* pNodeGraph, void* pFramesOut, ma_uint64 frameCount, ma_uint64* pFramesRead); MA_API ma_uint32 ma_node_graph_get_channels(const ma_node_graph* pNodeGraph); MA_API ma_uint64 ma_node_graph_get_time(const ma_node_graph* pNodeGraph); MA_API ma_result ma_node_graph_set_time(ma_node_graph* pNodeGraph, ma_uint64 globalTime); /* Data source node. 0 input buses, 1 output bus. Used for reading from a data source. */ typedef struct { ma_node_config nodeConfig; ma_data_source* pDataSource; } ma_data_source_node_config; MA_API ma_data_source_node_config ma_data_source_node_config_init(ma_data_source* pDataSource); typedef struct { ma_node_base base; ma_data_source* pDataSource; } ma_data_source_node; MA_API ma_result ma_data_source_node_init(ma_node_graph* pNodeGraph, const ma_data_source_node_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_data_source_node* pDataSourceNode); MA_API void ma_data_source_node_uninit(ma_data_source_node* pDataSourceNode, const ma_allocation_callbacks* pAllocationCallbacks); MA_API ma_result ma_data_source_node_set_looping(ma_data_source_node* pDataSourceNode, ma_bool32 isLooping); MA_API ma_bool32 ma_data_source_node_is_looping(ma_data_source_node* pDataSourceNode); /* Splitter Node. 1 input, many outputs. Used for splitting/copying a stream so it can be as input into two separate output nodes. */ typedef struct { ma_node_config nodeConfig; ma_uint32 channels; ma_uint32 outputBusCount; } ma_splitter_node_config; MA_API ma_splitter_node_config ma_splitter_node_config_init(ma_uint32 channels); typedef struct { ma_node_base base; } ma_splitter_node; MA_API ma_result ma_splitter_node_init(ma_node_graph* pNodeGraph, const ma_splitter_node_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_splitter_node* pSplitterNode); MA_API void ma_splitter_node_uninit(ma_splitter_node* pSplitterNode, const ma_allocation_callbacks* pAllocationCallbacks); /* Biquad Node */ typedef struct { ma_node_config nodeConfig; ma_biquad_config biquad; } ma_biquad_node_config; MA_API ma_biquad_node_config ma_biquad_node_config_init(ma_uint32 channels, float b0, float b1, float b2, float a0, float a1, float a2); typedef struct { ma_node_base baseNode; ma_biquad biquad; } ma_biquad_node; MA_API ma_result ma_biquad_node_init(ma_node_graph* pNodeGraph, const ma_biquad_node_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_biquad_node* pNode); MA_API ma_result ma_biquad_node_reinit(const ma_biquad_config* pConfig, ma_biquad_node* pNode); MA_API void ma_biquad_node_uninit(ma_biquad_node* pNode, const ma_allocation_callbacks* pAllocationCallbacks); /* Low Pass Filter Node */ typedef struct { ma_node_config nodeConfig; ma_lpf_config lpf; } ma_lpf_node_config; MA_API ma_lpf_node_config ma_lpf_node_config_init(ma_uint32 channels, ma_uint32 sampleRate, double cutoffFrequency, ma_uint32 order); typedef struct { ma_node_base baseNode; ma_lpf lpf; } ma_lpf_node; MA_API ma_result ma_lpf_node_init(ma_node_graph* pNodeGraph, const ma_lpf_node_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_lpf_node* pNode); MA_API ma_result ma_lpf_node_reinit(const ma_lpf_config* pConfig, ma_lpf_node* pNode); MA_API void ma_lpf_node_uninit(ma_lpf_node* pNode, const ma_allocation_callbacks* pAllocationCallbacks); /* High Pass Filter Node */ typedef struct { ma_node_config nodeConfig; ma_hpf_config hpf; } ma_hpf_node_config; MA_API ma_hpf_node_config ma_hpf_node_config_init(ma_uint32 channels, ma_uint32 sampleRate, double cutoffFrequency, ma_uint32 order); typedef struct { ma_node_base baseNode; ma_hpf hpf; } ma_hpf_node; MA_API ma_result ma_hpf_node_init(ma_node_graph* pNodeGraph, const ma_hpf_node_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_hpf_node* pNode); MA_API ma_result ma_hpf_node_reinit(const ma_hpf_config* pConfig, ma_hpf_node* pNode); MA_API void ma_hpf_node_uninit(ma_hpf_node* pNode, const ma_allocation_callbacks* pAllocationCallbacks); /* Band Pass Filter Node */ typedef struct { ma_node_config nodeConfig; ma_bpf_config bpf; } ma_bpf_node_config; MA_API ma_bpf_node_config ma_bpf_node_config_init(ma_uint32 channels, ma_uint32 sampleRate, double cutoffFrequency, ma_uint32 order); typedef struct { ma_node_base baseNode; ma_bpf bpf; } ma_bpf_node; MA_API ma_result ma_bpf_node_init(ma_node_graph* pNodeGraph, const ma_bpf_node_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_bpf_node* pNode); MA_API ma_result ma_bpf_node_reinit(const ma_bpf_config* pConfig, ma_bpf_node* pNode); MA_API void ma_bpf_node_uninit(ma_bpf_node* pNode, const ma_allocation_callbacks* pAllocationCallbacks); /* Notching Filter Node */ typedef struct { ma_node_config nodeConfig; ma_notch_config notch; } ma_notch_node_config; MA_API ma_notch_node_config ma_notch_node_config_init(ma_uint32 channels, ma_uint32 sampleRate, double q, double frequency); typedef struct { ma_node_base baseNode; ma_notch2 notch; } ma_notch_node; MA_API ma_result ma_notch_node_init(ma_node_graph* pNodeGraph, const ma_notch_node_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_notch_node* pNode); MA_API ma_result ma_notch_node_reinit(const ma_notch_config* pConfig, ma_notch_node* pNode); MA_API void ma_notch_node_uninit(ma_notch_node* pNode, const ma_allocation_callbacks* pAllocationCallbacks); /* Peaking Filter Node */ typedef struct { ma_node_config nodeConfig; ma_peak_config peak; } ma_peak_node_config; MA_API ma_peak_node_config ma_peak_node_config_init(ma_uint32 channels, ma_uint32 sampleRate, double gainDB, double q, double frequency); typedef struct { ma_node_base baseNode; ma_peak2 peak; } ma_peak_node; MA_API ma_result ma_peak_node_init(ma_node_graph* pNodeGraph, const ma_peak_node_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_peak_node* pNode); MA_API ma_result ma_peak_node_reinit(const ma_peak_config* pConfig, ma_peak_node* pNode); MA_API void ma_peak_node_uninit(ma_peak_node* pNode, const ma_allocation_callbacks* pAllocationCallbacks); /* Low Shelf Filter Node */ typedef struct { ma_node_config nodeConfig; ma_loshelf_config loshelf; } ma_loshelf_node_config; MA_API ma_loshelf_node_config ma_loshelf_node_config_init(ma_uint32 channels, ma_uint32 sampleRate, double gainDB, double q, double frequency); typedef struct { ma_node_base baseNode; ma_loshelf2 loshelf; } ma_loshelf_node; MA_API ma_result ma_loshelf_node_init(ma_node_graph* pNodeGraph, const ma_loshelf_node_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_loshelf_node* pNode); MA_API ma_result ma_loshelf_node_reinit(const ma_loshelf_config* pConfig, ma_loshelf_node* pNode); MA_API void ma_loshelf_node_uninit(ma_loshelf_node* pNode, const ma_allocation_callbacks* pAllocationCallbacks); /* High Shelf Filter Node */ typedef struct { ma_node_config nodeConfig; ma_hishelf_config hishelf; } ma_hishelf_node_config; MA_API ma_hishelf_node_config ma_hishelf_node_config_init(ma_uint32 channels, ma_uint32 sampleRate, double gainDB, double q, double frequency); typedef struct { ma_node_base baseNode; ma_hishelf2 hishelf; } ma_hishelf_node; MA_API ma_result ma_hishelf_node_init(ma_node_graph* pNodeGraph, const ma_hishelf_node_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_hishelf_node* pNode); MA_API ma_result ma_hishelf_node_reinit(const ma_hishelf_config* pConfig, ma_hishelf_node* pNode); MA_API void ma_hishelf_node_uninit(ma_hishelf_node* pNode, const ma_allocation_callbacks* pAllocationCallbacks); typedef struct { ma_node_config nodeConfig; ma_delay_config delay; } ma_delay_node_config; MA_API ma_delay_node_config ma_delay_node_config_init(ma_uint32 channels, ma_uint32 sampleRate, ma_uint32 delayInFrames, float decay); typedef struct { ma_node_base baseNode; ma_delay delay; } ma_delay_node; MA_API ma_result ma_delay_node_init(ma_node_graph* pNodeGraph, const ma_delay_node_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_delay_node* pDelayNode); MA_API void ma_delay_node_uninit(ma_delay_node* pDelayNode, const ma_allocation_callbacks* pAllocationCallbacks); MA_API void ma_delay_node_set_wet(ma_delay_node* pDelayNode, float value); MA_API float ma_delay_node_get_wet(const ma_delay_node* pDelayNode); MA_API void ma_delay_node_set_dry(ma_delay_node* pDelayNode, float value); MA_API float ma_delay_node_get_dry(const ma_delay_node* pDelayNode); MA_API void ma_delay_node_set_decay(ma_delay_node* pDelayNode, float value); MA_API float ma_delay_node_get_decay(const ma_delay_node* pDelayNode); #endif /* MA_NO_NODE_GRAPH */ /* SECTION: miniaudio_engine.h */ /************************************************************************************************************************************************************ Engine ************************************************************************************************************************************************************/ #if !defined(MA_NO_ENGINE) && !defined(MA_NO_NODE_GRAPH) typedef struct ma_engine ma_engine; typedef struct ma_sound ma_sound; /* Sound flags. */ typedef enum { /* Resource manager flags. */ MA_SOUND_FLAG_STREAM = 0x00000001, /* MA_RESOURCE_MANAGER_DATA_SOURCE_FLAG_STREAM */ MA_SOUND_FLAG_DECODE = 0x00000002, /* MA_RESOURCE_MANAGER_DATA_SOURCE_FLAG_DECODE */ MA_SOUND_FLAG_ASYNC = 0x00000004, /* MA_RESOURCE_MANAGER_DATA_SOURCE_FLAG_ASYNC */ MA_SOUND_FLAG_WAIT_INIT = 0x00000008, /* MA_RESOURCE_MANAGER_DATA_SOURCE_FLAG_WAIT_INIT */ MA_SOUND_FLAG_UNKNOWN_LENGTH = 0x00000010, /* MA_RESOURCE_MANAGER_DATA_SOURCE_FLAG_UNKNOWN_LENGTH */ /* ma_sound specific flags. */ MA_SOUND_FLAG_NO_DEFAULT_ATTACHMENT = 0x00001000, /* Do not attach to the endpoint by default. Useful for when setting up nodes in a complex graph system. */ MA_SOUND_FLAG_NO_PITCH = 0x00002000, /* Disable pitch shifting with ma_sound_set_pitch() and ma_sound_group_set_pitch(). This is an optimization. */ MA_SOUND_FLAG_NO_SPATIALIZATION = 0x00004000 /* Disable spatialization. */ } ma_sound_flags; #ifndef MA_ENGINE_MAX_LISTENERS #define MA_ENGINE_MAX_LISTENERS 4 #endif #define MA_LISTENER_INDEX_CLOSEST ((ma_uint8)-1) typedef enum { ma_engine_node_type_sound, ma_engine_node_type_group } ma_engine_node_type; typedef struct { ma_engine* pEngine; ma_engine_node_type type; ma_uint32 channelsIn; ma_uint32 channelsOut; ma_uint32 sampleRate; /* Only used when the type is set to ma_engine_node_type_sound. */ ma_uint32 volumeSmoothTimeInPCMFrames; /* The number of frames to smooth over volume changes. Defaults to 0 in which case no smoothing is used. */ ma_mono_expansion_mode monoExpansionMode; ma_bool8 isPitchDisabled; /* Pitching can be explicitly disabled with MA_SOUND_FLAG_NO_PITCH to optimize processing. */ ma_bool8 isSpatializationDisabled; /* Spatialization can be explicitly disabled with MA_SOUND_FLAG_NO_SPATIALIZATION. */ ma_uint8 pinnedListenerIndex; /* The index of the listener this node should always use for spatialization. If set to MA_LISTENER_INDEX_CLOSEST the engine will use the closest listener. */ } ma_engine_node_config; MA_API ma_engine_node_config ma_engine_node_config_init(ma_engine* pEngine, ma_engine_node_type type, ma_uint32 flags); /* Base node object for both ma_sound and ma_sound_group. */ typedef struct { ma_node_base baseNode; /* Must be the first member for compatiblity with the ma_node API. */ ma_engine* pEngine; /* A pointer to the engine. Set based on the value from the config. */ ma_uint32 sampleRate; /* The sample rate of the input data. For sounds backed by a data source, this will be the data source's sample rate. Otherwise it'll be the engine's sample rate. */ ma_uint32 volumeSmoothTimeInPCMFrames; ma_mono_expansion_mode monoExpansionMode; ma_fader fader; ma_linear_resampler resampler; /* For pitch shift. */ ma_spatializer spatializer; ma_panner panner; ma_gainer volumeGainer; /* This will only be used if volumeSmoothTimeInPCMFrames is > 0. */ ma_atomic_float volume; /* Defaults to 1. */ MA_ATOMIC(4, float) pitch; float oldPitch; /* For determining whether or not the resampler needs to be updated to reflect the new pitch. The resampler will be updated on the mixing thread. */ float oldDopplerPitch; /* For determining whether or not the resampler needs to be updated to take a new doppler pitch into account. */ MA_ATOMIC(4, ma_bool32) isPitchDisabled; /* When set to true, pitching will be disabled which will allow the resampler to be bypassed to save some computation. */ MA_ATOMIC(4, ma_bool32) isSpatializationDisabled; /* Set to false by default. When set to false, will not have spatialisation applied. */ MA_ATOMIC(4, ma_uint32) pinnedListenerIndex; /* The index of the listener this node should always use for spatialization. If set to MA_LISTENER_INDEX_CLOSEST the engine will use the closest listener. */ /* When setting a fade, it's not done immediately in ma_sound_set_fade(). It's deferred to the audio thread which means we need to store the settings here. */ struct { ma_atomic_float volumeBeg; ma_atomic_float volumeEnd; ma_atomic_uint64 fadeLengthInFrames; /* <-- Defaults to (~(ma_uint64)0) which is used to indicate that no fade should be applied. */ ma_atomic_uint64 absoluteGlobalTimeInFrames; /* <-- The time to start the fade. */ } fadeSettings; /* Memory management. */ ma_bool8 _ownsHeap; void* _pHeap; } ma_engine_node; MA_API ma_result ma_engine_node_get_heap_size(const ma_engine_node_config* pConfig, size_t* pHeapSizeInBytes); MA_API ma_result ma_engine_node_init_preallocated(const ma_engine_node_config* pConfig, void* pHeap, ma_engine_node* pEngineNode); MA_API ma_result ma_engine_node_init(const ma_engine_node_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_engine_node* pEngineNode); MA_API void ma_engine_node_uninit(ma_engine_node* pEngineNode, const ma_allocation_callbacks* pAllocationCallbacks); #define MA_SOUND_SOURCE_CHANNEL_COUNT 0xFFFFFFFF /* Callback for when a sound reaches the end. */ typedef void (* ma_sound_end_proc)(void* pUserData, ma_sound* pSound); typedef struct { const char* pFilePath; /* Set this to load from the resource manager. */ const wchar_t* pFilePathW; /* Set this to load from the resource manager. */ ma_data_source* pDataSource; /* Set this to load from an existing data source. */ ma_node* pInitialAttachment; /* If set, the sound will be attached to an input of this node. This can be set to a ma_sound. If set to NULL, the sound will be attached directly to the endpoint unless MA_SOUND_FLAG_NO_DEFAULT_ATTACHMENT is set in `flags`. */ ma_uint32 initialAttachmentInputBusIndex; /* The index of the input bus of pInitialAttachment to attach the sound to. */ ma_uint32 channelsIn; /* Ignored if using a data source as input (the data source's channel count will be used always). Otherwise, setting to 0 will cause the engine's channel count to be used. */ ma_uint32 channelsOut; /* Set this to 0 (default) to use the engine's channel count. Set to MA_SOUND_SOURCE_CHANNEL_COUNT to use the data source's channel count (only used if using a data source as input). */ ma_mono_expansion_mode monoExpansionMode; /* Controls how the mono channel should be expanded to other channels when spatialization is disabled on a sound. */ ma_uint32 flags; /* A combination of MA_SOUND_FLAG_* flags. */ ma_uint32 volumeSmoothTimeInPCMFrames; /* The number of frames to smooth over volume changes. Defaults to 0 in which case no smoothing is used. */ ma_uint64 initialSeekPointInPCMFrames; /* Initializes the sound such that it's seeked to this location by default. */ ma_uint64 rangeBegInPCMFrames; ma_uint64 rangeEndInPCMFrames; ma_uint64 loopPointBegInPCMFrames; ma_uint64 loopPointEndInPCMFrames; ma_bool32 isLooping; ma_sound_end_proc endCallback; /* Fired when the sound reaches the end. Will be fired from the audio thread. Do not restart, uninitialize or otherwise change the state of the sound from here. Instead fire an event or set a variable to indicate to a different thread to change the start of the sound. Will not be fired in response to a scheduled stop with ma_sound_set_stop_time_*(). */ void* pEndCallbackUserData; #ifndef MA_NO_RESOURCE_MANAGER ma_resource_manager_pipeline_notifications initNotifications; #endif ma_fence* pDoneFence; /* Deprecated. Use initNotifications instead. Released when the resource manager has finished decoding the entire sound. Not used with streams. */ } ma_sound_config; MA_API ma_sound_config ma_sound_config_init(void); /* Deprecated. Will be removed in version 0.12. Use ma_sound_config_2() instead. */ MA_API ma_sound_config ma_sound_config_init_2(ma_engine* pEngine); /* Will be renamed to ma_sound_config_init() in version 0.12. */ struct ma_sound { ma_engine_node engineNode; /* Must be the first member for compatibility with the ma_node API. */ ma_data_source* pDataSource; MA_ATOMIC(8, ma_uint64) seekTarget; /* The PCM frame index to seek to in the mixing thread. Set to (~(ma_uint64)0) to not perform any seeking. */ MA_ATOMIC(4, ma_bool32) atEnd; ma_sound_end_proc endCallback; void* pEndCallbackUserData; ma_bool8 ownsDataSource; /* We're declaring a resource manager data source object here to save us a malloc when loading a sound via the resource manager, which I *think* will be the most common scenario. */ #ifndef MA_NO_RESOURCE_MANAGER ma_resource_manager_data_source* pResourceManagerDataSource; #endif }; /* Structure specifically for sounds played with ma_engine_play_sound(). Making this a separate structure to reduce overhead. */ typedef struct ma_sound_inlined ma_sound_inlined; struct ma_sound_inlined { ma_sound sound; ma_sound_inlined* pNext; ma_sound_inlined* pPrev; }; /* A sound group is just a sound. */ typedef ma_sound_config ma_sound_group_config; typedef ma_sound ma_sound_group; MA_API ma_sound_group_config ma_sound_group_config_init(void); /* Deprecated. Will be removed in version 0.12. Use ma_sound_config_2() instead. */ MA_API ma_sound_group_config ma_sound_group_config_init_2(ma_engine* pEngine); /* Will be renamed to ma_sound_config_init() in version 0.12. */ typedef void (* ma_engine_process_proc)(void* pUserData, float* pFramesOut, ma_uint64 frameCount); typedef struct { #if !defined(MA_NO_RESOURCE_MANAGER) ma_resource_manager* pResourceManager; /* Can be null in which case a resource manager will be created for you. */ #endif #if !defined(MA_NO_DEVICE_IO) ma_context* pContext; ma_device* pDevice; /* If set, the caller is responsible for calling ma_engine_data_callback() in the device's data callback. */ ma_device_id* pPlaybackDeviceID; /* The ID of the playback device to use with the default listener. */ ma_device_data_proc dataCallback; /* Can be null. Can be used to provide a custom device data callback. */ ma_device_notification_proc notificationCallback; #endif ma_log* pLog; /* When set to NULL, will use the context's log. */ ma_uint32 listenerCount; /* Must be between 1 and MA_ENGINE_MAX_LISTENERS. */ ma_uint32 channels; /* The number of channels to use when mixing and spatializing. When set to 0, will use the native channel count of the device. */ ma_uint32 sampleRate; /* The sample rate. When set to 0 will use the native channel count of the device. */ ma_uint32 periodSizeInFrames; /* If set to something other than 0, updates will always be exactly this size. The underlying device may be a different size, but from the perspective of the mixer that won't matter.*/ ma_uint32 periodSizeInMilliseconds; /* Used if periodSizeInFrames is unset. */ ma_uint32 gainSmoothTimeInFrames; /* The number of frames to interpolate the gain of spatialized sounds across. If set to 0, will use gainSmoothTimeInMilliseconds. */ ma_uint32 gainSmoothTimeInMilliseconds; /* When set to 0, gainSmoothTimeInFrames will be used. If both are set to 0, a default value will be used. */ ma_uint32 defaultVolumeSmoothTimeInPCMFrames; /* Defaults to 0. Controls the default amount of smoothing to apply to volume changes to sounds. High values means more smoothing at the expense of high latency (will take longer to reach the new volume). */ ma_allocation_callbacks allocationCallbacks; ma_bool32 noAutoStart; /* When set to true, requires an explicit call to ma_engine_start(). This is false by default, meaning the engine will be started automatically in ma_engine_init(). */ ma_bool32 noDevice; /* When set to true, don't create a default device. ma_engine_read_pcm_frames() can be called manually to read data. */ ma_mono_expansion_mode monoExpansionMode; /* Controls how the mono channel should be expanded to other channels when spatialization is disabled on a sound. */ ma_vfs* pResourceManagerVFS; /* A pointer to a pre-allocated VFS object to use with the resource manager. This is ignored if pResourceManager is not NULL. */ ma_engine_process_proc onProcess; /* Fired at the end of each call to ma_engine_read_pcm_frames(). For engine's that manage their own internal device (the default configuration), this will be fired from the audio thread, and you do not need to call ma_engine_read_pcm_frames() manually in order to trigger this. */ void* pProcessUserData; /* User data that's passed into onProcess. */ } ma_engine_config; MA_API ma_engine_config ma_engine_config_init(void); struct ma_engine { ma_node_graph nodeGraph; /* An engine is a node graph. It should be able to be plugged into any ma_node_graph API (with a cast) which means this must be the first member of this struct. */ #if !defined(MA_NO_RESOURCE_MANAGER) ma_resource_manager* pResourceManager; #endif #if !defined(MA_NO_DEVICE_IO) ma_device* pDevice; /* Optionally set via the config, otherwise allocated by the engine in ma_engine_init(). */ #endif ma_log* pLog; ma_uint32 sampleRate; ma_uint32 listenerCount; ma_spatializer_listener listeners[MA_ENGINE_MAX_LISTENERS]; ma_allocation_callbacks allocationCallbacks; ma_bool8 ownsResourceManager; ma_bool8 ownsDevice; ma_spinlock inlinedSoundLock; /* For synchronizing access so the inlined sound list. */ ma_sound_inlined* pInlinedSoundHead; /* The first inlined sound. Inlined sounds are tracked in a linked list. */ MA_ATOMIC(4, ma_uint32) inlinedSoundCount; /* The total number of allocated inlined sound objects. Used for debugging. */ ma_uint32 gainSmoothTimeInFrames; /* The number of frames to interpolate the gain of spatialized sounds across. */ ma_uint32 defaultVolumeSmoothTimeInPCMFrames; ma_mono_expansion_mode monoExpansionMode; ma_engine_process_proc onProcess; void* pProcessUserData; }; MA_API ma_result ma_engine_init(const ma_engine_config* pConfig, ma_engine* pEngine); MA_API void ma_engine_uninit(ma_engine* pEngine); MA_API ma_result ma_engine_read_pcm_frames(ma_engine* pEngine, void* pFramesOut, ma_uint64 frameCount, ma_uint64* pFramesRead); MA_API ma_node_graph* ma_engine_get_node_graph(ma_engine* pEngine); #if !defined(MA_NO_RESOURCE_MANAGER) MA_API ma_resource_manager* ma_engine_get_resource_manager(ma_engine* pEngine); #endif MA_API ma_device* ma_engine_get_device(ma_engine* pEngine); MA_API ma_log* ma_engine_get_log(ma_engine* pEngine); MA_API ma_node* ma_engine_get_endpoint(ma_engine* pEngine); MA_API ma_uint64 ma_engine_get_time_in_pcm_frames(const ma_engine* pEngine); MA_API ma_uint64 ma_engine_get_time_in_milliseconds(const ma_engine* pEngine); MA_API ma_result ma_engine_set_time_in_pcm_frames(ma_engine* pEngine, ma_uint64 globalTime); MA_API ma_result ma_engine_set_time_in_milliseconds(ma_engine* pEngine, ma_uint64 globalTime); MA_API ma_uint64 ma_engine_get_time(const ma_engine* pEngine); /* Deprecated. Use ma_engine_get_time_in_pcm_frames(). Will be removed in version 0.12. */ MA_API ma_result ma_engine_set_time(ma_engine* pEngine, ma_uint64 globalTime); /* Deprecated. Use ma_engine_set_time_in_pcm_frames(). Will be removed in version 0.12. */ MA_API ma_uint32 ma_engine_get_channels(const ma_engine* pEngine); MA_API ma_uint32 ma_engine_get_sample_rate(const ma_engine* pEngine); MA_API ma_result ma_engine_start(ma_engine* pEngine); MA_API ma_result ma_engine_stop(ma_engine* pEngine); MA_API ma_result ma_engine_set_volume(ma_engine* pEngine, float volume); MA_API float ma_engine_get_volume(ma_engine* pEngine); MA_API ma_result ma_engine_set_gain_db(ma_engine* pEngine, float gainDB); MA_API float ma_engine_get_gain_db(ma_engine* pEngine); MA_API ma_uint32 ma_engine_get_listener_count(const ma_engine* pEngine); MA_API ma_uint32 ma_engine_find_closest_listener(const ma_engine* pEngine, float absolutePosX, float absolutePosY, float absolutePosZ); MA_API void ma_engine_listener_set_position(ma_engine* pEngine, ma_uint32 listenerIndex, float x, float y, float z); MA_API ma_vec3f ma_engine_listener_get_position(const ma_engine* pEngine, ma_uint32 listenerIndex); MA_API void ma_engine_listener_set_direction(ma_engine* pEngine, ma_uint32 listenerIndex, float x, float y, float z); MA_API ma_vec3f ma_engine_listener_get_direction(const ma_engine* pEngine, ma_uint32 listenerIndex); MA_API void ma_engine_listener_set_velocity(ma_engine* pEngine, ma_uint32 listenerIndex, float x, float y, float z); MA_API ma_vec3f ma_engine_listener_get_velocity(const ma_engine* pEngine, ma_uint32 listenerIndex); MA_API void ma_engine_listener_set_cone(ma_engine* pEngine, ma_uint32 listenerIndex, float innerAngleInRadians, float outerAngleInRadians, float outerGain); MA_API void ma_engine_listener_get_cone(const ma_engine* pEngine, ma_uint32 listenerIndex, float* pInnerAngleInRadians, float* pOuterAngleInRadians, float* pOuterGain); MA_API void ma_engine_listener_set_world_up(ma_engine* pEngine, ma_uint32 listenerIndex, float x, float y, float z); MA_API ma_vec3f ma_engine_listener_get_world_up(const ma_engine* pEngine, ma_uint32 listenerIndex); MA_API void ma_engine_listener_set_enabled(ma_engine* pEngine, ma_uint32 listenerIndex, ma_bool32 isEnabled); MA_API ma_bool32 ma_engine_listener_is_enabled(const ma_engine* pEngine, ma_uint32 listenerIndex); #ifndef MA_NO_RESOURCE_MANAGER MA_API ma_result ma_engine_play_sound_ex(ma_engine* pEngine, const char* pFilePath, ma_node* pNode, ma_uint32 nodeInputBusIndex); MA_API ma_result ma_engine_play_sound(ma_engine* pEngine, const char* pFilePath, ma_sound_group* pGroup); /* Fire and forget. */ #endif #ifndef MA_NO_RESOURCE_MANAGER MA_API ma_result ma_sound_init_from_file(ma_engine* pEngine, const char* pFilePath, ma_uint32 flags, ma_sound_group* pGroup, ma_fence* pDoneFence, ma_sound* pSound); MA_API ma_result ma_sound_init_from_file_w(ma_engine* pEngine, const wchar_t* pFilePath, ma_uint32 flags, ma_sound_group* pGroup, ma_fence* pDoneFence, ma_sound* pSound); MA_API ma_result ma_sound_init_copy(ma_engine* pEngine, const ma_sound* pExistingSound, ma_uint32 flags, ma_sound_group* pGroup, ma_sound* pSound); #endif MA_API ma_result ma_sound_init_from_data_source(ma_engine* pEngine, ma_data_source* pDataSource, ma_uint32 flags, ma_sound_group* pGroup, ma_sound* pSound); MA_API ma_result ma_sound_init_ex(ma_engine* pEngine, const ma_sound_config* pConfig, ma_sound* pSound); MA_API void ma_sound_uninit(ma_sound* pSound); MA_API ma_engine* ma_sound_get_engine(const ma_sound* pSound); MA_API ma_data_source* ma_sound_get_data_source(const ma_sound* pSound); MA_API ma_result ma_sound_start(ma_sound* pSound); MA_API ma_result ma_sound_stop(ma_sound* pSound); MA_API ma_result ma_sound_stop_with_fade_in_pcm_frames(ma_sound* pSound, ma_uint64 fadeLengthInFrames); /* Will overwrite any scheduled stop and fade. */ MA_API ma_result ma_sound_stop_with_fade_in_milliseconds(ma_sound* pSound, ma_uint64 fadeLengthInFrames); /* Will overwrite any scheduled stop and fade. */ MA_API void ma_sound_set_volume(ma_sound* pSound, float volume); MA_API float ma_sound_get_volume(const ma_sound* pSound); MA_API void ma_sound_set_pan(ma_sound* pSound, float pan); MA_API float ma_sound_get_pan(const ma_sound* pSound); MA_API void ma_sound_set_pan_mode(ma_sound* pSound, ma_pan_mode panMode); MA_API ma_pan_mode ma_sound_get_pan_mode(const ma_sound* pSound); MA_API void ma_sound_set_pitch(ma_sound* pSound, float pitch); MA_API float ma_sound_get_pitch(const ma_sound* pSound); MA_API void ma_sound_set_spatialization_enabled(ma_sound* pSound, ma_bool32 enabled); MA_API ma_bool32 ma_sound_is_spatialization_enabled(const ma_sound* pSound); MA_API void ma_sound_set_pinned_listener_index(ma_sound* pSound, ma_uint32 listenerIndex); MA_API ma_uint32 ma_sound_get_pinned_listener_index(const ma_sound* pSound); MA_API ma_uint32 ma_sound_get_listener_index(const ma_sound* pSound); MA_API ma_vec3f ma_sound_get_direction_to_listener(const ma_sound* pSound); MA_API void ma_sound_set_position(ma_sound* pSound, float x, float y, float z); MA_API ma_vec3f ma_sound_get_position(const ma_sound* pSound); MA_API void ma_sound_set_direction(ma_sound* pSound, float x, float y, float z); MA_API ma_vec3f ma_sound_get_direction(const ma_sound* pSound); MA_API void ma_sound_set_velocity(ma_sound* pSound, float x, float y, float z); MA_API ma_vec3f ma_sound_get_velocity(const ma_sound* pSound); MA_API void ma_sound_set_attenuation_model(ma_sound* pSound, ma_attenuation_model attenuationModel); MA_API ma_attenuation_model ma_sound_get_attenuation_model(const ma_sound* pSound); MA_API void ma_sound_set_positioning(ma_sound* pSound, ma_positioning positioning); MA_API ma_positioning ma_sound_get_positioning(const ma_sound* pSound); MA_API void ma_sound_set_rolloff(ma_sound* pSound, float rolloff); MA_API float ma_sound_get_rolloff(const ma_sound* pSound); MA_API void ma_sound_set_min_gain(ma_sound* pSound, float minGain); MA_API float ma_sound_get_min_gain(const ma_sound* pSound); MA_API void ma_sound_set_max_gain(ma_sound* pSound, float maxGain); MA_API float ma_sound_get_max_gain(const ma_sound* pSound); MA_API void ma_sound_set_min_distance(ma_sound* pSound, float minDistance); MA_API float ma_sound_get_min_distance(const ma_sound* pSound); MA_API void ma_sound_set_max_distance(ma_sound* pSound, float maxDistance); MA_API float ma_sound_get_max_distance(const ma_sound* pSound); MA_API void ma_sound_set_cone(ma_sound* pSound, float innerAngleInRadians, float outerAngleInRadians, float outerGain); MA_API void ma_sound_get_cone(const ma_sound* pSound, float* pInnerAngleInRadians, float* pOuterAngleInRadians, float* pOuterGain); MA_API void ma_sound_set_doppler_factor(ma_sound* pSound, float dopplerFactor); MA_API float ma_sound_get_doppler_factor(const ma_sound* pSound); MA_API void ma_sound_set_directional_attenuation_factor(ma_sound* pSound, float directionalAttenuationFactor); MA_API float ma_sound_get_directional_attenuation_factor(const ma_sound* pSound); MA_API void ma_sound_set_fade_in_pcm_frames(ma_sound* pSound, float volumeBeg, float volumeEnd, ma_uint64 fadeLengthInFrames); MA_API void ma_sound_set_fade_in_milliseconds(ma_sound* pSound, float volumeBeg, float volumeEnd, ma_uint64 fadeLengthInMilliseconds); MA_API void ma_sound_set_fade_start_in_pcm_frames(ma_sound* pSound, float volumeBeg, float volumeEnd, ma_uint64 fadeLengthInFrames, ma_uint64 absoluteGlobalTimeInFrames); MA_API void ma_sound_set_fade_start_in_milliseconds(ma_sound* pSound, float volumeBeg, float volumeEnd, ma_uint64 fadeLengthInMilliseconds, ma_uint64 absoluteGlobalTimeInMilliseconds); MA_API float ma_sound_get_current_fade_volume(const ma_sound* pSound); MA_API void ma_sound_set_start_time_in_pcm_frames(ma_sound* pSound, ma_uint64 absoluteGlobalTimeInFrames); MA_API void ma_sound_set_start_time_in_milliseconds(ma_sound* pSound, ma_uint64 absoluteGlobalTimeInMilliseconds); MA_API void ma_sound_set_stop_time_in_pcm_frames(ma_sound* pSound, ma_uint64 absoluteGlobalTimeInFrames); MA_API void ma_sound_set_stop_time_in_milliseconds(ma_sound* pSound, ma_uint64 absoluteGlobalTimeInMilliseconds); MA_API void ma_sound_set_stop_time_with_fade_in_pcm_frames(ma_sound* pSound, ma_uint64 stopAbsoluteGlobalTimeInFrames, ma_uint64 fadeLengthInFrames); MA_API void ma_sound_set_stop_time_with_fade_in_milliseconds(ma_sound* pSound, ma_uint64 stopAbsoluteGlobalTimeInMilliseconds, ma_uint64 fadeLengthInMilliseconds); MA_API ma_bool32 ma_sound_is_playing(const ma_sound* pSound); MA_API ma_uint64 ma_sound_get_time_in_pcm_frames(const ma_sound* pSound); MA_API ma_uint64 ma_sound_get_time_in_milliseconds(const ma_sound* pSound); MA_API void ma_sound_set_looping(ma_sound* pSound, ma_bool32 isLooping); MA_API ma_bool32 ma_sound_is_looping(const ma_sound* pSound); MA_API ma_bool32 ma_sound_at_end(const ma_sound* pSound); MA_API ma_result ma_sound_seek_to_pcm_frame(ma_sound* pSound, ma_uint64 frameIndex); /* Just a wrapper around ma_data_source_seek_to_pcm_frame(). */ MA_API ma_result ma_sound_get_data_format(ma_sound* pSound, ma_format* pFormat, ma_uint32* pChannels, ma_uint32* pSampleRate, ma_channel* pChannelMap, size_t channelMapCap); MA_API ma_result ma_sound_get_cursor_in_pcm_frames(ma_sound* pSound, ma_uint64* pCursor); MA_API ma_result ma_sound_get_length_in_pcm_frames(ma_sound* pSound, ma_uint64* pLength); MA_API ma_result ma_sound_get_cursor_in_seconds(ma_sound* pSound, float* pCursor); MA_API ma_result ma_sound_get_length_in_seconds(ma_sound* pSound, float* pLength); MA_API ma_result ma_sound_set_end_callback(ma_sound* pSound, ma_sound_end_proc callback, void* pUserData); MA_API ma_result ma_sound_group_init(ma_engine* pEngine, ma_uint32 flags, ma_sound_group* pParentGroup, ma_sound_group* pGroup); MA_API ma_result ma_sound_group_init_ex(ma_engine* pEngine, const ma_sound_group_config* pConfig, ma_sound_group* pGroup); MA_API void ma_sound_group_uninit(ma_sound_group* pGroup); MA_API ma_engine* ma_sound_group_get_engine(const ma_sound_group* pGroup); MA_API ma_result ma_sound_group_start(ma_sound_group* pGroup); MA_API ma_result ma_sound_group_stop(ma_sound_group* pGroup); MA_API void ma_sound_group_set_volume(ma_sound_group* pGroup, float volume); MA_API float ma_sound_group_get_volume(const ma_sound_group* pGroup); MA_API void ma_sound_group_set_pan(ma_sound_group* pGroup, float pan); MA_API float ma_sound_group_get_pan(const ma_sound_group* pGroup); MA_API void ma_sound_group_set_pan_mode(ma_sound_group* pGroup, ma_pan_mode panMode); MA_API ma_pan_mode ma_sound_group_get_pan_mode(const ma_sound_group* pGroup); MA_API void ma_sound_group_set_pitch(ma_sound_group* pGroup, float pitch); MA_API float ma_sound_group_get_pitch(const ma_sound_group* pGroup); MA_API void ma_sound_group_set_spatialization_enabled(ma_sound_group* pGroup, ma_bool32 enabled); MA_API ma_bool32 ma_sound_group_is_spatialization_enabled(const ma_sound_group* pGroup); MA_API void ma_sound_group_set_pinned_listener_index(ma_sound_group* pGroup, ma_uint32 listenerIndex); MA_API ma_uint32 ma_sound_group_get_pinned_listener_index(const ma_sound_group* pGroup); MA_API ma_uint32 ma_sound_group_get_listener_index(const ma_sound_group* pGroup); MA_API ma_vec3f ma_sound_group_get_direction_to_listener(const ma_sound_group* pGroup); MA_API void ma_sound_group_set_position(ma_sound_group* pGroup, float x, float y, float z); MA_API ma_vec3f ma_sound_group_get_position(const ma_sound_group* pGroup); MA_API void ma_sound_group_set_direction(ma_sound_group* pGroup, float x, float y, float z); MA_API ma_vec3f ma_sound_group_get_direction(const ma_sound_group* pGroup); MA_API void ma_sound_group_set_velocity(ma_sound_group* pGroup, float x, float y, float z); MA_API ma_vec3f ma_sound_group_get_velocity(const ma_sound_group* pGroup); MA_API void ma_sound_group_set_attenuation_model(ma_sound_group* pGroup, ma_attenuation_model attenuationModel); MA_API ma_attenuation_model ma_sound_group_get_attenuation_model(const ma_sound_group* pGroup); MA_API void ma_sound_group_set_positioning(ma_sound_group* pGroup, ma_positioning positioning); MA_API ma_positioning ma_sound_group_get_positioning(const ma_sound_group* pGroup); MA_API void ma_sound_group_set_rolloff(ma_sound_group* pGroup, float rolloff); MA_API float ma_sound_group_get_rolloff(const ma_sound_group* pGroup); MA_API void ma_sound_group_set_min_gain(ma_sound_group* pGroup, float minGain); MA_API float ma_sound_group_get_min_gain(const ma_sound_group* pGroup); MA_API void ma_sound_group_set_max_gain(ma_sound_group* pGroup, float maxGain); MA_API float ma_sound_group_get_max_gain(const ma_sound_group* pGroup); MA_API void ma_sound_group_set_min_distance(ma_sound_group* pGroup, float minDistance); MA_API float ma_sound_group_get_min_distance(const ma_sound_group* pGroup); MA_API void ma_sound_group_set_max_distance(ma_sound_group* pGroup, float maxDistance); MA_API float ma_sound_group_get_max_distance(const ma_sound_group* pGroup); MA_API void ma_sound_group_set_cone(ma_sound_group* pGroup, float innerAngleInRadians, float outerAngleInRadians, float outerGain); MA_API void ma_sound_group_get_cone(const ma_sound_group* pGroup, float* pInnerAngleInRadians, float* pOuterAngleInRadians, float* pOuterGain); MA_API void ma_sound_group_set_doppler_factor(ma_sound_group* pGroup, float dopplerFactor); MA_API float ma_sound_group_get_doppler_factor(const ma_sound_group* pGroup); MA_API void ma_sound_group_set_directional_attenuation_factor(ma_sound_group* pGroup, float directionalAttenuationFactor); MA_API float ma_sound_group_get_directional_attenuation_factor(const ma_sound_group* pGroup); MA_API void ma_sound_group_set_fade_in_pcm_frames(ma_sound_group* pGroup, float volumeBeg, float volumeEnd, ma_uint64 fadeLengthInFrames); MA_API void ma_sound_group_set_fade_in_milliseconds(ma_sound_group* pGroup, float volumeBeg, float volumeEnd, ma_uint64 fadeLengthInMilliseconds); MA_API float ma_sound_group_get_current_fade_volume(ma_sound_group* pGroup); MA_API void ma_sound_group_set_start_time_in_pcm_frames(ma_sound_group* pGroup, ma_uint64 absoluteGlobalTimeInFrames); MA_API void ma_sound_group_set_start_time_in_milliseconds(ma_sound_group* pGroup, ma_uint64 absoluteGlobalTimeInMilliseconds); MA_API void ma_sound_group_set_stop_time_in_pcm_frames(ma_sound_group* pGroup, ma_uint64 absoluteGlobalTimeInFrames); MA_API void ma_sound_group_set_stop_time_in_milliseconds(ma_sound_group* pGroup, ma_uint64 absoluteGlobalTimeInMilliseconds); MA_API ma_bool32 ma_sound_group_is_playing(const ma_sound_group* pGroup); MA_API ma_uint64 ma_sound_group_get_time_in_pcm_frames(const ma_sound_group* pGroup); #endif /* MA_NO_ENGINE */ /* END SECTION: miniaudio_engine.h */ #ifdef __cplusplus } #endif #endif /* miniaudio_h */ /* This is for preventing greying out of the implementation section. */ #if defined(Q_CREATOR_RUN) || defined(__INTELLISENSE__) || defined(__CDT_PARSER__) #define MINIAUDIO_IMPLEMENTATION #endif /************************************************************************************************************************************************************ ************************************************************************************************************************************************************* IMPLEMENTATION ************************************************************************************************************************************************************* ************************************************************************************************************************************************************/ #if defined(MINIAUDIO_IMPLEMENTATION) || defined(MA_IMPLEMENTATION) #ifndef miniaudio_c #define miniaudio_c #include #include /* For INT_MAX */ #include /* sin(), etc. */ #include /* For malloc(), free(), wcstombs(). */ #include /* For memset() */ #include #include #if !defined(_MSC_VER) && !defined(__DMC__) #include /* For strcasecmp(). */ #include /* For wcslen(), wcsrtombs() */ #endif #ifdef _MSC_VER #include /* For _controlfp_s constants */ #endif #if defined(MA_WIN32) #include /* There's a possibility that WIN32_LEAN_AND_MEAN has been defined which will exclude some symbols such as STGM_READ and CLSCTL_ALL. We need to check these and define them ourselves if they're unavailable. */ #ifndef STGM_READ #define STGM_READ 0x00000000L #endif #ifndef CLSCTX_ALL #define CLSCTX_ALL 23 #endif /* IUnknown is used by both the WASAPI and DirectSound backends. It easier to just declare our version here. */ typedef struct ma_IUnknown ma_IUnknown; #endif #if !defined(MA_WIN32) #include #include /* select() (used for ma_sleep()). */ #include #endif #ifdef MA_NX #include /* For nanosleep() */ #endif #include /* For fstat(), etc. */ #ifdef MA_EMSCRIPTEN #include #endif /* Architecture Detection */ #if !defined(MA_64BIT) && !defined(MA_32BIT) #ifdef _WIN32 #ifdef _WIN64 #define MA_64BIT #else #define MA_32BIT #endif #endif #endif #if !defined(MA_64BIT) && !defined(MA_32BIT) #ifdef __GNUC__ #ifdef __LP64__ #define MA_64BIT #else #define MA_32BIT #endif #endif #endif #if !defined(MA_64BIT) && !defined(MA_32BIT) #include #if INTPTR_MAX == INT64_MAX #define MA_64BIT #else #define MA_32BIT #endif #endif #if defined(__arm__) || defined(_M_ARM) #define MA_ARM32 #endif #if defined(__arm64) || defined(__arm64__) || defined(__aarch64__) || defined(_M_ARM64) #define MA_ARM64 #endif #if defined(__x86_64__) || defined(_M_X64) #define MA_X64 #elif defined(__i386) || defined(_M_IX86) #define MA_X86 #elif defined(MA_ARM32) || defined(MA_ARM64) #define MA_ARM #endif /* Intrinsics Support */ #if (defined(MA_X64) || defined(MA_X86)) && !defined(__COSMOPOLITAN__) #if defined(_MSC_VER) && !defined(__clang__) /* MSVC. */ #if _MSC_VER >= 1400 && !defined(MA_NO_SSE2) /* 2005 */ #define MA_SUPPORT_SSE2 #endif /*#if _MSC_VER >= 1600 && !defined(MA_NO_AVX)*/ /* 2010 */ /* #define MA_SUPPORT_AVX*/ /*#endif*/ #if _MSC_VER >= 1700 && !defined(MA_NO_AVX2) /* 2012 */ #define MA_SUPPORT_AVX2 #endif #else /* Assume GNUC-style. */ #if defined(__SSE2__) && !defined(MA_NO_SSE2) #define MA_SUPPORT_SSE2 #endif /*#if defined(__AVX__) && !defined(MA_NO_AVX)*/ /* #define MA_SUPPORT_AVX*/ /*#endif*/ #if defined(__AVX2__) && !defined(MA_NO_AVX2) #define MA_SUPPORT_AVX2 #endif #endif /* If at this point we still haven't determined compiler support for the intrinsics just fall back to __has_include. */ #if !defined(__GNUC__) && !defined(__clang__) && defined(__has_include) #if !defined(MA_SUPPORT_SSE2) && !defined(MA_NO_SSE2) && __has_include() #define MA_SUPPORT_SSE2 #endif /*#if !defined(MA_SUPPORT_AVX) && !defined(MA_NO_AVX) && __has_include()*/ /* #define MA_SUPPORT_AVX*/ /*#endif*/ #if !defined(MA_SUPPORT_AVX2) && !defined(MA_NO_AVX2) && __has_include() #define MA_SUPPORT_AVX2 #endif #endif #if defined(MA_SUPPORT_AVX2) || defined(MA_SUPPORT_AVX) #include #elif defined(MA_SUPPORT_SSE2) #include #endif #endif #if defined(MA_ARM) #if !defined(MA_NO_NEON) && (defined(__ARM_NEON) || defined(__aarch64__) || defined(_M_ARM64)) #define MA_SUPPORT_NEON #include #endif #endif /* Begin globally disabled warnings. */ #if defined(_MSC_VER) #pragma warning(push) #pragma warning(disable:4752) /* found Intel(R) Advanced Vector Extensions; consider using /arch:AVX */ #pragma warning(disable:4049) /* compiler limit : terminating line number emission */ #endif #if defined(MA_X64) || defined(MA_X86) #if defined(_MSC_VER) && !defined(__clang__) #if _MSC_VER >= 1400 #include static MA_INLINE void ma_cpuid(int info[4], int fid) { __cpuid(info, fid); } #else #define MA_NO_CPUID #endif #if _MSC_VER >= 1600 && (defined(_MSC_FULL_VER) && _MSC_FULL_VER >= 160040219) static MA_INLINE unsigned __int64 ma_xgetbv(int reg) { return _xgetbv(reg); } #else #define MA_NO_XGETBV #endif #elif (defined(__GNUC__) || defined(__clang__)) && !defined(MA_ANDROID) static MA_INLINE void ma_cpuid(int info[4], int fid) { /* It looks like the -fPIC option uses the ebx register which GCC complains about. We can work around this by just using a different register, the specific register of which I'm letting the compiler decide on. The "k" prefix is used to specify a 32-bit register. The {...} syntax is for supporting different assembly dialects. What's basically happening is that we're saving and restoring the ebx register manually. */ #if defined(MA_X86) && defined(__PIC__) __asm__ __volatile__ ( "xchg{l} {%%}ebx, %k1;" "cpuid;" "xchg{l} {%%}ebx, %k1;" : "=a"(info[0]), "=&r"(info[1]), "=c"(info[2]), "=d"(info[3]) : "a"(fid), "c"(0) ); #else __asm__ __volatile__ ( "cpuid" : "=a"(info[0]), "=b"(info[1]), "=c"(info[2]), "=d"(info[3]) : "a"(fid), "c"(0) ); #endif } static MA_INLINE ma_uint64 ma_xgetbv(int reg) { unsigned int hi; unsigned int lo; __asm__ __volatile__ ( "xgetbv" : "=a"(lo), "=d"(hi) : "c"(reg) ); return ((ma_uint64)hi << 32) | (ma_uint64)lo; } #else #define MA_NO_CPUID #define MA_NO_XGETBV #endif #else #define MA_NO_CPUID #define MA_NO_XGETBV #endif static MA_INLINE ma_bool32 ma_has_sse2(void) { #if defined(MA_SUPPORT_SSE2) #if (defined(MA_X64) || defined(MA_X86)) && !defined(MA_NO_SSE2) #if defined(MA_X64) return MA_TRUE; /* 64-bit targets always support SSE2. */ #elif (defined(_M_IX86_FP) && _M_IX86_FP == 2) || defined(__SSE2__) return MA_TRUE; /* If the compiler is allowed to freely generate SSE2 code we can assume support. */ #else #if defined(MA_NO_CPUID) return MA_FALSE; #else int info[4]; ma_cpuid(info, 1); return (info[3] & (1 << 26)) != 0; #endif #endif #else return MA_FALSE; /* SSE2 is only supported on x86 and x64 architectures. */ #endif #else return MA_FALSE; /* No compiler support. */ #endif } #if 0 static MA_INLINE ma_bool32 ma_has_avx() { #if defined(MA_SUPPORT_AVX) #if (defined(MA_X64) || defined(MA_X86)) && !defined(MA_NO_AVX) #if defined(_AVX_) || defined(__AVX__) return MA_TRUE; /* If the compiler is allowed to freely generate AVX code we can assume support. */ #else /* AVX requires both CPU and OS support. */ #if defined(MA_NO_CPUID) || defined(MA_NO_XGETBV) return MA_FALSE; #else int info[4]; ma_cpuid(info, 1); if (((info[2] & (1 << 27)) != 0) && ((info[2] & (1 << 28)) != 0)) { ma_uint64 xrc = ma_xgetbv(0); if ((xrc & 0x06) == 0x06) { return MA_TRUE; } else { return MA_FALSE; } } else { return MA_FALSE; } #endif #endif #else return MA_FALSE; /* AVX is only supported on x86 and x64 architectures. */ #endif #else return MA_FALSE; /* No compiler support. */ #endif } #endif static MA_INLINE ma_bool32 ma_has_avx2(void) { #if defined(MA_SUPPORT_AVX2) #if (defined(MA_X64) || defined(MA_X86)) && !defined(MA_NO_AVX2) #if defined(_AVX2_) || defined(__AVX2__) return MA_TRUE; /* If the compiler is allowed to freely generate AVX2 code we can assume support. */ #else /* AVX2 requires both CPU and OS support. */ #if defined(MA_NO_CPUID) || defined(MA_NO_XGETBV) return MA_FALSE; #else int info1[4]; int info7[4]; ma_cpuid(info1, 1); ma_cpuid(info7, 7); if (((info1[2] & (1 << 27)) != 0) && ((info7[1] & (1 << 5)) != 0)) { ma_uint64 xrc = ma_xgetbv(0); if ((xrc & 0x06) == 0x06) { return MA_TRUE; } else { return MA_FALSE; } } else { return MA_FALSE; } #endif #endif #else return MA_FALSE; /* AVX2 is only supported on x86 and x64 architectures. */ #endif #else return MA_FALSE; /* No compiler support. */ #endif } static MA_INLINE ma_bool32 ma_has_neon(void) { #if defined(MA_SUPPORT_NEON) #if defined(MA_ARM) && !defined(MA_NO_NEON) #if (defined(__ARM_NEON) || defined(__aarch64__) || defined(_M_ARM64)) return MA_TRUE; /* If the compiler is allowed to freely generate NEON code we can assume support. */ #else /* TODO: Runtime check. */ return MA_FALSE; #endif #else return MA_FALSE; /* NEON is only supported on ARM architectures. */ #endif #else return MA_FALSE; /* No compiler support. */ #endif } #if defined(__has_builtin) #define MA_COMPILER_HAS_BUILTIN(x) __has_builtin(x) #else #define MA_COMPILER_HAS_BUILTIN(x) 0 #endif #ifndef MA_ASSUME #if MA_COMPILER_HAS_BUILTIN(__builtin_assume) #define MA_ASSUME(x) __builtin_assume(x) #elif MA_COMPILER_HAS_BUILTIN(__builtin_unreachable) #define MA_ASSUME(x) do { if (!(x)) __builtin_unreachable(); } while (0) #elif defined(_MSC_VER) #define MA_ASSUME(x) __assume(x) #else #define MA_ASSUME(x) (void)(x) #endif #endif #ifndef MA_RESTRICT #if defined(__clang__) || defined(__GNUC__) || defined(_MSC_VER) #define MA_RESTRICT __restrict #else #define MA_RESTRICT #endif #endif #if defined(_MSC_VER) && _MSC_VER >= 1400 #define MA_HAS_BYTESWAP16_INTRINSIC #define MA_HAS_BYTESWAP32_INTRINSIC #define MA_HAS_BYTESWAP64_INTRINSIC #elif defined(__clang__) #if MA_COMPILER_HAS_BUILTIN(__builtin_bswap16) #define MA_HAS_BYTESWAP16_INTRINSIC #endif #if MA_COMPILER_HAS_BUILTIN(__builtin_bswap32) #define MA_HAS_BYTESWAP32_INTRINSIC #endif #if MA_COMPILER_HAS_BUILTIN(__builtin_bswap64) #define MA_HAS_BYTESWAP64_INTRINSIC #endif #elif defined(__GNUC__) #if ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)) #define MA_HAS_BYTESWAP32_INTRINSIC #define MA_HAS_BYTESWAP64_INTRINSIC #endif #if ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)) #define MA_HAS_BYTESWAP16_INTRINSIC #endif #endif static MA_INLINE ma_bool32 ma_is_little_endian(void) { #if defined(MA_X86) || defined(MA_X64) return MA_TRUE; #else int n = 1; return (*(char*)&n) == 1; #endif } static MA_INLINE ma_bool32 ma_is_big_endian(void) { return !ma_is_little_endian(); } static MA_INLINE ma_uint32 ma_swap_endian_uint32(ma_uint32 n) { #ifdef MA_HAS_BYTESWAP32_INTRINSIC #if defined(_MSC_VER) return _byteswap_ulong(n); #elif defined(__GNUC__) || defined(__clang__) #if defined(MA_ARM) && (defined(__ARM_ARCH) && __ARM_ARCH >= 6) && !defined(MA_64BIT) /* <-- 64-bit inline assembly has not been tested, so disabling for now. */ /* Inline assembly optimized implementation for ARM. In my testing, GCC does not generate optimized code with __builtin_bswap32(). */ ma_uint32 r; __asm__ __volatile__ ( #if defined(MA_64BIT) "rev %w[out], %w[in]" : [out]"=r"(r) : [in]"r"(n) /* <-- This is untested. If someone in the community could test this, that would be appreciated! */ #else "rev %[out], %[in]" : [out]"=r"(r) : [in]"r"(n) #endif ); return r; #else return __builtin_bswap32(n); #endif #else #error "This compiler does not support the byte swap intrinsic." #endif #else return ((n & 0xFF000000) >> 24) | ((n & 0x00FF0000) >> 8) | ((n & 0x0000FF00) << 8) | ((n & 0x000000FF) << 24); #endif } #if !defined(MA_EMSCRIPTEN) #ifdef MA_WIN32 static void ma_sleep__win32(ma_uint32 milliseconds) { Sleep((DWORD)milliseconds); } #endif #ifdef MA_POSIX static void ma_sleep__posix(ma_uint32 milliseconds) { #ifdef MA_EMSCRIPTEN (void)milliseconds; MA_ASSERT(MA_FALSE); /* The Emscripten build should never sleep. */ #else #if (defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 199309L) || defined(MA_NX) struct timespec ts; ts.tv_sec = milliseconds / 1000; ts.tv_nsec = milliseconds % 1000 * 1000000; nanosleep(&ts, NULL); #else struct timeval tv; tv.tv_sec = milliseconds / 1000; tv.tv_usec = milliseconds % 1000 * 1000; select(0, NULL, NULL, NULL, &tv); #endif #endif } #endif static MA_INLINE void ma_sleep(ma_uint32 milliseconds) { #ifdef MA_WIN32 ma_sleep__win32(milliseconds); #endif #ifdef MA_POSIX ma_sleep__posix(milliseconds); #endif } #endif static MA_INLINE void ma_yield(void) { #if defined(__i386) || defined(_M_IX86) || defined(__x86_64__) || defined(_M_X64) /* x86/x64 */ #if (defined(_MSC_VER) || defined(__WATCOMC__) || defined(__DMC__)) && !defined(__clang__) #if _MSC_VER >= 1400 _mm_pause(); #else #if defined(__DMC__) /* Digital Mars does not recognize the PAUSE opcode. Fall back to NOP. */ __asm nop; #else __asm pause; #endif #endif #else __asm__ __volatile__ ("pause"); #endif #elif (defined(__arm__) && defined(__ARM_ARCH) && __ARM_ARCH >= 7) || defined(_M_ARM64) || (defined(_M_ARM) && _M_ARM >= 7) || defined(__ARM_ARCH_6K__) || defined(__ARM_ARCH_6T2__) /* ARM */ #if defined(_MSC_VER) /* Apparently there is a __yield() intrinsic that's compatible with ARM, but I cannot find documentation for it nor can I find where it's declared. */ __yield(); #else __asm__ __volatile__ ("yield"); /* ARMv6K/ARMv6T2 and above. */ #endif #else /* Unknown or unsupported architecture. No-op. */ #endif } #define MA_MM_DENORMALS_ZERO_MASK 0x0040 #define MA_MM_FLUSH_ZERO_MASK 0x8000 static MA_INLINE unsigned int ma_disable_denormals(void) { unsigned int prevState; #if defined(_MSC_VER) { /* Older versions of Visual Studio don't support the "safe" versions of _controlfp_s(). I don't know which version of Visual Studio first added support for _controlfp_s(), but I do know that VC6 lacks support. _MSC_VER = 1200 is VC6, but if you get compilation errors on older versions of Visual Studio, let me know and I'll make the necessary adjustment. */ #if _MSC_VER <= 1200 { prevState = _statusfp(); _controlfp(prevState | _DN_FLUSH, _MCW_DN); } #else { unsigned int unused; _controlfp_s(&prevState, 0, 0); _controlfp_s(&unused, prevState | _DN_FLUSH, _MCW_DN); } #endif } #elif defined(MA_X86) || defined(MA_X64) { #if defined(__SSE2__) && !(defined(__TINYC__) || defined(__WATCOMC__) || defined(__COSMOPOLITAN__)) /* <-- Add compilers that lack support for _mm_getcsr() and _mm_setcsr() to this list. */ { prevState = _mm_getcsr(); _mm_setcsr(prevState | MA_MM_DENORMALS_ZERO_MASK | MA_MM_FLUSH_ZERO_MASK); } #else { /* x88/64, but no support for _mm_getcsr()/_mm_setcsr(). May need to fall back to inlined assembly here. */ prevState = 0; } #endif } #else { /* Unknown or unsupported architecture. No-op. */ prevState = 0; } #endif return prevState; } static MA_INLINE void ma_restore_denormals(unsigned int prevState) { #if defined(_MSC_VER) { /* Older versions of Visual Studio do not support _controlfp_s(). See ma_disable_denormals(). */ #if _MSC_VER <= 1200 { _controlfp(prevState, _MCW_DN); } #else { unsigned int unused; _controlfp_s(&unused, prevState, _MCW_DN); } #endif } #elif defined(MA_X86) || defined(MA_X64) { #if defined(__SSE2__) && !(defined(__TINYC__) || defined(__WATCOMC__) || defined(__COSMOPOLITAN__)) /* <-- Add compilers that lack support for _mm_getcsr() and _mm_setcsr() to this list. */ { _mm_setcsr(prevState); } #else { /* x88/64, but no support for _mm_getcsr()/_mm_setcsr(). May need to fall back to inlined assembly here. */ (void)prevState; } #endif } #else { /* Unknown or unsupported architecture. No-op. */ (void)prevState; } #endif } #ifdef MA_ANDROID #include int ma_android_sdk_version() { char sdkVersion[PROP_VALUE_MAX + 1] = {0, }; if (__system_property_get("ro.build.version.sdk", sdkVersion)) { return atoi(sdkVersion); } return 0; } #endif #ifndef MA_COINIT_VALUE #define MA_COINIT_VALUE 0 /* 0 = COINIT_MULTITHREADED */ #endif #ifndef MA_FLT_MAX #ifdef FLT_MAX #define MA_FLT_MAX FLT_MAX #else #define MA_FLT_MAX 3.402823466e+38F #endif #endif #ifndef MA_PI #define MA_PI 3.14159265358979323846264f #endif #ifndef MA_PI_D #define MA_PI_D 3.14159265358979323846264 #endif #ifndef MA_TAU #define MA_TAU 6.28318530717958647693f #endif #ifndef MA_TAU_D #define MA_TAU_D 6.28318530717958647693 #endif /* The default format when ma_format_unknown (0) is requested when initializing a device. */ #ifndef MA_DEFAULT_FORMAT #define MA_DEFAULT_FORMAT ma_format_f32 #endif /* The default channel count to use when 0 is used when initializing a device. */ #ifndef MA_DEFAULT_CHANNELS #define MA_DEFAULT_CHANNELS 2 #endif /* The default sample rate to use when 0 is used when initializing a device. */ #ifndef MA_DEFAULT_SAMPLE_RATE #define MA_DEFAULT_SAMPLE_RATE 48000 #endif /* Default periods when none is specified in ma_device_init(). More periods means more work on the CPU. */ #ifndef MA_DEFAULT_PERIODS #define MA_DEFAULT_PERIODS 3 #endif /* The default period size in milliseconds for low latency mode. */ #ifndef MA_DEFAULT_PERIOD_SIZE_IN_MILLISECONDS_LOW_LATENCY #define MA_DEFAULT_PERIOD_SIZE_IN_MILLISECONDS_LOW_LATENCY 10 #endif /* The default buffer size in milliseconds for conservative mode. */ #ifndef MA_DEFAULT_PERIOD_SIZE_IN_MILLISECONDS_CONSERVATIVE #define MA_DEFAULT_PERIOD_SIZE_IN_MILLISECONDS_CONSERVATIVE 100 #endif /* The default LPF filter order for linear resampling. Note that this is clamped to MA_MAX_FILTER_ORDER. */ #ifndef MA_DEFAULT_RESAMPLER_LPF_ORDER #if MA_MAX_FILTER_ORDER >= 4 #define MA_DEFAULT_RESAMPLER_LPF_ORDER 4 #else #define MA_DEFAULT_RESAMPLER_LPF_ORDER MA_MAX_FILTER_ORDER #endif #endif #if defined(__clang__) || (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wunused-variable" #endif /* Standard sample rates, in order of priority. */ static ma_uint32 g_maStandardSampleRatePriorities[] = { (ma_uint32)ma_standard_sample_rate_48000, (ma_uint32)ma_standard_sample_rate_44100, (ma_uint32)ma_standard_sample_rate_32000, (ma_uint32)ma_standard_sample_rate_24000, (ma_uint32)ma_standard_sample_rate_22050, (ma_uint32)ma_standard_sample_rate_88200, (ma_uint32)ma_standard_sample_rate_96000, (ma_uint32)ma_standard_sample_rate_176400, (ma_uint32)ma_standard_sample_rate_192000, (ma_uint32)ma_standard_sample_rate_16000, (ma_uint32)ma_standard_sample_rate_11025, (ma_uint32)ma_standard_sample_rate_8000, (ma_uint32)ma_standard_sample_rate_352800, (ma_uint32)ma_standard_sample_rate_384000 }; static MA_INLINE ma_bool32 ma_is_standard_sample_rate(ma_uint32 sampleRate) { ma_uint32 iSampleRate; for (iSampleRate = 0; iSampleRate < sizeof(g_maStandardSampleRatePriorities) / sizeof(g_maStandardSampleRatePriorities[0]); iSampleRate += 1) { if (g_maStandardSampleRatePriorities[iSampleRate] == sampleRate) { return MA_TRUE; } } /* Getting here means the sample rate is not supported. */ return MA_FALSE; } static ma_format g_maFormatPriorities[] = { ma_format_s16, /* Most common */ ma_format_f32, /*ma_format_s24_32,*/ /* Clean alignment */ ma_format_s32, ma_format_s24, /* Unclean alignment */ ma_format_u8 /* Low quality */ }; #if defined(__clang__) || (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))) #pragma GCC diagnostic pop #endif MA_API void ma_version(ma_uint32* pMajor, ma_uint32* pMinor, ma_uint32* pRevision) { if (pMajor) { *pMajor = MA_VERSION_MAJOR; } if (pMinor) { *pMinor = MA_VERSION_MINOR; } if (pRevision) { *pRevision = MA_VERSION_REVISION; } } MA_API const char* ma_version_string(void) { return MA_VERSION_STRING; } /****************************************************************************** Standard Library Stuff ******************************************************************************/ #ifndef MA_ASSERT #define MA_ASSERT(condition) assert(condition) #endif #ifndef MA_MALLOC #define MA_MALLOC(sz) malloc((sz)) #endif #ifndef MA_REALLOC #define MA_REALLOC(p, sz) realloc((p), (sz)) #endif #ifndef MA_FREE #define MA_FREE(p) free((p)) #endif static MA_INLINE void ma_zero_memory_default(void* p, size_t sz) { if (p == NULL) { MA_ASSERT(sz == 0); /* If this is triggered there's an error with the calling code. */ return; } if (sz > 0) { memset(p, 0, sz); } } #ifndef MA_ZERO_MEMORY #define MA_ZERO_MEMORY(p, sz) ma_zero_memory_default((p), (sz)) #endif #ifndef MA_COPY_MEMORY #define MA_COPY_MEMORY(dst, src, sz) memcpy((dst), (src), (sz)) #endif #ifndef MA_MOVE_MEMORY #define MA_MOVE_MEMORY(dst, src, sz) memmove((dst), (src), (sz)) #endif #define MA_ZERO_OBJECT(p) MA_ZERO_MEMORY((p), sizeof(*(p))) #define ma_countof(x) (sizeof(x) / sizeof(x[0])) #define ma_max(x, y) (((x) > (y)) ? (x) : (y)) #define ma_min(x, y) (((x) < (y)) ? (x) : (y)) #define ma_abs(x) (((x) > 0) ? (x) : -(x)) #define ma_clamp(x, lo, hi) (ma_max(lo, ma_min(x, hi))) #define ma_offset_ptr(p, offset) (((ma_uint8*)(p)) + (offset)) #define ma_align(x, a) (((x) + ((a)-1)) & ~((a)-1)) #define ma_align_64(x) ma_align(x, 8) #define ma_buffer_frame_capacity(buffer, channels, format) (sizeof(buffer) / ma_get_bytes_per_sample(format) / (channels)) static MA_INLINE double ma_sind(double x) { /* TODO: Implement custom sin(x). */ return sin(x); } static MA_INLINE double ma_expd(double x) { /* TODO: Implement custom exp(x). */ return exp(x); } static MA_INLINE double ma_logd(double x) { /* TODO: Implement custom log(x). */ return log(x); } static MA_INLINE double ma_powd(double x, double y) { /* TODO: Implement custom pow(x, y). */ return pow(x, y); } static MA_INLINE double ma_sqrtd(double x) { /* TODO: Implement custom sqrt(x). */ return sqrt(x); } static MA_INLINE float ma_rsqrtf(float x) { #if defined(MA_SUPPORT_SSE2) && !defined(MA_NO_SSE2) && (defined(MA_X64) || (defined(_M_IX86_FP) && _M_IX86_FP == 2) || defined(__SSE2__)) { /* For SSE we can use RSQRTSS. This Stack Overflow post suggests that compilers don't necessarily generate optimal code when using intrinsics: https://web.archive.org/web/20221211012522/https://stackoverflow.com/questions/32687079/getting-fewest-instructions-for-rsqrtss-wrapper I'm going to do something similar here, but a bit simpler. */ #if defined(__GNUC__) || defined(__clang__) { float result; __asm__ __volatile__("rsqrtss %1, %0" : "=x"(result) : "x"(x)); return result; } #else { return _mm_cvtss_f32(_mm_rsqrt_ss(_mm_set_ps1(x))); } #endif } #else { return 1 / (float)ma_sqrtd(x); } #endif } static MA_INLINE float ma_sinf(float x) { return (float)ma_sind((float)x); } static MA_INLINE double ma_cosd(double x) { return ma_sind((MA_PI_D*0.5) - x); } static MA_INLINE float ma_cosf(float x) { return (float)ma_cosd((float)x); } static MA_INLINE double ma_log10d(double x) { return ma_logd(x) * 0.43429448190325182765; } static MA_INLINE float ma_powf(float x, float y) { return (float)ma_powd((double)x, (double)y); } static MA_INLINE float ma_log10f(float x) { return (float)ma_log10d((double)x); } static MA_INLINE double ma_degrees_to_radians(double degrees) { return degrees * 0.01745329252; } static MA_INLINE double ma_radians_to_degrees(double radians) { return radians * 57.295779512896; } static MA_INLINE float ma_degrees_to_radians_f(float degrees) { return degrees * 0.01745329252f; } static MA_INLINE float ma_radians_to_degrees_f(float radians) { return radians * 57.295779512896f; } /* Return Values: 0: Success 22: EINVAL 34: ERANGE Not using symbolic constants for errors because I want to avoid #including errno.h These are marked as no-inline because of some bad code generation by Clang. None of these functions are used in any performance-critical code within miniaudio. */ MA_API MA_NO_INLINE int ma_strcpy_s(char* dst, size_t dstSizeInBytes, const char* src) { size_t i; if (dst == 0) { return 22; } if (dstSizeInBytes == 0) { return 34; } if (src == 0) { dst[0] = '\0'; return 22; } for (i = 0; i < dstSizeInBytes && src[i] != '\0'; ++i) { dst[i] = src[i]; } if (i < dstSizeInBytes) { dst[i] = '\0'; return 0; } dst[0] = '\0'; return 34; } MA_API MA_NO_INLINE int ma_wcscpy_s(wchar_t* dst, size_t dstCap, const wchar_t* src) { size_t i; if (dst == 0) { return 22; } if (dstCap == 0) { return 34; } if (src == 0) { dst[0] = '\0'; return 22; } for (i = 0; i < dstCap && src[i] != '\0'; ++i) { dst[i] = src[i]; } if (i < dstCap) { dst[i] = '\0'; return 0; } dst[0] = '\0'; return 34; } MA_API MA_NO_INLINE int ma_strncpy_s(char* dst, size_t dstSizeInBytes, const char* src, size_t count) { size_t maxcount; size_t i; if (dst == 0) { return 22; } if (dstSizeInBytes == 0) { return 34; } if (src == 0) { dst[0] = '\0'; return 22; } maxcount = count; if (count == ((size_t)-1) || count >= dstSizeInBytes) { /* -1 = _TRUNCATE */ maxcount = dstSizeInBytes - 1; } for (i = 0; i < maxcount && src[i] != '\0'; ++i) { dst[i] = src[i]; } if (src[i] == '\0' || i == count || count == ((size_t)-1)) { dst[i] = '\0'; return 0; } dst[0] = '\0'; return 34; } MA_API MA_NO_INLINE int ma_strcat_s(char* dst, size_t dstSizeInBytes, const char* src) { char* dstorig; if (dst == 0) { return 22; } if (dstSizeInBytes == 0) { return 34; } if (src == 0) { dst[0] = '\0'; return 22; } dstorig = dst; while (dstSizeInBytes > 0 && dst[0] != '\0') { dst += 1; dstSizeInBytes -= 1; } if (dstSizeInBytes == 0) { return 22; /* Unterminated. */ } while (dstSizeInBytes > 0 && src[0] != '\0') { *dst++ = *src++; dstSizeInBytes -= 1; } if (dstSizeInBytes > 0) { dst[0] = '\0'; } else { dstorig[0] = '\0'; return 34; } return 0; } MA_API MA_NO_INLINE int ma_strncat_s(char* dst, size_t dstSizeInBytes, const char* src, size_t count) { char* dstorig; if (dst == 0) { return 22; } if (dstSizeInBytes == 0) { return 34; } if (src == 0) { return 22; } dstorig = dst; while (dstSizeInBytes > 0 && dst[0] != '\0') { dst += 1; dstSizeInBytes -= 1; } if (dstSizeInBytes == 0) { return 22; /* Unterminated. */ } if (count == ((size_t)-1)) { /* _TRUNCATE */ count = dstSizeInBytes - 1; } while (dstSizeInBytes > 0 && src[0] != '\0' && count > 0) { *dst++ = *src++; dstSizeInBytes -= 1; count -= 1; } if (dstSizeInBytes > 0) { dst[0] = '\0'; } else { dstorig[0] = '\0'; return 34; } return 0; } MA_API MA_NO_INLINE int ma_itoa_s(int value, char* dst, size_t dstSizeInBytes, int radix) { int sign; unsigned int valueU; char* dstEnd; if (dst == NULL || dstSizeInBytes == 0) { return 22; } if (radix < 2 || radix > 36) { dst[0] = '\0'; return 22; } sign = (value < 0 && radix == 10) ? -1 : 1; /* The negative sign is only used when the base is 10. */ if (value < 0) { valueU = -value; } else { valueU = value; } dstEnd = dst; do { int remainder = valueU % radix; if (remainder > 9) { *dstEnd = (char)((remainder - 10) + 'a'); } else { *dstEnd = (char)(remainder + '0'); } dstEnd += 1; dstSizeInBytes -= 1; valueU /= radix; } while (dstSizeInBytes > 0 && valueU > 0); if (dstSizeInBytes == 0) { dst[0] = '\0'; return 22; /* Ran out of room in the output buffer. */ } if (sign < 0) { *dstEnd++ = '-'; dstSizeInBytes -= 1; } if (dstSizeInBytes == 0) { dst[0] = '\0'; return 22; /* Ran out of room in the output buffer. */ } *dstEnd = '\0'; /* At this point the string will be reversed. */ dstEnd -= 1; while (dst < dstEnd) { char temp = *dst; *dst = *dstEnd; *dstEnd = temp; dst += 1; dstEnd -= 1; } return 0; } MA_API MA_NO_INLINE int ma_strcmp(const char* str1, const char* str2) { if (str1 == str2) return 0; /* These checks differ from the standard implementation. It's not important, but I prefer it just for sanity. */ if (str1 == NULL) return -1; if (str2 == NULL) return 1; for (;;) { if (str1[0] == '\0') { break; } if (str1[0] != str2[0]) { break; } str1 += 1; str2 += 1; } return ((unsigned char*)str1)[0] - ((unsigned char*)str2)[0]; } MA_API MA_NO_INLINE int ma_strappend(char* dst, size_t dstSize, const char* srcA, const char* srcB) { int result; result = ma_strncpy_s(dst, dstSize, srcA, (size_t)-1); if (result != 0) { return result; } result = ma_strncat_s(dst, dstSize, srcB, (size_t)-1); if (result != 0) { return result; } return result; } MA_API MA_NO_INLINE char* ma_copy_string(const char* src, const ma_allocation_callbacks* pAllocationCallbacks) { size_t sz; char* dst; if (src == NULL) { return NULL; } sz = strlen(src)+1; dst = (char*)ma_malloc(sz, pAllocationCallbacks); if (dst == NULL) { return NULL; } ma_strcpy_s(dst, sz, src); return dst; } MA_API MA_NO_INLINE wchar_t* ma_copy_string_w(const wchar_t* src, const ma_allocation_callbacks* pAllocationCallbacks) { size_t sz = wcslen(src)+1; wchar_t* dst = (wchar_t*)ma_malloc(sz * sizeof(*dst), pAllocationCallbacks); if (dst == NULL) { return NULL; } ma_wcscpy_s(dst, sz, src); return dst; } #include static ma_result ma_result_from_errno(int e) { if (e == 0) { return MA_SUCCESS; } #ifdef EPERM else if (e == EPERM) { return MA_INVALID_OPERATION; } #endif #ifdef ENOENT else if (e == ENOENT) { return MA_DOES_NOT_EXIST; } #endif #ifdef ESRCH else if (e == ESRCH) { return MA_DOES_NOT_EXIST; } #endif #ifdef EINTR else if (e == EINTR) { return MA_INTERRUPT; } #endif #ifdef EIO else if (e == EIO) { return MA_IO_ERROR; } #endif #ifdef ENXIO else if (e == ENXIO) { return MA_DOES_NOT_EXIST; } #endif #ifdef E2BIG else if (e == E2BIG) { return MA_INVALID_ARGS; } #endif #ifdef ENOEXEC else if (e == ENOEXEC) { return MA_INVALID_FILE; } #endif #ifdef EBADF else if (e == EBADF) { return MA_INVALID_FILE; } #endif #ifdef ECHILD else if (e == ECHILD) { return MA_ERROR; } #endif #ifdef EAGAIN else if (e == EAGAIN) { return MA_UNAVAILABLE; } #endif #ifdef ENOMEM else if (e == ENOMEM) { return MA_OUT_OF_MEMORY; } #endif #ifdef EACCES else if (e == EACCES) { return MA_ACCESS_DENIED; } #endif #ifdef EFAULT else if (e == EFAULT) { return MA_BAD_ADDRESS; } #endif #ifdef ENOTBLK else if (e == ENOTBLK) { return MA_ERROR; } #endif #ifdef EBUSY else if (e == EBUSY) { return MA_BUSY; } #endif #ifdef EEXIST else if (e == EEXIST) { return MA_ALREADY_EXISTS; } #endif #ifdef EXDEV else if (e == EXDEV) { return MA_ERROR; } #endif #ifdef ENODEV else if (e == ENODEV) { return MA_DOES_NOT_EXIST; } #endif #ifdef ENOTDIR else if (e == ENOTDIR) { return MA_NOT_DIRECTORY; } #endif #ifdef EISDIR else if (e == EISDIR) { return MA_IS_DIRECTORY; } #endif #ifdef EINVAL else if (e == EINVAL) { return MA_INVALID_ARGS; } #endif #ifdef ENFILE else if (e == ENFILE) { return MA_TOO_MANY_OPEN_FILES; } #endif #ifdef EMFILE else if (e == EMFILE) { return MA_TOO_MANY_OPEN_FILES; } #endif #ifdef ENOTTY else if (e == ENOTTY) { return MA_INVALID_OPERATION; } #endif #ifdef ETXTBSY else if (e == ETXTBSY) { return MA_BUSY; } #endif #ifdef EFBIG else if (e == EFBIG) { return MA_TOO_BIG; } #endif #ifdef ENOSPC else if (e == ENOSPC) { return MA_NO_SPACE; } #endif #ifdef ESPIPE else if (e == ESPIPE) { return MA_BAD_SEEK; } #endif #ifdef EROFS else if (e == EROFS) { return MA_ACCESS_DENIED; } #endif #ifdef EMLINK else if (e == EMLINK) { return MA_TOO_MANY_LINKS; } #endif #ifdef EPIPE else if (e == EPIPE) { return MA_BAD_PIPE; } #endif #ifdef EDOM else if (e == EDOM) { return MA_OUT_OF_RANGE; } #endif #ifdef ERANGE else if (e == ERANGE) { return MA_OUT_OF_RANGE; } #endif #ifdef EDEADLK else if (e == EDEADLK) { return MA_DEADLOCK; } #endif #ifdef ENAMETOOLONG else if (e == ENAMETOOLONG) { return MA_PATH_TOO_LONG; } #endif #ifdef ENOLCK else if (e == ENOLCK) { return MA_ERROR; } #endif #ifdef ENOSYS else if (e == ENOSYS) { return MA_NOT_IMPLEMENTED; } #endif #ifdef ENOTEMPTY else if (e == ENOTEMPTY) { return MA_DIRECTORY_NOT_EMPTY; } #endif #ifdef ELOOP else if (e == ELOOP) { return MA_TOO_MANY_LINKS; } #endif #ifdef ENOMSG else if (e == ENOMSG) { return MA_NO_MESSAGE; } #endif #ifdef EIDRM else if (e == EIDRM) { return MA_ERROR; } #endif #ifdef ECHRNG else if (e == ECHRNG) { return MA_ERROR; } #endif #ifdef EL2NSYNC else if (e == EL2NSYNC) { return MA_ERROR; } #endif #ifdef EL3HLT else if (e == EL3HLT) { return MA_ERROR; } #endif #ifdef EL3RST else if (e == EL3RST) { return MA_ERROR; } #endif #ifdef ELNRNG else if (e == ELNRNG) { return MA_OUT_OF_RANGE; } #endif #ifdef EUNATCH else if (e == EUNATCH) { return MA_ERROR; } #endif #ifdef ENOCSI else if (e == ENOCSI) { return MA_ERROR; } #endif #ifdef EL2HLT else if (e == EL2HLT) { return MA_ERROR; } #endif #ifdef EBADE else if (e == EBADE) { return MA_ERROR; } #endif #ifdef EBADR else if (e == EBADR) { return MA_ERROR; } #endif #ifdef EXFULL else if (e == EXFULL) { return MA_ERROR; } #endif #ifdef ENOANO else if (e == ENOANO) { return MA_ERROR; } #endif #ifdef EBADRQC else if (e == EBADRQC) { return MA_ERROR; } #endif #ifdef EBADSLT else if (e == EBADSLT) { return MA_ERROR; } #endif #ifdef EBFONT else if (e == EBFONT) { return MA_INVALID_FILE; } #endif #ifdef ENOSTR else if (e == ENOSTR) { return MA_ERROR; } #endif #ifdef ENODATA else if (e == ENODATA) { return MA_NO_DATA_AVAILABLE; } #endif #ifdef ETIME else if (e == ETIME) { return MA_TIMEOUT; } #endif #ifdef ENOSR else if (e == ENOSR) { return MA_NO_DATA_AVAILABLE; } #endif #ifdef ENONET else if (e == ENONET) { return MA_NO_NETWORK; } #endif #ifdef ENOPKG else if (e == ENOPKG) { return MA_ERROR; } #endif #ifdef EREMOTE else if (e == EREMOTE) { return MA_ERROR; } #endif #ifdef ENOLINK else if (e == ENOLINK) { return MA_ERROR; } #endif #ifdef EADV else if (e == EADV) { return MA_ERROR; } #endif #ifdef ESRMNT else if (e == ESRMNT) { return MA_ERROR; } #endif #ifdef ECOMM else if (e == ECOMM) { return MA_ERROR; } #endif #ifdef EPROTO else if (e == EPROTO) { return MA_ERROR; } #endif #ifdef EMULTIHOP else if (e == EMULTIHOP) { return MA_ERROR; } #endif #ifdef EDOTDOT else if (e == EDOTDOT) { return MA_ERROR; } #endif #ifdef EBADMSG else if (e == EBADMSG) { return MA_BAD_MESSAGE; } #endif #ifdef EOVERFLOW else if (e == EOVERFLOW) { return MA_TOO_BIG; } #endif #ifdef ENOTUNIQ else if (e == ENOTUNIQ) { return MA_NOT_UNIQUE; } #endif #ifdef EBADFD else if (e == EBADFD) { return MA_ERROR; } #endif #ifdef EREMCHG else if (e == EREMCHG) { return MA_ERROR; } #endif #ifdef ELIBACC else if (e == ELIBACC) { return MA_ACCESS_DENIED; } #endif #ifdef ELIBBAD else if (e == ELIBBAD) { return MA_INVALID_FILE; } #endif #ifdef ELIBSCN else if (e == ELIBSCN) { return MA_INVALID_FILE; } #endif #ifdef ELIBMAX else if (e == ELIBMAX) { return MA_ERROR; } #endif #ifdef ELIBEXEC else if (e == ELIBEXEC) { return MA_ERROR; } #endif #ifdef EILSEQ else if (e == EILSEQ) { return MA_INVALID_DATA; } #endif #ifdef ERESTART else if (e == ERESTART) { return MA_ERROR; } #endif #ifdef ESTRPIPE else if (e == ESTRPIPE) { return MA_ERROR; } #endif #ifdef EUSERS else if (e == EUSERS) { return MA_ERROR; } #endif #ifdef ENOTSOCK else if (e == ENOTSOCK) { return MA_NOT_SOCKET; } #endif #ifdef EDESTADDRREQ else if (e == EDESTADDRREQ) { return MA_NO_ADDRESS; } #endif #ifdef EMSGSIZE else if (e == EMSGSIZE) { return MA_TOO_BIG; } #endif #ifdef EPROTOTYPE else if (e == EPROTOTYPE) { return MA_BAD_PROTOCOL; } #endif #ifdef ENOPROTOOPT else if (e == ENOPROTOOPT) { return MA_PROTOCOL_UNAVAILABLE; } #endif #ifdef EPROTONOSUPPORT else if (e == EPROTONOSUPPORT) { return MA_PROTOCOL_NOT_SUPPORTED; } #endif #ifdef ESOCKTNOSUPPORT else if (e == ESOCKTNOSUPPORT) { return MA_SOCKET_NOT_SUPPORTED; } #endif #ifdef EOPNOTSUPP else if (e == EOPNOTSUPP) { return MA_INVALID_OPERATION; } #endif #ifdef EPFNOSUPPORT else if (e == EPFNOSUPPORT) { return MA_PROTOCOL_FAMILY_NOT_SUPPORTED; } #endif #ifdef EAFNOSUPPORT else if (e == EAFNOSUPPORT) { return MA_ADDRESS_FAMILY_NOT_SUPPORTED; } #endif #ifdef EADDRINUSE else if (e == EADDRINUSE) { return MA_ALREADY_IN_USE; } #endif #ifdef EADDRNOTAVAIL else if (e == EADDRNOTAVAIL) { return MA_ERROR; } #endif #ifdef ENETDOWN else if (e == ENETDOWN) { return MA_NO_NETWORK; } #endif #ifdef ENETUNREACH else if (e == ENETUNREACH) { return MA_NO_NETWORK; } #endif #ifdef ENETRESET else if (e == ENETRESET) { return MA_NO_NETWORK; } #endif #ifdef ECONNABORTED else if (e == ECONNABORTED) { return MA_NO_NETWORK; } #endif #ifdef ECONNRESET else if (e == ECONNRESET) { return MA_CONNECTION_RESET; } #endif #ifdef ENOBUFS else if (e == ENOBUFS) { return MA_NO_SPACE; } #endif #ifdef EISCONN else if (e == EISCONN) { return MA_ALREADY_CONNECTED; } #endif #ifdef ENOTCONN else if (e == ENOTCONN) { return MA_NOT_CONNECTED; } #endif #ifdef ESHUTDOWN else if (e == ESHUTDOWN) { return MA_ERROR; } #endif #ifdef ETOOMANYREFS else if (e == ETOOMANYREFS) { return MA_ERROR; } #endif #ifdef ETIMEDOUT else if (e == ETIMEDOUT) { return MA_TIMEOUT; } #endif #ifdef ECONNREFUSED else if (e == ECONNREFUSED) { return MA_CONNECTION_REFUSED; } #endif #ifdef EHOSTDOWN else if (e == EHOSTDOWN) { return MA_NO_HOST; } #endif #ifdef EHOSTUNREACH else if (e == EHOSTUNREACH) { return MA_NO_HOST; } #endif #ifdef EALREADY else if (e == EALREADY) { return MA_IN_PROGRESS; } #endif #ifdef EINPROGRESS else if (e == EINPROGRESS) { return MA_IN_PROGRESS; } #endif #ifdef ESTALE else if (e == ESTALE) { return MA_INVALID_FILE; } #endif #ifdef EUCLEAN else if (e == EUCLEAN) { return MA_ERROR; } #endif #ifdef ENOTNAM else if (e == ENOTNAM) { return MA_ERROR; } #endif #ifdef ENAVAIL else if (e == ENAVAIL) { return MA_ERROR; } #endif #ifdef EISNAM else if (e == EISNAM) { return MA_ERROR; } #endif #ifdef EREMOTEIO else if (e == EREMOTEIO) { return MA_IO_ERROR; } #endif #ifdef EDQUOT else if (e == EDQUOT) { return MA_NO_SPACE; } #endif #ifdef ENOMEDIUM else if (e == ENOMEDIUM) { return MA_DOES_NOT_EXIST; } #endif #ifdef EMEDIUMTYPE else if (e == EMEDIUMTYPE) { return MA_ERROR; } #endif #ifdef ECANCELED else if (e == ECANCELED) { return MA_CANCELLED; } #endif #ifdef ENOKEY else if (e == ENOKEY) { return MA_ERROR; } #endif #ifdef EKEYEXPIRED else if (e == EKEYEXPIRED) { return MA_ERROR; } #endif #ifdef EKEYREVOKED else if (e == EKEYREVOKED) { return MA_ERROR; } #endif #ifdef EKEYREJECTED else if (e == EKEYREJECTED) { return MA_ERROR; } #endif #ifdef EOWNERDEAD else if (e == EOWNERDEAD) { return MA_ERROR; } #endif #ifdef ENOTRECOVERABLE else if (e == ENOTRECOVERABLE) { return MA_ERROR; } #endif #ifdef ERFKILL else if (e == ERFKILL) { return MA_ERROR; } #endif #ifdef EHWPOISON else if (e == EHWPOISON) { return MA_ERROR; } #endif else { return MA_ERROR; } } MA_API ma_result ma_fopen(FILE** ppFile, const char* pFilePath, const char* pOpenMode) { #if defined(_MSC_VER) && _MSC_VER >= 1400 errno_t err; #endif if (ppFile != NULL) { *ppFile = NULL; /* Safety. */ } if (pFilePath == NULL || pOpenMode == NULL || ppFile == NULL) { return MA_INVALID_ARGS; } #if defined(_MSC_VER) && _MSC_VER >= 1400 err = fopen_s(ppFile, pFilePath, pOpenMode); if (err != 0) { return ma_result_from_errno(err); } #else #if defined(_WIN32) || defined(__APPLE__) *ppFile = fopen(pFilePath, pOpenMode); #else #if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64 && defined(_LARGEFILE64_SOURCE) *ppFile = fopen64(pFilePath, pOpenMode); #else *ppFile = fopen(pFilePath, pOpenMode); #endif #endif if (*ppFile == NULL) { ma_result result = ma_result_from_errno(errno); if (result == MA_SUCCESS) { result = MA_ERROR; /* Just a safety check to make sure we never ever return success when pFile == NULL. */ } return result; } #endif return MA_SUCCESS; } /* _wfopen() isn't always available in all compilation environments. * Windows only. * MSVC seems to support it universally as far back as VC6 from what I can tell (haven't checked further back). * MinGW-64 (both 32- and 64-bit) seems to support it. * MinGW wraps it in !defined(__STRICT_ANSI__). * OpenWatcom wraps it in !defined(_NO_EXT_KEYS). This can be reviewed as compatibility issues arise. The preference is to use _wfopen_s() and _wfopen() as opposed to the wcsrtombs() fallback, so if you notice your compiler not detecting this properly I'm happy to look at adding support. */ #if defined(_WIN32) #if defined(_MSC_VER) || defined(__MINGW64__) || (!defined(__STRICT_ANSI__) && !defined(_NO_EXT_KEYS)) #define MA_HAS_WFOPEN #endif #endif MA_API ma_result ma_wfopen(FILE** ppFile, const wchar_t* pFilePath, const wchar_t* pOpenMode, const ma_allocation_callbacks* pAllocationCallbacks) { if (ppFile != NULL) { *ppFile = NULL; /* Safety. */ } if (pFilePath == NULL || pOpenMode == NULL || ppFile == NULL) { return MA_INVALID_ARGS; } #if defined(MA_HAS_WFOPEN) { /* Use _wfopen() on Windows. */ #if defined(_MSC_VER) && _MSC_VER >= 1400 errno_t err = _wfopen_s(ppFile, pFilePath, pOpenMode); if (err != 0) { return ma_result_from_errno(err); } #else *ppFile = _wfopen(pFilePath, pOpenMode); if (*ppFile == NULL) { return ma_result_from_errno(errno); } #endif (void)pAllocationCallbacks; } #else /* Use fopen() on anything other than Windows. Requires a conversion. This is annoying because fopen() is locale specific. The only real way I can think of to do this is with wcsrtombs(). Note that wcstombs() is apparently not thread-safe because it uses a static global mbstate_t object for maintaining state. I've checked this with -std=c89 and it works, but if somebody get's a compiler error I'll look into improving compatibility. */ { mbstate_t mbs; size_t lenMB; const wchar_t* pFilePathTemp = pFilePath; char* pFilePathMB = NULL; char pOpenModeMB[32] = {0}; /* Get the length first. */ MA_ZERO_OBJECT(&mbs); lenMB = wcsrtombs(NULL, &pFilePathTemp, 0, &mbs); if (lenMB == (size_t)-1) { return ma_result_from_errno(errno); } pFilePathMB = (char*)ma_malloc(lenMB + 1, pAllocationCallbacks); if (pFilePathMB == NULL) { return MA_OUT_OF_MEMORY; } pFilePathTemp = pFilePath; MA_ZERO_OBJECT(&mbs); wcsrtombs(pFilePathMB, &pFilePathTemp, lenMB + 1, &mbs); /* The open mode should always consist of ASCII characters so we should be able to do a trivial conversion. */ { size_t i = 0; for (;;) { if (pOpenMode[i] == 0) { pOpenModeMB[i] = '\0'; break; } pOpenModeMB[i] = (char)pOpenMode[i]; i += 1; } } *ppFile = fopen(pFilePathMB, pOpenModeMB); ma_free(pFilePathMB, pAllocationCallbacks); } if (*ppFile == NULL) { return MA_ERROR; } #endif return MA_SUCCESS; } static MA_INLINE void ma_copy_memory_64(void* dst, const void* src, ma_uint64 sizeInBytes) { #if 0xFFFFFFFFFFFFFFFF <= MA_SIZE_MAX MA_COPY_MEMORY(dst, src, (size_t)sizeInBytes); #else while (sizeInBytes > 0) { ma_uint64 bytesToCopyNow = sizeInBytes; if (bytesToCopyNow > MA_SIZE_MAX) { bytesToCopyNow = MA_SIZE_MAX; } MA_COPY_MEMORY(dst, src, (size_t)bytesToCopyNow); /* Safe cast to size_t. */ sizeInBytes -= bytesToCopyNow; dst = ( void*)(( ma_uint8*)dst + bytesToCopyNow); src = (const void*)((const ma_uint8*)src + bytesToCopyNow); } #endif } static MA_INLINE void ma_zero_memory_64(void* dst, ma_uint64 sizeInBytes) { #if 0xFFFFFFFFFFFFFFFF <= MA_SIZE_MAX MA_ZERO_MEMORY(dst, (size_t)sizeInBytes); #else while (sizeInBytes > 0) { ma_uint64 bytesToZeroNow = sizeInBytes; if (bytesToZeroNow > MA_SIZE_MAX) { bytesToZeroNow = MA_SIZE_MAX; } MA_ZERO_MEMORY(dst, (size_t)bytesToZeroNow); /* Safe cast to size_t. */ sizeInBytes -= bytesToZeroNow; dst = (void*)((ma_uint8*)dst + bytesToZeroNow); } #endif } /* Thanks to good old Bit Twiddling Hacks for this one: http://graphics.stanford.edu/~seander/bithacks.html#RoundUpPowerOf2 */ static MA_INLINE unsigned int ma_next_power_of_2(unsigned int x) { x--; x |= x >> 1; x |= x >> 2; x |= x >> 4; x |= x >> 8; x |= x >> 16; x++; return x; } static MA_INLINE unsigned int ma_prev_power_of_2(unsigned int x) { return ma_next_power_of_2(x) >> 1; } static MA_INLINE unsigned int ma_round_to_power_of_2(unsigned int x) { unsigned int prev = ma_prev_power_of_2(x); unsigned int next = ma_next_power_of_2(x); if ((next - x) > (x - prev)) { return prev; } else { return next; } } static MA_INLINE unsigned int ma_count_set_bits(unsigned int x) { unsigned int count = 0; while (x != 0) { if (x & 1) { count += 1; } x = x >> 1; } return count; } /************************************************************************************************************************************************************** Allocation Callbacks **************************************************************************************************************************************************************/ static void* ma__malloc_default(size_t sz, void* pUserData) { (void)pUserData; return MA_MALLOC(sz); } static void* ma__realloc_default(void* p, size_t sz, void* pUserData) { (void)pUserData; return MA_REALLOC(p, sz); } static void ma__free_default(void* p, void* pUserData) { (void)pUserData; MA_FREE(p); } static ma_allocation_callbacks ma_allocation_callbacks_init_default(void) { ma_allocation_callbacks callbacks; callbacks.pUserData = NULL; callbacks.onMalloc = ma__malloc_default; callbacks.onRealloc = ma__realloc_default; callbacks.onFree = ma__free_default; return callbacks; } static ma_result ma_allocation_callbacks_init_copy(ma_allocation_callbacks* pDst, const ma_allocation_callbacks* pSrc) { if (pDst == NULL) { return MA_INVALID_ARGS; } if (pSrc == NULL) { *pDst = ma_allocation_callbacks_init_default(); } else { if (pSrc->pUserData == NULL && pSrc->onFree == NULL && pSrc->onMalloc == NULL && pSrc->onRealloc == NULL) { *pDst = ma_allocation_callbacks_init_default(); } else { if (pSrc->onFree == NULL || (pSrc->onMalloc == NULL && pSrc->onRealloc == NULL)) { return MA_INVALID_ARGS; /* Invalid allocation callbacks. */ } else { *pDst = *pSrc; } } } return MA_SUCCESS; } /************************************************************************************************************************************************************** Logging **************************************************************************************************************************************************************/ MA_API const char* ma_log_level_to_string(ma_uint32 logLevel) { switch (logLevel) { case MA_LOG_LEVEL_DEBUG: return "DEBUG"; case MA_LOG_LEVEL_INFO: return "INFO"; case MA_LOG_LEVEL_WARNING: return "WARNING"; case MA_LOG_LEVEL_ERROR: return "ERROR"; default: return "ERROR"; } } #if defined(MA_DEBUG_OUTPUT) #if defined(MA_ANDROID) #include #endif /* Customize this to use a specific tag in __android_log_print() for debug output messages. */ #ifndef MA_ANDROID_LOG_TAG #define MA_ANDROID_LOG_TAG "miniaudio" #endif void ma_log_callback_debug(void* pUserData, ma_uint32 level, const char* pMessage) { (void)pUserData; /* Special handling for some platforms. */ #if defined(MA_ANDROID) { /* Android. */ __android_log_print(ANDROID_LOG_DEBUG, MA_ANDROID_LOG_TAG, "%s: %s", ma_log_level_to_string(level), pMessage); } #else { /* Everything else. */ printf("%s: %s", ma_log_level_to_string(level), pMessage); } #endif } #endif MA_API ma_log_callback ma_log_callback_init(ma_log_callback_proc onLog, void* pUserData) { ma_log_callback callback; MA_ZERO_OBJECT(&callback); callback.onLog = onLog; callback.pUserData = pUserData; return callback; } MA_API ma_result ma_log_init(const ma_allocation_callbacks* pAllocationCallbacks, ma_log* pLog) { if (pLog == NULL) { return MA_INVALID_ARGS; } MA_ZERO_OBJECT(pLog); ma_allocation_callbacks_init_copy(&pLog->allocationCallbacks, pAllocationCallbacks); /* We need a mutex for thread safety. */ #ifndef MA_NO_THREADING { ma_result result = ma_mutex_init(&pLog->lock); if (result != MA_SUCCESS) { return result; } } #endif /* If we're using debug output, enable it. */ #if defined(MA_DEBUG_OUTPUT) { ma_log_register_callback(pLog, ma_log_callback_init(ma_log_callback_debug, NULL)); /* Doesn't really matter if this fails. */ } #endif return MA_SUCCESS; } MA_API void ma_log_uninit(ma_log* pLog) { if (pLog == NULL) { return; } #ifndef MA_NO_THREADING ma_mutex_uninit(&pLog->lock); #endif } static void ma_log_lock(ma_log* pLog) { #ifndef MA_NO_THREADING ma_mutex_lock(&pLog->lock); #else (void)pLog; #endif } static void ma_log_unlock(ma_log* pLog) { #ifndef MA_NO_THREADING ma_mutex_unlock(&pLog->lock); #else (void)pLog; #endif } MA_API ma_result ma_log_register_callback(ma_log* pLog, ma_log_callback callback) { ma_result result = MA_SUCCESS; if (pLog == NULL || callback.onLog == NULL) { return MA_INVALID_ARGS; } ma_log_lock(pLog); { if (pLog->callbackCount == ma_countof(pLog->callbacks)) { result = MA_OUT_OF_MEMORY; /* Reached the maximum allowed log callbacks. */ } else { pLog->callbacks[pLog->callbackCount] = callback; pLog->callbackCount += 1; } } ma_log_unlock(pLog); return result; } MA_API ma_result ma_log_unregister_callback(ma_log* pLog, ma_log_callback callback) { if (pLog == NULL) { return MA_INVALID_ARGS; } ma_log_lock(pLog); { ma_uint32 iLog; for (iLog = 0; iLog < pLog->callbackCount; ) { if (pLog->callbacks[iLog].onLog == callback.onLog) { /* Found. Move everything down a slot. */ ma_uint32 jLog; for (jLog = iLog; jLog < pLog->callbackCount-1; jLog += 1) { pLog->callbacks[jLog] = pLog->callbacks[jLog + 1]; } pLog->callbackCount -= 1; } else { /* Not found. */ iLog += 1; } } } ma_log_unlock(pLog); return MA_SUCCESS; } MA_API ma_result ma_log_post(ma_log* pLog, ma_uint32 level, const char* pMessage) { if (pLog == NULL || pMessage == NULL) { return MA_INVALID_ARGS; } ma_log_lock(pLog); { ma_uint32 iLog; for (iLog = 0; iLog < pLog->callbackCount; iLog += 1) { if (pLog->callbacks[iLog].onLog) { pLog->callbacks[iLog].onLog(pLog->callbacks[iLog].pUserData, level, pMessage); } } } ma_log_unlock(pLog); return MA_SUCCESS; } /* We need to emulate _vscprintf() for the VC6 build. This can be more efficient, but since it's only VC6, and it's just a logging function, I'm happy to keep this simple. In the VC6 build we can implement this in terms of _vsnprintf(). */ #if defined(_MSC_VER) && _MSC_VER < 1900 static int ma_vscprintf(const ma_allocation_callbacks* pAllocationCallbacks, const char* format, va_list args) { #if _MSC_VER > 1200 return _vscprintf(format, args); #else int result; char* pTempBuffer = NULL; size_t tempBufferCap = 1024; if (format == NULL) { errno = EINVAL; return -1; } for (;;) { char* pNewTempBuffer = (char*)ma_realloc(pTempBuffer, tempBufferCap, pAllocationCallbacks); if (pNewTempBuffer == NULL) { ma_free(pTempBuffer, pAllocationCallbacks); errno = ENOMEM; return -1; /* Out of memory. */ } pTempBuffer = pNewTempBuffer; result = _vsnprintf(pTempBuffer, tempBufferCap, format, args); ma_free(pTempBuffer, NULL); if (result != -1) { break; /* Got it. */ } /* Buffer wasn't big enough. Ideally it'd be nice to use an error code to know the reason for sure, but this is reliable enough. */ tempBufferCap *= 2; } return result; #endif } #endif MA_API ma_result ma_log_postv(ma_log* pLog, ma_uint32 level, const char* pFormat, va_list args) { if (pLog == NULL || pFormat == NULL) { return MA_INVALID_ARGS; } #if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || ((!defined(_MSC_VER) || _MSC_VER >= 1900) && !defined(__STRICT_ANSI__) && !defined(_NO_EXT_KEYS)) || (defined(__cplusplus) && __cplusplus >= 201103L) { ma_result result; int length; char pFormattedMessageStack[1024]; char* pFormattedMessageHeap = NULL; /* First try formatting into our fixed sized stack allocated buffer. If this is too small we'll fallback to a heap allocation. */ length = vsnprintf(pFormattedMessageStack, sizeof(pFormattedMessageStack), pFormat, args); if (length < 0) { return MA_INVALID_OPERATION; /* An error occurred when trying to convert the buffer. */ } if ((size_t)length < sizeof(pFormattedMessageStack)) { /* The string was written to the stack. */ result = ma_log_post(pLog, level, pFormattedMessageStack); } else { /* The stack buffer was too small, try the heap. */ pFormattedMessageHeap = (char*)ma_malloc(length + 1, &pLog->allocationCallbacks); if (pFormattedMessageHeap == NULL) { return MA_OUT_OF_MEMORY; } length = vsnprintf(pFormattedMessageHeap, length + 1, pFormat, args); if (length < 0) { ma_free(pFormattedMessageHeap, &pLog->allocationCallbacks); return MA_INVALID_OPERATION; } result = ma_log_post(pLog, level, pFormattedMessageHeap); ma_free(pFormattedMessageHeap, &pLog->allocationCallbacks); } return result; } #else { /* Without snprintf() we need to first measure the string and then heap allocate it. I'm only aware of Visual Studio having support for this without snprintf(), so we'll need to restrict this branch to Visual Studio. For other compilers we need to just not support formatted logging because I don't want the security risk of overflowing a fixed sized stack allocated buffer. */ #if defined(_MSC_VER) && _MSC_VER >= 1200 /* 1200 = VC6 */ { ma_result result; int formattedLen; char* pFormattedMessage = NULL; va_list args2; #if _MSC_VER >= 1800 { va_copy(args2, args); } #else { args2 = args; } #endif formattedLen = ma_vscprintf(&pLog->allocationCallbacks, pFormat, args2); va_end(args2); if (formattedLen <= 0) { return MA_INVALID_OPERATION; } pFormattedMessage = (char*)ma_malloc(formattedLen + 1, &pLog->allocationCallbacks); if (pFormattedMessage == NULL) { return MA_OUT_OF_MEMORY; } /* We'll get errors on newer versions of Visual Studio if we try to use vsprintf(). */ #if _MSC_VER >= 1400 /* 1400 = Visual Studio 2005 */ { vsprintf_s(pFormattedMessage, formattedLen + 1, pFormat, args); } #else { vsprintf(pFormattedMessage, pFormat, args); } #endif result = ma_log_post(pLog, level, pFormattedMessage); ma_free(pFormattedMessage, &pLog->allocationCallbacks); return result; } #else { /* Can't do anything because we don't have a safe way of to emulate vsnprintf() without a manual solution. */ (void)level; (void)args; return MA_INVALID_OPERATION; } #endif } #endif } MA_API ma_result ma_log_postf(ma_log* pLog, ma_uint32 level, const char* pFormat, ...) { ma_result result; va_list args; if (pLog == NULL || pFormat == NULL) { return MA_INVALID_ARGS; } va_start(args, pFormat); { result = ma_log_postv(pLog, level, pFormat, args); } va_end(args); return result; } static MA_INLINE ma_uint8 ma_clip_u8(ma_int32 x) { return (ma_uint8)(ma_clamp(x, -128, 127) + 128); } static MA_INLINE ma_int16 ma_clip_s16(ma_int32 x) { return (ma_int16)ma_clamp(x, -32768, 32767); } static MA_INLINE ma_int64 ma_clip_s24(ma_int64 x) { return (ma_int64)ma_clamp(x, -8388608, 8388607); } static MA_INLINE ma_int32 ma_clip_s32(ma_int64 x) { /* This dance is to silence warnings with -std=c89. A good compiler should be able to optimize this away. */ ma_int64 clipMin; ma_int64 clipMax; clipMin = -((ma_int64)2147483647 + 1); clipMax = (ma_int64)2147483647; return (ma_int32)ma_clamp(x, clipMin, clipMax); } static MA_INLINE float ma_clip_f32(float x) { if (x < -1) return -1; if (x > +1) return +1; return x; } static MA_INLINE float ma_mix_f32(float x, float y, float a) { return x*(1-a) + y*a; } static MA_INLINE float ma_mix_f32_fast(float x, float y, float a) { float r0 = (y - x); float r1 = r0*a; return x + r1; /*return x + (y - x)*a;*/ } #if defined(MA_SUPPORT_SSE2) static MA_INLINE __m128 ma_mix_f32_fast__sse2(__m128 x, __m128 y, __m128 a) { return _mm_add_ps(x, _mm_mul_ps(_mm_sub_ps(y, x), a)); } #endif #if defined(MA_SUPPORT_AVX2) static MA_INLINE __m256 ma_mix_f32_fast__avx2(__m256 x, __m256 y, __m256 a) { return _mm256_add_ps(x, _mm256_mul_ps(_mm256_sub_ps(y, x), a)); } #endif #if defined(MA_SUPPORT_NEON) static MA_INLINE float32x4_t ma_mix_f32_fast__neon(float32x4_t x, float32x4_t y, float32x4_t a) { return vaddq_f32(x, vmulq_f32(vsubq_f32(y, x), a)); } #endif static MA_INLINE double ma_mix_f64(double x, double y, double a) { return x*(1-a) + y*a; } static MA_INLINE double ma_mix_f64_fast(double x, double y, double a) { return x + (y - x)*a; } static MA_INLINE float ma_scale_to_range_f32(float x, float lo, float hi) { return lo + x*(hi-lo); } /* Greatest common factor using Euclid's algorithm iteratively. */ static MA_INLINE ma_uint32 ma_gcf_u32(ma_uint32 a, ma_uint32 b) { for (;;) { if (b == 0) { break; } else { ma_uint32 t = a; a = b; b = t % a; } } return a; } static ma_uint32 ma_ffs_32(ma_uint32 x) { ma_uint32 i; /* Just a naive implementation just to get things working for now. Will optimize this later. */ for (i = 0; i < 32; i += 1) { if ((x & (1 << i)) != 0) { return i; } } return i; } static MA_INLINE ma_int16 ma_float_to_fixed_16(float x) { return (ma_int16)(x * (1 << 8)); } /* Random Number Generation miniaudio uses the LCG random number generation algorithm. This is good enough for audio. Note that miniaudio's global LCG implementation uses global state which is _not_ thread-local. When this is called across multiple threads, results will be unpredictable. However, it won't crash and results will still be random enough for miniaudio's purposes. */ #ifndef MA_DEFAULT_LCG_SEED #define MA_DEFAULT_LCG_SEED 4321 #endif #define MA_LCG_M 2147483647 #define MA_LCG_A 48271 #define MA_LCG_C 0 static ma_lcg g_maLCG = {MA_DEFAULT_LCG_SEED}; /* Non-zero initial seed. Use ma_seed() to use an explicit seed. */ static MA_INLINE void ma_lcg_seed(ma_lcg* pLCG, ma_int32 seed) { MA_ASSERT(pLCG != NULL); pLCG->state = seed; } static MA_INLINE ma_int32 ma_lcg_rand_s32(ma_lcg* pLCG) { pLCG->state = (MA_LCG_A * pLCG->state + MA_LCG_C) % MA_LCG_M; return pLCG->state; } static MA_INLINE ma_uint32 ma_lcg_rand_u32(ma_lcg* pLCG) { return (ma_uint32)ma_lcg_rand_s32(pLCG); } static MA_INLINE ma_int16 ma_lcg_rand_s16(ma_lcg* pLCG) { return (ma_int16)(ma_lcg_rand_s32(pLCG) & 0xFFFF); } static MA_INLINE double ma_lcg_rand_f64(ma_lcg* pLCG) { return ma_lcg_rand_s32(pLCG) / (double)0x7FFFFFFF; } static MA_INLINE float ma_lcg_rand_f32(ma_lcg* pLCG) { return (float)ma_lcg_rand_f64(pLCG); } static MA_INLINE float ma_lcg_rand_range_f32(ma_lcg* pLCG, float lo, float hi) { return ma_scale_to_range_f32(ma_lcg_rand_f32(pLCG), lo, hi); } static MA_INLINE ma_int32 ma_lcg_rand_range_s32(ma_lcg* pLCG, ma_int32 lo, ma_int32 hi) { if (lo == hi) { return lo; } return lo + ma_lcg_rand_u32(pLCG) / (0xFFFFFFFF / (hi - lo + 1) + 1); } static MA_INLINE void ma_seed(ma_int32 seed) { ma_lcg_seed(&g_maLCG, seed); } static MA_INLINE ma_int32 ma_rand_s32(void) { return ma_lcg_rand_s32(&g_maLCG); } static MA_INLINE ma_uint32 ma_rand_u32(void) { return ma_lcg_rand_u32(&g_maLCG); } static MA_INLINE double ma_rand_f64(void) { return ma_lcg_rand_f64(&g_maLCG); } static MA_INLINE float ma_rand_f32(void) { return ma_lcg_rand_f32(&g_maLCG); } static MA_INLINE float ma_rand_range_f32(float lo, float hi) { return ma_lcg_rand_range_f32(&g_maLCG, lo, hi); } static MA_INLINE ma_int32 ma_rand_range_s32(ma_int32 lo, ma_int32 hi) { return ma_lcg_rand_range_s32(&g_maLCG, lo, hi); } static MA_INLINE float ma_dither_f32_rectangle(float ditherMin, float ditherMax) { return ma_rand_range_f32(ditherMin, ditherMax); } static MA_INLINE float ma_dither_f32_triangle(float ditherMin, float ditherMax) { float a = ma_rand_range_f32(ditherMin, 0); float b = ma_rand_range_f32(0, ditherMax); return a + b; } static MA_INLINE float ma_dither_f32(ma_dither_mode ditherMode, float ditherMin, float ditherMax) { if (ditherMode == ma_dither_mode_rectangle) { return ma_dither_f32_rectangle(ditherMin, ditherMax); } if (ditherMode == ma_dither_mode_triangle) { return ma_dither_f32_triangle(ditherMin, ditherMax); } return 0; } static MA_INLINE ma_int32 ma_dither_s32(ma_dither_mode ditherMode, ma_int32 ditherMin, ma_int32 ditherMax) { if (ditherMode == ma_dither_mode_rectangle) { ma_int32 a = ma_rand_range_s32(ditherMin, ditherMax); return a; } if (ditherMode == ma_dither_mode_triangle) { ma_int32 a = ma_rand_range_s32(ditherMin, 0); ma_int32 b = ma_rand_range_s32(0, ditherMax); return a + b; } return 0; } /************************************************************************************************************************************************************** Atomics **************************************************************************************************************************************************************/ /* ma_atomic.h begin */ #ifndef ma_atomic_h #if defined(__cplusplus) extern "C" { #endif #if defined(__clang__) || (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wlong-long" #if defined(__clang__) #pragma GCC diagnostic ignored "-Wc++11-long-long" #endif #endif typedef int ma_atomic_memory_order; #define MA_ATOMIC_HAS_8 #define MA_ATOMIC_HAS_16 #define MA_ATOMIC_HAS_32 #define MA_ATOMIC_HAS_64 #if (defined(_MSC_VER) ) || defined(__WATCOMC__) || defined(__DMC__) #define MA_ATOMIC_MSVC_ARM_INTRINSIC(dst, src, order, intrin, ma_atomicType, msvcType) \ ma_atomicType result; \ switch (order) \ { \ case ma_atomic_memory_order_relaxed: \ { \ result = (ma_atomicType)intrin##_nf((volatile msvcType*)dst, (msvcType)src); \ } break; \ case ma_atomic_memory_order_consume: \ case ma_atomic_memory_order_acquire: \ { \ result = (ma_atomicType)intrin##_acq((volatile msvcType*)dst, (msvcType)src); \ } break; \ case ma_atomic_memory_order_release: \ { \ result = (ma_atomicType)intrin##_rel((volatile msvcType*)dst, (msvcType)src); \ } break; \ case ma_atomic_memory_order_acq_rel: \ case ma_atomic_memory_order_seq_cst: \ default: \ { \ result = (ma_atomicType)intrin((volatile msvcType*)dst, (msvcType)src); \ } break; \ } \ return result; #define MA_ATOMIC_MSVC_ARM_INTRINSIC_COMPARE_EXCHANGE(ptr, expected, desired, order, intrin, ma_atomicType, msvcType) \ ma_atomicType result; \ switch (order) \ { \ case ma_atomic_memory_order_relaxed: \ { \ result = (ma_atomicType)intrin##_nf((volatile msvcType*)ptr, (msvcType)expected, (msvcType)desired); \ } break; \ case ma_atomic_memory_order_consume: \ case ma_atomic_memory_order_acquire: \ { \ result = (ma_atomicType)intrin##_acq((volatile msvcType*)ptr, (msvcType)expected, (msvcType)desired); \ } break; \ case ma_atomic_memory_order_release: \ { \ result = (ma_atomicType)intrin##_rel((volatile msvcType*)ptr, (msvcType)expected, (msvcType)desired); \ } break; \ case ma_atomic_memory_order_acq_rel: \ case ma_atomic_memory_order_seq_cst: \ default: \ { \ result = (ma_atomicType)intrin((volatile msvcType*)ptr, (msvcType)expected, (msvcType)desired); \ } break; \ } \ return result; #define ma_atomic_memory_order_relaxed 0 #define ma_atomic_memory_order_consume 1 #define ma_atomic_memory_order_acquire 2 #define ma_atomic_memory_order_release 3 #define ma_atomic_memory_order_acq_rel 4 #define ma_atomic_memory_order_seq_cst 5 #if _MSC_VER < 1600 && defined(MA_X86) #define MA_ATOMIC_MSVC_USE_INLINED_ASSEMBLY #endif #if _MSC_VER < 1600 #undef MA_ATOMIC_HAS_8 #undef MA_ATOMIC_HAS_16 #endif #if !defined(MA_ATOMIC_MSVC_USE_INLINED_ASSEMBLY) #include #endif #if defined(MA_ATOMIC_MSVC_USE_INLINED_ASSEMBLY) #if defined(MA_ATOMIC_HAS_8) static MA_INLINE ma_uint8 __stdcall ma_atomic_compare_and_swap_8(volatile ma_uint8* dst, ma_uint8 expected, ma_uint8 desired) { ma_uint8 result = 0; __asm { mov ecx, dst mov al, expected mov dl, desired lock cmpxchg [ecx], dl mov result, al } return result; } #endif #if defined(MA_ATOMIC_HAS_16) static MA_INLINE ma_uint16 __stdcall ma_atomic_compare_and_swap_16(volatile ma_uint16* dst, ma_uint16 expected, ma_uint16 desired) { ma_uint16 result = 0; __asm { mov ecx, dst mov ax, expected mov dx, desired lock cmpxchg [ecx], dx mov result, ax } return result; } #endif #if defined(MA_ATOMIC_HAS_32) static MA_INLINE ma_uint32 __stdcall ma_atomic_compare_and_swap_32(volatile ma_uint32* dst, ma_uint32 expected, ma_uint32 desired) { ma_uint32 result = 0; __asm { mov ecx, dst mov eax, expected mov edx, desired lock cmpxchg [ecx], edx mov result, eax } return result; } #endif #if defined(MA_ATOMIC_HAS_64) static MA_INLINE ma_uint64 __stdcall ma_atomic_compare_and_swap_64(volatile ma_uint64* dst, ma_uint64 expected, ma_uint64 desired) { ma_uint32 resultEAX = 0; ma_uint32 resultEDX = 0; __asm { mov esi, dst mov eax, dword ptr expected mov edx, dword ptr expected + 4 mov ebx, dword ptr desired mov ecx, dword ptr desired + 4 lock cmpxchg8b qword ptr [esi] mov resultEAX, eax mov resultEDX, edx } return ((ma_uint64)resultEDX << 32) | resultEAX; } #endif #else #if defined(MA_ATOMIC_HAS_8) #define ma_atomic_compare_and_swap_8( dst, expected, desired) (ma_uint8 )_InterlockedCompareExchange8((volatile char*)dst, (char)desired, (char)expected) #endif #if defined(MA_ATOMIC_HAS_16) #define ma_atomic_compare_and_swap_16(dst, expected, desired) (ma_uint16)_InterlockedCompareExchange16((volatile short*)dst, (short)desired, (short)expected) #endif #if defined(MA_ATOMIC_HAS_32) #define ma_atomic_compare_and_swap_32(dst, expected, desired) (ma_uint32)_InterlockedCompareExchange((volatile long*)dst, (long)desired, (long)expected) #endif #if defined(MA_ATOMIC_HAS_64) #define ma_atomic_compare_and_swap_64(dst, expected, desired) (ma_uint64)_InterlockedCompareExchange64((volatile ma_int64*)dst, (ma_int64)desired, (ma_int64)expected) #endif #endif #if defined(MA_ATOMIC_MSVC_USE_INLINED_ASSEMBLY) #if defined(MA_ATOMIC_HAS_8) static MA_INLINE ma_uint8 __stdcall ma_atomic_exchange_explicit_8(volatile ma_uint8* dst, ma_uint8 src, ma_atomic_memory_order order) { ma_uint8 result = 0; (void)order; __asm { mov ecx, dst mov al, src lock xchg [ecx], al mov result, al } return result; } #endif #if defined(MA_ATOMIC_HAS_16) static MA_INLINE ma_uint16 __stdcall ma_atomic_exchange_explicit_16(volatile ma_uint16* dst, ma_uint16 src, ma_atomic_memory_order order) { ma_uint16 result = 0; (void)order; __asm { mov ecx, dst mov ax, src lock xchg [ecx], ax mov result, ax } return result; } #endif #if defined(MA_ATOMIC_HAS_32) static MA_INLINE ma_uint32 __stdcall ma_atomic_exchange_explicit_32(volatile ma_uint32* dst, ma_uint32 src, ma_atomic_memory_order order) { ma_uint32 result = 0; (void)order; __asm { mov ecx, dst mov eax, src lock xchg [ecx], eax mov result, eax } return result; } #endif #else #if defined(MA_ATOMIC_HAS_8) static MA_INLINE ma_uint8 __stdcall ma_atomic_exchange_explicit_8(volatile ma_uint8* dst, ma_uint8 src, ma_atomic_memory_order order) { #if defined(MA_ARM) MA_ATOMIC_MSVC_ARM_INTRINSIC(dst, src, order, _InterlockedExchange8, ma_uint8, char); #else (void)order; return (ma_uint8)_InterlockedExchange8((volatile char*)dst, (char)src); #endif } #endif #if defined(MA_ATOMIC_HAS_16) static MA_INLINE ma_uint16 __stdcall ma_atomic_exchange_explicit_16(volatile ma_uint16* dst, ma_uint16 src, ma_atomic_memory_order order) { #if defined(MA_ARM) MA_ATOMIC_MSVC_ARM_INTRINSIC(dst, src, order, _InterlockedExchange16, ma_uint16, short); #else (void)order; return (ma_uint16)_InterlockedExchange16((volatile short*)dst, (short)src); #endif } #endif #if defined(MA_ATOMIC_HAS_32) static MA_INLINE ma_uint32 __stdcall ma_atomic_exchange_explicit_32(volatile ma_uint32* dst, ma_uint32 src, ma_atomic_memory_order order) { #if defined(MA_ARM) MA_ATOMIC_MSVC_ARM_INTRINSIC(dst, src, order, _InterlockedExchange, ma_uint32, long); #else (void)order; return (ma_uint32)_InterlockedExchange((volatile long*)dst, (long)src); #endif } #endif #if defined(MA_ATOMIC_HAS_64) && defined(MA_64BIT) static MA_INLINE ma_uint64 __stdcall ma_atomic_exchange_explicit_64(volatile ma_uint64* dst, ma_uint64 src, ma_atomic_memory_order order) { #if defined(MA_ARM) MA_ATOMIC_MSVC_ARM_INTRINSIC(dst, src, order, _InterlockedExchange64, ma_uint64, long long); #else (void)order; return (ma_uint64)_InterlockedExchange64((volatile long long*)dst, (long long)src); #endif } #else #endif #endif #if defined(MA_ATOMIC_HAS_64) && !defined(MA_64BIT) static MA_INLINE ma_uint64 __stdcall ma_atomic_exchange_explicit_64(volatile ma_uint64* dst, ma_uint64 src, ma_atomic_memory_order order) { ma_uint64 oldValue; do { oldValue = *dst; } while (ma_atomic_compare_and_swap_64(dst, oldValue, src) != oldValue); (void)order; return oldValue; } #endif #if defined(MA_ATOMIC_MSVC_USE_INLINED_ASSEMBLY) #if defined(MA_ATOMIC_HAS_8) static MA_INLINE ma_uint8 __stdcall ma_atomic_fetch_add_explicit_8(volatile ma_uint8* dst, ma_uint8 src, ma_atomic_memory_order order) { ma_uint8 result = 0; (void)order; __asm { mov ecx, dst mov al, src lock xadd [ecx], al mov result, al } return result; } #endif #if defined(MA_ATOMIC_HAS_16) static MA_INLINE ma_uint16 __stdcall ma_atomic_fetch_add_explicit_16(volatile ma_uint16* dst, ma_uint16 src, ma_atomic_memory_order order) { ma_uint16 result = 0; (void)order; __asm { mov ecx, dst mov ax, src lock xadd [ecx], ax mov result, ax } return result; } #endif #if defined(MA_ATOMIC_HAS_32) static MA_INLINE ma_uint32 __stdcall ma_atomic_fetch_add_explicit_32(volatile ma_uint32* dst, ma_uint32 src, ma_atomic_memory_order order) { ma_uint32 result = 0; (void)order; __asm { mov ecx, dst mov eax, src lock xadd [ecx], eax mov result, eax } return result; } #endif #else #if defined(MA_ATOMIC_HAS_8) static MA_INLINE ma_uint8 __stdcall ma_atomic_fetch_add_explicit_8(volatile ma_uint8* dst, ma_uint8 src, ma_atomic_memory_order order) { #if defined(MA_ARM) MA_ATOMIC_MSVC_ARM_INTRINSIC(dst, src, order, _InterlockedExchangeAdd8, ma_uint8, char); #else (void)order; return (ma_uint8)_InterlockedExchangeAdd8((volatile char*)dst, (char)src); #endif } #endif #if defined(MA_ATOMIC_HAS_16) static MA_INLINE ma_uint16 __stdcall ma_atomic_fetch_add_explicit_16(volatile ma_uint16* dst, ma_uint16 src, ma_atomic_memory_order order) { #if defined(MA_ARM) MA_ATOMIC_MSVC_ARM_INTRINSIC(dst, src, order, _InterlockedExchangeAdd16, ma_uint16, short); #else (void)order; return (ma_uint16)_InterlockedExchangeAdd16((volatile short*)dst, (short)src); #endif } #endif #if defined(MA_ATOMIC_HAS_32) static MA_INLINE ma_uint32 __stdcall ma_atomic_fetch_add_explicit_32(volatile ma_uint32* dst, ma_uint32 src, ma_atomic_memory_order order) { #if defined(MA_ARM) MA_ATOMIC_MSVC_ARM_INTRINSIC(dst, src, order, _InterlockedExchangeAdd, ma_uint32, long); #else (void)order; return (ma_uint32)_InterlockedExchangeAdd((volatile long*)dst, (long)src); #endif } #endif #if defined(MA_ATOMIC_HAS_64) && defined(MA_64BIT) static MA_INLINE ma_uint64 __stdcall ma_atomic_fetch_add_explicit_64(volatile ma_uint64* dst, ma_uint64 src, ma_atomic_memory_order order) { #if defined(MA_ARM) MA_ATOMIC_MSVC_ARM_INTRINSIC(dst, src, order, _InterlockedExchangeAdd64, ma_uint64, long long); #else (void)order; return (ma_uint64)_InterlockedExchangeAdd64((volatile long long*)dst, (long long)src); #endif } #else #endif #endif #if defined(MA_ATOMIC_HAS_64) && !defined(MA_64BIT) static MA_INLINE ma_uint64 __stdcall ma_atomic_fetch_add_explicit_64(volatile ma_uint64* dst, ma_uint64 src, ma_atomic_memory_order order) { ma_uint64 oldValue; ma_uint64 newValue; do { oldValue = *dst; newValue = oldValue + src; } while (ma_atomic_compare_and_swap_64(dst, oldValue, newValue) != oldValue); (void)order; return oldValue; } #endif #if defined(MA_ATOMIC_MSVC_USE_INLINED_ASSEMBLY) static MA_INLINE void __stdcall ma_atomic_thread_fence(ma_atomic_memory_order order) { (void)order; __asm { lock add [esp], 0 } } #else #if defined(MA_X64) #define ma_atomic_thread_fence(order) __faststorefence(), (void)order #elif defined(MA_ARM64) #define ma_atomic_thread_fence(order) __dmb(_ARM64_BARRIER_ISH), (void)order #else static MA_INLINE void ma_atomic_thread_fence(ma_atomic_memory_order order) { volatile ma_uint32 barrier = 0; ma_atomic_fetch_add_explicit_32(&barrier, 0, order); } #endif #endif #define ma_atomic_compiler_fence() ma_atomic_thread_fence(ma_atomic_memory_order_seq_cst) #define ma_atomic_signal_fence(order) ma_atomic_thread_fence(order) #if defined(MA_ATOMIC_HAS_8) static MA_INLINE ma_uint8 ma_atomic_load_explicit_8(volatile const ma_uint8* ptr, ma_atomic_memory_order order) { #if defined(MA_ARM) MA_ATOMIC_MSVC_ARM_INTRINSIC_COMPARE_EXCHANGE(ptr, 0, 0, order, _InterlockedCompareExchange8, ma_uint8, char); #else (void)order; return ma_atomic_compare_and_swap_8((volatile ma_uint8*)ptr, 0, 0); #endif } #endif #if defined(MA_ATOMIC_HAS_16) static MA_INLINE ma_uint16 ma_atomic_load_explicit_16(volatile const ma_uint16* ptr, ma_atomic_memory_order order) { #if defined(MA_ARM) MA_ATOMIC_MSVC_ARM_INTRINSIC_COMPARE_EXCHANGE(ptr, 0, 0, order, _InterlockedCompareExchange16, ma_uint16, short); #else (void)order; return ma_atomic_compare_and_swap_16((volatile ma_uint16*)ptr, 0, 0); #endif } #endif #if defined(MA_ATOMIC_HAS_32) static MA_INLINE ma_uint32 ma_atomic_load_explicit_32(volatile const ma_uint32* ptr, ma_atomic_memory_order order) { #if defined(MA_ARM) MA_ATOMIC_MSVC_ARM_INTRINSIC_COMPARE_EXCHANGE(ptr, 0, 0, order, _InterlockedCompareExchange, ma_uint32, long); #else (void)order; return ma_atomic_compare_and_swap_32((volatile ma_uint32*)ptr, 0, 0); #endif } #endif #if defined(MA_ATOMIC_HAS_64) static MA_INLINE ma_uint64 ma_atomic_load_explicit_64(volatile const ma_uint64* ptr, ma_atomic_memory_order order) { #if defined(MA_ARM) MA_ATOMIC_MSVC_ARM_INTRINSIC_COMPARE_EXCHANGE(ptr, 0, 0, order, _InterlockedCompareExchange64, ma_uint64, long long); #else (void)order; return ma_atomic_compare_and_swap_64((volatile ma_uint64*)ptr, 0, 0); #endif } #endif #if defined(MA_ATOMIC_HAS_8) #define ma_atomic_store_explicit_8( dst, src, order) (void)ma_atomic_exchange_explicit_8 (dst, src, order) #endif #if defined(MA_ATOMIC_HAS_16) #define ma_atomic_store_explicit_16(dst, src, order) (void)ma_atomic_exchange_explicit_16(dst, src, order) #endif #if defined(MA_ATOMIC_HAS_32) #define ma_atomic_store_explicit_32(dst, src, order) (void)ma_atomic_exchange_explicit_32(dst, src, order) #endif #if defined(MA_ATOMIC_HAS_64) #define ma_atomic_store_explicit_64(dst, src, order) (void)ma_atomic_exchange_explicit_64(dst, src, order) #endif #if defined(MA_ATOMIC_HAS_8) static MA_INLINE ma_uint8 __stdcall ma_atomic_fetch_sub_explicit_8(volatile ma_uint8* dst, ma_uint8 src, ma_atomic_memory_order order) { ma_uint8 oldValue; ma_uint8 newValue; do { oldValue = *dst; newValue = (ma_uint8)(oldValue - src); } while (ma_atomic_compare_and_swap_8(dst, oldValue, newValue) != oldValue); (void)order; return oldValue; } #endif #if defined(MA_ATOMIC_HAS_16) static MA_INLINE ma_uint16 __stdcall ma_atomic_fetch_sub_explicit_16(volatile ma_uint16* dst, ma_uint16 src, ma_atomic_memory_order order) { ma_uint16 oldValue; ma_uint16 newValue; do { oldValue = *dst; newValue = (ma_uint16)(oldValue - src); } while (ma_atomic_compare_and_swap_16(dst, oldValue, newValue) != oldValue); (void)order; return oldValue; } #endif #if defined(MA_ATOMIC_HAS_32) static MA_INLINE ma_uint32 __stdcall ma_atomic_fetch_sub_explicit_32(volatile ma_uint32* dst, ma_uint32 src, ma_atomic_memory_order order) { ma_uint32 oldValue; ma_uint32 newValue; do { oldValue = *dst; newValue = oldValue - src; } while (ma_atomic_compare_and_swap_32(dst, oldValue, newValue) != oldValue); (void)order; return oldValue; } #endif #if defined(MA_ATOMIC_HAS_64) static MA_INLINE ma_uint64 __stdcall ma_atomic_fetch_sub_explicit_64(volatile ma_uint64* dst, ma_uint64 src, ma_atomic_memory_order order) { ma_uint64 oldValue; ma_uint64 newValue; do { oldValue = *dst; newValue = oldValue - src; } while (ma_atomic_compare_and_swap_64(dst, oldValue, newValue) != oldValue); (void)order; return oldValue; } #endif #if defined(MA_ATOMIC_HAS_8) static MA_INLINE ma_uint8 __stdcall ma_atomic_fetch_and_explicit_8(volatile ma_uint8* dst, ma_uint8 src, ma_atomic_memory_order order) { #if defined(MA_ARM) MA_ATOMIC_MSVC_ARM_INTRINSIC(dst, src, order, _InterlockedAnd8, ma_uint8, char); #else ma_uint8 oldValue; ma_uint8 newValue; do { oldValue = *dst; newValue = (ma_uint8)(oldValue & src); } while (ma_atomic_compare_and_swap_8(dst, oldValue, newValue) != oldValue); (void)order; return oldValue; #endif } #endif #if defined(MA_ATOMIC_HAS_16) static MA_INLINE ma_uint16 __stdcall ma_atomic_fetch_and_explicit_16(volatile ma_uint16* dst, ma_uint16 src, ma_atomic_memory_order order) { #if defined(MA_ARM) MA_ATOMIC_MSVC_ARM_INTRINSIC(dst, src, order, _InterlockedAnd16, ma_uint16, short); #else ma_uint16 oldValue; ma_uint16 newValue; do { oldValue = *dst; newValue = (ma_uint16)(oldValue & src); } while (ma_atomic_compare_and_swap_16(dst, oldValue, newValue) != oldValue); (void)order; return oldValue; #endif } #endif #if defined(MA_ATOMIC_HAS_32) static MA_INLINE ma_uint32 __stdcall ma_atomic_fetch_and_explicit_32(volatile ma_uint32* dst, ma_uint32 src, ma_atomic_memory_order order) { #if defined(MA_ARM) MA_ATOMIC_MSVC_ARM_INTRINSIC(dst, src, order, _InterlockedAnd, ma_uint32, long); #else ma_uint32 oldValue; ma_uint32 newValue; do { oldValue = *dst; newValue = oldValue & src; } while (ma_atomic_compare_and_swap_32(dst, oldValue, newValue) != oldValue); (void)order; return oldValue; #endif } #endif #if defined(MA_ATOMIC_HAS_64) static MA_INLINE ma_uint64 __stdcall ma_atomic_fetch_and_explicit_64(volatile ma_uint64* dst, ma_uint64 src, ma_atomic_memory_order order) { #if defined(MA_ARM) MA_ATOMIC_MSVC_ARM_INTRINSIC(dst, src, order, _InterlockedAnd64, ma_uint64, long long); #else ma_uint64 oldValue; ma_uint64 newValue; do { oldValue = *dst; newValue = oldValue & src; } while (ma_atomic_compare_and_swap_64(dst, oldValue, newValue) != oldValue); (void)order; return oldValue; #endif } #endif #if defined(MA_ATOMIC_HAS_8) static MA_INLINE ma_uint8 __stdcall ma_atomic_fetch_xor_explicit_8(volatile ma_uint8* dst, ma_uint8 src, ma_atomic_memory_order order) { #if defined(MA_ARM) MA_ATOMIC_MSVC_ARM_INTRINSIC(dst, src, order, _InterlockedXor8, ma_uint8, char); #else ma_uint8 oldValue; ma_uint8 newValue; do { oldValue = *dst; newValue = (ma_uint8)(oldValue ^ src); } while (ma_atomic_compare_and_swap_8(dst, oldValue, newValue) != oldValue); (void)order; return oldValue; #endif } #endif #if defined(MA_ATOMIC_HAS_16) static MA_INLINE ma_uint16 __stdcall ma_atomic_fetch_xor_explicit_16(volatile ma_uint16* dst, ma_uint16 src, ma_atomic_memory_order order) { #if defined(MA_ARM) MA_ATOMIC_MSVC_ARM_INTRINSIC(dst, src, order, _InterlockedXor16, ma_uint16, short); #else ma_uint16 oldValue; ma_uint16 newValue; do { oldValue = *dst; newValue = (ma_uint16)(oldValue ^ src); } while (ma_atomic_compare_and_swap_16(dst, oldValue, newValue) != oldValue); (void)order; return oldValue; #endif } #endif #if defined(MA_ATOMIC_HAS_32) static MA_INLINE ma_uint32 __stdcall ma_atomic_fetch_xor_explicit_32(volatile ma_uint32* dst, ma_uint32 src, ma_atomic_memory_order order) { #if defined(MA_ARM) MA_ATOMIC_MSVC_ARM_INTRINSIC(dst, src, order, _InterlockedXor, ma_uint32, long); #else ma_uint32 oldValue; ma_uint32 newValue; do { oldValue = *dst; newValue = oldValue ^ src; } while (ma_atomic_compare_and_swap_32(dst, oldValue, newValue) != oldValue); (void)order; return oldValue; #endif } #endif #if defined(MA_ATOMIC_HAS_64) static MA_INLINE ma_uint64 __stdcall ma_atomic_fetch_xor_explicit_64(volatile ma_uint64* dst, ma_uint64 src, ma_atomic_memory_order order) { #if defined(MA_ARM) MA_ATOMIC_MSVC_ARM_INTRINSIC(dst, src, order, _InterlockedXor64, ma_uint64, long long); #else ma_uint64 oldValue; ma_uint64 newValue; do { oldValue = *dst; newValue = oldValue ^ src; } while (ma_atomic_compare_and_swap_64(dst, oldValue, newValue) != oldValue); (void)order; return oldValue; #endif } #endif #if defined(MA_ATOMIC_HAS_8) static MA_INLINE ma_uint8 __stdcall ma_atomic_fetch_or_explicit_8(volatile ma_uint8* dst, ma_uint8 src, ma_atomic_memory_order order) { #if defined(MA_ARM) MA_ATOMIC_MSVC_ARM_INTRINSIC(dst, src, order, _InterlockedOr8, ma_uint8, char); #else ma_uint8 oldValue; ma_uint8 newValue; do { oldValue = *dst; newValue = (ma_uint8)(oldValue | src); } while (ma_atomic_compare_and_swap_8(dst, oldValue, newValue) != oldValue); (void)order; return oldValue; #endif } #endif #if defined(MA_ATOMIC_HAS_16) static MA_INLINE ma_uint16 __stdcall ma_atomic_fetch_or_explicit_16(volatile ma_uint16* dst, ma_uint16 src, ma_atomic_memory_order order) { #if defined(MA_ARM) MA_ATOMIC_MSVC_ARM_INTRINSIC(dst, src, order, _InterlockedOr16, ma_uint16, short); #else ma_uint16 oldValue; ma_uint16 newValue; do { oldValue = *dst; newValue = (ma_uint16)(oldValue | src); } while (ma_atomic_compare_and_swap_16(dst, oldValue, newValue) != oldValue); (void)order; return oldValue; #endif } #endif #if defined(MA_ATOMIC_HAS_32) static MA_INLINE ma_uint32 __stdcall ma_atomic_fetch_or_explicit_32(volatile ma_uint32* dst, ma_uint32 src, ma_atomic_memory_order order) { #if defined(MA_ARM) MA_ATOMIC_MSVC_ARM_INTRINSIC(dst, src, order, _InterlockedOr, ma_uint32, long); #else ma_uint32 oldValue; ma_uint32 newValue; do { oldValue = *dst; newValue = oldValue | src; } while (ma_atomic_compare_and_swap_32(dst, oldValue, newValue) != oldValue); (void)order; return oldValue; #endif } #endif #if defined(MA_ATOMIC_HAS_64) static MA_INLINE ma_uint64 __stdcall ma_atomic_fetch_or_explicit_64(volatile ma_uint64* dst, ma_uint64 src, ma_atomic_memory_order order) { #if defined(MA_ARM) MA_ATOMIC_MSVC_ARM_INTRINSIC(dst, src, order, _InterlockedOr64, ma_uint64, long long); #else ma_uint64 oldValue; ma_uint64 newValue; do { oldValue = *dst; newValue = oldValue | src; } while (ma_atomic_compare_and_swap_64(dst, oldValue, newValue) != oldValue); (void)order; return oldValue; #endif } #endif #if defined(MA_ATOMIC_HAS_8) #define ma_atomic_test_and_set_explicit_8( dst, order) ma_atomic_exchange_explicit_8 (dst, 1, order) #endif #if defined(MA_ATOMIC_HAS_16) #define ma_atomic_test_and_set_explicit_16(dst, order) ma_atomic_exchange_explicit_16(dst, 1, order) #endif #if defined(MA_ATOMIC_HAS_32) #define ma_atomic_test_and_set_explicit_32(dst, order) ma_atomic_exchange_explicit_32(dst, 1, order) #endif #if defined(MA_ATOMIC_HAS_64) #define ma_atomic_test_and_set_explicit_64(dst, order) ma_atomic_exchange_explicit_64(dst, 1, order) #endif #if defined(MA_ATOMIC_HAS_8) #define ma_atomic_clear_explicit_8( dst, order) ma_atomic_store_explicit_8 (dst, 0, order) #endif #if defined(MA_ATOMIC_HAS_16) #define ma_atomic_clear_explicit_16(dst, order) ma_atomic_store_explicit_16(dst, 0, order) #endif #if defined(MA_ATOMIC_HAS_32) #define ma_atomic_clear_explicit_32(dst, order) ma_atomic_store_explicit_32(dst, 0, order) #endif #if defined(MA_ATOMIC_HAS_64) #define ma_atomic_clear_explicit_64(dst, order) ma_atomic_store_explicit_64(dst, 0, order) #endif #if defined(MA_ATOMIC_HAS_8) typedef ma_uint8 ma_atomic_flag; #define ma_atomic_flag_test_and_set_explicit(ptr, order) (ma_bool32)ma_atomic_test_and_set_explicit_8(ptr, order) #define ma_atomic_flag_clear_explicit(ptr, order) ma_atomic_clear_explicit_8(ptr, order) #define c89atoimc_flag_load_explicit(ptr, order) ma_atomic_load_explicit_8(ptr, order) #else typedef ma_uint32 ma_atomic_flag; #define ma_atomic_flag_test_and_set_explicit(ptr, order) (ma_bool32)ma_atomic_test_and_set_explicit_32(ptr, order) #define ma_atomic_flag_clear_explicit(ptr, order) ma_atomic_clear_explicit_32(ptr, order) #define c89atoimc_flag_load_explicit(ptr, order) ma_atomic_load_explicit_32(ptr, order) #endif #elif defined(__clang__) || (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7))) #define MA_ATOMIC_HAS_NATIVE_COMPARE_EXCHANGE #define MA_ATOMIC_HAS_NATIVE_IS_LOCK_FREE #define ma_atomic_memory_order_relaxed __ATOMIC_RELAXED #define ma_atomic_memory_order_consume __ATOMIC_CONSUME #define ma_atomic_memory_order_acquire __ATOMIC_ACQUIRE #define ma_atomic_memory_order_release __ATOMIC_RELEASE #define ma_atomic_memory_order_acq_rel __ATOMIC_ACQ_REL #define ma_atomic_memory_order_seq_cst __ATOMIC_SEQ_CST #define ma_atomic_compiler_fence() __asm__ __volatile__("":::"memory") #define ma_atomic_thread_fence(order) __atomic_thread_fence(order) #define ma_atomic_signal_fence(order) __atomic_signal_fence(order) #define ma_atomic_is_lock_free_8(ptr) __atomic_is_lock_free(1, ptr) #define ma_atomic_is_lock_free_16(ptr) __atomic_is_lock_free(2, ptr) #define ma_atomic_is_lock_free_32(ptr) __atomic_is_lock_free(4, ptr) #define ma_atomic_is_lock_free_64(ptr) __atomic_is_lock_free(8, ptr) #define ma_atomic_test_and_set_explicit_8( dst, order) __atomic_exchange_n(dst, 1, order) #define ma_atomic_test_and_set_explicit_16(dst, order) __atomic_exchange_n(dst, 1, order) #define ma_atomic_test_and_set_explicit_32(dst, order) __atomic_exchange_n(dst, 1, order) #define ma_atomic_test_and_set_explicit_64(dst, order) __atomic_exchange_n(dst, 1, order) #define ma_atomic_clear_explicit_8( dst, order) __atomic_store_n(dst, 0, order) #define ma_atomic_clear_explicit_16(dst, order) __atomic_store_n(dst, 0, order) #define ma_atomic_clear_explicit_32(dst, order) __atomic_store_n(dst, 0, order) #define ma_atomic_clear_explicit_64(dst, order) __atomic_store_n(dst, 0, order) #define ma_atomic_store_explicit_8( dst, src, order) __atomic_store_n(dst, src, order) #define ma_atomic_store_explicit_16(dst, src, order) __atomic_store_n(dst, src, order) #define ma_atomic_store_explicit_32(dst, src, order) __atomic_store_n(dst, src, order) #define ma_atomic_store_explicit_64(dst, src, order) __atomic_store_n(dst, src, order) #define ma_atomic_load_explicit_8( dst, order) __atomic_load_n(dst, order) #define ma_atomic_load_explicit_16(dst, order) __atomic_load_n(dst, order) #define ma_atomic_load_explicit_32(dst, order) __atomic_load_n(dst, order) #define ma_atomic_load_explicit_64(dst, order) __atomic_load_n(dst, order) #define ma_atomic_exchange_explicit_8( dst, src, order) __atomic_exchange_n(dst, src, order) #define ma_atomic_exchange_explicit_16(dst, src, order) __atomic_exchange_n(dst, src, order) #define ma_atomic_exchange_explicit_32(dst, src, order) __atomic_exchange_n(dst, src, order) #define ma_atomic_exchange_explicit_64(dst, src, order) __atomic_exchange_n(dst, src, order) #define ma_atomic_compare_exchange_strong_explicit_8( dst, expected, desired, successOrder, failureOrder) __atomic_compare_exchange_n(dst, expected, desired, 0, successOrder, failureOrder) #define ma_atomic_compare_exchange_strong_explicit_16(dst, expected, desired, successOrder, failureOrder) __atomic_compare_exchange_n(dst, expected, desired, 0, successOrder, failureOrder) #define ma_atomic_compare_exchange_strong_explicit_32(dst, expected, desired, successOrder, failureOrder) __atomic_compare_exchange_n(dst, expected, desired, 0, successOrder, failureOrder) #define ma_atomic_compare_exchange_strong_explicit_64(dst, expected, desired, successOrder, failureOrder) __atomic_compare_exchange_n(dst, expected, desired, 0, successOrder, failureOrder) #define ma_atomic_compare_exchange_weak_explicit_8( dst, expected, desired, successOrder, failureOrder) __atomic_compare_exchange_n(dst, expected, desired, 1, successOrder, failureOrder) #define ma_atomic_compare_exchange_weak_explicit_16(dst, expected, desired, successOrder, failureOrder) __atomic_compare_exchange_n(dst, expected, desired, 1, successOrder, failureOrder) #define ma_atomic_compare_exchange_weak_explicit_32(dst, expected, desired, successOrder, failureOrder) __atomic_compare_exchange_n(dst, expected, desired, 1, successOrder, failureOrder) #define ma_atomic_compare_exchange_weak_explicit_64(dst, expected, desired, successOrder, failureOrder) __atomic_compare_exchange_n(dst, expected, desired, 1, successOrder, failureOrder) #define ma_atomic_fetch_add_explicit_8( dst, src, order) __atomic_fetch_add(dst, src, order) #define ma_atomic_fetch_add_explicit_16(dst, src, order) __atomic_fetch_add(dst, src, order) #define ma_atomic_fetch_add_explicit_32(dst, src, order) __atomic_fetch_add(dst, src, order) #define ma_atomic_fetch_add_explicit_64(dst, src, order) __atomic_fetch_add(dst, src, order) #define ma_atomic_fetch_sub_explicit_8( dst, src, order) __atomic_fetch_sub(dst, src, order) #define ma_atomic_fetch_sub_explicit_16(dst, src, order) __atomic_fetch_sub(dst, src, order) #define ma_atomic_fetch_sub_explicit_32(dst, src, order) __atomic_fetch_sub(dst, src, order) #define ma_atomic_fetch_sub_explicit_64(dst, src, order) __atomic_fetch_sub(dst, src, order) #define ma_atomic_fetch_or_explicit_8( dst, src, order) __atomic_fetch_or(dst, src, order) #define ma_atomic_fetch_or_explicit_16(dst, src, order) __atomic_fetch_or(dst, src, order) #define ma_atomic_fetch_or_explicit_32(dst, src, order) __atomic_fetch_or(dst, src, order) #define ma_atomic_fetch_or_explicit_64(dst, src, order) __atomic_fetch_or(dst, src, order) #define ma_atomic_fetch_xor_explicit_8( dst, src, order) __atomic_fetch_xor(dst, src, order) #define ma_atomic_fetch_xor_explicit_16(dst, src, order) __atomic_fetch_xor(dst, src, order) #define ma_atomic_fetch_xor_explicit_32(dst, src, order) __atomic_fetch_xor(dst, src, order) #define ma_atomic_fetch_xor_explicit_64(dst, src, order) __atomic_fetch_xor(dst, src, order) #define ma_atomic_fetch_and_explicit_8( dst, src, order) __atomic_fetch_and(dst, src, order) #define ma_atomic_fetch_and_explicit_16(dst, src, order) __atomic_fetch_and(dst, src, order) #define ma_atomic_fetch_and_explicit_32(dst, src, order) __atomic_fetch_and(dst, src, order) #define ma_atomic_fetch_and_explicit_64(dst, src, order) __atomic_fetch_and(dst, src, order) static MA_INLINE ma_uint8 ma_atomic_compare_and_swap_8(volatile ma_uint8* dst, ma_uint8 expected, ma_uint8 desired) { __atomic_compare_exchange_n(dst, &expected, desired, 0, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); return expected; } static MA_INLINE ma_uint16 ma_atomic_compare_and_swap_16(volatile ma_uint16* dst, ma_uint16 expected, ma_uint16 desired) { __atomic_compare_exchange_n(dst, &expected, desired, 0, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); return expected; } static MA_INLINE ma_uint32 ma_atomic_compare_and_swap_32(volatile ma_uint32* dst, ma_uint32 expected, ma_uint32 desired) { __atomic_compare_exchange_n(dst, &expected, desired, 0, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); return expected; } static MA_INLINE ma_uint64 ma_atomic_compare_and_swap_64(volatile ma_uint64* dst, ma_uint64 expected, ma_uint64 desired) { __atomic_compare_exchange_n(dst, &expected, desired, 0, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); return expected; } typedef ma_uint8 ma_atomic_flag; #define ma_atomic_flag_test_and_set_explicit(dst, order) (ma_bool32)__atomic_test_and_set(dst, order) #define ma_atomic_flag_clear_explicit(dst, order) __atomic_clear(dst, order) #define c89atoimc_flag_load_explicit(ptr, order) ma_atomic_load_explicit_8(ptr, order) #else #define ma_atomic_memory_order_relaxed 1 #define ma_atomic_memory_order_consume 2 #define ma_atomic_memory_order_acquire 3 #define ma_atomic_memory_order_release 4 #define ma_atomic_memory_order_acq_rel 5 #define ma_atomic_memory_order_seq_cst 6 #define ma_atomic_compiler_fence() __asm__ __volatile__("":::"memory") #if defined(__GNUC__) #define ma_atomic_thread_fence(order) __sync_synchronize(), (void)order static MA_INLINE ma_uint8 ma_atomic_exchange_explicit_8(volatile ma_uint8* dst, ma_uint8 src, ma_atomic_memory_order order) { if (order > ma_atomic_memory_order_acquire) { __sync_synchronize(); } return __sync_lock_test_and_set(dst, src); } static MA_INLINE ma_uint16 ma_atomic_exchange_explicit_16(volatile ma_uint16* dst, ma_uint16 src, ma_atomic_memory_order order) { ma_uint16 oldValue; do { oldValue = *dst; } while (__sync_val_compare_and_swap(dst, oldValue, src) != oldValue); (void)order; return oldValue; } static MA_INLINE ma_uint32 ma_atomic_exchange_explicit_32(volatile ma_uint32* dst, ma_uint32 src, ma_atomic_memory_order order) { ma_uint32 oldValue; do { oldValue = *dst; } while (__sync_val_compare_and_swap(dst, oldValue, src) != oldValue); (void)order; return oldValue; } static MA_INLINE ma_uint64 ma_atomic_exchange_explicit_64(volatile ma_uint64* dst, ma_uint64 src, ma_atomic_memory_order order) { ma_uint64 oldValue; do { oldValue = *dst; } while (__sync_val_compare_and_swap(dst, oldValue, src) != oldValue); (void)order; return oldValue; } static MA_INLINE ma_uint8 ma_atomic_fetch_add_explicit_8(volatile ma_uint8* dst, ma_uint8 src, ma_atomic_memory_order order) { (void)order; return __sync_fetch_and_add(dst, src); } static MA_INLINE ma_uint16 ma_atomic_fetch_add_explicit_16(volatile ma_uint16* dst, ma_uint16 src, ma_atomic_memory_order order) { (void)order; return __sync_fetch_and_add(dst, src); } static MA_INLINE ma_uint32 ma_atomic_fetch_add_explicit_32(volatile ma_uint32* dst, ma_uint32 src, ma_atomic_memory_order order) { (void)order; return __sync_fetch_and_add(dst, src); } static MA_INLINE ma_uint64 ma_atomic_fetch_add_explicit_64(volatile ma_uint64* dst, ma_uint64 src, ma_atomic_memory_order order) { (void)order; return __sync_fetch_and_add(dst, src); } static MA_INLINE ma_uint8 ma_atomic_fetch_sub_explicit_8(volatile ma_uint8* dst, ma_uint8 src, ma_atomic_memory_order order) { (void)order; return __sync_fetch_and_sub(dst, src); } static MA_INLINE ma_uint16 ma_atomic_fetch_sub_explicit_16(volatile ma_uint16* dst, ma_uint16 src, ma_atomic_memory_order order) { (void)order; return __sync_fetch_and_sub(dst, src); } static MA_INLINE ma_uint32 ma_atomic_fetch_sub_explicit_32(volatile ma_uint32* dst, ma_uint32 src, ma_atomic_memory_order order) { (void)order; return __sync_fetch_and_sub(dst, src); } static MA_INLINE ma_uint64 ma_atomic_fetch_sub_explicit_64(volatile ma_uint64* dst, ma_uint64 src, ma_atomic_memory_order order) { (void)order; return __sync_fetch_and_sub(dst, src); } static MA_INLINE ma_uint8 ma_atomic_fetch_or_explicit_8(volatile ma_uint8* dst, ma_uint8 src, ma_atomic_memory_order order) { (void)order; return __sync_fetch_and_or(dst, src); } static MA_INLINE ma_uint16 ma_atomic_fetch_or_explicit_16(volatile ma_uint16* dst, ma_uint16 src, ma_atomic_memory_order order) { (void)order; return __sync_fetch_and_or(dst, src); } static MA_INLINE ma_uint32 ma_atomic_fetch_or_explicit_32(volatile ma_uint32* dst, ma_uint32 src, ma_atomic_memory_order order) { (void)order; return __sync_fetch_and_or(dst, src); } static MA_INLINE ma_uint64 ma_atomic_fetch_or_explicit_64(volatile ma_uint64* dst, ma_uint64 src, ma_atomic_memory_order order) { (void)order; return __sync_fetch_and_or(dst, src); } static MA_INLINE ma_uint8 ma_atomic_fetch_xor_explicit_8(volatile ma_uint8* dst, ma_uint8 src, ma_atomic_memory_order order) { (void)order; return __sync_fetch_and_xor(dst, src); } static MA_INLINE ma_uint16 ma_atomic_fetch_xor_explicit_16(volatile ma_uint16* dst, ma_uint16 src, ma_atomic_memory_order order) { (void)order; return __sync_fetch_and_xor(dst, src); } static MA_INLINE ma_uint32 ma_atomic_fetch_xor_explicit_32(volatile ma_uint32* dst, ma_uint32 src, ma_atomic_memory_order order) { (void)order; return __sync_fetch_and_xor(dst, src); } static MA_INLINE ma_uint64 ma_atomic_fetch_xor_explicit_64(volatile ma_uint64* dst, ma_uint64 src, ma_atomic_memory_order order) { (void)order; return __sync_fetch_and_xor(dst, src); } static MA_INLINE ma_uint8 ma_atomic_fetch_and_explicit_8(volatile ma_uint8* dst, ma_uint8 src, ma_atomic_memory_order order) { (void)order; return __sync_fetch_and_and(dst, src); } static MA_INLINE ma_uint16 ma_atomic_fetch_and_explicit_16(volatile ma_uint16* dst, ma_uint16 src, ma_atomic_memory_order order) { (void)order; return __sync_fetch_and_and(dst, src); } static MA_INLINE ma_uint32 ma_atomic_fetch_and_explicit_32(volatile ma_uint32* dst, ma_uint32 src, ma_atomic_memory_order order) { (void)order; return __sync_fetch_and_and(dst, src); } static MA_INLINE ma_uint64 ma_atomic_fetch_and_explicit_64(volatile ma_uint64* dst, ma_uint64 src, ma_atomic_memory_order order) { (void)order; return __sync_fetch_and_and(dst, src); } #define ma_atomic_compare_and_swap_8( dst, expected, desired) __sync_val_compare_and_swap(dst, expected, desired) #define ma_atomic_compare_and_swap_16(dst, expected, desired) __sync_val_compare_and_swap(dst, expected, desired) #define ma_atomic_compare_and_swap_32(dst, expected, desired) __sync_val_compare_and_swap(dst, expected, desired) #define ma_atomic_compare_and_swap_64(dst, expected, desired) __sync_val_compare_and_swap(dst, expected, desired) #else #if defined(MA_X86) #define ma_atomic_thread_fence(order) __asm__ __volatile__("lock; addl $0, (%%esp)" ::: "memory", "cc") #elif defined(MA_X64) #define ma_atomic_thread_fence(order) __asm__ __volatile__("lock; addq $0, (%%rsp)" ::: "memory", "cc") #else #error Unsupported architecture. Please submit a feature request. #endif static MA_INLINE ma_uint8 ma_atomic_compare_and_swap_8(volatile ma_uint8* dst, ma_uint8 expected, ma_uint8 desired) { ma_uint8 result; #if defined(MA_X86) || defined(MA_X64) __asm__ __volatile__("lock; cmpxchg %3, %0" : "+m"(*dst), "=a"(result) : "a"(expected), "d"(desired) : "cc"); #else #error Unsupported architecture. Please submit a feature request. #endif return result; } static MA_INLINE ma_uint16 ma_atomic_compare_and_swap_16(volatile ma_uint16* dst, ma_uint16 expected, ma_uint16 desired) { ma_uint16 result; #if defined(MA_X86) || defined(MA_X64) __asm__ __volatile__("lock; cmpxchg %3, %0" : "+m"(*dst), "=a"(result) : "a"(expected), "d"(desired) : "cc"); #else #error Unsupported architecture. Please submit a feature request. #endif return result; } static MA_INLINE ma_uint32 ma_atomic_compare_and_swap_32(volatile ma_uint32* dst, ma_uint32 expected, ma_uint32 desired) { ma_uint32 result; #if defined(MA_X86) || defined(MA_X64) __asm__ __volatile__("lock; cmpxchg %3, %0" : "+m"(*dst), "=a"(result) : "a"(expected), "d"(desired) : "cc"); #else #error Unsupported architecture. Please submit a feature request. #endif return result; } static MA_INLINE ma_uint64 ma_atomic_compare_and_swap_64(volatile ma_uint64* dst, ma_uint64 expected, ma_uint64 desired) { volatile ma_uint64 result; #if defined(MA_X86) ma_uint32 resultEAX; ma_uint32 resultEDX; __asm__ __volatile__("push %%ebx; xchg %5, %%ebx; lock; cmpxchg8b %0; pop %%ebx" : "+m"(*dst), "=a"(resultEAX), "=d"(resultEDX) : "a"(expected & 0xFFFFFFFF), "d"(expected >> 32), "r"(desired & 0xFFFFFFFF), "c"(desired >> 32) : "cc"); result = ((ma_uint64)resultEDX << 32) | resultEAX; #elif defined(MA_X64) __asm__ __volatile__("lock; cmpxchg %3, %0" : "+m"(*dst), "=a"(result) : "a"(expected), "d"(desired) : "cc"); #else #error Unsupported architecture. Please submit a feature request. #endif return result; } static MA_INLINE ma_uint8 ma_atomic_exchange_explicit_8(volatile ma_uint8* dst, ma_uint8 src, ma_atomic_memory_order order) { ma_uint8 result = 0; (void)order; #if defined(MA_X86) || defined(MA_X64) __asm__ __volatile__("lock; xchg %1, %0" : "+m"(*dst), "=a"(result) : "a"(src)); #else #error Unsupported architecture. Please submit a feature request. #endif return result; } static MA_INLINE ma_uint16 ma_atomic_exchange_explicit_16(volatile ma_uint16* dst, ma_uint16 src, ma_atomic_memory_order order) { ma_uint16 result = 0; (void)order; #if defined(MA_X86) || defined(MA_X64) __asm__ __volatile__("lock; xchg %1, %0" : "+m"(*dst), "=a"(result) : "a"(src)); #else #error Unsupported architecture. Please submit a feature request. #endif return result; } static MA_INLINE ma_uint32 ma_atomic_exchange_explicit_32(volatile ma_uint32* dst, ma_uint32 src, ma_atomic_memory_order order) { ma_uint32 result; (void)order; #if defined(MA_X86) || defined(MA_X64) __asm__ __volatile__("lock; xchg %1, %0" : "+m"(*dst), "=a"(result) : "a"(src)); #else #error Unsupported architecture. Please submit a feature request. #endif return result; } static MA_INLINE ma_uint64 ma_atomic_exchange_explicit_64(volatile ma_uint64* dst, ma_uint64 src, ma_atomic_memory_order order) { ma_uint64 result; (void)order; #if defined(MA_X86) do { result = *dst; } while (ma_atomic_compare_and_swap_64(dst, result, src) != result); #elif defined(MA_X64) __asm__ __volatile__("lock; xchg %1, %0" : "+m"(*dst), "=a"(result) : "a"(src)); #else #error Unsupported architecture. Please submit a feature request. #endif return result; } static MA_INLINE ma_uint8 ma_atomic_fetch_add_explicit_8(volatile ma_uint8* dst, ma_uint8 src, ma_atomic_memory_order order) { ma_uint8 result; (void)order; #if defined(MA_X86) || defined(MA_X64) __asm__ __volatile__("lock; xadd %1, %0" : "+m"(*dst), "=a"(result) : "a"(src) : "cc"); #else #error Unsupported architecture. Please submit a feature request. #endif return result; } static MA_INLINE ma_uint16 ma_atomic_fetch_add_explicit_16(volatile ma_uint16* dst, ma_uint16 src, ma_atomic_memory_order order) { ma_uint16 result; (void)order; #if defined(MA_X86) || defined(MA_X64) __asm__ __volatile__("lock; xadd %1, %0" : "+m"(*dst), "=a"(result) : "a"(src) : "cc"); #else #error Unsupported architecture. Please submit a feature request. #endif return result; } static MA_INLINE ma_uint32 ma_atomic_fetch_add_explicit_32(volatile ma_uint32* dst, ma_uint32 src, ma_atomic_memory_order order) { ma_uint32 result; (void)order; #if defined(MA_X86) || defined(MA_X64) __asm__ __volatile__("lock; xadd %1, %0" : "+m"(*dst), "=a"(result) : "a"(src) : "cc"); #else #error Unsupported architecture. Please submit a feature request. #endif return result; } static MA_INLINE ma_uint64 ma_atomic_fetch_add_explicit_64(volatile ma_uint64* dst, ma_uint64 src, ma_atomic_memory_order order) { #if defined(MA_X86) ma_uint64 oldValue; ma_uint64 newValue; (void)order; do { oldValue = *dst; newValue = oldValue + src; } while (ma_atomic_compare_and_swap_64(dst, oldValue, newValue) != oldValue); return oldValue; #elif defined(MA_X64) ma_uint64 result; (void)order; __asm__ __volatile__("lock; xadd %1, %0" : "+m"(*dst), "=a"(result) : "a"(src) : "cc"); return result; #endif } static MA_INLINE ma_uint8 ma_atomic_fetch_sub_explicit_8(volatile ma_uint8* dst, ma_uint8 src, ma_atomic_memory_order order) { ma_uint8 oldValue; ma_uint8 newValue; do { oldValue = *dst; newValue = (ma_uint8)(oldValue - src); } while (ma_atomic_compare_and_swap_8(dst, oldValue, newValue) != oldValue); (void)order; return oldValue; } static MA_INLINE ma_uint16 ma_atomic_fetch_sub_explicit_16(volatile ma_uint16* dst, ma_uint16 src, ma_atomic_memory_order order) { ma_uint16 oldValue; ma_uint16 newValue; do { oldValue = *dst; newValue = (ma_uint16)(oldValue - src); } while (ma_atomic_compare_and_swap_16(dst, oldValue, newValue) != oldValue); (void)order; return oldValue; } static MA_INLINE ma_uint32 ma_atomic_fetch_sub_explicit_32(volatile ma_uint32* dst, ma_uint32 src, ma_atomic_memory_order order) { ma_uint32 oldValue; ma_uint32 newValue; do { oldValue = *dst; newValue = oldValue - src; } while (ma_atomic_compare_and_swap_32(dst, oldValue, newValue) != oldValue); (void)order; return oldValue; } static MA_INLINE ma_uint64 ma_atomic_fetch_sub_explicit_64(volatile ma_uint64* dst, ma_uint64 src, ma_atomic_memory_order order) { ma_uint64 oldValue; ma_uint64 newValue; do { oldValue = *dst; newValue = oldValue - src; } while (ma_atomic_compare_and_swap_64(dst, oldValue, newValue) != oldValue); (void)order; return oldValue; } static MA_INLINE ma_uint8 ma_atomic_fetch_and_explicit_8(volatile ma_uint8* dst, ma_uint8 src, ma_atomic_memory_order order) { ma_uint8 oldValue; ma_uint8 newValue; do { oldValue = *dst; newValue = (ma_uint8)(oldValue & src); } while (ma_atomic_compare_and_swap_8(dst, oldValue, newValue) != oldValue); (void)order; return oldValue; } static MA_INLINE ma_uint16 ma_atomic_fetch_and_explicit_16(volatile ma_uint16* dst, ma_uint16 src, ma_atomic_memory_order order) { ma_uint16 oldValue; ma_uint16 newValue; do { oldValue = *dst; newValue = (ma_uint16)(oldValue & src); } while (ma_atomic_compare_and_swap_16(dst, oldValue, newValue) != oldValue); (void)order; return oldValue; } static MA_INLINE ma_uint32 ma_atomic_fetch_and_explicit_32(volatile ma_uint32* dst, ma_uint32 src, ma_atomic_memory_order order) { ma_uint32 oldValue; ma_uint32 newValue; do { oldValue = *dst; newValue = oldValue & src; } while (ma_atomic_compare_and_swap_32(dst, oldValue, newValue) != oldValue); (void)order; return oldValue; } static MA_INLINE ma_uint64 ma_atomic_fetch_and_explicit_64(volatile ma_uint64* dst, ma_uint64 src, ma_atomic_memory_order order) { ma_uint64 oldValue; ma_uint64 newValue; do { oldValue = *dst; newValue = oldValue & src; } while (ma_atomic_compare_and_swap_64(dst, oldValue, newValue) != oldValue); (void)order; return oldValue; } static MA_INLINE ma_uint8 ma_atomic_fetch_xor_explicit_8(volatile ma_uint8* dst, ma_uint8 src, ma_atomic_memory_order order) { ma_uint8 oldValue; ma_uint8 newValue; do { oldValue = *dst; newValue = (ma_uint8)(oldValue ^ src); } while (ma_atomic_compare_and_swap_8(dst, oldValue, newValue) != oldValue); (void)order; return oldValue; } static MA_INLINE ma_uint16 ma_atomic_fetch_xor_explicit_16(volatile ma_uint16* dst, ma_uint16 src, ma_atomic_memory_order order) { ma_uint16 oldValue; ma_uint16 newValue; do { oldValue = *dst; newValue = (ma_uint16)(oldValue ^ src); } while (ma_atomic_compare_and_swap_16(dst, oldValue, newValue) != oldValue); (void)order; return oldValue; } static MA_INLINE ma_uint32 ma_atomic_fetch_xor_explicit_32(volatile ma_uint32* dst, ma_uint32 src, ma_atomic_memory_order order) { ma_uint32 oldValue; ma_uint32 newValue; do { oldValue = *dst; newValue = oldValue ^ src; } while (ma_atomic_compare_and_swap_32(dst, oldValue, newValue) != oldValue); (void)order; return oldValue; } static MA_INLINE ma_uint64 ma_atomic_fetch_xor_explicit_64(volatile ma_uint64* dst, ma_uint64 src, ma_atomic_memory_order order) { ma_uint64 oldValue; ma_uint64 newValue; do { oldValue = *dst; newValue = oldValue ^ src; } while (ma_atomic_compare_and_swap_64(dst, oldValue, newValue) != oldValue); (void)order; return oldValue; } static MA_INLINE ma_uint8 ma_atomic_fetch_or_explicit_8(volatile ma_uint8* dst, ma_uint8 src, ma_atomic_memory_order order) { ma_uint8 oldValue; ma_uint8 newValue; do { oldValue = *dst; newValue = (ma_uint8)(oldValue | src); } while (ma_atomic_compare_and_swap_8(dst, oldValue, newValue) != oldValue); (void)order; return oldValue; } static MA_INLINE ma_uint16 ma_atomic_fetch_or_explicit_16(volatile ma_uint16* dst, ma_uint16 src, ma_atomic_memory_order order) { ma_uint16 oldValue; ma_uint16 newValue; do { oldValue = *dst; newValue = (ma_uint16)(oldValue | src); } while (ma_atomic_compare_and_swap_16(dst, oldValue, newValue) != oldValue); (void)order; return oldValue; } static MA_INLINE ma_uint32 ma_atomic_fetch_or_explicit_32(volatile ma_uint32* dst, ma_uint32 src, ma_atomic_memory_order order) { ma_uint32 oldValue; ma_uint32 newValue; do { oldValue = *dst; newValue = oldValue | src; } while (ma_atomic_compare_and_swap_32(dst, oldValue, newValue) != oldValue); (void)order; return oldValue; } static MA_INLINE ma_uint64 ma_atomic_fetch_or_explicit_64(volatile ma_uint64* dst, ma_uint64 src, ma_atomic_memory_order order) { ma_uint64 oldValue; ma_uint64 newValue; do { oldValue = *dst; newValue = oldValue | src; } while (ma_atomic_compare_and_swap_64(dst, oldValue, newValue) != oldValue); (void)order; return oldValue; } #endif #define ma_atomic_signal_fence(order) ma_atomic_thread_fence(order) static MA_INLINE ma_uint8 ma_atomic_load_explicit_8(volatile const ma_uint8* ptr, ma_atomic_memory_order order) { (void)order; return ma_atomic_compare_and_swap_8((ma_uint8*)ptr, 0, 0); } static MA_INLINE ma_uint16 ma_atomic_load_explicit_16(volatile const ma_uint16* ptr, ma_atomic_memory_order order) { (void)order; return ma_atomic_compare_and_swap_16((ma_uint16*)ptr, 0, 0); } static MA_INLINE ma_uint32 ma_atomic_load_explicit_32(volatile const ma_uint32* ptr, ma_atomic_memory_order order) { (void)order; return ma_atomic_compare_and_swap_32((ma_uint32*)ptr, 0, 0); } static MA_INLINE ma_uint64 ma_atomic_load_explicit_64(volatile const ma_uint64* ptr, ma_atomic_memory_order order) { (void)order; return ma_atomic_compare_and_swap_64((ma_uint64*)ptr, 0, 0); } #define ma_atomic_store_explicit_8( dst, src, order) (void)ma_atomic_exchange_explicit_8 (dst, src, order) #define ma_atomic_store_explicit_16(dst, src, order) (void)ma_atomic_exchange_explicit_16(dst, src, order) #define ma_atomic_store_explicit_32(dst, src, order) (void)ma_atomic_exchange_explicit_32(dst, src, order) #define ma_atomic_store_explicit_64(dst, src, order) (void)ma_atomic_exchange_explicit_64(dst, src, order) #define ma_atomic_test_and_set_explicit_8( dst, order) ma_atomic_exchange_explicit_8 (dst, 1, order) #define ma_atomic_test_and_set_explicit_16(dst, order) ma_atomic_exchange_explicit_16(dst, 1, order) #define ma_atomic_test_and_set_explicit_32(dst, order) ma_atomic_exchange_explicit_32(dst, 1, order) #define ma_atomic_test_and_set_explicit_64(dst, order) ma_atomic_exchange_explicit_64(dst, 1, order) #define ma_atomic_clear_explicit_8( dst, order) ma_atomic_store_explicit_8 (dst, 0, order) #define ma_atomic_clear_explicit_16(dst, order) ma_atomic_store_explicit_16(dst, 0, order) #define ma_atomic_clear_explicit_32(dst, order) ma_atomic_store_explicit_32(dst, 0, order) #define ma_atomic_clear_explicit_64(dst, order) ma_atomic_store_explicit_64(dst, 0, order) typedef ma_uint8 ma_atomic_flag; #define ma_atomic_flag_test_and_set_explicit(ptr, order) (ma_bool32)ma_atomic_test_and_set_explicit_8(ptr, order) #define ma_atomic_flag_clear_explicit(ptr, order) ma_atomic_clear_explicit_8(ptr, order) #define c89atoimc_flag_load_explicit(ptr, order) ma_atomic_load_explicit_8(ptr, order) #endif #if !defined(MA_ATOMIC_HAS_NATIVE_COMPARE_EXCHANGE) #if defined(MA_ATOMIC_HAS_8) static MA_INLINE ma_bool32 ma_atomic_compare_exchange_strong_explicit_8(volatile ma_uint8* dst, ma_uint8* expected, ma_uint8 desired, ma_atomic_memory_order successOrder, ma_atomic_memory_order failureOrder) { ma_uint8 expectedValue; ma_uint8 result; (void)successOrder; (void)failureOrder; expectedValue = ma_atomic_load_explicit_8(expected, ma_atomic_memory_order_seq_cst); result = ma_atomic_compare_and_swap_8(dst, expectedValue, desired); if (result == expectedValue) { return 1; } else { ma_atomic_store_explicit_8(expected, result, failureOrder); return 0; } } #endif #if defined(MA_ATOMIC_HAS_16) static MA_INLINE ma_bool32 ma_atomic_compare_exchange_strong_explicit_16(volatile ma_uint16* dst, ma_uint16* expected, ma_uint16 desired, ma_atomic_memory_order successOrder, ma_atomic_memory_order failureOrder) { ma_uint16 expectedValue; ma_uint16 result; (void)successOrder; (void)failureOrder; expectedValue = ma_atomic_load_explicit_16(expected, ma_atomic_memory_order_seq_cst); result = ma_atomic_compare_and_swap_16(dst, expectedValue, desired); if (result == expectedValue) { return 1; } else { ma_atomic_store_explicit_16(expected, result, failureOrder); return 0; } } #endif #if defined(MA_ATOMIC_HAS_32) static MA_INLINE ma_bool32 ma_atomic_compare_exchange_strong_explicit_32(volatile ma_uint32* dst, ma_uint32* expected, ma_uint32 desired, ma_atomic_memory_order successOrder, ma_atomic_memory_order failureOrder) { ma_uint32 expectedValue; ma_uint32 result; (void)successOrder; (void)failureOrder; expectedValue = ma_atomic_load_explicit_32(expected, ma_atomic_memory_order_seq_cst); result = ma_atomic_compare_and_swap_32(dst, expectedValue, desired); if (result == expectedValue) { return 1; } else { ma_atomic_store_explicit_32(expected, result, failureOrder); return 0; } } #endif #if defined(MA_ATOMIC_HAS_64) static MA_INLINE ma_bool32 ma_atomic_compare_exchange_strong_explicit_64(volatile ma_uint64* dst, volatile ma_uint64* expected, ma_uint64 desired, ma_atomic_memory_order successOrder, ma_atomic_memory_order failureOrder) { ma_uint64 expectedValue; ma_uint64 result; (void)successOrder; (void)failureOrder; expectedValue = ma_atomic_load_explicit_64(expected, ma_atomic_memory_order_seq_cst); result = ma_atomic_compare_and_swap_64(dst, expectedValue, desired); if (result == expectedValue) { return 1; } else { ma_atomic_store_explicit_64(expected, result, failureOrder); return 0; } } #endif #define ma_atomic_compare_exchange_weak_explicit_8( dst, expected, desired, successOrder, failureOrder) ma_atomic_compare_exchange_strong_explicit_8 (dst, expected, desired, successOrder, failureOrder) #define ma_atomic_compare_exchange_weak_explicit_16(dst, expected, desired, successOrder, failureOrder) ma_atomic_compare_exchange_strong_explicit_16(dst, expected, desired, successOrder, failureOrder) #define ma_atomic_compare_exchange_weak_explicit_32(dst, expected, desired, successOrder, failureOrder) ma_atomic_compare_exchange_strong_explicit_32(dst, expected, desired, successOrder, failureOrder) #define ma_atomic_compare_exchange_weak_explicit_64(dst, expected, desired, successOrder, failureOrder) ma_atomic_compare_exchange_strong_explicit_64(dst, expected, desired, successOrder, failureOrder) #endif #if !defined(MA_ATOMIC_HAS_NATIVE_IS_LOCK_FREE) static MA_INLINE ma_bool32 ma_atomic_is_lock_free_8(volatile void* ptr) { (void)ptr; return 1; } static MA_INLINE ma_bool32 ma_atomic_is_lock_free_16(volatile void* ptr) { (void)ptr; return 1; } static MA_INLINE ma_bool32 ma_atomic_is_lock_free_32(volatile void* ptr) { (void)ptr; return 1; } static MA_INLINE ma_bool32 ma_atomic_is_lock_free_64(volatile void* ptr) { (void)ptr; #if defined(MA_64BIT) return 1; #else #if defined(MA_X86) || defined(MA_X64) return 1; #else return 0; #endif #endif } #endif #if defined(MA_64BIT) static MA_INLINE ma_bool32 ma_atomic_is_lock_free_ptr(volatile void** ptr) { return ma_atomic_is_lock_free_64((volatile ma_uint64*)ptr); } static MA_INLINE void* ma_atomic_load_explicit_ptr(volatile void** ptr, ma_atomic_memory_order order) { return (void*)ma_atomic_load_explicit_64((volatile ma_uint64*)ptr, order); } static MA_INLINE void ma_atomic_store_explicit_ptr(volatile void** dst, void* src, ma_atomic_memory_order order) { ma_atomic_store_explicit_64((volatile ma_uint64*)dst, (ma_uint64)src, order); } static MA_INLINE void* ma_atomic_exchange_explicit_ptr(volatile void** dst, void* src, ma_atomic_memory_order order) { return (void*)ma_atomic_exchange_explicit_64((volatile ma_uint64*)dst, (ma_uint64)src, order); } static MA_INLINE ma_bool32 ma_atomic_compare_exchange_strong_explicit_ptr(volatile void** dst, void** expected, void* desired, ma_atomic_memory_order successOrder, ma_atomic_memory_order failureOrder) { return ma_atomic_compare_exchange_strong_explicit_64((volatile ma_uint64*)dst, (ma_uint64*)expected, (ma_uint64)desired, successOrder, failureOrder); } static MA_INLINE ma_bool32 ma_atomic_compare_exchange_weak_explicit_ptr(volatile void** dst, void** expected, void* desired, ma_atomic_memory_order successOrder, ma_atomic_memory_order failureOrder) { return ma_atomic_compare_exchange_weak_explicit_64((volatile ma_uint64*)dst, (ma_uint64*)expected, (ma_uint64)desired, successOrder, failureOrder); } static MA_INLINE void* ma_atomic_compare_and_swap_ptr(volatile void** dst, void* expected, void* desired) { return (void*)ma_atomic_compare_and_swap_64((volatile ma_uint64*)dst, (ma_uint64)expected, (ma_uint64)desired); } #elif defined(MA_32BIT) static MA_INLINE ma_bool32 ma_atomic_is_lock_free_ptr(volatile void** ptr) { return ma_atomic_is_lock_free_32((volatile ma_uint32*)ptr); } static MA_INLINE void* ma_atomic_load_explicit_ptr(volatile void** ptr, ma_atomic_memory_order order) { return (void*)ma_atomic_load_explicit_32((volatile ma_uint32*)ptr, order); } static MA_INLINE void ma_atomic_store_explicit_ptr(volatile void** dst, void* src, ma_atomic_memory_order order) { ma_atomic_store_explicit_32((volatile ma_uint32*)dst, (ma_uint32)src, order); } static MA_INLINE void* ma_atomic_exchange_explicit_ptr(volatile void** dst, void* src, ma_atomic_memory_order order) { return (void*)ma_atomic_exchange_explicit_32((volatile ma_uint32*)dst, (ma_uint32)src, order); } static MA_INLINE ma_bool32 ma_atomic_compare_exchange_strong_explicit_ptr(volatile void** dst, void** expected, void* desired, ma_atomic_memory_order successOrder, ma_atomic_memory_order failureOrder) { return ma_atomic_compare_exchange_strong_explicit_32((volatile ma_uint32*)dst, (ma_uint32*)expected, (ma_uint32)desired, successOrder, failureOrder); } static MA_INLINE ma_bool32 ma_atomic_compare_exchange_weak_explicit_ptr(volatile void** dst, void** expected, void* desired, ma_atomic_memory_order successOrder, ma_atomic_memory_order failureOrder) { return ma_atomic_compare_exchange_weak_explicit_32((volatile ma_uint32*)dst, (ma_uint32*)expected, (ma_uint32)desired, successOrder, failureOrder); } static MA_INLINE void* ma_atomic_compare_and_swap_ptr(volatile void** dst, void* expected, void* desired) { return (void*)ma_atomic_compare_and_swap_32((volatile ma_uint32*)dst, (ma_uint32)expected, (ma_uint32)desired); } #else #error Unsupported architecture. #endif #define ma_atomic_flag_test_and_set(ptr) ma_atomic_flag_test_and_set_explicit(ptr, ma_atomic_memory_order_seq_cst) #define ma_atomic_flag_clear(ptr) ma_atomic_flag_clear_explicit(ptr, ma_atomic_memory_order_seq_cst) #define ma_atomic_store_ptr(dst, src) ma_atomic_store_explicit_ptr((volatile void**)dst, (void*)src, ma_atomic_memory_order_seq_cst) #define ma_atomic_load_ptr(ptr) ma_atomic_load_explicit_ptr((volatile void**)ptr, ma_atomic_memory_order_seq_cst) #define ma_atomic_exchange_ptr(dst, src) ma_atomic_exchange_explicit_ptr((volatile void**)dst, (void*)src, ma_atomic_memory_order_seq_cst) #define ma_atomic_compare_exchange_strong_ptr(dst, expected, desired) ma_atomic_compare_exchange_strong_explicit_ptr((volatile void**)dst, (void**)expected, (void*)desired, ma_atomic_memory_order_seq_cst, ma_atomic_memory_order_seq_cst) #define ma_atomic_compare_exchange_weak_ptr(dst, expected, desired) ma_atomic_compare_exchange_weak_explicit_ptr((volatile void**)dst, (void**)expected, (void*)desired, ma_atomic_memory_order_seq_cst, ma_atomic_memory_order_seq_cst) #define ma_atomic_test_and_set_8( ptr) ma_atomic_test_and_set_explicit_8( ptr, ma_atomic_memory_order_seq_cst) #define ma_atomic_test_and_set_16(ptr) ma_atomic_test_and_set_explicit_16(ptr, ma_atomic_memory_order_seq_cst) #define ma_atomic_test_and_set_32(ptr) ma_atomic_test_and_set_explicit_32(ptr, ma_atomic_memory_order_seq_cst) #define ma_atomic_test_and_set_64(ptr) ma_atomic_test_and_set_explicit_64(ptr, ma_atomic_memory_order_seq_cst) #define ma_atomic_clear_8( ptr) ma_atomic_clear_explicit_8( ptr, ma_atomic_memory_order_seq_cst) #define ma_atomic_clear_16(ptr) ma_atomic_clear_explicit_16(ptr, ma_atomic_memory_order_seq_cst) #define ma_atomic_clear_32(ptr) ma_atomic_clear_explicit_32(ptr, ma_atomic_memory_order_seq_cst) #define ma_atomic_clear_64(ptr) ma_atomic_clear_explicit_64(ptr, ma_atomic_memory_order_seq_cst) #define ma_atomic_store_8( dst, src) ma_atomic_store_explicit_8( dst, src, ma_atomic_memory_order_seq_cst) #define ma_atomic_store_16(dst, src) ma_atomic_store_explicit_16(dst, src, ma_atomic_memory_order_seq_cst) #define ma_atomic_store_32(dst, src) ma_atomic_store_explicit_32(dst, src, ma_atomic_memory_order_seq_cst) #define ma_atomic_store_64(dst, src) ma_atomic_store_explicit_64(dst, src, ma_atomic_memory_order_seq_cst) #define ma_atomic_load_8( ptr) ma_atomic_load_explicit_8( ptr, ma_atomic_memory_order_seq_cst) #define ma_atomic_load_16(ptr) ma_atomic_load_explicit_16(ptr, ma_atomic_memory_order_seq_cst) #define ma_atomic_load_32(ptr) ma_atomic_load_explicit_32(ptr, ma_atomic_memory_order_seq_cst) #define ma_atomic_load_64(ptr) ma_atomic_load_explicit_64(ptr, ma_atomic_memory_order_seq_cst) #define ma_atomic_exchange_8( dst, src) ma_atomic_exchange_explicit_8( dst, src, ma_atomic_memory_order_seq_cst) #define ma_atomic_exchange_16(dst, src) ma_atomic_exchange_explicit_16(dst, src, ma_atomic_memory_order_seq_cst) #define ma_atomic_exchange_32(dst, src) ma_atomic_exchange_explicit_32(dst, src, ma_atomic_memory_order_seq_cst) #define ma_atomic_exchange_64(dst, src) ma_atomic_exchange_explicit_64(dst, src, ma_atomic_memory_order_seq_cst) #define ma_atomic_compare_exchange_strong_8( dst, expected, desired) ma_atomic_compare_exchange_strong_explicit_8( dst, expected, desired, ma_atomic_memory_order_seq_cst, ma_atomic_memory_order_seq_cst) #define ma_atomic_compare_exchange_strong_16(dst, expected, desired) ma_atomic_compare_exchange_strong_explicit_16(dst, expected, desired, ma_atomic_memory_order_seq_cst, ma_atomic_memory_order_seq_cst) #define ma_atomic_compare_exchange_strong_32(dst, expected, desired) ma_atomic_compare_exchange_strong_explicit_32(dst, expected, desired, ma_atomic_memory_order_seq_cst, ma_atomic_memory_order_seq_cst) #define ma_atomic_compare_exchange_strong_64(dst, expected, desired) ma_atomic_compare_exchange_strong_explicit_64(dst, expected, desired, ma_atomic_memory_order_seq_cst, ma_atomic_memory_order_seq_cst) #define ma_atomic_compare_exchange_weak_8( dst, expected, desired) ma_atomic_compare_exchange_weak_explicit_8( dst, expected, desired, ma_atomic_memory_order_seq_cst, ma_atomic_memory_order_seq_cst) #define ma_atomic_compare_exchange_weak_16( dst, expected, desired) ma_atomic_compare_exchange_weak_explicit_16(dst, expected, desired, ma_atomic_memory_order_seq_cst, ma_atomic_memory_order_seq_cst) #define ma_atomic_compare_exchange_weak_32( dst, expected, desired) ma_atomic_compare_exchange_weak_explicit_32(dst, expected, desired, ma_atomic_memory_order_seq_cst, ma_atomic_memory_order_seq_cst) #define ma_atomic_compare_exchange_weak_64( dst, expected, desired) ma_atomic_compare_exchange_weak_explicit_64(dst, expected, desired, ma_atomic_memory_order_seq_cst, ma_atomic_memory_order_seq_cst) #define ma_atomic_fetch_add_8( dst, src) ma_atomic_fetch_add_explicit_8( dst, src, ma_atomic_memory_order_seq_cst) #define ma_atomic_fetch_add_16(dst, src) ma_atomic_fetch_add_explicit_16(dst, src, ma_atomic_memory_order_seq_cst) #define ma_atomic_fetch_add_32(dst, src) ma_atomic_fetch_add_explicit_32(dst, src, ma_atomic_memory_order_seq_cst) #define ma_atomic_fetch_add_64(dst, src) ma_atomic_fetch_add_explicit_64(dst, src, ma_atomic_memory_order_seq_cst) #define ma_atomic_fetch_sub_8( dst, src) ma_atomic_fetch_sub_explicit_8( dst, src, ma_atomic_memory_order_seq_cst) #define ma_atomic_fetch_sub_16(dst, src) ma_atomic_fetch_sub_explicit_16(dst, src, ma_atomic_memory_order_seq_cst) #define ma_atomic_fetch_sub_32(dst, src) ma_atomic_fetch_sub_explicit_32(dst, src, ma_atomic_memory_order_seq_cst) #define ma_atomic_fetch_sub_64(dst, src) ma_atomic_fetch_sub_explicit_64(dst, src, ma_atomic_memory_order_seq_cst) #define ma_atomic_fetch_or_8( dst, src) ma_atomic_fetch_or_explicit_8( dst, src, ma_atomic_memory_order_seq_cst) #define ma_atomic_fetch_or_16(dst, src) ma_atomic_fetch_or_explicit_16(dst, src, ma_atomic_memory_order_seq_cst) #define ma_atomic_fetch_or_32(dst, src) ma_atomic_fetch_or_explicit_32(dst, src, ma_atomic_memory_order_seq_cst) #define ma_atomic_fetch_or_64(dst, src) ma_atomic_fetch_or_explicit_64(dst, src, ma_atomic_memory_order_seq_cst) #define ma_atomic_fetch_xor_8( dst, src) ma_atomic_fetch_xor_explicit_8( dst, src, ma_atomic_memory_order_seq_cst) #define ma_atomic_fetch_xor_16(dst, src) ma_atomic_fetch_xor_explicit_16(dst, src, ma_atomic_memory_order_seq_cst) #define ma_atomic_fetch_xor_32(dst, src) ma_atomic_fetch_xor_explicit_32(dst, src, ma_atomic_memory_order_seq_cst) #define ma_atomic_fetch_xor_64(dst, src) ma_atomic_fetch_xor_explicit_64(dst, src, ma_atomic_memory_order_seq_cst) #define ma_atomic_fetch_and_8( dst, src) ma_atomic_fetch_and_explicit_8 (dst, src, ma_atomic_memory_order_seq_cst) #define ma_atomic_fetch_and_16(dst, src) ma_atomic_fetch_and_explicit_16(dst, src, ma_atomic_memory_order_seq_cst) #define ma_atomic_fetch_and_32(dst, src) ma_atomic_fetch_and_explicit_32(dst, src, ma_atomic_memory_order_seq_cst) #define ma_atomic_fetch_and_64(dst, src) ma_atomic_fetch_and_explicit_64(dst, src, ma_atomic_memory_order_seq_cst) #define ma_atomic_test_and_set_explicit_i8( ptr, order) (ma_int8 )ma_atomic_test_and_set_explicit_8( (ma_uint8* )ptr, order) #define ma_atomic_test_and_set_explicit_i16(ptr, order) (ma_int16)ma_atomic_test_and_set_explicit_16((ma_uint16*)ptr, order) #define ma_atomic_test_and_set_explicit_i32(ptr, order) (ma_int32)ma_atomic_test_and_set_explicit_32((ma_uint32*)ptr, order) #define ma_atomic_test_and_set_explicit_i64(ptr, order) (ma_int64)ma_atomic_test_and_set_explicit_64((ma_uint64*)ptr, order) #define ma_atomic_clear_explicit_i8( ptr, order) ma_atomic_clear_explicit_8( (ma_uint8* )ptr, order) #define ma_atomic_clear_explicit_i16(ptr, order) ma_atomic_clear_explicit_16((ma_uint16*)ptr, order) #define ma_atomic_clear_explicit_i32(ptr, order) ma_atomic_clear_explicit_32((ma_uint32*)ptr, order) #define ma_atomic_clear_explicit_i64(ptr, order) ma_atomic_clear_explicit_64((ma_uint64*)ptr, order) #define ma_atomic_store_explicit_i8( dst, src, order) ma_atomic_store_explicit_8( (ma_uint8* )dst, (ma_uint8 )src, order) #define ma_atomic_store_explicit_i16(dst, src, order) ma_atomic_store_explicit_16((ma_uint16*)dst, (ma_uint16)src, order) #define ma_atomic_store_explicit_i32(dst, src, order) ma_atomic_store_explicit_32((ma_uint32*)dst, (ma_uint32)src, order) #define ma_atomic_store_explicit_i64(dst, src, order) ma_atomic_store_explicit_64((ma_uint64*)dst, (ma_uint64)src, order) #define ma_atomic_load_explicit_i8( ptr, order) (ma_int8 )ma_atomic_load_explicit_8( (ma_uint8* )ptr, order) #define ma_atomic_load_explicit_i16(ptr, order) (ma_int16)ma_atomic_load_explicit_16((ma_uint16*)ptr, order) #define ma_atomic_load_explicit_i32(ptr, order) (ma_int32)ma_atomic_load_explicit_32((ma_uint32*)ptr, order) #define ma_atomic_load_explicit_i64(ptr, order) (ma_int64)ma_atomic_load_explicit_64((ma_uint64*)ptr, order) #define ma_atomic_exchange_explicit_i8( dst, src, order) (ma_int8 )ma_atomic_exchange_explicit_8 ((ma_uint8* )dst, (ma_uint8 )src, order) #define ma_atomic_exchange_explicit_i16(dst, src, order) (ma_int16)ma_atomic_exchange_explicit_16((ma_uint16*)dst, (ma_uint16)src, order) #define ma_atomic_exchange_explicit_i32(dst, src, order) (ma_int32)ma_atomic_exchange_explicit_32((ma_uint32*)dst, (ma_uint32)src, order) #define ma_atomic_exchange_explicit_i64(dst, src, order) (ma_int64)ma_atomic_exchange_explicit_64((ma_uint64*)dst, (ma_uint64)src, order) #define ma_atomic_compare_exchange_strong_explicit_i8( dst, expected, desired, successOrder, failureOrder) ma_atomic_compare_exchange_strong_explicit_8( (ma_uint8* )dst, (ma_uint8* )expected, (ma_uint8 )desired, successOrder, failureOrder) #define ma_atomic_compare_exchange_strong_explicit_i16(dst, expected, desired, successOrder, failureOrder) ma_atomic_compare_exchange_strong_explicit_16((ma_uint16*)dst, (ma_uint16*)expected, (ma_uint16)desired, successOrder, failureOrder) #define ma_atomic_compare_exchange_strong_explicit_i32(dst, expected, desired, successOrder, failureOrder) ma_atomic_compare_exchange_strong_explicit_32((ma_uint32*)dst, (ma_uint32*)expected, (ma_uint32)desired, successOrder, failureOrder) #define ma_atomic_compare_exchange_strong_explicit_i64(dst, expected, desired, successOrder, failureOrder) ma_atomic_compare_exchange_strong_explicit_64((ma_uint64*)dst, (ma_uint64*)expected, (ma_uint64)desired, successOrder, failureOrder) #define ma_atomic_compare_exchange_weak_explicit_i8( dst, expected, desired, successOrder, failureOrder) ma_atomic_compare_exchange_weak_explicit_8( (ma_uint8* )dst, (ma_uint8* )expected, (ma_uint8 )desired, successOrder, failureOrder) #define ma_atomic_compare_exchange_weak_explicit_i16(dst, expected, desired, successOrder, failureOrder) ma_atomic_compare_exchange_weak_explicit_16((ma_uint16*)dst, (ma_uint16*)expected, (ma_uint16)desired, successOrder, failureOrder) #define ma_atomic_compare_exchange_weak_explicit_i32(dst, expected, desired, successOrder, failureOrder) ma_atomic_compare_exchange_weak_explicit_32((ma_uint32*)dst, (ma_uint32*)expected, (ma_uint32)desired, successOrder, failureOrder) #define ma_atomic_compare_exchange_weak_explicit_i64(dst, expected, desired, successOrder, failureOrder) ma_atomic_compare_exchange_weak_explicit_64((ma_uint64*)dst, (ma_uint64*)expected, (ma_uint64)desired, successOrder, failureOrder) #define ma_atomic_fetch_add_explicit_i8( dst, src, order) (ma_int8 )ma_atomic_fetch_add_explicit_8( (ma_uint8* )dst, (ma_uint8 )src, order) #define ma_atomic_fetch_add_explicit_i16(dst, src, order) (ma_int16)ma_atomic_fetch_add_explicit_16((ma_uint16*)dst, (ma_uint16)src, order) #define ma_atomic_fetch_add_explicit_i32(dst, src, order) (ma_int32)ma_atomic_fetch_add_explicit_32((ma_uint32*)dst, (ma_uint32)src, order) #define ma_atomic_fetch_add_explicit_i64(dst, src, order) (ma_int64)ma_atomic_fetch_add_explicit_64((ma_uint64*)dst, (ma_uint64)src, order) #define ma_atomic_fetch_sub_explicit_i8( dst, src, order) (ma_int8 )ma_atomic_fetch_sub_explicit_8( (ma_uint8* )dst, (ma_uint8 )src, order) #define ma_atomic_fetch_sub_explicit_i16(dst, src, order) (ma_int16)ma_atomic_fetch_sub_explicit_16((ma_uint16*)dst, (ma_uint16)src, order) #define ma_atomic_fetch_sub_explicit_i32(dst, src, order) (ma_int32)ma_atomic_fetch_sub_explicit_32((ma_uint32*)dst, (ma_uint32)src, order) #define ma_atomic_fetch_sub_explicit_i64(dst, src, order) (ma_int64)ma_atomic_fetch_sub_explicit_64((ma_uint64*)dst, (ma_uint64)src, order) #define ma_atomic_fetch_or_explicit_i8( dst, src, order) (ma_int8 )ma_atomic_fetch_or_explicit_8( (ma_uint8* )dst, (ma_uint8 )src, order) #define ma_atomic_fetch_or_explicit_i16(dst, src, order) (ma_int16)ma_atomic_fetch_or_explicit_16((ma_uint16*)dst, (ma_uint16)src, order) #define ma_atomic_fetch_or_explicit_i32(dst, src, order) (ma_int32)ma_atomic_fetch_or_explicit_32((ma_uint32*)dst, (ma_uint32)src, order) #define ma_atomic_fetch_or_explicit_i64(dst, src, order) (ma_int64)ma_atomic_fetch_or_explicit_64((ma_uint64*)dst, (ma_uint64)src, order) #define ma_atomic_fetch_xor_explicit_i8( dst, src, order) (ma_int8 )ma_atomic_fetch_xor_explicit_8( (ma_uint8* )dst, (ma_uint8 )src, order) #define ma_atomic_fetch_xor_explicit_i16(dst, src, order) (ma_int16)ma_atomic_fetch_xor_explicit_16((ma_uint16*)dst, (ma_uint16)src, order) #define ma_atomic_fetch_xor_explicit_i32(dst, src, order) (ma_int32)ma_atomic_fetch_xor_explicit_32((ma_uint32*)dst, (ma_uint32)src, order) #define ma_atomic_fetch_xor_explicit_i64(dst, src, order) (ma_int64)ma_atomic_fetch_xor_explicit_64((ma_uint64*)dst, (ma_uint64)src, order) #define ma_atomic_fetch_and_explicit_i8( dst, src, order) (ma_int8 )ma_atomic_fetch_and_explicit_8( (ma_uint8* )dst, (ma_uint8 )src, order) #define ma_atomic_fetch_and_explicit_i16(dst, src, order) (ma_int16)ma_atomic_fetch_and_explicit_16((ma_uint16*)dst, (ma_uint16)src, order) #define ma_atomic_fetch_and_explicit_i32(dst, src, order) (ma_int32)ma_atomic_fetch_and_explicit_32((ma_uint32*)dst, (ma_uint32)src, order) #define ma_atomic_fetch_and_explicit_i64(dst, src, order) (ma_int64)ma_atomic_fetch_and_explicit_64((ma_uint64*)dst, (ma_uint64)src, order) #define ma_atomic_test_and_set_i8( ptr) ma_atomic_test_and_set_explicit_i8( ptr, ma_atomic_memory_order_seq_cst) #define ma_atomic_test_and_set_i16(ptr) ma_atomic_test_and_set_explicit_i16(ptr, ma_atomic_memory_order_seq_cst) #define ma_atomic_test_and_set_i32(ptr) ma_atomic_test_and_set_explicit_i32(ptr, ma_atomic_memory_order_seq_cst) #define ma_atomic_test_and_set_i64(ptr) ma_atomic_test_and_set_explicit_i64(ptr, ma_atomic_memory_order_seq_cst) #define ma_atomic_clear_i8( ptr) ma_atomic_clear_explicit_i8( ptr, ma_atomic_memory_order_seq_cst) #define ma_atomic_clear_i16(ptr) ma_atomic_clear_explicit_i16(ptr, ma_atomic_memory_order_seq_cst) #define ma_atomic_clear_i32(ptr) ma_atomic_clear_explicit_i32(ptr, ma_atomic_memory_order_seq_cst) #define ma_atomic_clear_i64(ptr) ma_atomic_clear_explicit_i64(ptr, ma_atomic_memory_order_seq_cst) #define ma_atomic_store_i8( dst, src) ma_atomic_store_explicit_i8( dst, src, ma_atomic_memory_order_seq_cst) #define ma_atomic_store_i16(dst, src) ma_atomic_store_explicit_i16(dst, src, ma_atomic_memory_order_seq_cst) #define ma_atomic_store_i32(dst, src) ma_atomic_store_explicit_i32(dst, src, ma_atomic_memory_order_seq_cst) #define ma_atomic_store_i64(dst, src) ma_atomic_store_explicit_i64(dst, src, ma_atomic_memory_order_seq_cst) #define ma_atomic_load_i8( ptr) ma_atomic_load_explicit_i8( ptr, ma_atomic_memory_order_seq_cst) #define ma_atomic_load_i16(ptr) ma_atomic_load_explicit_i16(ptr, ma_atomic_memory_order_seq_cst) #define ma_atomic_load_i32(ptr) ma_atomic_load_explicit_i32(ptr, ma_atomic_memory_order_seq_cst) #define ma_atomic_load_i64(ptr) ma_atomic_load_explicit_i64(ptr, ma_atomic_memory_order_seq_cst) #define ma_atomic_exchange_i8( dst, src) ma_atomic_exchange_explicit_i8( dst, src, ma_atomic_memory_order_seq_cst) #define ma_atomic_exchange_i16(dst, src) ma_atomic_exchange_explicit_i16(dst, src, ma_atomic_memory_order_seq_cst) #define ma_atomic_exchange_i32(dst, src) ma_atomic_exchange_explicit_i32(dst, src, ma_atomic_memory_order_seq_cst) #define ma_atomic_exchange_i64(dst, src) ma_atomic_exchange_explicit_i64(dst, src, ma_atomic_memory_order_seq_cst) #define ma_atomic_compare_exchange_strong_i8( dst, expected, desired) ma_atomic_compare_exchange_strong_explicit_i8( dst, expected, desired, ma_atomic_memory_order_seq_cst, ma_atomic_memory_order_seq_cst) #define ma_atomic_compare_exchange_strong_i16(dst, expected, desired) ma_atomic_compare_exchange_strong_explicit_i16(dst, expected, desired, ma_atomic_memory_order_seq_cst, ma_atomic_memory_order_seq_cst) #define ma_atomic_compare_exchange_strong_i32(dst, expected, desired) ma_atomic_compare_exchange_strong_explicit_i32(dst, expected, desired, ma_atomic_memory_order_seq_cst, ma_atomic_memory_order_seq_cst) #define ma_atomic_compare_exchange_strong_i64(dst, expected, desired) ma_atomic_compare_exchange_strong_explicit_i64(dst, expected, desired, ma_atomic_memory_order_seq_cst, ma_atomic_memory_order_seq_cst) #define ma_atomic_compare_exchange_weak_i8( dst, expected, desired) ma_atomic_compare_exchange_weak_explicit_i8( dst, expected, desired, ma_atomic_memory_order_seq_cst, ma_atomic_memory_order_seq_cst) #define ma_atomic_compare_exchange_weak_i16(dst, expected, desired) ma_atomic_compare_exchange_weak_explicit_i16(dst, expected, desired, ma_atomic_memory_order_seq_cst, ma_atomic_memory_order_seq_cst) #define ma_atomic_compare_exchange_weak_i32(dst, expected, desired) ma_atomic_compare_exchange_weak_explicit_i32(dst, expected, desired, ma_atomic_memory_order_seq_cst, ma_atomic_memory_order_seq_cst) #define ma_atomic_compare_exchange_weak_i64(dst, expected, desired) ma_atomic_compare_exchange_weak_explicit_i64(dst, expected, desired, ma_atomic_memory_order_seq_cst, ma_atomic_memory_order_seq_cst) #define ma_atomic_fetch_add_i8( dst, src) ma_atomic_fetch_add_explicit_i8( dst, src, ma_atomic_memory_order_seq_cst) #define ma_atomic_fetch_add_i16(dst, src) ma_atomic_fetch_add_explicit_i16(dst, src, ma_atomic_memory_order_seq_cst) #define ma_atomic_fetch_add_i32(dst, src) ma_atomic_fetch_add_explicit_i32(dst, src, ma_atomic_memory_order_seq_cst) #define ma_atomic_fetch_add_i64(dst, src) ma_atomic_fetch_add_explicit_i64(dst, src, ma_atomic_memory_order_seq_cst) #define ma_atomic_fetch_sub_i8( dst, src) ma_atomic_fetch_sub_explicit_i8( dst, src, ma_atomic_memory_order_seq_cst) #define ma_atomic_fetch_sub_i16(dst, src) ma_atomic_fetch_sub_explicit_i16(dst, src, ma_atomic_memory_order_seq_cst) #define ma_atomic_fetch_sub_i32(dst, src) ma_atomic_fetch_sub_explicit_i32(dst, src, ma_atomic_memory_order_seq_cst) #define ma_atomic_fetch_sub_i64(dst, src) ma_atomic_fetch_sub_explicit_i64(dst, src, ma_atomic_memory_order_seq_cst) #define ma_atomic_fetch_or_i8( dst, src) ma_atomic_fetch_or_explicit_i8( dst, src, ma_atomic_memory_order_seq_cst) #define ma_atomic_fetch_or_i16(dst, src) ma_atomic_fetch_or_explicit_i16(dst, src, ma_atomic_memory_order_seq_cst) #define ma_atomic_fetch_or_i32(dst, src) ma_atomic_fetch_or_explicit_i32(dst, src, ma_atomic_memory_order_seq_cst) #define ma_atomic_fetch_or_i64(dst, src) ma_atomic_fetch_or_explicit_i64(dst, src, ma_atomic_memory_order_seq_cst) #define ma_atomic_fetch_xor_i8( dst, src) ma_atomic_fetch_xor_explicit_i8( dst, src, ma_atomic_memory_order_seq_cst) #define ma_atomic_fetch_xor_i16(dst, src) ma_atomic_fetch_xor_explicit_i16(dst, src, ma_atomic_memory_order_seq_cst) #define ma_atomic_fetch_xor_i32(dst, src) ma_atomic_fetch_xor_explicit_i32(dst, src, ma_atomic_memory_order_seq_cst) #define ma_atomic_fetch_xor_i64(dst, src) ma_atomic_fetch_xor_explicit_i64(dst, src, ma_atomic_memory_order_seq_cst) #define ma_atomic_fetch_and_i8( dst, src) ma_atomic_fetch_and_explicit_i8( dst, src, ma_atomic_memory_order_seq_cst) #define ma_atomic_fetch_and_i16(dst, src) ma_atomic_fetch_and_explicit_i16(dst, src, ma_atomic_memory_order_seq_cst) #define ma_atomic_fetch_and_i32(dst, src) ma_atomic_fetch_and_explicit_i32(dst, src, ma_atomic_memory_order_seq_cst) #define ma_atomic_fetch_and_i64(dst, src) ma_atomic_fetch_and_explicit_i64(dst, src, ma_atomic_memory_order_seq_cst) #define ma_atomic_compare_and_swap_i8( dst, expected, dedsired) (ma_int8 )ma_atomic_compare_and_swap_8( (ma_uint8* )dst, (ma_uint8 )expected, (ma_uint8 )dedsired) #define ma_atomic_compare_and_swap_i16(dst, expected, dedsired) (ma_int16)ma_atomic_compare_and_swap_16((ma_uint16*)dst, (ma_uint16)expected, (ma_uint16)dedsired) #define ma_atomic_compare_and_swap_i32(dst, expected, dedsired) (ma_int32)ma_atomic_compare_and_swap_32((ma_uint32*)dst, (ma_uint32)expected, (ma_uint32)dedsired) #define ma_atomic_compare_and_swap_i64(dst, expected, dedsired) (ma_int64)ma_atomic_compare_and_swap_64((ma_uint64*)dst, (ma_uint64)expected, (ma_uint64)dedsired) typedef union { ma_uint32 i; float f; } ma_atomic_if32; typedef union { ma_uint64 i; double f; } ma_atomic_if64; #define ma_atomic_clear_explicit_f32(ptr, order) ma_atomic_clear_explicit_32((ma_uint32*)ptr, order) #define ma_atomic_clear_explicit_f64(ptr, order) ma_atomic_clear_explicit_64((ma_uint64*)ptr, order) static MA_INLINE void ma_atomic_store_explicit_f32(volatile float* dst, float src, ma_atomic_memory_order order) { ma_atomic_if32 x; x.f = src; ma_atomic_store_explicit_32((volatile ma_uint32*)dst, x.i, order); } static MA_INLINE void ma_atomic_store_explicit_f64(volatile double* dst, double src, ma_atomic_memory_order order) { ma_atomic_if64 x; x.f = src; ma_atomic_store_explicit_64((volatile ma_uint64*)dst, x.i, order); } static MA_INLINE float ma_atomic_load_explicit_f32(volatile const float* ptr, ma_atomic_memory_order order) { ma_atomic_if32 r; r.i = ma_atomic_load_explicit_32((volatile const ma_uint32*)ptr, order); return r.f; } static MA_INLINE double ma_atomic_load_explicit_f64(volatile const double* ptr, ma_atomic_memory_order order) { ma_atomic_if64 r; r.i = ma_atomic_load_explicit_64((volatile const ma_uint64*)ptr, order); return r.f; } static MA_INLINE float ma_atomic_exchange_explicit_f32(volatile float* dst, float src, ma_atomic_memory_order order) { ma_atomic_if32 r; ma_atomic_if32 x; x.f = src; r.i = ma_atomic_exchange_explicit_32((volatile ma_uint32*)dst, x.i, order); return r.f; } static MA_INLINE double ma_atomic_exchange_explicit_f64(volatile double* dst, double src, ma_atomic_memory_order order) { ma_atomic_if64 r; ma_atomic_if64 x; x.f = src; r.i = ma_atomic_exchange_explicit_64((volatile ma_uint64*)dst, x.i, order); return r.f; } static MA_INLINE ma_bool32 ma_atomic_compare_exchange_strong_explicit_f32(volatile float* dst, float* expected, float desired, ma_atomic_memory_order successOrder, ma_atomic_memory_order failureOrder) { ma_atomic_if32 d; d.f = desired; return ma_atomic_compare_exchange_strong_explicit_32((volatile ma_uint32*)dst, (ma_uint32*)expected, d.i, successOrder, failureOrder); } static MA_INLINE ma_bool32 ma_atomic_compare_exchange_strong_explicit_f64(volatile double* dst, double* expected, double desired, ma_atomic_memory_order successOrder, ma_atomic_memory_order failureOrder) { ma_atomic_if64 d; d.f = desired; return ma_atomic_compare_exchange_strong_explicit_64((volatile ma_uint64*)dst, (ma_uint64*)expected, d.i, successOrder, failureOrder); } static MA_INLINE ma_bool32 ma_atomic_compare_exchange_weak_explicit_f32(volatile float* dst, float* expected, float desired, ma_atomic_memory_order successOrder, ma_atomic_memory_order failureOrder) { ma_atomic_if32 d; d.f = desired; return ma_atomic_compare_exchange_weak_explicit_32((volatile ma_uint32*)dst, (ma_uint32*)expected, d.i, successOrder, failureOrder); } static MA_INLINE ma_bool32 ma_atomic_compare_exchange_weak_explicit_f64(volatile double* dst, double* expected, double desired, ma_atomic_memory_order successOrder, ma_atomic_memory_order failureOrder) { ma_atomic_if64 d; d.f = desired; return ma_atomic_compare_exchange_weak_explicit_64((volatile ma_uint64*)dst, (ma_uint64*)expected, d.i, successOrder, failureOrder); } static MA_INLINE float ma_atomic_fetch_add_explicit_f32(volatile float* dst, float src, ma_atomic_memory_order order) { ma_atomic_if32 r; ma_atomic_if32 x; x.f = src; r.i = ma_atomic_fetch_add_explicit_32((volatile ma_uint32*)dst, x.i, order); return r.f; } static MA_INLINE double ma_atomic_fetch_add_explicit_f64(volatile double* dst, double src, ma_atomic_memory_order order) { ma_atomic_if64 r; ma_atomic_if64 x; x.f = src; r.i = ma_atomic_fetch_add_explicit_64((volatile ma_uint64*)dst, x.i, order); return r.f; } static MA_INLINE float ma_atomic_fetch_sub_explicit_f32(volatile float* dst, float src, ma_atomic_memory_order order) { ma_atomic_if32 r; ma_atomic_if32 x; x.f = src; r.i = ma_atomic_fetch_sub_explicit_32((volatile ma_uint32*)dst, x.i, order); return r.f; } static MA_INLINE double ma_atomic_fetch_sub_explicit_f64(volatile double* dst, double src, ma_atomic_memory_order order) { ma_atomic_if64 r; ma_atomic_if64 x; x.f = src; r.i = ma_atomic_fetch_sub_explicit_64((volatile ma_uint64*)dst, x.i, order); return r.f; } static MA_INLINE float ma_atomic_fetch_or_explicit_f32(volatile float* dst, float src, ma_atomic_memory_order order) { ma_atomic_if32 r; ma_atomic_if32 x; x.f = src; r.i = ma_atomic_fetch_or_explicit_32((volatile ma_uint32*)dst, x.i, order); return r.f; } static MA_INLINE double ma_atomic_fetch_or_explicit_f64(volatile double* dst, double src, ma_atomic_memory_order order) { ma_atomic_if64 r; ma_atomic_if64 x; x.f = src; r.i = ma_atomic_fetch_or_explicit_64((volatile ma_uint64*)dst, x.i, order); return r.f; } static MA_INLINE float ma_atomic_fetch_xor_explicit_f32(volatile float* dst, float src, ma_atomic_memory_order order) { ma_atomic_if32 r; ma_atomic_if32 x; x.f = src; r.i = ma_atomic_fetch_xor_explicit_32((volatile ma_uint32*)dst, x.i, order); return r.f; } static MA_INLINE double ma_atomic_fetch_xor_explicit_f64(volatile double* dst, double src, ma_atomic_memory_order order) { ma_atomic_if64 r; ma_atomic_if64 x; x.f = src; r.i = ma_atomic_fetch_xor_explicit_64((volatile ma_uint64*)dst, x.i, order); return r.f; } static MA_INLINE float ma_atomic_fetch_and_explicit_f32(volatile float* dst, float src, ma_atomic_memory_order order) { ma_atomic_if32 r; ma_atomic_if32 x; x.f = src; r.i = ma_atomic_fetch_and_explicit_32((volatile ma_uint32*)dst, x.i, order); return r.f; } static MA_INLINE double ma_atomic_fetch_and_explicit_f64(volatile double* dst, double src, ma_atomic_memory_order order) { ma_atomic_if64 r; ma_atomic_if64 x; x.f = src; r.i = ma_atomic_fetch_and_explicit_64((volatile ma_uint64*)dst, x.i, order); return r.f; } #define ma_atomic_clear_f32(ptr) (float )ma_atomic_clear_explicit_f32(ptr, ma_atomic_memory_order_seq_cst) #define ma_atomic_clear_f64(ptr) (double)ma_atomic_clear_explicit_f64(ptr, ma_atomic_memory_order_seq_cst) #define ma_atomic_store_f32(dst, src) ma_atomic_store_explicit_f32(dst, src, ma_atomic_memory_order_seq_cst) #define ma_atomic_store_f64(dst, src) ma_atomic_store_explicit_f64(dst, src, ma_atomic_memory_order_seq_cst) #define ma_atomic_load_f32(ptr) (float )ma_atomic_load_explicit_f32(ptr, ma_atomic_memory_order_seq_cst) #define ma_atomic_load_f64(ptr) (double)ma_atomic_load_explicit_f64(ptr, ma_atomic_memory_order_seq_cst) #define ma_atomic_exchange_f32(dst, src) (float )ma_atomic_exchange_explicit_f32(dst, src, ma_atomic_memory_order_seq_cst) #define ma_atomic_exchange_f64(dst, src) (double)ma_atomic_exchange_explicit_f64(dst, src, ma_atomic_memory_order_seq_cst) #define ma_atomic_compare_exchange_strong_f32(dst, expected, desired) ma_atomic_compare_exchange_strong_explicit_f32(dst, expected, desired, ma_atomic_memory_order_seq_cst, ma_atomic_memory_order_seq_cst) #define ma_atomic_compare_exchange_strong_f64(dst, expected, desired) ma_atomic_compare_exchange_strong_explicit_f64(dst, expected, desired, ma_atomic_memory_order_seq_cst, ma_atomic_memory_order_seq_cst) #define ma_atomic_compare_exchange_weak_f32(dst, expected, desired) ma_atomic_compare_exchange_weak_explicit_f32(dst, expected, desired, ma_atomic_memory_order_seq_cst, ma_atomic_memory_order_seq_cst) #define ma_atomic_compare_exchange_weak_f64(dst, expected, desired) ma_atomic_compare_exchange_weak_explicit_f64(dst, expected, desired, ma_atomic_memory_order_seq_cst, ma_atomic_memory_order_seq_cst) #define ma_atomic_fetch_add_f32(dst, src) ma_atomic_fetch_add_explicit_f32(dst, src, ma_atomic_memory_order_seq_cst) #define ma_atomic_fetch_add_f64(dst, src) ma_atomic_fetch_add_explicit_f64(dst, src, ma_atomic_memory_order_seq_cst) #define ma_atomic_fetch_sub_f32(dst, src) ma_atomic_fetch_sub_explicit_f32(dst, src, ma_atomic_memory_order_seq_cst) #define ma_atomic_fetch_sub_f64(dst, src) ma_atomic_fetch_sub_explicit_f64(dst, src, ma_atomic_memory_order_seq_cst) #define ma_atomic_fetch_or_f32(dst, src) ma_atomic_fetch_or_explicit_f32(dst, src, ma_atomic_memory_order_seq_cst) #define ma_atomic_fetch_or_f64(dst, src) ma_atomic_fetch_or_explicit_f64(dst, src, ma_atomic_memory_order_seq_cst) #define ma_atomic_fetch_xor_f32(dst, src) ma_atomic_fetch_xor_explicit_f32(dst, src, ma_atomic_memory_order_seq_cst) #define ma_atomic_fetch_xor_f64(dst, src) ma_atomic_fetch_xor_explicit_f64(dst, src, ma_atomic_memory_order_seq_cst) #define ma_atomic_fetch_and_f32(dst, src) ma_atomic_fetch_and_explicit_f32(dst, src, ma_atomic_memory_order_seq_cst) #define ma_atomic_fetch_and_f64(dst, src) ma_atomic_fetch_and_explicit_f64(dst, src, ma_atomic_memory_order_seq_cst) static MA_INLINE float ma_atomic_compare_and_swap_f32(volatile float* dst, float expected, float desired) { ma_atomic_if32 r; ma_atomic_if32 e, d; e.f = expected; d.f = desired; r.i = ma_atomic_compare_and_swap_32((volatile ma_uint32*)dst, e.i, d.i); return r.f; } static MA_INLINE double ma_atomic_compare_and_swap_f64(volatile double* dst, double expected, double desired) { ma_atomic_if64 r; ma_atomic_if64 e, d; e.f = expected; d.f = desired; r.i = ma_atomic_compare_and_swap_64((volatile ma_uint64*)dst, e.i, d.i); return r.f; } typedef ma_atomic_flag ma_atomic_spinlock; static MA_INLINE void ma_atomic_spinlock_lock(volatile ma_atomic_spinlock* pSpinlock) { for (;;) { if (ma_atomic_flag_test_and_set_explicit(pSpinlock, ma_atomic_memory_order_acquire) == 0) { break; } while (c89atoimc_flag_load_explicit(pSpinlock, ma_atomic_memory_order_relaxed) == 1) { } } } static MA_INLINE void ma_atomic_spinlock_unlock(volatile ma_atomic_spinlock* pSpinlock) { ma_atomic_flag_clear_explicit(pSpinlock, ma_atomic_memory_order_release); } #if defined(__clang__) || (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))) #pragma GCC diagnostic pop #endif #if defined(__cplusplus) } #endif #endif /* ma_atomic.h end */ #define MA_ATOMIC_SAFE_TYPE_IMPL(c89TypeExtension, type) \ static MA_INLINE ma_##type ma_atomic_##type##_get(ma_atomic_##type* x) \ { \ return (ma_##type)ma_atomic_load_##c89TypeExtension(&x->value); \ } \ static MA_INLINE void ma_atomic_##type##_set(ma_atomic_##type* x, ma_##type value) \ { \ ma_atomic_store_##c89TypeExtension(&x->value, value); \ } \ static MA_INLINE ma_##type ma_atomic_##type##_exchange(ma_atomic_##type* x, ma_##type value) \ { \ return (ma_##type)ma_atomic_exchange_##c89TypeExtension(&x->value, value); \ } \ static MA_INLINE ma_bool32 ma_atomic_##type##_compare_exchange(ma_atomic_##type* x, ma_##type* expected, ma_##type desired) \ { \ return ma_atomic_compare_exchange_weak_##c89TypeExtension(&x->value, expected, desired); \ } \ static MA_INLINE ma_##type ma_atomic_##type##_fetch_add(ma_atomic_##type* x, ma_##type y) \ { \ return (ma_##type)ma_atomic_fetch_add_##c89TypeExtension(&x->value, y); \ } \ static MA_INLINE ma_##type ma_atomic_##type##_fetch_sub(ma_atomic_##type* x, ma_##type y) \ { \ return (ma_##type)ma_atomic_fetch_sub_##c89TypeExtension(&x->value, y); \ } \ static MA_INLINE ma_##type ma_atomic_##type##_fetch_or(ma_atomic_##type* x, ma_##type y) \ { \ return (ma_##type)ma_atomic_fetch_or_##c89TypeExtension(&x->value, y); \ } \ static MA_INLINE ma_##type ma_atomic_##type##_fetch_xor(ma_atomic_##type* x, ma_##type y) \ { \ return (ma_##type)ma_atomic_fetch_xor_##c89TypeExtension(&x->value, y); \ } \ static MA_INLINE ma_##type ma_atomic_##type##_fetch_and(ma_atomic_##type* x, ma_##type y) \ { \ return (ma_##type)ma_atomic_fetch_and_##c89TypeExtension(&x->value, y); \ } \ static MA_INLINE ma_##type ma_atomic_##type##_compare_and_swap(ma_atomic_##type* x, ma_##type expected, ma_##type desired) \ { \ return (ma_##type)ma_atomic_compare_and_swap_##c89TypeExtension(&x->value, expected, desired); \ } \ #define MA_ATOMIC_SAFE_TYPE_IMPL_PTR(type) \ static MA_INLINE ma_##type* ma_atomic_ptr_##type##_get(ma_atomic_ptr_##type* x) \ { \ return ma_atomic_load_ptr((void**)&x->value); \ } \ static MA_INLINE void ma_atomic_ptr_##type##_set(ma_atomic_ptr_##type* x, ma_##type* value) \ { \ ma_atomic_store_ptr((void**)&x->value, (void*)value); \ } \ static MA_INLINE ma_##type* ma_atomic_ptr_##type##_exchange(ma_atomic_ptr_##type* x, ma_##type* value) \ { \ return ma_atomic_exchange_ptr((void**)&x->value, (void*)value); \ } \ static MA_INLINE ma_bool32 ma_atomic_ptr_##type##_compare_exchange(ma_atomic_ptr_##type* x, ma_##type** expected, ma_##type* desired) \ { \ return ma_atomic_compare_exchange_weak_ptr((void**)&x->value, (void*)expected, (void*)desired); \ } \ static MA_INLINE ma_##type* ma_atomic_ptr_##type##_compare_and_swap(ma_atomic_ptr_##type* x, ma_##type* expected, ma_##type* desired) \ { \ return (ma_##type*)ma_atomic_compare_and_swap_ptr((void**)&x->value, (void*)expected, (void*)desired); \ } \ MA_ATOMIC_SAFE_TYPE_IMPL(32, uint32) MA_ATOMIC_SAFE_TYPE_IMPL(i32, int32) MA_ATOMIC_SAFE_TYPE_IMPL(64, uint64) MA_ATOMIC_SAFE_TYPE_IMPL(f32, float) MA_ATOMIC_SAFE_TYPE_IMPL(32, bool32) #if !defined(MA_NO_DEVICE_IO) MA_ATOMIC_SAFE_TYPE_IMPL(i32, device_state) #endif MA_API ma_uint64 ma_calculate_frame_count_after_resampling(ma_uint32 sampleRateOut, ma_uint32 sampleRateIn, ma_uint64 frameCountIn) { /* This is based on the calculation in ma_linear_resampler_get_expected_output_frame_count(). */ ma_uint64 outputFrameCount; ma_uint64 preliminaryInputFrameCountFromFrac; ma_uint64 preliminaryInputFrameCount; if (sampleRateIn == 0 || sampleRateOut == 0 || frameCountIn == 0) { return 0; } if (sampleRateOut == sampleRateIn) { return frameCountIn; } outputFrameCount = (frameCountIn * sampleRateOut) / sampleRateIn; preliminaryInputFrameCountFromFrac = (outputFrameCount * (sampleRateIn / sampleRateOut)) / sampleRateOut; preliminaryInputFrameCount = (outputFrameCount * (sampleRateIn % sampleRateOut)) + preliminaryInputFrameCountFromFrac; if (preliminaryInputFrameCount <= frameCountIn) { outputFrameCount += 1; } return outputFrameCount; } #ifndef MA_DATA_CONVERTER_STACK_BUFFER_SIZE #define MA_DATA_CONVERTER_STACK_BUFFER_SIZE 4096 #endif #if defined(MA_WIN32) static ma_result ma_result_from_GetLastError(DWORD error) { switch (error) { case ERROR_SUCCESS: return MA_SUCCESS; case ERROR_PATH_NOT_FOUND: return MA_DOES_NOT_EXIST; case ERROR_TOO_MANY_OPEN_FILES: return MA_TOO_MANY_OPEN_FILES; case ERROR_NOT_ENOUGH_MEMORY: return MA_OUT_OF_MEMORY; case ERROR_DISK_FULL: return MA_NO_SPACE; case ERROR_HANDLE_EOF: return MA_AT_END; case ERROR_NEGATIVE_SEEK: return MA_BAD_SEEK; case ERROR_INVALID_PARAMETER: return MA_INVALID_ARGS; case ERROR_ACCESS_DENIED: return MA_ACCESS_DENIED; case ERROR_SEM_TIMEOUT: return MA_TIMEOUT; case ERROR_FILE_NOT_FOUND: return MA_DOES_NOT_EXIST; default: break; } return MA_ERROR; } #endif /* MA_WIN32 */ /******************************************************************************* Threading *******************************************************************************/ static MA_INLINE ma_result ma_spinlock_lock_ex(volatile ma_spinlock* pSpinlock, ma_bool32 yield) { if (pSpinlock == NULL) { return MA_INVALID_ARGS; } for (;;) { if (ma_atomic_exchange_explicit_32(pSpinlock, 1, ma_atomic_memory_order_acquire) == 0) { break; } while (ma_atomic_load_explicit_32(pSpinlock, ma_atomic_memory_order_relaxed) == 1) { if (yield) { ma_yield(); } } } return MA_SUCCESS; } MA_API ma_result ma_spinlock_lock(volatile ma_spinlock* pSpinlock) { return ma_spinlock_lock_ex(pSpinlock, MA_TRUE); } MA_API ma_result ma_spinlock_lock_noyield(volatile ma_spinlock* pSpinlock) { return ma_spinlock_lock_ex(pSpinlock, MA_FALSE); } MA_API ma_result ma_spinlock_unlock(volatile ma_spinlock* pSpinlock) { if (pSpinlock == NULL) { return MA_INVALID_ARGS; } ma_atomic_store_explicit_32(pSpinlock, 0, ma_atomic_memory_order_release); return MA_SUCCESS; } #ifndef MA_NO_THREADING #if defined(MA_POSIX) #define MA_THREADCALL typedef void* ma_thread_result; #elif defined(MA_WIN32) #define MA_THREADCALL WINAPI typedef unsigned long ma_thread_result; #endif typedef ma_thread_result (MA_THREADCALL * ma_thread_entry_proc)(void* pData); #ifdef MA_POSIX static ma_result ma_thread_create__posix(ma_thread* pThread, ma_thread_priority priority, size_t stackSize, ma_thread_entry_proc entryProc, void* pData) { int result; pthread_attr_t* pAttr = NULL; #if !defined(__EMSCRIPTEN__) /* Try setting the thread priority. It's not critical if anything fails here. */ pthread_attr_t attr; if (pthread_attr_init(&attr) == 0) { int scheduler = -1; /* We successfully initialized our attributes object so we can assign the pointer so it's passed into pthread_create(). */ pAttr = &attr; /* We need to set the scheduler policy. Only do this if the OS supports pthread_attr_setschedpolicy() */ #if !defined(MA_BEOS) { if (priority == ma_thread_priority_idle) { #ifdef SCHED_IDLE if (pthread_attr_setschedpolicy(&attr, SCHED_IDLE) == 0) { scheduler = SCHED_IDLE; } #endif } else if (priority == ma_thread_priority_realtime) { #ifdef SCHED_FIFO if (pthread_attr_setschedpolicy(&attr, SCHED_FIFO) == 0) { scheduler = SCHED_FIFO; } #endif #ifdef MA_LINUX } else { scheduler = sched_getscheduler(0); #endif } } #endif if (stackSize > 0) { pthread_attr_setstacksize(&attr, stackSize); } if (scheduler != -1) { int priorityMin = sched_get_priority_min(scheduler); int priorityMax = sched_get_priority_max(scheduler); int priorityStep = (priorityMax - priorityMin) / 7; /* 7 = number of priorities supported by miniaudio. */ struct sched_param sched; if (pthread_attr_getschedparam(&attr, &sched) == 0) { if (priority == ma_thread_priority_idle) { sched.sched_priority = priorityMin; } else if (priority == ma_thread_priority_realtime) { sched.sched_priority = priorityMax; } else { sched.sched_priority += ((int)priority + 5) * priorityStep; /* +5 because the lowest priority is -5. */ if (sched.sched_priority < priorityMin) { sched.sched_priority = priorityMin; } if (sched.sched_priority > priorityMax) { sched.sched_priority = priorityMax; } } /* I'm not treating a failure of setting the priority as a critical error so not checking the return value here. */ pthread_attr_setschedparam(&attr, &sched); } } } #else /* It's the emscripten build. We'll have a few unused parameters. */ (void)priority; (void)stackSize; #endif result = pthread_create((pthread_t*)pThread, pAttr, entryProc, pData); /* The thread attributes object is no longer required. */ if (pAttr != NULL) { pthread_attr_destroy(pAttr); } if (result != 0) { return ma_result_from_errno(result); } return MA_SUCCESS; } static void ma_thread_wait__posix(ma_thread* pThread) { pthread_join((pthread_t)*pThread, NULL); } static ma_result ma_mutex_init__posix(ma_mutex* pMutex) { int result; if (pMutex == NULL) { return MA_INVALID_ARGS; } MA_ZERO_OBJECT(pMutex); result = pthread_mutex_init((pthread_mutex_t*)pMutex, NULL); if (result != 0) { return ma_result_from_errno(result); } return MA_SUCCESS; } static void ma_mutex_uninit__posix(ma_mutex* pMutex) { pthread_mutex_destroy((pthread_mutex_t*)pMutex); } static void ma_mutex_lock__posix(ma_mutex* pMutex) { pthread_mutex_lock((pthread_mutex_t*)pMutex); } static void ma_mutex_unlock__posix(ma_mutex* pMutex) { pthread_mutex_unlock((pthread_mutex_t*)pMutex); } static ma_result ma_event_init__posix(ma_event* pEvent) { int result; result = pthread_mutex_init((pthread_mutex_t*)&pEvent->lock, NULL); if (result != 0) { return ma_result_from_errno(result); } result = pthread_cond_init((pthread_cond_t*)&pEvent->cond, NULL); if (result != 0) { pthread_mutex_destroy((pthread_mutex_t*)&pEvent->lock); return ma_result_from_errno(result); } pEvent->value = 0; return MA_SUCCESS; } static void ma_event_uninit__posix(ma_event* pEvent) { pthread_cond_destroy((pthread_cond_t*)&pEvent->cond); pthread_mutex_destroy((pthread_mutex_t*)&pEvent->lock); } static ma_result ma_event_wait__posix(ma_event* pEvent) { pthread_mutex_lock((pthread_mutex_t*)&pEvent->lock); { while (pEvent->value == 0) { pthread_cond_wait((pthread_cond_t*)&pEvent->cond, (pthread_mutex_t*)&pEvent->lock); } pEvent->value = 0; /* Auto-reset. */ } pthread_mutex_unlock((pthread_mutex_t*)&pEvent->lock); return MA_SUCCESS; } static ma_result ma_event_signal__posix(ma_event* pEvent) { pthread_mutex_lock((pthread_mutex_t*)&pEvent->lock); { pEvent->value = 1; pthread_cond_signal((pthread_cond_t*)&pEvent->cond); } pthread_mutex_unlock((pthread_mutex_t*)&pEvent->lock); return MA_SUCCESS; } static ma_result ma_semaphore_init__posix(int initialValue, ma_semaphore* pSemaphore) { int result; if (pSemaphore == NULL) { return MA_INVALID_ARGS; } pSemaphore->value = initialValue; result = pthread_mutex_init((pthread_mutex_t*)&pSemaphore->lock, NULL); if (result != 0) { return ma_result_from_errno(result); /* Failed to create mutex. */ } result = pthread_cond_init((pthread_cond_t*)&pSemaphore->cond, NULL); if (result != 0) { pthread_mutex_destroy((pthread_mutex_t*)&pSemaphore->lock); return ma_result_from_errno(result); /* Failed to create condition variable. */ } return MA_SUCCESS; } static void ma_semaphore_uninit__posix(ma_semaphore* pSemaphore) { if (pSemaphore == NULL) { return; } pthread_cond_destroy((pthread_cond_t*)&pSemaphore->cond); pthread_mutex_destroy((pthread_mutex_t*)&pSemaphore->lock); } static ma_result ma_semaphore_wait__posix(ma_semaphore* pSemaphore) { if (pSemaphore == NULL) { return MA_INVALID_ARGS; } pthread_mutex_lock((pthread_mutex_t*)&pSemaphore->lock); { /* We need to wait on a condition variable before escaping. We can't return from this function until the semaphore has been signaled. */ while (pSemaphore->value == 0) { pthread_cond_wait((pthread_cond_t*)&pSemaphore->cond, (pthread_mutex_t*)&pSemaphore->lock); } pSemaphore->value -= 1; } pthread_mutex_unlock((pthread_mutex_t*)&pSemaphore->lock); return MA_SUCCESS; } static ma_result ma_semaphore_release__posix(ma_semaphore* pSemaphore) { if (pSemaphore == NULL) { return MA_INVALID_ARGS; } pthread_mutex_lock((pthread_mutex_t*)&pSemaphore->lock); { pSemaphore->value += 1; pthread_cond_signal((pthread_cond_t*)&pSemaphore->cond); } pthread_mutex_unlock((pthread_mutex_t*)&pSemaphore->lock); return MA_SUCCESS; } #elif defined(MA_WIN32) static int ma_thread_priority_to_win32(ma_thread_priority priority) { switch (priority) { case ma_thread_priority_idle: return THREAD_PRIORITY_IDLE; case ma_thread_priority_lowest: return THREAD_PRIORITY_LOWEST; case ma_thread_priority_low: return THREAD_PRIORITY_BELOW_NORMAL; case ma_thread_priority_normal: return THREAD_PRIORITY_NORMAL; case ma_thread_priority_high: return THREAD_PRIORITY_ABOVE_NORMAL; case ma_thread_priority_highest: return THREAD_PRIORITY_HIGHEST; case ma_thread_priority_realtime: return THREAD_PRIORITY_TIME_CRITICAL; default: return THREAD_PRIORITY_NORMAL; } } static ma_result ma_thread_create__win32(ma_thread* pThread, ma_thread_priority priority, size_t stackSize, ma_thread_entry_proc entryProc, void* pData) { DWORD threadID; /* Not used. Only used for passing into CreateThread() so it doesn't fail on Windows 98. */ *pThread = CreateThread(NULL, stackSize, entryProc, pData, 0, &threadID); if (*pThread == NULL) { return ma_result_from_GetLastError(GetLastError()); } SetThreadPriority((HANDLE)*pThread, ma_thread_priority_to_win32(priority)); return MA_SUCCESS; } static void ma_thread_wait__win32(ma_thread* pThread) { WaitForSingleObject((HANDLE)*pThread, INFINITE); CloseHandle((HANDLE)*pThread); } static ma_result ma_mutex_init__win32(ma_mutex* pMutex) { *pMutex = CreateEventA(NULL, FALSE, TRUE, NULL); if (*pMutex == NULL) { return ma_result_from_GetLastError(GetLastError()); } return MA_SUCCESS; } static void ma_mutex_uninit__win32(ma_mutex* pMutex) { CloseHandle((HANDLE)*pMutex); } static void ma_mutex_lock__win32(ma_mutex* pMutex) { WaitForSingleObject((HANDLE)*pMutex, INFINITE); } static void ma_mutex_unlock__win32(ma_mutex* pMutex) { SetEvent((HANDLE)*pMutex); } static ma_result ma_event_init__win32(ma_event* pEvent) { *pEvent = CreateEventA(NULL, FALSE, FALSE, NULL); if (*pEvent == NULL) { return ma_result_from_GetLastError(GetLastError()); } return MA_SUCCESS; } static void ma_event_uninit__win32(ma_event* pEvent) { CloseHandle((HANDLE)*pEvent); } static ma_result ma_event_wait__win32(ma_event* pEvent) { DWORD result = WaitForSingleObject((HANDLE)*pEvent, INFINITE); if (result == WAIT_OBJECT_0) { return MA_SUCCESS; } if (result == WAIT_TIMEOUT) { return MA_TIMEOUT; } return ma_result_from_GetLastError(GetLastError()); } static ma_result ma_event_signal__win32(ma_event* pEvent) { BOOL result = SetEvent((HANDLE)*pEvent); if (result == 0) { return ma_result_from_GetLastError(GetLastError()); } return MA_SUCCESS; } static ma_result ma_semaphore_init__win32(int initialValue, ma_semaphore* pSemaphore) { *pSemaphore = CreateSemaphoreW(NULL, (LONG)initialValue, LONG_MAX, NULL); if (*pSemaphore == NULL) { return ma_result_from_GetLastError(GetLastError()); } return MA_SUCCESS; } static void ma_semaphore_uninit__win32(ma_semaphore* pSemaphore) { CloseHandle((HANDLE)*pSemaphore); } static ma_result ma_semaphore_wait__win32(ma_semaphore* pSemaphore) { DWORD result = WaitForSingleObject((HANDLE)*pSemaphore, INFINITE); if (result == WAIT_OBJECT_0) { return MA_SUCCESS; } if (result == WAIT_TIMEOUT) { return MA_TIMEOUT; } return ma_result_from_GetLastError(GetLastError()); } static ma_result ma_semaphore_release__win32(ma_semaphore* pSemaphore) { BOOL result = ReleaseSemaphore((HANDLE)*pSemaphore, 1, NULL); if (result == 0) { return ma_result_from_GetLastError(GetLastError()); } return MA_SUCCESS; } #endif typedef struct { ma_thread_entry_proc entryProc; void* pData; ma_allocation_callbacks allocationCallbacks; } ma_thread_proxy_data; static ma_thread_result MA_THREADCALL ma_thread_entry_proxy(void* pData) { ma_thread_proxy_data* pProxyData = (ma_thread_proxy_data*)pData; ma_thread_entry_proc entryProc; void* pEntryProcData; ma_thread_result result; #if defined(MA_ON_THREAD_ENTRY) MA_ON_THREAD_ENTRY #endif entryProc = pProxyData->entryProc; pEntryProcData = pProxyData->pData; /* Free the proxy data before getting into the real thread entry proc. */ ma_free(pProxyData, &pProxyData->allocationCallbacks); result = entryProc(pEntryProcData); #if defined(MA_ON_THREAD_EXIT) MA_ON_THREAD_EXIT #endif return result; } static ma_result ma_thread_create(ma_thread* pThread, ma_thread_priority priority, size_t stackSize, ma_thread_entry_proc entryProc, void* pData, const ma_allocation_callbacks* pAllocationCallbacks) { ma_result result; ma_thread_proxy_data* pProxyData; if (pThread == NULL || entryProc == NULL) { return MA_INVALID_ARGS; } pProxyData = (ma_thread_proxy_data*)ma_malloc(sizeof(*pProxyData), pAllocationCallbacks); /* Will be freed by the proxy entry proc. */ if (pProxyData == NULL) { return MA_OUT_OF_MEMORY; } #if defined(MA_THREAD_DEFAULT_STACK_SIZE) if (stackSize == 0) { stackSize = MA_THREAD_DEFAULT_STACK_SIZE; } #endif pProxyData->entryProc = entryProc; pProxyData->pData = pData; ma_allocation_callbacks_init_copy(&pProxyData->allocationCallbacks, pAllocationCallbacks); #if defined(MA_POSIX) result = ma_thread_create__posix(pThread, priority, stackSize, ma_thread_entry_proxy, pProxyData); #elif defined(MA_WIN32) result = ma_thread_create__win32(pThread, priority, stackSize, ma_thread_entry_proxy, pProxyData); #endif if (result != MA_SUCCESS) { ma_free(pProxyData, pAllocationCallbacks); return result; } return MA_SUCCESS; } static void ma_thread_wait(ma_thread* pThread) { if (pThread == NULL) { return; } #if defined(MA_POSIX) ma_thread_wait__posix(pThread); #elif defined(MA_WIN32) ma_thread_wait__win32(pThread); #endif } MA_API ma_result ma_mutex_init(ma_mutex* pMutex) { if (pMutex == NULL) { MA_ASSERT(MA_FALSE); /* Fire an assert so the caller is aware of this bug. */ return MA_INVALID_ARGS; } #if defined(MA_POSIX) return ma_mutex_init__posix(pMutex); #elif defined(MA_WIN32) return ma_mutex_init__win32(pMutex); #endif } MA_API void ma_mutex_uninit(ma_mutex* pMutex) { if (pMutex == NULL) { return; } #if defined(MA_POSIX) ma_mutex_uninit__posix(pMutex); #elif defined(MA_WIN32) ma_mutex_uninit__win32(pMutex); #endif } MA_API void ma_mutex_lock(ma_mutex* pMutex) { if (pMutex == NULL) { MA_ASSERT(MA_FALSE); /* Fire an assert so the caller is aware of this bug. */ return; } #if defined(MA_POSIX) ma_mutex_lock__posix(pMutex); #elif defined(MA_WIN32) ma_mutex_lock__win32(pMutex); #endif } MA_API void ma_mutex_unlock(ma_mutex* pMutex) { if (pMutex == NULL) { MA_ASSERT(MA_FALSE); /* Fire an assert so the caller is aware of this bug. */ return; } #if defined(MA_POSIX) ma_mutex_unlock__posix(pMutex); #elif defined(MA_WIN32) ma_mutex_unlock__win32(pMutex); #endif } MA_API ma_result ma_event_init(ma_event* pEvent) { if (pEvent == NULL) { MA_ASSERT(MA_FALSE); /* Fire an assert so the caller is aware of this bug. */ return MA_INVALID_ARGS; } #if defined(MA_POSIX) return ma_event_init__posix(pEvent); #elif defined(MA_WIN32) return ma_event_init__win32(pEvent); #endif } #if 0 static ma_result ma_event_alloc_and_init(ma_event** ppEvent, ma_allocation_callbacks* pAllocationCallbacks) { ma_result result; ma_event* pEvent; if (ppEvent == NULL) { return MA_INVALID_ARGS; } *ppEvent = NULL; pEvent = ma_malloc(sizeof(*pEvent), pAllocationCallbacks); if (pEvent == NULL) { return MA_OUT_OF_MEMORY; } result = ma_event_init(pEvent); if (result != MA_SUCCESS) { ma_free(pEvent, pAllocationCallbacks); return result; } *ppEvent = pEvent; return result; } #endif MA_API void ma_event_uninit(ma_event* pEvent) { if (pEvent == NULL) { return; } #if defined(MA_POSIX) ma_event_uninit__posix(pEvent); #elif defined(MA_WIN32) ma_event_uninit__win32(pEvent); #endif } #if 0 static void ma_event_uninit_and_free(ma_event* pEvent, ma_allocation_callbacks* pAllocationCallbacks) { if (pEvent == NULL) { return; } ma_event_uninit(pEvent); ma_free(pEvent, pAllocationCallbacks); } #endif MA_API ma_result ma_event_wait(ma_event* pEvent) { if (pEvent == NULL) { MA_ASSERT(MA_FALSE); /* Fire an assert to the caller is aware of this bug. */ return MA_INVALID_ARGS; } #if defined(MA_POSIX) return ma_event_wait__posix(pEvent); #elif defined(MA_WIN32) return ma_event_wait__win32(pEvent); #endif } MA_API ma_result ma_event_signal(ma_event* pEvent) { if (pEvent == NULL) { MA_ASSERT(MA_FALSE); /* Fire an assert to the caller is aware of this bug. */ return MA_INVALID_ARGS; } #if defined(MA_POSIX) return ma_event_signal__posix(pEvent); #elif defined(MA_WIN32) return ma_event_signal__win32(pEvent); #endif } MA_API ma_result ma_semaphore_init(int initialValue, ma_semaphore* pSemaphore) { if (pSemaphore == NULL) { MA_ASSERT(MA_FALSE); /* Fire an assert so the caller is aware of this bug. */ return MA_INVALID_ARGS; } #if defined(MA_POSIX) return ma_semaphore_init__posix(initialValue, pSemaphore); #elif defined(MA_WIN32) return ma_semaphore_init__win32(initialValue, pSemaphore); #endif } MA_API void ma_semaphore_uninit(ma_semaphore* pSemaphore) { if (pSemaphore == NULL) { MA_ASSERT(MA_FALSE); /* Fire an assert so the caller is aware of this bug. */ return; } #if defined(MA_POSIX) ma_semaphore_uninit__posix(pSemaphore); #elif defined(MA_WIN32) ma_semaphore_uninit__win32(pSemaphore); #endif } MA_API ma_result ma_semaphore_wait(ma_semaphore* pSemaphore) { if (pSemaphore == NULL) { MA_ASSERT(MA_FALSE); /* Fire an assert so the caller is aware of this bug. */ return MA_INVALID_ARGS; } #if defined(MA_POSIX) return ma_semaphore_wait__posix(pSemaphore); #elif defined(MA_WIN32) return ma_semaphore_wait__win32(pSemaphore); #endif } MA_API ma_result ma_semaphore_release(ma_semaphore* pSemaphore) { if (pSemaphore == NULL) { MA_ASSERT(MA_FALSE); /* Fire an assert so the caller is aware of this bug. */ return MA_INVALID_ARGS; } #if defined(MA_POSIX) return ma_semaphore_release__posix(pSemaphore); #elif defined(MA_WIN32) return ma_semaphore_release__win32(pSemaphore); #endif } #else /* MA_NO_THREADING is set which means threading is disabled. Threading is required by some API families. If any of these are enabled we need to throw an error. */ #ifndef MA_NO_DEVICE_IO #error "MA_NO_THREADING cannot be used without MA_NO_DEVICE_IO"; #endif #endif /* MA_NO_THREADING */ #define MA_FENCE_COUNTER_MAX 0x7FFFFFFF MA_API ma_result ma_fence_init(ma_fence* pFence) { if (pFence == NULL) { return MA_INVALID_ARGS; } MA_ZERO_OBJECT(pFence); pFence->counter = 0; #ifndef MA_NO_THREADING { ma_result result; result = ma_event_init(&pFence->e); if (result != MA_SUCCESS) { return result; } } #endif return MA_SUCCESS; } MA_API void ma_fence_uninit(ma_fence* pFence) { if (pFence == NULL) { return; } #ifndef MA_NO_THREADING { ma_event_uninit(&pFence->e); } #endif MA_ZERO_OBJECT(pFence); } MA_API ma_result ma_fence_acquire(ma_fence* pFence) { if (pFence == NULL) { return MA_INVALID_ARGS; } for (;;) { ma_uint32 oldCounter = ma_atomic_load_32(&pFence->counter); ma_uint32 newCounter = oldCounter + 1; /* Make sure we're not about to exceed our maximum value. */ if (newCounter > MA_FENCE_COUNTER_MAX) { MA_ASSERT(MA_FALSE); return MA_OUT_OF_RANGE; } if (ma_atomic_compare_exchange_weak_32(&pFence->counter, &oldCounter, newCounter)) { return MA_SUCCESS; } else { if (oldCounter == MA_FENCE_COUNTER_MAX) { MA_ASSERT(MA_FALSE); return MA_OUT_OF_RANGE; /* The other thread took the last available slot. Abort. */ } } } /* Should never get here. */ /*return MA_SUCCESS;*/ } MA_API ma_result ma_fence_release(ma_fence* pFence) { if (pFence == NULL) { return MA_INVALID_ARGS; } for (;;) { ma_uint32 oldCounter = ma_atomic_load_32(&pFence->counter); ma_uint32 newCounter = oldCounter - 1; if (oldCounter == 0) { MA_ASSERT(MA_FALSE); return MA_INVALID_OPERATION; /* Acquire/release mismatch. */ } if (ma_atomic_compare_exchange_weak_32(&pFence->counter, &oldCounter, newCounter)) { #ifndef MA_NO_THREADING { if (newCounter == 0) { ma_event_signal(&pFence->e); /* <-- ma_fence_wait() will be waiting on this. */ } } #endif return MA_SUCCESS; } else { if (oldCounter == 0) { MA_ASSERT(MA_FALSE); return MA_INVALID_OPERATION; /* Another thread has taken the 0 slot. Acquire/release mismatch. */ } } } /* Should never get here. */ /*return MA_SUCCESS;*/ } MA_API ma_result ma_fence_wait(ma_fence* pFence) { if (pFence == NULL) { return MA_INVALID_ARGS; } for (;;) { ma_uint32 counter; counter = ma_atomic_load_32(&pFence->counter); if (counter == 0) { /* Counter has hit zero. By the time we get here some other thread may have acquired the fence again, but that is where the caller needs to take care with how they se the fence. */ return MA_SUCCESS; } /* Getting here means the counter is > 0. We'll need to wait for something to happen. */ #ifndef MA_NO_THREADING { ma_result result; result = ma_event_wait(&pFence->e); if (result != MA_SUCCESS) { return result; } } #endif } /* Should never get here. */ /*return MA_INVALID_OPERATION;*/ } MA_API ma_result ma_async_notification_signal(ma_async_notification* pNotification) { ma_async_notification_callbacks* pNotificationCallbacks = (ma_async_notification_callbacks*)pNotification; if (pNotification == NULL) { return MA_INVALID_ARGS; } if (pNotificationCallbacks->onSignal == NULL) { return MA_NOT_IMPLEMENTED; } pNotificationCallbacks->onSignal(pNotification); return MA_INVALID_ARGS; } static void ma_async_notification_poll__on_signal(ma_async_notification* pNotification) { ((ma_async_notification_poll*)pNotification)->signalled = MA_TRUE; } MA_API ma_result ma_async_notification_poll_init(ma_async_notification_poll* pNotificationPoll) { if (pNotificationPoll == NULL) { return MA_INVALID_ARGS; } pNotificationPoll->cb.onSignal = ma_async_notification_poll__on_signal; pNotificationPoll->signalled = MA_FALSE; return MA_SUCCESS; } MA_API ma_bool32 ma_async_notification_poll_is_signalled(const ma_async_notification_poll* pNotificationPoll) { if (pNotificationPoll == NULL) { return MA_FALSE; } return pNotificationPoll->signalled; } static void ma_async_notification_event__on_signal(ma_async_notification* pNotification) { ma_async_notification_event_signal((ma_async_notification_event*)pNotification); } MA_API ma_result ma_async_notification_event_init(ma_async_notification_event* pNotificationEvent) { if (pNotificationEvent == NULL) { return MA_INVALID_ARGS; } pNotificationEvent->cb.onSignal = ma_async_notification_event__on_signal; #ifndef MA_NO_THREADING { ma_result result; result = ma_event_init(&pNotificationEvent->e); if (result != MA_SUCCESS) { return result; } return MA_SUCCESS; } #else { return MA_NOT_IMPLEMENTED; /* Threading is disabled. */ } #endif } MA_API ma_result ma_async_notification_event_uninit(ma_async_notification_event* pNotificationEvent) { if (pNotificationEvent == NULL) { return MA_INVALID_ARGS; } #ifndef MA_NO_THREADING { ma_event_uninit(&pNotificationEvent->e); return MA_SUCCESS; } #else { return MA_NOT_IMPLEMENTED; /* Threading is disabled. */ } #endif } MA_API ma_result ma_async_notification_event_wait(ma_async_notification_event* pNotificationEvent) { if (pNotificationEvent == NULL) { return MA_INVALID_ARGS; } #ifndef MA_NO_THREADING { return ma_event_wait(&pNotificationEvent->e); } #else { return MA_NOT_IMPLEMENTED; /* Threading is disabled. */ } #endif } MA_API ma_result ma_async_notification_event_signal(ma_async_notification_event* pNotificationEvent) { if (pNotificationEvent == NULL) { return MA_INVALID_ARGS; } #ifndef MA_NO_THREADING { return ma_event_signal(&pNotificationEvent->e); } #else { return MA_NOT_IMPLEMENTED; /* Threading is disabled. */ } #endif } /************************************************************************************************************************************************************ Job Queue ************************************************************************************************************************************************************/ MA_API ma_slot_allocator_config ma_slot_allocator_config_init(ma_uint32 capacity) { ma_slot_allocator_config config; MA_ZERO_OBJECT(&config); config.capacity = capacity; return config; } static MA_INLINE ma_uint32 ma_slot_allocator_calculate_group_capacity(ma_uint32 slotCapacity) { ma_uint32 cap = slotCapacity / 32; if ((slotCapacity % 32) != 0) { cap += 1; } return cap; } static MA_INLINE ma_uint32 ma_slot_allocator_group_capacity(const ma_slot_allocator* pAllocator) { return ma_slot_allocator_calculate_group_capacity(pAllocator->capacity); } typedef struct { size_t sizeInBytes; size_t groupsOffset; size_t slotsOffset; } ma_slot_allocator_heap_layout; static ma_result ma_slot_allocator_get_heap_layout(const ma_slot_allocator_config* pConfig, ma_slot_allocator_heap_layout* pHeapLayout) { MA_ASSERT(pHeapLayout != NULL); MA_ZERO_OBJECT(pHeapLayout); if (pConfig == NULL) { return MA_INVALID_ARGS; } if (pConfig->capacity == 0) { return MA_INVALID_ARGS; } pHeapLayout->sizeInBytes = 0; /* Groups. */ pHeapLayout->groupsOffset = pHeapLayout->sizeInBytes; pHeapLayout->sizeInBytes += ma_align_64(ma_slot_allocator_calculate_group_capacity(pConfig->capacity) * sizeof(ma_slot_allocator_group)); /* Slots. */ pHeapLayout->slotsOffset = pHeapLayout->sizeInBytes; pHeapLayout->sizeInBytes += ma_align_64(pConfig->capacity * sizeof(ma_uint32)); return MA_SUCCESS; } MA_API ma_result ma_slot_allocator_get_heap_size(const ma_slot_allocator_config* pConfig, size_t* pHeapSizeInBytes) { ma_result result; ma_slot_allocator_heap_layout layout; if (pHeapSizeInBytes == NULL) { return MA_INVALID_ARGS; } *pHeapSizeInBytes = 0; result = ma_slot_allocator_get_heap_layout(pConfig, &layout); if (result != MA_SUCCESS) { return result; } *pHeapSizeInBytes = layout.sizeInBytes; return result; } MA_API ma_result ma_slot_allocator_init_preallocated(const ma_slot_allocator_config* pConfig, void* pHeap, ma_slot_allocator* pAllocator) { ma_result result; ma_slot_allocator_heap_layout heapLayout; if (pAllocator == NULL) { return MA_INVALID_ARGS; } MA_ZERO_OBJECT(pAllocator); if (pHeap == NULL) { return MA_INVALID_ARGS; } result = ma_slot_allocator_get_heap_layout(pConfig, &heapLayout); if (result != MA_SUCCESS) { return result; } pAllocator->_pHeap = pHeap; MA_ZERO_MEMORY(pHeap, heapLayout.sizeInBytes); pAllocator->pGroups = (ma_slot_allocator_group*)ma_offset_ptr(pHeap, heapLayout.groupsOffset); pAllocator->pSlots = (ma_uint32*)ma_offset_ptr(pHeap, heapLayout.slotsOffset); pAllocator->capacity = pConfig->capacity; return MA_SUCCESS; } MA_API ma_result ma_slot_allocator_init(const ma_slot_allocator_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_slot_allocator* pAllocator) { ma_result result; size_t heapSizeInBytes; void* pHeap; result = ma_slot_allocator_get_heap_size(pConfig, &heapSizeInBytes); if (result != MA_SUCCESS) { return result; /* Failed to retrieve the size of the heap allocation. */ } if (heapSizeInBytes > 0) { pHeap = ma_malloc(heapSizeInBytes, pAllocationCallbacks); if (pHeap == NULL) { return MA_OUT_OF_MEMORY; } } else { pHeap = NULL; } result = ma_slot_allocator_init_preallocated(pConfig, pHeap, pAllocator); if (result != MA_SUCCESS) { ma_free(pHeap, pAllocationCallbacks); return result; } pAllocator->_ownsHeap = MA_TRUE; return MA_SUCCESS; } MA_API void ma_slot_allocator_uninit(ma_slot_allocator* pAllocator, const ma_allocation_callbacks* pAllocationCallbacks) { if (pAllocator == NULL) { return; } if (pAllocator->_ownsHeap) { ma_free(pAllocator->_pHeap, pAllocationCallbacks); } } MA_API ma_result ma_slot_allocator_alloc(ma_slot_allocator* pAllocator, ma_uint64* pSlot) { ma_uint32 iAttempt; const ma_uint32 maxAttempts = 2; /* The number of iterations to perform until returning MA_OUT_OF_MEMORY if no slots can be found. */ if (pAllocator == NULL || pSlot == NULL) { return MA_INVALID_ARGS; } for (iAttempt = 0; iAttempt < maxAttempts; iAttempt += 1) { /* We need to acquire a suitable bitfield first. This is a bitfield that's got an available slot within it. */ ma_uint32 iGroup; for (iGroup = 0; iGroup < ma_slot_allocator_group_capacity(pAllocator); iGroup += 1) { /* CAS */ for (;;) { ma_uint32 oldBitfield; ma_uint32 newBitfield; ma_uint32 bitOffset; oldBitfield = ma_atomic_load_32(&pAllocator->pGroups[iGroup].bitfield); /* <-- This copy must happen. The compiler must not optimize this away. */ /* Fast check to see if anything is available. */ if (oldBitfield == 0xFFFFFFFF) { break; /* No available bits in this bitfield. */ } bitOffset = ma_ffs_32(~oldBitfield); MA_ASSERT(bitOffset < 32); newBitfield = oldBitfield | (1 << bitOffset); if (ma_atomic_compare_and_swap_32(&pAllocator->pGroups[iGroup].bitfield, oldBitfield, newBitfield) == oldBitfield) { ma_uint32 slotIndex; /* Increment the counter as soon as possible to have other threads report out-of-memory sooner than later. */ ma_atomic_fetch_add_32(&pAllocator->count, 1); /* The slot index is required for constructing the output value. */ slotIndex = (iGroup << 5) + bitOffset; /* iGroup << 5 = iGroup * 32 */ if (slotIndex >= pAllocator->capacity) { return MA_OUT_OF_MEMORY; } /* Increment the reference count before constructing the output value. */ pAllocator->pSlots[slotIndex] += 1; /* Construct the output value. */ *pSlot = (((ma_uint64)pAllocator->pSlots[slotIndex] << 32) | slotIndex); return MA_SUCCESS; } } } /* We weren't able to find a slot. If it's because we've reached our capacity we need to return MA_OUT_OF_MEMORY. Otherwise we need to do another iteration and try again. */ if (pAllocator->count < pAllocator->capacity) { ma_yield(); } else { return MA_OUT_OF_MEMORY; } } /* We couldn't find a slot within the maximum number of attempts. */ return MA_OUT_OF_MEMORY; } MA_API ma_result ma_slot_allocator_free(ma_slot_allocator* pAllocator, ma_uint64 slot) { ma_uint32 iGroup; ma_uint32 iBit; if (pAllocator == NULL) { return MA_INVALID_ARGS; } iGroup = (ma_uint32)((slot & 0xFFFFFFFF) >> 5); /* slot / 32 */ iBit = (ma_uint32)((slot & 0xFFFFFFFF) & 31); /* slot % 32 */ if (iGroup >= ma_slot_allocator_group_capacity(pAllocator)) { return MA_INVALID_ARGS; } MA_ASSERT(iBit < 32); /* This must be true due to the logic we used to actually calculate it. */ while (ma_atomic_load_32(&pAllocator->count) > 0) { /* CAS */ ma_uint32 oldBitfield; ma_uint32 newBitfield; oldBitfield = ma_atomic_load_32(&pAllocator->pGroups[iGroup].bitfield); /* <-- This copy must happen. The compiler must not optimize this away. */ newBitfield = oldBitfield & ~(1 << iBit); /* Debugging for checking for double-frees. */ #if defined(MA_DEBUG_OUTPUT) { if ((oldBitfield & (1 << iBit)) == 0) { MA_ASSERT(MA_FALSE); /* Double free detected.*/ } } #endif if (ma_atomic_compare_and_swap_32(&pAllocator->pGroups[iGroup].bitfield, oldBitfield, newBitfield) == oldBitfield) { ma_atomic_fetch_sub_32(&pAllocator->count, 1); return MA_SUCCESS; } } /* Getting here means there are no allocations available for freeing. */ return MA_INVALID_OPERATION; } #define MA_JOB_ID_NONE ~((ma_uint64)0) #define MA_JOB_SLOT_NONE (ma_uint16)(~0) static MA_INLINE ma_uint32 ma_job_extract_refcount(ma_uint64 toc) { return (ma_uint32)(toc >> 32); } static MA_INLINE ma_uint16 ma_job_extract_slot(ma_uint64 toc) { return (ma_uint16)(toc & 0x0000FFFF); } static MA_INLINE ma_uint16 ma_job_extract_code(ma_uint64 toc) { return (ma_uint16)((toc & 0xFFFF0000) >> 16); } static MA_INLINE ma_uint64 ma_job_toc_to_allocation(ma_uint64 toc) { return ((ma_uint64)ma_job_extract_refcount(toc) << 32) | (ma_uint64)ma_job_extract_slot(toc); } static MA_INLINE ma_uint64 ma_job_set_refcount(ma_uint64 toc, ma_uint32 refcount) { /* Clear the reference count first. */ toc = toc & ~((ma_uint64)0xFFFFFFFF << 32); toc = toc | ((ma_uint64)refcount << 32); return toc; } MA_API ma_job ma_job_init(ma_uint16 code) { ma_job job; MA_ZERO_OBJECT(&job); job.toc.breakup.code = code; job.toc.breakup.slot = MA_JOB_SLOT_NONE; /* Temp value. Will be allocated when posted to a queue. */ job.next = MA_JOB_ID_NONE; return job; } static ma_result ma_job_process__noop(ma_job* pJob); static ma_result ma_job_process__quit(ma_job* pJob); static ma_result ma_job_process__custom(ma_job* pJob); static ma_result ma_job_process__resource_manager__load_data_buffer_node(ma_job* pJob); static ma_result ma_job_process__resource_manager__free_data_buffer_node(ma_job* pJob); static ma_result ma_job_process__resource_manager__page_data_buffer_node(ma_job* pJob); static ma_result ma_job_process__resource_manager__load_data_buffer(ma_job* pJob); static ma_result ma_job_process__resource_manager__free_data_buffer(ma_job* pJob); static ma_result ma_job_process__resource_manager__load_data_stream(ma_job* pJob); static ma_result ma_job_process__resource_manager__free_data_stream(ma_job* pJob); static ma_result ma_job_process__resource_manager__page_data_stream(ma_job* pJob); static ma_result ma_job_process__resource_manager__seek_data_stream(ma_job* pJob); #if !defined(MA_NO_DEVICE_IO) static ma_result ma_job_process__device__aaudio_reroute(ma_job* pJob); #endif static ma_job_proc g_jobVTable[MA_JOB_TYPE_COUNT] = { /* Miscellaneous. */ ma_job_process__quit, /* MA_JOB_TYPE_QUIT */ ma_job_process__custom, /* MA_JOB_TYPE_CUSTOM */ /* Resource Manager. */ ma_job_process__resource_manager__load_data_buffer_node, /* MA_JOB_TYPE_RESOURCE_MANAGER_LOAD_DATA_BUFFER_NODE */ ma_job_process__resource_manager__free_data_buffer_node, /* MA_JOB_TYPE_RESOURCE_MANAGER_FREE_DATA_BUFFER_NODE */ ma_job_process__resource_manager__page_data_buffer_node, /* MA_JOB_TYPE_RESOURCE_MANAGER_PAGE_DATA_BUFFER_NODE */ ma_job_process__resource_manager__load_data_buffer, /* MA_JOB_TYPE_RESOURCE_MANAGER_LOAD_DATA_BUFFER */ ma_job_process__resource_manager__free_data_buffer, /* MA_JOB_TYPE_RESOURCE_MANAGER_FREE_DATA_BUFFER */ ma_job_process__resource_manager__load_data_stream, /* MA_JOB_TYPE_RESOURCE_MANAGER_LOAD_DATA_STREAM */ ma_job_process__resource_manager__free_data_stream, /* MA_JOB_TYPE_RESOURCE_MANAGER_FREE_DATA_STREAM */ ma_job_process__resource_manager__page_data_stream, /* MA_JOB_TYPE_RESOURCE_MANAGER_PAGE_DATA_STREAM */ ma_job_process__resource_manager__seek_data_stream, /* MA_JOB_TYPE_RESOURCE_MANAGER_SEEK_DATA_STREAM */ /* Device. */ #if !defined(MA_NO_DEVICE_IO) ma_job_process__device__aaudio_reroute /*MA_JOB_TYPE_DEVICE_AAUDIO_REROUTE*/ #endif }; MA_API ma_result ma_job_process(ma_job* pJob) { if (pJob == NULL) { return MA_INVALID_ARGS; } if (pJob->toc.breakup.code >= MA_JOB_TYPE_COUNT) { return MA_INVALID_OPERATION; } return g_jobVTable[pJob->toc.breakup.code](pJob); } static ma_result ma_job_process__noop(ma_job* pJob) { MA_ASSERT(pJob != NULL); /* No-op. */ (void)pJob; return MA_SUCCESS; } static ma_result ma_job_process__quit(ma_job* pJob) { return ma_job_process__noop(pJob); } static ma_result ma_job_process__custom(ma_job* pJob) { MA_ASSERT(pJob != NULL); /* No-op if there's no callback. */ if (pJob->data.custom.proc == NULL) { return MA_SUCCESS; } return pJob->data.custom.proc(pJob); } MA_API ma_job_queue_config ma_job_queue_config_init(ma_uint32 flags, ma_uint32 capacity) { ma_job_queue_config config; config.flags = flags; config.capacity = capacity; return config; } typedef struct { size_t sizeInBytes; size_t allocatorOffset; size_t jobsOffset; } ma_job_queue_heap_layout; static ma_result ma_job_queue_get_heap_layout(const ma_job_queue_config* pConfig, ma_job_queue_heap_layout* pHeapLayout) { ma_result result; MA_ASSERT(pHeapLayout != NULL); MA_ZERO_OBJECT(pHeapLayout); if (pConfig == NULL) { return MA_INVALID_ARGS; } if (pConfig->capacity == 0) { return MA_INVALID_ARGS; } pHeapLayout->sizeInBytes = 0; /* Allocator. */ { ma_slot_allocator_config allocatorConfig; size_t allocatorHeapSizeInBytes; allocatorConfig = ma_slot_allocator_config_init(pConfig->capacity); result = ma_slot_allocator_get_heap_size(&allocatorConfig, &allocatorHeapSizeInBytes); if (result != MA_SUCCESS) { return result; } pHeapLayout->allocatorOffset = pHeapLayout->sizeInBytes; pHeapLayout->sizeInBytes += allocatorHeapSizeInBytes; } /* Jobs. */ pHeapLayout->jobsOffset = pHeapLayout->sizeInBytes; pHeapLayout->sizeInBytes += ma_align_64(pConfig->capacity * sizeof(ma_job)); return MA_SUCCESS; } MA_API ma_result ma_job_queue_get_heap_size(const ma_job_queue_config* pConfig, size_t* pHeapSizeInBytes) { ma_result result; ma_job_queue_heap_layout layout; if (pHeapSizeInBytes == NULL) { return MA_INVALID_ARGS; } *pHeapSizeInBytes = 0; result = ma_job_queue_get_heap_layout(pConfig, &layout); if (result != MA_SUCCESS) { return result; } *pHeapSizeInBytes = layout.sizeInBytes; return MA_SUCCESS; } MA_API ma_result ma_job_queue_init_preallocated(const ma_job_queue_config* pConfig, void* pHeap, ma_job_queue* pQueue) { ma_result result; ma_job_queue_heap_layout heapLayout; ma_slot_allocator_config allocatorConfig; if (pQueue == NULL) { return MA_INVALID_ARGS; } MA_ZERO_OBJECT(pQueue); result = ma_job_queue_get_heap_layout(pConfig, &heapLayout); if (result != MA_SUCCESS) { return result; } pQueue->_pHeap = pHeap; MA_ZERO_MEMORY(pHeap, heapLayout.sizeInBytes); pQueue->flags = pConfig->flags; pQueue->capacity = pConfig->capacity; pQueue->pJobs = (ma_job*)ma_offset_ptr(pHeap, heapLayout.jobsOffset); allocatorConfig = ma_slot_allocator_config_init(pConfig->capacity); result = ma_slot_allocator_init_preallocated(&allocatorConfig, ma_offset_ptr(pHeap, heapLayout.allocatorOffset), &pQueue->allocator); if (result != MA_SUCCESS) { return result; } /* We need a semaphore if we're running in non-blocking mode. If threading is disabled we need to return an error. */ if ((pQueue->flags & MA_JOB_QUEUE_FLAG_NON_BLOCKING) == 0) { #ifndef MA_NO_THREADING { ma_semaphore_init(0, &pQueue->sem); } #else { /* Threading is disabled and we've requested non-blocking mode. */ return MA_INVALID_OPERATION; } #endif } /* Our queue needs to be initialized with a free standing node. This should always be slot 0. Required for the lock free algorithm. The first job in the queue is just a dummy item for giving us the first item in the list which is stored in the "next" member. */ ma_slot_allocator_alloc(&pQueue->allocator, &pQueue->head); /* Will never fail. */ pQueue->pJobs[ma_job_extract_slot(pQueue->head)].next = MA_JOB_ID_NONE; pQueue->tail = pQueue->head; return MA_SUCCESS; } MA_API ma_result ma_job_queue_init(const ma_job_queue_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_job_queue* pQueue) { ma_result result; size_t heapSizeInBytes; void* pHeap; result = ma_job_queue_get_heap_size(pConfig, &heapSizeInBytes); if (result != MA_SUCCESS) { return result; } if (heapSizeInBytes > 0) { pHeap = ma_malloc(heapSizeInBytes, pAllocationCallbacks); if (pHeap == NULL) { return MA_OUT_OF_MEMORY; } } else { pHeap = NULL; } result = ma_job_queue_init_preallocated(pConfig, pHeap, pQueue); if (result != MA_SUCCESS) { ma_free(pHeap, pAllocationCallbacks); return result; } pQueue->_ownsHeap = MA_TRUE; return MA_SUCCESS; } MA_API void ma_job_queue_uninit(ma_job_queue* pQueue, const ma_allocation_callbacks* pAllocationCallbacks) { if (pQueue == NULL) { return; } /* All we need to do is uninitialize the semaphore. */ if ((pQueue->flags & MA_JOB_QUEUE_FLAG_NON_BLOCKING) == 0) { #ifndef MA_NO_THREADING { ma_semaphore_uninit(&pQueue->sem); } #else { MA_ASSERT(MA_FALSE); /* Should never get here. Should have been checked at initialization time. */ } #endif } ma_slot_allocator_uninit(&pQueue->allocator, pAllocationCallbacks); if (pQueue->_ownsHeap) { ma_free(pQueue->_pHeap, pAllocationCallbacks); } } static ma_bool32 ma_job_queue_cas(volatile ma_uint64* dst, ma_uint64 expected, ma_uint64 desired) { /* The new counter is taken from the expected value. */ return ma_atomic_compare_and_swap_64(dst, expected, ma_job_set_refcount(desired, ma_job_extract_refcount(expected) + 1)) == expected; } MA_API ma_result ma_job_queue_post(ma_job_queue* pQueue, const ma_job* pJob) { /* Lock free queue implementation based on the paper by Michael and Scott: Nonblocking Algorithms and Preemption-Safe Locking on Multiprogrammed Shared Memory Multiprocessors */ ma_result result; ma_uint64 slot; ma_uint64 tail; ma_uint64 next; if (pQueue == NULL || pJob == NULL) { return MA_INVALID_ARGS; } /* We need a new slot. */ result = ma_slot_allocator_alloc(&pQueue->allocator, &slot); if (result != MA_SUCCESS) { return result; /* Probably ran out of slots. If so, MA_OUT_OF_MEMORY will be returned. */ } /* At this point we should have a slot to place the job. */ MA_ASSERT(ma_job_extract_slot(slot) < pQueue->capacity); /* We need to put the job into memory before we do anything. */ pQueue->pJobs[ma_job_extract_slot(slot)] = *pJob; pQueue->pJobs[ma_job_extract_slot(slot)].toc.allocation = slot; /* This will overwrite the job code. */ pQueue->pJobs[ma_job_extract_slot(slot)].toc.breakup.code = pJob->toc.breakup.code; /* The job code needs to be applied again because the line above overwrote it. */ pQueue->pJobs[ma_job_extract_slot(slot)].next = MA_JOB_ID_NONE; /* Reset for safety. */ #ifndef MA_USE_EXPERIMENTAL_LOCK_FREE_JOB_QUEUE ma_spinlock_lock(&pQueue->lock); #endif { /* The job is stored in memory so now we need to add it to our linked list. We only ever add items to the end of the list. */ for (;;) { tail = ma_atomic_load_64(&pQueue->tail); next = ma_atomic_load_64(&pQueue->pJobs[ma_job_extract_slot(tail)].next); if (ma_job_toc_to_allocation(tail) == ma_job_toc_to_allocation(ma_atomic_load_64(&pQueue->tail))) { if (ma_job_extract_slot(next) == 0xFFFF) { if (ma_job_queue_cas(&pQueue->pJobs[ma_job_extract_slot(tail)].next, next, slot)) { break; } } else { ma_job_queue_cas(&pQueue->tail, tail, ma_job_extract_slot(next)); } } } ma_job_queue_cas(&pQueue->tail, tail, slot); } #ifndef MA_USE_EXPERIMENTAL_LOCK_FREE_JOB_QUEUE ma_spinlock_unlock(&pQueue->lock); #endif /* Signal the semaphore as the last step if we're using synchronous mode. */ if ((pQueue->flags & MA_JOB_QUEUE_FLAG_NON_BLOCKING) == 0) { #ifndef MA_NO_THREADING { ma_semaphore_release(&pQueue->sem); } #else { MA_ASSERT(MA_FALSE); /* Should never get here. Should have been checked at initialization time. */ } #endif } return MA_SUCCESS; } MA_API ma_result ma_job_queue_next(ma_job_queue* pQueue, ma_job* pJob) { ma_uint64 head; ma_uint64 tail; ma_uint64 next; if (pQueue == NULL || pJob == NULL) { return MA_INVALID_ARGS; } /* If we're running in synchronous mode we'll need to wait on a semaphore. */ if ((pQueue->flags & MA_JOB_QUEUE_FLAG_NON_BLOCKING) == 0) { #ifndef MA_NO_THREADING { ma_semaphore_wait(&pQueue->sem); } #else { MA_ASSERT(MA_FALSE); /* Should never get here. Should have been checked at initialization time. */ } #endif } #ifndef MA_USE_EXPERIMENTAL_LOCK_FREE_JOB_QUEUE ma_spinlock_lock(&pQueue->lock); #endif { /* BUG: In lock-free mode, multiple threads can be in this section of code. The "head" variable in the loop below is stored. One thread can fall through to the freeing of this item while another is still using "head" for the retrieval of the "next" variable. The slot allocator might need to make use of some reference counting to ensure it's only truely freed when there are no more references to the item. This must be fixed before removing these locks. */ /* Now we need to remove the root item from the list. */ for (;;) { head = ma_atomic_load_64(&pQueue->head); tail = ma_atomic_load_64(&pQueue->tail); next = ma_atomic_load_64(&pQueue->pJobs[ma_job_extract_slot(head)].next); if (ma_job_toc_to_allocation(head) == ma_job_toc_to_allocation(ma_atomic_load_64(&pQueue->head))) { if (ma_job_extract_slot(head) == ma_job_extract_slot(tail)) { if (ma_job_extract_slot(next) == 0xFFFF) { #ifndef MA_USE_EXPERIMENTAL_LOCK_FREE_JOB_QUEUE ma_spinlock_unlock(&pQueue->lock); #endif return MA_NO_DATA_AVAILABLE; } ma_job_queue_cas(&pQueue->tail, tail, ma_job_extract_slot(next)); } else { *pJob = pQueue->pJobs[ma_job_extract_slot(next)]; if (ma_job_queue_cas(&pQueue->head, head, ma_job_extract_slot(next))) { break; } } } } } #ifndef MA_USE_EXPERIMENTAL_LOCK_FREE_JOB_QUEUE ma_spinlock_unlock(&pQueue->lock); #endif ma_slot_allocator_free(&pQueue->allocator, head); /* If it's a quit job make sure it's put back on the queue to ensure other threads have an opportunity to detect it and terminate naturally. We could instead just leave it on the queue, but that would involve fiddling with the lock-free code above and I want to keep that as simple as possible. */ if (pJob->toc.breakup.code == MA_JOB_TYPE_QUIT) { ma_job_queue_post(pQueue, pJob); return MA_CANCELLED; /* Return a cancelled status just in case the thread is checking return codes and not properly checking for a quit job. */ } return MA_SUCCESS; } /******************************************************************************* Dynamic Linking *******************************************************************************/ #ifdef MA_POSIX /* No need for dlfcn.h if we're not using runtime linking. */ #ifndef MA_NO_RUNTIME_LINKING #include #endif #endif MA_API ma_handle ma_dlopen(ma_log* pLog, const char* filename) { #ifndef MA_NO_RUNTIME_LINKING ma_handle handle; ma_log_postf(pLog, MA_LOG_LEVEL_DEBUG, "Loading library: %s\n", filename); #ifdef MA_WIN32 /* From MSDN: Desktop applications cannot use LoadPackagedLibrary; if a desktop application calls this function it fails with APPMODEL_ERROR_NO_PACKAGE.*/ #if !defined(MA_WIN32_UWP) || !(defined(WINAPI_FAMILY) && ((defined(WINAPI_FAMILY_PHONE_APP) && WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP))) handle = (ma_handle)LoadLibraryA(filename); #else /* *sigh* It appears there is no ANSI version of LoadPackagedLibrary()... */ WCHAR filenameW[4096]; if (MultiByteToWideChar(CP_UTF8, 0, filename, -1, filenameW, sizeof(filenameW)) == 0) { handle = NULL; } else { handle = (ma_handle)LoadPackagedLibrary(filenameW, 0); } #endif #else handle = (ma_handle)dlopen(filename, RTLD_NOW); #endif /* I'm not considering failure to load a library an error nor a warning because seamlessly falling through to a lower-priority backend is a deliberate design choice. Instead I'm logging it as an informational message. */ if (handle == NULL) { ma_log_postf(pLog, MA_LOG_LEVEL_INFO, "Failed to load library: %s\n", filename); } return handle; #else /* Runtime linking is disabled. */ (void)pLog; (void)filename; return NULL; #endif } MA_API void ma_dlclose(ma_log* pLog, ma_handle handle) { #ifndef MA_NO_RUNTIME_LINKING #ifdef MA_WIN32 FreeLibrary((HMODULE)handle); #else dlclose((void*)handle); #endif (void)pLog; #else /* Runtime linking is disabled. */ (void)pLog; (void)handle; #endif } MA_API ma_proc ma_dlsym(ma_log* pLog, ma_handle handle, const char* symbol) { #ifndef MA_NO_RUNTIME_LINKING ma_proc proc; ma_log_postf(pLog, MA_LOG_LEVEL_DEBUG, "Loading symbol: %s\n", symbol); #ifdef _WIN32 proc = (ma_proc)GetProcAddress((HMODULE)handle, symbol); #else #if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wpedantic" #endif proc = (ma_proc)dlsym((void*)handle, symbol); #if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)) #pragma GCC diagnostic pop #endif #endif if (proc == NULL) { ma_log_postf(pLog, MA_LOG_LEVEL_WARNING, "Failed to load symbol: %s\n", symbol); } (void)pLog; /* It's possible for pContext to be unused. */ return proc; #else /* Runtime linking is disabled. */ (void)pLog; (void)handle; (void)symbol; return NULL; #endif } /************************************************************************************************************************************************************ ************************************************************************************************************************************************************* DEVICE I/O ========== ************************************************************************************************************************************************************* ************************************************************************************************************************************************************/ /* Disable run-time linking on certain backends and platforms. */ #ifndef MA_NO_RUNTIME_LINKING #if defined(MA_EMSCRIPTEN) || defined(MA_ORBIS) || defined(MA_PROSPERO) #define MA_NO_RUNTIME_LINKING #endif #endif #ifndef MA_NO_DEVICE_IO #if defined(MA_APPLE) && (__MAC_OS_X_VERSION_MIN_REQUIRED < 101200) #include /* For mach_absolute_time() */ #endif #ifdef MA_POSIX #include #include /* No need for dlfcn.h if we're not using runtime linking. */ #ifndef MA_NO_RUNTIME_LINKING #include #endif #endif MA_API void ma_device_info_add_native_data_format(ma_device_info* pDeviceInfo, ma_format format, ma_uint32 channels, ma_uint32 sampleRate, ma_uint32 flags) { if (pDeviceInfo == NULL) { return; } if (pDeviceInfo->nativeDataFormatCount < ma_countof(pDeviceInfo->nativeDataFormats)) { pDeviceInfo->nativeDataFormats[pDeviceInfo->nativeDataFormatCount].format = format; pDeviceInfo->nativeDataFormats[pDeviceInfo->nativeDataFormatCount].channels = channels; pDeviceInfo->nativeDataFormats[pDeviceInfo->nativeDataFormatCount].sampleRate = sampleRate; pDeviceInfo->nativeDataFormats[pDeviceInfo->nativeDataFormatCount].flags = flags; pDeviceInfo->nativeDataFormatCount += 1; } } typedef struct { ma_backend backend; const char* pName; } ma_backend_info; static ma_backend_info gBackendInfo[] = /* Indexed by the backend enum. Must be in the order backends are declared in the ma_backend enum. */ { {ma_backend_wasapi, "WASAPI"}, {ma_backend_dsound, "DirectSound"}, {ma_backend_winmm, "WinMM"}, {ma_backend_coreaudio, "Core Audio"}, {ma_backend_sndio, "sndio"}, {ma_backend_audio4, "audio(4)"}, {ma_backend_oss, "OSS"}, {ma_backend_pulseaudio, "PulseAudio"}, {ma_backend_alsa, "ALSA"}, {ma_backend_jack, "JACK"}, {ma_backend_aaudio, "AAudio"}, {ma_backend_opensl, "OpenSL|ES"}, {ma_backend_webaudio, "Web Audio"}, {ma_backend_custom, "Custom"}, {ma_backend_null, "Null"} }; MA_API const char* ma_get_backend_name(ma_backend backend) { if (backend < 0 || backend >= (int)ma_countof(gBackendInfo)) { return "Unknown"; } return gBackendInfo[backend].pName; } MA_API ma_result ma_get_backend_from_name(const char* pBackendName, ma_backend* pBackend) { size_t iBackend; if (pBackendName == NULL) { return MA_INVALID_ARGS; } for (iBackend = 0; iBackend < ma_countof(gBackendInfo); iBackend += 1) { if (ma_strcmp(pBackendName, gBackendInfo[iBackend].pName) == 0) { if (pBackend != NULL) { *pBackend = gBackendInfo[iBackend].backend; } return MA_SUCCESS; } } /* Getting here means the backend name is unknown. */ return MA_INVALID_ARGS; } MA_API ma_bool32 ma_is_backend_enabled(ma_backend backend) { /* This looks a little bit gross, but we want all backends to be included in the switch to avoid warnings on some compilers about some enums not being handled by the switch statement. */ switch (backend) { case ma_backend_wasapi: #if defined(MA_HAS_WASAPI) return MA_TRUE; #else return MA_FALSE; #endif case ma_backend_dsound: #if defined(MA_HAS_DSOUND) return MA_TRUE; #else return MA_FALSE; #endif case ma_backend_winmm: #if defined(MA_HAS_WINMM) return MA_TRUE; #else return MA_FALSE; #endif case ma_backend_coreaudio: #if defined(MA_HAS_COREAUDIO) return MA_TRUE; #else return MA_FALSE; #endif case ma_backend_sndio: #if defined(MA_HAS_SNDIO) return MA_TRUE; #else return MA_FALSE; #endif case ma_backend_audio4: #if defined(MA_HAS_AUDIO4) return MA_TRUE; #else return MA_FALSE; #endif case ma_backend_oss: #if defined(MA_HAS_OSS) return MA_TRUE; #else return MA_FALSE; #endif case ma_backend_pulseaudio: #if defined(MA_HAS_PULSEAUDIO) return MA_TRUE; #else return MA_FALSE; #endif case ma_backend_alsa: #if defined(MA_HAS_ALSA) return MA_TRUE; #else return MA_FALSE; #endif case ma_backend_jack: #if defined(MA_HAS_JACK) return MA_TRUE; #else return MA_FALSE; #endif case ma_backend_aaudio: #if defined(MA_HAS_AAUDIO) #if defined(MA_ANDROID) { return ma_android_sdk_version() >= 26; } #else return MA_FALSE; #endif #else return MA_FALSE; #endif case ma_backend_opensl: #if defined(MA_HAS_OPENSL) #if defined(MA_ANDROID) { return ma_android_sdk_version() >= 9; } #else return MA_TRUE; #endif #else return MA_FALSE; #endif case ma_backend_webaudio: #if defined(MA_HAS_WEBAUDIO) return MA_TRUE; #else return MA_FALSE; #endif case ma_backend_custom: #if defined(MA_HAS_CUSTOM) return MA_TRUE; #else return MA_FALSE; #endif case ma_backend_null: #if defined(MA_HAS_NULL) return MA_TRUE; #else return MA_FALSE; #endif default: return MA_FALSE; } } MA_API ma_result ma_get_enabled_backends(ma_backend* pBackends, size_t backendCap, size_t* pBackendCount) { size_t backendCount; size_t iBackend; ma_result result = MA_SUCCESS; if (pBackendCount == NULL) { return MA_INVALID_ARGS; } backendCount = 0; for (iBackend = 0; iBackend <= ma_backend_null; iBackend += 1) { ma_backend backend = (ma_backend)iBackend; if (ma_is_backend_enabled(backend)) { /* The backend is enabled. Try adding it to the list. If there's no room, MA_NO_SPACE needs to be returned. */ if (backendCount == backendCap) { result = MA_NO_SPACE; break; } else { pBackends[backendCount] = backend; backendCount += 1; } } } if (pBackendCount != NULL) { *pBackendCount = backendCount; } return result; } MA_API ma_bool32 ma_is_loopback_supported(ma_backend backend) { switch (backend) { case ma_backend_wasapi: return MA_TRUE; case ma_backend_dsound: return MA_FALSE; case ma_backend_winmm: return MA_FALSE; case ma_backend_coreaudio: return MA_FALSE; case ma_backend_sndio: return MA_FALSE; case ma_backend_audio4: return MA_FALSE; case ma_backend_oss: return MA_FALSE; case ma_backend_pulseaudio: return MA_FALSE; case ma_backend_alsa: return MA_FALSE; case ma_backend_jack: return MA_FALSE; case ma_backend_aaudio: return MA_FALSE; case ma_backend_opensl: return MA_FALSE; case ma_backend_webaudio: return MA_FALSE; case ma_backend_custom: return MA_FALSE; /* <-- Will depend on the implementation of the backend. */ case ma_backend_null: return MA_FALSE; default: return MA_FALSE; } } #if defined(MA_WIN32) /* WASAPI error codes. */ #define MA_AUDCLNT_E_NOT_INITIALIZED ((HRESULT)0x88890001) #define MA_AUDCLNT_E_ALREADY_INITIALIZED ((HRESULT)0x88890002) #define MA_AUDCLNT_E_WRONG_ENDPOINT_TYPE ((HRESULT)0x88890003) #define MA_AUDCLNT_E_DEVICE_INVALIDATED ((HRESULT)0x88890004) #define MA_AUDCLNT_E_NOT_STOPPED ((HRESULT)0x88890005) #define MA_AUDCLNT_E_BUFFER_TOO_LARGE ((HRESULT)0x88890006) #define MA_AUDCLNT_E_OUT_OF_ORDER ((HRESULT)0x88890007) #define MA_AUDCLNT_E_UNSUPPORTED_FORMAT ((HRESULT)0x88890008) #define MA_AUDCLNT_E_INVALID_SIZE ((HRESULT)0x88890009) #define MA_AUDCLNT_E_DEVICE_IN_USE ((HRESULT)0x8889000A) #define MA_AUDCLNT_E_BUFFER_OPERATION_PENDING ((HRESULT)0x8889000B) #define MA_AUDCLNT_E_THREAD_NOT_REGISTERED ((HRESULT)0x8889000C) #define MA_AUDCLNT_E_NO_SINGLE_PROCESS ((HRESULT)0x8889000D) #define MA_AUDCLNT_E_EXCLUSIVE_MODE_NOT_ALLOWED ((HRESULT)0x8889000E) #define MA_AUDCLNT_E_ENDPOINT_CREATE_FAILED ((HRESULT)0x8889000F) #define MA_AUDCLNT_E_SERVICE_NOT_RUNNING ((HRESULT)0x88890010) #define MA_AUDCLNT_E_EVENTHANDLE_NOT_EXPECTED ((HRESULT)0x88890011) #define MA_AUDCLNT_E_EXCLUSIVE_MODE_ONLY ((HRESULT)0x88890012) #define MA_AUDCLNT_E_BUFDURATION_PERIOD_NOT_EQUAL ((HRESULT)0x88890013) #define MA_AUDCLNT_E_EVENTHANDLE_NOT_SET ((HRESULT)0x88890014) #define MA_AUDCLNT_E_INCORRECT_BUFFER_SIZE ((HRESULT)0x88890015) #define MA_AUDCLNT_E_BUFFER_SIZE_ERROR ((HRESULT)0x88890016) #define MA_AUDCLNT_E_CPUUSAGE_EXCEEDED ((HRESULT)0x88890017) #define MA_AUDCLNT_E_BUFFER_ERROR ((HRESULT)0x88890018) #define MA_AUDCLNT_E_BUFFER_SIZE_NOT_ALIGNED ((HRESULT)0x88890019) #define MA_AUDCLNT_E_INVALID_DEVICE_PERIOD ((HRESULT)0x88890020) #define MA_AUDCLNT_E_INVALID_STREAM_FLAG ((HRESULT)0x88890021) #define MA_AUDCLNT_E_ENDPOINT_OFFLOAD_NOT_CAPABLE ((HRESULT)0x88890022) #define MA_AUDCLNT_E_OUT_OF_OFFLOAD_RESOURCES ((HRESULT)0x88890023) #define MA_AUDCLNT_E_OFFLOAD_MODE_ONLY ((HRESULT)0x88890024) #define MA_AUDCLNT_E_NONOFFLOAD_MODE_ONLY ((HRESULT)0x88890025) #define MA_AUDCLNT_E_RESOURCES_INVALIDATED ((HRESULT)0x88890026) #define MA_AUDCLNT_E_RAW_MODE_UNSUPPORTED ((HRESULT)0x88890027) #define MA_AUDCLNT_E_ENGINE_PERIODICITY_LOCKED ((HRESULT)0x88890028) #define MA_AUDCLNT_E_ENGINE_FORMAT_LOCKED ((HRESULT)0x88890029) #define MA_AUDCLNT_E_HEADTRACKING_ENABLED ((HRESULT)0x88890030) #define MA_AUDCLNT_E_HEADTRACKING_UNSUPPORTED ((HRESULT)0x88890040) #define MA_AUDCLNT_S_BUFFER_EMPTY ((HRESULT)0x08890001) #define MA_AUDCLNT_S_THREAD_ALREADY_REGISTERED ((HRESULT)0x08890002) #define MA_AUDCLNT_S_POSITION_STALLED ((HRESULT)0x08890003) #define MA_DS_OK ((HRESULT)0) #define MA_DS_NO_VIRTUALIZATION ((HRESULT)0x0878000A) #define MA_DSERR_ALLOCATED ((HRESULT)0x8878000A) #define MA_DSERR_CONTROLUNAVAIL ((HRESULT)0x8878001E) #define MA_DSERR_INVALIDPARAM ((HRESULT)0x80070057) /*E_INVALIDARG*/ #define MA_DSERR_INVALIDCALL ((HRESULT)0x88780032) #define MA_DSERR_GENERIC ((HRESULT)0x80004005) /*E_FAIL*/ #define MA_DSERR_PRIOLEVELNEEDED ((HRESULT)0x88780046) #define MA_DSERR_OUTOFMEMORY ((HRESULT)0x8007000E) /*E_OUTOFMEMORY*/ #define MA_DSERR_BADFORMAT ((HRESULT)0x88780064) #define MA_DSERR_UNSUPPORTED ((HRESULT)0x80004001) /*E_NOTIMPL*/ #define MA_DSERR_NODRIVER ((HRESULT)0x88780078) #define MA_DSERR_ALREADYINITIALIZED ((HRESULT)0x88780082) #define MA_DSERR_NOAGGREGATION ((HRESULT)0x80040110) /*CLASS_E_NOAGGREGATION*/ #define MA_DSERR_BUFFERLOST ((HRESULT)0x88780096) #define MA_DSERR_OTHERAPPHASPRIO ((HRESULT)0x887800A0) #define MA_DSERR_UNINITIALIZED ((HRESULT)0x887800AA) #define MA_DSERR_NOINTERFACE ((HRESULT)0x80004002) /*E_NOINTERFACE*/ #define MA_DSERR_ACCESSDENIED ((HRESULT)0x80070005) /*E_ACCESSDENIED*/ #define MA_DSERR_BUFFERTOOSMALL ((HRESULT)0x887800B4) #define MA_DSERR_DS8_REQUIRED ((HRESULT)0x887800BE) #define MA_DSERR_SENDLOOP ((HRESULT)0x887800C8) #define MA_DSERR_BADSENDBUFFERGUID ((HRESULT)0x887800D2) #define MA_DSERR_OBJECTNOTFOUND ((HRESULT)0x88781161) #define MA_DSERR_FXUNAVAILABLE ((HRESULT)0x887800DC) static ma_result ma_result_from_HRESULT(HRESULT hr) { switch (hr) { case NOERROR: return MA_SUCCESS; /*case S_OK: return MA_SUCCESS;*/ case E_POINTER: return MA_INVALID_ARGS; case E_UNEXPECTED: return MA_ERROR; case E_NOTIMPL: return MA_NOT_IMPLEMENTED; case E_OUTOFMEMORY: return MA_OUT_OF_MEMORY; case E_INVALIDARG: return MA_INVALID_ARGS; case E_NOINTERFACE: return MA_API_NOT_FOUND; case E_HANDLE: return MA_INVALID_ARGS; case E_ABORT: return MA_ERROR; case E_FAIL: return MA_ERROR; case E_ACCESSDENIED: return MA_ACCESS_DENIED; /* WASAPI */ case MA_AUDCLNT_E_NOT_INITIALIZED: return MA_DEVICE_NOT_INITIALIZED; case MA_AUDCLNT_E_ALREADY_INITIALIZED: return MA_DEVICE_ALREADY_INITIALIZED; case MA_AUDCLNT_E_WRONG_ENDPOINT_TYPE: return MA_INVALID_ARGS; case MA_AUDCLNT_E_DEVICE_INVALIDATED: return MA_UNAVAILABLE; case MA_AUDCLNT_E_NOT_STOPPED: return MA_DEVICE_NOT_STOPPED; case MA_AUDCLNT_E_BUFFER_TOO_LARGE: return MA_TOO_BIG; case MA_AUDCLNT_E_OUT_OF_ORDER: return MA_INVALID_OPERATION; case MA_AUDCLNT_E_UNSUPPORTED_FORMAT: return MA_FORMAT_NOT_SUPPORTED; case MA_AUDCLNT_E_INVALID_SIZE: return MA_INVALID_ARGS; case MA_AUDCLNT_E_DEVICE_IN_USE: return MA_BUSY; case MA_AUDCLNT_E_BUFFER_OPERATION_PENDING: return MA_INVALID_OPERATION; case MA_AUDCLNT_E_THREAD_NOT_REGISTERED: return MA_DOES_NOT_EXIST; case MA_AUDCLNT_E_NO_SINGLE_PROCESS: return MA_INVALID_OPERATION; case MA_AUDCLNT_E_EXCLUSIVE_MODE_NOT_ALLOWED: return MA_SHARE_MODE_NOT_SUPPORTED; case MA_AUDCLNT_E_ENDPOINT_CREATE_FAILED: return MA_FAILED_TO_OPEN_BACKEND_DEVICE; case MA_AUDCLNT_E_SERVICE_NOT_RUNNING: return MA_NOT_CONNECTED; case MA_AUDCLNT_E_EVENTHANDLE_NOT_EXPECTED: return MA_INVALID_ARGS; case MA_AUDCLNT_E_EXCLUSIVE_MODE_ONLY: return MA_SHARE_MODE_NOT_SUPPORTED; case MA_AUDCLNT_E_BUFDURATION_PERIOD_NOT_EQUAL: return MA_INVALID_ARGS; case MA_AUDCLNT_E_EVENTHANDLE_NOT_SET: return MA_INVALID_ARGS; case MA_AUDCLNT_E_INCORRECT_BUFFER_SIZE: return MA_INVALID_ARGS; case MA_AUDCLNT_E_BUFFER_SIZE_ERROR: return MA_INVALID_ARGS; case MA_AUDCLNT_E_CPUUSAGE_EXCEEDED: return MA_ERROR; case MA_AUDCLNT_E_BUFFER_ERROR: return MA_ERROR; case MA_AUDCLNT_E_BUFFER_SIZE_NOT_ALIGNED: return MA_INVALID_ARGS; case MA_AUDCLNT_E_INVALID_DEVICE_PERIOD: return MA_INVALID_ARGS; case MA_AUDCLNT_E_INVALID_STREAM_FLAG: return MA_INVALID_ARGS; case MA_AUDCLNT_E_ENDPOINT_OFFLOAD_NOT_CAPABLE: return MA_INVALID_OPERATION; case MA_AUDCLNT_E_OUT_OF_OFFLOAD_RESOURCES: return MA_OUT_OF_MEMORY; case MA_AUDCLNT_E_OFFLOAD_MODE_ONLY: return MA_INVALID_OPERATION; case MA_AUDCLNT_E_NONOFFLOAD_MODE_ONLY: return MA_INVALID_OPERATION; case MA_AUDCLNT_E_RESOURCES_INVALIDATED: return MA_INVALID_DATA; case MA_AUDCLNT_E_RAW_MODE_UNSUPPORTED: return MA_INVALID_OPERATION; case MA_AUDCLNT_E_ENGINE_PERIODICITY_LOCKED: return MA_INVALID_OPERATION; case MA_AUDCLNT_E_ENGINE_FORMAT_LOCKED: return MA_INVALID_OPERATION; case MA_AUDCLNT_E_HEADTRACKING_ENABLED: return MA_INVALID_OPERATION; case MA_AUDCLNT_E_HEADTRACKING_UNSUPPORTED: return MA_INVALID_OPERATION; case MA_AUDCLNT_S_BUFFER_EMPTY: return MA_NO_SPACE; case MA_AUDCLNT_S_THREAD_ALREADY_REGISTERED: return MA_ALREADY_EXISTS; case MA_AUDCLNT_S_POSITION_STALLED: return MA_ERROR; /* DirectSound */ /*case MA_DS_OK: return MA_SUCCESS;*/ /* S_OK */ case MA_DS_NO_VIRTUALIZATION: return MA_SUCCESS; case MA_DSERR_ALLOCATED: return MA_ALREADY_IN_USE; case MA_DSERR_CONTROLUNAVAIL: return MA_INVALID_OPERATION; /*case MA_DSERR_INVALIDPARAM: return MA_INVALID_ARGS;*/ /* E_INVALIDARG */ case MA_DSERR_INVALIDCALL: return MA_INVALID_OPERATION; /*case MA_DSERR_GENERIC: return MA_ERROR;*/ /* E_FAIL */ case MA_DSERR_PRIOLEVELNEEDED: return MA_INVALID_OPERATION; /*case MA_DSERR_OUTOFMEMORY: return MA_OUT_OF_MEMORY;*/ /* E_OUTOFMEMORY */ case MA_DSERR_BADFORMAT: return MA_FORMAT_NOT_SUPPORTED; /*case MA_DSERR_UNSUPPORTED: return MA_NOT_IMPLEMENTED;*/ /* E_NOTIMPL */ case MA_DSERR_NODRIVER: return MA_FAILED_TO_INIT_BACKEND; case MA_DSERR_ALREADYINITIALIZED: return MA_DEVICE_ALREADY_INITIALIZED; case MA_DSERR_NOAGGREGATION: return MA_ERROR; case MA_DSERR_BUFFERLOST: return MA_UNAVAILABLE; case MA_DSERR_OTHERAPPHASPRIO: return MA_ACCESS_DENIED; case MA_DSERR_UNINITIALIZED: return MA_DEVICE_NOT_INITIALIZED; /*case MA_DSERR_NOINTERFACE: return MA_API_NOT_FOUND;*/ /* E_NOINTERFACE */ /*case MA_DSERR_ACCESSDENIED: return MA_ACCESS_DENIED;*/ /* E_ACCESSDENIED */ case MA_DSERR_BUFFERTOOSMALL: return MA_NO_SPACE; case MA_DSERR_DS8_REQUIRED: return MA_INVALID_OPERATION; case MA_DSERR_SENDLOOP: return MA_DEADLOCK; case MA_DSERR_BADSENDBUFFERGUID: return MA_INVALID_ARGS; case MA_DSERR_OBJECTNOTFOUND: return MA_NO_DEVICE; case MA_DSERR_FXUNAVAILABLE: return MA_UNAVAILABLE; default: return MA_ERROR; } } /* PROPVARIANT */ #define MA_VT_LPWSTR 31 #define MA_VT_BLOB 65 #if defined(_MSC_VER) && !defined(__clang__) #pragma warning(push) #pragma warning(disable:4201) /* nonstandard extension used: nameless struct/union */ #elif defined(__clang__) || (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8))) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wpedantic" /* For ISO C99 doesn't support unnamed structs/unions [-Wpedantic] */ #if defined(__clang__) #pragma GCC diagnostic ignored "-Wc11-extensions" /* anonymous unions are a C11 extension */ #endif #endif typedef struct { WORD vt; WORD wReserved1; WORD wReserved2; WORD wReserved3; union { struct { ULONG cbSize; BYTE* pBlobData; } blob; WCHAR* pwszVal; char pad[16]; /* Just to ensure the size of the struct matches the official version. */ }; } MA_PROPVARIANT; #if defined(_MSC_VER) && !defined(__clang__) #pragma warning(pop) #elif defined(__clang__) || (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8))) #pragma GCC diagnostic pop #endif typedef HRESULT (WINAPI * MA_PFN_CoInitialize)(void* pvReserved); typedef HRESULT (WINAPI * MA_PFN_CoInitializeEx)(void* pvReserved, DWORD dwCoInit); typedef void (WINAPI * MA_PFN_CoUninitialize)(void); typedef HRESULT (WINAPI * MA_PFN_CoCreateInstance)(const IID* rclsid, void* pUnkOuter, DWORD dwClsContext, const IID* riid, void* ppv); typedef void (WINAPI * MA_PFN_CoTaskMemFree)(void* pv); typedef HRESULT (WINAPI * MA_PFN_PropVariantClear)(MA_PROPVARIANT *pvar); typedef int (WINAPI * MA_PFN_StringFromGUID2)(const GUID* const rguid, WCHAR* lpsz, int cchMax); typedef HWND (WINAPI * MA_PFN_GetForegroundWindow)(void); typedef HWND (WINAPI * MA_PFN_GetDesktopWindow)(void); #if defined(MA_WIN32_DESKTOP) /* Microsoft documents these APIs as returning LSTATUS, but the Win32 API shipping with some compilers do not define it. It's just a LONG. */ typedef LONG (WINAPI * MA_PFN_RegOpenKeyExA)(HKEY hKey, const char* lpSubKey, DWORD ulOptions, DWORD samDesired, HKEY* phkResult); typedef LONG (WINAPI * MA_PFN_RegCloseKey)(HKEY hKey); typedef LONG (WINAPI * MA_PFN_RegQueryValueExA)(HKEY hKey, const char* lpValueName, DWORD* lpReserved, DWORD* lpType, BYTE* lpData, DWORD* lpcbData); #endif /* MA_WIN32_DESKTOP */ MA_API size_t ma_strlen_WCHAR(const WCHAR* str) { size_t len = 0; while (str[len] != '\0') { len += 1; } return len; } MA_API int ma_strcmp_WCHAR(const WCHAR *s1, const WCHAR *s2) { while (*s1 != '\0' && *s1 == *s2) { s1 += 1; s2 += 1; } return *s1 - *s2; } MA_API int ma_strcpy_s_WCHAR(WCHAR* dst, size_t dstCap, const WCHAR* src) { size_t i; if (dst == 0) { return 22; } if (dstCap == 0) { return 34; } if (src == 0) { dst[0] = '\0'; return 22; } for (i = 0; i < dstCap && src[i] != '\0'; ++i) { dst[i] = src[i]; } if (i < dstCap) { dst[i] = '\0'; return 0; } dst[0] = '\0'; return 34; } #endif /* MA_WIN32 */ #define MA_DEFAULT_PLAYBACK_DEVICE_NAME "Default Playback Device" #define MA_DEFAULT_CAPTURE_DEVICE_NAME "Default Capture Device" /******************************************************************************* Timing *******************************************************************************/ #if defined(MA_WIN32) && !defined(MA_POSIX) static LARGE_INTEGER g_ma_TimerFrequency; /* <-- Initialized to zero since it's static. */ static void ma_timer_init(ma_timer* pTimer) { LARGE_INTEGER counter; if (g_ma_TimerFrequency.QuadPart == 0) { QueryPerformanceFrequency(&g_ma_TimerFrequency); } QueryPerformanceCounter(&counter); pTimer->counter = counter.QuadPart; } static double ma_timer_get_time_in_seconds(ma_timer* pTimer) { LARGE_INTEGER counter; if (!QueryPerformanceCounter(&counter)) { return 0; } return (double)(counter.QuadPart - pTimer->counter) / g_ma_TimerFrequency.QuadPart; } #elif defined(MA_APPLE) && (__MAC_OS_X_VERSION_MIN_REQUIRED < 101200) static ma_uint64 g_ma_TimerFrequency = 0; static void ma_timer_init(ma_timer* pTimer) { mach_timebase_info_data_t baseTime; mach_timebase_info(&baseTime); g_ma_TimerFrequency = (baseTime.denom * 1e9) / baseTime.numer; pTimer->counter = mach_absolute_time(); } static double ma_timer_get_time_in_seconds(ma_timer* pTimer) { ma_uint64 newTimeCounter = mach_absolute_time(); ma_uint64 oldTimeCounter = pTimer->counter; return (newTimeCounter - oldTimeCounter) / g_ma_TimerFrequency; } #elif defined(MA_EMSCRIPTEN) static MA_INLINE void ma_timer_init(ma_timer* pTimer) { pTimer->counterD = emscripten_get_now(); } static MA_INLINE double ma_timer_get_time_in_seconds(ma_timer* pTimer) { return (emscripten_get_now() - pTimer->counterD) / 1000; /* Emscripten is in milliseconds. */ } #else #if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 199309L #if defined(CLOCK_MONOTONIC) #define MA_CLOCK_ID CLOCK_MONOTONIC #else #define MA_CLOCK_ID CLOCK_REALTIME #endif static void ma_timer_init(ma_timer* pTimer) { struct timespec newTime; clock_gettime(MA_CLOCK_ID, &newTime); pTimer->counter = (newTime.tv_sec * 1000000000) + newTime.tv_nsec; } static double ma_timer_get_time_in_seconds(ma_timer* pTimer) { ma_uint64 newTimeCounter; ma_uint64 oldTimeCounter; struct timespec newTime; clock_gettime(MA_CLOCK_ID, &newTime); newTimeCounter = (newTime.tv_sec * 1000000000) + newTime.tv_nsec; oldTimeCounter = pTimer->counter; return (newTimeCounter - oldTimeCounter) / 1000000000.0; } #else static void ma_timer_init(ma_timer* pTimer) { struct timeval newTime; gettimeofday(&newTime, NULL); pTimer->counter = (newTime.tv_sec * 1000000) + newTime.tv_usec; } static double ma_timer_get_time_in_seconds(ma_timer* pTimer) { ma_uint64 newTimeCounter; ma_uint64 oldTimeCounter; struct timeval newTime; gettimeofday(&newTime, NULL); newTimeCounter = (newTime.tv_sec * 1000000) + newTime.tv_usec; oldTimeCounter = pTimer->counter; return (newTimeCounter - oldTimeCounter) / 1000000.0; } #endif #endif #if 0 static ma_uint32 ma_get_closest_standard_sample_rate(ma_uint32 sampleRateIn) { ma_uint32 closestRate = 0; ma_uint32 closestDiff = 0xFFFFFFFF; size_t iStandardRate; for (iStandardRate = 0; iStandardRate < ma_countof(g_maStandardSampleRatePriorities); ++iStandardRate) { ma_uint32 standardRate = g_maStandardSampleRatePriorities[iStandardRate]; ma_uint32 diff; if (sampleRateIn > standardRate) { diff = sampleRateIn - standardRate; } else { diff = standardRate - sampleRateIn; } if (diff == 0) { return standardRate; /* The input sample rate is a standard rate. */ } if (closestDiff > diff) { closestDiff = diff; closestRate = standardRate; } } return closestRate; } #endif static MA_INLINE unsigned int ma_device_disable_denormals(ma_device* pDevice) { MA_ASSERT(pDevice != NULL); if (!pDevice->noDisableDenormals) { return ma_disable_denormals(); } else { return 0; } } static MA_INLINE void ma_device_restore_denormals(ma_device* pDevice, unsigned int prevState) { MA_ASSERT(pDevice != NULL); if (!pDevice->noDisableDenormals) { ma_restore_denormals(prevState); } else { /* Do nothing. */ (void)prevState; } } static ma_device_notification ma_device_notification_init(ma_device* pDevice, ma_device_notification_type type) { ma_device_notification notification; MA_ZERO_OBJECT(¬ification); notification.pDevice = pDevice; notification.type = type; return notification; } static void ma_device__on_notification(ma_device_notification notification) { if(notification.pDevice != NULL) { MA_ASSERT(notification.pDevice != NULL); if (notification.pDevice->onNotification != NULL) { notification.pDevice->onNotification(¬ification); } /* TEMP FOR COMPATIBILITY: If it's a stopped notification, fire the onStop callback as well. This is only for backwards compatibility and will be removed. */ if (notification.pDevice->onStop != NULL && notification.type == ma_device_notification_type_stopped) { notification.pDevice->onStop(notification.pDevice); } } } static void ma_device__on_notification_started(ma_device* pDevice) { ma_device__on_notification(ma_device_notification_init(pDevice, ma_device_notification_type_started)); } static void ma_device__on_notification_stopped(ma_device* pDevice) { ma_device__on_notification(ma_device_notification_init(pDevice, ma_device_notification_type_stopped)); } /* Not all platforms support reroute notifications. */ #if !defined(MA_EMSCRIPTEN) static void ma_device__on_notification_rerouted(ma_device* pDevice) { ma_device__on_notification(ma_device_notification_init(pDevice, ma_device_notification_type_rerouted)); } #endif #if defined(MA_EMSCRIPTEN) EMSCRIPTEN_KEEPALIVE void ma_device__on_notification_unlocked(ma_device* pDevice) { ma_device__on_notification(ma_device_notification_init(pDevice, ma_device_notification_type_unlocked)); } #endif static void ma_device__on_data_inner(ma_device* pDevice, void* pFramesOut, const void* pFramesIn, ma_uint32 frameCount) { MA_ASSERT(pDevice != NULL); MA_ASSERT(pDevice->onData != NULL); if (!pDevice->noPreSilencedOutputBuffer && pFramesOut != NULL) { ma_silence_pcm_frames(pFramesOut, frameCount, pDevice->playback.format, pDevice->playback.channels); } pDevice->onData(pDevice, pFramesOut, pFramesIn, frameCount); } static void ma_device__on_data(ma_device* pDevice, void* pFramesOut, const void* pFramesIn, ma_uint32 frameCount) { MA_ASSERT(pDevice != NULL); /* Don't read more data from the client if we're in the process of stopping. */ if (ma_device_get_state(pDevice) == ma_device_state_stopping) { return; } if (pDevice->noFixedSizedCallback) { /* Fast path. Not using a fixed sized callback. Process directly from the specified buffers. */ ma_device__on_data_inner(pDevice, pFramesOut, pFramesIn, frameCount); } else { /* Slow path. Using a fixed sized callback. Need to use the intermediary buffer. */ ma_uint32 totalFramesProcessed = 0; while (totalFramesProcessed < frameCount) { ma_uint32 totalFramesRemaining = frameCount - totalFramesProcessed; ma_uint32 framesToProcessThisIteration = 0; if (pFramesIn != NULL) { /* Capturing. Write to the intermediary buffer. If there's no room, fire the callback to empty it. */ if (pDevice->capture.intermediaryBufferLen < pDevice->capture.intermediaryBufferCap) { /* There's some room left in the intermediary buffer. Write to it without firing the callback. */ framesToProcessThisIteration = totalFramesRemaining; if (framesToProcessThisIteration > pDevice->capture.intermediaryBufferCap - pDevice->capture.intermediaryBufferLen) { framesToProcessThisIteration = pDevice->capture.intermediaryBufferCap - pDevice->capture.intermediaryBufferLen; } ma_copy_pcm_frames( ma_offset_pcm_frames_ptr(pDevice->capture.pIntermediaryBuffer, pDevice->capture.intermediaryBufferLen, pDevice->capture.format, pDevice->capture.channels), ma_offset_pcm_frames_const_ptr(pFramesIn, totalFramesProcessed, pDevice->capture.format, pDevice->capture.channels), framesToProcessThisIteration, pDevice->capture.format, pDevice->capture.channels); pDevice->capture.intermediaryBufferLen += framesToProcessThisIteration; } if (pDevice->capture.intermediaryBufferLen == pDevice->capture.intermediaryBufferCap) { /* No room left in the intermediary buffer. Fire the data callback. */ if (pDevice->type == ma_device_type_duplex) { /* We'll do the duplex data callback later after we've processed the playback data. */ } else { ma_device__on_data_inner(pDevice, NULL, pDevice->capture.pIntermediaryBuffer, pDevice->capture.intermediaryBufferCap); /* The intermediary buffer has just been drained. */ pDevice->capture.intermediaryBufferLen = 0; } } } if (pFramesOut != NULL) { /* Playing back. Read from the intermediary buffer. If there's nothing in it, fire the callback to fill it. */ if (pDevice->playback.intermediaryBufferLen > 0) { /* There's some content in the intermediary buffer. Read from that without firing the callback. */ if (pDevice->type == ma_device_type_duplex) { /* The frames processed this iteration for a duplex device will always be based on the capture side. Leave it unmodified. */ } else { framesToProcessThisIteration = totalFramesRemaining; if (framesToProcessThisIteration > pDevice->playback.intermediaryBufferLen) { framesToProcessThisIteration = pDevice->playback.intermediaryBufferLen; } } ma_copy_pcm_frames( ma_offset_pcm_frames_ptr(pFramesOut, totalFramesProcessed, pDevice->playback.format, pDevice->playback.channels), ma_offset_pcm_frames_ptr(pDevice->playback.pIntermediaryBuffer, pDevice->playback.intermediaryBufferCap - pDevice->playback.intermediaryBufferLen, pDevice->playback.format, pDevice->playback.channels), framesToProcessThisIteration, pDevice->playback.format, pDevice->playback.channels); pDevice->playback.intermediaryBufferLen -= framesToProcessThisIteration; } if (pDevice->playback.intermediaryBufferLen == 0) { /* There's nothing in the intermediary buffer. Fire the data callback to fill it. */ if (pDevice->type == ma_device_type_duplex) { /* In duplex mode, the data callback will be fired later. Nothing to do here. */ } else { ma_device__on_data_inner(pDevice, pDevice->playback.pIntermediaryBuffer, NULL, pDevice->playback.intermediaryBufferCap); /* The intermediary buffer has just been filled. */ pDevice->playback.intermediaryBufferLen = pDevice->playback.intermediaryBufferCap; } } } /* If we're in duplex mode we might need to do a refill of the data. */ if (pDevice->type == ma_device_type_duplex) { if (pDevice->capture.intermediaryBufferLen == pDevice->capture.intermediaryBufferCap) { ma_device__on_data_inner(pDevice, pDevice->playback.pIntermediaryBuffer, pDevice->capture.pIntermediaryBuffer, pDevice->capture.intermediaryBufferCap); pDevice->playback.intermediaryBufferLen = pDevice->playback.intermediaryBufferCap; /* The playback buffer will have just been filled. */ pDevice->capture.intermediaryBufferLen = 0; /* The intermediary buffer has just been drained. */ } } /* Make sure this is only incremented once in the duplex case. */ totalFramesProcessed += framesToProcessThisIteration; } } } static void ma_device__handle_data_callback(ma_device* pDevice, void* pFramesOut, const void* pFramesIn, ma_uint32 frameCount) { float masterVolumeFactor; ma_device_get_master_volume(pDevice, &masterVolumeFactor); /* Use ma_device_get_master_volume() to ensure the volume is loaded atomically. */ if (pDevice->onData) { unsigned int prevDenormalState = ma_device_disable_denormals(pDevice); { /* Volume control of input makes things a bit awkward because the input buffer is read-only. We'll need to use a temp buffer and loop in this case. */ if (pFramesIn != NULL && masterVolumeFactor < 1) { ma_uint8 tempFramesIn[MA_DATA_CONVERTER_STACK_BUFFER_SIZE]; ma_uint32 bpfCapture = ma_get_bytes_per_frame(pDevice->capture.format, pDevice->capture.channels); ma_uint32 bpfPlayback = ma_get_bytes_per_frame(pDevice->playback.format, pDevice->playback.channels); ma_uint32 totalFramesProcessed = 0; while (totalFramesProcessed < frameCount) { ma_uint32 framesToProcessThisIteration = frameCount - totalFramesProcessed; if (framesToProcessThisIteration > sizeof(tempFramesIn)/bpfCapture) { framesToProcessThisIteration = sizeof(tempFramesIn)/bpfCapture; } ma_copy_and_apply_volume_factor_pcm_frames(tempFramesIn, ma_offset_ptr(pFramesIn, totalFramesProcessed*bpfCapture), framesToProcessThisIteration, pDevice->capture.format, pDevice->capture.channels, masterVolumeFactor); ma_device__on_data(pDevice, ma_offset_ptr(pFramesOut, totalFramesProcessed*bpfPlayback), tempFramesIn, framesToProcessThisIteration); totalFramesProcessed += framesToProcessThisIteration; } } else { ma_device__on_data(pDevice, pFramesOut, pFramesIn, frameCount); } /* Volume control and clipping for playback devices. */ if (pFramesOut != NULL) { if (masterVolumeFactor < 1) { if (pFramesIn == NULL) { /* <-- In full-duplex situations, the volume will have been applied to the input samples before the data callback. Applying it again post-callback will incorrectly compound it. */ ma_apply_volume_factor_pcm_frames(pFramesOut, frameCount, pDevice->playback.format, pDevice->playback.channels, masterVolumeFactor); } } if (!pDevice->noClip && pDevice->playback.format == ma_format_f32) { ma_clip_samples_f32((float*)pFramesOut, (const float*)pFramesOut, frameCount * pDevice->playback.channels); /* Intentionally specifying the same pointer for both input and output for in-place processing. */ } } } ma_device_restore_denormals(pDevice, prevDenormalState); } } /* A helper function for reading sample data from the client. */ static void ma_device__read_frames_from_client(ma_device* pDevice, ma_uint32 frameCount, void* pFramesOut) { MA_ASSERT(pDevice != NULL); MA_ASSERT(frameCount > 0); MA_ASSERT(pFramesOut != NULL); if (pDevice->playback.converter.isPassthrough) { ma_device__handle_data_callback(pDevice, pFramesOut, NULL, frameCount); } else { ma_result result; ma_uint64 totalFramesReadOut; void* pRunningFramesOut; totalFramesReadOut = 0; pRunningFramesOut = pFramesOut; /* We run slightly different logic depending on whether or not we're using a heap-allocated buffer for caching input data. This will be the case if the data converter does not have the ability to retrieve the required input frame count for a given output frame count. */ if (pDevice->playback.pInputCache != NULL) { while (totalFramesReadOut < frameCount) { ma_uint64 framesToReadThisIterationIn; ma_uint64 framesToReadThisIterationOut; /* If there's any data available in the cache, that needs to get processed first. */ if (pDevice->playback.inputCacheRemaining > 0) { framesToReadThisIterationOut = (frameCount - totalFramesReadOut); framesToReadThisIterationIn = framesToReadThisIterationOut; if (framesToReadThisIterationIn > pDevice->playback.inputCacheRemaining) { framesToReadThisIterationIn = pDevice->playback.inputCacheRemaining; } result = ma_data_converter_process_pcm_frames(&pDevice->playback.converter, ma_offset_pcm_frames_ptr(pDevice->playback.pInputCache, pDevice->playback.inputCacheConsumed, pDevice->playback.format, pDevice->playback.channels), &framesToReadThisIterationIn, pRunningFramesOut, &framesToReadThisIterationOut); if (result != MA_SUCCESS) { break; } pDevice->playback.inputCacheConsumed += framesToReadThisIterationIn; pDevice->playback.inputCacheRemaining -= framesToReadThisIterationIn; totalFramesReadOut += framesToReadThisIterationOut; pRunningFramesOut = ma_offset_ptr(pRunningFramesOut, framesToReadThisIterationOut * ma_get_bytes_per_frame(pDevice->playback.internalFormat, pDevice->playback.internalChannels)); if (framesToReadThisIterationIn == 0 && framesToReadThisIterationOut == 0) { break; /* We're done. */ } } /* Getting here means there's no data in the cache and we need to fill it up with data from the client. */ if (pDevice->playback.inputCacheRemaining == 0) { ma_device__handle_data_callback(pDevice, pDevice->playback.pInputCache, NULL, (ma_uint32)pDevice->playback.inputCacheCap); pDevice->playback.inputCacheConsumed = 0; pDevice->playback.inputCacheRemaining = pDevice->playback.inputCacheCap; } } } else { while (totalFramesReadOut < frameCount) { ma_uint8 pIntermediaryBuffer[MA_DATA_CONVERTER_STACK_BUFFER_SIZE]; /* In client format. */ ma_uint64 intermediaryBufferCap = sizeof(pIntermediaryBuffer) / ma_get_bytes_per_frame(pDevice->playback.format, pDevice->playback.channels); ma_uint64 framesToReadThisIterationIn; ma_uint64 framesReadThisIterationIn; ma_uint64 framesToReadThisIterationOut; ma_uint64 framesReadThisIterationOut; ma_uint64 requiredInputFrameCount; framesToReadThisIterationOut = (frameCount - totalFramesReadOut); framesToReadThisIterationIn = framesToReadThisIterationOut; if (framesToReadThisIterationIn > intermediaryBufferCap) { framesToReadThisIterationIn = intermediaryBufferCap; } ma_data_converter_get_required_input_frame_count(&pDevice->playback.converter, framesToReadThisIterationOut, &requiredInputFrameCount); if (framesToReadThisIterationIn > requiredInputFrameCount) { framesToReadThisIterationIn = requiredInputFrameCount; } if (framesToReadThisIterationIn > 0) { ma_device__handle_data_callback(pDevice, pIntermediaryBuffer, NULL, (ma_uint32)framesToReadThisIterationIn); } /* At this point we have our decoded data in input format and now we need to convert to output format. Note that even if we didn't read any input frames, we still want to try processing frames because there may some output frames generated from cached input data. */ framesReadThisIterationIn = framesToReadThisIterationIn; framesReadThisIterationOut = framesToReadThisIterationOut; result = ma_data_converter_process_pcm_frames(&pDevice->playback.converter, pIntermediaryBuffer, &framesReadThisIterationIn, pRunningFramesOut, &framesReadThisIterationOut); if (result != MA_SUCCESS) { break; } totalFramesReadOut += framesReadThisIterationOut; pRunningFramesOut = ma_offset_ptr(pRunningFramesOut, framesReadThisIterationOut * ma_get_bytes_per_frame(pDevice->playback.internalFormat, pDevice->playback.internalChannels)); if (framesReadThisIterationIn == 0 && framesReadThisIterationOut == 0) { break; /* We're done. */ } } } } } /* A helper for sending sample data to the client. */ static void ma_device__send_frames_to_client(ma_device* pDevice, ma_uint32 frameCountInDeviceFormat, const void* pFramesInDeviceFormat) { MA_ASSERT(pDevice != NULL); MA_ASSERT(frameCountInDeviceFormat > 0); MA_ASSERT(pFramesInDeviceFormat != NULL); if (pDevice->capture.converter.isPassthrough) { ma_device__handle_data_callback(pDevice, NULL, pFramesInDeviceFormat, frameCountInDeviceFormat); } else { ma_result result; ma_uint8 pFramesInClientFormat[MA_DATA_CONVERTER_STACK_BUFFER_SIZE]; ma_uint64 framesInClientFormatCap = sizeof(pFramesInClientFormat) / ma_get_bytes_per_frame(pDevice->capture.format, pDevice->capture.channels); ma_uint64 totalDeviceFramesProcessed = 0; ma_uint64 totalClientFramesProcessed = 0; const void* pRunningFramesInDeviceFormat = pFramesInDeviceFormat; /* We just keep going until we've exhaused all of our input frames and cannot generate any more output frames. */ for (;;) { ma_uint64 deviceFramesProcessedThisIteration; ma_uint64 clientFramesProcessedThisIteration; deviceFramesProcessedThisIteration = (frameCountInDeviceFormat - totalDeviceFramesProcessed); clientFramesProcessedThisIteration = framesInClientFormatCap; result = ma_data_converter_process_pcm_frames(&pDevice->capture.converter, pRunningFramesInDeviceFormat, &deviceFramesProcessedThisIteration, pFramesInClientFormat, &clientFramesProcessedThisIteration); if (result != MA_SUCCESS) { break; } if (clientFramesProcessedThisIteration > 0) { ma_device__handle_data_callback(pDevice, NULL, pFramesInClientFormat, (ma_uint32)clientFramesProcessedThisIteration); /* Safe cast. */ } pRunningFramesInDeviceFormat = ma_offset_ptr(pRunningFramesInDeviceFormat, deviceFramesProcessedThisIteration * ma_get_bytes_per_frame(pDevice->capture.internalFormat, pDevice->capture.internalChannels)); totalDeviceFramesProcessed += deviceFramesProcessedThisIteration; totalClientFramesProcessed += clientFramesProcessedThisIteration; /* This is just to silence a warning. I might want to use this variable later so leaving in place for now. */ (void)totalClientFramesProcessed; if (deviceFramesProcessedThisIteration == 0 && clientFramesProcessedThisIteration == 0) { break; /* We're done. */ } } } } static ma_result ma_device__handle_duplex_callback_capture(ma_device* pDevice, ma_uint32 frameCountInDeviceFormat, const void* pFramesInDeviceFormat, ma_pcm_rb* pRB) { ma_result result; ma_uint32 totalDeviceFramesProcessed = 0; const void* pRunningFramesInDeviceFormat = pFramesInDeviceFormat; MA_ASSERT(pDevice != NULL); MA_ASSERT(frameCountInDeviceFormat > 0); MA_ASSERT(pFramesInDeviceFormat != NULL); MA_ASSERT(pRB != NULL); /* Write to the ring buffer. The ring buffer is in the client format which means we need to convert. */ for (;;) { ma_uint32 framesToProcessInDeviceFormat = (frameCountInDeviceFormat - totalDeviceFramesProcessed); ma_uint32 framesToProcessInClientFormat = MA_DATA_CONVERTER_STACK_BUFFER_SIZE / ma_get_bytes_per_frame(pDevice->capture.format, pDevice->capture.channels); ma_uint64 framesProcessedInDeviceFormat; ma_uint64 framesProcessedInClientFormat; void* pFramesInClientFormat; result = ma_pcm_rb_acquire_write(pRB, &framesToProcessInClientFormat, &pFramesInClientFormat); if (result != MA_SUCCESS) { ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "Failed to acquire capture PCM frames from ring buffer."); break; } if (framesToProcessInClientFormat == 0) { if (ma_pcm_rb_pointer_distance(pRB) == (ma_int32)ma_pcm_rb_get_subbuffer_size(pRB)) { break; /* Overrun. Not enough room in the ring buffer for input frame. Excess frames are dropped. */ } } /* Convert. */ framesProcessedInDeviceFormat = framesToProcessInDeviceFormat; framesProcessedInClientFormat = framesToProcessInClientFormat; result = ma_data_converter_process_pcm_frames(&pDevice->capture.converter, pRunningFramesInDeviceFormat, &framesProcessedInDeviceFormat, pFramesInClientFormat, &framesProcessedInClientFormat); if (result != MA_SUCCESS) { break; } result = ma_pcm_rb_commit_write(pRB, (ma_uint32)framesProcessedInClientFormat); /* Safe cast. */ if (result != MA_SUCCESS) { ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "Failed to commit capture PCM frames to ring buffer."); break; } pRunningFramesInDeviceFormat = ma_offset_ptr(pRunningFramesInDeviceFormat, framesProcessedInDeviceFormat * ma_get_bytes_per_frame(pDevice->capture.internalFormat, pDevice->capture.internalChannels)); totalDeviceFramesProcessed += (ma_uint32)framesProcessedInDeviceFormat; /* Safe cast. */ /* We're done when we're unable to process any client nor device frames. */ if (framesProcessedInClientFormat == 0 && framesProcessedInDeviceFormat == 0) { break; /* Done. */ } } return MA_SUCCESS; } static ma_result ma_device__handle_duplex_callback_playback(ma_device* pDevice, ma_uint32 frameCount, void* pFramesInInternalFormat, ma_pcm_rb* pRB) { ma_result result; ma_uint8 silentInputFrames[MA_DATA_CONVERTER_STACK_BUFFER_SIZE]; ma_uint32 totalFramesReadOut = 0; MA_ASSERT(pDevice != NULL); MA_ASSERT(frameCount > 0); MA_ASSERT(pFramesInInternalFormat != NULL); MA_ASSERT(pRB != NULL); MA_ASSERT(pDevice->playback.pInputCache != NULL); /* Sitting in the ring buffer should be captured data from the capture callback in external format. If there's not enough data in there for the whole frameCount frames we just use silence instead for the input data. */ MA_ZERO_MEMORY(silentInputFrames, sizeof(silentInputFrames)); while (totalFramesReadOut < frameCount && ma_device_is_started(pDevice)) { /* We should have a buffer allocated on the heap. Any playback frames still sitting in there need to be sent to the internal device before we process any more data from the client. */ if (pDevice->playback.inputCacheRemaining > 0) { ma_uint64 framesConvertedIn = pDevice->playback.inputCacheRemaining; ma_uint64 framesConvertedOut = (frameCount - totalFramesReadOut); ma_data_converter_process_pcm_frames(&pDevice->playback.converter, ma_offset_pcm_frames_ptr(pDevice->playback.pInputCache, pDevice->playback.inputCacheConsumed, pDevice->playback.format, pDevice->playback.channels), &framesConvertedIn, pFramesInInternalFormat, &framesConvertedOut); pDevice->playback.inputCacheConsumed += framesConvertedIn; pDevice->playback.inputCacheRemaining -= framesConvertedIn; totalFramesReadOut += (ma_uint32)framesConvertedOut; /* Safe cast. */ pFramesInInternalFormat = ma_offset_ptr(pFramesInInternalFormat, framesConvertedOut * ma_get_bytes_per_frame(pDevice->playback.internalFormat, pDevice->playback.internalChannels)); } /* If there's no more data in the cache we'll need to fill it with some. */ if (totalFramesReadOut < frameCount && pDevice->playback.inputCacheRemaining == 0) { ma_uint32 inputFrameCount; void* pInputFrames; inputFrameCount = (ma_uint32)pDevice->playback.inputCacheCap; result = ma_pcm_rb_acquire_read(pRB, &inputFrameCount, &pInputFrames); if (result == MA_SUCCESS) { if (inputFrameCount > 0) { ma_device__handle_data_callback(pDevice, pDevice->playback.pInputCache, pInputFrames, inputFrameCount); } else { if (ma_pcm_rb_pointer_distance(pRB) == 0) { break; /* Underrun. */ } } } else { /* No capture data available. Feed in silence. */ inputFrameCount = (ma_uint32)ma_min(pDevice->playback.inputCacheCap, sizeof(silentInputFrames) / ma_get_bytes_per_frame(pDevice->capture.format, pDevice->capture.channels)); ma_device__handle_data_callback(pDevice, pDevice->playback.pInputCache, silentInputFrames, inputFrameCount); } pDevice->playback.inputCacheConsumed = 0; pDevice->playback.inputCacheRemaining = inputFrameCount; result = ma_pcm_rb_commit_read(pRB, inputFrameCount); if (result != MA_SUCCESS) { return result; /* Should never happen. */ } } } return MA_SUCCESS; } /* A helper for changing the state of the device. */ static MA_INLINE void ma_device__set_state(ma_device* pDevice, ma_device_state newState) { ma_atomic_device_state_set(&pDevice->state, newState); } #if defined(MA_WIN32) static GUID MA_GUID_KSDATAFORMAT_SUBTYPE_PCM = {0x00000001, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}}; static GUID MA_GUID_KSDATAFORMAT_SUBTYPE_IEEE_FLOAT = {0x00000003, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}}; /*static GUID MA_GUID_KSDATAFORMAT_SUBTYPE_ALAW = {0x00000006, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}};*/ /*static GUID MA_GUID_KSDATAFORMAT_SUBTYPE_MULAW = {0x00000007, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}};*/ #endif MA_API ma_uint32 ma_get_format_priority_index(ma_format format) /* Lower = better. */ { ma_uint32 i; for (i = 0; i < ma_countof(g_maFormatPriorities); ++i) { if (g_maFormatPriorities[i] == format) { return i; } } /* Getting here means the format could not be found or is equal to ma_format_unknown. */ return (ma_uint32)-1; } static ma_result ma_device__post_init_setup(ma_device* pDevice, ma_device_type deviceType); static ma_bool32 ma_device_descriptor_is_valid(const ma_device_descriptor* pDeviceDescriptor) { if (pDeviceDescriptor == NULL) { return MA_FALSE; } if (pDeviceDescriptor->format == ma_format_unknown) { return MA_FALSE; } if (pDeviceDescriptor->channels == 0 || pDeviceDescriptor->channels > MA_MAX_CHANNELS) { return MA_FALSE; } if (pDeviceDescriptor->sampleRate == 0) { return MA_FALSE; } return MA_TRUE; } static ma_result ma_device_audio_thread__default_read_write(ma_device* pDevice) { ma_result result = MA_SUCCESS; ma_bool32 exitLoop = MA_FALSE; ma_uint8 capturedDeviceData[MA_DATA_CONVERTER_STACK_BUFFER_SIZE]; ma_uint8 playbackDeviceData[MA_DATA_CONVERTER_STACK_BUFFER_SIZE]; ma_uint32 capturedDeviceDataCapInFrames = 0; ma_uint32 playbackDeviceDataCapInFrames = 0; MA_ASSERT(pDevice != NULL); /* Just some quick validation on the device type and the available callbacks. */ if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex || pDevice->type == ma_device_type_loopback) { if (pDevice->pContext->callbacks.onDeviceRead == NULL) { return MA_NOT_IMPLEMENTED; } capturedDeviceDataCapInFrames = sizeof(capturedDeviceData) / ma_get_bytes_per_frame(pDevice->capture.internalFormat, pDevice->capture.internalChannels); } if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) { if (pDevice->pContext->callbacks.onDeviceWrite == NULL) { return MA_NOT_IMPLEMENTED; } playbackDeviceDataCapInFrames = sizeof(playbackDeviceData) / ma_get_bytes_per_frame(pDevice->playback.internalFormat, pDevice->playback.internalChannels); } /* NOTE: The device was started outside of this function, in the worker thread. */ while (ma_device_get_state(pDevice) == ma_device_state_started && !exitLoop) { switch (pDevice->type) { case ma_device_type_duplex: { /* The process is: onDeviceRead() -> convert -> callback -> convert -> onDeviceWrite() */ ma_uint32 totalCapturedDeviceFramesProcessed = 0; ma_uint32 capturedDevicePeriodSizeInFrames = ma_min(pDevice->capture.internalPeriodSizeInFrames, pDevice->playback.internalPeriodSizeInFrames); while (totalCapturedDeviceFramesProcessed < capturedDevicePeriodSizeInFrames) { ma_uint32 capturedDeviceFramesRemaining; ma_uint32 capturedDeviceFramesProcessed; ma_uint32 capturedDeviceFramesToProcess; ma_uint32 capturedDeviceFramesToTryProcessing = capturedDevicePeriodSizeInFrames - totalCapturedDeviceFramesProcessed; if (capturedDeviceFramesToTryProcessing > capturedDeviceDataCapInFrames) { capturedDeviceFramesToTryProcessing = capturedDeviceDataCapInFrames; } result = pDevice->pContext->callbacks.onDeviceRead(pDevice, capturedDeviceData, capturedDeviceFramesToTryProcessing, &capturedDeviceFramesToProcess); if (result != MA_SUCCESS) { exitLoop = MA_TRUE; break; } capturedDeviceFramesRemaining = capturedDeviceFramesToProcess; capturedDeviceFramesProcessed = 0; /* At this point we have our captured data in device format and we now need to convert it to client format. */ for (;;) { ma_uint8 capturedClientData[MA_DATA_CONVERTER_STACK_BUFFER_SIZE]; ma_uint8 playbackClientData[MA_DATA_CONVERTER_STACK_BUFFER_SIZE]; ma_uint32 capturedClientDataCapInFrames = sizeof(capturedClientData) / ma_get_bytes_per_frame(pDevice->capture.format, pDevice->capture.channels); ma_uint32 playbackClientDataCapInFrames = sizeof(playbackClientData) / ma_get_bytes_per_frame(pDevice->playback.format, pDevice->playback.channels); ma_uint64 capturedClientFramesToProcessThisIteration = ma_min(capturedClientDataCapInFrames, playbackClientDataCapInFrames); ma_uint64 capturedDeviceFramesToProcessThisIteration = capturedDeviceFramesRemaining; ma_uint8* pRunningCapturedDeviceFrames = ma_offset_ptr(capturedDeviceData, capturedDeviceFramesProcessed * ma_get_bytes_per_frame(pDevice->capture.internalFormat, pDevice->capture.internalChannels)); /* Convert capture data from device format to client format. */ result = ma_data_converter_process_pcm_frames(&pDevice->capture.converter, pRunningCapturedDeviceFrames, &capturedDeviceFramesToProcessThisIteration, capturedClientData, &capturedClientFramesToProcessThisIteration); if (result != MA_SUCCESS) { break; } /* If we weren't able to generate any output frames it must mean we've exhaused all of our input. The only time this would not be the case is if capturedClientData was too small which should never be the case when it's of the size MA_DATA_CONVERTER_STACK_BUFFER_SIZE. */ if (capturedClientFramesToProcessThisIteration == 0) { break; } ma_device__handle_data_callback(pDevice, playbackClientData, capturedClientData, (ma_uint32)capturedClientFramesToProcessThisIteration); /* Safe cast .*/ capturedDeviceFramesProcessed += (ma_uint32)capturedDeviceFramesToProcessThisIteration; /* Safe cast. */ capturedDeviceFramesRemaining -= (ma_uint32)capturedDeviceFramesToProcessThisIteration; /* Safe cast. */ /* At this point the playbackClientData buffer should be holding data that needs to be written to the device. */ for (;;) { ma_uint64 convertedClientFrameCount = capturedClientFramesToProcessThisIteration; ma_uint64 convertedDeviceFrameCount = playbackDeviceDataCapInFrames; result = ma_data_converter_process_pcm_frames(&pDevice->playback.converter, playbackClientData, &convertedClientFrameCount, playbackDeviceData, &convertedDeviceFrameCount); if (result != MA_SUCCESS) { break; } result = pDevice->pContext->callbacks.onDeviceWrite(pDevice, playbackDeviceData, (ma_uint32)convertedDeviceFrameCount, NULL); /* Safe cast. */ if (result != MA_SUCCESS) { exitLoop = MA_TRUE; break; } capturedClientFramesToProcessThisIteration -= (ma_uint32)convertedClientFrameCount; /* Safe cast. */ if (capturedClientFramesToProcessThisIteration == 0) { break; } } /* In case an error happened from ma_device_write__null()... */ if (result != MA_SUCCESS) { exitLoop = MA_TRUE; break; } } /* Make sure we don't get stuck in the inner loop. */ if (capturedDeviceFramesProcessed == 0) { break; } totalCapturedDeviceFramesProcessed += capturedDeviceFramesProcessed; } } break; case ma_device_type_capture: case ma_device_type_loopback: { ma_uint32 periodSizeInFrames = pDevice->capture.internalPeriodSizeInFrames; ma_uint32 framesReadThisPeriod = 0; while (framesReadThisPeriod < periodSizeInFrames) { ma_uint32 framesRemainingInPeriod = periodSizeInFrames - framesReadThisPeriod; ma_uint32 framesProcessed; ma_uint32 framesToReadThisIteration = framesRemainingInPeriod; if (framesToReadThisIteration > capturedDeviceDataCapInFrames) { framesToReadThisIteration = capturedDeviceDataCapInFrames; } result = pDevice->pContext->callbacks.onDeviceRead(pDevice, capturedDeviceData, framesToReadThisIteration, &framesProcessed); if (result != MA_SUCCESS) { exitLoop = MA_TRUE; break; } /* Make sure we don't get stuck in the inner loop. */ if (framesProcessed == 0) { break; } ma_device__send_frames_to_client(pDevice, framesProcessed, capturedDeviceData); framesReadThisPeriod += framesProcessed; } } break; case ma_device_type_playback: { /* We write in chunks of the period size, but use a stack allocated buffer for the intermediary. */ ma_uint32 periodSizeInFrames = pDevice->playback.internalPeriodSizeInFrames; ma_uint32 framesWrittenThisPeriod = 0; while (framesWrittenThisPeriod < periodSizeInFrames) { ma_uint32 framesRemainingInPeriod = periodSizeInFrames - framesWrittenThisPeriod; ma_uint32 framesProcessed; ma_uint32 framesToWriteThisIteration = framesRemainingInPeriod; if (framesToWriteThisIteration > playbackDeviceDataCapInFrames) { framesToWriteThisIteration = playbackDeviceDataCapInFrames; } ma_device__read_frames_from_client(pDevice, framesToWriteThisIteration, playbackDeviceData); result = pDevice->pContext->callbacks.onDeviceWrite(pDevice, playbackDeviceData, framesToWriteThisIteration, &framesProcessed); if (result != MA_SUCCESS) { exitLoop = MA_TRUE; break; } /* Make sure we don't get stuck in the inner loop. */ if (framesProcessed == 0) { break; } framesWrittenThisPeriod += framesProcessed; } } break; /* Should never get here. */ default: break; } } return result; } /******************************************************************************* Null Backend *******************************************************************************/ #ifdef MA_HAS_NULL #define MA_DEVICE_OP_NONE__NULL 0 #define MA_DEVICE_OP_START__NULL 1 #define MA_DEVICE_OP_SUSPEND__NULL 2 #define MA_DEVICE_OP_KILL__NULL 3 static ma_thread_result MA_THREADCALL ma_device_thread__null(void* pData) { ma_device* pDevice = (ma_device*)pData; MA_ASSERT(pDevice != NULL); for (;;) { /* Keep the thread alive until the device is uninitialized. */ ma_uint32 operation; /* Wait for an operation to be requested. */ ma_event_wait(&pDevice->null_device.operationEvent); /* At this point an event should have been triggered. */ operation = pDevice->null_device.operation; /* Starting the device needs to put the thread into a loop. */ if (operation == MA_DEVICE_OP_START__NULL) { /* Reset the timer just in case. */ ma_timer_init(&pDevice->null_device.timer); /* Getting here means a suspend or kill operation has been requested. */ pDevice->null_device.operationResult = MA_SUCCESS; ma_event_signal(&pDevice->null_device.operationCompletionEvent); ma_semaphore_release(&pDevice->null_device.operationSemaphore); continue; } /* Suspending the device means we need to stop the timer and just continue the loop. */ if (operation == MA_DEVICE_OP_SUSPEND__NULL) { /* We need to add the current run time to the prior run time, then reset the timer. */ pDevice->null_device.priorRunTime += ma_timer_get_time_in_seconds(&pDevice->null_device.timer); ma_timer_init(&pDevice->null_device.timer); /* We're done. */ pDevice->null_device.operationResult = MA_SUCCESS; ma_event_signal(&pDevice->null_device.operationCompletionEvent); ma_semaphore_release(&pDevice->null_device.operationSemaphore); continue; } /* Killing the device means we need to get out of this loop so that this thread can terminate. */ if (operation == MA_DEVICE_OP_KILL__NULL) { pDevice->null_device.operationResult = MA_SUCCESS; ma_event_signal(&pDevice->null_device.operationCompletionEvent); ma_semaphore_release(&pDevice->null_device.operationSemaphore); break; } /* Getting a signal on a "none" operation probably means an error. Return invalid operation. */ if (operation == MA_DEVICE_OP_NONE__NULL) { MA_ASSERT(MA_FALSE); /* <-- Trigger this in debug mode to ensure developers are aware they're doing something wrong (or there's a bug in a miniaudio). */ pDevice->null_device.operationResult = MA_INVALID_OPERATION; ma_event_signal(&pDevice->null_device.operationCompletionEvent); ma_semaphore_release(&pDevice->null_device.operationSemaphore); continue; /* Continue the loop. Don't terminate. */ } } return (ma_thread_result)0; } static ma_result ma_device_do_operation__null(ma_device* pDevice, ma_uint32 operation) { ma_result result; /* TODO: Need to review this and consider just using mutual exclusion. I think the original motivation for this was to just post the event to a queue and return immediately, but that has since changed and now this function is synchronous. I think this can be simplified to just use a mutex. */ /* The first thing to do is wait for an operation slot to become available. We only have a single slot for this, but we could extend this later to support queing of operations. */ result = ma_semaphore_wait(&pDevice->null_device.operationSemaphore); if (result != MA_SUCCESS) { return result; /* Failed to wait for the event. */ } /* When we get here it means the background thread is not referencing the operation code and it can be changed. After changing this we need to signal an event to the worker thread to let it know that it can start work. */ pDevice->null_device.operation = operation; /* Once the operation code has been set, the worker thread can start work. */ if (ma_event_signal(&pDevice->null_device.operationEvent) != MA_SUCCESS) { return MA_ERROR; } /* We want everything to be synchronous so we're going to wait for the worker thread to complete it's operation. */ if (ma_event_wait(&pDevice->null_device.operationCompletionEvent) != MA_SUCCESS) { return MA_ERROR; } return pDevice->null_device.operationResult; } static ma_uint64 ma_device_get_total_run_time_in_frames__null(ma_device* pDevice) { ma_uint32 internalSampleRate; if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) { internalSampleRate = pDevice->capture.internalSampleRate; } else { internalSampleRate = pDevice->playback.internalSampleRate; } return (ma_uint64)((pDevice->null_device.priorRunTime + ma_timer_get_time_in_seconds(&pDevice->null_device.timer)) * internalSampleRate); } static ma_result ma_context_enumerate_devices__null(ma_context* pContext, ma_enum_devices_callback_proc callback, void* pUserData) { ma_bool32 cbResult = MA_TRUE; MA_ASSERT(pContext != NULL); MA_ASSERT(callback != NULL); /* Playback. */ if (cbResult) { ma_device_info deviceInfo; MA_ZERO_OBJECT(&deviceInfo); ma_strncpy_s(deviceInfo.name, sizeof(deviceInfo.name), "NULL Playback Device", (size_t)-1); deviceInfo.isDefault = MA_TRUE; /* Only one playback and capture device for the null backend, so might as well mark as default. */ cbResult = callback(pContext, ma_device_type_playback, &deviceInfo, pUserData); } /* Capture. */ if (cbResult) { ma_device_info deviceInfo; MA_ZERO_OBJECT(&deviceInfo); ma_strncpy_s(deviceInfo.name, sizeof(deviceInfo.name), "NULL Capture Device", (size_t)-1); deviceInfo.isDefault = MA_TRUE; /* Only one playback and capture device for the null backend, so might as well mark as default. */ cbResult = callback(pContext, ma_device_type_capture, &deviceInfo, pUserData); } (void)cbResult; /* Silence a static analysis warning. */ return MA_SUCCESS; } static ma_result ma_context_get_device_info__null(ma_context* pContext, ma_device_type deviceType, const ma_device_id* pDeviceID, ma_device_info* pDeviceInfo) { MA_ASSERT(pContext != NULL); if (pDeviceID != NULL && pDeviceID->nullbackend != 0) { return MA_NO_DEVICE; /* Don't know the device. */ } /* Name / Description */ if (deviceType == ma_device_type_playback) { ma_strncpy_s(pDeviceInfo->name, sizeof(pDeviceInfo->name), "NULL Playback Device", (size_t)-1); } else { ma_strncpy_s(pDeviceInfo->name, sizeof(pDeviceInfo->name), "NULL Capture Device", (size_t)-1); } pDeviceInfo->isDefault = MA_TRUE; /* Only one playback and capture device for the null backend, so might as well mark as default. */ /* Support everything on the null backend. */ pDeviceInfo->nativeDataFormats[0].format = ma_format_unknown; pDeviceInfo->nativeDataFormats[0].channels = 0; pDeviceInfo->nativeDataFormats[0].sampleRate = 0; pDeviceInfo->nativeDataFormats[0].flags = 0; pDeviceInfo->nativeDataFormatCount = 1; (void)pContext; return MA_SUCCESS; } static ma_result ma_device_uninit__null(ma_device* pDevice) { MA_ASSERT(pDevice != NULL); /* Keep it clean and wait for the device thread to finish before returning. */ ma_device_do_operation__null(pDevice, MA_DEVICE_OP_KILL__NULL); /* Wait for the thread to finish before continuing. */ ma_thread_wait(&pDevice->null_device.deviceThread); /* At this point the loop in the device thread is as good as terminated so we can uninitialize our events. */ ma_semaphore_uninit(&pDevice->null_device.operationSemaphore); ma_event_uninit(&pDevice->null_device.operationCompletionEvent); ma_event_uninit(&pDevice->null_device.operationEvent); return MA_SUCCESS; } static ma_result ma_device_init__null(ma_device* pDevice, const ma_device_config* pConfig, ma_device_descriptor* pDescriptorPlayback, ma_device_descriptor* pDescriptorCapture) { ma_result result; MA_ASSERT(pDevice != NULL); MA_ZERO_OBJECT(&pDevice->null_device); if (pConfig->deviceType == ma_device_type_loopback) { return MA_DEVICE_TYPE_NOT_SUPPORTED; } /* The null backend supports everything exactly as we specify it. */ if (pConfig->deviceType == ma_device_type_capture || pConfig->deviceType == ma_device_type_duplex) { pDescriptorCapture->format = (pDescriptorCapture->format != ma_format_unknown) ? pDescriptorCapture->format : MA_DEFAULT_FORMAT; pDescriptorCapture->channels = (pDescriptorCapture->channels != 0) ? pDescriptorCapture->channels : MA_DEFAULT_CHANNELS; pDescriptorCapture->sampleRate = (pDescriptorCapture->sampleRate != 0) ? pDescriptorCapture->sampleRate : MA_DEFAULT_SAMPLE_RATE; if (pDescriptorCapture->channelMap[0] == MA_CHANNEL_NONE) { ma_channel_map_init_standard(ma_standard_channel_map_default, pDescriptorCapture->channelMap, ma_countof(pDescriptorCapture->channelMap), pDescriptorCapture->channels); } pDescriptorCapture->periodSizeInFrames = ma_calculate_buffer_size_in_frames_from_descriptor(pDescriptorCapture, pDescriptorCapture->sampleRate, pConfig->performanceProfile); } if (pConfig->deviceType == ma_device_type_playback || pConfig->deviceType == ma_device_type_duplex) { pDescriptorPlayback->format = (pDescriptorPlayback->format != ma_format_unknown) ? pDescriptorPlayback->format : MA_DEFAULT_FORMAT; pDescriptorPlayback->channels = (pDescriptorPlayback->channels != 0) ? pDescriptorPlayback->channels : MA_DEFAULT_CHANNELS; pDescriptorPlayback->sampleRate = (pDescriptorPlayback->sampleRate != 0) ? pDescriptorPlayback->sampleRate : MA_DEFAULT_SAMPLE_RATE; if (pDescriptorPlayback->channelMap[0] == MA_CHANNEL_NONE) { ma_channel_map_init_standard(ma_standard_channel_map_default, pDescriptorPlayback->channelMap, ma_countof(pDescriptorCapture->channelMap), pDescriptorPlayback->channels); } pDescriptorPlayback->periodSizeInFrames = ma_calculate_buffer_size_in_frames_from_descriptor(pDescriptorPlayback, pDescriptorPlayback->sampleRate, pConfig->performanceProfile); } /* In order to get timing right, we need to create a thread that does nothing but keeps track of the timer. This timer is started when the first period is "written" to it, and then stopped in ma_device_stop__null(). */ result = ma_event_init(&pDevice->null_device.operationEvent); if (result != MA_SUCCESS) { return result; } result = ma_event_init(&pDevice->null_device.operationCompletionEvent); if (result != MA_SUCCESS) { return result; } result = ma_semaphore_init(1, &pDevice->null_device.operationSemaphore); /* <-- It's important that the initial value is set to 1. */ if (result != MA_SUCCESS) { return result; } result = ma_thread_create(&pDevice->null_device.deviceThread, pDevice->pContext->threadPriority, 0, ma_device_thread__null, pDevice, &pDevice->pContext->allocationCallbacks); if (result != MA_SUCCESS) { return result; } return MA_SUCCESS; } static ma_result ma_device_start__null(ma_device* pDevice) { MA_ASSERT(pDevice != NULL); ma_device_do_operation__null(pDevice, MA_DEVICE_OP_START__NULL); ma_atomic_bool32_set(&pDevice->null_device.isStarted, MA_TRUE); return MA_SUCCESS; } static ma_result ma_device_stop__null(ma_device* pDevice) { MA_ASSERT(pDevice != NULL); ma_device_do_operation__null(pDevice, MA_DEVICE_OP_SUSPEND__NULL); ma_atomic_bool32_set(&pDevice->null_device.isStarted, MA_FALSE); return MA_SUCCESS; } static ma_bool32 ma_device_is_started__null(ma_device* pDevice) { MA_ASSERT(pDevice != NULL); return ma_atomic_bool32_get(&pDevice->null_device.isStarted); } static ma_result ma_device_write__null(ma_device* pDevice, const void* pPCMFrames, ma_uint32 frameCount, ma_uint32* pFramesWritten) { ma_result result = MA_SUCCESS; ma_uint32 totalPCMFramesProcessed; ma_bool32 wasStartedOnEntry; if (pFramesWritten != NULL) { *pFramesWritten = 0; } wasStartedOnEntry = ma_device_is_started__null(pDevice); /* Keep going until everything has been read. */ totalPCMFramesProcessed = 0; while (totalPCMFramesProcessed < frameCount) { ma_uint64 targetFrame; /* If there are any frames remaining in the current period, consume those first. */ if (pDevice->null_device.currentPeriodFramesRemainingPlayback > 0) { ma_uint32 framesRemaining = (frameCount - totalPCMFramesProcessed); ma_uint32 framesToProcess = pDevice->null_device.currentPeriodFramesRemainingPlayback; if (framesToProcess > framesRemaining) { framesToProcess = framesRemaining; } /* We don't actually do anything with pPCMFrames, so just mark it as unused to prevent a warning. */ (void)pPCMFrames; pDevice->null_device.currentPeriodFramesRemainingPlayback -= framesToProcess; totalPCMFramesProcessed += framesToProcess; } /* If we've consumed the current period we'll need to mark it as such an ensure the device is started if it's not already. */ if (pDevice->null_device.currentPeriodFramesRemainingPlayback == 0) { pDevice->null_device.currentPeriodFramesRemainingPlayback = 0; if (!ma_device_is_started__null(pDevice) && !wasStartedOnEntry) { result = ma_device_start__null(pDevice); if (result != MA_SUCCESS) { break; } } } /* If we've consumed the whole buffer we can return now. */ MA_ASSERT(totalPCMFramesProcessed <= frameCount); if (totalPCMFramesProcessed == frameCount) { break; } /* Getting here means we've still got more frames to consume, we but need to wait for it to become available. */ targetFrame = pDevice->null_device.lastProcessedFramePlayback; for (;;) { ma_uint64 currentFrame; /* Stop waiting if the device has been stopped. */ if (!ma_device_is_started__null(pDevice)) { break; } currentFrame = ma_device_get_total_run_time_in_frames__null(pDevice); if (currentFrame >= targetFrame) { break; } /* Getting here means we haven't yet reached the target sample, so continue waiting. */ ma_sleep(10); } pDevice->null_device.lastProcessedFramePlayback += pDevice->playback.internalPeriodSizeInFrames; pDevice->null_device.currentPeriodFramesRemainingPlayback = pDevice->playback.internalPeriodSizeInFrames; } if (pFramesWritten != NULL) { *pFramesWritten = totalPCMFramesProcessed; } return result; } static ma_result ma_device_read__null(ma_device* pDevice, void* pPCMFrames, ma_uint32 frameCount, ma_uint32* pFramesRead) { ma_result result = MA_SUCCESS; ma_uint32 totalPCMFramesProcessed; if (pFramesRead != NULL) { *pFramesRead = 0; } /* Keep going until everything has been read. */ totalPCMFramesProcessed = 0; while (totalPCMFramesProcessed < frameCount) { ma_uint64 targetFrame; /* If there are any frames remaining in the current period, consume those first. */ if (pDevice->null_device.currentPeriodFramesRemainingCapture > 0) { ma_uint32 bpf = ma_get_bytes_per_frame(pDevice->capture.internalFormat, pDevice->capture.internalChannels); ma_uint32 framesRemaining = (frameCount - totalPCMFramesProcessed); ma_uint32 framesToProcess = pDevice->null_device.currentPeriodFramesRemainingCapture; if (framesToProcess > framesRemaining) { framesToProcess = framesRemaining; } /* We need to ensure the output buffer is zeroed. */ MA_ZERO_MEMORY(ma_offset_ptr(pPCMFrames, totalPCMFramesProcessed*bpf), framesToProcess*bpf); pDevice->null_device.currentPeriodFramesRemainingCapture -= framesToProcess; totalPCMFramesProcessed += framesToProcess; } /* If we've consumed the current period we'll need to mark it as such an ensure the device is started if it's not already. */ if (pDevice->null_device.currentPeriodFramesRemainingCapture == 0) { pDevice->null_device.currentPeriodFramesRemainingCapture = 0; } /* If we've consumed the whole buffer we can return now. */ MA_ASSERT(totalPCMFramesProcessed <= frameCount); if (totalPCMFramesProcessed == frameCount) { break; } /* Getting here means we've still got more frames to consume, we but need to wait for it to become available. */ targetFrame = pDevice->null_device.lastProcessedFrameCapture + pDevice->capture.internalPeriodSizeInFrames; for (;;) { ma_uint64 currentFrame; /* Stop waiting if the device has been stopped. */ if (!ma_device_is_started__null(pDevice)) { break; } currentFrame = ma_device_get_total_run_time_in_frames__null(pDevice); if (currentFrame >= targetFrame) { break; } /* Getting here means we haven't yet reached the target sample, so continue waiting. */ ma_sleep(10); } pDevice->null_device.lastProcessedFrameCapture += pDevice->capture.internalPeriodSizeInFrames; pDevice->null_device.currentPeriodFramesRemainingCapture = pDevice->capture.internalPeriodSizeInFrames; } if (pFramesRead != NULL) { *pFramesRead = totalPCMFramesProcessed; } return result; } static ma_result ma_context_uninit__null(ma_context* pContext) { MA_ASSERT(pContext != NULL); MA_ASSERT(pContext->backend == ma_backend_null); (void)pContext; return MA_SUCCESS; } static ma_result ma_context_init__null(ma_context* pContext, const ma_context_config* pConfig, ma_backend_callbacks* pCallbacks) { MA_ASSERT(pContext != NULL); (void)pConfig; (void)pContext; pCallbacks->onContextInit = ma_context_init__null; pCallbacks->onContextUninit = ma_context_uninit__null; pCallbacks->onContextEnumerateDevices = ma_context_enumerate_devices__null; pCallbacks->onContextGetDeviceInfo = ma_context_get_device_info__null; pCallbacks->onDeviceInit = ma_device_init__null; pCallbacks->onDeviceUninit = ma_device_uninit__null; pCallbacks->onDeviceStart = ma_device_start__null; pCallbacks->onDeviceStop = ma_device_stop__null; pCallbacks->onDeviceRead = ma_device_read__null; pCallbacks->onDeviceWrite = ma_device_write__null; pCallbacks->onDeviceDataLoop = NULL; /* Our backend is asynchronous with a blocking read-write API which means we can get miniaudio to deal with the audio thread. */ /* The null backend always works. */ return MA_SUCCESS; } #endif /******************************************************************************* WIN32 COMMON *******************************************************************************/ #if defined(MA_WIN32) #if defined(MA_WIN32_DESKTOP) || defined(MA_WIN32_GDK) #define ma_CoInitializeEx(pContext, pvReserved, dwCoInit) ((pContext->win32.CoInitializeEx) ? ((MA_PFN_CoInitializeEx)pContext->win32.CoInitializeEx)(pvReserved, dwCoInit) : ((MA_PFN_CoInitialize)pContext->win32.CoInitialize)(pvReserved)) #define ma_CoUninitialize(pContext) ((MA_PFN_CoUninitialize)pContext->win32.CoUninitialize)() #define ma_CoCreateInstance(pContext, rclsid, pUnkOuter, dwClsContext, riid, ppv) ((MA_PFN_CoCreateInstance)pContext->win32.CoCreateInstance)(rclsid, pUnkOuter, dwClsContext, riid, ppv) #define ma_CoTaskMemFree(pContext, pv) ((MA_PFN_CoTaskMemFree)pContext->win32.CoTaskMemFree)(pv) #define ma_PropVariantClear(pContext, pvar) ((MA_PFN_PropVariantClear)pContext->win32.PropVariantClear)(pvar) #else #define ma_CoInitializeEx(pContext, pvReserved, dwCoInit) CoInitializeEx(pvReserved, dwCoInit) #define ma_CoUninitialize(pContext) CoUninitialize() #define ma_CoCreateInstance(pContext, rclsid, pUnkOuter, dwClsContext, riid, ppv) CoCreateInstance(rclsid, pUnkOuter, dwClsContext, riid, ppv) #define ma_CoTaskMemFree(pContext, pv) CoTaskMemFree(pv) #define ma_PropVariantClear(pContext, pvar) PropVariantClear(pvar) #endif #if !defined(MAXULONG_PTR) && !defined(__WATCOMC__) typedef size_t DWORD_PTR; #endif #if !defined(WAVE_FORMAT_1M08) #define WAVE_FORMAT_1M08 0x00000001 #define WAVE_FORMAT_1S08 0x00000002 #define WAVE_FORMAT_1M16 0x00000004 #define WAVE_FORMAT_1S16 0x00000008 #define WAVE_FORMAT_2M08 0x00000010 #define WAVE_FORMAT_2S08 0x00000020 #define WAVE_FORMAT_2M16 0x00000040 #define WAVE_FORMAT_2S16 0x00000080 #define WAVE_FORMAT_4M08 0x00000100 #define WAVE_FORMAT_4S08 0x00000200 #define WAVE_FORMAT_4M16 0x00000400 #define WAVE_FORMAT_4S16 0x00000800 #endif #if !defined(WAVE_FORMAT_44M08) #define WAVE_FORMAT_44M08 0x00000100 #define WAVE_FORMAT_44S08 0x00000200 #define WAVE_FORMAT_44M16 0x00000400 #define WAVE_FORMAT_44S16 0x00000800 #define WAVE_FORMAT_48M08 0x00001000 #define WAVE_FORMAT_48S08 0x00002000 #define WAVE_FORMAT_48M16 0x00004000 #define WAVE_FORMAT_48S16 0x00008000 #define WAVE_FORMAT_96M08 0x00010000 #define WAVE_FORMAT_96S08 0x00020000 #define WAVE_FORMAT_96M16 0x00040000 #define WAVE_FORMAT_96S16 0x00080000 #endif #ifndef SPEAKER_FRONT_LEFT #define SPEAKER_FRONT_LEFT 0x1 #define SPEAKER_FRONT_RIGHT 0x2 #define SPEAKER_FRONT_CENTER 0x4 #define SPEAKER_LOW_FREQUENCY 0x8 #define SPEAKER_BACK_LEFT 0x10 #define SPEAKER_BACK_RIGHT 0x20 #define SPEAKER_FRONT_LEFT_OF_CENTER 0x40 #define SPEAKER_FRONT_RIGHT_OF_CENTER 0x80 #define SPEAKER_BACK_CENTER 0x100 #define SPEAKER_SIDE_LEFT 0x200 #define SPEAKER_SIDE_RIGHT 0x400 #define SPEAKER_TOP_CENTER 0x800 #define SPEAKER_TOP_FRONT_LEFT 0x1000 #define SPEAKER_TOP_FRONT_CENTER 0x2000 #define SPEAKER_TOP_FRONT_RIGHT 0x4000 #define SPEAKER_TOP_BACK_LEFT 0x8000 #define SPEAKER_TOP_BACK_CENTER 0x10000 #define SPEAKER_TOP_BACK_RIGHT 0x20000 #endif /* Implement our own version of MA_WAVEFORMATEXTENSIBLE so we can avoid a header. Be careful with this because MA_WAVEFORMATEX has an extra two bytes over standard WAVEFORMATEX due to padding. The standard version uses tight packing, but for compiler compatibility we're not doing that with ours. */ typedef struct { WORD wFormatTag; WORD nChannels; DWORD nSamplesPerSec; DWORD nAvgBytesPerSec; WORD nBlockAlign; WORD wBitsPerSample; WORD cbSize; } MA_WAVEFORMATEX; typedef struct { WORD wFormatTag; WORD nChannels; DWORD nSamplesPerSec; DWORD nAvgBytesPerSec; WORD nBlockAlign; WORD wBitsPerSample; WORD cbSize; union { WORD wValidBitsPerSample; WORD wSamplesPerBlock; WORD wReserved; } Samples; DWORD dwChannelMask; GUID SubFormat; } MA_WAVEFORMATEXTENSIBLE; #ifndef WAVE_FORMAT_EXTENSIBLE #define WAVE_FORMAT_EXTENSIBLE 0xFFFE #endif #ifndef WAVE_FORMAT_PCM #define WAVE_FORMAT_PCM 1 #endif #ifndef WAVE_FORMAT_IEEE_FLOAT #define WAVE_FORMAT_IEEE_FLOAT 0x0003 #endif /* Converts an individual Win32-style channel identifier (SPEAKER_FRONT_LEFT, etc.) to miniaudio. */ static ma_uint8 ma_channel_id_to_ma__win32(DWORD id) { switch (id) { case SPEAKER_FRONT_LEFT: return MA_CHANNEL_FRONT_LEFT; case SPEAKER_FRONT_RIGHT: return MA_CHANNEL_FRONT_RIGHT; case SPEAKER_FRONT_CENTER: return MA_CHANNEL_FRONT_CENTER; case SPEAKER_LOW_FREQUENCY: return MA_CHANNEL_LFE; case SPEAKER_BACK_LEFT: return MA_CHANNEL_BACK_LEFT; case SPEAKER_BACK_RIGHT: return MA_CHANNEL_BACK_RIGHT; case SPEAKER_FRONT_LEFT_OF_CENTER: return MA_CHANNEL_FRONT_LEFT_CENTER; case SPEAKER_FRONT_RIGHT_OF_CENTER: return MA_CHANNEL_FRONT_RIGHT_CENTER; case SPEAKER_BACK_CENTER: return MA_CHANNEL_BACK_CENTER; case SPEAKER_SIDE_LEFT: return MA_CHANNEL_SIDE_LEFT; case SPEAKER_SIDE_RIGHT: return MA_CHANNEL_SIDE_RIGHT; case SPEAKER_TOP_CENTER: return MA_CHANNEL_TOP_CENTER; case SPEAKER_TOP_FRONT_LEFT: return MA_CHANNEL_TOP_FRONT_LEFT; case SPEAKER_TOP_FRONT_CENTER: return MA_CHANNEL_TOP_FRONT_CENTER; case SPEAKER_TOP_FRONT_RIGHT: return MA_CHANNEL_TOP_FRONT_RIGHT; case SPEAKER_TOP_BACK_LEFT: return MA_CHANNEL_TOP_BACK_LEFT; case SPEAKER_TOP_BACK_CENTER: return MA_CHANNEL_TOP_BACK_CENTER; case SPEAKER_TOP_BACK_RIGHT: return MA_CHANNEL_TOP_BACK_RIGHT; default: return 0; } } /* Converts an individual miniaudio channel identifier (MA_CHANNEL_FRONT_LEFT, etc.) to Win32-style. */ static DWORD ma_channel_id_to_win32(DWORD id) { switch (id) { case MA_CHANNEL_MONO: return SPEAKER_FRONT_CENTER; case MA_CHANNEL_FRONT_LEFT: return SPEAKER_FRONT_LEFT; case MA_CHANNEL_FRONT_RIGHT: return SPEAKER_FRONT_RIGHT; case MA_CHANNEL_FRONT_CENTER: return SPEAKER_FRONT_CENTER; case MA_CHANNEL_LFE: return SPEAKER_LOW_FREQUENCY; case MA_CHANNEL_BACK_LEFT: return SPEAKER_BACK_LEFT; case MA_CHANNEL_BACK_RIGHT: return SPEAKER_BACK_RIGHT; case MA_CHANNEL_FRONT_LEFT_CENTER: return SPEAKER_FRONT_LEFT_OF_CENTER; case MA_CHANNEL_FRONT_RIGHT_CENTER: return SPEAKER_FRONT_RIGHT_OF_CENTER; case MA_CHANNEL_BACK_CENTER: return SPEAKER_BACK_CENTER; case MA_CHANNEL_SIDE_LEFT: return SPEAKER_SIDE_LEFT; case MA_CHANNEL_SIDE_RIGHT: return SPEAKER_SIDE_RIGHT; case MA_CHANNEL_TOP_CENTER: return SPEAKER_TOP_CENTER; case MA_CHANNEL_TOP_FRONT_LEFT: return SPEAKER_TOP_FRONT_LEFT; case MA_CHANNEL_TOP_FRONT_CENTER: return SPEAKER_TOP_FRONT_CENTER; case MA_CHANNEL_TOP_FRONT_RIGHT: return SPEAKER_TOP_FRONT_RIGHT; case MA_CHANNEL_TOP_BACK_LEFT: return SPEAKER_TOP_BACK_LEFT; case MA_CHANNEL_TOP_BACK_CENTER: return SPEAKER_TOP_BACK_CENTER; case MA_CHANNEL_TOP_BACK_RIGHT: return SPEAKER_TOP_BACK_RIGHT; default: return 0; } } /* Converts a channel mapping to a Win32-style channel mask. */ static DWORD ma_channel_map_to_channel_mask__win32(const ma_channel* pChannelMap, ma_uint32 channels) { DWORD dwChannelMask = 0; ma_uint32 iChannel; for (iChannel = 0; iChannel < channels; ++iChannel) { dwChannelMask |= ma_channel_id_to_win32(pChannelMap[iChannel]); } return dwChannelMask; } /* Converts a Win32-style channel mask to a miniaudio channel map. */ static void ma_channel_mask_to_channel_map__win32(DWORD dwChannelMask, ma_uint32 channels, ma_channel* pChannelMap) { /* If the channel mask is set to 0, just assume a default Win32 channel map. */ if (dwChannelMask == 0) { ma_channel_map_init_standard(ma_standard_channel_map_microsoft, pChannelMap, channels, channels); } else { if (channels == 1 && (dwChannelMask & SPEAKER_FRONT_CENTER) != 0) { pChannelMap[0] = MA_CHANNEL_MONO; } else { /* Just iterate over each bit. */ ma_uint32 iChannel = 0; ma_uint32 iBit; for (iBit = 0; iBit < 32 && iChannel < channels; ++iBit) { DWORD bitValue = (dwChannelMask & (1UL << iBit)); if (bitValue != 0) { /* The bit is set. */ pChannelMap[iChannel] = ma_channel_id_to_ma__win32(bitValue); iChannel += 1; } } } } } #ifdef __cplusplus static ma_bool32 ma_is_guid_equal(const void* a, const void* b) { return IsEqualGUID(*(const GUID*)a, *(const GUID*)b); } #else #define ma_is_guid_equal(a, b) IsEqualGUID((const GUID*)a, (const GUID*)b) #endif static MA_INLINE ma_bool32 ma_is_guid_null(const void* guid) { static GUID nullguid = {0x00000000, 0x0000, 0x0000, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}; return ma_is_guid_equal(guid, &nullguid); } static ma_format ma_format_from_WAVEFORMATEX(const MA_WAVEFORMATEX* pWF) { MA_ASSERT(pWF != NULL); if (pWF->wFormatTag == WAVE_FORMAT_EXTENSIBLE) { const MA_WAVEFORMATEXTENSIBLE* pWFEX = (const MA_WAVEFORMATEXTENSIBLE*)pWF; if (ma_is_guid_equal(&pWFEX->SubFormat, &MA_GUID_KSDATAFORMAT_SUBTYPE_PCM)) { if (pWFEX->Samples.wValidBitsPerSample == 32) { return ma_format_s32; } if (pWFEX->Samples.wValidBitsPerSample == 24) { if (pWFEX->wBitsPerSample == 32) { return ma_format_s32; } if (pWFEX->wBitsPerSample == 24) { return ma_format_s24; } } if (pWFEX->Samples.wValidBitsPerSample == 16) { return ma_format_s16; } if (pWFEX->Samples.wValidBitsPerSample == 8) { return ma_format_u8; } } if (ma_is_guid_equal(&pWFEX->SubFormat, &MA_GUID_KSDATAFORMAT_SUBTYPE_IEEE_FLOAT)) { if (pWFEX->Samples.wValidBitsPerSample == 32) { return ma_format_f32; } /* if (pWFEX->Samples.wValidBitsPerSample == 64) { return ma_format_f64; } */ } } else { if (pWF->wFormatTag == WAVE_FORMAT_PCM) { if (pWF->wBitsPerSample == 32) { return ma_format_s32; } if (pWF->wBitsPerSample == 24) { return ma_format_s24; } if (pWF->wBitsPerSample == 16) { return ma_format_s16; } if (pWF->wBitsPerSample == 8) { return ma_format_u8; } } if (pWF->wFormatTag == WAVE_FORMAT_IEEE_FLOAT) { if (pWF->wBitsPerSample == 32) { return ma_format_f32; } if (pWF->wBitsPerSample == 64) { /*return ma_format_f64;*/ } } } return ma_format_unknown; } #endif /******************************************************************************* WASAPI Backend *******************************************************************************/ #ifdef MA_HAS_WASAPI #if 0 #if defined(_MSC_VER) #pragma warning(push) #pragma warning(disable:4091) /* 'typedef ': ignored on left of '' when no variable is declared */ #endif #include #include #if defined(_MSC_VER) #pragma warning(pop) #endif #endif /* 0 */ static ma_result ma_device_reroute__wasapi(ma_device* pDevice, ma_device_type deviceType); /* Some compilers don't define VerifyVersionInfoW. Need to write this ourselves. */ #define MA_WIN32_WINNT_VISTA 0x0600 #define MA_VER_MINORVERSION 0x01 #define MA_VER_MAJORVERSION 0x02 #define MA_VER_SERVICEPACKMAJOR 0x20 #define MA_VER_GREATER_EQUAL 0x03 typedef struct { DWORD dwOSVersionInfoSize; DWORD dwMajorVersion; DWORD dwMinorVersion; DWORD dwBuildNumber; DWORD dwPlatformId; WCHAR szCSDVersion[128]; WORD wServicePackMajor; WORD wServicePackMinor; WORD wSuiteMask; BYTE wProductType; BYTE wReserved; } ma_OSVERSIONINFOEXW; typedef BOOL (WINAPI * ma_PFNVerifyVersionInfoW) (ma_OSVERSIONINFOEXW* lpVersionInfo, DWORD dwTypeMask, DWORDLONG dwlConditionMask); typedef ULONGLONG (WINAPI * ma_PFNVerSetConditionMask)(ULONGLONG dwlConditionMask, DWORD dwTypeBitMask, BYTE dwConditionMask); #ifndef PROPERTYKEY_DEFINED #define PROPERTYKEY_DEFINED #ifndef __WATCOMC__ typedef struct { GUID fmtid; DWORD pid; } PROPERTYKEY; #endif #endif /* Some compilers don't define PropVariantInit(). We just do this ourselves since it's just a memset(). */ static MA_INLINE void ma_PropVariantInit(MA_PROPVARIANT* pProp) { MA_ZERO_OBJECT(pProp); } static const PROPERTYKEY MA_PKEY_Device_FriendlyName = {{0xA45C254E, 0xDF1C, 0x4EFD, {0x80, 0x20, 0x67, 0xD1, 0x46, 0xA8, 0x50, 0xE0}}, 14}; static const PROPERTYKEY MA_PKEY_AudioEngine_DeviceFormat = {{0xF19F064D, 0x82C, 0x4E27, {0xBC, 0x73, 0x68, 0x82, 0xA1, 0xBB, 0x8E, 0x4C}}, 0}; static const IID MA_IID_IUnknown = {0x00000000, 0x0000, 0x0000, {0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46}}; /* 00000000-0000-0000-C000-000000000046 */ #if !defined(MA_WIN32_DESKTOP) && !defined(MA_WIN32_GDK) static const IID MA_IID_IAgileObject = {0x94EA2B94, 0xE9CC, 0x49E0, {0xC0, 0xFF, 0xEE, 0x64, 0xCA, 0x8F, 0x5B, 0x90}}; /* 94EA2B94-E9CC-49E0-C0FF-EE64CA8F5B90 */ #endif static const IID MA_IID_IAudioClient = {0x1CB9AD4C, 0xDBFA, 0x4C32, {0xB1, 0x78, 0xC2, 0xF5, 0x68, 0xA7, 0x03, 0xB2}}; /* 1CB9AD4C-DBFA-4C32-B178-C2F568A703B2 = __uuidof(IAudioClient) */ static const IID MA_IID_IAudioClient2 = {0x726778CD, 0xF60A, 0x4EDA, {0x82, 0xDE, 0xE4, 0x76, 0x10, 0xCD, 0x78, 0xAA}}; /* 726778CD-F60A-4EDA-82DE-E47610CD78AA = __uuidof(IAudioClient2) */ static const IID MA_IID_IAudioClient3 = {0x7ED4EE07, 0x8E67, 0x4CD4, {0x8C, 0x1A, 0x2B, 0x7A, 0x59, 0x87, 0xAD, 0x42}}; /* 7ED4EE07-8E67-4CD4-8C1A-2B7A5987AD42 = __uuidof(IAudioClient3) */ static const IID MA_IID_IAudioRenderClient = {0xF294ACFC, 0x3146, 0x4483, {0xA7, 0xBF, 0xAD, 0xDC, 0xA7, 0xC2, 0x60, 0xE2}}; /* F294ACFC-3146-4483-A7BF-ADDCA7C260E2 = __uuidof(IAudioRenderClient) */ static const IID MA_IID_IAudioCaptureClient = {0xC8ADBD64, 0xE71E, 0x48A0, {0xA4, 0xDE, 0x18, 0x5C, 0x39, 0x5C, 0xD3, 0x17}}; /* C8ADBD64-E71E-48A0-A4DE-185C395CD317 = __uuidof(IAudioCaptureClient) */ static const IID MA_IID_IMMNotificationClient = {0x7991EEC9, 0x7E89, 0x4D85, {0x83, 0x90, 0x6C, 0x70, 0x3C, 0xEC, 0x60, 0xC0}}; /* 7991EEC9-7E89-4D85-8390-6C703CEC60C0 = __uuidof(IMMNotificationClient) */ #if !defined(MA_WIN32_DESKTOP) && !defined(MA_WIN32_GDK) static const IID MA_IID_DEVINTERFACE_AUDIO_RENDER = {0xE6327CAD, 0xDCEC, 0x4949, {0xAE, 0x8A, 0x99, 0x1E, 0x97, 0x6A, 0x79, 0xD2}}; /* E6327CAD-DCEC-4949-AE8A-991E976A79D2 */ static const IID MA_IID_DEVINTERFACE_AUDIO_CAPTURE = {0x2EEF81BE, 0x33FA, 0x4800, {0x96, 0x70, 0x1C, 0xD4, 0x74, 0x97, 0x2C, 0x3F}}; /* 2EEF81BE-33FA-4800-9670-1CD474972C3F */ static const IID MA_IID_IActivateAudioInterfaceCompletionHandler = {0x41D949AB, 0x9862, 0x444A, {0x80, 0xF6, 0xC2, 0x61, 0x33, 0x4D, 0xA5, 0xEB}}; /* 41D949AB-9862-444A-80F6-C261334DA5EB */ #endif static const IID MA_CLSID_MMDeviceEnumerator = {0xBCDE0395, 0xE52F, 0x467C, {0x8E, 0x3D, 0xC4, 0x57, 0x92, 0x91, 0x69, 0x2E}}; /* BCDE0395-E52F-467C-8E3D-C4579291692E = __uuidof(MMDeviceEnumerator) */ static const IID MA_IID_IMMDeviceEnumerator = {0xA95664D2, 0x9614, 0x4F35, {0xA7, 0x46, 0xDE, 0x8D, 0xB6, 0x36, 0x17, 0xE6}}; /* A95664D2-9614-4F35-A746-DE8DB63617E6 = __uuidof(IMMDeviceEnumerator) */ #if defined(MA_WIN32_DESKTOP) || defined(MA_WIN32_GDK) #define MA_MM_DEVICE_STATE_ACTIVE 1 #define MA_MM_DEVICE_STATE_DISABLED 2 #define MA_MM_DEVICE_STATE_NOTPRESENT 4 #define MA_MM_DEVICE_STATE_UNPLUGGED 8 typedef struct ma_IMMDeviceEnumerator ma_IMMDeviceEnumerator; typedef struct ma_IMMDeviceCollection ma_IMMDeviceCollection; typedef struct ma_IMMDevice ma_IMMDevice; #else typedef struct ma_IActivateAudioInterfaceCompletionHandler ma_IActivateAudioInterfaceCompletionHandler; typedef struct ma_IActivateAudioInterfaceAsyncOperation ma_IActivateAudioInterfaceAsyncOperation; #endif typedef struct ma_IPropertyStore ma_IPropertyStore; typedef struct ma_IAudioClient ma_IAudioClient; typedef struct ma_IAudioClient2 ma_IAudioClient2; typedef struct ma_IAudioClient3 ma_IAudioClient3; typedef struct ma_IAudioRenderClient ma_IAudioRenderClient; typedef struct ma_IAudioCaptureClient ma_IAudioCaptureClient; typedef ma_int64 MA_REFERENCE_TIME; #define MA_AUDCLNT_STREAMFLAGS_CROSSPROCESS 0x00010000 #define MA_AUDCLNT_STREAMFLAGS_LOOPBACK 0x00020000 #define MA_AUDCLNT_STREAMFLAGS_EVENTCALLBACK 0x00040000 #define MA_AUDCLNT_STREAMFLAGS_NOPERSIST 0x00080000 #define MA_AUDCLNT_STREAMFLAGS_RATEADJUST 0x00100000 #define MA_AUDCLNT_STREAMFLAGS_SRC_DEFAULT_QUALITY 0x08000000 #define MA_AUDCLNT_STREAMFLAGS_AUTOCONVERTPCM 0x80000000 #define MA_AUDCLNT_SESSIONFLAGS_EXPIREWHENUNOWNED 0x10000000 #define MA_AUDCLNT_SESSIONFLAGS_DISPLAY_HIDE 0x20000000 #define MA_AUDCLNT_SESSIONFLAGS_DISPLAY_HIDEWHENEXPIRED 0x40000000 /* Buffer flags. */ #define MA_AUDCLNT_BUFFERFLAGS_DATA_DISCONTINUITY 1 #define MA_AUDCLNT_BUFFERFLAGS_SILENT 2 #define MA_AUDCLNT_BUFFERFLAGS_TIMESTAMP_ERROR 4 typedef enum { ma_eRender = 0, ma_eCapture = 1, ma_eAll = 2 } ma_EDataFlow; typedef enum { ma_eConsole = 0, ma_eMultimedia = 1, ma_eCommunications = 2 } ma_ERole; typedef enum { MA_AUDCLNT_SHAREMODE_SHARED, MA_AUDCLNT_SHAREMODE_EXCLUSIVE } MA_AUDCLNT_SHAREMODE; typedef enum { MA_AudioCategory_Other = 0 /* <-- miniaudio is only caring about Other. */ } MA_AUDIO_STREAM_CATEGORY; typedef struct { ma_uint32 cbSize; BOOL bIsOffload; MA_AUDIO_STREAM_CATEGORY eCategory; } ma_AudioClientProperties; /* IUnknown */ typedef struct { /* IUnknown */ HRESULT (STDMETHODCALLTYPE * QueryInterface)(ma_IUnknown* pThis, const IID* const riid, void** ppObject); ULONG (STDMETHODCALLTYPE * AddRef) (ma_IUnknown* pThis); ULONG (STDMETHODCALLTYPE * Release) (ma_IUnknown* pThis); } ma_IUnknownVtbl; struct ma_IUnknown { ma_IUnknownVtbl* lpVtbl; }; static MA_INLINE HRESULT ma_IUnknown_QueryInterface(ma_IUnknown* pThis, const IID* const riid, void** ppObject) { return pThis->lpVtbl->QueryInterface(pThis, riid, ppObject); } static MA_INLINE ULONG ma_IUnknown_AddRef(ma_IUnknown* pThis) { return pThis->lpVtbl->AddRef(pThis); } static MA_INLINE ULONG ma_IUnknown_Release(ma_IUnknown* pThis) { return pThis->lpVtbl->Release(pThis); } #if defined(MA_WIN32_DESKTOP) || defined(MA_WIN32_GDK) /* IMMNotificationClient */ typedef struct { /* IUnknown */ HRESULT (STDMETHODCALLTYPE * QueryInterface)(ma_IMMNotificationClient* pThis, const IID* const riid, void** ppObject); ULONG (STDMETHODCALLTYPE * AddRef) (ma_IMMNotificationClient* pThis); ULONG (STDMETHODCALLTYPE * Release) (ma_IMMNotificationClient* pThis); /* IMMNotificationClient */ HRESULT (STDMETHODCALLTYPE * OnDeviceStateChanged) (ma_IMMNotificationClient* pThis, const WCHAR* pDeviceID, DWORD dwNewState); HRESULT (STDMETHODCALLTYPE * OnDeviceAdded) (ma_IMMNotificationClient* pThis, const WCHAR* pDeviceID); HRESULT (STDMETHODCALLTYPE * OnDeviceRemoved) (ma_IMMNotificationClient* pThis, const WCHAR* pDeviceID); HRESULT (STDMETHODCALLTYPE * OnDefaultDeviceChanged)(ma_IMMNotificationClient* pThis, ma_EDataFlow dataFlow, ma_ERole role, const WCHAR* pDefaultDeviceID); HRESULT (STDMETHODCALLTYPE * OnPropertyValueChanged)(ma_IMMNotificationClient* pThis, const WCHAR* pDeviceID, const PROPERTYKEY key); } ma_IMMNotificationClientVtbl; /* IMMDeviceEnumerator */ typedef struct { /* IUnknown */ HRESULT (STDMETHODCALLTYPE * QueryInterface)(ma_IMMDeviceEnumerator* pThis, const IID* const riid, void** ppObject); ULONG (STDMETHODCALLTYPE * AddRef) (ma_IMMDeviceEnumerator* pThis); ULONG (STDMETHODCALLTYPE * Release) (ma_IMMDeviceEnumerator* pThis); /* IMMDeviceEnumerator */ HRESULT (STDMETHODCALLTYPE * EnumAudioEndpoints) (ma_IMMDeviceEnumerator* pThis, ma_EDataFlow dataFlow, DWORD dwStateMask, ma_IMMDeviceCollection** ppDevices); HRESULT (STDMETHODCALLTYPE * GetDefaultAudioEndpoint) (ma_IMMDeviceEnumerator* pThis, ma_EDataFlow dataFlow, ma_ERole role, ma_IMMDevice** ppEndpoint); HRESULT (STDMETHODCALLTYPE * GetDevice) (ma_IMMDeviceEnumerator* pThis, const WCHAR* pID, ma_IMMDevice** ppDevice); HRESULT (STDMETHODCALLTYPE * RegisterEndpointNotificationCallback) (ma_IMMDeviceEnumerator* pThis, ma_IMMNotificationClient* pClient); HRESULT (STDMETHODCALLTYPE * UnregisterEndpointNotificationCallback)(ma_IMMDeviceEnumerator* pThis, ma_IMMNotificationClient* pClient); } ma_IMMDeviceEnumeratorVtbl; struct ma_IMMDeviceEnumerator { ma_IMMDeviceEnumeratorVtbl* lpVtbl; }; static MA_INLINE HRESULT ma_IMMDeviceEnumerator_QueryInterface(ma_IMMDeviceEnumerator* pThis, const IID* const riid, void** ppObject) { return pThis->lpVtbl->QueryInterface(pThis, riid, ppObject); } static MA_INLINE ULONG ma_IMMDeviceEnumerator_AddRef(ma_IMMDeviceEnumerator* pThis) { return pThis->lpVtbl->AddRef(pThis); } static MA_INLINE ULONG ma_IMMDeviceEnumerator_Release(ma_IMMDeviceEnumerator* pThis) { return pThis->lpVtbl->Release(pThis); } static MA_INLINE HRESULT ma_IMMDeviceEnumerator_EnumAudioEndpoints(ma_IMMDeviceEnumerator* pThis, ma_EDataFlow dataFlow, DWORD dwStateMask, ma_IMMDeviceCollection** ppDevices) { return pThis->lpVtbl->EnumAudioEndpoints(pThis, dataFlow, dwStateMask, ppDevices); } static MA_INLINE HRESULT ma_IMMDeviceEnumerator_GetDefaultAudioEndpoint(ma_IMMDeviceEnumerator* pThis, ma_EDataFlow dataFlow, ma_ERole role, ma_IMMDevice** ppEndpoint) { return pThis->lpVtbl->GetDefaultAudioEndpoint(pThis, dataFlow, role, ppEndpoint); } static MA_INLINE HRESULT ma_IMMDeviceEnumerator_GetDevice(ma_IMMDeviceEnumerator* pThis, const WCHAR* pID, ma_IMMDevice** ppDevice) { return pThis->lpVtbl->GetDevice(pThis, pID, ppDevice); } static MA_INLINE HRESULT ma_IMMDeviceEnumerator_RegisterEndpointNotificationCallback(ma_IMMDeviceEnumerator* pThis, ma_IMMNotificationClient* pClient) { return pThis->lpVtbl->RegisterEndpointNotificationCallback(pThis, pClient); } static MA_INLINE HRESULT ma_IMMDeviceEnumerator_UnregisterEndpointNotificationCallback(ma_IMMDeviceEnumerator* pThis, ma_IMMNotificationClient* pClient) { return pThis->lpVtbl->UnregisterEndpointNotificationCallback(pThis, pClient); } /* IMMDeviceCollection */ typedef struct { /* IUnknown */ HRESULT (STDMETHODCALLTYPE * QueryInterface)(ma_IMMDeviceCollection* pThis, const IID* const riid, void** ppObject); ULONG (STDMETHODCALLTYPE * AddRef) (ma_IMMDeviceCollection* pThis); ULONG (STDMETHODCALLTYPE * Release) (ma_IMMDeviceCollection* pThis); /* IMMDeviceCollection */ HRESULT (STDMETHODCALLTYPE * GetCount)(ma_IMMDeviceCollection* pThis, UINT* pDevices); HRESULT (STDMETHODCALLTYPE * Item) (ma_IMMDeviceCollection* pThis, UINT nDevice, ma_IMMDevice** ppDevice); } ma_IMMDeviceCollectionVtbl; struct ma_IMMDeviceCollection { ma_IMMDeviceCollectionVtbl* lpVtbl; }; static MA_INLINE HRESULT ma_IMMDeviceCollection_QueryInterface(ma_IMMDeviceCollection* pThis, const IID* const riid, void** ppObject) { return pThis->lpVtbl->QueryInterface(pThis, riid, ppObject); } static MA_INLINE ULONG ma_IMMDeviceCollection_AddRef(ma_IMMDeviceCollection* pThis) { return pThis->lpVtbl->AddRef(pThis); } static MA_INLINE ULONG ma_IMMDeviceCollection_Release(ma_IMMDeviceCollection* pThis) { return pThis->lpVtbl->Release(pThis); } static MA_INLINE HRESULT ma_IMMDeviceCollection_GetCount(ma_IMMDeviceCollection* pThis, UINT* pDevices) { return pThis->lpVtbl->GetCount(pThis, pDevices); } static MA_INLINE HRESULT ma_IMMDeviceCollection_Item(ma_IMMDeviceCollection* pThis, UINT nDevice, ma_IMMDevice** ppDevice) { return pThis->lpVtbl->Item(pThis, nDevice, ppDevice); } /* IMMDevice */ typedef struct { /* IUnknown */ HRESULT (STDMETHODCALLTYPE * QueryInterface)(ma_IMMDevice* pThis, const IID* const riid, void** ppObject); ULONG (STDMETHODCALLTYPE * AddRef) (ma_IMMDevice* pThis); ULONG (STDMETHODCALLTYPE * Release) (ma_IMMDevice* pThis); /* IMMDevice */ HRESULT (STDMETHODCALLTYPE * Activate) (ma_IMMDevice* pThis, const IID* const iid, DWORD dwClsCtx, MA_PROPVARIANT* pActivationParams, void** ppInterface); HRESULT (STDMETHODCALLTYPE * OpenPropertyStore)(ma_IMMDevice* pThis, DWORD stgmAccess, ma_IPropertyStore** ppProperties); HRESULT (STDMETHODCALLTYPE * GetId) (ma_IMMDevice* pThis, WCHAR** pID); HRESULT (STDMETHODCALLTYPE * GetState) (ma_IMMDevice* pThis, DWORD *pState); } ma_IMMDeviceVtbl; struct ma_IMMDevice { ma_IMMDeviceVtbl* lpVtbl; }; static MA_INLINE HRESULT ma_IMMDevice_QueryInterface(ma_IMMDevice* pThis, const IID* const riid, void** ppObject) { return pThis->lpVtbl->QueryInterface(pThis, riid, ppObject); } static MA_INLINE ULONG ma_IMMDevice_AddRef(ma_IMMDevice* pThis) { return pThis->lpVtbl->AddRef(pThis); } static MA_INLINE ULONG ma_IMMDevice_Release(ma_IMMDevice* pThis) { return pThis->lpVtbl->Release(pThis); } static MA_INLINE HRESULT ma_IMMDevice_Activate(ma_IMMDevice* pThis, const IID* const iid, DWORD dwClsCtx, MA_PROPVARIANT* pActivationParams, void** ppInterface) { return pThis->lpVtbl->Activate(pThis, iid, dwClsCtx, pActivationParams, ppInterface); } static MA_INLINE HRESULT ma_IMMDevice_OpenPropertyStore(ma_IMMDevice* pThis, DWORD stgmAccess, ma_IPropertyStore** ppProperties) { return pThis->lpVtbl->OpenPropertyStore(pThis, stgmAccess, ppProperties); } static MA_INLINE HRESULT ma_IMMDevice_GetId(ma_IMMDevice* pThis, WCHAR** pID) { return pThis->lpVtbl->GetId(pThis, pID); } static MA_INLINE HRESULT ma_IMMDevice_GetState(ma_IMMDevice* pThis, DWORD *pState) { return pThis->lpVtbl->GetState(pThis, pState); } #else /* IActivateAudioInterfaceAsyncOperation */ typedef struct { /* IUnknown */ HRESULT (STDMETHODCALLTYPE * QueryInterface)(ma_IActivateAudioInterfaceAsyncOperation* pThis, const IID* const riid, void** ppObject); ULONG (STDMETHODCALLTYPE * AddRef) (ma_IActivateAudioInterfaceAsyncOperation* pThis); ULONG (STDMETHODCALLTYPE * Release) (ma_IActivateAudioInterfaceAsyncOperation* pThis); /* IActivateAudioInterfaceAsyncOperation */ HRESULT (STDMETHODCALLTYPE * GetActivateResult)(ma_IActivateAudioInterfaceAsyncOperation* pThis, HRESULT *pActivateResult, ma_IUnknown** ppActivatedInterface); } ma_IActivateAudioInterfaceAsyncOperationVtbl; struct ma_IActivateAudioInterfaceAsyncOperation { ma_IActivateAudioInterfaceAsyncOperationVtbl* lpVtbl; }; static MA_INLINE HRESULT ma_IActivateAudioInterfaceAsyncOperation_QueryInterface(ma_IActivateAudioInterfaceAsyncOperation* pThis, const IID* const riid, void** ppObject) { return pThis->lpVtbl->QueryInterface(pThis, riid, ppObject); } static MA_INLINE ULONG ma_IActivateAudioInterfaceAsyncOperation_AddRef(ma_IActivateAudioInterfaceAsyncOperation* pThis) { return pThis->lpVtbl->AddRef(pThis); } static MA_INLINE ULONG ma_IActivateAudioInterfaceAsyncOperation_Release(ma_IActivateAudioInterfaceAsyncOperation* pThis) { return pThis->lpVtbl->Release(pThis); } static MA_INLINE HRESULT ma_IActivateAudioInterfaceAsyncOperation_GetActivateResult(ma_IActivateAudioInterfaceAsyncOperation* pThis, HRESULT *pActivateResult, ma_IUnknown** ppActivatedInterface) { return pThis->lpVtbl->GetActivateResult(pThis, pActivateResult, ppActivatedInterface); } #endif /* IPropertyStore */ typedef struct { /* IUnknown */ HRESULT (STDMETHODCALLTYPE * QueryInterface)(ma_IPropertyStore* pThis, const IID* const riid, void** ppObject); ULONG (STDMETHODCALLTYPE * AddRef) (ma_IPropertyStore* pThis); ULONG (STDMETHODCALLTYPE * Release) (ma_IPropertyStore* pThis); /* IPropertyStore */ HRESULT (STDMETHODCALLTYPE * GetCount)(ma_IPropertyStore* pThis, DWORD* pPropCount); HRESULT (STDMETHODCALLTYPE * GetAt) (ma_IPropertyStore* pThis, DWORD propIndex, PROPERTYKEY* pPropKey); HRESULT (STDMETHODCALLTYPE * GetValue)(ma_IPropertyStore* pThis, const PROPERTYKEY* const pKey, MA_PROPVARIANT* pPropVar); HRESULT (STDMETHODCALLTYPE * SetValue)(ma_IPropertyStore* pThis, const PROPERTYKEY* const pKey, const MA_PROPVARIANT* const pPropVar); HRESULT (STDMETHODCALLTYPE * Commit) (ma_IPropertyStore* pThis); } ma_IPropertyStoreVtbl; struct ma_IPropertyStore { ma_IPropertyStoreVtbl* lpVtbl; }; static MA_INLINE HRESULT ma_IPropertyStore_QueryInterface(ma_IPropertyStore* pThis, const IID* const riid, void** ppObject) { return pThis->lpVtbl->QueryInterface(pThis, riid, ppObject); } static MA_INLINE ULONG ma_IPropertyStore_AddRef(ma_IPropertyStore* pThis) { return pThis->lpVtbl->AddRef(pThis); } static MA_INLINE ULONG ma_IPropertyStore_Release(ma_IPropertyStore* pThis) { return pThis->lpVtbl->Release(pThis); } static MA_INLINE HRESULT ma_IPropertyStore_GetCount(ma_IPropertyStore* pThis, DWORD* pPropCount) { return pThis->lpVtbl->GetCount(pThis, pPropCount); } static MA_INLINE HRESULT ma_IPropertyStore_GetAt(ma_IPropertyStore* pThis, DWORD propIndex, PROPERTYKEY* pPropKey) { return pThis->lpVtbl->GetAt(pThis, propIndex, pPropKey); } static MA_INLINE HRESULT ma_IPropertyStore_GetValue(ma_IPropertyStore* pThis, const PROPERTYKEY* const pKey, MA_PROPVARIANT* pPropVar) { return pThis->lpVtbl->GetValue(pThis, pKey, pPropVar); } static MA_INLINE HRESULT ma_IPropertyStore_SetValue(ma_IPropertyStore* pThis, const PROPERTYKEY* const pKey, const MA_PROPVARIANT* const pPropVar) { return pThis->lpVtbl->SetValue(pThis, pKey, pPropVar); } static MA_INLINE HRESULT ma_IPropertyStore_Commit(ma_IPropertyStore* pThis) { return pThis->lpVtbl->Commit(pThis); } /* IAudioClient */ typedef struct { /* IUnknown */ HRESULT (STDMETHODCALLTYPE * QueryInterface)(ma_IAudioClient* pThis, const IID* const riid, void** ppObject); ULONG (STDMETHODCALLTYPE * AddRef) (ma_IAudioClient* pThis); ULONG (STDMETHODCALLTYPE * Release) (ma_IAudioClient* pThis); /* IAudioClient */ HRESULT (STDMETHODCALLTYPE * Initialize) (ma_IAudioClient* pThis, MA_AUDCLNT_SHAREMODE shareMode, DWORD streamFlags, MA_REFERENCE_TIME bufferDuration, MA_REFERENCE_TIME periodicity, const MA_WAVEFORMATEX* pFormat, const GUID* pAudioSessionGuid); HRESULT (STDMETHODCALLTYPE * GetBufferSize) (ma_IAudioClient* pThis, ma_uint32* pNumBufferFrames); HRESULT (STDMETHODCALLTYPE * GetStreamLatency) (ma_IAudioClient* pThis, MA_REFERENCE_TIME* pLatency); HRESULT (STDMETHODCALLTYPE * GetCurrentPadding)(ma_IAudioClient* pThis, ma_uint32* pNumPaddingFrames); HRESULT (STDMETHODCALLTYPE * IsFormatSupported)(ma_IAudioClient* pThis, MA_AUDCLNT_SHAREMODE shareMode, const MA_WAVEFORMATEX* pFormat, MA_WAVEFORMATEX** ppClosestMatch); HRESULT (STDMETHODCALLTYPE * GetMixFormat) (ma_IAudioClient* pThis, MA_WAVEFORMATEX** ppDeviceFormat); HRESULT (STDMETHODCALLTYPE * GetDevicePeriod) (ma_IAudioClient* pThis, MA_REFERENCE_TIME* pDefaultDevicePeriod, MA_REFERENCE_TIME* pMinimumDevicePeriod); HRESULT (STDMETHODCALLTYPE * Start) (ma_IAudioClient* pThis); HRESULT (STDMETHODCALLTYPE * Stop) (ma_IAudioClient* pThis); HRESULT (STDMETHODCALLTYPE * Reset) (ma_IAudioClient* pThis); HRESULT (STDMETHODCALLTYPE * SetEventHandle) (ma_IAudioClient* pThis, HANDLE eventHandle); HRESULT (STDMETHODCALLTYPE * GetService) (ma_IAudioClient* pThis, const IID* const riid, void** pp); } ma_IAudioClientVtbl; struct ma_IAudioClient { ma_IAudioClientVtbl* lpVtbl; }; static MA_INLINE HRESULT ma_IAudioClient_QueryInterface(ma_IAudioClient* pThis, const IID* const riid, void** ppObject) { return pThis->lpVtbl->QueryInterface(pThis, riid, ppObject); } static MA_INLINE ULONG ma_IAudioClient_AddRef(ma_IAudioClient* pThis) { return pThis->lpVtbl->AddRef(pThis); } static MA_INLINE ULONG ma_IAudioClient_Release(ma_IAudioClient* pThis) { return pThis->lpVtbl->Release(pThis); } static MA_INLINE HRESULT ma_IAudioClient_Initialize(ma_IAudioClient* pThis, MA_AUDCLNT_SHAREMODE shareMode, DWORD streamFlags, MA_REFERENCE_TIME bufferDuration, MA_REFERENCE_TIME periodicity, const MA_WAVEFORMATEX* pFormat, const GUID* pAudioSessionGuid) { return pThis->lpVtbl->Initialize(pThis, shareMode, streamFlags, bufferDuration, periodicity, pFormat, pAudioSessionGuid); } static MA_INLINE HRESULT ma_IAudioClient_GetBufferSize(ma_IAudioClient* pThis, ma_uint32* pNumBufferFrames) { return pThis->lpVtbl->GetBufferSize(pThis, pNumBufferFrames); } static MA_INLINE HRESULT ma_IAudioClient_GetStreamLatency(ma_IAudioClient* pThis, MA_REFERENCE_TIME* pLatency) { return pThis->lpVtbl->GetStreamLatency(pThis, pLatency); } static MA_INLINE HRESULT ma_IAudioClient_GetCurrentPadding(ma_IAudioClient* pThis, ma_uint32* pNumPaddingFrames) { return pThis->lpVtbl->GetCurrentPadding(pThis, pNumPaddingFrames); } static MA_INLINE HRESULT ma_IAudioClient_IsFormatSupported(ma_IAudioClient* pThis, MA_AUDCLNT_SHAREMODE shareMode, const MA_WAVEFORMATEX* pFormat, MA_WAVEFORMATEX** ppClosestMatch) { return pThis->lpVtbl->IsFormatSupported(pThis, shareMode, pFormat, ppClosestMatch); } static MA_INLINE HRESULT ma_IAudioClient_GetMixFormat(ma_IAudioClient* pThis, MA_WAVEFORMATEX** ppDeviceFormat) { return pThis->lpVtbl->GetMixFormat(pThis, ppDeviceFormat); } static MA_INLINE HRESULT ma_IAudioClient_GetDevicePeriod(ma_IAudioClient* pThis, MA_REFERENCE_TIME* pDefaultDevicePeriod, MA_REFERENCE_TIME* pMinimumDevicePeriod) { return pThis->lpVtbl->GetDevicePeriod(pThis, pDefaultDevicePeriod, pMinimumDevicePeriod); } static MA_INLINE HRESULT ma_IAudioClient_Start(ma_IAudioClient* pThis) { return pThis->lpVtbl->Start(pThis); } static MA_INLINE HRESULT ma_IAudioClient_Stop(ma_IAudioClient* pThis) { return pThis->lpVtbl->Stop(pThis); } static MA_INLINE HRESULT ma_IAudioClient_Reset(ma_IAudioClient* pThis) { return pThis->lpVtbl->Reset(pThis); } static MA_INLINE HRESULT ma_IAudioClient_SetEventHandle(ma_IAudioClient* pThis, HANDLE eventHandle) { return pThis->lpVtbl->SetEventHandle(pThis, eventHandle); } static MA_INLINE HRESULT ma_IAudioClient_GetService(ma_IAudioClient* pThis, const IID* const riid, void** pp) { return pThis->lpVtbl->GetService(pThis, riid, pp); } /* IAudioClient2 */ typedef struct { /* IUnknown */ HRESULT (STDMETHODCALLTYPE * QueryInterface)(ma_IAudioClient2* pThis, const IID* const riid, void** ppObject); ULONG (STDMETHODCALLTYPE * AddRef) (ma_IAudioClient2* pThis); ULONG (STDMETHODCALLTYPE * Release) (ma_IAudioClient2* pThis); /* IAudioClient */ HRESULT (STDMETHODCALLTYPE * Initialize) (ma_IAudioClient2* pThis, MA_AUDCLNT_SHAREMODE shareMode, DWORD streamFlags, MA_REFERENCE_TIME bufferDuration, MA_REFERENCE_TIME periodicity, const MA_WAVEFORMATEX* pFormat, const GUID* pAudioSessionGuid); HRESULT (STDMETHODCALLTYPE * GetBufferSize) (ma_IAudioClient2* pThis, ma_uint32* pNumBufferFrames); HRESULT (STDMETHODCALLTYPE * GetStreamLatency) (ma_IAudioClient2* pThis, MA_REFERENCE_TIME* pLatency); HRESULT (STDMETHODCALLTYPE * GetCurrentPadding)(ma_IAudioClient2* pThis, ma_uint32* pNumPaddingFrames); HRESULT (STDMETHODCALLTYPE * IsFormatSupported)(ma_IAudioClient2* pThis, MA_AUDCLNT_SHAREMODE shareMode, const MA_WAVEFORMATEX* pFormat, MA_WAVEFORMATEX** ppClosestMatch); HRESULT (STDMETHODCALLTYPE * GetMixFormat) (ma_IAudioClient2* pThis, MA_WAVEFORMATEX** ppDeviceFormat); HRESULT (STDMETHODCALLTYPE * GetDevicePeriod) (ma_IAudioClient2* pThis, MA_REFERENCE_TIME* pDefaultDevicePeriod, MA_REFERENCE_TIME* pMinimumDevicePeriod); HRESULT (STDMETHODCALLTYPE * Start) (ma_IAudioClient2* pThis); HRESULT (STDMETHODCALLTYPE * Stop) (ma_IAudioClient2* pThis); HRESULT (STDMETHODCALLTYPE * Reset) (ma_IAudioClient2* pThis); HRESULT (STDMETHODCALLTYPE * SetEventHandle) (ma_IAudioClient2* pThis, HANDLE eventHandle); HRESULT (STDMETHODCALLTYPE * GetService) (ma_IAudioClient2* pThis, const IID* const riid, void** pp); /* IAudioClient2 */ HRESULT (STDMETHODCALLTYPE * IsOffloadCapable) (ma_IAudioClient2* pThis, MA_AUDIO_STREAM_CATEGORY category, BOOL* pOffloadCapable); HRESULT (STDMETHODCALLTYPE * SetClientProperties)(ma_IAudioClient2* pThis, const ma_AudioClientProperties* pProperties); HRESULT (STDMETHODCALLTYPE * GetBufferSizeLimits)(ma_IAudioClient2* pThis, const MA_WAVEFORMATEX* pFormat, BOOL eventDriven, MA_REFERENCE_TIME* pMinBufferDuration, MA_REFERENCE_TIME* pMaxBufferDuration); } ma_IAudioClient2Vtbl; struct ma_IAudioClient2 { ma_IAudioClient2Vtbl* lpVtbl; }; static MA_INLINE HRESULT ma_IAudioClient2_QueryInterface(ma_IAudioClient2* pThis, const IID* const riid, void** ppObject) { return pThis->lpVtbl->QueryInterface(pThis, riid, ppObject); } static MA_INLINE ULONG ma_IAudioClient2_AddRef(ma_IAudioClient2* pThis) { return pThis->lpVtbl->AddRef(pThis); } static MA_INLINE ULONG ma_IAudioClient2_Release(ma_IAudioClient2* pThis) { return pThis->lpVtbl->Release(pThis); } static MA_INLINE HRESULT ma_IAudioClient2_Initialize(ma_IAudioClient2* pThis, MA_AUDCLNT_SHAREMODE shareMode, DWORD streamFlags, MA_REFERENCE_TIME bufferDuration, MA_REFERENCE_TIME periodicity, const MA_WAVEFORMATEX* pFormat, const GUID* pAudioSessionGuid) { return pThis->lpVtbl->Initialize(pThis, shareMode, streamFlags, bufferDuration, periodicity, pFormat, pAudioSessionGuid); } static MA_INLINE HRESULT ma_IAudioClient2_GetBufferSize(ma_IAudioClient2* pThis, ma_uint32* pNumBufferFrames) { return pThis->lpVtbl->GetBufferSize(pThis, pNumBufferFrames); } static MA_INLINE HRESULT ma_IAudioClient2_GetStreamLatency(ma_IAudioClient2* pThis, MA_REFERENCE_TIME* pLatency) { return pThis->lpVtbl->GetStreamLatency(pThis, pLatency); } static MA_INLINE HRESULT ma_IAudioClient2_GetCurrentPadding(ma_IAudioClient2* pThis, ma_uint32* pNumPaddingFrames) { return pThis->lpVtbl->GetCurrentPadding(pThis, pNumPaddingFrames); } static MA_INLINE HRESULT ma_IAudioClient2_IsFormatSupported(ma_IAudioClient2* pThis, MA_AUDCLNT_SHAREMODE shareMode, const MA_WAVEFORMATEX* pFormat, MA_WAVEFORMATEX** ppClosestMatch) { return pThis->lpVtbl->IsFormatSupported(pThis, shareMode, pFormat, ppClosestMatch); } static MA_INLINE HRESULT ma_IAudioClient2_GetMixFormat(ma_IAudioClient2* pThis, MA_WAVEFORMATEX** ppDeviceFormat) { return pThis->lpVtbl->GetMixFormat(pThis, ppDeviceFormat); } static MA_INLINE HRESULT ma_IAudioClient2_GetDevicePeriod(ma_IAudioClient2* pThis, MA_REFERENCE_TIME* pDefaultDevicePeriod, MA_REFERENCE_TIME* pMinimumDevicePeriod) { return pThis->lpVtbl->GetDevicePeriod(pThis, pDefaultDevicePeriod, pMinimumDevicePeriod); } static MA_INLINE HRESULT ma_IAudioClient2_Start(ma_IAudioClient2* pThis) { return pThis->lpVtbl->Start(pThis); } static MA_INLINE HRESULT ma_IAudioClient2_Stop(ma_IAudioClient2* pThis) { return pThis->lpVtbl->Stop(pThis); } static MA_INLINE HRESULT ma_IAudioClient2_Reset(ma_IAudioClient2* pThis) { return pThis->lpVtbl->Reset(pThis); } static MA_INLINE HRESULT ma_IAudioClient2_SetEventHandle(ma_IAudioClient2* pThis, HANDLE eventHandle) { return pThis->lpVtbl->SetEventHandle(pThis, eventHandle); } static MA_INLINE HRESULT ma_IAudioClient2_GetService(ma_IAudioClient2* pThis, const IID* const riid, void** pp) { return pThis->lpVtbl->GetService(pThis, riid, pp); } static MA_INLINE HRESULT ma_IAudioClient2_IsOffloadCapable(ma_IAudioClient2* pThis, MA_AUDIO_STREAM_CATEGORY category, BOOL* pOffloadCapable) { return pThis->lpVtbl->IsOffloadCapable(pThis, category, pOffloadCapable); } static MA_INLINE HRESULT ma_IAudioClient2_SetClientProperties(ma_IAudioClient2* pThis, const ma_AudioClientProperties* pProperties) { return pThis->lpVtbl->SetClientProperties(pThis, pProperties); } static MA_INLINE HRESULT ma_IAudioClient2_GetBufferSizeLimits(ma_IAudioClient2* pThis, const MA_WAVEFORMATEX* pFormat, BOOL eventDriven, MA_REFERENCE_TIME* pMinBufferDuration, MA_REFERENCE_TIME* pMaxBufferDuration) { return pThis->lpVtbl->GetBufferSizeLimits(pThis, pFormat, eventDriven, pMinBufferDuration, pMaxBufferDuration); } /* IAudioClient3 */ typedef struct { /* IUnknown */ HRESULT (STDMETHODCALLTYPE * QueryInterface)(ma_IAudioClient3* pThis, const IID* const riid, void** ppObject); ULONG (STDMETHODCALLTYPE * AddRef) (ma_IAudioClient3* pThis); ULONG (STDMETHODCALLTYPE * Release) (ma_IAudioClient3* pThis); /* IAudioClient */ HRESULT (STDMETHODCALLTYPE * Initialize) (ma_IAudioClient3* pThis, MA_AUDCLNT_SHAREMODE shareMode, DWORD streamFlags, MA_REFERENCE_TIME bufferDuration, MA_REFERENCE_TIME periodicity, const MA_WAVEFORMATEX* pFormat, const GUID* pAudioSessionGuid); HRESULT (STDMETHODCALLTYPE * GetBufferSize) (ma_IAudioClient3* pThis, ma_uint32* pNumBufferFrames); HRESULT (STDMETHODCALLTYPE * GetStreamLatency) (ma_IAudioClient3* pThis, MA_REFERENCE_TIME* pLatency); HRESULT (STDMETHODCALLTYPE * GetCurrentPadding)(ma_IAudioClient3* pThis, ma_uint32* pNumPaddingFrames); HRESULT (STDMETHODCALLTYPE * IsFormatSupported)(ma_IAudioClient3* pThis, MA_AUDCLNT_SHAREMODE shareMode, const MA_WAVEFORMATEX* pFormat, MA_WAVEFORMATEX** ppClosestMatch); HRESULT (STDMETHODCALLTYPE * GetMixFormat) (ma_IAudioClient3* pThis, MA_WAVEFORMATEX** ppDeviceFormat); HRESULT (STDMETHODCALLTYPE * GetDevicePeriod) (ma_IAudioClient3* pThis, MA_REFERENCE_TIME* pDefaultDevicePeriod, MA_REFERENCE_TIME* pMinimumDevicePeriod); HRESULT (STDMETHODCALLTYPE * Start) (ma_IAudioClient3* pThis); HRESULT (STDMETHODCALLTYPE * Stop) (ma_IAudioClient3* pThis); HRESULT (STDMETHODCALLTYPE * Reset) (ma_IAudioClient3* pThis); HRESULT (STDMETHODCALLTYPE * SetEventHandle) (ma_IAudioClient3* pThis, HANDLE eventHandle); HRESULT (STDMETHODCALLTYPE * GetService) (ma_IAudioClient3* pThis, const IID* const riid, void** pp); /* IAudioClient2 */ HRESULT (STDMETHODCALLTYPE * IsOffloadCapable) (ma_IAudioClient3* pThis, MA_AUDIO_STREAM_CATEGORY category, BOOL* pOffloadCapable); HRESULT (STDMETHODCALLTYPE * SetClientProperties)(ma_IAudioClient3* pThis, const ma_AudioClientProperties* pProperties); HRESULT (STDMETHODCALLTYPE * GetBufferSizeLimits)(ma_IAudioClient3* pThis, const MA_WAVEFORMATEX* pFormat, BOOL eventDriven, MA_REFERENCE_TIME* pMinBufferDuration, MA_REFERENCE_TIME* pMaxBufferDuration); /* IAudioClient3 */ HRESULT (STDMETHODCALLTYPE * GetSharedModeEnginePeriod) (ma_IAudioClient3* pThis, const MA_WAVEFORMATEX* pFormat, ma_uint32* pDefaultPeriodInFrames, ma_uint32* pFundamentalPeriodInFrames, ma_uint32* pMinPeriodInFrames, ma_uint32* pMaxPeriodInFrames); HRESULT (STDMETHODCALLTYPE * GetCurrentSharedModeEnginePeriod)(ma_IAudioClient3* pThis, MA_WAVEFORMATEX** ppFormat, ma_uint32* pCurrentPeriodInFrames); HRESULT (STDMETHODCALLTYPE * InitializeSharedAudioStream) (ma_IAudioClient3* pThis, DWORD streamFlags, ma_uint32 periodInFrames, const MA_WAVEFORMATEX* pFormat, const GUID* pAudioSessionGuid); } ma_IAudioClient3Vtbl; struct ma_IAudioClient3 { ma_IAudioClient3Vtbl* lpVtbl; }; static MA_INLINE HRESULT ma_IAudioClient3_QueryInterface(ma_IAudioClient3* pThis, const IID* const riid, void** ppObject) { return pThis->lpVtbl->QueryInterface(pThis, riid, ppObject); } static MA_INLINE ULONG ma_IAudioClient3_AddRef(ma_IAudioClient3* pThis) { return pThis->lpVtbl->AddRef(pThis); } static MA_INLINE ULONG ma_IAudioClient3_Release(ma_IAudioClient3* pThis) { return pThis->lpVtbl->Release(pThis); } static MA_INLINE HRESULT ma_IAudioClient3_Initialize(ma_IAudioClient3* pThis, MA_AUDCLNT_SHAREMODE shareMode, DWORD streamFlags, MA_REFERENCE_TIME bufferDuration, MA_REFERENCE_TIME periodicity, const MA_WAVEFORMATEX* pFormat, const GUID* pAudioSessionGuid) { return pThis->lpVtbl->Initialize(pThis, shareMode, streamFlags, bufferDuration, periodicity, pFormat, pAudioSessionGuid); } static MA_INLINE HRESULT ma_IAudioClient3_GetBufferSize(ma_IAudioClient3* pThis, ma_uint32* pNumBufferFrames) { return pThis->lpVtbl->GetBufferSize(pThis, pNumBufferFrames); } static MA_INLINE HRESULT ma_IAudioClient3_GetStreamLatency(ma_IAudioClient3* pThis, MA_REFERENCE_TIME* pLatency) { return pThis->lpVtbl->GetStreamLatency(pThis, pLatency); } static MA_INLINE HRESULT ma_IAudioClient3_GetCurrentPadding(ma_IAudioClient3* pThis, ma_uint32* pNumPaddingFrames) { return pThis->lpVtbl->GetCurrentPadding(pThis, pNumPaddingFrames); } static MA_INLINE HRESULT ma_IAudioClient3_IsFormatSupported(ma_IAudioClient3* pThis, MA_AUDCLNT_SHAREMODE shareMode, const MA_WAVEFORMATEX* pFormat, MA_WAVEFORMATEX** ppClosestMatch) { return pThis->lpVtbl->IsFormatSupported(pThis, shareMode, pFormat, ppClosestMatch); } static MA_INLINE HRESULT ma_IAudioClient3_GetMixFormat(ma_IAudioClient3* pThis, MA_WAVEFORMATEX** ppDeviceFormat) { return pThis->lpVtbl->GetMixFormat(pThis, ppDeviceFormat); } static MA_INLINE HRESULT ma_IAudioClient3_GetDevicePeriod(ma_IAudioClient3* pThis, MA_REFERENCE_TIME* pDefaultDevicePeriod, MA_REFERENCE_TIME* pMinimumDevicePeriod) { return pThis->lpVtbl->GetDevicePeriod(pThis, pDefaultDevicePeriod, pMinimumDevicePeriod); } static MA_INLINE HRESULT ma_IAudioClient3_Start(ma_IAudioClient3* pThis) { return pThis->lpVtbl->Start(pThis); } static MA_INLINE HRESULT ma_IAudioClient3_Stop(ma_IAudioClient3* pThis) { return pThis->lpVtbl->Stop(pThis); } static MA_INLINE HRESULT ma_IAudioClient3_Reset(ma_IAudioClient3* pThis) { return pThis->lpVtbl->Reset(pThis); } static MA_INLINE HRESULT ma_IAudioClient3_SetEventHandle(ma_IAudioClient3* pThis, HANDLE eventHandle) { return pThis->lpVtbl->SetEventHandle(pThis, eventHandle); } static MA_INLINE HRESULT ma_IAudioClient3_GetService(ma_IAudioClient3* pThis, const IID* const riid, void** pp) { return pThis->lpVtbl->GetService(pThis, riid, pp); } static MA_INLINE HRESULT ma_IAudioClient3_IsOffloadCapable(ma_IAudioClient3* pThis, MA_AUDIO_STREAM_CATEGORY category, BOOL* pOffloadCapable) { return pThis->lpVtbl->IsOffloadCapable(pThis, category, pOffloadCapable); } static MA_INLINE HRESULT ma_IAudioClient3_SetClientProperties(ma_IAudioClient3* pThis, const ma_AudioClientProperties* pProperties) { return pThis->lpVtbl->SetClientProperties(pThis, pProperties); } static MA_INLINE HRESULT ma_IAudioClient3_GetBufferSizeLimits(ma_IAudioClient3* pThis, const MA_WAVEFORMATEX* pFormat, BOOL eventDriven, MA_REFERENCE_TIME* pMinBufferDuration, MA_REFERENCE_TIME* pMaxBufferDuration) { return pThis->lpVtbl->GetBufferSizeLimits(pThis, pFormat, eventDriven, pMinBufferDuration, pMaxBufferDuration); } static MA_INLINE HRESULT ma_IAudioClient3_GetSharedModeEnginePeriod(ma_IAudioClient3* pThis, const MA_WAVEFORMATEX* pFormat, ma_uint32* pDefaultPeriodInFrames, ma_uint32* pFundamentalPeriodInFrames, ma_uint32* pMinPeriodInFrames, ma_uint32* pMaxPeriodInFrames) { return pThis->lpVtbl->GetSharedModeEnginePeriod(pThis, pFormat, pDefaultPeriodInFrames, pFundamentalPeriodInFrames, pMinPeriodInFrames, pMaxPeriodInFrames); } static MA_INLINE HRESULT ma_IAudioClient3_GetCurrentSharedModeEnginePeriod(ma_IAudioClient3* pThis, MA_WAVEFORMATEX** ppFormat, ma_uint32* pCurrentPeriodInFrames) { return pThis->lpVtbl->GetCurrentSharedModeEnginePeriod(pThis, ppFormat, pCurrentPeriodInFrames); } static MA_INLINE HRESULT ma_IAudioClient3_InitializeSharedAudioStream(ma_IAudioClient3* pThis, DWORD streamFlags, ma_uint32 periodInFrames, const MA_WAVEFORMATEX* pFormat, const GUID* pAudioSessionGUID) { return pThis->lpVtbl->InitializeSharedAudioStream(pThis, streamFlags, periodInFrames, pFormat, pAudioSessionGUID); } /* IAudioRenderClient */ typedef struct { /* IUnknown */ HRESULT (STDMETHODCALLTYPE * QueryInterface)(ma_IAudioRenderClient* pThis, const IID* const riid, void** ppObject); ULONG (STDMETHODCALLTYPE * AddRef) (ma_IAudioRenderClient* pThis); ULONG (STDMETHODCALLTYPE * Release) (ma_IAudioRenderClient* pThis); /* IAudioRenderClient */ HRESULT (STDMETHODCALLTYPE * GetBuffer) (ma_IAudioRenderClient* pThis, ma_uint32 numFramesRequested, BYTE** ppData); HRESULT (STDMETHODCALLTYPE * ReleaseBuffer)(ma_IAudioRenderClient* pThis, ma_uint32 numFramesWritten, DWORD dwFlags); } ma_IAudioRenderClientVtbl; struct ma_IAudioRenderClient { ma_IAudioRenderClientVtbl* lpVtbl; }; static MA_INLINE HRESULT ma_IAudioRenderClient_QueryInterface(ma_IAudioRenderClient* pThis, const IID* const riid, void** ppObject) { return pThis->lpVtbl->QueryInterface(pThis, riid, ppObject); } static MA_INLINE ULONG ma_IAudioRenderClient_AddRef(ma_IAudioRenderClient* pThis) { return pThis->lpVtbl->AddRef(pThis); } static MA_INLINE ULONG ma_IAudioRenderClient_Release(ma_IAudioRenderClient* pThis) { return pThis->lpVtbl->Release(pThis); } static MA_INLINE HRESULT ma_IAudioRenderClient_GetBuffer(ma_IAudioRenderClient* pThis, ma_uint32 numFramesRequested, BYTE** ppData) { return pThis->lpVtbl->GetBuffer(pThis, numFramesRequested, ppData); } static MA_INLINE HRESULT ma_IAudioRenderClient_ReleaseBuffer(ma_IAudioRenderClient* pThis, ma_uint32 numFramesWritten, DWORD dwFlags) { return pThis->lpVtbl->ReleaseBuffer(pThis, numFramesWritten, dwFlags); } /* IAudioCaptureClient */ typedef struct { /* IUnknown */ HRESULT (STDMETHODCALLTYPE * QueryInterface)(ma_IAudioCaptureClient* pThis, const IID* const riid, void** ppObject); ULONG (STDMETHODCALLTYPE * AddRef) (ma_IAudioCaptureClient* pThis); ULONG (STDMETHODCALLTYPE * Release) (ma_IAudioCaptureClient* pThis); /* IAudioRenderClient */ HRESULT (STDMETHODCALLTYPE * GetBuffer) (ma_IAudioCaptureClient* pThis, BYTE** ppData, ma_uint32* pNumFramesToRead, DWORD* pFlags, ma_uint64* pDevicePosition, ma_uint64* pQPCPosition); HRESULT (STDMETHODCALLTYPE * ReleaseBuffer) (ma_IAudioCaptureClient* pThis, ma_uint32 numFramesRead); HRESULT (STDMETHODCALLTYPE * GetNextPacketSize)(ma_IAudioCaptureClient* pThis, ma_uint32* pNumFramesInNextPacket); } ma_IAudioCaptureClientVtbl; struct ma_IAudioCaptureClient { ma_IAudioCaptureClientVtbl* lpVtbl; }; static MA_INLINE HRESULT ma_IAudioCaptureClient_QueryInterface(ma_IAudioCaptureClient* pThis, const IID* const riid, void** ppObject) { return pThis->lpVtbl->QueryInterface(pThis, riid, ppObject); } static MA_INLINE ULONG ma_IAudioCaptureClient_AddRef(ma_IAudioCaptureClient* pThis) { return pThis->lpVtbl->AddRef(pThis); } static MA_INLINE ULONG ma_IAudioCaptureClient_Release(ma_IAudioCaptureClient* pThis) { return pThis->lpVtbl->Release(pThis); } static MA_INLINE HRESULT ma_IAudioCaptureClient_GetBuffer(ma_IAudioCaptureClient* pThis, BYTE** ppData, ma_uint32* pNumFramesToRead, DWORD* pFlags, ma_uint64* pDevicePosition, ma_uint64* pQPCPosition) { return pThis->lpVtbl->GetBuffer(pThis, ppData, pNumFramesToRead, pFlags, pDevicePosition, pQPCPosition); } static MA_INLINE HRESULT ma_IAudioCaptureClient_ReleaseBuffer(ma_IAudioCaptureClient* pThis, ma_uint32 numFramesRead) { return pThis->lpVtbl->ReleaseBuffer(pThis, numFramesRead); } static MA_INLINE HRESULT ma_IAudioCaptureClient_GetNextPacketSize(ma_IAudioCaptureClient* pThis, ma_uint32* pNumFramesInNextPacket) { return pThis->lpVtbl->GetNextPacketSize(pThis, pNumFramesInNextPacket); } #if defined(MA_WIN32_UWP) /* mmdevapi Functions */ typedef HRESULT (WINAPI * MA_PFN_ActivateAudioInterfaceAsync)(const wchar_t* deviceInterfacePath, const IID* riid, MA_PROPVARIANT* activationParams, ma_IActivateAudioInterfaceCompletionHandler* completionHandler, ma_IActivateAudioInterfaceAsyncOperation** activationOperation); #endif /* Avrt Functions */ typedef HANDLE (WINAPI * MA_PFN_AvSetMmThreadCharacteristicsA)(const char* TaskName, DWORD* TaskIndex); typedef BOOL (WINAPI * MA_PFN_AvRevertMmThreadCharacteristics)(HANDLE AvrtHandle); #if !defined(MA_WIN32_DESKTOP) && !defined(MA_WIN32_GDK) typedef struct ma_completion_handler_uwp ma_completion_handler_uwp; typedef struct { /* IUnknown */ HRESULT (STDMETHODCALLTYPE * QueryInterface)(ma_completion_handler_uwp* pThis, const IID* const riid, void** ppObject); ULONG (STDMETHODCALLTYPE * AddRef) (ma_completion_handler_uwp* pThis); ULONG (STDMETHODCALLTYPE * Release) (ma_completion_handler_uwp* pThis); /* IActivateAudioInterfaceCompletionHandler */ HRESULT (STDMETHODCALLTYPE * ActivateCompleted)(ma_completion_handler_uwp* pThis, ma_IActivateAudioInterfaceAsyncOperation* pActivateOperation); } ma_completion_handler_uwp_vtbl; struct ma_completion_handler_uwp { ma_completion_handler_uwp_vtbl* lpVtbl; MA_ATOMIC(4, ma_uint32) counter; HANDLE hEvent; }; static HRESULT STDMETHODCALLTYPE ma_completion_handler_uwp_QueryInterface(ma_completion_handler_uwp* pThis, const IID* const riid, void** ppObject) { /* We need to "implement" IAgileObject which is just an indicator that's used internally by WASAPI for some multithreading management. To "implement" this, we just make sure we return pThis when the IAgileObject is requested. */ if (!ma_is_guid_equal(riid, &MA_IID_IUnknown) && !ma_is_guid_equal(riid, &MA_IID_IActivateAudioInterfaceCompletionHandler) && !ma_is_guid_equal(riid, &MA_IID_IAgileObject)) { *ppObject = NULL; return E_NOINTERFACE; } /* Getting here means the IID is IUnknown or IMMNotificationClient. */ *ppObject = (void*)pThis; ((ma_completion_handler_uwp_vtbl*)pThis->lpVtbl)->AddRef(pThis); return S_OK; } static ULONG STDMETHODCALLTYPE ma_completion_handler_uwp_AddRef(ma_completion_handler_uwp* pThis) { return (ULONG)ma_atomic_fetch_add_32(&pThis->counter, 1) + 1; } static ULONG STDMETHODCALLTYPE ma_completion_handler_uwp_Release(ma_completion_handler_uwp* pThis) { ma_uint32 newRefCount = ma_atomic_fetch_sub_32(&pThis->counter, 1) - 1; if (newRefCount == 0) { return 0; /* We don't free anything here because we never allocate the object on the heap. */ } return (ULONG)newRefCount; } static HRESULT STDMETHODCALLTYPE ma_completion_handler_uwp_ActivateCompleted(ma_completion_handler_uwp* pThis, ma_IActivateAudioInterfaceAsyncOperation* pActivateOperation) { (void)pActivateOperation; SetEvent(pThis->hEvent); return S_OK; } static ma_completion_handler_uwp_vtbl g_maCompletionHandlerVtblInstance = { ma_completion_handler_uwp_QueryInterface, ma_completion_handler_uwp_AddRef, ma_completion_handler_uwp_Release, ma_completion_handler_uwp_ActivateCompleted }; static ma_result ma_completion_handler_uwp_init(ma_completion_handler_uwp* pHandler) { MA_ASSERT(pHandler != NULL); MA_ZERO_OBJECT(pHandler); pHandler->lpVtbl = &g_maCompletionHandlerVtblInstance; pHandler->counter = 1; pHandler->hEvent = CreateEventA(NULL, FALSE, FALSE, NULL); if (pHandler->hEvent == NULL) { return ma_result_from_GetLastError(GetLastError()); } return MA_SUCCESS; } static void ma_completion_handler_uwp_uninit(ma_completion_handler_uwp* pHandler) { if (pHandler->hEvent != NULL) { CloseHandle(pHandler->hEvent); } } static void ma_completion_handler_uwp_wait(ma_completion_handler_uwp* pHandler) { WaitForSingleObject((HANDLE)pHandler->hEvent, INFINITE); } #endif /* !MA_WIN32_DESKTOP */ /* We need a virtual table for our notification client object that's used for detecting changes to the default device. */ #if defined(MA_WIN32_DESKTOP) || defined(MA_WIN32_GDK) static HRESULT STDMETHODCALLTYPE ma_IMMNotificationClient_QueryInterface(ma_IMMNotificationClient* pThis, const IID* const riid, void** ppObject) { /* We care about two interfaces - IUnknown and IMMNotificationClient. If the requested IID is something else we just return E_NOINTERFACE. Otherwise we need to increment the reference counter and return S_OK. */ if (!ma_is_guid_equal(riid, &MA_IID_IUnknown) && !ma_is_guid_equal(riid, &MA_IID_IMMNotificationClient)) { *ppObject = NULL; return E_NOINTERFACE; } /* Getting here means the IID is IUnknown or IMMNotificationClient. */ *ppObject = (void*)pThis; ((ma_IMMNotificationClientVtbl*)pThis->lpVtbl)->AddRef(pThis); return S_OK; } static ULONG STDMETHODCALLTYPE ma_IMMNotificationClient_AddRef(ma_IMMNotificationClient* pThis) { return (ULONG)ma_atomic_fetch_add_32(&pThis->counter, 1) + 1; } static ULONG STDMETHODCALLTYPE ma_IMMNotificationClient_Release(ma_IMMNotificationClient* pThis) { ma_uint32 newRefCount = ma_atomic_fetch_sub_32(&pThis->counter, 1) - 1; if (newRefCount == 0) { return 0; /* We don't free anything here because we never allocate the object on the heap. */ } return (ULONG)newRefCount; } static HRESULT STDMETHODCALLTYPE ma_IMMNotificationClient_OnDeviceStateChanged(ma_IMMNotificationClient* pThis, const WCHAR* pDeviceID, DWORD dwNewState) { ma_bool32 isThisDevice = MA_FALSE; ma_bool32 isCapture = MA_FALSE; ma_bool32 isPlayback = MA_FALSE; #ifdef MA_DEBUG_OUTPUT /*ma_log_postf(ma_device_get_log(pThis->pDevice), MA_LOG_LEVEL_DEBUG, "IMMNotificationClient_OnDeviceStateChanged(pDeviceID=%S, dwNewState=%u)\n", (pDeviceID != NULL) ? pDeviceID : L"(NULL)", (unsigned int)dwNewState);*/ #endif /* There have been reports of a hang when a playback device is disconnected. The idea with this code is to explicitly stop the device if we detect that the device is disabled or has been unplugged. */ if (pThis->pDevice->wasapi.allowCaptureAutoStreamRouting && (pThis->pDevice->type == ma_device_type_capture || pThis->pDevice->type == ma_device_type_duplex || pThis->pDevice->type == ma_device_type_loopback)) { isCapture = MA_TRUE; if (ma_strcmp_WCHAR(pThis->pDevice->capture.id.wasapi, pDeviceID) == 0) { isThisDevice = MA_TRUE; } } if (pThis->pDevice->wasapi.allowPlaybackAutoStreamRouting && (pThis->pDevice->type == ma_device_type_playback || pThis->pDevice->type == ma_device_type_duplex)) { isPlayback = MA_TRUE; if (ma_strcmp_WCHAR(pThis->pDevice->playback.id.wasapi, pDeviceID) == 0) { isThisDevice = MA_TRUE; } } /* If the device ID matches our device we need to mark our device as detached and stop it. When a device is added in OnDeviceAdded(), we'll restart it. We only mark it as detached if the device was started at the time of being removed. */ if (isThisDevice) { if ((dwNewState & MA_MM_DEVICE_STATE_ACTIVE) == 0) { /* Unplugged or otherwise unavailable. Mark as detached if we were in a playing state. We'll use this to determine whether or not we need to automatically start the device when it's plugged back in again. */ if (ma_device_get_state(pThis->pDevice) == ma_device_state_started) { if (isPlayback) { pThis->pDevice->wasapi.isDetachedPlayback = MA_TRUE; } if (isCapture) { pThis->pDevice->wasapi.isDetachedCapture = MA_TRUE; } ma_device_stop(pThis->pDevice); } } if ((dwNewState & MA_MM_DEVICE_STATE_ACTIVE) != 0) { /* The device was activated. If we were detached, we need to start it again. */ ma_bool8 tryRestartingDevice = MA_FALSE; if (isPlayback) { if (pThis->pDevice->wasapi.isDetachedPlayback) { pThis->pDevice->wasapi.isDetachedPlayback = MA_FALSE; ma_device_reroute__wasapi(pThis->pDevice, ma_device_type_playback); tryRestartingDevice = MA_TRUE; } } if (isCapture) { if (pThis->pDevice->wasapi.isDetachedCapture) { pThis->pDevice->wasapi.isDetachedCapture = MA_FALSE; ma_device_reroute__wasapi(pThis->pDevice, (pThis->pDevice->type == ma_device_type_loopback) ? ma_device_type_loopback : ma_device_type_capture); tryRestartingDevice = MA_TRUE; } } if (tryRestartingDevice) { if (pThis->pDevice->wasapi.isDetachedPlayback == MA_FALSE && pThis->pDevice->wasapi.isDetachedCapture == MA_FALSE) { ma_device_start(pThis->pDevice); } } } } return S_OK; } static HRESULT STDMETHODCALLTYPE ma_IMMNotificationClient_OnDeviceAdded(ma_IMMNotificationClient* pThis, const WCHAR* pDeviceID) { #ifdef MA_DEBUG_OUTPUT /*ma_log_postf(ma_device_get_log(pThis->pDevice), MA_LOG_LEVEL_DEBUG, "IMMNotificationClient_OnDeviceAdded(pDeviceID=%S)\n", (pDeviceID != NULL) ? pDeviceID : L"(NULL)");*/ #endif /* We don't need to worry about this event for our purposes. */ (void)pThis; (void)pDeviceID; return S_OK; } static HRESULT STDMETHODCALLTYPE ma_IMMNotificationClient_OnDeviceRemoved(ma_IMMNotificationClient* pThis, const WCHAR* pDeviceID) { #ifdef MA_DEBUG_OUTPUT /*ma_log_postf(ma_device_get_log(pThis->pDevice), MA_LOG_LEVEL_DEBUG, "IMMNotificationClient_OnDeviceRemoved(pDeviceID=%S)\n", (pDeviceID != NULL) ? pDeviceID : L"(NULL)");*/ #endif /* We don't need to worry about this event for our purposes. */ (void)pThis; (void)pDeviceID; return S_OK; } static HRESULT STDMETHODCALLTYPE ma_IMMNotificationClient_OnDefaultDeviceChanged(ma_IMMNotificationClient* pThis, ma_EDataFlow dataFlow, ma_ERole role, const WCHAR* pDefaultDeviceID) { #ifdef MA_DEBUG_OUTPUT /*ma_log_postf(ma_device_get_log(pThis->pDevice), MA_LOG_LEVEL_DEBUG, "IMMNotificationClient_OnDefaultDeviceChanged(dataFlow=%d, role=%d, pDefaultDeviceID=%S)\n", dataFlow, role, (pDefaultDeviceID != NULL) ? pDefaultDeviceID : L"(NULL)");*/ #endif (void)role; /* We only care about devices with the same data flow as the current device. */ if ((pThis->pDevice->type == ma_device_type_playback && dataFlow != ma_eRender) || (pThis->pDevice->type == ma_device_type_capture && dataFlow != ma_eCapture) || (pThis->pDevice->type == ma_device_type_loopback && dataFlow != ma_eRender)) { ma_log_postf(ma_device_get_log(pThis->pDevice), MA_LOG_LEVEL_DEBUG, "[WASAPI] Stream rerouting abandoned because dataFlow does match device type.\n"); return S_OK; } /* We need to consider dataFlow as ma_eCapture if device is ma_device_type_loopback */ if (pThis->pDevice->type == ma_device_type_loopback) { dataFlow = ma_eCapture; } /* Don't do automatic stream routing if we're not allowed. */ if ((dataFlow == ma_eRender && pThis->pDevice->wasapi.allowPlaybackAutoStreamRouting == MA_FALSE) || (dataFlow == ma_eCapture && pThis->pDevice->wasapi.allowCaptureAutoStreamRouting == MA_FALSE)) { ma_log_postf(ma_device_get_log(pThis->pDevice), MA_LOG_LEVEL_DEBUG, "[WASAPI] Stream rerouting abandoned because automatic stream routing has been disabled by the device config.\n"); return S_OK; } /* Not currently supporting automatic stream routing in exclusive mode. This is not working correctly on my machine due to AUDCLNT_E_DEVICE_IN_USE errors when reinitializing the device. If this is a bug in miniaudio, we can try re-enabling this once it's fixed. */ if ((dataFlow == ma_eRender && pThis->pDevice->playback.shareMode == ma_share_mode_exclusive) || (dataFlow == ma_eCapture && pThis->pDevice->capture.shareMode == ma_share_mode_exclusive)) { ma_log_postf(ma_device_get_log(pThis->pDevice), MA_LOG_LEVEL_DEBUG, "[WASAPI] Stream rerouting abandoned because the device shared mode is exclusive.\n"); return S_OK; } /* Second attempt at device rerouting. We're going to retrieve the device's state at the time of the route change. We're then going to stop the device, reinitialize the device, and then start it again if the state before stopping was ma_device_state_started. */ { ma_uint32 previousState = ma_device_get_state(pThis->pDevice); ma_bool8 restartDevice = MA_FALSE; if (previousState == ma_device_state_uninitialized || previousState == ma_device_state_starting) { ma_log_postf(ma_device_get_log(pThis->pDevice), MA_LOG_LEVEL_DEBUG, "[WASAPI] Stream rerouting abandoned because the device is in the process of starting.\n"); return S_OK; } if (previousState == ma_device_state_started) { ma_device_stop(pThis->pDevice); restartDevice = MA_TRUE; } if (pDefaultDeviceID != NULL) { /* <-- The input device ID will be null if there's no other device available. */ ma_mutex_lock(&pThis->pDevice->wasapi.rerouteLock); { if (dataFlow == ma_eRender) { ma_device_reroute__wasapi(pThis->pDevice, ma_device_type_playback); if (pThis->pDevice->wasapi.isDetachedPlayback) { pThis->pDevice->wasapi.isDetachedPlayback = MA_FALSE; if (pThis->pDevice->type == ma_device_type_duplex && pThis->pDevice->wasapi.isDetachedCapture) { restartDevice = MA_FALSE; /* It's a duplex device and the capture side is detached. We cannot be restarting the device just yet. */ } else { restartDevice = MA_TRUE; /* It's not a duplex device, or the capture side is also attached so we can go ahead and restart the device. */ } } } else { ma_device_reroute__wasapi(pThis->pDevice, (pThis->pDevice->type == ma_device_type_loopback) ? ma_device_type_loopback : ma_device_type_capture); if (pThis->pDevice->wasapi.isDetachedCapture) { pThis->pDevice->wasapi.isDetachedCapture = MA_FALSE; if (pThis->pDevice->type == ma_device_type_duplex && pThis->pDevice->wasapi.isDetachedPlayback) { restartDevice = MA_FALSE; /* It's a duplex device and the playback side is detached. We cannot be restarting the device just yet. */ } else { restartDevice = MA_TRUE; /* It's not a duplex device, or the playback side is also attached so we can go ahead and restart the device. */ } } } } ma_mutex_unlock(&pThis->pDevice->wasapi.rerouteLock); if (restartDevice) { ma_device_start(pThis->pDevice); } } } return S_OK; } static HRESULT STDMETHODCALLTYPE ma_IMMNotificationClient_OnPropertyValueChanged(ma_IMMNotificationClient* pThis, const WCHAR* pDeviceID, const PROPERTYKEY key) { #ifdef MA_DEBUG_OUTPUT /*ma_log_postf(ma_device_get_log(pThis->pDevice), MA_LOG_LEVEL_DEBUG, "IMMNotificationClient_OnPropertyValueChanged(pDeviceID=%S)\n", (pDeviceID != NULL) ? pDeviceID : L"(NULL)");*/ #endif (void)pThis; (void)pDeviceID; (void)key; return S_OK; } static ma_IMMNotificationClientVtbl g_maNotificationCientVtbl = { ma_IMMNotificationClient_QueryInterface, ma_IMMNotificationClient_AddRef, ma_IMMNotificationClient_Release, ma_IMMNotificationClient_OnDeviceStateChanged, ma_IMMNotificationClient_OnDeviceAdded, ma_IMMNotificationClient_OnDeviceRemoved, ma_IMMNotificationClient_OnDefaultDeviceChanged, ma_IMMNotificationClient_OnPropertyValueChanged }; #endif /* MA_WIN32_DESKTOP */ static const char* ma_to_usage_string__wasapi(ma_wasapi_usage usage) { switch (usage) { case ma_wasapi_usage_default: return NULL; case ma_wasapi_usage_games: return "Games"; case ma_wasapi_usage_pro_audio: return "Pro Audio"; default: break; } return NULL; } #if defined(MA_WIN32_DESKTOP) || defined(MA_WIN32_GDK) typedef ma_IMMDevice ma_WASAPIDeviceInterface; #else typedef ma_IUnknown ma_WASAPIDeviceInterface; #endif #define MA_CONTEXT_COMMAND_QUIT__WASAPI 1 #define MA_CONTEXT_COMMAND_CREATE_IAUDIOCLIENT__WASAPI 2 #define MA_CONTEXT_COMMAND_RELEASE_IAUDIOCLIENT__WASAPI 3 static ma_context_command__wasapi ma_context_init_command__wasapi(int code) { ma_context_command__wasapi cmd; MA_ZERO_OBJECT(&cmd); cmd.code = code; return cmd; } static ma_result ma_context_post_command__wasapi(ma_context* pContext, const ma_context_command__wasapi* pCmd) { /* For now we are doing everything synchronously, but I might relax this later if the need arises. */ ma_result result; ma_bool32 isUsingLocalEvent = MA_FALSE; ma_event localEvent; MA_ASSERT(pContext != NULL); MA_ASSERT(pCmd != NULL); if (pCmd->pEvent == NULL) { isUsingLocalEvent = MA_TRUE; result = ma_event_init(&localEvent); if (result != MA_SUCCESS) { return result; /* Failed to create the event for this command. */ } } /* Here is where we add the command to the list. If there's not enough room we'll spin until there is. */ ma_mutex_lock(&pContext->wasapi.commandLock); { ma_uint32 index; /* Spin until we've got some space available. */ while (pContext->wasapi.commandCount == ma_countof(pContext->wasapi.commands)) { ma_yield(); } /* Space is now available. Can safely add to the list. */ index = (pContext->wasapi.commandIndex + pContext->wasapi.commandCount) % ma_countof(pContext->wasapi.commands); pContext->wasapi.commands[index] = *pCmd; pContext->wasapi.commands[index].pEvent = &localEvent; pContext->wasapi.commandCount += 1; /* Now that the command has been added, release the semaphore so ma_context_next_command__wasapi() can return. */ ma_semaphore_release(&pContext->wasapi.commandSem); } ma_mutex_unlock(&pContext->wasapi.commandLock); if (isUsingLocalEvent) { ma_event_wait(&localEvent); ma_event_uninit(&localEvent); } return MA_SUCCESS; } static ma_result ma_context_next_command__wasapi(ma_context* pContext, ma_context_command__wasapi* pCmd) { ma_result result = MA_SUCCESS; MA_ASSERT(pContext != NULL); MA_ASSERT(pCmd != NULL); result = ma_semaphore_wait(&pContext->wasapi.commandSem); if (result == MA_SUCCESS) { ma_mutex_lock(&pContext->wasapi.commandLock); { *pCmd = pContext->wasapi.commands[pContext->wasapi.commandIndex]; pContext->wasapi.commandIndex = (pContext->wasapi.commandIndex + 1) % ma_countof(pContext->wasapi.commands); pContext->wasapi.commandCount -= 1; } ma_mutex_unlock(&pContext->wasapi.commandLock); } return result; } static ma_thread_result MA_THREADCALL ma_context_command_thread__wasapi(void* pUserData) { ma_result result; ma_context* pContext = (ma_context*)pUserData; MA_ASSERT(pContext != NULL); for (;;) { ma_context_command__wasapi cmd; result = ma_context_next_command__wasapi(pContext, &cmd); if (result != MA_SUCCESS) { break; } switch (cmd.code) { case MA_CONTEXT_COMMAND_QUIT__WASAPI: { /* Do nothing. Handled after the switch. */ } break; case MA_CONTEXT_COMMAND_CREATE_IAUDIOCLIENT__WASAPI: { if (cmd.data.createAudioClient.deviceType == ma_device_type_playback) { *cmd.data.createAudioClient.pResult = ma_result_from_HRESULT(ma_IAudioClient_GetService((ma_IAudioClient*)cmd.data.createAudioClient.pAudioClient, &MA_IID_IAudioRenderClient, cmd.data.createAudioClient.ppAudioClientService)); } else { *cmd.data.createAudioClient.pResult = ma_result_from_HRESULT(ma_IAudioClient_GetService((ma_IAudioClient*)cmd.data.createAudioClient.pAudioClient, &MA_IID_IAudioCaptureClient, cmd.data.createAudioClient.ppAudioClientService)); } } break; case MA_CONTEXT_COMMAND_RELEASE_IAUDIOCLIENT__WASAPI: { if (cmd.data.releaseAudioClient.deviceType == ma_device_type_playback) { if (cmd.data.releaseAudioClient.pDevice->wasapi.pAudioClientPlayback != NULL) { ma_IAudioClient_Release((ma_IAudioClient*)cmd.data.releaseAudioClient.pDevice->wasapi.pAudioClientPlayback); cmd.data.releaseAudioClient.pDevice->wasapi.pAudioClientPlayback = NULL; } } if (cmd.data.releaseAudioClient.deviceType == ma_device_type_capture) { if (cmd.data.releaseAudioClient.pDevice->wasapi.pAudioClientCapture != NULL) { ma_IAudioClient_Release((ma_IAudioClient*)cmd.data.releaseAudioClient.pDevice->wasapi.pAudioClientCapture); cmd.data.releaseAudioClient.pDevice->wasapi.pAudioClientCapture = NULL; } } } break; default: { /* Unknown command. Ignore it, but trigger an assert in debug mode so we're aware of it. */ MA_ASSERT(MA_FALSE); } break; } if (cmd.pEvent != NULL) { ma_event_signal(cmd.pEvent); } if (cmd.code == MA_CONTEXT_COMMAND_QUIT__WASAPI) { break; /* Received a quit message. Get out of here. */ } } return (ma_thread_result)0; } static ma_result ma_device_create_IAudioClient_service__wasapi(ma_context* pContext, ma_device_type deviceType, ma_IAudioClient* pAudioClient, void** ppAudioClientService) { ma_result result; ma_result cmdResult; ma_context_command__wasapi cmd = ma_context_init_command__wasapi(MA_CONTEXT_COMMAND_CREATE_IAUDIOCLIENT__WASAPI); cmd.data.createAudioClient.deviceType = deviceType; cmd.data.createAudioClient.pAudioClient = (void*)pAudioClient; cmd.data.createAudioClient.ppAudioClientService = ppAudioClientService; cmd.data.createAudioClient.pResult = &cmdResult; /* Declared locally, but won't be dereferenced after this function returns since execution of the command will wait here. */ result = ma_context_post_command__wasapi(pContext, &cmd); /* This will not return until the command has actually been run. */ if (result != MA_SUCCESS) { return result; } return *cmd.data.createAudioClient.pResult; } #if 0 /* Not used at the moment, but leaving here for future use. */ static ma_result ma_device_release_IAudioClient_service__wasapi(ma_device* pDevice, ma_device_type deviceType) { ma_result result; ma_context_command__wasapi cmd = ma_context_init_command__wasapi(MA_CONTEXT_COMMAND_RELEASE_IAUDIOCLIENT__WASAPI); cmd.data.releaseAudioClient.pDevice = pDevice; cmd.data.releaseAudioClient.deviceType = deviceType; result = ma_context_post_command__wasapi(pDevice->pContext, &cmd); /* This will not return until the command has actually been run. */ if (result != MA_SUCCESS) { return result; } return MA_SUCCESS; } #endif static void ma_add_native_data_format_to_device_info_from_WAVEFORMATEX(const MA_WAVEFORMATEX* pWF, ma_share_mode shareMode, ma_device_info* pInfo) { MA_ASSERT(pWF != NULL); MA_ASSERT(pInfo != NULL); if (pInfo->nativeDataFormatCount >= ma_countof(pInfo->nativeDataFormats)) { return; /* Too many data formats. Need to ignore this one. Don't think this should ever happen with WASAPI. */ } pInfo->nativeDataFormats[pInfo->nativeDataFormatCount].format = ma_format_from_WAVEFORMATEX(pWF); pInfo->nativeDataFormats[pInfo->nativeDataFormatCount].channels = pWF->nChannels; pInfo->nativeDataFormats[pInfo->nativeDataFormatCount].sampleRate = pWF->nSamplesPerSec; pInfo->nativeDataFormats[pInfo->nativeDataFormatCount].flags = (shareMode == ma_share_mode_exclusive) ? MA_DATA_FORMAT_FLAG_EXCLUSIVE_MODE : 0; pInfo->nativeDataFormatCount += 1; } static ma_result ma_context_get_device_info_from_IAudioClient__wasapi(ma_context* pContext, /*ma_IMMDevice**/void* pMMDevice, ma_IAudioClient* pAudioClient, ma_device_info* pInfo) { HRESULT hr; MA_WAVEFORMATEX* pWF = NULL; MA_ASSERT(pAudioClient != NULL); MA_ASSERT(pInfo != NULL); /* Shared Mode. We use GetMixFormat() here. */ hr = ma_IAudioClient_GetMixFormat((ma_IAudioClient*)pAudioClient, (MA_WAVEFORMATEX**)&pWF); if (SUCCEEDED(hr)) { ma_add_native_data_format_to_device_info_from_WAVEFORMATEX(pWF, ma_share_mode_shared, pInfo); } else { ma_log_postf(ma_context_get_log(pContext), MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to retrieve mix format for device info retrieval."); return ma_result_from_HRESULT(hr); } /* Exlcusive Mode. We repeatedly call IsFormatSupported() here. This is not currently supported on UWP. Failure to retrieve the exclusive mode format is not considered an error, so from here on out, MA_SUCCESS is guaranteed to be returned. */ #if defined(MA_WIN32_DESKTOP) || defined(MA_WIN32_GDK) { ma_IPropertyStore *pProperties; /* The first thing to do is get the format from PKEY_AudioEngine_DeviceFormat. This should give us a channel count we assume is correct which will simplify our searching. */ hr = ma_IMMDevice_OpenPropertyStore((ma_IMMDevice*)pMMDevice, STGM_READ, &pProperties); if (SUCCEEDED(hr)) { MA_PROPVARIANT var; ma_PropVariantInit(&var); hr = ma_IPropertyStore_GetValue(pProperties, &MA_PKEY_AudioEngine_DeviceFormat, &var); if (SUCCEEDED(hr)) { pWF = (MA_WAVEFORMATEX*)var.blob.pBlobData; /* In my testing, the format returned by PKEY_AudioEngine_DeviceFormat is suitable for exclusive mode so we check this format first. If this fails, fall back to a search. */ hr = ma_IAudioClient_IsFormatSupported((ma_IAudioClient*)pAudioClient, MA_AUDCLNT_SHAREMODE_EXCLUSIVE, pWF, NULL); if (SUCCEEDED(hr)) { /* The format returned by PKEY_AudioEngine_DeviceFormat is supported. */ ma_add_native_data_format_to_device_info_from_WAVEFORMATEX(pWF, ma_share_mode_exclusive, pInfo); } else { /* The format returned by PKEY_AudioEngine_DeviceFormat is not supported, so fall back to a search. We assume the channel count returned by MA_PKEY_AudioEngine_DeviceFormat is valid and correct. For simplicity we're only returning one format. */ ma_uint32 channels = pWF->nChannels; ma_channel defaultChannelMap[MA_MAX_CHANNELS]; MA_WAVEFORMATEXTENSIBLE wf; ma_bool32 found; ma_uint32 iFormat; /* Make sure we don't overflow the channel map. */ if (channels > MA_MAX_CHANNELS) { channels = MA_MAX_CHANNELS; } ma_channel_map_init_standard(ma_standard_channel_map_microsoft, defaultChannelMap, ma_countof(defaultChannelMap), channels); MA_ZERO_OBJECT(&wf); wf.cbSize = sizeof(wf); wf.wFormatTag = WAVE_FORMAT_EXTENSIBLE; wf.nChannels = (WORD)channels; wf.dwChannelMask = ma_channel_map_to_channel_mask__win32(defaultChannelMap, channels); found = MA_FALSE; for (iFormat = 0; iFormat < ma_countof(g_maFormatPriorities); ++iFormat) { ma_format format = g_maFormatPriorities[iFormat]; ma_uint32 iSampleRate; wf.wBitsPerSample = (WORD)(ma_get_bytes_per_sample(format)*8); wf.nBlockAlign = (WORD)(wf.nChannels * wf.wBitsPerSample / 8); wf.nAvgBytesPerSec = wf.nBlockAlign * wf.nSamplesPerSec; wf.Samples.wValidBitsPerSample = /*(format == ma_format_s24_32) ? 24 :*/ wf.wBitsPerSample; if (format == ma_format_f32) { wf.SubFormat = MA_GUID_KSDATAFORMAT_SUBTYPE_IEEE_FLOAT; } else { wf.SubFormat = MA_GUID_KSDATAFORMAT_SUBTYPE_PCM; } for (iSampleRate = 0; iSampleRate < ma_countof(g_maStandardSampleRatePriorities); ++iSampleRate) { wf.nSamplesPerSec = g_maStandardSampleRatePriorities[iSampleRate]; hr = ma_IAudioClient_IsFormatSupported((ma_IAudioClient*)pAudioClient, MA_AUDCLNT_SHAREMODE_EXCLUSIVE, (MA_WAVEFORMATEX*)&wf, NULL); if (SUCCEEDED(hr)) { ma_add_native_data_format_to_device_info_from_WAVEFORMATEX((MA_WAVEFORMATEX*)&wf, ma_share_mode_exclusive, pInfo); found = MA_TRUE; break; } } if (found) { break; } } ma_PropVariantClear(pContext, &var); if (!found) { ma_log_postf(ma_context_get_log(pContext), MA_LOG_LEVEL_WARNING, "[WASAPI] Failed to find suitable device format for device info retrieval."); } } } else { ma_log_postf(ma_context_get_log(pContext), MA_LOG_LEVEL_WARNING, "[WASAPI] Failed to retrieve device format for device info retrieval."); } ma_IPropertyStore_Release(pProperties); } else { ma_log_postf(ma_context_get_log(pContext), MA_LOG_LEVEL_WARNING, "[WASAPI] Failed to open property store for device info retrieval."); } } #else { (void)pMMDevice; /* Unused. */ } #endif return MA_SUCCESS; } #if defined(MA_WIN32_DESKTOP) || defined(MA_WIN32_GDK) static ma_EDataFlow ma_device_type_to_EDataFlow(ma_device_type deviceType) { if (deviceType == ma_device_type_playback) { return ma_eRender; } else if (deviceType == ma_device_type_capture) { return ma_eCapture; } else { MA_ASSERT(MA_FALSE); return ma_eRender; /* Should never hit this. */ } } static ma_result ma_context_create_IMMDeviceEnumerator__wasapi(ma_context* pContext, ma_IMMDeviceEnumerator** ppDeviceEnumerator) { HRESULT hr; ma_IMMDeviceEnumerator* pDeviceEnumerator; MA_ASSERT(pContext != NULL); MA_ASSERT(ppDeviceEnumerator != NULL); *ppDeviceEnumerator = NULL; /* Safety. */ hr = ma_CoCreateInstance(pContext, &MA_CLSID_MMDeviceEnumerator, NULL, CLSCTX_ALL, &MA_IID_IMMDeviceEnumerator, (void**)&pDeviceEnumerator); if (FAILED(hr)) { ma_log_postf(ma_context_get_log(pContext), MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to create device enumerator."); return ma_result_from_HRESULT(hr); } *ppDeviceEnumerator = pDeviceEnumerator; return MA_SUCCESS; } static WCHAR* ma_context_get_default_device_id_from_IMMDeviceEnumerator__wasapi(ma_context* pContext, ma_IMMDeviceEnumerator* pDeviceEnumerator, ma_device_type deviceType) { HRESULT hr; ma_IMMDevice* pMMDefaultDevice = NULL; WCHAR* pDefaultDeviceID = NULL; ma_EDataFlow dataFlow; ma_ERole role; MA_ASSERT(pContext != NULL); MA_ASSERT(pDeviceEnumerator != NULL); (void)pContext; /* Grab the EDataFlow type from the device type. */ dataFlow = ma_device_type_to_EDataFlow(deviceType); /* The role is always eConsole, but we may make this configurable later. */ role = ma_eConsole; hr = ma_IMMDeviceEnumerator_GetDefaultAudioEndpoint(pDeviceEnumerator, dataFlow, role, &pMMDefaultDevice); if (FAILED(hr)) { return NULL; } hr = ma_IMMDevice_GetId(pMMDefaultDevice, &pDefaultDeviceID); ma_IMMDevice_Release(pMMDefaultDevice); pMMDefaultDevice = NULL; if (FAILED(hr)) { return NULL; } return pDefaultDeviceID; } static WCHAR* ma_context_get_default_device_id__wasapi(ma_context* pContext, ma_device_type deviceType) /* Free the returned pointer with ma_CoTaskMemFree() */ { ma_result result; ma_IMMDeviceEnumerator* pDeviceEnumerator; WCHAR* pDefaultDeviceID = NULL; MA_ASSERT(pContext != NULL); result = ma_context_create_IMMDeviceEnumerator__wasapi(pContext, &pDeviceEnumerator); if (result != MA_SUCCESS) { return NULL; } pDefaultDeviceID = ma_context_get_default_device_id_from_IMMDeviceEnumerator__wasapi(pContext, pDeviceEnumerator, deviceType); ma_IMMDeviceEnumerator_Release(pDeviceEnumerator); return pDefaultDeviceID; } static ma_result ma_context_get_MMDevice__wasapi(ma_context* pContext, ma_device_type deviceType, const ma_device_id* pDeviceID, ma_IMMDevice** ppMMDevice) { ma_IMMDeviceEnumerator* pDeviceEnumerator; HRESULT hr; MA_ASSERT(pContext != NULL); MA_ASSERT(ppMMDevice != NULL); hr = ma_CoCreateInstance(pContext, &MA_CLSID_MMDeviceEnumerator, NULL, CLSCTX_ALL, &MA_IID_IMMDeviceEnumerator, (void**)&pDeviceEnumerator); if (FAILED(hr)) { ma_log_postf(ma_context_get_log(pContext), MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to create IMMDeviceEnumerator.\n"); return ma_result_from_HRESULT(hr); } if (pDeviceID == NULL) { hr = ma_IMMDeviceEnumerator_GetDefaultAudioEndpoint(pDeviceEnumerator, (deviceType == ma_device_type_capture) ? ma_eCapture : ma_eRender, ma_eConsole, ppMMDevice); } else { hr = ma_IMMDeviceEnumerator_GetDevice(pDeviceEnumerator, pDeviceID->wasapi, ppMMDevice); } ma_IMMDeviceEnumerator_Release(pDeviceEnumerator); if (FAILED(hr)) { ma_log_postf(ma_context_get_log(pContext), MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to retrieve IMMDevice.\n"); return ma_result_from_HRESULT(hr); } return MA_SUCCESS; } static ma_result ma_context_get_device_id_from_MMDevice__wasapi(ma_context* pContext, ma_IMMDevice* pMMDevice, ma_device_id* pDeviceID) { WCHAR* pDeviceIDString; HRESULT hr; MA_ASSERT(pDeviceID != NULL); hr = ma_IMMDevice_GetId(pMMDevice, &pDeviceIDString); if (SUCCEEDED(hr)) { size_t idlen = ma_strlen_WCHAR(pDeviceIDString); if (idlen+1 > ma_countof(pDeviceID->wasapi)) { ma_CoTaskMemFree(pContext, pDeviceIDString); MA_ASSERT(MA_FALSE); /* NOTE: If this is triggered, please report it. It means the format of the ID must haved change and is too long to fit in our fixed sized buffer. */ return MA_ERROR; } MA_COPY_MEMORY(pDeviceID->wasapi, pDeviceIDString, idlen * sizeof(wchar_t)); pDeviceID->wasapi[idlen] = '\0'; ma_CoTaskMemFree(pContext, pDeviceIDString); return MA_SUCCESS; } return MA_ERROR; } static ma_result ma_context_get_device_info_from_MMDevice__wasapi(ma_context* pContext, ma_IMMDevice* pMMDevice, WCHAR* pDefaultDeviceID, ma_bool32 onlySimpleInfo, ma_device_info* pInfo) { ma_result result; HRESULT hr; MA_ASSERT(pContext != NULL); MA_ASSERT(pMMDevice != NULL); MA_ASSERT(pInfo != NULL); /* ID. */ result = ma_context_get_device_id_from_MMDevice__wasapi(pContext, pMMDevice, &pInfo->id); if (result == MA_SUCCESS) { if (pDefaultDeviceID != NULL) { if (ma_strcmp_WCHAR(pInfo->id.wasapi, pDefaultDeviceID) == 0) { pInfo->isDefault = MA_TRUE; } } } /* Description / Friendly Name */ { ma_IPropertyStore *pProperties; hr = ma_IMMDevice_OpenPropertyStore(pMMDevice, STGM_READ, &pProperties); if (SUCCEEDED(hr)) { MA_PROPVARIANT var; ma_PropVariantInit(&var); hr = ma_IPropertyStore_GetValue(pProperties, &MA_PKEY_Device_FriendlyName, &var); if (SUCCEEDED(hr)) { WideCharToMultiByte(CP_UTF8, 0, var.pwszVal, -1, pInfo->name, sizeof(pInfo->name), 0, FALSE); ma_PropVariantClear(pContext, &var); } ma_IPropertyStore_Release(pProperties); } } /* Format */ if (!onlySimpleInfo) { ma_IAudioClient* pAudioClient; hr = ma_IMMDevice_Activate(pMMDevice, &MA_IID_IAudioClient, CLSCTX_ALL, NULL, (void**)&pAudioClient); if (SUCCEEDED(hr)) { result = ma_context_get_device_info_from_IAudioClient__wasapi(pContext, pMMDevice, pAudioClient, pInfo); ma_IAudioClient_Release(pAudioClient); return result; } else { ma_log_postf(ma_context_get_log(pContext), MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to activate audio client for device info retrieval."); return ma_result_from_HRESULT(hr); } } return MA_SUCCESS; } static ma_result ma_context_enumerate_devices_by_type__wasapi(ma_context* pContext, ma_IMMDeviceEnumerator* pDeviceEnumerator, ma_device_type deviceType, ma_enum_devices_callback_proc callback, void* pUserData) { ma_result result = MA_SUCCESS; UINT deviceCount; HRESULT hr; ma_uint32 iDevice; WCHAR* pDefaultDeviceID = NULL; ma_IMMDeviceCollection* pDeviceCollection = NULL; MA_ASSERT(pContext != NULL); MA_ASSERT(callback != NULL); /* Grab the default device. We use this to know whether or not flag the returned device info as being the default. */ pDefaultDeviceID = ma_context_get_default_device_id_from_IMMDeviceEnumerator__wasapi(pContext, pDeviceEnumerator, deviceType); /* We need to enumerate the devices which returns a device collection. */ hr = ma_IMMDeviceEnumerator_EnumAudioEndpoints(pDeviceEnumerator, ma_device_type_to_EDataFlow(deviceType), MA_MM_DEVICE_STATE_ACTIVE, &pDeviceCollection); if (SUCCEEDED(hr)) { hr = ma_IMMDeviceCollection_GetCount(pDeviceCollection, &deviceCount); if (FAILED(hr)) { ma_log_postf(ma_context_get_log(pContext), MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to get device count.\n"); result = ma_result_from_HRESULT(hr); goto done; } for (iDevice = 0; iDevice < deviceCount; ++iDevice) { ma_device_info deviceInfo; ma_IMMDevice* pMMDevice; MA_ZERO_OBJECT(&deviceInfo); hr = ma_IMMDeviceCollection_Item(pDeviceCollection, iDevice, &pMMDevice); if (SUCCEEDED(hr)) { result = ma_context_get_device_info_from_MMDevice__wasapi(pContext, pMMDevice, pDefaultDeviceID, MA_TRUE, &deviceInfo); /* MA_TRUE = onlySimpleInfo. */ ma_IMMDevice_Release(pMMDevice); if (result == MA_SUCCESS) { ma_bool32 cbResult = callback(pContext, deviceType, &deviceInfo, pUserData); if (cbResult == MA_FALSE) { break; } } } } } done: if (pDefaultDeviceID != NULL) { ma_CoTaskMemFree(pContext, pDefaultDeviceID); pDefaultDeviceID = NULL; } if (pDeviceCollection != NULL) { ma_IMMDeviceCollection_Release(pDeviceCollection); pDeviceCollection = NULL; } return result; } static ma_result ma_context_get_IAudioClient_Desktop__wasapi(ma_context* pContext, ma_device_type deviceType, const ma_device_id* pDeviceID, MA_PROPVARIANT* pActivationParams, ma_IAudioClient** ppAudioClient, ma_IMMDevice** ppMMDevice) { ma_result result; HRESULT hr; MA_ASSERT(pContext != NULL); MA_ASSERT(ppAudioClient != NULL); MA_ASSERT(ppMMDevice != NULL); result = ma_context_get_MMDevice__wasapi(pContext, deviceType, pDeviceID, ppMMDevice); if (result != MA_SUCCESS) { return result; } hr = ma_IMMDevice_Activate(*ppMMDevice, &MA_IID_IAudioClient, CLSCTX_ALL, pActivationParams, (void**)ppAudioClient); if (FAILED(hr)) { return ma_result_from_HRESULT(hr); } return MA_SUCCESS; } #else static ma_result ma_context_get_IAudioClient_UWP__wasapi(ma_context* pContext, ma_device_type deviceType, const ma_device_id* pDeviceID, MA_PROPVARIANT* pActivationParams, ma_IAudioClient** ppAudioClient, ma_IUnknown** ppActivatedInterface) { ma_IActivateAudioInterfaceAsyncOperation *pAsyncOp = NULL; ma_completion_handler_uwp completionHandler; IID iid; WCHAR* iidStr; HRESULT hr; ma_result result; HRESULT activateResult; ma_IUnknown* pActivatedInterface; MA_ASSERT(pContext != NULL); MA_ASSERT(ppAudioClient != NULL); if (pDeviceID != NULL) { iidStr = (WCHAR*)pDeviceID->wasapi; } else { if (deviceType == ma_device_type_capture) { iid = MA_IID_DEVINTERFACE_AUDIO_CAPTURE; } else { iid = MA_IID_DEVINTERFACE_AUDIO_RENDER; } #if defined(__cplusplus) hr = StringFromIID(iid, &iidStr); #else hr = StringFromIID(&iid, &iidStr); #endif if (FAILED(hr)) { ma_log_postf(ma_context_get_log(pContext), MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to convert device IID to string for ActivateAudioInterfaceAsync(). Out of memory.\n"); return ma_result_from_HRESULT(hr); } } result = ma_completion_handler_uwp_init(&completionHandler); if (result != MA_SUCCESS) { ma_CoTaskMemFree(pContext, iidStr); ma_log_postf(ma_context_get_log(pContext), MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to create event for waiting for ActivateAudioInterfaceAsync().\n"); return result; } hr = ((MA_PFN_ActivateAudioInterfaceAsync)pContext->wasapi.ActivateAudioInterfaceAsync)(iidStr, &MA_IID_IAudioClient, pActivationParams, (ma_IActivateAudioInterfaceCompletionHandler*)&completionHandler, (ma_IActivateAudioInterfaceAsyncOperation**)&pAsyncOp); if (FAILED(hr)) { ma_completion_handler_uwp_uninit(&completionHandler); ma_CoTaskMemFree(pContext, iidStr); ma_log_postf(ma_context_get_log(pContext), MA_LOG_LEVEL_ERROR, "[WASAPI] ActivateAudioInterfaceAsync() failed.\n"); return ma_result_from_HRESULT(hr); } if (pDeviceID == NULL) { ma_CoTaskMemFree(pContext, iidStr); } /* Wait for the async operation for finish. */ ma_completion_handler_uwp_wait(&completionHandler); ma_completion_handler_uwp_uninit(&completionHandler); hr = ma_IActivateAudioInterfaceAsyncOperation_GetActivateResult(pAsyncOp, &activateResult, &pActivatedInterface); ma_IActivateAudioInterfaceAsyncOperation_Release(pAsyncOp); if (FAILED(hr) || FAILED(activateResult)) { ma_log_postf(ma_context_get_log(pContext), MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to activate device.\n"); return FAILED(hr) ? ma_result_from_HRESULT(hr) : ma_result_from_HRESULT(activateResult); } /* Here is where we grab the IAudioClient interface. */ hr = ma_IUnknown_QueryInterface(pActivatedInterface, &MA_IID_IAudioClient, (void**)ppAudioClient); if (FAILED(hr)) { ma_log_postf(ma_context_get_log(pContext), MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to query IAudioClient interface.\n"); return ma_result_from_HRESULT(hr); } if (ppActivatedInterface) { *ppActivatedInterface = pActivatedInterface; } else { ma_IUnknown_Release(pActivatedInterface); } return MA_SUCCESS; } #endif /* https://docs.microsoft.com/en-us/windows/win32/api/audioclientactivationparams/ne-audioclientactivationparams-audioclient_activation_type */ typedef enum { MA_AUDIOCLIENT_ACTIVATION_TYPE_DEFAULT, MA_AUDIOCLIENT_ACTIVATION_TYPE_PROCESS_LOOPBACK } MA_AUDIOCLIENT_ACTIVATION_TYPE; /* https://docs.microsoft.com/en-us/windows/win32/api/audioclientactivationparams/ne-audioclientactivationparams-process_loopback_mode */ typedef enum { MA_PROCESS_LOOPBACK_MODE_INCLUDE_TARGET_PROCESS_TREE, MA_PROCESS_LOOPBACK_MODE_EXCLUDE_TARGET_PROCESS_TREE } MA_PROCESS_LOOPBACK_MODE; /* https://docs.microsoft.com/en-us/windows/win32/api/audioclientactivationparams/ns-audioclientactivationparams-audioclient_process_loopback_params */ typedef struct { DWORD TargetProcessId; MA_PROCESS_LOOPBACK_MODE ProcessLoopbackMode; } MA_AUDIOCLIENT_PROCESS_LOOPBACK_PARAMS; #if defined(_MSC_VER) && !defined(__clang__) #pragma warning(push) #pragma warning(disable:4201) /* nonstandard extension used: nameless struct/union */ #elif defined(__clang__) || (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8))) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wpedantic" /* For ISO C99 doesn't support unnamed structs/unions [-Wpedantic] */ #if defined(__clang__) #pragma GCC diagnostic ignored "-Wc11-extensions" /* anonymous unions are a C11 extension */ #endif #endif /* https://docs.microsoft.com/en-us/windows/win32/api/audioclientactivationparams/ns-audioclientactivationparams-audioclient_activation_params */ typedef struct { MA_AUDIOCLIENT_ACTIVATION_TYPE ActivationType; union { MA_AUDIOCLIENT_PROCESS_LOOPBACK_PARAMS ProcessLoopbackParams; }; } MA_AUDIOCLIENT_ACTIVATION_PARAMS; #if defined(_MSC_VER) && !defined(__clang__) #pragma warning(pop) #elif defined(__clang__) || (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8))) #pragma GCC diagnostic pop #endif #define MA_VIRTUAL_AUDIO_DEVICE_PROCESS_LOOPBACK L"VAD\\Process_Loopback" static ma_result ma_context_get_IAudioClient__wasapi(ma_context* pContext, ma_device_type deviceType, const ma_device_id* pDeviceID, ma_uint32 loopbackProcessID, ma_bool32 loopbackProcessExclude, ma_IAudioClient** ppAudioClient, ma_WASAPIDeviceInterface** ppDeviceInterface) { ma_result result; ma_bool32 usingProcessLoopback = MA_FALSE; MA_AUDIOCLIENT_ACTIVATION_PARAMS audioclientActivationParams; MA_PROPVARIANT activationParams; MA_PROPVARIANT* pActivationParams = NULL; ma_device_id virtualDeviceID; /* Activation parameters specific to loopback mode. Note that process-specific loopback will only work when a default device ID is specified. */ if (deviceType == ma_device_type_loopback && loopbackProcessID != 0 && pDeviceID == NULL) { usingProcessLoopback = MA_TRUE; } if (usingProcessLoopback) { MA_ZERO_OBJECT(&audioclientActivationParams); audioclientActivationParams.ActivationType = MA_AUDIOCLIENT_ACTIVATION_TYPE_PROCESS_LOOPBACK; audioclientActivationParams.ProcessLoopbackParams.ProcessLoopbackMode = (loopbackProcessExclude) ? MA_PROCESS_LOOPBACK_MODE_EXCLUDE_TARGET_PROCESS_TREE : MA_PROCESS_LOOPBACK_MODE_INCLUDE_TARGET_PROCESS_TREE; audioclientActivationParams.ProcessLoopbackParams.TargetProcessId = (DWORD)loopbackProcessID; ma_PropVariantInit(&activationParams); activationParams.vt = MA_VT_BLOB; activationParams.blob.cbSize = sizeof(audioclientActivationParams); activationParams.blob.pBlobData = (BYTE*)&audioclientActivationParams; pActivationParams = &activationParams; /* When requesting a specific device ID we need to use a special device ID. */ MA_COPY_MEMORY(virtualDeviceID.wasapi, MA_VIRTUAL_AUDIO_DEVICE_PROCESS_LOOPBACK, (wcslen(MA_VIRTUAL_AUDIO_DEVICE_PROCESS_LOOPBACK) + 1) * sizeof(wchar_t)); /* +1 for the null terminator. */ pDeviceID = &virtualDeviceID; } else { pActivationParams = NULL; /* No activation parameters required. */ } #if defined(MA_WIN32_DESKTOP) || defined(MA_WIN32_GDK) result = ma_context_get_IAudioClient_Desktop__wasapi(pContext, deviceType, pDeviceID, pActivationParams, ppAudioClient, ppDeviceInterface); #else result = ma_context_get_IAudioClient_UWP__wasapi(pContext, deviceType, pDeviceID, pActivationParams, ppAudioClient, ppDeviceInterface); #endif /* If loopback mode was requested with a process ID and initialization failed, it could be because it's trying to run on an older version of Windows where it's not supported. We need to let the caller know about this with a log message. */ if (result != MA_SUCCESS) { if (usingProcessLoopback) { ma_log_postf(ma_context_get_log(pContext), MA_LOG_LEVEL_ERROR, "[WASAPI] Loopback mode requested to %s process ID %u, but initialization failed. Support for this feature begins with Windows 10 Build 20348. Confirm your version of Windows or consider not using process-specific loopback.\n", (loopbackProcessExclude) ? "exclude" : "include", loopbackProcessID); } } return result; } static ma_result ma_context_enumerate_devices__wasapi(ma_context* pContext, ma_enum_devices_callback_proc callback, void* pUserData) { /* Different enumeration for desktop and UWP. */ #if defined(MA_WIN32_DESKTOP) || defined(MA_WIN32_GDK) /* Desktop */ HRESULT hr; ma_IMMDeviceEnumerator* pDeviceEnumerator; hr = ma_CoCreateInstance(pContext, &MA_CLSID_MMDeviceEnumerator, NULL, CLSCTX_ALL, &MA_IID_IMMDeviceEnumerator, (void**)&pDeviceEnumerator); if (FAILED(hr)) { ma_log_postf(ma_context_get_log(pContext), MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to create device enumerator."); return ma_result_from_HRESULT(hr); } ma_context_enumerate_devices_by_type__wasapi(pContext, pDeviceEnumerator, ma_device_type_playback, callback, pUserData); ma_context_enumerate_devices_by_type__wasapi(pContext, pDeviceEnumerator, ma_device_type_capture, callback, pUserData); ma_IMMDeviceEnumerator_Release(pDeviceEnumerator); #else /* UWP The MMDevice API is only supported on desktop applications. For now, while I'm still figuring out how to properly enumerate over devices without using MMDevice, I'm restricting devices to defaults. Hint: DeviceInformation::FindAllAsync() with DeviceClass.AudioCapture/AudioRender. https://blogs.windows.com/buildingapps/2014/05/15/real-time-audio-in-windows-store-and-windows-phone-apps/ */ if (callback) { ma_bool32 cbResult = MA_TRUE; /* Playback. */ if (cbResult) { ma_device_info deviceInfo; MA_ZERO_OBJECT(&deviceInfo); ma_strncpy_s(deviceInfo.name, sizeof(deviceInfo.name), MA_DEFAULT_PLAYBACK_DEVICE_NAME, (size_t)-1); deviceInfo.isDefault = MA_TRUE; cbResult = callback(pContext, ma_device_type_playback, &deviceInfo, pUserData); } /* Capture. */ if (cbResult) { ma_device_info deviceInfo; MA_ZERO_OBJECT(&deviceInfo); ma_strncpy_s(deviceInfo.name, sizeof(deviceInfo.name), MA_DEFAULT_CAPTURE_DEVICE_NAME, (size_t)-1); deviceInfo.isDefault = MA_TRUE; cbResult = callback(pContext, ma_device_type_capture, &deviceInfo, pUserData); } } #endif return MA_SUCCESS; } static ma_result ma_context_get_device_info__wasapi(ma_context* pContext, ma_device_type deviceType, const ma_device_id* pDeviceID, ma_device_info* pDeviceInfo) { #if defined(MA_WIN32_DESKTOP) || defined(MA_WIN32_GDK) ma_result result; ma_IMMDevice* pMMDevice = NULL; WCHAR* pDefaultDeviceID = NULL; result = ma_context_get_MMDevice__wasapi(pContext, deviceType, pDeviceID, &pMMDevice); if (result != MA_SUCCESS) { return result; } /* We need the default device ID so we can set the isDefault flag in the device info. */ pDefaultDeviceID = ma_context_get_default_device_id__wasapi(pContext, deviceType); result = ma_context_get_device_info_from_MMDevice__wasapi(pContext, pMMDevice, pDefaultDeviceID, MA_FALSE, pDeviceInfo); /* MA_FALSE = !onlySimpleInfo. */ if (pDefaultDeviceID != NULL) { ma_CoTaskMemFree(pContext, pDefaultDeviceID); pDefaultDeviceID = NULL; } ma_IMMDevice_Release(pMMDevice); return result; #else ma_IAudioClient* pAudioClient; ma_result result; /* UWP currently only uses default devices. */ if (deviceType == ma_device_type_playback) { ma_strncpy_s(pDeviceInfo->name, sizeof(pDeviceInfo->name), MA_DEFAULT_PLAYBACK_DEVICE_NAME, (size_t)-1); } else { ma_strncpy_s(pDeviceInfo->name, sizeof(pDeviceInfo->name), MA_DEFAULT_CAPTURE_DEVICE_NAME, (size_t)-1); } result = ma_context_get_IAudioClient_UWP__wasapi(pContext, deviceType, pDeviceID, NULL, &pAudioClient, NULL); if (result != MA_SUCCESS) { return result; } result = ma_context_get_device_info_from_IAudioClient__wasapi(pContext, NULL, pAudioClient, pDeviceInfo); pDeviceInfo->isDefault = MA_TRUE; /* UWP only supports default devices. */ ma_IAudioClient_Release(pAudioClient); return result; #endif } static ma_result ma_device_uninit__wasapi(ma_device* pDevice) { MA_ASSERT(pDevice != NULL); #if defined(MA_WIN32_DESKTOP) || defined(MA_WIN32_GDK) if (pDevice->wasapi.pDeviceEnumerator) { ((ma_IMMDeviceEnumerator*)pDevice->wasapi.pDeviceEnumerator)->lpVtbl->UnregisterEndpointNotificationCallback((ma_IMMDeviceEnumerator*)pDevice->wasapi.pDeviceEnumerator, &pDevice->wasapi.notificationClient); ma_IMMDeviceEnumerator_Release((ma_IMMDeviceEnumerator*)pDevice->wasapi.pDeviceEnumerator); } #endif if (pDevice->wasapi.pRenderClient) { if (pDevice->wasapi.pMappedBufferPlayback != NULL) { ma_IAudioRenderClient_ReleaseBuffer((ma_IAudioRenderClient*)pDevice->wasapi.pRenderClient, pDevice->wasapi.mappedBufferPlaybackCap, 0); pDevice->wasapi.pMappedBufferPlayback = NULL; pDevice->wasapi.mappedBufferPlaybackCap = 0; pDevice->wasapi.mappedBufferPlaybackLen = 0; } ma_IAudioRenderClient_Release((ma_IAudioRenderClient*)pDevice->wasapi.pRenderClient); } if (pDevice->wasapi.pCaptureClient) { if (pDevice->wasapi.pMappedBufferCapture != NULL) { ma_IAudioCaptureClient_ReleaseBuffer((ma_IAudioCaptureClient*)pDevice->wasapi.pCaptureClient, pDevice->wasapi.mappedBufferCaptureCap); pDevice->wasapi.pMappedBufferCapture = NULL; pDevice->wasapi.mappedBufferCaptureCap = 0; pDevice->wasapi.mappedBufferCaptureLen = 0; } ma_IAudioCaptureClient_Release((ma_IAudioCaptureClient*)pDevice->wasapi.pCaptureClient); } if (pDevice->wasapi.pAudioClientPlayback) { ma_IAudioClient_Release((ma_IAudioClient*)pDevice->wasapi.pAudioClientPlayback); } if (pDevice->wasapi.pAudioClientCapture) { ma_IAudioClient_Release((ma_IAudioClient*)pDevice->wasapi.pAudioClientCapture); } if (pDevice->wasapi.hEventPlayback) { CloseHandle((HANDLE)pDevice->wasapi.hEventPlayback); } if (pDevice->wasapi.hEventCapture) { CloseHandle((HANDLE)pDevice->wasapi.hEventCapture); } return MA_SUCCESS; } typedef struct { /* Input. */ ma_format formatIn; ma_uint32 channelsIn; ma_uint32 sampleRateIn; ma_channel channelMapIn[MA_MAX_CHANNELS]; ma_uint32 periodSizeInFramesIn; ma_uint32 periodSizeInMillisecondsIn; ma_uint32 periodsIn; ma_share_mode shareMode; ma_performance_profile performanceProfile; ma_bool32 noAutoConvertSRC; ma_bool32 noDefaultQualitySRC; ma_bool32 noHardwareOffloading; ma_uint32 loopbackProcessID; ma_bool32 loopbackProcessExclude; /* Output. */ ma_IAudioClient* pAudioClient; ma_IAudioRenderClient* pRenderClient; ma_IAudioCaptureClient* pCaptureClient; ma_format formatOut; ma_uint32 channelsOut; ma_uint32 sampleRateOut; ma_channel channelMapOut[MA_MAX_CHANNELS]; ma_uint32 periodSizeInFramesOut; ma_uint32 periodsOut; ma_bool32 usingAudioClient3; char deviceName[256]; ma_device_id id; } ma_device_init_internal_data__wasapi; static ma_result ma_device_init_internal__wasapi(ma_context* pContext, ma_device_type deviceType, const ma_device_id* pDeviceID, ma_device_init_internal_data__wasapi* pData) { HRESULT hr; ma_result result = MA_SUCCESS; const char* errorMsg = ""; MA_AUDCLNT_SHAREMODE shareMode = MA_AUDCLNT_SHAREMODE_SHARED; DWORD streamFlags = 0; MA_REFERENCE_TIME periodDurationInMicroseconds; ma_bool32 wasInitializedUsingIAudioClient3 = MA_FALSE; MA_WAVEFORMATEXTENSIBLE wf; ma_WASAPIDeviceInterface* pDeviceInterface = NULL; ma_IAudioClient2* pAudioClient2; ma_uint32 nativeSampleRate; ma_bool32 usingProcessLoopback = MA_FALSE; MA_ASSERT(pContext != NULL); MA_ASSERT(pData != NULL); /* This function is only used to initialize one device type: either playback, capture or loopback. Never full-duplex. */ if (deviceType == ma_device_type_duplex) { return MA_INVALID_ARGS; } usingProcessLoopback = deviceType == ma_device_type_loopback && pData->loopbackProcessID != 0 && pDeviceID == NULL; pData->pAudioClient = NULL; pData->pRenderClient = NULL; pData->pCaptureClient = NULL; streamFlags = MA_AUDCLNT_STREAMFLAGS_EVENTCALLBACK; if (!pData->noAutoConvertSRC && pData->sampleRateIn != 0 && pData->shareMode != ma_share_mode_exclusive) { /* <-- Exclusive streams must use the native sample rate. */ streamFlags |= MA_AUDCLNT_STREAMFLAGS_AUTOCONVERTPCM; } if (!pData->noDefaultQualitySRC && pData->sampleRateIn != 0 && (streamFlags & MA_AUDCLNT_STREAMFLAGS_AUTOCONVERTPCM) != 0) { streamFlags |= MA_AUDCLNT_STREAMFLAGS_SRC_DEFAULT_QUALITY; } if (deviceType == ma_device_type_loopback) { streamFlags |= MA_AUDCLNT_STREAMFLAGS_LOOPBACK; } result = ma_context_get_IAudioClient__wasapi(pContext, deviceType, pDeviceID, pData->loopbackProcessID, pData->loopbackProcessExclude, &pData->pAudioClient, &pDeviceInterface); if (result != MA_SUCCESS) { goto done; } MA_ZERO_OBJECT(&wf); /* Try enabling hardware offloading. */ if (!pData->noHardwareOffloading) { hr = ma_IAudioClient_QueryInterface(pData->pAudioClient, &MA_IID_IAudioClient2, (void**)&pAudioClient2); if (SUCCEEDED(hr)) { BOOL isHardwareOffloadingSupported = 0; hr = ma_IAudioClient2_IsOffloadCapable(pAudioClient2, MA_AudioCategory_Other, &isHardwareOffloadingSupported); if (SUCCEEDED(hr) && isHardwareOffloadingSupported) { ma_AudioClientProperties clientProperties; MA_ZERO_OBJECT(&clientProperties); clientProperties.cbSize = sizeof(clientProperties); clientProperties.bIsOffload = 1; clientProperties.eCategory = MA_AudioCategory_Other; ma_IAudioClient2_SetClientProperties(pAudioClient2, &clientProperties); } pAudioClient2->lpVtbl->Release(pAudioClient2); } } /* Here is where we try to determine the best format to use with the device. If the client if wanting exclusive mode, first try finding the best format for that. If this fails, fall back to shared mode. */ result = MA_FORMAT_NOT_SUPPORTED; if (pData->shareMode == ma_share_mode_exclusive) { #if defined(MA_WIN32_DESKTOP) || defined(MA_WIN32_GDK) /* In exclusive mode on desktop we always use the backend's native format. */ ma_IPropertyStore* pStore = NULL; hr = ma_IMMDevice_OpenPropertyStore(pDeviceInterface, STGM_READ, &pStore); if (SUCCEEDED(hr)) { MA_PROPVARIANT prop; ma_PropVariantInit(&prop); hr = ma_IPropertyStore_GetValue(pStore, &MA_PKEY_AudioEngine_DeviceFormat, &prop); if (SUCCEEDED(hr)) { MA_WAVEFORMATEX* pActualFormat = (MA_WAVEFORMATEX*)prop.blob.pBlobData; hr = ma_IAudioClient_IsFormatSupported((ma_IAudioClient*)pData->pAudioClient, MA_AUDCLNT_SHAREMODE_EXCLUSIVE, pActualFormat, NULL); if (SUCCEEDED(hr)) { MA_COPY_MEMORY(&wf, pActualFormat, sizeof(MA_WAVEFORMATEXTENSIBLE)); } ma_PropVariantClear(pContext, &prop); } ma_IPropertyStore_Release(pStore); } #else /* I do not know how to query the device's native format on UWP so for now I'm just disabling support for exclusive mode. The alternative is to enumerate over different formats and check IsFormatSupported() until you find one that works. TODO: Add support for exclusive mode to UWP. */ hr = S_FALSE; #endif if (hr == S_OK) { shareMode = MA_AUDCLNT_SHAREMODE_EXCLUSIVE; result = MA_SUCCESS; } else { result = MA_SHARE_MODE_NOT_SUPPORTED; } } else { /* In shared mode we are always using the format reported by the operating system. */ MA_WAVEFORMATEXTENSIBLE* pNativeFormat = NULL; hr = ma_IAudioClient_GetMixFormat((ma_IAudioClient*)pData->pAudioClient, (MA_WAVEFORMATEX**)&pNativeFormat); if (hr != S_OK) { /* When using process-specific loopback, GetMixFormat() seems to always fail. */ if (usingProcessLoopback) { wf.wFormatTag = WAVE_FORMAT_IEEE_FLOAT; wf.nChannels = 2; wf.nSamplesPerSec = 44100; wf.wBitsPerSample = 32; wf.nBlockAlign = wf.nChannels * wf.wBitsPerSample / 8; wf.nAvgBytesPerSec = wf.nSamplesPerSec * wf.nBlockAlign; wf.cbSize = sizeof(MA_WAVEFORMATEX); result = MA_SUCCESS; } else { result = MA_FORMAT_NOT_SUPPORTED; } } else { /* I've seen cases where cbSize will be set to sizeof(WAVEFORMATEX) even though the structure itself is given the format tag of WAVE_FORMAT_EXTENSIBLE. If the format tag is WAVE_FORMAT_EXTENSIBLE want to make sure we copy the whole WAVEFORMATEXTENSIBLE structure. Otherwise we'll have to be safe and only copy the WAVEFORMATEX part. */ if (pNativeFormat->wFormatTag == WAVE_FORMAT_EXTENSIBLE) { MA_COPY_MEMORY(&wf, pNativeFormat, sizeof(MA_WAVEFORMATEXTENSIBLE)); } else { /* I've seen a case where cbSize was set to 0. Assume sizeof(WAVEFORMATEX) in this case. */ size_t cbSize = pNativeFormat->cbSize; if (cbSize == 0) { cbSize = sizeof(MA_WAVEFORMATEX); } /* Make sure we don't copy more than the capacity of `wf`. */ if (cbSize > sizeof(wf)) { cbSize = sizeof(wf); } MA_COPY_MEMORY(&wf, pNativeFormat, cbSize); } result = MA_SUCCESS; } ma_CoTaskMemFree(pContext, pNativeFormat); shareMode = MA_AUDCLNT_SHAREMODE_SHARED; } /* Return an error if we still haven't found a format. */ if (result != MA_SUCCESS) { errorMsg = "[WASAPI] Failed to find best device mix format."; goto done; } /* Override the native sample rate with the one requested by the caller, but only if we're not using the default sample rate. We'll use WASAPI to perform the sample rate conversion. */ nativeSampleRate = wf.nSamplesPerSec; if (streamFlags & MA_AUDCLNT_STREAMFLAGS_AUTOCONVERTPCM) { wf.nSamplesPerSec = (pData->sampleRateIn != 0) ? pData->sampleRateIn : MA_DEFAULT_SAMPLE_RATE; wf.nAvgBytesPerSec = wf.nSamplesPerSec * wf.nBlockAlign; } pData->formatOut = ma_format_from_WAVEFORMATEX((MA_WAVEFORMATEX*)&wf); if (pData->formatOut == ma_format_unknown) { /* The format isn't supported. This is almost certainly because the exclusive mode format isn't supported by miniaudio. We need to return MA_SHARE_MODE_NOT_SUPPORTED in this case so that the caller can detect it and fall back to shared mode if desired. We should never get here if shared mode was requested, but just for completeness we'll check for it and return MA_FORMAT_NOT_SUPPORTED. */ if (shareMode == MA_AUDCLNT_SHAREMODE_EXCLUSIVE) { result = MA_SHARE_MODE_NOT_SUPPORTED; } else { result = MA_FORMAT_NOT_SUPPORTED; } errorMsg = "[WASAPI] Native format not supported."; goto done; } pData->channelsOut = wf.nChannels; pData->sampleRateOut = wf.nSamplesPerSec; /* Get the internal channel map based on the channel mask. There is a possibility that GetMixFormat() returns a WAVEFORMATEX instead of a WAVEFORMATEXTENSIBLE, in which case the channel mask will be undefined. In this case we'll just use the default channel map. */ if (wf.wFormatTag == WAVE_FORMAT_EXTENSIBLE || wf.cbSize >= sizeof(MA_WAVEFORMATEXTENSIBLE)) { ma_channel_mask_to_channel_map__win32(wf.dwChannelMask, pData->channelsOut, pData->channelMapOut); } else { ma_channel_map_init_standard(ma_standard_channel_map_microsoft, pData->channelMapOut, ma_countof(pData->channelMapOut), pData->channelsOut); } /* Period size. */ pData->periodsOut = (pData->periodsIn != 0) ? pData->periodsIn : MA_DEFAULT_PERIODS; pData->periodSizeInFramesOut = pData->periodSizeInFramesIn; if (pData->periodSizeInFramesOut == 0) { if (pData->periodSizeInMillisecondsIn == 0) { if (pData->performanceProfile == ma_performance_profile_low_latency) { pData->periodSizeInFramesOut = ma_calculate_buffer_size_in_frames_from_milliseconds(MA_DEFAULT_PERIOD_SIZE_IN_MILLISECONDS_LOW_LATENCY, wf.nSamplesPerSec); } else { pData->periodSizeInFramesOut = ma_calculate_buffer_size_in_frames_from_milliseconds(MA_DEFAULT_PERIOD_SIZE_IN_MILLISECONDS_CONSERVATIVE, wf.nSamplesPerSec); } } else { pData->periodSizeInFramesOut = ma_calculate_buffer_size_in_frames_from_milliseconds(pData->periodSizeInMillisecondsIn, wf.nSamplesPerSec); } } periodDurationInMicroseconds = ((ma_uint64)pData->periodSizeInFramesOut * 1000 * 1000) / wf.nSamplesPerSec; /* Slightly different initialization for shared and exclusive modes. We try exclusive mode first, and if it fails, fall back to shared mode. */ if (shareMode == MA_AUDCLNT_SHAREMODE_EXCLUSIVE) { MA_REFERENCE_TIME bufferDuration = periodDurationInMicroseconds * pData->periodsOut * 10; /* If the periodicy is too small, Initialize() will fail with AUDCLNT_E_INVALID_DEVICE_PERIOD. In this case we should just keep increasing it and trying it again. */ hr = E_FAIL; for (;;) { hr = ma_IAudioClient_Initialize((ma_IAudioClient*)pData->pAudioClient, shareMode, streamFlags, bufferDuration, bufferDuration, (MA_WAVEFORMATEX*)&wf, NULL); if (hr == MA_AUDCLNT_E_INVALID_DEVICE_PERIOD) { if (bufferDuration > 500*10000) { break; } else { if (bufferDuration == 0) { /* <-- Just a sanity check to prevent an infinit loop. Should never happen, but it makes me feel better. */ break; } bufferDuration = bufferDuration * 2; continue; } } else { break; } } if (hr == MA_AUDCLNT_E_BUFFER_SIZE_NOT_ALIGNED) { ma_uint32 bufferSizeInFrames; hr = ma_IAudioClient_GetBufferSize((ma_IAudioClient*)pData->pAudioClient, &bufferSizeInFrames); if (SUCCEEDED(hr)) { bufferDuration = (MA_REFERENCE_TIME)((10000.0 * 1000 / wf.nSamplesPerSec * bufferSizeInFrames) + 0.5); /* Unfortunately we need to release and re-acquire the audio client according to MSDN. Seems silly - why not just call IAudioClient_Initialize() again?! */ ma_IAudioClient_Release((ma_IAudioClient*)pData->pAudioClient); #if defined(MA_WIN32_DESKTOP) || defined(MA_WIN32_GDK) hr = ma_IMMDevice_Activate(pDeviceInterface, &MA_IID_IAudioClient, CLSCTX_ALL, NULL, (void**)&pData->pAudioClient); #else hr = ma_IUnknown_QueryInterface(pDeviceInterface, &MA_IID_IAudioClient, (void**)&pData->pAudioClient); #endif if (SUCCEEDED(hr)) { hr = ma_IAudioClient_Initialize((ma_IAudioClient*)pData->pAudioClient, shareMode, streamFlags, bufferDuration, bufferDuration, (MA_WAVEFORMATEX*)&wf, NULL); } } } if (FAILED(hr)) { /* Failed to initialize in exclusive mode. Don't fall back to shared mode - instead tell the client about it. They can reinitialize in shared mode if they want. */ if (hr == E_ACCESSDENIED) { errorMsg = "[WASAPI] Failed to initialize device in exclusive mode. Access denied.", result = MA_ACCESS_DENIED; } else if (hr == MA_AUDCLNT_E_DEVICE_IN_USE) { errorMsg = "[WASAPI] Failed to initialize device in exclusive mode. Device in use.", result = MA_BUSY; } else { errorMsg = "[WASAPI] Failed to initialize device in exclusive mode."; result = ma_result_from_HRESULT(hr); } goto done; } } if (shareMode == MA_AUDCLNT_SHAREMODE_SHARED) { /* Low latency shared mode via IAudioClient3. NOTE ==== Contrary to the documentation on MSDN (https://docs.microsoft.com/en-us/windows/win32/api/audioclient/nf-audioclient-iaudioclient3-initializesharedaudiostream), the use of AUDCLNT_STREAMFLAGS_AUTOCONVERTPCM and AUDCLNT_STREAMFLAGS_SRC_DEFAULT_QUALITY with IAudioClient3_InitializeSharedAudioStream() absolutely does not work. Using any of these flags will result in HRESULT code 0x88890021. The other problem is that calling IAudioClient3_GetSharedModeEnginePeriod() with a sample rate different to that returned by IAudioClient_GetMixFormat() also results in an error. I'm therefore disabling low-latency shared mode with AUDCLNT_STREAMFLAGS_AUTOCONVERTPCM. */ #ifndef MA_WASAPI_NO_LOW_LATENCY_SHARED_MODE { if ((streamFlags & MA_AUDCLNT_STREAMFLAGS_AUTOCONVERTPCM) == 0 || nativeSampleRate == wf.nSamplesPerSec) { ma_IAudioClient3* pAudioClient3 = NULL; hr = ma_IAudioClient_QueryInterface(pData->pAudioClient, &MA_IID_IAudioClient3, (void**)&pAudioClient3); if (SUCCEEDED(hr)) { ma_uint32 defaultPeriodInFrames; ma_uint32 fundamentalPeriodInFrames; ma_uint32 minPeriodInFrames; ma_uint32 maxPeriodInFrames; hr = ma_IAudioClient3_GetSharedModeEnginePeriod(pAudioClient3, (MA_WAVEFORMATEX*)&wf, &defaultPeriodInFrames, &fundamentalPeriodInFrames, &minPeriodInFrames, &maxPeriodInFrames); if (SUCCEEDED(hr)) { ma_uint32 desiredPeriodInFrames = pData->periodSizeInFramesOut; ma_uint32 actualPeriodInFrames = desiredPeriodInFrames; /* Make sure the period size is a multiple of fundamentalPeriodInFrames. */ actualPeriodInFrames = actualPeriodInFrames / fundamentalPeriodInFrames; actualPeriodInFrames = actualPeriodInFrames * fundamentalPeriodInFrames; /* The period needs to be clamped between minPeriodInFrames and maxPeriodInFrames. */ actualPeriodInFrames = ma_clamp(actualPeriodInFrames, minPeriodInFrames, maxPeriodInFrames); ma_log_postf(ma_context_get_log(pContext), MA_LOG_LEVEL_DEBUG, "[WASAPI] Trying IAudioClient3_InitializeSharedAudioStream(actualPeriodInFrames=%d)\n", actualPeriodInFrames); ma_log_postf(ma_context_get_log(pContext), MA_LOG_LEVEL_DEBUG, " defaultPeriodInFrames=%d\n", defaultPeriodInFrames); ma_log_postf(ma_context_get_log(pContext), MA_LOG_LEVEL_DEBUG, " fundamentalPeriodInFrames=%d\n", fundamentalPeriodInFrames); ma_log_postf(ma_context_get_log(pContext), MA_LOG_LEVEL_DEBUG, " minPeriodInFrames=%d\n", minPeriodInFrames); ma_log_postf(ma_context_get_log(pContext), MA_LOG_LEVEL_DEBUG, " maxPeriodInFrames=%d\n", maxPeriodInFrames); /* If the client requested a largish buffer than we don't actually want to use low latency shared mode because it forces small buffers. */ if (actualPeriodInFrames >= desiredPeriodInFrames) { /* MA_AUDCLNT_STREAMFLAGS_AUTOCONVERTPCM | MA_AUDCLNT_STREAMFLAGS_SRC_DEFAULT_QUALITY must not be in the stream flags. If either of these are specified, IAudioClient3_InitializeSharedAudioStream() will fail. */ hr = ma_IAudioClient3_InitializeSharedAudioStream(pAudioClient3, streamFlags & ~(MA_AUDCLNT_STREAMFLAGS_AUTOCONVERTPCM | MA_AUDCLNT_STREAMFLAGS_SRC_DEFAULT_QUALITY), actualPeriodInFrames, (MA_WAVEFORMATEX*)&wf, NULL); if (SUCCEEDED(hr)) { wasInitializedUsingIAudioClient3 = MA_TRUE; pData->periodSizeInFramesOut = actualPeriodInFrames; ma_log_postf(ma_context_get_log(pContext), MA_LOG_LEVEL_DEBUG, "[WASAPI] Using IAudioClient3\n"); ma_log_postf(ma_context_get_log(pContext), MA_LOG_LEVEL_DEBUG, " periodSizeInFramesOut=%d\n", pData->periodSizeInFramesOut); } else { ma_log_postf(ma_context_get_log(pContext), MA_LOG_LEVEL_DEBUG, "[WASAPI] IAudioClient3_InitializeSharedAudioStream failed. Falling back to IAudioClient.\n"); } } else { ma_log_postf(ma_context_get_log(pContext), MA_LOG_LEVEL_DEBUG, "[WASAPI] Not using IAudioClient3 because the desired period size is larger than the maximum supported by IAudioClient3.\n"); } } else { ma_log_postf(ma_context_get_log(pContext), MA_LOG_LEVEL_DEBUG, "[WASAPI] IAudioClient3_GetSharedModeEnginePeriod failed. Falling back to IAudioClient.\n"); } ma_IAudioClient3_Release(pAudioClient3); pAudioClient3 = NULL; } } } #else { ma_log_postf(ma_context_get_log(pContext), MA_LOG_LEVEL_DEBUG, "[WASAPI] Not using IAudioClient3 because MA_WASAPI_NO_LOW_LATENCY_SHARED_MODE is enabled.\n"); } #endif /* If we don't have an IAudioClient3 then we need to use the normal initialization routine. */ if (!wasInitializedUsingIAudioClient3) { MA_REFERENCE_TIME bufferDuration = periodDurationInMicroseconds * pData->periodsOut * 10; /* <-- Multiply by 10 for microseconds to 100-nanoseconds. */ hr = ma_IAudioClient_Initialize((ma_IAudioClient*)pData->pAudioClient, shareMode, streamFlags, bufferDuration, 0, (const MA_WAVEFORMATEX*)&wf, NULL); if (FAILED(hr)) { if (hr == E_ACCESSDENIED) { errorMsg = "[WASAPI] Failed to initialize device. Access denied.", result = MA_ACCESS_DENIED; } else if (hr == MA_AUDCLNT_E_DEVICE_IN_USE) { errorMsg = "[WASAPI] Failed to initialize device. Device in use.", result = MA_BUSY; } else { errorMsg = "[WASAPI] Failed to initialize device.", result = ma_result_from_HRESULT(hr); } goto done; } } } if (!wasInitializedUsingIAudioClient3) { ma_uint32 bufferSizeInFrames = 0; hr = ma_IAudioClient_GetBufferSize((ma_IAudioClient*)pData->pAudioClient, &bufferSizeInFrames); if (FAILED(hr)) { errorMsg = "[WASAPI] Failed to get audio client's actual buffer size.", result = ma_result_from_HRESULT(hr); goto done; } /* When using process loopback mode, retrieval of the buffer size seems to result in totally incorrect values. In this case we'll just assume it's the same size as what we requested when we initialized the client. */ if (usingProcessLoopback) { bufferSizeInFrames = (ma_uint32)((periodDurationInMicroseconds * pData->periodsOut) * pData->sampleRateOut / 1000000); } pData->periodSizeInFramesOut = bufferSizeInFrames / pData->periodsOut; } pData->usingAudioClient3 = wasInitializedUsingIAudioClient3; if (deviceType == ma_device_type_playback) { result = ma_device_create_IAudioClient_service__wasapi(pContext, deviceType, (ma_IAudioClient*)pData->pAudioClient, (void**)&pData->pRenderClient); } else { result = ma_device_create_IAudioClient_service__wasapi(pContext, deviceType, (ma_IAudioClient*)pData->pAudioClient, (void**)&pData->pCaptureClient); } /*if (FAILED(hr)) {*/ if (result != MA_SUCCESS) { errorMsg = "[WASAPI] Failed to get audio client service."; goto done; } /* Grab the name of the device. */ #if defined(MA_WIN32_DESKTOP) || defined(MA_WIN32_GDK) { ma_IPropertyStore *pProperties; hr = ma_IMMDevice_OpenPropertyStore(pDeviceInterface, STGM_READ, &pProperties); if (SUCCEEDED(hr)) { MA_PROPVARIANT varName; ma_PropVariantInit(&varName); hr = ma_IPropertyStore_GetValue(pProperties, &MA_PKEY_Device_FriendlyName, &varName); if (SUCCEEDED(hr)) { WideCharToMultiByte(CP_UTF8, 0, varName.pwszVal, -1, pData->deviceName, sizeof(pData->deviceName), 0, FALSE); ma_PropVariantClear(pContext, &varName); } ma_IPropertyStore_Release(pProperties); } } #endif /* For the WASAPI backend we need to know the actual IDs of the device in order to do automatic stream routing so that IDs can be compared and we can determine which device has been detached and whether or not it matches with our ma_device. */ #if defined(MA_WIN32_DESKTOP) || defined(MA_WIN32_GDK) { /* Desktop */ ma_context_get_device_id_from_MMDevice__wasapi(pContext, pDeviceInterface, &pData->id); } #else { /* UWP */ /* TODO: Implement me. Need to figure out how to get the ID of the default device. */ } #endif done: /* Clean up. */ #if defined(MA_WIN32_DESKTOP) || defined(MA_WIN32_GDK) if (pDeviceInterface != NULL) { ma_IMMDevice_Release(pDeviceInterface); } #else if (pDeviceInterface != NULL) { ma_IUnknown_Release(pDeviceInterface); } #endif if (result != MA_SUCCESS) { if (pData->pRenderClient) { ma_IAudioRenderClient_Release((ma_IAudioRenderClient*)pData->pRenderClient); pData->pRenderClient = NULL; } if (pData->pCaptureClient) { ma_IAudioCaptureClient_Release((ma_IAudioCaptureClient*)pData->pCaptureClient); pData->pCaptureClient = NULL; } if (pData->pAudioClient) { ma_IAudioClient_Release((ma_IAudioClient*)pData->pAudioClient); pData->pAudioClient = NULL; } if (errorMsg != NULL && errorMsg[0] != '\0') { ma_log_postf(ma_context_get_log(pContext), MA_LOG_LEVEL_ERROR, "%s\n", errorMsg); } return result; } else { return MA_SUCCESS; } } static ma_result ma_device_reinit__wasapi(ma_device* pDevice, ma_device_type deviceType) { ma_device_init_internal_data__wasapi data; ma_result result; MA_ASSERT(pDevice != NULL); /* We only re-initialize the playback or capture device. Never a full-duplex device. */ if (deviceType == ma_device_type_duplex) { return MA_INVALID_ARGS; } /* Before reinitializing the device we need to free the previous audio clients. There's a known memory leak here. We will be calling this from the routing change callback that is fired by WASAPI. If we attempt to release the IAudioClient we will deadlock. In my opinion this is a bug. I'm not sure what I need to do to handle this cleanly, but I think we'll probably need some system where we post an event, but delay the execution of it until the callback has returned. I'm not sure how to do this reliably, however. I have set up some infrastructure for a command thread which might be useful for this. */ if (deviceType == ma_device_type_capture || deviceType == ma_device_type_loopback) { if (pDevice->wasapi.pCaptureClient) { ma_IAudioCaptureClient_Release((ma_IAudioCaptureClient*)pDevice->wasapi.pCaptureClient); pDevice->wasapi.pCaptureClient = NULL; } if (pDevice->wasapi.pAudioClientCapture) { /*ma_device_release_IAudioClient_service__wasapi(pDevice, ma_device_type_capture);*/ pDevice->wasapi.pAudioClientCapture = NULL; } } if (deviceType == ma_device_type_playback) { if (pDevice->wasapi.pRenderClient) { ma_IAudioRenderClient_Release((ma_IAudioRenderClient*)pDevice->wasapi.pRenderClient); pDevice->wasapi.pRenderClient = NULL; } if (pDevice->wasapi.pAudioClientPlayback) { /*ma_device_release_IAudioClient_service__wasapi(pDevice, ma_device_type_playback);*/ pDevice->wasapi.pAudioClientPlayback = NULL; } } if (deviceType == ma_device_type_playback) { data.formatIn = pDevice->playback.format; data.channelsIn = pDevice->playback.channels; MA_COPY_MEMORY(data.channelMapIn, pDevice->playback.channelMap, sizeof(pDevice->playback.channelMap)); data.shareMode = pDevice->playback.shareMode; } else { data.formatIn = pDevice->capture.format; data.channelsIn = pDevice->capture.channels; MA_COPY_MEMORY(data.channelMapIn, pDevice->capture.channelMap, sizeof(pDevice->capture.channelMap)); data.shareMode = pDevice->capture.shareMode; } data.sampleRateIn = pDevice->sampleRate; data.periodSizeInFramesIn = pDevice->wasapi.originalPeriodSizeInFrames; data.periodSizeInMillisecondsIn = pDevice->wasapi.originalPeriodSizeInMilliseconds; data.periodsIn = pDevice->wasapi.originalPeriods; data.performanceProfile = pDevice->wasapi.originalPerformanceProfile; data.noAutoConvertSRC = pDevice->wasapi.noAutoConvertSRC; data.noDefaultQualitySRC = pDevice->wasapi.noDefaultQualitySRC; data.noHardwareOffloading = pDevice->wasapi.noHardwareOffloading; data.loopbackProcessID = pDevice->wasapi.loopbackProcessID; data.loopbackProcessExclude = pDevice->wasapi.loopbackProcessExclude; result = ma_device_init_internal__wasapi(pDevice->pContext, deviceType, NULL, &data); if (result != MA_SUCCESS) { return result; } /* At this point we have some new objects ready to go. We need to uninitialize the previous ones and then set the new ones. */ if (deviceType == ma_device_type_capture || deviceType == ma_device_type_loopback) { pDevice->wasapi.pAudioClientCapture = data.pAudioClient; pDevice->wasapi.pCaptureClient = data.pCaptureClient; pDevice->capture.internalFormat = data.formatOut; pDevice->capture.internalChannels = data.channelsOut; pDevice->capture.internalSampleRate = data.sampleRateOut; MA_COPY_MEMORY(pDevice->capture.internalChannelMap, data.channelMapOut, sizeof(data.channelMapOut)); pDevice->capture.internalPeriodSizeInFrames = data.periodSizeInFramesOut; pDevice->capture.internalPeriods = data.periodsOut; ma_strcpy_s(pDevice->capture.name, sizeof(pDevice->capture.name), data.deviceName); ma_IAudioClient_SetEventHandle((ma_IAudioClient*)pDevice->wasapi.pAudioClientCapture, (HANDLE)pDevice->wasapi.hEventCapture); pDevice->wasapi.periodSizeInFramesCapture = data.periodSizeInFramesOut; ma_IAudioClient_GetBufferSize((ma_IAudioClient*)pDevice->wasapi.pAudioClientCapture, &pDevice->wasapi.actualBufferSizeInFramesCapture); /* We must always have a valid ID. */ ma_strcpy_s_WCHAR(pDevice->capture.id.wasapi, sizeof(pDevice->capture.id.wasapi), data.id.wasapi); } if (deviceType == ma_device_type_playback) { pDevice->wasapi.pAudioClientPlayback = data.pAudioClient; pDevice->wasapi.pRenderClient = data.pRenderClient; pDevice->playback.internalFormat = data.formatOut; pDevice->playback.internalChannels = data.channelsOut; pDevice->playback.internalSampleRate = data.sampleRateOut; MA_COPY_MEMORY(pDevice->playback.internalChannelMap, data.channelMapOut, sizeof(data.channelMapOut)); pDevice->playback.internalPeriodSizeInFrames = data.periodSizeInFramesOut; pDevice->playback.internalPeriods = data.periodsOut; ma_strcpy_s(pDevice->playback.name, sizeof(pDevice->playback.name), data.deviceName); ma_IAudioClient_SetEventHandle((ma_IAudioClient*)pDevice->wasapi.pAudioClientPlayback, (HANDLE)pDevice->wasapi.hEventPlayback); pDevice->wasapi.periodSizeInFramesPlayback = data.periodSizeInFramesOut; ma_IAudioClient_GetBufferSize((ma_IAudioClient*)pDevice->wasapi.pAudioClientPlayback, &pDevice->wasapi.actualBufferSizeInFramesPlayback); /* We must always have a valid ID because rerouting will look at it. */ ma_strcpy_s_WCHAR(pDevice->playback.id.wasapi, sizeof(pDevice->playback.id.wasapi), data.id.wasapi); } return MA_SUCCESS; } static ma_result ma_device_init__wasapi(ma_device* pDevice, const ma_device_config* pConfig, ma_device_descriptor* pDescriptorPlayback, ma_device_descriptor* pDescriptorCapture) { ma_result result = MA_SUCCESS; #if defined(MA_WIN32_DESKTOP) || defined(MA_WIN32_GDK) HRESULT hr; ma_IMMDeviceEnumerator* pDeviceEnumerator; #endif MA_ASSERT(pDevice != NULL); MA_ZERO_OBJECT(&pDevice->wasapi); pDevice->wasapi.usage = pConfig->wasapi.usage; pDevice->wasapi.noAutoConvertSRC = pConfig->wasapi.noAutoConvertSRC; pDevice->wasapi.noDefaultQualitySRC = pConfig->wasapi.noDefaultQualitySRC; pDevice->wasapi.noHardwareOffloading = pConfig->wasapi.noHardwareOffloading; pDevice->wasapi.loopbackProcessID = pConfig->wasapi.loopbackProcessID; pDevice->wasapi.loopbackProcessExclude = pConfig->wasapi.loopbackProcessExclude; /* Exclusive mode is not allowed with loopback. */ if (pConfig->deviceType == ma_device_type_loopback && pConfig->playback.shareMode == ma_share_mode_exclusive) { return MA_INVALID_DEVICE_CONFIG; } if (pConfig->deviceType == ma_device_type_capture || pConfig->deviceType == ma_device_type_duplex || pConfig->deviceType == ma_device_type_loopback) { ma_device_init_internal_data__wasapi data; data.formatIn = pDescriptorCapture->format; data.channelsIn = pDescriptorCapture->channels; data.sampleRateIn = pDescriptorCapture->sampleRate; MA_COPY_MEMORY(data.channelMapIn, pDescriptorCapture->channelMap, sizeof(pDescriptorCapture->channelMap)); data.periodSizeInFramesIn = pDescriptorCapture->periodSizeInFrames; data.periodSizeInMillisecondsIn = pDescriptorCapture->periodSizeInMilliseconds; data.periodsIn = pDescriptorCapture->periodCount; data.shareMode = pDescriptorCapture->shareMode; data.performanceProfile = pConfig->performanceProfile; data.noAutoConvertSRC = pConfig->wasapi.noAutoConvertSRC; data.noDefaultQualitySRC = pConfig->wasapi.noDefaultQualitySRC; data.noHardwareOffloading = pConfig->wasapi.noHardwareOffloading; data.loopbackProcessID = pConfig->wasapi.loopbackProcessID; data.loopbackProcessExclude = pConfig->wasapi.loopbackProcessExclude; result = ma_device_init_internal__wasapi(pDevice->pContext, (pConfig->deviceType == ma_device_type_loopback) ? ma_device_type_loopback : ma_device_type_capture, pDescriptorCapture->pDeviceID, &data); if (result != MA_SUCCESS) { return result; } pDevice->wasapi.pAudioClientCapture = data.pAudioClient; pDevice->wasapi.pCaptureClient = data.pCaptureClient; pDevice->wasapi.originalPeriodSizeInMilliseconds = pDescriptorCapture->periodSizeInMilliseconds; pDevice->wasapi.originalPeriodSizeInFrames = pDescriptorCapture->periodSizeInFrames; pDevice->wasapi.originalPeriods = pDescriptorCapture->periodCount; pDevice->wasapi.originalPerformanceProfile = pConfig->performanceProfile; /* The event for capture needs to be manual reset for the same reason as playback. We keep the initial state set to unsignaled, however, because we want to block until we actually have something for the first call to ma_device_read(). */ pDevice->wasapi.hEventCapture = (ma_handle)CreateEventA(NULL, FALSE, FALSE, NULL); /* Auto reset, unsignaled by default. */ if (pDevice->wasapi.hEventCapture == NULL) { result = ma_result_from_GetLastError(GetLastError()); if (pDevice->wasapi.pCaptureClient != NULL) { ma_IAudioCaptureClient_Release((ma_IAudioCaptureClient*)pDevice->wasapi.pCaptureClient); pDevice->wasapi.pCaptureClient = NULL; } if (pDevice->wasapi.pAudioClientCapture != NULL) { ma_IAudioClient_Release((ma_IAudioClient*)pDevice->wasapi.pAudioClientCapture); pDevice->wasapi.pAudioClientCapture = NULL; } ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to create event for capture."); return result; } ma_IAudioClient_SetEventHandle((ma_IAudioClient*)pDevice->wasapi.pAudioClientCapture, (HANDLE)pDevice->wasapi.hEventCapture); pDevice->wasapi.periodSizeInFramesCapture = data.periodSizeInFramesOut; ma_IAudioClient_GetBufferSize((ma_IAudioClient*)pDevice->wasapi.pAudioClientCapture, &pDevice->wasapi.actualBufferSizeInFramesCapture); /* We must always have a valid ID. */ ma_strcpy_s_WCHAR(pDevice->capture.id.wasapi, sizeof(pDevice->capture.id.wasapi), data.id.wasapi); /* The descriptor needs to be updated with actual values. */ pDescriptorCapture->format = data.formatOut; pDescriptorCapture->channels = data.channelsOut; pDescriptorCapture->sampleRate = data.sampleRateOut; MA_COPY_MEMORY(pDescriptorCapture->channelMap, data.channelMapOut, sizeof(data.channelMapOut)); pDescriptorCapture->periodSizeInFrames = data.periodSizeInFramesOut; pDescriptorCapture->periodCount = data.periodsOut; } if (pConfig->deviceType == ma_device_type_playback || pConfig->deviceType == ma_device_type_duplex) { ma_device_init_internal_data__wasapi data; data.formatIn = pDescriptorPlayback->format; data.channelsIn = pDescriptorPlayback->channels; data.sampleRateIn = pDescriptorPlayback->sampleRate; MA_COPY_MEMORY(data.channelMapIn, pDescriptorPlayback->channelMap, sizeof(pDescriptorPlayback->channelMap)); data.periodSizeInFramesIn = pDescriptorPlayback->periodSizeInFrames; data.periodSizeInMillisecondsIn = pDescriptorPlayback->periodSizeInMilliseconds; data.periodsIn = pDescriptorPlayback->periodCount; data.shareMode = pDescriptorPlayback->shareMode; data.performanceProfile = pConfig->performanceProfile; data.noAutoConvertSRC = pConfig->wasapi.noAutoConvertSRC; data.noDefaultQualitySRC = pConfig->wasapi.noDefaultQualitySRC; data.noHardwareOffloading = pConfig->wasapi.noHardwareOffloading; data.loopbackProcessID = pConfig->wasapi.loopbackProcessID; data.loopbackProcessExclude = pConfig->wasapi.loopbackProcessExclude; result = ma_device_init_internal__wasapi(pDevice->pContext, ma_device_type_playback, pDescriptorPlayback->pDeviceID, &data); if (result != MA_SUCCESS) { if (pConfig->deviceType == ma_device_type_duplex) { if (pDevice->wasapi.pCaptureClient != NULL) { ma_IAudioCaptureClient_Release((ma_IAudioCaptureClient*)pDevice->wasapi.pCaptureClient); pDevice->wasapi.pCaptureClient = NULL; } if (pDevice->wasapi.pAudioClientCapture != NULL) { ma_IAudioClient_Release((ma_IAudioClient*)pDevice->wasapi.pAudioClientCapture); pDevice->wasapi.pAudioClientCapture = NULL; } CloseHandle((HANDLE)pDevice->wasapi.hEventCapture); pDevice->wasapi.hEventCapture = NULL; } return result; } pDevice->wasapi.pAudioClientPlayback = data.pAudioClient; pDevice->wasapi.pRenderClient = data.pRenderClient; pDevice->wasapi.originalPeriodSizeInMilliseconds = pDescriptorPlayback->periodSizeInMilliseconds; pDevice->wasapi.originalPeriodSizeInFrames = pDescriptorPlayback->periodSizeInFrames; pDevice->wasapi.originalPeriods = pDescriptorPlayback->periodCount; pDevice->wasapi.originalPerformanceProfile = pConfig->performanceProfile; /* The event for playback is needs to be manual reset because we want to explicitly control the fact that it becomes signalled only after the whole available space has been filled, never before. The playback event also needs to be initially set to a signaled state so that the first call to ma_device_write() is able to get passed WaitForMultipleObjects(). */ pDevice->wasapi.hEventPlayback = (ma_handle)CreateEventA(NULL, FALSE, TRUE, NULL); /* Auto reset, signaled by default. */ if (pDevice->wasapi.hEventPlayback == NULL) { result = ma_result_from_GetLastError(GetLastError()); if (pConfig->deviceType == ma_device_type_duplex) { if (pDevice->wasapi.pCaptureClient != NULL) { ma_IAudioCaptureClient_Release((ma_IAudioCaptureClient*)pDevice->wasapi.pCaptureClient); pDevice->wasapi.pCaptureClient = NULL; } if (pDevice->wasapi.pAudioClientCapture != NULL) { ma_IAudioClient_Release((ma_IAudioClient*)pDevice->wasapi.pAudioClientCapture); pDevice->wasapi.pAudioClientCapture = NULL; } CloseHandle((HANDLE)pDevice->wasapi.hEventCapture); pDevice->wasapi.hEventCapture = NULL; } if (pDevice->wasapi.pRenderClient != NULL) { ma_IAudioRenderClient_Release((ma_IAudioRenderClient*)pDevice->wasapi.pRenderClient); pDevice->wasapi.pRenderClient = NULL; } if (pDevice->wasapi.pAudioClientPlayback != NULL) { ma_IAudioClient_Release((ma_IAudioClient*)pDevice->wasapi.pAudioClientPlayback); pDevice->wasapi.pAudioClientPlayback = NULL; } ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to create event for playback."); return result; } ma_IAudioClient_SetEventHandle((ma_IAudioClient*)pDevice->wasapi.pAudioClientPlayback, (HANDLE)pDevice->wasapi.hEventPlayback); pDevice->wasapi.periodSizeInFramesPlayback = data.periodSizeInFramesOut; ma_IAudioClient_GetBufferSize((ma_IAudioClient*)pDevice->wasapi.pAudioClientPlayback, &pDevice->wasapi.actualBufferSizeInFramesPlayback); /* We must always have a valid ID because rerouting will look at it. */ ma_strcpy_s_WCHAR(pDevice->playback.id.wasapi, sizeof(pDevice->playback.id.wasapi), data.id.wasapi); /* The descriptor needs to be updated with actual values. */ pDescriptorPlayback->format = data.formatOut; pDescriptorPlayback->channels = data.channelsOut; pDescriptorPlayback->sampleRate = data.sampleRateOut; MA_COPY_MEMORY(pDescriptorPlayback->channelMap, data.channelMapOut, sizeof(data.channelMapOut)); pDescriptorPlayback->periodSizeInFrames = data.periodSizeInFramesOut; pDescriptorPlayback->periodCount = data.periodsOut; } /* We need to register a notification client to detect when the device has been disabled, unplugged or re-routed (when the default device changes). When we are connecting to the default device we want to do automatic stream routing when the device is disabled or unplugged. Otherwise we want to just stop the device outright and let the application handle it. */ #if defined(MA_WIN32_DESKTOP) || defined(MA_WIN32_GDK) if (pConfig->wasapi.noAutoStreamRouting == MA_FALSE) { if ((pConfig->deviceType == ma_device_type_capture || pConfig->deviceType == ma_device_type_duplex || pConfig->deviceType == ma_device_type_loopback) && pConfig->capture.pDeviceID == NULL) { pDevice->wasapi.allowCaptureAutoStreamRouting = MA_TRUE; } if ((pConfig->deviceType == ma_device_type_playback || pConfig->deviceType == ma_device_type_duplex) && pConfig->playback.pDeviceID == NULL) { pDevice->wasapi.allowPlaybackAutoStreamRouting = MA_TRUE; } } ma_mutex_init(&pDevice->wasapi.rerouteLock); hr = ma_CoCreateInstance(pDevice->pContext, &MA_CLSID_MMDeviceEnumerator, NULL, CLSCTX_ALL, &MA_IID_IMMDeviceEnumerator, (void**)&pDeviceEnumerator); if (FAILED(hr)) { ma_device_uninit__wasapi(pDevice); ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to create device enumerator."); return ma_result_from_HRESULT(hr); } pDevice->wasapi.notificationClient.lpVtbl = (void*)&g_maNotificationCientVtbl; pDevice->wasapi.notificationClient.counter = 1; pDevice->wasapi.notificationClient.pDevice = pDevice; hr = pDeviceEnumerator->lpVtbl->RegisterEndpointNotificationCallback(pDeviceEnumerator, &pDevice->wasapi.notificationClient); if (SUCCEEDED(hr)) { pDevice->wasapi.pDeviceEnumerator = (ma_ptr)pDeviceEnumerator; } else { /* Not the end of the world if we fail to register the notification callback. We just won't support automatic stream routing. */ ma_IMMDeviceEnumerator_Release(pDeviceEnumerator); } #endif ma_atomic_bool32_set(&pDevice->wasapi.isStartedCapture, MA_FALSE); ma_atomic_bool32_set(&pDevice->wasapi.isStartedPlayback, MA_FALSE); return MA_SUCCESS; } static ma_result ma_device__get_available_frames__wasapi(ma_device* pDevice, ma_IAudioClient* pAudioClient, ma_uint32* pFrameCount) { ma_uint32 paddingFramesCount; HRESULT hr; ma_share_mode shareMode; MA_ASSERT(pDevice != NULL); MA_ASSERT(pFrameCount != NULL); *pFrameCount = 0; if ((ma_ptr)pAudioClient != pDevice->wasapi.pAudioClientPlayback && (ma_ptr)pAudioClient != pDevice->wasapi.pAudioClientCapture) { return MA_INVALID_OPERATION; } /* I've had a report that GetCurrentPadding() is returning a frame count of 0 which is preventing higher level function calls from doing anything because it thinks nothing is available. I have taken a look at the documentation and it looks like this is unnecessary in exclusive mode. From Microsoft's documentation: For an exclusive-mode rendering or capture stream that was initialized with the AUDCLNT_STREAMFLAGS_EVENTCALLBACK flag, the client typically has no use for the padding value reported by GetCurrentPadding. Instead, the client accesses an entire buffer during each processing pass. Considering this, I'm going to skip GetCurrentPadding() for exclusive mode and just report the entire buffer. This depends on the caller making sure they wait on the event handler. */ shareMode = ((ma_ptr)pAudioClient == pDevice->wasapi.pAudioClientPlayback) ? pDevice->playback.shareMode : pDevice->capture.shareMode; if (shareMode == ma_share_mode_shared) { /* Shared mode. */ hr = ma_IAudioClient_GetCurrentPadding(pAudioClient, &paddingFramesCount); if (FAILED(hr)) { return ma_result_from_HRESULT(hr); } if ((ma_ptr)pAudioClient == pDevice->wasapi.pAudioClientPlayback) { *pFrameCount = pDevice->wasapi.actualBufferSizeInFramesPlayback - paddingFramesCount; } else { *pFrameCount = paddingFramesCount; } } else { /* Exclusive mode. */ if ((ma_ptr)pAudioClient == pDevice->wasapi.pAudioClientPlayback) { *pFrameCount = pDevice->wasapi.actualBufferSizeInFramesPlayback; } else { *pFrameCount = pDevice->wasapi.actualBufferSizeInFramesCapture; } } return MA_SUCCESS; } static ma_result ma_device_reroute__wasapi(ma_device* pDevice, ma_device_type deviceType) { ma_result result; if (deviceType == ma_device_type_duplex) { return MA_INVALID_ARGS; } ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_DEBUG, "=== CHANGING DEVICE ===\n"); result = ma_device_reinit__wasapi(pDevice, deviceType); if (result != MA_SUCCESS) { ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_WARNING, "[WASAPI] Reinitializing device after route change failed.\n"); return result; } ma_device__post_init_setup(pDevice, deviceType); ma_device__on_notification_rerouted(pDevice); ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_DEBUG, "=== DEVICE CHANGED ===\n"); return MA_SUCCESS; } static ma_result ma_device_start__wasapi_nolock(ma_device* pDevice) { HRESULT hr; if (pDevice->pContext->wasapi.hAvrt) { const char* pTaskName = ma_to_usage_string__wasapi(pDevice->wasapi.usage); if (pTaskName) { DWORD idx = 0; pDevice->wasapi.hAvrtHandle = (ma_handle)((MA_PFN_AvSetMmThreadCharacteristicsA)pDevice->pContext->wasapi.AvSetMmThreadCharacteristicsA)(pTaskName, &idx); } } if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex || pDevice->type == ma_device_type_loopback) { hr = ma_IAudioClient_Start((ma_IAudioClient*)pDevice->wasapi.pAudioClientCapture); if (FAILED(hr)) { ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to start internal capture device. HRESULT = %d.", (int)hr); return ma_result_from_HRESULT(hr); } ma_atomic_bool32_set(&pDevice->wasapi.isStartedCapture, MA_TRUE); } if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) { hr = ma_IAudioClient_Start((ma_IAudioClient*)pDevice->wasapi.pAudioClientPlayback); if (FAILED(hr)) { ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to start internal playback device. HRESULT = %d.", (int)hr); return ma_result_from_HRESULT(hr); } ma_atomic_bool32_set(&pDevice->wasapi.isStartedPlayback, MA_TRUE); } return MA_SUCCESS; } static ma_result ma_device_start__wasapi(ma_device* pDevice) { ma_result result; MA_ASSERT(pDevice != NULL); /* Wait for any rerouting to finish before attempting to start the device. */ ma_mutex_lock(&pDevice->wasapi.rerouteLock); { result = ma_device_start__wasapi_nolock(pDevice); } ma_mutex_unlock(&pDevice->wasapi.rerouteLock); return result; } static ma_result ma_device_stop__wasapi_nolock(ma_device* pDevice) { ma_result result; HRESULT hr; MA_ASSERT(pDevice != NULL); if (pDevice->wasapi.hAvrtHandle) { ((MA_PFN_AvRevertMmThreadCharacteristics)pDevice->pContext->wasapi.AvRevertMmThreadcharacteristics)((HANDLE)pDevice->wasapi.hAvrtHandle); pDevice->wasapi.hAvrtHandle = NULL; } if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex || pDevice->type == ma_device_type_loopback) { hr = ma_IAudioClient_Stop((ma_IAudioClient*)pDevice->wasapi.pAudioClientCapture); if (FAILED(hr)) { ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to stop internal capture device."); return ma_result_from_HRESULT(hr); } /* The audio client needs to be reset otherwise restarting will fail. */ hr = ma_IAudioClient_Reset((ma_IAudioClient*)pDevice->wasapi.pAudioClientCapture); if (FAILED(hr)) { ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to reset internal capture device."); return ma_result_from_HRESULT(hr); } /* If we have a mapped buffer we need to release it. */ if (pDevice->wasapi.pMappedBufferCapture != NULL) { ma_IAudioCaptureClient_ReleaseBuffer((ma_IAudioCaptureClient*)pDevice->wasapi.pCaptureClient, pDevice->wasapi.mappedBufferCaptureCap); pDevice->wasapi.pMappedBufferCapture = NULL; pDevice->wasapi.mappedBufferCaptureCap = 0; pDevice->wasapi.mappedBufferCaptureLen = 0; } ma_atomic_bool32_set(&pDevice->wasapi.isStartedCapture, MA_FALSE); } if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) { /* The buffer needs to be drained before stopping the device. Not doing this will result in the last few frames not getting output to the speakers. This is a problem for very short sounds because it'll result in a significant portion of it not getting played. */ if (ma_atomic_bool32_get(&pDevice->wasapi.isStartedPlayback)) { /* We need to make sure we put a timeout here or else we'll risk getting stuck in a deadlock in some cases. */ DWORD waitTime = pDevice->wasapi.actualBufferSizeInFramesPlayback / pDevice->playback.internalSampleRate; if (pDevice->playback.shareMode == ma_share_mode_exclusive) { WaitForSingleObject((HANDLE)pDevice->wasapi.hEventPlayback, waitTime); } else { ma_uint32 prevFramesAvaialablePlayback = (ma_uint32)-1; ma_uint32 framesAvailablePlayback; for (;;) { result = ma_device__get_available_frames__wasapi(pDevice, (ma_IAudioClient*)pDevice->wasapi.pAudioClientPlayback, &framesAvailablePlayback); if (result != MA_SUCCESS) { break; } if (framesAvailablePlayback >= pDevice->wasapi.actualBufferSizeInFramesPlayback) { break; } /* Just a safety check to avoid an infinite loop. If this iteration results in a situation where the number of available frames has not changed, get out of the loop. I don't think this should ever happen, but I think it's nice to have just in case. */ if (framesAvailablePlayback == prevFramesAvaialablePlayback) { break; } prevFramesAvaialablePlayback = framesAvailablePlayback; WaitForSingleObject((HANDLE)pDevice->wasapi.hEventPlayback, waitTime * 1000); ResetEvent((HANDLE)pDevice->wasapi.hEventPlayback); /* Manual reset. */ } } } hr = ma_IAudioClient_Stop((ma_IAudioClient*)pDevice->wasapi.pAudioClientPlayback); if (FAILED(hr)) { ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to stop internal playback device."); return ma_result_from_HRESULT(hr); } /* The audio client needs to be reset otherwise restarting will fail. */ hr = ma_IAudioClient_Reset((ma_IAudioClient*)pDevice->wasapi.pAudioClientPlayback); if (FAILED(hr)) { ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to reset internal playback device."); return ma_result_from_HRESULT(hr); } if (pDevice->wasapi.pMappedBufferPlayback != NULL) { ma_IAudioRenderClient_ReleaseBuffer((ma_IAudioRenderClient*)pDevice->wasapi.pRenderClient, pDevice->wasapi.mappedBufferPlaybackCap, 0); pDevice->wasapi.pMappedBufferPlayback = NULL; pDevice->wasapi.mappedBufferPlaybackCap = 0; pDevice->wasapi.mappedBufferPlaybackLen = 0; } ma_atomic_bool32_set(&pDevice->wasapi.isStartedPlayback, MA_FALSE); } return MA_SUCCESS; } static ma_result ma_device_stop__wasapi(ma_device* pDevice) { ma_result result; MA_ASSERT(pDevice != NULL); /* Wait for any rerouting to finish before attempting to stop the device. */ ma_mutex_lock(&pDevice->wasapi.rerouteLock); { result = ma_device_stop__wasapi_nolock(pDevice); } ma_mutex_unlock(&pDevice->wasapi.rerouteLock); return result; } #ifndef MA_WASAPI_WAIT_TIMEOUT_MILLISECONDS #define MA_WASAPI_WAIT_TIMEOUT_MILLISECONDS 5000 #endif static ma_result ma_device_read__wasapi(ma_device* pDevice, void* pFrames, ma_uint32 frameCount, ma_uint32* pFramesRead) { ma_result result = MA_SUCCESS; ma_uint32 totalFramesProcessed = 0; /* When reading, we need to get a buffer and process all of it before releasing it. Because the frame count (frameCount) can be different to the size of the buffer, we'll need to cache the pointer to the buffer. */ /* Keep running until we've processed the requested number of frames. */ while (ma_device_get_state(pDevice) == ma_device_state_started && totalFramesProcessed < frameCount) { ma_uint32 framesRemaining = frameCount - totalFramesProcessed; /* If we have a mapped data buffer, consume that first. */ if (pDevice->wasapi.pMappedBufferCapture != NULL) { /* We have a cached data pointer so consume that before grabbing another one from WASAPI. */ ma_uint32 framesToProcessNow = framesRemaining; if (framesToProcessNow > pDevice->wasapi.mappedBufferCaptureLen) { framesToProcessNow = pDevice->wasapi.mappedBufferCaptureLen; } /* Now just copy the data over to the output buffer. */ ma_copy_pcm_frames( ma_offset_pcm_frames_ptr(pFrames, totalFramesProcessed, pDevice->capture.internalFormat, pDevice->capture.internalChannels), ma_offset_pcm_frames_const_ptr(pDevice->wasapi.pMappedBufferCapture, pDevice->wasapi.mappedBufferCaptureCap - pDevice->wasapi.mappedBufferCaptureLen, pDevice->capture.internalFormat, pDevice->capture.internalChannels), framesToProcessNow, pDevice->capture.internalFormat, pDevice->capture.internalChannels ); totalFramesProcessed += framesToProcessNow; pDevice->wasapi.mappedBufferCaptureLen -= framesToProcessNow; /* If the data buffer has been fully consumed we need to release it. */ if (pDevice->wasapi.mappedBufferCaptureLen == 0) { ma_IAudioCaptureClient_ReleaseBuffer((ma_IAudioCaptureClient*)pDevice->wasapi.pCaptureClient, pDevice->wasapi.mappedBufferCaptureCap); pDevice->wasapi.pMappedBufferCapture = NULL; pDevice->wasapi.mappedBufferCaptureCap = 0; } } else { /* We don't have any cached data pointer, so grab another one. */ HRESULT hr; DWORD flags = 0; /* First just ask WASAPI for a data buffer. If it's not available, we'll wait for more. */ hr = ma_IAudioCaptureClient_GetBuffer((ma_IAudioCaptureClient*)pDevice->wasapi.pCaptureClient, (BYTE**)&pDevice->wasapi.pMappedBufferCapture, &pDevice->wasapi.mappedBufferCaptureCap, &flags, NULL, NULL); if (hr == S_OK) { /* We got a data buffer. Continue to the next loop iteration which will then read from the mapped pointer. */ pDevice->wasapi.mappedBufferCaptureLen = pDevice->wasapi.mappedBufferCaptureCap; /* There have been reports that indicate that at times the AUDCLNT_BUFFERFLAGS_DATA_DISCONTINUITY is reported for every call to IAudioCaptureClient_GetBuffer() above which results in spamming of the debug messages below. To partially work around this, I'm only outputting these messages when MA_DEBUG_OUTPUT is explicitly defined. The better solution would be to figure out why the flag is always getting reported. */ #if defined(MA_DEBUG_OUTPUT) { if (flags != 0) { ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_DEBUG, "[WASAPI] Capture Flags: %ld\n", flags); if ((flags & MA_AUDCLNT_BUFFERFLAGS_DATA_DISCONTINUITY) != 0) { ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_DEBUG, "[WASAPI] Data discontinuity (possible overrun). Attempting recovery. mappedBufferCaptureCap=%d\n", pDevice->wasapi.mappedBufferCaptureCap); } } } #endif /* Overrun detection. */ if ((flags & MA_AUDCLNT_BUFFERFLAGS_DATA_DISCONTINUITY) != 0) { /* Glitched. Probably due to an overrun. */ /* If we got an overrun it probably means we're straddling the end of the buffer. In normal capture mode this is the fault of the client application because they're responsible for ensuring data is processed fast enough. In duplex mode, however, the processing of audio is tied to the playback device, so this can possibly be the result of a timing de-sync. In capture mode we're not going to do any kind of recovery because the real fix is for the client application to process faster. In duplex mode, we'll treat this as a desync and reset the buffers to prevent a never-ending sequence of glitches due to straddling the end of the buffer. */ if (pDevice->type == ma_device_type_duplex) { /* Experiment: If we empty out the *entire* buffer we may end up putting ourselves into an underrun position which isn't really any better than the overrun we're probably in right now. Instead we'll just empty out about half. */ ma_uint32 i; ma_uint32 periodCount = (pDevice->wasapi.actualBufferSizeInFramesCapture / pDevice->wasapi.periodSizeInFramesCapture); ma_uint32 iterationCount = periodCount / 2; if ((periodCount % 2) > 0) { iterationCount += 1; } for (i = 0; i < iterationCount; i += 1) { hr = ma_IAudioCaptureClient_ReleaseBuffer((ma_IAudioCaptureClient*)pDevice->wasapi.pCaptureClient, pDevice->wasapi.mappedBufferCaptureCap); if (FAILED(hr)) { ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_DEBUG, "[WASAPI] Data discontinuity recovery: IAudioCaptureClient_ReleaseBuffer() failed with %ld.\n", hr); break; } flags = 0; hr = ma_IAudioCaptureClient_GetBuffer((ma_IAudioCaptureClient*)pDevice->wasapi.pCaptureClient, (BYTE**)&pDevice->wasapi.pMappedBufferCapture, &pDevice->wasapi.mappedBufferCaptureCap, &flags, NULL, NULL); if (hr == MA_AUDCLNT_S_BUFFER_EMPTY || FAILED(hr)) { /* The buffer has been completely emptied or an error occurred. In this case we'll need to reset the state of the mapped buffer which will trigger the next iteration to get a fresh buffer from WASAPI. */ pDevice->wasapi.pMappedBufferCapture = NULL; pDevice->wasapi.mappedBufferCaptureCap = 0; pDevice->wasapi.mappedBufferCaptureLen = 0; if (hr == MA_AUDCLNT_S_BUFFER_EMPTY) { if ((flags & MA_AUDCLNT_BUFFERFLAGS_DATA_DISCONTINUITY) != 0) { ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_DEBUG, "[WASAPI] Data discontinuity recovery: Buffer emptied, and data discontinuity still reported.\n"); } else { ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_DEBUG, "[WASAPI] Data discontinuity recovery: Buffer emptied.\n"); } } if (FAILED(hr)) { ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_DEBUG, "[WASAPI] Data discontinuity recovery: IAudioCaptureClient_GetBuffer() failed with %ld.\n", hr); } break; } } /* If at this point we have a valid buffer mapped, make sure the buffer length is set appropriately. */ if (pDevice->wasapi.pMappedBufferCapture != NULL) { pDevice->wasapi.mappedBufferCaptureLen = pDevice->wasapi.mappedBufferCaptureCap; } } } continue; } else { if (hr == MA_AUDCLNT_S_BUFFER_EMPTY || hr == MA_AUDCLNT_E_BUFFER_ERROR) { /* No data is available. We need to wait for more. There's two situations to consider here. The first is normal capture mode. If this times out it probably means the microphone isn't delivering data for whatever reason. In this case we'll just abort the read and return whatever we were able to get. The other situations is loopback mode, in which case a timeout probably just means the nothing is playing through the speakers. */ /* Experiment: Use a shorter timeout for loopback mode. */ DWORD timeoutInMilliseconds = MA_WASAPI_WAIT_TIMEOUT_MILLISECONDS; if (pDevice->type == ma_device_type_loopback) { timeoutInMilliseconds = 10; } if (WaitForSingleObject((HANDLE)pDevice->wasapi.hEventCapture, timeoutInMilliseconds) != WAIT_OBJECT_0) { if (pDevice->type == ma_device_type_loopback) { continue; /* Keep waiting in loopback mode. */ } else { result = MA_ERROR; break; /* Wait failed. */ } } /* At this point we should be able to loop back to the start of the loop and try retrieving a data buffer again. */ } else { /* An error occurred and we need to abort. */ ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to retrieve internal buffer from capture device in preparation for reading from the device. HRESULT = %d. Stopping device.\n", (int)hr); result = ma_result_from_HRESULT(hr); break; } } } } /* If we were unable to process the entire requested frame count, but we still have a mapped buffer, there's a good chance either an error occurred or the device was stopped mid-read. In this case we'll need to make sure the buffer is released. */ if (totalFramesProcessed < frameCount && pDevice->wasapi.pMappedBufferCapture != NULL) { ma_IAudioCaptureClient_ReleaseBuffer((ma_IAudioCaptureClient*)pDevice->wasapi.pCaptureClient, pDevice->wasapi.mappedBufferCaptureCap); pDevice->wasapi.pMappedBufferCapture = NULL; pDevice->wasapi.mappedBufferCaptureCap = 0; pDevice->wasapi.mappedBufferCaptureLen = 0; } if (pFramesRead != NULL) { *pFramesRead = totalFramesProcessed; } return result; } static ma_result ma_device_write__wasapi(ma_device* pDevice, const void* pFrames, ma_uint32 frameCount, ma_uint32* pFramesWritten) { ma_result result = MA_SUCCESS; ma_uint32 totalFramesProcessed = 0; /* Keep writing to the device until it's stopped or we've consumed all of our input. */ while (ma_device_get_state(pDevice) == ma_device_state_started && totalFramesProcessed < frameCount) { ma_uint32 framesRemaining = frameCount - totalFramesProcessed; /* We're going to do this in a similar way to capture. We'll first check if the cached data pointer is valid, and if so, read from that. Otherwise We will call IAudioRenderClient_GetBuffer() with a requested buffer size equal to our actual period size. If it returns AUDCLNT_E_BUFFER_TOO_LARGE it means we need to wait for some data to become available. */ if (pDevice->wasapi.pMappedBufferPlayback != NULL) { /* We still have some space available in the mapped data buffer. Write to it. */ ma_uint32 framesToProcessNow = framesRemaining; if (framesToProcessNow > (pDevice->wasapi.mappedBufferPlaybackCap - pDevice->wasapi.mappedBufferPlaybackLen)) { framesToProcessNow = (pDevice->wasapi.mappedBufferPlaybackCap - pDevice->wasapi.mappedBufferPlaybackLen); } /* Now just copy the data over to the output buffer. */ ma_copy_pcm_frames( ma_offset_pcm_frames_ptr(pDevice->wasapi.pMappedBufferPlayback, pDevice->wasapi.mappedBufferPlaybackLen, pDevice->playback.internalFormat, pDevice->playback.internalChannels), ma_offset_pcm_frames_const_ptr(pFrames, totalFramesProcessed, pDevice->playback.internalFormat, pDevice->playback.internalChannels), framesToProcessNow, pDevice->playback.internalFormat, pDevice->playback.internalChannels ); totalFramesProcessed += framesToProcessNow; pDevice->wasapi.mappedBufferPlaybackLen += framesToProcessNow; /* If the data buffer has been fully consumed we need to release it. */ if (pDevice->wasapi.mappedBufferPlaybackLen == pDevice->wasapi.mappedBufferPlaybackCap) { ma_IAudioRenderClient_ReleaseBuffer((ma_IAudioRenderClient*)pDevice->wasapi.pRenderClient, pDevice->wasapi.mappedBufferPlaybackCap, 0); pDevice->wasapi.pMappedBufferPlayback = NULL; pDevice->wasapi.mappedBufferPlaybackCap = 0; pDevice->wasapi.mappedBufferPlaybackLen = 0; /* In exclusive mode we need to wait here. Exclusive mode is weird because GetBuffer() never seems to return AUDCLNT_E_BUFFER_TOO_LARGE, which is what we normally use to determine whether or not we need to wait for more data. */ if (pDevice->playback.shareMode == ma_share_mode_exclusive) { if (WaitForSingleObject((HANDLE)pDevice->wasapi.hEventPlayback, MA_WASAPI_WAIT_TIMEOUT_MILLISECONDS) != WAIT_OBJECT_0) { result = MA_ERROR; break; /* Wait failed. Probably timed out. */ } } } } else { /* We don't have a mapped data buffer so we'll need to get one. */ HRESULT hr; ma_uint32 bufferSizeInFrames; /* Special rules for exclusive mode. */ if (pDevice->playback.shareMode == ma_share_mode_exclusive) { bufferSizeInFrames = pDevice->wasapi.actualBufferSizeInFramesPlayback; } else { bufferSizeInFrames = pDevice->wasapi.periodSizeInFramesPlayback; } hr = ma_IAudioRenderClient_GetBuffer((ma_IAudioRenderClient*)pDevice->wasapi.pRenderClient, bufferSizeInFrames, (BYTE**)&pDevice->wasapi.pMappedBufferPlayback); if (hr == S_OK) { /* We have data available. */ pDevice->wasapi.mappedBufferPlaybackCap = bufferSizeInFrames; pDevice->wasapi.mappedBufferPlaybackLen = 0; } else { if (hr == MA_AUDCLNT_E_BUFFER_TOO_LARGE || hr == MA_AUDCLNT_E_BUFFER_ERROR) { /* Not enough data available. We need to wait for more. */ if (WaitForSingleObject((HANDLE)pDevice->wasapi.hEventPlayback, MA_WASAPI_WAIT_TIMEOUT_MILLISECONDS) != WAIT_OBJECT_0) { result = MA_ERROR; break; /* Wait failed. Probably timed out. */ } } else { /* Some error occurred. We'll need to abort. */ ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to retrieve internal buffer from playback device in preparation for writing to the device. HRESULT = %d. Stopping device.\n", (int)hr); result = ma_result_from_HRESULT(hr); break; } } } } if (pFramesWritten != NULL) { *pFramesWritten = totalFramesProcessed; } return result; } static ma_result ma_device_data_loop_wakeup__wasapi(ma_device* pDevice) { MA_ASSERT(pDevice != NULL); if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex || pDevice->type == ma_device_type_loopback) { SetEvent((HANDLE)pDevice->wasapi.hEventCapture); } if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) { SetEvent((HANDLE)pDevice->wasapi.hEventPlayback); } return MA_SUCCESS; } static ma_result ma_context_uninit__wasapi(ma_context* pContext) { ma_context_command__wasapi cmd = ma_context_init_command__wasapi(MA_CONTEXT_COMMAND_QUIT__WASAPI); MA_ASSERT(pContext != NULL); MA_ASSERT(pContext->backend == ma_backend_wasapi); ma_context_post_command__wasapi(pContext, &cmd); ma_thread_wait(&pContext->wasapi.commandThread); if (pContext->wasapi.hAvrt) { ma_dlclose(ma_context_get_log(pContext), pContext->wasapi.hAvrt); pContext->wasapi.hAvrt = NULL; } #if defined(MA_WIN32_UWP) { if (pContext->wasapi.hMMDevapi) { ma_dlclose(ma_context_get_log(pContext), pContext->wasapi.hMMDevapi); pContext->wasapi.hMMDevapi = NULL; } } #endif /* Only after the thread has been terminated can we uninitialize the sync objects for the command thread. */ ma_semaphore_uninit(&pContext->wasapi.commandSem); ma_mutex_uninit(&pContext->wasapi.commandLock); return MA_SUCCESS; } static ma_result ma_context_init__wasapi(ma_context* pContext, const ma_context_config* pConfig, ma_backend_callbacks* pCallbacks) { ma_result result = MA_SUCCESS; MA_ASSERT(pContext != NULL); (void)pConfig; #ifdef MA_WIN32_DESKTOP /* WASAPI is only supported in Vista SP1 and newer. The reason for SP1 and not the base version of Vista is that event-driven exclusive mode does not work until SP1. Unfortunately older compilers don't define these functions so we need to dynamically load them in order to avoid a link error. */ { ma_OSVERSIONINFOEXW osvi; ma_handle kernel32DLL; ma_PFNVerifyVersionInfoW _VerifyVersionInfoW; ma_PFNVerSetConditionMask _VerSetConditionMask; kernel32DLL = ma_dlopen(ma_context_get_log(pContext), "kernel32.dll"); if (kernel32DLL == NULL) { return MA_NO_BACKEND; } _VerifyVersionInfoW = (ma_PFNVerifyVersionInfoW )ma_dlsym(ma_context_get_log(pContext), kernel32DLL, "VerifyVersionInfoW"); _VerSetConditionMask = (ma_PFNVerSetConditionMask)ma_dlsym(ma_context_get_log(pContext), kernel32DLL, "VerSetConditionMask"); if (_VerifyVersionInfoW == NULL || _VerSetConditionMask == NULL) { ma_dlclose(ma_context_get_log(pContext), kernel32DLL); return MA_NO_BACKEND; } MA_ZERO_OBJECT(&osvi); osvi.dwOSVersionInfoSize = sizeof(osvi); osvi.dwMajorVersion = ((MA_WIN32_WINNT_VISTA >> 8) & 0xFF); osvi.dwMinorVersion = ((MA_WIN32_WINNT_VISTA >> 0) & 0xFF); osvi.wServicePackMajor = 1; if (_VerifyVersionInfoW(&osvi, MA_VER_MAJORVERSION | MA_VER_MINORVERSION | MA_VER_SERVICEPACKMAJOR, _VerSetConditionMask(_VerSetConditionMask(_VerSetConditionMask(0, MA_VER_MAJORVERSION, MA_VER_GREATER_EQUAL), MA_VER_MINORVERSION, MA_VER_GREATER_EQUAL), MA_VER_SERVICEPACKMAJOR, MA_VER_GREATER_EQUAL))) { result = MA_SUCCESS; } else { result = MA_NO_BACKEND; } ma_dlclose(ma_context_get_log(pContext), kernel32DLL); } #endif if (result != MA_SUCCESS) { return result; } MA_ZERO_OBJECT(&pContext->wasapi); #if defined(MA_WIN32_UWP) { /* Link to mmdevapi so we can get access to ActivateAudioInterfaceAsync(). */ pContext->wasapi.hMMDevapi = ma_dlopen(ma_context_get_log(pContext), "mmdevapi.dll"); if (pContext->wasapi.hMMDevapi) { pContext->wasapi.ActivateAudioInterfaceAsync = ma_dlsym(ma_context_get_log(pContext), pContext->wasapi.hMMDevapi, "ActivateAudioInterfaceAsync"); if (pContext->wasapi.ActivateAudioInterfaceAsync == NULL) { ma_dlclose(ma_context_get_log(pContext), pContext->wasapi.hMMDevapi); return MA_NO_BACKEND; /* ActivateAudioInterfaceAsync() could not be loaded. */ } } else { return MA_NO_BACKEND; /* Failed to load mmdevapi.dll which is required for ActivateAudioInterfaceAsync() */ } } #endif /* Optionally use the Avrt API to specify the audio thread's latency sensitivity requirements */ pContext->wasapi.hAvrt = ma_dlopen(ma_context_get_log(pContext), "avrt.dll"); if (pContext->wasapi.hAvrt) { pContext->wasapi.AvSetMmThreadCharacteristicsA = ma_dlsym(ma_context_get_log(pContext), pContext->wasapi.hAvrt, "AvSetMmThreadCharacteristicsA"); pContext->wasapi.AvRevertMmThreadcharacteristics = ma_dlsym(ma_context_get_log(pContext), pContext->wasapi.hAvrt, "AvRevertMmThreadCharacteristics"); /* If either function could not be found, disable use of avrt entirely. */ if (!pContext->wasapi.AvSetMmThreadCharacteristicsA || !pContext->wasapi.AvRevertMmThreadcharacteristics) { pContext->wasapi.AvSetMmThreadCharacteristicsA = NULL; pContext->wasapi.AvRevertMmThreadcharacteristics = NULL; ma_dlclose(ma_context_get_log(pContext), pContext->wasapi.hAvrt); pContext->wasapi.hAvrt = NULL; } } /* Annoyingly, WASAPI does not allow you to release an IAudioClient object from a different thread than the one that retrieved it with GetService(). This can result in a deadlock in two situations: 1) When calling ma_device_uninit() from a different thread to ma_device_init(); and 2) When uninitializing and reinitializing the internal IAudioClient object in response to automatic stream routing. We could define ma_device_uninit() such that it must be called on the same thread as ma_device_init(). We could also just not release the IAudioClient when performing automatic stream routing to avoid the deadlock. Neither of these are acceptable solutions in my view so we're going to have to work around this with a worker thread. This is not ideal, but I can't think of a better way to do this. More information about this can be found here: https://docs.microsoft.com/en-us/windows/win32/api/audioclient/nn-audioclient-iaudiorenderclient Note this section: When releasing an IAudioRenderClient interface instance, the client must call the interface's Release method from the same thread as the call to IAudioClient::GetService that created the object. */ { result = ma_mutex_init(&pContext->wasapi.commandLock); if (result != MA_SUCCESS) { return result; } result = ma_semaphore_init(0, &pContext->wasapi.commandSem); if (result != MA_SUCCESS) { ma_mutex_uninit(&pContext->wasapi.commandLock); return result; } result = ma_thread_create(&pContext->wasapi.commandThread, ma_thread_priority_normal, 0, ma_context_command_thread__wasapi, pContext, &pContext->allocationCallbacks); if (result != MA_SUCCESS) { ma_semaphore_uninit(&pContext->wasapi.commandSem); ma_mutex_uninit(&pContext->wasapi.commandLock); return result; } } pCallbacks->onContextInit = ma_context_init__wasapi; pCallbacks->onContextUninit = ma_context_uninit__wasapi; pCallbacks->onContextEnumerateDevices = ma_context_enumerate_devices__wasapi; pCallbacks->onContextGetDeviceInfo = ma_context_get_device_info__wasapi; pCallbacks->onDeviceInit = ma_device_init__wasapi; pCallbacks->onDeviceUninit = ma_device_uninit__wasapi; pCallbacks->onDeviceStart = ma_device_start__wasapi; pCallbacks->onDeviceStop = ma_device_stop__wasapi; pCallbacks->onDeviceRead = ma_device_read__wasapi; pCallbacks->onDeviceWrite = ma_device_write__wasapi; pCallbacks->onDeviceDataLoop = NULL; pCallbacks->onDeviceDataLoopWakeup = ma_device_data_loop_wakeup__wasapi; return MA_SUCCESS; } #endif /****************************************************************************** DirectSound Backend ******************************************************************************/ #ifdef MA_HAS_DSOUND /*#include */ /*static const GUID MA_GUID_IID_DirectSoundNotify = {0xb0210783, 0x89cd, 0x11d0, {0xaf, 0x08, 0x00, 0xa0, 0xc9, 0x25, 0xcd, 0x16}};*/ /* miniaudio only uses priority or exclusive modes. */ #define MA_DSSCL_NORMAL 1 #define MA_DSSCL_PRIORITY 2 #define MA_DSSCL_EXCLUSIVE 3 #define MA_DSSCL_WRITEPRIMARY 4 #define MA_DSCAPS_PRIMARYMONO 0x00000001 #define MA_DSCAPS_PRIMARYSTEREO 0x00000002 #define MA_DSCAPS_PRIMARY8BIT 0x00000004 #define MA_DSCAPS_PRIMARY16BIT 0x00000008 #define MA_DSCAPS_CONTINUOUSRATE 0x00000010 #define MA_DSCAPS_EMULDRIVER 0x00000020 #define MA_DSCAPS_CERTIFIED 0x00000040 #define MA_DSCAPS_SECONDARYMONO 0x00000100 #define MA_DSCAPS_SECONDARYSTEREO 0x00000200 #define MA_DSCAPS_SECONDARY8BIT 0x00000400 #define MA_DSCAPS_SECONDARY16BIT 0x00000800 #define MA_DSBCAPS_PRIMARYBUFFER 0x00000001 #define MA_DSBCAPS_STATIC 0x00000002 #define MA_DSBCAPS_LOCHARDWARE 0x00000004 #define MA_DSBCAPS_LOCSOFTWARE 0x00000008 #define MA_DSBCAPS_CTRL3D 0x00000010 #define MA_DSBCAPS_CTRLFREQUENCY 0x00000020 #define MA_DSBCAPS_CTRLPAN 0x00000040 #define MA_DSBCAPS_CTRLVOLUME 0x00000080 #define MA_DSBCAPS_CTRLPOSITIONNOTIFY 0x00000100 #define MA_DSBCAPS_CTRLFX 0x00000200 #define MA_DSBCAPS_STICKYFOCUS 0x00004000 #define MA_DSBCAPS_GLOBALFOCUS 0x00008000 #define MA_DSBCAPS_GETCURRENTPOSITION2 0x00010000 #define MA_DSBCAPS_MUTE3DATMAXDISTANCE 0x00020000 #define MA_DSBCAPS_LOCDEFER 0x00040000 #define MA_DSBCAPS_TRUEPLAYPOSITION 0x00080000 #define MA_DSBPLAY_LOOPING 0x00000001 #define MA_DSBPLAY_LOCHARDWARE 0x00000002 #define MA_DSBPLAY_LOCSOFTWARE 0x00000004 #define MA_DSBPLAY_TERMINATEBY_TIME 0x00000008 #define MA_DSBPLAY_TERMINATEBY_DISTANCE 0x00000010 #define MA_DSBPLAY_TERMINATEBY_PRIORITY 0x00000020 #define MA_DSCBSTART_LOOPING 0x00000001 typedef struct { DWORD dwSize; DWORD dwFlags; DWORD dwBufferBytes; DWORD dwReserved; MA_WAVEFORMATEX* lpwfxFormat; GUID guid3DAlgorithm; } MA_DSBUFFERDESC; typedef struct { DWORD dwSize; DWORD dwFlags; DWORD dwBufferBytes; DWORD dwReserved; MA_WAVEFORMATEX* lpwfxFormat; DWORD dwFXCount; void* lpDSCFXDesc; /* <-- miniaudio doesn't use this, so set to void*. */ } MA_DSCBUFFERDESC; typedef struct { DWORD dwSize; DWORD dwFlags; DWORD dwMinSecondarySampleRate; DWORD dwMaxSecondarySampleRate; DWORD dwPrimaryBuffers; DWORD dwMaxHwMixingAllBuffers; DWORD dwMaxHwMixingStaticBuffers; DWORD dwMaxHwMixingStreamingBuffers; DWORD dwFreeHwMixingAllBuffers; DWORD dwFreeHwMixingStaticBuffers; DWORD dwFreeHwMixingStreamingBuffers; DWORD dwMaxHw3DAllBuffers; DWORD dwMaxHw3DStaticBuffers; DWORD dwMaxHw3DStreamingBuffers; DWORD dwFreeHw3DAllBuffers; DWORD dwFreeHw3DStaticBuffers; DWORD dwFreeHw3DStreamingBuffers; DWORD dwTotalHwMemBytes; DWORD dwFreeHwMemBytes; DWORD dwMaxContigFreeHwMemBytes; DWORD dwUnlockTransferRateHwBuffers; DWORD dwPlayCpuOverheadSwBuffers; DWORD dwReserved1; DWORD dwReserved2; } MA_DSCAPS; typedef struct { DWORD dwSize; DWORD dwFlags; DWORD dwBufferBytes; DWORD dwUnlockTransferRate; DWORD dwPlayCpuOverhead; } MA_DSBCAPS; typedef struct { DWORD dwSize; DWORD dwFlags; DWORD dwFormats; DWORD dwChannels; } MA_DSCCAPS; typedef struct { DWORD dwSize; DWORD dwFlags; DWORD dwBufferBytes; DWORD dwReserved; } MA_DSCBCAPS; typedef struct { DWORD dwOffset; HANDLE hEventNotify; } MA_DSBPOSITIONNOTIFY; typedef struct ma_IDirectSound ma_IDirectSound; typedef struct ma_IDirectSoundBuffer ma_IDirectSoundBuffer; typedef struct ma_IDirectSoundCapture ma_IDirectSoundCapture; typedef struct ma_IDirectSoundCaptureBuffer ma_IDirectSoundCaptureBuffer; typedef struct ma_IDirectSoundNotify ma_IDirectSoundNotify; /* COM objects. The way these work is that you have a vtable (a list of function pointers, kind of like how C++ works internally), and then you have a structure with a single member, which is a pointer to the vtable. The vtable is where the methods of the object are defined. Methods need to be in a specific order, and parent classes need to have their methods declared first. */ /* IDirectSound */ typedef struct { /* IUnknown */ HRESULT (STDMETHODCALLTYPE * QueryInterface)(ma_IDirectSound* pThis, const IID* const riid, void** ppObject); ULONG (STDMETHODCALLTYPE * AddRef) (ma_IDirectSound* pThis); ULONG (STDMETHODCALLTYPE * Release) (ma_IDirectSound* pThis); /* IDirectSound */ HRESULT (STDMETHODCALLTYPE * CreateSoundBuffer) (ma_IDirectSound* pThis, const MA_DSBUFFERDESC* pDSBufferDesc, ma_IDirectSoundBuffer** ppDSBuffer, void* pUnkOuter); HRESULT (STDMETHODCALLTYPE * GetCaps) (ma_IDirectSound* pThis, MA_DSCAPS* pDSCaps); HRESULT (STDMETHODCALLTYPE * DuplicateSoundBuffer)(ma_IDirectSound* pThis, ma_IDirectSoundBuffer* pDSBufferOriginal, ma_IDirectSoundBuffer** ppDSBufferDuplicate); HRESULT (STDMETHODCALLTYPE * SetCooperativeLevel) (ma_IDirectSound* pThis, HWND hwnd, DWORD dwLevel); HRESULT (STDMETHODCALLTYPE * Compact) (ma_IDirectSound* pThis); HRESULT (STDMETHODCALLTYPE * GetSpeakerConfig) (ma_IDirectSound* pThis, DWORD* pSpeakerConfig); HRESULT (STDMETHODCALLTYPE * SetSpeakerConfig) (ma_IDirectSound* pThis, DWORD dwSpeakerConfig); HRESULT (STDMETHODCALLTYPE * Initialize) (ma_IDirectSound* pThis, const GUID* pGuidDevice); } ma_IDirectSoundVtbl; struct ma_IDirectSound { ma_IDirectSoundVtbl* lpVtbl; }; static MA_INLINE HRESULT ma_IDirectSound_QueryInterface(ma_IDirectSound* pThis, const IID* const riid, void** ppObject) { return pThis->lpVtbl->QueryInterface(pThis, riid, ppObject); } static MA_INLINE ULONG ma_IDirectSound_AddRef(ma_IDirectSound* pThis) { return pThis->lpVtbl->AddRef(pThis); } static MA_INLINE ULONG ma_IDirectSound_Release(ma_IDirectSound* pThis) { return pThis->lpVtbl->Release(pThis); } static MA_INLINE HRESULT ma_IDirectSound_CreateSoundBuffer(ma_IDirectSound* pThis, const MA_DSBUFFERDESC* pDSBufferDesc, ma_IDirectSoundBuffer** ppDSBuffer, void* pUnkOuter) { return pThis->lpVtbl->CreateSoundBuffer(pThis, pDSBufferDesc, ppDSBuffer, pUnkOuter); } static MA_INLINE HRESULT ma_IDirectSound_GetCaps(ma_IDirectSound* pThis, MA_DSCAPS* pDSCaps) { return pThis->lpVtbl->GetCaps(pThis, pDSCaps); } static MA_INLINE HRESULT ma_IDirectSound_DuplicateSoundBuffer(ma_IDirectSound* pThis, ma_IDirectSoundBuffer* pDSBufferOriginal, ma_IDirectSoundBuffer** ppDSBufferDuplicate) { return pThis->lpVtbl->DuplicateSoundBuffer(pThis, pDSBufferOriginal, ppDSBufferDuplicate); } static MA_INLINE HRESULT ma_IDirectSound_SetCooperativeLevel(ma_IDirectSound* pThis, HWND hwnd, DWORD dwLevel) { return pThis->lpVtbl->SetCooperativeLevel(pThis, hwnd, dwLevel); } static MA_INLINE HRESULT ma_IDirectSound_Compact(ma_IDirectSound* pThis) { return pThis->lpVtbl->Compact(pThis); } static MA_INLINE HRESULT ma_IDirectSound_GetSpeakerConfig(ma_IDirectSound* pThis, DWORD* pSpeakerConfig) { return pThis->lpVtbl->GetSpeakerConfig(pThis, pSpeakerConfig); } static MA_INLINE HRESULT ma_IDirectSound_SetSpeakerConfig(ma_IDirectSound* pThis, DWORD dwSpeakerConfig) { return pThis->lpVtbl->SetSpeakerConfig(pThis, dwSpeakerConfig); } static MA_INLINE HRESULT ma_IDirectSound_Initialize(ma_IDirectSound* pThis, const GUID* pGuidDevice) { return pThis->lpVtbl->Initialize(pThis, pGuidDevice); } /* IDirectSoundBuffer */ typedef struct { /* IUnknown */ HRESULT (STDMETHODCALLTYPE * QueryInterface)(ma_IDirectSoundBuffer* pThis, const IID* const riid, void** ppObject); ULONG (STDMETHODCALLTYPE * AddRef) (ma_IDirectSoundBuffer* pThis); ULONG (STDMETHODCALLTYPE * Release) (ma_IDirectSoundBuffer* pThis); /* IDirectSoundBuffer */ HRESULT (STDMETHODCALLTYPE * GetCaps) (ma_IDirectSoundBuffer* pThis, MA_DSBCAPS* pDSBufferCaps); HRESULT (STDMETHODCALLTYPE * GetCurrentPosition)(ma_IDirectSoundBuffer* pThis, DWORD* pCurrentPlayCursor, DWORD* pCurrentWriteCursor); HRESULT (STDMETHODCALLTYPE * GetFormat) (ma_IDirectSoundBuffer* pThis, MA_WAVEFORMATEX* pFormat, DWORD dwSizeAllocated, DWORD* pSizeWritten); HRESULT (STDMETHODCALLTYPE * GetVolume) (ma_IDirectSoundBuffer* pThis, LONG* pVolume); HRESULT (STDMETHODCALLTYPE * GetPan) (ma_IDirectSoundBuffer* pThis, LONG* pPan); HRESULT (STDMETHODCALLTYPE * GetFrequency) (ma_IDirectSoundBuffer* pThis, DWORD* pFrequency); HRESULT (STDMETHODCALLTYPE * GetStatus) (ma_IDirectSoundBuffer* pThis, DWORD* pStatus); HRESULT (STDMETHODCALLTYPE * Initialize) (ma_IDirectSoundBuffer* pThis, ma_IDirectSound* pDirectSound, const MA_DSBUFFERDESC* pDSBufferDesc); HRESULT (STDMETHODCALLTYPE * Lock) (ma_IDirectSoundBuffer* pThis, DWORD dwOffset, DWORD dwBytes, void** ppAudioPtr1, DWORD* pAudioBytes1, void** ppAudioPtr2, DWORD* pAudioBytes2, DWORD dwFlags); HRESULT (STDMETHODCALLTYPE * Play) (ma_IDirectSoundBuffer* pThis, DWORD dwReserved1, DWORD dwPriority, DWORD dwFlags); HRESULT (STDMETHODCALLTYPE * SetCurrentPosition)(ma_IDirectSoundBuffer* pThis, DWORD dwNewPosition); HRESULT (STDMETHODCALLTYPE * SetFormat) (ma_IDirectSoundBuffer* pThis, const MA_WAVEFORMATEX* pFormat); HRESULT (STDMETHODCALLTYPE * SetVolume) (ma_IDirectSoundBuffer* pThis, LONG volume); HRESULT (STDMETHODCALLTYPE * SetPan) (ma_IDirectSoundBuffer* pThis, LONG pan); HRESULT (STDMETHODCALLTYPE * SetFrequency) (ma_IDirectSoundBuffer* pThis, DWORD dwFrequency); HRESULT (STDMETHODCALLTYPE * Stop) (ma_IDirectSoundBuffer* pThis); HRESULT (STDMETHODCALLTYPE * Unlock) (ma_IDirectSoundBuffer* pThis, void* pAudioPtr1, DWORD dwAudioBytes1, void* pAudioPtr2, DWORD dwAudioBytes2); HRESULT (STDMETHODCALLTYPE * Restore) (ma_IDirectSoundBuffer* pThis); } ma_IDirectSoundBufferVtbl; struct ma_IDirectSoundBuffer { ma_IDirectSoundBufferVtbl* lpVtbl; }; static MA_INLINE HRESULT ma_IDirectSoundBuffer_QueryInterface(ma_IDirectSoundBuffer* pThis, const IID* const riid, void** ppObject) { return pThis->lpVtbl->QueryInterface(pThis, riid, ppObject); } static MA_INLINE ULONG ma_IDirectSoundBuffer_AddRef(ma_IDirectSoundBuffer* pThis) { return pThis->lpVtbl->AddRef(pThis); } static MA_INLINE ULONG ma_IDirectSoundBuffer_Release(ma_IDirectSoundBuffer* pThis) { return pThis->lpVtbl->Release(pThis); } static MA_INLINE HRESULT ma_IDirectSoundBuffer_GetCaps(ma_IDirectSoundBuffer* pThis, MA_DSBCAPS* pDSBufferCaps) { return pThis->lpVtbl->GetCaps(pThis, pDSBufferCaps); } static MA_INLINE HRESULT ma_IDirectSoundBuffer_GetCurrentPosition(ma_IDirectSoundBuffer* pThis, DWORD* pCurrentPlayCursor, DWORD* pCurrentWriteCursor) { return pThis->lpVtbl->GetCurrentPosition(pThis, pCurrentPlayCursor, pCurrentWriteCursor); } static MA_INLINE HRESULT ma_IDirectSoundBuffer_GetFormat(ma_IDirectSoundBuffer* pThis, MA_WAVEFORMATEX* pFormat, DWORD dwSizeAllocated, DWORD* pSizeWritten) { return pThis->lpVtbl->GetFormat(pThis, pFormat, dwSizeAllocated, pSizeWritten); } static MA_INLINE HRESULT ma_IDirectSoundBuffer_GetVolume(ma_IDirectSoundBuffer* pThis, LONG* pVolume) { return pThis->lpVtbl->GetVolume(pThis, pVolume); } static MA_INLINE HRESULT ma_IDirectSoundBuffer_GetPan(ma_IDirectSoundBuffer* pThis, LONG* pPan) { return pThis->lpVtbl->GetPan(pThis, pPan); } static MA_INLINE HRESULT ma_IDirectSoundBuffer_GetFrequency(ma_IDirectSoundBuffer* pThis, DWORD* pFrequency) { return pThis->lpVtbl->GetFrequency(pThis, pFrequency); } static MA_INLINE HRESULT ma_IDirectSoundBuffer_GetStatus(ma_IDirectSoundBuffer* pThis, DWORD* pStatus) { return pThis->lpVtbl->GetStatus(pThis, pStatus); } static MA_INLINE HRESULT ma_IDirectSoundBuffer_Initialize(ma_IDirectSoundBuffer* pThis, ma_IDirectSound* pDirectSound, const MA_DSBUFFERDESC* pDSBufferDesc) { return pThis->lpVtbl->Initialize(pThis, pDirectSound, pDSBufferDesc); } static MA_INLINE HRESULT ma_IDirectSoundBuffer_Lock(ma_IDirectSoundBuffer* pThis, DWORD dwOffset, DWORD dwBytes, void** ppAudioPtr1, DWORD* pAudioBytes1, void** ppAudioPtr2, DWORD* pAudioBytes2, DWORD dwFlags) { return pThis->lpVtbl->Lock(pThis, dwOffset, dwBytes, ppAudioPtr1, pAudioBytes1, ppAudioPtr2, pAudioBytes2, dwFlags); } static MA_INLINE HRESULT ma_IDirectSoundBuffer_Play(ma_IDirectSoundBuffer* pThis, DWORD dwReserved1, DWORD dwPriority, DWORD dwFlags) { return pThis->lpVtbl->Play(pThis, dwReserved1, dwPriority, dwFlags); } static MA_INLINE HRESULT ma_IDirectSoundBuffer_SetCurrentPosition(ma_IDirectSoundBuffer* pThis, DWORD dwNewPosition) { return pThis->lpVtbl->SetCurrentPosition(pThis, dwNewPosition); } static MA_INLINE HRESULT ma_IDirectSoundBuffer_SetFormat(ma_IDirectSoundBuffer* pThis, const MA_WAVEFORMATEX* pFormat) { return pThis->lpVtbl->SetFormat(pThis, pFormat); } static MA_INLINE HRESULT ma_IDirectSoundBuffer_SetVolume(ma_IDirectSoundBuffer* pThis, LONG volume) { return pThis->lpVtbl->SetVolume(pThis, volume); } static MA_INLINE HRESULT ma_IDirectSoundBuffer_SetPan(ma_IDirectSoundBuffer* pThis, LONG pan) { return pThis->lpVtbl->SetPan(pThis, pan); } static MA_INLINE HRESULT ma_IDirectSoundBuffer_SetFrequency(ma_IDirectSoundBuffer* pThis, DWORD dwFrequency) { return pThis->lpVtbl->SetFrequency(pThis, dwFrequency); } static MA_INLINE HRESULT ma_IDirectSoundBuffer_Stop(ma_IDirectSoundBuffer* pThis) { return pThis->lpVtbl->Stop(pThis); } static MA_INLINE HRESULT ma_IDirectSoundBuffer_Unlock(ma_IDirectSoundBuffer* pThis, void* pAudioPtr1, DWORD dwAudioBytes1, void* pAudioPtr2, DWORD dwAudioBytes2) { return pThis->lpVtbl->Unlock(pThis, pAudioPtr1, dwAudioBytes1, pAudioPtr2, dwAudioBytes2); } static MA_INLINE HRESULT ma_IDirectSoundBuffer_Restore(ma_IDirectSoundBuffer* pThis) { return pThis->lpVtbl->Restore(pThis); } /* IDirectSoundCapture */ typedef struct { /* IUnknown */ HRESULT (STDMETHODCALLTYPE * QueryInterface)(ma_IDirectSoundCapture* pThis, const IID* const riid, void** ppObject); ULONG (STDMETHODCALLTYPE * AddRef) (ma_IDirectSoundCapture* pThis); ULONG (STDMETHODCALLTYPE * Release) (ma_IDirectSoundCapture* pThis); /* IDirectSoundCapture */ HRESULT (STDMETHODCALLTYPE * CreateCaptureBuffer)(ma_IDirectSoundCapture* pThis, const MA_DSCBUFFERDESC* pDSCBufferDesc, ma_IDirectSoundCaptureBuffer** ppDSCBuffer, void* pUnkOuter); HRESULT (STDMETHODCALLTYPE * GetCaps) (ma_IDirectSoundCapture* pThis, MA_DSCCAPS* pDSCCaps); HRESULT (STDMETHODCALLTYPE * Initialize) (ma_IDirectSoundCapture* pThis, const GUID* pGuidDevice); } ma_IDirectSoundCaptureVtbl; struct ma_IDirectSoundCapture { ma_IDirectSoundCaptureVtbl* lpVtbl; }; static MA_INLINE HRESULT ma_IDirectSoundCapture_QueryInterface (ma_IDirectSoundCapture* pThis, const IID* const riid, void** ppObject) { return pThis->lpVtbl->QueryInterface(pThis, riid, ppObject); } static MA_INLINE ULONG ma_IDirectSoundCapture_AddRef (ma_IDirectSoundCapture* pThis) { return pThis->lpVtbl->AddRef(pThis); } static MA_INLINE ULONG ma_IDirectSoundCapture_Release (ma_IDirectSoundCapture* pThis) { return pThis->lpVtbl->Release(pThis); } static MA_INLINE HRESULT ma_IDirectSoundCapture_CreateCaptureBuffer(ma_IDirectSoundCapture* pThis, const MA_DSCBUFFERDESC* pDSCBufferDesc, ma_IDirectSoundCaptureBuffer** ppDSCBuffer, void* pUnkOuter) { return pThis->lpVtbl->CreateCaptureBuffer(pThis, pDSCBufferDesc, ppDSCBuffer, pUnkOuter); } static MA_INLINE HRESULT ma_IDirectSoundCapture_GetCaps (ma_IDirectSoundCapture* pThis, MA_DSCCAPS* pDSCCaps) { return pThis->lpVtbl->GetCaps(pThis, pDSCCaps); } static MA_INLINE HRESULT ma_IDirectSoundCapture_Initialize (ma_IDirectSoundCapture* pThis, const GUID* pGuidDevice) { return pThis->lpVtbl->Initialize(pThis, pGuidDevice); } /* IDirectSoundCaptureBuffer */ typedef struct { /* IUnknown */ HRESULT (STDMETHODCALLTYPE * QueryInterface)(ma_IDirectSoundCaptureBuffer* pThis, const IID* const riid, void** ppObject); ULONG (STDMETHODCALLTYPE * AddRef) (ma_IDirectSoundCaptureBuffer* pThis); ULONG (STDMETHODCALLTYPE * Release) (ma_IDirectSoundCaptureBuffer* pThis); /* IDirectSoundCaptureBuffer */ HRESULT (STDMETHODCALLTYPE * GetCaps) (ma_IDirectSoundCaptureBuffer* pThis, MA_DSCBCAPS* pDSCBCaps); HRESULT (STDMETHODCALLTYPE * GetCurrentPosition)(ma_IDirectSoundCaptureBuffer* pThis, DWORD* pCapturePosition, DWORD* pReadPosition); HRESULT (STDMETHODCALLTYPE * GetFormat) (ma_IDirectSoundCaptureBuffer* pThis, MA_WAVEFORMATEX* pFormat, DWORD dwSizeAllocated, DWORD* pSizeWritten); HRESULT (STDMETHODCALLTYPE * GetStatus) (ma_IDirectSoundCaptureBuffer* pThis, DWORD* pStatus); HRESULT (STDMETHODCALLTYPE * Initialize) (ma_IDirectSoundCaptureBuffer* pThis, ma_IDirectSoundCapture* pDirectSoundCapture, const MA_DSCBUFFERDESC* pDSCBufferDesc); HRESULT (STDMETHODCALLTYPE * Lock) (ma_IDirectSoundCaptureBuffer* pThis, DWORD dwOffset, DWORD dwBytes, void** ppAudioPtr1, DWORD* pAudioBytes1, void** ppAudioPtr2, DWORD* pAudioBytes2, DWORD dwFlags); HRESULT (STDMETHODCALLTYPE * Start) (ma_IDirectSoundCaptureBuffer* pThis, DWORD dwFlags); HRESULT (STDMETHODCALLTYPE * Stop) (ma_IDirectSoundCaptureBuffer* pThis); HRESULT (STDMETHODCALLTYPE * Unlock) (ma_IDirectSoundCaptureBuffer* pThis, void* pAudioPtr1, DWORD dwAudioBytes1, void* pAudioPtr2, DWORD dwAudioBytes2); } ma_IDirectSoundCaptureBufferVtbl; struct ma_IDirectSoundCaptureBuffer { ma_IDirectSoundCaptureBufferVtbl* lpVtbl; }; static MA_INLINE HRESULT ma_IDirectSoundCaptureBuffer_QueryInterface(ma_IDirectSoundCaptureBuffer* pThis, const IID* const riid, void** ppObject) { return pThis->lpVtbl->QueryInterface(pThis, riid, ppObject); } static MA_INLINE ULONG ma_IDirectSoundCaptureBuffer_AddRef(ma_IDirectSoundCaptureBuffer* pThis) { return pThis->lpVtbl->AddRef(pThis); } static MA_INLINE ULONG ma_IDirectSoundCaptureBuffer_Release(ma_IDirectSoundCaptureBuffer* pThis) { return pThis->lpVtbl->Release(pThis); } static MA_INLINE HRESULT ma_IDirectSoundCaptureBuffer_GetCaps(ma_IDirectSoundCaptureBuffer* pThis, MA_DSCBCAPS* pDSCBCaps) { return pThis->lpVtbl->GetCaps(pThis, pDSCBCaps); } static MA_INLINE HRESULT ma_IDirectSoundCaptureBuffer_GetCurrentPosition(ma_IDirectSoundCaptureBuffer* pThis, DWORD* pCapturePosition, DWORD* pReadPosition) { return pThis->lpVtbl->GetCurrentPosition(pThis, pCapturePosition, pReadPosition); } static MA_INLINE HRESULT ma_IDirectSoundCaptureBuffer_GetFormat(ma_IDirectSoundCaptureBuffer* pThis, MA_WAVEFORMATEX* pFormat, DWORD dwSizeAllocated, DWORD* pSizeWritten) { return pThis->lpVtbl->GetFormat(pThis, pFormat, dwSizeAllocated, pSizeWritten); } static MA_INLINE HRESULT ma_IDirectSoundCaptureBuffer_GetStatus(ma_IDirectSoundCaptureBuffer* pThis, DWORD* pStatus) { return pThis->lpVtbl->GetStatus(pThis, pStatus); } static MA_INLINE HRESULT ma_IDirectSoundCaptureBuffer_Initialize(ma_IDirectSoundCaptureBuffer* pThis, ma_IDirectSoundCapture* pDirectSoundCapture, const MA_DSCBUFFERDESC* pDSCBufferDesc) { return pThis->lpVtbl->Initialize(pThis, pDirectSoundCapture, pDSCBufferDesc); } static MA_INLINE HRESULT ma_IDirectSoundCaptureBuffer_Lock(ma_IDirectSoundCaptureBuffer* pThis, DWORD dwOffset, DWORD dwBytes, void** ppAudioPtr1, DWORD* pAudioBytes1, void** ppAudioPtr2, DWORD* pAudioBytes2, DWORD dwFlags) { return pThis->lpVtbl->Lock(pThis, dwOffset, dwBytes, ppAudioPtr1, pAudioBytes1, ppAudioPtr2, pAudioBytes2, dwFlags); } static MA_INLINE HRESULT ma_IDirectSoundCaptureBuffer_Start(ma_IDirectSoundCaptureBuffer* pThis, DWORD dwFlags) { return pThis->lpVtbl->Start(pThis, dwFlags); } static MA_INLINE HRESULT ma_IDirectSoundCaptureBuffer_Stop(ma_IDirectSoundCaptureBuffer* pThis) { return pThis->lpVtbl->Stop(pThis); } static MA_INLINE HRESULT ma_IDirectSoundCaptureBuffer_Unlock(ma_IDirectSoundCaptureBuffer* pThis, void* pAudioPtr1, DWORD dwAudioBytes1, void* pAudioPtr2, DWORD dwAudioBytes2) { return pThis->lpVtbl->Unlock(pThis, pAudioPtr1, dwAudioBytes1, pAudioPtr2, dwAudioBytes2); } /* IDirectSoundNotify */ typedef struct { /* IUnknown */ HRESULT (STDMETHODCALLTYPE * QueryInterface)(ma_IDirectSoundNotify* pThis, const IID* const riid, void** ppObject); ULONG (STDMETHODCALLTYPE * AddRef) (ma_IDirectSoundNotify* pThis); ULONG (STDMETHODCALLTYPE * Release) (ma_IDirectSoundNotify* pThis); /* IDirectSoundNotify */ HRESULT (STDMETHODCALLTYPE * SetNotificationPositions)(ma_IDirectSoundNotify* pThis, DWORD dwPositionNotifies, const MA_DSBPOSITIONNOTIFY* pPositionNotifies); } ma_IDirectSoundNotifyVtbl; struct ma_IDirectSoundNotify { ma_IDirectSoundNotifyVtbl* lpVtbl; }; static MA_INLINE HRESULT ma_IDirectSoundNotify_QueryInterface(ma_IDirectSoundNotify* pThis, const IID* const riid, void** ppObject) { return pThis->lpVtbl->QueryInterface(pThis, riid, ppObject); } static MA_INLINE ULONG ma_IDirectSoundNotify_AddRef(ma_IDirectSoundNotify* pThis) { return pThis->lpVtbl->AddRef(pThis); } static MA_INLINE ULONG ma_IDirectSoundNotify_Release(ma_IDirectSoundNotify* pThis) { return pThis->lpVtbl->Release(pThis); } static MA_INLINE HRESULT ma_IDirectSoundNotify_SetNotificationPositions(ma_IDirectSoundNotify* pThis, DWORD dwPositionNotifies, const MA_DSBPOSITIONNOTIFY* pPositionNotifies) { return pThis->lpVtbl->SetNotificationPositions(pThis, dwPositionNotifies, pPositionNotifies); } typedef BOOL (CALLBACK * ma_DSEnumCallbackAProc) (GUID* pDeviceGUID, const char* pDeviceDescription, const char* pModule, void* pContext); typedef HRESULT (WINAPI * ma_DirectSoundCreateProc) (const GUID* pcGuidDevice, ma_IDirectSound** ppDS8, ma_IUnknown* pUnkOuter); typedef HRESULT (WINAPI * ma_DirectSoundEnumerateAProc) (ma_DSEnumCallbackAProc pDSEnumCallback, void* pContext); typedef HRESULT (WINAPI * ma_DirectSoundCaptureCreateProc) (const GUID* pcGuidDevice, ma_IDirectSoundCapture** ppDSC8, ma_IUnknown* pUnkOuter); typedef HRESULT (WINAPI * ma_DirectSoundCaptureEnumerateAProc)(ma_DSEnumCallbackAProc pDSEnumCallback, void* pContext); static ma_uint32 ma_get_best_sample_rate_within_range(ma_uint32 sampleRateMin, ma_uint32 sampleRateMax) { /* Normalize the range in case we were given something stupid. */ if (sampleRateMin < (ma_uint32)ma_standard_sample_rate_min) { sampleRateMin = (ma_uint32)ma_standard_sample_rate_min; } if (sampleRateMax > (ma_uint32)ma_standard_sample_rate_max) { sampleRateMax = (ma_uint32)ma_standard_sample_rate_max; } if (sampleRateMin > sampleRateMax) { sampleRateMin = sampleRateMax; } if (sampleRateMin == sampleRateMax) { return sampleRateMax; } else { size_t iStandardRate; for (iStandardRate = 0; iStandardRate < ma_countof(g_maStandardSampleRatePriorities); ++iStandardRate) { ma_uint32 standardRate = g_maStandardSampleRatePriorities[iStandardRate]; if (standardRate >= sampleRateMin && standardRate <= sampleRateMax) { return standardRate; } } } /* Should never get here. */ MA_ASSERT(MA_FALSE); return 0; } /* Retrieves the channel count and channel map for the given speaker configuration. If the speaker configuration is unknown, the channel count and channel map will be left unmodified. */ static void ma_get_channels_from_speaker_config__dsound(DWORD speakerConfig, WORD* pChannelsOut, DWORD* pChannelMapOut) { WORD channels; DWORD channelMap; channels = 0; if (pChannelsOut != NULL) { channels = *pChannelsOut; } channelMap = 0; if (pChannelMapOut != NULL) { channelMap = *pChannelMapOut; } /* The speaker configuration is a combination of speaker config and speaker geometry. The lower 8 bits is what we care about. The upper 16 bits is for the geometry. */ switch ((BYTE)(speakerConfig)) { case 1 /*DSSPEAKER_HEADPHONE*/: channels = 2; channelMap = SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT; break; case 2 /*DSSPEAKER_MONO*/: channels = 1; channelMap = SPEAKER_FRONT_CENTER; break; case 3 /*DSSPEAKER_QUAD*/: channels = 4; channelMap = SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_BACK_LEFT | SPEAKER_BACK_RIGHT; break; case 4 /*DSSPEAKER_STEREO*/: channels = 2; channelMap = SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT; break; case 5 /*DSSPEAKER_SURROUND*/: channels = 4; channelMap = SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_FRONT_CENTER | SPEAKER_BACK_CENTER; break; case 6 /*DSSPEAKER_5POINT1_BACK*/ /*DSSPEAKER_5POINT1*/: channels = 6; channelMap = SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_FRONT_CENTER | SPEAKER_LOW_FREQUENCY | SPEAKER_BACK_LEFT | SPEAKER_BACK_RIGHT; break; case 7 /*DSSPEAKER_7POINT1_WIDE*/ /*DSSPEAKER_7POINT1*/: channels = 8; channelMap = SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_FRONT_CENTER | SPEAKER_LOW_FREQUENCY | SPEAKER_BACK_LEFT | SPEAKER_BACK_RIGHT | SPEAKER_FRONT_LEFT_OF_CENTER | SPEAKER_FRONT_RIGHT_OF_CENTER; break; case 8 /*DSSPEAKER_7POINT1_SURROUND*/: channels = 8; channelMap = SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_FRONT_CENTER | SPEAKER_LOW_FREQUENCY | SPEAKER_BACK_LEFT | SPEAKER_BACK_RIGHT | SPEAKER_SIDE_LEFT | SPEAKER_SIDE_RIGHT; break; case 9 /*DSSPEAKER_5POINT1_SURROUND*/: channels = 6; channelMap = SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_FRONT_CENTER | SPEAKER_LOW_FREQUENCY | SPEAKER_SIDE_LEFT | SPEAKER_SIDE_RIGHT; break; default: break; } if (pChannelsOut != NULL) { *pChannelsOut = channels; } if (pChannelMapOut != NULL) { *pChannelMapOut = channelMap; } } static ma_result ma_context_create_IDirectSound__dsound(ma_context* pContext, ma_share_mode shareMode, const ma_device_id* pDeviceID, ma_IDirectSound** ppDirectSound) { ma_IDirectSound* pDirectSound; HWND hWnd; HRESULT hr; MA_ASSERT(pContext != NULL); MA_ASSERT(ppDirectSound != NULL); *ppDirectSound = NULL; pDirectSound = NULL; if (FAILED(((ma_DirectSoundCreateProc)pContext->dsound.DirectSoundCreate)((pDeviceID == NULL) ? NULL : (const GUID*)pDeviceID->dsound, &pDirectSound, NULL))) { ma_log_postf(ma_context_get_log(pContext), MA_LOG_LEVEL_ERROR, "[DirectSound] DirectSoundCreate() failed for playback device."); return MA_FAILED_TO_OPEN_BACKEND_DEVICE; } /* The cooperative level must be set before doing anything else. */ hWnd = ((MA_PFN_GetForegroundWindow)pContext->win32.GetForegroundWindow)(); if (hWnd == 0) { hWnd = ((MA_PFN_GetDesktopWindow)pContext->win32.GetDesktopWindow)(); } hr = ma_IDirectSound_SetCooperativeLevel(pDirectSound, hWnd, (shareMode == ma_share_mode_exclusive) ? MA_DSSCL_EXCLUSIVE : MA_DSSCL_PRIORITY); if (FAILED(hr)) { ma_log_postf(ma_context_get_log(pContext), MA_LOG_LEVEL_ERROR, "[DirectSound] IDirectSound_SetCooperateiveLevel() failed for playback device."); return ma_result_from_HRESULT(hr); } *ppDirectSound = pDirectSound; return MA_SUCCESS; } static ma_result ma_context_create_IDirectSoundCapture__dsound(ma_context* pContext, ma_share_mode shareMode, const ma_device_id* pDeviceID, ma_IDirectSoundCapture** ppDirectSoundCapture) { ma_IDirectSoundCapture* pDirectSoundCapture; HRESULT hr; MA_ASSERT(pContext != NULL); MA_ASSERT(ppDirectSoundCapture != NULL); /* DirectSound does not support exclusive mode for capture. */ if (shareMode == ma_share_mode_exclusive) { return MA_SHARE_MODE_NOT_SUPPORTED; } *ppDirectSoundCapture = NULL; pDirectSoundCapture = NULL; hr = ((ma_DirectSoundCaptureCreateProc)pContext->dsound.DirectSoundCaptureCreate)((pDeviceID == NULL) ? NULL : (const GUID*)pDeviceID->dsound, &pDirectSoundCapture, NULL); if (FAILED(hr)) { ma_log_postf(ma_context_get_log(pContext), MA_LOG_LEVEL_ERROR, "[DirectSound] DirectSoundCaptureCreate() failed for capture device."); return ma_result_from_HRESULT(hr); } *ppDirectSoundCapture = pDirectSoundCapture; return MA_SUCCESS; } static ma_result ma_context_get_format_info_for_IDirectSoundCapture__dsound(ma_context* pContext, ma_IDirectSoundCapture* pDirectSoundCapture, WORD* pChannels, WORD* pBitsPerSample, DWORD* pSampleRate) { HRESULT hr; MA_DSCCAPS caps; WORD bitsPerSample; DWORD sampleRate; MA_ASSERT(pContext != NULL); MA_ASSERT(pDirectSoundCapture != NULL); if (pChannels) { *pChannels = 0; } if (pBitsPerSample) { *pBitsPerSample = 0; } if (pSampleRate) { *pSampleRate = 0; } MA_ZERO_OBJECT(&caps); caps.dwSize = sizeof(caps); hr = ma_IDirectSoundCapture_GetCaps(pDirectSoundCapture, &caps); if (FAILED(hr)) { ma_log_postf(ma_context_get_log(pContext), MA_LOG_LEVEL_ERROR, "[DirectSound] IDirectSoundCapture_GetCaps() failed for capture device."); return ma_result_from_HRESULT(hr); } if (pChannels) { *pChannels = (WORD)caps.dwChannels; } /* The device can support multiple formats. We just go through the different formats in order of priority and pick the first one. This the same type of system as the WinMM backend. */ bitsPerSample = 16; sampleRate = 48000; if (caps.dwChannels == 1) { if ((caps.dwFormats & WAVE_FORMAT_48M16) != 0) { sampleRate = 48000; } else if ((caps.dwFormats & WAVE_FORMAT_44M16) != 0) { sampleRate = 44100; } else if ((caps.dwFormats & WAVE_FORMAT_2M16) != 0) { sampleRate = 22050; } else if ((caps.dwFormats & WAVE_FORMAT_1M16) != 0) { sampleRate = 11025; } else if ((caps.dwFormats & WAVE_FORMAT_96M16) != 0) { sampleRate = 96000; } else { bitsPerSample = 8; if ((caps.dwFormats & WAVE_FORMAT_48M08) != 0) { sampleRate = 48000; } else if ((caps.dwFormats & WAVE_FORMAT_44M08) != 0) { sampleRate = 44100; } else if ((caps.dwFormats & WAVE_FORMAT_2M08) != 0) { sampleRate = 22050; } else if ((caps.dwFormats & WAVE_FORMAT_1M08) != 0) { sampleRate = 11025; } else if ((caps.dwFormats & WAVE_FORMAT_96M08) != 0) { sampleRate = 96000; } else { bitsPerSample = 16; /* Didn't find it. Just fall back to 16-bit. */ } } } else if (caps.dwChannels == 2) { if ((caps.dwFormats & WAVE_FORMAT_48S16) != 0) { sampleRate = 48000; } else if ((caps.dwFormats & WAVE_FORMAT_44S16) != 0) { sampleRate = 44100; } else if ((caps.dwFormats & WAVE_FORMAT_2S16) != 0) { sampleRate = 22050; } else if ((caps.dwFormats & WAVE_FORMAT_1S16) != 0) { sampleRate = 11025; } else if ((caps.dwFormats & WAVE_FORMAT_96S16) != 0) { sampleRate = 96000; } else { bitsPerSample = 8; if ((caps.dwFormats & WAVE_FORMAT_48S08) != 0) { sampleRate = 48000; } else if ((caps.dwFormats & WAVE_FORMAT_44S08) != 0) { sampleRate = 44100; } else if ((caps.dwFormats & WAVE_FORMAT_2S08) != 0) { sampleRate = 22050; } else if ((caps.dwFormats & WAVE_FORMAT_1S08) != 0) { sampleRate = 11025; } else if ((caps.dwFormats & WAVE_FORMAT_96S08) != 0) { sampleRate = 96000; } else { bitsPerSample = 16; /* Didn't find it. Just fall back to 16-bit. */ } } } if (pBitsPerSample) { *pBitsPerSample = bitsPerSample; } if (pSampleRate) { *pSampleRate = sampleRate; } return MA_SUCCESS; } typedef struct { ma_context* pContext; ma_device_type deviceType; ma_enum_devices_callback_proc callback; void* pUserData; ma_bool32 terminated; } ma_context_enumerate_devices_callback_data__dsound; static BOOL CALLBACK ma_context_enumerate_devices_callback__dsound(GUID* lpGuid, const char* lpcstrDescription, const char* lpcstrModule, void* lpContext) { ma_context_enumerate_devices_callback_data__dsound* pData = (ma_context_enumerate_devices_callback_data__dsound*)lpContext; ma_device_info deviceInfo; (void)lpcstrModule; MA_ZERO_OBJECT(&deviceInfo); /* ID. */ if (lpGuid != NULL) { MA_COPY_MEMORY(deviceInfo.id.dsound, lpGuid, 16); } else { MA_ZERO_MEMORY(deviceInfo.id.dsound, 16); deviceInfo.isDefault = MA_TRUE; } /* Name / Description */ ma_strncpy_s(deviceInfo.name, sizeof(deviceInfo.name), lpcstrDescription, (size_t)-1); /* Call the callback function, but make sure we stop enumerating if the callee requested so. */ MA_ASSERT(pData != NULL); pData->terminated = (pData->callback(pData->pContext, pData->deviceType, &deviceInfo, pData->pUserData) == MA_FALSE); if (pData->terminated) { return FALSE; /* Stop enumeration. */ } else { return TRUE; /* Continue enumeration. */ } } static ma_result ma_context_enumerate_devices__dsound(ma_context* pContext, ma_enum_devices_callback_proc callback, void* pUserData) { ma_context_enumerate_devices_callback_data__dsound data; MA_ASSERT(pContext != NULL); MA_ASSERT(callback != NULL); data.pContext = pContext; data.callback = callback; data.pUserData = pUserData; data.terminated = MA_FALSE; /* Playback. */ if (!data.terminated) { data.deviceType = ma_device_type_playback; ((ma_DirectSoundEnumerateAProc)pContext->dsound.DirectSoundEnumerateA)(ma_context_enumerate_devices_callback__dsound, &data); } /* Capture. */ if (!data.terminated) { data.deviceType = ma_device_type_capture; ((ma_DirectSoundCaptureEnumerateAProc)pContext->dsound.DirectSoundCaptureEnumerateA)(ma_context_enumerate_devices_callback__dsound, &data); } return MA_SUCCESS; } typedef struct { const ma_device_id* pDeviceID; ma_device_info* pDeviceInfo; ma_bool32 found; } ma_context_get_device_info_callback_data__dsound; static BOOL CALLBACK ma_context_get_device_info_callback__dsound(GUID* lpGuid, const char* lpcstrDescription, const char* lpcstrModule, void* lpContext) { ma_context_get_device_info_callback_data__dsound* pData = (ma_context_get_device_info_callback_data__dsound*)lpContext; MA_ASSERT(pData != NULL); if ((pData->pDeviceID == NULL || ma_is_guid_null(pData->pDeviceID->dsound)) && (lpGuid == NULL || ma_is_guid_null(lpGuid))) { /* Default device. */ ma_strncpy_s(pData->pDeviceInfo->name, sizeof(pData->pDeviceInfo->name), lpcstrDescription, (size_t)-1); pData->pDeviceInfo->isDefault = MA_TRUE; pData->found = MA_TRUE; return FALSE; /* Stop enumeration. */ } else { /* Not the default device. */ if (lpGuid != NULL && pData->pDeviceID != NULL) { if (memcmp(pData->pDeviceID->dsound, lpGuid, sizeof(pData->pDeviceID->dsound)) == 0) { ma_strncpy_s(pData->pDeviceInfo->name, sizeof(pData->pDeviceInfo->name), lpcstrDescription, (size_t)-1); pData->found = MA_TRUE; return FALSE; /* Stop enumeration. */ } } } (void)lpcstrModule; return TRUE; } static ma_result ma_context_get_device_info__dsound(ma_context* pContext, ma_device_type deviceType, const ma_device_id* pDeviceID, ma_device_info* pDeviceInfo) { ma_result result; HRESULT hr; if (pDeviceID != NULL) { ma_context_get_device_info_callback_data__dsound data; /* ID. */ MA_COPY_MEMORY(pDeviceInfo->id.dsound, pDeviceID->dsound, 16); /* Name / Description. This is retrieved by enumerating over each device until we find that one that matches the input ID. */ data.pDeviceID = pDeviceID; data.pDeviceInfo = pDeviceInfo; data.found = MA_FALSE; if (deviceType == ma_device_type_playback) { ((ma_DirectSoundEnumerateAProc)pContext->dsound.DirectSoundEnumerateA)(ma_context_get_device_info_callback__dsound, &data); } else { ((ma_DirectSoundCaptureEnumerateAProc)pContext->dsound.DirectSoundCaptureEnumerateA)(ma_context_get_device_info_callback__dsound, &data); } if (!data.found) { return MA_NO_DEVICE; } } else { /* I don't think there's a way to get the name of the default device with DirectSound. In this case we just need to use defaults. */ /* ID */ MA_ZERO_MEMORY(pDeviceInfo->id.dsound, 16); /* Name / Description */ if (deviceType == ma_device_type_playback) { ma_strncpy_s(pDeviceInfo->name, sizeof(pDeviceInfo->name), MA_DEFAULT_PLAYBACK_DEVICE_NAME, (size_t)-1); } else { ma_strncpy_s(pDeviceInfo->name, sizeof(pDeviceInfo->name), MA_DEFAULT_CAPTURE_DEVICE_NAME, (size_t)-1); } pDeviceInfo->isDefault = MA_TRUE; } /* Retrieving detailed information is slightly different depending on the device type. */ if (deviceType == ma_device_type_playback) { /* Playback. */ ma_IDirectSound* pDirectSound; MA_DSCAPS caps; WORD channels; result = ma_context_create_IDirectSound__dsound(pContext, ma_share_mode_shared, pDeviceID, &pDirectSound); if (result != MA_SUCCESS) { return result; } MA_ZERO_OBJECT(&caps); caps.dwSize = sizeof(caps); hr = ma_IDirectSound_GetCaps(pDirectSound, &caps); if (FAILED(hr)) { ma_log_postf(ma_context_get_log(pContext), MA_LOG_LEVEL_ERROR, "[DirectSound] IDirectSound_GetCaps() failed for playback device."); return ma_result_from_HRESULT(hr); } /* Channels. Only a single channel count is reported for DirectSound. */ if ((caps.dwFlags & MA_DSCAPS_PRIMARYSTEREO) != 0) { /* It supports at least stereo, but could support more. */ DWORD speakerConfig; channels = 2; /* Look at the speaker configuration to get a better idea on the channel count. */ hr = ma_IDirectSound_GetSpeakerConfig(pDirectSound, &speakerConfig); if (SUCCEEDED(hr)) { ma_get_channels_from_speaker_config__dsound(speakerConfig, &channels, NULL); } } else { /* It does not support stereo, which means we are stuck with mono. */ channels = 1; } /* In DirectSound, our native formats are centered around sample rates. All formats are supported, and we're only reporting a single channel count. However, DirectSound can report a range of supported sample rates. We're only going to include standard rates known by miniaudio in order to keep the size of this within reason. */ if ((caps.dwFlags & MA_DSCAPS_CONTINUOUSRATE) != 0) { /* Multiple sample rates are supported. We'll report in order of our preferred sample rates. */ size_t iStandardSampleRate; for (iStandardSampleRate = 0; iStandardSampleRate < ma_countof(g_maStandardSampleRatePriorities); iStandardSampleRate += 1) { ma_uint32 sampleRate = g_maStandardSampleRatePriorities[iStandardSampleRate]; if (sampleRate >= caps.dwMinSecondarySampleRate && sampleRate <= caps.dwMaxSecondarySampleRate) { pDeviceInfo->nativeDataFormats[pDeviceInfo->nativeDataFormatCount].format = ma_format_unknown; pDeviceInfo->nativeDataFormats[pDeviceInfo->nativeDataFormatCount].channels = channels; pDeviceInfo->nativeDataFormats[pDeviceInfo->nativeDataFormatCount].sampleRate = sampleRate; pDeviceInfo->nativeDataFormats[pDeviceInfo->nativeDataFormatCount].flags = 0; pDeviceInfo->nativeDataFormatCount += 1; } } } else { /* Only a single sample rate is supported. */ pDeviceInfo->nativeDataFormats[pDeviceInfo->nativeDataFormatCount].format = ma_format_unknown; pDeviceInfo->nativeDataFormats[pDeviceInfo->nativeDataFormatCount].channels = channels; pDeviceInfo->nativeDataFormats[pDeviceInfo->nativeDataFormatCount].sampleRate = caps.dwMaxSecondarySampleRate; pDeviceInfo->nativeDataFormats[pDeviceInfo->nativeDataFormatCount].flags = 0; pDeviceInfo->nativeDataFormatCount += 1; } ma_IDirectSound_Release(pDirectSound); } else { /* Capture. This is a little different to playback due to the say the supported formats are reported. Technically capture devices can support a number of different formats, but for simplicity and consistency with ma_device_init() I'm just reporting the best format. */ ma_IDirectSoundCapture* pDirectSoundCapture; WORD channels; WORD bitsPerSample; DWORD sampleRate; result = ma_context_create_IDirectSoundCapture__dsound(pContext, ma_share_mode_shared, pDeviceID, &pDirectSoundCapture); if (result != MA_SUCCESS) { return result; } result = ma_context_get_format_info_for_IDirectSoundCapture__dsound(pContext, pDirectSoundCapture, &channels, &bitsPerSample, &sampleRate); if (result != MA_SUCCESS) { ma_IDirectSoundCapture_Release(pDirectSoundCapture); return result; } ma_IDirectSoundCapture_Release(pDirectSoundCapture); /* The format is always an integer format and is based on the bits per sample. */ if (bitsPerSample == 8) { pDeviceInfo->nativeDataFormats[0].format = ma_format_u8; } else if (bitsPerSample == 16) { pDeviceInfo->nativeDataFormats[0].format = ma_format_s16; } else if (bitsPerSample == 24) { pDeviceInfo->nativeDataFormats[0].format = ma_format_s24; } else if (bitsPerSample == 32) { pDeviceInfo->nativeDataFormats[0].format = ma_format_s32; } else { return MA_FORMAT_NOT_SUPPORTED; } pDeviceInfo->nativeDataFormats[0].channels = channels; pDeviceInfo->nativeDataFormats[0].sampleRate = sampleRate; pDeviceInfo->nativeDataFormats[0].flags = 0; pDeviceInfo->nativeDataFormatCount = 1; } return MA_SUCCESS; } static ma_result ma_device_uninit__dsound(ma_device* pDevice) { MA_ASSERT(pDevice != NULL); if (pDevice->dsound.pCaptureBuffer != NULL) { ma_IDirectSoundCaptureBuffer_Release((ma_IDirectSoundCaptureBuffer*)pDevice->dsound.pCaptureBuffer); } if (pDevice->dsound.pCapture != NULL) { ma_IDirectSoundCapture_Release((ma_IDirectSoundCapture*)pDevice->dsound.pCapture); } if (pDevice->dsound.pPlaybackBuffer != NULL) { ma_IDirectSoundBuffer_Release((ma_IDirectSoundBuffer*)pDevice->dsound.pPlaybackBuffer); } if (pDevice->dsound.pPlaybackPrimaryBuffer != NULL) { ma_IDirectSoundBuffer_Release((ma_IDirectSoundBuffer*)pDevice->dsound.pPlaybackPrimaryBuffer); } if (pDevice->dsound.pPlayback != NULL) { ma_IDirectSound_Release((ma_IDirectSound*)pDevice->dsound.pPlayback); } return MA_SUCCESS; } static ma_result ma_config_to_WAVEFORMATEXTENSIBLE(ma_format format, ma_uint32 channels, ma_uint32 sampleRate, const ma_channel* pChannelMap, MA_WAVEFORMATEXTENSIBLE* pWF) { GUID subformat; if (format == ma_format_unknown) { format = MA_DEFAULT_FORMAT; } if (channels == 0) { channels = MA_DEFAULT_CHANNELS; } if (sampleRate == 0) { sampleRate = MA_DEFAULT_SAMPLE_RATE; } switch (format) { case ma_format_u8: case ma_format_s16: case ma_format_s24: /*case ma_format_s24_32:*/ case ma_format_s32: { subformat = MA_GUID_KSDATAFORMAT_SUBTYPE_PCM; } break; case ma_format_f32: { subformat = MA_GUID_KSDATAFORMAT_SUBTYPE_IEEE_FLOAT; } break; default: return MA_FORMAT_NOT_SUPPORTED; } MA_ZERO_OBJECT(pWF); pWF->cbSize = sizeof(*pWF); pWF->wFormatTag = WAVE_FORMAT_EXTENSIBLE; pWF->nChannels = (WORD)channels; pWF->nSamplesPerSec = (DWORD)sampleRate; pWF->wBitsPerSample = (WORD)(ma_get_bytes_per_sample(format)*8); pWF->nBlockAlign = (WORD)(pWF->nChannels * pWF->wBitsPerSample / 8); pWF->nAvgBytesPerSec = pWF->nBlockAlign * pWF->nSamplesPerSec; pWF->Samples.wValidBitsPerSample = pWF->wBitsPerSample; pWF->dwChannelMask = ma_channel_map_to_channel_mask__win32(pChannelMap, channels); pWF->SubFormat = subformat; return MA_SUCCESS; } static ma_uint32 ma_calculate_period_size_in_frames_from_descriptor__dsound(const ma_device_descriptor* pDescriptor, ma_uint32 nativeSampleRate, ma_performance_profile performanceProfile) { /* DirectSound has a minimum period size of 20ms. In practice, this doesn't seem to be enough for reliable glitch-free processing so going to use 30ms instead. */ ma_uint32 minPeriodSizeInFrames = ma_calculate_buffer_size_in_frames_from_milliseconds(30, nativeSampleRate); ma_uint32 periodSizeInFrames; periodSizeInFrames = ma_calculate_buffer_size_in_frames_from_descriptor(pDescriptor, nativeSampleRate, performanceProfile); if (periodSizeInFrames < minPeriodSizeInFrames) { periodSizeInFrames = minPeriodSizeInFrames; } return periodSizeInFrames; } static ma_result ma_device_init__dsound(ma_device* pDevice, const ma_device_config* pConfig, ma_device_descriptor* pDescriptorPlayback, ma_device_descriptor* pDescriptorCapture) { ma_result result; HRESULT hr; MA_ASSERT(pDevice != NULL); MA_ZERO_OBJECT(&pDevice->dsound); if (pConfig->deviceType == ma_device_type_loopback) { return MA_DEVICE_TYPE_NOT_SUPPORTED; } /* Unfortunately DirectSound uses different APIs and data structures for playback and catpure devices. We need to initialize the capture device first because we'll want to match it's buffer size and period count on the playback side if we're using full-duplex mode. */ if (pConfig->deviceType == ma_device_type_capture || pConfig->deviceType == ma_device_type_duplex) { MA_WAVEFORMATEXTENSIBLE wf; MA_DSCBUFFERDESC descDS; ma_uint32 periodSizeInFrames; ma_uint32 periodCount; char rawdata[1024]; /* <-- Ugly hack to avoid a malloc() due to a crappy DirectSound API. */ MA_WAVEFORMATEXTENSIBLE* pActualFormat; result = ma_config_to_WAVEFORMATEXTENSIBLE(pDescriptorCapture->format, pDescriptorCapture->channels, pDescriptorCapture->sampleRate, pDescriptorCapture->channelMap, &wf); if (result != MA_SUCCESS) { return result; } result = ma_context_create_IDirectSoundCapture__dsound(pDevice->pContext, pDescriptorCapture->shareMode, pDescriptorCapture->pDeviceID, (ma_IDirectSoundCapture**)&pDevice->dsound.pCapture); if (result != MA_SUCCESS) { ma_device_uninit__dsound(pDevice); return result; } result = ma_context_get_format_info_for_IDirectSoundCapture__dsound(pDevice->pContext, (ma_IDirectSoundCapture*)pDevice->dsound.pCapture, &wf.nChannels, &wf.wBitsPerSample, &wf.nSamplesPerSec); if (result != MA_SUCCESS) { ma_device_uninit__dsound(pDevice); return result; } wf.nBlockAlign = (WORD)(wf.nChannels * wf.wBitsPerSample / 8); wf.nAvgBytesPerSec = wf.nBlockAlign * wf.nSamplesPerSec; wf.Samples.wValidBitsPerSample = wf.wBitsPerSample; wf.SubFormat = MA_GUID_KSDATAFORMAT_SUBTYPE_PCM; /* The size of the buffer must be a clean multiple of the period count. */ periodSizeInFrames = ma_calculate_period_size_in_frames_from_descriptor__dsound(pDescriptorCapture, wf.nSamplesPerSec, pConfig->performanceProfile); periodCount = (pDescriptorCapture->periodCount > 0) ? pDescriptorCapture->periodCount : MA_DEFAULT_PERIODS; MA_ZERO_OBJECT(&descDS); descDS.dwSize = sizeof(descDS); descDS.dwFlags = 0; descDS.dwBufferBytes = periodSizeInFrames * periodCount * wf.nBlockAlign; descDS.lpwfxFormat = (MA_WAVEFORMATEX*)&wf; hr = ma_IDirectSoundCapture_CreateCaptureBuffer((ma_IDirectSoundCapture*)pDevice->dsound.pCapture, &descDS, (ma_IDirectSoundCaptureBuffer**)&pDevice->dsound.pCaptureBuffer, NULL); if (FAILED(hr)) { ma_device_uninit__dsound(pDevice); ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[DirectSound] IDirectSoundCapture_CreateCaptureBuffer() failed for capture device."); return ma_result_from_HRESULT(hr); } /* Get the _actual_ properties of the buffer. */ pActualFormat = (MA_WAVEFORMATEXTENSIBLE*)rawdata; hr = ma_IDirectSoundCaptureBuffer_GetFormat((ma_IDirectSoundCaptureBuffer*)pDevice->dsound.pCaptureBuffer, (MA_WAVEFORMATEX*)pActualFormat, sizeof(rawdata), NULL); if (FAILED(hr)) { ma_device_uninit__dsound(pDevice); ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[DirectSound] Failed to retrieve the actual format of the capture device's buffer."); return ma_result_from_HRESULT(hr); } /* We can now start setting the output data formats. */ pDescriptorCapture->format = ma_format_from_WAVEFORMATEX((MA_WAVEFORMATEX*)pActualFormat); pDescriptorCapture->channels = pActualFormat->nChannels; pDescriptorCapture->sampleRate = pActualFormat->nSamplesPerSec; /* Get the native channel map based on the channel mask. */ if (pActualFormat->wFormatTag == WAVE_FORMAT_EXTENSIBLE) { ma_channel_mask_to_channel_map__win32(pActualFormat->dwChannelMask, pDescriptorCapture->channels, pDescriptorCapture->channelMap); } else { ma_channel_mask_to_channel_map__win32(wf.dwChannelMask, pDescriptorCapture->channels, pDescriptorCapture->channelMap); } /* After getting the actual format the size of the buffer in frames may have actually changed. However, we want this to be as close to what the user has asked for as possible, so let's go ahead and release the old capture buffer and create a new one in this case. */ if (periodSizeInFrames != (descDS.dwBufferBytes / ma_get_bytes_per_frame(pDescriptorCapture->format, pDescriptorCapture->channels) / periodCount)) { descDS.dwBufferBytes = periodSizeInFrames * ma_get_bytes_per_frame(pDescriptorCapture->format, pDescriptorCapture->channels) * periodCount; ma_IDirectSoundCaptureBuffer_Release((ma_IDirectSoundCaptureBuffer*)pDevice->dsound.pCaptureBuffer); hr = ma_IDirectSoundCapture_CreateCaptureBuffer((ma_IDirectSoundCapture*)pDevice->dsound.pCapture, &descDS, (ma_IDirectSoundCaptureBuffer**)&pDevice->dsound.pCaptureBuffer, NULL); if (FAILED(hr)) { ma_device_uninit__dsound(pDevice); ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[DirectSound] Second attempt at IDirectSoundCapture_CreateCaptureBuffer() failed for capture device."); return ma_result_from_HRESULT(hr); } } /* DirectSound should give us a buffer exactly the size we asked for. */ pDescriptorCapture->periodSizeInFrames = periodSizeInFrames; pDescriptorCapture->periodCount = periodCount; } if (pConfig->deviceType == ma_device_type_playback || pConfig->deviceType == ma_device_type_duplex) { MA_WAVEFORMATEXTENSIBLE wf; MA_DSBUFFERDESC descDSPrimary; MA_DSCAPS caps; char rawdata[1024]; /* <-- Ugly hack to avoid a malloc() due to a crappy DirectSound API. */ MA_WAVEFORMATEXTENSIBLE* pActualFormat; ma_uint32 periodSizeInFrames; ma_uint32 periodCount; MA_DSBUFFERDESC descDS; WORD nativeChannelCount; DWORD nativeChannelMask = 0; result = ma_config_to_WAVEFORMATEXTENSIBLE(pDescriptorPlayback->format, pDescriptorPlayback->channels, pDescriptorPlayback->sampleRate, pDescriptorPlayback->channelMap, &wf); if (result != MA_SUCCESS) { return result; } result = ma_context_create_IDirectSound__dsound(pDevice->pContext, pDescriptorPlayback->shareMode, pDescriptorPlayback->pDeviceID, (ma_IDirectSound**)&pDevice->dsound.pPlayback); if (result != MA_SUCCESS) { ma_device_uninit__dsound(pDevice); return result; } MA_ZERO_OBJECT(&descDSPrimary); descDSPrimary.dwSize = sizeof(MA_DSBUFFERDESC); descDSPrimary.dwFlags = MA_DSBCAPS_PRIMARYBUFFER | MA_DSBCAPS_CTRLVOLUME; hr = ma_IDirectSound_CreateSoundBuffer((ma_IDirectSound*)pDevice->dsound.pPlayback, &descDSPrimary, (ma_IDirectSoundBuffer**)&pDevice->dsound.pPlaybackPrimaryBuffer, NULL); if (FAILED(hr)) { ma_device_uninit__dsound(pDevice); ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[DirectSound] IDirectSound_CreateSoundBuffer() failed for playback device's primary buffer."); return ma_result_from_HRESULT(hr); } /* We may want to make some adjustments to the format if we are using defaults. */ MA_ZERO_OBJECT(&caps); caps.dwSize = sizeof(caps); hr = ma_IDirectSound_GetCaps((ma_IDirectSound*)pDevice->dsound.pPlayback, &caps); if (FAILED(hr)) { ma_device_uninit__dsound(pDevice); ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[DirectSound] IDirectSound_GetCaps() failed for playback device."); return ma_result_from_HRESULT(hr); } if ((caps.dwFlags & MA_DSCAPS_PRIMARYSTEREO) != 0) { DWORD speakerConfig; /* It supports at least stereo, but could support more. */ nativeChannelCount = 2; /* Look at the speaker configuration to get a better idea on the channel count. */ if (SUCCEEDED(ma_IDirectSound_GetSpeakerConfig((ma_IDirectSound*)pDevice->dsound.pPlayback, &speakerConfig))) { ma_get_channels_from_speaker_config__dsound(speakerConfig, &nativeChannelCount, &nativeChannelMask); } } else { /* It does not support stereo, which means we are stuck with mono. */ nativeChannelCount = 1; nativeChannelMask = 0x00000001; } if (pDescriptorPlayback->channels == 0) { wf.nChannels = nativeChannelCount; wf.dwChannelMask = nativeChannelMask; } if (pDescriptorPlayback->sampleRate == 0) { /* We base the sample rate on the values returned by GetCaps(). */ if ((caps.dwFlags & MA_DSCAPS_CONTINUOUSRATE) != 0) { wf.nSamplesPerSec = ma_get_best_sample_rate_within_range(caps.dwMinSecondarySampleRate, caps.dwMaxSecondarySampleRate); } else { wf.nSamplesPerSec = caps.dwMaxSecondarySampleRate; } } wf.nBlockAlign = (WORD)(wf.nChannels * wf.wBitsPerSample / 8); wf.nAvgBytesPerSec = wf.nBlockAlign * wf.nSamplesPerSec; /* From MSDN: The method succeeds even if the hardware does not support the requested format; DirectSound sets the buffer to the closest supported format. To determine whether this has happened, an application can call the GetFormat method for the primary buffer and compare the result with the format that was requested with the SetFormat method. */ hr = ma_IDirectSoundBuffer_SetFormat((ma_IDirectSoundBuffer*)pDevice->dsound.pPlaybackPrimaryBuffer, (MA_WAVEFORMATEX*)&wf); if (FAILED(hr)) { /* If setting of the format failed we'll try again with some fallback settings. On Windows 98 I have observed that IEEE_FLOAT does not work. We'll therefore enforce PCM. I also had issues where a sample rate of 48000 did not work correctly. Not sure if it was a driver issue or not, but will use 44100 for the sample rate. */ wf.cbSize = 18; /* NOTE: Don't use sizeof(MA_WAVEFORMATEX) here because it's got an extra 2 bytes due to padding. */ wf.wFormatTag = WAVE_FORMAT_PCM; wf.wBitsPerSample = 16; wf.nChannels = nativeChannelCount; wf.nSamplesPerSec = 44100; wf.nBlockAlign = wf.nChannels * (wf.wBitsPerSample / 8); wf.nAvgBytesPerSec = wf.nSamplesPerSec * wf.nBlockAlign; hr = ma_IDirectSoundBuffer_SetFormat((ma_IDirectSoundBuffer*)pDevice->dsound.pPlaybackPrimaryBuffer, (MA_WAVEFORMATEX*)&wf); if (FAILED(hr)) { ma_device_uninit__dsound(pDevice); ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[DirectSound] Failed to set format of playback device's primary buffer."); return ma_result_from_HRESULT(hr); } } /* Get the _actual_ properties of the buffer. */ pActualFormat = (MA_WAVEFORMATEXTENSIBLE*)rawdata; hr = ma_IDirectSoundBuffer_GetFormat((ma_IDirectSoundBuffer*)pDevice->dsound.pPlaybackPrimaryBuffer, (MA_WAVEFORMATEX*)pActualFormat, sizeof(rawdata), NULL); if (FAILED(hr)) { ma_device_uninit__dsound(pDevice); ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[DirectSound] Failed to retrieve the actual format of the playback device's primary buffer."); return ma_result_from_HRESULT(hr); } /* We now have enough information to start setting some output properties. */ pDescriptorPlayback->format = ma_format_from_WAVEFORMATEX((MA_WAVEFORMATEX*)pActualFormat); pDescriptorPlayback->channels = pActualFormat->nChannels; pDescriptorPlayback->sampleRate = pActualFormat->nSamplesPerSec; /* Get the internal channel map based on the channel mask. */ if (pActualFormat->wFormatTag == WAVE_FORMAT_EXTENSIBLE) { ma_channel_mask_to_channel_map__win32(pActualFormat->dwChannelMask, pDescriptorPlayback->channels, pDescriptorPlayback->channelMap); } else { ma_channel_mask_to_channel_map__win32(wf.dwChannelMask, pDescriptorPlayback->channels, pDescriptorPlayback->channelMap); } /* The size of the buffer must be a clean multiple of the period count. */ periodSizeInFrames = ma_calculate_period_size_in_frames_from_descriptor__dsound(pDescriptorPlayback, pDescriptorPlayback->sampleRate, pConfig->performanceProfile); periodCount = (pDescriptorPlayback->periodCount > 0) ? pDescriptorPlayback->periodCount : MA_DEFAULT_PERIODS; /* Meaning of dwFlags (from MSDN): DSBCAPS_CTRLPOSITIONNOTIFY The buffer has position notification capability. DSBCAPS_GLOBALFOCUS With this flag set, an application using DirectSound can continue to play its buffers if the user switches focus to another application, even if the new application uses DirectSound. DSBCAPS_GETCURRENTPOSITION2 In the first version of DirectSound, the play cursor was significantly ahead of the actual playing sound on emulated sound cards; it was directly behind the write cursor. Now, if the DSBCAPS_GETCURRENTPOSITION2 flag is specified, the application can get a more accurate play cursor. */ MA_ZERO_OBJECT(&descDS); descDS.dwSize = sizeof(descDS); descDS.dwFlags = MA_DSBCAPS_CTRLPOSITIONNOTIFY | MA_DSBCAPS_GLOBALFOCUS | MA_DSBCAPS_GETCURRENTPOSITION2; descDS.dwBufferBytes = periodSizeInFrames * periodCount * ma_get_bytes_per_frame(pDescriptorPlayback->format, pDescriptorPlayback->channels); descDS.lpwfxFormat = (MA_WAVEFORMATEX*)pActualFormat; hr = ma_IDirectSound_CreateSoundBuffer((ma_IDirectSound*)pDevice->dsound.pPlayback, &descDS, (ma_IDirectSoundBuffer**)&pDevice->dsound.pPlaybackBuffer, NULL); if (FAILED(hr)) { ma_device_uninit__dsound(pDevice); ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[DirectSound] IDirectSound_CreateSoundBuffer() failed for playback device's secondary buffer."); return ma_result_from_HRESULT(hr); } /* DirectSound should give us a buffer exactly the size we asked for. */ pDescriptorPlayback->periodSizeInFrames = periodSizeInFrames; pDescriptorPlayback->periodCount = periodCount; } return MA_SUCCESS; } static ma_result ma_device_data_loop__dsound(ma_device* pDevice) { ma_result result = MA_SUCCESS; ma_uint32 bpfDeviceCapture = ma_get_bytes_per_frame(pDevice->capture.internalFormat, pDevice->capture.internalChannels); ma_uint32 bpfDevicePlayback = ma_get_bytes_per_frame(pDevice->playback.internalFormat, pDevice->playback.internalChannels); HRESULT hr; DWORD lockOffsetInBytesCapture; DWORD lockSizeInBytesCapture; DWORD mappedSizeInBytesCapture; DWORD mappedDeviceFramesProcessedCapture; void* pMappedDeviceBufferCapture; DWORD lockOffsetInBytesPlayback; DWORD lockSizeInBytesPlayback; DWORD mappedSizeInBytesPlayback; void* pMappedDeviceBufferPlayback; DWORD prevReadCursorInBytesCapture = 0; DWORD prevPlayCursorInBytesPlayback = 0; ma_bool32 physicalPlayCursorLoopFlagPlayback = 0; DWORD virtualWriteCursorInBytesPlayback = 0; ma_bool32 virtualWriteCursorLoopFlagPlayback = 0; ma_bool32 isPlaybackDeviceStarted = MA_FALSE; ma_uint32 framesWrittenToPlaybackDevice = 0; /* For knowing whether or not the playback device needs to be started. */ ma_uint32 waitTimeInMilliseconds = 1; MA_ASSERT(pDevice != NULL); /* The first thing to do is start the capture device. The playback device is only started after the first period is written. */ if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) { hr = ma_IDirectSoundCaptureBuffer_Start((ma_IDirectSoundCaptureBuffer*)pDevice->dsound.pCaptureBuffer, MA_DSCBSTART_LOOPING); if (FAILED(hr)) { ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[DirectSound] IDirectSoundCaptureBuffer_Start() failed."); return ma_result_from_HRESULT(hr); } } while (ma_device_get_state(pDevice) == ma_device_state_started) { switch (pDevice->type) { case ma_device_type_duplex: { DWORD physicalCaptureCursorInBytes; DWORD physicalReadCursorInBytes; hr = ma_IDirectSoundCaptureBuffer_GetCurrentPosition((ma_IDirectSoundCaptureBuffer*)pDevice->dsound.pCaptureBuffer, &physicalCaptureCursorInBytes, &physicalReadCursorInBytes); if (FAILED(hr)) { return ma_result_from_HRESULT(hr); } /* If nothing is available we just sleep for a bit and return from this iteration. */ if (physicalReadCursorInBytes == prevReadCursorInBytesCapture) { ma_sleep(waitTimeInMilliseconds); continue; /* Nothing is available in the capture buffer. */ } /* The current position has moved. We need to map all of the captured samples and write them to the playback device, making sure we don't return until every frame has been copied over. */ if (prevReadCursorInBytesCapture < physicalReadCursorInBytes) { /* The capture position has not looped. This is the simple case. */ lockOffsetInBytesCapture = prevReadCursorInBytesCapture; lockSizeInBytesCapture = (physicalReadCursorInBytes - prevReadCursorInBytesCapture); } else { /* The capture position has looped. This is the more complex case. Map to the end of the buffer. If this does not return anything, do it again from the start. */ if (prevReadCursorInBytesCapture < pDevice->capture.internalPeriodSizeInFrames*pDevice->capture.internalPeriods*bpfDeviceCapture) { /* Lock up to the end of the buffer. */ lockOffsetInBytesCapture = prevReadCursorInBytesCapture; lockSizeInBytesCapture = (pDevice->capture.internalPeriodSizeInFrames*pDevice->capture.internalPeriods*bpfDeviceCapture) - prevReadCursorInBytesCapture; } else { /* Lock starting from the start of the buffer. */ lockOffsetInBytesCapture = 0; lockSizeInBytesCapture = physicalReadCursorInBytes; } } if (lockSizeInBytesCapture == 0) { ma_sleep(waitTimeInMilliseconds); continue; /* Nothing is available in the capture buffer. */ } hr = ma_IDirectSoundCaptureBuffer_Lock((ma_IDirectSoundCaptureBuffer*)pDevice->dsound.pCaptureBuffer, lockOffsetInBytesCapture, lockSizeInBytesCapture, &pMappedDeviceBufferCapture, &mappedSizeInBytesCapture, NULL, NULL, 0); if (FAILED(hr)) { ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[DirectSound] Failed to map buffer from capture device in preparation for writing to the device."); return ma_result_from_HRESULT(hr); } /* At this point we have some input data that we need to output. We do not return until every mapped frame of the input data is written to the playback device. */ mappedDeviceFramesProcessedCapture = 0; for (;;) { /* Keep writing to the playback device. */ ma_uint8 inputFramesInClientFormat[MA_DATA_CONVERTER_STACK_BUFFER_SIZE]; ma_uint32 inputFramesInClientFormatCap = sizeof(inputFramesInClientFormat) / ma_get_bytes_per_frame(pDevice->capture.format, pDevice->capture.channels); ma_uint8 outputFramesInClientFormat[MA_DATA_CONVERTER_STACK_BUFFER_SIZE]; ma_uint32 outputFramesInClientFormatCap = sizeof(outputFramesInClientFormat) / ma_get_bytes_per_frame(pDevice->playback.format, pDevice->playback.channels); ma_uint32 outputFramesInClientFormatCount; ma_uint32 outputFramesInClientFormatConsumed = 0; ma_uint64 clientCapturedFramesToProcess = ma_min(inputFramesInClientFormatCap, outputFramesInClientFormatCap); ma_uint64 deviceCapturedFramesToProcess = (mappedSizeInBytesCapture / bpfDeviceCapture) - mappedDeviceFramesProcessedCapture; void* pRunningMappedDeviceBufferCapture = ma_offset_ptr(pMappedDeviceBufferCapture, mappedDeviceFramesProcessedCapture * bpfDeviceCapture); result = ma_data_converter_process_pcm_frames(&pDevice->capture.converter, pRunningMappedDeviceBufferCapture, &deviceCapturedFramesToProcess, inputFramesInClientFormat, &clientCapturedFramesToProcess); if (result != MA_SUCCESS) { break; } outputFramesInClientFormatCount = (ma_uint32)clientCapturedFramesToProcess; mappedDeviceFramesProcessedCapture += (ma_uint32)deviceCapturedFramesToProcess; ma_device__handle_data_callback(pDevice, outputFramesInClientFormat, inputFramesInClientFormat, (ma_uint32)clientCapturedFramesToProcess); /* At this point we have input and output data in client format. All we need to do now is convert it to the output device format. This may take a few passes. */ for (;;) { ma_uint32 framesWrittenThisIteration; DWORD physicalPlayCursorInBytes; DWORD physicalWriteCursorInBytes; DWORD availableBytesPlayback; DWORD silentPaddingInBytes = 0; /* <-- Must be initialized to 0. */ /* We need the physical play and write cursors. */ if (FAILED(ma_IDirectSoundBuffer_GetCurrentPosition((ma_IDirectSoundBuffer*)pDevice->dsound.pPlaybackBuffer, &physicalPlayCursorInBytes, &physicalWriteCursorInBytes))) { break; } if (physicalPlayCursorInBytes < prevPlayCursorInBytesPlayback) { physicalPlayCursorLoopFlagPlayback = !physicalPlayCursorLoopFlagPlayback; } prevPlayCursorInBytesPlayback = physicalPlayCursorInBytes; /* If there's any bytes available for writing we can do that now. The space between the virtual cursor position and play cursor. */ if (physicalPlayCursorLoopFlagPlayback == virtualWriteCursorLoopFlagPlayback) { /* Same loop iteration. The available bytes wraps all the way around from the virtual write cursor to the physical play cursor. */ if (physicalPlayCursorInBytes <= virtualWriteCursorInBytesPlayback) { availableBytesPlayback = (pDevice->playback.internalPeriodSizeInFrames*pDevice->playback.internalPeriods*bpfDevicePlayback) - virtualWriteCursorInBytesPlayback; availableBytesPlayback += physicalPlayCursorInBytes; /* Wrap around. */ } else { /* This is an error. */ ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_WARNING, "[DirectSound] (Duplex/Playback): Play cursor has moved in front of the write cursor (same loop iteration). physicalPlayCursorInBytes=%ld, virtualWriteCursorInBytes=%ld.\n", physicalPlayCursorInBytes, virtualWriteCursorInBytesPlayback); availableBytesPlayback = 0; } } else { /* Different loop iterations. The available bytes only goes from the virtual write cursor to the physical play cursor. */ if (physicalPlayCursorInBytes >= virtualWriteCursorInBytesPlayback) { availableBytesPlayback = physicalPlayCursorInBytes - virtualWriteCursorInBytesPlayback; } else { /* This is an error. */ ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_WARNING, "[DirectSound] (Duplex/Playback): Write cursor has moved behind the play cursor (different loop iterations). physicalPlayCursorInBytes=%ld, virtualWriteCursorInBytes=%ld.\n", physicalPlayCursorInBytes, virtualWriteCursorInBytesPlayback); availableBytesPlayback = 0; } } /* If there's no room available for writing we need to wait for more. */ if (availableBytesPlayback == 0) { /* If we haven't started the device yet, this will never get beyond 0. In this case we need to get the device started. */ if (!isPlaybackDeviceStarted) { hr = ma_IDirectSoundBuffer_Play((ma_IDirectSoundBuffer*)pDevice->dsound.pPlaybackBuffer, 0, 0, MA_DSBPLAY_LOOPING); if (FAILED(hr)) { ma_IDirectSoundCaptureBuffer_Stop((ma_IDirectSoundCaptureBuffer*)pDevice->dsound.pCaptureBuffer); ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[DirectSound] IDirectSoundBuffer_Play() failed."); return ma_result_from_HRESULT(hr); } isPlaybackDeviceStarted = MA_TRUE; } else { ma_sleep(waitTimeInMilliseconds); continue; } } /* Getting here means there room available somewhere. We limit this to either the end of the buffer or the physical play cursor, whichever is closest. */ lockOffsetInBytesPlayback = virtualWriteCursorInBytesPlayback; if (physicalPlayCursorLoopFlagPlayback == virtualWriteCursorLoopFlagPlayback) { /* Same loop iteration. Go up to the end of the buffer. */ lockSizeInBytesPlayback = (pDevice->playback.internalPeriodSizeInFrames*pDevice->playback.internalPeriods*bpfDevicePlayback) - virtualWriteCursorInBytesPlayback; } else { /* Different loop iterations. Go up to the physical play cursor. */ lockSizeInBytesPlayback = physicalPlayCursorInBytes - virtualWriteCursorInBytesPlayback; } hr = ma_IDirectSoundBuffer_Lock((ma_IDirectSoundBuffer*)pDevice->dsound.pPlaybackBuffer, lockOffsetInBytesPlayback, lockSizeInBytesPlayback, &pMappedDeviceBufferPlayback, &mappedSizeInBytesPlayback, NULL, NULL, 0); if (FAILED(hr)) { ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[DirectSound] Failed to map buffer from playback device in preparation for writing to the device."); result = ma_result_from_HRESULT(hr); break; } /* Experiment: If the playback buffer is being starved, pad it with some silence to get it back in sync. This will cause a glitch, but it may prevent endless glitching due to it constantly running out of data. */ if (isPlaybackDeviceStarted) { DWORD bytesQueuedForPlayback = (pDevice->playback.internalPeriodSizeInFrames*pDevice->playback.internalPeriods*bpfDevicePlayback) - availableBytesPlayback; if (bytesQueuedForPlayback < (pDevice->playback.internalPeriodSizeInFrames*bpfDevicePlayback)) { silentPaddingInBytes = (pDevice->playback.internalPeriodSizeInFrames*2*bpfDevicePlayback) - bytesQueuedForPlayback; if (silentPaddingInBytes > lockSizeInBytesPlayback) { silentPaddingInBytes = lockSizeInBytesPlayback; } ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_WARNING, "[DirectSound] (Duplex/Playback) Playback buffer starved. availableBytesPlayback=%ld, silentPaddingInBytes=%ld\n", availableBytesPlayback, silentPaddingInBytes); } } /* At this point we have a buffer for output. */ if (silentPaddingInBytes > 0) { MA_ZERO_MEMORY(pMappedDeviceBufferPlayback, silentPaddingInBytes); framesWrittenThisIteration = silentPaddingInBytes/bpfDevicePlayback; } else { ma_uint64 convertedFrameCountIn = (outputFramesInClientFormatCount - outputFramesInClientFormatConsumed); ma_uint64 convertedFrameCountOut = mappedSizeInBytesPlayback/bpfDevicePlayback; void* pConvertedFramesIn = ma_offset_ptr(outputFramesInClientFormat, outputFramesInClientFormatConsumed * bpfDevicePlayback); void* pConvertedFramesOut = pMappedDeviceBufferPlayback; result = ma_data_converter_process_pcm_frames(&pDevice->playback.converter, pConvertedFramesIn, &convertedFrameCountIn, pConvertedFramesOut, &convertedFrameCountOut); if (result != MA_SUCCESS) { break; } outputFramesInClientFormatConsumed += (ma_uint32)convertedFrameCountOut; framesWrittenThisIteration = (ma_uint32)convertedFrameCountOut; } hr = ma_IDirectSoundBuffer_Unlock((ma_IDirectSoundBuffer*)pDevice->dsound.pPlaybackBuffer, pMappedDeviceBufferPlayback, framesWrittenThisIteration*bpfDevicePlayback, NULL, 0); if (FAILED(hr)) { ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[DirectSound] Failed to unlock internal buffer from playback device after writing to the device."); result = ma_result_from_HRESULT(hr); break; } virtualWriteCursorInBytesPlayback += framesWrittenThisIteration*bpfDevicePlayback; if ((virtualWriteCursorInBytesPlayback/bpfDevicePlayback) == pDevice->playback.internalPeriodSizeInFrames*pDevice->playback.internalPeriods) { virtualWriteCursorInBytesPlayback = 0; virtualWriteCursorLoopFlagPlayback = !virtualWriteCursorLoopFlagPlayback; } /* We may need to start the device. We want two full periods to be written before starting the playback device. Having an extra period adds a bit of a buffer to prevent the playback buffer from getting starved. */ framesWrittenToPlaybackDevice += framesWrittenThisIteration; if (!isPlaybackDeviceStarted && framesWrittenToPlaybackDevice >= (pDevice->playback.internalPeriodSizeInFrames*2)) { hr = ma_IDirectSoundBuffer_Play((ma_IDirectSoundBuffer*)pDevice->dsound.pPlaybackBuffer, 0, 0, MA_DSBPLAY_LOOPING); if (FAILED(hr)) { ma_IDirectSoundCaptureBuffer_Stop((ma_IDirectSoundCaptureBuffer*)pDevice->dsound.pCaptureBuffer); ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[DirectSound] IDirectSoundBuffer_Play() failed."); return ma_result_from_HRESULT(hr); } isPlaybackDeviceStarted = MA_TRUE; } if (framesWrittenThisIteration < mappedSizeInBytesPlayback/bpfDevicePlayback) { break; /* We're finished with the output data.*/ } } if (clientCapturedFramesToProcess == 0) { break; /* We just consumed every input sample. */ } } /* At this point we're done with the mapped portion of the capture buffer. */ hr = ma_IDirectSoundCaptureBuffer_Unlock((ma_IDirectSoundCaptureBuffer*)pDevice->dsound.pCaptureBuffer, pMappedDeviceBufferCapture, mappedSizeInBytesCapture, NULL, 0); if (FAILED(hr)) { ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[DirectSound] Failed to unlock internal buffer from capture device after reading from the device."); return ma_result_from_HRESULT(hr); } prevReadCursorInBytesCapture = (lockOffsetInBytesCapture + mappedSizeInBytesCapture); } break; case ma_device_type_capture: { DWORD physicalCaptureCursorInBytes; DWORD physicalReadCursorInBytes; hr = ma_IDirectSoundCaptureBuffer_GetCurrentPosition((ma_IDirectSoundCaptureBuffer*)pDevice->dsound.pCaptureBuffer, &physicalCaptureCursorInBytes, &physicalReadCursorInBytes); if (FAILED(hr)) { return MA_ERROR; } /* If the previous capture position is the same as the current position we need to wait a bit longer. */ if (prevReadCursorInBytesCapture == physicalReadCursorInBytes) { ma_sleep(waitTimeInMilliseconds); continue; } /* Getting here means we have capture data available. */ if (prevReadCursorInBytesCapture < physicalReadCursorInBytes) { /* The capture position has not looped. This is the simple case. */ lockOffsetInBytesCapture = prevReadCursorInBytesCapture; lockSizeInBytesCapture = (physicalReadCursorInBytes - prevReadCursorInBytesCapture); } else { /* The capture position has looped. This is the more complex case. Map to the end of the buffer. If this does not return anything, do it again from the start. */ if (prevReadCursorInBytesCapture < pDevice->capture.internalPeriodSizeInFrames*pDevice->capture.internalPeriods*bpfDeviceCapture) { /* Lock up to the end of the buffer. */ lockOffsetInBytesCapture = prevReadCursorInBytesCapture; lockSizeInBytesCapture = (pDevice->capture.internalPeriodSizeInFrames*pDevice->capture.internalPeriods*bpfDeviceCapture) - prevReadCursorInBytesCapture; } else { /* Lock starting from the start of the buffer. */ lockOffsetInBytesCapture = 0; lockSizeInBytesCapture = physicalReadCursorInBytes; } } if (lockSizeInBytesCapture < pDevice->capture.internalPeriodSizeInFrames) { ma_sleep(waitTimeInMilliseconds); continue; /* Nothing is available in the capture buffer. */ } hr = ma_IDirectSoundCaptureBuffer_Lock((ma_IDirectSoundCaptureBuffer*)pDevice->dsound.pCaptureBuffer, lockOffsetInBytesCapture, lockSizeInBytesCapture, &pMappedDeviceBufferCapture, &mappedSizeInBytesCapture, NULL, NULL, 0); if (FAILED(hr)) { ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[DirectSound] Failed to map buffer from capture device in preparation for writing to the device."); result = ma_result_from_HRESULT(hr); } if (lockSizeInBytesCapture != mappedSizeInBytesCapture) { ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_DEBUG, "[DirectSound] (Capture) lockSizeInBytesCapture=%ld != mappedSizeInBytesCapture=%ld\n", lockSizeInBytesCapture, mappedSizeInBytesCapture); } ma_device__send_frames_to_client(pDevice, mappedSizeInBytesCapture/bpfDeviceCapture, pMappedDeviceBufferCapture); hr = ma_IDirectSoundCaptureBuffer_Unlock((ma_IDirectSoundCaptureBuffer*)pDevice->dsound.pCaptureBuffer, pMappedDeviceBufferCapture, mappedSizeInBytesCapture, NULL, 0); if (FAILED(hr)) { ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[DirectSound] Failed to unlock internal buffer from capture device after reading from the device."); return ma_result_from_HRESULT(hr); } prevReadCursorInBytesCapture = lockOffsetInBytesCapture + mappedSizeInBytesCapture; if (prevReadCursorInBytesCapture == (pDevice->capture.internalPeriodSizeInFrames*pDevice->capture.internalPeriods*bpfDeviceCapture)) { prevReadCursorInBytesCapture = 0; } } break; case ma_device_type_playback: { DWORD availableBytesPlayback; DWORD physicalPlayCursorInBytes; DWORD physicalWriteCursorInBytes; hr = ma_IDirectSoundBuffer_GetCurrentPosition((ma_IDirectSoundBuffer*)pDevice->dsound.pPlaybackBuffer, &physicalPlayCursorInBytes, &physicalWriteCursorInBytes); if (FAILED(hr)) { break; } if (physicalPlayCursorInBytes < prevPlayCursorInBytesPlayback) { physicalPlayCursorLoopFlagPlayback = !physicalPlayCursorLoopFlagPlayback; } prevPlayCursorInBytesPlayback = physicalPlayCursorInBytes; /* If there's any bytes available for writing we can do that now. The space between the virtual cursor position and play cursor. */ if (physicalPlayCursorLoopFlagPlayback == virtualWriteCursorLoopFlagPlayback) { /* Same loop iteration. The available bytes wraps all the way around from the virtual write cursor to the physical play cursor. */ if (physicalPlayCursorInBytes <= virtualWriteCursorInBytesPlayback) { availableBytesPlayback = (pDevice->playback.internalPeriodSizeInFrames*pDevice->playback.internalPeriods*bpfDevicePlayback) - virtualWriteCursorInBytesPlayback; availableBytesPlayback += physicalPlayCursorInBytes; /* Wrap around. */ } else { /* This is an error. */ ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_WARNING, "[DirectSound] (Playback): Play cursor has moved in front of the write cursor (same loop iterations). physicalPlayCursorInBytes=%ld, virtualWriteCursorInBytes=%ld.\n", physicalPlayCursorInBytes, virtualWriteCursorInBytesPlayback); availableBytesPlayback = 0; } } else { /* Different loop iterations. The available bytes only goes from the virtual write cursor to the physical play cursor. */ if (physicalPlayCursorInBytes >= virtualWriteCursorInBytesPlayback) { availableBytesPlayback = physicalPlayCursorInBytes - virtualWriteCursorInBytesPlayback; } else { /* This is an error. */ ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_WARNING, "[DirectSound] (Playback): Write cursor has moved behind the play cursor (different loop iterations). physicalPlayCursorInBytes=%ld, virtualWriteCursorInBytes=%ld.\n", physicalPlayCursorInBytes, virtualWriteCursorInBytesPlayback); availableBytesPlayback = 0; } } /* If there's no room available for writing we need to wait for more. */ if (availableBytesPlayback < pDevice->playback.internalPeriodSizeInFrames) { /* If we haven't started the device yet, this will never get beyond 0. In this case we need to get the device started. */ if (availableBytesPlayback == 0 && !isPlaybackDeviceStarted) { hr = ma_IDirectSoundBuffer_Play((ma_IDirectSoundBuffer*)pDevice->dsound.pPlaybackBuffer, 0, 0, MA_DSBPLAY_LOOPING); if (FAILED(hr)) { ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[DirectSound] IDirectSoundBuffer_Play() failed."); return ma_result_from_HRESULT(hr); } isPlaybackDeviceStarted = MA_TRUE; } else { ma_sleep(waitTimeInMilliseconds); continue; } } /* Getting here means there room available somewhere. We limit this to either the end of the buffer or the physical play cursor, whichever is closest. */ lockOffsetInBytesPlayback = virtualWriteCursorInBytesPlayback; if (physicalPlayCursorLoopFlagPlayback == virtualWriteCursorLoopFlagPlayback) { /* Same loop iteration. Go up to the end of the buffer. */ lockSizeInBytesPlayback = (pDevice->playback.internalPeriodSizeInFrames*pDevice->playback.internalPeriods*bpfDevicePlayback) - virtualWriteCursorInBytesPlayback; } else { /* Different loop iterations. Go up to the physical play cursor. */ lockSizeInBytesPlayback = physicalPlayCursorInBytes - virtualWriteCursorInBytesPlayback; } hr = ma_IDirectSoundBuffer_Lock((ma_IDirectSoundBuffer*)pDevice->dsound.pPlaybackBuffer, lockOffsetInBytesPlayback, lockSizeInBytesPlayback, &pMappedDeviceBufferPlayback, &mappedSizeInBytesPlayback, NULL, NULL, 0); if (FAILED(hr)) { ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[DirectSound] Failed to map buffer from playback device in preparation for writing to the device."); result = ma_result_from_HRESULT(hr); break; } /* At this point we have a buffer for output. */ ma_device__read_frames_from_client(pDevice, (mappedSizeInBytesPlayback/bpfDevicePlayback), pMappedDeviceBufferPlayback); hr = ma_IDirectSoundBuffer_Unlock((ma_IDirectSoundBuffer*)pDevice->dsound.pPlaybackBuffer, pMappedDeviceBufferPlayback, mappedSizeInBytesPlayback, NULL, 0); if (FAILED(hr)) { ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[DirectSound] Failed to unlock internal buffer from playback device after writing to the device."); result = ma_result_from_HRESULT(hr); break; } virtualWriteCursorInBytesPlayback += mappedSizeInBytesPlayback; if (virtualWriteCursorInBytesPlayback == pDevice->playback.internalPeriodSizeInFrames*pDevice->playback.internalPeriods*bpfDevicePlayback) { virtualWriteCursorInBytesPlayback = 0; virtualWriteCursorLoopFlagPlayback = !virtualWriteCursorLoopFlagPlayback; } /* We may need to start the device. We want two full periods to be written before starting the playback device. Having an extra period adds a bit of a buffer to prevent the playback buffer from getting starved. */ framesWrittenToPlaybackDevice += mappedSizeInBytesPlayback/bpfDevicePlayback; if (!isPlaybackDeviceStarted && framesWrittenToPlaybackDevice >= pDevice->playback.internalPeriodSizeInFrames) { hr = ma_IDirectSoundBuffer_Play((ma_IDirectSoundBuffer*)pDevice->dsound.pPlaybackBuffer, 0, 0, MA_DSBPLAY_LOOPING); if (FAILED(hr)) { ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[DirectSound] IDirectSoundBuffer_Play() failed."); return ma_result_from_HRESULT(hr); } isPlaybackDeviceStarted = MA_TRUE; } } break; default: return MA_INVALID_ARGS; /* Invalid device type. */ } if (result != MA_SUCCESS) { return result; } } /* Getting here means the device is being stopped. */ if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) { hr = ma_IDirectSoundCaptureBuffer_Stop((ma_IDirectSoundCaptureBuffer*)pDevice->dsound.pCaptureBuffer); if (FAILED(hr)) { ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[DirectSound] IDirectSoundCaptureBuffer_Stop() failed."); return ma_result_from_HRESULT(hr); } } if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) { /* The playback device should be drained before stopping. All we do is wait until the available bytes is equal to the size of the buffer. */ if (isPlaybackDeviceStarted) { for (;;) { DWORD availableBytesPlayback = 0; DWORD physicalPlayCursorInBytes; DWORD physicalWriteCursorInBytes; hr = ma_IDirectSoundBuffer_GetCurrentPosition((ma_IDirectSoundBuffer*)pDevice->dsound.pPlaybackBuffer, &physicalPlayCursorInBytes, &physicalWriteCursorInBytes); if (FAILED(hr)) { break; } if (physicalPlayCursorInBytes < prevPlayCursorInBytesPlayback) { physicalPlayCursorLoopFlagPlayback = !physicalPlayCursorLoopFlagPlayback; } prevPlayCursorInBytesPlayback = physicalPlayCursorInBytes; if (physicalPlayCursorLoopFlagPlayback == virtualWriteCursorLoopFlagPlayback) { /* Same loop iteration. The available bytes wraps all the way around from the virtual write cursor to the physical play cursor. */ if (physicalPlayCursorInBytes <= virtualWriteCursorInBytesPlayback) { availableBytesPlayback = (pDevice->playback.internalPeriodSizeInFrames*pDevice->playback.internalPeriods*bpfDevicePlayback) - virtualWriteCursorInBytesPlayback; availableBytesPlayback += physicalPlayCursorInBytes; /* Wrap around. */ } else { break; } } else { /* Different loop iterations. The available bytes only goes from the virtual write cursor to the physical play cursor. */ if (physicalPlayCursorInBytes >= virtualWriteCursorInBytesPlayback) { availableBytesPlayback = physicalPlayCursorInBytes - virtualWriteCursorInBytesPlayback; } else { break; } } if (availableBytesPlayback >= (pDevice->playback.internalPeriodSizeInFrames*pDevice->playback.internalPeriods*bpfDevicePlayback)) { break; } ma_sleep(waitTimeInMilliseconds); } } hr = ma_IDirectSoundBuffer_Stop((ma_IDirectSoundBuffer*)pDevice->dsound.pPlaybackBuffer); if (FAILED(hr)) { ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[DirectSound] IDirectSoundBuffer_Stop() failed."); return ma_result_from_HRESULT(hr); } ma_IDirectSoundBuffer_SetCurrentPosition((ma_IDirectSoundBuffer*)pDevice->dsound.pPlaybackBuffer, 0); } return MA_SUCCESS; } static ma_result ma_context_uninit__dsound(ma_context* pContext) { MA_ASSERT(pContext != NULL); MA_ASSERT(pContext->backend == ma_backend_dsound); ma_dlclose(ma_context_get_log(pContext), pContext->dsound.hDSoundDLL); return MA_SUCCESS; } static ma_result ma_context_init__dsound(ma_context* pContext, const ma_context_config* pConfig, ma_backend_callbacks* pCallbacks) { MA_ASSERT(pContext != NULL); (void)pConfig; pContext->dsound.hDSoundDLL = ma_dlopen(ma_context_get_log(pContext), "dsound.dll"); if (pContext->dsound.hDSoundDLL == NULL) { return MA_API_NOT_FOUND; } pContext->dsound.DirectSoundCreate = ma_dlsym(ma_context_get_log(pContext), pContext->dsound.hDSoundDLL, "DirectSoundCreate"); pContext->dsound.DirectSoundEnumerateA = ma_dlsym(ma_context_get_log(pContext), pContext->dsound.hDSoundDLL, "DirectSoundEnumerateA"); pContext->dsound.DirectSoundCaptureCreate = ma_dlsym(ma_context_get_log(pContext), pContext->dsound.hDSoundDLL, "DirectSoundCaptureCreate"); pContext->dsound.DirectSoundCaptureEnumerateA = ma_dlsym(ma_context_get_log(pContext), pContext->dsound.hDSoundDLL, "DirectSoundCaptureEnumerateA"); /* We need to support all functions or nothing. DirectSound with Windows 95 seems to not work too well in my testing. For example, it's missing DirectSoundCaptureEnumerateA(). This is a convenient place to just disable the DirectSound backend for Windows 95. */ if (pContext->dsound.DirectSoundCreate == NULL || pContext->dsound.DirectSoundEnumerateA == NULL || pContext->dsound.DirectSoundCaptureCreate == NULL || pContext->dsound.DirectSoundCaptureEnumerateA == NULL) { return MA_API_NOT_FOUND; } pCallbacks->onContextInit = ma_context_init__dsound; pCallbacks->onContextUninit = ma_context_uninit__dsound; pCallbacks->onContextEnumerateDevices = ma_context_enumerate_devices__dsound; pCallbacks->onContextGetDeviceInfo = ma_context_get_device_info__dsound; pCallbacks->onDeviceInit = ma_device_init__dsound; pCallbacks->onDeviceUninit = ma_device_uninit__dsound; pCallbacks->onDeviceStart = NULL; /* Not used. Started in onDeviceDataLoop. */ pCallbacks->onDeviceStop = NULL; /* Not used. Stopped in onDeviceDataLoop. */ pCallbacks->onDeviceRead = NULL; /* Not used. Data is read directly in onDeviceDataLoop. */ pCallbacks->onDeviceWrite = NULL; /* Not used. Data is written directly in onDeviceDataLoop. */ pCallbacks->onDeviceDataLoop = ma_device_data_loop__dsound; return MA_SUCCESS; } #endif /****************************************************************************** WinMM Backend ******************************************************************************/ #ifdef MA_HAS_WINMM /* Some build configurations will exclude the WinMM API. An example is when WIN32_LEAN_AND_MEAN is defined. We need to define the types and functions we need manually. */ #define MA_MMSYSERR_NOERROR 0 #define MA_MMSYSERR_ERROR 1 #define MA_MMSYSERR_BADDEVICEID 2 #define MA_MMSYSERR_INVALHANDLE 5 #define MA_MMSYSERR_NOMEM 7 #define MA_MMSYSERR_INVALFLAG 10 #define MA_MMSYSERR_INVALPARAM 11 #define MA_MMSYSERR_HANDLEBUSY 12 #define MA_CALLBACK_EVENT 0x00050000 #define MA_WAVE_ALLOWSYNC 0x0002 #define MA_WHDR_DONE 0x00000001 #define MA_WHDR_PREPARED 0x00000002 #define MA_WHDR_BEGINLOOP 0x00000004 #define MA_WHDR_ENDLOOP 0x00000008 #define MA_WHDR_INQUEUE 0x00000010 #define MA_MAXPNAMELEN 32 typedef void* MA_HWAVEIN; typedef void* MA_HWAVEOUT; typedef UINT MA_MMRESULT; typedef UINT MA_MMVERSION; typedef struct { WORD wMid; WORD wPid; MA_MMVERSION vDriverVersion; CHAR szPname[MA_MAXPNAMELEN]; DWORD dwFormats; WORD wChannels; WORD wReserved1; } MA_WAVEINCAPSA; typedef struct { WORD wMid; WORD wPid; MA_MMVERSION vDriverVersion; CHAR szPname[MA_MAXPNAMELEN]; DWORD dwFormats; WORD wChannels; WORD wReserved1; DWORD dwSupport; } MA_WAVEOUTCAPSA; typedef struct tagWAVEHDR { char* lpData; DWORD dwBufferLength; DWORD dwBytesRecorded; DWORD_PTR dwUser; DWORD dwFlags; DWORD dwLoops; struct tagWAVEHDR* lpNext; DWORD_PTR reserved; } MA_WAVEHDR; typedef struct { WORD wMid; WORD wPid; MA_MMVERSION vDriverVersion; CHAR szPname[MA_MAXPNAMELEN]; DWORD dwFormats; WORD wChannels; WORD wReserved1; DWORD dwSupport; GUID ManufacturerGuid; GUID ProductGuid; GUID NameGuid; } MA_WAVEOUTCAPS2A; typedef struct { WORD wMid; WORD wPid; MA_MMVERSION vDriverVersion; CHAR szPname[MA_MAXPNAMELEN]; DWORD dwFormats; WORD wChannels; WORD wReserved1; GUID ManufacturerGuid; GUID ProductGuid; GUID NameGuid; } MA_WAVEINCAPS2A; typedef UINT (WINAPI * MA_PFN_waveOutGetNumDevs)(void); typedef MA_MMRESULT (WINAPI * MA_PFN_waveOutGetDevCapsA)(ma_uintptr uDeviceID, MA_WAVEOUTCAPSA* pwoc, UINT cbwoc); typedef MA_MMRESULT (WINAPI * MA_PFN_waveOutOpen)(MA_HWAVEOUT* phwo, UINT uDeviceID, const MA_WAVEFORMATEX* pwfx, DWORD_PTR dwCallback, DWORD_PTR dwInstance, DWORD fdwOpen); typedef MA_MMRESULT (WINAPI * MA_PFN_waveOutClose)(MA_HWAVEOUT hwo); typedef MA_MMRESULT (WINAPI * MA_PFN_waveOutPrepareHeader)(MA_HWAVEOUT hwo, MA_WAVEHDR* pwh, UINT cbwh); typedef MA_MMRESULT (WINAPI * MA_PFN_waveOutUnprepareHeader)(MA_HWAVEOUT hwo, MA_WAVEHDR* pwh, UINT cbwh); typedef MA_MMRESULT (WINAPI * MA_PFN_waveOutWrite)(MA_HWAVEOUT hwo, MA_WAVEHDR* pwh, UINT cbwh); typedef MA_MMRESULT (WINAPI * MA_PFN_waveOutReset)(MA_HWAVEOUT hwo); typedef UINT (WINAPI * MA_PFN_waveInGetNumDevs)(void); typedef MA_MMRESULT (WINAPI * MA_PFN_waveInGetDevCapsA)(ma_uintptr uDeviceID, MA_WAVEINCAPSA* pwic, UINT cbwic); typedef MA_MMRESULT (WINAPI * MA_PFN_waveInOpen)(MA_HWAVEIN* phwi, UINT uDeviceID, const MA_WAVEFORMATEX* pwfx, DWORD_PTR dwCallback, DWORD_PTR dwInstance, DWORD fdwOpen); typedef MA_MMRESULT (WINAPI * MA_PFN_waveInClose)(MA_HWAVEIN hwi); typedef MA_MMRESULT (WINAPI * MA_PFN_waveInPrepareHeader)(MA_HWAVEIN hwi, MA_WAVEHDR* pwh, UINT cbwh); typedef MA_MMRESULT (WINAPI * MA_PFN_waveInUnprepareHeader)(MA_HWAVEIN hwi, MA_WAVEHDR* pwh, UINT cbwh); typedef MA_MMRESULT (WINAPI * MA_PFN_waveInAddBuffer)(MA_HWAVEIN hwi, MA_WAVEHDR* pwh, UINT cbwh); typedef MA_MMRESULT (WINAPI * MA_PFN_waveInStart)(MA_HWAVEIN hwi); typedef MA_MMRESULT (WINAPI * MA_PFN_waveInReset)(MA_HWAVEIN hwi); static ma_result ma_result_from_MMRESULT(MA_MMRESULT resultMM) { switch (resultMM) { case MA_MMSYSERR_NOERROR: return MA_SUCCESS; case MA_MMSYSERR_BADDEVICEID: return MA_INVALID_ARGS; case MA_MMSYSERR_INVALHANDLE: return MA_INVALID_ARGS; case MA_MMSYSERR_NOMEM: return MA_OUT_OF_MEMORY; case MA_MMSYSERR_INVALFLAG: return MA_INVALID_ARGS; case MA_MMSYSERR_INVALPARAM: return MA_INVALID_ARGS; case MA_MMSYSERR_HANDLEBUSY: return MA_BUSY; case MA_MMSYSERR_ERROR: return MA_ERROR; default: return MA_ERROR; } } static char* ma_find_last_character(char* str, char ch) { char* last; if (str == NULL) { return NULL; } last = NULL; while (*str != '\0') { if (*str == ch) { last = str; } str += 1; } return last; } static ma_uint32 ma_get_period_size_in_bytes(ma_uint32 periodSizeInFrames, ma_format format, ma_uint32 channels) { return periodSizeInFrames * ma_get_bytes_per_frame(format, channels); } /* Our own "WAVECAPS" structure that contains generic information shared between WAVEOUTCAPS2 and WAVEINCAPS2 so we can do things generically and typesafely. Names are being kept the same for consistency. */ typedef struct { CHAR szPname[MA_MAXPNAMELEN]; DWORD dwFormats; WORD wChannels; GUID NameGuid; } MA_WAVECAPSA; static ma_result ma_get_best_info_from_formats_flags__winmm(DWORD dwFormats, WORD channels, WORD* pBitsPerSample, DWORD* pSampleRate) { WORD bitsPerSample = 0; DWORD sampleRate = 0; if (pBitsPerSample) { *pBitsPerSample = 0; } if (pSampleRate) { *pSampleRate = 0; } if (channels == 1) { bitsPerSample = 16; if ((dwFormats & WAVE_FORMAT_48M16) != 0) { sampleRate = 48000; } else if ((dwFormats & WAVE_FORMAT_44M16) != 0) { sampleRate = 44100; } else if ((dwFormats & WAVE_FORMAT_2M16) != 0) { sampleRate = 22050; } else if ((dwFormats & WAVE_FORMAT_1M16) != 0) { sampleRate = 11025; } else if ((dwFormats & WAVE_FORMAT_96M16) != 0) { sampleRate = 96000; } else { bitsPerSample = 8; if ((dwFormats & WAVE_FORMAT_48M08) != 0) { sampleRate = 48000; } else if ((dwFormats & WAVE_FORMAT_44M08) != 0) { sampleRate = 44100; } else if ((dwFormats & WAVE_FORMAT_2M08) != 0) { sampleRate = 22050; } else if ((dwFormats & WAVE_FORMAT_1M08) != 0) { sampleRate = 11025; } else if ((dwFormats & WAVE_FORMAT_96M08) != 0) { sampleRate = 96000; } else { return MA_FORMAT_NOT_SUPPORTED; } } } else { bitsPerSample = 16; if ((dwFormats & WAVE_FORMAT_48S16) != 0) { sampleRate = 48000; } else if ((dwFormats & WAVE_FORMAT_44S16) != 0) { sampleRate = 44100; } else if ((dwFormats & WAVE_FORMAT_2S16) != 0) { sampleRate = 22050; } else if ((dwFormats & WAVE_FORMAT_1S16) != 0) { sampleRate = 11025; } else if ((dwFormats & WAVE_FORMAT_96S16) != 0) { sampleRate = 96000; } else { bitsPerSample = 8; if ((dwFormats & WAVE_FORMAT_48S08) != 0) { sampleRate = 48000; } else if ((dwFormats & WAVE_FORMAT_44S08) != 0) { sampleRate = 44100; } else if ((dwFormats & WAVE_FORMAT_2S08) != 0) { sampleRate = 22050; } else if ((dwFormats & WAVE_FORMAT_1S08) != 0) { sampleRate = 11025; } else if ((dwFormats & WAVE_FORMAT_96S08) != 0) { sampleRate = 96000; } else { return MA_FORMAT_NOT_SUPPORTED; } } } if (pBitsPerSample) { *pBitsPerSample = bitsPerSample; } if (pSampleRate) { *pSampleRate = sampleRate; } return MA_SUCCESS; } static ma_result ma_formats_flags_to_WAVEFORMATEX__winmm(DWORD dwFormats, WORD channels, MA_WAVEFORMATEX* pWF) { ma_result result; MA_ASSERT(pWF != NULL); MA_ZERO_OBJECT(pWF); pWF->cbSize = sizeof(*pWF); pWF->wFormatTag = WAVE_FORMAT_PCM; pWF->nChannels = (WORD)channels; if (pWF->nChannels > 2) { pWF->nChannels = 2; } result = ma_get_best_info_from_formats_flags__winmm(dwFormats, channels, &pWF->wBitsPerSample, &pWF->nSamplesPerSec); if (result != MA_SUCCESS) { return result; } pWF->nBlockAlign = (WORD)(pWF->nChannels * pWF->wBitsPerSample / 8); pWF->nAvgBytesPerSec = pWF->nBlockAlign * pWF->nSamplesPerSec; return MA_SUCCESS; } static ma_result ma_context_get_device_info_from_WAVECAPS(ma_context* pContext, MA_WAVECAPSA* pCaps, ma_device_info* pDeviceInfo) { WORD bitsPerSample; DWORD sampleRate; ma_result result; MA_ASSERT(pContext != NULL); MA_ASSERT(pCaps != NULL); MA_ASSERT(pDeviceInfo != NULL); /* Name / Description Unfortunately the name specified in WAVE(OUT/IN)CAPS2 is limited to 31 characters. This results in an unprofessional looking situation where the names of the devices are truncated. To help work around this, we need to look at the name GUID and try looking in the registry for the full name. If we can't find it there, we need to just fall back to the default name. */ /* Set the default to begin with. */ ma_strncpy_s(pDeviceInfo->name, sizeof(pDeviceInfo->name), pCaps->szPname, (size_t)-1); /* Now try the registry. There's a few things to consider here: - The name GUID can be null, in which we case we just need to stick to the original 31 characters. - If the name GUID is not present in the registry we'll also need to stick to the original 31 characters. - I like consistency, so I want the returned device names to be consistent with those returned by WASAPI and DirectSound. The problem, however is that WASAPI and DirectSound use " ()" format (such as "Speakers (High Definition Audio)"), but WinMM does not specificy the component name. From my admittedly limited testing, I've notice the component name seems to usually fit within the 31 characters of the fixed sized buffer, so what I'm going to do is parse that string for the component name, and then concatenate the name from the registry. */ if (!ma_is_guid_null(&pCaps->NameGuid)) { WCHAR guidStrW[256]; if (((MA_PFN_StringFromGUID2)pContext->win32.StringFromGUID2)(&pCaps->NameGuid, guidStrW, ma_countof(guidStrW)) > 0) { char guidStr[256]; char keyStr[1024]; HKEY hKey; WideCharToMultiByte(CP_UTF8, 0, guidStrW, -1, guidStr, sizeof(guidStr), 0, FALSE); ma_strcpy_s(keyStr, sizeof(keyStr), "SYSTEM\\CurrentControlSet\\Control\\MediaCategories\\"); ma_strcat_s(keyStr, sizeof(keyStr), guidStr); if (((MA_PFN_RegOpenKeyExA)pContext->win32.RegOpenKeyExA)(HKEY_LOCAL_MACHINE, keyStr, 0, KEY_READ, &hKey) == ERROR_SUCCESS) { BYTE nameFromReg[512]; DWORD nameFromRegSize = sizeof(nameFromReg); LONG resultWin32 = ((MA_PFN_RegQueryValueExA)pContext->win32.RegQueryValueExA)(hKey, "Name", 0, NULL, (BYTE*)nameFromReg, (DWORD*)&nameFromRegSize); ((MA_PFN_RegCloseKey)pContext->win32.RegCloseKey)(hKey); if (resultWin32 == ERROR_SUCCESS) { /* We have the value from the registry, so now we need to construct the name string. */ char name[1024]; if (ma_strcpy_s(name, sizeof(name), pDeviceInfo->name) == 0) { char* nameBeg = ma_find_last_character(name, '('); if (nameBeg != NULL) { size_t leadingLen = (nameBeg - name); ma_strncpy_s(nameBeg + 1, sizeof(name) - leadingLen, (const char*)nameFromReg, (size_t)-1); /* The closing ")", if it can fit. */ if (leadingLen + nameFromRegSize < sizeof(name)-1) { ma_strcat_s(name, sizeof(name), ")"); } ma_strncpy_s(pDeviceInfo->name, sizeof(pDeviceInfo->name), name, (size_t)-1); } } } } } } result = ma_get_best_info_from_formats_flags__winmm(pCaps->dwFormats, pCaps->wChannels, &bitsPerSample, &sampleRate); if (result != MA_SUCCESS) { return result; } if (bitsPerSample == 8) { pDeviceInfo->nativeDataFormats[0].format = ma_format_u8; } else if (bitsPerSample == 16) { pDeviceInfo->nativeDataFormats[0].format = ma_format_s16; } else if (bitsPerSample == 24) { pDeviceInfo->nativeDataFormats[0].format = ma_format_s24; } else if (bitsPerSample == 32) { pDeviceInfo->nativeDataFormats[0].format = ma_format_s32; } else { return MA_FORMAT_NOT_SUPPORTED; } pDeviceInfo->nativeDataFormats[0].channels = pCaps->wChannels; pDeviceInfo->nativeDataFormats[0].sampleRate = sampleRate; pDeviceInfo->nativeDataFormats[0].flags = 0; pDeviceInfo->nativeDataFormatCount = 1; return MA_SUCCESS; } static ma_result ma_context_get_device_info_from_WAVEOUTCAPS2(ma_context* pContext, MA_WAVEOUTCAPS2A* pCaps, ma_device_info* pDeviceInfo) { MA_WAVECAPSA caps; MA_ASSERT(pContext != NULL); MA_ASSERT(pCaps != NULL); MA_ASSERT(pDeviceInfo != NULL); MA_COPY_MEMORY(caps.szPname, pCaps->szPname, sizeof(caps.szPname)); caps.dwFormats = pCaps->dwFormats; caps.wChannels = pCaps->wChannels; caps.NameGuid = pCaps->NameGuid; return ma_context_get_device_info_from_WAVECAPS(pContext, &caps, pDeviceInfo); } static ma_result ma_context_get_device_info_from_WAVEINCAPS2(ma_context* pContext, MA_WAVEINCAPS2A* pCaps, ma_device_info* pDeviceInfo) { MA_WAVECAPSA caps; MA_ASSERT(pContext != NULL); MA_ASSERT(pCaps != NULL); MA_ASSERT(pDeviceInfo != NULL); MA_COPY_MEMORY(caps.szPname, pCaps->szPname, sizeof(caps.szPname)); caps.dwFormats = pCaps->dwFormats; caps.wChannels = pCaps->wChannels; caps.NameGuid = pCaps->NameGuid; return ma_context_get_device_info_from_WAVECAPS(pContext, &caps, pDeviceInfo); } static ma_result ma_context_enumerate_devices__winmm(ma_context* pContext, ma_enum_devices_callback_proc callback, void* pUserData) { UINT playbackDeviceCount; UINT captureDeviceCount; UINT iPlaybackDevice; UINT iCaptureDevice; MA_ASSERT(pContext != NULL); MA_ASSERT(callback != NULL); /* Playback. */ playbackDeviceCount = ((MA_PFN_waveOutGetNumDevs)pContext->winmm.waveOutGetNumDevs)(); for (iPlaybackDevice = 0; iPlaybackDevice < playbackDeviceCount; ++iPlaybackDevice) { MA_MMRESULT result; MA_WAVEOUTCAPS2A caps; MA_ZERO_OBJECT(&caps); result = ((MA_PFN_waveOutGetDevCapsA)pContext->winmm.waveOutGetDevCapsA)(iPlaybackDevice, (MA_WAVEOUTCAPSA*)&caps, sizeof(caps)); if (result == MA_MMSYSERR_NOERROR) { ma_device_info deviceInfo; MA_ZERO_OBJECT(&deviceInfo); deviceInfo.id.winmm = iPlaybackDevice; /* The first enumerated device is the default device. */ if (iPlaybackDevice == 0) { deviceInfo.isDefault = MA_TRUE; } if (ma_context_get_device_info_from_WAVEOUTCAPS2(pContext, &caps, &deviceInfo) == MA_SUCCESS) { ma_bool32 cbResult = callback(pContext, ma_device_type_playback, &deviceInfo, pUserData); if (cbResult == MA_FALSE) { return MA_SUCCESS; /* Enumeration was stopped. */ } } } } /* Capture. */ captureDeviceCount = ((MA_PFN_waveInGetNumDevs)pContext->winmm.waveInGetNumDevs)(); for (iCaptureDevice = 0; iCaptureDevice < captureDeviceCount; ++iCaptureDevice) { MA_MMRESULT result; MA_WAVEINCAPS2A caps; MA_ZERO_OBJECT(&caps); result = ((MA_PFN_waveInGetDevCapsA)pContext->winmm.waveInGetDevCapsA)(iCaptureDevice, (MA_WAVEINCAPSA*)&caps, sizeof(caps)); if (result == MA_MMSYSERR_NOERROR) { ma_device_info deviceInfo; MA_ZERO_OBJECT(&deviceInfo); deviceInfo.id.winmm = iCaptureDevice; /* The first enumerated device is the default device. */ if (iCaptureDevice == 0) { deviceInfo.isDefault = MA_TRUE; } if (ma_context_get_device_info_from_WAVEINCAPS2(pContext, &caps, &deviceInfo) == MA_SUCCESS) { ma_bool32 cbResult = callback(pContext, ma_device_type_capture, &deviceInfo, pUserData); if (cbResult == MA_FALSE) { return MA_SUCCESS; /* Enumeration was stopped. */ } } } } return MA_SUCCESS; } static ma_result ma_context_get_device_info__winmm(ma_context* pContext, ma_device_type deviceType, const ma_device_id* pDeviceID, ma_device_info* pDeviceInfo) { UINT winMMDeviceID; MA_ASSERT(pContext != NULL); winMMDeviceID = 0; if (pDeviceID != NULL) { winMMDeviceID = (UINT)pDeviceID->winmm; } pDeviceInfo->id.winmm = winMMDeviceID; /* The first ID is the default device. */ if (winMMDeviceID == 0) { pDeviceInfo->isDefault = MA_TRUE; } if (deviceType == ma_device_type_playback) { MA_MMRESULT result; MA_WAVEOUTCAPS2A caps; MA_ZERO_OBJECT(&caps); result = ((MA_PFN_waveOutGetDevCapsA)pContext->winmm.waveOutGetDevCapsA)(winMMDeviceID, (MA_WAVEOUTCAPSA*)&caps, sizeof(caps)); if (result == MA_MMSYSERR_NOERROR) { return ma_context_get_device_info_from_WAVEOUTCAPS2(pContext, &caps, pDeviceInfo); } } else { MA_MMRESULT result; MA_WAVEINCAPS2A caps; MA_ZERO_OBJECT(&caps); result = ((MA_PFN_waveInGetDevCapsA)pContext->winmm.waveInGetDevCapsA)(winMMDeviceID, (MA_WAVEINCAPSA*)&caps, sizeof(caps)); if (result == MA_MMSYSERR_NOERROR) { return ma_context_get_device_info_from_WAVEINCAPS2(pContext, &caps, pDeviceInfo); } } return MA_NO_DEVICE; } static ma_result ma_device_uninit__winmm(ma_device* pDevice) { MA_ASSERT(pDevice != NULL); if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) { ((MA_PFN_waveInClose)pDevice->pContext->winmm.waveInClose)((MA_HWAVEIN)pDevice->winmm.hDeviceCapture); CloseHandle((HANDLE)pDevice->winmm.hEventCapture); } if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) { ((MA_PFN_waveOutReset)pDevice->pContext->winmm.waveOutReset)((MA_HWAVEOUT)pDevice->winmm.hDevicePlayback); ((MA_PFN_waveOutClose)pDevice->pContext->winmm.waveOutClose)((MA_HWAVEOUT)pDevice->winmm.hDevicePlayback); CloseHandle((HANDLE)pDevice->winmm.hEventPlayback); } ma_free(pDevice->winmm._pHeapData, &pDevice->pContext->allocationCallbacks); MA_ZERO_OBJECT(&pDevice->winmm); /* Safety. */ return MA_SUCCESS; } static ma_uint32 ma_calculate_period_size_in_frames_from_descriptor__winmm(const ma_device_descriptor* pDescriptor, ma_uint32 nativeSampleRate, ma_performance_profile performanceProfile) { /* WinMM has a minimum period size of 40ms. */ ma_uint32 minPeriodSizeInFrames = ma_calculate_buffer_size_in_frames_from_milliseconds(40, nativeSampleRate); ma_uint32 periodSizeInFrames; periodSizeInFrames = ma_calculate_buffer_size_in_frames_from_descriptor(pDescriptor, nativeSampleRate, performanceProfile); if (periodSizeInFrames < minPeriodSizeInFrames) { periodSizeInFrames = minPeriodSizeInFrames; } return periodSizeInFrames; } static ma_result ma_device_init__winmm(ma_device* pDevice, const ma_device_config* pConfig, ma_device_descriptor* pDescriptorPlayback, ma_device_descriptor* pDescriptorCapture) { const char* errorMsg = ""; ma_result errorCode = MA_ERROR; ma_result result = MA_SUCCESS; ma_uint32 heapSize; UINT winMMDeviceIDPlayback = 0; UINT winMMDeviceIDCapture = 0; MA_ASSERT(pDevice != NULL); MA_ZERO_OBJECT(&pDevice->winmm); if (pConfig->deviceType == ma_device_type_loopback) { return MA_DEVICE_TYPE_NOT_SUPPORTED; } /* No exlusive mode with WinMM. */ if (((pConfig->deviceType == ma_device_type_playback || pConfig->deviceType == ma_device_type_duplex) && pDescriptorPlayback->shareMode == ma_share_mode_exclusive) || ((pConfig->deviceType == ma_device_type_capture || pConfig->deviceType == ma_device_type_duplex) && pDescriptorCapture->shareMode == ma_share_mode_exclusive)) { return MA_SHARE_MODE_NOT_SUPPORTED; } if (pDescriptorPlayback->pDeviceID != NULL) { winMMDeviceIDPlayback = (UINT)pDescriptorPlayback->pDeviceID->winmm; } if (pDescriptorCapture->pDeviceID != NULL) { winMMDeviceIDCapture = (UINT)pDescriptorCapture->pDeviceID->winmm; } /* The capture device needs to be initialized first. */ if (pConfig->deviceType == ma_device_type_capture || pConfig->deviceType == ma_device_type_duplex) { MA_WAVEINCAPSA caps; MA_WAVEFORMATEX wf; MA_MMRESULT resultMM; /* We use an event to know when a new fragment needs to be enqueued. */ pDevice->winmm.hEventCapture = (ma_handle)CreateEventA(NULL, TRUE, TRUE, NULL); if (pDevice->winmm.hEventCapture == NULL) { errorMsg = "[WinMM] Failed to create event for fragment enqueing for the capture device.", errorCode = ma_result_from_GetLastError(GetLastError()); goto on_error; } /* The format should be based on the device's actual format. */ if (((MA_PFN_waveInGetDevCapsA)pDevice->pContext->winmm.waveInGetDevCapsA)(winMMDeviceIDCapture, &caps, sizeof(caps)) != MA_MMSYSERR_NOERROR) { errorMsg = "[WinMM] Failed to retrieve internal device caps.", errorCode = MA_FORMAT_NOT_SUPPORTED; goto on_error; } result = ma_formats_flags_to_WAVEFORMATEX__winmm(caps.dwFormats, caps.wChannels, &wf); if (result != MA_SUCCESS) { errorMsg = "[WinMM] Could not find appropriate format for internal device.", errorCode = result; goto on_error; } resultMM = ((MA_PFN_waveInOpen)pDevice->pContext->winmm.waveInOpen)((MA_HWAVEIN*)&pDevice->winmm.hDeviceCapture, winMMDeviceIDCapture, &wf, (DWORD_PTR)pDevice->winmm.hEventCapture, (DWORD_PTR)pDevice, MA_CALLBACK_EVENT | MA_WAVE_ALLOWSYNC); if (resultMM != MA_MMSYSERR_NOERROR) { errorMsg = "[WinMM] Failed to open capture device.", errorCode = MA_FAILED_TO_OPEN_BACKEND_DEVICE; goto on_error; } pDescriptorCapture->format = ma_format_from_WAVEFORMATEX(&wf); pDescriptorCapture->channels = wf.nChannels; pDescriptorCapture->sampleRate = wf.nSamplesPerSec; ma_channel_map_init_standard(ma_standard_channel_map_microsoft, pDescriptorCapture->channelMap, ma_countof(pDescriptorCapture->channelMap), pDescriptorCapture->channels); pDescriptorCapture->periodCount = pDescriptorCapture->periodCount; pDescriptorCapture->periodSizeInFrames = ma_calculate_period_size_in_frames_from_descriptor__winmm(pDescriptorCapture, pDescriptorCapture->sampleRate, pConfig->performanceProfile); } if (pConfig->deviceType == ma_device_type_playback || pConfig->deviceType == ma_device_type_duplex) { MA_WAVEOUTCAPSA caps; MA_WAVEFORMATEX wf; MA_MMRESULT resultMM; /* We use an event to know when a new fragment needs to be enqueued. */ pDevice->winmm.hEventPlayback = (ma_handle)CreateEventA(NULL, TRUE, TRUE, NULL); if (pDevice->winmm.hEventPlayback == NULL) { errorMsg = "[WinMM] Failed to create event for fragment enqueing for the playback device.", errorCode = ma_result_from_GetLastError(GetLastError()); goto on_error; } /* The format should be based on the device's actual format. */ if (((MA_PFN_waveOutGetDevCapsA)pDevice->pContext->winmm.waveOutGetDevCapsA)(winMMDeviceIDPlayback, &caps, sizeof(caps)) != MA_MMSYSERR_NOERROR) { errorMsg = "[WinMM] Failed to retrieve internal device caps.", errorCode = MA_FORMAT_NOT_SUPPORTED; goto on_error; } result = ma_formats_flags_to_WAVEFORMATEX__winmm(caps.dwFormats, caps.wChannels, &wf); if (result != MA_SUCCESS) { errorMsg = "[WinMM] Could not find appropriate format for internal device.", errorCode = result; goto on_error; } resultMM = ((MA_PFN_waveOutOpen)pDevice->pContext->winmm.waveOutOpen)((MA_HWAVEOUT*)&pDevice->winmm.hDevicePlayback, winMMDeviceIDPlayback, &wf, (DWORD_PTR)pDevice->winmm.hEventPlayback, (DWORD_PTR)pDevice, MA_CALLBACK_EVENT | MA_WAVE_ALLOWSYNC); if (resultMM != MA_MMSYSERR_NOERROR) { errorMsg = "[WinMM] Failed to open playback device.", errorCode = MA_FAILED_TO_OPEN_BACKEND_DEVICE; goto on_error; } pDescriptorPlayback->format = ma_format_from_WAVEFORMATEX(&wf); pDescriptorPlayback->channels = wf.nChannels; pDescriptorPlayback->sampleRate = wf.nSamplesPerSec; ma_channel_map_init_standard(ma_standard_channel_map_microsoft, pDescriptorPlayback->channelMap, ma_countof(pDescriptorPlayback->channelMap), pDescriptorPlayback->channels); pDescriptorPlayback->periodCount = pDescriptorPlayback->periodCount; pDescriptorPlayback->periodSizeInFrames = ma_calculate_period_size_in_frames_from_descriptor__winmm(pDescriptorPlayback, pDescriptorPlayback->sampleRate, pConfig->performanceProfile); } /* The heap allocated data is allocated like so: [Capture WAVEHDRs][Playback WAVEHDRs][Capture Intermediary Buffer][Playback Intermediary Buffer] */ heapSize = 0; if (pConfig->deviceType == ma_device_type_capture || pConfig->deviceType == ma_device_type_duplex) { heapSize += sizeof(MA_WAVEHDR)*pDescriptorCapture->periodCount + (pDescriptorCapture->periodSizeInFrames * pDescriptorCapture->periodCount * ma_get_bytes_per_frame(pDescriptorCapture->format, pDescriptorCapture->channels)); } if (pConfig->deviceType == ma_device_type_playback || pConfig->deviceType == ma_device_type_duplex) { heapSize += sizeof(MA_WAVEHDR)*pDescriptorPlayback->periodCount + (pDescriptorPlayback->periodSizeInFrames * pDescriptorPlayback->periodCount * ma_get_bytes_per_frame(pDescriptorPlayback->format, pDescriptorPlayback->channels)); } pDevice->winmm._pHeapData = (ma_uint8*)ma_calloc(heapSize, &pDevice->pContext->allocationCallbacks); if (pDevice->winmm._pHeapData == NULL) { errorMsg = "[WinMM] Failed to allocate memory for the intermediary buffer.", errorCode = MA_OUT_OF_MEMORY; goto on_error; } MA_ZERO_MEMORY(pDevice->winmm._pHeapData, heapSize); if (pConfig->deviceType == ma_device_type_capture || pConfig->deviceType == ma_device_type_duplex) { ma_uint32 iPeriod; if (pConfig->deviceType == ma_device_type_capture) { pDevice->winmm.pWAVEHDRCapture = pDevice->winmm._pHeapData; pDevice->winmm.pIntermediaryBufferCapture = pDevice->winmm._pHeapData + (sizeof(MA_WAVEHDR)*(pDescriptorCapture->periodCount)); } else { pDevice->winmm.pWAVEHDRCapture = pDevice->winmm._pHeapData; pDevice->winmm.pIntermediaryBufferCapture = pDevice->winmm._pHeapData + (sizeof(MA_WAVEHDR)*(pDescriptorCapture->periodCount + pDescriptorPlayback->periodCount)); } /* Prepare headers. */ for (iPeriod = 0; iPeriod < pDescriptorCapture->periodCount; ++iPeriod) { ma_uint32 periodSizeInBytes = ma_get_period_size_in_bytes(pDescriptorCapture->periodSizeInFrames, pDescriptorCapture->format, pDescriptorCapture->channels); ((MA_WAVEHDR*)pDevice->winmm.pWAVEHDRCapture)[iPeriod].lpData = (char*)(pDevice->winmm.pIntermediaryBufferCapture + (periodSizeInBytes*iPeriod)); ((MA_WAVEHDR*)pDevice->winmm.pWAVEHDRCapture)[iPeriod].dwBufferLength = periodSizeInBytes; ((MA_WAVEHDR*)pDevice->winmm.pWAVEHDRCapture)[iPeriod].dwFlags = 0L; ((MA_WAVEHDR*)pDevice->winmm.pWAVEHDRCapture)[iPeriod].dwLoops = 0L; ((MA_PFN_waveInPrepareHeader)pDevice->pContext->winmm.waveInPrepareHeader)((MA_HWAVEIN)pDevice->winmm.hDeviceCapture, &((MA_WAVEHDR*)pDevice->winmm.pWAVEHDRCapture)[iPeriod], sizeof(MA_WAVEHDR)); /* The user data of the MA_WAVEHDR structure is a single flag the controls whether or not it is ready for writing. Consider it to be named "isLocked". A value of 0 means it's unlocked and available for writing. A value of 1 means it's locked. */ ((MA_WAVEHDR*)pDevice->winmm.pWAVEHDRCapture)[iPeriod].dwUser = 0; } } if (pConfig->deviceType == ma_device_type_playback || pConfig->deviceType == ma_device_type_duplex) { ma_uint32 iPeriod; if (pConfig->deviceType == ma_device_type_playback) { pDevice->winmm.pWAVEHDRPlayback = pDevice->winmm._pHeapData; pDevice->winmm.pIntermediaryBufferPlayback = pDevice->winmm._pHeapData + (sizeof(MA_WAVEHDR)*pDescriptorPlayback->periodCount); } else { pDevice->winmm.pWAVEHDRPlayback = pDevice->winmm._pHeapData + (sizeof(MA_WAVEHDR)*(pDescriptorCapture->periodCount)); pDevice->winmm.pIntermediaryBufferPlayback = pDevice->winmm._pHeapData + (sizeof(MA_WAVEHDR)*(pDescriptorCapture->periodCount + pDescriptorPlayback->periodCount)) + (pDescriptorCapture->periodSizeInFrames*pDescriptorCapture->periodCount*ma_get_bytes_per_frame(pDescriptorCapture->format, pDescriptorCapture->channels)); } /* Prepare headers. */ for (iPeriod = 0; iPeriod < pDescriptorPlayback->periodCount; ++iPeriod) { ma_uint32 periodSizeInBytes = ma_get_period_size_in_bytes(pDescriptorPlayback->periodSizeInFrames, pDescriptorPlayback->format, pDescriptorPlayback->channels); ((MA_WAVEHDR*)pDevice->winmm.pWAVEHDRPlayback)[iPeriod].lpData = (char*)(pDevice->winmm.pIntermediaryBufferPlayback + (periodSizeInBytes*iPeriod)); ((MA_WAVEHDR*)pDevice->winmm.pWAVEHDRPlayback)[iPeriod].dwBufferLength = periodSizeInBytes; ((MA_WAVEHDR*)pDevice->winmm.pWAVEHDRPlayback)[iPeriod].dwFlags = 0L; ((MA_WAVEHDR*)pDevice->winmm.pWAVEHDRPlayback)[iPeriod].dwLoops = 0L; ((MA_PFN_waveOutPrepareHeader)pDevice->pContext->winmm.waveOutPrepareHeader)((MA_HWAVEOUT)pDevice->winmm.hDevicePlayback, &((MA_WAVEHDR*)pDevice->winmm.pWAVEHDRPlayback)[iPeriod], sizeof(MA_WAVEHDR)); /* The user data of the MA_WAVEHDR structure is a single flag the controls whether or not it is ready for writing. Consider it to be named "isLocked". A value of 0 means it's unlocked and available for writing. A value of 1 means it's locked. */ ((MA_WAVEHDR*)pDevice->winmm.pWAVEHDRPlayback)[iPeriod].dwUser = 0; } } return MA_SUCCESS; on_error: if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) { if (pDevice->winmm.pWAVEHDRCapture != NULL) { ma_uint32 iPeriod; for (iPeriod = 0; iPeriod < pDescriptorCapture->periodCount; ++iPeriod) { ((MA_PFN_waveInUnprepareHeader)pDevice->pContext->winmm.waveInUnprepareHeader)((MA_HWAVEIN)pDevice->winmm.hDeviceCapture, &((MA_WAVEHDR*)pDevice->winmm.pWAVEHDRCapture)[iPeriod], sizeof(MA_WAVEHDR)); } } ((MA_PFN_waveInClose)pDevice->pContext->winmm.waveInClose)((MA_HWAVEIN)pDevice->winmm.hDeviceCapture); } if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) { if (pDevice->winmm.pWAVEHDRCapture != NULL) { ma_uint32 iPeriod; for (iPeriod = 0; iPeriod < pDescriptorPlayback->periodCount; ++iPeriod) { ((MA_PFN_waveOutUnprepareHeader)pDevice->pContext->winmm.waveOutUnprepareHeader)((MA_HWAVEOUT)pDevice->winmm.hDevicePlayback, &((MA_WAVEHDR*)pDevice->winmm.pWAVEHDRPlayback)[iPeriod], sizeof(MA_WAVEHDR)); } } ((MA_PFN_waveOutClose)pDevice->pContext->winmm.waveOutClose)((MA_HWAVEOUT)pDevice->winmm.hDevicePlayback); } ma_free(pDevice->winmm._pHeapData, &pDevice->pContext->allocationCallbacks); if (errorMsg != NULL && errorMsg[0] != '\0') { ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "%s", errorMsg); } return errorCode; } static ma_result ma_device_start__winmm(ma_device* pDevice) { MA_ASSERT(pDevice != NULL); if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) { MA_MMRESULT resultMM; MA_WAVEHDR* pWAVEHDR; ma_uint32 iPeriod; pWAVEHDR = (MA_WAVEHDR*)pDevice->winmm.pWAVEHDRCapture; /* Make sure the event is reset to a non-signaled state to ensure we don't prematurely return from WaitForSingleObject(). */ ResetEvent((HANDLE)pDevice->winmm.hEventCapture); /* To start the device we attach all of the buffers and then start it. As the buffers are filled with data we will get notifications. */ for (iPeriod = 0; iPeriod < pDevice->capture.internalPeriods; ++iPeriod) { resultMM = ((MA_PFN_waveInAddBuffer)pDevice->pContext->winmm.waveInAddBuffer)((MA_HWAVEIN)pDevice->winmm.hDeviceCapture, &((MA_WAVEHDR*)pDevice->winmm.pWAVEHDRCapture)[iPeriod], sizeof(MA_WAVEHDR)); if (resultMM != MA_MMSYSERR_NOERROR) { ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[WinMM] Failed to attach input buffers to capture device in preparation for capture."); return ma_result_from_MMRESULT(resultMM); } /* Make sure all of the buffers start out locked. We don't want to access them until the backend tells us we can. */ pWAVEHDR[iPeriod].dwUser = 1; /* 1 = locked. */ } /* Capture devices need to be explicitly started, unlike playback devices. */ resultMM = ((MA_PFN_waveInStart)pDevice->pContext->winmm.waveInStart)((MA_HWAVEIN)pDevice->winmm.hDeviceCapture); if (resultMM != MA_MMSYSERR_NOERROR) { ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[WinMM] Failed to start backend device."); return ma_result_from_MMRESULT(resultMM); } } if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) { /* Don't need to do anything for playback. It'll be started automatically in ma_device_start__winmm(). */ } return MA_SUCCESS; } static ma_result ma_device_stop__winmm(ma_device* pDevice) { MA_MMRESULT resultMM; MA_ASSERT(pDevice != NULL); if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) { if (pDevice->winmm.hDeviceCapture == NULL) { return MA_INVALID_ARGS; } resultMM = ((MA_PFN_waveInReset)pDevice->pContext->winmm.waveInReset)((MA_HWAVEIN)pDevice->winmm.hDeviceCapture); if (resultMM != MA_MMSYSERR_NOERROR) { ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_WARNING, "[WinMM] WARNING: Failed to reset capture device."); } } if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) { ma_uint32 iPeriod; MA_WAVEHDR* pWAVEHDR; if (pDevice->winmm.hDevicePlayback == NULL) { return MA_INVALID_ARGS; } /* We need to drain the device. To do this we just loop over each header and if it's locked just wait for the event. */ pWAVEHDR = (MA_WAVEHDR*)pDevice->winmm.pWAVEHDRPlayback; for (iPeriod = 0; iPeriod < pDevice->playback.internalPeriods; iPeriod += 1) { if (pWAVEHDR[iPeriod].dwUser == 1) { /* 1 = locked. */ if (WaitForSingleObject((HANDLE)pDevice->winmm.hEventPlayback, INFINITE) != WAIT_OBJECT_0) { break; /* An error occurred so just abandon ship and stop the device without draining. */ } pWAVEHDR[iPeriod].dwUser = 0; } } resultMM = ((MA_PFN_waveOutReset)pDevice->pContext->winmm.waveOutReset)((MA_HWAVEOUT)pDevice->winmm.hDevicePlayback); if (resultMM != MA_MMSYSERR_NOERROR) { ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_WARNING, "[WinMM] WARNING: Failed to reset playback device."); } } return MA_SUCCESS; } static ma_result ma_device_write__winmm(ma_device* pDevice, const void* pPCMFrames, ma_uint32 frameCount, ma_uint32* pFramesWritten) { ma_result result = MA_SUCCESS; MA_MMRESULT resultMM; ma_uint32 totalFramesWritten; MA_WAVEHDR* pWAVEHDR; MA_ASSERT(pDevice != NULL); MA_ASSERT(pPCMFrames != NULL); if (pFramesWritten != NULL) { *pFramesWritten = 0; } pWAVEHDR = (MA_WAVEHDR*)pDevice->winmm.pWAVEHDRPlayback; /* Keep processing as much data as possible. */ totalFramesWritten = 0; while (totalFramesWritten < frameCount) { /* If the current header has some space available we need to write part of it. */ if (pWAVEHDR[pDevice->winmm.iNextHeaderPlayback].dwUser == 0) { /* 0 = unlocked. */ /* This header has room in it. We copy as much of it as we can. If we end up fully consuming the buffer we need to write it out and move on to the next iteration. */ ma_uint32 bpf = ma_get_bytes_per_frame(pDevice->playback.internalFormat, pDevice->playback.internalChannels); ma_uint32 framesRemainingInHeader = (pWAVEHDR[pDevice->winmm.iNextHeaderPlayback].dwBufferLength/bpf) - pDevice->winmm.headerFramesConsumedPlayback; ma_uint32 framesToCopy = ma_min(framesRemainingInHeader, (frameCount - totalFramesWritten)); const void* pSrc = ma_offset_ptr(pPCMFrames, totalFramesWritten*bpf); void* pDst = ma_offset_ptr(pWAVEHDR[pDevice->winmm.iNextHeaderPlayback].lpData, pDevice->winmm.headerFramesConsumedPlayback*bpf); MA_COPY_MEMORY(pDst, pSrc, framesToCopy*bpf); pDevice->winmm.headerFramesConsumedPlayback += framesToCopy; totalFramesWritten += framesToCopy; /* If we've consumed the buffer entirely we need to write it out to the device. */ if (pDevice->winmm.headerFramesConsumedPlayback == (pWAVEHDR[pDevice->winmm.iNextHeaderPlayback].dwBufferLength/bpf)) { pWAVEHDR[pDevice->winmm.iNextHeaderPlayback].dwUser = 1; /* 1 = locked. */ pWAVEHDR[pDevice->winmm.iNextHeaderPlayback].dwFlags &= ~MA_WHDR_DONE; /* <-- Need to make sure the WHDR_DONE flag is unset. */ /* Make sure the event is reset to a non-signaled state to ensure we don't prematurely return from WaitForSingleObject(). */ ResetEvent((HANDLE)pDevice->winmm.hEventPlayback); /* The device will be started here. */ resultMM = ((MA_PFN_waveOutWrite)pDevice->pContext->winmm.waveOutWrite)((MA_HWAVEOUT)pDevice->winmm.hDevicePlayback, &pWAVEHDR[pDevice->winmm.iNextHeaderPlayback], sizeof(MA_WAVEHDR)); if (resultMM != MA_MMSYSERR_NOERROR) { result = ma_result_from_MMRESULT(resultMM); ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[WinMM] waveOutWrite() failed."); break; } /* Make sure we move to the next header. */ pDevice->winmm.iNextHeaderPlayback = (pDevice->winmm.iNextHeaderPlayback + 1) % pDevice->playback.internalPeriods; pDevice->winmm.headerFramesConsumedPlayback = 0; } /* If at this point we have consumed the entire input buffer we can return. */ MA_ASSERT(totalFramesWritten <= frameCount); if (totalFramesWritten == frameCount) { break; } /* Getting here means there's more to process. */ continue; } /* Getting here means there isn't enough room in the buffer and we need to wait for one to become available. */ if (WaitForSingleObject((HANDLE)pDevice->winmm.hEventPlayback, INFINITE) != WAIT_OBJECT_0) { result = MA_ERROR; break; } /* Something happened. If the next buffer has been marked as done we need to reset a bit of state. */ if ((pWAVEHDR[pDevice->winmm.iNextHeaderPlayback].dwFlags & MA_WHDR_DONE) != 0) { pWAVEHDR[pDevice->winmm.iNextHeaderPlayback].dwUser = 0; /* 0 = unlocked (make it available for writing). */ pDevice->winmm.headerFramesConsumedPlayback = 0; } /* If the device has been stopped we need to break. */ if (ma_device_get_state(pDevice) != ma_device_state_started) { break; } } if (pFramesWritten != NULL) { *pFramesWritten = totalFramesWritten; } return result; } static ma_result ma_device_read__winmm(ma_device* pDevice, void* pPCMFrames, ma_uint32 frameCount, ma_uint32* pFramesRead) { ma_result result = MA_SUCCESS; MA_MMRESULT resultMM; ma_uint32 totalFramesRead; MA_WAVEHDR* pWAVEHDR; MA_ASSERT(pDevice != NULL); MA_ASSERT(pPCMFrames != NULL); if (pFramesRead != NULL) { *pFramesRead = 0; } pWAVEHDR = (MA_WAVEHDR*)pDevice->winmm.pWAVEHDRCapture; /* Keep processing as much data as possible. */ totalFramesRead = 0; while (totalFramesRead < frameCount) { /* If the current header has some space available we need to write part of it. */ if (pWAVEHDR[pDevice->winmm.iNextHeaderCapture].dwUser == 0) { /* 0 = unlocked. */ /* The buffer is available for reading. If we fully consume it we need to add it back to the buffer. */ ma_uint32 bpf = ma_get_bytes_per_frame(pDevice->capture.internalFormat, pDevice->capture.internalChannels); ma_uint32 framesRemainingInHeader = (pWAVEHDR[pDevice->winmm.iNextHeaderCapture].dwBufferLength/bpf) - pDevice->winmm.headerFramesConsumedCapture; ma_uint32 framesToCopy = ma_min(framesRemainingInHeader, (frameCount - totalFramesRead)); const void* pSrc = ma_offset_ptr(pWAVEHDR[pDevice->winmm.iNextHeaderCapture].lpData, pDevice->winmm.headerFramesConsumedCapture*bpf); void* pDst = ma_offset_ptr(pPCMFrames, totalFramesRead*bpf); MA_COPY_MEMORY(pDst, pSrc, framesToCopy*bpf); pDevice->winmm.headerFramesConsumedCapture += framesToCopy; totalFramesRead += framesToCopy; /* If we've consumed the buffer entirely we need to add it back to the device. */ if (pDevice->winmm.headerFramesConsumedCapture == (pWAVEHDR[pDevice->winmm.iNextHeaderCapture].dwBufferLength/bpf)) { pWAVEHDR[pDevice->winmm.iNextHeaderCapture].dwUser = 1; /* 1 = locked. */ pWAVEHDR[pDevice->winmm.iNextHeaderCapture].dwFlags &= ~MA_WHDR_DONE; /* <-- Need to make sure the WHDR_DONE flag is unset. */ /* Make sure the event is reset to a non-signaled state to ensure we don't prematurely return from WaitForSingleObject(). */ ResetEvent((HANDLE)pDevice->winmm.hEventCapture); /* The device will be started here. */ resultMM = ((MA_PFN_waveInAddBuffer)pDevice->pContext->winmm.waveInAddBuffer)((MA_HWAVEIN)pDevice->winmm.hDeviceCapture, &((MA_WAVEHDR*)pDevice->winmm.pWAVEHDRCapture)[pDevice->winmm.iNextHeaderCapture], sizeof(MA_WAVEHDR)); if (resultMM != MA_MMSYSERR_NOERROR) { result = ma_result_from_MMRESULT(resultMM); ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[WinMM] waveInAddBuffer() failed."); break; } /* Make sure we move to the next header. */ pDevice->winmm.iNextHeaderCapture = (pDevice->winmm.iNextHeaderCapture + 1) % pDevice->capture.internalPeriods; pDevice->winmm.headerFramesConsumedCapture = 0; } /* If at this point we have filled the entire input buffer we can return. */ MA_ASSERT(totalFramesRead <= frameCount); if (totalFramesRead == frameCount) { break; } /* Getting here means there's more to process. */ continue; } /* Getting here means there isn't enough any data left to send to the client which means we need to wait for more. */ if (WaitForSingleObject((HANDLE)pDevice->winmm.hEventCapture, INFINITE) != WAIT_OBJECT_0) { result = MA_ERROR; break; } /* Something happened. If the next buffer has been marked as done we need to reset a bit of state. */ if ((pWAVEHDR[pDevice->winmm.iNextHeaderCapture].dwFlags & MA_WHDR_DONE) != 0) { pWAVEHDR[pDevice->winmm.iNextHeaderCapture].dwUser = 0; /* 0 = unlocked (make it available for reading). */ pDevice->winmm.headerFramesConsumedCapture = 0; } /* If the device has been stopped we need to break. */ if (ma_device_get_state(pDevice) != ma_device_state_started) { break; } } if (pFramesRead != NULL) { *pFramesRead = totalFramesRead; } return result; } static ma_result ma_context_uninit__winmm(ma_context* pContext) { MA_ASSERT(pContext != NULL); MA_ASSERT(pContext->backend == ma_backend_winmm); ma_dlclose(ma_context_get_log(pContext), pContext->winmm.hWinMM); return MA_SUCCESS; } static ma_result ma_context_init__winmm(ma_context* pContext, const ma_context_config* pConfig, ma_backend_callbacks* pCallbacks) { MA_ASSERT(pContext != NULL); (void)pConfig; pContext->winmm.hWinMM = ma_dlopen(ma_context_get_log(pContext), "winmm.dll"); if (pContext->winmm.hWinMM == NULL) { return MA_NO_BACKEND; } pContext->winmm.waveOutGetNumDevs = ma_dlsym(ma_context_get_log(pContext), pContext->winmm.hWinMM, "waveOutGetNumDevs"); pContext->winmm.waveOutGetDevCapsA = ma_dlsym(ma_context_get_log(pContext), pContext->winmm.hWinMM, "waveOutGetDevCapsA"); pContext->winmm.waveOutOpen = ma_dlsym(ma_context_get_log(pContext), pContext->winmm.hWinMM, "waveOutOpen"); pContext->winmm.waveOutClose = ma_dlsym(ma_context_get_log(pContext), pContext->winmm.hWinMM, "waveOutClose"); pContext->winmm.waveOutPrepareHeader = ma_dlsym(ma_context_get_log(pContext), pContext->winmm.hWinMM, "waveOutPrepareHeader"); pContext->winmm.waveOutUnprepareHeader = ma_dlsym(ma_context_get_log(pContext), pContext->winmm.hWinMM, "waveOutUnprepareHeader"); pContext->winmm.waveOutWrite = ma_dlsym(ma_context_get_log(pContext), pContext->winmm.hWinMM, "waveOutWrite"); pContext->winmm.waveOutReset = ma_dlsym(ma_context_get_log(pContext), pContext->winmm.hWinMM, "waveOutReset"); pContext->winmm.waveInGetNumDevs = ma_dlsym(ma_context_get_log(pContext), pContext->winmm.hWinMM, "waveInGetNumDevs"); pContext->winmm.waveInGetDevCapsA = ma_dlsym(ma_context_get_log(pContext), pContext->winmm.hWinMM, "waveInGetDevCapsA"); pContext->winmm.waveInOpen = ma_dlsym(ma_context_get_log(pContext), pContext->winmm.hWinMM, "waveInOpen"); pContext->winmm.waveInClose = ma_dlsym(ma_context_get_log(pContext), pContext->winmm.hWinMM, "waveInClose"); pContext->winmm.waveInPrepareHeader = ma_dlsym(ma_context_get_log(pContext), pContext->winmm.hWinMM, "waveInPrepareHeader"); pContext->winmm.waveInUnprepareHeader = ma_dlsym(ma_context_get_log(pContext), pContext->winmm.hWinMM, "waveInUnprepareHeader"); pContext->winmm.waveInAddBuffer = ma_dlsym(ma_context_get_log(pContext), pContext->winmm.hWinMM, "waveInAddBuffer"); pContext->winmm.waveInStart = ma_dlsym(ma_context_get_log(pContext), pContext->winmm.hWinMM, "waveInStart"); pContext->winmm.waveInReset = ma_dlsym(ma_context_get_log(pContext), pContext->winmm.hWinMM, "waveInReset"); pCallbacks->onContextInit = ma_context_init__winmm; pCallbacks->onContextUninit = ma_context_uninit__winmm; pCallbacks->onContextEnumerateDevices = ma_context_enumerate_devices__winmm; pCallbacks->onContextGetDeviceInfo = ma_context_get_device_info__winmm; pCallbacks->onDeviceInit = ma_device_init__winmm; pCallbacks->onDeviceUninit = ma_device_uninit__winmm; pCallbacks->onDeviceStart = ma_device_start__winmm; pCallbacks->onDeviceStop = ma_device_stop__winmm; pCallbacks->onDeviceRead = ma_device_read__winmm; pCallbacks->onDeviceWrite = ma_device_write__winmm; pCallbacks->onDeviceDataLoop = NULL; /* This is a blocking read-write API, so this can be NULL since miniaudio will manage the audio thread for us. */ return MA_SUCCESS; } #endif /****************************************************************************** ALSA Backend ******************************************************************************/ #ifdef MA_HAS_ALSA #include /* poll(), struct pollfd */ #include /* eventfd() */ #ifdef MA_NO_RUNTIME_LINKING /* asoundlib.h marks some functions with "inline" which isn't always supported. Need to emulate it. */ #if !defined(__cplusplus) #if defined(__STRICT_ANSI__) #if !defined(inline) #define inline __inline__ __attribute__((always_inline)) #define MA_INLINE_DEFINED #endif #endif #endif #include #if defined(MA_INLINE_DEFINED) #undef inline #undef MA_INLINE_DEFINED #endif typedef snd_pcm_uframes_t ma_snd_pcm_uframes_t; typedef snd_pcm_sframes_t ma_snd_pcm_sframes_t; typedef snd_pcm_stream_t ma_snd_pcm_stream_t; typedef snd_pcm_format_t ma_snd_pcm_format_t; typedef snd_pcm_access_t ma_snd_pcm_access_t; typedef snd_pcm_t ma_snd_pcm_t; typedef snd_pcm_hw_params_t ma_snd_pcm_hw_params_t; typedef snd_pcm_sw_params_t ma_snd_pcm_sw_params_t; typedef snd_pcm_format_mask_t ma_snd_pcm_format_mask_t; typedef snd_pcm_info_t ma_snd_pcm_info_t; typedef snd_pcm_channel_area_t ma_snd_pcm_channel_area_t; typedef snd_pcm_chmap_t ma_snd_pcm_chmap_t; typedef snd_pcm_state_t ma_snd_pcm_state_t; /* snd_pcm_stream_t */ #define MA_SND_PCM_STREAM_PLAYBACK SND_PCM_STREAM_PLAYBACK #define MA_SND_PCM_STREAM_CAPTURE SND_PCM_STREAM_CAPTURE /* snd_pcm_format_t */ #define MA_SND_PCM_FORMAT_UNKNOWN SND_PCM_FORMAT_UNKNOWN #define MA_SND_PCM_FORMAT_U8 SND_PCM_FORMAT_U8 #define MA_SND_PCM_FORMAT_S16_LE SND_PCM_FORMAT_S16_LE #define MA_SND_PCM_FORMAT_S16_BE SND_PCM_FORMAT_S16_BE #define MA_SND_PCM_FORMAT_S24_LE SND_PCM_FORMAT_S24_LE #define MA_SND_PCM_FORMAT_S24_BE SND_PCM_FORMAT_S24_BE #define MA_SND_PCM_FORMAT_S32_LE SND_PCM_FORMAT_S32_LE #define MA_SND_PCM_FORMAT_S32_BE SND_PCM_FORMAT_S32_BE #define MA_SND_PCM_FORMAT_FLOAT_LE SND_PCM_FORMAT_FLOAT_LE #define MA_SND_PCM_FORMAT_FLOAT_BE SND_PCM_FORMAT_FLOAT_BE #define MA_SND_PCM_FORMAT_FLOAT64_LE SND_PCM_FORMAT_FLOAT64_LE #define MA_SND_PCM_FORMAT_FLOAT64_BE SND_PCM_FORMAT_FLOAT64_BE #define MA_SND_PCM_FORMAT_MU_LAW SND_PCM_FORMAT_MU_LAW #define MA_SND_PCM_FORMAT_A_LAW SND_PCM_FORMAT_A_LAW #define MA_SND_PCM_FORMAT_S24_3LE SND_PCM_FORMAT_S24_3LE #define MA_SND_PCM_FORMAT_S24_3BE SND_PCM_FORMAT_S24_3BE /* ma_snd_pcm_access_t */ #define MA_SND_PCM_ACCESS_MMAP_INTERLEAVED SND_PCM_ACCESS_MMAP_INTERLEAVED #define MA_SND_PCM_ACCESS_MMAP_NONINTERLEAVED SND_PCM_ACCESS_MMAP_NONINTERLEAVED #define MA_SND_PCM_ACCESS_MMAP_COMPLEX SND_PCM_ACCESS_MMAP_COMPLEX #define MA_SND_PCM_ACCESS_RW_INTERLEAVED SND_PCM_ACCESS_RW_INTERLEAVED #define MA_SND_PCM_ACCESS_RW_NONINTERLEAVED SND_PCM_ACCESS_RW_NONINTERLEAVED /* Channel positions. */ #define MA_SND_CHMAP_UNKNOWN SND_CHMAP_UNKNOWN #define MA_SND_CHMAP_NA SND_CHMAP_NA #define MA_SND_CHMAP_MONO SND_CHMAP_MONO #define MA_SND_CHMAP_FL SND_CHMAP_FL #define MA_SND_CHMAP_FR SND_CHMAP_FR #define MA_SND_CHMAP_RL SND_CHMAP_RL #define MA_SND_CHMAP_RR SND_CHMAP_RR #define MA_SND_CHMAP_FC SND_CHMAP_FC #define MA_SND_CHMAP_LFE SND_CHMAP_LFE #define MA_SND_CHMAP_SL SND_CHMAP_SL #define MA_SND_CHMAP_SR SND_CHMAP_SR #define MA_SND_CHMAP_RC SND_CHMAP_RC #define MA_SND_CHMAP_FLC SND_CHMAP_FLC #define MA_SND_CHMAP_FRC SND_CHMAP_FRC #define MA_SND_CHMAP_RLC SND_CHMAP_RLC #define MA_SND_CHMAP_RRC SND_CHMAP_RRC #define MA_SND_CHMAP_FLW SND_CHMAP_FLW #define MA_SND_CHMAP_FRW SND_CHMAP_FRW #define MA_SND_CHMAP_FLH SND_CHMAP_FLH #define MA_SND_CHMAP_FCH SND_CHMAP_FCH #define MA_SND_CHMAP_FRH SND_CHMAP_FRH #define MA_SND_CHMAP_TC SND_CHMAP_TC #define MA_SND_CHMAP_TFL SND_CHMAP_TFL #define MA_SND_CHMAP_TFR SND_CHMAP_TFR #define MA_SND_CHMAP_TFC SND_CHMAP_TFC #define MA_SND_CHMAP_TRL SND_CHMAP_TRL #define MA_SND_CHMAP_TRR SND_CHMAP_TRR #define MA_SND_CHMAP_TRC SND_CHMAP_TRC #define MA_SND_CHMAP_TFLC SND_CHMAP_TFLC #define MA_SND_CHMAP_TFRC SND_CHMAP_TFRC #define MA_SND_CHMAP_TSL SND_CHMAP_TSL #define MA_SND_CHMAP_TSR SND_CHMAP_TSR #define MA_SND_CHMAP_LLFE SND_CHMAP_LLFE #define MA_SND_CHMAP_RLFE SND_CHMAP_RLFE #define MA_SND_CHMAP_BC SND_CHMAP_BC #define MA_SND_CHMAP_BLC SND_CHMAP_BLC #define MA_SND_CHMAP_BRC SND_CHMAP_BRC /* Open mode flags. */ #define MA_SND_PCM_NO_AUTO_RESAMPLE SND_PCM_NO_AUTO_RESAMPLE #define MA_SND_PCM_NO_AUTO_CHANNELS SND_PCM_NO_AUTO_CHANNELS #define MA_SND_PCM_NO_AUTO_FORMAT SND_PCM_NO_AUTO_FORMAT #else #include /* For EPIPE, etc. */ typedef unsigned long ma_snd_pcm_uframes_t; typedef long ma_snd_pcm_sframes_t; typedef int ma_snd_pcm_stream_t; typedef int ma_snd_pcm_format_t; typedef int ma_snd_pcm_access_t; typedef int ma_snd_pcm_state_t; typedef struct ma_snd_pcm_t ma_snd_pcm_t; typedef struct ma_snd_pcm_hw_params_t ma_snd_pcm_hw_params_t; typedef struct ma_snd_pcm_sw_params_t ma_snd_pcm_sw_params_t; typedef struct ma_snd_pcm_format_mask_t ma_snd_pcm_format_mask_t; typedef struct ma_snd_pcm_info_t ma_snd_pcm_info_t; typedef struct { void* addr; unsigned int first; unsigned int step; } ma_snd_pcm_channel_area_t; typedef struct { unsigned int channels; unsigned int pos[1]; } ma_snd_pcm_chmap_t; /* snd_pcm_state_t */ #define MA_SND_PCM_STATE_OPEN 0 #define MA_SND_PCM_STATE_SETUP 1 #define MA_SND_PCM_STATE_PREPARED 2 #define MA_SND_PCM_STATE_RUNNING 3 #define MA_SND_PCM_STATE_XRUN 4 #define MA_SND_PCM_STATE_DRAINING 5 #define MA_SND_PCM_STATE_PAUSED 6 #define MA_SND_PCM_STATE_SUSPENDED 7 #define MA_SND_PCM_STATE_DISCONNECTED 8 /* snd_pcm_stream_t */ #define MA_SND_PCM_STREAM_PLAYBACK 0 #define MA_SND_PCM_STREAM_CAPTURE 1 /* snd_pcm_format_t */ #define MA_SND_PCM_FORMAT_UNKNOWN -1 #define MA_SND_PCM_FORMAT_U8 1 #define MA_SND_PCM_FORMAT_S16_LE 2 #define MA_SND_PCM_FORMAT_S16_BE 3 #define MA_SND_PCM_FORMAT_S24_LE 6 #define MA_SND_PCM_FORMAT_S24_BE 7 #define MA_SND_PCM_FORMAT_S32_LE 10 #define MA_SND_PCM_FORMAT_S32_BE 11 #define MA_SND_PCM_FORMAT_FLOAT_LE 14 #define MA_SND_PCM_FORMAT_FLOAT_BE 15 #define MA_SND_PCM_FORMAT_FLOAT64_LE 16 #define MA_SND_PCM_FORMAT_FLOAT64_BE 17 #define MA_SND_PCM_FORMAT_MU_LAW 20 #define MA_SND_PCM_FORMAT_A_LAW 21 #define MA_SND_PCM_FORMAT_S24_3LE 32 #define MA_SND_PCM_FORMAT_S24_3BE 33 /* snd_pcm_access_t */ #define MA_SND_PCM_ACCESS_MMAP_INTERLEAVED 0 #define MA_SND_PCM_ACCESS_MMAP_NONINTERLEAVED 1 #define MA_SND_PCM_ACCESS_MMAP_COMPLEX 2 #define MA_SND_PCM_ACCESS_RW_INTERLEAVED 3 #define MA_SND_PCM_ACCESS_RW_NONINTERLEAVED 4 /* Channel positions. */ #define MA_SND_CHMAP_UNKNOWN 0 #define MA_SND_CHMAP_NA 1 #define MA_SND_CHMAP_MONO 2 #define MA_SND_CHMAP_FL 3 #define MA_SND_CHMAP_FR 4 #define MA_SND_CHMAP_RL 5 #define MA_SND_CHMAP_RR 6 #define MA_SND_CHMAP_FC 7 #define MA_SND_CHMAP_LFE 8 #define MA_SND_CHMAP_SL 9 #define MA_SND_CHMAP_SR 10 #define MA_SND_CHMAP_RC 11 #define MA_SND_CHMAP_FLC 12 #define MA_SND_CHMAP_FRC 13 #define MA_SND_CHMAP_RLC 14 #define MA_SND_CHMAP_RRC 15 #define MA_SND_CHMAP_FLW 16 #define MA_SND_CHMAP_FRW 17 #define MA_SND_CHMAP_FLH 18 #define MA_SND_CHMAP_FCH 19 #define MA_SND_CHMAP_FRH 20 #define MA_SND_CHMAP_TC 21 #define MA_SND_CHMAP_TFL 22 #define MA_SND_CHMAP_TFR 23 #define MA_SND_CHMAP_TFC 24 #define MA_SND_CHMAP_TRL 25 #define MA_SND_CHMAP_TRR 26 #define MA_SND_CHMAP_TRC 27 #define MA_SND_CHMAP_TFLC 28 #define MA_SND_CHMAP_TFRC 29 #define MA_SND_CHMAP_TSL 30 #define MA_SND_CHMAP_TSR 31 #define MA_SND_CHMAP_LLFE 32 #define MA_SND_CHMAP_RLFE 33 #define MA_SND_CHMAP_BC 34 #define MA_SND_CHMAP_BLC 35 #define MA_SND_CHMAP_BRC 36 /* Open mode flags. */ #define MA_SND_PCM_NO_AUTO_RESAMPLE 0x00010000 #define MA_SND_PCM_NO_AUTO_CHANNELS 0x00020000 #define MA_SND_PCM_NO_AUTO_FORMAT 0x00040000 #endif typedef int (* ma_snd_pcm_open_proc) (ma_snd_pcm_t **pcm, const char *name, ma_snd_pcm_stream_t stream, int mode); typedef int (* ma_snd_pcm_close_proc) (ma_snd_pcm_t *pcm); typedef size_t (* ma_snd_pcm_hw_params_sizeof_proc) (void); typedef int (* ma_snd_pcm_hw_params_any_proc) (ma_snd_pcm_t *pcm, ma_snd_pcm_hw_params_t *params); typedef int (* ma_snd_pcm_hw_params_set_format_proc) (ma_snd_pcm_t *pcm, ma_snd_pcm_hw_params_t *params, ma_snd_pcm_format_t val); typedef int (* ma_snd_pcm_hw_params_set_format_first_proc) (ma_snd_pcm_t *pcm, ma_snd_pcm_hw_params_t *params, ma_snd_pcm_format_t *format); typedef void (* ma_snd_pcm_hw_params_get_format_mask_proc) (ma_snd_pcm_hw_params_t *params, ma_snd_pcm_format_mask_t *mask); typedef int (* ma_snd_pcm_hw_params_set_channels_proc) (ma_snd_pcm_t *pcm, ma_snd_pcm_hw_params_t *params, unsigned int val); typedef int (* ma_snd_pcm_hw_params_set_channels_near_proc) (ma_snd_pcm_t *pcm, ma_snd_pcm_hw_params_t *params, unsigned int *val); typedef int (* ma_snd_pcm_hw_params_set_channels_minmax_proc) (ma_snd_pcm_t *pcm, ma_snd_pcm_hw_params_t *params, unsigned int *minimum, unsigned int *maximum); typedef int (* ma_snd_pcm_hw_params_set_rate_resample_proc) (ma_snd_pcm_t *pcm, ma_snd_pcm_hw_params_t *params, unsigned int val); typedef int (* ma_snd_pcm_hw_params_set_rate_proc) (ma_snd_pcm_t *pcm, ma_snd_pcm_hw_params_t *params, unsigned int val, int dir); typedef int (* ma_snd_pcm_hw_params_set_rate_near_proc) (ma_snd_pcm_t *pcm, ma_snd_pcm_hw_params_t *params, unsigned int *val, int *dir); typedef int (* ma_snd_pcm_hw_params_set_buffer_size_near_proc)(ma_snd_pcm_t *pcm, ma_snd_pcm_hw_params_t *params, ma_snd_pcm_uframes_t *val); typedef int (* ma_snd_pcm_hw_params_set_periods_near_proc) (ma_snd_pcm_t *pcm, ma_snd_pcm_hw_params_t *params, unsigned int *val, int *dir); typedef int (* ma_snd_pcm_hw_params_set_access_proc) (ma_snd_pcm_t *pcm, ma_snd_pcm_hw_params_t *params, ma_snd_pcm_access_t _access); typedef int (* ma_snd_pcm_hw_params_get_format_proc) (const ma_snd_pcm_hw_params_t *params, ma_snd_pcm_format_t *format); typedef int (* ma_snd_pcm_hw_params_get_channels_proc) (const ma_snd_pcm_hw_params_t *params, unsigned int *val); typedef int (* ma_snd_pcm_hw_params_get_channels_min_proc) (const ma_snd_pcm_hw_params_t *params, unsigned int *val); typedef int (* ma_snd_pcm_hw_params_get_channels_max_proc) (const ma_snd_pcm_hw_params_t *params, unsigned int *val); typedef int (* ma_snd_pcm_hw_params_get_rate_proc) (const ma_snd_pcm_hw_params_t *params, unsigned int *rate, int *dir); typedef int (* ma_snd_pcm_hw_params_get_rate_min_proc) (const ma_snd_pcm_hw_params_t *params, unsigned int *rate, int *dir); typedef int (* ma_snd_pcm_hw_params_get_rate_max_proc) (const ma_snd_pcm_hw_params_t *params, unsigned int *rate, int *dir); typedef int (* ma_snd_pcm_hw_params_get_buffer_size_proc) (const ma_snd_pcm_hw_params_t *params, ma_snd_pcm_uframes_t *val); typedef int (* ma_snd_pcm_hw_params_get_periods_proc) (const ma_snd_pcm_hw_params_t *params, unsigned int *val, int *dir); typedef int (* ma_snd_pcm_hw_params_get_access_proc) (const ma_snd_pcm_hw_params_t *params, ma_snd_pcm_access_t *_access); typedef int (* ma_snd_pcm_hw_params_test_format_proc) (ma_snd_pcm_t *pcm, ma_snd_pcm_hw_params_t *params, ma_snd_pcm_format_t val); typedef int (* ma_snd_pcm_hw_params_test_channels_proc) (ma_snd_pcm_t *pcm, ma_snd_pcm_hw_params_t *params, unsigned int val); typedef int (* ma_snd_pcm_hw_params_test_rate_proc) (ma_snd_pcm_t *pcm, ma_snd_pcm_hw_params_t *params, unsigned int val, int dir); typedef int (* ma_snd_pcm_hw_params_proc) (ma_snd_pcm_t *pcm, ma_snd_pcm_hw_params_t *params); typedef size_t (* ma_snd_pcm_sw_params_sizeof_proc) (void); typedef int (* ma_snd_pcm_sw_params_current_proc) (ma_snd_pcm_t *pcm, ma_snd_pcm_sw_params_t *params); typedef int (* ma_snd_pcm_sw_params_get_boundary_proc) (const ma_snd_pcm_sw_params_t *params, ma_snd_pcm_uframes_t* val); typedef int (* ma_snd_pcm_sw_params_set_avail_min_proc) (ma_snd_pcm_t *pcm, ma_snd_pcm_sw_params_t *params, ma_snd_pcm_uframes_t val); typedef int (* ma_snd_pcm_sw_params_set_start_threshold_proc) (ma_snd_pcm_t *pcm, ma_snd_pcm_sw_params_t *params, ma_snd_pcm_uframes_t val); typedef int (* ma_snd_pcm_sw_params_set_stop_threshold_proc) (ma_snd_pcm_t *pcm, ma_snd_pcm_sw_params_t *params, ma_snd_pcm_uframes_t val); typedef int (* ma_snd_pcm_sw_params_proc) (ma_snd_pcm_t *pcm, ma_snd_pcm_sw_params_t *params); typedef size_t (* ma_snd_pcm_format_mask_sizeof_proc) (void); typedef int (* ma_snd_pcm_format_mask_test_proc) (const ma_snd_pcm_format_mask_t *mask, ma_snd_pcm_format_t val); typedef ma_snd_pcm_chmap_t * (* ma_snd_pcm_get_chmap_proc) (ma_snd_pcm_t *pcm); typedef ma_snd_pcm_state_t (* ma_snd_pcm_state_proc) (ma_snd_pcm_t *pcm); typedef int (* ma_snd_pcm_prepare_proc) (ma_snd_pcm_t *pcm); typedef int (* ma_snd_pcm_start_proc) (ma_snd_pcm_t *pcm); typedef int (* ma_snd_pcm_drop_proc) (ma_snd_pcm_t *pcm); typedef int (* ma_snd_pcm_drain_proc) (ma_snd_pcm_t *pcm); typedef int (* ma_snd_pcm_reset_proc) (ma_snd_pcm_t *pcm); typedef int (* ma_snd_device_name_hint_proc) (int card, const char *iface, void ***hints); typedef char * (* ma_snd_device_name_get_hint_proc) (const void *hint, const char *id); typedef int (* ma_snd_card_get_index_proc) (const char *name); typedef int (* ma_snd_device_name_free_hint_proc) (void **hints); typedef int (* ma_snd_pcm_mmap_begin_proc) (ma_snd_pcm_t *pcm, const ma_snd_pcm_channel_area_t **areas, ma_snd_pcm_uframes_t *offset, ma_snd_pcm_uframes_t *frames); typedef ma_snd_pcm_sframes_t (* ma_snd_pcm_mmap_commit_proc) (ma_snd_pcm_t *pcm, ma_snd_pcm_uframes_t offset, ma_snd_pcm_uframes_t frames); typedef int (* ma_snd_pcm_recover_proc) (ma_snd_pcm_t *pcm, int err, int silent); typedef ma_snd_pcm_sframes_t (* ma_snd_pcm_readi_proc) (ma_snd_pcm_t *pcm, void *buffer, ma_snd_pcm_uframes_t size); typedef ma_snd_pcm_sframes_t (* ma_snd_pcm_writei_proc) (ma_snd_pcm_t *pcm, const void *buffer, ma_snd_pcm_uframes_t size); typedef ma_snd_pcm_sframes_t (* ma_snd_pcm_avail_proc) (ma_snd_pcm_t *pcm); typedef ma_snd_pcm_sframes_t (* ma_snd_pcm_avail_update_proc) (ma_snd_pcm_t *pcm); typedef int (* ma_snd_pcm_wait_proc) (ma_snd_pcm_t *pcm, int timeout); typedef int (* ma_snd_pcm_nonblock_proc) (ma_snd_pcm_t *pcm, int nonblock); typedef int (* ma_snd_pcm_info_proc) (ma_snd_pcm_t *pcm, ma_snd_pcm_info_t* info); typedef size_t (* ma_snd_pcm_info_sizeof_proc) (void); typedef const char* (* ma_snd_pcm_info_get_name_proc) (const ma_snd_pcm_info_t* info); typedef int (* ma_snd_pcm_poll_descriptors_proc) (ma_snd_pcm_t *pcm, struct pollfd *pfds, unsigned int space); typedef int (* ma_snd_pcm_poll_descriptors_count_proc) (ma_snd_pcm_t *pcm); typedef int (* ma_snd_pcm_poll_descriptors_revents_proc) (ma_snd_pcm_t *pcm, struct pollfd *pfds, unsigned int nfds, unsigned short *revents); typedef int (* ma_snd_config_update_free_global_proc) (void); /* This array specifies each of the common devices that can be used for both playback and capture. */ static const char* g_maCommonDeviceNamesALSA[] = { "default", "null", "pulse", "jack" }; /* This array allows us to blacklist specific playback devices. */ static const char* g_maBlacklistedPlaybackDeviceNamesALSA[] = { "" }; /* This array allows us to blacklist specific capture devices. */ static const char* g_maBlacklistedCaptureDeviceNamesALSA[] = { "" }; static ma_snd_pcm_format_t ma_convert_ma_format_to_alsa_format(ma_format format) { ma_snd_pcm_format_t ALSAFormats[] = { MA_SND_PCM_FORMAT_UNKNOWN, /* ma_format_unknown */ MA_SND_PCM_FORMAT_U8, /* ma_format_u8 */ MA_SND_PCM_FORMAT_S16_LE, /* ma_format_s16 */ MA_SND_PCM_FORMAT_S24_3LE, /* ma_format_s24 */ MA_SND_PCM_FORMAT_S32_LE, /* ma_format_s32 */ MA_SND_PCM_FORMAT_FLOAT_LE /* ma_format_f32 */ }; if (ma_is_big_endian()) { ALSAFormats[0] = MA_SND_PCM_FORMAT_UNKNOWN; ALSAFormats[1] = MA_SND_PCM_FORMAT_U8; ALSAFormats[2] = MA_SND_PCM_FORMAT_S16_BE; ALSAFormats[3] = MA_SND_PCM_FORMAT_S24_3BE; ALSAFormats[4] = MA_SND_PCM_FORMAT_S32_BE; ALSAFormats[5] = MA_SND_PCM_FORMAT_FLOAT_BE; } return ALSAFormats[format]; } static ma_format ma_format_from_alsa(ma_snd_pcm_format_t formatALSA) { if (ma_is_little_endian()) { switch (formatALSA) { case MA_SND_PCM_FORMAT_S16_LE: return ma_format_s16; case MA_SND_PCM_FORMAT_S24_3LE: return ma_format_s24; case MA_SND_PCM_FORMAT_S32_LE: return ma_format_s32; case MA_SND_PCM_FORMAT_FLOAT_LE: return ma_format_f32; default: break; } } else { switch (formatALSA) { case MA_SND_PCM_FORMAT_S16_BE: return ma_format_s16; case MA_SND_PCM_FORMAT_S24_3BE: return ma_format_s24; case MA_SND_PCM_FORMAT_S32_BE: return ma_format_s32; case MA_SND_PCM_FORMAT_FLOAT_BE: return ma_format_f32; default: break; } } /* Endian agnostic. */ switch (formatALSA) { case MA_SND_PCM_FORMAT_U8: return ma_format_u8; default: return ma_format_unknown; } } static ma_channel ma_convert_alsa_channel_position_to_ma_channel(unsigned int alsaChannelPos) { switch (alsaChannelPos) { case MA_SND_CHMAP_MONO: return MA_CHANNEL_MONO; case MA_SND_CHMAP_FL: return MA_CHANNEL_FRONT_LEFT; case MA_SND_CHMAP_FR: return MA_CHANNEL_FRONT_RIGHT; case MA_SND_CHMAP_RL: return MA_CHANNEL_BACK_LEFT; case MA_SND_CHMAP_RR: return MA_CHANNEL_BACK_RIGHT; case MA_SND_CHMAP_FC: return MA_CHANNEL_FRONT_CENTER; case MA_SND_CHMAP_LFE: return MA_CHANNEL_LFE; case MA_SND_CHMAP_SL: return MA_CHANNEL_SIDE_LEFT; case MA_SND_CHMAP_SR: return MA_CHANNEL_SIDE_RIGHT; case MA_SND_CHMAP_RC: return MA_CHANNEL_BACK_CENTER; case MA_SND_CHMAP_FLC: return MA_CHANNEL_FRONT_LEFT_CENTER; case MA_SND_CHMAP_FRC: return MA_CHANNEL_FRONT_RIGHT_CENTER; case MA_SND_CHMAP_RLC: return 0; case MA_SND_CHMAP_RRC: return 0; case MA_SND_CHMAP_FLW: return 0; case MA_SND_CHMAP_FRW: return 0; case MA_SND_CHMAP_FLH: return 0; case MA_SND_CHMAP_FCH: return 0; case MA_SND_CHMAP_FRH: return 0; case MA_SND_CHMAP_TC: return MA_CHANNEL_TOP_CENTER; case MA_SND_CHMAP_TFL: return MA_CHANNEL_TOP_FRONT_LEFT; case MA_SND_CHMAP_TFR: return MA_CHANNEL_TOP_FRONT_RIGHT; case MA_SND_CHMAP_TFC: return MA_CHANNEL_TOP_FRONT_CENTER; case MA_SND_CHMAP_TRL: return MA_CHANNEL_TOP_BACK_LEFT; case MA_SND_CHMAP_TRR: return MA_CHANNEL_TOP_BACK_RIGHT; case MA_SND_CHMAP_TRC: return MA_CHANNEL_TOP_BACK_CENTER; default: break; } return 0; } static ma_bool32 ma_is_common_device_name__alsa(const char* name) { size_t iName; for (iName = 0; iName < ma_countof(g_maCommonDeviceNamesALSA); ++iName) { if (ma_strcmp(name, g_maCommonDeviceNamesALSA[iName]) == 0) { return MA_TRUE; } } return MA_FALSE; } static ma_bool32 ma_is_playback_device_blacklisted__alsa(const char* name) { size_t iName; for (iName = 0; iName < ma_countof(g_maBlacklistedPlaybackDeviceNamesALSA); ++iName) { if (ma_strcmp(name, g_maBlacklistedPlaybackDeviceNamesALSA[iName]) == 0) { return MA_TRUE; } } return MA_FALSE; } static ma_bool32 ma_is_capture_device_blacklisted__alsa(const char* name) { size_t iName; for (iName = 0; iName < ma_countof(g_maBlacklistedCaptureDeviceNamesALSA); ++iName) { if (ma_strcmp(name, g_maBlacklistedCaptureDeviceNamesALSA[iName]) == 0) { return MA_TRUE; } } return MA_FALSE; } static ma_bool32 ma_is_device_blacklisted__alsa(ma_device_type deviceType, const char* name) { if (deviceType == ma_device_type_playback) { return ma_is_playback_device_blacklisted__alsa(name); } else { return ma_is_capture_device_blacklisted__alsa(name); } } static const char* ma_find_char(const char* str, char c, int* index) { int i = 0; for (;;) { if (str[i] == '\0') { if (index) *index = -1; return NULL; } if (str[i] == c) { if (index) *index = i; return str + i; } i += 1; } /* Should never get here, but treat it as though the character was not found to make me feel better inside. */ if (index) *index = -1; return NULL; } static ma_bool32 ma_is_device_name_in_hw_format__alsa(const char* hwid) { /* This function is just checking whether or not hwid is in "hw:%d,%d" format. */ int commaPos; const char* dev; int i; if (hwid == NULL) { return MA_FALSE; } if (hwid[0] != 'h' || hwid[1] != 'w' || hwid[2] != ':') { return MA_FALSE; } hwid += 3; dev = ma_find_char(hwid, ',', &commaPos); if (dev == NULL) { return MA_FALSE; } else { dev += 1; /* Skip past the ",". */ } /* Check if the part between the ":" and the "," contains only numbers. If not, return false. */ for (i = 0; i < commaPos; ++i) { if (hwid[i] < '0' || hwid[i] > '9') { return MA_FALSE; } } /* Check if everything after the "," is numeric. If not, return false. */ i = 0; while (dev[i] != '\0') { if (dev[i] < '0' || dev[i] > '9') { return MA_FALSE; } i += 1; } return MA_TRUE; } static int ma_convert_device_name_to_hw_format__alsa(ma_context* pContext, char* dst, size_t dstSize, const char* src) /* Returns 0 on success, non-0 on error. */ { /* src should look something like this: "hw:CARD=I82801AAICH,DEV=0" */ int colonPos; int commaPos; char card[256]; const char* dev; int cardIndex; if (dst == NULL) { return -1; } if (dstSize < 7) { return -1; /* Absolute minimum size of the output buffer is 7 bytes. */ } *dst = '\0'; /* Safety. */ if (src == NULL) { return -1; } /* If the input name is already in "hw:%d,%d" format, just return that verbatim. */ if (ma_is_device_name_in_hw_format__alsa(src)) { return ma_strcpy_s(dst, dstSize, src); } src = ma_find_char(src, ':', &colonPos); if (src == NULL) { return -1; /* Couldn't find a colon */ } dev = ma_find_char(src, ',', &commaPos); if (dev == NULL) { dev = "0"; ma_strncpy_s(card, sizeof(card), src+6, (size_t)-1); /* +6 = ":CARD=" */ } else { dev = dev + 5; /* +5 = ",DEV=" */ ma_strncpy_s(card, sizeof(card), src+6, commaPos-6); /* +6 = ":CARD=" */ } cardIndex = ((ma_snd_card_get_index_proc)pContext->alsa.snd_card_get_index)(card); if (cardIndex < 0) { return -2; /* Failed to retrieve the card index. */ } /* Construction. */ dst[0] = 'h'; dst[1] = 'w'; dst[2] = ':'; if (ma_itoa_s(cardIndex, dst+3, dstSize-3, 10) != 0) { return -3; } if (ma_strcat_s(dst, dstSize, ",") != 0) { return -3; } if (ma_strcat_s(dst, dstSize, dev) != 0) { return -3; } return 0; } static ma_bool32 ma_does_id_exist_in_list__alsa(ma_device_id* pUniqueIDs, ma_uint32 count, const char* pHWID) { ma_uint32 i; MA_ASSERT(pHWID != NULL); for (i = 0; i < count; ++i) { if (ma_strcmp(pUniqueIDs[i].alsa, pHWID) == 0) { return MA_TRUE; } } return MA_FALSE; } static ma_result ma_context_open_pcm__alsa(ma_context* pContext, ma_share_mode shareMode, ma_device_type deviceType, const ma_device_id* pDeviceID, int openMode, ma_snd_pcm_t** ppPCM) { ma_snd_pcm_t* pPCM; ma_snd_pcm_stream_t stream; MA_ASSERT(pContext != NULL); MA_ASSERT(ppPCM != NULL); *ppPCM = NULL; pPCM = NULL; stream = (deviceType == ma_device_type_playback) ? MA_SND_PCM_STREAM_PLAYBACK : MA_SND_PCM_STREAM_CAPTURE; if (pDeviceID == NULL) { ma_bool32 isDeviceOpen; size_t i; /* We're opening the default device. I don't know if trying anything other than "default" is necessary, but it makes me feel better to try as hard as we can get to get _something_ working. */ const char* defaultDeviceNames[] = { "default", NULL, NULL, NULL, NULL, NULL, NULL }; if (shareMode == ma_share_mode_exclusive) { defaultDeviceNames[1] = "hw"; defaultDeviceNames[2] = "hw:0"; defaultDeviceNames[3] = "hw:0,0"; } else { if (deviceType == ma_device_type_playback) { defaultDeviceNames[1] = "dmix"; defaultDeviceNames[2] = "dmix:0"; defaultDeviceNames[3] = "dmix:0,0"; } else { defaultDeviceNames[1] = "dsnoop"; defaultDeviceNames[2] = "dsnoop:0"; defaultDeviceNames[3] = "dsnoop:0,0"; } defaultDeviceNames[4] = "hw"; defaultDeviceNames[5] = "hw:0"; defaultDeviceNames[6] = "hw:0,0"; } isDeviceOpen = MA_FALSE; for (i = 0; i < ma_countof(defaultDeviceNames); ++i) { if (defaultDeviceNames[i] != NULL && defaultDeviceNames[i][0] != '\0') { if (((ma_snd_pcm_open_proc)pContext->alsa.snd_pcm_open)(&pPCM, defaultDeviceNames[i], stream, openMode) == 0) { isDeviceOpen = MA_TRUE; break; } } } if (!isDeviceOpen) { ma_log_postf(ma_context_get_log(pContext), MA_LOG_LEVEL_ERROR, "[ALSA] snd_pcm_open() failed when trying to open an appropriate default device."); return MA_FAILED_TO_OPEN_BACKEND_DEVICE; } } else { /* We're trying to open a specific device. There's a few things to consider here: miniaudio recongnizes a special format of device id that excludes the "hw", "dmix", etc. prefix. It looks like this: ":0,0", ":0,1", etc. When an ID of this format is specified, it indicates to miniaudio that it can try different combinations of plugins ("hw", "dmix", etc.) until it finds an appropriate one that works. This comes in very handy when trying to open a device in shared mode ("dmix"), vs exclusive mode ("hw"). */ /* May end up needing to make small adjustments to the ID, so make a copy. */ ma_device_id deviceID = *pDeviceID; int resultALSA = -ENODEV; if (deviceID.alsa[0] != ':') { /* The ID is not in ":0,0" format. Use the ID exactly as-is. */ resultALSA = ((ma_snd_pcm_open_proc)pContext->alsa.snd_pcm_open)(&pPCM, deviceID.alsa, stream, openMode); } else { char hwid[256]; /* The ID is in ":0,0" format. Try different plugins depending on the shared mode. */ if (deviceID.alsa[1] == '\0') { deviceID.alsa[0] = '\0'; /* An ID of ":" should be converted to "". */ } if (shareMode == ma_share_mode_shared) { if (deviceType == ma_device_type_playback) { ma_strcpy_s(hwid, sizeof(hwid), "dmix"); } else { ma_strcpy_s(hwid, sizeof(hwid), "dsnoop"); } if (ma_strcat_s(hwid, sizeof(hwid), deviceID.alsa) == 0) { resultALSA = ((ma_snd_pcm_open_proc)pContext->alsa.snd_pcm_open)(&pPCM, hwid, stream, openMode); } } /* If at this point we still don't have an open device it means we're either preferencing exclusive mode or opening with "dmix"/"dsnoop" failed. */ if (resultALSA != 0) { ma_strcpy_s(hwid, sizeof(hwid), "hw"); if (ma_strcat_s(hwid, sizeof(hwid), deviceID.alsa) == 0) { resultALSA = ((ma_snd_pcm_open_proc)pContext->alsa.snd_pcm_open)(&pPCM, hwid, stream, openMode); } } } if (resultALSA < 0) { ma_log_postf(ma_context_get_log(pContext), MA_LOG_LEVEL_ERROR, "[ALSA] snd_pcm_open() failed."); return ma_result_from_errno(-resultALSA); } } *ppPCM = pPCM; return MA_SUCCESS; } static ma_result ma_context_enumerate_devices__alsa(ma_context* pContext, ma_enum_devices_callback_proc callback, void* pUserData) { int resultALSA; ma_bool32 cbResult = MA_TRUE; char** ppDeviceHints; ma_device_id* pUniqueIDs = NULL; ma_uint32 uniqueIDCount = 0; char** ppNextDeviceHint; MA_ASSERT(pContext != NULL); MA_ASSERT(callback != NULL); ma_mutex_lock(&pContext->alsa.internalDeviceEnumLock); resultALSA = ((ma_snd_device_name_hint_proc)pContext->alsa.snd_device_name_hint)(-1, "pcm", (void***)&ppDeviceHints); if (resultALSA < 0) { ma_mutex_unlock(&pContext->alsa.internalDeviceEnumLock); return ma_result_from_errno(-resultALSA); } ppNextDeviceHint = ppDeviceHints; while (*ppNextDeviceHint != NULL) { char* NAME = ((ma_snd_device_name_get_hint_proc)pContext->alsa.snd_device_name_get_hint)(*ppNextDeviceHint, "NAME"); char* DESC = ((ma_snd_device_name_get_hint_proc)pContext->alsa.snd_device_name_get_hint)(*ppNextDeviceHint, "DESC"); char* IOID = ((ma_snd_device_name_get_hint_proc)pContext->alsa.snd_device_name_get_hint)(*ppNextDeviceHint, "IOID"); ma_device_type deviceType = ma_device_type_playback; ma_bool32 stopEnumeration = MA_FALSE; char hwid[sizeof(pUniqueIDs->alsa)]; ma_device_info deviceInfo; if ((IOID == NULL || ma_strcmp(IOID, "Output") == 0)) { deviceType = ma_device_type_playback; } if ((IOID != NULL && ma_strcmp(IOID, "Input" ) == 0)) { deviceType = ma_device_type_capture; } if (NAME != NULL) { if (pContext->alsa.useVerboseDeviceEnumeration) { /* Verbose mode. Use the name exactly as-is. */ ma_strncpy_s(hwid, sizeof(hwid), NAME, (size_t)-1); } else { /* Simplified mode. Use ":%d,%d" format. */ if (ma_convert_device_name_to_hw_format__alsa(pContext, hwid, sizeof(hwid), NAME) == 0) { /* At this point, hwid looks like "hw:0,0". In simplified enumeration mode, we actually want to strip off the plugin name so it looks like ":0,0". The reason for this is that this special format is detected at device initialization time and is used as an indicator to try and use the most appropriate plugin depending on the device type and sharing mode. */ char* dst = hwid; char* src = hwid+2; while ((*dst++ = *src++)); } else { /* Conversion to "hw:%d,%d" failed. Just use the name as-is. */ ma_strncpy_s(hwid, sizeof(hwid), NAME, (size_t)-1); } if (ma_does_id_exist_in_list__alsa(pUniqueIDs, uniqueIDCount, hwid)) { goto next_device; /* The device has already been enumerated. Move on to the next one. */ } else { /* The device has not yet been enumerated. Make sure it's added to our list so that it's not enumerated again. */ size_t newCapacity = sizeof(*pUniqueIDs) * (uniqueIDCount + 1); ma_device_id* pNewUniqueIDs = (ma_device_id*)ma_realloc(pUniqueIDs, newCapacity, &pContext->allocationCallbacks); if (pNewUniqueIDs == NULL) { goto next_device; /* Failed to allocate memory. */ } pUniqueIDs = pNewUniqueIDs; MA_COPY_MEMORY(pUniqueIDs[uniqueIDCount].alsa, hwid, sizeof(hwid)); uniqueIDCount += 1; } } } else { MA_ZERO_MEMORY(hwid, sizeof(hwid)); } MA_ZERO_OBJECT(&deviceInfo); ma_strncpy_s(deviceInfo.id.alsa, sizeof(deviceInfo.id.alsa), hwid, (size_t)-1); /* There's no good way to determine whether or not a device is the default on Linux. We're just going to do something simple and just use the name of "default" as the indicator. */ if (ma_strcmp(deviceInfo.id.alsa, "default") == 0) { deviceInfo.isDefault = MA_TRUE; } /* DESC is the friendly name. We treat this slightly differently depending on whether or not we are using verbose device enumeration. In verbose mode we want to take the entire description so that the end-user can distinguish between the subdevices of each card/dev pair. In simplified mode, however, we only want the first part of the description. The value in DESC seems to be split into two lines, with the first line being the name of the device and the second line being a description of the device. I don't like having the description be across two lines because it makes formatting ugly and annoying. I'm therefore deciding to put it all on a single line with the second line being put into parentheses. In simplified mode I'm just stripping the second line entirely. */ if (DESC != NULL) { int lfPos; const char* line2 = ma_find_char(DESC, '\n', &lfPos); if (line2 != NULL) { line2 += 1; /* Skip past the new-line character. */ if (pContext->alsa.useVerboseDeviceEnumeration) { /* Verbose mode. Put the second line in brackets. */ ma_strncpy_s(deviceInfo.name, sizeof(deviceInfo.name), DESC, lfPos); ma_strcat_s (deviceInfo.name, sizeof(deviceInfo.name), " ("); ma_strcat_s (deviceInfo.name, sizeof(deviceInfo.name), line2); ma_strcat_s (deviceInfo.name, sizeof(deviceInfo.name), ")"); } else { /* Simplified mode. Strip the second line entirely. */ ma_strncpy_s(deviceInfo.name, sizeof(deviceInfo.name), DESC, lfPos); } } else { /* There's no second line. Just copy the whole description. */ ma_strncpy_s(deviceInfo.name, sizeof(deviceInfo.name), DESC, (size_t)-1); } } if (!ma_is_device_blacklisted__alsa(deviceType, NAME)) { cbResult = callback(pContext, deviceType, &deviceInfo, pUserData); } /* Some devices are both playback and capture, but they are only enumerated by ALSA once. We need to fire the callback again for the other device type in this case. We do this for known devices and where the IOID hint is NULL, which means both Input and Output. */ if (cbResult) { if (ma_is_common_device_name__alsa(NAME) || IOID == NULL) { if (deviceType == ma_device_type_playback) { if (!ma_is_capture_device_blacklisted__alsa(NAME)) { cbResult = callback(pContext, ma_device_type_capture, &deviceInfo, pUserData); } } else { if (!ma_is_playback_device_blacklisted__alsa(NAME)) { cbResult = callback(pContext, ma_device_type_playback, &deviceInfo, pUserData); } } } } if (cbResult == MA_FALSE) { stopEnumeration = MA_TRUE; } next_device: free(NAME); free(DESC); free(IOID); ppNextDeviceHint += 1; /* We need to stop enumeration if the callback returned false. */ if (stopEnumeration) { break; } } ma_free(pUniqueIDs, &pContext->allocationCallbacks); ((ma_snd_device_name_free_hint_proc)pContext->alsa.snd_device_name_free_hint)((void**)ppDeviceHints); ma_mutex_unlock(&pContext->alsa.internalDeviceEnumLock); return MA_SUCCESS; } typedef struct { ma_device_type deviceType; const ma_device_id* pDeviceID; ma_share_mode shareMode; ma_device_info* pDeviceInfo; ma_bool32 foundDevice; } ma_context_get_device_info_enum_callback_data__alsa; static ma_bool32 ma_context_get_device_info_enum_callback__alsa(ma_context* pContext, ma_device_type deviceType, const ma_device_info* pDeviceInfo, void* pUserData) { ma_context_get_device_info_enum_callback_data__alsa* pData = (ma_context_get_device_info_enum_callback_data__alsa*)pUserData; MA_ASSERT(pData != NULL); (void)pContext; if (pData->pDeviceID == NULL && ma_strcmp(pDeviceInfo->id.alsa, "default") == 0) { ma_strncpy_s(pData->pDeviceInfo->name, sizeof(pData->pDeviceInfo->name), pDeviceInfo->name, (size_t)-1); pData->foundDevice = MA_TRUE; } else { if (pData->deviceType == deviceType && (pData->pDeviceID != NULL && ma_strcmp(pData->pDeviceID->alsa, pDeviceInfo->id.alsa) == 0)) { ma_strncpy_s(pData->pDeviceInfo->name, sizeof(pData->pDeviceInfo->name), pDeviceInfo->name, (size_t)-1); pData->foundDevice = MA_TRUE; } } /* Keep enumerating until we have found the device. */ return !pData->foundDevice; } static void ma_context_test_rate_and_add_native_data_format__alsa(ma_context* pContext, ma_snd_pcm_t* pPCM, ma_snd_pcm_hw_params_t* pHWParams, ma_format format, ma_uint32 channels, ma_uint32 sampleRate, ma_uint32 flags, ma_device_info* pDeviceInfo) { MA_ASSERT(pPCM != NULL); MA_ASSERT(pHWParams != NULL); MA_ASSERT(pDeviceInfo != NULL); if (pDeviceInfo->nativeDataFormatCount < ma_countof(pDeviceInfo->nativeDataFormats) && ((ma_snd_pcm_hw_params_test_rate_proc)pContext->alsa.snd_pcm_hw_params_test_rate)(pPCM, pHWParams, sampleRate, 0) == 0) { pDeviceInfo->nativeDataFormats[pDeviceInfo->nativeDataFormatCount].format = format; pDeviceInfo->nativeDataFormats[pDeviceInfo->nativeDataFormatCount].channels = channels; pDeviceInfo->nativeDataFormats[pDeviceInfo->nativeDataFormatCount].sampleRate = sampleRate; pDeviceInfo->nativeDataFormats[pDeviceInfo->nativeDataFormatCount].flags = flags; pDeviceInfo->nativeDataFormatCount += 1; } } static void ma_context_iterate_rates_and_add_native_data_format__alsa(ma_context* pContext, ma_snd_pcm_t* pPCM, ma_snd_pcm_hw_params_t* pHWParams, ma_format format, ma_uint32 channels, ma_uint32 flags, ma_device_info* pDeviceInfo) { ma_uint32 iSampleRate; unsigned int minSampleRate; unsigned int maxSampleRate; int sampleRateDir; /* Not used. Just passed into snd_pcm_hw_params_get_rate_min/max(). */ /* There could be a range. */ ((ma_snd_pcm_hw_params_get_rate_min_proc)pContext->alsa.snd_pcm_hw_params_get_rate_min)(pHWParams, &minSampleRate, &sampleRateDir); ((ma_snd_pcm_hw_params_get_rate_max_proc)pContext->alsa.snd_pcm_hw_params_get_rate_max)(pHWParams, &maxSampleRate, &sampleRateDir); /* Make sure our sample rates are clamped to sane values. Stupid devices like "pulse" will reports rates like "1" which is ridiculus. */ minSampleRate = ma_clamp(minSampleRate, (unsigned int)ma_standard_sample_rate_min, (unsigned int)ma_standard_sample_rate_max); maxSampleRate = ma_clamp(maxSampleRate, (unsigned int)ma_standard_sample_rate_min, (unsigned int)ma_standard_sample_rate_max); for (iSampleRate = 0; iSampleRate < ma_countof(g_maStandardSampleRatePriorities); iSampleRate += 1) { ma_uint32 standardSampleRate = g_maStandardSampleRatePriorities[iSampleRate]; if (standardSampleRate >= minSampleRate && standardSampleRate <= maxSampleRate) { ma_context_test_rate_and_add_native_data_format__alsa(pContext, pPCM, pHWParams, format, channels, standardSampleRate, flags, pDeviceInfo); } } /* Now make sure our min and max rates are included just in case they aren't in the range of our standard rates. */ if (!ma_is_standard_sample_rate(minSampleRate)) { ma_context_test_rate_and_add_native_data_format__alsa(pContext, pPCM, pHWParams, format, channels, minSampleRate, flags, pDeviceInfo); } if (!ma_is_standard_sample_rate(maxSampleRate) && maxSampleRate != minSampleRate) { ma_context_test_rate_and_add_native_data_format__alsa(pContext, pPCM, pHWParams, format, channels, maxSampleRate, flags, pDeviceInfo); } } static ma_result ma_context_get_device_info__alsa(ma_context* pContext, ma_device_type deviceType, const ma_device_id* pDeviceID, ma_device_info* pDeviceInfo) { ma_context_get_device_info_enum_callback_data__alsa data; ma_result result; int resultALSA; ma_snd_pcm_t* pPCM; ma_snd_pcm_hw_params_t* pHWParams; ma_uint32 iFormat; ma_uint32 iChannel; MA_ASSERT(pContext != NULL); /* We just enumerate to find basic information about the device. */ data.deviceType = deviceType; data.pDeviceID = pDeviceID; data.pDeviceInfo = pDeviceInfo; data.foundDevice = MA_FALSE; result = ma_context_enumerate_devices__alsa(pContext, ma_context_get_device_info_enum_callback__alsa, &data); if (result != MA_SUCCESS) { return result; } if (!data.foundDevice) { return MA_NO_DEVICE; } if (ma_strcmp(pDeviceInfo->id.alsa, "default") == 0) { pDeviceInfo->isDefault = MA_TRUE; } /* For detailed info we need to open the device. */ result = ma_context_open_pcm__alsa(pContext, ma_share_mode_shared, deviceType, pDeviceID, 0, &pPCM); if (result != MA_SUCCESS) { return result; } /* We need to initialize a HW parameters object in order to know what formats are supported. */ pHWParams = (ma_snd_pcm_hw_params_t*)ma_calloc(((ma_snd_pcm_hw_params_sizeof_proc)pContext->alsa.snd_pcm_hw_params_sizeof)(), &pContext->allocationCallbacks); if (pHWParams == NULL) { ((ma_snd_pcm_close_proc)pContext->alsa.snd_pcm_close)(pPCM); return MA_OUT_OF_MEMORY; } resultALSA = ((ma_snd_pcm_hw_params_any_proc)pContext->alsa.snd_pcm_hw_params_any)(pPCM, pHWParams); if (resultALSA < 0) { ma_free(pHWParams, &pContext->allocationCallbacks); ((ma_snd_pcm_close_proc)pContext->alsa.snd_pcm_close)(pPCM); ma_log_postf(ma_context_get_log(pContext), MA_LOG_LEVEL_ERROR, "[ALSA] Failed to initialize hardware parameters. snd_pcm_hw_params_any() failed."); return ma_result_from_errno(-resultALSA); } /* Some ALSA devices can support many permutations of formats, channels and rates. We only support a fixed number of permutations which means we need to employ some strategies to ensure the best combinations are returned. An example is the "pulse" device which can do it's own data conversion in software and as a result can support any combination of format, channels and rate. We want to ensure the the first data formats are the best. We have a list of favored sample formats and sample rates, so these will be the basis of our iteration. */ /* Formats. We just iterate over our standard formats and test them, making sure we reset the configuration space each iteration. */ for (iFormat = 0; iFormat < ma_countof(g_maFormatPriorities); iFormat += 1) { ma_format format = g_maFormatPriorities[iFormat]; /* For each format we need to make sure we reset the configuration space so we don't return channel counts and rates that aren't compatible with a format. */ ((ma_snd_pcm_hw_params_any_proc)pContext->alsa.snd_pcm_hw_params_any)(pPCM, pHWParams); /* Test the format first. If this fails it means the format is not supported and we can skip it. */ if (((ma_snd_pcm_hw_params_test_format_proc)pContext->alsa.snd_pcm_hw_params_test_format)(pPCM, pHWParams, ma_convert_ma_format_to_alsa_format(format)) == 0) { /* The format is supported. */ unsigned int minChannels; unsigned int maxChannels; /* The configuration space needs to be restricted to this format so we can get an accurate picture of which sample rates and channel counts are support with this format. */ ((ma_snd_pcm_hw_params_set_format_proc)pContext->alsa.snd_pcm_hw_params_set_format)(pPCM, pHWParams, ma_convert_ma_format_to_alsa_format(format)); /* Now we need to check for supported channels. */ ((ma_snd_pcm_hw_params_get_channels_min_proc)pContext->alsa.snd_pcm_hw_params_get_channels_min)(pHWParams, &minChannels); ((ma_snd_pcm_hw_params_get_channels_max_proc)pContext->alsa.snd_pcm_hw_params_get_channels_max)(pHWParams, &maxChannels); if (minChannels > MA_MAX_CHANNELS) { continue; /* Too many channels. */ } if (maxChannels < MA_MIN_CHANNELS) { continue; /* Not enough channels. */ } /* Make sure the channel count is clamped. This is mainly intended for the max channels because some devices can report an unbound maximum. */ minChannels = ma_clamp(minChannels, MA_MIN_CHANNELS, MA_MAX_CHANNELS); maxChannels = ma_clamp(maxChannels, MA_MIN_CHANNELS, MA_MAX_CHANNELS); if (minChannels == MA_MIN_CHANNELS && maxChannels == MA_MAX_CHANNELS) { /* The device supports all channels. Don't iterate over every single one. Instead just set the channels to 0 which means all channels are supported. */ ma_context_iterate_rates_and_add_native_data_format__alsa(pContext, pPCM, pHWParams, format, 0, 0, pDeviceInfo); /* Intentionally setting the channel count to 0 as that means all channels are supported. */ } else { /* The device only supports a specific set of channels. We need to iterate over all of them. */ for (iChannel = minChannels; iChannel <= maxChannels; iChannel += 1) { /* Test the channel before applying it to the configuration space. */ unsigned int channels = iChannel; /* Make sure our channel range is reset before testing again or else we'll always fail the test. */ ((ma_snd_pcm_hw_params_any_proc)pContext->alsa.snd_pcm_hw_params_any)(pPCM, pHWParams); ((ma_snd_pcm_hw_params_set_format_proc)pContext->alsa.snd_pcm_hw_params_set_format)(pPCM, pHWParams, ma_convert_ma_format_to_alsa_format(format)); if (((ma_snd_pcm_hw_params_test_channels_proc)pContext->alsa.snd_pcm_hw_params_test_channels)(pPCM, pHWParams, channels) == 0) { /* The channel count is supported. */ /* The configuration space now needs to be restricted to the channel count before extracting the sample rate. */ ((ma_snd_pcm_hw_params_set_channels_proc)pContext->alsa.snd_pcm_hw_params_set_channels)(pPCM, pHWParams, channels); /* Only after the configuration space has been restricted to the specific channel count should we iterate over our sample rates. */ ma_context_iterate_rates_and_add_native_data_format__alsa(pContext, pPCM, pHWParams, format, channels, 0, pDeviceInfo); } else { /* The channel count is not supported. Skip. */ } } } } else { /* The format is not supported. Skip. */ } } ma_free(pHWParams, &pContext->allocationCallbacks); ((ma_snd_pcm_close_proc)pContext->alsa.snd_pcm_close)(pPCM); return MA_SUCCESS; } static ma_result ma_device_uninit__alsa(ma_device* pDevice) { MA_ASSERT(pDevice != NULL); if ((ma_snd_pcm_t*)pDevice->alsa.pPCMCapture) { ((ma_snd_pcm_close_proc)pDevice->pContext->alsa.snd_pcm_close)((ma_snd_pcm_t*)pDevice->alsa.pPCMCapture); close(pDevice->alsa.wakeupfdCapture); ma_free(pDevice->alsa.pPollDescriptorsCapture, &pDevice->pContext->allocationCallbacks); } if ((ma_snd_pcm_t*)pDevice->alsa.pPCMPlayback) { ((ma_snd_pcm_close_proc)pDevice->pContext->alsa.snd_pcm_close)((ma_snd_pcm_t*)pDevice->alsa.pPCMPlayback); close(pDevice->alsa.wakeupfdPlayback); ma_free(pDevice->alsa.pPollDescriptorsPlayback, &pDevice->pContext->allocationCallbacks); } return MA_SUCCESS; } static ma_result ma_device_init_by_type__alsa(ma_device* pDevice, const ma_device_config* pConfig, ma_device_descriptor* pDescriptor, ma_device_type deviceType) { ma_result result; int resultALSA; ma_snd_pcm_t* pPCM; ma_bool32 isUsingMMap; ma_snd_pcm_format_t formatALSA; ma_format internalFormat; ma_uint32 internalChannels; ma_uint32 internalSampleRate; ma_channel internalChannelMap[MA_MAX_CHANNELS]; ma_uint32 internalPeriodSizeInFrames; ma_uint32 internalPeriods; int openMode; ma_snd_pcm_hw_params_t* pHWParams; ma_snd_pcm_sw_params_t* pSWParams; ma_snd_pcm_uframes_t bufferBoundary; int pollDescriptorCount; struct pollfd* pPollDescriptors; int wakeupfd; MA_ASSERT(pConfig != NULL); MA_ASSERT(deviceType != ma_device_type_duplex); /* This function should only be called for playback _or_ capture, never duplex. */ MA_ASSERT(pDevice != NULL); formatALSA = ma_convert_ma_format_to_alsa_format(pDescriptor->format); openMode = 0; if (pConfig->alsa.noAutoResample) { openMode |= MA_SND_PCM_NO_AUTO_RESAMPLE; } if (pConfig->alsa.noAutoChannels) { openMode |= MA_SND_PCM_NO_AUTO_CHANNELS; } if (pConfig->alsa.noAutoFormat) { openMode |= MA_SND_PCM_NO_AUTO_FORMAT; } result = ma_context_open_pcm__alsa(pDevice->pContext, pDescriptor->shareMode, deviceType, pDescriptor->pDeviceID, openMode, &pPCM); if (result != MA_SUCCESS) { return result; } /* Hardware parameters. */ pHWParams = (ma_snd_pcm_hw_params_t*)ma_calloc(((ma_snd_pcm_hw_params_sizeof_proc)pDevice->pContext->alsa.snd_pcm_hw_params_sizeof)(), &pDevice->pContext->allocationCallbacks); if (pHWParams == NULL) { ((ma_snd_pcm_close_proc)pDevice->pContext->alsa.snd_pcm_close)(pPCM); ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[ALSA] Failed to allocate memory for hardware parameters."); return MA_OUT_OF_MEMORY; } resultALSA = ((ma_snd_pcm_hw_params_any_proc)pDevice->pContext->alsa.snd_pcm_hw_params_any)(pPCM, pHWParams); if (resultALSA < 0) { ma_free(pHWParams, &pDevice->pContext->allocationCallbacks); ((ma_snd_pcm_close_proc)pDevice->pContext->alsa.snd_pcm_close)(pPCM); ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[ALSA] Failed to initialize hardware parameters. snd_pcm_hw_params_any() failed."); return ma_result_from_errno(-resultALSA); } /* MMAP Mode. Try using interleaved MMAP access. If this fails, fall back to standard readi/writei. */ isUsingMMap = MA_FALSE; #if 0 /* NOTE: MMAP mode temporarily disabled. */ if (deviceType != ma_device_type_capture) { /* <-- Disabling MMAP mode for capture devices because I apparently do not have a device that supports it which means I can't test it... Contributions welcome. */ if (!pConfig->alsa.noMMap) { if (((ma_snd_pcm_hw_params_set_access_proc)pDevice->pContext->alsa.snd_pcm_hw_params_set_access)(pPCM, pHWParams, MA_SND_PCM_ACCESS_MMAP_INTERLEAVED) == 0) { pDevice->alsa.isUsingMMap = MA_TRUE; } } } #endif if (!isUsingMMap) { resultALSA = ((ma_snd_pcm_hw_params_set_access_proc)pDevice->pContext->alsa.snd_pcm_hw_params_set_access)(pPCM, pHWParams, MA_SND_PCM_ACCESS_RW_INTERLEAVED); if (resultALSA < 0) { ma_free(pHWParams, &pDevice->pContext->allocationCallbacks); ((ma_snd_pcm_close_proc)pDevice->pContext->alsa.snd_pcm_close)(pPCM); ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[ALSA] Failed to set access mode to neither SND_PCM_ACCESS_MMAP_INTERLEAVED nor SND_PCM_ACCESS_RW_INTERLEAVED. snd_pcm_hw_params_set_access() failed."); return ma_result_from_errno(-resultALSA); } } /* Most important properties first. The documentation for OSS (yes, I know this is ALSA!) recommends format, channels, then sample rate. I can't find any documentation for ALSA specifically, so I'm going to copy the recommendation for OSS. */ /* Format. */ { /* At this point we should have a list of supported formats, so now we need to find the best one. We first check if the requested format is supported, and if so, use that one. If it's not supported, we just run though a list of formats and try to find the best one. */ if (formatALSA == MA_SND_PCM_FORMAT_UNKNOWN || ((ma_snd_pcm_hw_params_test_format_proc)pDevice->pContext->alsa.snd_pcm_hw_params_test_format)(pPCM, pHWParams, formatALSA) != 0) { /* We're either requesting the native format or the specified format is not supported. */ size_t iFormat; formatALSA = MA_SND_PCM_FORMAT_UNKNOWN; for (iFormat = 0; iFormat < ma_countof(g_maFormatPriorities); ++iFormat) { if (((ma_snd_pcm_hw_params_test_format_proc)pDevice->pContext->alsa.snd_pcm_hw_params_test_format)(pPCM, pHWParams, ma_convert_ma_format_to_alsa_format(g_maFormatPriorities[iFormat])) == 0) { formatALSA = ma_convert_ma_format_to_alsa_format(g_maFormatPriorities[iFormat]); break; } } if (formatALSA == MA_SND_PCM_FORMAT_UNKNOWN) { ma_free(pHWParams, &pDevice->pContext->allocationCallbacks); ((ma_snd_pcm_close_proc)pDevice->pContext->alsa.snd_pcm_close)(pPCM); ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[ALSA] Format not supported. The device does not support any miniaudio formats."); return MA_FORMAT_NOT_SUPPORTED; } } resultALSA = ((ma_snd_pcm_hw_params_set_format_proc)pDevice->pContext->alsa.snd_pcm_hw_params_set_format)(pPCM, pHWParams, formatALSA); if (resultALSA < 0) { ma_free(pHWParams, &pDevice->pContext->allocationCallbacks); ((ma_snd_pcm_close_proc)pDevice->pContext->alsa.snd_pcm_close)(pPCM); ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[ALSA] Format not supported. snd_pcm_hw_params_set_format() failed."); return ma_result_from_errno(-resultALSA); } internalFormat = ma_format_from_alsa(formatALSA); if (internalFormat == ma_format_unknown) { ma_free(pHWParams, &pDevice->pContext->allocationCallbacks); ((ma_snd_pcm_close_proc)pDevice->pContext->alsa.snd_pcm_close)(pPCM); ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[ALSA] The chosen format is not supported by miniaudio."); return MA_FORMAT_NOT_SUPPORTED; } } /* Channels. */ { unsigned int channels = pDescriptor->channels; if (channels == 0) { channels = MA_DEFAULT_CHANNELS; } resultALSA = ((ma_snd_pcm_hw_params_set_channels_near_proc)pDevice->pContext->alsa.snd_pcm_hw_params_set_channels_near)(pPCM, pHWParams, &channels); if (resultALSA < 0) { ma_free(pHWParams, &pDevice->pContext->allocationCallbacks); ((ma_snd_pcm_close_proc)pDevice->pContext->alsa.snd_pcm_close)(pPCM); ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[ALSA] Failed to set channel count. snd_pcm_hw_params_set_channels_near() failed."); return ma_result_from_errno(-resultALSA); } internalChannels = (ma_uint32)channels; } /* Sample Rate */ { unsigned int sampleRate; /* It appears there's either a bug in ALSA, a bug in some drivers, or I'm doing something silly; but having resampling enabled causes problems with some device configurations when used in conjunction with MMAP access mode. To fix this problem we need to disable resampling. To reproduce this problem, open the "plug:dmix" device, and set the sample rate to 44100. Internally, it looks like dmix uses a sample rate of 48000. The hardware parameters will get set correctly with no errors, but it looks like the 44100 -> 48000 resampling doesn't work properly - but only with MMAP access mode. You will notice skipping/crackling in the audio, and it'll run at a slightly faster rate. miniaudio has built-in support for sample rate conversion (albeit low quality at the moment), so disabling resampling should be fine for us. The only problem is that it won't be taking advantage of any kind of hardware-accelerated resampling and it won't be very good quality until I get a chance to improve the quality of miniaudio's software sample rate conversion. I don't currently know if the dmix plugin is the only one with this error. Indeed, this is the only one I've been able to reproduce this error with. In the future, we may want to restrict the disabling of resampling to only known bad plugins. */ ((ma_snd_pcm_hw_params_set_rate_resample_proc)pDevice->pContext->alsa.snd_pcm_hw_params_set_rate_resample)(pPCM, pHWParams, 0); sampleRate = pDescriptor->sampleRate; if (sampleRate == 0) { sampleRate = MA_DEFAULT_SAMPLE_RATE; } resultALSA = ((ma_snd_pcm_hw_params_set_rate_near_proc)pDevice->pContext->alsa.snd_pcm_hw_params_set_rate_near)(pPCM, pHWParams, &sampleRate, 0); if (resultALSA < 0) { ma_free(pHWParams, &pDevice->pContext->allocationCallbacks); ((ma_snd_pcm_close_proc)pDevice->pContext->alsa.snd_pcm_close)(pPCM); ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[ALSA] Sample rate not supported. snd_pcm_hw_params_set_rate_near() failed."); return ma_result_from_errno(-resultALSA); } internalSampleRate = (ma_uint32)sampleRate; } /* Periods. */ { ma_uint32 periods = pDescriptor->periodCount; resultALSA = ((ma_snd_pcm_hw_params_set_periods_near_proc)pDevice->pContext->alsa.snd_pcm_hw_params_set_periods_near)(pPCM, pHWParams, &periods, NULL); if (resultALSA < 0) { ma_free(pHWParams, &pDevice->pContext->allocationCallbacks); ((ma_snd_pcm_close_proc)pDevice->pContext->alsa.snd_pcm_close)(pPCM); ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[ALSA] Failed to set period count. snd_pcm_hw_params_set_periods_near() failed."); return ma_result_from_errno(-resultALSA); } internalPeriods = periods; } /* Buffer Size */ { ma_snd_pcm_uframes_t actualBufferSizeInFrames = ma_calculate_buffer_size_in_frames_from_descriptor(pDescriptor, internalSampleRate, pConfig->performanceProfile) * internalPeriods; resultALSA = ((ma_snd_pcm_hw_params_set_buffer_size_near_proc)pDevice->pContext->alsa.snd_pcm_hw_params_set_buffer_size_near)(pPCM, pHWParams, &actualBufferSizeInFrames); if (resultALSA < 0) { ma_free(pHWParams, &pDevice->pContext->allocationCallbacks); ((ma_snd_pcm_close_proc)pDevice->pContext->alsa.snd_pcm_close)(pPCM); ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[ALSA] Failed to set buffer size for device. snd_pcm_hw_params_set_buffer_size() failed."); return ma_result_from_errno(-resultALSA); } internalPeriodSizeInFrames = actualBufferSizeInFrames / internalPeriods; } /* Apply hardware parameters. */ resultALSA = ((ma_snd_pcm_hw_params_proc)pDevice->pContext->alsa.snd_pcm_hw_params)(pPCM, pHWParams); if (resultALSA < 0) { ma_free(pHWParams, &pDevice->pContext->allocationCallbacks); ((ma_snd_pcm_close_proc)pDevice->pContext->alsa.snd_pcm_close)(pPCM); ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[ALSA] Failed to set hardware parameters. snd_pcm_hw_params() failed."); return ma_result_from_errno(-resultALSA); } ma_free(pHWParams, &pDevice->pContext->allocationCallbacks); pHWParams = NULL; /* Software parameters. */ pSWParams = (ma_snd_pcm_sw_params_t*)ma_calloc(((ma_snd_pcm_sw_params_sizeof_proc)pDevice->pContext->alsa.snd_pcm_sw_params_sizeof)(), &pDevice->pContext->allocationCallbacks); if (pSWParams == NULL) { ((ma_snd_pcm_close_proc)pDevice->pContext->alsa.snd_pcm_close)(pPCM); ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[ALSA] Failed to allocate memory for software parameters."); return MA_OUT_OF_MEMORY; } resultALSA = ((ma_snd_pcm_sw_params_current_proc)pDevice->pContext->alsa.snd_pcm_sw_params_current)(pPCM, pSWParams); if (resultALSA < 0) { ma_free(pSWParams, &pDevice->pContext->allocationCallbacks); ((ma_snd_pcm_close_proc)pDevice->pContext->alsa.snd_pcm_close)(pPCM); ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[ALSA] Failed to initialize software parameters. snd_pcm_sw_params_current() failed."); return ma_result_from_errno(-resultALSA); } resultALSA = ((ma_snd_pcm_sw_params_set_avail_min_proc)pDevice->pContext->alsa.snd_pcm_sw_params_set_avail_min)(pPCM, pSWParams, ma_prev_power_of_2(internalPeriodSizeInFrames)); if (resultALSA < 0) { ma_free(pSWParams, &pDevice->pContext->allocationCallbacks); ((ma_snd_pcm_close_proc)pDevice->pContext->alsa.snd_pcm_close)(pPCM); ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[ALSA] snd_pcm_sw_params_set_avail_min() failed."); return ma_result_from_errno(-resultALSA); } resultALSA = ((ma_snd_pcm_sw_params_get_boundary_proc)pDevice->pContext->alsa.snd_pcm_sw_params_get_boundary)(pSWParams, &bufferBoundary); if (resultALSA < 0) { bufferBoundary = internalPeriodSizeInFrames * internalPeriods; } if (deviceType == ma_device_type_playback && !isUsingMMap) { /* Only playback devices in writei/readi mode need a start threshold. */ /* Subtle detail here with the start threshold. When in playback-only mode (no full-duplex) we can set the start threshold to the size of a period. But for full-duplex we need to set it such that it is at least two periods. */ resultALSA = ((ma_snd_pcm_sw_params_set_start_threshold_proc)pDevice->pContext->alsa.snd_pcm_sw_params_set_start_threshold)(pPCM, pSWParams, internalPeriodSizeInFrames*2); if (resultALSA < 0) { ma_free(pSWParams, &pDevice->pContext->allocationCallbacks); ((ma_snd_pcm_close_proc)pDevice->pContext->alsa.snd_pcm_close)(pPCM); ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[ALSA] Failed to set start threshold for playback device. snd_pcm_sw_params_set_start_threshold() failed."); return ma_result_from_errno(-resultALSA); } resultALSA = ((ma_snd_pcm_sw_params_set_stop_threshold_proc)pDevice->pContext->alsa.snd_pcm_sw_params_set_stop_threshold)(pPCM, pSWParams, bufferBoundary); if (resultALSA < 0) { /* Set to boundary to loop instead of stop in the event of an xrun. */ ma_free(pSWParams, &pDevice->pContext->allocationCallbacks); ((ma_snd_pcm_close_proc)pDevice->pContext->alsa.snd_pcm_close)(pPCM); ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[ALSA] Failed to set stop threshold for playback device. snd_pcm_sw_params_set_stop_threshold() failed."); return ma_result_from_errno(-resultALSA); } } resultALSA = ((ma_snd_pcm_sw_params_proc)pDevice->pContext->alsa.snd_pcm_sw_params)(pPCM, pSWParams); if (resultALSA < 0) { ma_free(pSWParams, &pDevice->pContext->allocationCallbacks); ((ma_snd_pcm_close_proc)pDevice->pContext->alsa.snd_pcm_close)(pPCM); ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[ALSA] Failed to set software parameters. snd_pcm_sw_params() failed."); return ma_result_from_errno(-resultALSA); } ma_free(pSWParams, &pDevice->pContext->allocationCallbacks); pSWParams = NULL; /* Grab the internal channel map. For now we're not going to bother trying to change the channel map and instead just do it ourselves. */ { ma_snd_pcm_chmap_t* pChmap = NULL; if (pDevice->pContext->alsa.snd_pcm_get_chmap != NULL) { pChmap = ((ma_snd_pcm_get_chmap_proc)pDevice->pContext->alsa.snd_pcm_get_chmap)(pPCM); } if (pChmap != NULL) { ma_uint32 iChannel; /* There are cases where the returned channel map can have a different channel count than was returned by snd_pcm_hw_params_set_channels_near(). */ if (pChmap->channels >= internalChannels) { /* Drop excess channels. */ for (iChannel = 0; iChannel < internalChannels; ++iChannel) { internalChannelMap[iChannel] = ma_convert_alsa_channel_position_to_ma_channel(pChmap->pos[iChannel]); } } else { ma_uint32 i; /* Excess channels use defaults. Do an initial fill with defaults, overwrite the first pChmap->channels, validate to ensure there are no duplicate channels. If validation fails, fall back to defaults. */ ma_bool32 isValid = MA_TRUE; /* Fill with defaults. */ ma_channel_map_init_standard(ma_standard_channel_map_alsa, internalChannelMap, ma_countof(internalChannelMap), internalChannels); /* Overwrite first pChmap->channels channels. */ for (iChannel = 0; iChannel < pChmap->channels; ++iChannel) { internalChannelMap[iChannel] = ma_convert_alsa_channel_position_to_ma_channel(pChmap->pos[iChannel]); } /* Validate. */ for (i = 0; i < internalChannels && isValid; ++i) { ma_uint32 j; for (j = i+1; j < internalChannels; ++j) { if (internalChannelMap[i] == internalChannelMap[j]) { isValid = MA_FALSE; break; } } } /* If our channel map is invalid, fall back to defaults. */ if (!isValid) { ma_channel_map_init_standard(ma_standard_channel_map_alsa, internalChannelMap, ma_countof(internalChannelMap), internalChannels); } } free(pChmap); pChmap = NULL; } else { /* Could not retrieve the channel map. Fall back to a hard-coded assumption. */ ma_channel_map_init_standard(ma_standard_channel_map_alsa, internalChannelMap, ma_countof(internalChannelMap), internalChannels); } } /* We need to retrieve the poll descriptors so we can use poll() to wait for data to become available for reading or writing. There's no well defined maximum for this so we're just going to allocate this on the heap. */ pollDescriptorCount = ((ma_snd_pcm_poll_descriptors_count_proc)pDevice->pContext->alsa.snd_pcm_poll_descriptors_count)(pPCM); if (pollDescriptorCount <= 0) { ((ma_snd_pcm_close_proc)pDevice->pContext->alsa.snd_pcm_close)(pPCM); ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[ALSA] Failed to retrieve poll descriptors count."); return MA_ERROR; } pPollDescriptors = (struct pollfd*)ma_malloc(sizeof(*pPollDescriptors) * (pollDescriptorCount + 1), &pDevice->pContext->allocationCallbacks); /* +1 because we want room for the wakeup descriptor. */ if (pPollDescriptors == NULL) { ((ma_snd_pcm_close_proc)pDevice->pContext->alsa.snd_pcm_close)(pPCM); ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[ALSA] Failed to allocate memory for poll descriptors."); return MA_OUT_OF_MEMORY; } /* We need an eventfd to wakeup from poll() and avoid a deadlock in situations where the driver never returns from writei() and readi(). This has been observed with the "pulse" device. */ wakeupfd = eventfd(0, 0); if (wakeupfd < 0) { ma_free(pPollDescriptors, &pDevice->pContext->allocationCallbacks); ((ma_snd_pcm_close_proc)pDevice->pContext->alsa.snd_pcm_close)(pPCM); ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[ALSA] Failed to create eventfd for poll wakeup."); return ma_result_from_errno(errno); } /* We'll place the wakeup fd at the start of the buffer. */ pPollDescriptors[0].fd = wakeupfd; pPollDescriptors[0].events = POLLIN; /* We only care about waiting to read from the wakeup file descriptor. */ pPollDescriptors[0].revents = 0; /* We can now extract the PCM poll descriptors which we place after the wakeup descriptor. */ pollDescriptorCount = ((ma_snd_pcm_poll_descriptors_proc)pDevice->pContext->alsa.snd_pcm_poll_descriptors)(pPCM, pPollDescriptors + 1, pollDescriptorCount); /* +1 because we want to place these descriptors after the wakeup descriptor. */ if (pollDescriptorCount <= 0) { close(wakeupfd); ma_free(pPollDescriptors, &pDevice->pContext->allocationCallbacks); ((ma_snd_pcm_close_proc)pDevice->pContext->alsa.snd_pcm_close)(pPCM); ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[ALSA] Failed to retrieve poll descriptors."); return MA_ERROR; } if (deviceType == ma_device_type_capture) { pDevice->alsa.pollDescriptorCountCapture = pollDescriptorCount; pDevice->alsa.pPollDescriptorsCapture = pPollDescriptors; pDevice->alsa.wakeupfdCapture = wakeupfd; } else { pDevice->alsa.pollDescriptorCountPlayback = pollDescriptorCount; pDevice->alsa.pPollDescriptorsPlayback = pPollDescriptors; pDevice->alsa.wakeupfdPlayback = wakeupfd; } /* We're done. Prepare the device. */ resultALSA = ((ma_snd_pcm_prepare_proc)pDevice->pContext->alsa.snd_pcm_prepare)(pPCM); if (resultALSA < 0) { close(wakeupfd); ma_free(pPollDescriptors, &pDevice->pContext->allocationCallbacks); ((ma_snd_pcm_close_proc)pDevice->pContext->alsa.snd_pcm_close)(pPCM); ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[ALSA] Failed to prepare device."); return ma_result_from_errno(-resultALSA); } if (deviceType == ma_device_type_capture) { pDevice->alsa.pPCMCapture = (ma_ptr)pPCM; pDevice->alsa.isUsingMMapCapture = isUsingMMap; } else { pDevice->alsa.pPCMPlayback = (ma_ptr)pPCM; pDevice->alsa.isUsingMMapPlayback = isUsingMMap; } pDescriptor->format = internalFormat; pDescriptor->channels = internalChannels; pDescriptor->sampleRate = internalSampleRate; ma_channel_map_copy(pDescriptor->channelMap, internalChannelMap, ma_min(internalChannels, MA_MAX_CHANNELS)); pDescriptor->periodSizeInFrames = internalPeriodSizeInFrames; pDescriptor->periodCount = internalPeriods; return MA_SUCCESS; } static ma_result ma_device_init__alsa(ma_device* pDevice, const ma_device_config* pConfig, ma_device_descriptor* pDescriptorPlayback, ma_device_descriptor* pDescriptorCapture) { MA_ASSERT(pDevice != NULL); MA_ZERO_OBJECT(&pDevice->alsa); if (pConfig->deviceType == ma_device_type_loopback) { return MA_DEVICE_TYPE_NOT_SUPPORTED; } if (pConfig->deviceType == ma_device_type_capture || pConfig->deviceType == ma_device_type_duplex) { ma_result result = ma_device_init_by_type__alsa(pDevice, pConfig, pDescriptorCapture, ma_device_type_capture); if (result != MA_SUCCESS) { return result; } } if (pConfig->deviceType == ma_device_type_playback || pConfig->deviceType == ma_device_type_duplex) { ma_result result = ma_device_init_by_type__alsa(pDevice, pConfig, pDescriptorPlayback, ma_device_type_playback); if (result != MA_SUCCESS) { return result; } } return MA_SUCCESS; } static ma_result ma_device_start__alsa(ma_device* pDevice) { int resultALSA; if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) { resultALSA = ((ma_snd_pcm_start_proc)pDevice->pContext->alsa.snd_pcm_start)((ma_snd_pcm_t*)pDevice->alsa.pPCMCapture); if (resultALSA < 0) { ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[ALSA] Failed to start capture device."); return ma_result_from_errno(-resultALSA); } } if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) { /* Don't need to do anything for playback because it'll be started automatically when enough data has been written. */ } return MA_SUCCESS; } static ma_result ma_device_stop__alsa(ma_device* pDevice) { /* The stop callback will get called on the worker thread after read/write__alsa() has returned. At this point there is a small chance that our wakeupfd has not been cleared. We'll clear that out now if applicable. */ int resultPoll; if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) { ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_DEBUG, "[ALSA] Dropping capture device...\n"); ((ma_snd_pcm_drop_proc)pDevice->pContext->alsa.snd_pcm_drop)((ma_snd_pcm_t*)pDevice->alsa.pPCMCapture); ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_DEBUG, "[ALSA] Dropping capture device successful.\n"); /* We need to prepare the device again, otherwise we won't be able to restart the device. */ ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_DEBUG, "[ALSA] Preparing capture device...\n"); if (((ma_snd_pcm_prepare_proc)pDevice->pContext->alsa.snd_pcm_prepare)((ma_snd_pcm_t*)pDevice->alsa.pPCMCapture) < 0) { ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_DEBUG, "[ALSA] Preparing capture device failed.\n"); } else { ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_DEBUG, "[ALSA] Preparing capture device successful.\n"); } /* Clear the wakeupfd. */ resultPoll = poll((struct pollfd*)pDevice->alsa.pPollDescriptorsCapture, 1, 0); if (resultPoll > 0) { ma_uint64 t; (void)!read(((struct pollfd*)pDevice->alsa.pPollDescriptorsCapture)[0].fd, &t, sizeof(t)); } } if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) { ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_DEBUG, "[ALSA] Dropping playback device...\n"); ((ma_snd_pcm_drop_proc)pDevice->pContext->alsa.snd_pcm_drop)((ma_snd_pcm_t*)pDevice->alsa.pPCMPlayback); ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_DEBUG, "[ALSA] Dropping playback device successful.\n"); /* We need to prepare the device again, otherwise we won't be able to restart the device. */ ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_DEBUG, "[ALSA] Preparing playback device...\n"); if (((ma_snd_pcm_prepare_proc)pDevice->pContext->alsa.snd_pcm_prepare)((ma_snd_pcm_t*)pDevice->alsa.pPCMPlayback) < 0) { ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_DEBUG, "[ALSA] Preparing playback device failed.\n"); } else { ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_DEBUG, "[ALSA] Preparing playback device successful.\n"); } /* Clear the wakeupfd. */ resultPoll = poll((struct pollfd*)pDevice->alsa.pPollDescriptorsPlayback, 1, 0); if (resultPoll > 0) { ma_uint64 t; (void)!read(((struct pollfd*)pDevice->alsa.pPollDescriptorsPlayback)[0].fd, &t, sizeof(t)); } } return MA_SUCCESS; } static ma_result ma_device_wait__alsa(ma_device* pDevice, ma_snd_pcm_t* pPCM, struct pollfd* pPollDescriptors, int pollDescriptorCount, short requiredEvent) { for (;;) { unsigned short revents; int resultALSA; int resultPoll = poll(pPollDescriptors, pollDescriptorCount, -1); if (resultPoll < 0) { ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[ALSA] poll() failed.\n"); return ma_result_from_errno(errno); } /* Before checking the ALSA poll descriptor flag we need to check if the wakeup descriptor has had it's POLLIN flag set. If so, we need to actually read the data and then exit function. The wakeup descriptor will be the first item in the descriptors buffer. */ if ((pPollDescriptors[0].revents & POLLIN) != 0) { ma_uint64 t; int resultRead = read(pPollDescriptors[0].fd, &t, sizeof(t)); /* <-- Important that we read here so that the next write() does not block. */ if (resultRead < 0) { ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[ALSA] read() failed.\n"); return ma_result_from_errno(errno); } ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_DEBUG, "[ALSA] POLLIN set for wakeupfd\n"); return MA_DEVICE_NOT_STARTED; } /* Getting here means that some data should be able to be read. We need to use ALSA to translate the revents flags for us. */ resultALSA = ((ma_snd_pcm_poll_descriptors_revents_proc)pDevice->pContext->alsa.snd_pcm_poll_descriptors_revents)(pPCM, pPollDescriptors + 1, pollDescriptorCount - 1, &revents); /* +1, -1 to ignore the wakeup descriptor. */ if (resultALSA < 0) { ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[ALSA] snd_pcm_poll_descriptors_revents() failed.\n"); return ma_result_from_errno(-resultALSA); } if ((revents & POLLERR) != 0) { ma_snd_pcm_state_t state = ((ma_snd_pcm_state_proc)pDevice->pContext->alsa.snd_pcm_state)(pPCM); if (state == MA_SND_PCM_STATE_XRUN) { /* The PCM is in a xrun state. This will be recovered from at a higher level. We can disregard this. */ } else { ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_WARNING, "[ALSA] POLLERR detected. status = %d\n", ((ma_snd_pcm_state_proc)pDevice->pContext->alsa.snd_pcm_state)(pPCM)); } } if ((revents & requiredEvent) == requiredEvent) { break; /* We're done. Data available for reading or writing. */ } } return MA_SUCCESS; } static ma_result ma_device_wait_read__alsa(ma_device* pDevice) { return ma_device_wait__alsa(pDevice, (ma_snd_pcm_t*)pDevice->alsa.pPCMCapture, (struct pollfd*)pDevice->alsa.pPollDescriptorsCapture, pDevice->alsa.pollDescriptorCountCapture + 1, POLLIN); /* +1 to account for the wakeup descriptor. */ } static ma_result ma_device_wait_write__alsa(ma_device* pDevice) { return ma_device_wait__alsa(pDevice, (ma_snd_pcm_t*)pDevice->alsa.pPCMPlayback, (struct pollfd*)pDevice->alsa.pPollDescriptorsPlayback, pDevice->alsa.pollDescriptorCountPlayback + 1, POLLOUT); /* +1 to account for the wakeup descriptor. */ } static ma_result ma_device_read__alsa(ma_device* pDevice, void* pFramesOut, ma_uint32 frameCount, ma_uint32* pFramesRead) { ma_snd_pcm_sframes_t resultALSA = 0; MA_ASSERT(pDevice != NULL); MA_ASSERT(pFramesOut != NULL); if (pFramesRead != NULL) { *pFramesRead = 0; } while (ma_device_get_state(pDevice) == ma_device_state_started) { ma_result result; /* The first thing to do is wait for data to become available for reading. This will return an error code if the device has been stopped. */ result = ma_device_wait_read__alsa(pDevice); if (result != MA_SUCCESS) { return result; } /* Getting here means we should have data available. */ resultALSA = ((ma_snd_pcm_readi_proc)pDevice->pContext->alsa.snd_pcm_readi)((ma_snd_pcm_t*)pDevice->alsa.pPCMCapture, pFramesOut, frameCount); if (resultALSA >= 0) { break; /* Success. */ } else { if (resultALSA == -EAGAIN) { /*ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_DEBUG, "EGAIN (read)\n");*/ continue; /* Try again. */ } else if (resultALSA == -EPIPE) { ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_DEBUG, "EPIPE (read)\n"); /* Overrun. Recover and try again. If this fails we need to return an error. */ resultALSA = ((ma_snd_pcm_recover_proc)pDevice->pContext->alsa.snd_pcm_recover)((ma_snd_pcm_t*)pDevice->alsa.pPCMCapture, resultALSA, MA_TRUE); if (resultALSA < 0) { ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[ALSA] Failed to recover device after overrun."); return ma_result_from_errno((int)-resultALSA); } resultALSA = ((ma_snd_pcm_start_proc)pDevice->pContext->alsa.snd_pcm_start)((ma_snd_pcm_t*)pDevice->alsa.pPCMCapture); if (resultALSA < 0) { ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[ALSA] Failed to start device after underrun."); return ma_result_from_errno((int)-resultALSA); } continue; /* Try reading again. */ } } } if (pFramesRead != NULL) { *pFramesRead = resultALSA; } return MA_SUCCESS; } static ma_result ma_device_write__alsa(ma_device* pDevice, const void* pFrames, ma_uint32 frameCount, ma_uint32* pFramesWritten) { ma_snd_pcm_sframes_t resultALSA = 0; MA_ASSERT(pDevice != NULL); MA_ASSERT(pFrames != NULL); if (pFramesWritten != NULL) { *pFramesWritten = 0; } while (ma_device_get_state(pDevice) == ma_device_state_started) { ma_result result; /* The first thing to do is wait for space to become available for writing. This will return an error code if the device has been stopped. */ result = ma_device_wait_write__alsa(pDevice); if (result != MA_SUCCESS) { return result; } resultALSA = ((ma_snd_pcm_writei_proc)pDevice->pContext->alsa.snd_pcm_writei)((ma_snd_pcm_t*)pDevice->alsa.pPCMPlayback, pFrames, frameCount); if (resultALSA >= 0) { break; /* Success. */ } else { if (resultALSA == -EAGAIN) { /*ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_DEBUG, "EGAIN (write)\n");*/ continue; /* Try again. */ } else if (resultALSA == -EPIPE) { ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_DEBUG, "EPIPE (write)\n"); /* Underrun. Recover and try again. If this fails we need to return an error. */ resultALSA = ((ma_snd_pcm_recover_proc)pDevice->pContext->alsa.snd_pcm_recover)((ma_snd_pcm_t*)pDevice->alsa.pPCMPlayback, resultALSA, MA_TRUE); /* MA_TRUE=silent (don't print anything on error). */ if (resultALSA < 0) { ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[ALSA] Failed to recover device after underrun."); return ma_result_from_errno((int)-resultALSA); } /* In my testing I have had a situation where writei() does not automatically restart the device even though I've set it up as such in the software parameters. What will happen is writei() will block indefinitely even though the number of frames is well beyond the auto-start threshold. To work around this I've needed to add an explicit start here. Not sure if this is me just being stupid and not recovering the device properly, but this definitely feels like something isn't quite right here. */ resultALSA = ((ma_snd_pcm_start_proc)pDevice->pContext->alsa.snd_pcm_start)((ma_snd_pcm_t*)pDevice->alsa.pPCMPlayback); if (resultALSA < 0) { ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[ALSA] Failed to start device after underrun."); return ma_result_from_errno((int)-resultALSA); } continue; /* Try writing again. */ } } } if (pFramesWritten != NULL) { *pFramesWritten = resultALSA; } return MA_SUCCESS; } static ma_result ma_device_data_loop_wakeup__alsa(ma_device* pDevice) { ma_uint64 t = 1; int resultWrite = 0; MA_ASSERT(pDevice != NULL); ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_DEBUG, "[ALSA] Waking up...\n"); /* Write to an eventfd to trigger a wakeup from poll() and abort any reading or writing. */ if (pDevice->alsa.pPollDescriptorsCapture != NULL) { resultWrite = write(pDevice->alsa.wakeupfdCapture, &t, sizeof(t)); } if (pDevice->alsa.pPollDescriptorsPlayback != NULL) { resultWrite = write(pDevice->alsa.wakeupfdPlayback, &t, sizeof(t)); } if (resultWrite < 0) { ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[ALSA] write() failed.\n"); return ma_result_from_errno(errno); } ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_DEBUG, "[ALSA] Waking up completed successfully.\n"); return MA_SUCCESS; } static ma_result ma_context_uninit__alsa(ma_context* pContext) { MA_ASSERT(pContext != NULL); MA_ASSERT(pContext->backend == ma_backend_alsa); /* Clean up memory for memory leak checkers. */ ((ma_snd_config_update_free_global_proc)pContext->alsa.snd_config_update_free_global)(); #ifndef MA_NO_RUNTIME_LINKING ma_dlclose(ma_context_get_log(pContext), pContext->alsa.asoundSO); #endif ma_mutex_uninit(&pContext->alsa.internalDeviceEnumLock); return MA_SUCCESS; } static ma_result ma_context_init__alsa(ma_context* pContext, const ma_context_config* pConfig, ma_backend_callbacks* pCallbacks) { ma_result result; #ifndef MA_NO_RUNTIME_LINKING const char* libasoundNames[] = { "libasound.so.2", "libasound.so" }; size_t i; for (i = 0; i < ma_countof(libasoundNames); ++i) { pContext->alsa.asoundSO = ma_dlopen(ma_context_get_log(pContext), libasoundNames[i]); if (pContext->alsa.asoundSO != NULL) { break; } } if (pContext->alsa.asoundSO == NULL) { ma_log_postf(ma_context_get_log(pContext), MA_LOG_LEVEL_DEBUG, "[ALSA] Failed to open shared object.\n"); return MA_NO_BACKEND; } pContext->alsa.snd_pcm_open = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->alsa.asoundSO, "snd_pcm_open"); pContext->alsa.snd_pcm_close = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->alsa.asoundSO, "snd_pcm_close"); pContext->alsa.snd_pcm_hw_params_sizeof = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->alsa.asoundSO, "snd_pcm_hw_params_sizeof"); pContext->alsa.snd_pcm_hw_params_any = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->alsa.asoundSO, "snd_pcm_hw_params_any"); pContext->alsa.snd_pcm_hw_params_set_format = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->alsa.asoundSO, "snd_pcm_hw_params_set_format"); pContext->alsa.snd_pcm_hw_params_set_format_first = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->alsa.asoundSO, "snd_pcm_hw_params_set_format_first"); pContext->alsa.snd_pcm_hw_params_get_format_mask = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->alsa.asoundSO, "snd_pcm_hw_params_get_format_mask"); pContext->alsa.snd_pcm_hw_params_set_channels = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->alsa.asoundSO, "snd_pcm_hw_params_set_channels"); pContext->alsa.snd_pcm_hw_params_set_channels_near = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->alsa.asoundSO, "snd_pcm_hw_params_set_channels_near"); pContext->alsa.snd_pcm_hw_params_set_channels_minmax = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->alsa.asoundSO, "snd_pcm_hw_params_set_channels_minmax"); pContext->alsa.snd_pcm_hw_params_set_rate_resample = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->alsa.asoundSO, "snd_pcm_hw_params_set_rate_resample"); pContext->alsa.snd_pcm_hw_params_set_rate = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->alsa.asoundSO, "snd_pcm_hw_params_set_rate"); pContext->alsa.snd_pcm_hw_params_set_rate_near = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->alsa.asoundSO, "snd_pcm_hw_params_set_rate_near"); pContext->alsa.snd_pcm_hw_params_set_buffer_size_near = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->alsa.asoundSO, "snd_pcm_hw_params_set_buffer_size_near"); pContext->alsa.snd_pcm_hw_params_set_periods_near = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->alsa.asoundSO, "snd_pcm_hw_params_set_periods_near"); pContext->alsa.snd_pcm_hw_params_set_access = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->alsa.asoundSO, "snd_pcm_hw_params_set_access"); pContext->alsa.snd_pcm_hw_params_get_format = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->alsa.asoundSO, "snd_pcm_hw_params_get_format"); pContext->alsa.snd_pcm_hw_params_get_channels = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->alsa.asoundSO, "snd_pcm_hw_params_get_channels"); pContext->alsa.snd_pcm_hw_params_get_channels_min = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->alsa.asoundSO, "snd_pcm_hw_params_get_channels_min"); pContext->alsa.snd_pcm_hw_params_get_channels_max = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->alsa.asoundSO, "snd_pcm_hw_params_get_channels_max"); pContext->alsa.snd_pcm_hw_params_get_rate = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->alsa.asoundSO, "snd_pcm_hw_params_get_rate"); pContext->alsa.snd_pcm_hw_params_get_rate_min = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->alsa.asoundSO, "snd_pcm_hw_params_get_rate_min"); pContext->alsa.snd_pcm_hw_params_get_rate_max = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->alsa.asoundSO, "snd_pcm_hw_params_get_rate_max"); pContext->alsa.snd_pcm_hw_params_get_buffer_size = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->alsa.asoundSO, "snd_pcm_hw_params_get_buffer_size"); pContext->alsa.snd_pcm_hw_params_get_periods = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->alsa.asoundSO, "snd_pcm_hw_params_get_periods"); pContext->alsa.snd_pcm_hw_params_get_access = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->alsa.asoundSO, "snd_pcm_hw_params_get_access"); pContext->alsa.snd_pcm_hw_params_test_format = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->alsa.asoundSO, "snd_pcm_hw_params_test_format"); pContext->alsa.snd_pcm_hw_params_test_channels = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->alsa.asoundSO, "snd_pcm_hw_params_test_channels"); pContext->alsa.snd_pcm_hw_params_test_rate = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->alsa.asoundSO, "snd_pcm_hw_params_test_rate"); pContext->alsa.snd_pcm_hw_params = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->alsa.asoundSO, "snd_pcm_hw_params"); pContext->alsa.snd_pcm_sw_params_sizeof = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->alsa.asoundSO, "snd_pcm_sw_params_sizeof"); pContext->alsa.snd_pcm_sw_params_current = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->alsa.asoundSO, "snd_pcm_sw_params_current"); pContext->alsa.snd_pcm_sw_params_get_boundary = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->alsa.asoundSO, "snd_pcm_sw_params_get_boundary"); pContext->alsa.snd_pcm_sw_params_set_avail_min = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->alsa.asoundSO, "snd_pcm_sw_params_set_avail_min"); pContext->alsa.snd_pcm_sw_params_set_start_threshold = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->alsa.asoundSO, "snd_pcm_sw_params_set_start_threshold"); pContext->alsa.snd_pcm_sw_params_set_stop_threshold = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->alsa.asoundSO, "snd_pcm_sw_params_set_stop_threshold"); pContext->alsa.snd_pcm_sw_params = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->alsa.asoundSO, "snd_pcm_sw_params"); pContext->alsa.snd_pcm_format_mask_sizeof = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->alsa.asoundSO, "snd_pcm_format_mask_sizeof"); pContext->alsa.snd_pcm_format_mask_test = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->alsa.asoundSO, "snd_pcm_format_mask_test"); pContext->alsa.snd_pcm_get_chmap = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->alsa.asoundSO, "snd_pcm_get_chmap"); pContext->alsa.snd_pcm_state = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->alsa.asoundSO, "snd_pcm_state"); pContext->alsa.snd_pcm_prepare = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->alsa.asoundSO, "snd_pcm_prepare"); pContext->alsa.snd_pcm_start = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->alsa.asoundSO, "snd_pcm_start"); pContext->alsa.snd_pcm_drop = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->alsa.asoundSO, "snd_pcm_drop"); pContext->alsa.snd_pcm_drain = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->alsa.asoundSO, "snd_pcm_drain"); pContext->alsa.snd_pcm_reset = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->alsa.asoundSO, "snd_pcm_reset"); pContext->alsa.snd_device_name_hint = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->alsa.asoundSO, "snd_device_name_hint"); pContext->alsa.snd_device_name_get_hint = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->alsa.asoundSO, "snd_device_name_get_hint"); pContext->alsa.snd_card_get_index = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->alsa.asoundSO, "snd_card_get_index"); pContext->alsa.snd_device_name_free_hint = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->alsa.asoundSO, "snd_device_name_free_hint"); pContext->alsa.snd_pcm_mmap_begin = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->alsa.asoundSO, "snd_pcm_mmap_begin"); pContext->alsa.snd_pcm_mmap_commit = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->alsa.asoundSO, "snd_pcm_mmap_commit"); pContext->alsa.snd_pcm_recover = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->alsa.asoundSO, "snd_pcm_recover"); pContext->alsa.snd_pcm_readi = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->alsa.asoundSO, "snd_pcm_readi"); pContext->alsa.snd_pcm_writei = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->alsa.asoundSO, "snd_pcm_writei"); pContext->alsa.snd_pcm_avail = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->alsa.asoundSO, "snd_pcm_avail"); pContext->alsa.snd_pcm_avail_update = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->alsa.asoundSO, "snd_pcm_avail_update"); pContext->alsa.snd_pcm_wait = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->alsa.asoundSO, "snd_pcm_wait"); pContext->alsa.snd_pcm_nonblock = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->alsa.asoundSO, "snd_pcm_nonblock"); pContext->alsa.snd_pcm_info = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->alsa.asoundSO, "snd_pcm_info"); pContext->alsa.snd_pcm_info_sizeof = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->alsa.asoundSO, "snd_pcm_info_sizeof"); pContext->alsa.snd_pcm_info_get_name = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->alsa.asoundSO, "snd_pcm_info_get_name"); pContext->alsa.snd_pcm_poll_descriptors = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->alsa.asoundSO, "snd_pcm_poll_descriptors"); pContext->alsa.snd_pcm_poll_descriptors_count = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->alsa.asoundSO, "snd_pcm_poll_descriptors_count"); pContext->alsa.snd_pcm_poll_descriptors_revents = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->alsa.asoundSO, "snd_pcm_poll_descriptors_revents"); pContext->alsa.snd_config_update_free_global = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->alsa.asoundSO, "snd_config_update_free_global"); #else /* The system below is just for type safety. */ ma_snd_pcm_open_proc _snd_pcm_open = snd_pcm_open; ma_snd_pcm_close_proc _snd_pcm_close = snd_pcm_close; ma_snd_pcm_hw_params_sizeof_proc _snd_pcm_hw_params_sizeof = snd_pcm_hw_params_sizeof; ma_snd_pcm_hw_params_any_proc _snd_pcm_hw_params_any = snd_pcm_hw_params_any; ma_snd_pcm_hw_params_set_format_proc _snd_pcm_hw_params_set_format = snd_pcm_hw_params_set_format; ma_snd_pcm_hw_params_set_format_first_proc _snd_pcm_hw_params_set_format_first = snd_pcm_hw_params_set_format_first; ma_snd_pcm_hw_params_get_format_mask_proc _snd_pcm_hw_params_get_format_mask = snd_pcm_hw_params_get_format_mask; ma_snd_pcm_hw_params_set_channels_proc _snd_pcm_hw_params_set_channels = snd_pcm_hw_params_set_channels; ma_snd_pcm_hw_params_set_channels_near_proc _snd_pcm_hw_params_set_channels_near = snd_pcm_hw_params_set_channels_near; ma_snd_pcm_hw_params_set_rate_resample_proc _snd_pcm_hw_params_set_rate_resample = snd_pcm_hw_params_set_rate_resample; ma_snd_pcm_hw_params_set_rate_near _snd_pcm_hw_params_set_rate = snd_pcm_hw_params_set_rate; ma_snd_pcm_hw_params_set_rate_near_proc _snd_pcm_hw_params_set_rate_near = snd_pcm_hw_params_set_rate_near; ma_snd_pcm_hw_params_set_rate_minmax_proc _snd_pcm_hw_params_set_rate_minmax = snd_pcm_hw_params_set_rate_minmax; ma_snd_pcm_hw_params_set_buffer_size_near_proc _snd_pcm_hw_params_set_buffer_size_near = snd_pcm_hw_params_set_buffer_size_near; ma_snd_pcm_hw_params_set_periods_near_proc _snd_pcm_hw_params_set_periods_near = snd_pcm_hw_params_set_periods_near; ma_snd_pcm_hw_params_set_access_proc _snd_pcm_hw_params_set_access = snd_pcm_hw_params_set_access; ma_snd_pcm_hw_params_get_format_proc _snd_pcm_hw_params_get_format = snd_pcm_hw_params_get_format; ma_snd_pcm_hw_params_get_channels_proc _snd_pcm_hw_params_get_channels = snd_pcm_hw_params_get_channels; ma_snd_pcm_hw_params_get_channels_min_proc _snd_pcm_hw_params_get_channels_min = snd_pcm_hw_params_get_channels_min; ma_snd_pcm_hw_params_get_channels_max_proc _snd_pcm_hw_params_get_channels_max = snd_pcm_hw_params_get_channels_max; ma_snd_pcm_hw_params_get_rate_proc _snd_pcm_hw_params_get_rate = snd_pcm_hw_params_get_rate; ma_snd_pcm_hw_params_get_rate_min_proc _snd_pcm_hw_params_get_rate_min = snd_pcm_hw_params_get_rate_min; ma_snd_pcm_hw_params_get_rate_max_proc _snd_pcm_hw_params_get_rate_max = snd_pcm_hw_params_get_rate_max; ma_snd_pcm_hw_params_get_buffer_size_proc _snd_pcm_hw_params_get_buffer_size = snd_pcm_hw_params_get_buffer_size; ma_snd_pcm_hw_params_get_periods_proc _snd_pcm_hw_params_get_periods = snd_pcm_hw_params_get_periods; ma_snd_pcm_hw_params_get_access_proc _snd_pcm_hw_params_get_access = snd_pcm_hw_params_get_access; ma_snd_pcm_hw_params_test_format_proc _snd_pcm_hw_params_test_format = snd_pcm_hw_params_test_format; ma_snd_pcm_hw_params_test_channels_proc _snd_pcm_hw_params_test_channels = snd_pcm_hw_params_test_channels; ma_snd_pcm_hw_params_test_rate_proc _snd_pcm_hw_params_test_rate = snd_pcm_hw_params_test_rate; ma_snd_pcm_hw_params_proc _snd_pcm_hw_params = snd_pcm_hw_params; ma_snd_pcm_sw_params_sizeof_proc _snd_pcm_sw_params_sizeof = snd_pcm_sw_params_sizeof; ma_snd_pcm_sw_params_current_proc _snd_pcm_sw_params_current = snd_pcm_sw_params_current; ma_snd_pcm_sw_params_get_boundary_proc _snd_pcm_sw_params_get_boundary = snd_pcm_sw_params_get_boundary; ma_snd_pcm_sw_params_set_avail_min_proc _snd_pcm_sw_params_set_avail_min = snd_pcm_sw_params_set_avail_min; ma_snd_pcm_sw_params_set_start_threshold_proc _snd_pcm_sw_params_set_start_threshold = snd_pcm_sw_params_set_start_threshold; ma_snd_pcm_sw_params_set_stop_threshold_proc _snd_pcm_sw_params_set_stop_threshold = snd_pcm_sw_params_set_stop_threshold; ma_snd_pcm_sw_params_proc _snd_pcm_sw_params = snd_pcm_sw_params; ma_snd_pcm_format_mask_sizeof_proc _snd_pcm_format_mask_sizeof = snd_pcm_format_mask_sizeof; ma_snd_pcm_format_mask_test_proc _snd_pcm_format_mask_test = snd_pcm_format_mask_test; ma_snd_pcm_get_chmap_proc _snd_pcm_get_chmap = snd_pcm_get_chmap; ma_snd_pcm_state_proc _snd_pcm_state = snd_pcm_state; ma_snd_pcm_prepare_proc _snd_pcm_prepare = snd_pcm_prepare; ma_snd_pcm_start_proc _snd_pcm_start = snd_pcm_start; ma_snd_pcm_drop_proc _snd_pcm_drop = snd_pcm_drop; ma_snd_pcm_drain_proc _snd_pcm_drain = snd_pcm_drain; ma_snd_pcm_reset_proc _snd_pcm_reset = snd_pcm_reset; ma_snd_device_name_hint_proc _snd_device_name_hint = snd_device_name_hint; ma_snd_device_name_get_hint_proc _snd_device_name_get_hint = snd_device_name_get_hint; ma_snd_card_get_index_proc _snd_card_get_index = snd_card_get_index; ma_snd_device_name_free_hint_proc _snd_device_name_free_hint = snd_device_name_free_hint; ma_snd_pcm_mmap_begin_proc _snd_pcm_mmap_begin = snd_pcm_mmap_begin; ma_snd_pcm_mmap_commit_proc _snd_pcm_mmap_commit = snd_pcm_mmap_commit; ma_snd_pcm_recover_proc _snd_pcm_recover = snd_pcm_recover; ma_snd_pcm_readi_proc _snd_pcm_readi = snd_pcm_readi; ma_snd_pcm_writei_proc _snd_pcm_writei = snd_pcm_writei; ma_snd_pcm_avail_proc _snd_pcm_avail = snd_pcm_avail; ma_snd_pcm_avail_update_proc _snd_pcm_avail_update = snd_pcm_avail_update; ma_snd_pcm_wait_proc _snd_pcm_wait = snd_pcm_wait; ma_snd_pcm_nonblock_proc _snd_pcm_nonblock = snd_pcm_nonblock; ma_snd_pcm_info_proc _snd_pcm_info = snd_pcm_info; ma_snd_pcm_info_sizeof_proc _snd_pcm_info_sizeof = snd_pcm_info_sizeof; ma_snd_pcm_info_get_name_proc _snd_pcm_info_get_name = snd_pcm_info_get_name; ma_snd_pcm_poll_descriptors _snd_pcm_poll_descriptors = snd_pcm_poll_descriptors; ma_snd_pcm_poll_descriptors_count _snd_pcm_poll_descriptors_count = snd_pcm_poll_descriptors_count; ma_snd_pcm_poll_descriptors_revents _snd_pcm_poll_descriptors_revents = snd_pcm_poll_descriptors_revents; ma_snd_config_update_free_global_proc _snd_config_update_free_global = snd_config_update_free_global; pContext->alsa.snd_pcm_open = (ma_proc)_snd_pcm_open; pContext->alsa.snd_pcm_close = (ma_proc)_snd_pcm_close; pContext->alsa.snd_pcm_hw_params_sizeof = (ma_proc)_snd_pcm_hw_params_sizeof; pContext->alsa.snd_pcm_hw_params_any = (ma_proc)_snd_pcm_hw_params_any; pContext->alsa.snd_pcm_hw_params_set_format = (ma_proc)_snd_pcm_hw_params_set_format; pContext->alsa.snd_pcm_hw_params_set_format_first = (ma_proc)_snd_pcm_hw_params_set_format_first; pContext->alsa.snd_pcm_hw_params_get_format_mask = (ma_proc)_snd_pcm_hw_params_get_format_mask; pContext->alsa.snd_pcm_hw_params_set_channels = (ma_proc)_snd_pcm_hw_params_set_channels; pContext->alsa.snd_pcm_hw_params_set_channels_near = (ma_proc)_snd_pcm_hw_params_set_channels_near; pContext->alsa.snd_pcm_hw_params_set_channels_minmax = (ma_proc)_snd_pcm_hw_params_set_channels_minmax; pContext->alsa.snd_pcm_hw_params_set_rate_resample = (ma_proc)_snd_pcm_hw_params_set_rate_resample; pContext->alsa.snd_pcm_hw_params_set_rate = (ma_proc)_snd_pcm_hw_params_set_rate; pContext->alsa.snd_pcm_hw_params_set_rate_near = (ma_proc)_snd_pcm_hw_params_set_rate_near; pContext->alsa.snd_pcm_hw_params_set_buffer_size_near = (ma_proc)_snd_pcm_hw_params_set_buffer_size_near; pContext->alsa.snd_pcm_hw_params_set_periods_near = (ma_proc)_snd_pcm_hw_params_set_periods_near; pContext->alsa.snd_pcm_hw_params_set_access = (ma_proc)_snd_pcm_hw_params_set_access; pContext->alsa.snd_pcm_hw_params_get_format = (ma_proc)_snd_pcm_hw_params_get_format; pContext->alsa.snd_pcm_hw_params_get_channels = (ma_proc)_snd_pcm_hw_params_get_channels; pContext->alsa.snd_pcm_hw_params_get_channels_min = (ma_proc)_snd_pcm_hw_params_get_channels_min; pContext->alsa.snd_pcm_hw_params_get_channels_max = (ma_proc)_snd_pcm_hw_params_get_channels_max; pContext->alsa.snd_pcm_hw_params_get_rate = (ma_proc)_snd_pcm_hw_params_get_rate; pContext->alsa.snd_pcm_hw_params_get_rate_min = (ma_proc)_snd_pcm_hw_params_get_rate_min; pContext->alsa.snd_pcm_hw_params_get_rate_max = (ma_proc)_snd_pcm_hw_params_get_rate_max; pContext->alsa.snd_pcm_hw_params_get_buffer_size = (ma_proc)_snd_pcm_hw_params_get_buffer_size; pContext->alsa.snd_pcm_hw_params_get_periods = (ma_proc)_snd_pcm_hw_params_get_periods; pContext->alsa.snd_pcm_hw_params_get_access = (ma_proc)_snd_pcm_hw_params_get_access; pContext->alsa.snd_pcm_hw_params_test_format = (ma_proc)_snd_pcm_hw_params_test_format; pContext->alsa.snd_pcm_hw_params_test_channels = (ma_proc)_snd_pcm_hw_params_test_channels; pContext->alsa.snd_pcm_hw_params_test_rate = (ma_proc)_snd_pcm_hw_params_test_rate; pContext->alsa.snd_pcm_hw_params = (ma_proc)_snd_pcm_hw_params; pContext->alsa.snd_pcm_sw_params_sizeof = (ma_proc)_snd_pcm_sw_params_sizeof; pContext->alsa.snd_pcm_sw_params_current = (ma_proc)_snd_pcm_sw_params_current; pContext->alsa.snd_pcm_sw_params_get_boundary = (ma_proc)_snd_pcm_sw_params_get_boundary; pContext->alsa.snd_pcm_sw_params_set_avail_min = (ma_proc)_snd_pcm_sw_params_set_avail_min; pContext->alsa.snd_pcm_sw_params_set_start_threshold = (ma_proc)_snd_pcm_sw_params_set_start_threshold; pContext->alsa.snd_pcm_sw_params_set_stop_threshold = (ma_proc)_snd_pcm_sw_params_set_stop_threshold; pContext->alsa.snd_pcm_sw_params = (ma_proc)_snd_pcm_sw_params; pContext->alsa.snd_pcm_format_mask_sizeof = (ma_proc)_snd_pcm_format_mask_sizeof; pContext->alsa.snd_pcm_format_mask_test = (ma_proc)_snd_pcm_format_mask_test; pContext->alsa.snd_pcm_get_chmap = (ma_proc)_snd_pcm_get_chmap; pContext->alsa.snd_pcm_state = (ma_proc)_snd_pcm_state; pContext->alsa.snd_pcm_prepare = (ma_proc)_snd_pcm_prepare; pContext->alsa.snd_pcm_start = (ma_proc)_snd_pcm_start; pContext->alsa.snd_pcm_drop = (ma_proc)_snd_pcm_drop; pContext->alsa.snd_pcm_drain = (ma_proc)_snd_pcm_drain; pContext->alsa.snd_pcm_reset = (ma_proc)_snd_pcm_reset; pContext->alsa.snd_device_name_hint = (ma_proc)_snd_device_name_hint; pContext->alsa.snd_device_name_get_hint = (ma_proc)_snd_device_name_get_hint; pContext->alsa.snd_card_get_index = (ma_proc)_snd_card_get_index; pContext->alsa.snd_device_name_free_hint = (ma_proc)_snd_device_name_free_hint; pContext->alsa.snd_pcm_mmap_begin = (ma_proc)_snd_pcm_mmap_begin; pContext->alsa.snd_pcm_mmap_commit = (ma_proc)_snd_pcm_mmap_commit; pContext->alsa.snd_pcm_recover = (ma_proc)_snd_pcm_recover; pContext->alsa.snd_pcm_readi = (ma_proc)_snd_pcm_readi; pContext->alsa.snd_pcm_writei = (ma_proc)_snd_pcm_writei; pContext->alsa.snd_pcm_avail = (ma_proc)_snd_pcm_avail; pContext->alsa.snd_pcm_avail_update = (ma_proc)_snd_pcm_avail_update; pContext->alsa.snd_pcm_wait = (ma_proc)_snd_pcm_wait; pContext->alsa.snd_pcm_nonblock = (ma_proc)_snd_pcm_nonblock; pContext->alsa.snd_pcm_info = (ma_proc)_snd_pcm_info; pContext->alsa.snd_pcm_info_sizeof = (ma_proc)_snd_pcm_info_sizeof; pContext->alsa.snd_pcm_info_get_name = (ma_proc)_snd_pcm_info_get_name; pContext->alsa.snd_pcm_poll_descriptors = (ma_proc)_snd_pcm_poll_descriptors; pContext->alsa.snd_pcm_poll_descriptors_count = (ma_proc)_snd_pcm_poll_descriptors_count; pContext->alsa.snd_pcm_poll_descriptors_revents = (ma_proc)_snd_pcm_poll_descriptors_revents; pContext->alsa.snd_config_update_free_global = (ma_proc)_snd_config_update_free_global; #endif pContext->alsa.useVerboseDeviceEnumeration = pConfig->alsa.useVerboseDeviceEnumeration; result = ma_mutex_init(&pContext->alsa.internalDeviceEnumLock); if (result != MA_SUCCESS) { ma_log_postf(ma_context_get_log(pContext), MA_LOG_LEVEL_ERROR, "[ALSA] WARNING: Failed to initialize mutex for internal device enumeration."); return result; } pCallbacks->onContextInit = ma_context_init__alsa; pCallbacks->onContextUninit = ma_context_uninit__alsa; pCallbacks->onContextEnumerateDevices = ma_context_enumerate_devices__alsa; pCallbacks->onContextGetDeviceInfo = ma_context_get_device_info__alsa; pCallbacks->onDeviceInit = ma_device_init__alsa; pCallbacks->onDeviceUninit = ma_device_uninit__alsa; pCallbacks->onDeviceStart = ma_device_start__alsa; pCallbacks->onDeviceStop = ma_device_stop__alsa; pCallbacks->onDeviceRead = ma_device_read__alsa; pCallbacks->onDeviceWrite = ma_device_write__alsa; pCallbacks->onDeviceDataLoop = NULL; pCallbacks->onDeviceDataLoopWakeup = ma_device_data_loop_wakeup__alsa; return MA_SUCCESS; } #endif /* ALSA */ /****************************************************************************** PulseAudio Backend ******************************************************************************/ #ifdef MA_HAS_PULSEAUDIO /* The PulseAudio API, along with Apple's Core Audio, is the worst of the maintream audio APIs. This is a brief description of what's going on in the PulseAudio backend. I apologize if this gets a bit ranty for your liking - you might want to skip this discussion. PulseAudio has something they call the "Simple API", which unfortunately isn't suitable for miniaudio. I've not seen anywhere where it allows you to enumerate over devices, nor does it seem to support the ability to stop and start streams. Looking at the documentation, it appears as though the stream is constantly running and you prevent sound from being emitted or captured by simply not calling the read or write functions. This is not a professional solution as it would be much better to *actually* stop the underlying stream. Perhaps the simple API has some smarts to do this automatically, but I'm not sure. Another limitation with the simple API is that it seems inefficient when you want to have multiple streams to a single context. For these reasons, miniaudio is not using the simple API. Since we're not using the simple API, we're left with the asynchronous API as our only other option. And boy, is this where it starts to get fun, and I don't mean that in a good way... The problems start with the very name of the API - "asynchronous". Yes, this is an asynchronous oriented API which means your commands don't immediately take effect. You instead need to issue your commands, and then wait for them to complete. The waiting mechanism is enabled through the use of a "main loop". In the asychronous API you cannot get away from the main loop, and the main loop is where almost all of PulseAudio's problems stem from. When you first initialize PulseAudio you need an object referred to as "main loop". You can implement this yourself by defining your own vtable, but it's much easier to just use one of the built-in main loop implementations. There's two generic implementations called pa_mainloop and pa_threaded_mainloop, and another implementation specific to GLib called pa_glib_mainloop. We're using pa_threaded_mainloop because it simplifies management of the worker thread. The idea of the main loop object is pretty self explanatory - you're supposed to use it to implement a worker thread which runs in a loop. The main loop is where operations are actually executed. To initialize the main loop, you just use `pa_threaded_mainloop_new()`. This is the first function you'll call. You can then get a pointer to the vtable with `pa_threaded_mainloop_get_api()` (the main loop vtable is called `pa_mainloop_api`). Again, you can bypass the threaded main loop object entirely and just implement `pa_mainloop_api` directly, but there's no need for it unless you're doing something extremely specialized such as if you want to integrate it into your application's existing main loop infrastructure. (EDIT 2021-01-26: miniaudio is no longer using `pa_threaded_mainloop` due to this issue: https://github.com/mackron/miniaudio/issues/262. It is now using `pa_mainloop` which turns out to be a simpler solution anyway. The rest of this rant still applies, however.) Once you have your main loop vtable (the `pa_mainloop_api` object) you can create the PulseAudio context. This is very similar to miniaudio's context and they map to each other quite well. You have one context to many streams, which is basically the same as miniaudio's one `ma_context` to many `ma_device`s. Here's where it starts to get annoying, however. When you first create the PulseAudio context, which is done with `pa_context_new()`, it's not actually connected to anything. When you connect, you call `pa_context_connect()`. However, if you remember, PulseAudio is an asynchronous API. That means you cannot just assume the context is connected after `pa_context_context()` has returned. You instead need to wait for it to connect. To do this, you need to either wait for a callback to get fired, which you can set with `pa_context_set_state_callback()`, or you can continuously poll the context's state. Either way, you need to run this in a loop. All objects from here out are created from the context, and, I believe, you can't be creating these objects until the context is connected. This waiting loop is therefore unavoidable. In order for the waiting to ever complete, however, the main loop needs to be running. Before attempting to connect the context, the main loop needs to be started with `pa_threaded_mainloop_start()`. The reason for this asynchronous design is to support cases where you're connecting to a remote server, say through a local network or an internet connection. However, the *VAST* majority of cases don't involve this at all - they just connect to a local "server" running on the host machine. The fact that this would be the default rather than making `pa_context_connect()` synchronous tends to boggle the mind. Once the context has been created and connected you can start creating a stream. A PulseAudio stream is analogous to miniaudio's device. The initialization of a stream is fairly standard - you configure some attributes (analogous to miniaudio's device config) and then call `pa_stream_new()` to actually create it. Here is where we start to get into "operations". When configuring the stream, you can get information about the source (such as sample format, sample rate, etc.), however it's not synchronous. Instead, a `pa_operation` object is returned from `pa_context_get_source_info_by_name()` (capture) or `pa_context_get_sink_info_by_name()` (playback). Then, you need to run a loop (again!) to wait for the operation to complete which you can determine via a callback or polling, just like we did with the context. Then, as an added bonus, you need to decrement the reference counter of the `pa_operation` object to ensure memory is cleaned up. All of that just to retrieve basic information about a device! Once the basic information about the device has been retrieved, miniaudio can now create the stream with `ma_stream_new()`. Like the context, this needs to be connected. But we need to be careful here, because we're now about to introduce one of the most horrific design choices in PulseAudio. PulseAudio allows you to specify a callback that is fired when data can be written to or read from a stream. The language is important here because PulseAudio takes it literally, specifically the "can be". You would think these callbacks would be appropriate as the place for writing and reading data to and from the stream, and that would be right, except when it's not. When you initialize the stream, you can set a flag that tells PulseAudio to not start the stream automatically. This is required because miniaudio does not auto-start devices straight after initialization - you need to call `ma_device_start()` manually. The problem is that even when this flag is specified, PulseAudio will immediately fire it's write or read callback. This is *technically* correct (based on the wording in the documentation) because indeed, data *can* be written at this point. The problem is that it's not *practical*. It makes sense that the write/read callback would be where a program will want to write or read data to or from the stream, but when it's called before the application has even requested that the stream be started, it's just not practical because the program probably isn't ready for any kind of data delivery at that point (it may still need to load files or whatnot). Instead, this callback should only be fired when the application requests the stream be started which is how it works with literally *every* other callback-based audio API. Since miniaudio forbids firing of the data callback until the device has been started (as it should be with *all* callback based APIs), logic needs to be added to ensure miniaudio doesn't just blindly fire the application-defined data callback from within the PulseAudio callback before the stream has actually been started. The device state is used for this - if the state is anything other than `ma_device_state_starting` or `ma_device_state_started`, the main data callback is not fired. This, unfortunately, is not the end of the problems with the PulseAudio write callback. Any normal callback based audio API will continuously fire the callback at regular intervals based on the size of the internal buffer. This will only ever be fired when the device is running, and will be fired regardless of whether or not the user actually wrote anything to the device/stream. This not the case in PulseAudio. In PulseAudio, the data callback will *only* be called if you wrote something to it previously. That means, if you don't call `pa_stream_write()`, the callback will not get fired. On the surface you wouldn't think this would matter because you should be always writing data, and if you don't have anything to write, just write silence. That's fine until you want to drain the stream. You see, if you're continuously writing data to the stream, the stream will never get drained! That means in order to drain the stream, you need to *not* write data to it! But remember, when you don't write data to the stream, the callback won't get fired again! Why is draining important? Because that's how we've defined stopping to work in miniaudio. In miniaudio, stopping the device requires it to be drained before returning from ma_device_stop(). So we've stopped the device, which requires us to drain, but draining requires us to *not* write data to the stream (or else it won't ever complete draining), but not writing to the stream means the callback won't get fired again! This becomes a problem when stopping and then restarting the device. When the device is stopped, it's drained, which requires us to *not* write anything to the stream. But then, since we didn't write anything to it, the write callback will *never* get called again if we just resume the stream naively. This means that starting the stream requires us to write data to the stream from outside the callback. This disconnect is something PulseAudio has got seriously wrong - there should only ever be a single source of data delivery, that being the callback. (I have tried using `pa_stream_flush()` to trigger the write callback to fire, but this just doesn't work for some reason.) Once you've created the stream, you need to connect it which involves the whole waiting procedure. This is the same process as the context, only this time you'll poll for the state with `pa_stream_get_status()`. The starting and stopping of a streaming is referred to as "corking" in PulseAudio. The analogy is corking a barrel. To start the stream, you uncork it, to stop it you cork it. Personally I think it's silly - why would you not just call it "starting" and "stopping" like any other normal audio API? Anyway, the act of corking is, you guessed it, asynchronous. This means you'll need our waiting loop as usual. Again, why this asynchronous design is the default is absolutely beyond me. Would it really be that hard to just make it run synchronously? Teardown is pretty simple (what?!). It's just a matter of calling the relevant `_unref()` function on each object in reverse order that they were initialized in. That's about it from the PulseAudio side. A bit ranty, I know, but they really need to fix that main loop and callback system. They're embarrassingly unpractical. The main loop thing is an easy fix - have synchronous versions of all APIs. If an application wants these to run asynchronously, they can execute them in a separate thread themselves. The desire to run these asynchronously is such a niche requirement - it makes no sense to make it the default. The stream write callback needs to be change, or an alternative provided, that is constantly fired, regardless of whether or not `pa_stream_write()` has been called, and it needs to take a pointer to a buffer as a parameter which the program just writes to directly rather than having to call `pa_stream_writable_size()` and `pa_stream_write()`. These changes alone will change PulseAudio from one of the worst audio APIs to one of the best. */ /* It is assumed pulseaudio.h is available when linking at compile time. When linking at compile time, we use the declarations in the header to check for type safety. We cannot do this when linking at run time because the header might not be available. */ #ifdef MA_NO_RUNTIME_LINKING /* pulseaudio.h marks some functions with "inline" which isn't always supported. Need to emulate it. */ #if !defined(__cplusplus) #if defined(__STRICT_ANSI__) #if !defined(inline) #define inline __inline__ __attribute__((always_inline)) #define MA_INLINE_DEFINED #endif #endif #endif #include #if defined(MA_INLINE_DEFINED) #undef inline #undef MA_INLINE_DEFINED #endif #define MA_PA_OK PA_OK #define MA_PA_ERR_ACCESS PA_ERR_ACCESS #define MA_PA_ERR_INVALID PA_ERR_INVALID #define MA_PA_ERR_NOENTITY PA_ERR_NOENTITY #define MA_PA_ERR_NOTSUPPORTED PA_ERR_NOTSUPPORTED #define MA_PA_CHANNELS_MAX PA_CHANNELS_MAX #define MA_PA_RATE_MAX PA_RATE_MAX typedef pa_context_flags_t ma_pa_context_flags_t; #define MA_PA_CONTEXT_NOFLAGS PA_CONTEXT_NOFLAGS #define MA_PA_CONTEXT_NOAUTOSPAWN PA_CONTEXT_NOAUTOSPAWN #define MA_PA_CONTEXT_NOFAIL PA_CONTEXT_NOFAIL typedef pa_stream_flags_t ma_pa_stream_flags_t; #define MA_PA_STREAM_NOFLAGS PA_STREAM_NOFLAGS #define MA_PA_STREAM_START_CORKED PA_STREAM_START_CORKED #define MA_PA_STREAM_INTERPOLATE_TIMING PA_STREAM_INTERPOLATE_TIMING #define MA_PA_STREAM_NOT_MONOTONIC PA_STREAM_NOT_MONOTONIC #define MA_PA_STREAM_AUTO_TIMING_UPDATE PA_STREAM_AUTO_TIMING_UPDATE #define MA_PA_STREAM_NO_REMAP_CHANNELS PA_STREAM_NO_REMAP_CHANNELS #define MA_PA_STREAM_NO_REMIX_CHANNELS PA_STREAM_NO_REMIX_CHANNELS #define MA_PA_STREAM_FIX_FORMAT PA_STREAM_FIX_FORMAT #define MA_PA_STREAM_FIX_RATE PA_STREAM_FIX_RATE #define MA_PA_STREAM_FIX_CHANNELS PA_STREAM_FIX_CHANNELS #define MA_PA_STREAM_DONT_MOVE PA_STREAM_DONT_MOVE #define MA_PA_STREAM_VARIABLE_RATE PA_STREAM_VARIABLE_RATE #define MA_PA_STREAM_PEAK_DETECT PA_STREAM_PEAK_DETECT #define MA_PA_STREAM_START_MUTED PA_STREAM_START_MUTED #define MA_PA_STREAM_ADJUST_LATENCY PA_STREAM_ADJUST_LATENCY #define MA_PA_STREAM_EARLY_REQUESTS PA_STREAM_EARLY_REQUESTS #define MA_PA_STREAM_DONT_INHIBIT_AUTO_SUSPEND PA_STREAM_DONT_INHIBIT_AUTO_SUSPEND #define MA_PA_STREAM_START_UNMUTED PA_STREAM_START_UNMUTED #define MA_PA_STREAM_FAIL_ON_SUSPEND PA_STREAM_FAIL_ON_SUSPEND #define MA_PA_STREAM_RELATIVE_VOLUME PA_STREAM_RELATIVE_VOLUME #define MA_PA_STREAM_PASSTHROUGH PA_STREAM_PASSTHROUGH typedef pa_sink_flags_t ma_pa_sink_flags_t; #define MA_PA_SINK_NOFLAGS PA_SINK_NOFLAGS #define MA_PA_SINK_HW_VOLUME_CTRL PA_SINK_HW_VOLUME_CTRL #define MA_PA_SINK_LATENCY PA_SINK_LATENCY #define MA_PA_SINK_HARDWARE PA_SINK_HARDWARE #define MA_PA_SINK_NETWORK PA_SINK_NETWORK #define MA_PA_SINK_HW_MUTE_CTRL PA_SINK_HW_MUTE_CTRL #define MA_PA_SINK_DECIBEL_VOLUME PA_SINK_DECIBEL_VOLUME #define MA_PA_SINK_FLAT_VOLUME PA_SINK_FLAT_VOLUME #define MA_PA_SINK_DYNAMIC_LATENCY PA_SINK_DYNAMIC_LATENCY #define MA_PA_SINK_SET_FORMATS PA_SINK_SET_FORMATS typedef pa_source_flags_t ma_pa_source_flags_t; #define MA_PA_SOURCE_NOFLAGS PA_SOURCE_NOFLAGS #define MA_PA_SOURCE_HW_VOLUME_CTRL PA_SOURCE_HW_VOLUME_CTRL #define MA_PA_SOURCE_LATENCY PA_SOURCE_LATENCY #define MA_PA_SOURCE_HARDWARE PA_SOURCE_HARDWARE #define MA_PA_SOURCE_NETWORK PA_SOURCE_NETWORK #define MA_PA_SOURCE_HW_MUTE_CTRL PA_SOURCE_HW_MUTE_CTRL #define MA_PA_SOURCE_DECIBEL_VOLUME PA_SOURCE_DECIBEL_VOLUME #define MA_PA_SOURCE_DYNAMIC_LATENCY PA_SOURCE_DYNAMIC_LATENCY #define MA_PA_SOURCE_FLAT_VOLUME PA_SOURCE_FLAT_VOLUME typedef pa_context_state_t ma_pa_context_state_t; #define MA_PA_CONTEXT_UNCONNECTED PA_CONTEXT_UNCONNECTED #define MA_PA_CONTEXT_CONNECTING PA_CONTEXT_CONNECTING #define MA_PA_CONTEXT_AUTHORIZING PA_CONTEXT_AUTHORIZING #define MA_PA_CONTEXT_SETTING_NAME PA_CONTEXT_SETTING_NAME #define MA_PA_CONTEXT_READY PA_CONTEXT_READY #define MA_PA_CONTEXT_FAILED PA_CONTEXT_FAILED #define MA_PA_CONTEXT_TERMINATED PA_CONTEXT_TERMINATED typedef pa_stream_state_t ma_pa_stream_state_t; #define MA_PA_STREAM_UNCONNECTED PA_STREAM_UNCONNECTED #define MA_PA_STREAM_CREATING PA_STREAM_CREATING #define MA_PA_STREAM_READY PA_STREAM_READY #define MA_PA_STREAM_FAILED PA_STREAM_FAILED #define MA_PA_STREAM_TERMINATED PA_STREAM_TERMINATED typedef pa_operation_state_t ma_pa_operation_state_t; #define MA_PA_OPERATION_RUNNING PA_OPERATION_RUNNING #define MA_PA_OPERATION_DONE PA_OPERATION_DONE #define MA_PA_OPERATION_CANCELLED PA_OPERATION_CANCELLED typedef pa_sink_state_t ma_pa_sink_state_t; #define MA_PA_SINK_INVALID_STATE PA_SINK_INVALID_STATE #define MA_PA_SINK_RUNNING PA_SINK_RUNNING #define MA_PA_SINK_IDLE PA_SINK_IDLE #define MA_PA_SINK_SUSPENDED PA_SINK_SUSPENDED typedef pa_source_state_t ma_pa_source_state_t; #define MA_PA_SOURCE_INVALID_STATE PA_SOURCE_INVALID_STATE #define MA_PA_SOURCE_RUNNING PA_SOURCE_RUNNING #define MA_PA_SOURCE_IDLE PA_SOURCE_IDLE #define MA_PA_SOURCE_SUSPENDED PA_SOURCE_SUSPENDED typedef pa_seek_mode_t ma_pa_seek_mode_t; #define MA_PA_SEEK_RELATIVE PA_SEEK_RELATIVE #define MA_PA_SEEK_ABSOLUTE PA_SEEK_ABSOLUTE #define MA_PA_SEEK_RELATIVE_ON_READ PA_SEEK_RELATIVE_ON_READ #define MA_PA_SEEK_RELATIVE_END PA_SEEK_RELATIVE_END typedef pa_channel_position_t ma_pa_channel_position_t; #define MA_PA_CHANNEL_POSITION_INVALID PA_CHANNEL_POSITION_INVALID #define MA_PA_CHANNEL_POSITION_MONO PA_CHANNEL_POSITION_MONO #define MA_PA_CHANNEL_POSITION_FRONT_LEFT PA_CHANNEL_POSITION_FRONT_LEFT #define MA_PA_CHANNEL_POSITION_FRONT_RIGHT PA_CHANNEL_POSITION_FRONT_RIGHT #define MA_PA_CHANNEL_POSITION_FRONT_CENTER PA_CHANNEL_POSITION_FRONT_CENTER #define MA_PA_CHANNEL_POSITION_REAR_CENTER PA_CHANNEL_POSITION_REAR_CENTER #define MA_PA_CHANNEL_POSITION_REAR_LEFT PA_CHANNEL_POSITION_REAR_LEFT #define MA_PA_CHANNEL_POSITION_REAR_RIGHT PA_CHANNEL_POSITION_REAR_RIGHT #define MA_PA_CHANNEL_POSITION_LFE PA_CHANNEL_POSITION_LFE #define MA_PA_CHANNEL_POSITION_FRONT_LEFT_OF_CENTER PA_CHANNEL_POSITION_FRONT_LEFT_OF_CENTER #define MA_PA_CHANNEL_POSITION_FRONT_RIGHT_OF_CENTER PA_CHANNEL_POSITION_FRONT_RIGHT_OF_CENTER #define MA_PA_CHANNEL_POSITION_SIDE_LEFT PA_CHANNEL_POSITION_SIDE_LEFT #define MA_PA_CHANNEL_POSITION_SIDE_RIGHT PA_CHANNEL_POSITION_SIDE_RIGHT #define MA_PA_CHANNEL_POSITION_AUX0 PA_CHANNEL_POSITION_AUX0 #define MA_PA_CHANNEL_POSITION_AUX1 PA_CHANNEL_POSITION_AUX1 #define MA_PA_CHANNEL_POSITION_AUX2 PA_CHANNEL_POSITION_AUX2 #define MA_PA_CHANNEL_POSITION_AUX3 PA_CHANNEL_POSITION_AUX3 #define MA_PA_CHANNEL_POSITION_AUX4 PA_CHANNEL_POSITION_AUX4 #define MA_PA_CHANNEL_POSITION_AUX5 PA_CHANNEL_POSITION_AUX5 #define MA_PA_CHANNEL_POSITION_AUX6 PA_CHANNEL_POSITION_AUX6 #define MA_PA_CHANNEL_POSITION_AUX7 PA_CHANNEL_POSITION_AUX7 #define MA_PA_CHANNEL_POSITION_AUX8 PA_CHANNEL_POSITION_AUX8 #define MA_PA_CHANNEL_POSITION_AUX9 PA_CHANNEL_POSITION_AUX9 #define MA_PA_CHANNEL_POSITION_AUX10 PA_CHANNEL_POSITION_AUX10 #define MA_PA_CHANNEL_POSITION_AUX11 PA_CHANNEL_POSITION_AUX11 #define MA_PA_CHANNEL_POSITION_AUX12 PA_CHANNEL_POSITION_AUX12 #define MA_PA_CHANNEL_POSITION_AUX13 PA_CHANNEL_POSITION_AUX13 #define MA_PA_CHANNEL_POSITION_AUX14 PA_CHANNEL_POSITION_AUX14 #define MA_PA_CHANNEL_POSITION_AUX15 PA_CHANNEL_POSITION_AUX15 #define MA_PA_CHANNEL_POSITION_AUX16 PA_CHANNEL_POSITION_AUX16 #define MA_PA_CHANNEL_POSITION_AUX17 PA_CHANNEL_POSITION_AUX17 #define MA_PA_CHANNEL_POSITION_AUX18 PA_CHANNEL_POSITION_AUX18 #define MA_PA_CHANNEL_POSITION_AUX19 PA_CHANNEL_POSITION_AUX19 #define MA_PA_CHANNEL_POSITION_AUX20 PA_CHANNEL_POSITION_AUX20 #define MA_PA_CHANNEL_POSITION_AUX21 PA_CHANNEL_POSITION_AUX21 #define MA_PA_CHANNEL_POSITION_AUX22 PA_CHANNEL_POSITION_AUX22 #define MA_PA_CHANNEL_POSITION_AUX23 PA_CHANNEL_POSITION_AUX23 #define MA_PA_CHANNEL_POSITION_AUX24 PA_CHANNEL_POSITION_AUX24 #define MA_PA_CHANNEL_POSITION_AUX25 PA_CHANNEL_POSITION_AUX25 #define MA_PA_CHANNEL_POSITION_AUX26 PA_CHANNEL_POSITION_AUX26 #define MA_PA_CHANNEL_POSITION_AUX27 PA_CHANNEL_POSITION_AUX27 #define MA_PA_CHANNEL_POSITION_AUX28 PA_CHANNEL_POSITION_AUX28 #define MA_PA_CHANNEL_POSITION_AUX29 PA_CHANNEL_POSITION_AUX29 #define MA_PA_CHANNEL_POSITION_AUX30 PA_CHANNEL_POSITION_AUX30 #define MA_PA_CHANNEL_POSITION_AUX31 PA_CHANNEL_POSITION_AUX31 #define MA_PA_CHANNEL_POSITION_TOP_CENTER PA_CHANNEL_POSITION_TOP_CENTER #define MA_PA_CHANNEL_POSITION_TOP_FRONT_LEFT PA_CHANNEL_POSITION_TOP_FRONT_LEFT #define MA_PA_CHANNEL_POSITION_TOP_FRONT_RIGHT PA_CHANNEL_POSITION_TOP_FRONT_RIGHT #define MA_PA_CHANNEL_POSITION_TOP_FRONT_CENTER PA_CHANNEL_POSITION_TOP_FRONT_CENTER #define MA_PA_CHANNEL_POSITION_TOP_REAR_LEFT PA_CHANNEL_POSITION_TOP_REAR_LEFT #define MA_PA_CHANNEL_POSITION_TOP_REAR_RIGHT PA_CHANNEL_POSITION_TOP_REAR_RIGHT #define MA_PA_CHANNEL_POSITION_TOP_REAR_CENTER PA_CHANNEL_POSITION_TOP_REAR_CENTER #define MA_PA_CHANNEL_POSITION_LEFT PA_CHANNEL_POSITION_LEFT #define MA_PA_CHANNEL_POSITION_RIGHT PA_CHANNEL_POSITION_RIGHT #define MA_PA_CHANNEL_POSITION_CENTER PA_CHANNEL_POSITION_CENTER #define MA_PA_CHANNEL_POSITION_SUBWOOFER PA_CHANNEL_POSITION_SUBWOOFER typedef pa_channel_map_def_t ma_pa_channel_map_def_t; #define MA_PA_CHANNEL_MAP_AIFF PA_CHANNEL_MAP_AIFF #define MA_PA_CHANNEL_MAP_ALSA PA_CHANNEL_MAP_ALSA #define MA_PA_CHANNEL_MAP_AUX PA_CHANNEL_MAP_AUX #define MA_PA_CHANNEL_MAP_WAVEEX PA_CHANNEL_MAP_WAVEEX #define MA_PA_CHANNEL_MAP_OSS PA_CHANNEL_MAP_OSS #define MA_PA_CHANNEL_MAP_DEFAULT PA_CHANNEL_MAP_DEFAULT typedef pa_sample_format_t ma_pa_sample_format_t; #define MA_PA_SAMPLE_INVALID PA_SAMPLE_INVALID #define MA_PA_SAMPLE_U8 PA_SAMPLE_U8 #define MA_PA_SAMPLE_ALAW PA_SAMPLE_ALAW #define MA_PA_SAMPLE_ULAW PA_SAMPLE_ULAW #define MA_PA_SAMPLE_S16LE PA_SAMPLE_S16LE #define MA_PA_SAMPLE_S16BE PA_SAMPLE_S16BE #define MA_PA_SAMPLE_FLOAT32LE PA_SAMPLE_FLOAT32LE #define MA_PA_SAMPLE_FLOAT32BE PA_SAMPLE_FLOAT32BE #define MA_PA_SAMPLE_S32LE PA_SAMPLE_S32LE #define MA_PA_SAMPLE_S32BE PA_SAMPLE_S32BE #define MA_PA_SAMPLE_S24LE PA_SAMPLE_S24LE #define MA_PA_SAMPLE_S24BE PA_SAMPLE_S24BE #define MA_PA_SAMPLE_S24_32LE PA_SAMPLE_S24_32LE #define MA_PA_SAMPLE_S24_32BE PA_SAMPLE_S24_32BE typedef pa_mainloop ma_pa_mainloop; typedef pa_threaded_mainloop ma_pa_threaded_mainloop; typedef pa_mainloop_api ma_pa_mainloop_api; typedef pa_context ma_pa_context; typedef pa_operation ma_pa_operation; typedef pa_stream ma_pa_stream; typedef pa_spawn_api ma_pa_spawn_api; typedef pa_buffer_attr ma_pa_buffer_attr; typedef pa_channel_map ma_pa_channel_map; typedef pa_cvolume ma_pa_cvolume; typedef pa_sample_spec ma_pa_sample_spec; typedef pa_sink_info ma_pa_sink_info; typedef pa_source_info ma_pa_source_info; typedef pa_context_notify_cb_t ma_pa_context_notify_cb_t; typedef pa_sink_info_cb_t ma_pa_sink_info_cb_t; typedef pa_source_info_cb_t ma_pa_source_info_cb_t; typedef pa_stream_success_cb_t ma_pa_stream_success_cb_t; typedef pa_stream_request_cb_t ma_pa_stream_request_cb_t; typedef pa_stream_notify_cb_t ma_pa_stream_notify_cb_t; typedef pa_free_cb_t ma_pa_free_cb_t; #else #define MA_PA_OK 0 #define MA_PA_ERR_ACCESS 1 #define MA_PA_ERR_INVALID 2 #define MA_PA_ERR_NOENTITY 5 #define MA_PA_ERR_NOTSUPPORTED 19 #define MA_PA_CHANNELS_MAX 32 #define MA_PA_RATE_MAX 384000 typedef int ma_pa_context_flags_t; #define MA_PA_CONTEXT_NOFLAGS 0x00000000 #define MA_PA_CONTEXT_NOAUTOSPAWN 0x00000001 #define MA_PA_CONTEXT_NOFAIL 0x00000002 typedef int ma_pa_stream_flags_t; #define MA_PA_STREAM_NOFLAGS 0x00000000 #define MA_PA_STREAM_START_CORKED 0x00000001 #define MA_PA_STREAM_INTERPOLATE_TIMING 0x00000002 #define MA_PA_STREAM_NOT_MONOTONIC 0x00000004 #define MA_PA_STREAM_AUTO_TIMING_UPDATE 0x00000008 #define MA_PA_STREAM_NO_REMAP_CHANNELS 0x00000010 #define MA_PA_STREAM_NO_REMIX_CHANNELS 0x00000020 #define MA_PA_STREAM_FIX_FORMAT 0x00000040 #define MA_PA_STREAM_FIX_RATE 0x00000080 #define MA_PA_STREAM_FIX_CHANNELS 0x00000100 #define MA_PA_STREAM_DONT_MOVE 0x00000200 #define MA_PA_STREAM_VARIABLE_RATE 0x00000400 #define MA_PA_STREAM_PEAK_DETECT 0x00000800 #define MA_PA_STREAM_START_MUTED 0x00001000 #define MA_PA_STREAM_ADJUST_LATENCY 0x00002000 #define MA_PA_STREAM_EARLY_REQUESTS 0x00004000 #define MA_PA_STREAM_DONT_INHIBIT_AUTO_SUSPEND 0x00008000 #define MA_PA_STREAM_START_UNMUTED 0x00010000 #define MA_PA_STREAM_FAIL_ON_SUSPEND 0x00020000 #define MA_PA_STREAM_RELATIVE_VOLUME 0x00040000 #define MA_PA_STREAM_PASSTHROUGH 0x00080000 typedef int ma_pa_sink_flags_t; #define MA_PA_SINK_NOFLAGS 0x00000000 #define MA_PA_SINK_HW_VOLUME_CTRL 0x00000001 #define MA_PA_SINK_LATENCY 0x00000002 #define MA_PA_SINK_HARDWARE 0x00000004 #define MA_PA_SINK_NETWORK 0x00000008 #define MA_PA_SINK_HW_MUTE_CTRL 0x00000010 #define MA_PA_SINK_DECIBEL_VOLUME 0x00000020 #define MA_PA_SINK_FLAT_VOLUME 0x00000040 #define MA_PA_SINK_DYNAMIC_LATENCY 0x00000080 #define MA_PA_SINK_SET_FORMATS 0x00000100 typedef int ma_pa_source_flags_t; #define MA_PA_SOURCE_NOFLAGS 0x00000000 #define MA_PA_SOURCE_HW_VOLUME_CTRL 0x00000001 #define MA_PA_SOURCE_LATENCY 0x00000002 #define MA_PA_SOURCE_HARDWARE 0x00000004 #define MA_PA_SOURCE_NETWORK 0x00000008 #define MA_PA_SOURCE_HW_MUTE_CTRL 0x00000010 #define MA_PA_SOURCE_DECIBEL_VOLUME 0x00000020 #define MA_PA_SOURCE_DYNAMIC_LATENCY 0x00000040 #define MA_PA_SOURCE_FLAT_VOLUME 0x00000080 typedef int ma_pa_context_state_t; #define MA_PA_CONTEXT_UNCONNECTED 0 #define MA_PA_CONTEXT_CONNECTING 1 #define MA_PA_CONTEXT_AUTHORIZING 2 #define MA_PA_CONTEXT_SETTING_NAME 3 #define MA_PA_CONTEXT_READY 4 #define MA_PA_CONTEXT_FAILED 5 #define MA_PA_CONTEXT_TERMINATED 6 typedef int ma_pa_stream_state_t; #define MA_PA_STREAM_UNCONNECTED 0 #define MA_PA_STREAM_CREATING 1 #define MA_PA_STREAM_READY 2 #define MA_PA_STREAM_FAILED 3 #define MA_PA_STREAM_TERMINATED 4 typedef int ma_pa_operation_state_t; #define MA_PA_OPERATION_RUNNING 0 #define MA_PA_OPERATION_DONE 1 #define MA_PA_OPERATION_CANCELLED 2 typedef int ma_pa_sink_state_t; #define MA_PA_SINK_INVALID_STATE -1 #define MA_PA_SINK_RUNNING 0 #define MA_PA_SINK_IDLE 1 #define MA_PA_SINK_SUSPENDED 2 typedef int ma_pa_source_state_t; #define MA_PA_SOURCE_INVALID_STATE -1 #define MA_PA_SOURCE_RUNNING 0 #define MA_PA_SOURCE_IDLE 1 #define MA_PA_SOURCE_SUSPENDED 2 typedef int ma_pa_seek_mode_t; #define MA_PA_SEEK_RELATIVE 0 #define MA_PA_SEEK_ABSOLUTE 1 #define MA_PA_SEEK_RELATIVE_ON_READ 2 #define MA_PA_SEEK_RELATIVE_END 3 typedef int ma_pa_channel_position_t; #define MA_PA_CHANNEL_POSITION_INVALID -1 #define MA_PA_CHANNEL_POSITION_MONO 0 #define MA_PA_CHANNEL_POSITION_FRONT_LEFT 1 #define MA_PA_CHANNEL_POSITION_FRONT_RIGHT 2 #define MA_PA_CHANNEL_POSITION_FRONT_CENTER 3 #define MA_PA_CHANNEL_POSITION_REAR_CENTER 4 #define MA_PA_CHANNEL_POSITION_REAR_LEFT 5 #define MA_PA_CHANNEL_POSITION_REAR_RIGHT 6 #define MA_PA_CHANNEL_POSITION_LFE 7 #define MA_PA_CHANNEL_POSITION_FRONT_LEFT_OF_CENTER 8 #define MA_PA_CHANNEL_POSITION_FRONT_RIGHT_OF_CENTER 9 #define MA_PA_CHANNEL_POSITION_SIDE_LEFT 10 #define MA_PA_CHANNEL_POSITION_SIDE_RIGHT 11 #define MA_PA_CHANNEL_POSITION_AUX0 12 #define MA_PA_CHANNEL_POSITION_AUX1 13 #define MA_PA_CHANNEL_POSITION_AUX2 14 #define MA_PA_CHANNEL_POSITION_AUX3 15 #define MA_PA_CHANNEL_POSITION_AUX4 16 #define MA_PA_CHANNEL_POSITION_AUX5 17 #define MA_PA_CHANNEL_POSITION_AUX6 18 #define MA_PA_CHANNEL_POSITION_AUX7 19 #define MA_PA_CHANNEL_POSITION_AUX8 20 #define MA_PA_CHANNEL_POSITION_AUX9 21 #define MA_PA_CHANNEL_POSITION_AUX10 22 #define MA_PA_CHANNEL_POSITION_AUX11 23 #define MA_PA_CHANNEL_POSITION_AUX12 24 #define MA_PA_CHANNEL_POSITION_AUX13 25 #define MA_PA_CHANNEL_POSITION_AUX14 26 #define MA_PA_CHANNEL_POSITION_AUX15 27 #define MA_PA_CHANNEL_POSITION_AUX16 28 #define MA_PA_CHANNEL_POSITION_AUX17 29 #define MA_PA_CHANNEL_POSITION_AUX18 30 #define MA_PA_CHANNEL_POSITION_AUX19 31 #define MA_PA_CHANNEL_POSITION_AUX20 32 #define MA_PA_CHANNEL_POSITION_AUX21 33 #define MA_PA_CHANNEL_POSITION_AUX22 34 #define MA_PA_CHANNEL_POSITION_AUX23 35 #define MA_PA_CHANNEL_POSITION_AUX24 36 #define MA_PA_CHANNEL_POSITION_AUX25 37 #define MA_PA_CHANNEL_POSITION_AUX26 38 #define MA_PA_CHANNEL_POSITION_AUX27 39 #define MA_PA_CHANNEL_POSITION_AUX28 40 #define MA_PA_CHANNEL_POSITION_AUX29 41 #define MA_PA_CHANNEL_POSITION_AUX30 42 #define MA_PA_CHANNEL_POSITION_AUX31 43 #define MA_PA_CHANNEL_POSITION_TOP_CENTER 44 #define MA_PA_CHANNEL_POSITION_TOP_FRONT_LEFT 45 #define MA_PA_CHANNEL_POSITION_TOP_FRONT_RIGHT 46 #define MA_PA_CHANNEL_POSITION_TOP_FRONT_CENTER 47 #define MA_PA_CHANNEL_POSITION_TOP_REAR_LEFT 48 #define MA_PA_CHANNEL_POSITION_TOP_REAR_RIGHT 49 #define MA_PA_CHANNEL_POSITION_TOP_REAR_CENTER 50 #define MA_PA_CHANNEL_POSITION_LEFT MA_PA_CHANNEL_POSITION_FRONT_LEFT #define MA_PA_CHANNEL_POSITION_RIGHT MA_PA_CHANNEL_POSITION_FRONT_RIGHT #define MA_PA_CHANNEL_POSITION_CENTER MA_PA_CHANNEL_POSITION_FRONT_CENTER #define MA_PA_CHANNEL_POSITION_SUBWOOFER MA_PA_CHANNEL_POSITION_LFE typedef int ma_pa_channel_map_def_t; #define MA_PA_CHANNEL_MAP_AIFF 0 #define MA_PA_CHANNEL_MAP_ALSA 1 #define MA_PA_CHANNEL_MAP_AUX 2 #define MA_PA_CHANNEL_MAP_WAVEEX 3 #define MA_PA_CHANNEL_MAP_OSS 4 #define MA_PA_CHANNEL_MAP_DEFAULT MA_PA_CHANNEL_MAP_AIFF typedef int ma_pa_sample_format_t; #define MA_PA_SAMPLE_INVALID -1 #define MA_PA_SAMPLE_U8 0 #define MA_PA_SAMPLE_ALAW 1 #define MA_PA_SAMPLE_ULAW 2 #define MA_PA_SAMPLE_S16LE 3 #define MA_PA_SAMPLE_S16BE 4 #define MA_PA_SAMPLE_FLOAT32LE 5 #define MA_PA_SAMPLE_FLOAT32BE 6 #define MA_PA_SAMPLE_S32LE 7 #define MA_PA_SAMPLE_S32BE 8 #define MA_PA_SAMPLE_S24LE 9 #define MA_PA_SAMPLE_S24BE 10 #define MA_PA_SAMPLE_S24_32LE 11 #define MA_PA_SAMPLE_S24_32BE 12 typedef struct ma_pa_mainloop ma_pa_mainloop; typedef struct ma_pa_threaded_mainloop ma_pa_threaded_mainloop; typedef struct ma_pa_mainloop_api ma_pa_mainloop_api; typedef struct ma_pa_context ma_pa_context; typedef struct ma_pa_operation ma_pa_operation; typedef struct ma_pa_stream ma_pa_stream; typedef struct ma_pa_spawn_api ma_pa_spawn_api; typedef struct { ma_uint32 maxlength; ma_uint32 tlength; ma_uint32 prebuf; ma_uint32 minreq; ma_uint32 fragsize; } ma_pa_buffer_attr; typedef struct { ma_uint8 channels; ma_pa_channel_position_t map[MA_PA_CHANNELS_MAX]; } ma_pa_channel_map; typedef struct { ma_uint8 channels; ma_uint32 values[MA_PA_CHANNELS_MAX]; } ma_pa_cvolume; typedef struct { ma_pa_sample_format_t format; ma_uint32 rate; ma_uint8 channels; } ma_pa_sample_spec; typedef struct { const char* name; ma_uint32 index; const char* description; ma_pa_sample_spec sample_spec; ma_pa_channel_map channel_map; ma_uint32 owner_module; ma_pa_cvolume volume; int mute; ma_uint32 monitor_source; const char* monitor_source_name; ma_uint64 latency; const char* driver; ma_pa_sink_flags_t flags; void* proplist; ma_uint64 configured_latency; ma_uint32 base_volume; ma_pa_sink_state_t state; ma_uint32 n_volume_steps; ma_uint32 card; ma_uint32 n_ports; void** ports; void* active_port; ma_uint8 n_formats; void** formats; } ma_pa_sink_info; typedef struct { const char *name; ma_uint32 index; const char *description; ma_pa_sample_spec sample_spec; ma_pa_channel_map channel_map; ma_uint32 owner_module; ma_pa_cvolume volume; int mute; ma_uint32 monitor_of_sink; const char *monitor_of_sink_name; ma_uint64 latency; const char *driver; ma_pa_source_flags_t flags; void* proplist; ma_uint64 configured_latency; ma_uint32 base_volume; ma_pa_source_state_t state; ma_uint32 n_volume_steps; ma_uint32 card; ma_uint32 n_ports; void** ports; void* active_port; ma_uint8 n_formats; void** formats; } ma_pa_source_info; typedef void (* ma_pa_context_notify_cb_t)(ma_pa_context* c, void* userdata); typedef void (* ma_pa_sink_info_cb_t) (ma_pa_context* c, const ma_pa_sink_info* i, int eol, void* userdata); typedef void (* ma_pa_source_info_cb_t) (ma_pa_context* c, const ma_pa_source_info* i, int eol, void* userdata); typedef void (* ma_pa_stream_success_cb_t)(ma_pa_stream* s, int success, void* userdata); typedef void (* ma_pa_stream_request_cb_t)(ma_pa_stream* s, size_t nbytes, void* userdata); typedef void (* ma_pa_stream_notify_cb_t) (ma_pa_stream* s, void* userdata); typedef void (* ma_pa_free_cb_t) (void* p); #endif typedef ma_pa_mainloop* (* ma_pa_mainloop_new_proc) (void); typedef void (* ma_pa_mainloop_free_proc) (ma_pa_mainloop* m); typedef void (* ma_pa_mainloop_quit_proc) (ma_pa_mainloop* m, int retval); typedef ma_pa_mainloop_api* (* ma_pa_mainloop_get_api_proc) (ma_pa_mainloop* m); typedef int (* ma_pa_mainloop_iterate_proc) (ma_pa_mainloop* m, int block, int* retval); typedef void (* ma_pa_mainloop_wakeup_proc) (ma_pa_mainloop* m); typedef ma_pa_threaded_mainloop* (* ma_pa_threaded_mainloop_new_proc) (void); typedef void (* ma_pa_threaded_mainloop_free_proc) (ma_pa_threaded_mainloop* m); typedef int (* ma_pa_threaded_mainloop_start_proc) (ma_pa_threaded_mainloop* m); typedef void (* ma_pa_threaded_mainloop_stop_proc) (ma_pa_threaded_mainloop* m); typedef void (* ma_pa_threaded_mainloop_lock_proc) (ma_pa_threaded_mainloop* m); typedef void (* ma_pa_threaded_mainloop_unlock_proc) (ma_pa_threaded_mainloop* m); typedef void (* ma_pa_threaded_mainloop_wait_proc) (ma_pa_threaded_mainloop* m); typedef void (* ma_pa_threaded_mainloop_signal_proc) (ma_pa_threaded_mainloop* m, int wait_for_accept); typedef void (* ma_pa_threaded_mainloop_accept_proc) (ma_pa_threaded_mainloop* m); typedef int (* ma_pa_threaded_mainloop_get_retval_proc) (ma_pa_threaded_mainloop* m); typedef ma_pa_mainloop_api* (* ma_pa_threaded_mainloop_get_api_proc) (ma_pa_threaded_mainloop* m); typedef int (* ma_pa_threaded_mainloop_in_thread_proc) (ma_pa_threaded_mainloop* m); typedef void (* ma_pa_threaded_mainloop_set_name_proc) (ma_pa_threaded_mainloop* m, const char* name); typedef ma_pa_context* (* ma_pa_context_new_proc) (ma_pa_mainloop_api* mainloop, const char* name); typedef void (* ma_pa_context_unref_proc) (ma_pa_context* c); typedef int (* ma_pa_context_connect_proc) (ma_pa_context* c, const char* server, ma_pa_context_flags_t flags, const ma_pa_spawn_api* api); typedef void (* ma_pa_context_disconnect_proc) (ma_pa_context* c); typedef void (* ma_pa_context_set_state_callback_proc) (ma_pa_context* c, ma_pa_context_notify_cb_t cb, void* userdata); typedef ma_pa_context_state_t (* ma_pa_context_get_state_proc) (ma_pa_context* c); typedef ma_pa_operation* (* ma_pa_context_get_sink_info_list_proc) (ma_pa_context* c, ma_pa_sink_info_cb_t cb, void* userdata); typedef ma_pa_operation* (* ma_pa_context_get_source_info_list_proc) (ma_pa_context* c, ma_pa_source_info_cb_t cb, void* userdata); typedef ma_pa_operation* (* ma_pa_context_get_sink_info_by_name_proc) (ma_pa_context* c, const char* name, ma_pa_sink_info_cb_t cb, void* userdata); typedef ma_pa_operation* (* ma_pa_context_get_source_info_by_name_proc)(ma_pa_context* c, const char* name, ma_pa_source_info_cb_t cb, void* userdata); typedef void (* ma_pa_operation_unref_proc) (ma_pa_operation* o); typedef ma_pa_operation_state_t (* ma_pa_operation_get_state_proc) (ma_pa_operation* o); typedef ma_pa_channel_map* (* ma_pa_channel_map_init_extend_proc) (ma_pa_channel_map* m, unsigned channels, ma_pa_channel_map_def_t def); typedef int (* ma_pa_channel_map_valid_proc) (const ma_pa_channel_map* m); typedef int (* ma_pa_channel_map_compatible_proc) (const ma_pa_channel_map* m, const ma_pa_sample_spec* ss); typedef ma_pa_stream* (* ma_pa_stream_new_proc) (ma_pa_context* c, const char* name, const ma_pa_sample_spec* ss, const ma_pa_channel_map* map); typedef void (* ma_pa_stream_unref_proc) (ma_pa_stream* s); typedef int (* ma_pa_stream_connect_playback_proc) (ma_pa_stream* s, const char* dev, const ma_pa_buffer_attr* attr, ma_pa_stream_flags_t flags, const ma_pa_cvolume* volume, ma_pa_stream* sync_stream); typedef int (* ma_pa_stream_connect_record_proc) (ma_pa_stream* s, const char* dev, const ma_pa_buffer_attr* attr, ma_pa_stream_flags_t flags); typedef int (* ma_pa_stream_disconnect_proc) (ma_pa_stream* s); typedef ma_pa_stream_state_t (* ma_pa_stream_get_state_proc) (ma_pa_stream* s); typedef const ma_pa_sample_spec* (* ma_pa_stream_get_sample_spec_proc) (ma_pa_stream* s); typedef const ma_pa_channel_map* (* ma_pa_stream_get_channel_map_proc) (ma_pa_stream* s); typedef const ma_pa_buffer_attr* (* ma_pa_stream_get_buffer_attr_proc) (ma_pa_stream* s); typedef ma_pa_operation* (* ma_pa_stream_set_buffer_attr_proc) (ma_pa_stream* s, const ma_pa_buffer_attr* attr, ma_pa_stream_success_cb_t cb, void* userdata); typedef const char* (* ma_pa_stream_get_device_name_proc) (ma_pa_stream* s); typedef void (* ma_pa_stream_set_write_callback_proc) (ma_pa_stream* s, ma_pa_stream_request_cb_t cb, void* userdata); typedef void (* ma_pa_stream_set_read_callback_proc) (ma_pa_stream* s, ma_pa_stream_request_cb_t cb, void* userdata); typedef void (* ma_pa_stream_set_suspended_callback_proc) (ma_pa_stream* s, ma_pa_stream_notify_cb_t cb, void* userdata); typedef void (* ma_pa_stream_set_moved_callback_proc) (ma_pa_stream* s, ma_pa_stream_notify_cb_t cb, void* userdata); typedef int (* ma_pa_stream_is_suspended_proc) (const ma_pa_stream* s); typedef ma_pa_operation* (* ma_pa_stream_flush_proc) (ma_pa_stream* s, ma_pa_stream_success_cb_t cb, void* userdata); typedef ma_pa_operation* (* ma_pa_stream_drain_proc) (ma_pa_stream* s, ma_pa_stream_success_cb_t cb, void* userdata); typedef int (* ma_pa_stream_is_corked_proc) (ma_pa_stream* s); typedef ma_pa_operation* (* ma_pa_stream_cork_proc) (ma_pa_stream* s, int b, ma_pa_stream_success_cb_t cb, void* userdata); typedef ma_pa_operation* (* ma_pa_stream_trigger_proc) (ma_pa_stream* s, ma_pa_stream_success_cb_t cb, void* userdata); typedef int (* ma_pa_stream_begin_write_proc) (ma_pa_stream* s, void** data, size_t* nbytes); typedef int (* ma_pa_stream_write_proc) (ma_pa_stream* s, const void* data, size_t nbytes, ma_pa_free_cb_t free_cb, int64_t offset, ma_pa_seek_mode_t seek); typedef int (* ma_pa_stream_peek_proc) (ma_pa_stream* s, const void** data, size_t* nbytes); typedef int (* ma_pa_stream_drop_proc) (ma_pa_stream* s); typedef size_t (* ma_pa_stream_writable_size_proc) (ma_pa_stream* s); typedef size_t (* ma_pa_stream_readable_size_proc) (ma_pa_stream* s); typedef struct { ma_uint32 count; ma_uint32 capacity; ma_device_info* pInfo; } ma_pulse_device_enum_data; static ma_result ma_result_from_pulse(int result) { if (result < 0) { return MA_ERROR; } switch (result) { case MA_PA_OK: return MA_SUCCESS; case MA_PA_ERR_ACCESS: return MA_ACCESS_DENIED; case MA_PA_ERR_INVALID: return MA_INVALID_ARGS; case MA_PA_ERR_NOENTITY: return MA_NO_DEVICE; default: return MA_ERROR; } } #if 0 static ma_pa_sample_format_t ma_format_to_pulse(ma_format format) { if (ma_is_little_endian()) { switch (format) { case ma_format_s16: return MA_PA_SAMPLE_S16LE; case ma_format_s24: return MA_PA_SAMPLE_S24LE; case ma_format_s32: return MA_PA_SAMPLE_S32LE; case ma_format_f32: return MA_PA_SAMPLE_FLOAT32LE; default: break; } } else { switch (format) { case ma_format_s16: return MA_PA_SAMPLE_S16BE; case ma_format_s24: return MA_PA_SAMPLE_S24BE; case ma_format_s32: return MA_PA_SAMPLE_S32BE; case ma_format_f32: return MA_PA_SAMPLE_FLOAT32BE; default: break; } } /* Endian agnostic. */ switch (format) { case ma_format_u8: return MA_PA_SAMPLE_U8; default: return MA_PA_SAMPLE_INVALID; } } #endif static ma_format ma_format_from_pulse(ma_pa_sample_format_t format) { if (ma_is_little_endian()) { switch (format) { case MA_PA_SAMPLE_S16LE: return ma_format_s16; case MA_PA_SAMPLE_S24LE: return ma_format_s24; case MA_PA_SAMPLE_S32LE: return ma_format_s32; case MA_PA_SAMPLE_FLOAT32LE: return ma_format_f32; default: break; } } else { switch (format) { case MA_PA_SAMPLE_S16BE: return ma_format_s16; case MA_PA_SAMPLE_S24BE: return ma_format_s24; case MA_PA_SAMPLE_S32BE: return ma_format_s32; case MA_PA_SAMPLE_FLOAT32BE: return ma_format_f32; default: break; } } /* Endian agnostic. */ switch (format) { case MA_PA_SAMPLE_U8: return ma_format_u8; default: return ma_format_unknown; } } static ma_channel ma_channel_position_from_pulse(ma_pa_channel_position_t position) { switch (position) { case MA_PA_CHANNEL_POSITION_INVALID: return MA_CHANNEL_NONE; case MA_PA_CHANNEL_POSITION_MONO: return MA_CHANNEL_MONO; case MA_PA_CHANNEL_POSITION_FRONT_LEFT: return MA_CHANNEL_FRONT_LEFT; case MA_PA_CHANNEL_POSITION_FRONT_RIGHT: return MA_CHANNEL_FRONT_RIGHT; case MA_PA_CHANNEL_POSITION_FRONT_CENTER: return MA_CHANNEL_FRONT_CENTER; case MA_PA_CHANNEL_POSITION_REAR_CENTER: return MA_CHANNEL_BACK_CENTER; case MA_PA_CHANNEL_POSITION_REAR_LEFT: return MA_CHANNEL_BACK_LEFT; case MA_PA_CHANNEL_POSITION_REAR_RIGHT: return MA_CHANNEL_BACK_RIGHT; case MA_PA_CHANNEL_POSITION_LFE: return MA_CHANNEL_LFE; case MA_PA_CHANNEL_POSITION_FRONT_LEFT_OF_CENTER: return MA_CHANNEL_FRONT_LEFT_CENTER; case MA_PA_CHANNEL_POSITION_FRONT_RIGHT_OF_CENTER: return MA_CHANNEL_FRONT_RIGHT_CENTER; case MA_PA_CHANNEL_POSITION_SIDE_LEFT: return MA_CHANNEL_SIDE_LEFT; case MA_PA_CHANNEL_POSITION_SIDE_RIGHT: return MA_CHANNEL_SIDE_RIGHT; case MA_PA_CHANNEL_POSITION_AUX0: return MA_CHANNEL_AUX_0; case MA_PA_CHANNEL_POSITION_AUX1: return MA_CHANNEL_AUX_1; case MA_PA_CHANNEL_POSITION_AUX2: return MA_CHANNEL_AUX_2; case MA_PA_CHANNEL_POSITION_AUX3: return MA_CHANNEL_AUX_3; case MA_PA_CHANNEL_POSITION_AUX4: return MA_CHANNEL_AUX_4; case MA_PA_CHANNEL_POSITION_AUX5: return MA_CHANNEL_AUX_5; case MA_PA_CHANNEL_POSITION_AUX6: return MA_CHANNEL_AUX_6; case MA_PA_CHANNEL_POSITION_AUX7: return MA_CHANNEL_AUX_7; case MA_PA_CHANNEL_POSITION_AUX8: return MA_CHANNEL_AUX_8; case MA_PA_CHANNEL_POSITION_AUX9: return MA_CHANNEL_AUX_9; case MA_PA_CHANNEL_POSITION_AUX10: return MA_CHANNEL_AUX_10; case MA_PA_CHANNEL_POSITION_AUX11: return MA_CHANNEL_AUX_11; case MA_PA_CHANNEL_POSITION_AUX12: return MA_CHANNEL_AUX_12; case MA_PA_CHANNEL_POSITION_AUX13: return MA_CHANNEL_AUX_13; case MA_PA_CHANNEL_POSITION_AUX14: return MA_CHANNEL_AUX_14; case MA_PA_CHANNEL_POSITION_AUX15: return MA_CHANNEL_AUX_15; case MA_PA_CHANNEL_POSITION_AUX16: return MA_CHANNEL_AUX_16; case MA_PA_CHANNEL_POSITION_AUX17: return MA_CHANNEL_AUX_17; case MA_PA_CHANNEL_POSITION_AUX18: return MA_CHANNEL_AUX_18; case MA_PA_CHANNEL_POSITION_AUX19: return MA_CHANNEL_AUX_19; case MA_PA_CHANNEL_POSITION_AUX20: return MA_CHANNEL_AUX_20; case MA_PA_CHANNEL_POSITION_AUX21: return MA_CHANNEL_AUX_21; case MA_PA_CHANNEL_POSITION_AUX22: return MA_CHANNEL_AUX_22; case MA_PA_CHANNEL_POSITION_AUX23: return MA_CHANNEL_AUX_23; case MA_PA_CHANNEL_POSITION_AUX24: return MA_CHANNEL_AUX_24; case MA_PA_CHANNEL_POSITION_AUX25: return MA_CHANNEL_AUX_25; case MA_PA_CHANNEL_POSITION_AUX26: return MA_CHANNEL_AUX_26; case MA_PA_CHANNEL_POSITION_AUX27: return MA_CHANNEL_AUX_27; case MA_PA_CHANNEL_POSITION_AUX28: return MA_CHANNEL_AUX_28; case MA_PA_CHANNEL_POSITION_AUX29: return MA_CHANNEL_AUX_29; case MA_PA_CHANNEL_POSITION_AUX30: return MA_CHANNEL_AUX_30; case MA_PA_CHANNEL_POSITION_AUX31: return MA_CHANNEL_AUX_31; case MA_PA_CHANNEL_POSITION_TOP_CENTER: return MA_CHANNEL_TOP_CENTER; case MA_PA_CHANNEL_POSITION_TOP_FRONT_LEFT: return MA_CHANNEL_TOP_FRONT_LEFT; case MA_PA_CHANNEL_POSITION_TOP_FRONT_RIGHT: return MA_CHANNEL_TOP_FRONT_RIGHT; case MA_PA_CHANNEL_POSITION_TOP_FRONT_CENTER: return MA_CHANNEL_TOP_FRONT_CENTER; case MA_PA_CHANNEL_POSITION_TOP_REAR_LEFT: return MA_CHANNEL_TOP_BACK_LEFT; case MA_PA_CHANNEL_POSITION_TOP_REAR_RIGHT: return MA_CHANNEL_TOP_BACK_RIGHT; case MA_PA_CHANNEL_POSITION_TOP_REAR_CENTER: return MA_CHANNEL_TOP_BACK_CENTER; default: return MA_CHANNEL_NONE; } } #if 0 static ma_pa_channel_position_t ma_channel_position_to_pulse(ma_channel position) { switch (position) { case MA_CHANNEL_NONE: return MA_PA_CHANNEL_POSITION_INVALID; case MA_CHANNEL_FRONT_LEFT: return MA_PA_CHANNEL_POSITION_FRONT_LEFT; case MA_CHANNEL_FRONT_RIGHT: return MA_PA_CHANNEL_POSITION_FRONT_RIGHT; case MA_CHANNEL_FRONT_CENTER: return MA_PA_CHANNEL_POSITION_FRONT_CENTER; case MA_CHANNEL_LFE: return MA_PA_CHANNEL_POSITION_LFE; case MA_CHANNEL_BACK_LEFT: return MA_PA_CHANNEL_POSITION_REAR_LEFT; case MA_CHANNEL_BACK_RIGHT: return MA_PA_CHANNEL_POSITION_REAR_RIGHT; case MA_CHANNEL_FRONT_LEFT_CENTER: return MA_PA_CHANNEL_POSITION_FRONT_LEFT_OF_CENTER; case MA_CHANNEL_FRONT_RIGHT_CENTER: return MA_PA_CHANNEL_POSITION_FRONT_RIGHT_OF_CENTER; case MA_CHANNEL_BACK_CENTER: return MA_PA_CHANNEL_POSITION_REAR_CENTER; case MA_CHANNEL_SIDE_LEFT: return MA_PA_CHANNEL_POSITION_SIDE_LEFT; case MA_CHANNEL_SIDE_RIGHT: return MA_PA_CHANNEL_POSITION_SIDE_RIGHT; case MA_CHANNEL_TOP_CENTER: return MA_PA_CHANNEL_POSITION_TOP_CENTER; case MA_CHANNEL_TOP_FRONT_LEFT: return MA_PA_CHANNEL_POSITION_TOP_FRONT_LEFT; case MA_CHANNEL_TOP_FRONT_CENTER: return MA_PA_CHANNEL_POSITION_TOP_FRONT_CENTER; case MA_CHANNEL_TOP_FRONT_RIGHT: return MA_PA_CHANNEL_POSITION_TOP_FRONT_RIGHT; case MA_CHANNEL_TOP_BACK_LEFT: return MA_PA_CHANNEL_POSITION_TOP_REAR_LEFT; case MA_CHANNEL_TOP_BACK_CENTER: return MA_PA_CHANNEL_POSITION_TOP_REAR_CENTER; case MA_CHANNEL_TOP_BACK_RIGHT: return MA_PA_CHANNEL_POSITION_TOP_REAR_RIGHT; case MA_CHANNEL_19: return MA_PA_CHANNEL_POSITION_AUX18; case MA_CHANNEL_20: return MA_PA_CHANNEL_POSITION_AUX19; case MA_CHANNEL_21: return MA_PA_CHANNEL_POSITION_AUX20; case MA_CHANNEL_22: return MA_PA_CHANNEL_POSITION_AUX21; case MA_CHANNEL_23: return MA_PA_CHANNEL_POSITION_AUX22; case MA_CHANNEL_24: return MA_PA_CHANNEL_POSITION_AUX23; case MA_CHANNEL_25: return MA_PA_CHANNEL_POSITION_AUX24; case MA_CHANNEL_26: return MA_PA_CHANNEL_POSITION_AUX25; case MA_CHANNEL_27: return MA_PA_CHANNEL_POSITION_AUX26; case MA_CHANNEL_28: return MA_PA_CHANNEL_POSITION_AUX27; case MA_CHANNEL_29: return MA_PA_CHANNEL_POSITION_AUX28; case MA_CHANNEL_30: return MA_PA_CHANNEL_POSITION_AUX29; case MA_CHANNEL_31: return MA_PA_CHANNEL_POSITION_AUX30; case MA_CHANNEL_32: return MA_PA_CHANNEL_POSITION_AUX31; default: return (ma_pa_channel_position_t)position; } } #endif static ma_result ma_wait_for_operation__pulse(ma_context* pContext, ma_ptr pMainLoop, ma_pa_operation* pOP) { int resultPA; ma_pa_operation_state_t state; MA_ASSERT(pContext != NULL); MA_ASSERT(pOP != NULL); for (;;) { state = ((ma_pa_operation_get_state_proc)pContext->pulse.pa_operation_get_state)(pOP); if (state != MA_PA_OPERATION_RUNNING) { break; /* Done. */ } resultPA = ((ma_pa_mainloop_iterate_proc)pContext->pulse.pa_mainloop_iterate)((ma_pa_mainloop*)pMainLoop, 1, NULL); if (resultPA < 0) { return ma_result_from_pulse(resultPA); } } return MA_SUCCESS; } static ma_result ma_wait_for_operation_and_unref__pulse(ma_context* pContext, ma_ptr pMainLoop, ma_pa_operation* pOP) { ma_result result; if (pOP == NULL) { return MA_INVALID_ARGS; } result = ma_wait_for_operation__pulse(pContext, pMainLoop, pOP); ((ma_pa_operation_unref_proc)pContext->pulse.pa_operation_unref)(pOP); return result; } static ma_result ma_wait_for_pa_context_to_connect__pulse(ma_context* pContext, ma_ptr pMainLoop, ma_ptr pPulseContext) { int resultPA; ma_pa_context_state_t state; for (;;) { state = ((ma_pa_context_get_state_proc)pContext->pulse.pa_context_get_state)((ma_pa_context*)pPulseContext); if (state == MA_PA_CONTEXT_READY) { break; /* Done. */ } if (state == MA_PA_CONTEXT_FAILED || state == MA_PA_CONTEXT_TERMINATED) { ma_log_postf(ma_context_get_log(pContext), MA_LOG_LEVEL_ERROR, "[PulseAudio] An error occurred while connecting the PulseAudio context."); return MA_ERROR; } resultPA = ((ma_pa_mainloop_iterate_proc)pContext->pulse.pa_mainloop_iterate)((ma_pa_mainloop*)pMainLoop, 1, NULL); if (resultPA < 0) { return ma_result_from_pulse(resultPA); } } /* Should never get here. */ return MA_SUCCESS; } static ma_result ma_wait_for_pa_stream_to_connect__pulse(ma_context* pContext, ma_ptr pMainLoop, ma_ptr pStream) { int resultPA; ma_pa_stream_state_t state; for (;;) { state = ((ma_pa_stream_get_state_proc)pContext->pulse.pa_stream_get_state)((ma_pa_stream*)pStream); if (state == MA_PA_STREAM_READY) { break; /* Done. */ } if (state == MA_PA_STREAM_FAILED || state == MA_PA_STREAM_TERMINATED) { ma_log_postf(ma_context_get_log(pContext), MA_LOG_LEVEL_ERROR, "[PulseAudio] An error occurred while connecting the PulseAudio stream."); return MA_ERROR; } resultPA = ((ma_pa_mainloop_iterate_proc)pContext->pulse.pa_mainloop_iterate)((ma_pa_mainloop*)pMainLoop, 1, NULL); if (resultPA < 0) { return ma_result_from_pulse(resultPA); } } return MA_SUCCESS; } static ma_result ma_init_pa_mainloop_and_pa_context__pulse(ma_context* pContext, const char* pApplicationName, const char* pServerName, ma_bool32 tryAutoSpawn, ma_ptr* ppMainLoop, ma_ptr* ppPulseContext) { ma_result result; ma_ptr pMainLoop; ma_ptr pPulseContext; MA_ASSERT(ppMainLoop != NULL); MA_ASSERT(ppPulseContext != NULL); /* The PulseAudio context maps well to miniaudio's notion of a context. The pa_context object will be initialized as part of the ma_context. */ pMainLoop = ((ma_pa_mainloop_new_proc)pContext->pulse.pa_mainloop_new)(); if (pMainLoop == NULL) { ma_log_postf(ma_context_get_log(pContext), MA_LOG_LEVEL_ERROR, "[PulseAudio] Failed to create mainloop."); return MA_FAILED_TO_INIT_BACKEND; } pPulseContext = ((ma_pa_context_new_proc)pContext->pulse.pa_context_new)(((ma_pa_mainloop_get_api_proc)pContext->pulse.pa_mainloop_get_api)((ma_pa_mainloop*)pMainLoop), pApplicationName); if (pPulseContext == NULL) { ma_log_postf(ma_context_get_log(pContext), MA_LOG_LEVEL_ERROR, "[PulseAudio] Failed to create PulseAudio context."); ((ma_pa_mainloop_free_proc)pContext->pulse.pa_mainloop_free)((ma_pa_mainloop*)(pMainLoop)); return MA_FAILED_TO_INIT_BACKEND; } /* Now we need to connect to the context. Everything is asynchronous so we need to wait for it to connect before returning. */ result = ma_result_from_pulse(((ma_pa_context_connect_proc)pContext->pulse.pa_context_connect)((ma_pa_context*)pPulseContext, pServerName, (tryAutoSpawn) ? 0 : MA_PA_CONTEXT_NOAUTOSPAWN, NULL)); if (result != MA_SUCCESS) { ma_log_postf(ma_context_get_log(pContext), MA_LOG_LEVEL_ERROR, "[PulseAudio] Failed to connect PulseAudio context."); ((ma_pa_mainloop_free_proc)pContext->pulse.pa_mainloop_free)((ma_pa_mainloop*)(pMainLoop)); return result; } /* Since ma_context_init() runs synchronously we need to wait for the PulseAudio context to connect before we return. */ result = ma_wait_for_pa_context_to_connect__pulse(pContext, pMainLoop, pPulseContext); if (result != MA_SUCCESS) { ma_log_postf(ma_context_get_log(pContext), MA_LOG_LEVEL_ERROR, "[PulseAudio] Waiting for connection failed."); ((ma_pa_mainloop_free_proc)pContext->pulse.pa_mainloop_free)((ma_pa_mainloop*)(pMainLoop)); return result; } *ppMainLoop = pMainLoop; *ppPulseContext = pPulseContext; return MA_SUCCESS; } static void ma_device_sink_info_callback(ma_pa_context* pPulseContext, const ma_pa_sink_info* pInfo, int endOfList, void* pUserData) { ma_pa_sink_info* pInfoOut; if (endOfList > 0) { return; } /* There has been a report that indicates that pInfo can be null which results in a null pointer dereference below. We'll check for this for safety. */ if (pInfo == NULL) { return; } pInfoOut = (ma_pa_sink_info*)pUserData; MA_ASSERT(pInfoOut != NULL); *pInfoOut = *pInfo; (void)pPulseContext; /* Unused. */ } static void ma_device_source_info_callback(ma_pa_context* pPulseContext, const ma_pa_source_info* pInfo, int endOfList, void* pUserData) { ma_pa_source_info* pInfoOut; if (endOfList > 0) { return; } /* There has been a report that indicates that pInfo can be null which results in a null pointer dereference below. We'll check for this for safety. */ if (pInfo == NULL) { return; } pInfoOut = (ma_pa_source_info*)pUserData; MA_ASSERT(pInfoOut != NULL); *pInfoOut = *pInfo; (void)pPulseContext; /* Unused. */ } #if 0 static void ma_device_sink_name_callback(ma_pa_context* pPulseContext, const ma_pa_sink_info* pInfo, int endOfList, void* pUserData) { ma_device* pDevice; if (endOfList > 0) { return; } pDevice = (ma_device*)pUserData; MA_ASSERT(pDevice != NULL); ma_strncpy_s(pDevice->playback.name, sizeof(pDevice->playback.name), pInfo->description, (size_t)-1); (void)pPulseContext; /* Unused. */ } static void ma_device_source_name_callback(ma_pa_context* pPulseContext, const ma_pa_source_info* pInfo, int endOfList, void* pUserData) { ma_device* pDevice; if (endOfList > 0) { return; } pDevice = (ma_device*)pUserData; MA_ASSERT(pDevice != NULL); ma_strncpy_s(pDevice->capture.name, sizeof(pDevice->capture.name), pInfo->description, (size_t)-1); (void)pPulseContext; /* Unused. */ } #endif static ma_result ma_context_get_sink_info__pulse(ma_context* pContext, const char* pDeviceName, ma_pa_sink_info* pSinkInfo) { ma_pa_operation* pOP; pOP = ((ma_pa_context_get_sink_info_by_name_proc)pContext->pulse.pa_context_get_sink_info_by_name)((ma_pa_context*)pContext->pulse.pPulseContext, pDeviceName, ma_device_sink_info_callback, pSinkInfo); if (pOP == NULL) { return MA_ERROR; } return ma_wait_for_operation_and_unref__pulse(pContext, pContext->pulse.pMainLoop, pOP); } static ma_result ma_context_get_source_info__pulse(ma_context* pContext, const char* pDeviceName, ma_pa_source_info* pSourceInfo) { ma_pa_operation* pOP; pOP = ((ma_pa_context_get_source_info_by_name_proc)pContext->pulse.pa_context_get_source_info_by_name)((ma_pa_context*)pContext->pulse.pPulseContext, pDeviceName, ma_device_source_info_callback, pSourceInfo); if (pOP == NULL) { return MA_ERROR; } return ma_wait_for_operation_and_unref__pulse(pContext, pContext->pulse.pMainLoop, pOP); } static ma_result ma_context_get_default_device_index__pulse(ma_context* pContext, ma_device_type deviceType, ma_uint32* pIndex) { ma_result result; MA_ASSERT(pContext != NULL); MA_ASSERT(pIndex != NULL); if (pIndex != NULL) { *pIndex = (ma_uint32)-1; } if (deviceType == ma_device_type_playback) { ma_pa_sink_info sinkInfo; result = ma_context_get_sink_info__pulse(pContext, NULL, &sinkInfo); if (result != MA_SUCCESS) { return result; } if (pIndex != NULL) { *pIndex = sinkInfo.index; } } if (deviceType == ma_device_type_capture) { ma_pa_source_info sourceInfo; result = ma_context_get_source_info__pulse(pContext, NULL, &sourceInfo); if (result != MA_SUCCESS) { return result; } if (pIndex != NULL) { *pIndex = sourceInfo.index; } } return MA_SUCCESS; } typedef struct { ma_context* pContext; ma_enum_devices_callback_proc callback; void* pUserData; ma_bool32 isTerminated; ma_uint32 defaultDeviceIndexPlayback; ma_uint32 defaultDeviceIndexCapture; } ma_context_enumerate_devices_callback_data__pulse; static void ma_context_enumerate_devices_sink_callback__pulse(ma_pa_context* pPulseContext, const ma_pa_sink_info* pSinkInfo, int endOfList, void* pUserData) { ma_context_enumerate_devices_callback_data__pulse* pData = (ma_context_enumerate_devices_callback_data__pulse*)pUserData; ma_device_info deviceInfo; MA_ASSERT(pData != NULL); if (endOfList || pData->isTerminated) { return; } MA_ZERO_OBJECT(&deviceInfo); /* The name from PulseAudio is the ID for miniaudio. */ if (pSinkInfo->name != NULL) { ma_strncpy_s(deviceInfo.id.pulse, sizeof(deviceInfo.id.pulse), pSinkInfo->name, (size_t)-1); } /* The description from PulseAudio is the name for miniaudio. */ if (pSinkInfo->description != NULL) { ma_strncpy_s(deviceInfo.name, sizeof(deviceInfo.name), pSinkInfo->description, (size_t)-1); } if (pSinkInfo->index == pData->defaultDeviceIndexPlayback) { deviceInfo.isDefault = MA_TRUE; } pData->isTerminated = !pData->callback(pData->pContext, ma_device_type_playback, &deviceInfo, pData->pUserData); (void)pPulseContext; /* Unused. */ } static void ma_context_enumerate_devices_source_callback__pulse(ma_pa_context* pPulseContext, const ma_pa_source_info* pSourceInfo, int endOfList, void* pUserData) { ma_context_enumerate_devices_callback_data__pulse* pData = (ma_context_enumerate_devices_callback_data__pulse*)pUserData; ma_device_info deviceInfo; MA_ASSERT(pData != NULL); if (endOfList || pData->isTerminated) { return; } MA_ZERO_OBJECT(&deviceInfo); /* The name from PulseAudio is the ID for miniaudio. */ if (pSourceInfo->name != NULL) { ma_strncpy_s(deviceInfo.id.pulse, sizeof(deviceInfo.id.pulse), pSourceInfo->name, (size_t)-1); } /* The description from PulseAudio is the name for miniaudio. */ if (pSourceInfo->description != NULL) { ma_strncpy_s(deviceInfo.name, sizeof(deviceInfo.name), pSourceInfo->description, (size_t)-1); } if (pSourceInfo->index == pData->defaultDeviceIndexCapture) { deviceInfo.isDefault = MA_TRUE; } pData->isTerminated = !pData->callback(pData->pContext, ma_device_type_capture, &deviceInfo, pData->pUserData); (void)pPulseContext; /* Unused. */ } static ma_result ma_context_enumerate_devices__pulse(ma_context* pContext, ma_enum_devices_callback_proc callback, void* pUserData) { ma_result result = MA_SUCCESS; ma_context_enumerate_devices_callback_data__pulse callbackData; ma_pa_operation* pOP = NULL; MA_ASSERT(pContext != NULL); MA_ASSERT(callback != NULL); callbackData.pContext = pContext; callbackData.callback = callback; callbackData.pUserData = pUserData; callbackData.isTerminated = MA_FALSE; callbackData.defaultDeviceIndexPlayback = (ma_uint32)-1; callbackData.defaultDeviceIndexCapture = (ma_uint32)-1; /* We need to get the index of the default devices. */ ma_context_get_default_device_index__pulse(pContext, ma_device_type_playback, &callbackData.defaultDeviceIndexPlayback); ma_context_get_default_device_index__pulse(pContext, ma_device_type_capture, &callbackData.defaultDeviceIndexCapture); /* Playback. */ if (!callbackData.isTerminated) { pOP = ((ma_pa_context_get_sink_info_list_proc)pContext->pulse.pa_context_get_sink_info_list)((ma_pa_context*)(pContext->pulse.pPulseContext), ma_context_enumerate_devices_sink_callback__pulse, &callbackData); if (pOP == NULL) { result = MA_ERROR; goto done; } result = ma_wait_for_operation__pulse(pContext, pContext->pulse.pMainLoop, pOP); ((ma_pa_operation_unref_proc)pContext->pulse.pa_operation_unref)(pOP); if (result != MA_SUCCESS) { goto done; } } /* Capture. */ if (!callbackData.isTerminated) { pOP = ((ma_pa_context_get_source_info_list_proc)pContext->pulse.pa_context_get_source_info_list)((ma_pa_context*)(pContext->pulse.pPulseContext), ma_context_enumerate_devices_source_callback__pulse, &callbackData); if (pOP == NULL) { result = MA_ERROR; goto done; } result = ma_wait_for_operation__pulse(pContext, pContext->pulse.pMainLoop, pOP); ((ma_pa_operation_unref_proc)pContext->pulse.pa_operation_unref)(pOP); if (result != MA_SUCCESS) { goto done; } } done: return result; } typedef struct { ma_device_info* pDeviceInfo; ma_uint32 defaultDeviceIndex; ma_bool32 foundDevice; } ma_context_get_device_info_callback_data__pulse; static void ma_context_get_device_info_sink_callback__pulse(ma_pa_context* pPulseContext, const ma_pa_sink_info* pInfo, int endOfList, void* pUserData) { ma_context_get_device_info_callback_data__pulse* pData = (ma_context_get_device_info_callback_data__pulse*)pUserData; if (endOfList > 0) { return; } MA_ASSERT(pData != NULL); pData->foundDevice = MA_TRUE; if (pInfo->name != NULL) { ma_strncpy_s(pData->pDeviceInfo->id.pulse, sizeof(pData->pDeviceInfo->id.pulse), pInfo->name, (size_t)-1); } if (pInfo->description != NULL) { ma_strncpy_s(pData->pDeviceInfo->name, sizeof(pData->pDeviceInfo->name), pInfo->description, (size_t)-1); } /* We're just reporting a single data format here. I think technically PulseAudio might support all formats, but I don't trust that PulseAudio will do *anything* right, so I'm just going to report the "native" device format. */ pData->pDeviceInfo->nativeDataFormats[0].format = ma_format_from_pulse(pInfo->sample_spec.format); pData->pDeviceInfo->nativeDataFormats[0].channels = pInfo->sample_spec.channels; pData->pDeviceInfo->nativeDataFormats[0].sampleRate = pInfo->sample_spec.rate; pData->pDeviceInfo->nativeDataFormats[0].flags = 0; pData->pDeviceInfo->nativeDataFormatCount = 1; if (pData->defaultDeviceIndex == pInfo->index) { pData->pDeviceInfo->isDefault = MA_TRUE; } (void)pPulseContext; /* Unused. */ } static void ma_context_get_device_info_source_callback__pulse(ma_pa_context* pPulseContext, const ma_pa_source_info* pInfo, int endOfList, void* pUserData) { ma_context_get_device_info_callback_data__pulse* pData = (ma_context_get_device_info_callback_data__pulse*)pUserData; if (endOfList > 0) { return; } MA_ASSERT(pData != NULL); pData->foundDevice = MA_TRUE; if (pInfo->name != NULL) { ma_strncpy_s(pData->pDeviceInfo->id.pulse, sizeof(pData->pDeviceInfo->id.pulse), pInfo->name, (size_t)-1); } if (pInfo->description != NULL) { ma_strncpy_s(pData->pDeviceInfo->name, sizeof(pData->pDeviceInfo->name), pInfo->description, (size_t)-1); } /* We're just reporting a single data format here. I think technically PulseAudio might support all formats, but I don't trust that PulseAudio will do *anything* right, so I'm just going to report the "native" device format. */ pData->pDeviceInfo->nativeDataFormats[0].format = ma_format_from_pulse(pInfo->sample_spec.format); pData->pDeviceInfo->nativeDataFormats[0].channels = pInfo->sample_spec.channels; pData->pDeviceInfo->nativeDataFormats[0].sampleRate = pInfo->sample_spec.rate; pData->pDeviceInfo->nativeDataFormats[0].flags = 0; pData->pDeviceInfo->nativeDataFormatCount = 1; if (pData->defaultDeviceIndex == pInfo->index) { pData->pDeviceInfo->isDefault = MA_TRUE; } (void)pPulseContext; /* Unused. */ } static ma_result ma_context_get_device_info__pulse(ma_context* pContext, ma_device_type deviceType, const ma_device_id* pDeviceID, ma_device_info* pDeviceInfo) { ma_result result = MA_SUCCESS; ma_context_get_device_info_callback_data__pulse callbackData; ma_pa_operation* pOP = NULL; const char* pDeviceName = NULL; MA_ASSERT(pContext != NULL); callbackData.pDeviceInfo = pDeviceInfo; callbackData.foundDevice = MA_FALSE; if (pDeviceID != NULL) { pDeviceName = pDeviceID->pulse; } else { pDeviceName = NULL; } result = ma_context_get_default_device_index__pulse(pContext, deviceType, &callbackData.defaultDeviceIndex); if (deviceType == ma_device_type_playback) { pOP = ((ma_pa_context_get_sink_info_by_name_proc)pContext->pulse.pa_context_get_sink_info_by_name)((ma_pa_context*)(pContext->pulse.pPulseContext), pDeviceName, ma_context_get_device_info_sink_callback__pulse, &callbackData); } else { pOP = ((ma_pa_context_get_source_info_by_name_proc)pContext->pulse.pa_context_get_source_info_by_name)((ma_pa_context*)(pContext->pulse.pPulseContext), pDeviceName, ma_context_get_device_info_source_callback__pulse, &callbackData); } if (pOP != NULL) { ma_wait_for_operation_and_unref__pulse(pContext, pContext->pulse.pMainLoop, pOP); } else { result = MA_ERROR; goto done; } if (!callbackData.foundDevice) { result = MA_NO_DEVICE; goto done; } done: return result; } static ma_result ma_device_uninit__pulse(ma_device* pDevice) { ma_context* pContext; MA_ASSERT(pDevice != NULL); pContext = pDevice->pContext; MA_ASSERT(pContext != NULL); if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) { ((ma_pa_stream_disconnect_proc)pContext->pulse.pa_stream_disconnect)((ma_pa_stream*)pDevice->pulse.pStreamCapture); ((ma_pa_stream_unref_proc)pContext->pulse.pa_stream_unref)((ma_pa_stream*)pDevice->pulse.pStreamCapture); } if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) { ((ma_pa_stream_disconnect_proc)pContext->pulse.pa_stream_disconnect)((ma_pa_stream*)pDevice->pulse.pStreamPlayback); ((ma_pa_stream_unref_proc)pContext->pulse.pa_stream_unref)((ma_pa_stream*)pDevice->pulse.pStreamPlayback); } if (pDevice->type == ma_device_type_duplex) { ma_duplex_rb_uninit(&pDevice->duplexRB); } ((ma_pa_context_disconnect_proc)pContext->pulse.pa_context_disconnect)((ma_pa_context*)pDevice->pulse.pPulseContext); ((ma_pa_context_unref_proc)pContext->pulse.pa_context_unref)((ma_pa_context*)pDevice->pulse.pPulseContext); ((ma_pa_mainloop_free_proc)pContext->pulse.pa_mainloop_free)((ma_pa_mainloop*)pDevice->pulse.pMainLoop); return MA_SUCCESS; } static ma_pa_buffer_attr ma_device__pa_buffer_attr_new(ma_uint32 periodSizeInFrames, ma_uint32 periods, const ma_pa_sample_spec* ss) { ma_pa_buffer_attr attr; attr.maxlength = periodSizeInFrames * periods * ma_get_bytes_per_frame(ma_format_from_pulse(ss->format), ss->channels); attr.tlength = attr.maxlength / periods; attr.prebuf = (ma_uint32)-1; attr.minreq = (ma_uint32)-1; attr.fragsize = attr.maxlength / periods; return attr; } static ma_pa_stream* ma_device__pa_stream_new__pulse(ma_device* pDevice, const char* pStreamName, const ma_pa_sample_spec* ss, const ma_pa_channel_map* cmap) { static int g_StreamCounter = 0; char actualStreamName[256]; if (pStreamName != NULL) { ma_strncpy_s(actualStreamName, sizeof(actualStreamName), pStreamName, (size_t)-1); } else { ma_strcpy_s(actualStreamName, sizeof(actualStreamName), "miniaudio:"); ma_itoa_s(g_StreamCounter, actualStreamName + 8, sizeof(actualStreamName)-8, 10); /* 8 = strlen("miniaudio:") */ } g_StreamCounter += 1; return ((ma_pa_stream_new_proc)pDevice->pContext->pulse.pa_stream_new)((ma_pa_context*)pDevice->pulse.pPulseContext, actualStreamName, ss, cmap); } static void ma_device_on_read__pulse(ma_pa_stream* pStream, size_t byteCount, void* pUserData) { ma_device* pDevice = (ma_device*)pUserData; ma_uint32 bpf; ma_uint32 deviceState; ma_uint64 frameCount; ma_uint64 framesProcessed; MA_ASSERT(pDevice != NULL); /* Don't do anything if the device isn't initialized yet. Yes, this can happen because PulseAudio can fire this callback before the stream has even started. Ridiculous. */ deviceState = ma_device_get_state(pDevice); if (deviceState != ma_device_state_starting && deviceState != ma_device_state_started) { return; } bpf = ma_get_bytes_per_frame(pDevice->capture.internalFormat, pDevice->capture.internalChannels); MA_ASSERT(bpf > 0); frameCount = byteCount / bpf; framesProcessed = 0; while (ma_device_get_state(pDevice) == ma_device_state_started && framesProcessed < frameCount) { const void* pMappedPCMFrames; size_t bytesMapped; ma_uint64 framesMapped; int pulseResult = ((ma_pa_stream_peek_proc)pDevice->pContext->pulse.pa_stream_peek)(pStream, &pMappedPCMFrames, &bytesMapped); if (pulseResult < 0) { break; /* Failed to map. Abort. */ } framesMapped = bytesMapped / bpf; if (framesMapped > 0) { if (pMappedPCMFrames != NULL) { ma_device_handle_backend_data_callback(pDevice, NULL, pMappedPCMFrames, framesMapped); } else { /* It's a hole. */ ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_DEBUG, "[PulseAudio] ma_device_on_read__pulse: Hole.\n"); } pulseResult = ((ma_pa_stream_drop_proc)pDevice->pContext->pulse.pa_stream_drop)(pStream); if (pulseResult < 0) { break; /* Failed to drop the buffer. */ } framesProcessed += framesMapped; } else { /* Nothing was mapped. Just abort. */ break; } } } static ma_result ma_device_write_to_stream__pulse(ma_device* pDevice, ma_pa_stream* pStream, ma_uint64* pFramesProcessed) { ma_result result = MA_SUCCESS; ma_uint64 framesProcessed = 0; size_t bytesMapped; ma_uint32 bpf; ma_uint32 deviceState; MA_ASSERT(pDevice != NULL); MA_ASSERT(pStream != NULL); bpf = ma_get_bytes_per_frame(pDevice->playback.internalFormat, pDevice->playback.internalChannels); MA_ASSERT(bpf > 0); deviceState = ma_device_get_state(pDevice); bytesMapped = ((ma_pa_stream_writable_size_proc)pDevice->pContext->pulse.pa_stream_writable_size)(pStream); if (bytesMapped != (size_t)-1) { if (bytesMapped > 0) { ma_uint64 framesMapped; void* pMappedPCMFrames; int pulseResult = ((ma_pa_stream_begin_write_proc)pDevice->pContext->pulse.pa_stream_begin_write)(pStream, &pMappedPCMFrames, &bytesMapped); if (pulseResult < 0) { result = ma_result_from_pulse(pulseResult); goto done; } framesMapped = bytesMapped / bpf; if (deviceState == ma_device_state_started || deviceState == ma_device_state_starting) { /* Check for starting state just in case this is being used to do the initial fill. */ ma_device_handle_backend_data_callback(pDevice, pMappedPCMFrames, NULL, framesMapped); } else { /* Device is not started. Write silence. */ ma_silence_pcm_frames(pMappedPCMFrames, framesMapped, pDevice->playback.format, pDevice->playback.channels); } pulseResult = ((ma_pa_stream_write_proc)pDevice->pContext->pulse.pa_stream_write)(pStream, pMappedPCMFrames, bytesMapped, NULL, 0, MA_PA_SEEK_RELATIVE); if (pulseResult < 0) { result = ma_result_from_pulse(pulseResult); goto done; /* Failed to write data to stream. */ } framesProcessed += framesMapped; } else { result = MA_SUCCESS; /* No data available for writing. */ goto done; } } else { result = MA_ERROR; /* Failed to retrieve the writable size. Abort. */ goto done; } done: if (pFramesProcessed != NULL) { *pFramesProcessed = framesProcessed; } return result; } static void ma_device_on_write__pulse(ma_pa_stream* pStream, size_t byteCount, void* pUserData) { ma_device* pDevice = (ma_device*)pUserData; ma_uint32 bpf; ma_uint64 frameCount; ma_uint64 framesProcessed; ma_uint32 deviceState; ma_result result; MA_ASSERT(pDevice != NULL); /* Don't do anything if the device isn't initialized yet. Yes, this can happen because PulseAudio can fire this callback before the stream has even started. Ridiculous. */ deviceState = ma_device_get_state(pDevice); if (deviceState != ma_device_state_starting && deviceState != ma_device_state_started) { return; } bpf = ma_get_bytes_per_frame(pDevice->playback.internalFormat, pDevice->playback.internalChannels); MA_ASSERT(bpf > 0); frameCount = byteCount / bpf; framesProcessed = 0; while (framesProcessed < frameCount) { ma_uint64 framesProcessedThisIteration; /* Don't keep trying to process frames if the device isn't started. */ deviceState = ma_device_get_state(pDevice); if (deviceState != ma_device_state_starting && deviceState != ma_device_state_started) { break; } result = ma_device_write_to_stream__pulse(pDevice, pStream, &framesProcessedThisIteration); if (result != MA_SUCCESS) { break; } framesProcessed += framesProcessedThisIteration; } } static void ma_device_on_suspended__pulse(ma_pa_stream* pStream, void* pUserData) { ma_device* pDevice = (ma_device*)pUserData; int suspended; (void)pStream; suspended = ((ma_pa_stream_is_suspended_proc)pDevice->pContext->pulse.pa_stream_is_suspended)(pStream); ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_DEBUG, "[Pulse] Device suspended state changed. pa_stream_is_suspended() returned %d.\n", suspended); if (suspended < 0) { return; } if (suspended == 1) { ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_DEBUG, "[Pulse] Device suspended state changed. Suspended.\n"); ma_device__on_notification_stopped(pDevice); } else { ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_DEBUG, "[Pulse] Device suspended state changed. Resumed.\n"); ma_device__on_notification_started(pDevice); } } static void ma_device_on_rerouted__pulse(ma_pa_stream* pStream, void* pUserData) { ma_device* pDevice = (ma_device*)pUserData; (void)pStream; (void)pUserData; ma_device__on_notification_rerouted(pDevice); } static ma_uint32 ma_calculate_period_size_in_frames_from_descriptor__pulse(const ma_device_descriptor* pDescriptor, ma_uint32 nativeSampleRate, ma_performance_profile performanceProfile) { /* There have been reports from users where buffers of < ~20ms result glitches when running through PipeWire. To work around this we're going to have to use a different default buffer size. */ const ma_uint32 defaultPeriodSizeInMilliseconds_LowLatency = 25; const ma_uint32 defaultPeriodSizeInMilliseconds_Conservative = MA_DEFAULT_PERIOD_SIZE_IN_MILLISECONDS_CONSERVATIVE; MA_ASSERT(nativeSampleRate != 0); if (pDescriptor->periodSizeInFrames == 0) { if (pDescriptor->periodSizeInMilliseconds == 0) { if (performanceProfile == ma_performance_profile_low_latency) { return ma_calculate_buffer_size_in_frames_from_milliseconds(defaultPeriodSizeInMilliseconds_LowLatency, nativeSampleRate); } else { return ma_calculate_buffer_size_in_frames_from_milliseconds(defaultPeriodSizeInMilliseconds_Conservative, nativeSampleRate); } } else { return ma_calculate_buffer_size_in_frames_from_milliseconds(pDescriptor->periodSizeInMilliseconds, nativeSampleRate); } } else { return pDescriptor->periodSizeInFrames; } } static ma_result ma_device_init__pulse(ma_device* pDevice, const ma_device_config* pConfig, ma_device_descriptor* pDescriptorPlayback, ma_device_descriptor* pDescriptorCapture) { /* Notes for PulseAudio: - When both the period size in frames and milliseconds are 0, we default to miniaudio's default buffer sizes rather than leaving it up to PulseAudio because I don't trust PulseAudio to give us any kind of reasonable latency by default. - Do not ever, *ever* forget to use MA_PA_STREAM_ADJUST_LATENCY. If you don't specify this flag, capture mode will just not work properly until you open another PulseAudio app. */ ma_result result = MA_SUCCESS; int error = 0; const char* devPlayback = NULL; const char* devCapture = NULL; ma_format format = ma_format_unknown; ma_uint32 channels = 0; ma_uint32 sampleRate = 0; ma_pa_sink_info sinkInfo; ma_pa_source_info sourceInfo; ma_pa_sample_spec ss; ma_pa_channel_map cmap; ma_pa_buffer_attr attr; const ma_pa_sample_spec* pActualSS = NULL; const ma_pa_buffer_attr* pActualAttr = NULL; ma_uint32 iChannel; ma_pa_stream_flags_t streamFlags; MA_ASSERT(pDevice != NULL); MA_ZERO_OBJECT(&pDevice->pulse); if (pConfig->deviceType == ma_device_type_loopback) { return MA_DEVICE_TYPE_NOT_SUPPORTED; } /* No exclusive mode with the PulseAudio backend. */ if (((pConfig->deviceType == ma_device_type_playback || pConfig->deviceType == ma_device_type_duplex) && pConfig->playback.shareMode == ma_share_mode_exclusive) || ((pConfig->deviceType == ma_device_type_capture || pConfig->deviceType == ma_device_type_duplex) && pConfig->capture.shareMode == ma_share_mode_exclusive)) { return MA_SHARE_MODE_NOT_SUPPORTED; } if (pConfig->deviceType == ma_device_type_playback || pConfig->deviceType == ma_device_type_duplex) { if (pDescriptorPlayback->pDeviceID != NULL) { devPlayback = pDescriptorPlayback->pDeviceID->pulse; } format = pDescriptorPlayback->format; channels = pDescriptorPlayback->channels; sampleRate = pDescriptorPlayback->sampleRate; } if (pConfig->deviceType == ma_device_type_capture || pConfig->deviceType == ma_device_type_duplex) { if (pDescriptorCapture->pDeviceID != NULL) { devCapture = pDescriptorCapture->pDeviceID->pulse; } format = pDescriptorCapture->format; channels = pDescriptorCapture->channels; sampleRate = pDescriptorCapture->sampleRate; } result = ma_init_pa_mainloop_and_pa_context__pulse(pDevice->pContext, pDevice->pContext->pulse.pApplicationName, pDevice->pContext->pulse.pServerName, MA_FALSE, &pDevice->pulse.pMainLoop, &pDevice->pulse.pPulseContext); if (result != MA_SUCCESS) { ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[PulseAudio] Failed to initialize PA mainloop and context for device.\n"); return result; } if (pConfig->deviceType == ma_device_type_capture || pConfig->deviceType == ma_device_type_duplex) { result = ma_context_get_source_info__pulse(pDevice->pContext, devCapture, &sourceInfo); if (result != MA_SUCCESS) { ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[PulseAudio] Failed to retrieve source info for capture device."); goto on_error0; } ss = sourceInfo.sample_spec; cmap = sourceInfo.channel_map; /* Use the requested channel count if we have one. */ if (pDescriptorCapture->channels != 0) { ss.channels = pDescriptorCapture->channels; } /* Use a default channel map. */ ((ma_pa_channel_map_init_extend_proc)pDevice->pContext->pulse.pa_channel_map_init_extend)(&cmap, ss.channels, MA_PA_CHANNEL_MAP_DEFAULT); /* Use the requested sample rate if one was specified. */ if (pDescriptorCapture->sampleRate != 0) { ss.rate = pDescriptorCapture->sampleRate; } streamFlags = MA_PA_STREAM_START_CORKED | MA_PA_STREAM_ADJUST_LATENCY; if (ma_format_from_pulse(ss.format) == ma_format_unknown) { if (ma_is_little_endian()) { ss.format = MA_PA_SAMPLE_FLOAT32LE; } else { ss.format = MA_PA_SAMPLE_FLOAT32BE; } streamFlags |= MA_PA_STREAM_FIX_FORMAT; ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_INFO, "[PulseAudio] sample_spec.format not supported by miniaudio. Defaulting to PA_SAMPLE_FLOAT32.\n"); } if (ss.rate == 0) { ss.rate = MA_DEFAULT_SAMPLE_RATE; streamFlags |= MA_PA_STREAM_FIX_RATE; ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_INFO, "[PulseAudio] sample_spec.rate = 0. Defaulting to %d.\n", ss.rate); } if (ss.channels == 0) { ss.channels = MA_DEFAULT_CHANNELS; streamFlags |= MA_PA_STREAM_FIX_CHANNELS; ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_INFO, "[PulseAudio] sample_spec.channels = 0. Defaulting to %d.\n", ss.channels); } /* We now have enough information to calculate our actual period size in frames. */ pDescriptorCapture->periodSizeInFrames = ma_calculate_period_size_in_frames_from_descriptor__pulse(pDescriptorCapture, ss.rate, pConfig->performanceProfile); attr = ma_device__pa_buffer_attr_new(pDescriptorCapture->periodSizeInFrames, pDescriptorCapture->periodCount, &ss); ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_INFO, "[PulseAudio] Capture attr: maxlength=%d, tlength=%d, prebuf=%d, minreq=%d, fragsize=%d; periodSizeInFrames=%d\n", attr.maxlength, attr.tlength, attr.prebuf, attr.minreq, attr.fragsize, pDescriptorCapture->periodSizeInFrames); pDevice->pulse.pStreamCapture = ma_device__pa_stream_new__pulse(pDevice, pConfig->pulse.pStreamNameCapture, &ss, &cmap); if (pDevice->pulse.pStreamCapture == NULL) { ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[PulseAudio] Failed to create PulseAudio capture stream.\n"); result = MA_ERROR; goto on_error0; } /* The callback needs to be set before connecting the stream. */ ((ma_pa_stream_set_read_callback_proc)pDevice->pContext->pulse.pa_stream_set_read_callback)((ma_pa_stream*)pDevice->pulse.pStreamCapture, ma_device_on_read__pulse, pDevice); /* State callback for checking when the device has been corked. */ ((ma_pa_stream_set_suspended_callback_proc)pDevice->pContext->pulse.pa_stream_set_suspended_callback)((ma_pa_stream*)pDevice->pulse.pStreamCapture, ma_device_on_suspended__pulse, pDevice); /* Rerouting notification. */ ((ma_pa_stream_set_moved_callback_proc)pDevice->pContext->pulse.pa_stream_set_moved_callback)((ma_pa_stream*)pDevice->pulse.pStreamCapture, ma_device_on_rerouted__pulse, pDevice); /* Connect after we've got all of our internal state set up. */ if (devCapture != NULL) { streamFlags |= MA_PA_STREAM_DONT_MOVE; } error = ((ma_pa_stream_connect_record_proc)pDevice->pContext->pulse.pa_stream_connect_record)((ma_pa_stream*)pDevice->pulse.pStreamCapture, devCapture, &attr, streamFlags); if (error != MA_PA_OK) { ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[PulseAudio] Failed to connect PulseAudio capture stream."); result = ma_result_from_pulse(error); goto on_error1; } result = ma_wait_for_pa_stream_to_connect__pulse(pDevice->pContext, pDevice->pulse.pMainLoop, (ma_pa_stream*)pDevice->pulse.pStreamCapture); if (result != MA_SUCCESS) { goto on_error2; } /* Internal format. */ pActualSS = ((ma_pa_stream_get_sample_spec_proc)pDevice->pContext->pulse.pa_stream_get_sample_spec)((ma_pa_stream*)pDevice->pulse.pStreamCapture); if (pActualSS != NULL) { ss = *pActualSS; ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_INFO, "[PulseAudio] Capture sample spec: format=%s, channels=%d, rate=%d\n", ma_get_format_name(ma_format_from_pulse(ss.format)), ss.channels, ss.rate); } else { ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_INFO, "[PulseAudio] Failed to retrieve capture sample spec.\n"); } pDescriptorCapture->format = ma_format_from_pulse(ss.format); pDescriptorCapture->channels = ss.channels; pDescriptorCapture->sampleRate = ss.rate; if (pDescriptorCapture->format == ma_format_unknown || pDescriptorCapture->channels == 0 || pDescriptorCapture->sampleRate == 0) { ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[PulseAudio] Capture sample spec is invalid. Device unusable by miniaudio. format=%s, channels=%d, sampleRate=%d.\n", ma_get_format_name(pDescriptorCapture->format), pDescriptorCapture->channels, pDescriptorCapture->sampleRate); result = MA_ERROR; goto on_error4; } /* Internal channel map. */ /* Bug in PipeWire. There have been reports that PipeWire is returning AUX channels when reporting the channel map. To somewhat workaround this, I'm hacking in a hard coded channel map for mono and stereo. In this case it should be safe to assume mono = MONO and stereo = LEFT/RIGHT. For all other channel counts we need to just put up with whatever PipeWire reports and hope it gets fixed sooner than later. I might remove this hack later. */ if (pDescriptorCapture->channels > 2) { for (iChannel = 0; iChannel < pDescriptorCapture->channels; ++iChannel) { pDescriptorCapture->channelMap[iChannel] = ma_channel_position_from_pulse(cmap.map[iChannel]); } } else { /* Hack for mono and stereo. */ if (pDescriptorCapture->channels == 1) { pDescriptorCapture->channelMap[0] = MA_CHANNEL_MONO; } else if (pDescriptorCapture->channels == 2) { pDescriptorCapture->channelMap[0] = MA_CHANNEL_FRONT_LEFT; pDescriptorCapture->channelMap[1] = MA_CHANNEL_FRONT_RIGHT; } else { MA_ASSERT(MA_FALSE); /* Should never hit this. */ } } /* Buffer. */ pActualAttr = ((ma_pa_stream_get_buffer_attr_proc)pDevice->pContext->pulse.pa_stream_get_buffer_attr)((ma_pa_stream*)pDevice->pulse.pStreamCapture); if (pActualAttr != NULL) { attr = *pActualAttr; } if (attr.fragsize > 0) { pDescriptorCapture->periodCount = ma_max(attr.maxlength / attr.fragsize, 1); } else { pDescriptorCapture->periodCount = 1; } pDescriptorCapture->periodSizeInFrames = attr.maxlength / ma_get_bytes_per_frame(pDescriptorCapture->format, pDescriptorCapture->channels) / pDescriptorCapture->periodCount; ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_INFO, "[PulseAudio] Capture actual attr: maxlength=%d, tlength=%d, prebuf=%d, minreq=%d, fragsize=%d; periodSizeInFrames=%d\n", attr.maxlength, attr.tlength, attr.prebuf, attr.minreq, attr.fragsize, pDescriptorCapture->periodSizeInFrames); } if (pConfig->deviceType == ma_device_type_playback || pConfig->deviceType == ma_device_type_duplex) { result = ma_context_get_sink_info__pulse(pDevice->pContext, devPlayback, &sinkInfo); if (result != MA_SUCCESS) { ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[PulseAudio] Failed to retrieve sink info for playback device.\n"); goto on_error2; } ss = sinkInfo.sample_spec; cmap = sinkInfo.channel_map; /* Use the requested channel count if we have one. */ if (pDescriptorPlayback->channels != 0) { ss.channels = pDescriptorPlayback->channels; } /* Use a default channel map. */ ((ma_pa_channel_map_init_extend_proc)pDevice->pContext->pulse.pa_channel_map_init_extend)(&cmap, ss.channels, MA_PA_CHANNEL_MAP_DEFAULT); /* Use the requested sample rate if one was specified. */ if (pDescriptorPlayback->sampleRate != 0) { ss.rate = pDescriptorPlayback->sampleRate; } streamFlags = MA_PA_STREAM_START_CORKED | MA_PA_STREAM_ADJUST_LATENCY; if (ma_format_from_pulse(ss.format) == ma_format_unknown) { if (ma_is_little_endian()) { ss.format = MA_PA_SAMPLE_FLOAT32LE; } else { ss.format = MA_PA_SAMPLE_FLOAT32BE; } streamFlags |= MA_PA_STREAM_FIX_FORMAT; ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_INFO, "[PulseAudio] sample_spec.format not supported by miniaudio. Defaulting to PA_SAMPLE_FLOAT32.\n"); } if (ss.rate == 0) { ss.rate = MA_DEFAULT_SAMPLE_RATE; streamFlags |= MA_PA_STREAM_FIX_RATE; ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_INFO, "[PulseAudio] sample_spec.rate = 0. Defaulting to %d.\n", ss.rate); } if (ss.channels == 0) { ss.channels = MA_DEFAULT_CHANNELS; streamFlags |= MA_PA_STREAM_FIX_CHANNELS; ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_INFO, "[PulseAudio] sample_spec.channels = 0. Defaulting to %d.\n", ss.channels); } /* We now have enough information to calculate the actual buffer size in frames. */ pDescriptorPlayback->periodSizeInFrames = ma_calculate_period_size_in_frames_from_descriptor__pulse(pDescriptorPlayback, ss.rate, pConfig->performanceProfile); attr = ma_device__pa_buffer_attr_new(pDescriptorPlayback->periodSizeInFrames, pDescriptorPlayback->periodCount, &ss); ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_INFO, "[PulseAudio] Playback attr: maxlength=%d, tlength=%d, prebuf=%d, minreq=%d, fragsize=%d; periodSizeInFrames=%d\n", attr.maxlength, attr.tlength, attr.prebuf, attr.minreq, attr.fragsize, pDescriptorPlayback->periodSizeInFrames); pDevice->pulse.pStreamPlayback = ma_device__pa_stream_new__pulse(pDevice, pConfig->pulse.pStreamNamePlayback, &ss, &cmap); if (pDevice->pulse.pStreamPlayback == NULL) { ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[PulseAudio] Failed to create PulseAudio playback stream.\n"); result = MA_ERROR; goto on_error2; } /* Note that this callback will be fired as soon as the stream is connected, even though it's started as corked. The callback needs to handle a device state of ma_device_state_uninitialized. */ ((ma_pa_stream_set_write_callback_proc)pDevice->pContext->pulse.pa_stream_set_write_callback)((ma_pa_stream*)pDevice->pulse.pStreamPlayback, ma_device_on_write__pulse, pDevice); /* State callback for checking when the device has been corked. */ ((ma_pa_stream_set_suspended_callback_proc)pDevice->pContext->pulse.pa_stream_set_suspended_callback)((ma_pa_stream*)pDevice->pulse.pStreamPlayback, ma_device_on_suspended__pulse, pDevice); /* Rerouting notification. */ ((ma_pa_stream_set_moved_callback_proc)pDevice->pContext->pulse.pa_stream_set_moved_callback)((ma_pa_stream*)pDevice->pulse.pStreamPlayback, ma_device_on_rerouted__pulse, pDevice); /* Connect after we've got all of our internal state set up. */ if (devPlayback != NULL) { streamFlags |= MA_PA_STREAM_DONT_MOVE; } error = ((ma_pa_stream_connect_playback_proc)pDevice->pContext->pulse.pa_stream_connect_playback)((ma_pa_stream*)pDevice->pulse.pStreamPlayback, devPlayback, &attr, streamFlags, NULL, NULL); if (error != MA_PA_OK) { ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[PulseAudio] Failed to connect PulseAudio playback stream."); result = ma_result_from_pulse(error); goto on_error3; } result = ma_wait_for_pa_stream_to_connect__pulse(pDevice->pContext, pDevice->pulse.pMainLoop, (ma_pa_stream*)pDevice->pulse.pStreamPlayback); if (result != MA_SUCCESS) { goto on_error3; } /* Internal format. */ pActualSS = ((ma_pa_stream_get_sample_spec_proc)pDevice->pContext->pulse.pa_stream_get_sample_spec)((ma_pa_stream*)pDevice->pulse.pStreamPlayback); if (pActualSS != NULL) { ss = *pActualSS; ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_INFO, "[PulseAudio] Playback sample spec: format=%s, channels=%d, rate=%d\n", ma_get_format_name(ma_format_from_pulse(ss.format)), ss.channels, ss.rate); } else { ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_INFO, "[PulseAudio] Failed to retrieve playback sample spec.\n"); } pDescriptorPlayback->format = ma_format_from_pulse(ss.format); pDescriptorPlayback->channels = ss.channels; pDescriptorPlayback->sampleRate = ss.rate; if (pDescriptorPlayback->format == ma_format_unknown || pDescriptorPlayback->channels == 0 || pDescriptorPlayback->sampleRate == 0) { ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[PulseAudio] Playback sample spec is invalid. Device unusable by miniaudio. format=%s, channels=%d, sampleRate=%d.\n", ma_get_format_name(pDescriptorPlayback->format), pDescriptorPlayback->channels, pDescriptorPlayback->sampleRate); result = MA_ERROR; goto on_error4; } /* Internal channel map. */ /* Bug in PipeWire. There have been reports that PipeWire is returning AUX channels when reporting the channel map. To somewhat workaround this, I'm hacking in a hard coded channel map for mono and stereo. In this case it should be safe to assume mono = MONO and stereo = LEFT/RIGHT. For all other channel counts we need to just put up with whatever PipeWire reports and hope it gets fixed sooner than later. I might remove this hack later. */ if (pDescriptorPlayback->channels > 2) { for (iChannel = 0; iChannel < pDescriptorPlayback->channels; ++iChannel) { pDescriptorPlayback->channelMap[iChannel] = ma_channel_position_from_pulse(cmap.map[iChannel]); } } else { /* Hack for mono and stereo. */ if (pDescriptorPlayback->channels == 1) { pDescriptorPlayback->channelMap[0] = MA_CHANNEL_MONO; } else if (pDescriptorPlayback->channels == 2) { pDescriptorPlayback->channelMap[0] = MA_CHANNEL_FRONT_LEFT; pDescriptorPlayback->channelMap[1] = MA_CHANNEL_FRONT_RIGHT; } else { MA_ASSERT(MA_FALSE); /* Should never hit this. */ } } /* Buffer. */ pActualAttr = ((ma_pa_stream_get_buffer_attr_proc)pDevice->pContext->pulse.pa_stream_get_buffer_attr)((ma_pa_stream*)pDevice->pulse.pStreamPlayback); if (pActualAttr != NULL) { attr = *pActualAttr; } if (attr.tlength > 0) { pDescriptorPlayback->periodCount = ma_max(attr.maxlength / attr.tlength, 1); } else { pDescriptorPlayback->periodCount = 1; } pDescriptorPlayback->periodSizeInFrames = attr.maxlength / ma_get_bytes_per_frame(pDescriptorPlayback->format, pDescriptorPlayback->channels) / pDescriptorPlayback->periodCount; ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_INFO, "[PulseAudio] Playback actual attr: maxlength=%d, tlength=%d, prebuf=%d, minreq=%d, fragsize=%d; internalPeriodSizeInFrames=%d\n", attr.maxlength, attr.tlength, attr.prebuf, attr.minreq, attr.fragsize, pDescriptorPlayback->periodSizeInFrames); } /* We need a ring buffer for handling duplex mode. We can use the main duplex ring buffer in the main part of the ma_device struct. We cannot, however, depend on ma_device_init() initializing this for us later on because that will only do it if it's a fully asynchronous backend - i.e. the onDeviceDataLoop callback is NULL, which is not the case for PulseAudio. */ if (pConfig->deviceType == ma_device_type_duplex) { ma_format rbFormat = (format != ma_format_unknown) ? format : pDescriptorCapture->format; ma_uint32 rbChannels = (channels > 0) ? channels : pDescriptorCapture->channels; ma_uint32 rbSampleRate = (sampleRate > 0) ? sampleRate : pDescriptorCapture->sampleRate; result = ma_duplex_rb_init(rbFormat, rbChannels, rbSampleRate, pDescriptorCapture->sampleRate, pDescriptorCapture->periodSizeInFrames, &pDevice->pContext->allocationCallbacks, &pDevice->duplexRB); if (result != MA_SUCCESS) { ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[PulseAudio] Failed to initialize ring buffer. %s.\n", ma_result_description(result)); goto on_error4; } } return MA_SUCCESS; on_error4: if (pConfig->deviceType == ma_device_type_playback || pConfig->deviceType == ma_device_type_duplex) { ((ma_pa_stream_disconnect_proc)pDevice->pContext->pulse.pa_stream_disconnect)((ma_pa_stream*)pDevice->pulse.pStreamPlayback); } on_error3: if (pConfig->deviceType == ma_device_type_playback || pConfig->deviceType == ma_device_type_duplex) { ((ma_pa_stream_unref_proc)pDevice->pContext->pulse.pa_stream_unref)((ma_pa_stream*)pDevice->pulse.pStreamPlayback); } on_error2: if (pConfig->deviceType == ma_device_type_capture || pConfig->deviceType == ma_device_type_duplex) { ((ma_pa_stream_disconnect_proc)pDevice->pContext->pulse.pa_stream_disconnect)((ma_pa_stream*)pDevice->pulse.pStreamCapture); } on_error1: if (pConfig->deviceType == ma_device_type_capture || pConfig->deviceType == ma_device_type_duplex) { ((ma_pa_stream_unref_proc)pDevice->pContext->pulse.pa_stream_unref)((ma_pa_stream*)pDevice->pulse.pStreamCapture); } on_error0: return result; } static void ma_pulse_operation_complete_callback(ma_pa_stream* pStream, int success, void* pUserData) { ma_bool32* pIsSuccessful = (ma_bool32*)pUserData; MA_ASSERT(pIsSuccessful != NULL); *pIsSuccessful = (ma_bool32)success; (void)pStream; /* Unused. */ } static ma_result ma_device__cork_stream__pulse(ma_device* pDevice, ma_device_type deviceType, int cork) { ma_context* pContext = pDevice->pContext; ma_bool32 wasSuccessful; ma_pa_stream* pStream; ma_pa_operation* pOP; ma_result result; /* This should not be called with a duplex device type. */ if (deviceType == ma_device_type_duplex) { return MA_INVALID_ARGS; } wasSuccessful = MA_FALSE; pStream = (ma_pa_stream*)((deviceType == ma_device_type_capture) ? pDevice->pulse.pStreamCapture : pDevice->pulse.pStreamPlayback); MA_ASSERT(pStream != NULL); pOP = ((ma_pa_stream_cork_proc)pContext->pulse.pa_stream_cork)(pStream, cork, ma_pulse_operation_complete_callback, &wasSuccessful); if (pOP == NULL) { ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[PulseAudio] Failed to cork PulseAudio stream."); return MA_ERROR; } result = ma_wait_for_operation_and_unref__pulse(pDevice->pContext, pDevice->pulse.pMainLoop, pOP); if (result != MA_SUCCESS) { ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[PulseAudio] An error occurred while waiting for the PulseAudio stream to cork."); return result; } if (!wasSuccessful) { ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[PulseAudio] Failed to %s PulseAudio stream.", (cork) ? "stop" : "start"); return MA_ERROR; } return MA_SUCCESS; } static ma_result ma_device_start__pulse(ma_device* pDevice) { ma_result result; MA_ASSERT(pDevice != NULL); if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) { result = ma_device__cork_stream__pulse(pDevice, ma_device_type_capture, 0); if (result != MA_SUCCESS) { return result; } } if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) { /* We need to fill some data before uncorking. Not doing this will result in the write callback never getting fired. We're not going to abort if writing fails because I still want the device to get uncorked. */ ma_device_write_to_stream__pulse(pDevice, (ma_pa_stream*)(pDevice->pulse.pStreamPlayback), NULL); /* No need to check the result here. Always want to fall through an uncork.*/ result = ma_device__cork_stream__pulse(pDevice, ma_device_type_playback, 0); if (result != MA_SUCCESS) { return result; } } return MA_SUCCESS; } static ma_result ma_device_stop__pulse(ma_device* pDevice) { ma_result result; MA_ASSERT(pDevice != NULL); if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) { result = ma_device__cork_stream__pulse(pDevice, ma_device_type_capture, 1); if (result != MA_SUCCESS) { return result; } } if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) { /* Ideally we would drain the device here, but there's been cases where PulseAudio seems to be broken on some systems to the point where no audio processing seems to happen. When this happens, draining never completes and we get stuck here. For now I'm disabling draining of the device so we don't just freeze the application. */ #if 0 ma_pa_operation* pOP = ((ma_pa_stream_drain_proc)pDevice->pContext->pulse.pa_stream_drain)((ma_pa_stream*)pDevice->pulse.pStreamPlayback, ma_pulse_operation_complete_callback, &wasSuccessful); ma_wait_for_operation_and_unref__pulse(pDevice->pContext, pDevice->pulse.pMainLoop, pOP); #endif result = ma_device__cork_stream__pulse(pDevice, ma_device_type_playback, 1); if (result != MA_SUCCESS) { return result; } } return MA_SUCCESS; } static ma_result ma_device_data_loop__pulse(ma_device* pDevice) { int resultPA; MA_ASSERT(pDevice != NULL); /* NOTE: Don't start the device here. It'll be done at a higher level. */ /* All data is handled through callbacks. All we need to do is iterate over the main loop and let the callbacks deal with it. */ while (ma_device_get_state(pDevice) == ma_device_state_started) { resultPA = ((ma_pa_mainloop_iterate_proc)pDevice->pContext->pulse.pa_mainloop_iterate)((ma_pa_mainloop*)pDevice->pulse.pMainLoop, 1, NULL); if (resultPA < 0) { break; } } /* NOTE: Don't stop the device here. It'll be done at a higher level. */ return MA_SUCCESS; } static ma_result ma_device_data_loop_wakeup__pulse(ma_device* pDevice) { MA_ASSERT(pDevice != NULL); ((ma_pa_mainloop_wakeup_proc)pDevice->pContext->pulse.pa_mainloop_wakeup)((ma_pa_mainloop*)pDevice->pulse.pMainLoop); return MA_SUCCESS; } static ma_result ma_context_uninit__pulse(ma_context* pContext) { MA_ASSERT(pContext != NULL); MA_ASSERT(pContext->backend == ma_backend_pulseaudio); ((ma_pa_context_disconnect_proc)pContext->pulse.pa_context_disconnect)((ma_pa_context*)pContext->pulse.pPulseContext); ((ma_pa_context_unref_proc)pContext->pulse.pa_context_unref)((ma_pa_context*)pContext->pulse.pPulseContext); ((ma_pa_mainloop_free_proc)pContext->pulse.pa_mainloop_free)((ma_pa_mainloop*)pContext->pulse.pMainLoop); ma_free(pContext->pulse.pServerName, &pContext->allocationCallbacks); ma_free(pContext->pulse.pApplicationName, &pContext->allocationCallbacks); #ifndef MA_NO_RUNTIME_LINKING ma_dlclose(ma_context_get_log(pContext), pContext->pulse.pulseSO); #endif return MA_SUCCESS; } static ma_result ma_context_init__pulse(ma_context* pContext, const ma_context_config* pConfig, ma_backend_callbacks* pCallbacks) { ma_result result; #ifndef MA_NO_RUNTIME_LINKING const char* libpulseNames[] = { "libpulse.so", "libpulse.so.0" }; size_t i; for (i = 0; i < ma_countof(libpulseNames); ++i) { pContext->pulse.pulseSO = ma_dlopen(ma_context_get_log(pContext), libpulseNames[i]); if (pContext->pulse.pulseSO != NULL) { break; } } if (pContext->pulse.pulseSO == NULL) { return MA_NO_BACKEND; } pContext->pulse.pa_mainloop_new = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->pulse.pulseSO, "pa_mainloop_new"); pContext->pulse.pa_mainloop_free = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->pulse.pulseSO, "pa_mainloop_free"); pContext->pulse.pa_mainloop_quit = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->pulse.pulseSO, "pa_mainloop_quit"); pContext->pulse.pa_mainloop_get_api = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->pulse.pulseSO, "pa_mainloop_get_api"); pContext->pulse.pa_mainloop_iterate = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->pulse.pulseSO, "pa_mainloop_iterate"); pContext->pulse.pa_mainloop_wakeup = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->pulse.pulseSO, "pa_mainloop_wakeup"); pContext->pulse.pa_threaded_mainloop_new = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->pulse.pulseSO, "pa_threaded_mainloop_new"); pContext->pulse.pa_threaded_mainloop_free = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->pulse.pulseSO, "pa_threaded_mainloop_free"); pContext->pulse.pa_threaded_mainloop_start = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->pulse.pulseSO, "pa_threaded_mainloop_start"); pContext->pulse.pa_threaded_mainloop_stop = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->pulse.pulseSO, "pa_threaded_mainloop_stop"); pContext->pulse.pa_threaded_mainloop_lock = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->pulse.pulseSO, "pa_threaded_mainloop_lock"); pContext->pulse.pa_threaded_mainloop_unlock = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->pulse.pulseSO, "pa_threaded_mainloop_unlock"); pContext->pulse.pa_threaded_mainloop_wait = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->pulse.pulseSO, "pa_threaded_mainloop_wait"); pContext->pulse.pa_threaded_mainloop_signal = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->pulse.pulseSO, "pa_threaded_mainloop_signal"); pContext->pulse.pa_threaded_mainloop_accept = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->pulse.pulseSO, "pa_threaded_mainloop_accept"); pContext->pulse.pa_threaded_mainloop_get_retval = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->pulse.pulseSO, "pa_threaded_mainloop_get_retval"); pContext->pulse.pa_threaded_mainloop_get_api = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->pulse.pulseSO, "pa_threaded_mainloop_get_api"); pContext->pulse.pa_threaded_mainloop_in_thread = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->pulse.pulseSO, "pa_threaded_mainloop_in_thread"); pContext->pulse.pa_threaded_mainloop_set_name = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->pulse.pulseSO, "pa_threaded_mainloop_set_name"); pContext->pulse.pa_context_new = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->pulse.pulseSO, "pa_context_new"); pContext->pulse.pa_context_unref = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->pulse.pulseSO, "pa_context_unref"); pContext->pulse.pa_context_connect = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->pulse.pulseSO, "pa_context_connect"); pContext->pulse.pa_context_disconnect = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->pulse.pulseSO, "pa_context_disconnect"); pContext->pulse.pa_context_set_state_callback = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->pulse.pulseSO, "pa_context_set_state_callback"); pContext->pulse.pa_context_get_state = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->pulse.pulseSO, "pa_context_get_state"); pContext->pulse.pa_context_get_sink_info_list = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->pulse.pulseSO, "pa_context_get_sink_info_list"); pContext->pulse.pa_context_get_source_info_list = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->pulse.pulseSO, "pa_context_get_source_info_list"); pContext->pulse.pa_context_get_sink_info_by_name = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->pulse.pulseSO, "pa_context_get_sink_info_by_name"); pContext->pulse.pa_context_get_source_info_by_name = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->pulse.pulseSO, "pa_context_get_source_info_by_name"); pContext->pulse.pa_operation_unref = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->pulse.pulseSO, "pa_operation_unref"); pContext->pulse.pa_operation_get_state = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->pulse.pulseSO, "pa_operation_get_state"); pContext->pulse.pa_channel_map_init_extend = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->pulse.pulseSO, "pa_channel_map_init_extend"); pContext->pulse.pa_channel_map_valid = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->pulse.pulseSO, "pa_channel_map_valid"); pContext->pulse.pa_channel_map_compatible = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->pulse.pulseSO, "pa_channel_map_compatible"); pContext->pulse.pa_stream_new = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->pulse.pulseSO, "pa_stream_new"); pContext->pulse.pa_stream_unref = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->pulse.pulseSO, "pa_stream_unref"); pContext->pulse.pa_stream_connect_playback = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->pulse.pulseSO, "pa_stream_connect_playback"); pContext->pulse.pa_stream_connect_record = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->pulse.pulseSO, "pa_stream_connect_record"); pContext->pulse.pa_stream_disconnect = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->pulse.pulseSO, "pa_stream_disconnect"); pContext->pulse.pa_stream_get_state = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->pulse.pulseSO, "pa_stream_get_state"); pContext->pulse.pa_stream_get_sample_spec = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->pulse.pulseSO, "pa_stream_get_sample_spec"); pContext->pulse.pa_stream_get_channel_map = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->pulse.pulseSO, "pa_stream_get_channel_map"); pContext->pulse.pa_stream_get_buffer_attr = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->pulse.pulseSO, "pa_stream_get_buffer_attr"); pContext->pulse.pa_stream_set_buffer_attr = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->pulse.pulseSO, "pa_stream_set_buffer_attr"); pContext->pulse.pa_stream_get_device_name = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->pulse.pulseSO, "pa_stream_get_device_name"); pContext->pulse.pa_stream_set_write_callback = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->pulse.pulseSO, "pa_stream_set_write_callback"); pContext->pulse.pa_stream_set_read_callback = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->pulse.pulseSO, "pa_stream_set_read_callback"); pContext->pulse.pa_stream_set_suspended_callback = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->pulse.pulseSO, "pa_stream_set_suspended_callback"); pContext->pulse.pa_stream_set_moved_callback = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->pulse.pulseSO, "pa_stream_set_moved_callback"); pContext->pulse.pa_stream_is_suspended = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->pulse.pulseSO, "pa_stream_is_suspended"); pContext->pulse.pa_stream_flush = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->pulse.pulseSO, "pa_stream_flush"); pContext->pulse.pa_stream_drain = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->pulse.pulseSO, "pa_stream_drain"); pContext->pulse.pa_stream_is_corked = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->pulse.pulseSO, "pa_stream_is_corked"); pContext->pulse.pa_stream_cork = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->pulse.pulseSO, "pa_stream_cork"); pContext->pulse.pa_stream_trigger = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->pulse.pulseSO, "pa_stream_trigger"); pContext->pulse.pa_stream_begin_write = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->pulse.pulseSO, "pa_stream_begin_write"); pContext->pulse.pa_stream_write = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->pulse.pulseSO, "pa_stream_write"); pContext->pulse.pa_stream_peek = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->pulse.pulseSO, "pa_stream_peek"); pContext->pulse.pa_stream_drop = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->pulse.pulseSO, "pa_stream_drop"); pContext->pulse.pa_stream_writable_size = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->pulse.pulseSO, "pa_stream_writable_size"); pContext->pulse.pa_stream_readable_size = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->pulse.pulseSO, "pa_stream_readable_size"); #else /* This strange assignment system is just for type safety. */ ma_pa_mainloop_new_proc _pa_mainloop_new = pa_mainloop_new; ma_pa_mainloop_free_proc _pa_mainloop_free = pa_mainloop_free; ma_pa_mainloop_quit_proc _pa_mainloop_quit = pa_mainloop_quit; ma_pa_mainloop_get_api_proc _pa_mainloop_get_api = pa_mainloop_get_api; ma_pa_mainloop_iterate_proc _pa_mainloop_iterate = pa_mainloop_iterate; ma_pa_mainloop_wakeup_proc _pa_mainloop_wakeup = pa_mainloop_wakeup; ma_pa_threaded_mainloop_new_proc _pa_threaded_mainloop_new = pa_threaded_mainloop_new; ma_pa_threaded_mainloop_free_proc _pa_threaded_mainloop_free = pa_threaded_mainloop_free; ma_pa_threaded_mainloop_start_proc _pa_threaded_mainloop_start = pa_threaded_mainloop_start; ma_pa_threaded_mainloop_stop_proc _pa_threaded_mainloop_stop = pa_threaded_mainloop_stop; ma_pa_threaded_mainloop_lock_proc _pa_threaded_mainloop_lock = pa_threaded_mainloop_lock; ma_pa_threaded_mainloop_unlock_proc _pa_threaded_mainloop_unlock = pa_threaded_mainloop_unlock; ma_pa_threaded_mainloop_wait_proc _pa_threaded_mainloop_wait = pa_threaded_mainloop_wait; ma_pa_threaded_mainloop_signal_proc _pa_threaded_mainloop_signal = pa_threaded_mainloop_signal; ma_pa_threaded_mainloop_accept_proc _pa_threaded_mainloop_accept = pa_threaded_mainloop_accept; ma_pa_threaded_mainloop_get_retval_proc _pa_threaded_mainloop_get_retval = pa_threaded_mainloop_get_retval; ma_pa_threaded_mainloop_get_api_proc _pa_threaded_mainloop_get_api = pa_threaded_mainloop_get_api; ma_pa_threaded_mainloop_in_thread_proc _pa_threaded_mainloop_in_thread = pa_threaded_mainloop_in_thread; ma_pa_threaded_mainloop_set_name_proc _pa_threaded_mainloop_set_name = pa_threaded_mainloop_set_name; ma_pa_context_new_proc _pa_context_new = pa_context_new; ma_pa_context_unref_proc _pa_context_unref = pa_context_unref; ma_pa_context_connect_proc _pa_context_connect = pa_context_connect; ma_pa_context_disconnect_proc _pa_context_disconnect = pa_context_disconnect; ma_pa_context_set_state_callback_proc _pa_context_set_state_callback = pa_context_set_state_callback; ma_pa_context_get_state_proc _pa_context_get_state = pa_context_get_state; ma_pa_context_get_sink_info_list_proc _pa_context_get_sink_info_list = pa_context_get_sink_info_list; ma_pa_context_get_source_info_list_proc _pa_context_get_source_info_list = pa_context_get_source_info_list; ma_pa_context_get_sink_info_by_name_proc _pa_context_get_sink_info_by_name = pa_context_get_sink_info_by_name; ma_pa_context_get_source_info_by_name_proc _pa_context_get_source_info_by_name= pa_context_get_source_info_by_name; ma_pa_operation_unref_proc _pa_operation_unref = pa_operation_unref; ma_pa_operation_get_state_proc _pa_operation_get_state = pa_operation_get_state; ma_pa_channel_map_init_extend_proc _pa_channel_map_init_extend = pa_channel_map_init_extend; ma_pa_channel_map_valid_proc _pa_channel_map_valid = pa_channel_map_valid; ma_pa_channel_map_compatible_proc _pa_channel_map_compatible = pa_channel_map_compatible; ma_pa_stream_new_proc _pa_stream_new = pa_stream_new; ma_pa_stream_unref_proc _pa_stream_unref = pa_stream_unref; ma_pa_stream_connect_playback_proc _pa_stream_connect_playback = pa_stream_connect_playback; ma_pa_stream_connect_record_proc _pa_stream_connect_record = pa_stream_connect_record; ma_pa_stream_disconnect_proc _pa_stream_disconnect = pa_stream_disconnect; ma_pa_stream_get_state_proc _pa_stream_get_state = pa_stream_get_state; ma_pa_stream_get_sample_spec_proc _pa_stream_get_sample_spec = pa_stream_get_sample_spec; ma_pa_stream_get_channel_map_proc _pa_stream_get_channel_map = pa_stream_get_channel_map; ma_pa_stream_get_buffer_attr_proc _pa_stream_get_buffer_attr = pa_stream_get_buffer_attr; ma_pa_stream_set_buffer_attr_proc _pa_stream_set_buffer_attr = pa_stream_set_buffer_attr; ma_pa_stream_get_device_name_proc _pa_stream_get_device_name = pa_stream_get_device_name; ma_pa_stream_set_write_callback_proc _pa_stream_set_write_callback = pa_stream_set_write_callback; ma_pa_stream_set_read_callback_proc _pa_stream_set_read_callback = pa_stream_set_read_callback; ma_pa_stream_set_suspended_callback_proc _pa_stream_set_suspended_callback = pa_stream_set_suspended_callback; ma_pa_stream_set_moved_callback_proc _pa_stream_set_moved_callback = pa_stream_set_moved_callback; ma_pa_stream_is_suspended_proc _pa_stream_is_suspended = pa_stream_is_suspended; ma_pa_stream_flush_proc _pa_stream_flush = pa_stream_flush; ma_pa_stream_drain_proc _pa_stream_drain = pa_stream_drain; ma_pa_stream_is_corked_proc _pa_stream_is_corked = pa_stream_is_corked; ma_pa_stream_cork_proc _pa_stream_cork = pa_stream_cork; ma_pa_stream_trigger_proc _pa_stream_trigger = pa_stream_trigger; ma_pa_stream_begin_write_proc _pa_stream_begin_write = pa_stream_begin_write; ma_pa_stream_write_proc _pa_stream_write = pa_stream_write; ma_pa_stream_peek_proc _pa_stream_peek = pa_stream_peek; ma_pa_stream_drop_proc _pa_stream_drop = pa_stream_drop; ma_pa_stream_writable_size_proc _pa_stream_writable_size = pa_stream_writable_size; ma_pa_stream_readable_size_proc _pa_stream_readable_size = pa_stream_readable_size; pContext->pulse.pa_mainloop_new = (ma_proc)_pa_mainloop_new; pContext->pulse.pa_mainloop_free = (ma_proc)_pa_mainloop_free; pContext->pulse.pa_mainloop_quit = (ma_proc)_pa_mainloop_quit; pContext->pulse.pa_mainloop_get_api = (ma_proc)_pa_mainloop_get_api; pContext->pulse.pa_mainloop_iterate = (ma_proc)_pa_mainloop_iterate; pContext->pulse.pa_mainloop_wakeup = (ma_proc)_pa_mainloop_wakeup; pContext->pulse.pa_threaded_mainloop_new = (ma_proc)_pa_threaded_mainloop_new; pContext->pulse.pa_threaded_mainloop_free = (ma_proc)_pa_threaded_mainloop_free; pContext->pulse.pa_threaded_mainloop_start = (ma_proc)_pa_threaded_mainloop_start; pContext->pulse.pa_threaded_mainloop_stop = (ma_proc)_pa_threaded_mainloop_stop; pContext->pulse.pa_threaded_mainloop_lock = (ma_proc)_pa_threaded_mainloop_lock; pContext->pulse.pa_threaded_mainloop_unlock = (ma_proc)_pa_threaded_mainloop_unlock; pContext->pulse.pa_threaded_mainloop_wait = (ma_proc)_pa_threaded_mainloop_wait; pContext->pulse.pa_threaded_mainloop_signal = (ma_proc)_pa_threaded_mainloop_signal; pContext->pulse.pa_threaded_mainloop_accept = (ma_proc)_pa_threaded_mainloop_accept; pContext->pulse.pa_threaded_mainloop_get_retval = (ma_proc)_pa_threaded_mainloop_get_retval; pContext->pulse.pa_threaded_mainloop_get_api = (ma_proc)_pa_threaded_mainloop_get_api; pContext->pulse.pa_threaded_mainloop_in_thread = (ma_proc)_pa_threaded_mainloop_in_thread; pContext->pulse.pa_threaded_mainloop_set_name = (ma_proc)_pa_threaded_mainloop_set_name; pContext->pulse.pa_context_new = (ma_proc)_pa_context_new; pContext->pulse.pa_context_unref = (ma_proc)_pa_context_unref; pContext->pulse.pa_context_connect = (ma_proc)_pa_context_connect; pContext->pulse.pa_context_disconnect = (ma_proc)_pa_context_disconnect; pContext->pulse.pa_context_set_state_callback = (ma_proc)_pa_context_set_state_callback; pContext->pulse.pa_context_get_state = (ma_proc)_pa_context_get_state; pContext->pulse.pa_context_get_sink_info_list = (ma_proc)_pa_context_get_sink_info_list; pContext->pulse.pa_context_get_source_info_list = (ma_proc)_pa_context_get_source_info_list; pContext->pulse.pa_context_get_sink_info_by_name = (ma_proc)_pa_context_get_sink_info_by_name; pContext->pulse.pa_context_get_source_info_by_name = (ma_proc)_pa_context_get_source_info_by_name; pContext->pulse.pa_operation_unref = (ma_proc)_pa_operation_unref; pContext->pulse.pa_operation_get_state = (ma_proc)_pa_operation_get_state; pContext->pulse.pa_channel_map_init_extend = (ma_proc)_pa_channel_map_init_extend; pContext->pulse.pa_channel_map_valid = (ma_proc)_pa_channel_map_valid; pContext->pulse.pa_channel_map_compatible = (ma_proc)_pa_channel_map_compatible; pContext->pulse.pa_stream_new = (ma_proc)_pa_stream_new; pContext->pulse.pa_stream_unref = (ma_proc)_pa_stream_unref; pContext->pulse.pa_stream_connect_playback = (ma_proc)_pa_stream_connect_playback; pContext->pulse.pa_stream_connect_record = (ma_proc)_pa_stream_connect_record; pContext->pulse.pa_stream_disconnect = (ma_proc)_pa_stream_disconnect; pContext->pulse.pa_stream_get_state = (ma_proc)_pa_stream_get_state; pContext->pulse.pa_stream_get_sample_spec = (ma_proc)_pa_stream_get_sample_spec; pContext->pulse.pa_stream_get_channel_map = (ma_proc)_pa_stream_get_channel_map; pContext->pulse.pa_stream_get_buffer_attr = (ma_proc)_pa_stream_get_buffer_attr; pContext->pulse.pa_stream_set_buffer_attr = (ma_proc)_pa_stream_set_buffer_attr; pContext->pulse.pa_stream_get_device_name = (ma_proc)_pa_stream_get_device_name; pContext->pulse.pa_stream_set_write_callback = (ma_proc)_pa_stream_set_write_callback; pContext->pulse.pa_stream_set_read_callback = (ma_proc)_pa_stream_set_read_callback; pContext->pulse.pa_stream_set_suspended_callback = (ma_proc)_pa_stream_set_suspended_callback; pContext->pulse.pa_stream_set_moved_callback = (ma_proc)_pa_stream_set_moved_callback; pContext->pulse.pa_stream_is_suspended = (ma_proc)_pa_stream_is_suspended; pContext->pulse.pa_stream_flush = (ma_proc)_pa_stream_flush; pContext->pulse.pa_stream_drain = (ma_proc)_pa_stream_drain; pContext->pulse.pa_stream_is_corked = (ma_proc)_pa_stream_is_corked; pContext->pulse.pa_stream_cork = (ma_proc)_pa_stream_cork; pContext->pulse.pa_stream_trigger = (ma_proc)_pa_stream_trigger; pContext->pulse.pa_stream_begin_write = (ma_proc)_pa_stream_begin_write; pContext->pulse.pa_stream_write = (ma_proc)_pa_stream_write; pContext->pulse.pa_stream_peek = (ma_proc)_pa_stream_peek; pContext->pulse.pa_stream_drop = (ma_proc)_pa_stream_drop; pContext->pulse.pa_stream_writable_size = (ma_proc)_pa_stream_writable_size; pContext->pulse.pa_stream_readable_size = (ma_proc)_pa_stream_readable_size; #endif /* We need to make a copy of the application and server names so we can pass them to the pa_context of each device. */ pContext->pulse.pApplicationName = ma_copy_string(pConfig->pulse.pApplicationName, &pContext->allocationCallbacks); if (pContext->pulse.pApplicationName == NULL && pConfig->pulse.pApplicationName != NULL) { return MA_OUT_OF_MEMORY; } pContext->pulse.pServerName = ma_copy_string(pConfig->pulse.pServerName, &pContext->allocationCallbacks); if (pContext->pulse.pServerName == NULL && pConfig->pulse.pServerName != NULL) { ma_free(pContext->pulse.pApplicationName, &pContext->allocationCallbacks); return MA_OUT_OF_MEMORY; } result = ma_init_pa_mainloop_and_pa_context__pulse(pContext, pConfig->pulse.pApplicationName, pConfig->pulse.pServerName, pConfig->pulse.tryAutoSpawn, &pContext->pulse.pMainLoop, &pContext->pulse.pPulseContext); if (result != MA_SUCCESS) { ma_free(pContext->pulse.pServerName, &pContext->allocationCallbacks); ma_free(pContext->pulse.pApplicationName, &pContext->allocationCallbacks); #ifndef MA_NO_RUNTIME_LINKING ma_dlclose(ma_context_get_log(pContext), pContext->pulse.pulseSO); #endif return result; } /* With pa_mainloop we run a synchronous backend, but we implement our own main loop. */ pCallbacks->onContextInit = ma_context_init__pulse; pCallbacks->onContextUninit = ma_context_uninit__pulse; pCallbacks->onContextEnumerateDevices = ma_context_enumerate_devices__pulse; pCallbacks->onContextGetDeviceInfo = ma_context_get_device_info__pulse; pCallbacks->onDeviceInit = ma_device_init__pulse; pCallbacks->onDeviceUninit = ma_device_uninit__pulse; pCallbacks->onDeviceStart = ma_device_start__pulse; pCallbacks->onDeviceStop = ma_device_stop__pulse; pCallbacks->onDeviceRead = NULL; /* Not used because we're implementing onDeviceDataLoop. */ pCallbacks->onDeviceWrite = NULL; /* Not used because we're implementing onDeviceDataLoop. */ pCallbacks->onDeviceDataLoop = ma_device_data_loop__pulse; pCallbacks->onDeviceDataLoopWakeup = ma_device_data_loop_wakeup__pulse; return MA_SUCCESS; } #endif /****************************************************************************** JACK Backend ******************************************************************************/ #ifdef MA_HAS_JACK /* It is assumed jack.h is available when compile-time linking is being used. */ #ifdef MA_NO_RUNTIME_LINKING #include typedef jack_nframes_t ma_jack_nframes_t; typedef jack_options_t ma_jack_options_t; typedef jack_status_t ma_jack_status_t; typedef jack_client_t ma_jack_client_t; typedef jack_port_t ma_jack_port_t; typedef JackProcessCallback ma_JackProcessCallback; typedef JackBufferSizeCallback ma_JackBufferSizeCallback; typedef JackShutdownCallback ma_JackShutdownCallback; #define MA_JACK_DEFAULT_AUDIO_TYPE JACK_DEFAULT_AUDIO_TYPE #define ma_JackNoStartServer JackNoStartServer #define ma_JackPortIsInput JackPortIsInput #define ma_JackPortIsOutput JackPortIsOutput #define ma_JackPortIsPhysical JackPortIsPhysical #else typedef ma_uint32 ma_jack_nframes_t; typedef int ma_jack_options_t; typedef int ma_jack_status_t; typedef struct ma_jack_client_t ma_jack_client_t; typedef struct ma_jack_port_t ma_jack_port_t; typedef int (* ma_JackProcessCallback) (ma_jack_nframes_t nframes, void* arg); typedef int (* ma_JackBufferSizeCallback)(ma_jack_nframes_t nframes, void* arg); typedef void (* ma_JackShutdownCallback) (void* arg); #define MA_JACK_DEFAULT_AUDIO_TYPE "32 bit float mono audio" #define ma_JackNoStartServer 1 #define ma_JackPortIsInput 1 #define ma_JackPortIsOutput 2 #define ma_JackPortIsPhysical 4 #endif typedef ma_jack_client_t* (* ma_jack_client_open_proc) (const char* client_name, ma_jack_options_t options, ma_jack_status_t* status, ...); typedef int (* ma_jack_client_close_proc) (ma_jack_client_t* client); typedef int (* ma_jack_client_name_size_proc) (void); typedef int (* ma_jack_set_process_callback_proc) (ma_jack_client_t* client, ma_JackProcessCallback process_callback, void* arg); typedef int (* ma_jack_set_buffer_size_callback_proc)(ma_jack_client_t* client, ma_JackBufferSizeCallback bufsize_callback, void* arg); typedef void (* ma_jack_on_shutdown_proc) (ma_jack_client_t* client, ma_JackShutdownCallback function, void* arg); typedef ma_jack_nframes_t (* ma_jack_get_sample_rate_proc) (ma_jack_client_t* client); typedef ma_jack_nframes_t (* ma_jack_get_buffer_size_proc) (ma_jack_client_t* client); typedef const char** (* ma_jack_get_ports_proc) (ma_jack_client_t* client, const char* port_name_pattern, const char* type_name_pattern, unsigned long flags); typedef int (* ma_jack_activate_proc) (ma_jack_client_t* client); typedef int (* ma_jack_deactivate_proc) (ma_jack_client_t* client); typedef int (* ma_jack_connect_proc) (ma_jack_client_t* client, const char* source_port, const char* destination_port); typedef ma_jack_port_t* (* ma_jack_port_register_proc) (ma_jack_client_t* client, const char* port_name, const char* port_type, unsigned long flags, unsigned long buffer_size); typedef const char* (* ma_jack_port_name_proc) (const ma_jack_port_t* port); typedef void* (* ma_jack_port_get_buffer_proc) (ma_jack_port_t* port, ma_jack_nframes_t nframes); typedef void (* ma_jack_free_proc) (void* ptr); static ma_result ma_context_open_client__jack(ma_context* pContext, ma_jack_client_t** ppClient) { size_t maxClientNameSize; char clientName[256]; ma_jack_status_t status; ma_jack_client_t* pClient; MA_ASSERT(pContext != NULL); MA_ASSERT(ppClient != NULL); if (ppClient) { *ppClient = NULL; } maxClientNameSize = ((ma_jack_client_name_size_proc)pContext->jack.jack_client_name_size)(); /* Includes null terminator. */ ma_strncpy_s(clientName, ma_min(sizeof(clientName), maxClientNameSize), (pContext->jack.pClientName != NULL) ? pContext->jack.pClientName : "miniaudio", (size_t)-1); pClient = ((ma_jack_client_open_proc)pContext->jack.jack_client_open)(clientName, (pContext->jack.tryStartServer) ? 0 : ma_JackNoStartServer, &status, NULL); if (pClient == NULL) { return MA_FAILED_TO_OPEN_BACKEND_DEVICE; } if (ppClient) { *ppClient = pClient; } return MA_SUCCESS; } static ma_result ma_context_enumerate_devices__jack(ma_context* pContext, ma_enum_devices_callback_proc callback, void* pUserData) { ma_bool32 cbResult = MA_TRUE; MA_ASSERT(pContext != NULL); MA_ASSERT(callback != NULL); /* Playback. */ if (cbResult) { ma_device_info deviceInfo; MA_ZERO_OBJECT(&deviceInfo); ma_strncpy_s(deviceInfo.name, sizeof(deviceInfo.name), MA_DEFAULT_PLAYBACK_DEVICE_NAME, (size_t)-1); deviceInfo.isDefault = MA_TRUE; /* JACK only uses default devices. */ cbResult = callback(pContext, ma_device_type_playback, &deviceInfo, pUserData); } /* Capture. */ if (cbResult) { ma_device_info deviceInfo; MA_ZERO_OBJECT(&deviceInfo); ma_strncpy_s(deviceInfo.name, sizeof(deviceInfo.name), MA_DEFAULT_CAPTURE_DEVICE_NAME, (size_t)-1); deviceInfo.isDefault = MA_TRUE; /* JACK only uses default devices. */ cbResult = callback(pContext, ma_device_type_capture, &deviceInfo, pUserData); } (void)cbResult; /* For silencing a static analysis warning. */ return MA_SUCCESS; } static ma_result ma_context_get_device_info__jack(ma_context* pContext, ma_device_type deviceType, const ma_device_id* pDeviceID, ma_device_info* pDeviceInfo) { ma_jack_client_t* pClient; ma_result result; const char** ppPorts; MA_ASSERT(pContext != NULL); if (pDeviceID != NULL && pDeviceID->jack != 0) { return MA_NO_DEVICE; /* Don't know the device. */ } /* Name / Description */ if (deviceType == ma_device_type_playback) { ma_strncpy_s(pDeviceInfo->name, sizeof(pDeviceInfo->name), MA_DEFAULT_PLAYBACK_DEVICE_NAME, (size_t)-1); } else { ma_strncpy_s(pDeviceInfo->name, sizeof(pDeviceInfo->name), MA_DEFAULT_CAPTURE_DEVICE_NAME, (size_t)-1); } /* Jack only uses default devices. */ pDeviceInfo->isDefault = MA_TRUE; /* Jack only supports f32 and has a specific channel count and sample rate. */ pDeviceInfo->nativeDataFormats[0].format = ma_format_f32; /* The channel count and sample rate can only be determined by opening the device. */ result = ma_context_open_client__jack(pContext, &pClient); if (result != MA_SUCCESS) { ma_log_postf(ma_context_get_log(pContext), MA_LOG_LEVEL_ERROR, "[JACK] Failed to open client."); return result; } pDeviceInfo->nativeDataFormats[0].sampleRate = ((ma_jack_get_sample_rate_proc)pContext->jack.jack_get_sample_rate)((ma_jack_client_t*)pClient); pDeviceInfo->nativeDataFormats[0].channels = 0; ppPorts = ((ma_jack_get_ports_proc)pContext->jack.jack_get_ports)((ma_jack_client_t*)pClient, NULL, MA_JACK_DEFAULT_AUDIO_TYPE, ma_JackPortIsPhysical | ((deviceType == ma_device_type_playback) ? ma_JackPortIsInput : ma_JackPortIsOutput)); if (ppPorts == NULL) { ((ma_jack_client_close_proc)pContext->jack.jack_client_close)((ma_jack_client_t*)pClient); ma_log_postf(ma_context_get_log(pContext), MA_LOG_LEVEL_ERROR, "[JACK] Failed to query physical ports."); return MA_FAILED_TO_OPEN_BACKEND_DEVICE; } while (ppPorts[pDeviceInfo->nativeDataFormats[0].channels] != NULL) { pDeviceInfo->nativeDataFormats[0].channels += 1; } pDeviceInfo->nativeDataFormats[0].flags = 0; pDeviceInfo->nativeDataFormatCount = 1; ((ma_jack_free_proc)pContext->jack.jack_free)((void*)ppPorts); ((ma_jack_client_close_proc)pContext->jack.jack_client_close)((ma_jack_client_t*)pClient); (void)pContext; return MA_SUCCESS; } static ma_result ma_device_uninit__jack(ma_device* pDevice) { ma_context* pContext; MA_ASSERT(pDevice != NULL); pContext = pDevice->pContext; MA_ASSERT(pContext != NULL); if (pDevice->jack.pClient != NULL) { ((ma_jack_client_close_proc)pContext->jack.jack_client_close)((ma_jack_client_t*)pDevice->jack.pClient); } if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) { ma_free(pDevice->jack.pIntermediaryBufferCapture, &pDevice->pContext->allocationCallbacks); ma_free(pDevice->jack.ppPortsCapture, &pDevice->pContext->allocationCallbacks); } if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) { ma_free(pDevice->jack.pIntermediaryBufferPlayback, &pDevice->pContext->allocationCallbacks); ma_free(pDevice->jack.ppPortsPlayback, &pDevice->pContext->allocationCallbacks); } return MA_SUCCESS; } static void ma_device__jack_shutdown_callback(void* pUserData) { /* JACK died. Stop the device. */ ma_device* pDevice = (ma_device*)pUserData; MA_ASSERT(pDevice != NULL); ma_device_stop(pDevice); } static int ma_device__jack_buffer_size_callback(ma_jack_nframes_t frameCount, void* pUserData) { ma_device* pDevice = (ma_device*)pUserData; MA_ASSERT(pDevice != NULL); if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) { size_t newBufferSize = frameCount * (pDevice->capture.internalChannels * ma_get_bytes_per_sample(pDevice->capture.internalFormat)); float* pNewBuffer = (float*)ma_calloc(newBufferSize, &pDevice->pContext->allocationCallbacks); if (pNewBuffer == NULL) { return MA_OUT_OF_MEMORY; } ma_free(pDevice->jack.pIntermediaryBufferCapture, &pDevice->pContext->allocationCallbacks); pDevice->jack.pIntermediaryBufferCapture = pNewBuffer; pDevice->playback.internalPeriodSizeInFrames = frameCount; } if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) { size_t newBufferSize = frameCount * (pDevice->playback.internalChannels * ma_get_bytes_per_sample(pDevice->playback.internalFormat)); float* pNewBuffer = (float*)ma_calloc(newBufferSize, &pDevice->pContext->allocationCallbacks); if (pNewBuffer == NULL) { return MA_OUT_OF_MEMORY; } ma_free(pDevice->jack.pIntermediaryBufferPlayback, &pDevice->pContext->allocationCallbacks); pDevice->jack.pIntermediaryBufferPlayback = pNewBuffer; pDevice->playback.internalPeriodSizeInFrames = frameCount; } return 0; } static int ma_device__jack_process_callback(ma_jack_nframes_t frameCount, void* pUserData) { ma_device* pDevice; ma_context* pContext; ma_uint32 iChannel; pDevice = (ma_device*)pUserData; MA_ASSERT(pDevice != NULL); pContext = pDevice->pContext; MA_ASSERT(pContext != NULL); if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) { /* Channels need to be interleaved. */ for (iChannel = 0; iChannel < pDevice->capture.internalChannels; ++iChannel) { const float* pSrc = (const float*)((ma_jack_port_get_buffer_proc)pContext->jack.jack_port_get_buffer)((ma_jack_port_t*)pDevice->jack.ppPortsCapture[iChannel], frameCount); if (pSrc != NULL) { float* pDst = pDevice->jack.pIntermediaryBufferCapture + iChannel; ma_jack_nframes_t iFrame; for (iFrame = 0; iFrame < frameCount; ++iFrame) { *pDst = *pSrc; pDst += pDevice->capture.internalChannels; pSrc += 1; } } } ma_device_handle_backend_data_callback(pDevice, NULL, pDevice->jack.pIntermediaryBufferCapture, frameCount); } if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) { ma_device_handle_backend_data_callback(pDevice, pDevice->jack.pIntermediaryBufferPlayback, NULL, frameCount); /* Channels need to be deinterleaved. */ for (iChannel = 0; iChannel < pDevice->playback.internalChannels; ++iChannel) { float* pDst = (float*)((ma_jack_port_get_buffer_proc)pContext->jack.jack_port_get_buffer)((ma_jack_port_t*)pDevice->jack.ppPortsPlayback[iChannel], frameCount); if (pDst != NULL) { const float* pSrc = pDevice->jack.pIntermediaryBufferPlayback + iChannel; ma_jack_nframes_t iFrame; for (iFrame = 0; iFrame < frameCount; ++iFrame) { *pDst = *pSrc; pDst += 1; pSrc += pDevice->playback.internalChannels; } } } } return 0; } static ma_result ma_device_init__jack(ma_device* pDevice, const ma_device_config* pConfig, ma_device_descriptor* pDescriptorPlayback, ma_device_descriptor* pDescriptorCapture) { ma_result result; ma_uint32 periodSizeInFrames; MA_ASSERT(pConfig != NULL); MA_ASSERT(pDevice != NULL); if (pConfig->deviceType == ma_device_type_loopback) { ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[JACK] Loopback mode not supported."); return MA_DEVICE_TYPE_NOT_SUPPORTED; } /* Only supporting default devices with JACK. */ if (((pConfig->deviceType == ma_device_type_playback || pConfig->deviceType == ma_device_type_duplex) && pDescriptorPlayback->pDeviceID != NULL && pDescriptorPlayback->pDeviceID->jack != 0) || ((pConfig->deviceType == ma_device_type_capture || pConfig->deviceType == ma_device_type_duplex) && pDescriptorCapture->pDeviceID != NULL && pDescriptorCapture->pDeviceID->jack != 0)) { ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[JACK] Only default devices are supported."); return MA_NO_DEVICE; } /* No exclusive mode with the JACK backend. */ if (((pConfig->deviceType == ma_device_type_playback || pConfig->deviceType == ma_device_type_duplex) && pDescriptorPlayback->shareMode == ma_share_mode_exclusive) || ((pConfig->deviceType == ma_device_type_capture || pConfig->deviceType == ma_device_type_duplex) && pDescriptorCapture->shareMode == ma_share_mode_exclusive)) { ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[JACK] Exclusive mode not supported."); return MA_SHARE_MODE_NOT_SUPPORTED; } /* Open the client. */ result = ma_context_open_client__jack(pDevice->pContext, (ma_jack_client_t**)&pDevice->jack.pClient); if (result != MA_SUCCESS) { ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[JACK] Failed to open client."); return result; } /* Callbacks. */ if (((ma_jack_set_process_callback_proc)pDevice->pContext->jack.jack_set_process_callback)((ma_jack_client_t*)pDevice->jack.pClient, ma_device__jack_process_callback, pDevice) != 0) { ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[JACK] Failed to set process callback."); return MA_FAILED_TO_OPEN_BACKEND_DEVICE; } if (((ma_jack_set_buffer_size_callback_proc)pDevice->pContext->jack.jack_set_buffer_size_callback)((ma_jack_client_t*)pDevice->jack.pClient, ma_device__jack_buffer_size_callback, pDevice) != 0) { ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[JACK] Failed to set buffer size callback."); return MA_FAILED_TO_OPEN_BACKEND_DEVICE; } ((ma_jack_on_shutdown_proc)pDevice->pContext->jack.jack_on_shutdown)((ma_jack_client_t*)pDevice->jack.pClient, ma_device__jack_shutdown_callback, pDevice); /* The buffer size in frames can change. */ periodSizeInFrames = ((ma_jack_get_buffer_size_proc)pDevice->pContext->jack.jack_get_buffer_size)((ma_jack_client_t*)pDevice->jack.pClient); if (pConfig->deviceType == ma_device_type_capture || pConfig->deviceType == ma_device_type_duplex) { ma_uint32 iPort; const char** ppPorts; pDescriptorCapture->format = ma_format_f32; pDescriptorCapture->channels = 0; pDescriptorCapture->sampleRate = ((ma_jack_get_sample_rate_proc)pDevice->pContext->jack.jack_get_sample_rate)((ma_jack_client_t*)pDevice->jack.pClient); ma_channel_map_init_standard(ma_standard_channel_map_alsa, pDescriptorCapture->channelMap, ma_countof(pDescriptorCapture->channelMap), pDescriptorCapture->channels); ppPorts = ((ma_jack_get_ports_proc)pDevice->pContext->jack.jack_get_ports)((ma_jack_client_t*)pDevice->jack.pClient, NULL, MA_JACK_DEFAULT_AUDIO_TYPE, ma_JackPortIsPhysical | ma_JackPortIsOutput); if (ppPorts == NULL) { ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[JACK] Failed to query physical ports."); return MA_FAILED_TO_OPEN_BACKEND_DEVICE; } /* Need to count the number of ports first so we can allocate some memory. */ while (ppPorts[pDescriptorCapture->channels] != NULL) { pDescriptorCapture->channels += 1; } pDevice->jack.ppPortsCapture = (ma_ptr*)ma_malloc(sizeof(*pDevice->jack.ppPortsCapture) * pDescriptorCapture->channels, &pDevice->pContext->allocationCallbacks); if (pDevice->jack.ppPortsCapture == NULL) { return MA_OUT_OF_MEMORY; } for (iPort = 0; iPort < pDescriptorCapture->channels; iPort += 1) { char name[64]; ma_strcpy_s(name, sizeof(name), "capture"); ma_itoa_s((int)iPort, name+7, sizeof(name)-7, 10); /* 7 = length of "capture" */ pDevice->jack.ppPortsCapture[iPort] = ((ma_jack_port_register_proc)pDevice->pContext->jack.jack_port_register)((ma_jack_client_t*)pDevice->jack.pClient, name, MA_JACK_DEFAULT_AUDIO_TYPE, ma_JackPortIsInput, 0); if (pDevice->jack.ppPortsCapture[iPort] == NULL) { ((ma_jack_free_proc)pDevice->pContext->jack.jack_free)((void*)ppPorts); ma_device_uninit__jack(pDevice); ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[JACK] Failed to register ports."); return MA_FAILED_TO_OPEN_BACKEND_DEVICE; } } ((ma_jack_free_proc)pDevice->pContext->jack.jack_free)((void*)ppPorts); pDescriptorCapture->periodSizeInFrames = periodSizeInFrames; pDescriptorCapture->periodCount = 1; /* There's no notion of a period in JACK. Just set to 1. */ pDevice->jack.pIntermediaryBufferCapture = (float*)ma_calloc(pDescriptorCapture->periodSizeInFrames * ma_get_bytes_per_frame(pDescriptorCapture->format, pDescriptorCapture->channels), &pDevice->pContext->allocationCallbacks); if (pDevice->jack.pIntermediaryBufferCapture == NULL) { ma_device_uninit__jack(pDevice); return MA_OUT_OF_MEMORY; } } if (pConfig->deviceType == ma_device_type_playback || pConfig->deviceType == ma_device_type_duplex) { ma_uint32 iPort; const char** ppPorts; pDescriptorPlayback->format = ma_format_f32; pDescriptorPlayback->channels = 0; pDescriptorPlayback->sampleRate = ((ma_jack_get_sample_rate_proc)pDevice->pContext->jack.jack_get_sample_rate)((ma_jack_client_t*)pDevice->jack.pClient); ma_channel_map_init_standard(ma_standard_channel_map_alsa, pDescriptorPlayback->channelMap, ma_countof(pDescriptorPlayback->channelMap), pDescriptorPlayback->channels); ppPorts = ((ma_jack_get_ports_proc)pDevice->pContext->jack.jack_get_ports)((ma_jack_client_t*)pDevice->jack.pClient, NULL, MA_JACK_DEFAULT_AUDIO_TYPE, ma_JackPortIsPhysical | ma_JackPortIsInput); if (ppPorts == NULL) { ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[JACK] Failed to query physical ports."); return MA_FAILED_TO_OPEN_BACKEND_DEVICE; } /* Need to count the number of ports first so we can allocate some memory. */ while (ppPorts[pDescriptorPlayback->channels] != NULL) { pDescriptorPlayback->channels += 1; } pDevice->jack.ppPortsPlayback = (ma_ptr*)ma_malloc(sizeof(*pDevice->jack.ppPortsPlayback) * pDescriptorPlayback->channels, &pDevice->pContext->allocationCallbacks); if (pDevice->jack.ppPortsPlayback == NULL) { ma_free(pDevice->jack.ppPortsCapture, &pDevice->pContext->allocationCallbacks); return MA_OUT_OF_MEMORY; } for (iPort = 0; iPort < pDescriptorPlayback->channels; iPort += 1) { char name[64]; ma_strcpy_s(name, sizeof(name), "playback"); ma_itoa_s((int)iPort, name+8, sizeof(name)-8, 10); /* 8 = length of "playback" */ pDevice->jack.ppPortsPlayback[iPort] = ((ma_jack_port_register_proc)pDevice->pContext->jack.jack_port_register)((ma_jack_client_t*)pDevice->jack.pClient, name, MA_JACK_DEFAULT_AUDIO_TYPE, ma_JackPortIsOutput, 0); if (pDevice->jack.ppPortsPlayback[iPort] == NULL) { ((ma_jack_free_proc)pDevice->pContext->jack.jack_free)((void*)ppPorts); ma_device_uninit__jack(pDevice); ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[JACK] Failed to register ports."); return MA_FAILED_TO_OPEN_BACKEND_DEVICE; } } ((ma_jack_free_proc)pDevice->pContext->jack.jack_free)((void*)ppPorts); pDescriptorPlayback->periodSizeInFrames = periodSizeInFrames; pDescriptorPlayback->periodCount = 1; /* There's no notion of a period in JACK. Just set to 1. */ pDevice->jack.pIntermediaryBufferPlayback = (float*)ma_calloc(pDescriptorPlayback->periodSizeInFrames * ma_get_bytes_per_frame(pDescriptorPlayback->format, pDescriptorPlayback->channels), &pDevice->pContext->allocationCallbacks); if (pDevice->jack.pIntermediaryBufferPlayback == NULL) { ma_device_uninit__jack(pDevice); return MA_OUT_OF_MEMORY; } } return MA_SUCCESS; } static ma_result ma_device_start__jack(ma_device* pDevice) { ma_context* pContext = pDevice->pContext; int resultJACK; size_t i; resultJACK = ((ma_jack_activate_proc)pContext->jack.jack_activate)((ma_jack_client_t*)pDevice->jack.pClient); if (resultJACK != 0) { ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[JACK] Failed to activate the JACK client."); return MA_FAILED_TO_START_BACKEND_DEVICE; } if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) { const char** ppServerPorts = ((ma_jack_get_ports_proc)pContext->jack.jack_get_ports)((ma_jack_client_t*)pDevice->jack.pClient, NULL, MA_JACK_DEFAULT_AUDIO_TYPE, ma_JackPortIsPhysical | ma_JackPortIsOutput); if (ppServerPorts == NULL) { ((ma_jack_deactivate_proc)pContext->jack.jack_deactivate)((ma_jack_client_t*)pDevice->jack.pClient); ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[JACK] Failed to retrieve physical ports."); return MA_ERROR; } for (i = 0; ppServerPorts[i] != NULL; ++i) { const char* pServerPort = ppServerPorts[i]; const char* pClientPort = ((ma_jack_port_name_proc)pContext->jack.jack_port_name)((ma_jack_port_t*)pDevice->jack.ppPortsCapture[i]); resultJACK = ((ma_jack_connect_proc)pContext->jack.jack_connect)((ma_jack_client_t*)pDevice->jack.pClient, pServerPort, pClientPort); if (resultJACK != 0) { ((ma_jack_free_proc)pContext->jack.jack_free)((void*)ppServerPorts); ((ma_jack_deactivate_proc)pContext->jack.jack_deactivate)((ma_jack_client_t*)pDevice->jack.pClient); ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[JACK] Failed to connect ports."); return MA_ERROR; } } ((ma_jack_free_proc)pContext->jack.jack_free)((void*)ppServerPorts); } if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) { const char** ppServerPorts = ((ma_jack_get_ports_proc)pContext->jack.jack_get_ports)((ma_jack_client_t*)pDevice->jack.pClient, NULL, MA_JACK_DEFAULT_AUDIO_TYPE, ma_JackPortIsPhysical | ma_JackPortIsInput); if (ppServerPorts == NULL) { ((ma_jack_deactivate_proc)pContext->jack.jack_deactivate)((ma_jack_client_t*)pDevice->jack.pClient); ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[JACK] Failed to retrieve physical ports."); return MA_ERROR; } for (i = 0; ppServerPorts[i] != NULL; ++i) { const char* pServerPort = ppServerPorts[i]; const char* pClientPort = ((ma_jack_port_name_proc)pContext->jack.jack_port_name)((ma_jack_port_t*)pDevice->jack.ppPortsPlayback[i]); resultJACK = ((ma_jack_connect_proc)pContext->jack.jack_connect)((ma_jack_client_t*)pDevice->jack.pClient, pClientPort, pServerPort); if (resultJACK != 0) { ((ma_jack_free_proc)pContext->jack.jack_free)((void*)ppServerPorts); ((ma_jack_deactivate_proc)pContext->jack.jack_deactivate)((ma_jack_client_t*)pDevice->jack.pClient); ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[JACK] Failed to connect ports."); return MA_ERROR; } } ((ma_jack_free_proc)pContext->jack.jack_free)((void*)ppServerPorts); } return MA_SUCCESS; } static ma_result ma_device_stop__jack(ma_device* pDevice) { ma_context* pContext = pDevice->pContext; if (((ma_jack_deactivate_proc)pContext->jack.jack_deactivate)((ma_jack_client_t*)pDevice->jack.pClient) != 0) { ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[JACK] An error occurred when deactivating the JACK client."); return MA_ERROR; } ma_device__on_notification_stopped(pDevice); return MA_SUCCESS; } static ma_result ma_context_uninit__jack(ma_context* pContext) { MA_ASSERT(pContext != NULL); MA_ASSERT(pContext->backend == ma_backend_jack); ma_free(pContext->jack.pClientName, &pContext->allocationCallbacks); pContext->jack.pClientName = NULL; #ifndef MA_NO_RUNTIME_LINKING ma_dlclose(ma_context_get_log(pContext), pContext->jack.jackSO); #endif return MA_SUCCESS; } static ma_result ma_context_init__jack(ma_context* pContext, const ma_context_config* pConfig, ma_backend_callbacks* pCallbacks) { #ifndef MA_NO_RUNTIME_LINKING const char* libjackNames[] = { #if defined(MA_WIN32) "libjack.dll", "libjack64.dll" #endif #if defined(MA_UNIX) "libjack.so", "libjack.so.0" #endif }; size_t i; for (i = 0; i < ma_countof(libjackNames); ++i) { pContext->jack.jackSO = ma_dlopen(ma_context_get_log(pContext), libjackNames[i]); if (pContext->jack.jackSO != NULL) { break; } } if (pContext->jack.jackSO == NULL) { return MA_NO_BACKEND; } pContext->jack.jack_client_open = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->jack.jackSO, "jack_client_open"); pContext->jack.jack_client_close = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->jack.jackSO, "jack_client_close"); pContext->jack.jack_client_name_size = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->jack.jackSO, "jack_client_name_size"); pContext->jack.jack_set_process_callback = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->jack.jackSO, "jack_set_process_callback"); pContext->jack.jack_set_buffer_size_callback = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->jack.jackSO, "jack_set_buffer_size_callback"); pContext->jack.jack_on_shutdown = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->jack.jackSO, "jack_on_shutdown"); pContext->jack.jack_get_sample_rate = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->jack.jackSO, "jack_get_sample_rate"); pContext->jack.jack_get_buffer_size = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->jack.jackSO, "jack_get_buffer_size"); pContext->jack.jack_get_ports = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->jack.jackSO, "jack_get_ports"); pContext->jack.jack_activate = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->jack.jackSO, "jack_activate"); pContext->jack.jack_deactivate = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->jack.jackSO, "jack_deactivate"); pContext->jack.jack_connect = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->jack.jackSO, "jack_connect"); pContext->jack.jack_port_register = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->jack.jackSO, "jack_port_register"); pContext->jack.jack_port_name = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->jack.jackSO, "jack_port_name"); pContext->jack.jack_port_get_buffer = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->jack.jackSO, "jack_port_get_buffer"); pContext->jack.jack_free = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->jack.jackSO, "jack_free"); #else /* This strange assignment system is here just to ensure type safety of miniaudio's function pointer types. If anything differs slightly the compiler should throw a warning. */ ma_jack_client_open_proc _jack_client_open = jack_client_open; ma_jack_client_close_proc _jack_client_close = jack_client_close; ma_jack_client_name_size_proc _jack_client_name_size = jack_client_name_size; ma_jack_set_process_callback_proc _jack_set_process_callback = jack_set_process_callback; ma_jack_set_buffer_size_callback_proc _jack_set_buffer_size_callback = jack_set_buffer_size_callback; ma_jack_on_shutdown_proc _jack_on_shutdown = jack_on_shutdown; ma_jack_get_sample_rate_proc _jack_get_sample_rate = jack_get_sample_rate; ma_jack_get_buffer_size_proc _jack_get_buffer_size = jack_get_buffer_size; ma_jack_get_ports_proc _jack_get_ports = jack_get_ports; ma_jack_activate_proc _jack_activate = jack_activate; ma_jack_deactivate_proc _jack_deactivate = jack_deactivate; ma_jack_connect_proc _jack_connect = jack_connect; ma_jack_port_register_proc _jack_port_register = jack_port_register; ma_jack_port_name_proc _jack_port_name = jack_port_name; ma_jack_port_get_buffer_proc _jack_port_get_buffer = jack_port_get_buffer; ma_jack_free_proc _jack_free = jack_free; pContext->jack.jack_client_open = (ma_proc)_jack_client_open; pContext->jack.jack_client_close = (ma_proc)_jack_client_close; pContext->jack.jack_client_name_size = (ma_proc)_jack_client_name_size; pContext->jack.jack_set_process_callback = (ma_proc)_jack_set_process_callback; pContext->jack.jack_set_buffer_size_callback = (ma_proc)_jack_set_buffer_size_callback; pContext->jack.jack_on_shutdown = (ma_proc)_jack_on_shutdown; pContext->jack.jack_get_sample_rate = (ma_proc)_jack_get_sample_rate; pContext->jack.jack_get_buffer_size = (ma_proc)_jack_get_buffer_size; pContext->jack.jack_get_ports = (ma_proc)_jack_get_ports; pContext->jack.jack_activate = (ma_proc)_jack_activate; pContext->jack.jack_deactivate = (ma_proc)_jack_deactivate; pContext->jack.jack_connect = (ma_proc)_jack_connect; pContext->jack.jack_port_register = (ma_proc)_jack_port_register; pContext->jack.jack_port_name = (ma_proc)_jack_port_name; pContext->jack.jack_port_get_buffer = (ma_proc)_jack_port_get_buffer; pContext->jack.jack_free = (ma_proc)_jack_free; #endif if (pConfig->jack.pClientName != NULL) { pContext->jack.pClientName = ma_copy_string(pConfig->jack.pClientName, &pContext->allocationCallbacks); } pContext->jack.tryStartServer = pConfig->jack.tryStartServer; /* Getting here means the JACK library is installed, but it doesn't necessarily mean it's usable. We need to quickly test this by connecting a temporary client. */ { ma_jack_client_t* pDummyClient; ma_result result = ma_context_open_client__jack(pContext, &pDummyClient); if (result != MA_SUCCESS) { ma_free(pContext->jack.pClientName, &pContext->allocationCallbacks); #ifndef MA_NO_RUNTIME_LINKING ma_dlclose(ma_context_get_log(pContext), pContext->jack.jackSO); #endif return MA_NO_BACKEND; } ((ma_jack_client_close_proc)pContext->jack.jack_client_close)((ma_jack_client_t*)pDummyClient); } pCallbacks->onContextInit = ma_context_init__jack; pCallbacks->onContextUninit = ma_context_uninit__jack; pCallbacks->onContextEnumerateDevices = ma_context_enumerate_devices__jack; pCallbacks->onContextGetDeviceInfo = ma_context_get_device_info__jack; pCallbacks->onDeviceInit = ma_device_init__jack; pCallbacks->onDeviceUninit = ma_device_uninit__jack; pCallbacks->onDeviceStart = ma_device_start__jack; pCallbacks->onDeviceStop = ma_device_stop__jack; pCallbacks->onDeviceRead = NULL; /* Not used because JACK is asynchronous. */ pCallbacks->onDeviceWrite = NULL; /* Not used because JACK is asynchronous. */ pCallbacks->onDeviceDataLoop = NULL; /* Not used because JACK is asynchronous. */ return MA_SUCCESS; } #endif /* JACK */ /****************************************************************************** Core Audio Backend References ========== - Technical Note TN2091: Device input using the HAL Output Audio Unit https://developer.apple.com/library/archive/technotes/tn2091/_index.html ******************************************************************************/ #ifdef MA_HAS_COREAUDIO #include #if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE == 1 #define MA_APPLE_MOBILE #if defined(TARGET_OS_TV) && TARGET_OS_TV == 1 #define MA_APPLE_TV #endif #if defined(TARGET_OS_WATCH) && TARGET_OS_WATCH == 1 #define MA_APPLE_WATCH #endif #if __has_feature(objc_arc) #define MA_BRIDGE_TRANSFER __bridge_transfer #define MA_BRIDGE_RETAINED __bridge_retained #else #define MA_BRIDGE_TRANSFER #define MA_BRIDGE_RETAINED #endif #else #define MA_APPLE_DESKTOP #endif #if defined(MA_APPLE_DESKTOP) #include #else #include #endif #include /* CoreFoundation */ typedef Boolean (* ma_CFStringGetCString_proc)(CFStringRef theString, char* buffer, CFIndex bufferSize, CFStringEncoding encoding); typedef void (* ma_CFRelease_proc)(CFTypeRef cf); /* CoreAudio */ #if defined(MA_APPLE_DESKTOP) typedef OSStatus (* ma_AudioObjectGetPropertyData_proc)(AudioObjectID inObjectID, const AudioObjectPropertyAddress* inAddress, UInt32 inQualifierDataSize, const void* inQualifierData, UInt32* ioDataSize, void* outData); typedef OSStatus (* ma_AudioObjectGetPropertyDataSize_proc)(AudioObjectID inObjectID, const AudioObjectPropertyAddress* inAddress, UInt32 inQualifierDataSize, const void* inQualifierData, UInt32* outDataSize); typedef OSStatus (* ma_AudioObjectSetPropertyData_proc)(AudioObjectID inObjectID, const AudioObjectPropertyAddress* inAddress, UInt32 inQualifierDataSize, const void* inQualifierData, UInt32 inDataSize, const void* inData); typedef OSStatus (* ma_AudioObjectAddPropertyListener_proc)(AudioObjectID inObjectID, const AudioObjectPropertyAddress* inAddress, AudioObjectPropertyListenerProc inListener, void* inClientData); typedef OSStatus (* ma_AudioObjectRemovePropertyListener_proc)(AudioObjectID inObjectID, const AudioObjectPropertyAddress* inAddress, AudioObjectPropertyListenerProc inListener, void* inClientData); #endif /* AudioToolbox */ typedef AudioComponent (* ma_AudioComponentFindNext_proc)(AudioComponent inComponent, const AudioComponentDescription* inDesc); typedef OSStatus (* ma_AudioComponentInstanceDispose_proc)(AudioComponentInstance inInstance); typedef OSStatus (* ma_AudioComponentInstanceNew_proc)(AudioComponent inComponent, AudioComponentInstance* outInstance); typedef OSStatus (* ma_AudioOutputUnitStart_proc)(AudioUnit inUnit); typedef OSStatus (* ma_AudioOutputUnitStop_proc)(AudioUnit inUnit); typedef OSStatus (* ma_AudioUnitAddPropertyListener_proc)(AudioUnit inUnit, AudioUnitPropertyID inID, AudioUnitPropertyListenerProc inProc, void* inProcUserData); typedef OSStatus (* ma_AudioUnitGetPropertyInfo_proc)(AudioUnit inUnit, AudioUnitPropertyID inID, AudioUnitScope inScope, AudioUnitElement inElement, UInt32* outDataSize, Boolean* outWriteable); typedef OSStatus (* ma_AudioUnitGetProperty_proc)(AudioUnit inUnit, AudioUnitPropertyID inID, AudioUnitScope inScope, AudioUnitElement inElement, void* outData, UInt32* ioDataSize); typedef OSStatus (* ma_AudioUnitSetProperty_proc)(AudioUnit inUnit, AudioUnitPropertyID inID, AudioUnitScope inScope, AudioUnitElement inElement, const void* inData, UInt32 inDataSize); typedef OSStatus (* ma_AudioUnitInitialize_proc)(AudioUnit inUnit); typedef OSStatus (* ma_AudioUnitRender_proc)(AudioUnit inUnit, AudioUnitRenderActionFlags* ioActionFlags, const AudioTimeStamp* inTimeStamp, UInt32 inOutputBusNumber, UInt32 inNumberFrames, AudioBufferList* ioData); #define MA_COREAUDIO_OUTPUT_BUS 0 #define MA_COREAUDIO_INPUT_BUS 1 #if defined(MA_APPLE_DESKTOP) static ma_result ma_device_reinit_internal__coreaudio(ma_device* pDevice, ma_device_type deviceType, ma_bool32 disposePreviousAudioUnit); #endif /* Core Audio So far, Core Audio has been the worst backend to work with due to being both unintuitive and having almost no documentation apart from comments in the headers (which admittedly are quite good). For my own purposes, and for anybody out there whose needing to figure out how this darn thing works, I'm going to outline a few things here. Since miniaudio is a fairly low-level API, one of the things it needs is control over specific devices, and it needs to be able to identify whether or not it can be used as playback and/or capture. The AudioObject API is the only one I've seen that supports this level of detail. There was some public domain sample code I stumbled across that used the AudioComponent and AudioUnit APIs, but I couldn't see anything that gave low-level control over device selection and capabilities (the distinction between playback and capture in particular). Therefore, miniaudio is using the AudioObject API. Most (all?) functions in the AudioObject API take a AudioObjectID as it's input. This is the device identifier. When retrieving global information, such as the device list, you use kAudioObjectSystemObject. When retrieving device-specific data, you pass in the ID for that device. In order to retrieve device-specific IDs you need to enumerate over each of the devices. This is done using the AudioObjectGetPropertyDataSize() and AudioObjectGetPropertyData() APIs which seem to be the central APIs for retrieving information about the system and specific devices. To use the AudioObjectGetPropertyData() API you need to use the notion of a property address. A property address is a structure with three variables and is used to identify which property you are getting or setting. The first is the "selector" which is basically the specific property that you're wanting to retrieve or set. The second is the "scope", which is typically set to kAudioObjectPropertyScopeGlobal, kAudioObjectPropertyScopeInput for input-specific properties and kAudioObjectPropertyScopeOutput for output-specific properties. The last is the "element" which is always set to kAudioObjectPropertyElementMain in miniaudio's case. I don't know of any cases where this would be set to anything different. Back to the earlier issue of device retrieval, you first use the AudioObjectGetPropertyDataSize() API to retrieve the size of the raw data which is just a list of AudioDeviceID's. You use the kAudioObjectSystemObject AudioObjectID, and a property address with the kAudioHardwarePropertyDevices selector and the kAudioObjectPropertyScopeGlobal scope. Once you have the size, allocate a block of memory of that size and then call AudioObjectGetPropertyData(). The data is just a list of AudioDeviceID's so just do "dataSize/sizeof(AudioDeviceID)" to know the device count. */ #if defined(MA_APPLE_MOBILE) static void ma_device__on_notification_interruption_began(ma_device* pDevice) { ma_device__on_notification(ma_device_notification_init(pDevice, ma_device_notification_type_interruption_began)); } static void ma_device__on_notification_interruption_ended(ma_device* pDevice) { ma_device__on_notification(ma_device_notification_init(pDevice, ma_device_notification_type_interruption_ended)); } #endif static ma_result ma_result_from_OSStatus(OSStatus status) { switch (status) { case noErr: return MA_SUCCESS; #if defined(MA_APPLE_DESKTOP) case kAudioHardwareNotRunningError: return MA_DEVICE_NOT_STARTED; case kAudioHardwareUnspecifiedError: return MA_ERROR; case kAudioHardwareUnknownPropertyError: return MA_INVALID_ARGS; case kAudioHardwareBadPropertySizeError: return MA_INVALID_OPERATION; case kAudioHardwareIllegalOperationError: return MA_INVALID_OPERATION; case kAudioHardwareBadObjectError: return MA_INVALID_ARGS; case kAudioHardwareBadDeviceError: return MA_INVALID_ARGS; case kAudioHardwareBadStreamError: return MA_INVALID_ARGS; case kAudioHardwareUnsupportedOperationError: return MA_INVALID_OPERATION; case kAudioDeviceUnsupportedFormatError: return MA_FORMAT_NOT_SUPPORTED; case kAudioDevicePermissionsError: return MA_ACCESS_DENIED; #endif default: return MA_ERROR; } } #if 0 static ma_channel ma_channel_from_AudioChannelBitmap(AudioChannelBitmap bit) { switch (bit) { case kAudioChannelBit_Left: return MA_CHANNEL_LEFT; case kAudioChannelBit_Right: return MA_CHANNEL_RIGHT; case kAudioChannelBit_Center: return MA_CHANNEL_FRONT_CENTER; case kAudioChannelBit_LFEScreen: return MA_CHANNEL_LFE; case kAudioChannelBit_LeftSurround: return MA_CHANNEL_BACK_LEFT; case kAudioChannelBit_RightSurround: return MA_CHANNEL_BACK_RIGHT; case kAudioChannelBit_LeftCenter: return MA_CHANNEL_FRONT_LEFT_CENTER; case kAudioChannelBit_RightCenter: return MA_CHANNEL_FRONT_RIGHT_CENTER; case kAudioChannelBit_CenterSurround: return MA_CHANNEL_BACK_CENTER; case kAudioChannelBit_LeftSurroundDirect: return MA_CHANNEL_SIDE_LEFT; case kAudioChannelBit_RightSurroundDirect: return MA_CHANNEL_SIDE_RIGHT; case kAudioChannelBit_TopCenterSurround: return MA_CHANNEL_TOP_CENTER; case kAudioChannelBit_VerticalHeightLeft: return MA_CHANNEL_TOP_FRONT_LEFT; case kAudioChannelBit_VerticalHeightCenter: return MA_CHANNEL_TOP_FRONT_CENTER; case kAudioChannelBit_VerticalHeightRight: return MA_CHANNEL_TOP_FRONT_RIGHT; case kAudioChannelBit_TopBackLeft: return MA_CHANNEL_TOP_BACK_LEFT; case kAudioChannelBit_TopBackCenter: return MA_CHANNEL_TOP_BACK_CENTER; case kAudioChannelBit_TopBackRight: return MA_CHANNEL_TOP_BACK_RIGHT; default: return MA_CHANNEL_NONE; } } #endif static ma_result ma_format_from_AudioStreamBasicDescription(const AudioStreamBasicDescription* pDescription, ma_format* pFormatOut) { MA_ASSERT(pDescription != NULL); MA_ASSERT(pFormatOut != NULL); *pFormatOut = ma_format_unknown; /* Safety. */ /* There's a few things miniaudio doesn't support. */ if (pDescription->mFormatID != kAudioFormatLinearPCM) { return MA_FORMAT_NOT_SUPPORTED; } /* We don't support any non-packed formats that are aligned high. */ if ((pDescription->mFormatFlags & kLinearPCMFormatFlagIsAlignedHigh) != 0) { return MA_FORMAT_NOT_SUPPORTED; } /* Only supporting native-endian. */ if ((ma_is_little_endian() && (pDescription->mFormatFlags & kAudioFormatFlagIsBigEndian) != 0) || (ma_is_big_endian() && (pDescription->mFormatFlags & kAudioFormatFlagIsBigEndian) == 0)) { return MA_FORMAT_NOT_SUPPORTED; } /* We are not currently supporting non-interleaved formats (this will be added in a future version of miniaudio). */ /*if ((pDescription->mFormatFlags & kAudioFormatFlagIsNonInterleaved) != 0) { return MA_FORMAT_NOT_SUPPORTED; }*/ if ((pDescription->mFormatFlags & kLinearPCMFormatFlagIsFloat) != 0) { if (pDescription->mBitsPerChannel == 32) { *pFormatOut = ma_format_f32; return MA_SUCCESS; } } else { if ((pDescription->mFormatFlags & kLinearPCMFormatFlagIsSignedInteger) != 0) { if (pDescription->mBitsPerChannel == 16) { *pFormatOut = ma_format_s16; return MA_SUCCESS; } else if (pDescription->mBitsPerChannel == 24) { if (pDescription->mBytesPerFrame == (pDescription->mBitsPerChannel/8 * pDescription->mChannelsPerFrame)) { *pFormatOut = ma_format_s24; return MA_SUCCESS; } else { if (pDescription->mBytesPerFrame/pDescription->mChannelsPerFrame == sizeof(ma_int32)) { /* TODO: Implement ma_format_s24_32. */ /**pFormatOut = ma_format_s24_32;*/ /*return MA_SUCCESS;*/ return MA_FORMAT_NOT_SUPPORTED; } } } else if (pDescription->mBitsPerChannel == 32) { *pFormatOut = ma_format_s32; return MA_SUCCESS; } } else { if (pDescription->mBitsPerChannel == 8) { *pFormatOut = ma_format_u8; return MA_SUCCESS; } } } /* Getting here means the format is not supported. */ return MA_FORMAT_NOT_SUPPORTED; } #if defined(MA_APPLE_DESKTOP) static ma_channel ma_channel_from_AudioChannelLabel(AudioChannelLabel label) { switch (label) { case kAudioChannelLabel_Unknown: return MA_CHANNEL_NONE; case kAudioChannelLabel_Unused: return MA_CHANNEL_NONE; case kAudioChannelLabel_UseCoordinates: return MA_CHANNEL_NONE; case kAudioChannelLabel_Left: return MA_CHANNEL_LEFT; case kAudioChannelLabel_Right: return MA_CHANNEL_RIGHT; case kAudioChannelLabel_Center: return MA_CHANNEL_FRONT_CENTER; case kAudioChannelLabel_LFEScreen: return MA_CHANNEL_LFE; case kAudioChannelLabel_LeftSurround: return MA_CHANNEL_BACK_LEFT; case kAudioChannelLabel_RightSurround: return MA_CHANNEL_BACK_RIGHT; case kAudioChannelLabel_LeftCenter: return MA_CHANNEL_FRONT_LEFT_CENTER; case kAudioChannelLabel_RightCenter: return MA_CHANNEL_FRONT_RIGHT_CENTER; case kAudioChannelLabel_CenterSurround: return MA_CHANNEL_BACK_CENTER; case kAudioChannelLabel_LeftSurroundDirect: return MA_CHANNEL_SIDE_LEFT; case kAudioChannelLabel_RightSurroundDirect: return MA_CHANNEL_SIDE_RIGHT; case kAudioChannelLabel_TopCenterSurround: return MA_CHANNEL_TOP_CENTER; case kAudioChannelLabel_VerticalHeightLeft: return MA_CHANNEL_TOP_FRONT_LEFT; case kAudioChannelLabel_VerticalHeightCenter: return MA_CHANNEL_TOP_FRONT_CENTER; case kAudioChannelLabel_VerticalHeightRight: return MA_CHANNEL_TOP_FRONT_RIGHT; case kAudioChannelLabel_TopBackLeft: return MA_CHANNEL_TOP_BACK_LEFT; case kAudioChannelLabel_TopBackCenter: return MA_CHANNEL_TOP_BACK_CENTER; case kAudioChannelLabel_TopBackRight: return MA_CHANNEL_TOP_BACK_RIGHT; case kAudioChannelLabel_RearSurroundLeft: return MA_CHANNEL_BACK_LEFT; case kAudioChannelLabel_RearSurroundRight: return MA_CHANNEL_BACK_RIGHT; case kAudioChannelLabel_LeftWide: return MA_CHANNEL_SIDE_LEFT; case kAudioChannelLabel_RightWide: return MA_CHANNEL_SIDE_RIGHT; case kAudioChannelLabel_LFE2: return MA_CHANNEL_LFE; case kAudioChannelLabel_LeftTotal: return MA_CHANNEL_LEFT; case kAudioChannelLabel_RightTotal: return MA_CHANNEL_RIGHT; case kAudioChannelLabel_HearingImpaired: return MA_CHANNEL_NONE; case kAudioChannelLabel_Narration: return MA_CHANNEL_MONO; case kAudioChannelLabel_Mono: return MA_CHANNEL_MONO; case kAudioChannelLabel_DialogCentricMix: return MA_CHANNEL_MONO; case kAudioChannelLabel_CenterSurroundDirect: return MA_CHANNEL_BACK_CENTER; case kAudioChannelLabel_Haptic: return MA_CHANNEL_NONE; case kAudioChannelLabel_Ambisonic_W: return MA_CHANNEL_NONE; case kAudioChannelLabel_Ambisonic_X: return MA_CHANNEL_NONE; case kAudioChannelLabel_Ambisonic_Y: return MA_CHANNEL_NONE; case kAudioChannelLabel_Ambisonic_Z: return MA_CHANNEL_NONE; case kAudioChannelLabel_MS_Mid: return MA_CHANNEL_LEFT; case kAudioChannelLabel_MS_Side: return MA_CHANNEL_RIGHT; case kAudioChannelLabel_XY_X: return MA_CHANNEL_LEFT; case kAudioChannelLabel_XY_Y: return MA_CHANNEL_RIGHT; case kAudioChannelLabel_HeadphonesLeft: return MA_CHANNEL_LEFT; case kAudioChannelLabel_HeadphonesRight: return MA_CHANNEL_RIGHT; case kAudioChannelLabel_ClickTrack: return MA_CHANNEL_NONE; case kAudioChannelLabel_ForeignLanguage: return MA_CHANNEL_NONE; case kAudioChannelLabel_Discrete: return MA_CHANNEL_NONE; case kAudioChannelLabel_Discrete_0: return MA_CHANNEL_AUX_0; case kAudioChannelLabel_Discrete_1: return MA_CHANNEL_AUX_1; case kAudioChannelLabel_Discrete_2: return MA_CHANNEL_AUX_2; case kAudioChannelLabel_Discrete_3: return MA_CHANNEL_AUX_3; case kAudioChannelLabel_Discrete_4: return MA_CHANNEL_AUX_4; case kAudioChannelLabel_Discrete_5: return MA_CHANNEL_AUX_5; case kAudioChannelLabel_Discrete_6: return MA_CHANNEL_AUX_6; case kAudioChannelLabel_Discrete_7: return MA_CHANNEL_AUX_7; case kAudioChannelLabel_Discrete_8: return MA_CHANNEL_AUX_8; case kAudioChannelLabel_Discrete_9: return MA_CHANNEL_AUX_9; case kAudioChannelLabel_Discrete_10: return MA_CHANNEL_AUX_10; case kAudioChannelLabel_Discrete_11: return MA_CHANNEL_AUX_11; case kAudioChannelLabel_Discrete_12: return MA_CHANNEL_AUX_12; case kAudioChannelLabel_Discrete_13: return MA_CHANNEL_AUX_13; case kAudioChannelLabel_Discrete_14: return MA_CHANNEL_AUX_14; case kAudioChannelLabel_Discrete_15: return MA_CHANNEL_AUX_15; case kAudioChannelLabel_Discrete_65535: return MA_CHANNEL_NONE; #if 0 /* Introduced in a later version of macOS. */ case kAudioChannelLabel_HOA_ACN: return MA_CHANNEL_NONE; case kAudioChannelLabel_HOA_ACN_0: return MA_CHANNEL_AUX_0; case kAudioChannelLabel_HOA_ACN_1: return MA_CHANNEL_AUX_1; case kAudioChannelLabel_HOA_ACN_2: return MA_CHANNEL_AUX_2; case kAudioChannelLabel_HOA_ACN_3: return MA_CHANNEL_AUX_3; case kAudioChannelLabel_HOA_ACN_4: return MA_CHANNEL_AUX_4; case kAudioChannelLabel_HOA_ACN_5: return MA_CHANNEL_AUX_5; case kAudioChannelLabel_HOA_ACN_6: return MA_CHANNEL_AUX_6; case kAudioChannelLabel_HOA_ACN_7: return MA_CHANNEL_AUX_7; case kAudioChannelLabel_HOA_ACN_8: return MA_CHANNEL_AUX_8; case kAudioChannelLabel_HOA_ACN_9: return MA_CHANNEL_AUX_9; case kAudioChannelLabel_HOA_ACN_10: return MA_CHANNEL_AUX_10; case kAudioChannelLabel_HOA_ACN_11: return MA_CHANNEL_AUX_11; case kAudioChannelLabel_HOA_ACN_12: return MA_CHANNEL_AUX_12; case kAudioChannelLabel_HOA_ACN_13: return MA_CHANNEL_AUX_13; case kAudioChannelLabel_HOA_ACN_14: return MA_CHANNEL_AUX_14; case kAudioChannelLabel_HOA_ACN_15: return MA_CHANNEL_AUX_15; case kAudioChannelLabel_HOA_ACN_65024: return MA_CHANNEL_NONE; #endif default: return MA_CHANNEL_NONE; } } static ma_result ma_get_channel_map_from_AudioChannelLayout(AudioChannelLayout* pChannelLayout, ma_channel* pChannelMap, size_t channelMapCap) { MA_ASSERT(pChannelLayout != NULL); if (pChannelLayout->mChannelLayoutTag == kAudioChannelLayoutTag_UseChannelDescriptions) { UInt32 iChannel; for (iChannel = 0; iChannel < pChannelLayout->mNumberChannelDescriptions && iChannel < channelMapCap; ++iChannel) { pChannelMap[iChannel] = ma_channel_from_AudioChannelLabel(pChannelLayout->mChannelDescriptions[iChannel].mChannelLabel); } } else #if 0 if (pChannelLayout->mChannelLayoutTag == kAudioChannelLayoutTag_UseChannelBitmap) { /* This is the same kind of system that's used by Windows audio APIs. */ UInt32 iChannel = 0; UInt32 iBit; AudioChannelBitmap bitmap = pChannelLayout->mChannelBitmap; for (iBit = 0; iBit < 32 && iChannel < channelMapCap; ++iBit) { AudioChannelBitmap bit = bitmap & (1 << iBit); if (bit != 0) { pChannelMap[iChannel++] = ma_channel_from_AudioChannelBit(bit); } } } else #endif { /* Need to use the tag to determine the channel map. For now I'm just assuming a default channel map, but later on this should be updated to determine the mapping based on the tag. */ UInt32 channelCount; /* Our channel map retrieval APIs below take 32-bit integers, so we'll want to clamp the channel map capacity. */ if (channelMapCap > 0xFFFFFFFF) { channelMapCap = 0xFFFFFFFF; } channelCount = ma_min(AudioChannelLayoutTag_GetNumberOfChannels(pChannelLayout->mChannelLayoutTag), (UInt32)channelMapCap); switch (pChannelLayout->mChannelLayoutTag) { case kAudioChannelLayoutTag_Mono: case kAudioChannelLayoutTag_Stereo: case kAudioChannelLayoutTag_StereoHeadphones: case kAudioChannelLayoutTag_MatrixStereo: case kAudioChannelLayoutTag_MidSide: case kAudioChannelLayoutTag_XY: case kAudioChannelLayoutTag_Binaural: case kAudioChannelLayoutTag_Ambisonic_B_Format: { ma_channel_map_init_standard(ma_standard_channel_map_default, pChannelMap, channelMapCap, channelCount); } break; case kAudioChannelLayoutTag_Octagonal: { pChannelMap[7] = MA_CHANNEL_SIDE_RIGHT; pChannelMap[6] = MA_CHANNEL_SIDE_LEFT; } MA_FALLTHROUGH; /* Intentional fallthrough. */ case kAudioChannelLayoutTag_Hexagonal: { pChannelMap[5] = MA_CHANNEL_BACK_CENTER; } MA_FALLTHROUGH; /* Intentional fallthrough. */ case kAudioChannelLayoutTag_Pentagonal: { pChannelMap[4] = MA_CHANNEL_FRONT_CENTER; } MA_FALLTHROUGH; /* Intentional fallthrough. */ case kAudioChannelLayoutTag_Quadraphonic: { pChannelMap[3] = MA_CHANNEL_BACK_RIGHT; pChannelMap[2] = MA_CHANNEL_BACK_LEFT; pChannelMap[1] = MA_CHANNEL_RIGHT; pChannelMap[0] = MA_CHANNEL_LEFT; } break; /* TODO: Add support for more tags here. */ default: { ma_channel_map_init_standard(ma_standard_channel_map_default, pChannelMap, channelMapCap, channelCount); } break; } } return MA_SUCCESS; } #if (defined(MAC_OS_VERSION_12_0) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_VERSION_12_0) || \ (defined(__IPHONE_15_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_15_0) #define AUDIO_OBJECT_PROPERTY_ELEMENT kAudioObjectPropertyElementMain #else /* kAudioObjectPropertyElementMaster is deprecated. */ #define AUDIO_OBJECT_PROPERTY_ELEMENT kAudioObjectPropertyElementMaster #endif static ma_result ma_get_device_object_ids__coreaudio(ma_context* pContext, UInt32* pDeviceCount, AudioObjectID** ppDeviceObjectIDs) /* NOTE: Free the returned buffer with ma_free(). */ { AudioObjectPropertyAddress propAddressDevices; UInt32 deviceObjectsDataSize; OSStatus status; AudioObjectID* pDeviceObjectIDs; MA_ASSERT(pContext != NULL); MA_ASSERT(pDeviceCount != NULL); MA_ASSERT(ppDeviceObjectIDs != NULL); /* Safety. */ *pDeviceCount = 0; *ppDeviceObjectIDs = NULL; propAddressDevices.mSelector = kAudioHardwarePropertyDevices; propAddressDevices.mScope = kAudioObjectPropertyScopeGlobal; propAddressDevices.mElement = AUDIO_OBJECT_PROPERTY_ELEMENT; status = ((ma_AudioObjectGetPropertyDataSize_proc)pContext->coreaudio.AudioObjectGetPropertyDataSize)(kAudioObjectSystemObject, &propAddressDevices, 0, NULL, &deviceObjectsDataSize); if (status != noErr) { return ma_result_from_OSStatus(status); } pDeviceObjectIDs = (AudioObjectID*)ma_malloc(deviceObjectsDataSize, &pContext->allocationCallbacks); if (pDeviceObjectIDs == NULL) { return MA_OUT_OF_MEMORY; } status = ((ma_AudioObjectGetPropertyData_proc)pContext->coreaudio.AudioObjectGetPropertyData)(kAudioObjectSystemObject, &propAddressDevices, 0, NULL, &deviceObjectsDataSize, pDeviceObjectIDs); if (status != noErr) { ma_free(pDeviceObjectIDs, &pContext->allocationCallbacks); return ma_result_from_OSStatus(status); } *pDeviceCount = deviceObjectsDataSize / sizeof(AudioObjectID); *ppDeviceObjectIDs = pDeviceObjectIDs; return MA_SUCCESS; } static ma_result ma_get_AudioObject_uid_as_CFStringRef(ma_context* pContext, AudioObjectID objectID, CFStringRef* pUID) { AudioObjectPropertyAddress propAddress; UInt32 dataSize; OSStatus status; MA_ASSERT(pContext != NULL); propAddress.mSelector = kAudioDevicePropertyDeviceUID; propAddress.mScope = kAudioObjectPropertyScopeGlobal; propAddress.mElement = AUDIO_OBJECT_PROPERTY_ELEMENT; dataSize = sizeof(*pUID); status = ((ma_AudioObjectGetPropertyData_proc)pContext->coreaudio.AudioObjectGetPropertyData)(objectID, &propAddress, 0, NULL, &dataSize, pUID); if (status != noErr) { return ma_result_from_OSStatus(status); } return MA_SUCCESS; } static ma_result ma_get_AudioObject_uid(ma_context* pContext, AudioObjectID objectID, size_t bufferSize, char* bufferOut) { CFStringRef uid; ma_result result; MA_ASSERT(pContext != NULL); result = ma_get_AudioObject_uid_as_CFStringRef(pContext, objectID, &uid); if (result != MA_SUCCESS) { return result; } if (!((ma_CFStringGetCString_proc)pContext->coreaudio.CFStringGetCString)(uid, bufferOut, bufferSize, kCFStringEncodingUTF8)) { return MA_ERROR; } ((ma_CFRelease_proc)pContext->coreaudio.CFRelease)(uid); return MA_SUCCESS; } static ma_result ma_get_AudioObject_name(ma_context* pContext, AudioObjectID objectID, size_t bufferSize, char* bufferOut) { AudioObjectPropertyAddress propAddress; CFStringRef deviceName = NULL; UInt32 dataSize; OSStatus status; MA_ASSERT(pContext != NULL); propAddress.mSelector = kAudioDevicePropertyDeviceNameCFString; propAddress.mScope = kAudioObjectPropertyScopeGlobal; propAddress.mElement = AUDIO_OBJECT_PROPERTY_ELEMENT; dataSize = sizeof(deviceName); status = ((ma_AudioObjectGetPropertyData_proc)pContext->coreaudio.AudioObjectGetPropertyData)(objectID, &propAddress, 0, NULL, &dataSize, &deviceName); if (status != noErr) { return ma_result_from_OSStatus(status); } if (!((ma_CFStringGetCString_proc)pContext->coreaudio.CFStringGetCString)(deviceName, bufferOut, bufferSize, kCFStringEncodingUTF8)) { return MA_ERROR; } ((ma_CFRelease_proc)pContext->coreaudio.CFRelease)(deviceName); return MA_SUCCESS; } static ma_bool32 ma_does_AudioObject_support_scope(ma_context* pContext, AudioObjectID deviceObjectID, AudioObjectPropertyScope scope) { AudioObjectPropertyAddress propAddress; UInt32 dataSize; OSStatus status; AudioBufferList* pBufferList; ma_bool32 isSupported; MA_ASSERT(pContext != NULL); /* To know whether or not a device is an input device we need ot look at the stream configuration. If it has an output channel it's a playback device. */ propAddress.mSelector = kAudioDevicePropertyStreamConfiguration; propAddress.mScope = scope; propAddress.mElement = AUDIO_OBJECT_PROPERTY_ELEMENT; status = ((ma_AudioObjectGetPropertyDataSize_proc)pContext->coreaudio.AudioObjectGetPropertyDataSize)(deviceObjectID, &propAddress, 0, NULL, &dataSize); if (status != noErr) { return MA_FALSE; } pBufferList = (AudioBufferList*)ma_malloc(dataSize, &pContext->allocationCallbacks); if (pBufferList == NULL) { return MA_FALSE; /* Out of memory. */ } status = ((ma_AudioObjectGetPropertyData_proc)pContext->coreaudio.AudioObjectGetPropertyData)(deviceObjectID, &propAddress, 0, NULL, &dataSize, pBufferList); if (status != noErr) { ma_free(pBufferList, &pContext->allocationCallbacks); return MA_FALSE; } isSupported = MA_FALSE; if (pBufferList->mNumberBuffers > 0) { isSupported = MA_TRUE; } ma_free(pBufferList, &pContext->allocationCallbacks); return isSupported; } static ma_bool32 ma_does_AudioObject_support_playback(ma_context* pContext, AudioObjectID deviceObjectID) { return ma_does_AudioObject_support_scope(pContext, deviceObjectID, kAudioObjectPropertyScopeOutput); } static ma_bool32 ma_does_AudioObject_support_capture(ma_context* pContext, AudioObjectID deviceObjectID) { return ma_does_AudioObject_support_scope(pContext, deviceObjectID, kAudioObjectPropertyScopeInput); } static ma_result ma_get_AudioObject_stream_descriptions(ma_context* pContext, AudioObjectID deviceObjectID, ma_device_type deviceType, UInt32* pDescriptionCount, AudioStreamRangedDescription** ppDescriptions) /* NOTE: Free the returned pointer with ma_free(). */ { AudioObjectPropertyAddress propAddress; UInt32 dataSize; OSStatus status; AudioStreamRangedDescription* pDescriptions; MA_ASSERT(pContext != NULL); MA_ASSERT(pDescriptionCount != NULL); MA_ASSERT(ppDescriptions != NULL); /* TODO: Experiment with kAudioStreamPropertyAvailablePhysicalFormats instead of (or in addition to) kAudioStreamPropertyAvailableVirtualFormats. My MacBook Pro uses s24/32 format, however, which miniaudio does not currently support. */ propAddress.mSelector = kAudioStreamPropertyAvailableVirtualFormats; /*kAudioStreamPropertyAvailablePhysicalFormats;*/ propAddress.mScope = (deviceType == ma_device_type_playback) ? kAudioObjectPropertyScopeOutput : kAudioObjectPropertyScopeInput; propAddress.mElement = AUDIO_OBJECT_PROPERTY_ELEMENT; status = ((ma_AudioObjectGetPropertyDataSize_proc)pContext->coreaudio.AudioObjectGetPropertyDataSize)(deviceObjectID, &propAddress, 0, NULL, &dataSize); if (status != noErr) { return ma_result_from_OSStatus(status); } pDescriptions = (AudioStreamRangedDescription*)ma_malloc(dataSize, &pContext->allocationCallbacks); if (pDescriptions == NULL) { return MA_OUT_OF_MEMORY; } status = ((ma_AudioObjectGetPropertyData_proc)pContext->coreaudio.AudioObjectGetPropertyData)(deviceObjectID, &propAddress, 0, NULL, &dataSize, pDescriptions); if (status != noErr) { ma_free(pDescriptions, &pContext->allocationCallbacks); return ma_result_from_OSStatus(status); } *pDescriptionCount = dataSize / sizeof(*pDescriptions); *ppDescriptions = pDescriptions; return MA_SUCCESS; } static ma_result ma_get_AudioObject_channel_layout(ma_context* pContext, AudioObjectID deviceObjectID, ma_device_type deviceType, AudioChannelLayout** ppChannelLayout) /* NOTE: Free the returned pointer with ma_free(). */ { AudioObjectPropertyAddress propAddress; UInt32 dataSize; OSStatus status; AudioChannelLayout* pChannelLayout; MA_ASSERT(pContext != NULL); MA_ASSERT(ppChannelLayout != NULL); *ppChannelLayout = NULL; /* Safety. */ propAddress.mSelector = kAudioDevicePropertyPreferredChannelLayout; propAddress.mScope = (deviceType == ma_device_type_playback) ? kAudioObjectPropertyScopeOutput : kAudioObjectPropertyScopeInput; propAddress.mElement = AUDIO_OBJECT_PROPERTY_ELEMENT; status = ((ma_AudioObjectGetPropertyDataSize_proc)pContext->coreaudio.AudioObjectGetPropertyDataSize)(deviceObjectID, &propAddress, 0, NULL, &dataSize); if (status != noErr) { return ma_result_from_OSStatus(status); } pChannelLayout = (AudioChannelLayout*)ma_malloc(dataSize, &pContext->allocationCallbacks); if (pChannelLayout == NULL) { return MA_OUT_OF_MEMORY; } status = ((ma_AudioObjectGetPropertyData_proc)pContext->coreaudio.AudioObjectGetPropertyData)(deviceObjectID, &propAddress, 0, NULL, &dataSize, pChannelLayout); if (status != noErr) { ma_free(pChannelLayout, &pContext->allocationCallbacks); return ma_result_from_OSStatus(status); } *ppChannelLayout = pChannelLayout; return MA_SUCCESS; } static ma_result ma_get_AudioObject_channel_count(ma_context* pContext, AudioObjectID deviceObjectID, ma_device_type deviceType, ma_uint32* pChannelCount) { AudioChannelLayout* pChannelLayout; ma_result result; MA_ASSERT(pContext != NULL); MA_ASSERT(pChannelCount != NULL); *pChannelCount = 0; /* Safety. */ result = ma_get_AudioObject_channel_layout(pContext, deviceObjectID, deviceType, &pChannelLayout); if (result != MA_SUCCESS) { return result; } if (pChannelLayout->mChannelLayoutTag == kAudioChannelLayoutTag_UseChannelDescriptions) { *pChannelCount = pChannelLayout->mNumberChannelDescriptions; } else if (pChannelLayout->mChannelLayoutTag == kAudioChannelLayoutTag_UseChannelBitmap) { *pChannelCount = ma_count_set_bits(pChannelLayout->mChannelBitmap); } else { *pChannelCount = AudioChannelLayoutTag_GetNumberOfChannels(pChannelLayout->mChannelLayoutTag); } ma_free(pChannelLayout, &pContext->allocationCallbacks); return MA_SUCCESS; } #if 0 static ma_result ma_get_AudioObject_channel_map(ma_context* pContext, AudioObjectID deviceObjectID, ma_device_type deviceType, ma_channel* pChannelMap, size_t channelMapCap) { AudioChannelLayout* pChannelLayout; ma_result result; MA_ASSERT(pContext != NULL); result = ma_get_AudioObject_channel_layout(pContext, deviceObjectID, deviceType, &pChannelLayout); if (result != MA_SUCCESS) { return result; /* Rather than always failing here, would it be more robust to simply assume a default? */ } result = ma_get_channel_map_from_AudioChannelLayout(pChannelLayout, pChannelMap, channelMapCap); if (result != MA_SUCCESS) { ma_free(pChannelLayout, &pContext->allocationCallbacks); return result; } ma_free(pChannelLayout, &pContext->allocationCallbacks); return result; } #endif static ma_result ma_get_AudioObject_sample_rates(ma_context* pContext, AudioObjectID deviceObjectID, ma_device_type deviceType, UInt32* pSampleRateRangesCount, AudioValueRange** ppSampleRateRanges) /* NOTE: Free the returned pointer with ma_free(). */ { AudioObjectPropertyAddress propAddress; UInt32 dataSize; OSStatus status; AudioValueRange* pSampleRateRanges; MA_ASSERT(pContext != NULL); MA_ASSERT(pSampleRateRangesCount != NULL); MA_ASSERT(ppSampleRateRanges != NULL); /* Safety. */ *pSampleRateRangesCount = 0; *ppSampleRateRanges = NULL; propAddress.mSelector = kAudioDevicePropertyAvailableNominalSampleRates; propAddress.mScope = (deviceType == ma_device_type_playback) ? kAudioObjectPropertyScopeOutput : kAudioObjectPropertyScopeInput; propAddress.mElement = AUDIO_OBJECT_PROPERTY_ELEMENT; status = ((ma_AudioObjectGetPropertyDataSize_proc)pContext->coreaudio.AudioObjectGetPropertyDataSize)(deviceObjectID, &propAddress, 0, NULL, &dataSize); if (status != noErr) { return ma_result_from_OSStatus(status); } pSampleRateRanges = (AudioValueRange*)ma_malloc(dataSize, &pContext->allocationCallbacks); if (pSampleRateRanges == NULL) { return MA_OUT_OF_MEMORY; } status = ((ma_AudioObjectGetPropertyData_proc)pContext->coreaudio.AudioObjectGetPropertyData)(deviceObjectID, &propAddress, 0, NULL, &dataSize, pSampleRateRanges); if (status != noErr) { ma_free(pSampleRateRanges, &pContext->allocationCallbacks); return ma_result_from_OSStatus(status); } *pSampleRateRangesCount = dataSize / sizeof(*pSampleRateRanges); *ppSampleRateRanges = pSampleRateRanges; return MA_SUCCESS; } #if 0 static ma_result ma_get_AudioObject_get_closest_sample_rate(ma_context* pContext, AudioObjectID deviceObjectID, ma_device_type deviceType, ma_uint32 sampleRateIn, ma_uint32* pSampleRateOut) { UInt32 sampleRateRangeCount; AudioValueRange* pSampleRateRanges; ma_result result; MA_ASSERT(pContext != NULL); MA_ASSERT(pSampleRateOut != NULL); *pSampleRateOut = 0; /* Safety. */ result = ma_get_AudioObject_sample_rates(pContext, deviceObjectID, deviceType, &sampleRateRangeCount, &pSampleRateRanges); if (result != MA_SUCCESS) { return result; } if (sampleRateRangeCount == 0) { ma_free(pSampleRateRanges, &pContext->allocationCallbacks); return MA_ERROR; /* Should never hit this case should we? */ } if (sampleRateIn == 0) { /* Search in order of miniaudio's preferred priority. */ UInt32 iMALSampleRate; for (iMALSampleRate = 0; iMALSampleRate < ma_countof(g_maStandardSampleRatePriorities); ++iMALSampleRate) { ma_uint32 malSampleRate = g_maStandardSampleRatePriorities[iMALSampleRate]; UInt32 iCASampleRate; for (iCASampleRate = 0; iCASampleRate < sampleRateRangeCount; ++iCASampleRate) { AudioValueRange caSampleRate = pSampleRateRanges[iCASampleRate]; if (caSampleRate.mMinimum <= malSampleRate && caSampleRate.mMaximum >= malSampleRate) { *pSampleRateOut = malSampleRate; ma_free(pSampleRateRanges, &pContext->allocationCallbacks); return MA_SUCCESS; } } } /* If we get here it means none of miniaudio's standard sample rates matched any of the supported sample rates from the device. In this case we just fall back to the first one reported by Core Audio. */ MA_ASSERT(sampleRateRangeCount > 0); *pSampleRateOut = pSampleRateRanges[0].mMinimum; ma_free(pSampleRateRanges, &pContext->allocationCallbacks); return MA_SUCCESS; } else { /* Find the closest match to this sample rate. */ UInt32 currentAbsoluteDifference = INT32_MAX; UInt32 iCurrentClosestRange = (UInt32)-1; UInt32 iRange; for (iRange = 0; iRange < sampleRateRangeCount; ++iRange) { if (pSampleRateRanges[iRange].mMinimum <= sampleRateIn && pSampleRateRanges[iRange].mMaximum >= sampleRateIn) { *pSampleRateOut = sampleRateIn; ma_free(pSampleRateRanges, &pContext->allocationCallbacks); return MA_SUCCESS; } else { UInt32 absoluteDifference; if (pSampleRateRanges[iRange].mMinimum > sampleRateIn) { absoluteDifference = pSampleRateRanges[iRange].mMinimum - sampleRateIn; } else { absoluteDifference = sampleRateIn - pSampleRateRanges[iRange].mMaximum; } if (currentAbsoluteDifference > absoluteDifference) { currentAbsoluteDifference = absoluteDifference; iCurrentClosestRange = iRange; } } } MA_ASSERT(iCurrentClosestRange != (UInt32)-1); *pSampleRateOut = pSampleRateRanges[iCurrentClosestRange].mMinimum; ma_free(pSampleRateRanges, &pContext->allocationCallbacks); return MA_SUCCESS; } /* Should never get here, but it would mean we weren't able to find any suitable sample rates. */ /*ma_free(pSampleRateRanges, &pContext->allocationCallbacks);*/ /*return MA_ERROR;*/ } #endif static ma_result ma_get_AudioObject_closest_buffer_size_in_frames(ma_context* pContext, AudioObjectID deviceObjectID, ma_device_type deviceType, ma_uint32 bufferSizeInFramesIn, ma_uint32* pBufferSizeInFramesOut) { AudioObjectPropertyAddress propAddress; AudioValueRange bufferSizeRange; UInt32 dataSize; OSStatus status; MA_ASSERT(pContext != NULL); MA_ASSERT(pBufferSizeInFramesOut != NULL); *pBufferSizeInFramesOut = 0; /* Safety. */ propAddress.mSelector = kAudioDevicePropertyBufferFrameSizeRange; propAddress.mScope = (deviceType == ma_device_type_playback) ? kAudioObjectPropertyScopeOutput : kAudioObjectPropertyScopeInput; propAddress.mElement = AUDIO_OBJECT_PROPERTY_ELEMENT; dataSize = sizeof(bufferSizeRange); status = ((ma_AudioObjectGetPropertyData_proc)pContext->coreaudio.AudioObjectGetPropertyData)(deviceObjectID, &propAddress, 0, NULL, &dataSize, &bufferSizeRange); if (status != noErr) { return ma_result_from_OSStatus(status); } /* This is just a clamp. */ if (bufferSizeInFramesIn < bufferSizeRange.mMinimum) { *pBufferSizeInFramesOut = (ma_uint32)bufferSizeRange.mMinimum; } else if (bufferSizeInFramesIn > bufferSizeRange.mMaximum) { *pBufferSizeInFramesOut = (ma_uint32)bufferSizeRange.mMaximum; } else { *pBufferSizeInFramesOut = bufferSizeInFramesIn; } return MA_SUCCESS; } static ma_result ma_set_AudioObject_buffer_size_in_frames(ma_context* pContext, AudioObjectID deviceObjectID, ma_device_type deviceType, ma_uint32* pPeriodSizeInOut) { ma_result result; ma_uint32 chosenBufferSizeInFrames; AudioObjectPropertyAddress propAddress; UInt32 dataSize; OSStatus status; MA_ASSERT(pContext != NULL); result = ma_get_AudioObject_closest_buffer_size_in_frames(pContext, deviceObjectID, deviceType, *pPeriodSizeInOut, &chosenBufferSizeInFrames); if (result != MA_SUCCESS) { return result; } /* Try setting the size of the buffer... If this fails we just use whatever is currently set. */ propAddress.mSelector = kAudioDevicePropertyBufferFrameSize; propAddress.mScope = (deviceType == ma_device_type_playback) ? kAudioObjectPropertyScopeOutput : kAudioObjectPropertyScopeInput; propAddress.mElement = AUDIO_OBJECT_PROPERTY_ELEMENT; ((ma_AudioObjectSetPropertyData_proc)pContext->coreaudio.AudioObjectSetPropertyData)(deviceObjectID, &propAddress, 0, NULL, sizeof(chosenBufferSizeInFrames), &chosenBufferSizeInFrames); /* Get the actual size of the buffer. */ dataSize = sizeof(*pPeriodSizeInOut); status = ((ma_AudioObjectGetPropertyData_proc)pContext->coreaudio.AudioObjectGetPropertyData)(deviceObjectID, &propAddress, 0, NULL, &dataSize, &chosenBufferSizeInFrames); if (status != noErr) { return ma_result_from_OSStatus(status); } *pPeriodSizeInOut = chosenBufferSizeInFrames; return MA_SUCCESS; } static ma_result ma_find_default_AudioObjectID(ma_context* pContext, ma_device_type deviceType, AudioObjectID* pDeviceObjectID) { AudioObjectPropertyAddress propAddressDefaultDevice; UInt32 defaultDeviceObjectIDSize = sizeof(AudioObjectID); AudioObjectID defaultDeviceObjectID; OSStatus status; MA_ASSERT(pContext != NULL); MA_ASSERT(pDeviceObjectID != NULL); /* Safety. */ *pDeviceObjectID = 0; propAddressDefaultDevice.mScope = kAudioObjectPropertyScopeGlobal; propAddressDefaultDevice.mElement = AUDIO_OBJECT_PROPERTY_ELEMENT; if (deviceType == ma_device_type_playback) { propAddressDefaultDevice.mSelector = kAudioHardwarePropertyDefaultOutputDevice; } else { propAddressDefaultDevice.mSelector = kAudioHardwarePropertyDefaultInputDevice; } defaultDeviceObjectIDSize = sizeof(AudioObjectID); status = ((ma_AudioObjectGetPropertyData_proc)pContext->coreaudio.AudioObjectGetPropertyData)(kAudioObjectSystemObject, &propAddressDefaultDevice, 0, NULL, &defaultDeviceObjectIDSize, &defaultDeviceObjectID); if (status == noErr) { *pDeviceObjectID = defaultDeviceObjectID; return MA_SUCCESS; } /* If we get here it means we couldn't find the device. */ return MA_NO_DEVICE; } static ma_result ma_find_AudioObjectID(ma_context* pContext, ma_device_type deviceType, const ma_device_id* pDeviceID, AudioObjectID* pDeviceObjectID) { MA_ASSERT(pContext != NULL); MA_ASSERT(pDeviceObjectID != NULL); /* Safety. */ *pDeviceObjectID = 0; if (pDeviceID == NULL) { /* Default device. */ return ma_find_default_AudioObjectID(pContext, deviceType, pDeviceObjectID); } else { /* Explicit device. */ UInt32 deviceCount; AudioObjectID* pDeviceObjectIDs; ma_result result; UInt32 iDevice; result = ma_get_device_object_ids__coreaudio(pContext, &deviceCount, &pDeviceObjectIDs); if (result != MA_SUCCESS) { return result; } for (iDevice = 0; iDevice < deviceCount; ++iDevice) { AudioObjectID deviceObjectID = pDeviceObjectIDs[iDevice]; char uid[256]; if (ma_get_AudioObject_uid(pContext, deviceObjectID, sizeof(uid), uid) != MA_SUCCESS) { continue; } if (deviceType == ma_device_type_playback) { if (ma_does_AudioObject_support_playback(pContext, deviceObjectID)) { if (strcmp(uid, pDeviceID->coreaudio) == 0) { *pDeviceObjectID = deviceObjectID; ma_free(pDeviceObjectIDs, &pContext->allocationCallbacks); return MA_SUCCESS; } } } else { if (ma_does_AudioObject_support_capture(pContext, deviceObjectID)) { if (strcmp(uid, pDeviceID->coreaudio) == 0) { *pDeviceObjectID = deviceObjectID; ma_free(pDeviceObjectIDs, &pContext->allocationCallbacks); return MA_SUCCESS; } } } } ma_free(pDeviceObjectIDs, &pContext->allocationCallbacks); } /* If we get here it means we couldn't find the device. */ return MA_NO_DEVICE; } static ma_result ma_find_best_format__coreaudio(ma_context* pContext, AudioObjectID deviceObjectID, ma_device_type deviceType, ma_format format, ma_uint32 channels, ma_uint32 sampleRate, const AudioStreamBasicDescription* pOrigFormat, AudioStreamBasicDescription* pFormat) { UInt32 deviceFormatDescriptionCount; AudioStreamRangedDescription* pDeviceFormatDescriptions; ma_result result; ma_uint32 desiredSampleRate; ma_uint32 desiredChannelCount; ma_format desiredFormat; AudioStreamBasicDescription bestDeviceFormatSoFar; ma_bool32 hasSupportedFormat; UInt32 iFormat; result = ma_get_AudioObject_stream_descriptions(pContext, deviceObjectID, deviceType, &deviceFormatDescriptionCount, &pDeviceFormatDescriptions); if (result != MA_SUCCESS) { return result; } desiredSampleRate = sampleRate; if (desiredSampleRate == 0) { desiredSampleRate = (ma_uint32)(pOrigFormat->mSampleRate); } desiredChannelCount = channels; if (desiredChannelCount == 0) { desiredChannelCount = pOrigFormat->mChannelsPerFrame; } desiredFormat = format; if (desiredFormat == ma_format_unknown) { result = ma_format_from_AudioStreamBasicDescription(pOrigFormat, &desiredFormat); if (result != MA_SUCCESS || desiredFormat == ma_format_unknown) { desiredFormat = g_maFormatPriorities[0]; } } /* If we get here it means we don't have an exact match to what the client is asking for. We'll need to find the closest one. The next loop will check for formats that have the same sample rate to what we're asking for. If there is, we prefer that one in all cases. */ MA_ZERO_OBJECT(&bestDeviceFormatSoFar); hasSupportedFormat = MA_FALSE; for (iFormat = 0; iFormat < deviceFormatDescriptionCount; ++iFormat) { ma_format formatFromDescription; ma_result formatResult = ma_format_from_AudioStreamBasicDescription(&pDeviceFormatDescriptions[iFormat].mFormat, &formatFromDescription); if (formatResult == MA_SUCCESS && formatFromDescription != ma_format_unknown) { hasSupportedFormat = MA_TRUE; bestDeviceFormatSoFar = pDeviceFormatDescriptions[iFormat].mFormat; break; } } if (!hasSupportedFormat) { ma_free(pDeviceFormatDescriptions, &pContext->allocationCallbacks); return MA_FORMAT_NOT_SUPPORTED; } for (iFormat = 0; iFormat < deviceFormatDescriptionCount; ++iFormat) { AudioStreamBasicDescription thisDeviceFormat = pDeviceFormatDescriptions[iFormat].mFormat; ma_format thisSampleFormat; ma_result formatResult; ma_format bestSampleFormatSoFar; /* If the format is not supported by miniaudio we need to skip this one entirely. */ formatResult = ma_format_from_AudioStreamBasicDescription(&pDeviceFormatDescriptions[iFormat].mFormat, &thisSampleFormat); if (formatResult != MA_SUCCESS || thisSampleFormat == ma_format_unknown) { continue; /* The format is not supported by miniaudio. Skip. */ } ma_format_from_AudioStreamBasicDescription(&bestDeviceFormatSoFar, &bestSampleFormatSoFar); /* Getting here means the format is supported by miniaudio which makes this format a candidate. */ if (thisDeviceFormat.mSampleRate != desiredSampleRate) { /* The sample rate does not match, but this format could still be usable, although it's a very low priority. If the best format so far has an equal sample rate we can just ignore this one. */ if (bestDeviceFormatSoFar.mSampleRate == desiredSampleRate) { continue; /* The best sample rate so far has the same sample rate as what we requested which means it's still the best so far. Skip this format. */ } else { /* In this case, neither the best format so far nor this one have the same sample rate. Check the channel count next. */ if (thisDeviceFormat.mChannelsPerFrame != desiredChannelCount) { /* This format has a different sample rate _and_ a different channel count. */ if (bestDeviceFormatSoFar.mChannelsPerFrame == desiredChannelCount) { continue; /* No change to the best format. */ } else { /* Both this format and the best so far have different sample rates and different channel counts. Whichever has the best format is the new best. */ if (ma_get_format_priority_index(thisSampleFormat) < ma_get_format_priority_index(bestSampleFormatSoFar)) { bestDeviceFormatSoFar = thisDeviceFormat; continue; } else { continue; /* No change to the best format. */ } } } else { /* This format has a different sample rate but the desired channel count. */ if (bestDeviceFormatSoFar.mChannelsPerFrame == desiredChannelCount) { /* Both this format and the best so far have the desired channel count. Whichever has the best format is the new best. */ if (ma_get_format_priority_index(thisSampleFormat) < ma_get_format_priority_index(bestSampleFormatSoFar)) { bestDeviceFormatSoFar = thisDeviceFormat; continue; } else { continue; /* No change to the best format for now. */ } } else { /* This format has the desired channel count, but the best so far does not. We have a new best. */ bestDeviceFormatSoFar = thisDeviceFormat; continue; } } } } else { /* The sample rates match which makes this format a very high priority contender. If the best format so far has a different sample rate it needs to be replaced with this one. */ if (bestDeviceFormatSoFar.mSampleRate != desiredSampleRate) { bestDeviceFormatSoFar = thisDeviceFormat; continue; } else { /* In this case both this format and the best format so far have the same sample rate. Check the channel count next. */ if (thisDeviceFormat.mChannelsPerFrame == desiredChannelCount) { /* In this case this format has the same channel count as what the client is requesting. If the best format so far has a different count, this one becomes the new best. */ if (bestDeviceFormatSoFar.mChannelsPerFrame != desiredChannelCount) { bestDeviceFormatSoFar = thisDeviceFormat; continue; } else { /* In this case both this format and the best so far have the ideal sample rate and channel count. Check the format. */ if (thisSampleFormat == desiredFormat) { bestDeviceFormatSoFar = thisDeviceFormat; break; /* Found the exact match. */ } else { /* The formats are different. The new best format is the one with the highest priority format according to miniaudio. */ if (ma_get_format_priority_index(thisSampleFormat) < ma_get_format_priority_index(bestSampleFormatSoFar)) { bestDeviceFormatSoFar = thisDeviceFormat; continue; } else { continue; /* No change to the best format for now. */ } } } } else { /* In this case the channel count is different to what the client has requested. If the best so far has the same channel count as the requested count then it remains the best. */ if (bestDeviceFormatSoFar.mChannelsPerFrame == desiredChannelCount) { continue; } else { /* This is the case where both have the same sample rate (good) but different channel counts. Right now both have about the same priority, but we need to compare the format now. */ if (thisSampleFormat == bestSampleFormatSoFar) { if (ma_get_format_priority_index(thisSampleFormat) < ma_get_format_priority_index(bestSampleFormatSoFar)) { bestDeviceFormatSoFar = thisDeviceFormat; continue; } else { continue; /* No change to the best format for now. */ } } } } } } } *pFormat = bestDeviceFormatSoFar; ma_free(pDeviceFormatDescriptions, &pContext->allocationCallbacks); return MA_SUCCESS; } static ma_result ma_get_AudioUnit_channel_map(ma_context* pContext, AudioUnit audioUnit, ma_device_type deviceType, ma_channel* pChannelMap, size_t channelMapCap) { AudioUnitScope deviceScope; AudioUnitElement deviceBus; UInt32 channelLayoutSize; OSStatus status; AudioChannelLayout* pChannelLayout; ma_result result; MA_ASSERT(pContext != NULL); if (deviceType == ma_device_type_playback) { deviceScope = kAudioUnitScope_Input; deviceBus = MA_COREAUDIO_OUTPUT_BUS; } else { deviceScope = kAudioUnitScope_Output; deviceBus = MA_COREAUDIO_INPUT_BUS; } status = ((ma_AudioUnitGetPropertyInfo_proc)pContext->coreaudio.AudioUnitGetPropertyInfo)(audioUnit, kAudioUnitProperty_AudioChannelLayout, deviceScope, deviceBus, &channelLayoutSize, NULL); if (status != noErr) { return ma_result_from_OSStatus(status); } pChannelLayout = (AudioChannelLayout*)ma_malloc(channelLayoutSize, &pContext->allocationCallbacks); if (pChannelLayout == NULL) { return MA_OUT_OF_MEMORY; } status = ((ma_AudioUnitGetProperty_proc)pContext->coreaudio.AudioUnitGetProperty)(audioUnit, kAudioUnitProperty_AudioChannelLayout, deviceScope, deviceBus, pChannelLayout, &channelLayoutSize); if (status != noErr) { ma_free(pChannelLayout, &pContext->allocationCallbacks); return ma_result_from_OSStatus(status); } result = ma_get_channel_map_from_AudioChannelLayout(pChannelLayout, pChannelMap, channelMapCap); if (result != MA_SUCCESS) { ma_free(pChannelLayout, &pContext->allocationCallbacks); return result; } ma_free(pChannelLayout, &pContext->allocationCallbacks); return MA_SUCCESS; } #endif /* MA_APPLE_DESKTOP */ #if !defined(MA_APPLE_DESKTOP) static void ma_AVAudioSessionPortDescription_to_device_info(AVAudioSessionPortDescription* pPortDesc, ma_device_info* pInfo) { MA_ZERO_OBJECT(pInfo); ma_strncpy_s(pInfo->name, sizeof(pInfo->name), [pPortDesc.portName UTF8String], (size_t)-1); ma_strncpy_s(pInfo->id.coreaudio, sizeof(pInfo->id.coreaudio), [pPortDesc.UID UTF8String], (size_t)-1); } #endif static ma_result ma_context_enumerate_devices__coreaudio(ma_context* pContext, ma_enum_devices_callback_proc callback, void* pUserData) { #if defined(MA_APPLE_DESKTOP) UInt32 deviceCount; AudioObjectID* pDeviceObjectIDs; AudioObjectID defaultDeviceObjectIDPlayback; AudioObjectID defaultDeviceObjectIDCapture; ma_result result; UInt32 iDevice; ma_find_default_AudioObjectID(pContext, ma_device_type_playback, &defaultDeviceObjectIDPlayback); /* OK if this fails. */ ma_find_default_AudioObjectID(pContext, ma_device_type_capture, &defaultDeviceObjectIDCapture); /* OK if this fails. */ result = ma_get_device_object_ids__coreaudio(pContext, &deviceCount, &pDeviceObjectIDs); if (result != MA_SUCCESS) { return result; } for (iDevice = 0; iDevice < deviceCount; ++iDevice) { AudioObjectID deviceObjectID = pDeviceObjectIDs[iDevice]; ma_device_info info; MA_ZERO_OBJECT(&info); if (ma_get_AudioObject_uid(pContext, deviceObjectID, sizeof(info.id.coreaudio), info.id.coreaudio) != MA_SUCCESS) { continue; } if (ma_get_AudioObject_name(pContext, deviceObjectID, sizeof(info.name), info.name) != MA_SUCCESS) { continue; } if (ma_does_AudioObject_support_playback(pContext, deviceObjectID)) { if (deviceObjectID == defaultDeviceObjectIDPlayback) { info.isDefault = MA_TRUE; } if (!callback(pContext, ma_device_type_playback, &info, pUserData)) { break; } } if (ma_does_AudioObject_support_capture(pContext, deviceObjectID)) { if (deviceObjectID == defaultDeviceObjectIDCapture) { info.isDefault = MA_TRUE; } if (!callback(pContext, ma_device_type_capture, &info, pUserData)) { break; } } } ma_free(pDeviceObjectIDs, &pContext->allocationCallbacks); #else ma_device_info info; NSArray *pInputs = [[[AVAudioSession sharedInstance] currentRoute] inputs]; NSArray *pOutputs = [[[AVAudioSession sharedInstance] currentRoute] outputs]; for (AVAudioSessionPortDescription* pPortDesc in pOutputs) { ma_AVAudioSessionPortDescription_to_device_info(pPortDesc, &info); if (!callback(pContext, ma_device_type_playback, &info, pUserData)) { return MA_SUCCESS; } } for (AVAudioSessionPortDescription* pPortDesc in pInputs) { ma_AVAudioSessionPortDescription_to_device_info(pPortDesc, &info); if (!callback(pContext, ma_device_type_capture, &info, pUserData)) { return MA_SUCCESS; } } #endif return MA_SUCCESS; } static ma_result ma_context_get_device_info__coreaudio(ma_context* pContext, ma_device_type deviceType, const ma_device_id* pDeviceID, ma_device_info* pDeviceInfo) { ma_result result; MA_ASSERT(pContext != NULL); #if defined(MA_APPLE_DESKTOP) /* Desktop */ { AudioObjectID deviceObjectID; AudioObjectID defaultDeviceObjectID; UInt32 streamDescriptionCount; AudioStreamRangedDescription* pStreamDescriptions; UInt32 iStreamDescription; UInt32 sampleRateRangeCount; AudioValueRange* pSampleRateRanges; ma_find_default_AudioObjectID(pContext, deviceType, &defaultDeviceObjectID); /* OK if this fails. */ result = ma_find_AudioObjectID(pContext, deviceType, pDeviceID, &deviceObjectID); if (result != MA_SUCCESS) { return result; } result = ma_get_AudioObject_uid(pContext, deviceObjectID, sizeof(pDeviceInfo->id.coreaudio), pDeviceInfo->id.coreaudio); if (result != MA_SUCCESS) { return result; } result = ma_get_AudioObject_name(pContext, deviceObjectID, sizeof(pDeviceInfo->name), pDeviceInfo->name); if (result != MA_SUCCESS) { return result; } if (deviceObjectID == defaultDeviceObjectID) { pDeviceInfo->isDefault = MA_TRUE; } /* There could be a large number of permutations here. Fortunately there is only a single channel count being reported which reduces this quite a bit. For sample rates we're only reporting those that are one of miniaudio's recognized "standard" rates. If there are still more formats than can fit into our fixed sized array we'll just need to truncate them. This is unlikely and will probably only happen if some driver performs software data conversion and therefore reports every possible format and sample rate. */ pDeviceInfo->nativeDataFormatCount = 0; /* Formats. */ { ma_format uniqueFormats[ma_format_count]; ma_uint32 uniqueFormatCount = 0; ma_uint32 channels; /* Channels. */ result = ma_get_AudioObject_channel_count(pContext, deviceObjectID, deviceType, &channels); if (result != MA_SUCCESS) { return result; } /* Formats. */ result = ma_get_AudioObject_stream_descriptions(pContext, deviceObjectID, deviceType, &streamDescriptionCount, &pStreamDescriptions); if (result != MA_SUCCESS) { return result; } for (iStreamDescription = 0; iStreamDescription < streamDescriptionCount; ++iStreamDescription) { ma_format format; ma_bool32 hasFormatBeenHandled = MA_FALSE; ma_uint32 iOutputFormat; ma_uint32 iSampleRate; result = ma_format_from_AudioStreamBasicDescription(&pStreamDescriptions[iStreamDescription].mFormat, &format); if (result != MA_SUCCESS) { continue; } MA_ASSERT(format != ma_format_unknown); /* Make sure the format isn't already in the output list. */ for (iOutputFormat = 0; iOutputFormat < uniqueFormatCount; ++iOutputFormat) { if (uniqueFormats[iOutputFormat] == format) { hasFormatBeenHandled = MA_TRUE; break; } } /* If we've already handled this format just skip it. */ if (hasFormatBeenHandled) { continue; } uniqueFormats[uniqueFormatCount] = format; uniqueFormatCount += 1; /* Sample Rates */ result = ma_get_AudioObject_sample_rates(pContext, deviceObjectID, deviceType, &sampleRateRangeCount, &pSampleRateRanges); if (result != MA_SUCCESS) { return result; } /* Annoyingly Core Audio reports a sample rate range. We just get all the standard rates that are between this range. */ for (iSampleRate = 0; iSampleRate < sampleRateRangeCount; ++iSampleRate) { ma_uint32 iStandardSampleRate; for (iStandardSampleRate = 0; iStandardSampleRate < ma_countof(g_maStandardSampleRatePriorities); iStandardSampleRate += 1) { ma_uint32 standardSampleRate = g_maStandardSampleRatePriorities[iStandardSampleRate]; if (standardSampleRate >= pSampleRateRanges[iSampleRate].mMinimum && standardSampleRate <= pSampleRateRanges[iSampleRate].mMaximum) { /* We have a new data format. Add it to the list. */ pDeviceInfo->nativeDataFormats[pDeviceInfo->nativeDataFormatCount].format = format; pDeviceInfo->nativeDataFormats[pDeviceInfo->nativeDataFormatCount].channels = channels; pDeviceInfo->nativeDataFormats[pDeviceInfo->nativeDataFormatCount].sampleRate = standardSampleRate; pDeviceInfo->nativeDataFormats[pDeviceInfo->nativeDataFormatCount].flags = 0; pDeviceInfo->nativeDataFormatCount += 1; if (pDeviceInfo->nativeDataFormatCount >= ma_countof(pDeviceInfo->nativeDataFormats)) { break; /* No more room for any more formats. */ } } } } ma_free(pSampleRateRanges, &pContext->allocationCallbacks); if (pDeviceInfo->nativeDataFormatCount >= ma_countof(pDeviceInfo->nativeDataFormats)) { break; /* No more room for any more formats. */ } } ma_free(pStreamDescriptions, &pContext->allocationCallbacks); } } #else /* Mobile */ { AudioComponentDescription desc; AudioComponent component; AudioUnit audioUnit; OSStatus status; AudioUnitScope formatScope; AudioUnitElement formatElement; AudioStreamBasicDescription bestFormat; UInt32 propSize; /* We want to ensure we use a consistent device name to device enumeration. */ if (pDeviceID != NULL && pDeviceID->coreaudio[0] != '\0') { ma_bool32 found = MA_FALSE; if (deviceType == ma_device_type_playback) { NSArray *pOutputs = [[[AVAudioSession sharedInstance] currentRoute] outputs]; for (AVAudioSessionPortDescription* pPortDesc in pOutputs) { if (strcmp(pDeviceID->coreaudio, [pPortDesc.UID UTF8String]) == 0) { ma_AVAudioSessionPortDescription_to_device_info(pPortDesc, pDeviceInfo); found = MA_TRUE; break; } } } else { NSArray *pInputs = [[[AVAudioSession sharedInstance] currentRoute] inputs]; for (AVAudioSessionPortDescription* pPortDesc in pInputs) { if (strcmp(pDeviceID->coreaudio, [pPortDesc.UID UTF8String]) == 0) { ma_AVAudioSessionPortDescription_to_device_info(pPortDesc, pDeviceInfo); found = MA_TRUE; break; } } } if (!found) { return MA_DOES_NOT_EXIST; } } else { if (deviceType == ma_device_type_playback) { ma_strncpy_s(pDeviceInfo->name, sizeof(pDeviceInfo->name), MA_DEFAULT_PLAYBACK_DEVICE_NAME, (size_t)-1); } else { ma_strncpy_s(pDeviceInfo->name, sizeof(pDeviceInfo->name), MA_DEFAULT_CAPTURE_DEVICE_NAME, (size_t)-1); } } /* Retrieving device information is more annoying on mobile than desktop. For simplicity I'm locking this down to whatever format is reported on a temporary I/O unit. The problem, however, is that this doesn't return a value for the sample rate which we need to retrieve from the AVAudioSession shared instance. */ desc.componentType = kAudioUnitType_Output; desc.componentSubType = kAudioUnitSubType_RemoteIO; desc.componentManufacturer = kAudioUnitManufacturer_Apple; desc.componentFlags = 0; desc.componentFlagsMask = 0; component = ((ma_AudioComponentFindNext_proc)pContext->coreaudio.AudioComponentFindNext)(NULL, &desc); if (component == NULL) { return MA_FAILED_TO_INIT_BACKEND; } status = ((ma_AudioComponentInstanceNew_proc)pContext->coreaudio.AudioComponentInstanceNew)(component, &audioUnit); if (status != noErr) { return ma_result_from_OSStatus(status); } formatScope = (deviceType == ma_device_type_playback) ? kAudioUnitScope_Input : kAudioUnitScope_Output; formatElement = (deviceType == ma_device_type_playback) ? MA_COREAUDIO_OUTPUT_BUS : MA_COREAUDIO_INPUT_BUS; propSize = sizeof(bestFormat); status = ((ma_AudioUnitGetProperty_proc)pContext->coreaudio.AudioUnitGetProperty)(audioUnit, kAudioUnitProperty_StreamFormat, formatScope, formatElement, &bestFormat, &propSize); if (status != noErr) { ((ma_AudioComponentInstanceDispose_proc)pContext->coreaudio.AudioComponentInstanceDispose)(audioUnit); return ma_result_from_OSStatus(status); } ((ma_AudioComponentInstanceDispose_proc)pContext->coreaudio.AudioComponentInstanceDispose)(audioUnit); audioUnit = NULL; /* Only a single format is being reported for iOS. */ pDeviceInfo->nativeDataFormatCount = 1; result = ma_format_from_AudioStreamBasicDescription(&bestFormat, &pDeviceInfo->nativeDataFormats[0].format); if (result != MA_SUCCESS) { return result; } pDeviceInfo->nativeDataFormats[0].channels = bestFormat.mChannelsPerFrame; /* It looks like Apple are wanting to push the whole AVAudioSession thing. Thus, we need to use that to determine device settings. To do this we just get the shared instance and inspect. */ @autoreleasepool { AVAudioSession* pAudioSession = [AVAudioSession sharedInstance]; MA_ASSERT(pAudioSession != NULL); pDeviceInfo->nativeDataFormats[0].sampleRate = (ma_uint32)pAudioSession.sampleRate; } } #endif (void)pDeviceInfo; /* Unused. */ return MA_SUCCESS; } static AudioBufferList* ma_allocate_AudioBufferList__coreaudio(ma_uint32 sizeInFrames, ma_format format, ma_uint32 channels, ma_stream_layout layout, const ma_allocation_callbacks* pAllocationCallbacks) { AudioBufferList* pBufferList; UInt32 audioBufferSizeInBytes; size_t allocationSize; MA_ASSERT(sizeInFrames > 0); MA_ASSERT(format != ma_format_unknown); MA_ASSERT(channels > 0); allocationSize = sizeof(AudioBufferList) - sizeof(AudioBuffer); /* Subtract sizeof(AudioBuffer) because that part is dynamically sized. */ if (layout == ma_stream_layout_interleaved) { /* Interleaved case. This is the simple case because we just have one buffer. */ allocationSize += sizeof(AudioBuffer) * 1; } else { /* Non-interleaved case. This is the more complex case because there's more than one buffer. */ allocationSize += sizeof(AudioBuffer) * channels; } allocationSize += sizeInFrames * ma_get_bytes_per_frame(format, channels); pBufferList = (AudioBufferList*)ma_malloc(allocationSize, pAllocationCallbacks); if (pBufferList == NULL) { return NULL; } audioBufferSizeInBytes = (UInt32)(sizeInFrames * ma_get_bytes_per_sample(format)); if (layout == ma_stream_layout_interleaved) { pBufferList->mNumberBuffers = 1; pBufferList->mBuffers[0].mNumberChannels = channels; pBufferList->mBuffers[0].mDataByteSize = audioBufferSizeInBytes * channels; pBufferList->mBuffers[0].mData = (ma_uint8*)pBufferList + sizeof(AudioBufferList); } else { ma_uint32 iBuffer; pBufferList->mNumberBuffers = channels; for (iBuffer = 0; iBuffer < pBufferList->mNumberBuffers; ++iBuffer) { pBufferList->mBuffers[iBuffer].mNumberChannels = 1; pBufferList->mBuffers[iBuffer].mDataByteSize = audioBufferSizeInBytes; pBufferList->mBuffers[iBuffer].mData = (ma_uint8*)pBufferList + ((sizeof(AudioBufferList) - sizeof(AudioBuffer)) + (sizeof(AudioBuffer) * channels)) + (audioBufferSizeInBytes * iBuffer); } } return pBufferList; } static ma_result ma_device_realloc_AudioBufferList__coreaudio(ma_device* pDevice, ma_uint32 sizeInFrames, ma_format format, ma_uint32 channels, ma_stream_layout layout) { MA_ASSERT(pDevice != NULL); MA_ASSERT(format != ma_format_unknown); MA_ASSERT(channels > 0); /* Only resize the buffer if necessary. */ if (pDevice->coreaudio.audioBufferCapInFrames < sizeInFrames) { AudioBufferList* pNewAudioBufferList; pNewAudioBufferList = ma_allocate_AudioBufferList__coreaudio(sizeInFrames, format, channels, layout, &pDevice->pContext->allocationCallbacks); if (pNewAudioBufferList == NULL) { return MA_OUT_OF_MEMORY; } /* At this point we'll have a new AudioBufferList and we can free the old one. */ ma_free(pDevice->coreaudio.pAudioBufferList, &pDevice->pContext->allocationCallbacks); pDevice->coreaudio.pAudioBufferList = pNewAudioBufferList; pDevice->coreaudio.audioBufferCapInFrames = sizeInFrames; } /* Getting here means the capacity of the audio is fine. */ return MA_SUCCESS; } static OSStatus ma_on_output__coreaudio(void* pUserData, AudioUnitRenderActionFlags* pActionFlags, const AudioTimeStamp* pTimeStamp, UInt32 busNumber, UInt32 frameCount, AudioBufferList* pBufferList) { ma_device* pDevice = (ma_device*)pUserData; ma_stream_layout layout; MA_ASSERT(pDevice != NULL); /*ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_DEBUG, "INFO: Output Callback: busNumber=%d, frameCount=%d, mNumberBuffers=%d\n", (int)busNumber, (int)frameCount, (int)pBufferList->mNumberBuffers);*/ /* We need to check whether or not we are outputting interleaved or non-interleaved samples. The way we do this is slightly different for each type. */ layout = ma_stream_layout_interleaved; if (pBufferList->mBuffers[0].mNumberChannels != pDevice->playback.internalChannels) { layout = ma_stream_layout_deinterleaved; } if (layout == ma_stream_layout_interleaved) { /* For now we can assume everything is interleaved. */ UInt32 iBuffer; for (iBuffer = 0; iBuffer < pBufferList->mNumberBuffers; ++iBuffer) { if (pBufferList->mBuffers[iBuffer].mNumberChannels == pDevice->playback.internalChannels) { ma_uint32 frameCountForThisBuffer = pBufferList->mBuffers[iBuffer].mDataByteSize / ma_get_bytes_per_frame(pDevice->playback.internalFormat, pDevice->playback.internalChannels); if (frameCountForThisBuffer > 0) { ma_device_handle_backend_data_callback(pDevice, pBufferList->mBuffers[iBuffer].mData, NULL, frameCountForThisBuffer); } /*a_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_DEBUG, " frameCount=%d, mNumberChannels=%d, mDataByteSize=%d\n", (int)frameCount, (int)pBufferList->mBuffers[iBuffer].mNumberChannels, (int)pBufferList->mBuffers[iBuffer].mDataByteSize);*/ } else { /* This case is where the number of channels in the output buffer do not match our internal channels. It could mean that it's not interleaved, in which case we can't handle right now since miniaudio does not yet support non-interleaved streams. We just output silence here. */ MA_ZERO_MEMORY(pBufferList->mBuffers[iBuffer].mData, pBufferList->mBuffers[iBuffer].mDataByteSize); /*ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_DEBUG, " WARNING: Outputting silence. frameCount=%d, mNumberChannels=%d, mDataByteSize=%d\n", (int)frameCount, (int)pBufferList->mBuffers[iBuffer].mNumberChannels, (int)pBufferList->mBuffers[iBuffer].mDataByteSize);*/ } } } else { /* This is the deinterleaved case. We need to update each buffer in groups of internalChannels. This assumes each buffer is the same size. */ MA_ASSERT(pDevice->playback.internalChannels <= MA_MAX_CHANNELS); /* This should heve been validated at initialization time. */ /* For safety we'll check that the internal channels is a multiple of the buffer count. If it's not it means something very strange has happened and we're not going to support it. */ if ((pBufferList->mNumberBuffers % pDevice->playback.internalChannels) == 0) { ma_uint8 tempBuffer[4096]; UInt32 iBuffer; for (iBuffer = 0; iBuffer < pBufferList->mNumberBuffers; iBuffer += pDevice->playback.internalChannels) { ma_uint32 frameCountPerBuffer = pBufferList->mBuffers[iBuffer].mDataByteSize / ma_get_bytes_per_sample(pDevice->playback.internalFormat); ma_uint32 framesRemaining = frameCountPerBuffer; while (framesRemaining > 0) { void* ppDeinterleavedBuffers[MA_MAX_CHANNELS]; ma_uint32 iChannel; ma_uint32 framesToRead = sizeof(tempBuffer) / ma_get_bytes_per_frame(pDevice->playback.internalFormat, pDevice->playback.internalChannels); if (framesToRead > framesRemaining) { framesToRead = framesRemaining; } ma_device_handle_backend_data_callback(pDevice, tempBuffer, NULL, framesToRead); for (iChannel = 0; iChannel < pDevice->playback.internalChannels; ++iChannel) { ppDeinterleavedBuffers[iChannel] = (void*)ma_offset_ptr(pBufferList->mBuffers[iBuffer+iChannel].mData, (frameCountPerBuffer - framesRemaining) * ma_get_bytes_per_sample(pDevice->playback.internalFormat)); } ma_deinterleave_pcm_frames(pDevice->playback.internalFormat, pDevice->playback.internalChannels, framesToRead, tempBuffer, ppDeinterleavedBuffers); framesRemaining -= framesToRead; } } } } (void)pActionFlags; (void)pTimeStamp; (void)busNumber; (void)frameCount; return noErr; } static OSStatus ma_on_input__coreaudio(void* pUserData, AudioUnitRenderActionFlags* pActionFlags, const AudioTimeStamp* pTimeStamp, UInt32 busNumber, UInt32 frameCount, AudioBufferList* pUnusedBufferList) { ma_device* pDevice = (ma_device*)pUserData; AudioBufferList* pRenderedBufferList; ma_result result; ma_stream_layout layout; ma_uint32 iBuffer; OSStatus status; MA_ASSERT(pDevice != NULL); pRenderedBufferList = (AudioBufferList*)pDevice->coreaudio.pAudioBufferList; MA_ASSERT(pRenderedBufferList); /* We need to check whether or not we are outputting interleaved or non-interleaved samples. The way we do this is slightly different for each type. */ layout = ma_stream_layout_interleaved; if (pRenderedBufferList->mBuffers[0].mNumberChannels != pDevice->capture.internalChannels) { layout = ma_stream_layout_deinterleaved; } /*ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_DEBUG, "INFO: Input Callback: busNumber=%d, frameCount=%d, mNumberBuffers=%d\n", (int)busNumber, (int)frameCount, (int)pRenderedBufferList->mNumberBuffers);*/ /* There has been a situation reported where frame count passed into this function is greater than the capacity of our capture buffer. There doesn't seem to be a reliable way to determine what the maximum frame count will be, so we need to instead resort to dynamically reallocating our buffer to ensure it's large enough to capture the number of frames requested by this callback. */ result = ma_device_realloc_AudioBufferList__coreaudio(pDevice, frameCount, pDevice->capture.internalFormat, pDevice->capture.internalChannels, layout); if (result != MA_SUCCESS) { ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_DEBUG, "Failed to allocate AudioBufferList for capture.\n"); return noErr; } pRenderedBufferList = (AudioBufferList*)pDevice->coreaudio.pAudioBufferList; MA_ASSERT(pRenderedBufferList); /* When you call AudioUnitRender(), Core Audio tries to be helpful by setting the mDataByteSize to the number of bytes that were actually rendered. The problem with this is that the next call can fail with -50 due to the size no longer being set to the capacity of the buffer, but instead the size in bytes of the previous render. This will cause a problem when a future call to this callback specifies a larger number of frames. To work around this we need to explicitly set the size of each buffer to their respective size in bytes. */ for (iBuffer = 0; iBuffer < pRenderedBufferList->mNumberBuffers; ++iBuffer) { pRenderedBufferList->mBuffers[iBuffer].mDataByteSize = pDevice->coreaudio.audioBufferCapInFrames * ma_get_bytes_per_sample(pDevice->capture.internalFormat) * pRenderedBufferList->mBuffers[iBuffer].mNumberChannels; } status = ((ma_AudioUnitRender_proc)pDevice->pContext->coreaudio.AudioUnitRender)((AudioUnit)pDevice->coreaudio.audioUnitCapture, pActionFlags, pTimeStamp, busNumber, frameCount, pRenderedBufferList); if (status != noErr) { ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_DEBUG, " ERROR: AudioUnitRender() failed with %d.\n", (int)status); return status; } if (layout == ma_stream_layout_interleaved) { for (iBuffer = 0; iBuffer < pRenderedBufferList->mNumberBuffers; ++iBuffer) { if (pRenderedBufferList->mBuffers[iBuffer].mNumberChannels == pDevice->capture.internalChannels) { ma_device_handle_backend_data_callback(pDevice, NULL, pRenderedBufferList->mBuffers[iBuffer].mData, frameCount); /*ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_DEBUG, " mDataByteSize=%d.\n", (int)pRenderedBufferList->mBuffers[iBuffer].mDataByteSize);*/ } else { /* This case is where the number of channels in the output buffer do not match our internal channels. It could mean that it's not interleaved, in which case we can't handle right now since miniaudio does not yet support non-interleaved streams. */ ma_uint8 silentBuffer[4096]; ma_uint32 framesRemaining; MA_ZERO_MEMORY(silentBuffer, sizeof(silentBuffer)); framesRemaining = frameCount; while (framesRemaining > 0) { ma_uint32 framesToSend = sizeof(silentBuffer) / ma_get_bytes_per_frame(pDevice->capture.internalFormat, pDevice->capture.internalChannels); if (framesToSend > framesRemaining) { framesToSend = framesRemaining; } ma_device_handle_backend_data_callback(pDevice, NULL, silentBuffer, framesToSend); framesRemaining -= framesToSend; } /*ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_DEBUG, " WARNING: Outputting silence. frameCount=%d, mNumberChannels=%d, mDataByteSize=%d\n", (int)frameCount, (int)pRenderedBufferList->mBuffers[iBuffer].mNumberChannels, (int)pRenderedBufferList->mBuffers[iBuffer].mDataByteSize);*/ } } } else { /* This is the deinterleaved case. We need to interleave the audio data before sending it to the client. This assumes each buffer is the same size. */ MA_ASSERT(pDevice->capture.internalChannels <= MA_MAX_CHANNELS); /* This should have been validated at initialization time. */ /* For safety we'll check that the internal channels is a multiple of the buffer count. If it's not it means something very strange has happened and we're not going to support it. */ if ((pRenderedBufferList->mNumberBuffers % pDevice->capture.internalChannels) == 0) { ma_uint8 tempBuffer[4096]; for (iBuffer = 0; iBuffer < pRenderedBufferList->mNumberBuffers; iBuffer += pDevice->capture.internalChannels) { ma_uint32 framesRemaining = frameCount; while (framesRemaining > 0) { void* ppDeinterleavedBuffers[MA_MAX_CHANNELS]; ma_uint32 iChannel; ma_uint32 framesToSend = sizeof(tempBuffer) / ma_get_bytes_per_frame(pDevice->capture.internalFormat, pDevice->capture.internalChannels); if (framesToSend > framesRemaining) { framesToSend = framesRemaining; } for (iChannel = 0; iChannel < pDevice->capture.internalChannels; ++iChannel) { ppDeinterleavedBuffers[iChannel] = (void*)ma_offset_ptr(pRenderedBufferList->mBuffers[iBuffer+iChannel].mData, (frameCount - framesRemaining) * ma_get_bytes_per_sample(pDevice->capture.internalFormat)); } ma_interleave_pcm_frames(pDevice->capture.internalFormat, pDevice->capture.internalChannels, framesToSend, (const void**)ppDeinterleavedBuffers, tempBuffer); ma_device_handle_backend_data_callback(pDevice, NULL, tempBuffer, framesToSend); framesRemaining -= framesToSend; } } } } (void)pActionFlags; (void)pTimeStamp; (void)busNumber; (void)frameCount; (void)pUnusedBufferList; return noErr; } static void on_start_stop__coreaudio(void* pUserData, AudioUnit audioUnit, AudioUnitPropertyID propertyID, AudioUnitScope scope, AudioUnitElement element) { ma_device* pDevice = (ma_device*)pUserData; MA_ASSERT(pDevice != NULL); /* Don't do anything if it looks like we're just reinitializing due to a device switch. */ if (((audioUnit == pDevice->coreaudio.audioUnitPlayback) && pDevice->coreaudio.isSwitchingPlaybackDevice) || ((audioUnit == pDevice->coreaudio.audioUnitCapture) && pDevice->coreaudio.isSwitchingCaptureDevice)) { return; } /* There's been a report of a deadlock here when triggered by ma_device_uninit(). It looks like AudioUnitGetProprty (called below) and AudioComponentInstanceDispose (called in ma_device_uninit) can try waiting on the same lock. I'm going to try working around this by not calling any Core Audio APIs in the callback when the device has been stopped or uninitialized. */ if (ma_device_get_state(pDevice) == ma_device_state_uninitialized || ma_device_get_state(pDevice) == ma_device_state_stopping || ma_device_get_state(pDevice) == ma_device_state_stopped) { ma_device__on_notification_stopped(pDevice); } else { UInt32 isRunning; UInt32 isRunningSize = sizeof(isRunning); OSStatus status = ((ma_AudioUnitGetProperty_proc)pDevice->pContext->coreaudio.AudioUnitGetProperty)(audioUnit, kAudioOutputUnitProperty_IsRunning, scope, element, &isRunning, &isRunningSize); if (status != noErr) { goto done; /* Don't really know what to do in this case... just ignore it, I suppose... */ } if (!isRunning) { /* The stop event is a bit annoying in Core Audio because it will be called when we automatically switch the default device. Some scenarios to consider: 1) When the device is unplugged, this will be called _before_ the default device change notification. 2) When the device is changed via the default device change notification, this will be called _after_ the switch. For case #1, we just check if there's a new default device available. If so, we just ignore the stop event. For case #2 we check a flag. */ if (((audioUnit == pDevice->coreaudio.audioUnitPlayback) && pDevice->coreaudio.isDefaultPlaybackDevice) || ((audioUnit == pDevice->coreaudio.audioUnitCapture) && pDevice->coreaudio.isDefaultCaptureDevice)) { /* It looks like the device is switching through an external event, such as the user unplugging the device or changing the default device via the operating system's sound settings. If we're re-initializing the device, we just terminate because we want the stopping of the device to be seamless to the client (we don't want them receiving the stopped event and thinking that the device has stopped when it hasn't!). */ if (((audioUnit == pDevice->coreaudio.audioUnitPlayback) && pDevice->coreaudio.isSwitchingPlaybackDevice) || ((audioUnit == pDevice->coreaudio.audioUnitCapture) && pDevice->coreaudio.isSwitchingCaptureDevice)) { goto done; } /* Getting here means the device is not reinitializing which means it may have been unplugged. From what I can see, it looks like Core Audio will try switching to the new default device seamlessly. We need to somehow find a way to determine whether or not Core Audio will most likely be successful in switching to the new device. TODO: Try to predict if Core Audio will switch devices. If not, the stopped callback needs to be posted. */ goto done; } /* Getting here means we need to stop the device. */ ma_device__on_notification_stopped(pDevice); } } (void)propertyID; /* Unused. */ done: /* Always signal the stop event. It's possible for the "else" case to get hit which can happen during an interruption. */ ma_event_signal(&pDevice->coreaudio.stopEvent); } #if defined(MA_APPLE_DESKTOP) static ma_spinlock g_DeviceTrackingInitLock_CoreAudio = 0; /* A spinlock for mutal exclusion of the init/uninit of the global tracking data. Initialization to 0 is what we need. */ static ma_uint32 g_DeviceTrackingInitCounter_CoreAudio = 0; static ma_mutex g_DeviceTrackingMutex_CoreAudio; static ma_device** g_ppTrackedDevices_CoreAudio = NULL; static ma_uint32 g_TrackedDeviceCap_CoreAudio = 0; static ma_uint32 g_TrackedDeviceCount_CoreAudio = 0; static OSStatus ma_default_device_changed__coreaudio(AudioObjectID objectID, UInt32 addressCount, const AudioObjectPropertyAddress* pAddresses, void* pUserData) { ma_device_type deviceType; /* Not sure if I really need to check this, but it makes me feel better. */ if (addressCount == 0) { return noErr; } if (pAddresses[0].mSelector == kAudioHardwarePropertyDefaultOutputDevice) { deviceType = ma_device_type_playback; } else if (pAddresses[0].mSelector == kAudioHardwarePropertyDefaultInputDevice) { deviceType = ma_device_type_capture; } else { return noErr; /* Should never hit this. */ } ma_mutex_lock(&g_DeviceTrackingMutex_CoreAudio); { ma_uint32 iDevice; for (iDevice = 0; iDevice < g_TrackedDeviceCount_CoreAudio; iDevice += 1) { ma_result reinitResult; ma_device* pDevice; pDevice = g_ppTrackedDevices_CoreAudio[iDevice]; if (pDevice->type == deviceType || pDevice->type == ma_device_type_duplex) { if (deviceType == ma_device_type_playback) { pDevice->coreaudio.isSwitchingPlaybackDevice = MA_TRUE; reinitResult = ma_device_reinit_internal__coreaudio(pDevice, deviceType, MA_TRUE); pDevice->coreaudio.isSwitchingPlaybackDevice = MA_FALSE; } else { pDevice->coreaudio.isSwitchingCaptureDevice = MA_TRUE; reinitResult = ma_device_reinit_internal__coreaudio(pDevice, deviceType, MA_TRUE); pDevice->coreaudio.isSwitchingCaptureDevice = MA_FALSE; } if (reinitResult == MA_SUCCESS) { ma_device__post_init_setup(pDevice, deviceType); /* Restart the device if required. If this fails we need to stop the device entirely. */ if (ma_device_get_state(pDevice) == ma_device_state_started) { OSStatus status; if (deviceType == ma_device_type_playback) { status = ((ma_AudioOutputUnitStart_proc)pDevice->pContext->coreaudio.AudioOutputUnitStart)((AudioUnit)pDevice->coreaudio.audioUnitPlayback); if (status != noErr) { if (pDevice->type == ma_device_type_duplex) { ((ma_AudioOutputUnitStop_proc)pDevice->pContext->coreaudio.AudioOutputUnitStop)((AudioUnit)pDevice->coreaudio.audioUnitCapture); } ma_device__set_state(pDevice, ma_device_state_stopped); } } else if (deviceType == ma_device_type_capture) { status = ((ma_AudioOutputUnitStart_proc)pDevice->pContext->coreaudio.AudioOutputUnitStart)((AudioUnit)pDevice->coreaudio.audioUnitCapture); if (status != noErr) { if (pDevice->type == ma_device_type_duplex) { ((ma_AudioOutputUnitStop_proc)pDevice->pContext->coreaudio.AudioOutputUnitStop)((AudioUnit)pDevice->coreaudio.audioUnitPlayback); } ma_device__set_state(pDevice, ma_device_state_stopped); } } } ma_device__on_notification_rerouted(pDevice); } } } } ma_mutex_unlock(&g_DeviceTrackingMutex_CoreAudio); /* Unused parameters. */ (void)objectID; (void)pUserData; return noErr; } static ma_result ma_context__init_device_tracking__coreaudio(ma_context* pContext) { MA_ASSERT(pContext != NULL); ma_spinlock_lock(&g_DeviceTrackingInitLock_CoreAudio); { /* Don't do anything if we've already initializd device tracking. */ if (g_DeviceTrackingInitCounter_CoreAudio == 0) { AudioObjectPropertyAddress propAddress; propAddress.mScope = kAudioObjectPropertyScopeGlobal; propAddress.mElement = AUDIO_OBJECT_PROPERTY_ELEMENT; ma_mutex_init(&g_DeviceTrackingMutex_CoreAudio); propAddress.mSelector = kAudioHardwarePropertyDefaultInputDevice; ((ma_AudioObjectAddPropertyListener_proc)pContext->coreaudio.AudioObjectAddPropertyListener)(kAudioObjectSystemObject, &propAddress, &ma_default_device_changed__coreaudio, NULL); propAddress.mSelector = kAudioHardwarePropertyDefaultOutputDevice; ((ma_AudioObjectAddPropertyListener_proc)pContext->coreaudio.AudioObjectAddPropertyListener)(kAudioObjectSystemObject, &propAddress, &ma_default_device_changed__coreaudio, NULL); } g_DeviceTrackingInitCounter_CoreAudio += 1; } ma_spinlock_unlock(&g_DeviceTrackingInitLock_CoreAudio); return MA_SUCCESS; } static ma_result ma_context__uninit_device_tracking__coreaudio(ma_context* pContext) { MA_ASSERT(pContext != NULL); ma_spinlock_lock(&g_DeviceTrackingInitLock_CoreAudio); { if (g_DeviceTrackingInitCounter_CoreAudio > 0) g_DeviceTrackingInitCounter_CoreAudio -= 1; if (g_DeviceTrackingInitCounter_CoreAudio == 0) { AudioObjectPropertyAddress propAddress; propAddress.mScope = kAudioObjectPropertyScopeGlobal; propAddress.mElement = AUDIO_OBJECT_PROPERTY_ELEMENT; propAddress.mSelector = kAudioHardwarePropertyDefaultInputDevice; ((ma_AudioObjectRemovePropertyListener_proc)pContext->coreaudio.AudioObjectRemovePropertyListener)(kAudioObjectSystemObject, &propAddress, &ma_default_device_changed__coreaudio, NULL); propAddress.mSelector = kAudioHardwarePropertyDefaultOutputDevice; ((ma_AudioObjectRemovePropertyListener_proc)pContext->coreaudio.AudioObjectRemovePropertyListener)(kAudioObjectSystemObject, &propAddress, &ma_default_device_changed__coreaudio, NULL); /* At this point there should be no tracked devices. If not there's an error somewhere. */ if (g_ppTrackedDevices_CoreAudio != NULL) { ma_log_postf(ma_context_get_log(pContext), MA_LOG_LEVEL_WARNING, "You have uninitialized all contexts while an associated device is still active."); ma_spinlock_unlock(&g_DeviceTrackingInitLock_CoreAudio); return MA_INVALID_OPERATION; } ma_mutex_uninit(&g_DeviceTrackingMutex_CoreAudio); } } ma_spinlock_unlock(&g_DeviceTrackingInitLock_CoreAudio); return MA_SUCCESS; } static ma_result ma_device__track__coreaudio(ma_device* pDevice) { MA_ASSERT(pDevice != NULL); ma_mutex_lock(&g_DeviceTrackingMutex_CoreAudio); { /* Allocate memory if required. */ if (g_TrackedDeviceCap_CoreAudio <= g_TrackedDeviceCount_CoreAudio) { ma_uint32 newCap; ma_device** ppNewDevices; newCap = g_TrackedDeviceCap_CoreAudio * 2; if (newCap == 0) { newCap = 1; } ppNewDevices = (ma_device**)ma_realloc(g_ppTrackedDevices_CoreAudio, sizeof(*g_ppTrackedDevices_CoreAudio)*newCap, &pDevice->pContext->allocationCallbacks); if (ppNewDevices == NULL) { ma_mutex_unlock(&g_DeviceTrackingMutex_CoreAudio); return MA_OUT_OF_MEMORY; } g_ppTrackedDevices_CoreAudio = ppNewDevices; g_TrackedDeviceCap_CoreAudio = newCap; } g_ppTrackedDevices_CoreAudio[g_TrackedDeviceCount_CoreAudio] = pDevice; g_TrackedDeviceCount_CoreAudio += 1; } ma_mutex_unlock(&g_DeviceTrackingMutex_CoreAudio); return MA_SUCCESS; } static ma_result ma_device__untrack__coreaudio(ma_device* pDevice) { MA_ASSERT(pDevice != NULL); ma_mutex_lock(&g_DeviceTrackingMutex_CoreAudio); { ma_uint32 iDevice; for (iDevice = 0; iDevice < g_TrackedDeviceCount_CoreAudio; iDevice += 1) { if (g_ppTrackedDevices_CoreAudio[iDevice] == pDevice) { /* We've found the device. We now need to remove it from the list. */ ma_uint32 jDevice; for (jDevice = iDevice; jDevice < g_TrackedDeviceCount_CoreAudio-1; jDevice += 1) { g_ppTrackedDevices_CoreAudio[jDevice] = g_ppTrackedDevices_CoreAudio[jDevice+1]; } g_TrackedDeviceCount_CoreAudio -= 1; /* If there's nothing else in the list we need to free memory. */ if (g_TrackedDeviceCount_CoreAudio == 0) { ma_free(g_ppTrackedDevices_CoreAudio, &pDevice->pContext->allocationCallbacks); g_ppTrackedDevices_CoreAudio = NULL; g_TrackedDeviceCap_CoreAudio = 0; } break; } } } ma_mutex_unlock(&g_DeviceTrackingMutex_CoreAudio); return MA_SUCCESS; } #endif #if defined(MA_APPLE_MOBILE) @interface ma_ios_notification_handler:NSObject { ma_device* m_pDevice; } @end @implementation ma_ios_notification_handler -(id)init:(ma_device*)pDevice { self = [super init]; m_pDevice = pDevice; /* For route changes. */ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handle_route_change:) name:AVAudioSessionRouteChangeNotification object:[AVAudioSession sharedInstance]]; /* For interruptions. */ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handle_interruption:) name:AVAudioSessionInterruptionNotification object:[AVAudioSession sharedInstance]]; return self; } -(void)dealloc { [self remove_handler]; #if defined(__has_feature) #if !__has_feature(objc_arc) [super dealloc]; #endif #endif } -(void)remove_handler { [[NSNotificationCenter defaultCenter] removeObserver:self name:AVAudioSessionRouteChangeNotification object:nil]; [[NSNotificationCenter defaultCenter] removeObserver:self name:AVAudioSessionInterruptionNotification object:nil]; } -(void)handle_interruption:(NSNotification*)pNotification { NSInteger type = [[[pNotification userInfo] objectForKey:AVAudioSessionInterruptionTypeKey] integerValue]; switch (type) { case AVAudioSessionInterruptionTypeBegan: { ma_log_postf(ma_device_get_log(m_pDevice), MA_LOG_LEVEL_INFO, "[Core Audio] Interruption: AVAudioSessionInterruptionTypeBegan\n"); /* Core Audio will have stopped the internal device automatically, but we need explicitly stop it at a higher level to ensure miniaudio-specific state is updated for consistency. */ ma_device_stop(m_pDevice); /* Fire the notification after the device has been stopped to ensure it's in the correct state when the notification handler is invoked. */ ma_device__on_notification_interruption_began(m_pDevice); } break; case AVAudioSessionInterruptionTypeEnded: { ma_log_postf(ma_device_get_log(m_pDevice), MA_LOG_LEVEL_INFO, "[Core Audio] Interruption: AVAudioSessionInterruptionTypeEnded\n"); ma_device__on_notification_interruption_ended(m_pDevice); } break; } } -(void)handle_route_change:(NSNotification*)pNotification { AVAudioSession* pSession = [AVAudioSession sharedInstance]; NSInteger reason = [[[pNotification userInfo] objectForKey:AVAudioSessionRouteChangeReasonKey] integerValue]; switch (reason) { case AVAudioSessionRouteChangeReasonOldDeviceUnavailable: { ma_log_postf(ma_device_get_log(m_pDevice), MA_LOG_LEVEL_INFO, "[Core Audio] Route Changed: AVAudioSessionRouteChangeReasonOldDeviceUnavailable\n"); } break; case AVAudioSessionRouteChangeReasonNewDeviceAvailable: { ma_log_postf(ma_device_get_log(m_pDevice), MA_LOG_LEVEL_INFO, "[Core Audio] Route Changed: AVAudioSessionRouteChangeReasonNewDeviceAvailable\n"); } break; case AVAudioSessionRouteChangeReasonNoSuitableRouteForCategory: { ma_log_postf(ma_device_get_log(m_pDevice), MA_LOG_LEVEL_INFO, "[Core Audio] Route Changed: AVAudioSessionRouteChangeReasonNoSuitableRouteForCategory\n"); } break; case AVAudioSessionRouteChangeReasonWakeFromSleep: { ma_log_postf(ma_device_get_log(m_pDevice), MA_LOG_LEVEL_INFO, "[Core Audio] Route Changed: AVAudioSessionRouteChangeReasonWakeFromSleep\n"); } break; case AVAudioSessionRouteChangeReasonOverride: { ma_log_postf(ma_device_get_log(m_pDevice), MA_LOG_LEVEL_INFO, "[Core Audio] Route Changed: AVAudioSessionRouteChangeReasonOverride\n"); } break; case AVAudioSessionRouteChangeReasonCategoryChange: { ma_log_postf(ma_device_get_log(m_pDevice), MA_LOG_LEVEL_INFO, "[Core Audio] Route Changed: AVAudioSessionRouteChangeReasonCategoryChange\n"); } break; case AVAudioSessionRouteChangeReasonUnknown: default: { ma_log_postf(ma_device_get_log(m_pDevice), MA_LOG_LEVEL_INFO, "[Core Audio] Route Changed: AVAudioSessionRouteChangeReasonUnknown\n"); } break; } ma_log_postf(ma_device_get_log(m_pDevice), MA_LOG_LEVEL_DEBUG, "[Core Audio] Changing Route. inputNumberChannels=%d; outputNumberOfChannels=%d\n", (int)pSession.inputNumberOfChannels, (int)pSession.outputNumberOfChannels); /* Let the application know about the route change. */ ma_device__on_notification_rerouted(m_pDevice); } @end #endif static ma_result ma_device_uninit__coreaudio(ma_device* pDevice) { MA_ASSERT(pDevice != NULL); MA_ASSERT(ma_device_get_state(pDevice) == ma_device_state_uninitialized); #if defined(MA_APPLE_DESKTOP) /* Make sure we're no longer tracking the device. It doesn't matter if we call this for a non-default device because it'll just gracefully ignore it. */ ma_device__untrack__coreaudio(pDevice); #endif #if defined(MA_APPLE_MOBILE) if (pDevice->coreaudio.pNotificationHandler != NULL) { ma_ios_notification_handler* pNotificationHandler = (MA_BRIDGE_TRANSFER ma_ios_notification_handler*)pDevice->coreaudio.pNotificationHandler; [pNotificationHandler remove_handler]; } #endif if (pDevice->coreaudio.audioUnitCapture != NULL) { ((ma_AudioComponentInstanceDispose_proc)pDevice->pContext->coreaudio.AudioComponentInstanceDispose)((AudioUnit)pDevice->coreaudio.audioUnitCapture); } if (pDevice->coreaudio.audioUnitPlayback != NULL) { ((ma_AudioComponentInstanceDispose_proc)pDevice->pContext->coreaudio.AudioComponentInstanceDispose)((AudioUnit)pDevice->coreaudio.audioUnitPlayback); } if (pDevice->coreaudio.pAudioBufferList) { ma_free(pDevice->coreaudio.pAudioBufferList, &pDevice->pContext->allocationCallbacks); } return MA_SUCCESS; } typedef struct { ma_bool32 allowNominalSampleRateChange; /* Input. */ ma_format formatIn; ma_uint32 channelsIn; ma_uint32 sampleRateIn; ma_channel channelMapIn[MA_MAX_CHANNELS]; ma_uint32 periodSizeInFramesIn; ma_uint32 periodSizeInMillisecondsIn; ma_uint32 periodsIn; ma_share_mode shareMode; ma_performance_profile performanceProfile; ma_bool32 registerStopEvent; /* Output. */ #if defined(MA_APPLE_DESKTOP) AudioObjectID deviceObjectID; #endif AudioComponent component; AudioUnit audioUnit; AudioBufferList* pAudioBufferList; /* Only used for input devices. */ ma_format formatOut; ma_uint32 channelsOut; ma_uint32 sampleRateOut; ma_channel channelMapOut[MA_MAX_CHANNELS]; ma_uint32 periodSizeInFramesOut; ma_uint32 periodsOut; char deviceName[256]; } ma_device_init_internal_data__coreaudio; static ma_result ma_device_init_internal__coreaudio(ma_context* pContext, ma_device_type deviceType, const ma_device_id* pDeviceID, ma_device_init_internal_data__coreaudio* pData, void* pDevice_DoNotReference) /* <-- pDevice is typed as void* intentionally so as to avoid accidentally referencing it. */ { ma_result result; OSStatus status; UInt32 enableIOFlag; AudioStreamBasicDescription bestFormat; UInt32 actualPeriodSizeInFrames; AURenderCallbackStruct callbackInfo; #if defined(MA_APPLE_DESKTOP) AudioObjectID deviceObjectID; #endif /* This API should only be used for a single device type: playback or capture. No full-duplex mode. */ if (deviceType == ma_device_type_duplex) { return MA_INVALID_ARGS; } MA_ASSERT(pContext != NULL); MA_ASSERT(deviceType == ma_device_type_playback || deviceType == ma_device_type_capture); #if defined(MA_APPLE_DESKTOP) pData->deviceObjectID = 0; #endif pData->component = NULL; pData->audioUnit = NULL; pData->pAudioBufferList = NULL; #if defined(MA_APPLE_DESKTOP) result = ma_find_AudioObjectID(pContext, deviceType, pDeviceID, &deviceObjectID); if (result != MA_SUCCESS) { return result; } pData->deviceObjectID = deviceObjectID; #endif /* Core audio doesn't really use the notion of a period so we can leave this unmodified, but not too over the top. */ pData->periodsOut = pData->periodsIn; if (pData->periodsOut == 0) { pData->periodsOut = MA_DEFAULT_PERIODS; } if (pData->periodsOut > 16) { pData->periodsOut = 16; } /* Audio unit. */ status = ((ma_AudioComponentInstanceNew_proc)pContext->coreaudio.AudioComponentInstanceNew)((AudioComponent)pContext->coreaudio.component, (AudioUnit*)&pData->audioUnit); if (status != noErr) { return ma_result_from_OSStatus(status); } /* The input/output buses need to be explicitly enabled and disabled. We set the flag based on the output unit first, then we just swap it for input. */ enableIOFlag = 1; if (deviceType == ma_device_type_capture) { enableIOFlag = 0; } status = ((ma_AudioUnitSetProperty_proc)pContext->coreaudio.AudioUnitSetProperty)(pData->audioUnit, kAudioOutputUnitProperty_EnableIO, kAudioUnitScope_Output, MA_COREAUDIO_OUTPUT_BUS, &enableIOFlag, sizeof(enableIOFlag)); if (status != noErr) { ((ma_AudioComponentInstanceDispose_proc)pContext->coreaudio.AudioComponentInstanceDispose)(pData->audioUnit); return ma_result_from_OSStatus(status); } enableIOFlag = (enableIOFlag == 0) ? 1 : 0; status = ((ma_AudioUnitSetProperty_proc)pContext->coreaudio.AudioUnitSetProperty)(pData->audioUnit, kAudioOutputUnitProperty_EnableIO, kAudioUnitScope_Input, MA_COREAUDIO_INPUT_BUS, &enableIOFlag, sizeof(enableIOFlag)); if (status != noErr) { ((ma_AudioComponentInstanceDispose_proc)pContext->coreaudio.AudioComponentInstanceDispose)(pData->audioUnit); return ma_result_from_OSStatus(status); } /* Set the device to use with this audio unit. This is only used on desktop since we are using defaults on mobile. */ #if defined(MA_APPLE_DESKTOP) status = ((ma_AudioUnitSetProperty_proc)pContext->coreaudio.AudioUnitSetProperty)(pData->audioUnit, kAudioOutputUnitProperty_CurrentDevice, kAudioUnitScope_Global, 0, &deviceObjectID, sizeof(deviceObjectID)); if (status != noErr) { ((ma_AudioComponentInstanceDispose_proc)pContext->coreaudio.AudioComponentInstanceDispose)(pData->audioUnit); return ma_result_from_OSStatus(result); } #else /* For some reason it looks like Apple is only allowing selection of the input device. There does not appear to be any way to change the default output route. I have no idea why this is like this, but for now we'll only be able to configure capture devices. */ if (pDeviceID != NULL) { if (deviceType == ma_device_type_capture) { ma_bool32 found = MA_FALSE; NSArray *pInputs = [[[AVAudioSession sharedInstance] currentRoute] inputs]; for (AVAudioSessionPortDescription* pPortDesc in pInputs) { if (strcmp(pDeviceID->coreaudio, [pPortDesc.UID UTF8String]) == 0) { [[AVAudioSession sharedInstance] setPreferredInput:pPortDesc error:nil]; found = MA_TRUE; break; } } if (found == MA_FALSE) { return MA_DOES_NOT_EXIST; } } } #endif /* Format. This is the hardest part of initialization because there's a few variables to take into account. 1) The format must be supported by the device. 2) The format must be supported miniaudio. 3) There's a priority that miniaudio prefers. Ideally we would like to use a format that's as close to the hardware as possible so we can get as close to a passthrough as possible. The most important property is the sample rate. miniaudio can do format conversion for any sample rate and channel count, but cannot do the same for the sample data format. If the sample data format is not supported by miniaudio it must be ignored completely. On mobile platforms this is a bit different. We just force the use of whatever the audio unit's current format is set to. */ { AudioStreamBasicDescription origFormat; UInt32 origFormatSize = sizeof(origFormat); AudioUnitScope formatScope = (deviceType == ma_device_type_playback) ? kAudioUnitScope_Input : kAudioUnitScope_Output; AudioUnitElement formatElement = (deviceType == ma_device_type_playback) ? MA_COREAUDIO_OUTPUT_BUS : MA_COREAUDIO_INPUT_BUS; if (deviceType == ma_device_type_playback) { status = ((ma_AudioUnitGetProperty_proc)pContext->coreaudio.AudioUnitGetProperty)(pData->audioUnit, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Output, MA_COREAUDIO_OUTPUT_BUS, &origFormat, &origFormatSize); } else { status = ((ma_AudioUnitGetProperty_proc)pContext->coreaudio.AudioUnitGetProperty)(pData->audioUnit, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Input, MA_COREAUDIO_INPUT_BUS, &origFormat, &origFormatSize); } if (status != noErr) { ((ma_AudioComponentInstanceDispose_proc)pContext->coreaudio.AudioComponentInstanceDispose)(pData->audioUnit); return ma_result_from_OSStatus(status); } #if defined(MA_APPLE_DESKTOP) result = ma_find_best_format__coreaudio(pContext, deviceObjectID, deviceType, pData->formatIn, pData->channelsIn, pData->sampleRateIn, &origFormat, &bestFormat); if (result != MA_SUCCESS) { ((ma_AudioComponentInstanceDispose_proc)pContext->coreaudio.AudioComponentInstanceDispose)(pData->audioUnit); return result; } /* Technical Note TN2091: Device input using the HAL Output Audio Unit https://developer.apple.com/library/archive/technotes/tn2091/_index.html This documentation says the following: The internal AudioConverter can handle any *simple* conversion. Typically, this means that a client can specify ANY variant of the PCM formats. Consequently, the device's sample rate should match the desired sample rate. If sample rate conversion is needed, it can be accomplished by buffering the input and converting the data on a separate thread with another AudioConverter. The important part here is the mention that it can handle *simple* conversions, which does *not* include sample rate. We therefore want to ensure the sample rate stays consistent. This document is specifically for input, but I'm going to play it safe and apply the same rule to output as well. I have tried going against the documentation by setting the sample rate anyway, but this just results in AudioUnitRender() returning a result code of -10863. I have also tried changing the format directly on the input scope on the input bus, but this just results in `ca_require: IsStreamFormatWritable(inScope, inElement) NotWritable` when trying to set the format. Something that does seem to work, however, has been setting the nominal sample rate on the deivce object. The problem with this, however, is that it actually changes the sample rate at the operating system level and not just the application. This could be intrusive to the user, however, so I don't think it's wise to make this the default. Instead I'm making this a configuration option. When the `coreaudio.allowNominalSampleRateChange` config option is set to true, changing the sample rate will be allowed. Otherwise it'll be fixed to the current sample rate. To check the system-defined sample rate, run the Audio MIDI Setup program that comes installed on macOS and observe how the sample rate changes as the sample rate is changed by miniaudio. */ if (pData->allowNominalSampleRateChange) { AudioValueRange sampleRateRange; AudioObjectPropertyAddress propAddress; sampleRateRange.mMinimum = bestFormat.mSampleRate; sampleRateRange.mMaximum = bestFormat.mSampleRate; propAddress.mSelector = kAudioDevicePropertyNominalSampleRate; propAddress.mScope = (deviceType == ma_device_type_playback) ? kAudioObjectPropertyScopeOutput : kAudioObjectPropertyScopeInput; propAddress.mElement = AUDIO_OBJECT_PROPERTY_ELEMENT; status = ((ma_AudioObjectSetPropertyData_proc)pContext->coreaudio.AudioObjectSetPropertyData)(deviceObjectID, &propAddress, 0, NULL, sizeof(sampleRateRange), &sampleRateRange); if (status != noErr) { bestFormat.mSampleRate = origFormat.mSampleRate; } } else { bestFormat.mSampleRate = origFormat.mSampleRate; } status = ((ma_AudioUnitSetProperty_proc)pContext->coreaudio.AudioUnitSetProperty)(pData->audioUnit, kAudioUnitProperty_StreamFormat, formatScope, formatElement, &bestFormat, sizeof(bestFormat)); if (status != noErr) { /* We failed to set the format, so fall back to the current format of the audio unit. */ bestFormat = origFormat; } #else bestFormat = origFormat; /* Sample rate is a little different here because for some reason kAudioUnitProperty_StreamFormat returns 0... Oh well. We need to instead try setting the sample rate to what the user has requested and then just see the results of it. Need to use some Objective-C here for this since it depends on Apple's AVAudioSession API. To do this we just get the shared AVAudioSession instance and then set it. Note that from what I can tell, it looks like the sample rate is shared between playback and capture for everything. */ @autoreleasepool { AVAudioSession* pAudioSession = [AVAudioSession sharedInstance]; MA_ASSERT(pAudioSession != NULL); [pAudioSession setPreferredSampleRate:(double)pData->sampleRateIn error:nil]; bestFormat.mSampleRate = pAudioSession.sampleRate; /* I've had a report that the channel count returned by AudioUnitGetProperty above is inconsistent with AVAudioSession outputNumberOfChannels. I'm going to try using the AVAudioSession values instead. */ if (deviceType == ma_device_type_playback) { bestFormat.mChannelsPerFrame = (UInt32)pAudioSession.outputNumberOfChannels; } if (deviceType == ma_device_type_capture) { bestFormat.mChannelsPerFrame = (UInt32)pAudioSession.inputNumberOfChannels; } } status = ((ma_AudioUnitSetProperty_proc)pContext->coreaudio.AudioUnitSetProperty)(pData->audioUnit, kAudioUnitProperty_StreamFormat, formatScope, formatElement, &bestFormat, sizeof(bestFormat)); if (status != noErr) { ((ma_AudioComponentInstanceDispose_proc)pContext->coreaudio.AudioComponentInstanceDispose)(pData->audioUnit); return ma_result_from_OSStatus(status); } #endif result = ma_format_from_AudioStreamBasicDescription(&bestFormat, &pData->formatOut); if (result != MA_SUCCESS) { ((ma_AudioComponentInstanceDispose_proc)pContext->coreaudio.AudioComponentInstanceDispose)(pData->audioUnit); return result; } if (pData->formatOut == ma_format_unknown) { ((ma_AudioComponentInstanceDispose_proc)pContext->coreaudio.AudioComponentInstanceDispose)(pData->audioUnit); return MA_FORMAT_NOT_SUPPORTED; } pData->channelsOut = bestFormat.mChannelsPerFrame; pData->sampleRateOut = (ma_uint32)(bestFormat.mSampleRate); } /* Clamp the channel count for safety. */ if (pData->channelsOut > MA_MAX_CHANNELS) { pData->channelsOut = MA_MAX_CHANNELS; } /* Internal channel map. This is weird in my testing. If I use the AudioObject to get the channel map, the channel descriptions are set to "Unknown" for some reason. To work around this it looks like retrieving it from the AudioUnit will work. However, and this is where it gets weird, it doesn't seem to work with capture devices, nor at all on iOS... Therefore I'm going to fall back to a default assumption in these cases. */ #if defined(MA_APPLE_DESKTOP) result = ma_get_AudioUnit_channel_map(pContext, pData->audioUnit, deviceType, pData->channelMapOut, pData->channelsOut); if (result != MA_SUCCESS) { #if 0 /* Try falling back to the channel map from the AudioObject. */ result = ma_get_AudioObject_channel_map(pContext, deviceObjectID, deviceType, pData->channelMapOut, pData->channelsOut); if (result != MA_SUCCESS) { return result; } #else /* Fall back to default assumptions. */ ma_channel_map_init_standard(ma_standard_channel_map_default, pData->channelMapOut, ma_countof(pData->channelMapOut), pData->channelsOut); #endif } #else /* TODO: Figure out how to get the channel map using AVAudioSession. */ ma_channel_map_init_standard(ma_standard_channel_map_default, pData->channelMapOut, ma_countof(pData->channelMapOut), pData->channelsOut); #endif /* Buffer size. Not allowing this to be configurable on iOS. */ if (pData->periodSizeInFramesIn == 0) { if (pData->periodSizeInMillisecondsIn == 0) { if (pData->performanceProfile == ma_performance_profile_low_latency) { actualPeriodSizeInFrames = ma_calculate_buffer_size_in_frames_from_milliseconds(MA_DEFAULT_PERIOD_SIZE_IN_MILLISECONDS_LOW_LATENCY, pData->sampleRateOut); } else { actualPeriodSizeInFrames = ma_calculate_buffer_size_in_frames_from_milliseconds(MA_DEFAULT_PERIOD_SIZE_IN_MILLISECONDS_CONSERVATIVE, pData->sampleRateOut); } } else { actualPeriodSizeInFrames = ma_calculate_buffer_size_in_frames_from_milliseconds(pData->periodSizeInMillisecondsIn, pData->sampleRateOut); } } else { actualPeriodSizeInFrames = pData->periodSizeInFramesIn; } #if defined(MA_APPLE_DESKTOP) result = ma_set_AudioObject_buffer_size_in_frames(pContext, deviceObjectID, deviceType, &actualPeriodSizeInFrames); if (result != MA_SUCCESS) { return result; } #else /* On iOS, the size of the IO buffer needs to be specified in seconds and is a floating point number. I don't trust any potential truncation errors due to converting from float to integer so I'm going to explicitly set the actual period size to the next power of 2. */ @autoreleasepool { AVAudioSession* pAudioSession = [AVAudioSession sharedInstance]; MA_ASSERT(pAudioSession != NULL); [pAudioSession setPreferredIOBufferDuration:((float)actualPeriodSizeInFrames / pAudioSession.sampleRate) error:nil]; actualPeriodSizeInFrames = ma_next_power_of_2((ma_uint32)(pAudioSession.IOBufferDuration * pAudioSession.sampleRate)); } #endif /* During testing I discovered that the buffer size can be too big. You'll get an error like this: kAudioUnitErr_TooManyFramesToProcess : inFramesToProcess=4096, mMaxFramesPerSlice=512 Note how inFramesToProcess is smaller than mMaxFramesPerSlice. To fix, we need to set kAudioUnitProperty_MaximumFramesPerSlice to that of the size of our buffer, or do it the other way around and set our buffer size to the kAudioUnitProperty_MaximumFramesPerSlice. */ status = ((ma_AudioUnitSetProperty_proc)pContext->coreaudio.AudioUnitSetProperty)(pData->audioUnit, kAudioUnitProperty_MaximumFramesPerSlice, kAudioUnitScope_Global, 0, &actualPeriodSizeInFrames, sizeof(actualPeriodSizeInFrames)); if (status != noErr) { ((ma_AudioComponentInstanceDispose_proc)pContext->coreaudio.AudioComponentInstanceDispose)(pData->audioUnit); return ma_result_from_OSStatus(status); } pData->periodSizeInFramesOut = (ma_uint32)actualPeriodSizeInFrames; /* We need a buffer list if this is an input device. We render into this in the input callback. */ if (deviceType == ma_device_type_capture) { ma_bool32 isInterleaved = (bestFormat.mFormatFlags & kAudioFormatFlagIsNonInterleaved) == 0; AudioBufferList* pBufferList; pBufferList = ma_allocate_AudioBufferList__coreaudio(pData->periodSizeInFramesOut, pData->formatOut, pData->channelsOut, (isInterleaved) ? ma_stream_layout_interleaved : ma_stream_layout_deinterleaved, &pContext->allocationCallbacks); if (pBufferList == NULL) { ((ma_AudioComponentInstanceDispose_proc)pContext->coreaudio.AudioComponentInstanceDispose)(pData->audioUnit); return MA_OUT_OF_MEMORY; } pData->pAudioBufferList = pBufferList; } /* Callbacks. */ callbackInfo.inputProcRefCon = pDevice_DoNotReference; if (deviceType == ma_device_type_playback) { callbackInfo.inputProc = ma_on_output__coreaudio; status = ((ma_AudioUnitSetProperty_proc)pContext->coreaudio.AudioUnitSetProperty)(pData->audioUnit, kAudioUnitProperty_SetRenderCallback, kAudioUnitScope_Global, 0, &callbackInfo, sizeof(callbackInfo)); if (status != noErr) { ((ma_AudioComponentInstanceDispose_proc)pContext->coreaudio.AudioComponentInstanceDispose)(pData->audioUnit); return ma_result_from_OSStatus(status); } } else { callbackInfo.inputProc = ma_on_input__coreaudio; status = ((ma_AudioUnitSetProperty_proc)pContext->coreaudio.AudioUnitSetProperty)(pData->audioUnit, kAudioOutputUnitProperty_SetInputCallback, kAudioUnitScope_Global, 0, &callbackInfo, sizeof(callbackInfo)); if (status != noErr) { ((ma_AudioComponentInstanceDispose_proc)pContext->coreaudio.AudioComponentInstanceDispose)(pData->audioUnit); return ma_result_from_OSStatus(status); } } /* We need to listen for stop events. */ if (pData->registerStopEvent) { status = ((ma_AudioUnitAddPropertyListener_proc)pContext->coreaudio.AudioUnitAddPropertyListener)(pData->audioUnit, kAudioOutputUnitProperty_IsRunning, on_start_stop__coreaudio, pDevice_DoNotReference); if (status != noErr) { ((ma_AudioComponentInstanceDispose_proc)pContext->coreaudio.AudioComponentInstanceDispose)(pData->audioUnit); return ma_result_from_OSStatus(status); } } /* Initialize the audio unit. */ status = ((ma_AudioUnitInitialize_proc)pContext->coreaudio.AudioUnitInitialize)(pData->audioUnit); if (status != noErr) { ma_free(pData->pAudioBufferList, &pContext->allocationCallbacks); pData->pAudioBufferList = NULL; ((ma_AudioComponentInstanceDispose_proc)pContext->coreaudio.AudioComponentInstanceDispose)(pData->audioUnit); return ma_result_from_OSStatus(status); } /* Grab the name. */ #if defined(MA_APPLE_DESKTOP) ma_get_AudioObject_name(pContext, deviceObjectID, sizeof(pData->deviceName), pData->deviceName); #else if (deviceType == ma_device_type_playback) { ma_strcpy_s(pData->deviceName, sizeof(pData->deviceName), MA_DEFAULT_PLAYBACK_DEVICE_NAME); } else { ma_strcpy_s(pData->deviceName, sizeof(pData->deviceName), MA_DEFAULT_CAPTURE_DEVICE_NAME); } #endif return result; } #if defined(MA_APPLE_DESKTOP) static ma_result ma_device_reinit_internal__coreaudio(ma_device* pDevice, ma_device_type deviceType, ma_bool32 disposePreviousAudioUnit) { ma_device_init_internal_data__coreaudio data; ma_result result; /* This should only be called for playback or capture, not duplex. */ if (deviceType == ma_device_type_duplex) { return MA_INVALID_ARGS; } data.allowNominalSampleRateChange = MA_FALSE; /* Don't change the nominal sample rate when switching devices. */ if (deviceType == ma_device_type_capture) { data.formatIn = pDevice->capture.format; data.channelsIn = pDevice->capture.channels; data.sampleRateIn = pDevice->sampleRate; MA_COPY_MEMORY(data.channelMapIn, pDevice->capture.channelMap, sizeof(pDevice->capture.channelMap)); data.shareMode = pDevice->capture.shareMode; data.performanceProfile = pDevice->coreaudio.originalPerformanceProfile; data.registerStopEvent = MA_TRUE; if (disposePreviousAudioUnit) { ((ma_AudioOutputUnitStop_proc)pDevice->pContext->coreaudio.AudioOutputUnitStop)((AudioUnit)pDevice->coreaudio.audioUnitCapture); ((ma_AudioComponentInstanceDispose_proc)pDevice->pContext->coreaudio.AudioComponentInstanceDispose)((AudioUnit)pDevice->coreaudio.audioUnitCapture); } if (pDevice->coreaudio.pAudioBufferList) { ma_free(pDevice->coreaudio.pAudioBufferList, &pDevice->pContext->allocationCallbacks); } } else if (deviceType == ma_device_type_playback) { data.formatIn = pDevice->playback.format; data.channelsIn = pDevice->playback.channels; data.sampleRateIn = pDevice->sampleRate; MA_COPY_MEMORY(data.channelMapIn, pDevice->playback.channelMap, sizeof(pDevice->playback.channelMap)); data.shareMode = pDevice->playback.shareMode; data.performanceProfile = pDevice->coreaudio.originalPerformanceProfile; data.registerStopEvent = (pDevice->type != ma_device_type_duplex); if (disposePreviousAudioUnit) { ((ma_AudioOutputUnitStop_proc)pDevice->pContext->coreaudio.AudioOutputUnitStop)((AudioUnit)pDevice->coreaudio.audioUnitPlayback); ((ma_AudioComponentInstanceDispose_proc)pDevice->pContext->coreaudio.AudioComponentInstanceDispose)((AudioUnit)pDevice->coreaudio.audioUnitPlayback); } } data.periodSizeInFramesIn = pDevice->coreaudio.originalPeriodSizeInFrames; data.periodSizeInMillisecondsIn = pDevice->coreaudio.originalPeriodSizeInMilliseconds; data.periodsIn = pDevice->coreaudio.originalPeriods; /* Need at least 3 periods for duplex. */ if (data.periodsIn < 3 && pDevice->type == ma_device_type_duplex) { data.periodsIn = 3; } result = ma_device_init_internal__coreaudio(pDevice->pContext, deviceType, NULL, &data, (void*)pDevice); if (result != MA_SUCCESS) { return result; } if (deviceType == ma_device_type_capture) { #if defined(MA_APPLE_DESKTOP) pDevice->coreaudio.deviceObjectIDCapture = (ma_uint32)data.deviceObjectID; ma_get_AudioObject_uid(pDevice->pContext, pDevice->coreaudio.deviceObjectIDCapture, sizeof(pDevice->capture.id.coreaudio), pDevice->capture.id.coreaudio); #endif pDevice->coreaudio.audioUnitCapture = (ma_ptr)data.audioUnit; pDevice->coreaudio.pAudioBufferList = (ma_ptr)data.pAudioBufferList; pDevice->coreaudio.audioBufferCapInFrames = data.periodSizeInFramesOut; pDevice->capture.internalFormat = data.formatOut; pDevice->capture.internalChannels = data.channelsOut; pDevice->capture.internalSampleRate = data.sampleRateOut; MA_COPY_MEMORY(pDevice->capture.internalChannelMap, data.channelMapOut, sizeof(data.channelMapOut)); pDevice->capture.internalPeriodSizeInFrames = data.periodSizeInFramesOut; pDevice->capture.internalPeriods = data.periodsOut; } else if (deviceType == ma_device_type_playback) { #if defined(MA_APPLE_DESKTOP) pDevice->coreaudio.deviceObjectIDPlayback = (ma_uint32)data.deviceObjectID; ma_get_AudioObject_uid(pDevice->pContext, pDevice->coreaudio.deviceObjectIDPlayback, sizeof(pDevice->playback.id.coreaudio), pDevice->playback.id.coreaudio); #endif pDevice->coreaudio.audioUnitPlayback = (ma_ptr)data.audioUnit; pDevice->playback.internalFormat = data.formatOut; pDevice->playback.internalChannels = data.channelsOut; pDevice->playback.internalSampleRate = data.sampleRateOut; MA_COPY_MEMORY(pDevice->playback.internalChannelMap, data.channelMapOut, sizeof(data.channelMapOut)); pDevice->playback.internalPeriodSizeInFrames = data.periodSizeInFramesOut; pDevice->playback.internalPeriods = data.periodsOut; } return MA_SUCCESS; } #endif /* MA_APPLE_DESKTOP */ static ma_result ma_device_init__coreaudio(ma_device* pDevice, const ma_device_config* pConfig, ma_device_descriptor* pDescriptorPlayback, ma_device_descriptor* pDescriptorCapture) { ma_result result; MA_ASSERT(pDevice != NULL); MA_ASSERT(pConfig != NULL); if (pConfig->deviceType == ma_device_type_loopback) { return MA_DEVICE_TYPE_NOT_SUPPORTED; } /* No exclusive mode with the Core Audio backend for now. */ if (((pConfig->deviceType == ma_device_type_capture || pConfig->deviceType == ma_device_type_duplex) && pDescriptorCapture->shareMode == ma_share_mode_exclusive) || ((pConfig->deviceType == ma_device_type_playback || pConfig->deviceType == ma_device_type_duplex) && pDescriptorPlayback->shareMode == ma_share_mode_exclusive)) { return MA_SHARE_MODE_NOT_SUPPORTED; } /* Capture needs to be initialized first. */ if (pConfig->deviceType == ma_device_type_capture || pConfig->deviceType == ma_device_type_duplex) { ma_device_init_internal_data__coreaudio data; data.allowNominalSampleRateChange = pConfig->coreaudio.allowNominalSampleRateChange; data.formatIn = pDescriptorCapture->format; data.channelsIn = pDescriptorCapture->channels; data.sampleRateIn = pDescriptorCapture->sampleRate; MA_COPY_MEMORY(data.channelMapIn, pDescriptorCapture->channelMap, sizeof(pDescriptorCapture->channelMap)); data.periodSizeInFramesIn = pDescriptorCapture->periodSizeInFrames; data.periodSizeInMillisecondsIn = pDescriptorCapture->periodSizeInMilliseconds; data.periodsIn = pDescriptorCapture->periodCount; data.shareMode = pDescriptorCapture->shareMode; data.performanceProfile = pConfig->performanceProfile; data.registerStopEvent = MA_TRUE; /* Need at least 3 periods for duplex. */ if (data.periodsIn < 3 && pConfig->deviceType == ma_device_type_duplex) { data.periodsIn = 3; } result = ma_device_init_internal__coreaudio(pDevice->pContext, ma_device_type_capture, pDescriptorCapture->pDeviceID, &data, (void*)pDevice); if (result != MA_SUCCESS) { return result; } pDevice->coreaudio.isDefaultCaptureDevice = (pConfig->capture.pDeviceID == NULL); #if defined(MA_APPLE_DESKTOP) pDevice->coreaudio.deviceObjectIDCapture = (ma_uint32)data.deviceObjectID; #endif pDevice->coreaudio.audioUnitCapture = (ma_ptr)data.audioUnit; pDevice->coreaudio.pAudioBufferList = (ma_ptr)data.pAudioBufferList; pDevice->coreaudio.audioBufferCapInFrames = data.periodSizeInFramesOut; pDevice->coreaudio.originalPeriodSizeInFrames = pDescriptorCapture->periodSizeInFrames; pDevice->coreaudio.originalPeriodSizeInMilliseconds = pDescriptorCapture->periodSizeInMilliseconds; pDevice->coreaudio.originalPeriods = pDescriptorCapture->periodCount; pDevice->coreaudio.originalPerformanceProfile = pConfig->performanceProfile; pDescriptorCapture->format = data.formatOut; pDescriptorCapture->channels = data.channelsOut; pDescriptorCapture->sampleRate = data.sampleRateOut; MA_COPY_MEMORY(pDescriptorCapture->channelMap, data.channelMapOut, sizeof(data.channelMapOut)); pDescriptorCapture->periodSizeInFrames = data.periodSizeInFramesOut; pDescriptorCapture->periodCount = data.periodsOut; #if defined(MA_APPLE_DESKTOP) ma_get_AudioObject_uid(pDevice->pContext, pDevice->coreaudio.deviceObjectIDCapture, sizeof(pDevice->capture.id.coreaudio), pDevice->capture.id.coreaudio); /* If we are using the default device we'll need to listen for changes to the system's default device so we can seemlessly switch the device in the background. */ if (pConfig->capture.pDeviceID == NULL) { ma_device__track__coreaudio(pDevice); } #endif } /* Playback. */ if (pConfig->deviceType == ma_device_type_playback || pConfig->deviceType == ma_device_type_duplex) { ma_device_init_internal_data__coreaudio data; data.allowNominalSampleRateChange = pConfig->coreaudio.allowNominalSampleRateChange; data.formatIn = pDescriptorPlayback->format; data.channelsIn = pDescriptorPlayback->channels; data.sampleRateIn = pDescriptorPlayback->sampleRate; MA_COPY_MEMORY(data.channelMapIn, pDescriptorPlayback->channelMap, sizeof(pDescriptorPlayback->channelMap)); data.shareMode = pDescriptorPlayback->shareMode; data.performanceProfile = pConfig->performanceProfile; /* In full-duplex mode we want the playback buffer to be the same size as the capture buffer. */ if (pConfig->deviceType == ma_device_type_duplex) { data.periodSizeInFramesIn = pDescriptorCapture->periodSizeInFrames; data.periodsIn = pDescriptorCapture->periodCount; data.registerStopEvent = MA_FALSE; } else { data.periodSizeInFramesIn = pDescriptorPlayback->periodSizeInFrames; data.periodSizeInMillisecondsIn = pDescriptorPlayback->periodSizeInMilliseconds; data.periodsIn = pDescriptorPlayback->periodCount; data.registerStopEvent = MA_TRUE; } result = ma_device_init_internal__coreaudio(pDevice->pContext, ma_device_type_playback, pDescriptorPlayback->pDeviceID, &data, (void*)pDevice); if (result != MA_SUCCESS) { if (pConfig->deviceType == ma_device_type_duplex) { ((ma_AudioComponentInstanceDispose_proc)pDevice->pContext->coreaudio.AudioComponentInstanceDispose)((AudioUnit)pDevice->coreaudio.audioUnitCapture); if (pDevice->coreaudio.pAudioBufferList) { ma_free(pDevice->coreaudio.pAudioBufferList, &pDevice->pContext->allocationCallbacks); } } return result; } pDevice->coreaudio.isDefaultPlaybackDevice = (pConfig->playback.pDeviceID == NULL); #if defined(MA_APPLE_DESKTOP) pDevice->coreaudio.deviceObjectIDPlayback = (ma_uint32)data.deviceObjectID; #endif pDevice->coreaudio.audioUnitPlayback = (ma_ptr)data.audioUnit; pDevice->coreaudio.originalPeriodSizeInFrames = pDescriptorPlayback->periodSizeInFrames; pDevice->coreaudio.originalPeriodSizeInMilliseconds = pDescriptorPlayback->periodSizeInMilliseconds; pDevice->coreaudio.originalPeriods = pDescriptorPlayback->periodCount; pDevice->coreaudio.originalPerformanceProfile = pConfig->performanceProfile; pDescriptorPlayback->format = data.formatOut; pDescriptorPlayback->channels = data.channelsOut; pDescriptorPlayback->sampleRate = data.sampleRateOut; MA_COPY_MEMORY(pDescriptorPlayback->channelMap, data.channelMapOut, sizeof(data.channelMapOut)); pDescriptorPlayback->periodSizeInFrames = data.periodSizeInFramesOut; pDescriptorPlayback->periodCount = data.periodsOut; #if defined(MA_APPLE_DESKTOP) ma_get_AudioObject_uid(pDevice->pContext, pDevice->coreaudio.deviceObjectIDPlayback, sizeof(pDevice->playback.id.coreaudio), pDevice->playback.id.coreaudio); /* If we are using the default device we'll need to listen for changes to the system's default device so we can seemlessly switch the device in the background. */ if (pDescriptorPlayback->pDeviceID == NULL && (pConfig->deviceType != ma_device_type_duplex || pDescriptorCapture->pDeviceID != NULL)) { ma_device__track__coreaudio(pDevice); } #endif } /* When stopping the device, a callback is called on another thread. We need to wait for this callback before returning from ma_device_stop(). This event is used for this. */ ma_event_init(&pDevice->coreaudio.stopEvent); /* We need to detect when a route has changed so we can update the data conversion pipeline accordingly. This is done differently on non-Desktop Apple platforms. */ #if defined(MA_APPLE_MOBILE) pDevice->coreaudio.pNotificationHandler = (MA_BRIDGE_RETAINED void*)[[ma_ios_notification_handler alloc] init:pDevice]; #endif return MA_SUCCESS; } static ma_result ma_device_start__coreaudio(ma_device* pDevice) { MA_ASSERT(pDevice != NULL); if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) { OSStatus status = ((ma_AudioOutputUnitStart_proc)pDevice->pContext->coreaudio.AudioOutputUnitStart)((AudioUnit)pDevice->coreaudio.audioUnitCapture); if (status != noErr) { return ma_result_from_OSStatus(status); } } if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) { OSStatus status = ((ma_AudioOutputUnitStart_proc)pDevice->pContext->coreaudio.AudioOutputUnitStart)((AudioUnit)pDevice->coreaudio.audioUnitPlayback); if (status != noErr) { if (pDevice->type == ma_device_type_duplex) { ((ma_AudioOutputUnitStop_proc)pDevice->pContext->coreaudio.AudioOutputUnitStop)((AudioUnit)pDevice->coreaudio.audioUnitCapture); } return ma_result_from_OSStatus(status); } } return MA_SUCCESS; } static ma_result ma_device_stop__coreaudio(ma_device* pDevice) { MA_ASSERT(pDevice != NULL); /* It's not clear from the documentation whether or not AudioOutputUnitStop() actually drains the device or not. */ if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) { OSStatus status = ((ma_AudioOutputUnitStop_proc)pDevice->pContext->coreaudio.AudioOutputUnitStop)((AudioUnit)pDevice->coreaudio.audioUnitCapture); if (status != noErr) { return ma_result_from_OSStatus(status); } } if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) { OSStatus status = ((ma_AudioOutputUnitStop_proc)pDevice->pContext->coreaudio.AudioOutputUnitStop)((AudioUnit)pDevice->coreaudio.audioUnitPlayback); if (status != noErr) { return ma_result_from_OSStatus(status); } } /* We need to wait for the callback to finish before returning. */ ma_event_wait(&pDevice->coreaudio.stopEvent); return MA_SUCCESS; } static ma_result ma_context_uninit__coreaudio(ma_context* pContext) { MA_ASSERT(pContext != NULL); MA_ASSERT(pContext->backend == ma_backend_coreaudio); #if defined(MA_APPLE_MOBILE) if (!pContext->coreaudio.noAudioSessionDeactivate) { if (![[AVAudioSession sharedInstance] setActive:false error:nil]) { ma_log_postf(ma_context_get_log(pContext), MA_LOG_LEVEL_ERROR, "Failed to deactivate audio session."); return MA_FAILED_TO_INIT_BACKEND; } } #endif #if !defined(MA_NO_RUNTIME_LINKING) && !defined(MA_APPLE_MOBILE) ma_dlclose(ma_context_get_log(pContext), pContext->coreaudio.hAudioUnit); ma_dlclose(ma_context_get_log(pContext), pContext->coreaudio.hCoreAudio); ma_dlclose(ma_context_get_log(pContext), pContext->coreaudio.hCoreFoundation); #endif #if !defined(MA_APPLE_MOBILE) ma_context__uninit_device_tracking__coreaudio(pContext); #endif (void)pContext; return MA_SUCCESS; } #if defined(MA_APPLE_MOBILE) && defined(__IPHONE_12_0) static AVAudioSessionCategory ma_to_AVAudioSessionCategory(ma_ios_session_category category) { /* The "default" and "none" categories are treated different and should not be used as an input into this function. */ MA_ASSERT(category != ma_ios_session_category_default); MA_ASSERT(category != ma_ios_session_category_none); switch (category) { case ma_ios_session_category_ambient: return AVAudioSessionCategoryAmbient; case ma_ios_session_category_solo_ambient: return AVAudioSessionCategorySoloAmbient; case ma_ios_session_category_playback: return AVAudioSessionCategoryPlayback; case ma_ios_session_category_record: return AVAudioSessionCategoryRecord; case ma_ios_session_category_play_and_record: return AVAudioSessionCategoryPlayAndRecord; case ma_ios_session_category_multi_route: return AVAudioSessionCategoryMultiRoute; case ma_ios_session_category_none: return AVAudioSessionCategoryAmbient; case ma_ios_session_category_default: return AVAudioSessionCategoryAmbient; default: return AVAudioSessionCategoryAmbient; } } #endif static ma_result ma_context_init__coreaudio(ma_context* pContext, const ma_context_config* pConfig, ma_backend_callbacks* pCallbacks) { #if !defined(MA_APPLE_MOBILE) ma_result result; #endif MA_ASSERT(pConfig != NULL); MA_ASSERT(pContext != NULL); #if defined(MA_APPLE_MOBILE) @autoreleasepool { AVAudioSession* pAudioSession = [AVAudioSession sharedInstance]; AVAudioSessionCategoryOptions options = pConfig->coreaudio.sessionCategoryOptions; MA_ASSERT(pAudioSession != NULL); if (pConfig->coreaudio.sessionCategory == ma_ios_session_category_default) { /* I'm going to use trial and error to determine our default session category. First we'll try PlayAndRecord. If that fails we'll try Playback and if that fails we'll try record. If all of these fail we'll just not set the category. */ #if !defined(MA_APPLE_TV) && !defined(MA_APPLE_WATCH) options |= AVAudioSessionCategoryOptionDefaultToSpeaker; #endif if ([pAudioSession setCategory: AVAudioSessionCategoryPlayAndRecord withOptions:options error:nil]) { /* Using PlayAndRecord */ } else if ([pAudioSession setCategory: AVAudioSessionCategoryPlayback withOptions:options error:nil]) { /* Using Playback */ } else if ([pAudioSession setCategory: AVAudioSessionCategoryRecord withOptions:options error:nil]) { /* Using Record */ } else { /* Leave as default? */ } } else { if (pConfig->coreaudio.sessionCategory != ma_ios_session_category_none) { #if defined(__IPHONE_12_0) if (![pAudioSession setCategory: ma_to_AVAudioSessionCategory(pConfig->coreaudio.sessionCategory) withOptions:options error:nil]) { return MA_INVALID_OPERATION; /* Failed to set session category. */ } #else /* Ignore the session category on version 11 and older, but post a warning. */ ma_log_postf(ma_context_get_log(pContext), MA_LOG_LEVEL_WARNING, "Session category only supported in iOS 12 and newer."); #endif } } if (!pConfig->coreaudio.noAudioSessionActivate) { if (![pAudioSession setActive:true error:nil]) { ma_log_postf(ma_context_get_log(pContext), MA_LOG_LEVEL_ERROR, "Failed to activate audio session."); return MA_FAILED_TO_INIT_BACKEND; } } } #endif #if !defined(MA_NO_RUNTIME_LINKING) && !defined(MA_APPLE_MOBILE) pContext->coreaudio.hCoreFoundation = ma_dlopen(ma_context_get_log(pContext), "/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation"); if (pContext->coreaudio.hCoreFoundation == NULL) { return MA_API_NOT_FOUND; } pContext->coreaudio.CFStringGetCString = ma_dlsym(ma_context_get_log(pContext), pContext->coreaudio.hCoreFoundation, "CFStringGetCString"); pContext->coreaudio.CFRelease = ma_dlsym(ma_context_get_log(pContext), pContext->coreaudio.hCoreFoundation, "CFRelease"); pContext->coreaudio.hCoreAudio = ma_dlopen(ma_context_get_log(pContext), "/System/Library/Frameworks/CoreAudio.framework/CoreAudio"); if (pContext->coreaudio.hCoreAudio == NULL) { ma_dlclose(ma_context_get_log(pContext), pContext->coreaudio.hCoreFoundation); return MA_API_NOT_FOUND; } pContext->coreaudio.AudioObjectGetPropertyData = ma_dlsym(ma_context_get_log(pContext), pContext->coreaudio.hCoreAudio, "AudioObjectGetPropertyData"); pContext->coreaudio.AudioObjectGetPropertyDataSize = ma_dlsym(ma_context_get_log(pContext), pContext->coreaudio.hCoreAudio, "AudioObjectGetPropertyDataSize"); pContext->coreaudio.AudioObjectSetPropertyData = ma_dlsym(ma_context_get_log(pContext), pContext->coreaudio.hCoreAudio, "AudioObjectSetPropertyData"); pContext->coreaudio.AudioObjectAddPropertyListener = ma_dlsym(ma_context_get_log(pContext), pContext->coreaudio.hCoreAudio, "AudioObjectAddPropertyListener"); pContext->coreaudio.AudioObjectRemovePropertyListener = ma_dlsym(ma_context_get_log(pContext), pContext->coreaudio.hCoreAudio, "AudioObjectRemovePropertyListener"); /* It looks like Apple has moved some APIs from AudioUnit into AudioToolbox on more recent versions of macOS. They are still defined in AudioUnit, but just in case they decide to remove them from there entirely I'm going to implement a fallback. The way it'll work is that it'll first try AudioUnit, and if the required symbols are not present there we'll fall back to AudioToolbox. */ pContext->coreaudio.hAudioUnit = ma_dlopen(ma_context_get_log(pContext), "/System/Library/Frameworks/AudioUnit.framework/AudioUnit"); if (pContext->coreaudio.hAudioUnit == NULL) { ma_dlclose(ma_context_get_log(pContext), pContext->coreaudio.hCoreAudio); ma_dlclose(ma_context_get_log(pContext), pContext->coreaudio.hCoreFoundation); return MA_API_NOT_FOUND; } if (ma_dlsym(ma_context_get_log(pContext), pContext->coreaudio.hAudioUnit, "AudioComponentFindNext") == NULL) { /* Couldn't find the required symbols in AudioUnit, so fall back to AudioToolbox. */ ma_dlclose(ma_context_get_log(pContext), pContext->coreaudio.hAudioUnit); pContext->coreaudio.hAudioUnit = ma_dlopen(ma_context_get_log(pContext), "/System/Library/Frameworks/AudioToolbox.framework/AudioToolbox"); if (pContext->coreaudio.hAudioUnit == NULL) { ma_dlclose(ma_context_get_log(pContext), pContext->coreaudio.hCoreAudio); ma_dlclose(ma_context_get_log(pContext), pContext->coreaudio.hCoreFoundation); return MA_API_NOT_FOUND; } } pContext->coreaudio.AudioComponentFindNext = ma_dlsym(ma_context_get_log(pContext), pContext->coreaudio.hAudioUnit, "AudioComponentFindNext"); pContext->coreaudio.AudioComponentInstanceDispose = ma_dlsym(ma_context_get_log(pContext), pContext->coreaudio.hAudioUnit, "AudioComponentInstanceDispose"); pContext->coreaudio.AudioComponentInstanceNew = ma_dlsym(ma_context_get_log(pContext), pContext->coreaudio.hAudioUnit, "AudioComponentInstanceNew"); pContext->coreaudio.AudioOutputUnitStart = ma_dlsym(ma_context_get_log(pContext), pContext->coreaudio.hAudioUnit, "AudioOutputUnitStart"); pContext->coreaudio.AudioOutputUnitStop = ma_dlsym(ma_context_get_log(pContext), pContext->coreaudio.hAudioUnit, "AudioOutputUnitStop"); pContext->coreaudio.AudioUnitAddPropertyListener = ma_dlsym(ma_context_get_log(pContext), pContext->coreaudio.hAudioUnit, "AudioUnitAddPropertyListener"); pContext->coreaudio.AudioUnitGetPropertyInfo = ma_dlsym(ma_context_get_log(pContext), pContext->coreaudio.hAudioUnit, "AudioUnitGetPropertyInfo"); pContext->coreaudio.AudioUnitGetProperty = ma_dlsym(ma_context_get_log(pContext), pContext->coreaudio.hAudioUnit, "AudioUnitGetProperty"); pContext->coreaudio.AudioUnitSetProperty = ma_dlsym(ma_context_get_log(pContext), pContext->coreaudio.hAudioUnit, "AudioUnitSetProperty"); pContext->coreaudio.AudioUnitInitialize = ma_dlsym(ma_context_get_log(pContext), pContext->coreaudio.hAudioUnit, "AudioUnitInitialize"); pContext->coreaudio.AudioUnitRender = ma_dlsym(ma_context_get_log(pContext), pContext->coreaudio.hAudioUnit, "AudioUnitRender"); #else pContext->coreaudio.CFStringGetCString = (ma_proc)CFStringGetCString; pContext->coreaudio.CFRelease = (ma_proc)CFRelease; #if defined(MA_APPLE_DESKTOP) pContext->coreaudio.AudioObjectGetPropertyData = (ma_proc)AudioObjectGetPropertyData; pContext->coreaudio.AudioObjectGetPropertyDataSize = (ma_proc)AudioObjectGetPropertyDataSize; pContext->coreaudio.AudioObjectSetPropertyData = (ma_proc)AudioObjectSetPropertyData; pContext->coreaudio.AudioObjectAddPropertyListener = (ma_proc)AudioObjectAddPropertyListener; pContext->coreaudio.AudioObjectRemovePropertyListener = (ma_proc)AudioObjectRemovePropertyListener; #endif pContext->coreaudio.AudioComponentFindNext = (ma_proc)AudioComponentFindNext; pContext->coreaudio.AudioComponentInstanceDispose = (ma_proc)AudioComponentInstanceDispose; pContext->coreaudio.AudioComponentInstanceNew = (ma_proc)AudioComponentInstanceNew; pContext->coreaudio.AudioOutputUnitStart = (ma_proc)AudioOutputUnitStart; pContext->coreaudio.AudioOutputUnitStop = (ma_proc)AudioOutputUnitStop; pContext->coreaudio.AudioUnitAddPropertyListener = (ma_proc)AudioUnitAddPropertyListener; pContext->coreaudio.AudioUnitGetPropertyInfo = (ma_proc)AudioUnitGetPropertyInfo; pContext->coreaudio.AudioUnitGetProperty = (ma_proc)AudioUnitGetProperty; pContext->coreaudio.AudioUnitSetProperty = (ma_proc)AudioUnitSetProperty; pContext->coreaudio.AudioUnitInitialize = (ma_proc)AudioUnitInitialize; pContext->coreaudio.AudioUnitRender = (ma_proc)AudioUnitRender; #endif /* Audio component. */ { AudioComponentDescription desc; desc.componentType = kAudioUnitType_Output; #if defined(MA_APPLE_DESKTOP) desc.componentSubType = kAudioUnitSubType_HALOutput; #else desc.componentSubType = kAudioUnitSubType_RemoteIO; #endif desc.componentManufacturer = kAudioUnitManufacturer_Apple; desc.componentFlags = 0; desc.componentFlagsMask = 0; pContext->coreaudio.component = ((ma_AudioComponentFindNext_proc)pContext->coreaudio.AudioComponentFindNext)(NULL, &desc); if (pContext->coreaudio.component == NULL) { #if !defined(MA_NO_RUNTIME_LINKING) && !defined(MA_APPLE_MOBILE) ma_dlclose(ma_context_get_log(pContext), pContext->coreaudio.hAudioUnit); ma_dlclose(ma_context_get_log(pContext), pContext->coreaudio.hCoreAudio); ma_dlclose(ma_context_get_log(pContext), pContext->coreaudio.hCoreFoundation); #endif return MA_FAILED_TO_INIT_BACKEND; } } #if !defined(MA_APPLE_MOBILE) result = ma_context__init_device_tracking__coreaudio(pContext); if (result != MA_SUCCESS) { #if !defined(MA_NO_RUNTIME_LINKING) && !defined(MA_APPLE_MOBILE) ma_dlclose(ma_context_get_log(pContext), pContext->coreaudio.hAudioUnit); ma_dlclose(ma_context_get_log(pContext), pContext->coreaudio.hCoreAudio); ma_dlclose(ma_context_get_log(pContext), pContext->coreaudio.hCoreFoundation); #endif return result; } #endif pContext->coreaudio.noAudioSessionDeactivate = pConfig->coreaudio.noAudioSessionDeactivate; pCallbacks->onContextInit = ma_context_init__coreaudio; pCallbacks->onContextUninit = ma_context_uninit__coreaudio; pCallbacks->onContextEnumerateDevices = ma_context_enumerate_devices__coreaudio; pCallbacks->onContextGetDeviceInfo = ma_context_get_device_info__coreaudio; pCallbacks->onDeviceInit = ma_device_init__coreaudio; pCallbacks->onDeviceUninit = ma_device_uninit__coreaudio; pCallbacks->onDeviceStart = ma_device_start__coreaudio; pCallbacks->onDeviceStop = ma_device_stop__coreaudio; pCallbacks->onDeviceRead = NULL; pCallbacks->onDeviceWrite = NULL; pCallbacks->onDeviceDataLoop = NULL; return MA_SUCCESS; } #endif /* Core Audio */ /****************************************************************************** sndio Backend ******************************************************************************/ #ifdef MA_HAS_SNDIO #include /* Only supporting OpenBSD. This did not work very well at all on FreeBSD when I tried it. Not sure if this is due to miniaudio's implementation or if it's some kind of system configuration issue, but basically the default device just doesn't emit any sound, or at times you'll hear tiny pieces. I will consider enabling this when there's demand for it or if I can get it tested and debugged more thoroughly. */ #if 0 #if defined(__NetBSD__) || defined(__OpenBSD__) #include #endif #if defined(__FreeBSD__) || defined(__DragonFly__) #include #endif #endif #define MA_SIO_DEVANY "default" #define MA_SIO_PLAY 1 #define MA_SIO_REC 2 #define MA_SIO_NENC 8 #define MA_SIO_NCHAN 8 #define MA_SIO_NRATE 16 #define MA_SIO_NCONF 4 struct ma_sio_hdl; /* <-- Opaque */ struct ma_sio_par { unsigned int bits; unsigned int bps; unsigned int sig; unsigned int le; unsigned int msb; unsigned int rchan; unsigned int pchan; unsigned int rate; unsigned int bufsz; unsigned int xrun; unsigned int round; unsigned int appbufsz; int __pad[3]; unsigned int __magic; }; struct ma_sio_enc { unsigned int bits; unsigned int bps; unsigned int sig; unsigned int le; unsigned int msb; }; struct ma_sio_conf { unsigned int enc; unsigned int rchan; unsigned int pchan; unsigned int rate; }; struct ma_sio_cap { struct ma_sio_enc enc[MA_SIO_NENC]; unsigned int rchan[MA_SIO_NCHAN]; unsigned int pchan[MA_SIO_NCHAN]; unsigned int rate[MA_SIO_NRATE]; int __pad[7]; unsigned int nconf; struct ma_sio_conf confs[MA_SIO_NCONF]; }; typedef struct ma_sio_hdl* (* ma_sio_open_proc) (const char*, unsigned int, int); typedef void (* ma_sio_close_proc) (struct ma_sio_hdl*); typedef int (* ma_sio_setpar_proc) (struct ma_sio_hdl*, struct ma_sio_par*); typedef int (* ma_sio_getpar_proc) (struct ma_sio_hdl*, struct ma_sio_par*); typedef int (* ma_sio_getcap_proc) (struct ma_sio_hdl*, struct ma_sio_cap*); typedef size_t (* ma_sio_write_proc) (struct ma_sio_hdl*, const void*, size_t); typedef size_t (* ma_sio_read_proc) (struct ma_sio_hdl*, void*, size_t); typedef int (* ma_sio_start_proc) (struct ma_sio_hdl*); typedef int (* ma_sio_stop_proc) (struct ma_sio_hdl*); typedef int (* ma_sio_initpar_proc)(struct ma_sio_par*); static ma_uint32 ma_get_standard_sample_rate_priority_index__sndio(ma_uint32 sampleRate) /* Lower = higher priority */ { ma_uint32 i; for (i = 0; i < ma_countof(g_maStandardSampleRatePriorities); ++i) { if (g_maStandardSampleRatePriorities[i] == sampleRate) { return i; } } return (ma_uint32)-1; } static ma_format ma_format_from_sio_enc__sndio(unsigned int bits, unsigned int bps, unsigned int sig, unsigned int le, unsigned int msb) { /* We only support native-endian right now. */ if ((ma_is_little_endian() && le == 0) || (ma_is_big_endian() && le == 1)) { return ma_format_unknown; } if (bits == 8 && bps == 1 && sig == 0) { return ma_format_u8; } if (bits == 16 && bps == 2 && sig == 1) { return ma_format_s16; } if (bits == 24 && bps == 3 && sig == 1) { return ma_format_s24; } if (bits == 24 && bps == 4 && sig == 1 && msb == 0) { /*return ma_format_s24_32;*/ } if (bits == 32 && bps == 4 && sig == 1) { return ma_format_s32; } return ma_format_unknown; } static ma_format ma_find_best_format_from_sio_cap__sndio(struct ma_sio_cap* caps) { ma_format bestFormat; unsigned int iConfig; MA_ASSERT(caps != NULL); bestFormat = ma_format_unknown; for (iConfig = 0; iConfig < caps->nconf; iConfig += 1) { unsigned int iEncoding; for (iEncoding = 0; iEncoding < MA_SIO_NENC; iEncoding += 1) { unsigned int bits; unsigned int bps; unsigned int sig; unsigned int le; unsigned int msb; ma_format format; if ((caps->confs[iConfig].enc & (1UL << iEncoding)) == 0) { continue; } bits = caps->enc[iEncoding].bits; bps = caps->enc[iEncoding].bps; sig = caps->enc[iEncoding].sig; le = caps->enc[iEncoding].le; msb = caps->enc[iEncoding].msb; format = ma_format_from_sio_enc__sndio(bits, bps, sig, le, msb); if (format == ma_format_unknown) { continue; /* Format not supported. */ } if (bestFormat == ma_format_unknown) { bestFormat = format; } else { if (ma_get_format_priority_index(bestFormat) > ma_get_format_priority_index(format)) { /* <-- Lower = better. */ bestFormat = format; } } } } return bestFormat; } static ma_uint32 ma_find_best_channels_from_sio_cap__sndio(struct ma_sio_cap* caps, ma_device_type deviceType, ma_format requiredFormat) { ma_uint32 maxChannels; unsigned int iConfig; MA_ASSERT(caps != NULL); MA_ASSERT(requiredFormat != ma_format_unknown); /* Just pick whatever configuration has the most channels. */ maxChannels = 0; for (iConfig = 0; iConfig < caps->nconf; iConfig += 1) { /* The encoding should be of requiredFormat. */ unsigned int iEncoding; for (iEncoding = 0; iEncoding < MA_SIO_NENC; iEncoding += 1) { unsigned int iChannel; unsigned int bits; unsigned int bps; unsigned int sig; unsigned int le; unsigned int msb; ma_format format; if ((caps->confs[iConfig].enc & (1UL << iEncoding)) == 0) { continue; } bits = caps->enc[iEncoding].bits; bps = caps->enc[iEncoding].bps; sig = caps->enc[iEncoding].sig; le = caps->enc[iEncoding].le; msb = caps->enc[iEncoding].msb; format = ma_format_from_sio_enc__sndio(bits, bps, sig, le, msb); if (format != requiredFormat) { continue; } /* Getting here means the format is supported. Iterate over each channel count and grab the biggest one. */ for (iChannel = 0; iChannel < MA_SIO_NCHAN; iChannel += 1) { unsigned int chan = 0; unsigned int channels; if (deviceType == ma_device_type_playback) { chan = caps->confs[iConfig].pchan; } else { chan = caps->confs[iConfig].rchan; } if ((chan & (1UL << iChannel)) == 0) { continue; } if (deviceType == ma_device_type_playback) { channels = caps->pchan[iChannel]; } else { channels = caps->rchan[iChannel]; } if (maxChannels < channels) { maxChannels = channels; } } } } return maxChannels; } static ma_uint32 ma_find_best_sample_rate_from_sio_cap__sndio(struct ma_sio_cap* caps, ma_device_type deviceType, ma_format requiredFormat, ma_uint32 requiredChannels) { ma_uint32 firstSampleRate; ma_uint32 bestSampleRate; unsigned int iConfig; MA_ASSERT(caps != NULL); MA_ASSERT(requiredFormat != ma_format_unknown); MA_ASSERT(requiredChannels > 0); MA_ASSERT(requiredChannels <= MA_MAX_CHANNELS); firstSampleRate = 0; /* <-- If the device does not support a standard rate we'll fall back to the first one that's found. */ bestSampleRate = 0; for (iConfig = 0; iConfig < caps->nconf; iConfig += 1) { /* The encoding should be of requiredFormat. */ unsigned int iEncoding; for (iEncoding = 0; iEncoding < MA_SIO_NENC; iEncoding += 1) { unsigned int iChannel; unsigned int bits; unsigned int bps; unsigned int sig; unsigned int le; unsigned int msb; ma_format format; if ((caps->confs[iConfig].enc & (1UL << iEncoding)) == 0) { continue; } bits = caps->enc[iEncoding].bits; bps = caps->enc[iEncoding].bps; sig = caps->enc[iEncoding].sig; le = caps->enc[iEncoding].le; msb = caps->enc[iEncoding].msb; format = ma_format_from_sio_enc__sndio(bits, bps, sig, le, msb); if (format != requiredFormat) { continue; } /* Getting here means the format is supported. Iterate over each channel count and grab the biggest one. */ for (iChannel = 0; iChannel < MA_SIO_NCHAN; iChannel += 1) { unsigned int chan = 0; unsigned int channels; unsigned int iRate; if (deviceType == ma_device_type_playback) { chan = caps->confs[iConfig].pchan; } else { chan = caps->confs[iConfig].rchan; } if ((chan & (1UL << iChannel)) == 0) { continue; } if (deviceType == ma_device_type_playback) { channels = caps->pchan[iChannel]; } else { channels = caps->rchan[iChannel]; } if (channels != requiredChannels) { continue; } /* Getting here means we have found a compatible encoding/channel pair. */ for (iRate = 0; iRate < MA_SIO_NRATE; iRate += 1) { ma_uint32 rate = (ma_uint32)caps->rate[iRate]; ma_uint32 ratePriority; if (firstSampleRate == 0) { firstSampleRate = rate; } /* Disregard this rate if it's not a standard one. */ ratePriority = ma_get_standard_sample_rate_priority_index__sndio(rate); if (ratePriority == (ma_uint32)-1) { continue; } if (ma_get_standard_sample_rate_priority_index__sndio(bestSampleRate) > ratePriority) { /* Lower = better. */ bestSampleRate = rate; } } } } } /* If a standard sample rate was not found just fall back to the first one that was iterated. */ if (bestSampleRate == 0) { bestSampleRate = firstSampleRate; } return bestSampleRate; } static ma_result ma_context_enumerate_devices__sndio(ma_context* pContext, ma_enum_devices_callback_proc callback, void* pUserData) { ma_bool32 isTerminating = MA_FALSE; struct ma_sio_hdl* handle; MA_ASSERT(pContext != NULL); MA_ASSERT(callback != NULL); /* sndio doesn't seem to have a good device enumeration API, so I'm therefore only enumerating over default devices for now. */ /* Playback. */ if (!isTerminating) { handle = ((ma_sio_open_proc)pContext->sndio.sio_open)(MA_SIO_DEVANY, MA_SIO_PLAY, 0); if (handle != NULL) { /* Supports playback. */ ma_device_info deviceInfo; MA_ZERO_OBJECT(&deviceInfo); ma_strcpy_s(deviceInfo.id.sndio, sizeof(deviceInfo.id.sndio), MA_SIO_DEVANY); ma_strcpy_s(deviceInfo.name, sizeof(deviceInfo.name), MA_DEFAULT_PLAYBACK_DEVICE_NAME); isTerminating = !callback(pContext, ma_device_type_playback, &deviceInfo, pUserData); ((ma_sio_close_proc)pContext->sndio.sio_close)(handle); } } /* Capture. */ if (!isTerminating) { handle = ((ma_sio_open_proc)pContext->sndio.sio_open)(MA_SIO_DEVANY, MA_SIO_REC, 0); if (handle != NULL) { /* Supports capture. */ ma_device_info deviceInfo; MA_ZERO_OBJECT(&deviceInfo); ma_strcpy_s(deviceInfo.id.sndio, sizeof(deviceInfo.id.sndio), "default"); ma_strcpy_s(deviceInfo.name, sizeof(deviceInfo.name), MA_DEFAULT_CAPTURE_DEVICE_NAME); isTerminating = !callback(pContext, ma_device_type_capture, &deviceInfo, pUserData); ((ma_sio_close_proc)pContext->sndio.sio_close)(handle); } } return MA_SUCCESS; } static ma_result ma_context_get_device_info__sndio(ma_context* pContext, ma_device_type deviceType, const ma_device_id* pDeviceID, ma_device_info* pDeviceInfo) { char devid[256]; struct ma_sio_hdl* handle; struct ma_sio_cap caps; unsigned int iConfig; MA_ASSERT(pContext != NULL); /* We need to open the device before we can get information about it. */ if (pDeviceID == NULL) { ma_strcpy_s(devid, sizeof(devid), MA_SIO_DEVANY); ma_strcpy_s(pDeviceInfo->name, sizeof(pDeviceInfo->name), (deviceType == ma_device_type_playback) ? MA_DEFAULT_PLAYBACK_DEVICE_NAME : MA_DEFAULT_CAPTURE_DEVICE_NAME); } else { ma_strcpy_s(devid, sizeof(devid), pDeviceID->sndio); ma_strcpy_s(pDeviceInfo->name, sizeof(pDeviceInfo->name), devid); } handle = ((ma_sio_open_proc)pContext->sndio.sio_open)(devid, (deviceType == ma_device_type_playback) ? MA_SIO_PLAY : MA_SIO_REC, 0); if (handle == NULL) { return MA_NO_DEVICE; } if (((ma_sio_getcap_proc)pContext->sndio.sio_getcap)(handle, &caps) == 0) { return MA_ERROR; } pDeviceInfo->nativeDataFormatCount = 0; for (iConfig = 0; iConfig < caps.nconf; iConfig += 1) { /* The main thing we care about is that the encoding is supported by miniaudio. If it is, we want to give preference to some formats over others. */ unsigned int iEncoding; unsigned int iChannel; unsigned int iRate; for (iEncoding = 0; iEncoding < MA_SIO_NENC; iEncoding += 1) { unsigned int bits; unsigned int bps; unsigned int sig; unsigned int le; unsigned int msb; ma_format format; if ((caps.confs[iConfig].enc & (1UL << iEncoding)) == 0) { continue; } bits = caps.enc[iEncoding].bits; bps = caps.enc[iEncoding].bps; sig = caps.enc[iEncoding].sig; le = caps.enc[iEncoding].le; msb = caps.enc[iEncoding].msb; format = ma_format_from_sio_enc__sndio(bits, bps, sig, le, msb); if (format == ma_format_unknown) { continue; /* Format not supported. */ } /* Channels. */ for (iChannel = 0; iChannel < MA_SIO_NCHAN; iChannel += 1) { unsigned int chan = 0; unsigned int channels; if (deviceType == ma_device_type_playback) { chan = caps.confs[iConfig].pchan; } else { chan = caps.confs[iConfig].rchan; } if ((chan & (1UL << iChannel)) == 0) { continue; } if (deviceType == ma_device_type_playback) { channels = caps.pchan[iChannel]; } else { channels = caps.rchan[iChannel]; } /* Sample Rates. */ for (iRate = 0; iRate < MA_SIO_NRATE; iRate += 1) { if ((caps.confs[iConfig].rate & (1UL << iRate)) != 0) { ma_device_info_add_native_data_format(pDeviceInfo, format, channels, caps.rate[iRate], 0); } } } } } ((ma_sio_close_proc)pContext->sndio.sio_close)(handle); return MA_SUCCESS; } static ma_result ma_device_uninit__sndio(ma_device* pDevice) { MA_ASSERT(pDevice != NULL); if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) { ((ma_sio_close_proc)pDevice->pContext->sndio.sio_close)((struct ma_sio_hdl*)pDevice->sndio.handleCapture); } if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) { ((ma_sio_close_proc)pDevice->pContext->sndio.sio_close)((struct ma_sio_hdl*)pDevice->sndio.handlePlayback); } return MA_SUCCESS; } static ma_result ma_device_init_handle__sndio(ma_device* pDevice, const ma_device_config* pConfig, ma_device_descriptor* pDescriptor, ma_device_type deviceType) { const char* pDeviceName; ma_ptr handle; int openFlags = 0; struct ma_sio_cap caps; struct ma_sio_par par; const ma_device_id* pDeviceID; ma_format format; ma_uint32 channels; ma_uint32 sampleRate; ma_format internalFormat; ma_uint32 internalChannels; ma_uint32 internalSampleRate; ma_uint32 internalPeriodSizeInFrames; ma_uint32 internalPeriods; MA_ASSERT(pConfig != NULL); MA_ASSERT(deviceType != ma_device_type_duplex); MA_ASSERT(pDevice != NULL); if (deviceType == ma_device_type_capture) { openFlags = MA_SIO_REC; } else { openFlags = MA_SIO_PLAY; } pDeviceID = pDescriptor->pDeviceID; format = pDescriptor->format; channels = pDescriptor->channels; sampleRate = pDescriptor->sampleRate; pDeviceName = MA_SIO_DEVANY; if (pDeviceID != NULL) { pDeviceName = pDeviceID->sndio; } handle = (ma_ptr)((ma_sio_open_proc)pDevice->pContext->sndio.sio_open)(pDeviceName, openFlags, 0); if (handle == NULL) { ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[sndio] Failed to open device."); return MA_FAILED_TO_OPEN_BACKEND_DEVICE; } /* We need to retrieve the device caps to determine the most appropriate format to use. */ if (((ma_sio_getcap_proc)pDevice->pContext->sndio.sio_getcap)((struct ma_sio_hdl*)handle, &caps) == 0) { ((ma_sio_close_proc)pDevice->pContext->sndio.sio_close)((struct ma_sio_hdl*)handle); ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[sndio] Failed to retrieve device caps."); return MA_ERROR; } /* Note: sndio reports a huge range of available channels. This is inconvenient for us because there's no real way, as far as I can tell, to get the _actual_ channel count of the device. I'm therefore restricting this to the requested channels, regardless of whether or not the default channel count is requested. For hardware devices, I'm suspecting only a single channel count will be reported and we can safely use the value returned by ma_find_best_channels_from_sio_cap__sndio(). */ if (deviceType == ma_device_type_capture) { if (format == ma_format_unknown) { format = ma_find_best_format_from_sio_cap__sndio(&caps); } if (channels == 0) { if (strlen(pDeviceName) > strlen("rsnd/") && strncmp(pDeviceName, "rsnd/", strlen("rsnd/")) == 0) { channels = ma_find_best_channels_from_sio_cap__sndio(&caps, deviceType, format); } else { channels = MA_DEFAULT_CHANNELS; } } } else { if (format == ma_format_unknown) { format = ma_find_best_format_from_sio_cap__sndio(&caps); } if (channels == 0) { if (strlen(pDeviceName) > strlen("rsnd/") && strncmp(pDeviceName, "rsnd/", strlen("rsnd/")) == 0) { channels = ma_find_best_channels_from_sio_cap__sndio(&caps, deviceType, format); } else { channels = MA_DEFAULT_CHANNELS; } } } if (sampleRate == 0) { sampleRate = ma_find_best_sample_rate_from_sio_cap__sndio(&caps, pConfig->deviceType, format, channels); } ((ma_sio_initpar_proc)pDevice->pContext->sndio.sio_initpar)(&par); par.msb = 0; par.le = ma_is_little_endian(); switch (format) { case ma_format_u8: { par.bits = 8; par.bps = 1; par.sig = 0; } break; case ma_format_s24: { par.bits = 24; par.bps = 3; par.sig = 1; } break; case ma_format_s32: { par.bits = 32; par.bps = 4; par.sig = 1; } break; case ma_format_s16: case ma_format_f32: case ma_format_unknown: default: { par.bits = 16; par.bps = 2; par.sig = 1; } break; } if (deviceType == ma_device_type_capture) { par.rchan = channels; } else { par.pchan = channels; } par.rate = sampleRate; internalPeriodSizeInFrames = ma_calculate_buffer_size_in_frames_from_descriptor(pDescriptor, par.rate, pConfig->performanceProfile); par.round = internalPeriodSizeInFrames; par.appbufsz = par.round * pDescriptor->periodCount; if (((ma_sio_setpar_proc)pDevice->pContext->sndio.sio_setpar)((struct ma_sio_hdl*)handle, &par) == 0) { ((ma_sio_close_proc)pDevice->pContext->sndio.sio_close)((struct ma_sio_hdl*)handle); ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[sndio] Failed to set buffer size."); return MA_ERROR; } if (((ma_sio_getpar_proc)pDevice->pContext->sndio.sio_getpar)((struct ma_sio_hdl*)handle, &par) == 0) { ((ma_sio_close_proc)pDevice->pContext->sndio.sio_close)((struct ma_sio_hdl*)handle); ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[sndio] Failed to retrieve buffer size."); return MA_ERROR; } internalFormat = ma_format_from_sio_enc__sndio(par.bits, par.bps, par.sig, par.le, par.msb); internalChannels = (deviceType == ma_device_type_capture) ? par.rchan : par.pchan; internalSampleRate = par.rate; internalPeriods = par.appbufsz / par.round; internalPeriodSizeInFrames = par.round; if (deviceType == ma_device_type_capture) { pDevice->sndio.handleCapture = handle; } else { pDevice->sndio.handlePlayback = handle; } pDescriptor->format = internalFormat; pDescriptor->channels = internalChannels; pDescriptor->sampleRate = internalSampleRate; ma_channel_map_init_standard(ma_standard_channel_map_sndio, pDescriptor->channelMap, ma_countof(pDescriptor->channelMap), internalChannels); pDescriptor->periodSizeInFrames = internalPeriodSizeInFrames; pDescriptor->periodCount = internalPeriods; return MA_SUCCESS; } static ma_result ma_device_init__sndio(ma_device* pDevice, const ma_device_config* pConfig, ma_device_descriptor* pDescriptorPlayback, ma_device_descriptor* pDescriptorCapture) { MA_ASSERT(pDevice != NULL); MA_ZERO_OBJECT(&pDevice->sndio); if (pConfig->deviceType == ma_device_type_loopback) { return MA_DEVICE_TYPE_NOT_SUPPORTED; } if (pConfig->deviceType == ma_device_type_capture || pConfig->deviceType == ma_device_type_duplex) { ma_result result = ma_device_init_handle__sndio(pDevice, pConfig, pDescriptorCapture, ma_device_type_capture); if (result != MA_SUCCESS) { return result; } } if (pConfig->deviceType == ma_device_type_playback || pConfig->deviceType == ma_device_type_duplex) { ma_result result = ma_device_init_handle__sndio(pDevice, pConfig, pDescriptorPlayback, ma_device_type_playback); if (result != MA_SUCCESS) { return result; } } return MA_SUCCESS; } static ma_result ma_device_start__sndio(ma_device* pDevice) { MA_ASSERT(pDevice != NULL); if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) { ((ma_sio_start_proc)pDevice->pContext->sndio.sio_start)((struct ma_sio_hdl*)pDevice->sndio.handleCapture); } if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) { ((ma_sio_start_proc)pDevice->pContext->sndio.sio_start)((struct ma_sio_hdl*)pDevice->sndio.handlePlayback); /* <-- Doesn't actually playback until data is written. */ } return MA_SUCCESS; } static ma_result ma_device_stop__sndio(ma_device* pDevice) { MA_ASSERT(pDevice != NULL); /* From the documentation: The sio_stop() function puts the audio subsystem in the same state as before sio_start() is called. It stops recording, drains the play buffer and then stops playback. If samples to play are queued but playback hasn't started yet then playback is forced immediately; playback will actually stop once the buffer is drained. In no case are samples in the play buffer discarded. Therefore, sio_stop() performs all of the necessary draining for us. */ if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) { ((ma_sio_stop_proc)pDevice->pContext->sndio.sio_stop)((struct ma_sio_hdl*)pDevice->sndio.handleCapture); } if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) { ((ma_sio_stop_proc)pDevice->pContext->sndio.sio_stop)((struct ma_sio_hdl*)pDevice->sndio.handlePlayback); } return MA_SUCCESS; } static ma_result ma_device_write__sndio(ma_device* pDevice, const void* pPCMFrames, ma_uint32 frameCount, ma_uint32* pFramesWritten) { int result; if (pFramesWritten != NULL) { *pFramesWritten = 0; } result = ((ma_sio_write_proc)pDevice->pContext->sndio.sio_write)((struct ma_sio_hdl*)pDevice->sndio.handlePlayback, pPCMFrames, frameCount * ma_get_bytes_per_frame(pDevice->playback.internalFormat, pDevice->playback.internalChannels)); if (result == 0) { ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[sndio] Failed to send data from the client to the device."); return MA_IO_ERROR; } if (pFramesWritten != NULL) { *pFramesWritten = frameCount; } return MA_SUCCESS; } static ma_result ma_device_read__sndio(ma_device* pDevice, void* pPCMFrames, ma_uint32 frameCount, ma_uint32* pFramesRead) { int result; if (pFramesRead != NULL) { *pFramesRead = 0; } result = ((ma_sio_read_proc)pDevice->pContext->sndio.sio_read)((struct ma_sio_hdl*)pDevice->sndio.handleCapture, pPCMFrames, frameCount * ma_get_bytes_per_frame(pDevice->capture.internalFormat, pDevice->capture.internalChannels)); if (result == 0) { ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[sndio] Failed to read data from the device to be sent to the device."); return MA_IO_ERROR; } if (pFramesRead != NULL) { *pFramesRead = frameCount; } return MA_SUCCESS; } static ma_result ma_context_uninit__sndio(ma_context* pContext) { MA_ASSERT(pContext != NULL); MA_ASSERT(pContext->backend == ma_backend_sndio); (void)pContext; return MA_SUCCESS; } static ma_result ma_context_init__sndio(ma_context* pContext, const ma_context_config* pConfig, ma_backend_callbacks* pCallbacks) { #ifndef MA_NO_RUNTIME_LINKING const char* libsndioNames[] = { "libsndio.so" }; size_t i; for (i = 0; i < ma_countof(libsndioNames); ++i) { pContext->sndio.sndioSO = ma_dlopen(ma_context_get_log(pContext), libsndioNames[i]); if (pContext->sndio.sndioSO != NULL) { break; } } if (pContext->sndio.sndioSO == NULL) { return MA_NO_BACKEND; } pContext->sndio.sio_open = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->sndio.sndioSO, "sio_open"); pContext->sndio.sio_close = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->sndio.sndioSO, "sio_close"); pContext->sndio.sio_setpar = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->sndio.sndioSO, "sio_setpar"); pContext->sndio.sio_getpar = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->sndio.sndioSO, "sio_getpar"); pContext->sndio.sio_getcap = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->sndio.sndioSO, "sio_getcap"); pContext->sndio.sio_write = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->sndio.sndioSO, "sio_write"); pContext->sndio.sio_read = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->sndio.sndioSO, "sio_read"); pContext->sndio.sio_start = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->sndio.sndioSO, "sio_start"); pContext->sndio.sio_stop = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->sndio.sndioSO, "sio_stop"); pContext->sndio.sio_initpar = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->sndio.sndioSO, "sio_initpar"); #else pContext->sndio.sio_open = sio_open; pContext->sndio.sio_close = sio_close; pContext->sndio.sio_setpar = sio_setpar; pContext->sndio.sio_getpar = sio_getpar; pContext->sndio.sio_getcap = sio_getcap; pContext->sndio.sio_write = sio_write; pContext->sndio.sio_read = sio_read; pContext->sndio.sio_start = sio_start; pContext->sndio.sio_stop = sio_stop; pContext->sndio.sio_initpar = sio_initpar; #endif pCallbacks->onContextInit = ma_context_init__sndio; pCallbacks->onContextUninit = ma_context_uninit__sndio; pCallbacks->onContextEnumerateDevices = ma_context_enumerate_devices__sndio; pCallbacks->onContextGetDeviceInfo = ma_context_get_device_info__sndio; pCallbacks->onDeviceInit = ma_device_init__sndio; pCallbacks->onDeviceUninit = ma_device_uninit__sndio; pCallbacks->onDeviceStart = ma_device_start__sndio; pCallbacks->onDeviceStop = ma_device_stop__sndio; pCallbacks->onDeviceRead = ma_device_read__sndio; pCallbacks->onDeviceWrite = ma_device_write__sndio; pCallbacks->onDeviceDataLoop = NULL; (void)pConfig; return MA_SUCCESS; } #endif /* sndio */ /****************************************************************************** audio(4) Backend ******************************************************************************/ #ifdef MA_HAS_AUDIO4 #include #include #include #include #include #include #include #if defined(__OpenBSD__) #include #if defined(OpenBSD) && OpenBSD >= 201709 #define MA_AUDIO4_USE_NEW_API #endif #endif static void ma_construct_device_id__audio4(char* id, size_t idSize, const char* base, int deviceIndex) { size_t baseLen; MA_ASSERT(id != NULL); MA_ASSERT(idSize > 0); MA_ASSERT(deviceIndex >= 0); baseLen = strlen(base); MA_ASSERT(idSize > baseLen); ma_strcpy_s(id, idSize, base); ma_itoa_s(deviceIndex, id+baseLen, idSize-baseLen, 10); } static ma_result ma_extract_device_index_from_id__audio4(const char* id, const char* base, int* pIndexOut) { size_t idLen; size_t baseLen; const char* deviceIndexStr; MA_ASSERT(id != NULL); MA_ASSERT(base != NULL); MA_ASSERT(pIndexOut != NULL); idLen = strlen(id); baseLen = strlen(base); if (idLen <= baseLen) { return MA_ERROR; /* Doesn't look like the id starts with the base. */ } if (strncmp(id, base, baseLen) != 0) { return MA_ERROR; /* ID does not begin with base. */ } deviceIndexStr = id + baseLen; if (deviceIndexStr[0] == '\0') { return MA_ERROR; /* No index specified in the ID. */ } if (pIndexOut) { *pIndexOut = atoi(deviceIndexStr); } return MA_SUCCESS; } #if !defined(MA_AUDIO4_USE_NEW_API) /* Old API */ static ma_format ma_format_from_encoding__audio4(unsigned int encoding, unsigned int precision) { if (precision == 8 && (encoding == AUDIO_ENCODING_ULINEAR || encoding == AUDIO_ENCODING_ULINEAR || encoding == AUDIO_ENCODING_ULINEAR_LE || encoding == AUDIO_ENCODING_ULINEAR_BE)) { return ma_format_u8; } else { if (ma_is_little_endian() && encoding == AUDIO_ENCODING_SLINEAR_LE) { if (precision == 16) { return ma_format_s16; } else if (precision == 24) { return ma_format_s24; } else if (precision == 32) { return ma_format_s32; } } else if (ma_is_big_endian() && encoding == AUDIO_ENCODING_SLINEAR_BE) { if (precision == 16) { return ma_format_s16; } else if (precision == 24) { return ma_format_s24; } else if (precision == 32) { return ma_format_s32; } } } return ma_format_unknown; /* Encoding not supported. */ } static void ma_encoding_from_format__audio4(ma_format format, unsigned int* pEncoding, unsigned int* pPrecision) { MA_ASSERT(pEncoding != NULL); MA_ASSERT(pPrecision != NULL); switch (format) { case ma_format_u8: { *pEncoding = AUDIO_ENCODING_ULINEAR; *pPrecision = 8; } break; case ma_format_s24: { *pEncoding = (ma_is_little_endian()) ? AUDIO_ENCODING_SLINEAR_LE : AUDIO_ENCODING_SLINEAR_BE; *pPrecision = 24; } break; case ma_format_s32: { *pEncoding = (ma_is_little_endian()) ? AUDIO_ENCODING_SLINEAR_LE : AUDIO_ENCODING_SLINEAR_BE; *pPrecision = 32; } break; case ma_format_s16: case ma_format_f32: case ma_format_unknown: default: { *pEncoding = (ma_is_little_endian()) ? AUDIO_ENCODING_SLINEAR_LE : AUDIO_ENCODING_SLINEAR_BE; *pPrecision = 16; } break; } } static ma_format ma_format_from_prinfo__audio4(struct audio_prinfo* prinfo) { return ma_format_from_encoding__audio4(prinfo->encoding, prinfo->precision); } static ma_format ma_best_format_from_fd__audio4(int fd, ma_format preferredFormat) { audio_encoding_t encoding; ma_uint32 iFormat; int counter = 0; /* First check to see if the preferred format is supported. */ if (preferredFormat != ma_format_unknown) { counter = 0; for (;;) { MA_ZERO_OBJECT(&encoding); encoding.index = counter; if (ioctl(fd, AUDIO_GETENC, &encoding) < 0) { break; } if (preferredFormat == ma_format_from_encoding__audio4(encoding.encoding, encoding.precision)) { return preferredFormat; /* Found the preferred format. */ } /* Getting here means this encoding does not match our preferred format so we need to more on to the next encoding. */ counter += 1; } } /* Getting here means our preferred format is not supported, so fall back to our standard priorities. */ for (iFormat = 0; iFormat < ma_countof(g_maFormatPriorities); iFormat += 1) { ma_format format = g_maFormatPriorities[iFormat]; counter = 0; for (;;) { MA_ZERO_OBJECT(&encoding); encoding.index = counter; if (ioctl(fd, AUDIO_GETENC, &encoding) < 0) { break; } if (format == ma_format_from_encoding__audio4(encoding.encoding, encoding.precision)) { return format; /* Found a workable format. */ } /* Getting here means this encoding does not match our preferred format so we need to more on to the next encoding. */ counter += 1; } } /* Getting here means not appropriate format was found. */ return ma_format_unknown; } #else static ma_format ma_format_from_swpar__audio4(struct audio_swpar* par) { if (par->bits == 8 && par->bps == 1 && par->sig == 0) { return ma_format_u8; } if (par->bits == 16 && par->bps == 2 && par->sig == 1 && par->le == ma_is_little_endian()) { return ma_format_s16; } if (par->bits == 24 && par->bps == 3 && par->sig == 1 && par->le == ma_is_little_endian()) { return ma_format_s24; } if (par->bits == 32 && par->bps == 4 && par->sig == 1 && par->le == ma_is_little_endian()) { return ma_format_f32; } /* Format not supported. */ return ma_format_unknown; } #endif static ma_result ma_context_get_device_info_from_fd__audio4(ma_context* pContext, ma_device_type deviceType, int fd, ma_device_info* pDeviceInfo) { audio_device_t fdDevice; MA_ASSERT(pContext != NULL); MA_ASSERT(fd >= 0); MA_ASSERT(pDeviceInfo != NULL); (void)pContext; (void)deviceType; if (ioctl(fd, AUDIO_GETDEV, &fdDevice) < 0) { return MA_ERROR; /* Failed to retrieve device info. */ } /* Name. */ ma_strcpy_s(pDeviceInfo->name, sizeof(pDeviceInfo->name), fdDevice.name); #if !defined(MA_AUDIO4_USE_NEW_API) { audio_info_t fdInfo; int counter = 0; ma_uint32 channels; ma_uint32 sampleRate; if (ioctl(fd, AUDIO_GETINFO, &fdInfo) < 0) { return MA_ERROR; } if (deviceType == ma_device_type_playback) { channels = fdInfo.play.channels; sampleRate = fdInfo.play.sample_rate; } else { channels = fdInfo.record.channels; sampleRate = fdInfo.record.sample_rate; } /* Supported formats. We get this by looking at the encodings. */ pDeviceInfo->nativeDataFormatCount = 0; for (;;) { audio_encoding_t encoding; ma_format format; MA_ZERO_OBJECT(&encoding); encoding.index = counter; if (ioctl(fd, AUDIO_GETENC, &encoding) < 0) { break; } format = ma_format_from_encoding__audio4(encoding.encoding, encoding.precision); if (format != ma_format_unknown) { ma_device_info_add_native_data_format(pDeviceInfo, format, channels, sampleRate, 0); } counter += 1; } } #else { struct audio_swpar fdPar; ma_format format; ma_uint32 channels; ma_uint32 sampleRate; if (ioctl(fd, AUDIO_GETPAR, &fdPar) < 0) { return MA_ERROR; } format = ma_format_from_swpar__audio4(&fdPar); if (format == ma_format_unknown) { return MA_FORMAT_NOT_SUPPORTED; } if (deviceType == ma_device_type_playback) { channels = fdPar.pchan; } else { channels = fdPar.rchan; } sampleRate = fdPar.rate; pDeviceInfo->nativeDataFormatCount = 0; ma_device_info_add_native_data_format(pDeviceInfo, format, channels, sampleRate, 0); } #endif return MA_SUCCESS; } static ma_result ma_context_enumerate_devices__audio4(ma_context* pContext, ma_enum_devices_callback_proc callback, void* pUserData) { const int maxDevices = 64; char devpath[256]; int iDevice; MA_ASSERT(pContext != NULL); MA_ASSERT(callback != NULL); /* Every device will be named "/dev/audioN", with a "/dev/audioctlN" equivalent. We use the "/dev/audioctlN" version here since we can open it even when another process has control of the "/dev/audioN" device. */ for (iDevice = 0; iDevice < maxDevices; ++iDevice) { struct stat st; int fd; ma_bool32 isTerminating = MA_FALSE; ma_strcpy_s(devpath, sizeof(devpath), "/dev/audioctl"); ma_itoa_s(iDevice, devpath+strlen(devpath), sizeof(devpath)-strlen(devpath), 10); if (stat(devpath, &st) < 0) { break; } /* The device exists, but we need to check if it's usable as playback and/or capture. */ /* Playback. */ if (!isTerminating) { fd = open(devpath, O_RDONLY, 0); if (fd >= 0) { /* Supports playback. */ ma_device_info deviceInfo; MA_ZERO_OBJECT(&deviceInfo); ma_construct_device_id__audio4(deviceInfo.id.audio4, sizeof(deviceInfo.id.audio4), "/dev/audio", iDevice); if (ma_context_get_device_info_from_fd__audio4(pContext, ma_device_type_playback, fd, &deviceInfo) == MA_SUCCESS) { isTerminating = !callback(pContext, ma_device_type_playback, &deviceInfo, pUserData); } close(fd); } } /* Capture. */ if (!isTerminating) { fd = open(devpath, O_WRONLY, 0); if (fd >= 0) { /* Supports capture. */ ma_device_info deviceInfo; MA_ZERO_OBJECT(&deviceInfo); ma_construct_device_id__audio4(deviceInfo.id.audio4, sizeof(deviceInfo.id.audio4), "/dev/audio", iDevice); if (ma_context_get_device_info_from_fd__audio4(pContext, ma_device_type_capture, fd, &deviceInfo) == MA_SUCCESS) { isTerminating = !callback(pContext, ma_device_type_capture, &deviceInfo, pUserData); } close(fd); } } if (isTerminating) { break; } } return MA_SUCCESS; } static ma_result ma_context_get_device_info__audio4(ma_context* pContext, ma_device_type deviceType, const ma_device_id* pDeviceID, ma_device_info* pDeviceInfo) { int fd = -1; int deviceIndex = -1; char ctlid[256]; ma_result result; MA_ASSERT(pContext != NULL); /* We need to open the "/dev/audioctlN" device to get the info. To do this we need to extract the number from the device ID which will be in "/dev/audioN" format. */ if (pDeviceID == NULL) { /* Default device. */ ma_strcpy_s(ctlid, sizeof(ctlid), "/dev/audioctl"); } else { /* Specific device. We need to convert from "/dev/audioN" to "/dev/audioctlN". */ result = ma_extract_device_index_from_id__audio4(pDeviceID->audio4, "/dev/audio", &deviceIndex); if (result != MA_SUCCESS) { return result; } ma_construct_device_id__audio4(ctlid, sizeof(ctlid), "/dev/audioctl", deviceIndex); } fd = open(ctlid, (deviceType == ma_device_type_playback) ? O_WRONLY : O_RDONLY, 0); if (fd == -1) { return MA_NO_DEVICE; } if (deviceIndex == -1) { ma_strcpy_s(pDeviceInfo->id.audio4, sizeof(pDeviceInfo->id.audio4), "/dev/audio"); } else { ma_construct_device_id__audio4(pDeviceInfo->id.audio4, sizeof(pDeviceInfo->id.audio4), "/dev/audio", deviceIndex); } result = ma_context_get_device_info_from_fd__audio4(pContext, deviceType, fd, pDeviceInfo); close(fd); return result; } static ma_result ma_device_uninit__audio4(ma_device* pDevice) { MA_ASSERT(pDevice != NULL); if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) { close(pDevice->audio4.fdCapture); } if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) { close(pDevice->audio4.fdPlayback); } return MA_SUCCESS; } static ma_result ma_device_init_fd__audio4(ma_device* pDevice, const ma_device_config* pConfig, ma_device_descriptor* pDescriptor, ma_device_type deviceType) { const char* pDefaultDeviceNames[] = { "/dev/audio", "/dev/audio0" }; const char* pDefaultDeviceCtlNames[] = { "/dev/audioctl", "/dev/audioctl0" }; int fd; int fdFlags = 0; size_t iDefaultDevice = (size_t)-1; ma_format internalFormat; ma_uint32 internalChannels; ma_uint32 internalSampleRate; ma_uint32 internalPeriodSizeInFrames; ma_uint32 internalPeriods; MA_ASSERT(pConfig != NULL); MA_ASSERT(deviceType != ma_device_type_duplex); MA_ASSERT(pDevice != NULL); /* The first thing to do is open the file. */ if (deviceType == ma_device_type_capture) { fdFlags = O_RDONLY; } else { fdFlags = O_WRONLY; } /*fdFlags |= O_NONBLOCK;*/ /* Find the index of the default device as a start. We'll use this index later. Set it to (size_t)-1 otherwise. */ if (pDescriptor->pDeviceID == NULL) { /* Default device. */ for (iDefaultDevice = 0; iDefaultDevice < ma_countof(pDefaultDeviceNames); ++iDefaultDevice) { fd = open(pDefaultDeviceNames[iDefaultDevice], fdFlags, 0); if (fd != -1) { break; } } } else { /* Specific device. */ fd = open(pDescriptor->pDeviceID->audio4, fdFlags, 0); for (iDefaultDevice = 0; iDefaultDevice < ma_countof(pDefaultDeviceNames); iDefaultDevice += 1) { if (ma_strcmp(pDefaultDeviceNames[iDefaultDevice], pDescriptor->pDeviceID->audio4) == 0) { break; } } if (iDefaultDevice == ma_countof(pDefaultDeviceNames)) { iDefaultDevice = (size_t)-1; } } if (fd == -1) { ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[audio4] Failed to open device."); return ma_result_from_errno(errno); } #if !defined(MA_AUDIO4_USE_NEW_API) /* Old API */ { audio_info_t fdInfo; int fdInfoResult = -1; /* The documentation is a little bit unclear to me as to how it handles formats. It says the following: Regardless of formats supported by underlying driver, the audio driver accepts the following formats. By then the next sentence says this: `encoding` and `precision` are one of the values obtained by AUDIO_GETENC. It sounds like a direct contradiction to me. I'm going to play this safe any only use the best sample format returned by AUDIO_GETENC. If the requested format is supported we'll use that, but otherwise we'll just use our standard format priorities to pick an appropriate one. */ AUDIO_INITINFO(&fdInfo); /* Get the default format from the audioctl file if we're asking for a default device. If we retrieve it from /dev/audio it'll default to mono 8000Hz. */ if (iDefaultDevice != (size_t)-1) { /* We're using a default device. Get the info from the /dev/audioctl file instead of /dev/audio. */ int fdctl = open(pDefaultDeviceCtlNames[iDefaultDevice], fdFlags, 0); if (fdctl != -1) { fdInfoResult = ioctl(fdctl, AUDIO_GETINFO, &fdInfo); close(fdctl); } } if (fdInfoResult == -1) { /* We still don't have the default device info so just retrieve it from the main audio device. */ if (ioctl(fd, AUDIO_GETINFO, &fdInfo) < 0) { close(fd); ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[audio4] AUDIO_GETINFO failed."); return ma_result_from_errno(errno); } } /* We get the driver to do as much of the data conversion as possible. */ if (deviceType == ma_device_type_capture) { fdInfo.mode = AUMODE_RECORD; ma_encoding_from_format__audio4(ma_best_format_from_fd__audio4(fd, pDescriptor->format), &fdInfo.record.encoding, &fdInfo.record.precision); if (pDescriptor->channels != 0) { fdInfo.record.channels = ma_clamp(pDescriptor->channels, 1, 12); /* From the documentation: `channels` ranges from 1 to 12. */ } if (pDescriptor->sampleRate != 0) { fdInfo.record.sample_rate = ma_clamp(pDescriptor->sampleRate, 1000, 192000); /* From the documentation: `frequency` ranges from 1000Hz to 192000Hz. (They mean `sample_rate` instead of `frequency`.) */ } } else { fdInfo.mode = AUMODE_PLAY; ma_encoding_from_format__audio4(ma_best_format_from_fd__audio4(fd, pDescriptor->format), &fdInfo.play.encoding, &fdInfo.play.precision); if (pDescriptor->channels != 0) { fdInfo.play.channels = ma_clamp(pDescriptor->channels, 1, 12); /* From the documentation: `channels` ranges from 1 to 12. */ } if (pDescriptor->sampleRate != 0) { fdInfo.play.sample_rate = ma_clamp(pDescriptor->sampleRate, 1000, 192000); /* From the documentation: `frequency` ranges from 1000Hz to 192000Hz. (They mean `sample_rate` instead of `frequency`.) */ } } if (ioctl(fd, AUDIO_SETINFO, &fdInfo) < 0) { close(fd); ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[audio4] Failed to set device format. AUDIO_SETINFO failed."); return ma_result_from_errno(errno); } if (ioctl(fd, AUDIO_GETINFO, &fdInfo) < 0) { close(fd); ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[audio4] AUDIO_GETINFO failed."); return ma_result_from_errno(errno); } if (deviceType == ma_device_type_capture) { internalFormat = ma_format_from_prinfo__audio4(&fdInfo.record); internalChannels = fdInfo.record.channels; internalSampleRate = fdInfo.record.sample_rate; } else { internalFormat = ma_format_from_prinfo__audio4(&fdInfo.play); internalChannels = fdInfo.play.channels; internalSampleRate = fdInfo.play.sample_rate; } if (internalFormat == ma_format_unknown) { close(fd); ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[audio4] The device's internal device format is not supported by miniaudio. The device is unusable."); return MA_FORMAT_NOT_SUPPORTED; } /* Buffer. */ { ma_uint32 internalPeriodSizeInBytes; internalPeriodSizeInFrames = ma_calculate_buffer_size_in_frames_from_descriptor(pDescriptor, internalSampleRate, pConfig->performanceProfile); internalPeriodSizeInBytes = internalPeriodSizeInFrames * ma_get_bytes_per_frame(internalFormat, internalChannels); if (internalPeriodSizeInBytes < 16) { internalPeriodSizeInBytes = 16; } internalPeriods = pDescriptor->periodCount; if (internalPeriods < 2) { internalPeriods = 2; } /* What miniaudio calls a period, audio4 calls a block. */ AUDIO_INITINFO(&fdInfo); fdInfo.hiwat = internalPeriods; fdInfo.lowat = internalPeriods-1; fdInfo.blocksize = internalPeriodSizeInBytes; if (ioctl(fd, AUDIO_SETINFO, &fdInfo) < 0) { close(fd); ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[audio4] Failed to set internal buffer size. AUDIO_SETINFO failed."); return ma_result_from_errno(errno); } internalPeriods = fdInfo.hiwat; internalPeriodSizeInFrames = fdInfo.blocksize / ma_get_bytes_per_frame(internalFormat, internalChannels); } } #else { struct audio_swpar fdPar; /* We need to retrieve the format of the device so we can know the channel count and sample rate. Then we can calculate the buffer size. */ if (ioctl(fd, AUDIO_GETPAR, &fdPar) < 0) { close(fd); ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[audio4] Failed to retrieve initial device parameters."); return ma_result_from_errno(errno); } internalFormat = ma_format_from_swpar__audio4(&fdPar); internalChannels = (deviceType == ma_device_type_capture) ? fdPar.rchan : fdPar.pchan; internalSampleRate = fdPar.rate; if (internalFormat == ma_format_unknown) { close(fd); ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[audio4] The device's internal device format is not supported by miniaudio. The device is unusable."); return MA_FORMAT_NOT_SUPPORTED; } /* Buffer. */ { ma_uint32 internalPeriodSizeInBytes; internalPeriodSizeInFrames = ma_calculate_buffer_size_in_frames_from_descriptor(pDescriptor, internalSampleRate, pConfig->performanceProfile); /* What miniaudio calls a period, audio4 calls a block. */ internalPeriodSizeInBytes = internalPeriodSizeInFrames * ma_get_bytes_per_frame(internalFormat, internalChannels); if (internalPeriodSizeInBytes < 16) { internalPeriodSizeInBytes = 16; } fdPar.nblks = pDescriptor->periodCount; fdPar.round = internalPeriodSizeInBytes; if (ioctl(fd, AUDIO_SETPAR, &fdPar) < 0) { close(fd); ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[audio4] Failed to set device parameters."); return ma_result_from_errno(errno); } if (ioctl(fd, AUDIO_GETPAR, &fdPar) < 0) { close(fd); ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[audio4] Failed to retrieve actual device parameters."); return ma_result_from_errno(errno); } } internalFormat = ma_format_from_swpar__audio4(&fdPar); internalChannels = (deviceType == ma_device_type_capture) ? fdPar.rchan : fdPar.pchan; internalSampleRate = fdPar.rate; internalPeriods = fdPar.nblks; internalPeriodSizeInFrames = fdPar.round / ma_get_bytes_per_frame(internalFormat, internalChannels); } #endif if (internalFormat == ma_format_unknown) { close(fd); ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[audio4] The device's internal device format is not supported by miniaudio. The device is unusable."); return MA_FORMAT_NOT_SUPPORTED; } if (deviceType == ma_device_type_capture) { pDevice->audio4.fdCapture = fd; } else { pDevice->audio4.fdPlayback = fd; } pDescriptor->format = internalFormat; pDescriptor->channels = internalChannels; pDescriptor->sampleRate = internalSampleRate; ma_channel_map_init_standard(ma_standard_channel_map_sound4, pDescriptor->channelMap, ma_countof(pDescriptor->channelMap), internalChannels); pDescriptor->periodSizeInFrames = internalPeriodSizeInFrames; pDescriptor->periodCount = internalPeriods; return MA_SUCCESS; } static ma_result ma_device_init__audio4(ma_device* pDevice, const ma_device_config* pConfig, ma_device_descriptor* pDescriptorPlayback, ma_device_descriptor* pDescriptorCapture) { MA_ASSERT(pDevice != NULL); MA_ZERO_OBJECT(&pDevice->audio4); if (pConfig->deviceType == ma_device_type_loopback) { return MA_DEVICE_TYPE_NOT_SUPPORTED; } pDevice->audio4.fdCapture = -1; pDevice->audio4.fdPlayback = -1; /* The version of the operating system dictates whether or not the device is exclusive or shared. NetBSD introduced in-kernel mixing which means it's shared. All other BSD flavours are exclusive as far as I'm aware. */ #if defined(__NetBSD_Version__) && __NetBSD_Version__ >= 800000000 /* NetBSD 8.0+ */ if (((pConfig->deviceType == ma_device_type_playback || pConfig->deviceType == ma_device_type_duplex) && pDescriptorPlayback->shareMode == ma_share_mode_exclusive) || ((pConfig->deviceType == ma_device_type_capture || pConfig->deviceType == ma_device_type_duplex) && pDescriptorCapture->shareMode == ma_share_mode_exclusive)) { return MA_SHARE_MODE_NOT_SUPPORTED; } #else /* All other flavors. */ #endif if (pConfig->deviceType == ma_device_type_capture || pConfig->deviceType == ma_device_type_duplex) { ma_result result = ma_device_init_fd__audio4(pDevice, pConfig, pDescriptorCapture, ma_device_type_capture); if (result != MA_SUCCESS) { return result; } } if (pConfig->deviceType == ma_device_type_playback || pConfig->deviceType == ma_device_type_duplex) { ma_result result = ma_device_init_fd__audio4(pDevice, pConfig, pDescriptorPlayback, ma_device_type_playback); if (result != MA_SUCCESS) { if (pConfig->deviceType == ma_device_type_duplex) { close(pDevice->audio4.fdCapture); } return result; } } return MA_SUCCESS; } static ma_result ma_device_start__audio4(ma_device* pDevice) { MA_ASSERT(pDevice != NULL); if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) { if (pDevice->audio4.fdCapture == -1) { return MA_INVALID_ARGS; } } if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) { if (pDevice->audio4.fdPlayback == -1) { return MA_INVALID_ARGS; } } return MA_SUCCESS; } static ma_result ma_device_stop_fd__audio4(ma_device* pDevice, int fd) { if (fd == -1) { return MA_INVALID_ARGS; } #if !defined(MA_AUDIO4_USE_NEW_API) if (ioctl(fd, AUDIO_FLUSH, 0) < 0) { ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[audio4] Failed to stop device. AUDIO_FLUSH failed."); return ma_result_from_errno(errno); } #else if (ioctl(fd, AUDIO_STOP, 0) < 0) { ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[audio4] Failed to stop device. AUDIO_STOP failed."); return ma_result_from_errno(errno); } #endif return MA_SUCCESS; } static ma_result ma_device_stop__audio4(ma_device* pDevice) { MA_ASSERT(pDevice != NULL); if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) { ma_result result; result = ma_device_stop_fd__audio4(pDevice, pDevice->audio4.fdCapture); if (result != MA_SUCCESS) { return result; } } if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) { ma_result result; /* Drain the device first. If this fails we'll just need to flush without draining. Unfortunately draining isn't available on newer version of OpenBSD. */ #if !defined(MA_AUDIO4_USE_NEW_API) ioctl(pDevice->audio4.fdPlayback, AUDIO_DRAIN, 0); #endif /* Here is where the device is stopped immediately. */ result = ma_device_stop_fd__audio4(pDevice, pDevice->audio4.fdPlayback); if (result != MA_SUCCESS) { return result; } } return MA_SUCCESS; } static ma_result ma_device_write__audio4(ma_device* pDevice, const void* pPCMFrames, ma_uint32 frameCount, ma_uint32* pFramesWritten) { int result; if (pFramesWritten != NULL) { *pFramesWritten = 0; } result = write(pDevice->audio4.fdPlayback, pPCMFrames, frameCount * ma_get_bytes_per_frame(pDevice->playback.internalFormat, pDevice->playback.internalChannels)); if (result < 0) { ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[audio4] Failed to write data to the device."); return ma_result_from_errno(errno); } if (pFramesWritten != NULL) { *pFramesWritten = (ma_uint32)result / ma_get_bytes_per_frame(pDevice->playback.internalFormat, pDevice->playback.internalChannels); } return MA_SUCCESS; } static ma_result ma_device_read__audio4(ma_device* pDevice, void* pPCMFrames, ma_uint32 frameCount, ma_uint32* pFramesRead) { int result; if (pFramesRead != NULL) { *pFramesRead = 0; } result = read(pDevice->audio4.fdCapture, pPCMFrames, frameCount * ma_get_bytes_per_frame(pDevice->capture.internalFormat, pDevice->capture.internalChannels)); if (result < 0) { ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[audio4] Failed to read data from the device."); return ma_result_from_errno(errno); } if (pFramesRead != NULL) { *pFramesRead = (ma_uint32)result / ma_get_bytes_per_frame(pDevice->capture.internalFormat, pDevice->capture.internalChannels); } return MA_SUCCESS; } static ma_result ma_context_uninit__audio4(ma_context* pContext) { MA_ASSERT(pContext != NULL); MA_ASSERT(pContext->backend == ma_backend_audio4); (void)pContext; return MA_SUCCESS; } static ma_result ma_context_init__audio4(ma_context* pContext, const ma_context_config* pConfig, ma_backend_callbacks* pCallbacks) { MA_ASSERT(pContext != NULL); (void)pConfig; pCallbacks->onContextInit = ma_context_init__audio4; pCallbacks->onContextUninit = ma_context_uninit__audio4; pCallbacks->onContextEnumerateDevices = ma_context_enumerate_devices__audio4; pCallbacks->onContextGetDeviceInfo = ma_context_get_device_info__audio4; pCallbacks->onDeviceInit = ma_device_init__audio4; pCallbacks->onDeviceUninit = ma_device_uninit__audio4; pCallbacks->onDeviceStart = ma_device_start__audio4; pCallbacks->onDeviceStop = ma_device_stop__audio4; pCallbacks->onDeviceRead = ma_device_read__audio4; pCallbacks->onDeviceWrite = ma_device_write__audio4; pCallbacks->onDeviceDataLoop = NULL; return MA_SUCCESS; } #endif /* audio4 */ /****************************************************************************** OSS Backend ******************************************************************************/ #ifdef MA_HAS_OSS #include #include #include #include #ifndef SNDCTL_DSP_HALT #define SNDCTL_DSP_HALT SNDCTL_DSP_RESET #endif #define MA_OSS_DEFAULT_DEVICE_NAME "/dev/dsp" static int ma_open_temp_device__oss() { /* The OSS sample code uses "/dev/mixer" as the device for getting system properties so I'm going to do the same. */ int fd = open("/dev/mixer", O_RDONLY, 0); if (fd >= 0) { return fd; } return -1; } static ma_result ma_context_open_device__oss(ma_context* pContext, ma_device_type deviceType, const ma_device_id* pDeviceID, ma_share_mode shareMode, int* pfd) { const char* deviceName; int flags; MA_ASSERT(pContext != NULL); MA_ASSERT(pfd != NULL); (void)pContext; *pfd = -1; /* This function should only be called for playback or capture, not duplex. */ if (deviceType == ma_device_type_duplex) { return MA_INVALID_ARGS; } deviceName = MA_OSS_DEFAULT_DEVICE_NAME; if (pDeviceID != NULL) { deviceName = pDeviceID->oss; } flags = (deviceType == ma_device_type_playback) ? O_WRONLY : O_RDONLY; if (shareMode == ma_share_mode_exclusive) { flags |= O_EXCL; } *pfd = open(deviceName, flags, 0); if (*pfd == -1) { return ma_result_from_errno(errno); } return MA_SUCCESS; } static ma_result ma_context_enumerate_devices__oss(ma_context* pContext, ma_enum_devices_callback_proc callback, void* pUserData) { int fd; oss_sysinfo si; int result; MA_ASSERT(pContext != NULL); MA_ASSERT(callback != NULL); fd = ma_open_temp_device__oss(); if (fd == -1) { ma_log_post(ma_context_get_log(pContext), MA_LOG_LEVEL_ERROR, "[OSS] Failed to open a temporary device for retrieving system information used for device enumeration."); return MA_NO_BACKEND; } result = ioctl(fd, SNDCTL_SYSINFO, &si); if (result != -1) { int iAudioDevice; for (iAudioDevice = 0; iAudioDevice < si.numaudios; ++iAudioDevice) { oss_audioinfo ai; ai.dev = iAudioDevice; result = ioctl(fd, SNDCTL_AUDIOINFO, &ai); if (result != -1) { if (ai.devnode[0] != '\0') { /* <-- Can be blank, according to documentation. */ ma_device_info deviceInfo; ma_bool32 isTerminating = MA_FALSE; MA_ZERO_OBJECT(&deviceInfo); /* ID */ ma_strncpy_s(deviceInfo.id.oss, sizeof(deviceInfo.id.oss), ai.devnode, (size_t)-1); /* The human readable device name should be in the "ai.handle" variable, but it can sometimes be empty in which case we just fall back to "ai.name" which is less user friendly, but usually has a value. */ if (ai.handle[0] != '\0') { ma_strncpy_s(deviceInfo.name, sizeof(deviceInfo.name), ai.handle, (size_t)-1); } else { ma_strncpy_s(deviceInfo.name, sizeof(deviceInfo.name), ai.name, (size_t)-1); } /* The device can be both playback and capture. */ if (!isTerminating && (ai.caps & PCM_CAP_OUTPUT) != 0) { isTerminating = !callback(pContext, ma_device_type_playback, &deviceInfo, pUserData); } if (!isTerminating && (ai.caps & PCM_CAP_INPUT) != 0) { isTerminating = !callback(pContext, ma_device_type_capture, &deviceInfo, pUserData); } if (isTerminating) { break; } } } } } else { close(fd); ma_log_post(ma_context_get_log(pContext), MA_LOG_LEVEL_ERROR, "[OSS] Failed to retrieve system information for device enumeration."); return MA_NO_BACKEND; } close(fd); return MA_SUCCESS; } static void ma_context_add_native_data_format__oss(ma_context* pContext, oss_audioinfo* pAudioInfo, ma_format format, ma_device_info* pDeviceInfo) { unsigned int minChannels; unsigned int maxChannels; unsigned int iRate; MA_ASSERT(pContext != NULL); MA_ASSERT(pAudioInfo != NULL); MA_ASSERT(pDeviceInfo != NULL); /* If we support all channels we just report 0. */ minChannels = ma_clamp(pAudioInfo->min_channels, MA_MIN_CHANNELS, MA_MAX_CHANNELS); maxChannels = ma_clamp(pAudioInfo->max_channels, MA_MIN_CHANNELS, MA_MAX_CHANNELS); /* OSS has this annoying thing where sample rates can be reported in two ways. We prefer explicitness, which OSS has in the form of nrates/rates, however there are times where nrates can be 0, in which case we'll need to use min_rate and max_rate and report only standard rates. */ if (pAudioInfo->nrates > 0) { for (iRate = 0; iRate < pAudioInfo->nrates; iRate += 1) { unsigned int rate = pAudioInfo->rates[iRate]; if (minChannels == MA_MIN_CHANNELS && maxChannels == MA_MAX_CHANNELS) { ma_device_info_add_native_data_format(pDeviceInfo, format, 0, rate, 0); /* Set the channel count to 0 to indicate that all channel counts are supported. */ } else { unsigned int iChannel; for (iChannel = minChannels; iChannel <= maxChannels; iChannel += 1) { ma_device_info_add_native_data_format(pDeviceInfo, format, iChannel, rate, 0); } } } } else { for (iRate = 0; iRate < ma_countof(g_maStandardSampleRatePriorities); iRate += 1) { ma_uint32 standardRate = g_maStandardSampleRatePriorities[iRate]; if (standardRate >= (ma_uint32)pAudioInfo->min_rate && standardRate <= (ma_uint32)pAudioInfo->max_rate) { if (minChannels == MA_MIN_CHANNELS && maxChannels == MA_MAX_CHANNELS) { ma_device_info_add_native_data_format(pDeviceInfo, format, 0, standardRate, 0); /* Set the channel count to 0 to indicate that all channel counts are supported. */ } else { unsigned int iChannel; for (iChannel = minChannels; iChannel <= maxChannels; iChannel += 1) { ma_device_info_add_native_data_format(pDeviceInfo, format, iChannel, standardRate, 0); } } } } } } static ma_result ma_context_get_device_info__oss(ma_context* pContext, ma_device_type deviceType, const ma_device_id* pDeviceID, ma_device_info* pDeviceInfo) { ma_bool32 foundDevice; int fdTemp; oss_sysinfo si; int result; MA_ASSERT(pContext != NULL); /* Handle the default device a little differently. */ if (pDeviceID == NULL) { if (deviceType == ma_device_type_playback) { ma_strncpy_s(pDeviceInfo->name, sizeof(pDeviceInfo->name), MA_DEFAULT_PLAYBACK_DEVICE_NAME, (size_t)-1); } else { ma_strncpy_s(pDeviceInfo->name, sizeof(pDeviceInfo->name), MA_DEFAULT_CAPTURE_DEVICE_NAME, (size_t)-1); } return MA_SUCCESS; } /* If we get here it means we are _not_ using the default device. */ foundDevice = MA_FALSE; fdTemp = ma_open_temp_device__oss(); if (fdTemp == -1) { ma_log_post(ma_context_get_log(pContext), MA_LOG_LEVEL_ERROR, "[OSS] Failed to open a temporary device for retrieving system information used for device enumeration."); return MA_NO_BACKEND; } result = ioctl(fdTemp, SNDCTL_SYSINFO, &si); if (result != -1) { int iAudioDevice; for (iAudioDevice = 0; iAudioDevice < si.numaudios; ++iAudioDevice) { oss_audioinfo ai; ai.dev = iAudioDevice; result = ioctl(fdTemp, SNDCTL_AUDIOINFO, &ai); if (result != -1) { if (ma_strcmp(ai.devnode, pDeviceID->oss) == 0) { /* It has the same name, so now just confirm the type. */ if ((deviceType == ma_device_type_playback && ((ai.caps & PCM_CAP_OUTPUT) != 0)) || (deviceType == ma_device_type_capture && ((ai.caps & PCM_CAP_INPUT) != 0))) { unsigned int formatMask; /* ID */ ma_strncpy_s(pDeviceInfo->id.oss, sizeof(pDeviceInfo->id.oss), ai.devnode, (size_t)-1); /* The human readable device name should be in the "ai.handle" variable, but it can sometimes be empty in which case we just fall back to "ai.name" which is less user friendly, but usually has a value. */ if (ai.handle[0] != '\0') { ma_strncpy_s(pDeviceInfo->name, sizeof(pDeviceInfo->name), ai.handle, (size_t)-1); } else { ma_strncpy_s(pDeviceInfo->name, sizeof(pDeviceInfo->name), ai.name, (size_t)-1); } pDeviceInfo->nativeDataFormatCount = 0; if (deviceType == ma_device_type_playback) { formatMask = ai.oformats; } else { formatMask = ai.iformats; } if (((formatMask & AFMT_S16_LE) != 0 && ma_is_little_endian()) || (AFMT_S16_BE && ma_is_big_endian())) { ma_context_add_native_data_format__oss(pContext, &ai, ma_format_s16, pDeviceInfo); } if (((formatMask & AFMT_S32_LE) != 0 && ma_is_little_endian()) || (AFMT_S32_BE && ma_is_big_endian())) { ma_context_add_native_data_format__oss(pContext, &ai, ma_format_s32, pDeviceInfo); } if ((formatMask & AFMT_U8) != 0) { ma_context_add_native_data_format__oss(pContext, &ai, ma_format_u8, pDeviceInfo); } foundDevice = MA_TRUE; break; } } } } } else { close(fdTemp); ma_log_post(ma_context_get_log(pContext), MA_LOG_LEVEL_ERROR, "[OSS] Failed to retrieve system information for device enumeration."); return MA_NO_BACKEND; } close(fdTemp); if (!foundDevice) { return MA_NO_DEVICE; } return MA_SUCCESS; } static ma_result ma_device_uninit__oss(ma_device* pDevice) { MA_ASSERT(pDevice != NULL); if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) { close(pDevice->oss.fdCapture); } if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) { close(pDevice->oss.fdPlayback); } return MA_SUCCESS; } static int ma_format_to_oss(ma_format format) { int ossFormat = AFMT_U8; switch (format) { case ma_format_s16: ossFormat = (ma_is_little_endian()) ? AFMT_S16_LE : AFMT_S16_BE; break; case ma_format_s24: ossFormat = (ma_is_little_endian()) ? AFMT_S32_LE : AFMT_S32_BE; break; case ma_format_s32: ossFormat = (ma_is_little_endian()) ? AFMT_S32_LE : AFMT_S32_BE; break; case ma_format_f32: ossFormat = (ma_is_little_endian()) ? AFMT_S16_LE : AFMT_S16_BE; break; case ma_format_u8: default: ossFormat = AFMT_U8; break; } return ossFormat; } static ma_format ma_format_from_oss(int ossFormat) { if (ossFormat == AFMT_U8) { return ma_format_u8; } else { if (ma_is_little_endian()) { switch (ossFormat) { case AFMT_S16_LE: return ma_format_s16; case AFMT_S32_LE: return ma_format_s32; default: return ma_format_unknown; } } else { switch (ossFormat) { case AFMT_S16_BE: return ma_format_s16; case AFMT_S32_BE: return ma_format_s32; default: return ma_format_unknown; } } } return ma_format_unknown; } static ma_result ma_device_init_fd__oss(ma_device* pDevice, const ma_device_config* pConfig, ma_device_descriptor* pDescriptor, ma_device_type deviceType) { ma_result result; int ossResult; int fd; const ma_device_id* pDeviceID = NULL; ma_share_mode shareMode; int ossFormat; int ossChannels; int ossSampleRate; int ossFragment; MA_ASSERT(pDevice != NULL); MA_ASSERT(pConfig != NULL); MA_ASSERT(deviceType != ma_device_type_duplex); pDeviceID = pDescriptor->pDeviceID; shareMode = pDescriptor->shareMode; ossFormat = ma_format_to_oss((pDescriptor->format != ma_format_unknown) ? pDescriptor->format : ma_format_s16); /* Use s16 by default because OSS doesn't like floating point. */ ossChannels = (int)(pDescriptor->channels > 0) ? pDescriptor->channels : MA_DEFAULT_CHANNELS; ossSampleRate = (int)(pDescriptor->sampleRate > 0) ? pDescriptor->sampleRate : MA_DEFAULT_SAMPLE_RATE; result = ma_context_open_device__oss(pDevice->pContext, deviceType, pDeviceID, shareMode, &fd); if (result != MA_SUCCESS) { ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[OSS] Failed to open device."); return result; } /* The OSS documantation is very clear about the order we should be initializing the device's properties: 1) Format 2) Channels 3) Sample rate. */ /* Format. */ ossResult = ioctl(fd, SNDCTL_DSP_SETFMT, &ossFormat); if (ossResult == -1) { close(fd); ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[OSS] Failed to set format."); return ma_result_from_errno(errno); } /* Channels. */ ossResult = ioctl(fd, SNDCTL_DSP_CHANNELS, &ossChannels); if (ossResult == -1) { close(fd); ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[OSS] Failed to set channel count."); return ma_result_from_errno(errno); } /* Sample Rate. */ ossResult = ioctl(fd, SNDCTL_DSP_SPEED, &ossSampleRate); if (ossResult == -1) { close(fd); ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[OSS] Failed to set sample rate."); return ma_result_from_errno(errno); } /* Buffer. The documentation says that the fragment settings should be set as soon as possible, but I'm not sure if it should be done before or after format/channels/rate. OSS wants the fragment size in bytes and a power of 2. When setting, we specify the power, not the actual value. */ { ma_uint32 periodSizeInFrames; ma_uint32 periodSizeInBytes; ma_uint32 ossFragmentSizePower; periodSizeInFrames = ma_calculate_buffer_size_in_frames_from_descriptor(pDescriptor, (ma_uint32)ossSampleRate, pConfig->performanceProfile); periodSizeInBytes = ma_round_to_power_of_2(periodSizeInFrames * ma_get_bytes_per_frame(ma_format_from_oss(ossFormat), ossChannels)); if (periodSizeInBytes < 16) { periodSizeInBytes = 16; } ossFragmentSizePower = 4; periodSizeInBytes >>= 4; while (periodSizeInBytes >>= 1) { ossFragmentSizePower += 1; } ossFragment = (int)((pConfig->periods << 16) | ossFragmentSizePower); ossResult = ioctl(fd, SNDCTL_DSP_SETFRAGMENT, &ossFragment); if (ossResult == -1) { close(fd); ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[OSS] Failed to set fragment size and period count."); return ma_result_from_errno(errno); } } /* Internal settings. */ if (deviceType == ma_device_type_capture) { pDevice->oss.fdCapture = fd; } else { pDevice->oss.fdPlayback = fd; } pDescriptor->format = ma_format_from_oss(ossFormat); pDescriptor->channels = ossChannels; pDescriptor->sampleRate = ossSampleRate; ma_channel_map_init_standard(ma_standard_channel_map_sound4, pDescriptor->channelMap, ma_countof(pDescriptor->channelMap), pDescriptor->channels); pDescriptor->periodCount = (ma_uint32)(ossFragment >> 16); pDescriptor->periodSizeInFrames = (ma_uint32)(1 << (ossFragment & 0xFFFF)) / ma_get_bytes_per_frame(pDescriptor->format, pDescriptor->channels); if (pDescriptor->format == ma_format_unknown) { ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[OSS] The device's internal format is not supported by miniaudio."); return MA_FORMAT_NOT_SUPPORTED; } return MA_SUCCESS; } static ma_result ma_device_init__oss(ma_device* pDevice, const ma_device_config* pConfig, ma_device_descriptor* pDescriptorPlayback, ma_device_descriptor* pDescriptorCapture) { MA_ASSERT(pDevice != NULL); MA_ASSERT(pConfig != NULL); MA_ZERO_OBJECT(&pDevice->oss); if (pConfig->deviceType == ma_device_type_loopback) { return MA_DEVICE_TYPE_NOT_SUPPORTED; } if (pConfig->deviceType == ma_device_type_capture || pConfig->deviceType == ma_device_type_duplex) { ma_result result = ma_device_init_fd__oss(pDevice, pConfig, pDescriptorCapture, ma_device_type_capture); if (result != MA_SUCCESS) { ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[OSS] Failed to open device."); return result; } } if (pConfig->deviceType == ma_device_type_playback || pConfig->deviceType == ma_device_type_duplex) { ma_result result = ma_device_init_fd__oss(pDevice, pConfig, pDescriptorPlayback, ma_device_type_playback); if (result != MA_SUCCESS) { ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[OSS] Failed to open device."); return result; } } return MA_SUCCESS; } /* Note on Starting and Stopping ============================= In the past I was using SNDCTL_DSP_HALT to stop the device, however this results in issues when trying to resume the device again. If we use SNDCTL_DSP_HALT, the next write() or read() will fail. Instead what we need to do is just not write or read to and from the device when the device is not running. As a result, both the start and stop functions for OSS are just empty stubs. The starting and stopping logic is handled by ma_device_write__oss() and ma_device_read__oss(). These will check the device state, and if the device is stopped they will simply not do any kind of processing. The downside to this technique is that I've noticed a fairly lengthy delay in stopping the device, up to a second. This is on a virtual machine, and as such might just be due to the virtual drivers, but I'm not fully sure. I am not sure how to work around this problem so for the moment that's just how it's going to have to be. When starting the device, OSS will automatically start it when write() or read() is called. */ static ma_result ma_device_start__oss(ma_device* pDevice) { MA_ASSERT(pDevice != NULL); /* The device is automatically started with reading and writing. */ (void)pDevice; return MA_SUCCESS; } static ma_result ma_device_stop__oss(ma_device* pDevice) { MA_ASSERT(pDevice != NULL); /* See note above on why this is empty. */ (void)pDevice; return MA_SUCCESS; } static ma_result ma_device_write__oss(ma_device* pDevice, const void* pPCMFrames, ma_uint32 frameCount, ma_uint32* pFramesWritten) { int resultOSS; ma_uint32 deviceState; if (pFramesWritten != NULL) { *pFramesWritten = 0; } /* Don't do any processing if the device is stopped. */ deviceState = ma_device_get_state(pDevice); if (deviceState != ma_device_state_started && deviceState != ma_device_state_starting) { return MA_SUCCESS; } resultOSS = write(pDevice->oss.fdPlayback, pPCMFrames, frameCount * ma_get_bytes_per_frame(pDevice->playback.internalFormat, pDevice->playback.internalChannels)); if (resultOSS < 0) { ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[OSS] Failed to send data from the client to the device."); return ma_result_from_errno(errno); } if (pFramesWritten != NULL) { *pFramesWritten = (ma_uint32)resultOSS / ma_get_bytes_per_frame(pDevice->playback.internalFormat, pDevice->playback.internalChannels); } return MA_SUCCESS; } static ma_result ma_device_read__oss(ma_device* pDevice, void* pPCMFrames, ma_uint32 frameCount, ma_uint32* pFramesRead) { int resultOSS; ma_uint32 deviceState; if (pFramesRead != NULL) { *pFramesRead = 0; } /* Don't do any processing if the device is stopped. */ deviceState = ma_device_get_state(pDevice); if (deviceState != ma_device_state_started && deviceState != ma_device_state_starting) { return MA_SUCCESS; } resultOSS = read(pDevice->oss.fdCapture, pPCMFrames, frameCount * ma_get_bytes_per_frame(pDevice->capture.internalFormat, pDevice->capture.internalChannels)); if (resultOSS < 0) { ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[OSS] Failed to read data from the device to be sent to the client."); return ma_result_from_errno(errno); } if (pFramesRead != NULL) { *pFramesRead = (ma_uint32)resultOSS / ma_get_bytes_per_frame(pDevice->capture.internalFormat, pDevice->capture.internalChannels); } return MA_SUCCESS; } static ma_result ma_context_uninit__oss(ma_context* pContext) { MA_ASSERT(pContext != NULL); MA_ASSERT(pContext->backend == ma_backend_oss); (void)pContext; return MA_SUCCESS; } static ma_result ma_context_init__oss(ma_context* pContext, const ma_context_config* pConfig, ma_backend_callbacks* pCallbacks) { int fd; int ossVersion; int result; MA_ASSERT(pContext != NULL); (void)pConfig; /* Try opening a temporary device first so we can get version information. This is closed at the end. */ fd = ma_open_temp_device__oss(); if (fd == -1) { ma_log_post(ma_context_get_log(pContext), MA_LOG_LEVEL_ERROR, "[OSS] Failed to open temporary device for retrieving system properties."); /* Looks liks OSS isn't installed, or there are no available devices. */ return MA_NO_BACKEND; } /* Grab the OSS version. */ ossVersion = 0; result = ioctl(fd, OSS_GETVERSION, &ossVersion); if (result == -1) { close(fd); ma_log_post(ma_context_get_log(pContext), MA_LOG_LEVEL_ERROR, "[OSS] Failed to retrieve OSS version."); return MA_NO_BACKEND; } /* The file handle to temp device is no longer needed. Close ASAP. */ close(fd); pContext->oss.versionMajor = ((ossVersion & 0xFF0000) >> 16); pContext->oss.versionMinor = ((ossVersion & 0x00FF00) >> 8); pCallbacks->onContextInit = ma_context_init__oss; pCallbacks->onContextUninit = ma_context_uninit__oss; pCallbacks->onContextEnumerateDevices = ma_context_enumerate_devices__oss; pCallbacks->onContextGetDeviceInfo = ma_context_get_device_info__oss; pCallbacks->onDeviceInit = ma_device_init__oss; pCallbacks->onDeviceUninit = ma_device_uninit__oss; pCallbacks->onDeviceStart = ma_device_start__oss; pCallbacks->onDeviceStop = ma_device_stop__oss; pCallbacks->onDeviceRead = ma_device_read__oss; pCallbacks->onDeviceWrite = ma_device_write__oss; pCallbacks->onDeviceDataLoop = NULL; return MA_SUCCESS; } #endif /* OSS */ /****************************************************************************** AAudio Backend ******************************************************************************/ #ifdef MA_HAS_AAUDIO /*#include */ typedef int32_t ma_aaudio_result_t; typedef int32_t ma_aaudio_direction_t; typedef int32_t ma_aaudio_sharing_mode_t; typedef int32_t ma_aaudio_format_t; typedef int32_t ma_aaudio_stream_state_t; typedef int32_t ma_aaudio_performance_mode_t; typedef int32_t ma_aaudio_usage_t; typedef int32_t ma_aaudio_content_type_t; typedef int32_t ma_aaudio_input_preset_t; typedef int32_t ma_aaudio_allowed_capture_policy_t; typedef int32_t ma_aaudio_data_callback_result_t; typedef struct ma_AAudioStreamBuilder_t* ma_AAudioStreamBuilder; typedef struct ma_AAudioStream_t* ma_AAudioStream; #define MA_AAUDIO_UNSPECIFIED 0 /* Result codes. miniaudio only cares about the success code. */ #define MA_AAUDIO_OK 0 /* Directions. */ #define MA_AAUDIO_DIRECTION_OUTPUT 0 #define MA_AAUDIO_DIRECTION_INPUT 1 /* Sharing modes. */ #define MA_AAUDIO_SHARING_MODE_EXCLUSIVE 0 #define MA_AAUDIO_SHARING_MODE_SHARED 1 /* Formats. */ #define MA_AAUDIO_FORMAT_PCM_I16 1 #define MA_AAUDIO_FORMAT_PCM_FLOAT 2 /* Stream states. */ #define MA_AAUDIO_STREAM_STATE_UNINITIALIZED 0 #define MA_AAUDIO_STREAM_STATE_UNKNOWN 1 #define MA_AAUDIO_STREAM_STATE_OPEN 2 #define MA_AAUDIO_STREAM_STATE_STARTING 3 #define MA_AAUDIO_STREAM_STATE_STARTED 4 #define MA_AAUDIO_STREAM_STATE_PAUSING 5 #define MA_AAUDIO_STREAM_STATE_PAUSED 6 #define MA_AAUDIO_STREAM_STATE_FLUSHING 7 #define MA_AAUDIO_STREAM_STATE_FLUSHED 8 #define MA_AAUDIO_STREAM_STATE_STOPPING 9 #define MA_AAUDIO_STREAM_STATE_STOPPED 10 #define MA_AAUDIO_STREAM_STATE_CLOSING 11 #define MA_AAUDIO_STREAM_STATE_CLOSED 12 #define MA_AAUDIO_STREAM_STATE_DISCONNECTED 13 /* Performance modes. */ #define MA_AAUDIO_PERFORMANCE_MODE_NONE 10 #define MA_AAUDIO_PERFORMANCE_MODE_POWER_SAVING 11 #define MA_AAUDIO_PERFORMANCE_MODE_LOW_LATENCY 12 /* Usage types. */ #define MA_AAUDIO_USAGE_MEDIA 1 #define MA_AAUDIO_USAGE_VOICE_COMMUNICATION 2 #define MA_AAUDIO_USAGE_VOICE_COMMUNICATION_SIGNALLING 3 #define MA_AAUDIO_USAGE_ALARM 4 #define MA_AAUDIO_USAGE_NOTIFICATION 5 #define MA_AAUDIO_USAGE_NOTIFICATION_RINGTONE 6 #define MA_AAUDIO_USAGE_NOTIFICATION_EVENT 10 #define MA_AAUDIO_USAGE_ASSISTANCE_ACCESSIBILITY 11 #define MA_AAUDIO_USAGE_ASSISTANCE_NAVIGATION_GUIDANCE 12 #define MA_AAUDIO_USAGE_ASSISTANCE_SONIFICATION 13 #define MA_AAUDIO_USAGE_GAME 14 #define MA_AAUDIO_USAGE_ASSISTANT 16 #define MA_AAUDIO_SYSTEM_USAGE_EMERGENCY 1000 #define MA_AAUDIO_SYSTEM_USAGE_SAFETY 1001 #define MA_AAUDIO_SYSTEM_USAGE_VEHICLE_STATUS 1002 #define MA_AAUDIO_SYSTEM_USAGE_ANNOUNCEMENT 1003 /* Content types. */ #define MA_AAUDIO_CONTENT_TYPE_SPEECH 1 #define MA_AAUDIO_CONTENT_TYPE_MUSIC 2 #define MA_AAUDIO_CONTENT_TYPE_MOVIE 3 #define MA_AAUDIO_CONTENT_TYPE_SONIFICATION 4 /* Input presets. */ #define MA_AAUDIO_INPUT_PRESET_GENERIC 1 #define MA_AAUDIO_INPUT_PRESET_CAMCORDER 5 #define MA_AAUDIO_INPUT_PRESET_VOICE_RECOGNITION 6 #define MA_AAUDIO_INPUT_PRESET_VOICE_COMMUNICATION 7 #define MA_AAUDIO_INPUT_PRESET_UNPROCESSED 9 #define MA_AAUDIO_INPUT_PRESET_VOICE_PERFORMANCE 10 /* Allowed Capture Policies */ #define MA_AAUDIO_ALLOW_CAPTURE_BY_ALL 1 #define MA_AAUDIO_ALLOW_CAPTURE_BY_SYSTEM 2 #define MA_AAUDIO_ALLOW_CAPTURE_BY_NONE 3 /* Callback results. */ #define MA_AAUDIO_CALLBACK_RESULT_CONTINUE 0 #define MA_AAUDIO_CALLBACK_RESULT_STOP 1 typedef ma_aaudio_data_callback_result_t (* ma_AAudioStream_dataCallback) (ma_AAudioStream* pStream, void* pUserData, void* pAudioData, int32_t numFrames); typedef void (* ma_AAudioStream_errorCallback)(ma_AAudioStream *pStream, void *pUserData, ma_aaudio_result_t error); typedef ma_aaudio_result_t (* MA_PFN_AAudio_createStreamBuilder) (ma_AAudioStreamBuilder** ppBuilder); typedef ma_aaudio_result_t (* MA_PFN_AAudioStreamBuilder_delete) (ma_AAudioStreamBuilder* pBuilder); typedef void (* MA_PFN_AAudioStreamBuilder_setDeviceId) (ma_AAudioStreamBuilder* pBuilder, int32_t deviceId); typedef void (* MA_PFN_AAudioStreamBuilder_setDirection) (ma_AAudioStreamBuilder* pBuilder, ma_aaudio_direction_t direction); typedef void (* MA_PFN_AAudioStreamBuilder_setSharingMode) (ma_AAudioStreamBuilder* pBuilder, ma_aaudio_sharing_mode_t sharingMode); typedef void (* MA_PFN_AAudioStreamBuilder_setFormat) (ma_AAudioStreamBuilder* pBuilder, ma_aaudio_format_t format); typedef void (* MA_PFN_AAudioStreamBuilder_setChannelCount) (ma_AAudioStreamBuilder* pBuilder, int32_t channelCount); typedef void (* MA_PFN_AAudioStreamBuilder_setSampleRate) (ma_AAudioStreamBuilder* pBuilder, int32_t sampleRate); typedef void (* MA_PFN_AAudioStreamBuilder_setBufferCapacityInFrames)(ma_AAudioStreamBuilder* pBuilder, int32_t numFrames); typedef void (* MA_PFN_AAudioStreamBuilder_setFramesPerDataCallback) (ma_AAudioStreamBuilder* pBuilder, int32_t numFrames); typedef void (* MA_PFN_AAudioStreamBuilder_setDataCallback) (ma_AAudioStreamBuilder* pBuilder, ma_AAudioStream_dataCallback callback, void* pUserData); typedef void (* MA_PFN_AAudioStreamBuilder_setErrorCallback) (ma_AAudioStreamBuilder* pBuilder, ma_AAudioStream_errorCallback callback, void* pUserData); typedef void (* MA_PFN_AAudioStreamBuilder_setPerformanceMode) (ma_AAudioStreamBuilder* pBuilder, ma_aaudio_performance_mode_t mode); typedef void (* MA_PFN_AAudioStreamBuilder_setUsage) (ma_AAudioStreamBuilder* pBuilder, ma_aaudio_usage_t contentType); typedef void (* MA_PFN_AAudioStreamBuilder_setContentType) (ma_AAudioStreamBuilder* pBuilder, ma_aaudio_content_type_t contentType); typedef void (* MA_PFN_AAudioStreamBuilder_setInputPreset) (ma_AAudioStreamBuilder* pBuilder, ma_aaudio_input_preset_t inputPreset); typedef void (* MA_PFN_AAudioStreamBuilder_setAllowedCapturePolicy) (ma_AAudioStreamBuilder* pBuilder, ma_aaudio_allowed_capture_policy_t policy); typedef ma_aaudio_result_t (* MA_PFN_AAudioStreamBuilder_openStream) (ma_AAudioStreamBuilder* pBuilder, ma_AAudioStream** ppStream); typedef ma_aaudio_result_t (* MA_PFN_AAudioStream_close) (ma_AAudioStream* pStream); typedef ma_aaudio_stream_state_t (* MA_PFN_AAudioStream_getState) (ma_AAudioStream* pStream); typedef ma_aaudio_result_t (* MA_PFN_AAudioStream_waitForStateChange) (ma_AAudioStream* pStream, ma_aaudio_stream_state_t inputState, ma_aaudio_stream_state_t* pNextState, int64_t timeoutInNanoseconds); typedef ma_aaudio_format_t (* MA_PFN_AAudioStream_getFormat) (ma_AAudioStream* pStream); typedef int32_t (* MA_PFN_AAudioStream_getChannelCount) (ma_AAudioStream* pStream); typedef int32_t (* MA_PFN_AAudioStream_getSampleRate) (ma_AAudioStream* pStream); typedef int32_t (* MA_PFN_AAudioStream_getBufferCapacityInFrames) (ma_AAudioStream* pStream); typedef int32_t (* MA_PFN_AAudioStream_getFramesPerDataCallback) (ma_AAudioStream* pStream); typedef int32_t (* MA_PFN_AAudioStream_getFramesPerBurst) (ma_AAudioStream* pStream); typedef ma_aaudio_result_t (* MA_PFN_AAudioStream_requestStart) (ma_AAudioStream* pStream); typedef ma_aaudio_result_t (* MA_PFN_AAudioStream_requestStop) (ma_AAudioStream* pStream); static ma_result ma_result_from_aaudio(ma_aaudio_result_t resultAA) { switch (resultAA) { case MA_AAUDIO_OK: return MA_SUCCESS; default: break; } return MA_ERROR; } static ma_aaudio_usage_t ma_to_usage__aaudio(ma_aaudio_usage usage) { switch (usage) { case ma_aaudio_usage_media: return MA_AAUDIO_USAGE_MEDIA; case ma_aaudio_usage_voice_communication: return MA_AAUDIO_USAGE_VOICE_COMMUNICATION; case ma_aaudio_usage_voice_communication_signalling: return MA_AAUDIO_USAGE_VOICE_COMMUNICATION_SIGNALLING; case ma_aaudio_usage_alarm: return MA_AAUDIO_USAGE_ALARM; case ma_aaudio_usage_notification: return MA_AAUDIO_USAGE_NOTIFICATION; case ma_aaudio_usage_notification_ringtone: return MA_AAUDIO_USAGE_NOTIFICATION_RINGTONE; case ma_aaudio_usage_notification_event: return MA_AAUDIO_USAGE_NOTIFICATION_EVENT; case ma_aaudio_usage_assistance_accessibility: return MA_AAUDIO_USAGE_ASSISTANCE_ACCESSIBILITY; case ma_aaudio_usage_assistance_navigation_guidance: return MA_AAUDIO_USAGE_ASSISTANCE_NAVIGATION_GUIDANCE; case ma_aaudio_usage_assistance_sonification: return MA_AAUDIO_USAGE_ASSISTANCE_SONIFICATION; case ma_aaudio_usage_game: return MA_AAUDIO_USAGE_GAME; case ma_aaudio_usage_assitant: return MA_AAUDIO_USAGE_ASSISTANT; case ma_aaudio_usage_emergency: return MA_AAUDIO_SYSTEM_USAGE_EMERGENCY; case ma_aaudio_usage_safety: return MA_AAUDIO_SYSTEM_USAGE_SAFETY; case ma_aaudio_usage_vehicle_status: return MA_AAUDIO_SYSTEM_USAGE_VEHICLE_STATUS; case ma_aaudio_usage_announcement: return MA_AAUDIO_SYSTEM_USAGE_ANNOUNCEMENT; default: break; } return MA_AAUDIO_USAGE_MEDIA; } static ma_aaudio_content_type_t ma_to_content_type__aaudio(ma_aaudio_content_type contentType) { switch (contentType) { case ma_aaudio_content_type_speech: return MA_AAUDIO_CONTENT_TYPE_SPEECH; case ma_aaudio_content_type_music: return MA_AAUDIO_CONTENT_TYPE_MUSIC; case ma_aaudio_content_type_movie: return MA_AAUDIO_CONTENT_TYPE_MOVIE; case ma_aaudio_content_type_sonification: return MA_AAUDIO_CONTENT_TYPE_SONIFICATION; default: break; } return MA_AAUDIO_CONTENT_TYPE_SPEECH; } static ma_aaudio_input_preset_t ma_to_input_preset__aaudio(ma_aaudio_input_preset inputPreset) { switch (inputPreset) { case ma_aaudio_input_preset_generic: return MA_AAUDIO_INPUT_PRESET_GENERIC; case ma_aaudio_input_preset_camcorder: return MA_AAUDIO_INPUT_PRESET_CAMCORDER; case ma_aaudio_input_preset_voice_recognition: return MA_AAUDIO_INPUT_PRESET_VOICE_RECOGNITION; case ma_aaudio_input_preset_voice_communication: return MA_AAUDIO_INPUT_PRESET_VOICE_COMMUNICATION; case ma_aaudio_input_preset_unprocessed: return MA_AAUDIO_INPUT_PRESET_UNPROCESSED; case ma_aaudio_input_preset_voice_performance: return MA_AAUDIO_INPUT_PRESET_VOICE_PERFORMANCE; default: break; } return MA_AAUDIO_INPUT_PRESET_GENERIC; } static ma_aaudio_allowed_capture_policy_t ma_to_allowed_capture_policy__aaudio(ma_aaudio_allowed_capture_policy allowedCapturePolicy) { switch (allowedCapturePolicy) { case ma_aaudio_allow_capture_by_all: return MA_AAUDIO_ALLOW_CAPTURE_BY_ALL; case ma_aaudio_allow_capture_by_system: return MA_AAUDIO_ALLOW_CAPTURE_BY_SYSTEM; case ma_aaudio_allow_capture_by_none: return MA_AAUDIO_ALLOW_CAPTURE_BY_NONE; default: break; } return MA_AAUDIO_ALLOW_CAPTURE_BY_ALL; } static void ma_stream_error_callback__aaudio(ma_AAudioStream* pStream, void* pUserData, ma_aaudio_result_t error) { ma_result result; ma_job job; ma_device* pDevice = (ma_device*)pUserData; MA_ASSERT(pDevice != NULL); (void)error; ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_INFO, "[AAudio] ERROR CALLBACK: error=%d, AAudioStream_getState()=%d\n", error, ((MA_PFN_AAudioStream_getState)pDevice->pContext->aaudio.AAudioStream_getState)(pStream)); /* When we get an error, we'll assume that the stream is in an erroneous state and needs to be restarted. From the documentation, we cannot do this from the error callback. Therefore we are going to use an event thread for the AAudio backend to do this cleanly and safely. */ job = ma_job_init(MA_JOB_TYPE_DEVICE_AAUDIO_REROUTE); job.data.device.aaudio.reroute.pDevice = pDevice; if (pStream == pDevice->aaudio.pStreamCapture) { job.data.device.aaudio.reroute.deviceType = ma_device_type_capture; } else { job.data.device.aaudio.reroute.deviceType = ma_device_type_playback; } result = ma_device_job_thread_post(&pDevice->pContext->aaudio.jobThread, &job); if (result != MA_SUCCESS) { ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_INFO, "[AAudio] Device Disconnected. Failed to post job for rerouting.\n"); return; } } static ma_aaudio_data_callback_result_t ma_stream_data_callback_capture__aaudio(ma_AAudioStream* pStream, void* pUserData, void* pAudioData, int32_t frameCount) { ma_device* pDevice = (ma_device*)pUserData; MA_ASSERT(pDevice != NULL); ma_device_handle_backend_data_callback(pDevice, NULL, pAudioData, frameCount); (void)pStream; return MA_AAUDIO_CALLBACK_RESULT_CONTINUE; } static ma_aaudio_data_callback_result_t ma_stream_data_callback_playback__aaudio(ma_AAudioStream* pStream, void* pUserData, void* pAudioData, int32_t frameCount) { ma_device* pDevice = (ma_device*)pUserData; MA_ASSERT(pDevice != NULL); ma_device_handle_backend_data_callback(pDevice, pAudioData, NULL, frameCount); (void)pStream; return MA_AAUDIO_CALLBACK_RESULT_CONTINUE; } static ma_result ma_create_and_configure_AAudioStreamBuilder__aaudio(ma_context* pContext, const ma_device_id* pDeviceID, ma_device_type deviceType, ma_share_mode shareMode, const ma_device_descriptor* pDescriptor, const ma_device_config* pConfig, ma_device* pDevice, ma_AAudioStreamBuilder** ppBuilder) { ma_AAudioStreamBuilder* pBuilder; ma_aaudio_result_t resultAA; /* Safety. */ *ppBuilder = NULL; resultAA = ((MA_PFN_AAudio_createStreamBuilder)pContext->aaudio.AAudio_createStreamBuilder)(&pBuilder); if (resultAA != MA_AAUDIO_OK) { return ma_result_from_aaudio(resultAA); } if (pDeviceID != NULL) { ((MA_PFN_AAudioStreamBuilder_setDeviceId)pContext->aaudio.AAudioStreamBuilder_setDeviceId)(pBuilder, pDeviceID->aaudio); } ((MA_PFN_AAudioStreamBuilder_setDirection)pContext->aaudio.AAudioStreamBuilder_setDirection)(pBuilder, (deviceType == ma_device_type_playback) ? MA_AAUDIO_DIRECTION_OUTPUT : MA_AAUDIO_DIRECTION_INPUT); ((MA_PFN_AAudioStreamBuilder_setSharingMode)pContext->aaudio.AAudioStreamBuilder_setSharingMode)(pBuilder, (shareMode == ma_share_mode_shared) ? MA_AAUDIO_SHARING_MODE_SHARED : MA_AAUDIO_SHARING_MODE_EXCLUSIVE); /* If we have a device descriptor make sure we configure the stream builder to take our requested parameters. */ if (pDescriptor != NULL) { MA_ASSERT(pConfig != NULL); /* We must have a device config if we also have a descriptor. The config is required for AAudio specific configuration options. */ if (pDescriptor->sampleRate != 0) { ((MA_PFN_AAudioStreamBuilder_setSampleRate)pContext->aaudio.AAudioStreamBuilder_setSampleRate)(pBuilder, pDescriptor->sampleRate); } if (deviceType == ma_device_type_capture) { if (pDescriptor->channels != 0) { ((MA_PFN_AAudioStreamBuilder_setChannelCount)pContext->aaudio.AAudioStreamBuilder_setChannelCount)(pBuilder, pDescriptor->channels); } if (pDescriptor->format != ma_format_unknown) { ((MA_PFN_AAudioStreamBuilder_setFormat)pContext->aaudio.AAudioStreamBuilder_setFormat)(pBuilder, (pDescriptor->format == ma_format_s16) ? MA_AAUDIO_FORMAT_PCM_I16 : MA_AAUDIO_FORMAT_PCM_FLOAT); } } else { if (pDescriptor->channels != 0) { ((MA_PFN_AAudioStreamBuilder_setChannelCount)pContext->aaudio.AAudioStreamBuilder_setChannelCount)(pBuilder, pDescriptor->channels); } if (pDescriptor->format != ma_format_unknown) { ((MA_PFN_AAudioStreamBuilder_setFormat)pContext->aaudio.AAudioStreamBuilder_setFormat)(pBuilder, (pDescriptor->format == ma_format_s16) ? MA_AAUDIO_FORMAT_PCM_I16 : MA_AAUDIO_FORMAT_PCM_FLOAT); } } /* There have been reports where setting the frames per data callback results in an error later on from Android. To address this, I'm experimenting with simply not setting it on anything from Android 11 and earlier. Suggestions welcome on how we might be able to make this more targetted. */ if (!pConfig->aaudio.enableCompatibilityWorkarounds || ma_android_sdk_version() > 30) { /* AAudio is annoying when it comes to it's buffer calculation stuff because it doesn't let you retrieve the actual sample rate until after you've opened the stream. But you need to configure the buffer capacity before you open the stream... :/ To solve, we're just going to assume MA_DEFAULT_SAMPLE_RATE (48000) and move on. */ ma_uint32 bufferCapacityInFrames = ma_calculate_buffer_size_in_frames_from_descriptor(pDescriptor, pDescriptor->sampleRate, pConfig->performanceProfile) * pDescriptor->periodCount; ((MA_PFN_AAudioStreamBuilder_setBufferCapacityInFrames)pContext->aaudio.AAudioStreamBuilder_setBufferCapacityInFrames)(pBuilder, bufferCapacityInFrames); ((MA_PFN_AAudioStreamBuilder_setFramesPerDataCallback)pContext->aaudio.AAudioStreamBuilder_setFramesPerDataCallback)(pBuilder, bufferCapacityInFrames / pDescriptor->periodCount); } if (deviceType == ma_device_type_capture) { if (pConfig->aaudio.inputPreset != ma_aaudio_input_preset_default && pContext->aaudio.AAudioStreamBuilder_setInputPreset != NULL) { ((MA_PFN_AAudioStreamBuilder_setInputPreset)pContext->aaudio.AAudioStreamBuilder_setInputPreset)(pBuilder, ma_to_input_preset__aaudio(pConfig->aaudio.inputPreset)); } ((MA_PFN_AAudioStreamBuilder_setDataCallback)pContext->aaudio.AAudioStreamBuilder_setDataCallback)(pBuilder, ma_stream_data_callback_capture__aaudio, (void*)pDevice); } else { if (pConfig->aaudio.usage != ma_aaudio_usage_default && pContext->aaudio.AAudioStreamBuilder_setUsage != NULL) { ((MA_PFN_AAudioStreamBuilder_setUsage)pContext->aaudio.AAudioStreamBuilder_setUsage)(pBuilder, ma_to_usage__aaudio(pConfig->aaudio.usage)); } if (pConfig->aaudio.contentType != ma_aaudio_content_type_default && pContext->aaudio.AAudioStreamBuilder_setContentType != NULL) { ((MA_PFN_AAudioStreamBuilder_setContentType)pContext->aaudio.AAudioStreamBuilder_setContentType)(pBuilder, ma_to_content_type__aaudio(pConfig->aaudio.contentType)); } if (pConfig->aaudio.allowedCapturePolicy != ma_aaudio_allow_capture_default && pContext->aaudio.AAudioStreamBuilder_setAllowedCapturePolicy != NULL) { ((MA_PFN_AAudioStreamBuilder_setAllowedCapturePolicy)pContext->aaudio.AAudioStreamBuilder_setAllowedCapturePolicy)(pBuilder, ma_to_allowed_capture_policy__aaudio(pConfig->aaudio.allowedCapturePolicy)); } ((MA_PFN_AAudioStreamBuilder_setDataCallback)pContext->aaudio.AAudioStreamBuilder_setDataCallback)(pBuilder, ma_stream_data_callback_playback__aaudio, (void*)pDevice); } /* Not sure how this affects things, but since there's a mapping between miniaudio's performance profiles and AAudio's performance modes, let go ahead and set it. */ ((MA_PFN_AAudioStreamBuilder_setPerformanceMode)pContext->aaudio.AAudioStreamBuilder_setPerformanceMode)(pBuilder, (pConfig->performanceProfile == ma_performance_profile_low_latency) ? MA_AAUDIO_PERFORMANCE_MODE_LOW_LATENCY : MA_AAUDIO_PERFORMANCE_MODE_NONE); /* We need to set an error callback to detect device changes. */ if (pDevice != NULL) { /* <-- pDevice should never be null if pDescriptor is not null, which is always the case if we hit this branch. Check anyway for safety. */ ((MA_PFN_AAudioStreamBuilder_setErrorCallback)pContext->aaudio.AAudioStreamBuilder_setErrorCallback)(pBuilder, ma_stream_error_callback__aaudio, (void*)pDevice); } } *ppBuilder = pBuilder; return MA_SUCCESS; } static ma_result ma_open_stream_and_close_builder__aaudio(ma_context* pContext, ma_AAudioStreamBuilder* pBuilder, ma_AAudioStream** ppStream) { ma_result result; result = ma_result_from_aaudio(((MA_PFN_AAudioStreamBuilder_openStream)pContext->aaudio.AAudioStreamBuilder_openStream)(pBuilder, ppStream)); ((MA_PFN_AAudioStreamBuilder_delete)pContext->aaudio.AAudioStreamBuilder_delete)(pBuilder); return result; } static ma_result ma_open_stream_basic__aaudio(ma_context* pContext, const ma_device_id* pDeviceID, ma_device_type deviceType, ma_share_mode shareMode, ma_AAudioStream** ppStream) { ma_result result; ma_AAudioStreamBuilder* pBuilder; *ppStream = NULL; result = ma_create_and_configure_AAudioStreamBuilder__aaudio(pContext, pDeviceID, deviceType, shareMode, NULL, NULL, NULL, &pBuilder); if (result != MA_SUCCESS) { return result; } return ma_open_stream_and_close_builder__aaudio(pContext, pBuilder, ppStream); } static ma_result ma_open_stream__aaudio(ma_device* pDevice, const ma_device_config* pConfig, ma_device_type deviceType, const ma_device_descriptor* pDescriptor, ma_AAudioStream** ppStream) { ma_result result; ma_AAudioStreamBuilder* pBuilder; MA_ASSERT(pDevice != NULL); MA_ASSERT(pDescriptor != NULL); MA_ASSERT(deviceType != ma_device_type_duplex); /* This function should not be called for a full-duplex device type. */ *ppStream = NULL; result = ma_create_and_configure_AAudioStreamBuilder__aaudio(pDevice->pContext, pDescriptor->pDeviceID, deviceType, pDescriptor->shareMode, pDescriptor, pConfig, pDevice, &pBuilder); if (result != MA_SUCCESS) { return result; } return ma_open_stream_and_close_builder__aaudio(pDevice->pContext, pBuilder, ppStream); } static ma_result ma_close_stream__aaudio(ma_context* pContext, ma_AAudioStream* pStream) { return ma_result_from_aaudio(((MA_PFN_AAudioStream_close)pContext->aaudio.AAudioStream_close)(pStream)); } static ma_bool32 ma_has_default_device__aaudio(ma_context* pContext, ma_device_type deviceType) { /* The only way to know this is to try creating a stream. */ ma_AAudioStream* pStream; ma_result result = ma_open_stream_basic__aaudio(pContext, NULL, deviceType, ma_share_mode_shared, &pStream); if (result != MA_SUCCESS) { return MA_FALSE; } ma_close_stream__aaudio(pContext, pStream); return MA_TRUE; } static ma_result ma_wait_for_simple_state_transition__aaudio(ma_context* pContext, ma_AAudioStream* pStream, ma_aaudio_stream_state_t oldState, ma_aaudio_stream_state_t newState) { ma_aaudio_stream_state_t actualNewState; ma_aaudio_result_t resultAA = ((MA_PFN_AAudioStream_waitForStateChange)pContext->aaudio.AAudioStream_waitForStateChange)(pStream, oldState, &actualNewState, 5000000000); /* 5 second timeout. */ if (resultAA != MA_AAUDIO_OK) { return ma_result_from_aaudio(resultAA); } if (newState != actualNewState) { return MA_ERROR; /* Failed to transition into the expected state. */ } return MA_SUCCESS; } static ma_result ma_context_enumerate_devices__aaudio(ma_context* pContext, ma_enum_devices_callback_proc callback, void* pUserData) { ma_bool32 cbResult = MA_TRUE; MA_ASSERT(pContext != NULL); MA_ASSERT(callback != NULL); /* Unfortunately AAudio does not have an enumeration API. Therefore I'm only going to report default devices, but only if it can instantiate a stream. */ /* Playback. */ if (cbResult) { ma_device_info deviceInfo; MA_ZERO_OBJECT(&deviceInfo); deviceInfo.id.aaudio = MA_AAUDIO_UNSPECIFIED; ma_strncpy_s(deviceInfo.name, sizeof(deviceInfo.name), MA_DEFAULT_PLAYBACK_DEVICE_NAME, (size_t)-1); if (ma_has_default_device__aaudio(pContext, ma_device_type_playback)) { cbResult = callback(pContext, ma_device_type_playback, &deviceInfo, pUserData); } } /* Capture. */ if (cbResult) { ma_device_info deviceInfo; MA_ZERO_OBJECT(&deviceInfo); deviceInfo.id.aaudio = MA_AAUDIO_UNSPECIFIED; ma_strncpy_s(deviceInfo.name, sizeof(deviceInfo.name), MA_DEFAULT_CAPTURE_DEVICE_NAME, (size_t)-1); if (ma_has_default_device__aaudio(pContext, ma_device_type_capture)) { cbResult = callback(pContext, ma_device_type_capture, &deviceInfo, pUserData); } } return MA_SUCCESS; } static void ma_context_add_native_data_format_from_AAudioStream_ex__aaudio(ma_context* pContext, ma_AAudioStream* pStream, ma_format format, ma_uint32 flags, ma_device_info* pDeviceInfo) { MA_ASSERT(pContext != NULL); MA_ASSERT(pStream != NULL); MA_ASSERT(pDeviceInfo != NULL); pDeviceInfo->nativeDataFormats[pDeviceInfo->nativeDataFormatCount].format = format; pDeviceInfo->nativeDataFormats[pDeviceInfo->nativeDataFormatCount].channels = ((MA_PFN_AAudioStream_getChannelCount)pContext->aaudio.AAudioStream_getChannelCount)(pStream); pDeviceInfo->nativeDataFormats[pDeviceInfo->nativeDataFormatCount].sampleRate = ((MA_PFN_AAudioStream_getSampleRate)pContext->aaudio.AAudioStream_getSampleRate)(pStream); pDeviceInfo->nativeDataFormats[pDeviceInfo->nativeDataFormatCount].flags = flags; pDeviceInfo->nativeDataFormatCount += 1; } static void ma_context_add_native_data_format_from_AAudioStream__aaudio(ma_context* pContext, ma_AAudioStream* pStream, ma_uint32 flags, ma_device_info* pDeviceInfo) { /* AAudio supports s16 and f32. */ ma_context_add_native_data_format_from_AAudioStream_ex__aaudio(pContext, pStream, ma_format_f32, flags, pDeviceInfo); ma_context_add_native_data_format_from_AAudioStream_ex__aaudio(pContext, pStream, ma_format_s16, flags, pDeviceInfo); } static ma_result ma_context_get_device_info__aaudio(ma_context* pContext, ma_device_type deviceType, const ma_device_id* pDeviceID, ma_device_info* pDeviceInfo) { ma_AAudioStream* pStream; ma_result result; MA_ASSERT(pContext != NULL); /* ID */ if (pDeviceID != NULL) { pDeviceInfo->id.aaudio = pDeviceID->aaudio; } else { pDeviceInfo->id.aaudio = MA_AAUDIO_UNSPECIFIED; } /* Name */ if (deviceType == ma_device_type_playback) { ma_strncpy_s(pDeviceInfo->name, sizeof(pDeviceInfo->name), MA_DEFAULT_PLAYBACK_DEVICE_NAME, (size_t)-1); } else { ma_strncpy_s(pDeviceInfo->name, sizeof(pDeviceInfo->name), MA_DEFAULT_CAPTURE_DEVICE_NAME, (size_t)-1); } pDeviceInfo->nativeDataFormatCount = 0; /* We'll need to open the device to get accurate sample rate and channel count information. */ result = ma_open_stream_basic__aaudio(pContext, pDeviceID, deviceType, ma_share_mode_shared, &pStream); if (result != MA_SUCCESS) { return result; } ma_context_add_native_data_format_from_AAudioStream__aaudio(pContext, pStream, 0, pDeviceInfo); ma_close_stream__aaudio(pContext, pStream); pStream = NULL; return MA_SUCCESS; } static ma_result ma_device_uninit__aaudio(ma_device* pDevice) { MA_ASSERT(pDevice != NULL); if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) { ma_close_stream__aaudio(pDevice->pContext, (ma_AAudioStream*)pDevice->aaudio.pStreamCapture); pDevice->aaudio.pStreamCapture = NULL; } if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) { ma_close_stream__aaudio(pDevice->pContext, (ma_AAudioStream*)pDevice->aaudio.pStreamPlayback); pDevice->aaudio.pStreamPlayback = NULL; } return MA_SUCCESS; } static ma_result ma_device_init_by_type__aaudio(ma_device* pDevice, const ma_device_config* pConfig, ma_device_type deviceType, ma_device_descriptor* pDescriptor, ma_AAudioStream** ppStream) { ma_result result; int32_t bufferCapacityInFrames; int32_t framesPerDataCallback; ma_AAudioStream* pStream; MA_ASSERT(pDevice != NULL); MA_ASSERT(pConfig != NULL); MA_ASSERT(pDescriptor != NULL); *ppStream = NULL; /* Safety. */ /* First step is to open the stream. From there we'll be able to extract the internal configuration. */ result = ma_open_stream__aaudio(pDevice, pConfig, deviceType, pDescriptor, &pStream); if (result != MA_SUCCESS) { return result; /* Failed to open the AAudio stream. */ } /* Now extract the internal configuration. */ pDescriptor->format = (((MA_PFN_AAudioStream_getFormat)pDevice->pContext->aaudio.AAudioStream_getFormat)(pStream) == MA_AAUDIO_FORMAT_PCM_I16) ? ma_format_s16 : ma_format_f32; pDescriptor->channels = ((MA_PFN_AAudioStream_getChannelCount)pDevice->pContext->aaudio.AAudioStream_getChannelCount)(pStream); pDescriptor->sampleRate = ((MA_PFN_AAudioStream_getSampleRate)pDevice->pContext->aaudio.AAudioStream_getSampleRate)(pStream); /* For the channel map we need to be sure we don't overflow any buffers. */ if (pDescriptor->channels <= MA_MAX_CHANNELS) { ma_channel_map_init_standard(ma_standard_channel_map_default, pDescriptor->channelMap, ma_countof(pDescriptor->channelMap), pDescriptor->channels); /* <-- Cannot find info on channel order, so assuming a default. */ } else { ma_channel_map_init_blank(pDescriptor->channelMap, MA_MAX_CHANNELS); /* Too many channels. Use a blank channel map. */ } bufferCapacityInFrames = ((MA_PFN_AAudioStream_getBufferCapacityInFrames)pDevice->pContext->aaudio.AAudioStream_getBufferCapacityInFrames)(pStream); framesPerDataCallback = ((MA_PFN_AAudioStream_getFramesPerDataCallback)pDevice->pContext->aaudio.AAudioStream_getFramesPerDataCallback)(pStream); if (framesPerDataCallback > 0) { pDescriptor->periodSizeInFrames = framesPerDataCallback; pDescriptor->periodCount = bufferCapacityInFrames / framesPerDataCallback; } else { pDescriptor->periodSizeInFrames = bufferCapacityInFrames; pDescriptor->periodCount = 1; } *ppStream = pStream; return MA_SUCCESS; } static ma_result ma_device_init__aaudio(ma_device* pDevice, const ma_device_config* pConfig, ma_device_descriptor* pDescriptorPlayback, ma_device_descriptor* pDescriptorCapture) { ma_result result; MA_ASSERT(pDevice != NULL); if (pConfig->deviceType == ma_device_type_loopback) { return MA_DEVICE_TYPE_NOT_SUPPORTED; } pDevice->aaudio.usage = pConfig->aaudio.usage; pDevice->aaudio.contentType = pConfig->aaudio.contentType; pDevice->aaudio.inputPreset = pConfig->aaudio.inputPreset; pDevice->aaudio.allowedCapturePolicy = pConfig->aaudio.allowedCapturePolicy; pDevice->aaudio.noAutoStartAfterReroute = pConfig->aaudio.noAutoStartAfterReroute; if (pConfig->deviceType == ma_device_type_capture || pConfig->deviceType == ma_device_type_duplex) { result = ma_device_init_by_type__aaudio(pDevice, pConfig, ma_device_type_capture, pDescriptorCapture, (ma_AAudioStream**)&pDevice->aaudio.pStreamCapture); if (result != MA_SUCCESS) { return result; } } if (pConfig->deviceType == ma_device_type_playback || pConfig->deviceType == ma_device_type_duplex) { result = ma_device_init_by_type__aaudio(pDevice, pConfig, ma_device_type_playback, pDescriptorPlayback, (ma_AAudioStream**)&pDevice->aaudio.pStreamPlayback); if (result != MA_SUCCESS) { return result; } } return MA_SUCCESS; } static ma_result ma_device_start_stream__aaudio(ma_device* pDevice, ma_AAudioStream* pStream) { ma_aaudio_result_t resultAA; ma_aaudio_stream_state_t currentState; MA_ASSERT(pDevice != NULL); resultAA = ((MA_PFN_AAudioStream_requestStart)pDevice->pContext->aaudio.AAudioStream_requestStart)(pStream); if (resultAA != MA_AAUDIO_OK) { return ma_result_from_aaudio(resultAA); } /* Do we actually need to wait for the device to transition into it's started state? */ /* The device should be in either a starting or started state. If it's not set to started we need to wait for it to transition. It should go from starting to started. */ currentState = ((MA_PFN_AAudioStream_getState)pDevice->pContext->aaudio.AAudioStream_getState)(pStream); if (currentState != MA_AAUDIO_STREAM_STATE_STARTED) { ma_result result; if (currentState != MA_AAUDIO_STREAM_STATE_STARTING) { return MA_ERROR; /* Expecting the stream to be a starting or started state. */ } result = ma_wait_for_simple_state_transition__aaudio(pDevice->pContext, pStream, currentState, MA_AAUDIO_STREAM_STATE_STARTED); if (result != MA_SUCCESS) { return result; } } return MA_SUCCESS; } static ma_result ma_device_stop_stream__aaudio(ma_device* pDevice, ma_AAudioStream* pStream) { ma_aaudio_result_t resultAA; ma_aaudio_stream_state_t currentState; MA_ASSERT(pDevice != NULL); /* From the AAudio documentation: The stream will stop after all of the data currently buffered has been played. This maps with miniaudio's requirement that device's be drained which means we don't need to implement any draining logic. */ currentState = ((MA_PFN_AAudioStream_getState)pDevice->pContext->aaudio.AAudioStream_getState)(pStream); if (currentState == MA_AAUDIO_STREAM_STATE_DISCONNECTED) { return MA_SUCCESS; /* The device is disconnected. Don't try stopping it. */ } resultAA = ((MA_PFN_AAudioStream_requestStop)pDevice->pContext->aaudio.AAudioStream_requestStop)(pStream); if (resultAA != MA_AAUDIO_OK) { return ma_result_from_aaudio(resultAA); } /* The device should be in either a stopping or stopped state. If it's not set to started we need to wait for it to transition. It should go from stopping to stopped. */ currentState = ((MA_PFN_AAudioStream_getState)pDevice->pContext->aaudio.AAudioStream_getState)(pStream); if (currentState != MA_AAUDIO_STREAM_STATE_STOPPED) { ma_result result; if (currentState != MA_AAUDIO_STREAM_STATE_STOPPING) { return MA_ERROR; /* Expecting the stream to be a stopping or stopped state. */ } result = ma_wait_for_simple_state_transition__aaudio(pDevice->pContext, pStream, currentState, MA_AAUDIO_STREAM_STATE_STOPPED); if (result != MA_SUCCESS) { return result; } } return MA_SUCCESS; } static ma_result ma_device_start__aaudio(ma_device* pDevice) { MA_ASSERT(pDevice != NULL); if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) { ma_result result = ma_device_start_stream__aaudio(pDevice, (ma_AAudioStream*)pDevice->aaudio.pStreamCapture); if (result != MA_SUCCESS) { return result; } } if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) { ma_result result = ma_device_start_stream__aaudio(pDevice, (ma_AAudioStream*)pDevice->aaudio.pStreamPlayback); if (result != MA_SUCCESS) { if (pDevice->type == ma_device_type_duplex) { ma_device_stop_stream__aaudio(pDevice, (ma_AAudioStream*)pDevice->aaudio.pStreamCapture); } return result; } } return MA_SUCCESS; } static ma_result ma_device_stop__aaudio(ma_device* pDevice) { MA_ASSERT(pDevice != NULL); if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) { ma_result result = ma_device_stop_stream__aaudio(pDevice, (ma_AAudioStream*)pDevice->aaudio.pStreamCapture); if (result != MA_SUCCESS) { return result; } } if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) { ma_result result = ma_device_stop_stream__aaudio(pDevice, (ma_AAudioStream*)pDevice->aaudio.pStreamPlayback); if (result != MA_SUCCESS) { return result; } } ma_device__on_notification_stopped(pDevice); return MA_SUCCESS; } static ma_result ma_device_reinit__aaudio(ma_device* pDevice, ma_device_type deviceType) { ma_result result; MA_ASSERT(pDevice != NULL); /* The first thing to do is close the streams. */ if (deviceType == ma_device_type_capture || deviceType == ma_device_type_duplex) { ma_close_stream__aaudio(pDevice->pContext, (ma_AAudioStream*)pDevice->aaudio.pStreamCapture); pDevice->aaudio.pStreamCapture = NULL; } if (deviceType == ma_device_type_playback || deviceType == ma_device_type_duplex) { ma_close_stream__aaudio(pDevice->pContext, (ma_AAudioStream*)pDevice->aaudio.pStreamPlayback); pDevice->aaudio.pStreamPlayback = NULL; } /* Now we need to reinitialize each streams. The hardest part with this is just filling output the config and descriptors. */ { ma_device_config deviceConfig; ma_device_descriptor descriptorPlayback; ma_device_descriptor descriptorCapture; deviceConfig = ma_device_config_init(deviceType); deviceConfig.playback.pDeviceID = NULL; /* Only doing rerouting with default devices. */ deviceConfig.playback.shareMode = pDevice->playback.shareMode; deviceConfig.playback.format = pDevice->playback.format; deviceConfig.playback.channels = pDevice->playback.channels; deviceConfig.capture.pDeviceID = NULL; /* Only doing rerouting with default devices. */ deviceConfig.capture.shareMode = pDevice->capture.shareMode; deviceConfig.capture.format = pDevice->capture.format; deviceConfig.capture.channels = pDevice->capture.channels; deviceConfig.sampleRate = pDevice->sampleRate; deviceConfig.aaudio.usage = pDevice->aaudio.usage; deviceConfig.aaudio.contentType = pDevice->aaudio.contentType; deviceConfig.aaudio.inputPreset = pDevice->aaudio.inputPreset; deviceConfig.aaudio.allowedCapturePolicy = pDevice->aaudio.allowedCapturePolicy; deviceConfig.aaudio.noAutoStartAfterReroute = pDevice->aaudio.noAutoStartAfterReroute; deviceConfig.periods = 1; /* Try to get an accurate period size. */ if (deviceType == ma_device_type_playback || deviceType == ma_device_type_duplex) { deviceConfig.periodSizeInFrames = pDevice->playback.internalPeriodSizeInFrames; } else { deviceConfig.periodSizeInFrames = pDevice->capture.internalPeriodSizeInFrames; } if (deviceType == ma_device_type_capture || deviceType == ma_device_type_duplex || deviceType == ma_device_type_loopback) { descriptorCapture.pDeviceID = deviceConfig.capture.pDeviceID; descriptorCapture.shareMode = deviceConfig.capture.shareMode; descriptorCapture.format = deviceConfig.capture.format; descriptorCapture.channels = deviceConfig.capture.channels; descriptorCapture.sampleRate = deviceConfig.sampleRate; descriptorCapture.periodSizeInFrames = deviceConfig.periodSizeInFrames; descriptorCapture.periodCount = deviceConfig.periods; } if (deviceType == ma_device_type_playback || deviceType == ma_device_type_duplex) { descriptorPlayback.pDeviceID = deviceConfig.playback.pDeviceID; descriptorPlayback.shareMode = deviceConfig.playback.shareMode; descriptorPlayback.format = deviceConfig.playback.format; descriptorPlayback.channels = deviceConfig.playback.channels; descriptorPlayback.sampleRate = deviceConfig.sampleRate; descriptorPlayback.periodSizeInFrames = deviceConfig.periodSizeInFrames; descriptorPlayback.periodCount = deviceConfig.periods; } result = ma_device_init__aaudio(pDevice, &deviceConfig, &descriptorPlayback, &descriptorCapture); if (result != MA_SUCCESS) { return result; } result = ma_device_post_init(pDevice, deviceType, &descriptorPlayback, &descriptorCapture); if (result != MA_SUCCESS) { ma_device_uninit__aaudio(pDevice); return result; } /* We'll only ever do this in response to a reroute. */ ma_device__on_notification_rerouted(pDevice); /* If the device is started, start the streams. Maybe make this configurable? */ if (ma_device_get_state(pDevice) == ma_device_state_started) { if (pDevice->aaudio.noAutoStartAfterReroute == MA_FALSE) { ma_device_start__aaudio(pDevice); } else { ma_device_stop(pDevice); /* Do a full device stop so we set internal state correctly. */ } } return MA_SUCCESS; } } static ma_result ma_device_get_info__aaudio(ma_device* pDevice, ma_device_type type, ma_device_info* pDeviceInfo) { ma_AAudioStream* pStream = NULL; MA_ASSERT(pDevice != NULL); MA_ASSERT(type != ma_device_type_duplex); MA_ASSERT(pDeviceInfo != NULL); if (type == ma_device_type_playback) { pStream = (ma_AAudioStream*)pDevice->aaudio.pStreamCapture; pDeviceInfo->id.aaudio = pDevice->capture.id.aaudio; ma_strncpy_s(pDeviceInfo->name, sizeof(pDeviceInfo->name), MA_DEFAULT_CAPTURE_DEVICE_NAME, (size_t)-1); /* Only supporting default devices. */ } if (type == ma_device_type_capture) { pStream = (ma_AAudioStream*)pDevice->aaudio.pStreamPlayback; pDeviceInfo->id.aaudio = pDevice->playback.id.aaudio; ma_strncpy_s(pDeviceInfo->name, sizeof(pDeviceInfo->name), MA_DEFAULT_PLAYBACK_DEVICE_NAME, (size_t)-1); /* Only supporting default devices. */ } /* Safety. Should never happen. */ if (pStream == NULL) { return MA_INVALID_OPERATION; } pDeviceInfo->nativeDataFormatCount = 0; ma_context_add_native_data_format_from_AAudioStream__aaudio(pDevice->pContext, pStream, 0, pDeviceInfo); return MA_SUCCESS; } static ma_result ma_context_uninit__aaudio(ma_context* pContext) { MA_ASSERT(pContext != NULL); MA_ASSERT(pContext->backend == ma_backend_aaudio); ma_device_job_thread_uninit(&pContext->aaudio.jobThread, &pContext->allocationCallbacks); ma_dlclose(ma_context_get_log(pContext), pContext->aaudio.hAAudio); pContext->aaudio.hAAudio = NULL; return MA_SUCCESS; } static ma_result ma_context_init__aaudio(ma_context* pContext, const ma_context_config* pConfig, ma_backend_callbacks* pCallbacks) { size_t i; const char* libNames[] = { "libaaudio.so" }; for (i = 0; i < ma_countof(libNames); ++i) { pContext->aaudio.hAAudio = ma_dlopen(ma_context_get_log(pContext), libNames[i]); if (pContext->aaudio.hAAudio != NULL) { break; } } if (pContext->aaudio.hAAudio == NULL) { return MA_FAILED_TO_INIT_BACKEND; } pContext->aaudio.AAudio_createStreamBuilder = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->aaudio.hAAudio, "AAudio_createStreamBuilder"); pContext->aaudio.AAudioStreamBuilder_delete = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->aaudio.hAAudio, "AAudioStreamBuilder_delete"); pContext->aaudio.AAudioStreamBuilder_setDeviceId = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->aaudio.hAAudio, "AAudioStreamBuilder_setDeviceId"); pContext->aaudio.AAudioStreamBuilder_setDirection = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->aaudio.hAAudio, "AAudioStreamBuilder_setDirection"); pContext->aaudio.AAudioStreamBuilder_setSharingMode = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->aaudio.hAAudio, "AAudioStreamBuilder_setSharingMode"); pContext->aaudio.AAudioStreamBuilder_setFormat = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->aaudio.hAAudio, "AAudioStreamBuilder_setFormat"); pContext->aaudio.AAudioStreamBuilder_setChannelCount = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->aaudio.hAAudio, "AAudioStreamBuilder_setChannelCount"); pContext->aaudio.AAudioStreamBuilder_setSampleRate = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->aaudio.hAAudio, "AAudioStreamBuilder_setSampleRate"); pContext->aaudio.AAudioStreamBuilder_setBufferCapacityInFrames = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->aaudio.hAAudio, "AAudioStreamBuilder_setBufferCapacityInFrames"); pContext->aaudio.AAudioStreamBuilder_setFramesPerDataCallback = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->aaudio.hAAudio, "AAudioStreamBuilder_setFramesPerDataCallback"); pContext->aaudio.AAudioStreamBuilder_setDataCallback = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->aaudio.hAAudio, "AAudioStreamBuilder_setDataCallback"); pContext->aaudio.AAudioStreamBuilder_setErrorCallback = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->aaudio.hAAudio, "AAudioStreamBuilder_setErrorCallback"); pContext->aaudio.AAudioStreamBuilder_setPerformanceMode = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->aaudio.hAAudio, "AAudioStreamBuilder_setPerformanceMode"); pContext->aaudio.AAudioStreamBuilder_setUsage = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->aaudio.hAAudio, "AAudioStreamBuilder_setUsage"); pContext->aaudio.AAudioStreamBuilder_setContentType = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->aaudio.hAAudio, "AAudioStreamBuilder_setContentType"); pContext->aaudio.AAudioStreamBuilder_setInputPreset = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->aaudio.hAAudio, "AAudioStreamBuilder_setInputPreset"); pContext->aaudio.AAudioStreamBuilder_setAllowedCapturePolicy = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->aaudio.hAAudio, "AAudioStreamBuilder_setAllowedCapturePolicy"); pContext->aaudio.AAudioStreamBuilder_openStream = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->aaudio.hAAudio, "AAudioStreamBuilder_openStream"); pContext->aaudio.AAudioStream_close = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->aaudio.hAAudio, "AAudioStream_close"); pContext->aaudio.AAudioStream_getState = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->aaudio.hAAudio, "AAudioStream_getState"); pContext->aaudio.AAudioStream_waitForStateChange = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->aaudio.hAAudio, "AAudioStream_waitForStateChange"); pContext->aaudio.AAudioStream_getFormat = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->aaudio.hAAudio, "AAudioStream_getFormat"); pContext->aaudio.AAudioStream_getChannelCount = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->aaudio.hAAudio, "AAudioStream_getChannelCount"); pContext->aaudio.AAudioStream_getSampleRate = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->aaudio.hAAudio, "AAudioStream_getSampleRate"); pContext->aaudio.AAudioStream_getBufferCapacityInFrames = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->aaudio.hAAudio, "AAudioStream_getBufferCapacityInFrames"); pContext->aaudio.AAudioStream_getFramesPerDataCallback = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->aaudio.hAAudio, "AAudioStream_getFramesPerDataCallback"); pContext->aaudio.AAudioStream_getFramesPerBurst = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->aaudio.hAAudio, "AAudioStream_getFramesPerBurst"); pContext->aaudio.AAudioStream_requestStart = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->aaudio.hAAudio, "AAudioStream_requestStart"); pContext->aaudio.AAudioStream_requestStop = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->aaudio.hAAudio, "AAudioStream_requestStop"); pCallbacks->onContextInit = ma_context_init__aaudio; pCallbacks->onContextUninit = ma_context_uninit__aaudio; pCallbacks->onContextEnumerateDevices = ma_context_enumerate_devices__aaudio; pCallbacks->onContextGetDeviceInfo = ma_context_get_device_info__aaudio; pCallbacks->onDeviceInit = ma_device_init__aaudio; pCallbacks->onDeviceUninit = ma_device_uninit__aaudio; pCallbacks->onDeviceStart = ma_device_start__aaudio; pCallbacks->onDeviceStop = ma_device_stop__aaudio; pCallbacks->onDeviceRead = NULL; /* Not used because AAudio is asynchronous. */ pCallbacks->onDeviceWrite = NULL; /* Not used because AAudio is asynchronous. */ pCallbacks->onDeviceDataLoop = NULL; /* Not used because AAudio is asynchronous. */ pCallbacks->onDeviceGetInfo = ma_device_get_info__aaudio; /* We need a job thread so we can deal with rerouting. */ { ma_result result; ma_device_job_thread_config jobThreadConfig; jobThreadConfig = ma_device_job_thread_config_init(); result = ma_device_job_thread_init(&jobThreadConfig, &pContext->allocationCallbacks, &pContext->aaudio.jobThread); if (result != MA_SUCCESS) { ma_dlclose(ma_context_get_log(pContext), pContext->aaudio.hAAudio); pContext->aaudio.hAAudio = NULL; return result; } } (void)pConfig; return MA_SUCCESS; } static ma_result ma_job_process__device__aaudio_reroute(ma_job* pJob) { ma_device* pDevice; MA_ASSERT(pJob != NULL); pDevice = (ma_device*)pJob->data.device.aaudio.reroute.pDevice; MA_ASSERT(pDevice != NULL); /* Here is where we need to reroute the device. To do this we need to uninitialize the stream and reinitialize it. */ return ma_device_reinit__aaudio(pDevice, (ma_device_type)pJob->data.device.aaudio.reroute.deviceType); } #else /* Getting here means there is no AAudio backend so we need a no-op job implementation. */ static ma_result ma_job_process__device__aaudio_reroute(ma_job* pJob) { return ma_job_process__noop(pJob); } #endif /* AAudio */ /****************************************************************************** OpenSL|ES Backend ******************************************************************************/ #ifdef MA_HAS_OPENSL #include #ifdef MA_ANDROID #include #endif typedef SLresult (SLAPIENTRY * ma_slCreateEngine_proc)(SLObjectItf* pEngine, SLuint32 numOptions, SLEngineOption* pEngineOptions, SLuint32 numInterfaces, SLInterfaceID* pInterfaceIds, SLboolean* pInterfaceRequired); /* OpenSL|ES has one-per-application objects :( */ static SLObjectItf g_maEngineObjectSL = NULL; static SLEngineItf g_maEngineSL = NULL; static ma_uint32 g_maOpenSLInitCounter = 0; static ma_spinlock g_maOpenSLSpinlock = 0; /* For init/uninit. */ #define MA_OPENSL_OBJ(p) (*((SLObjectItf)(p))) #define MA_OPENSL_OUTPUTMIX(p) (*((SLOutputMixItf)(p))) #define MA_OPENSL_PLAY(p) (*((SLPlayItf)(p))) #define MA_OPENSL_RECORD(p) (*((SLRecordItf)(p))) #ifdef MA_ANDROID #define MA_OPENSL_BUFFERQUEUE(p) (*((SLAndroidSimpleBufferQueueItf)(p))) #else #define MA_OPENSL_BUFFERQUEUE(p) (*((SLBufferQueueItf)(p))) #endif static ma_result ma_result_from_OpenSL(SLuint32 result) { switch (result) { case SL_RESULT_SUCCESS: return MA_SUCCESS; case SL_RESULT_PRECONDITIONS_VIOLATED: return MA_ERROR; case SL_RESULT_PARAMETER_INVALID: return MA_INVALID_ARGS; case SL_RESULT_MEMORY_FAILURE: return MA_OUT_OF_MEMORY; case SL_RESULT_RESOURCE_ERROR: return MA_INVALID_DATA; case SL_RESULT_RESOURCE_LOST: return MA_ERROR; case SL_RESULT_IO_ERROR: return MA_IO_ERROR; case SL_RESULT_BUFFER_INSUFFICIENT: return MA_NO_SPACE; case SL_RESULT_CONTENT_CORRUPTED: return MA_INVALID_DATA; case SL_RESULT_CONTENT_UNSUPPORTED: return MA_FORMAT_NOT_SUPPORTED; case SL_RESULT_CONTENT_NOT_FOUND: return MA_ERROR; case SL_RESULT_PERMISSION_DENIED: return MA_ACCESS_DENIED; case SL_RESULT_FEATURE_UNSUPPORTED: return MA_NOT_IMPLEMENTED; case SL_RESULT_INTERNAL_ERROR: return MA_ERROR; case SL_RESULT_UNKNOWN_ERROR: return MA_ERROR; case SL_RESULT_OPERATION_ABORTED: return MA_ERROR; case SL_RESULT_CONTROL_LOST: return MA_ERROR; default: return MA_ERROR; } } /* Converts an individual OpenSL-style channel identifier (SL_SPEAKER_FRONT_LEFT, etc.) to miniaudio. */ static ma_uint8 ma_channel_id_to_ma__opensl(SLuint32 id) { switch (id) { case SL_SPEAKER_FRONT_LEFT: return MA_CHANNEL_FRONT_LEFT; case SL_SPEAKER_FRONT_RIGHT: return MA_CHANNEL_FRONT_RIGHT; case SL_SPEAKER_FRONT_CENTER: return MA_CHANNEL_FRONT_CENTER; case SL_SPEAKER_LOW_FREQUENCY: return MA_CHANNEL_LFE; case SL_SPEAKER_BACK_LEFT: return MA_CHANNEL_BACK_LEFT; case SL_SPEAKER_BACK_RIGHT: return MA_CHANNEL_BACK_RIGHT; case SL_SPEAKER_FRONT_LEFT_OF_CENTER: return MA_CHANNEL_FRONT_LEFT_CENTER; case SL_SPEAKER_FRONT_RIGHT_OF_CENTER: return MA_CHANNEL_FRONT_RIGHT_CENTER; case SL_SPEAKER_BACK_CENTER: return MA_CHANNEL_BACK_CENTER; case SL_SPEAKER_SIDE_LEFT: return MA_CHANNEL_SIDE_LEFT; case SL_SPEAKER_SIDE_RIGHT: return MA_CHANNEL_SIDE_RIGHT; case SL_SPEAKER_TOP_CENTER: return MA_CHANNEL_TOP_CENTER; case SL_SPEAKER_TOP_FRONT_LEFT: return MA_CHANNEL_TOP_FRONT_LEFT; case SL_SPEAKER_TOP_FRONT_CENTER: return MA_CHANNEL_TOP_FRONT_CENTER; case SL_SPEAKER_TOP_FRONT_RIGHT: return MA_CHANNEL_TOP_FRONT_RIGHT; case SL_SPEAKER_TOP_BACK_LEFT: return MA_CHANNEL_TOP_BACK_LEFT; case SL_SPEAKER_TOP_BACK_CENTER: return MA_CHANNEL_TOP_BACK_CENTER; case SL_SPEAKER_TOP_BACK_RIGHT: return MA_CHANNEL_TOP_BACK_RIGHT; default: return 0; } } /* Converts an individual miniaudio channel identifier (MA_CHANNEL_FRONT_LEFT, etc.) to OpenSL-style. */ static SLuint32 ma_channel_id_to_opensl(ma_uint8 id) { switch (id) { case MA_CHANNEL_MONO: return SL_SPEAKER_FRONT_CENTER; case MA_CHANNEL_FRONT_LEFT: return SL_SPEAKER_FRONT_LEFT; case MA_CHANNEL_FRONT_RIGHT: return SL_SPEAKER_FRONT_RIGHT; case MA_CHANNEL_FRONT_CENTER: return SL_SPEAKER_FRONT_CENTER; case MA_CHANNEL_LFE: return SL_SPEAKER_LOW_FREQUENCY; case MA_CHANNEL_BACK_LEFT: return SL_SPEAKER_BACK_LEFT; case MA_CHANNEL_BACK_RIGHT: return SL_SPEAKER_BACK_RIGHT; case MA_CHANNEL_FRONT_LEFT_CENTER: return SL_SPEAKER_FRONT_LEFT_OF_CENTER; case MA_CHANNEL_FRONT_RIGHT_CENTER: return SL_SPEAKER_FRONT_RIGHT_OF_CENTER; case MA_CHANNEL_BACK_CENTER: return SL_SPEAKER_BACK_CENTER; case MA_CHANNEL_SIDE_LEFT: return SL_SPEAKER_SIDE_LEFT; case MA_CHANNEL_SIDE_RIGHT: return SL_SPEAKER_SIDE_RIGHT; case MA_CHANNEL_TOP_CENTER: return SL_SPEAKER_TOP_CENTER; case MA_CHANNEL_TOP_FRONT_LEFT: return SL_SPEAKER_TOP_FRONT_LEFT; case MA_CHANNEL_TOP_FRONT_CENTER: return SL_SPEAKER_TOP_FRONT_CENTER; case MA_CHANNEL_TOP_FRONT_RIGHT: return SL_SPEAKER_TOP_FRONT_RIGHT; case MA_CHANNEL_TOP_BACK_LEFT: return SL_SPEAKER_TOP_BACK_LEFT; case MA_CHANNEL_TOP_BACK_CENTER: return SL_SPEAKER_TOP_BACK_CENTER; case MA_CHANNEL_TOP_BACK_RIGHT: return SL_SPEAKER_TOP_BACK_RIGHT; default: return 0; } } /* Converts a channel mapping to an OpenSL-style channel mask. */ static SLuint32 ma_channel_map_to_channel_mask__opensl(const ma_channel* pChannelMap, ma_uint32 channels) { SLuint32 channelMask = 0; ma_uint32 iChannel; for (iChannel = 0; iChannel < channels; ++iChannel) { channelMask |= ma_channel_id_to_opensl(pChannelMap[iChannel]); } return channelMask; } /* Converts an OpenSL-style channel mask to a miniaudio channel map. */ static void ma_channel_mask_to_channel_map__opensl(SLuint32 channelMask, ma_uint32 channels, ma_channel* pChannelMap) { if (channels == 1 && channelMask == 0) { pChannelMap[0] = MA_CHANNEL_MONO; } else if (channels == 2 && channelMask == 0) { pChannelMap[0] = MA_CHANNEL_FRONT_LEFT; pChannelMap[1] = MA_CHANNEL_FRONT_RIGHT; } else { if (channels == 1 && (channelMask & SL_SPEAKER_FRONT_CENTER) != 0) { pChannelMap[0] = MA_CHANNEL_MONO; } else { /* Just iterate over each bit. */ ma_uint32 iChannel = 0; ma_uint32 iBit; for (iBit = 0; iBit < 32 && iChannel < channels; ++iBit) { SLuint32 bitValue = (channelMask & (1UL << iBit)); if (bitValue != 0) { /* The bit is set. */ pChannelMap[iChannel] = ma_channel_id_to_ma__opensl(bitValue); iChannel += 1; } } } } } static SLuint32 ma_round_to_standard_sample_rate__opensl(SLuint32 samplesPerSec) { if (samplesPerSec <= SL_SAMPLINGRATE_8) { return SL_SAMPLINGRATE_8; } if (samplesPerSec <= SL_SAMPLINGRATE_11_025) { return SL_SAMPLINGRATE_11_025; } if (samplesPerSec <= SL_SAMPLINGRATE_12) { return SL_SAMPLINGRATE_12; } if (samplesPerSec <= SL_SAMPLINGRATE_16) { return SL_SAMPLINGRATE_16; } if (samplesPerSec <= SL_SAMPLINGRATE_22_05) { return SL_SAMPLINGRATE_22_05; } if (samplesPerSec <= SL_SAMPLINGRATE_24) { return SL_SAMPLINGRATE_24; } if (samplesPerSec <= SL_SAMPLINGRATE_32) { return SL_SAMPLINGRATE_32; } if (samplesPerSec <= SL_SAMPLINGRATE_44_1) { return SL_SAMPLINGRATE_44_1; } if (samplesPerSec <= SL_SAMPLINGRATE_48) { return SL_SAMPLINGRATE_48; } /* Android doesn't support more than 48000. */ #ifndef MA_ANDROID if (samplesPerSec <= SL_SAMPLINGRATE_64) { return SL_SAMPLINGRATE_64; } if (samplesPerSec <= SL_SAMPLINGRATE_88_2) { return SL_SAMPLINGRATE_88_2; } if (samplesPerSec <= SL_SAMPLINGRATE_96) { return SL_SAMPLINGRATE_96; } if (samplesPerSec <= SL_SAMPLINGRATE_192) { return SL_SAMPLINGRATE_192; } #endif return SL_SAMPLINGRATE_16; } static SLint32 ma_to_stream_type__opensl(ma_opensl_stream_type streamType) { switch (streamType) { case ma_opensl_stream_type_voice: return SL_ANDROID_STREAM_VOICE; case ma_opensl_stream_type_system: return SL_ANDROID_STREAM_SYSTEM; case ma_opensl_stream_type_ring: return SL_ANDROID_STREAM_RING; case ma_opensl_stream_type_media: return SL_ANDROID_STREAM_MEDIA; case ma_opensl_stream_type_alarm: return SL_ANDROID_STREAM_ALARM; case ma_opensl_stream_type_notification: return SL_ANDROID_STREAM_NOTIFICATION; default: break; } return SL_ANDROID_STREAM_VOICE; } static SLint32 ma_to_recording_preset__opensl(ma_opensl_recording_preset recordingPreset) { switch (recordingPreset) { case ma_opensl_recording_preset_generic: return SL_ANDROID_RECORDING_PRESET_GENERIC; case ma_opensl_recording_preset_camcorder: return SL_ANDROID_RECORDING_PRESET_CAMCORDER; case ma_opensl_recording_preset_voice_recognition: return SL_ANDROID_RECORDING_PRESET_VOICE_RECOGNITION; case ma_opensl_recording_preset_voice_communication: return SL_ANDROID_RECORDING_PRESET_VOICE_COMMUNICATION; case ma_opensl_recording_preset_voice_unprocessed: return SL_ANDROID_RECORDING_PRESET_UNPROCESSED; default: break; } return SL_ANDROID_RECORDING_PRESET_NONE; } static ma_result ma_context_enumerate_devices__opensl(ma_context* pContext, ma_enum_devices_callback_proc callback, void* pUserData) { ma_bool32 cbResult; MA_ASSERT(pContext != NULL); MA_ASSERT(callback != NULL); MA_ASSERT(g_maOpenSLInitCounter > 0); /* <-- If you trigger this it means you've either not initialized the context, or you've uninitialized it and then attempted to enumerate devices. */ if (g_maOpenSLInitCounter == 0) { return MA_INVALID_OPERATION; } /* TODO: Test Me. This is currently untested, so for now we are just returning default devices. */ #if 0 && !defined(MA_ANDROID) ma_bool32 isTerminated = MA_FALSE; SLuint32 pDeviceIDs[128]; SLint32 deviceCount = sizeof(pDeviceIDs) / sizeof(pDeviceIDs[0]); SLAudioIODeviceCapabilitiesItf deviceCaps; SLresult resultSL = (*g_maEngineObjectSL)->GetInterface(g_maEngineObjectSL, (SLInterfaceID)pContext->opensl.SL_IID_AUDIOIODEVICECAPABILITIES, &deviceCaps); if (resultSL != SL_RESULT_SUCCESS) { /* The interface may not be supported so just report a default device. */ goto return_default_device; } /* Playback */ if (!isTerminated) { resultSL = (*deviceCaps)->GetAvailableAudioOutputs(deviceCaps, &deviceCount, pDeviceIDs); if (resultSL != SL_RESULT_SUCCESS) { return ma_result_from_OpenSL(resultSL); } for (SLint32 iDevice = 0; iDevice < deviceCount; ++iDevice) { ma_device_info deviceInfo; MA_ZERO_OBJECT(&deviceInfo); deviceInfo.id.opensl = pDeviceIDs[iDevice]; SLAudioOutputDescriptor desc; resultSL = (*deviceCaps)->QueryAudioOutputCapabilities(deviceCaps, deviceInfo.id.opensl, &desc); if (resultSL == SL_RESULT_SUCCESS) { ma_strncpy_s(deviceInfo.name, sizeof(deviceInfo.name), (const char*)desc.pDeviceName, (size_t)-1); ma_bool32 cbResult = callback(pContext, ma_device_type_playback, &deviceInfo, pUserData); if (cbResult == MA_FALSE) { isTerminated = MA_TRUE; break; } } } } /* Capture */ if (!isTerminated) { resultSL = (*deviceCaps)->GetAvailableAudioInputs(deviceCaps, &deviceCount, pDeviceIDs); if (resultSL != SL_RESULT_SUCCESS) { return ma_result_from_OpenSL(resultSL); } for (SLint32 iDevice = 0; iDevice < deviceCount; ++iDevice) { ma_device_info deviceInfo; MA_ZERO_OBJECT(&deviceInfo); deviceInfo.id.opensl = pDeviceIDs[iDevice]; SLAudioInputDescriptor desc; resultSL = (*deviceCaps)->QueryAudioInputCapabilities(deviceCaps, deviceInfo.id.opensl, &desc); if (resultSL == SL_RESULT_SUCCESS) { ma_strncpy_s(deviceInfo.name, sizeof(deviceInfo.name), (const char*)desc.deviceName, (size_t)-1); ma_bool32 cbResult = callback(pContext, ma_device_type_capture, &deviceInfo, pUserData); if (cbResult == MA_FALSE) { isTerminated = MA_TRUE; break; } } } } return MA_SUCCESS; #else goto return_default_device; #endif return_default_device:; cbResult = MA_TRUE; /* Playback. */ if (cbResult) { ma_device_info deviceInfo; MA_ZERO_OBJECT(&deviceInfo); deviceInfo.id.opensl = SL_DEFAULTDEVICEID_AUDIOOUTPUT; ma_strncpy_s(deviceInfo.name, sizeof(deviceInfo.name), MA_DEFAULT_PLAYBACK_DEVICE_NAME, (size_t)-1); cbResult = callback(pContext, ma_device_type_playback, &deviceInfo, pUserData); } /* Capture. */ if (cbResult) { ma_device_info deviceInfo; MA_ZERO_OBJECT(&deviceInfo); deviceInfo.id.opensl = SL_DEFAULTDEVICEID_AUDIOINPUT; ma_strncpy_s(deviceInfo.name, sizeof(deviceInfo.name), MA_DEFAULT_CAPTURE_DEVICE_NAME, (size_t)-1); cbResult = callback(pContext, ma_device_type_capture, &deviceInfo, pUserData); } return MA_SUCCESS; } static void ma_context_add_data_format_ex__opensl(ma_context* pContext, ma_format format, ma_uint32 channels, ma_uint32 sampleRate, ma_device_info* pDeviceInfo) { MA_ASSERT(pContext != NULL); MA_ASSERT(pDeviceInfo != NULL); pDeviceInfo->nativeDataFormats[pDeviceInfo->nativeDataFormatCount].format = format; pDeviceInfo->nativeDataFormats[pDeviceInfo->nativeDataFormatCount].channels = channels; pDeviceInfo->nativeDataFormats[pDeviceInfo->nativeDataFormatCount].sampleRate = sampleRate; pDeviceInfo->nativeDataFormats[pDeviceInfo->nativeDataFormatCount].flags = 0; pDeviceInfo->nativeDataFormatCount += 1; } static void ma_context_add_data_format__opensl(ma_context* pContext, ma_format format, ma_device_info* pDeviceInfo) { ma_uint32 minChannels = 1; ma_uint32 maxChannels = 2; ma_uint32 minSampleRate = (ma_uint32)ma_standard_sample_rate_8000; ma_uint32 maxSampleRate = (ma_uint32)ma_standard_sample_rate_48000; ma_uint32 iChannel; ma_uint32 iSampleRate; MA_ASSERT(pContext != NULL); MA_ASSERT(pDeviceInfo != NULL); /* Each sample format can support mono and stereo, and we'll support a small subset of standard rates (up to 48000). A better solution would be to somehow find a native sample rate. */ for (iChannel = minChannels; iChannel < maxChannels; iChannel += 1) { for (iSampleRate = 0; iSampleRate < ma_countof(g_maStandardSampleRatePriorities); iSampleRate += 1) { ma_uint32 standardSampleRate = g_maStandardSampleRatePriorities[iSampleRate]; if (standardSampleRate >= minSampleRate && standardSampleRate <= maxSampleRate) { ma_context_add_data_format_ex__opensl(pContext, format, iChannel, standardSampleRate, pDeviceInfo); } } } } static ma_result ma_context_get_device_info__opensl(ma_context* pContext, ma_device_type deviceType, const ma_device_id* pDeviceID, ma_device_info* pDeviceInfo) { MA_ASSERT(pContext != NULL); MA_ASSERT(g_maOpenSLInitCounter > 0); /* <-- If you trigger this it means you've either not initialized the context, or you've uninitialized it and then attempted to get device info. */ if (g_maOpenSLInitCounter == 0) { return MA_INVALID_OPERATION; } /* TODO: Test Me. This is currently untested, so for now we are just returning default devices. */ #if 0 && !defined(MA_ANDROID) SLAudioIODeviceCapabilitiesItf deviceCaps; SLresult resultSL = (*g_maEngineObjectSL)->GetInterface(g_maEngineObjectSL, (SLInterfaceID)pContext->opensl.SL_IID_AUDIOIODEVICECAPABILITIES, &deviceCaps); if (resultSL != SL_RESULT_SUCCESS) { /* The interface may not be supported so just report a default device. */ goto return_default_device; } if (deviceType == ma_device_type_playback) { SLAudioOutputDescriptor desc; resultSL = (*deviceCaps)->QueryAudioOutputCapabilities(deviceCaps, pDeviceID->opensl, &desc); if (resultSL != SL_RESULT_SUCCESS) { return ma_result_from_OpenSL(resultSL); } ma_strncpy_s(pDeviceInfo->name, sizeof(pDeviceInfo->name), (const char*)desc.pDeviceName, (size_t)-1); } else { SLAudioInputDescriptor desc; resultSL = (*deviceCaps)->QueryAudioInputCapabilities(deviceCaps, pDeviceID->opensl, &desc); if (resultSL != SL_RESULT_SUCCESS) { return ma_result_from_OpenSL(resultSL); } ma_strncpy_s(pDeviceInfo->name, sizeof(pDeviceInfo->name), (const char*)desc.deviceName, (size_t)-1); } goto return_detailed_info; #else goto return_default_device; #endif return_default_device: if (pDeviceID != NULL) { if ((deviceType == ma_device_type_playback && pDeviceID->opensl != SL_DEFAULTDEVICEID_AUDIOOUTPUT) || (deviceType == ma_device_type_capture && pDeviceID->opensl != SL_DEFAULTDEVICEID_AUDIOINPUT)) { return MA_NO_DEVICE; /* Don't know the device. */ } } /* ID and Name / Description */ if (deviceType == ma_device_type_playback) { pDeviceInfo->id.opensl = SL_DEFAULTDEVICEID_AUDIOOUTPUT; ma_strncpy_s(pDeviceInfo->name, sizeof(pDeviceInfo->name), MA_DEFAULT_PLAYBACK_DEVICE_NAME, (size_t)-1); } else { pDeviceInfo->id.opensl = SL_DEFAULTDEVICEID_AUDIOINPUT; ma_strncpy_s(pDeviceInfo->name, sizeof(pDeviceInfo->name), MA_DEFAULT_CAPTURE_DEVICE_NAME, (size_t)-1); } pDeviceInfo->isDefault = MA_TRUE; goto return_detailed_info; return_detailed_info: /* For now we're just outputting a set of values that are supported by the API but not necessarily supported by the device natively. Later on we should work on this so that it more closely reflects the device's actual native format. */ pDeviceInfo->nativeDataFormatCount = 0; #if defined(MA_ANDROID) && __ANDROID_API__ >= 21 ma_context_add_data_format__opensl(pContext, ma_format_f32, pDeviceInfo); #endif ma_context_add_data_format__opensl(pContext, ma_format_s16, pDeviceInfo); ma_context_add_data_format__opensl(pContext, ma_format_u8, pDeviceInfo); return MA_SUCCESS; } #ifdef MA_ANDROID /*void ma_buffer_queue_callback_capture__opensl_android(SLAndroidSimpleBufferQueueItf pBufferQueue, SLuint32 eventFlags, const void* pBuffer, SLuint32 bufferSize, SLuint32 dataUsed, void* pContext)*/ static void ma_buffer_queue_callback_capture__opensl_android(SLAndroidSimpleBufferQueueItf pBufferQueue, void* pUserData) { ma_device* pDevice = (ma_device*)pUserData; size_t periodSizeInBytes; ma_uint8* pBuffer; SLresult resultSL; MA_ASSERT(pDevice != NULL); (void)pBufferQueue; /* For now, don't do anything unless the buffer was fully processed. From what I can tell, it looks like OpenSL|ES 1.1 improves on buffer queues to the point that we could much more intelligently handle this, but unfortunately it looks like Android is only supporting OpenSL|ES 1.0.1 for now :( */ /* Don't do anything if the device is not started. */ if (ma_device_get_state(pDevice) != ma_device_state_started) { return; } /* Don't do anything if the device is being drained. */ if (pDevice->opensl.isDrainingCapture) { return; } periodSizeInBytes = pDevice->capture.internalPeriodSizeInFrames * ma_get_bytes_per_frame(pDevice->capture.internalFormat, pDevice->capture.internalChannels); pBuffer = pDevice->opensl.pBufferCapture + (pDevice->opensl.currentBufferIndexCapture * periodSizeInBytes); ma_device_handle_backend_data_callback(pDevice, NULL, pBuffer, pDevice->capture.internalPeriodSizeInFrames); resultSL = MA_OPENSL_BUFFERQUEUE(pDevice->opensl.pBufferQueueCapture)->Enqueue((SLAndroidSimpleBufferQueueItf)pDevice->opensl.pBufferQueueCapture, pBuffer, periodSizeInBytes); if (resultSL != SL_RESULT_SUCCESS) { return; } pDevice->opensl.currentBufferIndexCapture = (pDevice->opensl.currentBufferIndexCapture + 1) % pDevice->capture.internalPeriods; } static void ma_buffer_queue_callback_playback__opensl_android(SLAndroidSimpleBufferQueueItf pBufferQueue, void* pUserData) { ma_device* pDevice = (ma_device*)pUserData; size_t periodSizeInBytes; ma_uint8* pBuffer; SLresult resultSL; MA_ASSERT(pDevice != NULL); (void)pBufferQueue; /* Don't do anything if the device is not started. */ if (ma_device_get_state(pDevice) != ma_device_state_started) { return; } /* Don't do anything if the device is being drained. */ if (pDevice->opensl.isDrainingPlayback) { return; } periodSizeInBytes = pDevice->playback.internalPeriodSizeInFrames * ma_get_bytes_per_frame(pDevice->playback.internalFormat, pDevice->playback.internalChannels); pBuffer = pDevice->opensl.pBufferPlayback + (pDevice->opensl.currentBufferIndexPlayback * periodSizeInBytes); ma_device_handle_backend_data_callback(pDevice, pBuffer, NULL, pDevice->playback.internalPeriodSizeInFrames); resultSL = MA_OPENSL_BUFFERQUEUE(pDevice->opensl.pBufferQueuePlayback)->Enqueue((SLAndroidSimpleBufferQueueItf)pDevice->opensl.pBufferQueuePlayback, pBuffer, periodSizeInBytes); if (resultSL != SL_RESULT_SUCCESS) { return; } pDevice->opensl.currentBufferIndexPlayback = (pDevice->opensl.currentBufferIndexPlayback + 1) % pDevice->playback.internalPeriods; } #endif static ma_result ma_device_uninit__opensl(ma_device* pDevice) { MA_ASSERT(pDevice != NULL); MA_ASSERT(g_maOpenSLInitCounter > 0); /* <-- If you trigger this it means you've either not initialized the context, or you've uninitialized it before uninitializing the device. */ if (g_maOpenSLInitCounter == 0) { return MA_INVALID_OPERATION; } if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) { if (pDevice->opensl.pAudioRecorderObj) { MA_OPENSL_OBJ(pDevice->opensl.pAudioRecorderObj)->Destroy((SLObjectItf)pDevice->opensl.pAudioRecorderObj); } ma_free(pDevice->opensl.pBufferCapture, &pDevice->pContext->allocationCallbacks); } if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) { if (pDevice->opensl.pAudioPlayerObj) { MA_OPENSL_OBJ(pDevice->opensl.pAudioPlayerObj)->Destroy((SLObjectItf)pDevice->opensl.pAudioPlayerObj); } if (pDevice->opensl.pOutputMixObj) { MA_OPENSL_OBJ(pDevice->opensl.pOutputMixObj)->Destroy((SLObjectItf)pDevice->opensl.pOutputMixObj); } ma_free(pDevice->opensl.pBufferPlayback, &pDevice->pContext->allocationCallbacks); } return MA_SUCCESS; } #if defined(MA_ANDROID) && __ANDROID_API__ >= 21 typedef SLAndroidDataFormat_PCM_EX ma_SLDataFormat_PCM; #else typedef SLDataFormat_PCM ma_SLDataFormat_PCM; #endif static ma_result ma_SLDataFormat_PCM_init__opensl(ma_format format, ma_uint32 channels, ma_uint32 sampleRate, const ma_channel* channelMap, ma_SLDataFormat_PCM* pDataFormat) { /* We need to convert our format/channels/rate so that they aren't set to default. */ if (format == ma_format_unknown) { format = MA_DEFAULT_FORMAT; } if (channels == 0) { channels = MA_DEFAULT_CHANNELS; } if (sampleRate == 0) { sampleRate = MA_DEFAULT_SAMPLE_RATE; } #if defined(MA_ANDROID) && __ANDROID_API__ >= 21 if (format == ma_format_f32) { pDataFormat->formatType = SL_ANDROID_DATAFORMAT_PCM_EX; pDataFormat->representation = SL_ANDROID_PCM_REPRESENTATION_FLOAT; } else { pDataFormat->formatType = SL_DATAFORMAT_PCM; } #else pDataFormat->formatType = SL_DATAFORMAT_PCM; #endif pDataFormat->numChannels = channels; ((SLDataFormat_PCM*)pDataFormat)->samplesPerSec = ma_round_to_standard_sample_rate__opensl(sampleRate * 1000); /* In millihertz. Annoyingly, the sample rate variable is named differently between SLAndroidDataFormat_PCM_EX and SLDataFormat_PCM */ pDataFormat->bitsPerSample = ma_get_bytes_per_sample(format) * 8; pDataFormat->channelMask = ma_channel_map_to_channel_mask__opensl(channelMap, channels); pDataFormat->endianness = (ma_is_little_endian()) ? SL_BYTEORDER_LITTLEENDIAN : SL_BYTEORDER_BIGENDIAN; /* Android has a few restrictions on the format as documented here: https://developer.android.com/ndk/guides/audio/opensl-for-android.html - Only mono and stereo is supported. - Only u8 and s16 formats are supported. - Maximum sample rate of 48000. */ #ifdef MA_ANDROID if (pDataFormat->numChannels > 2) { pDataFormat->numChannels = 2; } #if __ANDROID_API__ >= 21 if (pDataFormat->formatType == SL_ANDROID_DATAFORMAT_PCM_EX) { /* It's floating point. */ MA_ASSERT(pDataFormat->representation == SL_ANDROID_PCM_REPRESENTATION_FLOAT); if (pDataFormat->bitsPerSample > 32) { pDataFormat->bitsPerSample = 32; } } else { if (pDataFormat->bitsPerSample > 16) { pDataFormat->bitsPerSample = 16; } } #else if (pDataFormat->bitsPerSample > 16) { pDataFormat->bitsPerSample = 16; } #endif if (((SLDataFormat_PCM*)pDataFormat)->samplesPerSec > SL_SAMPLINGRATE_48) { ((SLDataFormat_PCM*)pDataFormat)->samplesPerSec = SL_SAMPLINGRATE_48; } #endif pDataFormat->containerSize = pDataFormat->bitsPerSample; /* Always tightly packed for now. */ return MA_SUCCESS; } static ma_result ma_deconstruct_SLDataFormat_PCM__opensl(ma_SLDataFormat_PCM* pDataFormat, ma_format* pFormat, ma_uint32* pChannels, ma_uint32* pSampleRate, ma_channel* pChannelMap, size_t channelMapCap) { ma_bool32 isFloatingPoint = MA_FALSE; #if defined(MA_ANDROID) && __ANDROID_API__ >= 21 if (pDataFormat->formatType == SL_ANDROID_DATAFORMAT_PCM_EX) { MA_ASSERT(pDataFormat->representation == SL_ANDROID_PCM_REPRESENTATION_FLOAT); isFloatingPoint = MA_TRUE; } #endif if (isFloatingPoint) { if (pDataFormat->bitsPerSample == 32) { *pFormat = ma_format_f32; } } else { if (pDataFormat->bitsPerSample == 8) { *pFormat = ma_format_u8; } else if (pDataFormat->bitsPerSample == 16) { *pFormat = ma_format_s16; } else if (pDataFormat->bitsPerSample == 24) { *pFormat = ma_format_s24; } else if (pDataFormat->bitsPerSample == 32) { *pFormat = ma_format_s32; } } *pChannels = pDataFormat->numChannels; *pSampleRate = ((SLDataFormat_PCM*)pDataFormat)->samplesPerSec / 1000; ma_channel_mask_to_channel_map__opensl(pDataFormat->channelMask, ma_min(pDataFormat->numChannels, channelMapCap), pChannelMap); return MA_SUCCESS; } static ma_result ma_device_init__opensl(ma_device* pDevice, const ma_device_config* pConfig, ma_device_descriptor* pDescriptorPlayback, ma_device_descriptor* pDescriptorCapture) { #ifdef MA_ANDROID SLDataLocator_AndroidSimpleBufferQueue queue; SLresult resultSL; size_t bufferSizeInBytes; SLInterfaceID itfIDs[2]; const SLboolean itfIDsRequired[] = { SL_BOOLEAN_TRUE, /* SL_IID_ANDROIDSIMPLEBUFFERQUEUE */ SL_BOOLEAN_FALSE /* SL_IID_ANDROIDCONFIGURATION */ }; #endif MA_ASSERT(g_maOpenSLInitCounter > 0); /* <-- If you trigger this it means you've either not initialized the context, or you've uninitialized it and then attempted to initialize a new device. */ if (g_maOpenSLInitCounter == 0) { return MA_INVALID_OPERATION; } if (pConfig->deviceType == ma_device_type_loopback) { return MA_DEVICE_TYPE_NOT_SUPPORTED; } /* For now, only supporting Android implementations of OpenSL|ES since that's the only one I've been able to test with and I currently depend on Android-specific extensions (simple buffer queues). */ #ifdef MA_ANDROID itfIDs[0] = (SLInterfaceID)pDevice->pContext->opensl.SL_IID_ANDROIDSIMPLEBUFFERQUEUE; itfIDs[1] = (SLInterfaceID)pDevice->pContext->opensl.SL_IID_ANDROIDCONFIGURATION; /* No exclusive mode with OpenSL|ES. */ if (((pConfig->deviceType == ma_device_type_playback || pConfig->deviceType == ma_device_type_duplex) && pDescriptorPlayback->shareMode == ma_share_mode_exclusive) || ((pConfig->deviceType == ma_device_type_capture || pConfig->deviceType == ma_device_type_duplex) && pDescriptorCapture->shareMode == ma_share_mode_exclusive)) { return MA_SHARE_MODE_NOT_SUPPORTED; } /* Now we can start initializing the device properly. */ MA_ASSERT(pDevice != NULL); MA_ZERO_OBJECT(&pDevice->opensl); queue.locatorType = SL_DATALOCATOR_ANDROIDSIMPLEBUFFERQUEUE; if (pConfig->deviceType == ma_device_type_capture || pConfig->deviceType == ma_device_type_duplex) { ma_SLDataFormat_PCM pcm; SLDataLocator_IODevice locatorDevice; SLDataSource source; SLDataSink sink; SLAndroidConfigurationItf pRecorderConfig; ma_SLDataFormat_PCM_init__opensl(pDescriptorCapture->format, pDescriptorCapture->channels, pDescriptorCapture->sampleRate, pDescriptorCapture->channelMap, &pcm); locatorDevice.locatorType = SL_DATALOCATOR_IODEVICE; locatorDevice.deviceType = SL_IODEVICE_AUDIOINPUT; locatorDevice.deviceID = SL_DEFAULTDEVICEID_AUDIOINPUT; /* Must always use the default device with Android. */ locatorDevice.device = NULL; source.pLocator = &locatorDevice; source.pFormat = NULL; queue.numBuffers = pDescriptorCapture->periodCount; sink.pLocator = &queue; sink.pFormat = (SLDataFormat_PCM*)&pcm; resultSL = (*g_maEngineSL)->CreateAudioRecorder(g_maEngineSL, (SLObjectItf*)&pDevice->opensl.pAudioRecorderObj, &source, &sink, ma_countof(itfIDs), itfIDs, itfIDsRequired); if (resultSL == SL_RESULT_CONTENT_UNSUPPORTED || resultSL == SL_RESULT_PARAMETER_INVALID) { /* Unsupported format. Fall back to something safer and try again. If this fails, just abort. */ pcm.formatType = SL_DATAFORMAT_PCM; pcm.numChannels = 1; ((SLDataFormat_PCM*)&pcm)->samplesPerSec = SL_SAMPLINGRATE_16; /* The name of the sample rate variable is different between SLAndroidDataFormat_PCM_EX and SLDataFormat_PCM. */ pcm.bitsPerSample = 16; pcm.containerSize = pcm.bitsPerSample; /* Always tightly packed for now. */ pcm.channelMask = 0; resultSL = (*g_maEngineSL)->CreateAudioRecorder(g_maEngineSL, (SLObjectItf*)&pDevice->opensl.pAudioRecorderObj, &source, &sink, ma_countof(itfIDs), itfIDs, itfIDsRequired); } if (resultSL != SL_RESULT_SUCCESS) { ma_device_uninit__opensl(pDevice); ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[OpenSL] Failed to create audio recorder."); return ma_result_from_OpenSL(resultSL); } /* Set the recording preset before realizing the player. */ if (pConfig->opensl.recordingPreset != ma_opensl_recording_preset_default) { resultSL = MA_OPENSL_OBJ(pDevice->opensl.pAudioRecorderObj)->GetInterface((SLObjectItf)pDevice->opensl.pAudioRecorderObj, (SLInterfaceID)pDevice->pContext->opensl.SL_IID_ANDROIDCONFIGURATION, &pRecorderConfig); if (resultSL == SL_RESULT_SUCCESS) { SLint32 recordingPreset = ma_to_recording_preset__opensl(pConfig->opensl.recordingPreset); resultSL = (*pRecorderConfig)->SetConfiguration(pRecorderConfig, SL_ANDROID_KEY_RECORDING_PRESET, &recordingPreset, sizeof(SLint32)); if (resultSL != SL_RESULT_SUCCESS) { /* Failed to set the configuration. Just keep going. */ } } } resultSL = MA_OPENSL_OBJ(pDevice->opensl.pAudioRecorderObj)->Realize((SLObjectItf)pDevice->opensl.pAudioRecorderObj, SL_BOOLEAN_FALSE); if (resultSL != SL_RESULT_SUCCESS) { ma_device_uninit__opensl(pDevice); ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[OpenSL] Failed to realize audio recorder."); return ma_result_from_OpenSL(resultSL); } resultSL = MA_OPENSL_OBJ(pDevice->opensl.pAudioRecorderObj)->GetInterface((SLObjectItf)pDevice->opensl.pAudioRecorderObj, (SLInterfaceID)pDevice->pContext->opensl.SL_IID_RECORD, &pDevice->opensl.pAudioRecorder); if (resultSL != SL_RESULT_SUCCESS) { ma_device_uninit__opensl(pDevice); ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[OpenSL] Failed to retrieve SL_IID_RECORD interface."); return ma_result_from_OpenSL(resultSL); } resultSL = MA_OPENSL_OBJ(pDevice->opensl.pAudioRecorderObj)->GetInterface((SLObjectItf)pDevice->opensl.pAudioRecorderObj, (SLInterfaceID)pDevice->pContext->opensl.SL_IID_ANDROIDSIMPLEBUFFERQUEUE, &pDevice->opensl.pBufferQueueCapture); if (resultSL != SL_RESULT_SUCCESS) { ma_device_uninit__opensl(pDevice); ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[OpenSL] Failed to retrieve SL_IID_ANDROIDSIMPLEBUFFERQUEUE interface."); return ma_result_from_OpenSL(resultSL); } resultSL = MA_OPENSL_BUFFERQUEUE(pDevice->opensl.pBufferQueueCapture)->RegisterCallback((SLAndroidSimpleBufferQueueItf)pDevice->opensl.pBufferQueueCapture, ma_buffer_queue_callback_capture__opensl_android, pDevice); if (resultSL != SL_RESULT_SUCCESS) { ma_device_uninit__opensl(pDevice); ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[OpenSL] Failed to register buffer queue callback."); return ma_result_from_OpenSL(resultSL); } /* The internal format is determined by the "pcm" object. */ ma_deconstruct_SLDataFormat_PCM__opensl(&pcm, &pDescriptorCapture->format, &pDescriptorCapture->channels, &pDescriptorCapture->sampleRate, pDescriptorCapture->channelMap, ma_countof(pDescriptorCapture->channelMap)); /* Buffer. */ pDescriptorCapture->periodSizeInFrames = ma_calculate_buffer_size_in_frames_from_descriptor(pDescriptorCapture, pDescriptorCapture->sampleRate, pConfig->performanceProfile); pDevice->opensl.currentBufferIndexCapture = 0; bufferSizeInBytes = pDescriptorCapture->periodSizeInFrames * ma_get_bytes_per_frame(pDescriptorCapture->format, pDescriptorCapture->channels) * pDescriptorCapture->periodCount; pDevice->opensl.pBufferCapture = (ma_uint8*)ma_calloc(bufferSizeInBytes, &pDevice->pContext->allocationCallbacks); if (pDevice->opensl.pBufferCapture == NULL) { ma_device_uninit__opensl(pDevice); ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[OpenSL] Failed to allocate memory for data buffer."); return MA_OUT_OF_MEMORY; } MA_ZERO_MEMORY(pDevice->opensl.pBufferCapture, bufferSizeInBytes); } if (pConfig->deviceType == ma_device_type_playback || pConfig->deviceType == ma_device_type_duplex) { ma_SLDataFormat_PCM pcm; SLDataSource source; SLDataLocator_OutputMix outmixLocator; SLDataSink sink; SLAndroidConfigurationItf pPlayerConfig; ma_SLDataFormat_PCM_init__opensl(pDescriptorPlayback->format, pDescriptorPlayback->channels, pDescriptorPlayback->sampleRate, pDescriptorPlayback->channelMap, &pcm); resultSL = (*g_maEngineSL)->CreateOutputMix(g_maEngineSL, (SLObjectItf*)&pDevice->opensl.pOutputMixObj, 0, NULL, NULL); if (resultSL != SL_RESULT_SUCCESS) { ma_device_uninit__opensl(pDevice); ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[OpenSL] Failed to create output mix."); return ma_result_from_OpenSL(resultSL); } resultSL = MA_OPENSL_OBJ(pDevice->opensl.pOutputMixObj)->Realize((SLObjectItf)pDevice->opensl.pOutputMixObj, SL_BOOLEAN_FALSE); if (resultSL != SL_RESULT_SUCCESS) { ma_device_uninit__opensl(pDevice); ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[OpenSL] Failed to realize output mix object."); return ma_result_from_OpenSL(resultSL); } resultSL = MA_OPENSL_OBJ(pDevice->opensl.pOutputMixObj)->GetInterface((SLObjectItf)pDevice->opensl.pOutputMixObj, (SLInterfaceID)pDevice->pContext->opensl.SL_IID_OUTPUTMIX, &pDevice->opensl.pOutputMix); if (resultSL != SL_RESULT_SUCCESS) { ma_device_uninit__opensl(pDevice); ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[OpenSL] Failed to retrieve SL_IID_OUTPUTMIX interface."); return ma_result_from_OpenSL(resultSL); } /* Set the output device. */ if (pDescriptorPlayback->pDeviceID != NULL) { SLuint32 deviceID_OpenSL = pDescriptorPlayback->pDeviceID->opensl; MA_OPENSL_OUTPUTMIX(pDevice->opensl.pOutputMix)->ReRoute((SLOutputMixItf)pDevice->opensl.pOutputMix, 1, &deviceID_OpenSL); } queue.numBuffers = pDescriptorPlayback->periodCount; source.pLocator = &queue; source.pFormat = (SLDataFormat_PCM*)&pcm; outmixLocator.locatorType = SL_DATALOCATOR_OUTPUTMIX; outmixLocator.outputMix = (SLObjectItf)pDevice->opensl.pOutputMixObj; sink.pLocator = &outmixLocator; sink.pFormat = NULL; resultSL = (*g_maEngineSL)->CreateAudioPlayer(g_maEngineSL, (SLObjectItf*)&pDevice->opensl.pAudioPlayerObj, &source, &sink, ma_countof(itfIDs), itfIDs, itfIDsRequired); if (resultSL == SL_RESULT_CONTENT_UNSUPPORTED || resultSL == SL_RESULT_PARAMETER_INVALID) { /* Unsupported format. Fall back to something safer and try again. If this fails, just abort. */ pcm.formatType = SL_DATAFORMAT_PCM; pcm.numChannels = 2; ((SLDataFormat_PCM*)&pcm)->samplesPerSec = SL_SAMPLINGRATE_16; pcm.bitsPerSample = 16; pcm.containerSize = pcm.bitsPerSample; /* Always tightly packed for now. */ pcm.channelMask = SL_SPEAKER_FRONT_LEFT | SL_SPEAKER_FRONT_RIGHT; resultSL = (*g_maEngineSL)->CreateAudioPlayer(g_maEngineSL, (SLObjectItf*)&pDevice->opensl.pAudioPlayerObj, &source, &sink, ma_countof(itfIDs), itfIDs, itfIDsRequired); } if (resultSL != SL_RESULT_SUCCESS) { ma_device_uninit__opensl(pDevice); ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[OpenSL] Failed to create audio player."); return ma_result_from_OpenSL(resultSL); } /* Set the stream type before realizing the player. */ if (pConfig->opensl.streamType != ma_opensl_stream_type_default) { resultSL = MA_OPENSL_OBJ(pDevice->opensl.pAudioPlayerObj)->GetInterface((SLObjectItf)pDevice->opensl.pAudioPlayerObj, (SLInterfaceID)pDevice->pContext->opensl.SL_IID_ANDROIDCONFIGURATION, &pPlayerConfig); if (resultSL == SL_RESULT_SUCCESS) { SLint32 streamType = ma_to_stream_type__opensl(pConfig->opensl.streamType); resultSL = (*pPlayerConfig)->SetConfiguration(pPlayerConfig, SL_ANDROID_KEY_STREAM_TYPE, &streamType, sizeof(SLint32)); if (resultSL != SL_RESULT_SUCCESS) { /* Failed to set the configuration. Just keep going. */ } } } resultSL = MA_OPENSL_OBJ(pDevice->opensl.pAudioPlayerObj)->Realize((SLObjectItf)pDevice->opensl.pAudioPlayerObj, SL_BOOLEAN_FALSE); if (resultSL != SL_RESULT_SUCCESS) { ma_device_uninit__opensl(pDevice); ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[OpenSL] Failed to realize audio player."); return ma_result_from_OpenSL(resultSL); } resultSL = MA_OPENSL_OBJ(pDevice->opensl.pAudioPlayerObj)->GetInterface((SLObjectItf)pDevice->opensl.pAudioPlayerObj, (SLInterfaceID)pDevice->pContext->opensl.SL_IID_PLAY, &pDevice->opensl.pAudioPlayer); if (resultSL != SL_RESULT_SUCCESS) { ma_device_uninit__opensl(pDevice); ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[OpenSL] Failed to retrieve SL_IID_PLAY interface."); return ma_result_from_OpenSL(resultSL); } resultSL = MA_OPENSL_OBJ(pDevice->opensl.pAudioPlayerObj)->GetInterface((SLObjectItf)pDevice->opensl.pAudioPlayerObj, (SLInterfaceID)pDevice->pContext->opensl.SL_IID_ANDROIDSIMPLEBUFFERQUEUE, &pDevice->opensl.pBufferQueuePlayback); if (resultSL != SL_RESULT_SUCCESS) { ma_device_uninit__opensl(pDevice); ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[OpenSL] Failed to retrieve SL_IID_ANDROIDSIMPLEBUFFERQUEUE interface."); return ma_result_from_OpenSL(resultSL); } resultSL = MA_OPENSL_BUFFERQUEUE(pDevice->opensl.pBufferQueuePlayback)->RegisterCallback((SLAndroidSimpleBufferQueueItf)pDevice->opensl.pBufferQueuePlayback, ma_buffer_queue_callback_playback__opensl_android, pDevice); if (resultSL != SL_RESULT_SUCCESS) { ma_device_uninit__opensl(pDevice); ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[OpenSL] Failed to register buffer queue callback."); return ma_result_from_OpenSL(resultSL); } /* The internal format is determined by the "pcm" object. */ ma_deconstruct_SLDataFormat_PCM__opensl(&pcm, &pDescriptorPlayback->format, &pDescriptorPlayback->channels, &pDescriptorPlayback->sampleRate, pDescriptorPlayback->channelMap, ma_countof(pDescriptorPlayback->channelMap)); /* Buffer. */ pDescriptorPlayback->periodSizeInFrames = ma_calculate_buffer_size_in_frames_from_descriptor(pDescriptorPlayback, pDescriptorPlayback->sampleRate, pConfig->performanceProfile); pDevice->opensl.currentBufferIndexPlayback = 0; bufferSizeInBytes = pDescriptorPlayback->periodSizeInFrames * ma_get_bytes_per_frame(pDescriptorPlayback->format, pDescriptorPlayback->channels) * pDescriptorPlayback->periodCount; pDevice->opensl.pBufferPlayback = (ma_uint8*)ma_calloc(bufferSizeInBytes, &pDevice->pContext->allocationCallbacks); if (pDevice->opensl.pBufferPlayback == NULL) { ma_device_uninit__opensl(pDevice); ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[OpenSL] Failed to allocate memory for data buffer."); return MA_OUT_OF_MEMORY; } MA_ZERO_MEMORY(pDevice->opensl.pBufferPlayback, bufferSizeInBytes); } return MA_SUCCESS; #else return MA_NO_BACKEND; /* Non-Android implementations are not supported. */ #endif } static ma_result ma_device_start__opensl(ma_device* pDevice) { SLresult resultSL; size_t periodSizeInBytes; ma_uint32 iPeriod; MA_ASSERT(pDevice != NULL); MA_ASSERT(g_maOpenSLInitCounter > 0); /* <-- If you trigger this it means you've either not initialized the context, or you've uninitialized it and then attempted to start the device. */ if (g_maOpenSLInitCounter == 0) { return MA_INVALID_OPERATION; } if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) { resultSL = MA_OPENSL_RECORD(pDevice->opensl.pAudioRecorder)->SetRecordState((SLRecordItf)pDevice->opensl.pAudioRecorder, SL_RECORDSTATE_RECORDING); if (resultSL != SL_RESULT_SUCCESS) { ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[OpenSL] Failed to start internal capture device."); return ma_result_from_OpenSL(resultSL); } periodSizeInBytes = pDevice->capture.internalPeriodSizeInFrames * ma_get_bytes_per_frame(pDevice->capture.internalFormat, pDevice->capture.internalChannels); for (iPeriod = 0; iPeriod < pDevice->capture.internalPeriods; ++iPeriod) { resultSL = MA_OPENSL_BUFFERQUEUE(pDevice->opensl.pBufferQueueCapture)->Enqueue((SLAndroidSimpleBufferQueueItf)pDevice->opensl.pBufferQueueCapture, pDevice->opensl.pBufferCapture + (periodSizeInBytes * iPeriod), periodSizeInBytes); if (resultSL != SL_RESULT_SUCCESS) { MA_OPENSL_RECORD(pDevice->opensl.pAudioRecorder)->SetRecordState((SLRecordItf)pDevice->opensl.pAudioRecorder, SL_RECORDSTATE_STOPPED); ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[OpenSL] Failed to enqueue buffer for capture device."); return ma_result_from_OpenSL(resultSL); } } } if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) { resultSL = MA_OPENSL_PLAY(pDevice->opensl.pAudioPlayer)->SetPlayState((SLPlayItf)pDevice->opensl.pAudioPlayer, SL_PLAYSTATE_PLAYING); if (resultSL != SL_RESULT_SUCCESS) { ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[OpenSL] Failed to start internal playback device."); return ma_result_from_OpenSL(resultSL); } /* In playback mode (no duplex) we need to load some initial buffers. In duplex mode we need to enqueue silent buffers. */ if (pDevice->type == ma_device_type_duplex) { MA_ZERO_MEMORY(pDevice->opensl.pBufferPlayback, pDevice->playback.internalPeriodSizeInFrames * pDevice->playback.internalPeriods * ma_get_bytes_per_frame(pDevice->playback.internalFormat, pDevice->playback.internalChannels)); } else { ma_device__read_frames_from_client(pDevice, pDevice->playback.internalPeriodSizeInFrames * pDevice->playback.internalPeriods, pDevice->opensl.pBufferPlayback); } periodSizeInBytes = pDevice->playback.internalPeriodSizeInFrames * ma_get_bytes_per_frame(pDevice->playback.internalFormat, pDevice->playback.internalChannels); for (iPeriod = 0; iPeriod < pDevice->playback.internalPeriods; ++iPeriod) { resultSL = MA_OPENSL_BUFFERQUEUE(pDevice->opensl.pBufferQueuePlayback)->Enqueue((SLAndroidSimpleBufferQueueItf)pDevice->opensl.pBufferQueuePlayback, pDevice->opensl.pBufferPlayback + (periodSizeInBytes * iPeriod), periodSizeInBytes); if (resultSL != SL_RESULT_SUCCESS) { MA_OPENSL_PLAY(pDevice->opensl.pAudioPlayer)->SetPlayState((SLPlayItf)pDevice->opensl.pAudioPlayer, SL_PLAYSTATE_STOPPED); ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[OpenSL] Failed to enqueue buffer for playback device."); return ma_result_from_OpenSL(resultSL); } } } return MA_SUCCESS; } static ma_result ma_device_drain__opensl(ma_device* pDevice, ma_device_type deviceType) { SLAndroidSimpleBufferQueueItf pBufferQueue; MA_ASSERT(deviceType == ma_device_type_capture || deviceType == ma_device_type_playback); if (pDevice->type == ma_device_type_capture) { pBufferQueue = (SLAndroidSimpleBufferQueueItf)pDevice->opensl.pBufferQueueCapture; pDevice->opensl.isDrainingCapture = MA_TRUE; } else { pBufferQueue = (SLAndroidSimpleBufferQueueItf)pDevice->opensl.pBufferQueuePlayback; pDevice->opensl.isDrainingPlayback = MA_TRUE; } for (;;) { SLAndroidSimpleBufferQueueState state; MA_OPENSL_BUFFERQUEUE(pBufferQueue)->GetState(pBufferQueue, &state); if (state.count == 0) { break; } ma_sleep(10); } if (pDevice->type == ma_device_type_capture) { pDevice->opensl.isDrainingCapture = MA_FALSE; } else { pDevice->opensl.isDrainingPlayback = MA_FALSE; } return MA_SUCCESS; } static ma_result ma_device_stop__opensl(ma_device* pDevice) { SLresult resultSL; MA_ASSERT(pDevice != NULL); MA_ASSERT(g_maOpenSLInitCounter > 0); /* <-- If you trigger this it means you've either not initialized the context, or you've uninitialized it before stopping/uninitializing the device. */ if (g_maOpenSLInitCounter == 0) { return MA_INVALID_OPERATION; } if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) { ma_device_drain__opensl(pDevice, ma_device_type_capture); resultSL = MA_OPENSL_RECORD(pDevice->opensl.pAudioRecorder)->SetRecordState((SLRecordItf)pDevice->opensl.pAudioRecorder, SL_RECORDSTATE_STOPPED); if (resultSL != SL_RESULT_SUCCESS) { ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[OpenSL] Failed to stop internal capture device."); return ma_result_from_OpenSL(resultSL); } MA_OPENSL_BUFFERQUEUE(pDevice->opensl.pBufferQueueCapture)->Clear((SLAndroidSimpleBufferQueueItf)pDevice->opensl.pBufferQueueCapture); } if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) { ma_device_drain__opensl(pDevice, ma_device_type_playback); resultSL = MA_OPENSL_PLAY(pDevice->opensl.pAudioPlayer)->SetPlayState((SLPlayItf)pDevice->opensl.pAudioPlayer, SL_PLAYSTATE_STOPPED); if (resultSL != SL_RESULT_SUCCESS) { ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[OpenSL] Failed to stop internal playback device."); return ma_result_from_OpenSL(resultSL); } MA_OPENSL_BUFFERQUEUE(pDevice->opensl.pBufferQueuePlayback)->Clear((SLAndroidSimpleBufferQueueItf)pDevice->opensl.pBufferQueuePlayback); } /* Make sure the client is aware that the device has stopped. There may be an OpenSL|ES callback for this, but I haven't found it. */ ma_device__on_notification_stopped(pDevice); return MA_SUCCESS; } static ma_result ma_context_uninit__opensl(ma_context* pContext) { MA_ASSERT(pContext != NULL); MA_ASSERT(pContext->backend == ma_backend_opensl); (void)pContext; /* Uninit global data. */ ma_spinlock_lock(&g_maOpenSLSpinlock); { MA_ASSERT(g_maOpenSLInitCounter > 0); /* If you've triggered this, it means you have ma_context_init/uninit mismatch. Each successful call to ma_context_init() must be matched up with a call to ma_context_uninit(). */ g_maOpenSLInitCounter -= 1; if (g_maOpenSLInitCounter == 0) { (*g_maEngineObjectSL)->Destroy(g_maEngineObjectSL); } } ma_spinlock_unlock(&g_maOpenSLSpinlock); return MA_SUCCESS; } static ma_result ma_dlsym_SLInterfaceID__opensl(ma_context* pContext, const char* pName, ma_handle* pHandle) { /* We need to return an error if the symbol cannot be found. This is important because there have been reports that some symbols do not exist. */ ma_handle* p = (ma_handle*)ma_dlsym(ma_context_get_log(pContext), pContext->opensl.libOpenSLES, pName); if (p == NULL) { ma_log_postf(ma_context_get_log(pContext), MA_LOG_LEVEL_INFO, "[OpenSL] Cannot find symbol %s", pName); return MA_NO_BACKEND; } *pHandle = *p; return MA_SUCCESS; } static ma_result ma_context_init_engine_nolock__opensl(ma_context* pContext) { g_maOpenSLInitCounter += 1; if (g_maOpenSLInitCounter == 1) { SLresult resultSL; resultSL = ((ma_slCreateEngine_proc)pContext->opensl.slCreateEngine)(&g_maEngineObjectSL, 0, NULL, 0, NULL, NULL); if (resultSL != SL_RESULT_SUCCESS) { g_maOpenSLInitCounter -= 1; return ma_result_from_OpenSL(resultSL); } (*g_maEngineObjectSL)->Realize(g_maEngineObjectSL, SL_BOOLEAN_FALSE); resultSL = (*g_maEngineObjectSL)->GetInterface(g_maEngineObjectSL, (SLInterfaceID)pContext->opensl.SL_IID_ENGINE, &g_maEngineSL); if (resultSL != SL_RESULT_SUCCESS) { (*g_maEngineObjectSL)->Destroy(g_maEngineObjectSL); g_maOpenSLInitCounter -= 1; return ma_result_from_OpenSL(resultSL); } } return MA_SUCCESS; } static ma_result ma_context_init__opensl(ma_context* pContext, const ma_context_config* pConfig, ma_backend_callbacks* pCallbacks) { ma_result result; #if !defined(MA_NO_RUNTIME_LINKING) size_t i; const char* libOpenSLESNames[] = { "libOpenSLES.so" }; #endif MA_ASSERT(pContext != NULL); (void)pConfig; #if !defined(MA_NO_RUNTIME_LINKING) /* Dynamically link against libOpenSLES.so. I have now had multiple reports that SL_IID_ANDROIDSIMPLEBUFFERQUEUE cannot be found. One report was happening at compile time and another at runtime. To try working around this, I'm going to link to libOpenSLES at runtime and extract the symbols rather than reference them directly. This should, hopefully, fix these issues as the compiler won't see any references to the symbols and will hopefully skip the checks. */ for (i = 0; i < ma_countof(libOpenSLESNames); i += 1) { pContext->opensl.libOpenSLES = ma_dlopen(ma_context_get_log(pContext), libOpenSLESNames[i]); if (pContext->opensl.libOpenSLES != NULL) { break; } } if (pContext->opensl.libOpenSLES == NULL) { ma_log_post(ma_context_get_log(pContext), MA_LOG_LEVEL_INFO, "[OpenSL] Could not find libOpenSLES.so"); return MA_NO_BACKEND; } result = ma_dlsym_SLInterfaceID__opensl(pContext, "SL_IID_ENGINE", &pContext->opensl.SL_IID_ENGINE); if (result != MA_SUCCESS) { ma_dlclose(ma_context_get_log(pContext), pContext->opensl.libOpenSLES); return result; } result = ma_dlsym_SLInterfaceID__opensl(pContext, "SL_IID_AUDIOIODEVICECAPABILITIES", &pContext->opensl.SL_IID_AUDIOIODEVICECAPABILITIES); if (result != MA_SUCCESS) { ma_dlclose(ma_context_get_log(pContext), pContext->opensl.libOpenSLES); return result; } result = ma_dlsym_SLInterfaceID__opensl(pContext, "SL_IID_ANDROIDSIMPLEBUFFERQUEUE", &pContext->opensl.SL_IID_ANDROIDSIMPLEBUFFERQUEUE); if (result != MA_SUCCESS) { ma_dlclose(ma_context_get_log(pContext), pContext->opensl.libOpenSLES); return result; } result = ma_dlsym_SLInterfaceID__opensl(pContext, "SL_IID_RECORD", &pContext->opensl.SL_IID_RECORD); if (result != MA_SUCCESS) { ma_dlclose(ma_context_get_log(pContext), pContext->opensl.libOpenSLES); return result; } result = ma_dlsym_SLInterfaceID__opensl(pContext, "SL_IID_PLAY", &pContext->opensl.SL_IID_PLAY); if (result != MA_SUCCESS) { ma_dlclose(ma_context_get_log(pContext), pContext->opensl.libOpenSLES); return result; } result = ma_dlsym_SLInterfaceID__opensl(pContext, "SL_IID_OUTPUTMIX", &pContext->opensl.SL_IID_OUTPUTMIX); if (result != MA_SUCCESS) { ma_dlclose(ma_context_get_log(pContext), pContext->opensl.libOpenSLES); return result; } result = ma_dlsym_SLInterfaceID__opensl(pContext, "SL_IID_ANDROIDCONFIGURATION", &pContext->opensl.SL_IID_ANDROIDCONFIGURATION); if (result != MA_SUCCESS) { ma_dlclose(ma_context_get_log(pContext), pContext->opensl.libOpenSLES); return result; } pContext->opensl.slCreateEngine = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->opensl.libOpenSLES, "slCreateEngine"); if (pContext->opensl.slCreateEngine == NULL) { ma_dlclose(ma_context_get_log(pContext), pContext->opensl.libOpenSLES); ma_log_post(ma_context_get_log(pContext), MA_LOG_LEVEL_INFO, "[OpenSL] Cannot find symbol slCreateEngine."); return MA_NO_BACKEND; } #else pContext->opensl.SL_IID_ENGINE = (ma_handle)SL_IID_ENGINE; pContext->opensl.SL_IID_AUDIOIODEVICECAPABILITIES = (ma_handle)SL_IID_AUDIOIODEVICECAPABILITIES; pContext->opensl.SL_IID_ANDROIDSIMPLEBUFFERQUEUE = (ma_handle)SL_IID_ANDROIDSIMPLEBUFFERQUEUE; pContext->opensl.SL_IID_RECORD = (ma_handle)SL_IID_RECORD; pContext->opensl.SL_IID_PLAY = (ma_handle)SL_IID_PLAY; pContext->opensl.SL_IID_OUTPUTMIX = (ma_handle)SL_IID_OUTPUTMIX; pContext->opensl.SL_IID_ANDROIDCONFIGURATION = (ma_handle)SL_IID_ANDROIDCONFIGURATION; pContext->opensl.slCreateEngine = (ma_proc)slCreateEngine; #endif /* Initialize global data first if applicable. */ ma_spinlock_lock(&g_maOpenSLSpinlock); { result = ma_context_init_engine_nolock__opensl(pContext); } ma_spinlock_unlock(&g_maOpenSLSpinlock); if (result != MA_SUCCESS) { ma_dlclose(ma_context_get_log(pContext), pContext->opensl.libOpenSLES); ma_log_post(ma_context_get_log(pContext), MA_LOG_LEVEL_INFO, "[OpenSL] Failed to initialize OpenSL engine."); return result; } pCallbacks->onContextInit = ma_context_init__opensl; pCallbacks->onContextUninit = ma_context_uninit__opensl; pCallbacks->onContextEnumerateDevices = ma_context_enumerate_devices__opensl; pCallbacks->onContextGetDeviceInfo = ma_context_get_device_info__opensl; pCallbacks->onDeviceInit = ma_device_init__opensl; pCallbacks->onDeviceUninit = ma_device_uninit__opensl; pCallbacks->onDeviceStart = ma_device_start__opensl; pCallbacks->onDeviceStop = ma_device_stop__opensl; pCallbacks->onDeviceRead = NULL; /* Not needed because OpenSL|ES is asynchronous. */ pCallbacks->onDeviceWrite = NULL; /* Not needed because OpenSL|ES is asynchronous. */ pCallbacks->onDeviceDataLoop = NULL; /* Not needed because OpenSL|ES is asynchronous. */ return MA_SUCCESS; } #endif /* OpenSL|ES */ /****************************************************************************** Web Audio Backend ******************************************************************************/ #ifdef MA_HAS_WEBAUDIO #include #if (__EMSCRIPTEN_major__ > 3) || (__EMSCRIPTEN_major__ == 3 && (__EMSCRIPTEN_minor__ > 1 || (__EMSCRIPTEN_minor__ == 1 && __EMSCRIPTEN_tiny__ >= 32))) #include #define MA_SUPPORT_AUDIO_WORKLETS #endif /* TODO: Version 0.12: Swap this logic around so that AudioWorklets are used by default. Add MA_NO_AUDIO_WORKLETS. */ #if defined(MA_ENABLE_AUDIO_WORKLETS) && defined(MA_SUPPORT_AUDIO_WORKLETS) #define MA_USE_AUDIO_WORKLETS #endif /* The thread stack size must be a multiple of 16. */ #ifndef MA_AUDIO_WORKLETS_THREAD_STACK_SIZE #define MA_AUDIO_WORKLETS_THREAD_STACK_SIZE 16384 #endif #if defined(MA_USE_AUDIO_WORKLETS) #define MA_WEBAUDIO_LATENCY_HINT_BALANCED "balanced" #define MA_WEBAUDIO_LATENCY_HINT_INTERACTIVE "interactive" #define MA_WEBAUDIO_LATENCY_HINT_PLAYBACK "playback" #endif static ma_bool32 ma_is_capture_supported__webaudio() { return EM_ASM_INT({ return (navigator.mediaDevices !== undefined && navigator.mediaDevices.getUserMedia !== undefined); }, 0) != 0; /* Must pass in a dummy argument for C99 compatibility. */ } #ifdef __cplusplus extern "C" { #endif void* EMSCRIPTEN_KEEPALIVE ma_malloc_emscripten(size_t sz, const ma_allocation_callbacks* pAllocationCallbacks) { return ma_malloc(sz, pAllocationCallbacks); } void EMSCRIPTEN_KEEPALIVE ma_free_emscripten(void* p, const ma_allocation_callbacks* pAllocationCallbacks) { ma_free(p, pAllocationCallbacks); } void EMSCRIPTEN_KEEPALIVE ma_device_process_pcm_frames_capture__webaudio(ma_device* pDevice, int frameCount, float* pFrames) { ma_device_handle_backend_data_callback(pDevice, NULL, pFrames, (ma_uint32)frameCount); } void EMSCRIPTEN_KEEPALIVE ma_device_process_pcm_frames_playback__webaudio(ma_device* pDevice, int frameCount, float* pFrames) { ma_device_handle_backend_data_callback(pDevice, pFrames, NULL, (ma_uint32)frameCount); } #ifdef __cplusplus } #endif static ma_result ma_context_enumerate_devices__webaudio(ma_context* pContext, ma_enum_devices_callback_proc callback, void* pUserData) { ma_bool32 cbResult = MA_TRUE; MA_ASSERT(pContext != NULL); MA_ASSERT(callback != NULL); /* Only supporting default devices for now. */ /* Playback. */ if (cbResult) { ma_device_info deviceInfo; MA_ZERO_OBJECT(&deviceInfo); ma_strncpy_s(deviceInfo.name, sizeof(deviceInfo.name), MA_DEFAULT_PLAYBACK_DEVICE_NAME, (size_t)-1); deviceInfo.isDefault = MA_TRUE; /* Only supporting default devices. */ cbResult = callback(pContext, ma_device_type_playback, &deviceInfo, pUserData); } /* Capture. */ if (cbResult) { if (ma_is_capture_supported__webaudio()) { ma_device_info deviceInfo; MA_ZERO_OBJECT(&deviceInfo); ma_strncpy_s(deviceInfo.name, sizeof(deviceInfo.name), MA_DEFAULT_CAPTURE_DEVICE_NAME, (size_t)-1); deviceInfo.isDefault = MA_TRUE; /* Only supporting default devices. */ cbResult = callback(pContext, ma_device_type_capture, &deviceInfo, pUserData); } } return MA_SUCCESS; } static ma_result ma_context_get_device_info__webaudio(ma_context* pContext, ma_device_type deviceType, const ma_device_id* pDeviceID, ma_device_info* pDeviceInfo) { MA_ASSERT(pContext != NULL); if (deviceType == ma_device_type_capture && !ma_is_capture_supported__webaudio()) { return MA_NO_DEVICE; } MA_ZERO_MEMORY(pDeviceInfo->id.webaudio, sizeof(pDeviceInfo->id.webaudio)); /* Only supporting default devices for now. */ (void)pDeviceID; if (deviceType == ma_device_type_playback) { ma_strncpy_s(pDeviceInfo->name, sizeof(pDeviceInfo->name), MA_DEFAULT_PLAYBACK_DEVICE_NAME, (size_t)-1); } else { ma_strncpy_s(pDeviceInfo->name, sizeof(pDeviceInfo->name), MA_DEFAULT_CAPTURE_DEVICE_NAME, (size_t)-1); } /* Only supporting default devices. */ pDeviceInfo->isDefault = MA_TRUE; /* Web Audio can support any number of channels and sample rates. It only supports f32 formats, however. */ pDeviceInfo->nativeDataFormats[0].flags = 0; pDeviceInfo->nativeDataFormats[0].format = ma_format_unknown; pDeviceInfo->nativeDataFormats[0].channels = 0; /* All channels are supported. */ pDeviceInfo->nativeDataFormats[0].sampleRate = EM_ASM_INT({ try { var temp = new (window.AudioContext || window.webkitAudioContext)(); var sampleRate = temp.sampleRate; temp.close(); return sampleRate; } catch(e) { return 0; } }, 0); /* Must pass in a dummy argument for C99 compatibility. */ if (pDeviceInfo->nativeDataFormats[0].sampleRate == 0) { return MA_NO_DEVICE; } pDeviceInfo->nativeDataFormatCount = 1; return MA_SUCCESS; } static ma_result ma_device_uninit__webaudio(ma_device* pDevice) { MA_ASSERT(pDevice != NULL); #if defined(MA_USE_AUDIO_WORKLETS) { EM_ASM({ var device = miniaudio.get_device_by_index($0); if (device.streamNode !== undefined) { device.streamNode.disconnect(); device.streamNode = undefined; } }, pDevice->webaudio.deviceIndex); emscripten_destroy_web_audio_node(pDevice->webaudio.audioWorklet); emscripten_destroy_audio_context(pDevice->webaudio.audioContext); ma_free(pDevice->webaudio.pStackBuffer, &pDevice->pContext->allocationCallbacks); } #else { EM_ASM({ var device = miniaudio.get_device_by_index($0); /* Make sure all nodes are disconnected and marked for collection. */ if (device.scriptNode !== undefined) { device.scriptNode.onaudioprocess = function(e) {}; /* We want to reset the callback to ensure it doesn't get called after AudioContext.close() has returned. Shouldn't happen since we're disconnecting, but just to be safe... */ device.scriptNode.disconnect(); device.scriptNode = undefined; } if (device.streamNode !== undefined) { device.streamNode.disconnect(); device.streamNode = undefined; } /* Stop the device. I think there is a chance the callback could get fired after calling this, hence why we want to clear the callback before closing. */ device.webaudio.close(); device.webaudio = undefined; device.pDevice = undefined; }, pDevice->webaudio.deviceIndex); } #endif /* Clean up the device on the JS side. */ EM_ASM({ miniaudio.untrack_device_by_index($0); }, pDevice->webaudio.deviceIndex); ma_free(pDevice->webaudio.pIntermediaryBuffer, &pDevice->pContext->allocationCallbacks); return MA_SUCCESS; } #if !defined(MA_USE_AUDIO_WORKLETS) static ma_uint32 ma_calculate_period_size_in_frames_from_descriptor__webaudio(const ma_device_descriptor* pDescriptor, ma_uint32 nativeSampleRate, ma_performance_profile performanceProfile) { /* There have been reports of the default buffer size being too small on some browsers. If we're using the default buffer size, we'll make sure the period size is bigger than our standard defaults. */ ma_uint32 periodSizeInFrames; if (nativeSampleRate == 0) { nativeSampleRate = MA_DEFAULT_SAMPLE_RATE; } if (pDescriptor->periodSizeInFrames == 0) { if (pDescriptor->periodSizeInMilliseconds == 0) { if (performanceProfile == ma_performance_profile_low_latency) { periodSizeInFrames = ma_calculate_buffer_size_in_frames_from_milliseconds(33, nativeSampleRate); /* 1 frame @ 30 FPS */ } else { periodSizeInFrames = ma_calculate_buffer_size_in_frames_from_milliseconds(333, nativeSampleRate); } } else { periodSizeInFrames = ma_calculate_buffer_size_in_frames_from_milliseconds(pDescriptor->periodSizeInMilliseconds, nativeSampleRate); } } else { periodSizeInFrames = pDescriptor->periodSizeInFrames; } /* The size of the buffer must be a power of 2 and between 256 and 16384. */ if (periodSizeInFrames < 256) { periodSizeInFrames = 256; } else if (periodSizeInFrames > 16384) { periodSizeInFrames = 16384; } else { periodSizeInFrames = ma_next_power_of_2(periodSizeInFrames); } return periodSizeInFrames; } #endif #if defined(MA_USE_AUDIO_WORKLETS) typedef struct { ma_device* pDevice; const ma_device_config* pConfig; ma_device_descriptor* pDescriptorPlayback; ma_device_descriptor* pDescriptorCapture; } ma_audio_worklet_thread_initialized_data; static EM_BOOL ma_audio_worklet_process_callback__webaudio(int inputCount, const AudioSampleFrame* pInputs, int outputCount, AudioSampleFrame* pOutputs, int paramCount, const AudioParamFrame* pParams, void* pUserData) { ma_device* pDevice = (ma_device*)pUserData; ma_uint32 frameCount; (void)paramCount; (void)pParams; if (ma_device_get_state(pDevice) != ma_device_state_started) { return EM_TRUE; } /* The Emscripten documentation says that it'll always be 128 frames being passed in. Hard coding it like that feels like a very bad idea to me. Even if it's hard coded in the backend, the API and documentation should always refer to variables instead of a hard coded number. In any case, will follow along for the time being. Unfortunately the audio data is not interleaved so we'll need to convert it before we give the data to miniaudio for further processing. */ frameCount = 128; if (inputCount > 0) { /* Input data needs to be interleaved before we hand it to the client. */ for (ma_uint32 iChannel = 0; iChannel < pDevice->capture.internalChannels; iChannel += 1) { for (ma_uint32 iFrame = 0; iFrame < frameCount; iFrame += 1) { pDevice->webaudio.pIntermediaryBuffer[iFrame*pDevice->capture.internalChannels + iChannel] = pInputs[0].data[frameCount*iChannel + iFrame]; } } ma_device_process_pcm_frames_capture__webaudio(pDevice, frameCount, pDevice->webaudio.pIntermediaryBuffer); } if (outputCount > 0) { /* If it's a capture-only device, we'll need to output silence. */ if (pDevice->type == ma_device_type_capture) { MA_ZERO_MEMORY(pOutputs[0].data, frameCount * pDevice->playback.internalChannels * sizeof(float)); } else { ma_device_process_pcm_frames_playback__webaudio(pDevice, frameCount, pDevice->webaudio.pIntermediaryBuffer); /* We've read the data from the client. Now we need to deinterleave the buffer and output to the output buffer. */ for (ma_uint32 iChannel = 0; iChannel < pDevice->playback.internalChannels; iChannel += 1) { for (ma_uint32 iFrame = 0; iFrame < frameCount; iFrame += 1) { pOutputs[0].data[frameCount*iChannel + iFrame] = pDevice->webaudio.pIntermediaryBuffer[iFrame*pDevice->playback.internalChannels + iChannel]; } } } } return EM_TRUE; } static void ma_audio_worklet_processor_created__webaudio(EMSCRIPTEN_WEBAUDIO_T audioContext, EM_BOOL success, void* pUserData) { ma_audio_worklet_thread_initialized_data* pParameters = (ma_audio_worklet_thread_initialized_data*)pUserData; EmscriptenAudioWorkletNodeCreateOptions audioWorkletOptions; int channels = 0; size_t intermediaryBufferSizeInFrames; int sampleRate; if (success == EM_FALSE) { pParameters->pDevice->webaudio.initResult = MA_ERROR; ma_free(pParameters, &pParameters->pDevice->pContext->allocationCallbacks); return; } /* The next step is to initialize the audio worklet node. */ MA_ZERO_OBJECT(&audioWorkletOptions); /* The way channel counts work with Web Audio is confusing. As far as I can tell, there's no way to know the channel count from MediaStreamAudioSourceNode (what we use for capture)? The only way to have control is to configure an output channel count on the capture side. This is slightly confusing for capture mode because intuitively you wouldn't actually connect an output to an input-only node, but this is what we'll have to do in order to have proper control over the channel count. In the capture case, we'll have to output silence to it's output node. */ if (pParameters->pConfig->deviceType == ma_device_type_capture) { channels = (int)((pParameters->pDescriptorCapture->channels > 0) ? pParameters->pDescriptorCapture->channels : MA_DEFAULT_CHANNELS); audioWorkletOptions.numberOfInputs = 1; } else { channels = (int)((pParameters->pDescriptorPlayback->channels > 0) ? pParameters->pDescriptorPlayback->channels : MA_DEFAULT_CHANNELS); if (pParameters->pConfig->deviceType == ma_device_type_duplex) { audioWorkletOptions.numberOfInputs = 1; } else { audioWorkletOptions.numberOfInputs = 0; } } audioWorkletOptions.numberOfOutputs = 1; audioWorkletOptions.outputChannelCounts = &channels; /* Now that we know the channel count to use we can allocate the intermediary buffer. The intermediary buffer is used for interleaving and deinterleaving. */ intermediaryBufferSizeInFrames = 128; pParameters->pDevice->webaudio.pIntermediaryBuffer = (float*)ma_malloc(intermediaryBufferSizeInFrames * (ma_uint32)channels * sizeof(float), &pParameters->pDevice->pContext->allocationCallbacks); if (pParameters->pDevice->webaudio.pIntermediaryBuffer == NULL) { pParameters->pDevice->webaudio.initResult = MA_OUT_OF_MEMORY; ma_free(pParameters, &pParameters->pDevice->pContext->allocationCallbacks); return; } pParameters->pDevice->webaudio.audioWorklet = emscripten_create_wasm_audio_worklet_node(audioContext, "miniaudio", &audioWorkletOptions, &ma_audio_worklet_process_callback__webaudio, pParameters->pDevice); /* With the audio worklet initialized we can now attach it to the graph. */ if (pParameters->pConfig->deviceType == ma_device_type_capture || pParameters->pConfig->deviceType == ma_device_type_duplex) { ma_result attachmentResult = (ma_result)EM_ASM_INT({ var getUserMediaResult = 0; var audioWorklet = emscriptenGetAudioObject($0); var audioContext = emscriptenGetAudioObject($1); navigator.mediaDevices.getUserMedia({audio:true, video:false}) .then(function(stream) { audioContext.streamNode = audioContext.createMediaStreamSource(stream); audioContext.streamNode.connect(audioWorklet); audioWorklet.connect(audioContext.destination); getUserMediaResult = 0; /* 0 = MA_SUCCESS */ }) .catch(function(error) { console.log("navigator.mediaDevices.getUserMedia Failed: " + error); getUserMediaResult = -1; /* -1 = MA_ERROR */ }); return getUserMediaResult; }, pParameters->pDevice->webaudio.audioWorklet, audioContext); if (attachmentResult != MA_SUCCESS) { ma_log_postf(ma_device_get_log(pParameters->pDevice), MA_LOG_LEVEL_ERROR, "Web Audio: Failed to connect capture node."); emscripten_destroy_web_audio_node(pParameters->pDevice->webaudio.audioWorklet); pParameters->pDevice->webaudio.initResult = attachmentResult; ma_free(pParameters, &pParameters->pDevice->pContext->allocationCallbacks); return; } } /* If it's playback only we can now attach the worklet node to the graph. This has already been done for the duplex case. */ if (pParameters->pConfig->deviceType == ma_device_type_playback) { ma_result attachmentResult = (ma_result)EM_ASM_INT({ var audioWorklet = emscriptenGetAudioObject($0); var audioContext = emscriptenGetAudioObject($1); audioWorklet.connect(audioContext.destination); return 0; /* 0 = MA_SUCCESS */ }, pParameters->pDevice->webaudio.audioWorklet, audioContext); if (attachmentResult != MA_SUCCESS) { ma_log_postf(ma_device_get_log(pParameters->pDevice), MA_LOG_LEVEL_ERROR, "Web Audio: Failed to connect playback node."); pParameters->pDevice->webaudio.initResult = attachmentResult; ma_free(pParameters, &pParameters->pDevice->pContext->allocationCallbacks); return; } } /* We need to update the descriptors so that they reflect the internal data format. Both capture and playback should be the same. */ sampleRate = EM_ASM_INT({ return emscriptenGetAudioObject($0).sampleRate; }, audioContext); if (pParameters->pDescriptorCapture != NULL) { pParameters->pDescriptorCapture->format = ma_format_f32; pParameters->pDescriptorCapture->channels = (ma_uint32)channels; pParameters->pDescriptorCapture->sampleRate = (ma_uint32)sampleRate; ma_channel_map_init_standard(ma_standard_channel_map_webaudio, pParameters->pDescriptorCapture->channelMap, ma_countof(pParameters->pDescriptorCapture->channelMap), pParameters->pDescriptorCapture->channels); pParameters->pDescriptorCapture->periodSizeInFrames = intermediaryBufferSizeInFrames; pParameters->pDescriptorCapture->periodCount = 1; } if (pParameters->pDescriptorPlayback != NULL) { pParameters->pDescriptorPlayback->format = ma_format_f32; pParameters->pDescriptorPlayback->channels = (ma_uint32)channels; pParameters->pDescriptorPlayback->sampleRate = (ma_uint32)sampleRate; ma_channel_map_init_standard(ma_standard_channel_map_webaudio, pParameters->pDescriptorPlayback->channelMap, ma_countof(pParameters->pDescriptorPlayback->channelMap), pParameters->pDescriptorPlayback->channels); pParameters->pDescriptorPlayback->periodSizeInFrames = intermediaryBufferSizeInFrames; pParameters->pDescriptorPlayback->periodCount = 1; } /* At this point we're done and we can return. */ ma_log_postf(ma_device_get_log(pParameters->pDevice), MA_LOG_LEVEL_DEBUG, "AudioWorklets: Created worklet node: %d\n", pParameters->pDevice->webaudio.audioWorklet); pParameters->pDevice->webaudio.initResult = MA_SUCCESS; ma_free(pParameters, &pParameters->pDevice->pContext->allocationCallbacks); } static void ma_audio_worklet_thread_initialized__webaudio(EMSCRIPTEN_WEBAUDIO_T audioContext, EM_BOOL success, void* pUserData) { ma_audio_worklet_thread_initialized_data* pParameters = (ma_audio_worklet_thread_initialized_data*)pUserData; WebAudioWorkletProcessorCreateOptions workletProcessorOptions; MA_ASSERT(pParameters != NULL); if (success == EM_FALSE) { pParameters->pDevice->webaudio.initResult = MA_ERROR; return; } MA_ZERO_OBJECT(&workletProcessorOptions); workletProcessorOptions.name = "miniaudio"; /* I'm not entirely sure what to call this. Does this need to be globally unique, or does it need only be unique for a given AudioContext? */ emscripten_create_wasm_audio_worklet_processor_async(audioContext, &workletProcessorOptions, ma_audio_worklet_processor_created__webaudio, pParameters); } #endif static ma_result ma_device_init__webaudio(ma_device* pDevice, const ma_device_config* pConfig, ma_device_descriptor* pDescriptorPlayback, ma_device_descriptor* pDescriptorCapture) { if (pConfig->deviceType == ma_device_type_loopback) { return MA_DEVICE_TYPE_NOT_SUPPORTED; } /* No exclusive mode with Web Audio. */ if (((pConfig->deviceType == ma_device_type_playback || pConfig->deviceType == ma_device_type_duplex) && pDescriptorPlayback->shareMode == ma_share_mode_exclusive) || ((pConfig->deviceType == ma_device_type_capture || pConfig->deviceType == ma_device_type_duplex) && pDescriptorCapture->shareMode == ma_share_mode_exclusive)) { return MA_SHARE_MODE_NOT_SUPPORTED; } /* With AudioWorklets we'll have just a single AudioContext. I'm not sure why I'm not doing this for ScriptProcessorNode so it might be worthwhile to look into that as well. */ #if defined(MA_USE_AUDIO_WORKLETS) { EmscriptenWebAudioCreateAttributes audioContextAttributes; ma_audio_worklet_thread_initialized_data* pInitParameters; void* pStackBuffer; if (pConfig->performanceProfile == ma_performance_profile_conservative) { audioContextAttributes.latencyHint = MA_WEBAUDIO_LATENCY_HINT_PLAYBACK; } else { audioContextAttributes.latencyHint = MA_WEBAUDIO_LATENCY_HINT_INTERACTIVE; } /* In my testing, Firefox does not seem to capture audio data properly if the sample rate is set to anything other than 48K. This does not seem to be the case for other browsers. For this reason, if the device type is anything other than playback, we'll leave the sample rate as-is and let the browser pick the appropriate rate for us. */ if (pConfig->deviceType == ma_device_type_playback) { audioContextAttributes.sampleRate = pDescriptorPlayback->sampleRate; } else { audioContextAttributes.sampleRate = 0; } /* It's not clear if this can return an error. None of the tests in the Emscripten repository check for this, so neither am I for now. */ pDevice->webaudio.audioContext = emscripten_create_audio_context(&audioContextAttributes); /* With the context created we can now create the worklet. We can only have a single worklet per audio context which means we'll need to craft this appropriately to handle duplex devices correctly. */ /* We now need to create a worker thread. This is a bit weird because we need to allocate our own buffer for the thread's stack. The stack needs to be aligned to 16 bytes. I'm going to allocate this on the heap to keep it simple. */ pStackBuffer = ma_aligned_malloc(MA_AUDIO_WORKLETS_THREAD_STACK_SIZE, 16, &pDevice->pContext->allocationCallbacks); if (pStackBuffer == NULL) { emscripten_destroy_audio_context(pDevice->webaudio.audioContext); return MA_OUT_OF_MEMORY; } /* Our thread initialization parameters need to be allocated on the heap so they don't go out of scope. */ pInitParameters = (ma_audio_worklet_thread_initialized_data*)ma_malloc(sizeof(*pInitParameters), &pDevice->pContext->allocationCallbacks); if (pInitParameters == NULL) { ma_free(pStackBuffer, &pDevice->pContext->allocationCallbacks); emscripten_destroy_audio_context(pDevice->webaudio.audioContext); return MA_OUT_OF_MEMORY; } pInitParameters->pDevice = pDevice; pInitParameters->pConfig = pConfig; pInitParameters->pDescriptorPlayback = pDescriptorPlayback; pInitParameters->pDescriptorCapture = pDescriptorCapture; /* We need to flag the device as not yet initialized so we can wait on it later. Unfortunately all of the Emscripten WebAudio stuff is asynchronous. */ pDevice->webaudio.initResult = MA_BUSY; { emscripten_start_wasm_audio_worklet_thread_async(pDevice->webaudio.audioContext, pStackBuffer, MA_AUDIO_WORKLETS_THREAD_STACK_SIZE, ma_audio_worklet_thread_initialized__webaudio, pInitParameters); } while (pDevice->webaudio.initResult == MA_BUSY) { emscripten_sleep(1); } /* We must wait for initialization to complete. We're just spinning here. The emscripten_sleep() call is why we need to build with `-sASYNCIFY`. */ /* Initialization is now complete. Descriptors were updated when the worklet was initialized. */ if (pDevice->webaudio.initResult != MA_SUCCESS) { ma_free(pStackBuffer, &pDevice->pContext->allocationCallbacks); emscripten_destroy_audio_context(pDevice->webaudio.audioContext); return pDevice->webaudio.initResult; } /* We need to add an entry to the miniaudio.devices list on the JS side so we can do some JS/C interop. */ pDevice->webaudio.deviceIndex = EM_ASM_INT({ return miniaudio.track_device({ webaudio: emscriptenGetAudioObject($0), state: 1 /* 1 = ma_device_state_stopped */ }); }, pDevice->webaudio.audioContext); return MA_SUCCESS; } #else { /* ScriptProcessorNode. This path requires us to do almost everything in JS, but we'll do as much as we can in C. */ ma_uint32 deviceIndex; ma_uint32 channels; ma_uint32 sampleRate; ma_uint32 periodSizeInFrames; /* The channel count will depend on the device type. If it's a capture, use it's, otherwise use the playback side. */ if (pConfig->deviceType == ma_device_type_capture) { channels = (pDescriptorCapture->channels > 0) ? pDescriptorCapture->channels : MA_DEFAULT_CHANNELS; } else { channels = (pDescriptorPlayback->channels > 0) ? pDescriptorPlayback->channels : MA_DEFAULT_CHANNELS; } /* When testing in Firefox, I've seen it where capture mode fails if the sample rate is changed to anything other than it's native rate. For this reason we're leaving the sample rate untouched for capture devices. */ if (pConfig->deviceType == ma_device_type_playback) { sampleRate = pDescriptorPlayback->sampleRate; } else { sampleRate = 0; /* Let the browser decide when capturing. */ } /* The period size needs to be a power of 2. */ if (pConfig->deviceType == ma_device_type_capture) { periodSizeInFrames = ma_calculate_period_size_in_frames_from_descriptor__webaudio(pDescriptorCapture, sampleRate, pConfig->performanceProfile); } else { periodSizeInFrames = ma_calculate_period_size_in_frames_from_descriptor__webaudio(pDescriptorPlayback, sampleRate, pConfig->performanceProfile); } /* We need an intermediary buffer for doing interleaving and deinterleaving. */ pDevice->webaudio.pIntermediaryBuffer = (float*)ma_malloc(periodSizeInFrames * channels * sizeof(float), &pDevice->pContext->allocationCallbacks); if (pDevice->webaudio.pIntermediaryBuffer == NULL) { return MA_OUT_OF_MEMORY; } deviceIndex = EM_ASM_INT({ var deviceType = $0; var channels = $1; var sampleRate = $2; var bufferSize = $3; var pIntermediaryBuffer = $4; var pDevice = $5; if (typeof(window.miniaudio) === 'undefined') { return -1; /* Context not initialized. */ } var device = {}; /* First thing we need is an AudioContext. */ var audioContextOptions = {}; if (deviceType == window.miniaudio.device_type.playback && sampleRate != 0) { audioContextOptions.sampleRate = sampleRate; } device.webaudio = new (window.AudioContext || window.webkitAudioContext)(audioContextOptions); device.webaudio.suspend(); /* The AudioContext must be created in a suspended state. */ device.state = window.miniaudio.device_state.stopped; /* We need to create a ScriptProcessorNode. The channel situation is the same as the AudioWorklet path in that we need to specify an output and configure the channel count there. */ var channelCountIn = 0; var channelCountOut = channels; if (deviceType != window.miniaudio.device_type.playback) { channelCountIn = channels; } device.scriptNode = device.webaudio.createScriptProcessor(bufferSize, channelCountIn, channelCountOut); /* The node processing callback. */ device.scriptNode.onaudioprocess = function(e) { if (device.intermediaryBufferView == null || device.intermediaryBufferView.length == 0) { device.intermediaryBufferView = new Float32Array(Module.HEAPF32.buffer, pIntermediaryBuffer, bufferSize * channels); } /* Do the capture side first. */ if (deviceType == miniaudio.device_type.capture || deviceType == miniaudio.device_type.duplex) { /* The data must be interleaved before being processed miniaudio. */ for (var iChannel = 0; iChannel < channels; iChannel += 1) { var inputBuffer = e.inputBuffer.getChannelData(iChannel); var intermediaryBuffer = device.intermediaryBufferView; for (var iFrame = 0; iFrame < bufferSize; iFrame += 1) { intermediaryBuffer[iFrame*channels + iChannel] = inputBuffer[iFrame]; } } _ma_device_process_pcm_frames_capture__webaudio(pDevice, bufferSize, pIntermediaryBuffer); } if (deviceType == miniaudio.device_type.playback || deviceType == miniaudio.device_type.duplex) { _ma_device_process_pcm_frames_playback__webaudio(pDevice, bufferSize, pIntermediaryBuffer); for (var iChannel = 0; iChannel < e.outputBuffer.numberOfChannels; ++iChannel) { var outputBuffer = e.outputBuffer.getChannelData(iChannel); var intermediaryBuffer = device.intermediaryBufferView; for (var iFrame = 0; iFrame < bufferSize; iFrame += 1) { outputBuffer[iFrame] = intermediaryBuffer[iFrame*channels + iChannel]; } } } else { /* It's a capture-only device. Make sure the output is silenced. */ for (var iChannel = 0; iChannel < e.outputBuffer.numberOfChannels; ++iChannel) { e.outputBuffer.getChannelData(iChannel).fill(0.0); } } }; /* Now we need to connect our node to the graph. */ if (deviceType == miniaudio.device_type.capture || deviceType == miniaudio.device_type.duplex) { navigator.mediaDevices.getUserMedia({audio:true, video:false}) .then(function(stream) { device.streamNode = device.webaudio.createMediaStreamSource(stream); device.streamNode.connect(device.scriptNode); device.scriptNode.connect(device.webaudio.destination); }) .catch(function(error) { console.log("Failed to get user media: " + error); }); } if (deviceType == miniaudio.device_type.playback) { device.scriptNode.connect(device.webaudio.destination); } device.pDevice = pDevice; return miniaudio.track_device(device); }, pConfig->deviceType, channels, sampleRate, periodSizeInFrames, pDevice->webaudio.pIntermediaryBuffer, pDevice); if (deviceIndex < 0) { return MA_FAILED_TO_OPEN_BACKEND_DEVICE; } pDevice->webaudio.deviceIndex = deviceIndex; /* Grab the sample rate from the audio context directly. */ sampleRate = (ma_uint32)EM_ASM_INT({ return miniaudio.get_device_by_index($0).webaudio.sampleRate; }, deviceIndex); if (pDescriptorCapture != NULL) { pDescriptorCapture->format = ma_format_f32; pDescriptorCapture->channels = channels; pDescriptorCapture->sampleRate = sampleRate; ma_channel_map_init_standard(ma_standard_channel_map_webaudio, pDescriptorCapture->channelMap, ma_countof(pDescriptorCapture->channelMap), pDescriptorCapture->channels); pDescriptorCapture->periodSizeInFrames = periodSizeInFrames; pDescriptorCapture->periodCount = 1; } if (pDescriptorPlayback != NULL) { pDescriptorPlayback->format = ma_format_f32; pDescriptorPlayback->channels = channels; pDescriptorPlayback->sampleRate = sampleRate; ma_channel_map_init_standard(ma_standard_channel_map_webaudio, pDescriptorPlayback->channelMap, ma_countof(pDescriptorPlayback->channelMap), pDescriptorPlayback->channels); pDescriptorPlayback->periodSizeInFrames = periodSizeInFrames; pDescriptorPlayback->periodCount = 1; } return MA_SUCCESS; } #endif } static ma_result ma_device_start__webaudio(ma_device* pDevice) { MA_ASSERT(pDevice != NULL); EM_ASM({ var device = miniaudio.get_device_by_index($0); device.webaudio.resume(); device.state = miniaudio.device_state.started; }, pDevice->webaudio.deviceIndex); return MA_SUCCESS; } static ma_result ma_device_stop__webaudio(ma_device* pDevice) { MA_ASSERT(pDevice != NULL); /* From the WebAudio API documentation for AudioContext.suspend(): Suspends the progression of AudioContext's currentTime, allows any current context processing blocks that are already processed to be played to the destination, and then allows the system to release its claim on audio hardware. I read this to mean that "any current context processing blocks" are processed by suspend() - i.e. They they are drained. We therefore shouldn't need to do any kind of explicit draining. */ EM_ASM({ var device = miniaudio.get_device_by_index($0); device.webaudio.suspend(); device.state = miniaudio.device_state.stopped; }, pDevice->webaudio.deviceIndex); ma_device__on_notification_stopped(pDevice); return MA_SUCCESS; } static ma_result ma_context_uninit__webaudio(ma_context* pContext) { MA_ASSERT(pContext != NULL); MA_ASSERT(pContext->backend == ma_backend_webaudio); (void)pContext; /* Unused. */ /* Remove the global miniaudio object from window if there are no more references to it. */ EM_ASM({ if (typeof(window.miniaudio) !== 'undefined') { window.miniaudio.referenceCount -= 1; if (window.miniaudio.referenceCount === 0) { delete window.miniaudio; } } }); return MA_SUCCESS; } static ma_result ma_context_init__webaudio(ma_context* pContext, const ma_context_config* pConfig, ma_backend_callbacks* pCallbacks) { int resultFromJS; MA_ASSERT(pContext != NULL); (void)pConfig; /* Unused. */ /* Here is where our global JavaScript object is initialized. */ resultFromJS = EM_ASM_INT({ if (typeof window === 'undefined' || (window.AudioContext || window.webkitAudioContext) === undefined) { return 0; /* Web Audio not supported. */ } if (typeof(window.miniaudio) === 'undefined') { window.miniaudio = { referenceCount: 0 }; /* Device types. */ window.miniaudio.device_type = {}; window.miniaudio.device_type.playback = $0; window.miniaudio.device_type.capture = $1; window.miniaudio.device_type.duplex = $2; /* Device states. */ window.miniaudio.device_state = {}; window.miniaudio.device_state.stopped = $3; window.miniaudio.device_state.started = $4; /* Device cache for mapping devices to indexes for JavaScript/C interop. */ miniaudio.devices = []; miniaudio.track_device = function(device) { /* Try inserting into a free slot first. */ for (var iDevice = 0; iDevice < miniaudio.devices.length; ++iDevice) { if (miniaudio.devices[iDevice] == null) { miniaudio.devices[iDevice] = device; return iDevice; } } /* Getting here means there is no empty slots in the array so we just push to the end. */ miniaudio.devices.push(device); return miniaudio.devices.length - 1; }; miniaudio.untrack_device_by_index = function(deviceIndex) { /* We just set the device's slot to null. The slot will get reused in the next call to ma_track_device. */ miniaudio.devices[deviceIndex] = null; /* Trim the array if possible. */ while (miniaudio.devices.length > 0) { if (miniaudio.devices[miniaudio.devices.length-1] == null) { miniaudio.devices.pop(); } else { break; } } }; miniaudio.untrack_device = function(device) { for (var iDevice = 0; iDevice < miniaudio.devices.length; ++iDevice) { if (miniaudio.devices[iDevice] == device) { return miniaudio.untrack_device_by_index(iDevice); } } }; miniaudio.get_device_by_index = function(deviceIndex) { return miniaudio.devices[deviceIndex]; }; miniaudio.unlock_event_types = (function(){ return ['touchend', 'click']; })(); miniaudio.unlock = function() { for(var i = 0; i < miniaudio.devices.length; ++i) { var device = miniaudio.devices[i]; if (device != null && device.webaudio != null && device.state === window.miniaudio.device_state.started) { device.webaudio.resume().then(() => { Module._ma_device__on_notification_unlocked(device.pDevice); }, (error) => {console.error("Failed to resume audiocontext", error); }); } } miniaudio.unlock_event_types.map(function(event_type) { document.removeEventListener(event_type, miniaudio.unlock, true); }); }; miniaudio.unlock_event_types.map(function(event_type) { document.addEventListener(event_type, miniaudio.unlock, true); }); } window.miniaudio.referenceCount += 1; return 1; }, ma_device_type_playback, ma_device_type_capture, ma_device_type_duplex, ma_device_state_stopped, ma_device_state_started); if (resultFromJS != 1) { return MA_FAILED_TO_INIT_BACKEND; } pCallbacks->onContextInit = ma_context_init__webaudio; pCallbacks->onContextUninit = ma_context_uninit__webaudio; pCallbacks->onContextEnumerateDevices = ma_context_enumerate_devices__webaudio; pCallbacks->onContextGetDeviceInfo = ma_context_get_device_info__webaudio; pCallbacks->onDeviceInit = ma_device_init__webaudio; pCallbacks->onDeviceUninit = ma_device_uninit__webaudio; pCallbacks->onDeviceStart = ma_device_start__webaudio; pCallbacks->onDeviceStop = ma_device_stop__webaudio; pCallbacks->onDeviceRead = NULL; /* Not needed because WebAudio is asynchronous. */ pCallbacks->onDeviceWrite = NULL; /* Not needed because WebAudio is asynchronous. */ pCallbacks->onDeviceDataLoop = NULL; /* Not needed because WebAudio is asynchronous. */ return MA_SUCCESS; } #endif /* Web Audio */ static ma_bool32 ma__is_channel_map_valid(const ma_channel* pChannelMap, ma_uint32 channels) { /* A blank channel map should be allowed, in which case it should use an appropriate default which will depend on context. */ if (pChannelMap != NULL && pChannelMap[0] != MA_CHANNEL_NONE) { ma_uint32 iChannel; if (channels == 0 || channels > MA_MAX_CHANNELS) { return MA_FALSE; /* Channel count out of range. */ } /* A channel cannot be present in the channel map more than once. */ for (iChannel = 0; iChannel < channels; ++iChannel) { ma_uint32 jChannel; for (jChannel = iChannel + 1; jChannel < channels; ++jChannel) { if (pChannelMap[iChannel] == pChannelMap[jChannel]) { return MA_FALSE; } } } } return MA_TRUE; } static ma_bool32 ma_context_is_backend_asynchronous(ma_context* pContext) { MA_ASSERT(pContext != NULL); if (pContext->callbacks.onDeviceRead == NULL && pContext->callbacks.onDeviceWrite == NULL) { if (pContext->callbacks.onDeviceDataLoop == NULL) { return MA_TRUE; } else { return MA_FALSE; } } else { return MA_FALSE; } } static ma_result ma_device__post_init_setup(ma_device* pDevice, ma_device_type deviceType) { ma_result result; MA_ASSERT(pDevice != NULL); if (deviceType == ma_device_type_capture || deviceType == ma_device_type_duplex || deviceType == ma_device_type_loopback) { if (pDevice->capture.format == ma_format_unknown) { pDevice->capture.format = pDevice->capture.internalFormat; } if (pDevice->capture.channels == 0) { pDevice->capture.channels = pDevice->capture.internalChannels; } if (pDevice->capture.channelMap[0] == MA_CHANNEL_NONE) { MA_ASSERT(pDevice->capture.channels <= MA_MAX_CHANNELS); if (pDevice->capture.internalChannels == pDevice->capture.channels) { ma_channel_map_copy(pDevice->capture.channelMap, pDevice->capture.internalChannelMap, pDevice->capture.channels); } else { if (pDevice->capture.channelMixMode == ma_channel_mix_mode_simple) { ma_channel_map_init_blank(pDevice->capture.channelMap, pDevice->capture.channels); } else { ma_channel_map_init_standard(ma_standard_channel_map_default, pDevice->capture.channelMap, ma_countof(pDevice->capture.channelMap), pDevice->capture.channels); } } } } if (deviceType == ma_device_type_playback || deviceType == ma_device_type_duplex) { if (pDevice->playback.format == ma_format_unknown) { pDevice->playback.format = pDevice->playback.internalFormat; } if (pDevice->playback.channels == 0) { pDevice->playback.channels = pDevice->playback.internalChannels; } if (pDevice->playback.channelMap[0] == MA_CHANNEL_NONE) { MA_ASSERT(pDevice->playback.channels <= MA_MAX_CHANNELS); if (pDevice->playback.internalChannels == pDevice->playback.channels) { ma_channel_map_copy(pDevice->playback.channelMap, pDevice->playback.internalChannelMap, pDevice->playback.channels); } else { if (pDevice->playback.channelMixMode == ma_channel_mix_mode_simple) { ma_channel_map_init_blank(pDevice->playback.channelMap, pDevice->playback.channels); } else { ma_channel_map_init_standard(ma_standard_channel_map_default, pDevice->playback.channelMap, ma_countof(pDevice->playback.channelMap), pDevice->playback.channels); } } } } if (pDevice->sampleRate == 0) { if (deviceType == ma_device_type_capture || deviceType == ma_device_type_duplex || deviceType == ma_device_type_loopback) { pDevice->sampleRate = pDevice->capture.internalSampleRate; } else { pDevice->sampleRate = pDevice->playback.internalSampleRate; } } /* Data converters. */ if (deviceType == ma_device_type_capture || deviceType == ma_device_type_duplex || deviceType == ma_device_type_loopback) { /* Converting from internal device format to client format. */ ma_data_converter_config converterConfig = ma_data_converter_config_init_default(); converterConfig.formatIn = pDevice->capture.internalFormat; converterConfig.channelsIn = pDevice->capture.internalChannels; converterConfig.sampleRateIn = pDevice->capture.internalSampleRate; converterConfig.pChannelMapIn = pDevice->capture.internalChannelMap; converterConfig.formatOut = pDevice->capture.format; converterConfig.channelsOut = pDevice->capture.channels; converterConfig.sampleRateOut = pDevice->sampleRate; converterConfig.pChannelMapOut = pDevice->capture.channelMap; converterConfig.channelMixMode = pDevice->capture.channelMixMode; converterConfig.calculateLFEFromSpatialChannels = pDevice->capture.calculateLFEFromSpatialChannels; converterConfig.allowDynamicSampleRate = MA_FALSE; converterConfig.resampling.algorithm = pDevice->resampling.algorithm; converterConfig.resampling.linear.lpfOrder = pDevice->resampling.linear.lpfOrder; converterConfig.resampling.pBackendVTable = pDevice->resampling.pBackendVTable; converterConfig.resampling.pBackendUserData = pDevice->resampling.pBackendUserData; /* Make sure the old converter is uninitialized first. */ if (ma_device_get_state(pDevice) != ma_device_state_uninitialized) { ma_data_converter_uninit(&pDevice->capture.converter, &pDevice->pContext->allocationCallbacks); } result = ma_data_converter_init(&converterConfig, &pDevice->pContext->allocationCallbacks, &pDevice->capture.converter); if (result != MA_SUCCESS) { return result; } } if (deviceType == ma_device_type_playback || deviceType == ma_device_type_duplex) { /* Converting from client format to device format. */ ma_data_converter_config converterConfig = ma_data_converter_config_init_default(); converterConfig.formatIn = pDevice->playback.format; converterConfig.channelsIn = pDevice->playback.channels; converterConfig.sampleRateIn = pDevice->sampleRate; converterConfig.pChannelMapIn = pDevice->playback.channelMap; converterConfig.formatOut = pDevice->playback.internalFormat; converterConfig.channelsOut = pDevice->playback.internalChannels; converterConfig.sampleRateOut = pDevice->playback.internalSampleRate; converterConfig.pChannelMapOut = pDevice->playback.internalChannelMap; converterConfig.channelMixMode = pDevice->playback.channelMixMode; converterConfig.calculateLFEFromSpatialChannels = pDevice->playback.calculateLFEFromSpatialChannels; converterConfig.allowDynamicSampleRate = MA_FALSE; converterConfig.resampling.algorithm = pDevice->resampling.algorithm; converterConfig.resampling.linear.lpfOrder = pDevice->resampling.linear.lpfOrder; converterConfig.resampling.pBackendVTable = pDevice->resampling.pBackendVTable; converterConfig.resampling.pBackendUserData = pDevice->resampling.pBackendUserData; /* Make sure the old converter is uninitialized first. */ if (ma_device_get_state(pDevice) != ma_device_state_uninitialized) { ma_data_converter_uninit(&pDevice->playback.converter, &pDevice->pContext->allocationCallbacks); } result = ma_data_converter_init(&converterConfig, &pDevice->pContext->allocationCallbacks, &pDevice->playback.converter); if (result != MA_SUCCESS) { return result; } } /* If the device is doing playback (ma_device_type_playback or ma_device_type_duplex), there's a couple of situations where we'll need a heap allocated cache. The first is a duplex device for backends that use a callback for data delivery. The reason this is needed is that the input stage needs to have a buffer to place the input data while it waits for the playback stage, after which the miniaudio data callback will get fired. This is not needed for backends that use a blocking API because miniaudio manages temporary buffers on the stack to achieve this. The other situation is when the data converter does not have the ability to query the number of input frames that are required in order to process a given number of output frames. When performing data conversion, it's useful if miniaudio know exactly how many frames it needs from the client in order to generate a given number of output frames. This way, only exactly the number of frames are needed to be read from the client which means no cache is necessary. On the other hand, if miniaudio doesn't know how many frames to read, it is forced to read in fixed sized chunks and then cache any residual unused input frames, those of which will be processed at a later stage. */ if (deviceType == ma_device_type_playback || deviceType == ma_device_type_duplex) { ma_uint64 unused; pDevice->playback.inputCacheConsumed = 0; pDevice->playback.inputCacheRemaining = 0; if (pDevice->type == ma_device_type_duplex || /* Duplex. backend may decide to use ma_device_handle_backend_data_callback() which will require this cache. */ ma_data_converter_get_required_input_frame_count(&pDevice->playback.converter, 1, &unused) != MA_SUCCESS) /* Data conversion required input frame calculation not supported. */ { /* We need a heap allocated cache. We want to size this based on the period size. */ void* pNewInputCache; ma_uint64 newInputCacheCap; ma_uint64 newInputCacheSizeInBytes; newInputCacheCap = ma_calculate_frame_count_after_resampling(pDevice->playback.internalSampleRate, pDevice->sampleRate, pDevice->playback.internalPeriodSizeInFrames); newInputCacheSizeInBytes = newInputCacheCap * ma_get_bytes_per_frame(pDevice->playback.format, pDevice->playback.channels); if (newInputCacheSizeInBytes > MA_SIZE_MAX) { ma_free(pDevice->playback.pInputCache, &pDevice->pContext->allocationCallbacks); pDevice->playback.pInputCache = NULL; pDevice->playback.inputCacheCap = 0; return MA_OUT_OF_MEMORY; /* Allocation too big. Should never hit this, but makes the cast below safer for 32-bit builds. */ } pNewInputCache = ma_realloc(pDevice->playback.pInputCache, (size_t)newInputCacheSizeInBytes, &pDevice->pContext->allocationCallbacks); if (pNewInputCache == NULL) { ma_free(pDevice->playback.pInputCache, &pDevice->pContext->allocationCallbacks); pDevice->playback.pInputCache = NULL; pDevice->playback.inputCacheCap = 0; return MA_OUT_OF_MEMORY; } pDevice->playback.pInputCache = pNewInputCache; pDevice->playback.inputCacheCap = newInputCacheCap; } else { /* Heap allocation not required. Make sure we clear out the old cache just in case this function was called in response to a route change. */ ma_free(pDevice->playback.pInputCache, &pDevice->pContext->allocationCallbacks); pDevice->playback.pInputCache = NULL; pDevice->playback.inputCacheCap = 0; } } return MA_SUCCESS; } MA_API ma_result ma_device_post_init(ma_device* pDevice, ma_device_type deviceType, const ma_device_descriptor* pDescriptorPlayback, const ma_device_descriptor* pDescriptorCapture) { ma_result result; if (pDevice == NULL) { return MA_INVALID_ARGS; } /* Capture. */ if (deviceType == ma_device_type_capture || deviceType == ma_device_type_duplex || deviceType == ma_device_type_loopback) { if (ma_device_descriptor_is_valid(pDescriptorCapture) == MA_FALSE) { return MA_INVALID_ARGS; } pDevice->capture.internalFormat = pDescriptorCapture->format; pDevice->capture.internalChannels = pDescriptorCapture->channels; pDevice->capture.internalSampleRate = pDescriptorCapture->sampleRate; MA_COPY_MEMORY(pDevice->capture.internalChannelMap, pDescriptorCapture->channelMap, sizeof(pDescriptorCapture->channelMap)); pDevice->capture.internalPeriodSizeInFrames = pDescriptorCapture->periodSizeInFrames; pDevice->capture.internalPeriods = pDescriptorCapture->periodCount; if (pDevice->capture.internalPeriodSizeInFrames == 0) { pDevice->capture.internalPeriodSizeInFrames = ma_calculate_buffer_size_in_frames_from_milliseconds(pDescriptorCapture->periodSizeInMilliseconds, pDescriptorCapture->sampleRate); } } /* Playback. */ if (deviceType == ma_device_type_playback || deviceType == ma_device_type_duplex) { if (ma_device_descriptor_is_valid(pDescriptorPlayback) == MA_FALSE) { return MA_INVALID_ARGS; } pDevice->playback.internalFormat = pDescriptorPlayback->format; pDevice->playback.internalChannels = pDescriptorPlayback->channels; pDevice->playback.internalSampleRate = pDescriptorPlayback->sampleRate; MA_COPY_MEMORY(pDevice->playback.internalChannelMap, pDescriptorPlayback->channelMap, sizeof(pDescriptorPlayback->channelMap)); pDevice->playback.internalPeriodSizeInFrames = pDescriptorPlayback->periodSizeInFrames; pDevice->playback.internalPeriods = pDescriptorPlayback->periodCount; if (pDevice->playback.internalPeriodSizeInFrames == 0) { pDevice->playback.internalPeriodSizeInFrames = ma_calculate_buffer_size_in_frames_from_milliseconds(pDescriptorPlayback->periodSizeInMilliseconds, pDescriptorPlayback->sampleRate); } } /* The name of the device can be retrieved from device info. This may be temporary and replaced with a `ma_device_get_info(pDevice, deviceType)` instead. For loopback devices, we need to retrieve the name of the playback device. */ { ma_device_info deviceInfo; if (deviceType == ma_device_type_capture || deviceType == ma_device_type_duplex || deviceType == ma_device_type_loopback) { result = ma_device_get_info(pDevice, (deviceType == ma_device_type_loopback) ? ma_device_type_playback : ma_device_type_capture, &deviceInfo); if (result == MA_SUCCESS) { ma_strncpy_s(pDevice->capture.name, sizeof(pDevice->capture.name), deviceInfo.name, (size_t)-1); } else { /* We failed to retrieve the device info. Fall back to a default name. */ if (pDescriptorCapture->pDeviceID == NULL) { ma_strncpy_s(pDevice->capture.name, sizeof(pDevice->capture.name), MA_DEFAULT_CAPTURE_DEVICE_NAME, (size_t)-1); } else { ma_strncpy_s(pDevice->capture.name, sizeof(pDevice->capture.name), "Capture Device", (size_t)-1); } } } if (deviceType == ma_device_type_playback || deviceType == ma_device_type_duplex) { result = ma_device_get_info(pDevice, ma_device_type_playback, &deviceInfo); if (result == MA_SUCCESS) { ma_strncpy_s(pDevice->playback.name, sizeof(pDevice->playback.name), deviceInfo.name, (size_t)-1); } else { /* We failed to retrieve the device info. Fall back to a default name. */ if (pDescriptorPlayback->pDeviceID == NULL) { ma_strncpy_s(pDevice->playback.name, sizeof(pDevice->playback.name), MA_DEFAULT_PLAYBACK_DEVICE_NAME, (size_t)-1); } else { ma_strncpy_s(pDevice->playback.name, sizeof(pDevice->playback.name), "Playback Device", (size_t)-1); } } } } /* Update data conversion. */ return ma_device__post_init_setup(pDevice, deviceType); /* TODO: Should probably rename ma_device__post_init_setup() to something better. */ } static ma_thread_result MA_THREADCALL ma_worker_thread(void* pData) { ma_device* pDevice = (ma_device*)pData; #ifdef MA_WIN32 HRESULT CoInitializeResult; #endif MA_ASSERT(pDevice != NULL); #ifdef MA_WIN32 CoInitializeResult = ma_CoInitializeEx(pDevice->pContext, NULL, MA_COINIT_VALUE); #endif /* When the device is being initialized it's initial state is set to ma_device_state_uninitialized. Before returning from ma_device_init(), the state needs to be set to something valid. In miniaudio the device's default state immediately after initialization is stopped, so therefore we need to mark the device as such. miniaudio will wait on the worker thread to signal an event to know when the worker thread is ready for action. */ ma_device__set_state(pDevice, ma_device_state_stopped); ma_event_signal(&pDevice->stopEvent); for (;;) { /* <-- This loop just keeps the thread alive. The main audio loop is inside. */ ma_result startResult; ma_result stopResult; /* <-- This will store the result from onDeviceStop(). If it returns an error, we don't fire the stopped notification callback. */ /* We wait on an event to know when something has requested that the device be started and the main loop entered. */ ma_event_wait(&pDevice->wakeupEvent); /* Default result code. */ pDevice->workResult = MA_SUCCESS; /* If the reason for the wake up is that we are terminating, just break from the loop. */ if (ma_device_get_state(pDevice) == ma_device_state_uninitialized) { break; } /* Getting to this point means the device is wanting to get started. The function that has requested that the device be started will be waiting on an event (pDevice->startEvent) which means we need to make sure we signal the event in both the success and error case. It's important that the state of the device is set _before_ signaling the event. */ MA_ASSERT(ma_device_get_state(pDevice) == ma_device_state_starting); /* If the device has a start callback, start it now. */ if (pDevice->pContext->callbacks.onDeviceStart != NULL) { startResult = pDevice->pContext->callbacks.onDeviceStart(pDevice); } else { startResult = MA_SUCCESS; } /* If starting was not successful we'll need to loop back to the start and wait for something to happen (pDevice->wakeupEvent). */ if (startResult != MA_SUCCESS) { pDevice->workResult = startResult; ma_event_signal(&pDevice->startEvent); /* <-- Always signal the start event so ma_device_start() can return as it'll be waiting on it. */ continue; } /* Make sure the state is set appropriately. */ ma_device__set_state(pDevice, ma_device_state_started); /* <-- Set this before signaling the event so that the state is always guaranteed to be good after ma_device_start() has returned. */ ma_event_signal(&pDevice->startEvent); ma_device__on_notification_started(pDevice); if (pDevice->pContext->callbacks.onDeviceDataLoop != NULL) { pDevice->pContext->callbacks.onDeviceDataLoop(pDevice); } else { /* The backend is not using a custom main loop implementation, so now fall back to the blocking read-write implementation. */ ma_device_audio_thread__default_read_write(pDevice); } /* Getting here means we have broken from the main loop which happens the application has requested that device be stopped. */ if (pDevice->pContext->callbacks.onDeviceStop != NULL) { stopResult = pDevice->pContext->callbacks.onDeviceStop(pDevice); } else { stopResult = MA_SUCCESS; /* No stop callback with the backend. Just assume successful. */ } /* After the device has stopped, make sure an event is posted. Don't post a stopped event if stopping failed. This can happen on some backends when the underlying stream has been stopped due to the device being physically unplugged or disabled via an OS setting. */ if (stopResult == MA_SUCCESS) { ma_device__on_notification_stopped(pDevice); } /* If we stopped because the device has been uninitialized, abort now. */ if (ma_device_get_state(pDevice) == ma_device_state_uninitialized) { break; } /* A function somewhere is waiting for the device to have stopped for real so we need to signal an event to allow it to continue. */ ma_device__set_state(pDevice, ma_device_state_stopped); ma_event_signal(&pDevice->stopEvent); } #ifdef MA_WIN32 if (CoInitializeResult == S_OK) { ma_CoUninitialize(pDevice->pContext); } #endif return (ma_thread_result)0; } /* Helper for determining whether or not the given device is initialized. */ static ma_bool32 ma_device__is_initialized(ma_device* pDevice) { if (pDevice == NULL) { return MA_FALSE; } return ma_device_get_state(pDevice) != ma_device_state_uninitialized; } #ifdef MA_WIN32 static ma_result ma_context_uninit_backend_apis__win32(ma_context* pContext) { /* For some reason UWP complains when CoUninitialize() is called. I'm just not going to call it on UWP. */ #if defined(MA_WIN32_DESKTOP) || defined(MA_WIN32_GDK) if (pContext->win32.CoInitializeResult == S_OK) { ma_CoUninitialize(pContext); } #if defined(MA_WIN32_DESKTOP) ma_dlclose(ma_context_get_log(pContext), pContext->win32.hUser32DLL); ma_dlclose(ma_context_get_log(pContext), pContext->win32.hAdvapi32DLL); #endif ma_dlclose(ma_context_get_log(pContext), pContext->win32.hOle32DLL); #else (void)pContext; #endif return MA_SUCCESS; } static ma_result ma_context_init_backend_apis__win32(ma_context* pContext) { #if defined(MA_WIN32_DESKTOP) || defined(MA_WIN32_GDK) #if defined(MA_WIN32_DESKTOP) /* User32.dll */ pContext->win32.hUser32DLL = ma_dlopen(ma_context_get_log(pContext), "user32.dll"); if (pContext->win32.hUser32DLL == NULL) { return MA_FAILED_TO_INIT_BACKEND; } pContext->win32.GetForegroundWindow = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->win32.hUser32DLL, "GetForegroundWindow"); pContext->win32.GetDesktopWindow = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->win32.hUser32DLL, "GetDesktopWindow"); /* Advapi32.dll */ pContext->win32.hAdvapi32DLL = ma_dlopen(ma_context_get_log(pContext), "advapi32.dll"); if (pContext->win32.hAdvapi32DLL == NULL) { return MA_FAILED_TO_INIT_BACKEND; } pContext->win32.RegOpenKeyExA = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->win32.hAdvapi32DLL, "RegOpenKeyExA"); pContext->win32.RegCloseKey = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->win32.hAdvapi32DLL, "RegCloseKey"); pContext->win32.RegQueryValueExA = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->win32.hAdvapi32DLL, "RegQueryValueExA"); #endif /* Ole32.dll */ pContext->win32.hOle32DLL = ma_dlopen(ma_context_get_log(pContext), "ole32.dll"); if (pContext->win32.hOle32DLL == NULL) { return MA_FAILED_TO_INIT_BACKEND; } pContext->win32.CoInitialize = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->win32.hOle32DLL, "CoInitialize"); pContext->win32.CoInitializeEx = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->win32.hOle32DLL, "CoInitializeEx"); pContext->win32.CoUninitialize = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->win32.hOle32DLL, "CoUninitialize"); pContext->win32.CoCreateInstance = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->win32.hOle32DLL, "CoCreateInstance"); pContext->win32.CoTaskMemFree = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->win32.hOle32DLL, "CoTaskMemFree"); pContext->win32.PropVariantClear = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->win32.hOle32DLL, "PropVariantClear"); pContext->win32.StringFromGUID2 = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->win32.hOle32DLL, "StringFromGUID2"); #else (void)pContext; /* Unused. */ #endif pContext->win32.CoInitializeResult = ma_CoInitializeEx(pContext, NULL, MA_COINIT_VALUE); return MA_SUCCESS; } #else static ma_result ma_context_uninit_backend_apis__nix(ma_context* pContext) { (void)pContext; return MA_SUCCESS; } static ma_result ma_context_init_backend_apis__nix(ma_context* pContext) { (void)pContext; return MA_SUCCESS; } #endif static ma_result ma_context_init_backend_apis(ma_context* pContext) { ma_result result; #ifdef MA_WIN32 result = ma_context_init_backend_apis__win32(pContext); #else result = ma_context_init_backend_apis__nix(pContext); #endif return result; } static ma_result ma_context_uninit_backend_apis(ma_context* pContext) { ma_result result; #ifdef MA_WIN32 result = ma_context_uninit_backend_apis__win32(pContext); #else result = ma_context_uninit_backend_apis__nix(pContext); #endif return result; } /* The default capacity doesn't need to be too big. */ #ifndef MA_DEFAULT_DEVICE_JOB_QUEUE_CAPACITY #define MA_DEFAULT_DEVICE_JOB_QUEUE_CAPACITY 32 #endif MA_API ma_device_job_thread_config ma_device_job_thread_config_init(void) { ma_device_job_thread_config config; MA_ZERO_OBJECT(&config); config.noThread = MA_FALSE; config.jobQueueCapacity = MA_DEFAULT_DEVICE_JOB_QUEUE_CAPACITY; config.jobQueueFlags = 0; return config; } static ma_thread_result MA_THREADCALL ma_device_job_thread_entry(void* pUserData) { ma_device_job_thread* pJobThread = (ma_device_job_thread*)pUserData; MA_ASSERT(pJobThread != NULL); for (;;) { ma_result result; ma_job job; result = ma_device_job_thread_next(pJobThread, &job); if (result != MA_SUCCESS) { break; } if (job.toc.breakup.code == MA_JOB_TYPE_QUIT) { break; } ma_job_process(&job); } return (ma_thread_result)0; } MA_API ma_result ma_device_job_thread_init(const ma_device_job_thread_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_device_job_thread* pJobThread) { ma_result result; ma_job_queue_config jobQueueConfig; if (pJobThread == NULL) { return MA_INVALID_ARGS; } MA_ZERO_OBJECT(pJobThread); if (pConfig == NULL) { return MA_INVALID_ARGS; } /* Initialize the job queue before the thread to ensure it's in a valid state. */ jobQueueConfig = ma_job_queue_config_init(pConfig->jobQueueFlags, pConfig->jobQueueCapacity); result = ma_job_queue_init(&jobQueueConfig, pAllocationCallbacks, &pJobThread->jobQueue); if (result != MA_SUCCESS) { return result; /* Failed to initialize job queue. */ } /* The thread needs to be initialized after the job queue to ensure the thread doesn't try to access it prematurely. */ if (pConfig->noThread == MA_FALSE) { result = ma_thread_create(&pJobThread->thread, ma_thread_priority_normal, 0, ma_device_job_thread_entry, pJobThread, pAllocationCallbacks); if (result != MA_SUCCESS) { ma_job_queue_uninit(&pJobThread->jobQueue, pAllocationCallbacks); return result; /* Failed to create the job thread. */ } pJobThread->_hasThread = MA_TRUE; } else { pJobThread->_hasThread = MA_FALSE; } return MA_SUCCESS; } MA_API void ma_device_job_thread_uninit(ma_device_job_thread* pJobThread, const ma_allocation_callbacks* pAllocationCallbacks) { if (pJobThread == NULL) { return; } /* The first thing to do is post a quit message to the job queue. If we're using a thread we'll need to wait for it. */ { ma_job job = ma_job_init(MA_JOB_TYPE_QUIT); ma_device_job_thread_post(pJobThread, &job); } /* Wait for the thread to terminate naturally. */ if (pJobThread->_hasThread) { ma_thread_wait(&pJobThread->thread); } /* At this point the thread should be terminated so we can safely uninitialize the job queue. */ ma_job_queue_uninit(&pJobThread->jobQueue, pAllocationCallbacks); } MA_API ma_result ma_device_job_thread_post(ma_device_job_thread* pJobThread, const ma_job* pJob) { if (pJobThread == NULL || pJob == NULL) { return MA_INVALID_ARGS; } return ma_job_queue_post(&pJobThread->jobQueue, pJob); } MA_API ma_result ma_device_job_thread_next(ma_device_job_thread* pJobThread, ma_job* pJob) { if (pJob == NULL) { return MA_INVALID_ARGS; } MA_ZERO_OBJECT(pJob); if (pJobThread == NULL) { return MA_INVALID_ARGS; } return ma_job_queue_next(&pJobThread->jobQueue, pJob); } MA_API ma_context_config ma_context_config_init(void) { ma_context_config config; MA_ZERO_OBJECT(&config); return config; } MA_API ma_result ma_context_init(const ma_backend backends[], ma_uint32 backendCount, const ma_context_config* pConfig, ma_context* pContext) { ma_result result; ma_context_config defaultConfig; ma_backend defaultBackends[ma_backend_null+1]; ma_uint32 iBackend; ma_backend* pBackendsToIterate; ma_uint32 backendsToIterateCount; if (pContext == NULL) { return MA_INVALID_ARGS; } MA_ZERO_OBJECT(pContext); /* Always make sure the config is set first to ensure properties are available as soon as possible. */ if (pConfig == NULL) { defaultConfig = ma_context_config_init(); pConfig = &defaultConfig; } /* Allocation callbacks need to come first because they'll be passed around to other areas. */ result = ma_allocation_callbacks_init_copy(&pContext->allocationCallbacks, &pConfig->allocationCallbacks); if (result != MA_SUCCESS) { return result; } /* Get a lot set up first so we can start logging ASAP. */ if (pConfig->pLog != NULL) { pContext->pLog = pConfig->pLog; } else { result = ma_log_init(&pContext->allocationCallbacks, &pContext->log); if (result == MA_SUCCESS) { pContext->pLog = &pContext->log; } else { pContext->pLog = NULL; /* Logging is not available. */ } } pContext->threadPriority = pConfig->threadPriority; pContext->threadStackSize = pConfig->threadStackSize; pContext->pUserData = pConfig->pUserData; /* Backend APIs need to be initialized first. This is where external libraries will be loaded and linked. */ result = ma_context_init_backend_apis(pContext); if (result != MA_SUCCESS) { return result; } for (iBackend = 0; iBackend <= ma_backend_null; ++iBackend) { defaultBackends[iBackend] = (ma_backend)iBackend; } pBackendsToIterate = (ma_backend*)backends; backendsToIterateCount = backendCount; if (pBackendsToIterate == NULL) { pBackendsToIterate = (ma_backend*)defaultBackends; backendsToIterateCount = ma_countof(defaultBackends); } MA_ASSERT(pBackendsToIterate != NULL); for (iBackend = 0; iBackend < backendsToIterateCount; iBackend += 1) { ma_backend backend = pBackendsToIterate[iBackend]; /* Make sure all callbacks are reset so we don't accidentally drag in any from previously failed initialization attempts. */ MA_ZERO_OBJECT(&pContext->callbacks); /* These backends are using the new callback system. */ switch (backend) { #ifdef MA_HAS_WASAPI case ma_backend_wasapi: { pContext->callbacks.onContextInit = ma_context_init__wasapi; } break; #endif #ifdef MA_HAS_DSOUND case ma_backend_dsound: { pContext->callbacks.onContextInit = ma_context_init__dsound; } break; #endif #ifdef MA_HAS_WINMM case ma_backend_winmm: { pContext->callbacks.onContextInit = ma_context_init__winmm; } break; #endif #ifdef MA_HAS_COREAUDIO case ma_backend_coreaudio: { pContext->callbacks.onContextInit = ma_context_init__coreaudio; } break; #endif #ifdef MA_HAS_SNDIO case ma_backend_sndio: { pContext->callbacks.onContextInit = ma_context_init__sndio; } break; #endif #ifdef MA_HAS_AUDIO4 case ma_backend_audio4: { pContext->callbacks.onContextInit = ma_context_init__audio4; } break; #endif #ifdef MA_HAS_OSS case ma_backend_oss: { pContext->callbacks.onContextInit = ma_context_init__oss; } break; #endif #ifdef MA_HAS_PULSEAUDIO case ma_backend_pulseaudio: { pContext->callbacks.onContextInit = ma_context_init__pulse; } break; #endif #ifdef MA_HAS_ALSA case ma_backend_alsa: { pContext->callbacks.onContextInit = ma_context_init__alsa; } break; #endif #ifdef MA_HAS_JACK case ma_backend_jack: { pContext->callbacks.onContextInit = ma_context_init__jack; } break; #endif #ifdef MA_HAS_AAUDIO case ma_backend_aaudio: { if (ma_is_backend_enabled(backend)) { pContext->callbacks.onContextInit = ma_context_init__aaudio; } } break; #endif #ifdef MA_HAS_OPENSL case ma_backend_opensl: { if (ma_is_backend_enabled(backend)) { pContext->callbacks.onContextInit = ma_context_init__opensl; } } break; #endif #ifdef MA_HAS_WEBAUDIO case ma_backend_webaudio: { pContext->callbacks.onContextInit = ma_context_init__webaudio; } break; #endif #ifdef MA_HAS_CUSTOM case ma_backend_custom: { /* Slightly different logic for custom backends. Custom backends can optionally set all of their callbacks in the config. */ pContext->callbacks = pConfig->custom; } break; #endif #ifdef MA_HAS_NULL case ma_backend_null: { pContext->callbacks.onContextInit = ma_context_init__null; } break; #endif default: break; } if (pContext->callbacks.onContextInit != NULL) { ma_log_postf(ma_context_get_log(pContext), MA_LOG_LEVEL_DEBUG, "Attempting to initialize %s backend...\n", ma_get_backend_name(backend)); result = pContext->callbacks.onContextInit(pContext, pConfig, &pContext->callbacks); } else { /* Getting here means the onContextInit callback is not set which means the backend is not enabled. Special case for the custom backend. */ if (backend != ma_backend_custom) { result = MA_BACKEND_NOT_ENABLED; } else { #if !defined(MA_HAS_CUSTOM) result = MA_BACKEND_NOT_ENABLED; #else result = MA_NO_BACKEND; #endif } } /* If this iteration was successful, return. */ if (result == MA_SUCCESS) { result = ma_mutex_init(&pContext->deviceEnumLock); if (result != MA_SUCCESS) { ma_log_postf(ma_context_get_log(pContext), MA_LOG_LEVEL_WARNING, "Failed to initialize mutex for device enumeration. ma_context_get_devices() is not thread safe.\n"); } result = ma_mutex_init(&pContext->deviceInfoLock); if (result != MA_SUCCESS) { ma_log_postf(ma_context_get_log(pContext), MA_LOG_LEVEL_WARNING, "Failed to initialize mutex for device info retrieval. ma_context_get_device_info() is not thread safe.\n"); } ma_log_postf(ma_context_get_log(pContext), MA_LOG_LEVEL_DEBUG, "System Architecture:\n"); ma_log_postf(ma_context_get_log(pContext), MA_LOG_LEVEL_DEBUG, " Endian: %s\n", ma_is_little_endian() ? "LE" : "BE"); ma_log_postf(ma_context_get_log(pContext), MA_LOG_LEVEL_DEBUG, " SSE2: %s\n", ma_has_sse2() ? "YES" : "NO"); ma_log_postf(ma_context_get_log(pContext), MA_LOG_LEVEL_DEBUG, " AVX2: %s\n", ma_has_avx2() ? "YES" : "NO"); ma_log_postf(ma_context_get_log(pContext), MA_LOG_LEVEL_DEBUG, " NEON: %s\n", ma_has_neon() ? "YES" : "NO"); pContext->backend = backend; return result; } else { if (result == MA_BACKEND_NOT_ENABLED) { ma_log_postf(ma_context_get_log(pContext), MA_LOG_LEVEL_DEBUG, "%s backend is disabled.\n", ma_get_backend_name(backend)); } else { ma_log_postf(ma_context_get_log(pContext), MA_LOG_LEVEL_DEBUG, "Failed to initialize %s backend.\n", ma_get_backend_name(backend)); } } } /* If we get here it means an error occurred. */ MA_ZERO_OBJECT(pContext); /* Safety. */ return MA_NO_BACKEND; } MA_API ma_result ma_context_uninit(ma_context* pContext) { if (pContext == NULL) { return MA_INVALID_ARGS; } if (pContext->callbacks.onContextUninit != NULL) { pContext->callbacks.onContextUninit(pContext); } ma_mutex_uninit(&pContext->deviceEnumLock); ma_mutex_uninit(&pContext->deviceInfoLock); ma_free(pContext->pDeviceInfos, &pContext->allocationCallbacks); ma_context_uninit_backend_apis(pContext); if (pContext->pLog == &pContext->log) { ma_log_uninit(&pContext->log); } return MA_SUCCESS; } MA_API size_t ma_context_sizeof(void) { return sizeof(ma_context); } MA_API ma_log* ma_context_get_log(ma_context* pContext) { if (pContext == NULL) { return NULL; } return pContext->pLog; } MA_API ma_result ma_context_enumerate_devices(ma_context* pContext, ma_enum_devices_callback_proc callback, void* pUserData) { ma_result result; if (pContext == NULL || callback == NULL) { return MA_INVALID_ARGS; } if (pContext->callbacks.onContextEnumerateDevices == NULL) { return MA_INVALID_OPERATION; } ma_mutex_lock(&pContext->deviceEnumLock); { result = pContext->callbacks.onContextEnumerateDevices(pContext, callback, pUserData); } ma_mutex_unlock(&pContext->deviceEnumLock); return result; } static ma_bool32 ma_context_get_devices__enum_callback(ma_context* pContext, ma_device_type deviceType, const ma_device_info* pInfo, void* pUserData) { /* We need to insert the device info into our main internal buffer. Where it goes depends on the device type. If it's a capture device it's just appended to the end. If it's a playback device it's inserted just before the first capture device. */ /* First make sure we have room. Since the number of devices we add to the list is usually relatively small I've decided to use a simple fixed size increment for buffer expansion. */ const ma_uint32 bufferExpansionCount = 2; const ma_uint32 totalDeviceInfoCount = pContext->playbackDeviceInfoCount + pContext->captureDeviceInfoCount; if (totalDeviceInfoCount >= pContext->deviceInfoCapacity) { ma_uint32 newCapacity = pContext->deviceInfoCapacity + bufferExpansionCount; ma_device_info* pNewInfos = (ma_device_info*)ma_realloc(pContext->pDeviceInfos, sizeof(*pContext->pDeviceInfos)*newCapacity, &pContext->allocationCallbacks); if (pNewInfos == NULL) { return MA_FALSE; /* Out of memory. */ } pContext->pDeviceInfos = pNewInfos; pContext->deviceInfoCapacity = newCapacity; } if (deviceType == ma_device_type_playback) { /* Playback. Insert just before the first capture device. */ /* The first thing to do is move all of the capture devices down a slot. */ ma_uint32 iFirstCaptureDevice = pContext->playbackDeviceInfoCount; size_t iCaptureDevice; for (iCaptureDevice = totalDeviceInfoCount; iCaptureDevice > iFirstCaptureDevice; --iCaptureDevice) { pContext->pDeviceInfos[iCaptureDevice] = pContext->pDeviceInfos[iCaptureDevice-1]; } /* Now just insert where the first capture device was before moving it down a slot. */ pContext->pDeviceInfos[iFirstCaptureDevice] = *pInfo; pContext->playbackDeviceInfoCount += 1; } else { /* Capture. Insert at the end. */ pContext->pDeviceInfos[totalDeviceInfoCount] = *pInfo; pContext->captureDeviceInfoCount += 1; } (void)pUserData; return MA_TRUE; } MA_API ma_result ma_context_get_devices(ma_context* pContext, ma_device_info** ppPlaybackDeviceInfos, ma_uint32* pPlaybackDeviceCount, ma_device_info** ppCaptureDeviceInfos, ma_uint32* pCaptureDeviceCount) { ma_result result; /* Safety. */ if (ppPlaybackDeviceInfos != NULL) *ppPlaybackDeviceInfos = NULL; if (pPlaybackDeviceCount != NULL) *pPlaybackDeviceCount = 0; if (ppCaptureDeviceInfos != NULL) *ppCaptureDeviceInfos = NULL; if (pCaptureDeviceCount != NULL) *pCaptureDeviceCount = 0; if (pContext == NULL) { return MA_INVALID_ARGS; } if (pContext->callbacks.onContextEnumerateDevices == NULL) { return MA_INVALID_OPERATION; } /* Note that we don't use ma_context_enumerate_devices() here because we want to do locking at a higher level. */ ma_mutex_lock(&pContext->deviceEnumLock); { /* Reset everything first. */ pContext->playbackDeviceInfoCount = 0; pContext->captureDeviceInfoCount = 0; /* Now enumerate over available devices. */ result = pContext->callbacks.onContextEnumerateDevices(pContext, ma_context_get_devices__enum_callback, NULL); if (result == MA_SUCCESS) { /* Playback devices. */ if (ppPlaybackDeviceInfos != NULL) { *ppPlaybackDeviceInfos = pContext->pDeviceInfos; } if (pPlaybackDeviceCount != NULL) { *pPlaybackDeviceCount = pContext->playbackDeviceInfoCount; } /* Capture devices. */ if (ppCaptureDeviceInfos != NULL) { *ppCaptureDeviceInfos = pContext->pDeviceInfos; /* Capture devices come after playback devices. */ if (pContext->playbackDeviceInfoCount > 0) { /* Conditional, because NULL+0 is undefined behavior. */ *ppCaptureDeviceInfos += pContext->playbackDeviceInfoCount; } } if (pCaptureDeviceCount != NULL) { *pCaptureDeviceCount = pContext->captureDeviceInfoCount; } } } ma_mutex_unlock(&pContext->deviceEnumLock); return result; } MA_API ma_result ma_context_get_device_info(ma_context* pContext, ma_device_type deviceType, const ma_device_id* pDeviceID, ma_device_info* pDeviceInfo) { ma_result result; ma_device_info deviceInfo; /* NOTE: Do not clear pDeviceInfo on entry. The reason is the pDeviceID may actually point to pDeviceInfo->id which will break things. */ if (pContext == NULL || pDeviceInfo == NULL) { return MA_INVALID_ARGS; } MA_ZERO_OBJECT(&deviceInfo); /* Help the backend out by copying over the device ID if we have one. */ if (pDeviceID != NULL) { MA_COPY_MEMORY(&deviceInfo.id, pDeviceID, sizeof(*pDeviceID)); } if (pContext->callbacks.onContextGetDeviceInfo == NULL) { return MA_INVALID_OPERATION; } ma_mutex_lock(&pContext->deviceInfoLock); { result = pContext->callbacks.onContextGetDeviceInfo(pContext, deviceType, pDeviceID, &deviceInfo); } ma_mutex_unlock(&pContext->deviceInfoLock); *pDeviceInfo = deviceInfo; return result; } MA_API ma_bool32 ma_context_is_loopback_supported(ma_context* pContext) { if (pContext == NULL) { return MA_FALSE; } return ma_is_loopback_supported(pContext->backend); } MA_API ma_device_config ma_device_config_init(ma_device_type deviceType) { ma_device_config config; MA_ZERO_OBJECT(&config); config.deviceType = deviceType; config.resampling = ma_resampler_config_init(ma_format_unknown, 0, 0, 0, ma_resample_algorithm_linear); /* Format/channels/rate don't matter here. */ return config; } MA_API ma_result ma_device_init(ma_context* pContext, const ma_device_config* pConfig, ma_device* pDevice) { ma_result result; ma_device_descriptor descriptorPlayback; ma_device_descriptor descriptorCapture; /* The context can be null, in which case we self-manage it. */ if (pContext == NULL) { return ma_device_init_ex(NULL, 0, NULL, pConfig, pDevice); } if (pDevice == NULL) { return MA_INVALID_ARGS; } MA_ZERO_OBJECT(pDevice); if (pConfig == NULL) { return MA_INVALID_ARGS; } /* Check that we have our callbacks defined. */ if (pContext->callbacks.onDeviceInit == NULL) { return MA_INVALID_OPERATION; } /* Basic config validation. */ if (pConfig->deviceType == ma_device_type_capture || pConfig->deviceType == ma_device_type_duplex) { if (pConfig->capture.channels > MA_MAX_CHANNELS) { return MA_INVALID_ARGS; } if (!ma__is_channel_map_valid(pConfig->capture.pChannelMap, pConfig->capture.channels)) { return MA_INVALID_ARGS; } } if (pConfig->deviceType == ma_device_type_playback || pConfig->deviceType == ma_device_type_duplex || pConfig->deviceType == ma_device_type_loopback) { if (pConfig->playback.channels > MA_MAX_CHANNELS) { return MA_INVALID_ARGS; } if (!ma__is_channel_map_valid(pConfig->playback.pChannelMap, pConfig->playback.channels)) { return MA_INVALID_ARGS; } } pDevice->pContext = pContext; /* Set the user data and log callback ASAP to ensure it is available for the entire initialization process. */ pDevice->pUserData = pConfig->pUserData; pDevice->onData = pConfig->dataCallback; pDevice->onNotification = pConfig->notificationCallback; pDevice->onStop = pConfig->stopCallback; if (pConfig->playback.pDeviceID != NULL) { MA_COPY_MEMORY(&pDevice->playback.id, pConfig->playback.pDeviceID, sizeof(pDevice->playback.id)); pDevice->playback.pID = &pDevice->playback.id; } else { pDevice->playback.pID = NULL; } if (pConfig->capture.pDeviceID != NULL) { MA_COPY_MEMORY(&pDevice->capture.id, pConfig->capture.pDeviceID, sizeof(pDevice->capture.id)); pDevice->capture.pID = &pDevice->capture.id; } else { pDevice->capture.pID = NULL; } pDevice->noPreSilencedOutputBuffer = pConfig->noPreSilencedOutputBuffer; pDevice->noClip = pConfig->noClip; pDevice->noDisableDenormals = pConfig->noDisableDenormals; pDevice->noFixedSizedCallback = pConfig->noFixedSizedCallback; ma_atomic_float_set(&pDevice->masterVolumeFactor, 1); pDevice->type = pConfig->deviceType; pDevice->sampleRate = pConfig->sampleRate; pDevice->resampling.algorithm = pConfig->resampling.algorithm; pDevice->resampling.linear.lpfOrder = pConfig->resampling.linear.lpfOrder; pDevice->resampling.pBackendVTable = pConfig->resampling.pBackendVTable; pDevice->resampling.pBackendUserData = pConfig->resampling.pBackendUserData; pDevice->capture.shareMode = pConfig->capture.shareMode; pDevice->capture.format = pConfig->capture.format; pDevice->capture.channels = pConfig->capture.channels; ma_channel_map_copy_or_default(pDevice->capture.channelMap, ma_countof(pDevice->capture.channelMap), pConfig->capture.pChannelMap, pConfig->capture.channels); pDevice->capture.channelMixMode = pConfig->capture.channelMixMode; pDevice->capture.calculateLFEFromSpatialChannels = pConfig->capture.calculateLFEFromSpatialChannels; pDevice->playback.shareMode = pConfig->playback.shareMode; pDevice->playback.format = pConfig->playback.format; pDevice->playback.channels = pConfig->playback.channels; ma_channel_map_copy_or_default(pDevice->playback.channelMap, ma_countof(pDevice->playback.channelMap), pConfig->playback.pChannelMap, pConfig->playback.channels); pDevice->playback.channelMixMode = pConfig->playback.channelMixMode; pDevice->playback.calculateLFEFromSpatialChannels = pConfig->playback.calculateLFEFromSpatialChannels; result = ma_mutex_init(&pDevice->startStopLock); if (result != MA_SUCCESS) { return result; } /* When the device is started, the worker thread is the one that does the actual startup of the backend device. We use a semaphore to wait for the background thread to finish the work. The same applies for stopping the device. Each of these semaphores is released internally by the worker thread when the work is completed. The start semaphore is also used to wake up the worker thread. */ result = ma_event_init(&pDevice->wakeupEvent); if (result != MA_SUCCESS) { ma_mutex_uninit(&pDevice->startStopLock); return result; } result = ma_event_init(&pDevice->startEvent); if (result != MA_SUCCESS) { ma_event_uninit(&pDevice->wakeupEvent); ma_mutex_uninit(&pDevice->startStopLock); return result; } result = ma_event_init(&pDevice->stopEvent); if (result != MA_SUCCESS) { ma_event_uninit(&pDevice->startEvent); ma_event_uninit(&pDevice->wakeupEvent); ma_mutex_uninit(&pDevice->startStopLock); return result; } MA_ZERO_OBJECT(&descriptorPlayback); descriptorPlayback.pDeviceID = pConfig->playback.pDeviceID; descriptorPlayback.shareMode = pConfig->playback.shareMode; descriptorPlayback.format = pConfig->playback.format; descriptorPlayback.channels = pConfig->playback.channels; descriptorPlayback.sampleRate = pConfig->sampleRate; ma_channel_map_copy_or_default(descriptorPlayback.channelMap, ma_countof(descriptorPlayback.channelMap), pConfig->playback.pChannelMap, pConfig->playback.channels); descriptorPlayback.periodSizeInFrames = pConfig->periodSizeInFrames; descriptorPlayback.periodSizeInMilliseconds = pConfig->periodSizeInMilliseconds; descriptorPlayback.periodCount = pConfig->periods; if (descriptorPlayback.periodCount == 0) { descriptorPlayback.periodCount = MA_DEFAULT_PERIODS; } MA_ZERO_OBJECT(&descriptorCapture); descriptorCapture.pDeviceID = pConfig->capture.pDeviceID; descriptorCapture.shareMode = pConfig->capture.shareMode; descriptorCapture.format = pConfig->capture.format; descriptorCapture.channels = pConfig->capture.channels; descriptorCapture.sampleRate = pConfig->sampleRate; ma_channel_map_copy_or_default(descriptorCapture.channelMap, ma_countof(descriptorCapture.channelMap), pConfig->capture.pChannelMap, pConfig->capture.channels); descriptorCapture.periodSizeInFrames = pConfig->periodSizeInFrames; descriptorCapture.periodSizeInMilliseconds = pConfig->periodSizeInMilliseconds; descriptorCapture.periodCount = pConfig->periods; if (descriptorCapture.periodCount == 0) { descriptorCapture.periodCount = MA_DEFAULT_PERIODS; } result = pContext->callbacks.onDeviceInit(pDevice, pConfig, &descriptorPlayback, &descriptorCapture); if (result != MA_SUCCESS) { ma_event_uninit(&pDevice->startEvent); ma_event_uninit(&pDevice->wakeupEvent); ma_mutex_uninit(&pDevice->startStopLock); return result; } #if 0 /* On output the descriptors will contain the *actual* data format of the device. We need this to know how to convert the data between the requested format and the internal format. */ if (pConfig->deviceType == ma_device_type_capture || pConfig->deviceType == ma_device_type_duplex || pConfig->deviceType == ma_device_type_loopback) { if (!ma_device_descriptor_is_valid(&descriptorCapture)) { ma_device_uninit(pDevice); return MA_INVALID_ARGS; } pDevice->capture.internalFormat = descriptorCapture.format; pDevice->capture.internalChannels = descriptorCapture.channels; pDevice->capture.internalSampleRate = descriptorCapture.sampleRate; ma_channel_map_copy(pDevice->capture.internalChannelMap, descriptorCapture.channelMap, descriptorCapture.channels); pDevice->capture.internalPeriodSizeInFrames = descriptorCapture.periodSizeInFrames; pDevice->capture.internalPeriods = descriptorCapture.periodCount; if (pDevice->capture.internalPeriodSizeInFrames == 0) { pDevice->capture.internalPeriodSizeInFrames = ma_calculate_buffer_size_in_frames_from_milliseconds(descriptorCapture.periodSizeInMilliseconds, descriptorCapture.sampleRate); } } if (pConfig->deviceType == ma_device_type_playback || pConfig->deviceType == ma_device_type_duplex) { if (!ma_device_descriptor_is_valid(&descriptorPlayback)) { ma_device_uninit(pDevice); return MA_INVALID_ARGS; } pDevice->playback.internalFormat = descriptorPlayback.format; pDevice->playback.internalChannels = descriptorPlayback.channels; pDevice->playback.internalSampleRate = descriptorPlayback.sampleRate; ma_channel_map_copy(pDevice->playback.internalChannelMap, descriptorPlayback.channelMap, descriptorPlayback.channels); pDevice->playback.internalPeriodSizeInFrames = descriptorPlayback.periodSizeInFrames; pDevice->playback.internalPeriods = descriptorPlayback.periodCount; if (pDevice->playback.internalPeriodSizeInFrames == 0) { pDevice->playback.internalPeriodSizeInFrames = ma_calculate_buffer_size_in_frames_from_milliseconds(descriptorPlayback.periodSizeInMilliseconds, descriptorPlayback.sampleRate); } } /* The name of the device can be retrieved from device info. This may be temporary and replaced with a `ma_device_get_info(pDevice, deviceType)` instead. For loopback devices, we need to retrieve the name of the playback device. */ { ma_device_info deviceInfo; if (pConfig->deviceType == ma_device_type_capture || pConfig->deviceType == ma_device_type_duplex || pConfig->deviceType == ma_device_type_loopback) { result = ma_device_get_info(pDevice, (pConfig->deviceType == ma_device_type_loopback) ? ma_device_type_playback : ma_device_type_capture, &deviceInfo); if (result == MA_SUCCESS) { ma_strncpy_s(pDevice->capture.name, sizeof(pDevice->capture.name), deviceInfo.name, (size_t)-1); } else { /* We failed to retrieve the device info. Fall back to a default name. */ if (descriptorCapture.pDeviceID == NULL) { ma_strncpy_s(pDevice->capture.name, sizeof(pDevice->capture.name), MA_DEFAULT_CAPTURE_DEVICE_NAME, (size_t)-1); } else { ma_strncpy_s(pDevice->capture.name, sizeof(pDevice->capture.name), "Capture Device", (size_t)-1); } } } if (pConfig->deviceType == ma_device_type_playback || pConfig->deviceType == ma_device_type_duplex) { result = ma_device_get_info(pDevice, ma_device_type_playback, &deviceInfo); if (result == MA_SUCCESS) { ma_strncpy_s(pDevice->playback.name, sizeof(pDevice->playback.name), deviceInfo.name, (size_t)-1); } else { /* We failed to retrieve the device info. Fall back to a default name. */ if (descriptorPlayback.pDeviceID == NULL) { ma_strncpy_s(pDevice->playback.name, sizeof(pDevice->playback.name), MA_DEFAULT_PLAYBACK_DEVICE_NAME, (size_t)-1); } else { ma_strncpy_s(pDevice->playback.name, sizeof(pDevice->playback.name), "Playback Device", (size_t)-1); } } } } ma_device__post_init_setup(pDevice, pConfig->deviceType); #endif result = ma_device_post_init(pDevice, pConfig->deviceType, &descriptorPlayback, &descriptorCapture); if (result != MA_SUCCESS) { ma_device_uninit(pDevice); return result; } /* If we're using fixed sized callbacks we'll need to make use of an intermediary buffer. Needs to be done after post_init_setup() because we'll need access to the sample rate. */ if (pConfig->noFixedSizedCallback == MA_FALSE) { /* We're using a fixed sized data callback so we'll need an intermediary buffer. */ ma_uint32 intermediaryBufferCap = pConfig->periodSizeInFrames; if (intermediaryBufferCap == 0) { intermediaryBufferCap = ma_calculate_buffer_size_in_frames_from_milliseconds(pConfig->periodSizeInMilliseconds, pDevice->sampleRate); } if (pConfig->deviceType == ma_device_type_capture || pConfig->deviceType == ma_device_type_duplex || pConfig->deviceType == ma_device_type_loopback) { ma_uint32 intermediaryBufferSizeInBytes; pDevice->capture.intermediaryBufferLen = 0; pDevice->capture.intermediaryBufferCap = intermediaryBufferCap; if (pDevice->capture.intermediaryBufferCap == 0) { pDevice->capture.intermediaryBufferCap = pDevice->capture.internalPeriodSizeInFrames; } intermediaryBufferSizeInBytes = pDevice->capture.intermediaryBufferCap * ma_get_bytes_per_frame(pDevice->capture.format, pDevice->capture.channels); pDevice->capture.pIntermediaryBuffer = ma_malloc((size_t)intermediaryBufferSizeInBytes, &pContext->allocationCallbacks); if (pDevice->capture.pIntermediaryBuffer == NULL) { ma_device_uninit(pDevice); return MA_OUT_OF_MEMORY; } /* Silence the buffer for safety. */ ma_silence_pcm_frames(pDevice->capture.pIntermediaryBuffer, pDevice->capture.intermediaryBufferCap, pDevice->capture.format, pDevice->capture.channels); pDevice->capture.intermediaryBufferLen = pDevice->capture.intermediaryBufferCap; } if (pConfig->deviceType == ma_device_type_playback || pConfig->deviceType == ma_device_type_duplex) { ma_uint64 intermediaryBufferSizeInBytes; pDevice->playback.intermediaryBufferLen = 0; if (pConfig->deviceType == ma_device_type_duplex) { pDevice->playback.intermediaryBufferCap = pDevice->capture.intermediaryBufferCap; /* In duplex mode, make sure the intermediary buffer is always the same size as the capture side. */ } else { pDevice->playback.intermediaryBufferCap = intermediaryBufferCap; if (pDevice->playback.intermediaryBufferCap == 0) { pDevice->playback.intermediaryBufferCap = pDevice->playback.internalPeriodSizeInFrames; } } intermediaryBufferSizeInBytes = pDevice->playback.intermediaryBufferCap * ma_get_bytes_per_frame(pDevice->playback.format, pDevice->playback.channels); pDevice->playback.pIntermediaryBuffer = ma_malloc((size_t)intermediaryBufferSizeInBytes, &pContext->allocationCallbacks); if (pDevice->playback.pIntermediaryBuffer == NULL) { ma_device_uninit(pDevice); return MA_OUT_OF_MEMORY; } /* Silence the buffer for safety. */ ma_silence_pcm_frames(pDevice->playback.pIntermediaryBuffer, pDevice->playback.intermediaryBufferCap, pDevice->playback.format, pDevice->playback.channels); pDevice->playback.intermediaryBufferLen = 0; } } else { /* Not using a fixed sized data callback so no need for an intermediary buffer. */ } /* Some backends don't require the worker thread. */ if (!ma_context_is_backend_asynchronous(pContext)) { /* The worker thread. */ result = ma_thread_create(&pDevice->thread, pContext->threadPriority, pContext->threadStackSize, ma_worker_thread, pDevice, &pContext->allocationCallbacks); if (result != MA_SUCCESS) { ma_device_uninit(pDevice); return result; } /* Wait for the worker thread to put the device into it's stopped state for real. */ ma_event_wait(&pDevice->stopEvent); MA_ASSERT(ma_device_get_state(pDevice) == ma_device_state_stopped); } else { /* If the backend is asynchronous and the device is duplex, we'll need an intermediary ring buffer. Note that this needs to be done after ma_device__post_init_setup(). */ if (ma_context_is_backend_asynchronous(pContext)) { if (pConfig->deviceType == ma_device_type_duplex) { result = ma_duplex_rb_init(pDevice->capture.format, pDevice->capture.channels, pDevice->sampleRate, pDevice->capture.internalSampleRate, pDevice->capture.internalPeriodSizeInFrames, &pDevice->pContext->allocationCallbacks, &pDevice->duplexRB); if (result != MA_SUCCESS) { ma_device_uninit(pDevice); return result; } } } ma_device__set_state(pDevice, ma_device_state_stopped); } /* Log device information. */ { ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_INFO, "[%s]\n", ma_get_backend_name(pDevice->pContext->backend)); if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex || pDevice->type == ma_device_type_loopback) { char name[MA_MAX_DEVICE_NAME_LENGTH + 1]; ma_device_get_name(pDevice, (pDevice->type == ma_device_type_loopback) ? ma_device_type_playback : ma_device_type_capture, name, sizeof(name), NULL); ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_INFO, " %s (%s)\n", name, "Capture"); ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_INFO, " Format: %s -> %s\n", ma_get_format_name(pDevice->capture.internalFormat), ma_get_format_name(pDevice->capture.format)); ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_INFO, " Channels: %d -> %d\n", pDevice->capture.internalChannels, pDevice->capture.channels); ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_INFO, " Sample Rate: %d -> %d\n", pDevice->capture.internalSampleRate, pDevice->sampleRate); ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_INFO, " Buffer Size: %d*%d (%d)\n", pDevice->capture.internalPeriodSizeInFrames, pDevice->capture.internalPeriods, (pDevice->capture.internalPeriodSizeInFrames * pDevice->capture.internalPeriods)); ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_INFO, " Conversion:\n"); ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_INFO, " Pre Format Conversion: %s\n", pDevice->capture.converter.hasPreFormatConversion ? "YES" : "NO"); ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_INFO, " Post Format Conversion: %s\n", pDevice->capture.converter.hasPostFormatConversion ? "YES" : "NO"); ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_INFO, " Channel Routing: %s\n", pDevice->capture.converter.hasChannelConverter ? "YES" : "NO"); ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_INFO, " Resampling: %s\n", pDevice->capture.converter.hasResampler ? "YES" : "NO"); ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_INFO, " Passthrough: %s\n", pDevice->capture.converter.isPassthrough ? "YES" : "NO"); { char channelMapStr[1024]; ma_channel_map_to_string(pDevice->capture.internalChannelMap, pDevice->capture.internalChannels, channelMapStr, sizeof(channelMapStr)); ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_INFO, " Channel Map In: {%s}\n", channelMapStr); ma_channel_map_to_string(pDevice->capture.channelMap, pDevice->capture.channels, channelMapStr, sizeof(channelMapStr)); ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_INFO, " Channel Map Out: {%s}\n", channelMapStr); } } if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) { char name[MA_MAX_DEVICE_NAME_LENGTH + 1]; ma_device_get_name(pDevice, ma_device_type_playback, name, sizeof(name), NULL); ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_INFO, " %s (%s)\n", name, "Playback"); ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_INFO, " Format: %s -> %s\n", ma_get_format_name(pDevice->playback.format), ma_get_format_name(pDevice->playback.internalFormat)); ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_INFO, " Channels: %d -> %d\n", pDevice->playback.channels, pDevice->playback.internalChannels); ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_INFO, " Sample Rate: %d -> %d\n", pDevice->sampleRate, pDevice->playback.internalSampleRate); ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_INFO, " Buffer Size: %d*%d (%d)\n", pDevice->playback.internalPeriodSizeInFrames, pDevice->playback.internalPeriods, (pDevice->playback.internalPeriodSizeInFrames * pDevice->playback.internalPeriods)); ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_INFO, " Conversion:\n"); ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_INFO, " Pre Format Conversion: %s\n", pDevice->playback.converter.hasPreFormatConversion ? "YES" : "NO"); ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_INFO, " Post Format Conversion: %s\n", pDevice->playback.converter.hasPostFormatConversion ? "YES" : "NO"); ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_INFO, " Channel Routing: %s\n", pDevice->playback.converter.hasChannelConverter ? "YES" : "NO"); ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_INFO, " Resampling: %s\n", pDevice->playback.converter.hasResampler ? "YES" : "NO"); ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_INFO, " Passthrough: %s\n", pDevice->playback.converter.isPassthrough ? "YES" : "NO"); { char channelMapStr[1024]; ma_channel_map_to_string(pDevice->playback.channelMap, pDevice->playback.channels, channelMapStr, sizeof(channelMapStr)); ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_INFO, " Channel Map In: {%s}\n", channelMapStr); ma_channel_map_to_string(pDevice->playback.internalChannelMap, pDevice->playback.internalChannels, channelMapStr, sizeof(channelMapStr)); ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_INFO, " Channel Map Out: {%s}\n", channelMapStr); } } } MA_ASSERT(ma_device_get_state(pDevice) == ma_device_state_stopped); return MA_SUCCESS; } MA_API ma_result ma_device_init_ex(const ma_backend backends[], ma_uint32 backendCount, const ma_context_config* pContextConfig, const ma_device_config* pConfig, ma_device* pDevice) { ma_result result; ma_context* pContext; ma_backend defaultBackends[ma_backend_null+1]; ma_uint32 iBackend; ma_backend* pBackendsToIterate; ma_uint32 backendsToIterateCount; ma_allocation_callbacks allocationCallbacks; if (pConfig == NULL) { return MA_INVALID_ARGS; } if (pContextConfig != NULL) { result = ma_allocation_callbacks_init_copy(&allocationCallbacks, &pContextConfig->allocationCallbacks); if (result != MA_SUCCESS) { return result; } } else { allocationCallbacks = ma_allocation_callbacks_init_default(); } pContext = (ma_context*)ma_malloc(sizeof(*pContext), &allocationCallbacks); if (pContext == NULL) { return MA_OUT_OF_MEMORY; } for (iBackend = 0; iBackend <= ma_backend_null; ++iBackend) { defaultBackends[iBackend] = (ma_backend)iBackend; } pBackendsToIterate = (ma_backend*)backends; backendsToIterateCount = backendCount; if (pBackendsToIterate == NULL) { pBackendsToIterate = (ma_backend*)defaultBackends; backendsToIterateCount = ma_countof(defaultBackends); } result = MA_NO_BACKEND; for (iBackend = 0; iBackend < backendsToIterateCount; ++iBackend) { /* This is a hack for iOS. If the context config is null, there's a good chance the `ma_device_init(NULL, &deviceConfig, pDevice);` pattern is being used. In this case, set the session category based on the device type. */ #if defined(MA_APPLE_MOBILE) ma_context_config contextConfig; if (pContextConfig == NULL) { contextConfig = ma_context_config_init(); switch (pConfig->deviceType) { case ma_device_type_duplex: { contextConfig.coreaudio.sessionCategory = ma_ios_session_category_play_and_record; } break; case ma_device_type_capture: { contextConfig.coreaudio.sessionCategory = ma_ios_session_category_record; } break; case ma_device_type_playback: default: { contextConfig.coreaudio.sessionCategory = ma_ios_session_category_playback; } break; } pContextConfig = &contextConfig; } #endif result = ma_context_init(&pBackendsToIterate[iBackend], 1, pContextConfig, pContext); if (result == MA_SUCCESS) { result = ma_device_init(pContext, pConfig, pDevice); if (result == MA_SUCCESS) { break; /* Success. */ } else { ma_context_uninit(pContext); /* Failure. */ } } } if (result != MA_SUCCESS) { ma_free(pContext, &allocationCallbacks); return result; } pDevice->isOwnerOfContext = MA_TRUE; return result; } MA_API void ma_device_uninit(ma_device* pDevice) { if (!ma_device__is_initialized(pDevice)) { return; } /* It's possible for the miniaudio side of the device and the backend to not be in sync due to system-level situations such as the computer being put into sleep mode and the backend not notifying miniaudio of the fact the device has stopped. It's possible for this to result in a deadlock due to miniaudio thinking the device is in a running state, when in fact it's not running at all. For this reason I am no longer explicitly stopping the device. I don't think this should affect anyone in practice since uninitializing the backend will naturally stop the device anyway. */ #if 0 { /* Make sure the device is stopped first. The backends will probably handle this naturally, but I like to do it explicitly for my own sanity. */ if (ma_device_is_started(pDevice)) { ma_device_stop(pDevice); } } #endif /* Putting the device into an uninitialized state will make the worker thread return. */ ma_device__set_state(pDevice, ma_device_state_uninitialized); /* Wake up the worker thread and wait for it to properly terminate. */ if (!ma_context_is_backend_asynchronous(pDevice->pContext)) { ma_event_signal(&pDevice->wakeupEvent); ma_thread_wait(&pDevice->thread); } if (pDevice->pContext->callbacks.onDeviceUninit != NULL) { pDevice->pContext->callbacks.onDeviceUninit(pDevice); } ma_event_uninit(&pDevice->stopEvent); ma_event_uninit(&pDevice->startEvent); ma_event_uninit(&pDevice->wakeupEvent); ma_mutex_uninit(&pDevice->startStopLock); if (ma_context_is_backend_asynchronous(pDevice->pContext)) { if (pDevice->type == ma_device_type_duplex) { ma_duplex_rb_uninit(&pDevice->duplexRB); } } if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex || pDevice->type == ma_device_type_loopback) { ma_data_converter_uninit(&pDevice->capture.converter, &pDevice->pContext->allocationCallbacks); } if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) { ma_data_converter_uninit(&pDevice->playback.converter, &pDevice->pContext->allocationCallbacks); } if (pDevice->playback.pInputCache != NULL) { ma_free(pDevice->playback.pInputCache, &pDevice->pContext->allocationCallbacks); } if (pDevice->capture.pIntermediaryBuffer != NULL) { ma_free(pDevice->capture.pIntermediaryBuffer, &pDevice->pContext->allocationCallbacks); } if (pDevice->playback.pIntermediaryBuffer != NULL) { ma_free(pDevice->playback.pIntermediaryBuffer, &pDevice->pContext->allocationCallbacks); } if (pDevice->isOwnerOfContext) { ma_allocation_callbacks allocationCallbacks = pDevice->pContext->allocationCallbacks; ma_context_uninit(pDevice->pContext); ma_free(pDevice->pContext, &allocationCallbacks); } MA_ZERO_OBJECT(pDevice); } MA_API ma_context* ma_device_get_context(ma_device* pDevice) { if (pDevice == NULL) { return NULL; } return pDevice->pContext; } MA_API ma_log* ma_device_get_log(ma_device* pDevice) { return ma_context_get_log(ma_device_get_context(pDevice)); } MA_API ma_result ma_device_get_info(ma_device* pDevice, ma_device_type type, ma_device_info* pDeviceInfo) { if (pDeviceInfo == NULL) { return MA_INVALID_ARGS; } MA_ZERO_OBJECT(pDeviceInfo); if (pDevice == NULL) { return MA_INVALID_ARGS; } /* If the onDeviceGetInfo() callback is set, use that. Otherwise we'll fall back to ma_context_get_device_info(). */ if (pDevice->pContext->callbacks.onDeviceGetInfo != NULL) { return pDevice->pContext->callbacks.onDeviceGetInfo(pDevice, type, pDeviceInfo); } /* Getting here means onDeviceGetInfo is not implemented so we need to fall back to an alternative. */ if (type == ma_device_type_playback) { return ma_context_get_device_info(pDevice->pContext, type, pDevice->playback.pID, pDeviceInfo); } else { return ma_context_get_device_info(pDevice->pContext, type, pDevice->capture.pID, pDeviceInfo); } } MA_API ma_result ma_device_get_name(ma_device* pDevice, ma_device_type type, char* pName, size_t nameCap, size_t* pLengthNotIncludingNullTerminator) { ma_result result; ma_device_info deviceInfo; if (pLengthNotIncludingNullTerminator != NULL) { *pLengthNotIncludingNullTerminator = 0; } if (pName != NULL && nameCap > 0) { pName[0] = '\0'; } result = ma_device_get_info(pDevice, type, &deviceInfo); if (result != MA_SUCCESS) { return result; } if (pName != NULL) { ma_strncpy_s(pName, nameCap, deviceInfo.name, (size_t)-1); /* For safety, make sure the length is based on the truncated output string rather than the source. Otherwise the caller might assume the output buffer contains more content than it actually does. */ if (pLengthNotIncludingNullTerminator != NULL) { *pLengthNotIncludingNullTerminator = strlen(pName); } } else { /* Name not specified. Just report the length of the source string. */ if (pLengthNotIncludingNullTerminator != NULL) { *pLengthNotIncludingNullTerminator = strlen(deviceInfo.name); } } return MA_SUCCESS; } MA_API ma_result ma_device_start(ma_device* pDevice) { ma_result result; if (pDevice == NULL) { return MA_INVALID_ARGS; } if (ma_device_get_state(pDevice) == ma_device_state_uninitialized) { return MA_INVALID_OPERATION; /* Not initialized. */ } if (ma_device_get_state(pDevice) == ma_device_state_started) { return MA_SUCCESS; /* Already started. */ } ma_mutex_lock(&pDevice->startStopLock); { /* Starting and stopping are wrapped in a mutex which means we can assert that the device is in a stopped or paused state. */ MA_ASSERT(ma_device_get_state(pDevice) == ma_device_state_stopped); ma_device__set_state(pDevice, ma_device_state_starting); /* Asynchronous backends need to be handled differently. */ if (ma_context_is_backend_asynchronous(pDevice->pContext)) { if (pDevice->pContext->callbacks.onDeviceStart != NULL) { result = pDevice->pContext->callbacks.onDeviceStart(pDevice); } else { result = MA_INVALID_OPERATION; } if (result == MA_SUCCESS) { ma_device__set_state(pDevice, ma_device_state_started); ma_device__on_notification_started(pDevice); } } else { /* Synchronous backends are started by signaling an event that's being waited on in the worker thread. We first wake up the thread and then wait for the start event. */ ma_event_signal(&pDevice->wakeupEvent); /* Wait for the worker thread to finish starting the device. Note that the worker thread will be the one who puts the device into the started state. Don't call ma_device__set_state() here. */ ma_event_wait(&pDevice->startEvent); result = pDevice->workResult; } /* We changed the state from stopped to started, so if we failed, make sure we put the state back to stopped. */ if (result != MA_SUCCESS) { ma_device__set_state(pDevice, ma_device_state_stopped); } } ma_mutex_unlock(&pDevice->startStopLock); return result; } MA_API ma_result ma_device_stop(ma_device* pDevice) { ma_result result; if (pDevice == NULL) { return MA_INVALID_ARGS; } if (ma_device_get_state(pDevice) == ma_device_state_uninitialized) { return MA_INVALID_OPERATION; /* Not initialized. */ } if (ma_device_get_state(pDevice) == ma_device_state_stopped) { return MA_SUCCESS; /* Already stopped. */ } ma_mutex_lock(&pDevice->startStopLock); { /* Starting and stopping are wrapped in a mutex which means we can assert that the device is in a started or paused state. */ MA_ASSERT(ma_device_get_state(pDevice) == ma_device_state_started); ma_device__set_state(pDevice, ma_device_state_stopping); /* Asynchronous backends need to be handled differently. */ if (ma_context_is_backend_asynchronous(pDevice->pContext)) { /* Asynchronous backends must have a stop operation. */ if (pDevice->pContext->callbacks.onDeviceStop != NULL) { result = pDevice->pContext->callbacks.onDeviceStop(pDevice); } else { result = MA_INVALID_OPERATION; } ma_device__set_state(pDevice, ma_device_state_stopped); } else { /* Synchronous backends. The stop callback is always called from the worker thread. Do not call the stop callback here. If the backend is implementing it's own audio thread loop we'll need to wake it up if required. Note that we need to make sure the state of the device is *not* playing right now, which it shouldn't be since we set it above. This is super important though, so I'm asserting it here as well for extra safety in case we accidentally change something later. */ MA_ASSERT(ma_device_get_state(pDevice) != ma_device_state_started); if (pDevice->pContext->callbacks.onDeviceDataLoopWakeup != NULL) { pDevice->pContext->callbacks.onDeviceDataLoopWakeup(pDevice); } /* We need to wait for the worker thread to become available for work before returning. Note that the worker thread will be the one who puts the device into the stopped state. Don't call ma_device__set_state() here. */ ma_event_wait(&pDevice->stopEvent); result = MA_SUCCESS; } /* This is a safety measure to ensure the internal buffer has been cleared so any leftover does not get played the next time the device starts. Ideally this should be drained by the backend first. */ pDevice->playback.intermediaryBufferLen = 0; pDevice->playback.inputCacheConsumed = 0; pDevice->playback.inputCacheRemaining = 0; } ma_mutex_unlock(&pDevice->startStopLock); return result; } MA_API ma_bool32 ma_device_is_started(const ma_device* pDevice) { return ma_device_get_state(pDevice) == ma_device_state_started; } MA_API ma_device_state ma_device_get_state(const ma_device* pDevice) { if (pDevice == NULL) { return ma_device_state_uninitialized; } return ma_atomic_device_state_get((ma_atomic_device_state*)&pDevice->state); /* Naughty cast to get rid of a const warning. */ } MA_API ma_result ma_device_set_master_volume(ma_device* pDevice, float volume) { if (pDevice == NULL) { return MA_INVALID_ARGS; } if (volume < 0.0f) { return MA_INVALID_ARGS; } ma_atomic_float_set(&pDevice->masterVolumeFactor, volume); return MA_SUCCESS; } MA_API ma_result ma_device_get_master_volume(ma_device* pDevice, float* pVolume) { if (pVolume == NULL) { return MA_INVALID_ARGS; } if (pDevice == NULL) { *pVolume = 0; return MA_INVALID_ARGS; } *pVolume = ma_atomic_float_get(&pDevice->masterVolumeFactor); return MA_SUCCESS; } MA_API ma_result ma_device_set_master_volume_db(ma_device* pDevice, float gainDB) { if (gainDB > 0) { return MA_INVALID_ARGS; } return ma_device_set_master_volume(pDevice, ma_volume_db_to_linear(gainDB)); } MA_API ma_result ma_device_get_master_volume_db(ma_device* pDevice, float* pGainDB) { float factor; ma_result result; if (pGainDB == NULL) { return MA_INVALID_ARGS; } result = ma_device_get_master_volume(pDevice, &factor); if (result != MA_SUCCESS) { *pGainDB = 0; return result; } *pGainDB = ma_volume_linear_to_db(factor); return MA_SUCCESS; } MA_API ma_result ma_device_handle_backend_data_callback(ma_device* pDevice, void* pOutput, const void* pInput, ma_uint32 frameCount) { if (pDevice == NULL) { return MA_INVALID_ARGS; } if (pOutput == NULL && pInput == NULL) { return MA_INVALID_ARGS; } if (pDevice->type == ma_device_type_duplex) { if (pInput != NULL) { ma_device__handle_duplex_callback_capture(pDevice, frameCount, pInput, &pDevice->duplexRB.rb); } if (pOutput != NULL) { ma_device__handle_duplex_callback_playback(pDevice, frameCount, pOutput, &pDevice->duplexRB.rb); } } else { if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_loopback) { if (pInput == NULL) { return MA_INVALID_ARGS; } ma_device__send_frames_to_client(pDevice, frameCount, pInput); } if (pDevice->type == ma_device_type_playback) { if (pOutput == NULL) { return MA_INVALID_ARGS; } ma_device__read_frames_from_client(pDevice, frameCount, pOutput); } } return MA_SUCCESS; } MA_API ma_uint32 ma_calculate_buffer_size_in_frames_from_descriptor(const ma_device_descriptor* pDescriptor, ma_uint32 nativeSampleRate, ma_performance_profile performanceProfile) { if (pDescriptor == NULL) { return 0; } /* We must have a non-0 native sample rate, but some backends don't allow retrieval of this at the time when the size of the buffer needs to be determined. In this case we need to just take a best guess and move on. We'll try using the sample rate in pDescriptor first. If that's not set we'll just fall back to MA_DEFAULT_SAMPLE_RATE. */ if (nativeSampleRate == 0) { nativeSampleRate = pDescriptor->sampleRate; } if (nativeSampleRate == 0) { nativeSampleRate = MA_DEFAULT_SAMPLE_RATE; } MA_ASSERT(nativeSampleRate != 0); if (pDescriptor->periodSizeInFrames == 0) { if (pDescriptor->periodSizeInMilliseconds == 0) { if (performanceProfile == ma_performance_profile_low_latency) { return ma_calculate_buffer_size_in_frames_from_milliseconds(MA_DEFAULT_PERIOD_SIZE_IN_MILLISECONDS_LOW_LATENCY, nativeSampleRate); } else { return ma_calculate_buffer_size_in_frames_from_milliseconds(MA_DEFAULT_PERIOD_SIZE_IN_MILLISECONDS_CONSERVATIVE, nativeSampleRate); } } else { return ma_calculate_buffer_size_in_frames_from_milliseconds(pDescriptor->periodSizeInMilliseconds, nativeSampleRate); } } else { return pDescriptor->periodSizeInFrames; } } #endif /* MA_NO_DEVICE_IO */ MA_API ma_uint32 ma_calculate_buffer_size_in_milliseconds_from_frames(ma_uint32 bufferSizeInFrames, ma_uint32 sampleRate) { /* Prevent a division by zero. */ if (sampleRate == 0) { return 0; } return bufferSizeInFrames*1000 / sampleRate; } MA_API ma_uint32 ma_calculate_buffer_size_in_frames_from_milliseconds(ma_uint32 bufferSizeInMilliseconds, ma_uint32 sampleRate) { /* Prevent a division by zero. */ if (sampleRate == 0) { return 0; } return bufferSizeInMilliseconds*sampleRate / 1000; } MA_API void ma_copy_pcm_frames(void* dst, const void* src, ma_uint64 frameCount, ma_format format, ma_uint32 channels) { if (dst == src) { return; /* No-op. */ } ma_copy_memory_64(dst, src, frameCount * ma_get_bytes_per_frame(format, channels)); } MA_API void ma_silence_pcm_frames(void* p, ma_uint64 frameCount, ma_format format, ma_uint32 channels) { if (format == ma_format_u8) { ma_uint64 sampleCount = frameCount * channels; ma_uint64 iSample; for (iSample = 0; iSample < sampleCount; iSample += 1) { ((ma_uint8*)p)[iSample] = 128; } } else { ma_zero_memory_64(p, frameCount * ma_get_bytes_per_frame(format, channels)); } } MA_API void* ma_offset_pcm_frames_ptr(void* p, ma_uint64 offsetInFrames, ma_format format, ma_uint32 channels) { return ma_offset_ptr(p, offsetInFrames * ma_get_bytes_per_frame(format, channels)); } MA_API const void* ma_offset_pcm_frames_const_ptr(const void* p, ma_uint64 offsetInFrames, ma_format format, ma_uint32 channels) { return ma_offset_ptr(p, offsetInFrames * ma_get_bytes_per_frame(format, channels)); } MA_API void ma_clip_samples_u8(ma_uint8* pDst, const ma_int16* pSrc, ma_uint64 count) { ma_uint64 iSample; MA_ASSERT(pDst != NULL); MA_ASSERT(pSrc != NULL); for (iSample = 0; iSample < count; iSample += 1) { pDst[iSample] = ma_clip_u8(pSrc[iSample]); } } MA_API void ma_clip_samples_s16(ma_int16* pDst, const ma_int32* pSrc, ma_uint64 count) { ma_uint64 iSample; MA_ASSERT(pDst != NULL); MA_ASSERT(pSrc != NULL); for (iSample = 0; iSample < count; iSample += 1) { pDst[iSample] = ma_clip_s16(pSrc[iSample]); } } MA_API void ma_clip_samples_s24(ma_uint8* pDst, const ma_int64* pSrc, ma_uint64 count) { ma_uint64 iSample; MA_ASSERT(pDst != NULL); MA_ASSERT(pSrc != NULL); for (iSample = 0; iSample < count; iSample += 1) { ma_int64 s = ma_clip_s24(pSrc[iSample]); pDst[iSample*3 + 0] = (ma_uint8)((s & 0x000000FF) >> 0); pDst[iSample*3 + 1] = (ma_uint8)((s & 0x0000FF00) >> 8); pDst[iSample*3 + 2] = (ma_uint8)((s & 0x00FF0000) >> 16); } } MA_API void ma_clip_samples_s32(ma_int32* pDst, const ma_int64* pSrc, ma_uint64 count) { ma_uint64 iSample; MA_ASSERT(pDst != NULL); MA_ASSERT(pSrc != NULL); for (iSample = 0; iSample < count; iSample += 1) { pDst[iSample] = ma_clip_s32(pSrc[iSample]); } } MA_API void ma_clip_samples_f32(float* pDst, const float* pSrc, ma_uint64 count) { ma_uint64 iSample; MA_ASSERT(pDst != NULL); MA_ASSERT(pSrc != NULL); for (iSample = 0; iSample < count; iSample += 1) { pDst[iSample] = ma_clip_f32(pSrc[iSample]); } } MA_API void ma_clip_pcm_frames(void* pDst, const void* pSrc, ma_uint64 frameCount, ma_format format, ma_uint32 channels) { ma_uint64 sampleCount; MA_ASSERT(pDst != NULL); MA_ASSERT(pSrc != NULL); sampleCount = frameCount * channels; switch (format) { case ma_format_u8: ma_clip_samples_u8( (ma_uint8*)pDst, (const ma_int16*)pSrc, sampleCount); break; case ma_format_s16: ma_clip_samples_s16((ma_int16*)pDst, (const ma_int32*)pSrc, sampleCount); break; case ma_format_s24: ma_clip_samples_s24((ma_uint8*)pDst, (const ma_int64*)pSrc, sampleCount); break; case ma_format_s32: ma_clip_samples_s32((ma_int32*)pDst, (const ma_int64*)pSrc, sampleCount); break; case ma_format_f32: ma_clip_samples_f32(( float*)pDst, (const float*)pSrc, sampleCount); break; /* Do nothing if we don't know the format. We're including these here to silence a compiler warning about enums not being handled by the switch. */ case ma_format_unknown: case ma_format_count: break; } } MA_API void ma_copy_and_apply_volume_factor_u8(ma_uint8* pSamplesOut, const ma_uint8* pSamplesIn, ma_uint64 sampleCount, float factor) { ma_uint64 iSample; if (pSamplesOut == NULL || pSamplesIn == NULL) { return; } for (iSample = 0; iSample < sampleCount; iSample += 1) { pSamplesOut[iSample] = (ma_uint8)(pSamplesIn[iSample] * factor); } } MA_API void ma_copy_and_apply_volume_factor_s16(ma_int16* pSamplesOut, const ma_int16* pSamplesIn, ma_uint64 sampleCount, float factor) { ma_uint64 iSample; if (pSamplesOut == NULL || pSamplesIn == NULL) { return; } for (iSample = 0; iSample < sampleCount; iSample += 1) { pSamplesOut[iSample] = (ma_int16)(pSamplesIn[iSample] * factor); } } MA_API void ma_copy_and_apply_volume_factor_s24(void* pSamplesOut, const void* pSamplesIn, ma_uint64 sampleCount, float factor) { ma_uint64 iSample; ma_uint8* pSamplesOut8; ma_uint8* pSamplesIn8; if (pSamplesOut == NULL || pSamplesIn == NULL) { return; } pSamplesOut8 = (ma_uint8*)pSamplesOut; pSamplesIn8 = (ma_uint8*)pSamplesIn; for (iSample = 0; iSample < sampleCount; iSample += 1) { ma_int32 sampleS32; sampleS32 = (ma_int32)(((ma_uint32)(pSamplesIn8[iSample*3+0]) << 8) | ((ma_uint32)(pSamplesIn8[iSample*3+1]) << 16) | ((ma_uint32)(pSamplesIn8[iSample*3+2])) << 24); sampleS32 = (ma_int32)(sampleS32 * factor); pSamplesOut8[iSample*3+0] = (ma_uint8)(((ma_uint32)sampleS32 & 0x0000FF00) >> 8); pSamplesOut8[iSample*3+1] = (ma_uint8)(((ma_uint32)sampleS32 & 0x00FF0000) >> 16); pSamplesOut8[iSample*3+2] = (ma_uint8)(((ma_uint32)sampleS32 & 0xFF000000) >> 24); } } MA_API void ma_copy_and_apply_volume_factor_s32(ma_int32* pSamplesOut, const ma_int32* pSamplesIn, ma_uint64 sampleCount, float factor) { ma_uint64 iSample; if (pSamplesOut == NULL || pSamplesIn == NULL) { return; } for (iSample = 0; iSample < sampleCount; iSample += 1) { pSamplesOut[iSample] = (ma_int32)(pSamplesIn[iSample] * factor); } } MA_API void ma_copy_and_apply_volume_factor_f32(float* pSamplesOut, const float* pSamplesIn, ma_uint64 sampleCount, float factor) { ma_uint64 iSample; if (pSamplesOut == NULL || pSamplesIn == NULL) { return; } if (factor == 1) { if (pSamplesOut == pSamplesIn) { /* In place. No-op. */ } else { /* Just a copy. */ for (iSample = 0; iSample < sampleCount; iSample += 1) { pSamplesOut[iSample] = pSamplesIn[iSample]; } } } else { for (iSample = 0; iSample < sampleCount; iSample += 1) { pSamplesOut[iSample] = pSamplesIn[iSample] * factor; } } } MA_API void ma_apply_volume_factor_u8(ma_uint8* pSamples, ma_uint64 sampleCount, float factor) { ma_copy_and_apply_volume_factor_u8(pSamples, pSamples, sampleCount, factor); } MA_API void ma_apply_volume_factor_s16(ma_int16* pSamples, ma_uint64 sampleCount, float factor) { ma_copy_and_apply_volume_factor_s16(pSamples, pSamples, sampleCount, factor); } MA_API void ma_apply_volume_factor_s24(void* pSamples, ma_uint64 sampleCount, float factor) { ma_copy_and_apply_volume_factor_s24(pSamples, pSamples, sampleCount, factor); } MA_API void ma_apply_volume_factor_s32(ma_int32* pSamples, ma_uint64 sampleCount, float factor) { ma_copy_and_apply_volume_factor_s32(pSamples, pSamples, sampleCount, factor); } MA_API void ma_apply_volume_factor_f32(float* pSamples, ma_uint64 sampleCount, float factor) { ma_copy_and_apply_volume_factor_f32(pSamples, pSamples, sampleCount, factor); } MA_API void ma_copy_and_apply_volume_factor_pcm_frames_u8(ma_uint8* pFramesOut, const ma_uint8* pFramesIn, ma_uint64 frameCount, ma_uint32 channels, float factor) { ma_copy_and_apply_volume_factor_u8(pFramesOut, pFramesIn, frameCount*channels, factor); } MA_API void ma_copy_and_apply_volume_factor_pcm_frames_s16(ma_int16* pFramesOut, const ma_int16* pFramesIn, ma_uint64 frameCount, ma_uint32 channels, float factor) { ma_copy_and_apply_volume_factor_s16(pFramesOut, pFramesIn, frameCount*channels, factor); } MA_API void ma_copy_and_apply_volume_factor_pcm_frames_s24(void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount, ma_uint32 channels, float factor) { ma_copy_and_apply_volume_factor_s24(pFramesOut, pFramesIn, frameCount*channels, factor); } MA_API void ma_copy_and_apply_volume_factor_pcm_frames_s32(ma_int32* pFramesOut, const ma_int32* pFramesIn, ma_uint64 frameCount, ma_uint32 channels, float factor) { ma_copy_and_apply_volume_factor_s32(pFramesOut, pFramesIn, frameCount*channels, factor); } MA_API void ma_copy_and_apply_volume_factor_pcm_frames_f32(float* pFramesOut, const float* pFramesIn, ma_uint64 frameCount, ma_uint32 channels, float factor) { ma_copy_and_apply_volume_factor_f32(pFramesOut, pFramesIn, frameCount*channels, factor); } MA_API void ma_copy_and_apply_volume_factor_pcm_frames(void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount, ma_format format, ma_uint32 channels, float factor) { switch (format) { case ma_format_u8: ma_copy_and_apply_volume_factor_pcm_frames_u8 ((ma_uint8*)pFramesOut, (const ma_uint8*)pFramesIn, frameCount, channels, factor); return; case ma_format_s16: ma_copy_and_apply_volume_factor_pcm_frames_s16((ma_int16*)pFramesOut, (const ma_int16*)pFramesIn, frameCount, channels, factor); return; case ma_format_s24: ma_copy_and_apply_volume_factor_pcm_frames_s24( pFramesOut, pFramesIn, frameCount, channels, factor); return; case ma_format_s32: ma_copy_and_apply_volume_factor_pcm_frames_s32((ma_int32*)pFramesOut, (const ma_int32*)pFramesIn, frameCount, channels, factor); return; case ma_format_f32: ma_copy_and_apply_volume_factor_pcm_frames_f32( (float*)pFramesOut, (const float*)pFramesIn, frameCount, channels, factor); return; default: return; /* Do nothing. */ } } MA_API void ma_apply_volume_factor_pcm_frames_u8(ma_uint8* pFrames, ma_uint64 frameCount, ma_uint32 channels, float factor) { ma_copy_and_apply_volume_factor_pcm_frames_u8(pFrames, pFrames, frameCount, channels, factor); } MA_API void ma_apply_volume_factor_pcm_frames_s16(ma_int16* pFrames, ma_uint64 frameCount, ma_uint32 channels, float factor) { ma_copy_and_apply_volume_factor_pcm_frames_s16(pFrames, pFrames, frameCount, channels, factor); } MA_API void ma_apply_volume_factor_pcm_frames_s24(void* pFrames, ma_uint64 frameCount, ma_uint32 channels, float factor) { ma_copy_and_apply_volume_factor_pcm_frames_s24(pFrames, pFrames, frameCount, channels, factor); } MA_API void ma_apply_volume_factor_pcm_frames_s32(ma_int32* pFrames, ma_uint64 frameCount, ma_uint32 channels, float factor) { ma_copy_and_apply_volume_factor_pcm_frames_s32(pFrames, pFrames, frameCount, channels, factor); } MA_API void ma_apply_volume_factor_pcm_frames_f32(float* pFrames, ma_uint64 frameCount, ma_uint32 channels, float factor) { ma_copy_and_apply_volume_factor_pcm_frames_f32(pFrames, pFrames, frameCount, channels, factor); } MA_API void ma_apply_volume_factor_pcm_frames(void* pFramesOut, ma_uint64 frameCount, ma_format format, ma_uint32 channels, float factor) { ma_copy_and_apply_volume_factor_pcm_frames(pFramesOut, pFramesOut, frameCount, format, channels, factor); } MA_API void ma_copy_and_apply_volume_factor_per_channel_f32(float* pFramesOut, const float* pFramesIn, ma_uint64 frameCount, ma_uint32 channels, float* pChannelGains) { ma_uint64 iFrame; if (channels == 2) { /* TODO: Do an optimized implementation for stereo and mono. Can do a SIMD optimized implementation as well. */ } for (iFrame = 0; iFrame < frameCount; iFrame += 1) { ma_uint32 iChannel; for (iChannel = 0; iChannel < channels; iChannel += 1) { pFramesOut[iFrame * channels + iChannel] = pFramesIn[iFrame * channels + iChannel] * pChannelGains[iChannel]; } } } static MA_INLINE ma_int16 ma_apply_volume_unclipped_u8(ma_int16 x, ma_int16 volume) { return (ma_int16)(((ma_int32)x * (ma_int32)volume) >> 8); } static MA_INLINE ma_int32 ma_apply_volume_unclipped_s16(ma_int32 x, ma_int16 volume) { return (ma_int32)((x * volume) >> 8); } static MA_INLINE ma_int64 ma_apply_volume_unclipped_s24(ma_int64 x, ma_int16 volume) { return (ma_int64)((x * volume) >> 8); } static MA_INLINE ma_int64 ma_apply_volume_unclipped_s32(ma_int64 x, ma_int16 volume) { return (ma_int64)((x * volume) >> 8); } static MA_INLINE float ma_apply_volume_unclipped_f32(float x, float volume) { return x * volume; } MA_API void ma_copy_and_apply_volume_and_clip_samples_u8(ma_uint8* pDst, const ma_int16* pSrc, ma_uint64 count, float volume) { ma_uint64 iSample; ma_int16 volumeFixed; MA_ASSERT(pDst != NULL); MA_ASSERT(pSrc != NULL); volumeFixed = ma_float_to_fixed_16(volume); for (iSample = 0; iSample < count; iSample += 1) { pDst[iSample] = ma_clip_u8(ma_apply_volume_unclipped_u8(pSrc[iSample], volumeFixed)); } } MA_API void ma_copy_and_apply_volume_and_clip_samples_s16(ma_int16* pDst, const ma_int32* pSrc, ma_uint64 count, float volume) { ma_uint64 iSample; ma_int16 volumeFixed; MA_ASSERT(pDst != NULL); MA_ASSERT(pSrc != NULL); volumeFixed = ma_float_to_fixed_16(volume); for (iSample = 0; iSample < count; iSample += 1) { pDst[iSample] = ma_clip_s16(ma_apply_volume_unclipped_s16(pSrc[iSample], volumeFixed)); } } MA_API void ma_copy_and_apply_volume_and_clip_samples_s24(ma_uint8* pDst, const ma_int64* pSrc, ma_uint64 count, float volume) { ma_uint64 iSample; ma_int16 volumeFixed; MA_ASSERT(pDst != NULL); MA_ASSERT(pSrc != NULL); volumeFixed = ma_float_to_fixed_16(volume); for (iSample = 0; iSample < count; iSample += 1) { ma_int64 s = ma_clip_s24(ma_apply_volume_unclipped_s24(pSrc[iSample], volumeFixed)); pDst[iSample*3 + 0] = (ma_uint8)((s & 0x000000FF) >> 0); pDst[iSample*3 + 1] = (ma_uint8)((s & 0x0000FF00) >> 8); pDst[iSample*3 + 2] = (ma_uint8)((s & 0x00FF0000) >> 16); } } MA_API void ma_copy_and_apply_volume_and_clip_samples_s32(ma_int32* pDst, const ma_int64* pSrc, ma_uint64 count, float volume) { ma_uint64 iSample; ma_int16 volumeFixed; MA_ASSERT(pDst != NULL); MA_ASSERT(pSrc != NULL); volumeFixed = ma_float_to_fixed_16(volume); for (iSample = 0; iSample < count; iSample += 1) { pDst[iSample] = ma_clip_s32(ma_apply_volume_unclipped_s32(pSrc[iSample], volumeFixed)); } } MA_API void ma_copy_and_apply_volume_and_clip_samples_f32(float* pDst, const float* pSrc, ma_uint64 count, float volume) { ma_uint64 iSample; MA_ASSERT(pDst != NULL); MA_ASSERT(pSrc != NULL); /* For the f32 case we need to make sure this supports in-place processing where the input and output buffers are the same. */ for (iSample = 0; iSample < count; iSample += 1) { pDst[iSample] = ma_clip_f32(ma_apply_volume_unclipped_f32(pSrc[iSample], volume)); } } MA_API void ma_copy_and_apply_volume_and_clip_pcm_frames(void* pDst, const void* pSrc, ma_uint64 frameCount, ma_format format, ma_uint32 channels, float volume) { MA_ASSERT(pDst != NULL); MA_ASSERT(pSrc != NULL); if (volume == 1) { ma_clip_pcm_frames(pDst, pSrc, frameCount, format, channels); /* Optimized case for volume = 1. */ } else if (volume == 0) { ma_silence_pcm_frames(pDst, frameCount, format, channels); /* Optimized case for volume = 0. */ } else { ma_uint64 sampleCount = frameCount * channels; switch (format) { case ma_format_u8: ma_copy_and_apply_volume_and_clip_samples_u8( (ma_uint8*)pDst, (const ma_int16*)pSrc, sampleCount, volume); break; case ma_format_s16: ma_copy_and_apply_volume_and_clip_samples_s16((ma_int16*)pDst, (const ma_int32*)pSrc, sampleCount, volume); break; case ma_format_s24: ma_copy_and_apply_volume_and_clip_samples_s24((ma_uint8*)pDst, (const ma_int64*)pSrc, sampleCount, volume); break; case ma_format_s32: ma_copy_and_apply_volume_and_clip_samples_s32((ma_int32*)pDst, (const ma_int64*)pSrc, sampleCount, volume); break; case ma_format_f32: ma_copy_and_apply_volume_and_clip_samples_f32(( float*)pDst, (const float*)pSrc, sampleCount, volume); break; /* Do nothing if we don't know the format. We're including these here to silence a compiler warning about enums not being handled by the switch. */ case ma_format_unknown: case ma_format_count: break; } } } MA_API float ma_volume_linear_to_db(float factor) { return 20*ma_log10f(factor); } MA_API float ma_volume_db_to_linear(float gain) { return ma_powf(10, gain/20.0f); } MA_API ma_result ma_mix_pcm_frames_f32(float* pDst, const float* pSrc, ma_uint64 frameCount, ma_uint32 channels, float volume) { ma_uint64 iSample; ma_uint64 sampleCount; if (pDst == NULL || pSrc == NULL || channels == 0) { return MA_INVALID_ARGS; } if (volume == 0) { return MA_SUCCESS; /* No changes if the volume is 0. */ } sampleCount = frameCount * channels; if (volume == 1) { for (iSample = 0; iSample < sampleCount; iSample += 1) { pDst[iSample] += pSrc[iSample]; } } else { for (iSample = 0; iSample < sampleCount; iSample += 1) { pDst[iSample] += ma_apply_volume_unclipped_f32(pSrc[iSample], volume); } } return MA_SUCCESS; } /************************************************************************************************************************************************************** Format Conversion **************************************************************************************************************************************************************/ static MA_INLINE ma_int16 ma_pcm_sample_f32_to_s16(float x) { return (ma_int16)(x * 32767.0f); } static MA_INLINE ma_int16 ma_pcm_sample_u8_to_s16_no_scale(ma_uint8 x) { return (ma_int16)((ma_int16)x - 128); } static MA_INLINE ma_int64 ma_pcm_sample_s24_to_s32_no_scale(const ma_uint8* x) { return (ma_int64)(((ma_uint64)x[0] << 40) | ((ma_uint64)x[1] << 48) | ((ma_uint64)x[2] << 56)) >> 40; /* Make sure the sign bits are maintained. */ } static MA_INLINE void ma_pcm_sample_s32_to_s24_no_scale(ma_int64 x, ma_uint8* s24) { s24[0] = (ma_uint8)((x & 0x000000FF) >> 0); s24[1] = (ma_uint8)((x & 0x0000FF00) >> 8); s24[2] = (ma_uint8)((x & 0x00FF0000) >> 16); } /* u8 */ MA_API void ma_pcm_u8_to_u8(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode) { (void)ditherMode; ma_copy_memory_64(dst, src, count * sizeof(ma_uint8)); } static MA_INLINE void ma_pcm_u8_to_s16__reference(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode) { ma_int16* dst_s16 = (ma_int16*)dst; const ma_uint8* src_u8 = (const ma_uint8*)src; ma_uint64 i; for (i = 0; i < count; i += 1) { ma_int16 x = src_u8[i]; x = (ma_int16)(x - 128); x = (ma_int16)(x << 8); dst_s16[i] = x; } (void)ditherMode; } static MA_INLINE void ma_pcm_u8_to_s16__optimized(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode) { ma_pcm_u8_to_s16__reference(dst, src, count, ditherMode); } #if defined(MA_SUPPORT_SSE2) static MA_INLINE void ma_pcm_u8_to_s16__sse2(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode) { ma_pcm_u8_to_s16__optimized(dst, src, count, ditherMode); } #endif #if defined(MA_SUPPORT_NEON) static MA_INLINE void ma_pcm_u8_to_s16__neon(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode) { ma_pcm_u8_to_s16__optimized(dst, src, count, ditherMode); } #endif MA_API void ma_pcm_u8_to_s16(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode) { #ifdef MA_USE_REFERENCE_CONVERSION_APIS ma_pcm_u8_to_s16__reference(dst, src, count, ditherMode); #else # if defined(MA_SUPPORT_SSE2) if (ma_has_sse2()) { ma_pcm_u8_to_s16__sse2(dst, src, count, ditherMode); } else #elif defined(MA_SUPPORT_NEON) if (ma_has_neon()) { ma_pcm_u8_to_s16__neon(dst, src, count, ditherMode); } else #endif { ma_pcm_u8_to_s16__optimized(dst, src, count, ditherMode); } #endif } static MA_INLINE void ma_pcm_u8_to_s24__reference(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode) { ma_uint8* dst_s24 = (ma_uint8*)dst; const ma_uint8* src_u8 = (const ma_uint8*)src; ma_uint64 i; for (i = 0; i < count; i += 1) { ma_int16 x = src_u8[i]; x = (ma_int16)(x - 128); dst_s24[i*3+0] = 0; dst_s24[i*3+1] = 0; dst_s24[i*3+2] = (ma_uint8)((ma_int8)x); } (void)ditherMode; } static MA_INLINE void ma_pcm_u8_to_s24__optimized(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode) { ma_pcm_u8_to_s24__reference(dst, src, count, ditherMode); } #if defined(MA_SUPPORT_SSE2) static MA_INLINE void ma_pcm_u8_to_s24__sse2(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode) { ma_pcm_u8_to_s24__optimized(dst, src, count, ditherMode); } #endif #if defined(MA_SUPPORT_NEON) static MA_INLINE void ma_pcm_u8_to_s24__neon(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode) { ma_pcm_u8_to_s24__optimized(dst, src, count, ditherMode); } #endif MA_API void ma_pcm_u8_to_s24(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode) { #ifdef MA_USE_REFERENCE_CONVERSION_APIS ma_pcm_u8_to_s24__reference(dst, src, count, ditherMode); #else # if defined(MA_SUPPORT_SSE2) if (ma_has_sse2()) { ma_pcm_u8_to_s24__sse2(dst, src, count, ditherMode); } else #elif defined(MA_SUPPORT_NEON) if (ma_has_neon()) { ma_pcm_u8_to_s24__neon(dst, src, count, ditherMode); } else #endif { ma_pcm_u8_to_s24__optimized(dst, src, count, ditherMode); } #endif } static MA_INLINE void ma_pcm_u8_to_s32__reference(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode) { ma_int32* dst_s32 = (ma_int32*)dst; const ma_uint8* src_u8 = (const ma_uint8*)src; ma_uint64 i; for (i = 0; i < count; i += 1) { ma_int32 x = src_u8[i]; x = x - 128; x = x << 24; dst_s32[i] = x; } (void)ditherMode; } static MA_INLINE void ma_pcm_u8_to_s32__optimized(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode) { ma_pcm_u8_to_s32__reference(dst, src, count, ditherMode); } #if defined(MA_SUPPORT_SSE2) static MA_INLINE void ma_pcm_u8_to_s32__sse2(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode) { ma_pcm_u8_to_s32__optimized(dst, src, count, ditherMode); } #endif #if defined(MA_SUPPORT_NEON) static MA_INLINE void ma_pcm_u8_to_s32__neon(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode) { ma_pcm_u8_to_s32__optimized(dst, src, count, ditherMode); } #endif MA_API void ma_pcm_u8_to_s32(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode) { #ifdef MA_USE_REFERENCE_CONVERSION_APIS ma_pcm_u8_to_s32__reference(dst, src, count, ditherMode); #else # if defined(MA_SUPPORT_SSE2) if (ma_has_sse2()) { ma_pcm_u8_to_s32__sse2(dst, src, count, ditherMode); } else #elif defined(MA_SUPPORT_NEON) if (ma_has_neon()) { ma_pcm_u8_to_s32__neon(dst, src, count, ditherMode); } else #endif { ma_pcm_u8_to_s32__optimized(dst, src, count, ditherMode); } #endif } static MA_INLINE void ma_pcm_u8_to_f32__reference(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode) { float* dst_f32 = (float*)dst; const ma_uint8* src_u8 = (const ma_uint8*)src; ma_uint64 i; for (i = 0; i < count; i += 1) { float x = (float)src_u8[i]; x = x * 0.00784313725490196078f; /* 0..255 to 0..2 */ x = x - 1; /* 0..2 to -1..1 */ dst_f32[i] = x; } (void)ditherMode; } static MA_INLINE void ma_pcm_u8_to_f32__optimized(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode) { ma_pcm_u8_to_f32__reference(dst, src, count, ditherMode); } #if defined(MA_SUPPORT_SSE2) static MA_INLINE void ma_pcm_u8_to_f32__sse2(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode) { ma_pcm_u8_to_f32__optimized(dst, src, count, ditherMode); } #endif #if defined(MA_SUPPORT_NEON) static MA_INLINE void ma_pcm_u8_to_f32__neon(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode) { ma_pcm_u8_to_f32__optimized(dst, src, count, ditherMode); } #endif MA_API void ma_pcm_u8_to_f32(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode) { #ifdef MA_USE_REFERENCE_CONVERSION_APIS ma_pcm_u8_to_f32__reference(dst, src, count, ditherMode); #else # if defined(MA_SUPPORT_SSE2) if (ma_has_sse2()) { ma_pcm_u8_to_f32__sse2(dst, src, count, ditherMode); } else #elif defined(MA_SUPPORT_NEON) if (ma_has_neon()) { ma_pcm_u8_to_f32__neon(dst, src, count, ditherMode); } else #endif { ma_pcm_u8_to_f32__optimized(dst, src, count, ditherMode); } #endif } #ifdef MA_USE_REFERENCE_CONVERSION_APIS static MA_INLINE void ma_pcm_interleave_u8__reference(void* dst, const void** src, ma_uint64 frameCount, ma_uint32 channels) { ma_uint8* dst_u8 = (ma_uint8*)dst; const ma_uint8** src_u8 = (const ma_uint8**)src; ma_uint64 iFrame; for (iFrame = 0; iFrame < frameCount; iFrame += 1) { ma_uint32 iChannel; for (iChannel = 0; iChannel < channels; iChannel += 1) { dst_u8[iFrame*channels + iChannel] = src_u8[iChannel][iFrame]; } } } #else static MA_INLINE void ma_pcm_interleave_u8__optimized(void* dst, const void** src, ma_uint64 frameCount, ma_uint32 channels) { ma_uint8* dst_u8 = (ma_uint8*)dst; const ma_uint8** src_u8 = (const ma_uint8**)src; if (channels == 1) { ma_copy_memory_64(dst, src[0], frameCount * sizeof(ma_uint8)); } else if (channels == 2) { ma_uint64 iFrame; for (iFrame = 0; iFrame < frameCount; iFrame += 1) { dst_u8[iFrame*2 + 0] = src_u8[0][iFrame]; dst_u8[iFrame*2 + 1] = src_u8[1][iFrame]; } } else { ma_uint64 iFrame; for (iFrame = 0; iFrame < frameCount; iFrame += 1) { ma_uint32 iChannel; for (iChannel = 0; iChannel < channels; iChannel += 1) { dst_u8[iFrame*channels + iChannel] = src_u8[iChannel][iFrame]; } } } } #endif MA_API void ma_pcm_interleave_u8(void* dst, const void** src, ma_uint64 frameCount, ma_uint32 channels) { #ifdef MA_USE_REFERENCE_CONVERSION_APIS ma_pcm_interleave_u8__reference(dst, src, frameCount, channels); #else ma_pcm_interleave_u8__optimized(dst, src, frameCount, channels); #endif } static MA_INLINE void ma_pcm_deinterleave_u8__reference(void** dst, const void* src, ma_uint64 frameCount, ma_uint32 channels) { ma_uint8** dst_u8 = (ma_uint8**)dst; const ma_uint8* src_u8 = (const ma_uint8*)src; ma_uint64 iFrame; for (iFrame = 0; iFrame < frameCount; iFrame += 1) { ma_uint32 iChannel; for (iChannel = 0; iChannel < channels; iChannel += 1) { dst_u8[iChannel][iFrame] = src_u8[iFrame*channels + iChannel]; } } } static MA_INLINE void ma_pcm_deinterleave_u8__optimized(void** dst, const void* src, ma_uint64 frameCount, ma_uint32 channels) { ma_pcm_deinterleave_u8__reference(dst, src, frameCount, channels); } MA_API void ma_pcm_deinterleave_u8(void** dst, const void* src, ma_uint64 frameCount, ma_uint32 channels) { #ifdef MA_USE_REFERENCE_CONVERSION_APIS ma_pcm_deinterleave_u8__reference(dst, src, frameCount, channels); #else ma_pcm_deinterleave_u8__optimized(dst, src, frameCount, channels); #endif } /* s16 */ static MA_INLINE void ma_pcm_s16_to_u8__reference(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode) { ma_uint8* dst_u8 = (ma_uint8*)dst; const ma_int16* src_s16 = (const ma_int16*)src; if (ditherMode == ma_dither_mode_none) { ma_uint64 i; for (i = 0; i < count; i += 1) { ma_int16 x = src_s16[i]; x = (ma_int16)(x >> 8); x = (ma_int16)(x + 128); dst_u8[i] = (ma_uint8)x; } } else { ma_uint64 i; for (i = 0; i < count; i += 1) { ma_int16 x = src_s16[i]; /* Dither. Don't overflow. */ ma_int32 dither = ma_dither_s32(ditherMode, -0x80, 0x7F); if ((x + dither) <= 0x7FFF) { x = (ma_int16)(x + dither); } else { x = 0x7FFF; } x = (ma_int16)(x >> 8); x = (ma_int16)(x + 128); dst_u8[i] = (ma_uint8)x; } } } static MA_INLINE void ma_pcm_s16_to_u8__optimized(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode) { ma_pcm_s16_to_u8__reference(dst, src, count, ditherMode); } #if defined(MA_SUPPORT_SSE2) static MA_INLINE void ma_pcm_s16_to_u8__sse2(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode) { ma_pcm_s16_to_u8__optimized(dst, src, count, ditherMode); } #endif #if defined(MA_SUPPORT_NEON) static MA_INLINE void ma_pcm_s16_to_u8__neon(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode) { ma_pcm_s16_to_u8__optimized(dst, src, count, ditherMode); } #endif MA_API void ma_pcm_s16_to_u8(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode) { #ifdef MA_USE_REFERENCE_CONVERSION_APIS ma_pcm_s16_to_u8__reference(dst, src, count, ditherMode); #else # if defined(MA_SUPPORT_SSE2) if (ma_has_sse2()) { ma_pcm_s16_to_u8__sse2(dst, src, count, ditherMode); } else #elif defined(MA_SUPPORT_NEON) if (ma_has_neon()) { ma_pcm_s16_to_u8__neon(dst, src, count, ditherMode); } else #endif { ma_pcm_s16_to_u8__optimized(dst, src, count, ditherMode); } #endif } MA_API void ma_pcm_s16_to_s16(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode) { (void)ditherMode; ma_copy_memory_64(dst, src, count * sizeof(ma_int16)); } static MA_INLINE void ma_pcm_s16_to_s24__reference(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode) { ma_uint8* dst_s24 = (ma_uint8*)dst; const ma_int16* src_s16 = (const ma_int16*)src; ma_uint64 i; for (i = 0; i < count; i += 1) { dst_s24[i*3+0] = 0; dst_s24[i*3+1] = (ma_uint8)(src_s16[i] & 0xFF); dst_s24[i*3+2] = (ma_uint8)(src_s16[i] >> 8); } (void)ditherMode; } static MA_INLINE void ma_pcm_s16_to_s24__optimized(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode) { ma_pcm_s16_to_s24__reference(dst, src, count, ditherMode); } #if defined(MA_SUPPORT_SSE2) static MA_INLINE void ma_pcm_s16_to_s24__sse2(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode) { ma_pcm_s16_to_s24__optimized(dst, src, count, ditherMode); } #endif #if defined(MA_SUPPORT_NEON) static MA_INLINE void ma_pcm_s16_to_s24__neon(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode) { ma_pcm_s16_to_s24__optimized(dst, src, count, ditherMode); } #endif MA_API void ma_pcm_s16_to_s24(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode) { #ifdef MA_USE_REFERENCE_CONVERSION_APIS ma_pcm_s16_to_s24__reference(dst, src, count, ditherMode); #else # if defined(MA_SUPPORT_SSE2) if (ma_has_sse2()) { ma_pcm_s16_to_s24__sse2(dst, src, count, ditherMode); } else #elif defined(MA_SUPPORT_NEON) if (ma_has_neon()) { ma_pcm_s16_to_s24__neon(dst, src, count, ditherMode); } else #endif { ma_pcm_s16_to_s24__optimized(dst, src, count, ditherMode); } #endif } static MA_INLINE void ma_pcm_s16_to_s32__reference(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode) { ma_int32* dst_s32 = (ma_int32*)dst; const ma_int16* src_s16 = (const ma_int16*)src; ma_uint64 i; for (i = 0; i < count; i += 1) { dst_s32[i] = src_s16[i] << 16; } (void)ditherMode; } static MA_INLINE void ma_pcm_s16_to_s32__optimized(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode) { ma_pcm_s16_to_s32__reference(dst, src, count, ditherMode); } #if defined(MA_SUPPORT_SSE2) static MA_INLINE void ma_pcm_s16_to_s32__sse2(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode) { ma_pcm_s16_to_s32__optimized(dst, src, count, ditherMode); } #endif #if defined(MA_SUPPORT_NEON) static MA_INLINE void ma_pcm_s16_to_s32__neon(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode) { ma_pcm_s16_to_s32__optimized(dst, src, count, ditherMode); } #endif MA_API void ma_pcm_s16_to_s32(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode) { #ifdef MA_USE_REFERENCE_CONVERSION_APIS ma_pcm_s16_to_s32__reference(dst, src, count, ditherMode); #else # if defined(MA_SUPPORT_SSE2) if (ma_has_sse2()) { ma_pcm_s16_to_s32__sse2(dst, src, count, ditherMode); } else #elif defined(MA_SUPPORT_NEON) if (ma_has_neon()) { ma_pcm_s16_to_s32__neon(dst, src, count, ditherMode); } else #endif { ma_pcm_s16_to_s32__optimized(dst, src, count, ditherMode); } #endif } static MA_INLINE void ma_pcm_s16_to_f32__reference(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode) { float* dst_f32 = (float*)dst; const ma_int16* src_s16 = (const ma_int16*)src; ma_uint64 i; for (i = 0; i < count; i += 1) { float x = (float)src_s16[i]; #if 0 /* The accurate way. */ x = x + 32768.0f; /* -32768..32767 to 0..65535 */ x = x * 0.00003051804379339284f; /* 0..65535 to 0..2 */ x = x - 1; /* 0..2 to -1..1 */ #else /* The fast way. */ x = x * 0.000030517578125f; /* -32768..32767 to -1..0.999969482421875 */ #endif dst_f32[i] = x; } (void)ditherMode; } static MA_INLINE void ma_pcm_s16_to_f32__optimized(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode) { ma_pcm_s16_to_f32__reference(dst, src, count, ditherMode); } #if defined(MA_SUPPORT_SSE2) static MA_INLINE void ma_pcm_s16_to_f32__sse2(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode) { ma_pcm_s16_to_f32__optimized(dst, src, count, ditherMode); } #endif #if defined(MA_SUPPORT_NEON) static MA_INLINE void ma_pcm_s16_to_f32__neon(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode) { ma_pcm_s16_to_f32__optimized(dst, src, count, ditherMode); } #endif MA_API void ma_pcm_s16_to_f32(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode) { #ifdef MA_USE_REFERENCE_CONVERSION_APIS ma_pcm_s16_to_f32__reference(dst, src, count, ditherMode); #else # if defined(MA_SUPPORT_SSE2) if (ma_has_sse2()) { ma_pcm_s16_to_f32__sse2(dst, src, count, ditherMode); } else #elif defined(MA_SUPPORT_NEON) if (ma_has_neon()) { ma_pcm_s16_to_f32__neon(dst, src, count, ditherMode); } else #endif { ma_pcm_s16_to_f32__optimized(dst, src, count, ditherMode); } #endif } static MA_INLINE void ma_pcm_interleave_s16__reference(void* dst, const void** src, ma_uint64 frameCount, ma_uint32 channels) { ma_int16* dst_s16 = (ma_int16*)dst; const ma_int16** src_s16 = (const ma_int16**)src; ma_uint64 iFrame; for (iFrame = 0; iFrame < frameCount; iFrame += 1) { ma_uint32 iChannel; for (iChannel = 0; iChannel < channels; iChannel += 1) { dst_s16[iFrame*channels + iChannel] = src_s16[iChannel][iFrame]; } } } static MA_INLINE void ma_pcm_interleave_s16__optimized(void* dst, const void** src, ma_uint64 frameCount, ma_uint32 channels) { ma_pcm_interleave_s16__reference(dst, src, frameCount, channels); } MA_API void ma_pcm_interleave_s16(void* dst, const void** src, ma_uint64 frameCount, ma_uint32 channels) { #ifdef MA_USE_REFERENCE_CONVERSION_APIS ma_pcm_interleave_s16__reference(dst, src, frameCount, channels); #else ma_pcm_interleave_s16__optimized(dst, src, frameCount, channels); #endif } static MA_INLINE void ma_pcm_deinterleave_s16__reference(void** dst, const void* src, ma_uint64 frameCount, ma_uint32 channels) { ma_int16** dst_s16 = (ma_int16**)dst; const ma_int16* src_s16 = (const ma_int16*)src; ma_uint64 iFrame; for (iFrame = 0; iFrame < frameCount; iFrame += 1) { ma_uint32 iChannel; for (iChannel = 0; iChannel < channels; iChannel += 1) { dst_s16[iChannel][iFrame] = src_s16[iFrame*channels + iChannel]; } } } static MA_INLINE void ma_pcm_deinterleave_s16__optimized(void** dst, const void* src, ma_uint64 frameCount, ma_uint32 channels) { ma_pcm_deinterleave_s16__reference(dst, src, frameCount, channels); } MA_API void ma_pcm_deinterleave_s16(void** dst, const void* src, ma_uint64 frameCount, ma_uint32 channels) { #ifdef MA_USE_REFERENCE_CONVERSION_APIS ma_pcm_deinterleave_s16__reference(dst, src, frameCount, channels); #else ma_pcm_deinterleave_s16__optimized(dst, src, frameCount, channels); #endif } /* s24 */ static MA_INLINE void ma_pcm_s24_to_u8__reference(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode) { ma_uint8* dst_u8 = (ma_uint8*)dst; const ma_uint8* src_s24 = (const ma_uint8*)src; if (ditherMode == ma_dither_mode_none) { ma_uint64 i; for (i = 0; i < count; i += 1) { dst_u8[i] = (ma_uint8)((ma_int8)src_s24[i*3 + 2] + 128); } } else { ma_uint64 i; for (i = 0; i < count; i += 1) { ma_int32 x = (ma_int32)(((ma_uint32)(src_s24[i*3+0]) << 8) | ((ma_uint32)(src_s24[i*3+1]) << 16) | ((ma_uint32)(src_s24[i*3+2])) << 24); /* Dither. Don't overflow. */ ma_int32 dither = ma_dither_s32(ditherMode, -0x800000, 0x7FFFFF); if ((ma_int64)x + dither <= 0x7FFFFFFF) { x = x + dither; } else { x = 0x7FFFFFFF; } x = x >> 24; x = x + 128; dst_u8[i] = (ma_uint8)x; } } } static MA_INLINE void ma_pcm_s24_to_u8__optimized(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode) { ma_pcm_s24_to_u8__reference(dst, src, count, ditherMode); } #if defined(MA_SUPPORT_SSE2) static MA_INLINE void ma_pcm_s24_to_u8__sse2(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode) { ma_pcm_s24_to_u8__optimized(dst, src, count, ditherMode); } #endif #if defined(MA_SUPPORT_NEON) static MA_INLINE void ma_pcm_s24_to_u8__neon(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode) { ma_pcm_s24_to_u8__optimized(dst, src, count, ditherMode); } #endif MA_API void ma_pcm_s24_to_u8(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode) { #ifdef MA_USE_REFERENCE_CONVERSION_APIS ma_pcm_s24_to_u8__reference(dst, src, count, ditherMode); #else # if defined(MA_SUPPORT_SSE2) if (ma_has_sse2()) { ma_pcm_s24_to_u8__sse2(dst, src, count, ditherMode); } else #elif defined(MA_SUPPORT_NEON) if (ma_has_neon()) { ma_pcm_s24_to_u8__neon(dst, src, count, ditherMode); } else #endif { ma_pcm_s24_to_u8__optimized(dst, src, count, ditherMode); } #endif } static MA_INLINE void ma_pcm_s24_to_s16__reference(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode) { ma_int16* dst_s16 = (ma_int16*)dst; const ma_uint8* src_s24 = (const ma_uint8*)src; if (ditherMode == ma_dither_mode_none) { ma_uint64 i; for (i = 0; i < count; i += 1) { ma_uint16 dst_lo = ((ma_uint16)src_s24[i*3 + 1]); ma_uint16 dst_hi = (ma_uint16)((ma_uint16)src_s24[i*3 + 2] << 8); dst_s16[i] = (ma_int16)(dst_lo | dst_hi); } } else { ma_uint64 i; for (i = 0; i < count; i += 1) { ma_int32 x = (ma_int32)(((ma_uint32)(src_s24[i*3+0]) << 8) | ((ma_uint32)(src_s24[i*3+1]) << 16) | ((ma_uint32)(src_s24[i*3+2])) << 24); /* Dither. Don't overflow. */ ma_int32 dither = ma_dither_s32(ditherMode, -0x8000, 0x7FFF); if ((ma_int64)x + dither <= 0x7FFFFFFF) { x = x + dither; } else { x = 0x7FFFFFFF; } x = x >> 16; dst_s16[i] = (ma_int16)x; } } } static MA_INLINE void ma_pcm_s24_to_s16__optimized(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode) { ma_pcm_s24_to_s16__reference(dst, src, count, ditherMode); } #if defined(MA_SUPPORT_SSE2) static MA_INLINE void ma_pcm_s24_to_s16__sse2(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode) { ma_pcm_s24_to_s16__optimized(dst, src, count, ditherMode); } #endif #if defined(MA_SUPPORT_NEON) static MA_INLINE void ma_pcm_s24_to_s16__neon(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode) { ma_pcm_s24_to_s16__optimized(dst, src, count, ditherMode); } #endif MA_API void ma_pcm_s24_to_s16(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode) { #ifdef MA_USE_REFERENCE_CONVERSION_APIS ma_pcm_s24_to_s16__reference(dst, src, count, ditherMode); #else # if defined(MA_SUPPORT_SSE2) if (ma_has_sse2()) { ma_pcm_s24_to_s16__sse2(dst, src, count, ditherMode); } else #elif defined(MA_SUPPORT_NEON) if (ma_has_neon()) { ma_pcm_s24_to_s16__neon(dst, src, count, ditherMode); } else #endif { ma_pcm_s24_to_s16__optimized(dst, src, count, ditherMode); } #endif } MA_API void ma_pcm_s24_to_s24(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode) { (void)ditherMode; ma_copy_memory_64(dst, src, count * 3); } static MA_INLINE void ma_pcm_s24_to_s32__reference(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode) { ma_int32* dst_s32 = (ma_int32*)dst; const ma_uint8* src_s24 = (const ma_uint8*)src; ma_uint64 i; for (i = 0; i < count; i += 1) { dst_s32[i] = (ma_int32)(((ma_uint32)(src_s24[i*3+0]) << 8) | ((ma_uint32)(src_s24[i*3+1]) << 16) | ((ma_uint32)(src_s24[i*3+2])) << 24); } (void)ditherMode; } static MA_INLINE void ma_pcm_s24_to_s32__optimized(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode) { ma_pcm_s24_to_s32__reference(dst, src, count, ditherMode); } #if defined(MA_SUPPORT_SSE2) static MA_INLINE void ma_pcm_s24_to_s32__sse2(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode) { ma_pcm_s24_to_s32__optimized(dst, src, count, ditherMode); } #endif #if defined(MA_SUPPORT_NEON) static MA_INLINE void ma_pcm_s24_to_s32__neon(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode) { ma_pcm_s24_to_s32__optimized(dst, src, count, ditherMode); } #endif MA_API void ma_pcm_s24_to_s32(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode) { #ifdef MA_USE_REFERENCE_CONVERSION_APIS ma_pcm_s24_to_s32__reference(dst, src, count, ditherMode); #else # if defined(MA_SUPPORT_SSE2) if (ma_has_sse2()) { ma_pcm_s24_to_s32__sse2(dst, src, count, ditherMode); } else #elif defined(MA_SUPPORT_NEON) if (ma_has_neon()) { ma_pcm_s24_to_s32__neon(dst, src, count, ditherMode); } else #endif { ma_pcm_s24_to_s32__optimized(dst, src, count, ditherMode); } #endif } static MA_INLINE void ma_pcm_s24_to_f32__reference(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode) { float* dst_f32 = (float*)dst; const ma_uint8* src_s24 = (const ma_uint8*)src; ma_uint64 i; for (i = 0; i < count; i += 1) { float x = (float)(((ma_int32)(((ma_uint32)(src_s24[i*3+0]) << 8) | ((ma_uint32)(src_s24[i*3+1]) << 16) | ((ma_uint32)(src_s24[i*3+2])) << 24)) >> 8); #if 0 /* The accurate way. */ x = x + 8388608.0f; /* -8388608..8388607 to 0..16777215 */ x = x * 0.00000011920929665621f; /* 0..16777215 to 0..2 */ x = x - 1; /* 0..2 to -1..1 */ #else /* The fast way. */ x = x * 0.00000011920928955078125f; /* -8388608..8388607 to -1..0.999969482421875 */ #endif dst_f32[i] = x; } (void)ditherMode; } static MA_INLINE void ma_pcm_s24_to_f32__optimized(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode) { ma_pcm_s24_to_f32__reference(dst, src, count, ditherMode); } #if defined(MA_SUPPORT_SSE2) static MA_INLINE void ma_pcm_s24_to_f32__sse2(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode) { ma_pcm_s24_to_f32__optimized(dst, src, count, ditherMode); } #endif #if defined(MA_SUPPORT_NEON) static MA_INLINE void ma_pcm_s24_to_f32__neon(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode) { ma_pcm_s24_to_f32__optimized(dst, src, count, ditherMode); } #endif MA_API void ma_pcm_s24_to_f32(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode) { #ifdef MA_USE_REFERENCE_CONVERSION_APIS ma_pcm_s24_to_f32__reference(dst, src, count, ditherMode); #else # if defined(MA_SUPPORT_SSE2) if (ma_has_sse2()) { ma_pcm_s24_to_f32__sse2(dst, src, count, ditherMode); } else #elif defined(MA_SUPPORT_NEON) if (ma_has_neon()) { ma_pcm_s24_to_f32__neon(dst, src, count, ditherMode); } else #endif { ma_pcm_s24_to_f32__optimized(dst, src, count, ditherMode); } #endif } static MA_INLINE void ma_pcm_interleave_s24__reference(void* dst, const void** src, ma_uint64 frameCount, ma_uint32 channels) { ma_uint8* dst8 = (ma_uint8*)dst; const ma_uint8** src8 = (const ma_uint8**)src; ma_uint64 iFrame; for (iFrame = 0; iFrame < frameCount; iFrame += 1) { ma_uint32 iChannel; for (iChannel = 0; iChannel < channels; iChannel += 1) { dst8[iFrame*3*channels + iChannel*3 + 0] = src8[iChannel][iFrame*3 + 0]; dst8[iFrame*3*channels + iChannel*3 + 1] = src8[iChannel][iFrame*3 + 1]; dst8[iFrame*3*channels + iChannel*3 + 2] = src8[iChannel][iFrame*3 + 2]; } } } static MA_INLINE void ma_pcm_interleave_s24__optimized(void* dst, const void** src, ma_uint64 frameCount, ma_uint32 channels) { ma_pcm_interleave_s24__reference(dst, src, frameCount, channels); } MA_API void ma_pcm_interleave_s24(void* dst, const void** src, ma_uint64 frameCount, ma_uint32 channels) { #ifdef MA_USE_REFERENCE_CONVERSION_APIS ma_pcm_interleave_s24__reference(dst, src, frameCount, channels); #else ma_pcm_interleave_s24__optimized(dst, src, frameCount, channels); #endif } static MA_INLINE void ma_pcm_deinterleave_s24__reference(void** dst, const void* src, ma_uint64 frameCount, ma_uint32 channels) { ma_uint8** dst8 = (ma_uint8**)dst; const ma_uint8* src8 = (const ma_uint8*)src; ma_uint32 iFrame; for (iFrame = 0; iFrame < frameCount; iFrame += 1) { ma_uint32 iChannel; for (iChannel = 0; iChannel < channels; iChannel += 1) { dst8[iChannel][iFrame*3 + 0] = src8[iFrame*3*channels + iChannel*3 + 0]; dst8[iChannel][iFrame*3 + 1] = src8[iFrame*3*channels + iChannel*3 + 1]; dst8[iChannel][iFrame*3 + 2] = src8[iFrame*3*channels + iChannel*3 + 2]; } } } static MA_INLINE void ma_pcm_deinterleave_s24__optimized(void** dst, const void* src, ma_uint64 frameCount, ma_uint32 channels) { ma_pcm_deinterleave_s24__reference(dst, src, frameCount, channels); } MA_API void ma_pcm_deinterleave_s24(void** dst, const void* src, ma_uint64 frameCount, ma_uint32 channels) { #ifdef MA_USE_REFERENCE_CONVERSION_APIS ma_pcm_deinterleave_s24__reference(dst, src, frameCount, channels); #else ma_pcm_deinterleave_s24__optimized(dst, src, frameCount, channels); #endif } /* s32 */ static MA_INLINE void ma_pcm_s32_to_u8__reference(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode) { ma_uint8* dst_u8 = (ma_uint8*)dst; const ma_int32* src_s32 = (const ma_int32*)src; if (ditherMode == ma_dither_mode_none) { ma_uint64 i; for (i = 0; i < count; i += 1) { ma_int32 x = src_s32[i]; x = x >> 24; x = x + 128; dst_u8[i] = (ma_uint8)x; } } else { ma_uint64 i; for (i = 0; i < count; i += 1) { ma_int32 x = src_s32[i]; /* Dither. Don't overflow. */ ma_int32 dither = ma_dither_s32(ditherMode, -0x800000, 0x7FFFFF); if ((ma_int64)x + dither <= 0x7FFFFFFF) { x = x + dither; } else { x = 0x7FFFFFFF; } x = x >> 24; x = x + 128; dst_u8[i] = (ma_uint8)x; } } } static MA_INLINE void ma_pcm_s32_to_u8__optimized(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode) { ma_pcm_s32_to_u8__reference(dst, src, count, ditherMode); } #if defined(MA_SUPPORT_SSE2) static MA_INLINE void ma_pcm_s32_to_u8__sse2(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode) { ma_pcm_s32_to_u8__optimized(dst, src, count, ditherMode); } #endif #if defined(MA_SUPPORT_NEON) static MA_INLINE void ma_pcm_s32_to_u8__neon(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode) { ma_pcm_s32_to_u8__optimized(dst, src, count, ditherMode); } #endif MA_API void ma_pcm_s32_to_u8(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode) { #ifdef MA_USE_REFERENCE_CONVERSION_APIS ma_pcm_s32_to_u8__reference(dst, src, count, ditherMode); #else # if defined(MA_SUPPORT_SSE2) if (ma_has_sse2()) { ma_pcm_s32_to_u8__sse2(dst, src, count, ditherMode); } else #elif defined(MA_SUPPORT_NEON) if (ma_has_neon()) { ma_pcm_s32_to_u8__neon(dst, src, count, ditherMode); } else #endif { ma_pcm_s32_to_u8__optimized(dst, src, count, ditherMode); } #endif } static MA_INLINE void ma_pcm_s32_to_s16__reference(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode) { ma_int16* dst_s16 = (ma_int16*)dst; const ma_int32* src_s32 = (const ma_int32*)src; if (ditherMode == ma_dither_mode_none) { ma_uint64 i; for (i = 0; i < count; i += 1) { ma_int32 x = src_s32[i]; x = x >> 16; dst_s16[i] = (ma_int16)x; } } else { ma_uint64 i; for (i = 0; i < count; i += 1) { ma_int32 x = src_s32[i]; /* Dither. Don't overflow. */ ma_int32 dither = ma_dither_s32(ditherMode, -0x8000, 0x7FFF); if ((ma_int64)x + dither <= 0x7FFFFFFF) { x = x + dither; } else { x = 0x7FFFFFFF; } x = x >> 16; dst_s16[i] = (ma_int16)x; } } } static MA_INLINE void ma_pcm_s32_to_s16__optimized(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode) { ma_pcm_s32_to_s16__reference(dst, src, count, ditherMode); } #if defined(MA_SUPPORT_SSE2) static MA_INLINE void ma_pcm_s32_to_s16__sse2(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode) { ma_pcm_s32_to_s16__optimized(dst, src, count, ditherMode); } #endif #if defined(MA_SUPPORT_NEON) static MA_INLINE void ma_pcm_s32_to_s16__neon(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode) { ma_pcm_s32_to_s16__optimized(dst, src, count, ditherMode); } #endif MA_API void ma_pcm_s32_to_s16(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode) { #ifdef MA_USE_REFERENCE_CONVERSION_APIS ma_pcm_s32_to_s16__reference(dst, src, count, ditherMode); #else # if defined(MA_SUPPORT_SSE2) if (ma_has_sse2()) { ma_pcm_s32_to_s16__sse2(dst, src, count, ditherMode); } else #elif defined(MA_SUPPORT_NEON) if (ma_has_neon()) { ma_pcm_s32_to_s16__neon(dst, src, count, ditherMode); } else #endif { ma_pcm_s32_to_s16__optimized(dst, src, count, ditherMode); } #endif } static MA_INLINE void ma_pcm_s32_to_s24__reference(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode) { ma_uint8* dst_s24 = (ma_uint8*)dst; const ma_int32* src_s32 = (const ma_int32*)src; ma_uint64 i; for (i = 0; i < count; i += 1) { ma_uint32 x = (ma_uint32)src_s32[i]; dst_s24[i*3+0] = (ma_uint8)((x & 0x0000FF00) >> 8); dst_s24[i*3+1] = (ma_uint8)((x & 0x00FF0000) >> 16); dst_s24[i*3+2] = (ma_uint8)((x & 0xFF000000) >> 24); } (void)ditherMode; /* No dithering for s32 -> s24. */ } static MA_INLINE void ma_pcm_s32_to_s24__optimized(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode) { ma_pcm_s32_to_s24__reference(dst, src, count, ditherMode); } #if defined(MA_SUPPORT_SSE2) static MA_INLINE void ma_pcm_s32_to_s24__sse2(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode) { ma_pcm_s32_to_s24__optimized(dst, src, count, ditherMode); } #endif #if defined(MA_SUPPORT_NEON) static MA_INLINE void ma_pcm_s32_to_s24__neon(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode) { ma_pcm_s32_to_s24__optimized(dst, src, count, ditherMode); } #endif MA_API void ma_pcm_s32_to_s24(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode) { #ifdef MA_USE_REFERENCE_CONVERSION_APIS ma_pcm_s32_to_s24__reference(dst, src, count, ditherMode); #else # if defined(MA_SUPPORT_SSE2) if (ma_has_sse2()) { ma_pcm_s32_to_s24__sse2(dst, src, count, ditherMode); } else #elif defined(MA_SUPPORT_NEON) if (ma_has_neon()) { ma_pcm_s32_to_s24__neon(dst, src, count, ditherMode); } else #endif { ma_pcm_s32_to_s24__optimized(dst, src, count, ditherMode); } #endif } MA_API void ma_pcm_s32_to_s32(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode) { (void)ditherMode; ma_copy_memory_64(dst, src, count * sizeof(ma_int32)); } static MA_INLINE void ma_pcm_s32_to_f32__reference(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode) { float* dst_f32 = (float*)dst; const ma_int32* src_s32 = (const ma_int32*)src; ma_uint64 i; for (i = 0; i < count; i += 1) { double x = src_s32[i]; #if 0 x = x + 2147483648.0; x = x * 0.0000000004656612873077392578125; x = x - 1; #else x = x / 2147483648.0; #endif dst_f32[i] = (float)x; } (void)ditherMode; /* No dithering for s32 -> f32. */ } static MA_INLINE void ma_pcm_s32_to_f32__optimized(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode) { ma_pcm_s32_to_f32__reference(dst, src, count, ditherMode); } #if defined(MA_SUPPORT_SSE2) static MA_INLINE void ma_pcm_s32_to_f32__sse2(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode) { ma_pcm_s32_to_f32__optimized(dst, src, count, ditherMode); } #endif #if defined(MA_SUPPORT_NEON) static MA_INLINE void ma_pcm_s32_to_f32__neon(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode) { ma_pcm_s32_to_f32__optimized(dst, src, count, ditherMode); } #endif MA_API void ma_pcm_s32_to_f32(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode) { #ifdef MA_USE_REFERENCE_CONVERSION_APIS ma_pcm_s32_to_f32__reference(dst, src, count, ditherMode); #else # if defined(MA_SUPPORT_SSE2) if (ma_has_sse2()) { ma_pcm_s32_to_f32__sse2(dst, src, count, ditherMode); } else #elif defined(MA_SUPPORT_NEON) if (ma_has_neon()) { ma_pcm_s32_to_f32__neon(dst, src, count, ditherMode); } else #endif { ma_pcm_s32_to_f32__optimized(dst, src, count, ditherMode); } #endif } static MA_INLINE void ma_pcm_interleave_s32__reference(void* dst, const void** src, ma_uint64 frameCount, ma_uint32 channels) { ma_int32* dst_s32 = (ma_int32*)dst; const ma_int32** src_s32 = (const ma_int32**)src; ma_uint64 iFrame; for (iFrame = 0; iFrame < frameCount; iFrame += 1) { ma_uint32 iChannel; for (iChannel = 0; iChannel < channels; iChannel += 1) { dst_s32[iFrame*channels + iChannel] = src_s32[iChannel][iFrame]; } } } static MA_INLINE void ma_pcm_interleave_s32__optimized(void* dst, const void** src, ma_uint64 frameCount, ma_uint32 channels) { ma_pcm_interleave_s32__reference(dst, src, frameCount, channels); } MA_API void ma_pcm_interleave_s32(void* dst, const void** src, ma_uint64 frameCount, ma_uint32 channels) { #ifdef MA_USE_REFERENCE_CONVERSION_APIS ma_pcm_interleave_s32__reference(dst, src, frameCount, channels); #else ma_pcm_interleave_s32__optimized(dst, src, frameCount, channels); #endif } static MA_INLINE void ma_pcm_deinterleave_s32__reference(void** dst, const void* src, ma_uint64 frameCount, ma_uint32 channels) { ma_int32** dst_s32 = (ma_int32**)dst; const ma_int32* src_s32 = (const ma_int32*)src; ma_uint64 iFrame; for (iFrame = 0; iFrame < frameCount; iFrame += 1) { ma_uint32 iChannel; for (iChannel = 0; iChannel < channels; iChannel += 1) { dst_s32[iChannel][iFrame] = src_s32[iFrame*channels + iChannel]; } } } static MA_INLINE void ma_pcm_deinterleave_s32__optimized(void** dst, const void* src, ma_uint64 frameCount, ma_uint32 channels) { ma_pcm_deinterleave_s32__reference(dst, src, frameCount, channels); } MA_API void ma_pcm_deinterleave_s32(void** dst, const void* src, ma_uint64 frameCount, ma_uint32 channels) { #ifdef MA_USE_REFERENCE_CONVERSION_APIS ma_pcm_deinterleave_s32__reference(dst, src, frameCount, channels); #else ma_pcm_deinterleave_s32__optimized(dst, src, frameCount, channels); #endif } /* f32 */ static MA_INLINE void ma_pcm_f32_to_u8__reference(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode) { ma_uint64 i; ma_uint8* dst_u8 = (ma_uint8*)dst; const float* src_f32 = (const float*)src; float ditherMin = 0; float ditherMax = 0; if (ditherMode != ma_dither_mode_none) { ditherMin = 1.0f / -128; ditherMax = 1.0f / 127; } for (i = 0; i < count; i += 1) { float x = src_f32[i]; x = x + ma_dither_f32(ditherMode, ditherMin, ditherMax); x = ((x < -1) ? -1 : ((x > 1) ? 1 : x)); /* clip */ x = x + 1; /* -1..1 to 0..2 */ x = x * 127.5f; /* 0..2 to 0..255 */ dst_u8[i] = (ma_uint8)x; } } static MA_INLINE void ma_pcm_f32_to_u8__optimized(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode) { ma_pcm_f32_to_u8__reference(dst, src, count, ditherMode); } #if defined(MA_SUPPORT_SSE2) static MA_INLINE void ma_pcm_f32_to_u8__sse2(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode) { ma_pcm_f32_to_u8__optimized(dst, src, count, ditherMode); } #endif #if defined(MA_SUPPORT_NEON) static MA_INLINE void ma_pcm_f32_to_u8__neon(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode) { ma_pcm_f32_to_u8__optimized(dst, src, count, ditherMode); } #endif MA_API void ma_pcm_f32_to_u8(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode) { #ifdef MA_USE_REFERENCE_CONVERSION_APIS ma_pcm_f32_to_u8__reference(dst, src, count, ditherMode); #else # if defined(MA_SUPPORT_SSE2) if (ma_has_sse2()) { ma_pcm_f32_to_u8__sse2(dst, src, count, ditherMode); } else #elif defined(MA_SUPPORT_NEON) if (ma_has_neon()) { ma_pcm_f32_to_u8__neon(dst, src, count, ditherMode); } else #endif { ma_pcm_f32_to_u8__optimized(dst, src, count, ditherMode); } #endif } #ifdef MA_USE_REFERENCE_CONVERSION_APIS static MA_INLINE void ma_pcm_f32_to_s16__reference(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode) { ma_uint64 i; ma_int16* dst_s16 = (ma_int16*)dst; const float* src_f32 = (const float*)src; float ditherMin = 0; float ditherMax = 0; if (ditherMode != ma_dither_mode_none) { ditherMin = 1.0f / -32768; ditherMax = 1.0f / 32767; } for (i = 0; i < count; i += 1) { float x = src_f32[i]; x = x + ma_dither_f32(ditherMode, ditherMin, ditherMax); x = ((x < -1) ? -1 : ((x > 1) ? 1 : x)); /* clip */ #if 0 /* The accurate way. */ x = x + 1; /* -1..1 to 0..2 */ x = x * 32767.5f; /* 0..2 to 0..65535 */ x = x - 32768.0f; /* 0...65535 to -32768..32767 */ #else /* The fast way. */ x = x * 32767.0f; /* -1..1 to -32767..32767 */ #endif dst_s16[i] = (ma_int16)x; } } #else static MA_INLINE void ma_pcm_f32_to_s16__optimized(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode) { ma_uint64 i; ma_uint64 i4; ma_uint64 count4; ma_int16* dst_s16 = (ma_int16*)dst; const float* src_f32 = (const float*)src; float ditherMin = 0; float ditherMax = 0; if (ditherMode != ma_dither_mode_none) { ditherMin = 1.0f / -32768; ditherMax = 1.0f / 32767; } /* Unrolled. */ i = 0; count4 = count >> 2; for (i4 = 0; i4 < count4; i4 += 1) { float d0 = ma_dither_f32(ditherMode, ditherMin, ditherMax); float d1 = ma_dither_f32(ditherMode, ditherMin, ditherMax); float d2 = ma_dither_f32(ditherMode, ditherMin, ditherMax); float d3 = ma_dither_f32(ditherMode, ditherMin, ditherMax); float x0 = src_f32[i+0]; float x1 = src_f32[i+1]; float x2 = src_f32[i+2]; float x3 = src_f32[i+3]; x0 = x0 + d0; x1 = x1 + d1; x2 = x2 + d2; x3 = x3 + d3; x0 = ((x0 < -1) ? -1 : ((x0 > 1) ? 1 : x0)); x1 = ((x1 < -1) ? -1 : ((x1 > 1) ? 1 : x1)); x2 = ((x2 < -1) ? -1 : ((x2 > 1) ? 1 : x2)); x3 = ((x3 < -1) ? -1 : ((x3 > 1) ? 1 : x3)); x0 = x0 * 32767.0f; x1 = x1 * 32767.0f; x2 = x2 * 32767.0f; x3 = x3 * 32767.0f; dst_s16[i+0] = (ma_int16)x0; dst_s16[i+1] = (ma_int16)x1; dst_s16[i+2] = (ma_int16)x2; dst_s16[i+3] = (ma_int16)x3; i += 4; } /* Leftover. */ for (; i < count; i += 1) { float x = src_f32[i]; x = x + ma_dither_f32(ditherMode, ditherMin, ditherMax); x = ((x < -1) ? -1 : ((x > 1) ? 1 : x)); /* clip */ x = x * 32767.0f; /* -1..1 to -32767..32767 */ dst_s16[i] = (ma_int16)x; } } #if defined(MA_SUPPORT_SSE2) static MA_INLINE void ma_pcm_f32_to_s16__sse2(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode) { ma_uint64 i; ma_uint64 i8; ma_uint64 count8; ma_int16* dst_s16; const float* src_f32; float ditherMin; float ditherMax; /* Both the input and output buffers need to be aligned to 16 bytes. */ if ((((ma_uintptr)dst & 15) != 0) || (((ma_uintptr)src & 15) != 0)) { ma_pcm_f32_to_s16__optimized(dst, src, count, ditherMode); return; } dst_s16 = (ma_int16*)dst; src_f32 = (const float*)src; ditherMin = 0; ditherMax = 0; if (ditherMode != ma_dither_mode_none) { ditherMin = 1.0f / -32768; ditherMax = 1.0f / 32767; } i = 0; /* SSE2. SSE allows us to output 8 s16's at a time which means our loop is unrolled 8 times. */ count8 = count >> 3; for (i8 = 0; i8 < count8; i8 += 1) { __m128 d0; __m128 d1; __m128 x0; __m128 x1; if (ditherMode == ma_dither_mode_none) { d0 = _mm_set1_ps(0); d1 = _mm_set1_ps(0); } else if (ditherMode == ma_dither_mode_rectangle) { d0 = _mm_set_ps( ma_dither_f32_rectangle(ditherMin, ditherMax), ma_dither_f32_rectangle(ditherMin, ditherMax), ma_dither_f32_rectangle(ditherMin, ditherMax), ma_dither_f32_rectangle(ditherMin, ditherMax) ); d1 = _mm_set_ps( ma_dither_f32_rectangle(ditherMin, ditherMax), ma_dither_f32_rectangle(ditherMin, ditherMax), ma_dither_f32_rectangle(ditherMin, ditherMax), ma_dither_f32_rectangle(ditherMin, ditherMax) ); } else { d0 = _mm_set_ps( ma_dither_f32_triangle(ditherMin, ditherMax), ma_dither_f32_triangle(ditherMin, ditherMax), ma_dither_f32_triangle(ditherMin, ditherMax), ma_dither_f32_triangle(ditherMin, ditherMax) ); d1 = _mm_set_ps( ma_dither_f32_triangle(ditherMin, ditherMax), ma_dither_f32_triangle(ditherMin, ditherMax), ma_dither_f32_triangle(ditherMin, ditherMax), ma_dither_f32_triangle(ditherMin, ditherMax) ); } x0 = *((__m128*)(src_f32 + i) + 0); x1 = *((__m128*)(src_f32 + i) + 1); x0 = _mm_add_ps(x0, d0); x1 = _mm_add_ps(x1, d1); x0 = _mm_mul_ps(x0, _mm_set1_ps(32767.0f)); x1 = _mm_mul_ps(x1, _mm_set1_ps(32767.0f)); _mm_stream_si128(((__m128i*)(dst_s16 + i)), _mm_packs_epi32(_mm_cvttps_epi32(x0), _mm_cvttps_epi32(x1))); i += 8; } /* Leftover. */ for (; i < count; i += 1) { float x = src_f32[i]; x = x + ma_dither_f32(ditherMode, ditherMin, ditherMax); x = ((x < -1) ? -1 : ((x > 1) ? 1 : x)); /* clip */ x = x * 32767.0f; /* -1..1 to -32767..32767 */ dst_s16[i] = (ma_int16)x; } } #endif /* SSE2 */ #if defined(MA_SUPPORT_NEON) static MA_INLINE void ma_pcm_f32_to_s16__neon(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode) { ma_uint64 i; ma_uint64 i8; ma_uint64 count8; ma_int16* dst_s16; const float* src_f32; float ditherMin; float ditherMax; if (!ma_has_neon()) { ma_pcm_f32_to_s16__optimized(dst, src, count, ditherMode); return; } /* Both the input and output buffers need to be aligned to 16 bytes. */ if ((((ma_uintptr)dst & 15) != 0) || (((ma_uintptr)src & 15) != 0)) { ma_pcm_f32_to_s16__optimized(dst, src, count, ditherMode); return; } dst_s16 = (ma_int16*)dst; src_f32 = (const float*)src; ditherMin = 0; ditherMax = 0; if (ditherMode != ma_dither_mode_none) { ditherMin = 1.0f / -32768; ditherMax = 1.0f / 32767; } i = 0; /* NEON. NEON allows us to output 8 s16's at a time which means our loop is unrolled 8 times. */ count8 = count >> 3; for (i8 = 0; i8 < count8; i8 += 1) { float32x4_t d0; float32x4_t d1; float32x4_t x0; float32x4_t x1; int32x4_t i0; int32x4_t i1; if (ditherMode == ma_dither_mode_none) { d0 = vmovq_n_f32(0); d1 = vmovq_n_f32(0); } else if (ditherMode == ma_dither_mode_rectangle) { float d0v[4]; float d1v[4]; d0v[0] = ma_dither_f32_rectangle(ditherMin, ditherMax); d0v[1] = ma_dither_f32_rectangle(ditherMin, ditherMax); d0v[2] = ma_dither_f32_rectangle(ditherMin, ditherMax); d0v[3] = ma_dither_f32_rectangle(ditherMin, ditherMax); d0 = vld1q_f32(d0v); d1v[0] = ma_dither_f32_rectangle(ditherMin, ditherMax); d1v[1] = ma_dither_f32_rectangle(ditherMin, ditherMax); d1v[2] = ma_dither_f32_rectangle(ditherMin, ditherMax); d1v[3] = ma_dither_f32_rectangle(ditherMin, ditherMax); d1 = vld1q_f32(d1v); } else { float d0v[4]; float d1v[4]; d0v[0] = ma_dither_f32_triangle(ditherMin, ditherMax); d0v[1] = ma_dither_f32_triangle(ditherMin, ditherMax); d0v[2] = ma_dither_f32_triangle(ditherMin, ditherMax); d0v[3] = ma_dither_f32_triangle(ditherMin, ditherMax); d0 = vld1q_f32(d0v); d1v[0] = ma_dither_f32_triangle(ditherMin, ditherMax); d1v[1] = ma_dither_f32_triangle(ditherMin, ditherMax); d1v[2] = ma_dither_f32_triangle(ditherMin, ditherMax); d1v[3] = ma_dither_f32_triangle(ditherMin, ditherMax); d1 = vld1q_f32(d1v); } x0 = *((float32x4_t*)(src_f32 + i) + 0); x1 = *((float32x4_t*)(src_f32 + i) + 1); x0 = vaddq_f32(x0, d0); x1 = vaddq_f32(x1, d1); x0 = vmulq_n_f32(x0, 32767.0f); x1 = vmulq_n_f32(x1, 32767.0f); i0 = vcvtq_s32_f32(x0); i1 = vcvtq_s32_f32(x1); *((int16x8_t*)(dst_s16 + i)) = vcombine_s16(vqmovn_s32(i0), vqmovn_s32(i1)); i += 8; } /* Leftover. */ for (; i < count; i += 1) { float x = src_f32[i]; x = x + ma_dither_f32(ditherMode, ditherMin, ditherMax); x = ((x < -1) ? -1 : ((x > 1) ? 1 : x)); /* clip */ x = x * 32767.0f; /* -1..1 to -32767..32767 */ dst_s16[i] = (ma_int16)x; } } #endif /* Neon */ #endif /* MA_USE_REFERENCE_CONVERSION_APIS */ MA_API void ma_pcm_f32_to_s16(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode) { #ifdef MA_USE_REFERENCE_CONVERSION_APIS ma_pcm_f32_to_s16__reference(dst, src, count, ditherMode); #else # if defined(MA_SUPPORT_SSE2) if (ma_has_sse2()) { ma_pcm_f32_to_s16__sse2(dst, src, count, ditherMode); } else #elif defined(MA_SUPPORT_NEON) if (ma_has_neon()) { ma_pcm_f32_to_s16__neon(dst, src, count, ditherMode); } else #endif { ma_pcm_f32_to_s16__optimized(dst, src, count, ditherMode); } #endif } static MA_INLINE void ma_pcm_f32_to_s24__reference(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode) { ma_uint8* dst_s24 = (ma_uint8*)dst; const float* src_f32 = (const float*)src; ma_uint64 i; for (i = 0; i < count; i += 1) { ma_int32 r; float x = src_f32[i]; x = ((x < -1) ? -1 : ((x > 1) ? 1 : x)); /* clip */ #if 0 /* The accurate way. */ x = x + 1; /* -1..1 to 0..2 */ x = x * 8388607.5f; /* 0..2 to 0..16777215 */ x = x - 8388608.0f; /* 0..16777215 to -8388608..8388607 */ #else /* The fast way. */ x = x * 8388607.0f; /* -1..1 to -8388607..8388607 */ #endif r = (ma_int32)x; dst_s24[(i*3)+0] = (ma_uint8)((r & 0x0000FF) >> 0); dst_s24[(i*3)+1] = (ma_uint8)((r & 0x00FF00) >> 8); dst_s24[(i*3)+2] = (ma_uint8)((r & 0xFF0000) >> 16); } (void)ditherMode; /* No dithering for f32 -> s24. */ } static MA_INLINE void ma_pcm_f32_to_s24__optimized(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode) { ma_pcm_f32_to_s24__reference(dst, src, count, ditherMode); } #if defined(MA_SUPPORT_SSE2) static MA_INLINE void ma_pcm_f32_to_s24__sse2(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode) { ma_pcm_f32_to_s24__optimized(dst, src, count, ditherMode); } #endif #if defined(MA_SUPPORT_NEON) static MA_INLINE void ma_pcm_f32_to_s24__neon(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode) { ma_pcm_f32_to_s24__optimized(dst, src, count, ditherMode); } #endif MA_API void ma_pcm_f32_to_s24(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode) { #ifdef MA_USE_REFERENCE_CONVERSION_APIS ma_pcm_f32_to_s24__reference(dst, src, count, ditherMode); #else # if defined(MA_SUPPORT_SSE2) if (ma_has_sse2()) { ma_pcm_f32_to_s24__sse2(dst, src, count, ditherMode); } else #elif defined(MA_SUPPORT_NEON) if (ma_has_neon()) { ma_pcm_f32_to_s24__neon(dst, src, count, ditherMode); } else #endif { ma_pcm_f32_to_s24__optimized(dst, src, count, ditherMode); } #endif } static MA_INLINE void ma_pcm_f32_to_s32__reference(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode) { ma_int32* dst_s32 = (ma_int32*)dst; const float* src_f32 = (const float*)src; ma_uint32 i; for (i = 0; i < count; i += 1) { double x = src_f32[i]; x = ((x < -1) ? -1 : ((x > 1) ? 1 : x)); /* clip */ #if 0 /* The accurate way. */ x = x + 1; /* -1..1 to 0..2 */ x = x * 2147483647.5; /* 0..2 to 0..4294967295 */ x = x - 2147483648.0; /* 0...4294967295 to -2147483648..2147483647 */ #else /* The fast way. */ x = x * 2147483647.0; /* -1..1 to -2147483647..2147483647 */ #endif dst_s32[i] = (ma_int32)x; } (void)ditherMode; /* No dithering for f32 -> s32. */ } static MA_INLINE void ma_pcm_f32_to_s32__optimized(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode) { ma_pcm_f32_to_s32__reference(dst, src, count, ditherMode); } #if defined(MA_SUPPORT_SSE2) static MA_INLINE void ma_pcm_f32_to_s32__sse2(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode) { ma_pcm_f32_to_s32__optimized(dst, src, count, ditherMode); } #endif #if defined(MA_SUPPORT_NEON) static MA_INLINE void ma_pcm_f32_to_s32__neon(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode) { ma_pcm_f32_to_s32__optimized(dst, src, count, ditherMode); } #endif MA_API void ma_pcm_f32_to_s32(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode) { #ifdef MA_USE_REFERENCE_CONVERSION_APIS ma_pcm_f32_to_s32__reference(dst, src, count, ditherMode); #else # if defined(MA_SUPPORT_SSE2) if (ma_has_sse2()) { ma_pcm_f32_to_s32__sse2(dst, src, count, ditherMode); } else #elif defined(MA_SUPPORT_NEON) if (ma_has_neon()) { ma_pcm_f32_to_s32__neon(dst, src, count, ditherMode); } else #endif { ma_pcm_f32_to_s32__optimized(dst, src, count, ditherMode); } #endif } MA_API void ma_pcm_f32_to_f32(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode) { (void)ditherMode; ma_copy_memory_64(dst, src, count * sizeof(float)); } static void ma_pcm_interleave_f32__reference(void* dst, const void** src, ma_uint64 frameCount, ma_uint32 channels) { float* dst_f32 = (float*)dst; const float** src_f32 = (const float**)src; ma_uint64 iFrame; for (iFrame = 0; iFrame < frameCount; iFrame += 1) { ma_uint32 iChannel; for (iChannel = 0; iChannel < channels; iChannel += 1) { dst_f32[iFrame*channels + iChannel] = src_f32[iChannel][iFrame]; } } } static void ma_pcm_interleave_f32__optimized(void* dst, const void** src, ma_uint64 frameCount, ma_uint32 channels) { ma_pcm_interleave_f32__reference(dst, src, frameCount, channels); } MA_API void ma_pcm_interleave_f32(void* dst, const void** src, ma_uint64 frameCount, ma_uint32 channels) { #ifdef MA_USE_REFERENCE_CONVERSION_APIS ma_pcm_interleave_f32__reference(dst, src, frameCount, channels); #else ma_pcm_interleave_f32__optimized(dst, src, frameCount, channels); #endif } static void ma_pcm_deinterleave_f32__reference(void** dst, const void* src, ma_uint64 frameCount, ma_uint32 channels) { float** dst_f32 = (float**)dst; const float* src_f32 = (const float*)src; ma_uint64 iFrame; for (iFrame = 0; iFrame < frameCount; iFrame += 1) { ma_uint32 iChannel; for (iChannel = 0; iChannel < channels; iChannel += 1) { dst_f32[iChannel][iFrame] = src_f32[iFrame*channels + iChannel]; } } } static void ma_pcm_deinterleave_f32__optimized(void** dst, const void* src, ma_uint64 frameCount, ma_uint32 channels) { ma_pcm_deinterleave_f32__reference(dst, src, frameCount, channels); } MA_API void ma_pcm_deinterleave_f32(void** dst, const void* src, ma_uint64 frameCount, ma_uint32 channels) { #ifdef MA_USE_REFERENCE_CONVERSION_APIS ma_pcm_deinterleave_f32__reference(dst, src, frameCount, channels); #else ma_pcm_deinterleave_f32__optimized(dst, src, frameCount, channels); #endif } MA_API void ma_pcm_convert(void* pOut, ma_format formatOut, const void* pIn, ma_format formatIn, ma_uint64 sampleCount, ma_dither_mode ditherMode) { if (formatOut == formatIn) { ma_copy_memory_64(pOut, pIn, sampleCount * ma_get_bytes_per_sample(formatOut)); return; } switch (formatIn) { case ma_format_u8: { switch (formatOut) { case ma_format_s16: ma_pcm_u8_to_s16(pOut, pIn, sampleCount, ditherMode); return; case ma_format_s24: ma_pcm_u8_to_s24(pOut, pIn, sampleCount, ditherMode); return; case ma_format_s32: ma_pcm_u8_to_s32(pOut, pIn, sampleCount, ditherMode); return; case ma_format_f32: ma_pcm_u8_to_f32(pOut, pIn, sampleCount, ditherMode); return; default: break; } } break; case ma_format_s16: { switch (formatOut) { case ma_format_u8: ma_pcm_s16_to_u8( pOut, pIn, sampleCount, ditherMode); return; case ma_format_s24: ma_pcm_s16_to_s24(pOut, pIn, sampleCount, ditherMode); return; case ma_format_s32: ma_pcm_s16_to_s32(pOut, pIn, sampleCount, ditherMode); return; case ma_format_f32: ma_pcm_s16_to_f32(pOut, pIn, sampleCount, ditherMode); return; default: break; } } break; case ma_format_s24: { switch (formatOut) { case ma_format_u8: ma_pcm_s24_to_u8( pOut, pIn, sampleCount, ditherMode); return; case ma_format_s16: ma_pcm_s24_to_s16(pOut, pIn, sampleCount, ditherMode); return; case ma_format_s32: ma_pcm_s24_to_s32(pOut, pIn, sampleCount, ditherMode); return; case ma_format_f32: ma_pcm_s24_to_f32(pOut, pIn, sampleCount, ditherMode); return; default: break; } } break; case ma_format_s32: { switch (formatOut) { case ma_format_u8: ma_pcm_s32_to_u8( pOut, pIn, sampleCount, ditherMode); return; case ma_format_s16: ma_pcm_s32_to_s16(pOut, pIn, sampleCount, ditherMode); return; case ma_format_s24: ma_pcm_s32_to_s24(pOut, pIn, sampleCount, ditherMode); return; case ma_format_f32: ma_pcm_s32_to_f32(pOut, pIn, sampleCount, ditherMode); return; default: break; } } break; case ma_format_f32: { switch (formatOut) { case ma_format_u8: ma_pcm_f32_to_u8( pOut, pIn, sampleCount, ditherMode); return; case ma_format_s16: ma_pcm_f32_to_s16(pOut, pIn, sampleCount, ditherMode); return; case ma_format_s24: ma_pcm_f32_to_s24(pOut, pIn, sampleCount, ditherMode); return; case ma_format_s32: ma_pcm_f32_to_s32(pOut, pIn, sampleCount, ditherMode); return; default: break; } } break; default: break; } } MA_API void ma_convert_pcm_frames_format(void* pOut, ma_format formatOut, const void* pIn, ma_format formatIn, ma_uint64 frameCount, ma_uint32 channels, ma_dither_mode ditherMode) { ma_pcm_convert(pOut, formatOut, pIn, formatIn, frameCount * channels, ditherMode); } MA_API void ma_deinterleave_pcm_frames(ma_format format, ma_uint32 channels, ma_uint64 frameCount, const void* pInterleavedPCMFrames, void** ppDeinterleavedPCMFrames) { if (pInterleavedPCMFrames == NULL || ppDeinterleavedPCMFrames == NULL) { return; /* Invalid args. */ } /* For efficiency we do this per format. */ switch (format) { case ma_format_s16: { const ma_int16* pSrcS16 = (const ma_int16*)pInterleavedPCMFrames; ma_uint64 iPCMFrame; for (iPCMFrame = 0; iPCMFrame < frameCount; ++iPCMFrame) { ma_uint32 iChannel; for (iChannel = 0; iChannel < channels; ++iChannel) { ma_int16* pDstS16 = (ma_int16*)ppDeinterleavedPCMFrames[iChannel]; pDstS16[iPCMFrame] = pSrcS16[iPCMFrame*channels+iChannel]; } } } break; case ma_format_f32: { const float* pSrcF32 = (const float*)pInterleavedPCMFrames; ma_uint64 iPCMFrame; for (iPCMFrame = 0; iPCMFrame < frameCount; ++iPCMFrame) { ma_uint32 iChannel; for (iChannel = 0; iChannel < channels; ++iChannel) { float* pDstF32 = (float*)ppDeinterleavedPCMFrames[iChannel]; pDstF32[iPCMFrame] = pSrcF32[iPCMFrame*channels+iChannel]; } } } break; default: { ma_uint32 sampleSizeInBytes = ma_get_bytes_per_sample(format); ma_uint64 iPCMFrame; for (iPCMFrame = 0; iPCMFrame < frameCount; ++iPCMFrame) { ma_uint32 iChannel; for (iChannel = 0; iChannel < channels; ++iChannel) { void* pDst = ma_offset_ptr(ppDeinterleavedPCMFrames[iChannel], iPCMFrame*sampleSizeInBytes); const void* pSrc = ma_offset_ptr(pInterleavedPCMFrames, (iPCMFrame*channels+iChannel)*sampleSizeInBytes); memcpy(pDst, pSrc, sampleSizeInBytes); } } } break; } } MA_API void ma_interleave_pcm_frames(ma_format format, ma_uint32 channels, ma_uint64 frameCount, const void** ppDeinterleavedPCMFrames, void* pInterleavedPCMFrames) { switch (format) { case ma_format_s16: { ma_int16* pDstS16 = (ma_int16*)pInterleavedPCMFrames; ma_uint64 iPCMFrame; for (iPCMFrame = 0; iPCMFrame < frameCount; ++iPCMFrame) { ma_uint32 iChannel; for (iChannel = 0; iChannel < channels; ++iChannel) { const ma_int16* pSrcS16 = (const ma_int16*)ppDeinterleavedPCMFrames[iChannel]; pDstS16[iPCMFrame*channels+iChannel] = pSrcS16[iPCMFrame]; } } } break; case ma_format_f32: { float* pDstF32 = (float*)pInterleavedPCMFrames; ma_uint64 iPCMFrame; for (iPCMFrame = 0; iPCMFrame < frameCount; ++iPCMFrame) { ma_uint32 iChannel; for (iChannel = 0; iChannel < channels; ++iChannel) { const float* pSrcF32 = (const float*)ppDeinterleavedPCMFrames[iChannel]; pDstF32[iPCMFrame*channels+iChannel] = pSrcF32[iPCMFrame]; } } } break; default: { ma_uint32 sampleSizeInBytes = ma_get_bytes_per_sample(format); ma_uint64 iPCMFrame; for (iPCMFrame = 0; iPCMFrame < frameCount; ++iPCMFrame) { ma_uint32 iChannel; for (iChannel = 0; iChannel < channels; ++iChannel) { void* pDst = ma_offset_ptr(pInterleavedPCMFrames, (iPCMFrame*channels+iChannel)*sampleSizeInBytes); const void* pSrc = ma_offset_ptr(ppDeinterleavedPCMFrames[iChannel], iPCMFrame*sampleSizeInBytes); memcpy(pDst, pSrc, sampleSizeInBytes); } } } break; } } /************************************************************************************************************************************************************** Biquad Filter **************************************************************************************************************************************************************/ #ifndef MA_BIQUAD_FIXED_POINT_SHIFT #define MA_BIQUAD_FIXED_POINT_SHIFT 14 #endif static ma_int32 ma_biquad_float_to_fp(double x) { return (ma_int32)(x * (1 << MA_BIQUAD_FIXED_POINT_SHIFT)); } MA_API ma_biquad_config ma_biquad_config_init(ma_format format, ma_uint32 channels, double b0, double b1, double b2, double a0, double a1, double a2) { ma_biquad_config config; MA_ZERO_OBJECT(&config); config.format = format; config.channels = channels; config.b0 = b0; config.b1 = b1; config.b2 = b2; config.a0 = a0; config.a1 = a1; config.a2 = a2; return config; } typedef struct { size_t sizeInBytes; size_t r1Offset; size_t r2Offset; } ma_biquad_heap_layout; static ma_result ma_biquad_get_heap_layout(const ma_biquad_config* pConfig, ma_biquad_heap_layout* pHeapLayout) { MA_ASSERT(pHeapLayout != NULL); MA_ZERO_OBJECT(pHeapLayout); if (pConfig == NULL) { return MA_INVALID_ARGS; } if (pConfig->channels == 0) { return MA_INVALID_ARGS; } pHeapLayout->sizeInBytes = 0; /* R0 */ pHeapLayout->r1Offset = pHeapLayout->sizeInBytes; pHeapLayout->sizeInBytes += sizeof(ma_biquad_coefficient) * pConfig->channels; /* R1 */ pHeapLayout->r2Offset = pHeapLayout->sizeInBytes; pHeapLayout->sizeInBytes += sizeof(ma_biquad_coefficient) * pConfig->channels; /* Make sure allocation size is aligned. */ pHeapLayout->sizeInBytes = ma_align_64(pHeapLayout->sizeInBytes); return MA_SUCCESS; } MA_API ma_result ma_biquad_get_heap_size(const ma_biquad_config* pConfig, size_t* pHeapSizeInBytes) { ma_result result; ma_biquad_heap_layout heapLayout; if (pHeapSizeInBytes == NULL) { return MA_INVALID_ARGS; } *pHeapSizeInBytes = 0; result = ma_biquad_get_heap_layout(pConfig, &heapLayout); if (result != MA_SUCCESS) { return result; } *pHeapSizeInBytes = heapLayout.sizeInBytes; return MA_SUCCESS; } MA_API ma_result ma_biquad_init_preallocated(const ma_biquad_config* pConfig, void* pHeap, ma_biquad* pBQ) { ma_result result; ma_biquad_heap_layout heapLayout; if (pBQ == NULL) { return MA_INVALID_ARGS; } MA_ZERO_OBJECT(pBQ); result = ma_biquad_get_heap_layout(pConfig, &heapLayout); if (result != MA_SUCCESS) { return result; } pBQ->_pHeap = pHeap; MA_ZERO_MEMORY(pHeap, heapLayout.sizeInBytes); pBQ->pR1 = (ma_biquad_coefficient*)ma_offset_ptr(pHeap, heapLayout.r1Offset); pBQ->pR2 = (ma_biquad_coefficient*)ma_offset_ptr(pHeap, heapLayout.r2Offset); return ma_biquad_reinit(pConfig, pBQ); } MA_API ma_result ma_biquad_init(const ma_biquad_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_biquad* pBQ) { ma_result result; size_t heapSizeInBytes; void* pHeap; result = ma_biquad_get_heap_size(pConfig, &heapSizeInBytes); if (result != MA_SUCCESS) { return result; } if (heapSizeInBytes > 0) { pHeap = ma_malloc(heapSizeInBytes, pAllocationCallbacks); if (pHeap == NULL) { return MA_OUT_OF_MEMORY; } } else { pHeap = NULL; } result = ma_biquad_init_preallocated(pConfig, pHeap, pBQ); if (result != MA_SUCCESS) { ma_free(pHeap, pAllocationCallbacks); return result; } pBQ->_ownsHeap = MA_TRUE; return MA_SUCCESS; } MA_API void ma_biquad_uninit(ma_biquad* pBQ, const ma_allocation_callbacks* pAllocationCallbacks) { if (pBQ == NULL) { return; } if (pBQ->_ownsHeap) { ma_free(pBQ->_pHeap, pAllocationCallbacks); } } MA_API ma_result ma_biquad_reinit(const ma_biquad_config* pConfig, ma_biquad* pBQ) { if (pBQ == NULL || pConfig == NULL) { return MA_INVALID_ARGS; } if (pConfig->a0 == 0) { return MA_INVALID_ARGS; /* Division by zero. */ } /* Only supporting f32 and s16. */ if (pConfig->format != ma_format_f32 && pConfig->format != ma_format_s16) { return MA_INVALID_ARGS; } /* The format cannot be changed after initialization. */ if (pBQ->format != ma_format_unknown && pBQ->format != pConfig->format) { return MA_INVALID_OPERATION; } /* The channel count cannot be changed after initialization. */ if (pBQ->channels != 0 && pBQ->channels != pConfig->channels) { return MA_INVALID_OPERATION; } pBQ->format = pConfig->format; pBQ->channels = pConfig->channels; /* Normalize. */ if (pConfig->format == ma_format_f32) { pBQ->b0.f32 = (float)(pConfig->b0 / pConfig->a0); pBQ->b1.f32 = (float)(pConfig->b1 / pConfig->a0); pBQ->b2.f32 = (float)(pConfig->b2 / pConfig->a0); pBQ->a1.f32 = (float)(pConfig->a1 / pConfig->a0); pBQ->a2.f32 = (float)(pConfig->a2 / pConfig->a0); } else { pBQ->b0.s32 = ma_biquad_float_to_fp(pConfig->b0 / pConfig->a0); pBQ->b1.s32 = ma_biquad_float_to_fp(pConfig->b1 / pConfig->a0); pBQ->b2.s32 = ma_biquad_float_to_fp(pConfig->b2 / pConfig->a0); pBQ->a1.s32 = ma_biquad_float_to_fp(pConfig->a1 / pConfig->a0); pBQ->a2.s32 = ma_biquad_float_to_fp(pConfig->a2 / pConfig->a0); } return MA_SUCCESS; } MA_API ma_result ma_biquad_clear_cache(ma_biquad* pBQ) { if (pBQ == NULL) { return MA_INVALID_ARGS; } if (pBQ->format == ma_format_f32) { pBQ->pR1->f32 = 0; pBQ->pR2->f32 = 0; } else { pBQ->pR1->s32 = 0; pBQ->pR2->s32 = 0; } return MA_SUCCESS; } static MA_INLINE void ma_biquad_process_pcm_frame_f32__direct_form_2_transposed(ma_biquad* pBQ, float* pY, const float* pX) { ma_uint32 c; const ma_uint32 channels = pBQ->channels; const float b0 = pBQ->b0.f32; const float b1 = pBQ->b1.f32; const float b2 = pBQ->b2.f32; const float a1 = pBQ->a1.f32; const float a2 = pBQ->a2.f32; MA_ASSUME(channels > 0); for (c = 0; c < channels; c += 1) { float r1 = pBQ->pR1[c].f32; float r2 = pBQ->pR2[c].f32; float x = pX[c]; float y; y = b0*x + r1; r1 = b1*x - a1*y + r2; r2 = b2*x - a2*y; pY[c] = y; pBQ->pR1[c].f32 = r1; pBQ->pR2[c].f32 = r2; } } static MA_INLINE void ma_biquad_process_pcm_frame_f32(ma_biquad* pBQ, float* pY, const float* pX) { ma_biquad_process_pcm_frame_f32__direct_form_2_transposed(pBQ, pY, pX); } static MA_INLINE void ma_biquad_process_pcm_frame_s16__direct_form_2_transposed(ma_biquad* pBQ, ma_int16* pY, const ma_int16* pX) { ma_uint32 c; const ma_uint32 channels = pBQ->channels; const ma_int32 b0 = pBQ->b0.s32; const ma_int32 b1 = pBQ->b1.s32; const ma_int32 b2 = pBQ->b2.s32; const ma_int32 a1 = pBQ->a1.s32; const ma_int32 a2 = pBQ->a2.s32; MA_ASSUME(channels > 0); for (c = 0; c < channels; c += 1) { ma_int32 r1 = pBQ->pR1[c].s32; ma_int32 r2 = pBQ->pR2[c].s32; ma_int32 x = pX[c]; ma_int32 y; y = (b0*x + r1) >> MA_BIQUAD_FIXED_POINT_SHIFT; r1 = (b1*x - a1*y + r2); r2 = (b2*x - a2*y); pY[c] = (ma_int16)ma_clamp(y, -32768, 32767); pBQ->pR1[c].s32 = r1; pBQ->pR2[c].s32 = r2; } } static MA_INLINE void ma_biquad_process_pcm_frame_s16(ma_biquad* pBQ, ma_int16* pY, const ma_int16* pX) { ma_biquad_process_pcm_frame_s16__direct_form_2_transposed(pBQ, pY, pX); } MA_API ma_result ma_biquad_process_pcm_frames(ma_biquad* pBQ, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount) { ma_uint32 n; if (pBQ == NULL || pFramesOut == NULL || pFramesIn == NULL) { return MA_INVALID_ARGS; } /* Note that the logic below needs to support in-place filtering. That is, it must support the case where pFramesOut and pFramesIn are the same. */ if (pBQ->format == ma_format_f32) { /* */ float* pY = ( float*)pFramesOut; const float* pX = (const float*)pFramesIn; for (n = 0; n < frameCount; n += 1) { ma_biquad_process_pcm_frame_f32__direct_form_2_transposed(pBQ, pY, pX); pY += pBQ->channels; pX += pBQ->channels; } } else if (pBQ->format == ma_format_s16) { /* */ ma_int16* pY = ( ma_int16*)pFramesOut; const ma_int16* pX = (const ma_int16*)pFramesIn; for (n = 0; n < frameCount; n += 1) { ma_biquad_process_pcm_frame_s16__direct_form_2_transposed(pBQ, pY, pX); pY += pBQ->channels; pX += pBQ->channels; } } else { MA_ASSERT(MA_FALSE); return MA_INVALID_ARGS; /* Format not supported. Should never hit this because it's checked in ma_biquad_init() and ma_biquad_reinit(). */ } return MA_SUCCESS; } MA_API ma_uint32 ma_biquad_get_latency(const ma_biquad* pBQ) { if (pBQ == NULL) { return 0; } return 2; } /************************************************************************************************************************************************************** Low-Pass Filter **************************************************************************************************************************************************************/ MA_API ma_lpf1_config ma_lpf1_config_init(ma_format format, ma_uint32 channels, ma_uint32 sampleRate, double cutoffFrequency) { ma_lpf1_config config; MA_ZERO_OBJECT(&config); config.format = format; config.channels = channels; config.sampleRate = sampleRate; config.cutoffFrequency = cutoffFrequency; config.q = 0.5; return config; } MA_API ma_lpf2_config ma_lpf2_config_init(ma_format format, ma_uint32 channels, ma_uint32 sampleRate, double cutoffFrequency, double q) { ma_lpf2_config config; MA_ZERO_OBJECT(&config); config.format = format; config.channels = channels; config.sampleRate = sampleRate; config.cutoffFrequency = cutoffFrequency; config.q = q; /* Q cannot be 0 or else it'll result in a division by 0. In this case just default to 0.707107. */ if (config.q == 0) { config.q = 0.707107; } return config; } typedef struct { size_t sizeInBytes; size_t r1Offset; } ma_lpf1_heap_layout; static ma_result ma_lpf1_get_heap_layout(const ma_lpf1_config* pConfig, ma_lpf1_heap_layout* pHeapLayout) { MA_ASSERT(pHeapLayout != NULL); MA_ZERO_OBJECT(pHeapLayout); if (pConfig == NULL) { return MA_INVALID_ARGS; } if (pConfig->channels == 0) { return MA_INVALID_ARGS; } pHeapLayout->sizeInBytes = 0; /* R1 */ pHeapLayout->r1Offset = pHeapLayout->sizeInBytes; pHeapLayout->sizeInBytes += sizeof(ma_biquad_coefficient) * pConfig->channels; /* Make sure allocation size is aligned. */ pHeapLayout->sizeInBytes = ma_align_64(pHeapLayout->sizeInBytes); return MA_SUCCESS; } MA_API ma_result ma_lpf1_get_heap_size(const ma_lpf1_config* pConfig, size_t* pHeapSizeInBytes) { ma_result result; ma_lpf1_heap_layout heapLayout; if (pHeapSizeInBytes == NULL) { return MA_INVALID_ARGS; } result = ma_lpf1_get_heap_layout(pConfig, &heapLayout); if (result != MA_SUCCESS) { return result; } *pHeapSizeInBytes = heapLayout.sizeInBytes; return MA_SUCCESS; } MA_API ma_result ma_lpf1_init_preallocated(const ma_lpf1_config* pConfig, void* pHeap, ma_lpf1* pLPF) { ma_result result; ma_lpf1_heap_layout heapLayout; if (pLPF == NULL) { return MA_INVALID_ARGS; } MA_ZERO_OBJECT(pLPF); result = ma_lpf1_get_heap_layout(pConfig, &heapLayout); if (result != MA_SUCCESS) { return result; } pLPF->_pHeap = pHeap; MA_ZERO_MEMORY(pHeap, heapLayout.sizeInBytes); pLPF->pR1 = (ma_biquad_coefficient*)ma_offset_ptr(pHeap, heapLayout.r1Offset); return ma_lpf1_reinit(pConfig, pLPF); } MA_API ma_result ma_lpf1_init(const ma_lpf1_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_lpf1* pLPF) { ma_result result; size_t heapSizeInBytes; void* pHeap; result = ma_lpf1_get_heap_size(pConfig, &heapSizeInBytes); if (result != MA_SUCCESS) { return result; } if (heapSizeInBytes > 0) { pHeap = ma_malloc(heapSizeInBytes, pAllocationCallbacks); if (pHeap == NULL) { return MA_OUT_OF_MEMORY; } } else { pHeap = NULL; } result = ma_lpf1_init_preallocated(pConfig, pHeap, pLPF); if (result != MA_SUCCESS) { ma_free(pHeap, pAllocationCallbacks); return result; } pLPF->_ownsHeap = MA_TRUE; return MA_SUCCESS; } MA_API void ma_lpf1_uninit(ma_lpf1* pLPF, const ma_allocation_callbacks* pAllocationCallbacks) { if (pLPF == NULL) { return; } if (pLPF->_ownsHeap) { ma_free(pLPF->_pHeap, pAllocationCallbacks); } } MA_API ma_result ma_lpf1_reinit(const ma_lpf1_config* pConfig, ma_lpf1* pLPF) { double a; if (pLPF == NULL || pConfig == NULL) { return MA_INVALID_ARGS; } /* Only supporting f32 and s16. */ if (pConfig->format != ma_format_f32 && pConfig->format != ma_format_s16) { return MA_INVALID_ARGS; } /* The format cannot be changed after initialization. */ if (pLPF->format != ma_format_unknown && pLPF->format != pConfig->format) { return MA_INVALID_OPERATION; } /* The channel count cannot be changed after initialization. */ if (pLPF->channels != 0 && pLPF->channels != pConfig->channels) { return MA_INVALID_OPERATION; } pLPF->format = pConfig->format; pLPF->channels = pConfig->channels; a = ma_expd(-2 * MA_PI_D * pConfig->cutoffFrequency / pConfig->sampleRate); if (pConfig->format == ma_format_f32) { pLPF->a.f32 = (float)a; } else { pLPF->a.s32 = ma_biquad_float_to_fp(a); } return MA_SUCCESS; } MA_API ma_result ma_lpf1_clear_cache(ma_lpf1* pLPF) { if (pLPF == NULL) { return MA_INVALID_ARGS; } if (pLPF->format == ma_format_f32) { pLPF->a.f32 = 0; } else { pLPF->a.s32 = 0; } return MA_SUCCESS; } static MA_INLINE void ma_lpf1_process_pcm_frame_f32(ma_lpf1* pLPF, float* pY, const float* pX) { ma_uint32 c; const ma_uint32 channels = pLPF->channels; const float a = pLPF->a.f32; const float b = 1 - a; MA_ASSUME(channels > 0); for (c = 0; c < channels; c += 1) { float r1 = pLPF->pR1[c].f32; float x = pX[c]; float y; y = b*x + a*r1; pY[c] = y; pLPF->pR1[c].f32 = y; } } static MA_INLINE void ma_lpf1_process_pcm_frame_s16(ma_lpf1* pLPF, ma_int16* pY, const ma_int16* pX) { ma_uint32 c; const ma_uint32 channels = pLPF->channels; const ma_int32 a = pLPF->a.s32; const ma_int32 b = ((1 << MA_BIQUAD_FIXED_POINT_SHIFT) - a); MA_ASSUME(channels > 0); for (c = 0; c < channels; c += 1) { ma_int32 r1 = pLPF->pR1[c].s32; ma_int32 x = pX[c]; ma_int32 y; y = (b*x + a*r1) >> MA_BIQUAD_FIXED_POINT_SHIFT; pY[c] = (ma_int16)y; pLPF->pR1[c].s32 = (ma_int32)y; } } MA_API ma_result ma_lpf1_process_pcm_frames(ma_lpf1* pLPF, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount) { ma_uint32 n; if (pLPF == NULL || pFramesOut == NULL || pFramesIn == NULL) { return MA_INVALID_ARGS; } /* Note that the logic below needs to support in-place filtering. That is, it must support the case where pFramesOut and pFramesIn are the same. */ if (pLPF->format == ma_format_f32) { /* */ float* pY = ( float*)pFramesOut; const float* pX = (const float*)pFramesIn; for (n = 0; n < frameCount; n += 1) { ma_lpf1_process_pcm_frame_f32(pLPF, pY, pX); pY += pLPF->channels; pX += pLPF->channels; } } else if (pLPF->format == ma_format_s16) { /* */ ma_int16* pY = ( ma_int16*)pFramesOut; const ma_int16* pX = (const ma_int16*)pFramesIn; for (n = 0; n < frameCount; n += 1) { ma_lpf1_process_pcm_frame_s16(pLPF, pY, pX); pY += pLPF->channels; pX += pLPF->channels; } } else { MA_ASSERT(MA_FALSE); return MA_INVALID_ARGS; /* Format not supported. Should never hit this because it's checked in ma_biquad_init() and ma_biquad_reinit(). */ } return MA_SUCCESS; } MA_API ma_uint32 ma_lpf1_get_latency(const ma_lpf1* pLPF) { if (pLPF == NULL) { return 0; } return 1; } static MA_INLINE ma_biquad_config ma_lpf2__get_biquad_config(const ma_lpf2_config* pConfig) { ma_biquad_config bqConfig; double q; double w; double s; double c; double a; MA_ASSERT(pConfig != NULL); q = pConfig->q; w = 2 * MA_PI_D * pConfig->cutoffFrequency / pConfig->sampleRate; s = ma_sind(w); c = ma_cosd(w); a = s / (2*q); bqConfig.b0 = (1 - c) / 2; bqConfig.b1 = 1 - c; bqConfig.b2 = (1 - c) / 2; bqConfig.a0 = 1 + a; bqConfig.a1 = -2 * c; bqConfig.a2 = 1 - a; bqConfig.format = pConfig->format; bqConfig.channels = pConfig->channels; return bqConfig; } MA_API ma_result ma_lpf2_get_heap_size(const ma_lpf2_config* pConfig, size_t* pHeapSizeInBytes) { ma_biquad_config bqConfig; bqConfig = ma_lpf2__get_biquad_config(pConfig); return ma_biquad_get_heap_size(&bqConfig, pHeapSizeInBytes); } MA_API ma_result ma_lpf2_init_preallocated(const ma_lpf2_config* pConfig, void* pHeap, ma_lpf2* pLPF) { ma_result result; ma_biquad_config bqConfig; if (pLPF == NULL) { return MA_INVALID_ARGS; } MA_ZERO_OBJECT(pLPF); if (pConfig == NULL) { return MA_INVALID_ARGS; } bqConfig = ma_lpf2__get_biquad_config(pConfig); result = ma_biquad_init_preallocated(&bqConfig, pHeap, &pLPF->bq); if (result != MA_SUCCESS) { return result; } return MA_SUCCESS; } MA_API ma_result ma_lpf2_init(const ma_lpf2_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_lpf2* pLPF) { ma_result result; size_t heapSizeInBytes; void* pHeap; result = ma_lpf2_get_heap_size(pConfig, &heapSizeInBytes); if (result != MA_SUCCESS) { return result; } if (heapSizeInBytes > 0) { pHeap = ma_malloc(heapSizeInBytes, pAllocationCallbacks); if (pHeap == NULL) { return MA_OUT_OF_MEMORY; } } else { pHeap = NULL; } result = ma_lpf2_init_preallocated(pConfig, pHeap, pLPF); if (result != MA_SUCCESS) { ma_free(pHeap, pAllocationCallbacks); return result; } pLPF->bq._ownsHeap = MA_TRUE; /* <-- This will cause the biquad to take ownership of the heap and free it when it's uninitialized. */ return MA_SUCCESS; } MA_API void ma_lpf2_uninit(ma_lpf2* pLPF, const ma_allocation_callbacks* pAllocationCallbacks) { if (pLPF == NULL) { return; } ma_biquad_uninit(&pLPF->bq, pAllocationCallbacks); /* <-- This will free the heap allocation. */ } MA_API ma_result ma_lpf2_reinit(const ma_lpf2_config* pConfig, ma_lpf2* pLPF) { ma_result result; ma_biquad_config bqConfig; if (pLPF == NULL || pConfig == NULL) { return MA_INVALID_ARGS; } bqConfig = ma_lpf2__get_biquad_config(pConfig); result = ma_biquad_reinit(&bqConfig, &pLPF->bq); if (result != MA_SUCCESS) { return result; } return MA_SUCCESS; } MA_API ma_result ma_lpf2_clear_cache(ma_lpf2* pLPF) { if (pLPF == NULL) { return MA_INVALID_ARGS; } ma_biquad_clear_cache(&pLPF->bq); return MA_SUCCESS; } static MA_INLINE void ma_lpf2_process_pcm_frame_s16(ma_lpf2* pLPF, ma_int16* pFrameOut, const ma_int16* pFrameIn) { ma_biquad_process_pcm_frame_s16(&pLPF->bq, pFrameOut, pFrameIn); } static MA_INLINE void ma_lpf2_process_pcm_frame_f32(ma_lpf2* pLPF, float* pFrameOut, const float* pFrameIn) { ma_biquad_process_pcm_frame_f32(&pLPF->bq, pFrameOut, pFrameIn); } MA_API ma_result ma_lpf2_process_pcm_frames(ma_lpf2* pLPF, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount) { if (pLPF == NULL) { return MA_INVALID_ARGS; } return ma_biquad_process_pcm_frames(&pLPF->bq, pFramesOut, pFramesIn, frameCount); } MA_API ma_uint32 ma_lpf2_get_latency(const ma_lpf2* pLPF) { if (pLPF == NULL) { return 0; } return ma_biquad_get_latency(&pLPF->bq); } MA_API ma_lpf_config ma_lpf_config_init(ma_format format, ma_uint32 channels, ma_uint32 sampleRate, double cutoffFrequency, ma_uint32 order) { ma_lpf_config config; MA_ZERO_OBJECT(&config); config.format = format; config.channels = channels; config.sampleRate = sampleRate; config.cutoffFrequency = cutoffFrequency; config.order = ma_min(order, MA_MAX_FILTER_ORDER); return config; } typedef struct { size_t sizeInBytes; size_t lpf1Offset; size_t lpf2Offset; /* Offset of the first second order filter. Subsequent filters will come straight after, and will each have the same heap size. */ } ma_lpf_heap_layout; static void ma_lpf_calculate_sub_lpf_counts(ma_uint32 order, ma_uint32* pLPF1Count, ma_uint32* pLPF2Count) { MA_ASSERT(pLPF1Count != NULL); MA_ASSERT(pLPF2Count != NULL); *pLPF1Count = order % 2; *pLPF2Count = order / 2; } static ma_result ma_lpf_get_heap_layout(const ma_lpf_config* pConfig, ma_lpf_heap_layout* pHeapLayout) { ma_result result; ma_uint32 lpf1Count; ma_uint32 lpf2Count; ma_uint32 ilpf1; ma_uint32 ilpf2; MA_ASSERT(pHeapLayout != NULL); MA_ZERO_OBJECT(pHeapLayout); if (pConfig == NULL) { return MA_INVALID_ARGS; } if (pConfig->channels == 0) { return MA_INVALID_ARGS; } if (pConfig->order > MA_MAX_FILTER_ORDER) { return MA_INVALID_ARGS; } ma_lpf_calculate_sub_lpf_counts(pConfig->order, &lpf1Count, &lpf2Count); pHeapLayout->sizeInBytes = 0; /* LPF 1 */ pHeapLayout->lpf1Offset = pHeapLayout->sizeInBytes; for (ilpf1 = 0; ilpf1 < lpf1Count; ilpf1 += 1) { size_t lpf1HeapSizeInBytes; ma_lpf1_config lpf1Config = ma_lpf1_config_init(pConfig->format, pConfig->channels, pConfig->sampleRate, pConfig->cutoffFrequency); result = ma_lpf1_get_heap_size(&lpf1Config, &lpf1HeapSizeInBytes); if (result != MA_SUCCESS) { return result; } pHeapLayout->sizeInBytes += sizeof(ma_lpf1) + lpf1HeapSizeInBytes; } /* LPF 2*/ pHeapLayout->lpf2Offset = pHeapLayout->sizeInBytes; for (ilpf2 = 0; ilpf2 < lpf2Count; ilpf2 += 1) { size_t lpf2HeapSizeInBytes; ma_lpf2_config lpf2Config = ma_lpf2_config_init(pConfig->format, pConfig->channels, pConfig->sampleRate, pConfig->cutoffFrequency, 0.707107); /* <-- The "q" parameter does not matter for the purpose of calculating the heap size. */ result = ma_lpf2_get_heap_size(&lpf2Config, &lpf2HeapSizeInBytes); if (result != MA_SUCCESS) { return result; } pHeapLayout->sizeInBytes += sizeof(ma_lpf2) + lpf2HeapSizeInBytes; } /* Make sure allocation size is aligned. */ pHeapLayout->sizeInBytes = ma_align_64(pHeapLayout->sizeInBytes); return MA_SUCCESS; } static ma_result ma_lpf_reinit__internal(const ma_lpf_config* pConfig, void* pHeap, ma_lpf* pLPF, ma_bool32 isNew) { ma_result result; ma_uint32 lpf1Count; ma_uint32 lpf2Count; ma_uint32 ilpf1; ma_uint32 ilpf2; ma_lpf_heap_layout heapLayout; /* Only used if isNew is true. */ if (pLPF == NULL || pConfig == NULL) { return MA_INVALID_ARGS; } /* Only supporting f32 and s16. */ if (pConfig->format != ma_format_f32 && pConfig->format != ma_format_s16) { return MA_INVALID_ARGS; } /* The format cannot be changed after initialization. */ if (pLPF->format != ma_format_unknown && pLPF->format != pConfig->format) { return MA_INVALID_OPERATION; } /* The channel count cannot be changed after initialization. */ if (pLPF->channels != 0 && pLPF->channels != pConfig->channels) { return MA_INVALID_OPERATION; } if (pConfig->order > MA_MAX_FILTER_ORDER) { return MA_INVALID_ARGS; } ma_lpf_calculate_sub_lpf_counts(pConfig->order, &lpf1Count, &lpf2Count); /* The filter order can't change between reinits. */ if (!isNew) { if (pLPF->lpf1Count != lpf1Count || pLPF->lpf2Count != lpf2Count) { return MA_INVALID_OPERATION; } } if (isNew) { result = ma_lpf_get_heap_layout(pConfig, &heapLayout); if (result != MA_SUCCESS) { return result; } pLPF->_pHeap = pHeap; MA_ZERO_MEMORY(pHeap, heapLayout.sizeInBytes); pLPF->pLPF1 = (ma_lpf1*)ma_offset_ptr(pHeap, heapLayout.lpf1Offset); pLPF->pLPF2 = (ma_lpf2*)ma_offset_ptr(pHeap, heapLayout.lpf2Offset); } else { MA_ZERO_OBJECT(&heapLayout); /* To silence a compiler warning. */ } for (ilpf1 = 0; ilpf1 < lpf1Count; ilpf1 += 1) { ma_lpf1_config lpf1Config = ma_lpf1_config_init(pConfig->format, pConfig->channels, pConfig->sampleRate, pConfig->cutoffFrequency); if (isNew) { size_t lpf1HeapSizeInBytes; result = ma_lpf1_get_heap_size(&lpf1Config, &lpf1HeapSizeInBytes); if (result == MA_SUCCESS) { result = ma_lpf1_init_preallocated(&lpf1Config, ma_offset_ptr(pHeap, heapLayout.lpf1Offset + (sizeof(ma_lpf1) * lpf1Count) + (ilpf1 * lpf1HeapSizeInBytes)), &pLPF->pLPF1[ilpf1]); } } else { result = ma_lpf1_reinit(&lpf1Config, &pLPF->pLPF1[ilpf1]); } if (result != MA_SUCCESS) { ma_uint32 jlpf1; for (jlpf1 = 0; jlpf1 < ilpf1; jlpf1 += 1) { ma_lpf1_uninit(&pLPF->pLPF1[jlpf1], NULL); /* No need for allocation callbacks here since we used a preallocated heap allocation. */ } return result; } } for (ilpf2 = 0; ilpf2 < lpf2Count; ilpf2 += 1) { ma_lpf2_config lpf2Config; double q; double a; /* Tempting to use 0.707107, but won't result in a Butterworth filter if the order is > 2. */ if (lpf1Count == 1) { a = (1 + ilpf2*1) * (MA_PI_D/(pConfig->order*1)); /* Odd order. */ } else { a = (1 + ilpf2*2) * (MA_PI_D/(pConfig->order*2)); /* Even order. */ } q = 1 / (2*ma_cosd(a)); lpf2Config = ma_lpf2_config_init(pConfig->format, pConfig->channels, pConfig->sampleRate, pConfig->cutoffFrequency, q); if (isNew) { size_t lpf2HeapSizeInBytes; result = ma_lpf2_get_heap_size(&lpf2Config, &lpf2HeapSizeInBytes); if (result == MA_SUCCESS) { result = ma_lpf2_init_preallocated(&lpf2Config, ma_offset_ptr(pHeap, heapLayout.lpf2Offset + (sizeof(ma_lpf2) * lpf2Count) + (ilpf2 * lpf2HeapSizeInBytes)), &pLPF->pLPF2[ilpf2]); } } else { result = ma_lpf2_reinit(&lpf2Config, &pLPF->pLPF2[ilpf2]); } if (result != MA_SUCCESS) { ma_uint32 jlpf1; ma_uint32 jlpf2; for (jlpf1 = 0; jlpf1 < lpf1Count; jlpf1 += 1) { ma_lpf1_uninit(&pLPF->pLPF1[jlpf1], NULL); /* No need for allocation callbacks here since we used a preallocated heap allocation. */ } for (jlpf2 = 0; jlpf2 < ilpf2; jlpf2 += 1) { ma_lpf2_uninit(&pLPF->pLPF2[jlpf2], NULL); /* No need for allocation callbacks here since we used a preallocated heap allocation. */ } return result; } } pLPF->lpf1Count = lpf1Count; pLPF->lpf2Count = lpf2Count; pLPF->format = pConfig->format; pLPF->channels = pConfig->channels; pLPF->sampleRate = pConfig->sampleRate; return MA_SUCCESS; } MA_API ma_result ma_lpf_get_heap_size(const ma_lpf_config* pConfig, size_t* pHeapSizeInBytes) { ma_result result; ma_lpf_heap_layout heapLayout; if (pHeapSizeInBytes == NULL) { return MA_INVALID_ARGS; } *pHeapSizeInBytes = 0; result = ma_lpf_get_heap_layout(pConfig, &heapLayout); if (result != MA_SUCCESS) { return result; } *pHeapSizeInBytes = heapLayout.sizeInBytes; return result; } MA_API ma_result ma_lpf_init_preallocated(const ma_lpf_config* pConfig, void* pHeap, ma_lpf* pLPF) { if (pLPF == NULL) { return MA_INVALID_ARGS; } MA_ZERO_OBJECT(pLPF); return ma_lpf_reinit__internal(pConfig, pHeap, pLPF, /*isNew*/MA_TRUE); } MA_API ma_result ma_lpf_init(const ma_lpf_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_lpf* pLPF) { ma_result result; size_t heapSizeInBytes; void* pHeap; result = ma_lpf_get_heap_size(pConfig, &heapSizeInBytes); if (result != MA_SUCCESS) { return result; } if (heapSizeInBytes > 0) { pHeap = ma_malloc(heapSizeInBytes, pAllocationCallbacks); if (pHeap == NULL) { return MA_OUT_OF_MEMORY; } } else { pHeap = NULL; } result = ma_lpf_init_preallocated(pConfig, pHeap, pLPF); if (result != MA_SUCCESS) { ma_free(pHeap, pAllocationCallbacks); return result; } pLPF->_ownsHeap = MA_TRUE; return MA_SUCCESS; } MA_API void ma_lpf_uninit(ma_lpf* pLPF, const ma_allocation_callbacks* pAllocationCallbacks) { ma_uint32 ilpf1; ma_uint32 ilpf2; if (pLPF == NULL) { return; } for (ilpf1 = 0; ilpf1 < pLPF->lpf1Count; ilpf1 += 1) { ma_lpf1_uninit(&pLPF->pLPF1[ilpf1], pAllocationCallbacks); } for (ilpf2 = 0; ilpf2 < pLPF->lpf2Count; ilpf2 += 1) { ma_lpf2_uninit(&pLPF->pLPF2[ilpf2], pAllocationCallbacks); } if (pLPF->_ownsHeap) { ma_free(pLPF->_pHeap, pAllocationCallbacks); } } MA_API ma_result ma_lpf_reinit(const ma_lpf_config* pConfig, ma_lpf* pLPF) { return ma_lpf_reinit__internal(pConfig, NULL, pLPF, /*isNew*/MA_FALSE); } MA_API ma_result ma_lpf_clear_cache(ma_lpf* pLPF) { ma_uint32 ilpf1; ma_uint32 ilpf2; if (pLPF == NULL) { return MA_INVALID_ARGS; } for (ilpf1 = 0; ilpf1 < pLPF->lpf1Count; ilpf1 += 1) { ma_lpf1_clear_cache(&pLPF->pLPF1[ilpf1]); } for (ilpf2 = 0; ilpf2 < pLPF->lpf2Count; ilpf2 += 1) { ma_lpf2_clear_cache(&pLPF->pLPF2[ilpf2]); } return MA_SUCCESS; } static MA_INLINE void ma_lpf_process_pcm_frame_f32(ma_lpf* pLPF, float* pY, const void* pX) { ma_uint32 ilpf1; ma_uint32 ilpf2; MA_ASSERT(pLPF->format == ma_format_f32); MA_MOVE_MEMORY(pY, pX, ma_get_bytes_per_frame(pLPF->format, pLPF->channels)); for (ilpf1 = 0; ilpf1 < pLPF->lpf1Count; ilpf1 += 1) { ma_lpf1_process_pcm_frame_f32(&pLPF->pLPF1[ilpf1], pY, pY); } for (ilpf2 = 0; ilpf2 < pLPF->lpf2Count; ilpf2 += 1) { ma_lpf2_process_pcm_frame_f32(&pLPF->pLPF2[ilpf2], pY, pY); } } static MA_INLINE void ma_lpf_process_pcm_frame_s16(ma_lpf* pLPF, ma_int16* pY, const ma_int16* pX) { ma_uint32 ilpf1; ma_uint32 ilpf2; MA_ASSERT(pLPF->format == ma_format_s16); MA_MOVE_MEMORY(pY, pX, ma_get_bytes_per_frame(pLPF->format, pLPF->channels)); for (ilpf1 = 0; ilpf1 < pLPF->lpf1Count; ilpf1 += 1) { ma_lpf1_process_pcm_frame_s16(&pLPF->pLPF1[ilpf1], pY, pY); } for (ilpf2 = 0; ilpf2 < pLPF->lpf2Count; ilpf2 += 1) { ma_lpf2_process_pcm_frame_s16(&pLPF->pLPF2[ilpf2], pY, pY); } } MA_API ma_result ma_lpf_process_pcm_frames(ma_lpf* pLPF, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount) { ma_result result; ma_uint32 ilpf1; ma_uint32 ilpf2; if (pLPF == NULL) { return MA_INVALID_ARGS; } /* Faster path for in-place. */ if (pFramesOut == pFramesIn) { for (ilpf1 = 0; ilpf1 < pLPF->lpf1Count; ilpf1 += 1) { result = ma_lpf1_process_pcm_frames(&pLPF->pLPF1[ilpf1], pFramesOut, pFramesOut, frameCount); if (result != MA_SUCCESS) { return result; } } for (ilpf2 = 0; ilpf2 < pLPF->lpf2Count; ilpf2 += 1) { result = ma_lpf2_process_pcm_frames(&pLPF->pLPF2[ilpf2], pFramesOut, pFramesOut, frameCount); if (result != MA_SUCCESS) { return result; } } } /* Slightly slower path for copying. */ if (pFramesOut != pFramesIn) { ma_uint32 iFrame; /* */ if (pLPF->format == ma_format_f32) { /* */ float* pFramesOutF32 = ( float*)pFramesOut; const float* pFramesInF32 = (const float*)pFramesIn; for (iFrame = 0; iFrame < frameCount; iFrame += 1) { ma_lpf_process_pcm_frame_f32(pLPF, pFramesOutF32, pFramesInF32); pFramesOutF32 += pLPF->channels; pFramesInF32 += pLPF->channels; } } else if (pLPF->format == ma_format_s16) { /* */ ma_int16* pFramesOutS16 = ( ma_int16*)pFramesOut; const ma_int16* pFramesInS16 = (const ma_int16*)pFramesIn; for (iFrame = 0; iFrame < frameCount; iFrame += 1) { ma_lpf_process_pcm_frame_s16(pLPF, pFramesOutS16, pFramesInS16); pFramesOutS16 += pLPF->channels; pFramesInS16 += pLPF->channels; } } else { MA_ASSERT(MA_FALSE); return MA_INVALID_OPERATION; /* Should never hit this. */ } } return MA_SUCCESS; } MA_API ma_uint32 ma_lpf_get_latency(const ma_lpf* pLPF) { if (pLPF == NULL) { return 0; } return pLPF->lpf2Count*2 + pLPF->lpf1Count; } /************************************************************************************************************************************************************** High-Pass Filtering **************************************************************************************************************************************************************/ MA_API ma_hpf1_config ma_hpf1_config_init(ma_format format, ma_uint32 channels, ma_uint32 sampleRate, double cutoffFrequency) { ma_hpf1_config config; MA_ZERO_OBJECT(&config); config.format = format; config.channels = channels; config.sampleRate = sampleRate; config.cutoffFrequency = cutoffFrequency; return config; } MA_API ma_hpf2_config ma_hpf2_config_init(ma_format format, ma_uint32 channels, ma_uint32 sampleRate, double cutoffFrequency, double q) { ma_hpf2_config config; MA_ZERO_OBJECT(&config); config.format = format; config.channels = channels; config.sampleRate = sampleRate; config.cutoffFrequency = cutoffFrequency; config.q = q; /* Q cannot be 0 or else it'll result in a division by 0. In this case just default to 0.707107. */ if (config.q == 0) { config.q = 0.707107; } return config; } typedef struct { size_t sizeInBytes; size_t r1Offset; } ma_hpf1_heap_layout; static ma_result ma_hpf1_get_heap_layout(const ma_hpf1_config* pConfig, ma_hpf1_heap_layout* pHeapLayout) { MA_ASSERT(pHeapLayout != NULL); MA_ZERO_OBJECT(pHeapLayout); if (pConfig == NULL) { return MA_INVALID_ARGS; } if (pConfig->channels == 0) { return MA_INVALID_ARGS; } pHeapLayout->sizeInBytes = 0; /* R1 */ pHeapLayout->r1Offset = pHeapLayout->sizeInBytes; pHeapLayout->sizeInBytes += sizeof(ma_biquad_coefficient) * pConfig->channels; /* Make sure allocation size is aligned. */ pHeapLayout->sizeInBytes = ma_align_64(pHeapLayout->sizeInBytes); return MA_SUCCESS; } MA_API ma_result ma_hpf1_get_heap_size(const ma_hpf1_config* pConfig, size_t* pHeapSizeInBytes) { ma_result result; ma_hpf1_heap_layout heapLayout; if (pHeapSizeInBytes == NULL) { return MA_INVALID_ARGS; } result = ma_hpf1_get_heap_layout(pConfig, &heapLayout); if (result != MA_SUCCESS) { return result; } *pHeapSizeInBytes = heapLayout.sizeInBytes; return MA_SUCCESS; } MA_API ma_result ma_hpf1_init_preallocated(const ma_hpf1_config* pConfig, void* pHeap, ma_hpf1* pLPF) { ma_result result; ma_hpf1_heap_layout heapLayout; if (pLPF == NULL) { return MA_INVALID_ARGS; } MA_ZERO_OBJECT(pLPF); result = ma_hpf1_get_heap_layout(pConfig, &heapLayout); if (result != MA_SUCCESS) { return result; } pLPF->_pHeap = pHeap; MA_ZERO_MEMORY(pHeap, heapLayout.sizeInBytes); pLPF->pR1 = (ma_biquad_coefficient*)ma_offset_ptr(pHeap, heapLayout.r1Offset); return ma_hpf1_reinit(pConfig, pLPF); } MA_API ma_result ma_hpf1_init(const ma_hpf1_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_hpf1* pLPF) { ma_result result; size_t heapSizeInBytes; void* pHeap; result = ma_hpf1_get_heap_size(pConfig, &heapSizeInBytes); if (result != MA_SUCCESS) { return result; } if (heapSizeInBytes > 0) { pHeap = ma_malloc(heapSizeInBytes, pAllocationCallbacks); if (pHeap == NULL) { return MA_OUT_OF_MEMORY; } } else { pHeap = NULL; } result = ma_hpf1_init_preallocated(pConfig, pHeap, pLPF); if (result != MA_SUCCESS) { ma_free(pHeap, pAllocationCallbacks); return result; } pLPF->_ownsHeap = MA_TRUE; return MA_SUCCESS; } MA_API void ma_hpf1_uninit(ma_hpf1* pHPF, const ma_allocation_callbacks* pAllocationCallbacks) { if (pHPF == NULL) { return; } if (pHPF->_ownsHeap) { ma_free(pHPF->_pHeap, pAllocationCallbacks); } } MA_API ma_result ma_hpf1_reinit(const ma_hpf1_config* pConfig, ma_hpf1* pHPF) { double a; if (pHPF == NULL || pConfig == NULL) { return MA_INVALID_ARGS; } /* Only supporting f32 and s16. */ if (pConfig->format != ma_format_f32 && pConfig->format != ma_format_s16) { return MA_INVALID_ARGS; } /* The format cannot be changed after initialization. */ if (pHPF->format != ma_format_unknown && pHPF->format != pConfig->format) { return MA_INVALID_OPERATION; } /* The channel count cannot be changed after initialization. */ if (pHPF->channels != 0 && pHPF->channels != pConfig->channels) { return MA_INVALID_OPERATION; } pHPF->format = pConfig->format; pHPF->channels = pConfig->channels; a = ma_expd(-2 * MA_PI_D * pConfig->cutoffFrequency / pConfig->sampleRate); if (pConfig->format == ma_format_f32) { pHPF->a.f32 = (float)a; } else { pHPF->a.s32 = ma_biquad_float_to_fp(a); } return MA_SUCCESS; } static MA_INLINE void ma_hpf1_process_pcm_frame_f32(ma_hpf1* pHPF, float* pY, const float* pX) { ma_uint32 c; const ma_uint32 channels = pHPF->channels; const float a = 1 - pHPF->a.f32; const float b = 1 - a; MA_ASSUME(channels > 0); for (c = 0; c < channels; c += 1) { float r1 = pHPF->pR1[c].f32; float x = pX[c]; float y; y = b*x - a*r1; pY[c] = y; pHPF->pR1[c].f32 = y; } } static MA_INLINE void ma_hpf1_process_pcm_frame_s16(ma_hpf1* pHPF, ma_int16* pY, const ma_int16* pX) { ma_uint32 c; const ma_uint32 channels = pHPF->channels; const ma_int32 a = ((1 << MA_BIQUAD_FIXED_POINT_SHIFT) - pHPF->a.s32); const ma_int32 b = ((1 << MA_BIQUAD_FIXED_POINT_SHIFT) - a); MA_ASSUME(channels > 0); for (c = 0; c < channels; c += 1) { ma_int32 r1 = pHPF->pR1[c].s32; ma_int32 x = pX[c]; ma_int32 y; y = (b*x - a*r1) >> MA_BIQUAD_FIXED_POINT_SHIFT; pY[c] = (ma_int16)y; pHPF->pR1[c].s32 = (ma_int32)y; } } MA_API ma_result ma_hpf1_process_pcm_frames(ma_hpf1* pHPF, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount) { ma_uint32 n; if (pHPF == NULL || pFramesOut == NULL || pFramesIn == NULL) { return MA_INVALID_ARGS; } /* Note that the logic below needs to support in-place filtering. That is, it must support the case where pFramesOut and pFramesIn are the same. */ if (pHPF->format == ma_format_f32) { /* */ float* pY = ( float*)pFramesOut; const float* pX = (const float*)pFramesIn; for (n = 0; n < frameCount; n += 1) { ma_hpf1_process_pcm_frame_f32(pHPF, pY, pX); pY += pHPF->channels; pX += pHPF->channels; } } else if (pHPF->format == ma_format_s16) { /* */ ma_int16* pY = ( ma_int16*)pFramesOut; const ma_int16* pX = (const ma_int16*)pFramesIn; for (n = 0; n < frameCount; n += 1) { ma_hpf1_process_pcm_frame_s16(pHPF, pY, pX); pY += pHPF->channels; pX += pHPF->channels; } } else { MA_ASSERT(MA_FALSE); return MA_INVALID_ARGS; /* Format not supported. Should never hit this because it's checked in ma_biquad_init() and ma_biquad_reinit(). */ } return MA_SUCCESS; } MA_API ma_uint32 ma_hpf1_get_latency(const ma_hpf1* pHPF) { if (pHPF == NULL) { return 0; } return 1; } static MA_INLINE ma_biquad_config ma_hpf2__get_biquad_config(const ma_hpf2_config* pConfig) { ma_biquad_config bqConfig; double q; double w; double s; double c; double a; MA_ASSERT(pConfig != NULL); q = pConfig->q; w = 2 * MA_PI_D * pConfig->cutoffFrequency / pConfig->sampleRate; s = ma_sind(w); c = ma_cosd(w); a = s / (2*q); bqConfig.b0 = (1 + c) / 2; bqConfig.b1 = -(1 + c); bqConfig.b2 = (1 + c) / 2; bqConfig.a0 = 1 + a; bqConfig.a1 = -2 * c; bqConfig.a2 = 1 - a; bqConfig.format = pConfig->format; bqConfig.channels = pConfig->channels; return bqConfig; } MA_API ma_result ma_hpf2_get_heap_size(const ma_hpf2_config* pConfig, size_t* pHeapSizeInBytes) { ma_biquad_config bqConfig; bqConfig = ma_hpf2__get_biquad_config(pConfig); return ma_biquad_get_heap_size(&bqConfig, pHeapSizeInBytes); } MA_API ma_result ma_hpf2_init_preallocated(const ma_hpf2_config* pConfig, void* pHeap, ma_hpf2* pHPF) { ma_result result; ma_biquad_config bqConfig; if (pHPF == NULL) { return MA_INVALID_ARGS; } MA_ZERO_OBJECT(pHPF); if (pConfig == NULL) { return MA_INVALID_ARGS; } bqConfig = ma_hpf2__get_biquad_config(pConfig); result = ma_biquad_init_preallocated(&bqConfig, pHeap, &pHPF->bq); if (result != MA_SUCCESS) { return result; } return MA_SUCCESS; } MA_API ma_result ma_hpf2_init(const ma_hpf2_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_hpf2* pHPF) { ma_result result; size_t heapSizeInBytes; void* pHeap; result = ma_hpf2_get_heap_size(pConfig, &heapSizeInBytes); if (result != MA_SUCCESS) { return result; } if (heapSizeInBytes > 0) { pHeap = ma_malloc(heapSizeInBytes, pAllocationCallbacks); if (pHeap == NULL) { return MA_OUT_OF_MEMORY; } } else { pHeap = NULL; } result = ma_hpf2_init_preallocated(pConfig, pHeap, pHPF); if (result != MA_SUCCESS) { ma_free(pHeap, pAllocationCallbacks); return result; } pHPF->bq._ownsHeap = MA_TRUE; /* <-- This will cause the biquad to take ownership of the heap and free it when it's uninitialized. */ return MA_SUCCESS; } MA_API void ma_hpf2_uninit(ma_hpf2* pHPF, const ma_allocation_callbacks* pAllocationCallbacks) { if (pHPF == NULL) { return; } ma_biquad_uninit(&pHPF->bq, pAllocationCallbacks); /* <-- This will free the heap allocation. */ } MA_API ma_result ma_hpf2_reinit(const ma_hpf2_config* pConfig, ma_hpf2* pHPF) { ma_result result; ma_biquad_config bqConfig; if (pHPF == NULL || pConfig == NULL) { return MA_INVALID_ARGS; } bqConfig = ma_hpf2__get_biquad_config(pConfig); result = ma_biquad_reinit(&bqConfig, &pHPF->bq); if (result != MA_SUCCESS) { return result; } return MA_SUCCESS; } static MA_INLINE void ma_hpf2_process_pcm_frame_s16(ma_hpf2* pHPF, ma_int16* pFrameOut, const ma_int16* pFrameIn) { ma_biquad_process_pcm_frame_s16(&pHPF->bq, pFrameOut, pFrameIn); } static MA_INLINE void ma_hpf2_process_pcm_frame_f32(ma_hpf2* pHPF, float* pFrameOut, const float* pFrameIn) { ma_biquad_process_pcm_frame_f32(&pHPF->bq, pFrameOut, pFrameIn); } MA_API ma_result ma_hpf2_process_pcm_frames(ma_hpf2* pHPF, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount) { if (pHPF == NULL) { return MA_INVALID_ARGS; } return ma_biquad_process_pcm_frames(&pHPF->bq, pFramesOut, pFramesIn, frameCount); } MA_API ma_uint32 ma_hpf2_get_latency(const ma_hpf2* pHPF) { if (pHPF == NULL) { return 0; } return ma_biquad_get_latency(&pHPF->bq); } MA_API ma_hpf_config ma_hpf_config_init(ma_format format, ma_uint32 channels, ma_uint32 sampleRate, double cutoffFrequency, ma_uint32 order) { ma_hpf_config config; MA_ZERO_OBJECT(&config); config.format = format; config.channels = channels; config.sampleRate = sampleRate; config.cutoffFrequency = cutoffFrequency; config.order = ma_min(order, MA_MAX_FILTER_ORDER); return config; } typedef struct { size_t sizeInBytes; size_t hpf1Offset; size_t hpf2Offset; /* Offset of the first second order filter. Subsequent filters will come straight after, and will each have the same heap size. */ } ma_hpf_heap_layout; static void ma_hpf_calculate_sub_hpf_counts(ma_uint32 order, ma_uint32* pHPF1Count, ma_uint32* pHPF2Count) { MA_ASSERT(pHPF1Count != NULL); MA_ASSERT(pHPF2Count != NULL); *pHPF1Count = order % 2; *pHPF2Count = order / 2; } static ma_result ma_hpf_get_heap_layout(const ma_hpf_config* pConfig, ma_hpf_heap_layout* pHeapLayout) { ma_result result; ma_uint32 hpf1Count; ma_uint32 hpf2Count; ma_uint32 ihpf1; ma_uint32 ihpf2; MA_ASSERT(pHeapLayout != NULL); MA_ZERO_OBJECT(pHeapLayout); if (pConfig == NULL) { return MA_INVALID_ARGS; } if (pConfig->channels == 0) { return MA_INVALID_ARGS; } if (pConfig->order > MA_MAX_FILTER_ORDER) { return MA_INVALID_ARGS; } ma_hpf_calculate_sub_hpf_counts(pConfig->order, &hpf1Count, &hpf2Count); pHeapLayout->sizeInBytes = 0; /* HPF 1 */ pHeapLayout->hpf1Offset = pHeapLayout->sizeInBytes; for (ihpf1 = 0; ihpf1 < hpf1Count; ihpf1 += 1) { size_t hpf1HeapSizeInBytes; ma_hpf1_config hpf1Config = ma_hpf1_config_init(pConfig->format, pConfig->channels, pConfig->sampleRate, pConfig->cutoffFrequency); result = ma_hpf1_get_heap_size(&hpf1Config, &hpf1HeapSizeInBytes); if (result != MA_SUCCESS) { return result; } pHeapLayout->sizeInBytes += sizeof(ma_hpf1) + hpf1HeapSizeInBytes; } /* HPF 2*/ pHeapLayout->hpf2Offset = pHeapLayout->sizeInBytes; for (ihpf2 = 0; ihpf2 < hpf2Count; ihpf2 += 1) { size_t hpf2HeapSizeInBytes; ma_hpf2_config hpf2Config = ma_hpf2_config_init(pConfig->format, pConfig->channels, pConfig->sampleRate, pConfig->cutoffFrequency, 0.707107); /* <-- The "q" parameter does not matter for the purpose of calculating the heap size. */ result = ma_hpf2_get_heap_size(&hpf2Config, &hpf2HeapSizeInBytes); if (result != MA_SUCCESS) { return result; } pHeapLayout->sizeInBytes += sizeof(ma_hpf2) + hpf2HeapSizeInBytes; } /* Make sure allocation size is aligned. */ pHeapLayout->sizeInBytes = ma_align_64(pHeapLayout->sizeInBytes); return MA_SUCCESS; } static ma_result ma_hpf_reinit__internal(const ma_hpf_config* pConfig, void* pHeap, ma_hpf* pHPF, ma_bool32 isNew) { ma_result result; ma_uint32 hpf1Count; ma_uint32 hpf2Count; ma_uint32 ihpf1; ma_uint32 ihpf2; ma_hpf_heap_layout heapLayout; /* Only used if isNew is true. */ if (pHPF == NULL || pConfig == NULL) { return MA_INVALID_ARGS; } /* Only supporting f32 and s16. */ if (pConfig->format != ma_format_f32 && pConfig->format != ma_format_s16) { return MA_INVALID_ARGS; } /* The format cannot be changed after initialization. */ if (pHPF->format != ma_format_unknown && pHPF->format != pConfig->format) { return MA_INVALID_OPERATION; } /* The channel count cannot be changed after initialization. */ if (pHPF->channels != 0 && pHPF->channels != pConfig->channels) { return MA_INVALID_OPERATION; } if (pConfig->order > MA_MAX_FILTER_ORDER) { return MA_INVALID_ARGS; } ma_hpf_calculate_sub_hpf_counts(pConfig->order, &hpf1Count, &hpf2Count); /* The filter order can't change between reinits. */ if (!isNew) { if (pHPF->hpf1Count != hpf1Count || pHPF->hpf2Count != hpf2Count) { return MA_INVALID_OPERATION; } } if (isNew) { result = ma_hpf_get_heap_layout(pConfig, &heapLayout); if (result != MA_SUCCESS) { return result; } pHPF->_pHeap = pHeap; MA_ZERO_MEMORY(pHeap, heapLayout.sizeInBytes); pHPF->pHPF1 = (ma_hpf1*)ma_offset_ptr(pHeap, heapLayout.hpf1Offset); pHPF->pHPF2 = (ma_hpf2*)ma_offset_ptr(pHeap, heapLayout.hpf2Offset); } else { MA_ZERO_OBJECT(&heapLayout); /* To silence a compiler warning. */ } for (ihpf1 = 0; ihpf1 < hpf1Count; ihpf1 += 1) { ma_hpf1_config hpf1Config = ma_hpf1_config_init(pConfig->format, pConfig->channels, pConfig->sampleRate, pConfig->cutoffFrequency); if (isNew) { size_t hpf1HeapSizeInBytes; result = ma_hpf1_get_heap_size(&hpf1Config, &hpf1HeapSizeInBytes); if (result == MA_SUCCESS) { result = ma_hpf1_init_preallocated(&hpf1Config, ma_offset_ptr(pHeap, heapLayout.hpf1Offset + (sizeof(ma_hpf1) * hpf1Count) + (ihpf1 * hpf1HeapSizeInBytes)), &pHPF->pHPF1[ihpf1]); } } else { result = ma_hpf1_reinit(&hpf1Config, &pHPF->pHPF1[ihpf1]); } if (result != MA_SUCCESS) { ma_uint32 jhpf1; for (jhpf1 = 0; jhpf1 < ihpf1; jhpf1 += 1) { ma_hpf1_uninit(&pHPF->pHPF1[jhpf1], NULL); /* No need for allocation callbacks here since we used a preallocated heap allocation. */ } return result; } } for (ihpf2 = 0; ihpf2 < hpf2Count; ihpf2 += 1) { ma_hpf2_config hpf2Config; double q; double a; /* Tempting to use 0.707107, but won't result in a Butterworth filter if the order is > 2. */ if (hpf1Count == 1) { a = (1 + ihpf2*1) * (MA_PI_D/(pConfig->order*1)); /* Odd order. */ } else { a = (1 + ihpf2*2) * (MA_PI_D/(pConfig->order*2)); /* Even order. */ } q = 1 / (2*ma_cosd(a)); hpf2Config = ma_hpf2_config_init(pConfig->format, pConfig->channels, pConfig->sampleRate, pConfig->cutoffFrequency, q); if (isNew) { size_t hpf2HeapSizeInBytes; result = ma_hpf2_get_heap_size(&hpf2Config, &hpf2HeapSizeInBytes); if (result == MA_SUCCESS) { result = ma_hpf2_init_preallocated(&hpf2Config, ma_offset_ptr(pHeap, heapLayout.hpf2Offset + (sizeof(ma_hpf2) * hpf2Count) + (ihpf2 * hpf2HeapSizeInBytes)), &pHPF->pHPF2[ihpf2]); } } else { result = ma_hpf2_reinit(&hpf2Config, &pHPF->pHPF2[ihpf2]); } if (result != MA_SUCCESS) { ma_uint32 jhpf1; ma_uint32 jhpf2; for (jhpf1 = 0; jhpf1 < hpf1Count; jhpf1 += 1) { ma_hpf1_uninit(&pHPF->pHPF1[jhpf1], NULL); /* No need for allocation callbacks here since we used a preallocated heap allocation. */ } for (jhpf2 = 0; jhpf2 < ihpf2; jhpf2 += 1) { ma_hpf2_uninit(&pHPF->pHPF2[jhpf2], NULL); /* No need for allocation callbacks here since we used a preallocated heap allocation. */ } return result; } } pHPF->hpf1Count = hpf1Count; pHPF->hpf2Count = hpf2Count; pHPF->format = pConfig->format; pHPF->channels = pConfig->channels; pHPF->sampleRate = pConfig->sampleRate; return MA_SUCCESS; } MA_API ma_result ma_hpf_get_heap_size(const ma_hpf_config* pConfig, size_t* pHeapSizeInBytes) { ma_result result; ma_hpf_heap_layout heapLayout; if (pHeapSizeInBytes == NULL) { return MA_INVALID_ARGS; } *pHeapSizeInBytes = 0; result = ma_hpf_get_heap_layout(pConfig, &heapLayout); if (result != MA_SUCCESS) { return result; } *pHeapSizeInBytes = heapLayout.sizeInBytes; return result; } MA_API ma_result ma_hpf_init_preallocated(const ma_hpf_config* pConfig, void* pHeap, ma_hpf* pLPF) { if (pLPF == NULL) { return MA_INVALID_ARGS; } MA_ZERO_OBJECT(pLPF); return ma_hpf_reinit__internal(pConfig, pHeap, pLPF, /*isNew*/MA_TRUE); } MA_API ma_result ma_hpf_init(const ma_hpf_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_hpf* pHPF) { ma_result result; size_t heapSizeInBytes; void* pHeap; result = ma_hpf_get_heap_size(pConfig, &heapSizeInBytes); if (result != MA_SUCCESS) { return result; } if (heapSizeInBytes > 0) { pHeap = ma_malloc(heapSizeInBytes, pAllocationCallbacks); if (pHeap == NULL) { return MA_OUT_OF_MEMORY; } } else { pHeap = NULL; } result = ma_hpf_init_preallocated(pConfig, pHeap, pHPF); if (result != MA_SUCCESS) { ma_free(pHeap, pAllocationCallbacks); return result; } pHPF->_ownsHeap = MA_TRUE; return MA_SUCCESS; } MA_API void ma_hpf_uninit(ma_hpf* pHPF, const ma_allocation_callbacks* pAllocationCallbacks) { ma_uint32 ihpf1; ma_uint32 ihpf2; if (pHPF == NULL) { return; } for (ihpf1 = 0; ihpf1 < pHPF->hpf1Count; ihpf1 += 1) { ma_hpf1_uninit(&pHPF->pHPF1[ihpf1], pAllocationCallbacks); } for (ihpf2 = 0; ihpf2 < pHPF->hpf2Count; ihpf2 += 1) { ma_hpf2_uninit(&pHPF->pHPF2[ihpf2], pAllocationCallbacks); } if (pHPF->_ownsHeap) { ma_free(pHPF->_pHeap, pAllocationCallbacks); } } MA_API ma_result ma_hpf_reinit(const ma_hpf_config* pConfig, ma_hpf* pHPF) { return ma_hpf_reinit__internal(pConfig, NULL, pHPF, /*isNew*/MA_FALSE); } MA_API ma_result ma_hpf_process_pcm_frames(ma_hpf* pHPF, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount) { ma_result result; ma_uint32 ihpf1; ma_uint32 ihpf2; if (pHPF == NULL) { return MA_INVALID_ARGS; } /* Faster path for in-place. */ if (pFramesOut == pFramesIn) { for (ihpf1 = 0; ihpf1 < pHPF->hpf1Count; ihpf1 += 1) { result = ma_hpf1_process_pcm_frames(&pHPF->pHPF1[ihpf1], pFramesOut, pFramesOut, frameCount); if (result != MA_SUCCESS) { return result; } } for (ihpf2 = 0; ihpf2 < pHPF->hpf2Count; ihpf2 += 1) { result = ma_hpf2_process_pcm_frames(&pHPF->pHPF2[ihpf2], pFramesOut, pFramesOut, frameCount); if (result != MA_SUCCESS) { return result; } } } /* Slightly slower path for copying. */ if (pFramesOut != pFramesIn) { ma_uint32 iFrame; /* */ if (pHPF->format == ma_format_f32) { /* */ float* pFramesOutF32 = ( float*)pFramesOut; const float* pFramesInF32 = (const float*)pFramesIn; for (iFrame = 0; iFrame < frameCount; iFrame += 1) { MA_COPY_MEMORY(pFramesOutF32, pFramesInF32, ma_get_bytes_per_frame(pHPF->format, pHPF->channels)); for (ihpf1 = 0; ihpf1 < pHPF->hpf1Count; ihpf1 += 1) { ma_hpf1_process_pcm_frame_f32(&pHPF->pHPF1[ihpf1], pFramesOutF32, pFramesOutF32); } for (ihpf2 = 0; ihpf2 < pHPF->hpf2Count; ihpf2 += 1) { ma_hpf2_process_pcm_frame_f32(&pHPF->pHPF2[ihpf2], pFramesOutF32, pFramesOutF32); } pFramesOutF32 += pHPF->channels; pFramesInF32 += pHPF->channels; } } else if (pHPF->format == ma_format_s16) { /* */ ma_int16* pFramesOutS16 = ( ma_int16*)pFramesOut; const ma_int16* pFramesInS16 = (const ma_int16*)pFramesIn; for (iFrame = 0; iFrame < frameCount; iFrame += 1) { MA_COPY_MEMORY(pFramesOutS16, pFramesInS16, ma_get_bytes_per_frame(pHPF->format, pHPF->channels)); for (ihpf1 = 0; ihpf1 < pHPF->hpf1Count; ihpf1 += 1) { ma_hpf1_process_pcm_frame_s16(&pHPF->pHPF1[ihpf1], pFramesOutS16, pFramesOutS16); } for (ihpf2 = 0; ihpf2 < pHPF->hpf2Count; ihpf2 += 1) { ma_hpf2_process_pcm_frame_s16(&pHPF->pHPF2[ihpf2], pFramesOutS16, pFramesOutS16); } pFramesOutS16 += pHPF->channels; pFramesInS16 += pHPF->channels; } } else { MA_ASSERT(MA_FALSE); return MA_INVALID_OPERATION; /* Should never hit this. */ } } return MA_SUCCESS; } MA_API ma_uint32 ma_hpf_get_latency(const ma_hpf* pHPF) { if (pHPF == NULL) { return 0; } return pHPF->hpf2Count*2 + pHPF->hpf1Count; } /************************************************************************************************************************************************************** Band-Pass Filtering **************************************************************************************************************************************************************/ MA_API ma_bpf2_config ma_bpf2_config_init(ma_format format, ma_uint32 channels, ma_uint32 sampleRate, double cutoffFrequency, double q) { ma_bpf2_config config; MA_ZERO_OBJECT(&config); config.format = format; config.channels = channels; config.sampleRate = sampleRate; config.cutoffFrequency = cutoffFrequency; config.q = q; /* Q cannot be 0 or else it'll result in a division by 0. In this case just default to 0.707107. */ if (config.q == 0) { config.q = 0.707107; } return config; } static MA_INLINE ma_biquad_config ma_bpf2__get_biquad_config(const ma_bpf2_config* pConfig) { ma_biquad_config bqConfig; double q; double w; double s; double c; double a; MA_ASSERT(pConfig != NULL); q = pConfig->q; w = 2 * MA_PI_D * pConfig->cutoffFrequency / pConfig->sampleRate; s = ma_sind(w); c = ma_cosd(w); a = s / (2*q); bqConfig.b0 = q * a; bqConfig.b1 = 0; bqConfig.b2 = -q * a; bqConfig.a0 = 1 + a; bqConfig.a1 = -2 * c; bqConfig.a2 = 1 - a; bqConfig.format = pConfig->format; bqConfig.channels = pConfig->channels; return bqConfig; } MA_API ma_result ma_bpf2_get_heap_size(const ma_bpf2_config* pConfig, size_t* pHeapSizeInBytes) { ma_biquad_config bqConfig; bqConfig = ma_bpf2__get_biquad_config(pConfig); return ma_biquad_get_heap_size(&bqConfig, pHeapSizeInBytes); } MA_API ma_result ma_bpf2_init_preallocated(const ma_bpf2_config* pConfig, void* pHeap, ma_bpf2* pBPF) { ma_result result; ma_biquad_config bqConfig; if (pBPF == NULL) { return MA_INVALID_ARGS; } MA_ZERO_OBJECT(pBPF); if (pConfig == NULL) { return MA_INVALID_ARGS; } bqConfig = ma_bpf2__get_biquad_config(pConfig); result = ma_biquad_init_preallocated(&bqConfig, pHeap, &pBPF->bq); if (result != MA_SUCCESS) { return result; } return MA_SUCCESS; } MA_API ma_result ma_bpf2_init(const ma_bpf2_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_bpf2* pBPF) { ma_result result; size_t heapSizeInBytes; void* pHeap; result = ma_bpf2_get_heap_size(pConfig, &heapSizeInBytes); if (result != MA_SUCCESS) { return result; } if (heapSizeInBytes > 0) { pHeap = ma_malloc(heapSizeInBytes, pAllocationCallbacks); if (pHeap == NULL) { return MA_OUT_OF_MEMORY; } } else { pHeap = NULL; } result = ma_bpf2_init_preallocated(pConfig, pHeap, pBPF); if (result != MA_SUCCESS) { ma_free(pHeap, pAllocationCallbacks); return result; } pBPF->bq._ownsHeap = MA_TRUE; /* <-- This will cause the biquad to take ownership of the heap and free it when it's uninitialized. */ return MA_SUCCESS; } MA_API void ma_bpf2_uninit(ma_bpf2* pBPF, const ma_allocation_callbacks* pAllocationCallbacks) { if (pBPF == NULL) { return; } ma_biquad_uninit(&pBPF->bq, pAllocationCallbacks); /* <-- This will free the heap allocation. */ } MA_API ma_result ma_bpf2_reinit(const ma_bpf2_config* pConfig, ma_bpf2* pBPF) { ma_result result; ma_biquad_config bqConfig; if (pBPF == NULL || pConfig == NULL) { return MA_INVALID_ARGS; } bqConfig = ma_bpf2__get_biquad_config(pConfig); result = ma_biquad_reinit(&bqConfig, &pBPF->bq); if (result != MA_SUCCESS) { return result; } return MA_SUCCESS; } static MA_INLINE void ma_bpf2_process_pcm_frame_s16(ma_bpf2* pBPF, ma_int16* pFrameOut, const ma_int16* pFrameIn) { ma_biquad_process_pcm_frame_s16(&pBPF->bq, pFrameOut, pFrameIn); } static MA_INLINE void ma_bpf2_process_pcm_frame_f32(ma_bpf2* pBPF, float* pFrameOut, const float* pFrameIn) { ma_biquad_process_pcm_frame_f32(&pBPF->bq, pFrameOut, pFrameIn); } MA_API ma_result ma_bpf2_process_pcm_frames(ma_bpf2* pBPF, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount) { if (pBPF == NULL) { return MA_INVALID_ARGS; } return ma_biquad_process_pcm_frames(&pBPF->bq, pFramesOut, pFramesIn, frameCount); } MA_API ma_uint32 ma_bpf2_get_latency(const ma_bpf2* pBPF) { if (pBPF == NULL) { return 0; } return ma_biquad_get_latency(&pBPF->bq); } MA_API ma_bpf_config ma_bpf_config_init(ma_format format, ma_uint32 channels, ma_uint32 sampleRate, double cutoffFrequency, ma_uint32 order) { ma_bpf_config config; MA_ZERO_OBJECT(&config); config.format = format; config.channels = channels; config.sampleRate = sampleRate; config.cutoffFrequency = cutoffFrequency; config.order = ma_min(order, MA_MAX_FILTER_ORDER); return config; } typedef struct { size_t sizeInBytes; size_t bpf2Offset; } ma_bpf_heap_layout; static ma_result ma_bpf_get_heap_layout(const ma_bpf_config* pConfig, ma_bpf_heap_layout* pHeapLayout) { ma_result result; ma_uint32 bpf2Count; ma_uint32 ibpf2; MA_ASSERT(pHeapLayout != NULL); MA_ZERO_OBJECT(pHeapLayout); if (pConfig == NULL) { return MA_INVALID_ARGS; } if (pConfig->order > MA_MAX_FILTER_ORDER) { return MA_INVALID_ARGS; } /* We must have an even number of order. */ if ((pConfig->order & 0x1) != 0) { return MA_INVALID_ARGS; } bpf2Count = pConfig->channels / 2; pHeapLayout->sizeInBytes = 0; /* BPF 2 */ pHeapLayout->bpf2Offset = pHeapLayout->sizeInBytes; for (ibpf2 = 0; ibpf2 < bpf2Count; ibpf2 += 1) { size_t bpf2HeapSizeInBytes; ma_bpf2_config bpf2Config = ma_bpf2_config_init(pConfig->format, pConfig->channels, pConfig->sampleRate, pConfig->cutoffFrequency, 0.707107); /* <-- The "q" parameter does not matter for the purpose of calculating the heap size. */ result = ma_bpf2_get_heap_size(&bpf2Config, &bpf2HeapSizeInBytes); if (result != MA_SUCCESS) { return result; } pHeapLayout->sizeInBytes += sizeof(ma_bpf2) + bpf2HeapSizeInBytes; } /* Make sure allocation size is aligned. */ pHeapLayout->sizeInBytes = ma_align_64(pHeapLayout->sizeInBytes); return MA_SUCCESS; } static ma_result ma_bpf_reinit__internal(const ma_bpf_config* pConfig, void* pHeap, ma_bpf* pBPF, ma_bool32 isNew) { ma_result result; ma_uint32 bpf2Count; ma_uint32 ibpf2; ma_bpf_heap_layout heapLayout; /* Only used if isNew is true. */ if (pBPF == NULL || pConfig == NULL) { return MA_INVALID_ARGS; } /* Only supporting f32 and s16. */ if (pConfig->format != ma_format_f32 && pConfig->format != ma_format_s16) { return MA_INVALID_ARGS; } /* The format cannot be changed after initialization. */ if (pBPF->format != ma_format_unknown && pBPF->format != pConfig->format) { return MA_INVALID_OPERATION; } /* The channel count cannot be changed after initialization. */ if (pBPF->channels != 0 && pBPF->channels != pConfig->channels) { return MA_INVALID_OPERATION; } if (pConfig->order > MA_MAX_FILTER_ORDER) { return MA_INVALID_ARGS; } /* We must have an even number of order. */ if ((pConfig->order & 0x1) != 0) { return MA_INVALID_ARGS; } bpf2Count = pConfig->order / 2; /* The filter order can't change between reinits. */ if (!isNew) { if (pBPF->bpf2Count != bpf2Count) { return MA_INVALID_OPERATION; } } if (isNew) { result = ma_bpf_get_heap_layout(pConfig, &heapLayout); if (result != MA_SUCCESS) { return result; } pBPF->_pHeap = pHeap; MA_ZERO_MEMORY(pHeap, heapLayout.sizeInBytes); pBPF->pBPF2 = (ma_bpf2*)ma_offset_ptr(pHeap, heapLayout.bpf2Offset); } else { MA_ZERO_OBJECT(&heapLayout); } for (ibpf2 = 0; ibpf2 < bpf2Count; ibpf2 += 1) { ma_bpf2_config bpf2Config; double q; /* TODO: Calculate Q to make this a proper Butterworth filter. */ q = 0.707107; bpf2Config = ma_bpf2_config_init(pConfig->format, pConfig->channels, pConfig->sampleRate, pConfig->cutoffFrequency, q); if (isNew) { size_t bpf2HeapSizeInBytes; result = ma_bpf2_get_heap_size(&bpf2Config, &bpf2HeapSizeInBytes); if (result == MA_SUCCESS) { result = ma_bpf2_init_preallocated(&bpf2Config, ma_offset_ptr(pHeap, heapLayout.bpf2Offset + (sizeof(ma_bpf2) * bpf2Count) + (ibpf2 * bpf2HeapSizeInBytes)), &pBPF->pBPF2[ibpf2]); } } else { result = ma_bpf2_reinit(&bpf2Config, &pBPF->pBPF2[ibpf2]); } if (result != MA_SUCCESS) { return result; } } pBPF->bpf2Count = bpf2Count; pBPF->format = pConfig->format; pBPF->channels = pConfig->channels; return MA_SUCCESS; } MA_API ma_result ma_bpf_get_heap_size(const ma_bpf_config* pConfig, size_t* pHeapSizeInBytes) { ma_result result; ma_bpf_heap_layout heapLayout; if (pHeapSizeInBytes == NULL) { return MA_INVALID_ARGS; } *pHeapSizeInBytes = 0; result = ma_bpf_get_heap_layout(pConfig, &heapLayout); if (result != MA_SUCCESS) { return result; } *pHeapSizeInBytes = heapLayout.sizeInBytes; return MA_SUCCESS; } MA_API ma_result ma_bpf_init_preallocated(const ma_bpf_config* pConfig, void* pHeap, ma_bpf* pBPF) { if (pBPF == NULL) { return MA_INVALID_ARGS; } MA_ZERO_OBJECT(pBPF); return ma_bpf_reinit__internal(pConfig, pHeap, pBPF, /*isNew*/MA_TRUE); } MA_API ma_result ma_bpf_init(const ma_bpf_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_bpf* pBPF) { ma_result result; size_t heapSizeInBytes; void* pHeap; result = ma_bpf_get_heap_size(pConfig, &heapSizeInBytes); if (result != MA_SUCCESS) { return result; } if (heapSizeInBytes > 0) { pHeap = ma_malloc(heapSizeInBytes, pAllocationCallbacks); if (pHeap == NULL) { return MA_OUT_OF_MEMORY; } } else { pHeap = NULL; } result = ma_bpf_init_preallocated(pConfig, pHeap, pBPF); if (result != MA_SUCCESS) { ma_free(pHeap, pAllocationCallbacks); return result; } pBPF->_ownsHeap = MA_TRUE; return MA_SUCCESS; } MA_API void ma_bpf_uninit(ma_bpf* pBPF, const ma_allocation_callbacks* pAllocationCallbacks) { ma_uint32 ibpf2; if (pBPF == NULL) { return; } for (ibpf2 = 0; ibpf2 < pBPF->bpf2Count; ibpf2 += 1) { ma_bpf2_uninit(&pBPF->pBPF2[ibpf2], pAllocationCallbacks); } if (pBPF->_ownsHeap) { ma_free(pBPF->_pHeap, pAllocationCallbacks); } } MA_API ma_result ma_bpf_reinit(const ma_bpf_config* pConfig, ma_bpf* pBPF) { return ma_bpf_reinit__internal(pConfig, NULL, pBPF, /*isNew*/MA_FALSE); } MA_API ma_result ma_bpf_process_pcm_frames(ma_bpf* pBPF, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount) { ma_result result; ma_uint32 ibpf2; if (pBPF == NULL) { return MA_INVALID_ARGS; } /* Faster path for in-place. */ if (pFramesOut == pFramesIn) { for (ibpf2 = 0; ibpf2 < pBPF->bpf2Count; ibpf2 += 1) { result = ma_bpf2_process_pcm_frames(&pBPF->pBPF2[ibpf2], pFramesOut, pFramesOut, frameCount); if (result != MA_SUCCESS) { return result; } } } /* Slightly slower path for copying. */ if (pFramesOut != pFramesIn) { ma_uint32 iFrame; /* */ if (pBPF->format == ma_format_f32) { /* */ float* pFramesOutF32 = ( float*)pFramesOut; const float* pFramesInF32 = (const float*)pFramesIn; for (iFrame = 0; iFrame < frameCount; iFrame += 1) { MA_COPY_MEMORY(pFramesOutF32, pFramesInF32, ma_get_bytes_per_frame(pBPF->format, pBPF->channels)); for (ibpf2 = 0; ibpf2 < pBPF->bpf2Count; ibpf2 += 1) { ma_bpf2_process_pcm_frame_f32(&pBPF->pBPF2[ibpf2], pFramesOutF32, pFramesOutF32); } pFramesOutF32 += pBPF->channels; pFramesInF32 += pBPF->channels; } } else if (pBPF->format == ma_format_s16) { /* */ ma_int16* pFramesOutS16 = ( ma_int16*)pFramesOut; const ma_int16* pFramesInS16 = (const ma_int16*)pFramesIn; for (iFrame = 0; iFrame < frameCount; iFrame += 1) { MA_COPY_MEMORY(pFramesOutS16, pFramesInS16, ma_get_bytes_per_frame(pBPF->format, pBPF->channels)); for (ibpf2 = 0; ibpf2 < pBPF->bpf2Count; ibpf2 += 1) { ma_bpf2_process_pcm_frame_s16(&pBPF->pBPF2[ibpf2], pFramesOutS16, pFramesOutS16); } pFramesOutS16 += pBPF->channels; pFramesInS16 += pBPF->channels; } } else { MA_ASSERT(MA_FALSE); return MA_INVALID_OPERATION; /* Should never hit this. */ } } return MA_SUCCESS; } MA_API ma_uint32 ma_bpf_get_latency(const ma_bpf* pBPF) { if (pBPF == NULL) { return 0; } return pBPF->bpf2Count*2; } /************************************************************************************************************************************************************** Notching Filter **************************************************************************************************************************************************************/ MA_API ma_notch2_config ma_notch2_config_init(ma_format format, ma_uint32 channels, ma_uint32 sampleRate, double q, double frequency) { ma_notch2_config config; MA_ZERO_OBJECT(&config); config.format = format; config.channels = channels; config.sampleRate = sampleRate; config.q = q; config.frequency = frequency; if (config.q == 0) { config.q = 0.707107; } return config; } static MA_INLINE ma_biquad_config ma_notch2__get_biquad_config(const ma_notch2_config* pConfig) { ma_biquad_config bqConfig; double q; double w; double s; double c; double a; MA_ASSERT(pConfig != NULL); q = pConfig->q; w = 2 * MA_PI_D * pConfig->frequency / pConfig->sampleRate; s = ma_sind(w); c = ma_cosd(w); a = s / (2*q); bqConfig.b0 = 1; bqConfig.b1 = -2 * c; bqConfig.b2 = 1; bqConfig.a0 = 1 + a; bqConfig.a1 = -2 * c; bqConfig.a2 = 1 - a; bqConfig.format = pConfig->format; bqConfig.channels = pConfig->channels; return bqConfig; } MA_API ma_result ma_notch2_get_heap_size(const ma_notch2_config* pConfig, size_t* pHeapSizeInBytes) { ma_biquad_config bqConfig; bqConfig = ma_notch2__get_biquad_config(pConfig); return ma_biquad_get_heap_size(&bqConfig, pHeapSizeInBytes); } MA_API ma_result ma_notch2_init_preallocated(const ma_notch2_config* pConfig, void* pHeap, ma_notch2* pFilter) { ma_result result; ma_biquad_config bqConfig; if (pFilter == NULL) { return MA_INVALID_ARGS; } MA_ZERO_OBJECT(pFilter); if (pConfig == NULL) { return MA_INVALID_ARGS; } bqConfig = ma_notch2__get_biquad_config(pConfig); result = ma_biquad_init_preallocated(&bqConfig, pHeap, &pFilter->bq); if (result != MA_SUCCESS) { return result; } return MA_SUCCESS; } MA_API ma_result ma_notch2_init(const ma_notch2_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_notch2* pFilter) { ma_result result; size_t heapSizeInBytes; void* pHeap; result = ma_notch2_get_heap_size(pConfig, &heapSizeInBytes); if (result != MA_SUCCESS) { return result; } if (heapSizeInBytes > 0) { pHeap = ma_malloc(heapSizeInBytes, pAllocationCallbacks); if (pHeap == NULL) { return MA_OUT_OF_MEMORY; } } else { pHeap = NULL; } result = ma_notch2_init_preallocated(pConfig, pHeap, pFilter); if (result != MA_SUCCESS) { ma_free(pHeap, pAllocationCallbacks); return result; } pFilter->bq._ownsHeap = MA_TRUE; /* <-- This will cause the biquad to take ownership of the heap and free it when it's uninitialized. */ return MA_SUCCESS; } MA_API void ma_notch2_uninit(ma_notch2* pFilter, const ma_allocation_callbacks* pAllocationCallbacks) { if (pFilter == NULL) { return; } ma_biquad_uninit(&pFilter->bq, pAllocationCallbacks); /* <-- This will free the heap allocation. */ } MA_API ma_result ma_notch2_reinit(const ma_notch2_config* pConfig, ma_notch2* pFilter) { ma_result result; ma_biquad_config bqConfig; if (pFilter == NULL || pConfig == NULL) { return MA_INVALID_ARGS; } bqConfig = ma_notch2__get_biquad_config(pConfig); result = ma_biquad_reinit(&bqConfig, &pFilter->bq); if (result != MA_SUCCESS) { return result; } return MA_SUCCESS; } static MA_INLINE void ma_notch2_process_pcm_frame_s16(ma_notch2* pFilter, ma_int16* pFrameOut, const ma_int16* pFrameIn) { ma_biquad_process_pcm_frame_s16(&pFilter->bq, pFrameOut, pFrameIn); } static MA_INLINE void ma_notch2_process_pcm_frame_f32(ma_notch2* pFilter, float* pFrameOut, const float* pFrameIn) { ma_biquad_process_pcm_frame_f32(&pFilter->bq, pFrameOut, pFrameIn); } MA_API ma_result ma_notch2_process_pcm_frames(ma_notch2* pFilter, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount) { if (pFilter == NULL) { return MA_INVALID_ARGS; } return ma_biquad_process_pcm_frames(&pFilter->bq, pFramesOut, pFramesIn, frameCount); } MA_API ma_uint32 ma_notch2_get_latency(const ma_notch2* pFilter) { if (pFilter == NULL) { return 0; } return ma_biquad_get_latency(&pFilter->bq); } /************************************************************************************************************************************************************** Peaking EQ Filter **************************************************************************************************************************************************************/ MA_API ma_peak2_config ma_peak2_config_init(ma_format format, ma_uint32 channels, ma_uint32 sampleRate, double gainDB, double q, double frequency) { ma_peak2_config config; MA_ZERO_OBJECT(&config); config.format = format; config.channels = channels; config.sampleRate = sampleRate; config.gainDB = gainDB; config.q = q; config.frequency = frequency; if (config.q == 0) { config.q = 0.707107; } return config; } static MA_INLINE ma_biquad_config ma_peak2__get_biquad_config(const ma_peak2_config* pConfig) { ma_biquad_config bqConfig; double q; double w; double s; double c; double a; double A; MA_ASSERT(pConfig != NULL); q = pConfig->q; w = 2 * MA_PI_D * pConfig->frequency / pConfig->sampleRate; s = ma_sind(w); c = ma_cosd(w); a = s / (2*q); A = ma_powd(10, (pConfig->gainDB / 40)); bqConfig.b0 = 1 + (a * A); bqConfig.b1 = -2 * c; bqConfig.b2 = 1 - (a * A); bqConfig.a0 = 1 + (a / A); bqConfig.a1 = -2 * c; bqConfig.a2 = 1 - (a / A); bqConfig.format = pConfig->format; bqConfig.channels = pConfig->channels; return bqConfig; } MA_API ma_result ma_peak2_get_heap_size(const ma_peak2_config* pConfig, size_t* pHeapSizeInBytes) { ma_biquad_config bqConfig; bqConfig = ma_peak2__get_biquad_config(pConfig); return ma_biquad_get_heap_size(&bqConfig, pHeapSizeInBytes); } MA_API ma_result ma_peak2_init_preallocated(const ma_peak2_config* pConfig, void* pHeap, ma_peak2* pFilter) { ma_result result; ma_biquad_config bqConfig; if (pFilter == NULL) { return MA_INVALID_ARGS; } MA_ZERO_OBJECT(pFilter); if (pConfig == NULL) { return MA_INVALID_ARGS; } bqConfig = ma_peak2__get_biquad_config(pConfig); result = ma_biquad_init_preallocated(&bqConfig, pHeap, &pFilter->bq); if (result != MA_SUCCESS) { return result; } return MA_SUCCESS; } MA_API ma_result ma_peak2_init(const ma_peak2_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_peak2* pFilter) { ma_result result; size_t heapSizeInBytes; void* pHeap; result = ma_peak2_get_heap_size(pConfig, &heapSizeInBytes); if (result != MA_SUCCESS) { return result; } if (heapSizeInBytes > 0) { pHeap = ma_malloc(heapSizeInBytes, pAllocationCallbacks); if (pHeap == NULL) { return MA_OUT_OF_MEMORY; } } else { pHeap = NULL; } result = ma_peak2_init_preallocated(pConfig, pHeap, pFilter); if (result != MA_SUCCESS) { ma_free(pHeap, pAllocationCallbacks); return result; } pFilter->bq._ownsHeap = MA_TRUE; /* <-- This will cause the biquad to take ownership of the heap and free it when it's uninitialized. */ return MA_SUCCESS; } MA_API void ma_peak2_uninit(ma_peak2* pFilter, const ma_allocation_callbacks* pAllocationCallbacks) { if (pFilter == NULL) { return; } ma_biquad_uninit(&pFilter->bq, pAllocationCallbacks); /* <-- This will free the heap allocation. */ } MA_API ma_result ma_peak2_reinit(const ma_peak2_config* pConfig, ma_peak2* pFilter) { ma_result result; ma_biquad_config bqConfig; if (pFilter == NULL || pConfig == NULL) { return MA_INVALID_ARGS; } bqConfig = ma_peak2__get_biquad_config(pConfig); result = ma_biquad_reinit(&bqConfig, &pFilter->bq); if (result != MA_SUCCESS) { return result; } return MA_SUCCESS; } static MA_INLINE void ma_peak2_process_pcm_frame_s16(ma_peak2* pFilter, ma_int16* pFrameOut, const ma_int16* pFrameIn) { ma_biquad_process_pcm_frame_s16(&pFilter->bq, pFrameOut, pFrameIn); } static MA_INLINE void ma_peak2_process_pcm_frame_f32(ma_peak2* pFilter, float* pFrameOut, const float* pFrameIn) { ma_biquad_process_pcm_frame_f32(&pFilter->bq, pFrameOut, pFrameIn); } MA_API ma_result ma_peak2_process_pcm_frames(ma_peak2* pFilter, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount) { if (pFilter == NULL) { return MA_INVALID_ARGS; } return ma_biquad_process_pcm_frames(&pFilter->bq, pFramesOut, pFramesIn, frameCount); } MA_API ma_uint32 ma_peak2_get_latency(const ma_peak2* pFilter) { if (pFilter == NULL) { return 0; } return ma_biquad_get_latency(&pFilter->bq); } /************************************************************************************************************************************************************** Low Shelf Filter **************************************************************************************************************************************************************/ MA_API ma_loshelf2_config ma_loshelf2_config_init(ma_format format, ma_uint32 channels, ma_uint32 sampleRate, double gainDB, double shelfSlope, double frequency) { ma_loshelf2_config config; MA_ZERO_OBJECT(&config); config.format = format; config.channels = channels; config.sampleRate = sampleRate; config.gainDB = gainDB; config.shelfSlope = shelfSlope; config.frequency = frequency; return config; } static MA_INLINE ma_biquad_config ma_loshelf2__get_biquad_config(const ma_loshelf2_config* pConfig) { ma_biquad_config bqConfig; double w; double s; double c; double A; double S; double a; double sqrtA; MA_ASSERT(pConfig != NULL); w = 2 * MA_PI_D * pConfig->frequency / pConfig->sampleRate; s = ma_sind(w); c = ma_cosd(w); A = ma_powd(10, (pConfig->gainDB / 40)); S = pConfig->shelfSlope; a = s/2 * ma_sqrtd((A + 1/A) * (1/S - 1) + 2); sqrtA = 2*ma_sqrtd(A)*a; bqConfig.b0 = A * ((A + 1) - (A - 1)*c + sqrtA); bqConfig.b1 = 2 * A * ((A - 1) - (A + 1)*c); bqConfig.b2 = A * ((A + 1) - (A - 1)*c - sqrtA); bqConfig.a0 = (A + 1) + (A - 1)*c + sqrtA; bqConfig.a1 = -2 * ((A - 1) + (A + 1)*c); bqConfig.a2 = (A + 1) + (A - 1)*c - sqrtA; bqConfig.format = pConfig->format; bqConfig.channels = pConfig->channels; return bqConfig; } MA_API ma_result ma_loshelf2_get_heap_size(const ma_loshelf2_config* pConfig, size_t* pHeapSizeInBytes) { ma_biquad_config bqConfig; bqConfig = ma_loshelf2__get_biquad_config(pConfig); return ma_biquad_get_heap_size(&bqConfig, pHeapSizeInBytes); } MA_API ma_result ma_loshelf2_init_preallocated(const ma_loshelf2_config* pConfig, void* pHeap, ma_loshelf2* pFilter) { ma_result result; ma_biquad_config bqConfig; if (pFilter == NULL) { return MA_INVALID_ARGS; } MA_ZERO_OBJECT(pFilter); if (pConfig == NULL) { return MA_INVALID_ARGS; } bqConfig = ma_loshelf2__get_biquad_config(pConfig); result = ma_biquad_init_preallocated(&bqConfig, pHeap, &pFilter->bq); if (result != MA_SUCCESS) { return result; } return MA_SUCCESS; } MA_API ma_result ma_loshelf2_init(const ma_loshelf2_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_loshelf2* pFilter) { ma_result result; size_t heapSizeInBytes; void* pHeap; result = ma_loshelf2_get_heap_size(pConfig, &heapSizeInBytes); if (result != MA_SUCCESS) { return result; } if (heapSizeInBytes > 0) { pHeap = ma_malloc(heapSizeInBytes, pAllocationCallbacks); if (pHeap == NULL) { return MA_OUT_OF_MEMORY; } } else { pHeap = NULL; } result = ma_loshelf2_init_preallocated(pConfig, pHeap, pFilter); if (result != MA_SUCCESS) { ma_free(pHeap, pAllocationCallbacks); return result; } pFilter->bq._ownsHeap = MA_TRUE; /* <-- This will cause the biquad to take ownership of the heap and free it when it's uninitialized. */ return MA_SUCCESS; } MA_API void ma_loshelf2_uninit(ma_loshelf2* pFilter, const ma_allocation_callbacks* pAllocationCallbacks) { if (pFilter == NULL) { return; } ma_biquad_uninit(&pFilter->bq, pAllocationCallbacks); /* <-- This will free the heap allocation. */ } MA_API ma_result ma_loshelf2_reinit(const ma_loshelf2_config* pConfig, ma_loshelf2* pFilter) { ma_result result; ma_biquad_config bqConfig; if (pFilter == NULL || pConfig == NULL) { return MA_INVALID_ARGS; } bqConfig = ma_loshelf2__get_biquad_config(pConfig); result = ma_biquad_reinit(&bqConfig, &pFilter->bq); if (result != MA_SUCCESS) { return result; } return MA_SUCCESS; } static MA_INLINE void ma_loshelf2_process_pcm_frame_s16(ma_loshelf2* pFilter, ma_int16* pFrameOut, const ma_int16* pFrameIn) { ma_biquad_process_pcm_frame_s16(&pFilter->bq, pFrameOut, pFrameIn); } static MA_INLINE void ma_loshelf2_process_pcm_frame_f32(ma_loshelf2* pFilter, float* pFrameOut, const float* pFrameIn) { ma_biquad_process_pcm_frame_f32(&pFilter->bq, pFrameOut, pFrameIn); } MA_API ma_result ma_loshelf2_process_pcm_frames(ma_loshelf2* pFilter, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount) { if (pFilter == NULL) { return MA_INVALID_ARGS; } return ma_biquad_process_pcm_frames(&pFilter->bq, pFramesOut, pFramesIn, frameCount); } MA_API ma_uint32 ma_loshelf2_get_latency(const ma_loshelf2* pFilter) { if (pFilter == NULL) { return 0; } return ma_biquad_get_latency(&pFilter->bq); } /************************************************************************************************************************************************************** High Shelf Filter **************************************************************************************************************************************************************/ MA_API ma_hishelf2_config ma_hishelf2_config_init(ma_format format, ma_uint32 channels, ma_uint32 sampleRate, double gainDB, double shelfSlope, double frequency) { ma_hishelf2_config config; MA_ZERO_OBJECT(&config); config.format = format; config.channels = channels; config.sampleRate = sampleRate; config.gainDB = gainDB; config.shelfSlope = shelfSlope; config.frequency = frequency; return config; } static MA_INLINE ma_biquad_config ma_hishelf2__get_biquad_config(const ma_hishelf2_config* pConfig) { ma_biquad_config bqConfig; double w; double s; double c; double A; double S; double a; double sqrtA; MA_ASSERT(pConfig != NULL); w = 2 * MA_PI_D * pConfig->frequency / pConfig->sampleRate; s = ma_sind(w); c = ma_cosd(w); A = ma_powd(10, (pConfig->gainDB / 40)); S = pConfig->shelfSlope; a = s/2 * ma_sqrtd((A + 1/A) * (1/S - 1) + 2); sqrtA = 2*ma_sqrtd(A)*a; bqConfig.b0 = A * ((A + 1) + (A - 1)*c + sqrtA); bqConfig.b1 = -2 * A * ((A - 1) + (A + 1)*c); bqConfig.b2 = A * ((A + 1) + (A - 1)*c - sqrtA); bqConfig.a0 = (A + 1) - (A - 1)*c + sqrtA; bqConfig.a1 = 2 * ((A - 1) - (A + 1)*c); bqConfig.a2 = (A + 1) - (A - 1)*c - sqrtA; bqConfig.format = pConfig->format; bqConfig.channels = pConfig->channels; return bqConfig; } MA_API ma_result ma_hishelf2_get_heap_size(const ma_hishelf2_config* pConfig, size_t* pHeapSizeInBytes) { ma_biquad_config bqConfig; bqConfig = ma_hishelf2__get_biquad_config(pConfig); return ma_biquad_get_heap_size(&bqConfig, pHeapSizeInBytes); } MA_API ma_result ma_hishelf2_init_preallocated(const ma_hishelf2_config* pConfig, void* pHeap, ma_hishelf2* pFilter) { ma_result result; ma_biquad_config bqConfig; if (pFilter == NULL) { return MA_INVALID_ARGS; } MA_ZERO_OBJECT(pFilter); if (pConfig == NULL) { return MA_INVALID_ARGS; } bqConfig = ma_hishelf2__get_biquad_config(pConfig); result = ma_biquad_init_preallocated(&bqConfig, pHeap, &pFilter->bq); if (result != MA_SUCCESS) { return result; } return MA_SUCCESS; } MA_API ma_result ma_hishelf2_init(const ma_hishelf2_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_hishelf2* pFilter) { ma_result result; size_t heapSizeInBytes; void* pHeap; result = ma_hishelf2_get_heap_size(pConfig, &heapSizeInBytes); if (result != MA_SUCCESS) { return result; } if (heapSizeInBytes > 0) { pHeap = ma_malloc(heapSizeInBytes, pAllocationCallbacks); if (pHeap == NULL) { return MA_OUT_OF_MEMORY; } } else { pHeap = NULL; } result = ma_hishelf2_init_preallocated(pConfig, pHeap, pFilter); if (result != MA_SUCCESS) { ma_free(pHeap, pAllocationCallbacks); return result; } pFilter->bq._ownsHeap = MA_TRUE; /* <-- This will cause the biquad to take ownership of the heap and free it when it's uninitialized. */ return MA_SUCCESS; } MA_API void ma_hishelf2_uninit(ma_hishelf2* pFilter, const ma_allocation_callbacks* pAllocationCallbacks) { if (pFilter == NULL) { return; } ma_biquad_uninit(&pFilter->bq, pAllocationCallbacks); /* <-- This will free the heap allocation. */ } MA_API ma_result ma_hishelf2_reinit(const ma_hishelf2_config* pConfig, ma_hishelf2* pFilter) { ma_result result; ma_biquad_config bqConfig; if (pFilter == NULL || pConfig == NULL) { return MA_INVALID_ARGS; } bqConfig = ma_hishelf2__get_biquad_config(pConfig); result = ma_biquad_reinit(&bqConfig, &pFilter->bq); if (result != MA_SUCCESS) { return result; } return MA_SUCCESS; } static MA_INLINE void ma_hishelf2_process_pcm_frame_s16(ma_hishelf2* pFilter, ma_int16* pFrameOut, const ma_int16* pFrameIn) { ma_biquad_process_pcm_frame_s16(&pFilter->bq, pFrameOut, pFrameIn); } static MA_INLINE void ma_hishelf2_process_pcm_frame_f32(ma_hishelf2* pFilter, float* pFrameOut, const float* pFrameIn) { ma_biquad_process_pcm_frame_f32(&pFilter->bq, pFrameOut, pFrameIn); } MA_API ma_result ma_hishelf2_process_pcm_frames(ma_hishelf2* pFilter, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount) { if (pFilter == NULL) { return MA_INVALID_ARGS; } return ma_biquad_process_pcm_frames(&pFilter->bq, pFramesOut, pFramesIn, frameCount); } MA_API ma_uint32 ma_hishelf2_get_latency(const ma_hishelf2* pFilter) { if (pFilter == NULL) { return 0; } return ma_biquad_get_latency(&pFilter->bq); } /* Delay */ MA_API ma_delay_config ma_delay_config_init(ma_uint32 channels, ma_uint32 sampleRate, ma_uint32 delayInFrames, float decay) { ma_delay_config config; MA_ZERO_OBJECT(&config); config.channels = channels; config.sampleRate = sampleRate; config.delayInFrames = delayInFrames; config.delayStart = (decay == 0) ? MA_TRUE : MA_FALSE; /* Delay the start if it looks like we're not configuring an echo. */ config.wet = 1; config.dry = 1; config.decay = decay; return config; } MA_API ma_result ma_delay_init(const ma_delay_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_delay* pDelay) { if (pDelay == NULL) { return MA_INVALID_ARGS; } MA_ZERO_OBJECT(pDelay); if (pConfig == NULL) { return MA_INVALID_ARGS; } if (pConfig->decay < 0 || pConfig->decay > 1) { return MA_INVALID_ARGS; } pDelay->config = *pConfig; pDelay->bufferSizeInFrames = pConfig->delayInFrames; pDelay->cursor = 0; pDelay->pBuffer = (float*)ma_malloc((size_t)(pDelay->bufferSizeInFrames * ma_get_bytes_per_frame(ma_format_f32, pConfig->channels)), pAllocationCallbacks); if (pDelay->pBuffer == NULL) { return MA_OUT_OF_MEMORY; } ma_silence_pcm_frames(pDelay->pBuffer, pDelay->bufferSizeInFrames, ma_format_f32, pConfig->channels); return MA_SUCCESS; } MA_API void ma_delay_uninit(ma_delay* pDelay, const ma_allocation_callbacks* pAllocationCallbacks) { if (pDelay == NULL) { return; } ma_free(pDelay->pBuffer, pAllocationCallbacks); } MA_API ma_result ma_delay_process_pcm_frames(ma_delay* pDelay, void* pFramesOut, const void* pFramesIn, ma_uint32 frameCount) { ma_uint32 iFrame; ma_uint32 iChannel; float* pFramesOutF32 = (float*)pFramesOut; const float* pFramesInF32 = (const float*)pFramesIn; if (pDelay == NULL || pFramesOut == NULL || pFramesIn == NULL) { return MA_INVALID_ARGS; } for (iFrame = 0; iFrame < frameCount; iFrame += 1) { for (iChannel = 0; iChannel < pDelay->config.channels; iChannel += 1) { ma_uint32 iBuffer = (pDelay->cursor * pDelay->config.channels) + iChannel; if (pDelay->config.delayStart) { /* Delayed start. */ /* Read */ pFramesOutF32[iChannel] = pDelay->pBuffer[iBuffer] * pDelay->config.wet; /* Feedback */ pDelay->pBuffer[iBuffer] = (pDelay->pBuffer[iBuffer] * pDelay->config.decay) + (pFramesInF32[iChannel] * pDelay->config.dry); } else { /* Immediate start */ /* Feedback */ pDelay->pBuffer[iBuffer] = (pDelay->pBuffer[iBuffer] * pDelay->config.decay) + (pFramesInF32[iChannel] * pDelay->config.dry); /* Read */ pFramesOutF32[iChannel] = pDelay->pBuffer[iBuffer] * pDelay->config.wet; } } pDelay->cursor = (pDelay->cursor + 1) % pDelay->bufferSizeInFrames; pFramesOutF32 += pDelay->config.channels; pFramesInF32 += pDelay->config.channels; } return MA_SUCCESS; } MA_API void ma_delay_set_wet(ma_delay* pDelay, float value) { if (pDelay == NULL) { return; } pDelay->config.wet = value; } MA_API float ma_delay_get_wet(const ma_delay* pDelay) { if (pDelay == NULL) { return 0; } return pDelay->config.wet; } MA_API void ma_delay_set_dry(ma_delay* pDelay, float value) { if (pDelay == NULL) { return; } pDelay->config.dry = value; } MA_API float ma_delay_get_dry(const ma_delay* pDelay) { if (pDelay == NULL) { return 0; } return pDelay->config.dry; } MA_API void ma_delay_set_decay(ma_delay* pDelay, float value) { if (pDelay == NULL) { return; } pDelay->config.decay = value; } MA_API float ma_delay_get_decay(const ma_delay* pDelay) { if (pDelay == NULL) { return 0; } return pDelay->config.decay; } MA_API ma_gainer_config ma_gainer_config_init(ma_uint32 channels, ma_uint32 smoothTimeInFrames) { ma_gainer_config config; MA_ZERO_OBJECT(&config); config.channels = channels; config.smoothTimeInFrames = smoothTimeInFrames; return config; } typedef struct { size_t sizeInBytes; size_t oldGainsOffset; size_t newGainsOffset; } ma_gainer_heap_layout; static ma_result ma_gainer_get_heap_layout(const ma_gainer_config* pConfig, ma_gainer_heap_layout* pHeapLayout) { MA_ASSERT(pHeapLayout != NULL); MA_ZERO_OBJECT(pHeapLayout); if (pConfig == NULL) { return MA_INVALID_ARGS; } if (pConfig->channels == 0) { return MA_INVALID_ARGS; } pHeapLayout->sizeInBytes = 0; /* Old gains. */ pHeapLayout->oldGainsOffset = pHeapLayout->sizeInBytes; pHeapLayout->sizeInBytes += sizeof(float) * pConfig->channels; /* New gains. */ pHeapLayout->newGainsOffset = pHeapLayout->sizeInBytes; pHeapLayout->sizeInBytes += sizeof(float) * pConfig->channels; /* Alignment. */ pHeapLayout->sizeInBytes = ma_align_64(pHeapLayout->sizeInBytes); return MA_SUCCESS; } MA_API ma_result ma_gainer_get_heap_size(const ma_gainer_config* pConfig, size_t* pHeapSizeInBytes) { ma_result result; ma_gainer_heap_layout heapLayout; if (pHeapSizeInBytes == NULL) { return MA_INVALID_ARGS; } *pHeapSizeInBytes = 0; result = ma_gainer_get_heap_layout(pConfig, &heapLayout); if (result != MA_SUCCESS) { return MA_INVALID_ARGS; } *pHeapSizeInBytes = heapLayout.sizeInBytes; return MA_SUCCESS; } MA_API ma_result ma_gainer_init_preallocated(const ma_gainer_config* pConfig, void* pHeap, ma_gainer* pGainer) { ma_result result; ma_gainer_heap_layout heapLayout; ma_uint32 iChannel; if (pGainer == NULL) { return MA_INVALID_ARGS; } MA_ZERO_OBJECT(pGainer); if (pConfig == NULL || pHeap == NULL) { return MA_INVALID_ARGS; } result = ma_gainer_get_heap_layout(pConfig, &heapLayout); if (result != MA_SUCCESS) { return result; } pGainer->_pHeap = pHeap; MA_ZERO_MEMORY(pHeap, heapLayout.sizeInBytes); pGainer->pOldGains = (float*)ma_offset_ptr(pHeap, heapLayout.oldGainsOffset); pGainer->pNewGains = (float*)ma_offset_ptr(pHeap, heapLayout.newGainsOffset); pGainer->masterVolume = 1; pGainer->config = *pConfig; pGainer->t = (ma_uint32)-1; /* No interpolation by default. */ for (iChannel = 0; iChannel < pConfig->channels; iChannel += 1) { pGainer->pOldGains[iChannel] = 1; pGainer->pNewGains[iChannel] = 1; } return MA_SUCCESS; } MA_API ma_result ma_gainer_init(const ma_gainer_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_gainer* pGainer) { ma_result result; size_t heapSizeInBytes; void* pHeap; result = ma_gainer_get_heap_size(pConfig, &heapSizeInBytes); if (result != MA_SUCCESS) { return result; /* Failed to retrieve the size of the heap allocation. */ } if (heapSizeInBytes > 0) { pHeap = ma_malloc(heapSizeInBytes, pAllocationCallbacks); if (pHeap == NULL) { return MA_OUT_OF_MEMORY; } } else { pHeap = NULL; } result = ma_gainer_init_preallocated(pConfig, pHeap, pGainer); if (result != MA_SUCCESS) { ma_free(pHeap, pAllocationCallbacks); return result; } pGainer->_ownsHeap = MA_TRUE; return MA_SUCCESS; } MA_API void ma_gainer_uninit(ma_gainer* pGainer, const ma_allocation_callbacks* pAllocationCallbacks) { if (pGainer == NULL) { return; } if (pGainer->_ownsHeap) { ma_free(pGainer->_pHeap, pAllocationCallbacks); } } static float ma_gainer_calculate_current_gain(const ma_gainer* pGainer, ma_uint32 channel) { float a = (float)pGainer->t / pGainer->config.smoothTimeInFrames; return ma_mix_f32_fast(pGainer->pOldGains[channel], pGainer->pNewGains[channel], a); } static /*__attribute__((noinline))*/ ma_result ma_gainer_process_pcm_frames_internal(ma_gainer * pGainer, void* MA_RESTRICT pFramesOut, const void* MA_RESTRICT pFramesIn, ma_uint64 frameCount) { ma_uint64 iFrame; ma_uint32 iChannel; ma_uint64 interpolatedFrameCount; MA_ASSERT(pGainer != NULL); /* We don't necessarily need to apply a linear interpolation for the entire frameCount frames. When linear interpolation is not needed we can do a simple volume adjustment which will be more efficient than a lerp with an alpha value of 1. To do this, all we need to do is determine how many frames need to have a lerp applied. Then we just process that number of frames with linear interpolation. After that we run on an optimized path which just applies the new gains without a lerp. */ if (pGainer->t >= pGainer->config.smoothTimeInFrames) { interpolatedFrameCount = 0; } else { interpolatedFrameCount = pGainer->t - pGainer->config.smoothTimeInFrames; if (interpolatedFrameCount > frameCount) { interpolatedFrameCount = frameCount; } } /* Start off with our interpolated frames. When we do this, we'll adjust frameCount and our pointers so that the fast path can work naturally without consideration of the interpolated path. */ if (interpolatedFrameCount > 0) { /* We can allow the input and output buffers to be null in which case we'll just update the internal timer. */ if (pFramesOut != NULL && pFramesIn != NULL) { /* All we're really doing here is moving the old gains towards the new gains. We don't want to be modifying the gains inside the ma_gainer object because that will break things. Instead we can make a copy here on the stack. For extreme channel counts we can fall back to a slower implementation which just uses a standard lerp. */ float* pFramesOutF32 = (float*)pFramesOut; const float* pFramesInF32 = (const float*)pFramesIn; float a = (float)pGainer->t / pGainer->config.smoothTimeInFrames; float d = 1.0f / pGainer->config.smoothTimeInFrames; if (pGainer->config.channels <= 32) { float pRunningGain[32]; float pRunningGainDelta[32]; /* Could this be heap-allocated as part of the ma_gainer object? */ /* Initialize the running gain. */ for (iChannel = 0; iChannel < pGainer->config.channels; iChannel += 1) { float t = (pGainer->pNewGains[iChannel] - pGainer->pOldGains[iChannel]) * pGainer->masterVolume; pRunningGainDelta[iChannel] = t * d; pRunningGain[iChannel] = (pGainer->pOldGains[iChannel] * pGainer->masterVolume) + (t * a); } iFrame = 0; /* Optimized paths for common channel counts. This is mostly just experimenting with some SIMD ideas. It's not necessarily final. */ if (pGainer->config.channels == 2) { #if defined(MA_SUPPORT_SSE2) if (ma_has_sse2()) { ma_uint64 unrolledLoopCount = interpolatedFrameCount >> 1; /* Expand some arrays so we can have a clean SIMD loop below. */ __m128 runningGainDelta0 = _mm_set_ps(pRunningGainDelta[1], pRunningGainDelta[0], pRunningGainDelta[1], pRunningGainDelta[0]); __m128 runningGain0 = _mm_set_ps(pRunningGain[1] + pRunningGainDelta[1], pRunningGain[0] + pRunningGainDelta[0], pRunningGain[1], pRunningGain[0]); for (; iFrame < unrolledLoopCount; iFrame += 1) { _mm_storeu_ps(&pFramesOutF32[iFrame*4 + 0], _mm_mul_ps(_mm_loadu_ps(&pFramesInF32[iFrame*4 + 0]), runningGain0)); runningGain0 = _mm_add_ps(runningGain0, runningGainDelta0); } iFrame = unrolledLoopCount << 1; } else #endif { /* Two different scalar implementations here. Clang (and I assume GCC) will vectorize both of these, but the bottom version results in a nicer vectorization with less instructions emitted. The problem, however, is that the bottom version runs slower when compiled with MSVC. The top version will be partially vectorized by MSVC. */ #if defined(_MSC_VER) && !defined(__clang__) ma_uint64 unrolledLoopCount = interpolatedFrameCount >> 1; /* Expand some arrays so we can have a clean 4x SIMD operation in the loop. */ pRunningGainDelta[2] = pRunningGainDelta[0]; pRunningGainDelta[3] = pRunningGainDelta[1]; pRunningGain[2] = pRunningGain[0] + pRunningGainDelta[0]; pRunningGain[3] = pRunningGain[1] + pRunningGainDelta[1]; for (; iFrame < unrolledLoopCount; iFrame += 1) { pFramesOutF32[iFrame*4 + 0] = pFramesInF32[iFrame*4 + 0] * pRunningGain[0]; pFramesOutF32[iFrame*4 + 1] = pFramesInF32[iFrame*4 + 1] * pRunningGain[1]; pFramesOutF32[iFrame*4 + 2] = pFramesInF32[iFrame*4 + 2] * pRunningGain[2]; pFramesOutF32[iFrame*4 + 3] = pFramesInF32[iFrame*4 + 3] * pRunningGain[3]; /* Move the running gain forward towards the new gain. */ pRunningGain[0] += pRunningGainDelta[0]; pRunningGain[1] += pRunningGainDelta[1]; pRunningGain[2] += pRunningGainDelta[2]; pRunningGain[3] += pRunningGainDelta[3]; } iFrame = unrolledLoopCount << 1; #else for (; iFrame < interpolatedFrameCount; iFrame += 1) { for (iChannel = 0; iChannel < 2; iChannel += 1) { pFramesOutF32[iFrame*2 + iChannel] = pFramesInF32[iFrame*2 + iChannel] * pRunningGain[iChannel]; } for (iChannel = 0; iChannel < 2; iChannel += 1) { pRunningGain[iChannel] += pRunningGainDelta[iChannel]; } } #endif } } else if (pGainer->config.channels == 6) { #if defined(MA_SUPPORT_SSE2) if (ma_has_sse2()) { /* For 6 channels things are a bit more complicated because 6 isn't cleanly divisible by 4. We need to do 2 frames at a time, meaning we'll be doing 12 samples in a group. Like the stereo case we'll need to expand some arrays so we can do clean 4x SIMD operations. */ ma_uint64 unrolledLoopCount = interpolatedFrameCount >> 1; /* Expand some arrays so we can have a clean SIMD loop below. */ __m128 runningGainDelta0 = _mm_set_ps(pRunningGainDelta[3], pRunningGainDelta[2], pRunningGainDelta[1], pRunningGainDelta[0]); __m128 runningGainDelta1 = _mm_set_ps(pRunningGainDelta[1], pRunningGainDelta[0], pRunningGainDelta[5], pRunningGainDelta[4]); __m128 runningGainDelta2 = _mm_set_ps(pRunningGainDelta[5], pRunningGainDelta[4], pRunningGainDelta[3], pRunningGainDelta[2]); __m128 runningGain0 = _mm_set_ps(pRunningGain[3], pRunningGain[2], pRunningGain[1], pRunningGain[0]); __m128 runningGain1 = _mm_set_ps(pRunningGain[1] + pRunningGainDelta[1], pRunningGain[0] + pRunningGainDelta[0], pRunningGain[5], pRunningGain[4]); __m128 runningGain2 = _mm_set_ps(pRunningGain[5] + pRunningGainDelta[5], pRunningGain[4] + pRunningGainDelta[4], pRunningGain[3] + pRunningGainDelta[3], pRunningGain[2] + pRunningGainDelta[2]); for (; iFrame < unrolledLoopCount; iFrame += 1) { _mm_storeu_ps(&pFramesOutF32[iFrame*12 + 0], _mm_mul_ps(_mm_loadu_ps(&pFramesInF32[iFrame*12 + 0]), runningGain0)); _mm_storeu_ps(&pFramesOutF32[iFrame*12 + 4], _mm_mul_ps(_mm_loadu_ps(&pFramesInF32[iFrame*12 + 4]), runningGain1)); _mm_storeu_ps(&pFramesOutF32[iFrame*12 + 8], _mm_mul_ps(_mm_loadu_ps(&pFramesInF32[iFrame*12 + 8]), runningGain2)); runningGain0 = _mm_add_ps(runningGain0, runningGainDelta0); runningGain1 = _mm_add_ps(runningGain1, runningGainDelta1); runningGain2 = _mm_add_ps(runningGain2, runningGainDelta2); } iFrame = unrolledLoopCount << 1; } else #endif { for (; iFrame < interpolatedFrameCount; iFrame += 1) { for (iChannel = 0; iChannel < 6; iChannel += 1) { pFramesOutF32[iFrame*6 + iChannel] = pFramesInF32[iFrame*6 + iChannel] * pRunningGain[iChannel]; } /* Move the running gain forward towards the new gain. */ for (iChannel = 0; iChannel < 6; iChannel += 1) { pRunningGain[iChannel] += pRunningGainDelta[iChannel]; } } } } else if (pGainer->config.channels == 8) { /* For 8 channels we can just go over frame by frame and do all eight channels as 2 separate 4x SIMD operations. */ #if defined(MA_SUPPORT_SSE2) if (ma_has_sse2()) { __m128 runningGainDelta0 = _mm_loadu_ps(&pRunningGainDelta[0]); __m128 runningGainDelta1 = _mm_loadu_ps(&pRunningGainDelta[4]); __m128 runningGain0 = _mm_loadu_ps(&pRunningGain[0]); __m128 runningGain1 = _mm_loadu_ps(&pRunningGain[4]); for (; iFrame < interpolatedFrameCount; iFrame += 1) { _mm_storeu_ps(&pFramesOutF32[iFrame*8 + 0], _mm_mul_ps(_mm_loadu_ps(&pFramesInF32[iFrame*8 + 0]), runningGain0)); _mm_storeu_ps(&pFramesOutF32[iFrame*8 + 4], _mm_mul_ps(_mm_loadu_ps(&pFramesInF32[iFrame*8 + 4]), runningGain1)); runningGain0 = _mm_add_ps(runningGain0, runningGainDelta0); runningGain1 = _mm_add_ps(runningGain1, runningGainDelta1); } } else #endif { /* This is crafted so that it auto-vectorizes when compiled with Clang. */ for (; iFrame < interpolatedFrameCount; iFrame += 1) { for (iChannel = 0; iChannel < 8; iChannel += 1) { pFramesOutF32[iFrame*8 + iChannel] = pFramesInF32[iFrame*8 + iChannel] * pRunningGain[iChannel]; } /* Move the running gain forward towards the new gain. */ for (iChannel = 0; iChannel < 8; iChannel += 1) { pRunningGain[iChannel] += pRunningGainDelta[iChannel]; } } } } for (; iFrame < interpolatedFrameCount; iFrame += 1) { for (iChannel = 0; iChannel < pGainer->config.channels; iChannel += 1) { pFramesOutF32[iFrame*pGainer->config.channels + iChannel] = pFramesInF32[iFrame*pGainer->config.channels + iChannel] * pRunningGain[iChannel]; pRunningGain[iChannel] += pRunningGainDelta[iChannel]; } } } else { /* Slower path for extreme channel counts where we can't fit enough on the stack. We could also move this to the heap as part of the ma_gainer object which might even be better since it'll only be updated when the gains actually change. */ for (iFrame = 0; iFrame < interpolatedFrameCount; iFrame += 1) { for (iChannel = 0; iChannel < pGainer->config.channels; iChannel += 1) { pFramesOutF32[iFrame*pGainer->config.channels + iChannel] = pFramesInF32[iFrame*pGainer->config.channels + iChannel] * ma_mix_f32_fast(pGainer->pOldGains[iChannel], pGainer->pNewGains[iChannel], a) * pGainer->masterVolume; } a += d; } } } /* Make sure the timer is updated. */ pGainer->t = (ma_uint32)ma_min(pGainer->t + interpolatedFrameCount, pGainer->config.smoothTimeInFrames); /* Adjust our arguments so the next part can work normally. */ frameCount -= interpolatedFrameCount; pFramesOut = ma_offset_ptr(pFramesOut, interpolatedFrameCount * sizeof(float)); pFramesIn = ma_offset_ptr(pFramesIn, interpolatedFrameCount * sizeof(float)); } /* All we need to do here is apply the new gains using an optimized path. */ if (pFramesOut != NULL && pFramesIn != NULL) { if (pGainer->config.channels <= 32) { float gains[32]; for (iChannel = 0; iChannel < pGainer->config.channels; iChannel += 1) { gains[iChannel] = pGainer->pNewGains[iChannel] * pGainer->masterVolume; } ma_copy_and_apply_volume_factor_per_channel_f32((float*)pFramesOut, (const float*)pFramesIn, frameCount, pGainer->config.channels, gains); } else { /* Slow path. Too many channels to fit on the stack. Need to apply a master volume as a separate path. */ for (iFrame = 0; iFrame < frameCount; iFrame += 1) { for (iChannel = 0; iChannel < pGainer->config.channels; iChannel += 1) { ((float*)pFramesOut)[iFrame*pGainer->config.channels + iChannel] = ((const float*)pFramesIn)[iFrame*pGainer->config.channels + iChannel] * pGainer->pNewGains[iChannel] * pGainer->masterVolume; } } } } /* Now that some frames have been processed we need to make sure future changes to the gain are interpolated. */ if (pGainer->t == (ma_uint32)-1) { pGainer->t = (ma_uint32)ma_min(pGainer->config.smoothTimeInFrames, frameCount); } #if 0 if (pGainer->t >= pGainer->config.smoothTimeInFrames) { /* Fast path. No gain calculation required. */ ma_copy_and_apply_volume_factor_per_channel_f32(pFramesOutF32, pFramesInF32, frameCount, pGainer->config.channels, pGainer->pNewGains); ma_apply_volume_factor_f32(pFramesOutF32, frameCount * pGainer->config.channels, pGainer->masterVolume); /* Now that some frames have been processed we need to make sure future changes to the gain are interpolated. */ if (pGainer->t == (ma_uint32)-1) { pGainer->t = pGainer->config.smoothTimeInFrames; } } else { /* Slow path. Need to interpolate the gain for each channel individually. */ /* We can allow the input and output buffers to be null in which case we'll just update the internal timer. */ if (pFramesOut != NULL && pFramesIn != NULL) { float a = (float)pGainer->t / pGainer->config.smoothTimeInFrames; float d = 1.0f / pGainer->config.smoothTimeInFrames; ma_uint32 channelCount = pGainer->config.channels; for (iFrame = 0; iFrame < frameCount; iFrame += 1) { for (iChannel = 0; iChannel < channelCount; iChannel += 1) { pFramesOutF32[iChannel] = pFramesInF32[iChannel] * ma_mix_f32_fast(pGainer->pOldGains[iChannel], pGainer->pNewGains[iChannel], a) * pGainer->masterVolume; } pFramesOutF32 += channelCount; pFramesInF32 += channelCount; a += d; if (a > 1) { a = 1; } } } pGainer->t = (ma_uint32)ma_min(pGainer->t + frameCount, pGainer->config.smoothTimeInFrames); #if 0 /* Reference implementation. */ for (iFrame = 0; iFrame < frameCount; iFrame += 1) { /* We can allow the input and output buffers to be null in which case we'll just update the internal timer. */ if (pFramesOut != NULL && pFramesIn != NULL) { for (iChannel = 0; iChannel < pGainer->config.channels; iChannel += 1) { pFramesOutF32[iFrame * pGainer->config.channels + iChannel] = pFramesInF32[iFrame * pGainer->config.channels + iChannel] * ma_gainer_calculate_current_gain(pGainer, iChannel) * pGainer->masterVolume; } } /* Move interpolation time forward, but don't go beyond our smoothing time. */ pGainer->t = ma_min(pGainer->t + 1, pGainer->config.smoothTimeInFrames); } #endif } #endif return MA_SUCCESS; } MA_API ma_result ma_gainer_process_pcm_frames(ma_gainer* pGainer, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount) { if (pGainer == NULL) { return MA_INVALID_ARGS; } /* ma_gainer_process_pcm_frames_internal() marks pFramesOut and pFramesIn with MA_RESTRICT which helps with auto-vectorization. */ return ma_gainer_process_pcm_frames_internal(pGainer, pFramesOut, pFramesIn, frameCount); } static void ma_gainer_set_gain_by_index(ma_gainer* pGainer, float newGain, ma_uint32 iChannel) { pGainer->pOldGains[iChannel] = ma_gainer_calculate_current_gain(pGainer, iChannel); pGainer->pNewGains[iChannel] = newGain; } static void ma_gainer_reset_smoothing_time(ma_gainer* pGainer) { if (pGainer->t == (ma_uint32)-1) { pGainer->t = pGainer->config.smoothTimeInFrames; /* No smoothing required for initial gains setting. */ } else { pGainer->t = 0; } } MA_API ma_result ma_gainer_set_gain(ma_gainer* pGainer, float newGain) { ma_uint32 iChannel; if (pGainer == NULL) { return MA_INVALID_ARGS; } for (iChannel = 0; iChannel < pGainer->config.channels; iChannel += 1) { ma_gainer_set_gain_by_index(pGainer, newGain, iChannel); } /* The smoothing time needs to be reset to ensure we always interpolate by the configured smoothing time, but only if it's not the first setting. */ ma_gainer_reset_smoothing_time(pGainer); return MA_SUCCESS; } MA_API ma_result ma_gainer_set_gains(ma_gainer* pGainer, float* pNewGains) { ma_uint32 iChannel; if (pGainer == NULL || pNewGains == NULL) { return MA_INVALID_ARGS; } for (iChannel = 0; iChannel < pGainer->config.channels; iChannel += 1) { ma_gainer_set_gain_by_index(pGainer, pNewGains[iChannel], iChannel); } /* The smoothing time needs to be reset to ensure we always interpolate by the configured smoothing time, but only if it's not the first setting. */ ma_gainer_reset_smoothing_time(pGainer); return MA_SUCCESS; } MA_API ma_result ma_gainer_set_master_volume(ma_gainer* pGainer, float volume) { if (pGainer == NULL) { return MA_INVALID_ARGS; } pGainer->masterVolume = volume; return MA_SUCCESS; } MA_API ma_result ma_gainer_get_master_volume(const ma_gainer* pGainer, float* pVolume) { if (pGainer == NULL || pVolume == NULL) { return MA_INVALID_ARGS; } *pVolume = pGainer->masterVolume; return MA_SUCCESS; } MA_API ma_panner_config ma_panner_config_init(ma_format format, ma_uint32 channels) { ma_panner_config config; MA_ZERO_OBJECT(&config); config.format = format; config.channels = channels; config.mode = ma_pan_mode_balance; /* Set to balancing mode by default because it's consistent with other audio engines and most likely what the caller is expecting. */ config.pan = 0; return config; } MA_API ma_result ma_panner_init(const ma_panner_config* pConfig, ma_panner* pPanner) { if (pPanner == NULL) { return MA_INVALID_ARGS; } MA_ZERO_OBJECT(pPanner); if (pConfig == NULL) { return MA_INVALID_ARGS; } pPanner->format = pConfig->format; pPanner->channels = pConfig->channels; pPanner->mode = pConfig->mode; pPanner->pan = pConfig->pan; return MA_SUCCESS; } static void ma_stereo_balance_pcm_frames_f32(float* pFramesOut, const float* pFramesIn, ma_uint64 frameCount, float pan) { ma_uint64 iFrame; if (pan > 0) { float factor = 1.0f - pan; if (pFramesOut == pFramesIn) { for (iFrame = 0; iFrame < frameCount; iFrame += 1) { pFramesOut[iFrame*2 + 0] = pFramesIn[iFrame*2 + 0] * factor; } } else { for (iFrame = 0; iFrame < frameCount; iFrame += 1) { pFramesOut[iFrame*2 + 0] = pFramesIn[iFrame*2 + 0] * factor; pFramesOut[iFrame*2 + 1] = pFramesIn[iFrame*2 + 1]; } } } else { float factor = 1.0f + pan; if (pFramesOut == pFramesIn) { for (iFrame = 0; iFrame < frameCount; iFrame += 1) { pFramesOut[iFrame*2 + 1] = pFramesIn[iFrame*2 + 1] * factor; } } else { for (iFrame = 0; iFrame < frameCount; iFrame += 1) { pFramesOut[iFrame*2 + 0] = pFramesIn[iFrame*2 + 0]; pFramesOut[iFrame*2 + 1] = pFramesIn[iFrame*2 + 1] * factor; } } } } static void ma_stereo_balance_pcm_frames(void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount, ma_format format, float pan) { if (pan == 0) { /* Fast path. No panning required. */ if (pFramesOut == pFramesIn) { /* No-op */ } else { ma_copy_pcm_frames(pFramesOut, pFramesIn, frameCount, format, 2); } return; } switch (format) { case ma_format_f32: ma_stereo_balance_pcm_frames_f32((float*)pFramesOut, (float*)pFramesIn, frameCount, pan); break; /* Unknown format. Just copy. */ default: { ma_copy_pcm_frames(pFramesOut, pFramesIn, frameCount, format, 2); } break; } } static void ma_stereo_pan_pcm_frames_f32(float* pFramesOut, const float* pFramesIn, ma_uint64 frameCount, float pan) { ma_uint64 iFrame; if (pan > 0) { float factorL0 = 1.0f - pan; float factorL1 = 0.0f + pan; for (iFrame = 0; iFrame < frameCount; iFrame += 1) { float sample0 = (pFramesIn[iFrame*2 + 0] * factorL0); float sample1 = (pFramesIn[iFrame*2 + 0] * factorL1) + pFramesIn[iFrame*2 + 1]; pFramesOut[iFrame*2 + 0] = sample0; pFramesOut[iFrame*2 + 1] = sample1; } } else { float factorR0 = 0.0f - pan; float factorR1 = 1.0f + pan; for (iFrame = 0; iFrame < frameCount; iFrame += 1) { float sample0 = pFramesIn[iFrame*2 + 0] + (pFramesIn[iFrame*2 + 1] * factorR0); float sample1 = (pFramesIn[iFrame*2 + 1] * factorR1); pFramesOut[iFrame*2 + 0] = sample0; pFramesOut[iFrame*2 + 1] = sample1; } } } static void ma_stereo_pan_pcm_frames(void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount, ma_format format, float pan) { if (pan == 0) { /* Fast path. No panning required. */ if (pFramesOut == pFramesIn) { /* No-op */ } else { ma_copy_pcm_frames(pFramesOut, pFramesIn, frameCount, format, 2); } return; } switch (format) { case ma_format_f32: ma_stereo_pan_pcm_frames_f32((float*)pFramesOut, (float*)pFramesIn, frameCount, pan); break; /* Unknown format. Just copy. */ default: { ma_copy_pcm_frames(pFramesOut, pFramesIn, frameCount, format, 2); } break; } } MA_API ma_result ma_panner_process_pcm_frames(ma_panner* pPanner, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount) { if (pPanner == NULL || pFramesOut == NULL || pFramesIn == NULL) { return MA_INVALID_ARGS; } if (pPanner->channels == 2) { /* Stereo case. For now assume channel 0 is left and channel right is 1, but should probably add support for a channel map. */ if (pPanner->mode == ma_pan_mode_balance) { ma_stereo_balance_pcm_frames(pFramesOut, pFramesIn, frameCount, pPanner->format, pPanner->pan); } else { ma_stereo_pan_pcm_frames(pFramesOut, pFramesIn, frameCount, pPanner->format, pPanner->pan); } } else { if (pPanner->channels == 1) { /* Panning has no effect on mono streams. */ ma_copy_pcm_frames(pFramesOut, pFramesIn, frameCount, pPanner->format, pPanner->channels); } else { /* For now we're not going to support non-stereo set ups. Not sure how I want to handle this case just yet. */ ma_copy_pcm_frames(pFramesOut, pFramesIn, frameCount, pPanner->format, pPanner->channels); } } return MA_SUCCESS; } MA_API void ma_panner_set_mode(ma_panner* pPanner, ma_pan_mode mode) { if (pPanner == NULL) { return; } pPanner->mode = mode; } MA_API ma_pan_mode ma_panner_get_mode(const ma_panner* pPanner) { if (pPanner == NULL) { return ma_pan_mode_balance; } return pPanner->mode; } MA_API void ma_panner_set_pan(ma_panner* pPanner, float pan) { if (pPanner == NULL) { return; } pPanner->pan = ma_clamp(pan, -1.0f, 1.0f); } MA_API float ma_panner_get_pan(const ma_panner* pPanner) { if (pPanner == NULL) { return 0; } return pPanner->pan; } MA_API ma_fader_config ma_fader_config_init(ma_format format, ma_uint32 channels, ma_uint32 sampleRate) { ma_fader_config config; MA_ZERO_OBJECT(&config); config.format = format; config.channels = channels; config.sampleRate = sampleRate; return config; } MA_API ma_result ma_fader_init(const ma_fader_config* pConfig, ma_fader* pFader) { if (pFader == NULL) { return MA_INVALID_ARGS; } MA_ZERO_OBJECT(pFader); if (pConfig == NULL) { return MA_INVALID_ARGS; } /* Only f32 is supported for now. */ if (pConfig->format != ma_format_f32) { return MA_INVALID_ARGS; } pFader->config = *pConfig; pFader->volumeBeg = 1; pFader->volumeEnd = 1; pFader->lengthInFrames = 0; pFader->cursorInFrames = 0; return MA_SUCCESS; } MA_API ma_result ma_fader_process_pcm_frames(ma_fader* pFader, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount) { if (pFader == NULL) { return MA_INVALID_ARGS; } /* If the cursor is still negative we need to just copy the absolute number of those frames, but no more than frameCount. */ if (pFader->cursorInFrames < 0) { ma_uint64 absCursorInFrames = (ma_uint64)0 - pFader->cursorInFrames; if (absCursorInFrames > frameCount) { absCursorInFrames = frameCount; } ma_copy_pcm_frames(pFramesOut, pFramesIn, absCursorInFrames, pFader->config.format, pFader->config.channels); pFader->cursorInFrames += absCursorInFrames; frameCount -= absCursorInFrames; pFramesOut = ma_offset_ptr(pFramesOut, ma_get_bytes_per_frame(pFader->config.format, pFader->config.channels)*absCursorInFrames); pFramesIn = ma_offset_ptr(pFramesIn, ma_get_bytes_per_frame(pFader->config.format, pFader->config.channels)*absCursorInFrames); } if (pFader->cursorInFrames >= 0) { /* For now we need to clamp frameCount so that the cursor never overflows 32-bits. This is required for the conversion to a float which we use for the linear interpolation. This might be changed later. */ if (frameCount + pFader->cursorInFrames > UINT_MAX) { frameCount = UINT_MAX - pFader->cursorInFrames; } /* Optimized path if volumeBeg and volumeEnd are equal. */ if (pFader->volumeBeg == pFader->volumeEnd) { if (pFader->volumeBeg == 1) { /* Straight copy. */ ma_copy_pcm_frames(pFramesOut, pFramesIn, frameCount, pFader->config.format, pFader->config.channels); } else { /* Copy with volume. */ ma_copy_and_apply_volume_and_clip_pcm_frames(pFramesOut, pFramesIn, frameCount, pFader->config.format, pFader->config.channels, pFader->volumeBeg); } } else { /* Slower path. Volumes are different, so may need to do an interpolation. */ if ((ma_uint64)pFader->cursorInFrames >= pFader->lengthInFrames) { /* Fast path. We've gone past the end of the fade period so just apply the end volume to all samples. */ ma_copy_and_apply_volume_and_clip_pcm_frames(pFramesOut, pFramesIn, frameCount, pFader->config.format, pFader->config.channels, pFader->volumeEnd); } else { /* Slow path. This is where we do the actual fading. */ ma_uint64 iFrame; ma_uint32 iChannel; /* For now we only support f32. Support for other formats might be added later. */ if (pFader->config.format == ma_format_f32) { const float* pFramesInF32 = (const float*)pFramesIn; /* */ float* pFramesOutF32 = ( float*)pFramesOut; for (iFrame = 0; iFrame < frameCount; iFrame += 1) { float a = (ma_uint32)ma_min(pFader->cursorInFrames + iFrame, pFader->lengthInFrames) / (float)((ma_uint32)pFader->lengthInFrames); /* Safe cast due to the frameCount clamp at the top of this function. */ float volume = ma_mix_f32_fast(pFader->volumeBeg, pFader->volumeEnd, a); for (iChannel = 0; iChannel < pFader->config.channels; iChannel += 1) { pFramesOutF32[iFrame*pFader->config.channels + iChannel] = pFramesInF32[iFrame*pFader->config.channels + iChannel] * volume; } } } else { return MA_NOT_IMPLEMENTED; } } } } pFader->cursorInFrames += frameCount; return MA_SUCCESS; } MA_API void ma_fader_get_data_format(const ma_fader* pFader, ma_format* pFormat, ma_uint32* pChannels, ma_uint32* pSampleRate) { if (pFader == NULL) { return; } if (pFormat != NULL) { *pFormat = pFader->config.format; } if (pChannels != NULL) { *pChannels = pFader->config.channels; } if (pSampleRate != NULL) { *pSampleRate = pFader->config.sampleRate; } } MA_API void ma_fader_set_fade(ma_fader* pFader, float volumeBeg, float volumeEnd, ma_uint64 lengthInFrames) { ma_fader_set_fade_ex(pFader, volumeBeg, volumeEnd, lengthInFrames, 0); } MA_API void ma_fader_set_fade_ex(ma_fader* pFader, float volumeBeg, float volumeEnd, ma_uint64 lengthInFrames, ma_int64 startOffsetInFrames) { if (pFader == NULL) { return; } /* If the volume is negative, use current volume. */ if (volumeBeg < 0) { volumeBeg = ma_fader_get_current_volume(pFader); } /* The length needs to be clamped to 32-bits due to how we convert it to a float for linear interpolation reasons. I might change this requirement later, but for now it's not important. */ if (lengthInFrames > UINT_MAX) { lengthInFrames = UINT_MAX; } /* The start offset needs to be clamped to ensure it doesn't overflow a signed number. */ if (startOffsetInFrames > INT_MAX) { startOffsetInFrames = INT_MAX; } pFader->volumeBeg = volumeBeg; pFader->volumeEnd = volumeEnd; pFader->lengthInFrames = lengthInFrames; pFader->cursorInFrames = -startOffsetInFrames; } MA_API float ma_fader_get_current_volume(const ma_fader* pFader) { if (pFader == NULL) { return 0.0f; } /* Any frames prior to the start of the fade period will be at unfaded volume. */ if (pFader->cursorInFrames < 0) { return 1.0f; } /* The current volume depends on the position of the cursor. */ if (pFader->cursorInFrames == 0) { return pFader->volumeBeg; } else if ((ma_uint64)pFader->cursorInFrames >= pFader->lengthInFrames) { /* Safe case because the < 0 case was checked above. */ return pFader->volumeEnd; } else { /* The cursor is somewhere inside the fading period. We can figure this out with a simple linear interpoluation between volumeBeg and volumeEnd based on our cursor position. */ return ma_mix_f32_fast(pFader->volumeBeg, pFader->volumeEnd, (ma_uint32)pFader->cursorInFrames / (float)((ma_uint32)pFader->lengthInFrames)); /* Safe cast to uint32 because we clamp it in ma_fader_process_pcm_frames(). */ } } MA_API ma_vec3f ma_vec3f_init_3f(float x, float y, float z) { ma_vec3f v; v.x = x; v.y = y; v.z = z; return v; } MA_API ma_vec3f ma_vec3f_sub(ma_vec3f a, ma_vec3f b) { return ma_vec3f_init_3f( a.x - b.x, a.y - b.y, a.z - b.z ); } MA_API ma_vec3f ma_vec3f_neg(ma_vec3f a) { return ma_vec3f_init_3f( -a.x, -a.y, -a.z ); } MA_API float ma_vec3f_dot(ma_vec3f a, ma_vec3f b) { return a.x*b.x + a.y*b.y + a.z*b.z; } MA_API float ma_vec3f_len2(ma_vec3f v) { return ma_vec3f_dot(v, v); } MA_API float ma_vec3f_len(ma_vec3f v) { return (float)ma_sqrtd(ma_vec3f_len2(v)); } MA_API float ma_vec3f_dist(ma_vec3f a, ma_vec3f b) { return ma_vec3f_len(ma_vec3f_sub(a, b)); } MA_API ma_vec3f ma_vec3f_normalize(ma_vec3f v) { float invLen; float len2 = ma_vec3f_len2(v); if (len2 == 0) { return ma_vec3f_init_3f(0, 0, 0); } invLen = ma_rsqrtf(len2); v.x *= invLen; v.y *= invLen; v.z *= invLen; return v; } MA_API ma_vec3f ma_vec3f_cross(ma_vec3f a, ma_vec3f b) { return ma_vec3f_init_3f( a.y*b.z - a.z*b.y, a.z*b.x - a.x*b.z, a.x*b.y - a.y*b.x ); } MA_API void ma_atomic_vec3f_init(ma_atomic_vec3f* v, ma_vec3f value) { v->v = value; v->lock = 0; /* Important this is initialized to 0. */ } MA_API void ma_atomic_vec3f_set(ma_atomic_vec3f* v, ma_vec3f value) { ma_spinlock_lock(&v->lock); { v->v = value; } ma_spinlock_unlock(&v->lock); } MA_API ma_vec3f ma_atomic_vec3f_get(ma_atomic_vec3f* v) { ma_vec3f r; ma_spinlock_lock(&v->lock); { r = v->v; } ma_spinlock_unlock(&v->lock); return r; } static void ma_channel_map_apply_f32(float* pFramesOut, const ma_channel* pChannelMapOut, ma_uint32 channelsOut, const float* pFramesIn, const ma_channel* pChannelMapIn, ma_uint32 channelsIn, ma_uint64 frameCount, ma_channel_mix_mode mode, ma_mono_expansion_mode monoExpansionMode); static ma_bool32 ma_is_spatial_channel_position(ma_channel channelPosition); #ifndef MA_DEFAULT_SPEED_OF_SOUND #define MA_DEFAULT_SPEED_OF_SOUND 343.3f #endif /* These vectors represent the direction that speakers are facing from the center point. They're used for panning in the spatializer. Must be normalized. */ static ma_vec3f g_maChannelDirections[MA_CHANNEL_POSITION_COUNT] = { { 0.0f, 0.0f, -1.0f }, /* MA_CHANNEL_NONE */ { 0.0f, 0.0f, -1.0f }, /* MA_CHANNEL_MONO */ {-0.7071f, 0.0f, -0.7071f }, /* MA_CHANNEL_FRONT_LEFT */ {+0.7071f, 0.0f, -0.7071f }, /* MA_CHANNEL_FRONT_RIGHT */ { 0.0f, 0.0f, -1.0f }, /* MA_CHANNEL_FRONT_CENTER */ { 0.0f, 0.0f, -1.0f }, /* MA_CHANNEL_LFE */ {-0.7071f, 0.0f, +0.7071f }, /* MA_CHANNEL_BACK_LEFT */ {+0.7071f, 0.0f, +0.7071f }, /* MA_CHANNEL_BACK_RIGHT */ {-0.3162f, 0.0f, -0.9487f }, /* MA_CHANNEL_FRONT_LEFT_CENTER */ {+0.3162f, 0.0f, -0.9487f }, /* MA_CHANNEL_FRONT_RIGHT_CENTER */ { 0.0f, 0.0f, +1.0f }, /* MA_CHANNEL_BACK_CENTER */ {-1.0f, 0.0f, 0.0f }, /* MA_CHANNEL_SIDE_LEFT */ {+1.0f, 0.0f, 0.0f }, /* MA_CHANNEL_SIDE_RIGHT */ { 0.0f, +1.0f, 0.0f }, /* MA_CHANNEL_TOP_CENTER */ {-0.5774f, +0.5774f, -0.5774f }, /* MA_CHANNEL_TOP_FRONT_LEFT */ { 0.0f, +0.7071f, -0.7071f }, /* MA_CHANNEL_TOP_FRONT_CENTER */ {+0.5774f, +0.5774f, -0.5774f }, /* MA_CHANNEL_TOP_FRONT_RIGHT */ {-0.5774f, +0.5774f, +0.5774f }, /* MA_CHANNEL_TOP_BACK_LEFT */ { 0.0f, +0.7071f, +0.7071f }, /* MA_CHANNEL_TOP_BACK_CENTER */ {+0.5774f, +0.5774f, +0.5774f }, /* MA_CHANNEL_TOP_BACK_RIGHT */ { 0.0f, 0.0f, -1.0f }, /* MA_CHANNEL_AUX_0 */ { 0.0f, 0.0f, -1.0f }, /* MA_CHANNEL_AUX_1 */ { 0.0f, 0.0f, -1.0f }, /* MA_CHANNEL_AUX_2 */ { 0.0f, 0.0f, -1.0f }, /* MA_CHANNEL_AUX_3 */ { 0.0f, 0.0f, -1.0f }, /* MA_CHANNEL_AUX_4 */ { 0.0f, 0.0f, -1.0f }, /* MA_CHANNEL_AUX_5 */ { 0.0f, 0.0f, -1.0f }, /* MA_CHANNEL_AUX_6 */ { 0.0f, 0.0f, -1.0f }, /* MA_CHANNEL_AUX_7 */ { 0.0f, 0.0f, -1.0f }, /* MA_CHANNEL_AUX_8 */ { 0.0f, 0.0f, -1.0f }, /* MA_CHANNEL_AUX_9 */ { 0.0f, 0.0f, -1.0f }, /* MA_CHANNEL_AUX_10 */ { 0.0f, 0.0f, -1.0f }, /* MA_CHANNEL_AUX_11 */ { 0.0f, 0.0f, -1.0f }, /* MA_CHANNEL_AUX_12 */ { 0.0f, 0.0f, -1.0f }, /* MA_CHANNEL_AUX_13 */ { 0.0f, 0.0f, -1.0f }, /* MA_CHANNEL_AUX_14 */ { 0.0f, 0.0f, -1.0f }, /* MA_CHANNEL_AUX_15 */ { 0.0f, 0.0f, -1.0f }, /* MA_CHANNEL_AUX_16 */ { 0.0f, 0.0f, -1.0f }, /* MA_CHANNEL_AUX_17 */ { 0.0f, 0.0f, -1.0f }, /* MA_CHANNEL_AUX_18 */ { 0.0f, 0.0f, -1.0f }, /* MA_CHANNEL_AUX_19 */ { 0.0f, 0.0f, -1.0f }, /* MA_CHANNEL_AUX_20 */ { 0.0f, 0.0f, -1.0f }, /* MA_CHANNEL_AUX_21 */ { 0.0f, 0.0f, -1.0f }, /* MA_CHANNEL_AUX_22 */ { 0.0f, 0.0f, -1.0f }, /* MA_CHANNEL_AUX_23 */ { 0.0f, 0.0f, -1.0f }, /* MA_CHANNEL_AUX_24 */ { 0.0f, 0.0f, -1.0f }, /* MA_CHANNEL_AUX_25 */ { 0.0f, 0.0f, -1.0f }, /* MA_CHANNEL_AUX_26 */ { 0.0f, 0.0f, -1.0f }, /* MA_CHANNEL_AUX_27 */ { 0.0f, 0.0f, -1.0f }, /* MA_CHANNEL_AUX_28 */ { 0.0f, 0.0f, -1.0f }, /* MA_CHANNEL_AUX_29 */ { 0.0f, 0.0f, -1.0f }, /* MA_CHANNEL_AUX_30 */ { 0.0f, 0.0f, -1.0f } /* MA_CHANNEL_AUX_31 */ }; static ma_vec3f ma_get_channel_direction(ma_channel channel) { if (channel >= MA_CHANNEL_POSITION_COUNT) { return ma_vec3f_init_3f(0, 0, -1); } else { return g_maChannelDirections[channel]; } } static float ma_attenuation_inverse(float distance, float minDistance, float maxDistance, float rolloff) { if (minDistance >= maxDistance) { return 1; /* To avoid division by zero. Do not attenuate. */ } return minDistance / (minDistance + rolloff * (ma_clamp(distance, minDistance, maxDistance) - minDistance)); } static float ma_attenuation_linear(float distance, float minDistance, float maxDistance, float rolloff) { if (minDistance >= maxDistance) { return 1; /* To avoid division by zero. Do not attenuate. */ } return 1 - rolloff * (ma_clamp(distance, minDistance, maxDistance) - minDistance) / (maxDistance - minDistance); } static float ma_attenuation_exponential(float distance, float minDistance, float maxDistance, float rolloff) { if (minDistance >= maxDistance) { return 1; /* To avoid division by zero. Do not attenuate. */ } return (float)ma_powd(ma_clamp(distance, minDistance, maxDistance) / minDistance, -rolloff); } /* Dopper Effect calculation taken from the OpenAL spec, with two main differences: 1) The source to listener vector will have already been calcualted at an earlier step so we can just use that directly. We need only the position of the source relative to the origin. 2) We don't scale by a frequency because we actually just want the ratio which we'll plug straight into the resampler directly. */ static float ma_doppler_pitch(ma_vec3f relativePosition, ma_vec3f sourceVelocity, ma_vec3f listenVelocity, float speedOfSound, float dopplerFactor) { float len; float vls; float vss; len = ma_vec3f_len(relativePosition); /* There's a case where the position of the source will be right on top of the listener in which case the length will be 0 and we'll end up with a division by zero. We can just return a ratio of 1.0 in this case. This is not considered in the OpenAL spec, but is necessary. */ if (len == 0) { return 1.0; } vls = ma_vec3f_dot(relativePosition, listenVelocity) / len; vss = ma_vec3f_dot(relativePosition, sourceVelocity) / len; vls = ma_min(vls, speedOfSound / dopplerFactor); vss = ma_min(vss, speedOfSound / dopplerFactor); return (speedOfSound - dopplerFactor*vls) / (speedOfSound - dopplerFactor*vss); } static void ma_get_default_channel_map_for_spatializer(ma_channel* pChannelMap, size_t channelMapCap, ma_uint32 channelCount) { /* Special case for stereo. Want to default the left and right speakers to side left and side right so that they're facing directly down the X axis rather than slightly forward. Not doing this will result in sounds being quieter when behind the listener. This might actually be good for some scenerios, but I don't think it's an appropriate default because it can be a bit unexpected. */ if (channelCount == 2) { pChannelMap[0] = MA_CHANNEL_SIDE_LEFT; pChannelMap[1] = MA_CHANNEL_SIDE_RIGHT; } else { ma_channel_map_init_standard(ma_standard_channel_map_default, pChannelMap, channelMapCap, channelCount); } } MA_API ma_spatializer_listener_config ma_spatializer_listener_config_init(ma_uint32 channelsOut) { ma_spatializer_listener_config config; MA_ZERO_OBJECT(&config); config.channelsOut = channelsOut; config.pChannelMapOut = NULL; config.handedness = ma_handedness_right; config.worldUp = ma_vec3f_init_3f(0, 1, 0); config.coneInnerAngleInRadians = 6.283185f; /* 360 degrees. */ config.coneOuterAngleInRadians = 6.283185f; /* 360 degrees. */ config.coneOuterGain = 0; config.speedOfSound = 343.3f; /* Same as OpenAL. Used for doppler effect. */ return config; } typedef struct { size_t sizeInBytes; size_t channelMapOutOffset; } ma_spatializer_listener_heap_layout; static ma_result ma_spatializer_listener_get_heap_layout(const ma_spatializer_listener_config* pConfig, ma_spatializer_listener_heap_layout* pHeapLayout) { MA_ASSERT(pHeapLayout != NULL); MA_ZERO_OBJECT(pHeapLayout); if (pConfig == NULL) { return MA_INVALID_ARGS; } if (pConfig->channelsOut == 0) { return MA_INVALID_ARGS; } pHeapLayout->sizeInBytes = 0; /* Channel map. We always need this, even for passthroughs. */ pHeapLayout->channelMapOutOffset = pHeapLayout->sizeInBytes; pHeapLayout->sizeInBytes += ma_align_64(sizeof(*pConfig->pChannelMapOut) * pConfig->channelsOut); return MA_SUCCESS; } MA_API ma_result ma_spatializer_listener_get_heap_size(const ma_spatializer_listener_config* pConfig, size_t* pHeapSizeInBytes) { ma_result result; ma_spatializer_listener_heap_layout heapLayout; if (pHeapSizeInBytes == NULL) { return MA_INVALID_ARGS; } *pHeapSizeInBytes = 0; result = ma_spatializer_listener_get_heap_layout(pConfig, &heapLayout); if (result != MA_SUCCESS) { return result; } *pHeapSizeInBytes = heapLayout.sizeInBytes; return MA_SUCCESS; } MA_API ma_result ma_spatializer_listener_init_preallocated(const ma_spatializer_listener_config* pConfig, void* pHeap, ma_spatializer_listener* pListener) { ma_result result; ma_spatializer_listener_heap_layout heapLayout; if (pListener == NULL) { return MA_INVALID_ARGS; } MA_ZERO_OBJECT(pListener); result = ma_spatializer_listener_get_heap_layout(pConfig, &heapLayout); if (result != MA_SUCCESS) { return result; } pListener->_pHeap = pHeap; MA_ZERO_MEMORY(pHeap, heapLayout.sizeInBytes); pListener->config = *pConfig; ma_atomic_vec3f_init(&pListener->position, ma_vec3f_init_3f(0, 0, 0)); ma_atomic_vec3f_init(&pListener->direction, ma_vec3f_init_3f(0, 0, -1)); ma_atomic_vec3f_init(&pListener->velocity, ma_vec3f_init_3f(0, 0, 0)); pListener->isEnabled = MA_TRUE; /* Swap the forward direction if we're left handed (it was initialized based on right handed). */ if (pListener->config.handedness == ma_handedness_left) { ma_vec3f negDir = ma_vec3f_neg(ma_spatializer_listener_get_direction(pListener)); ma_spatializer_listener_set_direction(pListener, negDir.x, negDir.y, negDir.z); } /* We must always have a valid channel map. */ pListener->config.pChannelMapOut = (ma_channel*)ma_offset_ptr(pHeap, heapLayout.channelMapOutOffset); /* Use a slightly different default channel map for stereo. */ if (pConfig->pChannelMapOut == NULL) { ma_get_default_channel_map_for_spatializer(pListener->config.pChannelMapOut, pConfig->channelsOut, pConfig->channelsOut); } else { ma_channel_map_copy_or_default(pListener->config.pChannelMapOut, pConfig->channelsOut, pConfig->pChannelMapOut, pConfig->channelsOut); } return MA_SUCCESS; } MA_API ma_result ma_spatializer_listener_init(const ma_spatializer_listener_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_spatializer_listener* pListener) { ma_result result; size_t heapSizeInBytes; void* pHeap; result = ma_spatializer_listener_get_heap_size(pConfig, &heapSizeInBytes); if (result != MA_SUCCESS) { return result; } if (heapSizeInBytes > 0) { pHeap = ma_malloc(heapSizeInBytes, pAllocationCallbacks); if (pHeap == NULL) { return MA_OUT_OF_MEMORY; } } else { pHeap = NULL; } result = ma_spatializer_listener_init_preallocated(pConfig, pHeap, pListener); if (result != MA_SUCCESS) { ma_free(pHeap, pAllocationCallbacks); return result; } pListener->_ownsHeap = MA_TRUE; return MA_SUCCESS; } MA_API void ma_spatializer_listener_uninit(ma_spatializer_listener* pListener, const ma_allocation_callbacks* pAllocationCallbacks) { if (pListener == NULL) { return; } if (pListener->_ownsHeap) { ma_free(pListener->_pHeap, pAllocationCallbacks); } } MA_API ma_channel* ma_spatializer_listener_get_channel_map(ma_spatializer_listener* pListener) { if (pListener == NULL) { return NULL; } return pListener->config.pChannelMapOut; } MA_API void ma_spatializer_listener_set_cone(ma_spatializer_listener* pListener, float innerAngleInRadians, float outerAngleInRadians, float outerGain) { if (pListener == NULL) { return; } pListener->config.coneInnerAngleInRadians = innerAngleInRadians; pListener->config.coneOuterAngleInRadians = outerAngleInRadians; pListener->config.coneOuterGain = outerGain; } MA_API void ma_spatializer_listener_get_cone(const ma_spatializer_listener* pListener, float* pInnerAngleInRadians, float* pOuterAngleInRadians, float* pOuterGain) { if (pListener == NULL) { return; } if (pInnerAngleInRadians != NULL) { *pInnerAngleInRadians = pListener->config.coneInnerAngleInRadians; } if (pOuterAngleInRadians != NULL) { *pOuterAngleInRadians = pListener->config.coneOuterAngleInRadians; } if (pOuterGain != NULL) { *pOuterGain = pListener->config.coneOuterGain; } } MA_API void ma_spatializer_listener_set_position(ma_spatializer_listener* pListener, float x, float y, float z) { if (pListener == NULL) { return; } ma_atomic_vec3f_set(&pListener->position, ma_vec3f_init_3f(x, y, z)); } MA_API ma_vec3f ma_spatializer_listener_get_position(const ma_spatializer_listener* pListener) { if (pListener == NULL) { return ma_vec3f_init_3f(0, 0, 0); } return ma_atomic_vec3f_get((ma_atomic_vec3f*)&pListener->position); /* Naughty const-cast. It's just for atomically loading the vec3 which should be safe. */ } MA_API void ma_spatializer_listener_set_direction(ma_spatializer_listener* pListener, float x, float y, float z) { if (pListener == NULL) { return; } ma_atomic_vec3f_set(&pListener->direction, ma_vec3f_init_3f(x, y, z)); } MA_API ma_vec3f ma_spatializer_listener_get_direction(const ma_spatializer_listener* pListener) { if (pListener == NULL) { return ma_vec3f_init_3f(0, 0, -1); } return ma_atomic_vec3f_get((ma_atomic_vec3f*)&pListener->direction); /* Naughty const-cast. It's just for atomically loading the vec3 which should be safe. */ } MA_API void ma_spatializer_listener_set_velocity(ma_spatializer_listener* pListener, float x, float y, float z) { if (pListener == NULL) { return; } ma_atomic_vec3f_set(&pListener->velocity, ma_vec3f_init_3f(x, y, z)); } MA_API ma_vec3f ma_spatializer_listener_get_velocity(const ma_spatializer_listener* pListener) { if (pListener == NULL) { return ma_vec3f_init_3f(0, 0, 0); } return ma_atomic_vec3f_get((ma_atomic_vec3f*)&pListener->velocity); /* Naughty const-cast. It's just for atomically loading the vec3 which should be safe. */ } MA_API void ma_spatializer_listener_set_speed_of_sound(ma_spatializer_listener* pListener, float speedOfSound) { if (pListener == NULL) { return; } pListener->config.speedOfSound = speedOfSound; } MA_API float ma_spatializer_listener_get_speed_of_sound(const ma_spatializer_listener* pListener) { if (pListener == NULL) { return 0; } return pListener->config.speedOfSound; } MA_API void ma_spatializer_listener_set_world_up(ma_spatializer_listener* pListener, float x, float y, float z) { if (pListener == NULL) { return; } pListener->config.worldUp = ma_vec3f_init_3f(x, y, z); } MA_API ma_vec3f ma_spatializer_listener_get_world_up(const ma_spatializer_listener* pListener) { if (pListener == NULL) { return ma_vec3f_init_3f(0, 1, 0); } return pListener->config.worldUp; } MA_API void ma_spatializer_listener_set_enabled(ma_spatializer_listener* pListener, ma_bool32 isEnabled) { if (pListener == NULL) { return; } pListener->isEnabled = isEnabled; } MA_API ma_bool32 ma_spatializer_listener_is_enabled(const ma_spatializer_listener* pListener) { if (pListener == NULL) { return MA_FALSE; } return pListener->isEnabled; } MA_API ma_spatializer_config ma_spatializer_config_init(ma_uint32 channelsIn, ma_uint32 channelsOut) { ma_spatializer_config config; MA_ZERO_OBJECT(&config); config.channelsIn = channelsIn; config.channelsOut = channelsOut; config.pChannelMapIn = NULL; config.attenuationModel = ma_attenuation_model_inverse; config.positioning = ma_positioning_absolute; config.handedness = ma_handedness_right; config.minGain = 0; config.maxGain = 1; config.minDistance = 1; config.maxDistance = MA_FLT_MAX; config.rolloff = 1; config.coneInnerAngleInRadians = 6.283185f; /* 360 degrees. */ config.coneOuterAngleInRadians = 6.283185f; /* 360 degress. */ config.coneOuterGain = 0.0f; config.dopplerFactor = 1; config.directionalAttenuationFactor = 1; config.minSpatializationChannelGain = 0.2f; config.gainSmoothTimeInFrames = 360; /* 7.5ms @ 48K. */ return config; } static ma_gainer_config ma_spatializer_gainer_config_init(const ma_spatializer_config* pConfig) { MA_ASSERT(pConfig != NULL); return ma_gainer_config_init(pConfig->channelsOut, pConfig->gainSmoothTimeInFrames); } static ma_result ma_spatializer_validate_config(const ma_spatializer_config* pConfig) { MA_ASSERT(pConfig != NULL); if (pConfig->channelsIn == 0 || pConfig->channelsOut == 0) { return MA_INVALID_ARGS; } return MA_SUCCESS; } typedef struct { size_t sizeInBytes; size_t channelMapInOffset; size_t newChannelGainsOffset; size_t gainerOffset; } ma_spatializer_heap_layout; static ma_result ma_spatializer_get_heap_layout(const ma_spatializer_config* pConfig, ma_spatializer_heap_layout* pHeapLayout) { ma_result result; MA_ASSERT(pHeapLayout != NULL); MA_ZERO_OBJECT(pHeapLayout); if (pConfig == NULL) { return MA_INVALID_ARGS; } result = ma_spatializer_validate_config(pConfig); if (result != MA_SUCCESS) { return result; } pHeapLayout->sizeInBytes = 0; /* Channel map. */ pHeapLayout->channelMapInOffset = MA_SIZE_MAX; /* <-- MA_SIZE_MAX indicates no allocation necessary. */ if (pConfig->pChannelMapIn != NULL) { pHeapLayout->channelMapInOffset = pHeapLayout->sizeInBytes; pHeapLayout->sizeInBytes += ma_align_64(sizeof(*pConfig->pChannelMapIn) * pConfig->channelsIn); } /* New channel gains for output. */ pHeapLayout->newChannelGainsOffset = pHeapLayout->sizeInBytes; pHeapLayout->sizeInBytes += ma_align_64(sizeof(float) * pConfig->channelsOut); /* Gainer. */ { size_t gainerHeapSizeInBytes; ma_gainer_config gainerConfig; gainerConfig = ma_spatializer_gainer_config_init(pConfig); result = ma_gainer_get_heap_size(&gainerConfig, &gainerHeapSizeInBytes); if (result != MA_SUCCESS) { return result; } pHeapLayout->gainerOffset = pHeapLayout->sizeInBytes; pHeapLayout->sizeInBytes += ma_align_64(gainerHeapSizeInBytes); } return MA_SUCCESS; } MA_API ma_result ma_spatializer_get_heap_size(const ma_spatializer_config* pConfig, size_t* pHeapSizeInBytes) { ma_result result; ma_spatializer_heap_layout heapLayout; if (pHeapSizeInBytes == NULL) { return MA_INVALID_ARGS; } *pHeapSizeInBytes = 0; /* Safety. */ result = ma_spatializer_get_heap_layout(pConfig, &heapLayout); if (result != MA_SUCCESS) { return result; } *pHeapSizeInBytes = heapLayout.sizeInBytes; return MA_SUCCESS; } MA_API ma_result ma_spatializer_init_preallocated(const ma_spatializer_config* pConfig, void* pHeap, ma_spatializer* pSpatializer) { ma_result result; ma_spatializer_heap_layout heapLayout; ma_gainer_config gainerConfig; if (pSpatializer == NULL) { return MA_INVALID_ARGS; } MA_ZERO_OBJECT(pSpatializer); if (pConfig == NULL || pHeap == NULL) { return MA_INVALID_ARGS; } result = ma_spatializer_get_heap_layout(pConfig, &heapLayout); if (result != MA_SUCCESS) { return result; } pSpatializer->_pHeap = pHeap; MA_ZERO_MEMORY(pHeap, heapLayout.sizeInBytes); pSpatializer->channelsIn = pConfig->channelsIn; pSpatializer->channelsOut = pConfig->channelsOut; pSpatializer->attenuationModel = pConfig->attenuationModel; pSpatializer->positioning = pConfig->positioning; pSpatializer->handedness = pConfig->handedness; pSpatializer->minGain = pConfig->minGain; pSpatializer->maxGain = pConfig->maxGain; pSpatializer->minDistance = pConfig->minDistance; pSpatializer->maxDistance = pConfig->maxDistance; pSpatializer->rolloff = pConfig->rolloff; pSpatializer->coneInnerAngleInRadians = pConfig->coneInnerAngleInRadians; pSpatializer->coneOuterAngleInRadians = pConfig->coneOuterAngleInRadians; pSpatializer->coneOuterGain = pConfig->coneOuterGain; pSpatializer->dopplerFactor = pConfig->dopplerFactor; pSpatializer->minSpatializationChannelGain = pConfig->minSpatializationChannelGain; pSpatializer->directionalAttenuationFactor = pConfig->directionalAttenuationFactor; pSpatializer->gainSmoothTimeInFrames = pConfig->gainSmoothTimeInFrames; ma_atomic_vec3f_init(&pSpatializer->position, ma_vec3f_init_3f(0, 0, 0)); ma_atomic_vec3f_init(&pSpatializer->direction, ma_vec3f_init_3f(0, 0, -1)); ma_atomic_vec3f_init(&pSpatializer->velocity, ma_vec3f_init_3f(0, 0, 0)); pSpatializer->dopplerPitch = 1; /* Swap the forward direction if we're left handed (it was initialized based on right handed). */ if (pSpatializer->handedness == ma_handedness_left) { ma_vec3f negDir = ma_vec3f_neg(ma_spatializer_get_direction(pSpatializer)); ma_spatializer_set_direction(pSpatializer, negDir.x, negDir.y, negDir.z); } /* Channel map. This will be on the heap. */ if (pConfig->pChannelMapIn != NULL) { pSpatializer->pChannelMapIn = (ma_channel*)ma_offset_ptr(pHeap, heapLayout.channelMapInOffset); ma_channel_map_copy_or_default(pSpatializer->pChannelMapIn, pSpatializer->channelsIn, pConfig->pChannelMapIn, pSpatializer->channelsIn); } /* New channel gains for output channels. */ pSpatializer->pNewChannelGainsOut = (float*)ma_offset_ptr(pHeap, heapLayout.newChannelGainsOffset); /* Gainer. */ gainerConfig = ma_spatializer_gainer_config_init(pConfig); result = ma_gainer_init_preallocated(&gainerConfig, ma_offset_ptr(pHeap, heapLayout.gainerOffset), &pSpatializer->gainer); if (result != MA_SUCCESS) { return result; /* Failed to initialize the gainer. */ } return MA_SUCCESS; } MA_API ma_result ma_spatializer_init(const ma_spatializer_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_spatializer* pSpatializer) { ma_result result; size_t heapSizeInBytes; void* pHeap; /* We'll need a heap allocation to retrieve the size. */ result = ma_spatializer_get_heap_size(pConfig, &heapSizeInBytes); if (result != MA_SUCCESS) { return result; } if (heapSizeInBytes > 0) { pHeap = ma_malloc(heapSizeInBytes, pAllocationCallbacks); if (pHeap == NULL) { return MA_OUT_OF_MEMORY; } } else { pHeap = NULL; } result = ma_spatializer_init_preallocated(pConfig, pHeap, pSpatializer); if (result != MA_SUCCESS) { ma_free(pHeap, pAllocationCallbacks); return result; } pSpatializer->_ownsHeap = MA_TRUE; return MA_SUCCESS; } MA_API void ma_spatializer_uninit(ma_spatializer* pSpatializer, const ma_allocation_callbacks* pAllocationCallbacks) { if (pSpatializer == NULL) { return; } ma_gainer_uninit(&pSpatializer->gainer, pAllocationCallbacks); if (pSpatializer->_ownsHeap) { ma_free(pSpatializer->_pHeap, pAllocationCallbacks); } } static float ma_calculate_angular_gain(ma_vec3f dirA, ma_vec3f dirB, float coneInnerAngleInRadians, float coneOuterAngleInRadians, float coneOuterGain) { /* Angular attenuation. Unlike distance gain, the math for this is not specified by the OpenAL spec so we'll just go ahead and figure this out for ourselves at the expense of possibly being inconsistent with other implementations. To do cone attenuation, I'm just using the same math that we'd use to implement a basic spotlight in OpenGL. We just need to get the direction from the source to the listener and then do a dot product against that and the direction of the spotlight. Then we just compare that dot product against the cosine of the inner and outer angles. If the dot product is greater than the the outer angle, we just use coneOuterGain. If it's less than the inner angle, we just use a gain of 1. Otherwise we linearly interpolate between 1 and coneOuterGain. */ if (coneInnerAngleInRadians < 6.283185f) { float angularGain = 1; float cutoffInner = (float)ma_cosd(coneInnerAngleInRadians*0.5f); float cutoffOuter = (float)ma_cosd(coneOuterAngleInRadians*0.5f); float d; d = ma_vec3f_dot(dirA, dirB); if (d > cutoffInner) { /* It's inside the inner angle. */ angularGain = 1; } else { /* It's outside the inner angle. */ if (d > cutoffOuter) { /* It's between the inner and outer angle. We need to linearly interpolate between 1 and coneOuterGain. */ angularGain = ma_mix_f32(coneOuterGain, 1, (d - cutoffOuter) / (cutoffInner - cutoffOuter)); } else { /* It's outside the outer angle. */ angularGain = coneOuterGain; } } /*printf("d = %f; cutoffInner = %f; cutoffOuter = %f; angularGain = %f\n", d, cutoffInner, cutoffOuter, angularGain);*/ return angularGain; } else { /* Inner angle is 360 degrees so no need to do any attenuation. */ return 1; } } MA_API ma_result ma_spatializer_process_pcm_frames(ma_spatializer* pSpatializer, ma_spatializer_listener* pListener, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount) { ma_channel* pChannelMapIn = pSpatializer->pChannelMapIn; ma_channel* pChannelMapOut = pListener->config.pChannelMapOut; if (pSpatializer == NULL) { return MA_INVALID_ARGS; } /* If we're not spatializing we need to run an optimized path. */ if (ma_atomic_load_i32(&pSpatializer->attenuationModel) == ma_attenuation_model_none) { if (ma_spatializer_listener_is_enabled(pListener)) { /* No attenuation is required, but we'll need to do some channel conversion. */ if (pSpatializer->channelsIn == pSpatializer->channelsOut) { ma_copy_pcm_frames(pFramesOut, pFramesIn, frameCount, ma_format_f32, pSpatializer->channelsIn); } else { ma_channel_map_apply_f32((float*)pFramesOut, pChannelMapOut, pSpatializer->channelsOut, (const float*)pFramesIn, pChannelMapIn, pSpatializer->channelsIn, frameCount, ma_channel_mix_mode_rectangular, ma_mono_expansion_mode_default); /* Safe casts to float* because f32 is the only supported format. */ } } else { /* The listener is disabled. Output silence. */ ma_silence_pcm_frames(pFramesOut, frameCount, ma_format_f32, pSpatializer->channelsOut); } /* We're not doing attenuation so don't bother with doppler for now. I'm not sure if this is the correct thinking so might need to review this later. */ pSpatializer->dopplerPitch = 1; } else { /* Let's first determine which listener the sound is closest to. Need to keep in mind that we might not have a world or any listeners, in which case we just spatializer based on the listener being positioned at the origin (0, 0, 0). */ ma_vec3f relativePosNormalized; ma_vec3f relativePos; /* The position relative to the listener. */ ma_vec3f relativeDir; /* The direction of the sound, relative to the listener. */ ma_vec3f listenerVel; /* The volocity of the listener. For doppler pitch calculation. */ float speedOfSound; float distance = 0; float gain = 1; ma_uint32 iChannel; const ma_uint32 channelsOut = pSpatializer->channelsOut; const ma_uint32 channelsIn = pSpatializer->channelsIn; float minDistance = ma_spatializer_get_min_distance(pSpatializer); float maxDistance = ma_spatializer_get_max_distance(pSpatializer); float rolloff = ma_spatializer_get_rolloff(pSpatializer); float dopplerFactor = ma_spatializer_get_doppler_factor(pSpatializer); /* We'll need the listener velocity for doppler pitch calculations. The speed of sound is defined by the listener, so we'll grab that here too. */ if (pListener != NULL) { listenerVel = ma_spatializer_listener_get_velocity(pListener); speedOfSound = pListener->config.speedOfSound; } else { listenerVel = ma_vec3f_init_3f(0, 0, 0); speedOfSound = MA_DEFAULT_SPEED_OF_SOUND; } if (pListener == NULL || ma_spatializer_get_positioning(pSpatializer) == ma_positioning_relative) { /* There's no listener or we're using relative positioning. */ relativePos = ma_spatializer_get_position(pSpatializer); relativeDir = ma_spatializer_get_direction(pSpatializer); } else { /* We've found a listener and we're using absolute positioning. We need to transform the sound's position and direction so that it's relative to listener. Later on we'll use this for determining the factors to apply to each channel to apply the panning effect. */ ma_spatializer_get_relative_position_and_direction(pSpatializer, pListener, &relativePos, &relativeDir); } distance = ma_vec3f_len(relativePos); /* We've gathered the data, so now we can apply some spatialization. */ switch (ma_spatializer_get_attenuation_model(pSpatializer)) { case ma_attenuation_model_inverse: { gain = ma_attenuation_inverse(distance, minDistance, maxDistance, rolloff); } break; case ma_attenuation_model_linear: { gain = ma_attenuation_linear(distance, minDistance, maxDistance, rolloff); } break; case ma_attenuation_model_exponential: { gain = ma_attenuation_exponential(distance, minDistance, maxDistance, rolloff); } break; case ma_attenuation_model_none: default: { gain = 1; } break; } /* Normalize the position. */ if (distance > 0.001f) { float distanceInv = 1/distance; relativePosNormalized = relativePos; relativePosNormalized.x *= distanceInv; relativePosNormalized.y *= distanceInv; relativePosNormalized.z *= distanceInv; } else { distance = 0; relativePosNormalized = ma_vec3f_init_3f(0, 0, 0); } /* Angular attenuation. Unlike distance gain, the math for this is not specified by the OpenAL spec so we'll just go ahead and figure this out for ourselves at the expense of possibly being inconsistent with other implementations. To do cone attenuation, I'm just using the same math that we'd use to implement a basic spotlight in OpenGL. We just need to get the direction from the source to the listener and then do a dot product against that and the direction of the spotlight. Then we just compare that dot product against the cosine of the inner and outer angles. If the dot product is greater than the the outer angle, we just use coneOuterGain. If it's less than the inner angle, we just use a gain of 1. Otherwise we linearly interpolate between 1 and coneOuterGain. */ if (distance > 0) { /* Source anglular gain. */ float spatializerConeInnerAngle; float spatializerConeOuterAngle; float spatializerConeOuterGain; ma_spatializer_get_cone(pSpatializer, &spatializerConeInnerAngle, &spatializerConeOuterAngle, &spatializerConeOuterGain); gain *= ma_calculate_angular_gain(relativeDir, ma_vec3f_neg(relativePosNormalized), spatializerConeInnerAngle, spatializerConeOuterAngle, spatializerConeOuterGain); /* We're supporting angular gain on the listener as well for those who want to reduce the volume of sounds that are positioned behind the listener. On default settings, this will have no effect. */ if (pListener != NULL && pListener->config.coneInnerAngleInRadians < 6.283185f) { ma_vec3f listenerDirection; float listenerInnerAngle; float listenerOuterAngle; float listenerOuterGain; if (pListener->config.handedness == ma_handedness_right) { listenerDirection = ma_vec3f_init_3f(0, 0, -1); } else { listenerDirection = ma_vec3f_init_3f(0, 0, +1); } listenerInnerAngle = pListener->config.coneInnerAngleInRadians; listenerOuterAngle = pListener->config.coneOuterAngleInRadians; listenerOuterGain = pListener->config.coneOuterGain; gain *= ma_calculate_angular_gain(listenerDirection, relativePosNormalized, listenerInnerAngle, listenerOuterAngle, listenerOuterGain); } } else { /* The sound is right on top of the listener. Don't do any angular attenuation. */ } /* Clamp the gain. */ gain = ma_clamp(gain, ma_spatializer_get_min_gain(pSpatializer), ma_spatializer_get_max_gain(pSpatializer)); /* The gain needs to be applied per-channel here. The spatialization code below will be changing the per-channel gains which will then eventually be passed into the gainer which will deal with smoothing the gain transitions to avoid harsh changes in gain. */ for (iChannel = 0; iChannel < channelsOut; iChannel += 1) { pSpatializer->pNewChannelGainsOut[iChannel] = gain; } /* Convert to our output channel count. If the listener is disabled we just output silence here. We cannot ignore the whole section of code here because we need to update some internal spatialization state. */ if (ma_spatializer_listener_is_enabled(pListener)) { ma_channel_map_apply_f32((float*)pFramesOut, pChannelMapOut, channelsOut, (const float*)pFramesIn, pChannelMapIn, channelsIn, frameCount, ma_channel_mix_mode_rectangular, ma_mono_expansion_mode_default); } else { ma_silence_pcm_frames(pFramesOut, frameCount, ma_format_f32, pSpatializer->channelsOut); } /* Panning. This is where we'll apply the gain and convert to the output channel count. We have an optimized path for when we're converting to a mono stream. In that case we don't really need to do any panning - we just apply the gain to the final output. */ /*printf("distance=%f; gain=%f\n", distance, gain);*/ /* We must have a valid channel map here to ensure we spatialize properly. */ MA_ASSERT(pChannelMapOut != NULL); /* We're not converting to mono so we'll want to apply some panning. This is where the feeling of something being to the left, right, infront or behind the listener is calculated. I'm just using a basic model here. Note that the code below is not based on any specific algorithm. I'm just implementing this off the top of my head and seeing how it goes. There might be better ways to do this. To determine the direction of the sound relative to a speaker I'm using dot products. Each speaker is given a direction. For example, the left channel in a stereo system will be -1 on the X axis and the right channel will be +1 on the X axis. A dot product is performed against the direction vector of the channel and the normalized position of the sound. */ /* Calculate our per-channel gains. We do this based on the normalized relative position of the sound and it's relation to the direction of the channel. */ if (distance > 0) { ma_vec3f unitPos = relativePos; float distanceInv = 1/distance; unitPos.x *= distanceInv; unitPos.y *= distanceInv; unitPos.z *= distanceInv; for (iChannel = 0; iChannel < channelsOut; iChannel += 1) { ma_channel channelOut; float d; float dMin; channelOut = ma_channel_map_get_channel(pChannelMapOut, channelsOut, iChannel); if (ma_is_spatial_channel_position(channelOut)) { d = ma_mix_f32_fast(1, ma_vec3f_dot(unitPos, ma_get_channel_direction(channelOut)), ma_spatializer_get_directional_attenuation_factor(pSpatializer)); } else { d = 1; /* It's not a spatial channel so there's no real notion of direction. */ } /* In my testing, if the panning effect is too aggressive it makes spatialization feel uncomfortable. The "dMin" variable below is used to control the aggressiveness of the panning effect. When set to 0, panning will be most extreme and any sounds that are positioned on the opposite side of the speaker will be completely silent from that speaker. Not only does this feel uncomfortable, it doesn't even remotely represent the real world at all because sounds that come from your right side are still clearly audible from your left side. Setting "dMin" to 1 will result in no panning at all, which is also not ideal. By setting it to something greater than 0, the spatialization effect becomes much less dramatic and a lot more bearable. Summary: 0 = more extreme panning; 1 = no panning. */ dMin = pSpatializer->minSpatializationChannelGain; /* At this point, "d" will be positive if the sound is on the same side as the channel and negative if it's on the opposite side. It will be in the range of -1..1. There's two ways I can think of to calculate a panning value. The first is to simply convert it to 0..1, however this has a problem which I'm not entirely happy with. Considering a stereo system, when a sound is positioned right in front of the listener it'll result in each speaker getting a gain of 0.5. I don't know if I like the idea of having a scaling factor of 0.5 being applied to a sound when it's sitting right in front of the listener. I would intuitively expect that to be played at full volume, or close to it. The second idea I think of is to only apply a reduction in gain when the sound is on the opposite side of the speaker. That is, reduce the gain only when the dot product is negative. The problem with this is that there will not be any attenuation as the sound sweeps around the 180 degrees where the dot product is positive. The idea with this option is that you leave the gain at 1 when the sound is being played on the same side as the speaker and then you just reduce the volume when the sound is on the other side. The summarize, I think the first option should give a better sense of spatialization, but the second option is better for preserving the sound's power. UPDATE: In my testing, I find the first option to sound better. You can feel the sense of space a bit better, but you can also hear the reduction in volume when it's right in front. */ #if 1 { /* Scale the dot product from -1..1 to 0..1. Will result in a sound directly in front losing power by being played at 0.5 gain. */ d = (d + 1) * 0.5f; /* -1..1 to 0..1 */ d = ma_max(d, dMin); pSpatializer->pNewChannelGainsOut[iChannel] *= d; } #else { /* Only reduce the volume of the sound if it's on the opposite side. This path keeps the volume more consistent, but comes at the expense of a worse sense of space and positioning. */ if (d < 0) { d += 1; /* Move into the positive range. */ d = ma_max(d, dMin); channelGainsOut[iChannel] *= d; } } #endif } } else { /* Assume the sound is right on top of us. Don't do any panning. */ } /* Now we need to apply the volume to each channel. This needs to run through the gainer to ensure we get a smooth volume transition. */ ma_gainer_set_gains(&pSpatializer->gainer, pSpatializer->pNewChannelGainsOut); ma_gainer_process_pcm_frames(&pSpatializer->gainer, pFramesOut, pFramesOut, frameCount); /* Before leaving we'll want to update our doppler pitch so that the caller can apply some pitch shifting if they desire. Note that we need to negate the relative position here because the doppler calculation needs to be source-to-listener, but ours is listener-to- source. */ if (dopplerFactor > 0) { pSpatializer->dopplerPitch = ma_doppler_pitch(ma_vec3f_sub(ma_spatializer_listener_get_position(pListener), ma_spatializer_get_position(pSpatializer)), ma_spatializer_get_velocity(pSpatializer), listenerVel, speedOfSound, dopplerFactor); } else { pSpatializer->dopplerPitch = 1; } } return MA_SUCCESS; } MA_API ma_result ma_spatializer_set_master_volume(ma_spatializer* pSpatializer, float volume) { if (pSpatializer == NULL) { return MA_INVALID_ARGS; } return ma_gainer_set_master_volume(&pSpatializer->gainer, volume); } MA_API ma_result ma_spatializer_get_master_volume(const ma_spatializer* pSpatializer, float* pVolume) { if (pSpatializer == NULL) { return MA_INVALID_ARGS; } return ma_gainer_get_master_volume(&pSpatializer->gainer, pVolume); } MA_API ma_uint32 ma_spatializer_get_input_channels(const ma_spatializer* pSpatializer) { if (pSpatializer == NULL) { return 0; } return pSpatializer->channelsIn; } MA_API ma_uint32 ma_spatializer_get_output_channels(const ma_spatializer* pSpatializer) { if (pSpatializer == NULL) { return 0; } return pSpatializer->channelsOut; } MA_API void ma_spatializer_set_attenuation_model(ma_spatializer* pSpatializer, ma_attenuation_model attenuationModel) { if (pSpatializer == NULL) { return; } ma_atomic_exchange_i32(&pSpatializer->attenuationModel, attenuationModel); } MA_API ma_attenuation_model ma_spatializer_get_attenuation_model(const ma_spatializer* pSpatializer) { if (pSpatializer == NULL) { return ma_attenuation_model_none; } return (ma_attenuation_model)ma_atomic_load_i32(&pSpatializer->attenuationModel); } MA_API void ma_spatializer_set_positioning(ma_spatializer* pSpatializer, ma_positioning positioning) { if (pSpatializer == NULL) { return; } ma_atomic_exchange_i32(&pSpatializer->positioning, positioning); } MA_API ma_positioning ma_spatializer_get_positioning(const ma_spatializer* pSpatializer) { if (pSpatializer == NULL) { return ma_positioning_absolute; } return (ma_positioning)ma_atomic_load_i32(&pSpatializer->positioning); } MA_API void ma_spatializer_set_rolloff(ma_spatializer* pSpatializer, float rolloff) { if (pSpatializer == NULL) { return; } ma_atomic_exchange_f32(&pSpatializer->rolloff, rolloff); } MA_API float ma_spatializer_get_rolloff(const ma_spatializer* pSpatializer) { if (pSpatializer == NULL) { return 0; } return ma_atomic_load_f32(&pSpatializer->rolloff); } MA_API void ma_spatializer_set_min_gain(ma_spatializer* pSpatializer, float minGain) { if (pSpatializer == NULL) { return; } ma_atomic_exchange_f32(&pSpatializer->minGain, minGain); } MA_API float ma_spatializer_get_min_gain(const ma_spatializer* pSpatializer) { if (pSpatializer == NULL) { return 0; } return ma_atomic_load_f32(&pSpatializer->minGain); } MA_API void ma_spatializer_set_max_gain(ma_spatializer* pSpatializer, float maxGain) { if (pSpatializer == NULL) { return; } ma_atomic_exchange_f32(&pSpatializer->maxGain, maxGain); } MA_API float ma_spatializer_get_max_gain(const ma_spatializer* pSpatializer) { if (pSpatializer == NULL) { return 0; } return ma_atomic_load_f32(&pSpatializer->maxGain); } MA_API void ma_spatializer_set_min_distance(ma_spatializer* pSpatializer, float minDistance) { if (pSpatializer == NULL) { return; } ma_atomic_exchange_f32(&pSpatializer->minDistance, minDistance); } MA_API float ma_spatializer_get_min_distance(const ma_spatializer* pSpatializer) { if (pSpatializer == NULL) { return 0; } return ma_atomic_load_f32(&pSpatializer->minDistance); } MA_API void ma_spatializer_set_max_distance(ma_spatializer* pSpatializer, float maxDistance) { if (pSpatializer == NULL) { return; } ma_atomic_exchange_f32(&pSpatializer->maxDistance, maxDistance); } MA_API float ma_spatializer_get_max_distance(const ma_spatializer* pSpatializer) { if (pSpatializer == NULL) { return 0; } return ma_atomic_load_f32(&pSpatializer->maxDistance); } MA_API void ma_spatializer_set_cone(ma_spatializer* pSpatializer, float innerAngleInRadians, float outerAngleInRadians, float outerGain) { if (pSpatializer == NULL) { return; } ma_atomic_exchange_f32(&pSpatializer->coneInnerAngleInRadians, innerAngleInRadians); ma_atomic_exchange_f32(&pSpatializer->coneOuterAngleInRadians, outerAngleInRadians); ma_atomic_exchange_f32(&pSpatializer->coneOuterGain, outerGain); } MA_API void ma_spatializer_get_cone(const ma_spatializer* pSpatializer, float* pInnerAngleInRadians, float* pOuterAngleInRadians, float* pOuterGain) { if (pSpatializer == NULL) { return; } if (pInnerAngleInRadians != NULL) { *pInnerAngleInRadians = ma_atomic_load_f32(&pSpatializer->coneInnerAngleInRadians); } if (pOuterAngleInRadians != NULL) { *pOuterAngleInRadians = ma_atomic_load_f32(&pSpatializer->coneOuterAngleInRadians); } if (pOuterGain != NULL) { *pOuterGain = ma_atomic_load_f32(&pSpatializer->coneOuterGain); } } MA_API void ma_spatializer_set_doppler_factor(ma_spatializer* pSpatializer, float dopplerFactor) { if (pSpatializer == NULL) { return; } ma_atomic_exchange_f32(&pSpatializer->dopplerFactor, dopplerFactor); } MA_API float ma_spatializer_get_doppler_factor(const ma_spatializer* pSpatializer) { if (pSpatializer == NULL) { return 1; } return ma_atomic_load_f32(&pSpatializer->dopplerFactor); } MA_API void ma_spatializer_set_directional_attenuation_factor(ma_spatializer* pSpatializer, float directionalAttenuationFactor) { if (pSpatializer == NULL) { return; } ma_atomic_exchange_f32(&pSpatializer->directionalAttenuationFactor, directionalAttenuationFactor); } MA_API float ma_spatializer_get_directional_attenuation_factor(const ma_spatializer* pSpatializer) { if (pSpatializer == NULL) { return 1; } return ma_atomic_load_f32(&pSpatializer->directionalAttenuationFactor); } MA_API void ma_spatializer_set_position(ma_spatializer* pSpatializer, float x, float y, float z) { if (pSpatializer == NULL) { return; } ma_atomic_vec3f_set(&pSpatializer->position, ma_vec3f_init_3f(x, y, z)); } MA_API ma_vec3f ma_spatializer_get_position(const ma_spatializer* pSpatializer) { if (pSpatializer == NULL) { return ma_vec3f_init_3f(0, 0, 0); } return ma_atomic_vec3f_get((ma_atomic_vec3f*)&pSpatializer->position); /* Naughty const-cast. It's just for atomically loading the vec3 which should be safe. */ } MA_API void ma_spatializer_set_direction(ma_spatializer* pSpatializer, float x, float y, float z) { if (pSpatializer == NULL) { return; } ma_atomic_vec3f_set(&pSpatializer->direction, ma_vec3f_init_3f(x, y, z)); } MA_API ma_vec3f ma_spatializer_get_direction(const ma_spatializer* pSpatializer) { if (pSpatializer == NULL) { return ma_vec3f_init_3f(0, 0, -1); } return ma_atomic_vec3f_get((ma_atomic_vec3f*)&pSpatializer->direction); /* Naughty const-cast. It's just for atomically loading the vec3 which should be safe. */ } MA_API void ma_spatializer_set_velocity(ma_spatializer* pSpatializer, float x, float y, float z) { if (pSpatializer == NULL) { return; } ma_atomic_vec3f_set(&pSpatializer->velocity, ma_vec3f_init_3f(x, y, z)); } MA_API ma_vec3f ma_spatializer_get_velocity(const ma_spatializer* pSpatializer) { if (pSpatializer == NULL) { return ma_vec3f_init_3f(0, 0, 0); } return ma_atomic_vec3f_get((ma_atomic_vec3f*)&pSpatializer->velocity); /* Naughty const-cast. It's just for atomically loading the vec3 which should be safe. */ } MA_API void ma_spatializer_get_relative_position_and_direction(const ma_spatializer* pSpatializer, const ma_spatializer_listener* pListener, ma_vec3f* pRelativePos, ma_vec3f* pRelativeDir) { if (pRelativePos != NULL) { pRelativePos->x = 0; pRelativePos->y = 0; pRelativePos->z = 0; } if (pRelativeDir != NULL) { pRelativeDir->x = 0; pRelativeDir->y = 0; pRelativeDir->z = -1; } if (pSpatializer == NULL) { return; } if (pListener == NULL || ma_spatializer_get_positioning(pSpatializer) == ma_positioning_relative) { /* There's no listener or we're using relative positioning. */ if (pRelativePos != NULL) { *pRelativePos = ma_spatializer_get_position(pSpatializer); } if (pRelativeDir != NULL) { *pRelativeDir = ma_spatializer_get_direction(pSpatializer); } } else { ma_vec3f spatializerPosition; ma_vec3f spatializerDirection; ma_vec3f listenerPosition; ma_vec3f listenerDirection; ma_vec3f v; ma_vec3f axisX; ma_vec3f axisY; ma_vec3f axisZ; float m[4][4]; spatializerPosition = ma_spatializer_get_position(pSpatializer); spatializerDirection = ma_spatializer_get_direction(pSpatializer); listenerPosition = ma_spatializer_listener_get_position(pListener); listenerDirection = ma_spatializer_listener_get_direction(pListener); /* We need to calcualte the right vector from our forward and up vectors. This is done with a cross product. */ axisZ = ma_vec3f_normalize(listenerDirection); /* Normalization required here because we can't trust the caller. */ axisX = ma_vec3f_normalize(ma_vec3f_cross(axisZ, pListener->config.worldUp)); /* Normalization required here because the world up vector may not be perpendicular with the forward vector. */ /* The calculation of axisX above can result in a zero-length vector if the listener is looking straight up on the Y axis. We'll need to fall back to a +X in this case so that the calculations below don't fall apart. This is where a quaternion based listener and sound orientation would come in handy. */ if (ma_vec3f_len2(axisX) == 0) { axisX = ma_vec3f_init_3f(1, 0, 0); } axisY = ma_vec3f_cross(axisX, axisZ); /* No normalization is required here because axisX and axisZ are unit length and perpendicular. */ /* We need to swap the X axis if we're left handed because otherwise the cross product above will have resulted in it pointing in the wrong direction (right handed was assumed in the cross products above). */ if (pListener->config.handedness == ma_handedness_left) { axisX = ma_vec3f_neg(axisX); } /* Lookat. */ m[0][0] = axisX.x; m[1][0] = axisX.y; m[2][0] = axisX.z; m[3][0] = -ma_vec3f_dot(axisX, listenerPosition); m[0][1] = axisY.x; m[1][1] = axisY.y; m[2][1] = axisY.z; m[3][1] = -ma_vec3f_dot(axisY, listenerPosition); m[0][2] = -axisZ.x; m[1][2] = -axisZ.y; m[2][2] = -axisZ.z; m[3][2] = -ma_vec3f_dot(ma_vec3f_neg(axisZ), listenerPosition); m[0][3] = 0; m[1][3] = 0; m[2][3] = 0; m[3][3] = 1; /* Multiply the lookat matrix by the spatializer position to transform it to listener space. This allows calculations to work based on the sound being relative to the origin which makes things simpler. */ if (pRelativePos != NULL) { v = spatializerPosition; pRelativePos->x = m[0][0] * v.x + m[1][0] * v.y + m[2][0] * v.z + m[3][0] * 1; pRelativePos->y = m[0][1] * v.x + m[1][1] * v.y + m[2][1] * v.z + m[3][1] * 1; pRelativePos->z = m[0][2] * v.x + m[1][2] * v.y + m[2][2] * v.z + m[3][2] * 1; } /* The direction of the sound needs to also be transformed so that it's relative to the rotation of the listener. */ if (pRelativeDir != NULL) { v = spatializerDirection; pRelativeDir->x = m[0][0] * v.x + m[1][0] * v.y + m[2][0] * v.z; pRelativeDir->y = m[0][1] * v.x + m[1][1] * v.y + m[2][1] * v.z; pRelativeDir->z = m[0][2] * v.x + m[1][2] * v.y + m[2][2] * v.z; } } } /************************************************************************************************************************************************************** Resampling **************************************************************************************************************************************************************/ MA_API ma_linear_resampler_config ma_linear_resampler_config_init(ma_format format, ma_uint32 channels, ma_uint32 sampleRateIn, ma_uint32 sampleRateOut) { ma_linear_resampler_config config; MA_ZERO_OBJECT(&config); config.format = format; config.channels = channels; config.sampleRateIn = sampleRateIn; config.sampleRateOut = sampleRateOut; config.lpfOrder = ma_min(MA_DEFAULT_RESAMPLER_LPF_ORDER, MA_MAX_FILTER_ORDER); config.lpfNyquistFactor = 1; return config; } typedef struct { size_t sizeInBytes; size_t x0Offset; size_t x1Offset; size_t lpfOffset; } ma_linear_resampler_heap_layout; static void ma_linear_resampler_adjust_timer_for_new_rate(ma_linear_resampler* pResampler, ma_uint32 oldSampleRateOut, ma_uint32 newSampleRateOut) { /* So what's happening here? Basically we need to adjust the fractional component of the time advance based on the new rate. The old time advance will be based on the old sample rate, but we are needing to adjust it to that it's based on the new sample rate. */ ma_uint32 oldRateTimeWhole = pResampler->inTimeFrac / oldSampleRateOut; /* <-- This should almost never be anything other than 0, but leaving it here to make this more general and robust just in case. */ ma_uint32 oldRateTimeFract = pResampler->inTimeFrac % oldSampleRateOut; pResampler->inTimeFrac = (oldRateTimeWhole * newSampleRateOut) + ((oldRateTimeFract * newSampleRateOut) / oldSampleRateOut); /* Make sure the fractional part is less than the output sample rate. */ pResampler->inTimeInt += pResampler->inTimeFrac / pResampler->config.sampleRateOut; pResampler->inTimeFrac = pResampler->inTimeFrac % pResampler->config.sampleRateOut; } static ma_result ma_linear_resampler_set_rate_internal(ma_linear_resampler* pResampler, void* pHeap, ma_linear_resampler_heap_layout* pHeapLayout, ma_uint32 sampleRateIn, ma_uint32 sampleRateOut, ma_bool32 isResamplerAlreadyInitialized) { ma_result result; ma_uint32 gcf; ma_uint32 lpfSampleRate; double lpfCutoffFrequency; ma_lpf_config lpfConfig; ma_uint32 oldSampleRateOut; /* Required for adjusting time advance down the bottom. */ if (pResampler == NULL) { return MA_INVALID_ARGS; } if (sampleRateIn == 0 || sampleRateOut == 0) { return MA_INVALID_ARGS; } oldSampleRateOut = pResampler->config.sampleRateOut; pResampler->config.sampleRateIn = sampleRateIn; pResampler->config.sampleRateOut = sampleRateOut; /* Simplify the sample rate. */ gcf = ma_gcf_u32(pResampler->config.sampleRateIn, pResampler->config.sampleRateOut); pResampler->config.sampleRateIn /= gcf; pResampler->config.sampleRateOut /= gcf; /* Always initialize the low-pass filter, even when the order is 0. */ if (pResampler->config.lpfOrder > MA_MAX_FILTER_ORDER) { return MA_INVALID_ARGS; } lpfSampleRate = (ma_uint32)(ma_max(pResampler->config.sampleRateIn, pResampler->config.sampleRateOut)); lpfCutoffFrequency = ( double)(ma_min(pResampler->config.sampleRateIn, pResampler->config.sampleRateOut) * 0.5 * pResampler->config.lpfNyquistFactor); lpfConfig = ma_lpf_config_init(pResampler->config.format, pResampler->config.channels, lpfSampleRate, lpfCutoffFrequency, pResampler->config.lpfOrder); /* If the resampler is alreay initialized we don't want to do a fresh initialization of the low-pass filter because it will result in the cached frames getting cleared. Instead we re-initialize the filter which will maintain any cached frames. */ if (isResamplerAlreadyInitialized) { result = ma_lpf_reinit(&lpfConfig, &pResampler->lpf); } else { result = ma_lpf_init_preallocated(&lpfConfig, ma_offset_ptr(pHeap, pHeapLayout->lpfOffset), &pResampler->lpf); } if (result != MA_SUCCESS) { return result; } pResampler->inAdvanceInt = pResampler->config.sampleRateIn / pResampler->config.sampleRateOut; pResampler->inAdvanceFrac = pResampler->config.sampleRateIn % pResampler->config.sampleRateOut; /* Our timer was based on the old rate. We need to adjust it so that it's based on the new rate. */ ma_linear_resampler_adjust_timer_for_new_rate(pResampler, oldSampleRateOut, pResampler->config.sampleRateOut); return MA_SUCCESS; } static ma_result ma_linear_resampler_get_heap_layout(const ma_linear_resampler_config* pConfig, ma_linear_resampler_heap_layout* pHeapLayout) { MA_ASSERT(pHeapLayout != NULL); MA_ZERO_OBJECT(pHeapLayout); if (pConfig == NULL) { return MA_INVALID_ARGS; } if (pConfig->format != ma_format_f32 && pConfig->format != ma_format_s16) { return MA_INVALID_ARGS; } if (pConfig->channels == 0) { return MA_INVALID_ARGS; } pHeapLayout->sizeInBytes = 0; /* x0 */ pHeapLayout->x0Offset = pHeapLayout->sizeInBytes; if (pConfig->format == ma_format_f32) { pHeapLayout->sizeInBytes += sizeof(float) * pConfig->channels; } else { pHeapLayout->sizeInBytes += sizeof(ma_int16) * pConfig->channels; } /* x1 */ pHeapLayout->x1Offset = pHeapLayout->sizeInBytes; if (pConfig->format == ma_format_f32) { pHeapLayout->sizeInBytes += sizeof(float) * pConfig->channels; } else { pHeapLayout->sizeInBytes += sizeof(ma_int16) * pConfig->channels; } /* LPF */ pHeapLayout->lpfOffset = ma_align_64(pHeapLayout->sizeInBytes); { ma_result result; size_t lpfHeapSizeInBytes; ma_lpf_config lpfConfig = ma_lpf_config_init(pConfig->format, pConfig->channels, 1, 1, pConfig->lpfOrder); /* Sample rate and cutoff frequency do not matter. */ result = ma_lpf_get_heap_size(&lpfConfig, &lpfHeapSizeInBytes); if (result != MA_SUCCESS) { return result; } pHeapLayout->sizeInBytes += lpfHeapSizeInBytes; } /* Make sure allocation size is aligned. */ pHeapLayout->sizeInBytes = ma_align_64(pHeapLayout->sizeInBytes); return MA_SUCCESS; } MA_API ma_result ma_linear_resampler_get_heap_size(const ma_linear_resampler_config* pConfig, size_t* pHeapSizeInBytes) { ma_result result; ma_linear_resampler_heap_layout heapLayout; if (pHeapSizeInBytes == NULL) { return MA_INVALID_ARGS; } *pHeapSizeInBytes = 0; result = ma_linear_resampler_get_heap_layout(pConfig, &heapLayout); if (result != MA_SUCCESS) { return result; } *pHeapSizeInBytes = heapLayout.sizeInBytes; return MA_SUCCESS; } MA_API ma_result ma_linear_resampler_init_preallocated(const ma_linear_resampler_config* pConfig, void* pHeap, ma_linear_resampler* pResampler) { ma_result result; ma_linear_resampler_heap_layout heapLayout; if (pResampler == NULL) { return MA_INVALID_ARGS; } MA_ZERO_OBJECT(pResampler); result = ma_linear_resampler_get_heap_layout(pConfig, &heapLayout); if (result != MA_SUCCESS) { return result; } pResampler->config = *pConfig; pResampler->_pHeap = pHeap; MA_ZERO_MEMORY(pHeap, heapLayout.sizeInBytes); if (pConfig->format == ma_format_f32) { pResampler->x0.f32 = (float*)ma_offset_ptr(pHeap, heapLayout.x0Offset); pResampler->x1.f32 = (float*)ma_offset_ptr(pHeap, heapLayout.x1Offset); } else { pResampler->x0.s16 = (ma_int16*)ma_offset_ptr(pHeap, heapLayout.x0Offset); pResampler->x1.s16 = (ma_int16*)ma_offset_ptr(pHeap, heapLayout.x1Offset); } /* Setting the rate will set up the filter and time advances for us. */ result = ma_linear_resampler_set_rate_internal(pResampler, pHeap, &heapLayout, pConfig->sampleRateIn, pConfig->sampleRateOut, /* isResamplerAlreadyInitialized = */ MA_FALSE); if (result != MA_SUCCESS) { return result; } pResampler->inTimeInt = 1; /* Set this to one to force an input sample to always be loaded for the first output frame. */ pResampler->inTimeFrac = 0; return MA_SUCCESS; } MA_API ma_result ma_linear_resampler_init(const ma_linear_resampler_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_linear_resampler* pResampler) { ma_result result; size_t heapSizeInBytes; void* pHeap; result = ma_linear_resampler_get_heap_size(pConfig, &heapSizeInBytes); if (result != MA_SUCCESS) { return result; } if (heapSizeInBytes > 0) { pHeap = ma_malloc(heapSizeInBytes, pAllocationCallbacks); if (pHeap == NULL) { return MA_OUT_OF_MEMORY; } } else { pHeap = NULL; } result = ma_linear_resampler_init_preallocated(pConfig, pHeap, pResampler); if (result != MA_SUCCESS) { ma_free(pHeap, pAllocationCallbacks); return result; } pResampler->_ownsHeap = MA_TRUE; return MA_SUCCESS; } MA_API void ma_linear_resampler_uninit(ma_linear_resampler* pResampler, const ma_allocation_callbacks* pAllocationCallbacks) { if (pResampler == NULL) { return; } ma_lpf_uninit(&pResampler->lpf, pAllocationCallbacks); if (pResampler->_ownsHeap) { ma_free(pResampler->_pHeap, pAllocationCallbacks); } } static MA_INLINE ma_int16 ma_linear_resampler_mix_s16(ma_int16 x, ma_int16 y, ma_int32 a, const ma_int32 shift) { ma_int32 b; ma_int32 c; ma_int32 r; MA_ASSERT(a <= (1<> shift); } static void ma_linear_resampler_interpolate_frame_s16(ma_linear_resampler* pResampler, ma_int16* MA_RESTRICT pFrameOut) { ma_uint32 c; ma_uint32 a; const ma_uint32 channels = pResampler->config.channels; const ma_uint32 shift = 12; MA_ASSERT(pResampler != NULL); MA_ASSERT(pFrameOut != NULL); a = (pResampler->inTimeFrac << shift) / pResampler->config.sampleRateOut; MA_ASSUME(channels > 0); for (c = 0; c < channels; c += 1) { ma_int16 s = ma_linear_resampler_mix_s16(pResampler->x0.s16[c], pResampler->x1.s16[c], a, shift); pFrameOut[c] = s; } } static void ma_linear_resampler_interpolate_frame_f32(ma_linear_resampler* pResampler, float* MA_RESTRICT pFrameOut) { ma_uint32 c; float a; const ma_uint32 channels = pResampler->config.channels; MA_ASSERT(pResampler != NULL); MA_ASSERT(pFrameOut != NULL); a = (float)pResampler->inTimeFrac / pResampler->config.sampleRateOut; MA_ASSUME(channels > 0); for (c = 0; c < channels; c += 1) { float s = ma_mix_f32_fast(pResampler->x0.f32[c], pResampler->x1.f32[c], a); pFrameOut[c] = s; } } static ma_result ma_linear_resampler_process_pcm_frames_s16_downsample(ma_linear_resampler* pResampler, const void* pFramesIn, ma_uint64* pFrameCountIn, void* pFramesOut, ma_uint64* pFrameCountOut) { const ma_int16* pFramesInS16; /* */ ma_int16* pFramesOutS16; ma_uint64 frameCountIn; ma_uint64 frameCountOut; ma_uint64 framesProcessedIn; ma_uint64 framesProcessedOut; MA_ASSERT(pResampler != NULL); MA_ASSERT(pFrameCountIn != NULL); MA_ASSERT(pFrameCountOut != NULL); pFramesInS16 = (const ma_int16*)pFramesIn; pFramesOutS16 = ( ma_int16*)pFramesOut; frameCountIn = *pFrameCountIn; frameCountOut = *pFrameCountOut; framesProcessedIn = 0; framesProcessedOut = 0; while (framesProcessedOut < frameCountOut) { /* Before interpolating we need to load the buffers. When doing this we need to ensure we run every input sample through the filter. */ while (pResampler->inTimeInt > 0 && frameCountIn > framesProcessedIn) { ma_uint32 iChannel; if (pFramesInS16 != NULL) { for (iChannel = 0; iChannel < pResampler->config.channels; iChannel += 1) { pResampler->x0.s16[iChannel] = pResampler->x1.s16[iChannel]; pResampler->x1.s16[iChannel] = pFramesInS16[iChannel]; } pFramesInS16 += pResampler->config.channels; } else { for (iChannel = 0; iChannel < pResampler->config.channels; iChannel += 1) { pResampler->x0.s16[iChannel] = pResampler->x1.s16[iChannel]; pResampler->x1.s16[iChannel] = 0; } } /* Filter. Do not apply filtering if sample rates are the same or else you'll get dangerous glitching. */ if (pResampler->config.sampleRateIn != pResampler->config.sampleRateOut) { ma_lpf_process_pcm_frame_s16(&pResampler->lpf, pResampler->x1.s16, pResampler->x1.s16); } framesProcessedIn += 1; pResampler->inTimeInt -= 1; } if (pResampler->inTimeInt > 0) { break; /* Ran out of input data. */ } /* Getting here means the frames have been loaded and filtered and we can generate the next output frame. */ if (pFramesOutS16 != NULL) { MA_ASSERT(pResampler->inTimeInt == 0); ma_linear_resampler_interpolate_frame_s16(pResampler, pFramesOutS16); pFramesOutS16 += pResampler->config.channels; } framesProcessedOut += 1; /* Advance time forward. */ pResampler->inTimeInt += pResampler->inAdvanceInt; pResampler->inTimeFrac += pResampler->inAdvanceFrac; if (pResampler->inTimeFrac >= pResampler->config.sampleRateOut) { pResampler->inTimeFrac -= pResampler->config.sampleRateOut; pResampler->inTimeInt += 1; } } *pFrameCountIn = framesProcessedIn; *pFrameCountOut = framesProcessedOut; return MA_SUCCESS; } static ma_result ma_linear_resampler_process_pcm_frames_s16_upsample(ma_linear_resampler* pResampler, const void* pFramesIn, ma_uint64* pFrameCountIn, void* pFramesOut, ma_uint64* pFrameCountOut) { const ma_int16* pFramesInS16; /* */ ma_int16* pFramesOutS16; ma_uint64 frameCountIn; ma_uint64 frameCountOut; ma_uint64 framesProcessedIn; ma_uint64 framesProcessedOut; MA_ASSERT(pResampler != NULL); MA_ASSERT(pFrameCountIn != NULL); MA_ASSERT(pFrameCountOut != NULL); pFramesInS16 = (const ma_int16*)pFramesIn; pFramesOutS16 = ( ma_int16*)pFramesOut; frameCountIn = *pFrameCountIn; frameCountOut = *pFrameCountOut; framesProcessedIn = 0; framesProcessedOut = 0; while (framesProcessedOut < frameCountOut) { /* Before interpolating we need to load the buffers. */ while (pResampler->inTimeInt > 0 && frameCountIn > framesProcessedIn) { ma_uint32 iChannel; if (pFramesInS16 != NULL) { for (iChannel = 0; iChannel < pResampler->config.channels; iChannel += 1) { pResampler->x0.s16[iChannel] = pResampler->x1.s16[iChannel]; pResampler->x1.s16[iChannel] = pFramesInS16[iChannel]; } pFramesInS16 += pResampler->config.channels; } else { for (iChannel = 0; iChannel < pResampler->config.channels; iChannel += 1) { pResampler->x0.s16[iChannel] = pResampler->x1.s16[iChannel]; pResampler->x1.s16[iChannel] = 0; } } framesProcessedIn += 1; pResampler->inTimeInt -= 1; } if (pResampler->inTimeInt > 0) { break; /* Ran out of input data. */ } /* Getting here means the frames have been loaded and we can generate the next output frame. */ if (pFramesOutS16 != NULL) { MA_ASSERT(pResampler->inTimeInt == 0); ma_linear_resampler_interpolate_frame_s16(pResampler, pFramesOutS16); /* Filter. Do not apply filtering if sample rates are the same or else you'll get dangerous glitching. */ if (pResampler->config.sampleRateIn != pResampler->config.sampleRateOut) { ma_lpf_process_pcm_frame_s16(&pResampler->lpf, pFramesOutS16, pFramesOutS16); } pFramesOutS16 += pResampler->config.channels; } framesProcessedOut += 1; /* Advance time forward. */ pResampler->inTimeInt += pResampler->inAdvanceInt; pResampler->inTimeFrac += pResampler->inAdvanceFrac; if (pResampler->inTimeFrac >= pResampler->config.sampleRateOut) { pResampler->inTimeFrac -= pResampler->config.sampleRateOut; pResampler->inTimeInt += 1; } } *pFrameCountIn = framesProcessedIn; *pFrameCountOut = framesProcessedOut; return MA_SUCCESS; } static ma_result ma_linear_resampler_process_pcm_frames_s16(ma_linear_resampler* pResampler, const void* pFramesIn, ma_uint64* pFrameCountIn, void* pFramesOut, ma_uint64* pFrameCountOut) { MA_ASSERT(pResampler != NULL); if (pResampler->config.sampleRateIn > pResampler->config.sampleRateOut) { return ma_linear_resampler_process_pcm_frames_s16_downsample(pResampler, pFramesIn, pFrameCountIn, pFramesOut, pFrameCountOut); } else { return ma_linear_resampler_process_pcm_frames_s16_upsample(pResampler, pFramesIn, pFrameCountIn, pFramesOut, pFrameCountOut); } } static ma_result ma_linear_resampler_process_pcm_frames_f32_downsample(ma_linear_resampler* pResampler, const void* pFramesIn, ma_uint64* pFrameCountIn, void* pFramesOut, ma_uint64* pFrameCountOut) { const float* pFramesInF32; /* */ float* pFramesOutF32; ma_uint64 frameCountIn; ma_uint64 frameCountOut; ma_uint64 framesProcessedIn; ma_uint64 framesProcessedOut; MA_ASSERT(pResampler != NULL); MA_ASSERT(pFrameCountIn != NULL); MA_ASSERT(pFrameCountOut != NULL); pFramesInF32 = (const float*)pFramesIn; pFramesOutF32 = ( float*)pFramesOut; frameCountIn = *pFrameCountIn; frameCountOut = *pFrameCountOut; framesProcessedIn = 0; framesProcessedOut = 0; while (framesProcessedOut < frameCountOut) { /* Before interpolating we need to load the buffers. When doing this we need to ensure we run every input sample through the filter. */ while (pResampler->inTimeInt > 0 && frameCountIn > framesProcessedIn) { ma_uint32 iChannel; if (pFramesInF32 != NULL) { for (iChannel = 0; iChannel < pResampler->config.channels; iChannel += 1) { pResampler->x0.f32[iChannel] = pResampler->x1.f32[iChannel]; pResampler->x1.f32[iChannel] = pFramesInF32[iChannel]; } pFramesInF32 += pResampler->config.channels; } else { for (iChannel = 0; iChannel < pResampler->config.channels; iChannel += 1) { pResampler->x0.f32[iChannel] = pResampler->x1.f32[iChannel]; pResampler->x1.f32[iChannel] = 0; } } /* Filter. Do not apply filtering if sample rates are the same or else you'll get dangerous glitching. */ if (pResampler->config.sampleRateIn != pResampler->config.sampleRateOut) { ma_lpf_process_pcm_frame_f32(&pResampler->lpf, pResampler->x1.f32, pResampler->x1.f32); } framesProcessedIn += 1; pResampler->inTimeInt -= 1; } if (pResampler->inTimeInt > 0) { break; /* Ran out of input data. */ } /* Getting here means the frames have been loaded and filtered and we can generate the next output frame. */ if (pFramesOutF32 != NULL) { MA_ASSERT(pResampler->inTimeInt == 0); ma_linear_resampler_interpolate_frame_f32(pResampler, pFramesOutF32); pFramesOutF32 += pResampler->config.channels; } framesProcessedOut += 1; /* Advance time forward. */ pResampler->inTimeInt += pResampler->inAdvanceInt; pResampler->inTimeFrac += pResampler->inAdvanceFrac; if (pResampler->inTimeFrac >= pResampler->config.sampleRateOut) { pResampler->inTimeFrac -= pResampler->config.sampleRateOut; pResampler->inTimeInt += 1; } } *pFrameCountIn = framesProcessedIn; *pFrameCountOut = framesProcessedOut; return MA_SUCCESS; } static ma_result ma_linear_resampler_process_pcm_frames_f32_upsample(ma_linear_resampler* pResampler, const void* pFramesIn, ma_uint64* pFrameCountIn, void* pFramesOut, ma_uint64* pFrameCountOut) { const float* pFramesInF32; /* */ float* pFramesOutF32; ma_uint64 frameCountIn; ma_uint64 frameCountOut; ma_uint64 framesProcessedIn; ma_uint64 framesProcessedOut; MA_ASSERT(pResampler != NULL); MA_ASSERT(pFrameCountIn != NULL); MA_ASSERT(pFrameCountOut != NULL); pFramesInF32 = (const float*)pFramesIn; pFramesOutF32 = ( float*)pFramesOut; frameCountIn = *pFrameCountIn; frameCountOut = *pFrameCountOut; framesProcessedIn = 0; framesProcessedOut = 0; while (framesProcessedOut < frameCountOut) { /* Before interpolating we need to load the buffers. */ while (pResampler->inTimeInt > 0 && frameCountIn > framesProcessedIn) { ma_uint32 iChannel; if (pFramesInF32 != NULL) { for (iChannel = 0; iChannel < pResampler->config.channels; iChannel += 1) { pResampler->x0.f32[iChannel] = pResampler->x1.f32[iChannel]; pResampler->x1.f32[iChannel] = pFramesInF32[iChannel]; } pFramesInF32 += pResampler->config.channels; } else { for (iChannel = 0; iChannel < pResampler->config.channels; iChannel += 1) { pResampler->x0.f32[iChannel] = pResampler->x1.f32[iChannel]; pResampler->x1.f32[iChannel] = 0; } } framesProcessedIn += 1; pResampler->inTimeInt -= 1; } if (pResampler->inTimeInt > 0) { break; /* Ran out of input data. */ } /* Getting here means the frames have been loaded and we can generate the next output frame. */ if (pFramesOutF32 != NULL) { MA_ASSERT(pResampler->inTimeInt == 0); ma_linear_resampler_interpolate_frame_f32(pResampler, pFramesOutF32); /* Filter. Do not apply filtering if sample rates are the same or else you'll get dangerous glitching. */ if (pResampler->config.sampleRateIn != pResampler->config.sampleRateOut) { ma_lpf_process_pcm_frame_f32(&pResampler->lpf, pFramesOutF32, pFramesOutF32); } pFramesOutF32 += pResampler->config.channels; } framesProcessedOut += 1; /* Advance time forward. */ pResampler->inTimeInt += pResampler->inAdvanceInt; pResampler->inTimeFrac += pResampler->inAdvanceFrac; if (pResampler->inTimeFrac >= pResampler->config.sampleRateOut) { pResampler->inTimeFrac -= pResampler->config.sampleRateOut; pResampler->inTimeInt += 1; } } *pFrameCountIn = framesProcessedIn; *pFrameCountOut = framesProcessedOut; return MA_SUCCESS; } static ma_result ma_linear_resampler_process_pcm_frames_f32(ma_linear_resampler* pResampler, const void* pFramesIn, ma_uint64* pFrameCountIn, void* pFramesOut, ma_uint64* pFrameCountOut) { MA_ASSERT(pResampler != NULL); if (pResampler->config.sampleRateIn > pResampler->config.sampleRateOut) { return ma_linear_resampler_process_pcm_frames_f32_downsample(pResampler, pFramesIn, pFrameCountIn, pFramesOut, pFrameCountOut); } else { return ma_linear_resampler_process_pcm_frames_f32_upsample(pResampler, pFramesIn, pFrameCountIn, pFramesOut, pFrameCountOut); } } MA_API ma_result ma_linear_resampler_process_pcm_frames(ma_linear_resampler* pResampler, const void* pFramesIn, ma_uint64* pFrameCountIn, void* pFramesOut, ma_uint64* pFrameCountOut) { if (pResampler == NULL) { return MA_INVALID_ARGS; } /* */ if (pResampler->config.format == ma_format_s16) { return ma_linear_resampler_process_pcm_frames_s16(pResampler, pFramesIn, pFrameCountIn, pFramesOut, pFrameCountOut); } else if (pResampler->config.format == ma_format_f32) { return ma_linear_resampler_process_pcm_frames_f32(pResampler, pFramesIn, pFrameCountIn, pFramesOut, pFrameCountOut); } else { /* Should never get here. Getting here means the format is not supported and you didn't check the return value of ma_linear_resampler_init(). */ MA_ASSERT(MA_FALSE); return MA_INVALID_ARGS; } } MA_API ma_result ma_linear_resampler_set_rate(ma_linear_resampler* pResampler, ma_uint32 sampleRateIn, ma_uint32 sampleRateOut) { return ma_linear_resampler_set_rate_internal(pResampler, NULL, NULL, sampleRateIn, sampleRateOut, /* isResamplerAlreadyInitialized = */ MA_TRUE); } MA_API ma_result ma_linear_resampler_set_rate_ratio(ma_linear_resampler* pResampler, float ratioInOut) { ma_uint32 n; ma_uint32 d; if (pResampler == NULL) { return MA_INVALID_ARGS; } if (ratioInOut <= 0) { return MA_INVALID_ARGS; } d = 1000000; n = (ma_uint32)(ratioInOut * d); if (n == 0) { return MA_INVALID_ARGS; /* Ratio too small. */ } MA_ASSERT(n != 0); return ma_linear_resampler_set_rate(pResampler, n, d); } MA_API ma_uint64 ma_linear_resampler_get_input_latency(const ma_linear_resampler* pResampler) { if (pResampler == NULL) { return 0; } return 1 + ma_lpf_get_latency(&pResampler->lpf); } MA_API ma_uint64 ma_linear_resampler_get_output_latency(const ma_linear_resampler* pResampler) { if (pResampler == NULL) { return 0; } return ma_linear_resampler_get_input_latency(pResampler) * pResampler->config.sampleRateOut / pResampler->config.sampleRateIn; } MA_API ma_result ma_linear_resampler_get_required_input_frame_count(const ma_linear_resampler* pResampler, ma_uint64 outputFrameCount, ma_uint64* pInputFrameCount) { ma_uint64 inputFrameCount; if (pInputFrameCount == NULL) { return MA_INVALID_ARGS; } *pInputFrameCount = 0; if (pResampler == NULL) { return MA_INVALID_ARGS; } if (outputFrameCount == 0) { return MA_SUCCESS; } /* Any whole input frames are consumed before the first output frame is generated. */ inputFrameCount = pResampler->inTimeInt; outputFrameCount -= 1; /* The rest of the output frames can be calculated in constant time. */ inputFrameCount += outputFrameCount * pResampler->inAdvanceInt; inputFrameCount += (pResampler->inTimeFrac + (outputFrameCount * pResampler->inAdvanceFrac)) / pResampler->config.sampleRateOut; *pInputFrameCount = inputFrameCount; return MA_SUCCESS; } MA_API ma_result ma_linear_resampler_get_expected_output_frame_count(const ma_linear_resampler* pResampler, ma_uint64 inputFrameCount, ma_uint64* pOutputFrameCount) { ma_uint64 outputFrameCount; ma_uint64 preliminaryInputFrameCountFromFrac; ma_uint64 preliminaryInputFrameCount; if (pOutputFrameCount == NULL) { return MA_INVALID_ARGS; } *pOutputFrameCount = 0; if (pResampler == NULL) { return MA_INVALID_ARGS; } /* The first step is to get a preliminary output frame count. This will either be exactly equal to what we need, or less by 1. We need to determine how many input frames will be consumed by this value. If it's greater than our original input frame count it means we won't be able to generate an extra frame because we will have run out of input data. Otherwise we will have enough input for the generation of an extra output frame. This add-by-one logic is necessary due to how the data loading logic works when processing frames. */ outputFrameCount = (inputFrameCount * pResampler->config.sampleRateOut) / pResampler->config.sampleRateIn; /* We need to determine how many *whole* input frames will have been processed to generate our preliminary output frame count. This is used in the logic below to determine whether or not we need to add an extra output frame. */ preliminaryInputFrameCountFromFrac = (pResampler->inTimeFrac + outputFrameCount*pResampler->inAdvanceFrac) / pResampler->config.sampleRateOut; preliminaryInputFrameCount = (pResampler->inTimeInt + outputFrameCount*pResampler->inAdvanceInt ) + preliminaryInputFrameCountFromFrac; /* If the total number of *whole* input frames that would be required to generate our preliminary output frame count is greather than the amount of whole input frames we have available as input we need to *not* add an extra output frame as there won't be enough data to actually process. Otherwise we need to add the extra output frame. */ if (preliminaryInputFrameCount <= inputFrameCount) { outputFrameCount += 1; } *pOutputFrameCount = outputFrameCount; return MA_SUCCESS; } MA_API ma_result ma_linear_resampler_reset(ma_linear_resampler* pResampler) { ma_uint32 iChannel; if (pResampler == NULL) { return MA_INVALID_ARGS; } /* Timers need to be cleared back to zero. */ pResampler->inTimeInt = 1; /* Set this to one to force an input sample to always be loaded for the first output frame. */ pResampler->inTimeFrac = 0; /* Cached samples need to be cleared. */ if (pResampler->config.format == ma_format_f32) { for (iChannel = 0; iChannel < pResampler->config.channels; iChannel += 1) { pResampler->x0.f32[iChannel] = 0; pResampler->x1.f32[iChannel] = 0; } } else { for (iChannel = 0; iChannel < pResampler->config.channels; iChannel += 1) { pResampler->x0.s16[iChannel] = 0; pResampler->x1.s16[iChannel] = 0; } } /* The low pass filter needs to have it's cache reset. */ ma_lpf_clear_cache(&pResampler->lpf); return MA_SUCCESS; } /* Linear resampler backend vtable. */ static ma_linear_resampler_config ma_resampling_backend_get_config__linear(const ma_resampler_config* pConfig) { ma_linear_resampler_config linearConfig; linearConfig = ma_linear_resampler_config_init(pConfig->format, pConfig->channels, pConfig->sampleRateIn, pConfig->sampleRateOut); linearConfig.lpfOrder = pConfig->linear.lpfOrder; return linearConfig; } static ma_result ma_resampling_backend_get_heap_size__linear(void* pUserData, const ma_resampler_config* pConfig, size_t* pHeapSizeInBytes) { ma_linear_resampler_config linearConfig; (void)pUserData; linearConfig = ma_resampling_backend_get_config__linear(pConfig); return ma_linear_resampler_get_heap_size(&linearConfig, pHeapSizeInBytes); } static ma_result ma_resampling_backend_init__linear(void* pUserData, const ma_resampler_config* pConfig, void* pHeap, ma_resampling_backend** ppBackend) { ma_resampler* pResampler = (ma_resampler*)pUserData; ma_result result; ma_linear_resampler_config linearConfig; (void)pUserData; linearConfig = ma_resampling_backend_get_config__linear(pConfig); result = ma_linear_resampler_init_preallocated(&linearConfig, pHeap, &pResampler->state.linear); if (result != MA_SUCCESS) { return result; } *ppBackend = &pResampler->state.linear; return MA_SUCCESS; } static void ma_resampling_backend_uninit__linear(void* pUserData, ma_resampling_backend* pBackend, const ma_allocation_callbacks* pAllocationCallbacks) { (void)pUserData; ma_linear_resampler_uninit((ma_linear_resampler*)pBackend, pAllocationCallbacks); } static ma_result ma_resampling_backend_process__linear(void* pUserData, ma_resampling_backend* pBackend, const void* pFramesIn, ma_uint64* pFrameCountIn, void* pFramesOut, ma_uint64* pFrameCountOut) { (void)pUserData; return ma_linear_resampler_process_pcm_frames((ma_linear_resampler*)pBackend, pFramesIn, pFrameCountIn, pFramesOut, pFrameCountOut); } static ma_result ma_resampling_backend_set_rate__linear(void* pUserData, ma_resampling_backend* pBackend, ma_uint32 sampleRateIn, ma_uint32 sampleRateOut) { (void)pUserData; return ma_linear_resampler_set_rate((ma_linear_resampler*)pBackend, sampleRateIn, sampleRateOut); } static ma_uint64 ma_resampling_backend_get_input_latency__linear(void* pUserData, const ma_resampling_backend* pBackend) { (void)pUserData; return ma_linear_resampler_get_input_latency((const ma_linear_resampler*)pBackend); } static ma_uint64 ma_resampling_backend_get_output_latency__linear(void* pUserData, const ma_resampling_backend* pBackend) { (void)pUserData; return ma_linear_resampler_get_output_latency((const ma_linear_resampler*)pBackend); } static ma_result ma_resampling_backend_get_required_input_frame_count__linear(void* pUserData, const ma_resampling_backend* pBackend, ma_uint64 outputFrameCount, ma_uint64* pInputFrameCount) { (void)pUserData; return ma_linear_resampler_get_required_input_frame_count((const ma_linear_resampler*)pBackend, outputFrameCount, pInputFrameCount); } static ma_result ma_resampling_backend_get_expected_output_frame_count__linear(void* pUserData, const ma_resampling_backend* pBackend, ma_uint64 inputFrameCount, ma_uint64* pOutputFrameCount) { (void)pUserData; return ma_linear_resampler_get_expected_output_frame_count((const ma_linear_resampler*)pBackend, inputFrameCount, pOutputFrameCount); } static ma_result ma_resampling_backend_reset__linear(void* pUserData, ma_resampling_backend* pBackend) { (void)pUserData; return ma_linear_resampler_reset((ma_linear_resampler*)pBackend); } static ma_resampling_backend_vtable g_ma_linear_resampler_vtable = { ma_resampling_backend_get_heap_size__linear, ma_resampling_backend_init__linear, ma_resampling_backend_uninit__linear, ma_resampling_backend_process__linear, ma_resampling_backend_set_rate__linear, ma_resampling_backend_get_input_latency__linear, ma_resampling_backend_get_output_latency__linear, ma_resampling_backend_get_required_input_frame_count__linear, ma_resampling_backend_get_expected_output_frame_count__linear, ma_resampling_backend_reset__linear }; MA_API ma_resampler_config ma_resampler_config_init(ma_format format, ma_uint32 channels, ma_uint32 sampleRateIn, ma_uint32 sampleRateOut, ma_resample_algorithm algorithm) { ma_resampler_config config; MA_ZERO_OBJECT(&config); config.format = format; config.channels = channels; config.sampleRateIn = sampleRateIn; config.sampleRateOut = sampleRateOut; config.algorithm = algorithm; /* Linear. */ config.linear.lpfOrder = ma_min(MA_DEFAULT_RESAMPLER_LPF_ORDER, MA_MAX_FILTER_ORDER); return config; } static ma_result ma_resampler_get_vtable(const ma_resampler_config* pConfig, ma_resampler* pResampler, ma_resampling_backend_vtable** ppVTable, void** ppUserData) { MA_ASSERT(pConfig != NULL); MA_ASSERT(ppVTable != NULL); MA_ASSERT(ppUserData != NULL); /* Safety. */ *ppVTable = NULL; *ppUserData = NULL; switch (pConfig->algorithm) { case ma_resample_algorithm_linear: { *ppVTable = &g_ma_linear_resampler_vtable; *ppUserData = pResampler; } break; case ma_resample_algorithm_custom: { *ppVTable = pConfig->pBackendVTable; *ppUserData = pConfig->pBackendUserData; } break; default: return MA_INVALID_ARGS; } return MA_SUCCESS; } MA_API ma_result ma_resampler_get_heap_size(const ma_resampler_config* pConfig, size_t* pHeapSizeInBytes) { ma_result result; ma_resampling_backend_vtable* pVTable; void* pVTableUserData; if (pHeapSizeInBytes == NULL) { return MA_INVALID_ARGS; } *pHeapSizeInBytes = 0; if (pConfig == NULL) { return MA_INVALID_ARGS; } result = ma_resampler_get_vtable(pConfig, NULL, &pVTable, &pVTableUserData); if (result != MA_SUCCESS) { return result; } if (pVTable == NULL || pVTable->onGetHeapSize == NULL) { return MA_NOT_IMPLEMENTED; } result = pVTable->onGetHeapSize(pVTableUserData, pConfig, pHeapSizeInBytes); if (result != MA_SUCCESS) { return result; } return MA_SUCCESS; } MA_API ma_result ma_resampler_init_preallocated(const ma_resampler_config* pConfig, void* pHeap, ma_resampler* pResampler) { ma_result result; if (pResampler == NULL) { return MA_INVALID_ARGS; } MA_ZERO_OBJECT(pResampler); if (pConfig == NULL) { return MA_INVALID_ARGS; } pResampler->_pHeap = pHeap; pResampler->format = pConfig->format; pResampler->channels = pConfig->channels; pResampler->sampleRateIn = pConfig->sampleRateIn; pResampler->sampleRateOut = pConfig->sampleRateOut; result = ma_resampler_get_vtable(pConfig, pResampler, &pResampler->pBackendVTable, &pResampler->pBackendUserData); if (result != MA_SUCCESS) { return result; } if (pResampler->pBackendVTable == NULL || pResampler->pBackendVTable->onInit == NULL) { return MA_NOT_IMPLEMENTED; /* onInit not implemented. */ } result = pResampler->pBackendVTable->onInit(pResampler->pBackendUserData, pConfig, pHeap, &pResampler->pBackend); if (result != MA_SUCCESS) { return result; } return MA_SUCCESS; } MA_API ma_result ma_resampler_init(const ma_resampler_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_resampler* pResampler) { ma_result result; size_t heapSizeInBytes; void* pHeap; result = ma_resampler_get_heap_size(pConfig, &heapSizeInBytes); if (result != MA_SUCCESS) { return result; } if (heapSizeInBytes > 0) { pHeap = ma_malloc(heapSizeInBytes, pAllocationCallbacks); if (pHeap == NULL) { return MA_OUT_OF_MEMORY; } } else { pHeap = NULL; } result = ma_resampler_init_preallocated(pConfig, pHeap, pResampler); if (result != MA_SUCCESS) { ma_free(pHeap, pAllocationCallbacks); return result; } pResampler->_ownsHeap = MA_TRUE; return MA_SUCCESS; } MA_API void ma_resampler_uninit(ma_resampler* pResampler, const ma_allocation_callbacks* pAllocationCallbacks) { if (pResampler == NULL) { return; } if (pResampler->pBackendVTable == NULL || pResampler->pBackendVTable->onUninit == NULL) { return; } pResampler->pBackendVTable->onUninit(pResampler->pBackendUserData, pResampler->pBackend, pAllocationCallbacks); if (pResampler->_ownsHeap) { ma_free(pResampler->_pHeap, pAllocationCallbacks); } } MA_API ma_result ma_resampler_process_pcm_frames(ma_resampler* pResampler, const void* pFramesIn, ma_uint64* pFrameCountIn, void* pFramesOut, ma_uint64* pFrameCountOut) { if (pResampler == NULL) { return MA_INVALID_ARGS; } if (pFrameCountOut == NULL && pFrameCountIn == NULL) { return MA_INVALID_ARGS; } if (pResampler->pBackendVTable == NULL || pResampler->pBackendVTable->onProcess == NULL) { return MA_NOT_IMPLEMENTED; } return pResampler->pBackendVTable->onProcess(pResampler->pBackendUserData, pResampler->pBackend, pFramesIn, pFrameCountIn, pFramesOut, pFrameCountOut); } MA_API ma_result ma_resampler_set_rate(ma_resampler* pResampler, ma_uint32 sampleRateIn, ma_uint32 sampleRateOut) { ma_result result; if (pResampler == NULL) { return MA_INVALID_ARGS; } if (sampleRateIn == 0 || sampleRateOut == 0) { return MA_INVALID_ARGS; } if (pResampler->pBackendVTable == NULL || pResampler->pBackendVTable->onSetRate == NULL) { return MA_NOT_IMPLEMENTED; } result = pResampler->pBackendVTable->onSetRate(pResampler->pBackendUserData, pResampler->pBackend, sampleRateIn, sampleRateOut); if (result != MA_SUCCESS) { return result; } pResampler->sampleRateIn = sampleRateIn; pResampler->sampleRateOut = sampleRateOut; return MA_SUCCESS; } MA_API ma_result ma_resampler_set_rate_ratio(ma_resampler* pResampler, float ratio) { ma_uint32 n; ma_uint32 d; if (pResampler == NULL) { return MA_INVALID_ARGS; } if (ratio <= 0) { return MA_INVALID_ARGS; } d = 1000; n = (ma_uint32)(ratio * d); if (n == 0) { return MA_INVALID_ARGS; /* Ratio too small. */ } MA_ASSERT(n != 0); return ma_resampler_set_rate(pResampler, n, d); } MA_API ma_uint64 ma_resampler_get_input_latency(const ma_resampler* pResampler) { if (pResampler == NULL) { return 0; } if (pResampler->pBackendVTable == NULL || pResampler->pBackendVTable->onGetInputLatency == NULL) { return 0; } return pResampler->pBackendVTable->onGetInputLatency(pResampler->pBackendUserData, pResampler->pBackend); } MA_API ma_uint64 ma_resampler_get_output_latency(const ma_resampler* pResampler) { if (pResampler == NULL) { return 0; } if (pResampler->pBackendVTable == NULL || pResampler->pBackendVTable->onGetOutputLatency == NULL) { return 0; } return pResampler->pBackendVTable->onGetOutputLatency(pResampler->pBackendUserData, pResampler->pBackend); } MA_API ma_result ma_resampler_get_required_input_frame_count(const ma_resampler* pResampler, ma_uint64 outputFrameCount, ma_uint64* pInputFrameCount) { if (pInputFrameCount == NULL) { return MA_INVALID_ARGS; } *pInputFrameCount = 0; if (pResampler == NULL) { return MA_INVALID_ARGS; } if (pResampler->pBackendVTable == NULL || pResampler->pBackendVTable->onGetRequiredInputFrameCount == NULL) { return MA_NOT_IMPLEMENTED; } return pResampler->pBackendVTable->onGetRequiredInputFrameCount(pResampler->pBackendUserData, pResampler->pBackend, outputFrameCount, pInputFrameCount); } MA_API ma_result ma_resampler_get_expected_output_frame_count(const ma_resampler* pResampler, ma_uint64 inputFrameCount, ma_uint64* pOutputFrameCount) { if (pOutputFrameCount == NULL) { return MA_INVALID_ARGS; } *pOutputFrameCount = 0; if (pResampler == NULL) { return MA_INVALID_ARGS; } if (pResampler->pBackendVTable == NULL || pResampler->pBackendVTable->onGetExpectedOutputFrameCount == NULL) { return MA_NOT_IMPLEMENTED; } return pResampler->pBackendVTable->onGetExpectedOutputFrameCount(pResampler->pBackendUserData, pResampler->pBackend, inputFrameCount, pOutputFrameCount); } MA_API ma_result ma_resampler_reset(ma_resampler* pResampler) { if (pResampler == NULL) { return MA_INVALID_ARGS; } if (pResampler->pBackendVTable == NULL || pResampler->pBackendVTable->onReset == NULL) { return MA_NOT_IMPLEMENTED; } return pResampler->pBackendVTable->onReset(pResampler->pBackendUserData, pResampler->pBackend); } /************************************************************************************************************************************************************** Channel Conversion **************************************************************************************************************************************************************/ #ifndef MA_CHANNEL_CONVERTER_FIXED_POINT_SHIFT #define MA_CHANNEL_CONVERTER_FIXED_POINT_SHIFT 12 #endif #define MA_PLANE_LEFT 0 #define MA_PLANE_RIGHT 1 #define MA_PLANE_FRONT 2 #define MA_PLANE_BACK 3 #define MA_PLANE_BOTTOM 4 #define MA_PLANE_TOP 5 static float g_maChannelPlaneRatios[MA_CHANNEL_POSITION_COUNT][6] = { { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}, /* MA_CHANNEL_NONE */ { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}, /* MA_CHANNEL_MONO */ { 0.5f, 0.0f, 0.5f, 0.0f, 0.0f, 0.0f}, /* MA_CHANNEL_FRONT_LEFT */ { 0.0f, 0.5f, 0.5f, 0.0f, 0.0f, 0.0f}, /* MA_CHANNEL_FRONT_RIGHT */ { 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f}, /* MA_CHANNEL_FRONT_CENTER */ { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}, /* MA_CHANNEL_LFE */ { 0.5f, 0.0f, 0.0f, 0.5f, 0.0f, 0.0f}, /* MA_CHANNEL_BACK_LEFT */ { 0.0f, 0.5f, 0.0f, 0.5f, 0.0f, 0.0f}, /* MA_CHANNEL_BACK_RIGHT */ { 0.25f, 0.0f, 0.75f, 0.0f, 0.0f, 0.0f}, /* MA_CHANNEL_FRONT_LEFT_CENTER */ { 0.0f, 0.25f, 0.75f, 0.0f, 0.0f, 0.0f}, /* MA_CHANNEL_FRONT_RIGHT_CENTER */ { 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f}, /* MA_CHANNEL_BACK_CENTER */ { 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}, /* MA_CHANNEL_SIDE_LEFT */ { 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f}, /* MA_CHANNEL_SIDE_RIGHT */ { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, /* MA_CHANNEL_TOP_CENTER */ { 0.33f, 0.0f, 0.33f, 0.0f, 0.0f, 0.34f}, /* MA_CHANNEL_TOP_FRONT_LEFT */ { 0.0f, 0.0f, 0.5f, 0.0f, 0.0f, 0.5f}, /* MA_CH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f, 0.0f}, /* MA_CHANNEL_AUX_30 */ { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}, /* MA_CHANNEL_AUX_31 */ }; static float ma_calculate_channel_position_rectangular_weight(ma_channel channelPositionA, ma_channel channelPositionB) { /* Imagine the following simplified example: You have a single input speaker which is the front/left speaker which you want to convert to the following output configuration: - front/left - side/left - back/left The front/left output is easy - it the same speaker position so it receives the full contribution of the front/left input. The amount of contribution to apply to the side/left and back/left speakers, however, is a bit more complicated. Imagine the front/left speaker as emitting audio from two planes - the front plane and the left plane. You can think of the front/left speaker emitting half of it's total volume from the front, and the other half from the left. Since part of it's volume is being emitted from the left side, and the side/left and back/left channels also emit audio from the left plane, one would expect that they would receive some amount of contribution from front/left speaker. The amount of contribution depends on how many planes are shared between the two speakers. Note that in the examples below I've added a top/front/left speaker as an example just to show how the math works across 3 spatial dimensions. The first thing to do is figure out how each speaker's volume is spread over each of plane: - front/left: 2 planes (front and left) = 1/2 = half it's total volume on each plane - side/left: 1 plane (left only) = 1/1 = entire volume from left plane - back/left: 2 planes (back and left) = 1/2 = half it's total volume on each plane - top/front/left: 3 planes (top, front and left) = 1/3 = one third it's total volume on each plane The amount of volume each channel contributes to each of it's planes is what controls how much it is willing to given and take to other channels on the same plane. The volume that is willing to the given by one channel is multiplied by the volume that is willing to be taken by the other to produce the final contribution. */ /* Contribution = Sum(Volume to Give * Volume to Take) */ float contribution = g_maChannelPlaneRatios[channelPositionA][0] * g_maChannelPlaneRatios[channelPositionB][0] + g_maChannelPlaneRatios[channelPositionA][1] * g_maChannelPlaneRatios[channelPositionB][1] + g_maChannelPlaneRatios[channelPositionA][2] * g_maChannelPlaneRatios[channelPositionB][2] + g_maChannelPlaneRatios[channelPositionA][3] * g_maChannelPlaneRatios[channelPositionB][3] + g_maChannelPlaneRatios[channelPositionA][4] * g_maChannelPlaneRatios[channelPositionB][4] + g_maChannelPlaneRatios[channelPositionA][5] * g_maChannelPlaneRatios[channelPositionB][5]; return contribution; } MA_API ma_channel_converter_config ma_channel_converter_config_init(ma_format format, ma_uint32 channelsIn, const ma_channel* pChannelMapIn, ma_uint32 channelsOut, const ma_channel* pChannelMapOut, ma_channel_mix_mode mixingMode) { ma_channel_converter_config config; MA_ZERO_OBJECT(&config); config.format = format; config.channelsIn = channelsIn; config.channelsOut = channelsOut; config.pChannelMapIn = pChannelMapIn; config.pChannelMapOut = pChannelMapOut; config.mixingMode = mixingMode; return config; } static ma_int32 ma_channel_converter_float_to_fixed(float x) { return (ma_int32)(x * (1< 0); for (iChannel = 0; iChannel < channels; ++iChannel) { if (ma_is_spatial_channel_position(ma_channel_map_get_channel(pChannelMap, channels, iChannel))) { spatialChannelCount++; } } return spatialChannelCount; } static ma_bool32 ma_is_spatial_channel_position(ma_channel channelPosition) { int i; if (channelPosition == MA_CHANNEL_NONE || channelPosition == MA_CHANNEL_MONO || channelPosition == MA_CHANNEL_LFE) { return MA_FALSE; } if (channelPosition >= MA_CHANNEL_AUX_0 && channelPosition <= MA_CHANNEL_AUX_31) { return MA_FALSE; } for (i = 0; i < 6; ++i) { /* Each side of a cube. */ if (g_maChannelPlaneRatios[channelPosition][i] != 0) { return MA_TRUE; } } return MA_FALSE; } static ma_bool32 ma_channel_map_is_passthrough(const ma_channel* pChannelMapIn, ma_uint32 channelsIn, const ma_channel* pChannelMapOut, ma_uint32 channelsOut) { if (channelsOut == channelsIn) { return ma_channel_map_is_equal(pChannelMapOut, pChannelMapIn, channelsOut); } else { return MA_FALSE; /* Channel counts differ, so cannot be a passthrough. */ } } static ma_channel_conversion_path ma_channel_map_get_conversion_path(const ma_channel* pChannelMapIn, ma_uint32 channelsIn, const ma_channel* pChannelMapOut, ma_uint32 channelsOut, ma_channel_mix_mode mode) { if (ma_channel_map_is_passthrough(pChannelMapIn, channelsIn, pChannelMapOut, channelsOut)) { return ma_channel_conversion_path_passthrough; } if (channelsOut == 1 && (pChannelMapOut == NULL || pChannelMapOut[0] == MA_CHANNEL_MONO)) { return ma_channel_conversion_path_mono_out; } if (channelsIn == 1 && (pChannelMapIn == NULL || pChannelMapIn[0] == MA_CHANNEL_MONO)) { return ma_channel_conversion_path_mono_in; } if (mode == ma_channel_mix_mode_custom_weights) { return ma_channel_conversion_path_weights; } /* We can use a simple shuffle if both channel maps have the same channel count and all channel positions are present in both. */ if (channelsIn == channelsOut) { ma_uint32 iChannelIn; ma_bool32 areAllChannelPositionsPresent = MA_TRUE; for (iChannelIn = 0; iChannelIn < channelsIn; ++iChannelIn) { ma_bool32 isInputChannelPositionInOutput = MA_FALSE; if (ma_channel_map_contains_channel_position(channelsOut, pChannelMapOut, ma_channel_map_get_channel(pChannelMapIn, channelsIn, iChannelIn))) { isInputChannelPositionInOutput = MA_TRUE; break; } if (!isInputChannelPositionInOutput) { areAllChannelPositionsPresent = MA_FALSE; break; } } if (areAllChannelPositionsPresent) { return ma_channel_conversion_path_shuffle; } } /* Getting here means we'll need to use weights. */ return ma_channel_conversion_path_weights; } static ma_result ma_channel_map_build_shuffle_table(const ma_channel* pChannelMapIn, ma_uint32 channelCountIn, const ma_channel* pChannelMapOut, ma_uint32 channelCountOut, ma_uint8* pShuffleTable) { ma_uint32 iChannelIn; ma_uint32 iChannelOut; if (pShuffleTable == NULL || channelCountIn == 0 || channelCountOut == 0) { return MA_INVALID_ARGS; } /* When building the shuffle table we just do a 1:1 mapping based on the first occurance of a channel. If the input channel has more than one occurance of a channel position, the second one will be ignored. */ for (iChannelOut = 0; iChannelOut < channelCountOut; iChannelOut += 1) { ma_channel channelOut; /* Default to MA_CHANNEL_INDEX_NULL so that if a mapping is not found it'll be set appropriately. */ pShuffleTable[iChannelOut] = MA_CHANNEL_INDEX_NULL; channelOut = ma_channel_map_get_channel(pChannelMapOut, channelCountOut, iChannelOut); for (iChannelIn = 0; iChannelIn < channelCountIn; iChannelIn += 1) { ma_channel channelIn; channelIn = ma_channel_map_get_channel(pChannelMapIn, channelCountIn, iChannelIn); if (channelOut == channelIn) { pShuffleTable[iChannelOut] = (ma_uint8)iChannelIn; break; } /* Getting here means the channels don't exactly match, but we are going to support some relaxed matching for practicality. If, for example, there are two stereo channel maps, but one uses front left/right and the other uses side left/right, it makes logical sense to just map these. The way we'll do it is we'll check if there is a logical corresponding mapping, and if so, apply it, but we will *not* break from the loop, thereby giving the loop a chance to find an exact match later which will take priority. */ switch (channelOut) { /* Left channels. */ case MA_CHANNEL_FRONT_LEFT: case MA_CHANNEL_SIDE_LEFT: { switch (channelIn) { case MA_CHANNEL_FRONT_LEFT: case MA_CHANNEL_SIDE_LEFT: { pShuffleTable[iChannelOut] = (ma_uint8)iChannelIn; } break; } } break; /* Right channels. */ case MA_CHANNEL_FRONT_RIGHT: case MA_CHANNEL_SIDE_RIGHT: { switch (channelIn) { case MA_CHANNEL_FRONT_RIGHT: case MA_CHANNEL_SIDE_RIGHT: { pShuffleTable[iChannelOut] = (ma_uint8)iChannelIn; } break; } } break; default: break; } } } return MA_SUCCESS; } static void ma_channel_map_apply_shuffle_table_u8(ma_uint8* pFramesOut, ma_uint32 channelsOut, const ma_uint8* pFramesIn, ma_uint32 channelsIn, ma_uint64 frameCount, const ma_uint8* pShuffleTable) { ma_uint64 iFrame; ma_uint32 iChannelOut; for (iFrame = 0; iFrame < frameCount; iFrame += 1) { for (iChannelOut = 0; iChannelOut < channelsOut; iChannelOut += 1) { ma_uint8 iChannelIn = pShuffleTable[iChannelOut]; if (iChannelIn < channelsIn) { /* For safety, and to deal with MA_CHANNEL_INDEX_NULL. */ pFramesOut[iChannelOut] = pFramesIn[iChannelIn]; } else { pFramesOut[iChannelOut] = 0; } } pFramesOut += channelsOut; pFramesIn += channelsIn; } } static void ma_channel_map_apply_shuffle_table_s16(ma_int16* pFramesOut, ma_uint32 channelsOut, const ma_int16* pFramesIn, ma_uint32 channelsIn, ma_uint64 frameCount, const ma_uint8* pShuffleTable) { ma_uint64 iFrame; ma_uint32 iChannelOut; for (iFrame = 0; iFrame < frameCount; iFrame += 1) { for (iChannelOut = 0; iChannelOut < channelsOut; iChannelOut += 1) { ma_uint8 iChannelIn = pShuffleTable[iChannelOut]; if (iChannelIn < channelsIn) { /* For safety, and to deal with MA_CHANNEL_INDEX_NULL. */ pFramesOut[iChannelOut] = pFramesIn[iChannelIn]; } else { pFramesOut[iChannelOut] = 0; } } pFramesOut += channelsOut; pFramesIn += channelsIn; } } static void ma_channel_map_apply_shuffle_table_s24(ma_uint8* pFramesOut, ma_uint32 channelsOut, const ma_uint8* pFramesIn, ma_uint32 channelsIn, ma_uint64 frameCount, const ma_uint8* pShuffleTable) { ma_uint64 iFrame; ma_uint32 iChannelOut; for (iFrame = 0; iFrame < frameCount; iFrame += 1) { for (iChannelOut = 0; iChannelOut < channelsOut; iChannelOut += 1) { ma_uint8 iChannelIn = pShuffleTable[iChannelOut]; if (iChannelIn < channelsIn) { /* For safety, and to deal with MA_CHANNEL_INDEX_NULL. */ pFramesOut[iChannelOut*3 + 0] = pFramesIn[iChannelIn*3 + 0]; pFramesOut[iChannelOut*3 + 1] = pFramesIn[iChannelIn*3 + 1]; pFramesOut[iChannelOut*3 + 2] = pFramesIn[iChannelIn*3 + 2]; } else { pFramesOut[iChannelOut*3 + 0] = 0; } pFramesOut[iChannelOut*3 + 1] = 0; } pFramesOut[iChannelOut*3 + 2] = 0; pFramesOut += channelsOut*3; pFramesIn += channelsIn*3; } } static void ma_channel_map_apply_shuffle_table_s32(ma_int32* pFramesOut, ma_uint32 channelsOut, const ma_int32* pFramesIn, ma_uint32 channelsIn, ma_uint64 frameCount, const ma_uint8* pShuffleTable) { ma_uint64 iFrame; ma_uint32 iChannelOut; for (iFrame = 0; iFrame < frameCount; iFrame += 1) { for (iChannelOut = 0; iChannelOut < channelsOut; iChannelOut += 1) { ma_uint8 iChannelIn = pShuffleTable[iChannelOut]; if (iChannelIn < channelsIn) { /* For safety, and to deal with MA_CHANNEL_INDEX_NULL. */ pFramesOut[iChannelOut] = pFramesIn[iChannelIn]; } else { pFramesOut[iChannelOut] = 0; } } pFramesOut += channelsOut; pFramesIn += channelsIn; } } static void ma_channel_map_apply_shuffle_table_f32(float* pFramesOut, ma_uint32 channelsOut, const float* pFramesIn, ma_uint32 channelsIn, ma_uint64 frameCount, const ma_uint8* pShuffleTable) { ma_uint64 iFrame; ma_uint32 iChannelOut; for (iFrame = 0; iFrame < frameCount; iFrame += 1) { for (iChannelOut = 0; iChannelOut < channelsOut; iChannelOut += 1) { ma_uint8 iChannelIn = pShuffleTable[iChannelOut]; if (iChannelIn < channelsIn) { /* For safety, and to deal with MA_CHANNEL_INDEX_NULL. */ pFramesOut[iChannelOut] = pFramesIn[iChannelIn]; } else { pFramesOut[iChannelOut] = 0; } } pFramesOut += channelsOut; pFramesIn += channelsIn; } } static ma_result ma_channel_map_apply_shuffle_table(void* pFramesOut, ma_uint32 channelsOut, const void* pFramesIn, ma_uint32 channelsIn, ma_uint64 frameCount, const ma_uint8* pShuffleTable, ma_format format) { if (pFramesOut == NULL || pFramesIn == NULL || channelsOut == 0 || pShuffleTable == NULL) { return MA_INVALID_ARGS; } switch (format) { case ma_format_u8: { ma_channel_map_apply_shuffle_table_u8((ma_uint8*)pFramesOut, channelsOut, (const ma_uint8*)pFramesIn, channelsIn, frameCount, pShuffleTable); } break; case ma_format_s16: { ma_channel_map_apply_shuffle_table_s16((ma_int16*)pFramesOut, channelsOut, (const ma_int16*)pFramesIn, channelsIn, frameCount, pShuffleTable); } break; case ma_format_s24: { ma_channel_map_apply_shuffle_table_s24((ma_uint8*)pFramesOut, channelsOut, (const ma_uint8*)pFramesIn, channelsIn, frameCount, pShuffleTable); } break; case ma_format_s32: { ma_channel_map_apply_shuffle_table_s32((ma_int32*)pFramesOut, channelsOut, (const ma_int32*)pFramesIn, channelsIn, frameCount, pShuffleTable); } break; case ma_format_f32: { ma_channel_map_apply_shuffle_table_f32((float*)pFramesOut, channelsOut, (const float*)pFramesIn, channelsIn, frameCount, pShuffleTable); } break; default: return MA_INVALID_ARGS; /* Unknown format. */ } return MA_SUCCESS; } static ma_result ma_channel_map_apply_mono_out_f32(float* pFramesOut, const float* pFramesIn, const ma_channel* pChannelMapIn, ma_uint32 channelsIn, ma_uint64 frameCount) { ma_uint64 iFrame; ma_uint32 iChannelIn; ma_uint32 accumulationCount; if (pFramesOut == NULL || pFramesIn == NULL || channelsIn == 0) { return MA_INVALID_ARGS; } /* In this case the output stream needs to be the average of all channels, ignoring NONE. */ /* A quick pre-processing step to get the accumulation counter since we're ignoring NONE channels. */ accumulationCount = 0; for (iChannelIn = 0; iChannelIn < channelsIn; iChannelIn += 1) { if (ma_channel_map_get_channel(pChannelMapIn, channelsIn, iChannelIn) != MA_CHANNEL_NONE) { accumulationCount += 1; } } if (accumulationCount > 0) { /* <-- Prevent a division by zero. */ for (iFrame = 0; iFrame < frameCount; iFrame += 1) { float accumulation = 0; for (iChannelIn = 0; iChannelIn < channelsIn; iChannelIn += 1) { ma_channel channelIn = ma_channel_map_get_channel(pChannelMapIn, channelsIn, iChannelIn); if (channelIn != MA_CHANNEL_NONE) { accumulation += pFramesIn[iChannelIn]; } } pFramesOut[0] = accumulation / accumulationCount; pFramesOut += 1; pFramesIn += channelsIn; } } else { ma_silence_pcm_frames(pFramesOut, frameCount, ma_format_f32, 1); } return MA_SUCCESS; } static ma_result ma_channel_map_apply_mono_in_f32(float* MA_RESTRICT pFramesOut, const ma_channel* pChannelMapOut, ma_uint32 channelsOut, const float* MA_RESTRICT pFramesIn, ma_uint64 frameCount, ma_mono_expansion_mode monoExpansionMode) { ma_uint64 iFrame; ma_uint32 iChannelOut; if (pFramesOut == NULL || channelsOut == 0 || pFramesIn == NULL) { return MA_INVALID_ARGS; } /* Note that the MA_CHANNEL_NONE channel must be ignored in all cases. */ switch (monoExpansionMode) { case ma_mono_expansion_mode_average: { float weight; ma_uint32 validChannelCount = 0; for (iChannelOut = 0; iChannelOut < channelsOut; iChannelOut += 1) { ma_channel channelOut = ma_channel_map_get_channel(pChannelMapOut, channelsOut, iChannelOut); if (channelOut != MA_CHANNEL_NONE) { validChannelCount += 1; } } weight = 1.0f / validChannelCount; for (iFrame = 0; iFrame < frameCount; iFrame += 1) { for (iChannelOut = 0; iChannelOut < channelsOut; iChannelOut += 1) { ma_channel channelOut = ma_channel_map_get_channel(pChannelMapOut, channelsOut, iChannelOut); if (channelOut != MA_CHANNEL_NONE) { pFramesOut[iChannelOut] = pFramesIn[0] * weight; } } pFramesOut += channelsOut; pFramesIn += 1; } } break; case ma_mono_expansion_mode_stereo_only: { if (channelsOut >= 2) { ma_uint32 iChannelLeft = (ma_uint32)-1; ma_uint32 iChannelRight = (ma_uint32)-1; /* We first need to find our stereo channels. We prefer front-left and front-right, but if they're not available, we'll also try side-left and side-right. If neither are available we'll fall through to the default case below. */ for (iChannelOut = 0; iChannelOut < channelsOut; iChannelOut += 1) { ma_channel channelOut = ma_channel_map_get_channel(pChannelMapOut, channelsOut, iChannelOut); if (channelOut == MA_CHANNEL_SIDE_LEFT) { iChannelLeft = iChannelOut; } if (channelOut == MA_CHANNEL_SIDE_RIGHT) { iChannelRight = iChannelOut; } } for (iChannelOut = 0; iChannelOut < channelsOut; iChannelOut += 1) { ma_channel channelOut = ma_channel_map_get_channel(pChannelMapOut, channelsOut, iChannelOut); if (channelOut == MA_CHANNEL_FRONT_LEFT) { iChannelLeft = iChannelOut; } if (channelOut == MA_CHANNEL_FRONT_RIGHT) { iChannelRight = iChannelOut; } } if (iChannelLeft != (ma_uint32)-1 && iChannelRight != (ma_uint32)-1) { /* We found our stereo channels so we can duplicate the signal across those channels. */ for (iFrame = 0; iFrame < frameCount; iFrame += 1) { for (iChannelOut = 0; iChannelOut < channelsOut; iChannelOut += 1) { ma_channel channelOut = ma_channel_map_get_channel(pChannelMapOut, channelsOut, iChannelOut); if (channelOut != MA_CHANNEL_NONE) { if (iChannelOut == iChannelLeft || iChannelOut == iChannelRight) { pFramesOut[iChannelOut] = pFramesIn[0]; } else { pFramesOut[iChannelOut] = 0.0f; } } } pFramesOut += channelsOut; pFramesIn += 1; } break; /* Get out of the switch. */ } else { /* Fallthrough. Does not have left and right channels. */ goto default_handler; } } else { /* Fallthrough. Does not have stereo channels. */ goto default_handler; } }; /* Fallthrough. See comments above. */ case ma_mono_expansion_mode_duplicate: default: { default_handler: { if (channelsOut <= MA_MAX_CHANNELS) { ma_bool32 hasEmptyChannel = MA_FALSE; ma_channel channelPositions[MA_MAX_CHANNELS]; for (iChannelOut = 0; iChannelOut < channelsOut; iChannelOut += 1) { channelPositions[iChannelOut] = ma_channel_map_get_channel(pChannelMapOut, channelsOut, iChannelOut); if (channelPositions[iChannelOut] == MA_CHANNEL_NONE) { hasEmptyChannel = MA_TRUE; } } if (hasEmptyChannel == MA_FALSE) { /* Faster path when there's no MA_CHANNEL_NONE channel positions. This should hopefully help the compiler with auto-vectorization.m */ if (channelsOut == 2) { #if defined(MA_SUPPORT_SSE2) if (ma_has_sse2()) { /* We want to do two frames in each iteration. */ ma_uint64 unrolledFrameCount = frameCount >> 1; for (iFrame = 0; iFrame < unrolledFrameCount; iFrame += 1) { __m128 in0 = _mm_set1_ps(pFramesIn[iFrame*2 + 0]); __m128 in1 = _mm_set1_ps(pFramesIn[iFrame*2 + 1]); _mm_storeu_ps(&pFramesOut[iFrame*4 + 0], _mm_shuffle_ps(in0, in1, _MM_SHUFFLE(0, 0, 0, 0))); } /* Tail. */ iFrame = unrolledFrameCount << 1; goto generic_on_fastpath; } else #endif { for (iFrame = 0; iFrame < frameCount; iFrame += 1) { for (iChannelOut = 0; iChannelOut < 2; iChannelOut += 1) { pFramesOut[iFrame*2 + iChannelOut] = pFramesIn[iFrame]; } } } } else if (channelsOut == 6) { #if defined(MA_SUPPORT_SSE2) if (ma_has_sse2()) { /* We want to do two frames in each iteration so we can have a multiple of 4 samples. */ ma_uint64 unrolledFrameCount = frameCount >> 1; for (iFrame = 0; iFrame < unrolledFrameCount; iFrame += 1) { __m128 in0 = _mm_set1_ps(pFramesIn[iFrame*2 + 0]); __m128 in1 = _mm_set1_ps(pFramesIn[iFrame*2 + 1]); _mm_storeu_ps(&pFramesOut[iFrame*12 + 0], in0); _mm_storeu_ps(&pFramesOut[iFrame*12 + 4], _mm_shuffle_ps(in0, in1, _MM_SHUFFLE(0, 0, 0, 0))); _mm_storeu_ps(&pFramesOut[iFrame*12 + 8], in1); } /* Tail. */ iFrame = unrolledFrameCount << 1; goto generic_on_fastpath; } else #endif { for (iFrame = 0; iFrame < frameCount; iFrame += 1) { for (iChannelOut = 0; iChannelOut < 6; iChannelOut += 1) { pFramesOut[iFrame*6 + iChannelOut] = pFramesIn[iFrame]; } } } } else if (channelsOut == 8) { #if defined(MA_SUPPORT_SSE2) if (ma_has_sse2()) { for (iFrame = 0; iFrame < frameCount; iFrame += 1) { __m128 in = _mm_set1_ps(pFramesIn[iFrame]); _mm_storeu_ps(&pFramesOut[iFrame*8 + 0], in); _mm_storeu_ps(&pFramesOut[iFrame*8 + 4], in); } } else #endif { for (iFrame = 0; iFrame < frameCount; iFrame += 1) { for (iChannelOut = 0; iChannelOut < 8; iChannelOut += 1) { pFramesOut[iFrame*8 + iChannelOut] = pFramesIn[iFrame]; } } } } else { iFrame = 0; #if defined(MA_SUPPORT_SSE2) /* For silencing a warning with non-x86 builds. */ generic_on_fastpath: #endif { for (; iFrame < frameCount; iFrame += 1) { for (iChannelOut = 0; iChannelOut < channelsOut; iChannelOut += 1) { pFramesOut[iFrame*channelsOut + iChannelOut] = pFramesIn[iFrame]; } } } } } else { /* Slow path. Need to handle MA_CHANNEL_NONE. */ for (iFrame = 0; iFrame < frameCount; iFrame += 1) { for (iChannelOut = 0; iChannelOut < channelsOut; iChannelOut += 1) { if (channelPositions[iChannelOut] != MA_CHANNEL_NONE) { pFramesOut[iFrame*channelsOut + iChannelOut] = pFramesIn[iFrame]; } } } } } else { /* Slow path. Too many channels to store on the stack. */ for (iFrame = 0; iFrame < frameCount; iFrame += 1) { for (iChannelOut = 0; iChannelOut < channelsOut; iChannelOut += 1) { ma_channel channelOut = ma_channel_map_get_channel(pChannelMapOut, channelsOut, iChannelOut); if (channelOut != MA_CHANNEL_NONE) { pFramesOut[iFrame*channelsOut + iChannelOut] = pFramesIn[iFrame]; } } } } } } break; } return MA_SUCCESS; } static void ma_channel_map_apply_f32(float* pFramesOut, const ma_channel* pChannelMapOut, ma_uint32 channelsOut, const float* pFramesIn, const ma_channel* pChannelMapIn, ma_uint32 channelsIn, ma_uint64 frameCount, ma_channel_mix_mode mode, ma_mono_expansion_mode monoExpansionMode) { ma_channel_conversion_path conversionPath = ma_channel_map_get_conversion_path(pChannelMapIn, channelsIn, pChannelMapOut, channelsOut, mode); /* Optimized Path: Passthrough */ if (conversionPath == ma_channel_conversion_path_passthrough) { ma_copy_pcm_frames(pFramesOut, pFramesIn, frameCount, ma_format_f32, channelsOut); return; } /* Special Path: Mono Output. */ if (conversionPath == ma_channel_conversion_path_mono_out) { ma_channel_map_apply_mono_out_f32(pFramesOut, pFramesIn, pChannelMapIn, channelsIn, frameCount); return; } /* Special Path: Mono Input. */ if (conversionPath == ma_channel_conversion_path_mono_in) { ma_channel_map_apply_mono_in_f32(pFramesOut, pChannelMapOut, channelsOut, pFramesIn, frameCount, monoExpansionMode); return; } /* Getting here means we aren't running on an optimized conversion path. */ if (channelsOut <= MA_MAX_CHANNELS) { ma_result result; if (mode == ma_channel_mix_mode_simple) { ma_channel shuffleTable[MA_MAX_CHANNELS]; result = ma_channel_map_build_shuffle_table(pChannelMapIn, channelsIn, pChannelMapOut, channelsOut, shuffleTable); if (result != MA_SUCCESS) { return; } result = ma_channel_map_apply_shuffle_table(pFramesOut, channelsOut, pFramesIn, channelsIn, frameCount, shuffleTable, ma_format_f32); if (result != MA_SUCCESS) { return; } } else { ma_uint32 iFrame; ma_uint32 iChannelOut; ma_uint32 iChannelIn; float weights[32][32]; /* Do not use MA_MAX_CHANNELS here! */ /* If we have a small enough number of channels, pre-compute the weights. Otherwise we'll just need to fall back to a slower path because otherwise we'll run out of stack space. */ if (channelsIn <= ma_countof(weights) && channelsOut <= ma_countof(weights)) { /* Pre-compute weights. */ for (iChannelOut = 0; iChannelOut < channelsOut; iChannelOut += 1) { ma_channel channelOut = ma_channel_map_get_channel(pChannelMapOut, channelsOut, iChannelOut); for (iChannelIn = 0; iChannelIn < channelsIn; iChannelIn += 1) { ma_channel channelIn = ma_channel_map_get_channel(pChannelMapIn, channelsIn, iChannelIn); weights[iChannelOut][iChannelIn] = ma_calculate_channel_position_rectangular_weight(channelOut, channelIn); } } iFrame = 0; /* Experiment: Try an optimized unroll for some specific cases to see how it improves performance. RESULT: Good gains. */ if (channelsOut == 8) { /* Experiment 2: Expand the inner loop to see what kind of different it makes. RESULT: Small, but worthwhile gain. */ if (channelsIn == 2) { for (; iFrame < frameCount; iFrame += 1) { float accumulation[8] = { 0, 0, 0, 0, 0, 0, 0, 0 }; accumulation[0] += pFramesIn[iFrame*2 + 0] * weights[0][0]; accumulation[1] += pFramesIn[iFrame*2 + 0] * weights[1][0]; accumulation[2] += pFramesIn[iFrame*2 + 0] * weights[2][0]; accumulation[3] += pFramesIn[iFrame*2 + 0] * weights[3][0]; accumulation[4] += pFramesIn[iFrame*2 + 0] * weights[4][0]; accumulation[5] += pFramesIn[iFrame*2 + 0] * weights[5][0]; accumulation[6] += pFramesIn[iFrame*2 + 0] * weights[6][0]; accumulation[7] += pFramesIn[iFrame*2 + 0] * weights[7][0]; accumulation[0] += pFramesIn[iFrame*2 + 1] * weights[0][1]; accumulation[1] += pFramesIn[iFrame*2 + 1] * weights[1][1]; accumulation[2] += pFramesIn[iFrame*2 + 1] * weights[2][1]; accumulation[3] += pFramesIn[iFrame*2 + 1] * weights[3][1]; accumulation[4] += pFramesIn[iFrame*2 + 1] * weights[4][1]; accumulation[5] += pFramesIn[iFrame*2 + 1] * weights[5][1]; accumulation[6] += pFramesIn[iFrame*2 + 1] * weights[6][1]; accumulation[7] += pFramesIn[iFrame*2 + 1] * weights[7][1]; pFramesOut[iFrame*8 + 0] = accumulation[0]; pFramesOut[iFrame*8 + 1] = accumulation[1]; pFramesOut[iFrame*8 + 2] = accumulation[2]; pFramesOut[iFrame*8 + 3] = accumulation[3]; pFramesOut[iFrame*8 + 4] = accumulation[4]; pFramesOut[iFrame*8 + 5] = accumulation[5]; pFramesOut[iFrame*8 + 6] = accumulation[6]; pFramesOut[iFrame*8 + 7] = accumulation[7]; } } else { /* When outputting to 8 channels, we can do everything in groups of two 4x SIMD operations. */ for (; iFrame < frameCount; iFrame += 1) { float accumulation[8] = { 0, 0, 0, 0, 0, 0, 0, 0 }; for (iChannelIn = 0; iChannelIn < channelsIn; iChannelIn += 1) { accumulation[0] += pFramesIn[iFrame*channelsIn + iChannelIn] * weights[0][iChannelIn]; accumulation[1] += pFramesIn[iFrame*channelsIn + iChannelIn] * weights[1][iChannelIn]; accumulation[2] += pFramesIn[iFrame*channelsIn + iChannelIn] * weights[2][iChannelIn]; accumulation[3] += pFramesIn[iFrame*channelsIn + iChannelIn] * weights[3][iChannelIn]; accumulation[4] += pFramesIn[iFrame*channelsIn + iChannelIn] * weights[4][iChannelIn]; accumulation[5] += pFramesIn[iFrame*channelsIn + iChannelIn] * weights[5][iChannelIn]; accumulation[6] += pFramesIn[iFrame*channelsIn + iChannelIn] * weights[6][iChannelIn]; accumulation[7] += pFramesIn[iFrame*channelsIn + iChannelIn] * weights[7][iChannelIn]; } pFramesOut[iFrame*8 + 0] = accumulation[0]; pFramesOut[iFrame*8 + 1] = accumulation[1]; pFramesOut[iFrame*8 + 2] = accumulation[2]; pFramesOut[iFrame*8 + 3] = accumulation[3]; pFramesOut[iFrame*8 + 4] = accumulation[4]; pFramesOut[iFrame*8 + 5] = accumulation[5]; pFramesOut[iFrame*8 + 6] = accumulation[6]; pFramesOut[iFrame*8 + 7] = accumulation[7]; } } } else if (channelsOut == 6) { /* When outputting to 6 channels we unfortunately don't have a nice multiple of 4 to do 4x SIMD operations. Instead we'll expand our weights and do two frames at a time. */ for (; iFrame < frameCount; iFrame += 1) { float accumulation[12] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; for (iChannelIn = 0; iChannelIn < channelsIn; iChannelIn += 1) { accumulation[0] += pFramesIn[iFrame*channelsIn + iChannelIn] * weights[0][iChannelIn]; accumulation[1] += pFramesIn[iFrame*channelsIn + iChannelIn] * weights[1][iChannelIn]; accumulation[2] += pFramesIn[iFrame*channelsIn + iChannelIn] * weights[2][iChannelIn]; accumulation[3] += pFramesIn[iFrame*channelsIn + iChannelIn] * weights[3][iChannelIn]; accumulation[4] += pFramesIn[iFrame*channelsIn + iChannelIn] * weights[4][iChannelIn]; accumulation[5] += pFramesIn[iFrame*channelsIn + iChannelIn] * weights[5][iChannelIn]; } pFramesOut[iFrame*6 + 0] = accumulation[0]; pFramesOut[iFrame*6 + 1] = accumulation[1]; pFramesOut[iFrame*6 + 2] = accumulation[2]; pFramesOut[iFrame*6 + 3] = accumulation[3]; pFramesOut[iFrame*6 + 4] = accumulation[4]; pFramesOut[iFrame*6 + 5] = accumulation[5]; } } /* Leftover frames. */ for (; iFrame < frameCount; iFrame += 1) { for (iChannelOut = 0; iChannelOut < channelsOut; iChannelOut += 1) { float accumulation = 0; for (iChannelIn = 0; iChannelIn < channelsIn; iChannelIn += 1) { accumulation += pFramesIn[iFrame*channelsIn + iChannelIn] * weights[iChannelOut][iChannelIn]; } pFramesOut[iFrame*channelsOut + iChannelOut] = accumulation; } } } else { /* Cannot pre-compute weights because not enough room in stack-allocated buffer. */ for (iFrame = 0; iFrame < frameCount; iFrame += 1) { for (iChannelOut = 0; iChannelOut < channelsOut; iChannelOut += 1) { float accumulation = 0; ma_channel channelOut = ma_channel_map_get_channel(pChannelMapOut, channelsOut, iChannelOut); for (iChannelIn = 0; iChannelIn < channelsIn; iChannelIn += 1) { ma_channel channelIn = ma_channel_map_get_channel(pChannelMapIn, channelsIn, iChannelIn); accumulation += pFramesIn[iFrame*channelsIn + iChannelIn] * ma_calculate_channel_position_rectangular_weight(channelOut, channelIn); } pFramesOut[iFrame*channelsOut + iChannelOut] = accumulation; } } } } } else { /* Fall back to silence. If you hit this, what are you doing with so many channels?! */ ma_silence_pcm_frames(pFramesOut, frameCount, ma_format_f32, channelsOut); } } typedef struct { size_t sizeInBytes; size_t channelMapInOffset; size_t channelMapOutOffset; size_t shuffleTableOffset; size_t weightsOffset; } ma_channel_converter_heap_layout; static ma_channel_conversion_path ma_channel_converter_config_get_conversion_path(const ma_channel_converter_config* pConfig) { return ma_channel_map_get_conversion_path(pConfig->pChannelMapIn, pConfig->channelsIn, pConfig->pChannelMapOut, pConfig->channelsOut, pConfig->mixingMode); } static ma_result ma_channel_converter_get_heap_layout(const ma_channel_converter_config* pConfig, ma_channel_converter_heap_layout* pHeapLayout) { ma_channel_conversion_path conversionPath; MA_ASSERT(pHeapLayout != NULL); if (pConfig == NULL) { return MA_INVALID_ARGS; } if (pConfig->channelsIn == 0 || pConfig->channelsOut == 0) { return MA_INVALID_ARGS; } if (!ma_channel_map_is_valid(pConfig->pChannelMapIn, pConfig->channelsIn)) { return MA_INVALID_ARGS; } if (!ma_channel_map_is_valid(pConfig->pChannelMapOut, pConfig->channelsOut)) { return MA_INVALID_ARGS; } pHeapLayout->sizeInBytes = 0; /* Input channel map. Only need to allocate this if we have an input channel map (otherwise default channel map is assumed). */ pHeapLayout->channelMapInOffset = pHeapLayout->sizeInBytes; if (pConfig->pChannelMapIn != NULL) { pHeapLayout->sizeInBytes += sizeof(ma_channel) * pConfig->channelsIn; } /* Output channel map. Only need to allocate this if we have an output channel map (otherwise default channel map is assumed). */ pHeapLayout->channelMapOutOffset = pHeapLayout->sizeInBytes; if (pConfig->pChannelMapOut != NULL) { pHeapLayout->sizeInBytes += sizeof(ma_channel) * pConfig->channelsOut; } /* Alignment for the next section. */ pHeapLayout->sizeInBytes = ma_align_64(pHeapLayout->sizeInBytes); /* Whether or not we use weights of a shuffle table depends on the channel map themselves and the algorithm we've chosen. */ conversionPath = ma_channel_converter_config_get_conversion_path(pConfig); /* Shuffle table */ pHeapLayout->shuffleTableOffset = pHeapLayout->sizeInBytes; if (conversionPath == ma_channel_conversion_path_shuffle) { pHeapLayout->sizeInBytes += sizeof(ma_uint8) * pConfig->channelsOut; } /* Weights */ pHeapLayout->weightsOffset = pHeapLayout->sizeInBytes; if (conversionPath == ma_channel_conversion_path_weights) { pHeapLayout->sizeInBytes += sizeof(float*) * pConfig->channelsIn; pHeapLayout->sizeInBytes += sizeof(float ) * pConfig->channelsIn * pConfig->channelsOut; } /* Make sure allocation size is aligned. */ pHeapLayout->sizeInBytes = ma_align_64(pHeapLayout->sizeInBytes); return MA_SUCCESS; } MA_API ma_result ma_channel_converter_get_heap_size(const ma_channel_converter_config* pConfig, size_t* pHeapSizeInBytes) { ma_result result; ma_channel_converter_heap_layout heapLayout; if (pHeapSizeInBytes == NULL) { return MA_INVALID_ARGS; } *pHeapSizeInBytes = 0; result = ma_channel_converter_get_heap_layout(pConfig, &heapLayout); if (result != MA_SUCCESS) { return result; } *pHeapSizeInBytes = heapLayout.sizeInBytes; return MA_SUCCESS; } MA_API ma_result ma_channel_converter_init_preallocated(const ma_channel_converter_config* pConfig, void* pHeap, ma_channel_converter* pConverter) { ma_result result; ma_channel_converter_heap_layout heapLayout; if (pConverter == NULL) { return MA_INVALID_ARGS; } MA_ZERO_OBJECT(pConverter); result = ma_channel_converter_get_heap_layout(pConfig, &heapLayout); if (result != MA_SUCCESS) { return result; } pConverter->_pHeap = pHeap; MA_ZERO_MEMORY(pConverter->_pHeap, heapLayout.sizeInBytes); pConverter->format = pConfig->format; pConverter->channelsIn = pConfig->channelsIn; pConverter->channelsOut = pConfig->channelsOut; pConverter->mixingMode = pConfig->mixingMode; if (pConfig->pChannelMapIn != NULL) { pConverter->pChannelMapIn = (ma_channel*)ma_offset_ptr(pHeap, heapLayout.channelMapInOffset); ma_channel_map_copy_or_default(pConverter->pChannelMapIn, pConfig->channelsIn, pConfig->pChannelMapIn, pConfig->channelsIn); } else { pConverter->pChannelMapIn = NULL; /* Use default channel map. */ } if (pConfig->pChannelMapOut != NULL) { pConverter->pChannelMapOut = (ma_channel*)ma_offset_ptr(pHeap, heapLayout.channelMapOutOffset); ma_channel_map_copy_or_default(pConverter->pChannelMapOut, pConfig->channelsOut, pConfig->pChannelMapOut, pConfig->channelsOut); } else { pConverter->pChannelMapOut = NULL; /* Use default channel map. */ } pConverter->conversionPath = ma_channel_converter_config_get_conversion_path(pConfig); if (pConverter->conversionPath == ma_channel_conversion_path_shuffle) { pConverter->pShuffleTable = (ma_uint8*)ma_offset_ptr(pHeap, heapLayout.shuffleTableOffset); ma_channel_map_build_shuffle_table(pConverter->pChannelMapIn, pConverter->channelsIn, pConverter->pChannelMapOut, pConverter->channelsOut, pConverter->pShuffleTable); } if (pConverter->conversionPath == ma_channel_conversion_path_weights) { ma_uint32 iChannelIn; ma_uint32 iChannelOut; if (pConverter->format == ma_format_f32) { pConverter->weights.f32 = (float** )ma_offset_ptr(pHeap, heapLayout.weightsOffset); for (iChannelIn = 0; iChannelIn < pConverter->channelsIn; iChannelIn += 1) { pConverter->weights.f32[iChannelIn] = (float*)ma_offset_ptr(pHeap, heapLayout.weightsOffset + ((sizeof(float*) * pConverter->channelsIn) + (sizeof(float) * pConverter->channelsOut * iChannelIn))); } } else { pConverter->weights.s16 = (ma_int32**)ma_offset_ptr(pHeap, heapLayout.weightsOffset); for (iChannelIn = 0; iChannelIn < pConverter->channelsIn; iChannelIn += 1) { pConverter->weights.s16[iChannelIn] = (ma_int32*)ma_offset_ptr(pHeap, heapLayout.weightsOffset + ((sizeof(ma_int32*) * pConverter->channelsIn) + (sizeof(ma_int32) * pConverter->channelsOut * iChannelIn))); } } /* Silence our weights by default. */ for (iChannelIn = 0; iChannelIn < pConverter->channelsIn; iChannelIn += 1) { for (iChannelOut = 0; iChannelOut < pConverter->channelsOut; iChannelOut += 1) { if (pConverter->format == ma_format_f32) { pConverter->weights.f32[iChannelIn][iChannelOut] = 0.0f; } else { pConverter->weights.s16[iChannelIn][iChannelOut] = 0; } } } /* We now need to fill out our weights table. This is determined by the mixing mode. */ /* In all cases we need to make sure all channels that are present in both channel maps have a 1:1 mapping. */ for (iChannelIn = 0; iChannelIn < pConverter->channelsIn; ++iChannelIn) { ma_channel channelPosIn = ma_channel_map_get_channel(pConverter->pChannelMapIn, pConverter->channelsIn, iChannelIn); for (iChannelOut = 0; iChannelOut < pConverter->channelsOut; ++iChannelOut) { ma_channel channelPosOut = ma_channel_map_get_channel(pConverter->pChannelMapOut, pConverter->channelsOut, iChannelOut); if (channelPosIn == channelPosOut) { float weight = 1; if (pConverter->format == ma_format_f32) { pConverter->weights.f32[iChannelIn][iChannelOut] = weight; } else { pConverter->weights.s16[iChannelIn][iChannelOut] = ma_channel_converter_float_to_fixed(weight); } } } } switch (pConverter->mixingMode) { case ma_channel_mix_mode_custom_weights: { if (pConfig->ppWeights == NULL) { return MA_INVALID_ARGS; /* Config specified a custom weights mixing mode, but no custom weights have been specified. */ } for (iChannelIn = 0; iChannelIn < pConverter->channelsIn; iChannelIn += 1) { for (iChannelOut = 0; iChannelOut < pConverter->channelsOut; iChannelOut += 1) { float weight = pConfig->ppWeights[iChannelIn][iChannelOut]; if (pConverter->format == ma_format_f32) { pConverter->weights.f32[iChannelIn][iChannelOut] = weight; } else { pConverter->weights.s16[iChannelIn][iChannelOut] = ma_channel_converter_float_to_fixed(weight); } } } } break; case ma_channel_mix_mode_simple: { /* In simple mode, only set weights for channels that have exactly matching types, leave the rest at zero. The 1:1 mappings have already been covered before this switch statement. */ } break; case ma_channel_mix_mode_rectangular: default: { /* Unmapped input channels. */ for (iChannelIn = 0; iChannelIn < pConverter->channelsIn; ++iChannelIn) { ma_channel channelPosIn = ma_channel_map_get_channel(pConverter->pChannelMapIn, pConverter->channelsIn, iChannelIn); if (ma_is_spatial_channel_position(channelPosIn)) { if (!ma_channel_map_contains_channel_position(pConverter->channelsOut, pConverter->pChannelMapOut, channelPosIn)) { for (iChannelOut = 0; iChannelOut < pConverter->channelsOut; ++iChannelOut) { ma_channel channelPosOut = ma_channel_map_get_channel(pConverter->pChannelMapOut, pConverter->channelsOut, iChannelOut); if (ma_is_spatial_channel_position(channelPosOut)) { float weight = 0; if (pConverter->mixingMode == ma_channel_mix_mode_rectangular) { weight = ma_calculate_channel_position_rectangular_weight(channelPosIn, channelPosOut); } /* Only apply the weight if we haven't already got some contribution from the respective channels. */ if (pConverter->format == ma_format_f32) { if (pConverter->weights.f32[iChannelIn][iChannelOut] == 0) { pConverter->weights.f32[iChannelIn][iChannelOut] = weight; } } else { if (pConverter->weights.s16[iChannelIn][iChannelOut] == 0) { pConverter->weights.s16[iChannelIn][iChannelOut] = ma_channel_converter_float_to_fixed(weight); } } } } } } } /* Unmapped output channels. */ for (iChannelOut = 0; iChannelOut < pConverter->channelsOut; ++iChannelOut) { ma_channel channelPosOut = ma_channel_map_get_channel(pConverter->pChannelMapOut, pConverter->channelsOut, iChannelOut); if (ma_is_spatial_channel_position(channelPosOut)) { if (!ma_channel_map_contains_channel_position(pConverter->channelsIn, pConverter->pChannelMapIn, channelPosOut)) { for (iChannelIn = 0; iChannelIn < pConverter->channelsIn; ++iChannelIn) { ma_channel channelPosIn = ma_channel_map_get_channel(pConverter->pChannelMapIn, pConverter->channelsIn, iChannelIn); if (ma_is_spatial_channel_position(channelPosIn)) { float weight = 0; if (pConverter->mixingMode == ma_channel_mix_mode_rectangular) { weight = ma_calculate_channel_position_rectangular_weight(channelPosIn, channelPosOut); } /* Only apply the weight if we haven't already got some contribution from the respective channels. */ if (pConverter->format == ma_format_f32) { if (pConverter->weights.f32[iChannelIn][iChannelOut] == 0) { pConverter->weights.f32[iChannelIn][iChannelOut] = weight; } } else { if (pConverter->weights.s16[iChannelIn][iChannelOut] == 0) { pConverter->weights.s16[iChannelIn][iChannelOut] = ma_channel_converter_float_to_fixed(weight); } } } } } } } /* If LFE is in the output channel map but was not present in the input channel map, configure its weight now */ if (pConfig->calculateLFEFromSpatialChannels) { if (!ma_channel_map_contains_channel_position(pConverter->channelsIn, pConverter->pChannelMapIn, MA_CHANNEL_LFE)) { ma_uint32 spatialChannelCount = ma_channel_map_get_spatial_channel_count(pConverter->pChannelMapIn, pConverter->channelsIn); ma_uint32 iChannelOutLFE; if (spatialChannelCount > 0 && ma_channel_map_find_channel_position(pConverter->channelsOut, pConverter->pChannelMapOut, MA_CHANNEL_LFE, &iChannelOutLFE)) { const float weightForLFE = 1.0f / spatialChannelCount; for (iChannelIn = 0; iChannelIn < pConverter->channelsIn; ++iChannelIn) { const ma_channel channelPosIn = ma_channel_map_get_channel(pConverter->pChannelMapIn, pConverter->channelsIn, iChannelIn); if (ma_is_spatial_channel_position(channelPosIn)) { if (pConverter->format == ma_format_f32) { if (pConverter->weights.f32[iChannelIn][iChannelOutLFE] == 0) { pConverter->weights.f32[iChannelIn][iChannelOutLFE] = weightForLFE; } } else { if (pConverter->weights.s16[iChannelIn][iChannelOutLFE] == 0) { pConverter->weights.s16[iChannelIn][iChannelOutLFE] = ma_channel_converter_float_to_fixed(weightForLFE); } } } } } } } } break; } } return MA_SUCCESS; } MA_API ma_result ma_channel_converter_init(const ma_channel_converter_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_channel_converter* pConverter) { ma_result result; size_t heapSizeInBytes; void* pHeap; result = ma_channel_converter_get_heap_size(pConfig, &heapSizeInBytes); if (result != MA_SUCCESS) { return result; } if (heapSizeInBytes > 0) { pHeap = ma_malloc(heapSizeInBytes, pAllocationCallbacks); if (pHeap == NULL) { return MA_OUT_OF_MEMORY; } } else { pHeap = NULL; } result = ma_channel_converter_init_preallocated(pConfig, pHeap, pConverter); if (result != MA_SUCCESS) { ma_free(pHeap, pAllocationCallbacks); return result; } pConverter->_ownsHeap = MA_TRUE; return MA_SUCCESS; } MA_API void ma_channel_converter_uninit(ma_channel_converter* pConverter, const ma_allocation_callbacks* pAllocationCallbacks) { if (pConverter == NULL) { return; } if (pConverter->_ownsHeap) { ma_free(pConverter->_pHeap, pAllocationCallbacks); } } static ma_result ma_channel_converter_process_pcm_frames__passthrough(ma_channel_converter* pConverter, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount) { MA_ASSERT(pConverter != NULL); MA_ASSERT(pFramesOut != NULL); MA_ASSERT(pFramesIn != NULL); ma_copy_memory_64(pFramesOut, pFramesIn, frameCount * ma_get_bytes_per_frame(pConverter->format, pConverter->channelsOut)); return MA_SUCCESS; } static ma_result ma_channel_converter_process_pcm_frames__shuffle(ma_channel_converter* pConverter, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount) { MA_ASSERT(pConverter != NULL); MA_ASSERT(pFramesOut != NULL); MA_ASSERT(pFramesIn != NULL); MA_ASSERT(pConverter->channelsIn == pConverter->channelsOut); return ma_channel_map_apply_shuffle_table(pFramesOut, pConverter->channelsOut, pFramesIn, pConverter->channelsIn, frameCount, pConverter->pShuffleTable, pConverter->format); } static ma_result ma_channel_converter_process_pcm_frames__mono_in(ma_channel_converter* pConverter, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount) { ma_uint64 iFrame; MA_ASSERT(pConverter != NULL); MA_ASSERT(pFramesOut != NULL); MA_ASSERT(pFramesIn != NULL); MA_ASSERT(pConverter->channelsIn == 1); switch (pConverter->format) { case ma_format_u8: { /* */ ma_uint8* pFramesOutU8 = ( ma_uint8*)pFramesOut; const ma_uint8* pFramesInU8 = (const ma_uint8*)pFramesIn; for (iFrame = 0; iFrame < frameCount; ++iFrame) { ma_uint32 iChannel; for (iChannel = 0; iChannel < pConverter->channelsOut; iChannel += 1) { pFramesOutU8[iFrame*pConverter->channelsOut + iChannel] = pFramesInU8[iFrame]; } } } break; case ma_format_s16: { /* */ ma_int16* pFramesOutS16 = ( ma_int16*)pFramesOut; const ma_int16* pFramesInS16 = (const ma_int16*)pFramesIn; if (pConverter->channelsOut == 2) { for (iFrame = 0; iFrame < frameCount; ++iFrame) { pFramesOutS16[iFrame*2 + 0] = pFramesInS16[iFrame]; pFramesOutS16[iFrame*2 + 1] = pFramesInS16[iFrame]; } } else { for (iFrame = 0; iFrame < frameCount; ++iFrame) { ma_uint32 iChannel; for (iChannel = 0; iChannel < pConverter->channelsOut; iChannel += 1) { pFramesOutS16[iFrame*pConverter->channelsOut + iChannel] = pFramesInS16[iFrame]; } } } } break; case ma_format_s24: { /* */ ma_uint8* pFramesOutS24 = ( ma_uint8*)pFramesOut; const ma_uint8* pFramesInS24 = (const ma_uint8*)pFramesIn; for (iFrame = 0; iFrame < frameCount; ++iFrame) { ma_uint32 iChannel; for (iChannel = 0; iChannel < pConverter->channelsOut; iChannel += 1) { ma_uint64 iSampleOut = iFrame*pConverter->channelsOut + iChannel; ma_uint64 iSampleIn = iFrame; pFramesOutS24[iSampleOut*3 + 0] = pFramesInS24[iSampleIn*3 + 0]; pFramesOutS24[iSampleOut*3 + 1] = pFramesInS24[iSampleIn*3 + 1]; pFramesOutS24[iSampleOut*3 + 2] = pFramesInS24[iSampleIn*3 + 2]; } } } break; case ma_format_s32: { /* */ ma_int32* pFramesOutS32 = ( ma_int32*)pFramesOut; const ma_int32* pFramesInS32 = (const ma_int32*)pFramesIn; for (iFrame = 0; iFrame < frameCount; ++iFrame) { ma_uint32 iChannel; for (iChannel = 0; iChannel < pConverter->channelsOut; iChannel += 1) { pFramesOutS32[iFrame*pConverter->channelsOut + iChannel] = pFramesInS32[iFrame]; } } } break; case ma_format_f32: { /* */ float* pFramesOutF32 = ( float*)pFramesOut; const float* pFramesInF32 = (const float*)pFramesIn; if (pConverter->channelsOut == 2) { for (iFrame = 0; iFrame < frameCount; ++iFrame) { pFramesOutF32[iFrame*2 + 0] = pFramesInF32[iFrame]; pFramesOutF32[iFrame*2 + 1] = pFramesInF32[iFrame]; } } else { for (iFrame = 0; iFrame < frameCount; ++iFrame) { ma_uint32 iChannel; for (iChannel = 0; iChannel < pConverter->channelsOut; iChannel += 1) { pFramesOutF32[iFrame*pConverter->channelsOut + iChannel] = pFramesInF32[iFrame]; } } } } break; default: return MA_INVALID_OPERATION; /* Unknown format. */ } return MA_SUCCESS; } static ma_result ma_channel_converter_process_pcm_frames__mono_out(ma_channel_converter* pConverter, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount) { ma_uint64 iFrame; ma_uint32 iChannel; MA_ASSERT(pConverter != NULL); MA_ASSERT(pFramesOut != NULL); MA_ASSERT(pFramesIn != NULL); MA_ASSERT(pConverter->channelsOut == 1); switch (pConverter->format) { case ma_format_u8: { /* */ ma_uint8* pFramesOutU8 = ( ma_uint8*)pFramesOut; const ma_uint8* pFramesInU8 = (const ma_uint8*)pFramesIn; for (iFrame = 0; iFrame < frameCount; ++iFrame) { ma_int32 t = 0; for (iChannel = 0; iChannel < pConverter->channelsIn; iChannel += 1) { t += ma_pcm_sample_u8_to_s16_no_scale(pFramesInU8[iFrame*pConverter->channelsIn + iChannel]); } pFramesOutU8[iFrame] = ma_clip_u8(t / pConverter->channelsOut); } } break; case ma_format_s16: { /* */ ma_int16* pFramesOutS16 = ( ma_int16*)pFramesOut; const ma_int16* pFramesInS16 = (const ma_int16*)pFramesIn; for (iFrame = 0; iFrame < frameCount; ++iFrame) { ma_int32 t = 0; for (iChannel = 0; iChannel < pConverter->channelsIn; iChannel += 1) { t += pFramesInS16[iFrame*pConverter->channelsIn + iChannel]; } pFramesOutS16[iFrame] = (ma_int16)(t / pConverter->channelsIn); } } break; case ma_format_s24: { /* */ ma_uint8* pFramesOutS24 = ( ma_uint8*)pFramesOut; const ma_uint8* pFramesInS24 = (const ma_uint8*)pFramesIn; for (iFrame = 0; iFrame < frameCount; ++iFrame) { ma_int64 t = 0; for (iChannel = 0; iChannel < pConverter->channelsIn; iChannel += 1) { t += ma_pcm_sample_s24_to_s32_no_scale(&pFramesInS24[(iFrame*pConverter->channelsIn + iChannel)*3]); } ma_pcm_sample_s32_to_s24_no_scale(t / pConverter->channelsIn, &pFramesOutS24[iFrame*3]); } } break; case ma_format_s32: { /* */ ma_int32* pFramesOutS32 = ( ma_int32*)pFramesOut; const ma_int32* pFramesInS32 = (const ma_int32*)pFramesIn; for (iFrame = 0; iFrame < frameCount; ++iFrame) { ma_int64 t = 0; for (iChannel = 0; iChannel < pConverter->channelsIn; iChannel += 1) { t += pFramesInS32[iFrame*pConverter->channelsIn + iChannel]; } pFramesOutS32[iFrame] = (ma_int32)(t / pConverter->channelsIn); } } break; case ma_format_f32: { /* */ float* pFramesOutF32 = ( float*)pFramesOut; const float* pFramesInF32 = (const float*)pFramesIn; for (iFrame = 0; iFrame < frameCount; ++iFrame) { float t = 0; for (iChannel = 0; iChannel < pConverter->channelsIn; iChannel += 1) { t += pFramesInF32[iFrame*pConverter->channelsIn + iChannel]; } pFramesOutF32[iFrame] = t / pConverter->channelsIn; } } break; default: return MA_INVALID_OPERATION; /* Unknown format. */ } return MA_SUCCESS; } static ma_result ma_channel_converter_process_pcm_frames__weights(ma_channel_converter* pConverter, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount) { ma_uint32 iFrame; ma_uint32 iChannelIn; ma_uint32 iChannelOut; MA_ASSERT(pConverter != NULL); MA_ASSERT(pFramesOut != NULL); MA_ASSERT(pFramesIn != NULL); /* This is the more complicated case. Each of the output channels is accumulated with 0 or more input channels. */ /* Clear. */ ma_zero_memory_64(pFramesOut, frameCount * ma_get_bytes_per_frame(pConverter->format, pConverter->channelsOut)); /* Accumulate. */ switch (pConverter->format) { case ma_format_u8: { /* */ ma_uint8* pFramesOutU8 = ( ma_uint8*)pFramesOut; const ma_uint8* pFramesInU8 = (const ma_uint8*)pFramesIn; for (iFrame = 0; iFrame < frameCount; iFrame += 1) { for (iChannelIn = 0; iChannelIn < pConverter->channelsIn; ++iChannelIn) { for (iChannelOut = 0; iChannelOut < pConverter->channelsOut; ++iChannelOut) { ma_int16 u8_O = ma_pcm_sample_u8_to_s16_no_scale(pFramesOutU8[iFrame*pConverter->channelsOut + iChannelOut]); ma_int16 u8_I = ma_pcm_sample_u8_to_s16_no_scale(pFramesInU8 [iFrame*pConverter->channelsIn + iChannelIn ]); ma_int32 s = (ma_int32)ma_clamp(u8_O + ((u8_I * pConverter->weights.s16[iChannelIn][iChannelOut]) >> MA_CHANNEL_CONVERTER_FIXED_POINT_SHIFT), -128, 127); pFramesOutU8[iFrame*pConverter->channelsOut + iChannelOut] = ma_clip_u8((ma_int16)s); } } } } break; case ma_format_s16: { /* */ ma_int16* pFramesOutS16 = ( ma_int16*)pFramesOut; const ma_int16* pFramesInS16 = (const ma_int16*)pFramesIn; for (iFrame = 0; iFrame < frameCount; iFrame += 1) { for (iChannelIn = 0; iChannelIn < pConverter->channelsIn; ++iChannelIn) { for (iChannelOut = 0; iChannelOut < pConverter->channelsOut; ++iChannelOut) { ma_int32 s = pFramesOutS16[iFrame*pConverter->channelsOut + iChannelOut]; s += (pFramesInS16[iFrame*pConverter->channelsIn + iChannelIn] * pConverter->weights.s16[iChannelIn][iChannelOut]) >> MA_CHANNEL_CONVERTER_FIXED_POINT_SHIFT; pFramesOutS16[iFrame*pConverter->channelsOut + iChannelOut] = (ma_int16)ma_clamp(s, -32768, 32767); } } } } break; case ma_format_s24: { /* */ ma_uint8* pFramesOutS24 = ( ma_uint8*)pFramesOut; const ma_uint8* pFramesInS24 = (const ma_uint8*)pFramesIn; for (iFrame = 0; iFrame < frameCount; iFrame += 1) { for (iChannelIn = 0; iChannelIn < pConverter->channelsIn; ++iChannelIn) { for (iChannelOut = 0; iChannelOut < pConverter->channelsOut; ++iChannelOut) { ma_int64 s24_O = ma_pcm_sample_s24_to_s32_no_scale(&pFramesOutS24[(iFrame*pConverter->channelsOut + iChannelOut)*3]); ma_int64 s24_I = ma_pcm_sample_s24_to_s32_no_scale(&pFramesInS24 [(iFrame*pConverter->channelsIn + iChannelIn )*3]); ma_int64 s24 = (ma_int32)ma_clamp(s24_O + ((s24_I * pConverter->weights.s16[iChannelIn][iChannelOut]) >> MA_CHANNEL_CONVERTER_FIXED_POINT_SHIFT), -8388608, 8388607); ma_pcm_sample_s32_to_s24_no_scale(s24, &pFramesOutS24[(iFrame*pConverter->channelsOut + iChannelOut)*3]); } } } } break; case ma_format_s32: { /* */ ma_int32* pFramesOutS32 = ( ma_int32*)pFramesOut; const ma_int32* pFramesInS32 = (const ma_int32*)pFramesIn; for (iFrame = 0; iFrame < frameCount; iFrame += 1) { for (iChannelIn = 0; iChannelIn < pConverter->channelsIn; ++iChannelIn) { for (iChannelOut = 0; iChannelOut < pConverter->channelsOut; ++iChannelOut) { ma_int64 s = pFramesOutS32[iFrame*pConverter->channelsOut + iChannelOut]; s += ((ma_int64)pFramesInS32[iFrame*pConverter->channelsIn + iChannelIn] * pConverter->weights.s16[iChannelIn][iChannelOut]) >> MA_CHANNEL_CONVERTER_FIXED_POINT_SHIFT; pFramesOutS32[iFrame*pConverter->channelsOut + iChannelOut] = ma_clip_s32(s); } } } } break; case ma_format_f32: { /* */ float* pFramesOutF32 = ( float*)pFramesOut; const float* pFramesInF32 = (const float*)pFramesIn; for (iFrame = 0; iFrame < frameCount; iFrame += 1) { for (iChannelIn = 0; iChannelIn < pConverter->channelsIn; ++iChannelIn) { for (iChannelOut = 0; iChannelOut < pConverter->channelsOut; ++iChannelOut) { pFramesOutF32[iFrame*pConverter->channelsOut + iChannelOut] += pFramesInF32[iFrame*pConverter->channelsIn + iChannelIn] * pConverter->weights.f32[iChannelIn][iChannelOut]; } } } } break; default: return MA_INVALID_OPERATION; /* Unknown format. */ } return MA_SUCCESS; } MA_API ma_result ma_channel_converter_process_pcm_frames(ma_channel_converter* pConverter, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount) { if (pConverter == NULL) { return MA_INVALID_ARGS; } if (pFramesOut == NULL) { return MA_INVALID_ARGS; } if (pFramesIn == NULL) { ma_zero_memory_64(pFramesOut, frameCount * ma_get_bytes_per_frame(pConverter->format, pConverter->channelsOut)); return MA_SUCCESS; } switch (pConverter->conversionPath) { case ma_channel_conversion_path_passthrough: return ma_channel_converter_process_pcm_frames__passthrough(pConverter, pFramesOut, pFramesIn, frameCount); case ma_channel_conversion_path_mono_out: return ma_channel_converter_process_pcm_frames__mono_out(pConverter, pFramesOut, pFramesIn, frameCount); case ma_channel_conversion_path_mono_in: return ma_channel_converter_process_pcm_frames__mono_in(pConverter, pFramesOut, pFramesIn, frameCount); case ma_channel_conversion_path_shuffle: return ma_channel_converter_process_pcm_frames__shuffle(pConverter, pFramesOut, pFramesIn, frameCount); case ma_channel_conversion_path_weights: default: { return ma_channel_converter_process_pcm_frames__weights(pConverter, pFramesOut, pFramesIn, frameCount); } } } MA_API ma_result ma_channel_converter_get_input_channel_map(const ma_channel_converter* pConverter, ma_channel* pChannelMap, size_t channelMapCap) { if (pConverter == NULL || pChannelMap == NULL) { return MA_INVALID_ARGS; } ma_channel_map_copy_or_default(pChannelMap, channelMapCap, pConverter->pChannelMapIn, pConverter->channelsIn); return MA_SUCCESS; } MA_API ma_result ma_channel_converter_get_output_channel_map(const ma_channel_converter* pConverter, ma_channel* pChannelMap, size_t channelMapCap) { if (pConverter == NULL || pChannelMap == NULL) { return MA_INVALID_ARGS; } ma_channel_map_copy_or_default(pChannelMap, channelMapCap, pConverter->pChannelMapOut, pConverter->channelsOut); return MA_SUCCESS; } /************************************************************************************************************************************************************** Data Conversion **************************************************************************************************************************************************************/ MA_API ma_data_converter_config ma_data_converter_config_init_default(void) { ma_data_converter_config config; MA_ZERO_OBJECT(&config); config.ditherMode = ma_dither_mode_none; config.resampling.algorithm = ma_resample_algorithm_linear; config.allowDynamicSampleRate = MA_FALSE; /* Disable dynamic sample rates by default because dynamic rate adjustments should be quite rare and it allows an optimization for cases when the in and out sample rates are the same. */ /* Linear resampling defaults. */ config.resampling.linear.lpfOrder = 1; return config; } MA_API ma_data_converter_config ma_data_converter_config_init(ma_format formatIn, ma_format formatOut, ma_uint32 channelsIn, ma_uint32 channelsOut, ma_uint32 sampleRateIn, ma_uint32 sampleRateOut) { ma_data_converter_config config = ma_data_converter_config_init_default(); config.formatIn = formatIn; config.formatOut = formatOut; config.channelsIn = channelsIn; config.channelsOut = channelsOut; config.sampleRateIn = sampleRateIn; config.sampleRateOut = sampleRateOut; return config; } typedef struct { size_t sizeInBytes; size_t channelConverterOffset; size_t resamplerOffset; } ma_data_converter_heap_layout; static ma_bool32 ma_data_converter_config_is_resampler_required(const ma_data_converter_config* pConfig) { MA_ASSERT(pConfig != NULL); return pConfig->allowDynamicSampleRate || pConfig->sampleRateIn != pConfig->sampleRateOut; } static ma_format ma_data_converter_config_get_mid_format(const ma_data_converter_config* pConfig) { MA_ASSERT(pConfig != NULL); /* We want to avoid as much data conversion as possible. The channel converter and linear resampler both support s16 and f32 natively. We need to decide on the format to use for this stage. We call this the mid format because it's used in the middle stage of the conversion pipeline. If the output format is either s16 or f32 we use that one. If that is not the case it will do the same thing for the input format. If it's neither we just use f32. If we are using a custom resampling backend, we can only guarantee that f32 will be supported so we'll be forced to use that if resampling is required. */ if (ma_data_converter_config_is_resampler_required(pConfig) && pConfig->resampling.algorithm != ma_resample_algorithm_linear) { return ma_format_f32; /* <-- Force f32 since that is the only one we can guarantee will be supported by the resampler. */ } else { /* */ if (pConfig->formatOut == ma_format_s16 || pConfig->formatOut == ma_format_f32) { return pConfig->formatOut; } else if (pConfig->formatIn == ma_format_s16 || pConfig->formatIn == ma_format_f32) { return pConfig->formatIn; } else { return ma_format_f32; } } } static ma_channel_converter_config ma_channel_converter_config_init_from_data_converter_config(const ma_data_converter_config* pConfig) { ma_channel_converter_config channelConverterConfig; MA_ASSERT(pConfig != NULL); channelConverterConfig = ma_channel_converter_config_init(ma_data_converter_config_get_mid_format(pConfig), pConfig->channelsIn, pConfig->pChannelMapIn, pConfig->channelsOut, pConfig->pChannelMapOut, pConfig->channelMixMode); channelConverterConfig.ppWeights = pConfig->ppChannelWeights; channelConverterConfig.calculateLFEFromSpatialChannels = pConfig->calculateLFEFromSpatialChannels; return channelConverterConfig; } static ma_resampler_config ma_resampler_config_init_from_data_converter_config(const ma_data_converter_config* pConfig) { ma_resampler_config resamplerConfig; ma_uint32 resamplerChannels; MA_ASSERT(pConfig != NULL); /* The resampler is the most expensive part of the conversion process, so we need to do it at the stage where the channel count is at it's lowest. */ if (pConfig->channelsIn < pConfig->channelsOut) { resamplerChannels = pConfig->channelsIn; } else { resamplerChannels = pConfig->channelsOut; } resamplerConfig = ma_resampler_config_init(ma_data_converter_config_get_mid_format(pConfig), resamplerChannels, pConfig->sampleRateIn, pConfig->sampleRateOut, pConfig->resampling.algorithm); resamplerConfig.linear = pConfig->resampling.linear; resamplerConfig.pBackendVTable = pConfig->resampling.pBackendVTable; resamplerConfig.pBackendUserData = pConfig->resampling.pBackendUserData; return resamplerConfig; } static ma_result ma_data_converter_get_heap_layout(const ma_data_converter_config* pConfig, ma_data_converter_heap_layout* pHeapLayout) { ma_result result; MA_ASSERT(pHeapLayout != NULL); MA_ZERO_OBJECT(pHeapLayout); if (pConfig == NULL) { return MA_INVALID_ARGS; } if (pConfig->channelsIn == 0 || pConfig->channelsOut == 0) { return MA_INVALID_ARGS; } pHeapLayout->sizeInBytes = 0; /* Channel converter. */ pHeapLayout->channelConverterOffset = pHeapLayout->sizeInBytes; { size_t heapSizeInBytes; ma_channel_converter_config channelConverterConfig = ma_channel_converter_config_init_from_data_converter_config(pConfig); result = ma_channel_converter_get_heap_size(&channelConverterConfig, &heapSizeInBytes); if (result != MA_SUCCESS) { return result; } pHeapLayout->sizeInBytes += heapSizeInBytes; } /* Resampler. */ pHeapLayout->resamplerOffset = pHeapLayout->sizeInBytes; if (ma_data_converter_config_is_resampler_required(pConfig)) { size_t heapSizeInBytes; ma_resampler_config resamplerConfig = ma_resampler_config_init_from_data_converter_config(pConfig); result = ma_resampler_get_heap_size(&resamplerConfig, &heapSizeInBytes); if (result != MA_SUCCESS) { return result; } pHeapLayout->sizeInBytes += heapSizeInBytes; } /* Make sure allocation size is aligned. */ pHeapLayout->sizeInBytes = ma_align_64(pHeapLayout->sizeInBytes); return MA_SUCCESS; } MA_API ma_result ma_data_converter_get_heap_size(const ma_data_converter_config* pConfig, size_t* pHeapSizeInBytes) { ma_result result; ma_data_converter_heap_layout heapLayout; if (pHeapSizeInBytes == NULL) { return MA_INVALID_ARGS; } *pHeapSizeInBytes = 0; result = ma_data_converter_get_heap_layout(pConfig, &heapLayout); if (result != MA_SUCCESS) { return result; } *pHeapSizeInBytes = heapLayout.sizeInBytes; return MA_SUCCESS; } MA_API ma_result ma_data_converter_init_preallocated(const ma_data_converter_config* pConfig, void* pHeap, ma_data_converter* pConverter) { ma_result result; ma_data_converter_heap_layout heapLayout; ma_format midFormat; ma_bool32 isResamplingRequired; if (pConverter == NULL) { return MA_INVALID_ARGS; } MA_ZERO_OBJECT(pConverter); result = ma_data_converter_get_heap_layout(pConfig, &heapLayout); if (result != MA_SUCCESS) { return result; } pConverter->_pHeap = pHeap; MA_ZERO_MEMORY(pHeap, heapLayout.sizeInBytes); pConverter->formatIn = pConfig->formatIn; pConverter->formatOut = pConfig->formatOut; pConverter->channelsIn = pConfig->channelsIn; pConverter->channelsOut = pConfig->channelsOut; pConverter->sampleRateIn = pConfig->sampleRateIn; pConverter->sampleRateOut = pConfig->sampleRateOut; pConverter->ditherMode = pConfig->ditherMode; /* Determine if resampling is required. We need to do this so we can determine an appropriate mid format to use. If resampling is required, the mid format must be ma_format_f32 since that is the only one that is guaranteed to supported by custom resampling backends. */ isResamplingRequired = ma_data_converter_config_is_resampler_required(pConfig); midFormat = ma_data_converter_config_get_mid_format(pConfig); /* Channel converter. We always initialize this, but we check if it configures itself as a passthrough to determine whether or not it's needed. */ { ma_channel_converter_config channelConverterConfig = ma_channel_converter_config_init_from_data_converter_config(pConfig); result = ma_channel_converter_init_preallocated(&channelConverterConfig, ma_offset_ptr(pHeap, heapLayout.channelConverterOffset), &pConverter->channelConverter); if (result != MA_SUCCESS) { return result; } /* If the channel converter is not a passthrough we need to enable it. Otherwise we can skip it. */ if (pConverter->channelConverter.conversionPath != ma_channel_conversion_path_passthrough) { pConverter->hasChannelConverter = MA_TRUE; } } /* Resampler. */ if (isResamplingRequired) { ma_resampler_config resamplerConfig = ma_resampler_config_init_from_data_converter_config(pConfig); result = ma_resampler_init_preallocated(&resamplerConfig, ma_offset_ptr(pHeap, heapLayout.resamplerOffset), &pConverter->resampler); if (result != MA_SUCCESS) { return result; } pConverter->hasResampler = MA_TRUE; } /* We can simplify pre- and post-format conversion if we have neither channel conversion nor resampling. */ if (pConverter->hasChannelConverter == MA_FALSE && pConverter->hasResampler == MA_FALSE) { /* We have neither channel conversion nor resampling so we'll only need one of pre- or post-format conversion, or none if the input and output formats are the same. */ if (pConverter->formatIn == pConverter->formatOut) { /* The formats are the same so we can just pass through. */ pConverter->hasPreFormatConversion = MA_FALSE; pConverter->hasPostFormatConversion = MA_FALSE; } else { /* The formats are different so we need to do either pre- or post-format conversion. It doesn't matter which. */ pConverter->hasPreFormatConversion = MA_FALSE; pConverter->hasPostFormatConversion = MA_TRUE; } } else { /* We have a channel converter and/or resampler so we'll need channel conversion based on the mid format. */ if (pConverter->formatIn != midFormat) { pConverter->hasPreFormatConversion = MA_TRUE; } if (pConverter->formatOut != midFormat) { pConverter->hasPostFormatConversion = MA_TRUE; } } /* We can enable passthrough optimizations if applicable. Note that we'll only be able to do this if the sample rate is static. */ if (pConverter->hasPreFormatConversion == MA_FALSE && pConverter->hasPostFormatConversion == MA_FALSE && pConverter->hasChannelConverter == MA_FALSE && pConverter->hasResampler == MA_FALSE) { pConverter->isPassthrough = MA_TRUE; } /* We now need to determine our execution path. */ if (pConverter->isPassthrough) { pConverter->executionPath = ma_data_converter_execution_path_passthrough; } else { if (pConverter->channelsIn < pConverter->channelsOut) { /* Do resampling first, if necessary. */ MA_ASSERT(pConverter->hasChannelConverter == MA_TRUE); if (pConverter->hasResampler) { pConverter->executionPath = ma_data_converter_execution_path_resample_first; } else { pConverter->executionPath = ma_data_converter_execution_path_channels_only; } } else { /* Do channel conversion first, if necessary. */ if (pConverter->hasChannelConverter) { if (pConverter->hasResampler) { pConverter->executionPath = ma_data_converter_execution_path_channels_first; } else { pConverter->executionPath = ma_data_converter_execution_path_channels_only; } } else { /* Channel routing not required. */ if (pConverter->hasResampler) { pConverter->executionPath = ma_data_converter_execution_path_resample_only; } else { pConverter->executionPath = ma_data_converter_execution_path_format_only; } } } } return MA_SUCCESS; } MA_API ma_result ma_data_converter_init(const ma_data_converter_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_data_converter* pConverter) { ma_result result; size_t heapSizeInBytes; void* pHeap; result = ma_data_converter_get_heap_size(pConfig, &heapSizeInBytes); if (result != MA_SUCCESS) { return result; } if (heapSizeInBytes > 0) { pHeap = ma_malloc(heapSizeInBytes, pAllocationCallbacks); if (pHeap == NULL) { return MA_OUT_OF_MEMORY; } } else { pHeap = NULL; } result = ma_data_converter_init_preallocated(pConfig, pHeap, pConverter); if (result != MA_SUCCESS) { ma_free(pHeap, pAllocationCallbacks); return result; } pConverter->_ownsHeap = MA_TRUE; return MA_SUCCESS; } MA_API void ma_data_converter_uninit(ma_data_converter* pConverter, const ma_allocation_callbacks* pAllocationCallbacks) { if (pConverter == NULL) { return; } if (pConverter->hasResampler) { ma_resampler_uninit(&pConverter->resampler, pAllocationCallbacks); } ma_channel_converter_uninit(&pConverter->channelConverter, pAllocationCallbacks); if (pConverter->_ownsHeap) { ma_free(pConverter->_pHeap, pAllocationCallbacks); } } static ma_result ma_data_converter_process_pcm_frames__passthrough(ma_data_converter* pConverter, const void* pFramesIn, ma_uint64* pFrameCountIn, void* pFramesOut, ma_uint64* pFrameCountOut) { ma_uint64 frameCountIn; ma_uint64 frameCountOut; ma_uint64 frameCount; MA_ASSERT(pConverter != NULL); frameCountIn = 0; if (pFrameCountIn != NULL) { frameCountIn = *pFrameCountIn; } frameCountOut = 0; if (pFrameCountOut != NULL) { frameCountOut = *pFrameCountOut; } frameCount = ma_min(frameCountIn, frameCountOut); if (pFramesOut != NULL) { if (pFramesIn != NULL) { ma_copy_memory_64(pFramesOut, pFramesIn, frameCount * ma_get_bytes_per_frame(pConverter->formatOut, pConverter->channelsOut)); } else { ma_zero_memory_64(pFramesOut, frameCount * ma_get_bytes_per_frame(pConverter->formatOut, pConverter->channelsOut)); } } if (pFrameCountIn != NULL) { *pFrameCountIn = frameCount; } if (pFrameCountOut != NULL) { *pFrameCountOut = frameCount; } return MA_SUCCESS; } static ma_result ma_data_converter_process_pcm_frames__format_only(ma_data_converter* pConverter, const void* pFramesIn, ma_uint64* pFrameCountIn, void* pFramesOut, ma_uint64* pFrameCountOut) { ma_uint64 frameCountIn; ma_uint64 frameCountOut; ma_uint64 frameCount; MA_ASSERT(pConverter != NULL); frameCountIn = 0; if (pFrameCountIn != NULL) { frameCountIn = *pFrameCountIn; } frameCountOut = 0; if (pFrameCountOut != NULL) { frameCountOut = *pFrameCountOut; } frameCount = ma_min(frameCountIn, frameCountOut); if (pFramesOut != NULL) { if (pFramesIn != NULL) { ma_convert_pcm_frames_format(pFramesOut, pConverter->formatOut, pFramesIn, pConverter->formatIn, frameCount, pConverter->channelsIn, pConverter->ditherMode); } else { ma_zero_memory_64(pFramesOut, frameCount * ma_get_bytes_per_frame(pConverter->formatOut, pConverter->channelsOut)); } } if (pFrameCountIn != NULL) { *pFrameCountIn = frameCount; } if (pFrameCountOut != NULL) { *pFrameCountOut = frameCount; } return MA_SUCCESS; } static ma_result ma_data_converter_process_pcm_frames__resample_with_format_conversion(ma_data_converter* pConverter, const void* pFramesIn, ma_uint64* pFrameCountIn, void* pFramesOut, ma_uint64* pFrameCountOut) { ma_result result = MA_SUCCESS; ma_uint64 frameCountIn; ma_uint64 frameCountOut; ma_uint64 framesProcessedIn; ma_uint64 framesProcessedOut; MA_ASSERT(pConverter != NULL); frameCountIn = 0; if (pFrameCountIn != NULL) { frameCountIn = *pFrameCountIn; } frameCountOut = 0; if (pFrameCountOut != NULL) { frameCountOut = *pFrameCountOut; } framesProcessedIn = 0; framesProcessedOut = 0; while (framesProcessedOut < frameCountOut) { ma_uint8 pTempBufferOut[MA_DATA_CONVERTER_STACK_BUFFER_SIZE]; const ma_uint32 tempBufferOutCap = sizeof(pTempBufferOut) / ma_get_bytes_per_frame(pConverter->resampler.format, pConverter->resampler.channels); const void* pFramesInThisIteration; /* */ void* pFramesOutThisIteration; ma_uint64 frameCountInThisIteration; ma_uint64 frameCountOutThisIteration; if (pFramesIn != NULL) { pFramesInThisIteration = ma_offset_ptr(pFramesIn, framesProcessedIn * ma_get_bytes_per_frame(pConverter->formatIn, pConverter->channelsIn)); } else { pFramesInThisIteration = NULL; } if (pFramesOut != NULL) { pFramesOutThisIteration = ma_offset_ptr(pFramesOut, framesProcessedOut * ma_get_bytes_per_frame(pConverter->formatOut, pConverter->channelsOut)); } else { pFramesOutThisIteration = NULL; } /* Do a pre format conversion if necessary. */ if (pConverter->hasPreFormatConversion) { ma_uint8 pTempBufferIn[MA_DATA_CONVERTER_STACK_BUFFER_SIZE]; const ma_uint32 tempBufferInCap = sizeof(pTempBufferIn) / ma_get_bytes_per_frame(pConverter->resampler.format, pConverter->resampler.channels); frameCountInThisIteration = (frameCountIn - framesProcessedIn); if (frameCountInThisIteration > tempBufferInCap) { frameCountInThisIteration = tempBufferInCap; } if (pConverter->hasPostFormatConversion) { if (frameCountInThisIteration > tempBufferOutCap) { frameCountInThisIteration = tempBufferOutCap; } } if (pFramesInThisIteration != NULL) { ma_convert_pcm_frames_format(pTempBufferIn, pConverter->resampler.format, pFramesInThisIteration, pConverter->formatIn, frameCountInThisIteration, pConverter->channelsIn, pConverter->ditherMode); } else { MA_ZERO_MEMORY(pTempBufferIn, sizeof(pTempBufferIn)); } frameCountOutThisIteration = (frameCountOut - framesProcessedOut); if (pConverter->hasPostFormatConversion) { /* Both input and output conversion required. Output to the temp buffer. */ if (frameCountOutThisIteration > tempBufferOutCap) { frameCountOutThisIteration = tempBufferOutCap; } result = ma_resampler_process_pcm_frames(&pConverter->resampler, pTempBufferIn, &frameCountInThisIteration, pTempBufferOut, &frameCountOutThisIteration); } else { /* Only pre-format required. Output straight to the output buffer. */ result = ma_resampler_process_pcm_frames(&pConverter->resampler, pTempBufferIn, &frameCountInThisIteration, pFramesOutThisIteration, &frameCountOutThisIteration); } if (result != MA_SUCCESS) { break; } } else { /* No pre-format required. Just read straight from the input buffer. */ MA_ASSERT(pConverter->hasPostFormatConversion == MA_TRUE); frameCountInThisIteration = (frameCountIn - framesProcessedIn); frameCountOutThisIteration = (frameCountOut - framesProcessedOut); if (frameCountOutThisIteration > tempBufferOutCap) { frameCountOutThisIteration = tempBufferOutCap; } result = ma_resampler_process_pcm_frames(&pConverter->resampler, pFramesInThisIteration, &frameCountInThisIteration, pTempBufferOut, &frameCountOutThisIteration); if (result != MA_SUCCESS) { break; } } /* If we are doing a post format conversion we need to do that now. */ if (pConverter->hasPostFormatConversion) { if (pFramesOutThisIteration != NULL) { ma_convert_pcm_frames_format(pFramesOutThisIteration, pConverter->formatOut, pTempBufferOut, pConverter->resampler.format, frameCountOutThisIteration, pConverter->resampler.channels, pConverter->ditherMode); } } framesProcessedIn += frameCountInThisIteration; framesProcessedOut += frameCountOutThisIteration; MA_ASSERT(framesProcessedIn <= frameCountIn); MA_ASSERT(framesProcessedOut <= frameCountOut); if (frameCountOutThisIteration == 0) { break; /* Consumed all of our input data. */ } } if (pFrameCountIn != NULL) { *pFrameCountIn = framesProcessedIn; } if (pFrameCountOut != NULL) { *pFrameCountOut = framesProcessedOut; } return result; } static ma_result ma_data_converter_process_pcm_frames__resample_only(ma_data_converter* pConverter, const void* pFramesIn, ma_uint64* pFrameCountIn, void* pFramesOut, ma_uint64* pFrameCountOut) { MA_ASSERT(pConverter != NULL); if (pConverter->hasPreFormatConversion == MA_FALSE && pConverter->hasPostFormatConversion == MA_FALSE) { /* Neither pre- nor post-format required. This is simple case where only resampling is required. */ return ma_resampler_process_pcm_frames(&pConverter->resampler, pFramesIn, pFrameCountIn, pFramesOut, pFrameCountOut); } else { /* Format conversion required. */ return ma_data_converter_process_pcm_frames__resample_with_format_conversion(pConverter, pFramesIn, pFrameCountIn, pFramesOut, pFrameCountOut); } } static ma_result ma_data_converter_process_pcm_frames__channels_only(ma_data_converter* pConverter, const void* pFramesIn, ma_uint64* pFrameCountIn, void* pFramesOut, ma_uint64* pFrameCountOut) { ma_result result; ma_uint64 frameCountIn; ma_uint64 frameCountOut; ma_uint64 frameCount; MA_ASSERT(pConverter != NULL); frameCountIn = 0; if (pFrameCountIn != NULL) { frameCountIn = *pFrameCountIn; } frameCountOut = 0; if (pFrameCountOut != NULL) { frameCountOut = *pFrameCountOut; } frameCount = ma_min(frameCountIn, frameCountOut); if (pConverter->hasPreFormatConversion == MA_FALSE && pConverter->hasPostFormatConversion == MA_FALSE) { /* No format conversion required. */ result = ma_channel_converter_process_pcm_frames(&pConverter->channelConverter, pFramesOut, pFramesIn, frameCount); if (result != MA_SUCCESS) { return result; } } else { /* Format conversion required. */ ma_uint64 framesProcessed = 0; while (framesProcessed < frameCount) { ma_uint8 pTempBufferOut[MA_DATA_CONVERTER_STACK_BUFFER_SIZE]; const ma_uint32 tempBufferOutCap = sizeof(pTempBufferOut) / ma_get_bytes_per_frame(pConverter->channelConverter.format, pConverter->channelConverter.channelsOut); const void* pFramesInThisIteration; /* */ void* pFramesOutThisIteration; ma_uint64 frameCountThisIteration; if (pFramesIn != NULL) { pFramesInThisIteration = ma_offset_ptr(pFramesIn, framesProcessed * ma_get_bytes_per_frame(pConverter->formatIn, pConverter->channelsIn)); } else { pFramesInThisIteration = NULL; } if (pFramesOut != NULL) { pFramesOutThisIteration = ma_offset_ptr(pFramesOut, framesProcessed * ma_get_bytes_per_frame(pConverter->formatOut, pConverter->channelsOut)); } else { pFramesOutThisIteration = NULL; } /* Do a pre format conversion if necessary. */ if (pConverter->hasPreFormatConversion) { ma_uint8 pTempBufferIn[MA_DATA_CONVERTER_STACK_BUFFER_SIZE]; const ma_uint32 tempBufferInCap = sizeof(pTempBufferIn) / ma_get_bytes_per_frame(pConverter->channelConverter.format, pConverter->channelConverter.channelsIn); frameCountThisIteration = (frameCount - framesProcessed); if (frameCountThisIteration > tempBufferInCap) { frameCountThisIteration = tempBufferInCap; } if (pConverter->hasPostFormatConversion) { if (frameCountThisIteration > tempBufferOutCap) { frameCountThisIteration = tempBufferOutCap; } } if (pFramesInThisIteration != NULL) { ma_convert_pcm_frames_format(pTempBufferIn, pConverter->channelConverter.format, pFramesInThisIteration, pConverter->formatIn, frameCountThisIteration, pConverter->channelsIn, pConverter->ditherMode); } else { MA_ZERO_MEMORY(pTempBufferIn, sizeof(pTempBufferIn)); } if (pConverter->hasPostFormatConversion) { /* Both input and output conversion required. Output to the temp buffer. */ result = ma_channel_converter_process_pcm_frames(&pConverter->channelConverter, pTempBufferOut, pTempBufferIn, frameCountThisIteration); } else { /* Only pre-format required. Output straight to the output buffer. */ result = ma_channel_converter_process_pcm_frames(&pConverter->channelConverter, pFramesOutThisIteration, pTempBufferIn, frameCountThisIteration); } if (result != MA_SUCCESS) { break; } } else { /* No pre-format required. Just read straight from the input buffer. */ MA_ASSERT(pConverter->hasPostFormatConversion == MA_TRUE); frameCountThisIteration = (frameCount - framesProcessed); if (frameCountThisIteration > tempBufferOutCap) { frameCountThisIteration = tempBufferOutCap; } result = ma_channel_converter_process_pcm_frames(&pConverter->channelConverter, pTempBufferOut, pFramesInThisIteration, frameCountThisIteration); if (result != MA_SUCCESS) { break; } } /* If we are doing a post format conversion we need to do that now. */ if (pConverter->hasPostFormatConversion) { if (pFramesOutThisIteration != NULL) { ma_convert_pcm_frames_format(pFramesOutThisIteration, pConverter->formatOut, pTempBufferOut, pConverter->channelConverter.format, frameCountThisIteration, pConverter->channelConverter.channelsOut, pConverter->ditherMode); } } framesProcessed += frameCountThisIteration; } } if (pFrameCountIn != NULL) { *pFrameCountIn = frameCount; } if (pFrameCountOut != NULL) { *pFrameCountOut = frameCount; } return MA_SUCCESS; } static ma_result ma_data_converter_process_pcm_frames__resample_first(ma_data_converter* pConverter, const void* pFramesIn, ma_uint64* pFrameCountIn, void* pFramesOut, ma_uint64* pFrameCountOut) { ma_result result; ma_uint64 frameCountIn; ma_uint64 frameCountOut; ma_uint64 framesProcessedIn; ma_uint64 framesProcessedOut; ma_uint8 pTempBufferIn[MA_DATA_CONVERTER_STACK_BUFFER_SIZE]; /* In resampler format. */ ma_uint64 tempBufferInCap; ma_uint8 pTempBufferMid[MA_DATA_CONVERTER_STACK_BUFFER_SIZE]; /* In resampler format, channel converter input format. */ ma_uint64 tempBufferMidCap; ma_uint8 pTempBufferOut[MA_DATA_CONVERTER_STACK_BUFFER_SIZE]; /* In channel converter output format. */ ma_uint64 tempBufferOutCap; MA_ASSERT(pConverter != NULL); MA_ASSERT(pConverter->resampler.format == pConverter->channelConverter.format); MA_ASSERT(pConverter->resampler.channels == pConverter->channelConverter.channelsIn); MA_ASSERT(pConverter->resampler.channels < pConverter->channelConverter.channelsOut); frameCountIn = 0; if (pFrameCountIn != NULL) { frameCountIn = *pFrameCountIn; } frameCountOut = 0; if (pFrameCountOut != NULL) { frameCountOut = *pFrameCountOut; } framesProcessedIn = 0; framesProcessedOut = 0; tempBufferInCap = sizeof(pTempBufferIn) / ma_get_bytes_per_frame(pConverter->resampler.format, pConverter->resampler.channels); tempBufferMidCap = sizeof(pTempBufferIn) / ma_get_bytes_per_frame(pConverter->resampler.format, pConverter->resampler.channels); tempBufferOutCap = sizeof(pTempBufferOut) / ma_get_bytes_per_frame(pConverter->channelConverter.format, pConverter->channelConverter.channelsOut); while (framesProcessedOut < frameCountOut) { ma_uint64 frameCountInThisIteration; ma_uint64 frameCountOutThisIteration; const void* pRunningFramesIn = NULL; void* pRunningFramesOut = NULL; const void* pResampleBufferIn; void* pChannelsBufferOut; if (pFramesIn != NULL) { pRunningFramesIn = ma_offset_ptr(pFramesIn, framesProcessedIn * ma_get_bytes_per_frame(pConverter->formatIn, pConverter->channelsIn)); } if (pFramesOut != NULL) { pRunningFramesOut = ma_offset_ptr(pFramesOut, framesProcessedOut * ma_get_bytes_per_frame(pConverter->formatOut, pConverter->channelsOut)); } /* Run input data through the resampler and output it to the temporary buffer. */ frameCountInThisIteration = (frameCountIn - framesProcessedIn); if (pConverter->hasPreFormatConversion) { if (frameCountInThisIteration > tempBufferInCap) { frameCountInThisIteration = tempBufferInCap; } } frameCountOutThisIteration = (frameCountOut - framesProcessedOut); if (frameCountOutThisIteration > tempBufferMidCap) { frameCountOutThisIteration = tempBufferMidCap; } /* We can't read more frames than can fit in the output buffer. */ if (pConverter->hasPostFormatConversion) { if (frameCountOutThisIteration > tempBufferOutCap) { frameCountOutThisIteration = tempBufferOutCap; } } /* We need to ensure we don't try to process too many input frames that we run out of room in the output buffer. If this happens we'll end up glitching. */ /* We need to try to predict how many input frames will be required for the resampler. If the resampler can tell us, we'll use that. Otherwise we'll need to make a best guess. The further off we are from this, the more wasted format conversions we'll end up doing. */ #if 1 { ma_uint64 requiredInputFrameCount; result = ma_resampler_get_required_input_frame_count(&pConverter->resampler, frameCountOutThisIteration, &requiredInputFrameCount); if (result != MA_SUCCESS) { /* Fall back to a best guess. */ requiredInputFrameCount = (frameCountOutThisIteration * pConverter->resampler.sampleRateIn) / pConverter->resampler.sampleRateOut; } if (frameCountInThisIteration > requiredInputFrameCount) { frameCountInThisIteration = requiredInputFrameCount; } } #endif if (pConverter->hasPreFormatConversion) { if (pFramesIn != NULL) { ma_convert_pcm_frames_format(pTempBufferIn, pConverter->resampler.format, pRunningFramesIn, pConverter->formatIn, frameCountInThisIteration, pConverter->channelsIn, pConverter->ditherMode); pResampleBufferIn = pTempBufferIn; } else { pResampleBufferIn = NULL; } } else { pResampleBufferIn = pRunningFramesIn; } result = ma_resampler_process_pcm_frames(&pConverter->resampler, pResampleBufferIn, &frameCountInThisIteration, pTempBufferMid, &frameCountOutThisIteration); if (result != MA_SUCCESS) { return result; } /* The input data has been resampled so now we need to run it through the channel converter. The input data is always contained in pTempBufferMid. We only need to do this part if we have an output buffer. */ if (pFramesOut != NULL) { if (pConverter->hasPostFormatConversion) { pChannelsBufferOut = pTempBufferOut; } else { pChannelsBufferOut = pRunningFramesOut; } result = ma_channel_converter_process_pcm_frames(&pConverter->channelConverter, pChannelsBufferOut, pTempBufferMid, frameCountOutThisIteration); if (result != MA_SUCCESS) { return result; } /* Finally we do post format conversion. */ if (pConverter->hasPostFormatConversion) { ma_convert_pcm_frames_format(pRunningFramesOut, pConverter->formatOut, pChannelsBufferOut, pConverter->channelConverter.format, frameCountOutThisIteration, pConverter->channelConverter.channelsOut, pConverter->ditherMode); } } framesProcessedIn += frameCountInThisIteration; framesProcessedOut += frameCountOutThisIteration; MA_ASSERT(framesProcessedIn <= frameCountIn); MA_ASSERT(framesProcessedOut <= frameCountOut); if (frameCountOutThisIteration == 0) { break; /* Consumed all of our input data. */ } } if (pFrameCountIn != NULL) { *pFrameCountIn = framesProcessedIn; } if (pFrameCountOut != NULL) { *pFrameCountOut = framesProcessedOut; } return MA_SUCCESS; } static ma_result ma_data_converter_process_pcm_frames__channels_first(ma_data_converter* pConverter, const void* pFramesIn, ma_uint64* pFrameCountIn, void* pFramesOut, ma_uint64* pFrameCountOut) { ma_result result; ma_uint64 frameCountIn; ma_uint64 frameCountOut; ma_uint64 framesProcessedIn; ma_uint64 framesProcessedOut; ma_uint8 pTempBufferIn[MA_DATA_CONVERTER_STACK_BUFFER_SIZE]; /* In resampler format. */ ma_uint64 tempBufferInCap; ma_uint8 pTempBufferMid[MA_DATA_CONVERTER_STACK_BUFFER_SIZE]; /* In resampler format, channel converter input format. */ ma_uint64 tempBufferMidCap; ma_uint8 pTempBufferOut[MA_DATA_CONVERTER_STACK_BUFFER_SIZE]; /* In channel converter output format. */ ma_uint64 tempBufferOutCap; MA_ASSERT(pConverter != NULL); MA_ASSERT(pConverter->resampler.format == pConverter->channelConverter.format); MA_ASSERT(pConverter->resampler.channels == pConverter->channelConverter.channelsOut); MA_ASSERT(pConverter->resampler.channels <= pConverter->channelConverter.channelsIn); frameCountIn = 0; if (pFrameCountIn != NULL) { frameCountIn = *pFrameCountIn; } frameCountOut = 0; if (pFrameCountOut != NULL) { frameCountOut = *pFrameCountOut; } framesProcessedIn = 0; framesProcessedOut = 0; tempBufferInCap = sizeof(pTempBufferIn) / ma_get_bytes_per_frame(pConverter->channelConverter.format, pConverter->channelConverter.channelsIn); tempBufferMidCap = sizeof(pTempBufferIn) / ma_get_bytes_per_frame(pConverter->channelConverter.format, pConverter->channelConverter.channelsOut); tempBufferOutCap = sizeof(pTempBufferOut) / ma_get_bytes_per_frame(pConverter->resampler.format, pConverter->resampler.channels); while (framesProcessedOut < frameCountOut) { ma_uint64 frameCountInThisIteration; ma_uint64 frameCountOutThisIteration; const void* pRunningFramesIn = NULL; void* pRunningFramesOut = NULL; const void* pChannelsBufferIn; void* pResampleBufferOut; if (pFramesIn != NULL) { pRunningFramesIn = ma_offset_ptr(pFramesIn, framesProcessedIn * ma_get_bytes_per_frame(pConverter->formatIn, pConverter->channelsIn)); } if (pFramesOut != NULL) { pRunningFramesOut = ma_offset_ptr(pFramesOut, framesProcessedOut * ma_get_bytes_per_frame(pConverter->formatOut, pConverter->channelsOut)); } /* Before doing any processing we need to determine how many frames we should try processing this iteration, for both input and output. The resampler requires us to perform format and channel conversion before passing any data into it. If we get our input count wrong, we'll end up peforming redundant pre-processing. This isn't the end of the world, but it does result in some inefficiencies proportionate to how far our estimates are off. If the resampler has a means to calculate exactly how much we'll need, we'll use that. Otherwise we'll make a best guess. In order to do this, we'll need to calculate the output frame count first. */ frameCountOutThisIteration = (frameCountOut - framesProcessedOut); if (frameCountOutThisIteration > tempBufferMidCap) { frameCountOutThisIteration = tempBufferMidCap; } if (pConverter->hasPostFormatConversion) { if (frameCountOutThisIteration > tempBufferOutCap) { frameCountOutThisIteration = tempBufferOutCap; } } /* Now that we have the output frame count we can determine the input frame count. */ frameCountInThisIteration = (frameCountIn - framesProcessedIn); if (pConverter->hasPreFormatConversion) { if (frameCountInThisIteration > tempBufferInCap) { frameCountInThisIteration = tempBufferInCap; } } if (frameCountInThisIteration > tempBufferMidCap) { frameCountInThisIteration = tempBufferMidCap; } #if 1 { ma_uint64 requiredInputFrameCount; result = ma_resampler_get_required_input_frame_count(&pConverter->resampler, frameCountOutThisIteration, &requiredInputFrameCount); if (result != MA_SUCCESS) { /* Fall back to a best guess. */ requiredInputFrameCount = (frameCountOutThisIteration * pConverter->resampler.sampleRateIn) / pConverter->resampler.sampleRateOut; } if (frameCountInThisIteration > requiredInputFrameCount) { frameCountInThisIteration = requiredInputFrameCount; } } #endif /* Pre format conversion. */ if (pConverter->hasPreFormatConversion) { if (pRunningFramesIn != NULL) { ma_convert_pcm_frames_format(pTempBufferIn, pConverter->channelConverter.format, pRunningFramesIn, pConverter->formatIn, frameCountInThisIteration, pConverter->channelsIn, pConverter->ditherMode); pChannelsBufferIn = pTempBufferIn; } else { pChannelsBufferIn = NULL; } } else { pChannelsBufferIn = pRunningFramesIn; } /* Channel conversion. */ result = ma_channel_converter_process_pcm_frames(&pConverter->channelConverter, pTempBufferMid, pChannelsBufferIn, frameCountInThisIteration); if (result != MA_SUCCESS) { return result; } /* Resampling. */ if (pConverter->hasPostFormatConversion) { pResampleBufferOut = pTempBufferOut; } else { pResampleBufferOut = pRunningFramesOut; } result = ma_resampler_process_pcm_frames(&pConverter->resampler, pTempBufferMid, &frameCountInThisIteration, pResampleBufferOut, &frameCountOutThisIteration); if (result != MA_SUCCESS) { return result; } /* Post format conversion. */ if (pConverter->hasPostFormatConversion) { if (pRunningFramesOut != NULL) { ma_convert_pcm_frames_format(pRunningFramesOut, pConverter->formatOut, pResampleBufferOut, pConverter->resampler.format, frameCountOutThisIteration, pConverter->channelsOut, pConverter->ditherMode); } } framesProcessedIn += frameCountInThisIteration; framesProcessedOut += frameCountOutThisIteration; MA_ASSERT(framesProcessedIn <= frameCountIn); MA_ASSERT(framesProcessedOut <= frameCountOut); if (frameCountOutThisIteration == 0) { break; /* Consumed all of our input data. */ } } if (pFrameCountIn != NULL) { *pFrameCountIn = framesProcessedIn; } if (pFrameCountOut != NULL) { *pFrameCountOut = framesProcessedOut; } return MA_SUCCESS; } MA_API ma_result ma_data_converter_process_pcm_frames(ma_data_converter* pConverter, const void* pFramesIn, ma_uint64* pFrameCountIn, void* pFramesOut, ma_uint64* pFrameCountOut) { if (pConverter == NULL) { return MA_INVALID_ARGS; } switch (pConverter->executionPath) { case ma_data_converter_execution_path_passthrough: return ma_data_converter_process_pcm_frames__passthrough(pConverter, pFramesIn, pFrameCountIn, pFramesOut, pFrameCountOut); case ma_data_converter_execution_path_format_only: return ma_data_converter_process_pcm_frames__format_only(pConverter, pFramesIn, pFrameCountIn, pFramesOut, pFrameCountOut); case ma_data_converter_execution_path_channels_only: return ma_data_converter_process_pcm_frames__channels_only(pConverter, pFramesIn, pFrameCountIn, pFramesOut, pFrameCountOut); case ma_data_converter_execution_path_resample_only: return ma_data_converter_process_pcm_frames__resample_only(pConverter, pFramesIn, pFrameCountIn, pFramesOut, pFrameCountOut); case ma_data_converter_execution_path_resample_first: return ma_data_converter_process_pcm_frames__resample_first(pConverter, pFramesIn, pFrameCountIn, pFramesOut, pFrameCountOut); case ma_data_converter_execution_path_channels_first: return ma_data_converter_process_pcm_frames__channels_first(pConverter, pFramesIn, pFrameCountIn, pFramesOut, pFrameCountOut); default: return MA_INVALID_OPERATION; /* Should never hit this. */ } } MA_API ma_result ma_data_converter_set_rate(ma_data_converter* pConverter, ma_uint32 sampleRateIn, ma_uint32 sampleRateOut) { if (pConverter == NULL) { return MA_INVALID_ARGS; } if (pConverter->hasResampler == MA_FALSE) { return MA_INVALID_OPERATION; /* Dynamic resampling not enabled. */ } return ma_resampler_set_rate(&pConverter->resampler, sampleRateIn, sampleRateOut); } MA_API ma_result ma_data_converter_set_rate_ratio(ma_data_converter* pConverter, float ratioInOut) { if (pConverter == NULL) { return MA_INVALID_ARGS; } if (pConverter->hasResampler == MA_FALSE) { return MA_INVALID_OPERATION; /* Dynamic resampling not enabled. */ } return ma_resampler_set_rate_ratio(&pConverter->resampler, ratioInOut); } MA_API ma_uint64 ma_data_converter_get_input_latency(const ma_data_converter* pConverter) { if (pConverter == NULL) { return 0; } if (pConverter->hasResampler) { return ma_resampler_get_input_latency(&pConverter->resampler); } return 0; /* No latency without a resampler. */ } MA_API ma_uint64 ma_data_converter_get_output_latency(const ma_data_converter* pConverter) { if (pConverter == NULL) { return 0; } if (pConverter->hasResampler) { return ma_resampler_get_output_latency(&pConverter->resampler); } return 0; /* No latency without a resampler. */ } MA_API ma_result ma_data_converter_get_required_input_frame_count(const ma_data_converter* pConverter, ma_uint64 outputFrameCount, ma_uint64* pInputFrameCount) { if (pInputFrameCount == NULL) { return MA_INVALID_ARGS; } *pInputFrameCount = 0; if (pConverter == NULL) { return MA_INVALID_ARGS; } if (pConverter->hasResampler) { return ma_resampler_get_required_input_frame_count(&pConverter->resampler, outputFrameCount, pInputFrameCount); } else { *pInputFrameCount = outputFrameCount; /* 1:1 */ return MA_SUCCESS; } } MA_API ma_result ma_data_converter_get_expected_output_frame_count(const ma_data_converter* pConverter, ma_uint64 inputFrameCount, ma_uint64* pOutputFrameCount) { if (pOutputFrameCount == NULL) { return MA_INVALID_ARGS; } *pOutputFrameCount = 0; if (pConverter == NULL) { return MA_INVALID_ARGS; } if (pConverter->hasResampler) { return ma_resampler_get_expected_output_frame_count(&pConverter->resampler, inputFrameCount, pOutputFrameCount); } else { *pOutputFrameCount = inputFrameCount; /* 1:1 */ return MA_SUCCESS; } } MA_API ma_result ma_data_converter_get_input_channel_map(const ma_data_converter* pConverter, ma_channel* pChannelMap, size_t channelMapCap) { if (pConverter == NULL || pChannelMap == NULL) { return MA_INVALID_ARGS; } if (pConverter->hasChannelConverter) { ma_channel_converter_get_output_channel_map(&pConverter->channelConverter, pChannelMap, channelMapCap); } else { ma_channel_map_init_standard(ma_standard_channel_map_default, pChannelMap, channelMapCap, pConverter->channelsOut); } return MA_SUCCESS; } MA_API ma_result ma_data_converter_get_output_channel_map(const ma_data_converter* pConverter, ma_channel* pChannelMap, size_t channelMapCap) { if (pConverter == NULL || pChannelMap == NULL) { return MA_INVALID_ARGS; } if (pConverter->hasChannelConverter) { ma_channel_converter_get_input_channel_map(&pConverter->channelConverter, pChannelMap, channelMapCap); } else { ma_channel_map_init_standard(ma_standard_channel_map_default, pChannelMap, channelMapCap, pConverter->channelsIn); } return MA_SUCCESS; } MA_API ma_result ma_data_converter_reset(ma_data_converter* pConverter) { if (pConverter == NULL) { return MA_INVALID_ARGS; } /* There's nothing to do if we're not resampling. */ if (pConverter->hasResampler == MA_FALSE) { return MA_SUCCESS; } return ma_resampler_reset(&pConverter->resampler); } /************************************************************************************************************************************************************** Channel Maps **************************************************************************************************************************************************************/ static ma_channel ma_channel_map_init_standard_channel(ma_standard_channel_map standardChannelMap, ma_uint32 channelCount, ma_uint32 channelIndex); MA_API ma_channel ma_channel_map_get_channel(const ma_channel* pChannelMap, ma_uint32 channelCount, ma_uint32 channelIndex) { if (pChannelMap == NULL) { return ma_channel_map_init_standard_channel(ma_standard_channel_map_default, channelCount, channelIndex); } else { if (channelIndex >= channelCount) { return MA_CHANNEL_NONE; } return pChannelMap[channelIndex]; } } MA_API void ma_channel_map_init_blank(ma_channel* pChannelMap, ma_uint32 channels) { if (pChannelMap == NULL) { return; } MA_ZERO_MEMORY(pChannelMap, sizeof(*pChannelMap) * channels); } static ma_channel ma_channel_map_init_standard_channel_microsoft(ma_uint32 channelCount, ma_uint32 channelIndex) { if (channelCount == 0 || channelIndex >= channelCount) { return MA_CHANNEL_NONE; } /* This is the Microsoft channel map. Based off the speaker configurations mentioned here: https://docs.microsoft.com/en-us/windows-hardware/drivers/ddi/content/ksmedia/ns-ksmedia-ksaudio_channel_config */ switch (channelCount) { case 0: return MA_CHANNEL_NONE; case 1: { return MA_CHANNEL_MONO; } break; case 2: { switch (channelIndex) { case 0: return MA_CHANNEL_FRONT_LEFT; case 1: return MA_CHANNEL_FRONT_RIGHT; } } break; case 3: /* No defined, but best guess. */ { switch (channelIndex) { case 0: return MA_CHANNEL_FRONT_LEFT; case 1: return MA_CHANNEL_FRONT_RIGHT; case 2: return MA_CHANNEL_FRONT_CENTER; } } break; case 4: { switch (channelIndex) { #ifndef MA_USE_QUAD_MICROSOFT_CHANNEL_MAP /* Surround. Using the Surround profile has the advantage of the 3rd channel (MA_CHANNEL_FRONT_CENTER) mapping nicely with higher channel counts. */ case 0: return MA_CHANNEL_FRONT_LEFT; case 1: return MA_CHANNEL_FRONT_RIGHT; case 2: return MA_CHANNEL_FRONT_CENTER; case 3: return MA_CHANNEL_BACK_CENTER; #else /* Quad. */ case 0: return MA_CHANNEL_FRONT_LEFT; case 1: return MA_CHANNEL_FRONT_RIGHT; case 2: return MA_CHANNEL_BACK_LEFT; case 3: return MA_CHANNEL_BACK_RIGHT; #endif } } break; case 5: /* Not defined, but best guess. */ { switch (channelIndex) { case 0: return MA_CHANNEL_FRONT_LEFT; case 1: return MA_CHANNEL_FRONT_RIGHT; case 2: return MA_CHANNEL_FRONT_CENTER; case 3: return MA_CHANNEL_BACK_LEFT; case 4: return MA_CHANNEL_BACK_RIGHT; } } break; case 6: { switch (channelIndex) { case 0: return MA_CHANNEL_FRONT_LEFT; case 1: return MA_CHANNEL_FRONT_RIGHT; case 2: return MA_CHANNEL_FRONT_CENTER; case 3: return MA_CHANNEL_LFE; case 4: return MA_CHANNEL_SIDE_LEFT; case 5: return MA_CHANNEL_SIDE_RIGHT; } } break; case 7: /* Not defined, but best guess. */ { switch (channelIndex) { case 0: return MA_CHANNEL_FRONT_LEFT; case 1: return MA_CHANNEL_FRONT_RIGHT; case 2: return MA_CHANNEL_FRONT_CENTER; case 3: return MA_CHANNEL_LFE; case 4: return MA_CHANNEL_BACK_CENTER; case 5: return MA_CHANNEL_SIDE_LEFT; case 6: return MA_CHANNEL_SIDE_RIGHT; } } break; case 8: default: { switch (channelIndex) { case 0: return MA_CHANNEL_FRONT_LEFT; case 1: return MA_CHANNEL_FRONT_RIGHT; case 2: return MA_CHANNEL_FRONT_CENTER; case 3: return MA_CHANNEL_LFE; case 4: return MA_CHANNEL_BACK_LEFT; case 5: return MA_CHANNEL_BACK_RIGHT; case 6: return MA_CHANNEL_SIDE_LEFT; case 7: return MA_CHANNEL_SIDE_RIGHT; } } break; } if (channelCount > 8) { if (channelIndex < 32) { /* We have 32 AUX channels. */ return (ma_channel)(MA_CHANNEL_AUX_0 + (channelIndex - 8)); } } /* Getting here means we don't know how to map the channel position so just return MA_CHANNEL_NONE. */ return MA_CHANNEL_NONE; } static ma_channel ma_channel_map_init_standard_channel_alsa(ma_uint32 channelCount, ma_uint32 channelIndex) { switch (channelCount) { case 0: return MA_CHANNEL_NONE; case 1: { return MA_CHANNEL_MONO; } break; case 2: { switch (channelIndex) { case 0: return MA_CHANNEL_FRONT_LEFT; case 1: return MA_CHANNEL_FRONT_RIGHT; } } break; case 3: { switch (channelIndex) { case 0: return MA_CHANNEL_FRONT_LEFT; case 1: return MA_CHANNEL_FRONT_RIGHT; case 2: return MA_CHANNEL_FRONT_CENTER; } } break; case 4: { switch (channelIndex) { case 0: return MA_CHANNEL_FRONT_LEFT; case 1: return MA_CHANNEL_FRONT_RIGHT; case 2: return MA_CHANNEL_BACK_LEFT; case 3: return MA_CHANNEL_BACK_RIGHT; } } break; case 5: { switch (channelIndex) { case 0: return MA_CHANNEL_FRONT_LEFT; case 1: return MA_CHANNEL_FRONT_RIGHT; case 2: return MA_CHANNEL_BACK_LEFT; case 3: return MA_CHANNEL_BACK_RIGHT; case 4: return MA_CHANNEL_FRONT_CENTER; } } break; case 6: { switch (channelIndex) { case 0: return MA_CHANNEL_FRONT_LEFT; case 1: return MA_CHANNEL_FRONT_RIGHT; case 2: return MA_CHANNEL_BACK_LEFT; case 3: return MA_CHANNEL_BACK_RIGHT; case 4: return MA_CHANNEL_FRONT_CENTER; case 5: return MA_CHANNEL_LFE; } } break; case 7: { switch (channelIndex) { case 0: return MA_CHANNEL_FRONT_LEFT; case 1: return MA_CHANNEL_FRONT_RIGHT; case 2: return MA_CHANNEL_BACK_LEFT; case 3: return MA_CHANNEL_BACK_RIGHT; case 4: return MA_CHANNEL_FRONT_CENTER; case 5: return MA_CHANNEL_LFE; case 6: return MA_CHANNEL_BACK_CENTER; } } break; case 8: default: { switch (channelIndex) { case 0: return MA_CHANNEL_FRONT_LEFT; case 1: return MA_CHANNEL_FRONT_RIGHT; case 2: return MA_CHANNEL_BACK_LEFT; case 3: return MA_CHANNEL_BACK_RIGHT; case 4: return MA_CHANNEL_FRONT_CENTER; case 5: return MA_CHANNEL_LFE; case 6: return MA_CHANNEL_SIDE_LEFT; case 7: return MA_CHANNEL_SIDE_RIGHT; } } break; } if (channelCount > 8) { if (channelIndex < 32) { /* We have 32 AUX channels. */ return (ma_channel)(MA_CHANNEL_AUX_0 + (channelIndex - 8)); } } /* Getting here means we don't know how to map the channel position so just return MA_CHANNEL_NONE. */ return MA_CHANNEL_NONE; } static ma_channel ma_channel_map_init_standard_channel_rfc3551(ma_uint32 channelCount, ma_uint32 channelIndex) { switch (channelCount) { case 0: return MA_CHANNEL_NONE; case 1: { return MA_CHANNEL_MONO; } break; case 2: { switch (channelIndex) { case 0: return MA_CHANNEL_FRONT_LEFT; case 1: return MA_CHANNEL_FRONT_RIGHT; } } break; case 3: { switch (channelIndex) { case 0: return MA_CHANNEL_FRONT_LEFT; case 1: return MA_CHANNEL_FRONT_RIGHT; case 2: return MA_CHANNEL_FRONT_CENTER; } } break; case 4: { switch (channelIndex) { case 0: return MA_CHANNEL_FRONT_LEFT; case 2: return MA_CHANNEL_FRONT_CENTER; case 1: return MA_CHANNEL_FRONT_RIGHT; case 3: return MA_CHANNEL_BACK_CENTER; } } break; case 5: { switch (channelIndex) { case 0: return MA_CHANNEL_FRONT_LEFT; case 1: return MA_CHANNEL_FRONT_RIGHT; case 2: return MA_CHANNEL_FRONT_CENTER; case 3: return MA_CHANNEL_BACK_LEFT; case 4: return MA_CHANNEL_BACK_RIGHT; } } break; case 6: default: { switch (channelIndex) { case 0: return MA_CHANNEL_FRONT_LEFT; case 1: return MA_CHANNEL_SIDE_LEFT; case 2: return MA_CHANNEL_FRONT_CENTER; case 3: return MA_CHANNEL_FRONT_RIGHT; case 4: return MA_CHANNEL_SIDE_RIGHT; case 5: return MA_CHANNEL_BACK_CENTER; } } break; } if (channelCount > 6) { if (channelIndex < 32) { /* We have 32 AUX channels. */ return (ma_channel)(MA_CHANNEL_AUX_0 + (channelIndex - 6)); } } /* Getting here means we don't know how to map the channel position so just return MA_CHANNEL_NONE. */ return MA_CHANNEL_NONE; } static ma_channel ma_channel_map_init_standard_channel_flac(ma_uint32 channelCount, ma_uint32 channelIndex) { switch (channelCount) { case 0: return MA_CHANNEL_NONE; case 1: { return MA_CHANNEL_MONO; } break; case 2: { switch (channelIndex) { case 0: return MA_CHANNEL_FRONT_LEFT; case 1: return MA_CHANNEL_FRONT_RIGHT; } } break; case 3: { switch (channelIndex) { case 0: return MA_CHANNEL_FRONT_LEFT; case 1: return MA_CHANNEL_FRONT_RIGHT; case 2: return MA_CHANNEL_FRONT_CENTER; } } break; case 4: { switch (channelIndex) { case 0: return MA_CHANNEL_FRONT_LEFT; case 1: return MA_CHANNEL_FRONT_RIGHT; case 2: return MA_CHANNEL_BACK_LEFT; case 3: return MA_CHANNEL_BACK_RIGHT; } } break; case 5: { switch (channelIndex) { case 0: return MA_CHANNEL_FRONT_LEFT; case 1: return MA_CHANNEL_FRONT_RIGHT; case 2: return MA_CHANNEL_FRONT_CENTER; case 3: return MA_CHANNEL_BACK_LEFT; case 4: return MA_CHANNEL_BACK_RIGHT; } } break; case 6: { switch (channelIndex) { case 0: return MA_CHANNEL_FRONT_LEFT; case 1: return MA_CHANNEL_FRONT_RIGHT; case 2: return MA_CHANNEL_FRONT_CENTER; case 3: return MA_CHANNEL_LFE; case 4: return MA_CHANNEL_BACK_LEFT; case 5: return MA_CHANNEL_BACK_RIGHT; } } break; case 7: { switch (channelIndex) { case 0: return MA_CHANNEL_FRONT_LEFT; case 1: return MA_CHANNEL_FRONT_RIGHT; case 2: return MA_CHANNEL_FRONT_CENTER; case 3: return MA_CHANNEL_LFE; case 4: return MA_CHANNEL_BACK_CENTER; case 5: return MA_CHANNEL_SIDE_LEFT; case 6: return MA_CHANNEL_SIDE_RIGHT; } } break; case 8: default: { switch (channelIndex) { case 0: return MA_CHANNEL_FRONT_LEFT; case 1: return MA_CHANNEL_FRONT_RIGHT; case 2: return MA_CHANNEL_FRONT_CENTER; case 3: return MA_CHANNEL_LFE; case 4: return MA_CHANNEL_BACK_LEFT; case 5: return MA_CHANNEL_BACK_RIGHT; case 6: return MA_CHANNEL_SIDE_LEFT; case 7: return MA_CHANNEL_SIDE_RIGHT; } } break; } if (channelCount > 8) { if (channelIndex < 32) { /* We have 32 AUX channels. */ return (ma_channel)(MA_CHANNEL_AUX_0 + (channelIndex - 8)); } } /* Getting here means we don't know how to map the channel position so just return MA_CHANNEL_NONE. */ return MA_CHANNEL_NONE; } static ma_channel ma_channel_map_init_standard_channel_vorbis(ma_uint32 channelCount, ma_uint32 channelIndex) { switch (channelCount) { case 0: return MA_CHANNEL_NONE; case 1: { return MA_CHANNEL_MONO; } break; case 2: { switch (channelIndex) { case 0: return MA_CHANNEL_FRONT_LEFT; case 1: return MA_CHANNEL_FRONT_RIGHT; } } break; case 3: { switch (channelIndex) { case 0: return MA_CHANNEL_FRONT_LEFT; case 1: return MA_CHANNEL_FRONT_CENTER; case 2: return MA_CHANNEL_FRONT_RIGHT; } } break; case 4: { switch (channelIndex) { case 0: return MA_CHANNEL_FRONT_LEFT; case 1: return MA_CHANNEL_FRONT_RIGHT; case 2: return MA_CHANNEL_BACK_LEFT; case 3: return MA_CHANNEL_BACK_RIGHT; } } break; case 5: { switch (channelIndex) { case 0: return MA_CHANNEL_FRONT_LEFT; case 1: return MA_CHANNEL_FRONT_CENTER; case 2: return MA_CHANNEL_FRONT_RIGHT; case 3: return MA_CHANNEL_BACK_LEFT; case 4: return MA_CHANNEL_BACK_RIGHT; } } break; case 6: { switch (channelIndex) { case 0: return MA_CHANNEL_FRONT_LEFT; case 1: return MA_CHANNEL_FRONT_CENTER; case 2: return MA_CHANNEL_FRONT_RIGHT; case 3: return MA_CHANNEL_BACK_LEFT; case 4: return MA_CHANNEL_BACK_RIGHT; case 5: return MA_CHANNEL_LFE; } } break; case 7: { switch (channelIndex) { case 0: return MA_CHANNEL_FRONT_LEFT; case 1: return MA_CHANNEL_FRONT_CENTER; case 2: return MA_CHANNEL_FRONT_RIGHT; case 3: return MA_CHANNEL_SIDE_LEFT; case 4: return MA_CHANNEL_SIDE_RIGHT; case 5: return MA_CHANNEL_BACK_CENTER; case 6: return MA_CHANNEL_LFE; } } break; case 8: default: { switch (channelIndex) { case 0: return MA_CHANNEL_FRONT_LEFT; case 1: return MA_CHANNEL_FRONT_CENTER; case 2: return MA_CHANNEL_FRONT_RIGHT; case 3: return MA_CHANNEL_SIDE_LEFT; case 4: return MA_CHANNEL_SIDE_RIGHT; case 5: return MA_CHANNEL_BACK_LEFT; case 6: return MA_CHANNEL_BACK_RIGHT; case 7: return MA_CHANNEL_LFE; } } break; } if (channelCount > 8) { if (channelIndex < 32) { /* We have 32 AUX channels. */ return (ma_channel)(MA_CHANNEL_AUX_0 + (channelIndex - 8)); } } /* Getting here means we don't know how to map the channel position so just return MA_CHANNEL_NONE. */ return MA_CHANNEL_NONE; } static ma_channel ma_channel_map_init_standard_channel_sound4(ma_uint32 channelCount, ma_uint32 channelIndex) { switch (channelCount) { case 0: return MA_CHANNEL_NONE; case 1: { return MA_CHANNEL_MONO; } break; case 2: { switch (channelIndex) { case 0: return MA_CHANNEL_FRONT_LEFT; case 1: return MA_CHANNEL_FRONT_RIGHT; } } break; case 3: { switch (channelIndex) { case 0: return MA_CHANNEL_FRONT_LEFT; case 1: return MA_CHANNEL_FRONT_RIGHT; case 2: return MA_CHANNEL_FRONT_CENTER; } } break; case 4: { switch (channelIndex) { case 0: return MA_CHANNEL_FRONT_LEFT; case 1: return MA_CHANNEL_FRONT_RIGHT; case 2: return MA_CHANNEL_BACK_LEFT; case 3: return MA_CHANNEL_BACK_RIGHT; } } break; case 5: { switch (channelIndex) { case 0: return MA_CHANNEL_FRONT_LEFT; case 1: return MA_CHANNEL_FRONT_RIGHT; case 2: return MA_CHANNEL_FRONT_CENTER; case 3: return MA_CHANNEL_BACK_LEFT; case 4: return MA_CHANNEL_BACK_RIGHT; } } break; case 6: { switch (channelIndex) { case 0: return MA_CHANNEL_FRONT_LEFT; case 1: return MA_CHANNEL_FRONT_CENTER; case 2: return MA_CHANNEL_FRONT_RIGHT; case 3: return MA_CHANNEL_BACK_LEFT; case 4: return MA_CHANNEL_BACK_RIGHT; case 5: return MA_CHANNEL_LFE; } } break; case 7: { switch (channelIndex) { case 0: return MA_CHANNEL_FRONT_LEFT; case 1: return MA_CHANNEL_FRONT_CENTER; case 2: return MA_CHANNEL_FRONT_RIGHT; case 3: return MA_CHANNEL_SIDE_LEFT; case 4: return MA_CHANNEL_SIDE_RIGHT; case 5: return MA_CHANNEL_BACK_CENTER; case 6: return MA_CHANNEL_LFE; } } break; case 8: default: { switch (channelIndex) { case 0: return MA_CHANNEL_FRONT_LEFT; case 1: return MA_CHANNEL_FRONT_CENTER; case 2: return MA_CHANNEL_FRONT_RIGHT; case 3: return MA_CHANNEL_SIDE_LEFT; case 4: return MA_CHANNEL_SIDE_RIGHT; case 5: return MA_CHANNEL_BACK_LEFT; case 6: return MA_CHANNEL_BACK_RIGHT; case 7: return MA_CHANNEL_LFE; } } break; } if (channelCount > 8) { if (channelIndex < 32) { /* We have 32 AUX channels. */ return (ma_channel)(MA_CHANNEL_AUX_0 + (channelIndex - 8)); } } /* Getting here means we don't know how to map the channel position so just return MA_CHANNEL_NONE. */ return MA_CHANNEL_NONE; } static ma_channel ma_channel_map_init_standard_channel_sndio(ma_uint32 channelCount, ma_uint32 channelIndex) { switch (channelCount) { case 0: return MA_CHANNEL_NONE; case 1: { return MA_CHANNEL_MONO; } break; case 2: { switch (channelIndex) { case 0: return MA_CHANNEL_FRONT_LEFT; case 1: return MA_CHANNEL_FRONT_RIGHT; } } break; case 3: /* No defined, but best guess. */ { switch (channelIndex) { case 0: return MA_CHANNEL_FRONT_LEFT; case 1: return MA_CHANNEL_FRONT_RIGHT; case 2: return MA_CHANNEL_FRONT_CENTER; } } break; case 4: { switch (channelIndex) { case 0: return MA_CHANNEL_FRONT_LEFT; case 1: return MA_CHANNEL_FRONT_RIGHT; case 2: return MA_CHANNEL_BACK_LEFT; case 3: return MA_CHANNEL_BACK_RIGHT; } } break; case 5: /* Not defined, but best guess. */ { switch (channelIndex) { case 0: return MA_CHANNEL_FRONT_LEFT; case 1: return MA_CHANNEL_FRONT_RIGHT; case 2: return MA_CHANNEL_BACK_LEFT; case 3: return MA_CHANNEL_BACK_RIGHT; case 4: return MA_CHANNEL_FRONT_CENTER; } } break; case 6: default: { switch (channelIndex) { case 0: return MA_CHANNEL_FRONT_LEFT; case 1: return MA_CHANNEL_FRONT_RIGHT; case 2: return MA_CHANNEL_BACK_LEFT; case 3: return MA_CHANNEL_BACK_RIGHT; case 4: return MA_CHANNEL_FRONT_CENTER; case 5: return MA_CHANNEL_LFE; } } break; } if (channelCount > 6) { if (channelIndex < 32) { /* We have 32 AUX channels. */ return (ma_channel)(MA_CHANNEL_AUX_0 + (channelIndex - 6)); } } /* Getting here means we don't know how to map the channel position so just return MA_CHANNEL_NONE. */ return MA_CHANNEL_NONE; } static ma_channel ma_channel_map_init_standard_channel(ma_standard_channel_map standardChannelMap, ma_uint32 channelCount, ma_uint32 channelIndex) { if (channelCount == 0 || channelIndex >= channelCount) { return MA_CHANNEL_NONE; } switch (standardChannelMap) { case ma_standard_channel_map_alsa: { return ma_channel_map_init_standard_channel_alsa(channelCount, channelIndex); } break; case ma_standard_channel_map_rfc3551: { return ma_channel_map_init_standard_channel_rfc3551(channelCount, channelIndex); } break; case ma_standard_channel_map_flac: { return ma_channel_map_init_standard_channel_flac(channelCount, channelIndex); } break; case ma_standard_channel_map_vorbis: { return ma_channel_map_init_standard_channel_vorbis(channelCount, channelIndex); } break; case ma_standard_channel_map_sound4: { return ma_channel_map_init_standard_channel_sound4(channelCount, channelIndex); } break; case ma_standard_channel_map_sndio: { return ma_channel_map_init_standard_channel_sndio(channelCount, channelIndex); } break; case ma_standard_channel_map_microsoft: /* Also default. */ /*case ma_standard_channel_map_default;*/ default: { return ma_channel_map_init_standard_channel_microsoft(channelCount, channelIndex); } break; } } MA_API void ma_channel_map_init_standard(ma_standard_channel_map standardChannelMap, ma_channel* pChannelMap, size_t channelMapCap, ma_uint32 channels) { ma_uint32 iChannel; if (pChannelMap == NULL || channelMapCap == 0 || channels == 0) { return; } for (iChannel = 0; iChannel < channels; iChannel += 1) { if (channelMapCap == 0) { break; /* Ran out of room. */ } pChannelMap[0] = ma_channel_map_init_standard_channel(standardChannelMap, channels, iChannel); pChannelMap += 1; channelMapCap -= 1; } } MA_API void ma_channel_map_copy(ma_channel* pOut, const ma_channel* pIn, ma_uint32 channels) { if (pOut != NULL && pIn != NULL && channels > 0) { MA_COPY_MEMORY(pOut, pIn, sizeof(*pOut) * channels); } } MA_API void ma_channel_map_copy_or_default(ma_channel* pOut, size_t channelMapCapOut, const ma_channel* pIn, ma_uint32 channels) { if (pOut == NULL || channels == 0) { return; } if (pIn != NULL) { ma_channel_map_copy(pOut, pIn, channels); } else { ma_channel_map_init_standard(ma_standard_channel_map_default, pOut, channelMapCapOut, channels); } } MA_API ma_bool32 ma_channel_map_is_valid(const ma_channel* pChannelMap, ma_uint32 channels) { /* A channel count of 0 is invalid. */ if (channels == 0) { return MA_FALSE; } /* It does not make sense to have a mono channel when there is more than 1 channel. */ if (channels > 1) { ma_uint32 iChannel; for (iChannel = 0; iChannel < channels; ++iChannel) { if (ma_channel_map_get_channel(pChannelMap, channels, iChannel) == MA_CHANNEL_MONO) { return MA_FALSE; } } } return MA_TRUE; } MA_API ma_bool32 ma_channel_map_is_equal(const ma_channel* pChannelMapA, const ma_channel* pChannelMapB, ma_uint32 channels) { ma_uint32 iChannel; if (pChannelMapA == pChannelMapB) { return MA_TRUE; } for (iChannel = 0; iChannel < channels; ++iChannel) { if (ma_channel_map_get_channel(pChannelMapA, channels, iChannel) != ma_channel_map_get_channel(pChannelMapB, channels, iChannel)) { return MA_FALSE; } } return MA_TRUE; } MA_API ma_bool32 ma_channel_map_is_blank(const ma_channel* pChannelMap, ma_uint32 channels) { ma_uint32 iChannel; /* A null channel map is equivalent to the default channel map. */ if (pChannelMap == NULL) { return MA_FALSE; } for (iChannel = 0; iChannel < channels; ++iChannel) { if (pChannelMap[iChannel] != MA_CHANNEL_NONE) { return MA_FALSE; } } return MA_TRUE; } MA_API ma_bool32 ma_channel_map_contains_channel_position(ma_uint32 channels, const ma_channel* pChannelMap, ma_channel channelPosition) { return ma_channel_map_find_channel_position(channels, pChannelMap, channelPosition, NULL); } MA_API ma_bool32 ma_channel_map_find_channel_position(ma_uint32 channels, const ma_channel* pChannelMap, ma_channel channelPosition, ma_uint32* pChannelIndex) { ma_uint32 iChannel; if (pChannelIndex != NULL) { *pChannelIndex = (ma_uint32)-1; } for (iChannel = 0; iChannel < channels; ++iChannel) { if (ma_channel_map_get_channel(pChannelMap, channels, iChannel) == channelPosition) { if (pChannelIndex != NULL) { *pChannelIndex = iChannel; } return MA_TRUE; } } /* Getting here means the channel position was not found. */ return MA_FALSE; } MA_API size_t ma_channel_map_to_string(const ma_channel* pChannelMap, ma_uint32 channels, char* pBufferOut, size_t bufferCap) { size_t len; ma_uint32 iChannel; len = 0; for (iChannel = 0; iChannel < channels; iChannel += 1) { const char* pChannelStr = ma_channel_position_to_string(ma_channel_map_get_channel(pChannelMap, channels, iChannel)); size_t channelStrLen = strlen(pChannelStr); /* Append the string if necessary. */ if (pBufferOut != NULL && bufferCap > len + channelStrLen) { MA_COPY_MEMORY(pBufferOut + len, pChannelStr, channelStrLen); } len += channelStrLen; /* Append a space if it's not the last item. */ if (iChannel+1 < channels) { if (pBufferOut != NULL && bufferCap > len + 1) { pBufferOut[len] = ' '; } len += 1; } } /* Null terminate. Don't increment the length here. */ if (pBufferOut != NULL && bufferCap > len + 1) { pBufferOut[len] = '\0'; } return len; } MA_API const char* ma_channel_position_to_string(ma_channel channel) { switch (channel) { case MA_CHANNEL_NONE : return "CHANNEL_NONE"; case MA_CHANNEL_MONO : return "CHANNEL_MONO"; case MA_CHANNEL_FRONT_LEFT : return "CHANNEL_FRONT_LEFT"; case MA_CHANNEL_FRONT_RIGHT : return "CHANNEL_FRONT_RIGHT"; case MA_CHANNEL_FRONT_CENTER : return "CHANNEL_FRONT_CENTER"; case MA_CHANNEL_LFE : return "CHANNEL_LFE"; case MA_CHANNEL_BACK_LEFT : return "CHANNEL_BACK_LEFT"; case MA_CHANNEL_BACK_RIGHT : return "CHANNEL_BACK_RIGHT"; case MA_CHANNEL_FRONT_LEFT_CENTER : return "CHANNEL_FRONT_LEFT_CENTER "; case MA_CHANNEL_FRONT_RIGHT_CENTER: return "CHANNEL_FRONT_RIGHT_CENTER"; case MA_CHANNEL_BACK_CENTER : return "CHANNEL_BACK_CENTER"; case MA_CHANNEL_SIDE_LEFT : return "CHANNEL_SIDE_LEFT"; case MA_CHANNEL_SIDE_RIGHT : return "CHANNEL_SIDE_RIGHT"; case MA_CHANNEL_TOP_CENTER : return "CHANNEL_TOP_CENTER"; case MA_CHANNEL_TOP_FRONT_LEFT : return "CHANNEL_TOP_FRONT_LEFT"; case MA_CHANNEL_TOP_FRONT_CENTER : return "CHANNEL_TOP_FRONT_CENTER"; case MA_CHANNEL_TOP_FRONT_RIGHT : return "CHANNEL_TOP_FRONT_RIGHT"; case MA_CHANNEL_TOP_BACK_LEFT : return "CHANNEL_TOP_BACK_LEFT"; case MA_CHANNEL_TOP_BACK_CENTER : return "CHANNEL_TOP_BACK_CENTER"; case MA_CHANNEL_TOP_BACK_RIGHT : return "CHANNEL_TOP_BACK_RIGHT"; case MA_CHANNEL_AUX_0 : return "CHANNEL_AUX_0"; case MA_CHANNEL_AUX_1 : return "CHANNEL_AUX_1"; case MA_CHANNEL_AUX_2 : return "CHANNEL_AUX_2"; case MA_CHANNEL_AUX_3 : return "CHANNEL_AUX_3"; case MA_CHANNEL_AUX_4 : return "CHANNEL_AUX_4"; case MA_CHANNEL_AUX_5 : return "CHANNEL_AUX_5"; case MA_CHANNEL_AUX_6 : return "CHANNEL_AUX_6"; case MA_CHANNEL_AUX_7 : return "CHANNEL_AUX_7"; case MA_CHANNEL_AUX_8 : return "CHANNEL_AUX_8"; case MA_CHANNEL_AUX_9 : return "CHANNEL_AUX_9"; case MA_CHANNEL_AUX_10 : return "CHANNEL_AUX_10"; case MA_CHANNEL_AUX_11 : return "CHANNEL_AUX_11"; case MA_CHANNEL_AUX_12 : return "CHANNEL_AUX_12"; case MA_CHANNEL_AUX_13 : return "CHANNEL_AUX_13"; case MA_CHANNEL_AUX_14 : return "CHANNEL_AUX_14"; case MA_CHANNEL_AUX_15 : return "CHANNEL_AUX_15"; case MA_CHANNEL_AUX_16 : return "CHANNEL_AUX_16"; case MA_CHANNEL_AUX_17 : return "CHANNEL_AUX_17"; case MA_CHANNEL_AUX_18 : return "CHANNEL_AUX_18"; case MA_CHANNEL_AUX_19 : return "CHANNEL_AUX_19"; case MA_CHANNEL_AUX_20 : return "CHANNEL_AUX_20"; case MA_CHANNEL_AUX_21 : return "CHANNEL_AUX_21"; case MA_CHANNEL_AUX_22 : return "CHANNEL_AUX_22"; case MA_CHANNEL_AUX_23 : return "CHANNEL_AUX_23"; case MA_CHANNEL_AUX_24 : return "CHANNEL_AUX_24"; case MA_CHANNEL_AUX_25 : return "CHANNEL_AUX_25"; case MA_CHANNEL_AUX_26 : return "CHANNEL_AUX_26"; case MA_CHANNEL_AUX_27 : return "CHANNEL_AUX_27"; case MA_CHANNEL_AUX_28 : return "CHANNEL_AUX_28"; case MA_CHANNEL_AUX_29 : return "CHANNEL_AUX_29"; case MA_CHANNEL_AUX_30 : return "CHANNEL_AUX_30"; case MA_CHANNEL_AUX_31 : return "CHANNEL_AUX_31"; default: break; } return "UNKNOWN"; } /************************************************************************************************************************************************************** Conversion Helpers **************************************************************************************************************************************************************/ MA_API ma_uint64 ma_convert_frames(void* pOut, ma_uint64 frameCountOut, ma_format formatOut, ma_uint32 channelsOut, ma_uint32 sampleRateOut, const void* pIn, ma_uint64 frameCountIn, ma_format formatIn, ma_uint32 channelsIn, ma_uint32 sampleRateIn) { ma_data_converter_config config; config = ma_data_converter_config_init(formatIn, formatOut, channelsIn, channelsOut, sampleRateIn, sampleRateOut); config.resampling.linear.lpfOrder = ma_min(MA_DEFAULT_RESAMPLER_LPF_ORDER, MA_MAX_FILTER_ORDER); return ma_convert_frames_ex(pOut, frameCountOut, pIn, frameCountIn, &config); } MA_API ma_uint64 ma_convert_frames_ex(void* pOut, ma_uint64 frameCountOut, const void* pIn, ma_uint64 frameCountIn, const ma_data_converter_config* pConfig) { ma_result result; ma_data_converter converter; if (frameCountIn == 0 || pConfig == NULL) { return 0; } result = ma_data_converter_init(pConfig, NULL, &converter); if (result != MA_SUCCESS) { return 0; /* Failed to initialize the data converter. */ } if (pOut == NULL) { result = ma_data_converter_get_expected_output_frame_count(&converter, frameCountIn, &frameCountOut); if (result != MA_SUCCESS) { if (result == MA_NOT_IMPLEMENTED) { /* No way to calculate the number of frames, so we'll need to brute force it and loop. */ frameCountOut = 0; while (frameCountIn > 0) { ma_uint64 framesProcessedIn = frameCountIn; ma_uint64 framesProcessedOut = 0xFFFFFFFF; result = ma_data_converter_process_pcm_frames(&converter, pIn, &framesProcessedIn, NULL, &framesProcessedOut); if (result != MA_SUCCESS) { break; } frameCountIn -= framesProcessedIn; } } } } else { result = ma_data_converter_process_pcm_frames(&converter, pIn, &frameCountIn, pOut, &frameCountOut); if (result != MA_SUCCESS) { frameCountOut = 0; } } ma_data_converter_uninit(&converter, NULL); return frameCountOut; } /************************************************************************************************************************************************************** Ring Buffer **************************************************************************************************************************************************************/ static MA_INLINE ma_uint32 ma_rb__extract_offset_in_bytes(ma_uint32 encodedOffset) { return encodedOffset & 0x7FFFFFFF; } static MA_INLINE ma_uint32 ma_rb__extract_offset_loop_flag(ma_uint32 encodedOffset) { return encodedOffset & 0x80000000; } static MA_INLINE void* ma_rb__get_read_ptr(ma_rb* pRB) { MA_ASSERT(pRB != NULL); return ma_offset_ptr(pRB->pBuffer, ma_rb__extract_offset_in_bytes(ma_atomic_load_32(&pRB->encodedReadOffset))); } static MA_INLINE void* ma_rb__get_write_ptr(ma_rb* pRB) { MA_ASSERT(pRB != NULL); return ma_offset_ptr(pRB->pBuffer, ma_rb__extract_offset_in_bytes(ma_atomic_load_32(&pRB->encodedWriteOffset))); } static MA_INLINE ma_uint32 ma_rb__construct_offset(ma_uint32 offsetInBytes, ma_uint32 offsetLoopFlag) { return offsetLoopFlag | offsetInBytes; } static MA_INLINE void ma_rb__deconstruct_offset(ma_uint32 encodedOffset, ma_uint32* pOffsetInBytes, ma_uint32* pOffsetLoopFlag) { MA_ASSERT(pOffsetInBytes != NULL); MA_ASSERT(pOffsetLoopFlag != NULL); *pOffsetInBytes = ma_rb__extract_offset_in_bytes(encodedOffset); *pOffsetLoopFlag = ma_rb__extract_offset_loop_flag(encodedOffset); } MA_API ma_result ma_rb_init_ex(size_t subbufferSizeInBytes, size_t subbufferCount, size_t subbufferStrideInBytes, void* pOptionalPreallocatedBuffer, const ma_allocation_callbacks* pAllocationCallbacks, ma_rb* pRB) { ma_result result; const ma_uint32 maxSubBufferSize = 0x7FFFFFFF - (MA_SIMD_ALIGNMENT-1); if (pRB == NULL) { return MA_INVALID_ARGS; } if (subbufferSizeInBytes == 0 || subbufferCount == 0) { return MA_INVALID_ARGS; } if (subbufferSizeInBytes > maxSubBufferSize) { return MA_INVALID_ARGS; /* Maximum buffer size is ~2GB. The most significant bit is a flag for use internally. */ } MA_ZERO_OBJECT(pRB); result = ma_allocation_callbacks_init_copy(&pRB->allocationCallbacks, pAllocationCallbacks); if (result != MA_SUCCESS) { return result; } pRB->subbufferSizeInBytes = (ma_uint32)subbufferSizeInBytes; pRB->subbufferCount = (ma_uint32)subbufferCount; if (pOptionalPreallocatedBuffer != NULL) { pRB->subbufferStrideInBytes = (ma_uint32)subbufferStrideInBytes; pRB->pBuffer = pOptionalPreallocatedBuffer; } else { size_t bufferSizeInBytes; /* Here is where we allocate our own buffer. We always want to align this to MA_SIMD_ALIGNMENT for future SIMD optimization opportunity. To do this we need to make sure the stride is a multiple of MA_SIMD_ALIGNMENT. */ pRB->subbufferStrideInBytes = (pRB->subbufferSizeInBytes + (MA_SIMD_ALIGNMENT-1)) & ~MA_SIMD_ALIGNMENT; bufferSizeInBytes = (size_t)pRB->subbufferCount*pRB->subbufferStrideInBytes; pRB->pBuffer = ma_aligned_malloc(bufferSizeInBytes, MA_SIMD_ALIGNMENT, &pRB->allocationCallbacks); if (pRB->pBuffer == NULL) { return MA_OUT_OF_MEMORY; } MA_ZERO_MEMORY(pRB->pBuffer, bufferSizeInBytes); pRB->ownsBuffer = MA_TRUE; } return MA_SUCCESS; } MA_API ma_result ma_rb_init(size_t bufferSizeInBytes, void* pOptionalPreallocatedBuffer, const ma_allocation_callbacks* pAllocationCallbacks, ma_rb* pRB) { return ma_rb_init_ex(bufferSizeInBytes, 1, 0, pOptionalPreallocatedBuffer, pAllocationCallbacks, pRB); } MA_API void ma_rb_uninit(ma_rb* pRB) { if (pRB == NULL) { return; } if (pRB->ownsBuffer) { ma_aligned_free(pRB->pBuffer, &pRB->allocationCallbacks); } } MA_API void ma_rb_reset(ma_rb* pRB) { if (pRB == NULL) { return; } ma_atomic_exchange_32(&pRB->encodedReadOffset, 0); ma_atomic_exchange_32(&pRB->encodedWriteOffset, 0); } MA_API ma_result ma_rb_acquire_read(ma_rb* pRB, size_t* pSizeInBytes, void** ppBufferOut) { ma_uint32 writeOffset; ma_uint32 writeOffsetInBytes; ma_uint32 writeOffsetLoopFlag; ma_uint32 readOffset; ma_uint32 readOffsetInBytes; ma_uint32 readOffsetLoopFlag; size_t bytesAvailable; size_t bytesRequested; if (pRB == NULL || pSizeInBytes == NULL || ppBufferOut == NULL) { return MA_INVALID_ARGS; } /* The returned buffer should never move ahead of the write pointer. */ writeOffset = ma_atomic_load_32(&pRB->encodedWriteOffset); ma_rb__deconstruct_offset(writeOffset, &writeOffsetInBytes, &writeOffsetLoopFlag); readOffset = ma_atomic_load_32(&pRB->encodedReadOffset); ma_rb__deconstruct_offset(readOffset, &readOffsetInBytes, &readOffsetLoopFlag); /* The number of bytes available depends on whether or not the read and write pointers are on the same loop iteration. If so, we can only read up to the write pointer. If not, we can only read up to the end of the buffer. */ if (readOffsetLoopFlag == writeOffsetLoopFlag) { bytesAvailable = writeOffsetInBytes - readOffsetInBytes; } else { bytesAvailable = pRB->subbufferSizeInBytes - readOffsetInBytes; } bytesRequested = *pSizeInBytes; if (bytesRequested > bytesAvailable) { bytesRequested = bytesAvailable; } *pSizeInBytes = bytesRequested; (*ppBufferOut) = ma_rb__get_read_ptr(pRB); return MA_SUCCESS; } MA_API ma_result ma_rb_commit_read(ma_rb* pRB, size_t sizeInBytes) { ma_uint32 readOffset; ma_uint32 readOffsetInBytes; ma_uint32 readOffsetLoopFlag; ma_uint32 newReadOffsetInBytes; ma_uint32 newReadOffsetLoopFlag; if (pRB == NULL) { return MA_INVALID_ARGS; } readOffset = ma_atomic_load_32(&pRB->encodedReadOffset); ma_rb__deconstruct_offset(readOffset, &readOffsetInBytes, &readOffsetLoopFlag); /* Check that sizeInBytes is correct. It should never go beyond the end of the buffer. */ newReadOffsetInBytes = (ma_uint32)(readOffsetInBytes + sizeInBytes); if (newReadOffsetInBytes > pRB->subbufferSizeInBytes) { return MA_INVALID_ARGS; /* <-- sizeInBytes will cause the read offset to overflow. */ } /* Move the read pointer back to the start if necessary. */ newReadOffsetLoopFlag = readOffsetLoopFlag; if (newReadOffsetInBytes == pRB->subbufferSizeInBytes) { newReadOffsetInBytes = 0; newReadOffsetLoopFlag ^= 0x80000000; } ma_atomic_exchange_32(&pRB->encodedReadOffset, ma_rb__construct_offset(newReadOffsetLoopFlag, newReadOffsetInBytes)); if (ma_rb_pointer_distance(pRB) == 0) { return MA_AT_END; } else { return MA_SUCCESS; } } MA_API ma_result ma_rb_acquire_write(ma_rb* pRB, size_t* pSizeInBytes, void** ppBufferOut) { ma_uint32 readOffset; ma_uint32 readOffsetInBytes; ma_uint32 readOffsetLoopFlag; ma_uint32 writeOffset; ma_uint32 writeOffsetInBytes; ma_uint32 writeOffsetLoopFlag; size_t bytesAvailable; size_t bytesRequested; if (pRB == NULL || pSizeInBytes == NULL || ppBufferOut == NULL) { return MA_INVALID_ARGS; } /* The returned buffer should never overtake the read buffer. */ readOffset = ma_atomic_load_32(&pRB->encodedReadOffset); ma_rb__deconstruct_offset(readOffset, &readOffsetInBytes, &readOffsetLoopFlag); writeOffset = ma_atomic_load_32(&pRB->encodedWriteOffset); ma_rb__deconstruct_offset(writeOffset, &writeOffsetInBytes, &writeOffsetLoopFlag); /* In the case of writing, if the write pointer and the read pointer are on the same loop iteration we can only write up to the end of the buffer. Otherwise we can only write up to the read pointer. The write pointer should never overtake the read pointer. */ if (writeOffsetLoopFlag == readOffsetLoopFlag) { bytesAvailable = pRB->subbufferSizeInBytes - writeOffsetInBytes; } else { bytesAvailable = readOffsetInBytes - writeOffsetInBytes; } bytesRequested = *pSizeInBytes; if (bytesRequested > bytesAvailable) { bytesRequested = bytesAvailable; } *pSizeInBytes = bytesRequested; *ppBufferOut = ma_rb__get_write_ptr(pRB); /* Clear the buffer if desired. */ if (pRB->clearOnWriteAcquire) { MA_ZERO_MEMORY(*ppBufferOut, *pSizeInBytes); } return MA_SUCCESS; } MA_API ma_result ma_rb_commit_write(ma_rb* pRB, size_t sizeInBytes) { ma_uint32 writeOffset; ma_uint32 writeOffsetInBytes; ma_uint32 writeOffsetLoopFlag; ma_uint32 newWriteOffsetInBytes; ma_uint32 newWriteOffsetLoopFlag; if (pRB == NULL) { return MA_INVALID_ARGS; } writeOffset = ma_atomic_load_32(&pRB->encodedWriteOffset); ma_rb__deconstruct_offset(writeOffset, &writeOffsetInBytes, &writeOffsetLoopFlag); /* Check that sizeInBytes is correct. It should never go beyond the end of the buffer. */ newWriteOffsetInBytes = (ma_uint32)(writeOffsetInBytes + sizeInBytes); if (newWriteOffsetInBytes > pRB->subbufferSizeInBytes) { return MA_INVALID_ARGS; /* <-- sizeInBytes will cause the read offset to overflow. */ } /* Move the read pointer back to the start if necessary. */ newWriteOffsetLoopFlag = writeOffsetLoopFlag; if (newWriteOffsetInBytes == pRB->subbufferSizeInBytes) { newWriteOffsetInBytes = 0; newWriteOffsetLoopFlag ^= 0x80000000; } ma_atomic_exchange_32(&pRB->encodedWriteOffset, ma_rb__construct_offset(newWriteOffsetLoopFlag, newWriteOffsetInBytes)); if (ma_rb_pointer_distance(pRB) == 0) { return MA_AT_END; } else { return MA_SUCCESS; } } MA_API ma_result ma_rb_seek_read(ma_rb* pRB, size_t offsetInBytes) { ma_uint32 readOffset; ma_uint32 readOffsetInBytes; ma_uint32 readOffsetLoopFlag; ma_uint32 writeOffset; ma_uint32 writeOffsetInBytes; ma_uint32 writeOffsetLoopFlag; ma_uint32 newReadOffsetInBytes; ma_uint32 newReadOffsetLoopFlag; if (pRB == NULL || offsetInBytes > pRB->subbufferSizeInBytes) { return MA_INVALID_ARGS; } readOffset = ma_atomic_load_32(&pRB->encodedReadOffset); ma_rb__deconstruct_offset(readOffset, &readOffsetInBytes, &readOffsetLoopFlag); writeOffset = ma_atomic_load_32(&pRB->encodedWriteOffset); ma_rb__deconstruct_offset(writeOffset, &writeOffsetInBytes, &writeOffsetLoopFlag); newReadOffsetLoopFlag = readOffsetLoopFlag; /* We cannot go past the write buffer. */ if (readOffsetLoopFlag == writeOffsetLoopFlag) { if ((readOffsetInBytes + offsetInBytes) > writeOffsetInBytes) { newReadOffsetInBytes = writeOffsetInBytes; } else { newReadOffsetInBytes = (ma_uint32)(readOffsetInBytes + offsetInBytes); } } else { /* May end up looping. */ if ((readOffsetInBytes + offsetInBytes) >= pRB->subbufferSizeInBytes) { newReadOffsetInBytes = (ma_uint32)(readOffsetInBytes + offsetInBytes) - pRB->subbufferSizeInBytes; newReadOffsetLoopFlag ^= 0x80000000; /* <-- Looped. */ } else { newReadOffsetInBytes = (ma_uint32)(readOffsetInBytes + offsetInBytes); } } ma_atomic_exchange_32(&pRB->encodedReadOffset, ma_rb__construct_offset(newReadOffsetInBytes, newReadOffsetLoopFlag)); return MA_SUCCESS; } MA_API ma_result ma_rb_seek_write(ma_rb* pRB, size_t offsetInBytes) { ma_uint32 readOffset; ma_uint32 readOffsetInBytes; ma_uint32 readOffsetLoopFlag; ma_uint32 writeOffset; ma_uint32 writeOffsetInBytes; ma_uint32 writeOffsetLoopFlag; ma_uint32 newWriteOffsetInBytes; ma_uint32 newWriteOffsetLoopFlag; if (pRB == NULL) { return MA_INVALID_ARGS; } readOffset = ma_atomic_load_32(&pRB->encodedReadOffset); ma_rb__deconstruct_offset(readOffset, &readOffsetInBytes, &readOffsetLoopFlag); writeOffset = ma_atomic_load_32(&pRB->encodedWriteOffset); ma_rb__deconstruct_offset(writeOffset, &writeOffsetInBytes, &writeOffsetLoopFlag); newWriteOffsetLoopFlag = writeOffsetLoopFlag; /* We cannot go past the write buffer. */ if (readOffsetLoopFlag == writeOffsetLoopFlag) { /* May end up looping. */ if ((writeOffsetInBytes + offsetInBytes) >= pRB->subbufferSizeInBytes) { newWriteOffsetInBytes = (ma_uint32)(writeOffsetInBytes + offsetInBytes) - pRB->subbufferSizeInBytes; newWriteOffsetLoopFlag ^= 0x80000000; /* <-- Looped. */ } else { newWriteOffsetInBytes = (ma_uint32)(writeOffsetInBytes + offsetInBytes); } } else { if ((writeOffsetInBytes + offsetInBytes) > readOffsetInBytes) { newWriteOffsetInBytes = readOffsetInBytes; } else { newWriteOffsetInBytes = (ma_uint32)(writeOffsetInBytes + offsetInBytes); } } ma_atomic_exchange_32(&pRB->encodedWriteOffset, ma_rb__construct_offset(newWriteOffsetInBytes, newWriteOffsetLoopFlag)); return MA_SUCCESS; } MA_API ma_int32 ma_rb_pointer_distance(ma_rb* pRB) { ma_uint32 readOffset; ma_uint32 readOffsetInBytes; ma_uint32 readOffsetLoopFlag; ma_uint32 writeOffset; ma_uint32 writeOffsetInBytes; ma_uint32 writeOffsetLoopFlag; if (pRB == NULL) { return 0; } readOffset = ma_atomic_load_32(&pRB->encodedReadOffset); ma_rb__deconstruct_offset(readOffset, &readOffsetInBytes, &readOffsetLoopFlag); writeOffset = ma_atomic_load_32(&pRB->encodedWriteOffset); ma_rb__deconstruct_offset(writeOffset, &writeOffsetInBytes, &writeOffsetLoopFlag); if (readOffsetLoopFlag == writeOffsetLoopFlag) { return writeOffsetInBytes - readOffsetInBytes; } else { return writeOffsetInBytes + (pRB->subbufferSizeInBytes - readOffsetInBytes); } } MA_API ma_uint32 ma_rb_available_read(ma_rb* pRB) { ma_int32 dist; if (pRB == NULL) { return 0; } dist = ma_rb_pointer_distance(pRB); if (dist < 0) { return 0; } return dist; } MA_API ma_uint32 ma_rb_available_write(ma_rb* pRB) { if (pRB == NULL) { return 0; } return (ma_uint32)(ma_rb_get_subbuffer_size(pRB) - ma_rb_pointer_distance(pRB)); } MA_API size_t ma_rb_get_subbuffer_size(ma_rb* pRB) { if (pRB == NULL) { return 0; } return pRB->subbufferSizeInBytes; } MA_API size_t ma_rb_get_subbuffer_stride(ma_rb* pRB) { if (pRB == NULL) { return 0; } if (pRB->subbufferStrideInBytes == 0) { return (size_t)pRB->subbufferSizeInBytes; } return (size_t)pRB->subbufferStrideInBytes; } MA_API size_t ma_rb_get_subbuffer_offset(ma_rb* pRB, size_t subbufferIndex) { if (pRB == NULL) { return 0; } return subbufferIndex * ma_rb_get_subbuffer_stride(pRB); } MA_API void* ma_rb_get_subbuffer_ptr(ma_rb* pRB, size_t subbufferIndex, void* pBuffer) { if (pRB == NULL) { return NULL; } return ma_offset_ptr(pBuffer, ma_rb_get_subbuffer_offset(pRB, subbufferIndex)); } static ma_result ma_pcm_rb_data_source__on_read(ma_data_source* pDataSource, void* pFramesOut, ma_uint64 frameCount, ma_uint64* pFramesRead) { /* Since there's no notion of an end, we don't ever want to return MA_AT_END here. But it is possible to return 0. */ ma_pcm_rb* pRB = (ma_pcm_rb*)pDataSource; ma_result result; ma_uint64 totalFramesRead; MA_ASSERT(pRB != NULL); /* We need to run this in a loop since the ring buffer itself may loop. */ totalFramesRead = 0; while (totalFramesRead < frameCount) { void* pMappedBuffer; ma_uint32 mappedFrameCount; ma_uint64 framesToRead = frameCount - totalFramesRead; if (framesToRead > 0xFFFFFFFF) { framesToRead = 0xFFFFFFFF; } mappedFrameCount = (ma_uint32)framesToRead; result = ma_pcm_rb_acquire_read(pRB, &mappedFrameCount, &pMappedBuffer); if (result != MA_SUCCESS) { break; } if (mappedFrameCount == 0) { break; /* <-- End of ring buffer. */ } ma_copy_pcm_frames(ma_offset_pcm_frames_ptr(pFramesOut, totalFramesRead, pRB->format, pRB->channels), pMappedBuffer, mappedFrameCount, pRB->format, pRB->channels); result = ma_pcm_rb_commit_read(pRB, mappedFrameCount); if (result != MA_SUCCESS) { break; } totalFramesRead += mappedFrameCount; } *pFramesRead = totalFramesRead; return MA_SUCCESS; } static ma_result ma_pcm_rb_data_source__on_get_data_format(ma_data_source* pDataSource, ma_format* pFormat, ma_uint32* pChannels, ma_uint32* pSampleRate, ma_channel* pChannelMap, size_t channelMapCap) { ma_pcm_rb* pRB = (ma_pcm_rb*)pDataSource; MA_ASSERT(pRB != NULL); if (pFormat != NULL) { *pFormat = pRB->format; } if (pChannels != NULL) { *pChannels = pRB->channels; } if (pSampleRate != NULL) { *pSampleRate = pRB->sampleRate; } /* Just assume the default channel map. */ if (pChannelMap != NULL) { ma_channel_map_init_standard(ma_standard_channel_map_default, pChannelMap, channelMapCap, pRB->channels); } return MA_SUCCESS; } static ma_data_source_vtable ma_gRBDataSourceVTable = { ma_pcm_rb_data_source__on_read, NULL, /* onSeek */ ma_pcm_rb_data_source__on_get_data_format, NULL, /* onGetCursor */ NULL, /* onGetLength */ NULL, /* onSetLooping */ 0 }; static MA_INLINE ma_uint32 ma_pcm_rb_get_bpf(ma_pcm_rb* pRB) { MA_ASSERT(pRB != NULL); return ma_get_bytes_per_frame(pRB->format, pRB->channels); } MA_API ma_result ma_pcm_rb_init_ex(ma_format format, ma_uint32 channels, ma_uint32 subbufferSizeInFrames, ma_uint32 subbufferCount, ma_uint32 subbufferStrideInFrames, void* pOptionalPreallocatedBuffer, const ma_allocation_callbacks* pAllocationCallbacks, ma_pcm_rb* pRB) { ma_uint32 bpf; ma_result result; if (pRB == NULL) { return MA_INVALID_ARGS; } MA_ZERO_OBJECT(pRB); bpf = ma_get_bytes_per_frame(format, channels); if (bpf == 0) { return MA_INVALID_ARGS; } result = ma_rb_init_ex(subbufferSizeInFrames*bpf, subbufferCount, subbufferStrideInFrames*bpf, pOptionalPreallocatedBuffer, pAllocationCallbacks, &pRB->rb); if (result != MA_SUCCESS) { return result; } pRB->format = format; pRB->channels = channels; pRB->sampleRate = 0; /* The sample rate is not passed in as a parameter. */ /* The PCM ring buffer is a data source. We need to get that set up as well. */ { ma_data_source_config dataSourceConfig = ma_data_source_config_init(); dataSourceConfig.vtable = &ma_gRBDataSourceVTable; result = ma_data_source_init(&dataSourceConfig, &pRB->ds); if (result != MA_SUCCESS) { ma_rb_uninit(&pRB->rb); return result; } } return MA_SUCCESS; } MA_API ma_result ma_pcm_rb_init(ma_format format, ma_uint32 channels, ma_uint32 bufferSizeInFrames, void* pOptionalPreallocatedBuffer, const ma_allocation_callbacks* pAllocationCallbacks, ma_pcm_rb* pRB) { return ma_pcm_rb_init_ex(format, channels, bufferSizeInFrames, 1, 0, pOptionalPreallocatedBuffer, pAllocationCallbacks, pRB); } MA_API void ma_pcm_rb_uninit(ma_pcm_rb* pRB) { if (pRB == NULL) { return; } ma_data_source_uninit(&pRB->ds); ma_rb_uninit(&pRB->rb); } MA_API void ma_pcm_rb_reset(ma_pcm_rb* pRB) { if (pRB == NULL) { return; } ma_rb_reset(&pRB->rb); } MA_API ma_result ma_pcm_rb_acquire_read(ma_pcm_rb* pRB, ma_uint32* pSizeInFrames, void** ppBufferOut) { size_t sizeInBytes; ma_result result; if (pRB == NULL || pSizeInFrames == NULL) { return MA_INVALID_ARGS; } sizeInBytes = *pSizeInFrames * ma_pcm_rb_get_bpf(pRB); result = ma_rb_acquire_read(&pRB->rb, &sizeInBytes, ppBufferOut); if (result != MA_SUCCESS) { return result; } *pSizeInFrames = (ma_uint32)(sizeInBytes / (size_t)ma_pcm_rb_get_bpf(pRB)); return MA_SUCCESS; } MA_API ma_result ma_pcm_rb_commit_read(ma_pcm_rb* pRB, ma_uint32 sizeInFrames) { if (pRB == NULL) { return MA_INVALID_ARGS; } return ma_rb_commit_read(&pRB->rb, sizeInFrames * ma_pcm_rb_get_bpf(pRB)); } MA_API ma_result ma_pcm_rb_acquire_write(ma_pcm_rb* pRB, ma_uint32* pSizeInFrames, void** ppBufferOut) { size_t sizeInBytes; ma_result result; if (pRB == NULL) { return MA_INVALID_ARGS; } sizeInBytes = *pSizeInFrames * ma_pcm_rb_get_bpf(pRB); result = ma_rb_acquire_write(&pRB->rb, &sizeInBytes, ppBufferOut); if (result != MA_SUCCESS) { return result; } *pSizeInFrames = (ma_uint32)(sizeInBytes / ma_pcm_rb_get_bpf(pRB)); return MA_SUCCESS; } MA_API ma_result ma_pcm_rb_commit_write(ma_pcm_rb* pRB, ma_uint32 sizeInFrames) { if (pRB == NULL) { return MA_INVALID_ARGS; } return ma_rb_commit_write(&pRB->rb, sizeInFrames * ma_pcm_rb_get_bpf(pRB)); } MA_API ma_result ma_pcm_rb_seek_read(ma_pcm_rb* pRB, ma_uint32 offsetInFrames) { if (pRB == NULL) { return MA_INVALID_ARGS; } return ma_rb_seek_read(&pRB->rb, offsetInFrames * ma_pcm_rb_get_bpf(pRB)); } MA_API ma_result ma_pcm_rb_seek_write(ma_pcm_rb* pRB, ma_uint32 offsetInFrames) { if (pRB == NULL) { return MA_INVALID_ARGS; } return ma_rb_seek_write(&pRB->rb, offsetInFrames * ma_pcm_rb_get_bpf(pRB)); } MA_API ma_int32 ma_pcm_rb_pointer_distance(ma_pcm_rb* pRB) { if (pRB == NULL) { return 0; } return ma_rb_pointer_distance(&pRB->rb) / ma_pcm_rb_get_bpf(pRB); } MA_API ma_uint32 ma_pcm_rb_available_read(ma_pcm_rb* pRB) { if (pRB == NULL) { return 0; } return ma_rb_available_read(&pRB->rb) / ma_pcm_rb_get_bpf(pRB); } MA_API ma_uint32 ma_pcm_rb_available_write(ma_pcm_rb* pRB) { if (pRB == NULL) { return 0; } return ma_rb_available_write(&pRB->rb) / ma_pcm_rb_get_bpf(pRB); } MA_API ma_uint32 ma_pcm_rb_get_subbuffer_size(ma_pcm_rb* pRB) { if (pRB == NULL) { return 0; } return (ma_uint32)(ma_rb_get_subbuffer_size(&pRB->rb) / ma_pcm_rb_get_bpf(pRB)); } MA_API ma_uint32 ma_pcm_rb_get_subbuffer_stride(ma_pcm_rb* pRB) { if (pRB == NULL) { return 0; } return (ma_uint32)(ma_rb_get_subbuffer_stride(&pRB->rb) / ma_pcm_rb_get_bpf(pRB)); } MA_API ma_uint32 ma_pcm_rb_get_subbuffer_offset(ma_pcm_rb* pRB, ma_uint32 subbufferIndex) { if (pRB == NULL) { return 0; } return (ma_uint32)(ma_rb_get_subbuffer_offset(&pRB->rb, subbufferIndex) / ma_pcm_rb_get_bpf(pRB)); } MA_API void* ma_pcm_rb_get_subbuffer_ptr(ma_pcm_rb* pRB, ma_uint32 subbufferIndex, void* pBuffer) { if (pRB == NULL) { return NULL; } return ma_rb_get_subbuffer_ptr(&pRB->rb, subbufferIndex, pBuffer); } MA_API ma_format ma_pcm_rb_get_format(const ma_pcm_rb* pRB) { if (pRB == NULL) { return ma_format_unknown; } return pRB->format; } MA_API ma_uint32 ma_pcm_rb_get_channels(const ma_pcm_rb* pRB) { if (pRB == NULL) { return 0; } return pRB->channels; } MA_API ma_uint32 ma_pcm_rb_get_sample_rate(const ma_pcm_rb* pRB) { if (pRB == NULL) { return 0; } return pRB->sampleRate; } MA_API void ma_pcm_rb_set_sample_rate(ma_pcm_rb* pRB, ma_uint32 sampleRate) { if (pRB == NULL) { return; } pRB->sampleRate = sampleRate; } MA_API ma_result ma_duplex_rb_init(ma_format captureFormat, ma_uint32 captureChannels, ma_uint32 sampleRate, ma_uint32 captureInternalSampleRate, ma_uint32 captureInternalPeriodSizeInFrames, const ma_allocation_callbacks* pAllocationCallbacks, ma_duplex_rb* pRB) { ma_result result; ma_uint32 sizeInFrames; sizeInFrames = (ma_uint32)ma_calculate_frame_count_after_resampling(sampleRate, captureInternalSampleRate, captureInternalPeriodSizeInFrames * 5); if (sizeInFrames == 0) { return MA_INVALID_ARGS; } result = ma_pcm_rb_init(captureFormat, captureChannels, sizeInFrames, NULL, pAllocationCallbacks, &pRB->rb); if (result != MA_SUCCESS) { return result; } /* Seek forward a bit so we have a bit of a buffer in case of desyncs. */ ma_pcm_rb_seek_write((ma_pcm_rb*)pRB, captureInternalPeriodSizeInFrames * 2); return MA_SUCCESS; } MA_API ma_result ma_duplex_rb_uninit(ma_duplex_rb* pRB) { ma_pcm_rb_uninit((ma_pcm_rb*)pRB); return MA_SUCCESS; } /************************************************************************************************************************************************************** Miscellaneous Helpers **************************************************************************************************************************************************************/ MA_API const char* ma_result_description(ma_result result) { switch (result) { case MA_SUCCESS: return "No error"; case MA_ERROR: return "Unknown error"; case MA_INVALID_ARGS: return "Invalid argument"; case MA_INVALID_OPERATION: return "Invalid operation"; case MA_OUT_OF_MEMORY: return "Out of memory"; case MA_OUT_OF_RANGE: return "Out of range"; case MA_ACCESS_DENIED: return "Permission denied"; case MA_DOES_NOT_EXIST: return "Resource does not exist"; case MA_ALREADY_EXISTS: return "Resource already exists"; case MA_TOO_MANY_OPEN_FILES: return "Too many open files"; case MA_INVALID_FILE: return "Invalid file"; case MA_TOO_BIG: return "Too large"; case MA_PATH_TOO_LONG: return "Path too long"; case MA_NAME_TOO_LONG: return "Name too long"; case MA_NOT_DIRECTORY: return "Not a directory"; case MA_IS_DIRECTORY: return "Is a directory"; case MA_DIRECTORY_NOT_EMPTY: return "Directory not empty"; case MA_AT_END: return "At end"; case MA_NO_SPACE: return "No space available"; case MA_BUSY: return "Device or resource busy"; case MA_IO_ERROR: return "Input/output error"; case MA_INTERRUPT: return "Interrupted"; case MA_UNAVAILABLE: return "Resource unavailable"; case MA_ALREADY_IN_USE: return "Resource already in use"; case MA_BAD_ADDRESS: return "Bad address"; case MA_BAD_SEEK: return "Illegal seek"; case MA_BAD_PIPE: return "Broken pipe"; case MA_DEADLOCK: return "Deadlock"; case MA_TOO_MANY_LINKS: return "Too many links"; case MA_NOT_IMPLEMENTED: return "Not implemented"; case MA_NO_MESSAGE: return "No message of desired type"; case MA_BAD_MESSAGE: return "Invalid message"; case MA_NO_DATA_AVAILABLE: return "No data available"; case MA_INVALID_DATA: return "Invalid data"; case MA_TIMEOUT: return "Timeout"; case MA_NO_NETWORK: return "Network unavailable"; case MA_NOT_UNIQUE: return "Not unique"; case MA_NOT_SOCKET: return "Socket operation on non-socket"; case MA_NO_ADDRESS: return "Destination address required"; case MA_BAD_PROTOCOL: return "Protocol wrong type for socket"; case MA_PROTOCOL_UNAVAILABLE: return "Protocol not available"; case MA_PROTOCOL_NOT_SUPPORTED: return "Protocol not supported"; case MA_PROTOCOL_FAMILY_NOT_SUPPORTED: return "Protocol family not supported"; case MA_ADDRESS_FAMILY_NOT_SUPPORTED: return "Address family not supported"; case MA_SOCKET_NOT_SUPPORTED: return "Socket type not supported"; case MA_CONNECTION_RESET: return "Connection reset"; case MA_ALREADY_CONNECTED: return "Already connected"; case MA_NOT_CONNECTED: return "Not connected"; case MA_CONNECTION_REFUSED: return "Connection refused"; case MA_NO_HOST: return "No host"; case MA_IN_PROGRESS: return "Operation in progress"; case MA_CANCELLED: return "Operation cancelled"; case MA_MEMORY_ALREADY_MAPPED: return "Memory already mapped"; case MA_FORMAT_NOT_SUPPORTED: return "Format not supported"; case MA_DEVICE_TYPE_NOT_SUPPORTED: return "Device type not supported"; case MA_SHARE_MODE_NOT_SUPPORTED: return "Share mode not supported"; case MA_NO_BACKEND: return "No backend"; case MA_NO_DEVICE: return "No device"; case MA_API_NOT_FOUND: return "API not found"; case MA_INVALID_DEVICE_CONFIG: return "Invalid device config"; case MA_DEVICE_NOT_INITIALIZED: return "Device not initialized"; case MA_DEVICE_NOT_STARTED: return "Device not started"; case MA_FAILED_TO_INIT_BACKEND: return "Failed to initialize backend"; case MA_FAILED_TO_OPEN_BACKEND_DEVICE: return "Failed to open backend device"; case MA_FAILED_TO_START_BACKEND_DEVICE: return "Failed to start backend device"; case MA_FAILED_TO_STOP_BACKEND_DEVICE: return "Failed to stop backend device"; default: return "Unknown error"; } } MA_API void* ma_malloc(size_t sz, const ma_allocation_callbacks* pAllocationCallbacks) { if (pAllocationCallbacks != NULL) { if (pAllocationCallbacks->onMalloc != NULL) { return pAllocationCallbacks->onMalloc(sz, pAllocationCallbacks->pUserData); } else { return NULL; /* Do not fall back to the default implementation. */ } } else { return ma__malloc_default(sz, NULL); } } MA_API void* ma_calloc(size_t sz, const ma_allocation_callbacks* pAllocationCallbacks) { void* p = ma_malloc(sz, pAllocationCallbacks); if (p != NULL) { MA_ZERO_MEMORY(p, sz); } return p; } MA_API void* ma_realloc(void* p, size_t sz, const ma_allocation_callbacks* pAllocationCallbacks) { if (pAllocationCallbacks != NULL) { if (pAllocationCallbacks->onRealloc != NULL) { return pAllocationCallbacks->onRealloc(p, sz, pAllocationCallbacks->pUserData); } else { return NULL; /* Do not fall back to the default implementation. */ } } else { return ma__realloc_default(p, sz, NULL); } } MA_API void ma_free(void* p, const ma_allocation_callbacks* pAllocationCallbacks) { if (p == NULL) { return; } if (pAllocationCallbacks != NULL) { if (pAllocationCallbacks->onFree != NULL) { pAllocationCallbacks->onFree(p, pAllocationCallbacks->pUserData); } else { return; /* Do no fall back to the default implementation. */ } } else { ma__free_default(p, NULL); } } MA_API void* ma_aligned_malloc(size_t sz, size_t alignment, const ma_allocation_callbacks* pAllocationCallbacks) { size_t extraBytes; void* pUnaligned; void* pAligned; if (alignment == 0) { return 0; } extraBytes = alignment-1 + sizeof(void*); pUnaligned = ma_malloc(sz + extraBytes, pAllocationCallbacks); if (pUnaligned == NULL) { return NULL; } pAligned = (void*)(((ma_uintptr)pUnaligned + extraBytes) & ~((ma_uintptr)(alignment-1))); ((void**)pAligned)[-1] = pUnaligned; return pAligned; } MA_API void ma_aligned_free(void* p, const ma_allocation_callbacks* pAllocationCallbacks) { ma_free(((void**)p)[-1], pAllocationCallbacks); } MA_API const char* ma_get_format_name(ma_format format) { switch (format) { case ma_format_unknown: return "Unknown"; case ma_format_u8: return "8-bit Unsigned Integer"; case ma_format_s16: return "16-bit Signed Integer"; case ma_format_s24: return "24-bit Signed Integer (Tightly Packed)"; case ma_format_s32: return "32-bit Signed Integer"; case ma_format_f32: return "32-bit IEEE Floating Point"; default: return "Invalid"; } } MA_API void ma_blend_f32(float* pOut, float* pInA, float* pInB, float factor, ma_uint32 channels) { ma_uint32 i; for (i = 0; i < channels; ++i) { pOut[i] = ma_mix_f32(pInA[i], pInB[i], factor); } } MA_API ma_uint32 ma_get_bytes_per_sample(ma_format format) { ma_uint32 sizes[] = { 0, /* unknown */ 1, /* u8 */ 2, /* s16 */ 3, /* s24 */ 4, /* s32 */ 4, /* f32 */ }; return sizes[format]; } #define MA_DATA_SOURCE_DEFAULT_RANGE_BEG 0 #define MA_DATA_SOURCE_DEFAULT_RANGE_END ~((ma_uint64)0) #define MA_DATA_SOURCE_DEFAULT_LOOP_POINT_BEG 0 #define MA_DATA_SOURCE_DEFAULT_LOOP_POINT_END ~((ma_uint64)0) MA_API ma_data_source_config ma_data_source_config_init(void) { ma_data_source_config config; MA_ZERO_OBJECT(&config); return config; } MA_API ma_result ma_data_source_init(const ma_data_source_config* pConfig, ma_data_source* pDataSource) { ma_data_source_base* pDataSourceBase = (ma_data_source_base*)pDataSource; if (pDataSource == NULL) { return MA_INVALID_ARGS; } MA_ZERO_OBJECT(pDataSourceBase); if (pConfig == NULL) { return MA_INVALID_ARGS; } pDataSourceBase->vtable = pConfig->vtable; pDataSourceBase->rangeBegInFrames = MA_DATA_SOURCE_DEFAULT_RANGE_BEG; pDataSourceBase->rangeEndInFrames = MA_DATA_SOURCE_DEFAULT_RANGE_END; pDataSourceBase->loopBegInFrames = MA_DATA_SOURCE_DEFAULT_LOOP_POINT_BEG; pDataSourceBase->loopEndInFrames = MA_DATA_SOURCE_DEFAULT_LOOP_POINT_END; pDataSourceBase->pCurrent = pDataSource; /* Always read from ourself by default. */ pDataSourceBase->pNext = NULL; pDataSourceBase->onGetNext = NULL; return MA_SUCCESS; } MA_API void ma_data_source_uninit(ma_data_source* pDataSource) { if (pDataSource == NULL) { return; } /* This is placeholder in case we need this later. Data sources need to call this in their uninitialization routine to ensure things work later on if something is added here. */ } static ma_result ma_data_source_resolve_current(ma_data_source* pDataSource, ma_data_source** ppCurrentDataSource) { ma_data_source_base* pCurrentDataSource = (ma_data_source_base*)pDataSource; MA_ASSERT(pDataSource != NULL); MA_ASSERT(ppCurrentDataSource != NULL); if (pCurrentDataSource->pCurrent == NULL) { /* The current data source is NULL. If we're using this in the context of a chain we need to return NULL here so that we don't end up looping. Otherwise we just return the data source itself. */ if (pCurrentDataSource->pNext != NULL || pCurrentDataSource->onGetNext != NULL) { pCurrentDataSource = NULL; } else { pCurrentDataSource = (ma_data_source_base*)pDataSource; /* Not being used in a chain. Make sure we just always read from the data source itself at all times. */ } } else { pCurrentDataSource = (ma_data_source_base*)pCurrentDataSource->pCurrent; } *ppCurrentDataSource = pCurrentDataSource; return MA_SUCCESS; } static ma_result ma_data_source_read_pcm_frames_within_range(ma_data_source* pDataSource, void* pFramesOut, ma_uint64 frameCount, ma_uint64* pFramesRead) { ma_data_source_base* pDataSourceBase = (ma_data_source_base*)pDataSource; ma_result result; ma_uint64 framesRead = 0; ma_bool32 loop = ma_data_source_is_looping(pDataSource); if (pDataSourceBase == NULL) { return MA_AT_END; } if (frameCount == 0) { return MA_INVALID_ARGS; } if ((pDataSourceBase->vtable->flags & MA_DATA_SOURCE_SELF_MANAGED_RANGE_AND_LOOP_POINT) != 0 || (pDataSourceBase->rangeEndInFrames == ~((ma_uint64)0) && (pDataSourceBase->loopEndInFrames == ~((ma_uint64)0) || loop == MA_FALSE))) { /* Either the data source is self-managing the range, or no range is set - just read like normal. The data source itself will tell us when the end is reached. */ result = pDataSourceBase->vtable->onRead(pDataSourceBase, pFramesOut, frameCount, &framesRead); } else { /* Need to clamp to within the range. */ ma_uint64 relativeCursor; ma_uint64 absoluteCursor; result = ma_data_source_get_cursor_in_pcm_frames(pDataSourceBase, &relativeCursor); if (result != MA_SUCCESS) { /* Failed to retrieve the cursor. Cannot read within a range or loop points. Just read like normal - this may happen for things like noise data sources where it doesn't really matter. */ result = pDataSourceBase->vtable->onRead(pDataSourceBase, pFramesOut, frameCount, &framesRead); } else { ma_uint64 rangeBeg; ma_uint64 rangeEnd; /* We have the cursor. We need to make sure we don't read beyond our range. */ rangeBeg = pDataSourceBase->rangeBegInFrames; rangeEnd = pDataSourceBase->rangeEndInFrames; absoluteCursor = rangeBeg + relativeCursor; /* If looping, make sure we're within range. */ if (loop) { if (pDataSourceBase->loopEndInFrames != ~((ma_uint64)0)) { rangeEnd = ma_min(rangeEnd, pDataSourceBase->rangeBegInFrames + pDataSourceBase->loopEndInFrames); } } if (frameCount > (rangeEnd - absoluteCursor) && rangeEnd != ~((ma_uint64)0)) { frameCount = (rangeEnd - absoluteCursor); } /* If the cursor is sitting on the end of the range the frame count will be set to 0 which can result in MA_INVALID_ARGS. In this case, we don't want to try reading, but instead return MA_AT_END so the higher level function can know about it. */ if (frameCount > 0) { result = pDataSourceBase->vtable->onRead(pDataSourceBase, pFramesOut, frameCount, &framesRead); } else { result = MA_AT_END; /* The cursor is sitting on the end of the range which means we're at the end. */ } } } if (pFramesRead != NULL) { *pFramesRead = framesRead; } /* We need to make sure MA_AT_END is returned if we hit the end of the range. */ if (result == MA_SUCCESS && framesRead == 0) { result = MA_AT_END; } return result; } MA_API ma_result ma_data_source_read_pcm_frames(ma_data_source* pDataSource, void* pFramesOut, ma_uint64 frameCount, ma_uint64* pFramesRead) { ma_result result = MA_SUCCESS; ma_data_source_base* pDataSourceBase = (ma_data_source_base*)pDataSource; ma_data_source_base* pCurrentDataSource; void* pRunningFramesOut = pFramesOut; ma_uint64 totalFramesProcessed = 0; ma_format format; ma_uint32 channels; ma_uint32 emptyLoopCounter = 0; /* Keeps track of how many times 0 frames have been read. For infinite loop detection of sounds with no audio data. */ ma_bool32 loop; if (pFramesRead != NULL) { *pFramesRead = 0; } if (frameCount == 0) { return MA_INVALID_ARGS; } if (pDataSourceBase == NULL) { return MA_INVALID_ARGS; } loop = ma_data_source_is_looping(pDataSource); /* We need to know the data format so we can advance the output buffer as we read frames. If this fails, chaining will not work and we'll just read as much as we can from the current source. */ if (ma_data_source_get_data_format(pDataSource, &format, &channels, NULL, NULL, 0) != MA_SUCCESS) { result = ma_data_source_resolve_current(pDataSource, (ma_data_source**)&pCurrentDataSource); if (result != MA_SUCCESS) { return result; } return ma_data_source_read_pcm_frames_within_range(pCurrentDataSource, pFramesOut, frameCount, pFramesRead); } /* Looping is a bit of a special case. When the `loop` argument is true, chaining will not work and only the current data source will be read from. */ /* Keep reading until we've read as many frames as possible. */ while (totalFramesProcessed < frameCount) { ma_uint64 framesProcessed = 0; ma_uint64 framesRemaining = frameCount - totalFramesProcessed; /* We need to resolve the data source that we'll actually be reading from. */ result = ma_data_source_resolve_current(pDataSource, (ma_data_source**)&pCurrentDataSource); if (result != MA_SUCCESS) { break; } if (pCurrentDataSource == NULL) { break; } result = ma_data_source_read_pcm_frames_within_range(pCurrentDataSource, pRunningFramesOut, framesRemaining, &framesProcessed); totalFramesProcessed += framesProcessed; /* If we encounted an error from the read callback, make sure it's propagated to the caller. The caller may need to know whether or not MA_BUSY is returned which is not necessarily considered an error. */ if (result != MA_SUCCESS && result != MA_AT_END) { break; } /* We can determine if we've reached the end by checking if ma_data_source_read_pcm_frames_within_range() returned MA_AT_END. To loop back to the start, all we need to do is seek back to the first frame. */ if (result == MA_AT_END) { /* The result needs to be reset back to MA_SUCCESS (from MA_AT_END) so that we don't accidentally return MA_AT_END when data has been read in prior loop iterations. at the end of this function, the result will be checked for MA_SUCCESS, and if the total number of frames processed is 0, will be explicitly set to MA_AT_END. */ result = MA_SUCCESS; /* We reached the end. If we're looping, we just loop back to the start of the current data source. If we're not looping we need to check if we have another in the chain, and if so, switch to it. */ if (loop) { if (framesProcessed == 0) { emptyLoopCounter += 1; if (emptyLoopCounter > 1) { break; /* Infinite loop detected. Get out. */ } } else { emptyLoopCounter = 0; } result = ma_data_source_seek_to_pcm_frame(pCurrentDataSource, pCurrentDataSource->loopBegInFrames); if (result != MA_SUCCESS) { break; /* Failed to loop. Abort. */ } /* Don't return MA_AT_END for looping sounds. */ result = MA_SUCCESS; } else { if (pCurrentDataSource->pNext != NULL) { pDataSourceBase->pCurrent = pCurrentDataSource->pNext; } else if (pCurrentDataSource->onGetNext != NULL) { pDataSourceBase->pCurrent = pCurrentDataSource->onGetNext(pCurrentDataSource); if (pDataSourceBase->pCurrent == NULL) { break; /* Our callback did not return a next data source. We're done. */ } } else { /* Reached the end of the chain. We're done. */ break; } /* The next data source needs to be rewound to ensure data is read in looping scenarios. */ result = ma_data_source_seek_to_pcm_frame(pDataSourceBase->pCurrent, 0); if (result != MA_SUCCESS) { break; } } } if (pRunningFramesOut != NULL) { pRunningFramesOut = ma_offset_ptr(pRunningFramesOut, framesProcessed * ma_get_bytes_per_frame(format, channels)); } } if (pFramesRead != NULL) { *pFramesRead = totalFramesProcessed; } MA_ASSERT(!(result == MA_AT_END && totalFramesProcessed > 0)); /* We should never be returning MA_AT_END if we read some data. */ if (result == MA_SUCCESS && totalFramesProcessed == 0) { result = MA_AT_END; } return result; } MA_API ma_result ma_data_source_seek_pcm_frames(ma_data_source* pDataSource, ma_uint64 frameCount, ma_uint64* pFramesSeeked) { return ma_data_source_read_pcm_frames(pDataSource, NULL, frameCount, pFramesSeeked); } MA_API ma_result ma_data_source_seek_to_pcm_frame(ma_data_source* pDataSource, ma_uint64 frameIndex) { ma_data_source_base* pDataSourceBase = (ma_data_source_base*)pDataSource; if (pDataSourceBase == NULL) { return MA_SUCCESS; } if (pDataSourceBase->vtable->onSeek == NULL) { return MA_NOT_IMPLEMENTED; } if (frameIndex > pDataSourceBase->rangeEndInFrames) { return MA_INVALID_OPERATION; /* Trying to seek to far forward. */ } return pDataSourceBase->vtable->onSeek(pDataSource, pDataSourceBase->rangeBegInFrames + frameIndex); } MA_API ma_result ma_data_source_get_data_format(ma_data_source* pDataSource, ma_format* pFormat, ma_uint32* pChannels, ma_uint32* pSampleRate, ma_channel* pChannelMap, size_t channelMapCap) { ma_data_source_base* pDataSourceBase = (ma_data_source_base*)pDataSource; ma_result result; ma_format format; ma_uint32 channels; ma_uint32 sampleRate; /* Initialize to defaults for safety just in case the data source does not implement this callback. */ if (pFormat != NULL) { *pFormat = ma_format_unknown; } if (pChannels != NULL) { *pChannels = 0; } if (pSampleRate != NULL) { *pSampleRate = 0; } if (pChannelMap != NULL) { MA_ZERO_MEMORY(pChannelMap, sizeof(*pChannelMap) * channelMapCap); } if (pDataSourceBase == NULL) { return MA_INVALID_ARGS; } if (pDataSourceBase->vtable->onGetDataFormat == NULL) { return MA_NOT_IMPLEMENTED; } result = pDataSourceBase->vtable->onGetDataFormat(pDataSource, &format, &channels, &sampleRate, pChannelMap, channelMapCap); if (result != MA_SUCCESS) { return result; } if (pFormat != NULL) { *pFormat = format; } if (pChannels != NULL) { *pChannels = channels; } if (pSampleRate != NULL) { *pSampleRate = sampleRate; } /* Channel map was passed in directly to the callback. This is safe due to the channelMapCap parameter. */ return MA_SUCCESS; } MA_API ma_result ma_data_source_get_cursor_in_pcm_frames(ma_data_source* pDataSource, ma_uint64* pCursor) { ma_data_source_base* pDataSourceBase = (ma_data_source_base*)pDataSource; ma_result result; ma_uint64 cursor; if (pCursor == NULL) { return MA_INVALID_ARGS; } *pCursor = 0; if (pDataSourceBase == NULL) { return MA_SUCCESS; } if (pDataSourceBase->vtable->onGetCursor == NULL) { return MA_NOT_IMPLEMENTED; } result = pDataSourceBase->vtable->onGetCursor(pDataSourceBase, &cursor); if (result != MA_SUCCESS) { return result; } /* The cursor needs to be made relative to the start of the range. */ if (cursor < pDataSourceBase->rangeBegInFrames) { /* Safety check so we don't return some huge number. */ *pCursor = 0; } else { *pCursor = cursor - pDataSourceBase->rangeBegInFrames; } return MA_SUCCESS; } MA_API ma_result ma_data_source_get_length_in_pcm_frames(ma_data_source* pDataSource, ma_uint64* pLength) { ma_data_source_base* pDataSourceBase = (ma_data_source_base*)pDataSource; if (pLength == NULL) { return MA_INVALID_ARGS; } *pLength = 0; if (pDataSourceBase == NULL) { return MA_INVALID_ARGS; } /* If we have a range defined we'll use that to determine the length. This is one of rare times where we'll actually trust the caller. If they've set the range, I think it's mostly safe to assume they've set it based on some higher level knowledge of the structure of the sound bank. */ if (pDataSourceBase->rangeEndInFrames != ~((ma_uint64)0)) { *pLength = pDataSourceBase->rangeEndInFrames - pDataSourceBase->rangeBegInFrames; return MA_SUCCESS; } /* Getting here means a range is not defined so we'll need to get the data source itself to tell us the length. */ if (pDataSourceBase->vtable->onGetLength == NULL) { return MA_NOT_IMPLEMENTED; } return pDataSourceBase->vtable->onGetLength(pDataSource, pLength); } MA_API ma_result ma_data_source_get_cursor_in_seconds(ma_data_source* pDataSource, float* pCursor) { ma_result result; ma_uint64 cursorInPCMFrames; ma_uint32 sampleRate; if (pCursor == NULL) { return MA_INVALID_ARGS; } *pCursor = 0; result = ma_data_source_get_cursor_in_pcm_frames(pDataSource, &cursorInPCMFrames); if (result != MA_SUCCESS) { return result; } result = ma_data_source_get_data_format(pDataSource, NULL, NULL, &sampleRate, NULL, 0); if (result != MA_SUCCESS) { return result; } /* VC6 does not support division of unsigned 64-bit integers with floating point numbers. Need to use a signed number. This shouldn't effect anything in practice. */ *pCursor = (ma_int64)cursorInPCMFrames / (float)sampleRate; return MA_SUCCESS; } MA_API ma_result ma_data_source_get_length_in_seconds(ma_data_source* pDataSource, float* pLength) { ma_result result; ma_uint64 lengthInPCMFrames; ma_uint32 sampleRate; if (pLength == NULL) { return MA_INVALID_ARGS; } *pLength = 0; result = ma_data_source_get_length_in_pcm_frames(pDataSource, &lengthInPCMFrames); if (result != MA_SUCCESS) { return result; } result = ma_data_source_get_data_format(pDataSource, NULL, NULL, &sampleRate, NULL, 0); if (result != MA_SUCCESS) { return result; } /* VC6 does not support division of unsigned 64-bit integers with floating point numbers. Need to use a signed number. This shouldn't effect anything in practice. */ *pLength = (ma_int64)lengthInPCMFrames / (float)sampleRate; return MA_SUCCESS; } MA_API ma_result ma_data_source_set_looping(ma_data_source* pDataSource, ma_bool32 isLooping) { ma_data_source_base* pDataSourceBase = (ma_data_source_base*)pDataSource; if (pDataSource == NULL) { return MA_INVALID_ARGS; } ma_atomic_exchange_32(&pDataSourceBase->isLooping, isLooping); /* If there's no callback for this just treat it as a successful no-op. */ if (pDataSourceBase->vtable->onSetLooping == NULL) { return MA_SUCCESS; } return pDataSourceBase->vtable->onSetLooping(pDataSource, isLooping); } MA_API ma_bool32 ma_data_source_is_looping(const ma_data_source* pDataSource) { const ma_data_source_base* pDataSourceBase = (const ma_data_source_base*)pDataSource; if (pDataSource == NULL) { return MA_FALSE; } return ma_atomic_load_32(&pDataSourceBase->isLooping); } MA_API ma_result ma_data_source_set_range_in_pcm_frames(ma_data_source* pDataSource, ma_uint64 rangeBegInFrames, ma_uint64 rangeEndInFrames) { ma_data_source_base* pDataSourceBase = (ma_data_source_base*)pDataSource; ma_result result; ma_uint64 relativeCursor; ma_uint64 absoluteCursor; ma_bool32 doSeekAdjustment = MA_FALSE; if (pDataSource == NULL) { return MA_INVALID_ARGS; } if (rangeEndInFrames < rangeBegInFrames) { return MA_INVALID_ARGS; /* The end of the range must come after the beginning. */ } /* We may need to adjust the position of the cursor to ensure it's clamped to the range. Grab it now so we can calculate it's absolute position before we change the range. */ result = ma_data_source_get_cursor_in_pcm_frames(pDataSource, &relativeCursor); if (result == MA_SUCCESS) { doSeekAdjustment = MA_TRUE; absoluteCursor = relativeCursor + pDataSourceBase->rangeBegInFrames; } else { /* We couldn't get the position of the cursor. It probably means the data source has no notion of a cursor. We'll just leave it at position 0. Don't treat this as an error. */ doSeekAdjustment = MA_FALSE; relativeCursor = 0; absoluteCursor = 0; } pDataSourceBase->rangeBegInFrames = rangeBegInFrames; pDataSourceBase->rangeEndInFrames = rangeEndInFrames; /* The commented out logic below was intended to maintain loop points in response to a change in the range. However, this is not useful because it results in the sound breaking when you move the range outside of the old loop points. I'm simplifying this by simply resetting the loop points. The caller is expected to update their loop points if they change the range. In practice this should be mostly a non-issue because the majority of the time the range will be set once right after initialization. */ pDataSourceBase->loopBegInFrames = 0; pDataSourceBase->loopEndInFrames = ~((ma_uint64)0); /* Seek to within range. Note that our seek positions here are relative to the new range. We don't want do do this if we failed to retrieve the cursor earlier on because it probably means the data source has no notion of a cursor. In practice the seek would probably fail (which we silently ignore), but I'm just not even going to attempt it. */ if (doSeekAdjustment) { if (absoluteCursor < rangeBegInFrames) { ma_data_source_seek_to_pcm_frame(pDataSource, 0); } else if (absoluteCursor > rangeEndInFrames) { ma_data_source_seek_to_pcm_frame(pDataSource, rangeEndInFrames - rangeBegInFrames); } } return MA_SUCCESS; } MA_API void ma_data_source_get_range_in_pcm_frames(const ma_data_source* pDataSource, ma_uint64* pRangeBegInFrames, ma_uint64* pRangeEndInFrames) { const ma_data_source_base* pDataSourceBase = (const ma_data_source_base*)pDataSource; if (pDataSource == NULL) { return; } if (pRangeBegInFrames != NULL) { *pRangeBegInFrames = pDataSourceBase->rangeBegInFrames; } if (pRangeEndInFrames != NULL) { *pRangeEndInFrames = pDataSourceBase->rangeEndInFrames; } } MA_API ma_result ma_data_source_set_loop_point_in_pcm_frames(ma_data_source* pDataSource, ma_uint64 loopBegInFrames, ma_uint64 loopEndInFrames) { ma_data_source_base* pDataSourceBase = (ma_data_source_base*)pDataSource; if (pDataSource == NULL) { return MA_INVALID_ARGS; } if (loopEndInFrames < loopBegInFrames) { return MA_INVALID_ARGS; /* The end of the loop point must come after the beginning. */ } if (loopEndInFrames > pDataSourceBase->rangeEndInFrames && loopEndInFrames != ~((ma_uint64)0)) { return MA_INVALID_ARGS; /* The end of the loop point must not go beyond the range. */ } pDataSourceBase->loopBegInFrames = loopBegInFrames; pDataSourceBase->loopEndInFrames = loopEndInFrames; /* The end cannot exceed the range. */ if (pDataSourceBase->loopEndInFrames > (pDataSourceBase->rangeEndInFrames - pDataSourceBase->rangeBegInFrames) && pDataSourceBase->loopEndInFrames != ~((ma_uint64)0)) { pDataSourceBase->loopEndInFrames = (pDataSourceBase->rangeEndInFrames - pDataSourceBase->rangeBegInFrames); } return MA_SUCCESS; } MA_API void ma_data_source_get_loop_point_in_pcm_frames(const ma_data_source* pDataSource, ma_uint64* pLoopBegInFrames, ma_uint64* pLoopEndInFrames) { const ma_data_source_base* pDataSourceBase = (const ma_data_source_base*)pDataSource; if (pDataSource == NULL) { return; } if (pLoopBegInFrames != NULL) { *pLoopBegInFrames = pDataSourceBase->loopBegInFrames; } if (pLoopEndInFrames != NULL) { *pLoopEndInFrames = pDataSourceBase->loopEndInFrames; } } MA_API ma_result ma_data_source_set_current(ma_data_source* pDataSource, ma_data_source* pCurrentDataSource) { ma_data_source_base* pDataSourceBase = (ma_data_source_base*)pDataSource; if (pDataSource == NULL) { return MA_INVALID_ARGS; } pDataSourceBase->pCurrent = pCurrentDataSource; return MA_SUCCESS; } MA_API ma_data_source* ma_data_source_get_current(const ma_data_source* pDataSource) { const ma_data_source_base* pDataSourceBase = (const ma_data_source_base*)pDataSource; if (pDataSource == NULL) { return NULL; } return pDataSourceBase->pCurrent; } MA_API ma_result ma_data_source_set_next(ma_data_source* pDataSource, ma_data_source* pNextDataSource) { ma_data_source_base* pDataSourceBase = (ma_data_source_base*)pDataSource; if (pDataSource == NULL) { return MA_INVALID_ARGS; } pDataSourceBase->pNext = pNextDataSource; return MA_SUCCESS; } MA_API ma_data_source* ma_data_source_get_next(const ma_data_source* pDataSource) { const ma_data_source_base* pDataSourceBase = (const ma_data_source_base*)pDataSource; if (pDataSource == NULL) { return NULL; } return pDataSourceBase->pNext; } MA_API ma_result ma_data_source_set_next_callback(ma_data_source* pDataSource, ma_data_source_get_next_proc onGetNext) { ma_data_source_base* pDataSourceBase = (ma_data_source_base*)pDataSource; if (pDataSource == NULL) { return MA_INVALID_ARGS; } pDataSourceBase->onGetNext = onGetNext; return MA_SUCCESS; } MA_API ma_data_source_get_next_proc ma_data_source_get_next_callback(const ma_data_source* pDataSource) { const ma_data_source_base* pDataSourceBase = (const ma_data_source_base*)pDataSource; if (pDataSource == NULL) { return NULL; } return pDataSourceBase->onGetNext; } static ma_result ma_audio_buffer_ref__data_source_on_read(ma_data_source* pDataSource, void* pFramesOut, ma_uint64 frameCount, ma_uint64* pFramesRead) { ma_audio_buffer_ref* pAudioBufferRef = (ma_audio_buffer_ref*)pDataSource; ma_uint64 framesRead = ma_audio_buffer_ref_read_pcm_frames(pAudioBufferRef, pFramesOut, frameCount, MA_FALSE); if (pFramesRead != NULL) { *pFramesRead = framesRead; } if (framesRead < frameCount || framesRead == 0) { return MA_AT_END; } return MA_SUCCESS; } static ma_result ma_audio_buffer_ref__data_source_on_seek(ma_data_source* pDataSource, ma_uint64 frameIndex) { return ma_audio_buffer_ref_seek_to_pcm_frame((ma_audio_buffer_ref*)pDataSource, frameIndex); } static ma_result ma_audio_buffer_ref__data_source_on_get_data_format(ma_data_source* pDataSource, ma_format* pFormat, ma_uint32* pChannels, ma_uint32* pSampleRate, ma_channel* pChannelMap, size_t channelMapCap) { ma_audio_buffer_ref* pAudioBufferRef = (ma_audio_buffer_ref*)pDataSource; *pFormat = pAudioBufferRef->format; *pChannels = pAudioBufferRef->channels; *pSampleRate = pAudioBufferRef->sampleRate; ma_channel_map_init_standard(ma_standard_channel_map_default, pChannelMap, channelMapCap, pAudioBufferRef->channels); return MA_SUCCESS; } static ma_result ma_audio_buffer_ref__data_source_on_get_cursor(ma_data_source* pDataSource, ma_uint64* pCursor) { ma_audio_buffer_ref* pAudioBufferRef = (ma_audio_buffer_ref*)pDataSource; *pCursor = pAudioBufferRef->cursor; return MA_SUCCESS; } static ma_result ma_audio_buffer_ref__data_source_on_get_length(ma_data_source* pDataSource, ma_uint64* pLength) { ma_audio_buffer_ref* pAudioBufferRef = (ma_audio_buffer_ref*)pDataSource; *pLength = pAudioBufferRef->sizeInFrames; return MA_SUCCESS; } static ma_data_source_vtable g_ma_audio_buffer_ref_data_source_vtable = { ma_audio_buffer_ref__data_source_on_read, ma_audio_buffer_ref__data_source_on_seek, ma_audio_buffer_ref__data_source_on_get_data_format, ma_audio_buffer_ref__data_source_on_get_cursor, ma_audio_buffer_ref__data_source_on_get_length, NULL, /* onSetLooping */ 0 }; MA_API ma_result ma_audio_buffer_ref_init(ma_format format, ma_uint32 channels, const void* pData, ma_uint64 sizeInFrames, ma_audio_buffer_ref* pAudioBufferRef) { ma_result result; ma_data_source_config dataSourceConfig; if (pAudioBufferRef == NULL) { return MA_INVALID_ARGS; } MA_ZERO_OBJECT(pAudioBufferRef); dataSourceConfig = ma_data_source_config_init(); dataSourceConfig.vtable = &g_ma_audio_buffer_ref_data_source_vtable; result = ma_data_source_init(&dataSourceConfig, &pAudioBufferRef->ds); if (result != MA_SUCCESS) { return result; } pAudioBufferRef->format = format; pAudioBufferRef->channels = channels; pAudioBufferRef->sampleRate = 0; /* TODO: Version 0.12. Set this to sampleRate. */ pAudioBufferRef->cursor = 0; pAudioBufferRef->sizeInFrames = sizeInFrames; pAudioBufferRef->pData = pData; return MA_SUCCESS; } MA_API void ma_audio_buffer_ref_uninit(ma_audio_buffer_ref* pAudioBufferRef) { if (pAudioBufferRef == NULL) { return; } ma_data_source_uninit(&pAudioBufferRef->ds); } MA_API ma_result ma_audio_buffer_ref_set_data(ma_audio_buffer_ref* pAudioBufferRef, const void* pData, ma_uint64 sizeInFrames) { if (pAudioBufferRef == NULL) { return MA_INVALID_ARGS; } pAudioBufferRef->cursor = 0; pAudioBufferRef->sizeInFrames = sizeInFrames; pAudioBufferRef->pData = pData; return MA_SUCCESS; } MA_API ma_uint64 ma_audio_buffer_ref_read_pcm_frames(ma_audio_buffer_ref* pAudioBufferRef, void* pFramesOut, ma_uint64 frameCount, ma_bool32 loop) { ma_uint64 totalFramesRead = 0; if (pAudioBufferRef == NULL) { return 0; } if (frameCount == 0) { return 0; } while (totalFramesRead < frameCount) { ma_uint64 framesAvailable = pAudioBufferRef->sizeInFrames - pAudioBufferRef->cursor; ma_uint64 framesRemaining = frameCount - totalFramesRead; ma_uint64 framesToRead; framesToRead = framesRemaining; if (framesToRead > framesAvailable) { framesToRead = framesAvailable; } if (pFramesOut != NULL) { ma_copy_pcm_frames(ma_offset_ptr(pFramesOut, totalFramesRead * ma_get_bytes_per_frame(pAudioBufferRef->format, pAudioBufferRef->channels)), ma_offset_ptr(pAudioBufferRef->pData, pAudioBufferRef->cursor * ma_get_bytes_per_frame(pAudioBufferRef->format, pAudioBufferRef->channels)), framesToRead, pAudioBufferRef->format, pAudioBufferRef->channels); } totalFramesRead += framesToRead; pAudioBufferRef->cursor += framesToRead; if (pAudioBufferRef->cursor == pAudioBufferRef->sizeInFrames) { if (loop) { pAudioBufferRef->cursor = 0; } else { break; /* We've reached the end and we're not looping. Done. */ } } MA_ASSERT(pAudioBufferRef->cursor < pAudioBufferRef->sizeInFrames); } return totalFramesRead; } MA_API ma_result ma_audio_buffer_ref_seek_to_pcm_frame(ma_audio_buffer_ref* pAudioBufferRef, ma_uint64 frameIndex) { if (pAudioBufferRef == NULL) { return MA_INVALID_ARGS; } if (frameIndex > pAudioBufferRef->sizeInFrames) { return MA_INVALID_ARGS; } pAudioBufferRef->cursor = (size_t)frameIndex; return MA_SUCCESS; } MA_API ma_result ma_audio_buffer_ref_map(ma_audio_buffer_ref* pAudioBufferRef, void** ppFramesOut, ma_uint64* pFrameCount) { ma_uint64 framesAvailable; ma_uint64 frameCount = 0; if (ppFramesOut != NULL) { *ppFramesOut = NULL; /* Safety. */ } if (pFrameCount != NULL) { frameCount = *pFrameCount; *pFrameCount = 0; /* Safety. */ } if (pAudioBufferRef == NULL || ppFramesOut == NULL || pFrameCount == NULL) { return MA_INVALID_ARGS; } framesAvailable = pAudioBufferRef->sizeInFrames - pAudioBufferRef->cursor; if (frameCount > framesAvailable) { frameCount = framesAvailable; } *ppFramesOut = ma_offset_ptr(pAudioBufferRef->pData, pAudioBufferRef->cursor * ma_get_bytes_per_frame(pAudioBufferRef->format, pAudioBufferRef->channels)); *pFrameCount = frameCount; return MA_SUCCESS; } MA_API ma_result ma_audio_buffer_ref_unmap(ma_audio_buffer_ref* pAudioBufferRef, ma_uint64 frameCount) { ma_uint64 framesAvailable; if (pAudioBufferRef == NULL) { return MA_INVALID_ARGS; } framesAvailable = pAudioBufferRef->sizeInFrames - pAudioBufferRef->cursor; if (frameCount > framesAvailable) { return MA_INVALID_ARGS; /* The frame count was too big. This should never happen in an unmapping. Need to make sure the caller is aware of this. */ } pAudioBufferRef->cursor += frameCount; if (pAudioBufferRef->cursor == pAudioBufferRef->sizeInFrames) { return MA_AT_END; /* Successful. Need to tell the caller that the end has been reached so that it can loop if desired. */ } else { return MA_SUCCESS; } } MA_API ma_bool32 ma_audio_buffer_ref_at_end(const ma_audio_buffer_ref* pAudioBufferRef) { if (pAudioBufferRef == NULL) { return MA_FALSE; } return pAudioBufferRef->cursor == pAudioBufferRef->sizeInFrames; } MA_API ma_result ma_audio_buffer_ref_get_cursor_in_pcm_frames(const ma_audio_buffer_ref* pAudioBufferRef, ma_uint64* pCursor) { if (pCursor == NULL) { return MA_INVALID_ARGS; } *pCursor = 0; if (pAudioBufferRef == NULL) { return MA_INVALID_ARGS; } *pCursor = pAudioBufferRef->cursor; return MA_SUCCESS; } MA_API ma_result ma_audio_buffer_ref_get_length_in_pcm_frames(const ma_audio_buffer_ref* pAudioBufferRef, ma_uint64* pLength) { if (pLength == NULL) { return MA_INVALID_ARGS; } *pLength = 0; if (pAudioBufferRef == NULL) { return MA_INVALID_ARGS; } *pLength = pAudioBufferRef->sizeInFrames; return MA_SUCCESS; } MA_API ma_result ma_audio_buffer_ref_get_available_frames(const ma_audio_buffer_ref* pAudioBufferRef, ma_uint64* pAvailableFrames) { if (pAvailableFrames == NULL) { return MA_INVALID_ARGS; } *pAvailableFrames = 0; if (pAudioBufferRef == NULL) { return MA_INVALID_ARGS; } if (pAudioBufferRef->sizeInFrames <= pAudioBufferRef->cursor) { *pAvailableFrames = 0; } else { *pAvailableFrames = pAudioBufferRef->sizeInFrames - pAudioBufferRef->cursor; } return MA_SUCCESS; } MA_API ma_audio_buffer_config ma_audio_buffer_config_init(ma_format format, ma_uint32 channels, ma_uint64 sizeInFrames, const void* pData, const ma_allocation_callbacks* pAllocationCallbacks) { ma_audio_buffer_config config; MA_ZERO_OBJECT(&config); config.format = format; config.channels = channels; config.sampleRate = 0; /* TODO: Version 0.12. Set this to sampleRate. */ config.sizeInFrames = sizeInFrames; config.pData = pData; ma_allocation_callbacks_init_copy(&config.allocationCallbacks, pAllocationCallbacks); return config; } static ma_result ma_audio_buffer_init_ex(const ma_audio_buffer_config* pConfig, ma_bool32 doCopy, ma_audio_buffer* pAudioBuffer) { ma_result result; if (pAudioBuffer == NULL) { return MA_INVALID_ARGS; } MA_ZERO_MEMORY(pAudioBuffer, sizeof(*pAudioBuffer) - sizeof(pAudioBuffer->_pExtraData)); /* Safety. Don't overwrite the extra data. */ if (pConfig == NULL) { return MA_INVALID_ARGS; } if (pConfig->sizeInFrames == 0) { return MA_INVALID_ARGS; /* Not allowing buffer sizes of 0 frames. */ } result = ma_audio_buffer_ref_init(pConfig->format, pConfig->channels, NULL, 0, &pAudioBuffer->ref); if (result != MA_SUCCESS) { return result; } /* TODO: Version 0.12. Set this in ma_audio_buffer_ref_init() instead of here. */ pAudioBuffer->ref.sampleRate = pConfig->sampleRate; ma_allocation_callbacks_init_copy(&pAudioBuffer->allocationCallbacks, &pConfig->allocationCallbacks); if (doCopy) { ma_uint64 allocationSizeInBytes; void* pData; allocationSizeInBytes = pConfig->sizeInFrames * ma_get_bytes_per_frame(pConfig->format, pConfig->channels); if (allocationSizeInBytes > MA_SIZE_MAX) { return MA_OUT_OF_MEMORY; /* Too big. */ } pData = ma_malloc((size_t)allocationSizeInBytes, &pAudioBuffer->allocationCallbacks); /* Safe cast to size_t. */ if (pData == NULL) { return MA_OUT_OF_MEMORY; } if (pConfig->pData != NULL) { ma_copy_pcm_frames(pData, pConfig->pData, pConfig->sizeInFrames, pConfig->format, pConfig->channels); } else { ma_silence_pcm_frames(pData, pConfig->sizeInFrames, pConfig->format, pConfig->channels); } ma_audio_buffer_ref_set_data(&pAudioBuffer->ref, pData, pConfig->sizeInFrames); pAudioBuffer->ownsData = MA_TRUE; } else { ma_audio_buffer_ref_set_data(&pAudioBuffer->ref, pConfig->pData, pConfig->sizeInFrames); pAudioBuffer->ownsData = MA_FALSE; } return MA_SUCCESS; } static void ma_audio_buffer_uninit_ex(ma_audio_buffer* pAudioBuffer, ma_bool32 doFree) { if (pAudioBuffer == NULL) { return; } if (pAudioBuffer->ownsData && pAudioBuffer->ref.pData != &pAudioBuffer->_pExtraData[0]) { ma_free((void*)pAudioBuffer->ref.pData, &pAudioBuffer->allocationCallbacks); /* Naugty const cast, but OK in this case since we've guarded it with the ownsData check. */ } if (doFree) { ma_free(pAudioBuffer, &pAudioBuffer->allocationCallbacks); } ma_audio_buffer_ref_uninit(&pAudioBuffer->ref); } MA_API ma_result ma_audio_buffer_init(const ma_audio_buffer_config* pConfig, ma_audio_buffer* pAudioBuffer) { return ma_audio_buffer_init_ex(pConfig, MA_FALSE, pAudioBuffer); } MA_API ma_result ma_audio_buffer_init_copy(const ma_audio_buffer_config* pConfig, ma_audio_buffer* pAudioBuffer) { return ma_audio_buffer_init_ex(pConfig, MA_TRUE, pAudioBuffer); } MA_API ma_result ma_audio_buffer_alloc_and_init(const ma_audio_buffer_config* pConfig, ma_audio_buffer** ppAudioBuffer) { ma_result result; ma_audio_buffer* pAudioBuffer; ma_audio_buffer_config innerConfig; /* We'll be making some changes to the config, so need to make a copy. */ ma_uint64 allocationSizeInBytes; if (ppAudioBuffer == NULL) { return MA_INVALID_ARGS; } *ppAudioBuffer = NULL; /* Safety. */ if (pConfig == NULL) { return MA_INVALID_ARGS; } innerConfig = *pConfig; ma_allocation_callbacks_init_copy(&innerConfig.allocationCallbacks, &pConfig->allocationCallbacks); allocationSizeInBytes = sizeof(*pAudioBuffer) - sizeof(pAudioBuffer->_pExtraData) + (pConfig->sizeInFrames * ma_get_bytes_per_frame(pConfig->format, pConfig->channels)); if (allocationSizeInBytes > MA_SIZE_MAX) { return MA_OUT_OF_MEMORY; /* Too big. */ } pAudioBuffer = (ma_audio_buffer*)ma_malloc((size_t)allocationSizeInBytes, &innerConfig.allocationCallbacks); /* Safe cast to size_t. */ if (pAudioBuffer == NULL) { return MA_OUT_OF_MEMORY; } if (pConfig->pData != NULL) { ma_copy_pcm_frames(&pAudioBuffer->_pExtraData[0], pConfig->pData, pConfig->sizeInFrames, pConfig->format, pConfig->channels); } else { ma_silence_pcm_frames(&pAudioBuffer->_pExtraData[0], pConfig->sizeInFrames, pConfig->format, pConfig->channels); } innerConfig.pData = &pAudioBuffer->_pExtraData[0]; result = ma_audio_buffer_init_ex(&innerConfig, MA_FALSE, pAudioBuffer); if (result != MA_SUCCESS) { ma_free(pAudioBuffer, &innerConfig.allocationCallbacks); return result; } *ppAudioBuffer = pAudioBuffer; return MA_SUCCESS; } MA_API void ma_audio_buffer_uninit(ma_audio_buffer* pAudioBuffer) { ma_audio_buffer_uninit_ex(pAudioBuffer, MA_FALSE); } MA_API void ma_audio_buffer_uninit_and_free(ma_audio_buffer* pAudioBuffer) { ma_audio_buffer_uninit_ex(pAudioBuffer, MA_TRUE); } MA_API ma_uint64 ma_audio_buffer_read_pcm_frames(ma_audio_buffer* pAudioBuffer, void* pFramesOut, ma_uint64 frameCount, ma_bool32 loop) { if (pAudioBuffer == NULL) { return 0; } return ma_audio_buffer_ref_read_pcm_frames(&pAudioBuffer->ref, pFramesOut, frameCount, loop); } MA_API ma_result ma_audio_buffer_seek_to_pcm_frame(ma_audio_buffer* pAudioBuffer, ma_uint64 frameIndex) { if (pAudioBuffer == NULL) { return MA_INVALID_ARGS; } return ma_audio_buffer_ref_seek_to_pcm_frame(&pAudioBuffer->ref, frameIndex); } MA_API ma_result ma_audio_buffer_map(ma_audio_buffer* pAudioBuffer, void** ppFramesOut, ma_uint64* pFrameCount) { if (ppFramesOut != NULL) { *ppFramesOut = NULL; /* Safety. */ } if (pAudioBuffer == NULL) { if (pFrameCount != NULL) { *pFrameCount = 0; } return MA_INVALID_ARGS; } return ma_audio_buffer_ref_map(&pAudioBuffer->ref, ppFramesOut, pFrameCount); } MA_API ma_result ma_audio_buffer_unmap(ma_audio_buffer* pAudioBuffer, ma_uint64 frameCount) { if (pAudioBuffer == NULL) { return MA_INVALID_ARGS; } return ma_audio_buffer_ref_unmap(&pAudioBuffer->ref, frameCount); } MA_API ma_bool32 ma_audio_buffer_at_end(const ma_audio_buffer* pAudioBuffer) { if (pAudioBuffer == NULL) { return MA_FALSE; } return ma_audio_buffer_ref_at_end(&pAudioBuffer->ref); } MA_API ma_result ma_audio_buffer_get_cursor_in_pcm_frames(const ma_audio_buffer* pAudioBuffer, ma_uint64* pCursor) { if (pAudioBuffer == NULL) { return MA_INVALID_ARGS; } return ma_audio_buffer_ref_get_cursor_in_pcm_frames(&pAudioBuffer->ref, pCursor); } MA_API ma_result ma_audio_buffer_get_length_in_pcm_frames(const ma_audio_buffer* pAudioBuffer, ma_uint64* pLength) { if (pAudioBuffer == NULL) { return MA_INVALID_ARGS; } return ma_audio_buffer_ref_get_length_in_pcm_frames(&pAudioBuffer->ref, pLength); } MA_API ma_result ma_audio_buffer_get_available_frames(const ma_audio_buffer* pAudioBuffer, ma_uint64* pAvailableFrames) { if (pAvailableFrames == NULL) { return MA_INVALID_ARGS; } *pAvailableFrames = 0; if (pAudioBuffer == NULL) { return MA_INVALID_ARGS; } return ma_audio_buffer_ref_get_available_frames(&pAudioBuffer->ref, pAvailableFrames); } MA_API ma_result ma_paged_audio_buffer_data_init(ma_format format, ma_uint32 channels, ma_paged_audio_buffer_data* pData) { if (pData == NULL) { return MA_INVALID_ARGS; } MA_ZERO_OBJECT(pData); pData->format = format; pData->channels = channels; pData->pTail = &pData->head; return MA_SUCCESS; } MA_API void ma_paged_audio_buffer_data_uninit(ma_paged_audio_buffer_data* pData, const ma_allocation_callbacks* pAllocationCallbacks) { ma_paged_audio_buffer_page* pPage; if (pData == NULL) { return; } /* All pages need to be freed. */ pPage = (ma_paged_audio_buffer_page*)ma_atomic_load_ptr(&pData->head.pNext); while (pPage != NULL) { ma_paged_audio_buffer_page* pNext = (ma_paged_audio_buffer_page*)ma_atomic_load_ptr(&pPage->pNext); ma_free(pPage, pAllocationCallbacks); pPage = pNext; } } MA_API ma_paged_audio_buffer_page* ma_paged_audio_buffer_data_get_head(ma_paged_audio_buffer_data* pData) { if (pData == NULL) { return NULL; } return &pData->head; } MA_API ma_paged_audio_buffer_page* ma_paged_audio_buffer_data_get_tail(ma_paged_audio_buffer_data* pData) { if (pData == NULL) { return NULL; } return pData->pTail; } MA_API ma_result ma_paged_audio_buffer_data_get_length_in_pcm_frames(ma_paged_audio_buffer_data* pData, ma_uint64* pLength) { ma_paged_audio_buffer_page* pPage; if (pLength == NULL) { return MA_INVALID_ARGS; } *pLength = 0; if (pData == NULL) { return MA_INVALID_ARGS; } /* Calculate the length from the linked list. */ for (pPage = (ma_paged_audio_buffer_page*)ma_atomic_load_ptr(&pData->head.pNext); pPage != NULL; pPage = (ma_paged_audio_buffer_page*)ma_atomic_load_ptr(&pPage->pNext)) { *pLength += pPage->sizeInFrames; } return MA_SUCCESS; } MA_API ma_result ma_paged_audio_buffer_data_allocate_page(ma_paged_audio_buffer_data* pData, ma_uint64 pageSizeInFrames, const void* pInitialData, const ma_allocation_callbacks* pAllocationCallbacks, ma_paged_audio_buffer_page** ppPage) { ma_paged_audio_buffer_page* pPage; ma_uint64 allocationSize; if (ppPage == NULL) { return MA_INVALID_ARGS; } *ppPage = NULL; if (pData == NULL) { return MA_INVALID_ARGS; } allocationSize = sizeof(*pPage) + (pageSizeInFrames * ma_get_bytes_per_frame(pData->format, pData->channels)); if (allocationSize > MA_SIZE_MAX) { return MA_OUT_OF_MEMORY; /* Too big. */ } pPage = (ma_paged_audio_buffer_page*)ma_malloc((size_t)allocationSize, pAllocationCallbacks); /* Safe cast to size_t. */ if (pPage == NULL) { return MA_OUT_OF_MEMORY; } pPage->pNext = NULL; pPage->sizeInFrames = pageSizeInFrames; if (pInitialData != NULL) { ma_copy_pcm_frames(pPage->pAudioData, pInitialData, pageSizeInFrames, pData->format, pData->channels); } *ppPage = pPage; return MA_SUCCESS; } MA_API ma_result ma_paged_audio_buffer_data_free_page(ma_paged_audio_buffer_data* pData, ma_paged_audio_buffer_page* pPage, const ma_allocation_callbacks* pAllocationCallbacks) { if (pData == NULL || pPage == NULL) { return MA_INVALID_ARGS; } /* It's assumed the page is not attached to the list. */ ma_free(pPage, pAllocationCallbacks); return MA_SUCCESS; } MA_API ma_result ma_paged_audio_buffer_data_append_page(ma_paged_audio_buffer_data* pData, ma_paged_audio_buffer_page* pPage) { if (pData == NULL || pPage == NULL) { return MA_INVALID_ARGS; } /* This function assumes the page has been filled with audio data by this point. As soon as we append, the page will be available for reading. */ /* First thing to do is update the tail. */ for (;;) { ma_paged_audio_buffer_page* pOldTail = (ma_paged_audio_buffer_page*)ma_atomic_load_ptr(&pData->pTail); ma_paged_audio_buffer_page* pNewTail = pPage; if (ma_atomic_compare_exchange_weak_ptr((volatile void**)&pData->pTail, (void**)&pOldTail, pNewTail)) { /* Here is where we append the page to the list. After this, the page is attached to the list and ready to be read from. */ ma_atomic_exchange_ptr(&pOldTail->pNext, pPage); break; /* Done. */ } } return MA_SUCCESS; } MA_API ma_result ma_paged_audio_buffer_data_allocate_and_append_page(ma_paged_audio_buffer_data* pData, ma_uint32 pageSizeInFrames, const void* pInitialData, const ma_allocation_callbacks* pAllocationCallbacks) { ma_result result; ma_paged_audio_buffer_page* pPage; result = ma_paged_audio_buffer_data_allocate_page(pData, pageSizeInFrames, pInitialData, pAllocationCallbacks, &pPage); if (result != MA_SUCCESS) { return result; } return ma_paged_audio_buffer_data_append_page(pData, pPage); /* <-- Should never fail. */ } MA_API ma_paged_audio_buffer_config ma_paged_audio_buffer_config_init(ma_paged_audio_buffer_data* pData) { ma_paged_audio_buffer_config config; MA_ZERO_OBJECT(&config); config.pData = pData; return config; } static ma_result ma_paged_audio_buffer__data_source_on_read(ma_data_source* pDataSource, void* pFramesOut, ma_uint64 frameCount, ma_uint64* pFramesRead) { return ma_paged_audio_buffer_read_pcm_frames((ma_paged_audio_buffer*)pDataSource, pFramesOut, frameCount, pFramesRead); } static ma_result ma_paged_audio_buffer__data_source_on_seek(ma_data_source* pDataSource, ma_uint64 frameIndex) { return ma_paged_audio_buffer_seek_to_pcm_frame((ma_paged_audio_buffer*)pDataSource, frameIndex); } static ma_result ma_paged_audio_buffer__data_source_on_get_data_format(ma_data_source* pDataSource, ma_format* pFormat, ma_uint32* pChannels, ma_uint32* pSampleRate, ma_channel* pChannelMap, size_t channelMapCap) { ma_paged_audio_buffer* pPagedAudioBuffer = (ma_paged_audio_buffer*)pDataSource; *pFormat = pPagedAudioBuffer->pData->format; *pChannels = pPagedAudioBuffer->pData->channels; *pSampleRate = 0; /* There is no notion of a sample rate with audio buffers. */ ma_channel_map_init_standard(ma_standard_channel_map_default, pChannelMap, channelMapCap, pPagedAudioBuffer->pData->channels); return MA_SUCCESS; } static ma_result ma_paged_audio_buffer__data_source_on_get_cursor(ma_data_source* pDataSource, ma_uint64* pCursor) { return ma_paged_audio_buffer_get_cursor_in_pcm_frames((ma_paged_audio_buffer*)pDataSource, pCursor); } static ma_result ma_paged_audio_buffer__data_source_on_get_length(ma_data_source* pDataSource, ma_uint64* pLength) { return ma_paged_audio_buffer_get_length_in_pcm_frames((ma_paged_audio_buffer*)pDataSource, pLength); } static ma_data_source_vtable g_ma_paged_audio_buffer_data_source_vtable = { ma_paged_audio_buffer__data_source_on_read, ma_paged_audio_buffer__data_source_on_seek, ma_paged_audio_buffer__data_source_on_get_data_format, ma_paged_audio_buffer__data_source_on_get_cursor, ma_paged_audio_buffer__data_source_on_get_length, NULL, /* onSetLooping */ 0 }; MA_API ma_result ma_paged_audio_buffer_init(const ma_paged_audio_buffer_config* pConfig, ma_paged_audio_buffer* pPagedAudioBuffer) { ma_result result; ma_data_source_config dataSourceConfig; if (pPagedAudioBuffer == NULL) { return MA_INVALID_ARGS; } MA_ZERO_OBJECT(pPagedAudioBuffer); /* A config is required for the format and channel count. */ if (pConfig == NULL) { return MA_INVALID_ARGS; } if (pConfig->pData == NULL) { return MA_INVALID_ARGS; /* No underlying data specified. */ } dataSourceConfig = ma_data_source_config_init(); dataSourceConfig.vtable = &g_ma_paged_audio_buffer_data_source_vtable; result = ma_data_source_init(&dataSourceConfig, &pPagedAudioBuffer->ds); if (result != MA_SUCCESS) { return result; } pPagedAudioBuffer->pData = pConfig->pData; pPagedAudioBuffer->pCurrent = ma_paged_audio_buffer_data_get_head(pConfig->pData); pPagedAudioBuffer->relativeCursor = 0; pPagedAudioBuffer->absoluteCursor = 0; return MA_SUCCESS; } MA_API void ma_paged_audio_buffer_uninit(ma_paged_audio_buffer* pPagedAudioBuffer) { if (pPagedAudioBuffer == NULL) { return; } /* Nothing to do. The data needs to be deleted separately. */ } MA_API ma_result ma_paged_audio_buffer_read_pcm_frames(ma_paged_audio_buffer* pPagedAudioBuffer, void* pFramesOut, ma_uint64 frameCount, ma_uint64* pFramesRead) { ma_result result = MA_SUCCESS; ma_uint64 totalFramesRead = 0; ma_format format; ma_uint32 channels; if (pPagedAudioBuffer == NULL) { return MA_INVALID_ARGS; } format = pPagedAudioBuffer->pData->format; channels = pPagedAudioBuffer->pData->channels; while (totalFramesRead < frameCount) { /* Read from the current page. The buffer should never be in a state where this is NULL. */ ma_uint64 framesRemainingInCurrentPage; ma_uint64 framesRemainingToRead = frameCount - totalFramesRead; ma_uint64 framesToReadThisIteration; MA_ASSERT(pPagedAudioBuffer->pCurrent != NULL); framesRemainingInCurrentPage = pPagedAudioBuffer->pCurrent->sizeInFrames - pPagedAudioBuffer->relativeCursor; framesToReadThisIteration = ma_min(framesRemainingInCurrentPage, framesRemainingToRead); ma_copy_pcm_frames(ma_offset_pcm_frames_ptr(pFramesOut, totalFramesRead, format, channels), ma_offset_pcm_frames_ptr(pPagedAudioBuffer->pCurrent->pAudioData, pPagedAudioBuffer->relativeCursor, format, channels), framesToReadThisIteration, format, channels); totalFramesRead += framesToReadThisIteration; pPagedAudioBuffer->absoluteCursor += framesToReadThisIteration; pPagedAudioBuffer->relativeCursor += framesToReadThisIteration; /* Move to the next page if necessary. If there's no more pages, we need to return MA_AT_END. */ MA_ASSERT(pPagedAudioBuffer->relativeCursor <= pPagedAudioBuffer->pCurrent->sizeInFrames); if (pPagedAudioBuffer->relativeCursor == pPagedAudioBuffer->pCurrent->sizeInFrames) { /* We reached the end of the page. Need to move to the next. If there's no more pages, we're done. */ ma_paged_audio_buffer_page* pNext = (ma_paged_audio_buffer_page*)ma_atomic_load_ptr(&pPagedAudioBuffer->pCurrent->pNext); if (pNext == NULL) { result = MA_AT_END; break; /* We've reached the end. */ } else { pPagedAudioBuffer->pCurrent = pNext; pPagedAudioBuffer->relativeCursor = 0; } } } if (pFramesRead != NULL) { *pFramesRead = totalFramesRead; } return result; } MA_API ma_result ma_paged_audio_buffer_seek_to_pcm_frame(ma_paged_audio_buffer* pPagedAudioBuffer, ma_uint64 frameIndex) { if (pPagedAudioBuffer == NULL) { return MA_INVALID_ARGS; } if (frameIndex == pPagedAudioBuffer->absoluteCursor) { return MA_SUCCESS; /* Nothing to do. */ } if (frameIndex < pPagedAudioBuffer->absoluteCursor) { /* Moving backwards. Need to move the cursor back to the start, and then move forward. */ pPagedAudioBuffer->pCurrent = ma_paged_audio_buffer_data_get_head(pPagedAudioBuffer->pData); pPagedAudioBuffer->absoluteCursor = 0; pPagedAudioBuffer->relativeCursor = 0; /* Fall through to the forward seeking section below. */ } if (frameIndex > pPagedAudioBuffer->absoluteCursor) { /* Moving forward. */ ma_paged_audio_buffer_page* pPage; ma_uint64 runningCursor = 0; for (pPage = (ma_paged_audio_buffer_page*)ma_atomic_load_ptr(&ma_paged_audio_buffer_data_get_head(pPagedAudioBuffer->pData)->pNext); pPage != NULL; pPage = (ma_paged_audio_buffer_page*)ma_atomic_load_ptr(&pPage->pNext)) { ma_uint64 pageRangeBeg = runningCursor; ma_uint64 pageRangeEnd = pageRangeBeg + pPage->sizeInFrames; if (frameIndex >= pageRangeBeg) { if (frameIndex < pageRangeEnd || (frameIndex == pageRangeEnd && pPage == (ma_paged_audio_buffer_page*)ma_atomic_load_ptr(ma_paged_audio_buffer_data_get_tail(pPagedAudioBuffer->pData)))) { /* A small edge case - allow seeking to the very end of the buffer. */ /* We found the page. */ pPagedAudioBuffer->pCurrent = pPage; pPagedAudioBuffer->absoluteCursor = frameIndex; pPagedAudioBuffer->relativeCursor = frameIndex - pageRangeBeg; return MA_SUCCESS; } } runningCursor = pageRangeEnd; } /* Getting here means we tried seeking too far forward. Don't change any state. */ return MA_BAD_SEEK; } return MA_SUCCESS; } MA_API ma_result ma_paged_audio_buffer_get_cursor_in_pcm_frames(ma_paged_audio_buffer* pPagedAudioBuffer, ma_uint64* pCursor) { if (pCursor == NULL) { return MA_INVALID_ARGS; } *pCursor = 0; /* Safety. */ if (pPagedAudioBuffer == NULL) { return MA_INVALID_ARGS; } *pCursor = pPagedAudioBuffer->absoluteCursor; return MA_SUCCESS; } MA_API ma_result ma_paged_audio_buffer_get_length_in_pcm_frames(ma_paged_audio_buffer* pPagedAudioBuffer, ma_uint64* pLength) { return ma_paged_audio_buffer_data_get_length_in_pcm_frames(pPagedAudioBuffer->pData, pLength); } /************************************************************************************************************************************************************** VFS **************************************************************************************************************************************************************/ MA_API ma_result ma_vfs_open(ma_vfs* pVFS, const char* pFilePath, ma_uint32 openMode, ma_vfs_file* pFile) { ma_vfs_callbacks* pCallbacks = (ma_vfs_callbacks*)pVFS; if (pFile == NULL) { return MA_INVALID_ARGS; } *pFile = NULL; if (pVFS == NULL || pFilePath == NULL || openMode == 0) { return MA_INVALID_ARGS; } if (pCallbacks->onOpen == NULL) { return MA_NOT_IMPLEMENTED; } return pCallbacks->onOpen(pVFS, pFilePath, openMode, pFile); } MA_API ma_result ma_vfs_open_w(ma_vfs* pVFS, const wchar_t* pFilePath, ma_uint32 openMode, ma_vfs_file* pFile) { ma_vfs_callbacks* pCallbacks = (ma_vfs_callbacks*)pVFS; if (pFile == NULL) { return MA_INVALID_ARGS; } *pFile = NULL; if (pVFS == NULL || pFilePath == NULL || openMode == 0) { return MA_INVALID_ARGS; } if (pCallbacks->onOpenW == NULL) { return MA_NOT_IMPLEMENTED; } return pCallbacks->onOpenW(pVFS, pFilePath, openMode, pFile); } MA_API ma_result ma_vfs_close(ma_vfs* pVFS, ma_vfs_file file) { ma_vfs_callbacks* pCallbacks = (ma_vfs_callbacks*)pVFS; if (pVFS == NULL || file == NULL) { return MA_INVALID_ARGS; } if (pCallbacks->onClose == NULL) { return MA_NOT_IMPLEMENTED; } return pCallbacks->onClose(pVFS, file); } MA_API ma_result ma_vfs_read(ma_vfs* pVFS, ma_vfs_file file, void* pDst, size_t sizeInBytes, size_t* pBytesRead) { ma_vfs_callbacks* pCallbacks = (ma_vfs_callbacks*)pVFS; ma_result result; size_t bytesRead = 0; if (pBytesRead != NULL) { *pBytesRead = 0; } if (pVFS == NULL || file == NULL || pDst == NULL) { return MA_INVALID_ARGS; } if (pCallbacks->onRead == NULL) { return MA_NOT_IMPLEMENTED; } result = pCallbacks->onRead(pVFS, file, pDst, sizeInBytes, &bytesRead); if (pBytesRead != NULL) { *pBytesRead = bytesRead; } if (result == MA_SUCCESS && bytesRead == 0 && sizeInBytes > 0) { result = MA_AT_END; } return result; } MA_API ma_result ma_vfs_write(ma_vfs* pVFS, ma_vfs_file file, const void* pSrc, size_t sizeInBytes, size_t* pBytesWritten) { ma_vfs_callbacks* pCallbacks = (ma_vfs_callbacks*)pVFS; if (pBytesWritten != NULL) { *pBytesWritten = 0; } if (pVFS == NULL || file == NULL || pSrc == NULL) { return MA_INVALID_ARGS; } if (pCallbacks->onWrite == NULL) { return MA_NOT_IMPLEMENTED; } return pCallbacks->onWrite(pVFS, file, pSrc, sizeInBytes, pBytesWritten); } MA_API ma_result ma_vfs_seek(ma_vfs* pVFS, ma_vfs_file file, ma_int64 offset, ma_seek_origin origin) { ma_vfs_callbacks* pCallbacks = (ma_vfs_callbacks*)pVFS; if (pVFS == NULL || file == NULL) { return MA_INVALID_ARGS; } if (pCallbacks->onSeek == NULL) { return MA_NOT_IMPLEMENTED; } return pCallbacks->onSeek(pVFS, file, offset, origin); } MA_API ma_result ma_vfs_tell(ma_vfs* pVFS, ma_vfs_file file, ma_int64* pCursor) { ma_vfs_callbacks* pCallbacks = (ma_vfs_callbacks*)pVFS; if (pCursor == NULL) { return MA_INVALID_ARGS; } *pCursor = 0; if (pVFS == NULL || file == NULL) { return MA_INVALID_ARGS; } if (pCallbacks->onTell == NULL) { return MA_NOT_IMPLEMENTED; } return pCallbacks->onTell(pVFS, file, pCursor); } MA_API ma_result ma_vfs_info(ma_vfs* pVFS, ma_vfs_file file, ma_file_info* pInfo) { ma_vfs_callbacks* pCallbacks = (ma_vfs_callbacks*)pVFS; if (pInfo == NULL) { return MA_INVALID_ARGS; } MA_ZERO_OBJECT(pInfo); if (pVFS == NULL || file == NULL) { return MA_INVALID_ARGS; } if (pCallbacks->onInfo == NULL) { return MA_NOT_IMPLEMENTED; } return pCallbacks->onInfo(pVFS, file, pInfo); } #if !defined(MA_USE_WIN32_FILEIO) && (defined(MA_WIN32) && defined(MA_WIN32_DESKTOP) && !defined(MA_NO_WIN32_FILEIO) && !defined(MA_POSIX)) #define MA_USE_WIN32_FILEIO #endif #if defined(MA_USE_WIN32_FILEIO) /* We need to dynamically load SetFilePointer or SetFilePointerEx because older versions of Windows do not have the Ex version. We therefore need to do some dynamic branching depending on what's available. We load these when we load our first file from the default VFS. It's left open for the life of the program and is left to the OS to uninitialize when the program terminates. */ typedef DWORD (__stdcall * ma_SetFilePointer_proc)(HANDLE hFile, LONG lDistanceToMove, LONG* lpDistanceToMoveHigh, DWORD dwMoveMethod); typedef BOOL (__stdcall * ma_SetFilePointerEx_proc)(HANDLE hFile, LARGE_INTEGER liDistanceToMove, LARGE_INTEGER* lpNewFilePointer, DWORD dwMoveMethod); static ma_handle hKernel32DLL = NULL; static ma_SetFilePointer_proc ma_SetFilePointer = NULL; static ma_SetFilePointerEx_proc ma_SetFilePointerEx = NULL; static void ma_win32_fileio_init(void) { if (hKernel32DLL == NULL) { hKernel32DLL = ma_dlopen(NULL, "kernel32.dll"); if (hKernel32DLL != NULL) { ma_SetFilePointer = (ma_SetFilePointer_proc) ma_dlsym(NULL, hKernel32DLL, "SetFilePointer"); ma_SetFilePointerEx = (ma_SetFilePointerEx_proc)ma_dlsym(NULL, hKernel32DLL, "SetFilePointerEx"); } } } static void ma_default_vfs__get_open_settings_win32(ma_uint32 openMode, DWORD* pDesiredAccess, DWORD* pShareMode, DWORD* pCreationDisposition) { *pDesiredAccess = 0; if ((openMode & MA_OPEN_MODE_READ) != 0) { *pDesiredAccess |= GENERIC_READ; } if ((openMode & MA_OPEN_MODE_WRITE) != 0) { *pDesiredAccess |= GENERIC_WRITE; } *pShareMode = 0; if ((openMode & MA_OPEN_MODE_READ) != 0) { *pShareMode |= FILE_SHARE_READ; } if ((openMode & MA_OPEN_MODE_WRITE) != 0) { *pCreationDisposition = CREATE_ALWAYS; /* Opening in write mode. Truncate. */ } else { *pCreationDisposition = OPEN_EXISTING; /* Opening in read mode. File must exist. */ } } static ma_result ma_default_vfs_open__win32(ma_vfs* pVFS, const char* pFilePath, ma_uint32 openMode, ma_vfs_file* pFile) { HANDLE hFile; DWORD dwDesiredAccess; DWORD dwShareMode; DWORD dwCreationDisposition; (void)pVFS; /* Load some Win32 symbols dynamically so we can dynamically check for the existence of SetFilePointerEx. */ ma_win32_fileio_init(); ma_default_vfs__get_open_settings_win32(openMode, &dwDesiredAccess, &dwShareMode, &dwCreationDisposition); hFile = CreateFileA(pFilePath, dwDesiredAccess, dwShareMode, NULL, dwCreationDisposition, FILE_ATTRIBUTE_NORMAL, NULL); if (hFile == INVALID_HANDLE_VALUE) { return ma_result_from_GetLastError(GetLastError()); } *pFile = hFile; return MA_SUCCESS; } static ma_result ma_default_vfs_open_w__win32(ma_vfs* pVFS, const wchar_t* pFilePath, ma_uint32 openMode, ma_vfs_file* pFile) { HANDLE hFile; DWORD dwDesiredAccess; DWORD dwShareMode; DWORD dwCreationDisposition; (void)pVFS; /* Load some Win32 symbols dynamically so we can dynamically check for the existence of SetFilePointerEx. */ ma_win32_fileio_init(); ma_default_vfs__get_open_settings_win32(openMode, &dwDesiredAccess, &dwShareMode, &dwCreationDisposition); hFile = CreateFileW(pFilePath, dwDesiredAccess, dwShareMode, NULL, dwCreationDisposition, FILE_ATTRIBUTE_NORMAL, NULL); if (hFile == INVALID_HANDLE_VALUE) { return ma_result_from_GetLastError(GetLastError()); } *pFile = hFile; return MA_SUCCESS; } static ma_result ma_default_vfs_close__win32(ma_vfs* pVFS, ma_vfs_file file) { (void)pVFS; if (CloseHandle((HANDLE)file) == 0) { return ma_result_from_GetLastError(GetLastError()); } return MA_SUCCESS; } static ma_result ma_default_vfs_read__win32(ma_vfs* pVFS, ma_vfs_file file, void* pDst, size_t sizeInBytes, size_t* pBytesRead) { ma_result result = MA_SUCCESS; size_t totalBytesRead; (void)pVFS; totalBytesRead = 0; while (totalBytesRead < sizeInBytes) { size_t bytesRemaining; DWORD bytesToRead; DWORD bytesRead; BOOL readResult; bytesRemaining = sizeInBytes - totalBytesRead; if (bytesRemaining >= 0xFFFFFFFF) { bytesToRead = 0xFFFFFFFF; } else { bytesToRead = (DWORD)bytesRemaining; } readResult = ReadFile((HANDLE)file, ma_offset_ptr(pDst, totalBytesRead), bytesToRead, &bytesRead, NULL); if (readResult == 1 && bytesRead == 0) { result = MA_AT_END; break; /* EOF */ } totalBytesRead += bytesRead; if (bytesRead < bytesToRead) { break; /* EOF */ } if (readResult == 0) { result = ma_result_from_GetLastError(GetLastError()); break; } } if (pBytesRead != NULL) { *pBytesRead = totalBytesRead; } return result; } static ma_result ma_default_vfs_write__win32(ma_vfs* pVFS, ma_vfs_file file, const void* pSrc, size_t sizeInBytes, size_t* pBytesWritten) { ma_result result = MA_SUCCESS; size_t totalBytesWritten; (void)pVFS; totalBytesWritten = 0; while (totalBytesWritten < sizeInBytes) { size_t bytesRemaining; DWORD bytesToWrite; DWORD bytesWritten; BOOL writeResult; bytesRemaining = sizeInBytes - totalBytesWritten; if (bytesRemaining >= 0xFFFFFFFF) { bytesToWrite = 0xFFFFFFFF; } else { bytesToWrite = (DWORD)bytesRemaining; } writeResult = WriteFile((HANDLE)file, ma_offset_ptr(pSrc, totalBytesWritten), bytesToWrite, &bytesWritten, NULL); totalBytesWritten += bytesWritten; if (writeResult == 0) { result = ma_result_from_GetLastError(GetLastError()); break; } } if (pBytesWritten != NULL) { *pBytesWritten = totalBytesWritten; } return result; } static ma_result ma_default_vfs_seek__win32(ma_vfs* pVFS, ma_vfs_file file, ma_int64 offset, ma_seek_origin origin) { LARGE_INTEGER liDistanceToMove; DWORD dwMoveMethod; BOOL result; (void)pVFS; liDistanceToMove.QuadPart = offset; /* */ if (origin == ma_seek_origin_current) { dwMoveMethod = FILE_CURRENT; } else if (origin == ma_seek_origin_end) { dwMoveMethod = FILE_END; } else { dwMoveMethod = FILE_BEGIN; } if (ma_SetFilePointerEx != NULL) { result = ma_SetFilePointerEx((HANDLE)file, liDistanceToMove, NULL, dwMoveMethod); } else if (ma_SetFilePointer != NULL) { /* No SetFilePointerEx() so restrict to 31 bits. */ if (origin > 0x7FFFFFFF) { return MA_OUT_OF_RANGE; } result = ma_SetFilePointer((HANDLE)file, (LONG)liDistanceToMove.QuadPart, NULL, dwMoveMethod); } else { return MA_NOT_IMPLEMENTED; } if (result == 0) { return ma_result_from_GetLastError(GetLastError()); } return MA_SUCCESS; } static ma_result ma_default_vfs_tell__win32(ma_vfs* pVFS, ma_vfs_file file, ma_int64* pCursor) { LARGE_INTEGER liZero; LARGE_INTEGER liTell; BOOL result; (void)pVFS; liZero.QuadPart = 0; if (ma_SetFilePointerEx != NULL) { result = ma_SetFilePointerEx((HANDLE)file, liZero, &liTell, FILE_CURRENT); } else if (ma_SetFilePointer != NULL) { LONG tell; result = ma_SetFilePointer((HANDLE)file, (LONG)liZero.QuadPart, &tell, FILE_CURRENT); liTell.QuadPart = tell; } else { return MA_NOT_IMPLEMENTED; } if (result == 0) { return ma_result_from_GetLastError(GetLastError()); } if (pCursor != NULL) { *pCursor = liTell.QuadPart; } return MA_SUCCESS; } static ma_result ma_default_vfs_info__win32(ma_vfs* pVFS, ma_vfs_file file, ma_file_info* pInfo) { BY_HANDLE_FILE_INFORMATION fi; BOOL result; (void)pVFS; result = GetFileInformationByHandle((HANDLE)file, &fi); if (result == 0) { return ma_result_from_GetLastError(GetLastError()); } pInfo->sizeInBytes = ((ma_uint64)fi.nFileSizeHigh << 32) | ((ma_uint64)fi.nFileSizeLow); return MA_SUCCESS; } #else static ma_result ma_default_vfs_open__stdio(ma_vfs* pVFS, const char* pFilePath, ma_uint32 openMode, ma_vfs_file* pFile) { ma_result result; FILE* pFileStd; const char* pOpenModeStr; MA_ASSERT(pFilePath != NULL); MA_ASSERT(openMode != 0); MA_ASSERT(pFile != NULL); (void)pVFS; if ((openMode & MA_OPEN_MODE_READ) != 0) { if ((openMode & MA_OPEN_MODE_WRITE) != 0) { pOpenModeStr = "r+"; } else { pOpenModeStr = "rb"; } } else { pOpenModeStr = "wb"; } result = ma_fopen(&pFileStd, pFilePath, pOpenModeStr); if (result != MA_SUCCESS) { return result; } *pFile = pFileStd; return MA_SUCCESS; } static ma_result ma_default_vfs_open_w__stdio(ma_vfs* pVFS, const wchar_t* pFilePath, ma_uint32 openMode, ma_vfs_file* pFile) { ma_result result; FILE* pFileStd; const wchar_t* pOpenModeStr; MA_ASSERT(pFilePath != NULL); MA_ASSERT(openMode != 0); MA_ASSERT(pFile != NULL); (void)pVFS; if ((openMode & MA_OPEN_MODE_READ) != 0) { if ((openMode & MA_OPEN_MODE_WRITE) != 0) { pOpenModeStr = L"r+"; } else { pOpenModeStr = L"rb"; } } else { pOpenModeStr = L"wb"; } result = ma_wfopen(&pFileStd, pFilePath, pOpenModeStr, (pVFS != NULL) ? &((ma_default_vfs*)pVFS)->allocationCallbacks : NULL); if (result != MA_SUCCESS) { return result; } *pFile = pFileStd; return MA_SUCCESS; } static ma_result ma_default_vfs_close__stdio(ma_vfs* pVFS, ma_vfs_file file) { MA_ASSERT(file != NULL); (void)pVFS; fclose((FILE*)file); return MA_SUCCESS; } static ma_result ma_default_vfs_read__stdio(ma_vfs* pVFS, ma_vfs_file file, void* pDst, size_t sizeInBytes, size_t* pBytesRead) { size_t result; MA_ASSERT(file != NULL); MA_ASSERT(pDst != NULL); (void)pVFS; result = fread(pDst, 1, sizeInBytes, (FILE*)file); if (pBytesRead != NULL) { *pBytesRead = result; } if (result != sizeInBytes) { if (result == 0 && feof((FILE*)file)) { return MA_AT_END; } else { return ma_result_from_errno(ferror((FILE*)file)); } } return MA_SUCCESS; } static ma_result ma_default_vfs_write__stdio(ma_vfs* pVFS, ma_vfs_file file, const void* pSrc, size_t sizeInBytes, size_t* pBytesWritten) { size_t result; MA_ASSERT(file != NULL); MA_ASSERT(pSrc != NULL); (void)pVFS; result = fwrite(pSrc, 1, sizeInBytes, (FILE*)file); if (pBytesWritten != NULL) { *pBytesWritten = result; } if (result != sizeInBytes) { return ma_result_from_errno(ferror((FILE*)file)); } return MA_SUCCESS; } static ma_result ma_default_vfs_seek__stdio(ma_vfs* pVFS, ma_vfs_file file, ma_int64 offset, ma_seek_origin origin) { int result; int whence; MA_ASSERT(file != NULL); (void)pVFS; if (origin == ma_seek_origin_start) { whence = SEEK_SET; } else if (origin == ma_seek_origin_end) { whence = SEEK_END; } else { whence = SEEK_CUR; } #if defined(_WIN32) #if defined(_MSC_VER) && _MSC_VER > 1200 result = _fseeki64((FILE*)file, offset, whence); #else /* No _fseeki64() so restrict to 31 bits. */ if (origin > 0x7FFFFFFF) { return MA_OUT_OF_RANGE; } result = fseek((FILE*)file, (int)offset, whence); #endif #else result = fseek((FILE*)file, (long int)offset, whence); #endif if (result != 0) { return MA_ERROR; } return MA_SUCCESS; } static ma_result ma_default_vfs_tell__stdio(ma_vfs* pVFS, ma_vfs_file file, ma_int64* pCursor) { ma_int64 result; MA_ASSERT(file != NULL); MA_ASSERT(pCursor != NULL); (void)pVFS; #if defined(_WIN32) #if defined(_MSC_VER) && _MSC_VER > 1200 result = _ftelli64((FILE*)file); #else result = ftell((FILE*)file); #endif #else result = ftell((FILE*)file); #endif *pCursor = result; return MA_SUCCESS; } #if !defined(_MSC_VER) && !((defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 1) || defined(_XOPEN_SOURCE) || defined(_POSIX_SOURCE)) && !defined(MA_BSD) int fileno(FILE *stream); #endif static ma_result ma_default_vfs_info__stdio(ma_vfs* pVFS, ma_vfs_file file, ma_file_info* pInfo) { int fd; struct stat info; MA_ASSERT(file != NULL); MA_ASSERT(pInfo != NULL); (void)pVFS; #if defined(_MSC_VER) fd = _fileno((FILE*)file); #else fd = fileno((FILE*)file); #endif if (fstat(fd, &info) != 0) { return ma_result_from_errno(errno); } pInfo->sizeInBytes = info.st_size; return MA_SUCCESS; } #endif static ma_result ma_default_vfs_open(ma_vfs* pVFS, const char* pFilePath, ma_uint32 openMode, ma_vfs_file* pFile) { if (pFile == NULL) { return MA_INVALID_ARGS; } *pFile = NULL; if (pFilePath == NULL || openMode == 0) { return MA_INVALID_ARGS; } #if defined(MA_USE_WIN32_FILEIO) return ma_default_vfs_open__win32(pVFS, pFilePath, openMode, pFile); #else return ma_default_vfs_open__stdio(pVFS, pFilePath, openMode, pFile); #endif } static ma_result ma_default_vfs_open_w(ma_vfs* pVFS, const wchar_t* pFilePath, ma_uint32 openMode, ma_vfs_file* pFile) { if (pFile == NULL) { return MA_INVALID_ARGS; } *pFile = NULL; if (pFilePath == NULL || openMode == 0) { return MA_INVALID_ARGS; } #if defined(MA_USE_WIN32_FILEIO) return ma_default_vfs_open_w__win32(pVFS, pFilePath, openMode, pFile); #else return ma_default_vfs_open_w__stdio(pVFS, pFilePath, openMode, pFile); #endif } static ma_result ma_default_vfs_close(ma_vfs* pVFS, ma_vfs_file file) { if (file == NULL) { return MA_INVALID_ARGS; } #if defined(MA_USE_WIN32_FILEIO) return ma_default_vfs_close__win32(pVFS, file); #else return ma_default_vfs_close__stdio(pVFS, file); #endif } static ma_result ma_default_vfs_read(ma_vfs* pVFS, ma_vfs_file file, void* pDst, size_t sizeInBytes, size_t* pBytesRead) { if (pBytesRead != NULL) { *pBytesRead = 0; } if (file == NULL || pDst == NULL) { return MA_INVALID_ARGS; } #if defined(MA_USE_WIN32_FILEIO) return ma_default_vfs_read__win32(pVFS, file, pDst, sizeInBytes, pBytesRead); #else return ma_default_vfs_read__stdio(pVFS, file, pDst, sizeInBytes, pBytesRead); #endif } static ma_result ma_default_vfs_write(ma_vfs* pVFS, ma_vfs_file file, const void* pSrc, size_t sizeInBytes, size_t* pBytesWritten) { if (pBytesWritten != NULL) { *pBytesWritten = 0; } if (file == NULL || pSrc == NULL) { return MA_INVALID_ARGS; } #if defined(MA_USE_WIN32_FILEIO) return ma_default_vfs_write__win32(pVFS, file, pSrc, sizeInBytes, pBytesWritten); #else return ma_default_vfs_write__stdio(pVFS, file, pSrc, sizeInBytes, pBytesWritten); #endif } static ma_result ma_default_vfs_seek(ma_vfs* pVFS, ma_vfs_file file, ma_int64 offset, ma_seek_origin origin) { if (file == NULL) { return MA_INVALID_ARGS; } #if defined(MA_USE_WIN32_FILEIO) return ma_default_vfs_seek__win32(pVFS, file, offset, origin); #else return ma_default_vfs_seek__stdio(pVFS, file, offset, origin); #endif } static ma_result ma_default_vfs_tell(ma_vfs* pVFS, ma_vfs_file file, ma_int64* pCursor) { if (pCursor == NULL) { return MA_INVALID_ARGS; } *pCursor = 0; if (file == NULL) { return MA_INVALID_ARGS; } #if defined(MA_USE_WIN32_FILEIO) return ma_default_vfs_tell__win32(pVFS, file, pCursor); #else return ma_default_vfs_tell__stdio(pVFS, file, pCursor); #endif } static ma_result ma_default_vfs_info(ma_vfs* pVFS, ma_vfs_file file, ma_file_info* pInfo) { if (pInfo == NULL) { return MA_INVALID_ARGS; } MA_ZERO_OBJECT(pInfo); if (file == NULL) { return MA_INVALID_ARGS; } #if defined(MA_USE_WIN32_FILEIO) return ma_default_vfs_info__win32(pVFS, file, pInfo); #else return ma_default_vfs_info__stdio(pVFS, file, pInfo); #endif } MA_API ma_result ma_default_vfs_init(ma_default_vfs* pVFS, const ma_allocation_callbacks* pAllocationCallbacks) { if (pVFS == NULL) { return MA_INVALID_ARGS; } pVFS->cb.onOpen = ma_default_vfs_open; pVFS->cb.onOpenW = ma_default_vfs_open_w; pVFS->cb.onClose = ma_default_vfs_close; pVFS->cb.onRead = ma_default_vfs_read; pVFS->cb.onWrite = ma_default_vfs_write; pVFS->cb.onSeek = ma_default_vfs_seek; pVFS->cb.onTell = ma_default_vfs_tell; pVFS->cb.onInfo = ma_default_vfs_info; ma_allocation_callbacks_init_copy(&pVFS->allocationCallbacks, pAllocationCallbacks); return MA_SUCCESS; } MA_API ma_result ma_vfs_or_default_open(ma_vfs* pVFS, const char* pFilePath, ma_uint32 openMode, ma_vfs_file* pFile) { if (pVFS != NULL) { return ma_vfs_open(pVFS, pFilePath, openMode, pFile); } else { return ma_default_vfs_open(pVFS, pFilePath, openMode, pFile); } } MA_API ma_result ma_vfs_or_default_open_w(ma_vfs* pVFS, const wchar_t* pFilePath, ma_uint32 openMode, ma_vfs_file* pFile) { if (pVFS != NULL) { return ma_vfs_open_w(pVFS, pFilePath, openMode, pFile); } else { return ma_default_vfs_open_w(pVFS, pFilePath, openMode, pFile); } } MA_API ma_result ma_vfs_or_default_close(ma_vfs* pVFS, ma_vfs_file file) { if (pVFS != NULL) { return ma_vfs_close(pVFS, file); } else { return ma_default_vfs_close(pVFS, file); } } MA_API ma_result ma_vfs_or_default_read(ma_vfs* pVFS, ma_vfs_file file, void* pDst, size_t sizeInBytes, size_t* pBytesRead) { if (pVFS != NULL) { return ma_vfs_read(pVFS, file, pDst, sizeInBytes, pBytesRead); } else { return ma_default_vfs_read(pVFS, file, pDst, sizeInBytes, pBytesRead); } } MA_API ma_result ma_vfs_or_default_write(ma_vfs* pVFS, ma_vfs_file file, const void* pSrc, size_t sizeInBytes, size_t* pBytesWritten) { if (pVFS != NULL) { return ma_vfs_write(pVFS, file, pSrc, sizeInBytes, pBytesWritten); } else { return ma_default_vfs_write(pVFS, file, pSrc, sizeInBytes, pBytesWritten); } } MA_API ma_result ma_vfs_or_default_seek(ma_vfs* pVFS, ma_vfs_file file, ma_int64 offset, ma_seek_origin origin) { if (pVFS != NULL) { return ma_vfs_seek(pVFS, file, offset, origin); } else { return ma_default_vfs_seek(pVFS, file, offset, origin); } } MA_API ma_result ma_vfs_or_default_tell(ma_vfs* pVFS, ma_vfs_file file, ma_int64* pCursor) { if (pVFS != NULL) { return ma_vfs_tell(pVFS, file, pCursor); } else { return ma_default_vfs_tell(pVFS, file, pCursor); } } MA_API ma_result ma_vfs_or_default_info(ma_vfs* pVFS, ma_vfs_file file, ma_file_info* pInfo) { if (pVFS != NULL) { return ma_vfs_info(pVFS, file, pInfo); } else { return ma_default_vfs_info(pVFS, file, pInfo); } } static ma_result ma_vfs_open_and_read_file_ex(ma_vfs* pVFS, const char* pFilePath, const wchar_t* pFilePathW, void** ppData, size_t* pSize, const ma_allocation_callbacks* pAllocationCallbacks) { ma_result result; ma_vfs_file file; ma_file_info info; void* pData; size_t bytesRead; if (ppData != NULL) { *ppData = NULL; } if (pSize != NULL) { *pSize = 0; } if (ppData == NULL) { return MA_INVALID_ARGS; } if (pFilePath != NULL) { result = ma_vfs_or_default_open(pVFS, pFilePath, MA_OPEN_MODE_READ, &file); } else { result = ma_vfs_or_default_open_w(pVFS, pFilePathW, MA_OPEN_MODE_READ, &file); } if (result != MA_SUCCESS) { return result; } result = ma_vfs_or_default_info(pVFS, file, &info); if (result != MA_SUCCESS) { ma_vfs_or_default_close(pVFS, file); return result; } if (info.sizeInBytes > MA_SIZE_MAX) { ma_vfs_or_default_close(pVFS, file); return MA_TOO_BIG; } pData = ma_malloc((size_t)info.sizeInBytes, pAllocationCallbacks); /* Safe cast. */ if (pData == NULL) { ma_vfs_or_default_close(pVFS, file); return result; } result = ma_vfs_or_default_read(pVFS, file, pData, (size_t)info.sizeInBytes, &bytesRead); /* Safe cast. */ ma_vfs_or_default_close(pVFS, file); if (result != MA_SUCCESS) { ma_free(pData, pAllocationCallbacks); return result; } if (pSize != NULL) { *pSize = bytesRead; } MA_ASSERT(ppData != NULL); *ppData = pData; return MA_SUCCESS; } MA_API ma_result ma_vfs_open_and_read_file(ma_vfs* pVFS, const char* pFilePath, void** ppData, size_t* pSize, const ma_allocation_callbacks* pAllocationCallbacks) { return ma_vfs_open_and_read_file_ex(pVFS, pFilePath, NULL, ppData, pSize, pAllocationCallbacks); } MA_API ma_result ma_vfs_open_and_read_file_w(ma_vfs* pVFS, const wchar_t* pFilePath, void** ppData, size_t* pSize, const ma_allocation_callbacks* pAllocationCallbacks) { return ma_vfs_open_and_read_file_ex(pVFS, NULL, pFilePath, ppData, pSize, pAllocationCallbacks); } /************************************************************************************************************************************************************** Decoding and Encoding Headers. These are auto-generated from a tool. **************************************************************************************************************************************************************/ #if !defined(MA_NO_WAV) && (!defined(MA_NO_DECODING) || !defined(MA_NO_ENCODING)) /* dr_wav_h begin */ #ifndef ma_dr_wav_h #define ma_dr_wav_h #ifdef __cplusplus extern "C" { #endif #define MA_DR_WAV_STRINGIFY(x) #x #define MA_DR_WAV_XSTRINGIFY(x) MA_DR_WAV_STRINGIFY(x) #define MA_DR_WAV_VERSION_MAJOR 0 #define MA_DR_WAV_VERSION_MINOR 13 #define MA_DR_WAV_VERSION_REVISION 13 #define MA_DR_WAV_VERSION_STRING MA_DR_WAV_XSTRINGIFY(MA_DR_WAV_VERSION_MAJOR) "." MA_DR_WAV_XSTRINGIFY(MA_DR_WAV_VERSION_MINOR) "." MA_DR_WAV_XSTRINGIFY(MA_DR_WAV_VERSION_REVISION) #include #define MA_DR_WAVE_FORMAT_PCM 0x1 #define MA_DR_WAVE_FORMAT_ADPCM 0x2 #define MA_DR_WAVE_FORMAT_IEEE_FLOAT 0x3 #define MA_DR_WAVE_FORMAT_ALAW 0x6 #define MA_DR_WAVE_FORMAT_MULAW 0x7 #define MA_DR_WAVE_FORMAT_DVI_ADPCM 0x11 #define MA_DR_WAVE_FORMAT_EXTENSIBLE 0xFFFE #define MA_DR_WAV_SEQUENTIAL 0x00000001 #define MA_DR_WAV_WITH_METADATA 0x00000002 MA_API void ma_dr_wav_version(ma_uint32* pMajor, ma_uint32* pMinor, ma_uint32* pRevision); MA_API const char* ma_dr_wav_version_string(void); typedef enum { ma_dr_wav_seek_origin_start, ma_dr_wav_seek_origin_current } ma_dr_wav_seek_origin; typedef enum { ma_dr_wav_container_riff, ma_dr_wav_container_rifx, ma_dr_wav_container_w64, ma_dr_wav_container_rf64, ma_dr_wav_container_aiff } ma_dr_wav_container; typedef struct { union { ma_uint8 fourcc[4]; ma_uint8 guid[16]; } id; ma_uint64 sizeInBytes; unsigned int paddingSize; } ma_dr_wav_chunk_header; typedef struct { ma_uint16 formatTag; ma_uint16 channels; ma_uint32 sampleRate; ma_uint32 avgBytesPerSec; ma_uint16 blockAlign; ma_uint16 bitsPerSample; ma_uint16 extendedSize; ma_uint16 validBitsPerSample; ma_uint32 channelMask; ma_uint8 subFormat[16]; } ma_dr_wav_fmt; MA_API ma_uint16 ma_dr_wav_fmt_get_format(const ma_dr_wav_fmt* pFMT); typedef size_t (* ma_dr_wav_read_proc)(void* pUserData, void* pBufferOut, size_t bytesToRead); typedef size_t (* ma_dr_wav_write_proc)(void* pUserData, const void* pData, size_t bytesToWrite); typedef ma_bool32 (* ma_dr_wav_seek_proc)(void* pUserData, int offset, ma_dr_wav_seek_origin origin); typedef ma_uint64 (* ma_dr_wav_chunk_proc)(void* pChunkUserData, ma_dr_wav_read_proc onRead, ma_dr_wav_seek_proc onSeek, void* pReadSeekUserData, const ma_dr_wav_chunk_header* pChunkHeader, ma_dr_wav_container container, const ma_dr_wav_fmt* pFMT); typedef struct { const ma_uint8* data; size_t dataSize; size_t currentReadPos; } ma_dr_wav__memory_stream; typedef struct { void** ppData; size_t* pDataSize; size_t dataSize; size_t dataCapacity; size_t currentWritePos; } ma_dr_wav__memory_stream_write; typedef struct { ma_dr_wav_container container; ma_uint32 format; ma_uint32 channels; ma_uint32 sampleRate; ma_uint32 bitsPerSample; } ma_dr_wav_data_format; typedef enum { ma_dr_wav_metadata_type_none = 0, ma_dr_wav_metadata_type_unknown = 1 << 0, ma_dr_wav_metadata_type_smpl = 1 << 1, ma_dr_wav_metadata_type_inst = 1 << 2, ma_dr_wav_metadata_type_cue = 1 << 3, ma_dr_wav_metadata_type_acid = 1 << 4, ma_dr_wav_metadata_type_bext = 1 << 5, ma_dr_wav_metadata_type_list_label = 1 << 6, ma_dr_wav_metadata_type_list_note = 1 << 7, ma_dr_wav_metadata_type_list_labelled_cue_region = 1 << 8, ma_dr_wav_metadata_type_list_info_software = 1 << 9, ma_dr_wav_metadata_type_list_info_copyright = 1 << 10, ma_dr_wav_metadata_type_list_info_title = 1 << 11, ma_dr_wav_metadata_type_list_info_artist = 1 << 12, ma_dr_wav_metadata_type_list_info_comment = 1 << 13, ma_dr_wav_metadata_type_list_info_date = 1 << 14, ma_dr_wav_metadata_type_list_info_genre = 1 << 15, ma_dr_wav_metadata_type_list_info_album = 1 << 16, ma_dr_wav_metadata_type_list_info_tracknumber = 1 << 17, ma_dr_wav_metadata_type_list_all_info_strings = ma_dr_wav_metadata_type_list_info_software | ma_dr_wav_metadata_type_list_info_copyright | ma_dr_wav_metadata_type_list_info_title | ma_dr_wav_metadata_type_list_info_artist | ma_dr_wav_metadata_type_list_info_comment | ma_dr_wav_metadata_type_list_info_date | ma_dr_wav_metadata_type_list_info_genre | ma_dr_wav_metadata_type_list_info_album | ma_dr_wav_metadata_type_list_info_tracknumber, ma_dr_wav_metadata_type_list_all_adtl = ma_dr_wav_metadata_type_list_label | ma_dr_wav_metadata_type_list_note | ma_dr_wav_metadata_type_list_labelled_cue_region, ma_dr_wav_metadata_type_all = -2, ma_dr_wav_metadata_type_all_including_unknown = -1 } ma_dr_wav_metadata_type; typedef enum { ma_dr_wav_smpl_loop_type_forward = 0, ma_dr_wav_smpl_loop_type_pingpong = 1, ma_dr_wav_smpl_loop_type_backward = 2 } ma_dr_wav_smpl_loop_type; typedef struct { ma_uint32 cuePointId; ma_uint32 type; ma_uint32 firstSampleByteOffset; ma_uint32 lastSampleByteOffset; ma_uint32 sampleFraction; ma_uint32 playCount; } ma_dr_wav_smpl_loop; typedef struct { ma_uint32 manufacturerId; ma_uint32 productId; ma_uint32 samplePeriodNanoseconds; ma_uint32 midiUnityNote; ma_uint32 midiPitchFraction; ma_uint32 smpteFormat; ma_uint32 smpteOffset; ma_uint32 sampleLoopCount; ma_uint32 samplerSpecificDataSizeInBytes; ma_dr_wav_smpl_loop* pLoops; ma_uint8* pSamplerSpecificData; } ma_dr_wav_smpl; typedef struct { ma_int8 midiUnityNote; ma_int8 fineTuneCents; ma_int8 gainDecibels; ma_int8 lowNote; ma_int8 highNote; ma_int8 lowVelocity; ma_int8 highVelocity; } ma_dr_wav_inst; typedef struct { ma_uint32 id; ma_uint32 playOrderPosition; ma_uint8 dataChunkId[4]; ma_uint32 chunkStart; ma_uint32 blockStart; ma_uint32 sampleByteOffset; } ma_dr_wav_cue_point; typedef struct { ma_uint32 cuePointCount; ma_dr_wav_cue_point *pCuePoints; } ma_dr_wav_cue; typedef enum { ma_dr_wav_acid_flag_one_shot = 1, ma_dr_wav_acid_flag_root_note_set = 2, ma_dr_wav_acid_flag_stretch = 4, ma_dr_wav_acid_flag_disk_based = 8, ma_dr_wav_acid_flag_acidizer = 16 } ma_dr_wav_acid_flag; typedef struct { ma_uint32 flags; ma_uint16 midiUnityNote; ma_uint16 reserved1; float reserved2; ma_uint32 numBeats; ma_uint16 meterDenominator; ma_uint16 meterNumerator; float tempo; } ma_dr_wav_acid; typedef struct { ma_uint32 cuePointId; ma_uint32 stringLength; char* pString; } ma_dr_wav_list_label_or_note; typedef struct { char* pDescription; char* pOriginatorName; char* pOriginatorReference; char pOriginationDate[10]; char pOriginationTime[8]; ma_uint64 timeReference; ma_uint16 version; char* pCodingHistory; ma_uint32 codingHistorySize; ma_uint8* pUMID; ma_uint16 loudnessValue; ma_uint16 loudnessRange; ma_uint16 maxTruePeakLevel; ma_uint16 maxMomentaryLoudness; ma_uint16 maxShortTermLoudness; } ma_dr_wav_bext; typedef struct { ma_uint32 stringLength; char* pString; } ma_dr_wav_list_info_text; typedef struct { ma_uint32 cuePointId; ma_uint32 sampleLength; ma_uint8 purposeId[4]; ma_uint16 country; ma_uint16 language; ma_uint16 dialect; ma_uint16 codePage; ma_uint32 stringLength; char* pString; } ma_dr_wav_list_labelled_cue_region; typedef enum { ma_dr_wav_metadata_location_invalid, ma_dr_wav_metadata_location_top_level, ma_dr_wav_metadata_location_inside_info_list, ma_dr_wav_metadata_location_inside_adtl_list } ma_dr_wav_metadata_location; typedef struct { ma_uint8 id[4]; ma_dr_wav_metadata_location chunkLocation; ma_uint32 dataSizeInBytes; ma_uint8* pData; } ma_dr_wav_unknown_metadata; typedef struct { ma_dr_wav_metadata_type type; union { ma_dr_wav_cue cue; ma_dr_wav_smpl smpl; ma_dr_wav_acid acid; ma_dr_wav_inst inst; ma_dr_wav_bext bext; ma_dr_wav_list_label_or_note labelOrNote; ma_dr_wav_list_labelled_cue_region labelledCueRegion; ma_dr_wav_list_info_text infoText; ma_dr_wav_unknown_metadata unknown; } data; } ma_dr_wav_metadata; typedef struct { ma_dr_wav_read_proc onRead; ma_dr_wav_write_proc onWrite; ma_dr_wav_seek_proc onSeek; void* pUserData; ma_allocation_callbacks allocationCallbacks; ma_dr_wav_container container; ma_dr_wav_fmt fmt; ma_uint32 sampleRate; ma_uint16 channels; ma_uint16 bitsPerSample; ma_uint16 translatedFormatTag; ma_uint64 totalPCMFrameCount; ma_uint64 dataChunkDataSize; ma_uint64 dataChunkDataPos; ma_uint64 bytesRemaining; ma_uint64 readCursorInPCMFrames; ma_uint64 dataChunkDataSizeTargetWrite; ma_bool32 isSequentialWrite; ma_dr_wav_metadata* pMetadata; ma_uint32 metadataCount; ma_dr_wav__memory_stream memoryStream; ma_dr_wav__memory_stream_write memoryStreamWrite; struct { ma_uint32 bytesRemainingInBlock; ma_uint16 predictor[2]; ma_int32 delta[2]; ma_int32 cachedFrames[4]; ma_uint32 cachedFrameCount; ma_int32 prevFrames[2][2]; } msadpcm; struct { ma_uint32 bytesRemainingInBlock; ma_int32 predictor[2]; ma_int32 stepIndex[2]; ma_int32 cachedFrames[16]; ma_uint32 cachedFrameCount; } ima; struct { ma_bool8 isLE; ma_bool8 isUnsigned; } aiff; } ma_dr_wav; MA_API ma_bool32 ma_dr_wav_init(ma_dr_wav* pWav, ma_dr_wav_read_proc onRead, ma_dr_wav_seek_proc onSeek, void* pUserData, const ma_allocation_callbacks* pAllocationCallbacks); MA_API ma_bool32 ma_dr_wav_init_ex(ma_dr_wav* pWav, ma_dr_wav_read_proc onRead, ma_dr_wav_seek_proc onSeek, ma_dr_wav_chunk_proc onChunk, void* pReadSeekUserData, void* pChunkUserData, ma_uint32 flags, const ma_allocation_callbacks* pAllocationCallbacks); MA_API ma_bool32 ma_dr_wav_init_with_metadata(ma_dr_wav* pWav, ma_dr_wav_read_proc onRead, ma_dr_wav_seek_proc onSeek, void* pUserData, ma_uint32 flags, const ma_allocation_callbacks* pAllocationCallbacks); MA_API ma_bool32 ma_dr_wav_init_write(ma_dr_wav* pWav, const ma_dr_wav_data_format* pFormat, ma_dr_wav_write_proc onWrite, ma_dr_wav_seek_proc onSeek, void* pUserData, const ma_allocation_callbacks* pAllocationCallbacks); MA_API ma_bool32 ma_dr_wav_init_write_sequential(ma_dr_wav* pWav, const ma_dr_wav_data_format* pFormat, ma_uint64 totalSampleCount, ma_dr_wav_write_proc onWrite, void* pUserData, const ma_allocation_callbacks* pAllocationCallbacks); MA_API ma_bool32 ma_dr_wav_init_write_sequential_pcm_frames(ma_dr_wav* pWav, const ma_dr_wav_data_format* pFormat, ma_uint64 totalPCMFrameCount, ma_dr_wav_write_proc onWrite, void* pUserData, const ma_allocation_callbacks* pAllocationCallbacks); MA_API ma_bool32 ma_dr_wav_init_write_with_metadata(ma_dr_wav* pWav, const ma_dr_wav_data_format* pFormat, ma_dr_wav_write_proc onWrite, ma_dr_wav_seek_proc onSeek, void* pUserData, const ma_allocation_callbacks* pAllocationCallbacks, ma_dr_wav_metadata* pMetadata, ma_uint32 metadataCount); MA_API ma_uint64 ma_dr_wav_target_write_size_bytes(const ma_dr_wav_data_format* pFormat, ma_uint64 totalFrameCount, ma_dr_wav_metadata* pMetadata, ma_uint32 metadataCount); MA_API ma_dr_wav_metadata* ma_dr_wav_take_ownership_of_metadata(ma_dr_wav* pWav); MA_API ma_result ma_dr_wav_uninit(ma_dr_wav* pWav); MA_API size_t ma_dr_wav_read_raw(ma_dr_wav* pWav, size_t bytesToRead, void* pBufferOut); MA_API ma_uint64 ma_dr_wav_read_pcm_frames(ma_dr_wav* pWav, ma_uint64 framesToRead, void* pBufferOut); MA_API ma_uint64 ma_dr_wav_read_pcm_frames_le(ma_dr_wav* pWav, ma_uint64 framesToRead, void* pBufferOut); MA_API ma_uint64 ma_dr_wav_read_pcm_frames_be(ma_dr_wav* pWav, ma_uint64 framesToRead, void* pBufferOut); MA_API ma_bool32 ma_dr_wav_seek_to_pcm_frame(ma_dr_wav* pWav, ma_uint64 targetFrameIndex); MA_API ma_result ma_dr_wav_get_cursor_in_pcm_frames(ma_dr_wav* pWav, ma_uint64* pCursor); MA_API ma_result ma_dr_wav_get_length_in_pcm_frames(ma_dr_wav* pWav, ma_uint64* pLength); MA_API size_t ma_dr_wav_write_raw(ma_dr_wav* pWav, size_t bytesToWrite, const void* pData); MA_API ma_uint64 ma_dr_wav_write_pcm_frames(ma_dr_wav* pWav, ma_uint64 framesToWrite, const void* pData); MA_API ma_uint64 ma_dr_wav_write_pcm_frames_le(ma_dr_wav* pWav, ma_uint64 framesToWrite, const void* pData); MA_API ma_uint64 ma_dr_wav_write_pcm_frames_be(ma_dr_wav* pWav, ma_uint64 framesToWrite, const void* pData); #ifndef MA_DR_WAV_NO_CONVERSION_API MA_API ma_uint64 ma_dr_wav_read_pcm_frames_s16(ma_dr_wav* pWav, ma_uint64 framesToRead, ma_int16* pBufferOut); MA_API ma_uint64 ma_dr_wav_read_pcm_frames_s16le(ma_dr_wav* pWav, ma_uint64 framesToRead, ma_int16* pBufferOut); MA_API ma_uint64 ma_dr_wav_read_pcm_frames_s16be(ma_dr_wav* pWav, ma_uint64 framesToRead, ma_int16* pBufferOut); MA_API void ma_dr_wav_u8_to_s16(ma_int16* pOut, const ma_uint8* pIn, size_t sampleCount); MA_API void ma_dr_wav_s24_to_s16(ma_int16* pOut, const ma_uint8* pIn, size_t sampleCount); MA_API void ma_dr_wav_s32_to_s16(ma_int16* pOut, const ma_int32* pIn, size_t sampleCount); MA_API void ma_dr_wav_f32_to_s16(ma_int16* pOut, const float* pIn, size_t sampleCount); MA_API void ma_dr_wav_f64_to_s16(ma_int16* pOut, const double* pIn, size_t sampleCount); MA_API void ma_dr_wav_alaw_to_s16(ma_int16* pOut, const ma_uint8* pIn, size_t sampleCount); MA_API void ma_dr_wav_mulaw_to_s16(ma_int16* pOut, const ma_uint8* pIn, size_t sampleCount); MA_API ma_uint64 ma_dr_wav_read_pcm_frames_f32(ma_dr_wav* pWav, ma_uint64 framesToRead, float* pBufferOut); MA_API ma_uint64 ma_dr_wav_read_pcm_frames_f32le(ma_dr_wav* pWav, ma_uint64 framesToRead, float* pBufferOut); MA_API ma_uint64 ma_dr_wav_read_pcm_frames_f32be(ma_dr_wav* pWav, ma_uint64 framesToRead, float* pBufferOut); MA_API void ma_dr_wav_u8_to_f32(float* pOut, const ma_uint8* pIn, size_t sampleCount); MA_API void ma_dr_wav_s16_to_f32(float* pOut, const ma_int16* pIn, size_t sampleCount); MA_API void ma_dr_wav_s24_to_f32(float* pOut, const ma_uint8* pIn, size_t sampleCount); MA_API void ma_dr_wav_s32_to_f32(float* pOut, const ma_int32* pIn, size_t sampleCount); MA_API void ma_dr_wav_f64_to_f32(float* pOut, const double* pIn, size_t sampleCount); MA_API void ma_dr_wav_alaw_to_f32(float* pOut, const ma_uint8* pIn, size_t sampleCount); MA_API void ma_dr_wav_mulaw_to_f32(float* pOut, const ma_uint8* pIn, size_t sampleCount); MA_API ma_uint64 ma_dr_wav_read_pcm_frames_s32(ma_dr_wav* pWav, ma_uint64 framesToRead, ma_int32* pBufferOut); MA_API ma_uint64 ma_dr_wav_read_pcm_frames_s32le(ma_dr_wav* pWav, ma_uint64 framesToRead, ma_int32* pBufferOut); MA_API ma_uint64 ma_dr_wav_read_pcm_frames_s32be(ma_dr_wav* pWav, ma_uint64 framesToRead, ma_int32* pBufferOut); MA_API void ma_dr_wav_u8_to_s32(ma_int32* pOut, const ma_uint8* pIn, size_t sampleCount); MA_API void ma_dr_wav_s16_to_s32(ma_int32* pOut, const ma_int16* pIn, size_t sampleCount); MA_API void ma_dr_wav_s24_to_s32(ma_int32* pOut, const ma_uint8* pIn, size_t sampleCount); MA_API void ma_dr_wav_f32_to_s32(ma_int32* pOut, const float* pIn, size_t sampleCount); MA_API void ma_dr_wav_f64_to_s32(ma_int32* pOut, const double* pIn, size_t sampleCount); MA_API void ma_dr_wav_alaw_to_s32(ma_int32* pOut, const ma_uint8* pIn, size_t sampleCount); MA_API void ma_dr_wav_mulaw_to_s32(ma_int32* pOut, const ma_uint8* pIn, size_t sampleCount); #endif #ifndef MA_DR_WAV_NO_STDIO MA_API ma_bool32 ma_dr_wav_init_file(ma_dr_wav* pWav, const char* filename, const ma_allocation_callbacks* pAllocationCallbacks); MA_API ma_bool32 ma_dr_wav_init_file_ex(ma_dr_wav* pWav, const char* filename, ma_dr_wav_chunk_proc onChunk, void* pChunkUserData, ma_uint32 flags, const ma_allocation_callbacks* pAllocationCallbacks); MA_API ma_bool32 ma_dr_wav_init_file_w(ma_dr_wav* pWav, const wchar_t* filename, const ma_allocation_callbacks* pAllocationCallbacks); MA_API ma_bool32 ma_dr_wav_init_file_ex_w(ma_dr_wav* pWav, const wchar_t* filename, ma_dr_wav_chunk_proc onChunk, void* pChunkUserData, ma_uint32 flags, const ma_allocation_callbacks* pAllocationCallbacks); MA_API ma_bool32 ma_dr_wav_init_file_with_metadata(ma_dr_wav* pWav, const char* filename, ma_uint32 flags, const ma_allocation_callbacks* pAllocationCallbacks); MA_API ma_bool32 ma_dr_wav_init_file_with_metadata_w(ma_dr_wav* pWav, const wchar_t* filename, ma_uint32 flags, const ma_allocation_callbacks* pAllocationCallbacks); MA_API ma_bool32 ma_dr_wav_init_file_write(ma_dr_wav* pWav, const char* filename, const ma_dr_wav_data_format* pFormat, const ma_allocation_callbacks* pAllocationCallbacks); MA_API ma_bool32 ma_dr_wav_init_file_write_sequential(ma_dr_wav* pWav, const char* filename, const ma_dr_wav_data_format* pFormat, ma_uint64 totalSampleCount, const ma_allocation_callbacks* pAllocationCallbacks); MA_API ma_bool32 ma_dr_wav_init_file_write_sequential_pcm_frames(ma_dr_wav* pWav, const char* filename, const ma_dr_wav_data_format* pFormat, ma_uint64 totalPCMFrameCount, const ma_allocation_callbacks* pAllocationCallbacks); MA_API ma_bool32 ma_dr_wav_init_file_write_w(ma_dr_wav* pWav, const wchar_t* filename, const ma_dr_wav_data_format* pFormat, const ma_allocation_callbacks* pAllocationCallbacks); MA_API ma_bool32 ma_dr_wav_init_file_write_sequential_w(ma_dr_wav* pWav, const wchar_t* filename, const ma_dr_wav_data_format* pFormat, ma_uint64 totalSampleCount, const ma_allocation_callbacks* pAllocationCallbacks); MA_API ma_bool32 ma_dr_wav_init_file_write_sequential_pcm_frames_w(ma_dr_wav* pWav, const wchar_t* filename, const ma_dr_wav_data_format* pFormat, ma_uint64 totalPCMFrameCount, const ma_allocation_callbacks* pAllocationCallbacks); #endif MA_API ma_bool32 ma_dr_wav_init_memory(ma_dr_wav* pWav, const void* data, size_t dataSize, const ma_allocation_callbacks* pAllocationCallbacks); MA_API ma_bool32 ma_dr_wav_init_memory_ex(ma_dr_wav* pWav, const void* data, size_t dataSize, ma_dr_wav_chunk_proc onChunk, void* pChunkUserData, ma_uint32 flags, const ma_allocation_callbacks* pAllocationCallbacks); MA_API ma_bool32 ma_dr_wav_init_memory_with_metadata(ma_dr_wav* pWav, const void* data, size_t dataSize, ma_uint32 flags, const ma_allocation_callbacks* pAllocationCallbacks); MA_API ma_bool32 ma_dr_wav_init_memory_write(ma_dr_wav* pWav, void** ppData, size_t* pDataSize, const ma_dr_wav_data_format* pFormat, const ma_allocation_callbacks* pAllocationCallbacks); MA_API ma_bool32 ma_dr_wav_init_memory_write_sequential(ma_dr_wav* pWav, void** ppData, size_t* pDataSize, const ma_dr_wav_data_format* pFormat, ma_uint64 totalSampleCount, const ma_allocation_callbacks* pAllocationCallbacks); MA_API ma_bool32 ma_dr_wav_init_memory_write_sequential_pcm_frames(ma_dr_wav* pWav, void** ppData, size_t* pDataSize, const ma_dr_wav_data_format* pFormat, ma_uint64 totalPCMFrameCount, const ma_allocation_callbacks* pAllocationCallbacks); #ifndef MA_DR_WAV_NO_CONVERSION_API MA_API ma_int16* ma_dr_wav_open_and_read_pcm_frames_s16(ma_dr_wav_read_proc onRead, ma_dr_wav_seek_proc onSeek, void* pUserData, unsigned int* channelsOut, unsigned int* sampleRateOut, ma_uint64* totalFrameCountOut, const ma_allocation_callbacks* pAllocationCallbacks); MA_API float* ma_dr_wav_open_and_read_pcm_frames_f32(ma_dr_wav_read_proc onRead, ma_dr_wav_seek_proc onSeek, void* pUserData, unsigned int* channelsOut, unsigned int* sampleRateOut, ma_uint64* totalFrameCountOut, const ma_allocation_callbacks* pAllocationCallbacks); MA_API ma_int32* ma_dr_wav_open_and_read_pcm_frames_s32(ma_dr_wav_read_proc onRead, ma_dr_wav_seek_proc onSeek, void* pUserData, unsigned int* channelsOut, unsigned int* sampleRateOut, ma_uint64* totalFrameCountOut, const ma_allocation_callbacks* pAllocationCallbacks); #ifndef MA_DR_WAV_NO_STDIO MA_API ma_int16* ma_dr_wav_open_file_and_read_pcm_frames_s16(const char* filename, unsigned int* channelsOut, unsigned int* sampleRateOut, ma_uint64* totalFrameCountOut, const ma_allocation_callbacks* pAllocationCallbacks); MA_API float* ma_dr_wav_open_file_and_read_pcm_frames_f32(const char* filename, unsigned int* channelsOut, unsigned int* sampleRateOut, ma_uint64* totalFrameCountOut, const ma_allocation_callbacks* pAllocationCallbacks); MA_API ma_int32* ma_dr_wav_open_file_and_read_pcm_frames_s32(const char* filename, unsigned int* channelsOut, unsigned int* sampleRateOut, ma_uint64* totalFrameCountOut, const ma_allocation_callbacks* pAllocationCallbacks); MA_API ma_int16* ma_dr_wav_open_file_and_read_pcm_frames_s16_w(const wchar_t* filename, unsigned int* channelsOut, unsigned int* sampleRateOut, ma_uint64* totalFrameCountOut, const ma_allocation_callbacks* pAllocationCallbacks); MA_API float* ma_dr_wav_open_file_and_read_pcm_frames_f32_w(const wchar_t* filename, unsigned int* channelsOut, unsigned int* sampleRateOut, ma_uint64* totalFrameCountOut, const ma_allocation_callbacks* pAllocationCallbacks); MA_API ma_int32* ma_dr_wav_open_file_and_read_pcm_frames_s32_w(const wchar_t* filename, unsigned int* channelsOut, unsigned int* sampleRateOut, ma_uint64* totalFrameCountOut, const ma_allocation_callbacks* pAllocationCallbacks); #endif MA_API ma_int16* ma_dr_wav_open_memory_and_read_pcm_frames_s16(const void* data, size_t dataSize, unsigned int* channelsOut, unsigned int* sampleRateOut, ma_uint64* totalFrameCountOut, const ma_allocation_callbacks* pAllocationCallbacks); MA_API float* ma_dr_wav_open_memory_and_read_pcm_frames_f32(const void* data, size_t dataSize, unsigned int* channelsOut, unsigned int* sampleRateOut, ma_uint64* totalFrameCountOut, const ma_allocation_callbacks* pAllocationCallbacks); MA_API ma_int32* ma_dr_wav_open_memory_and_read_pcm_frames_s32(const void* data, size_t dataSize, unsigned int* channelsOut, unsigned int* sampleRateOut, ma_uint64* totalFrameCountOut, const ma_allocation_callbacks* pAllocationCallbacks); #endif MA_API void ma_dr_wav_free(void* p, const ma_allocation_callbacks* pAllocationCallbacks); MA_API ma_uint16 ma_dr_wav_bytes_to_u16(const ma_uint8* data); MA_API ma_int16 ma_dr_wav_bytes_to_s16(const ma_uint8* data); MA_API ma_uint32 ma_dr_wav_bytes_to_u32(const ma_uint8* data); MA_API ma_int32 ma_dr_wav_bytes_to_s32(const ma_uint8* data); MA_API ma_uint64 ma_dr_wav_bytes_to_u64(const ma_uint8* data); MA_API ma_int64 ma_dr_wav_bytes_to_s64(const ma_uint8* data); MA_API float ma_dr_wav_bytes_to_f32(const ma_uint8* data); MA_API ma_bool32 ma_dr_wav_guid_equal(const ma_uint8 a[16], const ma_uint8 b[16]); MA_API ma_bool32 ma_dr_wav_fourcc_equal(const ma_uint8* a, const char* b); #ifdef __cplusplus } #endif #endif /* dr_wav_h end */ #endif /* MA_NO_WAV */ #if !defined(MA_NO_FLAC) && !defined(MA_NO_DECODING) /* dr_flac_h begin */ #ifndef ma_dr_flac_h #define ma_dr_flac_h #ifdef __cplusplus extern "C" { #endif #define MA_DR_FLAC_STRINGIFY(x) #x #define MA_DR_FLAC_XSTRINGIFY(x) MA_DR_FLAC_STRINGIFY(x) #define MA_DR_FLAC_VERSION_MAJOR 0 #define MA_DR_FLAC_VERSION_MINOR 12 #define MA_DR_FLAC_VERSION_REVISION 42 #define MA_DR_FLAC_VERSION_STRING MA_DR_FLAC_XSTRINGIFY(MA_DR_FLAC_VERSION_MAJOR) "." MA_DR_FLAC_XSTRINGIFY(MA_DR_FLAC_VERSION_MINOR) "." MA_DR_FLAC_XSTRINGIFY(MA_DR_FLAC_VERSION_REVISION) #include #if defined(_MSC_VER) && _MSC_VER >= 1700 #define MA_DR_FLAC_DEPRECATED __declspec(deprecated) #elif (defined(__GNUC__) && __GNUC__ >= 4) #define MA_DR_FLAC_DEPRECATED __attribute__((deprecated)) #elif defined(__has_feature) #if __has_feature(attribute_deprecated) #define MA_DR_FLAC_DEPRECATED __attribute__((deprecated)) #else #define MA_DR_FLAC_DEPRECATED #endif #else #define MA_DR_FLAC_DEPRECATED #endif MA_API void ma_dr_flac_version(ma_uint32* pMajor, ma_uint32* pMinor, ma_uint32* pRevision); MA_API const char* ma_dr_flac_version_string(void); #ifndef MA_DR_FLAC_BUFFER_SIZE #define MA_DR_FLAC_BUFFER_SIZE 4096 #endif #ifdef MA_64BIT typedef ma_uint64 ma_dr_flac_cache_t; #else typedef ma_uint32 ma_dr_flac_cache_t; #endif #define MA_DR_FLAC_METADATA_BLOCK_TYPE_STREAMINFO 0 #define MA_DR_FLAC_METADATA_BLOCK_TYPE_PADDING 1 #define MA_DR_FLAC_METADATA_BLOCK_TYPE_APPLICATION 2 #define MA_DR_FLAC_METADATA_BLOCK_TYPE_SEEKTABLE 3 #define MA_DR_FLAC_METADATA_BLOCK_TYPE_VORBIS_COMMENT 4 #define MA_DR_FLAC_METADATA_BLOCK_TYPE_CUESHEET 5 #define MA_DR_FLAC_METADATA_BLOCK_TYPE_PICTURE 6 #define MA_DR_FLAC_METADATA_BLOCK_TYPE_INVALID 127 #define MA_DR_FLAC_PICTURE_TYPE_OTHER 0 #define MA_DR_FLAC_PICTURE_TYPE_FILE_ICON 1 #define MA_DR_FLAC_PICTURE_TYPE_OTHER_FILE_ICON 2 #define MA_DR_FLAC_PICTURE_TYPE_COVER_FRONT 3 #define MA_DR_FLAC_PICTURE_TYPE_COVER_BACK 4 #define MA_DR_FLAC_PICTURE_TYPE_LEAFLET_PAGE 5 #define MA_DR_FLAC_PICTURE_TYPE_MEDIA 6 #define MA_DR_FLAC_PICTURE_TYPE_LEAD_ARTIST 7 #define MA_DR_FLAC_PICTURE_TYPE_ARTIST 8 #define MA_DR_FLAC_PICTURE_TYPE_CONDUCTOR 9 #define MA_DR_FLAC_PICTURE_TYPE_BAND 10 #define MA_DR_FLAC_PICTURE_TYPE_COMPOSER 11 #define MA_DR_FLAC_PICTURE_TYPE_LYRICIST 12 #define MA_DR_FLAC_PICTURE_TYPE_RECORDING_LOCATION 13 #define MA_DR_FLAC_PICTURE_TYPE_DURING_RECORDING 14 #define MA_DR_FLAC_PICTURE_TYPE_DURING_PERFORMANCE 15 #define MA_DR_FLAC_PICTURE_TYPE_SCREEN_CAPTURE 16 #define MA_DR_FLAC_PICTURE_TYPE_BRIGHT_COLORED_FISH 17 #define MA_DR_FLAC_PICTURE_TYPE_ILLUSTRATION 18 #define MA_DR_FLAC_PICTURE_TYPE_BAND_LOGOTYPE 19 #define MA_DR_FLAC_PICTURE_TYPE_PUBLISHER_LOGOTYPE 20 typedef enum { ma_dr_flac_container_native, ma_dr_flac_container_ogg, ma_dr_flac_container_unknown } ma_dr_flac_container; typedef enum { ma_dr_flac_seek_origin_start, ma_dr_flac_seek_origin_current } ma_dr_flac_seek_origin; typedef struct { ma_uint64 firstPCMFrame; ma_uint64 flacFrameOffset; ma_uint16 pcmFrameCount; } ma_dr_flac_seekpoint; typedef struct { ma_uint16 minBlockSizeInPCMFrames; ma_uint16 maxBlockSizeInPCMFrames; ma_uint32 minFrameSizeInPCMFrames; ma_uint32 maxFrameSizeInPCMFrames; ma_uint32 sampleRate; ma_uint8 channels; ma_uint8 bitsPerSample; ma_uint64 totalPCMFrameCount; ma_uint8 md5[16]; } ma_dr_flac_streaminfo; typedef struct { ma_uint32 type; const void* pRawData; ma_uint32 rawDataSize; union { ma_dr_flac_streaminfo streaminfo; struct { int unused; } padding; struct { ma_uint32 id; const void* pData; ma_uint32 dataSize; } application; struct { ma_uint32 seekpointCount; const ma_dr_flac_seekpoint* pSeekpoints; } seektable; struct { ma_uint32 vendorLength; const char* vendor; ma_uint32 commentCount; const void* pComments; } vorbis_comment; struct { char catalog[128]; ma_uint64 leadInSampleCount; ma_bool32 isCD; ma_uint8 trackCount; const void* pTrackData; } cuesheet; struct { ma_uint32 type; ma_uint32 mimeLength; const char* mime; ma_uint32 descriptionLength; const char* description; ma_uint32 width; ma_uint32 height; ma_uint32 colorDepth; ma_uint32 indexColorCount; ma_uint32 pictureDataSize; const ma_uint8* pPictureData; } picture; } data; } ma_dr_flac_metadata; typedef size_t (* ma_dr_flac_read_proc)(void* pUserData, void* pBufferOut, size_t bytesToRead); typedef ma_bool32 (* ma_dr_flac_seek_proc)(void* pUserData, int offset, ma_dr_flac_seek_origin origin); typedef void (* ma_dr_flac_meta_proc)(void* pUserData, ma_dr_flac_metadata* pMetadata); typedef struct { const ma_uint8* data; size_t dataSize; size_t currentReadPos; } ma_dr_flac__memory_stream; typedef struct { ma_dr_flac_read_proc onRead; ma_dr_flac_seek_proc onSeek; void* pUserData; size_t unalignedByteCount; ma_dr_flac_cache_t unalignedCache; ma_uint32 nextL2Line; ma_uint32 consumedBits; ma_dr_flac_cache_t cacheL2[MA_DR_FLAC_BUFFER_SIZE/sizeof(ma_dr_flac_cache_t)]; ma_dr_flac_cache_t cache; ma_uint16 crc16; ma_dr_flac_cache_t crc16Cache; ma_uint32 crc16CacheIgnoredBytes; } ma_dr_flac_bs; typedef struct { ma_uint8 subframeType; ma_uint8 wastedBitsPerSample; ma_uint8 lpcOrder; ma_int32* pSamplesS32; } ma_dr_flac_subframe; typedef struct { ma_uint64 pcmFrameNumber; ma_uint32 flacFrameNumber; ma_uint32 sampleRate; ma_uint16 blockSizeInPCMFrames; ma_uint8 channelAssignment; ma_uint8 bitsPerSample; ma_uint8 crc8; } ma_dr_flac_frame_header; typedef struct { ma_dr_flac_frame_header header; ma_uint32 pcmFramesRemaining; ma_dr_flac_subframe subframes[8]; } ma_dr_flac_frame; typedef struct { ma_dr_flac_meta_proc onMeta; void* pUserDataMD; ma_allocation_callbacks allocationCallbacks; ma_uint32 sampleRate; ma_uint8 channels; ma_uint8 bitsPerSample; ma_uint16 maxBlockSizeInPCMFrames; ma_uint64 totalPCMFrameCount; ma_dr_flac_container container; ma_uint32 seekpointCount; ma_dr_flac_frame currentFLACFrame; ma_uint64 currentPCMFrame; ma_uint64 firstFLACFramePosInBytes; ma_dr_flac__memory_stream memoryStream; ma_int32* pDecodedSamples; ma_dr_flac_seekpoint* pSeekpoints; void* _oggbs; ma_bool32 _noSeekTableSeek : 1; ma_bool32 _noBinarySearchSeek : 1; ma_bool32 _noBruteForceSeek : 1; ma_dr_flac_bs bs; ma_uint8 pExtraData[1]; } ma_dr_flac; MA_API ma_dr_flac* ma_dr_flac_open(ma_dr_flac_read_proc onRead, ma_dr_flac_seek_proc onSeek, void* pUserData, const ma_allocation_callbacks* pAllocationCallbacks); MA_API ma_dr_flac* ma_dr_flac_open_relaxed(ma_dr_flac_read_proc onRead, ma_dr_flac_seek_proc onSeek, ma_dr_flac_container container, void* pUserData, const ma_allocation_callbacks* pAllocationCallbacks); MA_API ma_dr_flac* ma_dr_flac_open_with_metadata(ma_dr_flac_read_proc onRead, ma_dr_flac_seek_proc onSeek, ma_dr_flac_meta_proc onMeta, void* pUserData, const ma_allocation_callbacks* pAllocationCallbacks); MA_API ma_dr_flac* ma_dr_flac_open_with_metadata_relaxed(ma_dr_flac_read_proc onRead, ma_dr_flac_seek_proc onSeek, ma_dr_flac_meta_proc onMeta, ma_dr_flac_container container, void* pUserData, const ma_allocation_callbacks* pAllocationCallbacks); MA_API void ma_dr_flac_close(ma_dr_flac* pFlac); MA_API ma_uint64 ma_dr_flac_read_pcm_frames_s32(ma_dr_flac* pFlac, ma_uint64 framesToRead, ma_int32* pBufferOut); MA_API ma_uint64 ma_dr_flac_read_pcm_frames_s16(ma_dr_flac* pFlac, ma_uint64 framesToRead, ma_int16* pBufferOut); MA_API ma_uint64 ma_dr_flac_read_pcm_frames_f32(ma_dr_flac* pFlac, ma_uint64 framesToRead, float* pBufferOut); MA_API ma_bool32 ma_dr_flac_seek_to_pcm_frame(ma_dr_flac* pFlac, ma_uint64 pcmFrameIndex); #ifndef MA_DR_FLAC_NO_STDIO MA_API ma_dr_flac* ma_dr_flac_open_file(const char* pFileName, const ma_allocation_callbacks* pAllocationCallbacks); MA_API ma_dr_flac* ma_dr_flac_open_file_w(const wchar_t* pFileName, const ma_allocation_callbacks* pAllocationCallbacks); MA_API ma_dr_flac* ma_dr_flac_open_file_with_metadata(const char* pFileName, ma_dr_flac_meta_proc onMeta, void* pUserData, const ma_allocation_callbacks* pAllocationCallbacks); MA_API ma_dr_flac* ma_dr_flac_open_file_with_metadata_w(const wchar_t* pFileName, ma_dr_flac_meta_proc onMeta, void* pUserData, const ma_allocation_callbacks* pAllocationCallbacks); #endif MA_API ma_dr_flac* ma_dr_flac_open_memory(const void* pData, size_t dataSize, const ma_allocation_callbacks* pAllocationCallbacks); MA_API ma_dr_flac* ma_dr_flac_open_memory_with_metadata(const void* pData, size_t dataSize, ma_dr_flac_meta_proc onMeta, void* pUserData, const ma_allocation_callbacks* pAllocationCallbacks); MA_API ma_int32* ma_dr_flac_open_and_read_pcm_frames_s32(ma_dr_flac_read_proc onRead, ma_dr_flac_seek_proc onSeek, void* pUserData, unsigned int* channels, unsigned int* sampleRate, ma_uint64* totalPCMFrameCount, const ma_allocation_callbacks* pAllocationCallbacks); MA_API ma_int16* ma_dr_flac_open_and_read_pcm_frames_s16(ma_dr_flac_read_proc onRead, ma_dr_flac_seek_proc onSeek, void* pUserData, unsigned int* channels, unsigned int* sampleRate, ma_uint64* totalPCMFrameCount, const ma_allocation_callbacks* pAllocationCallbacks); MA_API float* ma_dr_flac_open_and_read_pcm_frames_f32(ma_dr_flac_read_proc onRead, ma_dr_flac_seek_proc onSeek, void* pUserData, unsigned int* channels, unsigned int* sampleRate, ma_uint64* totalPCMFrameCount, const ma_allocation_callbacks* pAllocationCallbacks); #ifndef MA_DR_FLAC_NO_STDIO MA_API ma_int32* ma_dr_flac_open_file_and_read_pcm_frames_s32(const char* filename, unsigned int* channels, unsigned int* sampleRate, ma_uint64* totalPCMFrameCount, const ma_allocation_callbacks* pAllocationCallbacks); MA_API ma_int16* ma_dr_flac_open_file_and_read_pcm_frames_s16(const char* filename, unsigned int* channels, unsigned int* sampleRate, ma_uint64* totalPCMFrameCount, const ma_allocation_callbacks* pAllocationCallbacks); MA_API float* ma_dr_flac_open_file_and_read_pcm_frames_f32(const char* filename, unsigned int* channels, unsigned int* sampleRate, ma_uint64* totalPCMFrameCount, const ma_allocation_callbacks* pAllocationCallbacks); #endif MA_API ma_int32* ma_dr_flac_open_memory_and_read_pcm_frames_s32(const void* data, size_t dataSize, unsigned int* channels, unsigned int* sampleRate, ma_uint64* totalPCMFrameCount, const ma_allocation_callbacks* pAllocationCallbacks); MA_API ma_int16* ma_dr_flac_open_memory_and_read_pcm_frames_s16(const void* data, size_t dataSize, unsigned int* channels, unsigned int* sampleRate, ma_uint64* totalPCMFrameCount, const ma_allocation_callbacks* pAllocationCallbacks); MA_API float* ma_dr_flac_open_memory_and_read_pcm_frames_f32(const void* data, size_t dataSize, unsigned int* channels, unsigned int* sampleRate, ma_uint64* totalPCMFrameCount, const ma_allocation_callbacks* pAllocationCallbacks); MA_API void ma_dr_flac_free(void* p, const ma_allocation_callbacks* pAllocationCallbacks); typedef struct { ma_uint32 countRemaining; const char* pRunningData; } ma_dr_flac_vorbis_comment_iterator; MA_API void ma_dr_flac_init_vorbis_comment_iterator(ma_dr_flac_vorbis_comment_iterator* pIter, ma_uint32 commentCount, const void* pComments); MA_API const char* ma_dr_flac_next_vorbis_comment(ma_dr_flac_vorbis_comment_iterator* pIter, ma_uint32* pCommentLengthOut); typedef struct { ma_uint32 countRemaining; const char* pRunningData; } ma_dr_flac_cuesheet_track_iterator; typedef struct { ma_uint64 offset; ma_uint8 index; ma_uint8 reserved[3]; } ma_dr_flac_cuesheet_track_index; typedef struct { ma_uint64 offset; ma_uint8 trackNumber; char ISRC[12]; ma_bool8 isAudio; ma_bool8 preEmphasis; ma_uint8 indexCount; const ma_dr_flac_cuesheet_track_index* pIndexPoints; } ma_dr_flac_cuesheet_track; MA_API void ma_dr_flac_init_cuesheet_track_iterator(ma_dr_flac_cuesheet_track_iterator* pIter, ma_uint32 trackCount, const void* pTrackData); MA_API ma_bool32 ma_dr_flac_next_cuesheet_track(ma_dr_flac_cuesheet_track_iterator* pIter, ma_dr_flac_cuesheet_track* pCuesheetTrack); #ifdef __cplusplus } #endif #endif /* dr_flac_h end */ #endif /* MA_NO_FLAC */ #if !defined(MA_NO_MP3) && !defined(MA_NO_DECODING) /* dr_mp3_h begin */ #ifndef ma_dr_mp3_h #define ma_dr_mp3_h #ifdef __cplusplus extern "C" { #endif #define MA_DR_MP3_STRINGIFY(x) #x #define MA_DR_MP3_XSTRINGIFY(x) MA_DR_MP3_STRINGIFY(x) #define MA_DR_MP3_VERSION_MAJOR 0 #define MA_DR_MP3_VERSION_MINOR 6 #define MA_DR_MP3_VERSION_REVISION 38 #define MA_DR_MP3_VERSION_STRING MA_DR_MP3_XSTRINGIFY(MA_DR_MP3_VERSION_MAJOR) "." MA_DR_MP3_XSTRINGIFY(MA_DR_MP3_VERSION_MINOR) "." MA_DR_MP3_XSTRINGIFY(MA_DR_MP3_VERSION_REVISION) #include #define MA_DR_MP3_MAX_PCM_FRAMES_PER_MP3_FRAME 1152 #define MA_DR_MP3_MAX_SAMPLES_PER_FRAME (MA_DR_MP3_MAX_PCM_FRAMES_PER_MP3_FRAME*2) MA_API void ma_dr_mp3_version(ma_uint32* pMajor, ma_uint32* pMinor, ma_uint32* pRevision); MA_API const char* ma_dr_mp3_version_string(void); typedef struct { int frame_bytes, channels, hz, layer, bitrate_kbps; } ma_dr_mp3dec_frame_info; typedef struct { float mdct_overlap[2][9*32], qmf_state[15*2*32]; int reserv, free_format_bytes; ma_uint8 header[4], reserv_buf[511]; } ma_dr_mp3dec; MA_API void ma_dr_mp3dec_init(ma_dr_mp3dec *dec); MA_API int ma_dr_mp3dec_decode_frame(ma_dr_mp3dec *dec, const ma_uint8 *mp3, int mp3_bytes, void *pcm, ma_dr_mp3dec_frame_info *info); MA_API void ma_dr_mp3dec_f32_to_s16(const float *in, ma_int16 *out, size_t num_samples); typedef enum { ma_dr_mp3_seek_origin_start, ma_dr_mp3_seek_origin_current } ma_dr_mp3_seek_origin; typedef struct { ma_uint64 seekPosInBytes; ma_uint64 pcmFrameIndex; ma_uint16 mp3FramesToDiscard; ma_uint16 pcmFramesToDiscard; } ma_dr_mp3_seek_point; typedef size_t (* ma_dr_mp3_read_proc)(void* pUserData, void* pBufferOut, size_t bytesToRead); typedef ma_bool32 (* ma_dr_mp3_seek_proc)(void* pUserData, int offset, ma_dr_mp3_seek_origin origin); typedef struct { ma_uint32 channels; ma_uint32 sampleRate; } ma_dr_mp3_config; typedef struct { ma_dr_mp3dec decoder; ma_uint32 channels; ma_uint32 sampleRate; ma_dr_mp3_read_proc onRead; ma_dr_mp3_seek_proc onSeek; void* pUserData; ma_allocation_callbacks allocationCallbacks; ma_uint32 mp3FrameChannels; ma_uint32 mp3FrameSampleRate; ma_uint32 pcmFramesConsumedInMP3Frame; ma_uint32 pcmFramesRemainingInMP3Frame; ma_uint8 pcmFrames[sizeof(float)*MA_DR_MP3_MAX_SAMPLES_PER_FRAME]; ma_uint64 currentPCMFrame; ma_uint64 streamCursor; ma_dr_mp3_seek_point* pSeekPoints; ma_uint32 seekPointCount; size_t dataSize; size_t dataCapacity; size_t dataConsumed; ma_uint8* pData; ma_bool32 atEnd : 1; struct { const ma_uint8* pData; size_t dataSize; size_t currentReadPos; } memory; } ma_dr_mp3; MA_API ma_bool32 ma_dr_mp3_init(ma_dr_mp3* pMP3, ma_dr_mp3_read_proc onRead, ma_dr_mp3_seek_proc onSeek, void* pUserData, const ma_allocation_callbacks* pAllocationCallbacks); MA_API ma_bool32 ma_dr_mp3_init_memory(ma_dr_mp3* pMP3, const void* pData, size_t dataSize, const ma_allocation_callbacks* pAllocationCallbacks); #ifndef MA_DR_MP3_NO_STDIO MA_API ma_bool32 ma_dr_mp3_init_file(ma_dr_mp3* pMP3, const char* pFilePath, const ma_allocation_callbacks* pAllocationCallbacks); MA_API ma_bool32 ma_dr_mp3_init_file_w(ma_dr_mp3* pMP3, const wchar_t* pFilePath, const ma_allocation_callbacks* pAllocationCallbacks); #endif MA_API void ma_dr_mp3_uninit(ma_dr_mp3* pMP3); MA_API ma_uint64 ma_dr_mp3_read_pcm_frames_f32(ma_dr_mp3* pMP3, ma_uint64 framesToRead, float* pBufferOut); MA_API ma_uint64 ma_dr_mp3_read_pcm_frames_s16(ma_dr_mp3* pMP3, ma_uint64 framesToRead, ma_int16* pBufferOut); MA_API ma_bool32 ma_dr_mp3_seek_to_pcm_frame(ma_dr_mp3* pMP3, ma_uint64 frameIndex); MA_API ma_uint64 ma_dr_mp3_get_pcm_frame_count(ma_dr_mp3* pMP3); MA_API ma_uint64 ma_dr_mp3_get_mp3_frame_count(ma_dr_mp3* pMP3); MA_API ma_bool32 ma_dr_mp3_get_mp3_and_pcm_frame_count(ma_dr_mp3* pMP3, ma_uint64* pMP3FrameCount, ma_uint64* pPCMFrameCount); MA_API ma_bool32 ma_dr_mp3_calculate_seek_points(ma_dr_mp3* pMP3, ma_uint32* pSeekPointCount, ma_dr_mp3_seek_point* pSeekPoints); MA_API ma_bool32 ma_dr_mp3_bind_seek_table(ma_dr_mp3* pMP3, ma_uint32 seekPointCount, ma_dr_mp3_seek_point* pSeekPoints); MA_API float* ma_dr_mp3_open_and_read_pcm_frames_f32(ma_dr_mp3_read_proc onRead, ma_dr_mp3_seek_proc onSeek, void* pUserData, ma_dr_mp3_config* pConfig, ma_uint64* pTotalFrameCount, const ma_allocation_callbacks* pAllocationCallbacks); MA_API ma_int16* ma_dr_mp3_open_and_read_pcm_frames_s16(ma_dr_mp3_read_proc onRead, ma_dr_mp3_seek_proc onSeek, void* pUserData, ma_dr_mp3_config* pConfig, ma_uint64* pTotalFrameCount, const ma_allocation_callbacks* pAllocationCallbacks); MA_API float* ma_dr_mp3_open_memory_and_read_pcm_frames_f32(const void* pData, size_t dataSize, ma_dr_mp3_config* pConfig, ma_uint64* pTotalFrameCount, const ma_allocation_callbacks* pAllocationCallbacks); MA_API ma_int16* ma_dr_mp3_open_memory_and_read_pcm_frames_s16(const void* pData, size_t dataSize, ma_dr_mp3_config* pConfig, ma_uint64* pTotalFrameCount, const ma_allocation_callbacks* pAllocationCallbacks); #ifndef MA_DR_MP3_NO_STDIO MA_API float* ma_dr_mp3_open_file_and_read_pcm_frames_f32(const char* filePath, ma_dr_mp3_config* pConfig, ma_uint64* pTotalFrameCount, const ma_allocation_callbacks* pAllocationCallbacks); MA_API ma_int16* ma_dr_mp3_open_file_and_read_pcm_frames_s16(const char* filePath, ma_dr_mp3_config* pConfig, ma_uint64* pTotalFrameCount, const ma_allocation_callbacks* pAllocationCallbacks); #endif MA_API void* ma_dr_mp3_malloc(size_t sz, const ma_allocation_callbacks* pAllocationCallbacks); MA_API void ma_dr_mp3_free(void* p, const ma_allocation_callbacks* pAllocationCallbacks); #ifdef __cplusplus } #endif #endif /* dr_mp3_h end */ #endif /* MA_NO_MP3 */ /************************************************************************************************************************************************************** Decoding **************************************************************************************************************************************************************/ #ifndef MA_NO_DECODING static ma_result ma_decoder_read_bytes(ma_decoder* pDecoder, void* pBufferOut, size_t bytesToRead, size_t* pBytesRead) { MA_ASSERT(pDecoder != NULL); return pDecoder->onRead(pDecoder, pBufferOut, bytesToRead, pBytesRead); } static ma_result ma_decoder_seek_bytes(ma_decoder* pDecoder, ma_int64 byteOffset, ma_seek_origin origin) { MA_ASSERT(pDecoder != NULL); return pDecoder->onSeek(pDecoder, byteOffset, origin); } static ma_result ma_decoder_tell_bytes(ma_decoder* pDecoder, ma_int64* pCursor) { MA_ASSERT(pDecoder != NULL); if (pDecoder->onTell == NULL) { return MA_NOT_IMPLEMENTED; } return pDecoder->onTell(pDecoder, pCursor); } MA_API ma_decoding_backend_config ma_decoding_backend_config_init(ma_format preferredFormat, ma_uint32 seekPointCount) { ma_decoding_backend_config config; MA_ZERO_OBJECT(&config); config.preferredFormat = preferredFormat; config.seekPointCount = seekPointCount; return config; } MA_API ma_decoder_config ma_decoder_config_init(ma_format outputFormat, ma_uint32 outputChannels, ma_uint32 outputSampleRate) { ma_decoder_config config; MA_ZERO_OBJECT(&config); config.format = outputFormat; config.channels = outputChannels; config.sampleRate = outputSampleRate; config.resampling = ma_resampler_config_init(ma_format_unknown, 0, 0, 0, ma_resample_algorithm_linear); /* Format/channels/rate doesn't matter here. */ config.encodingFormat = ma_encoding_format_unknown; /* Note that we are intentionally leaving the channel map empty here which will cause the default channel map to be used. */ return config; } MA_API ma_decoder_config ma_decoder_config_init_default() { return ma_decoder_config_init(ma_format_unknown, 0, 0); } MA_API ma_decoder_config ma_decoder_config_init_copy(const ma_decoder_config* pConfig) { ma_decoder_config config; if (pConfig != NULL) { config = *pConfig; } else { MA_ZERO_OBJECT(&config); } return config; } static ma_result ma_decoder__init_data_converter(ma_decoder* pDecoder, const ma_decoder_config* pConfig) { ma_result result; ma_data_converter_config converterConfig; ma_format internalFormat; ma_uint32 internalChannels; ma_uint32 internalSampleRate; ma_channel internalChannelMap[MA_MAX_CHANNELS]; MA_ASSERT(pDecoder != NULL); MA_ASSERT(pConfig != NULL); result = ma_data_source_get_data_format(pDecoder->pBackend, &internalFormat, &internalChannels, &internalSampleRate, internalChannelMap, ma_countof(internalChannelMap)); if (result != MA_SUCCESS) { return result; /* Failed to retrieve the internal data format. */ } /* Make sure we're not asking for too many channels. */ if (pConfig->channels > MA_MAX_CHANNELS) { return MA_INVALID_ARGS; } /* The internal channels should have already been validated at a higher level, but we'll do it again explicitly here for safety. */ if (internalChannels > MA_MAX_CHANNELS) { return MA_INVALID_ARGS; } /* Output format. */ if (pConfig->format == ma_format_unknown) { pDecoder->outputFormat = internalFormat; } else { pDecoder->outputFormat = pConfig->format; } if (pConfig->channels == 0) { pDecoder->outputChannels = internalChannels; } else { pDecoder->outputChannels = pConfig->channels; } if (pConfig->sampleRate == 0) { pDecoder->outputSampleRate = internalSampleRate; } else { pDecoder->outputSampleRate = pConfig->sampleRate; } converterConfig = ma_data_converter_config_init( internalFormat, pDecoder->outputFormat, internalChannels, pDecoder->outputChannels, internalSampleRate, pDecoder->outputSampleRate ); converterConfig.pChannelMapIn = internalChannelMap; converterConfig.pChannelMapOut = pConfig->pChannelMap; converterConfig.channelMixMode = pConfig->channelMixMode; converterConfig.ditherMode = pConfig->ditherMode; converterConfig.allowDynamicSampleRate = MA_FALSE; /* Never allow dynamic sample rate conversion. Setting this to true will disable passthrough optimizations. */ converterConfig.resampling = pConfig->resampling; result = ma_data_converter_init(&converterConfig, &pDecoder->allocationCallbacks, &pDecoder->converter); if (result != MA_SUCCESS) { return result; } /* Now that we have the decoder we need to determine whether or not we need a heap-allocated cache. We'll need this if the data converter does not support calculation of the required input frame count. To determine support for this we'll just run a test. */ { ma_uint64 unused; result = ma_data_converter_get_required_input_frame_count(&pDecoder->converter, 1, &unused); if (result != MA_SUCCESS) { /* We were unable to calculate the required input frame count which means we'll need to use a heap-allocated cache. */ ma_uint64 inputCacheCapSizeInBytes; pDecoder->inputCacheCap = MA_DATA_CONVERTER_STACK_BUFFER_SIZE / ma_get_bytes_per_frame(internalFormat, internalChannels); /* Not strictly necessary, but keeping here for safety in case we change the default value of pDecoder->inputCacheCap. */ inputCacheCapSizeInBytes = pDecoder->inputCacheCap * ma_get_bytes_per_frame(internalFormat, internalChannels); if (inputCacheCapSizeInBytes > MA_SIZE_MAX) { ma_data_converter_uninit(&pDecoder->converter, &pDecoder->allocationCallbacks); return MA_OUT_OF_MEMORY; } pDecoder->pInputCache = ma_malloc((size_t)inputCacheCapSizeInBytes, &pDecoder->allocationCallbacks); /* Safe cast to size_t. */ if (pDecoder->pInputCache == NULL) { ma_data_converter_uninit(&pDecoder->converter, &pDecoder->allocationCallbacks); return MA_OUT_OF_MEMORY; } } } return MA_SUCCESS; } static ma_result ma_decoder_internal_on_read__custom(void* pUserData, void* pBufferOut, size_t bytesToRead, size_t* pBytesRead) { ma_decoder* pDecoder = (ma_decoder*)pUserData; MA_ASSERT(pDecoder != NULL); return ma_decoder_read_bytes(pDecoder, pBufferOut, bytesToRead, pBytesRead); } static ma_result ma_decoder_internal_on_seek__custom(void* pUserData, ma_int64 offset, ma_seek_origin origin) { ma_decoder* pDecoder = (ma_decoder*)pUserData; MA_ASSERT(pDecoder != NULL); return ma_decoder_seek_bytes(pDecoder, offset, origin); } static ma_result ma_decoder_internal_on_tell__custom(void* pUserData, ma_int64* pCursor) { ma_decoder* pDecoder = (ma_decoder*)pUserData; MA_ASSERT(pDecoder != NULL); return ma_decoder_tell_bytes(pDecoder, pCursor); } static ma_result ma_decoder_init_from_vtable__internal(const ma_decoding_backend_vtable* pVTable, void* pVTableUserData, const ma_decoder_config* pConfig, ma_decoder* pDecoder) { ma_result result; ma_decoding_backend_config backendConfig; ma_data_source* pBackend; MA_ASSERT(pVTable != NULL); MA_ASSERT(pConfig != NULL); MA_ASSERT(pDecoder != NULL); if (pVTable->onInit == NULL) { return MA_NOT_IMPLEMENTED; } backendConfig = ma_decoding_backend_config_init(pConfig->format, pConfig->seekPointCount); result = pVTable->onInit(pVTableUserData, ma_decoder_internal_on_read__custom, ma_decoder_internal_on_seek__custom, ma_decoder_internal_on_tell__custom, pDecoder, &backendConfig, &pDecoder->allocationCallbacks, &pBackend); if (result != MA_SUCCESS) { return result; /* Failed to initialize the backend from this vtable. */ } /* Getting here means we were able to initialize the backend so we can now initialize the decoder. */ pDecoder->pBackend = pBackend; pDecoder->pBackendVTable = pVTable; pDecoder->pBackendUserData = pConfig->pCustomBackendUserData; return MA_SUCCESS; } static ma_result ma_decoder_init_from_file__internal(const ma_decoding_backend_vtable* pVTable, void* pVTableUserData, const char* pFilePath, const ma_decoder_config* pConfig, ma_decoder* pDecoder) { ma_result result; ma_decoding_backend_config backendConfig; ma_data_source* pBackend; MA_ASSERT(pVTable != NULL); MA_ASSERT(pConfig != NULL); MA_ASSERT(pDecoder != NULL); if (pVTable->onInitFile == NULL) { return MA_NOT_IMPLEMENTED; } backendConfig = ma_decoding_backend_config_init(pConfig->format, pConfig->seekPointCount); result = pVTable->onInitFile(pVTableUserData, pFilePath, &backendConfig, &pDecoder->allocationCallbacks, &pBackend); if (result != MA_SUCCESS) { return result; /* Failed to initialize the backend from this vtable. */ } /* Getting here means we were able to initialize the backend so we can now initialize the decoder. */ pDecoder->pBackend = pBackend; pDecoder->pBackendVTable = pVTable; pDecoder->pBackendUserData = pConfig->pCustomBackendUserData; return MA_SUCCESS; } static ma_result ma_decoder_init_from_file_w__internal(const ma_decoding_backend_vtable* pVTable, void* pVTableUserData, const wchar_t* pFilePath, const ma_decoder_config* pConfig, ma_decoder* pDecoder) { ma_result result; ma_decoding_backend_config backendConfig; ma_data_source* pBackend; MA_ASSERT(pVTable != NULL); MA_ASSERT(pConfig != NULL); MA_ASSERT(pDecoder != NULL); if (pVTable->onInitFileW == NULL) { return MA_NOT_IMPLEMENTED; } backendConfig = ma_decoding_backend_config_init(pConfig->format, pConfig->seekPointCount); result = pVTable->onInitFileW(pVTableUserData, pFilePath, &backendConfig, &pDecoder->allocationCallbacks, &pBackend); if (result != MA_SUCCESS) { return result; /* Failed to initialize the backend from this vtable. */ } /* Getting here means we were able to initialize the backend so we can now initialize the decoder. */ pDecoder->pBackend = pBackend; pDecoder->pBackendVTable = pVTable; pDecoder->pBackendUserData = pConfig->pCustomBackendUserData; return MA_SUCCESS; } static ma_result ma_decoder_init_from_memory__internal(const ma_decoding_backend_vtable* pVTable, void* pVTableUserData, const void* pData, size_t dataSize, const ma_decoder_config* pConfig, ma_decoder* pDecoder) { ma_result result; ma_decoding_backend_config backendConfig; ma_data_source* pBackend; MA_ASSERT(pVTable != NULL); MA_ASSERT(pConfig != NULL); MA_ASSERT(pDecoder != NULL); if (pVTable->onInitMemory == NULL) { return MA_NOT_IMPLEMENTED; } backendConfig = ma_decoding_backend_config_init(pConfig->format, pConfig->seekPointCount); result = pVTable->onInitMemory(pVTableUserData, pData, dataSize, &backendConfig, &pDecoder->allocationCallbacks, &pBackend); if (result != MA_SUCCESS) { return result; /* Failed to initialize the backend from this vtable. */ } /* Getting here means we were able to initialize the backend so we can now initialize the decoder. */ pDecoder->pBackend = pBackend; pDecoder->pBackendVTable = pVTable; pDecoder->pBackendUserData = pConfig->pCustomBackendUserData; return MA_SUCCESS; } static ma_result ma_decoder_init_custom__internal(const ma_decoder_config* pConfig, ma_decoder* pDecoder) { ma_result result = MA_NO_BACKEND; size_t ivtable; MA_ASSERT(pConfig != NULL); MA_ASSERT(pDecoder != NULL); if (pConfig->ppCustomBackendVTables == NULL) { return MA_NO_BACKEND; } /* The order each backend is listed is what defines the priority. */ for (ivtable = 0; ivtable < pConfig->customBackendCount; ivtable += 1) { const ma_decoding_backend_vtable* pVTable = pConfig->ppCustomBackendVTables[ivtable]; if (pVTable != NULL) { result = ma_decoder_init_from_vtable__internal(pVTable, pConfig->pCustomBackendUserData, pConfig, pDecoder); if (result == MA_SUCCESS) { return MA_SUCCESS; } else { /* Initialization failed. Move on to the next one, but seek back to the start first so the next vtable starts from the first byte of the file. */ result = ma_decoder_seek_bytes(pDecoder, 0, ma_seek_origin_start); if (result != MA_SUCCESS) { return result; /* Failed to seek back to the start. */ } } } else { /* No vtable. */ } } /* Getting here means we couldn't find a backend. */ return MA_NO_BACKEND; } static ma_result ma_decoder_init_custom_from_file__internal(const char* pFilePath, const ma_decoder_config* pConfig, ma_decoder* pDecoder) { ma_result result = MA_NO_BACKEND; size_t ivtable; MA_ASSERT(pConfig != NULL); MA_ASSERT(pDecoder != NULL); if (pConfig->ppCustomBackendVTables == NULL) { return MA_NO_BACKEND; } /* The order each backend is listed is what defines the priority. */ for (ivtable = 0; ivtable < pConfig->customBackendCount; ivtable += 1) { const ma_decoding_backend_vtable* pVTable = pConfig->ppCustomBackendVTables[ivtable]; if (pVTable != NULL) { result = ma_decoder_init_from_file__internal(pVTable, pConfig->pCustomBackendUserData, pFilePath, pConfig, pDecoder); if (result == MA_SUCCESS) { return MA_SUCCESS; } } else { /* No vtable. */ } } /* Getting here means we couldn't find a backend. */ return MA_NO_BACKEND; } static ma_result ma_decoder_init_custom_from_file_w__internal(const wchar_t* pFilePath, const ma_decoder_config* pConfig, ma_decoder* pDecoder) { ma_result result = MA_NO_BACKEND; size_t ivtable; MA_ASSERT(pConfig != NULL); MA_ASSERT(pDecoder != NULL); if (pConfig->ppCustomBackendVTables == NULL) { return MA_NO_BACKEND; } /* The order each backend is listed is what defines the priority. */ for (ivtable = 0; ivtable < pConfig->customBackendCount; ivtable += 1) { const ma_decoding_backend_vtable* pVTable = pConfig->ppCustomBackendVTables[ivtable]; if (pVTable != NULL) { result = ma_decoder_init_from_file_w__internal(pVTable, pConfig->pCustomBackendUserData, pFilePath, pConfig, pDecoder); if (result == MA_SUCCESS) { return MA_SUCCESS; } } else { /* No vtable. */ } } /* Getting here means we couldn't find a backend. */ return MA_NO_BACKEND; } static ma_result ma_decoder_init_custom_from_memory__internal(const void* pData, size_t dataSize, const ma_decoder_config* pConfig, ma_decoder* pDecoder) { ma_result result = MA_NO_BACKEND; size_t ivtable; MA_ASSERT(pConfig != NULL); MA_ASSERT(pDecoder != NULL); if (pConfig->ppCustomBackendVTables == NULL) { return MA_NO_BACKEND; } /* The order each backend is listed is what defines the priority. */ for (ivtable = 0; ivtable < pConfig->customBackendCount; ivtable += 1) { const ma_decoding_backend_vtable* pVTable = pConfig->ppCustomBackendVTables[ivtable]; if (pVTable != NULL) { result = ma_decoder_init_from_memory__internal(pVTable, pConfig->pCustomBackendUserData, pData, dataSize, pConfig, pDecoder); if (result == MA_SUCCESS) { return MA_SUCCESS; } } else { /* No vtable. */ } } /* Getting here means we couldn't find a backend. */ return MA_NO_BACKEND; } /* WAV */ #ifdef ma_dr_wav_h #define MA_HAS_WAV typedef struct { ma_data_source_base ds; ma_read_proc onRead; ma_seek_proc onSeek; ma_tell_proc onTell; void* pReadSeekTellUserData; ma_format format; /* Can be f32, s16 or s32. */ #if !defined(MA_NO_WAV) ma_dr_wav dr; #endif } ma_wav; MA_API ma_result ma_wav_init(ma_read_proc onRead, ma_seek_proc onSeek, ma_tell_proc onTell, void* pReadSeekTellUserData, const ma_decoding_backend_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_wav* pWav); MA_API ma_result ma_wav_init_file(const char* pFilePath, const ma_decoding_backend_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_wav* pWav); MA_API ma_result ma_wav_init_file_w(const wchar_t* pFilePath, const ma_decoding_backend_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_wav* pWav); MA_API ma_result ma_wav_init_memory(const void* pData, size_t dataSize, const ma_decoding_backend_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_wav* pWav); MA_API void ma_wav_uninit(ma_wav* pWav, const ma_allocation_callbacks* pAllocationCallbacks); MA_API ma_result ma_wav_read_pcm_frames(ma_wav* pWav, void* pFramesOut, ma_uint64 frameCount, ma_uint64* pFramesRead); MA_API ma_result ma_wav_seek_to_pcm_frame(ma_wav* pWav, ma_uint64 frameIndex); MA_API ma_result ma_wav_get_data_format(ma_wav* pWav, ma_format* pFormat, ma_uint32* pChannels, ma_uint32* pSampleRate, ma_channel* pChannelMap, size_t channelMapCap); MA_API ma_result ma_wav_get_cursor_in_pcm_frames(ma_wav* pWav, ma_uint64* pCursor); MA_API ma_result ma_wav_get_length_in_pcm_frames(ma_wav* pWav, ma_uint64* pLength); static ma_result ma_wav_ds_read(ma_data_source* pDataSource, void* pFramesOut, ma_uint64 frameCount, ma_uint64* pFramesRead) { return ma_wav_read_pcm_frames((ma_wav*)pDataSource, pFramesOut, frameCount, pFramesRead); } static ma_result ma_wav_ds_seek(ma_data_source* pDataSource, ma_uint64 frameIndex) { return ma_wav_seek_to_pcm_frame((ma_wav*)pDataSource, frameIndex); } static ma_result ma_wav_ds_get_data_format(ma_data_source* pDataSource, ma_format* pFormat, ma_uint32* pChannels, ma_uint32* pSampleRate, ma_channel* pChannelMap, size_t channelMapCap) { return ma_wav_get_data_format((ma_wav*)pDataSource, pFormat, pChannels, pSampleRate, pChannelMap, channelMapCap); } static ma_result ma_wav_ds_get_cursor(ma_data_source* pDataSource, ma_uint64* pCursor) { return ma_wav_get_cursor_in_pcm_frames((ma_wav*)pDataSource, pCursor); } static ma_result ma_wav_ds_get_length(ma_data_source* pDataSource, ma_uint64* pLength) { return ma_wav_get_length_in_pcm_frames((ma_wav*)pDataSource, pLength); } static ma_data_source_vtable g_ma_wav_ds_vtable = { ma_wav_ds_read, ma_wav_ds_seek, ma_wav_ds_get_data_format, ma_wav_ds_get_cursor, ma_wav_ds_get_length, NULL, /* onSetLooping */ 0 }; #if !defined(MA_NO_WAV) static size_t ma_wav_dr_callback__read(void* pUserData, void* pBufferOut, size_t bytesToRead) { ma_wav* pWav = (ma_wav*)pUserData; ma_result result; size_t bytesRead; MA_ASSERT(pWav != NULL); result = pWav->onRead(pWav->pReadSeekTellUserData, pBufferOut, bytesToRead, &bytesRead); (void)result; return bytesRead; } static ma_bool32 ma_wav_dr_callback__seek(void* pUserData, int offset, ma_dr_wav_seek_origin origin) { ma_wav* pWav = (ma_wav*)pUserData; ma_result result; ma_seek_origin maSeekOrigin; MA_ASSERT(pWav != NULL); maSeekOrigin = ma_seek_origin_start; if (origin == ma_dr_wav_seek_origin_current) { maSeekOrigin = ma_seek_origin_current; } result = pWav->onSeek(pWav->pReadSeekTellUserData, offset, maSeekOrigin); if (result != MA_SUCCESS) { return MA_FALSE; } return MA_TRUE; } #endif static ma_result ma_wav_init_internal(const ma_decoding_backend_config* pConfig, ma_wav* pWav) { ma_result result; ma_data_source_config dataSourceConfig; if (pWav == NULL) { return MA_INVALID_ARGS; } MA_ZERO_OBJECT(pWav); pWav->format = ma_format_unknown; /* Use closest match to source file by default. */ if (pConfig != NULL && (pConfig->preferredFormat == ma_format_f32 || pConfig->preferredFormat == ma_format_s16 || pConfig->preferredFormat == ma_format_s32)) { pWav->format = pConfig->preferredFormat; } else { /* Getting here means something other than f32 and s16 was specified. Just leave this unset to use the default format. */ } dataSourceConfig = ma_data_source_config_init(); dataSourceConfig.vtable = &g_ma_wav_ds_vtable; result = ma_data_source_init(&dataSourceConfig, &pWav->ds); if (result != MA_SUCCESS) { return result; /* Failed to initialize the base data source. */ } return MA_SUCCESS; } static ma_result ma_wav_post_init(ma_wav* pWav) { /* If an explicit format was not specified, try picking the closest match based on the internal format. The format needs to be supported by miniaudio. */ if (pWav->format == ma_format_unknown) { switch (pWav->dr.translatedFormatTag) { case MA_DR_WAVE_FORMAT_PCM: { if (pWav->dr.bitsPerSample == 8) { pWav->format = ma_format_u8; } else if (pWav->dr.bitsPerSample == 16) { pWav->format = ma_format_s16; } else if (pWav->dr.bitsPerSample == 24) { pWav->format = ma_format_s24; } else if (pWav->dr.bitsPerSample == 32) { pWav->format = ma_format_s32; } } break; case MA_DR_WAVE_FORMAT_IEEE_FLOAT: { if (pWav->dr.bitsPerSample == 32) { pWav->format = ma_format_f32; } } break; default: break; } /* Fall back to f32 if we couldn't find anything. */ if (pWav->format == ma_format_unknown) { pWav->format = ma_format_f32; } } return MA_SUCCESS; } MA_API ma_result ma_wav_init(ma_read_proc onRead, ma_seek_proc onSeek, ma_tell_proc onTell, void* pReadSeekTellUserData, const ma_decoding_backend_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_wav* pWav) { ma_result result; result = ma_wav_init_internal(pConfig, pWav); if (result != MA_SUCCESS) { return result; } if (onRead == NULL || onSeek == NULL) { return MA_INVALID_ARGS; /* onRead and onSeek are mandatory. */ } pWav->onRead = onRead; pWav->onSeek = onSeek; pWav->onTell = onTell; pWav->pReadSeekTellUserData = pReadSeekTellUserData; #if !defined(MA_NO_WAV) { ma_bool32 wavResult; wavResult = ma_dr_wav_init(&pWav->dr, ma_wav_dr_callback__read, ma_wav_dr_callback__seek, pWav, pAllocationCallbacks); if (wavResult != MA_TRUE) { return MA_INVALID_FILE; } ma_wav_post_init(pWav); return MA_SUCCESS; } #else { /* wav is disabled. */ (void)pAllocationCallbacks; return MA_NOT_IMPLEMENTED; } #endif } MA_API ma_result ma_wav_init_file(const char* pFilePath, const ma_decoding_backend_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_wav* pWav) { ma_result result; result = ma_wav_init_internal(pConfig, pWav); if (result != MA_SUCCESS) { return result; } #if !defined(MA_NO_WAV) { ma_bool32 wavResult; wavResult = ma_dr_wav_init_file(&pWav->dr, pFilePath, pAllocationCallbacks); if (wavResult != MA_TRUE) { return MA_INVALID_FILE; } ma_wav_post_init(pWav); return MA_SUCCESS; } #else { /* wav is disabled. */ (void)pFilePath; (void)pAllocationCallbacks; return MA_NOT_IMPLEMENTED; } #endif } MA_API ma_result ma_wav_init_file_w(const wchar_t* pFilePath, const ma_decoding_backend_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_wav* pWav) { ma_result result; result = ma_wav_init_internal(pConfig, pWav); if (result != MA_SUCCESS) { return result; } #if !defined(MA_NO_WAV) { ma_bool32 wavResult; wavResult = ma_dr_wav_init_file_w(&pWav->dr, pFilePath, pAllocationCallbacks); if (wavResult != MA_TRUE) { return MA_INVALID_FILE; } ma_wav_post_init(pWav); return MA_SUCCESS; } #else { /* wav is disabled. */ (void)pFilePath; (void)pAllocationCallbacks; return MA_NOT_IMPLEMENTED; } #endif } MA_API ma_result ma_wav_init_memory(const void* pData, size_t dataSize, const ma_decoding_backend_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_wav* pWav) { ma_result result; result = ma_wav_init_internal(pConfig, pWav); if (result != MA_SUCCESS) { return result; } #if !defined(MA_NO_WAV) { ma_bool32 wavResult; wavResult = ma_dr_wav_init_memory(&pWav->dr, pData, dataSize, pAllocationCallbacks); if (wavResult != MA_TRUE) { return MA_INVALID_FILE; } ma_wav_post_init(pWav); return MA_SUCCESS; } #else { /* wav is disabled. */ (void)pData; (void)dataSize; (void)pAllocationCallbacks; return MA_NOT_IMPLEMENTED; } #endif } MA_API void ma_wav_uninit(ma_wav* pWav, const ma_allocation_callbacks* pAllocationCallbacks) { if (pWav == NULL) { return; } (void)pAllocationCallbacks; #if !defined(MA_NO_WAV) { ma_dr_wav_uninit(&pWav->dr); } #else { /* wav is disabled. Should never hit this since initialization would have failed. */ MA_ASSERT(MA_FALSE); } #endif ma_data_source_uninit(&pWav->ds); } MA_API ma_result ma_wav_read_pcm_frames(ma_wav* pWav, void* pFramesOut, ma_uint64 frameCount, ma_uint64* pFramesRead) { if (pFramesRead != NULL) { *pFramesRead = 0; } if (frameCount == 0) { return MA_INVALID_ARGS; } if (pWav == NULL) { return MA_INVALID_ARGS; } #if !defined(MA_NO_WAV) { /* We always use floating point format. */ ma_result result = MA_SUCCESS; /* Must be initialized to MA_SUCCESS. */ ma_uint64 totalFramesRead = 0; ma_format format; ma_wav_get_data_format(pWav, &format, NULL, NULL, NULL, 0); switch (format) { case ma_format_f32: { totalFramesRead = ma_dr_wav_read_pcm_frames_f32(&pWav->dr, frameCount, (float*)pFramesOut); } break; case ma_format_s16: { totalFramesRead = ma_dr_wav_read_pcm_frames_s16(&pWav->dr, frameCount, (ma_int16*)pFramesOut); } break; case ma_format_s32: { totalFramesRead = ma_dr_wav_read_pcm_frames_s32(&pWav->dr, frameCount, (ma_int32*)pFramesOut); } break; /* Fallback to a raw read. */ case ma_format_unknown: return MA_INVALID_OPERATION; /* <-- this should never be hit because initialization would just fall back to a supported format. */ default: { totalFramesRead = ma_dr_wav_read_pcm_frames(&pWav->dr, frameCount, pFramesOut); } break; } /* In the future we'll update ma_dr_wav to return MA_AT_END for us. */ if (totalFramesRead == 0) { result = MA_AT_END; } if (pFramesRead != NULL) { *pFramesRead = totalFramesRead; } if (result == MA_SUCCESS && totalFramesRead == 0) { result = MA_AT_END; } return result; } #else { /* wav is disabled. Should never hit this since initialization would have failed. */ MA_ASSERT(MA_FALSE); (void)pFramesOut; (void)frameCount; (void)pFramesRead; return MA_NOT_IMPLEMENTED; } #endif } MA_API ma_result ma_wav_seek_to_pcm_frame(ma_wav* pWav, ma_uint64 frameIndex) { if (pWav == NULL) { return MA_INVALID_ARGS; } #if !defined(MA_NO_WAV) { ma_bool32 wavResult; wavResult = ma_dr_wav_seek_to_pcm_frame(&pWav->dr, frameIndex); if (wavResult != MA_TRUE) { return MA_ERROR; } return MA_SUCCESS; } #else { /* wav is disabled. Should never hit this since initialization would have failed. */ MA_ASSERT(MA_FALSE); (void)frameIndex; return MA_NOT_IMPLEMENTED; } #endif } MA_API ma_result ma_wav_get_data_format(ma_wav* pWav, ma_format* pFormat, ma_uint32* pChannels, ma_uint32* pSampleRate, ma_channel* pChannelMap, size_t channelMapCap) { /* Defaults for safety. */ if (pFormat != NULL) { *pFormat = ma_format_unknown; } if (pChannels != NULL) { *pChannels = 0; } if (pSampleRate != NULL) { *pSampleRate = 0; } if (pChannelMap != NULL) { MA_ZERO_MEMORY(pChannelMap, sizeof(*pChannelMap) * channelMapCap); } if (pWav == NULL) { return MA_INVALID_OPERATION; } if (pFormat != NULL) { *pFormat = pWav->format; } #if !defined(MA_NO_WAV) { if (pChannels != NULL) { *pChannels = pWav->dr.channels; } if (pSampleRate != NULL) { *pSampleRate = pWav->dr.sampleRate; } if (pChannelMap != NULL) { ma_channel_map_init_standard(ma_standard_channel_map_microsoft, pChannelMap, channelMapCap, pWav->dr.channels); } return MA_SUCCESS; } #else { /* wav is disabled. Should never hit this since initialization would have failed. */ MA_ASSERT(MA_FALSE); return MA_NOT_IMPLEMENTED; } #endif } MA_API ma_result ma_wav_get_cursor_in_pcm_frames(ma_wav* pWav, ma_uint64* pCursor) { if (pCursor == NULL) { return MA_INVALID_ARGS; } *pCursor = 0; /* Safety. */ if (pWav == NULL) { return MA_INVALID_ARGS; } #if !defined(MA_NO_WAV) { ma_result wavResult = ma_dr_wav_get_cursor_in_pcm_frames(&pWav->dr, pCursor); if (wavResult != MA_SUCCESS) { return (ma_result)wavResult; /* ma_dr_wav result codes map to miniaudio's. */ } return MA_SUCCESS; } #else { /* wav is disabled. Should never hit this since initialization would have failed. */ MA_ASSERT(MA_FALSE); return MA_NOT_IMPLEMENTED; } #endif } MA_API ma_result ma_wav_get_length_in_pcm_frames(ma_wav* pWav, ma_uint64* pLength) { if (pLength == NULL) { return MA_INVALID_ARGS; } *pLength = 0; /* Safety. */ if (pWav == NULL) { return MA_INVALID_ARGS; } #if !defined(MA_NO_WAV) { ma_result wavResult = ma_dr_wav_get_length_in_pcm_frames(&pWav->dr, pLength); if (wavResult != MA_SUCCESS) { return (ma_result)wavResult; /* ma_dr_wav result codes map to miniaudio's. */ } return MA_SUCCESS; } #else { /* wav is disabled. Should never hit this since initialization would have failed. */ MA_ASSERT(MA_FALSE); return MA_NOT_IMPLEMENTED; } #endif } static ma_result ma_decoding_backend_init__wav(void* pUserData, ma_read_proc onRead, ma_seek_proc onSeek, ma_tell_proc onTell, void* pReadSeekTellUserData, const ma_decoding_backend_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_data_source** ppBackend) { ma_result result; ma_wav* pWav; (void)pUserData; /* For now not using pUserData, but once we start storing the vorbis decoder state within the ma_decoder structure this will be set to the decoder so we can avoid a malloc. */ /* For now we're just allocating the decoder backend on the heap. */ pWav = (ma_wav*)ma_malloc(sizeof(*pWav), pAllocationCallbacks); if (pWav == NULL) { return MA_OUT_OF_MEMORY; } result = ma_wav_init(onRead, onSeek, onTell, pReadSeekTellUserData, pConfig, pAllocationCallbacks, pWav); if (result != MA_SUCCESS) { ma_free(pWav, pAllocationCallbacks); return result; } *ppBackend = pWav; return MA_SUCCESS; } static ma_result ma_decoding_backend_init_file__wav(void* pUserData, const char* pFilePath, const ma_decoding_backend_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_data_source** ppBackend) { ma_result result; ma_wav* pWav; (void)pUserData; /* For now not using pUserData, but once we start storing the vorbis decoder state within the ma_decoder structure this will be set to the decoder so we can avoid a malloc. */ /* For now we're just allocating the decoder backend on the heap. */ pWav = (ma_wav*)ma_malloc(sizeof(*pWav), pAllocationCallbacks); if (pWav == NULL) { return MA_OUT_OF_MEMORY; } result = ma_wav_init_file(pFilePath, pConfig, pAllocationCallbacks, pWav); if (result != MA_SUCCESS) { ma_free(pWav, pAllocationCallbacks); return result; } *ppBackend = pWav; return MA_SUCCESS; } static ma_result ma_decoding_backend_init_file_w__wav(void* pUserData, const wchar_t* pFilePath, const ma_decoding_backend_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_data_source** ppBackend) { ma_result result; ma_wav* pWav; (void)pUserData; /* For now not using pUserData, but once we start storing the vorbis decoder state within the ma_decoder structure this will be set to the decoder so we can avoid a malloc. */ /* For now we're just allocating the decoder backend on the heap. */ pWav = (ma_wav*)ma_malloc(sizeof(*pWav), pAllocationCallbacks); if (pWav == NULL) { return MA_OUT_OF_MEMORY; } result = ma_wav_init_file_w(pFilePath, pConfig, pAllocationCallbacks, pWav); if (result != MA_SUCCESS) { ma_free(pWav, pAllocationCallbacks); return result; } *ppBackend = pWav; return MA_SUCCESS; } static ma_result ma_decoding_backend_init_memory__wav(void* pUserData, const void* pData, size_t dataSize, const ma_decoding_backend_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_data_source** ppBackend) { ma_result result; ma_wav* pWav; (void)pUserData; /* For now not using pUserData, but once we start storing the vorbis decoder state within the ma_decoder structure this will be set to the decoder so we can avoid a malloc. */ /* For now we're just allocating the decoder backend on the heap. */ pWav = (ma_wav*)ma_malloc(sizeof(*pWav), pAllocationCallbacks); if (pWav == NULL) { return MA_OUT_OF_MEMORY; } result = ma_wav_init_memory(pData, dataSize, pConfig, pAllocationCallbacks, pWav); if (result != MA_SUCCESS) { ma_free(pWav, pAllocationCallbacks); return result; } *ppBackend = pWav; return MA_SUCCESS; } static void ma_decoding_backend_uninit__wav(void* pUserData, ma_data_source* pBackend, const ma_allocation_callbacks* pAllocationCallbacks) { ma_wav* pWav = (ma_wav*)pBackend; (void)pUserData; ma_wav_uninit(pWav, pAllocationCallbacks); ma_free(pWav, pAllocationCallbacks); } static ma_decoding_backend_vtable g_ma_decoding_backend_vtable_wav = { ma_decoding_backend_init__wav, ma_decoding_backend_init_file__wav, ma_decoding_backend_init_file_w__wav, ma_decoding_backend_init_memory__wav, ma_decoding_backend_uninit__wav }; static ma_result ma_decoder_init_wav__internal(const ma_decoder_config* pConfig, ma_decoder* pDecoder) { return ma_decoder_init_from_vtable__internal(&g_ma_decoding_backend_vtable_wav, NULL, pConfig, pDecoder); } static ma_result ma_decoder_init_wav_from_file__internal(const char* pFilePath, const ma_decoder_config* pConfig, ma_decoder* pDecoder) { return ma_decoder_init_from_file__internal(&g_ma_decoding_backend_vtable_wav, NULL, pFilePath, pConfig, pDecoder); } static ma_result ma_decoder_init_wav_from_file_w__internal(const wchar_t* pFilePath, const ma_decoder_config* pConfig, ma_decoder* pDecoder) { return ma_decoder_init_from_file_w__internal(&g_ma_decoding_backend_vtable_wav, NULL, pFilePath, pConfig, pDecoder); } static ma_result ma_decoder_init_wav_from_memory__internal(const void* pData, size_t dataSize, const ma_decoder_config* pConfig, ma_decoder* pDecoder) { return ma_decoder_init_from_memory__internal(&g_ma_decoding_backend_vtable_wav, NULL, pData, dataSize, pConfig, pDecoder); } #endif /* ma_dr_wav_h */ /* FLAC */ #ifdef ma_dr_flac_h #define MA_HAS_FLAC typedef struct { ma_data_source_base ds; ma_read_proc onRead; ma_seek_proc onSeek; ma_tell_proc onTell; void* pReadSeekTellUserData; ma_format format; /* Can be f32, s16 or s32. */ #if !defined(MA_NO_FLAC) ma_dr_flac* dr; #endif } ma_flac; MA_API ma_result ma_flac_init(ma_read_proc onRead, ma_seek_proc onSeek, ma_tell_proc onTell, void* pReadSeekTellUserData, const ma_decoding_backend_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_flac* pFlac); MA_API ma_result ma_flac_init_file(const char* pFilePath, const ma_decoding_backend_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_flac* pFlac); MA_API ma_result ma_flac_init_file_w(const wchar_t* pFilePath, const ma_decoding_backend_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_flac* pFlac); MA_API ma_result ma_flac_init_memory(const void* pData, size_t dataSize, const ma_decoding_backend_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_flac* pFlac); MA_API void ma_flac_uninit(ma_flac* pFlac, const ma_allocation_callbacks* pAllocationCallbacks); MA_API ma_result ma_flac_read_pcm_frames(ma_flac* pFlac, void* pFramesOut, ma_uint64 frameCount, ma_uint64* pFramesRead); MA_API ma_result ma_flac_seek_to_pcm_frame(ma_flac* pFlac, ma_uint64 frameIndex); MA_API ma_result ma_flac_get_data_format(ma_flac* pFlac, ma_format* pFormat, ma_uint32* pChannels, ma_uint32* pSampleRate, ma_channel* pChannelMap, size_t channelMapCap); MA_API ma_result ma_flac_get_cursor_in_pcm_frames(ma_flac* pFlac, ma_uint64* pCursor); MA_API ma_result ma_flac_get_length_in_pcm_frames(ma_flac* pFlac, ma_uint64* pLength); static ma_result ma_flac_ds_read(ma_data_source* pDataSource, void* pFramesOut, ma_uint64 frameCount, ma_uint64* pFramesRead) { return ma_flac_read_pcm_frames((ma_flac*)pDataSource, pFramesOut, frameCount, pFramesRead); } static ma_result ma_flac_ds_seek(ma_data_source* pDataSource, ma_uint64 frameIndex) { return ma_flac_seek_to_pcm_frame((ma_flac*)pDataSource, frameIndex); } static ma_result ma_flac_ds_get_data_format(ma_data_source* pDataSource, ma_format* pFormat, ma_uint32* pChannels, ma_uint32* pSampleRate, ma_channel* pChannelMap, size_t channelMapCap) { return ma_flac_get_data_format((ma_flac*)pDataSource, pFormat, pChannels, pSampleRate, pChannelMap, channelMapCap); } static ma_result ma_flac_ds_get_cursor(ma_data_source* pDataSource, ma_uint64* pCursor) { return ma_flac_get_cursor_in_pcm_frames((ma_flac*)pDataSource, pCursor); } static ma_result ma_flac_ds_get_length(ma_data_source* pDataSource, ma_uint64* pLength) { return ma_flac_get_length_in_pcm_frames((ma_flac*)pDataSource, pLength); } static ma_data_source_vtable g_ma_flac_ds_vtable = { ma_flac_ds_read, ma_flac_ds_seek, ma_flac_ds_get_data_format, ma_flac_ds_get_cursor, ma_flac_ds_get_length, NULL, /* onSetLooping */ 0 }; #if !defined(MA_NO_FLAC) static size_t ma_flac_dr_callback__read(void* pUserData, void* pBufferOut, size_t bytesToRead) { ma_flac* pFlac = (ma_flac*)pUserData; ma_result result; size_t bytesRead; MA_ASSERT(pFlac != NULL); result = pFlac->onRead(pFlac->pReadSeekTellUserData, pBufferOut, bytesToRead, &bytesRead); (void)result; return bytesRead; } static ma_bool32 ma_flac_dr_callback__seek(void* pUserData, int offset, ma_dr_flac_seek_origin origin) { ma_flac* pFlac = (ma_flac*)pUserData; ma_result result; ma_seek_origin maSeekOrigin; MA_ASSERT(pFlac != NULL); maSeekOrigin = ma_seek_origin_start; if (origin == ma_dr_flac_seek_origin_current) { maSeekOrigin = ma_seek_origin_current; } result = pFlac->onSeek(pFlac->pReadSeekTellUserData, offset, maSeekOrigin); if (result != MA_SUCCESS) { return MA_FALSE; } return MA_TRUE; } #endif static ma_result ma_flac_init_internal(const ma_decoding_backend_config* pConfig, ma_flac* pFlac) { ma_result result; ma_data_source_config dataSourceConfig; if (pFlac == NULL) { return MA_INVALID_ARGS; } MA_ZERO_OBJECT(pFlac); pFlac->format = ma_format_f32; /* f32 by default. */ if (pConfig != NULL && (pConfig->preferredFormat == ma_format_f32 || pConfig->preferredFormat == ma_format_s16 || pConfig->preferredFormat == ma_format_s32)) { pFlac->format = pConfig->preferredFormat; } else { /* Getting here means something other than f32 and s16 was specified. Just leave this unset to use the default format. */ } dataSourceConfig = ma_data_source_config_init(); dataSourceConfig.vtable = &g_ma_flac_ds_vtable; result = ma_data_source_init(&dataSourceConfig, &pFlac->ds); if (result != MA_SUCCESS) { return result; /* Failed to initialize the base data source. */ } return MA_SUCCESS; } MA_API ma_result ma_flac_init(ma_read_proc onRead, ma_seek_proc onSeek, ma_tell_proc onTell, void* pReadSeekTellUserData, const ma_decoding_backend_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_flac* pFlac) { ma_result result; result = ma_flac_init_internal(pConfig, pFlac); if (result != MA_SUCCESS) { return result; } if (onRead == NULL || onSeek == NULL) { return MA_INVALID_ARGS; /* onRead and onSeek are mandatory. */ } pFlac->onRead = onRead; pFlac->onSeek = onSeek; pFlac->onTell = onTell; pFlac->pReadSeekTellUserData = pReadSeekTellUserData; #if !defined(MA_NO_FLAC) { pFlac->dr = ma_dr_flac_open(ma_flac_dr_callback__read, ma_flac_dr_callback__seek, pFlac, pAllocationCallbacks); if (pFlac->dr == NULL) { return MA_INVALID_FILE; } return MA_SUCCESS; } #else { /* flac is disabled. */ (void)pAllocationCallbacks; return MA_NOT_IMPLEMENTED; } #endif } MA_API ma_result ma_flac_init_file(const char* pFilePath, const ma_decoding_backend_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_flac* pFlac) { ma_result result; result = ma_flac_init_internal(pConfig, pFlac); if (result != MA_SUCCESS) { return result; } #if !defined(MA_NO_FLAC) { pFlac->dr = ma_dr_flac_open_file(pFilePath, pAllocationCallbacks); if (pFlac->dr == NULL) { return MA_INVALID_FILE; } return MA_SUCCESS; } #else { /* flac is disabled. */ (void)pFilePath; (void)pAllocationCallbacks; return MA_NOT_IMPLEMENTED; } #endif } MA_API ma_result ma_flac_init_file_w(const wchar_t* pFilePath, const ma_decoding_backend_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_flac* pFlac) { ma_result result; result = ma_flac_init_internal(pConfig, pFlac); if (result != MA_SUCCESS) { return result; } #if !defined(MA_NO_FLAC) { pFlac->dr = ma_dr_flac_open_file_w(pFilePath, pAllocationCallbacks); if (pFlac->dr == NULL) { return MA_INVALID_FILE; } return MA_SUCCESS; } #else { /* flac is disabled. */ (void)pFilePath; (void)pAllocationCallbacks; return MA_NOT_IMPLEMENTED; } #endif } MA_API ma_result ma_flac_init_memory(const void* pData, size_t dataSize, const ma_decoding_backend_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_flac* pFlac) { ma_result result; result = ma_flac_init_internal(pConfig, pFlac); if (result != MA_SUCCESS) { return result; } #if !defined(MA_NO_FLAC) { pFlac->dr = ma_dr_flac_open_memory(pData, dataSize, pAllocationCallbacks); if (pFlac->dr == NULL) { return MA_INVALID_FILE; } return MA_SUCCESS; } #else { /* flac is disabled. */ (void)pData; (void)dataSize; (void)pAllocationCallbacks; return MA_NOT_IMPLEMENTED; } #endif } MA_API void ma_flac_uninit(ma_flac* pFlac, const ma_allocation_callbacks* pAllocationCallbacks) { if (pFlac == NULL) { return; } (void)pAllocationCallbacks; #if !defined(MA_NO_FLAC) { ma_dr_flac_close(pFlac->dr); } #else { /* flac is disabled. Should never hit this since initialization would have failed. */ MA_ASSERT(MA_FALSE); } #endif ma_data_source_uninit(&pFlac->ds); } MA_API ma_result ma_flac_read_pcm_frames(ma_flac* pFlac, void* pFramesOut, ma_uint64 frameCount, ma_uint64* pFramesRead) { if (pFramesRead != NULL) { *pFramesRead = 0; } if (frameCount == 0) { return MA_INVALID_ARGS; } if (pFlac == NULL) { return MA_INVALID_ARGS; } #if !defined(MA_NO_FLAC) { /* We always use floating point format. */ ma_result result = MA_SUCCESS; /* Must be initialized to MA_SUCCESS. */ ma_uint64 totalFramesRead = 0; ma_format format; ma_flac_get_data_format(pFlac, &format, NULL, NULL, NULL, 0); switch (format) { case ma_format_f32: { totalFramesRead = ma_dr_flac_read_pcm_frames_f32(pFlac->dr, frameCount, (float*)pFramesOut); } break; case ma_format_s16: { totalFramesRead = ma_dr_flac_read_pcm_frames_s16(pFlac->dr, frameCount, (ma_int16*)pFramesOut); } break; case ma_format_s32: { totalFramesRead = ma_dr_flac_read_pcm_frames_s32(pFlac->dr, frameCount, (ma_int32*)pFramesOut); } break; case ma_format_u8: case ma_format_s24: case ma_format_unknown: default: { return MA_INVALID_OPERATION; }; } /* In the future we'll update ma_dr_flac to return MA_AT_END for us. */ if (totalFramesRead == 0) { result = MA_AT_END; } if (pFramesRead != NULL) { *pFramesRead = totalFramesRead; } if (result == MA_SUCCESS && totalFramesRead == 0) { result = MA_AT_END; } return result; } #else { /* flac is disabled. Should never hit this since initialization would have failed. */ MA_ASSERT(MA_FALSE); (void)pFramesOut; (void)frameCount; (void)pFramesRead; return MA_NOT_IMPLEMENTED; } #endif } MA_API ma_result ma_flac_seek_to_pcm_frame(ma_flac* pFlac, ma_uint64 frameIndex) { if (pFlac == NULL) { return MA_INVALID_ARGS; } #if !defined(MA_NO_FLAC) { ma_bool32 flacResult; flacResult = ma_dr_flac_seek_to_pcm_frame(pFlac->dr, frameIndex); if (flacResult != MA_TRUE) { return MA_ERROR; } return MA_SUCCESS; } #else { /* flac is disabled. Should never hit this since initialization would have failed. */ MA_ASSERT(MA_FALSE); (void)frameIndex; return MA_NOT_IMPLEMENTED; } #endif } MA_API ma_result ma_flac_get_data_format(ma_flac* pFlac, ma_format* pFormat, ma_uint32* pChannels, ma_uint32* pSampleRate, ma_channel* pChannelMap, size_t channelMapCap) { /* Defaults for safety. */ if (pFormat != NULL) { *pFormat = ma_format_unknown; } if (pChannels != NULL) { *pChannels = 0; } if (pSampleRate != NULL) { *pSampleRate = 0; } if (pChannelMap != NULL) { MA_ZERO_MEMORY(pChannelMap, sizeof(*pChannelMap) * channelMapCap); } if (pFlac == NULL) { return MA_INVALID_OPERATION; } if (pFormat != NULL) { *pFormat = pFlac->format; } #if !defined(MA_NO_FLAC) { if (pChannels != NULL) { *pChannels = pFlac->dr->channels; } if (pSampleRate != NULL) { *pSampleRate = pFlac->dr->sampleRate; } if (pChannelMap != NULL) { ma_channel_map_init_standard(ma_standard_channel_map_microsoft, pChannelMap, channelMapCap, pFlac->dr->channels); } return MA_SUCCESS; } #else { /* flac is disabled. Should never hit this since initialization would have failed. */ MA_ASSERT(MA_FALSE); return MA_NOT_IMPLEMENTED; } #endif } MA_API ma_result ma_flac_get_cursor_in_pcm_frames(ma_flac* pFlac, ma_uint64* pCursor) { if (pCursor == NULL) { return MA_INVALID_ARGS; } *pCursor = 0; /* Safety. */ if (pFlac == NULL) { return MA_INVALID_ARGS; } #if !defined(MA_NO_FLAC) { *pCursor = pFlac->dr->currentPCMFrame; return MA_SUCCESS; } #else { /* flac is disabled. Should never hit this since initialization would have failed. */ MA_ASSERT(MA_FALSE); return MA_NOT_IMPLEMENTED; } #endif } MA_API ma_result ma_flac_get_length_in_pcm_frames(ma_flac* pFlac, ma_uint64* pLength) { if (pLength == NULL) { return MA_INVALID_ARGS; } *pLength = 0; /* Safety. */ if (pFlac == NULL) { return MA_INVALID_ARGS; } #if !defined(MA_NO_FLAC) { *pLength = pFlac->dr->totalPCMFrameCount; return MA_SUCCESS; } #else { /* flac is disabled. Should never hit this since initialization would have failed. */ MA_ASSERT(MA_FALSE); return MA_NOT_IMPLEMENTED; } #endif } static ma_result ma_decoding_backend_init__flac(void* pUserData, ma_read_proc onRead, ma_seek_proc onSeek, ma_tell_proc onTell, void* pReadSeekTellUserData, const ma_decoding_backend_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_data_source** ppBackend) { ma_result result; ma_flac* pFlac; (void)pUserData; /* For now not using pUserData, but once we start storing the vorbis decoder state within the ma_decoder structure this will be set to the decoder so we can avoid a malloc. */ /* For now we're just allocating the decoder backend on the heap. */ pFlac = (ma_flac*)ma_malloc(sizeof(*pFlac), pAllocationCallbacks); if (pFlac == NULL) { return MA_OUT_OF_MEMORY; } result = ma_flac_init(onRead, onSeek, onTell, pReadSeekTellUserData, pConfig, pAllocationCallbacks, pFlac); if (result != MA_SUCCESS) { ma_free(pFlac, pAllocationCallbacks); return result; } *ppBackend = pFlac; return MA_SUCCESS; } static ma_result ma_decoding_backend_init_file__flac(void* pUserData, const char* pFilePath, const ma_decoding_backend_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_data_source** ppBackend) { ma_result result; ma_flac* pFlac; (void)pUserData; /* For now not using pUserData, but once we start storing the vorbis decoder state within the ma_decoder structure this will be set to the decoder so we can avoid a malloc. */ /* For now we're just allocating the decoder backend on the heap. */ pFlac = (ma_flac*)ma_malloc(sizeof(*pFlac), pAllocationCallbacks); if (pFlac == NULL) { return MA_OUT_OF_MEMORY; } result = ma_flac_init_file(pFilePath, pConfig, pAllocationCallbacks, pFlac); if (result != MA_SUCCESS) { ma_free(pFlac, pAllocationCallbacks); return result; } *ppBackend = pFlac; return MA_SUCCESS; } static ma_result ma_decoding_backend_init_file_w__flac(void* pUserData, const wchar_t* pFilePath, const ma_decoding_backend_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_data_source** ppBackend) { ma_result result; ma_flac* pFlac; (void)pUserData; /* For now not using pUserData, but once we start storing the vorbis decoder state within the ma_decoder structure this will be set to the decoder so we can avoid a malloc. */ /* For now we're just allocating the decoder backend on the heap. */ pFlac = (ma_flac*)ma_malloc(sizeof(*pFlac), pAllocationCallbacks); if (pFlac == NULL) { return MA_OUT_OF_MEMORY; } result = ma_flac_init_file_w(pFilePath, pConfig, pAllocationCallbacks, pFlac); if (result != MA_SUCCESS) { ma_free(pFlac, pAllocationCallbacks); return result; } *ppBackend = pFlac; return MA_SUCCESS; } static ma_result ma_decoding_backend_init_memory__flac(void* pUserData, const void* pData, size_t dataSize, const ma_decoding_backend_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_data_source** ppBackend) { ma_result result; ma_flac* pFlac; (void)pUserData; /* For now not using pUserData, but once we start storing the vorbis decoder state within the ma_decoder structure this will be set to the decoder so we can avoid a malloc. */ /* For now we're just allocating the decoder backend on the heap. */ pFlac = (ma_flac*)ma_malloc(sizeof(*pFlac), pAllocationCallbacks); if (pFlac == NULL) { return MA_OUT_OF_MEMORY; } result = ma_flac_init_memory(pData, dataSize, pConfig, pAllocationCallbacks, pFlac); if (result != MA_SUCCESS) { ma_free(pFlac, pAllocationCallbacks); return result; } *ppBackend = pFlac; return MA_SUCCESS; } static void ma_decoding_backend_uninit__flac(void* pUserData, ma_data_source* pBackend, const ma_allocation_callbacks* pAllocationCallbacks) { ma_flac* pFlac = (ma_flac*)pBackend; (void)pUserData; ma_flac_uninit(pFlac, pAllocationCallbacks); ma_free(pFlac, pAllocationCallbacks); } static ma_decoding_backend_vtable g_ma_decoding_backend_vtable_flac = { ma_decoding_backend_init__flac, ma_decoding_backend_init_file__flac, ma_decoding_backend_init_file_w__flac, ma_decoding_backend_init_memory__flac, ma_decoding_backend_uninit__flac }; static ma_result ma_decoder_init_flac__internal(const ma_decoder_config* pConfig, ma_decoder* pDecoder) { return ma_decoder_init_from_vtable__internal(&g_ma_decoding_backend_vtable_flac, NULL, pConfig, pDecoder); } static ma_result ma_decoder_init_flac_from_file__internal(const char* pFilePath, const ma_decoder_config* pConfig, ma_decoder* pDecoder) { return ma_decoder_init_from_file__internal(&g_ma_decoding_backend_vtable_flac, NULL, pFilePath, pConfig, pDecoder); } static ma_result ma_decoder_init_flac_from_file_w__internal(const wchar_t* pFilePath, const ma_decoder_config* pConfig, ma_decoder* pDecoder) { return ma_decoder_init_from_file_w__internal(&g_ma_decoding_backend_vtable_flac, NULL, pFilePath, pConfig, pDecoder); } static ma_result ma_decoder_init_flac_from_memory__internal(const void* pData, size_t dataSize, const ma_decoder_config* pConfig, ma_decoder* pDecoder) { return ma_decoder_init_from_memory__internal(&g_ma_decoding_backend_vtable_flac, NULL, pData, dataSize, pConfig, pDecoder); } #endif /* ma_dr_flac_h */ /* MP3 */ #ifdef ma_dr_mp3_h #define MA_HAS_MP3 typedef struct { ma_data_source_base ds; ma_read_proc onRead; ma_seek_proc onSeek; ma_tell_proc onTell; void* pReadSeekTellUserData; ma_format format; /* Can be f32 or s16. */ #if !defined(MA_NO_MP3) ma_dr_mp3 dr; ma_uint32 seekPointCount; ma_dr_mp3_seek_point* pSeekPoints; /* Only used if seek table generation is used. */ #endif } ma_mp3; MA_API ma_result ma_mp3_init(ma_read_proc onRead, ma_seek_proc onSeek, ma_tell_proc onTell, void* pReadSeekTellUserData, const ma_decoding_backend_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_mp3* pMP3); MA_API ma_result ma_mp3_init_file(const char* pFilePath, const ma_decoding_backend_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_mp3* pMP3); MA_API ma_result ma_mp3_init_file_w(const wchar_t* pFilePath, const ma_decoding_backend_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_mp3* pMP3); MA_API ma_result ma_mp3_init_memory(const void* pData, size_t dataSize, const ma_decoding_backend_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_mp3* pMP3); MA_API void ma_mp3_uninit(ma_mp3* pMP3, const ma_allocation_callbacks* pAllocationCallbacks); MA_API ma_result ma_mp3_read_pcm_frames(ma_mp3* pMP3, void* pFramesOut, ma_uint64 frameCount, ma_uint64* pFramesRead); MA_API ma_result ma_mp3_seek_to_pcm_frame(ma_mp3* pMP3, ma_uint64 frameIndex); MA_API ma_result ma_mp3_get_data_format(ma_mp3* pMP3, ma_format* pFormat, ma_uint32* pChannels, ma_uint32* pSampleRate, ma_channel* pChannelMap, size_t channelMapCap); MA_API ma_result ma_mp3_get_cursor_in_pcm_frames(ma_mp3* pMP3, ma_uint64* pCursor); MA_API ma_result ma_mp3_get_length_in_pcm_frames(ma_mp3* pMP3, ma_uint64* pLength); static ma_result ma_mp3_ds_read(ma_data_source* pDataSource, void* pFramesOut, ma_uint64 frameCount, ma_uint64* pFramesRead) { return ma_mp3_read_pcm_frames((ma_mp3*)pDataSource, pFramesOut, frameCount, pFramesRead); } static ma_result ma_mp3_ds_seek(ma_data_source* pDataSource, ma_uint64 frameIndex) { return ma_mp3_seek_to_pcm_frame((ma_mp3*)pDataSource, frameIndex); } static ma_result ma_mp3_ds_get_data_format(ma_data_source* pDataSource, ma_format* pFormat, ma_uint32* pChannels, ma_uint32* pSampleRate, ma_channel* pChannelMap, size_t channelMapCap) { return ma_mp3_get_data_format((ma_mp3*)pDataSource, pFormat, pChannels, pSampleRate, pChannelMap, channelMapCap); } static ma_result ma_mp3_ds_get_cursor(ma_data_source* pDataSource, ma_uint64* pCursor) { return ma_mp3_get_cursor_in_pcm_frames((ma_mp3*)pDataSource, pCursor); } static ma_result ma_mp3_ds_get_length(ma_data_source* pDataSource, ma_uint64* pLength) { return ma_mp3_get_length_in_pcm_frames((ma_mp3*)pDataSource, pLength); } static ma_data_source_vtable g_ma_mp3_ds_vtable = { ma_mp3_ds_read, ma_mp3_ds_seek, ma_mp3_ds_get_data_format, ma_mp3_ds_get_cursor, ma_mp3_ds_get_length, NULL, /* onSetLooping */ 0 }; #if !defined(MA_NO_MP3) static size_t ma_mp3_dr_callback__read(void* pUserData, void* pBufferOut, size_t bytesToRead) { ma_mp3* pMP3 = (ma_mp3*)pUserData; ma_result result; size_t bytesRead; MA_ASSERT(pMP3 != NULL); result = pMP3->onRead(pMP3->pReadSeekTellUserData, pBufferOut, bytesToRead, &bytesRead); (void)result; return bytesRead; } static ma_bool32 ma_mp3_dr_callback__seek(void* pUserData, int offset, ma_dr_mp3_seek_origin origin) { ma_mp3* pMP3 = (ma_mp3*)pUserData; ma_result result; ma_seek_origin maSeekOrigin; MA_ASSERT(pMP3 != NULL); maSeekOrigin = ma_seek_origin_start; if (origin == ma_dr_mp3_seek_origin_current) { maSeekOrigin = ma_seek_origin_current; } result = pMP3->onSeek(pMP3->pReadSeekTellUserData, offset, maSeekOrigin); if (result != MA_SUCCESS) { return MA_FALSE; } return MA_TRUE; } #endif static ma_result ma_mp3_init_internal(const ma_decoding_backend_config* pConfig, ma_mp3* pMP3) { ma_result result; ma_data_source_config dataSourceConfig; if (pMP3 == NULL) { return MA_INVALID_ARGS; } MA_ZERO_OBJECT(pMP3); pMP3->format = ma_format_f32; /* f32 by default. */ if (pConfig != NULL && (pConfig->preferredFormat == ma_format_f32 || pConfig->preferredFormat == ma_format_s16)) { pMP3->format = pConfig->preferredFormat; } else { /* Getting here means something other than f32 and s16 was specified. Just leave this unset to use the default format. */ } dataSourceConfig = ma_data_source_config_init(); dataSourceConfig.vtable = &g_ma_mp3_ds_vtable; result = ma_data_source_init(&dataSourceConfig, &pMP3->ds); if (result != MA_SUCCESS) { return result; /* Failed to initialize the base data source. */ } return MA_SUCCESS; } static ma_result ma_mp3_generate_seek_table(ma_mp3* pMP3, const ma_decoding_backend_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks) { ma_bool32 mp3Result; ma_uint32 seekPointCount = 0; ma_dr_mp3_seek_point* pSeekPoints = NULL; MA_ASSERT(pMP3 != NULL); MA_ASSERT(pConfig != NULL); seekPointCount = pConfig->seekPointCount; if (seekPointCount > 0) { pSeekPoints = (ma_dr_mp3_seek_point*)ma_malloc(sizeof(*pMP3->pSeekPoints) * seekPointCount, pAllocationCallbacks); if (pSeekPoints == NULL) { return MA_OUT_OF_MEMORY; } } mp3Result = ma_dr_mp3_calculate_seek_points(&pMP3->dr, &seekPointCount, pSeekPoints); if (mp3Result != MA_TRUE) { ma_free(pSeekPoints, pAllocationCallbacks); return MA_ERROR; } mp3Result = ma_dr_mp3_bind_seek_table(&pMP3->dr, seekPointCount, pSeekPoints); if (mp3Result != MA_TRUE) { ma_free(pSeekPoints, pAllocationCallbacks); return MA_ERROR; } pMP3->seekPointCount = seekPointCount; pMP3->pSeekPoints = pSeekPoints; return MA_SUCCESS; } static ma_result ma_mp3_post_init(ma_mp3* pMP3, const ma_decoding_backend_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks) { ma_result result; result = ma_mp3_generate_seek_table(pMP3, pConfig, pAllocationCallbacks); if (result != MA_SUCCESS) { return result; } return MA_SUCCESS; } MA_API ma_result ma_mp3_init(ma_read_proc onRead, ma_seek_proc onSeek, ma_tell_proc onTell, void* pReadSeekTellUserData, const ma_decoding_backend_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_mp3* pMP3) { ma_result result; result = ma_mp3_init_internal(pConfig, pMP3); if (result != MA_SUCCESS) { return result; } if (onRead == NULL || onSeek == NULL) { return MA_INVALID_ARGS; /* onRead and onSeek are mandatory. */ } pMP3->onRead = onRead; pMP3->onSeek = onSeek; pMP3->onTell = onTell; pMP3->pReadSeekTellUserData = pReadSeekTellUserData; #if !defined(MA_NO_MP3) { ma_bool32 mp3Result; mp3Result = ma_dr_mp3_init(&pMP3->dr, ma_mp3_dr_callback__read, ma_mp3_dr_callback__seek, pMP3, pAllocationCallbacks); if (mp3Result != MA_TRUE) { return MA_INVALID_FILE; } ma_mp3_post_init(pMP3, pConfig, pAllocationCallbacks); return MA_SUCCESS; } #else { /* mp3 is disabled. */ (void)pAllocationCallbacks; return MA_NOT_IMPLEMENTED; } #endif } MA_API ma_result ma_mp3_init_file(const char* pFilePath, const ma_decoding_backend_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_mp3* pMP3) { ma_result result; result = ma_mp3_init_internal(pConfig, pMP3); if (result != MA_SUCCESS) { return result; } #if !defined(MA_NO_MP3) { ma_bool32 mp3Result; mp3Result = ma_dr_mp3_init_file(&pMP3->dr, pFilePath, pAllocationCallbacks); if (mp3Result != MA_TRUE) { return MA_INVALID_FILE; } ma_mp3_post_init(pMP3, pConfig, pAllocationCallbacks); return MA_SUCCESS; } #else { /* mp3 is disabled. */ (void)pFilePath; (void)pAllocationCallbacks; return MA_NOT_IMPLEMENTED; } #endif } MA_API ma_result ma_mp3_init_file_w(const wchar_t* pFilePath, const ma_decoding_backend_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_mp3* pMP3) { ma_result result; result = ma_mp3_init_internal(pConfig, pMP3); if (result != MA_SUCCESS) { return result; } #if !defined(MA_NO_MP3) { ma_bool32 mp3Result; mp3Result = ma_dr_mp3_init_file_w(&pMP3->dr, pFilePath, pAllocationCallbacks); if (mp3Result != MA_TRUE) { return MA_INVALID_FILE; } ma_mp3_post_init(pMP3, pConfig, pAllocationCallbacks); return MA_SUCCESS; } #else { /* mp3 is disabled. */ (void)pFilePath; (void)pAllocationCallbacks; return MA_NOT_IMPLEMENTED; } #endif } MA_API ma_result ma_mp3_init_memory(const void* pData, size_t dataSize, const ma_decoding_backend_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_mp3* pMP3) { ma_result result; result = ma_mp3_init_internal(pConfig, pMP3); if (result != MA_SUCCESS) { return result; } #if !defined(MA_NO_MP3) { ma_bool32 mp3Result; mp3Result = ma_dr_mp3_init_memory(&pMP3->dr, pData, dataSize, pAllocationCallbacks); if (mp3Result != MA_TRUE) { return MA_INVALID_FILE; } ma_mp3_post_init(pMP3, pConfig, pAllocationCallbacks); return MA_SUCCESS; } #else { /* mp3 is disabled. */ (void)pData; (void)dataSize; (void)pAllocationCallbacks; return MA_NOT_IMPLEMENTED; } #endif } MA_API void ma_mp3_uninit(ma_mp3* pMP3, const ma_allocation_callbacks* pAllocationCallbacks) { if (pMP3 == NULL) { return; } #if !defined(MA_NO_MP3) { ma_dr_mp3_uninit(&pMP3->dr); } #else { /* mp3 is disabled. Should never hit this since initialization would have failed. */ MA_ASSERT(MA_FALSE); } #endif /* Seek points need to be freed after the MP3 decoder has been uninitialized to ensure they're no longer being referenced. */ ma_free(pMP3->pSeekPoints, pAllocationCallbacks); ma_data_source_uninit(&pMP3->ds); } MA_API ma_result ma_mp3_read_pcm_frames(ma_mp3* pMP3, void* pFramesOut, ma_uint64 frameCount, ma_uint64* pFramesRead) { if (pFramesRead != NULL) { *pFramesRead = 0; } if (frameCount == 0) { return MA_INVALID_ARGS; } if (pMP3 == NULL) { return MA_INVALID_ARGS; } #if !defined(MA_NO_MP3) { /* We always use floating point format. */ ma_result result = MA_SUCCESS; /* Must be initialized to MA_SUCCESS. */ ma_uint64 totalFramesRead = 0; ma_format format; ma_mp3_get_data_format(pMP3, &format, NULL, NULL, NULL, 0); switch (format) { case ma_format_f32: { totalFramesRead = ma_dr_mp3_read_pcm_frames_f32(&pMP3->dr, frameCount, (float*)pFramesOut); } break; case ma_format_s16: { totalFramesRead = ma_dr_mp3_read_pcm_frames_s16(&pMP3->dr, frameCount, (ma_int16*)pFramesOut); } break; case ma_format_u8: case ma_format_s24: case ma_format_s32: case ma_format_unknown: default: { return MA_INVALID_OPERATION; }; } /* In the future we'll update ma_dr_mp3 to return MA_AT_END for us. */ if (totalFramesRead == 0) { result = MA_AT_END; } if (pFramesRead != NULL) { *pFramesRead = totalFramesRead; } return result; } #else { /* mp3 is disabled. Should never hit this since initialization would have failed. */ MA_ASSERT(MA_FALSE); (void)pFramesOut; (void)frameCount; (void)pFramesRead; return MA_NOT_IMPLEMENTED; } #endif } MA_API ma_result ma_mp3_seek_to_pcm_frame(ma_mp3* pMP3, ma_uint64 frameIndex) { if (pMP3 == NULL) { return MA_INVALID_ARGS; } #if !defined(MA_NO_MP3) { ma_bool32 mp3Result; mp3Result = ma_dr_mp3_seek_to_pcm_frame(&pMP3->dr, frameIndex); if (mp3Result != MA_TRUE) { return MA_ERROR; } return MA_SUCCESS; } #else { /* mp3 is disabled. Should never hit this since initialization would have failed. */ MA_ASSERT(MA_FALSE); (void)frameIndex; return MA_NOT_IMPLEMENTED; } #endif } MA_API ma_result ma_mp3_get_data_format(ma_mp3* pMP3, ma_format* pFormat, ma_uint32* pChannels, ma_uint32* pSampleRate, ma_channel* pChannelMap, size_t channelMapCap) { /* Defaults for safety. */ if (pFormat != NULL) { *pFormat = ma_format_unknown; } if (pChannels != NULL) { *pChannels = 0; } if (pSampleRate != NULL) { *pSampleRate = 0; } if (pChannelMap != NULL) { MA_ZERO_MEMORY(pChannelMap, sizeof(*pChannelMap) * channelMapCap); } if (pMP3 == NULL) { return MA_INVALID_OPERATION; } if (pFormat != NULL) { *pFormat = pMP3->format; } #if !defined(MA_NO_MP3) { if (pChannels != NULL) { *pChannels = pMP3->dr.channels; } if (pSampleRate != NULL) { *pSampleRate = pMP3->dr.sampleRate; } if (pChannelMap != NULL) { ma_channel_map_init_standard(ma_standard_channel_map_default, pChannelMap, channelMapCap, pMP3->dr.channels); } return MA_SUCCESS; } #else { /* mp3 is disabled. Should never hit this since initialization would have failed. */ MA_ASSERT(MA_FALSE); return MA_NOT_IMPLEMENTED; } #endif } MA_API ma_result ma_mp3_get_cursor_in_pcm_frames(ma_mp3* pMP3, ma_uint64* pCursor) { if (pCursor == NULL) { return MA_INVALID_ARGS; } *pCursor = 0; /* Safety. */ if (pMP3 == NULL) { return MA_INVALID_ARGS; } #if !defined(MA_NO_MP3) { *pCursor = pMP3->dr.currentPCMFrame; return MA_SUCCESS; } #else { /* mp3 is disabled. Should never hit this since initialization would have failed. */ MA_ASSERT(MA_FALSE); return MA_NOT_IMPLEMENTED; } #endif } MA_API ma_result ma_mp3_get_length_in_pcm_frames(ma_mp3* pMP3, ma_uint64* pLength) { if (pLength == NULL) { return MA_INVALID_ARGS; } *pLength = 0; /* Safety. */ if (pMP3 == NULL) { return MA_INVALID_ARGS; } #if !defined(MA_NO_MP3) { *pLength = ma_dr_mp3_get_pcm_frame_count(&pMP3->dr); return MA_SUCCESS; } #else { /* mp3 is disabled. Should never hit this since initialization would have failed. */ MA_ASSERT(MA_FALSE); return MA_NOT_IMPLEMENTED; } #endif } static ma_result ma_decoding_backend_init__mp3(void* pUserData, ma_read_proc onRead, ma_seek_proc onSeek, ma_tell_proc onTell, void* pReadSeekTellUserData, const ma_decoding_backend_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_data_source** ppBackend) { ma_result result; ma_mp3* pMP3; (void)pUserData; /* For now not using pUserData, but once we start storing the vorbis decoder state within the ma_decoder structure this will be set to the decoder so we can avoid a malloc. */ /* For now we're just allocating the decoder backend on the heap. */ pMP3 = (ma_mp3*)ma_malloc(sizeof(*pMP3), pAllocationCallbacks); if (pMP3 == NULL) { return MA_OUT_OF_MEMORY; } result = ma_mp3_init(onRead, onSeek, onTell, pReadSeekTellUserData, pConfig, pAllocationCallbacks, pMP3); if (result != MA_SUCCESS) { ma_free(pMP3, pAllocationCallbacks); return result; } *ppBackend = pMP3; return MA_SUCCESS; } static ma_result ma_decoding_backend_init_file__mp3(void* pUserData, const char* pFilePath, const ma_decoding_backend_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_data_source** ppBackend) { ma_result result; ma_mp3* pMP3; (void)pUserData; /* For now not using pUserData, but once we start storing the vorbis decoder state within the ma_decoder structure this will be set to the decoder so we can avoid a malloc. */ /* For now we're just allocating the decoder backend on the heap. */ pMP3 = (ma_mp3*)ma_malloc(sizeof(*pMP3), pAllocationCallbacks); if (pMP3 == NULL) { return MA_OUT_OF_MEMORY; } result = ma_mp3_init_file(pFilePath, pConfig, pAllocationCallbacks, pMP3); if (result != MA_SUCCESS) { ma_free(pMP3, pAllocationCallbacks); return result; } *ppBackend = pMP3; return MA_SUCCESS; } static ma_result ma_decoding_backend_init_file_w__mp3(void* pUserData, const wchar_t* pFilePath, const ma_decoding_backend_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_data_source** ppBackend) { ma_result result; ma_mp3* pMP3; (void)pUserData; /* For now not using pUserData, but once we start storing the vorbis decoder state within the ma_decoder structure this will be set to the decoder so we can avoid a malloc. */ /* For now we're just allocating the decoder backend on the heap. */ pMP3 = (ma_mp3*)ma_malloc(sizeof(*pMP3), pAllocationCallbacks); if (pMP3 == NULL) { return MA_OUT_OF_MEMORY; } result = ma_mp3_init_file_w(pFilePath, pConfig, pAllocationCallbacks, pMP3); if (result != MA_SUCCESS) { ma_free(pMP3, pAllocationCallbacks); return result; } *ppBackend = pMP3; return MA_SUCCESS; } static ma_result ma_decoding_backend_init_memory__mp3(void* pUserData, const void* pData, size_t dataSize, const ma_decoding_backend_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_data_source** ppBackend) { ma_result result; ma_mp3* pMP3; (void)pUserData; /* For now not using pUserData, but once we start storing the vorbis decoder state within the ma_decoder structure this will be set to the decoder so we can avoid a malloc. */ /* For now we're just allocating the decoder backend on the heap. */ pMP3 = (ma_mp3*)ma_malloc(sizeof(*pMP3), pAllocationCallbacks); if (pMP3 == NULL) { return MA_OUT_OF_MEMORY; } result = ma_mp3_init_memory(pData, dataSize, pConfig, pAllocationCallbacks, pMP3); if (result != MA_SUCCESS) { ma_free(pMP3, pAllocationCallbacks); return result; } *ppBackend = pMP3; return MA_SUCCESS; } static void ma_decoding_backend_uninit__mp3(void* pUserData, ma_data_source* pBackend, const ma_allocation_callbacks* pAllocationCallbacks) { ma_mp3* pMP3 = (ma_mp3*)pBackend; (void)pUserData; ma_mp3_uninit(pMP3, pAllocationCallbacks); ma_free(pMP3, pAllocationCallbacks); } static ma_decoding_backend_vtable g_ma_decoding_backend_vtable_mp3 = { ma_decoding_backend_init__mp3, ma_decoding_backend_init_file__mp3, ma_decoding_backend_init_file_w__mp3, ma_decoding_backend_init_memory__mp3, ma_decoding_backend_uninit__mp3 }; static ma_result ma_decoder_init_mp3__internal(const ma_decoder_config* pConfig, ma_decoder* pDecoder) { return ma_decoder_init_from_vtable__internal(&g_ma_decoding_backend_vtable_mp3, NULL, pConfig, pDecoder); } static ma_result ma_decoder_init_mp3_from_file__internal(const char* pFilePath, const ma_decoder_config* pConfig, ma_decoder* pDecoder) { return ma_decoder_init_from_file__internal(&g_ma_decoding_backend_vtable_mp3, NULL, pFilePath, pConfig, pDecoder); } static ma_result ma_decoder_init_mp3_from_file_w__internal(const wchar_t* pFilePath, const ma_decoder_config* pConfig, ma_decoder* pDecoder) { return ma_decoder_init_from_file_w__internal(&g_ma_decoding_backend_vtable_mp3, NULL, pFilePath, pConfig, pDecoder); } static ma_result ma_decoder_init_mp3_from_memory__internal(const void* pData, size_t dataSize, const ma_decoder_config* pConfig, ma_decoder* pDecoder) { return ma_decoder_init_from_memory__internal(&g_ma_decoding_backend_vtable_mp3, NULL, pData, dataSize, pConfig, pDecoder); } #endif /* ma_dr_mp3_h */ /* Vorbis */ #ifdef STB_VORBIS_INCLUDE_STB_VORBIS_H #define MA_HAS_VORBIS /* The size in bytes of each chunk of data to read from the Vorbis stream. */ #define MA_VORBIS_DATA_CHUNK_SIZE 4096 typedef struct { ma_data_source_base ds; ma_read_proc onRead; ma_seek_proc onSeek; ma_tell_proc onTell; void* pReadSeekTellUserData; ma_allocation_callbacks allocationCallbacks; /* Store the allocation callbacks within the structure because we may need to dynamically expand a buffer in ma_stbvorbis_read_pcm_frames() when using push mode. */ ma_format format; /* Only f32 is allowed with stb_vorbis. */ ma_uint32 channels; ma_uint32 sampleRate; ma_uint64 cursor; #if !defined(MA_NO_VORBIS) stb_vorbis* stb; ma_bool32 usingPushMode; struct { ma_uint8* pData; size_t dataSize; size_t dataCapacity; size_t audioStartOffsetInBytes; ma_uint32 framesConsumed; /* The number of frames consumed in ppPacketData. */ ma_uint32 framesRemaining; /* The number of frames remaining in ppPacketData. */ float** ppPacketData; } push; #endif } ma_stbvorbis; MA_API ma_result ma_stbvorbis_init(ma_read_proc onRead, ma_seek_proc onSeek, ma_tell_proc onTell, void* pReadSeekTellUserData, const ma_decoding_backend_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_stbvorbis* pVorbis); MA_API ma_result ma_stbvorbis_init_file(const char* pFilePath, const ma_decoding_backend_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_stbvorbis* pVorbis); MA_API ma_result ma_stbvorbis_init_memory(const void* pData, size_t dataSize, const ma_decoding_backend_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_stbvorbis* pVorbis); MA_API void ma_stbvorbis_uninit(ma_stbvorbis* pVorbis, const ma_allocation_callbacks* pAllocationCallbacks); MA_API ma_result ma_stbvorbis_read_pcm_frames(ma_stbvorbis* pVorbis, void* pFramesOut, ma_uint64 frameCount, ma_uint64* pFramesRead); MA_API ma_result ma_stbvorbis_seek_to_pcm_frame(ma_stbvorbis* pVorbis, ma_uint64 frameIndex); MA_API ma_result ma_stbvorbis_get_data_format(ma_stbvorbis* pVorbis, ma_format* pFormat, ma_uint32* pChannels, ma_uint32* pSampleRate, ma_channel* pChannelMap, size_t channelMapCap); MA_API ma_result ma_stbvorbis_get_cursor_in_pcm_frames(ma_stbvorbis* pVorbis, ma_uint64* pCursor); MA_API ma_result ma_stbvorbis_get_length_in_pcm_frames(ma_stbvorbis* pVorbis, ma_uint64* pLength); static ma_result ma_stbvorbis_ds_read(ma_data_source* pDataSource, void* pFramesOut, ma_uint64 frameCount, ma_uint64* pFramesRead) { return ma_stbvorbis_read_pcm_frames((ma_stbvorbis*)pDataSource, pFramesOut, frameCount, pFramesRead); } static ma_result ma_stbvorbis_ds_seek(ma_data_source* pDataSource, ma_uint64 frameIndex) { return ma_stbvorbis_seek_to_pcm_frame((ma_stbvorbis*)pDataSource, frameIndex); } static ma_result ma_stbvorbis_ds_get_data_format(ma_data_source* pDataSource, ma_format* pFormat, ma_uint32* pChannels, ma_uint32* pSampleRate, ma_channel* pChannelMap, size_t channelMapCap) { return ma_stbvorbis_get_data_format((ma_stbvorbis*)pDataSource, pFormat, pChannels, pSampleRate, pChannelMap, channelMapCap); } static ma_result ma_stbvorbis_ds_get_cursor(ma_data_source* pDataSource, ma_uint64* pCursor) { return ma_stbvorbis_get_cursor_in_pcm_frames((ma_stbvorbis*)pDataSource, pCursor); } static ma_result ma_stbvorbis_ds_get_length(ma_data_source* pDataSource, ma_uint64* pLength) { return ma_stbvorbis_get_length_in_pcm_frames((ma_stbvorbis*)pDataSource, pLength); } static ma_data_source_vtable g_ma_stbvorbis_ds_vtable = { ma_stbvorbis_ds_read, ma_stbvorbis_ds_seek, ma_stbvorbis_ds_get_data_format, ma_stbvorbis_ds_get_cursor, ma_stbvorbis_ds_get_length, NULL, /* onSetLooping */ 0 }; static ma_result ma_stbvorbis_init_internal(const ma_decoding_backend_config* pConfig, ma_stbvorbis* pVorbis) { ma_result result; ma_data_source_config dataSourceConfig; (void)pConfig; if (pVorbis == NULL) { return MA_INVALID_ARGS; } MA_ZERO_OBJECT(pVorbis); pVorbis->format = ma_format_f32; /* Only supporting f32. */ dataSourceConfig = ma_data_source_config_init(); dataSourceConfig.vtable = &g_ma_stbvorbis_ds_vtable; result = ma_data_source_init(&dataSourceConfig, &pVorbis->ds); if (result != MA_SUCCESS) { return result; /* Failed to initialize the base data source. */ } return MA_SUCCESS; } #if !defined(MA_NO_VORBIS) static ma_result ma_stbvorbis_post_init(ma_stbvorbis* pVorbis) { stb_vorbis_info info; MA_ASSERT(pVorbis != NULL); info = stb_vorbis_get_info(pVorbis->stb); pVorbis->channels = info.channels; pVorbis->sampleRate = info.sample_rate; return MA_SUCCESS; } static ma_result ma_stbvorbis_init_internal_decoder_push(ma_stbvorbis* pVorbis) { ma_result result; stb_vorbis* stb; size_t dataSize = 0; size_t dataCapacity = 0; ma_uint8* pData = NULL; /* <-- Must be initialized to NULL. */ for (;;) { int vorbisError; int consumedDataSize; /* <-- Fill by stb_vorbis_open_pushdata(). */ size_t bytesRead; ma_uint8* pNewData; /* Allocate memory for the new chunk. */ dataCapacity += MA_VORBIS_DATA_CHUNK_SIZE; pNewData = (ma_uint8*)ma_realloc(pData, dataCapacity, &pVorbis->allocationCallbacks); if (pNewData == NULL) { ma_free(pData, &pVorbis->allocationCallbacks); return MA_OUT_OF_MEMORY; } pData = pNewData; /* Read in the next chunk. */ result = pVorbis->onRead(pVorbis->pReadSeekTellUserData, ma_offset_ptr(pData, dataSize), (dataCapacity - dataSize), &bytesRead); dataSize += bytesRead; if (result != MA_SUCCESS) { ma_free(pData, &pVorbis->allocationCallbacks); return result; } /* We have a maximum of 31 bits with stb_vorbis. */ if (dataSize > INT_MAX) { ma_free(pData, &pVorbis->allocationCallbacks); return MA_TOO_BIG; } stb = stb_vorbis_open_pushdata(pData, (int)dataSize, &consumedDataSize, &vorbisError, NULL); if (stb != NULL) { /* Successfully opened the Vorbis decoder. We might have some leftover unprocessed data so we'll need to move that down to the front. */ dataSize -= (size_t)consumedDataSize; /* Consume the data. */ MA_MOVE_MEMORY(pData, ma_offset_ptr(pData, consumedDataSize), dataSize); /* We need to track the start point so we can seek back to the start of the audio data when seeking. */ pVorbis->push.audioStartOffsetInBytes = consumedDataSize; break; } else { /* Failed to open the decoder. */ if (vorbisError == VORBIS_need_more_data) { continue; } else { ma_free(pData, &pVorbis->allocationCallbacks); return MA_ERROR; /* Failed to open the stb_vorbis decoder. */ } } } MA_ASSERT(stb != NULL); pVorbis->stb = stb; pVorbis->push.pData = pData; pVorbis->push.dataSize = dataSize; pVorbis->push.dataCapacity = dataCapacity; return MA_SUCCESS; } #endif MA_API ma_result ma_stbvorbis_init(ma_read_proc onRead, ma_seek_proc onSeek, ma_tell_proc onTell, void* pReadSeekTellUserData, const ma_decoding_backend_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_stbvorbis* pVorbis) { ma_result result; result = ma_stbvorbis_init_internal(pConfig, pVorbis); if (result != MA_SUCCESS) { return result; } if (onRead == NULL || onSeek == NULL) { return MA_INVALID_ARGS; /* onRead and onSeek are mandatory. */ } pVorbis->onRead = onRead; pVorbis->onSeek = onSeek; pVorbis->onTell = onTell; pVorbis->pReadSeekTellUserData = pReadSeekTellUserData; ma_allocation_callbacks_init_copy(&pVorbis->allocationCallbacks, pAllocationCallbacks); #if !defined(MA_NO_VORBIS) { /* stb_vorbis lacks a callback based API for it's pulling API which means we're stuck with the pushing API. In order for us to be able to successfully initialize the decoder we need to supply it with enough data. We need to keep loading data until we have enough. */ result = ma_stbvorbis_init_internal_decoder_push(pVorbis); if (result != MA_SUCCESS) { return result; } pVorbis->usingPushMode = MA_TRUE; result = ma_stbvorbis_post_init(pVorbis); if (result != MA_SUCCESS) { stb_vorbis_close(pVorbis->stb); ma_free(pVorbis->push.pData, pAllocationCallbacks); return result; } return MA_SUCCESS; } #else { /* vorbis is disabled. */ (void)pAllocationCallbacks; return MA_NOT_IMPLEMENTED; } #endif } MA_API ma_result ma_stbvorbis_init_file(const char* pFilePath, const ma_decoding_backend_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_stbvorbis* pVorbis) { ma_result result; result = ma_stbvorbis_init_internal(pConfig, pVorbis); if (result != MA_SUCCESS) { return result; } #if !defined(MA_NO_VORBIS) { (void)pAllocationCallbacks; /* Don't know how to make use of this with stb_vorbis. */ /* We can use stb_vorbis' pull mode for file based streams. */ pVorbis->stb = stb_vorbis_open_filename(pFilePath, NULL, NULL); if (pVorbis->stb == NULL) { return MA_INVALID_FILE; } pVorbis->usingPushMode = MA_FALSE; result = ma_stbvorbis_post_init(pVorbis); if (result != MA_SUCCESS) { stb_vorbis_close(pVorbis->stb); return result; } return MA_SUCCESS; } #else { /* vorbis is disabled. */ (void)pFilePath; (void)pAllocationCallbacks; return MA_NOT_IMPLEMENTED; } #endif } MA_API ma_result ma_stbvorbis_init_memory(const void* pData, size_t dataSize, const ma_decoding_backend_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_stbvorbis* pVorbis) { ma_result result; result = ma_stbvorbis_init_internal(pConfig, pVorbis); if (result != MA_SUCCESS) { return result; } #if !defined(MA_NO_VORBIS) { (void)pAllocationCallbacks; /* stb_vorbis uses an int as it's size specifier, restricting it to 32-bit even on 64-bit systems. *sigh*. */ if (dataSize > INT_MAX) { return MA_TOO_BIG; } pVorbis->stb = stb_vorbis_open_memory((const unsigned char*)pData, (int)dataSize, NULL, NULL); if (pVorbis->stb == NULL) { return MA_INVALID_FILE; } pVorbis->usingPushMode = MA_FALSE; result = ma_stbvorbis_post_init(pVorbis); if (result != MA_SUCCESS) { stb_vorbis_close(pVorbis->stb); return result; } return MA_SUCCESS; } #else { /* vorbis is disabled. */ (void)pData; (void)dataSize; (void)pAllocationCallbacks; return MA_NOT_IMPLEMENTED; } #endif } MA_API void ma_stbvorbis_uninit(ma_stbvorbis* pVorbis, const ma_allocation_callbacks* pAllocationCallbacks) { if (pVorbis == NULL) { return; } #if !defined(MA_NO_VORBIS) { stb_vorbis_close(pVorbis->stb); /* We'll have to clear some memory if we're using push mode. */ if (pVorbis->usingPushMode) { ma_free(pVorbis->push.pData, pAllocationCallbacks); } } #else { /* vorbis is disabled. Should never hit this since initialization would have failed. */ MA_ASSERT(MA_FALSE); } #endif ma_data_source_uninit(&pVorbis->ds); } MA_API ma_result ma_stbvorbis_read_pcm_frames(ma_stbvorbis* pVorbis, void* pFramesOut, ma_uint64 frameCount, ma_uint64* pFramesRead) { if (pFramesRead != NULL) { *pFramesRead = 0; } if (frameCount == 0) { return MA_INVALID_ARGS; } if (pVorbis == NULL) { return MA_INVALID_ARGS; } #if !defined(MA_NO_VORBIS) { /* We always use floating point format. */ ma_result result = MA_SUCCESS; /* Must be initialized to MA_SUCCESS. */ ma_uint64 totalFramesRead = 0; ma_format format; ma_uint32 channels; ma_stbvorbis_get_data_format(pVorbis, &format, &channels, NULL, NULL, 0); if (format == ma_format_f32) { /* We read differently depending on whether or not we're using push mode. */ if (pVorbis->usingPushMode) { /* Push mode. This is the complex case. */ float* pFramesOutF32 = (float*)pFramesOut; while (totalFramesRead < frameCount) { /* The first thing to do is read from any already-cached frames. */ ma_uint32 framesToReadFromCache = (ma_uint32)ma_min(pVorbis->push.framesRemaining, (frameCount - totalFramesRead)); /* Safe cast because pVorbis->framesRemaining is 32-bit. */ /* The output pointer can be null in which case we just treate it as a seek. */ if (pFramesOut != NULL) { ma_uint64 iFrame; for (iFrame = 0; iFrame < framesToReadFromCache; iFrame += 1) { ma_uint32 iChannel; for (iChannel = 0; iChannel < pVorbis->channels; iChannel += 1) { pFramesOutF32[iChannel] = pVorbis->push.ppPacketData[iChannel][pVorbis->push.framesConsumed + iFrame]; } pFramesOutF32 += pVorbis->channels; } } /* Update pointers and counters. */ pVorbis->push.framesConsumed += framesToReadFromCache; pVorbis->push.framesRemaining -= framesToReadFromCache; totalFramesRead += framesToReadFromCache; /* Don't bother reading any more frames right now if we've just finished loading. */ if (totalFramesRead == frameCount) { break; } MA_ASSERT(pVorbis->push.framesRemaining == 0); /* Getting here means we've run out of cached frames. We'll need to load some more. */ for (;;) { int samplesRead = 0; int consumedDataSize; /* We need to case dataSize to an int, so make sure we can do it safely. */ if (pVorbis->push.dataSize > INT_MAX) { break; /* Too big. */ } consumedDataSize = stb_vorbis_decode_frame_pushdata(pVorbis->stb, pVorbis->push.pData, (int)pVorbis->push.dataSize, NULL, &pVorbis->push.ppPacketData, &samplesRead); if (consumedDataSize != 0) { /* Successfully decoded a Vorbis frame. Consume the data. */ pVorbis->push.dataSize -= (size_t)consumedDataSize; MA_MOVE_MEMORY(pVorbis->push.pData, ma_offset_ptr(pVorbis->push.pData, consumedDataSize), pVorbis->push.dataSize); pVorbis->push.framesConsumed = 0; pVorbis->push.framesRemaining = samplesRead; break; } else { /* Not enough data. Read more. */ size_t bytesRead; /* Expand the data buffer if necessary. */ if (pVorbis->push.dataCapacity == pVorbis->push.dataSize) { size_t newCap = pVorbis->push.dataCapacity + MA_VORBIS_DATA_CHUNK_SIZE; ma_uint8* pNewData; pNewData = (ma_uint8*)ma_realloc(pVorbis->push.pData, newCap, &pVorbis->allocationCallbacks); if (pNewData == NULL) { result = MA_OUT_OF_MEMORY; break; } pVorbis->push.pData = pNewData; pVorbis->push.dataCapacity = newCap; } /* We should have enough room to load some data. */ result = pVorbis->onRead(pVorbis->pReadSeekTellUserData, ma_offset_ptr(pVorbis->push.pData, pVorbis->push.dataSize), (pVorbis->push.dataCapacity - pVorbis->push.dataSize), &bytesRead); pVorbis->push.dataSize += bytesRead; if (result != MA_SUCCESS) { break; /* Failed to read any data. Get out. */ } } } /* If we don't have a success code at this point it means we've encounted an error or the end of the file has been reached (probably the latter). */ if (result != MA_SUCCESS) { break; } } } else { /* Pull mode. This is the simple case, but we still need to run in a loop because stb_vorbis loves using 32-bit instead of 64-bit. */ while (totalFramesRead < frameCount) { ma_uint64 framesRemaining = (frameCount - totalFramesRead); int framesRead; if (framesRemaining > INT_MAX) { framesRemaining = INT_MAX; } framesRead = stb_vorbis_get_samples_float_interleaved(pVorbis->stb, channels, (float*)ma_offset_pcm_frames_ptr(pFramesOut, totalFramesRead, format, channels), (int)framesRemaining * channels); /* Safe cast. */ totalFramesRead += framesRead; if (framesRead < (int)framesRemaining) { break; /* Nothing left to read. Get out. */ } } } } else { result = MA_INVALID_ARGS; } pVorbis->cursor += totalFramesRead; if (totalFramesRead == 0) { result = MA_AT_END; } if (pFramesRead != NULL) { *pFramesRead = totalFramesRead; } if (result == MA_SUCCESS && totalFramesRead == 0) { result = MA_AT_END; } return result; } #else { /* vorbis is disabled. Should never hit this since initialization would have failed. */ MA_ASSERT(MA_FALSE); (void)pFramesOut; (void)frameCount; (void)pFramesRead; return MA_NOT_IMPLEMENTED; } #endif } MA_API ma_result ma_stbvorbis_seek_to_pcm_frame(ma_stbvorbis* pVorbis, ma_uint64 frameIndex) { if (pVorbis == NULL) { return MA_INVALID_ARGS; } #if !defined(MA_NO_VORBIS) { /* Different seeking methods depending on whether or not we're using push mode. */ if (pVorbis->usingPushMode) { /* Push mode. This is the complex case. */ ma_result result; float buffer[4096]; /* If we're seeking backwards, we need to seek back to the start and then brute-force forward. */ if (frameIndex < pVorbis->cursor) { if (frameIndex > 0x7FFFFFFF) { return MA_INVALID_ARGS; /* Trying to seek beyond the 32-bit maximum of stb_vorbis. */ } /* This is wildly inefficient due to me having trouble getting sample exact seeking working robustly with stb_vorbis_flush_pushdata(). The only way I can think to make this work perfectly is to reinitialize the decoder. Note that we only enter this path when seeking backwards. This will hopefully be removed once we get our own Vorbis decoder implemented. */ stb_vorbis_close(pVorbis->stb); ma_free(pVorbis->push.pData, &pVorbis->allocationCallbacks); MA_ZERO_OBJECT(&pVorbis->push); /* Seek to the start of the file. */ result = pVorbis->onSeek(pVorbis->pReadSeekTellUserData, 0, ma_seek_origin_start); if (result != MA_SUCCESS) { return result; } result = ma_stbvorbis_init_internal_decoder_push(pVorbis); if (result != MA_SUCCESS) { return result; } /* At this point we should be sitting on the first frame. */ pVorbis->cursor = 0; } /* We're just brute-forcing this for now. */ while (pVorbis->cursor < frameIndex) { ma_uint64 framesRead; ma_uint64 framesToRead = ma_countof(buffer)/pVorbis->channels; if (framesToRead > (frameIndex - pVorbis->cursor)) { framesToRead = (frameIndex - pVorbis->cursor); } result = ma_stbvorbis_read_pcm_frames(pVorbis, buffer, framesToRead, &framesRead); if (result != MA_SUCCESS) { return result; } } } else { /* Pull mode. This is the simple case. */ int vorbisResult; if (frameIndex > UINT_MAX) { return MA_INVALID_ARGS; /* Trying to seek beyond the 32-bit maximum of stb_vorbis. */ } vorbisResult = stb_vorbis_seek(pVorbis->stb, (unsigned int)frameIndex); /* Safe cast. */ if (vorbisResult == 0) { return MA_ERROR; /* See failed. */ } pVorbis->cursor = frameIndex; } return MA_SUCCESS; } #else { /* vorbis is disabled. Should never hit this since initialization would have failed. */ MA_ASSERT(MA_FALSE); (void)frameIndex; return MA_NOT_IMPLEMENTED; } #endif } MA_API ma_result ma_stbvorbis_get_data_format(ma_stbvorbis* pVorbis, ma_format* pFormat, ma_uint32* pChannels, ma_uint32* pSampleRate, ma_channel* pChannelMap, size_t channelMapCap) { /* Defaults for safety. */ if (pFormat != NULL) { *pFormat = ma_format_unknown; } if (pChannels != NULL) { *pChannels = 0; } if (pSampleRate != NULL) { *pSampleRate = 0; } if (pChannelMap != NULL) { MA_ZERO_MEMORY(pChannelMap, sizeof(*pChannelMap) * channelMapCap); } if (pVorbis == NULL) { return MA_INVALID_OPERATION; } if (pFormat != NULL) { *pFormat = pVorbis->format; } #if !defined(MA_NO_VORBIS) { if (pChannels != NULL) { *pChannels = pVorbis->channels; } if (pSampleRate != NULL) { *pSampleRate = pVorbis->sampleRate; } if (pChannelMap != NULL) { ma_channel_map_init_standard(ma_standard_channel_map_vorbis, pChannelMap, channelMapCap, pVorbis->channels); } return MA_SUCCESS; } #else { /* vorbis is disabled. Should never hit this since initialization would have failed. */ MA_ASSERT(MA_FALSE); return MA_NOT_IMPLEMENTED; } #endif } MA_API ma_result ma_stbvorbis_get_cursor_in_pcm_frames(ma_stbvorbis* pVorbis, ma_uint64* pCursor) { if (pCursor == NULL) { return MA_INVALID_ARGS; } *pCursor = 0; /* Safety. */ if (pVorbis == NULL) { return MA_INVALID_ARGS; } #if !defined(MA_NO_VORBIS) { *pCursor = pVorbis->cursor; return MA_SUCCESS; } #else { /* vorbis is disabled. Should never hit this since initialization would have failed. */ MA_ASSERT(MA_FALSE); return MA_NOT_IMPLEMENTED; } #endif } MA_API ma_result ma_stbvorbis_get_length_in_pcm_frames(ma_stbvorbis* pVorbis, ma_uint64* pLength) { if (pLength == NULL) { return MA_INVALID_ARGS; } *pLength = 0; /* Safety. */ if (pVorbis == NULL) { return MA_INVALID_ARGS; } #if !defined(MA_NO_VORBIS) { if (pVorbis->usingPushMode) { *pLength = 0; /* I don't know of a good way to determine this reliably with stb_vorbis and push mode. */ } else { *pLength = stb_vorbis_stream_length_in_samples(pVorbis->stb); } return MA_SUCCESS; } #else { /* vorbis is disabled. Should never hit this since initialization would have failed. */ MA_ASSERT(MA_FALSE); return MA_NOT_IMPLEMENTED; } #endif } static ma_result ma_decoding_backend_init__stbvorbis(void* pUserData, ma_read_proc onRead, ma_seek_proc onSeek, ma_tell_proc onTell, void* pReadSeekTellUserData, const ma_decoding_backend_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_data_source** ppBackend) { ma_result result; ma_stbvorbis* pVorbis; (void)pUserData; /* For now not using pUserData, but once we start storing the vorbis decoder state within the ma_decoder structure this will be set to the decoder so we can avoid a malloc. */ /* For now we're just allocating the decoder backend on the heap. */ pVorbis = (ma_stbvorbis*)ma_malloc(sizeof(*pVorbis), pAllocationCallbacks); if (pVorbis == NULL) { return MA_OUT_OF_MEMORY; } result = ma_stbvorbis_init(onRead, onSeek, onTell, pReadSeekTellUserData, pConfig, pAllocationCallbacks, pVorbis); if (result != MA_SUCCESS) { ma_free(pVorbis, pAllocationCallbacks); return result; } *ppBackend = pVorbis; return MA_SUCCESS; } static ma_result ma_decoding_backend_init_file__stbvorbis(void* pUserData, const char* pFilePath, const ma_decoding_backend_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_data_source** ppBackend) { ma_result result; ma_stbvorbis* pVorbis; (void)pUserData; /* For now not using pUserData, but once we start storing the vorbis decoder state within the ma_decoder structure this will be set to the decoder so we can avoid a malloc. */ /* For now we're just allocating the decoder backend on the heap. */ pVorbis = (ma_stbvorbis*)ma_malloc(sizeof(*pVorbis), pAllocationCallbacks); if (pVorbis == NULL) { return MA_OUT_OF_MEMORY; } result = ma_stbvorbis_init_file(pFilePath, pConfig, pAllocationCallbacks, pVorbis); if (result != MA_SUCCESS) { ma_free(pVorbis, pAllocationCallbacks); return result; } *ppBackend = pVorbis; return MA_SUCCESS; } static ma_result ma_decoding_backend_init_memory__stbvorbis(void* pUserData, const void* pData, size_t dataSize, const ma_decoding_backend_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_data_source** ppBackend) { ma_result result; ma_stbvorbis* pVorbis; (void)pUserData; /* For now not using pUserData, but once we start storing the vorbis decoder state within the ma_decoder structure this will be set to the decoder so we can avoid a malloc. */ /* For now we're just allocating the decoder backend on the heap. */ pVorbis = (ma_stbvorbis*)ma_malloc(sizeof(*pVorbis), pAllocationCallbacks); if (pVorbis == NULL) { return MA_OUT_OF_MEMORY; } result = ma_stbvorbis_init_memory(pData, dataSize, pConfig, pAllocationCallbacks, pVorbis); if (result != MA_SUCCESS) { ma_free(pVorbis, pAllocationCallbacks); return result; } *ppBackend = pVorbis; return MA_SUCCESS; } static void ma_decoding_backend_uninit__stbvorbis(void* pUserData, ma_data_source* pBackend, const ma_allocation_callbacks* pAllocationCallbacks) { ma_stbvorbis* pVorbis = (ma_stbvorbis*)pBackend; (void)pUserData; ma_stbvorbis_uninit(pVorbis, pAllocationCallbacks); ma_free(pVorbis, pAllocationCallbacks); } static ma_decoding_backend_vtable g_ma_decoding_backend_vtable_stbvorbis = { ma_decoding_backend_init__stbvorbis, ma_decoding_backend_init_file__stbvorbis, NULL, /* onInitFileW() */ ma_decoding_backend_init_memory__stbvorbis, ma_decoding_backend_uninit__stbvorbis }; static ma_result ma_decoder_init_vorbis__internal(const ma_decoder_config* pConfig, ma_decoder* pDecoder) { return ma_decoder_init_from_vtable__internal(&g_ma_decoding_backend_vtable_stbvorbis, NULL, pConfig, pDecoder); } static ma_result ma_decoder_init_vorbis_from_file__internal(const char* pFilePath, const ma_decoder_config* pConfig, ma_decoder* pDecoder) { return ma_decoder_init_from_file__internal(&g_ma_decoding_backend_vtable_stbvorbis, NULL, pFilePath, pConfig, pDecoder); } static ma_result ma_decoder_init_vorbis_from_file_w__internal(const wchar_t* pFilePath, const ma_decoder_config* pConfig, ma_decoder* pDecoder) { return ma_decoder_init_from_file_w__internal(&g_ma_decoding_backend_vtable_stbvorbis, NULL, pFilePath, pConfig, pDecoder); } static ma_result ma_decoder_init_vorbis_from_memory__internal(const void* pData, size_t dataSize, const ma_decoder_config* pConfig, ma_decoder* pDecoder) { return ma_decoder_init_from_memory__internal(&g_ma_decoding_backend_vtable_stbvorbis, NULL, pData, dataSize, pConfig, pDecoder); } #endif /* STB_VORBIS_INCLUDE_STB_VORBIS_H */ static ma_result ma_decoder__init_allocation_callbacks(const ma_decoder_config* pConfig, ma_decoder* pDecoder) { MA_ASSERT(pDecoder != NULL); if (pConfig != NULL) { return ma_allocation_callbacks_init_copy(&pDecoder->allocationCallbacks, &pConfig->allocationCallbacks); } else { pDecoder->allocationCallbacks = ma_allocation_callbacks_init_default(); return MA_SUCCESS; } } static ma_result ma_decoder__data_source_on_read(ma_data_source* pDataSource, void* pFramesOut, ma_uint64 frameCount, ma_uint64* pFramesRead) { return ma_decoder_read_pcm_frames((ma_decoder*)pDataSource, pFramesOut, frameCount, pFramesRead); } static ma_result ma_decoder__data_source_on_seek(ma_data_source* pDataSource, ma_uint64 frameIndex) { return ma_decoder_seek_to_pcm_frame((ma_decoder*)pDataSource, frameIndex); } static ma_result ma_decoder__data_source_on_get_data_format(ma_data_source* pDataSource, ma_format* pFormat, ma_uint32* pChannels, ma_uint32* pSampleRate, ma_channel* pChannelMap, size_t channelMapCap) { return ma_decoder_get_data_format((ma_decoder*)pDataSource, pFormat, pChannels, pSampleRate, pChannelMap, channelMapCap); } static ma_result ma_decoder__data_source_on_get_cursor(ma_data_source* pDataSource, ma_uint64* pCursor) { return ma_decoder_get_cursor_in_pcm_frames((ma_decoder*)pDataSource, pCursor); } static ma_result ma_decoder__data_source_on_get_length(ma_data_source* pDataSource, ma_uint64* pLength) { return ma_decoder_get_length_in_pcm_frames((ma_decoder*)pDataSource, pLength); } static ma_data_source_vtable g_ma_decoder_data_source_vtable = { ma_decoder__data_source_on_read, ma_decoder__data_source_on_seek, ma_decoder__data_source_on_get_data_format, ma_decoder__data_source_on_get_cursor, ma_decoder__data_source_on_get_length, NULL, /* onSetLooping */ 0 }; static ma_result ma_decoder__preinit(ma_decoder_read_proc onRead, ma_decoder_seek_proc onSeek, ma_decoder_tell_proc onTell, void* pUserData, const ma_decoder_config* pConfig, ma_decoder* pDecoder) { ma_result result; ma_data_source_config dataSourceConfig; MA_ASSERT(pConfig != NULL); if (pDecoder == NULL) { return MA_INVALID_ARGS; } MA_ZERO_OBJECT(pDecoder); dataSourceConfig = ma_data_source_config_init(); dataSourceConfig.vtable = &g_ma_decoder_data_source_vtable; result = ma_data_source_init(&dataSourceConfig, &pDecoder->ds); if (result != MA_SUCCESS) { return result; } pDecoder->onRead = onRead; pDecoder->onSeek = onSeek; pDecoder->onTell = onTell; pDecoder->pUserData = pUserData; result = ma_decoder__init_allocation_callbacks(pConfig, pDecoder); if (result != MA_SUCCESS) { ma_data_source_uninit(&pDecoder->ds); return result; } return MA_SUCCESS; } static ma_result ma_decoder__postinit(const ma_decoder_config* pConfig, ma_decoder* pDecoder) { ma_result result; result = ma_decoder__init_data_converter(pDecoder, pConfig); /* If we failed post initialization we need to uninitialize the decoder before returning to prevent a memory leak. */ if (result != MA_SUCCESS) { ma_decoder_uninit(pDecoder); return result; } return result; } static ma_result ma_decoder_init__internal(ma_decoder_read_proc onRead, ma_decoder_seek_proc onSeek, void* pUserData, const ma_decoder_config* pConfig, ma_decoder* pDecoder) { ma_result result = MA_NO_BACKEND; MA_ASSERT(pConfig != NULL); MA_ASSERT(pDecoder != NULL); /* Silence some warnings in the case that we don't have any decoder backends enabled. */ (void)onRead; (void)onSeek; (void)pUserData; /* If we've specified a specific encoding type, try that first. */ if (pConfig->encodingFormat != ma_encoding_format_unknown) { #ifdef MA_HAS_WAV if (pConfig->encodingFormat == ma_encoding_format_wav) { result = ma_decoder_init_wav__internal(pConfig, pDecoder); } #endif #ifdef MA_HAS_FLAC if (pConfig->encodingFormat == ma_encoding_format_flac) { result = ma_decoder_init_flac__internal(pConfig, pDecoder); } #endif #ifdef MA_HAS_MP3 if (pConfig->encodingFormat == ma_encoding_format_mp3) { result = ma_decoder_init_mp3__internal(pConfig, pDecoder); } #endif #ifdef MA_HAS_VORBIS if (pConfig->encodingFormat == ma_encoding_format_vorbis) { result = ma_decoder_init_vorbis__internal(pConfig, pDecoder); } #endif /* If we weren't able to initialize the decoder, seek back to the start to give the next attempts a clean start. */ if (result != MA_SUCCESS) { onSeek(pDecoder, 0, ma_seek_origin_start); } } if (result != MA_SUCCESS) { /* Getting here means we couldn't load a specific decoding backend based on the encoding format. */ /* We use trial and error to open a decoder. We prioritize custom decoders so that if they implement the same encoding format they take priority over the built-in decoders. */ if (result != MA_SUCCESS) { result = ma_decoder_init_custom__internal(pConfig, pDecoder); if (result != MA_SUCCESS) { onSeek(pDecoder, 0, ma_seek_origin_start); } } /* If we get to this point and we still haven't found a decoder, and the caller has requested a specific encoding format, there's no hope for it. Abort. */ if (pConfig->encodingFormat != ma_encoding_format_unknown) { return MA_NO_BACKEND; } #ifdef MA_HAS_WAV if (result != MA_SUCCESS) { result = ma_decoder_init_wav__internal(pConfig, pDecoder); if (result != MA_SUCCESS) { onSeek(pDecoder, 0, ma_seek_origin_start); } } #endif #ifdef MA_HAS_FLAC if (result != MA_SUCCESS) { result = ma_decoder_init_flac__internal(pConfig, pDecoder); if (result != MA_SUCCESS) { onSeek(pDecoder, 0, ma_seek_origin_start); } } #endif #ifdef MA_HAS_MP3 if (result != MA_SUCCESS) { result = ma_decoder_init_mp3__internal(pConfig, pDecoder); if (result != MA_SUCCESS) { onSeek(pDecoder, 0, ma_seek_origin_start); } } #endif #ifdef MA_HAS_VORBIS if (result != MA_SUCCESS) { result = ma_decoder_init_vorbis__internal(pConfig, pDecoder); if (result != MA_SUCCESS) { onSeek(pDecoder, 0, ma_seek_origin_start); } } #endif } if (result != MA_SUCCESS) { return result; } return ma_decoder__postinit(pConfig, pDecoder); } MA_API ma_result ma_decoder_init(ma_decoder_read_proc onRead, ma_decoder_seek_proc onSeek, void* pUserData, const ma_decoder_config* pConfig, ma_decoder* pDecoder) { ma_decoder_config config; ma_result result; config = ma_decoder_config_init_copy(pConfig); result = ma_decoder__preinit(onRead, onSeek, NULL, pUserData, &config, pDecoder); if (result != MA_SUCCESS) { return result; } return ma_decoder_init__internal(onRead, onSeek, pUserData, &config, pDecoder); } static ma_result ma_decoder__on_read_memory(ma_decoder* pDecoder, void* pBufferOut, size_t bytesToRead, size_t* pBytesRead) { size_t bytesRemaining; MA_ASSERT(pDecoder->data.memory.dataSize >= pDecoder->data.memory.currentReadPos); if (pBytesRead != NULL) { *pBytesRead = 0; } bytesRemaining = pDecoder->data.memory.dataSize - pDecoder->data.memory.currentReadPos; if (bytesToRead > bytesRemaining) { bytesToRead = bytesRemaining; } if (bytesRemaining == 0) { return MA_AT_END; } if (bytesToRead > 0) { MA_COPY_MEMORY(pBufferOut, pDecoder->data.memory.pData + pDecoder->data.memory.currentReadPos, bytesToRead); pDecoder->data.memory.currentReadPos += bytesToRead; } if (pBytesRead != NULL) { *pBytesRead = bytesToRead; } return MA_SUCCESS; } static ma_result ma_decoder__on_seek_memory(ma_decoder* pDecoder, ma_int64 byteOffset, ma_seek_origin origin) { if (byteOffset > 0 && (ma_uint64)byteOffset > MA_SIZE_MAX) { return MA_BAD_SEEK; } if (origin == ma_seek_origin_current) { if (byteOffset > 0) { if (pDecoder->data.memory.currentReadPos + byteOffset > pDecoder->data.memory.dataSize) { byteOffset = (ma_int64)(pDecoder->data.memory.dataSize - pDecoder->data.memory.currentReadPos); /* Trying to seek too far forward. */ } pDecoder->data.memory.currentReadPos += (size_t)byteOffset; } else { if (pDecoder->data.memory.currentReadPos < (size_t)-byteOffset) { byteOffset = -(ma_int64)pDecoder->data.memory.currentReadPos; /* Trying to seek too far backwards. */ } pDecoder->data.memory.currentReadPos -= (size_t)-byteOffset; } } else { if (origin == ma_seek_origin_end) { if (byteOffset < 0) { byteOffset = -byteOffset; } if (byteOffset > (ma_int64)pDecoder->data.memory.dataSize) { pDecoder->data.memory.currentReadPos = 0; /* Trying to seek too far back. */ } else { pDecoder->data.memory.currentReadPos = pDecoder->data.memory.dataSize - (size_t)byteOffset; } } else { if ((size_t)byteOffset <= pDecoder->data.memory.dataSize) { pDecoder->data.memory.currentReadPos = (size_t)byteOffset; } else { pDecoder->data.memory.currentReadPos = pDecoder->data.memory.dataSize; /* Trying to seek too far forward. */ } } } return MA_SUCCESS; } static ma_result ma_decoder__on_tell_memory(ma_decoder* pDecoder, ma_int64* pCursor) { MA_ASSERT(pDecoder != NULL); MA_ASSERT(pCursor != NULL); *pCursor = (ma_int64)pDecoder->data.memory.currentReadPos; return MA_SUCCESS; } static ma_result ma_decoder__preinit_memory_wrapper(const void* pData, size_t dataSize, const ma_decoder_config* pConfig, ma_decoder* pDecoder) { ma_result result = ma_decoder__preinit(ma_decoder__on_read_memory, ma_decoder__on_seek_memory, ma_decoder__on_tell_memory, NULL, pConfig, pDecoder); if (result != MA_SUCCESS) { return result; } if (pData == NULL || dataSize == 0) { return MA_INVALID_ARGS; } pDecoder->data.memory.pData = (const ma_uint8*)pData; pDecoder->data.memory.dataSize = dataSize; pDecoder->data.memory.currentReadPos = 0; (void)pConfig; return MA_SUCCESS; } MA_API ma_result ma_decoder_init_memory(const void* pData, size_t dataSize, const ma_decoder_config* pConfig, ma_decoder* pDecoder) { ma_result result; ma_decoder_config config; config = ma_decoder_config_init_copy(pConfig); result = ma_decoder__preinit(NULL, NULL, NULL, NULL, &config, pDecoder); if (result != MA_SUCCESS) { return result; } if (pData == NULL || dataSize == 0) { return MA_INVALID_ARGS; } /* If the backend has support for loading from a file path we'll want to use that. If that all fails we'll fall back to the VFS path. */ result = MA_NO_BACKEND; if (config.encodingFormat != ma_encoding_format_unknown) { #ifdef MA_HAS_WAV if (config.encodingFormat == ma_encoding_format_wav) { result = ma_decoder_init_wav_from_memory__internal(pData, dataSize, &config, pDecoder); } #endif #ifdef MA_HAS_FLAC if (config.encodingFormat == ma_encoding_format_flac) { result = ma_decoder_init_flac_from_memory__internal(pData, dataSize, &config, pDecoder); } #endif #ifdef MA_HAS_MP3 if (config.encodingFormat == ma_encoding_format_mp3) { result = ma_decoder_init_mp3_from_memory__internal(pData, dataSize, &config, pDecoder); } #endif #ifdef MA_HAS_VORBIS if (config.encodingFormat == ma_encoding_format_vorbis) { result = ma_decoder_init_vorbis_from_memory__internal(pData, dataSize, &config, pDecoder); } #endif } if (result != MA_SUCCESS) { /* Getting here means we weren't able to initialize a decoder of a specific encoding format. */ /* We use trial and error to open a decoder. We prioritize custom decoders so that if they implement the same encoding format they take priority over the built-in decoders. */ result = ma_decoder_init_custom_from_memory__internal(pData, dataSize, &config, pDecoder); /* If we get to this point and we still haven't found a decoder, and the caller has requested a specific encoding format, there's no hope for it. Abort. */ if (result != MA_SUCCESS && config.encodingFormat != ma_encoding_format_unknown) { return MA_NO_BACKEND; } /* Use trial and error for stock decoders. */ if (result != MA_SUCCESS) { #ifdef MA_HAS_WAV if (result != MA_SUCCESS) { result = ma_decoder_init_wav_from_memory__internal(pData, dataSize, &config, pDecoder); } #endif #ifdef MA_HAS_FLAC if (result != MA_SUCCESS) { result = ma_decoder_init_flac_from_memory__internal(pData, dataSize, &config, pDecoder); } #endif #ifdef MA_HAS_MP3 if (result != MA_SUCCESS) { result = ma_decoder_init_mp3_from_memory__internal(pData, dataSize, &config, pDecoder); } #endif #ifdef MA_HAS_VORBIS if (result != MA_SUCCESS) { result = ma_decoder_init_vorbis_from_memory__internal(pData, dataSize, &config, pDecoder); } #endif } } /* If at this point we still haven't successfully initialized the decoder it most likely means the backend doesn't have an implementation for loading from a file path. We'll try using miniaudio's built-in file IO for loading file. */ if (result == MA_SUCCESS) { /* Initialization was successful. Finish up. */ result = ma_decoder__postinit(&config, pDecoder); if (result != MA_SUCCESS) { /* The backend was initialized successfully, but for some reason post-initialization failed. This is most likely due to an out of memory error. We're going to abort with an error here and not try to recover. */ if (pDecoder->pBackendVTable != NULL && pDecoder->pBackendVTable->onUninit != NULL) { pDecoder->pBackendVTable->onUninit(pDecoder->pBackendUserData, &pDecoder->pBackend, &pDecoder->allocationCallbacks); } return result; } } else { /* Probably no implementation for loading from a block of memory. Use miniaudio's abstraction instead. */ result = ma_decoder__preinit_memory_wrapper(pData, dataSize, &config, pDecoder); if (result != MA_SUCCESS) { return result; } result = ma_decoder_init__internal(ma_decoder__on_read_memory, ma_decoder__on_seek_memory, NULL, &config, pDecoder); if (result != MA_SUCCESS) { return result; } } return MA_SUCCESS; } #if defined(MA_HAS_WAV) || \ defined(MA_HAS_MP3) || \ defined(MA_HAS_FLAC) || \ defined(MA_HAS_VORBIS) || \ defined(MA_HAS_OPUS) #define MA_HAS_PATH_API #endif #if defined(MA_HAS_PATH_API) static const char* ma_path_file_name(const char* path) { const char* fileName; if (path == NULL) { return NULL; } fileName = path; /* We just loop through the path until we find the last slash. */ while (path[0] != '\0') { if (path[0] == '/' || path[0] == '\\') { fileName = path; } path += 1; } /* At this point the file name is sitting on a slash, so just move forward. */ while (fileName[0] != '\0' && (fileName[0] == '/' || fileName[0] == '\\')) { fileName += 1; } return fileName; } static const wchar_t* ma_path_file_name_w(const wchar_t* path) { const wchar_t* fileName; if (path == NULL) { return NULL; } fileName = path; /* We just loop through the path until we find the last slash. */ while (path[0] != '\0') { if (path[0] == '/' || path[0] == '\\') { fileName = path; } path += 1; } /* At this point the file name is sitting on a slash, so just move forward. */ while (fileName[0] != '\0' && (fileName[0] == '/' || fileName[0] == '\\')) { fileName += 1; } return fileName; } static const char* ma_path_extension(const char* path) { const char* extension; const char* lastOccurance; if (path == NULL) { path = ""; } extension = ma_path_file_name(path); lastOccurance = NULL; /* Just find the last '.' and return. */ while (extension[0] != '\0') { if (extension[0] == '.') { extension += 1; lastOccurance = extension; } extension += 1; } return (lastOccurance != NULL) ? lastOccurance : extension; } static const wchar_t* ma_path_extension_w(const wchar_t* path) { const wchar_t* extension; const wchar_t* lastOccurance; if (path == NULL) { path = L""; } extension = ma_path_file_name_w(path); lastOccurance = NULL; /* Just find the last '.' and return. */ while (extension[0] != '\0') { if (extension[0] == '.') { extension += 1; lastOccurance = extension; } extension += 1; } return (lastOccurance != NULL) ? lastOccurance : extension; } static ma_bool32 ma_path_extension_equal(const char* path, const char* extension) { const char* ext1; const char* ext2; if (path == NULL || extension == NULL) { return MA_FALSE; } ext1 = extension; ext2 = ma_path_extension(path); #if defined(_MSC_VER) || defined(__DMC__) return _stricmp(ext1, ext2) == 0; #else return strcasecmp(ext1, ext2) == 0; #endif } static ma_bool32 ma_path_extension_equal_w(const wchar_t* path, const wchar_t* extension) { const wchar_t* ext1; const wchar_t* ext2; if (path == NULL || extension == NULL) { return MA_FALSE; } ext1 = extension; ext2 = ma_path_extension_w(path); #if defined(_MSC_VER) || defined(__WATCOMC__) || defined(__DMC__) return _wcsicmp(ext1, ext2) == 0; #else /* I'm not aware of a wide character version of strcasecmp(). I'm therefore converting the extensions to multibyte strings and comparing those. This isn't the most efficient way to do it, but it should work OK. */ { char ext1MB[4096]; char ext2MB[4096]; const wchar_t* pext1 = ext1; const wchar_t* pext2 = ext2; mbstate_t mbs1; mbstate_t mbs2; MA_ZERO_OBJECT(&mbs1); MA_ZERO_OBJECT(&mbs2); if (wcsrtombs(ext1MB, &pext1, sizeof(ext1MB), &mbs1) == (size_t)-1) { return MA_FALSE; } if (wcsrtombs(ext2MB, &pext2, sizeof(ext2MB), &mbs2) == (size_t)-1) { return MA_FALSE; } return strcasecmp(ext1MB, ext2MB) == 0; } #endif } #endif /* MA_HAS_PATH_API */ static ma_result ma_decoder__on_read_vfs(ma_decoder* pDecoder, void* pBufferOut, size_t bytesToRead, size_t* pBytesRead) { MA_ASSERT(pDecoder != NULL); MA_ASSERT(pBufferOut != NULL); return ma_vfs_or_default_read(pDecoder->data.vfs.pVFS, pDecoder->data.vfs.file, pBufferOut, bytesToRead, pBytesRead); } static ma_result ma_decoder__on_seek_vfs(ma_decoder* pDecoder, ma_int64 offset, ma_seek_origin origin) { MA_ASSERT(pDecoder != NULL); return ma_vfs_or_default_seek(pDecoder->data.vfs.pVFS, pDecoder->data.vfs.file, offset, origin); } static ma_result ma_decoder__on_tell_vfs(ma_decoder* pDecoder, ma_int64* pCursor) { MA_ASSERT(pDecoder != NULL); return ma_vfs_or_default_tell(pDecoder->data.vfs.pVFS, pDecoder->data.vfs.file, pCursor); } static ma_result ma_decoder__preinit_vfs(ma_vfs* pVFS, const char* pFilePath, const ma_decoder_config* pConfig, ma_decoder* pDecoder) { ma_result result; ma_vfs_file file; result = ma_decoder__preinit(ma_decoder__on_read_vfs, ma_decoder__on_seek_vfs, ma_decoder__on_tell_vfs, NULL, pConfig, pDecoder); if (result != MA_SUCCESS) { return result; } if (pFilePath == NULL || pFilePath[0] == '\0') { return MA_INVALID_ARGS; } result = ma_vfs_or_default_open(pVFS, pFilePath, MA_OPEN_MODE_READ, &file); if (result != MA_SUCCESS) { return result; } pDecoder->data.vfs.pVFS = pVFS; pDecoder->data.vfs.file = file; return MA_SUCCESS; } MA_API ma_result ma_decoder_init_vfs(ma_vfs* pVFS, const char* pFilePath, const ma_decoder_config* pConfig, ma_decoder* pDecoder) { ma_result result; ma_decoder_config config; config = ma_decoder_config_init_copy(pConfig); result = ma_decoder__preinit_vfs(pVFS, pFilePath, &config, pDecoder); if (result != MA_SUCCESS) { return result; } result = MA_NO_BACKEND; if (config.encodingFormat != ma_encoding_format_unknown) { #ifdef MA_HAS_WAV if (config.encodingFormat == ma_encoding_format_wav) { result = ma_decoder_init_wav__internal(&config, pDecoder); } #endif #ifdef MA_HAS_FLAC if (config.encodingFormat == ma_encoding_format_flac) { result = ma_decoder_init_flac__internal(&config, pDecoder); } #endif #ifdef MA_HAS_MP3 if (config.encodingFormat == ma_encoding_format_mp3) { result = ma_decoder_init_mp3__internal(&config, pDecoder); } #endif #ifdef MA_HAS_VORBIS if (config.encodingFormat == ma_encoding_format_vorbis) { result = ma_decoder_init_vorbis__internal(&config, pDecoder); } #endif /* Make sure we seek back to the start if we didn't initialize a decoder successfully so the next attempts have a fresh start. */ if (result != MA_SUCCESS) { ma_decoder__on_seek_vfs(pDecoder, 0, ma_seek_origin_start); } } if (result != MA_SUCCESS) { /* Getting here means we weren't able to initialize a decoder of a specific encoding format. */ /* We use trial and error to open a decoder. We prioritize custom decoders so that if they implement the same encoding format they take priority over the built-in decoders. */ if (result != MA_SUCCESS) { result = ma_decoder_init_custom__internal(&config, pDecoder); if (result != MA_SUCCESS) { ma_decoder__on_seek_vfs(pDecoder, 0, ma_seek_origin_start); } } /* If we get to this point and we still haven't found a decoder, and the caller has requested a specific encoding format, there's no hope for it. Abort. */ if (config.encodingFormat != ma_encoding_format_unknown) { return MA_NO_BACKEND; } #ifdef MA_HAS_WAV if (result != MA_SUCCESS && ma_path_extension_equal(pFilePath, "wav")) { result = ma_decoder_init_wav__internal(&config, pDecoder); if (result != MA_SUCCESS) { ma_decoder__on_seek_vfs(pDecoder, 0, ma_seek_origin_start); } } #endif #ifdef MA_HAS_FLAC if (result != MA_SUCCESS && ma_path_extension_equal(pFilePath, "flac")) { result = ma_decoder_init_flac__internal(&config, pDecoder); if (result != MA_SUCCESS) { ma_decoder__on_seek_vfs(pDecoder, 0, ma_seek_origin_start); } } #endif #ifdef MA_HAS_MP3 if (result != MA_SUCCESS && ma_path_extension_equal(pFilePath, "mp3")) { result = ma_decoder_init_mp3__internal(&config, pDecoder); if (result != MA_SUCCESS) { ma_decoder__on_seek_vfs(pDecoder, 0, ma_seek_origin_start); } } #endif } /* If we still haven't got a result just use trial and error. Otherwise we can finish up. */ if (result != MA_SUCCESS) { result = ma_decoder_init__internal(ma_decoder__on_read_vfs, ma_decoder__on_seek_vfs, NULL, &config, pDecoder); } else { result = ma_decoder__postinit(&config, pDecoder); } if (result != MA_SUCCESS) { if (pDecoder->data.vfs.file != NULL) { /* <-- Will be reset to NULL if ma_decoder_uninit() is called in one of the steps above which allows us to avoid a double close of the file. */ ma_vfs_or_default_close(pVFS, pDecoder->data.vfs.file); } return result; } return MA_SUCCESS; } static ma_result ma_decoder__preinit_vfs_w(ma_vfs* pVFS, const wchar_t* pFilePath, const ma_decoder_config* pConfig, ma_decoder* pDecoder) { ma_result result; ma_vfs_file file; result = ma_decoder__preinit(ma_decoder__on_read_vfs, ma_decoder__on_seek_vfs, ma_decoder__on_tell_vfs, NULL, pConfig, pDecoder); if (result != MA_SUCCESS) { return result; } if (pFilePath == NULL || pFilePath[0] == '\0') { return MA_INVALID_ARGS; } result = ma_vfs_or_default_open_w(pVFS, pFilePath, MA_OPEN_MODE_READ, &file); if (result != MA_SUCCESS) { return result; } pDecoder->data.vfs.pVFS = pVFS; pDecoder->data.vfs.file = file; return MA_SUCCESS; } MA_API ma_result ma_decoder_init_vfs_w(ma_vfs* pVFS, const wchar_t* pFilePath, const ma_decoder_config* pConfig, ma_decoder* pDecoder) { ma_result result; ma_decoder_config config; config = ma_decoder_config_init_copy(pConfig); result = ma_decoder__preinit_vfs_w(pVFS, pFilePath, &config, pDecoder); if (result != MA_SUCCESS) { return result; } result = MA_NO_BACKEND; if (config.encodingFormat != ma_encoding_format_unknown) { #ifdef MA_HAS_WAV if (config.encodingFormat == ma_encoding_format_wav) { result = ma_decoder_init_wav__internal(&config, pDecoder); } #endif #ifdef MA_HAS_FLAC if (config.encodingFormat == ma_encoding_format_flac) { result = ma_decoder_init_flac__internal(&config, pDecoder); } #endif #ifdef MA_HAS_MP3 if (config.encodingFormat == ma_encoding_format_mp3) { result = ma_decoder_init_mp3__internal(&config, pDecoder); } #endif #ifdef MA_HAS_VORBIS if (config.encodingFormat == ma_encoding_format_vorbis) { result = ma_decoder_init_vorbis__internal(&config, pDecoder); } #endif /* Make sure we seek back to the start if we didn't initialize a decoder successfully so the next attempts have a fresh start. */ if (result != MA_SUCCESS) { ma_decoder__on_seek_vfs(pDecoder, 0, ma_seek_origin_start); } } if (result != MA_SUCCESS) { /* Getting here means we weren't able to initialize a decoder of a specific encoding format. */ /* We use trial and error to open a decoder. We prioritize custom decoders so that if they implement the same encoding format they take priority over the built-in decoders. */ if (result != MA_SUCCESS) { result = ma_decoder_init_custom__internal(&config, pDecoder); if (result != MA_SUCCESS) { ma_decoder__on_seek_vfs(pDecoder, 0, ma_seek_origin_start); } } /* If we get to this point and we still haven't found a decoder, and the caller has requested a specific encoding format, there's no hope for it. Abort. */ if (config.encodingFormat != ma_encoding_format_unknown) { return MA_NO_BACKEND; } #ifdef MA_HAS_WAV if (result != MA_SUCCESS && ma_path_extension_equal_w(pFilePath, L"wav")) { result = ma_decoder_init_wav__internal(&config, pDecoder); if (result != MA_SUCCESS) { ma_decoder__on_seek_vfs(pDecoder, 0, ma_seek_origin_start); } } #endif #ifdef MA_HAS_FLAC if (result != MA_SUCCESS && ma_path_extension_equal_w(pFilePath, L"flac")) { result = ma_decoder_init_flac__internal(&config, pDecoder); if (result != MA_SUCCESS) { ma_decoder__on_seek_vfs(pDecoder, 0, ma_seek_origin_start); } } #endif #ifdef MA_HAS_MP3 if (result != MA_SUCCESS && ma_path_extension_equal_w(pFilePath, L"mp3")) { result = ma_decoder_init_mp3__internal(&config, pDecoder); if (result != MA_SUCCESS) { ma_decoder__on_seek_vfs(pDecoder, 0, ma_seek_origin_start); } } #endif } /* If we still haven't got a result just use trial and error. Otherwise we can finish up. */ if (result != MA_SUCCESS) { result = ma_decoder_init__internal(ma_decoder__on_read_vfs, ma_decoder__on_seek_vfs, NULL, &config, pDecoder); } else { result = ma_decoder__postinit(&config, pDecoder); } if (result != MA_SUCCESS) { ma_vfs_or_default_close(pVFS, pDecoder->data.vfs.file); return result; } return MA_SUCCESS; } static ma_result ma_decoder__preinit_file(const char* pFilePath, const ma_decoder_config* pConfig, ma_decoder* pDecoder) { ma_result result; result = ma_decoder__preinit(NULL, NULL, NULL, NULL, pConfig, pDecoder); if (result != MA_SUCCESS) { return result; } if (pFilePath == NULL || pFilePath[0] == '\0') { return MA_INVALID_ARGS; } return MA_SUCCESS; } MA_API ma_result ma_decoder_init_file(const char* pFilePath, const ma_decoder_config* pConfig, ma_decoder* pDecoder) { ma_result result; ma_decoder_config config; config = ma_decoder_config_init_copy(pConfig); result = ma_decoder__preinit_file(pFilePath, &config, pDecoder); if (result != MA_SUCCESS) { return result; } /* If the backend has support for loading from a file path we'll want to use that. If that all fails we'll fall back to the VFS path. */ result = MA_NO_BACKEND; if (config.encodingFormat != ma_encoding_format_unknown) { #ifdef MA_HAS_WAV if (config.encodingFormat == ma_encoding_format_wav) { result = ma_decoder_init_wav_from_file__internal(pFilePath, &config, pDecoder); } #endif #ifdef MA_HAS_FLAC if (config.encodingFormat == ma_encoding_format_flac) { result = ma_decoder_init_flac_from_file__internal(pFilePath, &config, pDecoder); } #endif #ifdef MA_HAS_MP3 if (config.encodingFormat == ma_encoding_format_mp3) { result = ma_decoder_init_mp3_from_file__internal(pFilePath, &config, pDecoder); } #endif #ifdef MA_HAS_VORBIS if (config.encodingFormat == ma_encoding_format_vorbis) { result = ma_decoder_init_vorbis_from_file__internal(pFilePath, &config, pDecoder); } #endif } if (result != MA_SUCCESS) { /* Getting here means we weren't able to initialize a decoder of a specific encoding format. */ /* We use trial and error to open a decoder. We prioritize custom decoders so that if they implement the same encoding format they take priority over the built-in decoders. */ result = ma_decoder_init_custom_from_file__internal(pFilePath, &config, pDecoder); /* If we get to this point and we still haven't found a decoder, and the caller has requested a specific encoding format, there's no hope for it. Abort. */ if (result != MA_SUCCESS && config.encodingFormat != ma_encoding_format_unknown) { return MA_NO_BACKEND; } /* First try loading based on the file extension so we don't waste time opening and closing files. */ #ifdef MA_HAS_WAV if (result != MA_SUCCESS && ma_path_extension_equal(pFilePath, "wav")) { result = ma_decoder_init_wav_from_file__internal(pFilePath, &config, pDecoder); } #endif #ifdef MA_HAS_FLAC if (result != MA_SUCCESS && ma_path_extension_equal(pFilePath, "flac")) { result = ma_decoder_init_flac_from_file__internal(pFilePath, &config, pDecoder); } #endif #ifdef MA_HAS_MP3 if (result != MA_SUCCESS && ma_path_extension_equal(pFilePath, "mp3")) { result = ma_decoder_init_mp3_from_file__internal(pFilePath, &config, pDecoder); } #endif #ifdef MA_HAS_VORBIS if (result != MA_SUCCESS && ma_path_extension_equal(pFilePath, "ogg")) { result = ma_decoder_init_vorbis_from_file__internal(pFilePath, &config, pDecoder); } #endif /* If we still haven't got a result just use trial and error. Custom decoders have already been attempted, so here we need only iterate over our stock decoders. */ if (result != MA_SUCCESS) { #ifdef MA_HAS_WAV if (result != MA_SUCCESS) { result = ma_decoder_init_wav_from_file__internal(pFilePath, &config, pDecoder); } #endif #ifdef MA_HAS_FLAC if (result != MA_SUCCESS) { result = ma_decoder_init_flac_from_file__internal(pFilePath, &config, pDecoder); } #endif #ifdef MA_HAS_MP3 if (result != MA_SUCCESS) { result = ma_decoder_init_mp3_from_file__internal(pFilePath, &config, pDecoder); } #endif #ifdef MA_HAS_VORBIS if (result != MA_SUCCESS) { result = ma_decoder_init_vorbis_from_file__internal(pFilePath, &config, pDecoder); } #endif } } /* If at this point we still haven't successfully initialized the decoder it most likely means the backend doesn't have an implementation for loading from a file path. We'll try using miniaudio's built-in file IO for loading file. */ if (result == MA_SUCCESS) { /* Initialization was successful. Finish up. */ result = ma_decoder__postinit(&config, pDecoder); if (result != MA_SUCCESS) { /* The backend was initialized successfully, but for some reason post-initialization failed. This is most likely due to an out of memory error. We're going to abort with an error here and not try to recover. */ if (pDecoder->pBackendVTable != NULL && pDecoder->pBackendVTable->onUninit != NULL) { pDecoder->pBackendVTable->onUninit(pDecoder->pBackendUserData, &pDecoder->pBackend, &pDecoder->allocationCallbacks); } return result; } } else { /* Probably no implementation for loading from a file path. Use miniaudio's file IO instead. */ result = ma_decoder_init_vfs(NULL, pFilePath, pConfig, pDecoder); if (result != MA_SUCCESS) { return result; } } return MA_SUCCESS; } static ma_result ma_decoder__preinit_file_w(const wchar_t* pFilePath, const ma_decoder_config* pConfig, ma_decoder* pDecoder) { ma_result result; result = ma_decoder__preinit(NULL, NULL, NULL, NULL, pConfig, pDecoder); if (result != MA_SUCCESS) { return result; } if (pFilePath == NULL || pFilePath[0] == '\0') { return MA_INVALID_ARGS; } return MA_SUCCESS; } MA_API ma_result ma_decoder_init_file_w(const wchar_t* pFilePath, const ma_decoder_config* pConfig, ma_decoder* pDecoder) { ma_result result; ma_decoder_config config; config = ma_decoder_config_init_copy(pConfig); result = ma_decoder__preinit_file_w(pFilePath, &config, pDecoder); if (result != MA_SUCCESS) { return result; } /* If the backend has support for loading from a file path we'll want to use that. If that all fails we'll fall back to the VFS path. */ result = MA_NO_BACKEND; if (config.encodingFormat != ma_encoding_format_unknown) { #ifdef MA_HAS_WAV if (config.encodingFormat == ma_encoding_format_wav) { result = ma_decoder_init_wav_from_file_w__internal(pFilePath, &config, pDecoder); } #endif #ifdef MA_HAS_FLAC if (config.encodingFormat == ma_encoding_format_flac) { result = ma_decoder_init_flac_from_file_w__internal(pFilePath, &config, pDecoder); } #endif #ifdef MA_HAS_MP3 if (config.encodingFormat == ma_encoding_format_mp3) { result = ma_decoder_init_mp3_from_file_w__internal(pFilePath, &config, pDecoder); } #endif #ifdef MA_HAS_VORBIS if (config.encodingFormat == ma_encoding_format_vorbis) { result = ma_decoder_init_vorbis_from_file_w__internal(pFilePath, &config, pDecoder); } #endif } if (result != MA_SUCCESS) { /* Getting here means we weren't able to initialize a decoder of a specific encoding format. */ /* We use trial and error to open a decoder. We prioritize custom decoders so that if they implement the same encoding format they take priority over the built-in decoders. */ result = ma_decoder_init_custom_from_file_w__internal(pFilePath, &config, pDecoder); /* If we get to this point and we still haven't found a decoder, and the caller has requested a specific encoding format, there's no hope for it. Abort. */ if (result != MA_SUCCESS && config.encodingFormat != ma_encoding_format_unknown) { return MA_NO_BACKEND; } /* First try loading based on the file extension so we don't waste time opening and closing files. */ #ifdef MA_HAS_WAV if (result != MA_SUCCESS && ma_path_extension_equal_w(pFilePath, L"wav")) { result = ma_decoder_init_wav_from_file_w__internal(pFilePath, &config, pDecoder); } #endif #ifdef MA_HAS_FLAC if (result != MA_SUCCESS && ma_path_extension_equal_w(pFilePath, L"flac")) { result = ma_decoder_init_flac_from_file_w__internal(pFilePath, &config, pDecoder); } #endif #ifdef MA_HAS_MP3 if (result != MA_SUCCESS && ma_path_extension_equal_w(pFilePath, L"mp3")) { result = ma_decoder_init_mp3_from_file_w__internal(pFilePath, &config, pDecoder); } #endif #ifdef MA_HAS_VORBIS if (result != MA_SUCCESS && ma_path_extension_equal_w(pFilePath, L"ogg")) { result = ma_decoder_init_vorbis_from_file_w__internal(pFilePath, &config, pDecoder); } #endif /* If we still haven't got a result just use trial and error. Custom decoders have already been attempted, so here we need only iterate over our stock decoders. */ if (result != MA_SUCCESS) { #ifdef MA_HAS_WAV if (result != MA_SUCCESS) { result = ma_decoder_init_wav_from_file_w__internal(pFilePath, &config, pDecoder); } #endif #ifdef MA_HAS_FLAC if (result != MA_SUCCESS) { result = ma_decoder_init_flac_from_file_w__internal(pFilePath, &config, pDecoder); } #endif #ifdef MA_HAS_MP3 if (result != MA_SUCCESS) { result = ma_decoder_init_mp3_from_file_w__internal(pFilePath, &config, pDecoder); } #endif #ifdef MA_HAS_VORBIS if (result != MA_SUCCESS) { result = ma_decoder_init_vorbis_from_file_w__internal(pFilePath, &config, pDecoder); } #endif } } /* If at this point we still haven't successfully initialized the decoder it most likely means the backend doesn't have an implementation for loading from a file path. We'll try using miniaudio's built-in file IO for loading file. */ if (result == MA_SUCCESS) { /* Initialization was successful. Finish up. */ result = ma_decoder__postinit(&config, pDecoder); if (result != MA_SUCCESS) { /* The backend was initialized successfully, but for some reason post-initialization failed. This is most likely due to an out of memory error. We're going to abort with an error here and not try to recover. */ if (pDecoder->pBackendVTable != NULL && pDecoder->pBackendVTable->onUninit != NULL) { pDecoder->pBackendVTable->onUninit(pDecoder->pBackendUserData, &pDecoder->pBackend, &pDecoder->allocationCallbacks); } return result; } } else { /* Probably no implementation for loading from a file path. Use miniaudio's file IO instead. */ result = ma_decoder_init_vfs_w(NULL, pFilePath, pConfig, pDecoder); if (result != MA_SUCCESS) { return result; } } return MA_SUCCESS; } MA_API ma_result ma_decoder_uninit(ma_decoder* pDecoder) { if (pDecoder == NULL) { return MA_INVALID_ARGS; } if (pDecoder->pBackend != NULL) { if (pDecoder->pBackendVTable != NULL && pDecoder->pBackendVTable->onUninit != NULL) { pDecoder->pBackendVTable->onUninit(pDecoder->pBackendUserData, pDecoder->pBackend, &pDecoder->allocationCallbacks); } } if (pDecoder->onRead == ma_decoder__on_read_vfs) { ma_vfs_or_default_close(pDecoder->data.vfs.pVFS, pDecoder->data.vfs.file); pDecoder->data.vfs.file = NULL; } ma_data_converter_uninit(&pDecoder->converter, &pDecoder->allocationCallbacks); ma_data_source_uninit(&pDecoder->ds); if (pDecoder->pInputCache != NULL) { ma_free(pDecoder->pInputCache, &pDecoder->allocationCallbacks); } return MA_SUCCESS; } MA_API ma_result ma_decoder_read_pcm_frames(ma_decoder* pDecoder, void* pFramesOut, ma_uint64 frameCount, ma_uint64* pFramesRead) { ma_result result = MA_SUCCESS; ma_uint64 totalFramesReadOut; void* pRunningFramesOut; if (pFramesRead != NULL) { *pFramesRead = 0; /* Safety. */ } if (frameCount == 0) { return MA_INVALID_ARGS; } if (pDecoder == NULL) { return MA_INVALID_ARGS; } if (pDecoder->pBackend == NULL) { return MA_INVALID_OPERATION; } /* Fast path. */ if (pDecoder->converter.isPassthrough) { result = ma_data_source_read_pcm_frames(pDecoder->pBackend, pFramesOut, frameCount, &totalFramesReadOut); } else { /* Getting here means we need to do data conversion. If we're seeking forward and are _not_ doing resampling we can run this in a fast path. If we're doing resampling we need to run through each sample because we need to ensure it's internal cache is updated. */ if (pFramesOut == NULL && pDecoder->converter.hasResampler == MA_FALSE) { result = ma_data_source_read_pcm_frames(pDecoder->pBackend, NULL, frameCount, &totalFramesReadOut); } else { /* Slow path. Need to run everything through the data converter. */ ma_format internalFormat; ma_uint32 internalChannels; totalFramesReadOut = 0; pRunningFramesOut = pFramesOut; result = ma_data_source_get_data_format(pDecoder->pBackend, &internalFormat, &internalChannels, NULL, NULL, 0); if (result != MA_SUCCESS) { return result; /* Failed to retrieve the internal format and channel count. */ } /* We run a different path depending on whether or not we are using a heap-allocated intermediary buffer or not. If the data converter does not support the calculation of the required number of input frames, we'll use the heap-allocated path. Otherwise we'll use the stack-allocated path. */ if (pDecoder->pInputCache != NULL) { /* We don't have a way of determining the required number of input frames, so need to persistently store input data in a cache. */ while (totalFramesReadOut < frameCount) { ma_uint64 framesToReadThisIterationIn; ma_uint64 framesToReadThisIterationOut; /* If there's any data available in the cache, that needs to get processed first. */ if (pDecoder->inputCacheRemaining > 0) { framesToReadThisIterationOut = (frameCount - totalFramesReadOut); framesToReadThisIterationIn = framesToReadThisIterationOut; if (framesToReadThisIterationIn > pDecoder->inputCacheRemaining) { framesToReadThisIterationIn = pDecoder->inputCacheRemaining; } result = ma_data_converter_process_pcm_frames(&pDecoder->converter, ma_offset_pcm_frames_ptr(pDecoder->pInputCache, pDecoder->inputCacheConsumed, internalFormat, internalChannels), &framesToReadThisIterationIn, pRunningFramesOut, &framesToReadThisIterationOut); if (result != MA_SUCCESS) { break; } pDecoder->inputCacheConsumed += framesToReadThisIterationIn; pDecoder->inputCacheRemaining -= framesToReadThisIterationIn; totalFramesReadOut += framesToReadThisIterationOut; if (pRunningFramesOut != NULL) { pRunningFramesOut = ma_offset_ptr(pRunningFramesOut, framesToReadThisIterationOut * ma_get_bytes_per_frame(pDecoder->outputFormat, pDecoder->outputChannels)); } if (framesToReadThisIterationIn == 0 && framesToReadThisIterationOut == 0) { break; /* We're done. */ } } /* Getting here means there's no data in the cache and we need to fill it up from the data source. */ if (pDecoder->inputCacheRemaining == 0) { pDecoder->inputCacheConsumed = 0; result = ma_data_source_read_pcm_frames(pDecoder->pBackend, pDecoder->pInputCache, pDecoder->inputCacheCap, &pDecoder->inputCacheRemaining); if (result != MA_SUCCESS) { break; } } } } else { /* We have a way of determining the required number of input frames so just use the stack. */ while (totalFramesReadOut < frameCount) { ma_uint8 pIntermediaryBuffer[MA_DATA_CONVERTER_STACK_BUFFER_SIZE]; /* In internal format. */ ma_uint64 intermediaryBufferCap = sizeof(pIntermediaryBuffer) / ma_get_bytes_per_frame(internalFormat, internalChannels); ma_uint64 framesToReadThisIterationIn; ma_uint64 framesReadThisIterationIn; ma_uint64 framesToReadThisIterationOut; ma_uint64 framesReadThisIterationOut; ma_uint64 requiredInputFrameCount; framesToReadThisIterationOut = (frameCount - totalFramesReadOut); framesToReadThisIterationIn = framesToReadThisIterationOut; if (framesToReadThisIterationIn > intermediaryBufferCap) { framesToReadThisIterationIn = intermediaryBufferCap; } ma_data_converter_get_required_input_frame_count(&pDecoder->converter, framesToReadThisIterationOut, &requiredInputFrameCount); if (framesToReadThisIterationIn > requiredInputFrameCount) { framesToReadThisIterationIn = requiredInputFrameCount; } if (requiredInputFrameCount > 0) { result = ma_data_source_read_pcm_frames(pDecoder->pBackend, pIntermediaryBuffer, framesToReadThisIterationIn, &framesReadThisIterationIn); } else { framesReadThisIterationIn = 0; } /* At this point we have our decoded data in input format and now we need to convert to output format. Note that even if we didn't read any input frames, we still want to try processing frames because there may some output frames generated from cached input data. */ framesReadThisIterationOut = framesToReadThisIterationOut; result = ma_data_converter_process_pcm_frames(&pDecoder->converter, pIntermediaryBuffer, &framesReadThisIterationIn, pRunningFramesOut, &framesReadThisIterationOut); if (result != MA_SUCCESS) { break; } totalFramesReadOut += framesReadThisIterationOut; if (pRunningFramesOut != NULL) { pRunningFramesOut = ma_offset_ptr(pRunningFramesOut, framesReadThisIterationOut * ma_get_bytes_per_frame(pDecoder->outputFormat, pDecoder->outputChannels)); } if (framesReadThisIterationIn == 0 && framesReadThisIterationOut == 0) { break; /* We're done. */ } } } } } pDecoder->readPointerInPCMFrames += totalFramesReadOut; if (pFramesRead != NULL) { *pFramesRead = totalFramesReadOut; } if (result == MA_SUCCESS && totalFramesReadOut == 0) { result = MA_AT_END; } return result; } MA_API ma_result ma_decoder_seek_to_pcm_frame(ma_decoder* pDecoder, ma_uint64 frameIndex) { if (pDecoder == NULL) { return MA_INVALID_ARGS; } if (pDecoder->pBackend != NULL) { ma_result result; ma_uint64 internalFrameIndex; ma_uint32 internalSampleRate; ma_uint64 currentFrameIndex; result = ma_data_source_get_data_format(pDecoder->pBackend, NULL, NULL, &internalSampleRate, NULL, 0); if (result != MA_SUCCESS) { return result; /* Failed to retrieve the internal sample rate. */ } if (internalSampleRate == pDecoder->outputSampleRate) { internalFrameIndex = frameIndex; } else { internalFrameIndex = ma_calculate_frame_count_after_resampling(internalSampleRate, pDecoder->outputSampleRate, frameIndex); } /* Only seek if we're requesting a different frame to what we're currently sitting on. */ ma_data_source_get_cursor_in_pcm_frames(pDecoder->pBackend, ¤tFrameIndex); if (currentFrameIndex != internalFrameIndex) { result = ma_data_source_seek_to_pcm_frame(pDecoder->pBackend, internalFrameIndex); if (result == MA_SUCCESS) { pDecoder->readPointerInPCMFrames = frameIndex; } /* Reset the data converter so that any cached data in the resampler is cleared. */ ma_data_converter_reset(&pDecoder->converter); } return result; } /* Should never get here, but if we do it means onSeekToPCMFrame was not set by the backend. */ return MA_INVALID_ARGS; } MA_API ma_result ma_decoder_get_data_format(ma_decoder* pDecoder, ma_format* pFormat, ma_uint32* pChannels, ma_uint32* pSampleRate, ma_channel* pChannelMap, size_t channelMapCap) { if (pDecoder == NULL) { return MA_INVALID_ARGS; } if (pFormat != NULL) { *pFormat = pDecoder->outputFormat; } if (pChannels != NULL) { *pChannels = pDecoder->outputChannels; } if (pSampleRate != NULL) { *pSampleRate = pDecoder->outputSampleRate; } if (pChannelMap != NULL) { ma_data_converter_get_output_channel_map(&pDecoder->converter, pChannelMap, channelMapCap); } return MA_SUCCESS; } MA_API ma_result ma_decoder_get_cursor_in_pcm_frames(ma_decoder* pDecoder, ma_uint64* pCursor) { if (pCursor == NULL) { return MA_INVALID_ARGS; } *pCursor = 0; if (pDecoder == NULL) { return MA_INVALID_ARGS; } *pCursor = pDecoder->readPointerInPCMFrames; return MA_SUCCESS; } MA_API ma_result ma_decoder_get_length_in_pcm_frames(ma_decoder* pDecoder, ma_uint64* pLength) { if (pLength == NULL) { return MA_INVALID_ARGS; } *pLength = 0; if (pDecoder == NULL) { return MA_INVALID_ARGS; } if (pDecoder->pBackend != NULL) { ma_result result; ma_uint64 internalLengthInPCMFrames; ma_uint32 internalSampleRate; result = ma_data_source_get_length_in_pcm_frames(pDecoder->pBackend, &internalLengthInPCMFrames); if (result != MA_SUCCESS) { return result; /* Failed to retrieve the internal length. */ } result = ma_data_source_get_data_format(pDecoder->pBackend, NULL, NULL, &internalSampleRate, NULL, 0); if (result != MA_SUCCESS) { return result; /* Failed to retrieve the internal sample rate. */ } if (internalSampleRate == pDecoder->outputSampleRate) { *pLength = internalLengthInPCMFrames; } else { *pLength = ma_calculate_frame_count_after_resampling(pDecoder->outputSampleRate, internalSampleRate, internalLengthInPCMFrames); } return MA_SUCCESS; } else { return MA_NO_BACKEND; } } MA_API ma_result ma_decoder_get_available_frames(ma_decoder* pDecoder, ma_uint64* pAvailableFrames) { ma_result result; ma_uint64 totalFrameCount; if (pAvailableFrames == NULL) { return MA_INVALID_ARGS; } *pAvailableFrames = 0; if (pDecoder == NULL) { return MA_INVALID_ARGS; } result = ma_decoder_get_length_in_pcm_frames(pDecoder, &totalFrameCount); if (result != MA_SUCCESS) { return result; } if (totalFrameCount <= pDecoder->readPointerInPCMFrames) { *pAvailableFrames = 0; } else { *pAvailableFrames = totalFrameCount - pDecoder->readPointerInPCMFrames; } return MA_SUCCESS; } static ma_result ma_decoder__full_decode_and_uninit(ma_decoder* pDecoder, ma_decoder_config* pConfigOut, ma_uint64* pFrameCountOut, void** ppPCMFramesOut) { ma_result result; ma_uint64 totalFrameCount; ma_uint64 bpf; ma_uint64 dataCapInFrames; void* pPCMFramesOut; MA_ASSERT(pDecoder != NULL); totalFrameCount = 0; bpf = ma_get_bytes_per_frame(pDecoder->outputFormat, pDecoder->outputChannels); /* The frame count is unknown until we try reading. Thus, we just run in a loop. */ dataCapInFrames = 0; pPCMFramesOut = NULL; for (;;) { ma_uint64 frameCountToTryReading; ma_uint64 framesJustRead; /* Make room if there's not enough. */ if (totalFrameCount == dataCapInFrames) { void* pNewPCMFramesOut; ma_uint64 newDataCapInFrames = dataCapInFrames*2; if (newDataCapInFrames == 0) { newDataCapInFrames = 4096; } if ((newDataCapInFrames * bpf) > MA_SIZE_MAX) { ma_free(pPCMFramesOut, &pDecoder->allocationCallbacks); return MA_TOO_BIG; } pNewPCMFramesOut = (void*)ma_realloc(pPCMFramesOut, (size_t)(newDataCapInFrames * bpf), &pDecoder->allocationCallbacks); if (pNewPCMFramesOut == NULL) { ma_free(pPCMFramesOut, &pDecoder->allocationCallbacks); return MA_OUT_OF_MEMORY; } dataCapInFrames = newDataCapInFrames; pPCMFramesOut = pNewPCMFramesOut; } frameCountToTryReading = dataCapInFrames - totalFrameCount; MA_ASSERT(frameCountToTryReading > 0); result = ma_decoder_read_pcm_frames(pDecoder, (ma_uint8*)pPCMFramesOut + (totalFrameCount * bpf), frameCountToTryReading, &framesJustRead); totalFrameCount += framesJustRead; if (result != MA_SUCCESS) { break; } if (framesJustRead < frameCountToTryReading) { break; } } if (pConfigOut != NULL) { pConfigOut->format = pDecoder->outputFormat; pConfigOut->channels = pDecoder->outputChannels; pConfigOut->sampleRate = pDecoder->outputSampleRate; } if (ppPCMFramesOut != NULL) { *ppPCMFramesOut = pPCMFramesOut; } else { ma_free(pPCMFramesOut, &pDecoder->allocationCallbacks); } if (pFrameCountOut != NULL) { *pFrameCountOut = totalFrameCount; } ma_decoder_uninit(pDecoder); return MA_SUCCESS; } MA_API ma_result ma_decode_from_vfs(ma_vfs* pVFS, const char* pFilePath, ma_decoder_config* pConfig, ma_uint64* pFrameCountOut, void** ppPCMFramesOut) { ma_result result; ma_decoder_config config; ma_decoder decoder; if (pFrameCountOut != NULL) { *pFrameCountOut = 0; } if (ppPCMFramesOut != NULL) { *ppPCMFramesOut = NULL; } config = ma_decoder_config_init_copy(pConfig); result = ma_decoder_init_vfs(pVFS, pFilePath, &config, &decoder); if (result != MA_SUCCESS) { return result; } result = ma_decoder__full_decode_and_uninit(&decoder, pConfig, pFrameCountOut, ppPCMFramesOut); return result; } MA_API ma_result ma_decode_file(const char* pFilePath, ma_decoder_config* pConfig, ma_uint64* pFrameCountOut, void** ppPCMFramesOut) { return ma_decode_from_vfs(NULL, pFilePath, pConfig, pFrameCountOut, ppPCMFramesOut); } MA_API ma_result ma_decode_memory(const void* pData, size_t dataSize, ma_decoder_config* pConfig, ma_uint64* pFrameCountOut, void** ppPCMFramesOut) { ma_decoder_config config; ma_decoder decoder; ma_result result; if (pFrameCountOut != NULL) { *pFrameCountOut = 0; } if (ppPCMFramesOut != NULL) { *ppPCMFramesOut = NULL; } if (pData == NULL || dataSize == 0) { return MA_INVALID_ARGS; } config = ma_decoder_config_init_copy(pConfig); result = ma_decoder_init_memory(pData, dataSize, &config, &decoder); if (result != MA_SUCCESS) { return result; } return ma_decoder__full_decode_and_uninit(&decoder, pConfig, pFrameCountOut, ppPCMFramesOut); } #endif /* MA_NO_DECODING */ #ifndef MA_NO_ENCODING #if defined(MA_HAS_WAV) static size_t ma_encoder__internal_on_write_wav(void* pUserData, const void* pData, size_t bytesToWrite) { ma_encoder* pEncoder = (ma_encoder*)pUserData; size_t bytesWritten = 0; MA_ASSERT(pEncoder != NULL); pEncoder->onWrite(pEncoder, pData, bytesToWrite, &bytesWritten); return bytesWritten; } static ma_bool32 ma_encoder__internal_on_seek_wav(void* pUserData, int offset, ma_dr_wav_seek_origin origin) { ma_encoder* pEncoder = (ma_encoder*)pUserData; ma_result result; MA_ASSERT(pEncoder != NULL); result = pEncoder->onSeek(pEncoder, offset, (origin == ma_dr_wav_seek_origin_start) ? ma_seek_origin_start : ma_seek_origin_current); if (result != MA_SUCCESS) { return MA_FALSE; } else { return MA_TRUE; } } static ma_result ma_encoder__on_init_wav(ma_encoder* pEncoder) { ma_dr_wav_data_format wavFormat; ma_allocation_callbacks allocationCallbacks; ma_dr_wav* pWav; MA_ASSERT(pEncoder != NULL); pWav = (ma_dr_wav*)ma_malloc(sizeof(*pWav), &pEncoder->config.allocationCallbacks); if (pWav == NULL) { return MA_OUT_OF_MEMORY; } wavFormat.container = ma_dr_wav_container_riff; wavFormat.channels = pEncoder->config.channels; wavFormat.sampleRate = pEncoder->config.sampleRate; wavFormat.bitsPerSample = ma_get_bytes_per_sample(pEncoder->config.format) * 8; if (pEncoder->config.format == ma_format_f32) { wavFormat.format = MA_DR_WAVE_FORMAT_IEEE_FLOAT; } else { wavFormat.format = MA_DR_WAVE_FORMAT_PCM; } allocationCallbacks.pUserData = pEncoder->config.allocationCallbacks.pUserData; allocationCallbacks.onMalloc = pEncoder->config.allocationCallbacks.onMalloc; allocationCallbacks.onRealloc = pEncoder->config.allocationCallbacks.onRealloc; allocationCallbacks.onFree = pEncoder->config.allocationCallbacks.onFree; if (!ma_dr_wav_init_write(pWav, &wavFormat, ma_encoder__internal_on_write_wav, ma_encoder__internal_on_seek_wav, pEncoder, &allocationCallbacks)) { return MA_ERROR; } pEncoder->pInternalEncoder = pWav; return MA_SUCCESS; } static void ma_encoder__on_uninit_wav(ma_encoder* pEncoder) { ma_dr_wav* pWav; MA_ASSERT(pEncoder != NULL); pWav = (ma_dr_wav*)pEncoder->pInternalEncoder; MA_ASSERT(pWav != NULL); ma_dr_wav_uninit(pWav); ma_free(pWav, &pEncoder->config.allocationCallbacks); } static ma_result ma_encoder__on_write_pcm_frames_wav(ma_encoder* pEncoder, const void* pFramesIn, ma_uint64 frameCount, ma_uint64* pFramesWritten) { ma_dr_wav* pWav; ma_uint64 framesWritten; MA_ASSERT(pEncoder != NULL); pWav = (ma_dr_wav*)pEncoder->pInternalEncoder; MA_ASSERT(pWav != NULL); framesWritten = ma_dr_wav_write_pcm_frames(pWav, frameCount, pFramesIn); if (pFramesWritten != NULL) { *pFramesWritten = framesWritten; } return MA_SUCCESS; } #endif MA_API ma_encoder_config ma_encoder_config_init(ma_encoding_format encodingFormat, ma_format format, ma_uint32 channels, ma_uint32 sampleRate) { ma_encoder_config config; MA_ZERO_OBJECT(&config); config.encodingFormat = encodingFormat; config.format = format; config.channels = channels; config.sampleRate = sampleRate; return config; } MA_API ma_result ma_encoder_preinit(const ma_encoder_config* pConfig, ma_encoder* pEncoder) { ma_result result; if (pEncoder == NULL) { return MA_INVALID_ARGS; } MA_ZERO_OBJECT(pEncoder); if (pConfig == NULL) { return MA_INVALID_ARGS; } if (pConfig->format == ma_format_unknown || pConfig->channels == 0 || pConfig->sampleRate == 0) { return MA_INVALID_ARGS; } pEncoder->config = *pConfig; result = ma_allocation_callbacks_init_copy(&pEncoder->config.allocationCallbacks, &pConfig->allocationCallbacks); if (result != MA_SUCCESS) { return result; } return MA_SUCCESS; } MA_API ma_result ma_encoder_init__internal(ma_encoder_write_proc onWrite, ma_encoder_seek_proc onSeek, void* pUserData, ma_encoder* pEncoder) { ma_result result = MA_SUCCESS; /* This assumes ma_encoder_preinit() has been called prior. */ MA_ASSERT(pEncoder != NULL); if (onWrite == NULL || onSeek == NULL) { return MA_INVALID_ARGS; } pEncoder->onWrite = onWrite; pEncoder->onSeek = onSeek; pEncoder->pUserData = pUserData; switch (pEncoder->config.encodingFormat) { case ma_encoding_format_wav: { #if defined(MA_HAS_WAV) pEncoder->onInit = ma_encoder__on_init_wav; pEncoder->onUninit = ma_encoder__on_uninit_wav; pEncoder->onWritePCMFrames = ma_encoder__on_write_pcm_frames_wav; #else result = MA_NO_BACKEND; #endif } break; default: { result = MA_INVALID_ARGS; } break; } /* Getting here means we should have our backend callbacks set up. */ if (result == MA_SUCCESS) { result = pEncoder->onInit(pEncoder); } return result; } static ma_result ma_encoder__on_write_vfs(ma_encoder* pEncoder, const void* pBufferIn, size_t bytesToWrite, size_t* pBytesWritten) { return ma_vfs_or_default_write(pEncoder->data.vfs.pVFS, pEncoder->data.vfs.file, pBufferIn, bytesToWrite, pBytesWritten); } static ma_result ma_encoder__on_seek_vfs(ma_encoder* pEncoder, ma_int64 offset, ma_seek_origin origin) { return ma_vfs_or_default_seek(pEncoder->data.vfs.pVFS, pEncoder->data.vfs.file, offset, origin); } MA_API ma_result ma_encoder_init_vfs(ma_vfs* pVFS, const char* pFilePath, const ma_encoder_config* pConfig, ma_encoder* pEncoder) { ma_result result; ma_vfs_file file; result = ma_encoder_preinit(pConfig, pEncoder); if (result != MA_SUCCESS) { return result; } /* Now open the file. If this fails we don't need to uninitialize the encoder. */ result = ma_vfs_or_default_open(pVFS, pFilePath, MA_OPEN_MODE_WRITE, &file); if (result != MA_SUCCESS) { return result; } pEncoder->data.vfs.pVFS = pVFS; pEncoder->data.vfs.file = file; result = ma_encoder_init__internal(ma_encoder__on_write_vfs, ma_encoder__on_seek_vfs, NULL, pEncoder); if (result != MA_SUCCESS) { ma_vfs_or_default_close(pVFS, file); return result; } return MA_SUCCESS; } MA_API ma_result ma_encoder_init_vfs_w(ma_vfs* pVFS, const wchar_t* pFilePath, const ma_encoder_config* pConfig, ma_encoder* pEncoder) { ma_result result; ma_vfs_file file; result = ma_encoder_preinit(pConfig, pEncoder); if (result != MA_SUCCESS) { return result; } /* Now open the file. If this fails we don't need to uninitialize the encoder. */ result = ma_vfs_or_default_open_w(pVFS, pFilePath, MA_OPEN_MODE_WRITE, &file); if (result != MA_SUCCESS) { return result; } pEncoder->data.vfs.pVFS = pVFS; pEncoder->data.vfs.file = file; result = ma_encoder_init__internal(ma_encoder__on_write_vfs, ma_encoder__on_seek_vfs, NULL, pEncoder); if (result != MA_SUCCESS) { ma_vfs_or_default_close(pVFS, file); return result; } return MA_SUCCESS; } MA_API ma_result ma_encoder_init_file(const char* pFilePath, const ma_encoder_config* pConfig, ma_encoder* pEncoder) { return ma_encoder_init_vfs(NULL, pFilePath, pConfig, pEncoder); } MA_API ma_result ma_encoder_init_file_w(const wchar_t* pFilePath, const ma_encoder_config* pConfig, ma_encoder* pEncoder) { return ma_encoder_init_vfs_w(NULL, pFilePath, pConfig, pEncoder); } MA_API ma_result ma_encoder_init(ma_encoder_write_proc onWrite, ma_encoder_seek_proc onSeek, void* pUserData, const ma_encoder_config* pConfig, ma_encoder* pEncoder) { ma_result result; result = ma_encoder_preinit(pConfig, pEncoder); if (result != MA_SUCCESS) { return result; } return ma_encoder_init__internal(onWrite, onSeek, pUserData, pEncoder); } MA_API void ma_encoder_uninit(ma_encoder* pEncoder) { if (pEncoder == NULL) { return; } if (pEncoder->onUninit) { pEncoder->onUninit(pEncoder); } /* If we have a file handle, close it. */ if (pEncoder->onWrite == ma_encoder__on_write_vfs) { ma_vfs_or_default_close(pEncoder->data.vfs.pVFS, pEncoder->data.vfs.file); pEncoder->data.vfs.file = NULL; } } MA_API ma_result ma_encoder_write_pcm_frames(ma_encoder* pEncoder, const void* pFramesIn, ma_uint64 frameCount, ma_uint64* pFramesWritten) { if (pFramesWritten != NULL) { *pFramesWritten = 0; } if (pEncoder == NULL || pFramesIn == NULL) { return MA_INVALID_ARGS; } return pEncoder->onWritePCMFrames(pEncoder, pFramesIn, frameCount, pFramesWritten); } #endif /* MA_NO_ENCODING */ /************************************************************************************************************************************************************** Generation **************************************************************************************************************************************************************/ #ifndef MA_NO_GENERATION MA_API ma_waveform_config ma_waveform_config_init(ma_format format, ma_uint32 channels, ma_uint32 sampleRate, ma_waveform_type type, double amplitude, double frequency) { ma_waveform_config config; MA_ZERO_OBJECT(&config); config.format = format; config.channels = channels; config.sampleRate = sampleRate; config.type = type; config.amplitude = amplitude; config.frequency = frequency; return config; } static ma_result ma_waveform__data_source_on_read(ma_data_source* pDataSource, void* pFramesOut, ma_uint64 frameCount, ma_uint64* pFramesRead) { return ma_waveform_read_pcm_frames((ma_waveform*)pDataSource, pFramesOut, frameCount, pFramesRead); } static ma_result ma_waveform__data_source_on_seek(ma_data_source* pDataSource, ma_uint64 frameIndex) { return ma_waveform_seek_to_pcm_frame((ma_waveform*)pDataSource, frameIndex); } static ma_result ma_waveform__data_source_on_get_data_format(ma_data_source* pDataSource, ma_format* pFormat, ma_uint32* pChannels, ma_uint32* pSampleRate, ma_channel* pChannelMap, size_t channelMapCap) { ma_waveform* pWaveform = (ma_waveform*)pDataSource; *pFormat = pWaveform->config.format; *pChannels = pWaveform->config.channels; *pSampleRate = pWaveform->config.sampleRate; ma_channel_map_init_standard(ma_standard_channel_map_default, pChannelMap, channelMapCap, pWaveform->config.channels); return MA_SUCCESS; } static ma_result ma_waveform__data_source_on_get_cursor(ma_data_source* pDataSource, ma_uint64* pCursor) { ma_waveform* pWaveform = (ma_waveform*)pDataSource; *pCursor = (ma_uint64)(pWaveform->time / pWaveform->advance); return MA_SUCCESS; } static double ma_waveform__calculate_advance(ma_uint32 sampleRate, double frequency) { return (1.0 / (sampleRate / frequency)); } static void ma_waveform__update_advance(ma_waveform* pWaveform) { pWaveform->advance = ma_waveform__calculate_advance(pWaveform->config.sampleRate, pWaveform->config.frequency); } static ma_data_source_vtable g_ma_waveform_data_source_vtable = { ma_waveform__data_source_on_read, ma_waveform__data_source_on_seek, ma_waveform__data_source_on_get_data_format, ma_waveform__data_source_on_get_cursor, NULL, /* onGetLength. There's no notion of a length in waveforms. */ NULL, /* onSetLooping */ 0 }; MA_API ma_result ma_waveform_init(const ma_waveform_config* pConfig, ma_waveform* pWaveform) { ma_result result; ma_data_source_config dataSourceConfig; if (pWaveform == NULL) { return MA_INVALID_ARGS; } MA_ZERO_OBJECT(pWaveform); dataSourceConfig = ma_data_source_config_init(); dataSourceConfig.vtable = &g_ma_waveform_data_source_vtable; result = ma_data_source_init(&dataSourceConfig, &pWaveform->ds); if (result != MA_SUCCESS) { return result; } pWaveform->config = *pConfig; pWaveform->advance = ma_waveform__calculate_advance(pWaveform->config.sampleRate, pWaveform->config.frequency); pWaveform->time = 0; return MA_SUCCESS; } MA_API void ma_waveform_uninit(ma_waveform* pWaveform) { if (pWaveform == NULL) { return; } ma_data_source_uninit(&pWaveform->ds); } MA_API ma_result ma_waveform_set_amplitude(ma_waveform* pWaveform, double amplitude) { if (pWaveform == NULL) { return MA_INVALID_ARGS; } pWaveform->config.amplitude = amplitude; return MA_SUCCESS; } MA_API ma_result ma_waveform_set_frequency(ma_waveform* pWaveform, double frequency) { if (pWaveform == NULL) { return MA_INVALID_ARGS; } pWaveform->config.frequency = frequency; ma_waveform__update_advance(pWaveform); return MA_SUCCESS; } MA_API ma_result ma_waveform_set_type(ma_waveform* pWaveform, ma_waveform_type type) { if (pWaveform == NULL) { return MA_INVALID_ARGS; } pWaveform->config.type = type; return MA_SUCCESS; } MA_API ma_result ma_waveform_set_sample_rate(ma_waveform* pWaveform, ma_uint32 sampleRate) { if (pWaveform == NULL) { return MA_INVALID_ARGS; } pWaveform->config.sampleRate = sampleRate; ma_waveform__update_advance(pWaveform); return MA_SUCCESS; } static float ma_waveform_sine_f32(double time, double amplitude) { return (float)(ma_sind(MA_TAU_D * time) * amplitude); } static ma_int16 ma_waveform_sine_s16(double time, double amplitude) { return ma_pcm_sample_f32_to_s16(ma_waveform_sine_f32(time, amplitude)); } static float ma_waveform_square_f32(double time, double dutyCycle, double amplitude) { double f = time - (ma_int64)time; double r; if (f < dutyCycle) { r = amplitude; } else { r = -amplitude; } return (float)r; } static ma_int16 ma_waveform_square_s16(double time, double dutyCycle, double amplitude) { return ma_pcm_sample_f32_to_s16(ma_waveform_square_f32(time, dutyCycle, amplitude)); } static float ma_waveform_triangle_f32(double time, double amplitude) { double f = time - (ma_int64)time; double r; r = 2 * ma_abs(2 * (f - 0.5)) - 1; return (float)(r * amplitude); } static ma_int16 ma_waveform_triangle_s16(double time, double amplitude) { return ma_pcm_sample_f32_to_s16(ma_waveform_triangle_f32(time, amplitude)); } static float ma_waveform_sawtooth_f32(double time, double amplitude) { double f = time - (ma_int64)time; double r; r = 2 * (f - 0.5); return (float)(r * amplitude); } static ma_int16 ma_waveform_sawtooth_s16(double time, double amplitude) { return ma_pcm_sample_f32_to_s16(ma_waveform_sawtooth_f32(time, amplitude)); } static void ma_waveform_read_pcm_frames__sine(ma_waveform* pWaveform, void* pFramesOut, ma_uint64 frameCount) { ma_uint64 iFrame; ma_uint64 iChannel; ma_uint32 bps = ma_get_bytes_per_sample(pWaveform->config.format); ma_uint32 bpf = bps * pWaveform->config.channels; MA_ASSERT(pWaveform != NULL); MA_ASSERT(pFramesOut != NULL); if (pWaveform->config.format == ma_format_f32) { float* pFramesOutF32 = (float*)pFramesOut; for (iFrame = 0; iFrame < frameCount; iFrame += 1) { float s = ma_waveform_sine_f32(pWaveform->time, pWaveform->config.amplitude); pWaveform->time += pWaveform->advance; for (iChannel = 0; iChannel < pWaveform->config.channels; iChannel += 1) { pFramesOutF32[iFrame*pWaveform->config.channels + iChannel] = s; } } } else if (pWaveform->config.format == ma_format_s16) { ma_int16* pFramesOutS16 = (ma_int16*)pFramesOut; for (iFrame = 0; iFrame < frameCount; iFrame += 1) { ma_int16 s = ma_waveform_sine_s16(pWaveform->time, pWaveform->config.amplitude); pWaveform->time += pWaveform->advance; for (iChannel = 0; iChannel < pWaveform->config.channels; iChannel += 1) { pFramesOutS16[iFrame*pWaveform->config.channels + iChannel] = s; } } } else { for (iFrame = 0; iFrame < frameCount; iFrame += 1) { float s = ma_waveform_sine_f32(pWaveform->time, pWaveform->config.amplitude); pWaveform->time += pWaveform->advance; for (iChannel = 0; iChannel < pWaveform->config.channels; iChannel += 1) { ma_pcm_convert(ma_offset_ptr(pFramesOut, iFrame*bpf + iChannel*bps), pWaveform->config.format, &s, ma_format_f32, 1, ma_dither_mode_none); } } } } static void ma_waveform_read_pcm_frames__square(ma_waveform* pWaveform, double dutyCycle, void* pFramesOut, ma_uint64 frameCount) { ma_uint64 iFrame; ma_uint64 iChannel; ma_uint32 bps = ma_get_bytes_per_sample(pWaveform->config.format); ma_uint32 bpf = bps * pWaveform->config.channels; MA_ASSERT(pWaveform != NULL); MA_ASSERT(pFramesOut != NULL); if (pWaveform->config.format == ma_format_f32) { float* pFramesOutF32 = (float*)pFramesOut; for (iFrame = 0; iFrame < frameCount; iFrame += 1) { float s = ma_waveform_square_f32(pWaveform->time, dutyCycle, pWaveform->config.amplitude); pWaveform->time += pWaveform->advance; for (iChannel = 0; iChannel < pWaveform->config.channels; iChannel += 1) { pFramesOutF32[iFrame*pWaveform->config.channels + iChannel] = s; } } } else if (pWaveform->config.format == ma_format_s16) { ma_int16* pFramesOutS16 = (ma_int16*)pFramesOut; for (iFrame = 0; iFrame < frameCount; iFrame += 1) { ma_int16 s = ma_waveform_square_s16(pWaveform->time, dutyCycle, pWaveform->config.amplitude); pWaveform->time += pWaveform->advance; for (iChannel = 0; iChannel < pWaveform->config.channels; iChannel += 1) { pFramesOutS16[iFrame*pWaveform->config.channels + iChannel] = s; } } } else { for (iFrame = 0; iFrame < frameCount; iFrame += 1) { float s = ma_waveform_square_f32(pWaveform->time, dutyCycle, pWaveform->config.amplitude); pWaveform->time += pWaveform->advance; for (iChannel = 0; iChannel < pWaveform->config.channels; iChannel += 1) { ma_pcm_convert(ma_offset_ptr(pFramesOut, iFrame*bpf + iChannel*bps), pWaveform->config.format, &s, ma_format_f32, 1, ma_dither_mode_none); } } } } static void ma_waveform_read_pcm_frames__triangle(ma_waveform* pWaveform, void* pFramesOut, ma_uint64 frameCount) { ma_uint64 iFrame; ma_uint64 iChannel; ma_uint32 bps = ma_get_bytes_per_sample(pWaveform->config.format); ma_uint32 bpf = bps * pWaveform->config.channels; MA_ASSERT(pWaveform != NULL); MA_ASSERT(pFramesOut != NULL); if (pWaveform->config.format == ma_format_f32) { float* pFramesOutF32 = (float*)pFramesOut; for (iFrame = 0; iFrame < frameCount; iFrame += 1) { float s = ma_waveform_triangle_f32(pWaveform->time, pWaveform->config.amplitude); pWaveform->time += pWaveform->advance; for (iChannel = 0; iChannel < pWaveform->config.channels; iChannel += 1) { pFramesOutF32[iFrame*pWaveform->config.channels + iChannel] = s; } } } else if (pWaveform->config.format == ma_format_s16) { ma_int16* pFramesOutS16 = (ma_int16*)pFramesOut; for (iFrame = 0; iFrame < frameCount; iFrame += 1) { ma_int16 s = ma_waveform_triangle_s16(pWaveform->time, pWaveform->config.amplitude); pWaveform->time += pWaveform->advance; for (iChannel = 0; iChannel < pWaveform->config.channels; iChannel += 1) { pFramesOutS16[iFrame*pWaveform->config.channels + iChannel] = s; } } } else { for (iFrame = 0; iFrame < frameCount; iFrame += 1) { float s = ma_waveform_triangle_f32(pWaveform->time, pWaveform->config.amplitude); pWaveform->time += pWaveform->advance; for (iChannel = 0; iChannel < pWaveform->config.channels; iChannel += 1) { ma_pcm_convert(ma_offset_ptr(pFramesOut, iFrame*bpf + iChannel*bps), pWaveform->config.format, &s, ma_format_f32, 1, ma_dither_mode_none); } } } } static void ma_waveform_read_pcm_frames__sawtooth(ma_waveform* pWaveform, void* pFramesOut, ma_uint64 frameCount) { ma_uint64 iFrame; ma_uint64 iChannel; ma_uint32 bps = ma_get_bytes_per_sample(pWaveform->config.format); ma_uint32 bpf = bps * pWaveform->config.channels; MA_ASSERT(pWaveform != NULL); MA_ASSERT(pFramesOut != NULL); if (pWaveform->config.format == ma_format_f32) { float* pFramesOutF32 = (float*)pFramesOut; for (iFrame = 0; iFrame < frameCount; iFrame += 1) { float s = ma_waveform_sawtooth_f32(pWaveform->time, pWaveform->config.amplitude); pWaveform->time += pWaveform->advance; for (iChannel = 0; iChannel < pWaveform->config.channels; iChannel += 1) { pFramesOutF32[iFrame*pWaveform->config.channels + iChannel] = s; } } } else if (pWaveform->config.format == ma_format_s16) { ma_int16* pFramesOutS16 = (ma_int16*)pFramesOut; for (iFrame = 0; iFrame < frameCount; iFrame += 1) { ma_int16 s = ma_waveform_sawtooth_s16(pWaveform->time, pWaveform->config.amplitude); pWaveform->time += pWaveform->advance; for (iChannel = 0; iChannel < pWaveform->config.channels; iChannel += 1) { pFramesOutS16[iFrame*pWaveform->config.channels + iChannel] = s; } } } else { for (iFrame = 0; iFrame < frameCount; iFrame += 1) { float s = ma_waveform_sawtooth_f32(pWaveform->time, pWaveform->config.amplitude); pWaveform->time += pWaveform->advance; for (iChannel = 0; iChannel < pWaveform->config.channels; iChannel += 1) { ma_pcm_convert(ma_offset_ptr(pFramesOut, iFrame*bpf + iChannel*bps), pWaveform->config.format, &s, ma_format_f32, 1, ma_dither_mode_none); } } } } MA_API ma_result ma_waveform_read_pcm_frames(ma_waveform* pWaveform, void* pFramesOut, ma_uint64 frameCount, ma_uint64* pFramesRead) { if (pFramesRead != NULL) { *pFramesRead = 0; } if (frameCount == 0) { return MA_INVALID_ARGS; } if (pWaveform == NULL) { return MA_INVALID_ARGS; } if (pFramesOut != NULL) { switch (pWaveform->config.type) { case ma_waveform_type_sine: { ma_waveform_read_pcm_frames__sine(pWaveform, pFramesOut, frameCount); } break; case ma_waveform_type_square: { ma_waveform_read_pcm_frames__square(pWaveform, 0.5, pFramesOut, frameCount); } break; case ma_waveform_type_triangle: { ma_waveform_read_pcm_frames__triangle(pWaveform, pFramesOut, frameCount); } break; case ma_waveform_type_sawtooth: { ma_waveform_read_pcm_frames__sawtooth(pWaveform, pFramesOut, frameCount); } break; default: return MA_INVALID_OPERATION; /* Unknown waveform type. */ } } else { pWaveform->time += pWaveform->advance * (ma_int64)frameCount; /* Cast to int64 required for VC6. Won't affect anything in practice. */ } if (pFramesRead != NULL) { *pFramesRead = frameCount; } return MA_SUCCESS; } MA_API ma_result ma_waveform_seek_to_pcm_frame(ma_waveform* pWaveform, ma_uint64 frameIndex) { if (pWaveform == NULL) { return MA_INVALID_ARGS; } pWaveform->time = pWaveform->advance * (ma_int64)frameIndex; /* Casting for VC6. Won't be an issue in practice. */ return MA_SUCCESS; } MA_API ma_pulsewave_config ma_pulsewave_config_init(ma_format format, ma_uint32 channels, ma_uint32 sampleRate, double dutyCycle, double amplitude, double frequency) { ma_pulsewave_config config; MA_ZERO_OBJECT(&config); config.format = format; config.channels = channels; config.sampleRate = sampleRate; config.dutyCycle = dutyCycle; config.amplitude = amplitude; config.frequency = frequency; return config; } MA_API ma_result ma_pulsewave_init(const ma_pulsewave_config* pConfig, ma_pulsewave* pWaveform) { ma_result result; ma_waveform_config config; if (pWaveform == NULL) { return MA_INVALID_ARGS; } MA_ZERO_OBJECT(pWaveform); config = ma_waveform_config_init( pConfig->format, pConfig->channels, pConfig->sampleRate, ma_waveform_type_square, pConfig->amplitude, pConfig->frequency ); result = ma_waveform_init(&config, &pWaveform->waveform); ma_pulsewave_set_duty_cycle(pWaveform, pConfig->dutyCycle); return result; } MA_API void ma_pulsewave_uninit(ma_pulsewave* pWaveform) { if (pWaveform == NULL) { return; } ma_waveform_uninit(&pWaveform->waveform); } MA_API ma_result ma_pulsewave_read_pcm_frames(ma_pulsewave* pWaveform, void* pFramesOut, ma_uint64 frameCount, ma_uint64* pFramesRead) { if (pFramesRead != NULL) { *pFramesRead = 0; } if (frameCount == 0) { return MA_INVALID_ARGS; } if (pWaveform == NULL) { return MA_INVALID_ARGS; } if (pFramesOut != NULL) { ma_waveform_read_pcm_frames__square(&pWaveform->waveform, pWaveform->config.dutyCycle, pFramesOut, frameCount); } else { pWaveform->waveform.time += pWaveform->waveform.advance * (ma_int64)frameCount; /* Cast to int64 required for VC6. Won't affect anything in practice. */ } if (pFramesRead != NULL) { *pFramesRead = frameCount; } return MA_SUCCESS; } MA_API ma_result ma_pulsewave_seek_to_pcm_frame(ma_pulsewave* pWaveform, ma_uint64 frameIndex) { if (pWaveform == NULL) { return MA_INVALID_ARGS; } ma_waveform_seek_to_pcm_frame(&pWaveform->waveform, frameIndex); return MA_SUCCESS; } MA_API ma_result ma_pulsewave_set_amplitude(ma_pulsewave* pWaveform, double amplitude) { if (pWaveform == NULL) { return MA_INVALID_ARGS; } pWaveform->config.amplitude = amplitude; ma_waveform_set_amplitude(&pWaveform->waveform, amplitude); return MA_SUCCESS; } MA_API ma_result ma_pulsewave_set_frequency(ma_pulsewave* pWaveform, double frequency) { if (pWaveform == NULL) { return MA_INVALID_ARGS; } pWaveform->config.frequency = frequency; ma_waveform_set_frequency(&pWaveform->waveform, frequency); return MA_SUCCESS; } MA_API ma_result ma_pulsewave_set_sample_rate(ma_pulsewave* pWaveform, ma_uint32 sampleRate) { if (pWaveform == NULL) { return MA_INVALID_ARGS; } pWaveform->config.sampleRate = sampleRate; ma_waveform_set_sample_rate(&pWaveform->waveform, sampleRate); return MA_SUCCESS; } MA_API ma_result ma_pulsewave_set_duty_cycle(ma_pulsewave* pWaveform, double dutyCycle) { if (pWaveform == NULL) { return MA_INVALID_ARGS; } pWaveform->config.dutyCycle = dutyCycle; return MA_SUCCESS; } MA_API ma_noise_config ma_noise_config_init(ma_format format, ma_uint32 channels, ma_noise_type type, ma_int32 seed, double amplitude) { ma_noise_config config; MA_ZERO_OBJECT(&config); config.format = format; config.channels = channels; config.type = type; config.seed = seed; config.amplitude = amplitude; if (config.seed == 0) { config.seed = MA_DEFAULT_LCG_SEED; } return config; } static ma_result ma_noise__data_source_on_read(ma_data_source* pDataSource, void* pFramesOut, ma_uint64 frameCount, ma_uint64* pFramesRead) { return ma_noise_read_pcm_frames((ma_noise*)pDataSource, pFramesOut, frameCount, pFramesRead); } static ma_result ma_noise__data_source_on_seek(ma_data_source* pDataSource, ma_uint64 frameIndex) { /* No-op. Just pretend to be successful. */ (void)pDataSource; (void)frameIndex; return MA_SUCCESS; } static ma_result ma_noise__data_source_on_get_data_format(ma_data_source* pDataSource, ma_format* pFormat, ma_uint32* pChannels, ma_uint32* pSampleRate, ma_channel* pChannelMap, size_t channelMapCap) { ma_noise* pNoise = (ma_noise*)pDataSource; *pFormat = pNoise->config.format; *pChannels = pNoise->config.channels; *pSampleRate = 0; /* There is no notion of sample rate with noise generation. */ ma_channel_map_init_standard(ma_standard_channel_map_default, pChannelMap, channelMapCap, pNoise->config.channels); return MA_SUCCESS; } static ma_data_source_vtable g_ma_noise_data_source_vtable = { ma_noise__data_source_on_read, ma_noise__data_source_on_seek, /* No-op for noise. */ ma_noise__data_source_on_get_data_format, NULL, /* onGetCursor. No notion of a cursor for noise. */ NULL, /* onGetLength. No notion of a length for noise. */ NULL, /* onSetLooping */ 0 }; #ifndef MA_PINK_NOISE_BIN_SIZE #define MA_PINK_NOISE_BIN_SIZE 16 #endif typedef struct { size_t sizeInBytes; struct { size_t binOffset; size_t accumulationOffset; size_t counterOffset; } pink; struct { size_t accumulationOffset; } brownian; } ma_noise_heap_layout; static ma_result ma_noise_get_heap_layout(const ma_noise_config* pConfig, ma_noise_heap_layout* pHeapLayout) { MA_ASSERT(pHeapLayout != NULL); MA_ZERO_OBJECT(pHeapLayout); if (pConfig == NULL) { return MA_INVALID_ARGS; } if (pConfig->channels == 0) { return MA_INVALID_ARGS; } pHeapLayout->sizeInBytes = 0; /* Pink. */ if (pConfig->type == ma_noise_type_pink) { /* bin */ pHeapLayout->pink.binOffset = pHeapLayout->sizeInBytes; pHeapLayout->sizeInBytes += sizeof(double*) * pConfig->channels; pHeapLayout->sizeInBytes += sizeof(double ) * pConfig->channels * MA_PINK_NOISE_BIN_SIZE; /* accumulation */ pHeapLayout->pink.accumulationOffset = pHeapLayout->sizeInBytes; pHeapLayout->sizeInBytes += sizeof(double) * pConfig->channels; /* counter */ pHeapLayout->pink.counterOffset = pHeapLayout->sizeInBytes; pHeapLayout->sizeInBytes += sizeof(ma_uint32) * pConfig->channels; } /* Brownian. */ if (pConfig->type == ma_noise_type_brownian) { /* accumulation */ pHeapLayout->brownian.accumulationOffset = pHeapLayout->sizeInBytes; pHeapLayout->sizeInBytes += sizeof(double) * pConfig->channels; } /* Make sure allocation size is aligned. */ pHeapLayout->sizeInBytes = ma_align_64(pHeapLayout->sizeInBytes); return MA_SUCCESS; } MA_API ma_result ma_noise_get_heap_size(const ma_noise_config* pConfig, size_t* pHeapSizeInBytes) { ma_result result; ma_noise_heap_layout heapLayout; if (pHeapSizeInBytes == NULL) { return MA_INVALID_ARGS; } *pHeapSizeInBytes = 0; result = ma_noise_get_heap_layout(pConfig, &heapLayout); if (result != MA_SUCCESS) { return result; } *pHeapSizeInBytes = heapLayout.sizeInBytes; return MA_SUCCESS; } MA_API ma_result ma_noise_init_preallocated(const ma_noise_config* pConfig, void* pHeap, ma_noise* pNoise) { ma_result result; ma_noise_heap_layout heapLayout; ma_data_source_config dataSourceConfig; ma_uint32 iChannel; if (pNoise == NULL) { return MA_INVALID_ARGS; } MA_ZERO_OBJECT(pNoise); result = ma_noise_get_heap_layout(pConfig, &heapLayout); if (result != MA_SUCCESS) { return result; } pNoise->_pHeap = pHeap; MA_ZERO_MEMORY(pNoise->_pHeap, heapLayout.sizeInBytes); dataSourceConfig = ma_data_source_config_init(); dataSourceConfig.vtable = &g_ma_noise_data_source_vtable; result = ma_data_source_init(&dataSourceConfig, &pNoise->ds); if (result != MA_SUCCESS) { return result; } pNoise->config = *pConfig; ma_lcg_seed(&pNoise->lcg, pConfig->seed); if (pNoise->config.type == ma_noise_type_pink) { pNoise->state.pink.bin = (double** )ma_offset_ptr(pHeap, heapLayout.pink.binOffset); pNoise->state.pink.accumulation = (double* )ma_offset_ptr(pHeap, heapLayout.pink.accumulationOffset); pNoise->state.pink.counter = (ma_uint32*)ma_offset_ptr(pHeap, heapLayout.pink.counterOffset); for (iChannel = 0; iChannel < pConfig->channels; iChannel += 1) { pNoise->state.pink.bin[iChannel] = (double*)ma_offset_ptr(pHeap, heapLayout.pink.binOffset + (sizeof(double*) * pConfig->channels) + (sizeof(double) * MA_PINK_NOISE_BIN_SIZE * iChannel)); pNoise->state.pink.accumulation[iChannel] = 0; pNoise->state.pink.counter[iChannel] = 1; } } if (pNoise->config.type == ma_noise_type_brownian) { pNoise->state.brownian.accumulation = (double*)ma_offset_ptr(pHeap, heapLayout.brownian.accumulationOffset); for (iChannel = 0; iChannel < pConfig->channels; iChannel += 1) { pNoise->state.brownian.accumulation[iChannel] = 0; } } return MA_SUCCESS; } MA_API ma_result ma_noise_init(const ma_noise_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_noise* pNoise) { ma_result result; size_t heapSizeInBytes; void* pHeap; result = ma_noise_get_heap_size(pConfig, &heapSizeInBytes); if (result != MA_SUCCESS) { return result; } if (heapSizeInBytes > 0) { pHeap = ma_malloc(heapSizeInBytes, pAllocationCallbacks); if (pHeap == NULL) { return MA_OUT_OF_MEMORY; } } else { pHeap = NULL; } result = ma_noise_init_preallocated(pConfig, pHeap, pNoise); if (result != MA_SUCCESS) { ma_free(pHeap, pAllocationCallbacks); return result; } pNoise->_ownsHeap = MA_TRUE; return MA_SUCCESS; } MA_API void ma_noise_uninit(ma_noise* pNoise, const ma_allocation_callbacks* pAllocationCallbacks) { if (pNoise == NULL) { return; } ma_data_source_uninit(&pNoise->ds); if (pNoise->_ownsHeap) { ma_free(pNoise->_pHeap, pAllocationCallbacks); } } MA_API ma_result ma_noise_set_amplitude(ma_noise* pNoise, double amplitude) { if (pNoise == NULL) { return MA_INVALID_ARGS; } pNoise->config.amplitude = amplitude; return MA_SUCCESS; } MA_API ma_result ma_noise_set_seed(ma_noise* pNoise, ma_int32 seed) { if (pNoise == NULL) { return MA_INVALID_ARGS; } pNoise->lcg.state = seed; return MA_SUCCESS; } MA_API ma_result ma_noise_set_type(ma_noise* pNoise, ma_noise_type type) { if (pNoise == NULL) { return MA_INVALID_ARGS; } /* This function should never have been implemented in the first place. Changing the type dynamically is not supported. Instead you need to uninitialize and reinitiailize a fresh `ma_noise` object. This function will be removed in version 0.12. */ MA_ASSERT(MA_FALSE); (void)type; return MA_INVALID_OPERATION; } static MA_INLINE float ma_noise_f32_white(ma_noise* pNoise) { return (float)(ma_lcg_rand_f64(&pNoise->lcg) * pNoise->config.amplitude); } static MA_INLINE ma_int16 ma_noise_s16_white(ma_noise* pNoise) { return ma_pcm_sample_f32_to_s16(ma_noise_f32_white(pNoise)); } static MA_INLINE ma_uint64 ma_noise_read_pcm_frames__white(ma_noise* pNoise, void* pFramesOut, ma_uint64 frameCount) { ma_uint64 iFrame; ma_uint32 iChannel; const ma_uint32 channels = pNoise->config.channels; MA_ASSUME(channels > 0); if (pNoise->config.format == ma_format_f32) { float* pFramesOutF32 = (float*)pFramesOut; if (pNoise->config.duplicateChannels) { for (iFrame = 0; iFrame < frameCount; iFrame += 1) { float s = ma_noise_f32_white(pNoise); for (iChannel = 0; iChannel < channels; iChannel += 1) { pFramesOutF32[iFrame*channels + iChannel] = s; } } } else { for (iFrame = 0; iFrame < frameCount; iFrame += 1) { for (iChannel = 0; iChannel < channels; iChannel += 1) { pFramesOutF32[iFrame*channels + iChannel] = ma_noise_f32_white(pNoise); } } } } else if (pNoise->config.format == ma_format_s16) { ma_int16* pFramesOutS16 = (ma_int16*)pFramesOut; if (pNoise->config.duplicateChannels) { for (iFrame = 0; iFrame < frameCount; iFrame += 1) { ma_int16 s = ma_noise_s16_white(pNoise); for (iChannel = 0; iChannel < channels; iChannel += 1) { pFramesOutS16[iFrame*channels + iChannel] = s; } } } else { for (iFrame = 0; iFrame < frameCount; iFrame += 1) { for (iChannel = 0; iChannel < channels; iChannel += 1) { pFramesOutS16[iFrame*channels + iChannel] = ma_noise_s16_white(pNoise); } } } } else { const ma_uint32 bps = ma_get_bytes_per_sample(pNoise->config.format); const ma_uint32 bpf = bps * channels; if (pNoise->config.duplicateChannels) { for (iFrame = 0; iFrame < frameCount; iFrame += 1) { float s = ma_noise_f32_white(pNoise); for (iChannel = 0; iChannel < channels; iChannel += 1) { ma_pcm_convert(ma_offset_ptr(pFramesOut, iFrame*bpf + iChannel*bps), pNoise->config.format, &s, ma_format_f32, 1, ma_dither_mode_none); } } } else { for (iFrame = 0; iFrame < frameCount; iFrame += 1) { for (iChannel = 0; iChannel < channels; iChannel += 1) { float s = ma_noise_f32_white(pNoise); ma_pcm_convert(ma_offset_ptr(pFramesOut, iFrame*bpf + iChannel*bps), pNoise->config.format, &s, ma_format_f32, 1, ma_dither_mode_none); } } } } return frameCount; } static MA_INLINE unsigned int ma_tzcnt32(unsigned int x) { unsigned int n; /* Special case for odd numbers since they should happen about half the time. */ if (x & 0x1) { return 0; } if (x == 0) { return sizeof(x) << 3; } n = 1; if ((x & 0x0000FFFF) == 0) { x >>= 16; n += 16; } if ((x & 0x000000FF) == 0) { x >>= 8; n += 8; } if ((x & 0x0000000F) == 0) { x >>= 4; n += 4; } if ((x & 0x00000003) == 0) { x >>= 2; n += 2; } n -= x & 0x00000001; return n; } /* Pink noise generation based on Tonic (public domain) with modifications. https://github.com/TonicAudio/Tonic/blob/master/src/Tonic/Noise.h This is basically _the_ reference for pink noise from what I've found: http://www.firstpr.com.au/dsp/pink-noise/ */ static MA_INLINE float ma_noise_f32_pink(ma_noise* pNoise, ma_uint32 iChannel) { double result; double binPrev; double binNext; unsigned int ibin; ibin = ma_tzcnt32(pNoise->state.pink.counter[iChannel]) & (MA_PINK_NOISE_BIN_SIZE - 1); binPrev = pNoise->state.pink.bin[iChannel][ibin]; binNext = ma_lcg_rand_f64(&pNoise->lcg); pNoise->state.pink.bin[iChannel][ibin] = binNext; pNoise->state.pink.accumulation[iChannel] += (binNext - binPrev); pNoise->state.pink.counter[iChannel] += 1; result = (ma_lcg_rand_f64(&pNoise->lcg) + pNoise->state.pink.accumulation[iChannel]); result /= 10; return (float)(result * pNoise->config.amplitude); } static MA_INLINE ma_int16 ma_noise_s16_pink(ma_noise* pNoise, ma_uint32 iChannel) { return ma_pcm_sample_f32_to_s16(ma_noise_f32_pink(pNoise, iChannel)); } static MA_INLINE ma_uint64 ma_noise_read_pcm_frames__pink(ma_noise* pNoise, void* pFramesOut, ma_uint64 frameCount) { ma_uint64 iFrame; ma_uint32 iChannel; const ma_uint32 channels = pNoise->config.channels; MA_ASSUME(channels > 0); if (pNoise->config.format == ma_format_f32) { float* pFramesOutF32 = (float*)pFramesOut; if (pNoise->config.duplicateChannels) { for (iFrame = 0; iFrame < frameCount; iFrame += 1) { float s = ma_noise_f32_pink(pNoise, 0); for (iChannel = 0; iChannel < channels; iChannel += 1) { pFramesOutF32[iFrame*channels + iChannel] = s; } } } else { for (iFrame = 0; iFrame < frameCount; iFrame += 1) { for (iChannel = 0; iChannel < channels; iChannel += 1) { pFramesOutF32[iFrame*channels + iChannel] = ma_noise_f32_pink(pNoise, iChannel); } } } } else if (pNoise->config.format == ma_format_s16) { ma_int16* pFramesOutS16 = (ma_int16*)pFramesOut; if (pNoise->config.duplicateChannels) { for (iFrame = 0; iFrame < frameCount; iFrame += 1) { ma_int16 s = ma_noise_s16_pink(pNoise, 0); for (iChannel = 0; iChannel < channels; iChannel += 1) { pFramesOutS16[iFrame*channels + iChannel] = s; } } } else { for (iFrame = 0; iFrame < frameCount; iFrame += 1) { for (iChannel = 0; iChannel < channels; iChannel += 1) { pFramesOutS16[iFrame*channels + iChannel] = ma_noise_s16_pink(pNoise, iChannel); } } } } else { const ma_uint32 bps = ma_get_bytes_per_sample(pNoise->config.format); const ma_uint32 bpf = bps * channels; if (pNoise->config.duplicateChannels) { for (iFrame = 0; iFrame < frameCount; iFrame += 1) { float s = ma_noise_f32_pink(pNoise, 0); for (iChannel = 0; iChannel < channels; iChannel += 1) { ma_pcm_convert(ma_offset_ptr(pFramesOut, iFrame*bpf + iChannel*bps), pNoise->config.format, &s, ma_format_f32, 1, ma_dither_mode_none); } } } else { for (iFrame = 0; iFrame < frameCount; iFrame += 1) { for (iChannel = 0; iChannel < channels; iChannel += 1) { float s = ma_noise_f32_pink(pNoise, iChannel); ma_pcm_convert(ma_offset_ptr(pFramesOut, iFrame*bpf + iChannel*bps), pNoise->config.format, &s, ma_format_f32, 1, ma_dither_mode_none); } } } } return frameCount; } static MA_INLINE float ma_noise_f32_brownian(ma_noise* pNoise, ma_uint32 iChannel) { double result; result = (ma_lcg_rand_f64(&pNoise->lcg) + pNoise->state.brownian.accumulation[iChannel]); result /= 1.005; /* Don't escape the -1..1 range on average. */ pNoise->state.brownian.accumulation[iChannel] = result; result /= 20; return (float)(result * pNoise->config.amplitude); } static MA_INLINE ma_int16 ma_noise_s16_brownian(ma_noise* pNoise, ma_uint32 iChannel) { return ma_pcm_sample_f32_to_s16(ma_noise_f32_brownian(pNoise, iChannel)); } static MA_INLINE ma_uint64 ma_noise_read_pcm_frames__brownian(ma_noise* pNoise, void* pFramesOut, ma_uint64 frameCount) { ma_uint64 iFrame; ma_uint32 iChannel; const ma_uint32 channels = pNoise->config.channels; MA_ASSUME(channels > 0); if (pNoise->config.format == ma_format_f32) { float* pFramesOutF32 = (float*)pFramesOut; if (pNoise->config.duplicateChannels) { for (iFrame = 0; iFrame < frameCount; iFrame += 1) { float s = ma_noise_f32_brownian(pNoise, 0); for (iChannel = 0; iChannel < channels; iChannel += 1) { pFramesOutF32[iFrame*channels + iChannel] = s; } } } else { for (iFrame = 0; iFrame < frameCount; iFrame += 1) { for (iChannel = 0; iChannel < channels; iChannel += 1) { pFramesOutF32[iFrame*channels + iChannel] = ma_noise_f32_brownian(pNoise, iChannel); } } } } else if (pNoise->config.format == ma_format_s16) { ma_int16* pFramesOutS16 = (ma_int16*)pFramesOut; if (pNoise->config.duplicateChannels) { for (iFrame = 0; iFrame < frameCount; iFrame += 1) { ma_int16 s = ma_noise_s16_brownian(pNoise, 0); for (iChannel = 0; iChannel < channels; iChannel += 1) { pFramesOutS16[iFrame*channels + iChannel] = s; } } } else { for (iFrame = 0; iFrame < frameCount; iFrame += 1) { for (iChannel = 0; iChannel < channels; iChannel += 1) { pFramesOutS16[iFrame*channels + iChannel] = ma_noise_s16_brownian(pNoise, iChannel); } } } } else { const ma_uint32 bps = ma_get_bytes_per_sample(pNoise->config.format); const ma_uint32 bpf = bps * channels; if (pNoise->config.duplicateChannels) { for (iFrame = 0; iFrame < frameCount; iFrame += 1) { float s = ma_noise_f32_brownian(pNoise, 0); for (iChannel = 0; iChannel < channels; iChannel += 1) { ma_pcm_convert(ma_offset_ptr(pFramesOut, iFrame*bpf + iChannel*bps), pNoise->config.format, &s, ma_format_f32, 1, ma_dither_mode_none); } } } else { for (iFrame = 0; iFrame < frameCount; iFrame += 1) { for (iChannel = 0; iChannel < channels; iChannel += 1) { float s = ma_noise_f32_brownian(pNoise, iChannel); ma_pcm_convert(ma_offset_ptr(pFramesOut, iFrame*bpf + iChannel*bps), pNoise->config.format, &s, ma_format_f32, 1, ma_dither_mode_none); } } } } return frameCount; } MA_API ma_result ma_noise_read_pcm_frames(ma_noise* pNoise, void* pFramesOut, ma_uint64 frameCount, ma_uint64* pFramesRead) { ma_uint64 framesRead = 0; if (pFramesRead != NULL) { *pFramesRead = 0; } if (frameCount == 0) { return MA_INVALID_ARGS; } if (pNoise == NULL) { return MA_INVALID_ARGS; } /* The output buffer is allowed to be NULL. Since we aren't tracking cursors or anything we can just do nothing and pretend to be successful. */ if (pFramesOut == NULL) { framesRead = frameCount; } else { switch (pNoise->config.type) { case ma_noise_type_white: framesRead = ma_noise_read_pcm_frames__white (pNoise, pFramesOut, frameCount); break; case ma_noise_type_pink: framesRead = ma_noise_read_pcm_frames__pink (pNoise, pFramesOut, frameCount); break; case ma_noise_type_brownian: framesRead = ma_noise_read_pcm_frames__brownian(pNoise, pFramesOut, frameCount); break; default: return MA_INVALID_OPERATION; /* Unknown noise type. */ } } if (pFramesRead != NULL) { *pFramesRead = framesRead; } return MA_SUCCESS; } #endif /* MA_NO_GENERATION */ #ifndef MA_NO_RESOURCE_MANAGER #ifndef MA_RESOURCE_MANAGER_PAGE_SIZE_IN_MILLISECONDS #define MA_RESOURCE_MANAGER_PAGE_SIZE_IN_MILLISECONDS 1000 #endif #ifndef MA_JOB_TYPE_RESOURCE_MANAGER_QUEUE_CAPACITY #define MA_JOB_TYPE_RESOURCE_MANAGER_QUEUE_CAPACITY 1024 #endif MA_API ma_resource_manager_pipeline_notifications ma_resource_manager_pipeline_notifications_init(void) { ma_resource_manager_pipeline_notifications notifications; MA_ZERO_OBJECT(¬ifications); return notifications; } static void ma_resource_manager_pipeline_notifications_signal_all_notifications(const ma_resource_manager_pipeline_notifications* pPipelineNotifications) { if (pPipelineNotifications == NULL) { return; } if (pPipelineNotifications->init.pNotification) { ma_async_notification_signal(pPipelineNotifications->init.pNotification); } if (pPipelineNotifications->done.pNotification) { ma_async_notification_signal(pPipelineNotifications->done.pNotification); } } static void ma_resource_manager_pipeline_notifications_acquire_all_fences(const ma_resource_manager_pipeline_notifications* pPipelineNotifications) { if (pPipelineNotifications == NULL) { return; } if (pPipelineNotifications->init.pFence != NULL) { ma_fence_acquire(pPipelineNotifications->init.pFence); } if (pPipelineNotifications->done.pFence != NULL) { ma_fence_acquire(pPipelineNotifications->done.pFence); } } static void ma_resource_manager_pipeline_notifications_release_all_fences(const ma_resource_manager_pipeline_notifications* pPipelineNotifications) { if (pPipelineNotifications == NULL) { return; } if (pPipelineNotifications->init.pFence != NULL) { ma_fence_release(pPipelineNotifications->init.pFence); } if (pPipelineNotifications->done.pFence != NULL) { ma_fence_release(pPipelineNotifications->done.pFence); } } #ifndef MA_DEFAULT_HASH_SEED #define MA_DEFAULT_HASH_SEED 42 #endif /* MurmurHash3. Based on code from https://github.com/PeterScott/murmur3/blob/master/murmur3.c (public domain). */ #if defined(__clang__) || (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))) #pragma GCC diagnostic push #if __GNUC__ >= 7 #pragma GCC diagnostic ignored "-Wimplicit-fallthrough" #endif #endif static MA_INLINE ma_uint32 ma_rotl32(ma_uint32 x, ma_int8 r) { return (x << r) | (x >> (32 - r)); } static MA_INLINE ma_uint32 ma_hash_getblock(const ma_uint32* blocks, int i) { ma_uint32 block; /* Try silencing a sanitization warning about unaligned access by doing a memcpy() instead of assignment. */ MA_COPY_MEMORY(&block, ma_offset_ptr(blocks, i * sizeof(block)), sizeof(block)); if (ma_is_little_endian()) { return block; } else { return ma_swap_endian_uint32(block); } } static MA_INLINE ma_uint32 ma_hash_fmix32(ma_uint32 h) { h ^= h >> 16; h *= 0x85ebca6b; h ^= h >> 13; h *= 0xc2b2ae35; h ^= h >> 16; return h; } static ma_uint32 ma_hash_32(const void* key, int len, ma_uint32 seed) { const ma_uint8* data = (const ma_uint8*)key; const ma_uint32* blocks; const ma_uint8* tail; const int nblocks = len / 4; ma_uint32 h1 = seed; ma_uint32 c1 = 0xcc9e2d51; ma_uint32 c2 = 0x1b873593; ma_uint32 k1; int i; blocks = (const ma_uint32 *)(data + nblocks*4); for(i = -nblocks; i; i++) { k1 = ma_hash_getblock(blocks,i); k1 *= c1; k1 = ma_rotl32(k1, 15); k1 *= c2; h1 ^= k1; h1 = ma_rotl32(h1, 13); h1 = h1*5 + 0xe6546b64; } tail = (const ma_uint8*)(data + nblocks*4); k1 = 0; switch(len & 3) { case 3: k1 ^= tail[2] << 16; case 2: k1 ^= tail[1] << 8; case 1: k1 ^= tail[0]; k1 *= c1; k1 = ma_rotl32(k1, 15); k1 *= c2; h1 ^= k1; }; h1 ^= len; h1 = ma_hash_fmix32(h1); return h1; } #if defined(__clang__) || (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))) #pragma GCC diagnostic push #endif /* End MurmurHash3 */ static ma_uint32 ma_hash_string_32(const char* str) { return ma_hash_32(str, (int)strlen(str), MA_DEFAULT_HASH_SEED); } static ma_uint32 ma_hash_string_w_32(const wchar_t* str) { return ma_hash_32(str, (int)wcslen(str) * sizeof(*str), MA_DEFAULT_HASH_SEED); } /* Basic BST Functions */ static ma_result ma_resource_manager_data_buffer_node_search(ma_resource_manager* pResourceManager, ma_uint32 hashedName32, ma_resource_manager_data_buffer_node** ppDataBufferNode) { ma_resource_manager_data_buffer_node* pCurrentNode; MA_ASSERT(pResourceManager != NULL); MA_ASSERT(ppDataBufferNode != NULL); pCurrentNode = pResourceManager->pRootDataBufferNode; while (pCurrentNode != NULL) { if (hashedName32 == pCurrentNode->hashedName32) { break; /* Found. */ } else if (hashedName32 < pCurrentNode->hashedName32) { pCurrentNode = pCurrentNode->pChildLo; } else { pCurrentNode = pCurrentNode->pChildHi; } } *ppDataBufferNode = pCurrentNode; if (pCurrentNode == NULL) { return MA_DOES_NOT_EXIST; } else { return MA_SUCCESS; } } static ma_result ma_resource_manager_data_buffer_node_insert_point(ma_resource_manager* pResourceManager, ma_uint32 hashedName32, ma_resource_manager_data_buffer_node** ppInsertPoint) { ma_result result = MA_SUCCESS; ma_resource_manager_data_buffer_node* pCurrentNode; MA_ASSERT(pResourceManager != NULL); MA_ASSERT(ppInsertPoint != NULL); *ppInsertPoint = NULL; if (pResourceManager->pRootDataBufferNode == NULL) { return MA_SUCCESS; /* No items. */ } /* We need to find the node that will become the parent of the new node. If a node is found that already has the same hashed name we need to return MA_ALREADY_EXISTS. */ pCurrentNode = pResourceManager->pRootDataBufferNode; while (pCurrentNode != NULL) { if (hashedName32 == pCurrentNode->hashedName32) { result = MA_ALREADY_EXISTS; break; } else { if (hashedName32 < pCurrentNode->hashedName32) { if (pCurrentNode->pChildLo == NULL) { result = MA_SUCCESS; break; } else { pCurrentNode = pCurrentNode->pChildLo; } } else { if (pCurrentNode->pChildHi == NULL) { result = MA_SUCCESS; break; } else { pCurrentNode = pCurrentNode->pChildHi; } } } } *ppInsertPoint = pCurrentNode; return result; } static ma_result ma_resource_manager_data_buffer_node_insert_at(ma_resource_manager* pResourceManager, ma_resource_manager_data_buffer_node* pDataBufferNode, ma_resource_manager_data_buffer_node* pInsertPoint) { MA_ASSERT(pResourceManager != NULL); MA_ASSERT(pDataBufferNode != NULL); /* The key must have been set before calling this function. */ MA_ASSERT(pDataBufferNode->hashedName32 != 0); if (pInsertPoint == NULL) { /* It's the first node. */ pResourceManager->pRootDataBufferNode = pDataBufferNode; } else { /* It's not the first node. It needs to be inserted. */ if (pDataBufferNode->hashedName32 < pInsertPoint->hashedName32) { MA_ASSERT(pInsertPoint->pChildLo == NULL); pInsertPoint->pChildLo = pDataBufferNode; } else { MA_ASSERT(pInsertPoint->pChildHi == NULL); pInsertPoint->pChildHi = pDataBufferNode; } } pDataBufferNode->pParent = pInsertPoint; return MA_SUCCESS; } #if 0 /* Unused for now. */ static ma_result ma_resource_manager_data_buffer_node_insert(ma_resource_manager* pResourceManager, ma_resource_manager_data_buffer_node* pDataBufferNode) { ma_result result; ma_resource_manager_data_buffer_node* pInsertPoint; MA_ASSERT(pResourceManager != NULL); MA_ASSERT(pDataBufferNode != NULL); result = ma_resource_manager_data_buffer_node_insert_point(pResourceManager, pDataBufferNode->hashedName32, &pInsertPoint); if (result != MA_SUCCESS) { return MA_INVALID_ARGS; } return ma_resource_manager_data_buffer_node_insert_at(pResourceManager, pDataBufferNode, pInsertPoint); } #endif static MA_INLINE ma_resource_manager_data_buffer_node* ma_resource_manager_data_buffer_node_find_min(ma_resource_manager_data_buffer_node* pDataBufferNode) { ma_resource_manager_data_buffer_node* pCurrentNode; MA_ASSERT(pDataBufferNode != NULL); pCurrentNode = pDataBufferNode; while (pCurrentNode->pChildLo != NULL) { pCurrentNode = pCurrentNode->pChildLo; } return pCurrentNode; } static MA_INLINE ma_resource_manager_data_buffer_node* ma_resource_manager_data_buffer_node_find_max(ma_resource_manager_data_buffer_node* pDataBufferNode) { ma_resource_manager_data_buffer_node* pCurrentNode; MA_ASSERT(pDataBufferNode != NULL); pCurrentNode = pDataBufferNode; while (pCurrentNode->pChildHi != NULL) { pCurrentNode = pCurrentNode->pChildHi; } return pCurrentNode; } static MA_INLINE ma_resource_manager_data_buffer_node* ma_resource_manager_data_buffer_node_find_inorder_successor(ma_resource_manager_data_buffer_node* pDataBufferNode) { MA_ASSERT(pDataBufferNode != NULL); MA_ASSERT(pDataBufferNode->pChildHi != NULL); return ma_resource_manager_data_buffer_node_find_min(pDataBufferNode->pChildHi); } static MA_INLINE ma_resource_manager_data_buffer_node* ma_resource_manager_data_buffer_node_find_inorder_predecessor(ma_resource_manager_data_buffer_node* pDataBufferNode) { MA_ASSERT(pDataBufferNode != NULL); MA_ASSERT(pDataBufferNode->pChildLo != NULL); return ma_resource_manager_data_buffer_node_find_max(pDataBufferNode->pChildLo); } static ma_result ma_resource_manager_data_buffer_node_remove(ma_resource_manager* pResourceManager, ma_resource_manager_data_buffer_node* pDataBufferNode) { MA_ASSERT(pResourceManager != NULL); MA_ASSERT(pDataBufferNode != NULL); if (pDataBufferNode->pChildLo == NULL) { if (pDataBufferNode->pChildHi == NULL) { /* Simple case - deleting a buffer with no children. */ if (pDataBufferNode->pParent == NULL) { MA_ASSERT(pResourceManager->pRootDataBufferNode == pDataBufferNode); /* There is only a single buffer in the tree which should be equal to the root node. */ pResourceManager->pRootDataBufferNode = NULL; } else { if (pDataBufferNode->pParent->pChildLo == pDataBufferNode) { pDataBufferNode->pParent->pChildLo = NULL; } else { pDataBufferNode->pParent->pChildHi = NULL; } } } else { /* Node has one child - pChildHi != NULL. */ pDataBufferNode->pChildHi->pParent = pDataBufferNode->pParent; if (pDataBufferNode->pParent == NULL) { MA_ASSERT(pResourceManager->pRootDataBufferNode == pDataBufferNode); pResourceManager->pRootDataBufferNode = pDataBufferNode->pChildHi; } else { if (pDataBufferNode->pParent->pChildLo == pDataBufferNode) { pDataBufferNode->pParent->pChildLo = pDataBufferNode->pChildHi; } else { pDataBufferNode->pParent->pChildHi = pDataBufferNode->pChildHi; } } } } else { if (pDataBufferNode->pChildHi == NULL) { /* Node has one child - pChildLo != NULL. */ pDataBufferNode->pChildLo->pParent = pDataBufferNode->pParent; if (pDataBufferNode->pParent == NULL) { MA_ASSERT(pResourceManager->pRootDataBufferNode == pDataBufferNode); pResourceManager->pRootDataBufferNode = pDataBufferNode->pChildLo; } else { if (pDataBufferNode->pParent->pChildLo == pDataBufferNode) { pDataBufferNode->pParent->pChildLo = pDataBufferNode->pChildLo; } else { pDataBufferNode->pParent->pChildHi = pDataBufferNode->pChildLo; } } } else { /* Complex case - deleting a node with two children. */ ma_resource_manager_data_buffer_node* pReplacementDataBufferNode; /* For now we are just going to use the in-order successor as the replacement, but we may want to try to keep this balanced by switching between the two. */ pReplacementDataBufferNode = ma_resource_manager_data_buffer_node_find_inorder_successor(pDataBufferNode); MA_ASSERT(pReplacementDataBufferNode != NULL); /* Now that we have our replacement node we can make the change. The simple way to do this would be to just exchange the values, and then remove the replacement node, however we track specific nodes via pointers which means we can't just swap out the values. We need to instead just change the pointers around. The replacement node should have at most 1 child. Therefore, we can detach it in terms of our simpler cases above. What we're essentially doing is detaching the replacement node and reinserting it into the same position as the deleted node. */ MA_ASSERT(pReplacementDataBufferNode->pParent != NULL); /* The replacement node should never be the root which means it should always have a parent. */ MA_ASSERT(pReplacementDataBufferNode->pChildLo == NULL); /* Because we used in-order successor. This would be pChildHi == NULL if we used in-order predecessor. */ if (pReplacementDataBufferNode->pChildHi == NULL) { if (pReplacementDataBufferNode->pParent->pChildLo == pReplacementDataBufferNode) { pReplacementDataBufferNode->pParent->pChildLo = NULL; } else { pReplacementDataBufferNode->pParent->pChildHi = NULL; } } else { pReplacementDataBufferNode->pChildHi->pParent = pReplacementDataBufferNode->pParent; if (pReplacementDataBufferNode->pParent->pChildLo == pReplacementDataBufferNode) { pReplacementDataBufferNode->pParent->pChildLo = pReplacementDataBufferNode->pChildHi; } else { pReplacementDataBufferNode->pParent->pChildHi = pReplacementDataBufferNode->pChildHi; } } /* The replacement node has essentially been detached from the binary tree, so now we need to replace the old data buffer with it. The first thing to update is the parent */ if (pDataBufferNode->pParent != NULL) { if (pDataBufferNode->pParent->pChildLo == pDataBufferNode) { pDataBufferNode->pParent->pChildLo = pReplacementDataBufferNode; } else { pDataBufferNode->pParent->pChildHi = pReplacementDataBufferNode; } } /* Now need to update the replacement node's pointers. */ pReplacementDataBufferNode->pParent = pDataBufferNode->pParent; pReplacementDataBufferNode->pChildLo = pDataBufferNode->pChildLo; pReplacementDataBufferNode->pChildHi = pDataBufferNode->pChildHi; /* Now the children of the replacement node need to have their parent pointers updated. */ if (pReplacementDataBufferNode->pChildLo != NULL) { pReplacementDataBufferNode->pChildLo->pParent = pReplacementDataBufferNode; } if (pReplacementDataBufferNode->pChildHi != NULL) { pReplacementDataBufferNode->pChildHi->pParent = pReplacementDataBufferNode; } /* Now the root node needs to be updated. */ if (pResourceManager->pRootDataBufferNode == pDataBufferNode) { pResourceManager->pRootDataBufferNode = pReplacementDataBufferNode; } } } return MA_SUCCESS; } #if 0 /* Unused for now. */ static ma_result ma_resource_manager_data_buffer_node_remove_by_key(ma_resource_manager* pResourceManager, ma_uint32 hashedName32) { ma_result result; ma_resource_manager_data_buffer_node* pDataBufferNode; result = ma_resource_manager_data_buffer_search(pResourceManager, hashedName32, &pDataBufferNode); if (result != MA_SUCCESS) { return result; /* Could not find the data buffer. */ } return ma_resource_manager_data_buffer_remove(pResourceManager, pDataBufferNode); } #endif static ma_resource_manager_data_supply_type ma_resource_manager_data_buffer_node_get_data_supply_type(ma_resource_manager_data_buffer_node* pDataBufferNode) { return (ma_resource_manager_data_supply_type)ma_atomic_load_i32(&pDataBufferNode->data.type); } static void ma_resource_manager_data_buffer_node_set_data_supply_type(ma_resource_manager_data_buffer_node* pDataBufferNode, ma_resource_manager_data_supply_type supplyType) { ma_atomic_exchange_i32(&pDataBufferNode->data.type, supplyType); } static ma_result ma_resource_manager_data_buffer_node_increment_ref(ma_resource_manager* pResourceManager, ma_resource_manager_data_buffer_node* pDataBufferNode, ma_uint32* pNewRefCount) { ma_uint32 refCount; MA_ASSERT(pResourceManager != NULL); MA_ASSERT(pDataBufferNode != NULL); (void)pResourceManager; refCount = ma_atomic_fetch_add_32(&pDataBufferNode->refCount, 1) + 1; if (pNewRefCount != NULL) { *pNewRefCount = refCount; } return MA_SUCCESS; } static ma_result ma_resource_manager_data_buffer_node_decrement_ref(ma_resource_manager* pResourceManager, ma_resource_manager_data_buffer_node* pDataBufferNode, ma_uint32* pNewRefCount) { ma_uint32 refCount; MA_ASSERT(pResourceManager != NULL); MA_ASSERT(pDataBufferNode != NULL); (void)pResourceManager; refCount = ma_atomic_fetch_sub_32(&pDataBufferNode->refCount, 1) - 1; if (pNewRefCount != NULL) { *pNewRefCount = refCount; } return MA_SUCCESS; } static void ma_resource_manager_data_buffer_node_free(ma_resource_manager* pResourceManager, ma_resource_manager_data_buffer_node* pDataBufferNode) { MA_ASSERT(pResourceManager != NULL); MA_ASSERT(pDataBufferNode != NULL); if (pDataBufferNode->isDataOwnedByResourceManager) { if (ma_resource_manager_data_buffer_node_get_data_supply_type(pDataBufferNode) == ma_resource_manager_data_supply_type_encoded) { ma_free((void*)pDataBufferNode->data.backend.encoded.pData, &pResourceManager->config.allocationCallbacks); pDataBufferNode->data.backend.encoded.pData = NULL; pDataBufferNode->data.backend.encoded.sizeInBytes = 0; } else if (ma_resource_manager_data_buffer_node_get_data_supply_type(pDataBufferNode) == ma_resource_manager_data_supply_type_decoded) { ma_free((void*)pDataBufferNode->data.backend.decoded.pData, &pResourceManager->config.allocationCallbacks); pDataBufferNode->data.backend.decoded.pData = NULL; pDataBufferNode->data.backend.decoded.totalFrameCount = 0; } else if (ma_resource_manager_data_buffer_node_get_data_supply_type(pDataBufferNode) == ma_resource_manager_data_supply_type_decoded_paged) { ma_paged_audio_buffer_data_uninit(&pDataBufferNode->data.backend.decodedPaged.data, &pResourceManager->config.allocationCallbacks); } else { /* Should never hit this if the node was successfully initialized. */ MA_ASSERT(pDataBufferNode->result != MA_SUCCESS); } } /* The data buffer itself needs to be freed. */ ma_free(pDataBufferNode, &pResourceManager->config.allocationCallbacks); } static ma_result ma_resource_manager_data_buffer_node_result(const ma_resource_manager_data_buffer_node* pDataBufferNode) { MA_ASSERT(pDataBufferNode != NULL); return (ma_result)ma_atomic_load_i32((ma_result*)&pDataBufferNode->result); /* Need a naughty const-cast here. */ } static ma_bool32 ma_resource_manager_is_threading_enabled(const ma_resource_manager* pResourceManager) { MA_ASSERT(pResourceManager != NULL); return (pResourceManager->config.flags & MA_RESOURCE_MANAGER_FLAG_NO_THREADING) == 0; } typedef struct { union { ma_async_notification_event e; ma_async_notification_poll p; } backend; /* Must be the first member. */ ma_resource_manager* pResourceManager; } ma_resource_manager_inline_notification; static ma_result ma_resource_manager_inline_notification_init(ma_resource_manager* pResourceManager, ma_resource_manager_inline_notification* pNotification) { MA_ASSERT(pResourceManager != NULL); MA_ASSERT(pNotification != NULL); pNotification->pResourceManager = pResourceManager; if (ma_resource_manager_is_threading_enabled(pResourceManager)) { return ma_async_notification_event_init(&pNotification->backend.e); } else { return ma_async_notification_poll_init(&pNotification->backend.p); } } static void ma_resource_manager_inline_notification_uninit(ma_resource_manager_inline_notification* pNotification) { MA_ASSERT(pNotification != NULL); if (ma_resource_manager_is_threading_enabled(pNotification->pResourceManager)) { ma_async_notification_event_uninit(&pNotification->backend.e); } else { /* No need to uninitialize a polling notification. */ } } static void ma_resource_manager_inline_notification_wait(ma_resource_manager_inline_notification* pNotification) { MA_ASSERT(pNotification != NULL); if (ma_resource_manager_is_threading_enabled(pNotification->pResourceManager)) { ma_async_notification_event_wait(&pNotification->backend.e); } else { while (ma_async_notification_poll_is_signalled(&pNotification->backend.p) == MA_FALSE) { ma_result result = ma_resource_manager_process_next_job(pNotification->pResourceManager); if (result == MA_NO_DATA_AVAILABLE || result == MA_CANCELLED) { break; } } } } static void ma_resource_manager_inline_notification_wait_and_uninit(ma_resource_manager_inline_notification* pNotification) { ma_resource_manager_inline_notification_wait(pNotification); ma_resource_manager_inline_notification_uninit(pNotification); } static void ma_resource_manager_data_buffer_bst_lock(ma_resource_manager* pResourceManager) { MA_ASSERT(pResourceManager != NULL); if (ma_resource_manager_is_threading_enabled(pResourceManager)) { #ifndef MA_NO_THREADING { ma_mutex_lock(&pResourceManager->dataBufferBSTLock); } #else { MA_ASSERT(MA_FALSE); /* Should never hit this. */ } #endif } else { /* Threading not enabled. Do nothing. */ } } static void ma_resource_manager_data_buffer_bst_unlock(ma_resource_manager* pResourceManager) { MA_ASSERT(pResourceManager != NULL); if (ma_resource_manager_is_threading_enabled(pResourceManager)) { #ifndef MA_NO_THREADING { ma_mutex_unlock(&pResourceManager->dataBufferBSTLock); } #else { MA_ASSERT(MA_FALSE); /* Should never hit this. */ } #endif } else { /* Threading not enabled. Do nothing. */ } } #ifndef MA_NO_THREADING static ma_thread_result MA_THREADCALL ma_resource_manager_job_thread(void* pUserData) { ma_resource_manager* pResourceManager = (ma_resource_manager*)pUserData; MA_ASSERT(pResourceManager != NULL); for (;;) { ma_result result; ma_job job; result = ma_resource_manager_next_job(pResourceManager, &job); if (result != MA_SUCCESS) { break; } /* Terminate if we got a quit message. */ if (job.toc.breakup.code == MA_JOB_TYPE_QUIT) { break; } ma_job_process(&job); } return (ma_thread_result)0; } #endif MA_API ma_resource_manager_config ma_resource_manager_config_init(void) { ma_resource_manager_config config; MA_ZERO_OBJECT(&config); config.decodedFormat = ma_format_unknown; config.decodedChannels = 0; config.decodedSampleRate = 0; config.jobThreadCount = 1; /* A single miniaudio-managed job thread by default. */ config.jobQueueCapacity = MA_JOB_TYPE_RESOURCE_MANAGER_QUEUE_CAPACITY; /* Flags. */ config.flags = 0; #ifdef MA_NO_THREADING { /* Threading is disabled at compile time so disable threading at runtime as well by default. */ config.flags |= MA_RESOURCE_MANAGER_FLAG_NO_THREADING; config.jobThreadCount = 0; } #endif return config; } MA_API ma_result ma_resource_manager_init(const ma_resource_manager_config* pConfig, ma_resource_manager* pResourceManager) { ma_result result; ma_job_queue_config jobQueueConfig; if (pResourceManager == NULL) { return MA_INVALID_ARGS; } MA_ZERO_OBJECT(pResourceManager); if (pConfig == NULL) { return MA_INVALID_ARGS; } #ifndef MA_NO_THREADING { if (pConfig->jobThreadCount > ma_countof(pResourceManager->jobThreads)) { return MA_INVALID_ARGS; /* Requesting too many job threads. */ } } #endif pResourceManager->config = *pConfig; ma_allocation_callbacks_init_copy(&pResourceManager->config.allocationCallbacks, &pConfig->allocationCallbacks); /* Get the log set up early so we can start using it as soon as possible. */ if (pResourceManager->config.pLog == NULL) { result = ma_log_init(&pResourceManager->config.allocationCallbacks, &pResourceManager->log); if (result == MA_SUCCESS) { pResourceManager->config.pLog = &pResourceManager->log; } else { pResourceManager->config.pLog = NULL; /* Logging is unavailable. */ } } if (pResourceManager->config.pVFS == NULL) { result = ma_default_vfs_init(&pResourceManager->defaultVFS, &pResourceManager->config.allocationCallbacks); if (result != MA_SUCCESS) { return result; /* Failed to initialize the default file system. */ } pResourceManager->config.pVFS = &pResourceManager->defaultVFS; } /* If threading has been disabled at compile time, enfore it at run time as well. */ #ifdef MA_NO_THREADING { pResourceManager->config.flags |= MA_RESOURCE_MANAGER_FLAG_NO_THREADING; } #endif /* We need to force MA_RESOURCE_MANAGER_FLAG_NON_BLOCKING if MA_RESOURCE_MANAGER_FLAG_NO_THREADING is set. */ if ((pResourceManager->config.flags & MA_RESOURCE_MANAGER_FLAG_NO_THREADING) != 0) { pResourceManager->config.flags |= MA_RESOURCE_MANAGER_FLAG_NON_BLOCKING; /* We cannot allow job threads when MA_RESOURCE_MANAGER_FLAG_NO_THREADING has been set. This is an invalid use case. */ if (pResourceManager->config.jobThreadCount > 0) { return MA_INVALID_ARGS; } } /* Job queue. */ jobQueueConfig.capacity = pResourceManager->config.jobQueueCapacity; jobQueueConfig.flags = 0; if ((pResourceManager->config.flags & MA_RESOURCE_MANAGER_FLAG_NON_BLOCKING) != 0) { if (pResourceManager->config.jobThreadCount > 0) { return MA_INVALID_ARGS; /* Non-blocking mode is only valid for self-managed job threads. */ } jobQueueConfig.flags |= MA_JOB_QUEUE_FLAG_NON_BLOCKING; } result = ma_job_queue_init(&jobQueueConfig, &pResourceManager->config.allocationCallbacks, &pResourceManager->jobQueue); if (result != MA_SUCCESS) { return result; } /* Custom decoding backends. */ if (pConfig->ppCustomDecodingBackendVTables != NULL && pConfig->customDecodingBackendCount > 0) { size_t sizeInBytes = sizeof(*pResourceManager->config.ppCustomDecodingBackendVTables) * pConfig->customDecodingBackendCount; pResourceManager->config.ppCustomDecodingBackendVTables = (ma_decoding_backend_vtable**)ma_malloc(sizeInBytes, &pResourceManager->config.allocationCallbacks); if (pResourceManager->config.ppCustomDecodingBackendVTables == NULL) { ma_job_queue_uninit(&pResourceManager->jobQueue, &pResourceManager->config.allocationCallbacks); return MA_OUT_OF_MEMORY; } MA_COPY_MEMORY(pResourceManager->config.ppCustomDecodingBackendVTables, pConfig->ppCustomDecodingBackendVTables, sizeInBytes); pResourceManager->config.customDecodingBackendCount = pConfig->customDecodingBackendCount; pResourceManager->config.pCustomDecodingBackendUserData = pConfig->pCustomDecodingBackendUserData; } /* Here is where we initialize our threading stuff. We don't do this if we don't support threading. */ if (ma_resource_manager_is_threading_enabled(pResourceManager)) { #ifndef MA_NO_THREADING { ma_uint32 iJobThread; /* Data buffer lock. */ result = ma_mutex_init(&pResourceManager->dataBufferBSTLock); if (result != MA_SUCCESS) { ma_job_queue_uninit(&pResourceManager->jobQueue, &pResourceManager->config.allocationCallbacks); return result; } /* Create the job threads last to ensure the threads has access to valid data. */ for (iJobThread = 0; iJobThread < pResourceManager->config.jobThreadCount; iJobThread += 1) { result = ma_thread_create(&pResourceManager->jobThreads[iJobThread], ma_thread_priority_normal, pResourceManager->config.jobThreadStackSize, ma_resource_manager_job_thread, pResourceManager, &pResourceManager->config.allocationCallbacks); if (result != MA_SUCCESS) { ma_mutex_uninit(&pResourceManager->dataBufferBSTLock); ma_job_queue_uninit(&pResourceManager->jobQueue, &pResourceManager->config.allocationCallbacks); return result; } } } #else { /* Threading is disabled at compile time. We should never get here because validation checks should have already been performed. */ MA_ASSERT(MA_FALSE); } #endif } return MA_SUCCESS; } static void ma_resource_manager_delete_all_data_buffer_nodes(ma_resource_manager* pResourceManager) { MA_ASSERT(pResourceManager); /* If everything was done properly, there shouldn't be any active data buffers. */ while (pResourceManager->pRootDataBufferNode != NULL) { ma_resource_manager_data_buffer_node* pDataBufferNode = pResourceManager->pRootDataBufferNode; ma_resource_manager_data_buffer_node_remove(pResourceManager, pDataBufferNode); /* The data buffer has been removed from the BST, so now we need to free it's data. */ ma_resource_manager_data_buffer_node_free(pResourceManager, pDataBufferNode); } } MA_API void ma_resource_manager_uninit(ma_resource_manager* pResourceManager) { if (pResourceManager == NULL) { return; } /* Job threads need to be killed first. To do this we need to post a quit message to the message queue and then wait for the thread. The quit message will never be removed from the queue which means it will never not be returned after being encounted for the first time which means all threads will eventually receive it. */ ma_resource_manager_post_job_quit(pResourceManager); /* Wait for every job to finish before continuing to ensure nothing is sill trying to access any of our objects below. */ if (ma_resource_manager_is_threading_enabled(pResourceManager)) { #ifndef MA_NO_THREADING { ma_uint32 iJobThread; for (iJobThread = 0; iJobThread < pResourceManager->config.jobThreadCount; iJobThread += 1) { ma_thread_wait(&pResourceManager->jobThreads[iJobThread]); } } #else { MA_ASSERT(MA_FALSE); /* Should never hit this. */ } #endif } /* At this point the thread should have returned and no other thread should be accessing our data. We can now delete all data buffers. */ ma_resource_manager_delete_all_data_buffer_nodes(pResourceManager); /* The job queue is no longer needed. */ ma_job_queue_uninit(&pResourceManager->jobQueue, &pResourceManager->config.allocationCallbacks); /* We're no longer doing anything with data buffers so the lock can now be uninitialized. */ if (ma_resource_manager_is_threading_enabled(pResourceManager)) { #ifndef MA_NO_THREADING { ma_mutex_uninit(&pResourceManager->dataBufferBSTLock); } #else { MA_ASSERT(MA_FALSE); /* Should never hit this. */ } #endif } ma_free(pResourceManager->config.ppCustomDecodingBackendVTables, &pResourceManager->config.allocationCallbacks); if (pResourceManager->config.pLog == &pResourceManager->log) { ma_log_uninit(&pResourceManager->log); } } MA_API ma_log* ma_resource_manager_get_log(ma_resource_manager* pResourceManager) { if (pResourceManager == NULL) { return NULL; } return pResourceManager->config.pLog; } MA_API ma_resource_manager_data_source_config ma_resource_manager_data_source_config_init(void) { ma_resource_manager_data_source_config config; MA_ZERO_OBJECT(&config); config.rangeBegInPCMFrames = MA_DATA_SOURCE_DEFAULT_RANGE_BEG; config.rangeEndInPCMFrames = MA_DATA_SOURCE_DEFAULT_RANGE_END; config.loopPointBegInPCMFrames = MA_DATA_SOURCE_DEFAULT_LOOP_POINT_BEG; config.loopPointEndInPCMFrames = MA_DATA_SOURCE_DEFAULT_LOOP_POINT_END; config.isLooping = MA_FALSE; return config; } static ma_decoder_config ma_resource_manager__init_decoder_config(ma_resource_manager* pResourceManager) { ma_decoder_config config; config = ma_decoder_config_init(pResourceManager->config.decodedFormat, pResourceManager->config.decodedChannels, pResourceManager->config.decodedSampleRate); config.allocationCallbacks = pResourceManager->config.allocationCallbacks; config.ppCustomBackendVTables = pResourceManager->config.ppCustomDecodingBackendVTables; config.customBackendCount = pResourceManager->config.customDecodingBackendCount; config.pCustomBackendUserData = pResourceManager->config.pCustomDecodingBackendUserData; return config; } static ma_result ma_resource_manager__init_decoder(ma_resource_manager* pResourceManager, const char* pFilePath, const wchar_t* pFilePathW, ma_decoder* pDecoder) { ma_result result; ma_decoder_config config; MA_ASSERT(pResourceManager != NULL); MA_ASSERT(pFilePath != NULL || pFilePathW != NULL); MA_ASSERT(pDecoder != NULL); config = ma_resource_manager__init_decoder_config(pResourceManager); if (pFilePath != NULL) { result = ma_decoder_init_vfs(pResourceManager->config.pVFS, pFilePath, &config, pDecoder); if (result != MA_SUCCESS) { ma_log_postf(ma_resource_manager_get_log(pResourceManager), MA_LOG_LEVEL_WARNING, "Failed to load file \"%s\". %s.\n", pFilePath, ma_result_description(result)); return result; } } else { result = ma_decoder_init_vfs_w(pResourceManager->config.pVFS, pFilePathW, &config, pDecoder); if (result != MA_SUCCESS) { #if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || defined(_MSC_VER) ma_log_postf(ma_resource_manager_get_log(pResourceManager), MA_LOG_LEVEL_WARNING, "Failed to load file \"%ls\". %s.\n", pFilePathW, ma_result_description(result)); #endif return result; } } return MA_SUCCESS; } static ma_bool32 ma_resource_manager_data_buffer_has_connector(ma_resource_manager_data_buffer* pDataBuffer) { return ma_atomic_bool32_get(&pDataBuffer->isConnectorInitialized); } static ma_data_source* ma_resource_manager_data_buffer_get_connector(ma_resource_manager_data_buffer* pDataBuffer) { if (ma_resource_manager_data_buffer_has_connector(pDataBuffer) == MA_FALSE) { return NULL; /* Connector not yet initialized. */ } switch (pDataBuffer->pNode->data.type) { case ma_resource_manager_data_supply_type_encoded: return &pDataBuffer->connector.decoder; case ma_resource_manager_data_supply_type_decoded: return &pDataBuffer->connector.buffer; case ma_resource_manager_data_supply_type_decoded_paged: return &pDataBuffer->connector.pagedBuffer; case ma_resource_manager_data_supply_type_unknown: default: { ma_log_postf(ma_resource_manager_get_log(pDataBuffer->pResourceManager), MA_LOG_LEVEL_ERROR, "Failed to retrieve data buffer connector. Unknown data supply type.\n"); return NULL; }; }; } static ma_result ma_resource_manager_data_buffer_init_connector(ma_resource_manager_data_buffer* pDataBuffer, const ma_resource_manager_data_source_config* pConfig, ma_async_notification* pInitNotification, ma_fence* pInitFence) { ma_result result; MA_ASSERT(pDataBuffer != NULL); MA_ASSERT(pConfig != NULL); MA_ASSERT(ma_resource_manager_data_buffer_has_connector(pDataBuffer) == MA_FALSE); /* The underlying data buffer must be initialized before we'll be able to know how to initialize the backend. */ result = ma_resource_manager_data_buffer_node_result(pDataBuffer->pNode); if (result != MA_SUCCESS && result != MA_BUSY) { return result; /* The data buffer is in an erroneous state. */ } /* We need to initialize either a ma_decoder or an ma_audio_buffer depending on whether or not the backing data is encoded or decoded. These act as the "instance" to the data and are used to form the connection between underlying data buffer and the data source. If the data buffer is decoded, we can use an ma_audio_buffer. This enables us to use memory mapping when mixing which saves us a bit of data movement overhead. */ switch (ma_resource_manager_data_buffer_node_get_data_supply_type(pDataBuffer->pNode)) { case ma_resource_manager_data_supply_type_encoded: /* Connector is a decoder. */ { ma_decoder_config config; config = ma_resource_manager__init_decoder_config(pDataBuffer->pResourceManager); result = ma_decoder_init_memory(pDataBuffer->pNode->data.backend.encoded.pData, pDataBuffer->pNode->data.backend.encoded.sizeInBytes, &config, &pDataBuffer->connector.decoder); } break; case ma_resource_manager_data_supply_type_decoded: /* Connector is an audio buffer. */ { ma_audio_buffer_config config; config = ma_audio_buffer_config_init(pDataBuffer->pNode->data.backend.decoded.format, pDataBuffer->pNode->data.backend.decoded.channels, pDataBuffer->pNode->data.backend.decoded.totalFrameCount, pDataBuffer->pNode->data.backend.decoded.pData, NULL); result = ma_audio_buffer_init(&config, &pDataBuffer->connector.buffer); } break; case ma_resource_manager_data_supply_type_decoded_paged: /* Connector is a paged audio buffer. */ { ma_paged_audio_buffer_config config; config = ma_paged_audio_buffer_config_init(&pDataBuffer->pNode->data.backend.decodedPaged.data); result = ma_paged_audio_buffer_init(&config, &pDataBuffer->connector.pagedBuffer); } break; case ma_resource_manager_data_supply_type_unknown: default: { /* Unknown data supply type. Should never happen. Need to post an error here. */ return MA_INVALID_ARGS; }; } /* Initialization of the connector is when we can fire the init notification. This will give the application access to the format/channels/rate of the data source. */ if (result == MA_SUCCESS) { /* The resource manager supports the ability to set the range and loop settings via a config at initialization time. This results in an case where the ranges could be set explicitly via ma_data_source_set_*() before we get to this point here. If this happens, we'll end up hitting a case where we just override those settings which results in what feels like a bug. To address this we only change the relevant properties if they're not equal to defaults. If they're equal to defaults there's no need to change them anyway. If they're *not* set to the default values, we can assume the user has set the range and loop settings via the config. If they're doing their own calls to ma_data_source_set_*() in addition to setting them via the config, that's entirely on the caller and any synchronization issue becomes their problem. */ if (pConfig->rangeBegInPCMFrames != MA_DATA_SOURCE_DEFAULT_RANGE_BEG || pConfig->rangeEndInPCMFrames != MA_DATA_SOURCE_DEFAULT_RANGE_END) { ma_data_source_set_range_in_pcm_frames(pDataBuffer, pConfig->rangeBegInPCMFrames, pConfig->rangeEndInPCMFrames); } if (pConfig->loopPointBegInPCMFrames != MA_DATA_SOURCE_DEFAULT_LOOP_POINT_BEG || pConfig->loopPointEndInPCMFrames != MA_DATA_SOURCE_DEFAULT_LOOP_POINT_END) { ma_data_source_set_loop_point_in_pcm_frames(pDataBuffer, pConfig->loopPointBegInPCMFrames, pConfig->loopPointEndInPCMFrames); } if (pConfig->isLooping != MA_FALSE) { ma_data_source_set_looping(pDataBuffer, pConfig->isLooping); } ma_atomic_bool32_set(&pDataBuffer->isConnectorInitialized, MA_TRUE); if (pInitNotification != NULL) { ma_async_notification_signal(pInitNotification); } if (pInitFence != NULL) { ma_fence_release(pInitFence); } } /* At this point the backend should be initialized. We do *not* want to set pDataSource->result here - that needs to be done at a higher level to ensure it's done as the last step. */ return result; } static ma_result ma_resource_manager_data_buffer_uninit_connector(ma_resource_manager* pResourceManager, ma_resource_manager_data_buffer* pDataBuffer) { MA_ASSERT(pResourceManager != NULL); MA_ASSERT(pDataBuffer != NULL); (void)pResourceManager; switch (ma_resource_manager_data_buffer_node_get_data_supply_type(pDataBuffer->pNode)) { case ma_resource_manager_data_supply_type_encoded: /* Connector is a decoder. */ { ma_decoder_uninit(&pDataBuffer->connector.decoder); } break; case ma_resource_manager_data_supply_type_decoded: /* Connector is an audio buffer. */ { ma_audio_buffer_uninit(&pDataBuffer->connector.buffer); } break; case ma_resource_manager_data_supply_type_decoded_paged: /* Connector is a paged audio buffer. */ { ma_paged_audio_buffer_uninit(&pDataBuffer->connector.pagedBuffer); } break; case ma_resource_manager_data_supply_type_unknown: default: { /* Unknown data supply type. Should never happen. Need to post an error here. */ return MA_INVALID_ARGS; }; } return MA_SUCCESS; } static ma_uint32 ma_resource_manager_data_buffer_node_next_execution_order(ma_resource_manager_data_buffer_node* pDataBufferNode) { MA_ASSERT(pDataBufferNode != NULL); return ma_atomic_fetch_add_32(&pDataBufferNode->executionCounter, 1); } static ma_result ma_resource_manager_data_buffer_node_init_supply_encoded(ma_resource_manager* pResourceManager, ma_resource_manager_data_buffer_node* pDataBufferNode, const char* pFilePath, const wchar_t* pFilePathW) { ma_result result; size_t dataSizeInBytes; void* pData; MA_ASSERT(pResourceManager != NULL); MA_ASSERT(pDataBufferNode != NULL); MA_ASSERT(pFilePath != NULL || pFilePathW != NULL); result = ma_vfs_open_and_read_file_ex(pResourceManager->config.pVFS, pFilePath, pFilePathW, &pData, &dataSizeInBytes, &pResourceManager->config.allocationCallbacks); if (result != MA_SUCCESS) { if (pFilePath != NULL) { ma_log_postf(ma_resource_manager_get_log(pResourceManager), MA_LOG_LEVEL_WARNING, "Failed to load file \"%s\". %s.\n", pFilePath, ma_result_description(result)); } else { #if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || defined(_MSC_VER) ma_log_postf(ma_resource_manager_get_log(pResourceManager), MA_LOG_LEVEL_WARNING, "Failed to load file \"%ls\". %s.\n", pFilePathW, ma_result_description(result)); #endif } return result; } pDataBufferNode->data.backend.encoded.pData = pData; pDataBufferNode->data.backend.encoded.sizeInBytes = dataSizeInBytes; ma_resource_manager_data_buffer_node_set_data_supply_type(pDataBufferNode, ma_resource_manager_data_supply_type_encoded); /* <-- Must be set last. */ return MA_SUCCESS; } static ma_result ma_resource_manager_data_buffer_node_init_supply_decoded(ma_resource_manager* pResourceManager, ma_resource_manager_data_buffer_node* pDataBufferNode, const char* pFilePath, const wchar_t* pFilePathW, ma_uint32 flags, ma_decoder** ppDecoder) { ma_result result = MA_SUCCESS; ma_decoder* pDecoder; ma_uint64 totalFrameCount; MA_ASSERT(pResourceManager != NULL); MA_ASSERT(pDataBufferNode != NULL); MA_ASSERT(ppDecoder != NULL); MA_ASSERT(pFilePath != NULL || pFilePathW != NULL); *ppDecoder = NULL; /* For safety. */ pDecoder = (ma_decoder*)ma_malloc(sizeof(*pDecoder), &pResourceManager->config.allocationCallbacks); if (pDecoder == NULL) { return MA_OUT_OF_MEMORY; } result = ma_resource_manager__init_decoder(pResourceManager, pFilePath, pFilePathW, pDecoder); if (result != MA_SUCCESS) { ma_free(pDecoder, &pResourceManager->config.allocationCallbacks); return result; } /* At this point we have the decoder and we now need to initialize the data supply. This will be either a decoded buffer, or a decoded paged buffer. A regular buffer is just one big heap allocated buffer, whereas a paged buffer is a linked list of paged-sized buffers. The latter is used when the length of a sound is unknown until a full decode has been performed. */ if ((flags & MA_RESOURCE_MANAGER_DATA_SOURCE_FLAG_UNKNOWN_LENGTH) == 0) { result = ma_decoder_get_length_in_pcm_frames(pDecoder, &totalFrameCount); if (result != MA_SUCCESS) { return result; } } else { totalFrameCount = 0; } if (totalFrameCount > 0) { /* It's a known length. The data supply is a regular decoded buffer. */ ma_uint64 dataSizeInBytes; void* pData; dataSizeInBytes = totalFrameCount * ma_get_bytes_per_frame(pDecoder->outputFormat, pDecoder->outputChannels); if (dataSizeInBytes > MA_SIZE_MAX) { ma_decoder_uninit(pDecoder); ma_free(pDecoder, &pResourceManager->config.allocationCallbacks); return MA_TOO_BIG; } pData = ma_malloc((size_t)dataSizeInBytes, &pResourceManager->config.allocationCallbacks); if (pData == NULL) { ma_decoder_uninit(pDecoder); ma_free(pDecoder, &pResourceManager->config.allocationCallbacks); return MA_OUT_OF_MEMORY; } /* The buffer needs to be initialized to silence in case the caller reads from it. */ ma_silence_pcm_frames(pData, totalFrameCount, pDecoder->outputFormat, pDecoder->outputChannels); /* Data has been allocated and the data supply can now be initialized. */ pDataBufferNode->data.backend.decoded.pData = pData; pDataBufferNode->data.backend.decoded.totalFrameCount = totalFrameCount; pDataBufferNode->data.backend.decoded.format = pDecoder->outputFormat; pDataBufferNode->data.backend.decoded.channels = pDecoder->outputChannels; pDataBufferNode->data.backend.decoded.sampleRate = pDecoder->outputSampleRate; pDataBufferNode->data.backend.decoded.decodedFrameCount = 0; ma_resource_manager_data_buffer_node_set_data_supply_type(pDataBufferNode, ma_resource_manager_data_supply_type_decoded); /* <-- Must be set last. */ } else { /* It's an unknown length. The data supply is a paged decoded buffer. Setting this up is actually easier than the non-paged decoded buffer because we just need to initialize a ma_paged_audio_buffer object. */ result = ma_paged_audio_buffer_data_init(pDecoder->outputFormat, pDecoder->outputChannels, &pDataBufferNode->data.backend.decodedPaged.data); if (result != MA_SUCCESS) { ma_decoder_uninit(pDecoder); ma_free(pDecoder, &pResourceManager->config.allocationCallbacks); return result; } pDataBufferNode->data.backend.decodedPaged.sampleRate = pDecoder->outputSampleRate; pDataBufferNode->data.backend.decodedPaged.decodedFrameCount = 0; ma_resource_manager_data_buffer_node_set_data_supply_type(pDataBufferNode, ma_resource_manager_data_supply_type_decoded_paged); /* <-- Must be set last. */ } *ppDecoder = pDecoder; return MA_SUCCESS; } static ma_result ma_resource_manager_data_buffer_node_decode_next_page(ma_resource_manager* pResourceManager, ma_resource_manager_data_buffer_node* pDataBufferNode, ma_decoder* pDecoder) { ma_result result = MA_SUCCESS; ma_uint64 pageSizeInFrames; ma_uint64 framesToTryReading; ma_uint64 framesRead; MA_ASSERT(pResourceManager != NULL); MA_ASSERT(pDataBufferNode != NULL); MA_ASSERT(pDecoder != NULL); /* We need to know the size of a page in frames to know how many frames to decode. */ pageSizeInFrames = MA_RESOURCE_MANAGER_PAGE_SIZE_IN_MILLISECONDS * (pDecoder->outputSampleRate/1000); framesToTryReading = pageSizeInFrames; /* Here is where we do the decoding of the next page. We'll run a slightly different path depending on whether or not we're using a flat or paged buffer because the allocation of the page differs between the two. For a flat buffer it's an offset to an already-allocated buffer. For a paged buffer, we need to allocate a new page and attach it to the linked list. */ switch (ma_resource_manager_data_buffer_node_get_data_supply_type(pDataBufferNode)) { case ma_resource_manager_data_supply_type_decoded: { /* The destination buffer is an offset to the existing buffer. Don't read more than we originally retrieved when we first initialized the decoder. */ void* pDst; ma_uint64 framesRemaining = pDataBufferNode->data.backend.decoded.totalFrameCount - pDataBufferNode->data.backend.decoded.decodedFrameCount; if (framesToTryReading > framesRemaining) { framesToTryReading = framesRemaining; } if (framesToTryReading > 0) { pDst = ma_offset_ptr( pDataBufferNode->data.backend.decoded.pData, pDataBufferNode->data.backend.decoded.decodedFrameCount * ma_get_bytes_per_frame(pDataBufferNode->data.backend.decoded.format, pDataBufferNode->data.backend.decoded.channels) ); MA_ASSERT(pDst != NULL); result = ma_decoder_read_pcm_frames(pDecoder, pDst, framesToTryReading, &framesRead); if (framesRead > 0) { pDataBufferNode->data.backend.decoded.decodedFrameCount += framesRead; } } else { framesRead = 0; } } break; case ma_resource_manager_data_supply_type_decoded_paged: { /* The destination buffer is a freshly allocated page. */ ma_paged_audio_buffer_page* pPage; result = ma_paged_audio_buffer_data_allocate_page(&pDataBufferNode->data.backend.decodedPaged.data, framesToTryReading, NULL, &pResourceManager->config.allocationCallbacks, &pPage); if (result != MA_SUCCESS) { return result; } result = ma_decoder_read_pcm_frames(pDecoder, pPage->pAudioData, framesToTryReading, &framesRead); if (framesRead > 0) { pPage->sizeInFrames = framesRead; result = ma_paged_audio_buffer_data_append_page(&pDataBufferNode->data.backend.decodedPaged.data, pPage); if (result == MA_SUCCESS) { pDataBufferNode->data.backend.decodedPaged.decodedFrameCount += framesRead; } else { /* Failed to append the page. Just abort and set the status to MA_AT_END. */ ma_paged_audio_buffer_data_free_page(&pDataBufferNode->data.backend.decodedPaged.data, pPage, &pResourceManager->config.allocationCallbacks); result = MA_AT_END; } } else { /* No frames were read. Free the page and just set the status to MA_AT_END. */ ma_paged_audio_buffer_data_free_page(&pDataBufferNode->data.backend.decodedPaged.data, pPage, &pResourceManager->config.allocationCallbacks); result = MA_AT_END; } } break; case ma_resource_manager_data_supply_type_encoded: case ma_resource_manager_data_supply_type_unknown: default: { /* Unexpected data supply type. */ ma_log_postf(ma_resource_manager_get_log(pResourceManager), MA_LOG_LEVEL_ERROR, "Unexpected data supply type (%d) when decoding page.", ma_resource_manager_data_buffer_node_get_data_supply_type(pDataBufferNode)); return MA_ERROR; }; } if (result == MA_SUCCESS && framesRead == 0) { result = MA_AT_END; } return result; } static ma_result ma_resource_manager_data_buffer_node_acquire_critical_section(ma_resource_manager* pResourceManager, const char* pFilePath, const wchar_t* pFilePathW, ma_uint32 hashedName32, ma_uint32 flags, const ma_resource_manager_data_supply* pExistingData, ma_fence* pInitFence, ma_fence* pDoneFence, ma_resource_manager_inline_notification* pInitNotification, ma_resource_manager_data_buffer_node** ppDataBufferNode) { ma_result result = MA_SUCCESS; ma_resource_manager_data_buffer_node* pDataBufferNode = NULL; ma_resource_manager_data_buffer_node* pInsertPoint; if (ppDataBufferNode != NULL) { *ppDataBufferNode = NULL; } result = ma_resource_manager_data_buffer_node_insert_point(pResourceManager, hashedName32, &pInsertPoint); if (result == MA_ALREADY_EXISTS) { /* The node already exists. We just need to increment the reference count. */ pDataBufferNode = pInsertPoint; result = ma_resource_manager_data_buffer_node_increment_ref(pResourceManager, pDataBufferNode, NULL); if (result != MA_SUCCESS) { return result; /* Should never happen. Failed to increment the reference count. */ } result = MA_ALREADY_EXISTS; goto done; } else { /* The node does not already exist. We need to post a LOAD_DATA_BUFFER_NODE job here. This needs to be done inside the critical section to ensure an uninitialization of the node does not occur before initialization on another thread. */ pDataBufferNode = (ma_resource_manager_data_buffer_node*)ma_malloc(sizeof(*pDataBufferNode), &pResourceManager->config.allocationCallbacks); if (pDataBufferNode == NULL) { return MA_OUT_OF_MEMORY; } MA_ZERO_OBJECT(pDataBufferNode); pDataBufferNode->hashedName32 = hashedName32; pDataBufferNode->refCount = 1; /* Always set to 1 by default (this is our first reference). */ if (pExistingData == NULL) { pDataBufferNode->data.type = ma_resource_manager_data_supply_type_unknown; /* <-- We won't know this until we start decoding. */ pDataBufferNode->result = MA_BUSY; /* Must be set to MA_BUSY before we leave the critical section, so might as well do it now. */ pDataBufferNode->isDataOwnedByResourceManager = MA_TRUE; } else { pDataBufferNode->data = *pExistingData; pDataBufferNode->result = MA_SUCCESS; /* Not loading asynchronously, so just set the status */ pDataBufferNode->isDataOwnedByResourceManager = MA_FALSE; } result = ma_resource_manager_data_buffer_node_insert_at(pResourceManager, pDataBufferNode, pInsertPoint); if (result != MA_SUCCESS) { ma_free(pDataBufferNode, &pResourceManager->config.allocationCallbacks); return result; /* Should never happen. Failed to insert the data buffer into the BST. */ } /* Here is where we'll post the job, but only if we're loading asynchronously. If we're loading synchronously we'll defer loading to a later stage, outside of the critical section. */ if (pDataBufferNode->isDataOwnedByResourceManager && (flags & MA_RESOURCE_MANAGER_DATA_SOURCE_FLAG_ASYNC) != 0) { /* Loading asynchronously. Post the job. */ ma_job job; char* pFilePathCopy = NULL; wchar_t* pFilePathWCopy = NULL; /* We need a copy of the file path. We should probably make this more efficient, but for now we'll do a transient memory allocation. */ if (pFilePath != NULL) { pFilePathCopy = ma_copy_string(pFilePath, &pResourceManager->config.allocationCallbacks); } else { pFilePathWCopy = ma_copy_string_w(pFilePathW, &pResourceManager->config.allocationCallbacks); } if (pFilePathCopy == NULL && pFilePathWCopy == NULL) { ma_resource_manager_data_buffer_node_remove(pResourceManager, pDataBufferNode); ma_free(pDataBufferNode, &pResourceManager->config.allocationCallbacks); return MA_OUT_OF_MEMORY; } if ((flags & MA_RESOURCE_MANAGER_DATA_SOURCE_FLAG_WAIT_INIT) != 0) { ma_resource_manager_inline_notification_init(pResourceManager, pInitNotification); } /* Acquire init and done fences before posting the job. These will be unacquired by the job thread. */ if (pInitFence != NULL) { ma_fence_acquire(pInitFence); } if (pDoneFence != NULL) { ma_fence_acquire(pDoneFence); } /* We now have everything we need to post the job to the job thread. */ job = ma_job_init(MA_JOB_TYPE_RESOURCE_MANAGER_LOAD_DATA_BUFFER_NODE); job.order = ma_resource_manager_data_buffer_node_next_execution_order(pDataBufferNode); job.data.resourceManager.loadDataBufferNode.pResourceManager = pResourceManager; job.data.resourceManager.loadDataBufferNode.pDataBufferNode = pDataBufferNode; job.data.resourceManager.loadDataBufferNode.pFilePath = pFilePathCopy; job.data.resourceManager.loadDataBufferNode.pFilePathW = pFilePathWCopy; job.data.resourceManager.loadDataBufferNode.flags = flags; job.data.resourceManager.loadDataBufferNode.pInitNotification = ((flags & MA_RESOURCE_MANAGER_DATA_SOURCE_FLAG_WAIT_INIT) != 0) ? pInitNotification : NULL; job.data.resourceManager.loadDataBufferNode.pDoneNotification = NULL; job.data.resourceManager.loadDataBufferNode.pInitFence = pInitFence; job.data.resourceManager.loadDataBufferNode.pDoneFence = pDoneFence; if ((flags & MA_RESOURCE_MANAGER_DATA_SOURCE_FLAG_WAIT_INIT) != 0) { result = ma_job_process(&job); } else { result = ma_resource_manager_post_job(pResourceManager, &job); } if (result != MA_SUCCESS) { /* Failed to post job. Probably ran out of memory. */ ma_log_postf(ma_resource_manager_get_log(pResourceManager), MA_LOG_LEVEL_ERROR, "Failed to post MA_JOB_TYPE_RESOURCE_MANAGER_LOAD_DATA_BUFFER_NODE job. %s.\n", ma_result_description(result)); /* Fences were acquired before posting the job, but since the job was not able to be posted, we need to make sure we release them so nothing gets stuck waiting. */ if (pInitFence != NULL) { ma_fence_release(pInitFence); } if (pDoneFence != NULL) { ma_fence_release(pDoneFence); } if ((flags & MA_RESOURCE_MANAGER_DATA_SOURCE_FLAG_WAIT_INIT) != 0) { ma_resource_manager_inline_notification_uninit(pInitNotification); } else { /* These will have been freed by the job thread, but with WAIT_INIT they will already have happend sinced the job has already been handled. */ ma_free(pFilePathCopy, &pResourceManager->config.allocationCallbacks); ma_free(pFilePathWCopy, &pResourceManager->config.allocationCallbacks); } ma_resource_manager_data_buffer_node_remove(pResourceManager, pDataBufferNode); ma_free(pDataBufferNode, &pResourceManager->config.allocationCallbacks); return result; } } } done: if (ppDataBufferNode != NULL) { *ppDataBufferNode = pDataBufferNode; } return result; } static ma_result ma_resource_manager_data_buffer_node_acquire(ma_resource_manager* pResourceManager, const char* pFilePath, const wchar_t* pFilePathW, ma_uint32 hashedName32, ma_uint32 flags, const ma_resource_manager_data_supply* pExistingData, ma_fence* pInitFence, ma_fence* pDoneFence, ma_resource_manager_data_buffer_node** ppDataBufferNode) { ma_result result = MA_SUCCESS; ma_bool32 nodeAlreadyExists = MA_FALSE; ma_resource_manager_data_buffer_node* pDataBufferNode = NULL; ma_resource_manager_inline_notification initNotification; /* Used when the WAIT_INIT flag is set. */ if (ppDataBufferNode != NULL) { *ppDataBufferNode = NULL; /* Safety. */ } if (pResourceManager == NULL || (pFilePath == NULL && pFilePathW == NULL && hashedName32 == 0)) { return MA_INVALID_ARGS; } /* If we're specifying existing data, it must be valid. */ if (pExistingData != NULL && pExistingData->type == ma_resource_manager_data_supply_type_unknown) { return MA_INVALID_ARGS; } /* If we don't support threading, remove the ASYNC flag to make the rest of this a bit simpler. */ if (ma_resource_manager_is_threading_enabled(pResourceManager) == MA_FALSE) { flags &= ~MA_RESOURCE_MANAGER_DATA_SOURCE_FLAG_ASYNC; } if (hashedName32 == 0) { if (pFilePath != NULL) { hashedName32 = ma_hash_string_32(pFilePath); } else { hashedName32 = ma_hash_string_w_32(pFilePathW); } } /* Here is where we either increment the node's reference count or allocate a new one and add it to the BST. When allocating a new node, we need to make sure the LOAD_DATA_BUFFER_NODE job is posted inside the critical section just in case the caller immediately uninitializes the node as this will ensure the FREE_DATA_BUFFER_NODE job is given an execution order such that the node is not uninitialized before initialization. */ ma_resource_manager_data_buffer_bst_lock(pResourceManager); { result = ma_resource_manager_data_buffer_node_acquire_critical_section(pResourceManager, pFilePath, pFilePathW, hashedName32, flags, pExistingData, pInitFence, pDoneFence, &initNotification, &pDataBufferNode); } ma_resource_manager_data_buffer_bst_unlock(pResourceManager); if (result == MA_ALREADY_EXISTS) { nodeAlreadyExists = MA_TRUE; result = MA_SUCCESS; } else { if (result != MA_SUCCESS) { return result; } } /* If we're loading synchronously, we'll need to load everything now. When loading asynchronously, a job will have been posted inside the BST critical section so that an uninitialization can be allocated an appropriate execution order thereby preventing it from being uninitialized before the node is initialized by the decoding thread(s). */ if (nodeAlreadyExists == MA_FALSE) { /* Don't need to try loading anything if the node already exists. */ if (pFilePath == NULL && pFilePathW == NULL) { /* If this path is hit, it means a buffer is being copied (i.e. initialized from only the hashed name), but that node has been freed in the meantime, probably from some other thread. This is an invalid operation. */ ma_log_postf(ma_resource_manager_get_log(pResourceManager), MA_LOG_LEVEL_WARNING, "Cloning data buffer node failed because the source node was released. The source node must remain valid until the cloning has completed.\n"); result = MA_INVALID_OPERATION; goto done; } if (pDataBufferNode->isDataOwnedByResourceManager) { if ((flags & MA_RESOURCE_MANAGER_DATA_SOURCE_FLAG_ASYNC) == 0) { /* Loading synchronously. Load the sound in it's entirety here. */ if ((flags & MA_RESOURCE_MANAGER_DATA_SOURCE_FLAG_DECODE) == 0) { /* No decoding. This is the simple case - just store the file contents in memory. */ result = ma_resource_manager_data_buffer_node_init_supply_encoded(pResourceManager, pDataBufferNode, pFilePath, pFilePathW); if (result != MA_SUCCESS) { goto done; } } else { /* Decoding. We do this the same way as we do when loading asynchronously. */ ma_decoder* pDecoder; result = ma_resource_manager_data_buffer_node_init_supply_decoded(pResourceManager, pDataBufferNode, pFilePath, pFilePathW, flags, &pDecoder); if (result != MA_SUCCESS) { goto done; } /* We have the decoder, now decode page by page just like we do when loading asynchronously. */ for (;;) { /* Decode next page. */ result = ma_resource_manager_data_buffer_node_decode_next_page(pResourceManager, pDataBufferNode, pDecoder); if (result != MA_SUCCESS) { break; /* Will return MA_AT_END when the last page has been decoded. */ } } /* Reaching the end needs to be considered successful. */ if (result == MA_AT_END) { result = MA_SUCCESS; } /* At this point the data buffer is either fully decoded or some error occurred. Either way, the decoder is no longer necessary. */ ma_decoder_uninit(pDecoder); ma_free(pDecoder, &pResourceManager->config.allocationCallbacks); } /* Getting here means we were successful. Make sure the status of the node is updated accordingly. */ ma_atomic_exchange_i32(&pDataBufferNode->result, result); } else { /* Loading asynchronously. We may need to wait for initialization. */ if ((flags & MA_RESOURCE_MANAGER_DATA_SOURCE_FLAG_WAIT_INIT) != 0) { ma_resource_manager_inline_notification_wait(&initNotification); } } } else { /* The data is not managed by the resource manager so there's nothing else to do. */ MA_ASSERT(pExistingData != NULL); } } done: /* If we failed to initialize the data buffer we need to free it. */ if (result != MA_SUCCESS) { if (nodeAlreadyExists == MA_FALSE) { ma_resource_manager_data_buffer_node_remove(pResourceManager, pDataBufferNode); ma_free(pDataBufferNode, &pResourceManager->config.allocationCallbacks); } } /* The init notification needs to be uninitialized. This will be used if the node does not already exist, and we've specified ASYNC | WAIT_INIT. */ if (nodeAlreadyExists == MA_FALSE && pDataBufferNode->isDataOwnedByResourceManager && (flags & MA_RESOURCE_MANAGER_DATA_SOURCE_FLAG_ASYNC) != 0) { if ((flags & MA_RESOURCE_MANAGER_DATA_SOURCE_FLAG_WAIT_INIT) != 0) { ma_resource_manager_inline_notification_uninit(&initNotification); } } if (ppDataBufferNode != NULL) { *ppDataBufferNode = pDataBufferNode; } return result; } static ma_result ma_resource_manager_data_buffer_node_unacquire(ma_resource_manager* pResourceManager, ma_resource_manager_data_buffer_node* pDataBufferNode, const char* pName, const wchar_t* pNameW) { ma_result result = MA_SUCCESS; ma_uint32 refCount = 0xFFFFFFFF; /* The new reference count of the node after decrementing. Initialize to non-0 to be safe we don't fall into the freeing path. */ ma_uint32 hashedName32 = 0; if (pResourceManager == NULL) { return MA_INVALID_ARGS; } if (pDataBufferNode == NULL) { if (pName == NULL && pNameW == NULL) { return MA_INVALID_ARGS; } if (pName != NULL) { hashedName32 = ma_hash_string_32(pName); } else { hashedName32 = ma_hash_string_w_32(pNameW); } } /* The first thing to do is decrement the reference counter of the node. Then, if the reference count is zero, we need to free the node. If the node is still in the process of loading, we'll need to post a job to the job queue to free the node. Otherwise we'll just do it here. */ ma_resource_manager_data_buffer_bst_lock(pResourceManager); { /* Might need to find the node. Must be done inside the critical section. */ if (pDataBufferNode == NULL) { result = ma_resource_manager_data_buffer_node_search(pResourceManager, hashedName32, &pDataBufferNode); if (result != MA_SUCCESS) { goto stage2; /* Couldn't find the node. */ } } result = ma_resource_manager_data_buffer_node_decrement_ref(pResourceManager, pDataBufferNode, &refCount); if (result != MA_SUCCESS) { goto stage2; /* Should never happen. */ } if (refCount == 0) { result = ma_resource_manager_data_buffer_node_remove(pResourceManager, pDataBufferNode); if (result != MA_SUCCESS) { goto stage2; /* An error occurred when trying to remove the data buffer. This should never happen. */ } } } ma_resource_manager_data_buffer_bst_unlock(pResourceManager); stage2: if (result != MA_SUCCESS) { return result; } /* Here is where we need to free the node. We don't want to do this inside the critical section above because we want to keep that as small as possible for multi-threaded efficiency. */ if (refCount == 0) { if (ma_resource_manager_data_buffer_node_result(pDataBufferNode) == MA_BUSY) { /* The sound is still loading. We need to delay the freeing of the node to a safe time. */ ma_job job; /* We need to mark the node as unavailable for the sake of the resource manager worker threads. */ ma_atomic_exchange_i32(&pDataBufferNode->result, MA_UNAVAILABLE); job = ma_job_init(MA_JOB_TYPE_RESOURCE_MANAGER_FREE_DATA_BUFFER_NODE); job.order = ma_resource_manager_data_buffer_node_next_execution_order(pDataBufferNode); job.data.resourceManager.freeDataBufferNode.pResourceManager = pResourceManager; job.data.resourceManager.freeDataBufferNode.pDataBufferNode = pDataBufferNode; result = ma_resource_manager_post_job(pResourceManager, &job); if (result != MA_SUCCESS) { ma_log_postf(ma_resource_manager_get_log(pResourceManager), MA_LOG_LEVEL_ERROR, "Failed to post MA_JOB_TYPE_RESOURCE_MANAGER_FREE_DATA_BUFFER_NODE job. %s.\n", ma_result_description(result)); return result; } /* If we don't support threading, process the job queue here. */ if (ma_resource_manager_is_threading_enabled(pResourceManager) == MA_FALSE) { while (ma_resource_manager_data_buffer_node_result(pDataBufferNode) == MA_BUSY) { result = ma_resource_manager_process_next_job(pResourceManager); if (result == MA_NO_DATA_AVAILABLE || result == MA_CANCELLED) { result = MA_SUCCESS; break; } } } else { /* Threading is enabled. The job queue will deal with the rest of the cleanup from here. */ } } else { /* The sound isn't loading so we can just free the node here. */ ma_resource_manager_data_buffer_node_free(pResourceManager, pDataBufferNode); } } return result; } static ma_uint32 ma_resource_manager_data_buffer_next_execution_order(ma_resource_manager_data_buffer* pDataBuffer) { MA_ASSERT(pDataBuffer != NULL); return ma_atomic_fetch_add_32(&pDataBuffer->executionCounter, 1); } static ma_result ma_resource_manager_data_buffer_cb__read_pcm_frames(ma_data_source* pDataSource, void* pFramesOut, ma_uint64 frameCount, ma_uint64* pFramesRead) { return ma_resource_manager_data_buffer_read_pcm_frames((ma_resource_manager_data_buffer*)pDataSource, pFramesOut, frameCount, pFramesRead); } static ma_result ma_resource_manager_data_buffer_cb__seek_to_pcm_frame(ma_data_source* pDataSource, ma_uint64 frameIndex) { return ma_resource_manager_data_buffer_seek_to_pcm_frame((ma_resource_manager_data_buffer*)pDataSource, frameIndex); } static ma_result ma_resource_manager_data_buffer_cb__get_data_format(ma_data_source* pDataSource, ma_format* pFormat, ma_uint32* pChannels, ma_uint32* pSampleRate, ma_channel* pChannelMap, size_t channelMapCap) { return ma_resource_manager_data_buffer_get_data_format((ma_resource_manager_data_buffer*)pDataSource, pFormat, pChannels, pSampleRate, pChannelMap, channelMapCap); } static ma_result ma_resource_manager_data_buffer_cb__get_cursor_in_pcm_frames(ma_data_source* pDataSource, ma_uint64* pCursor) { return ma_resource_manager_data_buffer_get_cursor_in_pcm_frames((ma_resource_manager_data_buffer*)pDataSource, pCursor); } static ma_result ma_resource_manager_data_buffer_cb__get_length_in_pcm_frames(ma_data_source* pDataSource, ma_uint64* pLength) { return ma_resource_manager_data_buffer_get_length_in_pcm_frames((ma_resource_manager_data_buffer*)pDataSource, pLength); } static ma_result ma_resource_manager_data_buffer_cb__set_looping(ma_data_source* pDataSource, ma_bool32 isLooping) { ma_resource_manager_data_buffer* pDataBuffer = (ma_resource_manager_data_buffer*)pDataSource; MA_ASSERT(pDataBuffer != NULL); ma_atomic_exchange_32(&pDataBuffer->isLooping, isLooping); /* The looping state needs to be set on the connector as well or else looping won't work when we read audio data. */ ma_data_source_set_looping(ma_resource_manager_data_buffer_get_connector(pDataBuffer), isLooping); return MA_SUCCESS; } static ma_data_source_vtable g_ma_resource_manager_data_buffer_vtable = { ma_resource_manager_data_buffer_cb__read_pcm_frames, ma_resource_manager_data_buffer_cb__seek_to_pcm_frame, ma_resource_manager_data_buffer_cb__get_data_format, ma_resource_manager_data_buffer_cb__get_cursor_in_pcm_frames, ma_resource_manager_data_buffer_cb__get_length_in_pcm_frames, ma_resource_manager_data_buffer_cb__set_looping, 0 }; static ma_result ma_resource_manager_data_buffer_init_ex_internal(ma_resource_manager* pResourceManager, const ma_resource_manager_data_source_config* pConfig, ma_uint32 hashedName32, ma_resource_manager_data_buffer* pDataBuffer) { ma_result result = MA_SUCCESS; ma_resource_manager_data_buffer_node* pDataBufferNode; ma_data_source_config dataSourceConfig; ma_bool32 async; ma_uint32 flags; ma_resource_manager_pipeline_notifications notifications; if (pDataBuffer == NULL) { if (pConfig != NULL && pConfig->pNotifications != NULL) { ma_resource_manager_pipeline_notifications_signal_all_notifications(pConfig->pNotifications); } return MA_INVALID_ARGS; } MA_ZERO_OBJECT(pDataBuffer); if (pConfig == NULL) { return MA_INVALID_ARGS; } if (pConfig->pNotifications != NULL) { notifications = *pConfig->pNotifications; /* From here on out we should be referencing `notifications` instead of `pNotifications`. Set this to NULL to catch errors at testing time. */ } else { MA_ZERO_OBJECT(¬ifications); } /* For safety, always remove the ASYNC flag if threading is disabled on the resource manager. */ flags = pConfig->flags; if (ma_resource_manager_is_threading_enabled(pResourceManager) == MA_FALSE) { flags &= ~MA_RESOURCE_MANAGER_DATA_SOURCE_FLAG_ASYNC; } async = (flags & MA_RESOURCE_MANAGER_DATA_SOURCE_FLAG_ASYNC) != 0; /* Fences need to be acquired before doing anything. These must be acquired and released outside of the node to ensure there's no holes where ma_fence_wait() could prematurely return before the data buffer has completed initialization. When loading asynchronously, the node acquisition routine below will acquire the fences on this thread and then release them on the async thread when the operation is complete. These fences are always released at the "done" tag at the end of this function. They'll be acquired a second if loading asynchronously. This double acquisition system is just done to simplify code maintanence. */ ma_resource_manager_pipeline_notifications_acquire_all_fences(¬ifications); { /* We first need to acquire a node. If ASYNC is not set, this will not return until the entire sound has been loaded. */ result = ma_resource_manager_data_buffer_node_acquire(pResourceManager, pConfig->pFilePath, pConfig->pFilePathW, hashedName32, flags, NULL, notifications.init.pFence, notifications.done.pFence, &pDataBufferNode); if (result != MA_SUCCESS) { ma_resource_manager_pipeline_notifications_signal_all_notifications(¬ifications); goto done; } dataSourceConfig = ma_data_source_config_init(); dataSourceConfig.vtable = &g_ma_resource_manager_data_buffer_vtable; result = ma_data_source_init(&dataSourceConfig, &pDataBuffer->ds); if (result != MA_SUCCESS) { ma_resource_manager_data_buffer_node_unacquire(pResourceManager, pDataBufferNode, NULL, NULL); ma_resource_manager_pipeline_notifications_signal_all_notifications(¬ifications); goto done; } pDataBuffer->pResourceManager = pResourceManager; pDataBuffer->pNode = pDataBufferNode; pDataBuffer->flags = flags; pDataBuffer->result = MA_BUSY; /* Always default to MA_BUSY for safety. It'll be overwritten when loading completes or an error occurs. */ /* If we're loading asynchronously we need to post a job to the job queue to initialize the connector. */ if (async == MA_FALSE || ma_resource_manager_data_buffer_node_result(pDataBufferNode) == MA_SUCCESS) { /* Loading synchronously or the data has already been fully loaded. We can just initialize the connector from here without a job. */ result = ma_resource_manager_data_buffer_init_connector(pDataBuffer, pConfig, NULL, NULL); ma_atomic_exchange_i32(&pDataBuffer->result, result); ma_resource_manager_pipeline_notifications_signal_all_notifications(¬ifications); goto done; } else { /* The node's data supply isn't initialized yet. The caller has requested that we load asynchronously so we need to post a job to do this. */ ma_job job; ma_resource_manager_inline_notification initNotification; /* Used when the WAIT_INIT flag is set. */ if ((flags & MA_RESOURCE_MANAGER_DATA_SOURCE_FLAG_WAIT_INIT) != 0) { ma_resource_manager_inline_notification_init(pResourceManager, &initNotification); } /* The status of the data buffer needs to be set to MA_BUSY before posting the job so that the worker thread is aware of it's busy state. If the LOAD_DATA_BUFFER job sees a status other than MA_BUSY, it'll assume an error and fall through to an early exit. */ ma_atomic_exchange_i32(&pDataBuffer->result, MA_BUSY); /* Acquire fences a second time. These will be released by the async thread. */ ma_resource_manager_pipeline_notifications_acquire_all_fences(¬ifications); job = ma_job_init(MA_JOB_TYPE_RESOURCE_MANAGER_LOAD_DATA_BUFFER); job.order = ma_resource_manager_data_buffer_next_execution_order(pDataBuffer); job.data.resourceManager.loadDataBuffer.pDataBuffer = pDataBuffer; job.data.resourceManager.loadDataBuffer.pInitNotification = ((flags & MA_RESOURCE_MANAGER_DATA_SOURCE_FLAG_WAIT_INIT) != 0) ? &initNotification : notifications.init.pNotification; job.data.resourceManager.loadDataBuffer.pDoneNotification = notifications.done.pNotification; job.data.resourceManager.loadDataBuffer.pInitFence = notifications.init.pFence; job.data.resourceManager.loadDataBuffer.pDoneFence = notifications.done.pFence; job.data.resourceManager.loadDataBuffer.rangeBegInPCMFrames = pConfig->rangeBegInPCMFrames; job.data.resourceManager.loadDataBuffer.rangeEndInPCMFrames = pConfig->rangeEndInPCMFrames; job.data.resourceManager.loadDataBuffer.loopPointBegInPCMFrames = pConfig->loopPointBegInPCMFrames; job.data.resourceManager.loadDataBuffer.loopPointEndInPCMFrames = pConfig->loopPointEndInPCMFrames; job.data.resourceManager.loadDataBuffer.isLooping = pConfig->isLooping; /* If we need to wait for initialization to complete we can just process the job in place. */ if ((flags & MA_RESOURCE_MANAGER_DATA_SOURCE_FLAG_WAIT_INIT) != 0) { result = ma_job_process(&job); } else { result = ma_resource_manager_post_job(pResourceManager, &job); } if (result != MA_SUCCESS) { /* We failed to post the job. Most likely there isn't enough room in the queue's buffer. */ ma_log_postf(ma_resource_manager_get_log(pResourceManager), MA_LOG_LEVEL_ERROR, "Failed to post MA_JOB_TYPE_RESOURCE_MANAGER_LOAD_DATA_BUFFER job. %s.\n", ma_result_description(result)); ma_atomic_exchange_i32(&pDataBuffer->result, result); /* Release the fences after the result has been set on the data buffer. */ ma_resource_manager_pipeline_notifications_release_all_fences(¬ifications); } else { if ((flags & MA_RESOURCE_MANAGER_DATA_SOURCE_FLAG_WAIT_INIT) != 0) { ma_resource_manager_inline_notification_wait(&initNotification); if (notifications.init.pNotification != NULL) { ma_async_notification_signal(notifications.init.pNotification); } /* NOTE: Do not release the init fence here. It will have been done by the job. */ /* Make sure we return an error if initialization failed on the async thread. */ result = ma_resource_manager_data_buffer_result(pDataBuffer); if (result == MA_BUSY) { result = MA_SUCCESS; } } } if ((flags & MA_RESOURCE_MANAGER_DATA_SOURCE_FLAG_WAIT_INIT) != 0) { ma_resource_manager_inline_notification_uninit(&initNotification); } } if (result != MA_SUCCESS) { ma_resource_manager_data_buffer_node_unacquire(pResourceManager, pDataBufferNode, NULL, NULL); goto done; } } done: if (result == MA_SUCCESS) { if (pConfig->initialSeekPointInPCMFrames > 0) { ma_resource_manager_data_buffer_seek_to_pcm_frame(pDataBuffer, pConfig->initialSeekPointInPCMFrames); } } ma_resource_manager_pipeline_notifications_release_all_fences(¬ifications); return result; } MA_API ma_result ma_resource_manager_data_buffer_init_ex(ma_resource_manager* pResourceManager, const ma_resource_manager_data_source_config* pConfig, ma_resource_manager_data_buffer* pDataBuffer) { return ma_resource_manager_data_buffer_init_ex_internal(pResourceManager, pConfig, 0, pDataBuffer); } MA_API ma_result ma_resource_manager_data_buffer_init(ma_resource_manager* pResourceManager, const char* pFilePath, ma_uint32 flags, const ma_resource_manager_pipeline_notifications* pNotifications, ma_resource_manager_data_buffer* pDataBuffer) { ma_resource_manager_data_source_config config; config = ma_resource_manager_data_source_config_init(); config.pFilePath = pFilePath; config.flags = flags; config.pNotifications = pNotifications; return ma_resource_manager_data_buffer_init_ex(pResourceManager, &config, pDataBuffer); } MA_API ma_result ma_resource_manager_data_buffer_init_w(ma_resource_manager* pResourceManager, const wchar_t* pFilePath, ma_uint32 flags, const ma_resource_manager_pipeline_notifications* pNotifications, ma_resource_manager_data_buffer* pDataBuffer) { ma_resource_manager_data_source_config config; config = ma_resource_manager_data_source_config_init(); config.pFilePathW = pFilePath; config.flags = flags; config.pNotifications = pNotifications; return ma_resource_manager_data_buffer_init_ex(pResourceManager, &config, pDataBuffer); } MA_API ma_result ma_resource_manager_data_buffer_init_copy(ma_resource_manager* pResourceManager, const ma_resource_manager_data_buffer* pExistingDataBuffer, ma_resource_manager_data_buffer* pDataBuffer) { ma_resource_manager_data_source_config config; if (pExistingDataBuffer == NULL) { return MA_INVALID_ARGS; } MA_ASSERT(pExistingDataBuffer->pNode != NULL); /* <-- If you've triggered this, you've passed in an invalid existing data buffer. */ config = ma_resource_manager_data_source_config_init(); config.flags = pExistingDataBuffer->flags; return ma_resource_manager_data_buffer_init_ex_internal(pResourceManager, &config, pExistingDataBuffer->pNode->hashedName32, pDataBuffer); } static ma_result ma_resource_manager_data_buffer_uninit_internal(ma_resource_manager_data_buffer* pDataBuffer) { MA_ASSERT(pDataBuffer != NULL); /* The connector should be uninitialized first. */ ma_resource_manager_data_buffer_uninit_connector(pDataBuffer->pResourceManager, pDataBuffer); /* With the connector uninitialized we can unacquire the node. */ ma_resource_manager_data_buffer_node_unacquire(pDataBuffer->pResourceManager, pDataBuffer->pNode, NULL, NULL); /* The base data source needs to be uninitialized as well. */ ma_data_source_uninit(&pDataBuffer->ds); return MA_SUCCESS; } MA_API ma_result ma_resource_manager_data_buffer_uninit(ma_resource_manager_data_buffer* pDataBuffer) { ma_result result; if (pDataBuffer == NULL) { return MA_INVALID_ARGS; } if (ma_resource_manager_data_buffer_result(pDataBuffer) == MA_SUCCESS) { /* The data buffer can be deleted synchronously. */ return ma_resource_manager_data_buffer_uninit_internal(pDataBuffer); } else { /* The data buffer needs to be deleted asynchronously because it's still loading. With the status set to MA_UNAVAILABLE, no more pages will be loaded and the uninitialization should happen fairly quickly. Since the caller owns the data buffer, we need to wait for this event to get processed before returning. */ ma_resource_manager_inline_notification notification; ma_job job; /* We need to mark the node as unavailable so we don't try reading from it anymore, but also to let the loading thread know that it needs to abort it's loading procedure. */ ma_atomic_exchange_i32(&pDataBuffer->result, MA_UNAVAILABLE); result = ma_resource_manager_inline_notification_init(pDataBuffer->pResourceManager, ¬ification); if (result != MA_SUCCESS) { return result; /* Failed to create the notification. This should rarely, if ever, happen. */ } job = ma_job_init(MA_JOB_TYPE_RESOURCE_MANAGER_FREE_DATA_BUFFER); job.order = ma_resource_manager_data_buffer_next_execution_order(pDataBuffer); job.data.resourceManager.freeDataBuffer.pDataBuffer = pDataBuffer; job.data.resourceManager.freeDataBuffer.pDoneNotification = ¬ification; job.data.resourceManager.freeDataBuffer.pDoneFence = NULL; result = ma_resource_manager_post_job(pDataBuffer->pResourceManager, &job); if (result != MA_SUCCESS) { ma_resource_manager_inline_notification_uninit(¬ification); return result; } ma_resource_manager_inline_notification_wait_and_uninit(¬ification); } return result; } MA_API ma_result ma_resource_manager_data_buffer_read_pcm_frames(ma_resource_manager_data_buffer* pDataBuffer, void* pFramesOut, ma_uint64 frameCount, ma_uint64* pFramesRead) { ma_result result = MA_SUCCESS; ma_uint64 framesRead = 0; ma_bool32 isDecodedBufferBusy = MA_FALSE; /* Safety. */ if (pFramesRead != NULL) { *pFramesRead = 0; } if (frameCount == 0) { return MA_INVALID_ARGS; } /* We cannot be using the data buffer after it's been uninitialized. If you trigger this assert it means you're trying to read from the data buffer after it's been uninitialized or is in the process of uninitializing. */ MA_ASSERT(ma_resource_manager_data_buffer_node_result(pDataBuffer->pNode) != MA_UNAVAILABLE); /* If the node is not initialized we need to abort with a busy code. */ if (ma_resource_manager_data_buffer_has_connector(pDataBuffer) == MA_FALSE) { return MA_BUSY; /* Still loading. */ } /* If we've got a seek scheduled we'll want to do that before reading. However, for paged buffers, there's a chance that the sound hasn't yet been decoded up to the seek point will result in the seek failing. If this happens, we need to keep the seek scheduled and return MA_BUSY. */ if (pDataBuffer->seekToCursorOnNextRead) { pDataBuffer->seekToCursorOnNextRead = MA_FALSE; result = ma_data_source_seek_to_pcm_frame(ma_resource_manager_data_buffer_get_connector(pDataBuffer), pDataBuffer->seekTargetInPCMFrames); if (result != MA_SUCCESS) { if (result == MA_BAD_SEEK && ma_resource_manager_data_buffer_node_get_data_supply_type(pDataBuffer->pNode) == ma_resource_manager_data_supply_type_decoded_paged) { pDataBuffer->seekToCursorOnNextRead = MA_TRUE; /* Keep the seek scheduled. We just haven't loaded enough data yet to do the seek properly. */ return MA_BUSY; } return result; } } /* For decoded buffers (not paged) we need to check beforehand how many frames we have available. We cannot exceed this amount. We'll read as much as we can, and then return MA_BUSY. */ if (ma_resource_manager_data_buffer_node_get_data_supply_type(pDataBuffer->pNode) == ma_resource_manager_data_supply_type_decoded) { ma_uint64 availableFrames; isDecodedBufferBusy = (ma_resource_manager_data_buffer_node_result(pDataBuffer->pNode) == MA_BUSY); if (ma_resource_manager_data_buffer_get_available_frames(pDataBuffer, &availableFrames) == MA_SUCCESS) { /* Don't try reading more than the available frame count. */ if (frameCount > availableFrames) { frameCount = availableFrames; /* If there's no frames available we want to set the status to MA_AT_END. The logic below will check if the node is busy, and if so, change it to MA_BUSY. The reason we do this is because we don't want to call `ma_data_source_read_pcm_frames()` if the frame count is 0 because that'll result in a situation where it's possible MA_AT_END won't get returned. */ if (frameCount == 0) { result = MA_AT_END; } } else { isDecodedBufferBusy = MA_FALSE; /* We have enough frames available in the buffer to avoid a MA_BUSY status. */ } } } /* Don't attempt to read anything if we've got no frames available. */ if (frameCount > 0) { result = ma_data_source_read_pcm_frames(ma_resource_manager_data_buffer_get_connector(pDataBuffer), pFramesOut, frameCount, &framesRead); } /* If we returned MA_AT_END, but the node is still loading, we don't want to return that code or else the caller will interpret the sound as at the end and terminate decoding. */ if (result == MA_AT_END) { if (ma_resource_manager_data_buffer_node_result(pDataBuffer->pNode) == MA_BUSY) { result = MA_BUSY; } } if (isDecodedBufferBusy) { result = MA_BUSY; } if (pFramesRead != NULL) { *pFramesRead = framesRead; } if (result == MA_SUCCESS && framesRead == 0) { result = MA_AT_END; } return result; } MA_API ma_result ma_resource_manager_data_buffer_seek_to_pcm_frame(ma_resource_manager_data_buffer* pDataBuffer, ma_uint64 frameIndex) { ma_result result; /* We cannot be using the data source after it's been uninitialized. */ MA_ASSERT(ma_resource_manager_data_buffer_node_result(pDataBuffer->pNode) != MA_UNAVAILABLE); /* If we haven't yet got a connector we need to abort. */ if (ma_resource_manager_data_buffer_has_connector(pDataBuffer) == MA_FALSE) { pDataBuffer->seekTargetInPCMFrames = frameIndex; pDataBuffer->seekToCursorOnNextRead = MA_TRUE; return MA_BUSY; /* Still loading. */ } result = ma_data_source_seek_to_pcm_frame(ma_resource_manager_data_buffer_get_connector(pDataBuffer), frameIndex); if (result != MA_SUCCESS) { return result; } pDataBuffer->seekTargetInPCMFrames = ~(ma_uint64)0; /* <-- For identification purposes. */ pDataBuffer->seekToCursorOnNextRead = MA_FALSE; return MA_SUCCESS; } MA_API ma_result ma_resource_manager_data_buffer_get_data_format(ma_resource_manager_data_buffer* pDataBuffer, ma_format* pFormat, ma_uint32* pChannels, ma_uint32* pSampleRate, ma_channel* pChannelMap, size_t channelMapCap) { /* We cannot be using the data source after it's been uninitialized. */ MA_ASSERT(ma_resource_manager_data_buffer_node_result(pDataBuffer->pNode) != MA_UNAVAILABLE); switch (ma_resource_manager_data_buffer_node_get_data_supply_type(pDataBuffer->pNode)) { case ma_resource_manager_data_supply_type_encoded: { return ma_data_source_get_data_format(&pDataBuffer->connector.decoder, pFormat, pChannels, pSampleRate, pChannelMap, channelMapCap); }; case ma_resource_manager_data_supply_type_decoded: { *pFormat = pDataBuffer->pNode->data.backend.decoded.format; *pChannels = pDataBuffer->pNode->data.backend.decoded.channels; *pSampleRate = pDataBuffer->pNode->data.backend.decoded.sampleRate; ma_channel_map_init_standard(ma_standard_channel_map_default, pChannelMap, channelMapCap, pDataBuffer->pNode->data.backend.decoded.channels); return MA_SUCCESS; }; case ma_resource_manager_data_supply_type_decoded_paged: { *pFormat = pDataBuffer->pNode->data.backend.decodedPaged.data.format; *pChannels = pDataBuffer->pNode->data.backend.decodedPaged.data.channels; *pSampleRate = pDataBuffer->pNode->data.backend.decodedPaged.sampleRate; ma_channel_map_init_standard(ma_standard_channel_map_default, pChannelMap, channelMapCap, pDataBuffer->pNode->data.backend.decoded.channels); return MA_SUCCESS; }; case ma_resource_manager_data_supply_type_unknown: { return MA_BUSY; /* Still loading. */ }; default: { /* Unknown supply type. Should never hit this. */ return MA_INVALID_ARGS; } } } MA_API ma_result ma_resource_manager_data_buffer_get_cursor_in_pcm_frames(ma_resource_manager_data_buffer* pDataBuffer, ma_uint64* pCursor) { /* We cannot be using the data source after it's been uninitialized. */ MA_ASSERT(ma_resource_manager_data_buffer_node_result(pDataBuffer->pNode) != MA_UNAVAILABLE); if (pDataBuffer == NULL || pCursor == NULL) { return MA_INVALID_ARGS; } *pCursor = 0; switch (ma_resource_manager_data_buffer_node_get_data_supply_type(pDataBuffer->pNode)) { case ma_resource_manager_data_supply_type_encoded: { return ma_decoder_get_cursor_in_pcm_frames(&pDataBuffer->connector.decoder, pCursor); }; case ma_resource_manager_data_supply_type_decoded: { return ma_audio_buffer_get_cursor_in_pcm_frames(&pDataBuffer->connector.buffer, pCursor); }; case ma_resource_manager_data_supply_type_decoded_paged: { return ma_paged_audio_buffer_get_cursor_in_pcm_frames(&pDataBuffer->connector.pagedBuffer, pCursor); }; case ma_resource_manager_data_supply_type_unknown: { return MA_BUSY; }; default: { return MA_INVALID_ARGS; } } } MA_API ma_result ma_resource_manager_data_buffer_get_length_in_pcm_frames(ma_resource_manager_data_buffer* pDataBuffer, ma_uint64* pLength) { /* We cannot be using the data source after it's been uninitialized. */ MA_ASSERT(ma_resource_manager_data_buffer_node_result(pDataBuffer->pNode) != MA_UNAVAILABLE); if (pDataBuffer == NULL || pLength == NULL) { return MA_INVALID_ARGS; } if (ma_resource_manager_data_buffer_node_get_data_supply_type(pDataBuffer->pNode) == ma_resource_manager_data_supply_type_unknown) { return MA_BUSY; /* Still loading. */ } return ma_data_source_get_length_in_pcm_frames(ma_resource_manager_data_buffer_get_connector(pDataBuffer), pLength); } MA_API ma_result ma_resource_manager_data_buffer_result(const ma_resource_manager_data_buffer* pDataBuffer) { if (pDataBuffer == NULL) { return MA_INVALID_ARGS; } return (ma_result)ma_atomic_load_i32((ma_result*)&pDataBuffer->result); /* Need a naughty const-cast here. */ } MA_API ma_result ma_resource_manager_data_buffer_set_looping(ma_resource_manager_data_buffer* pDataBuffer, ma_bool32 isLooping) { return ma_data_source_set_looping(pDataBuffer, isLooping); } MA_API ma_bool32 ma_resource_manager_data_buffer_is_looping(const ma_resource_manager_data_buffer* pDataBuffer) { return ma_data_source_is_looping(pDataBuffer); } MA_API ma_result ma_resource_manager_data_buffer_get_available_frames(ma_resource_manager_data_buffer* pDataBuffer, ma_uint64* pAvailableFrames) { if (pAvailableFrames == NULL) { return MA_INVALID_ARGS; } *pAvailableFrames = 0; if (pDataBuffer == NULL) { return MA_INVALID_ARGS; } if (ma_resource_manager_data_buffer_node_get_data_supply_type(pDataBuffer->pNode) == ma_resource_manager_data_supply_type_unknown) { if (ma_resource_manager_data_buffer_node_result(pDataBuffer->pNode) == MA_BUSY) { return MA_BUSY; } else { return MA_INVALID_OPERATION; /* No connector. */ } } switch (ma_resource_manager_data_buffer_node_get_data_supply_type(pDataBuffer->pNode)) { case ma_resource_manager_data_supply_type_encoded: { return ma_decoder_get_available_frames(&pDataBuffer->connector.decoder, pAvailableFrames); }; case ma_resource_manager_data_supply_type_decoded: { return ma_audio_buffer_get_available_frames(&pDataBuffer->connector.buffer, pAvailableFrames); }; case ma_resource_manager_data_supply_type_decoded_paged: { ma_uint64 cursor; ma_paged_audio_buffer_get_cursor_in_pcm_frames(&pDataBuffer->connector.pagedBuffer, &cursor); if (pDataBuffer->pNode->data.backend.decodedPaged.decodedFrameCount > cursor) { *pAvailableFrames = pDataBuffer->pNode->data.backend.decodedPaged.decodedFrameCount - cursor; } else { *pAvailableFrames = 0; } return MA_SUCCESS; }; case ma_resource_manager_data_supply_type_unknown: default: { /* Unknown supply type. Should never hit this. */ return MA_INVALID_ARGS; } } } MA_API ma_result ma_resource_manager_register_file(ma_resource_manager* pResourceManager, const char* pFilePath, ma_uint32 flags) { return ma_resource_manager_data_buffer_node_acquire(pResourceManager, pFilePath, NULL, 0, flags, NULL, NULL, NULL, NULL); } MA_API ma_result ma_resource_manager_register_file_w(ma_resource_manager* pResourceManager, const wchar_t* pFilePath, ma_uint32 flags) { return ma_resource_manager_data_buffer_node_acquire(pResourceManager, NULL, pFilePath, 0, flags, NULL, NULL, NULL, NULL); } static ma_result ma_resource_manager_register_data(ma_resource_manager* pResourceManager, const char* pName, const wchar_t* pNameW, ma_resource_manager_data_supply* pExistingData) { return ma_resource_manager_data_buffer_node_acquire(pResourceManager, pName, pNameW, 0, 0, pExistingData, NULL, NULL, NULL); } static ma_result ma_resource_manager_register_decoded_data_internal(ma_resource_manager* pResourceManager, const char* pName, const wchar_t* pNameW, const void* pData, ma_uint64 frameCount, ma_format format, ma_uint32 channels, ma_uint32 sampleRate) { ma_resource_manager_data_supply data; data.type = ma_resource_manager_data_supply_type_decoded; data.backend.decoded.pData = pData; data.backend.decoded.totalFrameCount = frameCount; data.backend.decoded.format = format; data.backend.decoded.channels = channels; data.backend.decoded.sampleRate = sampleRate; return ma_resource_manager_register_data(pResourceManager, pName, pNameW, &data); } MA_API ma_result ma_resource_manager_register_decoded_data(ma_resource_manager* pResourceManager, const char* pName, const void* pData, ma_uint64 frameCount, ma_format format, ma_uint32 channels, ma_uint32 sampleRate) { return ma_resource_manager_register_decoded_data_internal(pResourceManager, pName, NULL, pData, frameCount, format, channels, sampleRate); } MA_API ma_result ma_resource_manager_register_decoded_data_w(ma_resource_manager* pResourceManager, const wchar_t* pName, const void* pData, ma_uint64 frameCount, ma_format format, ma_uint32 channels, ma_uint32 sampleRate) { return ma_resource_manager_register_decoded_data_internal(pResourceManager, NULL, pName, pData, frameCount, format, channels, sampleRate); } static ma_result ma_resource_manager_register_encoded_data_internal(ma_resource_manager* pResourceManager, const char* pName, const wchar_t* pNameW, const void* pData, size_t sizeInBytes) { ma_resource_manager_data_supply data; data.type = ma_resource_manager_data_supply_type_encoded; data.backend.encoded.pData = pData; data.backend.encoded.sizeInBytes = sizeInBytes; return ma_resource_manager_register_data(pResourceManager, pName, pNameW, &data); } MA_API ma_result ma_resource_manager_register_encoded_data(ma_resource_manager* pResourceManager, const char* pName, const void* pData, size_t sizeInBytes) { return ma_resource_manager_register_encoded_data_internal(pResourceManager, pName, NULL, pData, sizeInBytes); } MA_API ma_result ma_resource_manager_register_encoded_data_w(ma_resource_manager* pResourceManager, const wchar_t* pName, const void* pData, size_t sizeInBytes) { return ma_resource_manager_register_encoded_data_internal(pResourceManager, NULL, pName, pData, sizeInBytes); } MA_API ma_result ma_resource_manager_unregister_file(ma_resource_manager* pResourceManager, const char* pFilePath) { return ma_resource_manager_unregister_data(pResourceManager, pFilePath); } MA_API ma_result ma_resource_manager_unregister_file_w(ma_resource_manager* pResourceManager, const wchar_t* pFilePath) { return ma_resource_manager_unregister_data_w(pResourceManager, pFilePath); } MA_API ma_result ma_resource_manager_unregister_data(ma_resource_manager* pResourceManager, const char* pName) { return ma_resource_manager_data_buffer_node_unacquire(pResourceManager, NULL, pName, NULL); } MA_API ma_result ma_resource_manager_unregister_data_w(ma_resource_manager* pResourceManager, const wchar_t* pName) { return ma_resource_manager_data_buffer_node_unacquire(pResourceManager, NULL, NULL, pName); } static ma_uint32 ma_resource_manager_data_stream_next_execution_order(ma_resource_manager_data_stream* pDataStream) { MA_ASSERT(pDataStream != NULL); return ma_atomic_fetch_add_32(&pDataStream->executionCounter, 1); } static ma_bool32 ma_resource_manager_data_stream_is_decoder_at_end(const ma_resource_manager_data_stream* pDataStream) { MA_ASSERT(pDataStream != NULL); return ma_atomic_load_32((ma_bool32*)&pDataStream->isDecoderAtEnd); } static ma_uint32 ma_resource_manager_data_stream_seek_counter(const ma_resource_manager_data_stream* pDataStream) { MA_ASSERT(pDataStream != NULL); return ma_atomic_load_32((ma_uint32*)&pDataStream->seekCounter); } static ma_result ma_resource_manager_data_stream_cb__read_pcm_frames(ma_data_source* pDataSource, void* pFramesOut, ma_uint64 frameCount, ma_uint64* pFramesRead) { return ma_resource_manager_data_stream_read_pcm_frames((ma_resource_manager_data_stream*)pDataSource, pFramesOut, frameCount, pFramesRead); } static ma_result ma_resource_manager_data_stream_cb__seek_to_pcm_frame(ma_data_source* pDataSource, ma_uint64 frameIndex) { return ma_resource_manager_data_stream_seek_to_pcm_frame((ma_resource_manager_data_stream*)pDataSource, frameIndex); } static ma_result ma_resource_manager_data_stream_cb__get_data_format(ma_data_source* pDataSource, ma_format* pFormat, ma_uint32* pChannels, ma_uint32* pSampleRate, ma_channel* pChannelMap, size_t channelMapCap) { return ma_resource_manager_data_stream_get_data_format((ma_resource_manager_data_stream*)pDataSource, pFormat, pChannels, pSampleRate, pChannelMap, channelMapCap); } static ma_result ma_resource_manager_data_stream_cb__get_cursor_in_pcm_frames(ma_data_source* pDataSource, ma_uint64* pCursor) { return ma_resource_manager_data_stream_get_cursor_in_pcm_frames((ma_resource_manager_data_stream*)pDataSource, pCursor); } static ma_result ma_resource_manager_data_stream_cb__get_length_in_pcm_frames(ma_data_source* pDataSource, ma_uint64* pLength) { return ma_resource_manager_data_stream_get_length_in_pcm_frames((ma_resource_manager_data_stream*)pDataSource, pLength); } static ma_result ma_resource_manager_data_stream_cb__set_looping(ma_data_source* pDataSource, ma_bool32 isLooping) { ma_resource_manager_data_stream* pDataStream = (ma_resource_manager_data_stream*)pDataSource; MA_ASSERT(pDataStream != NULL); ma_atomic_exchange_32(&pDataStream->isLooping, isLooping); return MA_SUCCESS; } static ma_data_source_vtable g_ma_resource_manager_data_stream_vtable = { ma_resource_manager_data_stream_cb__read_pcm_frames, ma_resource_manager_data_stream_cb__seek_to_pcm_frame, ma_resource_manager_data_stream_cb__get_data_format, ma_resource_manager_data_stream_cb__get_cursor_in_pcm_frames, ma_resource_manager_data_stream_cb__get_length_in_pcm_frames, ma_resource_manager_data_stream_cb__set_looping, 0 /*MA_DATA_SOURCE_SELF_MANAGED_RANGE_AND_LOOP_POINT*/ }; static void ma_resource_manager_data_stream_set_absolute_cursor(ma_resource_manager_data_stream* pDataStream, ma_uint64 absoluteCursor) { /* Loop if possible. */ if (absoluteCursor > pDataStream->totalLengthInPCMFrames && pDataStream->totalLengthInPCMFrames > 0) { absoluteCursor = absoluteCursor % pDataStream->totalLengthInPCMFrames; } ma_atomic_exchange_64(&pDataStream->absoluteCursor, absoluteCursor); } MA_API ma_result ma_resource_manager_data_stream_init_ex(ma_resource_manager* pResourceManager, const ma_resource_manager_data_source_config* pConfig, ma_resource_manager_data_stream* pDataStream) { ma_result result; ma_data_source_config dataSourceConfig; char* pFilePathCopy = NULL; wchar_t* pFilePathWCopy = NULL; ma_job job; ma_bool32 waitBeforeReturning = MA_FALSE; ma_resource_manager_inline_notification waitNotification; ma_resource_manager_pipeline_notifications notifications; if (pDataStream == NULL) { if (pConfig != NULL && pConfig->pNotifications != NULL) { ma_resource_manager_pipeline_notifications_signal_all_notifications(pConfig->pNotifications); } return MA_INVALID_ARGS; } MA_ZERO_OBJECT(pDataStream); if (pConfig == NULL) { return MA_INVALID_ARGS; } if (pConfig->pNotifications != NULL) { notifications = *pConfig->pNotifications; /* From here on out, `notifications` should be used instead of `pNotifications`. Setting this to NULL to catch any errors at testing time. */ } else { MA_ZERO_OBJECT(¬ifications); } dataSourceConfig = ma_data_source_config_init(); dataSourceConfig.vtable = &g_ma_resource_manager_data_stream_vtable; result = ma_data_source_init(&dataSourceConfig, &pDataStream->ds); if (result != MA_SUCCESS) { ma_resource_manager_pipeline_notifications_signal_all_notifications(¬ifications); return result; } pDataStream->pResourceManager = pResourceManager; pDataStream->flags = pConfig->flags; pDataStream->result = MA_BUSY; ma_data_source_set_range_in_pcm_frames(pDataStream, pConfig->rangeBegInPCMFrames, pConfig->rangeEndInPCMFrames); ma_data_source_set_loop_point_in_pcm_frames(pDataStream, pConfig->loopPointBegInPCMFrames, pConfig->loopPointEndInPCMFrames); ma_data_source_set_looping(pDataStream, pConfig->isLooping); if (pResourceManager == NULL || (pConfig->pFilePath == NULL && pConfig->pFilePathW == NULL)) { ma_resource_manager_pipeline_notifications_signal_all_notifications(¬ifications); return MA_INVALID_ARGS; } /* We want all access to the VFS and the internal decoder to happen on the job thread just to keep things easier to manage for the VFS. */ /* We need a copy of the file path. We should probably make this more efficient, but for now we'll do a transient memory allocation. */ if (pConfig->pFilePath != NULL) { pFilePathCopy = ma_copy_string(pConfig->pFilePath, &pResourceManager->config.allocationCallbacks); } else { pFilePathWCopy = ma_copy_string_w(pConfig->pFilePathW, &pResourceManager->config.allocationCallbacks); } if (pFilePathCopy == NULL && pFilePathWCopy == NULL) { ma_resource_manager_pipeline_notifications_signal_all_notifications(¬ifications); return MA_OUT_OF_MEMORY; } /* We need to check for the presence of MA_RESOURCE_MANAGER_DATA_SOURCE_FLAG_ASYNC. If it's not set, we need to wait before returning. Otherwise we can return immediately. Likewise, we'll also check for MA_RESOURCE_MANAGER_DATA_SOURCE_FLAG_WAIT_INIT and do the same. */ if ((pConfig->flags & MA_RESOURCE_MANAGER_DATA_SOURCE_FLAG_ASYNC) == 0 || (pConfig->flags & MA_RESOURCE_MANAGER_DATA_SOURCE_FLAG_WAIT_INIT) != 0) { waitBeforeReturning = MA_TRUE; ma_resource_manager_inline_notification_init(pResourceManager, &waitNotification); } ma_resource_manager_pipeline_notifications_acquire_all_fences(¬ifications); /* Set the absolute cursor to our initial seek position so retrieval of the cursor returns a good value. */ ma_resource_manager_data_stream_set_absolute_cursor(pDataStream, pConfig->initialSeekPointInPCMFrames); /* We now have everything we need to post the job. This is the last thing we need to do from here. The rest will be done by the job thread. */ job = ma_job_init(MA_JOB_TYPE_RESOURCE_MANAGER_LOAD_DATA_STREAM); job.order = ma_resource_manager_data_stream_next_execution_order(pDataStream); job.data.resourceManager.loadDataStream.pDataStream = pDataStream; job.data.resourceManager.loadDataStream.pFilePath = pFilePathCopy; job.data.resourceManager.loadDataStream.pFilePathW = pFilePathWCopy; job.data.resourceManager.loadDataStream.initialSeekPoint = pConfig->initialSeekPointInPCMFrames; job.data.resourceManager.loadDataStream.pInitNotification = (waitBeforeReturning == MA_TRUE) ? &waitNotification : notifications.init.pNotification; job.data.resourceManager.loadDataStream.pInitFence = notifications.init.pFence; result = ma_resource_manager_post_job(pResourceManager, &job); if (result != MA_SUCCESS) { ma_resource_manager_pipeline_notifications_signal_all_notifications(¬ifications); ma_resource_manager_pipeline_notifications_release_all_fences(¬ifications); if (waitBeforeReturning) { ma_resource_manager_inline_notification_uninit(&waitNotification); } ma_free(pFilePathCopy, &pResourceManager->config.allocationCallbacks); ma_free(pFilePathWCopy, &pResourceManager->config.allocationCallbacks); return result; } /* Wait if needed. */ if (waitBeforeReturning) { ma_resource_manager_inline_notification_wait_and_uninit(&waitNotification); if (notifications.init.pNotification != NULL) { ma_async_notification_signal(notifications.init.pNotification); } /* If there was an error during initialization make sure we return that result here. We don't want to do this if we're not waiting because it will most likely be in a busy state. */ if (pDataStream->result != MA_SUCCESS) { return pDataStream->result; } /* NOTE: Do not release pInitFence here. That will be done by the job. */ } return MA_SUCCESS; } MA_API ma_result ma_resource_manager_data_stream_init(ma_resource_manager* pResourceManager, const char* pFilePath, ma_uint32 flags, const ma_resource_manager_pipeline_notifications* pNotifications, ma_resource_manager_data_stream* pDataStream) { ma_resource_manager_data_source_config config; config = ma_resource_manager_data_source_config_init(); config.pFilePath = pFilePath; config.flags = flags; config.pNotifications = pNotifications; return ma_resource_manager_data_stream_init_ex(pResourceManager, &config, pDataStream); } MA_API ma_result ma_resource_manager_data_stream_init_w(ma_resource_manager* pResourceManager, const wchar_t* pFilePath, ma_uint32 flags, const ma_resource_manager_pipeline_notifications* pNotifications, ma_resource_manager_data_stream* pDataStream) { ma_resource_manager_data_source_config config; config = ma_resource_manager_data_source_config_init(); config.pFilePathW = pFilePath; config.flags = flags; config.pNotifications = pNotifications; return ma_resource_manager_data_stream_init_ex(pResourceManager, &config, pDataStream); } MA_API ma_result ma_resource_manager_data_stream_uninit(ma_resource_manager_data_stream* pDataStream) { ma_resource_manager_inline_notification freeEvent; ma_job job; if (pDataStream == NULL) { return MA_INVALID_ARGS; } /* The first thing to do is set the result to unavailable. This will prevent future page decoding. */ ma_atomic_exchange_i32(&pDataStream->result, MA_UNAVAILABLE); /* We need to post a job to ensure we're not in the middle or decoding or anything. Because the object is owned by the caller, we'll need to wait for it to complete before returning which means we need an event. */ ma_resource_manager_inline_notification_init(pDataStream->pResourceManager, &freeEvent); job = ma_job_init(MA_JOB_TYPE_RESOURCE_MANAGER_FREE_DATA_STREAM); job.order = ma_resource_manager_data_stream_next_execution_order(pDataStream); job.data.resourceManager.freeDataStream.pDataStream = pDataStream; job.data.resourceManager.freeDataStream.pDoneNotification = &freeEvent; job.data.resourceManager.freeDataStream.pDoneFence = NULL; ma_resource_manager_post_job(pDataStream->pResourceManager, &job); /* We need to wait for the job to finish processing before we return. */ ma_resource_manager_inline_notification_wait_and_uninit(&freeEvent); return MA_SUCCESS; } static ma_uint32 ma_resource_manager_data_stream_get_page_size_in_frames(ma_resource_manager_data_stream* pDataStream) { MA_ASSERT(pDataStream != NULL); MA_ASSERT(pDataStream->isDecoderInitialized == MA_TRUE); return MA_RESOURCE_MANAGER_PAGE_SIZE_IN_MILLISECONDS * (pDataStream->decoder.outputSampleRate/1000); } static void* ma_resource_manager_data_stream_get_page_data_pointer(ma_resource_manager_data_stream* pDataStream, ma_uint32 pageIndex, ma_uint32 relativeCursor) { MA_ASSERT(pDataStream != NULL); MA_ASSERT(pDataStream->isDecoderInitialized == MA_TRUE); MA_ASSERT(pageIndex == 0 || pageIndex == 1); return ma_offset_ptr(pDataStream->pPageData, ((ma_resource_manager_data_stream_get_page_size_in_frames(pDataStream) * pageIndex) + relativeCursor) * ma_get_bytes_per_frame(pDataStream->decoder.outputFormat, pDataStream->decoder.outputChannels)); } static void ma_resource_manager_data_stream_fill_page(ma_resource_manager_data_stream* pDataStream, ma_uint32 pageIndex) { ma_result result = MA_SUCCESS; ma_uint64 pageSizeInFrames; ma_uint64 totalFramesReadForThisPage = 0; void* pPageData = ma_resource_manager_data_stream_get_page_data_pointer(pDataStream, pageIndex, 0); pageSizeInFrames = ma_resource_manager_data_stream_get_page_size_in_frames(pDataStream); /* The decoder needs to inherit the stream's looping and range state. */ { ma_uint64 rangeBeg; ma_uint64 rangeEnd; ma_uint64 loopPointBeg; ma_uint64 loopPointEnd; ma_data_source_set_looping(&pDataStream->decoder, ma_resource_manager_data_stream_is_looping(pDataStream)); ma_data_source_get_range_in_pcm_frames(pDataStream, &rangeBeg, &rangeEnd); ma_data_source_set_range_in_pcm_frames(&pDataStream->decoder, rangeBeg, rangeEnd); ma_data_source_get_loop_point_in_pcm_frames(pDataStream, &loopPointBeg, &loopPointEnd); ma_data_source_set_loop_point_in_pcm_frames(&pDataStream->decoder, loopPointBeg, loopPointEnd); } /* Just read straight from the decoder. It will deal with ranges and looping for us. */ result = ma_data_source_read_pcm_frames(&pDataStream->decoder, pPageData, pageSizeInFrames, &totalFramesReadForThisPage); if (result == MA_AT_END || totalFramesReadForThisPage < pageSizeInFrames) { ma_atomic_exchange_32(&pDataStream->isDecoderAtEnd, MA_TRUE); } ma_atomic_exchange_32(&pDataStream->pageFrameCount[pageIndex], (ma_uint32)totalFramesReadForThisPage); ma_atomic_exchange_32(&pDataStream->isPageValid[pageIndex], MA_TRUE); } static void ma_resource_manager_data_stream_fill_pages(ma_resource_manager_data_stream* pDataStream) { ma_uint32 iPage; MA_ASSERT(pDataStream != NULL); for (iPage = 0; iPage < 2; iPage += 1) { ma_resource_manager_data_stream_fill_page(pDataStream, iPage); } } static ma_result ma_resource_manager_data_stream_map(ma_resource_manager_data_stream* pDataStream, void** ppFramesOut, ma_uint64* pFrameCount) { ma_uint64 framesAvailable; ma_uint64 frameCount = 0; /* We cannot be using the data source after it's been uninitialized. */ MA_ASSERT(ma_resource_manager_data_stream_result(pDataStream) != MA_UNAVAILABLE); if (pFrameCount != NULL) { frameCount = *pFrameCount; *pFrameCount = 0; } if (ppFramesOut != NULL) { *ppFramesOut = NULL; } if (pDataStream == NULL || ppFramesOut == NULL || pFrameCount == NULL) { return MA_INVALID_ARGS; } if (ma_resource_manager_data_stream_result(pDataStream) != MA_SUCCESS) { return MA_INVALID_OPERATION; } /* Don't attempt to read while we're in the middle of seeking. Tell the caller that we're busy. */ if (ma_resource_manager_data_stream_seek_counter(pDataStream) > 0) { return MA_BUSY; } /* If the page we're on is invalid it means we've caught up to the job thread. */ if (ma_atomic_load_32(&pDataStream->isPageValid[pDataStream->currentPageIndex]) == MA_FALSE) { framesAvailable = 0; } else { /* The page we're on is valid so we must have some frames available. We need to make sure that we don't overflow into the next page, even if it's valid. The reason is that the unmap process will only post an update for one page at a time. Keeping mapping tied to page boundaries makes this simpler. */ ma_uint32 currentPageFrameCount = ma_atomic_load_32(&pDataStream->pageFrameCount[pDataStream->currentPageIndex]); MA_ASSERT(currentPageFrameCount >= pDataStream->relativeCursor); framesAvailable = currentPageFrameCount - pDataStream->relativeCursor; } /* If there's no frames available and the result is set to MA_AT_END we need to return MA_AT_END. */ if (framesAvailable == 0) { if (ma_resource_manager_data_stream_is_decoder_at_end(pDataStream)) { return MA_AT_END; } else { return MA_BUSY; /* There are no frames available, but we're not marked as EOF so we might have caught up to the job thread. Need to return MA_BUSY and wait for more data. */ } } MA_ASSERT(framesAvailable > 0); if (frameCount > framesAvailable) { frameCount = framesAvailable; } *ppFramesOut = ma_resource_manager_data_stream_get_page_data_pointer(pDataStream, pDataStream->currentPageIndex, pDataStream->relativeCursor); *pFrameCount = frameCount; return MA_SUCCESS; } static ma_result ma_resource_manager_data_stream_unmap(ma_resource_manager_data_stream* pDataStream, ma_uint64 frameCount) { ma_uint32 newRelativeCursor; ma_uint32 pageSizeInFrames; ma_job job; /* We cannot be using the data source after it's been uninitialized. */ MA_ASSERT(ma_resource_manager_data_stream_result(pDataStream) != MA_UNAVAILABLE); if (pDataStream == NULL) { return MA_INVALID_ARGS; } if (ma_resource_manager_data_stream_result(pDataStream) != MA_SUCCESS) { return MA_INVALID_OPERATION; } /* The frame count should always fit inside a 32-bit integer. */ if (frameCount > 0xFFFFFFFF) { return MA_INVALID_ARGS; } pageSizeInFrames = ma_resource_manager_data_stream_get_page_size_in_frames(pDataStream); /* The absolute cursor needs to be updated for ma_resource_manager_data_stream_get_cursor_in_pcm_frames(). */ ma_resource_manager_data_stream_set_absolute_cursor(pDataStream, ma_atomic_load_64(&pDataStream->absoluteCursor) + frameCount); /* Here is where we need to check if we need to load a new page, and if so, post a job to load it. */ newRelativeCursor = pDataStream->relativeCursor + (ma_uint32)frameCount; /* If the new cursor has flowed over to the next page we need to mark the old one as invalid and post an event for it. */ if (newRelativeCursor >= pageSizeInFrames) { newRelativeCursor -= pageSizeInFrames; /* Here is where we post the job start decoding. */ job = ma_job_init(MA_JOB_TYPE_RESOURCE_MANAGER_PAGE_DATA_STREAM); job.order = ma_resource_manager_data_stream_next_execution_order(pDataStream); job.data.resourceManager.pageDataStream.pDataStream = pDataStream; job.data.resourceManager.pageDataStream.pageIndex = pDataStream->currentPageIndex; /* The page needs to be marked as invalid so that the public API doesn't try reading from it. */ ma_atomic_exchange_32(&pDataStream->isPageValid[pDataStream->currentPageIndex], MA_FALSE); /* Before posting the job we need to make sure we set some state. */ pDataStream->relativeCursor = newRelativeCursor; pDataStream->currentPageIndex = (pDataStream->currentPageIndex + 1) & 0x01; return ma_resource_manager_post_job(pDataStream->pResourceManager, &job); } else { /* We haven't moved into a new page so we can just move the cursor forward. */ pDataStream->relativeCursor = newRelativeCursor; return MA_SUCCESS; } } MA_API ma_result ma_resource_manager_data_stream_read_pcm_frames(ma_resource_manager_data_stream* pDataStream, void* pFramesOut, ma_uint64 frameCount, ma_uint64* pFramesRead) { ma_result result = MA_SUCCESS; ma_uint64 totalFramesProcessed; ma_format format; ma_uint32 channels; /* Safety. */ if (pFramesRead != NULL) { *pFramesRead = 0; } if (frameCount == 0) { return MA_INVALID_ARGS; } /* We cannot be using the data source after it's been uninitialized. */ MA_ASSERT(ma_resource_manager_data_stream_result(pDataStream) != MA_UNAVAILABLE); if (pDataStream == NULL) { return MA_INVALID_ARGS; } if (ma_resource_manager_data_stream_result(pDataStream) != MA_SUCCESS) { return MA_INVALID_OPERATION; } /* Don't attempt to read while we're in the middle of seeking. Tell the caller that we're busy. */ if (ma_resource_manager_data_stream_seek_counter(pDataStream) > 0) { return MA_BUSY; } ma_resource_manager_data_stream_get_data_format(pDataStream, &format, &channels, NULL, NULL, 0); /* Reading is implemented in terms of map/unmap. We need to run this in a loop because mapping is clamped against page boundaries. */ totalFramesProcessed = 0; while (totalFramesProcessed < frameCount) { void* pMappedFrames; ma_uint64 mappedFrameCount; mappedFrameCount = frameCount - totalFramesProcessed; result = ma_resource_manager_data_stream_map(pDataStream, &pMappedFrames, &mappedFrameCount); if (result != MA_SUCCESS) { break; } /* Copy the mapped data to the output buffer if we have one. It's allowed for pFramesOut to be NULL in which case a relative forward seek is performed. */ if (pFramesOut != NULL) { ma_copy_pcm_frames(ma_offset_pcm_frames_ptr(pFramesOut, totalFramesProcessed, format, channels), pMappedFrames, mappedFrameCount, format, channels); } totalFramesProcessed += mappedFrameCount; result = ma_resource_manager_data_stream_unmap(pDataStream, mappedFrameCount); if (result != MA_SUCCESS) { break; /* This is really bad - will only get an error here if we failed to post a job to the queue for loading the next page. */ } } if (pFramesRead != NULL) { *pFramesRead = totalFramesProcessed; } if (result == MA_SUCCESS && totalFramesProcessed == 0) { result = MA_AT_END; } return result; } MA_API ma_result ma_resource_manager_data_stream_seek_to_pcm_frame(ma_resource_manager_data_stream* pDataStream, ma_uint64 frameIndex) { ma_job job; ma_result streamResult; streamResult = ma_resource_manager_data_stream_result(pDataStream); /* We cannot be using the data source after it's been uninitialized. */ MA_ASSERT(streamResult != MA_UNAVAILABLE); if (pDataStream == NULL) { return MA_INVALID_ARGS; } if (streamResult != MA_SUCCESS && streamResult != MA_BUSY) { return MA_INVALID_OPERATION; } /* If we're not already seeking and we're sitting on the same frame, just make this a no-op. */ if (ma_atomic_load_32(&pDataStream->seekCounter) == 0) { if (ma_atomic_load_64(&pDataStream->absoluteCursor) == frameIndex) { return MA_SUCCESS; } } /* Increment the seek counter first to indicate to read_paged_pcm_frames() and map_paged_pcm_frames() that we are in the middle of a seek and MA_BUSY should be returned. */ ma_atomic_fetch_add_32(&pDataStream->seekCounter, 1); /* Update the absolute cursor so that ma_resource_manager_data_stream_get_cursor_in_pcm_frames() returns the new position. */ ma_resource_manager_data_stream_set_absolute_cursor(pDataStream, frameIndex); /* We need to clear our currently loaded pages so that the stream starts playback from the new seek point as soon as possible. These are for the purpose of the public API and will be ignored by the seek job. The seek job will operate on the assumption that both pages have been marked as invalid and the cursor is at the start of the first page. */ pDataStream->relativeCursor = 0; pDataStream->currentPageIndex = 0; ma_atomic_exchange_32(&pDataStream->isPageValid[0], MA_FALSE); ma_atomic_exchange_32(&pDataStream->isPageValid[1], MA_FALSE); /* Make sure the data stream is not marked as at the end or else if we seek in response to hitting the end, we won't be able to read any more data. */ ma_atomic_exchange_32(&pDataStream->isDecoderAtEnd, MA_FALSE); /* The public API is not allowed to touch the internal decoder so we need to use a job to perform the seek. When seeking, the job thread will assume both pages are invalid and any content contained within them will be discarded and replaced with newly decoded data. */ job = ma_job_init(MA_JOB_TYPE_RESOURCE_MANAGER_SEEK_DATA_STREAM); job.order = ma_resource_manager_data_stream_next_execution_order(pDataStream); job.data.resourceManager.seekDataStream.pDataStream = pDataStream; job.data.resourceManager.seekDataStream.frameIndex = frameIndex; return ma_resource_manager_post_job(pDataStream->pResourceManager, &job); } MA_API ma_result ma_resource_manager_data_stream_get_data_format(ma_resource_manager_data_stream* pDataStream, ma_format* pFormat, ma_uint32* pChannels, ma_uint32* pSampleRate, ma_channel* pChannelMap, size_t channelMapCap) { /* We cannot be using the data source after it's been uninitialized. */ MA_ASSERT(ma_resource_manager_data_stream_result(pDataStream) != MA_UNAVAILABLE); if (pFormat != NULL) { *pFormat = ma_format_unknown; } if (pChannels != NULL) { *pChannels = 0; } if (pSampleRate != NULL) { *pSampleRate = 0; } if (pChannelMap != NULL) { MA_ZERO_MEMORY(pChannelMap, sizeof(*pChannelMap) * channelMapCap); } if (pDataStream == NULL) { return MA_INVALID_ARGS; } if (ma_resource_manager_data_stream_result(pDataStream) != MA_SUCCESS) { return MA_INVALID_OPERATION; } /* We're being a little bit naughty here and accessing the internal decoder from the public API. The output data format is constant, and we've defined this function such that the application is responsible for ensuring it's not called while uninitializing so it should be safe. */ return ma_data_source_get_data_format(&pDataStream->decoder, pFormat, pChannels, pSampleRate, pChannelMap, channelMapCap); } MA_API ma_result ma_resource_manager_data_stream_get_cursor_in_pcm_frames(ma_resource_manager_data_stream* pDataStream, ma_uint64* pCursor) { ma_result result; if (pCursor == NULL) { return MA_INVALID_ARGS; } *pCursor = 0; /* We cannot be using the data source after it's been uninitialized. */ MA_ASSERT(ma_resource_manager_data_stream_result(pDataStream) != MA_UNAVAILABLE); if (pDataStream == NULL) { return MA_INVALID_ARGS; } /* If the stream is in an erroneous state we need to return an invalid operation. We can allow this to be called when the data stream is in a busy state because the caller may have asked for an initial seek position and it's convenient to return that as the cursor position. */ result = ma_resource_manager_data_stream_result(pDataStream); if (result != MA_SUCCESS && result != MA_BUSY) { return MA_INVALID_OPERATION; } *pCursor = ma_atomic_load_64(&pDataStream->absoluteCursor); return MA_SUCCESS; } MA_API ma_result ma_resource_manager_data_stream_get_length_in_pcm_frames(ma_resource_manager_data_stream* pDataStream, ma_uint64* pLength) { ma_result streamResult; if (pLength == NULL) { return MA_INVALID_ARGS; } *pLength = 0; streamResult = ma_resource_manager_data_stream_result(pDataStream); /* We cannot be using the data source after it's been uninitialized. */ MA_ASSERT(streamResult != MA_UNAVAILABLE); if (pDataStream == NULL) { return MA_INVALID_ARGS; } if (streamResult != MA_SUCCESS) { return streamResult; } /* We most definitely do not want to be calling ma_decoder_get_length_in_pcm_frames() directly. Instead we want to use a cached value that we calculated when we initialized it on the job thread. */ *pLength = pDataStream->totalLengthInPCMFrames; if (*pLength == 0) { return MA_NOT_IMPLEMENTED; /* Some decoders may not have a known length. */ } return MA_SUCCESS; } MA_API ma_result ma_resource_manager_data_stream_result(const ma_resource_manager_data_stream* pDataStream) { if (pDataStream == NULL) { return MA_INVALID_ARGS; } return (ma_result)ma_atomic_load_i32(&pDataStream->result); } MA_API ma_result ma_resource_manager_data_stream_set_looping(ma_resource_manager_data_stream* pDataStream, ma_bool32 isLooping) { return ma_data_source_set_looping(pDataStream, isLooping); } MA_API ma_bool32 ma_resource_manager_data_stream_is_looping(const ma_resource_manager_data_stream* pDataStream) { if (pDataStream == NULL) { return MA_FALSE; } return ma_atomic_load_32((ma_bool32*)&pDataStream->isLooping); /* Naughty const-cast. Value won't change from here in practice (maybe from another thread). */ } MA_API ma_result ma_resource_manager_data_stream_get_available_frames(ma_resource_manager_data_stream* pDataStream, ma_uint64* pAvailableFrames) { ma_uint32 pageIndex0; ma_uint32 pageIndex1; ma_uint32 relativeCursor; ma_uint64 availableFrames; if (pAvailableFrames == NULL) { return MA_INVALID_ARGS; } *pAvailableFrames = 0; if (pDataStream == NULL) { return MA_INVALID_ARGS; } pageIndex0 = pDataStream->currentPageIndex; pageIndex1 = (pDataStream->currentPageIndex + 1) & 0x01; relativeCursor = pDataStream->relativeCursor; availableFrames = 0; if (ma_atomic_load_32(&pDataStream->isPageValid[pageIndex0])) { availableFrames += ma_atomic_load_32(&pDataStream->pageFrameCount[pageIndex0]) - relativeCursor; if (ma_atomic_load_32(&pDataStream->isPageValid[pageIndex1])) { availableFrames += ma_atomic_load_32(&pDataStream->pageFrameCount[pageIndex1]); } } *pAvailableFrames = availableFrames; return MA_SUCCESS; } static ma_result ma_resource_manager_data_source_preinit(ma_resource_manager* pResourceManager, const ma_resource_manager_data_source_config* pConfig, ma_resource_manager_data_source* pDataSource) { if (pDataSource == NULL) { return MA_INVALID_ARGS; } MA_ZERO_OBJECT(pDataSource); if (pConfig == NULL) { return MA_INVALID_ARGS; } if (pResourceManager == NULL) { return MA_INVALID_ARGS; } pDataSource->flags = pConfig->flags; return MA_SUCCESS; } MA_API ma_result ma_resource_manager_data_source_init_ex(ma_resource_manager* pResourceManager, const ma_resource_manager_data_source_config* pConfig, ma_resource_manager_data_source* pDataSource) { ma_result result; result = ma_resource_manager_data_source_preinit(pResourceManager, pConfig, pDataSource); if (result != MA_SUCCESS) { return result; } /* The data source itself is just a data stream or a data buffer. */ if ((pConfig->flags & MA_RESOURCE_MANAGER_DATA_SOURCE_FLAG_STREAM) != 0) { return ma_resource_manager_data_stream_init_ex(pResourceManager, pConfig, &pDataSource->backend.stream); } else { return ma_resource_manager_data_buffer_init_ex(pResourceManager, pConfig, &pDataSource->backend.buffer); } } MA_API ma_result ma_resource_manager_data_source_init(ma_resource_manager* pResourceManager, const char* pName, ma_uint32 flags, const ma_resource_manager_pipeline_notifications* pNotifications, ma_resource_manager_data_source* pDataSource) { ma_resource_manager_data_source_config config; config = ma_resource_manager_data_source_config_init(); config.pFilePath = pName; config.flags = flags; config.pNotifications = pNotifications; return ma_resource_manager_data_source_init_ex(pResourceManager, &config, pDataSource); } MA_API ma_result ma_resource_manager_data_source_init_w(ma_resource_manager* pResourceManager, const wchar_t* pName, ma_uint32 flags, const ma_resource_manager_pipeline_notifications* pNotifications, ma_resource_manager_data_source* pDataSource) { ma_resource_manager_data_source_config config; config = ma_resource_manager_data_source_config_init(); config.pFilePathW = pName; config.flags = flags; config.pNotifications = pNotifications; return ma_resource_manager_data_source_init_ex(pResourceManager, &config, pDataSource); } MA_API ma_result ma_resource_manager_data_source_init_copy(ma_resource_manager* pResourceManager, const ma_resource_manager_data_source* pExistingDataSource, ma_resource_manager_data_source* pDataSource) { ma_result result; ma_resource_manager_data_source_config config; if (pExistingDataSource == NULL) { return MA_INVALID_ARGS; } config = ma_resource_manager_data_source_config_init(); config.flags = pExistingDataSource->flags; result = ma_resource_manager_data_source_preinit(pResourceManager, &config, pDataSource); if (result != MA_SUCCESS) { return result; } /* Copying can only be done from data buffers. Streams cannot be copied. */ if ((pExistingDataSource->flags & MA_RESOURCE_MANAGER_DATA_SOURCE_FLAG_STREAM) != 0) { return MA_INVALID_OPERATION; } return ma_resource_manager_data_buffer_init_copy(pResourceManager, &pExistingDataSource->backend.buffer, &pDataSource->backend.buffer); } MA_API ma_result ma_resource_manager_data_source_uninit(ma_resource_manager_data_source* pDataSource) { if (pDataSource == NULL) { return MA_INVALID_ARGS; } /* All we need to is uninitialize the underlying data buffer or data stream. */ if ((pDataSource->flags & MA_RESOURCE_MANAGER_DATA_SOURCE_FLAG_STREAM) != 0) { return ma_resource_manager_data_stream_uninit(&pDataSource->backend.stream); } else { return ma_resource_manager_data_buffer_uninit(&pDataSource->backend.buffer); } } MA_API ma_result ma_resource_manager_data_source_read_pcm_frames(ma_resource_manager_data_source* pDataSource, void* pFramesOut, ma_uint64 frameCount, ma_uint64* pFramesRead) { /* Safety. */ if (pFramesRead != NULL) { *pFramesRead = 0; } if (pDataSource == NULL) { return MA_INVALID_ARGS; } if ((pDataSource->flags & MA_RESOURCE_MANAGER_DATA_SOURCE_FLAG_STREAM) != 0) { return ma_resource_manager_data_stream_read_pcm_frames(&pDataSource->backend.stream, pFramesOut, frameCount, pFramesRead); } else { return ma_resource_manager_data_buffer_read_pcm_frames(&pDataSource->backend.buffer, pFramesOut, frameCount, pFramesRead); } } MA_API ma_result ma_resource_manager_data_source_seek_to_pcm_frame(ma_resource_manager_data_source* pDataSource, ma_uint64 frameIndex) { if (pDataSource == NULL) { return MA_INVALID_ARGS; } if ((pDataSource->flags & MA_RESOURCE_MANAGER_DATA_SOURCE_FLAG_STREAM) != 0) { return ma_resource_manager_data_stream_seek_to_pcm_frame(&pDataSource->backend.stream, frameIndex); } else { return ma_resource_manager_data_buffer_seek_to_pcm_frame(&pDataSource->backend.buffer, frameIndex); } } MA_API ma_result ma_resource_manager_data_source_map(ma_resource_manager_data_source* pDataSource, void** ppFramesOut, ma_uint64* pFrameCount) { if (pDataSource == NULL) { return MA_INVALID_ARGS; } if ((pDataSource->flags & MA_RESOURCE_MANAGER_DATA_SOURCE_FLAG_STREAM) != 0) { return ma_resource_manager_data_stream_map(&pDataSource->backend.stream, ppFramesOut, pFrameCount); } else { return MA_NOT_IMPLEMENTED; /* Mapping not supported with data buffers. */ } } MA_API ma_result ma_resource_manager_data_source_unmap(ma_resource_manager_data_source* pDataSource, ma_uint64 frameCount) { if (pDataSource == NULL) { return MA_INVALID_ARGS; } if ((pDataSource->flags & MA_RESOURCE_MANAGER_DATA_SOURCE_FLAG_STREAM) != 0) { return ma_resource_manager_data_stream_unmap(&pDataSource->backend.stream, frameCount); } else { return MA_NOT_IMPLEMENTED; /* Mapping not supported with data buffers. */ } } MA_API ma_result ma_resource_manager_data_source_get_data_format(ma_resource_manager_data_source* pDataSource, ma_format* pFormat, ma_uint32* pChannels, ma_uint32* pSampleRate, ma_channel* pChannelMap, size_t channelMapCap) { if (pDataSource == NULL) { return MA_INVALID_ARGS; } if ((pDataSource->flags & MA_RESOURCE_MANAGER_DATA_SOURCE_FLAG_STREAM) != 0) { return ma_resource_manager_data_stream_get_data_format(&pDataSource->backend.stream, pFormat, pChannels, pSampleRate, pChannelMap, channelMapCap); } else { return ma_resource_manager_data_buffer_get_data_format(&pDataSource->backend.buffer, pFormat, pChannels, pSampleRate, pChannelMap, channelMapCap); } } MA_API ma_result ma_resource_manager_data_source_get_cursor_in_pcm_frames(ma_resource_manager_data_source* pDataSource, ma_uint64* pCursor) { if (pDataSource == NULL) { return MA_INVALID_ARGS; } if ((pDataSource->flags & MA_RESOURCE_MANAGER_DATA_SOURCE_FLAG_STREAM) != 0) { return ma_resource_manager_data_stream_get_cursor_in_pcm_frames(&pDataSource->backend.stream, pCursor); } else { return ma_resource_manager_data_buffer_get_cursor_in_pcm_frames(&pDataSource->backend.buffer, pCursor); } } MA_API ma_result ma_resource_manager_data_source_get_length_in_pcm_frames(ma_resource_manager_data_source* pDataSource, ma_uint64* pLength) { if (pDataSource == NULL) { return MA_INVALID_ARGS; } if ((pDataSource->flags & MA_RESOURCE_MANAGER_DATA_SOURCE_FLAG_STREAM) != 0) { return ma_resource_manager_data_stream_get_length_in_pcm_frames(&pDataSource->backend.stream, pLength); } else { return ma_resource_manager_data_buffer_get_length_in_pcm_frames(&pDataSource->backend.buffer, pLength); } } MA_API ma_result ma_resource_manager_data_source_result(const ma_resource_manager_data_source* pDataSource) { if (pDataSource == NULL) { return MA_INVALID_ARGS; } if ((pDataSource->flags & MA_RESOURCE_MANAGER_DATA_SOURCE_FLAG_STREAM) != 0) { return ma_resource_manager_data_stream_result(&pDataSource->backend.stream); } else { return ma_resource_manager_data_buffer_result(&pDataSource->backend.buffer); } } MA_API ma_result ma_resource_manager_data_source_set_looping(ma_resource_manager_data_source* pDataSource, ma_bool32 isLooping) { if (pDataSource == NULL) { return MA_INVALID_ARGS; } if ((pDataSource->flags & MA_RESOURCE_MANAGER_DATA_SOURCE_FLAG_STREAM) != 0) { return ma_resource_manager_data_stream_set_looping(&pDataSource->backend.stream, isLooping); } else { return ma_resource_manager_data_buffer_set_looping(&pDataSource->backend.buffer, isLooping); } } MA_API ma_bool32 ma_resource_manager_data_source_is_looping(const ma_resource_manager_data_source* pDataSource) { if (pDataSource == NULL) { return MA_FALSE; } if ((pDataSource->flags & MA_RESOURCE_MANAGER_DATA_SOURCE_FLAG_STREAM) != 0) { return ma_resource_manager_data_stream_is_looping(&pDataSource->backend.stream); } else { return ma_resource_manager_data_buffer_is_looping(&pDataSource->backend.buffer); } } MA_API ma_result ma_resource_manager_data_source_get_available_frames(ma_resource_manager_data_source* pDataSource, ma_uint64* pAvailableFrames) { if (pAvailableFrames == NULL) { return MA_INVALID_ARGS; } *pAvailableFrames = 0; if (pDataSource == NULL) { return MA_INVALID_ARGS; } if ((pDataSource->flags & MA_RESOURCE_MANAGER_DATA_SOURCE_FLAG_STREAM) != 0) { return ma_resource_manager_data_stream_get_available_frames(&pDataSource->backend.stream, pAvailableFrames); } else { return ma_resource_manager_data_buffer_get_available_frames(&pDataSource->backend.buffer, pAvailableFrames); } } MA_API ma_result ma_resource_manager_post_job(ma_resource_manager* pResourceManager, const ma_job* pJob) { if (pResourceManager == NULL) { return MA_INVALID_ARGS; } return ma_job_queue_post(&pResourceManager->jobQueue, pJob); } MA_API ma_result ma_resource_manager_post_job_quit(ma_resource_manager* pResourceManager) { ma_job job = ma_job_init(MA_JOB_TYPE_QUIT); return ma_resource_manager_post_job(pResourceManager, &job); } MA_API ma_result ma_resource_manager_next_job(ma_resource_manager* pResourceManager, ma_job* pJob) { if (pResourceManager == NULL) { return MA_INVALID_ARGS; } return ma_job_queue_next(&pResourceManager->jobQueue, pJob); } static ma_result ma_job_process__resource_manager__load_data_buffer_node(ma_job* pJob) { ma_result result = MA_SUCCESS; ma_resource_manager* pResourceManager; ma_resource_manager_data_buffer_node* pDataBufferNode; MA_ASSERT(pJob != NULL); pResourceManager = (ma_resource_manager*)pJob->data.resourceManager.loadDataBufferNode.pResourceManager; MA_ASSERT(pResourceManager != NULL); pDataBufferNode = (ma_resource_manager_data_buffer_node*)pJob->data.resourceManager.loadDataBufferNode.pDataBufferNode; MA_ASSERT(pDataBufferNode != NULL); MA_ASSERT(pDataBufferNode->isDataOwnedByResourceManager == MA_TRUE); /* The data should always be owned by the resource manager. */ /* The data buffer is not getting deleted, but we may be getting executed out of order. If so, we need to push the job back onto the queue and return. */ if (pJob->order != ma_atomic_load_32(&pDataBufferNode->executionPointer)) { return ma_resource_manager_post_job(pResourceManager, pJob); /* Attempting to execute out of order. Probably interleaved with a MA_JOB_TYPE_RESOURCE_MANAGER_FREE_DATA_BUFFER job. */ } /* First thing we need to do is check whether or not the data buffer is getting deleted. If so we just abort. */ if (ma_resource_manager_data_buffer_node_result(pDataBufferNode) != MA_BUSY) { result = ma_resource_manager_data_buffer_node_result(pDataBufferNode); /* The data buffer may be getting deleted before it's even been loaded. */ goto done; } /* We're ready to start loading. Essentially what we're doing here is initializing the data supply of the node. Once this is complete, data buffers can have their connectors initialized which will allow then to have audio data read from them. Note that when the data supply type has been moved away from "unknown", that is when other threads will determine that the node is available for data delivery and the data buffer connectors can be initialized. Therefore, it's important that it is set after the data supply has been initialized. */ if ((pJob->data.resourceManager.loadDataBufferNode.flags & MA_RESOURCE_MANAGER_DATA_SOURCE_FLAG_DECODE) != 0) { /* Decoding. This is the complex case because we're not going to be doing the entire decoding process here. Instead it's going to be split of multiple jobs and loaded in pages. The reason for this is to evenly distribute decoding time across multiple sounds, rather than having one huge sound hog all the available processing resources. The first thing we do is initialize a decoder. This is allocated on the heap and is passed around to the paging jobs. When the last paging job has completed it's processing, it'll free the decoder for us. This job does not do any actual decoding. It instead just posts a PAGE_DATA_BUFFER_NODE job which is where the actual decoding work will be done. However, once this job is complete, the node will be in a state where data buffer connectors can be initialized. */ ma_decoder* pDecoder; /* <-- Free'd on the last page decode. */ ma_job pageDataBufferNodeJob; /* Allocate the decoder by initializing a decoded data supply. */ result = ma_resource_manager_data_buffer_node_init_supply_decoded(pResourceManager, pDataBufferNode, pJob->data.resourceManager.loadDataBufferNode.pFilePath, pJob->data.resourceManager.loadDataBufferNode.pFilePathW, pJob->data.resourceManager.loadDataBufferNode.flags, &pDecoder); /* Don't ever propagate an MA_BUSY result code or else the resource manager will think the node is just busy decoding rather than in an error state. This should never happen, but including this logic for safety just in case. */ if (result == MA_BUSY) { result = MA_ERROR; } if (result != MA_SUCCESS) { if (pJob->data.resourceManager.loadDataBufferNode.pFilePath != NULL) { ma_log_postf(ma_resource_manager_get_log(pResourceManager), MA_LOG_LEVEL_WARNING, "Failed to initialize data supply for \"%s\". %s.\n", pJob->data.resourceManager.loadDataBufferNode.pFilePath, ma_result_description(result)); } else { #if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || defined(_MSC_VER) ma_log_postf(ma_resource_manager_get_log(pResourceManager), MA_LOG_LEVEL_WARNING, "Failed to initialize data supply for \"%ls\", %s.\n", pJob->data.resourceManager.loadDataBufferNode.pFilePathW, ma_result_description(result)); #endif } goto done; } /* At this point the node's data supply is initialized and other threads can start initializing their data buffer connectors. However, no data will actually be available until we start to actually decode it. To do this, we need to post a paging job which is where the decoding work is done. Note that if an error occurred at an earlier point, this section will have been skipped. */ pageDataBufferNodeJob = ma_job_init(MA_JOB_TYPE_RESOURCE_MANAGER_PAGE_DATA_BUFFER_NODE); pageDataBufferNodeJob.order = ma_resource_manager_data_buffer_node_next_execution_order(pDataBufferNode); pageDataBufferNodeJob.data.resourceManager.pageDataBufferNode.pResourceManager = pResourceManager; pageDataBufferNodeJob.data.resourceManager.pageDataBufferNode.pDataBufferNode = pDataBufferNode; pageDataBufferNodeJob.data.resourceManager.pageDataBufferNode.pDecoder = pDecoder; pageDataBufferNodeJob.data.resourceManager.pageDataBufferNode.pDoneNotification = pJob->data.resourceManager.loadDataBufferNode.pDoneNotification; pageDataBufferNodeJob.data.resourceManager.pageDataBufferNode.pDoneFence = pJob->data.resourceManager.loadDataBufferNode.pDoneFence; /* The job has been set up so it can now be posted. */ result = ma_resource_manager_post_job(pResourceManager, &pageDataBufferNodeJob); /* When we get here, we want to make sure the result code is set to MA_BUSY. The reason for this is that the result will be copied over to the node's internal result variable. In this case, since the decoding is still in-progress, we need to make sure the result code is set to MA_BUSY. */ if (result != MA_SUCCESS) { ma_log_postf(ma_resource_manager_get_log(pResourceManager), MA_LOG_LEVEL_ERROR, "Failed to post MA_JOB_TYPE_RESOURCE_MANAGER_PAGE_DATA_BUFFER_NODE job. %s\n", ma_result_description(result)); ma_decoder_uninit(pDecoder); ma_free(pDecoder, &pResourceManager->config.allocationCallbacks); } else { result = MA_BUSY; } } else { /* No decoding. This is the simple case. We need only read the file content into memory and we're done. */ result = ma_resource_manager_data_buffer_node_init_supply_encoded(pResourceManager, pDataBufferNode, pJob->data.resourceManager.loadDataBufferNode.pFilePath, pJob->data.resourceManager.loadDataBufferNode.pFilePathW); } done: /* File paths are no longer needed. */ ma_free(pJob->data.resourceManager.loadDataBufferNode.pFilePath, &pResourceManager->config.allocationCallbacks); ma_free(pJob->data.resourceManager.loadDataBufferNode.pFilePathW, &pResourceManager->config.allocationCallbacks); /* We need to set the result to at the very end to ensure no other threads try reading the data before we've fully initialized the object. Other threads are going to be inspecting this variable to determine whether or not they're ready to read data. We can only change the result if it's set to MA_BUSY because otherwise we may be changing away from an error code which would be bad. An example is if the application creates a data buffer, but then immediately deletes it before we've got to this point. In this case, pDataBuffer->result will be MA_UNAVAILABLE, and setting it to MA_SUCCESS or any other error code would cause the buffer to look like it's in a state that it's not. */ ma_atomic_compare_and_swap_i32(&pDataBufferNode->result, MA_BUSY, result); /* At this point initialization is complete and we can signal the notification if any. */ if (pJob->data.resourceManager.loadDataBufferNode.pInitNotification != NULL) { ma_async_notification_signal(pJob->data.resourceManager.loadDataBufferNode.pInitNotification); } if (pJob->data.resourceManager.loadDataBufferNode.pInitFence != NULL) { ma_fence_release(pJob->data.resourceManager.loadDataBufferNode.pInitFence); } /* If we have a success result it means we've fully loaded the buffer. This will happen in the non-decoding case. */ if (result != MA_BUSY) { if (pJob->data.resourceManager.loadDataBufferNode.pDoneNotification != NULL) { ma_async_notification_signal(pJob->data.resourceManager.loadDataBufferNode.pDoneNotification); } if (pJob->data.resourceManager.loadDataBufferNode.pDoneFence != NULL) { ma_fence_release(pJob->data.resourceManager.loadDataBufferNode.pDoneFence); } } /* Increment the node's execution pointer so that the next jobs can be processed. This is how we keep decoding of pages in-order. */ ma_atomic_fetch_add_32(&pDataBufferNode->executionPointer, 1); /* A busy result should be considered successful from the point of view of the job system. */ if (result == MA_BUSY) { result = MA_SUCCESS; } return result; } static ma_result ma_job_process__resource_manager__free_data_buffer_node(ma_job* pJob) { ma_resource_manager* pResourceManager; ma_resource_manager_data_buffer_node* pDataBufferNode; MA_ASSERT(pJob != NULL); pResourceManager = (ma_resource_manager*)pJob->data.resourceManager.freeDataBufferNode.pResourceManager; MA_ASSERT(pResourceManager != NULL); pDataBufferNode = (ma_resource_manager_data_buffer_node*)pJob->data.resourceManager.freeDataBufferNode.pDataBufferNode; MA_ASSERT(pDataBufferNode != NULL); if (pJob->order != ma_atomic_load_32(&pDataBufferNode->executionPointer)) { return ma_resource_manager_post_job(pResourceManager, pJob); /* Out of order. */ } ma_resource_manager_data_buffer_node_free(pResourceManager, pDataBufferNode); /* The event needs to be signalled last. */ if (pJob->data.resourceManager.freeDataBufferNode.pDoneNotification != NULL) { ma_async_notification_signal(pJob->data.resourceManager.freeDataBufferNode.pDoneNotification); } if (pJob->data.resourceManager.freeDataBufferNode.pDoneFence != NULL) { ma_fence_release(pJob->data.resourceManager.freeDataBufferNode.pDoneFence); } ma_atomic_fetch_add_32(&pDataBufferNode->executionPointer, 1); return MA_SUCCESS; } static ma_result ma_job_process__resource_manager__page_data_buffer_node(ma_job* pJob) { ma_result result = MA_SUCCESS; ma_resource_manager* pResourceManager; ma_resource_manager_data_buffer_node* pDataBufferNode; MA_ASSERT(pJob != NULL); pResourceManager = (ma_resource_manager*)pJob->data.resourceManager.pageDataBufferNode.pResourceManager; MA_ASSERT(pResourceManager != NULL); pDataBufferNode = (ma_resource_manager_data_buffer_node*)pJob->data.resourceManager.pageDataBufferNode.pDataBufferNode; MA_ASSERT(pDataBufferNode != NULL); if (pJob->order != ma_atomic_load_32(&pDataBufferNode->executionPointer)) { return ma_resource_manager_post_job(pResourceManager, pJob); /* Out of order. */ } /* Don't do any more decoding if the data buffer has started the uninitialization process. */ result = ma_resource_manager_data_buffer_node_result(pDataBufferNode); if (result != MA_BUSY) { goto done; } /* We're ready to decode the next page. */ result = ma_resource_manager_data_buffer_node_decode_next_page(pResourceManager, pDataBufferNode, (ma_decoder*)pJob->data.resourceManager.pageDataBufferNode.pDecoder); /* If we have a success code by this point, we want to post another job. We're going to set the result back to MA_BUSY to make it clear that there's still more to load. */ if (result == MA_SUCCESS) { ma_job newJob; newJob = *pJob; /* Everything is the same as the input job, except the execution order. */ newJob.order = ma_resource_manager_data_buffer_node_next_execution_order(pDataBufferNode); /* We need a fresh execution order. */ result = ma_resource_manager_post_job(pResourceManager, &newJob); /* Since the sound isn't yet fully decoded we want the status to be set to busy. */ if (result == MA_SUCCESS) { result = MA_BUSY; } } done: /* If there's still more to decode the result will be set to MA_BUSY. Otherwise we can free the decoder. */ if (result != MA_BUSY) { ma_decoder_uninit((ma_decoder*)pJob->data.resourceManager.pageDataBufferNode.pDecoder); ma_free(pJob->data.resourceManager.pageDataBufferNode.pDecoder, &pResourceManager->config.allocationCallbacks); } /* If we reached the end we need to treat it as successful. */ if (result == MA_AT_END) { result = MA_SUCCESS; } /* Make sure we set the result of node in case some error occurred. */ ma_atomic_compare_and_swap_i32(&pDataBufferNode->result, MA_BUSY, result); /* Signal the notification after setting the result in case the notification callback wants to inspect the result code. */ if (result != MA_BUSY) { if (pJob->data.resourceManager.pageDataBufferNode.pDoneNotification != NULL) { ma_async_notification_signal(pJob->data.resourceManager.pageDataBufferNode.pDoneNotification); } if (pJob->data.resourceManager.pageDataBufferNode.pDoneFence != NULL) { ma_fence_release(pJob->data.resourceManager.pageDataBufferNode.pDoneFence); } } ma_atomic_fetch_add_32(&pDataBufferNode->executionPointer, 1); return result; } static ma_result ma_job_process__resource_manager__load_data_buffer(ma_job* pJob) { ma_result result = MA_SUCCESS; ma_resource_manager* pResourceManager; ma_resource_manager_data_buffer* pDataBuffer; ma_resource_manager_data_supply_type dataSupplyType = ma_resource_manager_data_supply_type_unknown; ma_bool32 isConnectorInitialized = MA_FALSE; /* All we're doing here is checking if the node has finished loading. If not, we just re-post the job and keep waiting. Otherwise we increment the execution counter and set the buffer's result code. */ MA_ASSERT(pJob != NULL); pDataBuffer = (ma_resource_manager_data_buffer*)pJob->data.resourceManager.loadDataBuffer.pDataBuffer; MA_ASSERT(pDataBuffer != NULL); pResourceManager = pDataBuffer->pResourceManager; if (pJob->order != ma_atomic_load_32(&pDataBuffer->executionPointer)) { return ma_resource_manager_post_job(pResourceManager, pJob); /* Attempting to execute out of order. Probably interleaved with a MA_JOB_TYPE_RESOURCE_MANAGER_FREE_DATA_BUFFER job. */ } /* First thing we need to do is check whether or not the data buffer is getting deleted. If so we just abort, but making sure we increment the execution pointer. */ result = ma_resource_manager_data_buffer_result(pDataBuffer); if (result != MA_BUSY) { goto done; /* <-- This will ensure the exucution pointer is incremented. */ } else { result = MA_SUCCESS; /* <-- Make sure this is reset. */ } /* Try initializing the connector if we haven't already. */ isConnectorInitialized = ma_resource_manager_data_buffer_has_connector(pDataBuffer); if (isConnectorInitialized == MA_FALSE) { dataSupplyType = ma_resource_manager_data_buffer_node_get_data_supply_type(pDataBuffer->pNode); if (dataSupplyType != ma_resource_manager_data_supply_type_unknown) { /* We can now initialize the connector. If this fails, we need to abort. It's very rare for this to fail. */ ma_resource_manager_data_source_config dataSourceConfig; /* For setting initial looping state and range. */ dataSourceConfig = ma_resource_manager_data_source_config_init(); dataSourceConfig.rangeBegInPCMFrames = pJob->data.resourceManager.loadDataBuffer.rangeBegInPCMFrames; dataSourceConfig.rangeEndInPCMFrames = pJob->data.resourceManager.loadDataBuffer.rangeEndInPCMFrames; dataSourceConfig.loopPointBegInPCMFrames = pJob->data.resourceManager.loadDataBuffer.loopPointBegInPCMFrames; dataSourceConfig.loopPointEndInPCMFrames = pJob->data.resourceManager.loadDataBuffer.loopPointEndInPCMFrames; dataSourceConfig.isLooping = pJob->data.resourceManager.loadDataBuffer.isLooping; result = ma_resource_manager_data_buffer_init_connector(pDataBuffer, &dataSourceConfig, pJob->data.resourceManager.loadDataBuffer.pInitNotification, pJob->data.resourceManager.loadDataBuffer.pInitFence); if (result != MA_SUCCESS) { ma_log_postf(ma_resource_manager_get_log(pResourceManager), MA_LOG_LEVEL_ERROR, "Failed to initialize connector for data buffer. %s.\n", ma_result_description(result)); goto done; } } else { /* Don't have a known data supply type. Most likely the data buffer node is still loading, but it could be that an error occurred. */ } } else { /* The connector is already initialized. Nothing to do here. */ } /* If the data node is still loading, we need to repost the job and *not* increment the execution pointer (i.e. we need to not fall through to the "done" label). There is a hole between here and the where the data connector is initialized where the data buffer node may have finished initializing. We need to check for this by checking the result of the data buffer node and whether or not we had an unknown data supply type at the time of trying to initialize the data connector. */ result = ma_resource_manager_data_buffer_node_result(pDataBuffer->pNode); if (result == MA_BUSY || (result == MA_SUCCESS && isConnectorInitialized == MA_FALSE && dataSupplyType == ma_resource_manager_data_supply_type_unknown)) { return ma_resource_manager_post_job(pResourceManager, pJob); } done: /* Only move away from a busy code so that we don't trash any existing error codes. */ ma_atomic_compare_and_swap_i32(&pDataBuffer->result, MA_BUSY, result); /* Only signal the other threads after the result has been set just for cleanliness sake. */ if (pJob->data.resourceManager.loadDataBuffer.pDoneNotification != NULL) { ma_async_notification_signal(pJob->data.resourceManager.loadDataBuffer.pDoneNotification); } if (pJob->data.resourceManager.loadDataBuffer.pDoneFence != NULL) { ma_fence_release(pJob->data.resourceManager.loadDataBuffer.pDoneFence); } /* If at this point the data buffer has not had it's connector initialized, it means the notification event was never signalled which means we need to signal it here. */ if (ma_resource_manager_data_buffer_has_connector(pDataBuffer) == MA_FALSE && result != MA_SUCCESS) { if (pJob->data.resourceManager.loadDataBuffer.pInitNotification != NULL) { ma_async_notification_signal(pJob->data.resourceManager.loadDataBuffer.pInitNotification); } if (pJob->data.resourceManager.loadDataBuffer.pInitFence != NULL) { ma_fence_release(pJob->data.resourceManager.loadDataBuffer.pInitFence); } } ma_atomic_fetch_add_32(&pDataBuffer->executionPointer, 1); return result; } static ma_result ma_job_process__resource_manager__free_data_buffer(ma_job* pJob) { ma_resource_manager* pResourceManager; ma_resource_manager_data_buffer* pDataBuffer; MA_ASSERT(pJob != NULL); pDataBuffer = (ma_resource_manager_data_buffer*)pJob->data.resourceManager.freeDataBuffer.pDataBuffer; MA_ASSERT(pDataBuffer != NULL); pResourceManager = pDataBuffer->pResourceManager; if (pJob->order != ma_atomic_load_32(&pDataBuffer->executionPointer)) { return ma_resource_manager_post_job(pResourceManager, pJob); /* Out of order. */ } ma_resource_manager_data_buffer_uninit_internal(pDataBuffer); /* The event needs to be signalled last. */ if (pJob->data.resourceManager.freeDataBuffer.pDoneNotification != NULL) { ma_async_notification_signal(pJob->data.resourceManager.freeDataBuffer.pDoneNotification); } if (pJob->data.resourceManager.freeDataBuffer.pDoneFence != NULL) { ma_fence_release(pJob->data.resourceManager.freeDataBuffer.pDoneFence); } ma_atomic_fetch_add_32(&pDataBuffer->executionPointer, 1); return MA_SUCCESS; } static ma_result ma_job_process__resource_manager__load_data_stream(ma_job* pJob) { ma_result result = MA_SUCCESS; ma_decoder_config decoderConfig; ma_uint32 pageBufferSizeInBytes; ma_resource_manager* pResourceManager; ma_resource_manager_data_stream* pDataStream; MA_ASSERT(pJob != NULL); pDataStream = (ma_resource_manager_data_stream*)pJob->data.resourceManager.loadDataStream.pDataStream; MA_ASSERT(pDataStream != NULL); pResourceManager = pDataStream->pResourceManager; if (pJob->order != ma_atomic_load_32(&pDataStream->executionPointer)) { return ma_resource_manager_post_job(pResourceManager, pJob); /* Out of order. */ } if (ma_resource_manager_data_stream_result(pDataStream) != MA_BUSY) { result = MA_INVALID_OPERATION; /* Most likely the data stream is being uninitialized. */ goto done; } /* We need to initialize the decoder first so we can determine the size of the pages. */ decoderConfig = ma_resource_manager__init_decoder_config(pResourceManager); if (pJob->data.resourceManager.loadDataStream.pFilePath != NULL) { result = ma_decoder_init_vfs(pResourceManager->config.pVFS, pJob->data.resourceManager.loadDataStream.pFilePath, &decoderConfig, &pDataStream->decoder); } else { result = ma_decoder_init_vfs_w(pResourceManager->config.pVFS, pJob->data.resourceManager.loadDataStream.pFilePathW, &decoderConfig, &pDataStream->decoder); } if (result != MA_SUCCESS) { goto done; } /* Retrieve the total length of the file before marking the decoder as loaded. */ if ((pDataStream->flags & MA_RESOURCE_MANAGER_DATA_SOURCE_FLAG_UNKNOWN_LENGTH) == 0) { result = ma_decoder_get_length_in_pcm_frames(&pDataStream->decoder, &pDataStream->totalLengthInPCMFrames); if (result != MA_SUCCESS) { goto done; /* Failed to retrieve the length. */ } } else { pDataStream->totalLengthInPCMFrames = 0; } /* Only mark the decoder as initialized when the length of the decoder has been retrieved because that can possibly require a scan over the whole file and we don't want to have another thread trying to access the decoder while it's scanning. */ pDataStream->isDecoderInitialized = MA_TRUE; /* We have the decoder so we can now initialize our page buffer. */ pageBufferSizeInBytes = ma_resource_manager_data_stream_get_page_size_in_frames(pDataStream) * 2 * ma_get_bytes_per_frame(pDataStream->decoder.outputFormat, pDataStream->decoder.outputChannels); pDataStream->pPageData = ma_malloc(pageBufferSizeInBytes, &pResourceManager->config.allocationCallbacks); if (pDataStream->pPageData == NULL) { ma_decoder_uninit(&pDataStream->decoder); result = MA_OUT_OF_MEMORY; goto done; } /* Seek to our initial seek point before filling the initial pages. */ ma_decoder_seek_to_pcm_frame(&pDataStream->decoder, pJob->data.resourceManager.loadDataStream.initialSeekPoint); /* We have our decoder and our page buffer, so now we need to fill our pages. */ ma_resource_manager_data_stream_fill_pages(pDataStream); /* And now we're done. We want to make sure the result is MA_SUCCESS. */ result = MA_SUCCESS; done: ma_free(pJob->data.resourceManager.loadDataStream.pFilePath, &pResourceManager->config.allocationCallbacks); ma_free(pJob->data.resourceManager.loadDataStream.pFilePathW, &pResourceManager->config.allocationCallbacks); /* We can only change the status away from MA_BUSY. If it's set to anything else it means an error has occurred somewhere or the uninitialization process has started (most likely). */ ma_atomic_compare_and_swap_i32(&pDataStream->result, MA_BUSY, result); /* Only signal the other threads after the result has been set just for cleanliness sake. */ if (pJob->data.resourceManager.loadDataStream.pInitNotification != NULL) { ma_async_notification_signal(pJob->data.resourceManager.loadDataStream.pInitNotification); } if (pJob->data.resourceManager.loadDataStream.pInitFence != NULL) { ma_fence_release(pJob->data.resourceManager.loadDataStream.pInitFence); } ma_atomic_fetch_add_32(&pDataStream->executionPointer, 1); return result; } static ma_result ma_job_process__resource_manager__free_data_stream(ma_job* pJob) { ma_resource_manager* pResourceManager; ma_resource_manager_data_stream* pDataStream; MA_ASSERT(pJob != NULL); pDataStream = (ma_resource_manager_data_stream*)pJob->data.resourceManager.freeDataStream.pDataStream; MA_ASSERT(pDataStream != NULL); pResourceManager = pDataStream->pResourceManager; if (pJob->order != ma_atomic_load_32(&pDataStream->executionPointer)) { return ma_resource_manager_post_job(pResourceManager, pJob); /* Out of order. */ } /* If our status is not MA_UNAVAILABLE we have a bug somewhere. */ MA_ASSERT(ma_resource_manager_data_stream_result(pDataStream) == MA_UNAVAILABLE); if (pDataStream->isDecoderInitialized) { ma_decoder_uninit(&pDataStream->decoder); } if (pDataStream->pPageData != NULL) { ma_free(pDataStream->pPageData, &pResourceManager->config.allocationCallbacks); pDataStream->pPageData = NULL; /* Just in case... */ } ma_data_source_uninit(&pDataStream->ds); /* The event needs to be signalled last. */ if (pJob->data.resourceManager.freeDataStream.pDoneNotification != NULL) { ma_async_notification_signal(pJob->data.resourceManager.freeDataStream.pDoneNotification); } if (pJob->data.resourceManager.freeDataStream.pDoneFence != NULL) { ma_fence_release(pJob->data.resourceManager.freeDataStream.pDoneFence); } /*ma_atomic_fetch_add_32(&pDataStream->executionPointer, 1);*/ return MA_SUCCESS; } static ma_result ma_job_process__resource_manager__page_data_stream(ma_job* pJob) { ma_result result = MA_SUCCESS; ma_resource_manager* pResourceManager; ma_resource_manager_data_stream* pDataStream; MA_ASSERT(pJob != NULL); pDataStream = (ma_resource_manager_data_stream*)pJob->data.resourceManager.pageDataStream.pDataStream; MA_ASSERT(pDataStream != NULL); pResourceManager = pDataStream->pResourceManager; if (pJob->order != ma_atomic_load_32(&pDataStream->executionPointer)) { return ma_resource_manager_post_job(pResourceManager, pJob); /* Out of order. */ } /* For streams, the status should be MA_SUCCESS. */ if (ma_resource_manager_data_stream_result(pDataStream) != MA_SUCCESS) { result = MA_INVALID_OPERATION; goto done; } ma_resource_manager_data_stream_fill_page(pDataStream, pJob->data.resourceManager.pageDataStream.pageIndex); done: ma_atomic_fetch_add_32(&pDataStream->executionPointer, 1); return result; } static ma_result ma_job_process__resource_manager__seek_data_stream(ma_job* pJob) { ma_result result = MA_SUCCESS; ma_resource_manager* pResourceManager; ma_resource_manager_data_stream* pDataStream; MA_ASSERT(pJob != NULL); pDataStream = (ma_resource_manager_data_stream*)pJob->data.resourceManager.seekDataStream.pDataStream; MA_ASSERT(pDataStream != NULL); pResourceManager = pDataStream->pResourceManager; if (pJob->order != ma_atomic_load_32(&pDataStream->executionPointer)) { return ma_resource_manager_post_job(pResourceManager, pJob); /* Out of order. */ } /* For streams the status should be MA_SUCCESS for this to do anything. */ if (ma_resource_manager_data_stream_result(pDataStream) != MA_SUCCESS || pDataStream->isDecoderInitialized == MA_FALSE) { result = MA_INVALID_OPERATION; goto done; } /* With seeking we just assume both pages are invalid and the relative frame cursor at position 0. This is basically exactly the same as loading, except instead of initializing the decoder, we seek to a frame. */ ma_decoder_seek_to_pcm_frame(&pDataStream->decoder, pJob->data.resourceManager.seekDataStream.frameIndex); /* After seeking we'll need to reload the pages. */ ma_resource_manager_data_stream_fill_pages(pDataStream); /* We need to let the public API know that we're done seeking. */ ma_atomic_fetch_sub_32(&pDataStream->seekCounter, 1); done: ma_atomic_fetch_add_32(&pDataStream->executionPointer, 1); return result; } MA_API ma_result ma_resource_manager_process_job(ma_resource_manager* pResourceManager, ma_job* pJob) { if (pResourceManager == NULL || pJob == NULL) { return MA_INVALID_ARGS; } return ma_job_process(pJob); } MA_API ma_result ma_resource_manager_process_next_job(ma_resource_manager* pResourceManager) { ma_result result; ma_job job; if (pResourceManager == NULL) { return MA_INVALID_ARGS; } /* This will return MA_CANCELLED if the next job is a quit job. */ result = ma_resource_manager_next_job(pResourceManager, &job); if (result != MA_SUCCESS) { return result; } return ma_job_process(&job); } #else /* We'll get here if the resource manager is being excluded from the build. We need to define the job processing callbacks as no-ops. */ static ma_result ma_job_process__resource_manager__load_data_buffer_node(ma_job* pJob) { return ma_job_process__noop(pJob); } static ma_result ma_job_process__resource_manager__free_data_buffer_node(ma_job* pJob) { return ma_job_process__noop(pJob); } static ma_result ma_job_process__resource_manager__page_data_buffer_node(ma_job* pJob) { return ma_job_process__noop(pJob); } static ma_result ma_job_process__resource_manager__load_data_buffer(ma_job* pJob) { return ma_job_process__noop(pJob); } static ma_result ma_job_process__resource_manager__free_data_buffer(ma_job* pJob) { return ma_job_process__noop(pJob); } static ma_result ma_job_process__resource_manager__load_data_stream(ma_job* pJob) { return ma_job_process__noop(pJob); } static ma_result ma_job_process__resource_manager__free_data_stream(ma_job* pJob) { return ma_job_process__noop(pJob); } static ma_result ma_job_process__resource_manager__page_data_stream(ma_job* pJob) { return ma_job_process__noop(pJob); } static ma_result ma_job_process__resource_manager__seek_data_stream(ma_job* pJob) { return ma_job_process__noop(pJob); } #endif /* MA_NO_RESOURCE_MANAGER */ #ifndef MA_NO_NODE_GRAPH /* 10ms @ 48K = 480. Must never exceed 65535. */ #ifndef MA_DEFAULT_NODE_CACHE_CAP_IN_FRAMES_PER_BUS #define MA_DEFAULT_NODE_CACHE_CAP_IN_FRAMES_PER_BUS 480 #endif static ma_result ma_node_read_pcm_frames(ma_node* pNode, ma_uint32 outputBusIndex, float* pFramesOut, ma_uint32 frameCount, ma_uint32* pFramesRead, ma_uint64 globalTime); MA_API void ma_debug_fill_pcm_frames_with_sine_wave(float* pFramesOut, ma_uint32 frameCount, ma_format format, ma_uint32 channels, ma_uint32 sampleRate) { #ifndef MA_NO_GENERATION { ma_waveform_config waveformConfig; ma_waveform waveform; waveformConfig = ma_waveform_config_init(format, channels, sampleRate, ma_waveform_type_sine, 1.0, 400); ma_waveform_init(&waveformConfig, &waveform); ma_waveform_read_pcm_frames(&waveform, pFramesOut, frameCount, NULL); } #else { (void)pFramesOut; (void)frameCount; (void)format; (void)channels; (void)sampleRate; #if defined(MA_DEBUG_OUTPUT) { #if _MSC_VER #pragma message ("ma_debug_fill_pcm_frames_with_sine_wave() will do nothing because MA_NO_GENERATION is enabled.") #endif } #endif } #endif } MA_API ma_node_graph_config ma_node_graph_config_init(ma_uint32 channels) { ma_node_graph_config config; MA_ZERO_OBJECT(&config); config.channels = channels; config.nodeCacheCapInFrames = MA_DEFAULT_NODE_CACHE_CAP_IN_FRAMES_PER_BUS; return config; } static void ma_node_graph_set_is_reading(ma_node_graph* pNodeGraph, ma_bool32 isReading) { MA_ASSERT(pNodeGraph != NULL); ma_atomic_exchange_32(&pNodeGraph->isReading, isReading); } #if 0 static ma_bool32 ma_node_graph_is_reading(ma_node_graph* pNodeGraph) { MA_ASSERT(pNodeGraph != NULL); return ma_atomic_load_32(&pNodeGraph->isReading); } #endif static void ma_node_graph_node_process_pcm_frames(ma_node* pNode, const float** ppFramesIn, ma_uint32* pFrameCountIn, float** ppFramesOut, ma_uint32* pFrameCountOut) { ma_node_graph* pNodeGraph = (ma_node_graph*)pNode; ma_uint64 framesRead; ma_node_graph_read_pcm_frames(pNodeGraph, ppFramesOut[0], *pFrameCountOut, &framesRead); *pFrameCountOut = (ma_uint32)framesRead; /* Safe cast. */ (void)ppFramesIn; (void)pFrameCountIn; } static ma_node_vtable g_node_graph_node_vtable = { ma_node_graph_node_process_pcm_frames, NULL, /* onGetRequiredInputFrameCount */ 0, /* 0 input buses. */ 1, /* 1 output bus. */ 0 /* Flags. */ }; static void ma_node_graph_endpoint_process_pcm_frames(ma_node* pNode, const float** ppFramesIn, ma_uint32* pFrameCountIn, float** ppFramesOut, ma_uint32* pFrameCountOut) { MA_ASSERT(pNode != NULL); MA_ASSERT(ma_node_get_input_bus_count(pNode) == 1); MA_ASSERT(ma_node_get_output_bus_count(pNode) == 1); /* Input channel count needs to be the same as the output channel count. */ MA_ASSERT(ma_node_get_input_channels(pNode, 0) == ma_node_get_output_channels(pNode, 0)); /* We don't need to do anything here because it's a passthrough. */ (void)pNode; (void)ppFramesIn; (void)pFrameCountIn; (void)ppFramesOut; (void)pFrameCountOut; #if 0 /* The data has already been mixed. We just need to move it to the output buffer. */ if (ppFramesIn != NULL) { ma_copy_pcm_frames(ppFramesOut[0], ppFramesIn[0], *pFrameCountOut, ma_format_f32, ma_node_get_output_channels(pNode, 0)); } #endif } static ma_node_vtable g_node_graph_endpoint_vtable = { ma_node_graph_endpoint_process_pcm_frames, NULL, /* onGetRequiredInputFrameCount */ 1, /* 1 input bus. */ 1, /* 1 output bus. */ MA_NODE_FLAG_PASSTHROUGH /* Flags. The endpoint is a passthrough. */ }; MA_API ma_result ma_node_graph_init(const ma_node_graph_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_node_graph* pNodeGraph) { ma_result result; ma_node_config baseConfig; ma_node_config endpointConfig; if (pNodeGraph == NULL) { return MA_INVALID_ARGS; } MA_ZERO_OBJECT(pNodeGraph); pNodeGraph->nodeCacheCapInFrames = pConfig->nodeCacheCapInFrames; if (pNodeGraph->nodeCacheCapInFrames == 0) { pNodeGraph->nodeCacheCapInFrames = MA_DEFAULT_NODE_CACHE_CAP_IN_FRAMES_PER_BUS; } /* Base node so we can use the node graph as a node into another graph. */ baseConfig = ma_node_config_init(); baseConfig.vtable = &g_node_graph_node_vtable; baseConfig.pOutputChannels = &pConfig->channels; result = ma_node_init(pNodeGraph, &baseConfig, pAllocationCallbacks, &pNodeGraph->base); if (result != MA_SUCCESS) { return result; } /* Endpoint. */ endpointConfig = ma_node_config_init(); endpointConfig.vtable = &g_node_graph_endpoint_vtable; endpointConfig.pInputChannels = &pConfig->channels; endpointConfig.pOutputChannels = &pConfig->channels; result = ma_node_init(pNodeGraph, &endpointConfig, pAllocationCallbacks, &pNodeGraph->endpoint); if (result != MA_SUCCESS) { ma_node_uninit(&pNodeGraph->base, pAllocationCallbacks); return result; } return MA_SUCCESS; } MA_API void ma_node_graph_uninit(ma_node_graph* pNodeGraph, const ma_allocation_callbacks* pAllocationCallbacks) { if (pNodeGraph == NULL) { return; } ma_node_uninit(&pNodeGraph->endpoint, pAllocationCallbacks); } MA_API ma_node* ma_node_graph_get_endpoint(ma_node_graph* pNodeGraph) { if (pNodeGraph == NULL) { return NULL; } return &pNodeGraph->endpoint; } MA_API ma_result ma_node_graph_read_pcm_frames(ma_node_graph* pNodeGraph, void* pFramesOut, ma_uint64 frameCount, ma_uint64* pFramesRead) { ma_result result = MA_SUCCESS; ma_uint64 totalFramesRead; ma_uint32 channels; if (pFramesRead != NULL) { *pFramesRead = 0; /* Safety. */ } if (pNodeGraph == NULL) { return MA_INVALID_ARGS; } channels = ma_node_get_output_channels(&pNodeGraph->endpoint, 0); /* We'll be nice and try to do a full read of all frameCount frames. */ totalFramesRead = 0; while (totalFramesRead < frameCount) { ma_uint32 framesJustRead; ma_uint64 framesToRead = frameCount - totalFramesRead; if (framesToRead > 0xFFFFFFFF) { framesToRead = 0xFFFFFFFF; } ma_node_graph_set_is_reading(pNodeGraph, MA_TRUE); { result = ma_node_read_pcm_frames(&pNodeGraph->endpoint, 0, (float*)ma_offset_pcm_frames_ptr(pFramesOut, totalFramesRead, ma_format_f32, channels), (ma_uint32)framesToRead, &framesJustRead, ma_node_get_time(&pNodeGraph->endpoint)); } ma_node_graph_set_is_reading(pNodeGraph, MA_FALSE); totalFramesRead += framesJustRead; if (result != MA_SUCCESS) { break; } /* Abort if we weren't able to read any frames or else we risk getting stuck in a loop. */ if (framesJustRead == 0) { break; } } /* Let's go ahead and silence any leftover frames just for some added safety to ensure the caller doesn't try emitting garbage out of the speakers. */ if (totalFramesRead < frameCount) { ma_silence_pcm_frames(ma_offset_pcm_frames_ptr(pFramesOut, totalFramesRead, ma_format_f32, channels), (frameCount - totalFramesRead), ma_format_f32, channels); } if (pFramesRead != NULL) { *pFramesRead = totalFramesRead; } return result; } MA_API ma_uint32 ma_node_graph_get_channels(const ma_node_graph* pNodeGraph) { if (pNodeGraph == NULL) { return 0; } return ma_node_get_output_channels(&pNodeGraph->endpoint, 0); } MA_API ma_uint64 ma_node_graph_get_time(const ma_node_graph* pNodeGraph) { if (pNodeGraph == NULL) { return 0; } return ma_node_get_time(&pNodeGraph->endpoint); /* Global time is just the local time of the endpoint. */ } MA_API ma_result ma_node_graph_set_time(ma_node_graph* pNodeGraph, ma_uint64 globalTime) { if (pNodeGraph == NULL) { return MA_INVALID_ARGS; } return ma_node_set_time(&pNodeGraph->endpoint, globalTime); /* Global time is just the local time of the endpoint. */ } #define MA_NODE_OUTPUT_BUS_FLAG_HAS_READ 0x01 /* Whether or not this bus ready to read more data. Only used on nodes with multiple output buses. */ static ma_result ma_node_output_bus_init(ma_node* pNode, ma_uint32 outputBusIndex, ma_uint32 channels, ma_node_output_bus* pOutputBus) { MA_ASSERT(pOutputBus != NULL); MA_ASSERT(outputBusIndex < MA_MAX_NODE_BUS_COUNT); MA_ASSERT(outputBusIndex < ma_node_get_output_bus_count(pNode)); MA_ASSERT(channels < 256); MA_ZERO_OBJECT(pOutputBus); if (channels == 0) { return MA_INVALID_ARGS; } pOutputBus->pNode = pNode; pOutputBus->outputBusIndex = (ma_uint8)outputBusIndex; pOutputBus->channels = (ma_uint8)channels; pOutputBus->flags = MA_NODE_OUTPUT_BUS_FLAG_HAS_READ; /* <-- Important that this flag is set by default. */ pOutputBus->volume = 1; return MA_SUCCESS; } static void ma_node_output_bus_lock(ma_node_output_bus* pOutputBus) { ma_spinlock_lock(&pOutputBus->lock); } static void ma_node_output_bus_unlock(ma_node_output_bus* pOutputBus) { ma_spinlock_unlock(&pOutputBus->lock); } static ma_uint32 ma_node_output_bus_get_channels(const ma_node_output_bus* pOutputBus) { return pOutputBus->channels; } static void ma_node_output_bus_set_has_read(ma_node_output_bus* pOutputBus, ma_bool32 hasRead) { if (hasRead) { ma_atomic_fetch_or_32(&pOutputBus->flags, MA_NODE_OUTPUT_BUS_FLAG_HAS_READ); } else { ma_atomic_fetch_and_32(&pOutputBus->flags, (ma_uint32)~MA_NODE_OUTPUT_BUS_FLAG_HAS_READ); } } static ma_bool32 ma_node_output_bus_has_read(ma_node_output_bus* pOutputBus) { return (ma_atomic_load_32(&pOutputBus->flags) & MA_NODE_OUTPUT_BUS_FLAG_HAS_READ) != 0; } static void ma_node_output_bus_set_is_attached(ma_node_output_bus* pOutputBus, ma_bool32 isAttached) { ma_atomic_exchange_32(&pOutputBus->isAttached, isAttached); } static ma_bool32 ma_node_output_bus_is_attached(ma_node_output_bus* pOutputBus) { return ma_atomic_load_32(&pOutputBus->isAttached); } static ma_result ma_node_output_bus_set_volume(ma_node_output_bus* pOutputBus, float volume) { MA_ASSERT(pOutputBus != NULL); if (volume < 0.0f) { volume = 0.0f; } ma_atomic_exchange_f32(&pOutputBus->volume, volume); return MA_SUCCESS; } static float ma_node_output_bus_get_volume(const ma_node_output_bus* pOutputBus) { return ma_atomic_load_f32((float*)&pOutputBus->volume); } static ma_result ma_node_input_bus_init(ma_uint32 channels, ma_node_input_bus* pInputBus) { MA_ASSERT(pInputBus != NULL); MA_ASSERT(channels < 256); MA_ZERO_OBJECT(pInputBus); if (channels == 0) { return MA_INVALID_ARGS; } pInputBus->channels = (ma_uint8)channels; return MA_SUCCESS; } static void ma_node_input_bus_lock(ma_node_input_bus* pInputBus) { MA_ASSERT(pInputBus != NULL); ma_spinlock_lock(&pInputBus->lock); } static void ma_node_input_bus_unlock(ma_node_input_bus* pInputBus) { MA_ASSERT(pInputBus != NULL); ma_spinlock_unlock(&pInputBus->lock); } static void ma_node_input_bus_next_begin(ma_node_input_bus* pInputBus) { ma_atomic_fetch_add_32(&pInputBus->nextCounter, 1); } static void ma_node_input_bus_next_end(ma_node_input_bus* pInputBus) { ma_atomic_fetch_sub_32(&pInputBus->nextCounter, 1); } static ma_uint32 ma_node_input_bus_get_next_counter(ma_node_input_bus* pInputBus) { return ma_atomic_load_32(&pInputBus->nextCounter); } static ma_uint32 ma_node_input_bus_get_channels(const ma_node_input_bus* pInputBus) { return pInputBus->channels; } static void ma_node_input_bus_detach__no_output_bus_lock(ma_node_input_bus* pInputBus, ma_node_output_bus* pOutputBus) { MA_ASSERT(pInputBus != NULL); MA_ASSERT(pOutputBus != NULL); /* Mark the output bus as detached first. This will prevent future iterations on the audio thread from iterating this output bus. */ ma_node_output_bus_set_is_attached(pOutputBus, MA_FALSE); /* We cannot use the output bus lock here since it'll be getting used at a higher level, but we do still need to use the input bus lock since we'll be updating pointers on two different output buses. The same rules apply here as the attaching case. Although we're using a lock here, we're *not* using a lock when iterating over the list in the audio thread. We therefore need to craft this in a way such that the iteration on the audio thread doesn't break. The the first thing to do is swap out the "next" pointer of the previous output bus with the new "next" output bus. This is the operation that matters for iteration on the audio thread. After that, the previous pointer on the new "next" pointer needs to be updated, after which point the linked list will be in a good state. */ ma_node_input_bus_lock(pInputBus); { ma_node_output_bus* pOldPrev = (ma_node_output_bus*)ma_atomic_load_ptr(&pOutputBus->pPrev); ma_node_output_bus* pOldNext = (ma_node_output_bus*)ma_atomic_load_ptr(&pOutputBus->pNext); if (pOldPrev != NULL) { ma_atomic_exchange_ptr(&pOldPrev->pNext, pOldNext); /* <-- This is where the output bus is detached from the list. */ } if (pOldNext != NULL) { ma_atomic_exchange_ptr(&pOldNext->pPrev, pOldPrev); /* <-- This is required for detachment. */ } } ma_node_input_bus_unlock(pInputBus); /* At this point the output bus is detached and the linked list is completely unaware of it. Reset some data for safety. */ ma_atomic_exchange_ptr(&pOutputBus->pNext, NULL); /* Using atomic exchanges here, mainly for the benefit of analysis tools which don't always recognize spinlocks. */ ma_atomic_exchange_ptr(&pOutputBus->pPrev, NULL); /* As above. */ pOutputBus->pInputNode = NULL; pOutputBus->inputNodeInputBusIndex = 0; /* For thread-safety reasons, we don't want to be returning from this straight away. We need to wait for the audio thread to finish with the output bus. There's two things we need to wait for. The first is the part that selects the next output bus in the list, and the other is the part that reads from the output bus. Basically all we're doing is waiting for the input bus to stop referencing the output bus. We're doing this part last because we want the section above to run while the audio thread is finishing up with the output bus, just for efficiency reasons. We marked the output bus as detached right at the top of this function which is going to prevent the audio thread from iterating the output bus again. */ /* Part 1: Wait for the current iteration to complete. */ while (ma_node_input_bus_get_next_counter(pInputBus) > 0) { ma_yield(); } /* Part 2: Wait for any reads to complete. */ while (ma_atomic_load_32(&pOutputBus->refCount) > 0) { ma_yield(); } /* At this point we're done detaching and we can be guaranteed that the audio thread is not going to attempt to reference this output bus again (until attached again). */ } #if 0 /* Not used at the moment, but leaving here in case I need it later. */ static void ma_node_input_bus_detach(ma_node_input_bus* pInputBus, ma_node_output_bus* pOutputBus) { MA_ASSERT(pInputBus != NULL); MA_ASSERT(pOutputBus != NULL); ma_node_output_bus_lock(pOutputBus); { ma_node_input_bus_detach__no_output_bus_lock(pInputBus, pOutputBus); } ma_node_output_bus_unlock(pOutputBus); } #endif static void ma_node_input_bus_attach(ma_node_input_bus* pInputBus, ma_node_output_bus* pOutputBus, ma_node* pNewInputNode, ma_uint32 inputNodeInputBusIndex) { MA_ASSERT(pInputBus != NULL); MA_ASSERT(pOutputBus != NULL); ma_node_output_bus_lock(pOutputBus); { ma_node_output_bus* pOldInputNode = (ma_node_output_bus*)ma_atomic_load_ptr(&pOutputBus->pInputNode); /* Detach from any existing attachment first if necessary. */ if (pOldInputNode != NULL) { ma_node_input_bus_detach__no_output_bus_lock(pInputBus, pOutputBus); } /* At this point we can be sure the output bus is not attached to anything. The linked list in the old input bus has been updated so that pOutputBus will not get iterated again. */ pOutputBus->pInputNode = pNewInputNode; /* No need for an atomic assignment here because modification of this variable always happens within a lock. */ pOutputBus->inputNodeInputBusIndex = (ma_uint8)inputNodeInputBusIndex; /* Now we need to attach the output bus to the linked list. This involves updating two pointers on two different output buses so I'm going to go ahead and keep this simple and just use a lock. There are ways to do this without a lock, but it's just too hard to maintain for it's value. Although we're locking here, it's important to remember that we're *not* locking when iterating and reading audio data since that'll be running on the audio thread. As a result we need to be careful how we craft this so that we don't break iteration. What we're going to do is always attach the new item so that it becomes the first item in the list. That way, as we're iterating we won't break any links in the list and iteration will continue safely. The detaching case will also be crafted in a way as to not break list iteration. It's important to remember to use atomic exchanges here since no locking is happening on the audio thread during iteration. */ ma_node_input_bus_lock(pInputBus); { ma_node_output_bus* pNewPrev = &pInputBus->head; ma_node_output_bus* pNewNext = (ma_node_output_bus*)ma_atomic_load_ptr(&pInputBus->head.pNext); /* Update the local output bus. */ ma_atomic_exchange_ptr(&pOutputBus->pPrev, pNewPrev); ma_atomic_exchange_ptr(&pOutputBus->pNext, pNewNext); /* Update the other output buses to point back to the local output bus. */ ma_atomic_exchange_ptr(&pInputBus->head.pNext, pOutputBus); /* <-- This is where the output bus is actually attached to the input bus. */ /* Do the previous pointer last. This is only used for detachment. */ if (pNewNext != NULL) { ma_atomic_exchange_ptr(&pNewNext->pPrev, pOutputBus); } } ma_node_input_bus_unlock(pInputBus); /* Mark the node as attached last. This is used to controlling whether or the output bus will be iterated on the audio thread. Mainly required for detachment purposes. */ ma_node_output_bus_set_is_attached(pOutputBus, MA_TRUE); } ma_node_output_bus_unlock(pOutputBus); } static ma_node_output_bus* ma_node_input_bus_next(ma_node_input_bus* pInputBus, ma_node_output_bus* pOutputBus) { ma_node_output_bus* pNext; MA_ASSERT(pInputBus != NULL); if (pOutputBus == NULL) { return NULL; } ma_node_input_bus_next_begin(pInputBus); { pNext = pOutputBus; for (;;) { pNext = (ma_node_output_bus*)ma_atomic_load_ptr(&pNext->pNext); if (pNext == NULL) { break; /* Reached the end. */ } if (ma_node_output_bus_is_attached(pNext) == MA_FALSE) { continue; /* The node is not attached. Keep checking. */ } /* The next node has been selected. */ break; } /* We need to increment the reference count of the selected node. */ if (pNext != NULL) { ma_atomic_fetch_add_32(&pNext->refCount, 1); } /* The previous node is no longer being referenced. */ ma_atomic_fetch_sub_32(&pOutputBus->refCount, 1); } ma_node_input_bus_next_end(pInputBus); return pNext; } static ma_node_output_bus* ma_node_input_bus_first(ma_node_input_bus* pInputBus) { return ma_node_input_bus_next(pInputBus, &pInputBus->head); } static ma_result ma_node_input_bus_read_pcm_frames(ma_node* pInputNode, ma_node_input_bus* pInputBus, float* pFramesOut, ma_uint32 frameCount, ma_uint32* pFramesRead, ma_uint64 globalTime) { ma_result result = MA_SUCCESS; ma_node_output_bus* pOutputBus; ma_node_output_bus* pFirst; ma_uint32 inputChannels; ma_bool32 doesOutputBufferHaveContent = MA_FALSE; (void)pInputNode; /* Not currently used. */ /* This will be called from the audio thread which means we can't be doing any locking. Basically, this function will not perfom any locking, whereas attaching and detaching will, but crafted in such a way that we don't need to perform any locking here. The important thing to remember is to always iterate in a forward direction. In order to process any data we need to first read from all input buses. That's where this function comes in. This iterates over each of the attachments and accumulates/mixes them. We also convert the channels to the nodes output channel count before mixing. We want to do this channel conversion so that the caller of this function can invoke the processing callback without having to do it themselves. When we iterate over each of the attachments on the input bus, we need to read as much data as we can from each of them so that we don't end up with holes between each of the attachments. To do this, we need to read from each attachment in a loop and read as many frames as we can, up to `frameCount`. */ MA_ASSERT(pInputNode != NULL); MA_ASSERT(pFramesRead != NULL); /* pFramesRead is critical and must always be specified. On input it's undefined and on output it'll be set to the number of frames actually read. */ *pFramesRead = 0; /* Safety. */ inputChannels = ma_node_input_bus_get_channels(pInputBus); /* We need to be careful with how we call ma_node_input_bus_first() and ma_node_input_bus_next(). They are both critical to our lock-free thread-safety system. We can only call ma_node_input_bus_first() once per iteration, however we have an optimization to checks whether or not it's the first item in the list. We therefore need to store a pointer to the first item rather than repeatedly calling ma_node_input_bus_first(). It's safe to keep hold of this pointer, so long as we don't dereference it after calling ma_node_input_bus_next(), which we won't be. */ pFirst = ma_node_input_bus_first(pInputBus); if (pFirst == NULL) { return MA_SUCCESS; /* No attachments. Read nothing. */ } for (pOutputBus = pFirst; pOutputBus != NULL; pOutputBus = ma_node_input_bus_next(pInputBus, pOutputBus)) { ma_uint32 framesProcessed = 0; ma_bool32 isSilentOutput = MA_FALSE; MA_ASSERT(pOutputBus->pNode != NULL); MA_ASSERT(((ma_node_base*)pOutputBus->pNode)->vtable != NULL); isSilentOutput = (((ma_node_base*)pOutputBus->pNode)->vtable->flags & MA_NODE_FLAG_SILENT_OUTPUT) != 0; if (pFramesOut != NULL) { /* Read. */ float temp[MA_DATA_CONVERTER_STACK_BUFFER_SIZE / sizeof(float)]; ma_uint32 tempCapInFrames = ma_countof(temp) / inputChannels; while (framesProcessed < frameCount) { float* pRunningFramesOut; ma_uint32 framesToRead; ma_uint32 framesJustRead; framesToRead = frameCount - framesProcessed; if (framesToRead > tempCapInFrames) { framesToRead = tempCapInFrames; } pRunningFramesOut = ma_offset_pcm_frames_ptr_f32(pFramesOut, framesProcessed, inputChannels); if (doesOutputBufferHaveContent == MA_FALSE) { /* Fast path. First attachment. We just read straight into the output buffer (no mixing required). */ result = ma_node_read_pcm_frames(pOutputBus->pNode, pOutputBus->outputBusIndex, pRunningFramesOut, framesToRead, &framesJustRead, globalTime + framesProcessed); } else { /* Slow path. Not the first attachment. Mixing required. */ result = ma_node_read_pcm_frames(pOutputBus->pNode, pOutputBus->outputBusIndex, temp, framesToRead, &framesJustRead, globalTime + framesProcessed); if (result == MA_SUCCESS || result == MA_AT_END) { if (isSilentOutput == MA_FALSE) { /* Don't mix if the node outputs silence. */ ma_mix_pcm_frames_f32(pRunningFramesOut, temp, framesJustRead, inputChannels, /*volume*/1); } } } framesProcessed += framesJustRead; /* If we reached the end or otherwise failed to read any data we need to finish up with this output node. */ if (result != MA_SUCCESS) { break; } /* If we didn't read anything, abort so we don't get stuck in a loop. */ if (framesJustRead == 0) { break; } } /* If it's the first attachment we didn't do any mixing. Any leftover samples need to be silenced. */ if (pOutputBus == pFirst && framesProcessed < frameCount) { ma_silence_pcm_frames(ma_offset_pcm_frames_ptr(pFramesOut, framesProcessed, ma_format_f32, inputChannels), (frameCount - framesProcessed), ma_format_f32, inputChannels); } if (isSilentOutput == MA_FALSE) { doesOutputBufferHaveContent = MA_TRUE; } } else { /* Seek. */ ma_node_read_pcm_frames(pOutputBus->pNode, pOutputBus->outputBusIndex, NULL, frameCount, &framesProcessed, globalTime); } } /* If we didn't output anything, output silence. */ if (doesOutputBufferHaveContent == MA_FALSE && pFramesOut != NULL) { ma_silence_pcm_frames(pFramesOut, frameCount, ma_format_f32, inputChannels); } /* In this path we always "process" the entire amount. */ *pFramesRead = frameCount; return result; } MA_API ma_node_config ma_node_config_init(void) { ma_node_config config; MA_ZERO_OBJECT(&config); config.initialState = ma_node_state_started; /* Nodes are started by default. */ config.inputBusCount = MA_NODE_BUS_COUNT_UNKNOWN; config.outputBusCount = MA_NODE_BUS_COUNT_UNKNOWN; return config; } static ma_result ma_node_detach_full(ma_node* pNode); static float* ma_node_get_cached_input_ptr(ma_node* pNode, ma_uint32 inputBusIndex) { ma_node_base* pNodeBase = (ma_node_base*)pNode; ma_uint32 iInputBus; float* pBasePtr; MA_ASSERT(pNodeBase != NULL); /* Input data is stored at the front of the buffer. */ pBasePtr = pNodeBase->pCachedData; for (iInputBus = 0; iInputBus < inputBusIndex; iInputBus += 1) { pBasePtr += pNodeBase->cachedDataCapInFramesPerBus * ma_node_input_bus_get_channels(&pNodeBase->pInputBuses[iInputBus]); } return pBasePtr; } static float* ma_node_get_cached_output_ptr(ma_node* pNode, ma_uint32 outputBusIndex) { ma_node_base* pNodeBase = (ma_node_base*)pNode; ma_uint32 iInputBus; ma_uint32 iOutputBus; float* pBasePtr; MA_ASSERT(pNodeBase != NULL); /* Cached output data starts after the input data. */ pBasePtr = pNodeBase->pCachedData; for (iInputBus = 0; iInputBus < ma_node_get_input_bus_count(pNodeBase); iInputBus += 1) { pBasePtr += pNodeBase->cachedDataCapInFramesPerBus * ma_node_input_bus_get_channels(&pNodeBase->pInputBuses[iInputBus]); } for (iOutputBus = 0; iOutputBus < outputBusIndex; iOutputBus += 1) { pBasePtr += pNodeBase->cachedDataCapInFramesPerBus * ma_node_output_bus_get_channels(&pNodeBase->pOutputBuses[iOutputBus]); } return pBasePtr; } typedef struct { size_t sizeInBytes; size_t inputBusOffset; size_t outputBusOffset; size_t cachedDataOffset; ma_uint32 inputBusCount; /* So it doesn't have to be calculated twice. */ ma_uint32 outputBusCount; /* So it doesn't have to be calculated twice. */ } ma_node_heap_layout; static ma_result ma_node_translate_bus_counts(const ma_node_config* pConfig, ma_uint32* pInputBusCount, ma_uint32* pOutputBusCount) { ma_uint32 inputBusCount; ma_uint32 outputBusCount; MA_ASSERT(pConfig != NULL); MA_ASSERT(pInputBusCount != NULL); MA_ASSERT(pOutputBusCount != NULL); /* Bus counts are determined by the vtable, unless they're set to `MA_NODE_BUS_COUNT_UNKNWON`, in which case they're taken from the config. */ if (pConfig->vtable->inputBusCount == MA_NODE_BUS_COUNT_UNKNOWN) { inputBusCount = pConfig->inputBusCount; } else { inputBusCount = pConfig->vtable->inputBusCount; if (pConfig->inputBusCount != MA_NODE_BUS_COUNT_UNKNOWN && pConfig->inputBusCount != pConfig->vtable->inputBusCount) { return MA_INVALID_ARGS; /* Invalid configuration. You must not specify a conflicting bus count between the node's config and the vtable. */ } } if (pConfig->vtable->outputBusCount == MA_NODE_BUS_COUNT_UNKNOWN) { outputBusCount = pConfig->outputBusCount; } else { outputBusCount = pConfig->vtable->outputBusCount; if (pConfig->outputBusCount != MA_NODE_BUS_COUNT_UNKNOWN && pConfig->outputBusCount != pConfig->vtable->outputBusCount) { return MA_INVALID_ARGS; /* Invalid configuration. You must not specify a conflicting bus count between the node's config and the vtable. */ } } /* Bus counts must be within limits. */ if (inputBusCount > MA_MAX_NODE_BUS_COUNT || outputBusCount > MA_MAX_NODE_BUS_COUNT) { return MA_INVALID_ARGS; } /* We must have channel counts for each bus. */ if ((inputBusCount > 0 && pConfig->pInputChannels == NULL) || (outputBusCount > 0 && pConfig->pOutputChannels == NULL)) { return MA_INVALID_ARGS; /* You must specify channel counts for each input and output bus. */ } /* Some special rules for passthrough nodes. */ if ((pConfig->vtable->flags & MA_NODE_FLAG_PASSTHROUGH) != 0) { if ((pConfig->vtable->inputBusCount != 0 && pConfig->vtable->inputBusCount != 1) || pConfig->vtable->outputBusCount != 1) { return MA_INVALID_ARGS; /* Passthrough nodes must have exactly 1 output bus and either 0 or 1 input bus. */ } if (pConfig->pInputChannels[0] != pConfig->pOutputChannels[0]) { return MA_INVALID_ARGS; /* Passthrough nodes must have the same number of channels between input and output nodes. */ } } *pInputBusCount = inputBusCount; *pOutputBusCount = outputBusCount; return MA_SUCCESS; } static ma_result ma_node_get_heap_layout(ma_node_graph* pNodeGraph, const ma_node_config* pConfig, ma_node_heap_layout* pHeapLayout) { ma_result result; ma_uint32 inputBusCount; ma_uint32 outputBusCount; MA_ASSERT(pHeapLayout != NULL); MA_ZERO_OBJECT(pHeapLayout); if (pConfig == NULL || pConfig->vtable == NULL || pConfig->vtable->onProcess == NULL) { return MA_INVALID_ARGS; } result = ma_node_translate_bus_counts(pConfig, &inputBusCount, &outputBusCount); if (result != MA_SUCCESS) { return result; } pHeapLayout->sizeInBytes = 0; /* Input buses. */ if (inputBusCount > MA_MAX_NODE_LOCAL_BUS_COUNT) { pHeapLayout->inputBusOffset = pHeapLayout->sizeInBytes; pHeapLayout->sizeInBytes += ma_align_64(sizeof(ma_node_input_bus) * inputBusCount); } else { pHeapLayout->inputBusOffset = MA_SIZE_MAX; /* MA_SIZE_MAX indicates that no heap allocation is required for the input bus. */ } /* Output buses. */ if (outputBusCount > MA_MAX_NODE_LOCAL_BUS_COUNT) { pHeapLayout->outputBusOffset = pHeapLayout->sizeInBytes; pHeapLayout->sizeInBytes += ma_align_64(sizeof(ma_node_output_bus) * outputBusCount); } else { pHeapLayout->outputBusOffset = MA_SIZE_MAX; } /* Cached audio data. We need to allocate memory for a caching both input and output data. We have an optimization where no caching is necessary for specific conditions: - The node has 0 inputs and 1 output. When a node meets the above conditions, no cache is allocated. The size choice for this buffer is a little bit finicky. We don't want to be too wasteful by allocating too much, but at the same time we want it be large enough so that enough frames can be processed for each call to ma_node_read_pcm_frames() so that it keeps things efficient. For now I'm going with 10ms @ 48K which is 480 frames per bus. This is configurable at compile time. It might also be worth investigating whether or not this can be configured at run time. */ if (inputBusCount == 0 && outputBusCount == 1) { /* Fast path. No cache needed. */ pHeapLayout->cachedDataOffset = MA_SIZE_MAX; } else { /* Slow path. Cache needed. */ size_t cachedDataSizeInBytes = 0; ma_uint32 iBus; for (iBus = 0; iBus < inputBusCount; iBus += 1) { cachedDataSizeInBytes += pNodeGraph->nodeCacheCapInFrames * ma_get_bytes_per_frame(ma_format_f32, pConfig->pInputChannels[iBus]); } for (iBus = 0; iBus < outputBusCount; iBus += 1) { cachedDataSizeInBytes += pNodeGraph->nodeCacheCapInFrames * ma_get_bytes_per_frame(ma_format_f32, pConfig->pOutputChannels[iBus]); } pHeapLayout->cachedDataOffset = pHeapLayout->sizeInBytes; pHeapLayout->sizeInBytes += ma_align_64(cachedDataSizeInBytes); } /* Not technically part of the heap, but we can output the input and output bus counts so we can avoid a redundant call to ma_node_translate_bus_counts(). */ pHeapLayout->inputBusCount = inputBusCount; pHeapLayout->outputBusCount = outputBusCount; /* Make sure allocation size is aligned. */ pHeapLayout->sizeInBytes = ma_align_64(pHeapLayout->sizeInBytes); return MA_SUCCESS; } MA_API ma_result ma_node_get_heap_size(ma_node_graph* pNodeGraph, const ma_node_config* pConfig, size_t* pHeapSizeInBytes) { ma_result result; ma_node_heap_layout heapLayout; if (pHeapSizeInBytes == NULL) { return MA_INVALID_ARGS; } *pHeapSizeInBytes = 0; result = ma_node_get_heap_layout(pNodeGraph, pConfig, &heapLayout); if (result != MA_SUCCESS) { return result; } *pHeapSizeInBytes = heapLayout.sizeInBytes; return MA_SUCCESS; } MA_API ma_result ma_node_init_preallocated(ma_node_graph* pNodeGraph, const ma_node_config* pConfig, void* pHeap, ma_node* pNode) { ma_node_base* pNodeBase = (ma_node_base*)pNode; ma_result result; ma_node_heap_layout heapLayout; ma_uint32 iInputBus; ma_uint32 iOutputBus; if (pNodeBase == NULL) { return MA_INVALID_ARGS; } MA_ZERO_OBJECT(pNodeBase); result = ma_node_get_heap_layout(pNodeGraph, pConfig, &heapLayout); if (result != MA_SUCCESS) { return result; } pNodeBase->_pHeap = pHeap; MA_ZERO_MEMORY(pHeap, heapLayout.sizeInBytes); pNodeBase->pNodeGraph = pNodeGraph; pNodeBase->vtable = pConfig->vtable; pNodeBase->state = pConfig->initialState; pNodeBase->stateTimes[ma_node_state_started] = 0; pNodeBase->stateTimes[ma_node_state_stopped] = (ma_uint64)(ma_int64)-1; /* Weird casting for VC6 compatibility. */ pNodeBase->inputBusCount = heapLayout.inputBusCount; pNodeBase->outputBusCount = heapLayout.outputBusCount; if (heapLayout.inputBusOffset != MA_SIZE_MAX) { pNodeBase->pInputBuses = (ma_node_input_bus*)ma_offset_ptr(pHeap, heapLayout.inputBusOffset); } else { pNodeBase->pInputBuses = pNodeBase->_inputBuses; } if (heapLayout.outputBusOffset != MA_SIZE_MAX) { pNodeBase->pOutputBuses = (ma_node_output_bus*)ma_offset_ptr(pHeap, heapLayout.outputBusOffset); } else { pNodeBase->pOutputBuses = pNodeBase->_outputBuses; } if (heapLayout.cachedDataOffset != MA_SIZE_MAX) { pNodeBase->pCachedData = (float*)ma_offset_ptr(pHeap, heapLayout.cachedDataOffset); pNodeBase->cachedDataCapInFramesPerBus = pNodeGraph->nodeCacheCapInFrames; } else { pNodeBase->pCachedData = NULL; } /* We need to run an initialization step for each input and output bus. */ for (iInputBus = 0; iInputBus < ma_node_get_input_bus_count(pNodeBase); iInputBus += 1) { result = ma_node_input_bus_init(pConfig->pInputChannels[iInputBus], &pNodeBase->pInputBuses[iInputBus]); if (result != MA_SUCCESS) { return result; } } for (iOutputBus = 0; iOutputBus < ma_node_get_output_bus_count(pNodeBase); iOutputBus += 1) { result = ma_node_output_bus_init(pNodeBase, iOutputBus, pConfig->pOutputChannels[iOutputBus], &pNodeBase->pOutputBuses[iOutputBus]); if (result != MA_SUCCESS) { return result; } } /* The cached data needs to be initialized to silence (or a sine wave tone if we're debugging). */ if (pNodeBase->pCachedData != NULL) { ma_uint32 iBus; #if 1 /* Toggle this between 0 and 1 to turn debugging on or off. 1 = fill with a sine wave for debugging; 0 = fill with silence. */ /* For safety we'll go ahead and default the buffer to silence. */ for (iBus = 0; iBus < ma_node_get_input_bus_count(pNodeBase); iBus += 1) { ma_silence_pcm_frames(ma_node_get_cached_input_ptr(pNode, iBus), pNodeBase->cachedDataCapInFramesPerBus, ma_format_f32, ma_node_input_bus_get_channels(&pNodeBase->pInputBuses[iBus])); } for (iBus = 0; iBus < ma_node_get_output_bus_count(pNodeBase); iBus += 1) { ma_silence_pcm_frames(ma_node_get_cached_output_ptr(pNode, iBus), pNodeBase->cachedDataCapInFramesPerBus, ma_format_f32, ma_node_output_bus_get_channels(&pNodeBase->pOutputBuses[iBus])); } #else /* For debugging. Default to a sine wave. */ for (iBus = 0; iBus < ma_node_get_input_bus_count(pNodeBase); iBus += 1) { ma_debug_fill_pcm_frames_with_sine_wave(ma_node_get_cached_input_ptr(pNode, iBus), pNodeBase->cachedDataCapInFramesPerBus, ma_format_f32, ma_node_input_bus_get_channels(&pNodeBase->pInputBuses[iBus]), 48000); } for (iBus = 0; iBus < ma_node_get_output_bus_count(pNodeBase); iBus += 1) { ma_debug_fill_pcm_frames_with_sine_wave(ma_node_get_cached_output_ptr(pNode, iBus), pNodeBase->cachedDataCapInFramesPerBus, ma_format_f32, ma_node_output_bus_get_channels(&pNodeBase->pOutputBuses[iBus]), 48000); } #endif } return MA_SUCCESS; } MA_API ma_result ma_node_init(ma_node_graph* pNodeGraph, const ma_node_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_node* pNode) { ma_result result; size_t heapSizeInBytes; void* pHeap; result = ma_node_get_heap_size(pNodeGraph, pConfig, &heapSizeInBytes); if (result != MA_SUCCESS) { return result; } if (heapSizeInBytes > 0) { pHeap = ma_malloc(heapSizeInBytes, pAllocationCallbacks); if (pHeap == NULL) { return MA_OUT_OF_MEMORY; } } else { pHeap = NULL; } result = ma_node_init_preallocated(pNodeGraph, pConfig, pHeap, pNode); if (result != MA_SUCCESS) { ma_free(pHeap, pAllocationCallbacks); return result; } ((ma_node_base*)pNode)->_ownsHeap = MA_TRUE; return MA_SUCCESS; } MA_API void ma_node_uninit(ma_node* pNode, const ma_allocation_callbacks* pAllocationCallbacks) { ma_node_base* pNodeBase = (ma_node_base*)pNode; if (pNodeBase == NULL) { return; } /* The first thing we need to do is fully detach the node. This will detach all inputs and outputs. We need to do this first because it will sever the connection with the node graph and allow us to complete uninitialization without needing to worry about thread-safety with the audio thread. The detachment process will wait for any local processing of the node to finish. */ ma_node_detach_full(pNode); /* At this point the node should be completely unreferenced by the node graph and we can finish up the uninitialization process without needing to worry about thread-safety. */ if (pNodeBase->_ownsHeap) { ma_free(pNodeBase->_pHeap, pAllocationCallbacks); } } MA_API ma_node_graph* ma_node_get_node_graph(const ma_node* pNode) { if (pNode == NULL) { return NULL; } return ((const ma_node_base*)pNode)->pNodeGraph; } MA_API ma_uint32 ma_node_get_input_bus_count(const ma_node* pNode) { if (pNode == NULL) { return 0; } return ((ma_node_base*)pNode)->inputBusCount; } MA_API ma_uint32 ma_node_get_output_bus_count(const ma_node* pNode) { if (pNode == NULL) { return 0; } return ((ma_node_base*)pNode)->outputBusCount; } MA_API ma_uint32 ma_node_get_input_channels(const ma_node* pNode, ma_uint32 inputBusIndex) { const ma_node_base* pNodeBase = (const ma_node_base*)pNode; if (pNode == NULL) { return 0; } if (inputBusIndex >= ma_node_get_input_bus_count(pNode)) { return 0; /* Invalid bus index. */ } return ma_node_input_bus_get_channels(&pNodeBase->pInputBuses[inputBusIndex]); } MA_API ma_uint32 ma_node_get_output_channels(const ma_node* pNode, ma_uint32 outputBusIndex) { const ma_node_base* pNodeBase = (const ma_node_base*)pNode; if (pNode == NULL) { return 0; } if (outputBusIndex >= ma_node_get_output_bus_count(pNode)) { return 0; /* Invalid bus index. */ } return ma_node_output_bus_get_channels(&pNodeBase->pOutputBuses[outputBusIndex]); } static ma_result ma_node_detach_full(ma_node* pNode) { ma_node_base* pNodeBase = (ma_node_base*)pNode; ma_uint32 iInputBus; if (pNodeBase == NULL) { return MA_INVALID_ARGS; } /* Make sure the node is completely detached first. This will not return until the output bus is guaranteed to no longer be referenced by the audio thread. */ ma_node_detach_all_output_buses(pNode); /* At this point all output buses will have been detached from the graph and we can be guaranteed that none of it's input nodes will be getting processed by the graph. We can detach these without needing to worry about the audio thread touching them. */ for (iInputBus = 0; iInputBus < ma_node_get_input_bus_count(pNode); iInputBus += 1) { ma_node_input_bus* pInputBus; ma_node_output_bus* pOutputBus; pInputBus = &pNodeBase->pInputBuses[iInputBus]; /* This is important. We cannot be using ma_node_input_bus_first() or ma_node_input_bus_next(). Those functions are specifically for the audio thread. We'll instead just manually iterate using standard linked list logic. We don't need to worry about the audio thread referencing these because the step above severed the connection to the graph. */ for (pOutputBus = (ma_node_output_bus*)ma_atomic_load_ptr(&pInputBus->head.pNext); pOutputBus != NULL; pOutputBus = (ma_node_output_bus*)ma_atomic_load_ptr(&pOutputBus->pNext)) { ma_node_detach_output_bus(pOutputBus->pNode, pOutputBus->outputBusIndex); /* This won't do any waiting in practice and should be efficient. */ } } return MA_SUCCESS; } MA_API ma_result ma_node_detach_output_bus(ma_node* pNode, ma_uint32 outputBusIndex) { ma_result result = MA_SUCCESS; ma_node_base* pNodeBase = (ma_node_base*)pNode; ma_node_base* pInputNodeBase; if (pNode == NULL) { return MA_INVALID_ARGS; } if (outputBusIndex >= ma_node_get_output_bus_count(pNode)) { return MA_INVALID_ARGS; /* Invalid output bus index. */ } /* We need to lock the output bus because we need to inspect the input node and grab it's input bus. */ ma_node_output_bus_lock(&pNodeBase->pOutputBuses[outputBusIndex]); { pInputNodeBase = (ma_node_base*)pNodeBase->pOutputBuses[outputBusIndex].pInputNode; if (pInputNodeBase != NULL) { ma_node_input_bus_detach__no_output_bus_lock(&pInputNodeBase->pInputBuses[pNodeBase->pOutputBuses[outputBusIndex].inputNodeInputBusIndex], &pNodeBase->pOutputBuses[outputBusIndex]); } } ma_node_output_bus_unlock(&pNodeBase->pOutputBuses[outputBusIndex]); return result; } MA_API ma_result ma_node_detach_all_output_buses(ma_node* pNode) { ma_uint32 iOutputBus; if (pNode == NULL) { return MA_INVALID_ARGS; } for (iOutputBus = 0; iOutputBus < ma_node_get_output_bus_count(pNode); iOutputBus += 1) { ma_node_detach_output_bus(pNode, iOutputBus); } return MA_SUCCESS; } MA_API ma_result ma_node_attach_output_bus(ma_node* pNode, ma_uint32 outputBusIndex, ma_node* pOtherNode, ma_uint32 otherNodeInputBusIndex) { ma_node_base* pNodeBase = (ma_node_base*)pNode; ma_node_base* pOtherNodeBase = (ma_node_base*)pOtherNode; if (pNodeBase == NULL || pOtherNodeBase == NULL) { return MA_INVALID_ARGS; } if (pNodeBase == pOtherNodeBase) { return MA_INVALID_OPERATION; /* Cannot attach a node to itself. */ } if (outputBusIndex >= ma_node_get_output_bus_count(pNode) || otherNodeInputBusIndex >= ma_node_get_input_bus_count(pOtherNode)) { return MA_INVALID_OPERATION; /* Invalid bus index. */ } /* The output channel count of the output node must be the same as the input channel count of the input node. */ if (ma_node_get_output_channels(pNode, outputBusIndex) != ma_node_get_input_channels(pOtherNode, otherNodeInputBusIndex)) { return MA_INVALID_OPERATION; /* Channel count is incompatible. */ } /* This will deal with detaching if the output bus is already attached to something. */ ma_node_input_bus_attach(&pOtherNodeBase->pInputBuses[otherNodeInputBusIndex], &pNodeBase->pOutputBuses[outputBusIndex], pOtherNode, otherNodeInputBusIndex); return MA_SUCCESS; } MA_API ma_result ma_node_set_output_bus_volume(ma_node* pNode, ma_uint32 outputBusIndex, float volume) { ma_node_base* pNodeBase = (ma_node_base*)pNode; if (pNodeBase == NULL) { return MA_INVALID_ARGS; } if (outputBusIndex >= ma_node_get_output_bus_count(pNode)) { return MA_INVALID_ARGS; /* Invalid bus index. */ } return ma_node_output_bus_set_volume(&pNodeBase->pOutputBuses[outputBusIndex], volume); } MA_API float ma_node_get_output_bus_volume(const ma_node* pNode, ma_uint32 outputBusIndex) { const ma_node_base* pNodeBase = (const ma_node_base*)pNode; if (pNodeBase == NULL) { return 0; } if (outputBusIndex >= ma_node_get_output_bus_count(pNode)) { return 0; /* Invalid bus index. */ } return ma_node_output_bus_get_volume(&pNodeBase->pOutputBuses[outputBusIndex]); } MA_API ma_result ma_node_set_state(ma_node* pNode, ma_node_state state) { ma_node_base* pNodeBase = (ma_node_base*)pNode; if (pNodeBase == NULL) { return MA_INVALID_ARGS; } ma_atomic_exchange_i32(&pNodeBase->state, state); return MA_SUCCESS; } MA_API ma_node_state ma_node_get_state(const ma_node* pNode) { const ma_node_base* pNodeBase = (const ma_node_base*)pNode; if (pNodeBase == NULL) { return ma_node_state_stopped; } return (ma_node_state)ma_atomic_load_i32(&pNodeBase->state); } MA_API ma_result ma_node_set_state_time(ma_node* pNode, ma_node_state state, ma_uint64 globalTime) { if (pNode == NULL) { return MA_INVALID_ARGS; } /* Validation check for safety since we'll be using this as an index into stateTimes[]. */ if (state != ma_node_state_started && state != ma_node_state_stopped) { return MA_INVALID_ARGS; } ma_atomic_exchange_64(&((ma_node_base*)pNode)->stateTimes[state], globalTime); return MA_SUCCESS; } MA_API ma_uint64 ma_node_get_state_time(const ma_node* pNode, ma_node_state state) { if (pNode == NULL) { return 0; } /* Validation check for safety since we'll be using this as an index into stateTimes[]. */ if (state != ma_node_state_started && state != ma_node_state_stopped) { return 0; } return ma_atomic_load_64(&((ma_node_base*)pNode)->stateTimes[state]); } MA_API ma_node_state ma_node_get_state_by_time(const ma_node* pNode, ma_uint64 globalTime) { if (pNode == NULL) { return ma_node_state_stopped; } return ma_node_get_state_by_time_range(pNode, globalTime, globalTime); } MA_API ma_node_state ma_node_get_state_by_time_range(const ma_node* pNode, ma_uint64 globalTimeBeg, ma_uint64 globalTimeEnd) { ma_node_state state; if (pNode == NULL) { return ma_node_state_stopped; } state = ma_node_get_state(pNode); /* An explicitly stopped node is always stopped. */ if (state == ma_node_state_stopped) { return ma_node_state_stopped; } /* Getting here means the node is marked as started, but it may still not be truly started due to it's start time not having been reached yet. Also, the stop time may have also been reached in which case it'll be considered stopped. */ if (ma_node_get_state_time(pNode, ma_node_state_started) > globalTimeBeg) { return ma_node_state_stopped; /* Start time has not yet been reached. */ } if (ma_node_get_state_time(pNode, ma_node_state_stopped) <= globalTimeEnd) { return ma_node_state_stopped; /* Stop time has been reached. */ } /* Getting here means the node is marked as started and is within it's start/stop times. */ return ma_node_state_started; } MA_API ma_uint64 ma_node_get_time(const ma_node* pNode) { if (pNode == NULL) { return 0; } return ma_atomic_load_64(&((ma_node_base*)pNode)->localTime); } MA_API ma_result ma_node_set_time(ma_node* pNode, ma_uint64 localTime) { if (pNode == NULL) { return MA_INVALID_ARGS; } ma_atomic_exchange_64(&((ma_node_base*)pNode)->localTime, localTime); return MA_SUCCESS; } static void ma_node_process_pcm_frames_internal(ma_node* pNode, const float** ppFramesIn, ma_uint32* pFrameCountIn, float** ppFramesOut, ma_uint32* pFrameCountOut) { ma_node_base* pNodeBase = (ma_node_base*)pNode; MA_ASSERT(pNode != NULL); if (pNodeBase->vtable->onProcess) { pNodeBase->vtable->onProcess(pNode, ppFramesIn, pFrameCountIn, ppFramesOut, pFrameCountOut); } } static ma_result ma_node_read_pcm_frames(ma_node* pNode, ma_uint32 outputBusIndex, float* pFramesOut, ma_uint32 frameCount, ma_uint32* pFramesRead, ma_uint64 globalTime) { ma_node_base* pNodeBase = (ma_node_base*)pNode; ma_result result = MA_SUCCESS; ma_uint32 iInputBus; ma_uint32 iOutputBus; ma_uint32 inputBusCount; ma_uint32 outputBusCount; ma_uint32 totalFramesRead = 0; float* ppFramesIn[MA_MAX_NODE_BUS_COUNT]; float* ppFramesOut[MA_MAX_NODE_BUS_COUNT]; ma_uint64 globalTimeBeg; ma_uint64 globalTimeEnd; ma_uint64 startTime; ma_uint64 stopTime; ma_uint32 timeOffsetBeg; ma_uint32 timeOffsetEnd; ma_uint32 frameCountIn; ma_uint32 frameCountOut; /* pFramesRead is mandatory. It must be used to determine how many frames were read. It's normal and expected that the number of frames read may be different to that requested. Therefore, the caller must look at this value to correctly determine how many frames were read. */ MA_ASSERT(pFramesRead != NULL); /* <-- If you've triggered this assert, you're using this function wrong. You *must* use this variable and inspect it after the call returns. */ if (pFramesRead == NULL) { return MA_INVALID_ARGS; } *pFramesRead = 0; /* Safety. */ if (pNodeBase == NULL) { return MA_INVALID_ARGS; } if (outputBusIndex >= ma_node_get_output_bus_count(pNodeBase)) { return MA_INVALID_ARGS; /* Invalid output bus index. */ } /* Don't do anything if we're in a stopped state. */ if (ma_node_get_state_by_time_range(pNode, globalTime, globalTime + frameCount) != ma_node_state_started) { return MA_SUCCESS; /* We're in a stopped state. This is not an error - we just need to not read anything. */ } globalTimeBeg = globalTime; globalTimeEnd = globalTime + frameCount; startTime = ma_node_get_state_time(pNode, ma_node_state_started); stopTime = ma_node_get_state_time(pNode, ma_node_state_stopped); /* At this point we know that we are inside our start/stop times. However, we may need to adjust our frame count and output pointer to accommodate since we could be straddling the time period that this function is getting called for. It's possible (and likely) that the start time does not line up with the output buffer. We therefore need to offset it by a number of frames to accommodate. The same thing applies for the stop time. */ timeOffsetBeg = (globalTimeBeg < startTime) ? (ma_uint32)(globalTimeEnd - startTime) : 0; timeOffsetEnd = (globalTimeEnd > stopTime) ? (ma_uint32)(globalTimeEnd - stopTime) : 0; /* Trim based on the start offset. We need to silence the start of the buffer. */ if (timeOffsetBeg > 0) { ma_silence_pcm_frames(pFramesOut, timeOffsetBeg, ma_format_f32, ma_node_get_output_channels(pNode, outputBusIndex)); pFramesOut += timeOffsetBeg * ma_node_get_output_channels(pNode, outputBusIndex); frameCount -= timeOffsetBeg; } /* Trim based on the end offset. We don't need to silence the tail section because we'll just have a reduced value written to pFramesRead. */ if (timeOffsetEnd > 0) { frameCount -= timeOffsetEnd; } /* We run on different paths depending on the bus counts. */ inputBusCount = ma_node_get_input_bus_count(pNode); outputBusCount = ma_node_get_output_bus_count(pNode); /* Run a simplified path when there are no inputs and one output. In this case there's nothing to actually read and we can go straight to output. This is a very common scenario because the vast majority of data source nodes will use this setup so this optimization I think is worthwhile. */ if (inputBusCount == 0 && outputBusCount == 1) { /* Fast path. No need to read from input and no need for any caching. */ frameCountIn = 0; frameCountOut = frameCount; /* Just read as much as we can. The callback will return what was actually read. */ ppFramesOut[0] = pFramesOut; /* If it's a passthrough we won't be expecting the callback to output anything, so we'll need to pre-silence the output buffer. */ if ((pNodeBase->vtable->flags & MA_NODE_FLAG_PASSTHROUGH) != 0) { ma_silence_pcm_frames(pFramesOut, frameCount, ma_format_f32, ma_node_get_output_channels(pNode, outputBusIndex)); } ma_node_process_pcm_frames_internal(pNode, NULL, &frameCountIn, ppFramesOut, &frameCountOut); totalFramesRead = frameCountOut; } else { /* Slow path. Need to read input data. */ if ((pNodeBase->vtable->flags & MA_NODE_FLAG_PASSTHROUGH) != 0) { /* Fast path. We're running a passthrough. We need to read directly into the output buffer, but still fire the callback so that event handling and trigger nodes can do their thing. Since it's a passthrough there's no need for any kind of caching logic. */ MA_ASSERT(outputBusCount == inputBusCount); MA_ASSERT(outputBusCount == 1); MA_ASSERT(outputBusIndex == 0); /* We just read directly from input bus to output buffer, and then afterwards fire the callback. */ ppFramesOut[0] = pFramesOut; ppFramesIn[0] = ppFramesOut[0]; result = ma_node_input_bus_read_pcm_frames(pNodeBase, &pNodeBase->pInputBuses[0], ppFramesIn[0], frameCount, &totalFramesRead, globalTime); if (result == MA_SUCCESS) { /* Even though it's a passthrough, we still need to fire the callback. */ frameCountIn = totalFramesRead; frameCountOut = totalFramesRead; if (totalFramesRead > 0) { ma_node_process_pcm_frames_internal(pNode, (const float**)ppFramesIn, &frameCountIn, ppFramesOut, &frameCountOut); /* From GCC: expected 'const float **' but argument is of type 'float **'. Shouldn't this be implicit? Excplicit cast to silence the warning. */ } /* A passthrough should never have modified the input and output frame counts. If you're triggering these assers you need to fix your processing callback. */ MA_ASSERT(frameCountIn == totalFramesRead); MA_ASSERT(frameCountOut == totalFramesRead); } } else { /* Slow path. Need to do caching. */ ma_uint32 framesToProcessIn; ma_uint32 framesToProcessOut; ma_bool32 consumeNullInput = MA_FALSE; /* We use frameCount as a basis for the number of frames to read since that's what's being requested, however we still need to clamp it to whatever can fit in the cache. This will also be used as the basis for determining how many input frames to read. This is not ideal because it can result in too many input frames being read which introduces latency. To solve this, nodes can implement an optional callback called onGetRequiredInputFrameCount which is used as hint to miniaudio as to how many input frames it needs to read at a time. This callback is completely optional, and if it's not set, miniaudio will assume `frameCount`. This function will be called multiple times for each period of time, once for each output node. We cannot read from each input node each time this function is called. Instead we need to check whether or not this is first output bus to be read from for this time period, and if so, read from our input data. To determine whether or not we're ready to read data, we check a flag. There will be one flag for each output. When the flag is set, it means data has been read previously and that we're ready to advance time forward for our input nodes by reading fresh data. */ framesToProcessOut = frameCount; if (framesToProcessOut > pNodeBase->cachedDataCapInFramesPerBus) { framesToProcessOut = pNodeBase->cachedDataCapInFramesPerBus; } framesToProcessIn = frameCount; if (pNodeBase->vtable->onGetRequiredInputFrameCount) { pNodeBase->vtable->onGetRequiredInputFrameCount(pNode, framesToProcessOut, &framesToProcessIn); /* <-- It does not matter if this fails. */ } if (framesToProcessIn > pNodeBase->cachedDataCapInFramesPerBus) { framesToProcessIn = pNodeBase->cachedDataCapInFramesPerBus; } MA_ASSERT(framesToProcessIn <= 0xFFFF); MA_ASSERT(framesToProcessOut <= 0xFFFF); if (ma_node_output_bus_has_read(&pNodeBase->pOutputBuses[outputBusIndex])) { /* Getting here means we need to do another round of processing. */ pNodeBase->cachedFrameCountOut = 0; for (;;) { frameCountOut = 0; /* We need to prepare our output frame pointers for processing. In the same iteration we need to mark every output bus as unread so that future calls to this function for different buses for the current time period don't pull in data when they should instead be reading from cache. */ for (iOutputBus = 0; iOutputBus < outputBusCount; iOutputBus += 1) { ma_node_output_bus_set_has_read(&pNodeBase->pOutputBuses[iOutputBus], MA_FALSE); /* <-- This is what tells the next calls to this function for other output buses for this time period to read from cache instead of pulling in more data. */ ppFramesOut[iOutputBus] = ma_node_get_cached_output_ptr(pNode, iOutputBus); } /* We only need to read from input buses if there isn't already some data in the cache. */ if (pNodeBase->cachedFrameCountIn == 0) { ma_uint32 maxFramesReadIn = 0; /* Here is where we pull in data from the input buses. This is what will trigger an advance in time. */ for (iInputBus = 0; iInputBus < inputBusCount; iInputBus += 1) { ma_uint32 framesRead; /* The first thing to do is get the offset within our bulk allocation to store this input data. */ ppFramesIn[iInputBus] = ma_node_get_cached_input_ptr(pNode, iInputBus); /* Once we've determined our destination pointer we can read. Note that we must inspect the number of frames read and fill any leftovers with silence for safety. */ result = ma_node_input_bus_read_pcm_frames(pNodeBase, &pNodeBase->pInputBuses[iInputBus], ppFramesIn[iInputBus], framesToProcessIn, &framesRead, globalTime); if (result != MA_SUCCESS) { /* It doesn't really matter if we fail because we'll just fill with silence. */ framesRead = 0; /* Just for safety, but I don't think it's really needed. */ } /* TODO: Minor optimization opportunity here. If no frames were read and the buffer is already filled with silence, no need to re-silence it. */ /* Any leftover frames need to silenced for safety. */ if (framesRead < framesToProcessIn) { ma_silence_pcm_frames(ppFramesIn[iInputBus] + (framesRead * ma_node_get_input_channels(pNodeBase, iInputBus)), (framesToProcessIn - framesRead), ma_format_f32, ma_node_get_input_channels(pNodeBase, iInputBus)); } maxFramesReadIn = ma_max(maxFramesReadIn, framesRead); } /* This was a fresh load of input data so reset our consumption counter. */ pNodeBase->consumedFrameCountIn = 0; /* We don't want to keep processing if there's nothing to process, so set the number of cached input frames to the maximum number we read from each attachment (the lesser will be padded with silence). If we didn't read anything, this will be set to 0 and the entire buffer will have been assigned to silence. This being equal to 0 is an important property for us because it allows us to detect when NULL can be passed into the processing callback for the input buffer for the purpose of continuous processing. */ pNodeBase->cachedFrameCountIn = (ma_uint16)maxFramesReadIn; } else { /* We don't need to read anything, but we do need to prepare our input frame pointers. */ for (iInputBus = 0; iInputBus < inputBusCount; iInputBus += 1) { ppFramesIn[iInputBus] = ma_node_get_cached_input_ptr(pNode, iInputBus) + (pNodeBase->consumedFrameCountIn * ma_node_get_input_channels(pNodeBase, iInputBus)); } } /* At this point we have our input data so now we need to do some processing. Sneaky little optimization here - we can set the pointer to the output buffer for this output bus so that the final copy into the output buffer is done directly by onProcess(). */ if (pFramesOut != NULL) { ppFramesOut[outputBusIndex] = ma_offset_pcm_frames_ptr_f32(pFramesOut, pNodeBase->cachedFrameCountOut, ma_node_get_output_channels(pNode, outputBusIndex)); } /* Give the processing function the entire capacity of the output buffer. */ frameCountOut = (framesToProcessOut - pNodeBase->cachedFrameCountOut); /* We need to treat nodes with continuous processing a little differently. For these ones, we always want to fire the callback with the requested number of frames, regardless of pNodeBase->cachedFrameCountIn, which could be 0. Also, we want to check if we can pass in NULL for the input buffer to the callback. */ if ((pNodeBase->vtable->flags & MA_NODE_FLAG_CONTINUOUS_PROCESSING) != 0) { /* We're using continuous processing. Make sure we specify the whole frame count at all times. */ frameCountIn = framesToProcessIn; /* Give the processing function as much input data as we've got in the buffer, including any silenced padding from short reads. */ if ((pNodeBase->vtable->flags & MA_NODE_FLAG_ALLOW_NULL_INPUT) != 0 && pNodeBase->consumedFrameCountIn == 0 && pNodeBase->cachedFrameCountIn == 0) { consumeNullInput = MA_TRUE; } else { consumeNullInput = MA_FALSE; } /* Since we're using continuous processing we're always passing in a full frame count regardless of how much input data was read. If this is greater than what we read as input, we'll end up with an underflow. We instead need to make sure our cached frame count is set to the number of frames we'll be passing to the data callback. Not doing this will result in an underflow when we "consume" the cached data later on. Note that this check needs to be done after the "consumeNullInput" check above because we use the property of cachedFrameCountIn being 0 to determine whether or not we should be passing in a null pointer to the processing callback for when the node is configured with MA_NODE_FLAG_ALLOW_NULL_INPUT. */ if (pNodeBase->cachedFrameCountIn < (ma_uint16)frameCountIn) { pNodeBase->cachedFrameCountIn = (ma_uint16)frameCountIn; } } else { frameCountIn = pNodeBase->cachedFrameCountIn; /* Give the processing function as much valid input data as we've got. */ consumeNullInput = MA_FALSE; } /* Process data slightly differently depending on whether or not we're consuming NULL input (checked just above). */ if (consumeNullInput) { ma_node_process_pcm_frames_internal(pNode, NULL, &frameCountIn, ppFramesOut, &frameCountOut); } else { /* We want to skip processing if there's no input data, but we can only do that safely if we know that there is no chance of any output frames being produced. If continuous processing is being used, this won't be a problem because the input frame count will always be non-0. However, if continuous processing is *not* enabled and input and output data is processed at different rates, we still need to process that last input frame because there could be a few excess output frames needing to be produced from cached data. The `MA_NODE_FLAG_DIFFERENT_PROCESSING_RATES` flag is used as the indicator for determining whether or not we need to process the node even when there are no input frames available right now. */ if (frameCountIn > 0 || (pNodeBase->vtable->flags & MA_NODE_FLAG_DIFFERENT_PROCESSING_RATES) != 0) { ma_node_process_pcm_frames_internal(pNode, (const float**)ppFramesIn, &frameCountIn, ppFramesOut, &frameCountOut); /* From GCC: expected 'const float **' but argument is of type 'float **'. Shouldn't this be implicit? Excplicit cast to silence the warning. */ } else { frameCountOut = 0; /* No data was processed. */ } } /* Thanks to our sneaky optimization above we don't need to do any data copying directly into the output buffer - the onProcess() callback just did that for us. We do, however, need to apply the number of input and output frames that were processed. Note that due to continuous processing above, we need to do explicit checks here. If we just consumed a NULL input buffer it means that no actual input data was processed from the internal buffers and we don't want to be modifying any counters. */ if (consumeNullInput == MA_FALSE) { pNodeBase->consumedFrameCountIn += (ma_uint16)frameCountIn; pNodeBase->cachedFrameCountIn -= (ma_uint16)frameCountIn; } /* The cached output frame count is always equal to what we just read. */ pNodeBase->cachedFrameCountOut += (ma_uint16)frameCountOut; /* If we couldn't process any data, we're done. The loop needs to be terminated here or else we'll get stuck in a loop. */ if (pNodeBase->cachedFrameCountOut == framesToProcessOut || (frameCountOut == 0 && frameCountIn == 0)) { break; } } } else { /* We're not needing to read anything from the input buffer so just read directly from our already-processed data. */ if (pFramesOut != NULL) { ma_copy_pcm_frames(pFramesOut, ma_node_get_cached_output_ptr(pNodeBase, outputBusIndex), pNodeBase->cachedFrameCountOut, ma_format_f32, ma_node_get_output_channels(pNodeBase, outputBusIndex)); } } /* The number of frames read is always equal to the number of cached output frames. */ totalFramesRead = pNodeBase->cachedFrameCountOut; /* Now that we've read the data, make sure our read flag is set. */ ma_node_output_bus_set_has_read(&pNodeBase->pOutputBuses[outputBusIndex], MA_TRUE); } } /* Apply volume, if necessary. */ ma_apply_volume_factor_f32(pFramesOut, totalFramesRead * ma_node_get_output_channels(pNodeBase, outputBusIndex), ma_node_output_bus_get_volume(&pNodeBase->pOutputBuses[outputBusIndex])); /* Advance our local time forward. */ ma_atomic_fetch_add_64(&pNodeBase->localTime, (ma_uint64)totalFramesRead); *pFramesRead = totalFramesRead + timeOffsetBeg; /* Must include the silenced section at the start of the buffer. */ return result; } /* Data source node. */ MA_API ma_data_source_node_config ma_data_source_node_config_init(ma_data_source* pDataSource) { ma_data_source_node_config config; MA_ZERO_OBJECT(&config); config.nodeConfig = ma_node_config_init(); config.pDataSource = pDataSource; return config; } static void ma_data_source_node_process_pcm_frames(ma_node* pNode, const float** ppFramesIn, ma_uint32* pFrameCountIn, float** ppFramesOut, ma_uint32* pFrameCountOut) { ma_data_source_node* pDataSourceNode = (ma_data_source_node*)pNode; ma_format format; ma_uint32 channels; ma_uint32 frameCount; ma_uint64 framesRead = 0; MA_ASSERT(pDataSourceNode != NULL); MA_ASSERT(pDataSourceNode->pDataSource != NULL); MA_ASSERT(ma_node_get_input_bus_count(pDataSourceNode) == 0); MA_ASSERT(ma_node_get_output_bus_count(pDataSourceNode) == 1); /* We don't want to read from ppFramesIn at all. Instead we read from the data source. */ (void)ppFramesIn; (void)pFrameCountIn; frameCount = *pFrameCountOut; /* miniaudio should never be calling this with a frame count of zero. */ MA_ASSERT(frameCount > 0); if (ma_data_source_get_data_format(pDataSourceNode->pDataSource, &format, &channels, NULL, NULL, 0) == MA_SUCCESS) { /* <-- Don't care about sample rate here. */ /* The node graph system requires samples be in floating point format. This is checked in ma_data_source_node_init(). */ MA_ASSERT(format == ma_format_f32); (void)format; /* Just to silence some static analysis tools. */ ma_data_source_read_pcm_frames(pDataSourceNode->pDataSource, ppFramesOut[0], frameCount, &framesRead); } *pFrameCountOut = (ma_uint32)framesRead; } static ma_node_vtable g_ma_data_source_node_vtable = { ma_data_source_node_process_pcm_frames, NULL, /* onGetRequiredInputFrameCount */ 0, /* 0 input buses. */ 1, /* 1 output bus. */ 0 }; MA_API ma_result ma_data_source_node_init(ma_node_graph* pNodeGraph, const ma_data_source_node_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_data_source_node* pDataSourceNode) { ma_result result; ma_format format; /* For validating the format, which must be ma_format_f32. */ ma_uint32 channels; /* For specifying the channel count of the output bus. */ ma_node_config baseConfig; if (pDataSourceNode == NULL) { return MA_INVALID_ARGS; } MA_ZERO_OBJECT(pDataSourceNode); if (pConfig == NULL) { return MA_INVALID_ARGS; } result = ma_data_source_get_data_format(pConfig->pDataSource, &format, &channels, NULL, NULL, 0); /* Don't care about sample rate. This will check pDataSource for NULL. */ if (result != MA_SUCCESS) { return result; } MA_ASSERT(format == ma_format_f32); /* <-- If you've triggered this it means your data source is not outputting floating-point samples. You must configure your data source to use ma_format_f32. */ if (format != ma_format_f32) { return MA_INVALID_ARGS; /* Invalid format. */ } /* The channel count is defined by the data source. If the caller has manually changed the channels we just ignore it. */ baseConfig = pConfig->nodeConfig; baseConfig.vtable = &g_ma_data_source_node_vtable; /* Explicitly set the vtable here to prevent callers from setting it incorrectly. */ /* The channel count is defined by the data source. It is invalid for the caller to manually set the channel counts in the config. `ma_data_source_node_config_init()` will have defaulted the channel count pointer to NULL which is how it must remain. If you trigger any of these asserts it means you're explicitly setting the channel count. Instead, configure the output channel count of your data source to be the necessary channel count. */ if (baseConfig.pOutputChannels != NULL) { return MA_INVALID_ARGS; } baseConfig.pOutputChannels = &channels; result = ma_node_init(pNodeGraph, &baseConfig, pAllocationCallbacks, &pDataSourceNode->base); if (result != MA_SUCCESS) { return result; } pDataSourceNode->pDataSource = pConfig->pDataSource; return MA_SUCCESS; } MA_API void ma_data_source_node_uninit(ma_data_source_node* pDataSourceNode, const ma_allocation_callbacks* pAllocationCallbacks) { ma_node_uninit(&pDataSourceNode->base, pAllocationCallbacks); } MA_API ma_result ma_data_source_node_set_looping(ma_data_source_node* pDataSourceNode, ma_bool32 isLooping) { if (pDataSourceNode == NULL) { return MA_INVALID_ARGS; } return ma_data_source_set_looping(pDataSourceNode->pDataSource, isLooping); } MA_API ma_bool32 ma_data_source_node_is_looping(ma_data_source_node* pDataSourceNode) { if (pDataSourceNode == NULL) { return MA_FALSE; } return ma_data_source_is_looping(pDataSourceNode->pDataSource); } /* Splitter Node. */ MA_API ma_splitter_node_config ma_splitter_node_config_init(ma_uint32 channels) { ma_splitter_node_config config; MA_ZERO_OBJECT(&config); config.nodeConfig = ma_node_config_init(); config.channels = channels; config.outputBusCount = 2; return config; } static void ma_splitter_node_process_pcm_frames(ma_node* pNode, const float** ppFramesIn, ma_uint32* pFrameCountIn, float** ppFramesOut, ma_uint32* pFrameCountOut) { ma_node_base* pNodeBase = (ma_node_base*)pNode; ma_uint32 iOutputBus; ma_uint32 channels; MA_ASSERT(pNodeBase != NULL); MA_ASSERT(ma_node_get_input_bus_count(pNodeBase) == 1); /* We don't need to consider the input frame count - it'll be the same as the output frame count and we process everything. */ (void)pFrameCountIn; /* NOTE: This assumes the same number of channels for all inputs and outputs. This was checked in ma_splitter_node_init(). */ channels = ma_node_get_input_channels(pNodeBase, 0); /* Splitting is just copying the first input bus and copying it over to each output bus. */ for (iOutputBus = 0; iOutputBus < ma_node_get_output_bus_count(pNodeBase); iOutputBus += 1) { ma_copy_pcm_frames(ppFramesOut[iOutputBus], ppFramesIn[0], *pFrameCountOut, ma_format_f32, channels); } } static ma_node_vtable g_ma_splitter_node_vtable = { ma_splitter_node_process_pcm_frames, NULL, /* onGetRequiredInputFrameCount */ 1, /* 1 input bus. */ MA_NODE_BUS_COUNT_UNKNOWN, /* The output bus count is specified on a per-node basis. */ 0 }; MA_API ma_result ma_splitter_node_init(ma_node_graph* pNodeGraph, const ma_splitter_node_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_splitter_node* pSplitterNode) { ma_result result; ma_node_config baseConfig; ma_uint32 pInputChannels[1]; ma_uint32 pOutputChannels[MA_MAX_NODE_BUS_COUNT]; ma_uint32 iOutputBus; if (pSplitterNode == NULL) { return MA_INVALID_ARGS; } MA_ZERO_OBJECT(pSplitterNode); if (pConfig == NULL) { return MA_INVALID_ARGS; } if (pConfig->outputBusCount > MA_MAX_NODE_BUS_COUNT) { return MA_INVALID_ARGS; /* Too many output buses. */ } /* Splitters require the same number of channels between inputs and outputs. */ pInputChannels[0] = pConfig->channels; for (iOutputBus = 0; iOutputBus < pConfig->outputBusCount; iOutputBus += 1) { pOutputChannels[iOutputBus] = pConfig->channels; } baseConfig = pConfig->nodeConfig; baseConfig.vtable = &g_ma_splitter_node_vtable; baseConfig.pInputChannels = pInputChannels; baseConfig.pOutputChannels = pOutputChannels; baseConfig.outputBusCount = pConfig->outputBusCount; result = ma_node_init(pNodeGraph, &baseConfig, pAllocationCallbacks, &pSplitterNode->base); if (result != MA_SUCCESS) { return result; /* Failed to initialize the base node. */ } return MA_SUCCESS; } MA_API void ma_splitter_node_uninit(ma_splitter_node* pSplitterNode, const ma_allocation_callbacks* pAllocationCallbacks) { ma_node_uninit(pSplitterNode, pAllocationCallbacks); } /* Biquad Node */ MA_API ma_biquad_node_config ma_biquad_node_config_init(ma_uint32 channels, float b0, float b1, float b2, float a0, float a1, float a2) { ma_biquad_node_config config; config.nodeConfig = ma_node_config_init(); config.biquad = ma_biquad_config_init(ma_format_f32, channels, b0, b1, b2, a0, a1, a2); return config; } static void ma_biquad_node_process_pcm_frames(ma_node* pNode, const float** ppFramesIn, ma_uint32* pFrameCountIn, float** ppFramesOut, ma_uint32* pFrameCountOut) { ma_biquad_node* pLPFNode = (ma_biquad_node*)pNode; MA_ASSERT(pNode != NULL); (void)pFrameCountIn; ma_biquad_process_pcm_frames(&pLPFNode->biquad, ppFramesOut[0], ppFramesIn[0], *pFrameCountOut); } static ma_node_vtable g_ma_biquad_node_vtable = { ma_biquad_node_process_pcm_frames, NULL, /* onGetRequiredInputFrameCount */ 1, /* One input. */ 1, /* One output. */ 0 /* Default flags. */ }; MA_API ma_result ma_biquad_node_init(ma_node_graph* pNodeGraph, const ma_biquad_node_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_biquad_node* pNode) { ma_result result; ma_node_config baseNodeConfig; if (pNode == NULL) { return MA_INVALID_ARGS; } MA_ZERO_OBJECT(pNode); if (pConfig == NULL) { return MA_INVALID_ARGS; } if (pConfig->biquad.format != ma_format_f32) { return MA_INVALID_ARGS; /* The format must be f32. */ } result = ma_biquad_init(&pConfig->biquad, pAllocationCallbacks, &pNode->biquad); if (result != MA_SUCCESS) { return result; } baseNodeConfig = ma_node_config_init(); baseNodeConfig.vtable = &g_ma_biquad_node_vtable; baseNodeConfig.pInputChannels = &pConfig->biquad.channels; baseNodeConfig.pOutputChannels = &pConfig->biquad.channels; result = ma_node_init(pNodeGraph, &baseNodeConfig, pAllocationCallbacks, pNode); if (result != MA_SUCCESS) { return result; } return result; } MA_API ma_result ma_biquad_node_reinit(const ma_biquad_config* pConfig, ma_biquad_node* pNode) { ma_biquad_node* pLPFNode = (ma_biquad_node*)pNode; MA_ASSERT(pNode != NULL); return ma_biquad_reinit(pConfig, &pLPFNode->biquad); } MA_API void ma_biquad_node_uninit(ma_biquad_node* pNode, const ma_allocation_callbacks* pAllocationCallbacks) { ma_biquad_node* pLPFNode = (ma_biquad_node*)pNode; if (pNode == NULL) { return; } ma_node_uninit(pNode, pAllocationCallbacks); ma_biquad_uninit(&pLPFNode->biquad, pAllocationCallbacks); } /* Low Pass Filter Node */ MA_API ma_lpf_node_config ma_lpf_node_config_init(ma_uint32 channels, ma_uint32 sampleRate, double cutoffFrequency, ma_uint32 order) { ma_lpf_node_config config; config.nodeConfig = ma_node_config_init(); config.lpf = ma_lpf_config_init(ma_format_f32, channels, sampleRate, cutoffFrequency, order); return config; } static void ma_lpf_node_process_pcm_frames(ma_node* pNode, const float** ppFramesIn, ma_uint32* pFrameCountIn, float** ppFramesOut, ma_uint32* pFrameCountOut) { ma_lpf_node* pLPFNode = (ma_lpf_node*)pNode; MA_ASSERT(pNode != NULL); (void)pFrameCountIn; ma_lpf_process_pcm_frames(&pLPFNode->lpf, ppFramesOut[0], ppFramesIn[0], *pFrameCountOut); } static ma_node_vtable g_ma_lpf_node_vtable = { ma_lpf_node_process_pcm_frames, NULL, /* onGetRequiredInputFrameCount */ 1, /* One input. */ 1, /* One output. */ 0 /* Default flags. */ }; MA_API ma_result ma_lpf_node_init(ma_node_graph* pNodeGraph, const ma_lpf_node_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_lpf_node* pNode) { ma_result result; ma_node_config baseNodeConfig; if (pNode == NULL) { return MA_INVALID_ARGS; } MA_ZERO_OBJECT(pNode); if (pConfig == NULL) { return MA_INVALID_ARGS; } if (pConfig->lpf.format != ma_format_f32) { return MA_INVALID_ARGS; /* The format must be f32. */ } result = ma_lpf_init(&pConfig->lpf, pAllocationCallbacks, &pNode->lpf); if (result != MA_SUCCESS) { return result; } baseNodeConfig = ma_node_config_init(); baseNodeConfig.vtable = &g_ma_lpf_node_vtable; baseNodeConfig.pInputChannels = &pConfig->lpf.channels; baseNodeConfig.pOutputChannels = &pConfig->lpf.channels; result = ma_node_init(pNodeGraph, &baseNodeConfig, pAllocationCallbacks, pNode); if (result != MA_SUCCESS) { return result; } return result; } MA_API ma_result ma_lpf_node_reinit(const ma_lpf_config* pConfig, ma_lpf_node* pNode) { ma_lpf_node* pLPFNode = (ma_lpf_node*)pNode; if (pNode == NULL) { return MA_INVALID_ARGS; } return ma_lpf_reinit(pConfig, &pLPFNode->lpf); } MA_API void ma_lpf_node_uninit(ma_lpf_node* pNode, const ma_allocation_callbacks* pAllocationCallbacks) { ma_lpf_node* pLPFNode = (ma_lpf_node*)pNode; if (pNode == NULL) { return; } ma_node_uninit(pNode, pAllocationCallbacks); ma_lpf_uninit(&pLPFNode->lpf, pAllocationCallbacks); } /* High Pass Filter Node */ MA_API ma_hpf_node_config ma_hpf_node_config_init(ma_uint32 channels, ma_uint32 sampleRate, double cutoffFrequency, ma_uint32 order) { ma_hpf_node_config config; config.nodeConfig = ma_node_config_init(); config.hpf = ma_hpf_config_init(ma_format_f32, channels, sampleRate, cutoffFrequency, order); return config; } static void ma_hpf_node_process_pcm_frames(ma_node* pNode, const float** ppFramesIn, ma_uint32* pFrameCountIn, float** ppFramesOut, ma_uint32* pFrameCountOut) { ma_hpf_node* pHPFNode = (ma_hpf_node*)pNode; MA_ASSERT(pNode != NULL); (void)pFrameCountIn; ma_hpf_process_pcm_frames(&pHPFNode->hpf, ppFramesOut[0], ppFramesIn[0], *pFrameCountOut); } static ma_node_vtable g_ma_hpf_node_vtable = { ma_hpf_node_process_pcm_frames, NULL, /* onGetRequiredInputFrameCount */ 1, /* One input. */ 1, /* One output. */ 0 /* Default flags. */ }; MA_API ma_result ma_hpf_node_init(ma_node_graph* pNodeGraph, const ma_hpf_node_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_hpf_node* pNode) { ma_result result; ma_node_config baseNodeConfig; if (pNode == NULL) { return MA_INVALID_ARGS; } MA_ZERO_OBJECT(pNode); if (pConfig == NULL) { return MA_INVALID_ARGS; } if (pConfig->hpf.format != ma_format_f32) { return MA_INVALID_ARGS; /* The format must be f32. */ } result = ma_hpf_init(&pConfig->hpf, pAllocationCallbacks, &pNode->hpf); if (result != MA_SUCCESS) { return result; } baseNodeConfig = ma_node_config_init(); baseNodeConfig.vtable = &g_ma_hpf_node_vtable; baseNodeConfig.pInputChannels = &pConfig->hpf.channels; baseNodeConfig.pOutputChannels = &pConfig->hpf.channels; result = ma_node_init(pNodeGraph, &baseNodeConfig, pAllocationCallbacks, pNode); if (result != MA_SUCCESS) { return result; } return result; } MA_API ma_result ma_hpf_node_reinit(const ma_hpf_config* pConfig, ma_hpf_node* pNode) { ma_hpf_node* pHPFNode = (ma_hpf_node*)pNode; if (pNode == NULL) { return MA_INVALID_ARGS; } return ma_hpf_reinit(pConfig, &pHPFNode->hpf); } MA_API void ma_hpf_node_uninit(ma_hpf_node* pNode, const ma_allocation_callbacks* pAllocationCallbacks) { ma_hpf_node* pHPFNode = (ma_hpf_node*)pNode; if (pNode == NULL) { return; } ma_node_uninit(pNode, pAllocationCallbacks); ma_hpf_uninit(&pHPFNode->hpf, pAllocationCallbacks); } /* Band Pass Filter Node */ MA_API ma_bpf_node_config ma_bpf_node_config_init(ma_uint32 channels, ma_uint32 sampleRate, double cutoffFrequency, ma_uint32 order) { ma_bpf_node_config config; config.nodeConfig = ma_node_config_init(); config.bpf = ma_bpf_config_init(ma_format_f32, channels, sampleRate, cutoffFrequency, order); return config; } static void ma_bpf_node_process_pcm_frames(ma_node* pNode, const float** ppFramesIn, ma_uint32* pFrameCountIn, float** ppFramesOut, ma_uint32* pFrameCountOut) { ma_bpf_node* pBPFNode = (ma_bpf_node*)pNode; MA_ASSERT(pNode != NULL); (void)pFrameCountIn; ma_bpf_process_pcm_frames(&pBPFNode->bpf, ppFramesOut[0], ppFramesIn[0], *pFrameCountOut); } static ma_node_vtable g_ma_bpf_node_vtable = { ma_bpf_node_process_pcm_frames, NULL, /* onGetRequiredInputFrameCount */ 1, /* One input. */ 1, /* One output. */ 0 /* Default flags. */ }; MA_API ma_result ma_bpf_node_init(ma_node_graph* pNodeGraph, const ma_bpf_node_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_bpf_node* pNode) { ma_result result; ma_node_config baseNodeConfig; if (pNode == NULL) { return MA_INVALID_ARGS; } MA_ZERO_OBJECT(pNode); if (pConfig == NULL) { return MA_INVALID_ARGS; } if (pConfig->bpf.format != ma_format_f32) { return MA_INVALID_ARGS; /* The format must be f32. */ } result = ma_bpf_init(&pConfig->bpf, pAllocationCallbacks, &pNode->bpf); if (result != MA_SUCCESS) { return result; } baseNodeConfig = ma_node_config_init(); baseNodeConfig.vtable = &g_ma_bpf_node_vtable; baseNodeConfig.pInputChannels = &pConfig->bpf.channels; baseNodeConfig.pOutputChannels = &pConfig->bpf.channels; result = ma_node_init(pNodeGraph, &baseNodeConfig, pAllocationCallbacks, pNode); if (result != MA_SUCCESS) { return result; } return result; } MA_API ma_result ma_bpf_node_reinit(const ma_bpf_config* pConfig, ma_bpf_node* pNode) { ma_bpf_node* pBPFNode = (ma_bpf_node*)pNode; if (pNode == NULL) { return MA_INVALID_ARGS; } return ma_bpf_reinit(pConfig, &pBPFNode->bpf); } MA_API void ma_bpf_node_uninit(ma_bpf_node* pNode, const ma_allocation_callbacks* pAllocationCallbacks) { ma_bpf_node* pBPFNode = (ma_bpf_node*)pNode; if (pNode == NULL) { return; } ma_node_uninit(pNode, pAllocationCallbacks); ma_bpf_uninit(&pBPFNode->bpf, pAllocationCallbacks); } /* Notching Filter Node */ MA_API ma_notch_node_config ma_notch_node_config_init(ma_uint32 channels, ma_uint32 sampleRate, double q, double frequency) { ma_notch_node_config config; config.nodeConfig = ma_node_config_init(); config.notch = ma_notch2_config_init(ma_format_f32, channels, sampleRate, q, frequency); return config; } static void ma_notch_node_process_pcm_frames(ma_node* pNode, const float** ppFramesIn, ma_uint32* pFrameCountIn, float** ppFramesOut, ma_uint32* pFrameCountOut) { ma_notch_node* pBPFNode = (ma_notch_node*)pNode; MA_ASSERT(pNode != NULL); (void)pFrameCountIn; ma_notch2_process_pcm_frames(&pBPFNode->notch, ppFramesOut[0], ppFramesIn[0], *pFrameCountOut); } static ma_node_vtable g_ma_notch_node_vtable = { ma_notch_node_process_pcm_frames, NULL, /* onGetRequiredInputFrameCount */ 1, /* One input. */ 1, /* One output. */ 0 /* Default flags. */ }; MA_API ma_result ma_notch_node_init(ma_node_graph* pNodeGraph, const ma_notch_node_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_notch_node* pNode) { ma_result result; ma_node_config baseNodeConfig; if (pNode == NULL) { return MA_INVALID_ARGS; } MA_ZERO_OBJECT(pNode); if (pConfig == NULL) { return MA_INVALID_ARGS; } if (pConfig->notch.format != ma_format_f32) { return MA_INVALID_ARGS; /* The format must be f32. */ } result = ma_notch2_init(&pConfig->notch, pAllocationCallbacks, &pNode->notch); if (result != MA_SUCCESS) { return result; } baseNodeConfig = ma_node_config_init(); baseNodeConfig.vtable = &g_ma_notch_node_vtable; baseNodeConfig.pInputChannels = &pConfig->notch.channels; baseNodeConfig.pOutputChannels = &pConfig->notch.channels; result = ma_node_init(pNodeGraph, &baseNodeConfig, pAllocationCallbacks, pNode); if (result != MA_SUCCESS) { return result; } return result; } MA_API ma_result ma_notch_node_reinit(const ma_notch_config* pConfig, ma_notch_node* pNode) { ma_notch_node* pNotchNode = (ma_notch_node*)pNode; if (pNode == NULL) { return MA_INVALID_ARGS; } return ma_notch2_reinit(pConfig, &pNotchNode->notch); } MA_API void ma_notch_node_uninit(ma_notch_node* pNode, const ma_allocation_callbacks* pAllocationCallbacks) { ma_notch_node* pNotchNode = (ma_notch_node*)pNode; if (pNode == NULL) { return; } ma_node_uninit(pNode, pAllocationCallbacks); ma_notch2_uninit(&pNotchNode->notch, pAllocationCallbacks); } /* Peaking Filter Node */ MA_API ma_peak_node_config ma_peak_node_config_init(ma_uint32 channels, ma_uint32 sampleRate, double gainDB, double q, double frequency) { ma_peak_node_config config; config.nodeConfig = ma_node_config_init(); config.peak = ma_peak2_config_init(ma_format_f32, channels, sampleRate, gainDB, q, frequency); return config; } static void ma_peak_node_process_pcm_frames(ma_node* pNode, const float** ppFramesIn, ma_uint32* pFrameCountIn, float** ppFramesOut, ma_uint32* pFrameCountOut) { ma_peak_node* pBPFNode = (ma_peak_node*)pNode; MA_ASSERT(pNode != NULL); (void)pFrameCountIn; ma_peak2_process_pcm_frames(&pBPFNode->peak, ppFramesOut[0], ppFramesIn[0], *pFrameCountOut); } static ma_node_vtable g_ma_peak_node_vtable = { ma_peak_node_process_pcm_frames, NULL, /* onGetRequiredInputFrameCount */ 1, /* One input. */ 1, /* One output. */ 0 /* Default flags. */ }; MA_API ma_result ma_peak_node_init(ma_node_graph* pNodeGraph, const ma_peak_node_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_peak_node* pNode) { ma_result result; ma_node_config baseNodeConfig; if (pNode == NULL) { return MA_INVALID_ARGS; } MA_ZERO_OBJECT(pNode); if (pConfig == NULL) { return MA_INVALID_ARGS; } if (pConfig->peak.format != ma_format_f32) { return MA_INVALID_ARGS; /* The format must be f32. */ } result = ma_peak2_init(&pConfig->peak, pAllocationCallbacks, &pNode->peak); if (result != MA_SUCCESS) { ma_node_uninit(pNode, pAllocationCallbacks); return result; } baseNodeConfig = ma_node_config_init(); baseNodeConfig.vtable = &g_ma_peak_node_vtable; baseNodeConfig.pInputChannels = &pConfig->peak.channels; baseNodeConfig.pOutputChannels = &pConfig->peak.channels; result = ma_node_init(pNodeGraph, &baseNodeConfig, pAllocationCallbacks, pNode); if (result != MA_SUCCESS) { return result; } return result; } MA_API ma_result ma_peak_node_reinit(const ma_peak_config* pConfig, ma_peak_node* pNode) { ma_peak_node* pPeakNode = (ma_peak_node*)pNode; if (pNode == NULL) { return MA_INVALID_ARGS; } return ma_peak2_reinit(pConfig, &pPeakNode->peak); } MA_API void ma_peak_node_uninit(ma_peak_node* pNode, const ma_allocation_callbacks* pAllocationCallbacks) { ma_peak_node* pPeakNode = (ma_peak_node*)pNode; if (pNode == NULL) { return; } ma_node_uninit(pNode, pAllocationCallbacks); ma_peak2_uninit(&pPeakNode->peak, pAllocationCallbacks); } /* Low Shelf Filter Node */ MA_API ma_loshelf_node_config ma_loshelf_node_config_init(ma_uint32 channels, ma_uint32 sampleRate, double gainDB, double q, double frequency) { ma_loshelf_node_config config; config.nodeConfig = ma_node_config_init(); config.loshelf = ma_loshelf2_config_init(ma_format_f32, channels, sampleRate, gainDB, q, frequency); return config; } static void ma_loshelf_node_process_pcm_frames(ma_node* pNode, const float** ppFramesIn, ma_uint32* pFrameCountIn, float** ppFramesOut, ma_uint32* pFrameCountOut) { ma_loshelf_node* pBPFNode = (ma_loshelf_node*)pNode; MA_ASSERT(pNode != NULL); (void)pFrameCountIn; ma_loshelf2_process_pcm_frames(&pBPFNode->loshelf, ppFramesOut[0], ppFramesIn[0], *pFrameCountOut); } static ma_node_vtable g_ma_loshelf_node_vtable = { ma_loshelf_node_process_pcm_frames, NULL, /* onGetRequiredInputFrameCount */ 1, /* One input. */ 1, /* One output. */ 0 /* Default flags. */ }; MA_API ma_result ma_loshelf_node_init(ma_node_graph* pNodeGraph, const ma_loshelf_node_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_loshelf_node* pNode) { ma_result result; ma_node_config baseNodeConfig; if (pNode == NULL) { return MA_INVALID_ARGS; } MA_ZERO_OBJECT(pNode); if (pConfig == NULL) { return MA_INVALID_ARGS; } if (pConfig->loshelf.format != ma_format_f32) { return MA_INVALID_ARGS; /* The format must be f32. */ } result = ma_loshelf2_init(&pConfig->loshelf, pAllocationCallbacks, &pNode->loshelf); if (result != MA_SUCCESS) { return result; } baseNodeConfig = ma_node_config_init(); baseNodeConfig.vtable = &g_ma_loshelf_node_vtable; baseNodeConfig.pInputChannels = &pConfig->loshelf.channels; baseNodeConfig.pOutputChannels = &pConfig->loshelf.channels; result = ma_node_init(pNodeGraph, &baseNodeConfig, pAllocationCallbacks, pNode); if (result != MA_SUCCESS) { return result; } return result; } MA_API ma_result ma_loshelf_node_reinit(const ma_loshelf_config* pConfig, ma_loshelf_node* pNode) { ma_loshelf_node* pLoshelfNode = (ma_loshelf_node*)pNode; if (pNode == NULL) { return MA_INVALID_ARGS; } return ma_loshelf2_reinit(pConfig, &pLoshelfNode->loshelf); } MA_API void ma_loshelf_node_uninit(ma_loshelf_node* pNode, const ma_allocation_callbacks* pAllocationCallbacks) { ma_loshelf_node* pLoshelfNode = (ma_loshelf_node*)pNode; if (pNode == NULL) { return; } ma_node_uninit(pNode, pAllocationCallbacks); ma_loshelf2_uninit(&pLoshelfNode->loshelf, pAllocationCallbacks); } /* High Shelf Filter Node */ MA_API ma_hishelf_node_config ma_hishelf_node_config_init(ma_uint32 channels, ma_uint32 sampleRate, double gainDB, double q, double frequency) { ma_hishelf_node_config config; config.nodeConfig = ma_node_config_init(); config.hishelf = ma_hishelf2_config_init(ma_format_f32, channels, sampleRate, gainDB, q, frequency); return config; } static void ma_hishelf_node_process_pcm_frames(ma_node* pNode, const float** ppFramesIn, ma_uint32* pFrameCountIn, float** ppFramesOut, ma_uint32* pFrameCountOut) { ma_hishelf_node* pBPFNode = (ma_hishelf_node*)pNode; MA_ASSERT(pNode != NULL); (void)pFrameCountIn; ma_hishelf2_process_pcm_frames(&pBPFNode->hishelf, ppFramesOut[0], ppFramesIn[0], *pFrameCountOut); } static ma_node_vtable g_ma_hishelf_node_vtable = { ma_hishelf_node_process_pcm_frames, NULL, /* onGetRequiredInputFrameCount */ 1, /* One input. */ 1, /* One output. */ 0 /* Default flags. */ }; MA_API ma_result ma_hishelf_node_init(ma_node_graph* pNodeGraph, const ma_hishelf_node_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_hishelf_node* pNode) { ma_result result; ma_node_config baseNodeConfig; if (pNode == NULL) { return MA_INVALID_ARGS; } MA_ZERO_OBJECT(pNode); if (pConfig == NULL) { return MA_INVALID_ARGS; } if (pConfig->hishelf.format != ma_format_f32) { return MA_INVALID_ARGS; /* The format must be f32. */ } result = ma_hishelf2_init(&pConfig->hishelf, pAllocationCallbacks, &pNode->hishelf); if (result != MA_SUCCESS) { return result; } baseNodeConfig = ma_node_config_init(); baseNodeConfig.vtable = &g_ma_hishelf_node_vtable; baseNodeConfig.pInputChannels = &pConfig->hishelf.channels; baseNodeConfig.pOutputChannels = &pConfig->hishelf.channels; result = ma_node_init(pNodeGraph, &baseNodeConfig, pAllocationCallbacks, pNode); if (result != MA_SUCCESS) { return result; } return result; } MA_API ma_result ma_hishelf_node_reinit(const ma_hishelf_config* pConfig, ma_hishelf_node* pNode) { ma_hishelf_node* pHishelfNode = (ma_hishelf_node*)pNode; if (pNode == NULL) { return MA_INVALID_ARGS; } return ma_hishelf2_reinit(pConfig, &pHishelfNode->hishelf); } MA_API void ma_hishelf_node_uninit(ma_hishelf_node* pNode, const ma_allocation_callbacks* pAllocationCallbacks) { ma_hishelf_node* pHishelfNode = (ma_hishelf_node*)pNode; if (pNode == NULL) { return; } ma_node_uninit(pNode, pAllocationCallbacks); ma_hishelf2_uninit(&pHishelfNode->hishelf, pAllocationCallbacks); } MA_API ma_delay_node_config ma_delay_node_config_init(ma_uint32 channels, ma_uint32 sampleRate, ma_uint32 delayInFrames, float decay) { ma_delay_node_config config; config.nodeConfig = ma_node_config_init(); config.delay = ma_delay_config_init(channels, sampleRate, delayInFrames, decay); return config; } static void ma_delay_node_process_pcm_frames(ma_node* pNode, const float** ppFramesIn, ma_uint32* pFrameCountIn, float** ppFramesOut, ma_uint32* pFrameCountOut) { ma_delay_node* pDelayNode = (ma_delay_node*)pNode; (void)pFrameCountIn; ma_delay_process_pcm_frames(&pDelayNode->delay, ppFramesOut[0], ppFramesIn[0], *pFrameCountOut); } static ma_node_vtable g_ma_delay_node_vtable = { ma_delay_node_process_pcm_frames, NULL, 1, /* 1 input channels. */ 1, /* 1 output channel. */ MA_NODE_FLAG_CONTINUOUS_PROCESSING /* Delay requires continuous processing to ensure the tail get's processed. */ }; MA_API ma_result ma_delay_node_init(ma_node_graph* pNodeGraph, const ma_delay_node_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_delay_node* pDelayNode) { ma_result result; ma_node_config baseConfig; if (pDelayNode == NULL) { return MA_INVALID_ARGS; } MA_ZERO_OBJECT(pDelayNode); result = ma_delay_init(&pConfig->delay, pAllocationCallbacks, &pDelayNode->delay); if (result != MA_SUCCESS) { return result; } baseConfig = pConfig->nodeConfig; baseConfig.vtable = &g_ma_delay_node_vtable; baseConfig.pInputChannels = &pConfig->delay.channels; baseConfig.pOutputChannels = &pConfig->delay.channels; result = ma_node_init(pNodeGraph, &baseConfig, pAllocationCallbacks, &pDelayNode->baseNode); if (result != MA_SUCCESS) { ma_delay_uninit(&pDelayNode->delay, pAllocationCallbacks); return result; } return result; } MA_API void ma_delay_node_uninit(ma_delay_node* pDelayNode, const ma_allocation_callbacks* pAllocationCallbacks) { if (pDelayNode == NULL) { return; } /* The base node is always uninitialized first. */ ma_node_uninit(pDelayNode, pAllocationCallbacks); ma_delay_uninit(&pDelayNode->delay, pAllocationCallbacks); } MA_API void ma_delay_node_set_wet(ma_delay_node* pDelayNode, float value) { if (pDelayNode == NULL) { return; } ma_delay_set_wet(&pDelayNode->delay, value); } MA_API float ma_delay_node_get_wet(const ma_delay_node* pDelayNode) { if (pDelayNode == NULL) { return 0; } return ma_delay_get_wet(&pDelayNode->delay); } MA_API void ma_delay_node_set_dry(ma_delay_node* pDelayNode, float value) { if (pDelayNode == NULL) { return; } ma_delay_set_dry(&pDelayNode->delay, value); } MA_API float ma_delay_node_get_dry(const ma_delay_node* pDelayNode) { if (pDelayNode == NULL) { return 0; } return ma_delay_get_dry(&pDelayNode->delay); } MA_API void ma_delay_node_set_decay(ma_delay_node* pDelayNode, float value) { if (pDelayNode == NULL) { return; } ma_delay_set_decay(&pDelayNode->delay, value); } MA_API float ma_delay_node_get_decay(const ma_delay_node* pDelayNode) { if (pDelayNode == NULL) { return 0; } return ma_delay_get_decay(&pDelayNode->delay); } #endif /* MA_NO_NODE_GRAPH */ /* SECTION: miniaudio_engine.c */ #if !defined(MA_NO_ENGINE) && !defined(MA_NO_NODE_GRAPH) /************************************************************************************************************************************************************** Engine **************************************************************************************************************************************************************/ #define MA_SEEK_TARGET_NONE (~(ma_uint64)0) static void ma_sound_set_at_end(ma_sound* pSound, ma_bool32 atEnd) { MA_ASSERT(pSound != NULL); ma_atomic_exchange_32(&pSound->atEnd, atEnd); /* Fire any callbacks or events. */ if (atEnd) { if (pSound->endCallback != NULL) { pSound->endCallback(pSound->pEndCallbackUserData, pSound); } } } static ma_bool32 ma_sound_get_at_end(const ma_sound* pSound) { MA_ASSERT(pSound != NULL); return ma_atomic_load_32(&pSound->atEnd); } MA_API ma_engine_node_config ma_engine_node_config_init(ma_engine* pEngine, ma_engine_node_type type, ma_uint32 flags) { ma_engine_node_config config; MA_ZERO_OBJECT(&config); config.pEngine = pEngine; config.type = type; config.isPitchDisabled = (flags & MA_SOUND_FLAG_NO_PITCH) != 0; config.isSpatializationDisabled = (flags & MA_SOUND_FLAG_NO_SPATIALIZATION) != 0; config.monoExpansionMode = pEngine->monoExpansionMode; return config; } static void ma_engine_node_update_pitch_if_required(ma_engine_node* pEngineNode) { ma_bool32 isUpdateRequired = MA_FALSE; float newPitch; MA_ASSERT(pEngineNode != NULL); newPitch = ma_atomic_load_explicit_f32(&pEngineNode->pitch, ma_atomic_memory_order_acquire); if (pEngineNode->oldPitch != newPitch) { pEngineNode->oldPitch = newPitch; isUpdateRequired = MA_TRUE; } if (pEngineNode->oldDopplerPitch != pEngineNode->spatializer.dopplerPitch) { pEngineNode->oldDopplerPitch = pEngineNode->spatializer.dopplerPitch; isUpdateRequired = MA_TRUE; } if (isUpdateRequired) { float basePitch = (float)pEngineNode->sampleRate / ma_engine_get_sample_rate(pEngineNode->pEngine); ma_linear_resampler_set_rate_ratio(&pEngineNode->resampler, basePitch * pEngineNode->oldPitch * pEngineNode->oldDopplerPitch); } } static ma_bool32 ma_engine_node_is_pitching_enabled(const ma_engine_node* pEngineNode) { MA_ASSERT(pEngineNode != NULL); /* Don't try to be clever by skiping resampling in the pitch=1 case or else you'll glitch when moving away from 1. */ return !ma_atomic_load_explicit_32(&pEngineNode->isPitchDisabled, ma_atomic_memory_order_acquire); } static ma_bool32 ma_engine_node_is_spatialization_enabled(const ma_engine_node* pEngineNode) { MA_ASSERT(pEngineNode != NULL); return !ma_atomic_load_explicit_32(&pEngineNode->isSpatializationDisabled, ma_atomic_memory_order_acquire); } static ma_uint64 ma_engine_node_get_required_input_frame_count(const ma_engine_node* pEngineNode, ma_uint64 outputFrameCount) { ma_uint64 inputFrameCount = 0; if (ma_engine_node_is_pitching_enabled(pEngineNode)) { ma_result result = ma_linear_resampler_get_required_input_frame_count(&pEngineNode->resampler, outputFrameCount, &inputFrameCount); if (result != MA_SUCCESS) { inputFrameCount = 0; } } else { inputFrameCount = outputFrameCount; /* No resampling, so 1:1. */ } return inputFrameCount; } static ma_result ma_engine_node_set_volume(ma_engine_node* pEngineNode, float volume) { if (pEngineNode == NULL) { return MA_INVALID_ARGS; } ma_atomic_float_set(&pEngineNode->volume, volume); /* If we're not smoothing we should bypass the volume gainer entirely. */ if (pEngineNode->volumeSmoothTimeInPCMFrames == 0) { /* We should always have an active spatializer because it can be enabled and disabled dynamically. We can just use that for hodling our volume. */ ma_spatializer_set_master_volume(&pEngineNode->spatializer, volume); } else { /* We're using volume smoothing, so apply the master volume to the gainer. */ ma_gainer_set_gain(&pEngineNode->volumeGainer, volume); } return MA_SUCCESS; } static ma_result ma_engine_node_get_volume(const ma_engine_node* pEngineNode, float* pVolume) { if (pVolume == NULL) { return MA_INVALID_ARGS; } *pVolume = 0.0f; if (pEngineNode == NULL) { return MA_INVALID_ARGS; } *pVolume = ma_atomic_float_get((ma_atomic_float*)&pEngineNode->volume); return MA_SUCCESS; } static void ma_engine_node_process_pcm_frames__general(ma_engine_node* pEngineNode, const float** ppFramesIn, ma_uint32* pFrameCountIn, float** ppFramesOut, ma_uint32* pFrameCountOut) { ma_uint32 frameCountIn; ma_uint32 frameCountOut; ma_uint32 totalFramesProcessedIn; ma_uint32 totalFramesProcessedOut; ma_uint32 channelsIn; ma_uint32 channelsOut; ma_bool32 isPitchingEnabled; ma_bool32 isFadingEnabled; ma_bool32 isSpatializationEnabled; ma_bool32 isPanningEnabled; ma_bool32 isVolumeSmoothingEnabled; frameCountIn = *pFrameCountIn; frameCountOut = *pFrameCountOut; channelsIn = ma_spatializer_get_input_channels(&pEngineNode->spatializer); channelsOut = ma_spatializer_get_output_channels(&pEngineNode->spatializer); totalFramesProcessedIn = 0; totalFramesProcessedOut = 0; /* Update the fader if applicable. */ { ma_uint64 fadeLengthInFrames = ma_atomic_uint64_get(&pEngineNode->fadeSettings.fadeLengthInFrames); if (fadeLengthInFrames != ~(ma_uint64)0) { float fadeVolumeBeg = ma_atomic_float_get(&pEngineNode->fadeSettings.volumeBeg); float fadeVolumeEnd = ma_atomic_float_get(&pEngineNode->fadeSettings.volumeEnd); ma_int64 fadeStartOffsetInFrames = (ma_int64)ma_atomic_uint64_get(&pEngineNode->fadeSettings.absoluteGlobalTimeInFrames); if (fadeStartOffsetInFrames == (ma_int64)(~(ma_uint64)0)) { fadeStartOffsetInFrames = 0; } else { fadeStartOffsetInFrames -= ma_engine_get_time_in_pcm_frames(pEngineNode->pEngine); } ma_fader_set_fade_ex(&pEngineNode->fader, fadeVolumeBeg, fadeVolumeEnd, fadeLengthInFrames, fadeStartOffsetInFrames); /* Reset the fade length so we don't erroneously apply it again. */ ma_atomic_uint64_set(&pEngineNode->fadeSettings.fadeLengthInFrames, ~(ma_uint64)0); } } isPitchingEnabled = ma_engine_node_is_pitching_enabled(pEngineNode); isFadingEnabled = pEngineNode->fader.volumeBeg != 1 || pEngineNode->fader.volumeEnd != 1; isSpatializationEnabled = ma_engine_node_is_spatialization_enabled(pEngineNode); isPanningEnabled = pEngineNode->panner.pan != 0 && channelsOut != 1; isVolumeSmoothingEnabled = pEngineNode->volumeSmoothTimeInPCMFrames > 0; /* Keep going while we've still got data available for processing. */ while (totalFramesProcessedOut < frameCountOut) { /* We need to process in a specific order. We always do resampling first because it's likely we're going to be increasing the channel count after spatialization. Also, I want to do fading based on the output sample rate. We'll first read into a buffer from the resampler. Then we'll do all processing that operates on the on the input channel count. We'll then get the spatializer to output to the output buffer and then do all effects from that point directly in the output buffer in-place. Note that we're always running the resampler if pitching is enabled, even when the pitch is 1. If we try to be clever and skip resampling when the pitch is 1, we'll get a glitch when we move away from 1, back to 1, and then away from 1 again. We'll want to implement any pitch=1 optimizations in the resampler itself. There's a small optimization here that we'll utilize since it might be a fairly common case. When the input and output channel counts are the same, we'll read straight into the output buffer from the resampler and do everything in-place. */ const float* pRunningFramesIn; float* pRunningFramesOut; float* pWorkingBuffer; /* This is the buffer that we'll be processing frames in. This is in input channels. */ float temp[MA_DATA_CONVERTER_STACK_BUFFER_SIZE / sizeof(float)]; ma_uint32 tempCapInFrames = ma_countof(temp) / channelsIn; ma_uint32 framesAvailableIn; ma_uint32 framesAvailableOut; ma_uint32 framesJustProcessedIn; ma_uint32 framesJustProcessedOut; ma_bool32 isWorkingBufferValid = MA_FALSE; framesAvailableIn = frameCountIn - totalFramesProcessedIn; framesAvailableOut = frameCountOut - totalFramesProcessedOut; pRunningFramesIn = ma_offset_pcm_frames_const_ptr_f32(ppFramesIn[0], totalFramesProcessedIn, channelsIn); pRunningFramesOut = ma_offset_pcm_frames_ptr_f32(ppFramesOut[0], totalFramesProcessedOut, channelsOut); if (channelsIn == channelsOut) { /* Fast path. Channel counts are the same. No need for an intermediary input buffer. */ pWorkingBuffer = pRunningFramesOut; } else { /* Slow path. Channel counts are different. Need to use an intermediary input buffer. */ pWorkingBuffer = temp; if (framesAvailableOut > tempCapInFrames) { framesAvailableOut = tempCapInFrames; } } /* First is resampler. */ if (isPitchingEnabled) { ma_uint64 resampleFrameCountIn = framesAvailableIn; ma_uint64 resampleFrameCountOut = framesAvailableOut; ma_linear_resampler_process_pcm_frames(&pEngineNode->resampler, pRunningFramesIn, &resampleFrameCountIn, pWorkingBuffer, &resampleFrameCountOut); isWorkingBufferValid = MA_TRUE; framesJustProcessedIn = (ma_uint32)resampleFrameCountIn; framesJustProcessedOut = (ma_uint32)resampleFrameCountOut; } else { framesJustProcessedIn = ma_min(framesAvailableIn, framesAvailableOut); framesJustProcessedOut = framesJustProcessedIn; /* When no resampling is being performed, the number of output frames is the same as input frames. */ } /* Fading. */ if (isFadingEnabled) { if (isWorkingBufferValid) { ma_fader_process_pcm_frames(&pEngineNode->fader, pWorkingBuffer, pWorkingBuffer, framesJustProcessedOut); /* In-place processing. */ } else { ma_fader_process_pcm_frames(&pEngineNode->fader, pWorkingBuffer, pRunningFramesIn, framesJustProcessedOut); isWorkingBufferValid = MA_TRUE; } } /* If we're using smoothing, we won't be applying volume via the spatializer, but instead from a ma_gainer. In this case we'll want to apply our volume now. */ if (isVolumeSmoothingEnabled) { if (isWorkingBufferValid) { ma_gainer_process_pcm_frames(&pEngineNode->volumeGainer, pWorkingBuffer, pWorkingBuffer, framesJustProcessedOut); } else { ma_gainer_process_pcm_frames(&pEngineNode->volumeGainer, pWorkingBuffer, pRunningFramesIn, framesJustProcessedOut); isWorkingBufferValid = MA_TRUE; } } /* If at this point we still haven't actually done anything with the working buffer we need to just read straight from the input buffer. */ if (isWorkingBufferValid == MA_FALSE) { pWorkingBuffer = (float*)pRunningFramesIn; /* Naughty const cast, but it's safe at this point because we won't ever be writing to it from this point out. */ } /* Spatialization. */ if (isSpatializationEnabled) { ma_uint32 iListener; /* When determining the listener to use, we first check to see if the sound is pinned to a specific listener. If so, we use that. Otherwise we just use the closest listener. */ if (pEngineNode->pinnedListenerIndex != MA_LISTENER_INDEX_CLOSEST && pEngineNode->pinnedListenerIndex < ma_engine_get_listener_count(pEngineNode->pEngine)) { iListener = pEngineNode->pinnedListenerIndex; } else { ma_vec3f spatializerPosition = ma_spatializer_get_position(&pEngineNode->spatializer); iListener = ma_engine_find_closest_listener(pEngineNode->pEngine, spatializerPosition.x, spatializerPosition.y, spatializerPosition.z); } ma_spatializer_process_pcm_frames(&pEngineNode->spatializer, &pEngineNode->pEngine->listeners[iListener], pRunningFramesOut, pWorkingBuffer, framesJustProcessedOut); } else { /* No spatialization, but we still need to do channel conversion and master volume. */ float volume; ma_engine_node_get_volume(pEngineNode, &volume); /* Should never fail. */ if (channelsIn == channelsOut) { /* No channel conversion required. Just copy straight to the output buffer. */ if (isVolumeSmoothingEnabled) { /* Volume has already been applied. Just copy straight to the output buffer. */ ma_copy_pcm_frames(pRunningFramesOut, pWorkingBuffer, framesJustProcessedOut * channelsOut, ma_format_f32, channelsOut); } else { /* Volume has not been applied yet. Copy and apply volume in the same pass. */ ma_copy_and_apply_volume_factor_f32(pRunningFramesOut, pWorkingBuffer, framesJustProcessedOut * channelsOut, volume); } } else { /* Channel conversion required. TODO: Add support for channel maps here. */ ma_channel_map_apply_f32(pRunningFramesOut, NULL, channelsOut, pWorkingBuffer, NULL, channelsIn, framesJustProcessedOut, ma_channel_mix_mode_simple, pEngineNode->monoExpansionMode); /* If we're using smoothing, the volume will have already been applied. */ if (!isVolumeSmoothingEnabled) { ma_apply_volume_factor_f32(pRunningFramesOut, framesJustProcessedOut * channelsOut, volume); } } } /* At this point we can guarantee that the output buffer contains valid data. We can process everything in place now. */ /* Panning. */ if (isPanningEnabled) { ma_panner_process_pcm_frames(&pEngineNode->panner, pRunningFramesOut, pRunningFramesOut, framesJustProcessedOut); /* In-place processing. */ } /* We're done for this chunk. */ totalFramesProcessedIn += framesJustProcessedIn; totalFramesProcessedOut += framesJustProcessedOut; /* If we didn't process any output frames this iteration it means we've either run out of input data, or run out of room in the output buffer. */ if (framesJustProcessedOut == 0) { break; } } /* At this point we're done processing. */ *pFrameCountIn = totalFramesProcessedIn; *pFrameCountOut = totalFramesProcessedOut; } static void ma_engine_node_process_pcm_frames__sound(ma_node* pNode, const float** ppFramesIn, ma_uint32* pFrameCountIn, float** ppFramesOut, ma_uint32* pFrameCountOut) { /* For sounds, we need to first read from the data source. Then we need to apply the engine effects (pan, pitch, fades, etc.). */ ma_result result = MA_SUCCESS; ma_sound* pSound = (ma_sound*)pNode; ma_uint32 frameCount = *pFrameCountOut; ma_uint32 totalFramesRead = 0; ma_format dataSourceFormat; ma_uint32 dataSourceChannels; ma_uint8 temp[MA_DATA_CONVERTER_STACK_BUFFER_SIZE]; ma_uint32 tempCapInFrames; ma_uint64 seekTarget; /* This is a data source node which means no input buses. */ (void)ppFramesIn; (void)pFrameCountIn; /* If we're marked at the end we need to stop the sound and do nothing. */ if (ma_sound_at_end(pSound)) { ma_sound_stop(pSound); *pFrameCountOut = 0; return; } /* If we're seeking, do so now before reading. */ seekTarget = ma_atomic_load_64(&pSound->seekTarget); if (seekTarget != MA_SEEK_TARGET_NONE) { ma_data_source_seek_to_pcm_frame(pSound->pDataSource, seekTarget); /* Any time-dependant effects need to have their times updated. */ ma_node_set_time(pSound, seekTarget); ma_atomic_exchange_64(&pSound->seekTarget, MA_SEEK_TARGET_NONE); } /* We want to update the pitch once. For sounds, this can be either at the start or at the end. If we don't force this to only ever be updating once, we could end up in a situation where retrieving the required input frame count ends up being different to what we actually retrieve. What could happen is that the required input frame count is calculated, the pitch is update, and then this processing function is called resulting in a different number of input frames being processed. Do not call this in ma_engine_node_process_pcm_frames__general() or else you'll hit the aforementioned bug. */ ma_engine_node_update_pitch_if_required(&pSound->engineNode); /* For the convenience of the caller, we're doing to allow data sources to use non-floating-point formats and channel counts that differ from the main engine. */ result = ma_data_source_get_data_format(pSound->pDataSource, &dataSourceFormat, &dataSourceChannels, NULL, NULL, 0); if (result == MA_SUCCESS) { tempCapInFrames = sizeof(temp) / ma_get_bytes_per_frame(dataSourceFormat, dataSourceChannels); /* Keep reading until we've read as much as was requested or we reach the end of the data source. */ while (totalFramesRead < frameCount) { ma_uint32 framesRemaining = frameCount - totalFramesRead; ma_uint32 framesToRead; ma_uint64 framesJustRead; ma_uint32 frameCountIn; ma_uint32 frameCountOut; const float* pRunningFramesIn; float* pRunningFramesOut; /* The first thing we need to do is read into the temporary buffer. We can calculate exactly how many input frames we'll need after resampling. */ framesToRead = (ma_uint32)ma_engine_node_get_required_input_frame_count(&pSound->engineNode, framesRemaining); if (framesToRead > tempCapInFrames) { framesToRead = tempCapInFrames; } result = ma_data_source_read_pcm_frames(pSound->pDataSource, temp, framesToRead, &framesJustRead); /* If we reached the end of the sound we'll want to mark it as at the end and stop it. This should never be returned for looping sounds. */ if (result == MA_AT_END) { ma_sound_set_at_end(pSound, MA_TRUE); /* This will be set to false in ma_sound_start(). */ } pRunningFramesOut = ma_offset_pcm_frames_ptr_f32(ppFramesOut[0], totalFramesRead, ma_engine_get_channels(ma_sound_get_engine(pSound))); frameCountIn = (ma_uint32)framesJustRead; frameCountOut = framesRemaining; /* Convert if necessary. */ if (dataSourceFormat == ma_format_f32) { /* Fast path. No data conversion necessary. */ pRunningFramesIn = (float*)temp; ma_engine_node_process_pcm_frames__general(&pSound->engineNode, &pRunningFramesIn, &frameCountIn, &pRunningFramesOut, &frameCountOut); } else { /* Slow path. Need to do sample format conversion to f32. If we give the f32 buffer the same count as the first temp buffer, we're guaranteed it'll be large enough. */ float tempf32[MA_DATA_CONVERTER_STACK_BUFFER_SIZE]; /* Do not do `MA_DATA_CONVERTER_STACK_BUFFER_SIZE/sizeof(float)` here like we've done in other places. */ ma_convert_pcm_frames_format(tempf32, ma_format_f32, temp, dataSourceFormat, framesJustRead, dataSourceChannels, ma_dither_mode_none); /* Now that we have our samples in f32 format we can process like normal. */ pRunningFramesIn = tempf32; ma_engine_node_process_pcm_frames__general(&pSound->engineNode, &pRunningFramesIn, &frameCountIn, &pRunningFramesOut, &frameCountOut); } /* We should have processed all of our input frames since we calculated the required number of input frames at the top. */ MA_ASSERT(frameCountIn == framesJustRead); totalFramesRead += (ma_uint32)frameCountOut; /* Safe cast. */ if (result != MA_SUCCESS || ma_sound_at_end(pSound)) { break; /* Might have reached the end. */ } } } *pFrameCountOut = totalFramesRead; } static void ma_engine_node_process_pcm_frames__group(ma_node* pNode, const float** ppFramesIn, ma_uint32* pFrameCountIn, float** ppFramesOut, ma_uint32* pFrameCountOut) { /* Make sure the pitch is updated before trying to read anything. It's important that this is done only once and not in ma_engine_node_process_pcm_frames__general(). The reason for this is that ma_engine_node_process_pcm_frames__general() will call ma_engine_node_get_required_input_frame_count(), and if another thread modifies the pitch just after that call it can result in a glitch due to the input rate changing. */ ma_engine_node_update_pitch_if_required((ma_engine_node*)pNode); /* For groups, the input data has already been read and we just need to apply the effect. */ ma_engine_node_process_pcm_frames__general((ma_engine_node*)pNode, ppFramesIn, pFrameCountIn, ppFramesOut, pFrameCountOut); } static ma_result ma_engine_node_get_required_input_frame_count__group(ma_node* pNode, ma_uint32 outputFrameCount, ma_uint32* pInputFrameCount) { ma_uint64 inputFrameCount; MA_ASSERT(pInputFrameCount != NULL); /* Our pitch will affect this calculation. We need to update it. */ ma_engine_node_update_pitch_if_required((ma_engine_node*)pNode); inputFrameCount = ma_engine_node_get_required_input_frame_count((ma_engine_node*)pNode, outputFrameCount); if (inputFrameCount > 0xFFFFFFFF) { inputFrameCount = 0xFFFFFFFF; /* Will never happen because miniaudio will only ever process in relatively small chunks. */ } *pInputFrameCount = (ma_uint32)inputFrameCount; return MA_SUCCESS; } static ma_node_vtable g_ma_engine_node_vtable__sound = { ma_engine_node_process_pcm_frames__sound, NULL, /* onGetRequiredInputFrameCount */ 0, /* Sounds are data source nodes which means they have zero inputs (their input is drawn from the data source itself). */ 1, /* Sounds have one output bus. */ 0 /* Default flags. */ }; static ma_node_vtable g_ma_engine_node_vtable__group = { ma_engine_node_process_pcm_frames__group, ma_engine_node_get_required_input_frame_count__group, 1, /* Groups have one input bus. */ 1, /* Groups have one output bus. */ MA_NODE_FLAG_DIFFERENT_PROCESSING_RATES /* The engine node does resampling so should let miniaudio know about it. */ }; static ma_node_config ma_engine_node_base_node_config_init(const ma_engine_node_config* pConfig) { ma_node_config baseNodeConfig; if (pConfig->type == ma_engine_node_type_sound) { /* Sound. */ baseNodeConfig = ma_node_config_init(); baseNodeConfig.vtable = &g_ma_engine_node_vtable__sound; baseNodeConfig.initialState = ma_node_state_stopped; /* Sounds are stopped by default. */ } else { /* Group. */ baseNodeConfig = ma_node_config_init(); baseNodeConfig.vtable = &g_ma_engine_node_vtable__group; baseNodeConfig.initialState = ma_node_state_started; /* Groups are started by default. */ } return baseNodeConfig; } static ma_spatializer_config ma_engine_node_spatializer_config_init(const ma_node_config* pBaseNodeConfig) { return ma_spatializer_config_init(pBaseNodeConfig->pInputChannels[0], pBaseNodeConfig->pOutputChannels[0]); } typedef struct { size_t sizeInBytes; size_t baseNodeOffset; size_t resamplerOffset; size_t spatializerOffset; size_t gainerOffset; } ma_engine_node_heap_layout; static ma_result ma_engine_node_get_heap_layout(const ma_engine_node_config* pConfig, ma_engine_node_heap_layout* pHeapLayout) { ma_result result; size_t tempHeapSize; ma_node_config baseNodeConfig; ma_linear_resampler_config resamplerConfig; ma_spatializer_config spatializerConfig; ma_gainer_config gainerConfig; ma_uint32 channelsIn; ma_uint32 channelsOut; ma_channel defaultStereoChannelMap[2] = {MA_CHANNEL_SIDE_LEFT, MA_CHANNEL_SIDE_RIGHT}; /* <-- Consistent with the default channel map of a stereo listener. Means channel conversion can run on a fast path. */ MA_ASSERT(pHeapLayout); MA_ZERO_OBJECT(pHeapLayout); if (pConfig == NULL) { return MA_INVALID_ARGS; } if (pConfig->pEngine == NULL) { return MA_INVALID_ARGS; /* An engine must be specified. */ } pHeapLayout->sizeInBytes = 0; channelsIn = (pConfig->channelsIn != 0) ? pConfig->channelsIn : ma_engine_get_channels(pConfig->pEngine); channelsOut = (pConfig->channelsOut != 0) ? pConfig->channelsOut : ma_engine_get_channels(pConfig->pEngine); /* Base node. */ baseNodeConfig = ma_engine_node_base_node_config_init(pConfig); baseNodeConfig.pInputChannels = &channelsIn; baseNodeConfig.pOutputChannels = &channelsOut; result = ma_node_get_heap_size(ma_engine_get_node_graph(pConfig->pEngine), &baseNodeConfig, &tempHeapSize); if (result != MA_SUCCESS) { return result; /* Failed to retrieve the size of the heap for the base node. */ } pHeapLayout->baseNodeOffset = pHeapLayout->sizeInBytes; pHeapLayout->sizeInBytes += ma_align_64(tempHeapSize); /* Resmapler. */ resamplerConfig = ma_linear_resampler_config_init(ma_format_f32, channelsIn, 1, 1); /* Input and output sample rates don't affect the calculation of the heap size. */ resamplerConfig.lpfOrder = 0; result = ma_linear_resampler_get_heap_size(&resamplerConfig, &tempHeapSize); if (result != MA_SUCCESS) { return result; /* Failed to retrieve the size of the heap for the resampler. */ } pHeapLayout->resamplerOffset = pHeapLayout->sizeInBytes; pHeapLayout->sizeInBytes += ma_align_64(tempHeapSize); /* Spatializer. */ spatializerConfig = ma_engine_node_spatializer_config_init(&baseNodeConfig); if (spatializerConfig.channelsIn == 2) { spatializerConfig.pChannelMapIn = defaultStereoChannelMap; } result = ma_spatializer_get_heap_size(&spatializerConfig, &tempHeapSize); if (result != MA_SUCCESS) { return result; /* Failed to retrieve the size of the heap for the spatializer. */ } pHeapLayout->spatializerOffset = pHeapLayout->sizeInBytes; pHeapLayout->sizeInBytes += ma_align_64(tempHeapSize); /* Gainer. Will not be used if we are not using smoothing. */ if (pConfig->volumeSmoothTimeInPCMFrames > 0) { gainerConfig = ma_gainer_config_init(channelsIn, pConfig->volumeSmoothTimeInPCMFrames); result = ma_gainer_get_heap_size(&gainerConfig, &tempHeapSize); if (result != MA_SUCCESS) { return result; } pHeapLayout->gainerOffset = pHeapLayout->sizeInBytes; pHeapLayout->sizeInBytes += ma_align_64(tempHeapSize); } return MA_SUCCESS; } MA_API ma_result ma_engine_node_get_heap_size(const ma_engine_node_config* pConfig, size_t* pHeapSizeInBytes) { ma_result result; ma_engine_node_heap_layout heapLayout; if (pHeapSizeInBytes == NULL) { return MA_INVALID_ARGS; } *pHeapSizeInBytes = 0; result = ma_engine_node_get_heap_layout(pConfig, &heapLayout); if (result != MA_SUCCESS) { return result; } *pHeapSizeInBytes = heapLayout.sizeInBytes; return MA_SUCCESS; } MA_API ma_result ma_engine_node_init_preallocated(const ma_engine_node_config* pConfig, void* pHeap, ma_engine_node* pEngineNode) { ma_result result; ma_engine_node_heap_layout heapLayout; ma_node_config baseNodeConfig; ma_linear_resampler_config resamplerConfig; ma_fader_config faderConfig; ma_spatializer_config spatializerConfig; ma_panner_config pannerConfig; ma_gainer_config gainerConfig; ma_uint32 channelsIn; ma_uint32 channelsOut; ma_channel defaultStereoChannelMap[2] = {MA_CHANNEL_SIDE_LEFT, MA_CHANNEL_SIDE_RIGHT}; /* <-- Consistent with the default channel map of a stereo listener. Means channel conversion can run on a fast path. */ if (pEngineNode == NULL) { return MA_INVALID_ARGS; } MA_ZERO_OBJECT(pEngineNode); result = ma_engine_node_get_heap_layout(pConfig, &heapLayout); if (result != MA_SUCCESS) { return result; } if (pConfig->pinnedListenerIndex != MA_LISTENER_INDEX_CLOSEST && pConfig->pinnedListenerIndex >= ma_engine_get_listener_count(pConfig->pEngine)) { return MA_INVALID_ARGS; /* Invalid listener. */ } pEngineNode->_pHeap = pHeap; MA_ZERO_MEMORY(pHeap, heapLayout.sizeInBytes); pEngineNode->pEngine = pConfig->pEngine; pEngineNode->sampleRate = (pConfig->sampleRate > 0) ? pConfig->sampleRate : ma_engine_get_sample_rate(pEngineNode->pEngine); pEngineNode->volumeSmoothTimeInPCMFrames = pConfig->volumeSmoothTimeInPCMFrames; pEngineNode->monoExpansionMode = pConfig->monoExpansionMode; ma_atomic_float_set(&pEngineNode->volume, 1); pEngineNode->pitch = 1; pEngineNode->oldPitch = 1; pEngineNode->oldDopplerPitch = 1; pEngineNode->isPitchDisabled = pConfig->isPitchDisabled; pEngineNode->isSpatializationDisabled = pConfig->isSpatializationDisabled; pEngineNode->pinnedListenerIndex = pConfig->pinnedListenerIndex; ma_atomic_float_set(&pEngineNode->fadeSettings.volumeBeg, 1); ma_atomic_float_set(&pEngineNode->fadeSettings.volumeEnd, 1); ma_atomic_uint64_set(&pEngineNode->fadeSettings.fadeLengthInFrames, (~(ma_uint64)0)); ma_atomic_uint64_set(&pEngineNode->fadeSettings.absoluteGlobalTimeInFrames, (~(ma_uint64)0)); /* <-- Indicates that the fade should start immediately. */ channelsIn = (pConfig->channelsIn != 0) ? pConfig->channelsIn : ma_engine_get_channels(pConfig->pEngine); channelsOut = (pConfig->channelsOut != 0) ? pConfig->channelsOut : ma_engine_get_channels(pConfig->pEngine); /* If the sample rate of the sound is different to the engine, make sure pitching is enabled so that the resampler is activated. Not doing this will result in the sound not being resampled if MA_SOUND_FLAG_NO_PITCH is used. */ if (pEngineNode->sampleRate != ma_engine_get_sample_rate(pEngineNode->pEngine)) { pEngineNode->isPitchDisabled = MA_FALSE; } /* Base node. */ baseNodeConfig = ma_engine_node_base_node_config_init(pConfig); baseNodeConfig.pInputChannels = &channelsIn; baseNodeConfig.pOutputChannels = &channelsOut; result = ma_node_init_preallocated(&pConfig->pEngine->nodeGraph, &baseNodeConfig, ma_offset_ptr(pHeap, heapLayout.baseNodeOffset), &pEngineNode->baseNode); if (result != MA_SUCCESS) { goto error0; } /* We can now initialize the effects we need in order to implement the engine node. There's a defined order of operations here, mainly centered around when we convert our channels from the data source's native channel count to the engine's channel count. As a rule, we want to do as much computation as possible before spatialization because there's a chance that will increase the channel count, thereby increasing the amount of work needing to be done to process. */ /* We'll always do resampling first. */ resamplerConfig = ma_linear_resampler_config_init(ma_format_f32, baseNodeConfig.pInputChannels[0], pEngineNode->sampleRate, ma_engine_get_sample_rate(pEngineNode->pEngine)); resamplerConfig.lpfOrder = 0; /* <-- Need to disable low-pass filtering for pitch shifting for now because there's cases where the biquads are becoming unstable. Need to figure out a better fix for this. */ result = ma_linear_resampler_init_preallocated(&resamplerConfig, ma_offset_ptr(pHeap, heapLayout.resamplerOffset), &pEngineNode->resampler); if (result != MA_SUCCESS) { goto error1; } /* After resampling will come the fader. */ faderConfig = ma_fader_config_init(ma_format_f32, baseNodeConfig.pInputChannels[0], ma_engine_get_sample_rate(pEngineNode->pEngine)); result = ma_fader_init(&faderConfig, &pEngineNode->fader); if (result != MA_SUCCESS) { goto error2; } /* Spatialization comes next. We spatialize based ont he node's output channel count. It's up the caller to ensure channels counts link up correctly in the node graph. */ spatializerConfig = ma_engine_node_spatializer_config_init(&baseNodeConfig); spatializerConfig.gainSmoothTimeInFrames = pEngineNode->pEngine->gainSmoothTimeInFrames; if (spatializerConfig.channelsIn == 2) { spatializerConfig.pChannelMapIn = defaultStereoChannelMap; } result = ma_spatializer_init_preallocated(&spatializerConfig, ma_offset_ptr(pHeap, heapLayout.spatializerOffset), &pEngineNode->spatializer); if (result != MA_SUCCESS) { goto error2; } /* After spatialization comes panning. We need to do this after spatialization because otherwise we wouldn't be able to pan mono sounds. */ pannerConfig = ma_panner_config_init(ma_format_f32, baseNodeConfig.pOutputChannels[0]); result = ma_panner_init(&pannerConfig, &pEngineNode->panner); if (result != MA_SUCCESS) { goto error3; } /* We'll need a gainer for smoothing out volume changes if we have a non-zero smooth time. We apply this before converting to the output channel count. */ if (pConfig->volumeSmoothTimeInPCMFrames > 0) { gainerConfig = ma_gainer_config_init(channelsIn, pConfig->volumeSmoothTimeInPCMFrames); result = ma_gainer_init_preallocated(&gainerConfig, ma_offset_ptr(pHeap, heapLayout.gainerOffset), &pEngineNode->volumeGainer); if (result != MA_SUCCESS) { goto error3; } } return MA_SUCCESS; /* No need for allocation callbacks here because we use a preallocated heap. */ error3: ma_spatializer_uninit(&pEngineNode->spatializer, NULL); error2: ma_linear_resampler_uninit(&pEngineNode->resampler, NULL); error1: ma_node_uninit(&pEngineNode->baseNode, NULL); error0: return result; } MA_API ma_result ma_engine_node_init(const ma_engine_node_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_engine_node* pEngineNode) { ma_result result; size_t heapSizeInBytes; void* pHeap; result = ma_engine_node_get_heap_size(pConfig, &heapSizeInBytes); if (result != MA_SUCCESS) { return result; } if (heapSizeInBytes > 0) { pHeap = ma_malloc(heapSizeInBytes, pAllocationCallbacks); if (pHeap == NULL) { return MA_OUT_OF_MEMORY; } } else { pHeap = NULL; } result = ma_engine_node_init_preallocated(pConfig, pHeap, pEngineNode); if (result != MA_SUCCESS) { ma_free(pHeap, pAllocationCallbacks); return result; } pEngineNode->_ownsHeap = MA_TRUE; return MA_SUCCESS; } MA_API void ma_engine_node_uninit(ma_engine_node* pEngineNode, const ma_allocation_callbacks* pAllocationCallbacks) { /* The base node always needs to be uninitialized first to ensure it's detached from the graph completely before we destroy anything that might be in the middle of being used by the processing function. */ ma_node_uninit(&pEngineNode->baseNode, pAllocationCallbacks); /* Now that the node has been uninitialized we can safely uninitialize the rest. */ if (pEngineNode->volumeSmoothTimeInPCMFrames > 0) { ma_gainer_uninit(&pEngineNode->volumeGainer, pAllocationCallbacks); } ma_spatializer_uninit(&pEngineNode->spatializer, pAllocationCallbacks); ma_linear_resampler_uninit(&pEngineNode->resampler, pAllocationCallbacks); /* Free the heap last. */ if (pEngineNode->_ownsHeap) { ma_free(pEngineNode->_pHeap, pAllocationCallbacks); } } MA_API ma_sound_config ma_sound_config_init(void) { return ma_sound_config_init_2(NULL); } MA_API ma_sound_config ma_sound_config_init_2(ma_engine* pEngine) { ma_sound_config config; MA_ZERO_OBJECT(&config); if (pEngine != NULL) { config.monoExpansionMode = pEngine->monoExpansionMode; } else { config.monoExpansionMode = ma_mono_expansion_mode_default; } config.rangeEndInPCMFrames = ~((ma_uint64)0); config.loopPointEndInPCMFrames = ~((ma_uint64)0); return config; } MA_API ma_sound_group_config ma_sound_group_config_init(void) { return ma_sound_group_config_init_2(NULL); } MA_API ma_sound_group_config ma_sound_group_config_init_2(ma_engine* pEngine) { ma_sound_group_config config; MA_ZERO_OBJECT(&config); if (pEngine != NULL) { config.monoExpansionMode = pEngine->monoExpansionMode; } else { config.monoExpansionMode = ma_mono_expansion_mode_default; } return config; } MA_API ma_engine_config ma_engine_config_init(void) { ma_engine_config config; MA_ZERO_OBJECT(&config); config.listenerCount = 1; /* Always want at least one listener. */ config.monoExpansionMode = ma_mono_expansion_mode_default; return config; } #if !defined(MA_NO_DEVICE_IO) static void ma_engine_data_callback_internal(ma_device* pDevice, void* pFramesOut, const void* pFramesIn, ma_uint32 frameCount) { ma_engine* pEngine = (ma_engine*)pDevice->pUserData; (void)pFramesIn; /* Experiment: Try processing a resource manager job if we're on the Emscripten build. This serves two purposes: 1) It ensures jobs are actually processed at some point since we cannot guarantee that the caller is doing the right thing and calling ma_resource_manager_process_next_job(); and 2) It's an attempt at working around an issue where processing jobs on the Emscripten main loop doesn't work as well as it should. When trying to load sounds without the `DECODE` flag or with the `ASYNC` flag, the sound data is just not able to be loaded in time before the callback is processed. I think it's got something to do with the single- threaded nature of Web, but I'm not entirely sure. */ #if !defined(MA_NO_RESOURCE_MANAGER) && defined(MA_EMSCRIPTEN) { if (pEngine->pResourceManager != NULL) { if ((pEngine->pResourceManager->config.flags & MA_RESOURCE_MANAGER_FLAG_NO_THREADING) != 0) { ma_resource_manager_process_next_job(pEngine->pResourceManager); } } } #endif ma_engine_read_pcm_frames(pEngine, pFramesOut, frameCount, NULL); } #endif MA_API ma_result ma_engine_init(const ma_engine_config* pConfig, ma_engine* pEngine) { ma_result result; ma_node_graph_config nodeGraphConfig; ma_engine_config engineConfig; ma_spatializer_listener_config listenerConfig; ma_uint32 iListener; if (pEngine == NULL) { return MA_INVALID_ARGS; } MA_ZERO_OBJECT(pEngine); /* The config is allowed to be NULL in which case we use defaults for everything. */ if (pConfig != NULL) { engineConfig = *pConfig; } else { engineConfig = ma_engine_config_init(); } pEngine->monoExpansionMode = engineConfig.monoExpansionMode; pEngine->defaultVolumeSmoothTimeInPCMFrames = engineConfig.defaultVolumeSmoothTimeInPCMFrames; pEngine->onProcess = engineConfig.onProcess; pEngine->pProcessUserData = engineConfig.pProcessUserData; ma_allocation_callbacks_init_copy(&pEngine->allocationCallbacks, &engineConfig.allocationCallbacks); #if !defined(MA_NO_RESOURCE_MANAGER) { pEngine->pResourceManager = engineConfig.pResourceManager; } #endif #if !defined(MA_NO_DEVICE_IO) { pEngine->pDevice = engineConfig.pDevice; /* If we don't have a device, we need one. */ if (pEngine->pDevice == NULL && engineConfig.noDevice == MA_FALSE) { ma_device_config deviceConfig; pEngine->pDevice = (ma_device*)ma_malloc(sizeof(*pEngine->pDevice), &pEngine->allocationCallbacks); if (pEngine->pDevice == NULL) { return MA_OUT_OF_MEMORY; } deviceConfig = ma_device_config_init(ma_device_type_playback); deviceConfig.playback.pDeviceID = engineConfig.pPlaybackDeviceID; deviceConfig.playback.format = ma_format_f32; deviceConfig.playback.channels = engineConfig.channels; deviceConfig.sampleRate = engineConfig.sampleRate; deviceConfig.dataCallback = (engineConfig.dataCallback != NULL) ? engineConfig.dataCallback : ma_engine_data_callback_internal; deviceConfig.pUserData = pEngine; deviceConfig.notificationCallback = engineConfig.notificationCallback; deviceConfig.periodSizeInFrames = engineConfig.periodSizeInFrames; deviceConfig.periodSizeInMilliseconds = engineConfig.periodSizeInMilliseconds; deviceConfig.noPreSilencedOutputBuffer = MA_TRUE; /* We'll always be outputting to every frame in the callback so there's no need for a pre-silenced buffer. */ deviceConfig.noClip = MA_TRUE; /* The engine will do clipping itself. */ if (engineConfig.pContext == NULL) { ma_context_config contextConfig = ma_context_config_init(); contextConfig.allocationCallbacks = pEngine->allocationCallbacks; contextConfig.pLog = engineConfig.pLog; /* If the engine config does not specify a log, use the resource manager's if we have one. */ #ifndef MA_NO_RESOURCE_MANAGER { if (contextConfig.pLog == NULL && engineConfig.pResourceManager != NULL) { contextConfig.pLog = ma_resource_manager_get_log(engineConfig.pResourceManager); } } #endif result = ma_device_init_ex(NULL, 0, &contextConfig, &deviceConfig, pEngine->pDevice); } else { result = ma_device_init(engineConfig.pContext, &deviceConfig, pEngine->pDevice); } if (result != MA_SUCCESS) { ma_free(pEngine->pDevice, &pEngine->allocationCallbacks); pEngine->pDevice = NULL; return result; } pEngine->ownsDevice = MA_TRUE; } /* Update the channel count and sample rate of the engine config so we can reference it below. */ if (pEngine->pDevice != NULL) { engineConfig.channels = pEngine->pDevice->playback.channels; engineConfig.sampleRate = pEngine->pDevice->sampleRate; } } #endif if (engineConfig.channels == 0 || engineConfig.sampleRate == 0) { return MA_INVALID_ARGS; } pEngine->sampleRate = engineConfig.sampleRate; /* The engine always uses either the log that was passed into the config, or the context's log is available. */ if (engineConfig.pLog != NULL) { pEngine->pLog = engineConfig.pLog; } else { #if !defined(MA_NO_DEVICE_IO) { pEngine->pLog = ma_device_get_log(pEngine->pDevice); } #else { pEngine->pLog = NULL; } #endif } /* The engine is a node graph. This needs to be initialized after we have the device so we can can determine the channel count. */ nodeGraphConfig = ma_node_graph_config_init(engineConfig.channels); nodeGraphConfig.nodeCacheCapInFrames = (engineConfig.periodSizeInFrames > 0xFFFF) ? 0xFFFF : (ma_uint16)engineConfig.periodSizeInFrames; result = ma_node_graph_init(&nodeGraphConfig, &pEngine->allocationCallbacks, &pEngine->nodeGraph); if (result != MA_SUCCESS) { goto on_error_1; } /* We need at least one listener. */ if (engineConfig.listenerCount == 0) { engineConfig.listenerCount = 1; } if (engineConfig.listenerCount > MA_ENGINE_MAX_LISTENERS) { result = MA_INVALID_ARGS; /* Too many listeners. */ goto on_error_1; } for (iListener = 0; iListener < engineConfig.listenerCount; iListener += 1) { listenerConfig = ma_spatializer_listener_config_init(ma_node_graph_get_channels(&pEngine->nodeGraph)); /* If we're using a device, use the device's channel map for the listener. Otherwise just use miniaudio's default channel map. */ #if !defined(MA_NO_DEVICE_IO) { if (pEngine->pDevice != NULL) { /* Temporarily disabled. There is a subtle bug here where front-left and front-right will be used by the device's channel map, but this is not what we want to use for spatialization. Instead we want to use side-left and side-right. I need to figure out a better solution for this. For now, disabling the use of device channel maps. */ /*listenerConfig.pChannelMapOut = pEngine->pDevice->playback.channelMap;*/ } } #endif result = ma_spatializer_listener_init(&listenerConfig, &pEngine->allocationCallbacks, &pEngine->listeners[iListener]); /* TODO: Change this to a pre-allocated heap. */ if (result != MA_SUCCESS) { goto on_error_2; } pEngine->listenerCount += 1; } /* Gain smoothing for spatialized sounds. */ pEngine->gainSmoothTimeInFrames = engineConfig.gainSmoothTimeInFrames; if (pEngine->gainSmoothTimeInFrames == 0) { ma_uint32 gainSmoothTimeInMilliseconds = engineConfig.gainSmoothTimeInMilliseconds; if (gainSmoothTimeInMilliseconds == 0) { gainSmoothTimeInMilliseconds = 8; } pEngine->gainSmoothTimeInFrames = (gainSmoothTimeInMilliseconds * ma_engine_get_sample_rate(pEngine)) / 1000; /* 8ms by default. */ } /* We need a resource manager. */ #ifndef MA_NO_RESOURCE_MANAGER { if (pEngine->pResourceManager == NULL) { ma_resource_manager_config resourceManagerConfig; pEngine->pResourceManager = (ma_resource_manager*)ma_malloc(sizeof(*pEngine->pResourceManager), &pEngine->allocationCallbacks); if (pEngine->pResourceManager == NULL) { result = MA_OUT_OF_MEMORY; goto on_error_2; } resourceManagerConfig = ma_resource_manager_config_init(); resourceManagerConfig.pLog = pEngine->pLog; /* Always use the engine's log for internally-managed resource managers. */ resourceManagerConfig.decodedFormat = ma_format_f32; resourceManagerConfig.decodedChannels = 0; /* Leave the decoded channel count as 0 so we can get good spatialization. */ resourceManagerConfig.decodedSampleRate = ma_engine_get_sample_rate(pEngine); ma_allocation_callbacks_init_copy(&resourceManagerConfig.allocationCallbacks, &pEngine->allocationCallbacks); resourceManagerConfig.pVFS = engineConfig.pResourceManagerVFS; /* The Emscripten build cannot use threads. */ #if defined(MA_EMSCRIPTEN) { resourceManagerConfig.jobThreadCount = 0; resourceManagerConfig.flags |= MA_RESOURCE_MANAGER_FLAG_NO_THREADING; } #endif result = ma_resource_manager_init(&resourceManagerConfig, pEngine->pResourceManager); if (result != MA_SUCCESS) { goto on_error_3; } pEngine->ownsResourceManager = MA_TRUE; } } #endif /* Setup some stuff for inlined sounds. That is sounds played with ma_engine_play_sound(). */ pEngine->inlinedSoundLock = 0; pEngine->pInlinedSoundHead = NULL; /* Start the engine if required. This should always be the last step. */ #if !defined(MA_NO_DEVICE_IO) { if (engineConfig.noAutoStart == MA_FALSE && pEngine->pDevice != NULL) { result = ma_engine_start(pEngine); if (result != MA_SUCCESS) { goto on_error_4; /* Failed to start the engine. */ } } } #endif return MA_SUCCESS; #if !defined(MA_NO_DEVICE_IO) on_error_4: #endif #if !defined(MA_NO_RESOURCE_MANAGER) on_error_3: if (pEngine->ownsResourceManager) { ma_free(pEngine->pResourceManager, &pEngine->allocationCallbacks); } #endif /* MA_NO_RESOURCE_MANAGER */ on_error_2: for (iListener = 0; iListener < pEngine->listenerCount; iListener += 1) { ma_spatializer_listener_uninit(&pEngine->listeners[iListener], &pEngine->allocationCallbacks); } ma_node_graph_uninit(&pEngine->nodeGraph, &pEngine->allocationCallbacks); on_error_1: #if !defined(MA_NO_DEVICE_IO) { if (pEngine->ownsDevice) { ma_device_uninit(pEngine->pDevice); ma_free(pEngine->pDevice, &pEngine->allocationCallbacks); } } #endif return result; } MA_API void ma_engine_uninit(ma_engine* pEngine) { ma_uint32 iListener; if (pEngine == NULL) { return; } /* The device must be uninitialized before the node graph to ensure the audio thread doesn't try accessing it. */ #if !defined(MA_NO_DEVICE_IO) { if (pEngine->ownsDevice) { ma_device_uninit(pEngine->pDevice); ma_free(pEngine->pDevice, &pEngine->allocationCallbacks); } else { if (pEngine->pDevice != NULL) { ma_device_stop(pEngine->pDevice); } } } #endif /* All inlined sounds need to be deleted. I'm going to use a lock here just to future proof in case I want to do some kind of garbage collection later on. */ ma_spinlock_lock(&pEngine->inlinedSoundLock); { for (;;) { ma_sound_inlined* pSoundToDelete = pEngine->pInlinedSoundHead; if (pSoundToDelete == NULL) { break; /* Done. */ } pEngine->pInlinedSoundHead = pSoundToDelete->pNext; ma_sound_uninit(&pSoundToDelete->sound); ma_free(pSoundToDelete, &pEngine->allocationCallbacks); } } ma_spinlock_unlock(&pEngine->inlinedSoundLock); for (iListener = 0; iListener < pEngine->listenerCount; iListener += 1) { ma_spatializer_listener_uninit(&pEngine->listeners[iListener], &pEngine->allocationCallbacks); } /* Make sure the node graph is uninitialized after the audio thread has been shutdown to prevent accessing of the node graph after being uninitialized. */ ma_node_graph_uninit(&pEngine->nodeGraph, &pEngine->allocationCallbacks); /* Uninitialize the resource manager last to ensure we don't have a thread still trying to access it. */ #ifndef MA_NO_RESOURCE_MANAGER if (pEngine->ownsResourceManager) { ma_resource_manager_uninit(pEngine->pResourceManager); ma_free(pEngine->pResourceManager, &pEngine->allocationCallbacks); } #endif } MA_API ma_result ma_engine_read_pcm_frames(ma_engine* pEngine, void* pFramesOut, ma_uint64 frameCount, ma_uint64* pFramesRead) { ma_result result; ma_uint64 framesRead = 0; if (pFramesRead != NULL) { *pFramesRead = 0; } result = ma_node_graph_read_pcm_frames(&pEngine->nodeGraph, pFramesOut, frameCount, &framesRead); if (result != MA_SUCCESS) { return result; } if (pFramesRead != NULL) { *pFramesRead = framesRead; } if (pEngine->onProcess) { pEngine->onProcess(pEngine->pProcessUserData, (float*)pFramesOut, framesRead); /* Safe cast to float* because the engine always works on floating point samples. */ } return MA_SUCCESS; } MA_API ma_node_graph* ma_engine_get_node_graph(ma_engine* pEngine) { if (pEngine == NULL) { return NULL; } return &pEngine->nodeGraph; } #if !defined(MA_NO_RESOURCE_MANAGER) MA_API ma_resource_manager* ma_engine_get_resource_manager(ma_engine* pEngine) { if (pEngine == NULL) { return NULL; } #if !defined(MA_NO_RESOURCE_MANAGER) { return pEngine->pResourceManager; } #else { return NULL; } #endif } #endif MA_API ma_device* ma_engine_get_device(ma_engine* pEngine) { if (pEngine == NULL) { return NULL; } #if !defined(MA_NO_DEVICE_IO) { return pEngine->pDevice; } #else { return NULL; } #endif } MA_API ma_log* ma_engine_get_log(ma_engine* pEngine) { if (pEngine == NULL) { return NULL; } if (pEngine->pLog != NULL) { return pEngine->pLog; } else { #if !defined(MA_NO_DEVICE_IO) { return ma_device_get_log(ma_engine_get_device(pEngine)); } #else { return NULL; } #endif } } MA_API ma_node* ma_engine_get_endpoint(ma_engine* pEngine) { return ma_node_graph_get_endpoint(&pEngine->nodeGraph); } MA_API ma_uint64 ma_engine_get_time_in_pcm_frames(const ma_engine* pEngine) { return ma_node_graph_get_time(&pEngine->nodeGraph); } MA_API ma_uint64 ma_engine_get_time_in_milliseconds(const ma_engine* pEngine) { return ma_engine_get_time_in_pcm_frames(pEngine) * 1000 / ma_engine_get_sample_rate(pEngine); } MA_API ma_result ma_engine_set_time_in_pcm_frames(ma_engine* pEngine, ma_uint64 globalTime) { return ma_node_graph_set_time(&pEngine->nodeGraph, globalTime); } MA_API ma_result ma_engine_set_time_in_milliseconds(ma_engine* pEngine, ma_uint64 globalTime) { return ma_engine_set_time_in_pcm_frames(pEngine, globalTime * ma_engine_get_sample_rate(pEngine) / 1000); } MA_API ma_uint64 ma_engine_get_time(const ma_engine* pEngine) { return ma_engine_get_time_in_pcm_frames(pEngine); } MA_API ma_result ma_engine_set_time(ma_engine* pEngine, ma_uint64 globalTime) { return ma_engine_set_time_in_pcm_frames(pEngine, globalTime); } MA_API ma_uint32 ma_engine_get_channels(const ma_engine* pEngine) { return ma_node_graph_get_channels(&pEngine->nodeGraph); } MA_API ma_uint32 ma_engine_get_sample_rate(const ma_engine* pEngine) { if (pEngine == NULL) { return 0; } return pEngine->sampleRate; } MA_API ma_result ma_engine_start(ma_engine* pEngine) { ma_result result; if (pEngine == NULL) { return MA_INVALID_ARGS; } #if !defined(MA_NO_DEVICE_IO) { if (pEngine->pDevice != NULL) { result = ma_device_start(pEngine->pDevice); } else { result = MA_INVALID_OPERATION; /* The engine is running without a device which means there's no real notion of "starting" the engine. */ } } #else { result = MA_INVALID_OPERATION; /* Device IO is disabled, so there's no real notion of "starting" the engine. */ } #endif if (result != MA_SUCCESS) { return result; } return MA_SUCCESS; } MA_API ma_result ma_engine_stop(ma_engine* pEngine) { ma_result result; if (pEngine == NULL) { return MA_INVALID_ARGS; } #if !defined(MA_NO_DEVICE_IO) { if (pEngine->pDevice != NULL) { result = ma_device_stop(pEngine->pDevice); } else { result = MA_INVALID_OPERATION; /* The engine is running without a device which means there's no real notion of "stopping" the engine. */ } } #else { result = MA_INVALID_OPERATION; /* Device IO is disabled, so there's no real notion of "stopping" the engine. */ } #endif if (result != MA_SUCCESS) { return result; } return MA_SUCCESS; } MA_API ma_result ma_engine_set_volume(ma_engine* pEngine, float volume) { if (pEngine == NULL) { return MA_INVALID_ARGS; } return ma_node_set_output_bus_volume(ma_node_graph_get_endpoint(&pEngine->nodeGraph), 0, volume); } MA_API float ma_engine_get_volume(ma_engine* pEngine) { if (pEngine == NULL) { return 0; } return ma_node_get_output_bus_volume(ma_node_graph_get_endpoint(&pEngine->nodeGraph), 0); } MA_API ma_result ma_engine_set_gain_db(ma_engine* pEngine, float gainDB) { return ma_engine_set_volume(pEngine, ma_volume_db_to_linear(gainDB)); } MA_API float ma_engine_get_gain_db(ma_engine* pEngine) { return ma_volume_linear_to_db(ma_engine_get_volume(pEngine)); } MA_API ma_uint32 ma_engine_get_listener_count(const ma_engine* pEngine) { if (pEngine == NULL) { return 0; } return pEngine->listenerCount; } MA_API ma_uint32 ma_engine_find_closest_listener(const ma_engine* pEngine, float absolutePosX, float absolutePosY, float absolutePosZ) { ma_uint32 iListener; ma_uint32 iListenerClosest; float closestLen2 = MA_FLT_MAX; if (pEngine == NULL || pEngine->listenerCount == 1) { return 0; } iListenerClosest = 0; for (iListener = 0; iListener < pEngine->listenerCount; iListener += 1) { if (ma_engine_listener_is_enabled(pEngine, iListener)) { float len2 = ma_vec3f_len2(ma_vec3f_sub(ma_spatializer_listener_get_position(&pEngine->listeners[iListener]), ma_vec3f_init_3f(absolutePosX, absolutePosY, absolutePosZ))); if (closestLen2 > len2) { closestLen2 = len2; iListenerClosest = iListener; } } } MA_ASSERT(iListenerClosest < 255); return iListenerClosest; } MA_API void ma_engine_listener_set_position(ma_engine* pEngine, ma_uint32 listenerIndex, float x, float y, float z) { if (pEngine == NULL || listenerIndex >= pEngine->listenerCount) { return; } ma_spatializer_listener_set_position(&pEngine->listeners[listenerIndex], x, y, z); } MA_API ma_vec3f ma_engine_listener_get_position(const ma_engine* pEngine, ma_uint32 listenerIndex) { if (pEngine == NULL || listenerIndex >= pEngine->listenerCount) { return ma_vec3f_init_3f(0, 0, 0); } return ma_spatializer_listener_get_position(&pEngine->listeners[listenerIndex]); } MA_API void ma_engine_listener_set_direction(ma_engine* pEngine, ma_uint32 listenerIndex, float x, float y, float z) { if (pEngine == NULL || listenerIndex >= pEngine->listenerCount) { return; } ma_spatializer_listener_set_direction(&pEngine->listeners[listenerIndex], x, y, z); } MA_API ma_vec3f ma_engine_listener_get_direction(const ma_engine* pEngine, ma_uint32 listenerIndex) { if (pEngine == NULL || listenerIndex >= pEngine->listenerCount) { return ma_vec3f_init_3f(0, 0, -1); } return ma_spatializer_listener_get_direction(&pEngine->listeners[listenerIndex]); } MA_API void ma_engine_listener_set_velocity(ma_engine* pEngine, ma_uint32 listenerIndex, float x, float y, float z) { if (pEngine == NULL || listenerIndex >= pEngine->listenerCount) { return; } ma_spatializer_listener_set_velocity(&pEngine->listeners[listenerIndex], x, y, z); } MA_API ma_vec3f ma_engine_listener_get_velocity(const ma_engine* pEngine, ma_uint32 listenerIndex) { if (pEngine == NULL || listenerIndex >= pEngine->listenerCount) { return ma_vec3f_init_3f(0, 0, 0); } return ma_spatializer_listener_get_velocity(&pEngine->listeners[listenerIndex]); } MA_API void ma_engine_listener_set_cone(ma_engine* pEngine, ma_uint32 listenerIndex, float innerAngleInRadians, float outerAngleInRadians, float outerGain) { if (pEngine == NULL || listenerIndex >= pEngine->listenerCount) { return; } ma_spatializer_listener_set_cone(&pEngine->listeners[listenerIndex], innerAngleInRadians, outerAngleInRadians, outerGain); } MA_API void ma_engine_listener_get_cone(const ma_engine* pEngine, ma_uint32 listenerIndex, float* pInnerAngleInRadians, float* pOuterAngleInRadians, float* pOuterGain) { if (pInnerAngleInRadians != NULL) { *pInnerAngleInRadians = 0; } if (pOuterAngleInRadians != NULL) { *pOuterAngleInRadians = 0; } if (pOuterGain != NULL) { *pOuterGain = 0; } if (pEngine == NULL || listenerIndex >= pEngine->listenerCount) { return; } ma_spatializer_listener_get_cone(&pEngine->listeners[listenerIndex], pInnerAngleInRadians, pOuterAngleInRadians, pOuterGain); } MA_API void ma_engine_listener_set_world_up(ma_engine* pEngine, ma_uint32 listenerIndex, float x, float y, float z) { if (pEngine == NULL || listenerIndex >= pEngine->listenerCount) { return; } ma_spatializer_listener_set_world_up(&pEngine->listeners[listenerIndex], x, y, z); } MA_API ma_vec3f ma_engine_listener_get_world_up(const ma_engine* pEngine, ma_uint32 listenerIndex) { if (pEngine == NULL || listenerIndex >= pEngine->listenerCount) { return ma_vec3f_init_3f(0, 1, 0); } return ma_spatializer_listener_get_world_up(&pEngine->listeners[listenerIndex]); } MA_API void ma_engine_listener_set_enabled(ma_engine* pEngine, ma_uint32 listenerIndex, ma_bool32 isEnabled) { if (pEngine == NULL || listenerIndex >= pEngine->listenerCount) { return; } ma_spatializer_listener_set_enabled(&pEngine->listeners[listenerIndex], isEnabled); } MA_API ma_bool32 ma_engine_listener_is_enabled(const ma_engine* pEngine, ma_uint32 listenerIndex) { if (pEngine == NULL || listenerIndex >= pEngine->listenerCount) { return MA_FALSE; } return ma_spatializer_listener_is_enabled(&pEngine->listeners[listenerIndex]); } #ifndef MA_NO_RESOURCE_MANAGER MA_API ma_result ma_engine_play_sound_ex(ma_engine* pEngine, const char* pFilePath, ma_node* pNode, ma_uint32 nodeInputBusIndex) { ma_result result = MA_SUCCESS; ma_sound_inlined* pSound = NULL; ma_sound_inlined* pNextSound = NULL; if (pEngine == NULL || pFilePath == NULL) { return MA_INVALID_ARGS; } /* Attach to the endpoint node if nothing is specicied. */ if (pNode == NULL) { pNode = ma_node_graph_get_endpoint(&pEngine->nodeGraph); nodeInputBusIndex = 0; } /* We want to check if we can recycle an already-allocated inlined sound. Since this is just a helper I'm not *too* concerned about performance here and I'm happy to use a lock to keep the implementation simple. Maybe this can be optimized later if there's enough demand, but if this function is being used it probably means the caller doesn't really care too much. What we do is check the atEnd flag. When this is true, we can recycle the sound. Otherwise we just keep iterating. If we reach the end without finding a sound to recycle we just allocate a new one. This doesn't scale well for a massive number of sounds being played simultaneously as we don't ever actually free the sound objects. Some kind of garbage collection routine might be valuable for this which I'll think about. */ ma_spinlock_lock(&pEngine->inlinedSoundLock); { ma_uint32 soundFlags = 0; for (pNextSound = pEngine->pInlinedSoundHead; pNextSound != NULL; pNextSound = pNextSound->pNext) { if (ma_sound_at_end(&pNextSound->sound)) { /* The sound is at the end which means it's available for recycling. All we need to do is uninitialize it and reinitialize it. All we're doing is recycling memory. */ pSound = pNextSound; ma_atomic_fetch_sub_32(&pEngine->inlinedSoundCount, 1); break; } } if (pSound != NULL) { /* We actually want to detach the sound from the list here. The reason is because we want the sound to be in a consistent state at the non-recycled case to simplify the logic below. */ if (pEngine->pInlinedSoundHead == pSound) { pEngine->pInlinedSoundHead = pSound->pNext; } if (pSound->pPrev != NULL) { pSound->pPrev->pNext = pSound->pNext; } if (pSound->pNext != NULL) { pSound->pNext->pPrev = pSound->pPrev; } /* Now the previous sound needs to be uninitialized. */ ma_sound_uninit(&pNextSound->sound); } else { /* No sound available for recycling. Allocate one now. */ pSound = (ma_sound_inlined*)ma_malloc(sizeof(*pSound), &pEngine->allocationCallbacks); } if (pSound != NULL) { /* Safety check for the allocation above. */ /* At this point we should have memory allocated for the inlined sound. We just need to initialize it like a normal sound now. */ soundFlags |= MA_SOUND_FLAG_ASYNC; /* For inlined sounds we don't want to be sitting around waiting for stuff to load so force an async load. */ soundFlags |= MA_SOUND_FLAG_NO_DEFAULT_ATTACHMENT; /* We want specific control over where the sound is attached in the graph. We'll attach it manually just before playing the sound. */ soundFlags |= MA_SOUND_FLAG_NO_PITCH; /* Pitching isn't usable with inlined sounds, so disable it to save on speed. */ soundFlags |= MA_SOUND_FLAG_NO_SPATIALIZATION; /* Not currently doing spatialization with inlined sounds, but this might actually change later. For now disable spatialization. Will be removed if we ever add support for spatialization here. */ result = ma_sound_init_from_file(pEngine, pFilePath, soundFlags, NULL, NULL, &pSound->sound); if (result == MA_SUCCESS) { /* Now attach the sound to the graph. */ result = ma_node_attach_output_bus(pSound, 0, pNode, nodeInputBusIndex); if (result == MA_SUCCESS) { /* At this point the sound should be loaded and we can go ahead and add it to the list. The new item becomes the new head. */ pSound->pNext = pEngine->pInlinedSoundHead; pSound->pPrev = NULL; pEngine->pInlinedSoundHead = pSound; /* <-- This is what attaches the sound to the list. */ if (pSound->pNext != NULL) { pSound->pNext->pPrev = pSound; } } else { ma_free(pSound, &pEngine->allocationCallbacks); } } else { ma_free(pSound, &pEngine->allocationCallbacks); } } else { result = MA_OUT_OF_MEMORY; } } ma_spinlock_unlock(&pEngine->inlinedSoundLock); if (result != MA_SUCCESS) { return result; } /* Finally we can start playing the sound. */ result = ma_sound_start(&pSound->sound); if (result != MA_SUCCESS) { /* Failed to start the sound. We need to mark it for recycling and return an error. */ ma_atomic_exchange_32(&pSound->sound.atEnd, MA_TRUE); return result; } ma_atomic_fetch_add_32(&pEngine->inlinedSoundCount, 1); return result; } MA_API ma_result ma_engine_play_sound(ma_engine* pEngine, const char* pFilePath, ma_sound_group* pGroup) { return ma_engine_play_sound_ex(pEngine, pFilePath, pGroup, 0); } #endif static ma_result ma_sound_preinit(ma_engine* pEngine, ma_sound* pSound) { if (pSound == NULL) { return MA_INVALID_ARGS; } MA_ZERO_OBJECT(pSound); pSound->seekTarget = MA_SEEK_TARGET_NONE; if (pEngine == NULL) { return MA_INVALID_ARGS; } return MA_SUCCESS; } static ma_result ma_sound_init_from_data_source_internal(ma_engine* pEngine, const ma_sound_config* pConfig, ma_sound* pSound) { ma_result result; ma_engine_node_config engineNodeConfig; ma_engine_node_type type; /* Will be set to ma_engine_node_type_group if no data source is specified. */ /* Do not clear pSound to zero here - that's done at a higher level with ma_sound_preinit(). */ MA_ASSERT(pEngine != NULL); MA_ASSERT(pSound != NULL); if (pConfig == NULL) { return MA_INVALID_ARGS; } pSound->pDataSource = pConfig->pDataSource; if (pConfig->pDataSource != NULL) { type = ma_engine_node_type_sound; } else { type = ma_engine_node_type_group; } /* Sounds are engine nodes. Before we can initialize this we need to determine the channel count. If we can't do this we need to abort. It's up to the caller to ensure they're using a data source that provides this information upfront. */ engineNodeConfig = ma_engine_node_config_init(pEngine, type, pConfig->flags); engineNodeConfig.channelsIn = pConfig->channelsIn; engineNodeConfig.channelsOut = pConfig->channelsOut; engineNodeConfig.volumeSmoothTimeInPCMFrames = pConfig->volumeSmoothTimeInPCMFrames; engineNodeConfig.monoExpansionMode = pConfig->monoExpansionMode; if (engineNodeConfig.volumeSmoothTimeInPCMFrames == 0) { engineNodeConfig.volumeSmoothTimeInPCMFrames = pEngine->defaultVolumeSmoothTimeInPCMFrames; } /* If we're loading from a data source the input channel count needs to be the data source's native channel count. */ if (pConfig->pDataSource != NULL) { result = ma_data_source_get_data_format(pConfig->pDataSource, NULL, &engineNodeConfig.channelsIn, &engineNodeConfig.sampleRate, NULL, 0); if (result != MA_SUCCESS) { return result; /* Failed to retrieve the channel count. */ } if (engineNodeConfig.channelsIn == 0) { return MA_INVALID_OPERATION; /* Invalid channel count. */ } if (engineNodeConfig.channelsOut == MA_SOUND_SOURCE_CHANNEL_COUNT) { engineNodeConfig.channelsOut = engineNodeConfig.channelsIn; } } /* Getting here means we should have a valid channel count and we can initialize the engine node. */ result = ma_engine_node_init(&engineNodeConfig, &pEngine->allocationCallbacks, &pSound->engineNode); if (result != MA_SUCCESS) { return result; } /* If no attachment is specified, attach the sound straight to the endpoint. */ if (pConfig->pInitialAttachment == NULL) { /* No group. Attach straight to the endpoint by default, unless the caller has requested that it not. */ if ((pConfig->flags & MA_SOUND_FLAG_NO_DEFAULT_ATTACHMENT) == 0) { result = ma_node_attach_output_bus(pSound, 0, ma_node_graph_get_endpoint(&pEngine->nodeGraph), 0); } } else { /* An attachment is specified. Attach to it by default. The sound has only a single output bus, and the config will specify which input bus to attach to. */ result = ma_node_attach_output_bus(pSound, 0, pConfig->pInitialAttachment, pConfig->initialAttachmentInputBusIndex); } if (result != MA_SUCCESS) { ma_engine_node_uninit(&pSound->engineNode, &pEngine->allocationCallbacks); return result; } /* Apply initial range and looping state to the data source if applicable. */ if (pConfig->rangeBegInPCMFrames != 0 || pConfig->rangeEndInPCMFrames != ~((ma_uint64)0)) { ma_data_source_set_range_in_pcm_frames(ma_sound_get_data_source(pSound), pConfig->rangeBegInPCMFrames, pConfig->rangeEndInPCMFrames); } if (pConfig->loopPointBegInPCMFrames != 0 || pConfig->loopPointEndInPCMFrames != ~((ma_uint64)0)) { ma_data_source_set_range_in_pcm_frames(ma_sound_get_data_source(pSound), pConfig->loopPointBegInPCMFrames, pConfig->loopPointEndInPCMFrames); } ma_sound_set_looping(pSound, pConfig->isLooping); return MA_SUCCESS; } #ifndef MA_NO_RESOURCE_MANAGER MA_API ma_result ma_sound_init_from_file_internal(ma_engine* pEngine, const ma_sound_config* pConfig, ma_sound* pSound) { ma_result result = MA_SUCCESS; ma_uint32 flags; ma_sound_config config; ma_resource_manager_pipeline_notifications notifications; /* The engine requires knowledge of the channel count of the underlying data source before it can initialize the sound. Therefore, we need to make the resource manager wait until initialization of the underlying data source to be initialized so we can get access to the channel count. To do this, the MA_RESOURCE_MANAGER_DATA_SOURCE_FLAG_WAIT_INIT is forced. Because we're initializing the data source before the sound, there's a chance the notification will get triggered before this function returns. This is OK, so long as the caller is aware of it and can avoid accessing the sound from within the notification. */ flags = pConfig->flags | MA_RESOURCE_MANAGER_DATA_SOURCE_FLAG_WAIT_INIT; pSound->pResourceManagerDataSource = (ma_resource_manager_data_source*)ma_malloc(sizeof(*pSound->pResourceManagerDataSource), &pEngine->allocationCallbacks); if (pSound->pResourceManagerDataSource == NULL) { return MA_OUT_OF_MEMORY; } /* Removed in 0.12. Set pDoneFence on the notifications. */ notifications = pConfig->initNotifications; if (pConfig->pDoneFence != NULL && notifications.done.pFence == NULL) { notifications.done.pFence = pConfig->pDoneFence; } /* We must wrap everything around the fence if one was specified. This ensures ma_fence_wait() does not return prematurely before the sound has finished initializing. */ if (notifications.done.pFence) { ma_fence_acquire(notifications.done.pFence); } { ma_resource_manager_data_source_config resourceManagerDataSourceConfig = ma_resource_manager_data_source_config_init(); resourceManagerDataSourceConfig.pFilePath = pConfig->pFilePath; resourceManagerDataSourceConfig.pFilePathW = pConfig->pFilePathW; resourceManagerDataSourceConfig.flags = flags; resourceManagerDataSourceConfig.pNotifications = ¬ifications; resourceManagerDataSourceConfig.initialSeekPointInPCMFrames = pConfig->initialSeekPointInPCMFrames; resourceManagerDataSourceConfig.rangeBegInPCMFrames = pConfig->rangeBegInPCMFrames; resourceManagerDataSourceConfig.rangeEndInPCMFrames = pConfig->rangeEndInPCMFrames; resourceManagerDataSourceConfig.loopPointBegInPCMFrames = pConfig->loopPointBegInPCMFrames; resourceManagerDataSourceConfig.loopPointEndInPCMFrames = pConfig->loopPointEndInPCMFrames; resourceManagerDataSourceConfig.isLooping = pConfig->isLooping; result = ma_resource_manager_data_source_init_ex(pEngine->pResourceManager, &resourceManagerDataSourceConfig, pSound->pResourceManagerDataSource); if (result != MA_SUCCESS) { goto done; } pSound->ownsDataSource = MA_TRUE; /* <-- Important. Not setting this will result in the resource manager data source never getting uninitialized. */ /* We need to use a slightly customized version of the config so we'll need to make a copy. */ config = *pConfig; config.pFilePath = NULL; config.pFilePathW = NULL; config.pDataSource = pSound->pResourceManagerDataSource; result = ma_sound_init_from_data_source_internal(pEngine, &config, pSound); if (result != MA_SUCCESS) { ma_resource_manager_data_source_uninit(pSound->pResourceManagerDataSource); ma_free(pSound->pResourceManagerDataSource, &pEngine->allocationCallbacks); MA_ZERO_OBJECT(pSound); goto done; } } done: if (notifications.done.pFence) { ma_fence_release(notifications.done.pFence); } return result; } MA_API ma_result ma_sound_init_from_file(ma_engine* pEngine, const char* pFilePath, ma_uint32 flags, ma_sound_group* pGroup, ma_fence* pDoneFence, ma_sound* pSound) { ma_sound_config config; if (pFilePath == NULL) { return MA_INVALID_ARGS; } config = ma_sound_config_init_2(pEngine); config.pFilePath = pFilePath; config.flags = flags; config.pInitialAttachment = pGroup; config.pDoneFence = pDoneFence; return ma_sound_init_ex(pEngine, &config, pSound); } MA_API ma_result ma_sound_init_from_file_w(ma_engine* pEngine, const wchar_t* pFilePath, ma_uint32 flags, ma_sound_group* pGroup, ma_fence* pDoneFence, ma_sound* pSound) { ma_sound_config config; if (pFilePath == NULL) { return MA_INVALID_ARGS; } config = ma_sound_config_init_2(pEngine); config.pFilePathW = pFilePath; config.flags = flags; config.pInitialAttachment = pGroup; config.pDoneFence = pDoneFence; return ma_sound_init_ex(pEngine, &config, pSound); } MA_API ma_result ma_sound_init_copy(ma_engine* pEngine, const ma_sound* pExistingSound, ma_uint32 flags, ma_sound_group* pGroup, ma_sound* pSound) { ma_result result; ma_sound_config config; result = ma_sound_preinit(pEngine, pSound); if (result != MA_SUCCESS) { return result; } if (pExistingSound == NULL) { return MA_INVALID_ARGS; } /* Cloning only works for data buffers (not streams) that are loaded from the resource manager. */ if (pExistingSound->pResourceManagerDataSource == NULL) { return MA_INVALID_OPERATION; } /* We need to make a clone of the data source. If the data source is not a data buffer (i.e. a stream) this will fail. */ pSound->pResourceManagerDataSource = (ma_resource_manager_data_source*)ma_malloc(sizeof(*pSound->pResourceManagerDataSource), &pEngine->allocationCallbacks); if (pSound->pResourceManagerDataSource == NULL) { return MA_OUT_OF_MEMORY; } result = ma_resource_manager_data_source_init_copy(pEngine->pResourceManager, pExistingSound->pResourceManagerDataSource, pSound->pResourceManagerDataSource); if (result != MA_SUCCESS) { ma_free(pSound->pResourceManagerDataSource, &pEngine->allocationCallbacks); return result; } config = ma_sound_config_init_2(pEngine); config.pDataSource = pSound->pResourceManagerDataSource; config.flags = flags; config.pInitialAttachment = pGroup; config.monoExpansionMode = pExistingSound->engineNode.monoExpansionMode; config.volumeSmoothTimeInPCMFrames = pExistingSound->engineNode.volumeSmoothTimeInPCMFrames; result = ma_sound_init_from_data_source_internal(pEngine, &config, pSound); if (result != MA_SUCCESS) { ma_resource_manager_data_source_uninit(pSound->pResourceManagerDataSource); ma_free(pSound->pResourceManagerDataSource, &pEngine->allocationCallbacks); MA_ZERO_OBJECT(pSound); return result; } /* Make sure the sound is marked as the owner of the data source or else it will never get uninitialized. */ pSound->ownsDataSource = MA_TRUE; return MA_SUCCESS; } #endif MA_API ma_result ma_sound_init_from_data_source(ma_engine* pEngine, ma_data_source* pDataSource, ma_uint32 flags, ma_sound_group* pGroup, ma_sound* pSound) { ma_sound_config config = ma_sound_config_init_2(pEngine); config.pDataSource = pDataSource; config.flags = flags; config.pInitialAttachment = pGroup; return ma_sound_init_ex(pEngine, &config, pSound); } MA_API ma_result ma_sound_init_ex(ma_engine* pEngine, const ma_sound_config* pConfig, ma_sound* pSound) { ma_result result; result = ma_sound_preinit(pEngine, pSound); if (result != MA_SUCCESS) { return result; } if (pConfig == NULL) { return MA_INVALID_ARGS; } pSound->endCallback = pConfig->endCallback; pSound->pEndCallbackUserData = pConfig->pEndCallbackUserData; /* We need to load the sound differently depending on whether or not we're loading from a file. */ #ifndef MA_NO_RESOURCE_MANAGER if (pConfig->pFilePath != NULL || pConfig->pFilePathW != NULL) { return ma_sound_init_from_file_internal(pEngine, pConfig, pSound); } else #endif { /* Getting here means we're not loading from a file. We may be loading from an already-initialized data source, or none at all. If we aren't specifying any data source, we'll be initializing the the equivalent to a group. ma_data_source_init_from_data_source_internal() will deal with this for us, so no special treatment required here. */ return ma_sound_init_from_data_source_internal(pEngine, pConfig, pSound); } } MA_API void ma_sound_uninit(ma_sound* pSound) { if (pSound == NULL) { return; } /* Always uninitialize the node first. This ensures it's detached from the graph and does not return until it has done so which makes thread safety beyond this point trivial. */ ma_engine_node_uninit(&pSound->engineNode, &pSound->engineNode.pEngine->allocationCallbacks); /* Once the sound is detached from the group we can guarantee that it won't be referenced by the mixer thread which means it's safe for us to destroy the data source. */ #ifndef MA_NO_RESOURCE_MANAGER if (pSound->ownsDataSource) { ma_resource_manager_data_source_uninit(pSound->pResourceManagerDataSource); ma_free(pSound->pResourceManagerDataSource, &pSound->engineNode.pEngine->allocationCallbacks); pSound->pDataSource = NULL; } #else MA_ASSERT(pSound->ownsDataSource == MA_FALSE); #endif } MA_API ma_engine* ma_sound_get_engine(const ma_sound* pSound) { if (pSound == NULL) { return NULL; } return pSound->engineNode.pEngine; } MA_API ma_data_source* ma_sound_get_data_source(const ma_sound* pSound) { if (pSound == NULL) { return NULL; } return pSound->pDataSource; } MA_API ma_result ma_sound_start(ma_sound* pSound) { if (pSound == NULL) { return MA_INVALID_ARGS; } /* If the sound is already playing, do nothing. */ if (ma_sound_is_playing(pSound)) { return MA_SUCCESS; } /* If the sound is at the end it means we want to start from the start again. */ if (ma_sound_at_end(pSound)) { ma_result result = ma_data_source_seek_to_pcm_frame(pSound->pDataSource, 0); if (result != MA_SUCCESS && result != MA_NOT_IMPLEMENTED) { return result; /* Failed to seek back to the start. */ } /* Make sure we clear the end indicator. */ ma_atomic_exchange_32(&pSound->atEnd, MA_FALSE); } /* Make sure the sound is started. If there's a start delay, the sound won't actually start until the start time is reached. */ ma_node_set_state(pSound, ma_node_state_started); return MA_SUCCESS; } MA_API ma_result ma_sound_stop(ma_sound* pSound) { if (pSound == NULL) { return MA_INVALID_ARGS; } /* This will stop the sound immediately. Use ma_sound_set_stop_time() to stop the sound at a specific time. */ ma_node_set_state(pSound, ma_node_state_stopped); return MA_SUCCESS; } MA_API ma_result ma_sound_stop_with_fade_in_pcm_frames(ma_sound* pSound, ma_uint64 fadeLengthInFrames) { if (pSound == NULL) { return MA_INVALID_ARGS; } /* Stopping with a fade out requires us to schedule the stop into the future by the fade length. */ ma_sound_set_stop_time_with_fade_in_pcm_frames(pSound, ma_engine_get_time_in_pcm_frames(ma_sound_get_engine(pSound)) + fadeLengthInFrames, fadeLengthInFrames); return MA_SUCCESS; } MA_API ma_result ma_sound_stop_with_fade_in_milliseconds(ma_sound* pSound, ma_uint64 fadeLengthInMilliseconds) { ma_uint64 sampleRate; if (pSound == NULL) { return MA_INVALID_ARGS; } sampleRate = ma_engine_get_sample_rate(ma_sound_get_engine(pSound)); return ma_sound_stop_with_fade_in_pcm_frames(pSound, (fadeLengthInMilliseconds * sampleRate) / 1000); } MA_API void ma_sound_set_volume(ma_sound* pSound, float volume) { if (pSound == NULL) { return; } ma_engine_node_set_volume(&pSound->engineNode, volume); } MA_API float ma_sound_get_volume(const ma_sound* pSound) { float volume = 0; if (pSound == NULL) { return 0; } ma_engine_node_get_volume(&pSound->engineNode, &volume); return volume; } MA_API void ma_sound_set_pan(ma_sound* pSound, float pan) { if (pSound == NULL) { return; } ma_panner_set_pan(&pSound->engineNode.panner, pan); } MA_API float ma_sound_get_pan(const ma_sound* pSound) { if (pSound == NULL) { return 0; } return ma_panner_get_pan(&pSound->engineNode.panner); } MA_API void ma_sound_set_pan_mode(ma_sound* pSound, ma_pan_mode panMode) { if (pSound == NULL) { return; } ma_panner_set_mode(&pSound->engineNode.panner, panMode); } MA_API ma_pan_mode ma_sound_get_pan_mode(const ma_sound* pSound) { if (pSound == NULL) { return ma_pan_mode_balance; } return ma_panner_get_mode(&pSound->engineNode.panner); } MA_API void ma_sound_set_pitch(ma_sound* pSound, float pitch) { if (pSound == NULL) { return; } if (pitch <= 0) { return; } ma_atomic_exchange_explicit_f32(&pSound->engineNode.pitch, pitch, ma_atomic_memory_order_release); } MA_API float ma_sound_get_pitch(const ma_sound* pSound) { if (pSound == NULL) { return 0; } return ma_atomic_load_f32(&pSound->engineNode.pitch); /* Naughty const-cast for this. */ } MA_API void ma_sound_set_spatialization_enabled(ma_sound* pSound, ma_bool32 enabled) { if (pSound == NULL) { return; } ma_atomic_exchange_explicit_32(&pSound->engineNode.isSpatializationDisabled, !enabled, ma_atomic_memory_order_release); } MA_API ma_bool32 ma_sound_is_spatialization_enabled(const ma_sound* pSound) { if (pSound == NULL) { return MA_FALSE; } return ma_engine_node_is_spatialization_enabled(&pSound->engineNode); } MA_API void ma_sound_set_pinned_listener_index(ma_sound* pSound, ma_uint32 listenerIndex) { if (pSound == NULL || listenerIndex >= ma_engine_get_listener_count(ma_sound_get_engine(pSound))) { return; } ma_atomic_exchange_explicit_32(&pSound->engineNode.pinnedListenerIndex, listenerIndex, ma_atomic_memory_order_release); } MA_API ma_uint32 ma_sound_get_pinned_listener_index(const ma_sound* pSound) { if (pSound == NULL) { return MA_LISTENER_INDEX_CLOSEST; } return ma_atomic_load_explicit_32(&pSound->engineNode.pinnedListenerIndex, ma_atomic_memory_order_acquire); } MA_API ma_uint32 ma_sound_get_listener_index(const ma_sound* pSound) { ma_uint32 listenerIndex; if (pSound == NULL) { return 0; } listenerIndex = ma_sound_get_pinned_listener_index(pSound); if (listenerIndex == MA_LISTENER_INDEX_CLOSEST) { ma_vec3f position = ma_sound_get_position(pSound); return ma_engine_find_closest_listener(ma_sound_get_engine(pSound), position.x, position.y, position.z); } return listenerIndex; } MA_API ma_vec3f ma_sound_get_direction_to_listener(const ma_sound* pSound) { ma_vec3f relativePos; ma_engine* pEngine; if (pSound == NULL) { return ma_vec3f_init_3f(0, 0, -1); } pEngine = ma_sound_get_engine(pSound); if (pEngine == NULL) { return ma_vec3f_init_3f(0, 0, -1); } ma_spatializer_get_relative_position_and_direction(&pSound->engineNode.spatializer, &pEngine->listeners[ma_sound_get_listener_index(pSound)], &relativePos, NULL); return ma_vec3f_normalize(ma_vec3f_neg(relativePos)); } MA_API void ma_sound_set_position(ma_sound* pSound, float x, float y, float z) { if (pSound == NULL) { return; } ma_spatializer_set_position(&pSound->engineNode.spatializer, x, y, z); } MA_API ma_vec3f ma_sound_get_position(const ma_sound* pSound) { if (pSound == NULL) { return ma_vec3f_init_3f(0, 0, 0); } return ma_spatializer_get_position(&pSound->engineNode.spatializer); } MA_API void ma_sound_set_direction(ma_sound* pSound, float x, float y, float z) { if (pSound == NULL) { return; } ma_spatializer_set_direction(&pSound->engineNode.spatializer, x, y, z); } MA_API ma_vec3f ma_sound_get_direction(const ma_sound* pSound) { if (pSound == NULL) { return ma_vec3f_init_3f(0, 0, 0); } return ma_spatializer_get_direction(&pSound->engineNode.spatializer); } MA_API void ma_sound_set_velocity(ma_sound* pSound, float x, float y, float z) { if (pSound == NULL) { return; } ma_spatializer_set_velocity(&pSound->engineNode.spatializer, x, y, z); } MA_API ma_vec3f ma_sound_get_velocity(const ma_sound* pSound) { if (pSound == NULL) { return ma_vec3f_init_3f(0, 0, 0); } return ma_spatializer_get_velocity(&pSound->engineNode.spatializer); } MA_API void ma_sound_set_attenuation_model(ma_sound* pSound, ma_attenuation_model attenuationModel) { if (pSound == NULL) { return; } ma_spatializer_set_attenuation_model(&pSound->engineNode.spatializer, attenuationModel); } MA_API ma_attenuation_model ma_sound_get_attenuation_model(const ma_sound* pSound) { if (pSound == NULL) { return ma_attenuation_model_none; } return ma_spatializer_get_attenuation_model(&pSound->engineNode.spatializer); } MA_API void ma_sound_set_positioning(ma_sound* pSound, ma_positioning positioning) { if (pSound == NULL) { return; } ma_spatializer_set_positioning(&pSound->engineNode.spatializer, positioning); } MA_API ma_positioning ma_sound_get_positioning(const ma_sound* pSound) { if (pSound == NULL) { return ma_positioning_absolute; } return ma_spatializer_get_positioning(&pSound->engineNode.spatializer); } MA_API void ma_sound_set_rolloff(ma_sound* pSound, float rolloff) { if (pSound == NULL) { return; } ma_spatializer_set_rolloff(&pSound->engineNode.spatializer, rolloff); } MA_API float ma_sound_get_rolloff(const ma_sound* pSound) { if (pSound == NULL) { return 0; } return ma_spatializer_get_rolloff(&pSound->engineNode.spatializer); } MA_API void ma_sound_set_min_gain(ma_sound* pSound, float minGain) { if (pSound == NULL) { return; } ma_spatializer_set_min_gain(&pSound->engineNode.spatializer, minGain); } MA_API float ma_sound_get_min_gain(const ma_sound* pSound) { if (pSound == NULL) { return 0; } return ma_spatializer_get_min_gain(&pSound->engineNode.spatializer); } MA_API void ma_sound_set_max_gain(ma_sound* pSound, float maxGain) { if (pSound == NULL) { return; } ma_spatializer_set_max_gain(&pSound->engineNode.spatializer, maxGain); } MA_API float ma_sound_get_max_gain(const ma_sound* pSound) { if (pSound == NULL) { return 0; } return ma_spatializer_get_max_gain(&pSound->engineNode.spatializer); } MA_API void ma_sound_set_min_distance(ma_sound* pSound, float minDistance) { if (pSound == NULL) { return; } ma_spatializer_set_min_distance(&pSound->engineNode.spatializer, minDistance); } MA_API float ma_sound_get_min_distance(const ma_sound* pSound) { if (pSound == NULL) { return 0; } return ma_spatializer_get_min_distance(&pSound->engineNode.spatializer); } MA_API void ma_sound_set_max_distance(ma_sound* pSound, float maxDistance) { if (pSound == NULL) { return; } ma_spatializer_set_max_distance(&pSound->engineNode.spatializer, maxDistance); } MA_API float ma_sound_get_max_distance(const ma_sound* pSound) { if (pSound == NULL) { return 0; } return ma_spatializer_get_max_distance(&pSound->engineNode.spatializer); } MA_API void ma_sound_set_cone(ma_sound* pSound, float innerAngleInRadians, float outerAngleInRadians, float outerGain) { if (pSound == NULL) { return; } ma_spatializer_set_cone(&pSound->engineNode.spatializer, innerAngleInRadians, outerAngleInRadians, outerGain); } MA_API void ma_sound_get_cone(const ma_sound* pSound, float* pInnerAngleInRadians, float* pOuterAngleInRadians, float* pOuterGain) { if (pInnerAngleInRadians != NULL) { *pInnerAngleInRadians = 0; } if (pOuterAngleInRadians != NULL) { *pOuterAngleInRadians = 0; } if (pOuterGain != NULL) { *pOuterGain = 0; } if (pSound == NULL) { return; } ma_spatializer_get_cone(&pSound->engineNode.spatializer, pInnerAngleInRadians, pOuterAngleInRadians, pOuterGain); } MA_API void ma_sound_set_doppler_factor(ma_sound* pSound, float dopplerFactor) { if (pSound == NULL) { return; } ma_spatializer_set_doppler_factor(&pSound->engineNode.spatializer, dopplerFactor); } MA_API float ma_sound_get_doppler_factor(const ma_sound* pSound) { if (pSound == NULL) { return 0; } return ma_spatializer_get_doppler_factor(&pSound->engineNode.spatializer); } MA_API void ma_sound_set_directional_attenuation_factor(ma_sound* pSound, float directionalAttenuationFactor) { if (pSound == NULL) { return; } ma_spatializer_set_directional_attenuation_factor(&pSound->engineNode.spatializer, directionalAttenuationFactor); } MA_API float ma_sound_get_directional_attenuation_factor(const ma_sound* pSound) { if (pSound == NULL) { return 1; } return ma_spatializer_get_directional_attenuation_factor(&pSound->engineNode.spatializer); } MA_API void ma_sound_set_fade_in_pcm_frames(ma_sound* pSound, float volumeBeg, float volumeEnd, ma_uint64 fadeLengthInFrames) { if (pSound == NULL) { return; } ma_sound_set_fade_start_in_pcm_frames(pSound, volumeBeg, volumeEnd, fadeLengthInFrames, (~(ma_uint64)0)); } MA_API void ma_sound_set_fade_in_milliseconds(ma_sound* pSound, float volumeBeg, float volumeEnd, ma_uint64 fadeLengthInMilliseconds) { if (pSound == NULL) { return; } ma_sound_set_fade_in_pcm_frames(pSound, volumeBeg, volumeEnd, (fadeLengthInMilliseconds * pSound->engineNode.fader.config.sampleRate) / 1000); } MA_API void ma_sound_set_fade_start_in_pcm_frames(ma_sound* pSound, float volumeBeg, float volumeEnd, ma_uint64 fadeLengthInFrames, ma_uint64 absoluteGlobalTimeInFrames) { if (pSound == NULL) { return; } /* We don't want to update the fader at this point because we need to use the engine's current time to derive the fader's start offset. The timer is being updated on the audio thread so in order to do this as accurately as possible we'll need to defer this to the audio thread. */ ma_atomic_float_set(&pSound->engineNode.fadeSettings.volumeBeg, volumeBeg); ma_atomic_float_set(&pSound->engineNode.fadeSettings.volumeEnd, volumeEnd); ma_atomic_uint64_set(&pSound->engineNode.fadeSettings.fadeLengthInFrames, fadeLengthInFrames); ma_atomic_uint64_set(&pSound->engineNode.fadeSettings.absoluteGlobalTimeInFrames, absoluteGlobalTimeInFrames); } MA_API void ma_sound_set_fade_start_in_milliseconds(ma_sound* pSound, float volumeBeg, float volumeEnd, ma_uint64 fadeLengthInMilliseconds, ma_uint64 absoluteGlobalTimeInMilliseconds) { ma_uint32 sampleRate; if (pSound == NULL) { return; } sampleRate = ma_engine_get_sample_rate(ma_sound_get_engine(pSound)); ma_sound_set_fade_start_in_pcm_frames(pSound, volumeBeg, volumeEnd, (fadeLengthInMilliseconds * sampleRate) / 1000, (absoluteGlobalTimeInMilliseconds * sampleRate) / 1000); } MA_API float ma_sound_get_current_fade_volume(const ma_sound* pSound) { if (pSound == NULL) { return MA_INVALID_ARGS; } return ma_fader_get_current_volume(&pSound->engineNode.fader); } MA_API void ma_sound_set_start_time_in_pcm_frames(ma_sound* pSound, ma_uint64 absoluteGlobalTimeInFrames) { if (pSound == NULL) { return; } ma_node_set_state_time(pSound, ma_node_state_started, absoluteGlobalTimeInFrames); } MA_API void ma_sound_set_start_time_in_milliseconds(ma_sound* pSound, ma_uint64 absoluteGlobalTimeInMilliseconds) { if (pSound == NULL) { return; } ma_sound_set_start_time_in_pcm_frames(pSound, absoluteGlobalTimeInMilliseconds * ma_engine_get_sample_rate(ma_sound_get_engine(pSound)) / 1000); } MA_API void ma_sound_set_stop_time_in_pcm_frames(ma_sound* pSound, ma_uint64 absoluteGlobalTimeInFrames) { if (pSound == NULL) { return; } ma_sound_set_stop_time_with_fade_in_pcm_frames(pSound, absoluteGlobalTimeInFrames, 0); } MA_API void ma_sound_set_stop_time_in_milliseconds(ma_sound* pSound, ma_uint64 absoluteGlobalTimeInMilliseconds) { if (pSound == NULL) { return; } ma_sound_set_stop_time_in_pcm_frames(pSound, absoluteGlobalTimeInMilliseconds * ma_engine_get_sample_rate(ma_sound_get_engine(pSound)) / 1000); } MA_API void ma_sound_set_stop_time_with_fade_in_pcm_frames(ma_sound* pSound, ma_uint64 stopAbsoluteGlobalTimeInFrames, ma_uint64 fadeLengthInFrames) { if (pSound == NULL) { return; } if (fadeLengthInFrames > 0) { if (fadeLengthInFrames > stopAbsoluteGlobalTimeInFrames) { fadeLengthInFrames = stopAbsoluteGlobalTimeInFrames; } ma_sound_set_fade_start_in_pcm_frames(pSound, -1, 0, fadeLengthInFrames, stopAbsoluteGlobalTimeInFrames - fadeLengthInFrames); } ma_node_set_state_time(pSound, ma_node_state_stopped, stopAbsoluteGlobalTimeInFrames); } MA_API void ma_sound_set_stop_time_with_fade_in_milliseconds(ma_sound* pSound, ma_uint64 stopAbsoluteGlobalTimeInMilliseconds, ma_uint64 fadeLengthInMilliseconds) { ma_uint32 sampleRate; if (pSound == NULL) { return; } sampleRate = ma_engine_get_sample_rate(ma_sound_get_engine(pSound)); ma_sound_set_stop_time_with_fade_in_pcm_frames(pSound, (stopAbsoluteGlobalTimeInMilliseconds * sampleRate) / 1000, (fadeLengthInMilliseconds * sampleRate) / 1000); } MA_API ma_bool32 ma_sound_is_playing(const ma_sound* pSound) { if (pSound == NULL) { return MA_FALSE; } return ma_node_get_state_by_time(pSound, ma_engine_get_time_in_pcm_frames(ma_sound_get_engine(pSound))) == ma_node_state_started; } MA_API ma_uint64 ma_sound_get_time_in_pcm_frames(const ma_sound* pSound) { if (pSound == NULL) { return 0; } return ma_node_get_time(pSound); } MA_API ma_uint64 ma_sound_get_time_in_milliseconds(const ma_sound* pSound) { return ma_sound_get_time_in_pcm_frames(pSound) * 1000 / ma_engine_get_sample_rate(ma_sound_get_engine(pSound)); } MA_API void ma_sound_set_looping(ma_sound* pSound, ma_bool32 isLooping) { if (pSound == NULL) { return; } /* Looping is only a valid concept if the sound is backed by a data source. */ if (pSound->pDataSource == NULL) { return; } /* The looping state needs to be applied to the data source in order for any looping to actually happen. */ ma_data_source_set_looping(pSound->pDataSource, isLooping); } MA_API ma_bool32 ma_sound_is_looping(const ma_sound* pSound) { if (pSound == NULL) { return MA_FALSE; } /* There is no notion of looping for sounds that are not backed by a data source. */ if (pSound->pDataSource == NULL) { return MA_FALSE; } return ma_data_source_is_looping(pSound->pDataSource); } MA_API ma_bool32 ma_sound_at_end(const ma_sound* pSound) { if (pSound == NULL) { return MA_FALSE; } /* There is no notion of an end of a sound if it's not backed by a data source. */ if (pSound->pDataSource == NULL) { return MA_FALSE; } return ma_sound_get_at_end(pSound); } MA_API ma_result ma_sound_seek_to_pcm_frame(ma_sound* pSound, ma_uint64 frameIndex) { if (pSound == NULL) { return MA_INVALID_ARGS; } /* Seeking is only valid for sounds that are backed by a data source. */ if (pSound->pDataSource == NULL) { return MA_INVALID_OPERATION; } /* We can't be seeking while reading at the same time. We just set the seek target and get the mixing thread to do the actual seek. */ ma_atomic_exchange_64(&pSound->seekTarget, frameIndex); return MA_SUCCESS; } MA_API ma_result ma_sound_get_data_format(ma_sound* pSound, ma_format* pFormat, ma_uint32* pChannels, ma_uint32* pSampleRate, ma_channel* pChannelMap, size_t channelMapCap) { if (pSound == NULL) { return MA_INVALID_ARGS; } /* The data format is retrieved directly from the data source if the sound is backed by one. Otherwise we pull it from the node. */ if (pSound->pDataSource == NULL) { ma_uint32 channels; if (pFormat != NULL) { *pFormat = ma_format_f32; } channels = ma_node_get_input_channels(&pSound->engineNode, 0); if (pChannels != NULL) { *pChannels = channels; } if (pSampleRate != NULL) { *pSampleRate = pSound->engineNode.resampler.config.sampleRateIn; } if (pChannelMap != NULL) { ma_channel_map_init_standard(ma_standard_channel_map_default, pChannelMap, channelMapCap, channels); } return MA_SUCCESS; } else { return ma_data_source_get_data_format(pSound->pDataSource, pFormat, pChannels, pSampleRate, pChannelMap, channelMapCap); } } MA_API ma_result ma_sound_get_cursor_in_pcm_frames(ma_sound* pSound, ma_uint64* pCursor) { ma_uint64 seekTarget; if (pSound == NULL) { return MA_INVALID_ARGS; } /* The notion of a cursor is only valid for sounds that are backed by a data source. */ if (pSound->pDataSource == NULL) { return MA_INVALID_OPERATION; } seekTarget = ma_atomic_load_64(&pSound->seekTarget); if (seekTarget != MA_SEEK_TARGET_NONE) { *pCursor = seekTarget; return MA_SUCCESS; } else { return ma_data_source_get_cursor_in_pcm_frames(pSound->pDataSource, pCursor); } } MA_API ma_result ma_sound_get_length_in_pcm_frames(ma_sound* pSound, ma_uint64* pLength) { if (pSound == NULL) { return MA_INVALID_ARGS; } /* The notion of a sound length is only valid for sounds that are backed by a data source. */ if (pSound->pDataSource == NULL) { return MA_INVALID_OPERATION; } return ma_data_source_get_length_in_pcm_frames(pSound->pDataSource, pLength); } MA_API ma_result ma_sound_get_cursor_in_seconds(ma_sound* pSound, float* pCursor) { ma_result result; ma_uint64 cursorInPCMFrames; ma_uint32 sampleRate; if (pCursor != NULL) { *pCursor = 0; } result = ma_sound_get_cursor_in_pcm_frames(pSound, &cursorInPCMFrames); if (result != MA_SUCCESS) { return result; } result = ma_sound_get_data_format(pSound, NULL, NULL, &sampleRate, NULL, 0); if (result != MA_SUCCESS) { return result; } /* VC6 does not support division of unsigned 64-bit integers with floating point numbers. Need to use a signed number. This shouldn't effect anything in practice. */ *pCursor = (ma_int64)cursorInPCMFrames / (float)sampleRate; return MA_SUCCESS; } MA_API ma_result ma_sound_get_length_in_seconds(ma_sound* pSound, float* pLength) { if (pSound == NULL) { return MA_INVALID_ARGS; } /* The notion of a sound length is only valid for sounds that are backed by a data source. */ if (pSound->pDataSource == NULL) { return MA_INVALID_OPERATION; } return ma_data_source_get_length_in_seconds(pSound->pDataSource, pLength); } MA_API ma_result ma_sound_set_end_callback(ma_sound* pSound, ma_sound_end_proc callback, void* pUserData) { if (pSound == NULL) { return MA_INVALID_ARGS; } /* The notion of an end is only valid for sounds that are backed by a data source. */ if (pSound->pDataSource == NULL) { return MA_INVALID_OPERATION; } pSound->endCallback = callback; pSound->pEndCallbackUserData = pUserData; return MA_SUCCESS; } MA_API ma_result ma_sound_group_init(ma_engine* pEngine, ma_uint32 flags, ma_sound_group* pParentGroup, ma_sound_group* pGroup) { ma_sound_group_config config = ma_sound_group_config_init_2(pEngine); config.flags = flags; config.pInitialAttachment = pParentGroup; return ma_sound_group_init_ex(pEngine, &config, pGroup); } MA_API ma_result ma_sound_group_init_ex(ma_engine* pEngine, const ma_sound_group_config* pConfig, ma_sound_group* pGroup) { ma_sound_config soundConfig; if (pGroup == NULL) { return MA_INVALID_ARGS; } MA_ZERO_OBJECT(pGroup); if (pConfig == NULL) { return MA_INVALID_ARGS; } /* A sound group is just a sound without a data source. */ soundConfig = *pConfig; soundConfig.pFilePath = NULL; soundConfig.pFilePathW = NULL; soundConfig.pDataSource = NULL; /* Groups need to have spatialization disabled by default because I think it'll be pretty rare that programs will want to spatialize groups (but not unheard of). Certainly it feels like disabling this by default feels like the right option. Spatialization can be enabled with a call to ma_sound_group_set_spatialization_enabled(). */ soundConfig.flags |= MA_SOUND_FLAG_NO_SPATIALIZATION; return ma_sound_init_ex(pEngine, &soundConfig, pGroup); } MA_API void ma_sound_group_uninit(ma_sound_group* pGroup) { ma_sound_uninit(pGroup); } MA_API ma_engine* ma_sound_group_get_engine(const ma_sound_group* pGroup) { return ma_sound_get_engine(pGroup); } MA_API ma_result ma_sound_group_start(ma_sound_group* pGroup) { return ma_sound_start(pGroup); } MA_API ma_result ma_sound_group_stop(ma_sound_group* pGroup) { return ma_sound_stop(pGroup); } MA_API void ma_sound_group_set_volume(ma_sound_group* pGroup, float volume) { ma_sound_set_volume(pGroup, volume); } MA_API float ma_sound_group_get_volume(const ma_sound_group* pGroup) { return ma_sound_get_volume(pGroup); } MA_API void ma_sound_group_set_pan(ma_sound_group* pGroup, float pan) { ma_sound_set_pan(pGroup, pan); } MA_API float ma_sound_group_get_pan(const ma_sound_group* pGroup) { return ma_sound_get_pan(pGroup); } MA_API void ma_sound_group_set_pan_mode(ma_sound_group* pGroup, ma_pan_mode panMode) { ma_sound_set_pan_mode(pGroup, panMode); } MA_API ma_pan_mode ma_sound_group_get_pan_mode(const ma_sound_group* pGroup) { return ma_sound_get_pan_mode(pGroup); } MA_API void ma_sound_group_set_pitch(ma_sound_group* pGroup, float pitch) { ma_sound_set_pitch(pGroup, pitch); } MA_API float ma_sound_group_get_pitch(const ma_sound_group* pGroup) { return ma_sound_get_pitch(pGroup); } MA_API void ma_sound_group_set_spatialization_enabled(ma_sound_group* pGroup, ma_bool32 enabled) { ma_sound_set_spatialization_enabled(pGroup, enabled); } MA_API ma_bool32 ma_sound_group_is_spatialization_enabled(const ma_sound_group* pGroup) { return ma_sound_is_spatialization_enabled(pGroup); } MA_API void ma_sound_group_set_pinned_listener_index(ma_sound_group* pGroup, ma_uint32 listenerIndex) { ma_sound_set_pinned_listener_index(pGroup, listenerIndex); } MA_API ma_uint32 ma_sound_group_get_pinned_listener_index(const ma_sound_group* pGroup) { return ma_sound_get_pinned_listener_index(pGroup); } MA_API ma_uint32 ma_sound_group_get_listener_index(const ma_sound_group* pGroup) { return ma_sound_get_listener_index(pGroup); } MA_API ma_vec3f ma_sound_group_get_direction_to_listener(const ma_sound_group* pGroup) { return ma_sound_get_direction_to_listener(pGroup); } MA_API void ma_sound_group_set_position(ma_sound_group* pGroup, float x, float y, float z) { ma_sound_set_position(pGroup, x, y, z); } MA_API ma_vec3f ma_sound_group_get_position(const ma_sound_group* pGroup) { return ma_sound_get_position(pGroup); } MA_API void ma_sound_group_set_direction(ma_sound_group* pGroup, float x, float y, float z) { ma_sound_set_direction(pGroup, x, y, z); } MA_API ma_vec3f ma_sound_group_get_direction(const ma_sound_group* pGroup) { return ma_sound_get_direction(pGroup); } MA_API void ma_sound_group_set_velocity(ma_sound_group* pGroup, float x, float y, float z) { ma_sound_set_velocity(pGroup, x, y, z); } MA_API ma_vec3f ma_sound_group_get_velocity(const ma_sound_group* pGroup) { return ma_sound_get_velocity(pGroup); } MA_API void ma_sound_group_set_attenuation_model(ma_sound_group* pGroup, ma_attenuation_model attenuationModel) { ma_sound_set_attenuation_model(pGroup, attenuationModel); } MA_API ma_attenuation_model ma_sound_group_get_attenuation_model(const ma_sound_group* pGroup) { return ma_sound_get_attenuation_model(pGroup); } MA_API void ma_sound_group_set_positioning(ma_sound_group* pGroup, ma_positioning positioning) { ma_sound_set_positioning(pGroup, positioning); } MA_API ma_positioning ma_sound_group_get_positioning(const ma_sound_group* pGroup) { return ma_sound_get_positioning(pGroup); } MA_API void ma_sound_group_set_rolloff(ma_sound_group* pGroup, float rolloff) { ma_sound_set_rolloff(pGroup, rolloff); } MA_API float ma_sound_group_get_rolloff(const ma_sound_group* pGroup) { return ma_sound_get_rolloff(pGroup); } MA_API void ma_sound_group_set_min_gain(ma_sound_group* pGroup, float minGain) { ma_sound_set_min_gain(pGroup, minGain); } MA_API float ma_sound_group_get_min_gain(const ma_sound_group* pGroup) { return ma_sound_get_min_gain(pGroup); } MA_API void ma_sound_group_set_max_gain(ma_sound_group* pGroup, float maxGain) { ma_sound_set_max_gain(pGroup, maxGain); } MA_API float ma_sound_group_get_max_gain(const ma_sound_group* pGroup) { return ma_sound_get_max_gain(pGroup); } MA_API void ma_sound_group_set_min_distance(ma_sound_group* pGroup, float minDistance) { ma_sound_set_min_distance(pGroup, minDistance); } MA_API float ma_sound_group_get_min_distance(const ma_sound_group* pGroup) { return ma_sound_get_min_distance(pGroup); } MA_API void ma_sound_group_set_max_distance(ma_sound_group* pGroup, float maxDistance) { ma_sound_set_max_distance(pGroup, maxDistance); } MA_API float ma_sound_group_get_max_distance(const ma_sound_group* pGroup) { return ma_sound_get_max_distance(pGroup); } MA_API void ma_sound_group_set_cone(ma_sound_group* pGroup, float innerAngleInRadians, float outerAngleInRadians, float outerGain) { ma_sound_set_cone(pGroup, innerAngleInRadians, outerAngleInRadians, outerGain); } MA_API void ma_sound_group_get_cone(const ma_sound_group* pGroup, float* pInnerAngleInRadians, float* pOuterAngleInRadians, float* pOuterGain) { ma_sound_get_cone(pGroup, pInnerAngleInRadians, pOuterAngleInRadians, pOuterGain); } MA_API void ma_sound_group_set_doppler_factor(ma_sound_group* pGroup, float dopplerFactor) { ma_sound_set_doppler_factor(pGroup, dopplerFactor); } MA_API float ma_sound_group_get_doppler_factor(const ma_sound_group* pGroup) { return ma_sound_get_doppler_factor(pGroup); } MA_API void ma_sound_group_set_directional_attenuation_factor(ma_sound_group* pGroup, float directionalAttenuationFactor) { ma_sound_set_directional_attenuation_factor(pGroup, directionalAttenuationFactor); } MA_API float ma_sound_group_get_directional_attenuation_factor(const ma_sound_group* pGroup) { return ma_sound_get_directional_attenuation_factor(pGroup); } MA_API void ma_sound_group_set_fade_in_pcm_frames(ma_sound_group* pGroup, float volumeBeg, float volumeEnd, ma_uint64 fadeLengthInFrames) { ma_sound_set_fade_in_pcm_frames(pGroup, volumeBeg, volumeEnd, fadeLengthInFrames); } MA_API void ma_sound_group_set_fade_in_milliseconds(ma_sound_group* pGroup, float volumeBeg, float volumeEnd, ma_uint64 fadeLengthInMilliseconds) { ma_sound_set_fade_in_milliseconds(pGroup, volumeBeg, volumeEnd, fadeLengthInMilliseconds); } MA_API float ma_sound_group_get_current_fade_volume(ma_sound_group* pGroup) { return ma_sound_get_current_fade_volume(pGroup); } MA_API void ma_sound_group_set_start_time_in_pcm_frames(ma_sound_group* pGroup, ma_uint64 absoluteGlobalTimeInFrames) { ma_sound_set_start_time_in_pcm_frames(pGroup, absoluteGlobalTimeInFrames); } MA_API void ma_sound_group_set_start_time_in_milliseconds(ma_sound_group* pGroup, ma_uint64 absoluteGlobalTimeInMilliseconds) { ma_sound_set_start_time_in_milliseconds(pGroup, absoluteGlobalTimeInMilliseconds); } MA_API void ma_sound_group_set_stop_time_in_pcm_frames(ma_sound_group* pGroup, ma_uint64 absoluteGlobalTimeInFrames) { ma_sound_set_stop_time_in_pcm_frames(pGroup, absoluteGlobalTimeInFrames); } MA_API void ma_sound_group_set_stop_time_in_milliseconds(ma_sound_group* pGroup, ma_uint64 absoluteGlobalTimeInMilliseconds) { ma_sound_set_stop_time_in_milliseconds(pGroup, absoluteGlobalTimeInMilliseconds); } MA_API ma_bool32 ma_sound_group_is_playing(const ma_sound_group* pGroup) { return ma_sound_is_playing(pGroup); } MA_API ma_uint64 ma_sound_group_get_time_in_pcm_frames(const ma_sound_group* pGroup) { return ma_sound_get_time_in_pcm_frames(pGroup); } #endif /* MA_NO_ENGINE */ /* END SECTION: miniaudio_engine.c */ /************************************************************************************************************************************************************** *************************************************************************************************************************************************************** Auto Generated ============== All code below is auto-generated from a tool. This mostly consists of decoding backend implementations such as ma_dr_wav, ma_dr_flac, etc. If you find a bug in the code below please report the bug to the respective repository for the relevant project (probably dr_libs). *************************************************************************************************************************************************************** **************************************************************************************************************************************************************/ #if !defined(MA_NO_WAV) && (!defined(MA_NO_DECODING) || !defined(MA_NO_ENCODING)) #if !defined(MA_DR_WAV_IMPLEMENTATION) && !defined(MA_DR_WAV_IMPLEMENTATION) /* For backwards compatibility. Will be removed in version 0.11 for cleanliness. */ /* dr_wav_c begin */ #ifndef ma_dr_wav_c #define ma_dr_wav_c #ifdef __MRC__ #pragma options opt off #endif #include #include #include #ifndef MA_DR_WAV_NO_STDIO #include #ifndef MA_DR_WAV_NO_WCHAR #include #endif #endif #ifndef MA_DR_WAV_ASSERT #include #define MA_DR_WAV_ASSERT(expression) assert(expression) #endif #ifndef MA_DR_WAV_MALLOC #define MA_DR_WAV_MALLOC(sz) malloc((sz)) #endif #ifndef MA_DR_WAV_REALLOC #define MA_DR_WAV_REALLOC(p, sz) realloc((p), (sz)) #endif #ifndef MA_DR_WAV_FREE #define MA_DR_WAV_FREE(p) free((p)) #endif #ifndef MA_DR_WAV_COPY_MEMORY #define MA_DR_WAV_COPY_MEMORY(dst, src, sz) memcpy((dst), (src), (sz)) #endif #ifndef MA_DR_WAV_ZERO_MEMORY #define MA_DR_WAV_ZERO_MEMORY(p, sz) memset((p), 0, (sz)) #endif #ifndef MA_DR_WAV_ZERO_OBJECT #define MA_DR_WAV_ZERO_OBJECT(p) MA_DR_WAV_ZERO_MEMORY((p), sizeof(*p)) #endif #define ma_dr_wav_countof(x) (sizeof(x) / sizeof(x[0])) #define ma_dr_wav_align(x, a) ((((x) + (a) - 1) / (a)) * (a)) #define ma_dr_wav_min(a, b) (((a) < (b)) ? (a) : (b)) #define ma_dr_wav_max(a, b) (((a) > (b)) ? (a) : (b)) #define ma_dr_wav_clamp(x, lo, hi) (ma_dr_wav_max((lo), ma_dr_wav_min((hi), (x)))) #define ma_dr_wav_offset_ptr(p, offset) (((ma_uint8*)(p)) + (offset)) #define MA_DR_WAV_MAX_SIMD_VECTOR_SIZE 32 #define MA_DR_WAV_INT64_MIN ((ma_int64) ((ma_uint64)0x80000000 << 32)) #define MA_DR_WAV_INT64_MAX ((ma_int64)(((ma_uint64)0x7FFFFFFF << 32) | 0xFFFFFFFF)) #if defined(_MSC_VER) && _MSC_VER >= 1400 #define MA_DR_WAV_HAS_BYTESWAP16_INTRINSIC #define MA_DR_WAV_HAS_BYTESWAP32_INTRINSIC #define MA_DR_WAV_HAS_BYTESWAP64_INTRINSIC #elif defined(__clang__) #if defined(__has_builtin) #if __has_builtin(__builtin_bswap16) #define MA_DR_WAV_HAS_BYTESWAP16_INTRINSIC #endif #if __has_builtin(__builtin_bswap32) #define MA_DR_WAV_HAS_BYTESWAP32_INTRINSIC #endif #if __has_builtin(__builtin_bswap64) #define MA_DR_WAV_HAS_BYTESWAP64_INTRINSIC #endif #endif #elif defined(__GNUC__) #if ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)) #define MA_DR_WAV_HAS_BYTESWAP32_INTRINSIC #define MA_DR_WAV_HAS_BYTESWAP64_INTRINSIC #endif #if ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)) #define MA_DR_WAV_HAS_BYTESWAP16_INTRINSIC #endif #endif MA_API void ma_dr_wav_version(ma_uint32* pMajor, ma_uint32* pMinor, ma_uint32* pRevision) { if (pMajor) { *pMajor = MA_DR_WAV_VERSION_MAJOR; } if (pMinor) { *pMinor = MA_DR_WAV_VERSION_MINOR; } if (pRevision) { *pRevision = MA_DR_WAV_VERSION_REVISION; } } MA_API const char* ma_dr_wav_version_string(void) { return MA_DR_WAV_VERSION_STRING; } #ifndef MA_DR_WAV_MAX_SAMPLE_RATE #define MA_DR_WAV_MAX_SAMPLE_RATE 384000 #endif #ifndef MA_DR_WAV_MAX_CHANNELS #define MA_DR_WAV_MAX_CHANNELS 256 #endif #ifndef MA_DR_WAV_MAX_BITS_PER_SAMPLE #define MA_DR_WAV_MAX_BITS_PER_SAMPLE 64 #endif static const ma_uint8 ma_dr_wavGUID_W64_RIFF[16] = {0x72,0x69,0x66,0x66, 0x2E,0x91, 0xCF,0x11, 0xA5,0xD6, 0x28,0xDB,0x04,0xC1,0x00,0x00}; static const ma_uint8 ma_dr_wavGUID_W64_WAVE[16] = {0x77,0x61,0x76,0x65, 0xF3,0xAC, 0xD3,0x11, 0x8C,0xD1, 0x00,0xC0,0x4F,0x8E,0xDB,0x8A}; static const ma_uint8 ma_dr_wavGUID_W64_FMT [16] = {0x66,0x6D,0x74,0x20, 0xF3,0xAC, 0xD3,0x11, 0x8C,0xD1, 0x00,0xC0,0x4F,0x8E,0xDB,0x8A}; static const ma_uint8 ma_dr_wavGUID_W64_FACT[16] = {0x66,0x61,0x63,0x74, 0xF3,0xAC, 0xD3,0x11, 0x8C,0xD1, 0x00,0xC0,0x4F,0x8E,0xDB,0x8A}; static const ma_uint8 ma_dr_wavGUID_W64_DATA[16] = {0x64,0x61,0x74,0x61, 0xF3,0xAC, 0xD3,0x11, 0x8C,0xD1, 0x00,0xC0,0x4F,0x8E,0xDB,0x8A}; static MA_INLINE int ma_dr_wav__is_little_endian(void) { #if defined(MA_X86) || defined(MA_X64) return MA_TRUE; #elif defined(__BYTE_ORDER) && defined(__LITTLE_ENDIAN) && __BYTE_ORDER == __LITTLE_ENDIAN return MA_TRUE; #else int n = 1; return (*(char*)&n) == 1; #endif } static MA_INLINE void ma_dr_wav_bytes_to_guid(const ma_uint8* data, ma_uint8* guid) { int i; for (i = 0; i < 16; ++i) { guid[i] = data[i]; } } static MA_INLINE ma_uint16 ma_dr_wav__bswap16(ma_uint16 n) { #ifdef MA_DR_WAV_HAS_BYTESWAP16_INTRINSIC #if defined(_MSC_VER) return _byteswap_ushort(n); #elif defined(__GNUC__) || defined(__clang__) return __builtin_bswap16(n); #else #error "This compiler does not support the byte swap intrinsic." #endif #else return ((n & 0xFF00) >> 8) | ((n & 0x00FF) << 8); #endif } static MA_INLINE ma_uint32 ma_dr_wav__bswap32(ma_uint32 n) { #ifdef MA_DR_WAV_HAS_BYTESWAP32_INTRINSIC #if defined(_MSC_VER) return _byteswap_ulong(n); #elif defined(__GNUC__) || defined(__clang__) #if defined(MA_ARM) && (defined(__ARM_ARCH) && __ARM_ARCH >= 6) && !defined(MA_64BIT) ma_uint32 r; __asm__ __volatile__ ( #if defined(MA_64BIT) "rev %w[out], %w[in]" : [out]"=r"(r) : [in]"r"(n) #else "rev %[out], %[in]" : [out]"=r"(r) : [in]"r"(n) #endif ); return r; #else return __builtin_bswap32(n); #endif #else #error "This compiler does not support the byte swap intrinsic." #endif #else return ((n & 0xFF000000) >> 24) | ((n & 0x00FF0000) >> 8) | ((n & 0x0000FF00) << 8) | ((n & 0x000000FF) << 24); #endif } static MA_INLINE ma_uint64 ma_dr_wav__bswap64(ma_uint64 n) { #ifdef MA_DR_WAV_HAS_BYTESWAP64_INTRINSIC #if defined(_MSC_VER) return _byteswap_uint64(n); #elif defined(__GNUC__) || defined(__clang__) return __builtin_bswap64(n); #else #error "This compiler does not support the byte swap intrinsic." #endif #else return ((n & ((ma_uint64)0xFF000000 << 32)) >> 56) | ((n & ((ma_uint64)0x00FF0000 << 32)) >> 40) | ((n & ((ma_uint64)0x0000FF00 << 32)) >> 24) | ((n & ((ma_uint64)0x000000FF << 32)) >> 8) | ((n & ((ma_uint64)0xFF000000 )) << 8) | ((n & ((ma_uint64)0x00FF0000 )) << 24) | ((n & ((ma_uint64)0x0000FF00 )) << 40) | ((n & ((ma_uint64)0x000000FF )) << 56); #endif } static MA_INLINE ma_int16 ma_dr_wav__bswap_s16(ma_int16 n) { return (ma_int16)ma_dr_wav__bswap16((ma_uint16)n); } static MA_INLINE void ma_dr_wav__bswap_samples_s16(ma_int16* pSamples, ma_uint64 sampleCount) { ma_uint64 iSample; for (iSample = 0; iSample < sampleCount; iSample += 1) { pSamples[iSample] = ma_dr_wav__bswap_s16(pSamples[iSample]); } } static MA_INLINE void ma_dr_wav__bswap_s24(ma_uint8* p) { ma_uint8 t; t = p[0]; p[0] = p[2]; p[2] = t; } static MA_INLINE void ma_dr_wav__bswap_samples_s24(ma_uint8* pSamples, ma_uint64 sampleCount) { ma_uint64 iSample; for (iSample = 0; iSample < sampleCount; iSample += 1) { ma_uint8* pSample = pSamples + (iSample*3); ma_dr_wav__bswap_s24(pSample); } } static MA_INLINE ma_int32 ma_dr_wav__bswap_s32(ma_int32 n) { return (ma_int32)ma_dr_wav__bswap32((ma_uint32)n); } static MA_INLINE void ma_dr_wav__bswap_samples_s32(ma_int32* pSamples, ma_uint64 sampleCount) { ma_uint64 iSample; for (iSample = 0; iSample < sampleCount; iSample += 1) { pSamples[iSample] = ma_dr_wav__bswap_s32(pSamples[iSample]); } } static MA_INLINE ma_int64 ma_dr_wav__bswap_s64(ma_int64 n) { return (ma_int64)ma_dr_wav__bswap64((ma_uint64)n); } static MA_INLINE void ma_dr_wav__bswap_samples_s64(ma_int64* pSamples, ma_uint64 sampleCount) { ma_uint64 iSample; for (iSample = 0; iSample < sampleCount; iSample += 1) { pSamples[iSample] = ma_dr_wav__bswap_s64(pSamples[iSample]); } } static MA_INLINE float ma_dr_wav__bswap_f32(float n) { union { ma_uint32 i; float f; } x; x.f = n; x.i = ma_dr_wav__bswap32(x.i); return x.f; } static MA_INLINE void ma_dr_wav__bswap_samples_f32(float* pSamples, ma_uint64 sampleCount) { ma_uint64 iSample; for (iSample = 0; iSample < sampleCount; iSample += 1) { pSamples[iSample] = ma_dr_wav__bswap_f32(pSamples[iSample]); } } static MA_INLINE void ma_dr_wav__bswap_samples(void* pSamples, ma_uint64 sampleCount, ma_uint32 bytesPerSample) { switch (bytesPerSample) { case 1: { } break; case 2: { ma_dr_wav__bswap_samples_s16((ma_int16*)pSamples, sampleCount); } break; case 3: { ma_dr_wav__bswap_samples_s24((ma_uint8*)pSamples, sampleCount); } break; case 4: { ma_dr_wav__bswap_samples_s32((ma_int32*)pSamples, sampleCount); } break; case 8: { ma_dr_wav__bswap_samples_s64((ma_int64*)pSamples, sampleCount); } break; default: { MA_DR_WAV_ASSERT(MA_FALSE); } break; } } MA_PRIVATE MA_INLINE ma_bool32 ma_dr_wav_is_container_be(ma_dr_wav_container container) { if (container == ma_dr_wav_container_rifx || container == ma_dr_wav_container_aiff) { return MA_TRUE; } else { return MA_FALSE; } } MA_PRIVATE MA_INLINE ma_uint16 ma_dr_wav_bytes_to_u16_le(const ma_uint8* data) { return ((ma_uint16)data[0] << 0) | ((ma_uint16)data[1] << 8); } MA_PRIVATE MA_INLINE ma_uint16 ma_dr_wav_bytes_to_u16_be(const ma_uint8* data) { return ((ma_uint16)data[1] << 0) | ((ma_uint16)data[0] << 8); } MA_PRIVATE MA_INLINE ma_uint16 ma_dr_wav_bytes_to_u16_ex(const ma_uint8* data, ma_dr_wav_container container) { if (ma_dr_wav_is_container_be(container)) { return ma_dr_wav_bytes_to_u16_be(data); } else { return ma_dr_wav_bytes_to_u16_le(data); } } MA_PRIVATE MA_INLINE ma_uint32 ma_dr_wav_bytes_to_u32_le(const ma_uint8* data) { return ((ma_uint32)data[0] << 0) | ((ma_uint32)data[1] << 8) | ((ma_uint32)data[2] << 16) | ((ma_uint32)data[3] << 24); } MA_PRIVATE MA_INLINE ma_uint32 ma_dr_wav_bytes_to_u32_be(const ma_uint8* data) { return ((ma_uint32)data[3] << 0) | ((ma_uint32)data[2] << 8) | ((ma_uint32)data[1] << 16) | ((ma_uint32)data[0] << 24); } MA_PRIVATE MA_INLINE ma_uint32 ma_dr_wav_bytes_to_u32_ex(const ma_uint8* data, ma_dr_wav_container container) { if (ma_dr_wav_is_container_be(container)) { return ma_dr_wav_bytes_to_u32_be(data); } else { return ma_dr_wav_bytes_to_u32_le(data); } } MA_PRIVATE ma_int64 ma_dr_wav_aiff_extented_to_s64(const ma_uint8* data) { ma_uint32 exponent = ((ma_uint32)data[0] << 8) | data[1]; ma_uint64 hi = ((ma_uint64)data[2] << 24) | ((ma_uint64)data[3] << 16) | ((ma_uint64)data[4] << 8) | ((ma_uint64)data[5] << 0); ma_uint64 lo = ((ma_uint64)data[6] << 24) | ((ma_uint64)data[7] << 16) | ((ma_uint64)data[8] << 8) | ((ma_uint64)data[9] << 0); ma_uint64 significand = (hi << 32) | lo; int sign = exponent >> 15; exponent &= 0x7FFF; if (exponent == 0 && significand == 0) { return 0; } else if (exponent == 0x7FFF) { return sign ? MA_DR_WAV_INT64_MIN : MA_DR_WAV_INT64_MAX; } exponent -= 16383; if (exponent > 63) { return sign ? MA_DR_WAV_INT64_MIN : MA_DR_WAV_INT64_MAX; } else if (exponent < 1) { return 0; } significand >>= (63 - exponent); if (sign) { return -(ma_int64)significand; } else { return (ma_int64)significand; } } MA_PRIVATE void* ma_dr_wav__malloc_default(size_t sz, void* pUserData) { (void)pUserData; return MA_DR_WAV_MALLOC(sz); } MA_PRIVATE void* ma_dr_wav__realloc_default(void* p, size_t sz, void* pUserData) { (void)pUserData; return MA_DR_WAV_REALLOC(p, sz); } MA_PRIVATE void ma_dr_wav__free_default(void* p, void* pUserData) { (void)pUserData; MA_DR_WAV_FREE(p); } MA_PRIVATE void* ma_dr_wav__malloc_from_callbacks(size_t sz, const ma_allocation_callbacks* pAllocationCallbacks) { if (pAllocationCallbacks == NULL) { return NULL; } if (pAllocationCallbacks->onMalloc != NULL) { return pAllocationCallbacks->onMalloc(sz, pAllocationCallbacks->pUserData); } if (pAllocationCallbacks->onRealloc != NULL) { return pAllocationCallbacks->onRealloc(NULL, sz, pAllocationCallbacks->pUserData); } return NULL; } MA_PRIVATE void* ma_dr_wav__realloc_from_callbacks(void* p, size_t szNew, size_t szOld, const ma_allocation_callbacks* pAllocationCallbacks) { if (pAllocationCallbacks == NULL) { return NULL; } if (pAllocationCallbacks->onRealloc != NULL) { return pAllocationCallbacks->onRealloc(p, szNew, pAllocationCallbacks->pUserData); } if (pAllocationCallbacks->onMalloc != NULL && pAllocationCallbacks->onFree != NULL) { void* p2; p2 = pAllocationCallbacks->onMalloc(szNew, pAllocationCallbacks->pUserData); if (p2 == NULL) { return NULL; } if (p != NULL) { MA_DR_WAV_COPY_MEMORY(p2, p, szOld); pAllocationCallbacks->onFree(p, pAllocationCallbacks->pUserData); } return p2; } return NULL; } MA_PRIVATE void ma_dr_wav__free_from_callbacks(void* p, const ma_allocation_callbacks* pAllocationCallbacks) { if (p == NULL || pAllocationCallbacks == NULL) { return; } if (pAllocationCallbacks->onFree != NULL) { pAllocationCallbacks->onFree(p, pAllocationCallbacks->pUserData); } } MA_PRIVATE ma_allocation_callbacks ma_dr_wav_copy_allocation_callbacks_or_defaults(const ma_allocation_callbacks* pAllocationCallbacks) { if (pAllocationCallbacks != NULL) { return *pAllocationCallbacks; } else { ma_allocation_callbacks allocationCallbacks; allocationCallbacks.pUserData = NULL; allocationCallbacks.onMalloc = ma_dr_wav__malloc_default; allocationCallbacks.onRealloc = ma_dr_wav__realloc_default; allocationCallbacks.onFree = ma_dr_wav__free_default; return allocationCallbacks; } } static MA_INLINE ma_bool32 ma_dr_wav__is_compressed_format_tag(ma_uint16 formatTag) { return formatTag == MA_DR_WAVE_FORMAT_ADPCM || formatTag == MA_DR_WAVE_FORMAT_DVI_ADPCM; } MA_PRIVATE unsigned int ma_dr_wav__chunk_padding_size_riff(ma_uint64 chunkSize) { return (unsigned int)(chunkSize % 2); } MA_PRIVATE unsigned int ma_dr_wav__chunk_padding_size_w64(ma_uint64 chunkSize) { return (unsigned int)(chunkSize % 8); } MA_PRIVATE ma_uint64 ma_dr_wav_read_pcm_frames_s16__msadpcm(ma_dr_wav* pWav, ma_uint64 samplesToRead, ma_int16* pBufferOut); MA_PRIVATE ma_uint64 ma_dr_wav_read_pcm_frames_s16__ima(ma_dr_wav* pWav, ma_uint64 samplesToRead, ma_int16* pBufferOut); MA_PRIVATE ma_bool32 ma_dr_wav_init_write__internal(ma_dr_wav* pWav, const ma_dr_wav_data_format* pFormat, ma_uint64 totalSampleCount); MA_PRIVATE ma_result ma_dr_wav__read_chunk_header(ma_dr_wav_read_proc onRead, void* pUserData, ma_dr_wav_container container, ma_uint64* pRunningBytesReadOut, ma_dr_wav_chunk_header* pHeaderOut) { if (container == ma_dr_wav_container_riff || container == ma_dr_wav_container_rifx || container == ma_dr_wav_container_rf64 || container == ma_dr_wav_container_aiff) { ma_uint8 sizeInBytes[4]; if (onRead(pUserData, pHeaderOut->id.fourcc, 4) != 4) { return MA_AT_END; } if (onRead(pUserData, sizeInBytes, 4) != 4) { return MA_INVALID_FILE; } pHeaderOut->sizeInBytes = ma_dr_wav_bytes_to_u32_ex(sizeInBytes, container); pHeaderOut->paddingSize = ma_dr_wav__chunk_padding_size_riff(pHeaderOut->sizeInBytes); *pRunningBytesReadOut += 8; } else if (container == ma_dr_wav_container_w64) { ma_uint8 sizeInBytes[8]; if (onRead(pUserData, pHeaderOut->id.guid, 16) != 16) { return MA_AT_END; } if (onRead(pUserData, sizeInBytes, 8) != 8) { return MA_INVALID_FILE; } pHeaderOut->sizeInBytes = ma_dr_wav_bytes_to_u64(sizeInBytes) - 24; pHeaderOut->paddingSize = ma_dr_wav__chunk_padding_size_w64(pHeaderOut->sizeInBytes); *pRunningBytesReadOut += 24; } else { return MA_INVALID_FILE; } return MA_SUCCESS; } MA_PRIVATE ma_bool32 ma_dr_wav__seek_forward(ma_dr_wav_seek_proc onSeek, ma_uint64 offset, void* pUserData) { ma_uint64 bytesRemainingToSeek = offset; while (bytesRemainingToSeek > 0) { if (bytesRemainingToSeek > 0x7FFFFFFF) { if (!onSeek(pUserData, 0x7FFFFFFF, ma_dr_wav_seek_origin_current)) { return MA_FALSE; } bytesRemainingToSeek -= 0x7FFFFFFF; } else { if (!onSeek(pUserData, (int)bytesRemainingToSeek, ma_dr_wav_seek_origin_current)) { return MA_FALSE; } bytesRemainingToSeek = 0; } } return MA_TRUE; } MA_PRIVATE ma_bool32 ma_dr_wav__seek_from_start(ma_dr_wav_seek_proc onSeek, ma_uint64 offset, void* pUserData) { if (offset <= 0x7FFFFFFF) { return onSeek(pUserData, (int)offset, ma_dr_wav_seek_origin_start); } if (!onSeek(pUserData, 0x7FFFFFFF, ma_dr_wav_seek_origin_start)) { return MA_FALSE; } offset -= 0x7FFFFFFF; for (;;) { if (offset <= 0x7FFFFFFF) { return onSeek(pUserData, (int)offset, ma_dr_wav_seek_origin_current); } if (!onSeek(pUserData, 0x7FFFFFFF, ma_dr_wav_seek_origin_current)) { return MA_FALSE; } offset -= 0x7FFFFFFF; } } MA_PRIVATE size_t ma_dr_wav__on_read(ma_dr_wav_read_proc onRead, void* pUserData, void* pBufferOut, size_t bytesToRead, ma_uint64* pCursor) { size_t bytesRead; MA_DR_WAV_ASSERT(onRead != NULL); MA_DR_WAV_ASSERT(pCursor != NULL); bytesRead = onRead(pUserData, pBufferOut, bytesToRead); *pCursor += bytesRead; return bytesRead; } #if 0 MA_PRIVATE ma_bool32 ma_dr_wav__on_seek(ma_dr_wav_seek_proc onSeek, void* pUserData, int offset, ma_dr_wav_seek_origin origin, ma_uint64* pCursor) { MA_DR_WAV_ASSERT(onSeek != NULL); MA_DR_WAV_ASSERT(pCursor != NULL); if (!onSeek(pUserData, offset, origin)) { return MA_FALSE; } if (origin == ma_dr_wav_seek_origin_start) { *pCursor = offset; } else { *pCursor += offset; } return MA_TRUE; } #endif #define MA_DR_WAV_SMPL_BYTES 36 #define MA_DR_WAV_SMPL_LOOP_BYTES 24 #define MA_DR_WAV_INST_BYTES 7 #define MA_DR_WAV_ACID_BYTES 24 #define MA_DR_WAV_CUE_BYTES 4 #define MA_DR_WAV_BEXT_BYTES 602 #define MA_DR_WAV_BEXT_DESCRIPTION_BYTES 256 #define MA_DR_WAV_BEXT_ORIGINATOR_NAME_BYTES 32 #define MA_DR_WAV_BEXT_ORIGINATOR_REF_BYTES 32 #define MA_DR_WAV_BEXT_RESERVED_BYTES 180 #define MA_DR_WAV_BEXT_UMID_BYTES 64 #define MA_DR_WAV_CUE_POINT_BYTES 24 #define MA_DR_WAV_LIST_LABEL_OR_NOTE_BYTES 4 #define MA_DR_WAV_LIST_LABELLED_TEXT_BYTES 20 #define MA_DR_WAV_METADATA_ALIGNMENT 8 typedef enum { ma_dr_wav__metadata_parser_stage_count, ma_dr_wav__metadata_parser_stage_read } ma_dr_wav__metadata_parser_stage; typedef struct { ma_dr_wav_read_proc onRead; ma_dr_wav_seek_proc onSeek; void *pReadSeekUserData; ma_dr_wav__metadata_parser_stage stage; ma_dr_wav_metadata *pMetadata; ma_uint32 metadataCount; ma_uint8 *pData; ma_uint8 *pDataCursor; ma_uint64 metadataCursor; ma_uint64 extraCapacity; } ma_dr_wav__metadata_parser; MA_PRIVATE size_t ma_dr_wav__metadata_memory_capacity(ma_dr_wav__metadata_parser* pParser) { ma_uint64 cap = sizeof(ma_dr_wav_metadata) * (ma_uint64)pParser->metadataCount + pParser->extraCapacity; if (cap > MA_SIZE_MAX) { return 0; } return (size_t)cap; } MA_PRIVATE ma_uint8* ma_dr_wav__metadata_get_memory(ma_dr_wav__metadata_parser* pParser, size_t size, size_t align) { ma_uint8* pResult; if (align) { ma_uintptr modulo = (ma_uintptr)pParser->pDataCursor % align; if (modulo != 0) { pParser->pDataCursor += align - modulo; } } pResult = pParser->pDataCursor; MA_DR_WAV_ASSERT((pResult + size) <= (pParser->pData + ma_dr_wav__metadata_memory_capacity(pParser))); pParser->pDataCursor += size; return pResult; } MA_PRIVATE void ma_dr_wav__metadata_request_extra_memory_for_stage_2(ma_dr_wav__metadata_parser* pParser, size_t bytes, size_t align) { size_t extra = bytes + (align ? (align - 1) : 0); pParser->extraCapacity += extra; } MA_PRIVATE ma_result ma_dr_wav__metadata_alloc(ma_dr_wav__metadata_parser* pParser, ma_allocation_callbacks* pAllocationCallbacks) { if (pParser->extraCapacity != 0 || pParser->metadataCount != 0) { pAllocationCallbacks->onFree(pParser->pData, pAllocationCallbacks->pUserData); pParser->pData = (ma_uint8*)pAllocationCallbacks->onMalloc(ma_dr_wav__metadata_memory_capacity(pParser), pAllocationCallbacks->pUserData); pParser->pDataCursor = pParser->pData; if (pParser->pData == NULL) { return MA_OUT_OF_MEMORY; } pParser->pMetadata = (ma_dr_wav_metadata*)ma_dr_wav__metadata_get_memory(pParser, sizeof(ma_dr_wav_metadata) * pParser->metadataCount, 1); pParser->metadataCursor = 0; } return MA_SUCCESS; } MA_PRIVATE size_t ma_dr_wav__metadata_parser_read(ma_dr_wav__metadata_parser* pParser, void* pBufferOut, size_t bytesToRead, ma_uint64* pCursor) { if (pCursor != NULL) { return ma_dr_wav__on_read(pParser->onRead, pParser->pReadSeekUserData, pBufferOut, bytesToRead, pCursor); } else { return pParser->onRead(pParser->pReadSeekUserData, pBufferOut, bytesToRead); } } MA_PRIVATE ma_uint64 ma_dr_wav__read_smpl_to_metadata_obj(ma_dr_wav__metadata_parser* pParser, const ma_dr_wav_chunk_header* pChunkHeader, ma_dr_wav_metadata* pMetadata) { ma_uint8 smplHeaderData[MA_DR_WAV_SMPL_BYTES]; ma_uint64 totalBytesRead = 0; size_t bytesJustRead; if (pMetadata == NULL) { return 0; } bytesJustRead = ma_dr_wav__metadata_parser_read(pParser, smplHeaderData, sizeof(smplHeaderData), &totalBytesRead); MA_DR_WAV_ASSERT(pParser->stage == ma_dr_wav__metadata_parser_stage_read); MA_DR_WAV_ASSERT(pChunkHeader != NULL); if (pMetadata != NULL && bytesJustRead == sizeof(smplHeaderData)) { ma_uint32 iSampleLoop; pMetadata->type = ma_dr_wav_metadata_type_smpl; pMetadata->data.smpl.manufacturerId = ma_dr_wav_bytes_to_u32(smplHeaderData + 0); pMetadata->data.smpl.productId = ma_dr_wav_bytes_to_u32(smplHeaderData + 4); pMetadata->data.smpl.samplePeriodNanoseconds = ma_dr_wav_bytes_to_u32(smplHeaderData + 8); pMetadata->data.smpl.midiUnityNote = ma_dr_wav_bytes_to_u32(smplHeaderData + 12); pMetadata->data.smpl.midiPitchFraction = ma_dr_wav_bytes_to_u32(smplHeaderData + 16); pMetadata->data.smpl.smpteFormat = ma_dr_wav_bytes_to_u32(smplHeaderData + 20); pMetadata->data.smpl.smpteOffset = ma_dr_wav_bytes_to_u32(smplHeaderData + 24); pMetadata->data.smpl.sampleLoopCount = ma_dr_wav_bytes_to_u32(smplHeaderData + 28); pMetadata->data.smpl.samplerSpecificDataSizeInBytes = ma_dr_wav_bytes_to_u32(smplHeaderData + 32); if (pMetadata->data.smpl.sampleLoopCount == (pChunkHeader->sizeInBytes - MA_DR_WAV_SMPL_BYTES) / MA_DR_WAV_SMPL_LOOP_BYTES) { pMetadata->data.smpl.pLoops = (ma_dr_wav_smpl_loop*)ma_dr_wav__metadata_get_memory(pParser, sizeof(ma_dr_wav_smpl_loop) * pMetadata->data.smpl.sampleLoopCount, MA_DR_WAV_METADATA_ALIGNMENT); for (iSampleLoop = 0; iSampleLoop < pMetadata->data.smpl.sampleLoopCount; ++iSampleLoop) { ma_uint8 smplLoopData[MA_DR_WAV_SMPL_LOOP_BYTES]; bytesJustRead = ma_dr_wav__metadata_parser_read(pParser, smplLoopData, sizeof(smplLoopData), &totalBytesRead); if (bytesJustRead == sizeof(smplLoopData)) { pMetadata->data.smpl.pLoops[iSampleLoop].cuePointId = ma_dr_wav_bytes_to_u32(smplLoopData + 0); pMetadata->data.smpl.pLoops[iSampleLoop].type = ma_dr_wav_bytes_to_u32(smplLoopData + 4); pMetadata->data.smpl.pLoops[iSampleLoop].firstSampleByteOffset = ma_dr_wav_bytes_to_u32(smplLoopData + 8); pMetadata->data.smpl.pLoops[iSampleLoop].lastSampleByteOffset = ma_dr_wav_bytes_to_u32(smplLoopData + 12); pMetadata->data.smpl.pLoops[iSampleLoop].sampleFraction = ma_dr_wav_bytes_to_u32(smplLoopData + 16); pMetadata->data.smpl.pLoops[iSampleLoop].playCount = ma_dr_wav_bytes_to_u32(smplLoopData + 20); } else { break; } } if (pMetadata->data.smpl.samplerSpecificDataSizeInBytes > 0) { pMetadata->data.smpl.pSamplerSpecificData = ma_dr_wav__metadata_get_memory(pParser, pMetadata->data.smpl.samplerSpecificDataSizeInBytes, 1); MA_DR_WAV_ASSERT(pMetadata->data.smpl.pSamplerSpecificData != NULL); ma_dr_wav__metadata_parser_read(pParser, pMetadata->data.smpl.pSamplerSpecificData, pMetadata->data.smpl.samplerSpecificDataSizeInBytes, &totalBytesRead); } } } return totalBytesRead; } MA_PRIVATE ma_uint64 ma_dr_wav__read_cue_to_metadata_obj(ma_dr_wav__metadata_parser* pParser, const ma_dr_wav_chunk_header* pChunkHeader, ma_dr_wav_metadata* pMetadata) { ma_uint8 cueHeaderSectionData[MA_DR_WAV_CUE_BYTES]; ma_uint64 totalBytesRead = 0; size_t bytesJustRead; if (pMetadata == NULL) { return 0; } bytesJustRead = ma_dr_wav__metadata_parser_read(pParser, cueHeaderSectionData, sizeof(cueHeaderSectionData), &totalBytesRead); MA_DR_WAV_ASSERT(pParser->stage == ma_dr_wav__metadata_parser_stage_read); if (bytesJustRead == sizeof(cueHeaderSectionData)) { pMetadata->type = ma_dr_wav_metadata_type_cue; pMetadata->data.cue.cuePointCount = ma_dr_wav_bytes_to_u32(cueHeaderSectionData); if (pMetadata->data.cue.cuePointCount == (pChunkHeader->sizeInBytes - MA_DR_WAV_CUE_BYTES) / MA_DR_WAV_CUE_POINT_BYTES) { pMetadata->data.cue.pCuePoints = (ma_dr_wav_cue_point*)ma_dr_wav__metadata_get_memory(pParser, sizeof(ma_dr_wav_cue_point) * pMetadata->data.cue.cuePointCount, MA_DR_WAV_METADATA_ALIGNMENT); MA_DR_WAV_ASSERT(pMetadata->data.cue.pCuePoints != NULL); if (pMetadata->data.cue.cuePointCount > 0) { ma_uint32 iCuePoint; for (iCuePoint = 0; iCuePoint < pMetadata->data.cue.cuePointCount; ++iCuePoint) { ma_uint8 cuePointData[MA_DR_WAV_CUE_POINT_BYTES]; bytesJustRead = ma_dr_wav__metadata_parser_read(pParser, cuePointData, sizeof(cuePointData), &totalBytesRead); if (bytesJustRead == sizeof(cuePointData)) { pMetadata->data.cue.pCuePoints[iCuePoint].id = ma_dr_wav_bytes_to_u32(cuePointData + 0); pMetadata->data.cue.pCuePoints[iCuePoint].playOrderPosition = ma_dr_wav_bytes_to_u32(cuePointData + 4); pMetadata->data.cue.pCuePoints[iCuePoint].dataChunkId[0] = cuePointData[8]; pMetadata->data.cue.pCuePoints[iCuePoint].dataChunkId[1] = cuePointData[9]; pMetadata->data.cue.pCuePoints[iCuePoint].dataChunkId[2] = cuePointData[10]; pMetadata->data.cue.pCuePoints[iCuePoint].dataChunkId[3] = cuePointData[11]; pMetadata->data.cue.pCuePoints[iCuePoint].chunkStart = ma_dr_wav_bytes_to_u32(cuePointData + 12); pMetadata->data.cue.pCuePoints[iCuePoint].blockStart = ma_dr_wav_bytes_to_u32(cuePointData + 16); pMetadata->data.cue.pCuePoints[iCuePoint].sampleByteOffset = ma_dr_wav_bytes_to_u32(cuePointData + 20); } else { break; } } } } } return totalBytesRead; } MA_PRIVATE ma_uint64 ma_dr_wav__read_inst_to_metadata_obj(ma_dr_wav__metadata_parser* pParser, ma_dr_wav_metadata* pMetadata) { ma_uint8 instData[MA_DR_WAV_INST_BYTES]; ma_uint64 bytesRead; if (pMetadata == NULL) { return 0; } bytesRead = ma_dr_wav__metadata_parser_read(pParser, instData, sizeof(instData), NULL); MA_DR_WAV_ASSERT(pParser->stage == ma_dr_wav__metadata_parser_stage_read); if (bytesRead == sizeof(instData)) { pMetadata->type = ma_dr_wav_metadata_type_inst; pMetadata->data.inst.midiUnityNote = (ma_int8)instData[0]; pMetadata->data.inst.fineTuneCents = (ma_int8)instData[1]; pMetadata->data.inst.gainDecibels = (ma_int8)instData[2]; pMetadata->data.inst.lowNote = (ma_int8)instData[3]; pMetadata->data.inst.highNote = (ma_int8)instData[4]; pMetadata->data.inst.lowVelocity = (ma_int8)instData[5]; pMetadata->data.inst.highVelocity = (ma_int8)instData[6]; } return bytesRead; } MA_PRIVATE ma_uint64 ma_dr_wav__read_acid_to_metadata_obj(ma_dr_wav__metadata_parser* pParser, ma_dr_wav_metadata* pMetadata) { ma_uint8 acidData[MA_DR_WAV_ACID_BYTES]; ma_uint64 bytesRead; if (pMetadata == NULL) { return 0; } bytesRead = ma_dr_wav__metadata_parser_read(pParser, acidData, sizeof(acidData), NULL); MA_DR_WAV_ASSERT(pParser->stage == ma_dr_wav__metadata_parser_stage_read); if (bytesRead == sizeof(acidData)) { pMetadata->type = ma_dr_wav_metadata_type_acid; pMetadata->data.acid.flags = ma_dr_wav_bytes_to_u32(acidData + 0); pMetadata->data.acid.midiUnityNote = ma_dr_wav_bytes_to_u16(acidData + 4); pMetadata->data.acid.reserved1 = ma_dr_wav_bytes_to_u16(acidData + 6); pMetadata->data.acid.reserved2 = ma_dr_wav_bytes_to_f32(acidData + 8); pMetadata->data.acid.numBeats = ma_dr_wav_bytes_to_u32(acidData + 12); pMetadata->data.acid.meterDenominator = ma_dr_wav_bytes_to_u16(acidData + 16); pMetadata->data.acid.meterNumerator = ma_dr_wav_bytes_to_u16(acidData + 18); pMetadata->data.acid.tempo = ma_dr_wav_bytes_to_f32(acidData + 20); } return bytesRead; } MA_PRIVATE size_t ma_dr_wav__strlen(const char* str) { size_t result = 0; while (*str++) { result += 1; } return result; } MA_PRIVATE size_t ma_dr_wav__strlen_clamped(const char* str, size_t maxToRead) { size_t result = 0; while (*str++ && result < maxToRead) { result += 1; } return result; } MA_PRIVATE char* ma_dr_wav__metadata_copy_string(ma_dr_wav__metadata_parser* pParser, const char* str, size_t maxToRead) { size_t len = ma_dr_wav__strlen_clamped(str, maxToRead); if (len) { char* result = (char*)ma_dr_wav__metadata_get_memory(pParser, len + 1, 1); MA_DR_WAV_ASSERT(result != NULL); MA_DR_WAV_COPY_MEMORY(result, str, len); result[len] = '\0'; return result; } else { return NULL; } } typedef struct { const void* pBuffer; size_t sizeInBytes; size_t cursor; } ma_dr_wav_buffer_reader; MA_PRIVATE ma_result ma_dr_wav_buffer_reader_init(const void* pBuffer, size_t sizeInBytes, ma_dr_wav_buffer_reader* pReader) { MA_DR_WAV_ASSERT(pBuffer != NULL); MA_DR_WAV_ASSERT(pReader != NULL); MA_DR_WAV_ZERO_OBJECT(pReader); pReader->pBuffer = pBuffer; pReader->sizeInBytes = sizeInBytes; pReader->cursor = 0; return MA_SUCCESS; } MA_PRIVATE const void* ma_dr_wav_buffer_reader_ptr(const ma_dr_wav_buffer_reader* pReader) { MA_DR_WAV_ASSERT(pReader != NULL); return ma_dr_wav_offset_ptr(pReader->pBuffer, pReader->cursor); } MA_PRIVATE ma_result ma_dr_wav_buffer_reader_seek(ma_dr_wav_buffer_reader* pReader, size_t bytesToSeek) { MA_DR_WAV_ASSERT(pReader != NULL); if (pReader->cursor + bytesToSeek > pReader->sizeInBytes) { return MA_BAD_SEEK; } pReader->cursor += bytesToSeek; return MA_SUCCESS; } MA_PRIVATE ma_result ma_dr_wav_buffer_reader_read(ma_dr_wav_buffer_reader* pReader, void* pDst, size_t bytesToRead, size_t* pBytesRead) { ma_result result = MA_SUCCESS; size_t bytesRemaining; MA_DR_WAV_ASSERT(pReader != NULL); if (pBytesRead != NULL) { *pBytesRead = 0; } bytesRemaining = (pReader->sizeInBytes - pReader->cursor); if (bytesToRead > bytesRemaining) { bytesToRead = bytesRemaining; } if (pDst == NULL) { result = ma_dr_wav_buffer_reader_seek(pReader, bytesToRead); } else { MA_DR_WAV_COPY_MEMORY(pDst, ma_dr_wav_buffer_reader_ptr(pReader), bytesToRead); pReader->cursor += bytesToRead; } MA_DR_WAV_ASSERT(pReader->cursor <= pReader->sizeInBytes); if (result == MA_SUCCESS) { if (pBytesRead != NULL) { *pBytesRead = bytesToRead; } } return MA_SUCCESS; } MA_PRIVATE ma_result ma_dr_wav_buffer_reader_read_u16(ma_dr_wav_buffer_reader* pReader, ma_uint16* pDst) { ma_result result; size_t bytesRead; ma_uint8 data[2]; MA_DR_WAV_ASSERT(pReader != NULL); MA_DR_WAV_ASSERT(pDst != NULL); *pDst = 0; result = ma_dr_wav_buffer_reader_read(pReader, data, sizeof(*pDst), &bytesRead); if (result != MA_SUCCESS || bytesRead != sizeof(*pDst)) { return result; } *pDst = ma_dr_wav_bytes_to_u16(data); return MA_SUCCESS; } MA_PRIVATE ma_result ma_dr_wav_buffer_reader_read_u32(ma_dr_wav_buffer_reader* pReader, ma_uint32* pDst) { ma_result result; size_t bytesRead; ma_uint8 data[4]; MA_DR_WAV_ASSERT(pReader != NULL); MA_DR_WAV_ASSERT(pDst != NULL); *pDst = 0; result = ma_dr_wav_buffer_reader_read(pReader, data, sizeof(*pDst), &bytesRead); if (result != MA_SUCCESS || bytesRead != sizeof(*pDst)) { return result; } *pDst = ma_dr_wav_bytes_to_u32(data); return MA_SUCCESS; } MA_PRIVATE ma_uint64 ma_dr_wav__read_bext_to_metadata_obj(ma_dr_wav__metadata_parser* pParser, ma_dr_wav_metadata* pMetadata, ma_uint64 chunkSize) { ma_uint8 bextData[MA_DR_WAV_BEXT_BYTES]; size_t bytesRead = ma_dr_wav__metadata_parser_read(pParser, bextData, sizeof(bextData), NULL); MA_DR_WAV_ASSERT(pParser->stage == ma_dr_wav__metadata_parser_stage_read); if (bytesRead == sizeof(bextData)) { ma_dr_wav_buffer_reader reader; ma_uint32 timeReferenceLow; ma_uint32 timeReferenceHigh; size_t extraBytes; pMetadata->type = ma_dr_wav_metadata_type_bext; if (ma_dr_wav_buffer_reader_init(bextData, bytesRead, &reader) == MA_SUCCESS) { pMetadata->data.bext.pDescription = ma_dr_wav__metadata_copy_string(pParser, (const char*)ma_dr_wav_buffer_reader_ptr(&reader), MA_DR_WAV_BEXT_DESCRIPTION_BYTES); ma_dr_wav_buffer_reader_seek(&reader, MA_DR_WAV_BEXT_DESCRIPTION_BYTES); pMetadata->data.bext.pOriginatorName = ma_dr_wav__metadata_copy_string(pParser, (const char*)ma_dr_wav_buffer_reader_ptr(&reader), MA_DR_WAV_BEXT_ORIGINATOR_NAME_BYTES); ma_dr_wav_buffer_reader_seek(&reader, MA_DR_WAV_BEXT_ORIGINATOR_NAME_BYTES); pMetadata->data.bext.pOriginatorReference = ma_dr_wav__metadata_copy_string(pParser, (const char*)ma_dr_wav_buffer_reader_ptr(&reader), MA_DR_WAV_BEXT_ORIGINATOR_REF_BYTES); ma_dr_wav_buffer_reader_seek(&reader, MA_DR_WAV_BEXT_ORIGINATOR_REF_BYTES); ma_dr_wav_buffer_reader_read(&reader, pMetadata->data.bext.pOriginationDate, sizeof(pMetadata->data.bext.pOriginationDate), NULL); ma_dr_wav_buffer_reader_read(&reader, pMetadata->data.bext.pOriginationTime, sizeof(pMetadata->data.bext.pOriginationTime), NULL); ma_dr_wav_buffer_reader_read_u32(&reader, &timeReferenceLow); ma_dr_wav_buffer_reader_read_u32(&reader, &timeReferenceHigh); pMetadata->data.bext.timeReference = ((ma_uint64)timeReferenceHigh << 32) + timeReferenceLow; ma_dr_wav_buffer_reader_read_u16(&reader, &pMetadata->data.bext.version); pMetadata->data.bext.pUMID = ma_dr_wav__metadata_get_memory(pParser, MA_DR_WAV_BEXT_UMID_BYTES, 1); ma_dr_wav_buffer_reader_read(&reader, pMetadata->data.bext.pUMID, MA_DR_WAV_BEXT_UMID_BYTES, NULL); ma_dr_wav_buffer_reader_read_u16(&reader, &pMetadata->data.bext.loudnessValue); ma_dr_wav_buffer_reader_read_u16(&reader, &pMetadata->data.bext.loudnessRange); ma_dr_wav_buffer_reader_read_u16(&reader, &pMetadata->data.bext.maxTruePeakLevel); ma_dr_wav_buffer_reader_read_u16(&reader, &pMetadata->data.bext.maxMomentaryLoudness); ma_dr_wav_buffer_reader_read_u16(&reader, &pMetadata->data.bext.maxShortTermLoudness); MA_DR_WAV_ASSERT((ma_dr_wav_offset_ptr(ma_dr_wav_buffer_reader_ptr(&reader), MA_DR_WAV_BEXT_RESERVED_BYTES)) == (bextData + MA_DR_WAV_BEXT_BYTES)); extraBytes = (size_t)(chunkSize - MA_DR_WAV_BEXT_BYTES); if (extraBytes > 0) { pMetadata->data.bext.pCodingHistory = (char*)ma_dr_wav__metadata_get_memory(pParser, extraBytes + 1, 1); MA_DR_WAV_ASSERT(pMetadata->data.bext.pCodingHistory != NULL); bytesRead += ma_dr_wav__metadata_parser_read(pParser, pMetadata->data.bext.pCodingHistory, extraBytes, NULL); pMetadata->data.bext.codingHistorySize = (ma_uint32)ma_dr_wav__strlen(pMetadata->data.bext.pCodingHistory); } else { pMetadata->data.bext.pCodingHistory = NULL; pMetadata->data.bext.codingHistorySize = 0; } } } return bytesRead; } MA_PRIVATE ma_uint64 ma_dr_wav__read_list_label_or_note_to_metadata_obj(ma_dr_wav__metadata_parser* pParser, ma_dr_wav_metadata* pMetadata, ma_uint64 chunkSize, ma_dr_wav_metadata_type type) { ma_uint8 cueIDBuffer[MA_DR_WAV_LIST_LABEL_OR_NOTE_BYTES]; ma_uint64 totalBytesRead = 0; size_t bytesJustRead = ma_dr_wav__metadata_parser_read(pParser, cueIDBuffer, sizeof(cueIDBuffer), &totalBytesRead); MA_DR_WAV_ASSERT(pParser->stage == ma_dr_wav__metadata_parser_stage_read); if (bytesJustRead == sizeof(cueIDBuffer)) { ma_uint32 sizeIncludingNullTerminator; pMetadata->type = type; pMetadata->data.labelOrNote.cuePointId = ma_dr_wav_bytes_to_u32(cueIDBuffer); sizeIncludingNullTerminator = (ma_uint32)chunkSize - MA_DR_WAV_LIST_LABEL_OR_NOTE_BYTES; if (sizeIncludingNullTerminator > 0) { pMetadata->data.labelOrNote.stringLength = sizeIncludingNullTerminator - 1; pMetadata->data.labelOrNote.pString = (char*)ma_dr_wav__metadata_get_memory(pParser, sizeIncludingNullTerminator, 1); MA_DR_WAV_ASSERT(pMetadata->data.labelOrNote.pString != NULL); ma_dr_wav__metadata_parser_read(pParser, pMetadata->data.labelOrNote.pString, sizeIncludingNullTerminator, &totalBytesRead); } else { pMetadata->data.labelOrNote.stringLength = 0; pMetadata->data.labelOrNote.pString = NULL; } } return totalBytesRead; } MA_PRIVATE ma_uint64 ma_dr_wav__read_list_labelled_cue_region_to_metadata_obj(ma_dr_wav__metadata_parser* pParser, ma_dr_wav_metadata* pMetadata, ma_uint64 chunkSize) { ma_uint8 buffer[MA_DR_WAV_LIST_LABELLED_TEXT_BYTES]; ma_uint64 totalBytesRead = 0; size_t bytesJustRead = ma_dr_wav__metadata_parser_read(pParser, buffer, sizeof(buffer), &totalBytesRead); MA_DR_WAV_ASSERT(pParser->stage == ma_dr_wav__metadata_parser_stage_read); if (bytesJustRead == sizeof(buffer)) { ma_uint32 sizeIncludingNullTerminator; pMetadata->type = ma_dr_wav_metadata_type_list_labelled_cue_region; pMetadata->data.labelledCueRegion.cuePointId = ma_dr_wav_bytes_to_u32(buffer + 0); pMetadata->data.labelledCueRegion.sampleLength = ma_dr_wav_bytes_to_u32(buffer + 4); pMetadata->data.labelledCueRegion.purposeId[0] = buffer[8]; pMetadata->data.labelledCueRegion.purposeId[1] = buffer[9]; pMetadata->data.labelledCueRegion.purposeId[2] = buffer[10]; pMetadata->data.labelledCueRegion.purposeId[3] = buffer[11]; pMetadata->data.labelledCueRegion.country = ma_dr_wav_bytes_to_u16(buffer + 12); pMetadata->data.labelledCueRegion.language = ma_dr_wav_bytes_to_u16(buffer + 14); pMetadata->data.labelledCueRegion.dialect = ma_dr_wav_bytes_to_u16(buffer + 16); pMetadata->data.labelledCueRegion.codePage = ma_dr_wav_bytes_to_u16(buffer + 18); sizeIncludingNullTerminator = (ma_uint32)chunkSize - MA_DR_WAV_LIST_LABELLED_TEXT_BYTES; if (sizeIncludingNullTerminator > 0) { pMetadata->data.labelledCueRegion.stringLength = sizeIncludingNullTerminator - 1; pMetadata->data.labelledCueRegion.pString = (char*)ma_dr_wav__metadata_get_memory(pParser, sizeIncludingNullTerminator, 1); MA_DR_WAV_ASSERT(pMetadata->data.labelledCueRegion.pString != NULL); ma_dr_wav__metadata_parser_read(pParser, pMetadata->data.labelledCueRegion.pString, sizeIncludingNullTerminator, &totalBytesRead); } else { pMetadata->data.labelledCueRegion.stringLength = 0; pMetadata->data.labelledCueRegion.pString = NULL; } } return totalBytesRead; } MA_PRIVATE ma_uint64 ma_dr_wav__metadata_process_info_text_chunk(ma_dr_wav__metadata_parser* pParser, ma_uint64 chunkSize, ma_dr_wav_metadata_type type) { ma_uint64 bytesRead = 0; ma_uint32 stringSizeWithNullTerminator = (ma_uint32)chunkSize; if (pParser->stage == ma_dr_wav__metadata_parser_stage_count) { pParser->metadataCount += 1; ma_dr_wav__metadata_request_extra_memory_for_stage_2(pParser, stringSizeWithNullTerminator, 1); } else { ma_dr_wav_metadata* pMetadata = &pParser->pMetadata[pParser->metadataCursor]; pMetadata->type = type; if (stringSizeWithNullTerminator > 0) { pMetadata->data.infoText.stringLength = stringSizeWithNullTerminator - 1; pMetadata->data.infoText.pString = (char*)ma_dr_wav__metadata_get_memory(pParser, stringSizeWithNullTerminator, 1); MA_DR_WAV_ASSERT(pMetadata->data.infoText.pString != NULL); bytesRead = ma_dr_wav__metadata_parser_read(pParser, pMetadata->data.infoText.pString, (size_t)stringSizeWithNullTerminator, NULL); if (bytesRead == chunkSize) { pParser->metadataCursor += 1; } else { } } else { pMetadata->data.infoText.stringLength = 0; pMetadata->data.infoText.pString = NULL; pParser->metadataCursor += 1; } } return bytesRead; } MA_PRIVATE ma_uint64 ma_dr_wav__metadata_process_unknown_chunk(ma_dr_wav__metadata_parser* pParser, const ma_uint8* pChunkId, ma_uint64 chunkSize, ma_dr_wav_metadata_location location) { ma_uint64 bytesRead = 0; if (location == ma_dr_wav_metadata_location_invalid) { return 0; } if (ma_dr_wav_fourcc_equal(pChunkId, "data") || ma_dr_wav_fourcc_equal(pChunkId, "fmt ") || ma_dr_wav_fourcc_equal(pChunkId, "fact")) { return 0; } if (pParser->stage == ma_dr_wav__metadata_parser_stage_count) { pParser->metadataCount += 1; ma_dr_wav__metadata_request_extra_memory_for_stage_2(pParser, (size_t)chunkSize, 1); } else { ma_dr_wav_metadata* pMetadata = &pParser->pMetadata[pParser->metadataCursor]; pMetadata->type = ma_dr_wav_metadata_type_unknown; pMetadata->data.unknown.chunkLocation = location; pMetadata->data.unknown.id[0] = pChunkId[0]; pMetadata->data.unknown.id[1] = pChunkId[1]; pMetadata->data.unknown.id[2] = pChunkId[2]; pMetadata->data.unknown.id[3] = pChunkId[3]; pMetadata->data.unknown.dataSizeInBytes = (ma_uint32)chunkSize; pMetadata->data.unknown.pData = (ma_uint8 *)ma_dr_wav__metadata_get_memory(pParser, (size_t)chunkSize, 1); MA_DR_WAV_ASSERT(pMetadata->data.unknown.pData != NULL); bytesRead = ma_dr_wav__metadata_parser_read(pParser, pMetadata->data.unknown.pData, pMetadata->data.unknown.dataSizeInBytes, NULL); if (bytesRead == pMetadata->data.unknown.dataSizeInBytes) { pParser->metadataCursor += 1; } else { } } return bytesRead; } MA_PRIVATE ma_bool32 ma_dr_wav__chunk_matches(ma_dr_wav_metadata_type allowedMetadataTypes, const ma_uint8* pChunkID, ma_dr_wav_metadata_type type, const char* pID) { return (allowedMetadataTypes & type) && ma_dr_wav_fourcc_equal(pChunkID, pID); } MA_PRIVATE ma_uint64 ma_dr_wav__metadata_process_chunk(ma_dr_wav__metadata_parser* pParser, const ma_dr_wav_chunk_header* pChunkHeader, ma_dr_wav_metadata_type allowedMetadataTypes) { const ma_uint8 *pChunkID = pChunkHeader->id.fourcc; ma_uint64 bytesRead = 0; if (ma_dr_wav__chunk_matches(allowedMetadataTypes, pChunkID, ma_dr_wav_metadata_type_smpl, "smpl")) { if (pChunkHeader->sizeInBytes >= MA_DR_WAV_SMPL_BYTES) { if (pParser->stage == ma_dr_wav__metadata_parser_stage_count) { ma_uint8 buffer[4]; size_t bytesJustRead; if (!pParser->onSeek(pParser->pReadSeekUserData, 28, ma_dr_wav_seek_origin_current)) { return bytesRead; } bytesRead += 28; bytesJustRead = ma_dr_wav__metadata_parser_read(pParser, buffer, sizeof(buffer), &bytesRead); if (bytesJustRead == sizeof(buffer)) { ma_uint32 loopCount = ma_dr_wav_bytes_to_u32(buffer); ma_uint64 calculatedLoopCount; calculatedLoopCount = (pChunkHeader->sizeInBytes - MA_DR_WAV_SMPL_BYTES) / MA_DR_WAV_SMPL_LOOP_BYTES; if (calculatedLoopCount == loopCount) { bytesJustRead = ma_dr_wav__metadata_parser_read(pParser, buffer, sizeof(buffer), &bytesRead); if (bytesJustRead == sizeof(buffer)) { ma_uint32 samplerSpecificDataSizeInBytes = ma_dr_wav_bytes_to_u32(buffer); pParser->metadataCount += 1; ma_dr_wav__metadata_request_extra_memory_for_stage_2(pParser, sizeof(ma_dr_wav_smpl_loop) * loopCount, MA_DR_WAV_METADATA_ALIGNMENT); ma_dr_wav__metadata_request_extra_memory_for_stage_2(pParser, samplerSpecificDataSizeInBytes, 1); } } else { } } } else { bytesRead = ma_dr_wav__read_smpl_to_metadata_obj(pParser, pChunkHeader, &pParser->pMetadata[pParser->metadataCursor]); if (bytesRead == pChunkHeader->sizeInBytes) { pParser->metadataCursor += 1; } else { } } } else { } } else if (ma_dr_wav__chunk_matches(allowedMetadataTypes, pChunkID, ma_dr_wav_metadata_type_inst, "inst")) { if (pChunkHeader->sizeInBytes == MA_DR_WAV_INST_BYTES) { if (pParser->stage == ma_dr_wav__metadata_parser_stage_count) { pParser->metadataCount += 1; } else { bytesRead = ma_dr_wav__read_inst_to_metadata_obj(pParser, &pParser->pMetadata[pParser->metadataCursor]); if (bytesRead == pChunkHeader->sizeInBytes) { pParser->metadataCursor += 1; } else { } } } else { } } else if (ma_dr_wav__chunk_matches(allowedMetadataTypes, pChunkID, ma_dr_wav_metadata_type_acid, "acid")) { if (pChunkHeader->sizeInBytes == MA_DR_WAV_ACID_BYTES) { if (pParser->stage == ma_dr_wav__metadata_parser_stage_count) { pParser->metadataCount += 1; } else { bytesRead = ma_dr_wav__read_acid_to_metadata_obj(pParser, &pParser->pMetadata[pParser->metadataCursor]); if (bytesRead == pChunkHeader->sizeInBytes) { pParser->metadataCursor += 1; } else { } } } else { } } else if (ma_dr_wav__chunk_matches(allowedMetadataTypes, pChunkID, ma_dr_wav_metadata_type_cue, "cue ")) { if (pChunkHeader->sizeInBytes >= MA_DR_WAV_CUE_BYTES) { if (pParser->stage == ma_dr_wav__metadata_parser_stage_count) { size_t cueCount; pParser->metadataCount += 1; cueCount = (size_t)(pChunkHeader->sizeInBytes - MA_DR_WAV_CUE_BYTES) / MA_DR_WAV_CUE_POINT_BYTES; ma_dr_wav__metadata_request_extra_memory_for_stage_2(pParser, sizeof(ma_dr_wav_cue_point) * cueCount, MA_DR_WAV_METADATA_ALIGNMENT); } else { bytesRead = ma_dr_wav__read_cue_to_metadata_obj(pParser, pChunkHeader, &pParser->pMetadata[pParser->metadataCursor]); if (bytesRead == pChunkHeader->sizeInBytes) { pParser->metadataCursor += 1; } else { } } } else { } } else if (ma_dr_wav__chunk_matches(allowedMetadataTypes, pChunkID, ma_dr_wav_metadata_type_bext, "bext")) { if (pChunkHeader->sizeInBytes >= MA_DR_WAV_BEXT_BYTES) { if (pParser->stage == ma_dr_wav__metadata_parser_stage_count) { char buffer[MA_DR_WAV_BEXT_DESCRIPTION_BYTES + 1]; size_t allocSizeNeeded = MA_DR_WAV_BEXT_UMID_BYTES; size_t bytesJustRead; buffer[MA_DR_WAV_BEXT_DESCRIPTION_BYTES] = '\0'; bytesJustRead = ma_dr_wav__metadata_parser_read(pParser, buffer, MA_DR_WAV_BEXT_DESCRIPTION_BYTES, &bytesRead); if (bytesJustRead != MA_DR_WAV_BEXT_DESCRIPTION_BYTES) { return bytesRead; } allocSizeNeeded += ma_dr_wav__strlen(buffer) + 1; buffer[MA_DR_WAV_BEXT_ORIGINATOR_NAME_BYTES] = '\0'; bytesJustRead = ma_dr_wav__metadata_parser_read(pParser, buffer, MA_DR_WAV_BEXT_ORIGINATOR_NAME_BYTES, &bytesRead); if (bytesJustRead != MA_DR_WAV_BEXT_ORIGINATOR_NAME_BYTES) { return bytesRead; } allocSizeNeeded += ma_dr_wav__strlen(buffer) + 1; buffer[MA_DR_WAV_BEXT_ORIGINATOR_REF_BYTES] = '\0'; bytesJustRead = ma_dr_wav__metadata_parser_read(pParser, buffer, MA_DR_WAV_BEXT_ORIGINATOR_REF_BYTES, &bytesRead); if (bytesJustRead != MA_DR_WAV_BEXT_ORIGINATOR_REF_BYTES) { return bytesRead; } allocSizeNeeded += ma_dr_wav__strlen(buffer) + 1; allocSizeNeeded += (size_t)pChunkHeader->sizeInBytes - MA_DR_WAV_BEXT_BYTES; ma_dr_wav__metadata_request_extra_memory_for_stage_2(pParser, allocSizeNeeded, 1); pParser->metadataCount += 1; } else { bytesRead = ma_dr_wav__read_bext_to_metadata_obj(pParser, &pParser->pMetadata[pParser->metadataCursor], pChunkHeader->sizeInBytes); if (bytesRead == pChunkHeader->sizeInBytes) { pParser->metadataCursor += 1; } else { } } } else { } } else if (ma_dr_wav_fourcc_equal(pChunkID, "LIST") || ma_dr_wav_fourcc_equal(pChunkID, "list")) { ma_dr_wav_metadata_location listType = ma_dr_wav_metadata_location_invalid; while (bytesRead < pChunkHeader->sizeInBytes) { ma_uint8 subchunkId[4]; ma_uint8 subchunkSizeBuffer[4]; ma_uint64 subchunkDataSize; ma_uint64 subchunkBytesRead = 0; ma_uint64 bytesJustRead = ma_dr_wav__metadata_parser_read(pParser, subchunkId, sizeof(subchunkId), &bytesRead); if (bytesJustRead != sizeof(subchunkId)) { break; } if (ma_dr_wav_fourcc_equal(subchunkId, "adtl")) { listType = ma_dr_wav_metadata_location_inside_adtl_list; continue; } else if (ma_dr_wav_fourcc_equal(subchunkId, "INFO")) { listType = ma_dr_wav_metadata_location_inside_info_list; continue; } bytesJustRead = ma_dr_wav__metadata_parser_read(pParser, subchunkSizeBuffer, sizeof(subchunkSizeBuffer), &bytesRead); if (bytesJustRead != sizeof(subchunkSizeBuffer)) { break; } subchunkDataSize = ma_dr_wav_bytes_to_u32(subchunkSizeBuffer); if (ma_dr_wav__chunk_matches(allowedMetadataTypes, subchunkId, ma_dr_wav_metadata_type_list_label, "labl") || ma_dr_wav__chunk_matches(allowedMetadataTypes, subchunkId, ma_dr_wav_metadata_type_list_note, "note")) { if (subchunkDataSize >= MA_DR_WAV_LIST_LABEL_OR_NOTE_BYTES) { ma_uint64 stringSizeWithNullTerm = subchunkDataSize - MA_DR_WAV_LIST_LABEL_OR_NOTE_BYTES; if (pParser->stage == ma_dr_wav__metadata_parser_stage_count) { pParser->metadataCount += 1; ma_dr_wav__metadata_request_extra_memory_for_stage_2(pParser, (size_t)stringSizeWithNullTerm, 1); } else { subchunkBytesRead = ma_dr_wav__read_list_label_or_note_to_metadata_obj(pParser, &pParser->pMetadata[pParser->metadataCursor], subchunkDataSize, ma_dr_wav_fourcc_equal(subchunkId, "labl") ? ma_dr_wav_metadata_type_list_label : ma_dr_wav_metadata_type_list_note); if (subchunkBytesRead == subchunkDataSize) { pParser->metadataCursor += 1; } else { } } } else { } } else if (ma_dr_wav__chunk_matches(allowedMetadataTypes, subchunkId, ma_dr_wav_metadata_type_list_labelled_cue_region, "ltxt")) { if (subchunkDataSize >= MA_DR_WAV_LIST_LABELLED_TEXT_BYTES) { ma_uint64 stringSizeWithNullTerminator = subchunkDataSize - MA_DR_WAV_LIST_LABELLED_TEXT_BYTES; if (pParser->stage == ma_dr_wav__metadata_parser_stage_count) { pParser->metadataCount += 1; ma_dr_wav__metadata_request_extra_memory_for_stage_2(pParser, (size_t)stringSizeWithNullTerminator, 1); } else { subchunkBytesRead = ma_dr_wav__read_list_labelled_cue_region_to_metadata_obj(pParser, &pParser->pMetadata[pParser->metadataCursor], subchunkDataSize); if (subchunkBytesRead == subchunkDataSize) { pParser->metadataCursor += 1; } else { } } } else { } } else if (ma_dr_wav__chunk_matches(allowedMetadataTypes, subchunkId, ma_dr_wav_metadata_type_list_info_software, "ISFT")) { subchunkBytesRead = ma_dr_wav__metadata_process_info_text_chunk(pParser, subchunkDataSize, ma_dr_wav_metadata_type_list_info_software); } else if (ma_dr_wav__chunk_matches(allowedMetadataTypes, subchunkId, ma_dr_wav_metadata_type_list_info_copyright, "ICOP")) { subchunkBytesRead = ma_dr_wav__metadata_process_info_text_chunk(pParser, subchunkDataSize, ma_dr_wav_metadata_type_list_info_copyright); } else if (ma_dr_wav__chunk_matches(allowedMetadataTypes, subchunkId, ma_dr_wav_metadata_type_list_info_title, "INAM")) { subchunkBytesRead = ma_dr_wav__metadata_process_info_text_chunk(pParser, subchunkDataSize, ma_dr_wav_metadata_type_list_info_title); } else if (ma_dr_wav__chunk_matches(allowedMetadataTypes, subchunkId, ma_dr_wav_metadata_type_list_info_artist, "IART")) { subchunkBytesRead = ma_dr_wav__metadata_process_info_text_chunk(pParser, subchunkDataSize, ma_dr_wav_metadata_type_list_info_artist); } else if (ma_dr_wav__chunk_matches(allowedMetadataTypes, subchunkId, ma_dr_wav_metadata_type_list_info_comment, "ICMT")) { subchunkBytesRead = ma_dr_wav__metadata_process_info_text_chunk(pParser, subchunkDataSize, ma_dr_wav_metadata_type_list_info_comment); } else if (ma_dr_wav__chunk_matches(allowedMetadataTypes, subchunkId, ma_dr_wav_metadata_type_list_info_date, "ICRD")) { subchunkBytesRead = ma_dr_wav__metadata_process_info_text_chunk(pParser, subchunkDataSize, ma_dr_wav_metadata_type_list_info_date); } else if (ma_dr_wav__chunk_matches(allowedMetadataTypes, subchunkId, ma_dr_wav_metadata_type_list_info_genre, "IGNR")) { subchunkBytesRead = ma_dr_wav__metadata_process_info_text_chunk(pParser, subchunkDataSize, ma_dr_wav_metadata_type_list_info_genre); } else if (ma_dr_wav__chunk_matches(allowedMetadataTypes, subchunkId, ma_dr_wav_metadata_type_list_info_album, "IPRD")) { subchunkBytesRead = ma_dr_wav__metadata_process_info_text_chunk(pParser, subchunkDataSize, ma_dr_wav_metadata_type_list_info_album); } else if (ma_dr_wav__chunk_matches(allowedMetadataTypes, subchunkId, ma_dr_wav_metadata_type_list_info_tracknumber, "ITRK")) { subchunkBytesRead = ma_dr_wav__metadata_process_info_text_chunk(pParser, subchunkDataSize, ma_dr_wav_metadata_type_list_info_tracknumber); } else if ((allowedMetadataTypes & ma_dr_wav_metadata_type_unknown) != 0) { subchunkBytesRead = ma_dr_wav__metadata_process_unknown_chunk(pParser, subchunkId, subchunkDataSize, listType); } bytesRead += subchunkBytesRead; MA_DR_WAV_ASSERT(subchunkBytesRead <= subchunkDataSize); if (subchunkBytesRead < subchunkDataSize) { ma_uint64 bytesToSeek = subchunkDataSize - subchunkBytesRead; if (!pParser->onSeek(pParser->pReadSeekUserData, (int)bytesToSeek, ma_dr_wav_seek_origin_current)) { break; } bytesRead += bytesToSeek; } if ((subchunkDataSize % 2) == 1) { if (!pParser->onSeek(pParser->pReadSeekUserData, 1, ma_dr_wav_seek_origin_current)) { break; } bytesRead += 1; } } } else if ((allowedMetadataTypes & ma_dr_wav_metadata_type_unknown) != 0) { bytesRead = ma_dr_wav__metadata_process_unknown_chunk(pParser, pChunkID, pChunkHeader->sizeInBytes, ma_dr_wav_metadata_location_top_level); } return bytesRead; } MA_PRIVATE ma_uint32 ma_dr_wav_get_bytes_per_pcm_frame(ma_dr_wav* pWav) { ma_uint32 bytesPerFrame; if ((pWav->bitsPerSample & 0x7) == 0) { bytesPerFrame = (pWav->bitsPerSample * pWav->fmt.channels) >> 3; } else { bytesPerFrame = pWav->fmt.blockAlign; } if (pWav->translatedFormatTag == MA_DR_WAVE_FORMAT_ALAW || pWav->translatedFormatTag == MA_DR_WAVE_FORMAT_MULAW) { if (bytesPerFrame != pWav->fmt.channels) { return 0; } } return bytesPerFrame; } MA_API ma_uint16 ma_dr_wav_fmt_get_format(const ma_dr_wav_fmt* pFMT) { if (pFMT == NULL) { return 0; } if (pFMT->formatTag != MA_DR_WAVE_FORMAT_EXTENSIBLE) { return pFMT->formatTag; } else { return ma_dr_wav_bytes_to_u16(pFMT->subFormat); } } MA_PRIVATE ma_bool32 ma_dr_wav_preinit(ma_dr_wav* pWav, ma_dr_wav_read_proc onRead, ma_dr_wav_seek_proc onSeek, void* pReadSeekUserData, const ma_allocation_callbacks* pAllocationCallbacks) { if (pWav == NULL || onRead == NULL || onSeek == NULL) { return MA_FALSE; } MA_DR_WAV_ZERO_MEMORY(pWav, sizeof(*pWav)); pWav->onRead = onRead; pWav->onSeek = onSeek; pWav->pUserData = pReadSeekUserData; pWav->allocationCallbacks = ma_dr_wav_copy_allocation_callbacks_or_defaults(pAllocationCallbacks); if (pWav->allocationCallbacks.onFree == NULL || (pWav->allocationCallbacks.onMalloc == NULL && pWav->allocationCallbacks.onRealloc == NULL)) { return MA_FALSE; } return MA_TRUE; } MA_PRIVATE ma_bool32 ma_dr_wav_init__internal(ma_dr_wav* pWav, ma_dr_wav_chunk_proc onChunk, void* pChunkUserData, ma_uint32 flags) { ma_result result; ma_uint64 cursor; ma_bool32 sequential; ma_uint8 riff[4]; ma_dr_wav_fmt fmt; unsigned short translatedFormatTag; ma_uint64 dataChunkSize = 0; ma_uint64 sampleCountFromFactChunk = 0; ma_uint64 metadataStartPos; ma_dr_wav__metadata_parser metadataParser; ma_bool8 isProcessingMetadata = MA_FALSE; ma_bool8 foundChunk_fmt = MA_FALSE; ma_bool8 foundChunk_data = MA_FALSE; ma_bool8 isAIFCFormType = MA_FALSE; ma_uint64 aiffFrameCount = 0; cursor = 0; sequential = (flags & MA_DR_WAV_SEQUENTIAL) != 0; MA_DR_WAV_ZERO_OBJECT(&fmt); if (ma_dr_wav__on_read(pWav->onRead, pWav->pUserData, riff, sizeof(riff), &cursor) != sizeof(riff)) { return MA_FALSE; } if (ma_dr_wav_fourcc_equal(riff, "RIFF")) { pWav->container = ma_dr_wav_container_riff; } else if (ma_dr_wav_fourcc_equal(riff, "RIFX")) { pWav->container = ma_dr_wav_container_rifx; } else if (ma_dr_wav_fourcc_equal(riff, "riff")) { int i; ma_uint8 riff2[12]; pWav->container = ma_dr_wav_container_w64; if (ma_dr_wav__on_read(pWav->onRead, pWav->pUserData, riff2, sizeof(riff2), &cursor) != sizeof(riff2)) { return MA_FALSE; } for (i = 0; i < 12; ++i) { if (riff2[i] != ma_dr_wavGUID_W64_RIFF[i+4]) { return MA_FALSE; } } } else if (ma_dr_wav_fourcc_equal(riff, "RF64")) { pWav->container = ma_dr_wav_container_rf64; } else if (ma_dr_wav_fourcc_equal(riff, "FORM")) { pWav->container = ma_dr_wav_container_aiff; } else { return MA_FALSE; } if (pWav->container == ma_dr_wav_container_riff || pWav->container == ma_dr_wav_container_rifx || pWav->container == ma_dr_wav_container_rf64) { ma_uint8 chunkSizeBytes[4]; ma_uint8 wave[4]; if (ma_dr_wav__on_read(pWav->onRead, pWav->pUserData, chunkSizeBytes, sizeof(chunkSizeBytes), &cursor) != sizeof(chunkSizeBytes)) { return MA_FALSE; } if (pWav->container == ma_dr_wav_container_riff || pWav->container == ma_dr_wav_container_rifx) { if (ma_dr_wav_bytes_to_u32_ex(chunkSizeBytes, pWav->container) < 36) { return MA_FALSE; } } else if (pWav->container == ma_dr_wav_container_rf64) { if (ma_dr_wav_bytes_to_u32_le(chunkSizeBytes) != 0xFFFFFFFF) { return MA_FALSE; } } else { return MA_FALSE; } if (ma_dr_wav__on_read(pWav->onRead, pWav->pUserData, wave, sizeof(wave), &cursor) != sizeof(wave)) { return MA_FALSE; } if (!ma_dr_wav_fourcc_equal(wave, "WAVE")) { return MA_FALSE; } } else if (pWav->container == ma_dr_wav_container_w64) { ma_uint8 chunkSizeBytes[8]; ma_uint8 wave[16]; if (ma_dr_wav__on_read(pWav->onRead, pWav->pUserData, chunkSizeBytes, sizeof(chunkSizeBytes), &cursor) != sizeof(chunkSizeBytes)) { return MA_FALSE; } if (ma_dr_wav_bytes_to_u64(chunkSizeBytes) < 80) { return MA_FALSE; } if (ma_dr_wav__on_read(pWav->onRead, pWav->pUserData, wave, sizeof(wave), &cursor) != sizeof(wave)) { return MA_FALSE; } if (!ma_dr_wav_guid_equal(wave, ma_dr_wavGUID_W64_WAVE)) { return MA_FALSE; } } else if (pWav->container == ma_dr_wav_container_aiff) { ma_uint8 chunkSizeBytes[4]; ma_uint8 aiff[4]; if (ma_dr_wav__on_read(pWav->onRead, pWav->pUserData, chunkSizeBytes, sizeof(chunkSizeBytes), &cursor) != sizeof(chunkSizeBytes)) { return MA_FALSE; } if (ma_dr_wav_bytes_to_u32_be(chunkSizeBytes) < 18) { return MA_FALSE; } if (ma_dr_wav__on_read(pWav->onRead, pWav->pUserData, aiff, sizeof(aiff), &cursor) != sizeof(aiff)) { return MA_FALSE; } if (ma_dr_wav_fourcc_equal(aiff, "AIFF")) { isAIFCFormType = MA_FALSE; } else if (ma_dr_wav_fourcc_equal(aiff, "AIFC")) { isAIFCFormType = MA_TRUE; } else { return MA_FALSE; } } else { return MA_FALSE; } if (pWav->container == ma_dr_wav_container_rf64) { ma_uint8 sizeBytes[8]; ma_uint64 bytesRemainingInChunk; ma_dr_wav_chunk_header header; result = ma_dr_wav__read_chunk_header(pWav->onRead, pWav->pUserData, pWav->container, &cursor, &header); if (result != MA_SUCCESS) { return MA_FALSE; } if (!ma_dr_wav_fourcc_equal(header.id.fourcc, "ds64")) { return MA_FALSE; } bytesRemainingInChunk = header.sizeInBytes + header.paddingSize; if (!ma_dr_wav__seek_forward(pWav->onSeek, 8, pWav->pUserData)) { return MA_FALSE; } bytesRemainingInChunk -= 8; cursor += 8; if (ma_dr_wav__on_read(pWav->onRead, pWav->pUserData, sizeBytes, sizeof(sizeBytes), &cursor) != sizeof(sizeBytes)) { return MA_FALSE; } bytesRemainingInChunk -= 8; dataChunkSize = ma_dr_wav_bytes_to_u64(sizeBytes); if (ma_dr_wav__on_read(pWav->onRead, pWav->pUserData, sizeBytes, sizeof(sizeBytes), &cursor) != sizeof(sizeBytes)) { return MA_FALSE; } bytesRemainingInChunk -= 8; sampleCountFromFactChunk = ma_dr_wav_bytes_to_u64(sizeBytes); if (!ma_dr_wav__seek_forward(pWav->onSeek, bytesRemainingInChunk, pWav->pUserData)) { return MA_FALSE; } cursor += bytesRemainingInChunk; } metadataStartPos = cursor; isProcessingMetadata = !sequential && ((flags & MA_DR_WAV_WITH_METADATA) != 0); if (pWav->container != ma_dr_wav_container_riff && pWav->container != ma_dr_wav_container_rf64) { isProcessingMetadata = MA_FALSE; } MA_DR_WAV_ZERO_MEMORY(&metadataParser, sizeof(metadataParser)); if (isProcessingMetadata) { metadataParser.onRead = pWav->onRead; metadataParser.onSeek = pWav->onSeek; metadataParser.pReadSeekUserData = pWav->pUserData; metadataParser.stage = ma_dr_wav__metadata_parser_stage_count; } for (;;) { ma_dr_wav_chunk_header header; ma_uint64 chunkSize; result = ma_dr_wav__read_chunk_header(pWav->onRead, pWav->pUserData, pWav->container, &cursor, &header); if (result != MA_SUCCESS) { break; } chunkSize = header.sizeInBytes; if (!sequential && onChunk != NULL) { ma_uint64 callbackBytesRead = onChunk(pChunkUserData, pWav->onRead, pWav->onSeek, pWav->pUserData, &header, pWav->container, &fmt); if (callbackBytesRead > 0) { if (ma_dr_wav__seek_from_start(pWav->onSeek, cursor, pWav->pUserData) == MA_FALSE) { return MA_FALSE; } } } if (((pWav->container == ma_dr_wav_container_riff || pWav->container == ma_dr_wav_container_rifx || pWav->container == ma_dr_wav_container_rf64) && ma_dr_wav_fourcc_equal(header.id.fourcc, "fmt ")) || ((pWav->container == ma_dr_wav_container_w64) && ma_dr_wav_guid_equal(header.id.guid, ma_dr_wavGUID_W64_FMT))) { ma_uint8 fmtData[16]; foundChunk_fmt = MA_TRUE; if (pWav->onRead(pWav->pUserData, fmtData, sizeof(fmtData)) != sizeof(fmtData)) { return MA_FALSE; } cursor += sizeof(fmtData); fmt.formatTag = ma_dr_wav_bytes_to_u16_ex(fmtData + 0, pWav->container); fmt.channels = ma_dr_wav_bytes_to_u16_ex(fmtData + 2, pWav->container); fmt.sampleRate = ma_dr_wav_bytes_to_u32_ex(fmtData + 4, pWav->container); fmt.avgBytesPerSec = ma_dr_wav_bytes_to_u32_ex(fmtData + 8, pWav->container); fmt.blockAlign = ma_dr_wav_bytes_to_u16_ex(fmtData + 12, pWav->container); fmt.bitsPerSample = ma_dr_wav_bytes_to_u16_ex(fmtData + 14, pWav->container); fmt.extendedSize = 0; fmt.validBitsPerSample = 0; fmt.channelMask = 0; MA_DR_WAV_ZERO_MEMORY(fmt.subFormat, sizeof(fmt.subFormat)); if (header.sizeInBytes > 16) { ma_uint8 fmt_cbSize[2]; int bytesReadSoFar = 0; if (pWav->onRead(pWav->pUserData, fmt_cbSize, sizeof(fmt_cbSize)) != sizeof(fmt_cbSize)) { return MA_FALSE; } cursor += sizeof(fmt_cbSize); bytesReadSoFar = 18; fmt.extendedSize = ma_dr_wav_bytes_to_u16_ex(fmt_cbSize, pWav->container); if (fmt.extendedSize > 0) { if (fmt.formatTag == MA_DR_WAVE_FORMAT_EXTENSIBLE) { if (fmt.extendedSize != 22) { return MA_FALSE; } } if (fmt.formatTag == MA_DR_WAVE_FORMAT_EXTENSIBLE) { ma_uint8 fmtext[22]; if (pWav->onRead(pWav->pUserData, fmtext, fmt.extendedSize) != fmt.extendedSize) { return MA_FALSE; } fmt.validBitsPerSample = ma_dr_wav_bytes_to_u16_ex(fmtext + 0, pWav->container); fmt.channelMask = ma_dr_wav_bytes_to_u32_ex(fmtext + 2, pWav->container); ma_dr_wav_bytes_to_guid(fmtext + 6, fmt.subFormat); } else { if (pWav->onSeek(pWav->pUserData, fmt.extendedSize, ma_dr_wav_seek_origin_current) == MA_FALSE) { return MA_FALSE; } } cursor += fmt.extendedSize; bytesReadSoFar += fmt.extendedSize; } if (pWav->onSeek(pWav->pUserData, (int)(header.sizeInBytes - bytesReadSoFar), ma_dr_wav_seek_origin_current) == MA_FALSE) { return MA_FALSE; } cursor += (header.sizeInBytes - bytesReadSoFar); } if (header.paddingSize > 0) { if (ma_dr_wav__seek_forward(pWav->onSeek, header.paddingSize, pWav->pUserData) == MA_FALSE) { break; } cursor += header.paddingSize; } continue; } if (((pWav->container == ma_dr_wav_container_riff || pWav->container == ma_dr_wav_container_rifx || pWav->container == ma_dr_wav_container_rf64) && ma_dr_wav_fourcc_equal(header.id.fourcc, "data")) || ((pWav->container == ma_dr_wav_container_w64) && ma_dr_wav_guid_equal(header.id.guid, ma_dr_wavGUID_W64_DATA))) { foundChunk_data = MA_TRUE; pWav->dataChunkDataPos = cursor; if (pWav->container != ma_dr_wav_container_rf64) { dataChunkSize = chunkSize; } if (sequential || !isProcessingMetadata) { break; } else { chunkSize += header.paddingSize; if (ma_dr_wav__seek_forward(pWav->onSeek, chunkSize, pWav->pUserData) == MA_FALSE) { break; } cursor += chunkSize; continue; } } if (((pWav->container == ma_dr_wav_container_riff || pWav->container == ma_dr_wav_container_rifx || pWav->container == ma_dr_wav_container_rf64) && ma_dr_wav_fourcc_equal(header.id.fourcc, "fact")) || ((pWav->container == ma_dr_wav_container_w64) && ma_dr_wav_guid_equal(header.id.guid, ma_dr_wavGUID_W64_FACT))) { if (pWav->container == ma_dr_wav_container_riff || pWav->container == ma_dr_wav_container_rifx) { ma_uint8 sampleCount[4]; if (ma_dr_wav__on_read(pWav->onRead, pWav->pUserData, &sampleCount, 4, &cursor) != 4) { return MA_FALSE; } chunkSize -= 4; if (pWav->translatedFormatTag == MA_DR_WAVE_FORMAT_ADPCM) { sampleCountFromFactChunk = ma_dr_wav_bytes_to_u32_ex(sampleCount, pWav->container); } else { sampleCountFromFactChunk = 0; } } else if (pWav->container == ma_dr_wav_container_w64) { if (ma_dr_wav__on_read(pWav->onRead, pWav->pUserData, &sampleCountFromFactChunk, 8, &cursor) != 8) { return MA_FALSE; } chunkSize -= 8; } else if (pWav->container == ma_dr_wav_container_rf64) { } chunkSize += header.paddingSize; if (ma_dr_wav__seek_forward(pWav->onSeek, chunkSize, pWav->pUserData) == MA_FALSE) { break; } cursor += chunkSize; continue; } if (pWav->container == ma_dr_wav_container_aiff && ma_dr_wav_fourcc_equal(header.id.fourcc, "COMM")) { ma_uint8 commData[24]; ma_uint32 commDataBytesToRead; ma_uint16 channels; ma_uint32 frameCount; ma_uint16 sampleSizeInBits; ma_int64 sampleRate; ma_uint16 compressionFormat; foundChunk_fmt = MA_TRUE; if (isAIFCFormType) { commDataBytesToRead = 24; if (header.sizeInBytes < commDataBytesToRead) { return MA_FALSE; } } else { commDataBytesToRead = 18; if (header.sizeInBytes != commDataBytesToRead) { return MA_FALSE; } } if (ma_dr_wav__on_read(pWav->onRead, pWav->pUserData, commData, commDataBytesToRead, &cursor) != commDataBytesToRead) { return MA_FALSE; } channels = ma_dr_wav_bytes_to_u16_ex (commData + 0, pWav->container); frameCount = ma_dr_wav_bytes_to_u32_ex (commData + 2, pWav->container); sampleSizeInBits = ma_dr_wav_bytes_to_u16_ex (commData + 6, pWav->container); sampleRate = ma_dr_wav_aiff_extented_to_s64(commData + 8); if (sampleRate < 0 || sampleRate > 0xFFFFFFFF) { return MA_FALSE; } if (isAIFCFormType) { const ma_uint8* type = commData + 18; if (ma_dr_wav_fourcc_equal(type, "NONE")) { compressionFormat = MA_DR_WAVE_FORMAT_PCM; } else if (ma_dr_wav_fourcc_equal(type, "raw ")) { compressionFormat = MA_DR_WAVE_FORMAT_PCM; if (sampleSizeInBits == 8) { pWav->aiff.isUnsigned = MA_TRUE; } } else if (ma_dr_wav_fourcc_equal(type, "sowt")) { compressionFormat = MA_DR_WAVE_FORMAT_PCM; pWav->aiff.isLE = MA_TRUE; } else if (ma_dr_wav_fourcc_equal(type, "fl32") || ma_dr_wav_fourcc_equal(type, "fl64") || ma_dr_wav_fourcc_equal(type, "FL32") || ma_dr_wav_fourcc_equal(type, "FL64")) { compressionFormat = MA_DR_WAVE_FORMAT_IEEE_FLOAT; } else if (ma_dr_wav_fourcc_equal(type, "alaw") || ma_dr_wav_fourcc_equal(type, "ALAW")) { compressionFormat = MA_DR_WAVE_FORMAT_ALAW; } else if (ma_dr_wav_fourcc_equal(type, "ulaw") || ma_dr_wav_fourcc_equal(type, "ULAW")) { compressionFormat = MA_DR_WAVE_FORMAT_MULAW; } else if (ma_dr_wav_fourcc_equal(type, "ima4")) { compressionFormat = MA_DR_WAVE_FORMAT_DVI_ADPCM; sampleSizeInBits = 4; return MA_FALSE; } else { return MA_FALSE; } } else { compressionFormat = MA_DR_WAVE_FORMAT_PCM; } aiffFrameCount = frameCount; fmt.formatTag = compressionFormat; fmt.channels = channels; fmt.sampleRate = (ma_uint32)sampleRate; fmt.bitsPerSample = sampleSizeInBits; fmt.blockAlign = (ma_uint16)(fmt.channels * fmt.bitsPerSample / 8); fmt.avgBytesPerSec = fmt.blockAlign * fmt.sampleRate; if (fmt.blockAlign == 0 && compressionFormat == MA_DR_WAVE_FORMAT_DVI_ADPCM) { fmt.blockAlign = 34 * fmt.channels; } if (compressionFormat == MA_DR_WAVE_FORMAT_ALAW || compressionFormat == MA_DR_WAVE_FORMAT_MULAW) { if (fmt.bitsPerSample > 8) { fmt.bitsPerSample = 8; fmt.blockAlign = fmt.channels; } } fmt.bitsPerSample += (fmt.bitsPerSample & 7); if (isAIFCFormType) { if (ma_dr_wav__seek_forward(pWav->onSeek, (chunkSize - commDataBytesToRead), pWav->pUserData) == MA_FALSE) { return MA_FALSE; } cursor += (chunkSize - commDataBytesToRead); } continue; } if (pWav->container == ma_dr_wav_container_aiff && ma_dr_wav_fourcc_equal(header.id.fourcc, "SSND")) { ma_uint8 offsetAndBlockSizeData[8]; ma_uint32 offset; foundChunk_data = MA_TRUE; if (ma_dr_wav__on_read(pWav->onRead, pWav->pUserData, offsetAndBlockSizeData, sizeof(offsetAndBlockSizeData), &cursor) != sizeof(offsetAndBlockSizeData)) { return MA_FALSE; } offset = ma_dr_wav_bytes_to_u32_ex(offsetAndBlockSizeData + 0, pWav->container); if (ma_dr_wav__seek_forward(pWav->onSeek, offset, pWav->pUserData) == MA_FALSE) { return MA_FALSE; } cursor += offset; pWav->dataChunkDataPos = cursor; dataChunkSize = chunkSize; if (sequential || !isProcessingMetadata) { break; } else { if (ma_dr_wav__seek_forward(pWav->onSeek, chunkSize, pWav->pUserData) == MA_FALSE) { break; } cursor += chunkSize; continue; } } if (isProcessingMetadata) { ma_uint64 metadataBytesRead; metadataBytesRead = ma_dr_wav__metadata_process_chunk(&metadataParser, &header, ma_dr_wav_metadata_type_all_including_unknown); MA_DR_WAV_ASSERT(metadataBytesRead <= header.sizeInBytes); if (ma_dr_wav__seek_from_start(pWav->onSeek, cursor, pWav->pUserData) == MA_FALSE) { break; } } chunkSize += header.paddingSize; if (ma_dr_wav__seek_forward(pWav->onSeek, chunkSize, pWav->pUserData) == MA_FALSE) { break; } cursor += chunkSize; } if (!foundChunk_fmt || !foundChunk_data) { return MA_FALSE; } if ((fmt.sampleRate == 0 || fmt.sampleRate > MA_DR_WAV_MAX_SAMPLE_RATE ) || (fmt.channels == 0 || fmt.channels > MA_DR_WAV_MAX_CHANNELS ) || (fmt.bitsPerSample == 0 || fmt.bitsPerSample > MA_DR_WAV_MAX_BITS_PER_SAMPLE) || fmt.blockAlign == 0) { return MA_FALSE; } translatedFormatTag = fmt.formatTag; if (translatedFormatTag == MA_DR_WAVE_FORMAT_EXTENSIBLE) { translatedFormatTag = ma_dr_wav_bytes_to_u16_ex(fmt.subFormat + 0, pWav->container); } if (!sequential) { if (!ma_dr_wav__seek_from_start(pWav->onSeek, pWav->dataChunkDataPos, pWav->pUserData)) { return MA_FALSE; } cursor = pWav->dataChunkDataPos; } if (isProcessingMetadata && metadataParser.metadataCount > 0) { if (ma_dr_wav__seek_from_start(pWav->onSeek, metadataStartPos, pWav->pUserData) == MA_FALSE) { return MA_FALSE; } result = ma_dr_wav__metadata_alloc(&metadataParser, &pWav->allocationCallbacks); if (result != MA_SUCCESS) { return MA_FALSE; } metadataParser.stage = ma_dr_wav__metadata_parser_stage_read; for (;;) { ma_dr_wav_chunk_header header; ma_uint64 metadataBytesRead; result = ma_dr_wav__read_chunk_header(pWav->onRead, pWav->pUserData, pWav->container, &cursor, &header); if (result != MA_SUCCESS) { break; } metadataBytesRead = ma_dr_wav__metadata_process_chunk(&metadataParser, &header, ma_dr_wav_metadata_type_all_including_unknown); if (ma_dr_wav__seek_forward(pWav->onSeek, (header.sizeInBytes + header.paddingSize) - metadataBytesRead, pWav->pUserData) == MA_FALSE) { ma_dr_wav_free(metadataParser.pMetadata, &pWav->allocationCallbacks); return MA_FALSE; } } pWav->pMetadata = metadataParser.pMetadata; pWav->metadataCount = metadataParser.metadataCount; } if (dataChunkSize == 0xFFFFFFFF && (pWav->container == ma_dr_wav_container_riff || pWav->container == ma_dr_wav_container_rifx) && pWav->isSequentialWrite == MA_FALSE) { dataChunkSize = 0; for (;;) { ma_uint8 temp[4096]; size_t bytesRead = pWav->onRead(pWav->pUserData, temp, sizeof(temp)); dataChunkSize += bytesRead; if (bytesRead < sizeof(temp)) { break; } } } if (ma_dr_wav__seek_from_start(pWav->onSeek, pWav->dataChunkDataPos, pWav->pUserData) == MA_FALSE) { ma_dr_wav_free(pWav->pMetadata, &pWav->allocationCallbacks); return MA_FALSE; } pWav->fmt = fmt; pWav->sampleRate = fmt.sampleRate; pWav->channels = fmt.channels; pWav->bitsPerSample = fmt.bitsPerSample; pWav->bytesRemaining = dataChunkSize; pWav->translatedFormatTag = translatedFormatTag; pWav->dataChunkDataSize = dataChunkSize; if (sampleCountFromFactChunk != 0) { pWav->totalPCMFrameCount = sampleCountFromFactChunk; } else if (aiffFrameCount != 0) { pWav->totalPCMFrameCount = aiffFrameCount; } else { ma_uint32 bytesPerFrame = ma_dr_wav_get_bytes_per_pcm_frame(pWav); if (bytesPerFrame == 0) { ma_dr_wav_free(pWav->pMetadata, &pWav->allocationCallbacks); return MA_FALSE; } pWav->totalPCMFrameCount = dataChunkSize / bytesPerFrame; if (pWav->translatedFormatTag == MA_DR_WAVE_FORMAT_ADPCM) { ma_uint64 totalBlockHeaderSizeInBytes; ma_uint64 blockCount = dataChunkSize / fmt.blockAlign; if ((blockCount * fmt.blockAlign) < dataChunkSize) { blockCount += 1; } totalBlockHeaderSizeInBytes = blockCount * (6*fmt.channels); pWav->totalPCMFrameCount = ((dataChunkSize - totalBlockHeaderSizeInBytes) * 2) / fmt.channels; } if (pWav->translatedFormatTag == MA_DR_WAVE_FORMAT_DVI_ADPCM) { ma_uint64 totalBlockHeaderSizeInBytes; ma_uint64 blockCount = dataChunkSize / fmt.blockAlign; if ((blockCount * fmt.blockAlign) < dataChunkSize) { blockCount += 1; } totalBlockHeaderSizeInBytes = blockCount * (4*fmt.channels); pWav->totalPCMFrameCount = ((dataChunkSize - totalBlockHeaderSizeInBytes) * 2) / fmt.channels; pWav->totalPCMFrameCount += blockCount; } } if (pWav->translatedFormatTag == MA_DR_WAVE_FORMAT_ADPCM || pWav->translatedFormatTag == MA_DR_WAVE_FORMAT_DVI_ADPCM) { if (pWav->channels > 2) { ma_dr_wav_free(pWav->pMetadata, &pWav->allocationCallbacks); return MA_FALSE; } } if (ma_dr_wav_get_bytes_per_pcm_frame(pWav) == 0) { ma_dr_wav_free(pWav->pMetadata, &pWav->allocationCallbacks); return MA_FALSE; } #ifdef MA_DR_WAV_LIBSNDFILE_COMPAT if (pWav->translatedFormatTag == MA_DR_WAVE_FORMAT_ADPCM) { ma_uint64 blockCount = dataChunkSize / fmt.blockAlign; pWav->totalPCMFrameCount = (((blockCount * (fmt.blockAlign - (6*pWav->channels))) * 2)) / fmt.channels; } if (pWav->translatedFormatTag == MA_DR_WAVE_FORMAT_DVI_ADPCM) { ma_uint64 blockCount = dataChunkSize / fmt.blockAlign; pWav->totalPCMFrameCount = (((blockCount * (fmt.blockAlign - (4*pWav->channels))) * 2) + (blockCount * pWav->channels)) / fmt.channels; } #endif return MA_TRUE; } MA_API ma_bool32 ma_dr_wav_init(ma_dr_wav* pWav, ma_dr_wav_read_proc onRead, ma_dr_wav_seek_proc onSeek, void* pUserData, const ma_allocation_callbacks* pAllocationCallbacks) { return ma_dr_wav_init_ex(pWav, onRead, onSeek, NULL, pUserData, NULL, 0, pAllocationCallbacks); } MA_API ma_bool32 ma_dr_wav_init_ex(ma_dr_wav* pWav, ma_dr_wav_read_proc onRead, ma_dr_wav_seek_proc onSeek, ma_dr_wav_chunk_proc onChunk, void* pReadSeekUserData, void* pChunkUserData, ma_uint32 flags, const ma_allocation_callbacks* pAllocationCallbacks) { if (!ma_dr_wav_preinit(pWav, onRead, onSeek, pReadSeekUserData, pAllocationCallbacks)) { return MA_FALSE; } return ma_dr_wav_init__internal(pWav, onChunk, pChunkUserData, flags); } MA_API ma_bool32 ma_dr_wav_init_with_metadata(ma_dr_wav* pWav, ma_dr_wav_read_proc onRead, ma_dr_wav_seek_proc onSeek, void* pUserData, ma_uint32 flags, const ma_allocation_callbacks* pAllocationCallbacks) { if (!ma_dr_wav_preinit(pWav, onRead, onSeek, pUserData, pAllocationCallbacks)) { return MA_FALSE; } return ma_dr_wav_init__internal(pWav, NULL, NULL, flags | MA_DR_WAV_WITH_METADATA); } MA_API ma_dr_wav_metadata* ma_dr_wav_take_ownership_of_metadata(ma_dr_wav* pWav) { ma_dr_wav_metadata *result = pWav->pMetadata; pWav->pMetadata = NULL; pWav->metadataCount = 0; return result; } MA_PRIVATE size_t ma_dr_wav__write(ma_dr_wav* pWav, const void* pData, size_t dataSize) { MA_DR_WAV_ASSERT(pWav != NULL); MA_DR_WAV_ASSERT(pWav->onWrite != NULL); return pWav->onWrite(pWav->pUserData, pData, dataSize); } MA_PRIVATE size_t ma_dr_wav__write_byte(ma_dr_wav* pWav, ma_uint8 byte) { MA_DR_WAV_ASSERT(pWav != NULL); MA_DR_WAV_ASSERT(pWav->onWrite != NULL); return pWav->onWrite(pWav->pUserData, &byte, 1); } MA_PRIVATE size_t ma_dr_wav__write_u16ne_to_le(ma_dr_wav* pWav, ma_uint16 value) { MA_DR_WAV_ASSERT(pWav != NULL); MA_DR_WAV_ASSERT(pWav->onWrite != NULL); if (!ma_dr_wav__is_little_endian()) { value = ma_dr_wav__bswap16(value); } return ma_dr_wav__write(pWav, &value, 2); } MA_PRIVATE size_t ma_dr_wav__write_u32ne_to_le(ma_dr_wav* pWav, ma_uint32 value) { MA_DR_WAV_ASSERT(pWav != NULL); MA_DR_WAV_ASSERT(pWav->onWrite != NULL); if (!ma_dr_wav__is_little_endian()) { value = ma_dr_wav__bswap32(value); } return ma_dr_wav__write(pWav, &value, 4); } MA_PRIVATE size_t ma_dr_wav__write_u64ne_to_le(ma_dr_wav* pWav, ma_uint64 value) { MA_DR_WAV_ASSERT(pWav != NULL); MA_DR_WAV_ASSERT(pWav->onWrite != NULL); if (!ma_dr_wav__is_little_endian()) { value = ma_dr_wav__bswap64(value); } return ma_dr_wav__write(pWav, &value, 8); } MA_PRIVATE size_t ma_dr_wav__write_f32ne_to_le(ma_dr_wav* pWav, float value) { union { ma_uint32 u32; float f32; } u; MA_DR_WAV_ASSERT(pWav != NULL); MA_DR_WAV_ASSERT(pWav->onWrite != NULL); u.f32 = value; if (!ma_dr_wav__is_little_endian()) { u.u32 = ma_dr_wav__bswap32(u.u32); } return ma_dr_wav__write(pWav, &u.u32, 4); } MA_PRIVATE size_t ma_dr_wav__write_or_count(ma_dr_wav* pWav, const void* pData, size_t dataSize) { if (pWav == NULL) { return dataSize; } return ma_dr_wav__write(pWav, pData, dataSize); } MA_PRIVATE size_t ma_dr_wav__write_or_count_byte(ma_dr_wav* pWav, ma_uint8 byte) { if (pWav == NULL) { return 1; } return ma_dr_wav__write_byte(pWav, byte); } MA_PRIVATE size_t ma_dr_wav__write_or_count_u16ne_to_le(ma_dr_wav* pWav, ma_uint16 value) { if (pWav == NULL) { return 2; } return ma_dr_wav__write_u16ne_to_le(pWav, value); } MA_PRIVATE size_t ma_dr_wav__write_or_count_u32ne_to_le(ma_dr_wav* pWav, ma_uint32 value) { if (pWav == NULL) { return 4; } return ma_dr_wav__write_u32ne_to_le(pWav, value); } #if 0 MA_PRIVATE size_t ma_dr_wav__write_or_count_u64ne_to_le(ma_dr_wav* pWav, ma_uint64 value) { if (pWav == NULL) { return 8; } return ma_dr_wav__write_u64ne_to_le(pWav, value); } #endif MA_PRIVATE size_t ma_dr_wav__write_or_count_f32ne_to_le(ma_dr_wav* pWav, float value) { if (pWav == NULL) { return 4; } return ma_dr_wav__write_f32ne_to_le(pWav, value); } MA_PRIVATE size_t ma_dr_wav__write_or_count_string_to_fixed_size_buf(ma_dr_wav* pWav, char* str, size_t bufFixedSize) { size_t len; if (pWav == NULL) { return bufFixedSize; } len = ma_dr_wav__strlen_clamped(str, bufFixedSize); ma_dr_wav__write_or_count(pWav, str, len); if (len < bufFixedSize) { size_t i; for (i = 0; i < bufFixedSize - len; ++i) { ma_dr_wav__write_byte(pWav, 0); } } return bufFixedSize; } MA_PRIVATE size_t ma_dr_wav__write_or_count_metadata(ma_dr_wav* pWav, ma_dr_wav_metadata* pMetadatas, ma_uint32 metadataCount) { size_t bytesWritten = 0; ma_bool32 hasListAdtl = MA_FALSE; ma_bool32 hasListInfo = MA_FALSE; ma_uint32 iMetadata; if (pMetadatas == NULL || metadataCount == 0) { return 0; } for (iMetadata = 0; iMetadata < metadataCount; ++iMetadata) { ma_dr_wav_metadata* pMetadata = &pMetadatas[iMetadata]; ma_uint32 chunkSize = 0; if ((pMetadata->type & ma_dr_wav_metadata_type_list_all_info_strings) || (pMetadata->type == ma_dr_wav_metadata_type_unknown && pMetadata->data.unknown.chunkLocation == ma_dr_wav_metadata_location_inside_info_list)) { hasListInfo = MA_TRUE; } if ((pMetadata->type & ma_dr_wav_metadata_type_list_all_adtl) || (pMetadata->type == ma_dr_wav_metadata_type_unknown && pMetadata->data.unknown.chunkLocation == ma_dr_wav_metadata_location_inside_adtl_list)) { hasListAdtl = MA_TRUE; } switch (pMetadata->type) { case ma_dr_wav_metadata_type_smpl: { ma_uint32 iLoop; chunkSize = MA_DR_WAV_SMPL_BYTES + MA_DR_WAV_SMPL_LOOP_BYTES * pMetadata->data.smpl.sampleLoopCount + pMetadata->data.smpl.samplerSpecificDataSizeInBytes; bytesWritten += ma_dr_wav__write_or_count(pWav, "smpl", 4); bytesWritten += ma_dr_wav__write_or_count_u32ne_to_le(pWav, chunkSize); bytesWritten += ma_dr_wav__write_or_count_u32ne_to_le(pWav, pMetadata->data.smpl.manufacturerId); bytesWritten += ma_dr_wav__write_or_count_u32ne_to_le(pWav, pMetadata->data.smpl.productId); bytesWritten += ma_dr_wav__write_or_count_u32ne_to_le(pWav, pMetadata->data.smpl.samplePeriodNanoseconds); bytesWritten += ma_dr_wav__write_or_count_u32ne_to_le(pWav, pMetadata->data.smpl.midiUnityNote); bytesWritten += ma_dr_wav__write_or_count_u32ne_to_le(pWav, pMetadata->data.smpl.midiPitchFraction); bytesWritten += ma_dr_wav__write_or_count_u32ne_to_le(pWav, pMetadata->data.smpl.smpteFormat); bytesWritten += ma_dr_wav__write_or_count_u32ne_to_le(pWav, pMetadata->data.smpl.smpteOffset); bytesWritten += ma_dr_wav__write_or_count_u32ne_to_le(pWav, pMetadata->data.smpl.sampleLoopCount); bytesWritten += ma_dr_wav__write_or_count_u32ne_to_le(pWav, pMetadata->data.smpl.samplerSpecificDataSizeInBytes); for (iLoop = 0; iLoop < pMetadata->data.smpl.sampleLoopCount; ++iLoop) { bytesWritten += ma_dr_wav__write_or_count_u32ne_to_le(pWav, pMetadata->data.smpl.pLoops[iLoop].cuePointId); bytesWritten += ma_dr_wav__write_or_count_u32ne_to_le(pWav, pMetadata->data.smpl.pLoops[iLoop].type); bytesWritten += ma_dr_wav__write_or_count_u32ne_to_le(pWav, pMetadata->data.smpl.pLoops[iLoop].firstSampleByteOffset); bytesWritten += ma_dr_wav__write_or_count_u32ne_to_le(pWav, pMetadata->data.smpl.pLoops[iLoop].lastSampleByteOffset); bytesWritten += ma_dr_wav__write_or_count_u32ne_to_le(pWav, pMetadata->data.smpl.pLoops[iLoop].sampleFraction); bytesWritten += ma_dr_wav__write_or_count_u32ne_to_le(pWav, pMetadata->data.smpl.pLoops[iLoop].playCount); } if (pMetadata->data.smpl.samplerSpecificDataSizeInBytes > 0) { bytesWritten += ma_dr_wav__write_or_count(pWav, pMetadata->data.smpl.pSamplerSpecificData, pMetadata->data.smpl.samplerSpecificDataSizeInBytes); } } break; case ma_dr_wav_metadata_type_inst: { chunkSize = MA_DR_WAV_INST_BYTES; bytesWritten += ma_dr_wav__write_or_count(pWav, "inst", 4); bytesWritten += ma_dr_wav__write_or_count_u32ne_to_le(pWav, chunkSize); bytesWritten += ma_dr_wav__write_or_count(pWav, &pMetadata->data.inst.midiUnityNote, 1); bytesWritten += ma_dr_wav__write_or_count(pWav, &pMetadata->data.inst.fineTuneCents, 1); bytesWritten += ma_dr_wav__write_or_count(pWav, &pMetadata->data.inst.gainDecibels, 1); bytesWritten += ma_dr_wav__write_or_count(pWav, &pMetadata->data.inst.lowNote, 1); bytesWritten += ma_dr_wav__write_or_count(pWav, &pMetadata->data.inst.highNote, 1); bytesWritten += ma_dr_wav__write_or_count(pWav, &pMetadata->data.inst.lowVelocity, 1); bytesWritten += ma_dr_wav__write_or_count(pWav, &pMetadata->data.inst.highVelocity, 1); } break; case ma_dr_wav_metadata_type_cue: { ma_uint32 iCuePoint; chunkSize = MA_DR_WAV_CUE_BYTES + MA_DR_WAV_CUE_POINT_BYTES * pMetadata->data.cue.cuePointCount; bytesWritten += ma_dr_wav__write_or_count(pWav, "cue ", 4); bytesWritten += ma_dr_wav__write_or_count_u32ne_to_le(pWav, chunkSize); bytesWritten += ma_dr_wav__write_or_count_u32ne_to_le(pWav, pMetadata->data.cue.cuePointCount); for (iCuePoint = 0; iCuePoint < pMetadata->data.cue.cuePointCount; ++iCuePoint) { bytesWritten += ma_dr_wav__write_or_count_u32ne_to_le(pWav, pMetadata->data.cue.pCuePoints[iCuePoint].id); bytesWritten += ma_dr_wav__write_or_count_u32ne_to_le(pWav, pMetadata->data.cue.pCuePoints[iCuePoint].playOrderPosition); bytesWritten += ma_dr_wav__write_or_count(pWav, pMetadata->data.cue.pCuePoints[iCuePoint].dataChunkId, 4); bytesWritten += ma_dr_wav__write_or_count_u32ne_to_le(pWav, pMetadata->data.cue.pCuePoints[iCuePoint].chunkStart); bytesWritten += ma_dr_wav__write_or_count_u32ne_to_le(pWav, pMetadata->data.cue.pCuePoints[iCuePoint].blockStart); bytesWritten += ma_dr_wav__write_or_count_u32ne_to_le(pWav, pMetadata->data.cue.pCuePoints[iCuePoint].sampleByteOffset); } } break; case ma_dr_wav_metadata_type_acid: { chunkSize = MA_DR_WAV_ACID_BYTES; bytesWritten += ma_dr_wav__write_or_count(pWav, "acid", 4); bytesWritten += ma_dr_wav__write_or_count_u32ne_to_le(pWav, chunkSize); bytesWritten += ma_dr_wav__write_or_count_u32ne_to_le(pWav, pMetadata->data.acid.flags); bytesWritten += ma_dr_wav__write_or_count_u16ne_to_le(pWav, pMetadata->data.acid.midiUnityNote); bytesWritten += ma_dr_wav__write_or_count_u16ne_to_le(pWav, pMetadata->data.acid.reserved1); bytesWritten += ma_dr_wav__write_or_count_f32ne_to_le(pWav, pMetadata->data.acid.reserved2); bytesWritten += ma_dr_wav__write_or_count_u32ne_to_le(pWav, pMetadata->data.acid.numBeats); bytesWritten += ma_dr_wav__write_or_count_u16ne_to_le(pWav, pMetadata->data.acid.meterDenominator); bytesWritten += ma_dr_wav__write_or_count_u16ne_to_le(pWav, pMetadata->data.acid.meterNumerator); bytesWritten += ma_dr_wav__write_or_count_f32ne_to_le(pWav, pMetadata->data.acid.tempo); } break; case ma_dr_wav_metadata_type_bext: { char reservedBuf[MA_DR_WAV_BEXT_RESERVED_BYTES]; ma_uint32 timeReferenceLow; ma_uint32 timeReferenceHigh; chunkSize = MA_DR_WAV_BEXT_BYTES + pMetadata->data.bext.codingHistorySize; bytesWritten += ma_dr_wav__write_or_count(pWav, "bext", 4); bytesWritten += ma_dr_wav__write_or_count_u32ne_to_le(pWav, chunkSize); bytesWritten += ma_dr_wav__write_or_count_string_to_fixed_size_buf(pWav, pMetadata->data.bext.pDescription, MA_DR_WAV_BEXT_DESCRIPTION_BYTES); bytesWritten += ma_dr_wav__write_or_count_string_to_fixed_size_buf(pWav, pMetadata->data.bext.pOriginatorName, MA_DR_WAV_BEXT_ORIGINATOR_NAME_BYTES); bytesWritten += ma_dr_wav__write_or_count_string_to_fixed_size_buf(pWav, pMetadata->data.bext.pOriginatorReference, MA_DR_WAV_BEXT_ORIGINATOR_REF_BYTES); bytesWritten += ma_dr_wav__write_or_count(pWav, pMetadata->data.bext.pOriginationDate, sizeof(pMetadata->data.bext.pOriginationDate)); bytesWritten += ma_dr_wav__write_or_count(pWav, pMetadata->data.bext.pOriginationTime, sizeof(pMetadata->data.bext.pOriginationTime)); timeReferenceLow = (ma_uint32)(pMetadata->data.bext.timeReference & 0xFFFFFFFF); timeReferenceHigh = (ma_uint32)(pMetadata->data.bext.timeReference >> 32); bytesWritten += ma_dr_wav__write_or_count_u32ne_to_le(pWav, timeReferenceLow); bytesWritten += ma_dr_wav__write_or_count_u32ne_to_le(pWav, timeReferenceHigh); bytesWritten += ma_dr_wav__write_or_count_u16ne_to_le(pWav, pMetadata->data.bext.version); bytesWritten += ma_dr_wav__write_or_count(pWav, pMetadata->data.bext.pUMID, MA_DR_WAV_BEXT_UMID_BYTES); bytesWritten += ma_dr_wav__write_or_count_u16ne_to_le(pWav, pMetadata->data.bext.loudnessValue); bytesWritten += ma_dr_wav__write_or_count_u16ne_to_le(pWav, pMetadata->data.bext.loudnessRange); bytesWritten += ma_dr_wav__write_or_count_u16ne_to_le(pWav, pMetadata->data.bext.maxTruePeakLevel); bytesWritten += ma_dr_wav__write_or_count_u16ne_to_le(pWav, pMetadata->data.bext.maxMomentaryLoudness); bytesWritten += ma_dr_wav__write_or_count_u16ne_to_le(pWav, pMetadata->data.bext.maxShortTermLoudness); MA_DR_WAV_ZERO_MEMORY(reservedBuf, sizeof(reservedBuf)); bytesWritten += ma_dr_wav__write_or_count(pWav, reservedBuf, sizeof(reservedBuf)); if (pMetadata->data.bext.codingHistorySize > 0) { bytesWritten += ma_dr_wav__write_or_count(pWav, pMetadata->data.bext.pCodingHistory, pMetadata->data.bext.codingHistorySize); } } break; case ma_dr_wav_metadata_type_unknown: { if (pMetadata->data.unknown.chunkLocation == ma_dr_wav_metadata_location_top_level) { chunkSize = pMetadata->data.unknown.dataSizeInBytes; bytesWritten += ma_dr_wav__write_or_count(pWav, pMetadata->data.unknown.id, 4); bytesWritten += ma_dr_wav__write_or_count_u32ne_to_le(pWav, chunkSize); bytesWritten += ma_dr_wav__write_or_count(pWav, pMetadata->data.unknown.pData, pMetadata->data.unknown.dataSizeInBytes); } } break; default: break; } if ((chunkSize % 2) != 0) { bytesWritten += ma_dr_wav__write_or_count_byte(pWav, 0); } } if (hasListInfo) { ma_uint32 chunkSize = 4; for (iMetadata = 0; iMetadata < metadataCount; ++iMetadata) { ma_dr_wav_metadata* pMetadata = &pMetadatas[iMetadata]; if ((pMetadata->type & ma_dr_wav_metadata_type_list_all_info_strings)) { chunkSize += 8; chunkSize += pMetadata->data.infoText.stringLength + 1; } else if (pMetadata->type == ma_dr_wav_metadata_type_unknown && pMetadata->data.unknown.chunkLocation == ma_dr_wav_metadata_location_inside_info_list) { chunkSize += 8; chunkSize += pMetadata->data.unknown.dataSizeInBytes; } if ((chunkSize % 2) != 0) { chunkSize += 1; } } bytesWritten += ma_dr_wav__write_or_count(pWav, "LIST", 4); bytesWritten += ma_dr_wav__write_or_count_u32ne_to_le(pWav, chunkSize); bytesWritten += ma_dr_wav__write_or_count(pWav, "INFO", 4); for (iMetadata = 0; iMetadata < metadataCount; ++iMetadata) { ma_dr_wav_metadata* pMetadata = &pMetadatas[iMetadata]; ma_uint32 subchunkSize = 0; if (pMetadata->type & ma_dr_wav_metadata_type_list_all_info_strings) { const char* pID = NULL; switch (pMetadata->type) { case ma_dr_wav_metadata_type_list_info_software: pID = "ISFT"; break; case ma_dr_wav_metadata_type_list_info_copyright: pID = "ICOP"; break; case ma_dr_wav_metadata_type_list_info_title: pID = "INAM"; break; case ma_dr_wav_metadata_type_list_info_artist: pID = "IART"; break; case ma_dr_wav_metadata_type_list_info_comment: pID = "ICMT"; break; case ma_dr_wav_metadata_type_list_info_date: pID = "ICRD"; break; case ma_dr_wav_metadata_type_list_info_genre: pID = "IGNR"; break; case ma_dr_wav_metadata_type_list_info_album: pID = "IPRD"; break; case ma_dr_wav_metadata_type_list_info_tracknumber: pID = "ITRK"; break; default: break; } MA_DR_WAV_ASSERT(pID != NULL); if (pMetadata->data.infoText.stringLength) { subchunkSize = pMetadata->data.infoText.stringLength + 1; bytesWritten += ma_dr_wav__write_or_count(pWav, pID, 4); bytesWritten += ma_dr_wav__write_or_count_u32ne_to_le(pWav, subchunkSize); bytesWritten += ma_dr_wav__write_or_count(pWav, pMetadata->data.infoText.pString, pMetadata->data.infoText.stringLength); bytesWritten += ma_dr_wav__write_or_count_byte(pWav, '\0'); } } else if (pMetadata->type == ma_dr_wav_metadata_type_unknown && pMetadata->data.unknown.chunkLocation == ma_dr_wav_metadata_location_inside_info_list) { if (pMetadata->data.unknown.dataSizeInBytes) { subchunkSize = pMetadata->data.unknown.dataSizeInBytes; bytesWritten += ma_dr_wav__write_or_count(pWav, pMetadata->data.unknown.id, 4); bytesWritten += ma_dr_wav__write_or_count_u32ne_to_le(pWav, pMetadata->data.unknown.dataSizeInBytes); bytesWritten += ma_dr_wav__write_or_count(pWav, pMetadata->data.unknown.pData, subchunkSize); } } if ((subchunkSize % 2) != 0) { bytesWritten += ma_dr_wav__write_or_count_byte(pWav, 0); } } } if (hasListAdtl) { ma_uint32 chunkSize = 4; for (iMetadata = 0; iMetadata < metadataCount; ++iMetadata) { ma_dr_wav_metadata* pMetadata = &pMetadatas[iMetadata]; switch (pMetadata->type) { case ma_dr_wav_metadata_type_list_label: case ma_dr_wav_metadata_type_list_note: { chunkSize += 8; chunkSize += MA_DR_WAV_LIST_LABEL_OR_NOTE_BYTES; if (pMetadata->data.labelOrNote.stringLength > 0) { chunkSize += pMetadata->data.labelOrNote.stringLength + 1; } } break; case ma_dr_wav_metadata_type_list_labelled_cue_region: { chunkSize += 8; chunkSize += MA_DR_WAV_LIST_LABELLED_TEXT_BYTES; if (pMetadata->data.labelledCueRegion.stringLength > 0) { chunkSize += pMetadata->data.labelledCueRegion.stringLength + 1; } } break; case ma_dr_wav_metadata_type_unknown: { if (pMetadata->data.unknown.chunkLocation == ma_dr_wav_metadata_location_inside_adtl_list) { chunkSize += 8; chunkSize += pMetadata->data.unknown.dataSizeInBytes; } } break; default: break; } if ((chunkSize % 2) != 0) { chunkSize += 1; } } bytesWritten += ma_dr_wav__write_or_count(pWav, "LIST", 4); bytesWritten += ma_dr_wav__write_or_count_u32ne_to_le(pWav, chunkSize); bytesWritten += ma_dr_wav__write_or_count(pWav, "adtl", 4); for (iMetadata = 0; iMetadata < metadataCount; ++iMetadata) { ma_dr_wav_metadata* pMetadata = &pMetadatas[iMetadata]; ma_uint32 subchunkSize = 0; switch (pMetadata->type) { case ma_dr_wav_metadata_type_list_label: case ma_dr_wav_metadata_type_list_note: { if (pMetadata->data.labelOrNote.stringLength > 0) { const char *pID = NULL; if (pMetadata->type == ma_dr_wav_metadata_type_list_label) { pID = "labl"; } else if (pMetadata->type == ma_dr_wav_metadata_type_list_note) { pID = "note"; } MA_DR_WAV_ASSERT(pID != NULL); MA_DR_WAV_ASSERT(pMetadata->data.labelOrNote.pString != NULL); subchunkSize = MA_DR_WAV_LIST_LABEL_OR_NOTE_BYTES; bytesWritten += ma_dr_wav__write_or_count(pWav, pID, 4); subchunkSize += pMetadata->data.labelOrNote.stringLength + 1; bytesWritten += ma_dr_wav__write_or_count_u32ne_to_le(pWav, subchunkSize); bytesWritten += ma_dr_wav__write_or_count_u32ne_to_le(pWav, pMetadata->data.labelOrNote.cuePointId); bytesWritten += ma_dr_wav__write_or_count(pWav, pMetadata->data.labelOrNote.pString, pMetadata->data.labelOrNote.stringLength); bytesWritten += ma_dr_wav__write_or_count_byte(pWav, '\0'); } } break; case ma_dr_wav_metadata_type_list_labelled_cue_region: { subchunkSize = MA_DR_WAV_LIST_LABELLED_TEXT_BYTES; bytesWritten += ma_dr_wav__write_or_count(pWav, "ltxt", 4); if (pMetadata->data.labelledCueRegion.stringLength > 0) { subchunkSize += pMetadata->data.labelledCueRegion.stringLength + 1; } bytesWritten += ma_dr_wav__write_or_count_u32ne_to_le(pWav, subchunkSize); bytesWritten += ma_dr_wav__write_or_count_u32ne_to_le(pWav, pMetadata->data.labelledCueRegion.cuePointId); bytesWritten += ma_dr_wav__write_or_count_u32ne_to_le(pWav, pMetadata->data.labelledCueRegion.sampleLength); bytesWritten += ma_dr_wav__write_or_count(pWav, pMetadata->data.labelledCueRegion.purposeId, 4); bytesWritten += ma_dr_wav__write_or_count_u16ne_to_le(pWav, pMetadata->data.labelledCueRegion.country); bytesWritten += ma_dr_wav__write_or_count_u16ne_to_le(pWav, pMetadata->data.labelledCueRegion.language); bytesWritten += ma_dr_wav__write_or_count_u16ne_to_le(pWav, pMetadata->data.labelledCueRegion.dialect); bytesWritten += ma_dr_wav__write_or_count_u16ne_to_le(pWav, pMetadata->data.labelledCueRegion.codePage); if (pMetadata->data.labelledCueRegion.stringLength > 0) { MA_DR_WAV_ASSERT(pMetadata->data.labelledCueRegion.pString != NULL); bytesWritten += ma_dr_wav__write_or_count(pWav, pMetadata->data.labelledCueRegion.pString, pMetadata->data.labelledCueRegion.stringLength); bytesWritten += ma_dr_wav__write_or_count_byte(pWav, '\0'); } } break; case ma_dr_wav_metadata_type_unknown: { if (pMetadata->data.unknown.chunkLocation == ma_dr_wav_metadata_location_inside_adtl_list) { subchunkSize = pMetadata->data.unknown.dataSizeInBytes; MA_DR_WAV_ASSERT(pMetadata->data.unknown.pData != NULL); bytesWritten += ma_dr_wav__write_or_count(pWav, pMetadata->data.unknown.id, 4); bytesWritten += ma_dr_wav__write_or_count_u32ne_to_le(pWav, subchunkSize); bytesWritten += ma_dr_wav__write_or_count(pWav, pMetadata->data.unknown.pData, subchunkSize); } } break; default: break; } if ((subchunkSize % 2) != 0) { bytesWritten += ma_dr_wav__write_or_count_byte(pWav, 0); } } } MA_DR_WAV_ASSERT((bytesWritten % 2) == 0); return bytesWritten; } MA_PRIVATE ma_uint32 ma_dr_wav__riff_chunk_size_riff(ma_uint64 dataChunkSize, ma_dr_wav_metadata* pMetadata, ma_uint32 metadataCount) { ma_uint64 chunkSize = 4 + 24 + (ma_uint64)ma_dr_wav__write_or_count_metadata(NULL, pMetadata, metadataCount) + 8 + dataChunkSize + ma_dr_wav__chunk_padding_size_riff(dataChunkSize); if (chunkSize > 0xFFFFFFFFUL) { chunkSize = 0xFFFFFFFFUL; } return (ma_uint32)chunkSize; } MA_PRIVATE ma_uint32 ma_dr_wav__data_chunk_size_riff(ma_uint64 dataChunkSize) { if (dataChunkSize <= 0xFFFFFFFFUL) { return (ma_uint32)dataChunkSize; } else { return 0xFFFFFFFFUL; } } MA_PRIVATE ma_uint64 ma_dr_wav__riff_chunk_size_w64(ma_uint64 dataChunkSize) { ma_uint64 dataSubchunkPaddingSize = ma_dr_wav__chunk_padding_size_w64(dataChunkSize); return 80 + 24 + dataChunkSize + dataSubchunkPaddingSize; } MA_PRIVATE ma_uint64 ma_dr_wav__data_chunk_size_w64(ma_uint64 dataChunkSize) { return 24 + dataChunkSize; } MA_PRIVATE ma_uint64 ma_dr_wav__riff_chunk_size_rf64(ma_uint64 dataChunkSize, ma_dr_wav_metadata *metadata, ma_uint32 numMetadata) { ma_uint64 chunkSize = 4 + 36 + 24 + (ma_uint64)ma_dr_wav__write_or_count_metadata(NULL, metadata, numMetadata) + 8 + dataChunkSize + ma_dr_wav__chunk_padding_size_riff(dataChunkSize); if (chunkSize > 0xFFFFFFFFUL) { chunkSize = 0xFFFFFFFFUL; } return chunkSize; } MA_PRIVATE ma_uint64 ma_dr_wav__data_chunk_size_rf64(ma_uint64 dataChunkSize) { return dataChunkSize; } MA_PRIVATE ma_bool32 ma_dr_wav_preinit_write(ma_dr_wav* pWav, const ma_dr_wav_data_format* pFormat, ma_bool32 isSequential, ma_dr_wav_write_proc onWrite, ma_dr_wav_seek_proc onSeek, void* pUserData, const ma_allocation_callbacks* pAllocationCallbacks) { if (pWav == NULL || onWrite == NULL) { return MA_FALSE; } if (!isSequential && onSeek == NULL) { return MA_FALSE; } if (pFormat->format == MA_DR_WAVE_FORMAT_EXTENSIBLE) { return MA_FALSE; } if (pFormat->format == MA_DR_WAVE_FORMAT_ADPCM || pFormat->format == MA_DR_WAVE_FORMAT_DVI_ADPCM) { return MA_FALSE; } MA_DR_WAV_ZERO_MEMORY(pWav, sizeof(*pWav)); pWav->onWrite = onWrite; pWav->onSeek = onSeek; pWav->pUserData = pUserData; pWav->allocationCallbacks = ma_dr_wav_copy_allocation_callbacks_or_defaults(pAllocationCallbacks); if (pWav->allocationCallbacks.onFree == NULL || (pWav->allocationCallbacks.onMalloc == NULL && pWav->allocationCallbacks.onRealloc == NULL)) { return MA_FALSE; } pWav->fmt.formatTag = (ma_uint16)pFormat->format; pWav->fmt.channels = (ma_uint16)pFormat->channels; pWav->fmt.sampleRate = pFormat->sampleRate; pWav->fmt.avgBytesPerSec = (ma_uint32)((pFormat->bitsPerSample * pFormat->sampleRate * pFormat->channels) / 8); pWav->fmt.blockAlign = (ma_uint16)((pFormat->channels * pFormat->bitsPerSample) / 8); pWav->fmt.bitsPerSample = (ma_uint16)pFormat->bitsPerSample; pWav->fmt.extendedSize = 0; pWav->isSequentialWrite = isSequential; return MA_TRUE; } MA_PRIVATE ma_bool32 ma_dr_wav_init_write__internal(ma_dr_wav* pWav, const ma_dr_wav_data_format* pFormat, ma_uint64 totalSampleCount) { size_t runningPos = 0; ma_uint64 initialDataChunkSize = 0; ma_uint64 chunkSizeFMT; if (pWav->isSequentialWrite) { initialDataChunkSize = (totalSampleCount * pWav->fmt.bitsPerSample) / 8; if (pFormat->container == ma_dr_wav_container_riff) { if (initialDataChunkSize > (0xFFFFFFFFUL - 36)) { return MA_FALSE; } } } pWav->dataChunkDataSizeTargetWrite = initialDataChunkSize; if (pFormat->container == ma_dr_wav_container_riff) { ma_uint32 chunkSizeRIFF = 28 + (ma_uint32)initialDataChunkSize; runningPos += ma_dr_wav__write(pWav, "RIFF", 4); runningPos += ma_dr_wav__write_u32ne_to_le(pWav, chunkSizeRIFF); runningPos += ma_dr_wav__write(pWav, "WAVE", 4); } else if (pFormat->container == ma_dr_wav_container_w64) { ma_uint64 chunkSizeRIFF = 80 + 24 + initialDataChunkSize; runningPos += ma_dr_wav__write(pWav, ma_dr_wavGUID_W64_RIFF, 16); runningPos += ma_dr_wav__write_u64ne_to_le(pWav, chunkSizeRIFF); runningPos += ma_dr_wav__write(pWav, ma_dr_wavGUID_W64_WAVE, 16); } else if (pFormat->container == ma_dr_wav_container_rf64) { runningPos += ma_dr_wav__write(pWav, "RF64", 4); runningPos += ma_dr_wav__write_u32ne_to_le(pWav, 0xFFFFFFFF); runningPos += ma_dr_wav__write(pWav, "WAVE", 4); } else { return MA_FALSE; } if (pFormat->container == ma_dr_wav_container_rf64) { ma_uint32 initialds64ChunkSize = 28; ma_uint64 initialRiffChunkSize = 8 + initialds64ChunkSize + initialDataChunkSize; runningPos += ma_dr_wav__write(pWav, "ds64", 4); runningPos += ma_dr_wav__write_u32ne_to_le(pWav, initialds64ChunkSize); runningPos += ma_dr_wav__write_u64ne_to_le(pWav, initialRiffChunkSize); runningPos += ma_dr_wav__write_u64ne_to_le(pWav, initialDataChunkSize); runningPos += ma_dr_wav__write_u64ne_to_le(pWav, totalSampleCount); runningPos += ma_dr_wav__write_u32ne_to_le(pWav, 0); } if (pFormat->container == ma_dr_wav_container_riff || pFormat->container == ma_dr_wav_container_rf64) { chunkSizeFMT = 16; runningPos += ma_dr_wav__write(pWav, "fmt ", 4); runningPos += ma_dr_wav__write_u32ne_to_le(pWav, (ma_uint32)chunkSizeFMT); } else if (pFormat->container == ma_dr_wav_container_w64) { chunkSizeFMT = 40; runningPos += ma_dr_wav__write(pWav, ma_dr_wavGUID_W64_FMT, 16); runningPos += ma_dr_wav__write_u64ne_to_le(pWav, chunkSizeFMT); } runningPos += ma_dr_wav__write_u16ne_to_le(pWav, pWav->fmt.formatTag); runningPos += ma_dr_wav__write_u16ne_to_le(pWav, pWav->fmt.channels); runningPos += ma_dr_wav__write_u32ne_to_le(pWav, pWav->fmt.sampleRate); runningPos += ma_dr_wav__write_u32ne_to_le(pWav, pWav->fmt.avgBytesPerSec); runningPos += ma_dr_wav__write_u16ne_to_le(pWav, pWav->fmt.blockAlign); runningPos += ma_dr_wav__write_u16ne_to_le(pWav, pWav->fmt.bitsPerSample); if (!pWav->isSequentialWrite && pWav->pMetadata != NULL && pWav->metadataCount > 0 && (pFormat->container == ma_dr_wav_container_riff || pFormat->container == ma_dr_wav_container_rf64)) { runningPos += ma_dr_wav__write_or_count_metadata(pWav, pWav->pMetadata, pWav->metadataCount); } pWav->dataChunkDataPos = runningPos; if (pFormat->container == ma_dr_wav_container_riff) { ma_uint32 chunkSizeDATA = (ma_uint32)initialDataChunkSize; runningPos += ma_dr_wav__write(pWav, "data", 4); runningPos += ma_dr_wav__write_u32ne_to_le(pWav, chunkSizeDATA); } else if (pFormat->container == ma_dr_wav_container_w64) { ma_uint64 chunkSizeDATA = 24 + initialDataChunkSize; runningPos += ma_dr_wav__write(pWav, ma_dr_wavGUID_W64_DATA, 16); runningPos += ma_dr_wav__write_u64ne_to_le(pWav, chunkSizeDATA); } else if (pFormat->container == ma_dr_wav_container_rf64) { runningPos += ma_dr_wav__write(pWav, "data", 4); runningPos += ma_dr_wav__write_u32ne_to_le(pWav, 0xFFFFFFFF); } pWav->container = pFormat->container; pWav->channels = (ma_uint16)pFormat->channels; pWav->sampleRate = pFormat->sampleRate; pWav->bitsPerSample = (ma_uint16)pFormat->bitsPerSample; pWav->translatedFormatTag = (ma_uint16)pFormat->format; pWav->dataChunkDataPos = runningPos; return MA_TRUE; } MA_API ma_bool32 ma_dr_wav_init_write(ma_dr_wav* pWav, const ma_dr_wav_data_format* pFormat, ma_dr_wav_write_proc onWrite, ma_dr_wav_seek_proc onSeek, void* pUserData, const ma_allocation_callbacks* pAllocationCallbacks) { if (!ma_dr_wav_preinit_write(pWav, pFormat, MA_FALSE, onWrite, onSeek, pUserData, pAllocationCallbacks)) { return MA_FALSE; } return ma_dr_wav_init_write__internal(pWav, pFormat, 0); } MA_API ma_bool32 ma_dr_wav_init_write_sequential(ma_dr_wav* pWav, const ma_dr_wav_data_format* pFormat, ma_uint64 totalSampleCount, ma_dr_wav_write_proc onWrite, void* pUserData, const ma_allocation_callbacks* pAllocationCallbacks) { if (!ma_dr_wav_preinit_write(pWav, pFormat, MA_TRUE, onWrite, NULL, pUserData, pAllocationCallbacks)) { return MA_FALSE; } return ma_dr_wav_init_write__internal(pWav, pFormat, totalSampleCount); } MA_API ma_bool32 ma_dr_wav_init_write_sequential_pcm_frames(ma_dr_wav* pWav, const ma_dr_wav_data_format* pFormat, ma_uint64 totalPCMFrameCount, ma_dr_wav_write_proc onWrite, void* pUserData, const ma_allocation_callbacks* pAllocationCallbacks) { if (pFormat == NULL) { return MA_FALSE; } return ma_dr_wav_init_write_sequential(pWav, pFormat, totalPCMFrameCount*pFormat->channels, onWrite, pUserData, pAllocationCallbacks); } MA_API ma_bool32 ma_dr_wav_init_write_with_metadata(ma_dr_wav* pWav, const ma_dr_wav_data_format* pFormat, ma_dr_wav_write_proc onWrite, ma_dr_wav_seek_proc onSeek, void* pUserData, const ma_allocation_callbacks* pAllocationCallbacks, ma_dr_wav_metadata* pMetadata, ma_uint32 metadataCount) { if (!ma_dr_wav_preinit_write(pWav, pFormat, MA_FALSE, onWrite, onSeek, pUserData, pAllocationCallbacks)) { return MA_FALSE; } pWav->pMetadata = pMetadata; pWav->metadataCount = metadataCount; return ma_dr_wav_init_write__internal(pWav, pFormat, 0); } MA_API ma_uint64 ma_dr_wav_target_write_size_bytes(const ma_dr_wav_data_format* pFormat, ma_uint64 totalFrameCount, ma_dr_wav_metadata* pMetadata, ma_uint32 metadataCount) { ma_uint64 targetDataSizeBytes = (ma_uint64)((ma_int64)totalFrameCount * pFormat->channels * pFormat->bitsPerSample/8.0); ma_uint64 riffChunkSizeBytes; ma_uint64 fileSizeBytes = 0; if (pFormat->container == ma_dr_wav_container_riff) { riffChunkSizeBytes = ma_dr_wav__riff_chunk_size_riff(targetDataSizeBytes, pMetadata, metadataCount); fileSizeBytes = (8 + riffChunkSizeBytes); } else if (pFormat->container == ma_dr_wav_container_w64) { riffChunkSizeBytes = ma_dr_wav__riff_chunk_size_w64(targetDataSizeBytes); fileSizeBytes = riffChunkSizeBytes; } else if (pFormat->container == ma_dr_wav_container_rf64) { riffChunkSizeBytes = ma_dr_wav__riff_chunk_size_rf64(targetDataSizeBytes, pMetadata, metadataCount); fileSizeBytes = (8 + riffChunkSizeBytes); } return fileSizeBytes; } #ifndef MA_DR_WAV_NO_STDIO MA_PRIVATE size_t ma_dr_wav__on_read_stdio(void* pUserData, void* pBufferOut, size_t bytesToRead) { return fread(pBufferOut, 1, bytesToRead, (FILE*)pUserData); } MA_PRIVATE size_t ma_dr_wav__on_write_stdio(void* pUserData, const void* pData, size_t bytesToWrite) { return fwrite(pData, 1, bytesToWrite, (FILE*)pUserData); } MA_PRIVATE ma_bool32 ma_dr_wav__on_seek_stdio(void* pUserData, int offset, ma_dr_wav_seek_origin origin) { return fseek((FILE*)pUserData, offset, (origin == ma_dr_wav_seek_origin_current) ? SEEK_CUR : SEEK_SET) == 0; } MA_API ma_bool32 ma_dr_wav_init_file(ma_dr_wav* pWav, const char* filename, const ma_allocation_callbacks* pAllocationCallbacks) { return ma_dr_wav_init_file_ex(pWav, filename, NULL, NULL, 0, pAllocationCallbacks); } MA_PRIVATE ma_bool32 ma_dr_wav_init_file__internal_FILE(ma_dr_wav* pWav, FILE* pFile, ma_dr_wav_chunk_proc onChunk, void* pChunkUserData, ma_uint32 flags, const ma_allocation_callbacks* pAllocationCallbacks) { ma_bool32 result; result = ma_dr_wav_preinit(pWav, ma_dr_wav__on_read_stdio, ma_dr_wav__on_seek_stdio, (void*)pFile, pAllocationCallbacks); if (result != MA_TRUE) { fclose(pFile); return result; } result = ma_dr_wav_init__internal(pWav, onChunk, pChunkUserData, flags); if (result != MA_TRUE) { fclose(pFile); return result; } return MA_TRUE; } MA_API ma_bool32 ma_dr_wav_init_file_ex(ma_dr_wav* pWav, const char* filename, ma_dr_wav_chunk_proc onChunk, void* pChunkUserData, ma_uint32 flags, const ma_allocation_callbacks* pAllocationCallbacks) { FILE* pFile; if (ma_fopen(&pFile, filename, "rb") != MA_SUCCESS) { return MA_FALSE; } return ma_dr_wav_init_file__internal_FILE(pWav, pFile, onChunk, pChunkUserData, flags, pAllocationCallbacks); } #ifndef MA_DR_WAV_NO_WCHAR MA_API ma_bool32 ma_dr_wav_init_file_w(ma_dr_wav* pWav, const wchar_t* filename, const ma_allocation_callbacks* pAllocationCallbacks) { return ma_dr_wav_init_file_ex_w(pWav, filename, NULL, NULL, 0, pAllocationCallbacks); } MA_API ma_bool32 ma_dr_wav_init_file_ex_w(ma_dr_wav* pWav, const wchar_t* filename, ma_dr_wav_chunk_proc onChunk, void* pChunkUserData, ma_uint32 flags, const ma_allocation_callbacks* pAllocationCallbacks) { FILE* pFile; if (ma_wfopen(&pFile, filename, L"rb", pAllocationCallbacks) != MA_SUCCESS) { return MA_FALSE; } return ma_dr_wav_init_file__internal_FILE(pWav, pFile, onChunk, pChunkUserData, flags, pAllocationCallbacks); } #endif MA_API ma_bool32 ma_dr_wav_init_file_with_metadata(ma_dr_wav* pWav, const char* filename, ma_uint32 flags, const ma_allocation_callbacks* pAllocationCallbacks) { FILE* pFile; if (ma_fopen(&pFile, filename, "rb") != MA_SUCCESS) { return MA_FALSE; } return ma_dr_wav_init_file__internal_FILE(pWav, pFile, NULL, NULL, flags | MA_DR_WAV_WITH_METADATA, pAllocationCallbacks); } #ifndef MA_DR_WAV_NO_WCHAR MA_API ma_bool32 ma_dr_wav_init_file_with_metadata_w(ma_dr_wav* pWav, const wchar_t* filename, ma_uint32 flags, const ma_allocation_callbacks* pAllocationCallbacks) { FILE* pFile; if (ma_wfopen(&pFile, filename, L"rb", pAllocationCallbacks) != MA_SUCCESS) { return MA_FALSE; } return ma_dr_wav_init_file__internal_FILE(pWav, pFile, NULL, NULL, flags | MA_DR_WAV_WITH_METADATA, pAllocationCallbacks); } #endif MA_PRIVATE ma_bool32 ma_dr_wav_init_file_write__internal_FILE(ma_dr_wav* pWav, FILE* pFile, const ma_dr_wav_data_format* pFormat, ma_uint64 totalSampleCount, ma_bool32 isSequential, const ma_allocation_callbacks* pAllocationCallbacks) { ma_bool32 result; result = ma_dr_wav_preinit_write(pWav, pFormat, isSequential, ma_dr_wav__on_write_stdio, ma_dr_wav__on_seek_stdio, (void*)pFile, pAllocationCallbacks); if (result != MA_TRUE) { fclose(pFile); return result; } result = ma_dr_wav_init_write__internal(pWav, pFormat, totalSampleCount); if (result != MA_TRUE) { fclose(pFile); return result; } return MA_TRUE; } MA_PRIVATE ma_bool32 ma_dr_wav_init_file_write__internal(ma_dr_wav* pWav, const char* filename, const ma_dr_wav_data_format* pFormat, ma_uint64 totalSampleCount, ma_bool32 isSequential, const ma_allocation_callbacks* pAllocationCallbacks) { FILE* pFile; if (ma_fopen(&pFile, filename, "wb") != MA_SUCCESS) { return MA_FALSE; } return ma_dr_wav_init_file_write__internal_FILE(pWav, pFile, pFormat, totalSampleCount, isSequential, pAllocationCallbacks); } #ifndef MA_DR_WAV_NO_WCHAR MA_PRIVATE ma_bool32 ma_dr_wav_init_file_write_w__internal(ma_dr_wav* pWav, const wchar_t* filename, const ma_dr_wav_data_format* pFormat, ma_uint64 totalSampleCount, ma_bool32 isSequential, const ma_allocation_callbacks* pAllocationCallbacks) { FILE* pFile; if (ma_wfopen(&pFile, filename, L"wb", pAllocationCallbacks) != MA_SUCCESS) { return MA_FALSE; } return ma_dr_wav_init_file_write__internal_FILE(pWav, pFile, pFormat, totalSampleCount, isSequential, pAllocationCallbacks); } #endif MA_API ma_bool32 ma_dr_wav_init_file_write(ma_dr_wav* pWav, const char* filename, const ma_dr_wav_data_format* pFormat, const ma_allocation_callbacks* pAllocationCallbacks) { return ma_dr_wav_init_file_write__internal(pWav, filename, pFormat, 0, MA_FALSE, pAllocationCallbacks); } MA_API ma_bool32 ma_dr_wav_init_file_write_sequential(ma_dr_wav* pWav, const char* filename, const ma_dr_wav_data_format* pFormat, ma_uint64 totalSampleCount, const ma_allocation_callbacks* pAllocationCallbacks) { return ma_dr_wav_init_file_write__internal(pWav, filename, pFormat, totalSampleCount, MA_TRUE, pAllocationCallbacks); } MA_API ma_bool32 ma_dr_wav_init_file_write_sequential_pcm_frames(ma_dr_wav* pWav, const char* filename, const ma_dr_wav_data_format* pFormat, ma_uint64 totalPCMFrameCount, const ma_allocation_callbacks* pAllocationCallbacks) { if (pFormat == NULL) { return MA_FALSE; } return ma_dr_wav_init_file_write_sequential(pWav, filename, pFormat, totalPCMFrameCount*pFormat->channels, pAllocationCallbacks); } #ifndef MA_DR_WAV_NO_WCHAR MA_API ma_bool32 ma_dr_wav_init_file_write_w(ma_dr_wav* pWav, const wchar_t* filename, const ma_dr_wav_data_format* pFormat, const ma_allocation_callbacks* pAllocationCallbacks) { return ma_dr_wav_init_file_write_w__internal(pWav, filename, pFormat, 0, MA_FALSE, pAllocationCallbacks); } MA_API ma_bool32 ma_dr_wav_init_file_write_sequential_w(ma_dr_wav* pWav, const wchar_t* filename, const ma_dr_wav_data_format* pFormat, ma_uint64 totalSampleCount, const ma_allocation_callbacks* pAllocationCallbacks) { return ma_dr_wav_init_file_write_w__internal(pWav, filename, pFormat, totalSampleCount, MA_TRUE, pAllocationCallbacks); } MA_API ma_bool32 ma_dr_wav_init_file_write_sequential_pcm_frames_w(ma_dr_wav* pWav, const wchar_t* filename, const ma_dr_wav_data_format* pFormat, ma_uint64 totalPCMFrameCount, const ma_allocation_callbacks* pAllocationCallbacks) { if (pFormat == NULL) { return MA_FALSE; } return ma_dr_wav_init_file_write_sequential_w(pWav, filename, pFormat, totalPCMFrameCount*pFormat->channels, pAllocationCallbacks); } #endif #endif MA_PRIVATE size_t ma_dr_wav__on_read_memory(void* pUserData, void* pBufferOut, size_t bytesToRead) { ma_dr_wav* pWav = (ma_dr_wav*)pUserData; size_t bytesRemaining; MA_DR_WAV_ASSERT(pWav != NULL); MA_DR_WAV_ASSERT(pWav->memoryStream.dataSize >= pWav->memoryStream.currentReadPos); bytesRemaining = pWav->memoryStream.dataSize - pWav->memoryStream.currentReadPos; if (bytesToRead > bytesRemaining) { bytesToRead = bytesRemaining; } if (bytesToRead > 0) { MA_DR_WAV_COPY_MEMORY(pBufferOut, pWav->memoryStream.data + pWav->memoryStream.currentReadPos, bytesToRead); pWav->memoryStream.currentReadPos += bytesToRead; } return bytesToRead; } MA_PRIVATE ma_bool32 ma_dr_wav__on_seek_memory(void* pUserData, int offset, ma_dr_wav_seek_origin origin) { ma_dr_wav* pWav = (ma_dr_wav*)pUserData; MA_DR_WAV_ASSERT(pWav != NULL); if (origin == ma_dr_wav_seek_origin_current) { if (offset > 0) { if (pWav->memoryStream.currentReadPos + offset > pWav->memoryStream.dataSize) { return MA_FALSE; } } else { if (pWav->memoryStream.currentReadPos < (size_t)-offset) { return MA_FALSE; } } pWav->memoryStream.currentReadPos += offset; } else { if ((ma_uint32)offset <= pWav->memoryStream.dataSize) { pWav->memoryStream.currentReadPos = offset; } else { return MA_FALSE; } } return MA_TRUE; } MA_PRIVATE size_t ma_dr_wav__on_write_memory(void* pUserData, const void* pDataIn, size_t bytesToWrite) { ma_dr_wav* pWav = (ma_dr_wav*)pUserData; size_t bytesRemaining; MA_DR_WAV_ASSERT(pWav != NULL); MA_DR_WAV_ASSERT(pWav->memoryStreamWrite.dataCapacity >= pWav->memoryStreamWrite.currentWritePos); bytesRemaining = pWav->memoryStreamWrite.dataCapacity - pWav->memoryStreamWrite.currentWritePos; if (bytesRemaining < bytesToWrite) { void* pNewData; size_t newDataCapacity = (pWav->memoryStreamWrite.dataCapacity == 0) ? 256 : pWav->memoryStreamWrite.dataCapacity * 2; if ((newDataCapacity - pWav->memoryStreamWrite.currentWritePos) < bytesToWrite) { newDataCapacity = pWav->memoryStreamWrite.currentWritePos + bytesToWrite; } pNewData = ma_dr_wav__realloc_from_callbacks(*pWav->memoryStreamWrite.ppData, newDataCapacity, pWav->memoryStreamWrite.dataCapacity, &pWav->allocationCallbacks); if (pNewData == NULL) { return 0; } *pWav->memoryStreamWrite.ppData = pNewData; pWav->memoryStreamWrite.dataCapacity = newDataCapacity; } MA_DR_WAV_COPY_MEMORY(((ma_uint8*)(*pWav->memoryStreamWrite.ppData)) + pWav->memoryStreamWrite.currentWritePos, pDataIn, bytesToWrite); pWav->memoryStreamWrite.currentWritePos += bytesToWrite; if (pWav->memoryStreamWrite.dataSize < pWav->memoryStreamWrite.currentWritePos) { pWav->memoryStreamWrite.dataSize = pWav->memoryStreamWrite.currentWritePos; } *pWav->memoryStreamWrite.pDataSize = pWav->memoryStreamWrite.dataSize; return bytesToWrite; } MA_PRIVATE ma_bool32 ma_dr_wav__on_seek_memory_write(void* pUserData, int offset, ma_dr_wav_seek_origin origin) { ma_dr_wav* pWav = (ma_dr_wav*)pUserData; MA_DR_WAV_ASSERT(pWav != NULL); if (origin == ma_dr_wav_seek_origin_current) { if (offset > 0) { if (pWav->memoryStreamWrite.currentWritePos + offset > pWav->memoryStreamWrite.dataSize) { offset = (int)(pWav->memoryStreamWrite.dataSize - pWav->memoryStreamWrite.currentWritePos); } } else { if (pWav->memoryStreamWrite.currentWritePos < (size_t)-offset) { offset = -(int)pWav->memoryStreamWrite.currentWritePos; } } pWav->memoryStreamWrite.currentWritePos += offset; } else { if ((ma_uint32)offset <= pWav->memoryStreamWrite.dataSize) { pWav->memoryStreamWrite.currentWritePos = offset; } else { pWav->memoryStreamWrite.currentWritePos = pWav->memoryStreamWrite.dataSize; } } return MA_TRUE; } MA_API ma_bool32 ma_dr_wav_init_memory(ma_dr_wav* pWav, const void* data, size_t dataSize, const ma_allocation_callbacks* pAllocationCallbacks) { return ma_dr_wav_init_memory_ex(pWav, data, dataSize, NULL, NULL, 0, pAllocationCallbacks); } MA_API ma_bool32 ma_dr_wav_init_memory_ex(ma_dr_wav* pWav, const void* data, size_t dataSize, ma_dr_wav_chunk_proc onChunk, void* pChunkUserData, ma_uint32 flags, const ma_allocation_callbacks* pAllocationCallbacks) { if (data == NULL || dataSize == 0) { return MA_FALSE; } if (!ma_dr_wav_preinit(pWav, ma_dr_wav__on_read_memory, ma_dr_wav__on_seek_memory, pWav, pAllocationCallbacks)) { return MA_FALSE; } pWav->memoryStream.data = (const ma_uint8*)data; pWav->memoryStream.dataSize = dataSize; pWav->memoryStream.currentReadPos = 0; return ma_dr_wav_init__internal(pWav, onChunk, pChunkUserData, flags); } MA_API ma_bool32 ma_dr_wav_init_memory_with_metadata(ma_dr_wav* pWav, const void* data, size_t dataSize, ma_uint32 flags, const ma_allocation_callbacks* pAllocationCallbacks) { if (data == NULL || dataSize == 0) { return MA_FALSE; } if (!ma_dr_wav_preinit(pWav, ma_dr_wav__on_read_memory, ma_dr_wav__on_seek_memory, pWav, pAllocationCallbacks)) { return MA_FALSE; } pWav->memoryStream.data = (const ma_uint8*)data; pWav->memoryStream.dataSize = dataSize; pWav->memoryStream.currentReadPos = 0; return ma_dr_wav_init__internal(pWav, NULL, NULL, flags | MA_DR_WAV_WITH_METADATA); } MA_PRIVATE ma_bool32 ma_dr_wav_init_memory_write__internal(ma_dr_wav* pWav, void** ppData, size_t* pDataSize, const ma_dr_wav_data_format* pFormat, ma_uint64 totalSampleCount, ma_bool32 isSequential, const ma_allocation_callbacks* pAllocationCallbacks) { if (ppData == NULL || pDataSize == NULL) { return MA_FALSE; } *ppData = NULL; *pDataSize = 0; if (!ma_dr_wav_preinit_write(pWav, pFormat, isSequential, ma_dr_wav__on_write_memory, ma_dr_wav__on_seek_memory_write, pWav, pAllocationCallbacks)) { return MA_FALSE; } pWav->memoryStreamWrite.ppData = ppData; pWav->memoryStreamWrite.pDataSize = pDataSize; pWav->memoryStreamWrite.dataSize = 0; pWav->memoryStreamWrite.dataCapacity = 0; pWav->memoryStreamWrite.currentWritePos = 0; return ma_dr_wav_init_write__internal(pWav, pFormat, totalSampleCount); } MA_API ma_bool32 ma_dr_wav_init_memory_write(ma_dr_wav* pWav, void** ppData, size_t* pDataSize, const ma_dr_wav_data_format* pFormat, const ma_allocation_callbacks* pAllocationCallbacks) { return ma_dr_wav_init_memory_write__internal(pWav, ppData, pDataSize, pFormat, 0, MA_FALSE, pAllocationCallbacks); } MA_API ma_bool32 ma_dr_wav_init_memory_write_sequential(ma_dr_wav* pWav, void** ppData, size_t* pDataSize, const ma_dr_wav_data_format* pFormat, ma_uint64 totalSampleCount, const ma_allocation_callbacks* pAllocationCallbacks) { return ma_dr_wav_init_memory_write__internal(pWav, ppData, pDataSize, pFormat, totalSampleCount, MA_TRUE, pAllocationCallbacks); } MA_API ma_bool32 ma_dr_wav_init_memory_write_sequential_pcm_frames(ma_dr_wav* pWav, void** ppData, size_t* pDataSize, const ma_dr_wav_data_format* pFormat, ma_uint64 totalPCMFrameCount, const ma_allocation_callbacks* pAllocationCallbacks) { if (pFormat == NULL) { return MA_FALSE; } return ma_dr_wav_init_memory_write_sequential(pWav, ppData, pDataSize, pFormat, totalPCMFrameCount*pFormat->channels, pAllocationCallbacks); } MA_API ma_result ma_dr_wav_uninit(ma_dr_wav* pWav) { ma_result result = MA_SUCCESS; if (pWav == NULL) { return MA_INVALID_ARGS; } if (pWav->onWrite != NULL) { ma_uint32 paddingSize = 0; if (pWav->container == ma_dr_wav_container_riff || pWav->container == ma_dr_wav_container_rf64) { paddingSize = ma_dr_wav__chunk_padding_size_riff(pWav->dataChunkDataSize); } else { paddingSize = ma_dr_wav__chunk_padding_size_w64(pWav->dataChunkDataSize); } if (paddingSize > 0) { ma_uint64 paddingData = 0; ma_dr_wav__write(pWav, &paddingData, paddingSize); } if (pWav->onSeek && !pWav->isSequentialWrite) { if (pWav->container == ma_dr_wav_container_riff) { if (pWav->onSeek(pWav->pUserData, 4, ma_dr_wav_seek_origin_start)) { ma_uint32 riffChunkSize = ma_dr_wav__riff_chunk_size_riff(pWav->dataChunkDataSize, pWav->pMetadata, pWav->metadataCount); ma_dr_wav__write_u32ne_to_le(pWav, riffChunkSize); } if (pWav->onSeek(pWav->pUserData, (int)pWav->dataChunkDataPos - 4, ma_dr_wav_seek_origin_start)) { ma_uint32 dataChunkSize = ma_dr_wav__data_chunk_size_riff(pWav->dataChunkDataSize); ma_dr_wav__write_u32ne_to_le(pWav, dataChunkSize); } } else if (pWav->container == ma_dr_wav_container_w64) { if (pWav->onSeek(pWav->pUserData, 16, ma_dr_wav_seek_origin_start)) { ma_uint64 riffChunkSize = ma_dr_wav__riff_chunk_size_w64(pWav->dataChunkDataSize); ma_dr_wav__write_u64ne_to_le(pWav, riffChunkSize); } if (pWav->onSeek(pWav->pUserData, (int)pWav->dataChunkDataPos - 8, ma_dr_wav_seek_origin_start)) { ma_uint64 dataChunkSize = ma_dr_wav__data_chunk_size_w64(pWav->dataChunkDataSize); ma_dr_wav__write_u64ne_to_le(pWav, dataChunkSize); } } else if (pWav->container == ma_dr_wav_container_rf64) { int ds64BodyPos = 12 + 8; if (pWav->onSeek(pWav->pUserData, ds64BodyPos + 0, ma_dr_wav_seek_origin_start)) { ma_uint64 riffChunkSize = ma_dr_wav__riff_chunk_size_rf64(pWav->dataChunkDataSize, pWav->pMetadata, pWav->metadataCount); ma_dr_wav__write_u64ne_to_le(pWav, riffChunkSize); } if (pWav->onSeek(pWav->pUserData, ds64BodyPos + 8, ma_dr_wav_seek_origin_start)) { ma_uint64 dataChunkSize = ma_dr_wav__data_chunk_size_rf64(pWav->dataChunkDataSize); ma_dr_wav__write_u64ne_to_le(pWav, dataChunkSize); } } } if (pWav->isSequentialWrite) { if (pWav->dataChunkDataSize != pWav->dataChunkDataSizeTargetWrite) { result = MA_INVALID_FILE; } } } else { ma_dr_wav_free(pWav->pMetadata, &pWav->allocationCallbacks); } #ifndef MA_DR_WAV_NO_STDIO if (pWav->onRead == ma_dr_wav__on_read_stdio || pWav->onWrite == ma_dr_wav__on_write_stdio) { fclose((FILE*)pWav->pUserData); } #endif return result; } MA_API size_t ma_dr_wav_read_raw(ma_dr_wav* pWav, size_t bytesToRead, void* pBufferOut) { size_t bytesRead; ma_uint32 bytesPerFrame; if (pWav == NULL || bytesToRead == 0) { return 0; } if (bytesToRead > pWav->bytesRemaining) { bytesToRead = (size_t)pWav->bytesRemaining; } if (bytesToRead == 0) { return 0; } bytesPerFrame = ma_dr_wav_get_bytes_per_pcm_frame(pWav); if (bytesPerFrame == 0) { return 0; } if (pBufferOut != NULL) { bytesRead = pWav->onRead(pWav->pUserData, pBufferOut, bytesToRead); } else { bytesRead = 0; while (bytesRead < bytesToRead) { size_t bytesToSeek = (bytesToRead - bytesRead); if (bytesToSeek > 0x7FFFFFFF) { bytesToSeek = 0x7FFFFFFF; } if (pWav->onSeek(pWav->pUserData, (int)bytesToSeek, ma_dr_wav_seek_origin_current) == MA_FALSE) { break; } bytesRead += bytesToSeek; } while (bytesRead < bytesToRead) { ma_uint8 buffer[4096]; size_t bytesSeeked; size_t bytesToSeek = (bytesToRead - bytesRead); if (bytesToSeek > sizeof(buffer)) { bytesToSeek = sizeof(buffer); } bytesSeeked = pWav->onRead(pWav->pUserData, buffer, bytesToSeek); bytesRead += bytesSeeked; if (bytesSeeked < bytesToSeek) { break; } } } pWav->readCursorInPCMFrames += bytesRead / bytesPerFrame; pWav->bytesRemaining -= bytesRead; return bytesRead; } MA_API ma_uint64 ma_dr_wav_read_pcm_frames_le(ma_dr_wav* pWav, ma_uint64 framesToRead, void* pBufferOut) { ma_uint32 bytesPerFrame; ma_uint64 bytesToRead; ma_uint64 framesRemainingInFile; if (pWav == NULL || framesToRead == 0) { return 0; } if (ma_dr_wav__is_compressed_format_tag(pWav->translatedFormatTag)) { return 0; } framesRemainingInFile = pWav->totalPCMFrameCount - pWav->readCursorInPCMFrames; if (framesToRead > framesRemainingInFile) { framesToRead = framesRemainingInFile; } bytesPerFrame = ma_dr_wav_get_bytes_per_pcm_frame(pWav); if (bytesPerFrame == 0) { return 0; } bytesToRead = framesToRead * bytesPerFrame; if (bytesToRead > MA_SIZE_MAX) { bytesToRead = (MA_SIZE_MAX / bytesPerFrame) * bytesPerFrame; } if (bytesToRead == 0) { return 0; } return ma_dr_wav_read_raw(pWav, (size_t)bytesToRead, pBufferOut) / bytesPerFrame; } MA_API ma_uint64 ma_dr_wav_read_pcm_frames_be(ma_dr_wav* pWav, ma_uint64 framesToRead, void* pBufferOut) { ma_uint64 framesRead = ma_dr_wav_read_pcm_frames_le(pWav, framesToRead, pBufferOut); if (pBufferOut != NULL) { ma_uint32 bytesPerFrame = ma_dr_wav_get_bytes_per_pcm_frame(pWav); if (bytesPerFrame == 0) { return 0; } ma_dr_wav__bswap_samples(pBufferOut, framesRead*pWav->channels, bytesPerFrame/pWav->channels); } return framesRead; } MA_API ma_uint64 ma_dr_wav_read_pcm_frames(ma_dr_wav* pWav, ma_uint64 framesToRead, void* pBufferOut) { ma_uint64 framesRead = 0; if (ma_dr_wav_is_container_be(pWav->container)) { if (pWav->container != ma_dr_wav_container_aiff || pWav->aiff.isLE == MA_FALSE) { if (ma_dr_wav__is_little_endian()) { framesRead = ma_dr_wav_read_pcm_frames_be(pWav, framesToRead, pBufferOut); } else { framesRead = ma_dr_wav_read_pcm_frames_le(pWav, framesToRead, pBufferOut); } goto post_process; } } if (ma_dr_wav__is_little_endian()) { framesRead = ma_dr_wav_read_pcm_frames_le(pWav, framesToRead, pBufferOut); } else { framesRead = ma_dr_wav_read_pcm_frames_be(pWav, framesToRead, pBufferOut); } post_process: { if (pWav->container == ma_dr_wav_container_aiff && pWav->bitsPerSample == 8 && pWav->aiff.isUnsigned == MA_FALSE) { if (pBufferOut != NULL) { ma_uint64 iSample; for (iSample = 0; iSample < framesRead * pWav->channels; iSample += 1) { ((ma_uint8*)pBufferOut)[iSample] += 128; } } } } return framesRead; } MA_PRIVATE ma_bool32 ma_dr_wav_seek_to_first_pcm_frame(ma_dr_wav* pWav) { if (pWav->onWrite != NULL) { return MA_FALSE; } if (!pWav->onSeek(pWav->pUserData, (int)pWav->dataChunkDataPos, ma_dr_wav_seek_origin_start)) { return MA_FALSE; } if (ma_dr_wav__is_compressed_format_tag(pWav->translatedFormatTag)) { if (pWav->translatedFormatTag == MA_DR_WAVE_FORMAT_ADPCM) { MA_DR_WAV_ZERO_OBJECT(&pWav->msadpcm); } else if (pWav->translatedFormatTag == MA_DR_WAVE_FORMAT_DVI_ADPCM) { MA_DR_WAV_ZERO_OBJECT(&pWav->ima); } else { MA_DR_WAV_ASSERT(MA_FALSE); } } pWav->readCursorInPCMFrames = 0; pWav->bytesRemaining = pWav->dataChunkDataSize; return MA_TRUE; } MA_API ma_bool32 ma_dr_wav_seek_to_pcm_frame(ma_dr_wav* pWav, ma_uint64 targetFrameIndex) { if (pWav == NULL || pWav->onSeek == NULL) { return MA_FALSE; } if (pWav->onWrite != NULL) { return MA_FALSE; } if (pWav->totalPCMFrameCount == 0) { return MA_TRUE; } if (targetFrameIndex > pWav->totalPCMFrameCount) { targetFrameIndex = pWav->totalPCMFrameCount; } if (ma_dr_wav__is_compressed_format_tag(pWav->translatedFormatTag)) { if (targetFrameIndex < pWav->readCursorInPCMFrames) { if (!ma_dr_wav_seek_to_first_pcm_frame(pWav)) { return MA_FALSE; } } if (targetFrameIndex > pWav->readCursorInPCMFrames) { ma_uint64 offsetInFrames = targetFrameIndex - pWav->readCursorInPCMFrames; ma_int16 devnull[2048]; while (offsetInFrames > 0) { ma_uint64 framesRead = 0; ma_uint64 framesToRead = offsetInFrames; if (framesToRead > ma_dr_wav_countof(devnull)/pWav->channels) { framesToRead = ma_dr_wav_countof(devnull)/pWav->channels; } if (pWav->translatedFormatTag == MA_DR_WAVE_FORMAT_ADPCM) { framesRead = ma_dr_wav_read_pcm_frames_s16__msadpcm(pWav, framesToRead, devnull); } else if (pWav->translatedFormatTag == MA_DR_WAVE_FORMAT_DVI_ADPCM) { framesRead = ma_dr_wav_read_pcm_frames_s16__ima(pWav, framesToRead, devnull); } else { MA_DR_WAV_ASSERT(MA_FALSE); } if (framesRead != framesToRead) { return MA_FALSE; } offsetInFrames -= framesRead; } } } else { ma_uint64 totalSizeInBytes; ma_uint64 currentBytePos; ma_uint64 targetBytePos; ma_uint64 offset; ma_uint32 bytesPerFrame; bytesPerFrame = ma_dr_wav_get_bytes_per_pcm_frame(pWav); if (bytesPerFrame == 0) { return MA_FALSE; } totalSizeInBytes = pWav->totalPCMFrameCount * bytesPerFrame; currentBytePos = totalSizeInBytes - pWav->bytesRemaining; targetBytePos = targetFrameIndex * bytesPerFrame; if (currentBytePos < targetBytePos) { offset = (targetBytePos - currentBytePos); } else { if (!ma_dr_wav_seek_to_first_pcm_frame(pWav)) { return MA_FALSE; } offset = targetBytePos; } while (offset > 0) { int offset32 = ((offset > INT_MAX) ? INT_MAX : (int)offset); if (!pWav->onSeek(pWav->pUserData, offset32, ma_dr_wav_seek_origin_current)) { return MA_FALSE; } pWav->readCursorInPCMFrames += offset32 / bytesPerFrame; pWav->bytesRemaining -= offset32; offset -= offset32; } } return MA_TRUE; } MA_API ma_result ma_dr_wav_get_cursor_in_pcm_frames(ma_dr_wav* pWav, ma_uint64* pCursor) { if (pCursor == NULL) { return MA_INVALID_ARGS; } *pCursor = 0; if (pWav == NULL) { return MA_INVALID_ARGS; } *pCursor = pWav->readCursorInPCMFrames; return MA_SUCCESS; } MA_API ma_result ma_dr_wav_get_length_in_pcm_frames(ma_dr_wav* pWav, ma_uint64* pLength) { if (pLength == NULL) { return MA_INVALID_ARGS; } *pLength = 0; if (pWav == NULL) { return MA_INVALID_ARGS; } *pLength = pWav->totalPCMFrameCount; return MA_SUCCESS; } MA_API size_t ma_dr_wav_write_raw(ma_dr_wav* pWav, size_t bytesToWrite, const void* pData) { size_t bytesWritten; if (pWav == NULL || bytesToWrite == 0 || pData == NULL) { return 0; } bytesWritten = pWav->onWrite(pWav->pUserData, pData, bytesToWrite); pWav->dataChunkDataSize += bytesWritten; return bytesWritten; } MA_API ma_uint64 ma_dr_wav_write_pcm_frames_le(ma_dr_wav* pWav, ma_uint64 framesToWrite, const void* pData) { ma_uint64 bytesToWrite; ma_uint64 bytesWritten; const ma_uint8* pRunningData; if (pWav == NULL || framesToWrite == 0 || pData == NULL) { return 0; } bytesToWrite = ((framesToWrite * pWav->channels * pWav->bitsPerSample) / 8); if (bytesToWrite > MA_SIZE_MAX) { return 0; } bytesWritten = 0; pRunningData = (const ma_uint8*)pData; while (bytesToWrite > 0) { size_t bytesJustWritten; ma_uint64 bytesToWriteThisIteration; bytesToWriteThisIteration = bytesToWrite; MA_DR_WAV_ASSERT(bytesToWriteThisIteration <= MA_SIZE_MAX); bytesJustWritten = ma_dr_wav_write_raw(pWav, (size_t)bytesToWriteThisIteration, pRunningData); if (bytesJustWritten == 0) { break; } bytesToWrite -= bytesJustWritten; bytesWritten += bytesJustWritten; pRunningData += bytesJustWritten; } return (bytesWritten * 8) / pWav->bitsPerSample / pWav->channels; } MA_API ma_uint64 ma_dr_wav_write_pcm_frames_be(ma_dr_wav* pWav, ma_uint64 framesToWrite, const void* pData) { ma_uint64 bytesToWrite; ma_uint64 bytesWritten; ma_uint32 bytesPerSample; const ma_uint8* pRunningData; if (pWav == NULL || framesToWrite == 0 || pData == NULL) { return 0; } bytesToWrite = ((framesToWrite * pWav->channels * pWav->bitsPerSample) / 8); if (bytesToWrite > MA_SIZE_MAX) { return 0; } bytesWritten = 0; pRunningData = (const ma_uint8*)pData; bytesPerSample = ma_dr_wav_get_bytes_per_pcm_frame(pWav) / pWav->channels; if (bytesPerSample == 0) { return 0; } while (bytesToWrite > 0) { ma_uint8 temp[4096]; ma_uint32 sampleCount; size_t bytesJustWritten; ma_uint64 bytesToWriteThisIteration; bytesToWriteThisIteration = bytesToWrite; MA_DR_WAV_ASSERT(bytesToWriteThisIteration <= MA_SIZE_MAX); sampleCount = sizeof(temp)/bytesPerSample; if (bytesToWriteThisIteration > ((ma_uint64)sampleCount)*bytesPerSample) { bytesToWriteThisIteration = ((ma_uint64)sampleCount)*bytesPerSample; } MA_DR_WAV_COPY_MEMORY(temp, pRunningData, (size_t)bytesToWriteThisIteration); ma_dr_wav__bswap_samples(temp, sampleCount, bytesPerSample); bytesJustWritten = ma_dr_wav_write_raw(pWav, (size_t)bytesToWriteThisIteration, temp); if (bytesJustWritten == 0) { break; } bytesToWrite -= bytesJustWritten; bytesWritten += bytesJustWritten; pRunningData += bytesJustWritten; } return (bytesWritten * 8) / pWav->bitsPerSample / pWav->channels; } MA_API ma_uint64 ma_dr_wav_write_pcm_frames(ma_dr_wav* pWav, ma_uint64 framesToWrite, const void* pData) { if (ma_dr_wav__is_little_endian()) { return ma_dr_wav_write_pcm_frames_le(pWav, framesToWrite, pData); } else { return ma_dr_wav_write_pcm_frames_be(pWav, framesToWrite, pData); } } MA_PRIVATE ma_uint64 ma_dr_wav_read_pcm_frames_s16__msadpcm(ma_dr_wav* pWav, ma_uint64 framesToRead, ma_int16* pBufferOut) { ma_uint64 totalFramesRead = 0; MA_DR_WAV_ASSERT(pWav != NULL); MA_DR_WAV_ASSERT(framesToRead > 0); while (pWav->readCursorInPCMFrames < pWav->totalPCMFrameCount) { MA_DR_WAV_ASSERT(framesToRead > 0); if (pWav->msadpcm.cachedFrameCount == 0 && pWav->msadpcm.bytesRemainingInBlock == 0) { if (pWav->channels == 1) { ma_uint8 header[7]; if (pWav->onRead(pWav->pUserData, header, sizeof(header)) != sizeof(header)) { return totalFramesRead; } pWav->msadpcm.bytesRemainingInBlock = pWav->fmt.blockAlign - sizeof(header); pWav->msadpcm.predictor[0] = header[0]; pWav->msadpcm.delta[0] = ma_dr_wav_bytes_to_s16(header + 1); pWav->msadpcm.prevFrames[0][1] = (ma_int32)ma_dr_wav_bytes_to_s16(header + 3); pWav->msadpcm.prevFrames[0][0] = (ma_int32)ma_dr_wav_bytes_to_s16(header + 5); pWav->msadpcm.cachedFrames[2] = pWav->msadpcm.prevFrames[0][0]; pWav->msadpcm.cachedFrames[3] = pWav->msadpcm.prevFrames[0][1]; pWav->msadpcm.cachedFrameCount = 2; } else { ma_uint8 header[14]; if (pWav->onRead(pWav->pUserData, header, sizeof(header)) != sizeof(header)) { return totalFramesRead; } pWav->msadpcm.bytesRemainingInBlock = pWav->fmt.blockAlign - sizeof(header); pWav->msadpcm.predictor[0] = header[0]; pWav->msadpcm.predictor[1] = header[1]; pWav->msadpcm.delta[0] = ma_dr_wav_bytes_to_s16(header + 2); pWav->msadpcm.delta[1] = ma_dr_wav_bytes_to_s16(header + 4); pWav->msadpcm.prevFrames[0][1] = (ma_int32)ma_dr_wav_bytes_to_s16(header + 6); pWav->msadpcm.prevFrames[1][1] = (ma_int32)ma_dr_wav_bytes_to_s16(header + 8); pWav->msadpcm.prevFrames[0][0] = (ma_int32)ma_dr_wav_bytes_to_s16(header + 10); pWav->msadpcm.prevFrames[1][0] = (ma_int32)ma_dr_wav_bytes_to_s16(header + 12); pWav->msadpcm.cachedFrames[0] = pWav->msadpcm.prevFrames[0][0]; pWav->msadpcm.cachedFrames[1] = pWav->msadpcm.prevFrames[1][0]; pWav->msadpcm.cachedFrames[2] = pWav->msadpcm.prevFrames[0][1]; pWav->msadpcm.cachedFrames[3] = pWav->msadpcm.prevFrames[1][1]; pWav->msadpcm.cachedFrameCount = 2; } } while (framesToRead > 0 && pWav->msadpcm.cachedFrameCount > 0 && pWav->readCursorInPCMFrames < pWav->totalPCMFrameCount) { if (pBufferOut != NULL) { ma_uint32 iSample = 0; for (iSample = 0; iSample < pWav->channels; iSample += 1) { pBufferOut[iSample] = (ma_int16)pWav->msadpcm.cachedFrames[(ma_dr_wav_countof(pWav->msadpcm.cachedFrames) - (pWav->msadpcm.cachedFrameCount*pWav->channels)) + iSample]; } pBufferOut += pWav->channels; } framesToRead -= 1; totalFramesRead += 1; pWav->readCursorInPCMFrames += 1; pWav->msadpcm.cachedFrameCount -= 1; } if (framesToRead == 0) { break; } if (pWav->msadpcm.cachedFrameCount == 0) { if (pWav->msadpcm.bytesRemainingInBlock == 0) { continue; } else { static ma_int32 adaptationTable[] = { 230, 230, 230, 230, 307, 409, 512, 614, 768, 614, 512, 409, 307, 230, 230, 230 }; static ma_int32 coeff1Table[] = { 256, 512, 0, 192, 240, 460, 392 }; static ma_int32 coeff2Table[] = { 0, -256, 0, 64, 0, -208, -232 }; ma_uint8 nibbles; ma_int32 nibble0; ma_int32 nibble1; if (pWav->onRead(pWav->pUserData, &nibbles, 1) != 1) { return totalFramesRead; } pWav->msadpcm.bytesRemainingInBlock -= 1; nibble0 = ((nibbles & 0xF0) >> 4); if ((nibbles & 0x80)) { nibble0 |= 0xFFFFFFF0UL; } nibble1 = ((nibbles & 0x0F) >> 0); if ((nibbles & 0x08)) { nibble1 |= 0xFFFFFFF0UL; } if (pWav->channels == 1) { ma_int32 newSample0; ma_int32 newSample1; newSample0 = ((pWav->msadpcm.prevFrames[0][1] * coeff1Table[pWav->msadpcm.predictor[0]]) + (pWav->msadpcm.prevFrames[0][0] * coeff2Table[pWav->msadpcm.predictor[0]])) >> 8; newSample0 += nibble0 * pWav->msadpcm.delta[0]; newSample0 = ma_dr_wav_clamp(newSample0, -32768, 32767); pWav->msadpcm.delta[0] = (adaptationTable[((nibbles & 0xF0) >> 4)] * pWav->msadpcm.delta[0]) >> 8; if (pWav->msadpcm.delta[0] < 16) { pWav->msadpcm.delta[0] = 16; } pWav->msadpcm.prevFrames[0][0] = pWav->msadpcm.prevFrames[0][1]; pWav->msadpcm.prevFrames[0][1] = newSample0; newSample1 = ((pWav->msadpcm.prevFrames[0][1] * coeff1Table[pWav->msadpcm.predictor[0]]) + (pWav->msadpcm.prevFrames[0][0] * coeff2Table[pWav->msadpcm.predictor[0]])) >> 8; newSample1 += nibble1 * pWav->msadpcm.delta[0]; newSample1 = ma_dr_wav_clamp(newSample1, -32768, 32767); pWav->msadpcm.delta[0] = (adaptationTable[((nibbles & 0x0F) >> 0)] * pWav->msadpcm.delta[0]) >> 8; if (pWav->msadpcm.delta[0] < 16) { pWav->msadpcm.delta[0] = 16; } pWav->msadpcm.prevFrames[0][0] = pWav->msadpcm.prevFrames[0][1]; pWav->msadpcm.prevFrames[0][1] = newSample1; pWav->msadpcm.cachedFrames[2] = newSample0; pWav->msadpcm.cachedFrames[3] = newSample1; pWav->msadpcm.cachedFrameCount = 2; } else { ma_int32 newSample0; ma_int32 newSample1; newSample0 = ((pWav->msadpcm.prevFrames[0][1] * coeff1Table[pWav->msadpcm.predictor[0]]) + (pWav->msadpcm.prevFrames[0][0] * coeff2Table[pWav->msadpcm.predictor[0]])) >> 8; newSample0 += nibble0 * pWav->msadpcm.delta[0]; newSample0 = ma_dr_wav_clamp(newSample0, -32768, 32767); pWav->msadpcm.delta[0] = (adaptationTable[((nibbles & 0xF0) >> 4)] * pWav->msadpcm.delta[0]) >> 8; if (pWav->msadpcm.delta[0] < 16) { pWav->msadpcm.delta[0] = 16; } pWav->msadpcm.prevFrames[0][0] = pWav->msadpcm.prevFrames[0][1]; pWav->msadpcm.prevFrames[0][1] = newSample0; newSample1 = ((pWav->msadpcm.prevFrames[1][1] * coeff1Table[pWav->msadpcm.predictor[1]]) + (pWav->msadpcm.prevFrames[1][0] * coeff2Table[pWav->msadpcm.predictor[1]])) >> 8; newSample1 += nibble1 * pWav->msadpcm.delta[1]; newSample1 = ma_dr_wav_clamp(newSample1, -32768, 32767); pWav->msadpcm.delta[1] = (adaptationTable[((nibbles & 0x0F) >> 0)] * pWav->msadpcm.delta[1]) >> 8; if (pWav->msadpcm.delta[1] < 16) { pWav->msadpcm.delta[1] = 16; } pWav->msadpcm.prevFrames[1][0] = pWav->msadpcm.prevFrames[1][1]; pWav->msadpcm.prevFrames[1][1] = newSample1; pWav->msadpcm.cachedFrames[2] = newSample0; pWav->msadpcm.cachedFrames[3] = newSample1; pWav->msadpcm.cachedFrameCount = 1; } } } } return totalFramesRead; } MA_PRIVATE ma_uint64 ma_dr_wav_read_pcm_frames_s16__ima(ma_dr_wav* pWav, ma_uint64 framesToRead, ma_int16* pBufferOut) { ma_uint64 totalFramesRead = 0; ma_uint32 iChannel; static ma_int32 indexTable[16] = { -1, -1, -1, -1, 2, 4, 6, 8, -1, -1, -1, -1, 2, 4, 6, 8 }; static ma_int32 stepTable[89] = { 7, 8, 9, 10, 11, 12, 13, 14, 16, 17, 19, 21, 23, 25, 28, 31, 34, 37, 41, 45, 50, 55, 60, 66, 73, 80, 88, 97, 107, 118, 130, 143, 157, 173, 190, 209, 230, 253, 279, 307, 337, 371, 408, 449, 494, 544, 598, 658, 724, 796, 876, 963, 1060, 1166, 1282, 1411, 1552, 1707, 1878, 2066, 2272, 2499, 2749, 3024, 3327, 3660, 4026, 4428, 4871, 5358, 5894, 6484, 7132, 7845, 8630, 9493, 10442, 11487, 12635, 13899, 15289, 16818, 18500, 20350, 22385, 24623, 27086, 29794, 32767 }; MA_DR_WAV_ASSERT(pWav != NULL); MA_DR_WAV_ASSERT(framesToRead > 0); while (pWav->readCursorInPCMFrames < pWav->totalPCMFrameCount) { MA_DR_WAV_ASSERT(framesToRead > 0); if (pWav->ima.cachedFrameCount == 0 && pWav->ima.bytesRemainingInBlock == 0) { if (pWav->channels == 1) { ma_uint8 header[4]; if (pWav->onRead(pWav->pUserData, header, sizeof(header)) != sizeof(header)) { return totalFramesRead; } pWav->ima.bytesRemainingInBlock = pWav->fmt.blockAlign - sizeof(header); if (header[2] >= ma_dr_wav_countof(stepTable)) { pWav->onSeek(pWav->pUserData, pWav->ima.bytesRemainingInBlock, ma_dr_wav_seek_origin_current); pWav->ima.bytesRemainingInBlock = 0; return totalFramesRead; } pWav->ima.predictor[0] = (ma_int16)ma_dr_wav_bytes_to_u16(header + 0); pWav->ima.stepIndex[0] = ma_dr_wav_clamp(header[2], 0, (ma_int32)ma_dr_wav_countof(stepTable)-1); pWav->ima.cachedFrames[ma_dr_wav_countof(pWav->ima.cachedFrames) - 1] = pWav->ima.predictor[0]; pWav->ima.cachedFrameCount = 1; } else { ma_uint8 header[8]; if (pWav->onRead(pWav->pUserData, header, sizeof(header)) != sizeof(header)) { return totalFramesRead; } pWav->ima.bytesRemainingInBlock = pWav->fmt.blockAlign - sizeof(header); if (header[2] >= ma_dr_wav_countof(stepTable) || header[6] >= ma_dr_wav_countof(stepTable)) { pWav->onSeek(pWav->pUserData, pWav->ima.bytesRemainingInBlock, ma_dr_wav_seek_origin_current); pWav->ima.bytesRemainingInBlock = 0; return totalFramesRead; } pWav->ima.predictor[0] = ma_dr_wav_bytes_to_s16(header + 0); pWav->ima.stepIndex[0] = ma_dr_wav_clamp(header[2], 0, (ma_int32)ma_dr_wav_countof(stepTable)-1); pWav->ima.predictor[1] = ma_dr_wav_bytes_to_s16(header + 4); pWav->ima.stepIndex[1] = ma_dr_wav_clamp(header[6], 0, (ma_int32)ma_dr_wav_countof(stepTable)-1); pWav->ima.cachedFrames[ma_dr_wav_countof(pWav->ima.cachedFrames) - 2] = pWav->ima.predictor[0]; pWav->ima.cachedFrames[ma_dr_wav_countof(pWav->ima.cachedFrames) - 1] = pWav->ima.predictor[1]; pWav->ima.cachedFrameCount = 1; } } while (framesToRead > 0 && pWav->ima.cachedFrameCount > 0 && pWav->readCursorInPCMFrames < pWav->totalPCMFrameCount) { if (pBufferOut != NULL) { ma_uint32 iSample; for (iSample = 0; iSample < pWav->channels; iSample += 1) { pBufferOut[iSample] = (ma_int16)pWav->ima.cachedFrames[(ma_dr_wav_countof(pWav->ima.cachedFrames) - (pWav->ima.cachedFrameCount*pWav->channels)) + iSample]; } pBufferOut += pWav->channels; } framesToRead -= 1; totalFramesRead += 1; pWav->readCursorInPCMFrames += 1; pWav->ima.cachedFrameCount -= 1; } if (framesToRead == 0) { break; } if (pWav->ima.cachedFrameCount == 0) { if (pWav->ima.bytesRemainingInBlock == 0) { continue; } else { pWav->ima.cachedFrameCount = 8; for (iChannel = 0; iChannel < pWav->channels; ++iChannel) { ma_uint32 iByte; ma_uint8 nibbles[4]; if (pWav->onRead(pWav->pUserData, &nibbles, 4) != 4) { pWav->ima.cachedFrameCount = 0; return totalFramesRead; } pWav->ima.bytesRemainingInBlock -= 4; for (iByte = 0; iByte < 4; ++iByte) { ma_uint8 nibble0 = ((nibbles[iByte] & 0x0F) >> 0); ma_uint8 nibble1 = ((nibbles[iByte] & 0xF0) >> 4); ma_int32 step = stepTable[pWav->ima.stepIndex[iChannel]]; ma_int32 predictor = pWav->ima.predictor[iChannel]; ma_int32 diff = step >> 3; if (nibble0 & 1) diff += step >> 2; if (nibble0 & 2) diff += step >> 1; if (nibble0 & 4) diff += step; if (nibble0 & 8) diff = -diff; predictor = ma_dr_wav_clamp(predictor + diff, -32768, 32767); pWav->ima.predictor[iChannel] = predictor; pWav->ima.stepIndex[iChannel] = ma_dr_wav_clamp(pWav->ima.stepIndex[iChannel] + indexTable[nibble0], 0, (ma_int32)ma_dr_wav_countof(stepTable)-1); pWav->ima.cachedFrames[(ma_dr_wav_countof(pWav->ima.cachedFrames) - (pWav->ima.cachedFrameCount*pWav->channels)) + (iByte*2+0)*pWav->channels + iChannel] = predictor; step = stepTable[pWav->ima.stepIndex[iChannel]]; predictor = pWav->ima.predictor[iChannel]; diff = step >> 3; if (nibble1 & 1) diff += step >> 2; if (nibble1 & 2) diff += step >> 1; if (nibble1 & 4) diff += step; if (nibble1 & 8) diff = -diff; predictor = ma_dr_wav_clamp(predictor + diff, -32768, 32767); pWav->ima.predictor[iChannel] = predictor; pWav->ima.stepIndex[iChannel] = ma_dr_wav_clamp(pWav->ima.stepIndex[iChannel] + indexTable[nibble1], 0, (ma_int32)ma_dr_wav_countof(stepTable)-1); pWav->ima.cachedFrames[(ma_dr_wav_countof(pWav->ima.cachedFrames) - (pWav->ima.cachedFrameCount*pWav->channels)) + (iByte*2+1)*pWav->channels + iChannel] = predictor; } } } } } return totalFramesRead; } #ifndef MA_DR_WAV_NO_CONVERSION_API static unsigned short g_ma_dr_wavAlawTable[256] = { 0xEA80, 0xEB80, 0xE880, 0xE980, 0xEE80, 0xEF80, 0xEC80, 0xED80, 0xE280, 0xE380, 0xE080, 0xE180, 0xE680, 0xE780, 0xE480, 0xE580, 0xF540, 0xF5C0, 0xF440, 0xF4C0, 0xF740, 0xF7C0, 0xF640, 0xF6C0, 0xF140, 0xF1C0, 0xF040, 0xF0C0, 0xF340, 0xF3C0, 0xF240, 0xF2C0, 0xAA00, 0xAE00, 0xA200, 0xA600, 0xBA00, 0xBE00, 0xB200, 0xB600, 0x8A00, 0x8E00, 0x8200, 0x8600, 0x9A00, 0x9E00, 0x9200, 0x9600, 0xD500, 0xD700, 0xD100, 0xD300, 0xDD00, 0xDF00, 0xD900, 0xDB00, 0xC500, 0xC700, 0xC100, 0xC300, 0xCD00, 0xCF00, 0xC900, 0xCB00, 0xFEA8, 0xFEB8, 0xFE88, 0xFE98, 0xFEE8, 0xFEF8, 0xFEC8, 0xFED8, 0xFE28, 0xFE38, 0xFE08, 0xFE18, 0xFE68, 0xFE78, 0xFE48, 0xFE58, 0xFFA8, 0xFFB8, 0xFF88, 0xFF98, 0xFFE8, 0xFFF8, 0xFFC8, 0xFFD8, 0xFF28, 0xFF38, 0xFF08, 0xFF18, 0xFF68, 0xFF78, 0xFF48, 0xFF58, 0xFAA0, 0xFAE0, 0xFA20, 0xFA60, 0xFBA0, 0xFBE0, 0xFB20, 0xFB60, 0xF8A0, 0xF8E0, 0xF820, 0xF860, 0xF9A0, 0xF9E0, 0xF920, 0xF960, 0xFD50, 0xFD70, 0xFD10, 0xFD30, 0xFDD0, 0xFDF0, 0xFD90, 0xFDB0, 0xFC50, 0xFC70, 0xFC10, 0xFC30, 0xFCD0, 0xFCF0, 0xFC90, 0xFCB0, 0x1580, 0x1480, 0x1780, 0x1680, 0x1180, 0x1080, 0x1380, 0x1280, 0x1D80, 0x1C80, 0x1F80, 0x1E80, 0x1980, 0x1880, 0x1B80, 0x1A80, 0x0AC0, 0x0A40, 0x0BC0, 0x0B40, 0x08C0, 0x0840, 0x09C0, 0x0940, 0x0EC0, 0x0E40, 0x0FC0, 0x0F40, 0x0CC0, 0x0C40, 0x0DC0, 0x0D40, 0x5600, 0x5200, 0x5E00, 0x5A00, 0x4600, 0x4200, 0x4E00, 0x4A00, 0x7600, 0x7200, 0x7E00, 0x7A00, 0x6600, 0x6200, 0x6E00, 0x6A00, 0x2B00, 0x2900, 0x2F00, 0x2D00, 0x2300, 0x2100, 0x2700, 0x2500, 0x3B00, 0x3900, 0x3F00, 0x3D00, 0x3300, 0x3100, 0x3700, 0x3500, 0x0158, 0x0148, 0x0178, 0x0168, 0x0118, 0x0108, 0x0138, 0x0128, 0x01D8, 0x01C8, 0x01F8, 0x01E8, 0x0198, 0x0188, 0x01B8, 0x01A8, 0x0058, 0x0048, 0x0078, 0x0068, 0x0018, 0x0008, 0x0038, 0x0028, 0x00D8, 0x00C8, 0x00F8, 0x00E8, 0x0098, 0x0088, 0x00B8, 0x00A8, 0x0560, 0x0520, 0x05E0, 0x05A0, 0x0460, 0x0420, 0x04E0, 0x04A0, 0x0760, 0x0720, 0x07E0, 0x07A0, 0x0660, 0x0620, 0x06E0, 0x06A0, 0x02B0, 0x0290, 0x02F0, 0x02D0, 0x0230, 0x0210, 0x0270, 0x0250, 0x03B0, 0x0390, 0x03F0, 0x03D0, 0x0330, 0x0310, 0x0370, 0x0350 }; static unsigned short g_ma_dr_wavMulawTable[256] = { 0x8284, 0x8684, 0x8A84, 0x8E84, 0x9284, 0x9684, 0x9A84, 0x9E84, 0xA284, 0xA684, 0xAA84, 0xAE84, 0xB284, 0xB684, 0xBA84, 0xBE84, 0xC184, 0xC384, 0xC584, 0xC784, 0xC984, 0xCB84, 0xCD84, 0xCF84, 0xD184, 0xD384, 0xD584, 0xD784, 0xD984, 0xDB84, 0xDD84, 0xDF84, 0xE104, 0xE204, 0xE304, 0xE404, 0xE504, 0xE604, 0xE704, 0xE804, 0xE904, 0xEA04, 0xEB04, 0xEC04, 0xED04, 0xEE04, 0xEF04, 0xF004, 0xF0C4, 0xF144, 0xF1C4, 0xF244, 0xF2C4, 0xF344, 0xF3C4, 0xF444, 0xF4C4, 0xF544, 0xF5C4, 0xF644, 0xF6C4, 0xF744, 0xF7C4, 0xF844, 0xF8A4, 0xF8E4, 0xF924, 0xF964, 0xF9A4, 0xF9E4, 0xFA24, 0xFA64, 0xFAA4, 0xFAE4, 0xFB24, 0xFB64, 0xFBA4, 0xFBE4, 0xFC24, 0xFC64, 0xFC94, 0xFCB4, 0xFCD4, 0xFCF4, 0xFD14, 0xFD34, 0xFD54, 0xFD74, 0xFD94, 0xFDB4, 0xFDD4, 0xFDF4, 0xFE14, 0xFE34, 0xFE54, 0xFE74, 0xFE8C, 0xFE9C, 0xFEAC, 0xFEBC, 0xFECC, 0xFEDC, 0xFEEC, 0xFEFC, 0xFF0C, 0xFF1C, 0xFF2C, 0xFF3C, 0xFF4C, 0xFF5C, 0xFF6C, 0xFF7C, 0xFF88, 0xFF90, 0xFF98, 0xFFA0, 0xFFA8, 0xFFB0, 0xFFB8, 0xFFC0, 0xFFC8, 0xFFD0, 0xFFD8, 0xFFE0, 0xFFE8, 0xFFF0, 0xFFF8, 0x0000, 0x7D7C, 0x797C, 0x757C, 0x717C, 0x6D7C, 0x697C, 0x657C, 0x617C, 0x5D7C, 0x597C, 0x557C, 0x517C, 0x4D7C, 0x497C, 0x457C, 0x417C, 0x3E7C, 0x3C7C, 0x3A7C, 0x387C, 0x367C, 0x347C, 0x327C, 0x307C, 0x2E7C, 0x2C7C, 0x2A7C, 0x287C, 0x267C, 0x247C, 0x227C, 0x207C, 0x1EFC, 0x1DFC, 0x1CFC, 0x1BFC, 0x1AFC, 0x19FC, 0x18FC, 0x17FC, 0x16FC, 0x15FC, 0x14FC, 0x13FC, 0x12FC, 0x11FC, 0x10FC, 0x0FFC, 0x0F3C, 0x0EBC, 0x0E3C, 0x0DBC, 0x0D3C, 0x0CBC, 0x0C3C, 0x0BBC, 0x0B3C, 0x0ABC, 0x0A3C, 0x09BC, 0x093C, 0x08BC, 0x083C, 0x07BC, 0x075C, 0x071C, 0x06DC, 0x069C, 0x065C, 0x061C, 0x05DC, 0x059C, 0x055C, 0x051C, 0x04DC, 0x049C, 0x045C, 0x041C, 0x03DC, 0x039C, 0x036C, 0x034C, 0x032C, 0x030C, 0x02EC, 0x02CC, 0x02AC, 0x028C, 0x026C, 0x024C, 0x022C, 0x020C, 0x01EC, 0x01CC, 0x01AC, 0x018C, 0x0174, 0x0164, 0x0154, 0x0144, 0x0134, 0x0124, 0x0114, 0x0104, 0x00F4, 0x00E4, 0x00D4, 0x00C4, 0x00B4, 0x00A4, 0x0094, 0x0084, 0x0078, 0x0070, 0x0068, 0x0060, 0x0058, 0x0050, 0x0048, 0x0040, 0x0038, 0x0030, 0x0028, 0x0020, 0x0018, 0x0010, 0x0008, 0x0000 }; static MA_INLINE ma_int16 ma_dr_wav__alaw_to_s16(ma_uint8 sampleIn) { return (short)g_ma_dr_wavAlawTable[sampleIn]; } static MA_INLINE ma_int16 ma_dr_wav__mulaw_to_s16(ma_uint8 sampleIn) { return (short)g_ma_dr_wavMulawTable[sampleIn]; } MA_PRIVATE void ma_dr_wav__pcm_to_s16(ma_int16* pOut, const ma_uint8* pIn, size_t totalSampleCount, unsigned int bytesPerSample) { size_t i; if (bytesPerSample == 1) { ma_dr_wav_u8_to_s16(pOut, pIn, totalSampleCount); return; } if (bytesPerSample == 2) { for (i = 0; i < totalSampleCount; ++i) { *pOut++ = ((const ma_int16*)pIn)[i]; } return; } if (bytesPerSample == 3) { ma_dr_wav_s24_to_s16(pOut, pIn, totalSampleCount); return; } if (bytesPerSample == 4) { ma_dr_wav_s32_to_s16(pOut, (const ma_int32*)pIn, totalSampleCount); return; } if (bytesPerSample > 8) { MA_DR_WAV_ZERO_MEMORY(pOut, totalSampleCount * sizeof(*pOut)); return; } for (i = 0; i < totalSampleCount; ++i) { ma_uint64 sample = 0; unsigned int shift = (8 - bytesPerSample) * 8; unsigned int j; for (j = 0; j < bytesPerSample; j += 1) { MA_DR_WAV_ASSERT(j < 8); sample |= (ma_uint64)(pIn[j]) << shift; shift += 8; } pIn += j; *pOut++ = (ma_int16)((ma_int64)sample >> 48); } } MA_PRIVATE void ma_dr_wav__ieee_to_s16(ma_int16* pOut, const ma_uint8* pIn, size_t totalSampleCount, unsigned int bytesPerSample) { if (bytesPerSample == 4) { ma_dr_wav_f32_to_s16(pOut, (const float*)pIn, totalSampleCount); return; } else if (bytesPerSample == 8) { ma_dr_wav_f64_to_s16(pOut, (const double*)pIn, totalSampleCount); return; } else { MA_DR_WAV_ZERO_MEMORY(pOut, totalSampleCount * sizeof(*pOut)); return; } } MA_PRIVATE ma_uint64 ma_dr_wav_read_pcm_frames_s16__pcm(ma_dr_wav* pWav, ma_uint64 framesToRead, ma_int16* pBufferOut) { ma_uint64 totalFramesRead; ma_uint8 sampleData[4096] = {0}; ma_uint32 bytesPerFrame; ma_uint32 bytesPerSample; ma_uint64 samplesRead; if ((pWav->translatedFormatTag == MA_DR_WAVE_FORMAT_PCM && pWav->bitsPerSample == 16) || pBufferOut == NULL) { return ma_dr_wav_read_pcm_frames(pWav, framesToRead, pBufferOut); } bytesPerFrame = ma_dr_wav_get_bytes_per_pcm_frame(pWav); if (bytesPerFrame == 0) { return 0; } bytesPerSample = bytesPerFrame / pWav->channels; if (bytesPerSample == 0 || (bytesPerFrame % pWav->channels) != 0) { return 0; } totalFramesRead = 0; while (framesToRead > 0) { ma_uint64 framesToReadThisIteration = ma_dr_wav_min(framesToRead, sizeof(sampleData)/bytesPerFrame); ma_uint64 framesRead = ma_dr_wav_read_pcm_frames(pWav, framesToReadThisIteration, sampleData); if (framesRead == 0) { break; } MA_DR_WAV_ASSERT(framesRead <= framesToReadThisIteration); samplesRead = framesRead * pWav->channels; if ((samplesRead * bytesPerSample) > sizeof(sampleData)) { MA_DR_WAV_ASSERT(MA_FALSE); break; } ma_dr_wav__pcm_to_s16(pBufferOut, sampleData, (size_t)samplesRead, bytesPerSample); pBufferOut += samplesRead; framesToRead -= framesRead; totalFramesRead += framesRead; } return totalFramesRead; } MA_PRIVATE ma_uint64 ma_dr_wav_read_pcm_frames_s16__ieee(ma_dr_wav* pWav, ma_uint64 framesToRead, ma_int16* pBufferOut) { ma_uint64 totalFramesRead; ma_uint8 sampleData[4096] = {0}; ma_uint32 bytesPerFrame; ma_uint32 bytesPerSample; ma_uint64 samplesRead; if (pBufferOut == NULL) { return ma_dr_wav_read_pcm_frames(pWav, framesToRead, NULL); } bytesPerFrame = ma_dr_wav_get_bytes_per_pcm_frame(pWav); if (bytesPerFrame == 0) { return 0; } bytesPerSample = bytesPerFrame / pWav->channels; if (bytesPerSample == 0 || (bytesPerFrame % pWav->channels) != 0) { return 0; } totalFramesRead = 0; while (framesToRead > 0) { ma_uint64 framesToReadThisIteration = ma_dr_wav_min(framesToRead, sizeof(sampleData)/bytesPerFrame); ma_uint64 framesRead = ma_dr_wav_read_pcm_frames(pWav, framesToReadThisIteration, sampleData); if (framesRead == 0) { break; } MA_DR_WAV_ASSERT(framesRead <= framesToReadThisIteration); samplesRead = framesRead * pWav->channels; if ((samplesRead * bytesPerSample) > sizeof(sampleData)) { MA_DR_WAV_ASSERT(MA_FALSE); break; } ma_dr_wav__ieee_to_s16(pBufferOut, sampleData, (size_t)samplesRead, bytesPerSample); pBufferOut += samplesRead; framesToRead -= framesRead; totalFramesRead += framesRead; } return totalFramesRead; } MA_PRIVATE ma_uint64 ma_dr_wav_read_pcm_frames_s16__alaw(ma_dr_wav* pWav, ma_uint64 framesToRead, ma_int16* pBufferOut) { ma_uint64 totalFramesRead; ma_uint8 sampleData[4096] = {0}; ma_uint32 bytesPerFrame; ma_uint32 bytesPerSample; ma_uint64 samplesRead; if (pBufferOut == NULL) { return ma_dr_wav_read_pcm_frames(pWav, framesToRead, NULL); } bytesPerFrame = ma_dr_wav_get_bytes_per_pcm_frame(pWav); if (bytesPerFrame == 0) { return 0; } bytesPerSample = bytesPerFrame / pWav->channels; if (bytesPerSample == 0 || (bytesPerFrame % pWav->channels) != 0) { return 0; } totalFramesRead = 0; while (framesToRead > 0) { ma_uint64 framesToReadThisIteration = ma_dr_wav_min(framesToRead, sizeof(sampleData)/bytesPerFrame); ma_uint64 framesRead = ma_dr_wav_read_pcm_frames(pWav, framesToReadThisIteration, sampleData); if (framesRead == 0) { break; } MA_DR_WAV_ASSERT(framesRead <= framesToReadThisIteration); samplesRead = framesRead * pWav->channels; if ((samplesRead * bytesPerSample) > sizeof(sampleData)) { MA_DR_WAV_ASSERT(MA_FALSE); break; } ma_dr_wav_alaw_to_s16(pBufferOut, sampleData, (size_t)samplesRead); #ifdef MA_DR_WAV_LIBSNDFILE_COMPAT { if (pWav->container == ma_dr_wav_container_aiff) { ma_uint64 iSample; for (iSample = 0; iSample < samplesRead; iSample += 1) { pBufferOut[iSample] = -pBufferOut[iSample]; } } } #endif pBufferOut += samplesRead; framesToRead -= framesRead; totalFramesRead += framesRead; } return totalFramesRead; } MA_PRIVATE ma_uint64 ma_dr_wav_read_pcm_frames_s16__mulaw(ma_dr_wav* pWav, ma_uint64 framesToRead, ma_int16* pBufferOut) { ma_uint64 totalFramesRead; ma_uint8 sampleData[4096] = {0}; ma_uint32 bytesPerFrame; ma_uint32 bytesPerSample; ma_uint64 samplesRead; if (pBufferOut == NULL) { return ma_dr_wav_read_pcm_frames(pWav, framesToRead, NULL); } bytesPerFrame = ma_dr_wav_get_bytes_per_pcm_frame(pWav); if (bytesPerFrame == 0) { return 0; } bytesPerSample = bytesPerFrame / pWav->channels; if (bytesPerSample == 0 || (bytesPerFrame % pWav->channels) != 0) { return 0; } totalFramesRead = 0; while (framesToRead > 0) { ma_uint64 framesToReadThisIteration = ma_dr_wav_min(framesToRead, sizeof(sampleData)/bytesPerFrame); ma_uint64 framesRead = ma_dr_wav_read_pcm_frames(pWav, framesToReadThisIteration, sampleData); if (framesRead == 0) { break; } MA_DR_WAV_ASSERT(framesRead <= framesToReadThisIteration); samplesRead = framesRead * pWav->channels; if ((samplesRead * bytesPerSample) > sizeof(sampleData)) { MA_DR_WAV_ASSERT(MA_FALSE); break; } ma_dr_wav_mulaw_to_s16(pBufferOut, sampleData, (size_t)samplesRead); #ifdef MA_DR_WAV_LIBSNDFILE_COMPAT { if (pWav->container == ma_dr_wav_container_aiff) { ma_uint64 iSample; for (iSample = 0; iSample < samplesRead; iSample += 1) { pBufferOut[iSample] = -pBufferOut[iSample]; } } } #endif pBufferOut += samplesRead; framesToRead -= framesRead; totalFramesRead += framesRead; } return totalFramesRead; } MA_API ma_uint64 ma_dr_wav_read_pcm_frames_s16(ma_dr_wav* pWav, ma_uint64 framesToRead, ma_int16* pBufferOut) { if (pWav == NULL || framesToRead == 0) { return 0; } if (pBufferOut == NULL) { return ma_dr_wav_read_pcm_frames(pWav, framesToRead, NULL); } if (framesToRead * pWav->channels * sizeof(ma_int16) > MA_SIZE_MAX) { framesToRead = MA_SIZE_MAX / sizeof(ma_int16) / pWav->channels; } if (pWav->translatedFormatTag == MA_DR_WAVE_FORMAT_PCM) { return ma_dr_wav_read_pcm_frames_s16__pcm(pWav, framesToRead, pBufferOut); } if (pWav->translatedFormatTag == MA_DR_WAVE_FORMAT_IEEE_FLOAT) { return ma_dr_wav_read_pcm_frames_s16__ieee(pWav, framesToRead, pBufferOut); } if (pWav->translatedFormatTag == MA_DR_WAVE_FORMAT_ALAW) { return ma_dr_wav_read_pcm_frames_s16__alaw(pWav, framesToRead, pBufferOut); } if (pWav->translatedFormatTag == MA_DR_WAVE_FORMAT_MULAW) { return ma_dr_wav_read_pcm_frames_s16__mulaw(pWav, framesToRead, pBufferOut); } if (pWav->translatedFormatTag == MA_DR_WAVE_FORMAT_ADPCM) { return ma_dr_wav_read_pcm_frames_s16__msadpcm(pWav, framesToRead, pBufferOut); } if (pWav->translatedFormatTag == MA_DR_WAVE_FORMAT_DVI_ADPCM) { return ma_dr_wav_read_pcm_frames_s16__ima(pWav, framesToRead, pBufferOut); } return 0; } MA_API ma_uint64 ma_dr_wav_read_pcm_frames_s16le(ma_dr_wav* pWav, ma_uint64 framesToRead, ma_int16* pBufferOut) { ma_uint64 framesRead = ma_dr_wav_read_pcm_frames_s16(pWav, framesToRead, pBufferOut); if (pBufferOut != NULL && ma_dr_wav__is_little_endian() == MA_FALSE) { ma_dr_wav__bswap_samples_s16(pBufferOut, framesRead*pWav->channels); } return framesRead; } MA_API ma_uint64 ma_dr_wav_read_pcm_frames_s16be(ma_dr_wav* pWav, ma_uint64 framesToRead, ma_int16* pBufferOut) { ma_uint64 framesRead = ma_dr_wav_read_pcm_frames_s16(pWav, framesToRead, pBufferOut); if (pBufferOut != NULL && ma_dr_wav__is_little_endian() == MA_TRUE) { ma_dr_wav__bswap_samples_s16(pBufferOut, framesRead*pWav->channels); } return framesRead; } MA_API void ma_dr_wav_u8_to_s16(ma_int16* pOut, const ma_uint8* pIn, size_t sampleCount) { int r; size_t i; for (i = 0; i < sampleCount; ++i) { int x = pIn[i]; r = x << 8; r = r - 32768; pOut[i] = (short)r; } } MA_API void ma_dr_wav_s24_to_s16(ma_int16* pOut, const ma_uint8* pIn, size_t sampleCount) { int r; size_t i; for (i = 0; i < sampleCount; ++i) { int x = ((int)(((unsigned int)(((const ma_uint8*)pIn)[i*3+0]) << 8) | ((unsigned int)(((const ma_uint8*)pIn)[i*3+1]) << 16) | ((unsigned int)(((const ma_uint8*)pIn)[i*3+2])) << 24)) >> 8; r = x >> 8; pOut[i] = (short)r; } } MA_API void ma_dr_wav_s32_to_s16(ma_int16* pOut, const ma_int32* pIn, size_t sampleCount) { int r; size_t i; for (i = 0; i < sampleCount; ++i) { int x = pIn[i]; r = x >> 16; pOut[i] = (short)r; } } MA_API void ma_dr_wav_f32_to_s16(ma_int16* pOut, const float* pIn, size_t sampleCount) { int r; size_t i; for (i = 0; i < sampleCount; ++i) { float x = pIn[i]; float c; c = ((x < -1) ? -1 : ((x > 1) ? 1 : x)); c = c + 1; r = (int)(c * 32767.5f); r = r - 32768; pOut[i] = (short)r; } } MA_API void ma_dr_wav_f64_to_s16(ma_int16* pOut, const double* pIn, size_t sampleCount) { int r; size_t i; for (i = 0; i < sampleCount; ++i) { double x = pIn[i]; double c; c = ((x < -1) ? -1 : ((x > 1) ? 1 : x)); c = c + 1; r = (int)(c * 32767.5); r = r - 32768; pOut[i] = (short)r; } } MA_API void ma_dr_wav_alaw_to_s16(ma_int16* pOut, const ma_uint8* pIn, size_t sampleCount) { size_t i; for (i = 0; i < sampleCount; ++i) { pOut[i] = ma_dr_wav__alaw_to_s16(pIn[i]); } } MA_API void ma_dr_wav_mulaw_to_s16(ma_int16* pOut, const ma_uint8* pIn, size_t sampleCount) { size_t i; for (i = 0; i < sampleCount; ++i) { pOut[i] = ma_dr_wav__mulaw_to_s16(pIn[i]); } } MA_PRIVATE void ma_dr_wav__pcm_to_f32(float* pOut, const ma_uint8* pIn, size_t sampleCount, unsigned int bytesPerSample) { unsigned int i; if (bytesPerSample == 1) { ma_dr_wav_u8_to_f32(pOut, pIn, sampleCount); return; } if (bytesPerSample == 2) { ma_dr_wav_s16_to_f32(pOut, (const ma_int16*)pIn, sampleCount); return; } if (bytesPerSample == 3) { ma_dr_wav_s24_to_f32(pOut, pIn, sampleCount); return; } if (bytesPerSample == 4) { ma_dr_wav_s32_to_f32(pOut, (const ma_int32*)pIn, sampleCount); return; } if (bytesPerSample > 8) { MA_DR_WAV_ZERO_MEMORY(pOut, sampleCount * sizeof(*pOut)); return; } for (i = 0; i < sampleCount; ++i) { ma_uint64 sample = 0; unsigned int shift = (8 - bytesPerSample) * 8; unsigned int j; for (j = 0; j < bytesPerSample; j += 1) { MA_DR_WAV_ASSERT(j < 8); sample |= (ma_uint64)(pIn[j]) << shift; shift += 8; } pIn += j; *pOut++ = (float)((ma_int64)sample / 9223372036854775807.0); } } MA_PRIVATE void ma_dr_wav__ieee_to_f32(float* pOut, const ma_uint8* pIn, size_t sampleCount, unsigned int bytesPerSample) { if (bytesPerSample == 4) { unsigned int i; for (i = 0; i < sampleCount; ++i) { *pOut++ = ((const float*)pIn)[i]; } return; } else if (bytesPerSample == 8) { ma_dr_wav_f64_to_f32(pOut, (const double*)pIn, sampleCount); return; } else { MA_DR_WAV_ZERO_MEMORY(pOut, sampleCount * sizeof(*pOut)); return; } } MA_PRIVATE ma_uint64 ma_dr_wav_read_pcm_frames_f32__pcm(ma_dr_wav* pWav, ma_uint64 framesToRead, float* pBufferOut) { ma_uint64 totalFramesRead; ma_uint8 sampleData[4096] = {0}; ma_uint32 bytesPerFrame; ma_uint32 bytesPerSample; ma_uint64 samplesRead; bytesPerFrame = ma_dr_wav_get_bytes_per_pcm_frame(pWav); if (bytesPerFrame == 0) { return 0; } bytesPerSample = bytesPerFrame / pWav->channels; if (bytesPerSample == 0 || (bytesPerFrame % pWav->channels) != 0) { return 0; } totalFramesRead = 0; while (framesToRead > 0) { ma_uint64 framesToReadThisIteration = ma_dr_wav_min(framesToRead, sizeof(sampleData)/bytesPerFrame); ma_uint64 framesRead = ma_dr_wav_read_pcm_frames(pWav, framesToReadThisIteration, sampleData); if (framesRead == 0) { break; } MA_DR_WAV_ASSERT(framesRead <= framesToReadThisIteration); samplesRead = framesRead * pWav->channels; if ((samplesRead * bytesPerSample) > sizeof(sampleData)) { MA_DR_WAV_ASSERT(MA_FALSE); break; } ma_dr_wav__pcm_to_f32(pBufferOut, sampleData, (size_t)samplesRead, bytesPerSample); pBufferOut += samplesRead; framesToRead -= framesRead; totalFramesRead += framesRead; } return totalFramesRead; } MA_PRIVATE ma_uint64 ma_dr_wav_read_pcm_frames_f32__msadpcm_ima(ma_dr_wav* pWav, ma_uint64 framesToRead, float* pBufferOut) { ma_uint64 totalFramesRead; ma_int16 samples16[2048]; totalFramesRead = 0; while (framesToRead > 0) { ma_uint64 framesToReadThisIteration = ma_dr_wav_min(framesToRead, ma_dr_wav_countof(samples16)/pWav->channels); ma_uint64 framesRead = ma_dr_wav_read_pcm_frames_s16(pWav, framesToReadThisIteration, samples16); if (framesRead == 0) { break; } MA_DR_WAV_ASSERT(framesRead <= framesToReadThisIteration); ma_dr_wav_s16_to_f32(pBufferOut, samples16, (size_t)(framesRead*pWav->channels)); pBufferOut += framesRead*pWav->channels; framesToRead -= framesRead; totalFramesRead += framesRead; } return totalFramesRead; } MA_PRIVATE ma_uint64 ma_dr_wav_read_pcm_frames_f32__ieee(ma_dr_wav* pWav, ma_uint64 framesToRead, float* pBufferOut) { ma_uint64 totalFramesRead; ma_uint8 sampleData[4096] = {0}; ma_uint32 bytesPerFrame; ma_uint32 bytesPerSample; ma_uint64 samplesRead; if (pWav->translatedFormatTag == MA_DR_WAVE_FORMAT_IEEE_FLOAT && pWav->bitsPerSample == 32) { return ma_dr_wav_read_pcm_frames(pWav, framesToRead, pBufferOut); } bytesPerFrame = ma_dr_wav_get_bytes_per_pcm_frame(pWav); if (bytesPerFrame == 0) { return 0; } bytesPerSample = bytesPerFrame / pWav->channels; if (bytesPerSample == 0 || (bytesPerFrame % pWav->channels) != 0) { return 0; } totalFramesRead = 0; while (framesToRead > 0) { ma_uint64 framesToReadThisIteration = ma_dr_wav_min(framesToRead, sizeof(sampleData)/bytesPerFrame); ma_uint64 framesRead = ma_dr_wav_read_pcm_frames(pWav, framesToReadThisIteration, sampleData); if (framesRead == 0) { break; } MA_DR_WAV_ASSERT(framesRead <= framesToReadThisIteration); samplesRead = framesRead * pWav->channels; if ((samplesRead * bytesPerSample) > sizeof(sampleData)) { MA_DR_WAV_ASSERT(MA_FALSE); break; } ma_dr_wav__ieee_to_f32(pBufferOut, sampleData, (size_t)samplesRead, bytesPerSample); pBufferOut += samplesRead; framesToRead -= framesRead; totalFramesRead += framesRead; } return totalFramesRead; } MA_PRIVATE ma_uint64 ma_dr_wav_read_pcm_frames_f32__alaw(ma_dr_wav* pWav, ma_uint64 framesToRead, float* pBufferOut) { ma_uint64 totalFramesRead; ma_uint8 sampleData[4096] = {0}; ma_uint32 bytesPerFrame; ma_uint32 bytesPerSample; ma_uint64 samplesRead; bytesPerFrame = ma_dr_wav_get_bytes_per_pcm_frame(pWav); if (bytesPerFrame == 0) { return 0; } bytesPerSample = bytesPerFrame / pWav->channels; if (bytesPerSample == 0 || (bytesPerFrame % pWav->channels) != 0) { return 0; } totalFramesRead = 0; while (framesToRead > 0) { ma_uint64 framesToReadThisIteration = ma_dr_wav_min(framesToRead, sizeof(sampleData)/bytesPerFrame); ma_uint64 framesRead = ma_dr_wav_read_pcm_frames(pWav, framesToReadThisIteration, sampleData); if (framesRead == 0) { break; } MA_DR_WAV_ASSERT(framesRead <= framesToReadThisIteration); samplesRead = framesRead * pWav->channels; if ((samplesRead * bytesPerSample) > sizeof(sampleData)) { MA_DR_WAV_ASSERT(MA_FALSE); break; } ma_dr_wav_alaw_to_f32(pBufferOut, sampleData, (size_t)samplesRead); #ifdef MA_DR_WAV_LIBSNDFILE_COMPAT { if (pWav->container == ma_dr_wav_container_aiff) { ma_uint64 iSample; for (iSample = 0; iSample < samplesRead; iSample += 1) { pBufferOut[iSample] = -pBufferOut[iSample]; } } } #endif pBufferOut += samplesRead; framesToRead -= framesRead; totalFramesRead += framesRead; } return totalFramesRead; } MA_PRIVATE ma_uint64 ma_dr_wav_read_pcm_frames_f32__mulaw(ma_dr_wav* pWav, ma_uint64 framesToRead, float* pBufferOut) { ma_uint64 totalFramesRead; ma_uint8 sampleData[4096] = {0}; ma_uint32 bytesPerFrame; ma_uint32 bytesPerSample; ma_uint64 samplesRead; bytesPerFrame = ma_dr_wav_get_bytes_per_pcm_frame(pWav); if (bytesPerFrame == 0) { return 0; } bytesPerSample = bytesPerFrame / pWav->channels; if (bytesPerSample == 0 || (bytesPerFrame % pWav->channels) != 0) { return 0; } totalFramesRead = 0; while (framesToRead > 0) { ma_uint64 framesToReadThisIteration = ma_dr_wav_min(framesToRead, sizeof(sampleData)/bytesPerFrame); ma_uint64 framesRead = ma_dr_wav_read_pcm_frames(pWav, framesToReadThisIteration, sampleData); if (framesRead == 0) { break; } MA_DR_WAV_ASSERT(framesRead <= framesToReadThisIteration); samplesRead = framesRead * pWav->channels; if ((samplesRead * bytesPerSample) > sizeof(sampleData)) { MA_DR_WAV_ASSERT(MA_FALSE); break; } ma_dr_wav_mulaw_to_f32(pBufferOut, sampleData, (size_t)samplesRead); #ifdef MA_DR_WAV_LIBSNDFILE_COMPAT { if (pWav->container == ma_dr_wav_container_aiff) { ma_uint64 iSample; for (iSample = 0; iSample < samplesRead; iSample += 1) { pBufferOut[iSample] = -pBufferOut[iSample]; } } } #endif pBufferOut += samplesRead; framesToRead -= framesRead; totalFramesRead += framesRead; } return totalFramesRead; } MA_API ma_uint64 ma_dr_wav_read_pcm_frames_f32(ma_dr_wav* pWav, ma_uint64 framesToRead, float* pBufferOut) { if (pWav == NULL || framesToRead == 0) { return 0; } if (pBufferOut == NULL) { return ma_dr_wav_read_pcm_frames(pWav, framesToRead, NULL); } if (framesToRead * pWav->channels * sizeof(float) > MA_SIZE_MAX) { framesToRead = MA_SIZE_MAX / sizeof(float) / pWav->channels; } if (pWav->translatedFormatTag == MA_DR_WAVE_FORMAT_PCM) { return ma_dr_wav_read_pcm_frames_f32__pcm(pWav, framesToRead, pBufferOut); } if (pWav->translatedFormatTag == MA_DR_WAVE_FORMAT_ADPCM || pWav->translatedFormatTag == MA_DR_WAVE_FORMAT_DVI_ADPCM) { return ma_dr_wav_read_pcm_frames_f32__msadpcm_ima(pWav, framesToRead, pBufferOut); } if (pWav->translatedFormatTag == MA_DR_WAVE_FORMAT_IEEE_FLOAT) { return ma_dr_wav_read_pcm_frames_f32__ieee(pWav, framesToRead, pBufferOut); } if (pWav->translatedFormatTag == MA_DR_WAVE_FORMAT_ALAW) { return ma_dr_wav_read_pcm_frames_f32__alaw(pWav, framesToRead, pBufferOut); } if (pWav->translatedFormatTag == MA_DR_WAVE_FORMAT_MULAW) { return ma_dr_wav_read_pcm_frames_f32__mulaw(pWav, framesToRead, pBufferOut); } return 0; } MA_API ma_uint64 ma_dr_wav_read_pcm_frames_f32le(ma_dr_wav* pWav, ma_uint64 framesToRead, float* pBufferOut) { ma_uint64 framesRead = ma_dr_wav_read_pcm_frames_f32(pWav, framesToRead, pBufferOut); if (pBufferOut != NULL && ma_dr_wav__is_little_endian() == MA_FALSE) { ma_dr_wav__bswap_samples_f32(pBufferOut, framesRead*pWav->channels); } return framesRead; } MA_API ma_uint64 ma_dr_wav_read_pcm_frames_f32be(ma_dr_wav* pWav, ma_uint64 framesToRead, float* pBufferOut) { ma_uint64 framesRead = ma_dr_wav_read_pcm_frames_f32(pWav, framesToRead, pBufferOut); if (pBufferOut != NULL && ma_dr_wav__is_little_endian() == MA_TRUE) { ma_dr_wav__bswap_samples_f32(pBufferOut, framesRead*pWav->channels); } return framesRead; } MA_API void ma_dr_wav_u8_to_f32(float* pOut, const ma_uint8* pIn, size_t sampleCount) { size_t i; if (pOut == NULL || pIn == NULL) { return; } #ifdef MA_DR_WAV_LIBSNDFILE_COMPAT for (i = 0; i < sampleCount; ++i) { *pOut++ = (pIn[i] / 256.0f) * 2 - 1; } #else for (i = 0; i < sampleCount; ++i) { float x = pIn[i]; x = x * 0.00784313725490196078f; x = x - 1; *pOut++ = x; } #endif } MA_API void ma_dr_wav_s16_to_f32(float* pOut, const ma_int16* pIn, size_t sampleCount) { size_t i; if (pOut == NULL || pIn == NULL) { return; } for (i = 0; i < sampleCount; ++i) { *pOut++ = pIn[i] * 0.000030517578125f; } } MA_API void ma_dr_wav_s24_to_f32(float* pOut, const ma_uint8* pIn, size_t sampleCount) { size_t i; if (pOut == NULL || pIn == NULL) { return; } for (i = 0; i < sampleCount; ++i) { double x; ma_uint32 a = ((ma_uint32)(pIn[i*3+0]) << 8); ma_uint32 b = ((ma_uint32)(pIn[i*3+1]) << 16); ma_uint32 c = ((ma_uint32)(pIn[i*3+2]) << 24); x = (double)((ma_int32)(a | b | c) >> 8); *pOut++ = (float)(x * 0.00000011920928955078125); } } MA_API void ma_dr_wav_s32_to_f32(float* pOut, const ma_int32* pIn, size_t sampleCount) { size_t i; if (pOut == NULL || pIn == NULL) { return; } for (i = 0; i < sampleCount; ++i) { *pOut++ = (float)(pIn[i] / 2147483648.0); } } MA_API void ma_dr_wav_f64_to_f32(float* pOut, const double* pIn, size_t sampleCount) { size_t i; if (pOut == NULL || pIn == NULL) { return; } for (i = 0; i < sampleCount; ++i) { *pOut++ = (float)pIn[i]; } } MA_API void ma_dr_wav_alaw_to_f32(float* pOut, const ma_uint8* pIn, size_t sampleCount) { size_t i; if (pOut == NULL || pIn == NULL) { return; } for (i = 0; i < sampleCount; ++i) { *pOut++ = ma_dr_wav__alaw_to_s16(pIn[i]) / 32768.0f; } } MA_API void ma_dr_wav_mulaw_to_f32(float* pOut, const ma_uint8* pIn, size_t sampleCount) { size_t i; if (pOut == NULL || pIn == NULL) { return; } for (i = 0; i < sampleCount; ++i) { *pOut++ = ma_dr_wav__mulaw_to_s16(pIn[i]) / 32768.0f; } } MA_PRIVATE void ma_dr_wav__pcm_to_s32(ma_int32* pOut, const ma_uint8* pIn, size_t totalSampleCount, unsigned int bytesPerSample) { unsigned int i; if (bytesPerSample == 1) { ma_dr_wav_u8_to_s32(pOut, pIn, totalSampleCount); return; } if (bytesPerSample == 2) { ma_dr_wav_s16_to_s32(pOut, (const ma_int16*)pIn, totalSampleCount); return; } if (bytesPerSample == 3) { ma_dr_wav_s24_to_s32(pOut, pIn, totalSampleCount); return; } if (bytesPerSample == 4) { for (i = 0; i < totalSampleCount; ++i) { *pOut++ = ((const ma_int32*)pIn)[i]; } return; } if (bytesPerSample > 8) { MA_DR_WAV_ZERO_MEMORY(pOut, totalSampleCount * sizeof(*pOut)); return; } for (i = 0; i < totalSampleCount; ++i) { ma_uint64 sample = 0; unsigned int shift = (8 - bytesPerSample) * 8; unsigned int j; for (j = 0; j < bytesPerSample; j += 1) { MA_DR_WAV_ASSERT(j < 8); sample |= (ma_uint64)(pIn[j]) << shift; shift += 8; } pIn += j; *pOut++ = (ma_int32)((ma_int64)sample >> 32); } } MA_PRIVATE void ma_dr_wav__ieee_to_s32(ma_int32* pOut, const ma_uint8* pIn, size_t totalSampleCount, unsigned int bytesPerSample) { if (bytesPerSample == 4) { ma_dr_wav_f32_to_s32(pOut, (const float*)pIn, totalSampleCount); return; } else if (bytesPerSample == 8) { ma_dr_wav_f64_to_s32(pOut, (const double*)pIn, totalSampleCount); return; } else { MA_DR_WAV_ZERO_MEMORY(pOut, totalSampleCount * sizeof(*pOut)); return; } } MA_PRIVATE ma_uint64 ma_dr_wav_read_pcm_frames_s32__pcm(ma_dr_wav* pWav, ma_uint64 framesToRead, ma_int32* pBufferOut) { ma_uint64 totalFramesRead; ma_uint8 sampleData[4096] = {0}; ma_uint32 bytesPerFrame; ma_uint32 bytesPerSample; ma_uint64 samplesRead; if (pWav->translatedFormatTag == MA_DR_WAVE_FORMAT_PCM && pWav->bitsPerSample == 32) { return ma_dr_wav_read_pcm_frames(pWav, framesToRead, pBufferOut); } bytesPerFrame = ma_dr_wav_get_bytes_per_pcm_frame(pWav); if (bytesPerFrame == 0) { return 0; } bytesPerSample = bytesPerFrame / pWav->channels; if (bytesPerSample == 0 || (bytesPerFrame % pWav->channels) != 0) { return 0; } totalFramesRead = 0; while (framesToRead > 0) { ma_uint64 framesToReadThisIteration = ma_dr_wav_min(framesToRead, sizeof(sampleData)/bytesPerFrame); ma_uint64 framesRead = ma_dr_wav_read_pcm_frames(pWav, framesToReadThisIteration, sampleData); if (framesRead == 0) { break; } MA_DR_WAV_ASSERT(framesRead <= framesToReadThisIteration); samplesRead = framesRead * pWav->channels; if ((samplesRead * bytesPerSample) > sizeof(sampleData)) { MA_DR_WAV_ASSERT(MA_FALSE); break; } ma_dr_wav__pcm_to_s32(pBufferOut, sampleData, (size_t)samplesRead, bytesPerSample); pBufferOut += samplesRead; framesToRead -= framesRead; totalFramesRead += framesRead; } return totalFramesRead; } MA_PRIVATE ma_uint64 ma_dr_wav_read_pcm_frames_s32__msadpcm_ima(ma_dr_wav* pWav, ma_uint64 framesToRead, ma_int32* pBufferOut) { ma_uint64 totalFramesRead = 0; ma_int16 samples16[2048]; while (framesToRead > 0) { ma_uint64 framesToReadThisIteration = ma_dr_wav_min(framesToRead, ma_dr_wav_countof(samples16)/pWav->channels); ma_uint64 framesRead = ma_dr_wav_read_pcm_frames_s16(pWav, framesToReadThisIteration, samples16); if (framesRead == 0) { break; } MA_DR_WAV_ASSERT(framesRead <= framesToReadThisIteration); ma_dr_wav_s16_to_s32(pBufferOut, samples16, (size_t)(framesRead*pWav->channels)); pBufferOut += framesRead*pWav->channels; framesToRead -= framesRead; totalFramesRead += framesRead; } return totalFramesRead; } MA_PRIVATE ma_uint64 ma_dr_wav_read_pcm_frames_s32__ieee(ma_dr_wav* pWav, ma_uint64 framesToRead, ma_int32* pBufferOut) { ma_uint64 totalFramesRead; ma_uint8 sampleData[4096] = {0}; ma_uint32 bytesPerFrame; ma_uint32 bytesPerSample; ma_uint64 samplesRead; bytesPerFrame = ma_dr_wav_get_bytes_per_pcm_frame(pWav); if (bytesPerFrame == 0) { return 0; } bytesPerSample = bytesPerFrame / pWav->channels; if (bytesPerSample == 0 || (bytesPerFrame % pWav->channels) != 0) { return 0; } totalFramesRead = 0; while (framesToRead > 0) { ma_uint64 framesToReadThisIteration = ma_dr_wav_min(framesToRead, sizeof(sampleData)/bytesPerFrame); ma_uint64 framesRead = ma_dr_wav_read_pcm_frames(pWav, framesToReadThisIteration, sampleData); if (framesRead == 0) { break; } MA_DR_WAV_ASSERT(framesRead <= framesToReadThisIteration); samplesRead = framesRead * pWav->channels; if ((samplesRead * bytesPerSample) > sizeof(sampleData)) { MA_DR_WAV_ASSERT(MA_FALSE); break; } ma_dr_wav__ieee_to_s32(pBufferOut, sampleData, (size_t)samplesRead, bytesPerSample); pBufferOut += samplesRead; framesToRead -= framesRead; totalFramesRead += framesRead; } return totalFramesRead; } MA_PRIVATE ma_uint64 ma_dr_wav_read_pcm_frames_s32__alaw(ma_dr_wav* pWav, ma_uint64 framesToRead, ma_int32* pBufferOut) { ma_uint64 totalFramesRead; ma_uint8 sampleData[4096] = {0}; ma_uint32 bytesPerFrame; ma_uint32 bytesPerSample; ma_uint64 samplesRead; bytesPerFrame = ma_dr_wav_get_bytes_per_pcm_frame(pWav); if (bytesPerFrame == 0) { return 0; } bytesPerSample = bytesPerFrame / pWav->channels; if (bytesPerSample == 0 || (bytesPerFrame % pWav->channels) != 0) { return 0; } totalFramesRead = 0; while (framesToRead > 0) { ma_uint64 framesToReadThisIteration = ma_dr_wav_min(framesToRead, sizeof(sampleData)/bytesPerFrame); ma_uint64 framesRead = ma_dr_wav_read_pcm_frames(pWav, framesToReadThisIteration, sampleData); if (framesRead == 0) { break; } MA_DR_WAV_ASSERT(framesRead <= framesToReadThisIteration); samplesRead = framesRead * pWav->channels; if ((samplesRead * bytesPerSample) > sizeof(sampleData)) { MA_DR_WAV_ASSERT(MA_FALSE); break; } ma_dr_wav_alaw_to_s32(pBufferOut, sampleData, (size_t)samplesRead); #ifdef MA_DR_WAV_LIBSNDFILE_COMPAT { if (pWav->container == ma_dr_wav_container_aiff) { ma_uint64 iSample; for (iSample = 0; iSample < samplesRead; iSample += 1) { pBufferOut[iSample] = -pBufferOut[iSample]; } } } #endif pBufferOut += samplesRead; framesToRead -= framesRead; totalFramesRead += framesRead; } return totalFramesRead; } MA_PRIVATE ma_uint64 ma_dr_wav_read_pcm_frames_s32__mulaw(ma_dr_wav* pWav, ma_uint64 framesToRead, ma_int32* pBufferOut) { ma_uint64 totalFramesRead; ma_uint8 sampleData[4096] = {0}; ma_uint32 bytesPerFrame; ma_uint32 bytesPerSample; ma_uint64 samplesRead; bytesPerFrame = ma_dr_wav_get_bytes_per_pcm_frame(pWav); if (bytesPerFrame == 0) { return 0; } bytesPerSample = bytesPerFrame / pWav->channels; if (bytesPerSample == 0 || (bytesPerFrame % pWav->channels) != 0) { return 0; } totalFramesRead = 0; while (framesToRead > 0) { ma_uint64 framesToReadThisIteration = ma_dr_wav_min(framesToRead, sizeof(sampleData)/bytesPerFrame); ma_uint64 framesRead = ma_dr_wav_read_pcm_frames(pWav, framesToReadThisIteration, sampleData); if (framesRead == 0) { break; } MA_DR_WAV_ASSERT(framesRead <= framesToReadThisIteration); samplesRead = framesRead * pWav->channels; if ((samplesRead * bytesPerSample) > sizeof(sampleData)) { MA_DR_WAV_ASSERT(MA_FALSE); break; } ma_dr_wav_mulaw_to_s32(pBufferOut, sampleData, (size_t)samplesRead); #ifdef MA_DR_WAV_LIBSNDFILE_COMPAT { if (pWav->container == ma_dr_wav_container_aiff) { ma_uint64 iSample; for (iSample = 0; iSample < samplesRead; iSample += 1) { pBufferOut[iSample] = -pBufferOut[iSample]; } } } #endif pBufferOut += samplesRead; framesToRead -= framesRead; totalFramesRead += framesRead; } return totalFramesRead; } MA_API ma_uint64 ma_dr_wav_read_pcm_frames_s32(ma_dr_wav* pWav, ma_uint64 framesToRead, ma_int32* pBufferOut) { if (pWav == NULL || framesToRead == 0) { return 0; } if (pBufferOut == NULL) { return ma_dr_wav_read_pcm_frames(pWav, framesToRead, NULL); } if (framesToRead * pWav->channels * sizeof(ma_int32) > MA_SIZE_MAX) { framesToRead = MA_SIZE_MAX / sizeof(ma_int32) / pWav->channels; } if (pWav->translatedFormatTag == MA_DR_WAVE_FORMAT_PCM) { return ma_dr_wav_read_pcm_frames_s32__pcm(pWav, framesToRead, pBufferOut); } if (pWav->translatedFormatTag == MA_DR_WAVE_FORMAT_ADPCM || pWav->translatedFormatTag == MA_DR_WAVE_FORMAT_DVI_ADPCM) { return ma_dr_wav_read_pcm_frames_s32__msadpcm_ima(pWav, framesToRead, pBufferOut); } if (pWav->translatedFormatTag == MA_DR_WAVE_FORMAT_IEEE_FLOAT) { return ma_dr_wav_read_pcm_frames_s32__ieee(pWav, framesToRead, pBufferOut); } if (pWav->translatedFormatTag == MA_DR_WAVE_FORMAT_ALAW) { return ma_dr_wav_read_pcm_frames_s32__alaw(pWav, framesToRead, pBufferOut); } if (pWav->translatedFormatTag == MA_DR_WAVE_FORMAT_MULAW) { return ma_dr_wav_read_pcm_frames_s32__mulaw(pWav, framesToRead, pBufferOut); } return 0; } MA_API ma_uint64 ma_dr_wav_read_pcm_frames_s32le(ma_dr_wav* pWav, ma_uint64 framesToRead, ma_int32* pBufferOut) { ma_uint64 framesRead = ma_dr_wav_read_pcm_frames_s32(pWav, framesToRead, pBufferOut); if (pBufferOut != NULL && ma_dr_wav__is_little_endian() == MA_FALSE) { ma_dr_wav__bswap_samples_s32(pBufferOut, framesRead*pWav->channels); } return framesRead; } MA_API ma_uint64 ma_dr_wav_read_pcm_frames_s32be(ma_dr_wav* pWav, ma_uint64 framesToRead, ma_int32* pBufferOut) { ma_uint64 framesRead = ma_dr_wav_read_pcm_frames_s32(pWav, framesToRead, pBufferOut); if (pBufferOut != NULL && ma_dr_wav__is_little_endian() == MA_TRUE) { ma_dr_wav__bswap_samples_s32(pBufferOut, framesRead*pWav->channels); } return framesRead; } MA_API void ma_dr_wav_u8_to_s32(ma_int32* pOut, const ma_uint8* pIn, size_t sampleCount) { size_t i; if (pOut == NULL || pIn == NULL) { return; } for (i = 0; i < sampleCount; ++i) { *pOut++ = ((int)pIn[i] - 128) << 24; } } MA_API void ma_dr_wav_s16_to_s32(ma_int32* pOut, const ma_int16* pIn, size_t sampleCount) { size_t i; if (pOut == NULL || pIn == NULL) { return; } for (i = 0; i < sampleCount; ++i) { *pOut++ = pIn[i] << 16; } } MA_API void ma_dr_wav_s24_to_s32(ma_int32* pOut, const ma_uint8* pIn, size_t sampleCount) { size_t i; if (pOut == NULL || pIn == NULL) { return; } for (i = 0; i < sampleCount; ++i) { unsigned int s0 = pIn[i*3 + 0]; unsigned int s1 = pIn[i*3 + 1]; unsigned int s2 = pIn[i*3 + 2]; ma_int32 sample32 = (ma_int32)((s0 << 8) | (s1 << 16) | (s2 << 24)); *pOut++ = sample32; } } MA_API void ma_dr_wav_f32_to_s32(ma_int32* pOut, const float* pIn, size_t sampleCount) { size_t i; if (pOut == NULL || pIn == NULL) { return; } for (i = 0; i < sampleCount; ++i) { *pOut++ = (ma_int32)(2147483648.0 * pIn[i]); } } MA_API void ma_dr_wav_f64_to_s32(ma_int32* pOut, const double* pIn, size_t sampleCount) { size_t i; if (pOut == NULL || pIn == NULL) { return; } for (i = 0; i < sampleCount; ++i) { *pOut++ = (ma_int32)(2147483648.0 * pIn[i]); } } MA_API void ma_dr_wav_alaw_to_s32(ma_int32* pOut, const ma_uint8* pIn, size_t sampleCount) { size_t i; if (pOut == NULL || pIn == NULL) { return; } for (i = 0; i < sampleCount; ++i) { *pOut++ = ((ma_int32)ma_dr_wav__alaw_to_s16(pIn[i])) << 16; } } MA_API void ma_dr_wav_mulaw_to_s32(ma_int32* pOut, const ma_uint8* pIn, size_t sampleCount) { size_t i; if (pOut == NULL || pIn == NULL) { return; } for (i= 0; i < sampleCount; ++i) { *pOut++ = ((ma_int32)ma_dr_wav__mulaw_to_s16(pIn[i])) << 16; } } MA_PRIVATE ma_int16* ma_dr_wav__read_pcm_frames_and_close_s16(ma_dr_wav* pWav, unsigned int* channels, unsigned int* sampleRate, ma_uint64* totalFrameCount) { ma_uint64 sampleDataSize; ma_int16* pSampleData; ma_uint64 framesRead; MA_DR_WAV_ASSERT(pWav != NULL); sampleDataSize = pWav->totalPCMFrameCount * pWav->channels * sizeof(ma_int16); if (sampleDataSize > MA_SIZE_MAX) { ma_dr_wav_uninit(pWav); return NULL; } pSampleData = (ma_int16*)ma_dr_wav__malloc_from_callbacks((size_t)sampleDataSize, &pWav->allocationCallbacks); if (pSampleData == NULL) { ma_dr_wav_uninit(pWav); return NULL; } framesRead = ma_dr_wav_read_pcm_frames_s16(pWav, (size_t)pWav->totalPCMFrameCount, pSampleData); if (framesRead != pWav->totalPCMFrameCount) { ma_dr_wav__free_from_callbacks(pSampleData, &pWav->allocationCallbacks); ma_dr_wav_uninit(pWav); return NULL; } ma_dr_wav_uninit(pWav); if (sampleRate) { *sampleRate = pWav->sampleRate; } if (channels) { *channels = pWav->channels; } if (totalFrameCount) { *totalFrameCount = pWav->totalPCMFrameCount; } return pSampleData; } MA_PRIVATE float* ma_dr_wav__read_pcm_frames_and_close_f32(ma_dr_wav* pWav, unsigned int* channels, unsigned int* sampleRate, ma_uint64* totalFrameCount) { ma_uint64 sampleDataSize; float* pSampleData; ma_uint64 framesRead; MA_DR_WAV_ASSERT(pWav != NULL); sampleDataSize = pWav->totalPCMFrameCount * pWav->channels * sizeof(float); if (sampleDataSize > MA_SIZE_MAX) { ma_dr_wav_uninit(pWav); return NULL; } pSampleData = (float*)ma_dr_wav__malloc_from_callbacks((size_t)sampleDataSize, &pWav->allocationCallbacks); if (pSampleData == NULL) { ma_dr_wav_uninit(pWav); return NULL; } framesRead = ma_dr_wav_read_pcm_frames_f32(pWav, (size_t)pWav->totalPCMFrameCount, pSampleData); if (framesRead != pWav->totalPCMFrameCount) { ma_dr_wav__free_from_callbacks(pSampleData, &pWav->allocationCallbacks); ma_dr_wav_uninit(pWav); return NULL; } ma_dr_wav_uninit(pWav); if (sampleRate) { *sampleRate = pWav->sampleRate; } if (channels) { *channels = pWav->channels; } if (totalFrameCount) { *totalFrameCount = pWav->totalPCMFrameCount; } return pSampleData; } MA_PRIVATE ma_int32* ma_dr_wav__read_pcm_frames_and_close_s32(ma_dr_wav* pWav, unsigned int* channels, unsigned int* sampleRate, ma_uint64* totalFrameCount) { ma_uint64 sampleDataSize; ma_int32* pSampleData; ma_uint64 framesRead; MA_DR_WAV_ASSERT(pWav != NULL); sampleDataSize = pWav->totalPCMFrameCount * pWav->channels * sizeof(ma_int32); if (sampleDataSize > MA_SIZE_MAX) { ma_dr_wav_uninit(pWav); return NULL; } pSampleData = (ma_int32*)ma_dr_wav__malloc_from_callbacks((size_t)sampleDataSize, &pWav->allocationCallbacks); if (pSampleData == NULL) { ma_dr_wav_uninit(pWav); return NULL; } framesRead = ma_dr_wav_read_pcm_frames_s32(pWav, (size_t)pWav->totalPCMFrameCount, pSampleData); if (framesRead != pWav->totalPCMFrameCount) { ma_dr_wav__free_from_callbacks(pSampleData, &pWav->allocationCallbacks); ma_dr_wav_uninit(pWav); return NULL; } ma_dr_wav_uninit(pWav); if (sampleRate) { *sampleRate = pWav->sampleRate; } if (channels) { *channels = pWav->channels; } if (totalFrameCount) { *totalFrameCount = pWav->totalPCMFrameCount; } return pSampleData; } MA_API ma_int16* ma_dr_wav_open_and_read_pcm_frames_s16(ma_dr_wav_read_proc onRead, ma_dr_wav_seek_proc onSeek, void* pUserData, unsigned int* channelsOut, unsigned int* sampleRateOut, ma_uint64* totalFrameCountOut, const ma_allocation_callbacks* pAllocationCallbacks) { ma_dr_wav wav; if (channelsOut) { *channelsOut = 0; } if (sampleRateOut) { *sampleRateOut = 0; } if (totalFrameCountOut) { *totalFrameCountOut = 0; } if (!ma_dr_wav_init(&wav, onRead, onSeek, pUserData, pAllocationCallbacks)) { return NULL; } return ma_dr_wav__read_pcm_frames_and_close_s16(&wav, channelsOut, sampleRateOut, totalFrameCountOut); } MA_API float* ma_dr_wav_open_and_read_pcm_frames_f32(ma_dr_wav_read_proc onRead, ma_dr_wav_seek_proc onSeek, void* pUserData, unsigned int* channelsOut, unsigned int* sampleRateOut, ma_uint64* totalFrameCountOut, const ma_allocation_callbacks* pAllocationCallbacks) { ma_dr_wav wav; if (channelsOut) { *channelsOut = 0; } if (sampleRateOut) { *sampleRateOut = 0; } if (totalFrameCountOut) { *totalFrameCountOut = 0; } if (!ma_dr_wav_init(&wav, onRead, onSeek, pUserData, pAllocationCallbacks)) { return NULL; } return ma_dr_wav__read_pcm_frames_and_close_f32(&wav, channelsOut, sampleRateOut, totalFrameCountOut); } MA_API ma_int32* ma_dr_wav_open_and_read_pcm_frames_s32(ma_dr_wav_read_proc onRead, ma_dr_wav_seek_proc onSeek, void* pUserData, unsigned int* channelsOut, unsigned int* sampleRateOut, ma_uint64* totalFrameCountOut, const ma_allocation_callbacks* pAllocationCallbacks) { ma_dr_wav wav; if (channelsOut) { *channelsOut = 0; } if (sampleRateOut) { *sampleRateOut = 0; } if (totalFrameCountOut) { *totalFrameCountOut = 0; } if (!ma_dr_wav_init(&wav, onRead, onSeek, pUserData, pAllocationCallbacks)) { return NULL; } return ma_dr_wav__read_pcm_frames_and_close_s32(&wav, channelsOut, sampleRateOut, totalFrameCountOut); } #ifndef MA_DR_WAV_NO_STDIO MA_API ma_int16* ma_dr_wav_open_file_and_read_pcm_frames_s16(const char* filename, unsigned int* channelsOut, unsigned int* sampleRateOut, ma_uint64* totalFrameCountOut, const ma_allocation_callbacks* pAllocationCallbacks) { ma_dr_wav wav; if (channelsOut) { *channelsOut = 0; } if (sampleRateOut) { *sampleRateOut = 0; } if (totalFrameCountOut) { *totalFrameCountOut = 0; } if (!ma_dr_wav_init_file(&wav, filename, pAllocationCallbacks)) { return NULL; } return ma_dr_wav__read_pcm_frames_and_close_s16(&wav, channelsOut, sampleRateOut, totalFrameCountOut); } MA_API float* ma_dr_wav_open_file_and_read_pcm_frames_f32(const char* filename, unsigned int* channelsOut, unsigned int* sampleRateOut, ma_uint64* totalFrameCountOut, const ma_allocation_callbacks* pAllocationCallbacks) { ma_dr_wav wav; if (channelsOut) { *channelsOut = 0; } if (sampleRateOut) { *sampleRateOut = 0; } if (totalFrameCountOut) { *totalFrameCountOut = 0; } if (!ma_dr_wav_init_file(&wav, filename, pAllocationCallbacks)) { return NULL; } return ma_dr_wav__read_pcm_frames_and_close_f32(&wav, channelsOut, sampleRateOut, totalFrameCountOut); } MA_API ma_int32* ma_dr_wav_open_file_and_read_pcm_frames_s32(const char* filename, unsigned int* channelsOut, unsigned int* sampleRateOut, ma_uint64* totalFrameCountOut, const ma_allocation_callbacks* pAllocationCallbacks) { ma_dr_wav wav; if (channelsOut) { *channelsOut = 0; } if (sampleRateOut) { *sampleRateOut = 0; } if (totalFrameCountOut) { *totalFrameCountOut = 0; } if (!ma_dr_wav_init_file(&wav, filename, pAllocationCallbacks)) { return NULL; } return ma_dr_wav__read_pcm_frames_and_close_s32(&wav, channelsOut, sampleRateOut, totalFrameCountOut); } #ifndef MA_DR_WAV_NO_WCHAR MA_API ma_int16* ma_dr_wav_open_file_and_read_pcm_frames_s16_w(const wchar_t* filename, unsigned int* channelsOut, unsigned int* sampleRateOut, ma_uint64* totalFrameCountOut, const ma_allocation_callbacks* pAllocationCallbacks) { ma_dr_wav wav; if (sampleRateOut) { *sampleRateOut = 0; } if (channelsOut) { *channelsOut = 0; } if (totalFrameCountOut) { *totalFrameCountOut = 0; } if (!ma_dr_wav_init_file_w(&wav, filename, pAllocationCallbacks)) { return NULL; } return ma_dr_wav__read_pcm_frames_and_close_s16(&wav, channelsOut, sampleRateOut, totalFrameCountOut); } MA_API float* ma_dr_wav_open_file_and_read_pcm_frames_f32_w(const wchar_t* filename, unsigned int* channelsOut, unsigned int* sampleRateOut, ma_uint64* totalFrameCountOut, const ma_allocation_callbacks* pAllocationCallbacks) { ma_dr_wav wav; if (sampleRateOut) { *sampleRateOut = 0; } if (channelsOut) { *channelsOut = 0; } if (totalFrameCountOut) { *totalFrameCountOut = 0; } if (!ma_dr_wav_init_file_w(&wav, filename, pAllocationCallbacks)) { return NULL; } return ma_dr_wav__read_pcm_frames_and_close_f32(&wav, channelsOut, sampleRateOut, totalFrameCountOut); } MA_API ma_int32* ma_dr_wav_open_file_and_read_pcm_frames_s32_w(const wchar_t* filename, unsigned int* channelsOut, unsigned int* sampleRateOut, ma_uint64* totalFrameCountOut, const ma_allocation_callbacks* pAllocationCallbacks) { ma_dr_wav wav; if (sampleRateOut) { *sampleRateOut = 0; } if (channelsOut) { *channelsOut = 0; } if (totalFrameCountOut) { *totalFrameCountOut = 0; } if (!ma_dr_wav_init_file_w(&wav, filename, pAllocationCallbacks)) { return NULL; } return ma_dr_wav__read_pcm_frames_and_close_s32(&wav, channelsOut, sampleRateOut, totalFrameCountOut); } #endif #endif MA_API ma_int16* ma_dr_wav_open_memory_and_read_pcm_frames_s16(const void* data, size_t dataSize, unsigned int* channelsOut, unsigned int* sampleRateOut, ma_uint64* totalFrameCountOut, const ma_allocation_callbacks* pAllocationCallbacks) { ma_dr_wav wav; if (channelsOut) { *channelsOut = 0; } if (sampleRateOut) { *sampleRateOut = 0; } if (totalFrameCountOut) { *totalFrameCountOut = 0; } if (!ma_dr_wav_init_memory(&wav, data, dataSize, pAllocationCallbacks)) { return NULL; } return ma_dr_wav__read_pcm_frames_and_close_s16(&wav, channelsOut, sampleRateOut, totalFrameCountOut); } MA_API float* ma_dr_wav_open_memory_and_read_pcm_frames_f32(const void* data, size_t dataSize, unsigned int* channelsOut, unsigned int* sampleRateOut, ma_uint64* totalFrameCountOut, const ma_allocation_callbacks* pAllocationCallbacks) { ma_dr_wav wav; if (channelsOut) { *channelsOut = 0; } if (sampleRateOut) { *sampleRateOut = 0; } if (totalFrameCountOut) { *totalFrameCountOut = 0; } if (!ma_dr_wav_init_memory(&wav, data, dataSize, pAllocationCallbacks)) { return NULL; } return ma_dr_wav__read_pcm_frames_and_close_f32(&wav, channelsOut, sampleRateOut, totalFrameCountOut); } MA_API ma_int32* ma_dr_wav_open_memory_and_read_pcm_frames_s32(const void* data, size_t dataSize, unsigned int* channelsOut, unsigned int* sampleRateOut, ma_uint64* totalFrameCountOut, const ma_allocation_callbacks* pAllocationCallbacks) { ma_dr_wav wav; if (channelsOut) { *channelsOut = 0; } if (sampleRateOut) { *sampleRateOut = 0; } if (totalFrameCountOut) { *totalFrameCountOut = 0; } if (!ma_dr_wav_init_memory(&wav, data, dataSize, pAllocationCallbacks)) { return NULL; } return ma_dr_wav__read_pcm_frames_and_close_s32(&wav, channelsOut, sampleRateOut, totalFrameCountOut); } #endif MA_API void ma_dr_wav_free(void* p, const ma_allocation_callbacks* pAllocationCallbacks) { if (pAllocationCallbacks != NULL) { ma_dr_wav__free_from_callbacks(p, pAllocationCallbacks); } else { ma_dr_wav__free_default(p, NULL); } } MA_API ma_uint16 ma_dr_wav_bytes_to_u16(const ma_uint8* data) { return ((ma_uint16)data[0] << 0) | ((ma_uint16)data[1] << 8); } MA_API ma_int16 ma_dr_wav_bytes_to_s16(const ma_uint8* data) { return (ma_int16)ma_dr_wav_bytes_to_u16(data); } MA_API ma_uint32 ma_dr_wav_bytes_to_u32(const ma_uint8* data) { return ma_dr_wav_bytes_to_u32_le(data); } MA_API float ma_dr_wav_bytes_to_f32(const ma_uint8* data) { union { ma_uint32 u32; float f32; } value; value.u32 = ma_dr_wav_bytes_to_u32(data); return value.f32; } MA_API ma_int32 ma_dr_wav_bytes_to_s32(const ma_uint8* data) { return (ma_int32)ma_dr_wav_bytes_to_u32(data); } MA_API ma_uint64 ma_dr_wav_bytes_to_u64(const ma_uint8* data) { return ((ma_uint64)data[0] << 0) | ((ma_uint64)data[1] << 8) | ((ma_uint64)data[2] << 16) | ((ma_uint64)data[3] << 24) | ((ma_uint64)data[4] << 32) | ((ma_uint64)data[5] << 40) | ((ma_uint64)data[6] << 48) | ((ma_uint64)data[7] << 56); } MA_API ma_int64 ma_dr_wav_bytes_to_s64(const ma_uint8* data) { return (ma_int64)ma_dr_wav_bytes_to_u64(data); } MA_API ma_bool32 ma_dr_wav_guid_equal(const ma_uint8 a[16], const ma_uint8 b[16]) { int i; for (i = 0; i < 16; i += 1) { if (a[i] != b[i]) { return MA_FALSE; } } return MA_TRUE; } MA_API ma_bool32 ma_dr_wav_fourcc_equal(const ma_uint8* a, const char* b) { return a[0] == b[0] && a[1] == b[1] && a[2] == b[2] && a[3] == b[3]; } #ifdef __MRC__ #pragma options opt reset #endif #endif /* dr_wav_c end */ #endif /* MA_DR_WAV_IMPLEMENTATION */ #endif /* MA_NO_WAV */ #if !defined(MA_NO_FLAC) && !defined(MA_NO_DECODING) #if !defined(MA_DR_FLAC_IMPLEMENTATION) && !defined(MA_DR_FLAC_IMPLEMENTATION) /* For backwards compatibility. Will be removed in version 0.11 for cleanliness. */ /* dr_flac_c begin */ #ifndef ma_dr_flac_c #define ma_dr_flac_c #if defined(__clang__) || (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))) #pragma GCC diagnostic push #if __GNUC__ >= 7 #pragma GCC diagnostic ignored "-Wimplicit-fallthrough" #endif #endif #ifdef __linux__ #ifndef _BSD_SOURCE #define _BSD_SOURCE #endif #ifndef _DEFAULT_SOURCE #define _DEFAULT_SOURCE #endif #ifndef __USE_BSD #define __USE_BSD #endif #include #endif #include #include #if !defined(MA_DR_FLAC_NO_SIMD) #if defined(MA_X64) || defined(MA_X86) #if defined(_MSC_VER) && !defined(__clang__) #if _MSC_VER >= 1400 && !defined(MA_DR_FLAC_NO_SSE2) #define MA_DR_FLAC_SUPPORT_SSE2 #endif #if _MSC_VER >= 1600 && !defined(MA_DR_FLAC_NO_SSE41) #define MA_DR_FLAC_SUPPORT_SSE41 #endif #elif defined(__clang__) || (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))) #if defined(__SSE2__) && !defined(MA_DR_FLAC_NO_SSE2) #define MA_DR_FLAC_SUPPORT_SSE2 #endif #if defined(__SSE4_1__) && !defined(MA_DR_FLAC_NO_SSE41) #define MA_DR_FLAC_SUPPORT_SSE41 #endif #endif #if !defined(__GNUC__) && !defined(__clang__) && defined(__has_include) #if !defined(MA_DR_FLAC_SUPPORT_SSE2) && !defined(MA_DR_FLAC_NO_SSE2) && __has_include() #define MA_DR_FLAC_SUPPORT_SSE2 #endif #if !defined(MA_DR_FLAC_SUPPORT_SSE41) && !defined(MA_DR_FLAC_NO_SSE41) && __has_include() #define MA_DR_FLAC_SUPPORT_SSE41 #endif #endif #if defined(MA_DR_FLAC_SUPPORT_SSE41) #include #elif defined(MA_DR_FLAC_SUPPORT_SSE2) #include #endif #endif #if defined(MA_ARM) #if !defined(MA_DR_FLAC_NO_NEON) && (defined(__ARM_NEON) || defined(__aarch64__) || defined(_M_ARM64)) #define MA_DR_FLAC_SUPPORT_NEON #include #endif #endif #endif #if !defined(MA_DR_FLAC_NO_SIMD) && (defined(MA_X86) || defined(MA_X64)) #if defined(_MSC_VER) && !defined(__clang__) #if _MSC_VER >= 1400 #include static void ma_dr_flac__cpuid(int info[4], int fid) { __cpuid(info, fid); } #else #define MA_DR_FLAC_NO_CPUID #endif #else #if defined(__GNUC__) || defined(__clang__) static void ma_dr_flac__cpuid(int info[4], int fid) { #if defined(MA_X86) && defined(__PIC__) __asm__ __volatile__ ( "xchg{l} {%%}ebx, %k1;" "cpuid;" "xchg{l} {%%}ebx, %k1;" : "=a"(info[0]), "=&r"(info[1]), "=c"(info[2]), "=d"(info[3]) : "a"(fid), "c"(0) ); #else __asm__ __volatile__ ( "cpuid" : "=a"(info[0]), "=b"(info[1]), "=c"(info[2]), "=d"(info[3]) : "a"(fid), "c"(0) ); #endif } #else #define MA_DR_FLAC_NO_CPUID #endif #endif #else #define MA_DR_FLAC_NO_CPUID #endif static MA_INLINE ma_bool32 ma_dr_flac_has_sse2(void) { #if defined(MA_DR_FLAC_SUPPORT_SSE2) #if (defined(MA_X64) || defined(MA_X86)) && !defined(MA_DR_FLAC_NO_SSE2) #if defined(MA_X64) return MA_TRUE; #elif (defined(_M_IX86_FP) && _M_IX86_FP == 2) || defined(__SSE2__) return MA_TRUE; #else #if defined(MA_DR_FLAC_NO_CPUID) return MA_FALSE; #else int info[4]; ma_dr_flac__cpuid(info, 1); return (info[3] & (1 << 26)) != 0; #endif #endif #else return MA_FALSE; #endif #else return MA_FALSE; #endif } static MA_INLINE ma_bool32 ma_dr_flac_has_sse41(void) { #if defined(MA_DR_FLAC_SUPPORT_SSE41) #if (defined(MA_X64) || defined(MA_X86)) && !defined(MA_DR_FLAC_NO_SSE41) #if defined(__SSE4_1__) || defined(__AVX__) return MA_TRUE; #else #if defined(MA_DR_FLAC_NO_CPUID) return MA_FALSE; #else int info[4]; ma_dr_flac__cpuid(info, 1); return (info[2] & (1 << 19)) != 0; #endif #endif #else return MA_FALSE; #endif #else return MA_FALSE; #endif } #if defined(_MSC_VER) && _MSC_VER >= 1500 && (defined(MA_X86) || defined(MA_X64)) && !defined(__clang__) #define MA_DR_FLAC_HAS_LZCNT_INTRINSIC #elif (defined(__GNUC__) && ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7))) #define MA_DR_FLAC_HAS_LZCNT_INTRINSIC #elif defined(__clang__) #if defined(__has_builtin) #if __has_builtin(__builtin_clzll) || __has_builtin(__builtin_clzl) #define MA_DR_FLAC_HAS_LZCNT_INTRINSIC #endif #endif #endif #if defined(_MSC_VER) && _MSC_VER >= 1400 && !defined(__clang__) #define MA_DR_FLAC_HAS_BYTESWAP16_INTRINSIC #define MA_DR_FLAC_HAS_BYTESWAP32_INTRINSIC #define MA_DR_FLAC_HAS_BYTESWAP64_INTRINSIC #elif defined(__clang__) #if defined(__has_builtin) #if __has_builtin(__builtin_bswap16) #define MA_DR_FLAC_HAS_BYTESWAP16_INTRINSIC #endif #if __has_builtin(__builtin_bswap32) #define MA_DR_FLAC_HAS_BYTESWAP32_INTRINSIC #endif #if __has_builtin(__builtin_bswap64) #define MA_DR_FLAC_HAS_BYTESWAP64_INTRINSIC #endif #endif #elif defined(__GNUC__) #if ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)) #define MA_DR_FLAC_HAS_BYTESWAP32_INTRINSIC #define MA_DR_FLAC_HAS_BYTESWAP64_INTRINSIC #endif #if ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)) #define MA_DR_FLAC_HAS_BYTESWAP16_INTRINSIC #endif #elif defined(__WATCOMC__) && defined(__386__) #define MA_DR_FLAC_HAS_BYTESWAP16_INTRINSIC #define MA_DR_FLAC_HAS_BYTESWAP32_INTRINSIC #define MA_DR_FLAC_HAS_BYTESWAP64_INTRINSIC extern __inline ma_uint16 _watcom_bswap16(ma_uint16); extern __inline ma_uint32 _watcom_bswap32(ma_uint32); extern __inline ma_uint64 _watcom_bswap64(ma_uint64); #pragma aux _watcom_bswap16 = \ "xchg al, ah" \ parm [ax] \ value [ax] \ modify nomemory; #pragma aux _watcom_bswap32 = \ "bswap eax" \ parm [eax] \ value [eax] \ modify nomemory; #pragma aux _watcom_bswap64 = \ "bswap eax" \ "bswap edx" \ "xchg eax,edx" \ parm [eax edx] \ value [eax edx] \ modify nomemory; #endif #ifndef MA_DR_FLAC_ASSERT #include #define MA_DR_FLAC_ASSERT(expression) assert(expression) #endif #ifndef MA_DR_FLAC_MALLOC #define MA_DR_FLAC_MALLOC(sz) malloc((sz)) #endif #ifndef MA_DR_FLAC_REALLOC #define MA_DR_FLAC_REALLOC(p, sz) realloc((p), (sz)) #endif #ifndef MA_DR_FLAC_FREE #define MA_DR_FLAC_FREE(p) free((p)) #endif #ifndef MA_DR_FLAC_COPY_MEMORY #define MA_DR_FLAC_COPY_MEMORY(dst, src, sz) memcpy((dst), (src), (sz)) #endif #ifndef MA_DR_FLAC_ZERO_MEMORY #define MA_DR_FLAC_ZERO_MEMORY(p, sz) memset((p), 0, (sz)) #endif #ifndef MA_DR_FLAC_ZERO_OBJECT #define MA_DR_FLAC_ZERO_OBJECT(p) MA_DR_FLAC_ZERO_MEMORY((p), sizeof(*(p))) #endif #define MA_DR_FLAC_MAX_SIMD_VECTOR_SIZE 64 #define MA_DR_FLAC_SUBFRAME_CONSTANT 0 #define MA_DR_FLAC_SUBFRAME_VERBATIM 1 #define MA_DR_FLAC_SUBFRAME_FIXED 8 #define MA_DR_FLAC_SUBFRAME_LPC 32 #define MA_DR_FLAC_SUBFRAME_RESERVED 255 #define MA_DR_FLAC_RESIDUAL_CODING_METHOD_PARTITIONED_RICE 0 #define MA_DR_FLAC_RESIDUAL_CODING_METHOD_PARTITIONED_RICE2 1 #define MA_DR_FLAC_CHANNEL_ASSIGNMENT_INDEPENDENT 0 #define MA_DR_FLAC_CHANNEL_ASSIGNMENT_LEFT_SIDE 8 #define MA_DR_FLAC_CHANNEL_ASSIGNMENT_RIGHT_SIDE 9 #define MA_DR_FLAC_CHANNEL_ASSIGNMENT_MID_SIDE 10 #define MA_DR_FLAC_SEEKPOINT_SIZE_IN_BYTES 18 #define MA_DR_FLAC_CUESHEET_TRACK_SIZE_IN_BYTES 36 #define MA_DR_FLAC_CUESHEET_TRACK_INDEX_SIZE_IN_BYTES 12 #define ma_dr_flac_align(x, a) ((((x) + (a) - 1) / (a)) * (a)) MA_API void ma_dr_flac_version(ma_uint32* pMajor, ma_uint32* pMinor, ma_uint32* pRevision) { if (pMajor) { *pMajor = MA_DR_FLAC_VERSION_MAJOR; } if (pMinor) { *pMinor = MA_DR_FLAC_VERSION_MINOR; } if (pRevision) { *pRevision = MA_DR_FLAC_VERSION_REVISION; } } MA_API const char* ma_dr_flac_version_string(void) { return MA_DR_FLAC_VERSION_STRING; } #if defined(__has_feature) #if __has_feature(thread_sanitizer) #define MA_DR_FLAC_NO_THREAD_SANITIZE __attribute__((no_sanitize("thread"))) #else #define MA_DR_FLAC_NO_THREAD_SANITIZE #endif #else #define MA_DR_FLAC_NO_THREAD_SANITIZE #endif #if defined(MA_DR_FLAC_HAS_LZCNT_INTRINSIC) static ma_bool32 ma_dr_flac__gIsLZCNTSupported = MA_FALSE; #endif #ifndef MA_DR_FLAC_NO_CPUID static ma_bool32 ma_dr_flac__gIsSSE2Supported = MA_FALSE; static ma_bool32 ma_dr_flac__gIsSSE41Supported = MA_FALSE; MA_DR_FLAC_NO_THREAD_SANITIZE static void ma_dr_flac__init_cpu_caps(void) { static ma_bool32 isCPUCapsInitialized = MA_FALSE; if (!isCPUCapsInitialized) { #if defined(MA_DR_FLAC_HAS_LZCNT_INTRINSIC) int info[4] = {0}; ma_dr_flac__cpuid(info, 0x80000001); ma_dr_flac__gIsLZCNTSupported = (info[2] & (1 << 5)) != 0; #endif ma_dr_flac__gIsSSE2Supported = ma_dr_flac_has_sse2(); ma_dr_flac__gIsSSE41Supported = ma_dr_flac_has_sse41(); isCPUCapsInitialized = MA_TRUE; } } #else static ma_bool32 ma_dr_flac__gIsNEONSupported = MA_FALSE; static MA_INLINE ma_bool32 ma_dr_flac__has_neon(void) { #if defined(MA_DR_FLAC_SUPPORT_NEON) #if defined(MA_ARM) && !defined(MA_DR_FLAC_NO_NEON) #if (defined(__ARM_NEON) || defined(__aarch64__) || defined(_M_ARM64)) return MA_TRUE; #else return MA_FALSE; #endif #else return MA_FALSE; #endif #else return MA_FALSE; #endif } MA_DR_FLAC_NO_THREAD_SANITIZE static void ma_dr_flac__init_cpu_caps(void) { ma_dr_flac__gIsNEONSupported = ma_dr_flac__has_neon(); #if defined(MA_DR_FLAC_HAS_LZCNT_INTRINSIC) && defined(MA_ARM) && (defined(__ARM_ARCH) && __ARM_ARCH >= 5) ma_dr_flac__gIsLZCNTSupported = MA_TRUE; #endif } #endif static MA_INLINE ma_bool32 ma_dr_flac__is_little_endian(void) { #if defined(MA_X86) || defined(MA_X64) return MA_TRUE; #elif defined(__BYTE_ORDER) && defined(__LITTLE_ENDIAN) && __BYTE_ORDER == __LITTLE_ENDIAN return MA_TRUE; #else int n = 1; return (*(char*)&n) == 1; #endif } static MA_INLINE ma_uint16 ma_dr_flac__swap_endian_uint16(ma_uint16 n) { #ifdef MA_DR_FLAC_HAS_BYTESWAP16_INTRINSIC #if defined(_MSC_VER) && !defined(__clang__) return _byteswap_ushort(n); #elif defined(__GNUC__) || defined(__clang__) return __builtin_bswap16(n); #elif defined(__WATCOMC__) && defined(__386__) return _watcom_bswap16(n); #else #error "This compiler does not support the byte swap intrinsic." #endif #else return ((n & 0xFF00) >> 8) | ((n & 0x00FF) << 8); #endif } static MA_INLINE ma_uint32 ma_dr_flac__swap_endian_uint32(ma_uint32 n) { #ifdef MA_DR_FLAC_HAS_BYTESWAP32_INTRINSIC #if defined(_MSC_VER) && !defined(__clang__) return _byteswap_ulong(n); #elif defined(__GNUC__) || defined(__clang__) #if defined(MA_ARM) && (defined(__ARM_ARCH) && __ARM_ARCH >= 6) && !defined(__ARM_ARCH_6M__) && !defined(MA_64BIT) ma_uint32 r; __asm__ __volatile__ ( #if defined(MA_64BIT) "rev %w[out], %w[in]" : [out]"=r"(r) : [in]"r"(n) #else "rev %[out], %[in]" : [out]"=r"(r) : [in]"r"(n) #endif ); return r; #else return __builtin_bswap32(n); #endif #elif defined(__WATCOMC__) && defined(__386__) return _watcom_bswap32(n); #else #error "This compiler does not support the byte swap intrinsic." #endif #else return ((n & 0xFF000000) >> 24) | ((n & 0x00FF0000) >> 8) | ((n & 0x0000FF00) << 8) | ((n & 0x000000FF) << 24); #endif } static MA_INLINE ma_uint64 ma_dr_flac__swap_endian_uint64(ma_uint64 n) { #ifdef MA_DR_FLAC_HAS_BYTESWAP64_INTRINSIC #if defined(_MSC_VER) && !defined(__clang__) return _byteswap_uint64(n); #elif defined(__GNUC__) || defined(__clang__) return __builtin_bswap64(n); #elif defined(__WATCOMC__) && defined(__386__) return _watcom_bswap64(n); #else #error "This compiler does not support the byte swap intrinsic." #endif #else return ((n & ((ma_uint64)0xFF000000 << 32)) >> 56) | ((n & ((ma_uint64)0x00FF0000 << 32)) >> 40) | ((n & ((ma_uint64)0x0000FF00 << 32)) >> 24) | ((n & ((ma_uint64)0x000000FF << 32)) >> 8) | ((n & ((ma_uint64)0xFF000000 )) << 8) | ((n & ((ma_uint64)0x00FF0000 )) << 24) | ((n & ((ma_uint64)0x0000FF00 )) << 40) | ((n & ((ma_uint64)0x000000FF )) << 56); #endif } static MA_INLINE ma_uint16 ma_dr_flac__be2host_16(ma_uint16 n) { if (ma_dr_flac__is_little_endian()) { return ma_dr_flac__swap_endian_uint16(n); } return n; } static MA_INLINE ma_uint32 ma_dr_flac__be2host_32(ma_uint32 n) { if (ma_dr_flac__is_little_endian()) { return ma_dr_flac__swap_endian_uint32(n); } return n; } static MA_INLINE ma_uint32 ma_dr_flac__be2host_32_ptr_unaligned(const void* pData) { const ma_uint8* pNum = (ma_uint8*)pData; return *(pNum) << 24 | *(pNum+1) << 16 | *(pNum+2) << 8 | *(pNum+3); } static MA_INLINE ma_uint64 ma_dr_flac__be2host_64(ma_uint64 n) { if (ma_dr_flac__is_little_endian()) { return ma_dr_flac__swap_endian_uint64(n); } return n; } static MA_INLINE ma_uint32 ma_dr_flac__le2host_32(ma_uint32 n) { if (!ma_dr_flac__is_little_endian()) { return ma_dr_flac__swap_endian_uint32(n); } return n; } static MA_INLINE ma_uint32 ma_dr_flac__le2host_32_ptr_unaligned(const void* pData) { const ma_uint8* pNum = (ma_uint8*)pData; return *pNum | *(pNum+1) << 8 | *(pNum+2) << 16 | *(pNum+3) << 24; } static MA_INLINE ma_uint32 ma_dr_flac__unsynchsafe_32(ma_uint32 n) { ma_uint32 result = 0; result |= (n & 0x7F000000) >> 3; result |= (n & 0x007F0000) >> 2; result |= (n & 0x00007F00) >> 1; result |= (n & 0x0000007F) >> 0; return result; } static ma_uint8 ma_dr_flac__crc8_table[] = { 0x00, 0x07, 0x0E, 0x09, 0x1C, 0x1B, 0x12, 0x15, 0x38, 0x3F, 0x36, 0x31, 0x24, 0x23, 0x2A, 0x2D, 0x70, 0x77, 0x7E, 0x79, 0x6C, 0x6B, 0x62, 0x65, 0x48, 0x4F, 0x46, 0x41, 0x54, 0x53, 0x5A, 0x5D, 0xE0, 0xE7, 0xEE, 0xE9, 0xFC, 0xFB, 0xF2, 0xF5, 0xD8, 0xDF, 0xD6, 0xD1, 0xC4, 0xC3, 0xCA, 0xCD, 0x90, 0x97, 0x9E,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x98, 0x9F, 0x8A, 0x8D, 0x84, 0x83, 0xDE, 0xD9, 0xD0, 0xD7, 0xC2, 0xC5, 0xCC, 0xCB, 0xE6, 0xE1, 0xE8, 0xEF, 0xFA, 0xFD, 0xF4, 0xF3 }; static ma_uint16 ma_dr_flac__crc16_table[] = { 0x0000, 0x8005, 0x800F, 0x000A, 0x801B, 0x001E, 0x0014, 0x8011, 0x8033, 0x0036, 0x003C, 0x8039, 0x0028, 0x802D, 0x8027, 0x0022, 0x8063, 0x0066, 0x006C, 0x8069, 0x0078, 0x807D, 0x8077, 0x0072, 0x0050, 0x8055, 0x805F, 0x005A, 0x804B, 0x004E, 0x0044, 0x8041, 0x80C3, 0x00C6, 0x00CC, 0x80C9, 0x00D8, 0x80DD, 0x80D7, 0x00D2, 0x00F0, 0x80F5, 0x80FF, 0x00FA, 0x80EB, 0x00EE, 0x00E4, 0x80E1, 0x00A0, 0x80A5, 0x80AF, 0x00AA, 0x80BB, 0x00BE, 0x00B4, 0x80B1, 0x8093, 0x0096, 0x009C, 0x8099, 0x0088, 0x808D, 0x8087, 0x0082, 0x8183, 0x0186, 0x018C, 0x8189, 0x0198, 0x819D, 0x8197, 0x0192, 0x01B0, 0x81B5, 0x81BF, 0x01BA, 0x81AB, 0x01AE, 0x01A4, 0x81A1, 0x01E0, 0x81E5, 0x81EF, 0x01EA, 0x81FB, 0x01FE, 0x01F4, 0x81F1, 0x81D3, 0x01D6, 0x01DC, 0x81D9, 0x01C8, 0x81CD, 0x81C7, 0x01C2, 0x0140, 0x8145, 0x814F, 0x014A, 0x815B, 0x015E, 0x0154, 0x8151, 0x8173, 0x0176, 0x017C, 0x8179, 0x0168, 0x816D, 0x8167, 0x0162, 0x8123, 0x0126, 0x012C, 0x8129, 0x0138, 0x813D, 0x8137, 0x0132, 0x0110, 0x8115, 0x811F, 0x011A, 0x810B, 0x010E, 0x0104, 0x8101, 0x8303, 0x0306, 0x030C, 0x8309, 0x0318, 0x831D, 0x8317, 0x0312, 0x0330, 0x8335, 0x833F, 0x033A, 0x832B, 0x032E, 0x0324, 0x8321, 0x0360, 0x8365, 0x836F, 0x036A, 0x837B, 0x037E, 0x0374, 0x8371, 0x8353, 0x0356, 0x035C, 0x8359, 0x0348, 0x834D, 0x8347, 0x0342, 0x03C0, 0x83C5, 0x83CF, 0x03CA, 0x83DB, 0x03DE, 0x03D4, 0x83D1, 0x83F3, 0x03F6, 0x03FC, 0x83F9, 0x03E8, 0x83ED, 0x83E7, 0x03E2, 0x83A3, 0x03A6, 0x03AC, 0x83A9, 0x03B8, 0x83BD, 0x83B7, 0x03B2, 0x0390, 0x8395, 0x839F, 0x039A, 0x838B, 0x038E, 0x0384, 0x8381, 0x0280, 0x8285, 0x828F, 0x028A, 0x829B, 0x029E, 0x0294, 0x8291, 0x82B3, 0x02B6, 0x02BC, 0x82B9, 0x02A8, 0x82AD, 0x82A7, 0x02A2, 0x82E3, 0x02E6, 0x02EC, 0x82E9, 0x02F8, 0x82FD, 0x82F7, 0x02F2, 0x02D0, 0x82D5, 0x82DF, 0x02DA, 0x82CB, 0x02CE, 0x02C4, 0x82C1, 0x8243, 0x0246, 0x024C, 0x8249, 0x0258, 0x825D, 0x8257, 0x0252, 0x0270, 0x8275, 0x827F, 0x027A, 0x826B, 0x026E, 0x0264, 0x8261, 0x0220, 0x8225, 0x822F, 0x022A, 0x823B, 0x023E, 0x0234, 0x8231, 0x8213, 0x0216, 0x021C, 0x8219, 0x0208, 0x820D, 0x8207, 0x0202 }; static MA_INLINE ma_uint8 ma_dr_flac_crc8_byte(ma_uint8 crc, ma_uint8 data) { return ma_dr_flac__crc8_table[crc ^ data]; } static MA_INLINE ma_uint8 ma_dr_flac_crc8(ma_uint8 crc, ma_uint32 data, ma_uint32 count) { #ifdef MA_DR_FLAC_NO_CRC (void)crc; (void)data; (void)count; return 0; #else #if 0 ma_uint8 p = 0x07; for (int i = count-1; i >= 0; --i) { ma_uint8 bit = (data & (1 << i)) >> i; if (crc & 0x80) { crc = ((crc << 1) | bit) ^ p; } else { crc = ((crc << 1) | bit); } } return crc; #else ma_uint32 wholeBytes; ma_uint32 leftoverBits; ma_uint64 leftoverDataMask; static ma_uint64 leftoverDataMaskTable[8] = { 0x00, 0x01, 0x03, 0x07, 0x0F, 0x1F, 0x3F, 0x7F }; MA_DR_FLAC_ASSERT(count <= 32); wholeBytes = count >> 3; leftoverBits = count - (wholeBytes*8); leftoverDataMask = leftoverDataMaskTable[leftoverBits]; switch (wholeBytes) { case 4: crc = ma_dr_flac_crc8_byte(crc, (ma_uint8)((data & (0xFF000000UL << leftoverBits)) >> (24 + leftoverBits))); case 3: crc = ma_dr_flac_crc8_byte(crc, (ma_uint8)((data & (0x00FF0000UL << leftoverBits)) >> (16 + leftoverBits))); case 2: crc = ma_dr_flac_crc8_byte(crc, (ma_uint8)((data & (0x0000FF00UL << leftoverBits)) >> ( 8 + leftoverBits))); case 1: crc = ma_dr_flac_crc8_byte(crc, (ma_uint8)((data & (0x000000FFUL << leftoverBits)) >> ( 0 + leftoverBits))); case 0: if (leftoverBits > 0) crc = (ma_uint8)((crc << leftoverBits) ^ ma_dr_flac__crc8_table[(crc >> (8 - leftoverBits)) ^ (data & leftoverDataMask)]); } return crc; #endif #endif } static MA_INLINE ma_uint16 ma_dr_flac_crc16_byte(ma_uint16 crc, ma_uint8 data) { return (crc << 8) ^ ma_dr_flac__crc16_table[(ma_uint8)(crc >> 8) ^ data]; } static MA_INLINE ma_uint16 ma_dr_flac_crc16_cache(ma_uint16 crc, ma_dr_flac_cache_t data) { #ifdef MA_64BIT crc = ma_dr_flac_crc16_byte(crc, (ma_uint8)((data >> 56) & 0xFF)); crc = ma_dr_flac_crc16_byte(crc, (ma_uint8)((data >> 48) & 0xFF)); crc = ma_dr_flac_crc16_byte(crc, (ma_uint8)((data >> 40) & 0xFF)); crc = ma_dr_flac_crc16_byte(crc, (ma_uint8)((data >> 32) & 0xFF)); #endif crc = ma_dr_flac_crc16_byte(crc, (ma_uint8)((data >> 24) & 0xFF)); crc = ma_dr_flac_crc16_byte(crc, (ma_uint8)((data >> 16) & 0xFF)); crc = ma_dr_flac_crc16_byte(crc, (ma_uint8)((data >> 8) & 0xFF)); crc = ma_dr_flac_crc16_byte(crc, (ma_uint8)((data >> 0) & 0xFF)); return crc; } static MA_INLINE ma_uint16 ma_dr_flac_crc16_bytes(ma_uint16 crc, ma_dr_flac_cache_t data, ma_uint32 byteCount) { switch (byteCount) { #ifdef MA_64BIT case 8: crc = ma_dr_flac_crc16_byte(crc, (ma_uint8)((data >> 56) & 0xFF)); case 7: crc = ma_dr_flac_crc16_byte(crc, (ma_uint8)((data >> 48) & 0xFF)); case 6: crc = ma_dr_flac_crc16_byte(crc, (ma_uint8)((data >> 40) & 0xFF)); case 5: crc = ma_dr_flac_crc16_byte(crc, (ma_uint8)((data >> 32) & 0xFF)); #endif case 4: crc = ma_dr_flac_crc16_byte(crc, (ma_uint8)((data >> 24) & 0xFF)); case 3: crc = ma_dr_flac_crc16_byte(crc, (ma_uint8)((data >> 16) & 0xFF)); case 2: crc = ma_dr_flac_crc16_byte(crc, (ma_uint8)((data >> 8) & 0xFF)); case 1: crc = ma_dr_flac_crc16_byte(crc, (ma_uint8)((data >> 0) & 0xFF)); } return crc; } #if 0 static MA_INLINE ma_uint16 ma_dr_flac_crc16__32bit(ma_uint16 crc, ma_uint32 data, ma_uint32 count) { #ifdef MA_DR_FLAC_NO_CRC (void)crc; (void)data; (void)count; return 0; #else #if 0 ma_uint16 p = 0x8005; for (int i = count-1; i >= 0; --i) { ma_uint16 bit = (data & (1ULL << i)) >> i; if (r & 0x8000) { r = ((r << 1) | bit) ^ p; } else { r = ((r << 1) | bit); } } return crc; #else ma_uint32 wholeBytes; ma_uint32 leftoverBits; ma_uint64 leftoverDataMask; static ma_uint64 leftoverDataMaskTable[8] = { 0x00, 0x01, 0x03, 0x07, 0x0F, 0x1F, 0x3F, 0x7F }; MA_DR_FLAC_ASSERT(count <= 64); wholeBytes = count >> 3; leftoverBits = count & 7; leftoverDataMask = leftoverDataMaskTable[leftoverBits]; switch (wholeBytes) { default: case 4: crc = ma_dr_flac_crc16_byte(crc, (ma_uint8)((data & (0xFF000000UL << leftoverBits)) >> (24 + leftoverBits))); case 3: crc = ma_dr_flac_crc16_byte(crc, (ma_uint8)((data & (0x00FF0000UL << leftoverBits)) >> (16 + leftoverBits))); case 2: crc = ma_dr_flac_crc16_byte(crc, (ma_uint8)((data & (0x0000FF00UL << leftoverBits)) >> ( 8 + leftoverBits))); case 1: crc = ma_dr_flac_crc16_byte(crc, (ma_uint8)((data & (0x000000FFUL << leftoverBits)) >> ( 0 + leftoverBits))); case 0: if (leftoverBits > 0) crc = (crc << leftoverBits) ^ ma_dr_flac__crc16_table[(crc >> (16 - leftoverBits)) ^ (data & leftoverDataMask)]; } return crc; #endif #endif } static MA_INLINE ma_uint16 ma_dr_flac_crc16__64bit(ma_uint16 crc, ma_uint64 data, ma_uint32 count) { #ifdef MA_DR_FLAC_NO_CRC (void)crc; (void)data; (void)count; return 0; #else ma_uint32 wholeBytes; ma_uint32 leftoverBits; ma_uint64 leftoverDataMask; static ma_uint64 leftoverDataMaskTable[8] = { 0x00, 0x01, 0x03, 0x07, 0x0F, 0x1F, 0x3F, 0x7F }; MA_DR_FLAC_ASSERT(count <= 64); wholeBytes = count >> 3; leftoverBits = count & 7; leftoverDataMask = leftoverDataMaskTable[leftoverBits]; switch (wholeBytes) { default: case 8: crc = ma_dr_flac_crc16_byte(crc, (ma_uint8)((data & (((ma_uint64)0xFF000000 << 32) << leftoverBits)) >> (56 + leftoverBits))); case 7: crc = ma_dr_flac_crc16_byte(crc, (ma_uint8)((data & (((ma_uint64)0x00FF0000 << 32) << leftoverBits)) >> (48 + leftoverBits))); case 6: crc = ma_dr_flac_crc16_byte(crc, (ma_uint8)((data & (((ma_uint64)0x0000FF00 << 32) << leftoverBits)) >> (40 + leftoverBits))); case 5: crc = ma_dr_flac_crc16_byte(crc, (ma_uint8)((data & (((ma_uint64)0x000000FF << 32) << leftoverBits)) >> (32 + leftoverBits))); case 4: crc = ma_dr_flac_crc16_byte(crc, (ma_uint8)((data & (((ma_uint64)0xFF000000 ) << leftoverBits)) >> (24 + leftoverBits))); case 3: crc = ma_dr_flac_crc16_byte(crc, (ma_uint8)((data & (((ma_uint64)0x00FF0000 ) << leftoverBits)) >> (16 + leftoverBits))); case 2: crc = ma_dr_flac_crc16_byte(crc, (ma_uint8)((data & (((ma_uint64)0x0000FF00 ) << leftoverBits)) >> ( 8 + leftoverBits))); case 1: crc = ma_dr_flac_crc16_byte(crc, (ma_uint8)((data & (((ma_uint64)0x000000FF ) << leftoverBits)) >> ( 0 + leftoverBits))); case 0: if (leftoverBits > 0) crc = (crc << leftoverBits) ^ ma_dr_flac__crc16_table[(crc >> (16 - leftoverBits)) ^ (data & leftoverDataMask)]; } return crc; #endif } static MA_INLINE ma_uint16 ma_dr_flac_crc16(ma_uint16 crc, ma_dr_flac_cache_t data, ma_uint32 count) { #ifdef MA_64BIT return ma_dr_flac_crc16__64bit(crc, data, count); #else return ma_dr_flac_crc16__32bit(crc, data, count); #endif } #endif #ifdef MA_64BIT #define ma_dr_flac__be2host__cache_line ma_dr_flac__be2host_64 #else #define ma_dr_flac__be2host__cache_line ma_dr_flac__be2host_32 #endif #define MA_DR_FLAC_CACHE_L1_SIZE_BYTES(bs) (sizeof((bs)->cache)) #define MA_DR_FLAC_CACHE_L1_SIZE_BITS(bs) (sizeof((bs)->cache)*8) #define MA_DR_FLAC_CACHE_L1_BITS_REMAINING(bs) (MA_DR_FLAC_CACHE_L1_SIZE_BITS(bs) - (bs)->consumedBits) #define MA_DR_FLAC_CACHE_L1_SELECTION_MASK(_bitCount) (~((~(ma_dr_flac_cache_t)0) >> (_bitCount))) #define MA_DR_FLAC_CACHE_L1_SELECTION_SHIFT(bs, _bitCount) (MA_DR_FLAC_CACHE_L1_SIZE_BITS(bs) - (_bitCount)) #define MA_DR_FLAC_CACHE_L1_SELECT(bs, _bitCount) (((bs)->cache) & MA_DR_FLAC_CACHE_L1_SELECTION_MASK(_bitCount)) #define MA_DR_FLAC_CACHE_L1_SELECT_AND_SHIFT(bs, _bitCount) (MA_DR_FLAC_CACHE_L1_SELECT((bs), (_bitCount)) >> MA_DR_FLAC_CACHE_L1_SELECTION_SHIFT((bs), (_bitCount))) #define MA_DR_FLAC_CACHE_L1_SELECT_AND_SHIFT_SAFE(bs, _bitCount)(MA_DR_FLAC_CACHE_L1_SELECT((bs), (_bitCount)) >> (MA_DR_FLAC_CACHE_L1_SELECTION_SHIFT((bs), (_bitCount)) & (MA_DR_FLAC_CACHE_L1_SIZE_BITS(bs)-1))) #define MA_DR_FLAC_CACHE_L2_SIZE_BYTES(bs) (sizeof((bs)->cacheL2)) #define MA_DR_FLAC_CACHE_L2_LINE_COUNT(bs) (MA_DR_FLAC_CACHE_L2_SIZE_BYTES(bs) / sizeof((bs)->cacheL2[0])) #define MA_DR_FLAC_CACHE_L2_LINES_REMAINING(bs) (MA_DR_FLAC_CACHE_L2_LINE_COUNT(bs) - (bs)->nextL2Line) #ifndef MA_DR_FLAC_NO_CRC static MA_INLINE void ma_dr_flac__reset_crc16(ma_dr_flac_bs* bs) { bs->crc16 = 0; bs->crc16CacheIgnoredBytes = bs->consumedBits >> 3; } static MA_INLINE void ma_dr_flac__update_crc16(ma_dr_flac_bs* bs) { if (bs->crc16CacheIgnoredBytes == 0) { bs->crc16 = ma_dr_flac_crc16_cache(bs->crc16, bs->crc16Cache); } else { bs->crc16 = ma_dr_flac_crc16_bytes(bs->crc16, bs->crc16Cache, MA_DR_FLAC_CACHE_L1_SIZE_BYTES(bs) - bs->crc16CacheIgnoredBytes); bs->crc16CacheIgnoredBytes = 0; } } static MA_INLINE ma_uint16 ma_dr_flac__flush_crc16(ma_dr_flac_bs* bs) { MA_DR_FLAC_ASSERT((MA_DR_FLAC_CACHE_L1_BITS_REMAINING(bs) & 7) == 0); if (MA_DR_FLAC_CACHE_L1_BITS_REMAINING(bs) == 0) { ma_dr_flac__update_crc16(bs); } else { bs->crc16 = ma_dr_flac_crc16_bytes(bs->crc16, bs->crc16Cache >> MA_DR_FLAC_CACHE_L1_BITS_REMAINING(bs), (bs->consumedBits >> 3) - bs->crc16CacheIgnoredBytes); bs->crc16CacheIgnoredBytes = bs->consumedBits >> 3; } return bs->crc16; } #endif static MA_INLINE ma_bool32 ma_dr_flac__reload_l1_cache_from_l2(ma_dr_flac_bs* bs) { size_t bytesRead; size_t alignedL1LineCount; if (bs->nextL2Line < MA_DR_FLAC_CACHE_L2_LINE_COUNT(bs)) { bs->cache = bs->cacheL2[bs->nextL2Line++]; return MA_TRUE; } if (bs->unalignedByteCount > 0) { return MA_FALSE; } bytesRead = bs->onRead(bs->pUserData, bs->cacheL2, MA_DR_FLAC_CACHE_L2_SIZE_BYTES(bs)); bs->nextL2Line = 0; if (bytesRead == MA_DR_FLAC_CACHE_L2_SIZE_BYTES(bs)) { bs->cache = bs->cacheL2[bs->nextL2Line++]; return MA_TRUE; } alignedL1LineCount = bytesRead / MA_DR_FLAC_CACHE_L1_SIZE_BYTES(bs); bs->unalignedByteCount = bytesRead - (alignedL1LineCount * MA_DR_FLAC_CACHE_L1_SIZE_BYTES(bs)); if (bs->unalignedByteCount > 0) { bs->unalignedCache = bs->cacheL2[alignedL1LineCount]; } if (alignedL1LineCount > 0) { size_t offset = MA_DR_FLAC_CACHE_L2_LINE_COUNT(bs) - alignedL1LineCount; size_t i; for (i = alignedL1LineCount; i > 0; --i) { bs->cacheL2[i-1 + offset] = bs->cacheL2[i-1]; } bs->nextL2Line = (ma_uint32)offset; bs->cache = bs->cacheL2[bs->nextL2Line++]; return MA_TRUE; } else { bs->nextL2Line = MA_DR_FLAC_CACHE_L2_LINE_COUNT(bs); return MA_FALSE; } } static ma_bool32 ma_dr_flac__reload_cache(ma_dr_flac_bs* bs) { size_t bytesRead; #ifndef MA_DR_FLAC_NO_CRC ma_dr_flac__update_crc16(bs); #endif if (ma_dr_flac__reload_l1_cache_from_l2(bs)) { bs->cache = ma_dr_flac__be2host__cache_line(bs->cache); bs->consumedBits = 0; #ifndef MA_DR_FLAC_NO_CRC bs->crc16Cache = bs->cache; #endif return MA_TRUE; } bytesRead = bs->unalignedByteCount; if (bytesRead == 0) { bs->consumedBits = MA_DR_FLAC_CACHE_L1_SIZE_BITS(bs); return MA_FALSE; } MA_DR_FLAC_ASSERT(bytesRead < MA_DR_FLAC_CACHE_L1_SIZE_BYTES(bs)); bs->consumedBits = (ma_uint32)(MA_DR_FLAC_CACHE_L1_SIZE_BYTES(bs) - bytesRead) * 8; bs->cache = ma_dr_flac__be2host__cache_line(bs->unalignedCache); bs->cache &= MA_DR_FLAC_CACHE_L1_SELECTION_MASK(MA_DR_FLAC_CACHE_L1_BITS_REMAINING(bs)); bs->unalignedByteCount = 0; #ifndef MA_DR_FLAC_NO_CRC bs->crc16Cache = bs->cache >> bs->consumedBits; bs->crc16CacheIgnoredBytes = bs->consumedBits >> 3; #endif return MA_TRUE; } static void ma_dr_flac__reset_cache(ma_dr_flac_bs* bs) { bs->nextL2Line = MA_DR_FLAC_CACHE_L2_LINE_COUNT(bs); bs->consumedBits = MA_DR_FLAC_CACHE_L1_SIZE_BITS(bs); bs->cache = 0; bs->unalignedByteCount = 0; bs->unalignedCache = 0; #ifndef MA_DR_FLAC_NO_CRC bs->crc16Cache = 0; bs->crc16CacheIgnoredBytes = 0; #endif } static MA_INLINE ma_bool32 ma_dr_flac__read_uint32(ma_dr_flac_bs* bs, unsigned int bitCount, ma_uint32* pResultOut) { MA_DR_FLAC_ASSERT(bs != NULL); MA_DR_FLAC_ASSERT(pResultOut != NULL); MA_DR_FLAC_ASSERT(bitCount > 0); MA_DR_FLAC_ASSERT(bitCount <= 32); if (bs->consumedBits == MA_DR_FLAC_CACHE_L1_SIZE_BITS(bs)) { if (!ma_dr_flac__reload_cache(bs)) { return MA_FALSE; } } if (bitCount <= MA_DR_FLAC_CACHE_L1_BITS_REMAINING(bs)) { #ifdef MA_64BIT *pResultOut = (ma_uint32)MA_DR_FLAC_CACHE_L1_SELECT_AND_SHIFT(bs, bitCount); bs->consumedBits += bitCount; bs->cache <<= bitCount; #else if (bitCount < MA_DR_FLAC_CACHE_L1_SIZE_BITS(bs)) { *pResultOut = (ma_uint32)MA_DR_FLAC_CACHE_L1_SELECT_AND_SHIFT(bs, bitCount); bs->consumedBits += bitCount; bs->cache <<= bitCount; } else { *pResultOut = (ma_uint32)bs->cache; bs->consumedBits = MA_DR_FLAC_CACHE_L1_SIZE_BITS(bs); bs->cache = 0; } #endif return MA_TRUE; } else { ma_uint32 bitCountHi = MA_DR_FLAC_CACHE_L1_BITS_REMAINING(bs); ma_uint32 bitCountLo = bitCount - bitCountHi; ma_uint32 resultHi; MA_DR_FLAC_ASSERT(bitCountHi > 0); MA_DR_FLAC_ASSERT(bitCountHi < 32); resultHi = (ma_uint32)MA_DR_FLAC_CACHE_L1_SELECT_AND_SHIFT(bs, bitCountHi); if (!ma_dr_flac__reload_cache(bs)) { return MA_FALSE; } if (bitCountLo > MA_DR_FLAC_CACHE_L1_BITS_REMAINING(bs)) { return MA_FALSE; } *pResultOut = (resultHi << bitCountLo) | (ma_uint32)MA_DR_FLAC_CACHE_L1_SELECT_AND_SHIFT(bs, bitCountLo); bs->consumedBits += bitCountLo; bs->cache <<= bitCountLo; return MA_TRUE; } } static ma_bool32 ma_dr_flac__read_int32(ma_dr_flac_bs* bs, unsigned int bitCount, ma_int32* pResult) { ma_uint32 result; MA_DR_FLAC_ASSERT(bs != NULL); MA_DR_FLAC_ASSERT(pResult != NULL); MA_DR_FLAC_ASSERT(bitCount > 0); MA_DR_FLAC_ASSERT(bitCount <= 32); if (!ma_dr_flac__read_uint32(bs, bitCount, &result)) { return MA_FALSE; } if (bitCount < 32) { ma_uint32 signbit; signbit = ((result >> (bitCount-1)) & 0x01); result |= (~signbit + 1) << bitCount; } *pResult = (ma_int32)result; return MA_TRUE; } #ifdef MA_64BIT static ma_bool32 ma_dr_flac__read_uint64(ma_dr_flac_bs* bs, unsigned int bitCount, ma_uint64* pResultOut) { ma_uint32 resultHi; ma_uint32 resultLo; MA_DR_FLAC_ASSERT(bitCount <= 64); MA_DR_FLAC_ASSERT(bitCount > 32); if (!ma_dr_flac__read_uint32(bs, bitCount - 32, &resultHi)) { return MA_FALSE; } if (!ma_dr_flac__read_uint32(bs, 32, &resultLo)) { return MA_FALSE; } *pResultOut = (((ma_uint64)resultHi) << 32) | ((ma_uint64)resultLo); return MA_TRUE; } #endif #if 0 static ma_bool32 ma_dr_flac__read_int64(ma_dr_flac_bs* bs, unsigned int bitCount, ma_int64* pResultOut) { ma_uint64 result; ma_uint64 signbit; MA_DR_FLAC_ASSERT(bitCount <= 64); if (!ma_dr_flac__read_uint64(bs, bitCount, &result)) { return MA_FALSE; } signbit = ((result >> (bitCount-1)) & 0x01); result |= (~signbit + 1) << bitCount; *pResultOut = (ma_int64)result; return MA_TRUE; } #endif static ma_bool32 ma_dr_flac__read_uint16(ma_dr_flac_bs* bs, unsigned int bitCount, ma_uint16* pResult) { ma_uint32 result; MA_DR_FLAC_ASSERT(bs != NULL); MA_DR_FLAC_ASSERT(pResult != NULL); MA_DR_FLAC_ASSERT(bitCount > 0); MA_DR_FLAC_ASSERT(bitCount <= 16); if (!ma_dr_flac__read_uint32(bs, bitCount, &result)) { return MA_FALSE; } *pResult = (ma_uint16)result; return MA_TRUE; } #if 0 static ma_bool32 ma_dr_flac__read_int16(ma_dr_flac_bs* bs, unsigned int bitCount, ma_int16* pResult) { ma_int32 result; MA_DR_FLAC_ASSERT(bs != NULL); MA_DR_FLAC_ASSERT(pResult != NULL); MA_DR_FLAC_ASSERT(bitCount > 0); MA_DR_FLAC_ASSERT(bitCount <= 16); if (!ma_dr_flac__read_int32(bs, bitCount, &result)) { return MA_FALSE; } *pResult = (ma_int16)result; return MA_TRUE; } #endif static ma_bool32 ma_dr_flac__read_uint8(ma_dr_flac_bs* bs, unsigned int bitCount, ma_uint8* pResult) { ma_uint32 result; MA_DR_FLAC_ASSERT(bs != NULL); MA_DR_FLAC_ASSERT(pResult != NULL); MA_DR_FLAC_ASSERT(bitCount > 0); MA_DR_FLAC_ASSERT(bitCount <= 8); if (!ma_dr_flac__read_uint32(bs, bitCount, &result)) { return MA_FALSE; } *pResult = (ma_uint8)result; return MA_TRUE; } static ma_bool32 ma_dr_flac__read_int8(ma_dr_flac_bs* bs, unsigned int bitCount, ma_int8* pResult) { ma_int32 result; MA_DR_FLAC_ASSERT(bs != NULL); MA_DR_FLAC_ASSERT(pResult != NULL); MA_DR_FLAC_ASSERT(bitCount > 0); MA_DR_FLAC_ASSERT(bitCount <= 8); if (!ma_dr_flac__read_int32(bs, bitCount, &result)) { return MA_FALSE; } *pResult = (ma_int8)result; return MA_TRUE; } static ma_bool32 ma_dr_flac__seek_bits(ma_dr_flac_bs* bs, size_t bitsToSeek) { if (bitsToSeek <= MA_DR_FLAC_CACHE_L1_BITS_REMAINING(bs)) { bs->consumedBits += (ma_uint32)bitsToSeek; bs->cache <<= bitsToSeek; return MA_TRUE; } else { bitsToSeek -= MA_DR_FLAC_CACHE_L1_BITS_REMAINING(bs); bs->consumedBits += MA_DR_FLAC_CACHE_L1_BITS_REMAINING(bs); bs->cache = 0; #ifdef MA_64BIT while (bitsToSeek >= MA_DR_FLAC_CACHE_L1_SIZE_BITS(bs)) { ma_uint64 bin; if (!ma_dr_flac__read_uint64(bs, MA_DR_FLAC_CACHE_L1_SIZE_BITS(bs), &bin)) { return MA_FALSE; } bitsToSeek -= MA_DR_FLAC_CACHE_L1_SIZE_BITS(bs); } #else while (bitsToSeek >= MA_DR_FLAC_CACHE_L1_SIZE_BITS(bs)) { ma_uint32 bin; if (!ma_dr_flac__read_uint32(bs, MA_DR_FLAC_CACHE_L1_SIZE_BITS(bs), &bin)) { return MA_FALSE; } bitsToSeek -= MA_DR_FLAC_CACHE_L1_SIZE_BITS(bs); } #endif while (bitsToSeek >= 8) { ma_uint8 bin; if (!ma_dr_flac__read_uint8(bs, 8, &bin)) { return MA_FALSE; } bitsToSeek -= 8; } if (bitsToSeek > 0) { ma_uint8 bin; if (!ma_dr_flac__read_uint8(bs, (ma_uint32)bitsToSeek, &bin)) { return MA_FALSE; } bitsToSeek = 0; } MA_DR_FLAC_ASSERT(bitsToSeek == 0); return MA_TRUE; } } static ma_bool32 ma_dr_flac__find_and_seek_to_next_sync_code(ma_dr_flac_bs* bs) { MA_DR_FLAC_ASSERT(bs != NULL); if (!ma_dr_flac__seek_bits(bs, MA_DR_FLAC_CACHE_L1_BITS_REMAINING(bs) & 7)) { return MA_FALSE; } for (;;) { ma_uint8 hi; #ifndef MA_DR_FLAC_NO_CRC ma_dr_flac__reset_crc16(bs); #endif if (!ma_dr_flac__read_uint8(bs, 8, &hi)) { return MA_FALSE; } if (hi == 0xFF) { ma_uint8 lo; if (!ma_dr_flac__read_uint8(bs, 6, &lo)) { return MA_FALSE; } if (lo == 0x3E) { return MA_TRUE; } else { if (!ma_dr_flac__seek_bits(bs, MA_DR_FLAC_CACHE_L1_BITS_REMAINING(bs) & 7)) { return MA_FALSE; } } } } } #if defined(MA_DR_FLAC_HAS_LZCNT_INTRINSIC) #define MA_DR_FLAC_IMPLEMENT_CLZ_LZCNT #endif #if defined(_MSC_VER) && _MSC_VER >= 1400 && (defined(MA_X64) || defined(MA_X86)) && !defined(__clang__) #define MA_DR_FLAC_IMPLEMENT_CLZ_MSVC #endif #if defined(__WATCOMC__) && defined(__386__) #define MA_DR_FLAC_IMPLEMENT_CLZ_WATCOM #endif #ifdef __MRC__ #include #define MA_DR_FLAC_IMPLEMENT_CLZ_MRC #endif static MA_INLINE ma_uint32 ma_dr_flac__clz_software(ma_dr_flac_cache_t x) { ma_uint32 n; static ma_uint32 clz_table_4[] = { 0, 4, 3, 3, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1 }; if (x == 0) { return sizeof(x)*8; } n = clz_table_4[x >> (sizeof(x)*8 - 4)]; if (n == 0) { #ifdef MA_64BIT if ((x & ((ma_uint64)0xFFFFFFFF << 32)) == 0) { n = 32; x <<= 32; } if ((x & ((ma_uint64)0xFFFF0000 << 32)) == 0) { n += 16; x <<= 16; } if ((x & ((ma_uint64)0xFF000000 << 32)) == 0) { n += 8; x <<= 8; } if ((x & ((ma_uint64)0xF0000000 << 32)) == 0) { n += 4; x <<= 4; } #else if ((x & 0xFFFF0000) == 0) { n = 16; x <<= 16; } if ((x & 0xFF000000) == 0) { n += 8; x <<= 8; } if ((x & 0xF0000000) == 0) { n += 4; x <<= 4; } #endif n += clz_table_4[x >> (sizeof(x)*8 - 4)]; } return n - 1; } #ifdef MA_DR_FLAC_IMPLEMENT_CLZ_LZCNT static MA_INLINE ma_bool32 ma_dr_flac__is_lzcnt_supported(void) { #if defined(MA_DR_FLAC_HAS_LZCNT_INTRINSIC) && defined(MA_ARM) && (defined(__ARM_ARCH) && __ARM_ARCH >= 5) return MA_TRUE; #elif defined(__MRC__) return MA_TRUE; #else #ifdef MA_DR_FLAC_HAS_LZCNT_INTRINSIC return ma_dr_flac__gIsLZCNTSupported; #else return MA_FALSE; #endif #endif } static MA_INLINE ma_uint32 ma_dr_flac__clz_lzcnt(ma_dr_flac_cache_t x) { #if defined(_MSC_VER) #ifdef MA_64BIT return (ma_uint32)__lzcnt64(x); #else return (ma_uint32)__lzcnt(x); #endif #else #if defined(__GNUC__) || defined(__clang__) #if defined(MA_X64) { ma_uint64 r; __asm__ __volatile__ ( "lzcnt{ %1, %0| %0, %1}" : "=r"(r) : "r"(x) : "cc" ); return (ma_uint32)r; } #elif defined(MA_X86) { ma_uint32 r; __asm__ __volatile__ ( "lzcnt{l %1, %0| %0, %1}" : "=r"(r) : "r"(x) : "cc" ); return r; } #elif defined(MA_ARM) && (defined(__ARM_ARCH) && __ARM_ARCH >= 5) && !defined(__ARM_ARCH_6M__) && !defined(MA_64BIT) { unsigned int r; __asm__ __volatile__ ( #if defined(MA_64BIT) "clz %w[out], %w[in]" : [out]"=r"(r) : [in]"r"(x) #else "clz %[out], %[in]" : [out]"=r"(r) : [in]"r"(x) #endif ); return r; } #else if (x == 0) { return sizeof(x)*8; } #ifdef MA_64BIT return (ma_uint32)__builtin_clzll((ma_uint64)x); #else return (ma_uint32)__builtin_clzl((ma_uint32)x); #endif #endif #else #error "This compiler does not support the lzcnt intrinsic." #endif #endif } #endif #ifdef MA_DR_FLAC_IMPLEMENT_CLZ_MSVC #include static MA_INLINE ma_uint32 ma_dr_flac__clz_msvc(ma_dr_flac_cache_t x) { ma_uint32 n; if (x == 0) { return sizeof(x)*8; } #ifdef MA_64BIT _BitScanReverse64((unsigned long*)&n, x); #else _BitScanReverse((unsigned long*)&n, x); #endif return sizeof(x)*8 - n - 1; } #endif #ifdef MA_DR_FLAC_IMPLEMENT_CLZ_WATCOM static __inline ma_uint32 ma_dr_flac__clz_watcom (ma_uint32); #ifdef MA_DR_FLAC_IMPLEMENT_CLZ_WATCOM_LZCNT #pragma aux ma_dr_flac__clz_watcom_lzcnt = \ "db 0F3h, 0Fh, 0BDh, 0C0h" \ parm [eax] \ value [eax] \ modify nomemory; #else #pragma aux ma_dr_flac__clz_watcom = \ "bsr eax, eax" \ "xor eax, 31" \ parm [eax] nomemory \ value [eax] \ modify exact [eax] nomemory; #endif #endif static MA_INLINE ma_uint32 ma_dr_flac__clz(ma_dr_flac_cache_t x) { #ifdef MA_DR_FLAC_IMPLEMENT_CLZ_LZCNT if (ma_dr_flac__is_lzcnt_supported()) { return ma_dr_flac__clz_lzcnt(x); } else #endif { #ifdef MA_DR_FLAC_IMPLEMENT_CLZ_MSVC return ma_dr_flac__clz_msvc(x); #elif defined(MA_DR_FLAC_IMPLEMENT_CLZ_WATCOM_LZCNT) return ma_dr_flac__clz_watcom_lzcnt(x); #elif defined(MA_DR_FLAC_IMPLEMENT_CLZ_WATCOM) return (x == 0) ? sizeof(x)*8 : ma_dr_flac__clz_watcom(x); #elif defined(__MRC__) return __cntlzw(x); #else return ma_dr_flac__clz_software(x); #endif } } static MA_INLINE ma_bool32 ma_dr_flac__seek_past_next_set_bit(ma_dr_flac_bs* bs, unsigned int* pOffsetOut) { ma_uint32 zeroCounter = 0; ma_uint32 setBitOffsetPlus1; while (bs->cache == 0) { zeroCounter += (ma_uint32)MA_DR_FLAC_CACHE_L1_BITS_REMAINING(bs); if (!ma_dr_flac__reload_cache(bs)) { return MA_FALSE; } } if (bs->cache == 1) { *pOffsetOut = zeroCounter + (ma_uint32)MA_DR_FLAC_CACHE_L1_BITS_REMAINING(bs) - 1; if (!ma_dr_flac__reload_cache(bs)) { return MA_FALSE; } return MA_TRUE; } setBitOffsetPlus1 = ma_dr_flac__clz(bs->cache); setBitOffsetPlus1 += 1; if (setBitOffsetPlus1 > MA_DR_FLAC_CACHE_L1_BITS_REMAINING(bs)) { return MA_FALSE; } bs->consumedBits += setBitOffsetPlus1; bs->cache <<= setBitOffsetPlus1; *pOffsetOut = zeroCounter + setBitOffsetPlus1 - 1; return MA_TRUE; } static ma_bool32 ma_dr_flac__seek_to_byte(ma_dr_flac_bs* bs, ma_uint64 offsetFromStart) { MA_DR_FLAC_ASSERT(bs != NULL); MA_DR_FLAC_ASSERT(offsetFromStart > 0); if (offsetFromStart > 0x7FFFFFFF) { ma_uint64 bytesRemaining = offsetFromStart; if (!bs->onSeek(bs->pUserData, 0x7FFFFFFF, ma_dr_flac_seek_origin_start)) { return MA_FALSE; } bytesRemaining -= 0x7FFFFFFF; while (bytesRemaining > 0x7FFFFFFF) { if (!bs->onSeek(bs->pUserData, 0x7FFFFFFF, ma_dr_flac_seek_origin_current)) { return MA_FALSE; } bytesRemaining -= 0x7FFFFFFF; } if (bytesRemaining > 0) { if (!bs->onSeek(bs->pUserData, (int)bytesRemaining, ma_dr_flac_seek_origin_current)) { return MA_FALSE; } } } else { if (!bs->onSeek(bs->pUserData, (int)offsetFromStart, ma_dr_flac_seek_origin_start)) { return MA_FALSE; } } ma_dr_flac__reset_cache(bs); return MA_TRUE; } static ma_result ma_dr_flac__read_utf8_coded_number(ma_dr_flac_bs* bs, ma_uint64* pNumberOut, ma_uint8* pCRCOut) { ma_uint8 crc; ma_uint64 result; ma_uint8 utf8[7] = {0}; int byteCount; int i; MA_DR_FLAC_ASSERT(bs != NULL); MA_DR_FLAC_ASSERT(pNumberOut != NULL); MA_DR_FLAC_ASSERT(pCRCOut != NULL); crc = *pCRCOut; if (!ma_dr_flac__read_uint8(bs, 8, utf8)) { *pNumberOut = 0; return MA_AT_END; } crc = ma_dr_flac_crc8(crc, utf8[0], 8); if ((utf8[0] & 0x80) == 0) { *pNumberOut = utf8[0]; *pCRCOut = crc; return MA_SUCCESS; } if ((utf8[0] & 0xE0) == 0xC0) { byteCount = 2; } else if ((utf8[0] & 0xF0) == 0xE0) { byteCount = 3; } else if ((utf8[0] & 0xF8) == 0xF0) { byteCount = 4; } else if ((utf8[0] & 0xFC) == 0xF8) { byteCount = 5; } else if ((utf8[0] & 0xFE) == 0xFC) { byteCount = 6; } else if ((utf8[0] & 0xFF) == 0xFE) { byteCount = 7; } else { *pNumberOut = 0; return MA_CRC_MISMATCH; } MA_DR_FLAC_ASSERT(byteCount > 1); result = (ma_uint64)(utf8[0] & (0xFF >> (byteCount + 1))); for (i = 1; i < byteCount; ++i) { if (!ma_dr_flac__read_uint8(bs, 8, utf8 + i)) { *pNumberOut = 0; return MA_AT_END; } crc = ma_dr_flac_crc8(crc, utf8[i], 8); result = (result << 6) | (utf8[i] & 0x3F); } *pNumberOut = result; *pCRCOut = crc; return MA_SUCCESS; } static MA_INLINE ma_uint32 ma_dr_flac__ilog2_u32(ma_uint32 x) { #if 1 ma_uint32 result = 0; while (x > 0) { result += 1; x >>= 1; } return result; #endif } static MA_INLINE ma_bool32 ma_dr_flac__use_64_bit_prediction(ma_uint32 bitsPerSample, ma_uint32 order, ma_uint32 precision) { return bitsPerSample + precision + ma_dr_flac__ilog2_u32(order) > 32; } #if defined(__clang__) __attribute__((no_sanitize("signed-integer-overflow"))) #endif static MA_INLINE ma_int32 ma_dr_flac__calculate_prediction_32(ma_uint32 order, ma_int32 shift, const ma_int32* coefficients, ma_int32* pDecodedSamples) { ma_int32 prediction = 0; MA_DR_FLAC_ASSERT(order <= 32); switch (order) { case 32: prediction += coefficients[31] * pDecodedSamples[-32]; case 31: prediction += coefficients[30] * pDecodedSamples[-31]; case 30: prediction += coefficients[29] * pDecodedSamples[-30]; case 29: prediction += coefficients[28] * pDecodedSamples[-29]; case 28: prediction += coefficients[27] * pDecodedSamples[-28]; case 27: prediction += coefficients[26] * pDecodedSamples[-27]; case 26: prediction += coefficients[25] * pDecodedSamples[-26]; case 25: prediction += coefficients[24] * pDecodedSamples[-25]; case 24: prediction += coefficients[23] * pDecodedSamples[-24]; case 23: prediction += coefficients[22] * pDecodedSamples[-23]; case 22: prediction += coefficients[21] * pDecodedSamples[-22]; case 21: prediction += coefficients[20] * pDecodedSamples[-21]; case 20: prediction += coefficients[19] * pDecodedSamples[-20]; case 19: prediction += coefficients[18] * pDecodedSamples[-19]; case 18: prediction += coefficients[17] * pDecodedSamples[-18]; case 17: prediction += coefficients[16] * pDecodedSamples[-17]; case 16: prediction += coefficients[15] * pDecodedSamples[-16]; case 15: prediction += coefficients[14] * pDecodedSamples[-15]; case 14: prediction += coefficients[13] * pDecodedSamples[-14]; case 13: prediction += coefficients[12] * pDecodedSamples[-13]; case 12: prediction += coefficients[11] * pDecodedSamples[-12]; case 11: prediction += coefficients[10] * pDecodedSamples[-11]; case 10: prediction += coefficients[ 9] * pDecodedSamples[-10]; case 9: prediction += coefficients[ 8] * pDecodedSamples[- 9]; case 8: prediction += coefficients[ 7] * pDecodedSamples[- 8]; case 7: prediction += coefficients[ 6] * pDecodedSamples[- 7]; case 6: prediction += coefficients[ 5] * pDecodedSamples[- 6]; case 5: prediction += coefficients[ 4] * pDecodedSamples[- 5]; case 4: prediction += coefficients[ 3] * pDecodedSamples[- 4]; case 3: prediction += coefficients[ 2] * pDecodedSamples[- 3]; case 2: prediction += coefficients[ 1] * pDecodedSamples[- 2]; case 1: prediction += coefficients[ 0] * pDecodedSamples[- 1]; } return (ma_int32)(prediction >> shift); } static MA_INLINE ma_int32 ma_dr_flac__calculate_prediction_64(ma_uint32 order, ma_int32 shift, const ma_int32* coefficients, ma_int32* pDecodedSamples) { ma_int64 prediction; MA_DR_FLAC_ASSERT(order <= 32); #ifndef MA_64BIT if (order == 8) { prediction = coefficients[0] * (ma_int64)pDecodedSamples[-1]; prediction += coefficients[1] * (ma_int64)pDecodedSamples[-2]; prediction += coefficients[2] * (ma_int64)pDecodedSamples[-3]; prediction += coefficients[3] * (ma_int64)pDecodedSamples[-4]; prediction += coefficients[4] * (ma_int64)pDecodedSamples[-5]; prediction += coefficients[5] * (ma_int64)pDecodedSamples[-6]; prediction += coefficients[6] * (ma_int64)pDecodedSamples[-7]; prediction += coefficients[7] * (ma_int64)pDecodedSamples[-8]; } else if (order == 7) { prediction = coefficients[0] * (ma_int64)pDecodedSamples[-1]; prediction += coefficients[1] * (ma_int64)pDecodedSamples[-2]; prediction += coefficients[2] * (ma_int64)pDecodedSamples[-3]; prediction += coefficients[3] * (ma_int64)pDecodedSamples[-4]; prediction += coefficients[4] * (ma_int64)pDecodedSamples[-5]; prediction += coefficients[5] * (ma_int64)pDecodedSamples[-6]; prediction += coefficients[6] * (ma_int64)pDecodedSamples[-7]; } else if (order == 3) { prediction = coefficients[0] * (ma_int64)pDecodedSamples[-1]; prediction += coefficients[1] * (ma_int64)pDecodedSamples[-2]; prediction += coefficients[2] * (ma_int64)pDecodedSamples[-3]; } else if (order == 6) { prediction = coefficients[0] * (ma_int64)pDecodedSamples[-1]; prediction += coefficients[1] * (ma_int64)pDecodedSamples[-2]; prediction += coefficients[2] * (ma_int64)pDecodedSamples[-3]; prediction += coefficients[3] * (ma_int64)pDecodedSamples[-4]; prediction += coefficients[4] * (ma_int64)pDecodedSamples[-5]; prediction += coefficients[5] * (ma_int64)pDecodedSamples[-6]; } else if (order == 5) { prediction = coefficients[0] * (ma_int64)pDecodedSamples[-1]; prediction += coefficients[1] * (ma_int64)pDecodedSamples[-2]; prediction += coefficients[2] * (ma_int64)pDecodedSamples[-3]; prediction += coefficients[3] * (ma_int64)pDecodedSamples[-4]; prediction += coefficients[4] * (ma_int64)pDecodedSamples[-5]; } else if (order == 4) { prediction = coefficients[0] * (ma_int64)pDecodedSamples[-1]; prediction += coefficients[1] * (ma_int64)pDecodedSamples[-2]; prediction += coefficients[2] * (ma_int64)pDecodedSamples[-3]; prediction += coefficients[3] * (ma_int64)pDecodedSamples[-4]; } else if (order == 12) { prediction = coefficients[0] * (ma_int64)pDecodedSamples[-1]; prediction += coefficients[1] * (ma_int64)pDecodedSamples[-2]; prediction += coefficients[2] * (ma_int64)pDecodedSamples[-3]; prediction += coefficients[3] * (ma_int64)pDecodedSamples[-4]; prediction += coefficients[4] * (ma_int64)pDecodedSamples[-5]; prediction += coefficients[5] * (ma_int64)pDecodedSamples[-6]; prediction += coefficients[6] * (ma_int64)pDecodedSamples[-7]; prediction += coefficients[7] * (ma_int64)pDecodedSamples[-8]; prediction += coefficients[8] * (ma_int64)pDecodedSamples[-9]; prediction += coefficients[9] * (ma_int64)pDecodedSamples[-10]; prediction += coefficients[10] * (ma_int64)pDecodedSamples[-11]; prediction += coefficients[11] * (ma_int64)pDecodedSamples[-12]; } else if (order == 2) { prediction = coefficients[0] * (ma_int64)pDecodedSamples[-1]; prediction += coefficients[1] * (ma_int64)pDecodedSamples[-2]; } else if (order == 1) { prediction = coefficients[0] * (ma_int64)pDecodedSamples[-1]; } else if (order == 10) { prediction = coefficients[0] * (ma_int64)pDecodedSamples[-1]; prediction += coefficients[1] * (ma_int64)pDecodedSamples[-2]; prediction += coefficients[2] * (ma_int64)pDecodedSamples[-3]; prediction += coefficients[3] * (ma_int64)pDecodedSamples[-4]; prediction += coefficients[4] * (ma_int64)pDecodedSamples[-5]; prediction += coefficients[5] * (ma_int64)pDecodedSamples[-6]; prediction += coefficients[6] * (ma_int64)pDecodedSamples[-7]; prediction += coefficients[7] * (ma_int64)pDecodedSamples[-8]; prediction += coefficients[8] * (ma_int64)pDecodedSamples[-9]; prediction += coefficients[9] * (ma_int64)pDecodedSamples[-10]; } else if (order == 9) { prediction = coefficients[0] * (ma_int64)pDecodedSamples[-1]; prediction += coefficients[1] * (ma_int64)pDecodedSamples[-2]; prediction += coefficients[2] * (ma_int64)pDecodedSamples[-3]; prediction += coefficients[3] * (ma_int64)pDecodedSamples[-4]; prediction += coefficients[4] * (ma_int64)pDecodedSamples[-5]; prediction += coefficients[5] * (ma_int64)pDecodedSamples[-6]; prediction += coefficients[6] * (ma_int64)pDecodedSamples[-7]; prediction += coefficients[7] * (ma_int64)pDecodedSamples[-8]; prediction += coefficients[8] * (ma_int64)pDecodedSamples[-9]; } else if (order == 11) { prediction = coefficients[0] * (ma_int64)pDecodedSamples[-1]; prediction += coefficients[1] * (ma_int64)pDecodedSamples[-2]; prediction += coefficients[2] * (ma_int64)pDecodedSamples[-3]; prediction += coefficients[3] * (ma_int64)pDecodedSamples[-4]; prediction += coefficients[4] * (ma_int64)pDecodedSamples[-5]; prediction += coefficients[5] * (ma_int64)pDecodedSamples[-6]; prediction += coefficients[6] * (ma_int64)pDecodedSamples[-7]; prediction += coefficients[7] * (ma_int64)pDecodedSamples[-8]; prediction += coefficients[8] * (ma_int64)pDecodedSamples[-9]; prediction += coefficients[9] * (ma_int64)pDecodedSamples[-10]; prediction += coefficients[10] * (ma_int64)pDecodedSamples[-11]; } else { int j; prediction = 0; for (j = 0; j < (int)order; ++j) { prediction += coefficients[j] * (ma_int64)pDecodedSamples[-j-1]; } } #endif #ifdef MA_64BIT prediction = 0; switch (order) { case 32: prediction += coefficients[31] * (ma_int64)pDecodedSamples[-32]; case 31: prediction += coefficients[30] * (ma_int64)pDecodedSamples[-31]; case 30: prediction += coefficients[29] * (ma_int64)pDecodedSamples[-30]; case 29: prediction += coefficients[28] * (ma_int64)pDecodedSamples[-29]; case 28: prediction += coefficients[27] * (ma_int64)pDecodedSamples[-28]; case 27: prediction += coefficients[26] * (ma_int64)pDecodedSamples[-27]; case 26: prediction += coefficients[25] * (ma_int64)pDecodedSamples[-26]; case 25: prediction += coefficients[24] * (ma_int64)pDecodedSamples[-25]; case 24: prediction += coefficients[23] * (ma_int64)pDecodedSamples[-24]; case 23: prediction += coefficients[22] * (ma_int64)pDecodedSamples[-23]; case 22: prediction += coefficients[21] * (ma_int64)pDecodedSamples[-22]; case 21: prediction += coefficients[20] * (ma_int64)pDecodedSamples[-21]; case 20: prediction += coefficients[19] * (ma_int64)pDecodedSamples[-20]; case 19: prediction += coefficients[18] * (ma_int64)pDecodedSamples[-19]; case 18: prediction += coefficients[17] * (ma_int64)pDecodedSamples[-18]; case 17: prediction += coefficients[16] * (ma_int64)pDecodedSamples[-17]; case 16: prediction += coefficients[15] * (ma_int64)pDecodedSamples[-16]; case 15: prediction += coefficients[14] * (ma_int64)pDecodedSamples[-15]; case 14: prediction += coefficients[13] * (ma_int64)pDecodedSamples[-14]; case 13: prediction += coefficients[12] * (ma_int64)pDecodedSamples[-13]; case 12: prediction += coefficients[11] * (ma_int64)pDecodedSamples[-12]; case 11: prediction += coefficients[10] * (ma_int64)pDecodedSamples[-11]; case 10: prediction += coefficients[ 9] * (ma_int64)pDecodedSamples[-10]; case 9: prediction += coefficients[ 8] * (ma_int64)pDecodedSamples[- 9]; case 8: prediction += coefficients[ 7] * (ma_int64)pDecodedSamples[- 8]; case 7: prediction += coefficients[ 6] * (ma_int64)pDecodedSamples[- 7]; case 6: prediction += coefficients[ 5] * (ma_int64)pDecodedSamples[- 6]; case 5: prediction += coefficients[ 4] * (ma_int64)pDecodedSamples[- 5]; case 4: prediction += coefficients[ 3] * (ma_int64)pDecodedSamples[- 4]; case 3: prediction += coefficients[ 2] * (ma_int64)pDecodedSamples[- 3]; case 2: prediction += coefficients[ 1] * (ma_int64)pDecodedSamples[- 2]; case 1: prediction += coefficients[ 0] * (ma_int64)pDecodedSamples[- 1]; } #endif return (ma_int32)(prediction >> shift); } #if 0 static ma_bool32 ma_dr_flac__decode_samples_with_residual__rice__reference(ma_dr_flac_bs* bs, ma_uint32 bitsPerSample, ma_uint32 count, ma_uint8 riceParam, ma_uint32 lpcOrder, ma_int32 lpcShift, ma_uint32 lpcPrecision, const ma_int32* coefficients, ma_int32* pSamplesOut) { ma_uint32 i; MA_DR_FLAC_ASSERT(bs != NULL); MA_DR_FLAC_ASSERT(pSamplesOut != NULL); for (i = 0; i < count; ++i) { ma_uint32 zeroCounter = 0; for (;;) { ma_uint8 bit; if (!ma_dr_flac__read_uint8(bs, 1, &bit)) { return MA_FALSE; } if (bit == 0) { zeroCounter += 1; } else { break; } } ma_uint32 decodedRice; if (riceParam > 0) { if (!ma_dr_flac__read_uint32(bs, riceParam, &decodedRice)) { return MA_FALSE; } } else { decodedRice = 0; } decodedRice |= (zeroCounter << riceParam); if ((decodedRice & 0x01)) { decodedRice = ~(decodedRice >> 1); } else { decodedRice = (decodedRice >> 1); } if (ma_dr_flac__use_64_bit_prediction(bitsPerSample, lpcOrder, lpcPrecision)) { pSamplesOut[i] = decodedRice + ma_dr_flac__calculate_prediction_64(lpcOrder, lpcShift, coefficients, pSamplesOut + i); } else { pSamplesOut[i] = decodedRice + ma_dr_flac__calculate_prediction_32(lpcOrder, lpcShift, coefficients, pSamplesOut + i); } } return MA_TRUE; } #endif #if 0 static ma_bool32 ma_dr_flac__read_rice_parts__reference(ma_dr_flac_bs* bs, ma_uint8 riceParam, ma_uint32* pZeroCounterOut, ma_uint32* pRiceParamPartOut) { ma_uint32 zeroCounter = 0; ma_uint32 decodedRice; for (;;) { ma_uint8 bit; if (!ma_dr_flac__read_uint8(bs, 1, &bit)) { return MA_FALSE; } if (bit == 0) { zeroCounter += 1; } else { break; } } if (riceParam > 0) { if (!ma_dr_flac__read_uint32(bs, riceParam, &decodedRice)) { return MA_FALSE; } } else { decodedRice = 0; } *pZeroCounterOut = zeroCounter; *pRiceParamPartOut = decodedRice; return MA_TRUE; } #endif #if 0 static MA_INLINE ma_bool32 ma_dr_flac__read_rice_parts(ma_dr_flac_bs* bs, ma_uint8 riceParam, ma_uint32* pZeroCounterOut, ma_uint32* pRiceParamPartOut) { ma_dr_flac_cache_t riceParamMask; ma_uint32 zeroCounter; ma_uint32 setBitOffsetPlus1; ma_uint32 riceParamPart; ma_uint32 riceLength; MA_DR_FLAC_ASSERT(riceParam > 0); riceParamMask = MA_DR_FLAC_CACHE_L1_SELECTION_MASK(riceParam); zeroCounter = 0; while (bs->cache == 0) { zeroCounter += (ma_uint32)MA_DR_FLAC_CACHE_L1_BITS_REMAINING(bs); if (!ma_dr_flac__reload_cache(bs)) { return MA_FALSE; } } setBitOffsetPlus1 = ma_dr_flac__clz(bs->cache); zeroCounter += setBitOffsetPlus1; setBitOffsetPlus1 += 1; riceLength = setBitOffsetPlus1 + riceParam; if (riceLength < MA_DR_FLAC_CACHE_L1_BITS_REMAINING(bs)) { riceParamPart = (ma_uint32)((bs->cache & (riceParamMask >> setBitOffsetPlus1)) >> MA_DR_FLAC_CACHE_L1_SELECTION_SHIFT(bs, riceLength)); bs->consumedBits += riceLength; bs->cache <<= riceLength; } else { ma_uint32 bitCountLo; ma_dr_flac_cache_t resultHi; bs->consumedBits += riceLength; bs->cache <<= setBitOffsetPlus1 & (MA_DR_FLAC_CACHE_L1_SIZE_BITS(bs)-1); bitCountLo = bs->consumedBits - MA_DR_FLAC_CACHE_L1_SIZE_BITS(bs); resultHi = MA_DR_FLAC_CACHE_L1_SELECT_AND_SHIFT(bs, riceParam); if (bs->nextL2Line < MA_DR_FLAC_CACHE_L2_LINE_COUNT(bs)) { #ifndef MA_DR_FLAC_NO_CRC ma_dr_flac__update_crc16(bs); #endif bs->cache = ma_dr_flac__be2host__cache_line(bs->cacheL2[bs->nextL2Line++]); bs->consumedBits = 0; #ifndef MA_DR_FLAC_NO_CRC bs->crc16Cache = bs->cache; #endif } else { if (!ma_dr_flac__reload_cache(bs)) { return MA_FALSE; } if (bitCountLo > MA_DR_FLAC_CACHE_L1_BITS_REMAINING(bs)) { return MA_FALSE; } } riceParamPart = (ma_uint32)(resultHi | MA_DR_FLAC_CACHE_L1_SELECT_AND_SHIFT_SAFE(bs, bitCountLo)); bs->consumedBits += bitCountLo; bs->cache <<= bitCountLo; } pZeroCounterOut[0] = zeroCounter; pRiceParamPartOut[0] = riceParamPart; return MA_TRUE; } #endif static MA_INLINE ma_bool32 ma_dr_flac__read_rice_parts_x1(ma_dr_flac_bs* bs, ma_uint8 riceParam, ma_uint32* pZeroCounterOut, ma_uint32* pRiceParamPartOut) { ma_uint32 riceParamPlus1 = riceParam + 1; ma_uint32 riceParamPlus1Shift = MA_DR_FLAC_CACHE_L1_SELECTION_SHIFT(bs, riceParamPlus1); ma_uint32 riceParamPlus1MaxConsumedBits = MA_DR_FLAC_CACHE_L1_SIZE_BITS(bs) - riceParamPlus1; ma_dr_flac_cache_t bs_cache = bs->cache; ma_uint32 bs_consumedBits = bs->consumedBits; ma_uint32 lzcount = ma_dr_flac__clz(bs_cache); if (lzcount < sizeof(bs_cache)*8) { pZeroCounterOut[0] = lzcount; extract_rice_param_part: bs_cache <<= lzcount; bs_consumedBits += lzcount; if (bs_consumedBits <= riceParamPlus1MaxConsumedBits) { pRiceParamPartOut[0] = (ma_uint32)(bs_cache >> riceParamPlus1Shift); bs_cache <<= riceParamPlus1; bs_consumedBits += riceParamPlus1; } else { ma_uint32 riceParamPartHi; ma_uint32 riceParamPartLo; ma_uint32 riceParamPartLoBitCount; riceParamPartHi = (ma_uint32)(bs_cache >> riceParamPlus1Shift); riceParamPartLoBitCount = bs_consumedBits - riceParamPlus1MaxConsumedBits; MA_DR_FLAC_ASSERT(riceParamPartLoBitCount > 0 && riceParamPartLoBitCount < 32); if (bs->nextL2Line < MA_DR_FLAC_CACHE_L2_LINE_COUNT(bs)) { #ifndef MA_DR_FLAC_NO_CRC ma_dr_flac__update_crc16(bs); #endif bs_cache = ma_dr_flac__be2host__cache_line(bs->cacheL2[bs->nextL2Line++]); bs_consumedBits = riceParamPartLoBitCount; #ifndef MA_DR_FLAC_NO_CRC bs->crc16Cache = bs_cache; #endif } else { if (!ma_dr_flac__reload_cache(bs)) { return MA_FALSE; } if (riceParamPartLoBitCount > MA_DR_FLAC_CACHE_L1_BITS_REMAINING(bs)) { return MA_FALSE; } bs_cache = bs->cache; bs_consumedBits = bs->consumedBits + riceParamPartLoBitCount; } riceParamPartLo = (ma_uint32)(bs_cache >> (MA_DR_FLAC_CACHE_L1_SELECTION_SHIFT(bs, riceParamPartLoBitCount))); pRiceParamPartOut[0] = riceParamPartHi | riceParamPartLo; bs_cache <<= riceParamPartLoBitCount; } } else { ma_uint32 zeroCounter = (ma_uint32)(MA_DR_FLAC_CACHE_L1_SIZE_BITS(bs) - bs_consumedBits); for (;;) { if (bs->nextL2Line < MA_DR_FLAC_CACHE_L2_LINE_COUNT(bs)) { #ifndef MA_DR_FLAC_NO_CRC ma_dr_flac__update_crc16(bs); #endif bs_cache = ma_dr_flac__be2host__cache_line(bs->cacheL2[bs->nextL2Line++]); bs_consumedBits = 0; #ifndef MA_DR_FLAC_NO_CRC bs->crc16Cache = bs_cache; #endif } else { if (!ma_dr_flac__reload_cache(bs)) { return MA_FALSE; } bs_cache = bs->cache; bs_consumedBits = bs->consumedBits; } lzcount = ma_dr_flac__clz(bs_cache); zeroCounter += lzcount; if (lzcount < sizeof(bs_cache)*8) { break; } } pZeroCounterOut[0] = zeroCounter; goto extract_rice_param_part; } bs->cache = bs_cache; bs->consumedBits = bs_consumedBits; return MA_TRUE; } static MA_INLINE ma_bool32 ma_dr_flac__seek_rice_parts(ma_dr_flac_bs* bs, ma_uint8 riceParam) { ma_uint32 riceParamPlus1 = riceParam + 1; ma_uint32 riceParamPlus1MaxConsumedBits = MA_DR_FLAC_CACHE_L1_SIZE_BITS(bs) - riceParamPlus1; ma_dr_flac_cache_t bs_cache = bs->cache; ma_uint32 bs_consumedBits = bs->consumedBits; ma_uint32 lzcount = ma_dr_flac__clz(bs_cache); if (lzcount < sizeof(bs_cache)*8) { extract_rice_param_part: bs_cache <<= lzcount; bs_consumedBits += lzcount; if (bs_consumedBits <= riceParamPlus1MaxConsumedBits) { bs_cache <<= riceParamPlus1; bs_consumedBits += riceParamPlus1; } else { ma_uint32 riceParamPartLoBitCount = bs_consumedBits - riceParamPlus1MaxConsumedBits; MA_DR_FLAC_ASSERT(riceParamPartLoBitCount > 0 && riceParamPartLoBitCount < 32); if (bs->nextL2Line < MA_DR_FLAC_CACHE_L2_LINE_COUNT(bs)) { #ifndef MA_DR_FLAC_NO_CRC ma_dr_flac__update_crc16(bs); #endif bs_cache = ma_dr_flac__be2host__cache_line(bs->cacheL2[bs->nextL2Line++]); bs_consumedBits = riceParamPartLoBitCount; #ifndef MA_DR_FLAC_NO_CRC bs->crc16Cache = bs_cache; #endif } else { if (!ma_dr_flac__reload_cache(bs)) { return MA_FALSE; } if (riceParamPartLoBitCount > MA_DR_FLAC_CACHE_L1_BITS_REMAINING(bs)) { return MA_FALSE; } bs_cache = bs->cache; bs_consumedBits = bs->consumedBits + riceParamPartLoBitCount; } bs_cache <<= riceParamPartLoBitCount; } } else { for (;;) { if (bs->nextL2Line < MA_DR_FLAC_CACHE_L2_LINE_COUNT(bs)) { #ifndef MA_DR_FLAC_NO_CRC ma_dr_flac__update_crc16(bs); #endif bs_cache = ma_dr_flac__be2host__cache_line(bs->cacheL2[bs->nextL2Line++]); bs_consumedBits = 0; #ifndef MA_DR_FLAC_NO_CRC bs->crc16Cache = bs_cache; #endif } else { if (!ma_dr_flac__reload_cache(bs)) { return MA_FALSE; } bs_cache = bs->cache; bs_consumedBits = bs->consumedBits; } lzcount = ma_dr_flac__clz(bs_cache); if (lzcount < sizeof(bs_cache)*8) { break; } } goto extract_rice_param_part; } bs->cache = bs_cache; bs->consumedBits = bs_consumedBits; return MA_TRUE; } static ma_bool32 ma_dr_flac__decode_samples_with_residual__rice__scalar_zeroorder(ma_dr_flac_bs* bs, ma_uint32 bitsPerSample, ma_uint32 count, ma_uint8 riceParam, ma_uint32 order, ma_int32 shift, const ma_int32* coefficients, ma_int32* pSamplesOut) { ma_uint32 t[2] = {0x00000000, 0xFFFFFFFF}; ma_uint32 zeroCountPart0; ma_uint32 riceParamPart0; ma_uint32 riceParamMask; ma_uint32 i; MA_DR_FLAC_ASSERT(bs != NULL); MA_DR_FLAC_ASSERT(pSamplesOut != NULL); (void)bitsPerSample; (void)order; (void)shift; (void)coefficients; riceParamMask = (ma_uint32)~((~0UL) << riceParam); i = 0; while (i < count) { if (!ma_dr_flac__read_rice_parts_x1(bs, riceParam, &zeroCountPart0, &riceParamPart0)) { return MA_FALSE; } riceParamPart0 &= riceParamMask; riceParamPart0 |= (zeroCountPart0 << riceParam); riceParamPart0 = (riceParamPart0 >> 1) ^ t[riceParamPart0 & 0x01]; pSamplesOut[i] = riceParamPart0; i += 1; } return MA_TRUE; } static ma_bool32 ma_dr_flac__decode_samples_with_residual__rice__scalar(ma_dr_flac_bs* bs, ma_uint32 bitsPerSample, ma_uint32 count, ma_uint8 riceParam, ma_uint32 lpcOrder, ma_int32 lpcShift, ma_uint32 lpcPrecision, const ma_int32* coefficients, ma_int32* pSamplesOut) { ma_uint32 t[2] = {0x00000000, 0xFFFFFFFF}; ma_uint32 zeroCountPart0 = 0; ma_uint32 zeroCountPart1 = 0; ma_uint32 zeroCountPart2 = 0; ma_uint32 zeroCountPart3 = 0; ma_uint32 riceParamPart0 = 0; ma_uint32 riceParamPart1 = 0; ma_uint32 riceParamPart2 = 0; ma_uint32 riceParamPart3 = 0; ma_uint32 riceParamMask; const ma_int32* pSamplesOutEnd; ma_uint32 i; MA_DR_FLAC_ASSERT(bs != NULL); MA_DR_FLAC_ASSERT(pSamplesOut != NULL); if (lpcOrder == 0) { return ma_dr_flac__decode_samples_with_residual__rice__scalar_zeroorder(bs, bitsPerSample, count, riceParam, lpcOrder, lpcShift, coefficients, pSamplesOut); } riceParamMask = (ma_uint32)~((~0UL) << riceParam); pSamplesOutEnd = pSamplesOut + (count & ~3); if (ma_dr_flac__use_64_bit_prediction(bitsPerSample, lpcOrder, lpcPrecision)) { while (pSamplesOut < pSamplesOutEnd) { if (!ma_dr_flac__read_rice_parts_x1(bs, riceParam, &zeroCountPart0, &riceParamPart0) || !ma_dr_flac__read_rice_parts_x1(bs, riceParam, &zeroCountPart1, &riceParamPart1) || !ma_dr_flac__read_rice_parts_x1(bs, riceParam, &zeroCountPart2, &riceParamPart2) || !ma_dr_flac__read_rice_parts_x1(bs, riceParam, &zeroCountPart3, &riceParamPart3)) { return MA_FALSE; } riceParamPart0 &= riceParamMask; riceParamPart1 &= riceParamMask; riceParamPart2 &= riceParamMask; riceParamPart3 &= riceParamMask; riceParamPart0 |= (zeroCountPart0 << riceParam); riceParamPart1 |= (zeroCountPart1 << riceParam); riceParamPart2 |= (zeroCountPart2 << riceParam); riceParamPart3 |= (zeroCountPart3 << riceParam); riceParamPart0 = (riceParamPart0 >> 1) ^ t[riceParamPart0 & 0x01]; riceParamPart1 = (riceParamPart1 >> 1) ^ t[riceParamPart1 & 0x01]; riceParamPart2 = (riceParamPart2 >> 1) ^ t[riceParamPart2 & 0x01]; riceParamPart3 = (riceParamPart3 >> 1) ^ t[riceParamPart3 & 0x01]; pSamplesOut[0] = riceParamPart0 + ma_dr_flac__calculate_prediction_64(lpcOrder, lpcShift, coefficients, pSamplesOut + 0); pSamplesOut[1] = riceParamPart1 + ma_dr_flac__calculate_prediction_64(lpcOrder, lpcShift, coefficients, pSamplesOut + 1); pSamplesOut[2] = riceParamPart2 + ma_dr_flac__calculate_prediction_64(lpcOrder, lpcShift, coefficients, pSamplesOut + 2); pSamplesOut[3] = riceParamPart3 + ma_dr_flac__calculate_prediction_64(lpcOrder, lpcShift, coefficients, pSamplesOut + 3); pSamplesOut += 4; } } else { while (pSamplesOut < pSamplesOutEnd) { if (!ma_dr_flac__read_rice_parts_x1(bs, riceParam, &zeroCountPart0, &riceParamPart0) || !ma_dr_flac__read_rice_parts_x1(bs, riceParam, &zeroCountPart1, &riceParamPart1) || !ma_dr_flac__read_rice_parts_x1(bs, riceParam, &zeroCountPart2, &riceParamPart2) || !ma_dr_flac__read_rice_parts_x1(bs, riceParam, &zeroCountPart3, &riceParamPart3)) { return MA_FALSE; } riceParamPart0 &= riceParamMask; riceParamPart1 &= riceParamMask; riceParamPart2 &= riceParamMask; riceParamPart3 &= riceParamMask; riceParamPart0 |= (zeroCountPart0 << riceParam); riceParamPart1 |= (zeroCountPart1 << riceParam); riceParamPart2 |= (zeroCountPart2 << riceParam); riceParamPart3 |= (zeroCountPart3 << riceParam); riceParamPart0 = (riceParamPart0 >> 1) ^ t[riceParamPart0 & 0x01]; riceParamPart1 = (riceParamPart1 >> 1) ^ t[riceParamPart1 & 0x01]; riceParamPart2 = (riceParamPart2 >> 1) ^ t[riceParamPart2 & 0x01]; riceParamPart3 = (riceParamPart3 >> 1) ^ t[riceParamPart3 & 0x01]; pSamplesOut[0] = riceParamPart0 + ma_dr_flac__calculate_prediction_32(lpcOrder, lpcShift, coefficients, pSamplesOut + 0); pSamplesOut[1] = riceParamPart1 + ma_dr_flac__calculate_prediction_32(lpcOrder, lpcShift, coefficients, pSamplesOut + 1); pSamplesOut[2] = riceParamPart2 + ma_dr_flac__calculate_prediction_32(lpcOrder, lpcShift, coefficients, pSamplesOut + 2); pSamplesOut[3] = riceParamPart3 + ma_dr_flac__calculate_prediction_32(lpcOrder, lpcShift, coefficients, pSamplesOut + 3); pSamplesOut += 4; } } i = (count & ~3); while (i < count) { if (!ma_dr_flac__read_rice_parts_x1(bs, riceParam, &zeroCountPart0, &riceParamPart0)) { return MA_FALSE; } riceParamPart0 &= riceParamMask; riceParamPart0 |= (zeroCountPart0 << riceParam); riceParamPart0 = (riceParamPart0 >> 1) ^ t[riceParamPart0 & 0x01]; if (ma_dr_flac__use_64_bit_prediction(bitsPerSample, lpcOrder, lpcPrecision)) { pSamplesOut[0] = riceParamPart0 + ma_dr_flac__calculate_prediction_64(lpcOrder, lpcShift, coefficients, pSamplesOut + 0); } else { pSamplesOut[0] = riceParamPart0 + ma_dr_flac__calculate_prediction_32(lpcOrder, lpcShift, coefficients, pSamplesOut + 0); } i += 1; pSamplesOut += 1; } return MA_TRUE; } #if defined(MA_DR_FLAC_SUPPORT_SSE2) static MA_INLINE __m128i ma_dr_flac__mm_packs_interleaved_epi32(__m128i a, __m128i b) { __m128i r; r = _mm_packs_epi32(a, b); r = _mm_shuffle_epi32(r, _MM_SHUFFLE(3, 1, 2, 0)); r = _mm_shufflehi_epi16(r, _MM_SHUFFLE(3, 1, 2, 0)); r = _mm_shufflelo_epi16(r, _MM_SHUFFLE(3, 1, 2, 0)); return r; } #endif #if defined(MA_DR_FLAC_SUPPORT_SSE41) static MA_INLINE __m128i ma_dr_flac__mm_not_si128(__m128i a) { return _mm_xor_si128(a, _mm_cmpeq_epi32(_mm_setzero_si128(), _mm_setzero_si128())); } static MA_INLINE __m128i ma_dr_flac__mm_hadd_epi32(__m128i x) { __m128i x64 = _mm_add_epi32(x, _mm_shuffle_epi32(x, _MM_SHUFFLE(1, 0, 3, 2))); __m128i x32 = _mm_shufflelo_epi16(x64, _MM_SHUFFLE(1, 0, 3, 2)); return _mm_add_epi32(x64, x32); } static MA_INLINE __m128i ma_dr_flac__mm_hadd_epi64(__m128i x) { return _mm_add_epi64(x, _mm_shuffle_epi32(x, _MM_SHUFFLE(1, 0, 3, 2))); } static MA_INLINE __m128i ma_dr_flac__mm_srai_epi64(__m128i x, int count) { __m128i lo = _mm_srli_epi64(x, count); __m128i hi = _mm_srai_epi32(x, count); hi = _mm_and_si128(hi, _mm_set_epi32(0xFFFFFFFF, 0, 0xFFFFFFFF, 0)); return _mm_or_si128(lo, hi); } static ma_bool32 ma_dr_flac__decode_samples_with_residual__rice__sse41_32(ma_dr_flac_bs* bs, ma_uint32 count, ma_uint8 riceParam, ma_uint32 order, ma_int32 shift, const ma_int32* coefficients, ma_int32* pSamplesOut) { int i; ma_uint32 riceParamMask; ma_int32* pDecodedSamples = pSamplesOut; ma_int32* pDecodedSamplesEnd = pSamplesOut + (count & ~3); ma_uint32 zeroCountParts0 = 0; ma_uint32 zeroCountParts1 = 0; ma_uint32 zeroCountParts2 = 0; ma_uint32 zeroCountParts3 = 0; ma_uint32 riceParamParts0 = 0; ma_uint32 riceParamParts1 = 0; ma_uint32 riceParamParts2 = 0; ma_uint32 riceParamParts3 = 0; __m128i coefficients128_0; __m128i coefficients128_4; __m128i coefficients128_8; __m128i samples128_0; __m128i samples128_4; __m128i samples128_8; __m128i riceParamMask128; const ma_uint32 t[2] = {0x00000000, 0xFFFFFFFF}; riceParamMask = (ma_uint32)~((~0UL) << riceParam); riceParamMask128 = _mm_set1_epi32(riceParamMask); coefficients128_0 = _mm_setzero_si128(); coefficients128_4 = _mm_setzero_si128(); coefficients128_8 = _mm_setzero_si128(); samples128_0 = _mm_setzero_si128(); samples128_4 = _mm_setzero_si128(); samples128_8 = _mm_setzero_si128(); #if 1 { int runningOrder = order; if (runningOrder >= 4) { coefficients128_0 = _mm_loadu_si128((const __m128i*)(coefficients + 0)); samples128_0 = _mm_loadu_si128((const __m128i*)(pSamplesOut - 4)); runningOrder -= 4; } else { switch (runningOrder) { case 3: coefficients128_0 = _mm_set_epi32(0, coefficients[2], coefficients[1], coefficients[0]); samples128_0 = _mm_set_epi32(pSamplesOut[-1], pSamplesOut[-2], pSamplesOut[-3], 0); break; case 2: coefficients128_0 = _mm_set_epi32(0, 0, coefficients[1], coefficients[0]); samples128_0 = _mm_set_epi32(pSamplesOut[-1], pSamplesOut[-2], 0, 0); break; case 1: coefficients128_0 = _mm_set_epi32(0, 0, 0, coefficients[0]); samples128_0 = _mm_set_epi32(pSamplesOut[-1], 0, 0, 0); break; } runningOrder = 0; } if (runningOrder >= 4) { coefficients128_4 = _mm_loadu_si128((const __m128i*)(coefficients + 4)); samples128_4 = _mm_loadu_si128((const __m128i*)(pSamplesOut - 8)); runningOrder -= 4; } else { switch (runningOrder) { case 3: coefficients128_4 = _mm_set_epi32(0, coefficients[6], coefficients[5], coefficients[4]); samples128_4 = _mm_set_epi32(pSamplesOut[-5], pSamplesOut[-6], pSamplesOut[-7], 0); break; case 2: coefficients128_4 = _mm_set_epi32(0, 0, coefficients[5], coefficients[4]); samples128_4 = _mm_set_epi32(pSamplesOut[-5], pSamplesOut[-6], 0, 0); break; case 1: coefficients128_4 = _mm_set_epi32(0, 0, 0, coefficients[4]); samples128_4 = _mm_set_epi32(pSamplesOut[-5], 0, 0, 0); break; } runningOrder = 0; } if (runningOrder == 4) { coefficients128_8 = _mm_loadu_si128((const __m128i*)(coefficients + 8)); samples128_8 = _mm_loadu_si128((const __m128i*)(pSamplesOut - 12)); runningOrder -= 4; } else { switch (runningOrder) { case 3: coefficients128_8 = _mm_set_epi32(0, coefficients[10], coefficients[9], coefficients[8]); samples128_8 = _mm_set_epi32(pSamplesOut[-9], pSamplesOut[-10], pSamplesOut[-11], 0); break; case 2: coefficients128_8 = _mm_set_epi32(0, 0, coefficients[9], coefficients[8]); samples128_8 = _mm_set_epi32(pSamplesOut[-9], pSamplesOut[-10], 0, 0); break; case 1: coefficients128_8 = _mm_set_epi32(0, 0, 0, coefficients[8]); samples128_8 = _mm_set_epi32(pSamplesOut[-9], 0, 0, 0); break; } runningOrder = 0; } coefficients128_0 = _mm_shuffle_epi32(coefficients128_0, _MM_SHUFFLE(0, 1, 2, 3)); coefficients128_4 = _mm_shuffle_epi32(coefficients128_4, _MM_SHUFFLE(0, 1, 2, 3)); coefficients128_8 = _mm_shuffle_epi32(coefficients128_8, _MM_SHUFFLE(0, 1, 2, 3)); } #else switch (order) { case 12: ((ma_int32*)&coefficients128_8)[0] = coefficients[11]; ((ma_int32*)&samples128_8)[0] = pDecodedSamples[-12]; case 11: ((ma_int32*)&coefficients128_8)[1] = coefficients[10]; ((ma_int32*)&samples128_8)[1] = pDecodedSamples[-11]; case 10: ((ma_int32*)&coefficients128_8)[2] = coefficients[ 9]; ((ma_int32*)&samples128_8)[2] = pDecodedSamples[-10]; case 9: ((ma_int32*)&coefficients128_8)[3] = coefficients[ 8]; ((ma_int32*)&samples128_8)[3] = pDecodedSamples[- 9]; case 8: ((ma_int32*)&coefficients128_4)[0] = coefficients[ 7]; ((ma_int32*)&samples128_4)[0] = pDecodedSamples[- 8]; case 7: ((ma_int32*)&coefficients128_4)[1] = coefficients[ 6]; ((ma_int32*)&samples128_4)[1] = pDecodedSamples[- 7]; case 6: ((ma_int32*)&coefficients128_4)[2] = coefficients[ 5]; ((ma_int32*)&samples128_4)[2] = pDecodedSamples[- 6]; case 5: ((ma_int32*)&coefficients128_4)[3] = coefficients[ 4]; ((ma_int32*)&samples128_4)[3] = pDecodedSamples[- 5]; case 4: ((ma_int32*)&coefficients128_0)[0] = coefficients[ 3]; ((ma_int32*)&samples128_0)[0] = pDecodedSamples[- 4]; case 3: ((ma_int32*)&coefficients128_0)[1] = coefficients[ 2]; ((ma_int32*)&samples128_0)[1] = pDecodedSamples[- 3]; case 2: ((ma_int32*)&coefficients128_0)[2] = coefficients[ 1]; ((ma_int32*)&samples128_0)[2] = pDecodedSamples[- 2]; case 1: ((ma_int32*)&coefficients128_0)[3] = coefficients[ 0]; ((ma_int32*)&samples128_0)[3] = pDecodedSamples[- 1]; } #endif while (pDecodedSamples < pDecodedSamplesEnd) { __m128i prediction128; __m128i zeroCountPart128; __m128i riceParamPart128; if (!ma_dr_flac__read_rice_parts_x1(bs, riceParam, &zeroCountParts0, &riceParamParts0) || !ma_dr_flac__read_rice_parts_x1(bs, riceParam, &zeroCountParts1, &riceParamParts1) || !ma_dr_flac__read_rice_parts_x1(bs, riceParam, &zeroCountParts2, &riceParamParts2) || !ma_dr_flac__read_rice_parts_x1(bs, riceParam, &zeroCountParts3, &riceParamParts3)) { return MA_FALSE; } zeroCountPart128 = _mm_set_epi32(zeroCountParts3, zeroCountParts2, zeroCountParts1, zeroCountParts0); riceParamPart128 = _mm_set_epi32(riceParamParts3, riceParamParts2, riceParamParts1, riceParamParts0); riceParamPart128 = _mm_and_si128(riceParamPart128, riceParamMask128); riceParamPart128 = _mm_or_si128(riceParamPart128, _mm_slli_epi32(zeroCountPart128, riceParam)); riceParamPart128 = _mm_xor_si128(_mm_srli_epi32(riceParamPart128, 1), _mm_add_epi32(ma_dr_flac__mm_not_si128(_mm_and_si128(riceParamPart128, _mm_set1_epi32(0x01))), _mm_set1_epi32(0x01))); if (order <= 4) { for (i = 0; i < 4; i += 1) { prediction128 = _mm_mullo_epi32(coefficients128_0, samples128_0); prediction128 = ma_dr_flac__mm_hadd_epi32(prediction128); prediction128 = _mm_srai_epi32(prediction128, shift); prediction128 = _mm_add_epi32(riceParamPart128, prediction128); samples128_0 = _mm_alignr_epi8(prediction128, samples128_0, 4); riceParamPart128 = _mm_alignr_epi8(_mm_setzero_si128(), riceParamPart128, 4); } } else if (order <= 8) { for (i = 0; i < 4; i += 1) { prediction128 = _mm_mullo_epi32(coefficients128_4, samples128_4); prediction128 = _mm_add_epi32(prediction128, _mm_mullo_epi32(coefficients128_0, samples128_0)); prediction128 = ma_dr_flac__mm_hadd_epi32(prediction128); prediction128 = _mm_srai_epi32(prediction128, shift); prediction128 = _mm_add_epi32(riceParamPart128, prediction128); samples128_4 = _mm_alignr_epi8(samples128_0, samples128_4, 4); samples128_0 = _mm_alignr_epi8(prediction128, samples128_0, 4); riceParamPart128 = _mm_alignr_epi8(_mm_setzero_si128(), riceParamPart128, 4); } } else { for (i = 0; i < 4; i += 1) { prediction128 = _mm_mullo_epi32(coefficients128_8, samples128_8); prediction128 = _mm_add_epi32(prediction128, _mm_mullo_epi32(coefficients128_4, samples128_4)); prediction128 = _mm_add_epi32(prediction128, _mm_mullo_epi32(coefficients128_0, samples128_0)); prediction128 = ma_dr_flac__mm_hadd_epi32(prediction128); prediction128 = _mm_srai_epi32(prediction128, shift); prediction128 = _mm_add_epi32(riceParamPart128, prediction128); samples128_8 = _mm_alignr_epi8(samples128_4, samples128_8, 4); samples128_4 = _mm_alignr_epi8(samples128_0, samples128_4, 4); samples128_0 = _mm_alignr_epi8(prediction128, samples128_0, 4); riceParamPart128 = _mm_alignr_epi8(_mm_setzero_si128(), riceParamPart128, 4); } } _mm_storeu_si128((__m128i*)pDecodedSamples, samples128_0); pDecodedSamples += 4; } i = (count & ~3); while (i < (int)count) { if (!ma_dr_flac__read_rice_parts_x1(bs, riceParam, &zeroCountParts0, &riceParamParts0)) { return MA_FALSE; } riceParamParts0 &= riceParamMask; riceParamParts0 |= (zeroCountParts0 << riceParam); riceParamParts0 = (riceParamParts0 >> 1) ^ t[riceParamParts0 & 0x01]; pDecodedSamples[0] = riceParamParts0 + ma_dr_flac__calculate_prediction_32(order, shift, coefficients, pDecodedSamples); i += 1; pDecodedSamples += 1; } return MA_TRUE; } static ma_bool32 ma_dr_flac__decode_samples_with_residual__rice__sse41_64(ma_dr_flac_bs* bs, ma_uint32 count, ma_uint8 riceParam, ma_uint32 order, ma_int32 shift, const ma_int32* coefficients, ma_int32* pSamplesOut) { int i; ma_uint32 riceParamMask; ma_int32* pDecodedSamples = pSamplesOut; ma_int32* pDecodedSamplesEnd = pSamplesOut + (count & ~3); ma_uint32 zeroCountParts0 = 0; ma_uint32 zeroCountParts1 = 0; ma_uint32 zeroCountParts2 = 0; ma_uint32 zeroCountParts3 = 0; ma_uint32 riceParamParts0 = 0; ma_uint32 riceParamParts1 = 0; ma_uint32 riceParamParts2 = 0; ma_uint32 riceParamParts3 = 0; __m128i coefficients128_0; __m128i coefficients128_4; __m128i coefficients128_8; __m128i samples128_0; __m128i samples128_4; __m128i samples128_8; __m128i prediction128; __m128i riceParamMask128; const ma_uint32 t[2] = {0x00000000, 0xFFFFFFFF}; MA_DR_FLAC_ASSERT(order <= 12); riceParamMask = (ma_uint32)~((~0UL) << riceParam); riceParamMask128 = _mm_set1_epi32(riceParamMask); prediction128 = _mm_setzero_si128(); coefficients128_0 = _mm_setzero_si128(); coefficients128_4 = _mm_setzero_si128(); coefficients128_8 = _mm_setzero_si128(); samples128_0 = _mm_setzero_si128(); samples128_4 = _mm_setzero_si128(); samples128_8 = _mm_setzero_si128(); #if 1 { int runningOrder = order; if (runningOrder >= 4) { coefficients128_0 = _mm_loadu_si128((const __m128i*)(coefficients + 0)); samples128_0 = _mm_loadu_si128((const __m128i*)(pSamplesOut - 4)); runningOrder -= 4; } else { switch (runningOrder) { case 3: coefficients128_0 = _mm_set_epi32(0, coefficients[2], coefficients[1], coefficients[0]); samples128_0 = _mm_set_epi32(pSamplesOut[-1], pSamplesOut[-2], pSamplesOut[-3], 0); break; case 2: coefficients128_0 = _mm_set_epi32(0, 0, coefficients[1], coefficients[0]); samples128_0 = _mm_set_epi32(pSamplesOut[-1], pSamplesOut[-2], 0, 0); break; case 1: coefficients128_0 = _mm_set_epi32(0, 0, 0, coefficients[0]); samples128_0 = _mm_set_epi32(pSamplesOut[-1], 0, 0, 0); break; } runningOrder = 0; } if (runningOrder >= 4) { coefficients128_4 = _mm_loadu_si128((const __m128i*)(coefficients + 4)); samples128_4 = _mm_loadu_si128((const __m128i*)(pSamplesOut - 8)); runningOrder -= 4; } else { switch (runningOrder) { case 3: coefficients128_4 = _mm_set_epi32(0, coefficients[6], coefficients[5], coefficients[4]); samples128_4 = _mm_set_epi32(pSamplesOut[-5], pSamplesOut[-6], pSamplesOut[-7], 0); break; case 2: coefficients128_4 = _mm_set_epi32(0, 0, coefficients[5], coefficients[4]); samples128_4 = _mm_set_epi32(pSamplesOut[-5], pSamplesOut[-6], 0, 0); break; case 1: coefficients128_4 = _mm_set_epi32(0, 0, 0, coefficients[4]); samples128_4 = _mm_set_epi32(pSamplesOut[-5], 0, 0, 0); break; } runningOrder = 0; } if (runningOrder == 4) { coefficients128_8 = _mm_loadu_si128((const __m128i*)(coefficients + 8)); samples128_8 = _mm_loadu_si128((const __m128i*)(pSamplesOut - 12)); runningOrder -= 4; } else { switch (runningOrder) { case 3: coefficients128_8 = _mm_set_epi32(0, coefficients[10], coefficients[9], coefficients[8]); samples128_8 = _mm_set_epi32(pSamplesOut[-9], pSamplesOut[-10], pSamplesOut[-11], 0); break; case 2: coefficients128_8 = _mm_set_epi32(0, 0, coefficients[9], coefficients[8]); samples128_8 = _mm_set_epi32(pSamplesOut[-9], pSamplesOut[-10], 0, 0); break; case 1: coefficients128_8 = _mm_set_epi32(0, 0, 0, coefficients[8]); samples128_8 = _mm_set_epi32(pSamplesOut[-9], 0, 0, 0); break; } runningOrder = 0; } coefficients128_0 = _mm_shuffle_epi32(coefficients128_0, _MM_SHUFFLE(0, 1, 2, 3)); coefficients128_4 = _mm_shuffle_epi32(coefficients128_4, _MM_SHUFFLE(0, 1, 2, 3)); coefficients128_8 = _mm_shuffle_epi32(coefficients128_8, _MM_SHUFFLE(0, 1, 2, 3)); } #else switch (order) { case 12: ((ma_int32*)&coefficients128_8)[0] = coefficients[11]; ((ma_int32*)&samples128_8)[0] = pDecodedSamples[-12]; case 11: ((ma_int32*)&coefficients128_8)[1] = coefficients[10]; ((ma_int32*)&samples128_8)[1] = pDecodedSamples[-11]; case 10: ((ma_int32*)&coefficients128_8)[2] = coefficients[ 9]; ((ma_int32*)&samples128_8)[2] = pDecodedSamples[-10]; case 9: ((ma_int32*)&coefficients128_8)[3] = coefficients[ 8]; ((ma_int32*)&samples128_8)[3] = pDecodedSamples[- 9]; case 8: ((ma_int32*)&coefficients128_4)[0] = coefficients[ 7]; ((ma_int32*)&samples128_4)[0] = pDecodedSamples[- 8]; case 7: ((ma_int32*)&coefficients128_4)[1] = coefficients[ 6]; ((ma_int32*)&samples128_4)[1] = pDecodedSamples[- 7]; case 6: ((ma_int32*)&coefficients128_4)[2] = coefficients[ 5]; ((ma_int32*)&samples128_4)[2] = pDecodedSamples[- 6]; case 5: ((ma_int32*)&coefficients128_4)[3] = coefficients[ 4]; ((ma_int32*)&samples128_4)[3] = pDecodedSamples[- 5]; case 4: ((ma_int32*)&coefficients128_0)[0] = coefficients[ 3]; ((ma_int32*)&samples128_0)[0] = pDecodedSamples[- 4]; case 3: ((ma_int32*)&coefficients128_0)[1] = coefficients[ 2]; ((ma_int32*)&samples128_0)[1] = pDecodedSamples[- 3]; case 2: ((ma_int32*)&coefficients128_0)[2] = coefficients[ 1]; ((ma_int32*)&samples128_0)[2] = pDecodedSamples[- 2]; case 1: ((ma_int32*)&coefficients128_0)[3] = coefficients[ 0]; ((ma_int32*)&samples128_0)[3] = pDecodedSamples[- 1]; } #endif while (pDecodedSamples < pDecodedSamplesEnd) { __m128i zeroCountPart128; __m128i riceParamPart128; if (!ma_dr_flac__read_rice_parts_x1(bs, riceParam, &zeroCountParts0, &riceParamParts0) || !ma_dr_flac__read_rice_parts_x1(bs, riceParam, &zeroCountParts1, &riceParamParts1) || !ma_dr_flac__read_rice_parts_x1(bs, riceParam, &zeroCountParts2, &riceParamParts2) || !ma_dr_flac__read_rice_parts_x1(bs, riceParam, &zeroCountParts3, &riceParamParts3)) { return MA_FALSE; } zeroCountPart128 = _mm_set_epi32(zeroCountParts3, zeroCountParts2, zeroCountParts1, zeroCountParts0); riceParamPart128 = _mm_set_epi32(riceParamParts3, riceParamParts2, riceParamParts1, riceParamParts0); riceParamPart128 = _mm_and_si128(riceParamPart128, riceParamMask128); riceParamPart128 = _mm_or_si128(riceParamPart128, _mm_slli_epi32(zeroCountPart128, riceParam)); riceParamPart128 = _mm_xor_si128(_mm_srli_epi32(riceParamPart128, 1), _mm_add_epi32(ma_dr_flac__mm_not_si128(_mm_and_si128(riceParamPart128, _mm_set1_epi32(1))), _mm_set1_epi32(1))); for (i = 0; i < 4; i += 1) { prediction128 = _mm_xor_si128(prediction128, prediction128); switch (order) { case 12: case 11: prediction128 = _mm_add_epi64(prediction128, _mm_mul_epi32(_mm_shuffle_epi32(coefficients128_8, _MM_SHUFFLE(1, 1, 0, 0)), _mm_shuffle_epi32(samples128_8, _MM_SHUFFLE(1, 1, 0, 0)))); case 10: case 9: prediction128 = _mm_add_epi64(prediction128, _mm_mul_epi32(_mm_shuffle_epi32(coefficients128_8, _MM_SHUFFLE(3, 3, 2, 2)), _mm_shuffle_epi32(samples128_8, _MM_SHUFFLE(3, 3, 2, 2)))); case 8: case 7: prediction128 = _mm_add_epi64(prediction128, _mm_mul_epi32(_mm_shuffle_epi32(coefficients128_4, _MM_SHUFFLE(1, 1, 0, 0)), _mm_shuffle_epi32(samples128_4, _MM_SHUFFLE(1, 1, 0, 0)))); case 6: case 5: prediction128 = _mm_add_epi64(prediction128, _mm_mul_epi32(_mm_shuffle_epi32(coefficients128_4, _MM_SHUFFLE(3, 3, 2, 2)), _mm_shuffle_epi32(samples128_4, _MM_SHUFFLE(3, 3, 2, 2)))); case 4: case 3: prediction128 = _mm_add_epi64(prediction128, _mm_mul_epi32(_mm_shuffle_epi32(coefficients128_0, _MM_SHUFFLE(1, 1, 0, 0)), _mm_shuffle_epi32(samples128_0, _MM_SHUFFLE(1, 1, 0, 0)))); case 2: case 1: prediction128 = _mm_add_epi64(prediction128, _mm_mul_epi32(_mm_shuffle_epi32(coefficients128_0, _MM_SHUFFLE(3, 3, 2, 2)), _mm_shuffle_epi32(samples128_0, _MM_SHUFFLE(3, 3, 2, 2)))); } prediction128 = ma_dr_flac__mm_hadd_epi64(prediction128); prediction128 = ma_dr_flac__mm_srai_epi64(prediction128, shift); prediction128 = _mm_add_epi32(riceParamPart128, prediction128); samples128_8 = _mm_alignr_epi8(samples128_4, samples128_8, 4); samples128_4 = _mm_alignr_epi8(samples128_0, samples128_4, 4); samples128_0 = _mm_alignr_epi8(prediction128, samples128_0, 4); riceParamPart128 = _mm_alignr_epi8(_mm_setzero_si128(), riceParamPart128, 4); } _mm_storeu_si128((__m128i*)pDecodedSamples, samples128_0); pDecodedSamples += 4; } i = (count & ~3); while (i < (int)count) { if (!ma_dr_flac__read_rice_parts_x1(bs, riceParam, &zeroCountParts0, &riceParamParts0)) { return MA_FALSE; } riceParamParts0 &= riceParamMask; riceParamParts0 |= (zeroCountParts0 << riceParam); riceParamParts0 = (riceParamParts0 >> 1) ^ t[riceParamParts0 & 0x01]; pDecodedSamples[0] = riceParamParts0 + ma_dr_flac__calculate_prediction_64(order, shift, coefficients, pDecodedSamples); i += 1; pDecodedSamples += 1; } return MA_TRUE; } static ma_bool32 ma_dr_flac__decode_samples_with_residual__rice__sse41(ma_dr_flac_bs* bs, ma_uint32 bitsPerSample, ma_uint32 count, ma_uint8 riceParam, ma_uint32 lpcOrder, ma_int32 lpcShift, ma_uint32 lpcPrecision, const ma_int32* coefficients, ma_int32* pSamplesOut) { MA_DR_FLAC_ASSERT(bs != NULL); MA_DR_FLAC_ASSERT(pSamplesOut != NULL); if (lpcOrder > 0 && lpcOrder <= 12) { if (ma_dr_flac__use_64_bit_prediction(bitsPerSample, lpcOrder, lpcPrecision)) { return ma_dr_flac__decode_samples_with_residual__rice__sse41_64(bs, count, riceParam, lpcOrder, lpcShift, coefficients, pSamplesOut); } else { return ma_dr_flac__decode_samples_with_residual__rice__sse41_32(bs, count, riceParam, lpcOrder, lpcShift, coefficients, pSamplesOut); } } else { return ma_dr_flac__decode_samples_with_residual__rice__scalar(bs, bitsPerSample, count, riceParam, lpcOrder, lpcShift, lpcPrecision, coefficients, pSamplesOut); } } #endif #if defined(MA_DR_FLAC_SUPPORT_NEON) static MA_INLINE void ma_dr_flac__vst2q_s32(ma_int32* p, int32x4x2_t x) { vst1q_s32(p+0, x.val[0]); vst1q_s32(p+4, x.val[1]); } static MA_INLINE void ma_dr_flac__vst2q_u32(ma_uint32* p, uint32x4x2_t x) { vst1q_u32(p+0, x.val[0]); vst1q_u32(p+4, x.val[1]); } static MA_INLINE void ma_dr_flac__vst2q_f32(float* p, float32x4x2_t x) { vst1q_f32(p+0, x.val[0]); vst1q_f32(p+4, x.val[1]); } static MA_INLINE void ma_dr_flac__vst2q_s16(ma_int16* p, int16x4x2_t x) { vst1q_s16(p, vcombine_s16(x.val[0], x.val[1])); } static MA_INLINE void ma_dr_flac__vst2q_u16(ma_uint16* p, uint16x4x2_t x) { vst1q_u16(p, vcombine_u16(x.val[0], x.val[1])); } static MA_INLINE int32x4_t ma_dr_flac__vdupq_n_s32x4(ma_int32 x3, ma_int32 x2, ma_int32 x1, ma_int32 x0) { ma_int32 x[4]; x[3] = x3; x[2] = x2; x[1] = x1; x[0] = x0; return vld1q_s32(x); } static MA_INLINE int32x4_t ma_dr_flac__valignrq_s32_1(int32x4_t a, int32x4_t b) { return vextq_s32(b, a, 1); } static MA_INLINE uint32x4_t ma_dr_flac__valignrq_u32_1(uint32x4_t a, uint32x4_t b) { return vextq_u32(b, a, 1); } static MA_INLINE int32x2_t ma_dr_flac__vhaddq_s32(int32x4_t x) { int32x2_t r = vadd_s32(vget_high_s32(x), vget_low_s32(x)); return vpadd_s32(r, r); } static MA_INLINE int64x1_t ma_dr_flac__vhaddq_s64(int64x2_t x) { return vadd_s64(vget_high_s64(x), vget_low_s64(x)); } static MA_INLINE int32x4_t ma_dr_flac__vrevq_s32(int32x4_t x) { return vrev64q_s32(vcombine_s32(vget_high_s32(x), vget_low_s32(x))); } static MA_INLINE int32x4_t ma_dr_flac__vnotq_s32(int32x4_t x) { return veorq_s32(x, vdupq_n_s32(0xFFFFFFFF)); } static MA_INLINE uint32x4_t ma_dr_flac__vnotq_u32(uint32x4_t x) { return veorq_u32(x, vdupq_n_u32(0xFFFFFFFF)); } static ma_bool32 ma_dr_flac__decode_samples_with_residual__rice__neon_32(ma_dr_flac_bs* bs, ma_uint32 count, ma_uint8 riceParam, ma_uint32 order, ma_int32 shift, const ma_int32* coefficients, ma_int32* pSamplesOut) { int i; ma_uint32 riceParamMask; ma_int32* pDecodedSamples = pSamplesOut; ma_int32* pDecodedSamplesEnd = pSamplesOut + (count & ~3); ma_uint32 zeroCountParts[4]; ma_uint32 riceParamParts[4]; int32x4_t coefficients128_0; int32x4_t coefficients128_4; int32x4_t coefficients128_8; int32x4_t samples128_0; int32x4_t samples128_4; int32x4_t samples128_8; uint32x4_t riceParamMask128; int32x4_t riceParam128; int32x2_t shift64; uint32x4_t one128; const ma_uint32 t[2] = {0x00000000, 0xFFFFFFFF}; riceParamMask = (ma_uint32)~((~0UL) << riceParam); riceParamMask128 = vdupq_n_u32(riceParamMask); riceParam128 = vdupq_n_s32(riceParam); shift64 = vdup_n_s32(-shift); one128 = vdupq_n_u32(1); { int runningOrder = order; ma_int32 tempC[4] = {0, 0, 0, 0}; ma_int32 tempS[4] = {0, 0, 0, 0}; if (runningOrder >= 4) { coefficients128_0 = vld1q_s32(coefficients + 0); samples128_0 = vld1q_s32(pSamplesOut - 4); runningOrder -= 4; } else { switch (runningOrder) { case 3: tempC[2] = coefficients[2]; tempS[1] = pSamplesOut[-3]; case 2: tempC[1] = coefficients[1]; tempS[2] = pSamplesOut[-2]; case 1: tempC[0] = coefficients[0]; tempS[3] = pSamplesOut[-1]; } coefficients128_0 = vld1q_s32(tempC); samples128_0 = vld1q_s32(tempS); runningOrder = 0; } if (runningOrder >= 4) { coefficients128_4 = vld1q_s32(coefficients + 4); samples128_4 = vld1q_s32(pSamplesOut - 8); runningOrder -= 4; } else { switch (runningOrder) { case 3: tempC[2] = coefficients[6]; tempS[1] = pSamplesOut[-7]; case 2: tempC[1] = coefficients[5]; tempS[2] = pSamplesOut[-6]; case 1: tempC[0] = coefficients[4]; tempS[3] = pSamplesOut[-5]; } coefficients128_4 = vld1q_s32(tempC); samples128_4 = vld1q_s32(tempS); runningOrder = 0; } if (runningOrder == 4) { coefficients128_8 = vld1q_s32(coefficients + 8); samples128_8 = vld1q_s32(pSamplesOut - 12); runningOrder -= 4; } else { switch (runningOrder) { case 3: tempC[2] = coefficients[10]; tempS[1] = pSamplesOut[-11]; case 2: tempC[1] = coefficients[ 9]; tempS[2] = pSamplesOut[-10]; case 1: tempC[0] = coefficients[ 8]; tempS[3] = pSamplesOut[- 9]; } coefficients128_8 = vld1q_s32(tempC); samples128_8 = vld1q_s32(tempS); runningOrder = 0; } coefficients128_0 = ma_dr_flac__vrevq_s32(coefficients128_0); coefficients128_4 = ma_dr_flac__vrevq_s32(coefficients128_4); coefficients128_8 = ma_dr_flac__vrevq_s32(coefficients128_8); } while (pDecodedSamples < pDecodedSamplesEnd) { int32x4_t prediction128; int32x2_t prediction64; uint32x4_t zeroCountPart128; uint32x4_t riceParamPart128; if (!ma_dr_flac__read_rice_parts_x1(bs, riceParam, &zeroCountParts[0], &riceParamParts[0]) || !ma_dr_flac__read_rice_parts_x1(bs, riceParam, &zeroCountParts[1], &riceParamParts[1]) || !ma_dr_flac__read_rice_parts_x1(bs, riceParam, &zeroCountParts[2], &riceParamParts[2]) || !ma_dr_flac__read_rice_parts_x1(bs, riceParam, &zeroCountParts[3], &riceParamParts[3])) { return MA_FALSE; } zeroCountPart128 = vld1q_u32(zeroCountParts); riceParamPart128 = vld1q_u32(riceParamParts); riceParamPart128 = vandq_u32(riceParamPart128, riceParamMask128); riceParamPart128 = vorrq_u32(riceParamPart128, vshlq_u32(zeroCountPart128, riceParam128)); riceParamPart128 = veorq_u32(vshrq_n_u32(riceParamPart128, 1), vaddq_u32(ma_dr_flac__vnotq_u32(vandq_u32(riceParamPart128, one128)), one128)); if (order <= 4) { for (i = 0; i < 4; i += 1) { prediction128 = vmulq_s32(coefficients128_0, samples128_0); prediction64 = ma_dr_flac__vhaddq_s32(prediction128); prediction64 = vshl_s32(prediction64, shift64); prediction64 = vadd_s32(prediction64, vget_low_s32(vreinterpretq_s32_u32(riceParamPart128))); samples128_0 = ma_dr_flac__valignrq_s32_1(vcombine_s32(prediction64, vdup_n_s32(0)), samples128_0); riceParamPart128 = ma_dr_flac__valignrq_u32_1(vdupq_n_u32(0), riceParamPart128); } } else if (order <= 8) { for (i = 0; i < 4; i += 1) { prediction128 = vmulq_s32(coefficients128_4, samples128_4); prediction128 = vmlaq_s32(prediction128, coefficients128_0, samples128_0); prediction64 = ma_dr_flac__vhaddq_s32(prediction128); prediction64 = vshl_s32(prediction64, shift64); prediction64 = vadd_s32(prediction64, vget_low_s32(vreinterpretq_s32_u32(riceParamPart128))); samples128_4 = ma_dr_flac__valignrq_s32_1(samples128_0, samples128_4); samples128_0 = ma_dr_flac__valignrq_s32_1(vcombine_s32(prediction64, vdup_n_s32(0)), samples128_0); riceParamPart128 = ma_dr_flac__valignrq_u32_1(vdupq_n_u32(0), riceParamPart128); } } else { for (i = 0; i < 4; i += 1) { prediction128 = vmulq_s32(coefficients128_8, samples128_8); prediction128 = vmlaq_s32(prediction128, coefficients128_4, samples128_4); prediction128 = vmlaq_s32(prediction128, coefficients128_0, samples128_0); prediction64 = ma_dr_flac__vhaddq_s32(prediction128); prediction64 = vshl_s32(prediction64, shift64); prediction64 = vadd_s32(prediction64, vget_low_s32(vreinterpretq_s32_u32(riceParamPart128))); samples128_8 = ma_dr_flac__valignrq_s32_1(samples128_4, samples128_8); samples128_4 = ma_dr_flac__valignrq_s32_1(samples128_0, samples128_4); samples128_0 = ma_dr_flac__valignrq_s32_1(vcombine_s32(prediction64, vdup_n_s32(0)), samples128_0); riceParamPart128 = ma_dr_flac__valignrq_u32_1(vdupq_n_u32(0), riceParamPart128); } } vst1q_s32(pDecodedSamples, samples128_0); pDecodedSamples += 4; } i = (count & ~3); while (i < (int)count) { if (!ma_dr_flac__read_rice_parts_x1(bs, riceParam, &zeroCountParts[0], &riceParamParts[0])) { return MA_FALSE; } riceParamParts[0] &= riceParamMask; riceParamParts[0] |= (zeroCountParts[0] << riceParam); riceParamParts[0] = (riceParamParts[0] >> 1) ^ t[riceParamParts[0] & 0x01]; pDecodedSamples[0] = riceParamParts[0] + ma_dr_flac__calculate_prediction_32(order, shift, coefficients, pDecodedSamples); i += 1; pDecodedSamples += 1; } return MA_TRUE; } static ma_bool32 ma_dr_flac__decode_samples_with_residual__rice__neon_64(ma_dr_flac_bs* bs, ma_uint32 count, ma_uint8 riceParam, ma_uint32 order, ma_int32 shift, const ma_int32* coefficients, ma_int32* pSamplesOut) { int i; ma_uint32 riceParamMask; ma_int32* pDecodedSamples = pSamplesOut; ma_int32* pDecodedSamplesEnd = pSamplesOut + (count & ~3); ma_uint32 zeroCountParts[4]; ma_uint32 riceParamParts[4]; int32x4_t coefficients128_0; int32x4_t coefficients128_4; int32x4_t coefficients128_8; int32x4_t samples128_0; int32x4_t samples128_4; int32x4_t samples128_8; uint32x4_t riceParamMask128; int32x4_t riceParam128; int64x1_t shift64; uint32x4_t one128; int64x2_t prediction128 = { 0 }; uint32x4_t zeroCountPart128; uint32x4_t riceParamPart128; const ma_uint32 t[2] = {0x00000000, 0xFFFFFFFF}; riceParamMask = (ma_uint32)~((~0UL) << riceParam); riceParamMask128 = vdupq_n_u32(riceParamMask); riceParam128 = vdupq_n_s32(riceParam); shift64 = vdup_n_s64(-shift); one128 = vdupq_n_u32(1); { int runningOrder = order; ma_int32 tempC[4] = {0, 0, 0, 0}; ma_int32 tempS[4] = {0, 0, 0, 0}; if (runningOrder >= 4) { coefficients128_0 = vld1q_s32(coefficients + 0); samples128_0 = vld1q_s32(pSamplesOut - 4); runningOrder -= 4; } else { switch (runningOrder) { case 3: tempC[2] = coefficients[2]; tempS[1] = pSamplesOut[-3]; case 2: tempC[1] = coefficients[1]; tempS[2] = pSamplesOut[-2]; case 1: tempC[0] = coefficients[0]; tempS[3] = pSamplesOut[-1]; } coefficients128_0 = vld1q_s32(tempC); samples128_0 = vld1q_s32(tempS); runningOrder = 0; } if (runningOrder >= 4) { coefficients128_4 = vld1q_s32(coefficients + 4); samples128_4 = vld1q_s32(pSamplesOut - 8); runningOrder -= 4; } else { switch (runningOrder) { case 3: tempC[2] = coefficients[6]; tempS[1] = pSamplesOut[-7]; case 2: tempC[1] = coefficients[5]; tempS[2] = pSamplesOut[-6]; case 1: tempC[0] = coefficients[4]; tempS[3] = pSamplesOut[-5]; } coefficients128_4 = vld1q_s32(tempC); samples128_4 = vld1q_s32(tempS); runningOrder = 0; } if (runningOrder == 4) { coefficients128_8 = vld1q_s32(coefficients + 8); samples128_8 = vld1q_s32(pSamplesOut - 12); runningOrder -= 4; } else { switch (runningOrder) { case 3: tempC[2] = coefficients[10]; tempS[1] = pSamplesOut[-11]; case 2: tempC[1] = coefficients[ 9]; tempS[2] = pSamplesOut[-10]; case 1: tempC[0] = coefficients[ 8]; tempS[3] = pSamplesOut[- 9]; } coefficients128_8 = vld1q_s32(tempC); samples128_8 = vld1q_s32(tempS); runningOrder = 0; } coefficients128_0 = ma_dr_flac__vrevq_s32(coefficients128_0); coefficients128_4 = ma_dr_flac__vrevq_s32(coefficients128_4); coefficients128_8 = ma_dr_flac__vrevq_s32(coefficients128_8); } while (pDecodedSamples < pDecodedSamplesEnd) { if (!ma_dr_flac__read_rice_parts_x1(bs, riceParam, &zeroCountParts[0], &riceParamParts[0]) || !ma_dr_flac__read_rice_parts_x1(bs, riceParam, &zeroCountParts[1], &riceParamParts[1]) || !ma_dr_flac__read_rice_parts_x1(bs, riceParam, &zeroCountParts[2], &riceParamParts[2]) || !ma_dr_flac__read_rice_parts_x1(bs, riceParam, &zeroCountParts[3], &riceParamParts[3])) { return MA_FALSE; } zeroCountPart128 = vld1q_u32(zeroCountParts); riceParamPart128 = vld1q_u32(riceParamParts); riceParamPart128 = vandq_u32(riceParamPart128, riceParamMask128); riceParamPart128 = vorrq_u32(riceParamPart128, vshlq_u32(zeroCountPart128, riceParam128)); riceParamPart128 = veorq_u32(vshrq_n_u32(riceParamPart128, 1), vaddq_u32(ma_dr_flac__vnotq_u32(vandq_u32(riceParamPart128, one128)), one128)); for (i = 0; i < 4; i += 1) { int64x1_t prediction64; prediction128 = veorq_s64(prediction128, prediction128); switch (order) { case 12: case 11: prediction128 = vaddq_s64(prediction128, vmull_s32(vget_low_s32(coefficients128_8), vget_low_s32(samples128_8))); case 10: case 9: prediction128 = vaddq_s64(prediction128, vmull_s32(vget_high_s32(coefficients128_8), vget_high_s32(samples128_8))); case 8: case 7: prediction128 = vaddq_s64(prediction128, vmull_s32(vget_low_s32(coefficients128_4), vget_low_s32(samples128_4))); case 6: case 5: prediction128 = vaddq_s64(prediction128, vmull_s32(vget_high_s32(coefficients128_4), vget_high_s32(samples128_4))); case 4: case 3: prediction128 = vaddq_s64(prediction128, vmull_s32(vget_low_s32(coefficients128_0), vget_low_s32(samples128_0))); case 2: case 1: prediction128 = vaddq_s64(prediction128, vmull_s32(vget_high_s32(coefficients128_0), vget_high_s32(samples128_0))); } prediction64 = ma_dr_flac__vhaddq_s64(prediction128); prediction64 = vshl_s64(prediction64, shift64); prediction64 = vadd_s64(prediction64, vdup_n_s64(vgetq_lane_u32(riceParamPart128, 0))); samples128_8 = ma_dr_flac__valignrq_s32_1(samples128_4, samples128_8); samples128_4 = ma_dr_flac__valignrq_s32_1(samples128_0, samples128_4); samples128_0 = ma_dr_flac__valignrq_s32_1(vcombine_s32(vreinterpret_s32_s64(prediction64), vdup_n_s32(0)), samples128_0); riceParamPart128 = ma_dr_flac__valignrq_u32_1(vdupq_n_u32(0), riceParamPart128); } vst1q_s32(pDecodedSamples, samples128_0); pDecodedSamples += 4; } i = (count & ~3); while (i < (int)count) { if (!ma_dr_flac__read_rice_parts_x1(bs, riceParam, &zeroCountParts[0], &riceParamParts[0])) { return MA_FALSE; } riceParamParts[0] &= riceParamMask; riceParamParts[0] |= (zeroCountParts[0] << riceParam); riceParamParts[0] = (riceParamParts[0] >> 1) ^ t[riceParamParts[0] & 0x01]; pDecodedSamples[0] = riceParamParts[0] + ma_dr_flac__calculate_prediction_64(order, shift, coefficients, pDecodedSamples); i += 1; pDecodedSamples += 1; } return MA_TRUE; } static ma_bool32 ma_dr_flac__decode_samples_with_residual__rice__neon(ma_dr_flac_bs* bs, ma_uint32 bitsPerSample, ma_uint32 count, ma_uint8 riceParam, ma_uint32 lpcOrder, ma_int32 lpcShift, ma_uint32 lpcPrecision, const ma_int32* coefficients, ma_int32* pSamplesOut) { MA_DR_FLAC_ASSERT(bs != NULL); MA_DR_FLAC_ASSERT(pSamplesOut != NULL); if (lpcOrder > 0 && lpcOrder <= 12) { if (ma_dr_flac__use_64_bit_prediction(bitsPerSample, lpcOrder, lpcPrecision)) { return ma_dr_flac__decode_samples_with_residual__rice__neon_64(bs, count, riceParam, lpcOrder, lpcShift, coefficients, pSamplesOut); } else { return ma_dr_flac__decode_samples_with_residual__rice__neon_32(bs, count, riceParam, lpcOrder, lpcShift, coefficients, pSamplesOut); } } else { return ma_dr_flac__decode_samples_with_residual__rice__scalar(bs, bitsPerSample, count, riceParam, lpcOrder, lpcShift, lpcPrecision, coefficients, pSamplesOut); } } #endif static ma_bool32 ma_dr_flac__decode_samples_with_residual__rice(ma_dr_flac_bs* bs, ma_uint32 bitsPerSample, ma_uint32 count, ma_uint8 riceParam, ma_uint32 lpcOrder, ma_int32 lpcShift, ma_uint32 lpcPrecision, const ma_int32* coefficients, ma_int32* pSamplesOut) { #if defined(MA_DR_FLAC_SUPPORT_SSE41) if (ma_dr_flac__gIsSSE41Supported) { return ma_dr_flac__decode_samples_with_residual__rice__sse41(bs, bitsPerSample, count, riceParam, lpcOrder, lpcShift, lpcPrecision, coefficients, pSamplesOut); } else #elif defined(MA_DR_FLAC_SUPPORT_NEON) if (ma_dr_flac__gIsNEONSupported) { return ma_dr_flac__decode_samples_with_residual__rice__neon(bs, bitsPerSample, count, riceParam, lpcOrder, lpcShift, lpcPrecision, coefficients, pSamplesOut); } else #endif { #if 0 return ma_dr_flac__decode_samples_with_residual__rice__reference(bs, bitsPerSample, count, riceParam, lpcOrder, lpcShift, lpcPrecision, coefficients, pSamplesOut); #else return ma_dr_flac__decode_samples_with_residual__rice__scalar(bs, bitsPerSample, count, riceParam, lpcOrder, lpcShift, lpcPrecision, coefficients, pSamplesOut); #endif } } static ma_bool32 ma_dr_flac__read_and_seek_residual__rice(ma_dr_flac_bs* bs, ma_uint32 count, ma_uint8 riceParam) { ma_uint32 i; MA_DR_FLAC_ASSERT(bs != NULL); for (i = 0; i < count; ++i) { if (!ma_dr_flac__seek_rice_parts(bs, riceParam)) { return MA_FALSE; } } return MA_TRUE; } #if defined(__clang__) __attribute__((no_sanitize("signed-integer-overflow"))) #endif static ma_bool32 ma_dr_flac__decode_samples_with_residual__unencoded(ma_dr_flac_bs* bs, ma_uint32 bitsPerSample, ma_uint32 count, ma_uint8 unencodedBitsPerSample, ma_uint32 lpcOrder, ma_int32 lpcShift, ma_uint32 lpcPrecision, const ma_int32* coefficients, ma_int32* pSamplesOut) { ma_uint32 i; MA_DR_FLAC_ASSERT(bs != NULL); MA_DR_FLAC_ASSERT(unencodedBitsPerSample <= 31); MA_DR_FLAC_ASSERT(pSamplesOut != NULL); for (i = 0; i < count; ++i) { if (unencodedBitsPerSample > 0) { if (!ma_dr_flac__read_int32(bs, unencodedBitsPerSample, pSamplesOut + i)) { return MA_FALSE; } } else { pSamplesOut[i] = 0; } if (ma_dr_flac__use_64_bit_prediction(bitsPerSample, lpcOrder, lpcPrecision)) { pSamplesOut[i] += ma_dr_flac__calculate_prediction_64(lpcOrder, lpcShift, coefficients, pSamplesOut + i); } else { pSamplesOut[i] += ma_dr_flac__calculate_prediction_32(lpcOrder, lpcShift, coefficients, pSamplesOut + i); } } return MA_TRUE; } static ma_bool32 ma_dr_flac__decode_samples_with_residual(ma_dr_flac_bs* bs, ma_uint32 bitsPerSample, ma_uint32 blockSize, ma_uint32 lpcOrder, ma_int32 lpcShift, ma_uint32 lpcPrecision, const ma_int32* coefficients, ma_int32* pDecodedSamples) { ma_uint8 residualMethod; ma_uint8 partitionOrder; ma_uint32 samplesInPartition; ma_uint32 partitionsRemaining; MA_DR_FLAC_ASSERT(bs != NULL); MA_DR_FLAC_ASSERT(blockSize != 0); MA_DR_FLAC_ASSERT(pDecodedSamples != NULL); if (!ma_dr_flac__read_uint8(bs, 2, &residualMethod)) { return MA_FALSE; } if (residualMethod != MA_DR_FLAC_RESIDUAL_CODING_METHOD_PARTITIONED_RICE && residualMethod != MA_DR_FLAC_RESIDUAL_CODING_METHOD_PARTITIONED_RICE2) { return MA_FALSE; } pDecodedSamples += lpcOrder; if (!ma_dr_flac__read_uint8(bs, 4, &partitionOrder)) { return MA_FALSE; } if (partitionOrder > 8) { return MA_FALSE; } if ((blockSize / (1 << partitionOrder)) < lpcOrder) { return MA_FALSE; } samplesInPartition = (blockSize / (1 << partitionOrder)) - lpcOrder; partitionsRemaining = (1 << partitionOrder); for (;;) { ma_uint8 riceParam = 0; if (residualMethod == MA_DR_FLAC_RESIDUAL_CODING_METHOD_PARTITIONED_RICE) { if (!ma_dr_flac__read_uint8(bs, 4, &riceParam)) { return MA_FALSE; } if (riceParam == 15) { riceParam = 0xFF; } } else if (residualMethod == MA_DR_FLAC_RESIDUAL_CODING_METHOD_PARTITIONED_RICE2) { if (!ma_dr_flac__read_uint8(bs, 5, &riceParam)) { return MA_FALSE; } if (riceParam == 31) { riceParam = 0xFF; } } if (riceParam != 0xFF) { if (!ma_dr_flac__decode_samples_with_residual__rice(bs, bitsPerSample, samplesInPartition, riceParam, lpcOrder, lpcShift, lpcPrecision, coefficients, pDecodedSamples)) { return MA_FALSE; } } else { ma_uint8 unencodedBitsPerSample = 0; if (!ma_dr_flac__read_uint8(bs, 5, &unencodedBitsPerSample)) { return MA_FALSE; } if (!ma_dr_flac__decode_samples_with_residual__unencoded(bs, bitsPerSample, samplesInPartition, unencodedBitsPerSample, lpcOrder, lpcShift, lpcPrecision, coefficients, pDecodedSamples)) { return MA_FALSE; } } pDecodedSamples += samplesInPartition; if (partitionsRemaining == 1) { break; } partitionsRemaining -= 1; if (partitionOrder != 0) { samplesInPartition = blockSize / (1 << partitionOrder); } } return MA_TRUE; } static ma_bool32 ma_dr_flac__read_and_seek_residual(ma_dr_flac_bs* bs, ma_uint32 blockSize, ma_uint32 order) { ma_uint8 residualMethod; ma_uint8 partitionOrder; ma_uint32 samplesInPartition; ma_uint32 partitionsRemaining; MA_DR_FLAC_ASSERT(bs != NULL); MA_DR_FLAC_ASSERT(blockSize != 0); if (!ma_dr_flac__read_uint8(bs, 2, &residualMethod)) { return MA_FALSE; } if (residualMethod != MA_DR_FLAC_RESIDUAL_CODING_METHOD_PARTITIONED_RICE && residualMethod != MA_DR_FLAC_RESIDUAL_CODING_METHOD_PARTITIONED_RICE2) { return MA_FALSE; } if (!ma_dr_flac__read_uint8(bs, 4, &partitionOrder)) { return MA_FALSE; } if (partitionOrder > 8) { return MA_FALSE; } if ((blockSize / (1 << partitionOrder)) <= order) { return MA_FALSE; } samplesInPartition = (blockSize / (1 << partitionOrder)) - order; partitionsRemaining = (1 << partitionOrder); for (;;) { ma_uint8 riceParam = 0; if (residualMethod == MA_DR_FLAC_RESIDUAL_CODING_METHOD_PARTITIONED_RICE) { if (!ma_dr_flac__read_uint8(bs, 4, &riceParam)) { return MA_FALSE; } if (riceParam == 15) { riceParam = 0xFF; } } else if (residualMethod == MA_DR_FLAC_RESIDUAL_CODING_METHOD_PARTITIONED_RICE2) { if (!ma_dr_flac__read_uint8(bs, 5, &riceParam)) { return MA_FALSE; } if (riceParam == 31) { riceParam = 0xFF; } } if (riceParam != 0xFF) { if (!ma_dr_flac__read_and_seek_residual__rice(bs, samplesInPartition, riceParam)) { return MA_FALSE; } } else { ma_uint8 unencodedBitsPerSample = 0; if (!ma_dr_flac__read_uint8(bs, 5, &unencodedBitsPerSample)) { return MA_FALSE; } if (!ma_dr_flac__seek_bits(bs, unencodedBitsPerSample * samplesInPartition)) { return MA_FALSE; } } if (partitionsRemaining == 1) { break; } partitionsRemaining -= 1; samplesInPartition = blockSize / (1 << partitionOrder); } return MA_TRUE; } static ma_bool32 ma_dr_flac__decode_samples__constant(ma_dr_flac_bs* bs, ma_uint32 blockSize, ma_uint32 subframeBitsPerSample, ma_int32* pDecodedSamples) { ma_uint32 i; ma_int32 sample; if (!ma_dr_flac__read_int32(bs, subframeBitsPerSample, &sample)) { return MA_FALSE; } for (i = 0; i < blockSize; ++i) { pDecodedSamples[i] = sample; } return MA_TRUE; } static ma_bool32 ma_dr_flac__decode_samples__verbatim(ma_dr_flac_bs* bs, ma_uint32 blockSize, ma_uint32 subframeBitsPerSample, ma_int32* pDecodedSamples) { ma_uint32 i; for (i = 0; i < blockSize; ++i) { ma_int32 sample; if (!ma_dr_flac__read_int32(bs, subframeBitsPerSample, &sample)) { return MA_FALSE; } pDecodedSamples[i] = sample; } return MA_TRUE; } static ma_bool32 ma_dr_flac__decode_samples__fixed(ma_dr_flac_bs* bs, ma_uint32 blockSize, ma_uint32 subframeBitsPerSample, ma_uint8 lpcOrder, ma_int32* pDecodedSamples) { ma_uint32 i; static ma_int32 lpcCoefficientsTable[5][4] = { {0, 0, 0, 0}, {1, 0, 0, 0}, {2, -1, 0, 0}, {3, -3, 1, 0}, {4, -6, 4, -1} }; for (i = 0; i < lpcOrder; ++i) { ma_int32 sample; if (!ma_dr_flac__read_int32(bs, subframeBitsPerSample, &sample)) { return MA_FALSE; } pDecodedSamples[i] = sample; } if (!ma_dr_flac__decode_samples_with_residual(bs, subframeBitsPerSample, blockSize, lpcOrder, 0, 4, lpcCoefficientsTable[lpcOrder], pDecodedSamples)) { return MA_FALSE; } return MA_TRUE; } static ma_bool32 ma_dr_flac__decode_samples__lpc(ma_dr_flac_bs* bs, ma_uint32 blockSize, ma_uint32 bitsPerSample, ma_uint8 lpcOrder, ma_int32* pDecodedSamples) { ma_uint8 i; ma_uint8 lpcPrecision; ma_int8 lpcShift; ma_int32 coefficients[32]; for (i = 0; i < lpcOrder; ++i) { ma_int32 sample; if (!ma_dr_flac__read_int32(bs, bitsPerSample, &sample)) { return MA_FALSE; } pDecodedSamples[i] = sample; } if (!ma_dr_flac__read_uint8(bs, 4, &lpcPrecision)) { return MA_FALSE; } if (lpcPrecision == 15) { return MA_FALSE; } lpcPrecision += 1; if (!ma_dr_flac__read_int8(bs, 5, &lpcShift)) { return MA_FALSE; } if (lpcShift < 0) { return MA_FALSE; } MA_DR_FLAC_ZERO_MEMORY(coefficients, sizeof(coefficients)); for (i = 0; i < lpcOrder; ++i) { if (!ma_dr_flac__read_int32(bs, lpcPrecision, coefficients + i)) { return MA_FALSE; } } if (!ma_dr_flac__decode_samples_with_residual(bs, bitsPerSample, blockSize, lpcOrder, lpcShift, lpcPrecision, coefficients, pDecodedSamples)) { return MA_FALSE; } return MA_TRUE; } static ma_bool32 ma_dr_flac__read_next_flac_frame_header(ma_dr_flac_bs* bs, ma_uint8 streaminfoBitsPerSample, ma_dr_flac_frame_header* header) { const ma_uint32 sampleRateTable[12] = {0, 88200, 176400, 192000, 8000, 16000, 22050, 24000, 32000, 44100, 48000, 96000}; const ma_uint8 bitsPerSampleTable[8] = {0, 8, 12, (ma_uint8)-1, 16, 20, 24, (ma_uint8)-1}; MA_DR_FLAC_ASSERT(bs != NULL); MA_DR_FLAC_ASSERT(header != NULL); for (;;) { ma_uint8 crc8 = 0xCE; ma_uint8 reserved = 0; ma_uint8 blockingStrategy = 0; ma_uint8 blockSize = 0; ma_uint8 sampleRate = 0; ma_uint8 channelAssignment = 0; ma_uint8 bitsPerSample = 0; ma_bool32 isVariableBlockSize; if (!ma_dr_flac__find_and_seek_to_next_sync_code(bs)) { return MA_FALSE; } if (!ma_dr_flac__read_uint8(bs, 1, &reserved)) { return MA_FALSE; } if (reserved == 1) { continue; } crc8 = ma_dr_flac_crc8(crc8, reserved, 1); if (!ma_dr_flac__read_uint8(bs, 1, &blockingStrategy)) { return MA_FALSE; } crc8 = ma_dr_flac_crc8(crc8, blockingStrategy, 1); if (!ma_dr_flac__read_uint8(bs, 4, &blockSize)) { return MA_FALSE; } if (blockSize == 0) { continue; } crc8 = ma_dr_flac_crc8(crc8, blockSize, 4); if (!ma_dr_flac__read_uint8(bs, 4, &sampleRate)) { return MA_FALSE; } crc8 = ma_dr_flac_crc8(crc8, sampleRate, 4); if (!ma_dr_flac__read_uint8(bs, 4, &channelAssignment)) { return MA_FALSE; } if (channelAssignment > 10) { continue; } crc8 = ma_dr_flac_crc8(crc8, channelAssignment, 4); if (!ma_dr_flac__read_uint8(bs, 3, &bitsPerSample)) { return MA_FALSE; } if (bitsPerSample == 3 || bitsPerSample == 7) { continue; } crc8 = ma_dr_flac_crc8(crc8, bitsPerSample, 3); if (!ma_dr_flac__read_uint8(bs, 1, &reserved)) { return MA_FALSE; } if (reserved == 1) { continue; } crc8 = ma_dr_flac_crc8(crc8, reserved, 1); isVariableBlockSize = blockingStrategy == 1; if (isVariableBlockSize) { ma_uint64 pcmFrameNumber; ma_result result = ma_dr_flac__read_utf8_coded_number(bs, &pcmFrameNumber, &crc8); if (result != MA_SUCCESS) { if (result == MA_AT_END) { return MA_FALSE; } else { continue; } } header->flacFrameNumber = 0; header->pcmFrameNumber = pcmFrameNumber; } else { ma_uint64 flacFrameNumber = 0; ma_result result = ma_dr_flac__read_utf8_coded_number(bs, &flacFrameNumber, &crc8); if (result != MA_SUCCESS) { if (result == MA_AT_END) { return MA_FALSE; } else { continue; } } header->flacFrameNumber = (ma_uint32)flacFrameNumber; header->pcmFrameNumber = 0; } MA_DR_FLAC_ASSERT(blockSize > 0); if (blockSize == 1) { header->blockSizeInPCMFrames = 192; } else if (blockSize <= 5) { MA_DR_FLAC_ASSERT(blockSize >= 2); header->blockSizeInPCMFrames = 576 * (1 << (blockSize - 2)); } else if (blockSize == 6) { if (!ma_dr_flac__read_uint16(bs, 8, &header->blockSizeInPCMFrames)) { return MA_FALSE; } crc8 = ma_dr_flac_crc8(crc8, header->blockSizeInPCMFrames, 8); header->blockSizeInPCMFrames += 1; } else if (blockSize == 7) { if (!ma_dr_flac__read_uint16(bs, 16, &header->blockSizeInPCMFrames)) { return MA_FALSE; } crc8 = ma_dr_flac_crc8(crc8, header->blockSizeInPCMFrames, 16); if (header->blockSizeInPCMFrames == 0xFFFF) { return MA_FALSE; } header->blockSizeInPCMFrames += 1; } else { MA_DR_FLAC_ASSERT(blockSize >= 8); header->blockSizeInPCMFrames = 256 * (1 << (blockSize - 8)); } if (sampleRate <= 11) { header->sampleRate = sampleRateTable[sampleRate]; } else if (sampleRate == 12) { if (!ma_dr_flac__read_uint32(bs, 8, &header->sampleRate)) { return MA_FALSE; } crc8 = ma_dr_flac_crc8(crc8, header->sampleRate, 8); header->sampleRate *= 1000; } else if (sampleRate == 13) { if (!ma_dr_flac__read_uint32(bs, 16, &header->sampleRate)) { return MA_FALSE; } crc8 = ma_dr_flac_crc8(crc8, header->sampleRate, 16); } else if (sampleRate == 14) { if (!ma_dr_flac__read_uint32(bs, 16, &header->sampleRate)) { return MA_FALSE; } crc8 = ma_dr_flac_crc8(crc8, header->sampleRate, 16); header->sampleRate *= 10; } else { continue; } header->channelAssignment = channelAssignment; header->bitsPerSample = bitsPerSampleTable[bitsPerSample]; if (header->bitsPerSample == 0) { header->bitsPerSample = streaminfoBitsPerSample; } if (header->bitsPerSample != streaminfoBitsPerSample) { return MA_FALSE; } if (!ma_dr_flac__read_uint8(bs, 8, &header->crc8)) { return MA_FALSE; } #ifndef MA_DR_FLAC_NO_CRC if (header->crc8 != crc8) { continue; } #endif return MA_TRUE; } } static ma_bool32 ma_dr_flac__read_subframe_header(ma_dr_flac_bs* bs, ma_dr_flac_subframe* pSubframe) { ma_uint8 header; int type; if (!ma_dr_flac__read_uint8(bs, 8, &header)) { return MA_FALSE; } if ((header & 0x80) != 0) { return MA_FALSE; } type = (header & 0x7E) >> 1; if (type == 0) { pSubframe->subframeType = MA_DR_FLAC_SUBFRAME_CONSTANT; } else if (type == 1) { pSubframe->subframeType = MA_DR_FLAC_SUBFRAME_VERBATIM; } else { if ((type & 0x20) != 0) { pSubframe->subframeType = MA_DR_FLAC_SUBFRAME_LPC; pSubframe->lpcOrder = (ma_uint8)(type & 0x1F) + 1; } else if ((type & 0x08) != 0) { pSubframe->subframeType = MA_DR_FLAC_SUBFRAME_FIXED; pSubframe->lpcOrder = (ma_uint8)(type & 0x07); if (pSubframe->lpcOrder > 4) { pSubframe->subframeType = MA_DR_FLAC_SUBFRAME_RESERVED; pSubframe->lpcOrder = 0; } } else { pSubframe->subframeType = MA_DR_FLAC_SUBFRAME_RESERVED; } } if (pSubframe->subframeType == MA_DR_FLAC_SUBFRAME_RESERVED) { return MA_FALSE; } pSubframe->wastedBitsPerSample = 0; if ((header & 0x01) == 1) { unsigned int wastedBitsPerSample; if (!ma_dr_flac__seek_past_next_set_bit(bs, &wastedBitsPerSample)) { return MA_FALSE; } pSubframe->wastedBitsPerSample = (ma_uint8)wastedBitsPerSample + 1; } return MA_TRUE; } static ma_bool32 ma_dr_flac__decode_subframe(ma_dr_flac_bs* bs, ma_dr_flac_frame* frame, int subframeIndex, ma_int32* pDecodedSamplesOut) { ma_dr_flac_subframe* pSubframe; ma_uint32 subframeBitsPerSample; MA_DR_FLAC_ASSERT(bs != NULL); MA_DR_FLAC_ASSERT(frame != NULL); pSubframe = frame->subframes + subframeIndex; if (!ma_dr_flac__read_subframe_header(bs, pSubframe)) { return MA_FALSE; } subframeBitsPerSample = frame->header.bitsPerSample; if ((frame->header.channelAssignment == MA_DR_FLAC_CHANNEL_ASSIGNMENT_LEFT_SIDE || frame->header.channelAssignment == MA_DR_FLAC_CHANNEL_ASSIGNMENT_MID_SIDE) && subframeIndex == 1) { subframeBitsPerSample += 1; } else if (frame->header.channelAssignment == MA_DR_FLAC_CHANNEL_ASSIGNMENT_RIGHT_SIDE && subframeIndex == 0) { subframeBitsPerSample += 1; } if (subframeBitsPerSample > 32) { return MA_FALSE; } if (pSubframe->wastedBitsPerSample >= subframeBitsPerSample) { return MA_FALSE; } subframeBitsPerSample -= pSubframe->wastedBitsPerSample; pSubframe->pSamplesS32 = pDecodedSamplesOut; switch (pSubframe->subframeType) { case MA_DR_FLAC_SUBFRAME_CONSTANT: { ma_dr_flac__decode_samples__constant(bs, frame->header.blockSizeInPCMFrames, subframeBitsPerSample, pSubframe->pSamplesS32); } break; case MA_DR_FLAC_SUBFRAME_VERBATIM: { ma_dr_flac__decode_samples__verbatim(bs, frame->header.blockSizeInPCMFrames, subframeBitsPerSample, pSubframe->pSamplesS32); } break; case MA_DR_FLAC_SUBFRAME_FIXED: { ma_dr_flac__decode_samples__fixed(bs, frame->header.blockSizeInPCMFrames, subframeBitsPerSample, pSubframe->lpcOrder, pSubframe->pSamplesS32); } break; case MA_DR_FLAC_SUBFRAME_LPC: { ma_dr_flac__decode_samples__lpc(bs, frame->header.blockSizeInPCMFrames, subframeBitsPerSample, pSubframe->lpcOrder, pSubframe->pSamplesS32); } break; default: return MA_FALSE; } return MA_TRUE; } static ma_bool32 ma_dr_flac__seek_subframe(ma_dr_flac_bs* bs, ma_dr_flac_frame* frame, int subframeIndex) { ma_dr_flac_subframe* pSubframe; ma_uint32 subframeBitsPerSample; MA_DR_FLAC_ASSERT(bs != NULL); MA_DR_FLAC_ASSERT(frame != NULL); pSubframe = frame->subframes + subframeIndex; if (!ma_dr_flac__read_subframe_header(bs, pSubframe)) { return MA_FALSE; } subframeBitsPerSample = frame->header.bitsPerSample; if ((frame->header.channelAssignment == MA_DR_FLAC_CHANNEL_ASSIGNMENT_LEFT_SIDE || frame->header.channelAssignment == MA_DR_FLAC_CHANNEL_ASSIGNMENT_MID_SIDE) && subframeIndex == 1) { subframeBitsPerSample += 1; } else if (frame->header.channelAssignment == MA_DR_FLAC_CHANNEL_ASSIGNMENT_RIGHT_SIDE && subframeIndex == 0) { subframeBitsPerSample += 1; } if (pSubframe->wastedBitsPerSample >= subframeBitsPerSample) { return MA_FALSE; } subframeBitsPerSample -= pSubframe->wastedBitsPerSample; pSubframe->pSamplesS32 = NULL; switch (pSubframe->subframeType) { case MA_DR_FLAC_SUBFRAME_CONSTANT: { if (!ma_dr_flac__seek_bits(bs, subframeBitsPerSample)) { return MA_FALSE; } } break; case MA_DR_FLAC_SUBFRAME_VERBATIM: { unsigned int bitsToSeek = frame->header.blockSizeInPCMFrames * subframeBitsPerSample; if (!ma_dr_flac__seek_bits(bs, bitsToSeek)) { return MA_FALSE; } } break; case MA_DR_FLAC_SUBFRAME_FIXED: { unsigned int bitsToSeek = pSubframe->lpcOrder * subframeBitsPerSample; if (!ma_dr_flac__seek_bits(bs, bitsToSeek)) { return MA_FALSE; } if (!ma_dr_flac__read_and_seek_residual(bs, frame->header.blockSizeInPCMFrames, pSubframe->lpcOrder)) { return MA_FALSE; } } break; case MA_DR_FLAC_SUBFRAME_LPC: { ma_uint8 lpcPrecision; unsigned int bitsToSeek = pSubframe->lpcOrder * subframeBitsPerSample; if (!ma_dr_flac__seek_bits(bs, bitsToSeek)) { return MA_FALSE; } if (!ma_dr_flac__read_uint8(bs, 4, &lpcPrecision)) { return MA_FALSE; } if (lpcPrecision == 15) { return MA_FALSE; } lpcPrecision += 1; bitsToSeek = (pSubframe->lpcOrder * lpcPrecision) + 5; if (!ma_dr_flac__seek_bits(bs, bitsToSeek)) { return MA_FALSE; } if (!ma_dr_flac__read_and_seek_residual(bs, frame->header.blockSizeInPCMFrames, pSubframe->lpcOrder)) { return MA_FALSE; } } break; default: return MA_FALSE; } return MA_TRUE; } static MA_INLINE ma_uint8 ma_dr_flac__get_channel_count_from_channel_assignment(ma_int8 channelAssignment) { ma_uint8 lookup[] = {1, 2, 3, 4, 5, 6, 7, 8, 2, 2, 2}; MA_DR_FLAC_ASSERT(channelAssignment <= 10); return lookup[channelAssignment]; } static ma_result ma_dr_flac__decode_flac_frame(ma_dr_flac* pFlac) { int channelCount; int i; ma_uint8 paddingSizeInBits; ma_uint16 desiredCRC16; #ifndef MA_DR_FLAC_NO_CRC ma_uint16 actualCRC16; #endif MA_DR_FLAC_ZERO_MEMORY(pFlac->currentFLACFrame.subframes, sizeof(pFlac->currentFLACFrame.subframes)); if (pFlac->currentFLACFrame.header.blockSizeInPCMFrames > pFlac->maxBlockSizeInPCMFrames) { return MA_ERROR; } channelCount = ma_dr_flac__get_channel_count_from_channel_assignment(pFlac->currentFLACFrame.header.channelAssignment); if (channelCount != (int)pFlac->channels) { return MA_ERROR; } for (i = 0; i < channelCount; ++i) { if (!ma_dr_flac__decode_subframe(&pFlac->bs, &pFlac->currentFLACFrame, i, pFlac->pDecodedSamples + (pFlac->currentFLACFrame.header.blockSizeInPCMFrames * i))) { return MA_ERROR; } } paddingSizeInBits = (ma_uint8)(MA_DR_FLAC_CACHE_L1_BITS_REMAINING(&pFlac->bs) & 7); if (paddingSizeInBits > 0) { ma_uint8 padding = 0; if (!ma_dr_flac__read_uint8(&pFlac->bs, paddingSizeInBits, &padding)) { return MA_AT_END; } } #ifndef MA_DR_FLAC_NO_CRC actualCRC16 = ma_dr_flac__flush_crc16(&pFlac->bs); #endif if (!ma_dr_flac__read_uint16(&pFlac->bs, 16, &desiredCRC16)) { return MA_AT_END; } #ifndef MA_DR_FLAC_NO_CRC if (actualCRC16 != desiredCRC16) { return MA_CRC_MISMATCH; } #endif pFlac->currentFLACFrame.pcmFramesRemaining = pFlac->currentFLACFrame.header.blockSizeInPCMFrames; return MA_SUCCESS; } static ma_result ma_dr_flac__seek_flac_frame(ma_dr_flac* pFlac) { int channelCount; int i; ma_uint16 desiredCRC16; #ifndef MA_DR_FLAC_NO_CRC ma_uint16 actualCRC16; #endif channelCount = ma_dr_flac__get_channel_count_from_channel_assignment(pFlac->currentFLACFrame.header.channelAssignment); for (i = 0; i < channelCount; ++i) { if (!ma_dr_flac__seek_subframe(&pFlac->bs, &pFlac->currentFLACFrame, i)) { return MA_ERROR; } } if (!ma_dr_flac__seek_bits(&pFlac->bs, MA_DR_FLAC_CACHE_L1_BITS_REMAINING(&pFlac->bs) & 7)) { return MA_ERROR; } #ifndef MA_DR_FLAC_NO_CRC actualCRC16 = ma_dr_flac__flush_crc16(&pFlac->bs); #endif if (!ma_dr_flac__read_uint16(&pFlac->bs, 16, &desiredCRC16)) { return MA_AT_END; } #ifndef MA_DR_FLAC_NO_CRC if (actualCRC16 != desiredCRC16) { return MA_CRC_MISMATCH; } #endif return MA_SUCCESS; } static ma_bool32 ma_dr_flac__read_and_decode_next_flac_frame(ma_dr_flac* pFlac) { MA_DR_FLAC_ASSERT(pFlac != NULL); for (;;) { ma_result result; if (!ma_dr_flac__read_next_flac_frame_header(&pFlac->bs, pFlac->bitsPerSample, &pFlac->currentFLACFrame.header)) { return MA_FALSE; } result = ma_dr_flac__decode_flac_frame(pFlac); if (result != MA_SUCCESS) { if (result == MA_CRC_MISMATCH) { continue; } else { return MA_FALSE; } } return MA_TRUE; } } static void ma_dr_flac__get_pcm_frame_range_of_current_flac_frame(ma_dr_flac* pFlac, ma_uint64* pFirstPCMFrame, ma_uint64* pLastPCMFrame) { ma_uint64 firstPCMFrame; ma_uint64 lastPCMFrame; MA_DR_FLAC_ASSERT(pFlac != NULL); firstPCMFrame = pFlac->currentFLACFrame.header.pcmFrameNumber; if (firstPCMFrame == 0) { firstPCMFrame = ((ma_uint64)pFlac->currentFLACFrame.header.flacFrameNumber) * pFlac->maxBlockSizeInPCMFrames; } lastPCMFrame = firstPCMFrame + pFlac->currentFLACFrame.header.blockSizeInPCMFrames; if (lastPCMFrame > 0) { lastPCMFrame -= 1; } if (pFirstPCMFrame) { *pFirstPCMFrame = firstPCMFrame; } if (pLastPCMFrame) { *pLastPCMFrame = lastPCMFrame; } } static ma_bool32 ma_dr_flac__seek_to_first_frame(ma_dr_flac* pFlac) { ma_bool32 result; MA_DR_FLAC_ASSERT(pFlac != NULL); result = ma_dr_flac__seek_to_byte(&pFlac->bs, pFlac->firstFLACFramePosInBytes); MA_DR_FLAC_ZERO_MEMORY(&pFlac->currentFLACFrame, sizeof(pFlac->currentFLACFrame)); pFlac->currentPCMFrame = 0; return result; } static MA_INLINE ma_result ma_dr_flac__seek_to_next_flac_frame(ma_dr_flac* pFlac) { MA_DR_FLAC_ASSERT(pFlac != NULL); return ma_dr_flac__seek_flac_frame(pFlac); } static ma_uint64 ma_dr_flac__seek_forward_by_pcm_frames(ma_dr_flac* pFlac, ma_uint64 pcmFramesToSeek) { ma_uint64 pcmFramesRead = 0; while (pcmFramesToSeek > 0) { if (pFlac->currentFLACFrame.pcmFramesRemaining == 0) { if (!ma_dr_flac__read_and_decode_next_flac_frame(pFlac)) { break; } } else { if (pFlac->currentFLACFrame.pcmFramesRemaining > pcmFramesToSeek) { pcmFramesRead += pcmFramesToSeek; pFlac->currentFLACFrame.pcmFramesRemaining -= (ma_uint32)pcmFramesToSeek; pcmFramesToSeek = 0; } else { pcmFramesRead += pFlac->currentFLACFrame.pcmFramesRemaining; pcmFramesToSeek -= pFlac->currentFLACFrame.pcmFramesRemaining; pFlac->currentFLACFrame.pcmFramesRemaining = 0; } } } pFlac->currentPCMFrame += pcmFramesRead; return pcmFramesRead; } static ma_bool32 ma_dr_flac__seek_to_pcm_frame__brute_force(ma_dr_flac* pFlac, ma_uint64 pcmFrameIndex) { ma_bool32 isMidFrame = MA_FALSE; ma_uint64 runningPCMFrameCount; MA_DR_FLAC_ASSERT(pFlac != NULL); if (pcmFrameIndex >= pFlac->currentPCMFrame) { runningPCMFrameCount = pFlac->currentPCMFrame; if (pFlac->currentPCMFrame == 0 && pFlac->currentFLACFrame.pcmFramesRemaining == 0) { if (!ma_dr_flac__read_next_flac_frame_header(&pFlac->bs, pFlac->bitsPerSample, &pFlac->currentFLACFrame.header)) { return MA_FALSE; } } else { isMidFrame = MA_TRUE; } } else { runningPCMFrameCount = 0; if (!ma_dr_flac__seek_to_first_frame(pFlac)) { return MA_FALSE; } if (!ma_dr_flac__read_next_flac_frame_header(&pFlac->bs, pFlac->bitsPerSample, &pFlac->currentFLACFrame.header)) { return MA_FALSE; } } for (;;) { ma_uint64 pcmFrameCountInThisFLACFrame; ma_uint64 firstPCMFrameInFLACFrame = 0; ma_uint64 lastPCMFrameInFLACFrame = 0; ma_dr_flac__get_pcm_frame_range_of_current_flac_frame(pFlac, &firstPCMFrameInFLACFrame, &lastPCMFrameInFLACFrame); pcmFrameCountInThisFLACFrame = (lastPCMFrameInFLACFrame - firstPCMFrameInFLACFrame) + 1; if (pcmFrameIndex < (runningPCMFrameCount + pcmFrameCountInThisFLACFrame)) { ma_uint64 pcmFramesToDecode = pcmFrameIndex - runningPCMFrameCount; if (!isMidFrame) { ma_result result = ma_dr_flac__decode_flac_frame(pFlac); if (result == MA_SUCCESS) { return ma_dr_flac__seek_forward_by_pcm_frames(pFlac, pcmFramesToDecode) == pcmFramesToDecode; } else { if (result == MA_CRC_MISMATCH) { goto next_iteration; } else { return MA_FALSE; } } } else { return ma_dr_flac__seek_forward_by_pcm_frames(pFlac, pcmFramesToDecode) == pcmFramesToDecode; } } else { if (!isMidFrame) { ma_result result = ma_dr_flac__seek_to_next_flac_frame(pFlac); if (result == MA_SUCCESS) { runningPCMFrameCount += pcmFrameCountInThisFLACFrame; } else { if (result == MA_CRC_MISMATCH) { goto next_iteration; } else { return MA_FALSE; } } } else { runningPCMFrameCount += pFlac->currentFLACFrame.pcmFramesRemaining; pFlac->currentFLACFrame.pcmFramesRemaining = 0; isMidFrame = MA_FALSE; } if (pcmFrameIndex == pFlac->totalPCMFrameCount && runningPCMFrameCount == pFlac->totalPCMFrameCount) { return MA_TRUE; } } next_iteration: if (!ma_dr_flac__read_next_flac_frame_header(&pFlac->bs, pFlac->bitsPerSample, &pFlac->currentFLACFrame.header)) { return MA_FALSE; } } } #if !defined(MA_DR_FLAC_NO_CRC) #define MA_DR_FLAC_BINARY_SEARCH_APPROX_COMPRESSION_RATIO 0.6f static ma_bool32 ma_dr_flac__seek_to_approximate_flac_frame_to_byte(ma_dr_flac* pFlac, ma_uint64 targetByte, ma_uint64 rangeLo, ma_uint64 rangeHi, ma_uint64* pLastSuccessfulSeekOffset) { MA_DR_FLAC_ASSERT(pFlac != NULL); MA_DR_FLAC_ASSERT(pLastSuccessfulSeekOffset != NULL); MA_DR_FLAC_ASSERT(targetByte >= rangeLo); MA_DR_FLAC_ASSERT(targetByte <= rangeHi); *pLastSuccessfulSeekOffset = pFlac->firstFLACFramePosInBytes; for (;;) { ma_uint64 lastTargetByte = targetByte; if (!ma_dr_flac__seek_to_byte(&pFlac->bs, targetByte)) { if (targetByte == 0) { ma_dr_flac__seek_to_first_frame(pFlac); return MA_FALSE; } targetByte = rangeLo + ((rangeHi - rangeLo)/2); rangeHi = targetByte; } else { MA_DR_FLAC_ZERO_MEMORY(&pFlac->currentFLACFrame, sizeof(pFlac->currentFLACFrame)); #if 1 if (!ma_dr_flac__read_and_decode_next_flac_frame(pFlac)) { targetByte = rangeLo + ((rangeHi - rangeLo)/2); rangeHi = targetByte; } else { break; } #else if (!ma_dr_flac__read_next_flac_frame_header(&pFlac->bs, pFlac->bitsPerSample, &pFlac->currentFLACFrame.header)) { targetByte = rangeLo + ((rangeHi - rangeLo)/2); rangeHi = targetByte; } else { break; } #endif } if(targetByte == lastTargetByte) { return MA_FALSE; } } ma_dr_flac__get_pcm_frame_range_of_current_flac_frame(pFlac, &pFlac->currentPCMFrame, NULL); MA_DR_FLAC_ASSERT(targetByte <= rangeHi); *pLastSuccessfulSeekOffset = targetByte; return MA_TRUE; } static ma_bool32 ma_dr_flac__decode_flac_frame_and_seek_forward_by_pcm_frames(ma_dr_flac* pFlac, ma_uint64 offset) { #if 0 if (ma_dr_flac__decode_flac_frame(pFlac) != MA_SUCCESS) { if (ma_dr_flac__read_and_decode_next_flac_frame(pFlac) == MA_FALSE) { return MA_FALSE; } } #endif return ma_dr_flac__seek_forward_by_pcm_frames(pFlac, offset) == offset; } static ma_bool32 ma_dr_flac__seek_to_pcm_frame__binary_search_internal(ma_dr_flac* pFlac, ma_uint64 pcmFrameIndex, ma_uint64 byteRangeLo, ma_uint64 byteRangeHi) { ma_uint64 targetByte; ma_uint64 pcmRangeLo = pFlac->totalPCMFrameCount; ma_uint64 pcmRangeHi = 0; ma_uint64 lastSuccessfulSeekOffset = (ma_uint64)-1; ma_uint64 closestSeekOffsetBeforeTargetPCMFrame = byteRangeLo; ma_uint32 seekForwardThreshold = (pFlac->maxBlockSizeInPCMFrames != 0) ? pFlac->maxBlockSizeInPCMFrames*2 : 4096; targetByte = byteRangeLo + (ma_uint64)(((ma_int64)((pcmFrameIndex - pFlac->currentPCMFrame) * pFlac->channels * pFlac->bitsPerSample)/8.0f) * MA_DR_FLAC_BINARY_SEARCH_APPROX_COMPRESSION_RATIO); if (targetByte > byteRangeHi) { targetByte = byteRangeHi; } for (;;) { if (ma_dr_flac__seek_to_approximate_flac_frame_to_byte(pFlac, targetByte, byteRangeLo, byteRangeHi, &lastSuccessfulSeekOffset)) { ma_uint64 newPCMRangeLo; ma_uint64 newPCMRangeHi; ma_dr_flac__get_pcm_frame_range_of_current_flac_frame(pFlac, &newPCMRangeLo, &newPCMRangeHi); if (pcmRangeLo == newPCMRangeLo) { if (!ma_dr_flac__seek_to_approximate_flac_frame_to_byte(pFlac, closestSeekOffsetBeforeTargetPCMFrame, closestSeekOffsetBeforeTargetPCMFrame, byteRangeHi, &lastSuccessfulSeekOffset)) { break; } if (ma_dr_flac__decode_flac_frame_and_seek_forward_by_pcm_frames(pFlac, pcmFrameIndex - pFlac->currentPCMFrame)) { return MA_TRUE; } else { break; } } pcmRangeLo = newPCMRangeLo; pcmRangeHi = newPCMRangeHi; if (pcmRangeLo <= pcmFrameIndex && pcmRangeHi >= pcmFrameIndex) { if (ma_dr_flac__decode_flac_frame_and_seek_forward_by_pcm_frames(pFlac, pcmFrameIndex - pFlac->currentPCMFrame) ) { return MA_TRUE; } else { break; } } else { const float approxCompressionRatio = (ma_int64)(lastSuccessfulSeekOffset - pFlac->firstFLACFramePosInBytes) / ((ma_int64)(pcmRangeLo * pFlac->channels * pFlac->bitsPerSample)/8.0f); if (pcmRangeLo > pcmFrameIndex) { byteRangeHi = lastSuccessfulSeekOffset; if (byteRangeLo > byteRangeHi) { byteRangeLo = byteRangeHi; } targetByte = byteRangeLo + ((byteRangeHi - byteRangeLo) / 2); if (targetByte < byteRangeLo) { targetByte = byteRangeLo; } } else { if ((pcmFrameIndex - pcmRangeLo) < seekForwardThreshold) { if (ma_dr_flac__decode_flac_frame_and_seek_forward_by_pcm_frames(pFlac, pcmFrameIndex - pFlac->currentPCMFrame)) { return MA_TRUE; } else { break; } } else { byteRangeLo = lastSuccessfulSeekOffset; if (byteRangeHi < byteRangeLo) { byteRangeHi = byteRangeLo; } targetByte = lastSuccessfulSeekOffset + (ma_uint64)(((ma_int64)((pcmFrameIndex-pcmRangeLo) * pFlac->channels * pFlac->bitsPerSample)/8.0f) * approxCompressionRatio); if (targetByte > byteRangeHi) { targetByte = byteRangeHi; } if (closestSeekOffsetBeforeTargetPCMFrame < lastSuccessfulSeekOffset) { closestSeekOffsetBeforeTargetPCMFrame = lastSuccessfulSeekOffset; } } } } } else { break; } } ma_dr_flac__seek_to_first_frame(pFlac); return MA_FALSE; } static ma_bool32 ma_dr_flac__seek_to_pcm_frame__binary_search(ma_dr_flac* pFlac, ma_uint64 pcmFrameIndex) { ma_uint64 byteRangeLo; ma_uint64 byteRangeHi; ma_uint32 seekForwardThreshold = (pFlac->maxBlockSizeInPCMFrames != 0) ? pFlac->maxBlockSizeInPCMFrames*2 : 4096; if (ma_dr_flac__seek_to_first_frame(pFlac) == MA_FALSE) { return MA_FALSE; } if (pcmFrameIndex < seekForwardThreshold) { return ma_dr_flac__seek_forward_by_pcm_frames(pFlac, pcmFrameIndex) == pcmFrameIndex; } byteRangeLo = pFlac->firstFLACFramePosInBytes; byteRangeHi = pFlac->firstFLACFramePosInBytes + (ma_uint64)((ma_int64)(pFlac->totalPCMFrameCount * pFlac->channels * pFlac->bitsPerSample)/8.0f); return ma_dr_flac__seek_to_pcm_frame__binary_search_internal(pFlac, pcmFrameIndex, byteRangeLo, byteRangeHi); } #endif static ma_bool32 ma_dr_flac__seek_to_pcm_frame__seek_table(ma_dr_flac* pFlac, ma_uint64 pcmFrameIndex) { ma_uint32 iClosestSeekpoint = 0; ma_bool32 isMidFrame = MA_FALSE; ma_uint64 runningPCMFrameCount; ma_uint32 iSeekpoint; MA_DR_FLAC_ASSERT(pFlac != NULL); if (pFlac->pSeekpoints == NULL || pFlac->seekpointCount == 0) { return MA_FALSE; } if (pFlac->pSeekpoints[0].firstPCMFrame > pcmFrameIndex) { return MA_FALSE; } for (iSeekpoint = 0; iSeekpoint < pFlac->seekpointCount; ++iSeekpoint) { if (pFlac->pSeekpoints[iSeekpoint].firstPCMFrame >= pcmFrameIndex) { break; } iClosestSeekpoint = iSeekpoint; } if (pFlac->pSeekpoints[iClosestSeekpoint].pcmFrameCount == 0 || pFlac->pSeekpoints[iClosestSeekpoint].pcmFrameCount > pFlac->maxBlockSizeInPCMFrames) { return MA_FALSE; } if (pFlac->pSeekpoints[iClosestSeekpoint].firstPCMFrame > pFlac->totalPCMFrameCount && pFlac->totalPCMFrameCount > 0) { return MA_FALSE; } #if !defined(MA_DR_FLAC_NO_CRC) if (pFlac->totalPCMFrameCount > 0) { ma_uint64 byteRangeLo; ma_uint64 byteRangeHi; byteRangeHi = pFlac->firstFLACFramePosInBytes + (ma_uint64)((ma_int64)(pFlac->totalPCMFrameCount * pFlac->channels * pFlac->bitsPerSample)/8.0f); byteRangeLo = pFlac->firstFLACFramePosInBytes + pFlac->pSeekpoints[iClosestSeekpoint].flacFrameOffset; if (iClosestSeekpoint < pFlac->seekpointCount-1) { ma_uint32 iNextSeekpoint = iClosestSeekpoint + 1; if (pFlac->pSeekpoints[iClosestSeekpoint].flacFrameOffset >= pFlac->pSeekpoints[iNextSeekpoint].flacFrameOffset || pFlac->pSeekpoints[iNextSeekpoint].pcmFrameCount == 0) { return MA_FALSE; } if (pFlac->pSeekpoints[iNextSeekpoint].firstPCMFrame != (((ma_uint64)0xFFFFFFFF << 32) | 0xFFFFFFFF)) { byteRangeHi = pFlac->firstFLACFramePosInBytes + pFlac->pSeekpoints[iNextSeekpoint].flacFrameOffset - 1; } } if (ma_dr_flac__seek_to_byte(&pFlac->bs, pFlac->firstFLACFramePosInBytes + pFlac->pSeekpoints[iClosestSeekpoint].flacFrameOffset)) { if (ma_dr_flac__read_next_flac_frame_header(&pFlac->bs, pFlac->bitsPerSample, &pFlac->currentFLACFrame.header)) { ma_dr_flac__get_pcm_frame_range_of_current_flac_frame(pFlac, &pFlac->currentPCMFrame, NULL); if (ma_dr_flac__seek_to_pcm_frame__binary_search_internal(pFlac, pcmFrameIndex, byteRangeLo, byteRangeHi)) { return MA_TRUE; } } } } #endif if (pcmFrameIndex >= pFlac->currentPCMFrame && pFlac->pSeekpoints[iClosestSeekpoint].firstPCMFrame <= pFlac->currentPCMFrame) { runningPCMFrameCount = pFlac->currentPCMFrame; if (pFlac->currentPCMFrame == 0 && pFlac->currentFLACFrame.pcmFramesRemaining == 0) { if (!ma_dr_flac__read_next_flac_frame_header(&pFlac->bs, pFlac->bitsPerSample, &pFlac->currentFLACFrame.header)) { return MA_FALSE; } } else { isMidFrame = MA_TRUE; } } else { runningPCMFrameCount = pFlac->pSeekpoints[iClosestSeekpoint].firstPCMFrame; if (!ma_dr_flac__seek_to_byte(&pFlac->bs, pFlac->firstFLACFramePosInBytes + pFlac->pSeekpoints[iClosestSeekpoint].flacFrameOffset)) { return MA_FALSE; } if (!ma_dr_flac__read_next_flac_frame_header(&pFlac->bs, pFlac->bitsPerSample, &pFlac->currentFLACFrame.header)) { return MA_FALSE; } } for (;;) { ma_uint64 pcmFrameCountInThisFLACFrame; ma_uint64 firstPCMFrameInFLACFrame = 0; ma_uint64 lastPCMFrameInFLACFrame = 0; ma_dr_flac__get_pcm_frame_range_of_current_flac_frame(pFlac, &firstPCMFrameInFLACFrame, &lastPCMFrameInFLACFrame); pcmFrameCountInThisFLACFrame = (lastPCMFrameInFLACFrame - firstPCMFrameInFLACFrame) + 1; if (pcmFrameIndex < (runningPCMFrameCount + pcmFrameCountInThisFLACFrame)) { ma_uint64 pcmFramesToDecode = pcmFrameIndex - runningPCMFrameCount; if (!isMidFrame) { ma_result result = ma_dr_flac__decode_flac_frame(pFlac); if (result == MA_SUCCESS) { return ma_dr_flac__seek_forward_by_pcm_frames(pFlac, pcmFramesToDecode) == pcmFramesToDecode; } else { if (result == MA_CRC_MISMATCH) { goto next_iteration; } else { return MA_FALSE; } } } else { return ma_dr_flac__seek_forward_by_pcm_frames(pFlac, pcmFramesToDecode) == pcmFramesToDecode; } } else { if (!isMidFrame) { ma_result result = ma_dr_flac__seek_to_next_flac_frame(pFlac); if (result == MA_SUCCESS) { runningPCMFrameCount += pcmFrameCountInThisFLACFrame; } else { if (result == MA_CRC_MISMATCH) { goto next_iteration; } else { return MA_FALSE; } } } else { runningPCMFrameCount += pFlac->currentFLACFrame.pcmFramesRemaining; pFlac->currentFLACFrame.pcmFramesRemaining = 0; isMidFrame = MA_FALSE; } if (pcmFrameIndex == pFlac->totalPCMFrameCount && runningPCMFrameCount == pFlac->totalPCMFrameCount) { return MA_TRUE; } } next_iteration: if (!ma_dr_flac__read_next_flac_frame_header(&pFlac->bs, pFlac->bitsPerSample, &pFlac->currentFLACFrame.header)) { return MA_FALSE; } } } #ifndef MA_DR_FLAC_NO_OGG typedef struct { ma_uint8 capturePattern[4]; ma_uint8 structureVersion; ma_uint8 headerType; ma_uint64 granulePosition; ma_uint32 serialNumber; ma_uint32 sequenceNumber; ma_uint32 checksum; ma_uint8 segmentCount; ma_uint8 segmentTable[255]; } ma_dr_flac_ogg_page_header; #endif typedef struct { ma_dr_flac_read_proc onRead; ma_dr_flac_seek_proc onSeek; ma_dr_flac_meta_proc onMeta; ma_dr_flac_container container; void* pUserData; void* pUserDataMD; ma_uint32 sampleRate; ma_uint8 channels; ma_uint8 bitsPerSample; ma_uint64 totalPCMFrameCount; ma_uint16 maxBlockSizeInPCMFrames; ma_uint64 runningFilePos; ma_bool32 hasStreamInfoBlock; ma_bool32 hasMetadataBlocks; ma_dr_flac_bs bs; ma_dr_flac_frame_header firstFrameHeader; #ifndef MA_DR_FLAC_NO_OGG ma_uint32 oggSerial; ma_uint64 oggFirstBytePos; ma_dr_flac_ogg_page_header oggBosHeader; #endif } ma_dr_flac_init_info; static MA_INLINE void ma_dr_flac__decode_block_header(ma_uint32 blockHeader, ma_uint8* isLastBlock, ma_uint8* blockType, ma_uint32* blockSize) { blockHeader = ma_dr_flac__be2host_32(blockHeader); *isLastBlock = (ma_uint8)((blockHeader & 0x80000000UL) >> 31); *blockType = (ma_uint8)((blockHeader & 0x7F000000UL) >> 24); *blockSize = (blockHeader & 0x00FFFFFFUL); } static MA_INLINE ma_bool32 ma_dr_flac__read_and_decode_block_header(ma_dr_flac_read_proc onRead, void* pUserData, ma_uint8* isLastBlock, ma_uint8* blockType, ma_uint32* blockSize) { ma_uint32 blockHeader; *blockSize = 0; if (onRead(pUserData, &blockHeader, 4) != 4) { return MA_FALSE; } ma_dr_flac__decode_block_header(blockHeader, isLastBlock, blockType, blockSize); return MA_TRUE; } static ma_bool32 ma_dr_flac__read_streaminfo(ma_dr_flac_read_proc onRead, void* pUserData, ma_dr_flac_streaminfo* pStreamInfo) { ma_uint32 blockSizes; ma_uint64 frameSizes = 0; ma_uint64 importantProps; ma_uint8 md5[16]; if (onRead(pUserData, &blockSizes, 4) != 4) { return MA_FALSE; } if (onRead(pUserData, &frameSizes, 6) != 6) { return MA_FALSE; } if (onRead(pUserData, &importantProps, 8) != 8) { return MA_FALSE; } if (onRead(pUserData, md5, sizeof(md5)) != sizeof(md5)) { return MA_FALSE; } blockSizes = ma_dr_flac__be2host_32(blockSizes); frameSizes = ma_dr_flac__be2host_64(frameSizes); importantProps = ma_dr_flac__be2host_64(importantProps); pStreamInfo->minBlockSizeInPCMFrames = (ma_uint16)((blockSizes & 0xFFFF0000) >> 16); pStreamInfo->maxBlockSizeInPCMFrames = (ma_uint16) (blockSizes & 0x0000FFFF); pStreamInfo->minFrameSizeInPCMFrames = (ma_uint32)((frameSizes & (((ma_uint64)0x00FFFFFF << 16) << 24)) >> 40); pStreamInfo->maxFrameSizeInPCMFrames = (ma_uint32)((frameSizes & (((ma_uint64)0x00FFFFFF << 16) << 0)) >> 16); pStreamInfo->sampleRate = (ma_uint32)((importantProps & (((ma_uint64)0x000FFFFF << 16) << 28)) >> 44); pStreamInfo->channels = (ma_uint8 )((importantProps & (((ma_uint64)0x0000000E << 16) << 24)) >> 41) + 1; pStreamInfo->bitsPerSample = (ma_uint8 )((importantProps & (((ma_uint64)0x0000001F << 16) << 20)) >> 36) + 1; pStreamInfo->totalPCMFrameCount = ((importantProps & ((((ma_uint64)0x0000000F << 16) << 16) | 0xFFFFFFFF))); MA_DR_FLAC_COPY_MEMORY(pStreamInfo->md5, md5, sizeof(md5)); return MA_TRUE; } static void* ma_dr_flac__malloc_default(size_t sz, void* pUserData) { (void)pUserData; return MA_DR_FLAC_MALLOC(sz); } static void* ma_dr_flac__realloc_default(void* p, size_t sz, void* pUserData) { (void)pUserData; return MA_DR_FLAC_REALLOC(p, sz); } static void ma_dr_flac__free_default(void* p, void* pUserData) { (void)pUserData; MA_DR_FLAC_FREE(p); } static void* ma_dr_flac__malloc_from_callbacks(size_t sz, const ma_allocation_callbacks* pAllocationCallbacks) { if (pAllocationCallbacks == NULL) { return NULL; } if (pAllocationCallbacks->onMalloc != NULL) { return pAllocationCallbacks->onMalloc(sz, pAllocationCallbacks->pUserData); } if (pAllocationCallbacks->onRealloc != NULL) { return pAllocationCallbacks->onRealloc(NULL, sz, pAllocationCallbacks->pUserData); } return NULL; } static void* ma_dr_flac__realloc_from_callbacks(void* p, size_t szNew, size_t szOld, const ma_allocation_callbacks* pAllocationCallbacks) { if (pAllocationCallbacks == NULL) { return NULL; } if (pAllocationCallbacks->onRealloc != NULL) { return pAllocationCallbacks->onRealloc(p, szNew, pAllocationCallbacks->pUserData); } if (pAllocationCallbacks->onMalloc != NULL && pAllocationCallbacks->onFree != NULL) { void* p2; p2 = pAllocationCallbacks->onMalloc(szNew, pAllocationCallbacks->pUserData); if (p2 == NULL) { return NULL; } if (p != NULL) { MA_DR_FLAC_COPY_MEMORY(p2, p, szOld); pAllocationCallbacks->onFree(p, pAllocationCallbacks->pUserData); } return p2; } return NULL; } static void ma_dr_flac__free_from_callbacks(void* p, const ma_allocation_callbacks* pAllocationCallbacks) { if (p == NULL || pAllocationCallbacks == NULL) { return; } if (pAllocationCallbacks->onFree != NULL) { pAllocationCallbacks->onFree(p, pAllocationCallbacks->pUserData); } } static ma_bool32 ma_dr_flac__read_and_decode_metadata(ma_dr_flac_read_proc onRead, ma_dr_flac_seek_proc onSeek, ma_dr_flac_meta_proc onMeta, void* pUserData, void* pUserDataMD, ma_uint64* pFirstFramePos, ma_uint64* pSeektablePos, ma_uint32* pSeekpointCount, ma_allocation_callbacks* pAllocationCallbacks) { ma_uint64 runningFilePos = 42; ma_uint64 seektablePos = 0; ma_uint32 seektableSize = 0; for (;;) { ma_dr_flac_metadata metadata; ma_uint8 isLastBlock = 0; ma_uint8 blockType = 0; ma_uint32 blockSize; if (ma_dr_flac__read_and_decode_block_header(onRead, pUserData, &isLastBlock, &blockType, &blockSize) == MA_FALSE) { return MA_FALSE; } runningFilePos += 4; metadata.type = blockType; metadata.pRawData = NULL; metadata.rawDataSize = 0; switch (blockType) { case MA_DR_FLAC_METADATA_BLOCK_TYPE_APPLICATION: { if (blockSize < 4) { return MA_FALSE; } if (onMeta) { void* pRawData = ma_dr_flac__malloc_from_callbacks(blockSize, pAllocationCallbacks); if (pRawData == NULL) { return MA_FALSE; } if (onRead(pUserData, pRawData, blockSize) != blockSize) { ma_dr_flac__free_from_callbacks(pRawData, pAllocationCallbacks); return MA_FALSE; } metadata.pRawData = pRawData; metadata.rawDataSize = blockSize; metadata.data.application.id = ma_dr_flac__be2host_32(*(ma_uint32*)pRawData); metadata.data.application.pData = (const void*)((ma_uint8*)pRawData + sizeof(ma_uint32)); metadata.data.application.dataSize = blockSize - sizeof(ma_uint32); onMeta(pUserDataMD, &metadata); ma_dr_flac__free_from_callbacks(pRawData, pAllocationCallbacks); } } break; case MA_DR_FLAC_METADATA_BLOCK_TYPE_SEEKTABLE: { seektablePos = runningFilePos; seektableSize = blockSize; if (onMeta) { ma_uint32 seekpointCount; ma_uint32 iSeekpoint; void* pRawData; seekpointCount = blockSize/MA_DR_FLAC_SEEKPOINT_SIZE_IN_BYTES; pRawData = ma_dr_flac__malloc_from_callbacks(seekpointCount * sizeof(ma_dr_flac_seekpoint), pAllocationCallbacks); if (pRawData == NULL) { return MA_FALSE; } for (iSeekpoint = 0; iSeekpoint < seekpointCount; ++iSeekpoint) { ma_dr_flac_seekpoint* pSeekpoint = (ma_dr_flac_seekpoint*)pRawData + iSeekpoint; if (onRead(pUserData, pSeekpoint, MA_DR_FLAC_SEEKPOINT_SIZE_IN_BYTES) != MA_DR_FLAC_SEEKPOINT_SIZE_IN_BYTES) { ma_dr_flac__free_from_callbacks(pRawData, pAllocationCallbacks); return MA_FALSE; } pSeekpoint->firstPCMFrame = ma_dr_flac__be2host_64(pSeekpoint->firstPCMFrame); pSeekpoint->flacFrameOffset = ma_dr_flac__be2host_64(pSeekpoint->flacFrameOffset); pSeekpoint->pcmFrameCount = ma_dr_flac__be2host_16(pSeekpoint->pcmFrameCount); } metadata.pRawData = pRawData; metadata.rawDataSize = blockSize; metadata.data.seektable.seekpointCount = seekpointCount; metadata.data.seektable.pSeekpoints = (const ma_dr_flac_seekpoint*)pRawData; onMeta(pUserDataMD, &metadata); ma_dr_flac__free_from_callbacks(pRawData, pAllocationCallbacks); } } break; case MA_DR_FLAC_METADATA_BLOCK_TYPE_VORBIS_COMMENT: { if (blockSize < 8) { return MA_FALSE; } if (onMeta) { void* pRawData; const char* pRunningData; const char* pRunningDataEnd; ma_uint32 i; pRawData = ma_dr_flac__malloc_from_callbacks(blockSize, pAllocationCallbacks); if (pRawData == NULL) { return MA_FALSE; } if (onRead(pUserData, pRawData, blockSize) != blockSize) { ma_dr_flac__free_from_callbacks(pRawData, pAllocationCallbacks); return MA_FALSE; } metadata.pRawData = pRawData; metadata.rawDataSize = blockSize; pRunningData = (const char*)pRawData; pRunningDataEnd = (const char*)pRawData + blockSize; metadata.data.vorbis_comment.vendorLength = ma_dr_flac__le2host_32_ptr_unaligned(pRunningData); pRunningData += 4; if ((pRunningDataEnd - pRunningData) - 4 < (ma_int64)metadata.data.vorbis_comment.vendorLength) { ma_dr_flac__free_from_callbacks(pRawData, pAllocationCallbacks); return MA_FALSE; } metadata.data.vorbis_comment.vendor = pRunningData; pRunningData += metadata.data.vorbis_comment.vendorLength; metadata.data.vorbis_comment.commentCount = ma_dr_flac__le2host_32_ptr_unaligned(pRunningData); pRunningData += 4; if ((pRunningDataEnd - pRunningData) / sizeof(ma_uint32) < metadata.data.vorbis_comment.commentCount) { ma_dr_flac__free_from_callbacks(pRawData, pAllocationCallbacks); return MA_FALSE; } metadata.data.vorbis_comment.pComments = pRunningData; for (i = 0; i < metadata.data.vorbis_comment.commentCount; ++i) { ma_uint32 commentLength; if (pRunningDataEnd - pRunningData < 4) { ma_dr_flac__free_from_callbacks(pRawData, pAllocationCallbacks); return MA_FALSE; } commentLength = ma_dr_flac__le2host_32_ptr_unaligned(pRunningData); pRunningData += 4; if (pRunningDataEnd - pRunningData < (ma_int64)commentLength) { ma_dr_flac__free_from_callbacks(pRawData, pAllocationCallbacks); return MA_FALSE; } pRunningData += commentLength; } onMeta(pUserDataMD, &metadata); ma_dr_flac__free_from_callbacks(pRawData, pAllocationCallbacks); } } break; case MA_DR_FLAC_METADATA_BLOCK_TYPE_CUESHEET: { if (blockSize < 396) { return MA_FALSE; } if (onMeta) { void* pRawData; const char* pRunningData; const char* pRunningDataEnd; size_t bufferSize; ma_uint8 iTrack; ma_uint8 iIndex; void* pTrackData; pRawData = ma_dr_flac__malloc_from_callbacks(blockSize, pAllocationCallbacks); if (pRawData == NULL) { return MA_FALSE; } if (onRead(pUserData, pRawData, blockSize) != blockSize) { ma_dr_flac__free_from_callbacks(pRawData, pAllocationCallbacks); return MA_FALSE; } metadata.pRawData = pRawData; metadata.rawDataSize = blockSize; pRunningData = (const char*)pRawData; pRunningDataEnd = (const char*)pRawData + blockSize; MA_DR_FLAC_COPY_MEMORY(metadata.data.cuesheet.catalog, pRunningData, 128); pRunningData += 128; metadata.data.cuesheet.leadInSampleCount = ma_dr_flac__be2host_64(*(const ma_uint64*)pRunningData); pRunningData += 8; metadata.data.cuesheet.isCD = (pRunningData[0] & 0x80) != 0; pRunningData += 259; metadata.data.cuesheet.trackCount = pRunningData[0]; pRunningData += 1; metadata.data.cuesheet.pTrackData = NULL; { const char* pRunningDataSaved = pRunningData; bufferSize = metadata.data.cuesheet.trackCount * MA_DR_FLAC_CUESHEET_TRACK_SIZE_IN_BYTES; for (iTrack = 0; iTrack < metadata.data.cuesheet.trackCount; ++iTrack) { ma_uint8 indexCount; ma_uint32 indexPointSize; if (pRunningDataEnd - pRunningData < MA_DR_FLAC_CUESHEET_TRACK_SIZE_IN_BYTES) { ma_dr_flac__free_from_callbacks(pRawData, pAllocationCallbacks); return MA_FALSE; } pRunningData += 35; indexCount = pRunningData[0]; pRunningData += 1; bufferSize += indexCount * sizeof(ma_dr_flac_cuesheet_track_index); indexPointSize = indexCount * MA_DR_FLAC_CUESHEET_TRACK_INDEX_SIZE_IN_BYTES; if (pRunningDataEnd - pRunningData < (ma_int64)indexPointSize) { ma_dr_flac__free_from_callbacks(pRawData, pAllocationCallbacks); return MA_FALSE; } pRunningData += indexPointSize; } pRunningData = pRunningDataSaved; } { char* pRunningTrackData; pTrackData = ma_dr_flac__malloc_from_callbacks(bufferSize, pAllocationCallbacks); if (pTrackData == NULL) { ma_dr_flac__free_from_callbacks(pRawData, pAllocationCallbacks); return MA_FALSE; } pRunningTrackData = (char*)pTrackData; for (iTrack = 0; iTrack < metadata.data.cuesheet.trackCount; ++iTrack) { ma_uint8 indexCount; MA_DR_FLAC_COPY_MEMORY(pRunningTrackData, pRunningData, MA_DR_FLAC_CUESHEET_TRACK_SIZE_IN_BYTES); pRunningData += MA_DR_FLAC_CUESHEET_TRACK_SIZE_IN_BYTES-1; pRunningTrackData += MA_DR_FLAC_CUESHEET_TRACK_SIZE_IN_BYTES-1; indexCount = pRunningData[0]; pRunningData += 1; pRunningTrackData += 1; for (iIndex = 0; iIndex < indexCount; ++iIndex) { ma_dr_flac_cuesheet_track_index* pTrackIndex = (ma_dr_flac_cuesheet_track_index*)pRunningTrackData; MA_DR_FLAC_COPY_MEMORY(pRunningTrackData, pRunningData, MA_DR_FLAC_CUESHEET_TRACK_INDEX_SIZE_IN_BYTES); pRunningData += MA_DR_FLAC_CUESHEET_TRACK_INDEX_SIZE_IN_BYTES; pRunningTrackData += sizeof(ma_dr_flac_cuesheet_track_index); pTrackIndex->offset = ma_dr_flac__be2host_64(pTrackIndex->offset); } } metadata.data.cuesheet.pTrackData = pTrackData; } ma_dr_flac__free_from_callbacks(pRawData, pAllocationCallbacks); pRawData = NULL; onMeta(pUserDataMD, &metadata); ma_dr_flac__free_from_callbacks(pTrackData, pAllocationCallbacks); pTrackData = NULL; } } break; case MA_DR_FLAC_METADATA_BLOCK_TYPE_PICTURE: { if (blockSize < 32) { return MA_FALSE; } if (onMeta) { void* pRawData; const char* pRunningData; const char* pRunningDataEnd; pRawData = ma_dr_flac__malloc_from_callbacks(blockSize, pAllocationCallbacks); if (pRawData == NULL) { return MA_FALSE; } if (onRead(pUserData, pRawData, blockSize) != blockSize) { ma_dr_flac__free_from_callbacks(pRawData, pAllocationCallbacks); return MA_FALSE; } metadata.pRawData = pRawData; metadata.rawDataSize = blockSize; pRunningData = (const char*)pRawData; pRunningDataEnd = (const char*)pRawData + blockSize; metadata.data.picture.type = ma_dr_flac__be2host_32_ptr_unaligned(pRunningData); pRunningData += 4; metadata.data.picture.mimeLength = ma_dr_flac__be2host_32_ptr_unaligned(pRunningData); pRunningData += 4; if ((pRunningDataEnd - pRunningData) - 24 < (ma_int64)metadata.data.picture.mimeLength) { ma_dr_flac__free_from_callbacks(pRawData, pAllocationCallbacks); return MA_FALSE; } metadata.data.picture.mime = pRunningData; pRunningData += metadata.data.picture.mimeLength; metadata.data.picture.descriptionLength = ma_dr_flac__be2host_32_ptr_unaligned(pRunningData); pRunningData += 4; if ((pRunningDataEnd - pRunningData) - 20 < (ma_int64)metadata.data.picture.descriptionLength) { ma_dr_flac__free_from_callbacks(pRawData, pAllocationCallbacks); return MA_FALSE; } metadata.data.picture.description = pRunningData; pRunningData += metadata.data.picture.descriptionLength; metadata.data.picture.width = ma_dr_flac__be2host_32_ptr_unaligned(pRunningData); pRunningData += 4; metadata.data.picture.height = ma_dr_flac__be2host_32_ptr_unaligned(pRunningData); pRunningData += 4; metadata.data.picture.colorDepth = ma_dr_flac__be2host_32_ptr_unaligned(pRunningData); pRunningData += 4; metadata.data.picture.indexColorCount = ma_dr_flac__be2host_32_ptr_unaligned(pRunningData); pRunningData += 4; metadata.data.picture.pictureDataSize = ma_dr_flac__be2host_32_ptr_unaligned(pRunningData); pRunningData += 4; metadata.data.picture.pPictureData = (const ma_uint8*)pRunningData; if (pRunningDataEnd - pRunningData < (ma_int64)metadata.data.picture.pictureDataSize) { ma_dr_flac__free_from_callbacks(pRawData, pAllocationCallbacks); return MA_FALSE; } onMeta(pUserDataMD, &metadata); ma_dr_flac__free_from_callbacks(pRawData, pAllocationCallbacks); } } break; case MA_DR_FLAC_METADATA_BLOCK_TYPE_PADDING: { if (onMeta) { metadata.data.padding.unused = 0; if (!onSeek(pUserData, blockSize, ma_dr_flac_seek_origin_current)) { isLastBlock = MA_TRUE; } else { onMeta(pUserDataMD, &metadata); } } } break; case MA_DR_FLAC_METADATA_BLOCK_TYPE_INVALID: { if (onMeta) { if (!onSeek(pUserData, blockSize, ma_dr_flac_seek_origin_current)) { isLastBlock = MA_TRUE; } } } break; default: { if (onMeta) { void* pRawData = ma_dr_flac__malloc_from_callbacks(blockSize, pAllocationCallbacks); if (pRawData == NULL) { return MA_FALSE; } if (onRead(pUserData, pRawData, blockSize) != blockSize) { ma_dr_flac__free_from_callbacks(pRawData, pAllocationCallbacks); return MA_FALSE; } metadata.pRawData = pRawData; metadata.rawDataSize = blockSize; onMeta(pUserDataMD, &metadata); ma_dr_flac__free_from_callbacks(pRawData, pAllocationCallbacks); } } break; } if (onMeta == NULL && blockSize > 0) { if (!onSeek(pUserData, blockSize, ma_dr_flac_seek_origin_current)) { isLastBlock = MA_TRUE; } } runningFilePos += blockSize; if (isLastBlock) { break; } } *pSeektablePos = seektablePos; *pSeekpointCount = seektableSize / MA_DR_FLAC_SEEKPOINT_SIZE_IN_BYTES; *pFirstFramePos = runningFilePos; return MA_TRUE; } static ma_bool32 ma_dr_flac__init_private__native(ma_dr_flac_init_info* pInit, ma_dr_flac_read_proc onRead, ma_dr_flac_seek_proc onSeek, ma_dr_flac_meta_proc onMeta, void* pUserData, void* pUserDataMD, ma_bool32 relaxed) { ma_uint8 isLastBlock; ma_uint8 blockType; ma_uint32 blockSize; (void)onSeek; pInit->container = ma_dr_flac_container_native; if (!ma_dr_flac__read_and_decode_block_header(onRead, pUserData, &isLastBlock, &blockType, &blockSize)) { return MA_FALSE; } if (blockType != MA_DR_FLAC_METADATA_BLOCK_TYPE_STREAMINFO || blockSize != 34) { if (!relaxed) { return MA_FALSE; } else { pInit->hasStreamInfoBlock = MA_FALSE; pInit->hasMetadataBlocks = MA_FALSE; if (!ma_dr_flac__read_next_flac_frame_header(&pInit->bs, 0, &pInit->firstFrameHeader)) { return MA_FALSE; } if (pInit->firstFrameHeader.bitsPerSample == 0) { return MA_FALSE; } pInit->sampleRate = pInit->firstFrameHeader.sampleRate; pInit->channels = ma_dr_flac__get_channel_count_from_channel_assignment(pInit->firstFrameHeader.channelAssignment); pInit->bitsPerSample = pInit->firstFrameHeader.bitsPerSample; pInit->maxBlockSizeInPCMFrames = 65535; return MA_TRUE; } } else { ma_dr_flac_streaminfo streaminfo; if (!ma_dr_flac__read_streaminfo(onRead, pUserData, &streaminfo)) { return MA_FALSE; } pInit->hasStreamInfoBlock = MA_TRUE; pInit->sampleRate = streaminfo.sampleRate; pInit->channels = streaminfo.channels; pInit->bitsPerSample = streaminfo.bitsPerSample; pInit->totalPCMFrameCount = streaminfo.totalPCMFrameCount; pInit->maxBlockSizeInPCMFrames = streaminfo.maxBlockSizeInPCMFrames; pInit->hasMetadataBlocks = !isLastBlock; if (onMeta) { ma_dr_flac_metadata metadata; metadata.type = MA_DR_FLAC_METADATA_BLOCK_TYPE_STREAMINFO; metadata.pRawData = NULL; metadata.rawDataSize = 0; metadata.data.streaminfo = streaminfo; onMeta(pUserDataMD, &metadata); } return MA_TRUE; } } #ifndef MA_DR_FLAC_NO_OGG #define MA_DR_FLAC_OGG_MAX_PAGE_SIZE 65307 #define MA_DR_FLAC_OGG_CAPTURE_PATTERN_CRC32 1605413199 typedef enum { ma_dr_flac_ogg_recover_on_crc_mismatch, ma_dr_flac_ogg_fail_on_crc_mismatch } ma_dr_flac_ogg_crc_mismatch_recovery; #ifndef MA_DR_FLAC_NO_CRC static ma_uint32 ma_dr_flac__crc32_table[] = { 0x00000000L, 0x04C11DB7L, 0x09823B6EL, 0x0D4326D9L, 0x130476DCL, 0x17C56B6BL, 0x1A864DB2L, 0x1E475005L, 0x2608EDB8L, 0x22C9F00FL, 0x2F8AD6D6L, 0x2B4BCB61L, 0x350C9B64L, 0x31CD86D3L, 0x3C8EA00AL, 0x384FBDBDL, 0x4C11DB70L, 0x48D0C6C7L, 0x4593E01EL, 0x4152FDA9L, 0x5F15ADACL, 0x5BD4B01BL, 0x569796C2L, 0x52568B75L, 0x6A1936C8L, 0x6ED82B7FL, 0x639B0DA6L, 0x675A1011L, 0x791D4014L, 0x7DDC5DA3L, 0x709F7B7AL, 0x745E66CDL, 0x9823B6E0L, 0x9CE2AB57L, 0x91A18D8EL, 0x95609039L, 0x8B27C03CL, 0x8FE6DD8BL, 0x82A5FB52L, 0x8664E6E5L, 0xBE2B5B58L, 0xBAEA46EFL, 0xB7A96036L, 0xB3687D81L, 0xAD2F2D84L, 0xA9EE3033L, 0xA4AD16EAL, 0xA06C0B5DL, 0xD4326D90L, 0xD0F37027L, 0xDDB056FEL, 0xD9714B49L, 0xC7361B4CL, 0xC3F706FBL, 0xCEB42022L, 0xCA753D95L, 0xF23A8028L, 0xF6FB9D9FL, 0xFBB8BB46L, 0xFF79A6F1L, 0xE13EF6F4L, 0xE5FFEB43L, 0xE8BCCD9AL, 0xEC7DD02DL, 0x34867077L, 0x30476DC0L, 0x3D044B19L, 0x39C556AEL, 0x278206ABL, 0x23431B1CL, 0x2E003DC5L, 0x2AC12072L, 0x128E9DCFL, 0x164F8078L, 0x1B0CA6A1L, 0x1FCDBB16L, 0x018AEB13L, 0x054BF6A4L, 0x0808D07DL, 0x0CC9CDCAL, 0x7897AB07L, 0x7C56B6B0L, 0x71159069L, 0x75D48DDEL, 0x6B93DDDBL, 0x6F52C06CL, 0x6211E6B5L, 0x66D0FB02L, 0x5E9F46BFL, 0x5A5E5B08L, 0x571D7DD1L, 0x53DC6066L, 0x4D9B3063L, 0x495A2DD4L, 0x44190B0DL, 0x40D816BAL, 0xACA5C697L, 0xA864DB20L, 0xA527FDF9L, 0xA1E6E04EL, 0xBFA1B04BL, 0xBB60ADFCL, 0xB6238B25L, 0xB2E29692L, 0x8AAD2B2FL, 0x8E6C3698L, 0x832F1041L, 0x87EE0DF6L, 0x99A95DF3L, 0x9D684044L, 0x902B669DL, 0x94EA7B2AL, 0xE0B41DE7L, 0xE4750050L, 0xE9362689L, 0xEDF73B3EL, 0xF3B06B3BL, 0xF771768CL, 0xFA325055L, 0xFEF34DE2L, 0xC6BCF05FL, 0xC27DEDE8L, 0xCF3ECB31L, 0xCBFFD686L, 0xD5B88683L, 0xD1799B34L, 0xDC3ABDEDL, 0xD8FBA05AL, 0x690CE0EEL, 0x6DCDFD59L, 0x608EDB80L, 0x644FC637L, 0x7A089632L, 0x7EC98B85L, 0x738AAD5CL, 0x774BB0EBL, 0x4F040D56L, 0x4BC510E1L, 0x46863638L, 0x42472B8FL, 0x5C007B8AL, 0x58C1663DL, 0x558240E4L, 0x51435D53L, 0x251D3B9EL, 0x21DC2629L, 0x2C9F00F0L, 0x285E1D47L, 0x36194D42L, 0x32D850F5L, 0x3F9B762CL, 0x3B5A6B9BL, 0x0315D626L, 0x07D4CB91L, 0x0A97ED48L, 0x0E56F0FFL, 0x1011A0FAL, 0x14D0BD4DL, 0x19939B94L, 0x1D528623L, 0xF12F560EL, 0xF5EE4BB9L, 0xF8AD6D60L, 0xFC6C70D7L, 0xE22B20D2L, 0xE6EA3D65L, 0xEBA91BBCL, 0xEF68060BL, 0xD727BBB6L, 0xD3E6A601L, 0xDEA580D8L, 0xDA649D6FL, 0xC423CD6AL, 0xC0E2D0DDL, 0xCDA1F604L, 0xC960EBB3L, 0xBD3E8D7EL, 0xB9FF90C9L, 0xB4BCB610L, 0xB07DABA7L, 0xAE3AFBA2L, 0xAAFBE615L, 0xA7B8C0CCL, 0xA379DD7BL, 0x9B3660C6L, 0x9FF77D71L, 0x92B45BA8L, 0x9675461FL, 0x8832161AL, 0x8CF30BADL, 0x81B02D74L, 0x857130C3L, 0x5D8A9099L, 0x594B8D2EL, 0x5408ABF7L, 0x50C9B640L, 0x4E8EE645L, 0x4A4FFBF2L, 0x470CDD2BL, 0x43CDC09CL, 0x7B827D21L, 0x7F436096L, 0x7200464FL, 0x76C15BF8L, 0x68860BFDL, 0x6C47164AL, 0x61043093L, 0x65C52D24L, 0x119B4BE9L, 0x155A565EL, 0x18197087L, 0x1CD86D30L, 0x029F3D35L, 0x065E2082L, 0x0B1D065BL, 0x0FDC1BECL, 0x3793A651L, 0x3352BBE6L, 0x3E119D3FL, 0x3AD08088L, 0x2497D08DL, 0x2056CD3AL, 0x2D15EBE3L, 0x29D4F654L, 0xC5A92679L, 0xC1683BCEL, 0xCC2B1D17L, 0xC8EA00A0L, 0xD6AD50A5L, 0xD26C4D12L, 0xDF2F6BCBL, 0xDBEE767CL, 0xE3A1CBC1L, 0xE760D676L, 0xEA23F0AFL, 0xEEE2ED18L, 0xF0A5BD1DL, 0xF464A0AAL, 0xF9278673L, 0xFDE69BC4L, 0x89B8FD09L, 0x8D79E0BEL, 0x803AC667L, 0x84FBDBD0L, 0x9ABC8BD5L, 0x9E7D9662L, 0x933EB0BBL, 0x97FFAD0CL, 0xAFB010B1L, 0xAB710D06L, 0xA6322BDFL, 0xA2F33668L, 0xBCB4666DL, 0xB8757BDAL, 0xB5365D03L, 0xB1F740B4L }; #endif static MA_INLINE ma_uint32 ma_dr_flac_crc32_byte(ma_uint32 crc32, ma_uint8 data) { #ifndef MA_DR_FLAC_NO_CRC return (crc32 << 8) ^ ma_dr_flac__crc32_table[(ma_uint8)((crc32 >> 24) & 0xFF) ^ data]; #else (void)data; return crc32; #endif } #if 0 static MA_INLINE ma_uint32 ma_dr_flac_crc32_uint32(ma_uint32 crc32, ma_uint32 data) { crc32 = ma_dr_flac_crc32_byte(crc32, (ma_uint8)((data >> 24) & 0xFF)); crc32 = ma_dr_flac_crc32_byte(crc32, (ma_uint8)((data >> 16) & 0xFF)); crc32 = ma_dr_flac_crc32_byte(crc32, (ma_uint8)((data >> 8) & 0xFF)); crc32 = ma_dr_flac_crc32_byte(crc32, (ma_uint8)((data >> 0) & 0xFF)); return crc32; } static MA_INLINE ma_uint32 ma_dr_flac_crc32_uint64(ma_uint32 crc32, ma_uint64 data) { crc32 = ma_dr_flac_crc32_uint32(crc32, (ma_uint32)((data >> 32) & 0xFFFFFFFF)); crc32 = ma_dr_flac_crc32_uint32(crc32, (ma_uint32)((data >> 0) & 0xFFFFFFFF)); return crc32; } #endif static MA_INLINE ma_uint32 ma_dr_flac_crc32_buffer(ma_uint32 crc32, ma_uint8* pData, ma_uint32 dataSize) { ma_uint32 i; for (i = 0; i < dataSize; ++i) { crc32 = ma_dr_flac_crc32_byte(crc32, pData[i]); } return crc32; } static MA_INLINE ma_bool32 ma_dr_flac_ogg__is_capture_pattern(ma_uint8 pattern[4]) { return pattern[0] == 'O' && pattern[1] == 'g' && pattern[2] == 'g' && pattern[3] == 'S'; } static MA_INLINE ma_uint32 ma_dr_flac_ogg__get_page_header_size(ma_dr_flac_ogg_page_header* pHeader) { return 27 + pHeader->segmentCount; } static MA_INLINE ma_uint32 ma_dr_flac_ogg__get_page_body_size(ma_dr_flac_ogg_page_header* pHeader) { ma_uint32 pageBodySize = 0; int i; for (i = 0; i < pHeader->segmentCount; ++i) { pageBodySize += pHeader->segmentTable[i]; } return pageBodySize; } static ma_result ma_dr_flac_ogg__read_page_header_after_capture_pattern(ma_dr_flac_read_proc onRead, void* pUserData, ma_dr_flac_ogg_page_header* pHeader, ma_uint32* pBytesRead, ma_uint32* pCRC32) { ma_uint8 data[23]; ma_uint32 i; MA_DR_FLAC_ASSERT(*pCRC32 == MA_DR_FLAC_OGG_CAPTURE_PATTERN_CRC32); if (onRead(pUserData, data, 23) != 23) { return MA_AT_END; } *pBytesRead += 23; pHeader->capturePattern[0] = 'O'; pHeader->capturePattern[1] = 'g'; pHeader->capturePattern[2] = 'g'; pHeader->capturePattern[3] = 'S'; pHeader->structureVersion = data[0]; pHeader->headerType = data[1]; MA_DR_FLAC_COPY_MEMORY(&pHeader->granulePosition, &data[ 2], 8); MA_DR_FLAC_COPY_MEMORY(&pHeader->serialNumber, &data[10], 4); MA_DR_FLAC_COPY_MEMORY(&pHeader->sequenceNumber, &data[14], 4); MA_DR_FLAC_COPY_MEMORY(&pHeader->checksum, &data[18], 4); pHeader->segmentCount = data[22]; data[18] = 0; data[19] = 0; data[20] = 0; data[21] = 0; for (i = 0; i < 23; ++i) { *pCRC32 = ma_dr_flac_crc32_byte(*pCRC32, data[i]); } if (onRead(pUserData, pHeader->segmentTable, pHeader->segmentCount) != pHeader->segmentCount) { return MA_AT_END; } *pBytesRead += pHeader->segmentCount; for (i = 0; i < pHeader->segmentCount; ++i) { *pCRC32 = ma_dr_flac_crc32_byte(*pCRC32, pHeader->segmentTable[i]); } return MA_SUCCESS; } static ma_result ma_dr_flac_ogg__read_page_header(ma_dr_flac_read_proc onRead, void* pUserData, ma_dr_flac_ogg_page_header* pHeader, ma_uint32* pBytesRead, ma_uint32* pCRC32) { ma_uint8 id[4]; *pBytesRead = 0; if (onRead(pUserData, id, 4) != 4) { return MA_AT_END; } *pBytesRead += 4; for (;;) { if (ma_dr_flac_ogg__is_capture_pattern(id)) { ma_result result; *pCRC32 = MA_DR_FLAC_OGG_CAPTURE_PATTERN_CRC32; result = ma_dr_flac_ogg__read_page_header_after_capture_pattern(onRead, pUserData, pHeader, pBytesRead, pCRC32); if (result == MA_SUCCESS) { return MA_SUCCESS; } else { if (result == MA_CRC_MISMATCH) { continue; } else { return result; } } } else { id[0] = id[1]; id[1] = id[2]; id[2] = id[3]; if (onRead(pUserData, &id[3], 1) != 1) { return MA_AT_END; } *pBytesRead += 1; } } } typedef struct { ma_dr_flac_read_proc onRead; ma_dr_flac_seek_proc onSeek; void* pUserData; ma_uint64 currentBytePos; ma_uint64 firstBytePos; ma_uint32 serialNumber; ma_dr_flac_ogg_page_header bosPageHeader; ma_dr_flac_ogg_page_header currentPageHeader; ma_uint32 bytesRemainingInPage; ma_uint32 pageDataSize; ma_uint8 pageData[MA_DR_FLAC_OGG_MAX_PAGE_SIZE]; } ma_dr_flac_oggbs; static size_t ma_dr_flac_oggbs__read_physical(ma_dr_flac_oggbs* oggbs, void* bufferOut, size_t bytesToRead) { size_t bytesActuallyRead = oggbs->onRead(oggbs->pUserData, bufferOut, bytesToRead); oggbs->currentBytePos += bytesActuallyRead; return bytesActuallyRead; } static ma_bool32 ma_dr_flac_oggbs__seek_physical(ma_dr_flac_oggbs* oggbs, ma_uint64 offset, ma_dr_flac_seek_origin origin) { if (origin == ma_dr_flac_seek_origin_start) { if (offset <= 0x7FFFFFFF) { if (!oggbs->onSeek(oggbs->pUserData, (int)offset, ma_dr_flac_seek_origin_start)) { return MA_FALSE; } oggbs->currentBytePos = offset; return MA_TRUE; } else { if (!oggbs->onSeek(oggbs->pUserData, 0x7FFFFFFF, ma_dr_flac_seek_origin_start)) { return MA_FALSE; } oggbs->currentBytePos = offset; return ma_dr_flac_oggbs__seek_physical(oggbs, offset - 0x7FFFFFFF, ma_dr_flac_seek_origin_current); } } else { while (offset > 0x7FFFFFFF) { if (!oggbs->onSeek(oggbs->pUserData, 0x7FFFFFFF, ma_dr_flac_seek_origin_current)) { return MA_FALSE; } oggbs->currentBytePos += 0x7FFFFFFF; offset -= 0x7FFFFFFF; } if (!oggbs->onSeek(oggbs->pUserData, (int)offset, ma_dr_flac_seek_origin_current)) { return MA_FALSE; } oggbs->currentBytePos += offset; return MA_TRUE; } } static ma_bool32 ma_dr_flac_oggbs__goto_next_page(ma_dr_flac_oggbs* oggbs, ma_dr_flac_ogg_crc_mismatch_recovery recoveryMethod) { ma_dr_flac_ogg_page_header header; for (;;) { ma_uint32 crc32 = 0; ma_uint32 bytesRead; ma_uint32 pageBodySize; #ifndef MA_DR_FLAC_NO_CRC ma_uint32 actualCRC32; #endif if (ma_dr_flac_ogg__read_page_header(oggbs->onRead, oggbs->pUserData, &header, &bytesRead, &crc32) != MA_SUCCESS) { return MA_FALSE; } oggbs->currentBytePos += bytesRead; pageBodySize = ma_dr_flac_ogg__get_page_body_size(&header); if (pageBodySize > MA_DR_FLAC_OGG_MAX_PAGE_SIZE) { continue; } if (header.serialNumber != oggbs->serialNumber) { if (pageBodySize > 0 && !ma_dr_flac_oggbs__seek_physical(oggbs, pageBodySize, ma_dr_flac_seek_origin_current)) { return MA_FALSE; } continue; } if (ma_dr_flac_oggbs__read_physical(oggbs, oggbs->pageData, pageBodySize) != pageBodySize) { return MA_FALSE; } oggbs->pageDataSize = pageBodySize; #ifndef MA_DR_FLAC_NO_CRC actualCRC32 = ma_dr_flac_crc32_buffer(crc32, oggbs->pageData, oggbs->pageDataSize); if (actualCRC32 != header.checksum) { if (recoveryMethod == ma_dr_flac_ogg_recover_on_crc_mismatch) { continue; } else { ma_dr_flac_oggbs__goto_next_page(oggbs, ma_dr_flac_ogg_recover_on_crc_mismatch); return MA_FALSE; } } #else (void)recoveryMethod; #endif oggbs->currentPageHeader = header; oggbs->bytesRemainingInPage = pageBodySize; return MA_TRUE; } } #if 0 static ma_uint8 ma_dr_flac_oggbs__get_current_segment_index(ma_dr_flac_oggbs* oggbs, ma_uint8* pBytesRemainingInSeg) { ma_uint32 bytesConsumedInPage = ma_dr_flac_ogg__get_page_body_size(&oggbs->currentPageHeader) - oggbs->bytesRemainingInPage; ma_uint8 iSeg = 0; ma_uint32 iByte = 0; while (iByte < bytesConsumedInPage) { ma_uint8 segmentSize = oggbs->currentPageHeader.segmentTable[iSeg]; if (iByte + segmentSize > bytesConsumedInPage) { break; } else { iSeg += 1; iByte += segmentSize; } } *pBytesRemainingInSeg = oggbs->currentPageHeader.segmentTable[iSeg] - (ma_uint8)(bytesConsumedInPage - iByte); return iSeg; } static ma_bool32 ma_dr_flac_oggbs__seek_to_next_packet(ma_dr_flac_oggbs* oggbs) { for (;;) { ma_bool32 atEndOfPage = MA_FALSE; ma_uint8 bytesRemainingInSeg; ma_uint8 iFirstSeg = ma_dr_flac_oggbs__get_current_segment_index(oggbs, &bytesRemainingInSeg); ma_uint32 bytesToEndOfPacketOrPage = bytesRemainingInSeg; for (ma_uint8 iSeg = iFirstSeg; iSeg < oggbs->currentPageHeader.segmentCount; ++iSeg) { ma_uint8 segmentSize = oggbs->currentPageHeader.segmentTable[iSeg]; if (segmentSize < 255) { if (iSeg == oggbs->currentPageHeader.segmentCount-1) { atEndOfPage = MA_TRUE; } break; } bytesToEndOfPacketOrPage += segmentSize; } ma_dr_flac_oggbs__seek_physical(oggbs, bytesToEndOfPacketOrPage, ma_dr_flac_seek_origin_current); oggbs->bytesRemainingInPage -= bytesToEndOfPacketOrPage; if (atEndOfPage) { if (!ma_dr_flac_oggbs__goto_next_page(oggbs)) { return MA_FALSE; } if ((oggbs->currentPageHeader.headerType & 0x01) == 0) { return MA_TRUE; } } else { return MA_TRUE; } } } static ma_bool32 ma_dr_flac_oggbs__seek_to_next_frame(ma_dr_flac_oggbs* oggbs) { return ma_dr_flac_oggbs__seek_to_next_packet(oggbs); } #endif static size_t ma_dr_flac__on_read_ogg(void* pUserData, void* bufferOut, size_t bytesToRead) { ma_dr_flac_oggbs* oggbs = (ma_dr_flac_oggbs*)pUserData; ma_uint8* pRunningBufferOut = (ma_uint8*)bufferOut; size_t bytesRead = 0; MA_DR_FLAC_ASSERT(oggbs != NULL); MA_DR_FLAC_ASSERT(pRunningBufferOut != NULL); while (bytesRead < bytesToRead) { size_t bytesRemainingToRead = bytesToRead - bytesRead; if (oggbs->bytesRemainingInPage >= bytesRemainingToRead) { MA_DR_FLAC_COPY_MEMORY(pRunningBufferOut, oggbs->pageData + (oggbs->pageDataSize - oggbs->bytesRemainingInPage), bytesRemainingToRead); bytesRead += bytesRemainingToRead; oggbs->bytesRemainingInPage -= (ma_uint32)bytesRemainingToRead; break; } if (oggbs->bytesRemainingInPage > 0) { MA_DR_FLAC_COPY_MEMORY(pRunningBufferOut, oggbs->pageData + (oggbs->pageDataSize - oggbs->bytesRemainingInPage), oggbs->bytesRemainingInPage); bytesRead += oggbs->bytesRemainingInPage; pRunningBufferOut += oggbs->bytesRemainingInPage; oggbs->bytesRemainingInPage = 0; } MA_DR_FLAC_ASSERT(bytesRemainingToRead > 0); if (!ma_dr_flac_oggbs__goto_next_page(oggbs, ma_dr_flac_ogg_recover_on_crc_mismatch)) { break; } } return bytesRead; } static ma_bool32 ma_dr_flac__on_seek_ogg(void* pUserData, int offset, ma_dr_flac_seek_origin origin) { ma_dr_flac_oggbs* oggbs = (ma_dr_flac_oggbs*)pUserData; int bytesSeeked = 0; MA_DR_FLAC_ASSERT(oggbs != NULL); MA_DR_FLAC_ASSERT(offset >= 0); if (origin == ma_dr_flac_seek_origin_start) { if (!ma_dr_flac_oggbs__seek_physical(oggbs, (int)oggbs->firstBytePos, ma_dr_flac_seek_origin_start)) { return MA_FALSE; } if (!ma_dr_flac_oggbs__goto_next_page(oggbs, ma_dr_flac_ogg_fail_on_crc_mismatch)) { return MA_FALSE; } return ma_dr_flac__on_seek_ogg(pUserData, offset, ma_dr_flac_seek_origin_current); } MA_DR_FLAC_ASSERT(origin == ma_dr_flac_seek_origin_current); while (bytesSeeked < offset) { int bytesRemainingToSeek = offset - bytesSeeked; MA_DR_FLAC_ASSERT(bytesRemainingToSeek >= 0); if (oggbs->bytesRemainingInPage >= (size_t)bytesRemainingToSeek) { bytesSeeked += bytesRemainingToSeek; (void)bytesSeeked; oggbs->bytesRemainingInPage -= bytesRemainingToSeek; break; } if (oggbs->bytesRemainingInPage > 0) { bytesSeeked += (int)oggbs->bytesRemainingInPage; oggbs->bytesRemainingInPage = 0; } MA_DR_FLAC_ASSERT(bytesRemainingToSeek > 0); if (!ma_dr_flac_oggbs__goto_next_page(oggbs, ma_dr_flac_ogg_fail_on_crc_mismatch)) { return MA_FALSE; } } return MA_TRUE; } static ma_bool32 ma_dr_flac_ogg__seek_to_pcm_frame(ma_dr_flac* pFlac, ma_uint64 pcmFrameIndex) { ma_dr_flac_oggbs* oggbs = (ma_dr_flac_oggbs*)pFlac->_oggbs; ma_uint64 originalBytePos; ma_uint64 runningGranulePosition; ma_uint64 runningFrameBytePos; ma_uint64 runningPCMFrameCount; MA_DR_FLAC_ASSERT(oggbs != NULL); originalBytePos = oggbs->currentBytePos; if (!ma_dr_flac__seek_to_byte(&pFlac->bs, pFlac->firstFLACFramePosInBytes)) { return MA_FALSE; } oggbs->bytesRemainingInPage = 0; runningGranulePosition = 0; for (;;) { if (!ma_dr_flac_oggbs__goto_next_page(oggbs, ma_dr_flac_ogg_recover_on_crc_mismatch)) { ma_dr_flac_oggbs__seek_physical(oggbs, originalBytePos, ma_dr_flac_seek_origin_start); return MA_FALSE; } runningFrameBytePos = oggbs->currentBytePos - ma_dr_flac_ogg__get_page_header_size(&oggbs->currentPageHeader) - oggbs->pageDataSize; if (oggbs->currentPageHeader.granulePosition >= pcmFrameIndex) { break; } if ((oggbs->currentPageHeader.headerType & 0x01) == 0) { if (oggbs->currentPageHeader.segmentTable[0] >= 2) { ma_uint8 firstBytesInPage[2]; firstBytesInPage[0] = oggbs->pageData[0]; firstBytesInPage[1] = oggbs->pageData[1]; if ((firstBytesInPage[0] == 0xFF) && (firstBytesInPage[1] & 0xFC) == 0xF8) { runningGranulePosition = oggbs->currentPageHeader.granulePosition; } continue; } } } if (!ma_dr_flac_oggbs__seek_physical(oggbs, runningFrameBytePos, ma_dr_flac_seek_origin_start)) { return MA_FALSE; } if (!ma_dr_flac_oggbs__goto_next_page(oggbs, ma_dr_flac_ogg_recover_on_crc_mismatch)) { return MA_FALSE; } runningPCMFrameCount = runningGranulePosition; for (;;) { ma_uint64 firstPCMFrameInFLACFrame = 0; ma_uint64 lastPCMFrameInFLACFrame = 0; ma_uint64 pcmFrameCountInThisFrame; if (!ma_dr_flac__read_next_flac_frame_header(&pFlac->bs, pFlac->bitsPerSample, &pFlac->currentFLACFrame.header)) { return MA_FALSE; } ma_dr_flac__get_pcm_frame_range_of_current_flac_frame(pFlac, &firstPCMFrameInFLACFrame, &lastPCMFrameInFLACFrame); pcmFrameCountInThisFrame = (lastPCMFrameInFLACFrame - firstPCMFrameInFLACFrame) + 1; if (pcmFrameIndex == pFlac->totalPCMFrameCount && (runningPCMFrameCount + pcmFrameCountInThisFrame) == pFlac->totalPCMFrameCount) { ma_result result = ma_dr_flac__decode_flac_frame(pFlac); if (result == MA_SUCCESS) { pFlac->currentPCMFrame = pcmFrameIndex; pFlac->currentFLACFrame.pcmFramesRemaining = 0; return MA_TRUE; } else { return MA_FALSE; } } if (pcmFrameIndex < (runningPCMFrameCount + pcmFrameCountInThisFrame)) { ma_result result = ma_dr_flac__decode_flac_frame(pFlac); if (result == MA_SUCCESS) { ma_uint64 pcmFramesToDecode = (size_t)(pcmFrameIndex - runningPCMFrameCount); if (pcmFramesToDecode == 0) { return MA_TRUE; } pFlac->currentPCMFrame = runningPCMFrameCount; return ma_dr_flac__seek_forward_by_pcm_frames(pFlac, pcmFramesToDecode) == pcmFramesToDecode; } else { if (result == MA_CRC_MISMATCH) { continue; } else { return MA_FALSE; } } } else { ma_result result = ma_dr_flac__seek_to_next_flac_frame(pFlac); if (result == MA_SUCCESS) { runningPCMFrameCount += pcmFrameCountInThisFrame; } else { if (result == MA_CRC_MISMATCH) { continue; } else { return MA_FALSE; } } } } } static ma_bool32 ma_dr_flac__init_private__ogg(ma_dr_flac_init_info* pInit, ma_dr_flac_read_proc onRead, ma_dr_flac_seek_proc onSeek, ma_dr_flac_meta_proc onMeta, void* pUserData, void* pUserDataMD, ma_bool32 relaxed) { ma_dr_flac_ogg_page_header header; ma_uint32 crc32 = MA_DR_FLAC_OGG_CAPTURE_PATTERN_CRC32; ma_uint32 bytesRead = 0; (void)relaxed; pInit->container = ma_dr_flac_container_ogg; pInit->oggFirstBytePos = 0; if (ma_dr_flac_ogg__read_page_header_after_capture_pattern(onRead, pUserData, &header, &bytesRead, &crc32) != MA_SUCCESS) { return MA_FALSE; } pInit->runningFilePos += bytesRead; for (;;) { int pageBodySize; if ((header.headerType & 0x02) == 0) { return MA_FALSE; } pageBodySize = ma_dr_flac_ogg__get_page_body_size(&header); if (pageBodySize == 51) { ma_uint32 bytesRemainingInPage = pageBodySize; ma_uint8 packetType; if (onRead(pUserData, &packetType, 1) != 1) { return MA_FALSE; } bytesRemainingInPage -= 1; if (packetType == 0x7F) { ma_uint8 sig[4]; if (onRead(pUserData, sig, 4) != 4) { return MA_FALSE; } bytesRemainingInPage -= 4; if (sig[0] == 'F' && sig[1] == 'L' && sig[2] == 'A' && sig[3] == 'C') { ma_uint8 mappingVersion[2]; if (onRead(pUserData, mappingVersion, 2) != 2) { return MA_FALSE; } if (mappingVersion[0] != 1) { return MA_FALSE; } if (!onSeek(pUserData, 2, ma_dr_flac_seek_origin_current)) { return MA_FALSE; } if (onRead(pUserData, sig, 4) != 4) { return MA_FALSE; } if (sig[0] == 'f' && sig[1] == 'L' && sig[2] == 'a' && sig[3] == 'C') { ma_dr_flac_streaminfo streaminfo; ma_uint8 isLastBlock; ma_uint8 blockType; ma_uint32 blockSize; if (!ma_dr_flac__read_and_decode_block_header(onRead, pUserData, &isLastBlock, &blockType, &blockSize)) { return MA_FALSE; } if (blockType != MA_DR_FLAC_METADATA_BLOCK_TYPE_STREAMINFO || blockSize != 34) { return MA_FALSE; } if (ma_dr_flac__read_streaminfo(onRead, pUserData, &streaminfo)) { pInit->hasStreamInfoBlock = MA_TRUE; pInit->sampleRate = streaminfo.sampleRate; pInit->channels = streaminfo.channels; pInit->bitsPerSample = streaminfo.bitsPerSample; pInit->totalPCMFrameCount = streaminfo.totalPCMFrameCount; pInit->maxBlockSizeInPCMFrames = streaminfo.maxBlockSizeInPCMFrames; pInit->hasMetadataBlocks = !isLastBlock; if (onMeta) { ma_dr_flac_metadata metadata; metadata.type = MA_DR_FLAC_METADATA_BLOCK_TYPE_STREAMINFO; metadata.pRawData = NULL; metadata.rawDataSize = 0; metadata.data.streaminfo = streaminfo; onMeta(pUserDataMD, &metadata); } pInit->runningFilePos += pageBodySize; pInit->oggFirstBytePos = pInit->runningFilePos - 79; pInit->oggSerial = header.serialNumber; pInit->oggBosHeader = header; break; } else { return MA_FALSE; } } else { return MA_FALSE; } } else { if (!onSeek(pUserData, bytesRemainingInPage, ma_dr_flac_seek_origin_current)) { return MA_FALSE; } } } else { if (!onSeek(pUserData, bytesRemainingInPage, ma_dr_flac_seek_origin_current)) { return MA_FALSE; } } } else { if (!onSeek(pUserData, pageBodySize, ma_dr_flac_seek_origin_current)) { return MA_FALSE; } } pInit->runningFilePos += pageBodySize; if (ma_dr_flac_ogg__read_page_header(onRead, pUserData, &header, &bytesRead, &crc32) != MA_SUCCESS) { return MA_FALSE; } pInit->runningFilePos += bytesRead; } pInit->hasMetadataBlocks = MA_TRUE; return MA_TRUE; } #endif static ma_bool32 ma_dr_flac__init_private(ma_dr_flac_init_info* pInit, ma_dr_flac_read_proc onRead, ma_dr_flac_seek_proc onSeek, ma_dr_flac_meta_proc onMeta, ma_dr_flac_container container, void* pUserData, void* pUserDataMD) { ma_bool32 relaxed; ma_uint8 id[4]; if (pInit == NULL || onRead == NULL || onSeek == NULL) { return MA_FALSE; } MA_DR_FLAC_ZERO_MEMORY(pInit, sizeof(*pInit)); pInit->onRead = onRead; pInit->onSeek = onSeek; pInit->onMeta = onMeta; pInit->container = container; pInit->pUserData = pUserData; pInit->pUserDataMD = pUserDataMD; pInit->bs.onRead = onRead; pInit->bs.onSeek = onSeek; pInit->bs.pUserData = pUserData; ma_dr_flac__reset_cache(&pInit->bs); relaxed = container != ma_dr_flac_container_unknown; for (;;) { if (onRead(pUserData, id, 4) != 4) { return MA_FALSE; } pInit->runningFilePos += 4; if (id[0] == 'I' && id[1] == 'D' && id[2] == '3') { ma_uint8 header[6]; ma_uint8 flags; ma_uint32 headerSize; if (onRead(pUserData, header, 6) != 6) { return MA_FALSE; } pInit->runningFilePos += 6; flags = header[1]; MA_DR_FLAC_COPY_MEMORY(&headerSize, header+2, 4); headerSize = ma_dr_flac__unsynchsafe_32(ma_dr_flac__be2host_32(headerSize)); if (flags & 0x10) { headerSize += 10; } if (!onSeek(pUserData, headerSize, ma_dr_flac_seek_origin_current)) { return MA_FALSE; } pInit->runningFilePos += headerSize; } else { break; } } if (id[0] == 'f' && id[1] == 'L' && id[2] == 'a' && id[3] == 'C') { return ma_dr_flac__init_private__native(pInit, onRead, onSeek, onMeta, pUserData, pUserDataMD, relaxed); } #ifndef MA_DR_FLAC_NO_OGG if (id[0] == 'O' && id[1] == 'g' && id[2] == 'g' && id[3] == 'S') { return ma_dr_flac__init_private__ogg(pInit, onRead, onSeek, onMeta, pUserData, pUserDataMD, relaxed); } #endif if (relaxed) { if (container == ma_dr_flac_container_native) { return ma_dr_flac__init_private__native(pInit, onRead, onSeek, onMeta, pUserData, pUserDataMD, relaxed); } #ifndef MA_DR_FLAC_NO_OGG if (container == ma_dr_flac_container_ogg) { return ma_dr_flac__init_private__ogg(pInit, onRead, onSeek, onMeta, pUserData, pUserDataMD, relaxed); } #endif } return MA_FALSE; } static void ma_dr_flac__init_from_info(ma_dr_flac* pFlac, const ma_dr_flac_init_info* pInit) { MA_DR_FLAC_ASSERT(pFlac != NULL); MA_DR_FLAC_ASSERT(pInit != NULL); MA_DR_FLAC_ZERO_MEMORY(pFlac, sizeof(*pFlac)); pFlac->bs = pInit->bs; pFlac->onMeta = pInit->onMeta; pFlac->pUserDataMD = pInit->pUserDataMD; pFlac->maxBlockSizeInPCMFrames = pInit->maxBlockSizeInPCMFrames; pFlac->sampleRate = pInit->sampleRate; pFlac->channels = (ma_uint8)pInit->channels; pFlac->bitsPerSample = (ma_uint8)pInit->bitsPerSample; pFlac->totalPCMFrameCount = pInit->totalPCMFrameCount; pFlac->container = pInit->container; } static ma_dr_flac* ma_dr_flac_open_with_metadata_private(ma_dr_flac_read_proc onRead, ma_dr_flac_seek_proc onSeek, ma_dr_flac_meta_proc onMeta, ma_dr_flac_container container, void* pUserData, void* pUserDataMD, const ma_allocation_callbacks* pAllocationCallbacks) { ma_dr_flac_init_info init; ma_uint32 allocationSize; ma_uint32 wholeSIMDVectorCountPerChannel; ma_uint32 decodedSamplesAllocationSize; #ifndef MA_DR_FLAC_NO_OGG ma_dr_flac_oggbs* pOggbs = NULL; #endif ma_uint64 firstFramePos; ma_uint64 seektablePos; ma_uint32 seekpointCount; ma_allocation_callbacks allocationCallbacks; ma_dr_flac* pFlac; ma_dr_flac__init_cpu_caps(); if (!ma_dr_flac__init_private(&init, onRead, onSeek, onMeta, container, pUserData, pUserDataMD)) { return NULL; } if (pAllocationCallbacks != NULL) { allocationCallbacks = *pAllocationCallbacks; if (allocationCallbacks.onFree == NULL || (allocationCallbacks.onMalloc == NULL && allocationCallbacks.onRealloc == NULL)) { return NULL; } } else { allocationCallbacks.pUserData = NULL; allocationCallbacks.onMalloc = ma_dr_flac__malloc_default; allocationCallbacks.onRealloc = ma_dr_flac__realloc_default; allocationCallbacks.onFree = ma_dr_flac__free_default; } allocationSize = sizeof(ma_dr_flac); if ((init.maxBlockSizeInPCMFrames % (MA_DR_FLAC_MAX_SIMD_VECTOR_SIZE / sizeof(ma_int32))) == 0) { wholeSIMDVectorCountPerChannel = (init.maxBlockSizeInPCMFrames / (MA_DR_FLAC_MAX_SIMD_VECTOR_SIZE / sizeof(ma_int32))); } else { wholeSIMDVectorCountPerChannel = (init.maxBlockSizeInPCMFrames / (MA_DR_FLAC_MAX_SIMD_VECTOR_SIZE / sizeof(ma_int32))) + 1; } decodedSamplesAllocationSize = wholeSIMDVectorCountPerChannel * MA_DR_FLAC_MAX_SIMD_VECTOR_SIZE * init.channels; allocationSize += decodedSamplesAllocationSize; allocationSize += MA_DR_FLAC_MAX_SIMD_VECTOR_SIZE; #ifndef MA_DR_FLAC_NO_OGG if (init.container == ma_dr_flac_container_ogg) { allocationSize += sizeof(ma_dr_flac_oggbs); pOggbs = (ma_dr_flac_oggbs*)ma_dr_flac__malloc_from_callbacks(sizeof(*pOggbs), &allocationCallbacks); if (pOggbs == NULL) { return NULL; } MA_DR_FLAC_ZERO_MEMORY(pOggbs, sizeof(*pOggbs)); pOggbs->onRead = onRead; pOggbs->onSeek = onSeek; pOggbs->pUserData = pUserData; pOggbs->currentBytePos = init.oggFirstBytePos; pOggbs->firstBytePos = init.oggFirstBytePos; pOggbs->serialNumber = init.oggSerial; pOggbs->bosPageHeader = init.oggBosHeader; pOggbs->bytesRemainingInPage = 0; } #endif firstFramePos = 42; seektablePos = 0; seekpointCount = 0; if (init.hasMetadataBlocks) { ma_dr_flac_read_proc onReadOverride = onRead; ma_dr_flac_seek_proc onSeekOverride = onSeek; void* pUserDataOverride = pUserData; #ifndef MA_DR_FLAC_NO_OGG if (init.container == ma_dr_flac_container_ogg) { onReadOverride = ma_dr_flac__on_read_ogg; onSeekOverride = ma_dr_flac__on_seek_ogg; pUserDataOverride = (void*)pOggbs; } #endif if (!ma_dr_flac__read_and_decode_metadata(onReadOverride, onSeekOverride, onMeta, pUserDataOverride, pUserDataMD, &firstFramePos, &seektablePos, &seekpointCount, &allocationCallbacks)) { #ifndef MA_DR_FLAC_NO_OGG ma_dr_flac__free_from_callbacks(pOggbs, &allocationCallbacks); #endif return NULL; } allocationSize += seekpointCount * sizeof(ma_dr_flac_seekpoint); } pFlac = (ma_dr_flac*)ma_dr_flac__malloc_from_callbacks(allocationSize, &allocationCallbacks); if (pFlac == NULL) { #ifndef MA_DR_FLAC_NO_OGG ma_dr_flac__free_from_callbacks(pOggbs, &allocationCallbacks); #endif return NULL; } ma_dr_flac__init_from_info(pFlac, &init); pFlac->allocationCallbacks = allocationCallbacks; pFlac->pDecodedSamples = (ma_int32*)ma_dr_flac_align((size_t)pFlac->pExtraData, MA_DR_FLAC_MAX_SIMD_VECTOR_SIZE); #ifndef MA_DR_FLAC_NO_OGG if (init.container == ma_dr_flac_container_ogg) { ma_dr_flac_oggbs* pInternalOggbs = (ma_dr_flac_oggbs*)((ma_uint8*)pFlac->pDecodedSamples + decodedSamplesAllocationSize + (seekpointCount * sizeof(ma_dr_flac_seekpoint))); MA_DR_FLAC_COPY_MEMORY(pInternalOggbs, pOggbs, sizeof(*pOggbs)); ma_dr_flac__free_from_callbacks(pOggbs, &allocationCallbacks); pOggbs = NULL; pFlac->bs.onRead = ma_dr_flac__on_read_ogg; pFlac->bs.onSeek = ma_dr_flac__on_seek_ogg; pFlac->bs.pUserData = (void*)pInternalOggbs; pFlac->_oggbs = (void*)pInternalOggbs; } #endif pFlac->firstFLACFramePosInBytes = firstFramePos; #ifndef MA_DR_FLAC_NO_OGG if (init.container == ma_dr_flac_container_ogg) { pFlac->pSeekpoints = NULL; pFlac->seekpointCount = 0; } else #endif { if (seektablePos != 0) { pFlac->seekpointCount = seekpointCount; pFlac->pSeekpoints = (ma_dr_flac_seekpoint*)((ma_uint8*)pFlac->pDecodedSamples + decodedSamplesAllocationSize); MA_DR_FLAC_ASSERT(pFlac->bs.onSeek != NULL); MA_DR_FLAC_ASSERT(pFlac->bs.onRead != NULL); if (pFlac->bs.onSeek(pFlac->bs.pUserData, (int)seektablePos, ma_dr_flac_seek_origin_start)) { ma_uint32 iSeekpoint; for (iSeekpoint = 0; iSeekpoint < seekpointCount; iSeekpoint += 1) { if (pFlac->bs.onRead(pFlac->bs.pUserData, pFlac->pSeekpoints + iSeekpoint, MA_DR_FLAC_SEEKPOINT_SIZE_IN_BYTES) == MA_DR_FLAC_SEEKPOINT_SIZE_IN_BYTES) { pFlac->pSeekpoints[iSeekpoint].firstPCMFrame = ma_dr_flac__be2host_64(pFlac->pSeekpoints[iSeekpoint].firstPCMFrame); pFlac->pSeekpoints[iSeekpoint].flacFrameOffset = ma_dr_flac__be2host_64(pFlac->pSeekpoints[iSeekpoint].flacFrameOffset); pFlac->pSeekpoints[iSeekpoint].pcmFrameCount = ma_dr_flac__be2host_16(pFlac->pSeekpoints[iSeekpoint].pcmFrameCount); } else { pFlac->pSeekpoints = NULL; pFlac->seekpointCount = 0; break; } } if (!pFlac->bs.onSeek(pFlac->bs.pUserData, (int)pFlac->firstFLACFramePosInBytes, ma_dr_flac_seek_origin_start)) { ma_dr_flac__free_from_callbacks(pFlac, &allocationCallbacks); return NULL; } } else { pFlac->pSeekpoints = NULL; pFlac->seekpointCount = 0; } } } if (!init.hasStreamInfoBlock) { pFlac->currentFLACFrame.header = init.firstFrameHeader; for (;;) { ma_result result = ma_dr_flac__decode_flac_frame(pFlac); if (result == MA_SUCCESS) { break; } else { if (result == MA_CRC_MISMATCH) { if (!ma_dr_flac__read_next_flac_frame_header(&pFlac->bs, pFlac->bitsPerSample, &pFlac->currentFLACFrame.header)) { ma_dr_flac__free_from_callbacks(pFlac, &allocationCallbacks); return NULL; } continue; } else { ma_dr_flac__free_from_callbacks(pFlac, &allocationCallbacks); return NULL; } } } } return pFlac; } #ifndef MA_DR_FLAC_NO_STDIO #include #ifndef MA_DR_FLAC_NO_WCHAR #include #endif static size_t ma_dr_flac__on_read_stdio(void* pUserData, void* bufferOut, size_t bytesToRead) { return fread(bufferOut, 1, bytesToRead, (FILE*)pUserData); } static ma_bool32 ma_dr_flac__on_seek_stdio(void* pUserData, int offset, ma_dr_flac_seek_origin origin) { MA_DR_FLAC_ASSERT(offset >= 0); return fseek((FILE*)pUserData, offset, (origin == ma_dr_flac_seek_origin_current) ? SEEK_CUR : SEEK_SET) == 0; } MA_API ma_dr_flac* ma_dr_flac_open_file(const char* pFileName, const ma_allocation_callbacks* pAllocationCallbacks) { ma_dr_flac* pFlac; FILE* pFile; if (ma_fopen(&pFile, pFileName, "rb") != MA_SUCCESS) { return NULL; } pFlac = ma_dr_flac_open(ma_dr_flac__on_read_stdio, ma_dr_flac__on_seek_stdio, (void*)pFile, pAllocationCallbacks); if (pFlac == NULL) { fclose(pFile); return NULL; } return pFlac; } #ifndef MA_DR_FLAC_NO_WCHAR MA_API ma_dr_flac* ma_dr_flac_open_file_w(const wchar_t* pFileName, const ma_allocation_callbacks* pAllocationCallbacks) { ma_dr_flac* pFlac; FILE* pFile; if (ma_wfopen(&pFile, pFileName, L"rb", pAllocationCallbacks) != MA_SUCCESS) { return NULL; } pFlac = ma_dr_flac_open(ma_dr_flac__on_read_stdio, ma_dr_flac__on_seek_stdio, (void*)pFile, pAllocationCallbacks); if (pFlac == NULL) { fclose(pFile); return NULL; } return pFlac; } #endif MA_API ma_dr_flac* ma_dr_flac_open_file_with_metadata(const char* pFileName, ma_dr_flac_meta_proc onMeta, void* pUserData, const ma_allocation_callbacks* pAllocationCallbacks) { ma_dr_flac* pFlac; FILE* pFile; if (ma_fopen(&pFile, pFileName, "rb") != MA_SUCCESS) { return NULL; } pFlac = ma_dr_flac_open_with_metadata_private(ma_dr_flac__on_read_stdio, ma_dr_flac__on_seek_stdio, onMeta, ma_dr_flac_container_unknown, (void*)pFile, pUserData, pAllocationCallbacks); if (pFlac == NULL) { fclose(pFile); return pFlac; } return pFlac; } #ifndef MA_DR_FLAC_NO_WCHAR MA_API ma_dr_flac* ma_dr_flac_open_file_with_metadata_w(const wchar_t* pFileName, ma_dr_flac_meta_proc onMeta, void* pUserData, const ma_allocation_callbacks* pAllocationCallbacks) { ma_dr_flac* pFlac; FILE* pFile; if (ma_wfopen(&pFile, pFileName, L"rb", pAllocationCallbacks) != MA_SUCCESS) { return NULL; } pFlac = ma_dr_flac_open_with_metadata_private(ma_dr_flac__on_read_stdio, ma_dr_flac__on_seek_stdio, onMeta, ma_dr_flac_container_unknown, (void*)pFile, pUserData, pAllocationCallbacks); if (pFlac == NULL) { fclose(pFile); return pFlac; } return pFlac; } #endif #endif static size_t ma_dr_flac__on_read_memory(void* pUserData, void* bufferOut, size_t bytesToRead) { ma_dr_flac__memory_stream* memoryStream = (ma_dr_flac__memory_stream*)pUserData; size_t bytesRemaining; MA_DR_FLAC_ASSERT(memoryStream != NULL); MA_DR_FLAC_ASSERT(memoryStream->dataSize >= memoryStream->currentReadPos); bytesRemaining = memoryStream->dataSize - memoryStream->currentReadPos; if (bytesToRead > bytesRemaining) { bytesToRead = bytesRemaining; } if (bytesToRead > 0) { MA_DR_FLAC_COPY_MEMORY(bufferOut, memoryStream->data + memoryStream->currentReadPos, bytesToRead); memoryStream->currentReadPos += bytesToRead; } return bytesToRead; } static ma_bool32 ma_dr_flac__on_seek_memory(void* pUserData, int offset, ma_dr_flac_seek_origin origin) { ma_dr_flac__memory_stream* memoryStream = (ma_dr_flac__memory_stream*)pUserData; MA_DR_FLAC_ASSERT(memoryStream != NULL); MA_DR_FLAC_ASSERT(offset >= 0); if (offset > (ma_int64)memoryStream->dataSize) { return MA_FALSE; } if (origin == ma_dr_flac_seek_origin_current) { if (memoryStream->currentReadPos + offset <= memoryStream->dataSize) { memoryStream->currentReadPos += offset; } else { return MA_FALSE; } } else { if ((ma_uint32)offset <= memoryStream->dataSize) { memoryStream->currentReadPos = offset; } else { return MA_FALSE; } } return MA_TRUE; } MA_API ma_dr_flac* ma_dr_flac_open_memory(const void* pData, size_t dataSize, const ma_allocation_callbacks* pAllocationCallbacks) { ma_dr_flac__memory_stream memoryStream; ma_dr_flac* pFlac; memoryStream.data = (const ma_uint8*)pData; memoryStream.dataSize = dataSize; memoryStream.currentReadPos = 0; pFlac = ma_dr_flac_open(ma_dr_flac__on_read_memory, ma_dr_flac__on_seek_memory, &memoryStream, pAllocationCallbacks); if (pFlac == NULL) { return NULL; } pFlac->memoryStream = memoryStream; #ifndef MA_DR_FLAC_NO_OGG if (pFlac->container == ma_dr_flac_container_ogg) { ma_dr_flac_oggbs* oggbs = (ma_dr_flac_oggbs*)pFlac->_oggbs; oggbs->pUserData = &pFlac->memoryStream; } else #endif { pFlac->bs.pUserData = &pFlac->memoryStream; } return pFlac; } MA_API ma_dr_flac* ma_dr_flac_open_memory_with_metadata(const void* pData, size_t dataSize, ma_dr_flac_meta_proc onMeta, void* pUserData, const ma_allocation_callbacks* pAllocationCallbacks) { ma_dr_flac__memory_stream memoryStream; ma_dr_flac* pFlac; memoryStream.data = (const ma_uint8*)pData; memoryStream.dataSize = dataSize; memoryStream.currentReadPos = 0; pFlac = ma_dr_flac_open_with_metadata_private(ma_dr_flac__on_read_memory, ma_dr_flac__on_seek_memory, onMeta, ma_dr_flac_container_unknown, &memoryStream, pUserData, pAllocationCallbacks); if (pFlac == NULL) { return NULL; } pFlac->memoryStream = memoryStream; #ifndef MA_DR_FLAC_NO_OGG if (pFlac->container == ma_dr_flac_container_ogg) { ma_dr_flac_oggbs* oggbs = (ma_dr_flac_oggbs*)pFlac->_oggbs; oggbs->pUserData = &pFlac->memoryStream; } else #endif { pFlac->bs.pUserData = &pFlac->memoryStream; } return pFlac; } MA_API ma_dr_flac* ma_dr_flac_open(ma_dr_flac_read_proc onRead, ma_dr_flac_seek_proc onSeek, void* pUserData, const ma_allocation_callbacks* pAllocationCallbacks) { return ma_dr_flac_open_with_metadata_private(onRead, onSeek, NULL, ma_dr_flac_container_unknown, pUserData, pUserData, pAllocationCallbacks); } MA_API ma_dr_flac* ma_dr_flac_open_relaxed(ma_dr_flac_read_proc onRead, ma_dr_flac_seek_proc onSeek, ma_dr_flac_container container, void* pUserData, const ma_allocation_callbacks* pAllocationCallbacks) { return ma_dr_flac_open_with_metadata_private(onRead, onSeek, NULL, container, pUserData, pUserData, pAllocationCallbacks); } MA_API ma_dr_flac* ma_dr_flac_open_with_metadata(ma_dr_flac_read_proc onRead, ma_dr_flac_seek_proc onSeek, ma_dr_flac_meta_proc onMeta, void* pUserData, const ma_allocation_callbacks* pAllocationCallbacks) { return ma_dr_flac_open_with_metadata_private(onRead, onSeek, onMeta, ma_dr_flac_container_unknown, pUserData, pUserData, pAllocationCallbacks); } MA_API ma_dr_flac* ma_dr_flac_open_with_metadata_relaxed(ma_dr_flac_read_proc onRead, ma_dr_flac_seek_proc onSeek, ma_dr_flac_meta_proc onMeta, ma_dr_flac_container container, void* pUserData, const ma_allocation_callbacks* pAllocationCallbacks) { return ma_dr_flac_open_with_metadata_private(onRead, onSeek, onMeta, container, pUserData, pUserData, pAllocationCallbacks); } MA_API void ma_dr_flac_close(ma_dr_flac* pFlac) { if (pFlac == NULL) { return; } #ifndef MA_DR_FLAC_NO_STDIO if (pFlac->bs.onRead == ma_dr_flac__on_read_stdio) { fclose((FILE*)pFlac->bs.pUserData); } #ifndef MA_DR_FLAC_NO_OGG if (pFlac->container == ma_dr_flac_container_ogg) { ma_dr_flac_oggbs* oggbs = (ma_dr_flac_oggbs*)pFlac->_oggbs; MA_DR_FLAC_ASSERT(pFlac->bs.onRead == ma_dr_flac__on_read_ogg); if (oggbs->onRead == ma_dr_flac__on_read_stdio) { fclose((FILE*)oggbs->pUserData); } } #endif #endif ma_dr_flac__free_from_callbacks(pFlac, &pFlac->allocationCallbacks); } #if 0 static MA_INLINE void ma_dr_flac_read_pcm_frames_s32__decode_left_side__reference(ma_dr_flac* pFlac, ma_uint64 frameCount, ma_uint32 unusedBitsPerSample, const ma_int32* pInputSamples0, const ma_int32* pInputSamples1, ma_int32* pOutputSamples) { ma_uint64 i; for (i = 0; i < frameCount; ++i) { ma_uint32 left = (ma_uint32)pInputSamples0[i] << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample); ma_uint32 side = (ma_uint32)pInputSamples1[i] << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample); ma_uint32 right = left - side; pOutputSamples[i*2+0] = (ma_int32)left; pOutputSamples[i*2+1] = (ma_int32)right; } } #endif static MA_INLINE void ma_dr_flac_read_pcm_frames_s32__decode_left_side__scalar(ma_dr_flac* pFlac, ma_uint64 frameCount, ma_uint32 unusedBitsPerSample, const ma_int32* pInputSamples0, const ma_int32* pInputSamples1, ma_int32* pOutputSamples) { ma_uint64 i; ma_uint64 frameCount4 = frameCount >> 2; const ma_uint32* pInputSamples0U32 = (const ma_uint32*)pInputSamples0; const ma_uint32* pInputSamples1U32 = (const ma_uint32*)pInputSamples1; ma_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample; ma_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample; for (i = 0; i < frameCount4; ++i) { ma_uint32 left0 = pInputSamples0U32[i*4+0] << shift0; ma_uint32 left1 = pInputSamples0U32[i*4+1] << shift0; ma_uint32 left2 = pInputSamples0U32[i*4+2] << shift0; ma_uint32 left3 = pInputSamples0U32[i*4+3] << shift0; ma_uint32 side0 = pInputSamples1U32[i*4+0] << shift1; ma_uint32 side1 = pInputSamples1U32[i*4+1] << shift1; ma_uint32 side2 = pInputSamples1U32[i*4+2] << shift1; ma_uint32 side3 = pInputSamples1U32[i*4+3] << shift1; ma_uint32 right0 = left0 - side0; ma_uint32 right1 = left1 - side1; ma_uint32 right2 = left2 - side2; ma_uint32 right3 = left3 - side3; pOutputSamples[i*8+0] = (ma_int32)left0; pOutputSamples[i*8+1] = (ma_int32)right0; pOutputSamples[i*8+2] = (ma_int32)left1; pOutputSamples[i*8+3] = (ma_int32)right1; pOutputSamples[i*8+4] = (ma_int32)left2; pOutputSamples[i*8+5] = (ma_int32)right2; pOutputSamples[i*8+6] = (ma_int32)left3; pOutputSamples[i*8+7] = (ma_int32)right3; } for (i = (frameCount4 << 2); i < frameCount; ++i) { ma_uint32 left = pInputSamples0U32[i] << shift0; ma_uint32 side = pInputSamples1U32[i] << shift1; ma_uint32 right = left - side; pOutputSamples[i*2+0] = (ma_int32)left; pOutputSamples[i*2+1] = (ma_int32)right; } } #if defined(MA_DR_FLAC_SUPPORT_SSE2) static MA_INLINE void ma_dr_flac_read_pcm_frames_s32__decode_left_side__sse2(ma_dr_flac* pFlac, ma_uint64 frameCount, ma_uint32 unusedBitsPerSample, const ma_int32* pInputSamples0, const ma_int32* pInputSamples1, ma_int32* pOutputSamples) { ma_uint64 i; ma_uint64 frameCount4 = frameCount >> 2; const ma_uint32* pInputSamples0U32 = (const ma_uint32*)pInputSamples0; const ma_uint32* pInputSamples1U32 = (const ma_uint32*)pInputSamples1; ma_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample; ma_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample; MA_DR_FLAC_ASSERT(pFlac->bitsPerSample <= 24); for (i = 0; i < frameCount4; ++i) { __m128i left = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples0 + i), shift0); __m128i side = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples1 + i), shift1); __m128i right = _mm_sub_epi32(left, side); _mm_storeu_si128((__m128i*)(pOutputSamples + i*8 + 0), _mm_unpacklo_epi32(left, right)); _mm_storeu_si128((__m128i*)(pOutputSamples + i*8 + 4), _mm_unpackhi_epi32(left, right)); } for (i = (frameCount4 << 2); i < frameCount; ++i) { ma_uint32 left = pInputSamples0U32[i] << shift0; ma_uint32 side = pInputSamples1U32[i] << shift1; ma_uint32 right = left - side; pOutputSamples[i*2+0] = (ma_int32)left; pOutputSamples[i*2+1] = (ma_int32)right; } } #endif #if defined(MA_DR_FLAC_SUPPORT_NEON) static MA_INLINE void ma_dr_flac_read_pcm_frames_s32__decode_left_side__neon(ma_dr_flac* pFlac, ma_uint64 frameCount, ma_uint32 unusedBitsPerSample, const ma_int32* pInputSamples0, const ma_int32* pInputSamples1, ma_int32* pOutputSamples) { ma_uint64 i; ma_uint64 frameCount4 = frameCount >> 2; const ma_uint32* pInputSamples0U32 = (const ma_uint32*)pInputSamples0; const ma_uint32* pInputSamples1U32 = (const ma_uint32*)pInputSamples1; ma_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample; ma_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample; int32x4_t shift0_4; int32x4_t shift1_4; MA_DR_FLAC_ASSERT(pFlac->bitsPerSample <= 24); shift0_4 = vdupq_n_s32(shift0); shift1_4 = vdupq_n_s32(shift1); for (i = 0; i < frameCount4; ++i) { uint32x4_t left; uint32x4_t side; uint32x4_t right; left = vshlq_u32(vld1q_u32(pInputSamples0U32 + i*4), shift0_4); side = vshlq_u32(vld1q_u32(pInputSamples1U32 + i*4), shift1_4); right = vsubq_u32(left, side); ma_dr_flac__vst2q_u32((ma_uint32*)pOutputSamples + i*8, vzipq_u32(left, right)); } for (i = (frameCount4 << 2); i < frameCount; ++i) { ma_uint32 left = pInputSamples0U32[i] << shift0; ma_uint32 side = pInputSamples1U32[i] << shift1; ma_uint32 right = left - side; pOutputSamples[i*2+0] = (ma_int32)left; pOutputSamples[i*2+1] = (ma_int32)right; } } #endif static MA_INLINE void ma_dr_flac_read_pcm_frames_s32__decode_left_side(ma_dr_flac* pFlac, ma_uint64 frameCount, ma_uint32 unusedBitsPerSample, const ma_int32* pInputSamples0, const ma_int32* pInputSamples1, ma_int32* pOutputSamples) { #if defined(MA_DR_FLAC_SUPPORT_SSE2) if (ma_dr_flac__gIsSSE2Supported && pFlac->bitsPerSample <= 24) { ma_dr_flac_read_pcm_frames_s32__decode_left_side__sse2(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples); } else #elif defined(MA_DR_FLAC_SUPPORT_NEON) if (ma_dr_flac__gIsNEONSupported && pFlac->bitsPerSample <= 24) { ma_dr_flac_read_pcm_frames_s32__decode_left_side__neon(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples); } else #endif { #if 0 ma_dr_flac_read_pcm_frames_s32__decode_left_side__reference(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples); #else ma_dr_flac_read_pcm_frames_s32__decode_left_side__scalar(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples); #endif } } #if 0 static MA_INLINE void ma_dr_flac_read_pcm_frames_s32__decode_right_side__reference(ma_dr_flac* pFlac, ma_uint64 frameCount, ma_uint32 unusedBitsPerSample, const ma_int32* pInputSamples0, const ma_int32* pInputSamples1, ma_int32* pOutputSamples) { ma_uint64 i; for (i = 0; i < frameCount; ++i) { ma_uint32 side = (ma_uint32)pInputSamples0[i] << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample); ma_uint32 right = (ma_uint32)pInputSamples1[i] << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample); ma_uint32 left = right + side; pOutputSamples[i*2+0] = (ma_int32)left; pOutputSamples[i*2+1] = (ma_int32)right; } } #endif static MA_INLINE void ma_dr_flac_read_pcm_frames_s32__decode_right_side__scalar(ma_dr_flac* pFlac, ma_uint64 frameCount, ma_uint32 unusedBitsPerSample, const ma_int32* pInputSamples0, const ma_int32* pInputSamples1, ma_int32* pOutputSamples) { ma_uint64 i; ma_uint64 frameCount4 = frameCount >> 2; const ma_uint32* pInputSamples0U32 = (const ma_uint32*)pInputSamples0; const ma_uint32* pInputSamples1U32 = (const ma_uint32*)pInputSamples1; ma_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample; ma_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample; for (i = 0; i < frameCount4; ++i) { ma_uint32 side0 = pInputSamples0U32[i*4+0] << shift0; ma_uint32 side1 = pInputSamples0U32[i*4+1] << shift0; ma_uint32 side2 = pInputSamples0U32[i*4+2] << shift0; ma_uint32 side3 = pInputSamples0U32[i*4+3] << shift0; ma_uint32 right0 = pInputSamples1U32[i*4+0] << shift1; ma_uint32 right1 = pInputSamples1U32[i*4+1] << shift1; ma_uint32 right2 = pInputSamples1U32[i*4+2] << shift1; ma_uint32 right3 = pInputSamples1U32[i*4+3] << shift1; ma_uint32 left0 = right0 + side0; ma_uint32 left1 = right1 + side1; ma_uint32 left2 = right2 + side2; ma_uint32 left3 = right3 + side3; pOutputSamples[i*8+0] = (ma_int32)left0; pOutputSamples[i*8+1] = (ma_int32)right0; pOutputSamples[i*8+2] = (ma_int32)left1; pOutputSamples[i*8+3] = (ma_int32)right1; pOutputSamples[i*8+4] = (ma_int32)left2; pOutputSamples[i*8+5] = (ma_int32)right2; pOutputSamples[i*8+6] = (ma_int32)left3; pOutputSamples[i*8+7] = (ma_int32)right3; } for (i = (frameCount4 << 2); i < frameCount; ++i) { ma_uint32 side = pInputSamples0U32[i] << shift0; ma_uint32 right = pInputSamples1U32[i] << shift1; ma_uint32 left = right + side; pOutputSamples[i*2+0] = (ma_int32)left; pOutputSamples[i*2+1] = (ma_int32)right; } } #if defined(MA_DR_FLAC_SUPPORT_SSE2) static MA_INLINE void ma_dr_flac_read_pcm_frames_s32__decode_right_side__sse2(ma_dr_flac* pFlac, ma_uint64 frameCount, ma_uint32 unusedBitsPerSample, const ma_int32* pInputSamples0, const ma_int32* pInputSamples1, ma_int32* pOutputSamples) { ma_uint64 i; ma_uint64 frameCount4 = frameCount >> 2; const ma_uint32* pInputSamples0U32 = (const ma_uint32*)pInputSamples0; const ma_uint32* pInputSamples1U32 = (const ma_uint32*)pInputSamples1; ma_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample; ma_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample; MA_DR_FLAC_ASSERT(pFlac->bitsPerSample <= 24); for (i = 0; i < frameCount4; ++i) { __m128i side = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples0 + i), shift0); __m128i right = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples1 + i), shift1); __m128i left = _mm_add_epi32(right, side); _mm_storeu_si128((__m128i*)(pOutputSamples + i*8 + 0), _mm_unpacklo_epi32(left, right)); _mm_storeu_si128((__m128i*)(pOutputSamples + i*8 + 4), _mm_unpackhi_epi32(left, right)); } for (i = (frameCount4 << 2); i < frameCount; ++i) { ma_uint32 side = pInputSamples0U32[i] << shift0; ma_uint32 right = pInputSamples1U32[i] << shift1; ma_uint32 left = right + side; pOutputSamples[i*2+0] = (ma_int32)left; pOutputSamples[i*2+1] = (ma_int32)right; } } #endif #if defined(MA_DR_FLAC_SUPPORT_NEON) static MA_INLINE void ma_dr_flac_read_pcm_frames_s32__decode_right_side__neon(ma_dr_flac* pFlac, ma_uint64 frameCount, ma_uint32 unusedBitsPerSample, const ma_int32* pInputSamples0, const ma_int32* pInputSamples1, ma_int32* pOutputSamples) { ma_uint64 i; ma_uint64 frameCount4 = frameCount >> 2; const ma_uint32* pInputSamples0U32 = (const ma_uint32*)pInputSamples0; const ma_uint32* pInputSamples1U32 = (const ma_uint32*)pInputSamples1; ma_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample; ma_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample; int32x4_t shift0_4; int32x4_t shift1_4; MA_DR_FLAC_ASSERT(pFlac->bitsPerSample <= 24); shift0_4 = vdupq_n_s32(shift0); shift1_4 = vdupq_n_s32(shift1); for (i = 0; i < frameCount4; ++i) { uint32x4_t side; uint32x4_t right; uint32x4_t left; side = vshlq_u32(vld1q_u32(pInputSamples0U32 + i*4), shift0_4); right = vshlq_u32(vld1q_u32(pInputSamples1U32 + i*4), shift1_4); left = vaddq_u32(right, side); ma_dr_flac__vst2q_u32((ma_uint32*)pOutputSamples + i*8, vzipq_u32(left, right)); } for (i = (frameCount4 << 2); i < frameCount; ++i) { ma_uint32 side = pInputSamples0U32[i] << shift0; ma_uint32 right = pInputSamples1U32[i] << shift1; ma_uint32 left = right + side; pOutputSamples[i*2+0] = (ma_int32)left; pOutputSamples[i*2+1] = (ma_int32)right; } } #endif static MA_INLINE void ma_dr_flac_read_pcm_frames_s32__decode_right_side(ma_dr_flac* pFlac, ma_uint64 frameCount, ma_uint32 unusedBitsPerSample, const ma_int32* pInputSamples0, const ma_int32* pInputSamples1, ma_int32* pOutputSamples) { #if defined(MA_DR_FLAC_SUPPORT_SSE2) if (ma_dr_flac__gIsSSE2Supported && pFlac->bitsPerSample <= 24) { ma_dr_flac_read_pcm_frames_s32__decode_right_side__sse2(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples); } else #elif defined(MA_DR_FLAC_SUPPORT_NEON) if (ma_dr_flac__gIsNEONSupported && pFlac->bitsPerSample <= 24) { ma_dr_flac_read_pcm_frames_s32__decode_right_side__neon(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples); } else #endif { #if 0 ma_dr_flac_read_pcm_frames_s32__decode_right_side__reference(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples); #else ma_dr_flac_read_pcm_frames_s32__decode_right_side__scalar(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples); #endif } } #if 0 static MA_INLINE void ma_dr_flac_read_pcm_frames_s32__decode_mid_side__reference(ma_dr_flac* pFlac, ma_uint64 frameCount, ma_uint32 unusedBitsPerSample, const ma_int32* pInputSamples0, const ma_int32* pInputSamples1, ma_int32* pOutputSamples) { for (ma_uint64 i = 0; i < frameCount; ++i) { ma_uint32 mid = pInputSamples0U32[i] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample; ma_uint32 side = pInputSamples1U32[i] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample; mid = (mid << 1) | (side & 0x01); pOutputSamples[i*2+0] = (ma_int32)((ma_uint32)((ma_int32)(mid + side) >> 1) << unusedBitsPerSample); pOutputSamples[i*2+1] = (ma_int32)((ma_uint32)((ma_int32)(mid - side) >> 1) << unusedBitsPerSample); } } #endif static MA_INLINE void ma_dr_flac_read_pcm_frames_s32__decode_mid_side__scalar(ma_dr_flac* pFlac, ma_uint64 frameCount, ma_uint32 unusedBitsPerSample, const ma_int32* pInputSamples0, const ma_int32* pInputSamples1, ma_int32* pOutputSamples) { ma_uint64 i; ma_uint64 frameCount4 = frameCount >> 2; const ma_uint32* pInputSamples0U32 = (const ma_uint32*)pInputSamples0; const ma_uint32* pInputSamples1U32 = (const ma_uint32*)pInputSamples1; ma_int32 shift = unusedBitsPerSample; if (shift > 0) { shift -= 1; for (i = 0; i < frameCount4; ++i) { ma_uint32 temp0L; ma_uint32 temp1L; ma_uint32 temp2L; ma_uint32 temp3L; ma_uint32 temp0R; ma_uint32 temp1R; ma_uint32 temp2R; ma_uint32 temp3R; ma_uint32 mid0 = pInputSamples0U32[i*4+0] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample; ma_uint32 mid1 = pInputSamples0U32[i*4+1] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample; ma_uint32 mid2 = pInputSamples0U32[i*4+2] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample; ma_uint32 mid3 = pInputSamples0U32[i*4+3] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample; ma_uint32 side0 = pInputSamples1U32[i*4+0] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample; ma_uint32 side1 = pInputSamples1U32[i*4+1] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample; ma_uint32 side2 = pInputSamples1U32[i*4+2] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample; ma_uint32 side3 = pInputSamples1U32[i*4+3] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample; mid0 = (mid0 << 1) | (side0 & 0x01); mid1 = (mid1 << 1) | (side1 & 0x01); mid2 = (mid2 << 1) | (side2 & 0x01); mid3 = (mid3 << 1) | (side3 & 0x01); temp0L = (mid0 + side0) << shift; temp1L = (mid1 + side1) << shift; temp2L = (mid2 + side2) << shift; temp3L = (mid3 + side3) << shift; temp0R = (mid0 - side0) << shift; temp1R = (mid1 - side1) << shift; temp2R = (mid2 - side2) << shift; temp3R = (mid3 - side3) << shift; pOutputSamples[i*8+0] = (ma_int32)temp0L; pOutputSamples[i*8+1] = (ma_int32)temp0R; pOutputSamples[i*8+2] = (ma_int32)temp1L; pOutputSamples[i*8+3] = (ma_int32)temp1R; pOutputSamples[i*8+4] = (ma_int32)temp2L; pOutputSamples[i*8+5] = (ma_int32)temp2R; pOutputSamples[i*8+6] = (ma_int32)temp3L; pOutputSamples[i*8+7] = (ma_int32)temp3R; } } else { for (i = 0; i < frameCount4; ++i) { ma_uint32 temp0L; ma_uint32 temp1L; ma_uint32 temp2L; ma_uint32 temp3L; ma_uint32 temp0R; ma_uint32 temp1R; ma_uint32 temp2R; ma_uint32 temp3R; ma_uint32 mid0 = pInputSamples0U32[i*4+0] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample; ma_uint32 mid1 = pInputSamples0U32[i*4+1] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample; ma_uint32 mid2 = pInputSamples0U32[i*4+2] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample; ma_uint32 mid3 = pInputSamples0U32[i*4+3] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample; ma_uint32 side0 = pInputSamples1U32[i*4+0] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample; ma_uint32 side1 = pInputSamples1U32[i*4+1] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample; ma_uint32 side2 = pInputSamples1U32[i*4+2] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample; ma_uint32 side3 = pInputSamples1U32[i*4+3] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample; mid0 = (mid0 << 1) | (side0 & 0x01); mid1 = (mid1 << 1) | (side1 & 0x01); mid2 = (mid2 << 1) | (side2 & 0x01); mid3 = (mid3 << 1) | (side3 & 0x01); temp0L = (ma_uint32)((ma_int32)(mid0 + side0) >> 1); temp1L = (ma_uint32)((ma_int32)(mid1 + side1) >> 1); temp2L = (ma_uint32)((ma_int32)(mid2 + side2) >> 1); temp3L = (ma_uint32)((ma_int32)(mid3 + side3) >> 1); temp0R = (ma_uint32)((ma_int32)(mid0 - side0) >> 1); temp1R = (ma_uint32)((ma_int32)(mid1 - side1) >> 1); temp2R = (ma_uint32)((ma_int32)(mid2 - side2) >> 1); temp3R = (ma_uint32)((ma_int32)(mid3 - side3) >> 1); pOutputSamples[i*8+0] = (ma_int32)temp0L; pOutputSamples[i*8+1] = (ma_int32)temp0R; pOutputSamples[i*8+2] = (ma_int32)temp1L; pOutputSamples[i*8+3] = (ma_int32)temp1R; pOutputSamples[i*8+4] = (ma_int32)temp2L; pOutputSamples[i*8+5] = (ma_int32)temp2R; pOutputSamples[i*8+6] = (ma_int32)temp3L; pOutputSamples[i*8+7] = (ma_int32)temp3R; } } for (i = (frameCount4 << 2); i < frameCount; ++i) { ma_uint32 mid = pInputSamples0U32[i] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample; ma_uint32 side = pInputSamples1U32[i] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample; mid = (mid << 1) | (side & 0x01); pOutputSamples[i*2+0] = (ma_int32)((ma_uint32)((ma_int32)(mid + side) >> 1) << unusedBitsPerSample); pOutputSamples[i*2+1] = (ma_int32)((ma_uint32)((ma_int32)(mid - side) >> 1) << unusedBitsPerSample); } } #if defined(MA_DR_FLAC_SUPPORT_SSE2) static MA_INLINE void ma_dr_flac_read_pcm_frames_s32__decode_mid_side__sse2(ma_dr_flac* pFlac, ma_uint64 frameCount, ma_uint32 unusedBitsPerSample, const ma_int32* pInputSamples0, const ma_int32* pInputSamples1, ma_int32* pOutputSamples) { ma_uint64 i; ma_uint64 frameCount4 = frameCount >> 2; const ma_uint32* pInputSamples0U32 = (const ma_uint32*)pInputSamples0; const ma_uint32* pInputSamples1U32 = (const ma_uint32*)pInputSamples1; ma_int32 shift = unusedBitsPerSample; MA_DR_FLAC_ASSERT(pFlac->bitsPerSample <= 24); if (shift == 0) { for (i = 0; i < frameCount4; ++i) { __m128i mid; __m128i side; __m128i left; __m128i right; mid = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples0 + i), pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample); side = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples1 + i), pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample); mid = _mm_or_si128(_mm_slli_epi32(mid, 1), _mm_and_si128(side, _mm_set1_epi32(0x01))); left = _mm_srai_epi32(_mm_add_epi32(mid, side), 1); right = _mm_srai_epi32(_mm_sub_epi32(mid, side), 1); _mm_storeu_si128((__m128i*)(pOutputSamples + i*8 + 0), _mm_unpacklo_epi32(left, right)); _mm_storeu_si128((__m128i*)(pOutputSamples + i*8 + 4), _mm_unpackhi_epi32(left, right)); } for (i = (frameCount4 << 2); i < frameCount; ++i) { ma_uint32 mid = pInputSamples0U32[i] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample; ma_uint32 side = pInputSamples1U32[i] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample; mid = (mid << 1) | (side & 0x01); pOutputSamples[i*2+0] = (ma_int32)(mid + side) >> 1; pOutputSamples[i*2+1] = (ma_int32)(mid - side) >> 1; } } else { shift -= 1; for (i = 0; i < frameCount4; ++i) { __m128i mid; __m128i side; __m128i left; __m128i right; mid = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples0 + i), pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample); side = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples1 + i), pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample); mid = _mm_or_si128(_mm_slli_epi32(mid, 1), _mm_and_si128(side, _mm_set1_epi32(0x01))); left = _mm_slli_epi32(_mm_add_epi32(mid, side), shift); right = _mm_slli_epi32(_mm_sub_epi32(mid, side), shift); _mm_storeu_si128((__m128i*)(pOutputSamples + i*8 + 0), _mm_unpacklo_epi32(left, right)); _mm_storeu_si128((__m128i*)(pOutputSamples + i*8 + 4), _mm_unpackhi_epi32(left, right)); } for (i = (frameCount4 << 2); i < frameCount; ++i) { ma_uint32 mid = pInputSamples0U32[i] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample; ma_uint32 side = pInputSamples1U32[i] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample; mid = (mid << 1) | (side & 0x01); pOutputSamples[i*2+0] = (ma_int32)((mid + side) << shift); pOutputSamples[i*2+1] = (ma_int32)((mid - side) << shift); } } } #endif #if defined(MA_DR_FLAC_SUPPORT_NEON) static MA_INLINE void ma_dr_flac_read_pcm_frames_s32__decode_mid_side__neon(ma_dr_flac* pFlac, ma_uint64 frameCount, ma_uint32 unusedBitsPerSample, const ma_int32* pInputSamples0, const ma_int32* pInputSamples1, ma_int32* pOutputSamples) { ma_uint64 i; ma_uint64 frameCount4 = frameCount >> 2; const ma_uint32* pInputSamples0U32 = (const ma_uint32*)pInputSamples0; const ma_uint32* pInputSamples1U32 = (const ma_uint32*)pInputSamples1; ma_int32 shift = unusedBitsPerSample; int32x4_t wbpsShift0_4; int32x4_t wbpsShift1_4; uint32x4_t one4; MA_DR_FLAC_ASSERT(pFlac->bitsPerSample <= 24); wbpsShift0_4 = vdupq_n_s32(pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample); wbpsShift1_4 = vdupq_n_s32(pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample); one4 = vdupq_n_u32(1); if (shift == 0) { for (i = 0; i < frameCount4; ++i) { uint32x4_t mid; uint32x4_t side; int32x4_t left; int32x4_t right; mid = vshlq_u32(vld1q_u32(pInputSamples0U32 + i*4), wbpsShift0_4); side = vshlq_u32(vld1q_u32(pInputSamples1U32 + i*4), wbpsShift1_4); mid = vorrq_u32(vshlq_n_u32(mid, 1), vandq_u32(side, one4)); left = vshrq_n_s32(vreinterpretq_s32_u32(vaddq_u32(mid, side)), 1); right = vshrq_n_s32(vreinterpretq_s32_u32(vsubq_u32(mid, side)), 1); ma_dr_flac__vst2q_s32(pOutputSamples + i*8, vzipq_s32(left, right)); } for (i = (frameCount4 << 2); i < frameCount; ++i) { ma_uint32 mid = pInputSamples0U32[i] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample; ma_uint32 side = pInputSamples1U32[i] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample; mid = (mid << 1) | (side & 0x01); pOutputSamples[i*2+0] = (ma_int32)(mid + side) >> 1; pOutputSamples[i*2+1] = (ma_int32)(mid - side) >> 1; } } else { int32x4_t shift4; shift -= 1; shift4 = vdupq_n_s32(shift); for (i = 0; i < frameCount4; ++i) { uint32x4_t mid; uint32x4_t side; int32x4_t left; int32x4_t right; mid = vshlq_u32(vld1q_u32(pInputSamples0U32 + i*4), wbpsShift0_4); side = vshlq_u32(vld1q_u32(pInputSamples1U32 + i*4), wbpsShift1_4); mid = vorrq_u32(vshlq_n_u32(mid, 1), vandq_u32(side, one4)); left = vreinterpretq_s32_u32(vshlq_u32(vaddq_u32(mid, side), shift4)); right = vreinterpretq_s32_u32(vshlq_u32(vsubq_u32(mid, side), shift4)); ma_dr_flac__vst2q_s32(pOutputSamples + i*8, vzipq_s32(left, right)); } for (i = (frameCount4 << 2); i < frameCount; ++i) { ma_uint32 mid = pInputSamples0U32[i] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample; ma_uint32 side = pInputSamples1U32[i] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample; mid = (mid << 1) | (side & 0x01); pOutputSamples[i*2+0] = (ma_int32)((mid + side) << shift); pOutputSamples[i*2+1] = (ma_int32)((mid - side) << shift); } } } #endif static MA_INLINE void ma_dr_flac_read_pcm_frames_s32__decode_mid_side(ma_dr_flac* pFlac, ma_uint64 frameCount, ma_uint32 unusedBitsPerSample, const ma_int32* pInputSamples0, const ma_int32* pInputSamples1, ma_int32* pOutputSamples) { #if defined(MA_DR_FLAC_SUPPORT_SSE2) if (ma_dr_flac__gIsSSE2Supported && pFlac->bitsPerSample <= 24) { ma_dr_flac_read_pcm_frames_s32__decode_mid_side__sse2(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples); } else #elif defined(MA_DR_FLAC_SUPPORT_NEON) if (ma_dr_flac__gIsNEONSupported && pFlac->bitsPerSample <= 24) { ma_dr_flac_read_pcm_frames_s32__decode_mid_side__neon(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples); } else #endif { #if 0 ma_dr_flac_read_pcm_frames_s32__decode_mid_side__reference(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples); #else ma_dr_flac_read_pcm_frames_s32__decode_mid_side__scalar(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples); #endif } } #if 0 static MA_INLINE void ma_dr_flac_read_pcm_frames_s32__decode_independent_stereo__reference(ma_dr_flac* pFlac, ma_uint64 frameCount, ma_uint32 unusedBitsPerSample, const ma_int32* pInputSamples0, const ma_int32* pInputSamples1, ma_int32* pOutputSamples) { for (ma_uint64 i = 0; i < frameCount; ++i) { pOutputSamples[i*2+0] = (ma_int32)((ma_uint32)pInputSamples0[i] << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample)); pOutputSamples[i*2+1] = (ma_int32)((ma_uint32)pInputSamples1[i] << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample)); } } #endif static MA_INLINE void ma_dr_flac_read_pcm_frames_s32__decode_independent_stereo__scalar(ma_dr_flac* pFlac, ma_uint64 frameCount, ma_uint32 unusedBitsPerSample, const ma_int32* pInputSamples0, const ma_int32* pInputSamples1, ma_int32* pOutputSamples) { ma_uint64 i; ma_uint64 frameCount4 = frameCount >> 2; const ma_uint32* pInputSamples0U32 = (const ma_uint32*)pInputSamples0; const ma_uint32* pInputSamples1U32 = (const ma_uint32*)pInputSamples1; ma_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample; ma_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample; for (i = 0; i < frameCount4; ++i) { ma_uint32 tempL0 = pInputSamples0U32[i*4+0] << shift0; ma_uint32 tempL1 = pInputSamples0U32[i*4+1] << shift0; ma_uint32 tempL2 = pInputSamples0U32[i*4+2] << shift0; ma_uint32 tempL3 = pInputSamples0U32[i*4+3] << shift0; ma_uint32 tempR0 = pInputSamples1U32[i*4+0] << shift1; ma_uint32 tempR1 = pInputSamples1U32[i*4+1] << shift1; ma_uint32 tempR2 = pInputSamples1U32[i*4+2] << shift1; ma_uint32 tempR3 = pInputSamples1U32[i*4+3] << shift1; pOutputSamples[i*8+0] = (ma_int32)tempL0; pOutputSamples[i*8+1] = (ma_int32)tempR0; pOutputSamples[i*8+2] = (ma_int32)tempL1; pOutputSamples[i*8+3] = (ma_int32)tempR1; pOutputSamples[i*8+4] = (ma_int32)tempL2; pOutputSamples[i*8+5] = (ma_int32)tempR2; pOutputSamples[i*8+6] = (ma_int32)tempL3; pOutputSamples[i*8+7] = (ma_int32)tempR3; } for (i = (frameCount4 << 2); i < frameCount; ++i) { pOutputSamples[i*2+0] = (ma_int32)(pInputSamples0U32[i] << shift0); pOutputSamples[i*2+1] = (ma_int32)(pInputSamples1U32[i] << shift1); } } #if defined(MA_DR_FLAC_SUPPORT_SSE2) static MA_INLINE void ma_dr_flac_read_pcm_frames_s32__decode_independent_stereo__sse2(ma_dr_flac* pFlac, ma_uint64 frameCount, ma_uint32 unusedBitsPerSample, const ma_int32* pInputSamples0, const ma_int32* pInputSamples1, ma_int32* pOutputSamples) { ma_uint64 i; ma_uint64 frameCount4 = frameCount >> 2; const ma_uint32* pInputSamples0U32 = (const ma_uint32*)pInputSamples0; const ma_uint32* pInputSamples1U32 = (const ma_uint32*)pInputSamples1; ma_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample; ma_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample; for (i = 0; i < frameCount4; ++i) { __m128i left = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples0 + i), shift0); __m128i right = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples1 + i), shift1); _mm_storeu_si128((__m128i*)(pOutputSamples + i*8 + 0), _mm_unpacklo_epi32(left, right)); _mm_storeu_si128((__m128i*)(pOutputSamples + i*8 + 4), _mm_unpackhi_epi32(left, right)); } for (i = (frameCount4 << 2); i < frameCount; ++i) { pOutputSamples[i*2+0] = (ma_int32)(pInputSamples0U32[i] << shift0); pOutputSamples[i*2+1] = (ma_int32)(pInputSamples1U32[i] << shift1); } } #endif #if defined(MA_DR_FLAC_SUPPORT_NEON) static MA_INLINE void ma_dr_flac_read_pcm_frames_s32__decode_independent_stereo__neon(ma_dr_flac* pFlac, ma_uint64 frameCount, ma_uint32 unusedBitsPerSample, const ma_int32* pInputSamples0, const ma_int32* pInputSamples1, ma_int32* pOutputSamples) { ma_uint64 i; ma_uint64 frameCount4 = frameCount >> 2; const ma_uint32* pInputSamples0U32 = (const ma_uint32*)pInputSamples0; const ma_uint32* pInputSamples1U32 = (const ma_uint32*)pInputSamples1; ma_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample; ma_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample; int32x4_t shift4_0 = vdupq_n_s32(shift0); int32x4_t shift4_1 = vdupq_n_s32(shift1); for (i = 0; i < frameCount4; ++i) { int32x4_t left; int32x4_t right; left = vreinterpretq_s32_u32(vshlq_u32(vld1q_u32(pInputSamples0U32 + i*4), shift4_0)); right = vreinterpretq_s32_u32(vshlq_u32(vld1q_u32(pInputSamples1U32 + i*4), shift4_1)); ma_dr_flac__vst2q_s32(pOutputSamples + i*8, vzipq_s32(left, right)); } for (i = (frameCount4 << 2); i < frameCount; ++i) { pOutputSamples[i*2+0] = (ma_int32)(pInputSamples0U32[i] << shift0); pOutputSamples[i*2+1] = (ma_int32)(pInputSamples1U32[i] << shift1); } } #endif static MA_INLINE void ma_dr_flac_read_pcm_frames_s32__decode_independent_stereo(ma_dr_flac* pFlac, ma_uint64 frameCount, ma_uint32 unusedBitsPerSample, const ma_int32* pInputSamples0, const ma_int32* pInputSamples1, ma_int32* pOutputSamples) { #if defined(MA_DR_FLAC_SUPPORT_SSE2) if (ma_dr_flac__gIsSSE2Supported && pFlac->bitsPerSample <= 24) { ma_dr_flac_read_pcm_frames_s32__decode_independent_stereo__sse2(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples); } else #elif defined(MA_DR_FLAC_SUPPORT_NEON) if (ma_dr_flac__gIsNEONSupported && pFlac->bitsPerSample <= 24) { ma_dr_flac_read_pcm_frames_s32__decode_independent_stereo__neon(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples); } else #endif { #if 0 ma_dr_flac_read_pcm_frames_s32__decode_independent_stereo__reference(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples); #else ma_dr_flac_read_pcm_frames_s32__decode_independent_stereo__scalar(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples); #endif } } MA_API ma_uint64 ma_dr_flac_read_pcm_frames_s32(ma_dr_flac* pFlac, ma_uint64 framesToRead, ma_int32* pBufferOut) { ma_uint64 framesRead; ma_uint32 unusedBitsPerSample; if (pFlac == NULL || framesToRead == 0) { return 0; } if (pBufferOut == NULL) { return ma_dr_flac__seek_forward_by_pcm_frames(pFlac, framesToRead); } MA_DR_FLAC_ASSERT(pFlac->bitsPerSample <= 32); unusedBitsPerSample = 32 - pFlac->bitsPerSample; framesRead = 0; while (framesToRead > 0) { if (pFlac->currentFLACFrame.pcmFramesRemaining == 0) { if (!ma_dr_flac__read_and_decode_next_flac_frame(pFlac)) { break; } } else { unsigned int channelCount = ma_dr_flac__get_channel_count_from_channel_assignment(pFlac->currentFLACFrame.header.channelAssignment); ma_uint64 iFirstPCMFrame = pFlac->currentFLACFrame.header.blockSizeInPCMFrames - pFlac->currentFLACFrame.pcmFramesRemaining; ma_uint64 frameCountThisIteration = framesToRead; if (frameCountThisIteration > pFlac->currentFLACFrame.pcmFramesRemaining) { frameCountThisIteration = pFlac->currentFLACFrame.pcmFramesRemaining; } if (channelCount == 2) { const ma_int32* pDecodedSamples0 = pFlac->currentFLACFrame.subframes[0].pSamplesS32 + iFirstPCMFrame; const ma_int32* pDecodedSamples1 = pFlac->currentFLACFrame.subframes[1].pSamplesS32 + iFirstPCMFrame; switch (pFlac->currentFLACFrame.header.channelAssignment) { case MA_DR_FLAC_CHANNEL_ASSIGNMENT_LEFT_SIDE: { ma_dr_flac_read_pcm_frames_s32__decode_left_side(pFlac, frameCountThisIteration, unusedBitsPerSample, pDecodedSamples0, pDecodedSamples1, pBufferOut); } break; case MA_DR_FLAC_CHANNEL_ASSIGNMENT_RIGHT_SIDE: { ma_dr_flac_read_pcm_frames_s32__decode_right_side(pFlac, frameCountThisIteration, unusedBitsPerSample, pDecodedSamples0, pDecodedSamples1, pBufferOut); } break; case MA_DR_FLAC_CHANNEL_ASSIGNMENT_MID_SIDE: { ma_dr_flac_read_pcm_frames_s32__decode_mid_side(pFlac, frameCountThisIteration, unusedBitsPerSample, pDecodedSamples0, pDecodedSamples1, pBufferOut); } break; case MA_DR_FLAC_CHANNEL_ASSIGNMENT_INDEPENDENT: default: { ma_dr_flac_read_pcm_frames_s32__decode_independent_stereo(pFlac, frameCountThisIteration, unusedBitsPerSample, pDecodedSamples0, pDecodedSamples1, pBufferOut); } break; } } else { ma_uint64 i; for (i = 0; i < frameCountThisIteration; ++i) { unsigned int j; for (j = 0; j < channelCount; ++j) { pBufferOut[(i*channelCount)+j] = (ma_int32)((ma_uint32)(pFlac->currentFLACFrame.subframes[j].pSamplesS32[iFirstPCMFrame + i]) << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[j].wastedBitsPerSample)); } } } framesRead += frameCountThisIteration; pBufferOut += frameCountThisIteration * channelCount; framesToRead -= frameCountThisIteration; pFlac->currentPCMFrame += frameCountThisIteration; pFlac->currentFLACFrame.pcmFramesRemaining -= (ma_uint32)frameCountThisIteration; } } return framesRead; } #if 0 static MA_INLINE void ma_dr_flac_read_pcm_frames_s16__decode_left_side__reference(ma_dr_flac* pFlac, ma_uint64 frameCount, ma_uint32 unusedBitsPerSample, const ma_int32* pInputSamples0, const ma_int32* pInputSamples1, ma_int16* pOutputSamples) { ma_uint64 i; for (i = 0; i < frameCount; ++i) { ma_uint32 left = (ma_uint32)pInputSamples0[i] << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample); ma_uint32 side = (ma_uint32)pInputSamples1[i] << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample); ma_uint32 right = left - side; left >>= 16; right >>= 16; pOutputSamples[i*2+0] = (ma_int16)left; pOutputSamples[i*2+1] = (ma_int16)right; } } #endif static MA_INLINE void ma_dr_flac_read_pcm_frames_s16__decode_left_side__scalar(ma_dr_flac* pFlac, ma_uint64 frameCount, ma_uint32 unusedBitsPerSample, const ma_int32* pInputSamples0, const ma_int32* pInputSamples1, ma_int16* pOutputSamples) { ma_uint64 i; ma_uint64 frameCount4 = frameCount >> 2; const ma_uint32* pInputSamples0U32 = (const ma_uint32*)pInputSamples0; const ma_uint32* pInputSamples1U32 = (const ma_uint32*)pInputSamples1; ma_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample; ma_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample; for (i = 0; i < frameCount4; ++i) { ma_uint32 left0 = pInputSamples0U32[i*4+0] << shift0; ma_uint32 left1 = pInputSamples0U32[i*4+1] << shift0; ma_uint32 left2 = pInputSamples0U32[i*4+2] << shift0; ma_uint32 left3 = pInputSamples0U32[i*4+3] << shift0; ma_uint32 side0 = pInputSamples1U32[i*4+0] << shift1; ma_uint32 side1 = pInputSamples1U32[i*4+1] << shift1; ma_uint32 side2 = pInputSamples1U32[i*4+2] << shift1; ma_uint32 side3 = pInputSamples1U32[i*4+3] << shift1; ma_uint32 right0 = left0 - side0; ma_uint32 right1 = left1 - side1; ma_uint32 right2 = left2 - side2; ma_uint32 right3 = left3 - side3; left0 >>= 16; left1 >>= 16; left2 >>= 16; left3 >>= 16; right0 >>= 16; right1 >>= 16; right2 >>= 16; right3 >>= 16; pOutputSamples[i*8+0] = (ma_int16)left0; pOutputSamples[i*8+1] = (ma_int16)right0; pOutputSamples[i*8+2] = (ma_int16)left1; pOutputSamples[i*8+3] = (ma_int16)right1; pOutputSamples[i*8+4] = (ma_int16)left2; pOutputSamples[i*8+5] = (ma_int16)right2; pOutputSamples[i*8+6] = (ma_int16)left3; pOutputSamples[i*8+7] = (ma_int16)right3; } for (i = (frameCount4 << 2); i < frameCount; ++i) { ma_uint32 left = pInputSamples0U32[i] << shift0; ma_uint32 side = pInputSamples1U32[i] << shift1; ma_uint32 right = left - side; left >>= 16; right >>= 16; pOutputSamples[i*2+0] = (ma_int16)left; pOutputSamples[i*2+1] = (ma_int16)right; } } #if defined(MA_DR_FLAC_SUPPORT_SSE2) static MA_INLINE void ma_dr_flac_read_pcm_frames_s16__decode_left_side__sse2(ma_dr_flac* pFlac, ma_uint64 frameCount, ma_uint32 unusedBitsPerSample, const ma_int32* pInputSamples0, const ma_int32* pInputSamples1, ma_int16* pOutputSamples) { ma_uint64 i; ma_uint64 frameCount4 = frameCount >> 2; const ma_uint32* pInputSamples0U32 = (const ma_uint32*)pInputSamples0; const ma_uint32* pInputSamples1U32 = (const ma_uint32*)pInputSamples1; ma_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample; ma_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample; MA_DR_FLAC_ASSERT(pFlac->bitsPerSample <= 24); for (i = 0; i < frameCount4; ++i) { __m128i left = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples0 + i), shift0); __m128i side = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples1 + i), shift1); __m128i right = _mm_sub_epi32(left, side); left = _mm_srai_epi32(left, 16); right = _mm_srai_epi32(right, 16); _mm_storeu_si128((__m128i*)(pOutputSamples + i*8), ma_dr_flac__mm_packs_interleaved_epi32(left, right)); } for (i = (frameCount4 << 2); i < frameCount; ++i) { ma_uint32 left = pInputSamples0U32[i] << shift0; ma_uint32 side = pInputSamples1U32[i] << shift1; ma_uint32 right = left - side; left >>= 16; right >>= 16; pOutputSamples[i*2+0] = (ma_int16)left; pOutputSamples[i*2+1] = (ma_int16)right; } } #endif #if defined(MA_DR_FLAC_SUPPORT_NEON) static MA_INLINE void ma_dr_flac_read_pcm_frames_s16__decode_left_side__neon(ma_dr_flac* pFlac, ma_uint64 frameCount, ma_uint32 unusedBitsPerSample, const ma_int32* pInputSamples0, const ma_int32* pInputSamples1, ma_int16* pOutputSamples) { ma_uint64 i; ma_uint64 frameCount4 = frameCount >> 2; const ma_uint32* pInputSamples0U32 = (const ma_uint32*)pInputSamples0; const ma_uint32* pInputSamples1U32 = (const ma_uint32*)pInputSamples1; ma_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample; ma_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample; int32x4_t shift0_4; int32x4_t shift1_4; MA_DR_FLAC_ASSERT(pFlac->bitsPerSample <= 24); shift0_4 = vdupq_n_s32(shift0); shift1_4 = vdupq_n_s32(shift1); for (i = 0; i < frameCount4; ++i) { uint32x4_t left; uint32x4_t side; uint32x4_t right; left = vshlq_u32(vld1q_u32(pInputSamples0U32 + i*4), shift0_4); side = vshlq_u32(vld1q_u32(pInputSamples1U32 + i*4), shift1_4); right = vsubq_u32(left, side); left = vshrq_n_u32(left, 16); right = vshrq_n_u32(right, 16); ma_dr_flac__vst2q_u16((ma_uint16*)pOutputSamples + i*8, vzip_u16(vmovn_u32(left), vmovn_u32(right))); } for (i = (frameCount4 << 2); i < frameCount; ++i) { ma_uint32 left = pInputSamples0U32[i] << shift0; ma_uint32 side = pInputSamples1U32[i] << shift1; ma_uint32 right = left - side; left >>= 16; right >>= 16; pOutputSamples[i*2+0] = (ma_int16)left; pOutputSamples[i*2+1] = (ma_int16)right; } } #endif static MA_INLINE void ma_dr_flac_read_pcm_frames_s16__decode_left_side(ma_dr_flac* pFlac, ma_uint64 frameCount, ma_uint32 unusedBitsPerSample, const ma_int32* pInputSamples0, const ma_int32* pInputSamples1, ma_int16* pOutputSamples) { #if defined(MA_DR_FLAC_SUPPORT_SSE2) if (ma_dr_flac__gIsSSE2Supported && pFlac->bitsPerSample <= 24) { ma_dr_flac_read_pcm_frames_s16__decode_left_side__sse2(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples); } else #elif defined(MA_DR_FLAC_SUPPORT_NEON) if (ma_dr_flac__gIsNEONSupported && pFlac->bitsPerSample <= 24) { ma_dr_flac_read_pcm_frames_s16__decode_left_side__neon(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples); } else #endif { #if 0 ma_dr_flac_read_pcm_frames_s16__decode_left_side__reference(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples); #else ma_dr_flac_read_pcm_frames_s16__decode_left_side__scalar(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples); #endif } } #if 0 static MA_INLINE void ma_dr_flac_read_pcm_frames_s16__decode_right_side__reference(ma_dr_flac* pFlac, ma_uint64 frameCount, ma_uint32 unusedBitsPerSample, const ma_int32* pInputSamples0, const ma_int32* pInputSamples1, ma_int16* pOutputSamples) { ma_uint64 i; for (i = 0; i < frameCount; ++i) { ma_uint32 side = (ma_uint32)pInputSamples0[i] << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample); ma_uint32 right = (ma_uint32)pInputSamples1[i] << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample); ma_uint32 left = right + side; left >>= 16; right >>= 16; pOutputSamples[i*2+0] = (ma_int16)left; pOutputSamples[i*2+1] = (ma_int16)right; } } #endif static MA_INLINE void ma_dr_flac_read_pcm_frames_s16__decode_right_side__scalar(ma_dr_flac* pFlac, ma_uint64 frameCount, ma_uint32 unusedBitsPerSample, const ma_int32* pInputSamples0, const ma_int32* pInputSamples1, ma_int16* pOutputSamples) { ma_uint64 i; ma_uint64 frameCount4 = frameCount >> 2; const ma_uint32* pInputSamples0U32 = (const ma_uint32*)pInputSamples0; const ma_uint32* pInputSamples1U32 = (const ma_uint32*)pInputSamples1; ma_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample; ma_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample; for (i = 0; i < frameCount4; ++i) { ma_uint32 side0 = pInputSamples0U32[i*4+0] << shift0; ma_uint32 side1 = pInputSamples0U32[i*4+1] << shift0; ma_uint32 side2 = pInputSamples0U32[i*4+2] << shift0; ma_uint32 side3 = pInputSamples0U32[i*4+3] << shift0; ma_uint32 right0 = pInputSamples1U32[i*4+0] << shift1; ma_uint32 right1 = pInputSamples1U32[i*4+1] << shift1; ma_uint32 right2 = pInputSamples1U32[i*4+2] << shift1; ma_uint32 right3 = pInputSamples1U32[i*4+3] << shift1; ma_uint32 left0 = right0 + side0; ma_uint32 left1 = right1 + side1; ma_uint32 left2 = right2 + side2; ma_uint32 left3 = right3 + side3; left0 >>= 16; left1 >>= 16; left2 >>= 16; left3 >>= 16; right0 >>= 16; right1 >>= 16; right2 >>= 16; right3 >>= 16; pOutputSamples[i*8+0] = (ma_int16)left0; pOutputSamples[i*8+1] = (ma_int16)right0; pOutputSamples[i*8+2] = (ma_int16)left1; pOutputSamples[i*8+3] = (ma_int16)right1; pOutputSamples[i*8+4] = (ma_int16)left2; pOutputSamples[i*8+5] = (ma_int16)right2; pOutputSamples[i*8+6] = (ma_int16)left3; pOutputSamples[i*8+7] = (ma_int16)right3; } for (i = (frameCount4 << 2); i < frameCount; ++i) { ma_uint32 side = pInputSamples0U32[i] << shift0; ma_uint32 right = pInputSamples1U32[i] << shift1; ma_uint32 left = right + side; left >>= 16; right >>= 16; pOutputSamples[i*2+0] = (ma_int16)left; pOutputSamples[i*2+1] = (ma_int16)right; } } #if defined(MA_DR_FLAC_SUPPORT_SSE2) static MA_INLINE void ma_dr_flac_read_pcm_frames_s16__decode_right_side__sse2(ma_dr_flac* pFlac, ma_uint64 frameCount, ma_uint32 unusedBitsPerSample, const ma_int32* pInputSamples0, const ma_int32* pInputSamples1, ma_int16* pOutputSamples) { ma_uint64 i; ma_uint64 frameCount4 = frameCount >> 2; const ma_uint32* pInputSamples0U32 = (const ma_uint32*)pInputSamples0; const ma_uint32* pInputSamples1U32 = (const ma_uint32*)pInputSamples1; ma_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample; ma_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample; MA_DR_FLAC_ASSERT(pFlac->bitsPerSample <= 24); for (i = 0; i < frameCount4; ++i) { __m128i side = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples0 + i), shift0); __m128i right = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples1 + i), shift1); __m128i left = _mm_add_epi32(right, side); left = _mm_srai_epi32(left, 16); right = _mm_srai_epi32(right, 16); _mm_storeu_si128((__m128i*)(pOutputSamples + i*8), ma_dr_flac__mm_packs_interleaved_epi32(left, right)); } for (i = (frameCount4 << 2); i < frameCount; ++i) { ma_uint32 side = pInputSamples0U32[i] << shift0; ma_uint32 right = pInputSamples1U32[i] << shift1; ma_uint32 left = right + side; left >>= 16; right >>= 16; pOutputSamples[i*2+0] = (ma_int16)left; pOutputSamples[i*2+1] = (ma_int16)right; } } #endif #if defined(MA_DR_FLAC_SUPPORT_NEON) static MA_INLINE void ma_dr_flac_read_pcm_frames_s16__decode_right_side__neon(ma_dr_flac* pFlac, ma_uint64 frameCount, ma_uint32 unusedBitsPerSample, const ma_int32* pInputSamples0, const ma_int32* pInputSamples1, ma_int16* pOutputSamples) { ma_uint64 i; ma_uint64 frameCount4 = frameCount >> 2; const ma_uint32* pInputSamples0U32 = (const ma_uint32*)pInputSamples0; const ma_uint32* pInputSamples1U32 = (const ma_uint32*)pInputSamples1; ma_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample; ma_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample; int32x4_t shift0_4; int32x4_t shift1_4; MA_DR_FLAC_ASSERT(pFlac->bitsPerSample <= 24); shift0_4 = vdupq_n_s32(shift0); shift1_4 = vdupq_n_s32(shift1); for (i = 0; i < frameCount4; ++i) { uint32x4_t side; uint32x4_t right; uint32x4_t left; side = vshlq_u32(vld1q_u32(pInputSamples0U32 + i*4), shift0_4); right = vshlq_u32(vld1q_u32(pInputSamples1U32 + i*4), shift1_4); left = vaddq_u32(right, side); left = vshrq_n_u32(left, 16); right = vshrq_n_u32(right, 16); ma_dr_flac__vst2q_u16((ma_uint16*)pOutputSamples + i*8, vzip_u16(vmovn_u32(left), vmovn_u32(right))); } for (i = (frameCount4 << 2); i < frameCount; ++i) { ma_uint32 side = pInputSamples0U32[i] << shift0; ma_uint32 right = pInputSamples1U32[i] << shift1; ma_uint32 left = right + side; left >>= 16; right >>= 16; pOutputSamples[i*2+0] = (ma_int16)left; pOutputSamples[i*2+1] = (ma_int16)right; } } #endif static MA_INLINE void ma_dr_flac_read_pcm_frames_s16__decode_right_side(ma_dr_flac* pFlac, ma_uint64 frameCount, ma_uint32 unusedBitsPerSample, const ma_int32* pInputSamples0, const ma_int32* pInputSamples1, ma_int16* pOutputSamples) { #if defined(MA_DR_FLAC_SUPPORT_SSE2) if (ma_dr_flac__gIsSSE2Supported && pFlac->bitsPerSample <= 24) { ma_dr_flac_read_pcm_frames_s16__decode_right_side__sse2(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples); } else #elif defined(MA_DR_FLAC_SUPPORT_NEON) if (ma_dr_flac__gIsNEONSupported && pFlac->bitsPerSample <= 24) { ma_dr_flac_read_pcm_frames_s16__decode_right_side__neon(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples); } else #endif { #if 0 ma_dr_flac_read_pcm_frames_s16__decode_right_side__reference(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples); #else ma_dr_flac_read_pcm_frames_s16__decode_right_side__scalar(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples); #endif } } #if 0 static MA_INLINE void ma_dr_flac_read_pcm_frames_s16__decode_mid_side__reference(ma_dr_flac* pFlac, ma_uint64 frameCount, ma_uint32 unusedBitsPerSample, const ma_int32* pInputSamples0, const ma_int32* pInputSamples1, ma_int16* pOutputSamples) { for (ma_uint64 i = 0; i < frameCount; ++i) { ma_uint32 mid = (ma_uint32)pInputSamples0[i] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample; ma_uint32 side = (ma_uint32)pInputSamples1[i] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample; mid = (mid << 1) | (side & 0x01); pOutputSamples[i*2+0] = (ma_int16)(((ma_uint32)((ma_int32)(mid + side) >> 1) << unusedBitsPerSample) >> 16); pOutputSamples[i*2+1] = (ma_int16)(((ma_uint32)((ma_int32)(mid - side) >> 1) << unusedBitsPerSample) >> 16); } } #endif static MA_INLINE void ma_dr_flac_read_pcm_frames_s16__decode_mid_side__scalar(ma_dr_flac* pFlac, ma_uint64 frameCount, ma_uint32 unusedBitsPerSample, const ma_int32* pInputSamples0, const ma_int32* pInputSamples1, ma_int16* pOutputSamples) { ma_uint64 i; ma_uint64 frameCount4 = frameCount >> 2; const ma_uint32* pInputSamples0U32 = (const ma_uint32*)pInputSamples0; const ma_uint32* pInputSamples1U32 = (const ma_uint32*)pInputSamples1; ma_uint32 shift = unusedBitsPerSample; if (shift > 0) { shift -= 1; for (i = 0; i < frameCount4; ++i) { ma_uint32 temp0L; ma_uint32 temp1L; ma_uint32 temp2L; ma_uint32 temp3L; ma_uint32 temp0R; ma_uint32 temp1R; ma_uint32 temp2R; ma_uint32 temp3R; ma_uint32 mid0 = pInputSamples0U32[i*4+0] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample; ma_uint32 mid1 = pInputSamples0U32[i*4+1] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample; ma_uint32 mid2 = pInputSamples0U32[i*4+2] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample; ma_uint32 mid3 = pInputSamples0U32[i*4+3] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample; ma_uint32 side0 = pInputSamples1U32[i*4+0] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample; ma_uint32 side1 = pInputSamples1U32[i*4+1] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample; ma_uint32 side2 = pInputSamples1U32[i*4+2] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample; ma_uint32 side3 = pInputSamples1U32[i*4+3] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample; mid0 = (mid0 << 1) | (side0 & 0x01); mid1 = (mid1 << 1) | (side1 & 0x01); mid2 = (mid2 << 1) | (side2 & 0x01); mid3 = (mid3 << 1) | (side3 & 0x01); temp0L = (mid0 + side0) << shift; temp1L = (mid1 + side1) << shift; temp2L = (mid2 + side2) << shift; temp3L = (mid3 + side3) << shift; temp0R = (mid0 - side0) << shift; temp1R = (mid1 - side1) << shift; temp2R = (mid2 - side2) << shift; temp3R = (mid3 - side3) << shift; temp0L >>= 16; temp1L >>= 16; temp2L >>= 16; temp3L >>= 16; temp0R >>= 16; temp1R >>= 16; temp2R >>= 16; temp3R >>= 16; pOutputSamples[i*8+0] = (ma_int16)temp0L; pOutputSamples[i*8+1] = (ma_int16)temp0R; pOutputSamples[i*8+2] = (ma_int16)temp1L; pOutputSamples[i*8+3] = (ma_int16)temp1R; pOutputSamples[i*8+4] = (ma_int16)temp2L; pOutputSamples[i*8+5] = (ma_int16)temp2R; pOutputSamples[i*8+6] = (ma_int16)temp3L; pOutputSamples[i*8+7] = (ma_int16)temp3R; } } else { for (i = 0; i < frameCount4; ++i) { ma_uint32 temp0L; ma_uint32 temp1L; ma_uint32 temp2L; ma_uint32 temp3L; ma_uint32 temp0R; ma_uint32 temp1R; ma_uint32 temp2R; ma_uint32 temp3R; ma_uint32 mid0 = pInputSamples0U32[i*4+0] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample; ma_uint32 mid1 = pInputSamples0U32[i*4+1] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample; ma_uint32 mid2 = pInputSamples0U32[i*4+2] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample; ma_uint32 mid3 = pInputSamples0U32[i*4+3] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample; ma_uint32 side0 = pInputSamples1U32[i*4+0] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample; ma_uint32 side1 = pInputSamples1U32[i*4+1] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample; ma_uint32 side2 = pInputSamples1U32[i*4+2] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample; ma_uint32 side3 = pInputSamples1U32[i*4+3] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample; mid0 = (mid0 << 1) | (side0 & 0x01); mid1 = (mid1 << 1) | (side1 & 0x01); mid2 = (mid2 << 1) | (side2 & 0x01); mid3 = (mid3 << 1) | (side3 & 0x01); temp0L = ((ma_int32)(mid0 + side0) >> 1); temp1L = ((ma_int32)(mid1 + side1) >> 1); temp2L = ((ma_int32)(mid2 + side2) >> 1); temp3L = ((ma_int32)(mid3 + side3) >> 1); temp0R = ((ma_int32)(mid0 - side0) >> 1); temp1R = ((ma_int32)(mid1 - side1) >> 1); temp2R = ((ma_int32)(mid2 - side2) >> 1); temp3R = ((ma_int32)(mid3 - side3) >> 1); temp0L >>= 16; temp1L >>= 16; temp2L >>= 16; temp3L >>= 16; temp0R >>= 16; temp1R >>= 16; temp2R >>= 16; temp3R >>= 16; pOutputSamples[i*8+0] = (ma_int16)temp0L; pOutputSamples[i*8+1] = (ma_int16)temp0R; pOutputSamples[i*8+2] = (ma_int16)temp1L; pOutputSamples[i*8+3] = (ma_int16)temp1R; pOutputSamples[i*8+4] = (ma_int16)temp2L; pOutputSamples[i*8+5] = (ma_int16)temp2R; pOutputSamples[i*8+6] = (ma_int16)temp3L; pOutputSamples[i*8+7] = (ma_int16)temp3R; } } for (i = (frameCount4 << 2); i < frameCount; ++i) { ma_uint32 mid = pInputSamples0U32[i] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample; ma_uint32 side = pInputSamples1U32[i] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample; mid = (mid << 1) | (side & 0x01); pOutputSamples[i*2+0] = (ma_int16)(((ma_uint32)((ma_int32)(mid + side) >> 1) << unusedBitsPerSample) >> 16); pOutputSamples[i*2+1] = (ma_int16)(((ma_uint32)((ma_int32)(mid - side) >> 1) << unusedBitsPerSample) >> 16); } } #if defined(MA_DR_FLAC_SUPPORT_SSE2) static MA_INLINE void ma_dr_flac_read_pcm_frames_s16__decode_mid_side__sse2(ma_dr_flac* pFlac, ma_uint64 frameCount, ma_uint32 unusedBitsPerSample, const ma_int32* pInputSamples0, const ma_int32* pInputSamples1, ma_int16* pOutputSamples) { ma_uint64 i; ma_uint64 frameCount4 = frameCount >> 2; const ma_uint32* pInputSamples0U32 = (const ma_uint32*)pInputSamples0; const ma_uint32* pInputSamples1U32 = (const ma_uint32*)pInputSamples1; ma_uint32 shift = unusedBitsPerSample; MA_DR_FLAC_ASSERT(pFlac->bitsPerSample <= 24); if (shift == 0) { for (i = 0; i < frameCount4; ++i) { __m128i mid; __m128i side; __m128i left; __m128i right; mid = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples0 + i), pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample); side = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples1 + i), pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample); mid = _mm_or_si128(_mm_slli_epi32(mid, 1), _mm_and_si128(side, _mm_set1_epi32(0x01))); left = _mm_srai_epi32(_mm_add_epi32(mid, side), 1); right = _mm_srai_epi32(_mm_sub_epi32(mid, side), 1); left = _mm_srai_epi32(left, 16); right = _mm_srai_epi32(right, 16); _mm_storeu_si128((__m128i*)(pOutputSamples + i*8), ma_dr_flac__mm_packs_interleaved_epi32(left, right)); } for (i = (frameCount4 << 2); i < frameCount; ++i) { ma_uint32 mid = pInputSamples0U32[i] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample; ma_uint32 side = pInputSamples1U32[i] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample; mid = (mid << 1) | (side & 0x01); pOutputSamples[i*2+0] = (ma_int16)(((ma_int32)(mid + side) >> 1) >> 16); pOutputSamples[i*2+1] = (ma_int16)(((ma_int32)(mid - side) >> 1) >> 16); } } else { shift -= 1; for (i = 0; i < frameCount4; ++i) { __m128i mid; __m128i side; __m128i left; __m128i right; mid = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples0 + i), pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample); side = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples1 + i), pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample); mid = _mm_or_si128(_mm_slli_epi32(mid, 1), _mm_and_si128(side, _mm_set1_epi32(0x01))); left = _mm_slli_epi32(_mm_add_epi32(mid, side), shift); right = _mm_slli_epi32(_mm_sub_epi32(mid, side), shift); left = _mm_srai_epi32(left, 16); right = _mm_srai_epi32(right, 16); _mm_storeu_si128((__m128i*)(pOutputSamples + i*8), ma_dr_flac__mm_packs_interleaved_epi32(left, right)); } for (i = (frameCount4 << 2); i < frameCount; ++i) { ma_uint32 mid = pInputSamples0U32[i] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample; ma_uint32 side = pInputSamples1U32[i] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample; mid = (mid << 1) | (side & 0x01); pOutputSamples[i*2+0] = (ma_int16)(((mid + side) << shift) >> 16); pOutputSamples[i*2+1] = (ma_int16)(((mid - side) << shift) >> 16); } } } #endif #if defined(MA_DR_FLAC_SUPPORT_NEON) static MA_INLINE void ma_dr_flac_read_pcm_frames_s16__decode_mid_side__neon(ma_dr_flac* pFlac, ma_uint64 frameCount, ma_uint32 unusedBitsPerSample, const ma_int32* pInputSamples0, const ma_int32* pInputSamples1, ma_int16* pOutputSamples) { ma_uint64 i; ma_uint64 frameCount4 = frameCount >> 2; const ma_uint32* pInputSamples0U32 = (const ma_uint32*)pInputSamples0; const ma_uint32* pInputSamples1U32 = (const ma_uint32*)pInputSamples1; ma_uint32 shift = unusedBitsPerSample; int32x4_t wbpsShift0_4; int32x4_t wbpsShift1_4; MA_DR_FLAC_ASSERT(pFlac->bitsPerSample <= 24); wbpsShift0_4 = vdupq_n_s32(pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample); wbpsShift1_4 = vdupq_n_s32(pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample); if (shift == 0) { for (i = 0; i < frameCount4; ++i) { uint32x4_t mid; uint32x4_t side; int32x4_t left; int32x4_t right; mid = vshlq_u32(vld1q_u32(pInputSamples0U32 + i*4), wbpsShift0_4); side = vshlq_u32(vld1q_u32(pInputSamples1U32 + i*4), wbpsShift1_4); mid = vorrq_u32(vshlq_n_u32(mid, 1), vandq_u32(side, vdupq_n_u32(1))); left = vshrq_n_s32(vreinterpretq_s32_u32(vaddq_u32(mid, side)), 1); right = vshrq_n_s32(vreinterpretq_s32_u32(vsubq_u32(mid, side)), 1); left = vshrq_n_s32(left, 16); right = vshrq_n_s32(right, 16); ma_dr_flac__vst2q_s16(pOutputSamples + i*8, vzip_s16(vmovn_s32(left), vmovn_s32(right))); } for (i = (frameCount4 << 2); i < frameCount; ++i) { ma_uint32 mid = pInputSamples0U32[i] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample; ma_uint32 side = pInputSamples1U32[i] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample; mid = (mid << 1) | (side & 0x01); pOutputSamples[i*2+0] = (ma_int16)(((ma_int32)(mid + side) >> 1) >> 16); pOutputSamples[i*2+1] = (ma_int16)(((ma_int32)(mid - side) >> 1) >> 16); } } else { int32x4_t shift4; shift -= 1; shift4 = vdupq_n_s32(shift); for (i = 0; i < frameCount4; ++i) { uint32x4_t mid; uint32x4_t side; int32x4_t left; int32x4_t right; mid = vshlq_u32(vld1q_u32(pInputSamples0U32 + i*4), wbpsShift0_4); side = vshlq_u32(vld1q_u32(pInputSamples1U32 + i*4), wbpsShift1_4); mid = vorrq_u32(vshlq_n_u32(mid, 1), vandq_u32(side, vdupq_n_u32(1))); left = vreinterpretq_s32_u32(vshlq_u32(vaddq_u32(mid, side), shift4)); right = vreinterpretq_s32_u32(vshlq_u32(vsubq_u32(mid, side), shift4)); left = vshrq_n_s32(left, 16); right = vshrq_n_s32(right, 16); ma_dr_flac__vst2q_s16(pOutputSamples + i*8, vzip_s16(vmovn_s32(left), vmovn_s32(right))); } for (i = (frameCount4 << 2); i < frameCount; ++i) { ma_uint32 mid = pInputSamples0U32[i] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample; ma_uint32 side = pInputSamples1U32[i] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample; mid = (mid << 1) | (side & 0x01); pOutputSamples[i*2+0] = (ma_int16)(((mid + side) << shift) >> 16); pOutputSamples[i*2+1] = (ma_int16)(((mid - side) << shift) >> 16); } } } #endif static MA_INLINE void ma_dr_flac_read_pcm_frames_s16__decode_mid_side(ma_dr_flac* pFlac, ma_uint64 frameCount, ma_uint32 unusedBitsPerSample, const ma_int32* pInputSamples0, const ma_int32* pInputSamples1, ma_int16* pOutputSamples) { #if defined(MA_DR_FLAC_SUPPORT_SSE2) if (ma_dr_flac__gIsSSE2Supported && pFlac->bitsPerSample <= 24) { ma_dr_flac_read_pcm_frames_s16__decode_mid_side__sse2(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples); } else #elif defined(MA_DR_FLAC_SUPPORT_NEON) if (ma_dr_flac__gIsNEONSupported && pFlac->bitsPerSample <= 24) { ma_dr_flac_read_pcm_frames_s16__decode_mid_side__neon(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples); } else #endif { #if 0 ma_dr_flac_read_pcm_frames_s16__decode_mid_side__reference(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples); #else ma_dr_flac_read_pcm_frames_s16__decode_mid_side__scalar(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples); #endif } } #if 0 static MA_INLINE void ma_dr_flac_read_pcm_frames_s16__decode_independent_stereo__reference(ma_dr_flac* pFlac, ma_uint64 frameCount, ma_uint32 unusedBitsPerSample, const ma_int32* pInputSamples0, const ma_int32* pInputSamples1, ma_int16* pOutputSamples) { for (ma_uint64 i = 0; i < frameCount; ++i) { pOutputSamples[i*2+0] = (ma_int16)((ma_int32)((ma_uint32)pInputSamples0[i] << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample)) >> 16); pOutputSamples[i*2+1] = (ma_int16)((ma_int32)((ma_uint32)pInputSamples1[i] << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample)) >> 16); } } #endif static MA_INLINE void ma_dr_flac_read_pcm_frames_s16__decode_independent_stereo__scalar(ma_dr_flac* pFlac, ma_uint64 frameCount, ma_uint32 unusedBitsPerSample, const ma_int32* pInputSamples0, const ma_int32* pInputSamples1, ma_int16* pOutputSamples) { ma_uint64 i; ma_uint64 frameCount4 = frameCount >> 2; const ma_uint32* pInputSamples0U32 = (const ma_uint32*)pInputSamples0; const ma_uint32* pInputSamples1U32 = (const ma_uint32*)pInputSamples1; ma_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample; ma_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample; for (i = 0; i < frameCount4; ++i) { ma_uint32 tempL0 = pInputSamples0U32[i*4+0] << shift0; ma_uint32 tempL1 = pInputSamples0U32[i*4+1] << shift0; ma_uint32 tempL2 = pInputSamples0U32[i*4+2] << shift0; ma_uint32 tempL3 = pInputSamples0U32[i*4+3] << shift0; ma_uint32 tempR0 = pInputSamples1U32[i*4+0] << shift1; ma_uint32 tempR1 = pInputSamples1U32[i*4+1] << shift1; ma_uint32 tempR2 = pInputSamples1U32[i*4+2] << shift1; ma_uint32 tempR3 = pInputSamples1U32[i*4+3] << shift1; tempL0 >>= 16; tempL1 >>= 16; tempL2 >>= 16; tempL3 >>= 16; tempR0 >>= 16; tempR1 >>= 16; tempR2 >>= 16; tempR3 >>= 16; pOutputSamples[i*8+0] = (ma_int16)tempL0; pOutputSamples[i*8+1] = (ma_int16)tempR0; pOutputSamples[i*8+2] = (ma_int16)tempL1; pOutputSamples[i*8+3] = (ma_int16)tempR1; pOutputSamples[i*8+4] = (ma_int16)tempL2; pOutputSamples[i*8+5] = (ma_int16)tempR2; pOutputSamples[i*8+6] = (ma_int16)tempL3; pOutputSamples[i*8+7] = (ma_int16)tempR3; } for (i = (frameCount4 << 2); i < frameCount; ++i) { pOutputSamples[i*2+0] = (ma_int16)((pInputSamples0U32[i] << shift0) >> 16); pOutputSamples[i*2+1] = (ma_int16)((pInputSamples1U32[i] << shift1) >> 16); } } #if defined(MA_DR_FLAC_SUPPORT_SSE2) static MA_INLINE void ma_dr_flac_read_pcm_frames_s16__decode_independent_stereo__sse2(ma_dr_flac* pFlac, ma_uint64 frameCount, ma_uint32 unusedBitsPerSample, const ma_int32* pInputSamples0, const ma_int32* pInputSamples1, ma_int16* pOutputSamples) { ma_uint64 i; ma_uint64 frameCount4 = frameCount >> 2; const ma_uint32* pInputSamples0U32 = (const ma_uint32*)pInputSamples0; const ma_uint32* pInputSamples1U32 = (const ma_uint32*)pInputSamples1; ma_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample; ma_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample; for (i = 0; i < frameCount4; ++i) { __m128i left = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples0 + i), shift0); __m128i right = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples1 + i), shift1); left = _mm_srai_epi32(left, 16); right = _mm_srai_epi32(right, 16); _mm_storeu_si128((__m128i*)(pOutputSamples + i*8), ma_dr_flac__mm_packs_interleaved_epi32(left, right)); } for (i = (frameCount4 << 2); i < frameCount; ++i) { pOutputSamples[i*2+0] = (ma_int16)((pInputSamples0U32[i] << shift0) >> 16); pOutputSamples[i*2+1] = (ma_int16)((pInputSamples1U32[i] << shift1) >> 16); } } #endif #if defined(MA_DR_FLAC_SUPPORT_NEON) static MA_INLINE void ma_dr_flac_read_pcm_frames_s16__decode_independent_stereo__neon(ma_dr_flac* pFlac, ma_uint64 frameCount, ma_uint32 unusedBitsPerSample, const ma_int32* pInputSamples0, const ma_int32* pInputSamples1, ma_int16* pOutputSamples) { ma_uint64 i; ma_uint64 frameCount4 = frameCount >> 2; const ma_uint32* pInputSamples0U32 = (const ma_uint32*)pInputSamples0; const ma_uint32* pInputSamples1U32 = (const ma_uint32*)pInputSamples1; ma_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample; ma_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample; int32x4_t shift0_4 = vdupq_n_s32(shift0); int32x4_t shift1_4 = vdupq_n_s32(shift1); for (i = 0; i < frameCount4; ++i) { int32x4_t left; int32x4_t right; left = vreinterpretq_s32_u32(vshlq_u32(vld1q_u32(pInputSamples0U32 + i*4), shift0_4)); right = vreinterpretq_s32_u32(vshlq_u32(vld1q_u32(pInputSamples1U32 + i*4), shift1_4)); left = vshrq_n_s32(left, 16); right = vshrq_n_s32(right, 16); ma_dr_flac__vst2q_s16(pOutputSamples + i*8, vzip_s16(vmovn_s32(left), vmovn_s32(right))); } for (i = (frameCount4 << 2); i < frameCount; ++i) { pOutputSamples[i*2+0] = (ma_int16)((pInputSamples0U32[i] << shift0) >> 16); pOutputSamples[i*2+1] = (ma_int16)((pInputSamples1U32[i] << shift1) >> 16); } } #endif static MA_INLINE void ma_dr_flac_read_pcm_frames_s16__decode_independent_stereo(ma_dr_flac* pFlac, ma_uint64 frameCount, ma_uint32 unusedBitsPerSample, const ma_int32* pInputSamples0, const ma_int32* pInputSamples1, ma_int16* pOutputSamples) { #if defined(MA_DR_FLAC_SUPPORT_SSE2) if (ma_dr_flac__gIsSSE2Supported && pFlac->bitsPerSample <= 24) { ma_dr_flac_read_pcm_frames_s16__decode_independent_stereo__sse2(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples); } else #elif defined(MA_DR_FLAC_SUPPORT_NEON) if (ma_dr_flac__gIsNEONSupported && pFlac->bitsPerSample <= 24) { ma_dr_flac_read_pcm_frames_s16__decode_independent_stereo__neon(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples); } else #endif { #if 0 ma_dr_flac_read_pcm_frames_s16__decode_independent_stereo__reference(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples); #else ma_dr_flac_read_pcm_frames_s16__decode_independent_stereo__scalar(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples); #endif } } MA_API ma_uint64 ma_dr_flac_read_pcm_frames_s16(ma_dr_flac* pFlac, ma_uint64 framesToRead, ma_int16* pBufferOut) { ma_uint64 framesRead; ma_uint32 unusedBitsPerSample; if (pFlac == NULL || framesToRead == 0) { return 0; } if (pBufferOut == NULL) { return ma_dr_flac__seek_forward_by_pcm_frames(pFlac, framesToRead); } MA_DR_FLAC_ASSERT(pFlac->bitsPerSample <= 32); unusedBitsPerSample = 32 - pFlac->bitsPerSample; framesRead = 0; while (framesToRead > 0) { if (pFlac->currentFLACFrame.pcmFramesRemaining == 0) { if (!ma_dr_flac__read_and_decode_next_flac_frame(pFlac)) { break; } } else { unsigned int channelCount = ma_dr_flac__get_channel_count_from_channel_assignment(pFlac->currentFLACFrame.header.channelAssignment); ma_uint64 iFirstPCMFrame = pFlac->currentFLACFrame.header.blockSizeInPCMFrames - pFlac->currentFLACFrame.pcmFramesRemaining; ma_uint64 frameCountThisIteration = framesToRead; if (frameCountThisIteration > pFlac->currentFLACFrame.pcmFramesRemaining) { frameCountThisIteration = pFlac->currentFLACFrame.pcmFramesRemaining; } if (channelCount == 2) { const ma_int32* pDecodedSamples0 = pFlac->currentFLACFrame.subframes[0].pSamplesS32 + iFirstPCMFrame; const ma_int32* pDecodedSamples1 = pFlac->currentFLACFrame.subframes[1].pSamplesS32 + iFirstPCMFrame; switch (pFlac->currentFLACFrame.header.channelAssignment) { case MA_DR_FLAC_CHANNEL_ASSIGNMENT_LEFT_SIDE: { ma_dr_flac_read_pcm_frames_s16__decode_left_side(pFlac, frameCountThisIteration, unusedBitsPerSample, pDecodedSamples0, pDecodedSamples1, pBufferOut); } break; case MA_DR_FLAC_CHANNEL_ASSIGNMENT_RIGHT_SIDE: { ma_dr_flac_read_pcm_frames_s16__decode_right_side(pFlac, frameCountThisIteration, unusedBitsPerSample, pDecodedSamples0, pDecodedSamples1, pBufferOut); } break; case MA_DR_FLAC_CHANNEL_ASSIGNMENT_MID_SIDE: { ma_dr_flac_read_pcm_frames_s16__decode_mid_side(pFlac, frameCountThisIteration, unusedBitsPerSample, pDecodedSamples0, pDecodedSamples1, pBufferOut); } break; case MA_DR_FLAC_CHANNEL_ASSIGNMENT_INDEPENDENT: default: { ma_dr_flac_read_pcm_frames_s16__decode_independent_stereo(pFlac, frameCountThisIteration, unusedBitsPerSample, pDecodedSamples0, pDecodedSamples1, pBufferOut); } break; } } else { ma_uint64 i; for (i = 0; i < frameCountThisIteration; ++i) { unsigned int j; for (j = 0; j < channelCount; ++j) { ma_int32 sampleS32 = (ma_int32)((ma_uint32)(pFlac->currentFLACFrame.subframes[j].pSamplesS32[iFirstPCMFrame + i]) << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[j].wastedBitsPerSample)); pBufferOut[(i*channelCount)+j] = (ma_int16)(sampleS32 >> 16); } } } framesRead += frameCountThisIteration; pBufferOut += frameCountThisIteration * channelCount; framesToRead -= frameCountThisIteration; pFlac->currentPCMFrame += frameCountThisIteration; pFlac->currentFLACFrame.pcmFramesRemaining -= (ma_uint32)frameCountThisIteration; } } return framesRead; } #if 0 static MA_INLINE void ma_dr_flac_read_pcm_frames_f32__decode_left_side__reference(ma_dr_flac* pFlac, ma_uint64 frameCount, ma_uint32 unusedBitsPerSample, const ma_int32* pInputSamples0, const ma_int32* pInputSamples1, float* pOutputSamples) { ma_uint64 i; for (i = 0; i < frameCount; ++i) { ma_uint32 left = (ma_uint32)pInputSamples0[i] << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample); ma_uint32 side = (ma_uint32)pInputSamples1[i] << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample); ma_uint32 right = left - side; pOutputSamples[i*2+0] = (float)((ma_int32)left / 2147483648.0); pOutputSamples[i*2+1] = (float)((ma_int32)right / 2147483648.0); } } #endif static MA_INLINE void ma_dr_flac_read_pcm_frames_f32__decode_left_side__scalar(ma_dr_flac* pFlac, ma_uint64 frameCount, ma_uint32 unusedBitsPerSample, const ma_int32* pInputSamples0, const ma_int32* pInputSamples1, float* pOutputSamples) { ma_uint64 i; ma_uint64 frameCount4 = frameCount >> 2; const ma_uint32* pInputSamples0U32 = (const ma_uint32*)pInputSamples0; const ma_uint32* pInputSamples1U32 = (const ma_uint32*)pInputSamples1; ma_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample; ma_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample; float factor = 1 / 2147483648.0; for (i = 0; i < frameCount4; ++i) { ma_uint32 left0 = pInputSamples0U32[i*4+0] << shift0; ma_uint32 left1 = pInputSamples0U32[i*4+1] << shift0; ma_uint32 left2 = pInputSamples0U32[i*4+2] << shift0; ma_uint32 left3 = pInputSamples0U32[i*4+3] << shift0; ma_uint32 side0 = pInputSamples1U32[i*4+0] << shift1; ma_uint32 side1 = pInputSamples1U32[i*4+1] << shift1; ma_uint32 side2 = pInputSamples1U32[i*4+2] << shift1; ma_uint32 side3 = pInputSamples1U32[i*4+3] << shift1; ma_uint32 right0 = left0 - side0; ma_uint32 right1 = left1 - side1; ma_uint32 right2 = left2 - side2; ma_uint32 right3 = left3 - side3; pOutputSamples[i*8+0] = (ma_int32)left0 * factor; pOutputSamples[i*8+1] = (ma_int32)right0 * factor; pOutputSamples[i*8+2] = (ma_int32)left1 * factor; pOutputSamples[i*8+3] = (ma_int32)right1 * factor; pOutputSamples[i*8+4] = (ma_int32)left2 * factor; pOutputSamples[i*8+5] = (ma_int32)right2 * factor; pOutputSamples[i*8+6] = (ma_int32)left3 * factor; pOutputSamples[i*8+7] = (ma_int32)right3 * factor; } for (i = (frameCount4 << 2); i < frameCount; ++i) { ma_uint32 left = pInputSamples0U32[i] << shift0; ma_uint32 side = pInputSamples1U32[i] << shift1; ma_uint32 right = left - side; pOutputSamples[i*2+0] = (ma_int32)left * factor; pOutputSamples[i*2+1] = (ma_int32)right * factor; } } #if defined(MA_DR_FLAC_SUPPORT_SSE2) static MA_INLINE void ma_dr_flac_read_pcm_frames_f32__decode_left_side__sse2(ma_dr_flac* pFlac, ma_uint64 frameCount, ma_uint32 unusedBitsPerSample, const ma_int32* pInputSamples0, const ma_int32* pInputSamples1, float* pOutputSamples) { ma_uint64 i; ma_uint64 frameCount4 = frameCount >> 2; const ma_uint32* pInputSamples0U32 = (const ma_uint32*)pInputSamples0; const ma_uint32* pInputSamples1U32 = (const ma_uint32*)pInputSamples1; ma_uint32 shift0 = (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample) - 8; ma_uint32 shift1 = (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample) - 8; __m128 factor; MA_DR_FLAC_ASSERT(pFlac->bitsPerSample <= 24); factor = _mm_set1_ps(1.0f / 8388608.0f); for (i = 0; i < frameCount4; ++i) { __m128i left = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples0 + i), shift0); __m128i side = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples1 + i), shift1); __m128i right = _mm_sub_epi32(left, side); __m128 leftf = _mm_mul_ps(_mm_cvtepi32_ps(left), factor); __m128 rightf = _mm_mul_ps(_mm_cvtepi32_ps(right), factor); _mm_storeu_ps(pOutputSamples + i*8 + 0, _mm_unpacklo_ps(leftf, rightf)); _mm_storeu_ps(pOutputSamples + i*8 + 4, _mm_unpackhi_ps(leftf, rightf)); } for (i = (frameCount4 << 2); i < frameCount; ++i) { ma_uint32 left = pInputSamples0U32[i] << shift0; ma_uint32 side = pInputSamples1U32[i] << shift1; ma_uint32 right = left - side; pOutputSamples[i*2+0] = (ma_int32)left / 8388608.0f; pOutputSamples[i*2+1] = (ma_int32)right / 8388608.0f; } } #endif #if defined(MA_DR_FLAC_SUPPORT_NEON) static MA_INLINE void ma_dr_flac_read_pcm_frames_f32__decode_left_side__neon(ma_dr_flac* pFlac, ma_uint64 frameCount, ma_uint32 unusedBitsPerSample, const ma_int32* pInputSamples0, const ma_int32* pInputSamples1, float* pOutputSamples) { ma_uint64 i; ma_uint64 frameCount4 = frameCount >> 2; const ma_uint32* pInputSamples0U32 = (const ma_uint32*)pInputSamples0; const ma_uint32* pInputSamples1U32 = (const ma_uint32*)pInputSamples1; ma_uint32 shift0 = (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample) - 8; ma_uint32 shift1 = (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample) - 8; float32x4_t factor4; int32x4_t shift0_4; int32x4_t shift1_4; MA_DR_FLAC_ASSERT(pFlac->bitsPerSample <= 24); factor4 = vdupq_n_f32(1.0f / 8388608.0f); shift0_4 = vdupq_n_s32(shift0); shift1_4 = vdupq_n_s32(shift1); for (i = 0; i < frameCount4; ++i) { uint32x4_t left; uint32x4_t side; uint32x4_t right; float32x4_t leftf; float32x4_t rightf; left = vshlq_u32(vld1q_u32(pInputSamples0U32 + i*4), shift0_4); side = vshlq_u32(vld1q_u32(pInputSamples1U32 + i*4), shift1_4); right = vsubq_u32(left, side); leftf = vmulq_f32(vcvtq_f32_s32(vreinterpretq_s32_u32(left)), factor4); rightf = vmulq_f32(vcvtq_f32_s32(vreinterpretq_s32_u32(right)), factor4); ma_dr_flac__vst2q_f32(pOutputSamples + i*8, vzipq_f32(leftf, rightf)); } for (i = (frameCount4 << 2); i < frameCount; ++i) { ma_uint32 left = pInputSamples0U32[i] << shift0; ma_uint32 side = pInputSamples1U32[i] << shift1; ma_uint32 right = left - side; pOutputSamples[i*2+0] = (ma_int32)left / 8388608.0f; pOutputSamples[i*2+1] = (ma_int32)right / 8388608.0f; } } #endif static MA_INLINE void ma_dr_flac_read_pcm_frames_f32__decode_left_side(ma_dr_flac* pFlac, ma_uint64 frameCount, ma_uint32 unusedBitsPerSample, const ma_int32* pInputSamples0, const ma_int32* pInputSamples1, float* pOutputSamples) { #if defined(MA_DR_FLAC_SUPPORT_SSE2) if (ma_dr_flac__gIsSSE2Supported && pFlac->bitsPerSample <= 24) { ma_dr_flac_read_pcm_frames_f32__decode_left_side__sse2(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples); } else #elif defined(MA_DR_FLAC_SUPPORT_NEON) if (ma_dr_flac__gIsNEONSupported && pFlac->bitsPerSample <= 24) { ma_dr_flac_read_pcm_frames_f32__decode_left_side__neon(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples); } else #endif { #if 0 ma_dr_flac_read_pcm_frames_f32__decode_left_side__reference(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples); #else ma_dr_flac_read_pcm_frames_f32__decode_left_side__scalar(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples); #endif } } #if 0 static MA_INLINE void ma_dr_flac_read_pcm_frames_f32__decode_right_side__reference(ma_dr_flac* pFlac, ma_uint64 frameCount, ma_uint32 unusedBitsPerSample, const ma_int32* pInputSamples0, const ma_int32* pInputSamples1, float* pOutputSamples) { ma_uint64 i; for (i = 0; i < frameCount; ++i) { ma_uint32 side = (ma_uint32)pInputSamples0[i] << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample); ma_uint32 right = (ma_uint32)pInputSamples1[i] << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample); ma_uint32 left = right + side; pOutputSamples[i*2+0] = (float)((ma_int32)left / 2147483648.0); pOutputSamples[i*2+1] = (float)((ma_int32)right / 2147483648.0); } } #endif static MA_INLINE void ma_dr_flac_read_pcm_frames_f32__decode_right_side__scalar(ma_dr_flac* pFlac, ma_uint64 frameCount, ma_uint32 unusedBitsPerSample, const ma_int32* pInputSamples0, const ma_int32* pInputSamples1, float* pOutputSamples) { ma_uint64 i; ma_uint64 frameCount4 = frameCount >> 2; const ma_uint32* pInputSamples0U32 = (const ma_uint32*)pInputSamples0; const ma_uint32* pInputSamples1U32 = (const ma_uint32*)pInputSamples1; ma_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample; ma_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample; float factor = 1 / 2147483648.0; for (i = 0; i < frameCount4; ++i) { ma_uint32 side0 = pInputSamples0U32[i*4+0] << shift0; ma_uint32 side1 = pInputSamples0U32[i*4+1] << shift0; ma_uint32 side2 = pInputSamples0U32[i*4+2] << shift0; ma_uint32 side3 = pInputSamples0U32[i*4+3] << shift0; ma_uint32 right0 = pInputSamples1U32[i*4+0] << shift1; ma_uint32 right1 = pInputSamples1U32[i*4+1] << shift1; ma_uint32 right2 = pInputSamples1U32[i*4+2] << shift1; ma_uint32 right3 = pInputSamples1U32[i*4+3] << shift1; ma_uint32 left0 = right0 + side0; ma_uint32 left1 = right1 + side1; ma_uint32 left2 = right2 + side2; ma_uint32 left3 = right3 + side3; pOutputSamples[i*8+0] = (ma_int32)left0 * factor; pOutputSamples[i*8+1] = (ma_int32)right0 * factor; pOutputSamples[i*8+2] = (ma_int32)left1 * factor; pOutputSamples[i*8+3] = (ma_int32)right1 * factor; pOutputSamples[i*8+4] = (ma_int32)left2 * factor; pOutputSamples[i*8+5] = (ma_int32)right2 * factor; pOutputSamples[i*8+6] = (ma_int32)left3 * factor; pOutputSamples[i*8+7] = (ma_int32)right3 * factor; } for (i = (frameCount4 << 2); i < frameCount; ++i) { ma_uint32 side = pInputSamples0U32[i] << shift0; ma_uint32 right = pInputSamples1U32[i] << shift1; ma_uint32 left = right + side; pOutputSamples[i*2+0] = (ma_int32)left * factor; pOutputSamples[i*2+1] = (ma_int32)right * factor; } } #if defined(MA_DR_FLAC_SUPPORT_SSE2) static MA_INLINE void ma_dr_flac_read_pcm_frames_f32__decode_right_side__sse2(ma_dr_flac* pFlac, ma_uint64 frameCount, ma_uint32 unusedBitsPerSample, const ma_int32* pInputSamples0, const ma_int32* pInputSamples1, float* pOutputSamples) { ma_uint64 i; ma_uint64 frameCount4 = frameCount >> 2; const ma_uint32* pInputSamples0U32 = (const ma_uint32*)pInputSamples0; const ma_uint32* pInputSamples1U32 = (const ma_uint32*)pInputSamples1; ma_uint32 shift0 = (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample) - 8; ma_uint32 shift1 = (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample) - 8; __m128 factor; MA_DR_FLAC_ASSERT(pFlac->bitsPerSample <= 24); factor = _mm_set1_ps(1.0f / 8388608.0f); for (i = 0; i < frameCount4; ++i) { __m128i side = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples0 + i), shift0); __m128i right = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples1 + i), shift1); __m128i left = _mm_add_epi32(right, side); __m128 leftf = _mm_mul_ps(_mm_cvtepi32_ps(left), factor); __m128 rightf = _mm_mul_ps(_mm_cvtepi32_ps(right), factor); _mm_storeu_ps(pOutputSamples + i*8 + 0, _mm_unpacklo_ps(leftf, rightf)); _mm_storeu_ps(pOutputSamples + i*8 + 4, _mm_unpackhi_ps(leftf, rightf)); } for (i = (frameCount4 << 2); i < frameCount; ++i) { ma_uint32 side = pInputSamples0U32[i] << shift0; ma_uint32 right = pInputSamples1U32[i] << shift1; ma_uint32 left = right + side; pOutputSamples[i*2+0] = (ma_int32)left / 8388608.0f; pOutputSamples[i*2+1] = (ma_int32)right / 8388608.0f; } } #endif #if defined(MA_DR_FLAC_SUPPORT_NEON) static MA_INLINE void ma_dr_flac_read_pcm_frames_f32__decode_right_side__neon(ma_dr_flac* pFlac, ma_uint64 frameCount, ma_uint32 unusedBitsPerSample, const ma_int32* pInputSamples0, const ma_int32* pInputSamples1, float* pOutputSamples) { ma_uint64 i; ma_uint64 frameCount4 = frameCount >> 2; const ma_uint32* pInputSamples0U32 = (const ma_uint32*)pInputSamples0; const ma_uint32* pInputSamples1U32 = (const ma_uint32*)pInputSamples1; ma_uint32 shift0 = (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample) - 8; ma_uint32 shift1 = (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample) - 8; float32x4_t factor4; int32x4_t shift0_4; int32x4_t shift1_4; MA_DR_FLAC_ASSERT(pFlac->bitsPerSample <= 24); factor4 = vdupq_n_f32(1.0f / 8388608.0f); shift0_4 = vdupq_n_s32(shift0); shift1_4 = vdupq_n_s32(shift1); for (i = 0; i < frameCount4; ++i) { uint32x4_t side; uint32x4_t right; uint32x4_t left; float32x4_t leftf; float32x4_t rightf; side = vshlq_u32(vld1q_u32(pInputSamples0U32 + i*4), shift0_4); right = vshlq_u32(vld1q_u32(pInputSamples1U32 + i*4), shift1_4); left = vaddq_u32(right, side); leftf = vmulq_f32(vcvtq_f32_s32(vreinterpretq_s32_u32(left)), factor4); rightf = vmulq_f32(vcvtq_f32_s32(vreinterpretq_s32_u32(right)), factor4); ma_dr_flac__vst2q_f32(pOutputSamples + i*8, vzipq_f32(leftf, rightf)); } for (i = (frameCount4 << 2); i < frameCount; ++i) { ma_uint32 side = pInputSamples0U32[i] << shift0; ma_uint32 right = pInputSamples1U32[i] << shift1; ma_uint32 left = right + side; pOutputSamples[i*2+0] = (ma_int32)left / 8388608.0f; pOutputSamples[i*2+1] = (ma_int32)right / 8388608.0f; } } #endif static MA_INLINE void ma_dr_flac_read_pcm_frames_f32__decode_right_side(ma_dr_flac* pFlac, ma_uint64 frameCount, ma_uint32 unusedBitsPerSample, const ma_int32* pInputSamples0, const ma_int32* pInputSamples1, float* pOutputSamples) { #if defined(MA_DR_FLAC_SUPPORT_SSE2) if (ma_dr_flac__gIsSSE2Supported && pFlac->bitsPerSample <= 24) { ma_dr_flac_read_pcm_frames_f32__decode_right_side__sse2(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples); } else #elif defined(MA_DR_FLAC_SUPPORT_NEON) if (ma_dr_flac__gIsNEONSupported && pFlac->bitsPerSample <= 24) { ma_dr_flac_read_pcm_frames_f32__decode_right_side__neon(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples); } else #endif { #if 0 ma_dr_flac_read_pcm_frames_f32__decode_right_side__reference(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples); #else ma_dr_flac_read_pcm_frames_f32__decode_right_side__scalar(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples); #endif } } #if 0 static MA_INLINE void ma_dr_flac_read_pcm_frames_f32__decode_mid_side__reference(ma_dr_flac* pFlac, ma_uint64 frameCount, ma_uint32 unusedBitsPerSample, const ma_int32* pInputSamples0, const ma_int32* pInputSamples1, float* pOutputSamples) { for (ma_uint64 i = 0; i < frameCount; ++i) { ma_uint32 mid = (ma_uint32)pInputSamples0[i] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample; ma_uint32 side = (ma_uint32)pInputSamples1[i] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample; mid = (mid << 1) | (side & 0x01); pOutputSamples[i*2+0] = (float)((((ma_int32)(mid + side) >> 1) << (unusedBitsPerSample)) / 2147483648.0); pOutputSamples[i*2+1] = (float)((((ma_int32)(mid - side) >> 1) << (unusedBitsPerSample)) / 2147483648.0); } } #endif static MA_INLINE void ma_dr_flac_read_pcm_frames_f32__decode_mid_side__scalar(ma_dr_flac* pFlac, ma_uint64 frameCount, ma_uint32 unusedBitsPerSample, const ma_int32* pInputSamples0, const ma_int32* pInputSamples1, float* pOutputSamples) { ma_uint64 i; ma_uint64 frameCount4 = frameCount >> 2; const ma_uint32* pInputSamples0U32 = (const ma_uint32*)pInputSamples0; const ma_uint32* pInputSamples1U32 = (const ma_uint32*)pInputSamples1; ma_uint32 shift = unusedBitsPerSample; float factor = 1 / 2147483648.0; if (shift > 0) { shift -= 1; for (i = 0; i < frameCount4; ++i) { ma_uint32 temp0L; ma_uint32 temp1L; ma_uint32 temp2L; ma_uint32 temp3L; ma_uint32 temp0R; ma_uint32 temp1R; ma_uint32 temp2R; ma_uint32 temp3R; ma_uint32 mid0 = pInputSamples0U32[i*4+0] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample; ma_uint32 mid1 = pInputSamples0U32[i*4+1] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample; ma_uint32 mid2 = pInputSamples0U32[i*4+2] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample; ma_uint32 mid3 = pInputSamples0U32[i*4+3] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample; ma_uint32 side0 = pInputSamples1U32[i*4+0] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample; ma_uint32 side1 = pInputSamples1U32[i*4+1] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample; ma_uint32 side2 = pInputSamples1U32[i*4+2] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample; ma_uint32 side3 = pInputSamples1U32[i*4+3] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample; mid0 = (mid0 << 1) | (side0 & 0x01); mid1 = (mid1 << 1) | (side1 & 0x01); mid2 = (mid2 << 1) | (side2 & 0x01); mid3 = (mid3 << 1) | (side3 & 0x01); temp0L = (mid0 + side0) << shift; temp1L = (mid1 + side1) << shift; temp2L = (mid2 + side2) << shift; temp3L = (mid3 + side3) << shift; temp0R = (mid0 - side0) << shift; temp1R = (mid1 - side1) << shift; temp2R = (mid2 - side2) << shift; temp3R = (mid3 - side3) << shift; pOutputSamples[i*8+0] = (ma_int32)temp0L * factor; pOutputSamples[i*8+1] = (ma_int32)temp0R * factor; pOutputSamples[i*8+2] = (ma_int32)temp1L * factor; pOutputSamples[i*8+3] = (ma_int32)temp1R * factor; pOutputSamples[i*8+4] = (ma_int32)temp2L * factor; pOutputSamples[i*8+5] = (ma_int32)temp2R * factor; pOutputSamples[i*8+6] = (ma_int32)temp3L * factor; pOutputSamples[i*8+7] = (ma_int32)temp3R * factor; } } else { for (i = 0; i < frameCount4; ++i) { ma_uint32 temp0L; ma_uint32 temp1L; ma_uint32 temp2L; ma_uint32 temp3L; ma_uint32 temp0R; ma_uint32 temp1R; ma_uint32 temp2R; ma_uint32 temp3R; ma_uint32 mid0 = pInputSamples0U32[i*4+0] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample; ma_uint32 mid1 = pInputSamples0U32[i*4+1] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample; ma_uint32 mid2 = pInputSamples0U32[i*4+2] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample; ma_uint32 mid3 = pInputSamples0U32[i*4+3] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample; ma_uint32 side0 = pInputSamples1U32[i*4+0] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample; ma_uint32 side1 = pInputSamples1U32[i*4+1] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample; ma_uint32 side2 = pInputSamples1U32[i*4+2] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample; ma_uint32 side3 = pInputSamples1U32[i*4+3] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample; mid0 = (mid0 << 1) | (side0 & 0x01); mid1 = (mid1 << 1) | (side1 & 0x01); mid2 = (mid2 << 1) | (side2 & 0x01); mid3 = (mid3 << 1) | (side3 & 0x01); temp0L = (ma_uint32)((ma_int32)(mid0 + side0) >> 1); temp1L = (ma_uint32)((ma_int32)(mid1 + side1) >> 1); temp2L = (ma_uint32)((ma_int32)(mid2 + side2) >> 1); temp3L = (ma_uint32)((ma_int32)(mid3 + side3) >> 1); temp0R = (ma_uint32)((ma_int32)(mid0 - side0) >> 1); temp1R = (ma_uint32)((ma_int32)(mid1 - side1) >> 1); temp2R = (ma_uint32)((ma_int32)(mid2 - side2) >> 1); temp3R = (ma_uint32)((ma_int32)(mid3 - side3) >> 1); pOutputSamples[i*8+0] = (ma_int32)temp0L * factor; pOutputSamples[i*8+1] = (ma_int32)temp0R * factor; pOutputSamples[i*8+2] = (ma_int32)temp1L * factor; pOutputSamples[i*8+3] = (ma_int32)temp1R * factor; pOutputSamples[i*8+4] = (ma_int32)temp2L * factor; pOutputSamples[i*8+5] = (ma_int32)temp2R * factor; pOutputSamples[i*8+6] = (ma_int32)temp3L * factor; pOutputSamples[i*8+7] = (ma_int32)temp3R * factor; } } for (i = (frameCount4 << 2); i < frameCount; ++i) { ma_uint32 mid = pInputSamples0U32[i] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample; ma_uint32 side = pInputSamples1U32[i] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample; mid = (mid << 1) | (side & 0x01); pOutputSamples[i*2+0] = (ma_int32)((ma_uint32)((ma_int32)(mid + side) >> 1) << unusedBitsPerSample) * factor; pOutputSamples[i*2+1] = (ma_int32)((ma_uint32)((ma_int32)(mid - side) >> 1) << unusedBitsPerSample) * factor; } } #if defined(MA_DR_FLAC_SUPPORT_SSE2) static MA_INLINE void ma_dr_flac_read_pcm_frames_f32__decode_mid_side__sse2(ma_dr_flac* pFlac, ma_uint64 frameCount, ma_uint32 unusedBitsPerSample, const ma_int32* pInputSamples0, const ma_int32* pInputSamples1, float* pOutputSamples) { ma_uint64 i; ma_uint64 frameCount4 = frameCount >> 2; const ma_uint32* pInputSamples0U32 = (const ma_uint32*)pInputSamples0; const ma_uint32* pInputSamples1U32 = (const ma_uint32*)pInputSamples1; ma_uint32 shift = unusedBitsPerSample - 8; float factor; __m128 factor128; MA_DR_FLAC_ASSERT(pFlac->bitsPerSample <= 24); factor = 1.0f / 8388608.0f; factor128 = _mm_set1_ps(factor); if (shift == 0) { for (i = 0; i < frameCount4; ++i) { __m128i mid; __m128i side; __m128i tempL; __m128i tempR; __m128 leftf; __m128 rightf; mid = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples0 + i), pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample); side = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples1 + i), pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample); mid = _mm_or_si128(_mm_slli_epi32(mid, 1), _mm_and_si128(side, _mm_set1_epi32(0x01))); tempL = _mm_srai_epi32(_mm_add_epi32(mid, side), 1); tempR = _mm_srai_epi32(_mm_sub_epi32(mid, side), 1); leftf = _mm_mul_ps(_mm_cvtepi32_ps(tempL), factor128); rightf = _mm_mul_ps(_mm_cvtepi32_ps(tempR), factor128); _mm_storeu_ps(pOutputSamples + i*8 + 0, _mm_unpacklo_ps(leftf, rightf)); _mm_storeu_ps(pOutputSamples + i*8 + 4, _mm_unpackhi_ps(leftf, rightf)); } for (i = (frameCount4 << 2); i < frameCount; ++i) { ma_uint32 mid = pInputSamples0U32[i] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample; ma_uint32 side = pInputSamples1U32[i] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample; mid = (mid << 1) | (side & 0x01); pOutputSamples[i*2+0] = ((ma_int32)(mid + side) >> 1) * factor; pOutputSamples[i*2+1] = ((ma_int32)(mid - side) >> 1) * factor; } } else { shift -= 1; for (i = 0; i < frameCount4; ++i) { __m128i mid; __m128i side; __m128i tempL; __m128i tempR; __m128 leftf; __m128 rightf; mid = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples0 + i), pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample); side = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples1 + i), pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample); mid = _mm_or_si128(_mm_slli_epi32(mid, 1), _mm_and_si128(side, _mm_set1_epi32(0x01))); tempL = _mm_slli_epi32(_mm_add_epi32(mid, side), shift); tempR = _mm_slli_epi32(_mm_sub_epi32(mid, side), shift); leftf = _mm_mul_ps(_mm_cvtepi32_ps(tempL), factor128); rightf = _mm_mul_ps(_mm_cvtepi32_ps(tempR), factor128); _mm_storeu_ps(pOutputSamples + i*8 + 0, _mm_unpacklo_ps(leftf, rightf)); _mm_storeu_ps(pOutputSamples + i*8 + 4, _mm_unpackhi_ps(leftf, rightf)); } for (i = (frameCount4 << 2); i < frameCount; ++i) { ma_uint32 mid = pInputSamples0U32[i] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample; ma_uint32 side = pInputSamples1U32[i] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample; mid = (mid << 1) | (side & 0x01); pOutputSamples[i*2+0] = (ma_int32)((mid + side) << shift) * factor; pOutputSamples[i*2+1] = (ma_int32)((mid - side) << shift) * factor; } } } #endif #if defined(MA_DR_FLAC_SUPPORT_NEON) static MA_INLINE void ma_dr_flac_read_pcm_frames_f32__decode_mid_side__neon(ma_dr_flac* pFlac, ma_uint64 frameCount, ma_uint32 unusedBitsPerSample, const ma_int32* pInputSamples0, const ma_int32* pInputSamples1, float* pOutputSamples) { ma_uint64 i; ma_uint64 frameCount4 = frameCount >> 2; const ma_uint32* pInputSamples0U32 = (const ma_uint32*)pInputSamples0; const ma_uint32* pInputSamples1U32 = (const ma_uint32*)pInputSamples1; ma_uint32 shift = unusedBitsPerSample - 8; float factor; float32x4_t factor4; int32x4_t shift4; int32x4_t wbps0_4; int32x4_t wbps1_4; MA_DR_FLAC_ASSERT(pFlac->bitsPerSample <= 24); factor = 1.0f / 8388608.0f; factor4 = vdupq_n_f32(factor); wbps0_4 = vdupq_n_s32(pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample); wbps1_4 = vdupq_n_s32(pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample); if (shift == 0) { for (i = 0; i < frameCount4; ++i) { int32x4_t lefti; int32x4_t righti; float32x4_t leftf; float32x4_t rightf; uint32x4_t mid = vshlq_u32(vld1q_u32(pInputSamples0U32 + i*4), wbps0_4); uint32x4_t side = vshlq_u32(vld1q_u32(pInputSamples1U32 + i*4), wbps1_4); mid = vorrq_u32(vshlq_n_u32(mid, 1), vandq_u32(side, vdupq_n_u32(1))); lefti = vshrq_n_s32(vreinterpretq_s32_u32(vaddq_u32(mid, side)), 1); righti = vshrq_n_s32(vreinterpretq_s32_u32(vsubq_u32(mid, side)), 1); leftf = vmulq_f32(vcvtq_f32_s32(lefti), factor4); rightf = vmulq_f32(vcvtq_f32_s32(righti), factor4); ma_dr_flac__vst2q_f32(pOutputSamples + i*8, vzipq_f32(leftf, rightf)); } for (i = (frameCount4 << 2); i < frameCount; ++i) { ma_uint32 mid = pInputSamples0U32[i] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample; ma_uint32 side = pInputSamples1U32[i] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample; mid = (mid << 1) | (side & 0x01); pOutputSamples[i*2+0] = ((ma_int32)(mid + side) >> 1) * factor; pOutputSamples[i*2+1] = ((ma_int32)(mid - side) >> 1) * factor; } } else { shift -= 1; shift4 = vdupq_n_s32(shift); for (i = 0; i < frameCount4; ++i) { uint32x4_t mid; uint32x4_t side; int32x4_t lefti; int32x4_t righti; float32x4_t leftf; float32x4_t rightf; mid = vshlq_u32(vld1q_u32(pInputSamples0U32 + i*4), wbps0_4); side = vshlq_u32(vld1q_u32(pInputSamples1U32 + i*4), wbps1_4); mid = vorrq_u32(vshlq_n_u32(mid, 1), vandq_u32(side, vdupq_n_u32(1))); lefti = vreinterpretq_s32_u32(vshlq_u32(vaddq_u32(mid, side), shift4)); righti = vreinterpretq_s32_u32(vshlq_u32(vsubq_u32(mid, side), shift4)); leftf = vmulq_f32(vcvtq_f32_s32(lefti), factor4); rightf = vmulq_f32(vcvtq_f32_s32(righti), factor4); ma_dr_flac__vst2q_f32(pOutputSamples + i*8, vzipq_f32(leftf, rightf)); } for (i = (frameCount4 << 2); i < frameCount; ++i) { ma_uint32 mid = pInputSamples0U32[i] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample; ma_uint32 side = pInputSamples1U32[i] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample; mid = (mid << 1) | (side & 0x01); pOutputSamples[i*2+0] = (ma_int32)((mid + side) << shift) * factor; pOutputSamples[i*2+1] = (ma_int32)((mid - side) << shift) * factor; } } } #endif static MA_INLINE void ma_dr_flac_read_pcm_frames_f32__decode_mid_side(ma_dr_flac* pFlac, ma_uint64 frameCount, ma_uint32 unusedBitsPerSample, const ma_int32* pInputSamples0, const ma_int32* pInputSamples1, float* pOutputSamples) { #if defined(MA_DR_FLAC_SUPPORT_SSE2) if (ma_dr_flac__gIsSSE2Supported && pFlac->bitsPerSample <= 24) { ma_dr_flac_read_pcm_frames_f32__decode_mid_side__sse2(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples); } else #elif defined(MA_DR_FLAC_SUPPORT_NEON) if (ma_dr_flac__gIsNEONSupported && pFlac->bitsPerSample <= 24) { ma_dr_flac_read_pcm_frames_f32__decode_mid_side__neon(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples); } else #endif { #if 0 ma_dr_flac_read_pcm_frames_f32__decode_mid_side__reference(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples); #else ma_dr_flac_read_pcm_frames_f32__decode_mid_side__scalar(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples); #endif } } #if 0 static MA_INLINE void ma_dr_flac_read_pcm_frames_f32__decode_independent_stereo__reference(ma_dr_flac* pFlac, ma_uint64 frameCount, ma_uint32 unusedBitsPerSample, const ma_int32* pInputSamples0, const ma_int32* pInputSamples1, float* pOutputSamples) { for (ma_uint64 i = 0; i < frameCount; ++i) { pOutputSamples[i*2+0] = (float)((ma_int32)((ma_uint32)pInputSamples0[i] << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample)) / 2147483648.0); pOutputSamples[i*2+1] = (float)((ma_int32)((ma_uint32)pInputSamples1[i] << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample)) / 2147483648.0); } } #endif static MA_INLINE void ma_dr_flac_read_pcm_frames_f32__decode_independent_stereo__scalar(ma_dr_flac* pFlac, ma_uint64 frameCount, ma_uint32 unusedBitsPerSample, const ma_int32* pInputSamples0, const ma_int32* pInputSamples1, float* pOutputSamples) { ma_uint64 i; ma_uint64 frameCount4 = frameCount >> 2; const ma_uint32* pInputSamples0U32 = (const ma_uint32*)pInputSamples0; const ma_uint32* pInputSamples1U32 = (const ma_uint32*)pInputSamples1; ma_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample; ma_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample; float factor = 1 / 2147483648.0; for (i = 0; i < frameCount4; ++i) { ma_uint32 tempL0 = pInputSamples0U32[i*4+0] << shift0; ma_uint32 tempL1 = pInputSamples0U32[i*4+1] << shift0; ma_uint32 tempL2 = pInputSamples0U32[i*4+2] << shift0; ma_uint32 tempL3 = pInputSamples0U32[i*4+3] << shift0; ma_uint32 tempR0 = pInputSamples1U32[i*4+0] << shift1; ma_uint32 tempR1 = pInputSamples1U32[i*4+1] << shift1; ma_uint32 tempR2 = pInputSamples1U32[i*4+2] << shift1; ma_uint32 tempR3 = pInputSamples1U32[i*4+3] << shift1; pOutputSamples[i*8+0] = (ma_int32)tempL0 * factor; pOutputSamples[i*8+1] = (ma_int32)tempR0 * factor; pOutputSamples[i*8+2] = (ma_int32)tempL1 * factor; pOutputSamples[i*8+3] = (ma_int32)tempR1 * factor; pOutputSamples[i*8+4] = (ma_int32)tempL2 * factor; pOutputSamples[i*8+5] = (ma_int32)tempR2 * factor; pOutputSamples[i*8+6] = (ma_int32)tempL3 * factor; pOutputSamples[i*8+7] = (ma_int32)tempR3 * factor; } for (i = (frameCount4 << 2); i < frameCount; ++i) { pOutputSamples[i*2+0] = (ma_int32)(pInputSamples0U32[i] << shift0) * factor; pOutputSamples[i*2+1] = (ma_int32)(pInputSamples1U32[i] << shift1) * factor; } } #if defined(MA_DR_FLAC_SUPPORT_SSE2) static MA_INLINE void ma_dr_flac_read_pcm_frames_f32__decode_independent_stereo__sse2(ma_dr_flac* pFlac, ma_uint64 frameCount, ma_uint32 unusedBitsPerSample, const ma_int32* pInputSamples0, const ma_int32* pInputSamples1, float* pOutputSamples) { ma_uint64 i; ma_uint64 frameCount4 = frameCount >> 2; const ma_uint32* pInputSamples0U32 = (const ma_uint32*)pInputSamples0; const ma_uint32* pInputSamples1U32 = (const ma_uint32*)pInputSamples1; ma_uint32 shift0 = (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample) - 8; ma_uint32 shift1 = (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample) - 8; float factor = 1.0f / 8388608.0f; __m128 factor128 = _mm_set1_ps(factor); for (i = 0; i < frameCount4; ++i) { __m128i lefti; __m128i righti; __m128 leftf; __m128 rightf; lefti = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples0 + i), shift0); righti = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples1 + i), shift1); leftf = _mm_mul_ps(_mm_cvtepi32_ps(lefti), factor128); rightf = _mm_mul_ps(_mm_cvtepi32_ps(righti), factor128); _mm_storeu_ps(pOutputSamples + i*8 + 0, _mm_unpacklo_ps(leftf, rightf)); _mm_storeu_ps(pOutputSamples + i*8 + 4, _mm_unpackhi_ps(leftf, rightf)); } for (i = (frameCount4 << 2); i < frameCount; ++i) { pOutputSamples[i*2+0] = (ma_int32)(pInputSamples0U32[i] << shift0) * factor; pOutputSamples[i*2+1] = (ma_int32)(pInputSamples1U32[i] << shift1) * factor; } } #endif #if defined(MA_DR_FLAC_SUPPORT_NEON) static MA_INLINE void ma_dr_flac_read_pcm_frames_f32__decode_independent_stereo__neon(ma_dr_flac* pFlac, ma_uint64 frameCount, ma_uint32 unusedBitsPerSample, const ma_int32* pInputSamples0, const ma_int32* pInputSamples1, float* pOutputSamples) { ma_uint64 i; ma_uint64 frameCount4 = frameCount >> 2; const ma_uint32* pInputSamples0U32 = (const ma_uint32*)pInputSamples0; const ma_uint32* pInputSamples1U32 = (const ma_uint32*)pInputSamples1; ma_uint32 shift0 = (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample) - 8; ma_uint32 shift1 = (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample) - 8; float factor = 1.0f / 8388608.0f; float32x4_t factor4 = vdupq_n_f32(factor); int32x4_t shift0_4 = vdupq_n_s32(shift0); int32x4_t shift1_4 = vdupq_n_s32(shift1); for (i = 0; i < frameCount4; ++i) { int32x4_t lefti; int32x4_t righti; float32x4_t leftf; float32x4_t rightf; lefti = vreinterpretq_s32_u32(vshlq_u32(vld1q_u32(pInputSamples0U32 + i*4), shift0_4)); righti = vreinterpretq_s32_u32(vshlq_u32(vld1q_u32(pInputSamples1U32 + i*4), shift1_4)); leftf = vmulq_f32(vcvtq_f32_s32(lefti), factor4); rightf = vmulq_f32(vcvtq_f32_s32(righti), factor4); ma_dr_flac__vst2q_f32(pOutputSamples + i*8, vzipq_f32(leftf, rightf)); } for (i = (frameCount4 << 2); i < frameCount; ++i) { pOutputSamples[i*2+0] = (ma_int32)(pInputSamples0U32[i] << shift0) * factor; pOutputSamples[i*2+1] = (ma_int32)(pInputSamples1U32[i] << shift1) * factor; } } #endif static MA_INLINE void ma_dr_flac_read_pcm_frames_f32__decode_independent_stereo(ma_dr_flac* pFlac, ma_uint64 frameCount, ma_uint32 unusedBitsPerSample, const ma_int32* pInputSamples0, const ma_int32* pInputSamples1, float* pOutputSamples) { #if defined(MA_DR_FLAC_SUPPORT_SSE2) if (ma_dr_flac__gIsSSE2Supported && pFlac->bitsPerSample <= 24) { ma_dr_flac_read_pcm_frames_f32__decode_independent_stereo__sse2(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples); } else #elif defined(MA_DR_FLAC_SUPPORT_NEON) if (ma_dr_flac__gIsNEONSupported && pFlac->bitsPerSample <= 24) { ma_dr_flac_read_pcm_frames_f32__decode_independent_stereo__neon(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples); } else #endif { #if 0 ma_dr_flac_read_pcm_frames_f32__decode_independent_stereo__reference(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples); #else ma_dr_flac_read_pcm_frames_f32__decode_independent_stereo__scalar(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples); #endif } } MA_API ma_uint64 ma_dr_flac_read_pcm_frames_f32(ma_dr_flac* pFlac, ma_uint64 framesToRead, float* pBufferOut) { ma_uint64 framesRead; ma_uint32 unusedBitsPerSample; if (pFlac == NULL || framesToRead == 0) { return 0; } if (pBufferOut == NULL) { return ma_dr_flac__seek_forward_by_pcm_frames(pFlac, framesToRead); } MA_DR_FLAC_ASSERT(pFlac->bitsPerSample <= 32); unusedBitsPerSample = 32 - pFlac->bitsPerSample; framesRead = 0; while (framesToRead > 0) { if (pFlac->currentFLACFrame.pcmFramesRemaining == 0) { if (!ma_dr_flac__read_and_decode_next_flac_frame(pFlac)) { break; } } else { unsigned int channelCount = ma_dr_flac__get_channel_count_from_channel_assignment(pFlac->currentFLACFrame.header.channelAssignment); ma_uint64 iFirstPCMFrame = pFlac->currentFLACFrame.header.blockSizeInPCMFrames - pFlac->currentFLACFrame.pcmFramesRemaining; ma_uint64 frameCountThisIteration = framesToRead; if (frameCountThisIteration > pFlac->currentFLACFrame.pcmFramesRemaining) { frameCountThisIteration = pFlac->currentFLACFrame.pcmFramesRemaining; } if (channelCount == 2) { const ma_int32* pDecodedSamples0 = pFlac->currentFLACFrame.subframes[0].pSamplesS32 + iFirstPCMFrame; const ma_int32* pDecodedSamples1 = pFlac->currentFLACFrame.subframes[1].pSamplesS32 + iFirstPCMFrame; switch (pFlac->currentFLACFrame.header.channelAssignment) { case MA_DR_FLAC_CHANNEL_ASSIGNMENT_LEFT_SIDE: { ma_dr_flac_read_pcm_frames_f32__decode_left_side(pFlac, frameCountThisIteration, unusedBitsPerSample, pDecodedSamples0, pDecodedSamples1, pBufferOut); } break; case MA_DR_FLAC_CHANNEL_ASSIGNMENT_RIGHT_SIDE: { ma_dr_flac_read_pcm_frames_f32__decode_right_side(pFlac, frameCountThisIteration, unusedBitsPerSample, pDecodedSamples0, pDecodedSamples1, pBufferOut); } break; case MA_DR_FLAC_CHANNEL_ASSIGNMENT_MID_SIDE: { ma_dr_flac_read_pcm_frames_f32__decode_mid_side(pFlac, frameCountThisIteration, unusedBitsPerSample, pDecodedSamples0, pDecodedSamples1, pBufferOut); } break; case MA_DR_FLAC_CHANNEL_ASSIGNMENT_INDEPENDENT: default: { ma_dr_flac_read_pcm_frames_f32__decode_independent_stereo(pFlac, frameCountThisIteration, unusedBitsPerSample, pDecodedSamples0, pDecodedSamples1, pBufferOut); } break; } } else { ma_uint64 i; for (i = 0; i < frameCountThisIteration; ++i) { unsigned int j; for (j = 0; j < channelCount; ++j) { ma_int32 sampleS32 = (ma_int32)((ma_uint32)(pFlac->currentFLACFrame.subframes[j].pSamplesS32[iFirstPCMFrame + i]) << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[j].wastedBitsPerSample)); pBufferOut[(i*channelCount)+j] = (float)(sampleS32 / 2147483648.0); } } } framesRead += frameCountThisIteration; pBufferOut += frameCountThisIteration * channelCount; framesToRead -= frameCountThisIteration; pFlac->currentPCMFrame += frameCountThisIteration; pFlac->currentFLACFrame.pcmFramesRemaining -= (unsigned int)frameCountThisIteration; } } return framesRead; } MA_API ma_bool32 ma_dr_flac_seek_to_pcm_frame(ma_dr_flac* pFlac, ma_uint64 pcmFrameIndex) { if (pFlac == NULL) { return MA_FALSE; } if (pFlac->currentPCMFrame == pcmFrameIndex) { return MA_TRUE; } if (pFlac->firstFLACFramePosInBytes == 0) { return MA_FALSE; } if (pcmFrameIndex == 0) { pFlac->currentPCMFrame = 0; return ma_dr_flac__seek_to_first_frame(pFlac); } else { ma_bool32 wasSuccessful = MA_FALSE; ma_uint64 originalPCMFrame = pFlac->currentPCMFrame; if (pcmFrameIndex > pFlac->totalPCMFrameCount) { pcmFrameIndex = pFlac->totalPCMFrameCount; } if (pcmFrameIndex > pFlac->currentPCMFrame) { ma_uint32 offset = (ma_uint32)(pcmFrameIndex - pFlac->currentPCMFrame); if (pFlac->currentFLACFrame.pcmFramesRemaining > offset) { pFlac->currentFLACFrame.pcmFramesRemaining -= offset; pFlac->currentPCMFrame = pcmFrameIndex; return MA_TRUE; } } else { ma_uint32 offsetAbs = (ma_uint32)(pFlac->currentPCMFrame - pcmFrameIndex); ma_uint32 currentFLACFramePCMFrameCount = pFlac->currentFLACFrame.header.blockSizeInPCMFrames; ma_uint32 currentFLACFramePCMFramesConsumed = currentFLACFramePCMFrameCount - pFlac->currentFLACFrame.pcmFramesRemaining; if (currentFLACFramePCMFramesConsumed > offsetAbs) { pFlac->currentFLACFrame.pcmFramesRemaining += offsetAbs; pFlac->currentPCMFrame = pcmFrameIndex; return MA_TRUE; } } #ifndef MA_DR_FLAC_NO_OGG if (pFlac->container == ma_dr_flac_container_ogg) { wasSuccessful = ma_dr_flac_ogg__seek_to_pcm_frame(pFlac, pcmFrameIndex); } else #endif { if (!pFlac->_noSeekTableSeek) { wasSuccessful = ma_dr_flac__seek_to_pcm_frame__seek_table(pFlac, pcmFrameIndex); } #if !defined(MA_DR_FLAC_NO_CRC) if (!wasSuccessful && !pFlac->_noBinarySearchSeek && pFlac->totalPCMFrameCount > 0) { wasSuccessful = ma_dr_flac__seek_to_pcm_frame__binary_search(pFlac, pcmFrameIndex); } #endif if (!wasSuccessful && !pFlac->_noBruteForceSeek) { wasSuccessful = ma_dr_flac__seek_to_pcm_frame__brute_force(pFlac, pcmFrameIndex); } } if (wasSuccessful) { pFlac->currentPCMFrame = pcmFrameIndex; } else { if (ma_dr_flac_seek_to_pcm_frame(pFlac, originalPCMFrame) == MA_FALSE) { ma_dr_flac_seek_to_pcm_frame(pFlac, 0); } } return wasSuccessful; } } #define MA_DR_FLAC_DEFINE_FULL_READ_AND_CLOSE(extension, type) \ static type* ma_dr_flac__full_read_and_close_ ## extension (ma_dr_flac* pFlac, unsigned int* channelsOut, unsigned int* sampleRateOut, ma_uint64* totalPCMFrameCountOut)\ { \ type* pSampleData = NULL; \ ma_uint64 totalPCMFrameCount; \ \ MA_DR_FLAC_ASSERT(pFlac != NULL); \ \ totalPCMFrameCount = pFlac->totalPCMFrameCount; \ \ if (totalPCMFrameCount == 0) { \ type buffer[4096]; \ ma_uint64 pcmFramesRead; \ size_t sampleDataBufferSize = sizeof(buffer); \ \ pSampleData = (type*)ma_dr_flac__malloc_from_callbacks(sampleDataBufferSize, &pFlac->allocationCallbacks); \ if (pSampleData == NULL) { \ goto on_error; \ } \ \ while ((pcmFramesRead = (ma_uint64)ma_dr_flac_read_pcm_frames_##extension(pFlac, sizeof(buffer)/sizeof(buffer[0])/pFlac->channels, buffer)) > 0) { \ if (((totalPCMFrameCount + pcmFramesRead) * pFlac->channels * sizeof(type)) > sampleDataBufferSize) { \ type* pNewSampleData; \ size_t newSampleDataBufferSize; \ \ newSampleDataBufferSize = sampleDataBufferSize * 2; \ pNewSampleData = (type*)ma_dr_flac__realloc_from_callbacks(pSampleData, newSampleDataBufferSize, sampleDataBufferSize, &pFlac->allocationCallbacks); \ if (pNewSampleData == NULL) { \ ma_dr_flac__free_from_callbacks(pSampleData, &pFlac->allocationCallbacks); \ goto on_error; \ } \ \ sampleDataBufferSize = newSampleDataBufferSize; \ pSampleData = pNewSampleData; \ } \ \ MA_DR_FLAC_COPY_MEMORY(pSampleData + (totalPCMFrameCount*pFlac->channels), buffer, (size_t)(pcmFramesRead*pFlac->channels*sizeof(type))); \ totalPCMFrameCount += pcmFramesRead; \ } \ \ \ MA_DR_FLAC_ZERO_MEMORY(pSampleData + (totalPCMFrameCount*pFlac->channels), (size_t)(sampleDataBufferSize - totalPCMFrameCount*pFlac->channels*sizeof(type))); \ } else { \ ma_uint64 dataSize = totalPCMFrameCount*pFlac->channels*sizeof(type); \ if (dataSize > (ma_uint64)MA_SIZE_MAX) { \ goto on_error; \ } \ \ pSampleData = (type*)ma_dr_flac__malloc_from_callbacks((size_t)dataSize, &pFlac->allocationCallbacks); \ if (pSampleData == NULL) { \ goto on_error; \ } \ \ totalPCMFrameCount = ma_dr_flac_read_pcm_frames_##extension(pFlac, pFlac->totalPCMFrameCount, pSampleData); \ } \ \ if (sampleRateOut) *sampleRateOut = pFlac->sampleRate; \ if (channelsOut) *channelsOut = pFlac->channels; \ if (totalPCMFrameCountOut) *totalPCMFrameCountOut = totalPCMFrameCount; \ \ ma_dr_flac_close(pFlac); \ return pSampleData; \ \ on_error: \ ma_dr_flac_close(pFlac); \ return NULL; \ } MA_DR_FLAC_DEFINE_FULL_READ_AND_CLOSE(s32, ma_int32) MA_DR_FLAC_DEFINE_FULL_READ_AND_CLOSE(s16, ma_int16) MA_DR_FLAC_DEFINE_FULL_READ_AND_CLOSE(f32, float) MA_API ma_int32* ma_dr_flac_open_and_read_pcm_frames_s32(ma_dr_flac_read_proc onRead, ma_dr_flac_seek_proc onSeek, void* pUserData, unsigned int* channelsOut, unsigned int* sampleRateOut, ma_uint64* totalPCMFrameCountOut, const ma_allocation_callbacks* pAllocationCallbacks) { ma_dr_flac* pFlac; if (channelsOut) { *channelsOut = 0; } if (sampleRateOut) { *sampleRateOut = 0; } if (totalPCMFrameCountOut) { *totalPCMFrameCountOut = 0; } pFlac = ma_dr_flac_open(onRead, onSeek, pUserData, pAllocationCallbacks); if (pFlac == NULL) { return NULL; } return ma_dr_flac__full_read_and_close_s32(pFlac, channelsOut, sampleRateOut, totalPCMFrameCountOut); } MA_API ma_int16* ma_dr_flac_open_and_read_pcm_frames_s16(ma_dr_flac_read_proc onRead, ma_dr_flac_seek_proc onSeek, void* pUserData, unsigned int* channelsOut, unsigned int* sampleRateOut, ma_uint64* totalPCMFrameCountOut, const ma_allocation_callbacks* pAllocationCallbacks) { ma_dr_flac* pFlac; if (channelsOut) { *channelsOut = 0; } if (sampleRateOut) { *sampleRateOut = 0; } if (totalPCMFrameCountOut) { *totalPCMFrameCountOut = 0; } pFlac = ma_dr_flac_open(onRead, onSeek, pUserData, pAllocationCallbacks); if (pFlac == NULL) { return NULL; } return ma_dr_flac__full_read_and_close_s16(pFlac, channelsOut, sampleRateOut, totalPCMFrameCountOut); } MA_API float* ma_dr_flac_open_and_read_pcm_frames_f32(ma_dr_flac_read_proc onRead, ma_dr_flac_seek_proc onSeek, void* pUserData, unsigned int* channelsOut, unsigned int* sampleRateOut, ma_uint64* totalPCMFrameCountOut, const ma_allocation_callbacks* pAllocationCallbacks) { ma_dr_flac* pFlac; if (channelsOut) { *channelsOut = 0; } if (sampleRateOut) { *sampleRateOut = 0; } if (totalPCMFrameCountOut) { *totalPCMFrameCountOut = 0; } pFlac = ma_dr_flac_open(onRead, onSeek, pUserData, pAllocationCallbacks); if (pFlac == NULL) { return NULL; } return ma_dr_flac__full_read_and_close_f32(pFlac, channelsOut, sampleRateOut, totalPCMFrameCountOut); } #ifndef MA_DR_FLAC_NO_STDIO MA_API ma_int32* ma_dr_flac_open_file_and_read_pcm_frames_s32(const char* filename, unsigned int* channels, unsigned int* sampleRate, ma_uint64* totalPCMFrameCount, const ma_allocation_callbacks* pAllocationCallbacks) { ma_dr_flac* pFlac; if (sampleRate) { *sampleRate = 0; } if (channels) { *channels = 0; } if (totalPCMFrameCount) { *totalPCMFrameCount = 0; } pFlac = ma_dr_flac_open_file(filename, pAllocationCallbacks); if (pFlac == NULL) { return NULL; } return ma_dr_flac__full_read_and_close_s32(pFlac, channels, sampleRate, totalPCMFrameCount); } MA_API ma_int16* ma_dr_flac_open_file_and_read_pcm_frames_s16(const char* filename, unsigned int* channels, unsigned int* sampleRate, ma_uint64* totalPCMFrameCount, const ma_allocation_callbacks* pAllocationCallbacks) { ma_dr_flac* pFlac; if (sampleRate) { *sampleRate = 0; } if (channels) { *channels = 0; } if (totalPCMFrameCount) { *totalPCMFrameCount = 0; } pFlac = ma_dr_flac_open_file(filename, pAllocationCallbacks); if (pFlac == NULL) { return NULL; } return ma_dr_flac__full_read_and_close_s16(pFlac, channels, sampleRate, totalPCMFrameCount); } MA_API float* ma_dr_flac_open_file_and_read_pcm_frames_f32(const char* filename, unsigned int* channels, unsigned int* sampleRate, ma_uint64* totalPCMFrameCount, const ma_allocation_callbacks* pAllocationCallbacks) { ma_dr_flac* pFlac; if (sampleRate) { *sampleRate = 0; } if (channels) { *channels = 0; } if (totalPCMFrameCount) { *totalPCMFrameCount = 0; } pFlac = ma_dr_flac_open_file(filename, pAllocationCallbacks); if (pFlac == NULL) { return NULL; } return ma_dr_flac__full_read_and_close_f32(pFlac, channels, sampleRate, totalPCMFrameCount); } #endif MA_API ma_int32* ma_dr_flac_open_memory_and_read_pcm_frames_s32(const void* data, size_t dataSize, unsigned int* channels, unsigned int* sampleRate, ma_uint64* totalPCMFrameCount, const ma_allocation_callbacks* pAllocationCallbacks) { ma_dr_flac* pFlac; if (sampleRate) { *sampleRate = 0; } if (channels) { *channels = 0; } if (totalPCMFrameCount) { *totalPCMFrameCount = 0; } pFlac = ma_dr_flac_open_memory(data, dataSize, pAllocationCallbacks); if (pFlac == NULL) { return NULL; } return ma_dr_flac__full_read_and_close_s32(pFlac, channels, sampleRate, totalPCMFrameCount); } MA_API ma_int16* ma_dr_flac_open_memory_and_read_pcm_frames_s16(const void* data, size_t dataSize, unsigned int* channels, unsigned int* sampleRate, ma_uint64* totalPCMFrameCount, const ma_allocation_callbacks* pAllocationCallbacks) { ma_dr_flac* pFlac; if (sampleRate) { *sampleRate = 0; } if (channels) { *channels = 0; } if (totalPCMFrameCount) { *totalPCMFrameCount = 0; } pFlac = ma_dr_flac_open_memory(data, dataSize, pAllocationCallbacks); if (pFlac == NULL) { return NULL; } return ma_dr_flac__full_read_and_close_s16(pFlac, channels, sampleRate, totalPCMFrameCount); } MA_API float* ma_dr_flac_open_memory_and_read_pcm_frames_f32(const void* data, size_t dataSize, unsigned int* channels, unsigned int* sampleRate, ma_uint64* totalPCMFrameCount, const ma_allocation_callbacks* pAllocationCallbacks) { ma_dr_flac* pFlac; if (sampleRate) { *sampleRate = 0; } if (channels) { *channels = 0; } if (totalPCMFrameCount) { *totalPCMFrameCount = 0; } pFlac = ma_dr_flac_open_memory(data, dataSize, pAllocationCallbacks); if (pFlac == NULL) { return NULL; } return ma_dr_flac__full_read_and_close_f32(pFlac, channels, sampleRate, totalPCMFrameCount); } MA_API void ma_dr_flac_free(void* p, const ma_allocation_callbacks* pAllocationCallbacks) { if (pAllocationCallbacks != NULL) { ma_dr_flac__free_from_callbacks(p, pAllocationCallbacks); } else { ma_dr_flac__free_default(p, NULL); } } MA_API void ma_dr_flac_init_vorbis_comment_iterator(ma_dr_flac_vorbis_comment_iterator* pIter, ma_uint32 commentCount, const void* pComments) { if (pIter == NULL) { return; } pIter->countRemaining = commentCount; pIter->pRunningData = (const char*)pComments; } MA_API const char* ma_dr_flac_next_vorbis_comment(ma_dr_flac_vorbis_comment_iterator* pIter, ma_uint32* pCommentLengthOut) { ma_int32 length; const char* pComment; if (pCommentLengthOut) { *pCommentLengthOut = 0; } if (pIter == NULL || pIter->countRemaining == 0 || pIter->pRunningData == NULL) { return NULL; } length = ma_dr_flac__le2host_32_ptr_unaligned(pIter->pRunningData); pIter->pRunningData += 4; pComment = pIter->pRunningData; pIter->pRunningData += length; pIter->countRemaining -= 1; if (pCommentLengthOut) { *pCommentLengthOut = length; } return pComment; } MA_API void ma_dr_flac_init_cuesheet_track_iterator(ma_dr_flac_cuesheet_track_iterator* pIter, ma_uint32 trackCount, const void* pTrackData) { if (pIter == NULL) { return; } pIter->countRemaining = trackCount; pIter->pRunningData = (const char*)pTrackData; } MA_API ma_bool32 ma_dr_flac_next_cuesheet_track(ma_dr_flac_cuesheet_track_iterator* pIter, ma_dr_flac_cuesheet_track* pCuesheetTrack) { ma_dr_flac_cuesheet_track cuesheetTrack; const char* pRunningData; ma_uint64 offsetHi; ma_uint64 offsetLo; if (pIter == NULL || pIter->countRemaining == 0 || pIter->pRunningData == NULL) { return MA_FALSE; } pRunningData = pIter->pRunningData; offsetHi = ma_dr_flac__be2host_32(*(const ma_uint32*)pRunningData); pRunningData += 4; offsetLo = ma_dr_flac__be2host_32(*(const ma_uint32*)pRunningData); pRunningData += 4; cuesheetTrack.offset = offsetLo | (offsetHi << 32); cuesheetTrack.trackNumber = pRunningData[0]; pRunningData += 1; MA_DR_FLAC_COPY_MEMORY(cuesheetTrack.ISRC, pRunningData, sizeof(cuesheetTrack.ISRC)); pRunningData += 12; cuesheetTrack.isAudio = (pRunningData[0] & 0x80) != 0; cuesheetTrack.preEmphasis = (pRunningData[0] & 0x40) != 0; pRunningData += 14; cuesheetTrack.indexCount = pRunningData[0]; pRunningData += 1; cuesheetTrack.pIndexPoints = (const ma_dr_flac_cuesheet_track_index*)pRunningData; pRunningData += cuesheetTrack.indexCount * sizeof(ma_dr_flac_cuesheet_track_index); pIter->pRunningData = pRunningData; pIter->countRemaining -= 1; if (pCuesheetTrack) { *pCuesheetTrack = cuesheetTrack; } return MA_TRUE; } #if defined(__clang__) || (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))) #pragma GCC diagnostic pop #endif #endif /* dr_flac_c end */ #endif /* MA_DR_FLAC_IMPLEMENTATION */ #endif /* MA_NO_FLAC */ #if !defined(MA_NO_MP3) && !defined(MA_NO_DECODING) #if !defined(MA_DR_MP3_IMPLEMENTATION) && !defined(MA_DR_MP3_IMPLEMENTATION) /* For backwards compatibility. Will be removed in version 0.11 for cleanliness. */ /* dr_mp3_c begin */ #ifndef ma_dr_mp3_c #define ma_dr_mp3_c #include #include #include MA_API void ma_dr_mp3_version(ma_uint32* pMajor, ma_uint32* pMinor, ma_uint32* pRevision) { if (pMajor) { *pMajor = MA_DR_MP3_VERSION_MAJOR; } if (pMinor) { *pMinor = MA_DR_MP3_VERSION_MINOR; } if (pRevision) { *pRevision = MA_DR_MP3_VERSION_REVISION; } } MA_API const char* ma_dr_mp3_version_string(void) { return MA_DR_MP3_VERSION_STRING; } #if defined(__TINYC__) #define MA_DR_MP3_NO_SIMD #endif #define MA_DR_MP3_OFFSET_PTR(p, offset) ((void*)((ma_uint8*)(p) + (offset))) #define MA_DR_MP3_MAX_FREE_FORMAT_FRAME_SIZE 2304 #ifndef MA_DR_MP3_MAX_FRAME_SYNC_MATCHES #define MA_DR_MP3_MAX_FRAME_SYNC_MATCHES 10 #endif #define MA_DR_MP3_MAX_L3_FRAME_PAYLOAD_BYTES MA_DR_MP3_MAX_FREE_FORMAT_FRAME_SIZE #define MA_DR_MP3_MAX_BITRESERVOIR_BYTES 511 #define MA_DR_MP3_SHORT_BLOCK_TYPE 2 #define MA_DR_MP3_STOP_BLOCK_TYPE 3 #define MA_DR_MP3_MODE_MONO 3 #define MA_DR_MP3_MODE_JOINT_STEREO 1 #define MA_DR_MP3_HDR_SIZE 4 #define MA_DR_MP3_HDR_IS_MONO(h) (((h[3]) & 0xC0) == 0xC0) #define MA_DR_MP3_HDR_IS_MS_STEREO(h) (((h[3]) & 0xE0) == 0x60) #define MA_DR_MP3_HDR_IS_FREE_FORMAT(h) (((h[2]) & 0xF0) == 0) #define MA_DR_MP3_HDR_IS_CRC(h) (!((h[1]) & 1)) #define MA_DR_MP3_HDR_TEST_PADDING(h) ((h[2]) & 0x2) #define MA_DR_MP3_HDR_TEST_MPEG1(h) ((h[1]) & 0x8) #define MA_DR_MP3_HDR_TEST_NOT_MPEG25(h) ((h[1]) & 0x10) #define MA_DR_MP3_HDR_TEST_I_STEREO(h) ((h[3]) & 0x10) #define MA_DR_MP3_HDR_TEST_MS_STEREO(h) ((h[3]) & 0x20) #define MA_DR_MP3_HDR_GET_STEREO_MODE(h) (((h[3]) >> 6) & 3) #define MA_DR_MP3_HDR_GET_STEREO_MODE_EXT(h) (((h[3]) >> 4) & 3) #define MA_DR_MP3_HDR_GET_LAYER(h) (((h[1]) >> 1) & 3) #define MA_DR_MP3_HDR_GET_BITRATE(h) ((h[2]) >> 4) #define MA_DR_MP3_HDR_GET_SAMPLE_RATE(h) (((h[2]) >> 2) & 3) #define MA_DR_MP3_HDR_GET_MY_SAMPLE_RATE(h) (MA_DR_MP3_HDR_GET_SAMPLE_RATE(h) + (((h[1] >> 3) & 1) + ((h[1] >> 4) & 1))*3) #define MA_DR_MP3_HDR_IS_FRAME_576(h) ((h[1] & 14) == 2) #define MA_DR_MP3_HDR_IS_LAYER_1(h) ((h[1] & 6) == 6) #define MA_DR_MP3_BITS_DEQUANTIZER_OUT -1 #define MA_DR_MP3_MAX_SCF (255 + MA_DR_MP3_BITS_DEQUANTIZER_OUT*4 - 210) #define MA_DR_MP3_MAX_SCFI ((MA_DR_MP3_MAX_SCF + 3) & ~3) #define MA_DR_MP3_MIN(a, b) ((a) > (b) ? (b) : (a)) #define MA_DR_MP3_MAX(a, b) ((a) < (b) ? (b) : (a)) #if !defined(MA_DR_MP3_NO_SIMD) #if !defined(MA_DR_MP3_ONLY_SIMD) && (defined(_M_X64) || defined(__x86_64__) || defined(__aarch64__) || defined(_M_ARM64)) #define MA_DR_MP3_ONLY_SIMD #endif #if ((defined(_MSC_VER) && _MSC_VER >= 1400) && defined(_M_X64)) || ((defined(__i386) || defined(_M_IX86) || defined(__i386__) || defined(__x86_64__)) && ((defined(_M_IX86_FP) && _M_IX86_FP == 2) || defined(__SSE2__))) #if defined(_MSC_VER) #include #endif #include #define MA_DR_MP3_HAVE_SSE 1 #define MA_DR_MP3_HAVE_SIMD 1 #define MA_DR_MP3_VSTORE _mm_storeu_ps #define MA_DR_MP3_VLD _mm_loadu_ps #define MA_DR_MP3_VSET _mm_set1_ps #define MA_DR_MP3_VADD _mm_add_ps #define MA_DR_MP3_VSUB _mm_sub_ps #define MA_DR_MP3_VMUL _mm_mul_ps #define MA_DR_MP3_VMAC(a, x, y) _mm_add_ps(a, _mm_mul_ps(x, y)) #define MA_DR_MP3_VMSB(a, x, y) _mm_sub_ps(a, _mm_mul_ps(x, y)) #define MA_DR_MP3_VMUL_S(x, s) _mm_mul_ps(x, _mm_set1_ps(s)) #define MA_DR_MP3_VREV(x) _mm_shuffle_ps(x, x, _MM_SHUFFLE(0, 1, 2, 3)) typedef __m128 ma_dr_mp3_f4; #if defined(_MSC_VER) || defined(MA_DR_MP3_ONLY_SIMD) #define ma_dr_mp3_cpuid __cpuid #else static __inline__ __attribute__((always_inline)) void ma_dr_mp3_cpuid(int CPUInfo[], const int InfoType) { #if defined(__PIC__) __asm__ __volatile__( #if defined(__x86_64__) "push %%rbx\n" "cpuid\n" "xchgl %%ebx, %1\n" "pop %%rbx\n" #else "xchgl %%ebx, %1\n" "cpuid\n" "xchgl %%ebx, %1\n" #endif : "=a" (CPUInfo[0]), "=r" (CPUInfo[1]), "=c" (CPUInfo[2]), "=d" (CPUInfo[3]) : "a" (InfoType)); #else __asm__ __volatile__( "cpuid" : "=a" (CPUInfo[0]), "=b" (CPUInfo[1]), "=c" (CPUInfo[2]), "=d" (CPUInfo[3]) : "a" (InfoType)); #endif } #endif static int ma_dr_mp3_have_simd(void) { #ifdef MA_DR_MP3_ONLY_SIMD return 1; #else static int g_have_simd; int CPUInfo[4]; #ifdef MINIMP3_TEST static int g_counter; if (g_counter++ > 100) return 0; #endif if (g_have_simd) goto end; ma_dr_mp3_cpuid(CPUInfo, 0); if (CPUInfo[0] > 0) { ma_dr_mp3_cpuid(CPUInfo, 1); g_have_simd = (CPUInfo[3] & (1 << 26)) + 1; return g_have_simd - 1; } end: return g_have_simd - 1; #endif } #elif defined(__ARM_NEON) || defined(__aarch64__) || defined(_M_ARM64) #include #define MA_DR_MP3_HAVE_SSE 0 #define MA_DR_MP3_HAVE_SIMD 1 #define MA_DR_MP3_VSTORE vst1q_f32 #define MA_DR_MP3_VLD vld1q_f32 #define MA_DR_MP3_VSET vmovq_n_f32 #define MA_DR_MP3_VADD vaddq_f32 #define MA_DR_MP3_VSUB vsubq_f32 #define MA_DR_MP3_VMUL vmulq_f32 #define MA_DR_MP3_VMAC(a, x, y) vmlaq_f32(a, x, y) #define MA_DR_MP3_VMSB(a, x, y) vmlsq_f32(a, x, y) #define MA_DR_MP3_VMUL_S(x, s) vmulq_f32(x, vmovq_n_f32(s)) #define MA_DR_MP3_VREV(x) vcombine_f32(vget_high_f32(vrev64q_f32(x)), vget_low_f32(vrev64q_f32(x))) typedef float32x4_t ma_dr_mp3_f4; static int ma_dr_mp3_have_simd(void) { return 1; } #else #define MA_DR_MP3_HAVE_SSE 0 #define MA_DR_MP3_HAVE_SIMD 0 #ifdef MA_DR_MP3_ONLY_SIMD #error MA_DR_MP3_ONLY_SIMD used, but SSE/NEON not enabled #endif #endif #else #define MA_DR_MP3_HAVE_SIMD 0 #endif #if defined(__ARM_ARCH) && (__ARM_ARCH >= 6) && !defined(__aarch64__) && !defined(_M_ARM64) && !defined(__ARM_ARCH_6M__) #define MA_DR_MP3_HAVE_ARMV6 1 static __inline__ __attribute__((always_inline)) ma_int32 ma_dr_mp3_clip_int16_arm(ma_int32 a) { ma_int32 x = 0; __asm__ ("ssat %0, #16, %1" : "=r"(x) : "r"(a)); return x; } #else #define MA_DR_MP3_HAVE_ARMV6 0 #endif #ifndef MA_DR_MP3_ASSERT #include #define MA_DR_MP3_ASSERT(expression) assert(expression) #endif #ifndef MA_DR_MP3_COPY_MEMORY #define MA_DR_MP3_COPY_MEMORY(dst, src, sz) memcpy((dst), (src), (sz)) #endif #ifndef MA_DR_MP3_MOVE_MEMORY #define MA_DR_MP3_MOVE_MEMORY(dst, src, sz) memmove((dst), (src), (sz)) #endif #ifndef MA_DR_MP3_ZERO_MEMORY #define MA_DR_MP3_ZERO_MEMORY(p, sz) memset((p), 0, (sz)) #endif #define MA_DR_MP3_ZERO_OBJECT(p) MA_DR_MP3_ZERO_MEMORY((p), sizeof(*(p))) #ifndef MA_DR_MP3_MALLOC #define MA_DR_MP3_MALLOC(sz) malloc((sz)) #endif #ifndef MA_DR_MP3_REALLOC #define MA_DR_MP3_REALLOC(p, sz) realloc((p), (sz)) #endif #ifndef MA_DR_MP3_FREE #define MA_DR_MP3_FREE(p) free((p)) #endif typedef struct { const ma_uint8 *buf; int pos, limit; } ma_dr_mp3_bs; typedef struct { float scf[3*64]; ma_uint8 total_bands, stereo_bands, bitalloc[64], scfcod[64]; } ma_dr_mp3_L12_scale_info; typedef struct { ma_uint8 tab_offset, code_tab_width, band_count; } ma_dr_mp3_L12_subband_alloc; typedef struct { const ma_uint8 *sfbtab; ma_uint16 part_23_length, big_values, scalefac_compress; ma_uint8 global_gain, block_type, mixed_block_flag, n_long_sfb, n_short_sfb; ma_uint8 table_select[3], region_count[3], subblock_gain[3]; ma_uint8 preflag, scalefac_scale, count1_table, scfsi; } ma_dr_mp3_L3_gr_info; typedef struct { ma_dr_mp3_bs bs; ma_uint8 maindata[MA_DR_MP3_MAX_BITRESERVOIR_BYTES + MA_DR_MP3_MAX_L3_FRAME_PAYLOAD_BYTES]; ma_dr_mp3_L3_gr_info gr_info[4]; float grbuf[2][576], scf[40], syn[18 + 15][2*32]; ma_uint8 ist_pos[2][39]; } ma_dr_mp3dec_scratch; static void ma_dr_mp3_bs_init(ma_dr_mp3_bs *bs, const ma_uint8 *data, int bytes) { bs->buf = data; bs->pos = 0; bs->limit = bytes*8; } static ma_uint32 ma_dr_mp3_bs_get_bits(ma_dr_mp3_bs *bs, int n) { ma_uint32 next, cache = 0, s = bs->pos & 7; int shl = n + s; const ma_uint8 *p = bs->buf + (bs->pos >> 3); if ((bs->pos += n) > bs->limit) return 0; next = *p++ & (255 >> s); while ((shl -= 8) > 0) { cache |= next << shl; next = *p++; } return cache | (next >> -shl); } static int ma_dr_mp3_hdr_valid(const ma_uint8 *h) { return h[0] == 0xff && ((h[1] & 0xF0) == 0xf0 || (h[1] & 0xFE) == 0xe2) && (MA_DR_MP3_HDR_GET_LAYER(h) != 0) && (MA_DR_MP3_HDR_GET_BITRATE(h) != 15) && (MA_DR_MP3_HDR_GET_SAMPLE_RATE(h) != 3); } static int ma_dr_mp3_hdr_compare(const ma_uint8 *h1, const ma_uint8 *h2) { return ma_dr_mp3_hdr_valid(h2) && ((h1[1] ^ h2[1]) & 0xFE) == 0 && ((h1[2] ^ h2[2]) & 0x0C) == 0 && !(MA_DR_MP3_HDR_IS_FREE_FORMAT(h1) ^ MA_DR_MP3_HDR_IS_FREE_FORMAT(h2)); } static unsigned ma_dr_mp3_hdr_bitrate_kbps(const ma_uint8 *h) { static const ma_uint8 halfrate[2][3][15] = { { { 0,4,8,12,16,20,24,28,32,40,48,56,64,72,80 }, { 0,4,8,12,16,20,24,28,32,40,48,56,64,72,80 }, { 0,16,24,28,32,40,48,56,64,72,80,88,96,112,128 } }, { { 0,16,20,24,28,32,40,48,56,64,80,96,112,128,160 }, { 0,16,24,28,32,40,48,56,64,80,96,112,128,160,192 }, { 0,16,32,48,64,80,96,112,128,144,160,176,192,208,224 } }, }; return 2*halfrate[!!MA_DR_MP3_HDR_TEST_MPEG1(h)][MA_DR_MP3_HDR_GET_LAYER(h) - 1][MA_DR_MP3_HDR_GET_BITRATE(h)]; } static unsigned ma_dr_mp3_hdr_sample_rate_hz(const ma_uint8 *h) { static const unsigned g_hz[3] = { 44100, 48000, 32000 }; return g_hz[MA_DR_MP3_HDR_GET_SAMPLE_RATE(h)] >> (int)!MA_DR_MP3_HDR_TEST_MPEG1(h) >> (int)!MA_DR_MP3_HDR_TEST_NOT_MPEG25(h); } static unsigned ma_dr_mp3_hdr_frame_samples(const ma_uint8 *h) { return MA_DR_MP3_HDR_IS_LAYER_1(h) ? 384 : (1152 >> (int)MA_DR_MP3_HDR_IS_FRAME_576(h)); } static int ma_dr_mp3_hdr_frame_bytes(const ma_uint8 *h, int free_format_size) { int frame_bytes = ma_dr_mp3_hdr_frame_samples(h)*ma_dr_mp3_hdr_bitrate_kbps(h)*125/ma_dr_mp3_hdr_sample_rate_hz(h); if (MA_DR_MP3_HDR_IS_LAYER_1(h)) { frame_bytes &= ~3; } return frame_bytes ? frame_bytes : free_format_size; } static int ma_dr_mp3_hdr_padding(const ma_uint8 *h) { return MA_DR_MP3_HDR_TEST_PADDING(h) ? (MA_DR_MP3_HDR_IS_LAYER_1(h) ? 4 : 1) : 0; } #ifndef MA_DR_MP3_ONLY_MP3 static const ma_dr_mp3_L12_subband_alloc *ma_dr_mp3_L12_subband_alloc_table(const ma_uint8 *hdr, ma_dr_mp3_L12_scale_info *sci) { const ma_dr_mp3_L12_subband_alloc *alloc; int mode = MA_DR_MP3_HDR_GET_STEREO_MODE(hdr); int nbands, stereo_bands = (mode == MA_DR_MP3_MODE_MONO) ? 0 : (mode == MA_DR_MP3_MODE_JOINT_STEREO) ? (MA_DR_MP3_HDR_GET_STEREO_MODE_EXT(hdr) << 2) + 4 : 32; if (MA_DR_MP3_HDR_IS_LAYER_1(hdr)) { static const ma_dr_mp3_L12_subband_alloc g_alloc_L1[] = { { 76, 4, 32 } }; alloc = g_alloc_L1; nbands = 32; } else if (!MA_DR_MP3_HDR_TEST_MPEG1(hdr)) { static const ma_dr_mp3_L12_subband_alloc g_alloc_L2M2[] = { { 60, 4, 4 }, { 44, 3, 7 }, { 44, 2, 19 } }; alloc = g_alloc_L2M2; nbands = 30; } else { static const ma_dr_mp3_L12_subband_alloc g_alloc_L2M1[] = { { 0, 4, 3 }, { 16, 4, 8 }, { 32, 3, 12 }, { 40, 2, 7 } }; int sample_rate_idx = MA_DR_MP3_HDR_GET_SAMPLE_RATE(hdr); unsigned kbps = ma_dr_mp3_hdr_bitrate_kbps(hdr) >> (int)(mode != MA_DR_MP3_MODE_MONO); if (!kbps) { kbps = 192; } alloc = g_alloc_L2M1; nbands = 27; if (kbps < 56) { static const ma_dr_mp3_L12_subband_alloc g_alloc_L2M1_lowrate[] = { { 44, 4, 2 }, { 44, 3, 10 } }; alloc = g_alloc_L2M1_lowrate; nbands = sample_rate_idx == 2 ? 12 : 8; } else if (kbps >= 96 && sample_rate_idx != 1) { nbands = 30; } } sci->total_bands = (ma_uint8)nbands; sci->stereo_bands = (ma_uint8)MA_DR_MP3_MIN(stereo_bands, nbands); return alloc; } static void ma_dr_mp3_L12_read_scalefactors(ma_dr_mp3_bs *bs, ma_uint8 *pba, ma_uint8 *scfcod, int bands, float *scf) { static const float g_deq_L12[18*3] = { #define MA_DR_MP3_DQ(x) 9.53674316e-07f/x, 7.56931807e-07f/x, 6.00777173e-07f/x MA_DR_MP3_DQ(3),MA_DR_MP3_DQ(7),MA_DR_MP3_DQ(15),MA_DR_MP3_DQ(31),MA_DR_MP3_DQ(63),MA_DR_MP3_DQ(127),MA_DR_MP3_DQ(255),MA_DR_MP3_DQ(511),MA_DR_MP3_DQ(1023),MA_DR_MP3_DQ(2047),MA_DR_MP3_DQ(4095),MA_DR_MP3_DQ(8191),MA_DR_MP3_DQ(16383),MA_DR_MP3_DQ(32767),MA_DR_MP3_DQ(65535),MA_DR_MP3_DQ(3),MA_DR_MP3_DQ(5),MA_DR_MP3_DQ(9) }; int i, m; for (i = 0; i < bands; i++) { float s = 0; int ba = *pba++; int mask = ba ? 4 + ((19 >> scfcod[i]) & 3) : 0; for (m = 4; m; m >>= 1) { if (mask & m) { int b = ma_dr_mp3_bs_get_bits(bs, 6); s = g_deq_L12[ba*3 - 6 + b % 3]*(int)(1 << 21 >> b/3); } *scf++ = s; } } } static void ma_dr_mp3_L12_read_scale_info(const ma_uint8 *hdr, ma_dr_mp3_bs *bs, ma_dr_mp3_L12_scale_info *sci) { static const ma_uint8 g_bitalloc_code_tab[] = { 0,17, 3, 4, 5,6,7, 8,9,10,11,12,13,14,15,16, 0,17,18, 3,19,4,5, 6,7, 8, 9,10,11,12,13,16, 0,17,18, 3,19,4,5,16, 0,17,18,16, 0,17,18,19, 4,5,6, 7,8, 9,10,11,12,13,14,15, 0,17,18, 3,19,4,5, 6,7, 8, 9,10,11,12,13,14, 0, 2, 3, 4, 5,6,7, 8,9,10,11,12,13,14,15,16 }; const ma_dr_mp3_L12_subband_alloc *subband_alloc = ma_dr_mp3_L12_subband_alloc_table(hdr, sci); int i, k = 0, ba_bits = 0; const ma_uint8 *ba_code_tab = g_bitalloc_code_tab; for (i = 0; i < sci->total_bands; i++) { ma_uint8 ba; if (i == k) { k += subband_alloc->band_count; ba_bits = subband_alloc->code_tab_width; ba_code_tab = g_bitalloc_code_tab + subband_alloc->tab_offset; subband_alloc++; } ba = ba_code_tab[ma_dr_mp3_bs_get_bits(bs, ba_bits)]; sci->bitalloc[2*i] = ba; if (i < sci->stereo_bands) { ba = ba_code_tab[ma_dr_mp3_bs_get_bits(bs, ba_bits)]; } sci->bitalloc[2*i + 1] = sci->stereo_bands ? ba : 0; } for (i = 0; i < 2*sci->total_bands; i++) { sci->scfcod[i] = (ma_uint8)(sci->bitalloc[i] ? MA_DR_MP3_HDR_IS_LAYER_1(hdr) ? 2 : ma_dr_mp3_bs_get_bits(bs, 2) : 6); } ma_dr_mp3_L12_read_scalefactors(bs, sci->bitalloc, sci->scfcod, sci->total_bands*2, sci->scf); for (i = sci->stereo_bands; i < sci->total_bands; i++) { sci->bitalloc[2*i + 1] = 0; } } static int ma_dr_mp3_L12_dequantize_granule(float *grbuf, ma_dr_mp3_bs *bs, ma_dr_mp3_L12_scale_info *sci, int group_size) { int i, j, k, choff = 576; for (j = 0; j < 4; j++) { float *dst = grbuf + group_size*j; for (i = 0; i < 2*sci->total_bands; i++) { int ba = sci->bitalloc[i]; if (ba != 0) { if (ba < 17) { int half = (1 << (ba - 1)) - 1; for (k = 0; k < group_size; k++) { dst[k] = (float)((int)ma_dr_mp3_bs_get_bits(bs, ba) - half); } } else { unsigned mod = (2 << (ba - 17)) + 1; unsigned code = ma_dr_mp3_bs_get_bits(bs, mod + 2 - (mod >> 3)); for (k = 0; k < group_size; k++, code /= mod) { dst[k] = (float)((int)(code % mod - mod/2)); } } } dst += choff; choff = 18 - choff; } } return group_size*4; } static void ma_dr_mp3_L12_apply_scf_384(ma_dr_mp3_L12_scale_info *sci, const float *scf, float *dst) { int i, k; MA_DR_MP3_COPY_MEMORY(dst + 576 + sci->stereo_bands*18, dst + sci->stereo_bands*18, (sci->total_bands - sci->stereo_bands)*18*sizeof(float)); for (i = 0; i < sci->total_bands; i++, dst += 18, scf += 6) { for (k = 0; k < 12; k++) { dst[k + 0] *= scf[0]; dst[k + 576] *= scf[3]; } } } #endif static int ma_dr_mp3_L3_read_side_info(ma_dr_mp3_bs *bs, ma_dr_mp3_L3_gr_info *gr, const ma_uint8 *hdr) { static const ma_uint8 g_scf_long[8][23] = { { 6,6,6,6,6,6,8,10,12,14,16,20,24,28,32,38,46,52,60,68,58,54,0 }, { 12,12,12,12,12,12,16,20,24,28,32,40,48,56,64,76,90,2,2,2,2,2,0 }, { 6,6,6,6,6,6,8,10,12,14,16,20,24,28,32,38,46,52,60,68,58,54,0 }, { 6,6,6,6,6,6,8,10,12,14,16,18,22,26,32,38,46,54,62,70,76,36,0 }, { 6,6,6,6,6,6,8,10,12,14,16,20,24,28,32,38,46,52,60,68,58,54,0 }, { 4,4,4,4,4,4,6,6,8,8,10,12,16,20,24,28,34,42,50,54,76,158,0 }, { 4,4,4,4,4,4,6,6,6,8,10,12,16,18,22,28,34,40,46,54,54,192,0 }, { 4,4,4,4,4,4,6,6,8,10,12,16,20,24,30,38,46,56,68,84,102,26,0 } }; static const ma_uint8 g_scf_short[8][40] = { { 4,4,4,4,4,4,4,4,4,6,6,6,8,8,8,10,10,10,12,12,12,14,14,14,18,18,18,24,24,24,30,30,30,40,40,40,18,18,18,0 }, { 8,8,8,8,8,8,8,8,8,12,12,12,16,16,16,20,20,20,24,24,24,28,28,28,36,36,36,2,2,2,2,2,2,2,2,2,26,26,26,0 }, { 4,4,4,4,4,4,4,4,4,6,6,6,6,6,6,8,8,8,10,10,10,14,14,14,18,18,18,26,26,26,32,32,32,42,42,42,18,18,18,0 }, { 4,4,4,4,4,4,4,4,4,6,6,6,8,8,8,10,10,10,12,12,12,14,14,14,18,18,18,24,24,24,32,32,32,44,44,44,12,12,12,0 }, { 4,4,4,4,4,4,4,4,4,6,6,6,8,8,8,10,10,10,12,12,12,14,14,14,18,18,18,24,24,24,30,30,30,40,40,40,18,18,18,0 }, { 4,4,4,4,4,4,4,4,4,4,4,4,6,6,6,8,8,8,10,10,10,12,12,12,14,14,14,18,18,18,22,22,22,30,30,30,56,56,56,0 }, { 4,4,4,4,4,4,4,4,4,4,4,4,6,6,6,6,6,6,10,10,10,12,12,12,14,14,14,16,16,16,20,20,20,26,26,26,66,66,66,0 }, { 4,4,4,4,4,4,4,4,4,4,4,4,6,6,6,8,8,8,12,12,12,16,16,16,20,20,20,26,26,26,34,34,34,42,42,42,12,12,12,0 } }; static const ma_uint8 g_scf_mixed[8][40] = { { 6,6,6,6,6,6,6,6,6,8,8,8,10,10,10,12,12,12,14,14,14,18,18,18,24,24,24,30,30,30,40,40,40,18,18,18,0 }, { 12,12,12,4,4,4,8,8,8,12,12,12,16,16,16,20,20,20,24,24,24,28,28,28,36,36,36,2,2,2,2,2,2,2,2,2,26,26,26,0 }, { 6,6,6,6,6,6,6,6,6,6,6,6,8,8,8,10,10,10,14,14,14,18,18,18,26,26,26,32,32,32,42,42,42,18,18,18,0 }, { 6,6,6,6,6,6,6,6,6,8,8,8,10,10,10,12,12,12,14,14,14,18,18,18,24,24,24,32,32,32,44,44,44,12,12,12,0 }, { 6,6,6,6,6,6,6,6,6,8,8,8,10,10,10,12,12,12,14,14,14,18,18,18,24,24,24,30,30,30,40,40,40,18,18,18,0 }, { 4,4,4,4,4,4,6,6,4,4,4,6,6,6,8,8,8,10,10,10,12,12,12,14,14,14,18,18,18,22,22,22,30,30,30,56,56,56,0 }, { 4,4,4,4,4,4,6,6,4,4,4,6,6,6,6,6,6,10,10,10,12,12,12,14,14,14,16,16,16,20,20,20,26,26,26,66,66,66,0 }, { 4,4,4,4,4,4,6,6,4,4,4,6,6,6,8,8,8,12,12,12,16,16,16,20,20,20,26,26,26,34,34,34,42,42,42,12,12,12,0 } }; unsigned tables, scfsi = 0; int main_data_begin, part_23_sum = 0; int gr_count = MA_DR_MP3_HDR_IS_MONO(hdr) ? 1 : 2; int sr_idx = MA_DR_MP3_HDR_GET_MY_SAMPLE_RATE(hdr); sr_idx -= (sr_idx != 0); if (MA_DR_MP3_HDR_TEST_MPEG1(hdr)) { gr_count *= 2; main_data_begin = ma_dr_mp3_bs_get_bits(bs, 9); scfsi = ma_dr_mp3_bs_get_bits(bs, 7 + gr_count); } else { main_data_begin = ma_dr_mp3_bs_get_bits(bs, 8 + gr_count) >> gr_count; } do { if (MA_DR_MP3_HDR_IS_MONO(hdr)) { scfsi <<= 4; } gr->part_23_length = (ma_uint16)ma_dr_mp3_bs_get_bits(bs, 12); part_23_sum += gr->part_23_length; gr->big_values = (ma_uint16)ma_dr_mp3_bs_get_bits(bs, 9); if (gr->big_values > 288) { return -1; } gr->global_gain = (ma_uint8)ma_dr_mp3_bs_get_bits(bs, 8); gr->scalefac_compress = (ma_uint16)ma_dr_mp3_bs_get_bits(bs, MA_DR_MP3_HDR_TEST_MPEG1(hdr) ? 4 : 9); gr->sfbtab = g_scf_long[sr_idx]; gr->n_long_sfb = 22; gr->n_short_sfb = 0; if (ma_dr_mp3_bs_get_bits(bs, 1)) { gr->block_type = (ma_uint8)ma_dr_mp3_bs_get_bits(bs, 2); if (!gr->block_type) { return -1; } gr->mixed_block_flag = (ma_uint8)ma_dr_mp3_bs_get_bits(bs, 1); gr->region_count[0] = 7; gr->region_count[1] = 255; if (gr->block_type == MA_DR_MP3_SHORT_BLOCK_TYPE) { scfsi &= 0x0F0F; if (!gr->mixed_block_flag) { gr->region_count[0] = 8; gr->sfbtab = g_scf_short[sr_idx]; gr->n_long_sfb = 0; gr->n_short_sfb = 39; } else { gr->sfbtab = g_scf_mixed[sr_idx]; gr->n_long_sfb = MA_DR_MP3_HDR_TEST_MPEG1(hdr) ? 8 : 6; gr->n_short_sfb = 30; } } tables = ma_dr_mp3_bs_get_bits(bs, 10); tables <<= 5; gr->subblock_gain[0] = (ma_uint8)ma_dr_mp3_bs_get_bits(bs, 3); gr->subblock_gain[1] = (ma_uint8)ma_dr_mp3_bs_get_bits(bs, 3); gr->subblock_gain[2] = (ma_uint8)ma_dr_mp3_bs_get_bits(bs, 3); } else { gr->block_type = 0; gr->mixed_block_flag = 0; tables = ma_dr_mp3_bs_get_bits(bs, 15); gr->region_count[0] = (ma_uint8)ma_dr_mp3_bs_get_bits(bs, 4); gr->region_count[1] = (ma_uint8)ma_dr_mp3_bs_get_bits(bs, 3); gr->region_count[2] = 255; } gr->table_select[0] = (ma_uint8)(tables >> 10); gr->table_select[1] = (ma_uint8)((tables >> 5) & 31); gr->table_select[2] = (ma_uint8)((tables) & 31); gr->preflag = (ma_uint8)(MA_DR_MP3_HDR_TEST_MPEG1(hdr) ? ma_dr_mp3_bs_get_bits(bs, 1) : (gr->scalefac_compress >= 500)); gr->scalefac_scale = (ma_uint8)ma_dr_mp3_bs_get_bits(bs, 1); gr->count1_table = (ma_uint8)ma_dr_mp3_bs_get_bits(bs, 1); gr->scfsi = (ma_uint8)((scfsi >> 12) & 15); scfsi <<= 4; gr++; } while(--gr_count); if (part_23_sum + bs->pos > bs->limit + main_data_begin*8) { return -1; } return main_data_begin; } static void ma_dr_mp3_L3_read_scalefactors(ma_uint8 *scf, ma_uint8 *ist_pos, const ma_uint8 *scf_size, const ma_uint8 *scf_count, ma_dr_mp3_bs *bitbuf, int scfsi) { int i, k; for (i = 0; i < 4 && scf_count[i]; i++, scfsi *= 2) { int cnt = scf_count[i]; if (scfsi & 8) { MA_DR_MP3_COPY_MEMORY(scf, ist_pos, cnt); } else { int bits = scf_size[i]; if (!bits) { MA_DR_MP3_ZERO_MEMORY(scf, cnt); MA_DR_MP3_ZERO_MEMORY(ist_pos, cnt); } else { int max_scf = (scfsi < 0) ? (1 << bits) - 1 : -1; for (k = 0; k < cnt; k++) { int s = ma_dr_mp3_bs_get_bits(bitbuf, bits); ist_pos[k] = (ma_uint8)(s == max_scf ? -1 : s); scf[k] = (ma_uint8)s; } } } ist_pos += cnt; scf += cnt; } scf[0] = scf[1] = scf[2] = 0; } static float ma_dr_mp3_L3_ldexp_q2(float y, int exp_q2) { static const float g_expfrac[4] = { 9.31322575e-10f,7.83145814e-10f,6.58544508e-10f,5.53767716e-10f }; int e; do { e = MA_DR_MP3_MIN(30*4, exp_q2); y *= g_expfrac[e & 3]*(1 << 30 >> (e >> 2)); } while ((exp_q2 -= e) > 0); return y; } static void ma_dr_mp3_L3_decode_scalefactors(const ma_uint8 *hdr, ma_uint8 *ist_pos, ma_dr_mp3_bs *bs, const ma_dr_mp3_L3_gr_info *gr, float *scf, int ch) { static const ma_uint8 g_scf_partitions[3][28] = { { 6,5,5, 5,6,5,5,5,6,5, 7,3,11,10,0,0, 7, 7, 7,0, 6, 6,6,3, 8, 8,5,0 }, { 8,9,6,12,6,9,9,9,6,9,12,6,15,18,0,0, 6,15,12,0, 6,12,9,6, 6,18,9,0 }, { 9,9,6,12,9,9,9,9,9,9,12,6,18,18,0,0,12,12,12,0,12, 9,9,6,15,12,9,0 } }; const ma_uint8 *scf_partition = g_scf_partitions[!!gr->n_short_sfb + !gr->n_long_sfb]; ma_uint8 scf_size[4], iscf[40]; int i, scf_shift = gr->scalefac_scale + 1, gain_exp, scfsi = gr->scfsi; float gain; if (MA_DR_MP3_HDR_TEST_MPEG1(hdr)) { static const ma_uint8 g_scfc_decode[16] = { 0,1,2,3, 12,5,6,7, 9,10,11,13, 14,15,18,19 }; int part = g_scfc_decode[gr->scalefac_compress]; scf_size[1] = scf_size[0] = (ma_uint8)(part >> 2); scf_size[3] = scf_size[2] = (ma_uint8)(part & 3); } else { static const ma_uint8 g_mod[6*4] = { 5,5,4,4,5,5,4,1,4,3,1,1,5,6,6,1,4,4,4,1,4,3,1,1 }; int k, modprod, sfc, ist = MA_DR_MP3_HDR_TEST_I_STEREO(hdr) && ch; sfc = gr->scalefac_compress >> ist; for (k = ist*3*4; sfc >= 0; sfc -= modprod, k += 4) { for (modprod = 1, i = 3; i >= 0; i--) { scf_size[i] = (ma_uint8)(sfc / modprod % g_mod[k + i]); modprod *= g_mod[k + i]; } } scf_partition += k; scfsi = -16; } ma_dr_mp3_L3_read_scalefactors(iscf, ist_pos, scf_size, scf_partition, bs, scfsi); if (gr->n_short_sfb) { int sh = 3 - scf_shift; for (i = 0; i < gr->n_short_sfb; i += 3) { iscf[gr->n_long_sfb + i + 0] = (ma_uint8)(iscf[gr->n_long_sfb + i + 0] + (gr->subblock_gain[0] << sh)); iscf[gr->n_long_sfb + i + 1] = (ma_uint8)(iscf[gr->n_long_sfb + i + 1] + (gr->subblock_gain[1] << sh)); iscf[gr->n_long_sfb + i + 2] = (ma_uint8)(iscf[gr->n_long_sfb + i + 2] + (gr->subblock_gain[2] << sh)); } } else if (gr->preflag) { static const ma_uint8 g_preamp[10] = { 1,1,1,1,2,2,3,3,3,2 }; for (i = 0; i < 10; i++) { iscf[11 + i] = (ma_uint8)(iscf[11 + i] + g_preamp[i]); } } gain_exp = gr->global_gain + MA_DR_MP3_BITS_DEQUANTIZER_OUT*4 - 210 - (MA_DR_MP3_HDR_IS_MS_STEREO(hdr) ? 2 : 0); gain = ma_dr_mp3_L3_ldexp_q2(1 << (MA_DR_MP3_MAX_SCFI/4), MA_DR_MP3_MAX_SCFI - gain_exp); for (i = 0; i < (int)(gr->n_long_sfb + gr->n_short_sfb); i++) { scf[i] = ma_dr_mp3_L3_ldexp_q2(gain, iscf[i] << scf_shift); } } static const float g_ma_dr_mp3_pow43[129 + 16] = { 0,-1,-2.519842f,-4.326749f,-6.349604f,-8.549880f,-10.902724f,-13.390518f,-16.000000f,-18.720754f,-21.544347f,-24.463781f,-27.473142f,-30.567351f,-33.741992f,-36.993181f, 0,1,2.519842f,4.326749f,6.349604f,8.549880f,10.902724f,13.390518f,16.000000f,18.720754f,21.544347f,24.463781f,27.473142f,30.567351f,33.741992f,36.993181f,40.317474f,43.711787f,47.173345f,50.699631f,54.288352f,57.937408f,61.644865f,65.408941f,69.227979f,73.100443f,77.024898f,81.000000f,85.024491f,89.097188f,93.216975f,97.382800f,101.593667f,105.848633f,110.146801f,114.487321f,118.869381f,123.292209f,127.755065f,132.257246f,136.798076f,141.376907f,145.993119f,150.646117f,155.335327f,160.060199f,164.820202f,169.614826f,174.443577f,179.305980f,184.201575f,189.129918f,194.090580f,199.083145f,204.107210f,209.162385f,214.248292f,219.364564f,224.510845f,229.686789f,234.892058f,240.126328f,245.389280f,250.680604f,256.000000f,261.347174f,266.721841f,272.123723f,277.552547f,283.008049f,288.489971f,293.998060f,299.532071f,305.091761f,310.676898f,316.287249f,321.922592f,327.582707f,333.267377f,338.976394f,344.709550f,350.466646f,356.247482f,362.051866f,367.879608f,373.730522f,379.604427f,385.501143f,391.420496f,397.362314f,403.326427f,409.312672f,415.320884f,421.350905f,427.402579f,433.475750f,439.570269f,445.685987f,451.822757f,457.980436f,464.158883f,470.357960f,476.577530f,482.817459f,489.077615f,495.357868f,501.658090f,507.978156f,514.317941f,520.677324f,527.056184f,533.454404f,539.871867f,546.308458f,552.764065f,559.238575f,565.731879f,572.243870f,578.774440f,585.323483f,591.890898f,598.476581f,605.080431f,611.702349f,618.342238f,625.000000f,631.675540f,638.368763f,645.079578f }; static float ma_dr_mp3_L3_pow_43(int x) { float frac; int sign, mult = 256; if (x < 129) { return g_ma_dr_mp3_pow43[16 + x]; } if (x < 1024) { mult = 16; x <<= 3; } sign = 2*x & 64; frac = (float)((x & 63) - sign) / ((x & ~63) + sign); return g_ma_dr_mp3_pow43[16 + ((x + sign) >> 6)]*(1.f + frac*((4.f/3) + frac*(2.f/9)))*mult; } static void ma_dr_mp3_L3_huffman(float *dst, ma_dr_mp3_bs *bs, const ma_dr_mp3_L3_gr_info *gr_info, const float *scf, int layer3gr_limit) { static const ma_int16 tabs[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 785,785,785,785,784,784,784,784,513,513,513,513,513,513,513,513,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256, -255,1313,1298,1282,785,785,785,785,784,784,784,784,769,769,769,769,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,290,288, -255,1313,1298,1282,769,769,769,769,529,529,529,529,529,529,529,529,528,528,528,528,528,528,528,528,512,512,512,512,512,512,512,512,290,288, -253,-318,-351,-367,785,785,785,785,784,784,784,784,769,769,769,769,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,819,818,547,547,275,275,275,275,561,560,515,546,289,274,288,258, -254,-287,1329,1299,1314,1312,1057,1057,1042,1042,1026,1026,784,784,784,784,529,529,529,529,529,529,529,529,769,769,769,769,768,768,768,768,563,560,306,306,291,259, -252,-413,-477,-542,1298,-575,1041,1041,784,784,784,784,769,769,769,769,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,-383,-399,1107,1092,1106,1061,849,849,789,789,1104,1091,773,773,1076,1075,341,340,325,309,834,804,577,577,532,532,516,516,832,818,803,816,561,561,531,531,515,546,289,289,288,258, -252,-429,-493,-559,1057,1057,1042,1042,529,529,529,529,529,529,529,529,784,784,784,784,769,769,769,769,512,512,512,512,512,512,512,512,-382,1077,-415,1106,1061,1104,849,849,789,789,1091,1076,1029,1075,834,834,597,581,340,340,339,324,804,833,532,532,832,772,818,803,817,787,816,771,290,290,290,290,288,258, -253,-349,-414,-447,-463,1329,1299,-479,1314,1312,1057,1057,1042,1042,1026,1026,785,785,785,785,784,784,784,784,769,769,769,769,768,768,768,768,-319,851,821,-335,836,850,805,849,341,340,325,336,533,533,579,579,564,564,773,832,578,548,563,516,321,276,306,291,304,259, -251,-572,-733,-830,-863,-879,1041,1041,784,784,784,784,769,769,769,769,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,-511,-527,-543,1396,1351,1381,1366,1395,1335,1380,-559,1334,1138,1138,1063,1063,1350,1392,1031,1031,1062,1062,1364,1363,1120,1120,1333,1348,881,881,881,881,375,374,359,373,343,358,341,325,791,791,1123,1122,-703,1105,1045,-719,865,865,790,790,774,774,1104,1029,338,293,323,308,-799,-815,833,788,772,818,803,816,322,292,307,320,561,531,515,546,289,274,288,258, -251,-525,-605,-685,-765,-831,-846,1298,1057,1057,1312,1282,785,785,785,785,784,784,784,784,769,769,769,769,512,512,512,512,512,512,512,512,1399,1398,1383,1367,1382,1396,1351,-511,1381,1366,1139,1139,1079,1079,1124,1124,1364,1349,1363,1333,882,882,882,882,807,807,807,807,1094,1094,1136,1136,373,341,535,535,881,775,867,822,774,-591,324,338,-671,849,550,550,866,864,609,609,293,336,534,534,789,835,773,-751,834,804,308,307,833,788,832,772,562,562,547,547,305,275,560,515,290,290, -252,-397,-477,-557,-622,-653,-719,-735,-750,1329,1299,1314,1057,1057,1042,1042,1312,1282,1024,1024,785,785,785,785,784,784,784,784,769,769,769,769,-383,1127,1141,1111,1126,1140,1095,1110,869,869,883,883,1079,1109,882,882,375,374,807,868,838,881,791,-463,867,822,368,263,852,837,836,-543,610,610,550,550,352,336,534,534,865,774,851,821,850,805,593,533,579,564,773,832,578,578,548,548,577,577,307,276,306,291,516,560,259,259, -250,-2107,-2507,-2764,-2909,-2974,-3007,-3023,1041,1041,1040,1040,769,769,769,769,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,-767,-1052,-1213,-1277,-1358,-1405,-1469,-1535,-1550,-1582,-1614,-1647,-1662,-1694,-1726,-1759,-1774,-1807,-1822,-1854,-1886,1565,-1919,-1935,-1951,-1967,1731,1730,1580,1717,-1983,1729,1564,-1999,1548,-2015,-2031,1715,1595,-2047,1714,-2063,1610,-2079,1609,-2095,1323,1323,1457,1457,1307,1307,1712,1547,1641,1700,1699,1594,1685,1625,1442,1442,1322,1322,-780,-973,-910,1279,1278,1277,1262,1276,1261,1275,1215,1260,1229,-959,974,974,989,989,-943,735,478,478,495,463,506,414,-1039,1003,958,1017,927,942,987,957,431,476,1272,1167,1228,-1183,1256,-1199,895,895,941,941,1242,1227,1212,1135,1014,1014,490,489,503,487,910,1013,985,925,863,894,970,955,1012,847,-1343,831,755,755,984,909,428,366,754,559,-1391,752,486,457,924,997,698,698,983,893,740,740,908,877,739,739,667,667,953,938,497,287,271,271,683,606,590,712,726,574,302,302,738,736,481,286,526,725,605,711,636,724,696,651,589,681,666,710,364,467,573,695,466,466,301,465,379,379,709,604,665,679,316,316,634,633,436,436,464,269,424,394,452,332,438,363,347,408,393,448,331,422,362,407,392,421,346,406,391,376,375,359,1441,1306,-2367,1290,-2383,1337,-2399,-2415,1426,1321,-2431,1411,1336,-2447,-2463,-2479,1169,1169,1049,1049,1424,1289,1412,1352,1319,-2495,1154,1154,1064,1064,1153,1153,416,390,360,404,403,389,344,374,373,343,358,372,327,357,342,311,356,326,1395,1394,1137,1137,1047,1047,1365,1392,1287,1379,1334,1364,1349,1378,1318,1363,792,792,792,792,1152,1152,1032,1032,1121,1121,1046,1046,1120,1120,1030,1030,-2895,1106,1061,1104,849,849,789,789,1091,1076,1029,1090,1060,1075,833,833,309,324,532,532,832,772,818,803,561,561,531,560,515,546,289,274,288,258, -250,-1179,-1579,-1836,-1996,-2124,-2253,-2333,-2413,-2477,-2542,-2574,-2607,-2622,-2655,1314,1313,1298,1312,1282,785,785,785,785,1040,1040,1025,1025,768,768,768,768,-766,-798,-830,-862,-895,-911,-927,-943,-959,-975,-991,-1007,-1023,-1039,-1055,-1070,1724,1647,-1103,-1119,1631,1767,1662,1738,1708,1723,-1135,1780,1615,1779,1599,1677,1646,1778,1583,-1151,1777,1567,1737,1692,1765,1722,1707,1630,1751,1661,1764,1614,1736,1676,1763,1750,1645,1598,1721,1691,1762,1706,1582,1761,1566,-1167,1749,1629,767,766,751,765,494,494,735,764,719,749,734,763,447,447,748,718,477,506,431,491,446,476,461,505,415,430,475,445,504,399,460,489,414,503,383,474,429,459,502,502,746,752,488,398,501,473,413,472,486,271,480,270,-1439,-1455,1357,-1471,-1487,-1503,1341,1325,-1519,1489,1463,1403,1309,-1535,1372,1448,1418,1476,1356,1462,1387,-1551,1475,1340,1447,1402,1386,-1567,1068,1068,1474,1461,455,380,468,440,395,425,410,454,364,467,466,464,453,269,409,448,268,432,1371,1473,1432,1417,1308,1460,1355,1446,1459,1431,1083,1083,1401,1416,1458,1445,1067,1067,1370,1457,1051,1051,1291,1430,1385,1444,1354,1415,1400,1443,1082,1082,1173,1113,1186,1066,1185,1050,-1967,1158,1128,1172,1097,1171,1081,-1983,1157,1112,416,266,375,400,1170,1142,1127,1065,793,793,1169,1033,1156,1096,1141,1111,1155,1080,1126,1140,898,898,808,808,897,897,792,792,1095,1152,1032,1125,1110,1139,1079,1124,882,807,838,881,853,791,-2319,867,368,263,822,852,837,866,806,865,-2399,851,352,262,534,534,821,836,594,594,549,549,593,593,533,533,848,773,579,579,564,578,548,563,276,276,577,576,306,291,516,560,305,305,275,259, -251,-892,-2058,-2620,-2828,-2957,-3023,-3039,1041,1041,1040,1040,769,769,769,769,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,-511,-527,-543,-559,1530,-575,-591,1528,1527,1407,1526,1391,1023,1023,1023,1023,1525,1375,1268,1268,1103,1103,1087,1087,1039,1039,1523,-604,815,815,815,815,510,495,509,479,508,463,507,447,431,505,415,399,-734,-782,1262,-815,1259,1244,-831,1258,1228,-847,-863,1196,-879,1253,987,987,748,-767,493,493,462,477,414,414,686,669,478,446,461,445,474,429,487,458,412,471,1266,1264,1009,1009,799,799,-1019,-1276,-1452,-1581,-1677,-1757,-1821,-1886,-1933,-1997,1257,1257,1483,1468,1512,1422,1497,1406,1467,1496,1421,1510,1134,1134,1225,1225,1466,1451,1374,1405,1252,1252,1358,1480,1164,1164,1251,1251,1238,1238,1389,1465,-1407,1054,1101,-1423,1207,-1439,830,830,1248,1038,1237,1117,1223,1148,1236,1208,411,426,395,410,379,269,1193,1222,1132,1235,1221,1116,976,976,1192,1162,1177,1220,1131,1191,963,963,-1647,961,780,-1663,558,558,994,993,437,408,393,407,829,978,813,797,947,-1743,721,721,377,392,844,950,828,890,706,706,812,859,796,960,948,843,934,874,571,571,-1919,690,555,689,421,346,539,539,944,779,918,873,932,842,903,888,570,570,931,917,674,674,-2575,1562,-2591,1609,-2607,1654,1322,1322,1441,1441,1696,1546,1683,1593,1669,1624,1426,1426,1321,1321,1639,1680,1425,1425,1305,1305,1545,1668,1608,1623,1667,1592,1638,1666,1320,1320,1652,1607,1409,1409,1304,1304,1288,1288,1664,1637,1395,1395,1335,1335,1622,1636,1394,1394,1319,1319,1606,1621,1392,1392,1137,1137,1137,1137,345,390,360,375,404,373,1047,-2751,-2767,-2783,1062,1121,1046,-2799,1077,-2815,1106,1061,789,789,1105,1104,263,355,310,340,325,354,352,262,339,324,1091,1076,1029,1090,1060,1075,833,833,788,788,1088,1028,818,818,803,803,561,561,531,531,816,771,546,546,289,274,288,258, -253,-317,-381,-446,-478,-509,1279,1279,-811,-1179,-1451,-1756,-1900,-2028,-2189,-2253,-2333,-2414,-2445,-2511,-2526,1313,1298,-2559,1041,1041,1040,1040,1025,1025,1024,1024,1022,1007,1021,991,1020,975,1019,959,687,687,1018,1017,671,671,655,655,1016,1015,639,639,758,758,623,623,757,607,756,591,755,575,754,559,543,543,1009,783,-575,-621,-685,-749,496,-590,750,749,734,748,974,989,1003,958,988,973,1002,942,987,957,972,1001,926,986,941,971,956,1000,910,985,925,999,894,970,-1071,-1087,-1102,1390,-1135,1436,1509,1451,1374,-1151,1405,1358,1480,1420,-1167,1507,1494,1389,1342,1465,1435,1450,1326,1505,1310,1493,1373,1479,1404,1492,1464,1419,428,443,472,397,736,526,464,464,486,457,442,471,484,482,1357,1449,1434,1478,1388,1491,1341,1490,1325,1489,1463,1403,1309,1477,1372,1448,1418,1433,1476,1356,1462,1387,-1439,1475,1340,1447,1402,1474,1324,1461,1371,1473,269,448,1432,1417,1308,1460,-1711,1459,-1727,1441,1099,1099,1446,1386,1431,1401,-1743,1289,1083,1083,1160,1160,1458,1445,1067,1067,1370,1457,1307,1430,1129,1129,1098,1098,268,432,267,416,266,400,-1887,1144,1187,1082,1173,1113,1186,1066,1050,1158,1128,1143,1172,1097,1171,1081,420,391,1157,1112,1170,1142,1127,1065,1169,1049,1156,1096,1141,1111,1155,1080,1126,1154,1064,1153,1140,1095,1048,-2159,1125,1110,1137,-2175,823,823,1139,1138,807,807,384,264,368,263,868,838,853,791,867,822,852,837,866,806,865,790,-2319,851,821,836,352,262,850,805,849,-2399,533,533,835,820,336,261,578,548,563,577,532,532,832,772,562,562,547,547,305,275,560,515,290,290,288,258 }; static const ma_uint8 tab32[] = { 130,162,193,209,44,28,76,140,9,9,9,9,9,9,9,9,190,254,222,238,126,94,157,157,109,61,173,205}; static const ma_uint8 tab33[] = { 252,236,220,204,188,172,156,140,124,108,92,76,60,44,28,12 }; static const ma_int16 tabindex[2*16] = { 0,32,64,98,0,132,180,218,292,364,426,538,648,746,0,1126,1460,1460,1460,1460,1460,1460,1460,1460,1842,1842,1842,1842,1842,1842,1842,1842 }; static const ma_uint8 g_linbits[] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,2,3,4,6,8,10,13,4,5,6,7,8,9,11,13 }; #define MA_DR_MP3_PEEK_BITS(n) (bs_cache >> (32 - (n))) #define MA_DR_MP3_FLUSH_BITS(n) { bs_cache <<= (n); bs_sh += (n); } #define MA_DR_MP3_CHECK_BITS while (bs_sh >= 0) { bs_cache |= (ma_uint32)*bs_next_ptr++ << bs_sh; bs_sh -= 8; } #define MA_DR_MP3_BSPOS ((bs_next_ptr - bs->buf)*8 - 24 + bs_sh) float one = 0.0f; int ireg = 0, big_val_cnt = gr_info->big_values; const ma_uint8 *sfb = gr_info->sfbtab; const ma_uint8 *bs_next_ptr = bs->buf + bs->pos/8; ma_uint32 bs_cache = (((bs_next_ptr[0]*256u + bs_next_ptr[1])*256u + bs_next_ptr[2])*256u + bs_next_ptr[3]) << (bs->pos & 7); int pairs_to_decode, np, bs_sh = (bs->pos & 7) - 8; bs_next_ptr += 4; while (big_val_cnt > 0) { int tab_num = gr_info->table_select[ireg]; int sfb_cnt = gr_info->region_count[ireg++]; const ma_int16 *codebook = tabs + tabindex[tab_num]; int linbits = g_linbits[tab_num]; if (linbits) { do { np = *sfb++ / 2; pairs_to_decode = MA_DR_MP3_MIN(big_val_cnt, np); one = *scf++; do { int j, w = 5; int leaf = codebook[MA_DR_MP3_PEEK_BITS(w)]; while (leaf < 0) { MA_DR_MP3_FLUSH_BITS(w); w = leaf & 7; leaf = codebook[MA_DR_MP3_PEEK_BITS(w) - (leaf >> 3)]; } MA_DR_MP3_FLUSH_BITS(leaf >> 8); for (j = 0; j < 2; j++, dst++, leaf >>= 4) { int lsb = leaf & 0x0F; if (lsb == 15) { lsb += MA_DR_MP3_PEEK_BITS(linbits); MA_DR_MP3_FLUSH_BITS(linbits); MA_DR_MP3_CHECK_BITS; *dst = one*ma_dr_mp3_L3_pow_43(lsb)*((ma_int32)bs_cache < 0 ? -1: 1); } else { *dst = g_ma_dr_mp3_pow43[16 + lsb - 16*(bs_cache >> 31)]*one; } MA_DR_MP3_FLUSH_BITS(lsb ? 1 : 0); } MA_DR_MP3_CHECK_BITS; } while (--pairs_to_decode); } while ((big_val_cnt -= np) > 0 && --sfb_cnt >= 0); } else { do { np = *sfb++ / 2; pairs_to_decode = MA_DR_MP3_MIN(big_val_cnt, np); one = *scf++; do { int j, w = 5; int leaf = codebook[MA_DR_MP3_PEEK_BITS(w)]; while (leaf < 0) { MA_DR_MP3_FLUSH_BITS(w); w = leaf & 7; leaf = codebook[MA_DR_MP3_PEEK_BITS(w) - (leaf >> 3)]; } MA_DR_MP3_FLUSH_BITS(leaf >> 8); for (j = 0; j < 2; j++, dst++, leaf >>= 4) { int lsb = leaf & 0x0F; *dst = g_ma_dr_mp3_pow43[16 + lsb - 16*(bs_cache >> 31)]*one; MA_DR_MP3_FLUSH_BITS(lsb ? 1 : 0); } MA_DR_MP3_CHECK_BITS; } while (--pairs_to_decode); } while ((big_val_cnt -= np) > 0 && --sfb_cnt >= 0); } } for (np = 1 - big_val_cnt;; dst += 4) { const ma_uint8 *codebook_count1 = (gr_info->count1_table) ? tab33 : tab32; int leaf = codebook_count1[MA_DR_MP3_PEEK_BITS(4)]; if (!(leaf & 8)) { leaf = codebook_count1[(leaf >> 3) + (bs_cache << 4 >> (32 - (leaf & 3)))]; } MA_DR_MP3_FLUSH_BITS(leaf & 7); if (MA_DR_MP3_BSPOS > layer3gr_limit) { break; } #define MA_DR_MP3_RELOAD_SCALEFACTOR if (!--np) { np = *sfb++/2; if (!np) break; one = *scf++; } #define MA_DR_MP3_DEQ_COUNT1(s) if (leaf & (128 >> s)) { dst[s] = ((ma_int32)bs_cache < 0) ? -one : one; MA_DR_MP3_FLUSH_BITS(1) } MA_DR_MP3_RELOAD_SCALEFACTOR; MA_DR_MP3_DEQ_COUNT1(0); MA_DR_MP3_DEQ_COUNT1(1); MA_DR_MP3_RELOAD_SCALEFACTOR; MA_DR_MP3_DEQ_COUNT1(2); MA_DR_MP3_DEQ_COUNT1(3); MA_DR_MP3_CHECK_BITS; } bs->pos = layer3gr_limit; } static void ma_dr_mp3_L3_midside_stereo(float *left, int n) { int i = 0; float *right = left + 576; #if MA_DR_MP3_HAVE_SIMD if (ma_dr_mp3_have_simd()) { for (; i < n - 3; i += 4) { ma_dr_mp3_f4 vl = MA_DR_MP3_VLD(left + i); ma_dr_mp3_f4 vr = MA_DR_MP3_VLD(right + i); MA_DR_MP3_VSTORE(left + i, MA_DR_MP3_VADD(vl, vr)); MA_DR_MP3_VSTORE(right + i, MA_DR_MP3_VSUB(vl, vr)); } #ifdef __GNUC__ if (__builtin_constant_p(n % 4 == 0) && n % 4 == 0) return; #endif } #endif for (; i < n; i++) { float a = left[i]; float b = right[i]; left[i] = a + b; right[i] = a - b; } } static void ma_dr_mp3_L3_intensity_stereo_band(float *left, int n, float kl, float kr) { int i; for (i = 0; i < n; i++) { left[i + 576] = left[i]*kr; left[i] = left[i]*kl; } } static void ma_dr_mp3_L3_stereo_top_band(const float *right, const ma_uint8 *sfb, int nbands, int max_band[3]) { int i, k; max_band[0] = max_band[1] = max_band[2] = -1; for (i = 0; i < nbands; i++) { for (k = 0; k < sfb[i]; k += 2) { if (right[k] != 0 || right[k + 1] != 0) { max_band[i % 3] = i; break; } } right += sfb[i]; } } static void ma_dr_mp3_L3_stereo_process(float *left, const ma_uint8 *ist_pos, const ma_uint8 *sfb, const ma_uint8 *hdr, int max_band[3], int mpeg2_sh) { static const float g_pan[7*2] = { 0,1,0.21132487f,0.78867513f,0.36602540f,0.63397460f,0.5f,0.5f,0.63397460f,0.36602540f,0.78867513f,0.21132487f,1,0 }; unsigned i, max_pos = MA_DR_MP3_HDR_TEST_MPEG1(hdr) ? 7 : 64; for (i = 0; sfb[i]; i++) { unsigned ipos = ist_pos[i]; if ((int)i > max_band[i % 3] && ipos < max_pos) { float kl, kr, s = MA_DR_MP3_HDR_TEST_MS_STEREO(hdr) ? 1.41421356f : 1; if (MA_DR_MP3_HDR_TEST_MPEG1(hdr)) { kl = g_pan[2*ipos]; kr = g_pan[2*ipos + 1]; } else { kl = 1; kr = ma_dr_mp3_L3_ldexp_q2(1, (ipos + 1) >> 1 << mpeg2_sh); if (ipos & 1) { kl = kr; kr = 1; } } ma_dr_mp3_L3_intensity_stereo_band(left, sfb[i], kl*s, kr*s); } else if (MA_DR_MP3_HDR_TEST_MS_STEREO(hdr)) { ma_dr_mp3_L3_midside_stereo(left, sfb[i]); } left += sfb[i]; } } static void ma_dr_mp3_L3_intensity_stereo(float *left, ma_uint8 *ist_pos, const ma_dr_mp3_L3_gr_info *gr, const ma_uint8 *hdr) { int max_band[3], n_sfb = gr->n_long_sfb + gr->n_short_sfb; int i, max_blocks = gr->n_short_sfb ? 3 : 1; ma_dr_mp3_L3_stereo_top_band(left + 576, gr->sfbtab, n_sfb, max_band); if (gr->n_long_sfb) { max_band[0] = max_band[1] = max_band[2] = MA_DR_MP3_MAX(MA_DR_MP3_MAX(max_band[0], max_band[1]), max_band[2]); } for (i = 0; i < max_blocks; i++) { int default_pos = MA_DR_MP3_HDR_TEST_MPEG1(hdr) ? 3 : 0; int itop = n_sfb - max_blocks + i; int prev = itop - max_blocks; ist_pos[itop] = (ma_uint8)(max_band[i] >= prev ? default_pos : ist_pos[prev]); } ma_dr_mp3_L3_stereo_process(left, ist_pos, gr->sfbtab, hdr, max_band, gr[1].scalefac_compress & 1); } static void ma_dr_mp3_L3_reorder(float *grbuf, float *scratch, const ma_uint8 *sfb) { int i, len; float *src = grbuf, *dst = scratch; for (;0 != (len = *sfb); sfb += 3, src += 2*len) { for (i = 0; i < len; i++, src++) { *dst++ = src[0*len]; *dst++ = src[1*len]; *dst++ = src[2*len]; } } MA_DR_MP3_COPY_MEMORY(grbuf, scratch, (dst - scratch)*sizeof(float)); } static void ma_dr_mp3_L3_antialias(float *grbuf, int nbands) { static const float g_aa[2][8] = { {0.85749293f,0.88174200f,0.94962865f,0.98331459f,0.99551782f,0.99916056f,0.99989920f,0.99999316f}, {0.51449576f,0.47173197f,0.31337745f,0.18191320f,0.09457419f,0.04096558f,0.01419856f,0.00369997f} }; for (; nbands > 0; nbands--, grbuf += 18) { int i = 0; #if MA_DR_MP3_HAVE_SIMD if (ma_dr_mp3_have_simd()) for (; i < 8; i += 4) { ma_dr_mp3_f4 vu = MA_DR_MP3_VLD(grbuf + 18 + i); ma_dr_mp3_f4 vd = MA_DR_MP3_VLD(grbuf + 14 - i); ma_dr_mp3_f4 vc0 = MA_DR_MP3_VLD(g_aa[0] + i); ma_dr_mp3_f4 vc1 = MA_DR_MP3_VLD(g_aa[1] + i); vd = MA_DR_MP3_VREV(vd); MA_DR_MP3_VSTORE(grbuf + 18 + i, MA_DR_MP3_VSUB(MA_DR_MP3_VMUL(vu, vc0), MA_DR_MP3_VMUL(vd, vc1))); vd = MA_DR_MP3_VADD(MA_DR_MP3_VMUL(vu, vc1), MA_DR_MP3_VMUL(vd, vc0)); MA_DR_MP3_VSTORE(grbuf + 14 - i, MA_DR_MP3_VREV(vd)); } #endif #ifndef MA_DR_MP3_ONLY_SIMD for(; i < 8; i++) { float u = grbuf[18 + i]; float d = grbuf[17 - i]; grbuf[18 + i] = u*g_aa[0][i] - d*g_aa[1][i]; grbuf[17 - i] = u*g_aa[1][i] + d*g_aa[0][i]; } #endif } } static void ma_dr_mp3_L3_dct3_9(float *y) { float s0, s1, s2, s3, s4, s5, s6, s7, s8, t0, t2, t4; s0 = y[0]; s2 = y[2]; s4 = y[4]; s6 = y[6]; s8 = y[8]; t0 = s0 + s6*0.5f; s0 -= s6; t4 = (s4 + s2)*0.93969262f; t2 = (s8 + s2)*0.76604444f; s6 = (s4 - s8)*0.17364818f; s4 += s8 - s2; s2 = s0 - s4*0.5f; y[4] = s4 + s0; s8 = t0 - t2 + s6; s0 = t0 - t4 + t2; s4 = t0 + t4 - s6; s1 = y[1]; s3 = y[3]; s5 = y[5]; s7 = y[7]; s3 *= 0.86602540f; t0 = (s5 + s1)*0.98480775f; t4 = (s5 - s7)*0.34202014f; t2 = (s1 + s7)*0.64278761f; s1 = (s1 - s5 - s7)*0.86602540f; s5 = t0 - s3 - t2; s7 = t4 - s3 - t0; s3 = t4 + s3 - t2; y[0] = s4 - s7; y[1] = s2 + s1; y[2] = s0 - s3; y[3] = s8 + s5; y[5] = s8 - s5; y[6] = s0 + s3; y[7] = s2 - s1; y[8] = s4 + s7; } static void ma_dr_mp3_L3_imdct36(float *grbuf, float *overlap, const float *window, int nbands) { int i, j; static const float g_twid9[18] = { 0.73727734f,0.79335334f,0.84339145f,0.88701083f,0.92387953f,0.95371695f,0.97629601f,0.99144486f,0.99904822f,0.67559021f,0.60876143f,0.53729961f,0.46174861f,0.38268343f,0.30070580f,0.21643961f,0.13052619f,0.04361938f }; for (j = 0; j < nbands; j++, grbuf += 18, overlap += 9) { float co[9], si[9]; co[0] = -grbuf[0]; si[0] = grbuf[17]; for (i = 0; i < 4; i++) { si[8 - 2*i] = grbuf[4*i + 1] - grbuf[4*i + 2]; co[1 + 2*i] = grbuf[4*i + 1] + grbuf[4*i + 2]; si[7 - 2*i] = grbuf[4*i + 4] - grbuf[4*i + 3]; co[2 + 2*i] = -(grbuf[4*i + 3] + grbuf[4*i + 4]); } ma_dr_mp3_L3_dct3_9(co); ma_dr_mp3_L3_dct3_9(si); si[1] = -si[1]; si[3] = -si[3]; si[5] = -si[5]; si[7] = -si[7]; i = 0; #if MA_DR_MP3_HAVE_SIMD if (ma_dr_mp3_have_simd()) for (; i < 8; i += 4) { ma_dr_mp3_f4 vovl = MA_DR_MP3_VLD(overlap + i); ma_dr_mp3_f4 vc = MA_DR_MP3_VLD(co + i); ma_dr_mp3_f4 vs = MA_DR_MP3_VLD(si + i); ma_dr_mp3_f4 vr0 = MA_DR_MP3_VLD(g_twid9 + i); ma_dr_mp3_f4 vr1 = MA_DR_MP3_VLD(g_twid9 + 9 + i); ma_dr_mp3_f4 vw0 = MA_DR_MP3_VLD(window + i); ma_dr_mp3_f4 vw1 = MA_DR_MP3_VLD(window + 9 + i); ma_dr_mp3_f4 vsum = MA_DR_MP3_VADD(MA_DR_MP3_VMUL(vc, vr1), MA_DR_MP3_VMUL(vs, vr0)); MA_DR_MP3_VSTORE(overlap + i, MA_DR_MP3_VSUB(MA_DR_MP3_VMUL(vc, vr0), MA_DR_MP3_VMUL(vs, vr1))); MA_DR_MP3_VSTORE(grbuf + i, MA_DR_MP3_VSUB(MA_DR_MP3_VMUL(vovl, vw0), MA_DR_MP3_VMUL(vsum, vw1))); vsum = MA_DR_MP3_VADD(MA_DR_MP3_VMUL(vovl, vw1), MA_DR_MP3_VMUL(vsum, vw0)); MA_DR_MP3_VSTORE(grbuf + 14 - i, MA_DR_MP3_VREV(vsum)); } #endif for (; i < 9; i++) { float ovl = overlap[i]; float sum = co[i]*g_twid9[9 + i] + si[i]*g_twid9[0 + i]; overlap[i] = co[i]*g_twid9[0 + i] - si[i]*g_twid9[9 + i]; grbuf[i] = ovl*window[0 + i] - sum*window[9 + i]; grbuf[17 - i] = ovl*window[9 + i] + sum*window[0 + i]; } } } static void ma_dr_mp3_L3_idct3(float x0, float x1, float x2, float *dst) { float m1 = x1*0.86602540f; float a1 = x0 - x2*0.5f; dst[1] = x0 + x2; dst[0] = a1 + m1; dst[2] = a1 - m1; } static void ma_dr_mp3_L3_imdct12(float *x, float *dst, float *overlap) { static const float g_twid3[6] = { 0.79335334f,0.92387953f,0.99144486f, 0.60876143f,0.38268343f,0.13052619f }; float co[3], si[3]; int i; ma_dr_mp3_L3_idct3(-x[0], x[6] + x[3], x[12] + x[9], co); ma_dr_mp3_L3_idct3(x[15], x[12] - x[9], x[6] - x[3], si); si[1] = -si[1]; for (i = 0; i < 3; i++) { float ovl = overlap[i]; float sum = co[i]*g_twid3[3 + i] + si[i]*g_twid3[0 + i]; overlap[i] = co[i]*g_twid3[0 + i] - si[i]*g_twid3[3 + i]; dst[i] = ovl*g_twid3[2 - i] - sum*g_twid3[5 - i]; dst[5 - i] = ovl*g_twid3[5 - i] + sum*g_twid3[2 - i]; } } static void ma_dr_mp3_L3_imdct_short(float *grbuf, float *overlap, int nbands) { for (;nbands > 0; nbands--, overlap += 9, grbuf += 18) { float tmp[18]; MA_DR_MP3_COPY_MEMORY(tmp, grbuf, sizeof(tmp)); MA_DR_MP3_COPY_MEMORY(grbuf, overlap, 6*sizeof(float)); ma_dr_mp3_L3_imdct12(tmp, grbuf + 6, overlap + 6); ma_dr_mp3_L3_imdct12(tmp + 1, grbuf + 12, overlap + 6); ma_dr_mp3_L3_imdct12(tmp + 2, overlap, overlap + 6); } } static void ma_dr_mp3_L3_change_sign(float *grbuf) { int b, i; for (b = 0, grbuf += 18; b < 32; b += 2, grbuf += 36) for (i = 1; i < 18; i += 2) grbuf[i] = -grbuf[i]; } static void ma_dr_mp3_L3_imdct_gr(float *grbuf, float *overlap, unsigned block_type, unsigned n_long_bands) { static const float g_mdct_window[2][18] = { { 0.99904822f,0.99144486f,0.97629601f,0.95371695f,0.92387953f,0.88701083f,0.84339145f,0.79335334f,0.73727734f,0.04361938f,0.13052619f,0.21643961f,0.30070580f,0.38268343f,0.46174861f,0.53729961f,0.60876143f,0.67559021f }, { 1,1,1,1,1,1,0.99144486f,0.92387953f,0.79335334f,0,0,0,0,0,0,0.13052619f,0.38268343f,0.60876143f } }; if (n_long_bands) { ma_dr_mp3_L3_imdct36(grbuf, overlap, g_mdct_window[0], n_long_bands); grbuf += 18*n_long_bands; overlap += 9*n_long_bands; } if (block_type == MA_DR_MP3_SHORT_BLOCK_TYPE) ma_dr_mp3_L3_imdct_short(grbuf, overlap, 32 - n_long_bands); else ma_dr_mp3_L3_imdct36(grbuf, overlap, g_mdct_window[block_type == MA_DR_MP3_STOP_BLOCK_TYPE], 32 - n_long_bands); } static void ma_dr_mp3_L3_save_reservoir(ma_dr_mp3dec *h, ma_dr_mp3dec_scratch *s) { int pos = (s->bs.pos + 7)/8u; int remains = s->bs.limit/8u - pos; if (remains > MA_DR_MP3_MAX_BITRESERVOIR_BYTES) { pos += remains - MA_DR_MP3_MAX_BITRESERVOIR_BYTES; remains = MA_DR_MP3_MAX_BITRESERVOIR_BYTES; } if (remains > 0) { MA_DR_MP3_MOVE_MEMORY(h->reserv_buf, s->maindata + pos, remains); } h->reserv = remains; } static int ma_dr_mp3_L3_restore_reservoir(ma_dr_mp3dec *h, ma_dr_mp3_bs *bs, ma_dr_mp3dec_scratch *s, int main_data_begin) { int frame_bytes = (bs->limit - bs->pos)/8; int bytes_have = MA_DR_MP3_MIN(h->reserv, main_data_begin); MA_DR_MP3_COPY_MEMORY(s->maindata, h->reserv_buf + MA_DR_MP3_MAX(0, h->reserv - main_data_begin), MA_DR_MP3_MIN(h->reserv, main_data_begin)); MA_DR_MP3_COPY_MEMORY(s->maindata + bytes_have, bs->buf + bs->pos/8, frame_bytes); ma_dr_mp3_bs_init(&s->bs, s->maindata, bytes_have + frame_bytes); return h->reserv >= main_data_begin; } static void ma_dr_mp3_L3_decode(ma_dr_mp3dec *h, ma_dr_mp3dec_scratch *s, ma_dr_mp3_L3_gr_info *gr_info, int nch) { int ch; for (ch = 0; ch < nch; ch++) { int layer3gr_limit = s->bs.pos + gr_info[ch].part_23_length; ma_dr_mp3_L3_decode_scalefactors(h->header, s->ist_pos[ch], &s->bs, gr_info + ch, s->scf, ch); ma_dr_mp3_L3_huffman(s->grbuf[ch], &s->bs, gr_info + ch, s->scf, layer3gr_limit); } if (MA_DR_MP3_HDR_TEST_I_STEREO(h->header)) { ma_dr_mp3_L3_intensity_stereo(s->grbuf[0], s->ist_pos[1], gr_info, h->header); } else if (MA_DR_MP3_HDR_IS_MS_STEREO(h->header)) { ma_dr_mp3_L3_midside_stereo(s->grbuf[0], 576); } for (ch = 0; ch < nch; ch++, gr_info++) { int aa_bands = 31; int n_long_bands = (gr_info->mixed_block_flag ? 2 : 0) << (int)(MA_DR_MP3_HDR_GET_MY_SAMPLE_RATE(h->header) == 2); if (gr_info->n_short_sfb) { aa_bands = n_long_bands - 1; ma_dr_mp3_L3_reorder(s->grbuf[ch] + n_long_bands*18, s->syn[0], gr_info->sfbtab + gr_info->n_long_sfb); } ma_dr_mp3_L3_antialias(s->grbuf[ch], aa_bands); ma_dr_mp3_L3_imdct_gr(s->grbuf[ch], h->mdct_overlap[ch], gr_info->block_type, n_long_bands); ma_dr_mp3_L3_change_sign(s->grbuf[ch]); } } static void ma_dr_mp3d_DCT_II(float *grbuf, int n) { static const float g_sec[24] = { 10.19000816f,0.50060302f,0.50241929f,3.40760851f,0.50547093f,0.52249861f,2.05778098f,0.51544732f,0.56694406f,1.48416460f,0.53104258f,0.64682180f,1.16943991f,0.55310392f,0.78815460f,0.97256821f,0.58293498f,1.06067765f,0.83934963f,0.62250412f,1.72244716f,0.74453628f,0.67480832f,5.10114861f }; int i, k = 0; #if MA_DR_MP3_HAVE_SIMD if (ma_dr_mp3_have_simd()) for (; k < n; k += 4) { ma_dr_mp3_f4 t[4][8], *x; float *y = grbuf + k; for (x = t[0], i = 0; i < 8; i++, x++) { ma_dr_mp3_f4 x0 = MA_DR_MP3_VLD(&y[i*18]); ma_dr_mp3_f4 x1 = MA_DR_MP3_VLD(&y[(15 - i)*18]); ma_dr_mp3_f4 x2 = MA_DR_MP3_VLD(&y[(16 + i)*18]); ma_dr_mp3_f4 x3 = MA_DR_MP3_VLD(&y[(31 - i)*18]); ma_dr_mp3_f4 t0 = MA_DR_MP3_VADD(x0, x3); ma_dr_mp3_f4 t1 = MA_DR_MP3_VADD(x1, x2); ma_dr_mp3_f4 t2 = MA_DR_MP3_VMUL_S(MA_DR_MP3_VSUB(x1, x2), g_sec[3*i + 0]); ma_dr_mp3_f4 t3 = MA_DR_MP3_VMUL_S(MA_DR_MP3_VSUB(x0, x3), g_sec[3*i + 1]); x[0] = MA_DR_MP3_VADD(t0, t1); x[8] = MA_DR_MP3_VMUL_S(MA_DR_MP3_VSUB(t0, t1), g_sec[3*i + 2]); x[16] = MA_DR_MP3_VADD(t3, t2); x[24] = MA_DR_MP3_VMUL_S(MA_DR_MP3_VSUB(t3, t2), g_sec[3*i + 2]); } for (x = t[0], i = 0; i < 4; i++, x += 8) { ma_dr_mp3_f4 x0 = x[0], x1 = x[1], x2 = x[2], x3 = x[3], x4 = x[4], x5 = x[5], x6 = x[6], x7 = x[7], xt; xt = MA_DR_MP3_VSUB(x0, x7); x0 = MA_DR_MP3_VADD(x0, x7); x7 = MA_DR_MP3_VSUB(x1, x6); x1 = MA_DR_MP3_VADD(x1, x6); x6 = MA_DR_MP3_VSUB(x2, x5); x2 = MA_DR_MP3_VADD(x2, x5); x5 = MA_DR_MP3_VSUB(x3, x4); x3 = MA_DR_MP3_VADD(x3, x4); x4 = MA_DR_MP3_VSUB(x0, x3); x0 = MA_DR_MP3_VADD(x0, x3); x3 = MA_DR_MP3_VSUB(x1, x2); x1 = MA_DR_MP3_VADD(x1, x2); x[0] = MA_DR_MP3_VADD(x0, x1); x[4] = MA_DR_MP3_VMUL_S(MA_DR_MP3_VSUB(x0, x1), 0.70710677f); x5 = MA_DR_MP3_VADD(x5, x6); x6 = MA_DR_MP3_VMUL_S(MA_DR_MP3_VADD(x6, x7), 0.70710677f); x7 = MA_DR_MP3_VADD(x7, xt); x3 = MA_DR_MP3_VMUL_S(MA_DR_MP3_VADD(x3, x4), 0.70710677f); x5 = MA_DR_MP3_VSUB(x5, MA_DR_MP3_VMUL_S(x7, 0.198912367f)); x7 = MA_DR_MP3_VADD(x7, MA_DR_MP3_VMUL_S(x5, 0.382683432f)); x5 = MA_DR_MP3_VSUB(x5, MA_DR_MP3_VMUL_S(x7, 0.198912367f)); x0 = MA_DR_MP3_VSUB(xt, x6); xt = MA_DR_MP3_VADD(xt, x6); x[1] = MA_DR_MP3_VMUL_S(MA_DR_MP3_VADD(xt, x7), 0.50979561f); x[2] = MA_DR_MP3_VMUL_S(MA_DR_MP3_VADD(x4, x3), 0.54119611f); x[3] = MA_DR_MP3_VMUL_S(MA_DR_MP3_VSUB(x0, x5), 0.60134488f); x[5] = MA_DR_MP3_VMUL_S(MA_DR_MP3_VADD(x0, x5), 0.89997619f); x[6] = MA_DR_MP3_VMUL_S(MA_DR_MP3_VSUB(x4, x3), 1.30656302f); x[7] = MA_DR_MP3_VMUL_S(MA_DR_MP3_VSUB(xt, x7), 2.56291556f); } if (k > n - 3) { #if MA_DR_MP3_HAVE_SSE #define MA_DR_MP3_VSAVE2(i, v) _mm_storel_pi((__m64 *)(void*)&y[i*18], v) #else #define MA_DR_MP3_VSAVE2(i, v) vst1_f32((float32_t *)&y[(i)*18], vget_low_f32(v)) #endif for (i = 0; i < 7; i++, y += 4*18) { ma_dr_mp3_f4 s = MA_DR_MP3_VADD(t[3][i], t[3][i + 1]); MA_DR_MP3_VSAVE2(0, t[0][i]); MA_DR_MP3_VSAVE2(1, MA_DR_MP3_VADD(t[2][i], s)); MA_DR_MP3_VSAVE2(2, MA_DR_MP3_VADD(t[1][i], t[1][i + 1])); MA_DR_MP3_VSAVE2(3, MA_DR_MP3_VADD(t[2][1 + i], s)); } MA_DR_MP3_VSAVE2(0, t[0][7]); MA_DR_MP3_VSAVE2(1, MA_DR_MP3_VADD(t[2][7], t[3][7])); MA_DR_MP3_VSAVE2(2, t[1][7]); MA_DR_MP3_VSAVE2(3, t[3][7]); } else { #define MA_DR_MP3_VSAVE4(i, v) MA_DR_MP3_VSTORE(&y[(i)*18], v) for (i = 0; i < 7; i++, y += 4*18) { ma_dr_mp3_f4 s = MA_DR_MP3_VADD(t[3][i], t[3][i + 1]); MA_DR_MP3_VSAVE4(0, t[0][i]); MA_DR_MP3_VSAVE4(1, MA_DR_MP3_VADD(t[2][i], s)); MA_DR_MP3_VSAVE4(2, MA_DR_MP3_VADD(t[1][i], t[1][i + 1])); MA_DR_MP3_VSAVE4(3, MA_DR_MP3_VADD(t[2][1 + i], s)); } MA_DR_MP3_VSAVE4(0, t[0][7]); MA_DR_MP3_VSAVE4(1, MA_DR_MP3_VADD(t[2][7], t[3][7])); MA_DR_MP3_VSAVE4(2, t[1][7]); MA_DR_MP3_VSAVE4(3, t[3][7]); } } else #endif #ifdef MA_DR_MP3_ONLY_SIMD {} #else for (; k < n; k++) { float t[4][8], *x, *y = grbuf + k; for (x = t[0], i = 0; i < 8; i++, x++) { float x0 = y[i*18]; float x1 = y[(15 - i)*18]; float x2 = y[(16 + i)*18]; float x3 = y[(31 - i)*18]; float t0 = x0 + x3; float t1 = x1 + x2; float t2 = (x1 - x2)*g_sec[3*i + 0]; float t3 = (x0 - x3)*g_sec[3*i + 1]; x[0] = t0 + t1; x[8] = (t0 - t1)*g_sec[3*i + 2]; x[16] = t3 + t2; x[24] = (t3 - t2)*g_sec[3*i + 2]; } for (x = t[0], i = 0; i < 4; i++, x += 8) { float x0 = x[0], x1 = x[1], x2 = x[2], x3 = x[3], x4 = x[4], x5 = x[5], x6 = x[6], x7 = x[7], xt; xt = x0 - x7; x0 += x7; x7 = x1 - x6; x1 += x6; x6 = x2 - x5; x2 += x5; x5 = x3 - x4; x3 += x4; x4 = x0 - x3; x0 += x3; x3 = x1 - x2; x1 += x2; x[0] = x0 + x1; x[4] = (x0 - x1)*0.70710677f; x5 = x5 + x6; x6 = (x6 + x7)*0.70710677f; x7 = x7 + xt; x3 = (x3 + x4)*0.70710677f; x5 -= x7*0.198912367f; x7 += x5*0.382683432f; x5 -= x7*0.198912367f; x0 = xt - x6; xt += x6; x[1] = (xt + x7)*0.50979561f; x[2] = (x4 + x3)*0.54119611f; x[3] = (x0 - x5)*0.60134488f; x[5] = (x0 + x5)*0.89997619f; x[6] = (x4 - x3)*1.30656302f; x[7] = (xt - x7)*2.56291556f; } for (i = 0; i < 7; i++, y += 4*18) { y[0*18] = t[0][i]; y[1*18] = t[2][i] + t[3][i] + t[3][i + 1]; y[2*18] = t[1][i] + t[1][i + 1]; y[3*18] = t[2][i + 1] + t[3][i] + t[3][i + 1]; } y[0*18] = t[0][7]; y[1*18] = t[2][7] + t[3][7]; y[2*18] = t[1][7]; y[3*18] = t[3][7]; } #endif } #ifndef MA_DR_MP3_FLOAT_OUTPUT typedef ma_int16 ma_dr_mp3d_sample_t; static ma_int16 ma_dr_mp3d_scale_pcm(float sample) { ma_int16 s; #if MA_DR_MP3_HAVE_ARMV6 ma_int32 s32 = (ma_int32)(sample + .5f); s32 -= (s32 < 0); s = (ma_int16)ma_dr_mp3_clip_int16_arm(s32); #else if (sample >= 32766.5) return (ma_int16) 32767; if (sample <= -32767.5) return (ma_int16)-32768; s = (ma_int16)(sample + .5f); s -= (s < 0); #endif return s; } #else typedef float ma_dr_mp3d_sample_t; static float ma_dr_mp3d_scale_pcm(float sample) { return sample*(1.f/32768.f); } #endif static void ma_dr_mp3d_synth_pair(ma_dr_mp3d_sample_t *pcm, int nch, const float *z) { float a; a = (z[14*64] - z[ 0]) * 29; a += (z[ 1*64] + z[13*64]) * 213; a += (z[12*64] - z[ 2*64]) * 459; a += (z[ 3*64] + z[11*64]) * 2037; a += (z[10*64] - z[ 4*64]) * 5153; a += (z[ 5*64] + z[ 9*64]) * 6574; a += (z[ 8*64] - z[ 6*64]) * 37489; a += z[ 7*64] * 75038; pcm[0] = ma_dr_mp3d_scale_pcm(a); z += 2; a = z[14*64] * 104; a += z[12*64] * 1567; a += z[10*64] * 9727; a += z[ 8*64] * 64019; a += z[ 6*64] * -9975; a += z[ 4*64] * -45; a += z[ 2*64] * 146; a += z[ 0*64] * -5; pcm[16*nch] = ma_dr_mp3d_scale_pcm(a); } static void ma_dr_mp3d_synth(float *xl, ma_dr_mp3d_sample_t *dstl, int nch, float *lins) { int i; float *xr = xl + 576*(nch - 1); ma_dr_mp3d_sample_t *dstr = dstl + (nch - 1); static const float g_win[] = { -1,26,-31,208,218,401,-519,2063,2000,4788,-5517,7134,5959,35640,-39336,74992, -1,24,-35,202,222,347,-581,2080,1952,4425,-5879,7640,5288,33791,-41176,74856, -1,21,-38,196,225,294,-645,2087,1893,4063,-6237,8092,4561,31947,-43006,74630, -1,19,-41,190,227,244,-711,2085,1822,3705,-6589,8492,3776,30112,-44821,74313, -1,17,-45,183,228,197,-779,2075,1739,3351,-6935,8840,2935,28289,-46617,73908, -1,16,-49,176,228,153,-848,2057,1644,3004,-7271,9139,2037,26482,-48390,73415, -2,14,-53,169,227,111,-919,2032,1535,2663,-7597,9389,1082,24694,-50137,72835, -2,13,-58,161,224,72,-991,2001,1414,2330,-7910,9592,70,22929,-51853,72169, -2,11,-63,154,221,36,-1064,1962,1280,2006,-8209,9750,-998,21189,-53534,71420, -2,10,-68,147,215,2,-1137,1919,1131,1692,-8491,9863,-2122,19478,-55178,70590, -3,9,-73,139,208,-29,-1210,1870,970,1388,-8755,9935,-3300,17799,-56778,69679, -3,8,-79,132,200,-57,-1283,1817,794,1095,-8998,9966,-4533,16155,-58333,68692, -4,7,-85,125,189,-83,-1356,1759,605,814,-9219,9959,-5818,14548,-59838,67629, -4,7,-91,117,177,-106,-1428,1698,402,545,-9416,9916,-7154,12980,-61289,66494, -5,6,-97,111,163,-127,-1498,1634,185,288,-9585,9838,-8540,11455,-62684,65290 }; float *zlin = lins + 15*64; const float *w = g_win; zlin[4*15] = xl[18*16]; zlin[4*15 + 1] = xr[18*16]; zlin[4*15 + 2] = xl[0]; zlin[4*15 + 3] = xr[0]; zlin[4*31] = xl[1 + 18*16]; zlin[4*31 + 1] = xr[1 + 18*16]; zlin[4*31 + 2] = xl[1]; zlin[4*31 + 3] = xr[1]; ma_dr_mp3d_synth_pair(dstr, nch, lins + 4*15 + 1); ma_dr_mp3d_synth_pair(dstr + 32*nch, nch, lins + 4*15 + 64 + 1); ma_dr_mp3d_synth_pair(dstl, nch, lins + 4*15); ma_dr_mp3d_synth_pair(dstl + 32*nch, nch, lins + 4*15 + 64); #if MA_DR_MP3_HAVE_SIMD if (ma_dr_mp3_have_simd()) for (i = 14; i >= 0; i--) { #define MA_DR_MP3_VLOAD(k) ma_dr_mp3_f4 w0 = MA_DR_MP3_VSET(*w++); ma_dr_mp3_f4 w1 = MA_DR_MP3_VSET(*w++); ma_dr_mp3_f4 vz = MA_DR_MP3_VLD(&zlin[4*i - 64*k]); ma_dr_mp3_f4 vy = MA_DR_MP3_VLD(&zlin[4*i - 64*(15 - k)]); #define MA_DR_MP3_V0(k) { MA_DR_MP3_VLOAD(k) b = MA_DR_MP3_VADD(MA_DR_MP3_VMUL(vz, w1), MA_DR_MP3_VMUL(vy, w0)) ; a = MA_DR_MP3_VSUB(MA_DR_MP3_VMUL(vz, w0), MA_DR_MP3_VMUL(vy, w1)); } #define MA_DR_MP3_V1(k) { MA_DR_MP3_VLOAD(k) b = MA_DR_MP3_VADD(b, MA_DR_MP3_VADD(MA_DR_MP3_VMUL(vz, w1), MA_DR_MP3_VMUL(vy, w0))); a = MA_DR_MP3_VADD(a, MA_DR_MP3_VSUB(MA_DR_MP3_VMUL(vz, w0), MA_DR_MP3_VMUL(vy, w1))); } #define MA_DR_MP3_V2(k) { MA_DR_MP3_VLOAD(k) b = MA_DR_MP3_VADD(b, MA_DR_MP3_VADD(MA_DR_MP3_VMUL(vz, w1), MA_DR_MP3_VMUL(vy, w0))); a = MA_DR_MP3_VADD(a, MA_DR_MP3_VSUB(MA_DR_MP3_VMUL(vy, w1), MA_DR_MP3_VMUL(vz, w0))); } ma_dr_mp3_f4 a, b; zlin[4*i] = xl[18*(31 - i)]; zlin[4*i + 1] = xr[18*(31 - i)]; zlin[4*i + 2] = xl[1 + 18*(31 - i)]; zlin[4*i + 3] = xr[1 + 18*(31 - i)]; zlin[4*i + 64] = xl[1 + 18*(1 + i)]; zlin[4*i + 64 + 1] = xr[1 + 18*(1 + i)]; zlin[4*i - 64 + 2] = xl[18*(1 + i)]; zlin[4*i - 64 + 3] = xr[18*(1 + i)]; MA_DR_MP3_V0(0) MA_DR_MP3_V2(1) MA_DR_MP3_V1(2) MA_DR_MP3_V2(3) MA_DR_MP3_V1(4) MA_DR_MP3_V2(5) MA_DR_MP3_V1(6) MA_DR_MP3_V2(7) { #ifndef MA_DR_MP3_FLOAT_OUTPUT #if MA_DR_MP3_HAVE_SSE static const ma_dr_mp3_f4 g_max = { 32767.0f, 32767.0f, 32767.0f, 32767.0f }; static const ma_dr_mp3_f4 g_min = { -32768.0f, -32768.0f, -32768.0f, -32768.0f }; __m128i pcm8 = _mm_packs_epi32(_mm_cvtps_epi32(_mm_max_ps(_mm_min_ps(a, g_max), g_min)), _mm_cvtps_epi32(_mm_max_ps(_mm_min_ps(b, g_max), g_min))); dstr[(15 - i)*nch] = (ma_int16)_mm_extract_epi16(pcm8, 1); dstr[(17 + i)*nch] = (ma_int16)_mm_extract_epi16(pcm8, 5); dstl[(15 - i)*nch] = (ma_int16)_mm_extract_epi16(pcm8, 0); dstl[(17 + i)*nch] = (ma_int16)_mm_extract_epi16(pcm8, 4); dstr[(47 - i)*nch] = (ma_int16)_mm_extract_epi16(pcm8, 3); dstr[(49 + i)*nch] = (ma_int16)_mm_extract_epi16(pcm8, 7); dstl[(47 - i)*nch] = (ma_int16)_mm_extract_epi16(pcm8, 2); dstl[(49 + i)*nch] = (ma_int16)_mm_extract_epi16(pcm8, 6); #else int16x4_t pcma, pcmb; a = MA_DR_MP3_VADD(a, MA_DR_MP3_VSET(0.5f)); b = MA_DR_MP3_VADD(b, MA_DR_MP3_VSET(0.5f)); pcma = vqmovn_s32(vqaddq_s32(vcvtq_s32_f32(a), vreinterpretq_s32_u32(vcltq_f32(a, MA_DR_MP3_VSET(0))))); pcmb = vqmovn_s32(vqaddq_s32(vcvtq_s32_f32(b), vreinterpretq_s32_u32(vcltq_f32(b, MA_DR_MP3_VSET(0))))); vst1_lane_s16(dstr + (15 - i)*nch, pcma, 1); vst1_lane_s16(dstr + (17 + i)*nch, pcmb, 1); vst1_lane_s16(dstl + (15 - i)*nch, pcma, 0); vst1_lane_s16(dstl + (17 + i)*nch, pcmb, 0); vst1_lane_s16(dstr + (47 - i)*nch, pcma, 3); vst1_lane_s16(dstr + (49 + i)*nch, pcmb, 3); vst1_lane_s16(dstl + (47 - i)*nch, pcma, 2); vst1_lane_s16(dstl + (49 + i)*nch, pcmb, 2); #endif #else #if MA_DR_MP3_HAVE_SSE static const ma_dr_mp3_f4 g_scale = { 1.0f/32768.0f, 1.0f/32768.0f, 1.0f/32768.0f, 1.0f/32768.0f }; #else const ma_dr_mp3_f4 g_scale = vdupq_n_f32(1.0f/32768.0f); #endif a = MA_DR_MP3_VMUL(a, g_scale); b = MA_DR_MP3_VMUL(b, g_scale); #if MA_DR_MP3_HAVE_SSE _mm_store_ss(dstr + (15 - i)*nch, _mm_shuffle_ps(a, a, _MM_SHUFFLE(1, 1, 1, 1))); _mm_store_ss(dstr + (17 + i)*nch, _mm_shuffle_ps(b, b, _MM_SHUFFLE(1, 1, 1, 1))); _mm_store_ss(dstl + (15 - i)*nch, _mm_shuffle_ps(a, a, _MM_SHUFFLE(0, 0, 0, 0))); _mm_store_ss(dstl + (17 + i)*nch, _mm_shuffle_ps(b, b, _MM_SHUFFLE(0, 0, 0, 0))); _mm_store_ss(dstr + (47 - i)*nch, _mm_shuffle_ps(a, a, _MM_SHUFFLE(3, 3, 3, 3))); _mm_store_ss(dstr + (49 + i)*nch, _mm_shuffle_ps(b, b, _MM_SHUFFLE(3, 3, 3, 3))); _mm_store_ss(dstl + (47 - i)*nch, _mm_shuffle_ps(a, a, _MM_SHUFFLE(2, 2, 2, 2))); _mm_store_ss(dstl + (49 + i)*nch, _mm_shuffle_ps(b, b, _MM_SHUFFLE(2, 2, 2, 2))); #else vst1q_lane_f32(dstr + (15 - i)*nch, a, 1); vst1q_lane_f32(dstr + (17 + i)*nch, b, 1); vst1q_lane_f32(dstl + (15 - i)*nch, a, 0); vst1q_lane_f32(dstl + (17 + i)*nch, b, 0); vst1q_lane_f32(dstr + (47 - i)*nch, a, 3); vst1q_lane_f32(dstr + (49 + i)*nch, b, 3); vst1q_lane_f32(dstl + (47 - i)*nch, a, 2); vst1q_lane_f32(dstl + (49 + i)*nch, b, 2); #endif #endif } } else #endif #ifdef MA_DR_MP3_ONLY_SIMD {} #else for (i = 14; i >= 0; i--) { #define MA_DR_MP3_LOAD(k) float w0 = *w++; float w1 = *w++; float *vz = &zlin[4*i - k*64]; float *vy = &zlin[4*i - (15 - k)*64]; #define MA_DR_MP3_S0(k) { int j; MA_DR_MP3_LOAD(k); for (j = 0; j < 4; j++) b[j] = vz[j]*w1 + vy[j]*w0, a[j] = vz[j]*w0 - vy[j]*w1; } #define MA_DR_MP3_S1(k) { int j; MA_DR_MP3_LOAD(k); for (j = 0; j < 4; j++) b[j] += vz[j]*w1 + vy[j]*w0, a[j] += vz[j]*w0 - vy[j]*w1; } #define MA_DR_MP3_S2(k) { int j; MA_DR_MP3_LOAD(k); for (j = 0; j < 4; j++) b[j] += vz[j]*w1 + vy[j]*w0, a[j] += vy[j]*w1 - vz[j]*w0; } float a[4], b[4]; zlin[4*i] = xl[18*(31 - i)]; zlin[4*i + 1] = xr[18*(31 - i)]; zlin[4*i + 2] = xl[1 + 18*(31 - i)]; zlin[4*i + 3] = xr[1 + 18*(31 - i)]; zlin[4*(i + 16)] = xl[1 + 18*(1 + i)]; zlin[4*(i + 16) + 1] = xr[1 + 18*(1 + i)]; zlin[4*(i - 16) + 2] = xl[18*(1 + i)]; zlin[4*(i - 16) + 3] = xr[18*(1 + i)]; MA_DR_MP3_S0(0) MA_DR_MP3_S2(1) MA_DR_MP3_S1(2) MA_DR_MP3_S2(3) MA_DR_MP3_S1(4) MA_DR_MP3_S2(5) MA_DR_MP3_S1(6) MA_DR_MP3_S2(7) dstr[(15 - i)*nch] = ma_dr_mp3d_scale_pcm(a[1]); dstr[(17 + i)*nch] = ma_dr_mp3d_scale_pcm(b[1]); dstl[(15 - i)*nch] = ma_dr_mp3d_scale_pcm(a[0]); dstl[(17 + i)*nch] = ma_dr_mp3d_scale_pcm(b[0]); dstr[(47 - i)*nch] = ma_dr_mp3d_scale_pcm(a[3]); dstr[(49 + i)*nch] = ma_dr_mp3d_scale_pcm(b[3]); dstl[(47 - i)*nch] = ma_dr_mp3d_scale_pcm(a[2]); dstl[(49 + i)*nch] = ma_dr_mp3d_scale_pcm(b[2]); } #endif } static void ma_dr_mp3d_synth_granule(float *qmf_state, float *grbuf, int nbands, int nch, ma_dr_mp3d_sample_t *pcm, float *lins) { int i; for (i = 0; i < nch; i++) { ma_dr_mp3d_DCT_II(grbuf + 576*i, nbands); } MA_DR_MP3_COPY_MEMORY(lins, qmf_state, sizeof(float)*15*64); for (i = 0; i < nbands; i += 2) { ma_dr_mp3d_synth(grbuf + i, pcm + 32*nch*i, nch, lins + i*64); } #ifndef MA_DR_MP3_NONSTANDARD_BUT_LOGICAL if (nch == 1) { for (i = 0; i < 15*64; i += 2) { qmf_state[i] = lins[nbands*64 + i]; } } else #endif { MA_DR_MP3_COPY_MEMORY(qmf_state, lins + nbands*64, sizeof(float)*15*64); } } static int ma_dr_mp3d_match_frame(const ma_uint8 *hdr, int mp3_bytes, int frame_bytes) { int i, nmatch; for (i = 0, nmatch = 0; nmatch < MA_DR_MP3_MAX_FRAME_SYNC_MATCHES; nmatch++) { i += ma_dr_mp3_hdr_frame_bytes(hdr + i, frame_bytes) + ma_dr_mp3_hdr_padding(hdr + i); if (i + MA_DR_MP3_HDR_SIZE > mp3_bytes) return nmatch > 0; if (!ma_dr_mp3_hdr_compare(hdr, hdr + i)) return 0; } return 1; } static int ma_dr_mp3d_find_frame(const ma_uint8 *mp3, int mp3_bytes, int *free_format_bytes, int *ptr_frame_bytes) { int i, k; for (i = 0; i < mp3_bytes - MA_DR_MP3_HDR_SIZE; i++, mp3++) { if (ma_dr_mp3_hdr_valid(mp3)) { int frame_bytes = ma_dr_mp3_hdr_frame_bytes(mp3, *free_format_bytes); int frame_and_padding = frame_bytes + ma_dr_mp3_hdr_padding(mp3); for (k = MA_DR_MP3_HDR_SIZE; !frame_bytes && k < MA_DR_MP3_MAX_FREE_FORMAT_FRAME_SIZE && i + 2*k < mp3_bytes - MA_DR_MP3_HDR_SIZE; k++) { if (ma_dr_mp3_hdr_compare(mp3, mp3 + k)) { int fb = k - ma_dr_mp3_hdr_padding(mp3); int nextfb = fb + ma_dr_mp3_hdr_padding(mp3 + k); if (i + k + nextfb + MA_DR_MP3_HDR_SIZE > mp3_bytes || !ma_dr_mp3_hdr_compare(mp3, mp3 + k + nextfb)) continue; frame_and_padding = k; frame_bytes = fb; *free_format_bytes = fb; } } if ((frame_bytes && i + frame_and_padding <= mp3_bytes && ma_dr_mp3d_match_frame(mp3, mp3_bytes - i, frame_bytes)) || (!i && frame_and_padding == mp3_bytes)) { *ptr_frame_bytes = frame_and_padding; return i; } *free_format_bytes = 0; } } *ptr_frame_bytes = 0; return mp3_bytes; } MA_API void ma_dr_mp3dec_init(ma_dr_mp3dec *dec) { dec->header[0] = 0; } MA_API int ma_dr_mp3dec_decode_frame(ma_dr_mp3dec *dec, const ma_uint8 *mp3, int mp3_bytes, void *pcm, ma_dr_mp3dec_frame_info *info) { int i = 0, igr, frame_size = 0, success = 1; const ma_uint8 *hdr; ma_dr_mp3_bs bs_frame[1]; ma_dr_mp3dec_scratch scratch; if (mp3_bytes > 4 && dec->header[0] == 0xff && ma_dr_mp3_hdr_compare(dec->header, mp3)) { frame_size = ma_dr_mp3_hdr_frame_bytes(mp3, dec->free_format_bytes) + ma_dr_mp3_hdr_padding(mp3); if (frame_size != mp3_bytes && (frame_size + MA_DR_MP3_HDR_SIZE > mp3_bytes || !ma_dr_mp3_hdr_compare(mp3, mp3 + frame_size))) { frame_size = 0; } } if (!frame_size) { MA_DR_MP3_ZERO_MEMORY(dec, sizeof(ma_dr_mp3dec)); i = ma_dr_mp3d_find_frame(mp3, mp3_bytes, &dec->free_format_bytes, &frame_size); if (!frame_size || i + frame_size > mp3_bytes) { info->frame_bytes = i; return 0; } } hdr = mp3 + i; MA_DR_MP3_COPY_MEMORY(dec->header, hdr, MA_DR_MP3_HDR_SIZE); info->frame_bytes = i + frame_size; info->channels = MA_DR_MP3_HDR_IS_MONO(hdr) ? 1 : 2; info->hz = ma_dr_mp3_hdr_sample_rate_hz(hdr); info->layer = 4 - MA_DR_MP3_HDR_GET_LAYER(hdr); info->bitrate_kbps = ma_dr_mp3_hdr_bitrate_kbps(hdr); ma_dr_mp3_bs_init(bs_frame, hdr + MA_DR_MP3_HDR_SIZE, frame_size - MA_DR_MP3_HDR_SIZE); if (MA_DR_MP3_HDR_IS_CRC(hdr)) { ma_dr_mp3_bs_get_bits(bs_frame, 16); } if (info->layer == 3) { int main_data_begin = ma_dr_mp3_L3_read_side_info(bs_frame, scratch.gr_info, hdr); if (main_data_begin < 0 || bs_frame->pos > bs_frame->limit) { ma_dr_mp3dec_init(dec); return 0; } success = ma_dr_mp3_L3_restore_reservoir(dec, bs_frame, &scratch, main_data_begin); if (success && pcm != NULL) { for (igr = 0; igr < (MA_DR_MP3_HDR_TEST_MPEG1(hdr) ? 2 : 1); igr++, pcm = MA_DR_MP3_OFFSET_PTR(pcm, sizeof(ma_dr_mp3d_sample_t)*576*info->channels)) { MA_DR_MP3_ZERO_MEMORY(scratch.grbuf[0], 576*2*sizeof(float)); ma_dr_mp3_L3_decode(dec, &scratch, scratch.gr_info + igr*info->channels, info->channels); ma_dr_mp3d_synth_granule(dec->qmf_state, scratch.grbuf[0], 18, info->channels, (ma_dr_mp3d_sample_t*)pcm, scratch.syn[0]); } } ma_dr_mp3_L3_save_reservoir(dec, &scratch); } else { #ifdef MA_DR_MP3_ONLY_MP3 return 0; #else ma_dr_mp3_L12_scale_info sci[1]; if (pcm == NULL) { return ma_dr_mp3_hdr_frame_samples(hdr); } ma_dr_mp3_L12_read_scale_info(hdr, bs_frame, sci); MA_DR_MP3_ZERO_MEMORY(scratch.grbuf[0], 576*2*sizeof(float)); for (i = 0, igr = 0; igr < 3; igr++) { if (12 == (i += ma_dr_mp3_L12_dequantize_granule(scratch.grbuf[0] + i, bs_frame, sci, info->layer | 1))) { i = 0; ma_dr_mp3_L12_apply_scf_384(sci, sci->scf + igr, scratch.grbuf[0]); ma_dr_mp3d_synth_granule(dec->qmf_state, scratch.grbuf[0], 12, info->channels, (ma_dr_mp3d_sample_t*)pcm, scratch.syn[0]); MA_DR_MP3_ZERO_MEMORY(scratch.grbuf[0], 576*2*sizeof(float)); pcm = MA_DR_MP3_OFFSET_PTR(pcm, sizeof(ma_dr_mp3d_sample_t)*384*info->channels); } if (bs_frame->pos > bs_frame->limit) { ma_dr_mp3dec_init(dec); return 0; } } #endif } return success*ma_dr_mp3_hdr_frame_samples(dec->header); } MA_API void ma_dr_mp3dec_f32_to_s16(const float *in, ma_int16 *out, size_t num_samples) { size_t i = 0; #if MA_DR_MP3_HAVE_SIMD size_t aligned_count = num_samples & ~7; for(; i < aligned_count; i+=8) { ma_dr_mp3_f4 scale = MA_DR_MP3_VSET(32768.0f); ma_dr_mp3_f4 a = MA_DR_MP3_VMUL(MA_DR_MP3_VLD(&in[i ]), scale); ma_dr_mp3_f4 b = MA_DR_MP3_VMUL(MA_DR_MP3_VLD(&in[i+4]), scale); #if MA_DR_MP3_HAVE_SSE ma_dr_mp3_f4 s16max = MA_DR_MP3_VSET( 32767.0f); ma_dr_mp3_f4 s16min = MA_DR_MP3_VSET(-32768.0f); __m128i pcm8 = _mm_packs_epi32(_mm_cvtps_epi32(_mm_max_ps(_mm_min_ps(a, s16max), s16min)), _mm_cvtps_epi32(_mm_max_ps(_mm_min_ps(b, s16max), s16min))); out[i ] = (ma_int16)_mm_extract_epi16(pcm8, 0); out[i+1] = (ma_int16)_mm_extract_epi16(pcm8, 1); out[i+2] = (ma_int16)_mm_extract_epi16(pcm8, 2); out[i+3] = (ma_int16)_mm_extract_epi16(pcm8, 3); out[i+4] = (ma_int16)_mm_extract_epi16(pcm8, 4); out[i+5] = (ma_int16)_mm_extract_epi16(pcm8, 5); out[i+6] = (ma_int16)_mm_extract_epi16(pcm8, 6); out[i+7] = (ma_int16)_mm_extract_epi16(pcm8, 7); #else int16x4_t pcma, pcmb; a = MA_DR_MP3_VADD(a, MA_DR_MP3_VSET(0.5f)); b = MA_DR_MP3_VADD(b, MA_DR_MP3_VSET(0.5f)); pcma = vqmovn_s32(vqaddq_s32(vcvtq_s32_f32(a), vreinterpretq_s32_u32(vcltq_f32(a, MA_DR_MP3_VSET(0))))); pcmb = vqmovn_s32(vqaddq_s32(vcvtq_s32_f32(b), vreinterpretq_s32_u32(vcltq_f32(b, MA_DR_MP3_VSET(0))))); vst1_lane_s16(out+i , pcma, 0); vst1_lane_s16(out+i+1, pcma, 1); vst1_lane_s16(out+i+2, pcma, 2); vst1_lane_s16(out+i+3, pcma, 3); vst1_lane_s16(out+i+4, pcmb, 0); vst1_lane_s16(out+i+5, pcmb, 1); vst1_lane_s16(out+i+6, pcmb, 2); vst1_lane_s16(out+i+7, pcmb, 3); #endif } #endif for(; i < num_samples; i++) { float sample = in[i] * 32768.0f; if (sample >= 32766.5) out[i] = (ma_int16) 32767; else if (sample <= -32767.5) out[i] = (ma_int16)-32768; else { short s = (ma_int16)(sample + .5f); s -= (s < 0); out[i] = s; } } } #ifndef MA_DR_MP3_SEEK_LEADING_MP3_FRAMES #define MA_DR_MP3_SEEK_LEADING_MP3_FRAMES 2 #endif #define MA_DR_MP3_MIN_DATA_CHUNK_SIZE 16384 #ifndef MA_DR_MP3_DATA_CHUNK_SIZE #define MA_DR_MP3_DATA_CHUNK_SIZE (MA_DR_MP3_MIN_DATA_CHUNK_SIZE*4) #endif #define MA_DR_MP3_COUNTOF(x) (sizeof(x) / sizeof(x[0])) #define MA_DR_MP3_CLAMP(x, lo, hi) (MA_DR_MP3_MAX(lo, MA_DR_MP3_MIN(x, hi))) #ifndef MA_DR_MP3_PI_D #define MA_DR_MP3_PI_D 3.14159265358979323846264 #endif #define MA_DR_MP3_DEFAULT_RESAMPLER_LPF_ORDER 2 static MA_INLINE float ma_dr_mp3_mix_f32(float x, float y, float a) { return x*(1-a) + y*a; } static MA_INLINE float ma_dr_mp3_mix_f32_fast(float x, float y, float a) { float r0 = (y - x); float r1 = r0*a; return x + r1; } static MA_INLINE ma_uint32 ma_dr_mp3_gcf_u32(ma_uint32 a, ma_uint32 b) { for (;;) { if (b == 0) { break; } else { ma_uint32 t = a; a = b; b = t % a; } } return a; } static void* ma_dr_mp3__malloc_default(size_t sz, void* pUserData) { (void)pUserData; return MA_DR_MP3_MALLOC(sz); } static void* ma_dr_mp3__realloc_default(void* p, size_t sz, void* pUserData) { (void)pUserData; return MA_DR_MP3_REALLOC(p, sz); } static void ma_dr_mp3__free_default(void* p, void* pUserData) { (void)pUserData; MA_DR_MP3_FREE(p); } static void* ma_dr_mp3__malloc_from_callbacks(size_t sz, const ma_allocation_callbacks* pAllocationCallbacks) { if (pAllocationCallbacks == NULL) { return NULL; } if (pAllocationCallbacks->onMalloc != NULL) { return pAllocationCallbacks->onMalloc(sz, pAllocationCallbacks->pUserData); } if (pAllocationCallbacks->onRealloc != NULL) { return pAllocationCallbacks->onRealloc(NULL, sz, pAllocationCallbacks->pUserData); } return NULL; } static void* ma_dr_mp3__realloc_from_callbacks(void* p, size_t szNew, size_t szOld, const ma_allocation_callbacks* pAllocationCallbacks) { if (pAllocationCallbacks == NULL) { return NULL; } if (pAllocationCallbacks->onRealloc != NULL) { return pAllocationCallbacks->onRealloc(p, szNew, pAllocationCallbacks->pUserData); } if (pAllocationCallbacks->onMalloc != NULL && pAllocationCallbacks->onFree != NULL) { void* p2; p2 = pAllocationCallbacks->onMalloc(szNew, pAllocationCallbacks->pUserData); if (p2 == NULL) { return NULL; } if (p != NULL) { MA_DR_MP3_COPY_MEMORY(p2, p, szOld); pAllocationCallbacks->onFree(p, pAllocationCallbacks->pUserData); } return p2; } return NULL; } static void ma_dr_mp3__free_from_callbacks(void* p, const ma_allocation_callbacks* pAllocationCallbacks) { if (p == NULL || pAllocationCallbacks == NULL) { return; } if (pAllocationCallbacks->onFree != NULL) { pAllocationCallbacks->onFree(p, pAllocationCallbacks->pUserData); } } static ma_allocation_callbacks ma_dr_mp3_copy_allocation_callbacks_or_defaults(const ma_allocation_callbacks* pAllocationCallbacks) { if (pAllocationCallbacks != NULL) { return *pAllocationCallbacks; } else { ma_allocation_callbacks allocationCallbacks; allocationCallbacks.pUserData = NULL; allocationCallbacks.onMalloc = ma_dr_mp3__malloc_default; allocationCallbacks.onRealloc = ma_dr_mp3__realloc_default; allocationCallbacks.onFree = ma_dr_mp3__free_default; return allocationCallbacks; } } static size_t ma_dr_mp3__on_read(ma_dr_mp3* pMP3, void* pBufferOut, size_t bytesToRead) { size_t bytesRead = pMP3->onRead(pMP3->pUserData, pBufferOut, bytesToRead); pMP3->streamCursor += bytesRead; return bytesRead; } static ma_bool32 ma_dr_mp3__on_seek(ma_dr_mp3* pMP3, int offset, ma_dr_mp3_seek_origin origin) { MA_DR_MP3_ASSERT(offset >= 0); if (!pMP3->onSeek(pMP3->pUserData, offset, origin)) { return MA_FALSE; } if (origin == ma_dr_mp3_seek_origin_start) { pMP3->streamCursor = (ma_uint64)offset; } else { pMP3->streamCursor += offset; } return MA_TRUE; } static ma_bool32 ma_dr_mp3__on_seek_64(ma_dr_mp3* pMP3, ma_uint64 offset, ma_dr_mp3_seek_origin origin) { if (offset <= 0x7FFFFFFF) { return ma_dr_mp3__on_seek(pMP3, (int)offset, origin); } if (!ma_dr_mp3__on_seek(pMP3, 0x7FFFFFFF, ma_dr_mp3_seek_origin_start)) { return MA_FALSE; } offset -= 0x7FFFFFFF; while (offset > 0) { if (offset <= 0x7FFFFFFF) { if (!ma_dr_mp3__on_seek(pMP3, (int)offset, ma_dr_mp3_seek_origin_current)) { return MA_FALSE; } offset = 0; } else { if (!ma_dr_mp3__on_seek(pMP3, 0x7FFFFFFF, ma_dr_mp3_seek_origin_current)) { return MA_FALSE; } offset -= 0x7FFFFFFF; } } return MA_TRUE; } static ma_uint32 ma_dr_mp3_decode_next_frame_ex__callbacks(ma_dr_mp3* pMP3, ma_dr_mp3d_sample_t* pPCMFrames) { ma_uint32 pcmFramesRead = 0; MA_DR_MP3_ASSERT(pMP3 != NULL); MA_DR_MP3_ASSERT(pMP3->onRead != NULL); if (pMP3->atEnd) { return 0; } for (;;) { ma_dr_mp3dec_frame_info info; if (pMP3->dataSize < MA_DR_MP3_MIN_DATA_CHUNK_SIZE) { size_t bytesRead; if (pMP3->pData != NULL) { MA_DR_MP3_MOVE_MEMORY(pMP3->pData, pMP3->pData + pMP3->dataConsumed, pMP3->dataSize); } pMP3->dataConsumed = 0; if (pMP3->dataCapacity < MA_DR_MP3_DATA_CHUNK_SIZE) { ma_uint8* pNewData; size_t newDataCap; newDataCap = MA_DR_MP3_DATA_CHUNK_SIZE; pNewData = (ma_uint8*)ma_dr_mp3__realloc_from_callbacks(pMP3->pData, newDataCap, pMP3->dataCapacity, &pMP3->allocationCallbacks); if (pNewData == NULL) { return 0; } pMP3->pData = pNewData; pMP3->dataCapacity = newDataCap; } bytesRead = ma_dr_mp3__on_read(pMP3, pMP3->pData + pMP3->dataSize, (pMP3->dataCapacity - pMP3->dataSize)); if (bytesRead == 0) { if (pMP3->dataSize == 0) { pMP3->atEnd = MA_TRUE; return 0; } } pMP3->dataSize += bytesRead; } if (pMP3->dataSize > INT_MAX) { pMP3->atEnd = MA_TRUE; return 0; } MA_DR_MP3_ASSERT(pMP3->pData != NULL); MA_DR_MP3_ASSERT(pMP3->dataCapacity > 0); if (pMP3->pData == NULL) { return 0; } pcmFramesRead = ma_dr_mp3dec_decode_frame(&pMP3->decoder, pMP3->pData + pMP3->dataConsumed, (int)pMP3->dataSize, pPCMFrames, &info); if (info.frame_bytes > 0) { pMP3->dataConsumed += (size_t)info.frame_bytes; pMP3->dataSize -= (size_t)info.frame_bytes; } if (pcmFramesRead > 0) { pcmFramesRead = ma_dr_mp3_hdr_frame_samples(pMP3->decoder.header); pMP3->pcmFramesConsumedInMP3Frame = 0; pMP3->pcmFramesRemainingInMP3Frame = pcmFramesRead; pMP3->mp3FrameChannels = info.channels; pMP3->mp3FrameSampleRate = info.hz; break; } else if (info.frame_bytes == 0) { size_t bytesRead; MA_DR_MP3_MOVE_MEMORY(pMP3->pData, pMP3->pData + pMP3->dataConsumed, pMP3->dataSize); pMP3->dataConsumed = 0; if (pMP3->dataCapacity == pMP3->dataSize) { ma_uint8* pNewData; size_t newDataCap; newDataCap = pMP3->dataCapacity + MA_DR_MP3_DATA_CHUNK_SIZE; pNewData = (ma_uint8*)ma_dr_mp3__realloc_from_callbacks(pMP3->pData, newDataCap, pMP3->dataCapacity, &pMP3->allocationCallbacks); if (pNewData == NULL) { return 0; } pMP3->pData = pNewData; pMP3->dataCapacity = newDataCap; } bytesRead = ma_dr_mp3__on_read(pMP3, pMP3->pData + pMP3->dataSize, (pMP3->dataCapacity - pMP3->dataSize)); if (bytesRead == 0) { pMP3->atEnd = MA_TRUE; return 0; } pMP3->dataSize += bytesRead; } }; return pcmFramesRead; } static ma_uint32 ma_dr_mp3_decode_next_frame_ex__memory(ma_dr_mp3* pMP3, ma_dr_mp3d_sample_t* pPCMFrames) { ma_uint32 pcmFramesRead = 0; ma_dr_mp3dec_frame_info info; MA_DR_MP3_ASSERT(pMP3 != NULL); MA_DR_MP3_ASSERT(pMP3->memory.pData != NULL); if (pMP3->atEnd) { return 0; } for (;;) { pcmFramesRead = ma_dr_mp3dec_decode_frame(&pMP3->decoder, pMP3->memory.pData + pMP3->memory.currentReadPos, (int)(pMP3->memory.dataSize - pMP3->memory.currentReadPos), pPCMFrames, &info); if (pcmFramesRead > 0) { pcmFramesRead = ma_dr_mp3_hdr_frame_samples(pMP3->decoder.header); pMP3->pcmFramesConsumedInMP3Frame = 0; pMP3->pcmFramesRemainingInMP3Frame = pcmFramesRead; pMP3->mp3FrameChannels = info.channels; pMP3->mp3FrameSampleRate = info.hz; break; } else if (info.frame_bytes > 0) { pMP3->memory.currentReadPos += (size_t)info.frame_bytes; } else { break; } } pMP3->memory.currentReadPos += (size_t)info.frame_bytes; return pcmFramesRead; } static ma_uint32 ma_dr_mp3_decode_next_frame_ex(ma_dr_mp3* pMP3, ma_dr_mp3d_sample_t* pPCMFrames) { if (pMP3->memory.pData != NULL && pMP3->memory.dataSize > 0) { return ma_dr_mp3_decode_next_frame_ex__memory(pMP3, pPCMFrames); } else { return ma_dr_mp3_decode_next_frame_ex__callbacks(pMP3, pPCMFrames); } } static ma_uint32 ma_dr_mp3_decode_next_frame(ma_dr_mp3* pMP3) { MA_DR_MP3_ASSERT(pMP3 != NULL); return ma_dr_mp3_decode_next_frame_ex(pMP3, (ma_dr_mp3d_sample_t*)pMP3->pcmFrames); } #if 0 static ma_uint32 ma_dr_mp3_seek_next_frame(ma_dr_mp3* pMP3) { ma_uint32 pcmFrameCount; MA_DR_MP3_ASSERT(pMP3 != NULL); pcmFrameCount = ma_dr_mp3_decode_next_frame_ex(pMP3, NULL); if (pcmFrameCount == 0) { return 0; } pMP3->currentPCMFrame += pcmFrameCount; pMP3->pcmFramesConsumedInMP3Frame = pcmFrameCount; pMP3->pcmFramesRemainingInMP3Frame = 0; return pcmFrameCount; } #endif static ma_bool32 ma_dr_mp3_init_internal(ma_dr_mp3* pMP3, ma_dr_mp3_read_proc onRead, ma_dr_mp3_seek_proc onSeek, void* pUserData, const ma_allocation_callbacks* pAllocationCallbacks) { MA_DR_MP3_ASSERT(pMP3 != NULL); MA_DR_MP3_ASSERT(onRead != NULL); ma_dr_mp3dec_init(&pMP3->decoder); pMP3->onRead = onRead; pMP3->onSeek = onSeek; pMP3->pUserData = pUserData; pMP3->allocationCallbacks = ma_dr_mp3_copy_allocation_callbacks_or_defaults(pAllocationCallbacks); if (pMP3->allocationCallbacks.onFree == NULL || (pMP3->allocationCallbacks.onMalloc == NULL && pMP3->allocationCallbacks.onRealloc == NULL)) { return MA_FALSE; } if (ma_dr_mp3_decode_next_frame(pMP3) == 0) { ma_dr_mp3__free_from_callbacks(pMP3->pData, &pMP3->allocationCallbacks); return MA_FALSE; } pMP3->channels = pMP3->mp3FrameChannels; pMP3->sampleRate = pMP3->mp3FrameSampleRate; return MA_TRUE; } MA_API ma_bool32 ma_dr_mp3_init(ma_dr_mp3* pMP3, ma_dr_mp3_read_proc onRead, ma_dr_mp3_seek_proc onSeek, void* pUserData, const ma_allocation_callbacks* pAllocationCallbacks) { if (pMP3 == NULL || onRead == NULL) { return MA_FALSE; } MA_DR_MP3_ZERO_OBJECT(pMP3); return ma_dr_mp3_init_internal(pMP3, onRead, onSeek, pUserData, pAllocationCallbacks); } static size_t ma_dr_mp3__on_read_memory(void* pUserData, void* pBufferOut, size_t bytesToRead) { ma_dr_mp3* pMP3 = (ma_dr_mp3*)pUserData; size_t bytesRemaining; MA_DR_MP3_ASSERT(pMP3 != NULL); MA_DR_MP3_ASSERT(pMP3->memory.dataSize >= pMP3->memory.currentReadPos); bytesRemaining = pMP3->memory.dataSize - pMP3->memory.currentReadPos; if (bytesToRead > bytesRemaining) { bytesToRead = bytesRemaining; } if (bytesToRead > 0) { MA_DR_MP3_COPY_MEMORY(pBufferOut, pMP3->memory.pData + pMP3->memory.currentReadPos, bytesToRead); pMP3->memory.currentReadPos += bytesToRead; } return bytesToRead; } static ma_bool32 ma_dr_mp3__on_seek_memory(void* pUserData, int byteOffset, ma_dr_mp3_seek_origin origin) { ma_dr_mp3* pMP3 = (ma_dr_mp3*)pUserData; MA_DR_MP3_ASSERT(pMP3 != NULL); if (origin == ma_dr_mp3_seek_origin_current) { if (byteOffset > 0) { if (pMP3->memory.currentReadPos + byteOffset > pMP3->memory.dataSize) { byteOffset = (int)(pMP3->memory.dataSize - pMP3->memory.currentReadPos); } } else { if (pMP3->memory.currentReadPos < (size_t)-byteOffset) { byteOffset = -(int)pMP3->memory.currentReadPos; } } pMP3->memory.currentReadPos += byteOffset; } else { if ((ma_uint32)byteOffset <= pMP3->memory.dataSize) { pMP3->memory.currentReadPos = byteOffset; } else { pMP3->memory.currentReadPos = pMP3->memory.dataSize; } } return MA_TRUE; } MA_API ma_bool32 ma_dr_mp3_init_memory(ma_dr_mp3* pMP3, const void* pData, size_t dataSize, const ma_allocation_callbacks* pAllocationCallbacks) { if (pMP3 == NULL) { return MA_FALSE; } MA_DR_MP3_ZERO_OBJECT(pMP3); if (pData == NULL || dataSize == 0) { return MA_FALSE; } pMP3->memory.pData = (const ma_uint8*)pData; pMP3->memory.dataSize = dataSize; pMP3->memory.currentReadPos = 0; return ma_dr_mp3_init_internal(pMP3, ma_dr_mp3__on_read_memory, ma_dr_mp3__on_seek_memory, pMP3, pAllocationCallbacks); } #ifndef MA_DR_MP3_NO_STDIO #include #include static size_t ma_dr_mp3__on_read_stdio(void* pUserData, void* pBufferOut, size_t bytesToRead) { return fread(pBufferOut, 1, bytesToRead, (FILE*)pUserData); } static ma_bool32 ma_dr_mp3__on_seek_stdio(void* pUserData, int offset, ma_dr_mp3_seek_origin origin) { return fseek((FILE*)pUserData, offset, (origin == ma_dr_mp3_seek_origin_current) ? SEEK_CUR : SEEK_SET) == 0; } MA_API ma_bool32 ma_dr_mp3_init_file(ma_dr_mp3* pMP3, const char* pFilePath, const ma_allocation_callbacks* pAllocationCallbacks) { ma_bool32 result; FILE* pFile; if (ma_fopen(&pFile, pFilePath, "rb") != MA_SUCCESS) { return MA_FALSE; } result = ma_dr_mp3_init(pMP3, ma_dr_mp3__on_read_stdio, ma_dr_mp3__on_seek_stdio, (void*)pFile, pAllocationCallbacks); if (result != MA_TRUE) { fclose(pFile); return result; } return MA_TRUE; } MA_API ma_bool32 ma_dr_mp3_init_file_w(ma_dr_mp3* pMP3, const wchar_t* pFilePath, const ma_allocation_callbacks* pAllocationCallbacks) { ma_bool32 result; FILE* pFile; if (ma_wfopen(&pFile, pFilePath, L"rb", pAllocationCallbacks) != MA_SUCCESS) { return MA_FALSE; } result = ma_dr_mp3_init(pMP3, ma_dr_mp3__on_read_stdio, ma_dr_mp3__on_seek_stdio, (void*)pFile, pAllocationCallbacks); if (result != MA_TRUE) { fclose(pFile); return result; } return MA_TRUE; } #endif MA_API void ma_dr_mp3_uninit(ma_dr_mp3* pMP3) { if (pMP3 == NULL) { return; } #ifndef MA_DR_MP3_NO_STDIO if (pMP3->onRead == ma_dr_mp3__on_read_stdio) { FILE* pFile = (FILE*)pMP3->pUserData; if (pFile != NULL) { fclose(pFile); pMP3->pUserData = NULL; } } #endif ma_dr_mp3__free_from_callbacks(pMP3->pData, &pMP3->allocationCallbacks); } #if defined(MA_DR_MP3_FLOAT_OUTPUT) static void ma_dr_mp3_f32_to_s16(ma_int16* dst, const float* src, ma_uint64 sampleCount) { ma_uint64 i; ma_uint64 i4; ma_uint64 sampleCount4; i = 0; sampleCount4 = sampleCount >> 2; for (i4 = 0; i4 < sampleCount4; i4 += 1) { float x0 = src[i+0]; float x1 = src[i+1]; float x2 = src[i+2]; float x3 = src[i+3]; x0 = ((x0 < -1) ? -1 : ((x0 > 1) ? 1 : x0)); x1 = ((x1 < -1) ? -1 : ((x1 > 1) ? 1 : x1)); x2 = ((x2 < -1) ? -1 : ((x2 > 1) ? 1 : x2)); x3 = ((x3 < -1) ? -1 : ((x3 > 1) ? 1 : x3)); x0 = x0 * 32767.0f; x1 = x1 * 32767.0f; x2 = x2 * 32767.0f; x3 = x3 * 32767.0f; dst[i+0] = (ma_int16)x0; dst[i+1] = (ma_int16)x1; dst[i+2] = (ma_int16)x2; dst[i+3] = (ma_int16)x3; i += 4; } for (; i < sampleCount; i += 1) { float x = src[i]; x = ((x < -1) ? -1 : ((x > 1) ? 1 : x)); x = x * 32767.0f; dst[i] = (ma_int16)x; } } #endif #if !defined(MA_DR_MP3_FLOAT_OUTPUT) static void ma_dr_mp3_s16_to_f32(float* dst, const ma_int16* src, ma_uint64 sampleCount) { ma_uint64 i; for (i = 0; i < sampleCount; i += 1) { float x = (float)src[i]; x = x * 0.000030517578125f; dst[i] = x; } } #endif static ma_uint64 ma_dr_mp3_read_pcm_frames_raw(ma_dr_mp3* pMP3, ma_uint64 framesToRead, void* pBufferOut) { ma_uint64 totalFramesRead = 0; MA_DR_MP3_ASSERT(pMP3 != NULL); MA_DR_MP3_ASSERT(pMP3->onRead != NULL); while (framesToRead > 0) { ma_uint32 framesToConsume = (ma_uint32)MA_DR_MP3_MIN(pMP3->pcmFramesRemainingInMP3Frame, framesToRead); if (pBufferOut != NULL) { #if defined(MA_DR_MP3_FLOAT_OUTPUT) float* pFramesOutF32 = (float*)MA_DR_MP3_OFFSET_PTR(pBufferOut, sizeof(float) * totalFramesRead * pMP3->channels); float* pFramesInF32 = (float*)MA_DR_MP3_OFFSET_PTR(&pMP3->pcmFrames[0], sizeof(float) * pMP3->pcmFramesConsumedInMP3Frame * pMP3->mp3FrameChannels); MA_DR_MP3_COPY_MEMORY(pFramesOutF32, pFramesInF32, sizeof(float) * framesToConsume * pMP3->channels); #else ma_int16* pFramesOutS16 = (ma_int16*)MA_DR_MP3_OFFSET_PTR(pBufferOut, sizeof(ma_int16) * totalFramesRead * pMP3->channels); ma_int16* pFramesInS16 = (ma_int16*)MA_DR_MP3_OFFSET_PTR(&pMP3->pcmFrames[0], sizeof(ma_int16) * pMP3->pcmFramesConsumedInMP3Frame * pMP3->mp3FrameChannels); MA_DR_MP3_COPY_MEMORY(pFramesOutS16, pFramesInS16, sizeof(ma_int16) * framesToConsume * pMP3->channels); #endif } pMP3->currentPCMFrame += framesToConsume; pMP3->pcmFramesConsumedInMP3Frame += framesToConsume; pMP3->pcmFramesRemainingInMP3Frame -= framesToConsume; totalFramesRead += framesToConsume; framesToRead -= framesToConsume; if (framesToRead == 0) { break; } MA_DR_MP3_ASSERT(pMP3->pcmFramesRemainingInMP3Frame == 0); if (ma_dr_mp3_decode_next_frame(pMP3) == 0) { break; } } return totalFramesRead; } MA_API ma_uint64 ma_dr_mp3_read_pcm_frames_f32(ma_dr_mp3* pMP3, ma_uint64 framesToRead, float* pBufferOut) { if (pMP3 == NULL || pMP3->onRead == NULL) { return 0; } #if defined(MA_DR_MP3_FLOAT_OUTPUT) return ma_dr_mp3_read_pcm_frames_raw(pMP3, framesToRead, pBufferOut); #else { ma_int16 pTempS16[8192]; ma_uint64 totalPCMFramesRead = 0; while (totalPCMFramesRead < framesToRead) { ma_uint64 framesJustRead; ma_uint64 framesRemaining = framesToRead - totalPCMFramesRead; ma_uint64 framesToReadNow = MA_DR_MP3_COUNTOF(pTempS16) / pMP3->channels; if (framesToReadNow > framesRemaining) { framesToReadNow = framesRemaining; } framesJustRead = ma_dr_mp3_read_pcm_frames_raw(pMP3, framesToReadNow, pTempS16); if (framesJustRead == 0) { break; } ma_dr_mp3_s16_to_f32((float*)MA_DR_MP3_OFFSET_PTR(pBufferOut, sizeof(float) * totalPCMFramesRead * pMP3->channels), pTempS16, framesJustRead * pMP3->channels); totalPCMFramesRead += framesJustRead; } return totalPCMFramesRead; } #endif } MA_API ma_uint64 ma_dr_mp3_read_pcm_frames_s16(ma_dr_mp3* pMP3, ma_uint64 framesToRead, ma_int16* pBufferOut) { if (pMP3 == NULL || pMP3->onRead == NULL) { return 0; } #if !defined(MA_DR_MP3_FLOAT_OUTPUT) return ma_dr_mp3_read_pcm_frames_raw(pMP3, framesToRead, pBufferOut); #else { float pTempF32[4096]; ma_uint64 totalPCMFramesRead = 0; while (totalPCMFramesRead < framesToRead) { ma_uint64 framesJustRead; ma_uint64 framesRemaining = framesToRead - totalPCMFramesRead; ma_uint64 framesToReadNow = MA_DR_MP3_COUNTOF(pTempF32) / pMP3->channels; if (framesToReadNow > framesRemaining) { framesToReadNow = framesRemaining; } framesJustRead = ma_dr_mp3_read_pcm_frames_raw(pMP3, framesToReadNow, pTempF32); if (framesJustRead == 0) { break; } ma_dr_mp3_f32_to_s16((ma_int16*)MA_DR_MP3_OFFSET_PTR(pBufferOut, sizeof(ma_int16) * totalPCMFramesRead * pMP3->channels), pTempF32, framesJustRead * pMP3->channels); totalPCMFramesRead += framesJustRead; } return totalPCMFramesRead; } #endif } static void ma_dr_mp3_reset(ma_dr_mp3* pMP3) { MA_DR_MP3_ASSERT(pMP3 != NULL); pMP3->pcmFramesConsumedInMP3Frame = 0; pMP3->pcmFramesRemainingInMP3Frame = 0; pMP3->currentPCMFrame = 0; pMP3->dataSize = 0; pMP3->atEnd = MA_FALSE; ma_dr_mp3dec_init(&pMP3->decoder); } static ma_bool32 ma_dr_mp3_seek_to_start_of_stream(ma_dr_mp3* pMP3) { MA_DR_MP3_ASSERT(pMP3 != NULL); MA_DR_MP3_ASSERT(pMP3->onSeek != NULL); if (!ma_dr_mp3__on_seek(pMP3, 0, ma_dr_mp3_seek_origin_start)) { return MA_FALSE; } ma_dr_mp3_reset(pMP3); return MA_TRUE; } static ma_bool32 ma_dr_mp3_seek_forward_by_pcm_frames__brute_force(ma_dr_mp3* pMP3, ma_uint64 frameOffset) { ma_uint64 framesRead; #if defined(MA_DR_MP3_FLOAT_OUTPUT) framesRead = ma_dr_mp3_read_pcm_frames_f32(pMP3, frameOffset, NULL); #else framesRead = ma_dr_mp3_read_pcm_frames_s16(pMP3, frameOffset, NULL); #endif if (framesRead != frameOffset) { return MA_FALSE; } return MA_TRUE; } static ma_bool32 ma_dr_mp3_seek_to_pcm_frame__brute_force(ma_dr_mp3* pMP3, ma_uint64 frameIndex) { MA_DR_MP3_ASSERT(pMP3 != NULL); if (frameIndex == pMP3->currentPCMFrame) { return MA_TRUE; } if (frameIndex < pMP3->currentPCMFrame) { if (!ma_dr_mp3_seek_to_start_of_stream(pMP3)) { return MA_FALSE; } } MA_DR_MP3_ASSERT(frameIndex >= pMP3->currentPCMFrame); return ma_dr_mp3_seek_forward_by_pcm_frames__brute_force(pMP3, (frameIndex - pMP3->currentPCMFrame)); } static ma_bool32 ma_dr_mp3_find_closest_seek_point(ma_dr_mp3* pMP3, ma_uint64 frameIndex, ma_uint32* pSeekPointIndex) { ma_uint32 iSeekPoint; MA_DR_MP3_ASSERT(pSeekPointIndex != NULL); *pSeekPointIndex = 0; if (frameIndex < pMP3->pSeekPoints[0].pcmFrameIndex) { return MA_FALSE; } for (iSeekPoint = 0; iSeekPoint < pMP3->seekPointCount; ++iSeekPoint) { if (pMP3->pSeekPoints[iSeekPoint].pcmFrameIndex > frameIndex) { break; } *pSeekPointIndex = iSeekPoint; } return MA_TRUE; } static ma_bool32 ma_dr_mp3_seek_to_pcm_frame__seek_table(ma_dr_mp3* pMP3, ma_uint64 frameIndex) { ma_dr_mp3_seek_point seekPoint; ma_uint32 priorSeekPointIndex; ma_uint16 iMP3Frame; ma_uint64 leftoverFrames; MA_DR_MP3_ASSERT(pMP3 != NULL); MA_DR_MP3_ASSERT(pMP3->pSeekPoints != NULL); MA_DR_MP3_ASSERT(pMP3->seekPointCount > 0); if (ma_dr_mp3_find_closest_seek_point(pMP3, frameIndex, &priorSeekPointIndex)) { seekPoint = pMP3->pSeekPoints[priorSeekPointIndex]; } else { seekPoint.seekPosInBytes = 0; seekPoint.pcmFrameIndex = 0; seekPoint.mp3FramesToDiscard = 0; seekPoint.pcmFramesToDiscard = 0; } if (!ma_dr_mp3__on_seek_64(pMP3, seekPoint.seekPosInBytes, ma_dr_mp3_seek_origin_start)) { return MA_FALSE; } ma_dr_mp3_reset(pMP3); for (iMP3Frame = 0; iMP3Frame < seekPoint.mp3FramesToDiscard; ++iMP3Frame) { ma_uint32 pcmFramesRead; ma_dr_mp3d_sample_t* pPCMFrames; pPCMFrames = NULL; if (iMP3Frame == seekPoint.mp3FramesToDiscard-1) { pPCMFrames = (ma_dr_mp3d_sample_t*)pMP3->pcmFrames; } pcmFramesRead = ma_dr_mp3_decode_next_frame_ex(pMP3, pPCMFrames); if (pcmFramesRead == 0) { return MA_FALSE; } } pMP3->currentPCMFrame = seekPoint.pcmFrameIndex - seekPoint.pcmFramesToDiscard; leftoverFrames = frameIndex - pMP3->currentPCMFrame; return ma_dr_mp3_seek_forward_by_pcm_frames__brute_force(pMP3, leftoverFrames); } MA_API ma_bool32 ma_dr_mp3_seek_to_pcm_frame(ma_dr_mp3* pMP3, ma_uint64 frameIndex) { if (pMP3 == NULL || pMP3->onSeek == NULL) { return MA_FALSE; } if (frameIndex == 0) { return ma_dr_mp3_seek_to_start_of_stream(pMP3); } if (pMP3->pSeekPoints != NULL && pMP3->seekPointCount > 0) { return ma_dr_mp3_seek_to_pcm_frame__seek_table(pMP3, frameIndex); } else { return ma_dr_mp3_seek_to_pcm_frame__brute_force(pMP3, frameIndex); } } MA_API ma_bool32 ma_dr_mp3_get_mp3_and_pcm_frame_count(ma_dr_mp3* pMP3, ma_uint64* pMP3FrameCount, ma_uint64* pPCMFrameCount) { ma_uint64 currentPCMFrame; ma_uint64 totalPCMFrameCount; ma_uint64 totalMP3FrameCount; if (pMP3 == NULL) { return MA_FALSE; } if (pMP3->onSeek == NULL) { return MA_FALSE; } currentPCMFrame = pMP3->currentPCMFrame; if (!ma_dr_mp3_seek_to_start_of_stream(pMP3)) { return MA_FALSE; } totalPCMFrameCount = 0; totalMP3FrameCount = 0; for (;;) { ma_uint32 pcmFramesInCurrentMP3Frame; pcmFramesInCurrentMP3Frame = ma_dr_mp3_decode_next_frame_ex(pMP3, NULL); if (pcmFramesInCurrentMP3Frame == 0) { break; } totalPCMFrameCount += pcmFramesInCurrentMP3Frame; totalMP3FrameCount += 1; } if (!ma_dr_mp3_seek_to_start_of_stream(pMP3)) { return MA_FALSE; } if (!ma_dr_mp3_seek_to_pcm_frame(pMP3, currentPCMFrame)) { return MA_FALSE; } if (pMP3FrameCount != NULL) { *pMP3FrameCount = totalMP3FrameCount; } if (pPCMFrameCount != NULL) { *pPCMFrameCount = totalPCMFrameCount; } return MA_TRUE; } MA_API ma_uint64 ma_dr_mp3_get_pcm_frame_count(ma_dr_mp3* pMP3) { ma_uint64 totalPCMFrameCount; if (!ma_dr_mp3_get_mp3_and_pcm_frame_count(pMP3, NULL, &totalPCMFrameCount)) { return 0; } return totalPCMFrameCount; } MA_API ma_uint64 ma_dr_mp3_get_mp3_frame_count(ma_dr_mp3* pMP3) { ma_uint64 totalMP3FrameCount; if (!ma_dr_mp3_get_mp3_and_pcm_frame_count(pMP3, &totalMP3FrameCount, NULL)) { return 0; } return totalMP3FrameCount; } static void ma_dr_mp3__accumulate_running_pcm_frame_count(ma_dr_mp3* pMP3, ma_uint32 pcmFrameCountIn, ma_uint64* pRunningPCMFrameCount, float* pRunningPCMFrameCountFractionalPart) { float srcRatio; float pcmFrameCountOutF; ma_uint32 pcmFrameCountOut; srcRatio = (float)pMP3->mp3FrameSampleRate / (float)pMP3->sampleRate; MA_DR_MP3_ASSERT(srcRatio > 0); pcmFrameCountOutF = *pRunningPCMFrameCountFractionalPart + (pcmFrameCountIn / srcRatio); pcmFrameCountOut = (ma_uint32)pcmFrameCountOutF; *pRunningPCMFrameCountFractionalPart = pcmFrameCountOutF - pcmFrameCountOut; *pRunningPCMFrameCount += pcmFrameCountOut; } typedef struct { ma_uint64 bytePos; ma_uint64 pcmFrameIndex; } ma_dr_mp3__seeking_mp3_frame_info; MA_API ma_bool32 ma_dr_mp3_calculate_seek_points(ma_dr_mp3* pMP3, ma_uint32* pSeekPointCount, ma_dr_mp3_seek_point* pSeekPoints) { ma_uint32 seekPointCount; ma_uint64 currentPCMFrame; ma_uint64 totalMP3FrameCount; ma_uint64 totalPCMFrameCount; if (pMP3 == NULL || pSeekPointCount == NULL || pSeekPoints == NULL) { return MA_FALSE; } seekPointCount = *pSeekPointCount; if (seekPointCount == 0) { return MA_FALSE; } currentPCMFrame = pMP3->currentPCMFrame; if (!ma_dr_mp3_get_mp3_and_pcm_frame_count(pMP3, &totalMP3FrameCount, &totalPCMFrameCount)) { return MA_FALSE; } if (totalMP3FrameCount < MA_DR_MP3_SEEK_LEADING_MP3_FRAMES+1) { seekPointCount = 1; pSeekPoints[0].seekPosInBytes = 0; pSeekPoints[0].pcmFrameIndex = 0; pSeekPoints[0].mp3FramesToDiscard = 0; pSeekPoints[0].pcmFramesToDiscard = 0; } else { ma_uint64 pcmFramesBetweenSeekPoints; ma_dr_mp3__seeking_mp3_frame_info mp3FrameInfo[MA_DR_MP3_SEEK_LEADING_MP3_FRAMES+1]; ma_uint64 runningPCMFrameCount = 0; float runningPCMFrameCountFractionalPart = 0; ma_uint64 nextTargetPCMFrame; ma_uint32 iMP3Frame; ma_uint32 iSeekPoint; if (seekPointCount > totalMP3FrameCount-1) { seekPointCount = (ma_uint32)totalMP3FrameCount-1; } pcmFramesBetweenSeekPoints = totalPCMFrameCount / (seekPointCount+1); if (!ma_dr_mp3_seek_to_start_of_stream(pMP3)) { return MA_FALSE; } for (iMP3Frame = 0; iMP3Frame < MA_DR_MP3_SEEK_LEADING_MP3_FRAMES+1; ++iMP3Frame) { ma_uint32 pcmFramesInCurrentMP3FrameIn; MA_DR_MP3_ASSERT(pMP3->streamCursor >= pMP3->dataSize); mp3FrameInfo[iMP3Frame].bytePos = pMP3->streamCursor - pMP3->dataSize; mp3FrameInfo[iMP3Frame].pcmFrameIndex = runningPCMFrameCount; pcmFramesInCurrentMP3FrameIn = ma_dr_mp3_decode_next_frame_ex(pMP3, NULL); if (pcmFramesInCurrentMP3FrameIn == 0) { return MA_FALSE; } ma_dr_mp3__accumulate_running_pcm_frame_count(pMP3, pcmFramesInCurrentMP3FrameIn, &runningPCMFrameCount, &runningPCMFrameCountFractionalPart); } nextTargetPCMFrame = 0; for (iSeekPoint = 0; iSeekPoint < seekPointCount; ++iSeekPoint) { nextTargetPCMFrame += pcmFramesBetweenSeekPoints; for (;;) { if (nextTargetPCMFrame < runningPCMFrameCount) { pSeekPoints[iSeekPoint].seekPosInBytes = mp3FrameInfo[0].bytePos; pSeekPoints[iSeekPoint].pcmFrameIndex = nextTargetPCMFrame; pSeekPoints[iSeekPoint].mp3FramesToDiscard = MA_DR_MP3_SEEK_LEADING_MP3_FRAMES; pSeekPoints[iSeekPoint].pcmFramesToDiscard = (ma_uint16)(nextTargetPCMFrame - mp3FrameInfo[MA_DR_MP3_SEEK_LEADING_MP3_FRAMES-1].pcmFrameIndex); break; } else { size_t i; ma_uint32 pcmFramesInCurrentMP3FrameIn; for (i = 0; i < MA_DR_MP3_COUNTOF(mp3FrameInfo)-1; ++i) { mp3FrameInfo[i] = mp3FrameInfo[i+1]; } mp3FrameInfo[MA_DR_MP3_COUNTOF(mp3FrameInfo)-1].bytePos = pMP3->streamCursor - pMP3->dataSize; mp3FrameInfo[MA_DR_MP3_COUNTOF(mp3FrameInfo)-1].pcmFrameIndex = runningPCMFrameCount; pcmFramesInCurrentMP3FrameIn = ma_dr_mp3_decode_next_frame_ex(pMP3, NULL); if (pcmFramesInCurrentMP3FrameIn == 0) { pSeekPoints[iSeekPoint].seekPosInBytes = mp3FrameInfo[0].bytePos; pSeekPoints[iSeekPoint].pcmFrameIndex = nextTargetPCMFrame; pSeekPoints[iSeekPoint].mp3FramesToDiscard = MA_DR_MP3_SEEK_LEADING_MP3_FRAMES; pSeekPoints[iSeekPoint].pcmFramesToDiscard = (ma_uint16)(nextTargetPCMFrame - mp3FrameInfo[MA_DR_MP3_SEEK_LEADING_MP3_FRAMES-1].pcmFrameIndex); break; } ma_dr_mp3__accumulate_running_pcm_frame_count(pMP3, pcmFramesInCurrentMP3FrameIn, &runningPCMFrameCount, &runningPCMFrameCountFractionalPart); } } } if (!ma_dr_mp3_seek_to_start_of_stream(pMP3)) { return MA_FALSE; } if (!ma_dr_mp3_seek_to_pcm_frame(pMP3, currentPCMFrame)) { return MA_FALSE; } } *pSeekPointCount = seekPointCount; return MA_TRUE; } MA_API ma_bool32 ma_dr_mp3_bind_seek_table(ma_dr_mp3* pMP3, ma_uint32 seekPointCount, ma_dr_mp3_seek_point* pSeekPoints) { if (pMP3 == NULL) { return MA_FALSE; } if (seekPointCount == 0 || pSeekPoints == NULL) { pMP3->seekPointCount = 0; pMP3->pSeekPoints = NULL; } else { pMP3->seekPointCount = seekPointCount; pMP3->pSeekPoints = pSeekPoints; } return MA_TRUE; } static float* ma_dr_mp3__full_read_and_close_f32(ma_dr_mp3* pMP3, ma_dr_mp3_config* pConfig, ma_uint64* pTotalFrameCount) { ma_uint64 totalFramesRead = 0; ma_uint64 framesCapacity = 0; float* pFrames = NULL; float temp[4096]; MA_DR_MP3_ASSERT(pMP3 != NULL); for (;;) { ma_uint64 framesToReadRightNow = MA_DR_MP3_COUNTOF(temp) / pMP3->channels; ma_uint64 framesJustRead = ma_dr_mp3_read_pcm_frames_f32(pMP3, framesToReadRightNow, temp); if (framesJustRead == 0) { break; } if (framesCapacity < totalFramesRead + framesJustRead) { ma_uint64 oldFramesBufferSize; ma_uint64 newFramesBufferSize; ma_uint64 newFramesCap; float* pNewFrames; newFramesCap = framesCapacity * 2; if (newFramesCap < totalFramesRead + framesJustRead) { newFramesCap = totalFramesRead + framesJustRead; } oldFramesBufferSize = framesCapacity * pMP3->channels * sizeof(float); newFramesBufferSize = newFramesCap * pMP3->channels * sizeof(float); if (newFramesBufferSize > (ma_uint64)MA_SIZE_MAX) { break; } pNewFrames = (float*)ma_dr_mp3__realloc_from_callbacks(pFrames, (size_t)newFramesBufferSize, (size_t)oldFramesBufferSize, &pMP3->allocationCallbacks); if (pNewFrames == NULL) { ma_dr_mp3__free_from_callbacks(pFrames, &pMP3->allocationCallbacks); break; } pFrames = pNewFrames; framesCapacity = newFramesCap; } MA_DR_MP3_COPY_MEMORY(pFrames + totalFramesRead*pMP3->channels, temp, (size_t)(framesJustRead*pMP3->channels*sizeof(float))); totalFramesRead += framesJustRead; if (framesJustRead != framesToReadRightNow) { break; } } if (pConfig != NULL) { pConfig->channels = pMP3->channels; pConfig->sampleRate = pMP3->sampleRate; } ma_dr_mp3_uninit(pMP3); if (pTotalFrameCount) { *pTotalFrameCount = totalFramesRead; } return pFrames; } static ma_int16* ma_dr_mp3__full_read_and_close_s16(ma_dr_mp3* pMP3, ma_dr_mp3_config* pConfig, ma_uint64* pTotalFrameCount) { ma_uint64 totalFramesRead = 0; ma_uint64 framesCapacity = 0; ma_int16* pFrames = NULL; ma_int16 temp[4096]; MA_DR_MP3_ASSERT(pMP3 != NULL); for (;;) { ma_uint64 framesToReadRightNow = MA_DR_MP3_COUNTOF(temp) / pMP3->channels; ma_uint64 framesJustRead = ma_dr_mp3_read_pcm_frames_s16(pMP3, framesToReadRightNow, temp); if (framesJustRead == 0) { break; } if (framesCapacity < totalFramesRead + framesJustRead) { ma_uint64 newFramesBufferSize; ma_uint64 oldFramesBufferSize; ma_uint64 newFramesCap; ma_int16* pNewFrames; newFramesCap = framesCapacity * 2; if (newFramesCap < totalFramesRead + framesJustRead) { newFramesCap = totalFramesRead + framesJustRead; } oldFramesBufferSize = framesCapacity * pMP3->channels * sizeof(ma_int16); newFramesBufferSize = newFramesCap * pMP3->channels * sizeof(ma_int16); if (newFramesBufferSize > (ma_uint64)MA_SIZE_MAX) { break; } pNewFrames = (ma_int16*)ma_dr_mp3__realloc_from_callbacks(pFrames, (size_t)newFramesBufferSize, (size_t)oldFramesBufferSize, &pMP3->allocationCallbacks); if (pNewFrames == NULL) { ma_dr_mp3__free_from_callbacks(pFrames, &pMP3->allocationCallbacks); break; } pFrames = pNewFrames; framesCapacity = newFramesCap; } MA_DR_MP3_COPY_MEMORY(pFrames + totalFramesRead*pMP3->channels, temp, (size_t)(framesJustRead*pMP3->channels*sizeof(ma_int16))); totalFramesRead += framesJustRead; if (framesJustRead != framesToReadRightNow) { break; } } if (pConfig != NULL) { pConfig->channels = pMP3->channels; pConfig->sampleRate = pMP3->sampleRate; } ma_dr_mp3_uninit(pMP3); if (pTotalFrameCount) { *pTotalFrameCount = totalFramesRead; } return pFrames; } MA_API float* ma_dr_mp3_open_and_read_pcm_frames_f32(ma_dr_mp3_read_proc onRead, ma_dr_mp3_seek_proc onSeek, void* pUserData, ma_dr_mp3_config* pConfig, ma_uint64* pTotalFrameCount, const ma_allocation_callbacks* pAllocationCallbacks) { ma_dr_mp3 mp3; if (!ma_dr_mp3_init(&mp3, onRead, onSeek, pUserData, pAllocationCallbacks)) { return NULL; } return ma_dr_mp3__full_read_and_close_f32(&mp3, pConfig, pTotalFrameCount); } MA_API ma_int16* ma_dr_mp3_open_and_read_pcm_frames_s16(ma_dr_mp3_read_proc onRead, ma_dr_mp3_seek_proc onSeek, void* pUserData, ma_dr_mp3_config* pConfig, ma_uint64* pTotalFrameCount, const ma_allocation_callbacks* pAllocationCallbacks) { ma_dr_mp3 mp3; if (!ma_dr_mp3_init(&mp3, onRead, onSeek, pUserData, pAllocationCallbacks)) { return NULL; } return ma_dr_mp3__full_read_and_close_s16(&mp3, pConfig, pTotalFrameCount); } MA_API float* ma_dr_mp3_open_memory_and_read_pcm_frames_f32(const void* pData, size_t dataSize, ma_dr_mp3_config* pConfig, ma_uint64* pTotalFrameCount, const ma_allocation_callbacks* pAllocationCallbacks) { ma_dr_mp3 mp3; if (!ma_dr_mp3_init_memory(&mp3, pData, dataSize, pAllocationCallbacks)) { return NULL; } return ma_dr_mp3__full_read_and_close_f32(&mp3, pConfig, pTotalFrameCount); } MA_API ma_int16* ma_dr_mp3_open_memory_and_read_pcm_frames_s16(const void* pData, size_t dataSize, ma_dr_mp3_config* pConfig, ma_uint64* pTotalFrameCount, const ma_allocation_callbacks* pAllocationCallbacks) { ma_dr_mp3 mp3; if (!ma_dr_mp3_init_memory(&mp3, pData, dataSize, pAllocationCallbacks)) { return NULL; } return ma_dr_mp3__full_read_and_close_s16(&mp3, pConfig, pTotalFrameCount); } #ifndef MA_DR_MP3_NO_STDIO MA_API float* ma_dr_mp3_open_file_and_read_pcm_frames_f32(const char* filePath, ma_dr_mp3_config* pConfig, ma_uint64* pTotalFrameCount, const ma_allocation_callbacks* pAllocationCallbacks) { ma_dr_mp3 mp3; if (!ma_dr_mp3_init_file(&mp3, filePath, pAllocationCallbacks)) { return NULL; } return ma_dr_mp3__full_read_and_close_f32(&mp3, pConfig, pTotalFrameCount); } MA_API ma_int16* ma_dr_mp3_open_file_and_read_pcm_frames_s16(const char* filePath, ma_dr_mp3_config* pConfig, ma_uint64* pTotalFrameCount, const ma_allocation_callbacks* pAllocationCallbacks) { ma_dr_mp3 mp3; if (!ma_dr_mp3_init_file(&mp3, filePath, pAllocationCallbacks)) { return NULL; } return ma_dr_mp3__full_read_and_close_s16(&mp3, pConfig, pTotalFrameCount); } #endif MA_API void* ma_dr_mp3_malloc(size_t sz, const ma_allocation_callbacks* pAllocationCallbacks) { if (pAllocationCallbacks != NULL) { return ma_dr_mp3__malloc_from_callbacks(sz, pAllocationCallbacks); } else { return ma_dr_mp3__malloc_default(sz, NULL); } } MA_API void ma_dr_mp3_free(void* p, const ma_allocation_callbacks* pAllocationCallbacks) { if (pAllocationCallbacks != NULL) { ma_dr_mp3__free_from_callbacks(p, pAllocationCallbacks); } else { ma_dr_mp3__free_default(p, NULL); } } #endif /* dr_mp3_c end */ #endif /* MA_DR_MP3_IMPLEMENTATION */ #endif /* MA_NO_MP3 */ /* End globally disabled warnings. */ #if defined(_MSC_VER) #pragma warning(pop) #endif #endif /* miniaudio_c */ #endif /* MINIAUDIO_IMPLEMENTATION */ /* This software is available as a choice of the following licenses. Choose whichever you prefer. =============================================================================== ALTERNATIVE 1 - Public Domain (www.unlicense.org) =============================================================================== This is free and unencumbered software released into the public domain. Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means. In jurisdictions that recognize copyright laws, the author or authors of this software dedicate any and all copyright interest in the software to the public domain. We make this dedication for the benefit of the public at large and to the detriment of our heirs and successors. We intend this dedication to be an overt act of relinquishment in perpetuity of all present and future rights to this software under copyright law. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. For more information, please refer to =============================================================================== ALTERNATIVE 2 - MIT No Attribution =============================================================================== Copyright 2023 David Reid Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ ================================================ FILE: src/oscillators.c ================================================ #include "amy.h" // For checking assumptions about bitwidths. #include #include "sine_lutset_fxpt.h" #include "saw_lutset_fxpt.h" #include "triangle_lutset_fxpt.h" // For hardware random on ESP #ifdef ESP_PLATFORM #include #endif // Multiply used to apply amplitude to unit waveforms. sample is first arg (<=1), amp is 2nd. //#define MULA_SS MUL6A_SS #define MULA_SS(a, b) MUL5A_SS(a, b) /* Dan Ellis libblosca functions */ const LUT *choose_from_lutset(float period, const LUT *lutset) { // Select the best entry from a lutset for a given period. // // Args: // period: (float) Target period of waveform in fractional samples. // lutset: Sorted list of LUTs, as generated by create_lutset(). // // Returns: // One of the LUTs from the lutset, best suited to interpolating to generate // a waveform of the desired period. // Use the earliest (i.e., longest, most harmonics) LUT that works // (i.e., will not actually cause aliasing). // So start with the highest-bandwidth (and longest) LUTs, but skip them // if they result in aliasing. const LUT *lut_table = NULL; int lut_size = 0; int lut_index = 0; while(lutset[lut_index].table_size > 0) { lut_table = &lutset[lut_index]; lut_size = lutset[lut_index].table_size; // What proportion of nyquist does the highest harmonic in this table occupy? float lut_bandwidth = 2 * lutset[lut_index].highest_harmonic / (float)lut_size; // To complete one cycle of points in steps, each step // will need to be this many samples: float lut_hop = lut_size / period; // If we have a signal with a given bandwidth, but then speed it up by // skipping lut_hop samples per sample, its bandwidth will increase // proportionately. float interp_bandwidth = lut_bandwidth * lut_hop; //printf("period=%f freq=%f lut_size=%d interp_bandwidth=%f\n", period, ((float)AMY_SAMPLE_RATE)/period, lut_size, interp_bandwidth); if (interp_bandwidth < 0.9) { // No aliasing, even with a 10% buffer (i.e., 19.8 kHz). break; } ++lut_index; } // At this point, we either got to the end of the LUT table, or we found a // table we could interpolate without aliasing. return lut_table; } // Multiple versions of render_lut with different features to avoid branches in sample loop. #define RENDER_LUT_PREAMBLE \ if(lut == NULL) return phase;\ int lut_mask = lut->table_size - 1; \ int lut_bits = lut->log_2_table_size; \ SAMPLE sample = 0; \ SAMPLE max_value = 0; \ SAMPLE current_amp = incoming_amp; \ SAMPLE incremental_amp = SHIFTR(ending_amp - incoming_amp, BLOCK_SIZE_BITS); #define MOD_PART_MOD \ total_phase += S2P(mod[i]); // Feedback is taken before output scaling. #define FEEDBACK_PART_FB \ past1 = past0; \ past0 = sample; \ total_phase += S2P(MUL4_SS(feedback_level, SHIFTR(past1 + past0, 1))); #define RENDER_LUT_GUTS(MOD_PART, FEEDBACK_PART, INTERP_PART) \ MOD_PART \ FEEDBACK_PART \ int16_t base_index = INT_OF_P(total_phase, lut_bits); \ SAMPLE frac = S_FRAC_OF_P(total_phase, lut_bits); \ SAMPLE b = L2S(lut->table[base_index]); \ SAMPLE c = L2S(lut->table[(base_index + 1) & lut_mask]); \ INTERP_PART #define INTERP_LINEAR \ sample = b + MUL0_SS(c - b, frac); // Miller's optimization - // https://github.com/pure-data/pure-data/blob/db777311d808bb3ba728b94ab067f8d333b7d0c2/src/d_array.c#L831C1-L833C76 // outlet_float(x->x_obj.ob_outlet, b + frac * ( // cminusb - 0.1666667f * (1.-frac) * ( // (d - a - 3.0f * cminusb) * frac + (d + 2.0f*a - 3.0f*b))));# #define INTERP_CUBIC \ SAMPLE a = L2S(lut->table[(base_index - 1) & lut_mask]); \ SAMPLE d = L2S(lut->table[(base_index + 2) & lut_mask]); \ SAMPLE cminusb = c - b; \ SAMPLE fr_d_ma_m3cmb = MUL0_SS(d - a - cminusb - SHIFTL(cminusb, 1), frac); \ SAMPLE next_bit = MUL0_SS(fr_d_ma_m3cmb + d + SHIFTL(a - b, 1) - b, MUL0_SS(F2S(1.0f) - frac, F2S(0.16666666666667f))); \ sample = b + MUL0_SS(cminusb - next_bit, frac); #define RENDER_LUT_LOOP_END \ SAMPLE value = buf[i] + MULA_SS(sample, current_amp); \ buf[i] = value; \ if (value < 0) value = -value; \ if (value > max_value) max_value = value; \ current_amp += incremental_amp; \ phase = P_WRAPPED_SUM(phase, step); #define NOTHING ; PHASOR render_lut_fm_fb(SAMPLE* buf, PHASOR phase, PHASOR step, SAMPLE incoming_amp, SAMPLE ending_amp, const LUT* lut, SAMPLE* mod, SAMPLE feedback_level, SAMPLE* last_two, SAMPLE *pmax_value) { AMY_PROFILE_START(RENDER_LUT_FM_FB) RENDER_LUT_PREAMBLE SAMPLE past0 = 0, past1 = 0; sample = last_two[0]; past0 = last_two[1]; for(uint16_t i = 0; i < AMY_BLOCK_SIZE; i++) { PHASOR total_phase = phase; RENDER_LUT_GUTS(MOD_PART_MOD, FEEDBACK_PART_FB, INTERP_LINEAR) RENDER_LUT_LOOP_END } last_two[0] = sample; last_two[1] = past0; *pmax_value = max_value; AMY_PROFILE_STOP(RENDER_LUT_FM_FB) return phase; } PHASOR render_lut_fb(SAMPLE* buf, PHASOR phase, PHASOR step, SAMPLE incoming_amp, SAMPLE ending_amp, const LUT* lut, SAMPLE feedback_level, SAMPLE* last_two, SAMPLE *pmax_value) { AMY_PROFILE_START(RENDER_LUT_FB) RENDER_LUT_PREAMBLE SAMPLE past0 = 0, past1 = 0; sample = last_two[0]; past0 = last_two[1]; for(uint16_t i = 0; i < AMY_BLOCK_SIZE; i++) { PHASOR total_phase = phase; RENDER_LUT_GUTS(NOTHING, FEEDBACK_PART_FB, INTERP_LINEAR) RENDER_LUT_LOOP_END } last_two[0] = sample; last_two[1] = past0; *pmax_value = max_value; AMY_PROFILE_STOP(RENDER_LUT_FB) return phase; } PHASOR render_lut_fm(SAMPLE* buf, PHASOR phase, PHASOR step, SAMPLE incoming_amp, SAMPLE ending_amp, const LUT* lut, SAMPLE* mod, SAMPLE* pmax_value) { AMY_PROFILE_START(RENDER_LUT_FM) RENDER_LUT_PREAMBLE for(uint16_t i = 0; i < AMY_BLOCK_SIZE; i++) { PHASOR total_phase = phase; RENDER_LUT_GUTS(MOD_PART_MOD, NOTHING, INTERP_LINEAR) RENDER_LUT_LOOP_END } *pmax_value = max_value; AMY_PROFILE_STOP(RENDER_LUT_FM) return phase; } PHASOR render_lut(SAMPLE* buf, PHASOR phase, PHASOR step, SAMPLE incoming_amp, SAMPLE ending_amp, const LUT* lut, SAMPLE* pmax_value) { AMY_PROFILE_START(RENDER_LUT) RENDER_LUT_PREAMBLE for(uint16_t i = 0; i < AMY_BLOCK_SIZE; i++) { PHASOR total_phase = phase; RENDER_LUT_GUTS(NOTHING, NOTHING, INTERP_LINEAR) RENDER_LUT_LOOP_END } *pmax_value = max_value; AMY_PROFILE_STOP(RENDER_LUT) return phase; } PHASOR render_lut_cub(SAMPLE* buf, PHASOR phase, PHASOR step, SAMPLE incoming_amp, SAMPLE ending_amp, const LUT* lut, SAMPLE *pmax_value) { AMY_PROFILE_START(RENDER_LUT_CUB) RENDER_LUT_PREAMBLE for(uint16_t i = 0; i < AMY_BLOCK_SIZE; i++) { PHASOR total_phase = phase; RENDER_LUT_GUTS(NOTHING, NOTHING, INTERP_CUBIC) RENDER_LUT_LOOP_END } *pmax_value = max_value; AMY_PROFILE_STOP(RENDER_LUT_CUB) return phase; } /* Audio in */ void audio_in_note_on(uint16_t osc, uint8_t channel) { // do i need to do anything here? probably not } void external_audio_in_note_on(uint16_t osc, uint8_t channel) { // do i need to do anything here? probably not } SAMPLE render_audio_in(SAMPLE * buf, uint16_t osc, uint8_t channel) { uint16_t c = 0; for(uint16_t i=channel;iamp)); } // We have to return something for max_value or else the zero-amp reaper will come along. return F2S(1.0); //max_value; } SAMPLE render_external_audio_in(SAMPLE *buf, uint16_t osc, uint8_t channel) { uint16_t c = 0; for(uint16_t i=channel;iamp)); } // We have to return something for max_value or else the zero-amp reaper will come along. return F2S(1.0); //max_value; } /* Pulse wave */ void pulse_note_on(uint16_t osc, float freq) { //printf("pulse_note_on: time %lld osc %d logfreq %f amp %f last_amp %f\n", amy_global.total_blocks*AMY_BLOCK_SIZE, osc, synth[osc]->logfreq, msynth[osc]->amp, msynth[osc]->last_amp); float period_samples = (float)AMY_SAMPLE_RATE / freq; synth[osc]->lut = choose_from_lutset(period_samples, saw_fxpt_lutset); } SAMPLE render_lpf_lut(SAMPLE* buf, uint16_t osc, int8_t is_square, int8_t direction, SAMPLE dc_offset) { AMY_PROFILE_START(RENDER_LPF_LUT) // Common function for pulse and saw. float freq = freq_of_logfreq(msynth[osc]->logfreq); PHASOR step = F2P(freq / (float)AMY_SAMPLE_RATE); // cycles per sec / samples per sec -> cycles per sample SAMPLE amp = direction * F2S(msynth[osc]->amp); SAMPLE last_amp = direction * F2S(msynth[osc]->last_amp); PHASOR pwm_phase = synth[osc]->phase; SAMPLE max_value; synth[osc]->phase = render_lut_cub(buf, synth[osc]->phase, step, last_amp, amp, synth[osc]->lut, &max_value); if (is_square) { // For pulse only, add a second delayed negative LUT wave. float duty = msynth[osc]->duty; if (duty < 0.01f) duty = 0.01f; if (duty > 0.99f) duty = 0.99f; pwm_phase = P_WRAPPED_SUM(pwm_phase, F2P(msynth[osc]->last_duty)); // Second pulse is given some blockwise-constant FM to maintain phase continuity across blocks. PHASOR delta_phase_per_sample = F2P((duty - msynth[osc]->last_duty) / AMY_BLOCK_SIZE); render_lut_cub(buf, pwm_phase, step + delta_phase_per_sample, -last_amp, -amp, synth[osc]->lut, &max_value); msynth[osc]->last_duty = duty; } // Remember last_amp. msynth[osc]->last_amp = msynth[osc]->amp; AMY_PROFILE_STOP(RENDER_LPF_LUT) return max_value; } SAMPLE render_pulse(SAMPLE* buf, uint16_t osc) { // Second (negative) impulse is cycles later. return render_lpf_lut(buf, osc, true, 1, 0); } void pulse_mod_trigger(uint16_t osc) { //float mod_sr = (float)AMY_SAMPLE_RATE / (float)AMY_BLOCK_SIZE; //float freq = freq_of_logfreq(synth[osc]->logfreq); //float period = 1. / (freq/mod_sr); //synth[osc]->step = period * synth[osc]->phase; } // dpwe sez to use this method for low-freq mod pulse still SAMPLE compute_mod_pulse(uint16_t osc) { // do BW pulse gen at SR=44100/64 SAMPLE sample; if(msynth[osc]->duty < 0.001f || msynth[osc]->duty > 0.999) msynth[osc]->duty = 0.5; if(synth[osc]->phase >= F2P(msynth[osc]->duty)) { sample = F2S(1.0f); } else { sample = F2S(-1.0f); } float mod_sr = (float)AMY_SAMPLE_RATE / (float)AMY_BLOCK_SIZE; // samples per sec / samples per call = calls per sec float freq = freq_of_logfreq(msynth[osc]->logfreq); synth[osc]->phase = P_WRAPPED_SUM(synth[osc]->phase, F2P(freq / mod_sr)); // cycles per sec / calls per sec = cycles per call return MULA_SS(sample, F2S(msynth[osc]->amp)); } /* Saw waves */ void saw_note_on(uint16_t osc, int8_t direction_notused, float freq) { //printf("saw_note_on: time %lld osc %d freq %f logfreq %f amp %f last_amp %f phase %f\n", amy_global.total_blocks*AMY_BLOCK_SIZE, osc, freq, synth[osc]->logfreq, msynth[osc]->amp, msynth[osc]->last_amp, P2F(synth[osc]->phase)); float period_samples = ((float)AMY_SAMPLE_RATE / freq); synth[osc]->lut = choose_from_lutset(period_samples, saw_fxpt_lutset); } void saw_down_note_on(uint16_t osc, float freq) { saw_note_on(osc, -1, freq); } void saw_up_note_on(uint16_t osc, float freq) { saw_note_on(osc, 1, freq); } SAMPLE render_saw(SAMPLE* buf, uint16_t osc, int8_t direction) { return render_lpf_lut(buf, osc, false, direction, /* dc offset */ 0); //printf("render_saw: time %lld osc %d buf[]=%f %f %f %f %f %f %f %f\n", // amy_global.total_blocks*AMY_BLOCK_SIZE, osc, S2F(buf[0]), S2F(buf[1]), S2F(buf[2]), S2F(buf[3]), S2F(buf[4]), S2F(buf[5]), S2F(buf[6]), S2F(buf[7])); } SAMPLE render_saw_down(SAMPLE* buf, uint16_t osc) { return render_saw(buf, osc, -1); } SAMPLE render_saw_up(SAMPLE* buf, uint16_t osc) { return render_saw(buf, osc, 1); } void saw_mod_trigger(uint16_t osc) { //float mod_sr = (float)AMY_SAMPLE_RATE / (float)AMY_BLOCK_SIZE; //float freq = freq_of_logfreq(synth[osc]->logfreq); //float period = 1. / (freq/mod_sr); //synth[osc]->step = period * synth[osc]->phase; } void saw_up_mod_trigger(uint16_t osc) { saw_mod_trigger(osc); } void saw_down_mod_trigger(uint16_t osc) { saw_mod_trigger(osc); } // TODO -- this should use dpwe code SAMPLE compute_mod_saw(uint16_t osc, int8_t direction) { // Saw waveform is just the phasor. SAMPLE sample = SHIFTL(P2S(synth[osc]->phase), 1) - F2S(1.0f); float mod_sr = (float)AMY_SAMPLE_RATE / (float)AMY_BLOCK_SIZE; // samples per sec / samples per call = calls per sec float freq = freq_of_logfreq(msynth[osc]->logfreq); synth[osc]->phase = P_WRAPPED_SUM(synth[osc]->phase, F2P(freq / mod_sr)); // cycles per sec / calls per sec = cycles per call return MULA_SS(sample, direction * F2S(msynth[osc]->amp)); } SAMPLE compute_mod_saw_down(uint16_t osc) { return compute_mod_saw(osc, -1); } SAMPLE compute_mod_saw_up(uint16_t osc) { return compute_mod_saw(osc, 1); } /* triangle wave */ void triangle_note_on(uint16_t osc, float freq) { float period_samples = (float)AMY_SAMPLE_RATE / freq; synth[osc]->lut = choose_from_lutset(period_samples, triangle_fxpt_lutset); } SAMPLE render_triangle(SAMPLE* buf, uint16_t osc) { float freq = freq_of_logfreq(msynth[osc]->logfreq); PHASOR step = F2P(freq / (float)AMY_SAMPLE_RATE); // cycles per sec / samples per sec -> cycles per sample SAMPLE amp = F2S(msynth[osc]->amp); SAMPLE last_amp = F2S(msynth[osc]->last_amp); SAMPLE max_value; synth[osc]->phase = render_lut(buf, synth[osc]->phase, step, last_amp, amp, synth[osc]->lut, &max_value); msynth[osc]->last_amp = msynth[osc]->amp; return max_value; } void triangle_mod_trigger(uint16_t osc) { // float mod_sr = (float)AMY_SAMPLE_RATE / (float)AMY_BLOCK_SIZE; // float freq = freq_of_logfreq(synth[osc]->logfreq); // float period = 1. / (freq/mod_sr); // synth[osc]->step = period * synth[osc]->phase; } // TODO -- this should use dpwe code SAMPLE compute_mod_triangle(uint16_t osc) { // Saw waveform is just the phasor. SAMPLE sample = SHIFTL(P2S(synth[osc]->phase), 2); // 0..4 if (sample > F2S(2.0f)) sample = F2S(4.0f) - sample; // 0..2..0 sample -= F2S(1.0f); // -1 .. 1 float mod_sr = (float)AMY_SAMPLE_RATE / (float)AMY_BLOCK_SIZE; // samples per sec / samples per call = calls per sec float freq = freq_of_logfreq(msynth[osc]->logfreq); synth[osc]->phase = P_WRAPPED_SUM(synth[osc]->phase, F2P(freq / mod_sr)); // cycles per sec / calls per sec = cycles per call return MULA_SS(sample, F2S(msynth[osc]->amp)); } /* FM */ // NB this uses new lingo for step, skip, phase etc void fm_sine_note_on(uint16_t osc, uint16_t algo_osc) { if(AMY_IS_SET(synth[osc]->logratio)) { msynth[osc]->logfreq = msynth[algo_osc]->logfreq + synth[osc]->logratio; } // An empty exercise since there is only one entry in sine_lutset. float freq = freq_of_logfreq(msynth[osc]->logfreq); float period_samples = (float)AMY_SAMPLE_RATE / freq; synth[osc]->lut = choose_from_lutset(period_samples, sine_fxpt_lutset); } SAMPLE render_fm_sine(SAMPLE* buf, uint16_t osc, SAMPLE* mod, SAMPLE feedback_level, uint16_t algo_osc, SAMPLE mod_amp) { if(AMY_IS_SET(synth[osc]->logratio)) { msynth[osc]->logfreq = msynth[algo_osc]->logfreq + synth[osc]->logratio; } float freq = freq_of_logfreq(msynth[osc]->logfreq); PHASOR step = F2P(freq / (float)AMY_SAMPLE_RATE); // cycles per sec / samples per sec -> cycles per sample SAMPLE amp = MUL8_SS(F2S(msynth[osc]->amp), mod_amp); SAMPLE last_amp = MUL8_SS(F2S(msynth[osc]->last_amp), mod_amp); SAMPLE max_value; if (feedback_level > 0 && mod) synth[osc]->phase = render_lut_fm_fb(buf, synth[osc]->phase, step, last_amp, amp, synth[osc]->lut, mod, feedback_level, synth[osc]->last_two, &max_value); else if (feedback_level > 0) synth[osc]->phase = render_lut_fb(buf, synth[osc]->phase, step, last_amp, amp, synth[osc]->lut, feedback_level, synth[osc]->last_two, &max_value); else if (mod) synth[osc]->phase = render_lut_fm(buf, synth[osc]->phase, step, last_amp, amp, synth[osc]->lut, mod, &max_value); else synth[osc]->phase = render_lut(buf, synth[osc]->phase, step, last_amp, amp, synth[osc]->lut, &max_value); msynth[osc]->last_amp = msynth[osc]->amp; return max_value; } /* sine */ void sine_note_on(uint16_t osc, float freq) { //fprintf(stderr, "sine_note_on: time %f osc %d freq %f\n", amy_global.total_blocks*AMY_BLOCK_SIZE / (float)AMY_SAMPLE_RATE, osc, freq_of_logfreq(synth[osc]->logfreq_coefs[0])); // There's really only one sine table, but for symmetry with the other ones... float period_samples = (float)AMY_SAMPLE_RATE / freq; synth[osc]->lut = choose_from_lutset(period_samples, sine_fxpt_lutset); } SAMPLE render_sine(SAMPLE* buf, uint16_t osc) { float freq = freq_of_logfreq(msynth[osc]->logfreq); PHASOR step = F2P(freq / (float)AMY_SAMPLE_RATE); // cycles per sec / samples per sec -> cycles per sample SAMPLE amp = F2S(msynth[osc]->amp); SAMPLE last_amp = F2S(msynth[osc]->last_amp); //fprintf(stderr, "render_sine: time %f osc %d freq %f last_amp %f amp %f\n", amy_global.total_blocks*AMY_BLOCK_SIZE / (float)AMY_SAMPLE_RATE, osc, AMY_SAMPLE_RATE * P2F(step), S2F(last_amp), S2F(amp)); SAMPLE max_value; synth[osc]->phase = render_lut(buf, synth[osc]->phase, step, last_amp, amp, synth[osc]->lut, &max_value); msynth[osc]->last_amp = msynth[osc]->amp; return max_value; } // TOOD -- not needed anymore SAMPLE compute_mod_sine(uint16_t osc) { // One sample pulled out of render_lut. const LUT *lut = synth[osc]->lut; int lut_mask = lut->table_size - 1; int lut_bits = lut->log_2_table_size; int16_t base_index = INT_OF_P(synth[osc]->phase, lut_bits); SAMPLE frac = S_FRAC_OF_P(synth[osc]->phase, lut_bits); LUTSAMPLE b = lut->table[base_index]; LUTSAMPLE c = lut->table[(base_index + 1) & lut_mask]; SAMPLE sample = L2S(b) + MUL0_SS(L2S(c - b), frac); float mod_sr = (float)AMY_SAMPLE_RATE / (float)AMY_BLOCK_SIZE; // samples per sec / samples per call = calls per sec float freq = freq_of_logfreq(msynth[osc]->logfreq); synth[osc]->phase = P_WRAPPED_SUM(synth[osc]->phase, F2P(freq / mod_sr)); // cycles per sec / calls per sec = cycles per call return MULA_SS(sample, F2S(msynth[osc]->amp)); } void sine_mod_trigger(uint16_t osc) { sine_note_on(osc, freq_of_logfreq(msynth[osc]->logfreq)); } // On the RP2040, rand and mrand48 etc. don't work on core1. // I think this is to do with the implicit state - it's not repeatable, nor strictly safe, // to potentially have two cores accessing the same rand_state memory at the same time. // However, we just want random values, and any bit pattern is acceptable. // So we make our own implementation of mrand48, and don't worry about it being called from both cores. static uint64_t rand_state = 0; static const uint64_t a = 0x5deece66dL; static const uint32_t c = 0xb; void my_srand48(uint32_t seedval) { rand_state = ((uint64_t)seedval) << 32L; } static inline int32_t my_mrand48(void) { // per https://www.ibm.com/docs/en/zos/2.4.0?topic=functions-mrand48-pseudo-random-number-generator rand_state = (a * rand_state + c) & 0x0000ffffffffffffL; return (int32_t)rand_state; } #if (defined PICO_RP2350) || (defined PICO_RP2040) #include "pico/rand.h" #endif // Returns a SAMPLE between -1 and 1. inline static SAMPLE amy_get_random() { #ifndef AMY_USE_FIXEDPOINT return ((float)drand48()) - 0.5f; #else //assert(RAND_MAX == 2147483647); // 2^31 - 1 return SHIFTR((SAMPLE)my_mrand48(), (32 - S_FRAC_BITS)); // - F2S(0.5f); #endif } /* noise */ void noise_note_on(uint16_t osc) { synth[osc]->last_two[0] = 0; synth[osc]->last_two[1] = 0; } SAMPLE render_noise(SAMPLE *buf, uint16_t osc) { SAMPLE amp = F2S(msynth[osc]->amp); SAMPLE max_value = 0; SAMPLE last_white = synth[osc]->last_two[0]; SAMPLE last_last_white = synth[osc]->last_two[1]; for(uint16_t i=0;i max_value) max_value = value; } synth[osc]->last_two[0] = last_white; synth[osc]->last_two[1] = last_last_white; return max_value; } SAMPLE compute_mod_noise(uint16_t osc) { float mod_sr = (float)AMY_SAMPLE_RATE / (float)AMY_BLOCK_SIZE; float freq = freq_of_logfreq(msynth[osc]->logfreq); float fstep = freq / mod_sr; SAMPLE amp = F2S(msynth[osc]->amp); PHASOR starting_phase = synth[osc]->phase; synth[osc]->phase = P_WRAPPED_SUM(synth[osc]->phase, F2P(fstep)); // cycles per sec / calls per sec = cycles per call if (fstep > 1.0f || synth[osc]->phase < starting_phase) { // phase wrapped, take new sample. synth[osc]->last_two[0] = MULA_SS(amy_get_random(), amp); } //printf("mod_noise: time %lld fstep %f samp %f\n", amy_global.total_blocks*AMY_BLOCK_SIZE, fstep, S2F(synth[osc]->last_two[0])); return synth[osc]->last_two[0]; } /* silent, i.e. just apply envelope */ SAMPLE render_envelope(SAMPLE *buf, uint16_t osc) { SAMPLE incoming_amp = F2S(msynth[osc]->last_amp); SAMPLE ending_amp = F2S(msynth[osc]->amp); SAMPLE max_value = 0; SAMPLE current_amp = incoming_amp; SAMPLE incremental_amp = SHIFTR(ending_amp - incoming_amp, BLOCK_SIZE_BITS); for(uint16_t i = 0; i < AMY_BLOCK_SIZE; i++) { SAMPLE value = MULA_SS(buf[i], current_amp); buf[i] = value; if (value < 0) value = -value; if (value > max_value) max_value = value; current_amp += incremental_amp; } msynth[osc]->last_amp = msynth[osc]->amp; return max_value; } /* partial */ SAMPLE render_partial(SAMPLE * buf, uint16_t osc) { float freq = freq_of_logfreq(msynth[osc]->logfreq); PHASOR step = F2P(freq / (float)AMY_SAMPLE_RATE); // cycles per sec / samples per sec -> cycles per sample SAMPLE amp = F2S(msynth[osc]->amp); SAMPLE last_amp = F2S(msynth[osc]->last_amp); //printf("render_partial: time %.3f logfreq %f freq %f last_amp %f amp %f step %f\n", (float)amy_global.total_blocks*AMY_BLOCK_SIZE/(float)AMY_SAMPLE_RATE, msynth[osc]->logfreq, freq, S2F(last_amp), S2F(amp), P2F(step) * synth[osc]->lut->table_size); SAMPLE max_value; synth[osc]->phase = render_lut(buf, synth[osc]->phase, step, last_amp, amp, synth[osc]->lut, &max_value); msynth[osc]->last_amp = msynth[osc]->amp; return max_value; } void partial_note_on(uint16_t osc) { float freq = freq_of_logfreq(msynth[osc]->logfreq); float period_samples = (float)AMY_SAMPLE_RATE / freq; synth[osc]->lut = choose_from_lutset(period_samples, sine_fxpt_lutset); } void partial_note_off(uint16_t osc) { synth[osc]->substep = 2; AMY_UNSET(synth[osc]->note_on_clock); synth[osc]->note_off_clock = amy_global.total_blocks*AMY_BLOCK_SIZE; msynth[osc]->last_amp = 0; synth[osc]->status = SYNTH_OFF; } #define MAX_KS_BUFFER_LEN 802 // 44100/55 -- 55Hz (A1) lowest we can go for KS SAMPLE ** ks_buffer; uint8_t ks_polyphony_index; /* karplus-strong */ SAMPLE render_ks(SAMPLE * buf, uint16_t osc) { SAMPLE half = MUL0_SS(F2S(0.5f), F2S(synth[osc]->feedback)); SAMPLE amp = F2S(msynth[osc]->amp); float freq = freq_of_logfreq(msynth[osc]->logfreq); SAMPLE max_value = 0; if(freq >= 55) { // lowest note we can play uint16_t buflen = (uint16_t)(AMY_SAMPLE_RATE / freq); for(uint16_t i = 0; i < AMY_BLOCK_SIZE; i++) { uint16_t index = (uint16_t)(synth[osc]->step); SAMPLE sample = ks_buffer[ks_polyphony_index][index]; ks_buffer[ks_polyphony_index][index] = SMULR7( (ks_buffer[ks_polyphony_index][index] + ks_buffer[ks_polyphony_index][(index + 1) % buflen]), half); synth[osc]->step = (index + 1) % buflen; SAMPLE value = SMULR7(sample, amp); buf[i] += value; if (i == 0) { max_value = value; } else { if (value > max_value) max_value = value; else if (-value > max_value) max_value = -value; } } } //fprintf(stderr, "render_ks time %u osc %d freq %.1f amp %.3f maxval %.3f\n", amy_global.total_blocks*AMY_BLOCK_SIZE, osc, freq, S2F(amp), S2F(max_value)); return max_value; } void ks_note_on(uint16_t osc) { float freq = freq_of_logfreq(msynth[osc]->logfreq); if(freq <= 1.f) freq = 1.f; uint16_t buflen = (uint16_t)(AMY_SAMPLE_RATE / freq); if(buflen > MAX_KS_BUFFER_LEN) buflen = MAX_KS_BUFFER_LEN; // init KS buffer with noise up to max SAMPLE sum = 0; for(uint16_t i = 0; i < buflen; i++) { SAMPLE val = amy_get_random(); ks_buffer[ks_polyphony_index][i] = val; sum += val; } // Remove dc, to avoid ending up with a dc-offset residual. SAMPLE mean = sum / buflen; for(uint16_t i = 0; i < buflen; i++) { ks_buffer[ks_polyphony_index][i] -= mean; } ks_polyphony_index++; if(ks_polyphony_index == AMY_KS_OSCS) ks_polyphony_index = 0; //fprintf(stderr, "ks_note_on: osc %d buflen %d poly_index %d\n", osc, buflen, ks_polyphony_index); } void ks_note_off(uint16_t osc) { msynth[osc]->amp = 0; } void ks_init(void) { // 6ms buffer ks_polyphony_index = 0; ks_buffer = (SAMPLE**) malloc(sizeof(SAMPLE*)*AMY_KS_OSCS); for(int i=0;ilogfreq_coefs[0])); //float period_samples = (float)AMY_SAMPLE_RATE / freq; //synth[osc]->lut = wavetable_lut; // TODO(dpwe): choose based on synth[osc]->preset. } // Structure of waveeditonlie wavetables. const int CYCLES_PER_WAVETABLE = 64; const int WAVETABLE_SAMPLES_PER_CYCLE = 256; const int WAVETABLE_LOG2_SAMPLES_PER_CYCLE = 8; SAMPLE render_wavetable(SAMPLE* buf, uint16_t osc) { float freq = freq_of_logfreq(msynth[osc]->logfreq); PHASOR step = F2P(freq / (float)AMY_SAMPLE_RATE); // cycles per sec / samples per sec -> cycles per sample SAMPLE amp = F2S(msynth[osc]->amp); SAMPLE last_amp = F2S(msynth[osc]->last_amp); //fprintf(stderr, "render_wavetable: time %f osc %d freq %f last_amp %f amp %f preset %d\n", amy_global.total_blocks*AMY_BLOCK_SIZE / (float)AMY_SAMPLE_RATE, osc, AMY_SAMPLE_RATE * P2F(step), S2F(last_amp), S2F(amp), synth[osc]->preset); SAMPLE max_value; float interp = MAX(0, MIN(CYCLES_PER_WAVETABLE - 1, (CYCLES_PER_WAVETABLE - 1) * msynth[osc]->duty)); // Don't try to interp beyond end of table. An N-waveform table can be interpolated from 0 to (N-1-eps). int table = MIN((int)floor(interp), CYCLES_PER_WAVETABLE - 2); // always need both this wavetable and the next one. interp = interp - table; // fractional part, normally < 1.0, but == 1.0 for very end of table. int wavetable_preset = AMY_IS_SET(synth[osc]->preset) ? (int)synth[osc]->preset : (int)pcm_wavetable_base; int wavetable_samples_per_table = (pcm_wavetable_len > 0) ? (int)pcm_wavetable_len : 16384; uint32_t sample_length = 0; const int16_t *wavetable_sample_ram = pcm_get_sample_ram_for_preset((uint16_t)wavetable_preset, &sample_length); if ((wavetable_sample_ram == NULL || sample_length < (uint32_t)wavetable_samples_per_table) && wavetable_preset != (int)pcm_wavetable_base) { wavetable_sample_ram = pcm_get_sample_ram_for_preset(pcm_wavetable_base, &sample_length); } if (wavetable_sample_ram == NULL || sample_length < (uint32_t)wavetable_samples_per_table) { return 0; } LUT wavetable_lut = {wavetable_sample_ram, WAVETABLE_SAMPLES_PER_CYCLE, WAVETABLE_LOG2_SAMPLES_PER_CYCLE, 0, 1.0f}; wavetable_lut.table += table * WAVETABLE_SAMPLES_PER_CYCLE; // don't update phase in the first call to render_lut, so second call uses the same phase SAMPLE interp_a = F2S(1.0f - interp); SAMPLE interp_b = F2S(interp); // If we used last_duty, we could actually smoothly interpolate the waveshape crossfade too (except across table boundaries). render_lut(buf, synth[osc]->phase, step, SMULR7(last_amp, interp_a), SMULR7(amp, interp_a), &wavetable_lut, &max_value); // Point to next cycle. wavetable_lut.table += WAVETABLE_SAMPLES_PER_CYCLE; synth[osc]->phase = render_lut(buf, synth[osc]->phase, step, SMULR7(last_amp, interp_b), SMULR7(amp, interp_b), &wavetable_lut, &max_value); msynth[osc]->last_amp = msynth[osc]->amp; return max_value; } #endif ================================================ FILE: src/parse.c ================================================ // parse.c // handle parsing wire strings #include "amy.h" #include "transfer.h" // for amy_dump_state_to_sysex, amy_dump_file_to_sysex #include // for isalpha(). #if defined(TULIP) || defined(AMYBOARD) #include "py/runtime.h" #endif float atoff(const char *s) { // Returns float value corresponding to parseable prefix of s. // Unlike atof(), it does not recognize scientific format ('e' or 'E') // and will stop parsing there. Needed for message strings that contain // 'e' as a command prefix. float frac = 0; // Skip leading spaces. while (*s == ' ') ++s; float whole = (float)atoi(s); int is_negative = (s[0] == '-'); // Can't use (whole < 0) because of "-0.xx". //const char *s_in = s; // for debug message. s += strspn(s, "-0123456789"); if (*s == '.') { // Float with a decimal part. // Step over dp ++s; // Extract fractional part. int fraclen = strspn(s, "0123456789"); char fracpart[8]; // atoi() will overflow for values larger than 2^31, so only decode a prefix. if (fraclen > 6) { for(int i = 0; i < 7; ++i) { fracpart[i] = s[i]; } fracpart[7] = '\0'; s = fracpart; fraclen = 7; } frac = (float)atoi(s); frac /= powf(10.f, (float)fraclen); if (is_negative) frac = -frac; } //fprintf(stderr, "input was %s output is %f + %f = %f\n", s_in, whole, frac, whole+frac); return whole + frac; } #define PARSE_LIST_STRSPN1(var) _Generic((var), \ float: " -0123456789,.", \ uint32_t: " 0123456789,", \ uint16_t: " 0123456789,", \ int16_t: " -0123456789,", \ int32_t: " -0123456789," \ ) #define PARSE_LIST_STRSPN2(var) _Generic((var), \ float: "-0123456789.", \ uint32_t: "0123456789", \ uint16_t: "0123456789", \ int16_t: "-0123456789", \ int32_t: "-0123456789" \ ) #define PARSE_LIST_ATO(var) _Generic((var), \ float: atoff, \ uint32_t: atoi, \ uint16_t: atoi, \ int32_t: atoi, \ int16_t: atoi \ ) #define PARSE_LIST(type) \ int parse_list_##type(char *message, type *vals, int max_num_vals, type skipped_val) { \ uint16_t c = 0, last_c; \ uint16_t stop = strspn(message, PARSE_LIST_STRSPN1(skipped_val)); \ int num_vals_received = 0; \ while(c < stop && num_vals_received < max_num_vals) { \ *vals = PARSE_LIST_ATO(skipped_val)(message + c); \ while (message[c] == ' ') ++c; \ last_c = c; \ c += strspn(message + c, PARSE_LIST_STRSPN2(skipped_val)); \ if (last_c == c) \ *vals = skipped_val; \ while (message[c] != ',' && message[c] != 0 && c < MAX_MESSAGE_LEN) c++; \ ++c; \ ++vals; \ ++num_vals_received; \ } \ if (c < stop) { \ fprintf(stderr, "WARNING: parse__list_##type: More than %d values in \"%s\"\n", \ max_num_vals, message); \ } else { /* pad to end */ \ for (int i = num_vals_received; i < max_num_vals; ++i) { \ *vals++ = skipped_val; \ } \ } \ return num_vals_received; \ } PARSE_LIST(float) PARSE_LIST(uint32_t) PARSE_LIST(uint16_t) PARSE_LIST(int32_t) PARSE_LIST(int16_t) #define PARSE_VAL(type) \ int parse_val_##type(char *message, type *val) { \ int c = 0; \ *val = PARSE_LIST_ATO(*val)(message); \ c = strspn(message, PARSE_LIST_STRSPN2(*val)); \ return c; \ } PARSE_VAL(float) PARSE_VAL(int32_t) char *copy_with_trim(char *dest, size_t dest_len, const char *src, size_t src_len) { // Copy a string while trimming leading and trailing spaces. const char *s = src; char *d = dest; size_t d_writ = 0; size_t s_read = 0; size_t trimmed_src_len = src_len; // scan for spaces at end while (trimmed_src_len > 0 && isspace((unsigned char)src[trimmed_src_len - 1])) { --trimmed_src_len; } // skip over leading spaces while (s_read < trimmed_src_len && isspace((unsigned char)*s)) { ++s; ++s_read; } while(s_read < trimmed_src_len && d_writ < (dest_len - 1)) { *d++ = *s++; ++s_read; ++d_writ; } *d = '\0'; // terminator. return (char*) (src + src_len); } static const char *strchrnul_local(const char *s, int c) { const char *found = strchr(s, c); if (found != NULL) { return found; } return s + strlen(s); } uint16_t parse_list_file_params(char *message, uint32_t *preset, char *filename, size_t filename_len, uint32_t *midinote) { // Returns number of characters of message that are consumed. if (filename_len > 0) { filename[0] = '\0'; } char *m = message; *preset = strtol(m, &m, 0); if (*m != ',') return m - message; ++m; m = copy_with_trim(filename, filename_len, m, strchrnul_local(m, ',') - m); if (*m != ',') return m - message; ++m; *midinote = strtol(m, &m, 0); return m - message; } uint16_t parse_list_file_transfer_params(char *message, char *filename, size_t filename_len, uint32_t *file_size) { *file_size = 0; if (filename_len > 0) { filename[0] = '\0'; } char *m = message; m = copy_with_trim(filename, filename_len, m, strchrnul_local(m, ',') - m); if (*m != ',') return m - message; ++m; *file_size = strtol(m, &m, 0); return m-message; } void copy_param_list_substring(char *dest, const char *src) { // Copy wire command string up to next parameter char. uint16_t c = 0; uint16_t stop = strspn(src, " 0123456789-,."); // Note space & period. while (c < stop && src[c]) { dest[c] = src[c]; c++; } dest[c] = '\0'; } float int_db_to_float_lin(uint32_t db) { // in interp_partials.h, we store amplitudes as integer dB values in range 0..100. float lin = 0; if (AMY_IS_UNSET(db)) return AMY_UNSET_VALUE(lin); lin = powf(10.0f, ((((float)db) - 100.0f) / 20.0f)) - 0.001f; if (lin < 0) return 0; return lin; } float int_db_to_60dB_01(uint32_t db) { // Map 100 (db) to 1.0, 40 (db) to 0.0 float lin = 0; if (AMY_IS_UNSET(db)) return AMY_UNSET_VALUE(lin); lin = 1.0f + (((float)db - 100.0f) / (3.0f * 20.0f)); if (lin < 0) return 0; return lin; } //static int16_t clamp_bp_time_ms_to_i16(uint32_t t_ms) { // if (t_ms >= (uint32_t)SHRT_MAX) return (int16_t)(SHRT_MAX - 1); // return (int16_t)t_ms; //} static int parse_breakpoint_event_core_float_lin(char* message, uint32_t *times_ms, float *values) { float vals[2 * MAX_BREAKPOINTS]; int num_vals = parse_list_float(message, vals, 2 * MAX_BREAKPOINTS, AMY_UNSET_VALUE(vals[0])); for (int i = 0; i < num_vals; ++i) { int bp_index = (i >> 1); if (bp_index >= MAX_BREAKPOINTS) break; if ((i % 2) == 0) { if (AMY_IS_SET(vals[i])) { int32_t t_ms = (int32_t)vals[i]; if (t_ms < 0) t_ms = 0; times_ms[bp_index] = (uint32_t)t_ms; // clamp_bp_time_ms_to_i16((uint32_t)t_ms); } else { AMY_UNSET(times_ms[bp_index]); } } else { values[bp_index] = vals[i]; } } return num_vals; } static int parse_breakpoint_event_core_int_db(char* message, uint32_t *times_ms, float *values) { uint32_t vals[2 * MAX_BREAKPOINTS]; int num_vals = parse_list_uint32_t(message, vals, 2 * MAX_BREAKPOINTS, AMY_UNSET_VALUE(vals[0])); for (int i = 0; i < num_vals; ++i) { int bp_index = (i >> 1); if (bp_index >= MAX_BREAKPOINTS) break; if ((i % 2) == 0) { if (AMY_IS_SET(vals[i])) { times_ms[bp_index] = vals[i]; // clamp_bp_time_ms_to_i16(vals[i]); } else { AMY_UNSET(times_ms[bp_index]); } } else { values[bp_index] = int_db_to_float_lin(vals[i]); //values[bp_index] = int_db_to_60dB_01(vals[i]); } } return num_vals; } static void parse_event_breakpoints(char *message, uint32_t *times_ms, float *values) { int num_vals = 0; for (int i = 0; i < MAX_BREAKPOINTS; ++i) { AMY_UNSET(times_ms[i]); AMY_UNSET(values[i]); } if (message[0] == '.' && message[1] == '.') { num_vals = parse_breakpoint_event_core_int_db(message + 2, times_ms, values); } else { num_vals = parse_breakpoint_event_core_float_lin(message, times_ms, values); } for (int i = num_vals; i < 2 * MAX_BREAKPOINTS; ++i) { int bp_index = (i >> 1); if (bp_index < MAX_BREAKPOINTS) { if ((i % 2) == 0) AMY_UNSET(times_ms[bp_index]); else AMY_UNSET(values[bp_index]); } } } // helper to parse the list of source oscs for an algorithm void parse_algo_source(char *message, int16_t *vals) { int num_parsed = parse_list_int16_t(message, vals, MAX_ALGO_OPS, AMY_UNSET_VALUE(vals[0])); // Clear unspecified values. for (int i = num_parsed; i < MAX_ALGO_OPS; ++i) { AMY_UNSET(vals[i]); } } void parse_voices(char *message, uint16_t *vals) { int num_parsed = parse_list_uint16_t(message, vals, MAX_VOICES_PER_INSTRUMENT, AMY_UNSET_VALUE(vals[0])); // Clear unspecified values. for (int i = num_parsed; i < MAX_VOICES_PER_INSTRUMENT; ++i) { AMY_UNSET(vals[i]); } } uint32_t ms_to_samples(uint32_t ms) { uint32_t samps = 0; if (AMY_IS_UNSET(ms)) return AMY_UNSET_VALUE(samps); samps = (uint32_t)(((float)ms / 1000.0) * (float)AMY_SAMPLE_RATE); return samps; } void parse_coef_message(char *message, float *coefs) { int num_coefs = parse_list_float(message, coefs, NUM_COMBO_COEFS, AMY_UNSET_VALUE(coefs[0])); // Clear the unspecified coefs to unset. for (int i = num_coefs; i < NUM_COMBO_COEFS; ++i) coefs[i] = AMY_UNSET_VALUE(coefs[0]); } #if defined(TULIP) || defined(AMYBOARD) extern const mp_obj_fun_builtin_var_t tulip_pcm_load_file_obj; #endif int parse_midi_cc_payload(char *message, int32_t *p_cc_code, int32_t *p_is_log, float *p_min_val, float *p_max_val, float *p_offset_val) { char *m = message; m += parse_val_int32_t(m, p_cc_code); if (m[0] != ',') goto end; else ++m; m += parse_val_int32_t(m, p_is_log); if (m[0] != ',') goto end; else ++m; m += parse_val_float(m, p_min_val); if (m[0] != ',') goto end; else ++m; m += parse_val_float(m, p_max_val); if (m[0] != ',') goto end; else ++m; m += parse_val_float(m, p_offset_val); end: return m - message; } // Parser for synth-layer ('i') prefix. int amy_parse_synth_layer_message(char *message, amy_event *e) { int skip_chars = 1; // default is to skip one extra char. if (message[0] >= '0' && message[0] <= '9') { // It's just the instrument number. e->synth = atoi(message); return 0; // no extra skip. } char cmd = message[0]; message++; if (cmd == 'p') e->pedal = atoi(message); else if (cmd == 'f') e->synth_flags = atoi(message); else if (cmd == 'v') e->num_voices = atoi(message); else if (cmd == 't') e->to_synth = atoi(message); else if (cmd == 'm') e->grab_midi_notes = atoi(message); else if (cmd == 'd') e->synth_delay_ms = atoi(message); else if (cmd == 'n') e->oscs_per_voice = atoi(message); else if (cmd == 'c') { // MIDI CC mapping ic,,,,,, see https://github.com/shorepine/amy/issues/524 // ic255 clears all MIDI CC mappings for this synth (short form, no extra fields needed). int32_t cc_code, is_log; float min_val, max_val, offset_val; AMY_UNSET(cc_code); AMY_UNSET(is_log); skip_chars = parse_midi_cc_payload(message, &cc_code, &is_log, &min_val, &max_val, &offset_val); if (*(message + skip_chars) != ',') { if (AMY_IS_UNSET(cc_code) || AMY_IS_SET(is_log)) { // Either parsing bailed without even a CC code, or it got past the is_log, meaning it wasn't a bare ic command. fprintf(stderr, "synth_layer: midi cc payload didn't parse for %s.\n", message - 1); return skip_chars; // maybe the rest will parse? } // Else we got an incomplete message with a valid CC code - clear it midi_clear_control_code(e->synth, cc_code); // (handles 255 as special case). return skip_chars; } ++skip_chars; // step over the "," before the wire string template. midi_store_control_code(e->synth, cc_code, is_log, min_val, max_val, offset_val, message + skip_chars); // Consume rest of message but leave the trailing 'Z' for the outer parser. int remainder = strlen(message); if (remainder > 0 && message[remainder - 1] == 'Z') remainder--; skip_chars = remainder; } else fprintf(stderr, "Unrecognized synth-level command '%s'\n", message - 1); return skip_chars; } // Parser for transfer-layer ('z') prefix. Returns how much of a message to skip uint16_t amy_parse_transfer_layer_message(char *message) { if (message[0] >= '0' && message[0] <= '9') { // z: Signal to start loading sample. // Params: preset number, length(frames), samplerate, midinote, loopstart, loopend. uint32_t sm[6]; // preset, length, SR, midinote, loop_start, loopend parse_list_uint32_t(message, sm, 6, 0); if(sm[1]==0) { // remove preset pcm_unload_preset(sm[0]); } else { int16_t * ram = pcm_load(sm[0], sm[1], sm[2], 1, sm[3], sm[4], sm[5]); start_receiving_transfer(sm[1]*2, (uint8_t*)ram); } return 0; } char cmd = message[0]; message++; if (cmd == 'T') { // zT: Signal to start loading file. //Params: Destination name, file size. uint32_t file_size = 0; char filename[MAX_FILENAME_LEN]; uint16_t len = parse_list_file_transfer_params(message, filename, sizeof(filename), &file_size); if (filename[0] != '\0') { sequencer_midi_stop(); // Stop sequencer (and sketch loop) during file transfer. start_receiving_file_transfer(file_size, filename); } return len; } else if (cmd == 'F') { // zF: setup PCM preset from WAV filename on disk. // Params: Preset number, filename, midi note uint32_t preset = 0; uint32_t midinote = 0; char filename[MAX_FILENAME_LEN]; uint16_t len = parse_list_file_params(message, &preset, filename, sizeof(filename), &midinote); if (filename[0] != '\0') { amy_global.transfer_stored_bytes = midinote; strncpy(amy_global.transfer_filename, filename, MAX_FILENAME_LEN); amy_global.transfer_file_handle = preset; // For tulip/amyboard we have to load the PCM file from the MP "task" #if (defined AMYBOARD) || (defined TULIP) mp_sched_schedule(MP_OBJ_FROM_PTR(&tulip_pcm_load_file_obj), mp_const_none); #else pcm_load_file(); #endif } return len; } else if (cmd == 'S') { // zS: sample from BUS[1] to a memorypcm patch. // Params: Preset number, bus, max length in frames,midinote,loopstart,loopend uint32_t sm[6]; // preset, bus, max frames, midinote, loop_start, loopend parse_list_uint32_t(message, sm, 6, 0); int16_t * ram = pcm_load(sm[0], sm[2], AMY_SAMPLE_RATE, 2, sm[3], sm[4], sm[5]); start_receiving_sample(sm[2], sm[1], ram); return 1; } else if (cmd == 'O') { //zO: stop sampling from any bus stop_receiving_sample(); return 1; } else if (cmd == 'D') { // zD: Dump data over MIDI sysex. // zD[Z] — dump all active instrument state + global effects. // zD[Z] — dump file contents from the filesystem. // The filename/payload is "rest of message" — we consume everything // to the end of the C string. A trailing 'Z' (end-of-message marker // some senders append) is stripped, so interior capital-Z characters // in the filename (e.g. "/ZIPFILE.py") are preserved. Limitation: // filenames whose last char is 'Z' are not addressable. char filename[MAX_FILENAME_LEN]; uint16_t len = 0; while (message[len] && len < MAX_FILENAME_LEN - 1) { filename[len] = message[len]; len++; } filename[len] = '\0'; if (len > 0 && filename[len - 1] == 'Z') { filename[--len] = '\0'; } if (filename[0] == '\0') { amy_dump_state_to_sysex(); } else { amy_dump_file_to_sysex(filename); } // Consume the whole rest of the message so the outer parser exits. { uint16_t total = 0; const char *scan = message - 1; // back to 'D' while (scan[total]) total++; return total; } } else if (cmd == 'A') { // zA: Update sketch.py on disk with current AMY state (calls update_file_hook). // Takes optional filename; defaults to /user/current/sketch.py on AMYboard. // Payload semantics match zD: the filename is "rest of message", a // trailing 'Z' terminator is stripped, and interior capital-Z chars // in the filename are preserved. char filename[MAX_FILENAME_LEN]; uint16_t len = 0; while (message[len] && len < MAX_FILENAME_LEN - 1) { filename[len] = message[len]; len++; } filename[len] = '\0'; if (len > 0 && filename[len - 1] == 'Z') { filename[--len] = '\0'; } if (amy_global.config.amy_external_update_file_hook) { if (filename[0]) { amy_global.config.amy_external_update_file_hook(filename); } else { amy_global.config.amy_external_update_file_hook("/user/current/sketch.py"); } } { uint16_t total = 0; const char *scan = message - 1; while (scan[total]) total++; return total; } } else if (cmd == 'P') { // zP: Execute Python code on host (e.g. zPimport amyboard; amyboard.restart_sketch()Z). // Payload semantics match zD: the code string is "rest of message", // a trailing 'Z' terminator is stripped, and interior capital-Z chars // in the code are preserved. char code[256]; uint16_t len = 0; while (message[len] && len < sizeof(code) - 1) { code[len] = message[len]; len++; } code[len] = '\0'; if (len > 0 && code[len - 1] == 'Z') { code[--len] = '\0'; } if (amy_global.config.amy_external_exec_hook) { amy_global.config.amy_external_exec_hook(code); } { uint16_t total = 0; const char *scan = message - 1; while (scan[total]) total++; return total; } } else fprintf(stderr, "Unrecognized transfer-level command '%s'\n", message - 1); return 0; } int _next_alpha(char *s) { // Return how many chars to skip to get to the next alphabet (command prefix) (or EOS). int p = 0; while (*(s + p)) { char c = *(s + p); if (isalpha(c)) break; ++p; } return p; } // given a string return a parsed event int amy_parse_message(char * message, int length, amy_event *e) { peek_stack("parse_message"); char cmd = '\0'; uint16_t pos = 0; // Check if we're in a transfer block, if so, parse it and leave this loop. // FILE transfers (zT, used to write files over MIDI sysex) arrive async // while a sketch may also be running, so we ONLY route them to the // transfer handler when the data is sysex-originated -- otherwise a // sketch calling amy.send(note=36) mid-transfer would get its wire // command base64-decoded as file data and corrupt the file. // // AUDIO transfers (amy.load_sample / load_sample_bytes) are different: // Python sends every chunk synchronously in a tight loop within the same // call, so no other amy.send() can interleave. They route regardless of // the sysex flag (which they don't carry, since send_raw goes through // the regular wire path). extern bool amy_parsing_from_sysex; if (amy_global.transfer_flag == AMY_TRANSFER_TYPE_AUDIO || (amy_parsing_from_sysex && amy_global.transfer_flag == AMY_TRANSFER_TYPE_FILE)) { parse_transfer_message(message, length); e->status = EVENT_TRANSFER_DATA; return length; } while(pos < length) { cmd = message[pos]; char *arg = message + pos + 1; if(isalpha(cmd)) { switch(cmd) { case 'a': parse_coef_message(arg, e->amp_coefs);break; case 'A': { char bp_msg[MAX_PARAM_LEN]; copy_param_list_substring(bp_msg, arg); parse_event_breakpoints(bp_msg, e->eg0_times, e->eg0_values); e->bp_is_set[0] = 1; break; } case 'B': { char bp_msg[MAX_PARAM_LEN]; copy_param_list_substring(bp_msg, arg); parse_event_breakpoints(bp_msg, e->eg1_times, e->eg1_values); e->bp_is_set[1] = 1; break; } case 'b': e->feedback = atoff(arg); break; case 'c': e->chained_osc = atoi(arg); break; /* C available */ case 'd': parse_coef_message(arg, e->duty_coefs);break; case 'D': show_debug(atoi(arg)); break; case 'f': parse_coef_message(arg, e->freq_coefs);break; case 'F': parse_coef_message(arg, e->filter_freq_coefs); break; case 'G': e->filter_type = atoi(arg); break; /* g used for Alles for client # */ case 'H': parse_list_uint32_t(arg, e->sequence, 3, 0); break; case 'h': if (AMY_HAS_REVERB) { float reverb_params[4]; parse_list_float(arg, reverb_params, 4, AMY_UNSET_VALUE(amy_global.reverb.liveness)); e->reverb_level = reverb_params[0]; e->reverb_liveness = reverb_params[1]; e->reverb_damping = reverb_params[2]; e->reverb_xover_hz = reverb_params[3]; } break; /* i is used by alles for sync index -- but only for sync messages -- ok to use here but test */ case 'i': pos += amy_parse_synth_layer_message(arg, e); break; // Skip over second cmd letter, if any, or entire MIDI CC code string. case 'I': e->ratio = atoff(arg); break; case 'j': e->tempo = atof(arg); break; /* j, J available */ // chorus.level case 'k': if(AMY_HAS_CHORUS) { float chorus_params[4]; parse_list_float(arg, chorus_params, 4, AMY_UNSET_FLOAT); e->chorus_level = chorus_params[0]; e->chorus_max_delay = chorus_params[1]; e->chorus_lfo_freq = chorus_params[2]; e->chorus_depth = chorus_params[3]; } break; case 'K': e->patch_number = atoi(arg); break; case 'l': e->velocity=atoff(arg); break; case 'L': e->mod_source=atoi(arg); break; case 'm': e->portamento_ms=atoi(arg); break; case 'M': if (AMY_HAS_ECHO) { float echo_params[5]; parse_list_float(arg, echo_params, 5, AMY_UNSET_FLOAT); e->echo_level = echo_params[0]; e->echo_delay_ms = echo_params[1]; e->echo_max_delay_ms = echo_params[2]; e->echo_feedback = echo_params[3]; e->echo_filter_coef = echo_params[4]; } break; case 'n': e->midi_note=atof(arg); break; case 'N': e->latency_ms = atoi(arg); break; case 'o': e->algorithm=atoi(arg); break; case 'O': parse_algo_source(arg, e->algo_source); break; case 'p': e->preset=atoi(arg); break; case 'P': e->trigger_phase=atoff(arg); break; /* q unused */ case 'Q': parse_coef_message(arg, e->pan_coefs); break; case 'r': parse_voices(arg, e->voices); break; case 'R': e->resonance=atoff(arg); break; case 's': e->pitch_bend = atoff(arg); break; case 'S': e->reset_osc = atoi(arg); // if we're resetting all of AMY, do it now if (e->reset_osc & (RESET_AMY | RESET_TIMEBASE | RESET_EVENTS | RESET_SYNTHS)) { if(e->reset_osc & RESET_AMY) { amy_stop(); amy_start(amy_global.config); } // if we're resetting timebase, do it NOW if(e->reset_osc & RESET_TIMEBASE) { amy_reset_sysclock(); } if(e->reset_osc & RESET_EVENTS) { amy_deltas_reset(); } if(e->reset_osc & RESET_SYNTHS) { amy_reset_oscs(); } AMY_UNSET(e->reset_osc); } break; /* t used for time */ case 't': e->time=atol(arg); break; case 'T': e->eg_type[0] = atoi(arg); break; case 'u': patches_store_patch(e, arg); pos = strlen(message) - 1; break; // patches_store_patch processes the patch as all the rest of the message and maybe sets patch. /* U used by Alles for sync */ case 'v': e->osc=((atoi(arg)) % (AMY_OSCS+1)); break; // allow osc wraparound case 'V': e->volume = atoff(arg); break; case 'w': e->wave=atoi(arg); break; /* W used by Tulip for CV, external_channel */ case 'X': e->eg_type[1] = atoi(arg); break; case 'x': { float eq[3] = {AMY_UNSET_VALUE(e->eq_l), AMY_UNSET_VALUE(e->eq_m), AMY_UNSET_VALUE(e->eq_h)}; parse_list_float(arg, eq, 3, AMY_UNSET_VALUE(e->eq_l)); e->eq_l = eq[0]; e->eq_m = eq[1]; e->eq_h = eq[2]; } break; case 'z': { pos += amy_parse_transfer_layer_message(arg); break; } /* Y,y available */ /* Z used for end of message */ case 'Z': ++pos; goto end; default: break; } } // Skip over arg, line up for the next cmd. ++pos; // move over the current command. if (pos > length) fprintf(stderr, "parse string overrun %d %d %s\n", pos, length, message); pos += _next_alpha(message + pos); // Skip over any non-alpha argument to the current command. } end: // Return exactly how many characters we used. return pos; } ================================================ FILE: src/patches.c ================================================ // patches.c // baked in AMY string patches (Juno-6 & DX7 for now) #include "amy.h" #include "patches.h" #include // for buffer overruns in sprint_event. #define _PATCHES_FIRST_USER_PATCH 1024 uint32_t max_num_memory_patches = 0; struct delta **memory_patch_deltas = NULL; uint16_t *memory_patch_oscs = NULL; uint16_t next_user_patch_index = 0; uint8_t * osc_to_voice = NULL; uint16_t *voice_to_base_osc = NULL; void patches_deinit() { memory_patch_deltas = NULL; memory_patch_oscs = NULL; osc_to_voice = NULL; voice_to_base_osc = NULL; } void patches_init(int max_memory_patches) { max_num_memory_patches = max_memory_patches; uint8_t *alloc_base = malloc_caps( max_num_memory_patches * sizeof(struct delta *) + max_num_memory_patches * sizeof(uint16_t) + AMY_OSCS * sizeof(uint8_t) + amy_global.config.max_voices * sizeof(uint16_t), amy_global.config.ram_caps_synth ); memory_patch_deltas = (struct delta **)alloc_base; memory_patch_oscs = (uint16_t *)(memory_patch_deltas + max_num_memory_patches); osc_to_voice = (uint8_t *)(memory_patch_oscs + max_num_memory_patches); voice_to_base_osc = (uint16_t *)(osc_to_voice + AMY_OSCS); bzero(memory_patch_deltas, max_num_memory_patches * sizeof(struct delta *)); patches_reset(); } void patches_reset_patch(int patch_number) { int patch_index = patch_number - _PATCHES_FIRST_USER_PATCH; if (patch_index < 0 || patch_index >= (int)max_num_memory_patches) { fprintf(stderr, "reset patch number %" PRId32 " is out of range (%" PRId32 " .. %" PRId32 ")\n", (int32_t)(patch_index + _PATCHES_FIRST_USER_PATCH), (int32_t)_PATCHES_FIRST_USER_PATCH, (int32_t)(_PATCHES_FIRST_USER_PATCH + (int32_t)max_num_memory_patches)); return; } if (memory_patch_deltas[patch_index] != NULL) delta_release_list(memory_patch_deltas[patch_index]); memory_patch_deltas[patch_index] = NULL; memory_patch_oscs[patch_index] = 0; } void patches_reset() { for(uint32_t v = 0; v < amy_global.config.max_voices; v++) { AMY_UNSET(voice_to_base_osc[v]); } for(uint32_t i = 0; i < AMY_OSCS; i++) { AMY_UNSET(osc_to_voice[i]); } for(uint32_t i = 0; i < max_num_memory_patches; i++) { patches_reset_patch(_PATCHES_FIRST_USER_PATCH + i); } next_user_patch_index = 0; } void patches_debug() { for(uint8_t v = 0; v < amy_global.config.max_voices; v++) { if (AMY_IS_SET(voice_to_base_osc[v])) fprintf(stderr, "voice %" PRIu8 " base osc %" PRIu16 "\n", v, voice_to_base_osc[v]); } fprintf(stderr, "osc_to_voice:\n"); for(uint16_t i=0;i= AMY_OSCS) break; fprintf(stderr, "%" PRIu8 " ", osc_to_voice[i + j]); } i += j; fprintf(stderr, "\n"); } for(uint8_t i = 0; i < max_num_memory_patches; i++) { if(memory_patch_oscs[i]) fprintf(stderr, "memory_patch %" PRIu16 " oscs %" PRIu16 " #deltas %" PRIi32 "\n", (uint16_t)(i + _PATCHES_FIRST_USER_PATCH), memory_patch_oscs[i], delta_list_len(memory_patch_deltas[i])); } uint16_t voices[MAX_VOICES_PER_INSTRUMENT]; for (uint8_t i = 0; i < 32 /* MAX_INSTRUMENTS */; ++i) { int num_voices = instrument_get_num_voices(i, voices); if (num_voices) { fprintf(stderr, "synth %" PRIu8 " num_voices %" PRId32 " patch_num %" PRId32 " flags %" PRIu32 " voices", i, (int32_t)num_voices, (int32_t)instrument_get_patch_number(i), instrument_get_flags(i)); for (int j = 0; j < num_voices; ++j) fprintf(stderr, " %" PRIu16, voices[j]); fprintf(stderr, "\n"); } } } struct delta **queue_for_patch_number(int patch_number) { int patch_index = patch_number - _PATCHES_FIRST_USER_PATCH; if (patch_index < 0 || patch_index >= (int)max_num_memory_patches) { fprintf(stderr, "queue for patch number %" PRId32 " is out of range (%" PRId32 " .. %" PRId32 ")\n", (int32_t)(patch_index + _PATCHES_FIRST_USER_PATCH), (int32_t)_PATCHES_FIRST_USER_PATCH, (int32_t)(_PATCHES_FIRST_USER_PATCH + (int32_t)max_num_memory_patches)); return NULL; } return &memory_patch_deltas[patch_index]; } void update_num_oscs_for_patch_number(int patch_number) { int patch_index = patch_number - _PATCHES_FIRST_USER_PATCH; if (patch_index < 0 || patch_index >= (int)max_num_memory_patches) { fprintf(stderr, "queue for patch number %" PRId32 " is out of range (%" PRId32 " .. %" PRId32 ")\n", (int32_t)(patch_index + _PATCHES_FIRST_USER_PATCH), (int32_t)_PATCHES_FIRST_USER_PATCH, (int32_t)(_PATCHES_FIRST_USER_PATCH + (int32_t)max_num_memory_patches)); return; } int num_oscs = 0; struct delta *d = memory_patch_deltas[patch_index]; while(d) { if (d->osc >= num_oscs) num_oscs = d->osc + 1; d = d->next; } memory_patch_oscs[patch_index] = num_oscs; } void all_notes_off() { for(uint16_t i=0;istatus == SYNTH_AUDIBLE) { synth[i]->status = SYNTH_INAUDIBLE; } } } } void add_deltas_to_queue_with_baseosc(struct delta *d, int base_osc, struct delta **queue, uint32_t time) { //fprintf(stderr, "add_deltas_to_queue_with_baseosc: added %d baseosc %d time %d\n", delta_list_len(d), base_osc, time); struct delta d_offset; while(d) { d_offset = *d; d_offset.osc += base_osc; if (d_offset.param == CHAINED_OSC || d_offset.param == MOD_SOURCE || d_offset.param == RESET_OSC || (d_offset.param >= ALGO_SOURCE_START && d_offset.param < ALGO_SOURCE_START + MAX_ALGO_OPS)) if (!(AMY_IS_UNSET((int16_t)d_offset.data.i) || AMY_IS_UNSET((uint16_t)d_offset.data.i))) // CHAINED_OSC is uint16_t, but ALGO_SOURCE is int16_t. d_offset.data.i += base_osc; d_offset.time = time; // assume the d->time is 0 and that's good. add_delta_to_queue(&d_offset, &amy_global.delta_queue); d = d->next; } } #define _EPRINT_I(FIELD, NAME, WIRECODE) if (AMY_IS_SET(e->FIELD)) { sprintf(s, "%s%" PRId32, wirecode ? WIRECODE : " " NAME ": ", (int32_t)e->FIELD); s += strlen(s); } #define _EPRINT_F(FIELD, NAME, WIRECODE) if (AMY_IS_SET(e->FIELD)) { sprintf(s, "%s%.3f", wirecode ? WIRECODE : " " NAME ": ", e->FIELD); s += strlen(s); } #define _EPRINT_COEF(FIELD, NAME, WIRECODE) { \ int last_set = -1; \ for (int i = 0; i < NUM_COMBO_COEFS; ++i) { \ if (AMY_IS_SET(e->FIELD[i])) last_set = i; \ } \ if (last_set >= 0) { \ sprintf(s, "%s", wirecode ? WIRECODE : " " NAME ": "); \ s += strlen(s); \ for (int i = 0; i <= last_set; ++i) { \ if (i > 0) { sprintf(s, ","); s += strlen(s); } \ if (AMY_IS_SET(e->FIELD[i])) { \ sprintf(s, "%.3f", e->FIELD[i]); \ s += strlen(s); \ } \ } \ } \ } #define _EPRINT_I_SEQ(FIELD, NAME, LEN, WIRECODE) { \ int last_set = -1; \ for (int i = 0; i < LEN; ++i) { \ if (AMY_IS_SET(e->FIELD[i])) last_set = i; \ } \ if (last_set >= 0) { \ sprintf(s, "%s", wirecode ? WIRECODE : " " NAME ": "); \ s += strlen(s); \ for (int i = 0; i <= last_set; ++i) { \ if (i > 0) { sprintf(s, ","); s += strlen(s); } \ if (AMY_IS_SET(e->FIELD[i])) { \ sprintf(s, "%" PRId32, (int32_t)e->FIELD[i]); \ s += strlen(s); \ } \ } \ } \ } #define _EPRINT_BP(TFIELD, VFIELD, NAME, WIRECODE) { \ int last_set = -1; \ for (int i = 0; i < MAX_BPS; ++i) { \ if (AMY_IS_SET(e->TFIELD[i]) || AMY_IS_SET(e->VFIELD[i])) last_set = i; \ } \ if (last_set >= 0) { \ sprintf(s, "%s", wirecode ? WIRECODE : " " NAME ": "); \ s += strlen(s); \ for (int i = 0; i <= last_set; ++i) { \ if (i > 0) { sprintf(s, ","); s += strlen(s); } \ if (AMY_IS_SET(e->TFIELD[i])) { \ sprintf(s, "%" PRIu32, e->TFIELD[i]); \ s += strlen(s); \ } \ sprintf(s, ","); \ s += strlen(s); \ if (AMY_IS_SET(e->VFIELD[i])) { \ sprintf(s, "%.3f", e->VFIELD[i]); \ s += strlen(s); \ } \ } \ } \ } #define _EPRINT_VALS_5(VAL1, VAL2, VAL3, VAL4, VAL5, NAME, WIRECODE) { \ float vals[] = {VAL1, VAL2, VAL3, VAL4, VAL5}; \ int n_vals = sizeof(vals) / sizeof(float); \ int last_one = -1; \ for (int i = 0; i < n_vals; ++i) { \ if (AMY_IS_SET(vals[i])) last_one = i; \ } \ if (last_one >= 0) { \ sprintf(s, "%s", wirecode ? WIRECODE : " " NAME ": "); \ s += strlen(s); \ for (int j = 0; j <= last_one; ++j) { \ if (AMY_IS_SET(vals[j])) { \ sprintf(s, "%.3f", vals[j]); \ s += strlen(s); \ } \ if (j < last_one) { \ sprintf(s, ","); \ s += strlen(s); \ } \ } \ } \ } int sprint_event(amy_event *e, char *s, size_t len, bool wirecode) { // Convert an event into a string, either human-readable or wirecode. // s must be allocated. len tells us how big it is. // Return is how many chrs written to s. Will abort if it overruns. char *s_entry = s; if (!wirecode) { sprintf(s, "amy_event(time=%" PRIu32 ", osc=%" PRIu16 "): ", e->time, e->osc); s += strlen(s); } else { if (AMY_IS_SET(e->time)) { sprintf(s, "t%" PRIu32, (int32_t)e->time); s += strlen(s); } if (AMY_IS_SET(e->osc)) { sprintf(s, "v%" PRIu16, (int16_t)e->osc); s += strlen(s); } } _EPRINT_I(wave, "wave", "w"); _EPRINT_I(preset, "preset", "p"); _EPRINT_F(midi_note, "midi_note", "n"); _EPRINT_F(velocity, "velocity", "l"); _EPRINT_I(patch_number, "patch_number", "K"); _EPRINT_COEF(amp_coefs, "amp_coefs", "a"); _EPRINT_COEF(freq_coefs, "freq_coefs", "f"); _EPRINT_COEF(filter_freq_coefs, "filter_freq_coefs", "F"); _EPRINT_COEF(duty_coefs, "duty_coefs", "d"); _EPRINT_COEF(pan_coefs, "pan_coefs", "Q"); _EPRINT_F(feedback, "feedback", "b"); _EPRINT_F(trigger_phase, "phase", "P"); _EPRINT_F(volume, "volume", "V"); // NOT osc-dep _EPRINT_F(pitch_bend, "pitch_bend", "s"); // NOT osc-dep _EPRINT_F(tempo, "tempo", "j"); // NOT osc-dep _EPRINT_I(latency_ms, "latency_ms", "N"); // NOT osc-dep _EPRINT_F(ratio, "ratio", "I"); _EPRINT_F(resonance, "resonance", "R"); _EPRINT_I(portamento_ms, "portamento_ms", "m"); _EPRINT_I(chained_osc, "chained_osc", "c"); _EPRINT_I(mod_source, "mod_source", "L"); _EPRINT_I(algorithm, "algorithm", "o"); _EPRINT_I(filter_type, "filter_type", "G"); _EPRINT_I_SEQ(bp_is_set, "bp_is_set", MAX_BREAKPOINT_SETS, "??"); // Convert these two at least to vectors of ints, save several hundred bytes _EPRINT_I_SEQ(algo_source, "algo_source", MAX_ALGO_OPS, "O"); _EPRINT_I_SEQ(voices, "voices", MAX_VOICES_PER_INSTRUMENT, "r"); _EPRINT_BP(eg0_times, eg0_values, "eg0", "A"); _EPRINT_BP(eg1_times, eg1_values, "eg1", "B"); _EPRINT_I(eg_type[0], "eg_type[0]", "T"); _EPRINT_I(eg_type[1], "eg_type[1]", "X"); // Instrument-layer values. _EPRINT_I(synth, "synth", "i"); _EPRINT_I(synth_flags, "synth_flags", "if"); // Special flags to set when defining instruments. _EPRINT_I(synth_delay_ms, "synth_delay_ms", "id"); // Extra delay added to synth note-ons to allow decay on voice-stealing. _EPRINT_I(to_synth, "to_synth", "it"); // For moving setup between synth numbers. _EPRINT_I(grab_midi_notes, "grab_midi_notes", "im"); // To enable/disable automatic MIDI note-on/off generating note-on/off. _EPRINT_I(pedal, "pedal", "ip"); // MIDI pedal value. _EPRINT_I(num_voices, "num_voices", "iv"); _EPRINT_I(oscs_per_voice, "oscs_per_voice", "in"); _EPRINT_I_SEQ(sequence, "sequence", 3, "H"); // tick, period, tag // //_EPRINT_I(status, "status"); _EPRINT_I(note_source, "note_source", "??"); // .. to mark note on/offs that come from MIDI so we don't send them back out again. _EPRINT_I(reset_osc, "reset_osc", "S"); // Global effects _EPRINT_VALS_5(e->eq_l, e->eq_m, e->eq_h, AMY_UNSET_FLOAT, AMY_UNSET_FLOAT, "eq_{l,m,h}", "x"); _EPRINT_VALS_5(e->echo_level, e->echo_delay_ms, e->echo_max_delay_ms, e->echo_feedback, e->echo_filter_coef, "echo_{level,delay,max,fb,filt}", "M"); _EPRINT_VALS_5(e->chorus_level, e->chorus_max_delay, e->chorus_lfo_freq, e->chorus_depth, AMY_UNSET_FLOAT, "chorus_{level,delay,lfo,depth}", "k"); _EPRINT_VALS_5(e->reverb_level, e->reverb_liveness, e->reverb_damping, e->reverb_xover_hz, AMY_UNSET_FLOAT, "reverb_{level,live,damp,xover}", "h"); if (wirecode && (s - s_entry) > 0) { sprintf(s, "Z"); s += strlen(s); } assert( ((size_t)(s - s_entry)) < len); // if we corrupted memory, at least we'll abort. return s - s_entry; } #define _CASE_I(FIELD, PARAM) case PARAM: event->FIELD = queue->data.i; break; #define _CASE_F(FIELD, PARAM) case PARAM: event->FIELD = queue->data.f; break; #define _CASE_LOG(FIELD, PARAM) case PARAM: event->FIELD = exp2f(queue->data.f); break; #define _TEST_COEFS(FIELD, PARAM) \ for (int i = 0; i < NUM_COMBO_COEFS; ++i) { \ if ((int)queue->param == (int)PARAM + i) event->FIELD[i] = queue->data.f; \ } \ // Const freq coef is in Hz, rest are linear. #define _TEST_FREQ_COEFS(FIELD, PARAM) \ for (int i = 0; i < NUM_COMBO_COEFS; ++i) { \ if ((int)queue->param == (int)PARAM + i) { \ if (i == COEF_CONST) \ event->FIELD[i] = freq_of_logfreq(queue->data.f); \ else \ event->FIELD[i] = queue->data.f; \ } \ } struct delta *deltas_to_event(struct delta *queue, struct amy_event *event) { // Consume deltas from queue and push into event. Return pointer to first non-consumed delta. if (queue == NULL) return NULL; event->osc = queue->osc; event->time = queue->time; uint32_t breakpoint_times[MAX_BREAKPOINT_SETS][MAX_BREAKPOINTS]; float breakpoint_values[MAX_BREAKPOINT_SETS][MAX_BREAKPOINTS]; for (int i = 0; i < MAX_BREAKPOINT_SETS; ++i) { for (int j = 0; j < MAX_BREAKPOINTS; ++j) { AMY_UNSET(breakpoint_times[i][j]); AMY_UNSET(breakpoint_values[i][j]); } } int highest_breakpoint[MAX_BREAKPOINT_SETS] = {-1, -1}; while(queue != NULL) { if (queue->osc != event->osc || queue->time != event->time) break; // delta doesn't fit this event. switch (queue->param) { _CASE_I(wave, WAVE) _CASE_I(preset, PRESET) _CASE_F(midi_note, MIDI_NOTE) _CASE_F(feedback, FEEDBACK) _CASE_F(trigger_phase, PHASE) _CASE_F(volume, VOLUME) _CASE_F(pitch_bend, PITCH_BEND) _CASE_I(latency_ms, LATENCY) _CASE_F(tempo, TEMPO) _CASE_LOG(ratio, RATIO) _CASE_F(resonance, RESONANCE) _CASE_I(portamento_ms, PORTAMENTO) _CASE_I(chained_osc, CHAINED_OSC) _CASE_I(reset_osc, RESET_OSC) _CASE_I(mod_source, MOD_SOURCE) _CASE_I(note_source, NOTE_SOURCE) _CASE_I(filter_type, FILTER_TYPE) _CASE_I(algorithm, ALGORITHM) _CASE_F(eq_l, EQ_L) _CASE_F(eq_m, EQ_M) _CASE_F(eq_h, EQ_H) _CASE_F(echo_max_delay_ms, ECHO_MAX_DELAY_MS) _CASE_F(echo_level, ECHO_LEVEL) _CASE_F(echo_delay_ms, ECHO_DELAY_MS) _CASE_F(echo_feedback, ECHO_FEEDBACK) _CASE_F(echo_filter_coef, ECHO_FILTER_COEF) _CASE_F(chorus_max_delay, CHORUS_MAX_DELAY) _CASE_F(chorus_level, CHORUS_LEVEL) _CASE_F(chorus_lfo_freq, CHORUS_LFO_FREQ) _CASE_F(chorus_depth, CHORUS_DEPTH) _CASE_F(reverb_level, REVERB_LEVEL) _CASE_F(reverb_liveness, REVERB_LIVENESS) _CASE_F(reverb_damping, REVERB_DAMPING) _CASE_F(reverb_xover_hz, REVERB_XOVER_HZ) _CASE_I(eg_type[0], EG0_TYPE) _CASE_I(eg_type[1], EG1_TYPE) _CASE_F(velocity, VELOCITY) default: // blocks, not handled by case _TEST_COEFS(amp_coefs, AMP) _TEST_FREQ_COEFS(freq_coefs, FREQ) _TEST_FREQ_COEFS(filter_freq_coefs, FILTER_FREQ) _TEST_COEFS(duty_coefs, DUTY) _TEST_COEFS(pan_coefs, PAN) for (int i = 0; i < MAX_ALGO_OPS; ++i) { if ((int)queue->param == (int)ALGO_SOURCE_START + i) event->algo_source[i] = queue->data.i; } for (int i = 0; i < MAX_BREAKPOINT_SETS; ++i) { for (int j = 0; j < MAX_BREAKPOINTS; ++j) { if ((int)queue->param == (int)BP_START + (j * 2) + (i * MAX_BREAKPOINTS * 2)) { //event->bp[i].time[j] = queue->data.i; breakpoint_times[i][j] = queue->data.i; if (j > highest_breakpoint[i]) highest_breakpoint[i] = j; } else if ((int)queue->param == (int)BP_START + (j * 2 + 1) + (i * MAX_BREAKPOINTS * 2)) { //event->bp[i].value[j] = queue->data.f; breakpoint_values[i][j] = queue->data.f; if (j > highest_breakpoint[i]) highest_breakpoint[i] = j; } } } break; } queue = queue->next; } uint32_t *bp_times_ms[MAX_BREAKPOINT_SETS] = {event->eg0_times, event->eg1_times}; float *bp_values[MAX_BREAKPOINT_SETS] = {event->eg0_values, event->eg1_values}; for (int i = 0; i < MAX_BREAKPOINT_SETS; ++i) { if (highest_breakpoint[i] >= 0) { event->bp_is_set[i] = 1; for (int j = 0; j <= highest_breakpoint[i]; ++j) { if (AMY_IS_SET(breakpoint_times[i][j])) { float t_ms = ((float)breakpoint_times[i][j]) * 1000.0f / (float)AMY_SAMPLE_RATE; int32_t t_rounded = (int32_t)roundf(t_ms); if (t_rounded < 0) t_rounded = 0; if (t_rounded >= SHRT_MAX) t_rounded = SHRT_MAX - 1; bp_times_ms[i][j] = (int16_t)t_rounded; } if (AMY_IS_SET(breakpoint_values[i][j])) { bp_values[i][j] = breakpoint_values[i][j]; } } } } return queue; } void parse_patch_string_to_queue(char *message, int base_osc, struct delta **queue, uint32_t time); void *yield_patch_events(uint16_t patch_number, struct amy_event *event, void *state) { // Return a sequence of events defining a patch (specified by number). // state = NULL on first call and it returns state to be passed on next call. Returns NULL when event sequence is finished. amy_clear_event(event); struct delta *queue = (struct delta *)state; if (queue == NULL) { // First call, initialize deltas queue. if (patch_number < _PATCHES_FIRST_USER_PATCH) { // This grabs a new set of deltas from the pool, when are they returned? parse_patch_string_to_queue((char *)patch_commands[patch_number], 0, &queue, 0); } else { int32_t patch_index = patch_number - _PATCHES_FIRST_USER_PATCH; if (patch_index < 0 || patch_index >= (int32_t)max_num_memory_patches) { fprintf(stderr, "patch_number %" PRIu16 " is out of range (%" PRId32 " .. %" PRId32 ")\n", patch_number, (int32_t)_PATCHES_FIRST_USER_PATCH, (int32_t)(_PATCHES_FIRST_USER_PATCH + (int32_t)max_num_memory_patches)); return NULL; } queue = memory_patch_deltas[patch_index]; } } struct delta *queue_on_entry = queue; /* Loop down the queue emitting events as needed. */ queue = deltas_to_event(queue, event); if (patch_number < _PATCHES_FIRST_USER_PATCH) { // We allocated this queue, take care of releasing deltas we're finished with. while (queue_on_entry != queue) { struct delta *doomed = queue_on_entry; queue_on_entry = doomed->next; delta_release(doomed); } } return (void *)queue; } #define EVENT_FROM_OSC(FIELD) \ if (synth[osc]->FIELD != empty_synth.FIELD) \ event->FIELD = synth[osc]->FIELD; #define EVENT_FROM_OSC_BASEOSC(FIELD) \ if (synth[osc]->FIELD != empty_synth.FIELD) \ event->FIELD = synth[osc]->FIELD - base_osc; #define EVENT_FROM_OSC_MAPPED(SYNTH_FIELD, EVENT_FIELD, MAP_FN) \ if (synth[osc]->SYNTH_FIELD != empty_synth.SYNTH_FIELD) \ event->EVENT_FIELD = MAP_FN(synth[osc]->SYNTH_FIELD); #define EVENT_FROM_OSC_ARRAY(FIELD, NUM_ELS) \ for (int i = 0; i < NUM_ELS; ++i) { \ if (synth[osc]->FIELD[i] != empty_synth.FIELD[i]) \ event->FIELD[i] = synth[osc]->FIELD[i]; \ } #define EVENT_FROM_OSC_ARRAY_BASEOSC(FIELD, NUM_ELS) \ for (int i = 0; i < NUM_ELS; ++i) { \ if (synth[osc]->FIELD[i] != empty_synth.FIELD[i]) \ event->FIELD[i] = synth[osc]->FIELD[i] - base_osc; \ } #define EVENT_FROM_OSC_ARRAY2(SYNTH_FIELD, EVENT_FIELD, NUM_ELS) \ for (int i = 0; i < NUM_ELS; ++i) { \ if (synth[osc]->SYNTH_FIELD[i] != empty_synth.SYNTH_FIELD[i]) \ event->EVENT_FIELD[i] = synth[osc]->SYNTH_FIELD[i]; \ } #define EVENT_FROM_OSC_ARRAY_T(SYNTH_FIELD, EVENT_FIELD, NUM_ELS) \ for (int i = 0; i < NUM_ELS; ++i) { \ if (synth[osc]->SYNTH_FIELD[i] != empty_synth.SYNTH_FIELD[i]) \ event->EVENT_FIELD[i] = lroundf(((float)synth[osc]->SYNTH_FIELD[i]) / (AMY_SAMPLE_RATE / 1000.0f)); \ } #define EVENT_FROM_OSC_ARRAY_FREQ(SYNTH_FIELD, EVENT_FIELD, NUM_ELS) \ for (int i = 0; i < NUM_ELS; ++i) { \ if (synth[osc]->SYNTH_FIELD[i] != empty_synth.SYNTH_FIELD[i]) { \ if (i == COEF_CONST) \ event->EVENT_FIELD[i] = freq_of_logfreq(synth[osc]->SYNTH_FIELD[i]); \ else \ event->EVENT_FIELD[i] = synth[osc]->SYNTH_FIELD[i]; \ } \ } void set_event_for_osc(int base_osc, int rel_osc, struct amy_event *event) { // Set fields in the event to configure the osc away from default. // We assume event has already been cleared. // We do not set the osc field of the event. int osc = base_osc + rel_osc; // Generate the reference "empty synth". struct synthinfo empty_synth; // We need to have space for the breakpoints. uint32_t times[MAX_BREAKPOINT_SETS * MAX_BREAKPOINTS]; float values[MAX_BREAKPOINT_SETS * MAX_BREAKPOINTS]; for (int i = 0; i < MAX_BREAKPOINT_SETS; ++i) { empty_synth.max_num_breakpoints[i] = synth[osc]->max_num_breakpoints[i]; empty_synth.breakpoint_times[i] = times + i * MAX_BREAKPOINTS; empty_synth.breakpoint_values[i] = values + i * MAX_BREAKPOINTS; } reset_osc_by_pointer(&empty_synth, /* msynth */ NULL); // Go through parameter fields picking out the ones that are nondefault. EVENT_FROM_OSC(wave); EVENT_FROM_OSC(preset); // Note and velocity are special for "note on" events, don't reflect them in config. //EVENT_FROM_OSC(midi_note); //EVENT_FROM_OSC(velocity); EVENT_FROM_OSC_ARRAY(amp_coefs, NUM_COMBO_COEFS); EVENT_FROM_OSC_ARRAY_FREQ(logfreq_coefs, freq_coefs, NUM_COMBO_COEFS); EVENT_FROM_OSC_ARRAY_FREQ(filter_logfreq_coefs, filter_freq_coefs, NUM_COMBO_COEFS); EVENT_FROM_OSC_ARRAY(duty_coefs, NUM_COMBO_COEFS); EVENT_FROM_OSC_ARRAY(pan_coefs, NUM_COMBO_COEFS); EVENT_FROM_OSC(feedback); EVENT_FROM_OSC(trigger_phase); EVENT_FROM_OSC_MAPPED(logratio, ratio, exp2f); EVENT_FROM_OSC(resonance); EVENT_FROM_OSC_MAPPED(portamento_alpha, portamento_ms, alpha_to_portamento_ms); EVENT_FROM_OSC_BASEOSC(chained_osc); EVENT_FROM_OSC_BASEOSC(mod_source); EVENT_FROM_OSC(algorithm); EVENT_FROM_OSC(filter_type); EVENT_FROM_OSC_ARRAY_BASEOSC(algo_source, MAX_ALGO_OPS); EVENT_FROM_OSC_ARRAY_T(breakpoint_times[0], eg0_times, synth[osc]->max_num_breakpoints[0]); EVENT_FROM_OSC_ARRAY2(breakpoint_values[0], eg0_values, synth[osc]->max_num_breakpoints[0]); EVENT_FROM_OSC_ARRAY_T(breakpoint_times[1], eg1_times, synth[osc]->max_num_breakpoints[1]); EVENT_FROM_OSC_ARRAY2(breakpoint_values[1], eg1_values, synth[osc]->max_num_breakpoints[1]); EVENT_FROM_OSC_ARRAY(eg_type, MAX_BREAKPOINT_SETS); } float lin_to_db(float lin) { return 20.0f * log10f(lin); } void set_event_for_global_fx(amy_event *event, struct state *state) { // Always emit all FX fields so saved patches are fully self-describing. // Volume event->volume = state->volume; // EQ event->eq_l = lin_to_db(S2F(state->eq[0])); event->eq_m = lin_to_db(S2F(state->eq[1])); event->eq_h = lin_to_db(S2F(state->eq[2])); // Reverb event->reverb_level = S2F(state->reverb.level); event->reverb_liveness = state->reverb.liveness; event->reverb_damping = state->reverb.damping; event->reverb_xover_hz = state->reverb.xover_hz; // Chorus event->chorus_level = S2F(state->chorus.level); event->chorus_max_delay = state->chorus.max_delay; event->chorus_lfo_freq = state->chorus.lfo_freq; event->chorus_depth = state->chorus.depth; // Echo event->echo_level = S2F(state->echo.level); event->echo_delay_ms = state->echo.delay_samples * 1000.f / AMY_SAMPLE_RATE; if (state->echo.max_delay_samples != 65536) event->echo_max_delay_ms = state->echo.max_delay_samples * 1000.f / AMY_SAMPLE_RATE; event->echo_feedback = S2F(state->echo.feedback); event->echo_filter_coef = S2F(state->echo.filter_coef); } void *yield_synth_events(uint8_t synth, struct amy_event *event, bool include_fx, void *state) { // Return a sequence of events defining a synth. // state = NULL on first call and it returns state to be passed on next call. Returns NULL when event sequence is finished. // Find oscs for synth. uint16_t voices[MAX_VOICES_PER_INSTRUMENT]; int num_voices = instrument_get_num_voices(synth, voices); if (num_voices < 1) { fprintf(stderr, "yield_synth_events: synth %" PRId32" has no voices.\n", (int32_t)synth); return NULL; // instrument not allocated. } uint32_t flags = instrument_get_flags(synth); uint16_t voice = voices[0]; uint16_t base_osc = voice_to_base_osc[voice]; int num_oscs = 0; while(osc_to_voice[base_osc + num_oscs] == voice) ++num_oscs; // The "state" indicates which osc within the voice we're going to report for. int state_val = (intptr_t)state; //fprintf(stderr, "yield_synth_events(%d) voice=%d num_oscs=%d state_val=%d\n", synth, voice, num_oscs, (int)state_val); amy_clear_event(event); int first_osc_state_val = 0; int last_osc_state_val = num_oscs; if (flags != 0) { ++first_osc_state_val; ++last_osc_state_val; if (state_val == 0) { event->synth_flags = flags; } } if (state_val >= first_osc_state_val && state_val < last_osc_state_val) { event->osc = state_val - first_osc_state_val; //fprintf(stderr, "2 base_osc %d, event->osc %d, state_val %d first_osc_state_val %d last_osc_state_val %d\n", // base_osc, event->osc, state_val, first_osc_state_val, last_osc_state_val); set_event_for_osc(base_osc, event->osc, event); } else if (include_fx && (state_val == last_osc_state_val)) { // optional final event contains the global settings (volume, eq, chorus, echo, reverb). set_event_for_global_fx(event, &amy_global); } ++state_val; if (state_val == last_osc_state_val + (include_fx ? 1 : 0)) state_val = 0; // Indicate this is the final event. return (void *)((intptr_t)state_val); } #define STATE_START_OF_MIDI 1024 void *yield_synth_commands(uint8_t synth, char *s, size_t len, bool include_fx, void *state) { // Generator to return multiple wirecode strings to reconfigure a synth. int state_val = (intptr_t)state; //fprintf(stderr, "yield_synth_commands: synth %d state %d\n", synth, state_val); s[0] = '\0'; // By default, return an empty string. if (state_val < STATE_START_OF_MIDI) { amy_event event = amy_default_event(); state_val = (intptr_t)yield_synth_events(synth, &event, include_fx, (void *)(intptr_t)state_val); sprint_event(&event, s, len, /* wirecode= */ true); if (state_val == 0) { // Push the state machine on to the MIDI codes state_val = STATE_START_OF_MIDI; } } else { // MIDI CC part bool found = false; for (int next_midi_code = state_val - STATE_START_OF_MIDI; next_midi_code < 128; ++next_midi_code) { if (midi_fetch_control_code_command(synth, next_midi_code, s, len) == true) { state_val = STATE_START_OF_MIDI + next_midi_code + 1; found = true; break; } } if (found == false) { // We hit the bottom of the MIDI CCs state_val = 0; // Will terminate the yield cycle. } } return (void *)(intptr_t)state_val; } void parse_patch_string_to_queue(char *message, int base_osc, struct delta **queue, uint32_t time) { // Work though the patch string and send to voices. // Now actually initialize the newly-allocated osc blocks with the patch uint16_t start = 0; //fprintf(stderr, "parse_patch_string: message %s\n", message); while(strlen(message + start)) { amy_event patch_event = amy_default_event(); int num_used = amy_parse_message(message + start, strlen(message + start), &patch_event); //{ // char sub_message[256]; // strncpy(sub_message, message + start, num_used); // sub_message[num_used]= 0; // fprintf(stderr, "parse_patch_string: sub_message %s\n", sub_message); //} start += num_used; amy_process_event(&patch_event); patch_event.time = time; if(patch_event.status == EVENT_SCHEDULED) { amy_event_to_deltas_queue(&patch_event, base_osc, queue); } } } // So emscripten knows how big to make this struct. int size_of_amy_event(void) { return sizeof(amy_event); } void patches_store_patch(amy_event *e, char * patch_string) { peek_stack("store_patch"); // amy patch string. Either pull patch_number from e, or allocate a new one and write it to e. // Patch is stored in ram. //fprintf(stderr, "store_patch: synth %d patch_num %d patch '%s'\n", e->synth, e->patch, patch_string); if (!AMY_IS_SET(e->patch_number)) { // We need to allocate a new number. e->patch_number = next_user_patch_index + _PATCHES_FIRST_USER_PATCH; // next_user_patch_index is updated as needed at the bottom of the function (so it can reflect user-defined numbers too). //fprintf(stderr, "store_patch: auto-assigning patch number %d for '%s'\n", e->patch_number, patch_string); } int patch_index = (int)e->patch_number - _PATCHES_FIRST_USER_PATCH; if (patch_index < 0 || patch_index >= (int)max_num_memory_patches) { fprintf(stderr, "patch number %" PRId32 " is out of range (%" PRId32 " .. %" PRId32 ")\n", (int32_t)(patch_index + _PATCHES_FIRST_USER_PATCH), (int32_t)_PATCHES_FIRST_USER_PATCH, (int32_t)(_PATCHES_FIRST_USER_PATCH + (int32_t)max_num_memory_patches)); return; } if (patch_index >= next_user_patch_index) next_user_patch_index = patch_index + 1; // Store the patch as deltas and find out how many oscs this message uses parse_patch_string_to_queue(patch_string, 0, &memory_patch_deltas[patch_index], e->time); update_num_oscs_for_patch_number(patch_index + _PATCHES_FIRST_USER_PATCH); //fprintf(stderr, "store_patch: patch %d max_osc %d patch %s #deltas %d (e->num_vx=%d)\n", patch_index, max_osc, patch_string, delta_list_len(memory_patch_deltas[patch_index]), e->num_voices); } extern int32_t parse_list_uint16_t(char *message, uint16_t *vals, int32_t max_num_vals, uint16_t skipped_val); // This code was originally in midi.c, but putting it here allows endogenous use of MIDI drums. // Drum kit - copied from tulip/shared/py/patches.py // Drumkit is [base_midi_note, name, general_midi_note] struct pcm_sample_info { int8_t pcm_preset_number; int8_t base_midi_note; }; #define AMY_MIDI_DRUMS_LOWEST_NOTE 35 #define AMY_MIDI_DRUMS_HIGHEST_NOTE 81 // drumkit[midi_note - AMY_MIDI_DRUMS_LOWEST_NOTE] == {pcm_patch_number, base_midi_note} // PCM presets available (from pcm_tiny.h): // [0] 808-MARACA root=89 // [1] 808-KIK 4 root=39 // [2] 808-SNR 4 root=45 // [3] 808-SNR 7 root=52 // [4] 808-SNR 10 root=51 // [5] 808-SNR 12 root=41 // [6] 808-C-HAT1 root=53 // [7] 808-O-HAT1 root=56 // [8] 808-LTOM M root=61 // [9] 808-DRYCLP root=94 // [10] 808-CWBELL root=69 struct pcm_sample_info drumkit[AMY_MIDI_DRUMS_HIGHEST_NOTE - AMY_MIDI_DRUMS_LOWEST_NOTE + 1] = { {1, 39}, // 35 Acoustic Bass Drum -> 808-KIK {1, 39}, // 36 Bass Drum 1 -> 808-KIK {4, 51}, // 37 Side Stick -> 808-SNR 10 (rimshot-like) {2, 45}, // 38 Acoustic Snare -> 808-SNR 4 {9, 94}, // 39 Hand Clap -> 808-DRYCLP {5, 41}, // 40 Electric Snare -> 808-SNR 12 {8, 56}, // 41 Low Floor Tom -> 808-LTOM (pitched down) {6, 53}, // 42 Closed Hi Hat -> 808-C-HAT1 {8, 61}, // 43 High Floor Tom -> 808-LTOM (root) {7, 61}, // 44 Pedal Hi-Hat -> 808-O-HAT1 (short) {8, 56}, // 45 Low Tom -> 808-LTOM (pitched down) {7, 56}, // 46 Open Hi-Hat -> 808-O-HAT1 {8, 63}, // 47 Low-Mid Tom -> 808-LTOM (slightly up) {8, 68}, // 48 Hi Mid Tom -> 808-LTOM (pitched up) {7, 46}, // 49 Crash Cymbal 1 -> 808-O-HAT1 (pitched down for wash) {8, 73}, // 50 High Tom -> 808-LTOM (pitched up high) {7, 51}, // 51 Ride Cymbal 1 -> 808-O-HAT1 (pitched down) {7, 48}, // 52 Chinese Cymbal -> 808-O-HAT1 (pitched down) {6, 47}, // 53 Ride Bell -> 808-C-HAT1 (pitched down, bell-like) {0, 79}, // 54 Tambourine -> 808-MARACA (pitched down) {7, 46}, // 55 Splash Cymbal -> 808-O-HAT1 (pitched down) {10, 69}, // 56 Cowbell -> 808-CWBELL {7, 48}, // 57 Crash Cymbal 2 -> 808-O-HAT1 (pitched down) {-1, -1}, // 58 Vibraslap {7, 53}, // 59 Ride Cymbal 2 -> 808-O-HAT1 (pitched down) {-1, -1}, // 60 Hi Bongo {-1, -1}, // 61 Low Bongo {-1, -1}, // 62 Mute Hi Conga {-1, -1}, // 63 Open Hi Conga {-1, -1}, // 64 Low Conga {8, 73}, // 65 High Timbale -> 808-LTOM (pitched up) {8, 63}, // 66 Low Timbale -> 808-LTOM (slightly up) {10, 76}, // 67 High Agogo -> 808-CWBELL (pitched up) {10, 64}, // 68 Low Agogo -> 808-CWBELL (pitched down) {0, 79}, // 69 Cabasa -> 808-MARACA (pitched down) {0, 89}, // 70 Maracas -> 808-MARACA (root) {-1, -1}, // 71 Short Whistle {-1, -1}, // 72 Long Whistle {-1, -1}, // 73 Short Guiro {-1, -1}, // 74 Long Guiro {-1, -1}, // 75 Claves {10, 76}, // 76 Hi Wood Block -> 808-CWBELL (pitched up) {10, 64}, // 77 Low Wood Block -> 808-CWBELL (pitched down) {-1, -1}, // 78 Mute Cuica {-1, -1}, // 79 Open Cuica {-1, -1}, // 80 Mute Triangle {-1, -1}, // 81 Open Triangle }; bool setup_drum_event(amy_event *e, uint8_t note) { // Special-case processing to convert MIDI drum notes into PCM patch events. bool forward_note = false; if (note >= AMY_MIDI_DRUMS_LOWEST_NOTE && note <= AMY_MIDI_DRUMS_HIGHEST_NOTE) { struct pcm_sample_info s = drumkit[note - AMY_MIDI_DRUMS_LOWEST_NOTE]; if (s.pcm_preset_number != -1) { e->wave = PCM; e->preset = s.pcm_preset_number; e->midi_note = s.base_midi_note; forward_note = true; } } return forward_note; } int copy_voices(uint16_t *from, uint16_t *to) { // Copy voice vectors up until first unset; return how many copied. int num_voices = 0; for (int i = 0; i < MAX_VOICES_PER_INSTRUMENT; ++i) { if (AMY_IS_SET(from[i])) { to[num_voices] = from[i]; ++num_voices; } else { break; } } return num_voices; } uint8_t patches_voices_for_note_onoff_event(amy_event *e, uint16_t voices[], uint32_t synth_flags, bool *pstolen) { // Identify the specific voice (or voices) for a note on/off event. // e->velocity is assumed to be set when this function is called. int num_voices = 0; if (AMY_IS_UNSET(e->midi_note) && AMY_IS_UNSET(e->preset) && instrument_get_num_voices(e->synth, NULL) != 1) { // velocity without midi_note is valid for velocity==0 => all-notes-off. if (e->velocity != 0) { // Attempted a note-on to all voices, suppress. fprintf(stderr, "note-on with no note for synth %" PRId32 " - ignored.\n", (int32_t)e->synth); return 0; } // All notes off - find out which voices are actually currently active, so we can turn them off. num_voices = instrument_all_notes_off(e->synth, voices); } else { // It's a note-on or note-off event, so the instrument mechanism chooses which single voice to use. uint16_t note = 0; if (AMY_IS_SET(e->midi_note)) // midi note can be unset if preset is set. note = (uint8_t)roundf(e->midi_note); if (synth_flags & _SYNTH_FLAGS_MIDI_DRUMS) { if (!setup_drum_event(e, note)) return 0; // It's not a MIDI drum event we can emulate, just drop the event. } if (AMY_IS_SET(e->preset)) { // This event includes a note *and* a preset, so it's like a drum sample note on. // Wrap the preset number into the note, so we don't allocate the same pitch for different drums to the same voice. note += 128 * e->preset; } bool is_note_off = (e->velocity == 0); voices[0] = instrument_voice_for_note_event(e->synth, note, is_note_off, pstolen); if (voices[0] == _INSTRUMENT_NO_VOICE) { // For now, I think this can only happen with a note-off that has no matching note-on. //fprintf(stderr, "synth %d did not find a voice, dropping message.\n", e->synth); // No, it also happens with note-offs when pedal is down. return 0; } num_voices = 1; } //fprintf(stderr, "instrument %d vel %d note %d voice %d\n", e->synth, (int)roundf(127.f * e->velocity), (int)roundf(e->midi_note), voices[0]); return num_voices; } uint8_t patches_voices_for_event(amy_event *e, uint16_t voices[]) { // Convert an event that may specify a synth into a number of specific voices. uint8_t num_voices = 0; uint32_t synth_flags = 0; if (!AMY_IS_SET(e->synth)) { // No instrument, just directly naming the voices. num_voices = copy_voices(e->voices, voices); } else { // We have an instrument specified - decide which of its voices are actually to be used. // It's a mistake to specify both synth (instrument) and voices, warn user we're ignoring voices. // (except in the afterlife of a load_patch event, which will most likely be empty anyway). if (AMY_IS_SET(e->voices[0]) && !AMY_IS_SET(e->patch_number)) { fprintf(stderr, "You specified both synth %" PRId32 " and voices %" PRIu16 "... Synth implies voices, ignoring voices.\n", (int32_t)e->synth, e->voices[0]); } synth_flags = instrument_get_flags(e->synth); if (AMY_IS_SET(e->to_synth)) { // This involves moving the instrument number. instrument_change_number(e->synth, e->to_synth); e->synth = e->to_synth; AMY_UNSET(e->to_synth); // Then continue handling any other args. } if (AMY_IS_SET(e->synth_delay_ms)) { // Set the synth noteon delay. instrument_set_noteon_delay_ms(e->synth, e->synth_delay_ms); } if (AMY_IS_SET(e->grab_midi_notes)) { // Set the grab_midi state. instrument_set_grab_midi_notes(e->synth, e->grab_midi_notes); } if (AMY_IS_SET(e->pedal)) { // Pedal events are a special case bool sustain = (e->pedal != 0); if (synth_flags & _SYNTH_FLAGS_NEGATE_PEDAL) { sustain = !sustain; // Some MIDI pedals report backwards. } // A sustain release can result in note-off events for multiple voices. num_voices = instrument_sustain(e->synth, sustain, voices); if (num_voices) { e->velocity = 0; } //fprintf(stderr, "synth %d pedal %d num_voices %d\n", e->synth, e->pedal, num_voices); } else if (AMY_IS_SET(e->velocity)) { bool stolen = false; num_voices = patches_voices_for_note_onoff_event(e, voices, synth_flags, &stolen); if (stolen) { // Here, we issue a quick note-off for the stolen note, to support short decay. Kind of an abstraction violation. struct delta d = { .time = e->time, .osc = voice_to_base_osc[voices[0]], .param = VELOCITY, .data.i = 0, .next = NULL, }; add_delta_to_queue(&d, &amy_global.delta_queue); //fprintf(stderr, "synth %d note %d: voice %d stolen, osc %d time %d added note-off\n", e->synth, (int)roundf(e->midi_note), voices[0], d.osc, d.time); } // Apply noteon_delay_ms to note-on events. if (instrument_noteon_delay_ms(e->synth)) { uint32_t playback_time = amy_sysclock(); if(AMY_IS_SET(e->time)) playback_time = e->time; playback_time += instrument_noteon_delay_ms(e->synth); e->time = playback_time; //fprintf(stderr, "synth %d note %d delay %d time %d\n", e->synth, (int)roundf(e->midi_note), instrument_noteon_delay_ms(e->synth), e->time); } } else { // Not note on/off, treat the synth as a shorthand for *all* the voices. num_voices = instrument_get_num_voices(e->synth, voices); } if (AMY_IS_SET(e->velocity) && e->velocity == 0 && (synth_flags & _SYNTH_FLAGS_IGNORE_NOTE_OFFS)) return 0; // Ignore the note off, as requested. } return num_voices; } // This is called when i get an event with voices (or an instrument) in it. // If the event also has synth and patch_number specified (a "load patch"), those are handled before this is called. // So i know that the patch / voice alloc already exists and the patch has already been set! void patches_event_has_voices(amy_event *e, struct delta **queue) { peek_stack("has_voices"); uint16_t voices[MAX_VOICES_PER_INSTRUMENT]; uint8_t num_voices = patches_voices_for_event(e, voices); if (num_voices == 0) { // No voices to process, somehow event is to be ignored. return; } // Clear out the instrument, voices, patch from the event. If we didn't, we'd keep calling this over and over AMY_UNSET(e->voices[0]); AMY_UNSET(e->patch_number); int32_t instrument = e->synth; AMY_UNSET(e->synth); // for each voice, send the event to the base osc (+ e->osc if given) for(uint8_t i=0;iwave, (int)e->midi_note, (int)(127.f * e->velocity)); } } // Restore the instrument in case this event is re-used. e->synth = instrument; } void release_voice_oscs(int32_t voice) { if(AMY_IS_SET(voice_to_base_osc[voice])) { //fprintf(stderr, "Already set voice %d, removing it\n", voice); // Remove the oscs for this old voice for(uint16_t i=0;isynth is assumed to be set. int num_voices = 0; // If the instrument is alread initialized, copy the voice numbers. num_voices = instrument_get_num_voices(e->synth, voices); if (AMY_IS_SET(e->num_voices) && e->num_voices != num_voices) { // If we did already have voice oscs, release them. for (int32_t i = 0; i < num_voices; ++i) { release_voice_oscs(voices[i]); } num_voices = 0; // Find avaliable voices with a single pass through voice_to_base_osc. uint32_t v = 0; for (int32_t i = 0; i < e->num_voices; ++i) { while (v < amy_global.config.max_voices) { if (AMY_IS_UNSET(voice_to_base_osc[v])) break; ++v; } if (v == amy_global.config.max_voices) { fprintf(stderr, "ran out of voices allocating %" PRId32 " voices to synth %" PRId32 ", ignoring.", (int32_t)e->num_voices, (int32_t)e->synth); patches_debug(); return 0; } voices[i] = v; ++v; ++num_voices; } // Was this deleting the instrument? i.e. was e->num_voices set but setting the num_voices to zero? if (num_voices == 0) { instrument_release(e->synth); // Delete the instrument number so we don't forward the 'rest' of the event to it. AMY_UNSET(e->synth); // Clear all the midi control code mappings. midi_clear_channel_mappings(e->synth); return 0; } //fprintf(stderr, "Allocated %d voices to instrument %d\n", num_voices, e->synth); } //for (int i = 0; i < num_voices; ++i) { // fprintf(stderr, "%d; ", voices[i]); //} //fprintf(stderr, "\n"); return num_voices; } void patches_load_patch(amy_event *e) { // Given an event with a synth (instrument) or voice spec, set up a synth. // Common case is to call with a patch to load, but can also have just // a oscs_per_voice value. // (also called if instrument & num_voices even if no patch specified, to change #voices). // This means to set/reset the voices and load the messages (from ROM or memory) and set them. peek_stack("load_patch"); uint16_t voices[MAX_VOICES_PER_INSTRUMENT]; uint8_t num_voices = 0; uint16_t oscs_per_voice = 0; uint16_t patch_number = e->patch_number; // Need to match type of e->patch_number so AMY_IS_UNSET(patch_number) will work. //fprintf(stderr, "load_patch synth %d patch_number %d num_voices %d oscs_per_voice %d\n", e->synth, e->patch_number, e->num_voices, e->oscs_per_voice); if (AMY_IS_SET(e->synth)) { num_voices = patches_voices_for_load_synth(e, voices); } else if (AMY_IS_SET(e->voices[0])) { num_voices = copy_voices(e->voices, voices); } if (num_voices == 0) { if (AMY_IS_UNSET(e->num_voices)) { // Print a warning unless we deliberately set the voices to zero to release the synth. fprintf(stderr, "synth %" PRId32 ": no voices selected, ignored (e->num_voices %" PRId32 " e->voices [0] %" PRIu16 "...)\n", (int32_t)e->synth, (int32_t)e->num_voices, e->voices[0]); } return; } else { // Reset every osc belonging to each voice so stale state doesn't persist // before we reallocate and reinitialize them below. for (uint8_t v = 0; v < num_voices; v++) { if (AMY_IS_SET(voice_to_base_osc[voices[v]])) { uint16_t base = voice_to_base_osc[voices[v]]; for (uint16_t j = 0; j < AMY_OSCS - base; j++) { if (osc_to_voice[base + j] != voices[v]) break; reset_osc(base + j); } } } } // At this point, we have the voices[] array and num_voices set up to be initialized. char *message = NULL; struct delta *deltas = NULL; // Figure out the #oscs per voice, setup message or deltas if available. if (AMY_IS_SET(e->oscs_per_voice)) { oscs_per_voice = e->oscs_per_voice; if (AMY_IS_SET(patch_number)) { fprintf(stderr, "WARN: synth %" PRId32 ": oscs_per_voice %" PRIu16 " made me ignore patch number %" PRIu16 "\n", (int32_t)e->synth, e->oscs_per_voice, patch_number); } } else { if (AMY_IS_UNSET(patch_number)) patch_number = instrument_get_patch_number(e->synth); if(patch_number < _PATCHES_FIRST_USER_PATCH) { // Built-in patch message = (char*)patch_commands[patch_number]; oscs_per_voice = patch_oscs[patch_number]; } else { // User-defined patch int32_t patch_index = patch_number - _PATCHES_FIRST_USER_PATCH; oscs_per_voice = memory_patch_oscs[patch_index]; if(oscs_per_voice > 0){ deltas = memory_patch_deltas[patch_index]; } else { fprintf(stderr, "patch_number %" PRIu16 " has %" PRIu16 " num_deltas %" PRIi32 " (synth %" PRId32 " num_voices %" PRId32 "), ignored\n", patch_number, oscs_per_voice, delta_list_len(memory_patch_deltas[patch_index]), (int32_t)e->synth, (int32_t)e->num_voices); return; } } } for(uint8_t v=0;vtime); } else if (message) { parse_patch_string_to_queue(message, voice_to_base_osc[voices[v]], &amy_global.delta_queue, e->time); } // Or maybe there's no deltas and no message, in which case we just set oscs_per_voice, waiting for config. } } // Finally, store as an instrument if instrument number is specified. if (AMY_IS_SET(e->synth)) { uint32_t flags = 0; if (AMY_IS_SET(e->synth_flags)) flags = e->synth_flags; instrument_add_new(e->synth, num_voices, voices, patch_number, oscs_per_voice, flags); } } ================================================ FILE: src/patches.h ================================================ // Automatically generated. // DX7 and juno 106 and custom patch table #ifndef __PATCHESH #define __PATCHESH static const char * const patch_commands[258] PROGMEM = { /* 0: Juno A11 Brass Set 1 */ "v1w4a1,,0,1Zv0w20c2L1G4Zv2w1c3L1Zv3w3c4L1Zv4w1c5L1Zv5w5L1Zv1f0.945A156,1.0,10000,0Zv2a0,,0,0f220,1,,,,0,1d0.902,,,,,0m0Zv3a1,,0,0f220,1,,,,0,1m0Zv4a0,,0,0f110,1,,,,0,1m0Zv5a0,,0,0Zv0F179.93,0.677,,5.024,0,0R0.93Zv0a0.85,,1,1,0A30,1,1355,0.354,232,0Zx0,0,0k1,,0.5,0.5Z", /* 1: Juno A12 Brass Swell */ "v1w4a1,,0,1Zv0w20c2L1G4Zv2w1c3L1Zv3w3c4L1Zv4w1c5L1Zv5w5L1Zv1f0.609A148,1.0,10000,0Zv2a0,,0,0f440,1,,,,0,1d0.72,,,,,0m0Zv3a1,,0,0f440,1,,,,0,1m0Zv4a0.551,,0,0f220,1,,,,0,1m0Zv5a0,,0,0Zv0F300.23,0.661,,2.252,0,0R1.015Zv0a0.591,,1,1,0A518,1,83561,0.299,310,0Zx7,-3,-3k1,,0.5,0.5Z", /* 2: Juno A13 Trumpet */ "v1w4a1,,0,1Zv0w20c2L1G4Zv2w1c3L1Zv3w3c4L1Zv4w1c5L1Zv5w5L1Zv1f2.437A128,1.0,10000,0Zv2a0,,0,0f440,1,,,,0.002,1d0.902,,,,,0m0Zv3a1,,0,0f440,1,,,,0.002,1m0Zv4a0,,0,0f220,1,,,,0.002,1m0Zv5a0,,0,0Zv0F591.35,0.465,,2.079,0,0.01R1.47Zv0a1,,1,1,0A46,1,3827,0.378,75,0Zx-8,0,0k0Z", /* 3: Juno A14 Flutes */ "v1w4a1,,0,1Zv0w20c2L1G4Zv2w1c3L1Zv3w3c4L1Zv4w1c5L1Zv5w5L1Zv1f3.067A115,1.0,10000,0Zv2a0,,0,0f440,1,,,,0,1d0.5,,,,,0m0Zv3a1,,0,0f440,1,,,,0,1m0Zv4a0,,0,0f220,1,,,,0,1m0Zv5a0,,0,0Zv0F549.34,0.323,,0.866,0,0.108R1.408Zv0a1,,1,1,0A190,1,9375,0,89,0Zx-15,8,8k0Z", /* 4: Juno A15 Moving Strings */ "v1w4a1,,0,1Zv0w20c2L1G4Zv2w1c3L1Zv3w3c4L1Zv4w1c5L1Zv5w5L1Zv1f3.341A5,1.0,10000,0Zv2a1,,0,0f440,1,,,,0,1d0.5,,,,,0.154m0Zv3a1,,0,0f440,1,,,,0,1m0Zv4a0.11,,0,0f220,1,,,,0,1m0Zv5a0,,0,0Zv0F3058.4,0.874,,0.346,0,0R1.083Zv0a0.268,,1,1,0A110,1,13385,0.693,277,0Zx0,0,0k1,,0.83,0.5Z", /* 5: Juno A16 Brass & Strings */ "v1w4a1,,0,1Zv0w20c2L1G4Zv2w1c3L1Zv3w3c4L1Zv4w1c5L1Zv5w5L1Zv1f1.483A5,1.0,10000,0Zv2a1,,0,0f220,1,,,,0,1d0.5,,,,,0.22m0Zv3a0,,0,0f220,1,,,,0,1m0Zv4a0.181,,0,0f110,1,,,,0,1m0Zv5a0,,0,0Zv0F2151.9,0.323,,0.346,0,0R1.015Zv0a0.614,,1,1,0A358,1,3827,0.417,453,0Zx7,-3,-3k1,,0.5,0.5Z", /* 6: Juno A17 Choir */ "v1w4a1,,0,1Zv0w20c2L1G4Zv2w1c3L1Zv3w3c4L1Zv4w1c5L1Zv5w5L1Zv1f2.98A21,1.0,10000,0Zv2a1,,0,0f440,1,,,,0.003,1d0.598,,,,,0m0Zv3a0,,0,0f440,1,,,,0.003,1m0Zv4a0,,0,0f220,1,,,,0.003,1m0Zv5a0,,0,0Zv0F776.47,0.488,,0.173,0,0R5.449Zv0a1,,1,1,0A550,1,72,1,559,0Zx-8,0,0k1,,0.5,0.5Z", /* 7: Juno A18 Piano I */ "v1w4a1,,0,1Zv0w20c2L1G4Zv2w1c3L1Zv3w3c4L1Zv4w1c5L1Zv5w5L1Zv1f0.945A156,1.0,10000,0Zv2a1,,0,0f440,1,,,,0,1d0.815,,,,,0m0Zv3a0,,0,0f440,1,,,,0,1m0Zv4a0.677,,0,0f220,1,,,,0,1m0Zv5a0,,0,0Zv0F993.85,0.213,,0.866,0,0R0.91Zv0a0.811,,1,1,0A6,1,3827,0,206,0Zx0,0,0k0Z", /* 8: Juno A21 Organ I */ "v1w4a1,,0,1Zv0w20c2L1G4Zv2w1c3L1Zv3w3c4L1Zv4w1c5L1Zv5w5L1Zv1f2.581A22,1.0,10000,0Zv2a1,,0,0f220,1,,,,0,1d0.5,,,,,0.209m0Zv3a0,,0,0f220,1,,,,0,1m0Zv4a0.181,,0,0f110,1,,,,0,1m0Zv5a0,,0,0Zv0F358.01,1,,0,1.213,0.01R3.679Zv0a0.787,,1,1,0A0,1,0,1,0,0B6,1,64,0.646,0,0Zx7,-3,-3k0Z", /* 9: Juno A22 Organ II */ "v1w4a1,,0,1Zv0w20c2L1G4Zv2w1c3L1Zv3w3c4L1Zv4w1c5L1Zv5w5L1Zv1f1.932A22,1.0,10000,0Zv2a1,,0,0f440,1,,,,0,1d0.5,,,,,0.209m0Zv3a0,,0,0f440,1,,,,0,1m0Zv4a0.457,,0,0f220,1,,,,0,1m0Zv5a0,,0,0Zv0F577.55,0.669,,0,1.213,0.01R3.679Zv0a0.583,,1,1,0A0,1,0,1,0,0B6,1,64,0.646,0,0Zx7,-3,-3k1,,0.5,0.5Z", /* 10: Juno A23 Combo Organ */ "v1w4a1,,0,1Zv0w20c2L1G4Zv2w1c3L1Zv3w3c4L1Zv4w1c5L1Zv5w5L1Zv1f4.7A34,1.0,10000,0Zv2a1,,0,0f880,1,,,,0.002,1d0.724,,,,,0m0Zv3a0,,0,0f880,1,,,,0.002,1m0Zv4a0.48,,0,0f440,1,,,,0.002,1m0Zv5a0,,0,0Zv0F1220.7,0.858,,0,0.346,0R3.227Zv0a0.756,,1,1,0A0,1,0,1,0,0B6,1,1272,0.339,504,0Zx-8,0,0k0Z", /* 11: Juno A24 Calliope */ "v1w4a1,,0,1Zv0w20c2L1G4Zv2w1c3L1Zv3w3c4L1Zv4w1c5L1Zv5w5L1Zv1f5.728A99,1.0,10000,0Zv2a1,,0,0f440,1,,,,0.003,1d0.5,,,,,0m0Zv3a0,,0,0f440,1,,,,0.003,1m0Zv4a0.378,,0,0f220,1,,,,0.003,1m0Zv5a0,,0,0Zv0F4678.2,0.441,,-1.472,0,0R1.262Zv0a0.701,,1,1,0A62,1,142057,1,22,0Zx-8,0,0k1,,0.5,0.5Z", /* 12: Juno A25 Donald Pluck */ "v1w4a1,,0,1Zv0w20c2L1G4Zv2w1c3L1Zv3w3c4L1Zv4w1c5L1Zv5w5L1Zv1f4.835A34,1.0,10000,0Zv2a1,,0,0f880,1,,,,0.002,1d0.724,,,,,0m0Zv3a0,,0,0f880,1,,,,0.002,1m0Zv4a1,,0,0f440,1,,,,0.002,1m0Zv5a0,,0,0Zv0F2060.1,0.614,,0,-1.299,0R6.928Zv0a0.646,,1,1,0A0,1,0,1,0,0B22,1,27,0.339,40,0Zx-15,8,8k0Z", /* 13: Juno A26 Celeste* (1 oct.up) */ "v1w4a1,,0,1Zv0w20c2L1G4Zv2w1c3L1Zv3w3c4L1Zv4w1c5L1Zv5w5L1Zv1f1.204A5,1.0,10000,0Zv2a1,,0,0f880,1,,,,0,1d0.5,,,,,0m0Zv3a0,,0,0f880,1,,,,0,1m0Zv4a0.118,,0,0f440,1,,,,0,1m0Zv5a0,,0,0Zv0F129.81,0.299,,4.677,0,0R1.182Zv0a0.756,,1,1,0A6,1,988,0,2777,0Zx7,-3,-3k0Z", /* 14: Juno A27 Elect. Piano I */ "v1w4a1,,0,1Zv0w20c2L1G4Zv2w1c3L1Zv3w3c4L1Zv4w1c5L1Zv5w5L1Zv1f2.98A5,1.0,10000,0Zv2a1,,0,0f220,1,,,,0,1d0.5,,,,,0m0Zv3a0,,0,0f220,1,,,,0,1m0Zv4a0,,0,0f110,1,,,,0,1m0Zv5a0,,0,0Zv0F42.457,0.276,,5.283,0,0.059R1.377Zv0a1,,1,1,0A14,1,11888,0.339,366,0Zx-15,8,8k0Z", /* 15: Juno A28 Elect. Piano II */ "v1w4a1,,0,1Zv0w20c2L1G4Zv2w1c3L1Zv3w3c4L1Zv4w1c5L1Zv5w5L1Zv1f0.5A5,1.0,10000,0Zv2a1,,0,0f220,1,,,,0,1d0.78,,,,,0m0Zv3a0,,0,0f220,1,,,,0,1m0Zv4a0,,0,0f110,1,,,,0,1m0Zv5a0,,0,0Zv0F465.58,0.63,,0.606,0,0R3.157Zv0a0.803,,1,1,0A6,1,4315,0,121,0Zx0,0,0k1,,0.5,0.5Z", /* 16: Juno A31 Clock Chimes* (1 oct. up) */ "v1w4a1,,0,1Zv0w20c2L1G4Zv2w1c3L1Zv3w3c4L1Zv4w1c5L1Zv5w5L1Zv1f2.98A5,1.0,10000,0Zv2a0,,0,0f880,1,,,,0,1d0.5,,,,,0m0Zv3a0,,0,0f880,1,,,,0,1m0Zv4a1,,0,0f440,1,,,,0,1m0Zv5a0.173,,0,0Zv0F382.06,1,,-0,0,0R11.2Zv0a0.819,,1,1,0A6,1,1272,0,651,0Zx7,-3,-3k1,,0.5,0.5Z", /* 17: Juno A32 Steel Drums */ "v1w4a1,,0,1Zv0w20c2L1G4Zv2w1c3L1Zv3w3c4L1Zv4w1c5L1Zv5w5L1Zv1f1.398A190,1.0,10000,0Zv2a1,,0,0f440,1,,,,0,1d0.626,,,,,0m0Zv3a0,,0,0f440,1,,,,0,1m0Zv4a0.26,,0,0f220,1,,,,0,1m0Zv5a0.071,,0,0Zv0F2210.6,1,,-2.252,0,0R1.911Zv0a1,,1,1,0A6,1,290,0,310,0Zx7,-3,-3k1,,0.5,0.5Z", /* 18: Juno A33 Xylophone */ "v1w4a1,,0,1Zv0w20c2L1G4Zv2w1c3L1Zv3w3c4L1Zv4w1c5L1Zv5w5L1Zv1f0.5A5,1.0,10000,0Zv2a1,,0,0f880,1,,,,0,1d0.5,,,,,0m0Zv3a0,,0,0f880,1,,,,0,1m0Zv4a0.118,,0,0f440,1,,,,0,1m0Zv5a0,,0,0Zv0F105.55,0.402,,4.677,0,0R1.182Zv0a1,,1,1,0A6,1,361,0.228,328,0Zx7,-3,-3k0Z", /* 19: Juno A34 Brass III */ "v1w4a1,,0,1Zv0w20c2L1G4Zv2w1c3L1Zv3w3c4L1Zv4w1c5L1Zv5w5L1Zv1f2.437A31,1.0,10000,0Zv2a0,,0,0f440,1,,,,0,1d0.638,,,,,0m0Zv3a1,,0,0f440,1,,,,0,1m0Zv4a0.173,,0,0f220,1,,,,0,1m0Zv5a0,,0,0Zv0F997.45,0.094,,0.953,0,0R1.182Zv0a1,,1,1,0A470,1,28883,0.74,310,0Zx7,-3,-3k1,,0.5,0.5Z", /* 20: Juno A35 Fanfare */ "v1w4a1,,0,1Zv0w20c2L1G4Zv2w1c3L1Zv3w3c4L1Zv4w1c5L1Zv5w5L1Zv1f2.108A5,1.0,10000,0Zv2a1,,0,0f220,1,,,,0,1d0.5,,,,,0.276m0Zv3a1,,0,0f220,1,,,,0,1m0Zv4a0.394,,0,0f110,1,,,,0,1m0Zv5a0,,0,0Zv0F298.86,0.528,,2.772,0,0R0.7Zv0a0.26,,1,1,0A582,1,36580,0.591,588,0Zx7,-3,-3k1,,0.5,0.5Z", /* 21: Juno A36 String III */ "v1w4a1,,0,1Zv0w20c2L1G4Zv2w1c3L1Zv3w3c4L1Zv4w1c5L1Zv5w5L1Zv1f2.171A48,1.0,10000,0Zv2a1,,0,0f440,1,,,,0,1d0.5,,,,,0.402m0Zv3a1,,0,0f440,1,,,,0,1m0Zv4a0,,0,0f220,1,,,,0,1m0Zv5a0,,0,0Zv0F1853.8,0.661,,0,0,0R0.95Zv0a0.575,,1,1,0A510,1,416,1,478,0Zx0,0,0k1,,0.83,0.5Z", /* 22: Juno A37 Pizzicato */ "v1w4a1,,0,1Zv0w20c2L1G4Zv2w1c3L1Zv3w3c4L1Zv4w1c5L1Zv5w5L1Zv1f3.067A28,1.0,10000,0Zv2a1,,0,0f440,1,,,,0,1d0.5,,,,,0.402m0Zv3a1,,0,0f440,1,,,,0,1m0Zv4a0,,0,0f220,1,,,,0,1m0Zv5a0,,0,0Zv0F1127.8,0.331,,0.433,0,0R0.731Zv0a1,,1,1,0A6,1,72,0,51,0Zx-15,8,8k1,,0.5,0.5Z", /* 23: Juno A38 High Strings */ "v1w4a1,,0,1Zv0w20c2L1G4Zv2w1c3L1Zv3w3c4L1Zv4w1c5L1Zv5w5L1Zv1f2.896A21,1.0,10000,0Zv2a1,,0,0f880,1,,,,0,1d0.5,,,,,0.402m0Zv3a0,,0,0f880,1,,,,0,1m0Zv4a0,,0,0f440,1,,,,0,1m0Zv5a0,,0,0Zv0F4093,0.559,,0.173,0,0R0.834Zv0a0.606,,1,1,0A150,1,988,1,366,0Zx-8,0,0k1,,0.83,0.5Z", /* 24: Juno A41 Bass clarinet */ "v1w4a1,,0,1Zv0w20c2L1G4Zv2w1c3L1Zv3w3c4L1Zv4w1c5L1Zv5w5L1Zv1f2.437A128,1.0,10000,0Zv2a1,,0,0f220,1,,,,0.002,1d0.5,,,,,0m0Zv3a0,,0,0f220,1,,,,0.002,1m0Zv4a0,,0,0f110,1,,,,0.002,1m0Zv5a0,,0,0Zv0F373.6,0.457,,2.165,0,0.079R1.536Zv0a0.819,,1,1,0A94,1,6559,0,149,0Zx0,0,0k0Z", /* 25: Juno A42 English Horn */ "v1w4a1,,0,1Zv0w20c2L1G4Zv2w1c3L1Zv3w3c4L1Zv4w1c5L1Zv5w5L1Zv1f2.108A128,1.0,10000,0Zv2a1,,0,0f440,1,,,,0.002,1d0.902,,,,,0m0Zv3a0,,0,0f440,1,,,,0.002,1m0Zv4a0,,0,0f220,1,,,,0.002,1m0Zv5a0,,0,0Zv0F1375.6,0.213,,0.606,0,0R1.996Zv0a1,,1,1,0A70,1,9375,0.205,75,0Zx-15,8,8k0Z", /* 26: Juno A43 Brass Ensemble */ "v1w4a1,,0,1Zv0w20c2L1G4Zv2w1c3L1Zv3w3c4L1Zv4w1c5L1Zv5w5L1Zv1f2.437A128,1.0,10000,0Zv2a0,,0,0f440,1,,,,0,1d0.902,,,,,0m0Zv3a1,,0,0f440,1,,,,0,1m0Zv4a0.244,,0,0f220,1,,,,0,1m0Zv5a0,,0,0Zv0F329.39,0.465,,2.512,0,0.01R1.829Zv0a0.811,,1,1,0A134,1,34482,0.764,261,0Zx0,0,0k1,,0.5,0.5Z", /* 27: Juno A44 Guitar */ "v1w4a1,,0,1Zv0w20c2L1G4Zv2w1c3L1Zv3w3c4L1Zv4w1c5L1Zv5w5L1Zv1f6.412A242,1.0,10000,0Zv2a1,,0,0f220,1,,,,0,1d0.756,,,,,0m0Zv3a1,,0,0f220,1,,,,0,1m0Zv4a0,,0,0f110,1,,,,0,1m0Zv5a0,,0,0Zv0F32.071,0.236,,6.15,0,0R0.971Zv0a0.756,,1,1,0A6,1,1632,0.425,219,0Zx0,0,0k0Z", /* 28: Juno A45 Koto */ "v1w4a1,,0,1Zv0w20c2L1G4Zv2w1c3L1Zv3w3c4L1Zv4w1c5L1Zv5w5L1Zv1f7.175A51,1.0,10000,0Zv2a1,,0,0f440,1,,,,0,1d0.87,,,,,0m0Zv3a0,,0,0f440,1,,,,0,1m0Zv4a0.016,,0,0f220,1,,,,0,1m0Zv5a0,,0,0Zv0F238.09,0.591,,2.512,0,0R2.483Zv0a1,,1,1,0A6,1,2087,0,346,0Zx-15,8,8k1,,0.5,0.5Z", /* 29: Juno A46 Dark Pluck */ "v1w4a1,,0,1Zv0w20c2L1G4Zv2w1c3L1Zv3w3c4L1Zv4w1c5L1Zv5w5L1Zv1f1.317A5,1.0,10000,0Zv2a1,,0,0f440,1,,,,0,1d0.843,,,,,0m0Zv3a0,,0,0f440,1,,,,0,1m0Zv4a0.764,,0,0f220,1,,,,0,1m0Zv5a0,,0,0Zv0F205.66,0.559,,2.339,0,0R2.651Zv0a0.709,,1,1,0A6,1,1632,0.118,1179,0Zx7,-3,-3k1,,0.83,0.5Z", /* 30: Juno A47 Funky I */ "v1w4a1,,0,1Zv0w20c2L1G4Zv2w1c3L1Zv3w3c4L1Zv4w1c5L1Zv5w5L1Zv1f0.57A5,1.0,10000,0Zv2a1,,0,0f220,1,,,,0,1d0.787,,,,,0m0Zv3a1,,0,0f220,1,,,,0,1m0Zv4a0.504,,0,0f110,1,,,,0,1m0Zv5a0,,0,0Zv0F115.39,0.323,,0,4.417,0R1.157Zv0a0.559,,1,1,0A0,1,0,1,0,0B6,1,388,0.283,6,0Zx7,-3,-3k1,,0.5,0.5Z", /* 31: Juno A48 Synth Bass I (unison) */ "v1w4a1,,0,1Zv0w20c2L1G4Zv2w1c3L1Zv3w3c4L1Zv4w1c5L1Zv5w5L1Zv1f2.896A24,1.0,10000,0Zv2a1,,0,0f220,1,,,,0,1d0.724,,,,,0m0Zv3a0,,0,0f220,1,,,,0,1m0Zv4a0.803,,0,0f110,1,,,,0,1m0Zv5a0.394,,0,0Zv0F120.15,0.276,,5.717,0,0R0.7Zv0a0.591,,1,1,0A6,1,513,0,293,0Zx7,-3,-3k0Z", /* 32: Juno A51 Lead I */ "v1w4a1,,0,1Zv0w20c2L1G4Zv2w1c3L1Zv3w3c4L1Zv4w1c5L1Zv5w5L1Zv1f4.317A995,1.0,10000,0Zv2a1,,0,0f440,1,,,,0.004,1d0.5,,,,,0m0Zv3a0,,0,0f440,1,,,,0.004,1m0Zv4a0,,0,0f220,1,,,,0.004,1m0Zv5a0,,0,0Zv0F216.7,0.409,,0,3.118,0R5.818Zv0a0.78,,1,1,0A0,1,0,1,0,0B6,1,1053,0.575,0,0Zx7,-3,-3k0Z", /* 33: Juno A52 Lead II */ "v1w4a1,,0,1Zv0w20c2L1G4Zv2w1c3L1Zv3w3c4L1Zv4w1c5L1Zv5w5L1Zv1f1.067A995,1.0,10000,0Zv2a1,,0,0f220,1,,,,0,1d0.5,,,,,0.209m0Zv3a1,,0,0f220,1,,,,0,1m0Zv4a0.622,,0,0f110,1,,,,0,1m0Zv5a0,,0,0Zv0F299.94,0.409,,0,3.724,0R0.7Zv0a0.441,,1,1,0A0,1,0,1,0,0B14,1,230,0.717,2093,0Zx0,0,0k0Z", /* 34: Juno A53 Lead III */ "v1w4a1,,0,1Zv0w20c2L1G4Zv2w1c3L1Zv3w3c4L1Zv4w1c5L1Zv5w5L1Zv1f6.412A450,1.0,10000,0Zv2a0,,0,0f440,1,,,,0.005,1d0.902,,,,,0m0Zv3a1,,0,0f440,1,,,,0.005,1m0Zv4a0,,0,0f220,1,,,,0.005,1m0Zv5a0,,0,0Zv0F877.5,0.598,,0,1.559,0.01R1.377Zv0a1,,1,1,0A0,1,0,1,0,0B6,1,3827,0.378,45,0Zx0,0,0k0Z", /* 35: Juno A54 Funky II */ "v1w4a1,,0,1Zv0w20c2L1G4Zv2w1c3L1Zv3w3c4L1Zv4w1c5L1Zv5w5L1Zv1f0.57A5,1.0,10000,0Zv2a1,,0,0f440,1,,,,0,1d0.689,,,,,0m0Zv3a0,,0,0f440,1,,,,0,1m0Zv4a0.449,,0,0f220,1,,,,0,1m0Zv5a0,,0,0Zv0F21.282,0.323,,0,7.016,0R1.157Zv0a0.787,,1,1,0A0,1,0,1,0,0B6,1,388,0.307,6,0Zx0,0,0k1,,0.5,0.5Z", /* 36: Juno A55 Synth Bass II */ "v1w4a1,,0,1Zv0w20c2L1G4Zv2w1c3L1Zv3w3c4L1Zv4w1c5L1Zv5w5L1Zv1f7.175A34,1.0,10000,0Zv2a0,,0,0f220,1,,,,0,1d0.5,,,,,0m0Zv3a1,,0,0f220,1,,,,0,1m0Zv4a0.354,,0,0f110,1,,,,0,1m0Zv5a0,,0,0Zv0F212.87,0,,0,4.071,0R0.7Zv0a0.614,,1,1,0A0,1,0,1,0,0B6,1,627,0.071,121,0Zx7,-3,-3k0Z", /* 37: Juno A56 Funky III */ "v1w4a1,,0,1Zv0w20c2L1G4Zv2w1c3L1Zv3w3c4L1Zv4w1c5L1Zv5w5L1Zv1f0.57A5,1.0,10000,0Zv2a1,,0,0f220,1,,,,0,1d0.535,,,,,0m0Zv3a1,,0,0f220,1,,,,0,1m0Zv4a1,,0,0f110,1,,,,0,1m0Zv5a0.795,,0,0Zv0F160.22,0.079,,0,3.898,0R2.276Zv0a0.622,,1,1,0A0,1,0,1,0,0B6,1,248,0,6,0Zx7,-3,-3k0Z", /* 38: Juno A57 Thud Wah */ "v1w4a1,,0,1Zv0w20c2L1G4Zv2w1c3L1Zv3w3c4L1Zv4w1c5L1Zv5w5L1Zv1f3.247A5,1.0,10000,0Zv2a1,,0,0f440,1,,,,0,1d0.5,,,,,0.402m0Zv3a1,,0,0f440,1,,,,0,1m0Zv4a0.252,,0,0f220,1,,,,0,1m0Zv5a0.063,,0,0Zv0F2072,0,,-2.945,0,0R4.886Zv0a0.835,,1,1,0A6,1,0,0.803,478,0Zx7,-3,-3k1,,0.83,0.5Z", /* 39: Juno A58 Going Up */ "v1w4a1,,0,1Zv0w20c2L1G4Zv2w1c3L1Zv3w3c4L1Zv4w1c5L1Zv5w5L1Zv1f0.5A5,1.0,10000,0Zv2a0,,0,0f440,1,,,,0,1d0.894,,,,,0m0Zv3a0,,0,0f440,1,,,,0,1m0Zv4a0,,0,0f220,1,,,,0,1m0Zv5a0.22,,0,0Zv0F2885.3,0.512,,-3.205,0,0R11.2Zv0a0.591,,1,1,0A6,1,46322,0.142,23282,0Zx0,0,0k0Z", /* 40: Juno A61 Piano II */ "v1w4a1,,0,1Zv0w20c2L1G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268,0,206,0Zx0,0,0k0Z", /* 44: Juno A65 Tom Toms (unison) */ "v1w4a1,,0,1Zv0w20c2L1G4Zv2w1c3L1Zv3w3c4L1Zv4w1c5L1Zv5w5L1Zv1f3.247A24,1.0,10000,0Zv2a0,,0,0f220,1,,,,0.002,1d0.5,,,,,0m0Zv3a0,,0,0f220,1,,,,0.002,1m0Zv4a0.457,,0,0f110,1,,,,0.002,1m0Zv5a1,,0,0Zv0F444.44,0.165,,3.465,0,0R0.764Zv0a0.795,,1,1,0A6,1,388,0.118,366,0Zx7,-3,-3k0Z", /* 45: Juno A66 Timpani (unison) */ "v1w4a1,,0,1Zv0w20c2L1G4Zv2w1c3L1Zv3w3c4L1Zv4w1c5L1Zv5w5L1Zv1f0.5A5,1.0,10000,0Zv2a0,,0,0f220,1,,,,0,1d0.638,,,,,0m0Zv3a0,,0,0f220,1,,,,0,1m0Zv4a0.37,,0,0f110,1,,,,0,1m0Zv5a1,,0,0Zv0F72.866,0.189,,4.677,0,0R0.7Zv0a1,,1,1,0A14,1,2087,0.205,1731,0Zx0,0,0k0Z", /* 46: Juno A67 Shaker */ "v1w4a1,,0,1Zv0w20c2L1G4Zv2w1c3L1Zv3w3c4L1Zv4w1c5L1Zv5w5L1Zv1f0.974A450,1.0,10000,0Zv2a0,,0,0f440,1,,,,0,1d0.728,,,,,0m0Zv3a0,,0,0f440,1,,,,0,1m0Zv4a0,,0,0f220,1,,,,0,1m0Zv5a1,,0,0Zv0F5877.9,0.63,,0.087,0,0.167R1.87Zv0a1,,1,1,0A86,1,55,0,0,0Zx-15,8,8k0Z", /* 47: Juno A68 Synth Pad */ "v1w4a1,,0,1Zv0w20c2L1G4Zv2w1c3L1Zv3w3c4L1Zv4w1c5L1Zv5w5L1Zv1f2.734A5,1.0,10000,0Zv2a1,,0,0f440,1,,,,0.001,1d0.5,,,,,0.169m0Zv3a0,,0,0f440,1,,,,0.001,1m0Zv4a0.291,,0,0f220,1,,,,0.001,1m0Zv5a0,,0,0Zv0F242.37,1,,7.276,0,0R0.7Zv0a0.402,,1,1,0A6,1,11888,0.591,1123,0Zx7,-3,-3k1,,0.83,0.5Z", /* 48: Juno A71 Sweep I */ "v1w4a1,,0,1Zv0w20c2L1G4Zv2w1c3L1Zv3w3c4L1Zv4w1c5L1Zv5w5L1Zv1f5.116A5,1.0,10000,0Zv2a1,,0,0f880,1,,,,0,1d0.5,,,,,0.402m0Zv3a0,,0,0f880,1,,,,0,1m0Zv4a0.331,,0,0f440,1,,,,0,1m0Zv5a0.22,,0,0Zv0F22970,0,,-5.803,0,0R1.676Zv0a0.764,,1,1,0A6,1,3194,1,2910,0Zx0,0,0k1,,0.83,0.5Z", /* 49: Juno A72 Pluck Sweep */ "v1w4a1,,0,1Zv0w20c2L1G4Zv2w1c3L1Zv3w3c4L1Zv4w1c5L1Zv5w5L1Zv1f3.853A148,1.0,10000,0Zv2a1,,0,0f440,1,,,,0,1d0.5,,,,,0.268m0Zv3a1,,0,0f440,1,,,,0,1m0Zv4a0.984,,0,0f220,1,,,,0,1m0Zv5a0,,0,0Zv0F960.19,0.772,,0.78,0,0.059R7.898Zv0a0.354,,1,1,0A6,1,16963,0,2301,0Zx-8,0,0k1,,0.83,0.5Z", /* 50: Juno A73 Repeater */ "v1w4a1,,0,1Zv0w20c2L1G4Zv2w1c3L1Zv3w3c4L1Zv4w1c5L1Zv5w5L1Zv1f4.974A31,1.0,10000,0Zv2a1,,0,0f440,1,,,,0.002,1d0.898,,,,,0m0Zv3a0,,0,0f440,1,,,,0.002,1m0Zv4a0.346,,0,0f220,1,,,,0.002,1m0Zv5a0,,0,0Zv0F8999.7,0.449,,0,-4.85,0R1.348Zv0a0.685,,1,1,0A0,1,0,1,0,0B118,1,0,0.323,0,0Zx0,0,0k1,,0.5,0.5Z", /* 51: Juno A74 Sweep II */ "v1w4a1,,0,1Zv0w20c2L1G4Zv2w1c3L1Zv3w3c4L1Zv4w1c5L1Zv5w5L1Zv1f6.783A472,1.0,10000,0Zv2a1,,0,0f440,1,,,,0.004,1d0.882,,,,,0m0Zv3a0,,0,0f440,1,,,,0.004,1m0Zv4a0.378,,0,0f220,1,,,,0.004,1m0Zv5a0,,0,0Zv0F1264.7,0.551,,5.89,0,0R6.489Zv0a0.795,,1,1,0A6,1,15068,0.417,2411,0Zx7,-3,-3k1,,0.5,0.5Z", /* 52: Juno A75 Pluck Bell */ "v1w4a1,,0,1Zv0w20c2L1G4Zv2w1c3L1Zv3w3c4L1Zv4w1c5L1Zv5w5L1Zv1f2.367A5,1.0,10000,0Zv2a1,,0,0f880,1,,,,0.001,1d0.5,,,,,0.067m0Zv3a0,,0,0f880,1,,,,0.001,1m0Zv4a0.386,,0,0f440,1,,,,0.001,1m0Zv5a0,,0,0Zv0F276.02,1,,4.244,0,0R0.7Zv0a0.386,,1,1,0A6,1,11888,0.591,720,0Zx7,-3,-3k1,,0.83,0.5Z", /* 53: Juno A76 Dark Synth Piano */ "v1w4a1,,0,1Zv0w20c2L1G4Zv2w1c3L1Zv3w3c4L1Zv4w1c5L1Zv5w5L1Zv1f20.195A5,1.0,10000,0Zv2a1,,0,0f440,1,,,,0,1d0.5,,,,,0m0Zv3a1,,0,0f440,1,,,,0,1m0Zv4a1,,0,0f220,1,,,,0,1m0Zv5a0,,0,0Zv0F662.85,0.559,,-0.52,0,0R4.576Zv0a0.622,,1,1,0A6,1,1195,0,619,0Zx7,-3,-3k1,,0.83,0.5Z", /* 54: Juno A77 Sustainer */ "v1w4a1,,0,1Zv0w20c2L1G4Zv2w1c3L1Zv3w3c4L1Zv4w1c5L1Zv5w5L1Zv1f4.196A5,1.0,10000,0Zv2a1,,0,0f440,1,,,,0.001,1d0.5,,,,,0.181m0Zv3a0,,0,0f440,1,,,,0.001,1m0Zv4a0.386,,0,0f220,1,,,,0.001,1m0Zv5a0,,0,0Zv0F276.02,1,,7.276,0,0R0.7Zv0a0.449,,1,1,0A6,1,11888,0.591,1651,0Zx7,-3,-3k0Z", /* 55: Juno A78 Wah Release */ "v1w4a1,,0,1Zv0w20c2L1G4Zv2w1c3L1Zv3w3c4L1Zv4w1c5L1Zv5w5L1Zv1f6.976A21,1.0,10000,0Zv2a1,,0,0f440,1,,,,0,1d0.598,,,,,0m0Zv3a0,,0,0f440,1,,,,0,1m0Zv4a0.685,,0,0f220,1,,,,0,1m0Zv5a0,,0,0Zv0F1837.9,0.52,,-1.646,0,0R4.78Zv0a0.819,,1,1,0A6,1,11203,0,193,0Zx0,0,0k1,,0.83,0.5Z", /* 56: Juno A81 Gong (play low chords) */ "v1w4a1,,0,1Zv0w20c2L1G4Zv2w1c3L1Zv3w3c4L1Zv4w1c5L1Zv5w5L1Zv1f20.195A5,1.0,10000,0Zv2a1,,0,0f220,1,,,,0,1d0.902,,,,,0m0Zv3a0,,0,0f220,1,,,,0,1m0Zv4a0,,0,0f110,1,,,,0,1m0Zv5a0.441,,0,0Zv0F1653.9,0.567,,-0.433,0,0R7.238Zv0a0.717,,1,1,0A30,1,1272,1,6126,0Zx0,0,0k1,,0.5,0.5Z", /* 57: Juno A82 Resonance Funk */ "v1w4a1,,0,1Zv0w20c2L1G4Zv2w1c3L1Zv3w3c4L1Zv4w1c5L1Zv5w5L1Zv1f2.98A5,1.0,10000,0Zv2a0,,0,0f220,1,,,,0,1d0.5,,,,,0m0Zv3a0,,0,0f220,1,,,,0,1m0Zv4a0,,0,0f110,1,,,,0,1m0Zv5a0,,0,0Zv0F101.47,0.701,,3.898,0,0R11.2Zv0a1,,1,1,0A6,1,165,0,121,0Zx0,0,0k0Z", /* 58: Juno A83 Drum Booms* (1 oct. down) */ "v1w4a1,,0,1Zv0w20c2L1G4Zv2w1c3L1Zv3w3c4L1Zv4w1c5L1Zv5w5L1Zv1f0.5A5,1.0,10000,0Zv2a0,,0,0f220,1,,,,0,1d0.902,,,,,0m0Zv3a0,,0,0f220,1,,,,0,1m0Zv4a0.362,,0,0f110,1,,,,0,1m0Zv5a1,,0,0Zv0F252.92,0.457,,2.945,0,0R0.7Zv0a1,,1,1,0A6,1,587,0.118,588,0Zx7,-3,-3k0Z", /* 59: Juno A84 Dust Storm */ "v1w4a1,,0,1Zv0w20c2L1G4Zv2w1c3L1Zv3w3c4L1Zv4w1c5L1Zv5w5L1Zv1f0.5A5,1.0,10000,0Zv2a0,,0,0f220,1,,,,0,1d0.5,,,,,0m0Zv3a0,,0,0f220,1,,,,0,1m0Zv4a0,,0,0f110,1,,,,0,1m0Zv5a1,,0,0Zv0F561.51,0.74,,0,0,0.433R4.477Zv0a1,,1,1,0A710,1,16963,0.22,3348,0Zx0,0,0k0Z", /* 60: Juno A85 Rocket Men */ "v1w4a1,,0,1Zv0w20c2L1G4Zv2w1c3L1Zv3w3c4L1Zv4w1c5L1Zv5w5L1Zv1f0.649A64,1.0,10000,0Zv2a0,,0,0f880,1,,,,0,1d0.902,,,,,0m0Zv3a0,,0,0f880,1,,,,0,1m0Zv4a0,,0,0f440,1,,,,0,1m0Zv5a0.764,,0,0Zv0F1882.7,0.441,,-0.693,0,0R8.433Zv0a1,,1,1,0A6,1,15068,1,8083,0Zx-15,8,8k0Z", /* 61: Juno A86 Hand Claps */ "v1w4a1,,0,1Zv0w20c2L1G4Zv2w1c3L1Zv3w3c4L1Zv4w1c5L1Zv5w5L1Zv1f2.98A5,1.0,10000,0Zv2a0,,0,0f220,1,,,,0,1d0.5,,,,,0m0Zv3a0,,0,0f220,1,,,,0,1m0Zv4a0,,0,0f110,1,,,,0,1m0Zv5a1,,0,0Zv0F49.174,0.433,,0,4.677,0R4.78Zv0a1,,1,1,0A0,1,0,1,0,0B14,1,72,0,30,0Zx-15,8,8k0Z", /* 62: Juno A87 FX Sweep */ "v1w4a1,,0,1Zv0w20c2L1G4Zv2w1c3L1Zv3w3c4L1Zv4w1c5L1Zv5w5L1Zv1f20.195A339,1.0,10000,0Zv2a1,,0,0f220,1,,,,0.027,1d0.5,,,,,0.402m0Zv3a0,,0,0f220,1,,,,0.027,1m0Zv4a1,,0,0f110,1,,,,0.027,1m0Zv5a1,,0,0Zv0F1931.3,0.74,,-7.189,0,0R1.829Zv0a1,,1,1,0A6,1,20258,0,11687,0Zx0,0,0k0Z", /* 63: Juno A88 Caverns */ "v1w4a1,,0,1Zv0w20c2L1G4Zv2w1c3L1Zv3w3c4L1Zv4w1c5L1Zv5w5L1Zv1f0.5A5,1.0,10000,0Zv2a0,,0,0f220,1,,,,0,1d0.5,,,,,0.402m0Zv3a0,,0,0f220,1,,,,0,1m0Zv4a0,,0,0f110,1,,,,0,1m0Zv5a1,,0,0Zv0F1434.5,0.543,,0,0,0R9.202Zv0a0.843,,1,1,0A6,1,92,0.299,531,0Zx-8,0,0k0Z", /* 64: Juno B11 Strings */ "v1w4a1,,0,1Zv0w20c2L1G4Zv2w1c3L1Zv3w3c4L1Zv4w1c5L1Zv5w5L1Zv1f2.814A128,1.0,10000,0Zv2a1,,0,0f440,1,,,,0,1d0.5,,,,,0.217m0Zv3a1,,0,0f440,1,,,,0,1m0Zv4a0,,0,0f220,1,,,,0,1m0Zv5a0,,0,0Zv0F5082.2,0.85,,0,0,0R0.7Zv0a0.409,,1,1,0A478,1,447,0.677,366,0Zx7,-3,-3k1,,0.83,0.5Z", /* 65: Juno B12 Violin */ "v1w4a1,,0,1Zv0w20c2L1G4Zv2w1c3L1Zv3w3c4L1Zv4w1c5L1Zv5w5L1Zv1f3.64A128,1.0,10000,0Zv2a0,,0,0f440,1,,,,0.005,1d0.5,,,,,0m0Zv3a1,,0,0f440,1,,,,0.005,1m0Zv4a0,,0,0f220,1,,,,0.005,1m0Zv5a0,,0,0Zv0F3173.2,0.945,,0,0,0R0.7Zv0a0.866,,1,1,0A350,1,1053,0.449,159,0Zx7,-3,-3k0Z", /* 66: Juno B13 Chorus Vibes */ "v1w4a1,,0,1Zv0w20c2L1G4Zv2w1c3L1Zv3w3c4L1Zv4w1c5L1Zv5w5L1Zv1f4.317A128,1.0,10000,0Zv2a1,,0,0f440,1,,,,0,1d0.5,,,,,0m0Zv3a0,,0,0f440,1,,,,0,1m0Zv4a0,,0,0f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0.002,1d0.5,,,,,0m0Zv3a0,,0,0f440,1,,,,0.002,1m0Zv4a0,,0,0f220,1,,,,0.002,1m0Zv5a0,,0,0Zv0F17.527,0.575,,7.795,0,0R0.7Zv0a0.512,,1,1,0A6,1,125,0.614,14048,0Zx7,-3,-3k1,,0.5,0.5Z", /* 71: Juno B18 Noise Sweep */ "v1w4a1,,0,1Zv0w20c2L1G4Zv2w1c3L1Zv3w3c4L1Zv4w1c5L1Zv5w5L1Zv1f20.195A5,1.0,10000,0Zv2a0,,0,0f220,1,,,,0,1d0.5,,,,,0m0Zv3a0,,0,0f220,1,,,,0,1m0Zv4a0,,0,0f110,1,,,,0,1m0Zv5a1,,0,0Zv0F22.662,0.819,,6.669,0,0R0.7Zv0a0.724,,1,1,0A118,1,7843,0.85,16883,0Zx7,-3,-3k0Z", /* 72: Juno B21 Space Chimes */ "v1w4a1,,0,1Zv0w20c2L1G4Zv2w1c3L1Zv3w3c4L1Zv4w1c5L1Zv5w5L1Zv1f9.237A5,1.0,10000,0Zv2a1,,0,0f880,1,,,,0,1d0.5,,,,,0m0Zv3a0,,0,0f880,1,,,,0,1m0Zv4a0,,0,0f440,1,,,,0,1m0Zv5a0,,0,0Zv0F1667.5,0.583,,0,0,0R11.2Zv0a0.669,,1,1,0A6,1,268,0,1019,0Zx7,-3,-3k1,,0.5,0.5Z", /* 73: Juno B22 Nylon Guitar */ "v1w4a1,,0,1Zv0w20c2L1G4Zv2w1c3L1Zv3w3c4L1Zv4w1c5L1Zv5w5L1Zv1f4.317A128,1.0,10000,0Zv2a1,,0,0f440,1,,,,0,1d0.614,,,,,0m0Zv3a0,,0,0f440,1,,,,0,1m0Zv4a0,,0,0f220,1,,,,0,1m0Zv5a0,,0,0Zv0F585.97,0.197,,2.252,0,0R0.7Zv0a0.906,,1,1,0A6,1,15068,0,232,0Zx-15,8,8k0Z", /* 74: Juno B23 Orchestral Pad */ "v1w4a1,,0,1Zv0w20c2L1G4Zv2w1c3L1Zv3w3c4L1Zv4w1c5L1Zv5w5L1Zv1f1.004A128,1.0,10000,0Zv2a1,,0,0f440,1,,,,0,1d0.5,,,,,0.413m0Zv3a1,,0,0f440,1,,,,0,1m0Zv4a1,,0,0f220,1,,,,0,1m0Zv5a0,,0,0Zv0F128.75,0.283,,4.764,0,0R0.7Zv0a0,,1,1,0A238,1,14202,0.394,685,0Zx7,-3,-3k1,,0.83,0.5Z", /* 75: Juno B24 Bright Pluck */ "v1w4a1,,0,1Zv0w20c2L1G4Zv2w1c3L1Zv3w3c4L1Zv4w1c5L1Zv5w5L1Zv1f0.5A5,1.0,10000,0Zv2a1,,0,0f440,1,,,,0,1d0.728,,,,,0m0Zv3a0,,0,0f440,1,,,,0,1m0Zv4a0,,0,0f220,1,,,,0,1m0Zv5a0,,0,0Zv0F752.17,0.677,,3.465,0,0R0.7Zv0a0.819,,1,1,0A6,1,268,0.331,453,0Zx0,0,0k0Z", /* 76: Juno B25 Organ Bell */ "v1w4a1,,0,1Zv0w20c2L1G4Zv2w1c3L1Zv3w3c4L1Zv4w1c5L1Zv5w5L1Zv1f5.116A5,1.0,10000,0Zv2a1,,0,0f440,1,,,,0.001,1d0.768,,,,,0m0Zv3a1,,0,0f440,1,,,,0.001,1m0Zv4a0.669,,0,0f220,1,,,,0.001,1m0Zv5a0,,0,0Zv0F1153.8,1,,0,0,0R0.7Zv0a0.488,,1,1,0A6,1,0,1,159,0Zx7,-3,-3k1,,0.5,0.5Z", /* 77: Juno B26 Accordion */ "v1w4a1,,0,1Zv0w20c2L1G4Zv2w1c3L1Zv3w3c4L1Zv4w1c5L1Zv5w5L1Zv1f0.5A5,1.0,10000,0Zv2a1,,0,0f440,1,,,,0,1d0.752,,,,,0m0Zv3a1,,0,0f440,1,,,,0,1m0Zv4a0.63,,0,0f220,1,,,,0,1m0Zv5a0,,0,0Zv0F2628.5,0.583,,1.213,0,0R0.7Zv0a0.52,,1,1,0A70,1,72,0.866,35,0Zx-15,8,8k1,,0.5,0.5Z", /* 78: Juno B27 FX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a0,,0,0f880,1,,,,0,1m0Zv4a0,,0,0f440,1,,,,0,1m0Zv5a0,,0,0Zv0F733.57,0.504,,1.386,0,0.748R11.2Zv0a0,,1,1,0A6,1,0,1,3348,0Zx7,-3,-3k1,,0.5,0.5Z", /* 86: Juno B37 Sharp Reed */ "v1w4a1,,0,1Zv0w20c2L1G4Zv2w1c3L1Zv3w3c4L1Zv4w1c5L1Zv5w5L1Zv1f0.974A5,1.0,10000,0Zv2a1,,0,0f880,1,,,,0,1d0.5,,,,,0.287m0Zv3a1,,0,0f880,1,,,,0,1m0Zv4a0,,0,0f440,1,,,,0,1m0Zv5a0,,0,0Zv0F144.98,0.512,,0,4.591,0R0.7Zv0a0.433,,1,1,0A0,1,0,1,0,0B22,1,151,0.882,0,0Zx7,-3,-3k0Z", /* 87: Juno B38 Bass Pluck */ "v1w4a1,,0,1Zv0w20c2L1G4Zv2w1c3L1Zv3w3c4L1Zv4w1c5L1Zv5w5L1Zv1f0.5A5,1.0,10000,0Zv2a1,,0,0f220,1,,,,0,1d0.5,,,,,0.236m0Zv3a1,,0,0f220,1,,,,0,1m0Zv4a0,,0,0f110,1,,,,0,1m0Zv5a0,,0,0Zv0F171.85,0.339,,2.425,0,0R1.318Zv0a0.724,,1,1,0A6,1,870,0.276,0,0Zx7,-3,-3k0Z", /* 88: Juno B41 Resonant Rise */ "v1w4a1,,0,1Zv0w20c2L1G4Zv2w1c3L1Zv3w3c4L1Zv4w1c5L1Zv5w5L1Zv1f2.437A5,1.0,10000,0Zv2a0,,0,0f220,1,,,,0.004,1d0.5,,,,,0m0Zv3a1,,0,0f220,1,,,,0.004,1m0Zv4a0,,0,0f110,1,,,,0.004,1m0Zv5a0,,0,0Zv0F1280.4,0.575,,0,-2.685,0R7.238Zv0a0.488,,1,1,0A0,1,0,1,0,0B6,1,1632,0.307,0,0Zx7,-3,-3k1,,0.83,0.5Z", /* 89: Juno B42 Harpsichord 2 */ "v1w4a1,,0,1Zv0w20c2L1G4Zv2w1c3L1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: Juno B46 Glassy Wah */ "v1w4a1,,0,1Zv0w20c2L1G4Zv2w1c3L1Zv3w3c4L1Zv4w1c5L1Zv5w5L1Zv1f0.5A1313,1.0,10000,0Zv2a1,,0,0f440,1,,,,0,1d0.61,,,,,0m0Zv3a0,,0,0f440,1,,,,0,1m0Zv4a0,,0,0f220,1,,,,0,1m0Zv5a0,,0,0Zv0F80.756,0.512,,5.283,0,0R1.47Zv0a0.882,,1,1,0A54,1,151,0.394,328,0Zx7,-3,-3k0Z", /* 94: Juno B47 Phase Ensemble */ "v1w4a1,,0,1Zv0w20c2L1G4Zv2w1c3L1Zv3w3c4L1Zv4w1c5L1Zv5w5L1Zv1f0.714A128,1.0,10000,0Zv2a1,,0,0f440,1,,,,0.001,1d0.5,,,,,0.413m0Zv3a0,,0,0f440,1,,,,0.001,1m0Zv4a0,,0,0f220,1,,,,0.001,1m0Zv5a0,,0,0Zv0F3718.8,1,,0,0,0R0.7Zv0a0.78,,1,1,0A678,1,1053,0.449,588,0Zx7,-3,-3k1,,0.83,0.5Z", /* 95: Juno B48 Chorused Bell */ "v1w4a1,,0,1Zv0w20c2L1G4Zv2w1c3L1Zv3w3c4L1Zv4w1c5L1Zv5w5L1Zv1f0.5A16,1.0,10000,0Zv2a1,,0,0f880,1,,,,0,1d0.5,,,,,0.413m0Zv3a0,,0,0f880,1,,,,0,1m0Zv4a0.795,,0,0f440,1,,,,0,1m0Zv5a0,,0,0Zv0F1013.2,1,,0,0,0R11.2Zv0a0.488,,1,1,0A6,1,3006,0,879,0Zx7,-3,-3k1,,0.5,0.5Z", /* 96: Juno B51 Clav */ "v1w4a1,,0,1Zv0w20c2L1G4Zv2w1c3L1Zv3w3c4L1Zv4w1c5L1Zv5w5L1Zv1f2.3A16,1.0,10000,0Zv2a1,,0,0f220,1,,,,0,1d0.858,,,,,0m0Zv3a0,,0,0f220,1,,,,0,1m0Zv4a0.055,,0,0f110,1,,,,0,1m0Zv5a0,,0,0Zv0F104.11,0,,5.457,0,0R0.7Zv0a0.85,,1,1,0A6,1,927,0.433,0,0Zx-8,0,0k0Z", /* 97: Juno B52 Organ 2 */ "v1w4a1,,0,1Zv0w20c2L1G4Zv2w1c3L1Zv3w3c4L1Zv4w1c5L1Zv5w5L1Zv1f5.569A5,1.0,10000,0Zv2a0,,0,0f220,1,,,,0,1d0.909,,,,,0m0Zv3a1,,0,0f220,1,,,,0,1m0Zv4a0,,0,0f110,1,,,,0,1m0Zv5a0,,0,0Zv0F731.97,1,,0,0.606,0R7.081Zv0a0.622,,1,1,0A0,1,0,1,0,0B6,1,0,0,0,0Zx7,-3,-3k1,,0.5,0.5Z", /* 98: Juno B53 Bassoon */ "v1w4a1,,0,1Zv0w20c2L1G4Zv2w1c3L1Zv3w3c4L1Zv4w1c5L1Zv5w5L1Zv1f6.06A89,1.0,10000,0Zv2a1,,0,0f220,1,,,,0.002,1d0.854,,,,,0m0Zv3a0,,0,0f220,1,,,,0.002,1m0Zv4a0,,0,0f110,1,,,,0.002,1m0Zv5a0,,0,0Zv0F188.99,0.772,,3.724,0,0.089R0.7Zv0a1,,1,1,0A46,1,142057,0.835,6,0Zx-15,8,8k0Z", /* 99: Juno B54 Auto Release Noise Sweep */ "v1w4a1,,0,1Zv0w20c2L1G4Zv2w1c3L1Zv3w3c4L1Zv4w1c5L1Zv5w5L1Zv1f20.195A5,1.0,10000,0Zv2a0,,0,0f880,1,,,,0,1d0.5,,,,,0m0Zv3a0,,0,0f880,1,,,,0,1m0Zv4a0,,0,0f440,1,,,,0,1m0Zv5a1,,0,0Zv0F76715,0.819,,-11,0,0R0.7Zv0a0.843,,1,1,0A6,1,8324,0.449,3049,0Zx7,-3,-3k1,,0.5,0.5Z", /* 100: Juno B55 Brass Ensemble */ "v1w4a1,,0,1Zv0w20c2L1G4Zv2w1c3L1Zv3w3c4L1Zv4w1c5L1Zv5w5L1Zv1f1.1A1313,1.0,10000,0Zv2a1,,0,0f440,1,,,,0,1d0.5,,,,,0.287m0Zv3a1,,0,0f440,1,,,,0,1m0Zv4a0,,0,0f220,1,,,,0,1m0Zv5a0,,0,0Zv0F360.26,0.512,,3.031,0,0R1.47Zv0a0.307,,1,1,0A54,1,4315,0.528,328,0Zx7,-3,-3k1,,0.5,0.5Z", /* 101: Juno B56 Ethereal */ "v1w4a1,,0,1Zv0w20c2L1G4Zv2w1c3L1Zv3w3c4L1Zv4w1c5L1Zv5w5L1Zv1f3.964A5,1.0,10000,0Zv2a1,,0,0f440,1,,,,0,1d0.5,,,,,0.413m0Zv3a1,,0,0f440,1,,,,0,1m0Zv4a0.465,,0,0f220,1,,,,0,1m0Zv5a0,,0,0Zv0F464.34,1,,0,0,0R9.613Zv0a0.472,,1,1,0A742,1,1442,1,796,0Zx7,-3,-3k1,,0.83,0.5Z", /* 102: Juno B57 Chorus Bell 2 */ "v1w4a1,,0,1Zv0w20c2L1G4Zv2w1c3L1Zv3w3c4L1Zv4w1c5L1Zv5w5L1Zv1f4.317A128,1.0,10000,0Zv2a1,,0,0f440,1,,,,0,1d0.614,,,,,0m0Zv3a1,,0,0f440,1,,,,0,1m0Zv4a0,,0,0f220,1,,,,0,1m0Zv5a0,,0,0Zv0F18.791,0.709,,5.37,0,0R6.489Zv0a0.236,,1,1,0A6,1,78775,0,16883,0Zx7,-3,-3k1,,0.5,0.5Z", /* 103: Juno B58 Blizzard */ "v1w4a1,,0,1Zv0w20c2L1G4Zv2w1c3L1Zv3w3c4L1Zv4w1c5L1Zv5w5L1Zv1f0.517A5,1.0,10000,0Zv2a0,,0,0f880,1,,,,0,1d0.5,,,,,0.413m0Zv3a0,,0,0f880,1,,,,0,1m0Zv4a0,,0,0f440,1,,,,0,1m0Zv5a1,,0,0Zv0F813.39,0.953,,0.606,0,0.374R4.886Zv0a1,,1,1,0A630,1,25663,0.685,2411,0Zx-15,8,8k0Z", /* 104: Juno B61 E. Piano with Tremolo */ "v1w4a1,,0,1Zv0w20c2L1G4Zv2w1c3L1Zv3w3c4L1Zv4w1c5L1Zv5w5L1Zv1f1.932A5,1.0,10000,0Zv2a1,,0,0f880,1,,,,0,1d0.5,,,,,0.083m0Zv3a0,,0,0f880,1,,,,0,1m0Zv4a1,,0,0f440,1,,,,0,1m0Zv5a0,,0,0Zv0F84.211,0.843,,3.031,0,0.069R0.7Zv0a0.811,,1,1,0A6,1,3603,0.472,6126,0Zx0,0,0k0Z", /* 105: Juno B62 Clarinet */ "v1w4a1,,0,1Zv0w20c2L1G4Zv2w1c3L1Zv3w3c4L1Zv4w1c5L1Zv5w5L1Zv1f3.964A36,1.0,10000,0Zv2a1,,0,0f440,1,,,,0.002,1d0.5,,,,,0m0Zv3a0,,0,0f440,1,,,,0.002,1m0Zv4a0,,0,0f220,1,,,,0.002,1m0Zv5a0,,0,0Zv0F188.99,0.772,,3.724,0,0.069R0.7Zv0a0.819,,1,1,0A46,1,142057,0.835,26,0Zx-15,8,8k0Z", /* 106: Juno B63 Thunder */ "v1w4a1,,0,1Zv0w20c2L1G4Zv2w1c3L1Zv3w3c4L1Zv4w1c5L1Zv5w5L1Zv1f20.195A5,1.0,10000,0Zv2a0,,0,0f220,1,,,,0,1d0.5,,,,,0m0Zv3a0,,0,0f220,1,,,,0,1m0Zv4a0,,0,0f110,1,,,,0,1m0Zv5a1,,0,0Zv0F22.662,0.819,,6.669,0,0R0.7Zv0a0.843,,1,1,0A6,1,212,0.85,16883,0Zx7,-3,-3k0Z", /* 107: Juno B64 Reedy Organ */ "v1w4a1,,0,1Zv0w20c2L1G4Zv2w1c3L1Zv3w3c4L1Zv4w1c5L1Zv5w5L1Zv1f1.483A28,1.0,10000,0Zv2a1,,0,0f440,1,,,,0,1d0.5,,,,,0.287m0Zv3a0,,0,0f440,1,,,,0,1m0Zv4a0,,0,0f220,1,,,,0,1m0Zv5a0,,0,0Zv0F144.98,0.512,,0,4.591,0R0.7Zv0a0.543,,1,1,0A0,1,0,1,0,0B30,1,988,0.858,0,0Zx7,-3,-3k0Z", /* 108: Juno B65 Flute / Horn */ "v1w4a1,,0,1Zv0w20c2L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Zx7,-3,-3k0Z", /* 112: Juno B71 Piccolo */ "v1w4a1,,0,1Zv0w20c2L1G4Zv2w1c3L1Zv3w3c4L1Zv4w1c5L1Zv5w5L1Zv1f4.079A51,1.0,10000,0Zv2a1,,0,0f880,1,,,,0,1d0.555,,,,,0m0Zv3a1,,0,0f880,1,,,,0,1m0Zv4a0,,0,0f440,1,,,,0,1m0Zv5a0,,0,0Zv0F25.183,0.772,,5.457,0,0.157R0.7Zv0a0.685,,1,1,0A134,1,34482,0.835,112,0Zx-8,0,0k0Z", /* 113: Juno B72 Melodic Taps */ "v1w4a1,,0,1Zv0w20c2L1G4Zv2w1c3L1Zv3w3c4L1Zv4w1c5L1Zv5w5L1Zv1f9.237A5,1.0,10000,0Zv2a0,,0,0f220,1,,,,0,1d0.5,,,,,0m0Zv3a0,,0,0f220,1,,,,0,1m0Zv4a0,,0,0f110,1,,,,0,1m0Zv5a1,,0,0Zv0F2359.1,1,,0,0,0R8.072Zv0a1,,1,1,0A6,1,248,0,139,0Zx-15,8,8k1,,0.5,0.5Z", /* 114: Juno B73 Meow Brass */ "v1w4a1,,0,1Zv0w20c2L1G4Zv2w1c3L1Zv3w3c4L1Zv4w1c5L1Zv5w5L1Zv1f2.367A5991,1.0,10000,0Zv2a0,,0,0f440,1,,,,0,1d0.5,,,,,0.287m0Zv3a1,,0,0f440,1,,,,0,1m0Zv4a0,,0,0f220,1,,,,0,1m0Zv5a0,,0,0Zv0F316.33,0.512,,0,3.031,0R6.212Zv0a0.661,,1,1,0A0,1,0,1,0,0B38,1,15988,0,170,0Zx7,-3,-3k0Z", /* 115: Juno B74 Violin (high) */ "v1w4a1,,0,1Zv0w20c2L1G4Zv2w1c3L1Zv3w3c4L1Zv4w1c5L1Zv5w5L1Zv1f4.196A128,1.0,10000,0Zv2a0,,0,0f880,1,,,,0.005,1d0.5,,,,,0m0Zv3a1,,0,0f880,1,,,,0.005,1m0Zv4a0,,0,0f440,1,,,,0.005,1m0Zv5a0,,0,0Zv0F6923.6,0.945,,0,0,0.03R0.7Zv0a0.669,,1,1,0A350,1,1053,0.449,159,0Zx7,-3,-3k0Z", /* 116: Juno B75 High Bells */ "v1w4a1,,0,1Zv0w20c2L1G4Zv2w1c3L1Zv3w3c4L1Zv4w1c5L1Zv5w5L1Zv1f1.278A128,1.0,10000,0Zv2a0,,0,0f880,1,,,,0.03,1d0.5,,,,,0m0Zv3a0,,0,0f880,1,,,,0.03,1m0Zv4a0,,0,0f440,1,,,,0.03,1m0Zv5a0,,0,0Zv0F3059.8,1,,0,0,0R11.2Zv0a0.874,,1,1,0A6,1,212,0.409,970,0Zx-15,8,8k0Z", /* 117: Juno B76 Rolling Wah */ "v1w4a1,,0,1Zv0w20c2L1G4Zv2w1c3L1Zv3w3c4L1Zv4w1c5L1Zv5w5L1Zv1f1.528A5,1.0,10000,0Zv2a1,,0,0f440,1,,,,0,1d0.5,,,,,0.413m0Zv3a0,,0,0f440,1,,,,0,1m0Zv4a0,,0,0f220,1,,,,0,1m0Zv5a0,,0,0Zv0F642.89,0,,0,0,1.25R0.852Zv0a0.606,,1,1,0A278,1,1963,1,8465,0Zx7,-3,-3k0Z", /* 118: Juno B77 Ping Bell */ "v1w4a1,,0,1Zv0w20c2L1G4Zv2w1c3L1Zv3w3c4L1Zv4w1c5L1Zv5w5L1Zv1f0.5A16,1.0,10000,0Zv2a1,,0,0f880,1,,,,0,1d0.5,,,,,0.409m0Zv3a0,,0,0f880,1,,,,0,1m0Zv4a0,,0,0f440,1,,,,0,1m0Zv5a0,,0,0Zv0F3059.8,1,,0,0,0R11.2Zv0a0.654,,1,1,0A6,1,230,0.181,879,0Zx7,-3,-3k1,,0.5,0.5Z", /* 119: Juno B78 Brassy Organ */ "v1w4a1,,0,1Zv0w20c2L1G4Zv2w1c3L1Zv3w3c4L1Zv4w1c5L1Zv5w5L1Zv1f0.835A5,1.0,10000,0Zv2a1,,0,0f220,1,,,,0,1d0.5,,,,,0.268m0Zv3a1,,0,0f220,1,,,,0,1m0Zv4a0.441,,0,0f110,1,,,,0,1m0Zv5a0,,0,0Zv0F27.056,0.409,,7.535,0,0R0.7Zv0a0.11,,1,1,0A6,1,587,0.858,0,0Zx7,-3,-3k1,,0.5,0.5Z", /* 120: Juno B81 Low Dark Strings */ "v1w4a1,,0,1Zv0w20c2L1G4Zv2w1c3L1Zv3w3c4L1Zv4w1c5L1Zv5w5L1Zv1f0.974A128,1.0,10000,0Zv2a1,,0,0f220,1,,,,0.001,1d0.5,,,,,0.319m0Zv3a1,,0,0f220,1,,,,0.001,1m0Zv4a0,,0,0f110,1,,,,0.001,1m0Zv5a0,,0,0Zv0F2003.8,0.811,,0,0,0R0.7Zv0a0.315,,1,1,0A670,1,230,0.858,408,0Zx7,-3,-3k1,,0.83,0.5Z", /* 121: Juno B82 Piccolo Trumpet */ "v1w4a1,,0,1Zv0w20c2L1G4Zv2w1c3L1Zv3w3c4L1Zv4w1c5L1Zv5w5L1Zv1f2.367A5991,1.0,10000,0Zv2a0,,0,0f440,1,,,,0,1d0.5,,,,,0.287m0Zv3a1,,0,0f440,1,,,,0,1m0Zv4a0,,0,0f220,1,,,,0,1m0Zv5a0,,0,0Zv0F21.863,1,,0,8.142,0R0.7Zv0a0.764,,1,1,0A0,1,0,1,0,0B30,1,988,0.402,45,0Zx7,-3,-3k0Z", /* 122: Juno B83 Cello */ "v1w4a1,,0,1Zv0w20c2L1G4Zv2w1c3L1Zv3w3c4L1Zv4w1c5L1Zv5w5L1Zv1f2.814A128,1.0,10000,0Zv2a0,,0,0f220,1,,,,0.005,1d0.5,,,,,0m0Zv3a1,,0,0f220,1,,,,0.005,1m0Zv4a0,,0,0f110,1,,,,0.005,1m0Zv5a0,,0,0Zv0F2049.7,0.354,,0.26,0,0.01R0.7Zv0a0.858,,1,1,0A390,1,3603,0.709,261,0Zx7,-3,-3k0Z", /* 123: Juno B84 High Strings */ "v1w4a1,,0,1Zv0w20c2L1G4Zv2w1c3L1Zv3w3c4L1Zv4w1c5L1Zv5w5L1Zv1f5.414A5,1.0,10000,0Zv2a1,,0,0f880,1,,,,0.002,1d0.5,,,,,0.276m0Zv3a1,,0,0f880,1,,,,0.002,1m0Zv4a0,,0,0f440,1,,,,0.002,1m0Zv5a0,,0,0Zv0F6885.4,0.559,,0,0,0R0.7Zv0a0.378,,1,1,0A222,1,2219,0.449,386,0Zx7,-3,-3k1,,0.83,0.5Z", /* 124: Juno B85 Rocket Men */ "v1w4a1,,0,1Zv0w20c2L1G4Zv2w1c3L1Zv3w3c4L1Zv4w1c5L1Zv5w5L1Zv1f11.884A5,1.0,10000,0Zv2a0,,0,0f440,1,,,,0,1d0.5,,,,,0m0Zv3a0,,0,0f440,1,,,,0,1m0Zv4a0,,0,0f220,1,,,,0,1m0Zv5a0,,0,0Zv0F27909,1,,-6.929,0,0.62R11.2Zv0a0,,1,1,0A6,1,142057,0.402,4035,0Zx7,-3,-3k1,,0.83,0.5Z", /* 125: Juno B86 Forbidden Planet */ "v1w4a1,,0,1Zv0w20c2L1G4Zv2w1c3L1Zv3w3c4L1Zv4w1c5L1Zv5w5L1Zv1f2.3A16,1.0,10000,0Zv2a1,,0,0f880,1,,,,0,1d0.673,,,,,0m0Zv3a0,,0,0f880,1,,,,0,1m0Zv4a0.071,,0,0f440,1,,,,0,1m0Zv5a0,,0,0Zv0F126.38,0.748,,7.622,0,0.049R0.764Zv0a0.622,,1,1,0A6,1,1272,0.181,408,0Zx-15,8,8k1,,0.5,0.5Z", /* 126: Juno B87 Froggy */ "v1w4a1,,0,1Zv0w20c2L1G4Zv2w1c3L1Zv3w3c4L1Zv4w1c5L1Zv5w5L1Zv1f5.116A5,1.0,10000,0Zv2a1,,0,0f220,1,,,,0,1d0.5,,,,,0m0Zv3a0,,0,0f220,1,,,,0,1m0Zv4a1,,0,0f110,1,,,,0,1m0Zv5a0,,0,0Zv0F781.14,1,,0,-3.724,0R11.2Zv0a0.606,,1,1,0A0,1,0,1,0,0B6,1,0,0,0,0Zx0,0,0k0Z", /* 127: Juno B88 Owgan */ "v1w4a1,,0,1Zv0w20c2L1G4Zv2w1c3L1Zv3w3c4L1Zv4w1c5L1Zv5w5L1Zv1f2.3A5,1.0,10000,0Zv2a1,,0,0f220,1,,,,0,1d0.677,,,,,0m0Zv3a1,,0,0f220,1,,,,0,1m0Zv4a0.441,,0,0f110,1,,,,0,1m0Zv5a0,,0,0Zv0F258.65,1,,2.772,0,0R4.381Zv0a0.795,,1,1,0A6,1,1355,0.433,0,0Zx7,-3,-3k0Z", /* 128: DX7 BRASS 1 */ "v2a0.458502,0,0,1,0,0P0.25A0,0.000188,97,0.917004,0,0.917004,530,0.5,70,0.000188L1I1Zv3a1.834008,0,0,1,0,0P0.25A0,0.000188,4,1,30,0.917004,0,0.917004,53,0.000188L1I1.00125Zv4a2,0,0,1,0,0P0.25A0,0.000188,4,1,30,0.917004,0,0.917004,53,0.000188L1I1Zv5a2,0,0,1,0,0P0.25A0,0.000188,4,1,0,0.917004,0,0.917004,53,0.000188L1I0.9975Zv6a0.64842,0,0,1,0,0P0.25A0,0.000188,11,0.229251,26,0.707107,37,0.771105,52,0.000188L1I0.504375Zv7a1.834008,0,0,1,0,0P0.25A0,0.000188,7,1,3,0.385553,0,0.771105,52,0.000188L1I0.504375Zv1w0a1f6.166667P0.25Zv0w8a1,0,1,0,0,0f0,1,0,1,0,0.007298b0.16A0,1,0,1,0,1,0,1,731,1L1O2,3,4,5,6,7o22Z", /* 129: DX7 BRASS 2 */ "v2a0.385553,0,0,1,0,0P0.25A0,0.000188,0,1,21,0.917004,484,0.385553,48,0.000188L1I0.5Zv3a2,0,0,1,0,0P0.25A0,0.000188,0,1,21,0.917004,822,0.210224,44,0.000188L1I0.500625Zv4a2,0,0,1,0,0P0.25A0,0.000188,0,1,21,0.917004,822,0.210224,44,0.000188L1I0.49875Zv5a2,0,0,1,0,0P0.25A0,0.000188,0,1,21,0.917004,822,0.210224,44,0.000188L1I0.498125Zv6a0.545254,0,0,1,0,0P0.25A0,0.000188,0,1,21,0.917004,871,0.192776,43,0.000188L1I0.504375Zv7a2,0,0,1,0,0P0.25A0,0.000188,0,1,21,0.917004,871,0.192776,43,0.000188L1I0.504375Zv1w0a1f6.166667P0.25Zv0w8a1,0,1,0,0,0f0,1,0,1,0,0b0.16A0,1,0,1,0,1,0,1,731,1L1O2,3,4,5,6,7o22Z", /* 130: DX7 BRASS 3 */ "v2a0.353553,0,0,1,0,0P0.25A0,0.000188,4,1,306,0.000188,0,0.000188,36,0.000188L1I8.47Zv3a0.162105,0,0,1,0,0P0.25A0,0.000188,109,0.917004,128,0.037163,24,0.040526,383,0.000188L1I3.17625Zv4a0.353553,0,0,1,0,0P0.25A0,0.000188,2,0.018581,0,0.037163,24,0.040526,383,0.000188L1I1Zv5a0.297302,0,0,1,0,0P0.25A0,0.000188,144,1,448,0.32421,0,0.32421,531,0.000188L1I1Zv6a0.162105,0,0,1,0,0P0.25A0,0.000188,231,0.297302,3282,0.000188,0,0.000188,36,0.000188L1I1Zv7a2,0,0,1,0,0P0.25A0,0.000188,51,1,1529,0.32421,0,0.32421,298,0.000188L1I1Zv1w4a1f5.833333P0.25Zv0w8a1,0,1,0,0,0f0,1,0,1,0,0.007298b0.08A0,1,0,1,0,1,0,1,731,1L1O2,3,4,5,6,7o18Z", /* 131: DX7 STRINGS 1 */ "v2a0.037163,0,0,1,0,0P0.25A0,0.000188,64,1,1402,0.545254,1083,0.32421,335,0.000188L1I14Zv3a0.545254,0,0,1,0,0P0.25A0,0.000188,37,0.32421,491,0.545254,1083,0.32421,335,0.000188L1I3Zv4a0.297302,0,0,1,0,0P0.25A0,0.000188,0,1,1402,0.545254,1083,0.32421,335,0.000188L1I1Zv5a0.64842,0,0,1,0,0P0.25A0,0.000188,182,1,153,0.297302,541,0.229251,319,0.000188L1I1Zv6a0.5,0,0,1,0,0P0.25A0,0.000188,2,0.229251,1,0.545254,7382,0.040526,430,0.000188L1I1Zv7a2,0,0,1,0,0P0.25A0,0.000188,162,1,1647,0.297302,2707,0.081052,1217,0.000188L1I1Zv1w4a1f5P0.25Zv0w8a1,0,1,0,0,0f0,1,0,1,0,0.006869b0.16A0,1,0,1,0,1,0,1,731,1L1O2,3,4,5,6,7o2Z", /* 132: DX7 STRINGS 2 */ "v2a0.162105,0,0,1,0,0P0.25A0,0.000188,7,1,2,0.545254,44073,0.000188,2904,0.000188L1I8Zv3a0.114626,0,0,1,0,0P0.25A0,0.000188,4,1,3,0.545254,44073,0.000188,4545,0.000188L1I2Zv4a0.272627,0,0,1,0,0P0.25A0,0.000188,97,0.917004,0,0.917004,29702,0.00426,1742,0.000188L1I2Zv5a1.090508,0,0,1,0,0P0.25A0,0.000188,81,1,2103,0.545254,44073,0.000188,523,0.000188L1I2.015Zv6a0.229251,0,0,1,0,0P0.25A0,0.000188,2,1,2550,0.545254,39446,0.00213,2953,0.000188L1I1.985Zv7a1.090508,0,0,1,0,0P0.25A0,0.000188,109,0.917004,0,0.917004,29702,0.00426,314,0.000188L1I2Zv1w0a1f5P0.25Zv0w8a1,0,1,0,0,0f0,1,0,1,0,0.006869b0.16A0,1,0,1,0,1,0,1,731,1L1O2,3,4,5,6,7o2Z", /* 133: DX7 STRINGS 3 */ "v2a0.040526,0,0,1,0,0P0.25A0,0.000188,64,1,8,0.545254,443,0.024097,218,0.000188L1I14Zv3a0.545254,0,0,1,0,0P0.25A0,0.000188,37,0.32421,1,0.545254,440,0.114626,288,0.000188L1I3Zv4a0.25,0,0,1,0,0P0.25A0,0.000188,0,1,1402,0.545254,541,0.420448,346,0.000188L1I1Zv5a2,0,0,1,0,0P0.25A0,0.000188,91,1,34,0.545254,34,0.5,1582,0.000188L1I1Zv6a0.64842,0,0,1,0,0P0.25A0,0.000188,0,0.229251,1,0.545254,172,0.353553,479,0.000188L1I1Zv7a2,0,0,1,0,0P0.25A0,0.000188,72,1,424,0.545254,210,0.458502,1244,0.000188L1I1Zv1w0a1f4.666667P0.25Zv0w8a1,0,1,0,0,0f0,1,0,1,0,0.015152b0.16A0,1,0,1,0,1,0,1,731,1L1O2,3,4,5,6,7o15Z", /* 134: DX7 ORCHESTRA */ "v2a0.458502,0,0,1,0,0P0.25A0,0.000188,7,1,2,0.545254,44073,0.000188,2904,0.000188L1I2Zv3a0.385553,0,0,1,0,0P0.25A0,0.000188,4,1,3,0.545254,44073,0.000188,208,0.000188L1I2Zv4a0.192776,0,0,1,0,0P0.25A0,0.000188,43,0.917004,0,0.917004,29702,0.00426,395,0.000188L1I2Zv5a1.542211,0,0,1,0,0P0.25A0,0.000188,57,1,2103,0.545254,44073,0.000188,523,0.000188L1I2.015Zv6a0.5,0,0,1,0,0P0.25A0,0.000188,64,1,58,0.594604,145,0.458502,156,0.000188L1I0.9925Zv7a2,0,0,1,0,0P0.25A0,0.000188,2,0.917004,0,0.917004,29702,0.00426,395,0.000188L1I1Zv1w0a1f5P0.25Zv0w8a1,0,1,0,0,0f0,1,0,1,0,0.008758b0.16A0,1,0,1,0,1,0,1,731,1L1O2,3,4,5,6,7o2Z", /* 135: DX7 PIANO 1 */ "v2a0.458502,0,0,1,0,0P0.25A0,0.000188,0,1,24000,0.125,7911,0.000188,60000,0.000188L1I0.99875Zv3a1.189207,0,0,1,0,0P0.25A0,0.000188,2,1,208,0.000633,430,0.000188,1311,0.000188L1I1.57875Zv4a2,0,0,1,0,0P0.25A0,0.000188,2,1,2753,0.162105,11387,0.000188,659,0.000188L1I1.00125Zv5a0.052556,0,0,1,0,0P0.25A0,0.000188,2,1,0,1,0,1,32783,0.000188L1I3Zv6a0.707107,0,0,1,0,0P0.25A0,0.000188,0,1,24000,0.125,7911,0.000188,60000,0.000188L1I1.0025Zv7a2,0,0,1,0,0P0.25A0,0.000188,2,1,1793,0.229251,14802,0.000188,466,0.000188L1I0.9975Zv1w4a1f5.833333P0.25Zv0w8a1,0,1,0,0,0f0,1,0,1,0,0b0.08A0,1,0,1,0,1,0,1,731,1L1O2,3,4,5,6,7o19Z", /* 136: DX7 PIANO 2 */ "v2a0.32421,0,0,1,0,0P0.25A0,0.000188,0,1,54,0.000188,0,0.000188,1846,0.000188L1I0.500625Zv3a1.29684,0,0,1,0,0P0.25A0,0.000188,0,1,54,0.000188,0,0.000188,3250,0.000188L1I0.5Zv4a0.545254,0,0,1,0,0P0.25A0,0.000188,0,1,1100,0.32421,18204,0.012049,5063,0.000188L1I0.99875Zv5a0.5,0,0,1,0,0P0.25A0,0.000188,0,1,1185,0.297302,15343,0.000188,370,0.000188L1I5.00625Zv6a0.64842,0,0,1,0,0P0.25A0,0.000188,0,1,24000,0.125,7911,0.000188,60000,0.000188L1I1.0025Zv7a1.29684,0,0,1,0,0P0.25A0,0.000188,2,1,4352,0.040526,29702,0.000188,370,0.000188L1I1Zv1w4a1f5P0.25Zv0w8a1,0,1,0,0,0f0,1,0,1,0,0b0.04A0,1,0,1,0,1,0,1,731,1L1O2,3,4,5,6,7o18Z", /* 137: DX7 PIANO 3 */ "v2a0.545254,0,0,1,0,0P0.25A0,0.000188,2,1,34,0.000977,5708,0.000188,28743,0.000188L1I0.50125Zv3a0.707107,0,0,1,0,0P0.25A0,0.000188,0,0.5,180,0.458502,60000,0.000188,53099,0.000188L1I0.9975Zv4a1.414214,0,0,1,0,0P0.25A0,0.000188,0,1,2,0.840896,7348,0.000188,659,0.000188L1I1.00375Zv5a1.681793,0,0,1,0,0P0.25A0,0.000188,0,0.25,3,0.0625,13427,0.000188,24000,0.000188L1I6.97375Zv6a0.594604,0,0,1,0,0P0.25A0,0.000188,0,0.5,30,0.458502,60000,0.000188,2904,0.000188L1I1.005Zv7a0.64842,0,0,1,0,0P0.25A0,0.000188,0,1,242,0.707107,7197,0.000188,659,0.000188L1I0.995Zv1w4a1f7.5P0.25Zv0w8a1,0,1,0,0,0f0,1,0,1,0,0b0.02A0,1,0,1,0,1,0,1,12000,1L1O2,3,4,5,6,7o3Z", /* 138: DX7 E.PIANO 1 */ "v2a0.353553,0,0,1,0,0P0.25A0,0.000188,0,1,271,0.707107,17148,0.000188,370,0.000188L1I1.00875Zv3a2,0,0,1,0,0P0.25A0,0.000188,0,1,722,0.707107,17148,0.000188,370,0.000188L1I0.99125Zv4a0.840896,0,0,1,0,0P0.25A0,0.000188,0,1,271,0.707107,17148,0.000188,370,0.000188L1I1Zv5a2,0,0,1,0,0P0.25A0,0.000188,0,1,722,0.707107,17148,0.000188,370,0.000188L1I1Zv6a0.057313,0,0,1,0,0P0.25A0,0.000188,0,1,148,0.125,2585,0.000188,14,0.000188L1I14Zv7a2,0,0,1,0,0P0.25A0,0.000188,0,1,2531,0.125,7911,0.000188,52,0.000188L1I1.00375Zv1w0a1f5.666667P0.25Zv0w8a1,0,1,0,0,0f0,1,0,1,0,0b0.08A0,1,0,1,0,1,0,1,731,1L1O2,3,4,5,6,7o5Z", /* 139: DX7 GUITAR 1 */ "v2a0.052556,0,0,1,0,0.000244P0.25A0,0.000188,0,1,273,0.000188,0,0.000188,20,0.000188L1I12Zv3a2,0,0,1,0,0P0.25A0,0.000188,2,1,0,0.545254,13431,0.000188,20,0.000188L1I3Zv4a0.840896,0,0,1,0,0P0.25A0,0.000188,2,1,0,0.545254,13431,0.000188,20,0.000188L1I3Zv5a2,0,0,1,0,0P0.25A0,0.000188,3,1,0,0.545254,13431,0.000188,20,0.000188L1I1Zv6a1.189207,0,0,1,0,0P0.25A0,0.000188,0,1,1371,0.32421,1879,0.000188,117,0.000188L1I3Zv7a2,0,0,1,0,0P0.25A0,0.000188,5,1,0,0.707107,8041,0.000188,36,0.000188L1I1Zv1w0a1f5.833333P0.25Zv0w8a1,0,1,0,0,0f0,1,0,1,0,0.00146b0.16A0,1,0,1,0,1,0,1,731,1L1O2,3,4,5,6,7o8Z", /* 140: DX7 GUITAR 2 */ "v2a0.210224,0,0,1,0,0P0.25A0,0.000188,0,1,36,0.771105,19788,0.125,41,0.000188L1I3Zv3a0.594604,0,0,1,0,0P0.25A0,0.000188,0,1,0,1,9200,0.136313,76000,0.000188L1I0.5Zv4a0.162105,0,0,1,0,0P0.25A0,0.000188,0,1,0,0.771105,6309,0.125,41,0.000188L1I0.5Zv5a2,0,0,1,0,0P0.25A0,0.000188,0,1,0,1,0,1,54,0.000188L1I1.5Zv6a0.707107,0,0,1,0,0P0.25A0,1,0,1,0,1,0,1,930,1L1I1Zv7a0.64842,0,0,1,0,0P0.25A0,0.000188,0,1,0,1,0,1,54,0.000188L1I3Zv1w4a1f5.833333P0.25Zv0w8a1,0,1,0,0,0f0,1,0,1,0,0b0.16A0,1,0,1,0,1,0,1,731,1L1O2,3,4,5,6,7o16Z", /* 141: DX7 SYN-LEAD 1 */ "v2a0.022097,0,0,1,0,0P0.25A0,0.000188,0,1,0,1,3,0.840896,97000,0.000188L1I17Zv3a0.015625,0,0,1,0,0P0.25A0,0.000188,0,1,0,0.052556,0,0.034078,60000,0.000188L1I2.9925Zv4a0.176777,0,0,1,0,0P0.25A0,0.000188,0,1,0,0.458502,6818,0.000188,117,0.000188L1I2.005Zv5a0.458502,0,0,1,0,0P0.25A0,0.000188,0,0.594604,0,0.458502,90000,0.000188,60000,0.000188L1I1Zv6a0.176777,0,0,1,0,0P0.25A0,0.000188,0,1,0,0.771105,7000,0.420448,89000,0.000188L1I0.99875Zv7a2,0,0,1,0,0P0.25A0,0.000188,0,1,4000,0.707107,0,0.707107,58,0.000188L1I1.00125Zv1w0a1f6.166667P0.25Zv0w8a1,0,1,0,0,0f0,1,0,1,0,0b0.16A0,1,0,1,0,1,0,1,12000,1L1O2,3,4,5,6,7o18Z", /* 142: DX7 BASS 1 */ "v2a0.594604,0,0,1,0,0P0.25A0,0.000188,0,0.594604,201,0.00213,3294,0.000188,208,0.000188L1I9Zv3a0.081052,0,0,1,0,0P0.25A0,0.000188,0,1,99000,0.000188,0,0.000188,60000,0.000188L1I0.5Zv4a1.189207,0,0,1,0,0P0.25A0,0.000188,0,0.458502,930,0.002533,18490,0.000188,208,0.000188L1I5Zv5a2,0,0,1,0,0P0.25A0,0.000188,0,0.176777,0,0.052556,3146,0.000188,3636,0.000188L1I0.5Zv6a0.385553,0,0,1,0,0P0.25A0,0.000188,0,1,17871,0.000188,0,0.000188,60000,0.000188L1I0.5Zv7a2,0,0,1,0,0P0.25A0,0.000188,0,1,6,0.707107,15503,0.003012,78,0.000188L1I0.5Zv1w4a1f5.833333P0.25Zv0w8a1,0,1,0,0,0f0,1,0,1,0,0b0.16A0,1,0,1,0,1,0,1,731,1L1O2,3,4,5,6,7o16Z", /* 143: DX7 BASS 2 */ "v2a0.707107,0,0,1,0,0P0.25A0,0.000188,1424,0.771105,3,0.840896,11411,0.000188,208,0.000188L1I0.500625Zv3a0.25,0,0,1,0,0P0.25A0,0.000188,0,1,137,0.114626,74000,0.000188,60000,0.000188L1I1.01Zv4a2,0,0,1,0,0P0.25A0,0.000188,2,0.594604,786,0.026278,4318,0.000188,262,0.000188L1I0.5Zv5a0.136313,0,0,1,0,0P0.25A0,0.000188,5,0.840896,2004,0.162105,3775,0.000188,3636,0.000188L1I1.00875Zv6a0.385553,0,0,1,0,0P0.25A0,0.000188,1157,1,2718,0.000188,0,0.000188,370,0.000188L1I0.515Zv7a2,0,0,1,0,0P0.25A0,0.000188,5,1,796,0.081052,15555,0.000188,82,0.000188L1I0.505Zv1w0a1f5.166667P0.25Zv0w8a1,0,1,0,0,0f0,1,0,1,0,0b0.16A0,1,0,1,0,1,0,1,731,1L1O2,3,4,5,6,7o17Z", /* 144: DX7 E.ORGAN 1 */ "v2a1.29684,0,0,1,0,0P0.25A0,0.000188,0,1,385,0.000188,0,0.000188,3,0.000188L1I3Zv3a1.29684,0,0,1,0,0P0.25A0,0.000188,0,1,0,1,0,1,6,0.000188L1I1.0025Zv4a1.29684,0,0,1,0,0P0.25A0,0.000188,0,1,0,1,0,1,6,0.000188L1I0.503125Zv5a1.29684,0,0,1,0,0P0.25A0,0.000188,0,1,0,1,0,1,15,0.000188L1I1.505Zv6a1.29684,0,0,1,0,0P0.25A0,0.000188,0,1,0,1,291,0.840896,5,0.000188L1I1.0025Zv7a1.29684,0,0,1,0,0P0.25A0,0.000188,0,1,0,1,0,1,6,0.000188L1I0.49875Zv1w4a1f5.833333P0.25Zv0w8a1,0,1,0,0,0f0,1,0,1,0,0b0.00125A0,1,0,1,0,1,0,1,731,1L1O2,3,4,5,6,7o32Z", /* 145: DX7 PIPES 1 */ "v2a0.272627,0,0,1,0,0P0.25A0,0.000188,7,1,0,1,0,1,60,0.000188L1I10Zv3a1.681793,0,0,1,0,0P0.25A0,0.000188,25,1,0,1,632,0.594604,161,0.000188L1I2Zv4a0.771105,0,0,1,0,0P0.25A0,0.000188,25,1,0,1,210,0.840896,599,0.000188L1I4Zv5a0.25,0,0,1,0,0P0.25A0,0.000188,0,1,0,1,13,0.458502,785,0.000188L1I1Zv6a0.917004,0,0,1,0,0P0.25A0,0.000188,0,1,0,1,13,0.458502,785,0.000188L1I0.5Zv7a2,0,0,1,0,0P0.25A0,0.000188,162,1,0,1,105,0.917004,3015,0.000188L1I0.5Zv1w0a1f5.666667P0.25Zv0w8a1,0,1,0,0,0f0,1,0,1,0,0b0.16A0,1,0,1,0,1,0,1,731,1L1O2,3,4,5,6,7o19Z", /* 146: DX7 HARPSICH 1 */ "v2a0.707107,0,0,1,0,0P0.25A0,0.917004,0,1,0,0.840896,3,0.5,0,0.917004L1I6Zv3a0.5,0,0,1,0,0P0.25A0,0.000188,0,1,681,0.458502,7618,0.000188,523,0.000188L1I3.995Zv4a2,0,0,1,0,0P0.25A0,0.917004,0,1,0,0.840896,3,0.5,0,0.917004L1I3Zv5a0.594604,0,0,1,0,0P0.25A0,0.000188,0,1,681,0.458502,7618,0.000188,523,0.000188L1I0.99875Zv6a2,0,0,1,0,0P0.25A0,0.917004,0,1,0,0.840896,3,0.5,0,0.917004L1I0.5Zv7a0.840896,0,0,1,0,0P0.25A0,0.000188,0,1,681,0.458502,7618,0.000188,523,0.000188L1I4Zv1w4a1f5.833333P0.25Zv0w8a1,0,1,0,0,0f0,1,0,1,0,0b0.0025A0,1,0,1,0,1,0,1,12000,1L1O2,3,4,5,6,7o5Z", /* 147: DX7 CLAV 1 */ "v2a0.32421,0,0,1,0,0P0.25A0,0.000188,0,0.353553,0,0.32421,86000,0.000188,60000,0.000188L1I8Zv3a2,0,0,1,0,0P0.25A0,0.000188,0,1,0,0.771105,7000,0.420448,89000,0.000188L1I0.49875Zv4a2,0,0,1,0,0P0.25A0,0.000188,0,1,0,0.458502,6818,0.000188,117,0.000188L1I2Zv5a0.176777,0,0,1,0,0P0.25A0,0.000188,0,0.353553,0,0.32421,86000,0.000188,60000,0.000188L1I6Zv6a2,0,0,1,0,0P0.25A0,0.000188,0,1,0,0.771105,7000,0.420448,89000,0.000188L1I0.499375Zv7a2,0,0,1,0,0P0.25A0,0.000188,0,1,0,0.458502,6818,0.000188,117,0.000188L1I0.500625Zv1w0a1f5P0.25Zv0w8a1,0,1,0,0,0f0,1,0,1,0,0b0.04A0,1,0,1,0,1,0,1,12000,1L1O2,3,4,5,6,7o3Z", /* 148: DX7 VIBE 1 */ "v2a0.052556,0,0,1,0,0P0.25A0,0.000188,0,1,521,0.003012,0,0.000188,370,0.000188L1I14Zv3a2,0,0,1,0,0P0.25A0,0.000188,2,1,0,0.458502,5647,0.007164,259,0.000188L1I1.00875Zv4a2,0,0,1,0,0P0.25A0,0.000188,2,1,0,0.458502,10588,0.000188,370,0.000188L1I0.99125Zv5a0.192776,0,0,1,0,0P0.25A0,0.000188,2,1,2,0.114626,1022,0.000188,370,0.000188L1I3Zv6a2,0,0,1,0,0P0.25A0,0.000188,2,1,0,0.458502,10588,0.000188,370,0.000188L1I1Zv7a0.028656,0,0,1,0,0P0.25A0,0.000188,0,1,5606,0.001642,0,0.000188,370,0.000188L1I4Zv1w4a1f4.333333P0.25Zv0w8a1,0,1,0,0,0f0,1,0,1,0,0b0.04A0,1,0,1,0,1,0,1,731,1L1O2,3,4,5,6,7o23Z", /* 149: DX7 MARIMBA */ "v2a2,0,0,1,0,0P0.25A0,0.000188,12896,0.162105,0,0.162105,270,0.000188,60000,0.000188L1I4.52Zv3a1.189207,0,0,1,0,0P0.25A0,0.000188,0,0.229251,11,0.012049,48000,0.000188,34092,0.000188L1I0.75Zv4a0.594604,0,0,1,0,0P0.25A0,0.000188,0,0.229251,11,0.012049,48000,0.000188,9,0.000188L1I5Zv5a2,0,0,1,0,0P0.25A0,0.000188,0,1,302,0.545254,638,0.000188,1043,0.000188L1I0.5Zv6a1.542211,0,0,1,0,0P0.25A0,0.000188,0,0.229251,16,0.012049,48000,0.000188,60000,0.000188L1I3Zv7a1.414214,0,0,1,0,0P0.25A0,0.000188,0,1,136,0.545254,638,0.000188,208,0.000188L1I0.5Zv1w4a1f5.833333P0.25Zv0w8a1,0,1,0,0,0f0,1,0,1,0,0b0.00125A0,1,0,1,0,1,0,1,731,1L1O2,3,4,5,6,7o7Z", /* 150: DX7 KOTO */ "v2a0.420448,0,0,1,0,0P0.25A0,0.000188,2,1,78,0.210224,2224,0.000188,466,0.000188L1I3Zv3a0.5,0,0,1,0,0P0.25A0,0.000188,0,1,247,0.458502,6099,0.000188,4066,0.000188L1I4Zv4a0.458502,0,0,1,0,0P0.25A0,0.000188,0,1,1742,0.136313,18702,0.000188,1311,0.000188L1I1Zv5a2,0,0,1,0,0P0.25A0,0.000188,0,1,8,0.545254,5575,0.000188,2594,0.000188L1I1Zv6a2,0,0,1,0,0P0.25A0,0.000188,0,1,12,0.25,6288,0.000188,466,0.000188L1I4Zv7a0.917004,0,0,1,0,0P0.25A0,0.000188,0,1,10,0.545254,226,0.000188,2316,0.000188L1I1Zv1w0a1f5P0.25Zv0w8a1,0,1,0,0,0f0,1,0,1,0,0.014596b0.16A0,1,4,0.978572,2,1,0,1,12000,1L1O2,3,4,5,6,7o2Z", /* 151: DX7 FLUTE 1 */ "v2a0.5,0,0,1,0,0P0.25A0,0.000188,0,1,39,0.0625,0,0.017039,90,0.000188L1I1.535Zv3a0.048194,0,0,1,0,0P0.25A0,0.000188,16,1,2425,0.000188,0,0.000188,104,0.000188L1I2Zv4a0.000377,0,0,1,0,0P0.25A0,0.000188,25,1,0,1,210,0.840896,189,0.000188L1I2Zv5a0.272627,0,0,1,0,0.000581P0.25A0,0.000188,40,0.385553,1077,0.00852,6,0.001506,41,0.000188L1I0.99625Zv6a0.25,0,0,1,0,0P0.25A0,0.000188,0,1,0,1,13,0.458502,350,0.000188L1I1.005Zv7a1.834008,0,0,1,0,0P0.25A0,0.000188,19,0.594604,3,0.420448,2,0.917004,107,0.000188L1I0.9975Zv1w4a1f5P0.25Zv0w8a1,0,1,0,0,0f0,1,0,1,0,0.00404b0.04A0,1,0,1,0,1,0,1,731,1L1O2,3,4,5,6,7o16Z", /* 152: DX7 ORCH-CHIME */ "v2a0.25,0,0,1,0,0P0.25A0,0.000188,0,1,0,1,0,1,99000,0.000188L1I0.99125Zv3a1.834008,0,0,1,0,0P0.25A0,0.000188,257,1,0,1,0,1,3822,0.000188L1I1.00875Zv4a1,0,0,1,0,0P0.25A0,0.000188,1,0.385553,4,0.192776,41792,0.000188,24000,0.000188L1I3.14Zv5a2,0,0,1,0,0P0.25A0,0.000188,2,1,27,0.707107,23378,0.000188,3636,0.000188L1I0.5Zv6a0.707107,0,0,1,0,0P0.25A0,0.000188,0,1,0,1,0,1,99000,0.000188L1I0.503125Zv7a1.681793,0,0,1,0,0P0.25A0,0.000188,578,1,0,1,0,1,3822,0.000188L1I0.503125Zv1w4a1f5P0.25Zv0w8a1,0,1,0,0,0f0,1,0,1,0,0.007298b0.16A0,1,0,1,0,1,0,1,179,1L1O2,3,4,5,6,7o5Z", /* 153: DX7 TUB BELLS */ "v2a0.594604,0,0,1,0,0P0.25A0,0.000188,0,1,5,0.000188,0,0.000188,4545,0.000188L1I1.9825Zv3a2,0,0,1,0,0f323.593657P0.25A0,0.000188,4,1,24,0.000188,0,0.000188,36,0.000188L1Zv4a0.25,0,0,1,0,0P0.25A0,0.000188,0,1,39600,0.000188,0,0.003012,2424,0.000188L1I3.495Zv5a2,0,0,1,0,0P0.25A0,0.000188,0,1,4280,0.000188,0,0.003012,3375,0.000188L1I0.99375Zv6a0.32421,0,0,1,0,0P0.25A0,0.000188,0,1,39600,0.000188,0,0.003012,2424,0.000188L1I3.5075Zv7a1.414214,0,0,1,0,0P0.25A0,0.000188,0,1,4280,0.000188,0,0.003012,3375,0.000188L1I1.0025Zv1w2a1f5.833333P0.25Zv0w8a1,0,1,0,0,0f0,1,0,1,0,0b0.16A0,1,0,1,0,1,0,1,731,1L1O2,3,4,5,6,7o5Z", /* 154: DX7 STEEL DRUM */ "v2a0.026278,0,0,1,0,0f398.107171P0.25A0,0.000188,0,0.5,62,0.229251,6212,0.000188,24000,0.000188L1Zv3a0.096388,0,0,1,0,0P0.25A0,0.000188,0,0.5,175,0.229251,2008,0.000188,60000,0.000188L1I5.32Zv4a0.771105,0,0,1,0,0P0.25A0,0.000188,0,0.5,110,0.229251,506,0.000188,9745,0.000188L1I2.0175Zv5a2,0,0,1,0,0P0.25A0,0.000188,0,1,424,0.545254,3171,0.000188,930,0.000188L1I1Zv6a0.096388,0,0,1,0,0P0.25A0,0.000188,0,1,2404,0.353553,15704,0.000188,31344,0.000188L1I1.7Zv7a2,0,0,1,0,0P0.25A0,0.000188,0,1,136,0.545254,3977,0.000188,1469,0.000188L1I1Zv1w0a1f4.166667P0.25Zv0w8a1,0,1,0,0,0f0,1,0,1,0,0.008586b0.04A0,1,0,1,0,1,0,1,1067,1L1O2,3,4,5,6,7o15Z", /* 155: DX7 TIMPANI */ "v2a0.210224,0,0,1,0,0P0.25A0,0.000188,0,0.917004,86728,0.000188,0,0.000188,5078,0.000188L1I0.78Zv3a0.210224,0,0,1,0,0P0.25A0,0.000188,0,1,611,0.000188,0,0.000188,12024,0.000188L1I0.5Zv4a0.707107,0,0,1,0,0P0.25A0,0.000188,0,1,1300,0.125,18456,0.000188,3636,0.000188L1I0.875Zv5a0.594604,0,0,1,0,0P0.25A0,0.000188,0,1,7,0.096388,6805,0.000188,7866,0.000188L1I0.678125Zv6a0.64842,0,0,1,0,0P0.25A0,0.000188,0,1,38,0.000188,0,0.000188,60000,0.000188L1I0.501875Zv7a2,0,0,1,0,0P0.25A0,0.000188,0,1,3046,0.000188,0,0.000188,2594,0.000188L1I0.5Zv1w4a1f1.833333P0.25Zv0w8a1,0,1,0,0,0f0,1,0,1,0,0.013737b0.16A0,1,0,1,3,1.021897,7,1,731,1L1O2,3,4,5,6,7o16Z", /* 156: DX7 REFS WHISL */ "v2a0.32421,0,0,1,0,0f10P0.25A0,0.000188,0,0.771105,55,0.162105,9176,0.000188,208,0.000188L1Zv3a0.096388,0,0,1,0,0f1P0.25A0,0.000188,0,1,99000,0.000188,0,0.000188,60000,0.000188L1Zv4a0.25,0,0,1,0,0f6606.93448P0.25A0,0.000188,0,0.771105,5,0.420448,10470,0.000188,208,0.000188L1Zv5a0.114626,0,0,1,0,0f46.773514P0.25A0,0.000188,28,1,0,1,0,1,99000,0.000188L1Zv6a1.189207,0,0,1,0,0f33.884416P0.25A0,0.000188,28,1,0,1,0,1,1087,0.000188L1Zv7a0.917004,0,0,1,0,0f2089.296131P0.25A0,0.000188,28,1,0,1,0,1,686,0.000188L1Zv1w5a1f50.29P0.25Zv0w8a1,0,1,0,0,0f0,1,0,1,0,0b0.005A0,1,313,0.78799,103,1,0,1,731,1L1O2,3,4,5,6,7o18Z", /* 157: DX7 VOICE 1 */ "v2a0.044194,0,0,1,0,0P0.25A0,0.000188,0,1,0,1,0,1,24362,0.000188L1I5.10625Zv3a0.037163,0,0,1,0,0P0.25A0,0.000188,515,1,1461,0.458502,153,0.297302,117,0.000188L1I1.00875Zv4a2,0,0,1,0,0P0.25A0,0.000411,0,0.012049,291,0.028656,660,0.001065,4400,0.000411L1I1.02375Zv5a2,0,0,1,0,0P0.25A0,0.000188,649,1,902,0.64842,7,0.840896,2119,0.000188L1I1.00875Zv6a2,0,0,1,0,0.000224P0.25A0,0.015625,0,0.015625,137,0.037163,11,0.136313,2637,0.015625L1I1Zv7a0.707107,0,0,1,0,0P0.25A0,0.000188,578,1,902,0.64842,7,0.840896,267,0.000188L1I0.99125Zv1w4a1f5.833333P0.25Zv0w8a1,0,1,0,0,0f0,1,0,1,0,0.027294b0.16A0,1,137,0.957603,36,1.021897,3,1,731,1L1O2,3,4,5,6,7o7Z", /* 158: DX7 TRAIN */ "v2a2,0,0,1,0,0P0.25A0,0.917004,4,1,0,1,0,1,4,0.917004L1I5Zv3a0.5,0,0,1,0,1P0.25A0,1,0,1,0,1,0,1,262,1L1I9.03375Zv4a0.840896,0,0,1,0,0f971.627952P0.25A0,0.000188,0,1,6709,0.000188,0,0.000188,5078,0.000188L1Zv5a2,0,0,1,0,0f373.680125P0.25A0,0.000188,0,1,6709,0.000188,0,0.000188,2594,0.000188L1Zv6a0.192776,0,0,1,0,0P0.25A0,0.000188,324,1,13843,0.037163,401,0.057313,32,0.000188L1I3.03Zv7a2,0,0,1,0,0P0.25A0,0.000188,16,1,1647,0.297302,0,0.297302,234,0.000188L1I1.64Zv1w4a1f6.5P0.25Zv0w8a1,0,1,0,0,0f0,1,0,1,0,0b0.16A0,1,0,1,0,1,0,1,731,1L1O2,3,4,5,6,7o5Z", /* 159: DX7 TAKE OFF */ "v2a2,0,0,1,0,0P0.25A0,0.000188,1,1,1021,0.545254,16607,0.000188,1043,0.000188L1I0.5Zv3a1.542211,0,0,1,0,0P0.25A0,0.000188,1,1,1058,0.458502,11799,0.000188,1647,0.000188L1I2.02Zv4a2,0,0,1,0,0P0.25A0,0.000188,6550,1,1324,0.707107,487,1,6000,0.000188L1I0.5Zv5a2,0,0,1,0,0P0.25A0,0.000188,1,0.0625,999,0.005066,0,0.105112,31992,0.000188L1I6.06Zv6a1.542211,0,0,1,0,0P0.25A0,0.000188,1,0.192776,1,0.707107,19038,0.000188,19868,0.000188L1I1Zv7a2,0,0,1,0,0P0.25A0,0.000188,2303,0.037163,3783,0.771105,23624,0.000188,2316,0.000188L1I4.04Zv1w3a1f11.666667P0.25Zv0w8a1,0,1,0,0,0f0,1,0,1,0,0b0.00125A0,15.657153,1791,1,1712,0.231848,264,1.957144,1368,15.657153L1O2,3,4,5,6,7o10Z", /* 160: DX7 PIANO 4 */ "v2a0.32421,0,0,1,0,0P0.25A0,0.000188,0,1,54,0.000188,0,0.000188,1846,0.000188L1I0.500625Zv3a2,0,0,1,0,0P0.25A0,0.000188,0,1,54,0.000188,0,0.000188,3250,0.000188L1I0.5Zv4a0.192776,0,0,1,0,0P0.25A0,0.000188,0,1,1100,0.32421,18204,0.012049,5063,0.000188L1I0.99875Zv5a0.385553,0,0,1,0,0P0.25A0,0.000188,0,1,1185,0.297302,15343,0.000188,370,0.000188L1I4.005Zv6a0.64842,0,0,1,0,0P0.25A0,0.000188,0,1,24000,0.125,7911,0.000188,60000,0.000188L1I1.0025Zv7a0.917004,0,0,1,0,0P0.25A0,0.000188,2,1,4352,0.040526,62000,0.000188,370,0.000188L1I1Zv1w4a1f5P0.25Zv0w8a1,0,1,0,0,0f0,1,0,1,0,0b0.04A0,1,0,1,0,1,0,1,731,1L1O2,3,4,5,6,7o18Z", /* 161: DX7 PIANO 5 */ "v2a0.125,0,0,1,0,0P0.25A0,0.000188,0,0.000266,0,0.000977,821,0.000188,24000,0.000188L1I5Zv3a0.25,0,0,1,0,0P0.25A0,0.000188,0,0.5,180,0.458502,60000,0.000188,53099,0.000188L1I1Zv4a2,0,0,1,0,0P0.25A0,0.000188,9,1,848,0.297302,11144,0.000188,370,0.000188L1I1Zv5a1.090508,0,0,1,0,0P0.25A0,0.000188,0,0.114626,8933,0.000977,821,0.000188,24000,0.000188L1I3Zv6a0.192776,0,0,1,0,0P0.25A0,0.000188,0,0.5,30,0.458502,60000,0.000188,2904,0.000188L1I1Zv7a2,0,0,1,0,0P0.25A0,0.000188,9,1,848,0.297302,11144,0.000188,370,0.000188L1I1Zv1w4a1f5P0.25Zv0w8a1,0,1,0,0,0f0,1,0,1,0,0b0.08A0,1,0,1,0,1,0,1,12000,1L1O2,3,4,5,6,7o3Z", /* 162: DX7 E.PIANO 2 */ "v2a0.64842,0,0,1,0,0P0.25A0,0.000188,0,1,0,1,99000,0.000188,6,0.000188L1I1Zv3a0.037163,0,0,1,0,0P0.25A0,0.000188,0,0.353553,783,0.022097,2123,0.000188,46,0.000188L1I11.0275Zv4a1.189207,0,0,1,0,0P0.25A0,0.000188,0,1,172,0.000188,0,0.000188,14,0.000188L1I0.505625Zv5a2,0,0,1,0,0P0.25A0,0.000188,2,1,5,0.458502,3102,0.000188,208,0.000188L1I1.00125Zv6a0.25,0,0,1,0,0P0.25A0,0.000188,1,1,0,0.594604,16787,0.000188,233,0.000188L1I1.00375Zv7a2,0,0,1,0,0P0.25A0,0.000188,0,1,0,0.594604,16787,0.000188,233,0.000188L1I0.99875Zv1w0a1f2.833333P0.25Zv0w8a1,0,1,0,0,0f0,1,0,1,0,0b0.16A0,1,0,1,0,1,0,1,731,1L1O2,3,4,5,6,7o12Z", /* 163: DX7 E.PIANO 3 */ "v2a0.25,0,0,1,0,0P0.25A0,0.000188,0,1,191,0.034078,6329,0.000188,233,0.000188L1I3Zv3a2,0,0,1,0,0P0.25A0,0.000188,0,1,0,0.707107,17148,0.000188,165,0.000188L1I1Zv4a0.006024,0,0,1,0,0P0.25A0,0.000188,0,1,13,0.210224,29509,0.000188,233,0.000188L1I14Zv5a2,0,0,1,0,0P0.25A0,0.000188,0,1,1029,0.192776,14441,0.000188,233,0.000188L1I1Zv6a0.229251,0,0,1,0,0P0.25A0,0.000188,0,1,24000,0.125,7911,0.000188,233,0.000188L1I2Zv7a1.834008,0,0,1,0,0P0.25A0,0.000188,0,1,1037,0.125,6348,0.000188,233,0.000188L1I1Zv1w4a1f5.666667P0.25Zv0w8a1,0,1,0,0,0f0,1,0,1,0,0b0.16A0,1,0,1,0,1,0,1,731,1L1O2,3,4,5,6,7o5Z", /* 164: DX7 E.PIANO 4 */ "v2a0.176777,0,0,1,0,0P0.25A0,0.000188,0,1,0,0.707107,17148,0.000188,20,0.000188L1I1Zv3a0.707107,0,0,1,0,0P0.25A0,0.000188,0,1,0,0.707107,6438,0.000188,165,0.000188L1I1Zv4a0.136313,0,0,1,0,0P0.25A0,0.000188,0,1,1,0.034078,310,0.006024,196,0.000188L1I14Zv5a2,0,0,1,0,0P0.25A0,0.000188,0,1,175,0.458502,6099,0.000188,20,0.000188L1I1Zv6a0.840896,0,0,1,0,0P0.25A0,1,0,1,0,0.125,7911,0.000188,11,1L1I1Zv7a2,0,0,1,0,0P0.25A0,0.000188,0,1,331,0.125,4062,0.000188,6,0.000188L1I1Zv1w4a1f5.666667P0.25Zv0w8a1,0,1,0,0,0f0,1,0,1,0,0b0.02A0,1,0,1,0,1,0,1,731,1L1O2,3,4,5,6,7o5Z", /* 165: DX7 PIANO 5THS */ "v2a0.057313,0,0,1,0,0P0.25A0,0.000188,0,1,949,0.458502,8507,0.000188,117,0.000188L1I1.50375Zv3a2,0,0,1,0,0P0.25A0,0.000188,0,1,949,0.458502,8507,0.000188,117,0.000188L1I1.4975Zv4a0.192776,0,0,1,0,0P0.25A0,0.000188,0,0.297302,3,0.081052,70000,0.000188,1311,0.000188L1I8Zv5a2,0,0,1,0,0P0.25A0,0.000188,0,1,1322,0.009291,4253,0.000188,117,0.000188L1I0.99125Zv6a0.458502,0,0,1,0,0P0.25A0,0.000188,0,1,13,0.545254,92000,0.000188,147,0.000188L1I1Zv7a2,0,0,1,0,0P0.25A0,0.000188,0,1,440,0.210224,7656,0.000188,117,0.000188L1I1.00875Zv1w4a1f8.333333P0.25Zv0w8a1,0,1,0,0,0f0,1,0,1,0,0.083283b0.01A0,1,0,1,0,1,0,1,12000,1L1O2,3,4,5,6,7o5Z", /* 166: DX7 CELESTE */ "v2a0.105112,0,0,1,0,0P0.25A0,0.000188,0,1,1151,0.192776,8439,0.000188,1169,0.000188L1I5Zv3a2,0,0,1,0,0P0.25A0,0.000188,0,1,2,0.192776,8439,0.000188,1169,0.000188L1I1Zv4a1.681793,0,0,1,0,0P0.25A0,0.000188,0,1,1151,0.192776,8439,0.000188,1169,0.000188L1I1Zv5a0.771105,0,0,1,0,0P0.25A0,0.000188,0,1,1151,0.192776,8439,0.000188,1169,0.000188L1I0.9925Zv6a0.64842,0,0,1,0,0P0.25A0,0.000188,0,1,1151,0.192776,8439,0.000188,1169,0.000188L1I1Zv7a2,0,0,1,0,0P0.25A0,0.000188,0,1,1151,0.192776,8439,0.000188,1169,0.000188L1I1Zv1w0a1f5.666667P0.25Zv0w8a1,0,1,0,0,0f0,1,0,1,0,0b0.04A0,1,0,1,0,1,0,1,731,1L1O2,3,4,5,6,7o31Z", /* 167: DX7 TOY PIANO */ "v2a0.594604,0,0,1,0,0.000188P0.25A0,0.000188,0,1,0,1,3046,0.000188,1043,0.000188L1I1.04Zv3a0.114626,0,0,1,0,0P0.25A0,0.000188,0,1,0,1,0,1,1534,0.000188L1I12.12Zv4a0.136313,0,0,1,0,0P0.25A0,0.000188,0,1,0,1,0,1,6000,0.000188L1I12.6Zv5a2,0,0,1,0,0P0.25A0,0.000188,0,1,15,0.081052,1529,0.000188,930,0.000188L1I4.44Zv6a1.834008,0,0,1,0,0P0.25A0,0.000188,0,1,15,0.081052,4242,0.000188,930,0.000188L1I2.02Zv7a2,0,0,1,0,0P0.25A0,0.000188,0,1,0,1,3046,0.000188,1043,0.000188L1I1Zv1w0a1f6P0.25Zv0w8a1,0,1,0,0,0f0,1,0,1,0,0b0.16A0,1,0,1,0,1,0,1,731,1L1O2,3,4,5,6,7o30Z", /* 168: DX7 HARPSICH 2 */ "v2a0.840896,0,0,1,0,0P0.25A0,1,0,1,0,1,189,0.840896,0,1L1I1Zv3a0.385553,0,0,1,0,0P0.25A0,0.000188,0,0.458502,1060,0.136313,19,0.125,1462,0.000188L1I8Zv4a0.594604,0,0,1,0,0P0.25A0,0.000188,0,1,2,0.458502,5454,0.000188,587,0.000188L1I3Zv5a0.32421,0,0,1,0,0P0.25A0,1,0,1,0,1,189,0.840896,0,1L1I2.99625Zv6a1.29684,0,0,1,0,0P0.25A0,0.000188,0,0.458502,12389,0.136313,0,0.125,1462,0.000188L1I1Zv7a0.458502,0,0,1,0,0P0.25A0,0.000188,3,1,3,0.458502,5454,0.000188,587,0.000188L1I1Zv1w4a1f5P0.25Zv0w8a1,0,1,0,0,0f0,1,0,1,0,0b0.00125A0,1,0,1,0,1,0,1,12000,1L1O2,3,4,5,6,7o3Z", /* 169: DX7 HARPSICH 3 */ "v2a0.32421,0,0,1,0,0P0.25A0,1,0,1,0,1,189,0.840896,0,1L1I1Zv3a1.542211,0,0,1,0,0P0.25A0,0.000188,0,0.458502,12389,0.136313,19,0.125,1462,0.000188L1I4Zv4a0.594604,0,0,1,0,0P0.25A0,0.000188,0,1,5,0.458502,5454,0.000188,416,0.000188L1I1Zv5a0.272627,0,0,1,0,0P0.25A0,1,0,1,0,1,189,0.840896,0,1L1I2.99625Zv6a1.414214,0,0,1,0,0P0.25A0,0.000188,0,0.458502,12389,0.136313,19,0.125,1462,0.000188L1I0.5Zv7a0.917004,0,0,1,0,0P0.25A0,0.000188,0,1,5,0.458502,5454,0.000188,262,0.000188L1I1Zv1w4a1f5P0.25Zv0w8a1,0,1,0,0,0f0,1,0,1,0,0b0.0025A0,1,0,1,0,1,0,1,12000,1L1O2,3,4,5,6,7o3Z", /* 170: DX7 CLAV 2 */ "v2a0.32421,0,0,1,0,0P0.25A0,0.000188,0,0.353553,0,0.32421,86000,0.000188,60000,0.000188L1I8Zv3a2,0,0,1,0,0P0.25A0,0.000188,0,1,0,0.162105,6396,0.420448,89000,0.000188L1I0.49875Zv4a2,0,0,1,0,0P0.25A0,0.000188,0,1,17,0.297302,6439,0.000188,117,0.000188L1I2Zv5a0.385553,0,0,1,0,0P0.25A0,0.000188,0,0.353553,6,0.32421,86000,0.000188,60000,0.000188L1I5.985Zv6a2,0,0,1,0,0P0.25A0,0.000188,0,1,0,0.771105,7000,0.420448,89000,0.000188L1I0.499375Zv7a2,0,0,1,0,0P0.25A0,0.000188,0,1,4,0.297302,6439,0.000188,117,0.000188L1I2.0025Zv1w4a1f6.833333P0.25Zv0w8a1,0,1,0,0,0f0,1,0,1,0,0b0.04A0,1,0,1,0,1,0,1,12000,1L1O2,3,4,5,6,7o4Z", /* 171: DX7 CLAV 3 */ "v2a0.125,0,0,1,0,0P0.25A0,0.000188,0,0.136313,17973,0.015625,12550,0.000188,3636,0.000188L1I12.045Zv3a1,0,0,1,0,0P0.25A0,0.000188,0,1,589,0.037163,18326,0.000188,1,0.000188L1I0.5Zv4a2,0,0,1,0,0P0.25A0,0.000188,0,1,0,1,12979,0.000188,7,0.000188L1I2Zv5a0.297302,0,0,1,0,0P0.25A0,0.000188,0,1,984,0.707107,23378,0.000188,58,0.000188L1I3Zv6a1.189207,0,0,1,0,0P0.25A0,0.000188,0,1,305,0.297302,13805,0.000188,3636,0.000188L1I0.504375Zv7a2,0,0,1,0,0P0.25A0,0.000188,2,1,193,0.707107,21111,0.000188,58,0.000188L1I0.5Zv1w4a1f5.833333P0.25Zv0w8a1,0,1,0,0,0f0,1,0,1,0,0b0.00125A0,1,0,1,0,1,0,1,731,1L1O2,3,4,5,6,7o4Z", /* 172: DX7 E.ORGAN 2 */ "v2a0.176777,0,0,1,0,0P0.25A0,0.000188,0,1,0,1,0,1,2,0.000188L1I1Zv3a2,0,0,1,0,0P0.25A0,0.000188,0,1,1029,0.192776,0,0.192776,1,0.000188L1I3Zv4a0.420448,0,0,1,0,0P0.25A0,0.000188,0,1,0,1,0,1,2,0.000188L1I0.9975Zv5a2,0,0,1,0,0P0.25A0,0.000188,0,1,0,1,0,1,2,0.000188L1I2.0025Zv6a1.834008,0,0,1,0,0P0.25A0,0.000188,0,1,0,1,0,1,2,0.000188L1I1.50125Zv7a2,0,0,1,0,0P0.25A0,0.000188,0,1,0,1,0,1,2,0.000188L1I1Zv1w0a1f5.833333P0.25Zv0w8a1,0,1,0,0,0f0,1,0,1,0,0b0.08A0,1,0,1,0,1,0,1,731,1L1O2,3,4,5,6,7o29Z", /* 173: DX7 E.ORGAN 3 */ "v2a0.25,0,0,1,0,0P0.25A0,0.000188,0,1,172,0.000188,0,0.000188,1,0.000188L1I4Zv3a0.64842,0,0,1,0,0P0.25A0,0.000188,0,1,0,1,0,1,2,0.000188L1I2Zv4a0.176777,0,0,1,0,0P0.25A0,0.000188,0,1,0,1,0,1,2,0.000188L1I5Zv5a2,0,0,1,0,0P0.25A0,0.000188,0,1,0,1,0,1,2,0.000188L1I2Zv6a2,0,0,1,0,0P0.25A0,0.000188,0,1,0,1,0,1,2,0.000188L1I1.00125Zv7a2,0,0,1,0,0P0.25A0,0.000188,0,1,0,1,0,1,2,0.000188L1I0.5Zv1w0a1f5.5P0.25Zv0w8a1,0,1,0,0,0f0,1,0,1,0,0b0.00125A0,1,0,1,0,1,0,1,731,1L1O2,3,4,5,6,7o29Z", /* 174: DX7 E.ORGAN 4 */ "v2a2,0,0,1,0,0P0.25A0,0.000188,0,0.32421,7,0.014328,1,0.000188,9,0.000188L1I4.035Zv3a2,0,0,1,0,0P0.25A0,0.000188,0,1,0,0.458502,37,0.272627,12,0.000188L1I5Zv4a2,0,0,1,0,0P0.25A0,0.000188,3,1,0,0.420448,0,0.192776,12,0.000188L1I0.49875Zv5a2,0,0,1,0,0P0.25A0,0.000188,0,1,0,1,0,0.840896,14,0.000188L1I1.00875Zv6a0.458502,0,0,1,0,0P0.25A0,0.000188,0,1,0,1,0,0.840896,14,0.000188L1I0.50125Zv7a1.414214,0,0,1,0,0P0.25A0,0.000188,0,1,0,1,0,1,15,0.000188L1I0.49875Zv1w4a1f5.666667P0.25Zv0w8a1,0,1,0,0,0f0,1,0,1,0,0b0.16A0,1,0,1,0,1,0,1,731,1L1O2,3,4,5,6,7o5Z", /* 175: DX7 E.ORGAN 5 */ "v2a0.210224,0,0,1,0,0P0.25A0,0.000188,0,1,0,1,0,1,2,0.000188L1I1Zv3a0.840896,0,0,1,0,0P0.25A0,0.000188,0,1,0,1,0,1,2,0.000188L1I3Zv4a0.917004,0,0,1,0,0P0.25A0,0.000188,0,1,0,1,0,1,2,0.000188L1I3Zv5a0.917004,0,0,1,0,0P0.25A0,0.000188,0,1,0,1,0,1,2,0.000188L1I3Zv6a0.917004,0,0,1,0,0P0.25A0,0.000188,0,1,0,1,0,1,2,0.000188L1I2Zv7a1,0,0,1,0,0P0.25A0,0.000188,0,1,0,1,0,1,2,0.000188L1I0.5Zv1w0a1f5.833333P0.25Zv0w8a1,0,1,0,0,0f0,1,0,1,0,0.011111b0.08A0,1,0,1,0,1,0,1,731,1L1O2,3,4,5,6,7o29Z", /* 176: DX7 PIPES 2 */ "v2a0.068157,0,0,1,0,0P0.25A0,0.000188,7,0.458502,0,0.64842,97,0.000691,58,0.000188L1I19Zv3a0.707107,0,0,1,0,0f1P0.25A0,0.000188,0,1,0,1,13,0.458502,350,0.000188L1Zv4a0.385553,0,0,1,0,0P0.25A0,0.000188,51,1,0,1,632,0.594604,101,0.000188L1I2Zv5a0.385553,0,0,1,0,0P0.25A0,0.000188,19,0.458502,0,0.64842,24,0.014328,194,0.000188L1I8Zv6a0.297302,0,0,1,0,0P0.25A0,0.000188,0,1,0,1,13,0.458502,350,0.000188L1I1Zv7a0.385553,0,0,1,0,0P0.25A0,0.000188,51,1,0,1,632,0.594604,101,0.000188L1I2Zv1w0a1f5.666667P0.25Zv0w8a1,0,1,0,0,0f0,1,0,1,0,0b0.16A0,1,0,1,0,1,0,1,731,1L1O2,3,4,5,6,7o3Z", /* 177: DX7 PIPES 3 */ "v2a0.057313,0,0,1,0,0P0.25A0,0.000188,1,1,0,1,0,1,108,0.000188L1I4.04Zv3a0.385553,0,0,1,0,0P0.25A0,0.000188,0,0.034078,8,1,0,1,34,0.000188L1I8.08Zv4a1.834008,0,0,1,0,0P0.25A0,0.000188,2,0.176777,1,1,0,1,611,0.000188L1I2.0175Zv5a0.707107,0,0,1,0,0P0.25A0,0.000188,4,1,0,1,0,1,136,0.000188L1I1.01Zv6a2,0,0,1,0,0P0.25A0,0.000188,0,0.026278,0,0.017039,35,1,121,0.000188L1I4.04Zv7a2,0,0,1,0,0P0.25A0,0.000188,4,1,0,0.840896,0,1,770,0.000188L1I0.5Zv1w0a1f5.833333P0.25Zv0w8a1,0,1,0,0,0f0,1,0,1,0,0b0.01A0,1,0,1,0,1,0,1,731,1L1O2,3,4,5,6,7o25Z", /* 178: DX7 PIPES 4 */ "v2a0.545254,0,0,1,0,0P0.25A0,0.000188,0,1,0,1,0,1,1087,0.000188L1I4Zv3a0.64842,0,0,1,0,0P0.25A0,0.000188,14,1,0,1,0,1,545,0.000188L1I2Zv4a0.297302,0,0,1,0,0P0.25A0,0.000188,0,1,0,1,0,1,611,0.000188L1I1Zv5a2,0,0,1,0,0P0.25A0,0.000188,40,1,0,1,13,0.458502,350,0.000188L1I2Zv6a0.771105,0,0,1,0,0P0.25A0,0.000188,0,1,0,1,13,0.458502,350,0.000188L1I0.5Zv7a2,0,0,1,0,0P0.25A0,0.000188,28,1,0,1,105,0.917004,53,0.000188L1I1Zv1w0a1f5.666667P0.25Zv0w8a1,0,1,0,0,0f0,1,0,1,0,0b0.00125A0,1,0,1,0,1,0,1,731,1L1O2,3,4,5,6,7o6Z", /* 179: DX7 CALIOPE */ "v2a0.458502,0,0,1,0,0P0.25A0,0.000188,8,1,39,0.0625,0,0.017039,90,0.000188L1I7.045Zv3a0.048194,0,0,1,0,0P0.25A0,0.000188,16,1,2425,0.000188,0,0.000188,104,0.000188L1I2Zv4a0.25,0,0,1,0,0P0.25A0,0.000188,25,1,0,1,210,0.840896,189,0.000188L1I1.9825Zv5a0.125,0,0,1,0,0P0.25A0,0.000188,40,0.385553,1077,0.00852,6,0.001506,41,0.000188L1I2.0375Zv6a0.25,0,0,1,0,0P0.25A0,0.000188,32,1,170,0.034078,92,0.000188,233,0.000188L1I4.6Zv7a1.834008,0,0,1,0,0P0.25A0,0.000188,14,0.229251,3,0.125,6,0.707107,104,0.000188L1I1Zv1w4a1f5P0.25Zv0w8a1,0,1,0,0,0f0,1,0,1,0,0b0.04A0,1,0,1,0,1,0,1,731,1L1O2,3,4,5,6,7o16Z", /* 180: DX7 ACCORDION */ "v2a0.148651,0,0,1,0,0P0.25A0,0.000188,0,0.458502,286,0.545254,11497,0.068157,420,0.000188L1I6.0075Zv3a0.25,0,0,1,0,0P0.25A0,0.000188,20,1,2103,0.545254,11497,0.068157,666,0.000188L1I0.99875Zv4a0.917004,0,0,1,0,0P0.25A0,0.000188,51,1,2103,0.545254,2439,1,68,0.000188L1I2Zv5a0.048194,0,0,1,0,0P0.25A0,0.000188,1,1,2103,0.545254,10060,0.088388,695,0.000188L1I3.0075Zv6a1,0,0,1,0,0P0.25A0,0.000188,0,1,2103,0.545254,10060,0.088388,43,0.000188L1I0.500625Zv7a0.707107,0,0,1,0,0P0.25A0,0.000188,51,1,2103,0.545254,4790,0.229251,25,0.000188L1I1Zv1w0a1f5.833333P0.25Zv0w8a1,0,1,0,0,0f0,1,0,1,0,0b0.16A0,1,0,1,0,1,0,1,731,1L1O2,3,4,5,6,7o3Z", /* 181: DX7 SITAR */ "v2a0.009291,0,0,1,0,0P0.25A0,0.000188,0,1,17,0.917004,9263,0.000188,28743,0.000188L1I9.01125Zv3a0.707107,0,0,1,0,0P0.25A0,0.000188,0,1,0,0.917004,9263,0.000188,36980,0.000188L1I0.99375Zv4a0.917004,0,0,1,0,0P0.25A0,0.000188,0,1,17,0.917004,1519,0.000188,36980,0.000188L1I6.97375Zv5a1,0,0,1,0,0P0.25A0,0.000188,0,1,0,0.917004,9263,0.000188,4545,0.000188L1I1Zv6a1.681793,0,0,1,0,0P0.25A0,0.000188,0,1,17,0.917004,9263,0.000188,36980,0.000188L1I1Zv7a0.210224,0,0,1,0,0P0.25A0,0.000188,0,1,0,0.917004,9263,0.000188,930,0.000188L1I20Zv1w4a1f4.666667P0.25Zv0w8a1,0,1,0,0,0f0,1,0,1,0,0b0.00125A0,1,0,1,0,1,0,1,179,1L1O2,3,4,5,6,7o8Z", /* 182: DX7 GUITAR 3 */ "v2a0.840896,0,0,1,0,0P0.25A0,0.000188,0,1,5454,0.001953,3176,0.000188,262,0.000188L1I5Zv3a0.074325,0,0,1,0,0P0.25A0,0.000188,62,0.771105,9046,0.001953,3176,0.000188,262,0.000188L1I1Zv4a0.088388,0,0,1,0,0P0.25A0,0.000188,0,1,5454,0.001953,3176,0.000188,262,0.000188L1I3Zv5a0.594604,0,0,1,0,0P0.25A0,0.000188,5,1,5454,0.001953,3176,0.000188,58,0.000188L1I1Zv6a0.25,0,0,1,0,0P0.25A0,0.000188,0,1,5454,0.001953,3176,0.000188,262,0.000188L1I1.0025Zv7a0.64842,0,0,1,0,0P0.25A0,0.000188,5,1,5454,0.001953,3176,0.000188,58,0.000188L1I1Zv1w0a1f6.5P0.25Zv0w8a1,0,1,0,0,0f0,1,0,1,0,0.000505b0.02A0,1,0,1,0,1,0,1,731,1L1O2,3,4,5,6,7o14Z", /* 183: DX7 GUITAR 4 */ "v2a0.917004,0,0,1,0,0P0.25A0,0.000188,0,1,24553,0.017039,52000,0.000188,262,0.000188L1I3Zv3a0.068157,0,0,1,0,0P0.25A0,0.000188,0,0.771105,3068,0.176777,739,0.420448,389,0.000188L1I1Zv4a0.32421,0,0,1,0,0P0.25A0,0.000188,0,1,7595,0.001953,6644,0.000188,262,0.000188L1I4Zv5a0.594604,0,0,1,0,0P0.25A0,0.000188,5,1,1029,0.192776,14441,0.000188,208,0.000188L1I1Zv6a1.834008,0,0,1,0,0P0.25A0,0.000188,0,1,99000,0.000188,0,0.000188,60000,0.000188L1I1.0025Zv7a0.114626,0,0,1,0,0P0.25A0,0.000188,0,1,686,0.000188,0,0.000188,58,0.000188L1I3Zv1w0a1f6.5P0.25Zv0w8a1,0,1,0,0,0f0,1,0,1,0,0.000505b0.02A0,1,0,1,0,1,0,1,731,1L1O2,3,4,5,6,7o14Z", /* 184: DX7 GUITAR 5 */ "v2a0.353553,0,0,1,0,0P0.25A0,0.000188,0,1,3185,0.017039,10421,0.000188,930,0.000188L1I4.975Zv3a0.068157,0,0,1,0,0P0.25A0,0.000188,0,0.771105,3068,0.176777,739,0.420448,550,0.000188L1I0.995Zv4a0.32421,0,0,1,0,0P0.25A0,0.000188,0,1,7595,0.001953,6644,0.000188,370,0.000188L1I3.98Zv5a0.545254,0,0,1,0,0P0.25A0,0.000188,5,1,1029,0.192776,14441,0.000188,1169,0.000188L1I0.995Zv6a1.090508,0,0,1,0,0P0.25A0,0.000188,0,1,1929,0.000188,0,0.000188,18026,0.000188L1I6.0375Zv7a0.420448,0,0,1,0,0P0.25A0,0.000188,0,1,4280,0.000188,0,0.000188,416,0.000188L1I8.05Zv1w0a1f6.5P0.25Zv0w8a1,0,1,0,0,0f0,1,0,1,0,0.000505b0.02A0,1,0,1,0,1,0,1,731,1L1O2,3,4,5,6,7o14Z", /* 185: DX7 GUITAR 6 */ "v2a0.420448,0,0,1,0,0P0.25A0,0.000188,2,1,78,0.210224,2224,0.000188,466,0.000188L1I6Zv3a1,0,0,1,0,0P0.25A0,0.000188,0,1,247,0.458502,6099,0.000188,4066,0.000188L1I4Zv4a2,0,0,1,0,0P0.25A0,0.000188,0,1,86,0.545254,3171,0.000188,2316,0.000188L1I2Zv5a2,0,0,1,0,0P0.25A0,0.000188,0,1,530,0.545254,5575,0.000188,2594,0.000188L1I1Zv6a0.840896,0,0,1,0,0P0.25A0,0.000188,0,1,349,0.25,3588,0.000188,16327,0.000188L1I2Zv7a1.090508,0,0,1,0,0P0.25A0,0.000188,0,1,86,0.545254,3171,0.000188,2316,0.000188L1I2Zv1w0a1f5P0.25Zv0w8a1,0,1,0,0,0f0,1,0,1,0,0b0.16A0,1,0,1,0,1,0,1,951,1L1O2,3,4,5,6,7o3Z", /* 186: DX7 LUTE */ "v2a0.192776,0,0,1,0,0P0.25A0,0.000188,0,1,60,0.000188,0,0.000188,466,0.000188L1I6.0075Zv3a0.068157,0,0,1,0,0P0.25A0,0.000188,0,1,4280,0.000188,0,0.000188,32,0.000188L1I4Zv4a0.009291,0,0,1,0,0P0.25A0,0.000188,0,1,3822,0.000188,0,0.000188,32,0.000188L1I2.0075Zv5a2,0,0,1,0,0P0.25A0,0.000188,2,1,3822,0.000188,0,0.000188,1469,0.000188L1I1Zv6a0.210224,0,0,1,0,0P0.25A0,0.000188,0,1,3822,0.000188,0,0.000188,32,0.000188L1I2Zv7a0.545254,0,0,1,0,0P0.25A0,0.000188,2,1,3822,0.000188,0,0.000188,1469,0.000188L1I1Zv1w4a1f4.5P0.25Zv0w8a1,0,1,0,0,0f0,1,0,1,0,0.002481b0.16A0,1,0,1,0,1,0,1,179,1L1O2,3,4,5,6,7o14Z", /* 187: DX7 BANJO */ "v2a0.707107,0,0,1,0,0P0.25A0,0.000188,0,1,2,0.148651,1064,0.000188,32,0.000188L1I15Zv3a0.25,0,0,1,0,0P0.25A0,0.000188,0,1,0,0.917004,9263,0.000188,466,0.000188L1I1.00375Zv4a0.32421,0,0,1,0,0P0.25A0,0.000188,0,1,242,0.707107,17148,0.000188,233,0.000188L1I4.9875Zv5a1,0,0,1,0,0P0.25A0,0.000188,0,1,0,1,1220,0.000188,185,0.000188L1I1.0025Zv6a0.385553,0,0,1,0,0P0.25A0,0.000188,0,1,17871,0.000188,0,0.000188,60000,0.000188L1I1.06Zv7a2,0,0,1,0,0P0.25A0,0.000188,0,1,60,0.034078,4545,0.000188,147,0.000188L1I1Zv1w4a1f1P0.25Zv0w8a1,0,1,0,0,0f0,1,0,1,0,0.00146b0.16A0,1,0,1,0,1,0,1,731,1L1O2,3,4,5,6,7o8Z", /* 188: DX7 HARP 1 */ "v2a0.64842,0,0,1,0,0.000188P0.25A0,0.000188,0,0.64842,146,0.176777,5985,0.000188,7866,0.000188L1I2Zv3a0.044194,0,0,1,0,0P0.25A0,0.000188,0,1,710,0.081052,1,0.000188,14765,0.000188L1I1Zv4a2,0,0,1,0,0P0.25A0,0.000188,0,1,1965,0.081052,485,0.000188,3636,0.000188L1I1Zv5a0.707107,0,0,1,0,0P0.25A0,0.000188,0,1,449,0.081052,862,0.000188,2068,0.000188L1I1Zv6a0.25,0,0,1,0,0P0.25A0,0.000188,0,1,1757,0.081052,1,0.000188,3636,0.000188L1I1Zv7a2,0,0,1,0,0P0.25A0,0.000188,0,1,2454,0.081052,769,0.000188,3250,0.000188L1I1Zv1w0a1f5.666667P0.25Zv0w8a1,0,1,0,0,0f0,1,0,1,0,0b0.16A0,1,0,1,0,1,0,1,731,1L1O2,3,4,5,6,7o3Z", /* 189: DX7 HARP 2 */ "v2a0.917004,0,0,1,0,0.000188P0.25A0,0.000188,0,0.64842,146,0.176777,5985,0.000188,7058,0.000188L1I2.97375Zv3a0.353553,0,0,1,0,0P0.25A0,0.000188,0,1,999,0.081052,1,0.000188,4545,0.000188L1I3.015Zv4a2,0,0,1,0,0P0.25A0,0.000188,0,1,1403,0.081052,485,0.000188,2594,0.000188L1I0.995Zv5a0.081052,0,0,1,0,0P0.25A0,0.000188,0,1,179,0.081052,862,0.000188,28743,0.000188L1I2.9775Zv6a0.353553,0,0,1,0,0P0.25A0,0.000188,0,1,284,0.081052,1,0.000188,24000,0.000188L1I1.995Zv7a2,0,0,1,0,0P0.25A0,0.000188,0,1,1403,0.081052,769,0.000188,3250,0.000188L1I1.00625Zv1w0a1f5.666667P0.25Zv0w8a1,0,1,0,0,0f0,1,0,1,0,0b0.08A0,1,0,1,0,1,0,1,731,1L1O2,3,4,5,6,7o3Z", /* 190: DX7 BASS 3 */ "v2a1,0,0,1,0,0P0.25A0,0.000188,1424,0.771105,3,0.840896,11411,0.000188,208,0.000188L1I0.500625Zv3a0.114626,0,0,1,0,0P0.25A0,0.000188,0,1,99000,0.000188,0,0.000188,60000,0.000188L1I1.01Zv4a2,0,0,1,0,0P0.25A0,0.000188,1,0.32421,357,0.026278,4318,0.000188,262,0.000188L1I0.5Zv5a2,0,0,1,0,0.000188P0.25A0,0.000188,735,0.297302,738,0.162105,3775,0.000188,3636,0.000188L1I0.504375Zv6a0.229251,0,0,1,0,0P0.25A0,0.000188,1157,1,2718,0.000188,0,0.000188,370,0.000188L1I0.515Zv7a2,0,0,1,0,0P0.25A0,0.000188,1,1,545,0.458502,6818,0.000188,82,0.000188L1I0.505Zv1w0a1f5.166667P0.25Zv0w8a1,0,1,0,0,0f0,1,0,1,0,0b0.16A0,1,0,1,0,1,0,1,731,1L1O2,3,4,5,6,7o17Z", /* 191: DX7 BASS 4 */ "v2a0.458502,0,0,1,0,0P0.25A0,0.000188,0,0.771105,55,0.162105,9176,0.000188,208,0.000188L1I4Zv3a0.00426,0,0,1,0,0P0.25A0,0.000188,0,1,99000,0.000188,0,0.000188,60000,0.000188L1I0.5Zv4a1.681793,0,0,1,0,0P0.25A0,0.000188,0,0.771105,15,0.136313,8941,0.000188,208,0.000188L1I0.5Zv5a0.068157,0,0,1,0,0P0.25A0,0.000188,1,1,677,0.420448,6742,0.000188,18,0.000188L1I1Zv6a0.192776,0,0,1,0,0P0.25A0,0.000188,2,1,218,0.420448,6742,0.000188,233,0.000188L1I0.5Zv7a2,0,0,1,0,0P0.25A0,0.000188,1,1,677,0.420448,6742,0.000188,18,0.000188L1I0.5Zv1w0a1f5.666667P0.25Zv0w8a1,0,1,0,0,0f0,1,0,1,0,0b0.16A0,1,0,1,0,1,0,1,731,1L1O2,3,4,5,6,7o17Z", /* 192: DX7 PICCOLO */ "v2a0.017039,0,0,1,0,0P0.25A0,0.000188,0,0.192776,3,0.048194,0,0.048194,1,0.000188L1I5.55Zv3a1.29684,0,0,1,0,0P0.25A0,0.000188,11,1,0,1,24,0.64842,72,0.000188L1I1.00125Zv4a0.03125,0,0,1,0,0P0.25A0,0.000188,0,0.771105,140,0.048194,0,0.048194,1,0.000188L1I1.0125Zv5a1.29684,0,0,1,0,0P0.25A0,0.000188,11,1,0,1,530,0.545254,71,0.000188L1I1.01125Zv6a0.00657,0,0,1,0,0P0.25A0,0.000188,0,0.771105,140,0.048194,0,0.048194,1,0.000188L1I2.02Zv7a1.189207,0,0,1,0,0P0.25A0,0.000188,11,1,0,1,530,0.545254,71,0.000188L1I1Zv1w0a1f5.833333P0.25Zv0w8a1,0,1,0,0,0f0,1,0,1,0,0b0.00125A0,1,0,1,0,1,0,1,731,1L1O2,3,4,5,6,7o5Z", /* 193: DX7 FLUTE 2 */ "v2a0.022097,0,0,1,0,0P0.25A0,0.000188,6,1,0,1,3,0.840896,97000,0.000188L1I17Zv3a0.096388,0,0,1,0,0P0.25A0,0.000188,91,1,20,0.052556,0,0.034078,60000,0.000188L1I2.9925Zv4a0.125,0,0,1,0,1P0.25A0,0.000188,0,1,0,0.458502,6818,0.000188,117,0.000188L1I1Zv5a0.840896,0,0,1,0,0P0.25A0,0.000188,0,0.594604,0,0.458502,90000,0.000188,60000,0.000188L1I1Zv6a0.192776,0,0,1,0,1P0.25A0,0.000188,0,1,0,0.771105,7000,0.420448,89000,0.000188L1I0.99875Zv7a2,0,0,1,0,0P0.25A0,0.000188,28,1,9000,0.458502,1676,0.840896,94,0.000188L1I1.00125Zv1w0a1f6.166667P0.25Zv0w8a1,0,1,0,0,0f0,1,0,1,0,0.003535b0.04A0,1,0,1,0,1,0,1,12000,1L1O2,3,4,5,6,7o18Z", /* 194: DX7 OBOE */ "v2a0.353553,0,0,1,0,0P0.25A0,0.000188,20,1,9000,0.458502,2342,1,60,0.000188L1I1Zv3a0.25,0,0,1,0,0P0.25A0,0.000188,20,1,9000,0.458502,2342,1,60,0.000188L1I1Zv4a0.25,0,0,1,0,0P0.25A0,0.000188,91,1,0,1,338,0.707107,58,0.000188L1I8Zv5a0.25,0,0,1,0,0P0.25A0,0.000188,0,1,1,0.458502,1,0.192776,49,0.000188L1I8Zv6a0.272627,0,0,1,0,0P0.25A0,0.000188,20,1,9000,0.458502,2342,1,60,0.000188L1I1Zv7a2,0,0,1,0,0P0.25A0,0.000188,23,0.707107,0,0.707107,1805,0.297302,52,0.000188L1I4Zv1w0a1f6.166667P0.25Zv0w8a1,0,1,0,0,0f0,1,0,1,0,0b0.04A0,1,0,1,0,1,0,1,12000,1L1O2,3,4,5,6,7o3Z", /* 195: DX7 CLARINET */ "v2a0.022097,0,0,1,0,0P0.25A0,0.000188,6,1,0,1,3,0.840896,97000,0.000188L1I10Zv3a0.040526,0,0,1,0,0P0.25A0,0.000188,1,1,20,0.052556,0,0.034078,60000,0.000188L1I7.98Zv4a0.0625,0,0,1,0,1P0.25A0,0.000188,0,1,0,0.458502,6818,0.000188,117,0.000188L1I6Zv5a1.090508,0,0,1,0,0P0.25A0,0.000188,0,0.353553,0,0.32421,86000,0.000188,60000,0.000188L1I4Zv6a0.136313,0,0,1,0,1P0.25A0,0.000188,0,1,0,0.771105,7000,0.420448,89000,0.000188L1I1.9975Zv7a2,0,0,1,0,0P0.25A0,0.000188,16,1,9000,0.458502,1676,0.840896,59,0.000188L1I1.00125Zv1w0a1f6.166667P0.25Zv0w8a1,0,1,0,0,0f0,1,0,1,0,0.003535b0.04A0,1,0,1,0,1,0,1,12000,1L1O2,3,4,5,6,7o17Z", /* 196: DX7 SAX BC */ "v2a2,0,0,1,0,0P0.25A0,0.000188,0,1,0,1,0,1,385,0.000188L1I0.5Zv3a0.034078,0,0,1,0,0.000188P0.25A0,0.000188,0,0.917004,438,1,0,1,153,0.000188L1I5.84375Zv4a0.162105,0,0,1,0,0.000188P0.25A0,0.000188,0,1,0,1,0,1,121,0.000188L1I0.5Zv5a0.272627,0,0,1,0,0.000188P0.25A0,0.000188,0,1,0,1,331,0.917004,120,0.000188L1I0.5Zv6a0.25,0,0,1,0,0.000188P0.25A0,0.000188,0,1,0,1,0,1,385,0.000188L1I0.5Zv7a2,0,0,1,0,0.000188P0.25A0,0.000188,18,1,0,1,0,1,108,0.000188L1I0.99125Zv1w0a1f5.666667P0.25Zv0w8a1,0,1,0,0,0f0,1,0,1,0,0b0.16A0,1,0,1,0,1,0,1,731,1L1O2,3,4,5,6,7o18Z", /* 197: DX7 BASSOON */ "v2a0.114626,0,0,1,0,0P0.25A0,0.000188,51,1,43,0.707107,846,0.297302,52,0.000188L1I6.24Zv3a0.353553,0,0,1,0,0P0.25A0,0.000188,0,1,1,0.458502,3,0.081052,43,0.000188L1I5Zv4a0.192776,0,0,1,0,0P0.25A0,0.000188,51,1,9000,0.458502,2342,1,60,0.000188L1I0.5Zv5a2,0,0,1,0,0P0.25A0,0.000188,28,1,43,0.707107,846,0.297302,52,0.000188L1I2Zv6a0.32421,0,0,1,0,0P0.25A0,0.000188,51,1,9000,0.458502,2342,1,60,0.000188L1I0.5Zv7a2,0,0,1,0,0P0.25A0,0.000188,28,1,43,0.707107,846,0.297302,52,0.000188L1I2Zv1w0a1f6.166667P0.25Zv0w8a1,0,1,0,0,0f0,1,0,1,0,0b0.01A0,1,0,1,0,1,0,1,12000,1L1O2,3,4,5,6,7o2Z", /* 198: DX7 STRINGS 4 */ "v2a0.162105,0,0,1,0,0P0.25A0,0.000188,7,1,2,0.545254,44073,0.000188,2904,0.000188L1I8Zv3a0.114626,0,0,1,0,0P0.25A0,0.000188,4,1,3,0.545254,44073,0.000188,4545,0.000188L1I2Zv4a0.272627,0,0,1,0,0P0.25A0,0.000188,97,0.917004,0,0.917004,29702,0.00426,1742,0.000188L1I2Zv5a1.090508,0,0,1,0,0P0.25A0,0.000188,81,1,2103,0.545254,44073,0.000188,523,0.000188L1I2.015Zv6a0.272627,0,0,1,0,0P0.25A0,0.000188,2,1,2550,0.545254,39446,0.00213,2953,0.000188L1I0.9925Zv7a1.090508,0,0,1,0,0P0.25A0,0.000188,109,0.917004,0,0.917004,29702,0.00426,314,0.000188L1I2Zv1w0a1f5P0.25Zv0w8a1,0,1,0,0,0f0,1,0,1,0,0.006869b0.16A0,1,0,1,0,1,0,1,731,1L1O2,3,4,5,6,7o2Z", /* 199: DX7 STRINGS 5 */ "v2a0.081052,0,0,1,0,0P0.25A0,0.000188,204,1,2103,0.545254,44073,0.000188,587,0.000188L1I4Zv3a0.114626,0,0,1,0,0P0.25A0,0.000188,204,1,2103,0.545254,44073,0.000188,587,0.000188L1I2Zv4a0.176777,0,0,1,0,0P0.25A0,0.000188,204,1,2103,0.545254,44073,0.000188,587,0.000188L1I1Zv5a1.090508,0,0,1,0,0P0.25A0,0.000188,1157,1,2103,0.545254,44073,0.000188,587,0.000188L1I1.00875Zv6a0.25,0,0,1,0,0P0.25A0,0.000188,1,1,2103,0.545254,44073,0.000188,587,0.000188L1I1.00875Zv7a0.707107,0,0,1,0,0P0.25A0,0.000188,1299,1,2103,0.545254,44073,0.000188,587,0.000188L1I0.99875Zv1w0a1f5.833333P0.25Zv0w8a1,0,1,0,0,0f0,1,0,1,0,0.007071b0.16A0,1,0,1,0,1,0,1,731,1L1O2,3,4,5,6,7o2Z", /* 200: DX7 STRINGS 6 */ "v2a0.192776,0,0,1,0,0P0.25A0,0.000188,0,0.917004,5254,0.000205,0,0.162105,14080,0.000188L1I3Zv3a0.5,0,0,1,0,0P0.25A0,0.000188,88,0.353553,0,0.353553,45,0.594604,1812,0.000188L1I0.995Zv4a0.272627,0,0,1,0,0P0.25A0,0.000188,3,1,0,1,0,1,1929,0.000188L1I0.9975Zv5a1.834008,0,0,1,0,0P0.25A0,0.000188,91,1,518,0.353553,13,0.420448,777,0.000188L1I1.00875Zv6a0.385553,0,0,1,0,0P0.25A0,0.000188,169,0.545254,518,0.192776,217,0.057313,14666,0.000188L1I3.0075Zv7a1,0,0,1,0,0P0.25A0,0.000188,144,1,6659,0.028656,6118,0.000188,208,0.000188L1I0.99125Zv1w4a1f5.833333P0.25Zv0w8a1,0,1,0,0,0f0,1,0,1,0,0.009444b0.16A0,1,0,1,0,1,0,1,731,1L1O2,3,4,5,6,7o15Z", /* 201: DX7 STRINGS 7 */ "v2a0.136313,0,0,1,0,0P0.25A0,0.000188,0,0.917004,5254,0.000205,0,0.162105,14080,0.000188L1I1.49625Zv3a0.353553,0,0,1,0,0P0.25A0,0.000188,88,0.353553,0,0.353553,45,0.594604,1812,0.000188L1I3Zv4a0.210224,0,0,1,0,0P0.25A0,0.000188,3,1,0,1,0,1,1929,0.000188L1I1.5Zv5a1.542211,0,0,1,0,0P0.25A0,0.000188,114,1,518,0.353553,13,0.420448,777,0.000188L1I1.50375Zv6a0.32421,0,0,1,0,0P0.25A0,0.000188,3,1,0,1,0,1,1929,0.000188L1I0.9975Zv7a2,0,0,1,0,0P0.25A0,0.000188,45,1,518,0.353553,13,0.420448,777,0.000188L1I1.00375Zv1w4a1f5.5P0.25Zv0w8a1,0,1,0,0,0f0,1,0,1,0,0.012879b0.16A0,1,0,1,0,1,0,1,731,1L1O2,3,4,5,6,7o2Z", /* 202: DX7 STRINGS 8 */ "v2a0.017039,0,0,1,0,0P0.25A0,0.000188,64,1,1402,0.545254,1083,0.32421,335,0.000188L1I1Zv3a0.162105,0,0,1,0,0P0.25A0,0.000188,37,0.32421,491,0.545254,1083,0.32421,335,0.000188L1I1Zv4a0.114626,0,0,1,0,0P0.25A0,0.000188,0,1,1402,0.545254,1083,0.32421,335,0.000188L1I1Zv5a2,0,0,1,0,0P0.25A0,0.000188,1,1,686,0.000188,0,0.000188,1043,0.000188L1I1Zv6a0.210224,0,0,1,0,0P0.25A0,0.000188,0,0.917004,762,0.000188,0,0.000188,370,0.000188L1I1Zv7a2,0,0,1,0,0P0.25A0,0.000188,0,1,486,0.000188,0,0.000188,659,0.000188L1I1Zv1w0a1f5.5P0.25Zv0w8a1,0,1,0,0,0f0,1,0,1,0,0.00404b0.16A0,1,0,1,0,1,0,1,731,1L1O2,3,4,5,6,7o2Z", /* 203: DX7 BRASS 4 */ "v2a0.458502,0,0,1,0,0P0.25A0,0.000188,97,0.917004,0,0.917004,530,0.5,70,0.000188L1I0.495625Zv3a1.834008,0,0,1,0,0P0.25A0,0.000188,4,1,30,0.917004,0,0.917004,53,0.000188L1I0.495625Zv4a2,0,0,1,0,0P0.25A0,0.000188,4,1,30,0.917004,0,0.917004,53,0.000188L1I0.495625Zv5a2,0,0,1,0,0P0.25A0,0.000188,4,1,0,0.917004,0,0.917004,53,0.000188L1I0.495625Zv6a0.5,0,0,1,0,0P0.25A0,0.000188,11,0.229251,26,0.707107,37,0.771105,52,0.000188L1I0.504375Zv7a1.189207,0,0,1,0,0P0.25A0,0.000188,7,1,3,0.385553,0,0.771105,52,0.000188L1I0.504375Zv1w0a1f6.166667P0.25Zv0w8a1,0,1,0,0,0f0,1,0,1,0,0b0.16A0,1,0,1,0,1,0,1,731,1L1O2,3,4,5,6,7o22Z", /* 204: DX7 BRASS 5 */ "v2a1.090508,0,0,1,0,0P0.25A0,0.000188,61,0.917004,6557,0.192776,2,0.297302,371,0.000188L1I1.5025Zv3a0.052556,0,0,1,0,0P0.25A0,0.000188,61,0.917004,6557,0.192776,2,0.297302,371,0.000188L1I1.5Zv4a0.545254,0,0,1,0,0P0.25A0,0.000188,61,0.917004,6557,0.192776,2,0.297302,371,0.000188L1I1.4975Zv5a1.834008,0,0,1,0,0P0.25A0,0.000188,22,1,4,0.545254,1444,0.272627,327,0.000188L1I1.505Zv6a0.458502,0,0,1,0,0P0.25A0,0.000188,61,0.917004,29,0.707107,0,0.707107,415,0.000188L1I0.99125Zv7a2,0,0,1,0,0P0.25A0,0.000188,22,1,1,0.840896,361,0.707107,370,0.000188L1I1Zv1w0a1f5.666667P0.25Zv0w8a1,0,1,0,0,0f0,1,0,1,0,0b0.16A0,1,0,1,0,1,0,1,731,1L1O2,3,4,5,6,7o2Z", /* 205: DX7 BRASS 6 BC */ "v2a0.5,0,0,1,0,0.000188P0.25A0,0.000188,28,1,1,0.917004,200,0.840896,59,0.000188L1I1Zv3a2,0,0,1,0,0.000188P0.25A0,0.000188,11,1,722,0.707107,0,0.707107,58,0.000188L1I1Zv4a1.681793,0,0,1,0,0.000188P0.25A0,0.000188,11,1,722,0.707107,0,0.707107,58,0.000188L1I1Zv5a2,0,0,1,0,0.000188P0.25A0,0.000188,11,1,541,0.771105,180,0.707107,58,0.000188L1I1Zv6a0.840896,0,0,1,0,0.000188P0.25A0,0.000188,28,1,2703,0.458502,3004,0.192776,49,0.000188L1I1Zv7a2,0,0,1,0,0.000188P0.25A0,0.000188,11,1,722,0.707107,0,0.707107,58,0.000188L1I1Zv1w0a1f5.666667P0.25Zv0w8a1,0,1,0,0,0f0,1,0,1,0,0b0.16A0,1,0,1,0,1,0,1,731,1L1O2,3,4,5,6,7o22Z", /* 206: DX7 BRASS 7 */ "v2a0.162105,0,0,1,0,0P0.25A0,0.000188,102,1,144,0.040526,0,0.040526,383,0.000188L1I3.15Zv3a0.64842,0,0,1,0,0P0.25A0,0.000188,2,0.018581,0,0.037163,24,0.040526,383,0.000188L1I1Zv4a0.297302,0,0,1,0,0P0.25A0,0.000188,459,1,276,0.458502,1624,0.192776,156,0.000188L1I1Zv5a2,0,0,1,0,0P0.25A0,0.000188,11,1,1529,0.32421,0,0.32421,298,0.000188L1I1Zv6a0.420448,0,0,1,0,0P0.25A0,0.000188,459,1,276,0.458502,1624,0.192776,156,0.000188L1I1Zv7a1.414214,0,0,1,0,0P0.25A0,0.000188,11,1,1529,0.32421,0,0.32421,298,0.000188L1I1Zv1w4a1f5.166667P0.25Zv0w8a1,0,1,0,0,0f0,1,0,1,0,0.000505b0.16A0,1,0,1,0,1,0,1,731,1L1O2,3,4,5,6,7o8Z", /* 207: DX7 BRASS 8 */ "v2a0.458502,0,0,1,0,0P0.25A0,0.000188,162,1,532,0.385553,567,0.229251,451,0.000188L1I0.5Zv3a2,0,0,1,0,0P0.25A0,0.000188,40,1,1235,0.020263,44735,0.000188,370,0.000188L1I0.5Zv4a2,0,0,1,0,0P0.25A0,0.000188,10,1,1235,0.020263,44735,0.000188,370,0.000188L1I0.5Zv5a2,0,0,1,0,0P0.25A0,0.000188,22,1,1235,0.020263,44735,0.000188,330,0.000188L1I1Zv6a0.64842,0,0,1,0,0P0.25A0,0.000188,9,1,1235,0.020263,44735,0.000188,185,0.000188L1I0.5Zv7a2,0,0,1,0,0P0.25A0,0.000188,32,1,1235,0.020263,44735,0.000188,147,0.000188L1I0.5Zv1w0a1f5.833333P0.25Zv0w8a1,0,1,0,0,0f0,1,0,1,0,0b0.16A0,1,0,1,0,1,0,1,731,1L1O2,3,4,5,6,7o22Z", /* 208: DX7 RECORDER */ "v2a0.840896,0,0,1,0,1P0.25A0,0.000188,3,1,0,0.771105,12,0.125,75000,0.000188L1I2Zv3a0.594604,0,0,1,0,0P0.25A0,0.000188,114,1,9000,0.458502,1676,0.840896,59,0.000188L1I1Zv4a0.917004,0,0,1,0,0P0.25A0,0.000188,22,1,0,0.771105,10,0.176777,79000,0.000188L1I2.0175Zv5a2,0,0,1,0,0P0.25A0,0.000188,91,1,9000,0.458502,1676,0.840896,59,0.000188L1I1.01Zv6a0.917004,0,0,1,0,0P0.25A0,0.000188,12,1,0,0.771105,10,0.176777,79000,0.000188L1I1.9825Zv7a2,0,0,1,0,0P0.25A0,0.000188,81,1,9000,0.458502,1676,0.840896,59,0.000188L1I1Zv1w0a1f6.166667P0.25Zv0w8a1,0,1,0,0,0f0,1,0,1,0,0.019192b0.04A0,1,0,1,0,1,0,1,12000,1L1O2,3,4,5,6,7o6Z", /* 209: DX7 HARMONICA1 */ "v2a0.013139,0,0,1,0,0P0.25A0,0.000188,0,1,1548,0.0625,0,0.017039,80,0.000188L1I7.62Zv3a0.074325,0,0,1,0,0P0.25A0,0.000188,15,0.917004,9,0.000188,0,0.917004,151,0.000188L1I5.04375Zv4a0.192776,0,0,1,0,0P0.25A0,0.000188,239,0.420448,19440,0.000448,0,0.007812,74,0.000188L1I0.505Zv5a2,0,0,1,0,0P0.25A0,0.000188,42,0.545254,15,0.353553,6591,0.000188,73,0.000188L1I1Zv6a0.000377,0,0,1,0,0.000188P0.25A0,0.000188,239,0.420448,19440,0.000448,0,0.007812,74,0.000188L1I1Zv7a0.000377,0,0,1,0,0P0.25A0,0.000188,42,0.545254,15,0.353553,6591,0.000188,73,0.000188L1I0.495625Zv1w0a1f7P0.25Zv0w8a1,0,1,0,0,0f0,1,0,1,0,0.005152b0.16A0,1,0,1,0,1,0,1,731,1L1O2,3,4,5,6,7o1Z", /* 210: DX7 HRMNCA2 BC */ "v2a0.013139,0,0,1,0,0.034078P0.25A0,0.000188,0,1,1548,0.0625,0,0.017039,80,0.000188L1I7.62Zv3a0.074325,0,0,1,0,0.034078P0.25A0,0.000188,15,0.917004,9,0.000188,0,0.917004,151,0.000188L1I5.04375Zv4a0.192776,0,0,1,0,0.034078P0.25A0,0.000188,239,0.420448,19440,0.000448,0,0.007812,74,0.000188L1I0.505Zv5a2,0,0,1,0,0.034078P0.25A0,0.000188,42,0.545254,12,1,0,1,121,0.000188L1I1Zv6a2,0,0,1,0,0.034078P0.25A0,0.000188,53,0.420448,19440,0.000448,0,0.007812,74,0.000188L1I1Zv7a2,0,0,1,0,0.034078P0.25A0,0.000188,42,0.545254,15,0.353553,6591,0.000188,73,0.000188L1I0.495625Zv1w0a1f7P0.25Zv0w8a1,0,1,0,0,0f0,1,0,1,0,0.005152b0.16A0,1,0,1,0,1,0,1,731,1L1O2,3,4,5,6,7o1Z", /* 211: DX7 VOICE 2 */ "v2a0.028656,0,0,1,0,0P0.25A0,0.000188,0,1,0,1,0,1,24362,0.000188L1I4.085Zv3a0.068157,0,0,1,0,0P0.25A0,0.000188,459,1,565,0.081052,400,0.026278,78,0.000188L1I1.00875Zv4a2,0,0,1,0,0P0.25A0,0.000411,4,0.32421,31,0.081052,69,0.057313,22800,0.000411L1I1.02375Zv5a2,0,0,1,0,0P0.25A0,0.000188,114,1,902,0.64842,7,0.840896,950,0.000188L1I1.00875Zv6a2,0,0,1,0,0.000224P0.25A0,0.037163,0,0.037163,14,0.088388,10,0.297302,2531,0.037163L1I1Zv7a0.707107,0,0,1,0,0P0.25A0,0.000188,40,1,902,0.64842,7,0.840896,267,0.000188L1I0.99125Zv1w4a1f5.833333P0.25Zv0w8a1,0,1,0,0,0f0,1,0,1,0,0.027294b0.16A0,1,137,0.957603,36,1.021897,3,1,731,1L1O2,3,4,5,6,7o7Z", /* 212: DX7 VOICE 3 */ "v2a0.545254,0,0,1,0,0P0.25A0,0.000188,846,0.018581,2,0.011049,46,0.00657,10089,0.000188L1I2.0425Zv3a2,0,0,1,0,0P0.25A0,0.000188,818,1,1461,0.458502,153,0.297302,117,0.000188L1I2.0175Zv4a1.090508,0,0,1,0,0P0.25A0,0.000411,949,0.012049,291,0.028656,660,0.001065,4400,0.000411L1I1.02375Zv5a2,0,0,1,0,0P0.25A0,0.000188,818,1,902,0.64842,7,0.840896,2119,0.000188L1I1.00875Zv6a0.040526,0,0,1,0,0.000224P0.25A0,0.010132,0,0.010132,125,0.024097,10,0.088388,2637,0.010132L1I2Zv7a2,0,0,1,0,0P0.25A0,0.000188,818,1,902,0.64842,7,0.840896,267,0.000188L1I0.99125Zv1w4a1f5.833333P0.25Zv0w8a1,0,1,0,0,0f0,1,0,1,0,0.012407b0.16A0,1,137,0.957603,36,1.021897,3,1,731,1L1O2,3,4,5,6,7o5Z", /* 213: DX7 GLOKENSPL */ "v2a0.192776,0,0,1,0,0P0.25A0,0.000188,0,0.771105,55,0.162105,9176,0.000188,208,0.000188L1I16Zv3a0.148651,0,0,1,0,0P0.25A0,0.000188,0,1,68,0.000188,0,0.000188,1,0.000188L1I4Zv4a1.681793,0,0,1,0,0P0.25A0,0.000188,0,0.229251,18,0.012049,48000,0.000188,1,0.000188L1I8Zv5a2,0,0,1,0,0P0.25A0,0.000188,0,1,35,0.210224,561,0.000188,1469,0.000188L1I1Zv6a0.458502,0,0,1,0,0P0.25A0,0.000188,0,0.192776,48,0.125,275,0.0625,67000,0.000188L1I8Zv7a2,0,0,1,0,0P0.25A0,0.000188,0,1,61,0.545254,5575,0.000188,523,0.000188L1I1Zv1w0a1f5.666667P0.25Zv0w8a1,0,1,0,0,0f0,1,0,1,0,0b0.16A0,1,0,1,0,1,0,1,731,1L1O2,3,4,5,6,7o7Z", /* 214: DX7 VIBE 2 */ "v2a0.840896,0,0,1,0,0P0.25A0,0.000188,1,1,1853,0.015625,2762,0.000188,370,0.000188L1I9.9Zv3a0.5,0,0,1,0,0P0.25A0,0.000188,0,1,184,0.003012,0,0.000188,370,0.000188L1I3.9975Zv4a0.034078,0,0,1,0,0P0.25A0,0.000188,114,1,0,0.458502,10588,0.000188,930,0.000188L1I9.8525Zv5a2,0,0,1,0,0P0.25A0,0.000188,2,1,0,0.458502,10588,0.000188,930,0.000188L1I1.00875Zv6a0.026278,0,0,1,0,0P0.25A0,0.000188,102,1,0,0.458502,10588,0.000188,930,0.000188L1I5Zv7a2,0,0,1,0,0P0.25A0,0.000188,2,1,0,0.458502,10588,0.000188,930,0.000188L1I0.99125Zv1w4a1f5.333333P0.25Zv0w8a1,0,1,0,0,0f0,1,0,1,0,0b0.005A0,1,0,1,0,1,0,1,731,1L1O2,3,4,5,6,7o5Z", /* 215: DX7 XYLOPHONE */ "v2a0.25,0,0,1,0,0P0.25A0,0.000188,12896,0.162105,0,0.162105,270,0.000188,60000,0.000188L1I4Zv3a0.353553,0,0,1,0,0P0.25A0,0.000188,0,0.771105,1,0.162105,270,0.000188,60000,0.000188L1I0.5Zv4a1.29684,0,0,1,0,0P0.25A0,0.000188,0,0.229251,14,0.012049,48000,0.000188,19868,0.000188L1I3Zv5a2,0,0,1,0,0P0.25A0,0.000188,0,1,43,0.545254,638,0.000188,1043,0.000188L1I0.5Zv6a2,0,0,1,0,0P0.25A0,0.000188,0,0.229251,18,0.012049,48000,0.000188,60000,0.000188L1I3Zv7a2,0,0,1,0,0P0.25A0,0.000188,0,1,96,0.545254,638,0.000188,262,0.000188L1I0.5Zv1w0a1f5.666667P0.25Zv0w8a1,0,1,0,0,0f0,1,0,1,0,0b0.00125A0,1,0,1,0,1,0,1,731,1L1O2,3,4,5,6,7o7Z", /* 216: DX7 CHIMES */ "v2a0.114626,0,0,1,0,0P0.25A0,0.000188,0,1,1624,0.458502,1805,0.192776,3088,0.000188L1I5Zv3a0.545254,0,0,1,0,0P0.25A0,0.000188,0,0.000188,0,0.458502,1805,0.192776,3459,0.000188L1I2.5075Zv4a0.125,0,0,1,0,0P0.25A0,0.000188,0,1,1624,0.458502,1805,0.192776,3088,0.000188L1I6Zv5a0.420448,0,0,1,0,0P0.25A0,0.000188,0,0.000188,0,0.458502,1805,0.192776,7561,0.000188L1I2.98875Zv6a0.420448,0,0,1,0,0P0.25A0,0.000188,0,1,1624,0.458502,1805,0.192776,3088,0.000188L1I8Zv7a0.25,0,0,1,0,0P0.25A0,0.000188,0,1,1624,0.458502,1805,0.192776,7561,0.000188L1I4Zv1w5a1f10P0.25Zv0w8a1,0,1,0,0,0f0,1,0,1,0,0b0.16A0,1,0,1,0,1,0,1,731,1L1O2,3,4,5,6,7o6Z", /* 217: DX7 GONG 1 */ "v2a0.00852,0,0,1,0,0P0.25A0,0.000188,1210,0.32421,463,0.771105,59169,0.000188,19868,0.000188L1I1.2Zv3a0.458502,0,0,1,0,0P0.25A0,0.000188,3062,0.707107,484,0.353553,26138,0.000188,13333,0.000188L1I1.4Zv4a0.545254,0,0,1,0,0P0.25A0,0.000188,3062,0.707107,484,0.353553,26138,0.000188,8759,0.000188L1I3Zv5a0.229251,0,0,1,0,0P0.25A0,0.000188,2237,0.353553,0,0.353553,26138,0.000188,1311,0.000188L1I0.745Zv6a0.192776,0,0,1,0,0P0.25A0,0.000188,1,1,378,0.707107,9747,0.00657,2484,0.000188L1I0.8Zv7a2,0,0,1,0,0P0.25A0,0.000188,1,1,378,0.707107,9747,0.00657,2221,0.000188L1I0.5Zv1w1a1f5.833333P0.25Zv0w8a1,0,1,0,0,0f0,1,0,1,0,0b0.04A0,1,0,1,0,1,0,1,731,1L1O2,3,4,5,6,7o16Z", /* 218: DX7 GONG 2 */ "v2a0.105112,0,0,1,0,0P0.25A0,0.000188,169,0.32421,463,0.771105,59169,0.000188,16327,0.000188L1I14.4Zv3a0.125,0,0,1,0,0P0.25A0,0.000188,170,0.707107,484,0.353553,26138,0.000188,28743,0.000188L1I5.6Zv4a0.105112,0,0,1,0,0P0.25A0,0.000188,2,0.707107,484,0.353553,26138,0.000188,7058,0.000188L1I3.78Zv5a0.088388,0,0,1,0,0P0.25A0,0.000188,382,0.707107,484,0.353553,537,0.000188,7058,0.000188L1I9.24Zv6a0.048194,0,0,1,0,0P0.25A0,0.000188,1031,1,217,0.297302,7942,0.00657,9111,0.000188L1I1Zv7a2,0,0,1,0,0P0.25A0,0.000188,3,1,378,0.707107,9747,0.00657,712,0.000188L1I1Zv1w0a1f5.833333P0.25Zv0w8a1,0,1,0,0,0f0,1,0,1,0,0b0.16A0,1,0,1,0,1,0,1,731,1L1O2,3,4,5,6,7o17Z", /* 219: DX7 BELLS */ "v2a0.229251,0,0,1,0,0P0.25A0,0.000188,0,1,5606,0.001642,0,0.000188,7866,0.000188L1I3.15375Zv3a0.024097,0,0,1,0,0P0.25A0,0.000188,0,1,5606,0.001642,0,0.000188,9745,0.000188L1I0.504375Zv4a0.353553,0,0,1,0,0P0.25A0,0.000188,0,1,5606,0.001642,7511,0.000188,6329,0.000188L1I1.17125Zv5a0.420448,0,0,1,0,0P0.25A0,0.000188,0,1,5606,0.001642,0,0.000188,4066,0.000188L1I3.15Zv6a1.189207,0,0,1,0,0P0.25A0,0.000188,0,1,5606,0.001642,0,0.000188,4066,0.000188L1I1.18Zv7a2,0,0,1,0,0P0.25A0,0.000188,0,1,5606,0.001642,0,0.000188,4066,0.000188L1I0.5Zv1w2a1f4.166667P0.25Zv0w8a1,0,1,0,0,0f0,1,0,1,0,0b0.04A0,1,3,0.978572,7,1.021897,7,1,731,1L1O2,3,4,5,6,7o27Z", /* 220: DX7 COW BELL */ "v2a0.229251,0,0,1,0,0P0.25A0,0.000188,0,1,2,0.771105,0,0.420448,3848,0.000188L1I8Zv3a2,0,0,1,0,0P0.25A0,0.000188,0,1,2,0.458502,556,0.000188,587,0.000188L1I1Zv4a0.385553,0,0,1,0,0P0.25A0,0.000188,0,1,0,0.771105,7,0.840896,4194,0.000188L1I4Zv5a2,0,0,1,0,0f524.80746P0.25A0,0.000188,0,1,108,0.000188,0,0.000188,370,0.000188L1Zv6a2,0,0,1,0,0P0.25A0,0.000188,0,0.162105,0,0.125,463,0.000188,2594,0.000188L1I7Zv7a2,0,0,1,0,0P0.25A0,0.000188,0,1,98,0.458502,556,0.000188,370,0.000188L1I1Zv1w0a1f5.666667P0.25Zv0w8a1,0,1,0,0,0f0,1,0,1,0,0b0.00125A0,1,0,1,0,1,0,1,731,1L1O2,3,4,5,6,7o6Z", /* 221: DX7 BLOCK */ "v2a0.353553,0,0,1,0,0P0.25A0,0.000188,0,1,1,0.458502,624,0.000188,58,0.000188L1I17Zv3a0.044194,0,0,1,0,0P0.25A0,0.000188,0,1,0,0.458502,624,0.000188,58,0.000188L1I5Zv4a0.105112,0,0,1,0,0P0.25A0,0.000188,0,1,1,0.458502,78,0.000188,58,0.000188L1I5Zv5a0.162105,0,0,1,0,0P0.25A0,0.000188,0,1,0,0.458502,17,0.000188,58,0.000188L1I5Zv6a0.353553,0,0,1,0,0P0.25A0,0.000188,0,0.034078,0,0.458502,98,0.000188,58,0.000188L1I5Zv7a1.681793,0,0,1,0,0P0.25A0,0.000188,0,1,347,0.458502,1109,0.000188,58,0.000188L1I1Zv1w0a1f5.666667P0.25Zv0w8a1,0,1,0,0,0f0,1,0,1,0,0b0.16A0,1,0,1,0,1,0,1,731,1L1O2,3,4,5,6,7o18Z", /* 222: DX7 FLEXATONE */ "v2a0.64842,0,0,1,0,0P0.25A0,0.000188,0,1,21,0.000188,0,0.000188,32,0.000188L1I16.21875Zv3a0.136313,0,0,1,0,0P0.25A0,0.000188,1,1,86,0.000188,0,0.000188,6329,0.000188L1I20.425Zv4a0.028656,0,0,1,0,0P0.25A0,0.000188,0,1,3822,0.000188,0,0.000188,4545,0.000188L1I7Zv5a2,0,0,1,0,0P0.25A0,0.000188,0,1,864,0.000188,0,0.000188,1647,0.000188L1I2Zv6a0.176777,0,0,1,0,0P0.25A0,0.000188,0,1,6,0.000188,0,0.000188,60000,0.000188L1I5Zv7a2,0,0,1,0,0P0.25A0,0.000188,0,1,96,0.000188,0,0.000188,1,0.000188L1I3Zv1w0a1f7.166667P0.25Zv0w8a1,0,1,0,0,0f0,1,0,1,0,0.438865b0.08A0,1,0,1,0,1,0,1,179,1L1O2,3,4,5,6,7o7Z", /* 223: DX7 LOG DRUM */ "v2a0.000896,0,0,1,0,0P0.25A0,0.000188,45,1,0,0.840896,179,0.068157,1182,0.000188L1I2.0425Zv3a1.834008,0,0,1,0,0P0.25A0,0.000188,3,0.353553,5,0.001953,166,0.000188,1043,0.000188L1I1.03875Zv4a1.834008,0,0,1,0,0P0.25A0,0.000188,0,0.771105,169,0.001953,166,0.000188,1043,0.000188L1I1.02375Zv5a2,0,0,1,0,0P0.25A0,0.000188,2,1,12997,0.001953,166,0.000188,1043,0.000188L1I0.5Zv6a2,0,0,1,0,0P0.25A0,0.000188,0,1,27,0.000188,0,0.000188,2068,0.000188L1I0.5Zv7a2,0,0,1,0,0P0.25A0,0.000188,1,1,864,0.000188,0,0.000188,587,0.000188L1I0.5Zv1w4a1f6P0.25Zv0w8a1,0,1,0,0,0f0,1,0,1,0,0.024381b0.04A0,1,0,1,0,1,0,1,179,1L1O2,3,4,5,6,7o14Z", /* 224: DX7 SYN-LEAD 2 */ "v2a0.272627,0,0,1,0,0P0.25A0,0.000188,0,1,666,0.024097,0,0.024097,30,0.000188L1I2Zv3a1.834008,0,0,1,0,0P0.25A0,0.000188,0,1,3,0.385553,0,0.771105,52,0.000188L1I1Zv4a2,0,0,1,0,0P0.25A0,0.000188,0,1,3,0.385553,0,0.771105,52,0.000188L1I1Zv5a2,0,0,1,0,0P0.25A0,0.000188,0,1,3,0.385553,0,0.771105,52,0.000188L1I1Zv6a0.32421,0,0,1,0,0P0.25A0,0.000188,0,1,666,0.024097,0,0.024097,30,0.000188L1I2Zv7a1.189207,0,0,1,0,0P0.25A0,0.000188,0,1,3,0.385553,0,0.771105,52,0.000188L1I1Zv1w0a1f6.166667P0.25Zv0w8a1,0,1,0,0,0f0,1,0,1,0,0b0.16A0,1,0,1,0,1,0,1,731,1L1O2,3,4,5,6,7o22Z", /* 225: DX7 SYN-LEAD 3 */ "v2a0.32421,0,0,1,0,0P0.25A0,0.000188,0,1,666,0.024097,1930,0.000188,32,0.000188L1I2Zv3a0.5,0,0,1,0,0P0.25A0,0.000188,0,1,3,0.385553,0,0.771105,52,0.000188L1I1Zv4a2,0,0,1,0,0P0.25A0,0.000188,0,1,3,0.385553,0,0.771105,52,0.000188L1I2Zv5a2,0,0,1,0,0P0.25A0,0.000188,0,1,3,0.385553,0,0.771105,52,0.000188L1I2Zv6a1.681793,0,0,1,0,0P0.25A0,0.000188,0,1,666,0.024097,1930,0.000188,32,0.000188L1I2Zv7a1.189207,0,0,1,0,0P0.25A0,0.000188,0,1,3,0.385553,0,0.007164,23,0.000188L1I1Zv1w0a1f6.166667P0.25Zv0w8a1,0,1,0,0,0f0,1,0,1,0,0b0.16A0,1,0,1,0,1,0,1,731,1L1O2,3,4,5,6,7o22Z", /* 226: DX7 SYN-LEAD 4 */ "v2a0.272627,0,0,1,0,0P0.25A0,0.000188,0,1,666,0.024097,0,0.024097,30,0.000188L1I1Zv3a1.834008,0,0,1,0,0P0.25A0,0.000188,0,1,3,0.385553,0,0.771105,52,0.000188L1I1Zv4a2,0,0,1,0,0P0.25A0,0.000188,0,1,3,0.385553,0,0.771105,52,0.000188L1I1Zv5a2,0,0,1,0,0P0.25A0,0.000188,0,1,3,0.385553,0,0.771105,52,0.000188L1I1Zv6a0.32421,0,0,1,0,0P0.25A0,0.000188,0,1,666,0.024097,0,0.024097,30,0.000188L1I1Zv7a1.189207,0,0,1,0,0P0.25A0,0.000188,0,1,3,0.385553,0,0.771105,52,0.000188L1I1Zv1w0a1f6.166667P0.25Zv0w8a1,0,1,0,0,0f0,1,0,1,0,0b0.16A0,1,0,1,0,1,0,1,731,1L1O2,3,4,5,6,7o22Z", /* 227: DX7 SYN-LEAD 5 */ "v2a0.148651,0,0,1,0,0P0.25A0,0.000188,0,1,0,1,99000,0.000188,523,0.000188L1I7Zv3a0.297302,0,0,1,0,0P0.25A0,0.000188,0,1,0,1,99000,0.000188,104,0.000188L1I3Zv4a0.64842,0,0,1,0,0P0.25A0,0.000188,0,1,0,1,99000,0.000188,104,0.000188L1I1Zv5a2,0,0,1,0,0P0.25A0,0.000188,0,1,4666,0.162105,40747,0.000188,104,0.000188L1I2Zv6a0.458502,0,0,1,0,0P0.25A0,0.000188,1424,0.771105,18,1,14000,0.297302,73,0.000188L1I3Zv7a2,0,0,1,0,0P0.25A0,0.000188,1424,0.771105,18,1,14000,0.297302,1,0.000188L1I3Zv1w0a1f5.833333P0.25Zv0w8a1,0,1,0,0,0f0,1,0,1,0,0.035855b0.16A0,1,0,1,0,1,0,1,179,1L1O2,3,4,5,6,7o1Z", /* 228: DX7 SYN-CLAV 1 */ "v2a0.385553,0,0,1,0,0P0.25A0,0.000188,0,1,372,0.037163,3937,0.009291,24,0.000188L1I21Zv3a0.017039,0,0,1,0,0P0.25A0,0.000188,0,1,372,0.037163,3937,0.009291,24,0.000188L1I1Zv4a0.044194,0,0,1,0,0P0.25A0,0.000188,0,1,710,0.081052,1968,0.040526,33,0.000188L1I12Zv5a0.545254,0,0,1,0,0P0.25A0,0.000188,0,1,372,0.037163,3937,0.009291,24,0.000188L1I3Zv6a0.32421,0,0,1,0,0P0.25A0,0.000188,0,1,372,0.037163,3937,0.009291,24,0.000188L1I2Zv7a2,0,0,1,0,0P0.25A0,0.000188,0,1,796,0.081052,3691,0.022097,30,0.000188L1I1Zv1w0a1f6.166667P0.25Zv0w8a1,0,1,0,0,0f0,1,0,1,0,0b0.16A0,1,0,1,0,1,0,1,731,1L1O2,3,4,5,6,7o16Z", /* 229: DX7 SYN-CLAV 2 */ "v2a0.229251,0,0,1,0,0P0.25A0,0.000188,1,0.385553,430,0.00852,6,0.001642,43,0.000188L1I9.9625Zv3a0.420448,0,0,1,0,0P0.25A0,0.000188,1,0.385553,1077,0.00852,6,0.001642,43,0.000188L1I1Zv4a1.681793,0,0,1,0,0P0.25A0,0.000188,40,0.385553,1077,0.00852,6,0.001642,43,0.000188L1I0.5025Zv5a1.834008,0,0,1,0,0P0.25A0,0.000188,0,1,4,0.420448,1,0.917004,170,0.000188L1I0.499375Zv6a2,0,0,1,0,0P0.25A0,0.000188,40,0.385553,1077,0.00852,6,0.001642,43,0.000188L1I0.5Zv7a2,0,0,1,0,0P0.25A0,0.000188,0,1,4,0.420448,1,0.917004,170,0.000188L1I1Zv1w4a1f5P0.25Zv0w8a1,0,1,0,0,0f0,1,0,1,0,0b0.04A0,1,0,1,0,1,0,1,179,1L1O2,3,4,5,6,7o7Z", /* 230: DX7 SYN-CLAV 3 */ "v2a0.162105,0,0,1,0,1P0.25A0,0.000188,0,0.148651,7075,0.015625,2080,0.385553,5333,0.000188L1I12.045Zv3a0.385553,0,0,1,0,1P0.25A0,0.000188,0,1,2953,0.353553,2403,0.176777,1540,0.000188L1I12Zv4a1.542211,0,0,1,0,0P0.25A0,0.000188,0,1,3809,0.297302,1582,0.771105,5818,0.000188L1I0.5025Zv5a2,0,0,1,0,1P0.25A0,0.000188,0,1,984,0.707107,6152,0.081052,68,0.000188L1I1.00375Zv6a2,0,0,1,0,1P0.25A0,0.000188,2,1,8628,0.297302,812,0.192776,4848,0.000188L1I1Zv7a2,0,0,1,0,0P0.25A0,0.000188,2,1,193,0.707107,1111,0.458502,87,0.000188L1I1Zv1w5a1f6.833333P0.25Zv0w8a1,0,1,0,0,0f0,1,0,1,0,0b0.005A0,1,0,1,0,1,0,1,179,1L1O2,3,4,5,6,7o2Z", /* 231: DX7 SYN-PIANO */ "v2a0.545254,0,0,1,0,0P0.25A0,0.003012,2,0.385553,13,0.000188,0,0.000188,0,0.003012L1I23.20125Zv3a2,0,0,1,0,0P0.25A0,0.000188,0,1,2531,0.125,7911,0.000188,370,0.000188L1I0.99125Zv4a2,0,0,1,0,0P0.25A0,0.074325,0,1,12,0.000188,0,0.000188,0,0.074325L1I2Zv5a2,0,0,1,0,0P0.25A0,0.000188,0,1,2531,0.125,7911,0.000188,208,0.000188L1I1Zv6a1.189207,0,0,1,0,0P0.25A0,0.000188,4126,1,0,1,0,1,24,0.000188L1I1Zv7a2,0,0,1,0,0P0.25A0,0.000188,0,1,2531,0.125,7911,0.000188,233,0.000188L1I1.00875Zv1w3a1f50.29P0.25Zv0w8a1,0,1,0,0,0f0,1,0,1,0,0b0.16A0,1,0,1,0,1,0,1,731,1L1O2,3,4,5,6,7o5Z", /* 232: DX7 SYNBRASS 1 */ "v2a0.5,0,0,1,0,0P0.25A0,0.000188,0,0.917004,0,0.917004,454,0.545254,71,0.000188L1I0.5Zv3a2,0,0,1,0,0P0.25A0,0.000188,0,1,30,0.917004,0,0.917004,53,0.000188L1I0.500625Zv4a2,0,0,1,0,0P0.25A0,0.000188,0,1,30,0.917004,0,0.917004,53,0.000188L1I0.49875Zv5a2,0,0,1,0,0P0.25A0,0.000188,0,1,0,0.917004,0,0.917004,53,0.000188L1I0.498125Zv6a1,0,0,1,0,0P0.25A0,0.000188,1206,0.545254,446,0.707107,444,0.594604,50,0.000188L1I0.504375Zv7a2,0,0,1,0,0P0.25A0,0.000188,0,1,3,0.385553,0,0.771105,52,0.000188L1I1.00875Zv1w0a1f6.166667P0.25Zv0w8a1,0,1,0,0,0f0,1,0,1,0,0b0.16A0,1,0,1,0,1,0,1,731,1L1O2,3,4,5,6,7o22Z", /* 233: DX7 SYNBRASS 2 */ "v2a0.771105,0,0,1,0,0P0.25A0,0.000188,18,1,0,1,206,0.594604,4,0.000188L1I1Zv3a2,0,0,1,0,0P0.25A0,0.000188,2,1,0,0.917004,0,0.917004,4,0.000188L1I1Zv4a2,0,0,1,0,0P0.25A0,0.000188,1,1,0,0.917004,0,0.917004,4,0.000188L1I1Zv5a1.834008,0,0,1,0,0P0.25A0,0.000188,2,1,0,1,0,0.917004,4,0.000188L1I1Zv6a1.090508,0,0,1,0,0P0.25A0,0.000188,45,1,0,1,92,0.272627,3,0.000188L1I0.504375Zv7a2,0,0,1,0,0P0.25A0,0.000188,2,1,0,1,0,0.917004,4,0.000188L1I1.00875Zv1w4a1f6.833333P0.25Zv0w8a1,0,1,0,0,0f0,1,0,1,0,0.004963b0.08A0,1,0,1,0,1,0,1,179,1L1O2,3,4,5,6,7o22Z", /* 234: DX7 SYNORGAN 1 */ "v2a0.5,0,0,1,0,0P0.25A0,0.000188,0,1,173,0.00426,54,0.002762,16,0.000188L1I20Zv3a1.834008,0,0,1,0,0P0.25A0,0.000188,18,1,0,1,0,1,54,0.000188L1I4Zv4a2,0,0,1,0,0P0.25A0,0.000188,18,1,0,1,0,1,54,0.000188L1I2Zv5a2,0,0,1,0,0P0.25A0,0.000188,18,1,0,1,0,1,54,0.000188L1I1Zv6a0.32421,0,0,1,0,0P0.25A0,0.000188,0,1,666,0.024097,0,0.024097,30,0.000188L1I1Zv7a2,0,0,1,0,0P0.25A0,0.000188,0,1,3,0.385553,0,0.771105,52,0.000188L1I3Zv1w0a1f6.166667P0.25Zv0w8a1,0,1,0,0,0f0,1,0,1,0,0b0.16A0,1,0,1,0,1,0,1,731,1L1O2,3,4,5,6,7o22Z", /* 235: DX7 SYNORGAN 2 */ "v2a0.25,0,0,1,0,0P0.25A0,0.000188,10,1,0,1,12979,0.000188,233,0.000188L1I0.99875Zv3a2,0,0,1,0,0P0.25A0,0.272627,4,1,0,1,14453,0.000188,31,0.272627L1I0.5Zv4a2,0,0,1,0,0P0.25A0,0.000188,0,0.000188,7,0.707107,303,0.458502,98,0.000188L1I0.5Zv5a0.297302,0,0,1,0,0P0.25A0,0.000188,7352,1,0,1,10443,0.000188,233,0.000188L1I9Zv6a2,0,0,1,0,0P0.25A0,0.000188,7352,1,0,1,0,1,385,0.000188L1I0.5Zv7a1.189207,0,0,1,0,0P0.25A0,0.000188,0,0.000188,7,0.707107,193,0.458502,98,0.000188L1I8.02Zv1w0a1f5.666667P0.25Zv0w8a1,0,1,0,0,0f0,1,0,1,0,0b0.02A0,1,0,1,0,1,0,1,731,1L1O2,3,4,5,6,7o3Z", /* 236: DX7 SYN-VOX */ "v2a0.000377,0,0,1,0,0P0.25A0,0.000188,0,1,11825,0.000896,131,0.000821,822,0.000188L1I0.499375Zv3a0.000377,0,0,1,0,0.0625P0.25A0,0.000188,0,1,11825,0.000896,131,0.000821,822,0.000188L1I0.50125Zv4a0.000377,0,0,1,0,0P0.25A0,0.000188,0,1,99,0.000896,131,0.000821,822,0.000188L1I1Zv5a2,0,0,1,0,0P0.25A0,0.000188,173,0.917004,60,0.000188,0,0.000188,9,0.000188L1I2.005Zv6a2,0,0,1,0,0P0.25A0,0.000188,43,0.052556,636,0.000188,16,1,86,0.000188L1I2.0225Zv7a2,0,0,1,0,0P0.25A0,0.000188,43,0.052556,4,0.176777,8,1,96,0.000188L1I1.9825Zv1w4a1f5.333333P0.25Zv0w8a1,0,1,0,0,0f0,1,0,1,0,0.01803b0.08A0,1,73,0.917004,24,0.937084,8,1,179,1L1O2,3,4,5,6,7o25Z", /* 237: DX7 SYN-ORCH */ "v2a0.25,0,0,1,0,0P0.25A0,0.707107,0,1,0,1,0,1,43,0.707107L1I2Zv3a0.25,0,0,1,0,0P0.25A0,0.000188,128,1,0,1,0,1,1087,0.000188L1I2Zv4a2,0,0,1,0,0P0.25A0,0.000188,72,1,0,1,850,0.458502,1754,0.000188L1I2Zv5a1.834008,0,0,1,0,0P0.25A0,0.000188,102,1,17,0.917004,58,0.707107,1851,0.000188L1I4.035Zv6a1.834008,0,0,1,0,0P0.25A0,0.000188,459,1,0,1,850,0.458502,1754,0.000188L1I2.0175Zv7a2,0,0,1,0,0P0.25A0,0.000188,459,1,17,0.917004,58,0.707107,1851,0.000188L1I0.99125Zv1w4a1f5.5P0.25Zv0w8a1,0,1,0,0,0f0,1,0,1,0,0.010217b0.16A0,1,0,1,0,1,0,1,179,1L1O2,3,4,5,6,7o25Z", /* 238: DX7 SYN-BASS 1 */ "v2a0.25,0,0,1,0,0P0.25A0,0.000188,25,1,661,0.096388,0,0.096388,3485,0.000188L1I1.00875Zv3a0.32421,0,0,1,0,0P0.25A0,0.000188,0,1,611,0.088388,738,0.048194,35,0.000188L1I1.00875Zv4a2,0,0,1,0,0P0.25A0,0.000188,0,1,3,0.385553,0,0.771105,2,0.000188L1I1.00875Zv5a0.5,0,0,1,0,0P0.25A0,0.000188,0,1,611,0.088388,738,0.048194,2206,0.000188L1I1Zv6a0.272627,0,0,1,0,0P0.25A0,0.000188,25,1,661,0.096388,0,0.096388,628,0.000188L1I1Zv7a2,0,0,1,0,0P0.25A0,0.000188,0,1,3,0.385553,0,0.771105,2,0.000188L1I2Zv1w4a1f6.166667P0.25Zv0w8a1,0,1,0,0,0f0,1,0,1,0,0b0.16A0,1,0,1,0,1,0,1,731,1L1O2,3,4,5,6,7o3Z", /* 239: DX7 SYN-BASS 2 */ "v2a0.385553,0,0,1,0,0P0.25A0,0.000188,0,1,21,0.917004,1355,0.081052,38,0.000188L1I0.5Zv3a2,0,0,1,0,0P0.25A0,0.000188,0,1,21,0.917004,1355,0.081052,38,0.000188L1I0.500625Zv4a2,0,0,1,0,0P0.25A0,0.000188,0,1,21,0.917004,1355,0.081052,38,0.000188L1I0.49875Zv5a2,0,0,1,0,0P0.25A0,0.000188,0,1,21,0.917004,1355,0.081052,38,0.000188L1I0.99625Zv6a0.840896,0,0,1,0,0P0.25A0,0.000188,0,1,21,0.917004,1355,0.081052,685,0.000188L1I0.504375Zv7a2,0,0,1,0,0P0.25A0,0.000188,0,1,105,0.917004,2953,0.081052,121,0.000188L1I2.0175Zv1w0a1f6.166667P0.25Zv0w8a1,0,1,0,0,0f0,1,0,1,0,0b0.08A0,1,0,1,0,1,0,1,731,1L1O2,3,4,5,6,7o9Z", /* 240: DX7 HARP-FLUTE */ "v2a2,0,0,1,0,0.044194P0.25A0,0.000188,0,1,10,0.004645,105,0.001065,69,0.000188L1I9Zv3a0.297302,0,0,1,0,0P0.25A0,0.000188,289,1,246,0.917004,12,0.771105,333,0.000188L1I1Zv4a1.189207,0,0,1,0,0P0.25A0,0.000188,459,1,246,0.917004,12,0.771105,333,0.000188L1I0.99125Zv5a0.771105,0,0,1,0,0P0.25A0,0.000188,0,1,309,0.013139,1,0.000188,2068,0.000188L1I3Zv6a0.114626,0,0,1,0,0P0.25A0,0.000188,0,1,449,0.081052,1,0.000188,4545,0.000188L1I2Zv7a2,0,0,1,0,0P0.25A0,0.000188,0,1,999,0.081052,4242,0.000188,2594,0.000188L1I1.00875Zv1w0a1f6.666667P0.25Zv0w8a1,0,1,0,0,0f0,1,0,1,0,0b0.16A0,1,0,1,0,1,0,1,731,1L1O2,3,4,5,6,7o3Z", /* 241: DX7 BELL-FLUTE */ "v2a0.272627,0,0,1,0,0P0.25A0,0.000188,1,1,6659,0.028656,6118,0.000188,659,0.000188L1I8.04Zv3a1.090508,0,0,1,0,0P0.25A0,0.000188,0,0.000188,0,0.917004,2690,0.000188,659,0.000188L1I1Zv4a0.272627,0,0,1,0,0P0.25A0,0.000188,1,0.545254,5522,0.028656,6118,0.000188,659,0.000188L1I5.985Zv5a1.681793,0,0,1,0,0P0.25A0,0.000188,0,0.000188,0,1,2718,0.000188,659,0.000188L1I1.00875Zv6a0.210224,0,0,1,0,0P0.25A0,0.000188,52,0.105112,152,0.707107,2320,0.105112,1788,0.000188L1I1.0025Zv7a2,0,0,1,0,0P0.25A0,0.000188,57,1,3106,0.028656,1267,0.000188,587,0.000188L1I0.99125Zv1w0a1f5.833333P0.25Zv0w8a1,0,1,0,0,0f0,1,0,1,0,0.00202b0.00125A0,1,0,1,0,1,0,1,731,1L1O2,3,4,5,6,7o5Z", /* 242: DX7 E.P-BRS BC */ "v2a0.32421,0,0,1,0,0.000188P0.25A0,0.000188,0,1,0,1,105,0.917004,382,0.000188L1I1Zv3a2,0,0,1,0,0.000188P0.25A0,0.000188,7,1,0,1,0,1,273,0.000188L1I1Zv4a0.014328,0,0,1,0,0P0.25A0,0.000188,0,1,312,0.210224,29509,0.000188,233,0.000188L1I14Zv5a1.29684,0,0,1,0,0P0.25A0,0.000188,0,1,1608,0.192776,14441,0.000188,233,0.000188L1I1.00875Zv6a0.272627,0,0,1,0,0P0.25A0,0.000188,0,1,24000,0.125,7911,0.000188,233,0.000188L1I1Zv7a1.414214,0,0,1,0,0P0.25A0,0.000188,0,1,3146,0.125,7911,0.000188,233,0.000188L1I1Zv1w0a1f5.666667P0.25Zv0w8a1,0,1,0,0,0f0,1,0,1,0,0b0.16A0,1,0,1,0,1,0,1,731,1L1O2,3,4,5,6,7o5Z", /* 243: DX7 T.BL-EXPA */ "v2a0.917004,0,0,1,0,0P0.25A0,0.000188,4631,1,0,1,7600,0.192776,6060,0.000188L1I1.005Zv3a2,0,0,1,0,0P0.25A0,0.000188,364,1,0,1,27000,0.096388,2482,0.000188L1I0.995Zv4a0.25,0,0,1,0,0P0.25A0,0.000188,0,1,39600,0.000188,0,0.000188,4545,0.000188L1I3.495Zv5a1.414214,0,0,1,0,0P0.25A0,0.000188,0,1,4280,0.000188,0,0.000188,6329,0.000188L1I0.99375Zv6a0.458502,0,0,1,0,0P0.25A0,0.000188,0,1,6709,0.000188,0,0.000188,4545,0.000188L1I3.5075Zv7a1.414214,0,0,1,0,0P0.25A0,0.000188,0,1,17871,0.000188,0,0.000188,6329,0.000188L1I1.0025Zv1w0a1f5.833333P0.25Zv0w8a1,0,1,0,0,0f0,1,0,1,0,0b0.04A0,1,0,1,0,1,0,1,731,1L1O2,3,4,5,6,7o5Z", /* 244: DX7 CHIME-STRG */ "v2a0.229251,0,0,1,0,0P0.25A0,0.000188,0,1,0,1,0,1,99000,0.000188L1I0.495625Zv3a2,0,0,1,0,0P0.25A0,0.000188,409,1,0,1,0,1,3822,0.000188L1I0.504375Zv4a0.162105,0,0,1,0,0P0.25A0,0.000188,0,0.000188,2,0.081052,3792,0.000188,14765,0.000188L1I13Zv5a1.681793,0,0,1,0,0P0.25A0,0.000188,0,1,0,1,3046,0.000188,2068,0.000188L1I2Zv6a0.594604,0,0,1,0,0P0.25A0,0.000188,0,1,0,1,0,1,99000,0.000188L1I0.503125Zv7a2,0,0,1,0,0P0.25A0,0.000188,409,1,0,1,0,1,3822,0.000188L1I1.00625Zv1w4a1f4.5P0.25Zv0w8a1,0,1,0,0,0f0,1,0,1,0,0.013737b0.16A0,1,0,1,0,1,0,1,179,1L1O2,3,4,5,6,7o5Z", /* 245: DX7 B.DRM-SNAR */ "v2a2,0,0,1,0,0f3715.352291P0.25A0,0.000188,0,1,0,1,0,1,99000,0.000188L1Zv3a0.917004,0,0,1,0,0P0.25A0,0.000188,0,1,2,0.420448,173,0.000188,370,0.000188L1I0.5Zv4a2,0,0,1,0,0f158.489319P0.25A0,0.000188,0,1,117,0.192776,1240,0.000188,659,0.000188L1Zv5a1.29684,0,0,1,0,0f6.702703P0.25A0,0.000188,0,1,1,0.458502,3102,0.000188,165,0.000188L1Zv6a1.834008,0,0,1,0,0f10.086721P0.25A0,0.000188,0,1,273,0.000188,0,0.000188,60000,0.000188L1Zv7a2,0,0,1,0,0f81.283052P0.25A0,0.000188,0,1,611,0.000188,0,0.000188,92,0.000188L1Zv1w1a1f9.166667P0.25Zv0w8a1,0,1,0,0,0f0,1,0,1,0,0b0.16A0,1,0,1,0,1,0,1,731,1L1O2,3,4,5,6,7o3Z", /* 246: DX7 SHIMMER */ "v2a0.176777,0,0,1,0,0P0.25A0,0.000188,0,1,654,0.192776,14441,0.000188,233,0.000188L1I1.43Zv3a1.681793,0,0,1,0,0P0.25A0,0.000188,0,1,654,0.192776,14441,0.000188,233,0.000188L1I1.43Zv4a0.057313,0,0,1,0,0P0.25A0,0.000188,0,1,8,0.192776,80000,0.000188,233,0.000188L1I15Zv5a1.681793,0,0,1,0,0P0.25A0,0.000188,0,1,1151,0.192776,80000,0.000188,233,0.000188L1I0.955Zv6a0.162105,0,0,1,0,0P0.25A0,0.000188,0,1,881,0.32421,86000,0.000188,233,0.000188L1I0.95Zv7a2,0,0,1,0,0P0.25A0,0.000188,0,1,654,0.192776,23000,0.026278,222,0.000188L1I0.955Zv1w1a1f8.333333P0.25Zv0w8a1,0,1,0,0,0f0,1,0,1,0,0.106551b0.08A0,1,0,1,0,1,0,1,731,1L1O2,3,4,5,6,7o5Z", /* 247: DX7 EVOLUTION */ "v2a1.834008,0,0,1,0,0.000188P0.25A0,0.000188,45,1,19,0.001953,166,0.000188,1043,0.000188L1I1.07125Zv3a1.681793,0,0,1,0,0.000188P0.25A0,0.000188,45,1,4,0.707107,587,0.000188,1043,0.000188L1I0.499375Zv4a2,0,0,1,0,0.000188P0.25A0,0.000188,6550,1,650,0.353553,49,0.176777,1373,0.000188L1I0.505625Zv5a2,0,0,1,0,0P0.25A0,0.000188,6550,1,650,0.353553,49,0.176777,1373,0.000188L1I0.5Zv6a0.594604,0,0,1,0,0P0.25A0,0.000188,6550,1,650,0.353553,49,0.176777,1373,0.000188L1I0.505625Zv7a2,0,0,1,0,0P0.25A0,0.000188,6550,1,650,0.353553,49,0.176777,1373,0.000188L1I0.504375Zv1w4a1f0.064P0.25Zv0w8a1,0,1,0,0,0f0,1,0,1,0,0b0.16A0,1,0,1,0,1,0,1,179,1L1O2,3,4,5,6,7o1Z", /* 248: DX7 WATER GDN */ "v2a2,0,0,1,0,0P0.25A0,0.000188,0,0.000188,0,1,193,0.000188,10,0.000188L1I12Zv3a1.189207,0,0,1,0,0P0.25A0,0.000188,0,0.000188,0,1,193,0.000188,11,0.000188L1I6Zv4a1.414214,0,0,1,0,0P0.25A0,0.000188,0,0.000188,0,1,193,0.000188,11,0.000188L1I3Zv5a2,0,0,1,0,0P0.25A0,0.000188,0,0.000188,0,1,193,0.000188,16,0.000188L1I2Zv6a2,0,0,1,0,0P0.25A0,0.000188,0,0.000188,0,1,193,0.000188,29,0.000188L1I1.5Zv7a2,0,0,1,0,0P0.25A0,0.000188,0,0.000188,0,1,193,0.000188,65,0.000188L1I1Zv1w4a1f6P0.25Zv0w8a1,0,1,0,0,0f0,1,0,1,0,0.000505b0.01A0,1,0,1,0,1,0,1,731,1L1O2,3,4,5,6,7o32Z", /* 249: DX7 WASP STING */ "v2a0.385553,0,0,1,0,0P0.25A0,0.000188,28,1,2703,0.458502,3004,0.192776,49,0.000188L1I1.01Zv3a2,0,0,1,0,0P0.25A0,0.000188,11,1,1624,0.458502,1805,0.192776,49,0.000188L1I1.00375Zv4a1.681793,0,0,1,0,0P0.25A0,0.000188,11,1,1624,0.458502,1805,0.192776,49,0.000188L1I1Zv5a2,0,0,1,0,0P0.25A0,0.000188,11,1,1624,0.458502,1805,0.192776,17,0.000188L1I0.5Zv6a2,0,0,1,0,0P0.25A0,0.000188,6550,1,1624,0.458502,1805,0.192776,3088,0.000188L1I0.5Zv7a0.5,0,0,1,0,0P0.25A0,0.000188,515,1,1624,0.458502,929,1,9357,0.000188L1I1Zv1w5a1f10P0.25Zv0w8a1,0,1,0,0,0f0,1,0,1,0,0b0.16A0,1,0,1,0,1,0,1,731,1L1O2,3,4,5,6,7o18Z", /* 250: DX7 LASER GUN */ "v2a0.545254,0,0,1,0,0P0.25A0,0.000188,1637,1,16079,0.000188,0,1,7500,0.000188L1I0.505Zv3a1.834008,0,0,1,0,0P0.25A0,0.000188,0,1,15,0.000188,0,0.917004,53,0.000188L1I0.505Zv4a0.074325,0,0,1,0,0P0.25A0,0.000188,0,1,15,0.000188,0,0.917004,53,0.000188L1I2.22Zv5a0.105112,0,0,1,0,0P0.25A0,0.000188,0,1,15,0.000188,0,0.917004,53,0.000188L1I17.17Zv6a0.64842,0,0,1,0,0P0.25A0,0.000188,0,1,232,0.003012,5,1,1721,0.000188L1I19.38Zv7a2,0,0,1,0,0P0.25A0,0.000188,0,1,2425,0.000188,0,0.000188,416,0.000188L1I5Zv1w3a1f7.166667P0.25Zv0w8a1,0,1,0,0,0f0,1,0,1,0,1.194688b0.16A0,2.043794,1122,1.138789,120,6.170625,191,0.897355,602,2.043794L1O2,3,4,5,6,7o31Z", /* 251: DX7 DESCENT */ "v2a0.297302,0,0,1,0,0.000188P0.25A0,0.000188,6550,1,0,1,99000,0.000188,60000,0.000188L1I8.01Zv3a0.096388,0,0,1,0,0.000188P0.25A0,0.000188,6550,1,0,1,99000,0.000188,60000,0.000188L1I0.99875Zv4a0.272627,0,0,1,0,0.000188P0.25A0,0.000188,6550,1,0,1,99000,0.000188,60000,0.000188L1I3.00375Zv5a2,0,0,1,0,0P0.25A0,0.000188,919,1,0,1,39600,0.000188,3636,0.000188L1I0.5Zv6a1.414214,0,0,1,0,0P0.25A0,0.000188,6550,1,0,1,99000,0.000188,60000,0.000188L1I0.505625Zv7a2,0,0,1,0,0P0.25A0,0.000188,919,1,0,1,47427,0.000188,3636,0.000188L1I0.504375Zv1w0a1f6.5P0.25Zv0w8a1,0,1,0,0,0f0,1,0,1,0,0.025253b0.16A0,1,93,1.915207,1875,1,0,1,186,1L1O2,3,4,5,6,7o1Z", /* 252: DX7 OCTAVE WAR */ "v2a0.148651,0,0,1,0,0P0.25A0,0.00029,5,1,0,1,30,0.917004,1146,0.00029L1I0.500625Zv3a0.096388,0,0,1,0,0P0.25A0,0.00029,2,1,0,1,30,0.917004,1146,0.00029L1I1.00125Zv4a0.017039,0,0,1,0,0P0.25A0,0.000188,114,1,8111,0.096388,17,0.420448,6742,0.000188L1I8Zv5a2,0,0,1,0,0P0.25A0,0.000188,114,1,8111,0.096388,17,0.420448,6742,0.000188L1I2Zv6a1.189207,0,0,1,0,0P0.25A0,0.000188,114,1,8111,0.096388,17,0.420448,6742,0.000188L1I3Zv7a2,0,0,1,0,0P0.25A0,0.000188,114,1,8111,0.096388,17,0.420448,6742,0.000188L1I3Zv1w1a1f3.5P0.25Zv0w8a1,0,1,0,0,0f0,1,0,1,0,0.70706b0.08A0,1,0,1,0,1,0,1,186,1L1O2,3,4,5,6,7o7Z", /* 253: DX7 GRAND PRIX */ "v2a0.385553,0,0,1,0,0P0.25A0,0.000188,369,0.229251,2273,0.068157,1665,0.000188,3636,0.000188L1I0.5Zv3a0.044194,0,0,1,0,0P0.25A0,0.000188,65,0.229251,3610,0.040526,13,0.007164,1816,0.000188L1I0.496875Zv4a2,0,0,1,0,0P0.25A0,0.000188,289,1,1500,0.068157,9,0.000188,3636,0.000188L1I0.5Zv5a2,0,0,1,0,0P0.25A0,0.000188,64,1,948,0.297302,3481,0.017039,3151,0.000188L1I0.5Zv6a0.840896,0,0,1,0,0P0.25A0,0.000188,0,0.074325,92,0.385553,10564,0.03125,1815,0.000188L1I2Zv7a1.090508,0,0,1,0,0P0.25A0,0.000188,1031,1,10394,0.003906,1263,0.00213,173,0.000188L1I4Zv1w0a1f50.29P0.25Zv0w8a1,0,1,0,0,0f0,1,0,1,0,0b0.16A0,0.048389,9275,15.657153,63,2.612474,1683,0.382779,34,0.048389L1O2,3,4,5,6,7o17Z", /* 254: DX7 ST.HELENS */ "v2a1.542211,0,0,1,0,0P0.25A0,0.420448,1126,1,17871,0.000188,0,1,2004,0.420448L1I0.745Zv3a1.834008,0,0,1,0,0P0.25A0,0.458502,6818,0.000188,0,0.000188,0,1,2000,0.458502L1I0.6Zv4a1.189207,0,0,1,0,0P0.25A0,0.420448,4308,0.000188,0,0.000188,0,1,1805,0.420448L1I0.615Zv5a1.681793,0,0,1,0,0P0.25A0,0.297302,13805,0.000188,0,0.000188,0,1,2805,0.297302L1I0.545Zv6a1.090508,0,0,1,0,0P0.25A0,0.297302,70,1,25166,0.001381,7616,0.000188,1852,0.297302L1I0.515Zv7a2,0,0,1,0,0P0.25A0,0.32421,67,1,25166,0.001381,7616,0.000188,427,0.32421L1I0.5Zv1w0a1f0.064P0.25Zv0w8a1,0,1,0,0,0f0,1,0,1,0,0b0.16A0,0.346878,37,0.048389,9,0.105447,12,0.231848,9,0.346878L1O2,3,4,5,6,7o17Z", /* 255: DX7 EXPLOSION */ "v2a2,0,0,1,0,0P0.25A0,0.000188,0,1,2,0.297302,85000,0.000188,60000,0.000188L1I0.515Zv3a0.068157,0,0,1,0,0P0.25A0,0.000188,0,1,43,0.707107,11176,0.000188,24000,0.000188L1I8.3825Zv4a2,0,0,1,0,0P0.25A0,0.000188,0,1,43,0.707107,11176,0.000188,31344,0.000188L1I0.51Zv5a0.5,0,0,1,0,0P0.25A0,0.000188,0,0.297302,99,1,10443,0.000188,26295,0.000188L1I0.654375Zv6a0.458502,0,0,1,0,0f100P0.25A0,0.000188,0,1,37,0.594604,13577,0.000188,14765,0.000188L1Zv7a0.162105,0,0,1,0,0P0.25A0,0.000188,0,1,0,1,11647,0.000188,21858,0.000188L1I0.495625Zv1w4a1f50.29P0.25Zv0w8a1,0,1,0,0,0f0,1,0,1,0,0b0.01A0,1,0,1,0,1,0,1,12000,1L1O2,3,4,5,6,7o16Z", /* 256: dpwe piano */ "k0Zv0w11a1,0,0,0p0Z", /* 257: amyboard default */ "v0w20F200.0,1.0,,,5.0R0.7A0,1,1000,0.2,100,0B0,1,1000,0.2,1000,0c2L1G4Zv2w1a,,0,0c3L1Zv3w2a,,0,0f220.0L1Zv1w4a,,0f4.0,0,,,,,0A0,1.0,10000,0Zx0,0,0k0,,0.5,0.5Z", }; const uint16_t patch_oscs[258] PROGMEM = { 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,25,4, }; #endif ================================================ FILE: src/pcm.c ================================================ // pcm.c #include "amy.h" #include "transfer.h" #ifdef __EMSCRIPTEN__ #include "emscripten.h" #endif #ifdef AMY_DAISY #define malloc_caps(a, b) qspi_malloc(a) #define free(a) qspi_free(a) #endif // This is for any in-memory PCM samples. typedef struct { uint8_t type; char filename[MAX_FILENAME_LEN]; uint8_t channels; uint32_t file_handle; uint32_t file_bytes_remaining; int16_t * sample_ram; uint32_t length; uint32_t loopstart; uint32_t loopend; uint8_t midinote; uint32_t samplerate; float log2sr; } memorypcm_preset_t; // linked list of memorypcm presets typedef struct memorypcm_ll_t{ memorypcm_preset_t *preset; struct memorypcm_ll_t *next; uint16_t preset_number; } memorypcm_ll_t; memorypcm_ll_t * memorypcm_ll_start; #define PCM_AMY_LOG2_SAMPLE_RATE log2f(PCM_AMY_SAMPLE_RATE / ZERO_LOGFREQ_IN_HZ) // Get either memory preset, file preset or baked in preset for preset number. // For ROM presets, fill the caller-provided rom_local and return it. memorypcm_preset_t * get_preset_for_preset_number(uint16_t preset_number, memorypcm_preset_t *rom_local) { // Get the memory preset. If we can't find it, it could be a ROM preset. So copy params in from ROM preset memorypcm_ll_t *preset = memorypcm_ll_start; while(preset != NULL) { if(preset->preset_number == preset_number) { if(preset->preset->sample_ram != NULL || preset->preset->file_handle > 0) { return preset->preset; } } preset = preset->next; } // No memory preset found, so try ROM preset. default to 0 if out of range if (preset_number >= pcm_samples) preset_number = 0; if (rom_local == NULL) { return NULL; } memset(rom_local, 0, sizeof(*rom_local)); const pcm_map_t cpreset = pcm_map[preset_number]; uint32_t offset = cpreset.offset; uint32_t length = cpreset.length; #ifdef PCM_LENGTH if (offset >= PCM_LENGTH) { offset = 0; length = 0; } else if (length > (PCM_LENGTH - offset)) { length = PCM_LENGTH - offset; } #endif rom_local->sample_ram = (int16_t*)pcm + offset; rom_local->length = length; rom_local->loopstart = cpreset.loopstart; rom_local->loopend = cpreset.loopend; if (rom_local->loopstart > rom_local->length) { rom_local->loopstart = 0; } if (rom_local->loopend > rom_local->length) { rom_local->loopend = rom_local->length; } rom_local->midinote = cpreset.midinote; rom_local->samplerate = PCM_AMY_SAMPLE_RATE; rom_local->log2sr = PCM_AMY_LOG2_SAMPLE_RATE; rom_local->type = AMY_PCM_TYPE_ROM; rom_local->channels = 1; return rom_local; } const int16_t *pcm_get_sample_ram_for_preset(uint16_t preset_number, uint32_t *length) { memorypcm_preset_t rom_local; memorypcm_preset_t *preset = get_preset_for_preset_number(preset_number, &rom_local); if (length != NULL) { *length = (preset != NULL) ? preset->length : 0; } if (preset == NULL) { return NULL; } return preset->sample_ram; } void pcm_init() { memorypcm_ll_start = NULL; } void pcm_deinit() { pcm_unload_all_presets(); } // How many bits used for fractional part of PCM table index. #define PCM_INDEX_FRAC_BITS 8 // The number of bits used to hold the table index. #define PCM_INDEX_BITS (31 - PCM_INDEX_FRAC_BITS) static void fclose_if_file(memorypcm_preset_t *preset) { if (preset == NULL) { return; } if (preset->type == AMY_PCM_TYPE_FILE && preset->file_handle != 0 && amy_global.config.amy_external_fclose_hook != NULL) { amy_global.config.amy_external_fclose_hook(preset->file_handle); preset->file_handle = 0; } } void pcm_note_on(uint16_t osc) { if(AMY_IS_SET(synth[osc]->preset)) { memorypcm_preset_t rom_local; memorypcm_preset_t *preset = get_preset_for_preset_number(synth[osc]->preset, &rom_local); if (preset->type == AMY_PCM_TYPE_FILE) { if (preset->file_handle != 0) { wave_info_t info = {0}; uint32_t data_bytes = 0; amy_global.config.amy_external_fseek_hook(preset->file_handle, 0); if (wave_parse_header(preset->file_handle, &info, &data_bytes)) { preset->channels = info.channels; preset->samplerate = info.sample_rate; preset->log2sr = log2f((float)info.sample_rate / ZERO_LOGFREQ_IN_HZ); preset->file_bytes_remaining = data_bytes; } else { amy_global.config.amy_external_fclose_hook(preset->file_handle); } } } else if (preset->type == AMY_PCM_TYPE_ROM) { // baked-in PCM - don't overrun. if(synth[osc]->preset >= pcm_samples) synth[osc]->preset = 0; } synth[osc]->phase = 0; // s16.15 index into the table; as if a PHASOR into a 16 bit sample table. // Special case: We use the msynth feedback flag to indicate note-off for looping PCM. As a result, it's explicitly NOT set in amy:hold_and_modify for PCM voices. Set it here. msynth[osc]->feedback = synth[osc]->feedback; // Make sure PCM waveforms are excluded from auto-termination, so we don't cut-off samples with silent gaps. synth[osc]->terminate_on_silence = 0; } } void pcm_mod_trigger(uint16_t osc) { pcm_note_on(osc); } void pcm_note_off(uint16_t osc) { if(AMY_IS_SET(synth[osc]->preset)) { uint32_t length = 0; memorypcm_preset_t rom_local; memorypcm_preset_t *preset = get_preset_for_preset_number(synth[osc]->preset, &rom_local); if(preset != NULL) { length = preset->length; } if(msynth[osc]->feedback == 0) { // Non-looping note: Set phase to the end to cause immediate stop. synth[osc]->phase = F2P(length / (float)(1 << PCM_INDEX_BITS)); } else { // Looping is requested, disable future looping, sample will play through to end. // (sending a second note-off will stop it immediately). msynth[osc]->feedback = 0; } } } uint32_t fill_sample_from_file(memorypcm_preset_t *preset_p, uint32_t frames_needed) { //fprintf(stderr, "fsff %ld frames\n", frames_needed); uint32_t bytes_per_frame = preset_p->channels * 2; uint32_t frames_available = 0; if (bytes_per_frame > 0) { frames_available = preset_p->file_bytes_remaining / bytes_per_frame; } if (frames_available > 0 && frames_needed > frames_available) { frames_needed = frames_available; } uint32_t frames_read = wave_read_pcm_frames_s16( preset_p->file_handle, preset_p->channels, &preset_p->file_bytes_remaining, preset_p->sample_ram, frames_needed); return frames_read; } SAMPLE render_pcm(SAMPLE* buf, uint16_t osc) { if(AMY_IS_SET(synth[osc]->preset)) { SAMPLE max_value = 0; memorypcm_preset_t rom_local; memorypcm_preset_t *preset = get_preset_for_preset_number(synth[osc]->preset, &rom_local); float logfreq = msynth[osc]->logfreq; // If osc[midi_note] is set, shift the freq by the preset's default base_note. if (AMY_IS_SET(synth[osc]->midi_note)) { logfreq -= logfreq_for_midi_note(preset->midinote); } float playback_freq = freq_of_logfreq(preset->log2sr + logfreq); uint32_t sample_length = preset->length; if (preset->type == AMY_PCM_TYPE_FILE) { float frames_per_output = playback_freq / (float)AMY_SAMPLE_RATE; uint32_t frames_needed = (uint32_t)ceilf(frames_per_output * AMY_BLOCK_SIZE) + 1; uint32_t max_frames = AMY_BLOCK_SIZE * PCM_FILE_BUFFER_MULT; if (frames_needed > max_frames) { frames_needed = max_frames; } sample_length = fill_sample_from_file(preset, frames_needed); if(sample_length != frames_needed) { // reached end of file synth[osc]->status = SYNTH_OFF; } synth[osc]->phase = 0; } if (preset->sample_ram == NULL || sample_length == 0) { synth[osc]->status = SYNTH_OFF; return 0; } SAMPLE amp = F2S(msynth[osc]->amp); PHASOR step = F2P((playback_freq / (float)AMY_SAMPLE_RATE) / (float)(1 << PCM_INDEX_BITS)); const LUTSAMPLE* table = preset->sample_ram; uint32_t base_index = INT_OF_P(synth[osc]->phase, PCM_INDEX_BITS); for(uint16_t i=0; i < AMY_BLOCK_SIZE; i++) { SAMPLE frac = S_FRAC_OF_P(synth[osc]->phase, PCM_INDEX_BITS); LUTSAMPLE b = 0; LUTSAMPLE c = 0; uint32_t next_index = base_index + 1; if (base_index >= sample_length) { if (preset->type != AMY_PCM_TYPE_FILE) { synth[osc]->status = SYNTH_OFF; } buf[i] = 0; continue; } if (preset->channels == 2) { uint32_t base_offset = base_index * 2; uint32_t next_offset = next_index * 2; if (synth[osc]->wave == PCM_LEFT) { b = table[base_offset]; c = (next_index < sample_length) ? table[next_offset] : b; } else if (synth[osc]->wave == PCM_RIGHT) { b = table[base_offset + 1]; c = (next_index < sample_length) ? table[next_offset + 1] : b; } else { // PCM or PCM_MIX LUTSAMPLE bl = table[base_offset]; LUTSAMPLE br = table[base_offset + 1]; b = (LUTSAMPLE)(((int32_t)bl + (int32_t)br) / 2); if (next_index < sample_length) { LUTSAMPLE cl = table[next_offset]; LUTSAMPLE cr = table[next_offset + 1]; c = (LUTSAMPLE)(((int32_t)cl + (int32_t)cr) / 2); } else { c = b; } } } else { b = table[base_index]; c = (next_index < sample_length) ? table[next_index] : b; } SAMPLE sample = L2S(b) + MUL4_SS(L2S(c - b), frac); synth[osc]->phase = P_WRAPPED_SUM(synth[osc]->phase, step); base_index = INT_OF_P(synth[osc]->phase, PCM_INDEX_BITS); if(preset->type != AMY_PCM_TYPE_FILE) { // For non-file samples, we have to check for end of sample/looping. if(base_index >= sample_length) { // end synth[osc]->status = SYNTH_OFF;// is this right? sample = 0; } else { if(msynth[osc]->feedback > 0) { // still looping. The feedback flag is cleared by pcm_note_off. if(base_index >= preset->loopend) { // loopend // back to loopstart int32_t loop_len = preset->loopend - preset->loopstart; synth[osc]->phase -= F2P(loop_len / (float)(1 << PCM_INDEX_BITS)); base_index -= loop_len; } } } } SAMPLE value = buf[i] + MUL4_SS(amp, sample); buf[i] = value; if (value < 0) value = -value; if (value > max_value) max_value = value; } //printf("render_pcm: osc %d preset %d len %d base_ix %d phase %f step %f tablestep %f amp %f\n", // osc, synth[osc]->preset, preset->length, base_index, P2F(synth[osc]->phase), P2F(step), (1 << PCM_INDEX_BITS) * P2F(step), S2F(msynth[osc]->amp)); return max_value; // i don't believe we ever need to detect silence in a sample. it will shut itself off at the end. } return 0; } SAMPLE compute_mod_pcm(uint16_t osc) { if(AMY_IS_SET(synth[osc]->preset)) { SAMPLE buf[AMY_BLOCK_SIZE]; memset(buf, 0, sizeof(buf)); render_pcm(buf, osc); return buf[0]; } return 0; } int pcm_load_file() { // We pass the inputs to this as aliases in the amy_global structure. This is to not destroy the MP heap for amy->AMYboard uint8_t midinote = amy_global.transfer_stored_bytes; uint16_t preset_number = amy_global.transfer_file_handle; char * filename = amy_global.transfer_filename; pcm_unload_preset(preset_number); if (filename == NULL || filename[0] == '\0') { return 0; } if (amy_global.config.amy_external_fopen_hook == NULL || amy_global.config.amy_external_fclose_hook == NULL) { fprintf(stderr, "fopen hook not enabled on platform\n"); return 0; } uint32_t handle = amy_global.config.amy_external_fopen_hook((char *)filename, "rb"); if (handle == 0) { fprintf(stderr, "Could not open file %s\n", filename); return 0; } wave_info_t info = {0}; uint32_t data_bytes = 0; if (!wave_parse_header(handle, &info, &data_bytes)) { fprintf(stderr, "Could not parse WAVE file %s\n", filename); amy_global.config.amy_external_fclose_hook(handle); return 0; } uint32_t total_frames = 0; if (info.channels > 0) { total_frames = data_bytes / (info.channels * 2); } uint32_t buffer_frames = AMY_BLOCK_SIZE * PCM_FILE_BUFFER_MULT; memorypcm_ll_t *new_preset_pointer = malloc_caps( sizeof(memorypcm_ll_t) + sizeof(memorypcm_preset_t) + buffer_frames * sizeof(int16_t), amy_global.config.ram_caps_sample); if (new_preset_pointer == NULL) { fprintf(stderr, "No RAM left for sample load\n"); return 0; } new_preset_pointer->next = memorypcm_ll_start; memorypcm_ll_start = new_preset_pointer; new_preset_pointer->preset_number = preset_number; memorypcm_preset_t *memory_preset = (memorypcm_preset_t *)(((uint8_t *)new_preset_pointer) + sizeof(memorypcm_ll_t)); strncpy(memory_preset->filename, filename, MAX_FILENAME_LEN - 1); memory_preset->filename[MAX_FILENAME_LEN - 1] = '\0'; memory_preset->channels = info.channels; memory_preset->samplerate = info.sample_rate; memory_preset->log2sr = log2f((float)info.sample_rate / ZERO_LOGFREQ_IN_HZ); memory_preset->midinote = midinote; memory_preset->length = total_frames; memory_preset->type = AMY_PCM_TYPE_FILE; memory_preset->file_bytes_remaining = total_frames * info.channels * 2; memory_preset->file_handle = handle; memory_preset->sample_ram = malloc_caps(buffer_frames * info.channels * sizeof(int16_t), amy_global.config.ram_caps_sample); new_preset_pointer->preset = memory_preset; //fprintf(stderr, "read file %s frames %ld channels %d preset %d handle %ld\n", filename, total_frames, info.channels, preset_number, handle); return 1; } // load mono samples (let python parse wave files) into preset # // set loopstart, loopend, midinote, samplerate (and log2sr) // return the allocated sample ram that AMY will fill in. int16_t * pcm_load(uint16_t preset_number, uint32_t length, uint32_t samplerate, uint8_t channels, uint8_t midinote, uint32_t loopstart, uint32_t loopend) { // if preset was already a memorypcm, we need to unload it pcm_unload_preset(preset_number); // this is a no-op if preset doesn't exist or is a const pcm // now alloc a new LL entry and preset (the old LL entry is removed with pcm_unload_preset) memorypcm_ll_t *new_preset_pointer = malloc_caps(sizeof(memorypcm_ll_t) + sizeof(memorypcm_preset_t) + length * channels * sizeof(int16_t), amy_global.config.ram_caps_sample); if(new_preset_pointer == NULL) { fprintf(stderr, "No RAM left for sample load\n"); return NULL; // no ram for sample } new_preset_pointer->next = memorypcm_ll_start; memorypcm_ll_start = new_preset_pointer; new_preset_pointer->preset_number = preset_number; memorypcm_preset_t *memory_preset = (memorypcm_preset_t *)(((uint8_t *)new_preset_pointer) + sizeof(memorypcm_ll_t)); memory_preset->samplerate = samplerate; memory_preset->log2sr = log2f((float)samplerate / ZERO_LOGFREQ_IN_HZ); memory_preset->midinote = midinote; memory_preset->loopstart = loopstart; memory_preset->length = length; memory_preset->channels = channels; memory_preset->filename[0] = '\0'; memory_preset->file_bytes_remaining = 0; memory_preset->file_handle = 0; memory_preset->type = AMY_PCM_TYPE_MEMORY; memory_preset->sample_ram = (int16_t *)(((uint8_t *)memory_preset) + sizeof(memorypcm_preset_t)); if(loopend == 0) { // loop whole sample memory_preset->loopend = memory_preset->length-1; } else { memory_preset->loopend = loopend; } new_preset_pointer->preset = memory_preset; return memory_preset->sample_ram; } void pcm_unload_preset(uint16_t preset_number) { // run through the LL looking for the preset memorypcm_ll_t **preset_pointer = &memorypcm_ll_start; while(*preset_pointer != NULL) { if((*preset_pointer)->preset_number == preset_number) { memorypcm_ll_t *next = (*preset_pointer)->next; fclose_if_file((*preset_pointer)->preset); // free the memory we allocated free((*preset_pointer)); // close up the list *preset_pointer = next; return; } else { preset_pointer = &(*preset_pointer)->next; } } //fprintf(stderr, "pcm_unload_preset: preset %d not found\n", preset_number); // This happens during a routine load_preset. } void pcm_unload_all_presets() { memorypcm_ll_t *preset_pointer = memorypcm_ll_start; while(preset_pointer != NULL) { memorypcm_ll_t *next_pointer = preset_pointer->next; fclose_if_file(preset_pointer->preset); free(preset_pointer); // Go to the next one preset_pointer = next_pointer; } memorypcm_ll_start = NULL; } ================================================ FILE: src/pcm_samples_tiny.h ================================================ // Automatically generated by amy.headers.generate_pcm_header() #ifndef __PCM_SAMPLES_H #define __PCM_SAMPLES_H const int16_t pcm[PCM_LENGTH] PROGMEM = { 82 ,48 ,-109 ,502 ,-495 ,385 ,214 ,-610 ,749 ,-167 ,135 ,108 ,-91 ,167 ,32 , 96 ,-13 ,132 ,44 ,45 ,-18 ,192 ,-254 ,583 ,-211 ,-76 ,132 ,-487 ,1097 ,-848 , 574 ,-167 ,184 ,1311 ,-3163 ,2080 ,732 ,-2546 ,2752 ,-980 ,-253 ,853 ,-1204 ,1787 ,-565 , -1805 ,2327 ,900 ,-3597 ,2184 ,680 ,-1069 ,1340 ,-991 ,680 ,-1211 ,2841 ,-1441 ,-2795 ,3186 , -421 ,-279 ,653 ,-697 ,700 ,-251 ,-372 ,2193 ,-1105 ,-1536 ,-952 ,2070 ,-161 ,1113 ,-1097 , 1934 ,-1327 ,-5113 ,6662 ,-2278 ,207 ,916 ,-1072 ,951 ,-848 ,978 ,-786 ,81 ,1895 ,-2657 , -719 ,2298 ,-120 ,293 ,-1565 ,687 ,1117 ,221 ,-2211 ,324 ,3128 ,-2481 ,-1337 ,2425 ,-731 , 649 ,-689 ,2631 ,-2503 ,-2924 ,4460 ,-865 ,-134 ,-669 ,4032 ,-5652 ,982 ,3285 ,-4224 ,6732 , -5206 ,648 ,-234 ,-1498 ,3759 ,-2578 ,3727 ,-4096 ,2959 ,-2670 ,-1506 ,4868 ,-3426 ,3068 ,-3726 , 2605 ,-313 ,-927 ,830 ,191 ,960 ,-3681 ,3823 ,-2200 ,1533 ,-29 ,-2088 ,2620 ,-1670 ,1474 , -1169 ,1037 ,-925 ,1233 ,100 ,-1751 ,1939 ,-3518 ,10322 ,-9046 ,-5297 ,7888 ,-5388 ,8250 ,-6162 , 4389 ,-463 ,-26 ,-1139 ,-8670 ,11455 ,-6103 ,6886 ,-7099 ,3 ,6326 ,-6474 ,5657 ,-5024 ,4035 , -3586 ,3552 ,-3101 ,1786 ,2206 ,-6366 ,7610 ,-8748 ,6942 ,-2041 ,-104 ,1027 ,-1002 ,3949 ,-8958 , 10099 ,-8910 ,6197 ,1216 ,-4584 ,2007 ,-4932 ,11157 ,-11829 ,8060 ,-1979 ,-479 ,2483 ,-4040 ,3958 , -4249 ,8533 ,-10486 ,3998 ,3112 ,-2907 ,-123 ,-2768 ,3913 ,3694 ,-5488 ,-1966 ,5673 ,-2613 ,5587 , -9982 ,3090 ,6373 ,-8467 ,8836 ,-1909 ,-10788 ,9555 ,-1492 ,-232 ,428 ,-325 ,3489 ,-9007 ,7896 , -2153 ,-954 ,3047 ,-1955 ,4354 ,-3037 ,-3723 ,2139 ,12 ,-8037 ,3569 ,15255 ,-11727 ,-4798 ,9750 , -5038 ,3685 ,-3110 ,534 ,-869 ,10001 ,-9418 ,-12877 ,18241 ,-4854 ,384 ,1211 ,-3488 ,3368 ,909 , -8079 ,10924 ,-720 ,-13418 ,10128 ,1740 ,2231 ,-8822 ,-2688 ,9933 ,-4173 ,1700 ,23 ,-2432 ,9001 , -13336 ,5339 ,4755 ,-11149 ,10073 ,-3680 ,968 ,-832 ,830 ,152 ,-638 ,1065 ,-1258 ,1737 ,-2189 , 2523 ,-2345 ,2657 ,-3302 ,5514 ,-2888 ,-6689 ,10848 ,-6719 ,2551 ,-2728 ,7295 ,-4546 ,-5886 ,9866 , -7879 ,5850 ,-2031 ,366 ,177 ,-549 ,-114 ,3999 ,-3213 ,-6860 ,8359 ,302 ,-2500 ,-2844 ,7739 , -5453 ,-2534 ,7539 ,-6990 ,8084 ,-5408 ,-3456 ,6802 ,-3960 ,4494 ,-5765 ,5081 ,-4562 ,11224 ,-4438 , -20476 ,17902 ,2899 ,-3234 ,-7589 ,6635 ,724 ,1476 ,-3406 ,-3303 ,8397 ,-6658 ,4913 ,-1588 ,-2214 , 6971 ,-10976 ,2658 ,10631 ,-11914 ,8345 ,-6389 ,-4500 ,9622 ,-2036 ,-1361 ,953 ,554 ,-2215 ,8944 , -14388 ,5615 ,6086 ,-6669 ,18 ,9165 ,-3687 ,-15996 ,17115 ,-5189 ,2501 ,-2827 ,7457 ,-5792 ,-9424 , 16246 ,-10062 ,6942 ,-4844 ,1544 ,1026 ,-1792 ,2510 ,-3011 ,2991 ,-439 ,1594 ,-11226 ,16544 ,-5673 , -12039 ,11848 ,-1962 ,6023 ,-14985 ,8760 ,4188 ,-9106 ,5908 ,-521 ,-1131 ,-127 ,4366 ,92 ,1632 , -19484 ,9611 ,7606 ,2803 ,-3012 ,-16598 ,20057 ,-8863 ,6017 ,-824 ,-8542 ,4473 ,3218 ,1552 ,-10851 , 15715 ,-12727 ,296 ,8723 ,-9762 ,9497 ,-4316 ,-2523 ,2510 ,961 ,-1763 ,1487 ,2507 ,-1377 ,-4622 , -2274 ,7672 ,-3858 ,-1425 ,5201 ,1081 ,-6340 ,-175 ,7350 ,-6823 ,5604 ,554 ,-10198 ,7951 ,-479 , -1362 ,1260 ,-900 ,535 ,-248 ,14 ,-113 ,839 ,-787 ,3347 ,-5629 ,-57 ,4287 ,-2274 ,778 , 663 ,-2573 ,5009 ,-4992 ,1140 ,6667 ,-14385 ,10351 ,-2120 ,18 ,2293 ,-3017 ,3030 ,-9494 ,13096 , -7556 ,-1136 ,6160 ,-6513 ,6577 ,-6277 ,6698 ,-75 ,-9071 ,5341 ,-3379 ,2821 ,2067 ,-1952 ,1383 , -1607 ,732 ,289 ,-1042 ,1374 ,1206 ,-6246 ,5737 ,715 ,-7293 ,10458 ,-8600 ,568 ,7803 ,-10518 , 5532 ,232 ,-1493 ,1252 ,-1031 ,825 ,-656 ,352 ,-280 ,470 ,-97 ,-442 ,-1391 ,3576 ,-1410 , -1910 ,548 ,1007 ,-177 ,307 ,777 ,-3069 ,3541 ,-1818 ,-309 ,-698 ,1076 ,275 ,-491 ,1961 , -4693 ,3832 ,-961 ,-1076 ,1848 ,-998 ,-132 ,-111 ,763 ,-893 ,827 ,-768 ,848 ,-723 ,57 , 1425 ,-3053 ,3652 ,-17 ,-5429 ,4259 ,-89 ,-1134 ,1732 ,-1602 ,1853 ,-1551 ,-458 ,1808 ,-1439 , 909 ,-245 ,-205 ,1012 ,-1619 ,808 ,572 ,-739 ,494 ,-133 ,177 ,-156 ,279 ,-325 ,359 , -268 ,501 ,11 ,-1073 ,1220 ,-446 ,263 ,-230 ,508 ,-72 ,-790 ,1257 ,-1103 ,202 ,685 , -396 ,267 ,-93 ,78 ,29 ,9 ,63 ,41 ,63 ,-47 ,281 ,-158 ,-167 ,426 ,-100 , 108 ,-67 ,320 ,-202 ,264 ,246 ,-858 ,954 ,-514 ,76 ,466 ,-262 ,446 ,-494 ,371 , 34 ,-56 ,234 ,-104 ,-61 ,193 ,71 ,-95 ,180 ,3 ,71 ,11 ,87 ,20 ,53 , 59 ,22 ,77 ,49 ,40 ,61 ,88 ,-1 ,78 ,58 ,75 ,7 ,153 ,23 ,-61 , 195 ,62 ,54 ,34 ,111 ,-37 ,178 ,137 ,-165 ,112 ,-6 ,-4 ,8 ,-10 ,11 , -12 ,11 ,-10 ,8 ,-7 ,5 ,-3 ,1 ,0 ,0 ,1 ,-1 ,1 ,-1 ,1 , -1 ,0 ,340 ,-16 ,20714 ,32767 ,31230 ,31466 ,29645 ,29929 ,29261 ,29251 ,29063 ,28751 ,28730 , 28201 ,28203 ,27545 ,27467 ,26792 ,26572 ,25880 ,25452 ,24821 ,24101 ,23618 ,17650 ,11527 ,9149 ,7093 , 5526 ,3639 ,1974 ,290 ,-1294 ,-2801 ,-4309 ,-5695 ,-7129 ,-8435 ,-9792 ,-11037 ,-12312 ,-13508 ,-14700 , -15842 ,-16960 ,-18040 ,-19080 ,-20102 ,-21067 ,-22012 ,-22904 ,-23778 ,-24587 ,-25368 ,-26109 ,-26801 ,-27459 ,-28069 , -28636 ,-29155 ,-29633 ,-30061 ,-30442 ,-30777 ,-31065 ,-31307 ,-31500 ,-31647 ,-31744 ,-31792 ,-31797 ,-31749 ,-31654 , -31515 ,-31327 ,-31091 ,-30814 ,-30489 ,-30118 ,-29705 ,-29243 ,-28740 ,-28193 ,-27609 ,-26982 ,-26319 ,-25614 ,-24872 , -24099 ,-23281 ,-22437 ,-21555 ,-20642 ,-19699 ,-18731 ,-17730 ,-16709 ,-15657 ,-14584 ,-13486 ,-12367 ,-11230 ,-10068 , -8897 ,-7696 ,-6494 ,-5259 ,-4011 ,-2746 ,-1460 ,-148 ,1179 ,2542 ,3931 ,5356 ,6734 ,7609 ,8144 , 8657 ,9134 ,9617 ,10077 ,10538 ,10979 ,11414 ,11839 ,12256 ,12661 ,13053 ,13441 ,13814 ,14180 ,14533 , 14878 ,15214 ,15542 ,15855 ,16161 ,16457 ,16745 ,17020 ,17287 ,17547 ,17793 ,18033 ,18266 ,18485 ,18696 , 18901 ,19094 ,19278 ,19452 ,19619 ,19776 ,19926 ,20067 ,20198 ,20321 ,20436 ,20546 ,20640 ,20733 ,20814 , 20885 ,20955 ,21011 ,21062 ,21103 ,21137 ,21164 ,21182 ,21193 ,21198 ,21195 ,21185 ,21166 ,21144 ,21114 , 21075 ,21030 ,20975 ,20916 ,20853 ,20779 ,20702 ,20618 ,20525 ,20429 ,20321 ,20211 ,20095 ,19974 ,19842 , 19709 ,19573 ,19425 ,19273 ,19115 ,18955 ,18786 ,18612 ,18434 ,18251 ,18060 ,17867 ,17669 ,17464 ,17256 , 17040 ,16824 ,16600 ,16375 ,16140 ,15907 ,15669 ,15422 ,15174 ,14920 ,14669 ,14409 ,14147 ,13880 ,13609 , 13336 ,13062 ,12784 ,12500 ,12214 ,11926 ,11635 ,11344 ,11047 ,10747 ,10448 ,10143 ,9837 ,9528 ,9216 , 8903 ,8587 ,8270 ,7950 ,7627 ,7299 ,6973 ,6638 ,6305 ,5968 ,5621 ,5275 ,4922 ,4565 ,4200 , 3833 ,3458 ,3078 ,2693 ,2304 ,1907 ,1506 ,1098 ,686 ,269 ,-152 ,-575 ,-1007 ,-1443 ,-1881 , -2326 ,-2775 ,-3225 ,-3678 ,-4137 ,-4597 ,-5060 ,-5524 ,-5991 ,-6458 ,-6928 ,-7399 ,-7870 ,-8342 ,-8812 , -9288 ,-9759 ,-10230 ,-10702 ,-11172 ,-11640 ,-12110 ,-12575 ,-13036 ,-13498 ,-13956 ,-14409 ,-14862 ,-15309 ,-15753 , -16191 ,-16625 ,-17057 ,-17481 ,-17904 ,-18320 ,-18731 ,-19133 ,-19530 ,-19922 ,-20308 ,-20689 ,-21057 ,-21423 ,-21780 , -22128 ,-22471 ,-22804 ,-23129 ,-23440 ,-23747 ,-24046 ,-24333 ,-24614 ,-24885 ,-25144 ,-25392 ,-25632 ,-25863 ,-26079 , -26286 ,-26485 ,-26673 ,-26849 ,-27016 ,-27168 ,-27310 ,-27442 ,-27562 ,-27670 ,-27767 ,-27854 ,-27924 ,-27990 ,-28038 , -28074 ,-28103 ,-28114 ,-28119 ,-28106 ,-28086 ,-28055 ,-28009 ,-27952 ,-27883 ,-27805 ,-27711 ,-27609 ,-27489 ,-27359 , -27222 ,-27069 ,-26908 ,-26737 ,-26552 ,-26356 ,-26148 ,-25927 ,-25695 ,-25456 ,-25202 ,-24939 ,-24671 ,-24386 ,-24094 , -23790 ,-23478 ,-23158 ,-22824 ,-22480 ,-22132 ,-21771 ,-21400 ,-21025 ,-20639 ,-20249 ,-19844 ,-19438 ,-19020 ,-18600 , -18170 ,-17731 ,-17293 ,-16842 ,-16390 ,-15930 ,-15467 ,-14999 ,-14528 ,-14054 ,-13576 ,-13096 ,-12614 ,-12131 ,-11646 , -11164 ,-10679 ,-10198 ,-9716 ,-9235 ,-8757 ,-8281 ,-7807 ,-7335 ,-6867 ,-6400 ,-5937 ,-5477 ,-5022 ,-4566 , -4116 ,-3667 ,-3223 ,-2781 ,-2344 ,-1911 ,-1477 ,-1050 ,-621 ,-204 ,212 ,630 ,1043 ,1451 ,1856 , 2260 ,2657 ,3051 ,3443 ,3834 ,4216 ,4598 ,4973 ,5345 ,5717 ,6081 ,6441 ,6797 ,7153 ,7503 , 7850 ,8191 ,8530 ,8864 ,9195 ,9520 ,9841 ,10162 ,10473 ,10783 ,11089 ,11390 ,11684 ,11981 ,12268 , 12552 ,12834 ,13108 ,13379 ,13644 ,13908 ,14167 ,14420 ,14669 ,14914 ,15154 ,15388 ,15620 ,15844 ,16066 , 16287 ,16500 ,16708 ,16912 ,17110 ,17305 ,17496 ,17682 ,17864 ,18040 ,18213 ,18383 ,18544 ,18700 ,18855 , 19000 ,19147 ,19285 ,19418 ,19551 ,19675 ,19797 ,19913 ,20025 ,20132 ,20231 ,20329 ,20420 ,20507 ,20592 , 20668 ,20742 ,20812 ,20877 ,20936 ,20989 ,21041 ,21085 ,21124 ,21161 ,21196 ,21222 ,21243 ,21261 ,21272 , 21279 ,21282 ,21283 ,21278 ,21267 ,21251 ,21234 ,21213 ,21183 ,21151 ,21114 ,21074 ,21030 ,20982 ,20928 , 20871 ,20811 ,20742 ,20670 ,20595 ,20518 ,20435 ,20347 ,20258 ,20163 ,20064 ,19960 ,19855 ,19744 ,19629 , 19510 ,19389 ,19263 ,19130 ,18999 ,18862 ,18721 ,18574 ,18429 ,18275 ,18119 ,17963 ,17798 ,17636 ,17467 , 17293 ,17117 ,16939 ,16759 ,16575 ,16386 ,16194 ,16000 ,15805 ,15606 ,15403 ,15199 ,14990 ,14778 ,14566 , 14351 ,14135 ,13914 ,13692 ,13466 ,13240 ,13010 ,12777 ,12544 ,12307 ,12068 ,11828 ,11587 ,11343 ,11100 , 10851 ,10602 ,10351 ,10096 ,9844 ,9590 ,9331 ,9071 ,8811 ,8548 ,8286 ,8021 ,7756 ,7488 ,7220 , 6952 ,6682 ,6410 ,6138 ,5871 ,5597 ,5323 ,5048 ,4774 ,4498 ,4222 ,3947 ,3668 ,3392 ,3116 , 2840 ,2562 ,2286 ,2007 ,1728 ,1450 ,1172 ,894 ,616 ,335 ,55 ,-219 ,-501 ,-782 ,-1063 , -1348 ,-1630 ,-1916 ,-2205 ,-2493 ,-2785 ,-3075 ,-3370 ,-3667 ,-3962 ,-4263 ,-4563 ,-4869 ,-5173 ,-5477 , -5786 ,-6096 ,-6407 ,-6718 ,-7031 ,-7343 ,-7660 ,-7975 ,-8292 ,-8604 ,-8922 ,-9240 ,-9552 ,-9873 ,-10185 , -10501 ,-10816 ,-11130 ,-11442 ,-11751 ,-12062 ,-12368 ,-12672 ,-12976 ,-13277 ,-13575 ,-13874 ,-14167 ,-14456 ,-14743 , -15024 ,-15304 ,-15582 ,-15853 ,-16119 ,-16385 ,-16646 ,-16902 ,-17150 ,-17398 ,-17637 ,-17873 ,-18102 ,-18336 ,-18555 , -18761 ,-18970 ,-19169 ,-19366 ,-19555 ,-19740 ,-19911 ,-20081 ,-20247 ,-20400 ,-20549 ,-20693 ,-20828 ,-20952 ,-21075 , -21185 ,-21289 ,-21389 ,-21478 ,-21558 ,-21631 ,-21698 ,-21755 ,-21806 ,-21849 ,-21885 ,-21910 ,-21926 ,-21937 ,-21937 , -21930 ,-21918 ,-21896 ,-21863 ,-21821 ,-21773 ,-21716 ,-21652 ,-21577 ,-21497 ,-21407 ,-21311 ,-21205 ,-21092 ,-20971 , -20839 ,-20706 ,-20560 ,-20408 ,-20246 ,-20080 ,-19909 ,-19727 ,-19536 ,-19339 ,-19136 ,-18923 ,-18709 ,-18483 ,-18254 , -18018 ,-17773 ,-17525 ,-17270 ,-17012 ,-16744 ,-16474 ,-16196 ,-15916 ,-15632 ,-15340 ,-15048 ,-14750 ,-14447 ,-14141 , -13832 ,-13521 ,-13208 ,-12890 ,-12574 ,-12254 ,-11932 ,-11612 ,-11290 ,-10966 ,-10640 ,-10317 ,-9991 ,-9669 ,-9344 , -9023 ,-8700 ,-8377 ,-8058 ,-7736 ,-7417 ,-7097 ,-6778 ,-6462 ,-6147 ,-5831 ,-5518 ,-5205 ,-4893 ,-4582 , -4274 ,-3967 ,-3659 ,-3356 ,-3050 ,-2747 ,-2446 ,-2147 ,-1847 ,-1550 ,-1254 ,-962 ,-670 ,-379 ,-93 , 194 ,477 ,762 ,1042 ,1322 ,1602 ,1877 ,2152 ,2423 ,2693 ,2961 ,3228 ,3492 ,3755 ,4015 , 4274 ,4529 ,4781 ,5034 ,5282 ,5531 ,5773 ,6016 ,6255 ,6490 ,6725 ,6956 ,7186 ,7412 ,7638 , 7859 ,8078 ,8295 ,8506 ,8717 ,8927 ,9129 ,9333 ,9536 ,9732 ,9926 ,10116 ,10307 ,10491 ,10673 , 10855 ,11031 ,11205 ,11378 ,11545 ,11712 ,11871 ,12030 ,12186 ,12336 ,12489 ,12636 ,12777 ,12919 ,13059 , 13190 ,13322 ,13450 ,13573 ,13693 ,13811 ,13926 ,14037 ,14147 ,14249 ,14353 ,14448 ,14543 ,14636 ,14722 , 14808 ,14890 ,14969 ,15042 ,15113 ,15180 ,15247 ,15308 ,15365 ,15421 ,15470 ,15518 ,15563 ,15603 ,15642 , 15675 ,15704 ,15732 ,15757 ,15776 ,15795 ,15814 ,15821 ,15829 ,15832 ,15832 ,15830 ,15823 ,15817 ,15801 , 15784 ,15768 ,15746 ,15720 ,15689 ,15660 ,15622 ,15584 ,15544 ,15496 ,15450 ,15400 ,15346 ,15287 ,15227 , 15164 ,15097 ,15028 ,14954 ,14881 ,14804 ,14724 ,14638 ,14551 ,14463 ,14369 ,14273 ,14176 ,14079 ,13973 , 13867 ,13760 ,13645 ,13533 ,13416 ,13297 ,13174 ,13050 ,12922 ,12790 ,12662 ,12529 ,12391 ,12252 ,12112 , 11967 ,11821 ,11675 ,11524 ,11372 ,11220 ,11064 ,10906 ,10744 ,10583 ,10417 ,10252 ,10087 ,9913 ,9743 , 9570 ,9394 ,9218 ,9040 ,8862 ,8679 ,8498 ,8315 ,8128 ,7940 ,7753 ,7564 ,7370 ,7181 ,6988 , 6792 ,6596 ,6400 ,6201 ,6005 ,5804 ,5604 ,5402 ,5199 ,4997 ,4791 ,4588 ,4382 ,4176 ,3971 , 3765 ,3557 ,3350 ,3141 ,2933 ,2726 ,2515 ,2308 ,2098 ,1888 ,1678 ,1468 ,1261 ,1052 ,842 , 633 ,423 ,214 ,7 ,-198 ,-405 ,-614 ,-819 ,-1027 ,-1234 ,-1439 ,-1645 ,-1848 ,-2053 ,-2258 , -2460 ,-2663 ,-2863 ,-3063 ,-3265 ,-3463 ,-3662 ,-3862 ,-4060 ,-4254 ,-4450 ,-4646 ,-4839 ,-5034 ,-5225 , -5416 ,-5608 ,-5801 ,-5991 ,-6182 ,-6372 ,-6559 ,-6750 ,-6938 ,-7125 ,-7312 ,-7500 ,-7687 ,-7872 ,-8060 , -8246 ,-8430 ,-8614 ,-8800 ,-8984 ,-9168 ,-9350 ,-9532 ,-9714 ,-9892 ,-10072 ,-10250 ,-10425 ,-10601 ,-10774 , -10948 ,-11118 ,-11288 ,-11456 ,-11620 ,-11786 ,-11945 ,-12105 ,-12264 ,-12419 ,-12572 ,-12723 ,-12871 ,-13017 ,-13160 , -13299 ,-13435 ,-13567 ,-13697 ,-13823 ,-13945 ,-14068 ,-14185 ,-14298 ,-14409 ,-14514 ,-14615 ,-14712 ,-14804 ,-14893 , -14978 ,-15060 ,-15140 ,-15211 ,-15279 ,-15343 ,-15402 ,-15456 ,-15506 ,-15552 ,-15593 ,-15627 ,-15661 ,-15687 ,-15707 , -15726 ,-15736 ,-15742 ,-15742 ,-15741 ,-15731 ,-15715 ,-15700 ,-15677 ,-15648 ,-15615 ,-15578 ,-15532 ,-15482 ,-15430 , -15370 ,-15308 ,-15241 ,-15167 ,-15088 ,-15005 ,-14917 ,-14822 ,-14726 ,-14624 ,-14519 ,-14409 ,-14292 ,-14175 ,-14049 , -13922 ,-13790 ,-13651 ,-13514 ,-13370 ,-13222 ,-13072 ,-12918 ,-12762 ,-12600 ,-12435 ,-12270 ,-12098 ,-11926 ,-11750 , -11574 ,-11397 ,-11214 ,-11028 ,-10842 ,-10655 ,-10466 ,-10277 ,-10083 ,-9890 ,-9697 ,-9501 ,-9304 ,-9108 ,-8910 , -8709 ,-8511 ,-8310 ,-8110 ,-7906 ,-7705 ,-7499 ,-7296 ,-7093 ,-6887 ,-6685 ,-6478 ,-6274 ,-6067 ,-5862 , -5657 ,-5451 ,-5244 ,-5037 ,-4832 ,-4627 ,-4420 ,-4213 ,-4007 ,-3802 ,-3595 ,-3389 ,-3184 ,-2977 ,-2772 , -2567 ,-2362 ,-2156 ,-1951 ,-1748 ,-1545 ,-1343 ,-1140 ,-938 ,-737 ,-535 ,-336 ,-136 ,58 ,255 , 453 ,651 ,847 ,1042 ,1236 ,1430 ,1623 ,1814 ,2005 ,2194 ,2384 ,2571 ,2759 ,2942 ,3125 , 3312 ,3492 ,3674 ,3852 ,4031 ,4206 ,4382 ,4557 ,4731 ,4902 ,5069 ,5239 ,5405 ,5570 ,5735 , 5898 ,6057 ,6218 ,6374 ,6528 ,6683 ,6836 ,6987 ,7136 ,7284 ,7429 ,7573 ,7714 ,7855 ,7991 , 8125 ,8259 ,8392 ,8521 ,8646 ,8774 ,8898 ,9019 ,9137 ,9256 ,9371 ,9483 ,9596 ,9704 ,9811 , 9916 ,10018 ,10117 ,10216 ,10311 ,10404 ,10495 ,10583 ,10672 ,10756 ,10837 ,10918 ,10995 ,11070 ,11141 , 11209 ,11278 ,11342 ,11403 ,11463 ,11522 ,11577 ,11627 ,11677 ,11727 ,11773 ,11815 ,11855 ,11892 ,11929 , 11962 ,11992 ,12021 ,12047 ,12071 ,12091 ,12108 ,12124 ,12139 ,12148 ,12158 ,12161 ,12165 ,12168 ,12163 , 12163 ,12155 ,12142 ,12132 ,12120 ,12103 ,12085 ,12065 ,12040 ,12014 ,11985 ,11954 ,11922 ,11888 ,11849 , 11809 ,11766 ,11722 ,11676 ,11625 ,11576 ,11520 ,11468 ,11410 ,11348 ,11285 ,11218 ,11155 ,11084 ,11014 , 10941 ,10865 ,10789 ,10708 ,10628 ,10545 ,10459 ,10371 ,10282 ,10191 ,10098 ,10003 ,9908 ,9809 ,9708 , 9607 ,9504 ,9398 ,9290 ,9182 ,9069 ,8958 ,8844 ,8727 ,8610 ,8492 ,8371 ,8247 ,8125 ,7995 , 7873 ,7747 ,7617 ,7489 ,7355 ,7224 ,7089 ,6954 ,6820 ,6680 ,6539 ,6402 ,6258 ,6116 ,5973 , 5826 ,5683 ,5534 ,5389 ,5242 ,5092 ,4943 ,4790 ,4641 ,4489 ,4336 ,4183 ,4029 ,3877 ,3721 , 3563 ,3407 ,3252 ,3094 ,2935 ,2779 ,2619 ,2462 ,2302 ,2142 ,1985 ,1823 ,1665 ,1504 ,1344 , 1184 ,1025 ,865 ,704 ,544 ,384 ,226 ,66 ,-91 ,-250 ,-409 ,-568 ,-726 ,-885 ,-1043 , -1199 ,-1359 ,-1512 ,-1670 ,-1826 ,-1982 ,-2136 ,-2288 ,-2444 ,-2597 ,-2750 ,-2899 ,-3050 ,-3199 ,-3349 , -3495 ,-3641 ,-3789 ,-3933 ,-4078 ,-4223 ,-4365 ,-4506 ,-4647 ,-4783 ,-4920 ,-5058 ,-5196 ,-5330 ,-5462 , -5596 ,-5726 ,-5856 ,-5985 ,-6113 ,-6238 ,-6361 ,-6486 ,-6609 ,-6728 ,-6849 ,-6968 ,-7084 ,-7200 ,-7313 , -7426 ,-7538 ,-7647 ,-7754 ,-7861 ,-7965 ,-8069 ,-8173 ,-8273 ,-8371 ,-8471 ,-8566 ,-8658 ,-8754 ,-8844 , -8934 ,-9024 ,-9109 ,-9193 ,-9273 ,-9357 ,-9436 ,-9513 ,-9590 ,-9663 ,-9737 ,-9804 ,-9874 ,-9939 ,-10003 , -10067 ,-10126 ,-10186 ,-10246 ,-10301 ,-10352 ,-10401 ,-10449 ,-10496 ,-10541 ,-10582 ,-10621 ,-10658 ,-10692 ,-10726 , -10756 ,-10784 ,-10810 ,-10833 ,-10853 ,-10870 ,-10888 ,-10900 ,-10911 ,-10923 ,-10927 ,-10928 ,-10931 ,-10927 ,-10924 , -10918 ,-10906 ,-10895 ,-10878 ,-10861 ,-10842 ,-10819 ,-10796 ,-10767 ,-10736 ,-10706 ,-10671 ,-10635 ,-10593 ,-10552 , -10510 ,-10459 ,-10413 ,-10361 ,-10305 ,-10250 ,-10189 ,-10129 ,-10066 ,-10001 ,-9934 ,-9863 ,-9791 ,-9717 ,-9642 , -9565 ,-9483 ,-9403 ,-9318 ,-9232 ,-9145 ,-9056 ,-8966 ,-8871 ,-8779 ,-8685 ,-8584 ,-8485 ,-8385 ,-8281 , -8179 ,-8073 ,-7966 ,-7856 ,-7747 ,-7637 ,-7526 ,-7414 ,-7301 ,-7183 ,-7067 ,-6951 ,-6829 ,-6711 ,-6590 , -6467 ,-6345 ,-6220 ,-6096 ,-5967 ,-5845 ,-5715 ,-5586 ,-5456 ,-5326 ,-5195 ,-5063 ,-4931 ,-4793 ,-4664 , -4527 ,-4390 ,-4256 ,-4118 ,-3980 ,-3842 ,-3704 ,-3566 ,-3427 ,-3287 ,-3146 ,-3003 ,-2864 ,-2724 ,-2579 , -2439 ,-2297 ,-2154 ,-2011 ,-1869 ,-1726 ,-1582 ,-1440 ,-1296 ,-1152 ,-1010 ,-867 ,-724 ,-581 ,-440 , -297 ,-152 ,-13 ,126 ,267 ,409 ,549 ,691 ,831 ,970 ,1111 ,1249 ,1389 ,1527 ,1666 , 1801 ,1936 ,2073 ,2210 ,2347 ,2479 ,2613 ,2746 ,2878 ,3007 ,3138 ,3270 ,3399 ,3528 ,3654 , 3778 ,3902 ,4028 ,4152 ,4274 ,4396 ,4517 ,4634 ,4752 ,4871 ,4985 ,5099 ,5214 ,5327 ,5438 , 5547 ,5656 ,5762 ,5867 ,5973 ,6075 ,6179 ,6278 ,6377 ,6476 ,6571 ,6665 ,6759 ,6853 ,6942 , 7032 ,7119 ,7205 ,7291 ,7373 ,7456 ,7534 ,7613 ,7690 ,7766 ,7839 ,7912 ,7982 ,8050 ,8119 , 8185 ,8248 ,8309 ,8373 ,8429 ,8486 ,8539 ,8593 ,8644 ,8692 ,8743 ,8790 ,8832 ,8875 ,8920 , 8957 ,8995 ,9030 ,9064 ,9095 ,9127 ,9156 ,9182 ,9207 ,9228 ,9252 ,9269 ,9286 ,9302 ,9316 , 9328 ,9337 ,9345 ,9352 ,9355 ,9355 ,9358 ,9358 ,9354 ,9347 ,9341 ,9333 ,9324 ,9310 ,9295 , 9281 ,9259 ,9242 ,9222 ,9197 ,9173 ,9145 ,9118 ,9084 ,9054 ,9022 ,8985 ,8947 ,8908 ,8868 , 8824 ,8782 ,8735 ,8686 ,8638 ,8587 ,8534 ,8480 ,8428 ,8369 ,8309 ,8250 ,8188 ,8124 ,8058 , 7991 ,7923 ,7854 ,7783 ,7711 ,7637 ,7562 ,7484 ,7405 ,7326 ,7245 ,7163 ,7081 ,6996 ,6909 , 6823 ,6734 ,6644 ,6551 ,6460 ,6368 ,6272 ,6178 ,6083 ,5984 ,5887 ,5785 ,5684 ,5584 ,5481 , 5376 ,5272 ,5166 ,5059 ,4953 ,4844 ,4735 ,4625 ,4513 ,4403 ,4288 ,4177 ,4065 ,3951 ,3834 , 3718 ,3604 ,3486 ,3368 ,3250 ,3135 ,3015 ,2896 ,2779 ,2659 ,2540 ,2418 ,2297 ,2174 ,2054 , 1932 ,1810 ,1689 ,1565 ,1443 ,1320 ,1198 ,1075 ,953 ,829 ,707 ,585 ,461 ,339 ,218 , 95 ,-24 ,-144 ,-266 ,-388 ,-510 ,-627 ,-750 ,-872 ,-992 ,-1113 ,-1231 ,-1351 ,-1469 ,-1589 , -1705 ,-1823 ,-1943 ,-2057 ,-2172 ,-2287 ,-2402 ,-2518 ,-2630 ,-2744 ,-2857 ,-2967 ,-3080 ,-3189 ,-3298 , -3407 ,-3516 ,-3623 ,-3729 ,-3832 ,-3938 ,-4044 ,-4146 ,-4249 ,-4349 ,-4448 ,-4547 ,-4647 ,-4742 ,-4837 , -4934 ,-5028 ,-5121 ,-5210 ,-5302 ,-5391 ,-5477 ,-5566 ,-5650 ,-5734 ,-5818 ,-5898 ,-5980 ,-6058 ,-6137 , -6214 ,-6290 ,-6367 ,-6438 ,-6510 ,-6582 ,-6650 ,-6718 ,-6786 ,-6850 ,-6912 ,-6975 ,-7035 ,-7094 ,-7153 , -7207 ,-7264 ,-7318 ,-7368 ,-7418 ,-7466 ,-7513 ,-7558 ,-7604 ,-7648 ,-7688 ,-7727 ,-7765 ,-7801 ,-7836 , -7868 ,-7899 ,-7930 ,-7958 ,-7986 ,-8010 ,-8031 ,-8054 ,-8072 ,-8089 ,-8108 ,-8122 ,-8133 ,-8147 ,-8158 , -8165 ,-8172 ,-8177 ,-8180 ,-8183 ,-8183 ,-8181 ,-8177 ,-8171 ,-8166 ,-8157 ,-8146 ,-8136 ,-8124 ,-8110 , -8094 ,-8076 ,-8057 ,-8037 ,-8015 ,-7994 ,-7965 ,-7938 ,-7911 ,-7879 ,-7848 ,-7816 ,-7780 ,-7743 ,-7708 , -7670 ,-7629 ,-7588 ,-7544 ,-7499 ,-7455 ,-7407 ,-7358 ,-7306 ,-7254 ,-7200 ,-7145 ,-7090 ,-7033 ,-6973 , -6913 ,-6853 ,-6789 ,-6724 ,-6659 ,-6594 ,-6526 ,-6453 ,-6385 ,-6313 ,-6240 ,-6167 ,-6093 ,-6017 ,-5939 , -5861 ,-5780 ,-5701 ,-5621 ,-5540 ,-5455 ,-5372 ,-5287 ,-5201 ,-5112 ,-5024 ,-4938 ,-4848 ,-4758 ,-4667 , -4578 ,-4484 ,-4389 ,-4297 ,-4202 ,-4106 ,-4014 ,-3914 ,-3816 ,-3719 ,-3619 ,-3522 ,-3421 ,-3322 ,-3220 , -3120 ,-3018 ,-2914 ,-2812 ,-2709 ,-2605 ,-2502 ,-2399 ,-2290 ,-2187 ,-2080 ,-1973 ,-1868 ,-1760 ,-1653 , -1545 ,-1440 ,-1334 ,-1225 ,-1117 ,-1009 ,-903 ,-794 ,-685 ,-579 ,-469 ,-364 ,-254 ,-145 ,-40 , 64 ,171 ,282 ,388 ,493 ,600 ,705 ,813 ,921 ,1026 ,1130 ,1234 ,1341 ,1444 ,1545 , 1649 ,1751 ,1856 ,1957 ,2057 ,2159 ,2258 ,2358 ,2458 ,2557 ,2652 ,2753 ,2849 ,2944 ,3039 , 3131 ,3227 ,3321 ,3413 ,3505 ,3596 ,3684 ,3775 ,3865 ,3950 ,4040 ,4125 ,4208 ,4294 ,4375 , 4458 ,4540 ,4620 ,4699 ,4778 ,4857 ,4930 ,5006 ,5080 ,5151 ,5224 ,5295 ,5366 ,5431 ,5499 , 5564 ,5627 ,5693 ,5754 ,5814 ,5874 ,5932 ,5989 ,6045 ,6098 ,6153 ,6205 ,6254 ,6304 ,6351 , 6398 ,6443 ,6489 ,6532 ,6573 ,6613 ,6651 ,6688 ,6726 ,6762 ,6796 ,6828 ,6860 ,6890 ,6916 , 6945 ,6971 ,6995 ,7019 ,7038 ,7058 ,7076 ,7091 ,7109 ,7124 ,7135 ,7148 ,7157 ,7165 ,7172 , 7179 ,7184 ,7186 ,7188 ,7189 ,7188 ,7185 ,7182 ,7175 ,7167 ,7159 ,7151 ,7138 ,7123 ,7112 , 7093 ,7077 ,7062 ,7041 ,7019 ,6998 ,6974 ,6949 ,6921 ,6895 ,6868 ,6835 ,6804 ,6772 ,6738 , 6704 ,6669 ,6629 ,6591 ,6550 ,6509 ,6467 ,6423 ,6378 ,6332 ,6286 ,6233 ,6188 ,6136 ,6083 , 6032 ,5977 ,5922 ,5866 ,5810 ,5749 ,5691 ,5630 ,5568 ,5506 ,5442 ,5377 ,5312 ,5244 ,5176 , 5109 ,5038 ,4969 ,4897 ,4823 ,4750 ,4676 ,4602 ,4527 ,4449 ,4371 ,4295 ,4215 ,4135 ,4056 , 3974 ,3891 ,3809 ,3727 ,3645 ,3557 ,3470 ,3388 ,3299 ,3214 ,3128 ,3040 ,2950 ,2861 ,2774 , 2685 ,2595 ,2503 ,2411 ,2321 ,2230 ,2135 ,2043 ,1951 ,1859 ,1764 ,1671 ,1580 ,1485 ,1392 , 1298 ,1203 ,1108 ,1014 ,920 ,826 ,733 ,636 ,540 ,448 ,350 ,257 ,165 ,68 ,-22 , -116 ,-209 ,-303 ,-399 ,-493 ,-584 ,-676 ,-770 ,-860 ,-955 ,-1046 ,-1138 ,-1227 ,-1318 ,-1408 , -1496 ,-1589 ,-1675 ,-1764 ,-1853 ,-1940 ,-2027 ,-2113 ,-2197 ,-2284 ,-2370 ,-2453 ,-2537 ,-2620 ,-2703 , -2785 ,-2866 ,-2945 ,-3026 ,-3104 ,-3181 ,-3262 ,-3338 ,-3412 ,-3490 ,-3565 ,-3638 ,-3712 ,-3784 ,-3856 , -3926 ,-3997 ,-4068 ,-4134 ,-4201 ,-4270 ,-4335 ,-4398 ,-4463 ,-4529 ,-4590 ,-4651 ,-4711 ,-4772 ,-4829 , -4884 ,-4941 ,-4995 ,-5050 ,-5102 ,-5155 ,-5206 ,-5254 ,-5304 ,-5349 ,-5394 ,-5438 ,-5484 ,-5525 ,-5565 , -5610 ,-5646 ,-5683 ,-5720 ,-5757 ,-5789 ,-5823 ,-5858 ,-5886 ,-5917 ,-5945 ,-5972 ,-6000 ,-6025 ,-6049 , -6070 ,-6092 ,-6113 ,-6130 ,-6149 ,-6166 ,-6182 ,-6197 ,-6208 ,-6222 ,-6231 ,-6239 ,-6249 ,-6255 ,-6260 , -6263 ,-6267 ,-6271 ,-6271 ,-6271 ,-6267 ,-6262 ,-6260 ,-6254 ,-6248 ,-6240 ,-6229 ,-6218 ,-6207 ,-6193 , -6179 ,-6162 ,-6144 ,-6127 ,-6108 ,-6087 ,-6065 ,-6045 ,-6020 ,-5993 ,-5970 ,-5941 ,-5912 ,-5882 ,-5852 , -5820 ,-5786 ,-5754 ,-5718 ,-5682 ,-5645 ,-5605 ,-5568 ,-5526 ,-5483 ,-5443 ,-5400 ,-5354 ,-5308 ,-5261 , -5212 ,-5164 ,-5116 ,-5066 ,-5012 ,-4960 ,-4910 ,-4853 ,-4797 ,-4741 ,-4684 ,-4627 ,-4568 ,-4507 ,-4446 , -4386 ,-4323 ,-4261 ,-4197 ,-4133 ,-4067 ,-4002 ,-3937 ,-3866 ,-3798 ,-3729 ,-3658 ,-3589 ,-3518 ,-3448 , -3376 ,-3304 ,-3231 ,-3156 ,-3084 ,-3010 ,-2932 ,-2857 ,-2781 ,-2705 ,-2627 ,-2551 ,-2473 ,-2395 ,-2318 , -2241 ,-2161 ,-2082 ,-2003 ,-1919 ,-1841 ,-1761 ,-1680 ,-1600 ,-1518 ,-1439 ,-1357 ,-1276 ,-1194 ,-1111 , -1033 ,-950 ,-866 ,-783 ,-701 ,-620 ,-536 ,-454 ,-372 ,-289 ,-206 ,-123 ,-40 ,40 ,119 , 203 ,284 ,367 ,448 ,528 ,610 ,692 ,774 ,853 ,935 ,1013 ,1096 ,1174 ,1253 ,1334 , 1409 ,1488 ,1565 ,1644 ,1722 ,1796 ,1874 ,1950 ,2022 ,2099 ,2173 ,2247 ,2319 ,2392 ,2464 , 2535 ,2607 ,2677 ,2748 ,2815 ,2883 ,2953 ,3021 ,3085 ,3153 ,3216 ,3282 ,3346 ,3408 ,3474 , 3534 ,3597 ,3657 ,3716 ,3776 ,3834 ,3892 ,3946 ,4003 ,4058 ,4110 ,4165 ,4217 ,4267 ,4317 , 4367 ,4412 ,4461 ,4508 ,4554 ,4599 ,4641 ,4683 ,4725 ,4765 ,4804 ,4844 ,4880 ,4917 ,4956 , 4988 ,5022 ,5052 ,5084 ,5118 ,5144 ,5173 ,5200 ,5226 ,5251 ,5275 ,5297 ,5319 ,5340 ,5357 , 5378 ,5395 ,5412 ,5430 ,5444 ,5455 ,5470 ,5483 ,5490 ,5502 ,5511 ,5516 ,5523 ,5527 ,5531 , 5534 ,5535 ,5534 ,5533 ,5532 ,5529 ,5525 ,5519 ,5512 ,5507 ,5498 ,5488 ,5480 ,5468 ,5454 , 5439 ,5425 ,5409 ,5391 ,5373 ,5352 ,5334 ,5312 ,5290 ,5267 ,5241 ,5217 ,5190 ,5162 ,5136 , 5105 ,5076 ,5045 ,5013 ,4982 ,4946 ,4913 ,4877 ,4840 ,4804 ,4765 ,4726 ,4688 ,4646 ,4605 , 4563 ,4518 ,4475 ,4430 ,4384 ,4340 ,4293 ,4244 ,4196 ,4146 ,4095 ,4045 ,3993 ,3941 ,3887 , 3835 ,3780 ,3724 ,3670 ,3611 ,3555 ,3497 ,3439 ,3378 ,3318 ,3259 ,3196 ,3135 ,3073 ,3010 , 2948 ,2884 ,2819 ,2757 ,2691 ,2624 ,2558 ,2490 ,2425 ,2357 ,2290 ,2223 ,2152 ,2086 ,2017 , 1948 ,1876 ,1805 ,1739 ,1667 ,1599 ,1527 ,1455 ,1385 ,1314 ,1246 ,1172 ,1101 ,1030 ,958 , 885 ,815 ,742 ,667 ,598 ,525 ,453 ,381 ,307 ,235 ,163 ,90 ,18 ,-51 ,-122 , -195 ,-267 ,-339 ,-410 ,-482 ,-555 ,-626 ,-697 ,-768 ,-840 ,-911 ,-980 ,-1050 ,-1119 ,-1191 , -1261 ,-1329 ,-1397 ,-1465 ,-1532 ,-1598 ,-1665 ,-1730 ,-1797 ,-1863 ,-1927 ,-1992 ,-2056 ,-2119 ,-2181 , -2243 ,-2306 ,-2367 ,-2426 ,-2485 ,-2546 ,-2606 ,-2662 ,-2720 ,-2778 ,-2833 ,-2888 ,-2944 ,-2998 ,-3051 , -3106 ,-3156 ,-3209 ,-3263 ,-3312 ,-3360 ,-3409 ,-3461 ,-3505 ,-3552 ,-3601 ,-3644 ,-3692 ,-3738 ,-3777 , -3822 ,-3863 ,-3903 ,-3947 ,-3986 ,-4023 ,-4059 ,-4097 ,-4135 ,-4169 ,-4201 ,-4236 ,-4268 ,-4298 ,-4330 , -4358 ,-4388 ,-4411 ,-4439 ,-4467 ,-4491 ,-4517 ,-4538 ,-4560 ,-4580 ,-4600 ,-4619 ,-4639 ,-4654 ,-4670 , -4688 ,-4699 ,-4713 ,-4726 ,-4738 ,-4748 ,-4757 ,-4768 ,-4774 ,-4781 ,-4788 ,-4792 ,-4796 ,-4799 ,-4800 , -4802 ,-4803 ,-4804 ,-4801 ,-4797 ,-4796 ,-4793 ,-4786 ,-4781 ,-4775 ,-4767 ,-4760 ,-4751 ,-4739 ,-4728 , -4715 ,-4702 ,-4688 ,-4672 ,-4657 ,-4638 ,-4621 ,-4602 ,-4584 ,-4564 ,-4539 ,-4516 ,-4493 ,-4469 ,-4444 , -4418 ,-4389 ,-4363 ,-4335 ,-4304 ,-4275 ,-4242 ,-4211 ,-4180 ,-4145 ,-4110 ,-4076 ,-4039 ,-4003 ,-3967 , -3929 ,-3890 ,-3849 ,-3812 ,-3769 ,-3730 ,-3688 ,-3644 ,-3602 ,-3557 ,-3511 ,-3467 ,-3421 ,-3374 ,-3327 , -3280 ,-3233 ,-3184 ,-3135 ,-3084 ,-3034 ,-2984 ,-2932 ,-2880 ,-2827 ,-2777 ,-2722 ,-2667 ,-2614 ,-2555 , -2501 ,-2445 ,-2388 ,-2333 ,-2273 ,-2215 ,-2155 ,-2098 ,-2037 ,-1976 ,-1917 ,-1857 ,-1795 ,-1733 ,-1674 , -1612 ,-1552 ,-1490 ,-1428 ,-1365 ,-1302 ,-1241 ,-1180 ,-1114 ,-1052 ,-990 ,-925 ,-860 ,-798 ,-736 , -671 ,-607 ,-545 ,-482 ,-418 ,-355 ,-291 ,-228 ,-167 ,-101 ,-40 ,19 ,81 ,145 ,207 , 270 ,332 ,395 ,459 ,519 ,583 ,645 ,707 ,771 ,832 ,894 ,955 ,1015 ,1076 ,1136 , 1196 ,1256 ,1318 ,1375 ,1434 ,1494 ,1551 ,1609 ,1663 ,1721 ,1779 ,1833 ,1890 ,1945 ,2001 , 2054 ,2107 ,2161 ,2215 ,2266 ,2317 ,2368 ,2419 ,2470 ,2516 ,2565 ,2614 ,2661 ,2707 ,2753 , 2801 ,2844 ,2888 ,2932 ,2977 ,3019 ,3063 ,3104 ,3143 ,3184 ,3224 ,3264 ,3302 ,3342 ,3378 , 3415 ,3452 ,3487 ,3520 ,3552 ,3587 ,3620 ,3652 ,3681 ,3714 ,3743 ,3771 ,3799 ,3825 ,3852 , 3877 ,3902 ,3926 ,3951 ,3971 ,3991 ,4012 ,4031 ,4052 ,4069 ,4086 ,4102 ,4117 ,4134 ,4149 , 4159 ,4172 ,4183 ,4192 ,4201 ,4211 ,4218 ,4223 ,4231 ,4235 ,4239 ,4243 ,4248 ,4248 ,4248 , 4248 ,4249 ,4249 ,4247 ,4244 ,4242 ,4240 ,4233 ,4229 ,4221 ,4214 ,4205 ,4196 ,4188 ,4175 , 4164 ,4151 ,4140 ,4127 ,4111 ,4096 ,4080 ,4064 ,4046 ,4027 ,4007 ,3985 ,3966 ,3944 ,3920 , 3899 ,3873 ,3849 ,3825 ,3797 ,3769 ,3742 ,3712 ,3683 ,3651 ,3622 ,3593 ,3559 ,3525 ,3492 , 3457 ,3422 ,3387 ,3349 ,3313 ,3276 ,3241 ,3200 ,3162 ,3124 ,3082 ,3042 ,2999 ,2960 ,2918 , 2877 ,2834 ,2792 ,2748 ,2703 ,2660 ,2611 ,2568 ,2522 ,2471 ,2427 ,2379 ,2332 ,2283 ,2234 , 2187 ,2133 ,2083 ,2034 ,1984 ,1932 ,1880 ,1831 ,1778 ,1725 ,1672 ,1620 ,1566 ,1515 ,1458 , 1404 ,1353 ,1295 ,1242 ,1187 ,1134 ,1077 ,1021 ,968 ,911 ,857 ,802 ,746 ,691 ,635 , 580 ,526 ,470 ,415 ,361 ,304 ,246 ,193 ,137 ,80 ,29 ,-22 ,-78 ,-133 ,-188 , -242 ,-296 ,-352 ,-403 ,-458 ,-516 ,-567 ,-620 ,-675 ,-727 ,-780 ,-836 ,-889 ,-940 ,-993 , -1046 ,-1098 ,-1150 ,-1204 ,-1253 ,-1305 ,-1356 ,-1404 ,-1456 ,-1505 ,-1556 ,-1604 ,-1653 ,-1701 ,-1747 , -1797 ,-1844 ,-1891 ,-1938 ,-1982 ,-2027 ,-2072 ,-2118 ,-2160 ,-2202 ,-2246 ,-2287 ,-2330 ,-2371 ,-2411 , -2452 ,-2491 ,-2529 ,-2566 ,-2603 ,-2643 ,-2678 ,-2715 ,-2749 ,-2784 ,-2818 ,-2848 ,-2884 ,-2917 ,-2949 , -2979 ,-3011 ,-3042 ,-3069 ,-3099 ,-3127 ,-3156 ,-3184 ,-3209 ,-3234 ,-3260 ,-3284 ,-3308 ,-3331 ,-3352 , -3375 ,-3395 ,-3417 ,-3438 ,-3456 ,-3474 ,-3491 ,-3510 ,-3527 ,-3539 ,-3554 ,-3570 ,-3584 ,-3595 ,-3605 , -3617 ,-3629 ,-3635 ,-3644 ,-3653 ,-3659 ,-3666 ,-3671 ,-3677 ,-3682 ,-3685 ,-3687 ,-3689 ,-3689 ,-3689 , -3690 ,-3688 ,-3686 ,-3684 ,-3681 ,-3678 ,-3673 ,-3668 ,-3661 ,-3653 ,-3647 ,-3638 ,-3628 ,-3618 ,-3607 , -3598 ,-3584 ,-3574 ,-3561 ,-3546 ,-3531 ,-3516 ,-3502 ,-3485 ,-3469 ,-3449 ,-3432 ,-3413 ,-3394 ,-3373 , -3350 ,-3331 ,-3309 ,-3286 ,-3263 ,-3238 ,-3214 ,-3189 ,-3162 ,-3134 ,-3107 ,-3078 ,-3050 ,-3019 ,-2989 , -2960 ,-2927 ,-2897 ,-2865 ,-2832 ,-2800 ,-2766 ,-2730 ,-2697 ,-2661 ,-2627 ,-2591 ,-2553 ,-2519 ,-2480 , -2444 ,-2406 ,-2367 ,-2329 ,-2289 ,-2249 ,-2208 ,-2170 ,-2129 ,-2087 ,-2046 ,-2006 ,-1965 ,-1922 ,-1882 , -1837 ,-1794 ,-1749 ,-1704 ,-1661 ,-1619 ,-1573 ,-1527 ,-1484 ,-1438 ,-1394 ,-1348 ,-1300 ,-1255 ,-1208 , -1161 ,-1115 ,-1066 ,-1018 ,-972 ,-923 ,-872 ,-825 ,-776 ,-726 ,-678 ,-630 ,-583 ,-533 ,-482 , -433 ,-385 ,-334 ,-286 ,-237 ,-186 ,-139 ,-89 ,-41 ,5 ,51 ,100 ,151 ,197 ,248 , 294 ,341 ,391 ,437 ,485 ,533 ,578 ,625 ,673 ,718 ,766 ,813 ,858 ,905 ,951 , 994 ,1041 ,1087 ,1129 ,1175 ,1218 ,1263 ,1305 ,1349 ,1396 ,1435 ,1479 ,1522 ,1562 ,1605 , 1647 ,1689 ,1729 ,1768 ,1807 ,1846 ,1886 ,1925 ,1964 ,2001 ,2039 ,2078 ,2112 ,2148 ,2185 , 2219 ,2253 ,2288 ,2321 ,2353 ,2386 ,2419 ,2450 ,2481 ,2511 ,2541 ,2571 ,2599 ,2628 ,2654 , 2680 ,2708 ,2732 ,2757 ,2781 ,2804 ,2827 ,2851 ,2873 ,2894 ,2915 ,2936 ,2957 ,2976 ,2996 , 3015 ,3030 ,3048 ,3066 ,3080 ,3095 ,3110 ,3122 ,3137 ,3151 ,3162 ,3174 ,3184 ,3195 ,3204 , 3215 ,3222 ,3229 ,3239 ,3242 ,3248 ,3255 ,3257 ,3262 ,3264 ,3266 ,3271 ,3270 ,3272 ,3272 , 3269 ,3267 ,3266 ,3263 ,3257 ,3254 ,3249 ,3242 ,3235 ,3228 ,3222 ,3213 ,3204 ,3196 ,3185 , 3175 ,3166 ,3154 ,3142 ,3128 ,3114 ,3101 ,3088 ,3073 ,3057 ,3041 ,3026 ,3007 ,2990 ,2975 , 2955 ,2935 ,2916 ,2896 ,2873 ,2853 ,2830 ,2812 ,2789 ,2763 ,2742 ,2716 ,2692 ,2666 ,2642 , 2615 ,2588 ,2562 ,2533 ,2504 ,2474 ,2446 ,2415 ,2385 ,2354 ,2320 ,2289 ,2257 ,2225 ,2193 , 2159 ,2127 ,2092 ,2057 ,2022 ,1985 ,1951 ,1915 ,1879 ,1842 ,1805 ,1769 ,1729 ,1693 ,1654 , 1615 ,1579 ,1541 ,1500 ,1460 ,1422 ,1382 ,1345 ,1305 ,1262 ,1224 ,1184 ,1142 ,1100 ,1060 , 1018 ,976 ,937 ,892 ,851 ,810 ,769 ,724 ,682 ,642 ,599 ,555 ,513 ,470 ,426 , 383 ,340 ,298 ,254 ,212 ,168 ,124 ,81 ,37 ,-1 ,-43 ,-87 ,-130 ,-172 ,-214 , -258 ,-300 ,-342 ,-385 ,-427 ,-468 ,-511 ,-552 ,-593 ,-635 ,-676 ,-714 ,-757 ,-797 ,-836 , -876 ,-915 ,-954 ,-990 ,-1030 ,-1068 ,-1107 ,-1145 ,-1183 ,-1220 ,-1257 ,-1294 ,-1330 ,-1366 ,-1401 , -1435 ,-1471 ,-1508 ,-1540 ,-1575 ,-1609 ,-1641 ,-1675 ,-1707 ,-1741 ,-1774 ,-1804 ,-1837 ,-1867 ,-1894 , -1927 ,-1957 ,-1985 ,-2017 ,-2043 ,-2074 ,-2099 ,-2127 ,-2156 ,-2180 ,-2207 ,-2231 ,-2255 ,-2279 ,-2302 , -2324 ,-2347 ,-2370 ,-2391 ,-2412 ,-2432 ,-2452 ,-2469 ,-2489 ,-2509 ,-2525 ,-2544 ,-2559 ,-2576 ,-2593 , -2606 ,-2622 ,-2637 ,-2650 ,-2665 ,-2678 ,-2689 ,-2699 ,-2711 ,-2723 ,-2732 ,-2742 ,-2753 ,-2760 ,-2769 , -2777 ,-2785 ,-2792 ,-2799 ,-2804 ,-2809 ,-2815 ,-2819 ,-2821 ,-2824 ,-2827 ,-2829 ,-2830 ,-2831 ,-2832 , -2830 ,-2829 ,-2828 ,-2825 ,-2824 ,-2819 ,-2815 ,-2811 ,-2803 ,-2799 ,-2793 ,-2785 ,-2776 ,-2769 ,-2760 , -2751 ,-2739 ,-2729 ,-2720 ,-2704 ,-2694 ,-2682 ,-2667 ,-2655 ,-2640 ,-2624 ,-2610 ,-2594 ,-2577 ,-2561 , -2544 ,-2525 ,-2509 ,-2489 ,-2470 ,-2450 ,-2430 ,-2411 ,-2392 ,-2369 ,-2347 ,-2327 ,-2302 ,-2280 ,-2258 , -2232 ,-2210 ,-2186 ,-2160 ,-2136 ,-2108 ,-2082 ,-2057 ,-2028 ,-2001 ,-1974 ,-1946 ,-1914 ,-1888 ,-1858 , -1827 ,-1800 ,-1767 ,-1736 ,-1707 ,-1677 ,-1644 ,-1610 ,-1579 ,-1548 ,-1515 ,-1482 ,-1450 ,-1416 ,-1381 , -1347 ,-1313 ,-1279 ,-1244 ,-1209 ,-1175 ,-1139 ,-1103 ,-1069 ,-1032 ,-997 ,-960 ,-924 ,-887 ,-852 , -819 ,-777 ,-742 ,-706 ,-669 ,-635 ,-597 ,-561 ,-521 ,-486 ,-447 ,-410 ,-374 ,-338 ,-300 , -261 ,-226 ,-187 ,-151 ,-110 ,-76 ,-38 ,-4 ,31 ,71 ,105 ,143 ,180 ,218 ,253 , 290 ,327 ,363 ,400 ,437 ,475 ,511 ,545 ,580 ,618 ,652 ,689 ,723 ,758 ,793 , 826 ,863 ,895 ,929 ,963 ,999 ,1030 ,1063 ,1096 ,1125 ,1160 ,1192 ,1222 ,1254 ,1285 , 1316 ,1346 ,1377 ,1405 ,1435 ,1464 ,1494 ,1521 ,1549 ,1578 ,1605 ,1635 ,1662 ,1688 ,1714 , 1740 ,1766 ,1791 ,1818 ,1843 ,1868 ,1891 ,1915 ,1939 ,1960 ,1985 ,2006 ,2027 ,2050 ,2069 , 2090 ,2112 ,2131 ,2150 ,2170 ,2189 ,2205 ,2222 ,2239 ,2255 ,2271 ,2287 ,2301 ,2314 ,2331 , 2341 ,2353 ,2367 ,2377 ,2390 ,2401 ,2411 ,2422 ,2431 ,2439 ,2449 ,2457 ,2464 ,2472 ,2478 , 2485 ,2489 ,2496 ,2501 ,2505 ,2507 ,2510 ,2514 ,2514 ,2517 ,2517 ,2517 ,2517 ,2518 ,2518 , 2514 ,2514 ,2511 ,2508 ,2506 ,2500 ,2497 ,2490 ,2484 ,2479 ,2473 ,2468 ,2459 ,2451 ,2443 , 2433 ,2425 ,2417 ,2405 ,2393 ,2382 ,2371 ,2360 ,2347 ,2334 ,2321 ,2305 ,2292 ,2279 ,2263 , 2249 ,2230 ,2215 ,2199 ,2180 ,2164 ,2147 ,2128 ,2109 ,2091 ,2073 ,2052 ,2032 ,2013 ,1991 , 1970 ,1949 ,1927 ,1905 ,1884 ,1860 ,1836 ,1813 ,1787 ,1765 ,1741 ,1717 ,1691 ,1666 ,1642 , 1615 ,1590 ,1563 ,1536 ,1508 ,1480 ,1454 ,1425 ,1398 ,1370 ,1340 ,1310 ,1281 ,1252 ,1223 , 1194 ,1162 ,1134 ,1102 ,1073 ,1044 ,1011 ,982 ,949 ,919 ,888 ,855 ,825 ,792 ,761 , 730 ,698 ,666 ,634 ,604 ,572 ,539 ,506 ,475 ,444 ,411 ,378 ,344 ,312 ,278 , 246 ,216 ,181 ,150 ,117 ,82 ,50 ,18 ,-10 ,-41 ,-77 ,-109 ,-140 ,-173 ,-205 , -240 ,-271 ,-304 ,-336 ,-367 ,-401 ,-433 ,-466 ,-497 ,-530 ,-561 ,-591 ,-622 ,-652 ,-686 , -715 ,-745 ,-775 ,-805 ,-837 ,-864 ,-895 ,-923 ,-951 ,-980 ,-1008 ,-1035 ,-1066 ,-1093 ,-1118 , -1147 ,-1173 ,-1201 ,-1226 ,-1251 ,-1279 ,-1303 ,-1328 ,-1352 ,-1377 ,-1402 ,-1426 ,-1448 ,-1469 ,-1495 , -1517 ,-1539 ,-1562 ,-1581 ,-1602 ,-1625 ,-1644 ,-1665 ,-1687 ,-1703 ,-1725 ,-1743 ,-1762 ,-1781 ,-1799 , -1818 ,-1832 ,-1851 ,-1866 ,-1880 ,-1899 ,-1912 ,-1926 ,-1941 ,-1955 ,-1968 ,-1980 ,-1993 ,-2003 ,-2017 , -2027 ,-2036 ,-2047 ,-2055 ,-2066 ,-2073 ,-2083 ,-2091 ,-2098 ,-2106 ,-2112 ,-2118 ,-2124 ,-2130 ,-2135 , -2139 ,-2144 ,-2147 ,-2149 ,-2152 ,-2156 ,-2159 ,-2160 ,-2162 ,-2162 ,-2162 ,-2163 ,-2162 ,-2162 ,-2161 , -2159 ,-2156 ,-2154 ,-2153 ,-2150 ,-2145 ,-2142 ,-2137 ,-2132 ,-2127 ,-2121 ,-2116 ,-2109 ,-2103 ,-2094 , -2086 ,-2080 ,-2069 ,-2061 ,-2052 ,-2043 ,-2033 ,-2023 ,-2011 ,-1998 ,-1987 ,-1975 ,-1962 ,-1950 ,-1936 , -1921 ,-1908 ,-1894 ,-1879 ,-1867 ,-1849 ,-1832 ,-1819 ,-1801 ,-1784 ,-1768 ,-1750 ,-1734 ,-1715 ,-1697 , -1681 ,-1662 ,-1640 ,-1621 ,-1602 ,-1581 ,-1561 ,-1543 ,-1522 ,-1498 ,-1478 ,-1455 ,-1437 ,-1414 ,-1390 , -1369 ,-1346 ,-1324 ,-1298 ,-1275 ,-1252 ,-1227 ,-1202 ,-1177 ,-1150 ,-1125 ,-1101 ,-1075 ,-1050 ,-1021 , -996 ,-970 ,-943 ,-916 ,-887 ,-861 ,-834 ,-806 ,-778 ,-750 ,-723 ,-693 ,-666 ,-638 ,-608 , -579 ,-551 ,-523 ,-492 ,-464 ,-436 ,-407 ,-377 ,-349 ,-320 ,-291 ,-263 ,-235 ,-207 ,-177 , -151 ,-120 ,-92 ,-64 ,-33 ,-8 ,17 ,46 ,75 ,104 ,134 ,159 ,188 ,216 ,244 , 275 ,301 ,329 ,358 ,385 ,415 ,443 ,470 ,500 ,526 ,551 ,580 ,607 ,632 ,661 , 688 ,713 ,739 ,766 ,793 ,818 ,841 ,866 ,893 ,919 ,940 ,965 ,990 ,1012 ,1037 , 1062 ,1083 ,1105 ,1129 ,1150 ,1172 ,1192 ,1213 ,1236 ,1256 ,1277 ,1296 ,1316 ,1337 ,1355 , 1373 ,1394 ,1412 ,1432 ,1448 ,1467 ,1484 ,1501 ,1518 ,1534 ,1552 ,1568 ,1585 ,1599 ,1613 , 1628 ,1645 ,1658 ,1672 ,1686 ,1700 ,1714 ,1724 ,1738 ,1750 ,1760 ,1774 ,1784 ,1792 ,1805 , 1813 ,1822 ,1831 ,1840 ,1847 ,1858 ,1866 ,1871 ,1880 ,1884 ,1893 ,1896 ,1901 ,1907 ,1910 , 1914 ,1918 ,1921 ,1920 ,1926 ,1930 ,1930 ,1932 ,1934 ,1936 ,1936 ,1935 ,1936 ,1935 ,1932 , 1933 ,1931 ,1928 ,1925 ,1921 ,1918 ,1914 ,1911 ,1907 ,1903 ,1897 ,1891 ,1887 ,1879 ,1872 , 1869 ,1861 ,1851 ,1845 ,1836 ,1826 ,1818 ,1810 ,1798 ,1789 ,1781 ,1768 ,1757 ,1745 ,1733 , 1722 ,1707 ,1696 ,1680 ,1665 ,1653 ,1639 ,1623 ,1606 ,1592 ,1576 ,1560 ,1543 ,1526 ,1510 , 1493 ,1476 ,1455 ,1441 ,1422 ,1404 ,1386 ,1365 ,1348 ,1326 ,1307 ,1287 ,1267 ,1246 ,1227 , 1207 ,1185 ,1165 ,1143 ,1122 ,1099 ,1082 ,1059 ,1036 ,1015 ,992 ,972 ,949 ,927 ,904 , 881 ,860 ,836 ,812 ,790 ,766 ,740 ,719 ,696 ,669 ,645 ,622 ,595 ,572 ,549 , 522 ,497 ,470 ,446 ,421 ,396 ,369 ,343 ,320 ,294 ,268 ,243 ,218 ,192 ,168 , 141 ,116 ,92 ,65 ,41 ,17 ,-4 ,-29 ,-53 ,-77 ,-102 ,-127 ,-153 ,-177 ,-202 , -225 ,-249 ,-274 ,-298 ,-320 ,-343 ,-368 ,-391 ,-415 ,-437 ,-460 ,-484 ,-508 ,-530 ,-554 , -576 ,-599 ,-622 ,-643 ,-667 ,-689 ,-712 ,-733 ,-755 ,-777 ,-798 ,-820 ,-842 ,-864 ,-882 , -904 ,-924 ,-945 ,-965 ,-984 ,-1006 ,-1024 ,-1043 ,-1062 ,-1080 ,-1096 ,-1115 ,-1133 ,-1150 ,-1169 , -1186 ,-1202 ,-1217 ,-1234 ,-1252 ,-1265 ,-1282 ,-1296 ,-1310 ,-1325 ,-1339 ,-1351 ,-1366 ,-1381 ,-1393 , -1406 ,-1417 ,-1430 ,-1444 ,-1456 ,-1466 ,-1478 ,-1490 ,-1499 ,-1509 ,-1521 ,-1532 ,-1540 ,-1551 ,-1560 , -1568 ,-1577 ,-1582 ,-1590 ,-1599 ,-1607 ,-1611 ,-1619 ,-1625 ,-1628 ,-1636 ,-1640 ,-1644 ,-1647 ,-1650 , -1653 ,-1656 ,-1659 ,-1662 ,-1664 ,-1663 ,-1663 ,-1666 ,-1665 ,-1666 ,-1667 ,-1665 ,-1664 ,-1662 ,-1662 , -1659 ,-1658 ,-1655 ,-1650 ,-1648 ,-1645 ,-1639 ,-1634 ,-1630 ,-1624 ,-1618 ,-1614 ,-1607 ,-1601 ,-1595 , -1589 ,-1582 ,-1574 ,-1569 ,-1561 ,-1554 ,-1545 ,-1535 ,-1528 ,-1516 ,-1506 ,-1497 ,-1488 ,-1478 ,-1467 , -1456 ,-1444 ,-1432 ,-1421 ,-1409 ,-1396 ,-1385 ,-1372 ,-1357 ,-1343 ,-1331 ,-1315 ,-1301 ,-1287 ,-1272 , -1258 ,-1244 ,-1228 ,-1213 ,-1197 ,-1178 ,-1165 ,-1150 ,-1132 ,-1115 ,-1096 ,-1080 ,-1064 ,-1047 ,-1027 , -1009 ,-991 ,-973 ,-955 ,-935 ,-917 ,-898 ,-880 ,-860 ,-842 ,-824 ,-803 ,-785 ,-762 ,-744 , -724 ,-703 ,-683 ,-661 ,-641 ,-621 ,-601 ,-579 ,-560 ,-537 ,-514 ,-496 ,-473 ,-450 ,-429 , -406 ,-384 ,-363 ,-341 ,-317 ,-298 ,-275 ,-252 ,-232 ,-208 ,-185 ,-164 ,-142 ,-121 ,-98 , -74 ,-55 ,-30 ,-9 ,7 ,28 ,49 ,75 ,96 ,118 ,140 ,160 ,183 ,203 ,225 , 247 ,265 ,288 ,311 ,331 ,352 ,372 ,393 ,414 ,434 ,456 ,475 ,497 ,518 ,539 , 560 ,581 ,602 ,621 ,642 ,659 ,681 ,700 ,719 ,738 ,756 ,778 ,794 ,813 ,831 , 847 ,867 ,885 ,902 ,919 ,936 ,955 ,971 ,987 ,1003 ,1016 ,1035 ,1050 ,1063 ,1083 , 1093 ,1108 ,1124 ,1137 ,1152 ,1165 ,1178 ,1190 ,1203 ,1216 ,1226 ,1237 ,1249 ,1260 ,1271 , 1281 ,1292 ,1303 ,1312 ,1322 ,1331 ,1341 ,1349 ,1358 ,1366 ,1375 ,1384 ,1390 ,1397 ,1405 , 1410 ,1417 ,1422 ,1429 ,1435 ,1438 ,1445 ,1449 ,1454 ,1456 ,1461 ,1465 ,1467 ,1470 ,1474 , 1478 ,1478 ,1482 ,1484 ,1484 ,1485 ,1485 ,1486 ,1487 ,1487 ,1486 ,1485 ,1485 ,1484 ,1483 , 1481 ,1478 ,1477 ,1475 ,1472 ,1467 ,1464 ,1459 ,1456 ,1452 ,1447 ,1443 ,1436 ,1433 ,1427 , 1420 ,1414 ,1408 ,1402 ,1396 ,1390 ,1382 ,1375 ,1365 ,1359 ,1350 ,1341 ,1334 ,1322 ,1312 , 1303 ,1296 ,1284 ,1276 ,1264 ,1251 ,1241 ,1228 ,1219 ,1206 ,1194 ,1182 ,1170 ,1158 ,1145 , 1132 ,1117 ,1104 ,1090 ,1076 ,1062 ,1047 ,1032 ,1018 ,1004 ,989 ,973 ,957 ,941 ,926 , 911 ,895 ,878 ,862 ,845 ,829 ,812 ,795 ,778 ,759 ,743 ,725 ,705 ,690 ,672 , 654 ,638 ,620 ,601 ,584 ,563 ,545 ,527 ,507 ,490 ,471 ,453 ,433 ,413 ,396 , 378 ,355 ,338 ,319 ,297 ,280 ,262 ,240 ,221 ,201 ,179 ,162 ,140 ,122 ,103 , 81 ,64 ,43 ,24 ,4 ,-12 ,-32 ,-53 ,-70 ,-91 ,-109 ,-129 ,-149 ,-167 ,-186 , -204 ,-225 ,-241 ,-262 ,-280 ,-299 ,-318 ,-335 ,-354 ,-369 ,-390 ,-407 ,-425 ,-446 ,-461 , -480 ,-495 ,-512 ,-529 ,-545 ,-561 ,-580 ,-595 ,-610 ,-628 ,-641 ,-658 ,-673 ,-690 ,-706 , -720 ,-735 ,-749 ,-765 ,-780 ,-793 ,-809 ,-823 ,-836 ,-850 ,-863 ,-876 ,-889 ,-904 ,-916 , -932 ,-942 ,-953 ,-965 ,-977 ,-990 ,-999 ,-1012 ,-1023 ,-1034 ,-1045 ,-1054 ,-1065 ,-1076 ,-1085 , -1093 ,-1103 ,-1112 ,-1120 ,-1129 ,-1138 ,-1146 ,-1152 ,-1160 ,-1168 ,-1172 ,-1180 ,-1186 ,-1193 ,-1200 , -1206 ,-1209 ,-1215 ,-1221 ,-1225 ,-1231 ,-1234 ,-1239 ,-1242 ,-1248 ,-1251 ,-1252 ,-1257 ,-1259 ,-1261 , -1263 ,-1265 ,-1268 ,-1268 ,-1271 ,-1271 ,-1271 ,-1274 ,-1272 ,-1272 ,-1273 ,-1272 ,-1270 ,-1269 ,-1269 , -1268 ,-1267 ,-1264 ,-1260 ,-1259 ,-1255 ,-1254 ,-1250 ,-1245 ,-1242 ,-1236 ,-1233 ,-1226 ,-1222 ,-1220 , -1213 ,-1208 ,-1202 ,-1193 ,-1187 ,-1182 ,-1173 ,-1168 ,-1163 ,-1153 ,-1146 ,-1136 ,-1131 ,-1122 ,-1110 , -1102 ,-1092 ,-1083 ,-1073 ,-1062 ,-1053 ,-1046 ,-1034 ,-1021 ,-1013 ,-1001 ,-990 ,-978 ,-967 ,-959 , -946 ,-933 ,-921 ,-906 ,-895 ,-884 ,-870 ,-859 ,-845 ,-832 ,-818 ,-805 ,-790 ,-776 ,-763 , -748 ,-736 ,-720 ,-705 ,-691 ,-674 ,-660 ,-644 ,-629 ,-614 ,-596 ,-582 ,-567 ,-550 ,-536 , -520 ,-500 ,-487 ,-471 ,-453 ,-439 ,-419 ,-406 ,-389 ,-371 ,-357 ,-340 ,-324 ,-308 ,-289 , -272 ,-258 ,-240 ,-222 ,-205 ,-188 ,-172 ,-156 ,-139 ,-120 ,-105 ,-88 ,-72 ,-56 ,-38 , -21 ,-7 ,5 ,22 ,40 ,57 ,72 ,89 ,108 ,122 ,139 ,155 ,173 ,190 ,205 , 222 ,237 ,253 ,270 ,286 ,301 ,320 ,335 ,348 ,363 ,381 ,398 ,411 ,427 ,445 , 458 ,474 ,493 ,504 ,519 ,536 ,549 ,566 ,578 ,594 ,608 ,620 ,637 ,647 ,661 , 677 ,689 ,701 ,716 ,727 ,739 ,753 ,763 ,777 ,789 ,799 ,812 ,823 ,835 ,847 , 859 ,869 ,878 ,889 ,898 ,908 ,918 ,929 ,940 ,947 ,957 ,965 ,976 ,984 ,992 , 1002 ,1006 ,1015 ,1024 ,1031 ,1039 ,1045 ,1052 ,1058 ,1064 ,1073 ,1078 ,1084 ,1090 ,1095 , 1099 ,1102 ,1108 ,1113 ,1119 ,1122 ,1124 ,1127 ,1131 ,1136 ,1136 ,1139 ,1141 ,1144 ,1146 , 1145 ,1148 ,1149 ,1150 ,1150 ,1152 ,1151 ,1151 ,1152 ,1149 ,1150 ,1147 ,1148 ,1146 ,1144 , 1143 ,1140 ,1138 ,1136 ,1134 ,1131 ,1130 ,1125 ,1121 ,1118 ,1114 ,1110 ,1102 ,1100 ,1095 , 1091 ,1085 ,1079 ,1076 ,1068 ,1060 ,1054 ,1049 ,1043 ,1035 ,1028 ,1020 ,1013 ,1006 ,997 , 992 ,982 ,974 ,966 ,957 ,950 ,939 ,928 ,920 ,910 ,900 ,890 ,879 ,869 ,858 , 847 ,835 ,826 ,813 ,802 ,793 ,780 ,769 ,757 ,746 ,735 ,723 ,712 ,700 ,687 , 676 ,664 ,652 ,639 ,627 ,612 ,599 ,589 ,576 ,561 ,546 ,535 ,521 ,506 ,495 , 480 ,467 ,453 ,438 ,424 ,412 ,397 ,380 ,369 ,351 ,337 ,325 ,308 ,292 ,278 , 264 ,247 ,234 ,220 ,204 ,189 ,174 ,159 ,143 ,130 ,114 ,100 ,86 ,69 ,57 , 40 ,26 ,12 ,-1 ,-12 ,-26 ,-40 ,-55 ,-71 ,-85 ,-99 ,-113 ,-129 ,-143 ,-156 , -170 ,-185 ,-198 ,-212 ,-228 ,-240 ,-256 ,-269 ,-282 ,-296 ,-311 ,-324 ,-338 ,-353 ,-365 , -380 ,-392 ,-408 ,-421 ,-430 ,-444 ,-457 ,-471 ,-484 ,-497 ,-510 ,-522 ,-534 ,-547 ,-557 , -570 ,-582 ,-593 ,-604 ,-616 ,-627 ,-636 ,-649 ,-659 ,-670 ,-680 ,-690 ,-701 ,-708 ,-720 , -730 ,-737 ,-746 ,-755 ,-763 ,-773 ,-780 ,-788 ,-799 ,-806 ,-813 ,-823 ,-831 ,-836 ,-844 , -849 ,-857 ,-865 ,-870 ,-876 ,-880 ,-887 ,-892 ,-896 ,-904 ,-909 ,-913 ,-917 ,-922 ,-927 , -929 ,-934 ,-939 ,-942 ,-946 ,-949 ,-953 ,-956 ,-957 ,-959 ,-960 ,-964 ,-964 ,-967 ,-968 , -967 ,-969 ,-969 ,-968 ,-968 ,-969 ,-968 ,-967 ,-968 ,-967 ,-966 ,-966 ,-966 ,-962 ,-960 , -957 ,-955 ,-953 ,-950 ,-947 ,-946 ,-943 ,-940 ,-937 ,-932 ,-929 ,-926 ,-924 ,-918 ,-916 , -911 ,-905 ,-903 ,-896 ,-893 ,-887 ,-882 ,-878 ,-871 ,-866 ,-860 ,-855 ,-850 ,-844 ,-837 , -829 ,-822 ,-814 ,-807 ,-802 ,-792 ,-785 ,-776 ,-767 ,-759 ,-749 ,-743 ,-732 ,-723 ,-715 , -707 ,-698 ,-688 ,-677 ,-668 ,-658 ,-646 ,-635 ,-627 ,-616 ,-606 ,-599 ,-586 ,-574 ,-565 , -553 ,-542 ,-531 ,-519 ,-507 ,-495 ,-485 ,-473 ,-460 ,-451 ,-438 ,-426 ,-414 ,-403 ,-390 , -378 ,-367 ,-354 ,-342 ,-327 ,-317 ,-306 ,-293 ,-279 ,-266 ,-252 ,-238 ,-226 ,-213 ,-199 , -186 ,-173 ,-159 ,-149 ,-135 ,-120 ,-108 ,-96 ,-81 ,-67 ,-57 ,-42 ,-30 ,-17 ,-6 , 4 ,20 ,31 ,45 ,57 ,70 ,84 ,97 ,111 ,124 ,137 ,148 ,161 ,175 ,189 , 201 ,212 ,224 ,239 ,250 ,262 ,275 ,286 ,298 ,309 ,321 ,332 ,345 ,358 ,369 , 383 ,391 ,402 ,415 ,425 ,436 ,447 ,459 ,471 ,482 ,492 ,503 ,515 ,525 ,536 , 545 ,556 ,566 ,574 ,584 ,593 ,602 ,612 ,621 ,630 ,637 ,647 ,655 ,662 ,671 , 679 ,686 ,694 ,701 ,707 ,715 ,723 ,730 ,738 ,742 ,749 ,754 ,759 ,766 ,770 , 777 ,782 ,787 ,790 ,797 ,801 ,805 ,812 ,812 ,819 ,825 ,826 ,831 ,835 ,839 , 842 ,846 ,850 ,853 ,855 ,858 ,863 ,865 ,867 ,870 ,871 ,875 ,879 ,878 ,881 , 880 ,881 ,885 ,885 ,886 ,883 ,885 ,885 ,884 ,885 ,883 ,882 ,882 ,881 ,878 , 878 ,877 ,873 ,871 ,870 ,869 ,865 ,864 ,858 ,855 ,854 ,849 ,845 ,843 ,838 , 834 ,832 ,826 ,822 ,817 ,813 ,808 ,802 ,799 ,792 ,787 ,782 ,776 ,770 ,762 , 756 ,749 ,745 ,740 ,730 ,723 ,717 ,709 ,703 ,695 ,688 ,678 ,670 ,664 ,654 , 649 ,637 ,629 ,623 ,613 ,602 ,593 ,584 ,573 ,566 ,557 ,545 ,537 ,527 ,516 , 506 ,495 ,487 ,476 ,464 ,456 ,445 ,436 ,426 ,413 ,403 ,394 ,383 ,370 ,362 , 353 ,341 ,329 ,319 ,309 ,298 ,286 ,277 ,266 ,253 ,242 ,233 ,221 ,208 ,198 , 187 ,174 ,164 ,154 ,142 ,128 ,119 ,106 ,96 ,85 ,72 ,62 ,48 ,38 ,25 , 16 ,4 ,-8 ,-15 ,-28 ,-41 ,-50 ,-61 ,-73 ,-83 ,-96 ,-105 ,-117 ,-130 ,-139 , -149 ,-159 ,-171 ,-181 ,-192 ,-202 ,-212 ,-221 ,-232 ,-243 ,-252 ,-260 ,-271 ,-280 ,-290 , -303 ,-311 ,-320 ,-331 ,-339 ,-348 ,-358 ,-368 ,-377 ,-387 ,-395 ,-404 ,-413 ,-420 ,-431 , -439 ,-448 ,-454 ,-462 ,-474 ,-480 ,-490 ,-497 ,-504 ,-513 ,-521 ,-530 ,-537 ,-545 ,-551 , -560 ,-567 ,-573 ,-581 ,-589 ,-595 ,-600 ,-606 ,-615 ,-623 ,-625 ,-633 ,-638 ,-643 ,-649 , -652 ,-658 ,-662 ,-669 ,-673 ,-677 ,-682 ,-687 ,-693 ,-697 ,-700 ,-704 ,-707 ,-710 ,-714 , -716 ,-720 ,-723 ,-726 ,-728 ,-730 ,-734 ,-734 ,-737 ,-739 ,-740 ,-742 ,-742 ,-744 ,-745 , -745 ,-745 ,-747 ,-748 ,-748 ,-747 ,-747 ,-747 ,-748 ,-746 ,-744 ,-744 ,-742 ,-740 ,-739 , -736 ,-735 ,-732 ,-728 ,-727 ,-723 ,-720 ,-716 ,-714 ,-710 ,-708 ,-704 ,-700 ,-698 ,-693 , -689 ,-686 ,-682 ,-676 ,-674 ,-669 ,-664 ,-660 ,-654 ,-649 ,-642 ,-639 ,-634 ,-628 ,-624 , -617 ,-611 ,-606 ,-600 ,-592 ,-587 ,-582 ,-575 ,-569 ,-561 ,-554 ,-548 ,-542 ,-536 ,-527 , -522 ,-514 ,-505 ,-500 ,-492 ,-485 ,-476 ,-468 ,-460 ,-452 ,-443 ,-433 ,-424 ,-419 ,-412 , -400 ,-394 ,-385 ,-377 ,-368 ,-358 ,-348 ,-340 ,-329 ,-320 ,-312 ,-303 ,-295 ,-284 ,-275 , -268 ,-255 ,-246 ,-238 ,-227 ,-217 ,-209 ,-200 ,-190 ,-179 ,-170 ,-161 ,-151 ,-143 ,-133 , -123 ,-114 ,-106 ,-94 ,-85 ,-76 ,-64 ,-57 ,-46 ,-35 ,-27 ,-16 ,-6 ,-2 ,4 , 18 ,28 ,34 ,47 ,57 ,65 ,78 ,87 ,96 ,107 ,116 ,125 ,137 ,147 ,155 , 165 ,174 ,187 ,197 ,205 ,216 ,226 ,234 ,243 ,252 ,262 ,274 ,280 ,290 ,301 , 308 ,317 ,327 ,334 ,343 ,351 ,360 ,368 ,376 ,385 ,391 ,399 ,407 ,415 ,421 , 428 ,437 ,443 ,452 ,460 ,466 ,474 ,481 ,488 ,494 ,501 ,508 ,515 ,521 ,529 , 536 ,540 ,547 ,553 ,561 ,567 ,571 ,578 ,583 ,589 ,595 ,599 ,604 ,610 ,613 , 616 ,622 ,626 ,630 ,633 ,636 ,636 ,644 ,645 ,647 ,652 ,652 ,658 ,657 ,658 , 661 ,662 ,664 ,666 ,668 ,668 ,670 ,671 ,673 ,673 ,674 ,677 ,676 ,678 ,677 , 678 ,679 ,679 ,680 ,679 ,679 ,678 ,679 ,679 ,676 ,676 ,677 ,676 ,675 ,673 , 673 ,672 ,670 ,667 ,664 ,664 ,660 ,657 ,656 ,654 ,650 ,650 ,648 ,643 ,640 , 635 ,634 ,629 ,625 ,623 ,618 ,612 ,606 ,606 ,599 ,593 ,593 ,586 ,580 ,577 , 571 ,565 ,562 ,555 ,549 ,546 ,541 ,534 ,531 ,525 ,518 ,514 ,509 ,503 ,495 , 490 ,485 ,478 ,474 ,467 ,460 ,455 ,449 ,440 ,433 ,428 ,421 ,413 ,406 ,398 , 392 ,385 ,376 ,368 ,361 ,351 ,344 ,336 ,326 ,320 ,310 ,302 ,294 ,282 ,275 , 268 ,256 ,249 ,239 ,230 ,223 ,213 ,204 ,194 ,186 ,177 ,166 ,159 ,149 ,140 , 130 ,123 ,113 ,104 ,97 ,85 ,77 ,69 ,59 ,53 ,42 ,34 ,25 ,18 ,10 , 1 ,-4 ,-15 ,-21 ,-29 ,-39 ,-46 ,-55 ,-62 ,-73 ,-80 ,-87 ,-98 ,-105 ,-113 , -124 ,-133 ,-139 ,-147 ,-157 ,-164 ,-172 ,-183 ,-189 ,-198 ,-207 ,-213 ,-222 ,-230 ,-237 , -245 ,-252 ,-262 ,-269 ,-274 ,-282 ,-287 ,-296 ,-303 ,-309 ,-317 ,-322 ,-329 ,-336 ,-341 , -347 ,-356 ,-362 ,-366 ,-373 ,-378 ,-384 ,-390 ,-396 ,-402 ,-407 ,-411 ,-416 ,-423 ,-425 , -432 ,-439 ,-441 ,-448 ,-454 ,-456 ,-463 ,-467 ,-472 ,-477 ,-480 ,-487 ,-490 ,-493 ,-497 , -498 ,-502 ,-508 ,-511 ,-513 ,-517 ,-522 ,-523 ,-528 ,-530 ,-531 ,-536 ,-538 ,-540 ,-541 , -544 ,-544 ,-547 ,-550 ,-549 ,-553 ,-555 ,-556 ,-557 ,-558 ,-559 ,-559 ,-561 ,-560 ,-560 , -562 ,-560 ,-560 ,-562 ,-561 ,-561 ,-560 ,-561 ,-560 ,-561 ,-560 ,-559 ,-561 ,-558 ,-556 , -554 ,-553 ,-552 ,-551 ,-551 ,-548 ,-549 ,-546 ,-543 ,-542 ,-539 ,-539 ,-536 ,-534 ,-531 , -528 ,-525 ,-523 ,-519 ,-515 ,-513 ,-507 ,-503 ,-500 ,-496 ,-494 ,-488 ,-485 ,-481 ,-476 , -471 ,-466 ,-463 ,-456 ,-451 ,-446 ,-442 ,-435 ,-430 ,-425 ,-417 ,-413 ,-408 ,-403 ,-398 , -390 ,-385 ,-377 ,-369 ,-365 ,-360 ,-352 ,-346 ,-339 ,-332 ,-326 ,-319 ,-313 ,-309 ,-301 , -293 ,-286 ,-279 ,-273 ,-266 ,-259 ,-251 ,-244 ,-239 ,-233 ,-224 ,-215 ,-210 ,-202 ,-195 , -188 ,-180 ,-172 ,-165 ,-158 ,-150 ,-145 ,-136 ,-128 ,-120 ,-112 ,-105 ,-97 ,-89 ,-84 , -74 ,-66 ,-59 ,-50 ,-44 ,-36 ,-30 ,-22 ,-14 ,-7 ,-2 ,2 ,12 ,19 ,27 , 33 ,41 ,50 ,57 ,65 ,73 ,80 ,87 ,95 ,102 ,109 ,117 ,126 ,131 ,139 , 148 ,152 ,160 ,164 ,173 ,181 ,188 ,196 ,203 ,208 ,214 ,222 ,230 ,235 ,242 , 248 ,252 ,262 ,268 ,274 ,282 ,285 ,292 ,299 ,307 ,314 ,319 ,325 ,330 ,337 , 344 ,348 ,353 ,358 ,363 ,370 ,374 ,378 ,384 ,389 ,394 ,399 ,403 ,408 ,413 , 417 ,423 ,427 ,432 ,436 ,439 ,445 ,448 ,453 ,456 ,460 ,463 ,467 ,475 ,475 , 479 ,482 ,485 ,490 ,492 ,496 ,500 ,502 ,503 ,506 ,507 ,510 ,513 ,514 ,517 , 520 ,523 ,524 ,525 ,525 ,528 ,529 ,528 ,532 ,532 ,532 ,532 ,535 ,535 ,535 , 535 ,535 ,535 ,533 ,535 ,534 ,533 ,534 ,534 ,534 ,532 ,531 ,528 ,527 ,525 , 523 ,522 ,522 ,518 ,518 ,516 ,511 ,510 ,508 ,504 ,501 ,498 ,496 ,493 ,489 , 486 ,482 ,479 ,477 ,472 ,468 ,466 ,462 ,458 ,456 ,450 ,449 ,446 ,443 ,437 , 432 ,433 ,425 ,421 ,420 ,414 ,410 ,406 ,405 ,398 ,393 ,390 ,384 ,379 ,374 , 370 ,363 ,360 ,356 ,350 ,345 ,340 ,335 ,330 ,323 ,317 ,313 ,307 ,301 ,294 , 287 ,281 ,275 ,269 ,264 ,256 ,251 ,246 ,239 ,234 ,227 ,221 ,214 ,207 ,201 , 195 ,189 ,183 ,175 ,171 ,164 ,156 ,150 ,144 ,137 ,131 ,125 ,119 ,112 ,105 , 98 ,93 ,87 ,78 ,72 ,67 ,60 ,53 ,48 ,38 ,31 ,27 ,18 ,11 ,5 , 0 ,-5 ,-12 ,-19 ,-24 ,-31 ,-37 ,-47 ,-53 ,-58 ,-67 ,-74 ,-79 ,-83 ,-92 , -99 ,-104 ,-111 ,-118 ,-121 ,-130 ,-137 ,-138 ,-148 ,-155 ,-160 ,-166 ,-173 ,-179 ,-184 , -190 ,-194 ,-201 ,-207 ,-213 ,-220 ,-223 ,-229 ,-234 ,-239 ,-247 ,-248 ,-256 ,-263 ,-266 , -272 ,-276 ,-280 ,-284 ,-289 ,-294 ,-299 ,-305 ,-309 ,-313 ,-319 ,-324 ,-328 ,-332 ,-337 , -341 ,-345 ,-351 ,-354 ,-357 ,-362 ,-367 ,-370 ,-372 ,-375 ,-380 ,-381 ,-384 ,-389 ,-390 , -393 ,-395 ,-397 ,-398 ,-402 ,-405 ,-405 ,-410 ,-410 ,-410 ,-413 ,-413 ,-415 ,-418 ,-419 , -421 ,-423 ,-422 ,-421 ,-423 ,-424 ,-425 ,-425 ,-425 ,-426 ,-425 ,-426 ,-425 ,-425 ,-427 , -425 ,-425 ,-425 ,-425 ,-426 ,-425 ,-425 ,-424 ,-424 ,-425 ,-424 ,-425 ,-422 ,-421 ,-420 , -417 ,-416 ,-416 ,-415 ,-412 ,-412 ,-410 ,-407 ,-406 ,-405 ,-403 ,-402 ,-399 ,-397 ,-395 , -392 ,-390 ,-387 ,-385 ,-381 ,-379 ,-376 ,-374 ,-373 ,-369 ,-365 ,-363 ,-359 ,-354 ,-351 , -348 ,-346 ,-340 ,-336 ,-333 ,-327 ,-324 ,-321 ,-315 ,-313 ,-308 ,-303 ,-299 ,-294 ,-290 , -285 ,-284 ,-278 ,-273 ,-268 ,-264 ,-259 ,-255 ,-252 ,-244 ,-241 ,-235 ,-231 ,-225 ,-219 , -217 ,-210 ,-203 ,-199 ,-194 ,-191 ,-186 ,-177 ,-173 ,-169 ,-163 ,-158 ,-152 ,-145 ,-142 , -138 ,-129 ,-125 ,-116 ,-111 ,-106 ,-98 ,-94 ,-88 ,-82 ,-75 ,-68 ,-63 ,-55 ,-51 , -44 ,-36 ,-31 ,-24 ,-19 ,-15 ,-8 ,-3 ,0 ,5 ,13 ,20 ,26 ,32 ,35 , 41 ,49 ,54 ,62 ,65 ,70 ,78 ,81 ,88 ,95 ,100 ,105 ,111 ,118 ,122 , 127 ,134 ,139 ,144 ,150 ,156 ,160 ,164 ,172 ,177 ,181 ,187 ,192 ,200 ,205 , 208 ,215 ,218 ,225 ,233 ,235 ,239 ,246 ,250 ,253 ,258 ,264 ,267 ,271 ,274 , 278 ,282 ,285 ,290 ,295 ,298 ,302 ,305 ,309 ,313 ,315 ,320 ,323 ,326 ,326 , 330 ,334 ,337 ,340 ,342 ,346 ,348 ,350 ,357 ,361 ,362 ,363 ,367 ,369 ,369 , 372 ,375 ,377 ,380 ,383 ,385 ,386 ,389 ,392 ,391 ,394 ,396 ,395 ,397 ,401 , 401 ,402 ,404 ,404 ,404 ,405 ,406 ,406 ,406 ,406 ,408 ,409 ,408 ,409 ,409 , 409 ,407 ,408 ,410 ,410 ,407 ,407 ,407 ,409 ,408 ,405 ,406 ,406 ,405 ,405 , 403 ,401 ,402 ,400 ,396 ,398 ,398 ,395 ,395 ,393 ,391 ,391 ,388 ,387 ,383 , 381 ,380 ,376 ,374 ,372 ,370 ,367 ,364 ,362 ,359 ,354 ,352 ,349 ,346 ,343 , 337 ,334 ,329 ,328 ,325 ,322 ,319 ,313 ,311 ,306 ,304 ,298 ,295 ,291 ,286 , 284 ,280 ,276 ,271 ,268 ,263 ,258 ,253 ,249 ,244 ,238 ,237 ,232 ,227 ,221 , 217 ,213 ,206 ,203 ,199 ,193 ,191 ,185 ,180 ,175 ,168 ,163 ,159 ,155 ,149 , 144 ,138 ,135 ,128 ,121 ,117 ,110 ,105 ,99 ,95 ,89 ,83 ,77 ,73 ,66 , 62 ,57 ,51 ,48 ,40 ,34 ,32 ,26 ,18 ,16 ,11 ,5 ,2 ,-2 ,-3 , -9 ,-14 ,-18 ,-22 ,-25 ,-31 ,-35 ,-40 ,-47 ,-51 ,-56 ,-60 ,-63 ,-68 ,-74 , -77 ,-81 ,-87 ,-92 ,-98 ,-100 ,-105 ,-111 ,-114 ,-120 ,-125 ,-132 ,-136 ,-139 ,-146 , -149 ,-154 ,-158 ,-162 ,-167 ,-172 ,-175 ,-178 ,-186 ,-189 ,-190 ,-196 ,-198 ,-201 ,-205 , -209 ,-213 ,-215 ,-219 ,-222 ,-227 ,-231 ,-234 ,-236 ,-239 ,-243 ,-243 ,-248 ,-250 ,-252 , -258 ,-259 ,-263 ,-265 ,-270 ,-269 ,-274 ,-277 ,-276 ,-283 ,-284 ,-286 ,-289 ,-291 ,-295 , -297 ,-300 ,-302 ,-304 ,-306 ,-311 ,-310 ,-309 ,-314 ,-314 ,-316 ,-317 ,-317 ,-320 ,-319 , -322 ,-322 ,-322 ,-326 ,-325 ,-325 ,-325 ,-327 ,-328 ,-326 ,-327 ,-326 ,-327 ,-327 ,-326 , -325 ,-326 ,-326 ,-323 ,-325 ,-324 ,-323 ,-321 ,-321 ,-323 ,-318 ,-319 ,-317 ,-317 ,-318 , -315 ,-314 ,-315 ,-315 ,-312 ,-312 ,-308 ,-307 ,-307 ,-307 ,-305 ,-301 ,-302 ,-299 ,-298 , -294 ,-293 ,-292 ,-286 ,-287 ,-284 ,-283 ,-279 ,-276 ,-275 ,-272 ,-271 ,-267 ,-264 ,-260 , -259 ,-254 ,-249 ,-247 ,-245 ,-241 ,-236 ,-233 ,-228 ,-226 ,-221 ,-217 ,-215 ,-207 ,-205 , -201 ,-199 ,-194 ,-190 ,-186 ,-182 ,-179 ,-175 ,-172 ,-169 ,-166 ,-160 ,-158 ,-156 ,-151 , -147 ,-143 ,-142 ,-138 ,-136 ,-131 ,-124 ,-123 ,-119 ,-116 ,-110 ,-109 ,-103 ,-98 ,-97 , -92 ,-87 ,-83 ,-80 ,-74 ,-72 ,-65 ,-61 ,-57 ,-50 ,-48 ,-42 ,-36 ,-30 ,-27 , -21 ,-17 ,-14 ,-8 ,-3 ,-1 ,-1 ,5 ,14 ,17 ,22 ,26 ,29 ,34 ,38 , 42 ,48 ,52 ,55 ,59 ,63 ,67 ,69 ,75 ,78 ,81 ,87 ,90 ,96 ,96 , 102 ,107 ,108 ,115 ,119 ,123 ,127 ,133 ,137 ,140 ,145 ,150 ,153 ,158 ,164 , 166 ,171 ,174 ,180 ,184 ,186 ,194 ,196 ,202 ,205 ,208 ,213 ,215 ,220 ,225 , 228 ,229 ,236 ,237 ,240 ,244 ,249 ,251 ,251 ,254 ,255 ,260 ,262 ,265 ,267 , 269 ,273 ,272 ,275 ,276 ,277 ,280 ,281 ,284 ,287 ,286 ,288 ,289 ,290 ,294 , 294 ,296 ,299 ,300 ,302 ,303 ,304 ,305 ,307 ,306 ,308 ,313 ,314 ,315 ,317 , 317 ,318 ,319 ,321 ,320 ,322 ,322 ,321 ,323 ,324 ,324 ,322 ,324 ,323 ,319 , 321 ,321 ,317 ,317 ,318 ,316 ,315 ,316 ,314 ,311 ,310 ,307 ,305 ,304 ,304 , 304 ,302 ,301 ,299 ,297 ,295 ,294 ,292 ,290 ,291 ,288 ,286 ,286 ,285 ,283 , 282 ,280 ,281 ,280 ,278 ,277 ,276 ,273 ,273 ,271 ,270 ,270 ,266 ,265 ,262 , 261 ,258 ,253 ,251 ,250 ,247 ,243 ,241 ,237 ,236 ,231 ,228 ,226 ,222 ,220 , 215 ,215 ,209 ,205 ,201 ,197 ,194 ,190 ,189 ,182 ,181 ,176 ,173 ,169 ,164 , 162 ,158 ,157 ,151 ,148 ,145 ,141 ,138 ,133 ,130 ,125 ,125 ,121 ,116 ,114 , 112 ,107 ,104 ,103 ,97 ,92 ,91 ,86 ,80 ,79 ,73 ,70 ,66 ,61 ,58 , 53 ,49 ,43 ,38 ,37 ,32 ,28 ,24 ,19 ,15 ,9 ,6 ,1 ,-1 ,-6 , -9 ,-12 ,-18 ,-21 ,-27 ,-30 ,-34 ,-37 ,-42 ,-46 ,-49 ,-56 ,-58 ,-61 ,-65 , -69 ,-72 ,-74 ,-78 ,-80 ,-86 ,-88 ,-91 ,-95 ,-98 ,-101 ,-105 ,-109 ,-110 ,-114 , -115 ,-119 ,-124 ,-125 ,-132 ,-132 ,-135 ,-140 ,-141 ,-145 ,-149 ,-152 ,-152 ,-156 ,-161 , -162 ,-167 ,-168 ,-172 ,-176 ,-177 ,-181 ,-182 ,-187 ,-188 ,-188 ,-191 ,-192 ,-196 ,-197 , -199 ,-201 ,-202 ,-204 ,-206 ,-206 ,-207 ,-209 ,-211 ,-212 ,-214 ,-214 ,-214 ,-215 ,-217 , -219 ,-219 ,-220 ,-219 ,-221 ,-222 ,-222 ,-221 ,-224 ,-226 ,-226 ,-227 ,-228 ,-231 ,-230 , -231 ,-233 ,-233 ,-235 ,-234 ,-237 ,-237 ,-237 ,-239 ,-238 ,-239 ,-243 ,-243 ,-241 ,-244 , -243 ,-243 ,-244 ,-244 ,-246 ,-248 ,-247 ,-248 ,-247 ,-247 ,-247 ,-244 ,-245 ,-244 ,-242 , -241 ,-239 ,-238 ,-237 ,-236 ,-233 ,-233 ,-232 ,-230 ,-229 ,-226 ,-223 ,-223 ,-221 ,-219 , -218 ,-215 ,-216 ,-213 ,-211 ,-209 ,-207 ,-205 ,-203 ,-201 ,-200 ,-199 ,-196 ,-195 ,-193 , -190 ,-188 ,-187 ,-187 ,-182 ,-180 ,-179 ,-174 ,-174 ,-170 ,-167 ,-167 ,-162 ,-161 ,-160 , -155 ,-153 ,-152 ,-146 ,-143 ,-141 ,-138 ,-134 ,-129 ,-124 ,-121 ,-119 ,-114 ,-110 ,-107 , -103 ,-99 ,-98 ,-93 ,-90 ,-85 ,-81 ,-78 ,-73 ,-72 ,-67 ,-65 ,-62 ,-56 ,-55 , -50 ,-49 ,-45 ,-40 ,-36 ,-33 ,-31 ,-27 ,-22 ,-20 ,-18 ,-13 ,-11 ,-9 ,-6 , -3 ,0 ,-2 ,2 ,8 ,10 ,15 ,16 ,22 ,24 ,27 ,32 ,36 ,37 ,39 , 45 ,50 ,54 ,56 ,60 ,62 ,65 ,70 ,71 ,74 ,77 ,81 ,84 ,88 ,92 , 94 ,95 ,99 ,103 ,104 ,106 ,110 ,113 ,116 ,119 ,120 ,121 ,126 ,129 ,130 , 135 ,134 ,136 ,139 ,141 ,145 ,147 ,148 ,149 ,153 ,154 ,156 ,163 ,162 ,163 , 168 ,170 ,172 ,173 ,179 ,182 ,183 ,187 ,190 ,192 ,194 ,197 ,199 ,203 ,204 , 207 ,209 ,212 ,215 ,216 ,219 ,220 ,223 ,224 ,227 ,228 ,228 ,232 ,234 ,234 , 235 ,236 ,235 ,236 ,239 ,237 ,239 ,242 ,240 ,241 ,242 ,243 ,244 ,246 ,245 , 246 ,248 ,247 ,248 ,247 ,249 ,248 ,249 ,249 ,248 ,250 ,249 ,250 ,249 ,249 , 251 ,250 ,250 ,250 ,251 ,252 ,250 ,249 ,249 ,249 ,249 ,248 ,248 ,246 ,246 , 246 ,243 ,242 ,241 ,240 ,238 ,236 ,236 ,236 ,234 ,230 ,230 ,228 ,228 ,226 , 221 ,223 ,218 ,214 ,215 ,211 ,211 ,208 ,206 ,206 ,204 ,202 ,198 ,195 ,193 , 191 ,190 ,187 ,184 ,184 ,182 ,182 ,178 ,176 ,172 ,172 ,169 ,164 ,165 ,161 , 160 ,156 ,156 ,153 ,149 ,149 ,147 ,144 ,138 ,138 ,134 ,132 ,132 ,126 ,123 , 123 ,119 ,117 ,116 ,112 ,109 ,105 ,104 ,103 ,98 ,94 ,93 ,92 ,88 ,86 , 82 ,80 ,77 ,74 ,73 ,71 ,65 ,62 ,60 ,58 ,55 ,53 ,51 ,48 ,46 , 41 ,39 ,37 ,31 ,31 ,29 ,26 ,22 ,18 ,16 ,14 ,10 ,7 ,816 ,-4954 , -12866 ,-12799 ,-13917 ,-13687 ,-13641 ,-13498 ,-13174 ,-13433 ,-13127 ,-13327 ,-12750 ,-12796 ,-11900 ,-11814 ,-10056 , -10117 ,-10045 ,-8169 ,-10085 ,-8812 ,-8181 ,1679 ,13665 ,8319 ,7775 ,16654 ,18401 ,13349 ,13353 ,22288 , 27227 ,24442 ,15645 ,17240 ,25604 ,23945 ,24483 ,21626 ,18899 ,21229 ,24607 ,25142 ,24623 ,23021 ,22049 , 27754 ,24093 ,9647 ,5266 ,13759 ,9936 ,3725 ,7843 ,6741 ,7740 ,16472 ,7320 ,-10282 ,-11544 ,-6665 , -4777 ,-3947 ,-7145 ,-6626 ,-4055 ,-16689 ,-20086 ,-19345 ,-9561 ,-8524 ,-28630 ,-28712 ,-23578 ,-18104 ,-17053 , -12007 ,-9587 ,-27517 ,-32768 ,-21415 ,-20348 ,-13235 ,-11103 ,-27627 ,-25477 ,-19702 ,-12974 ,-8949 ,-12815 ,-15285 , -8535 ,-918 ,-14523 ,-22750 ,-12764 ,-608 ,-7405 ,-3114 ,3725 ,-8949 ,-1833 ,4762 ,236 ,-4143 ,-5576 , 8835 ,12750 ,5392 ,11109 ,13337 ,4965 ,3157 ,9409 ,12726 ,22557 ,27208 ,14928 ,6247 ,6609 ,13783 , 19660 ,20033 ,27642 ,26765 ,13416 ,11937 ,18215 ,22207 ,12935 ,15820 ,26182 ,15035 ,14200 ,10573 ,9518 , 14342 ,10535 ,15197 ,11432 ,8134 ,2261 ,2880 ,9124 ,5228 ,3810 ,-4209 ,-4309 ,-2809 ,-5539 ,2839 , -2229 ,-10603 ,-9222 ,-17432 ,-12758 ,-11066 ,-17218 ,-14173 ,-15162 ,-12179 ,-10886 ,-11231 ,-17772 ,-24574 ,-24674 , -15373 ,-9327 ,-18391 ,-17801 ,-20555 ,-21618 ,-15688 ,-14375 ,-11363 ,-9781 ,-12807 ,-13892 ,-11863 ,-10802 ,-8582 , -8493 ,-2524 ,495 ,-5539 ,-11193 ,-14334 ,-7079 ,1184 ,2179 ,10075 ,6889 ,-5100 ,6208 ,6648 ,790 , 7845 ,5232 ,7632 ,11723 ,10303 ,13871 ,11990 ,10599 ,10307 ,10361 ,15357 ,11517 ,16176 ,17259 ,14541 , 15990 ,10317 ,11789 ,15838 ,17589 ,14846 ,21267 ,19270 ,10067 ,6481 ,3656 ,8234 ,13774 ,15308 ,12536 , 11268 ,2325 ,-1008 ,3278 ,4986 ,5751 ,4659 ,5763 ,7437 ,-3862 ,-9625 ,-6953 ,-6459 ,-37 ,-6330 , -9053 ,-10254 ,-7193 ,-6981 ,-16467 ,-16075 ,-11776 ,-3609 ,-11205 ,-17192 ,-13278 ,-17337 ,-18344 ,-11427 ,-10909 , -16205 ,-12519 ,-14943 ,-16615 ,-12491 ,-14933 ,-10693 ,-5979 ,-10976 ,-13673 ,-7032 ,-5939 ,-12882 ,-7667 ,-4883 , -8903 ,-1376 ,-493 ,-6631 ,-1274 ,2091 ,-1191 ,-1579 ,7 ,6254 ,12204 ,3955 ,-75 ,1869 ,7598 , 15490 ,9614 ,8700 ,7335 ,5747 ,8064 ,12681 ,16294 ,9804 ,8510 ,15254 ,16562 ,13022 ,11386 ,6596 , 7455 ,12741 ,12370 ,11407 ,17779 ,14369 ,4257 ,6121 ,8140 ,9961 ,9693 ,9679 ,7786 ,5524 ,5669 , 3882 ,9351 ,3453 ,-4718 ,-1135 ,-1293 ,5325 ,4823 ,-4252 ,-7244 ,-9434 ,-9023 ,-4889 ,1481 ,-3631 , -11427 ,-8577 ,-8176 ,-12650 ,-13838 ,-10510 ,-9304 ,-4429 ,-4292 ,-13887 ,-14424 ,-15522 ,-17360 ,-13087 ,-10830 , -8676 ,-9301 ,-8661 ,-8240 ,-9313 ,-11231 ,-8386 ,-2072 ,-9085 ,-14425 ,-9017 ,-2714 ,-5786 ,-3583 ,-1651 , -6263 ,-3033 ,-1762 ,5130 ,4022 ,1179 ,4037 ,498 ,-1459 ,-1479 ,4233 ,8036 ,7096 ,10592 ,13980 , 7391 ,3855 ,5938 ,6310 ,13064 ,13288 ,5931 ,7961 ,11446 ,13092 ,11057 ,6878 ,7105 ,9256 ,14462 , 11581 ,6290 ,6880 ,11782 ,11654 ,5056 ,5503 ,5798 ,5286 ,4816 ,5420 ,5828 ,7460 ,4208 ,649 , 3388 ,739 ,3414 ,1376 ,-6610 ,-5680 ,1255 ,-294 ,-4634 ,-3577 ,-7117 ,-6677 ,-8184 ,-7830 ,-4802 , -3953 ,-2931 ,-8307 ,-12545 ,-10517 ,-8586 ,-9537 ,-11212 ,-11254 ,-6860 ,-8001 ,-11403 ,-9252 ,-9183 ,-7599 , -5529 ,-4134 ,-7706 ,-12449 ,-8067 ,-7019 ,-7477 ,-7046 ,-7801 ,-6297 ,556 ,1191 ,-5215 ,-4483 ,-2507 , 1709 ,2713 ,1477 ,1366 ,2183 ,602 ,1769 ,5306 ,1096 ,2010 ,5011 ,6872 ,8040 ,7905 ,8192 , 7736 ,8078 ,7929 ,8464 ,7975 ,8129 ,8353 ,9022 ,8448 ,7820 ,14504 ,9763 ,1432 ,2628 ,6821 , 12039 ,7267 ,4007 ,6651 ,9339 ,6357 ,3338 ,3946 ,2036 ,3549 ,1527 ,-249 ,1614 ,3344 ,2151 , 319 ,3683 ,1345 ,-3785 ,-3262 ,-3136 ,-5158 ,-7135 ,-5963 ,-1458 ,-1297 ,-4146 ,-6436 ,-8664 ,-9283 , -8141 ,-6363 ,-6558 ,-4857 ,-2805 ,-6730 ,-12621 ,-9334 ,-6303 ,-9128 ,-6932 ,-7877 ,-10102 ,-5794 ,-1860 , -5523 ,-7590 ,-6069 ,-6544 ,-5417 ,-4987 ,-3906 ,-4749 ,-5239 ,-828 ,1543 ,-105 ,-1627 ,-2878 ,-2317 , 259 ,1716 ,4787 ,5944 ,3587 ,1592 ,104 ,1749 ,7548 ,7188 ,2982 ,4483 ,5186 ,5675 ,6964 , 7994 ,8669 ,6596 ,6440 ,9283 ,8497 ,6182 ,5023 ,4024 ,6455 ,9291 ,7939 ,6172 ,4571 ,2775 , 5810 ,5266 ,2852 ,4291 ,4344 ,6705 ,6825 ,2149 ,-1225 ,-837 ,3354 ,4213 ,-777 ,-3661 ,-394 , 674 ,-1503 ,-1963 ,-4786 ,-5131 ,-3821 ,-1490 ,325 ,-4456 ,-6831 ,-6533 ,-6556 ,-5245 ,-5146 ,-4945 , -5352 ,-4927 ,-5067 ,-7838 ,-3887 ,-5015 ,-9243 ,-8586 ,-8380 ,-5683 ,-4445 ,-2111 ,-5141 ,-8248 ,-6412 , -3369 ,-1520 ,-5366 ,-4303 ,-221 ,-765 ,-4060 ,-3906 ,-2551 ,-1387 ,270 ,-990 ,321 ,110 ,-237 , 4165 ,2296 ,1120 ,3154 ,3447 ,4192 ,3423 ,6683 ,6331 ,2749 ,2438 ,6147 ,8595 ,5318 ,3815 , 3152 ,6039 ,6704 ,5779 ,6233 ,5105 ,4172 ,4363 ,5196 ,6550 ,8649 ,5237 ,2991 ,3538 ,5173 , 6172 ,3355 ,1032 ,359 ,2966 ,3859 ,871 ,-974 ,-560 ,867 ,821 ,1536 ,3225 ,155 ,-2828 , -4955 ,-5527 ,-3450 ,-2532 ,-1166 ,-1491 ,-3666 ,-4694 ,-4482 ,-5137 ,-2100 ,-2255 ,-6514 ,-7106 ,-7095 , -6278 ,-4062 ,-1212 ,-4352 ,-6740 ,-5352 ,-5956 ,-5673 ,-5379 ,-4636 ,-4419 ,-5427 ,-2913 ,-814 ,-2348 , -3208 ,-3187 ,-3489 ,-3551 ,-2838 ,-715 ,1611 ,-488 ,-1420 ,-1203 ,619 ,2711 ,1435 ,2333 ,1823 , 1576 ,1545 ,379 ,1995 ,4776 ,4891 ,4408 ,4254 ,4195 ,4923 ,4616 ,3647 ,2384 ,3456 ,4813 , 6120 ,8412 ,5509 ,3011 ,4704 ,3406 ,3138 ,5418 ,5223 ,3600 ,3049 ,2847 ,1830 ,2217 ,3363 , 3352 ,2857 ,1902 ,2346 ,1549 ,1265 ,2852 ,539 ,-1933 ,-1715 ,-1756 ,-2694 ,-2786 ,-1720 ,946 , -511 ,-3961 ,-3497 ,-3047 ,-3071 ,-3022 ,-3389 ,-3029 ,-2110 ,-3991 ,-3989 ,-3535 ,-5402 ,-6338 ,-6294 , -3811 ,-3435 ,-4397 ,-4351 ,-3347 ,-567 ,-2540 ,-6091 ,-5048 ,-2661 ,-2439 ,-3122 ,-2811 ,-3617 ,-2203 , -1402 ,-2765 ,-1697 ,-579 ,165 ,105 ,801 ,296 ,1477 ,3255 ,-848 ,-107 ,1158 ,374 ,1778 , 2250 ,4801 ,4205 ,1709 ,1995 ,4396 ,4690 ,3454 ,3999 ,2645 ,2707 ,4273 ,3928 ,2718 ,3290 , 4124 ,4197 ,4817 ,3984 ,4093 ,3994 ,3629 ,4753 ,3972 ,1087 ,830 ,2314 ,1161 ,2174 ,2050 , 1394 ,1583 ,-472 ,-332 ,586 ,1492 ,241 ,-39 ,1479 ,-1337 ,-3476 ,-3207 ,-1921 ,349 ,-1418 , -3036 ,-2841 ,-3621 ,-3007 ,-2138 ,-3213 ,-3413 ,-1129 ,-2462 ,-4876 ,-5782 ,-5098 ,-3275 ,-3041 ,-1365 , -1136 ,-3668 ,-5239 ,-3761 ,-2933 ,-4275 ,-3594 ,-2238 ,-1588 ,-1815 ,-1827 ,-1284 ,-710 ,-1313 ,-1944 , -1249 ,-962 ,949 ,647 ,-1451 ,-953 ,232 ,1486 ,2986 ,1916 ,-918 ,31 ,1040 ,3404 ,4200 , 2601 ,2976 ,1721 ,1969 ,2054 ,1806 ,2785 ,3757 ,3961 ,5031 ,4549 ,2683 ,3414 ,2467 ,2018 , 2913 ,3176 ,2461 ,1902 ,2526 ,3017 ,4075 ,4185 ,1663 ,517 ,1571 ,674 ,509 ,1584 ,359 , -113 ,582 ,501 ,779 ,-15 ,1152 ,923 ,-2444 ,-1310 ,-913 ,-2870 ,-3190 ,-2637 ,-1665 ,-1663 , -1598 ,-1984 ,-2086 ,-599 ,-2476 ,-4439 ,-2777 ,-2320 ,-3299 ,-3647 ,-3418 ,-3572 ,-3841 ,-2394 ,-1620 , -2032 ,-1526 ,-2414 ,-3037 ,-2371 ,-2368 ,-2009 ,-1756 ,-2293 ,-1799 ,-1236 ,-804 ,-298 ,60 ,409 , -647 ,-1181 ,-324 ,296 ,1477 ,1040 ,-255 ,1149 ,1656 ,2010 ,1235 ,1397 ,2000 ,1841 ,2532 , 1504 ,2956 ,2695 ,2372 ,3027 ,1924 ,2696 ,2764 ,2270 ,2913 ,2848 ,1822 ,1979 ,2646 ,2928 , 2590 ,3364 ,3294 ,1102 ,1048 ,1186 ,1684 ,3106 ,2033 ,634 ,89 ,385 ,308 ,-662 ,-117 , 393 ,1399 ,742 ,-1311 ,-1614 ,-980 ,477 ,-262 ,-2018 ,-2652 ,-1610 ,-280 ,-1726 ,-2831 ,-2734 , -1951 ,-1097 ,-1721 ,-2795 ,-3285 ,-3152 ,-2467 ,-1817 ,-1876 ,-1094 ,-1271 ,-2333 ,-3189 ,-3686 ,-2989 , -1391 ,-50 ,-1351 ,-2230 ,-1746 ,-1491 ,-1985 ,-1955 ,-1106 ,-357 ,-110 ,153 ,1420 ,23 ,-1045 , -114 ,120 ,115 ,284 ,913 ,614 ,1164 ,2050 ,1779 ,974 ,778 ,2416 ,2478 ,1299 ,1791 , 2233 ,1417 ,2268 ,3478 ,2009 ,1924 ,2141 ,1266 ,1881 ,2120 ,3439 ,2784 ,1233 ,2352 ,1800 , 1687 ,1184 ,566 ,937 ,2060 ,2759 ,1174 ,-17 ,-448 ,203 ,531 ,754 ,726 ,961 ,1010 , -796 ,-1719 ,-1530 ,-243 ,-464 ,-1223 ,-698 ,-1605 ,-2111 ,-1677 ,-1428 ,-1280 ,-1254 ,-1468 ,-1585 , -1883 ,-1297 ,-853 ,-2205 ,-2659 ,-2954 ,-3117 ,-2183 ,-1721 ,-857 ,-438 ,-1449 ,-2102 ,-2466 ,-1667 , -1546 ,-1836 ,-619 ,-733 ,-1276 ,-1283 ,-981 ,-614 ,-85 ,324 ,-166 ,544 ,1152 ,-414 ,-910 , -102 ,467 ,971 ,1094 ,1431 ,1352 ,1417 ,1100 ,1655 ,1864 ,1046 ,1993 ,1539 ,1270 ,1201 , 743 ,1545 ,1923 ,2403 ,3385 ,2417 ,1268 ,1785 ,771 ,1301 ,2125 ,1285 ,1815 ,1103 ,978 , 1876 ,950 ,500 ,603 ,1404 ,2004 ,543 ,-624 ,59 ,937 ,-146 ,-837 ,339 ,477 ,-274 , -780 ,-1361 ,-825 ,-474 ,-1148 ,-1452 ,-1637 ,-719 ,-576 ,-1139 ,-1289 ,-1604 ,-1299 ,-1834 ,-2328 , -2058 ,-938 ,-969 ,-1935 ,-1770 ,-1472 ,-736 ,-1308 ,-2048 ,-1481 ,-1575 ,-1495 ,-1279 ,-1598 ,-1331 , -928 ,-20 ,250 ,-883 ,-1158 ,-756 ,-415 ,236 ,732 ,360 ,-164 ,-207 ,-322 ,-286 ,381 , 780 ,1104 ,1237 ,1706 ,1543 ,719 ,854 ,500 ,830 ,1269 ,1613 ,1622 ,1960 ,2864 ,1661 , 901 ,1065 ,1022 ,1066 ,1414 ,1378 ,919 ,1185 ,1488 ,1494 ,1526 ,1303 ,1291 ,977 ,1188 , 1921 ,563 ,146 ,8 ,-499 ,565 ,767 ,24 ,-55 ,-301 ,-506 ,59 ,-226 ,-382 ,-482 , -860 ,-1232 ,-875 ,-336 ,-842 ,-1119 ,-1231 ,-1321 ,-850 ,-211 ,-889 ,-1921 ,-2179 ,-1372 ,-1200 , -947 ,-591 ,-1594 ,-1397 ,-1403 ,-1526 ,-1196 ,-1370 ,-1285 ,-592 ,-634 ,-1058 ,-669 ,-472 ,-943 , -1007 ,-151 ,-370 ,-254 ,-323 ,-273 ,444 ,-107 ,-313 ,-180 ,314 ,546 ,869 ,1240 ,766 , 547 ,439 ,683 ,1326 ,1752 ,946 ,421 ,741 ,701 ,948 ,1277 ,1998 ,2101 ,1138 ,435 , 918 ,1502 ,1437 ,1338 ,1006 ,924 ,945 ,873 ,658 ,531 ,1163 ,1710 ,925 ,505 ,389 , -137 ,435 ,740 ,209 ,17 ,-321 ,-156 ,79 ,-129 ,307 ,-12 ,-664 ,-983 ,-1013 ,-353 , -166 ,-732 ,-1007 ,-820 ,-870 ,-785 ,-1263 ,-1305 ,-687 ,-923 ,-1074 ,-1340 ,-1494 ,-1118 ,-845 , -917 ,-870 ,-543 ,-560 ,-789 ,-1064 ,-1267 ,-1085 ,-821 ,-676 ,-752 ,-662 ,-520 ,-410 ,-88 , -191 ,-212 ,-443 ,-131 ,490 ,-13 ,-181 ,474 ,587 ,244 ,563 ,411 ,344 ,884 ,588 , 373 ,549 ,982 ,1659 ,1285 ,715 ,652 ,711 ,885 ,856 ,1110 ,1299 ,1077 ,1079 ,1097 , 962 ,866 ,928 ,952 ,859 ,885 ,757 ,1193 ,1107 ,384 ,375 ,231 ,0 ,28 ,206 , 188 ,315 ,100 ,145 ,471 ,163 ,-87 ,-491 ,-357 ,-509 ,-857 ,-838 ,-446 ,-6 ,-612 , -457 ,-393 ,-854 ,-973 ,-1021 ,-890 ,-1179 ,-1131 ,-1020 ,-576 ,-94 ,-688 ,-1093 ,-1094 ,-933 , -822 ,-876 ,-1064 ,-860 ,-243 ,-263 ,-649 ,-924 ,-364 ,-214 ,-721 ,-587 ,-418 ,68 ,270 , -81 ,-134 ,207 ,385 ,211 ,-8 ,64 ,421 ,355 ,315 ,460 ,570 ,440 ,417 ,762 , 623 ,841 ,1415 ,1067 ,596 ,617 ,781 ,884 ,826 ,692 ,829 ,976 ,861 ,781 ,700 , 786 ,461 ,703 ,1059 ,559 ,406 ,470 ,1020 ,668 ,247 ,326 ,-136 ,314 ,493 ,59 , -54 ,25 ,49 ,-125 ,-268 ,-550 ,-450 ,73 ,22 ,-639 ,-667 ,-210 ,-459 ,-817 ,-906 , -624 ,-378 ,-663 ,-384 ,-278 ,-993 ,-1039 ,-591 ,-849 ,-1041 ,-864 ,-676 ,-405 ,-202 ,-256 , -844 ,-1017 ,-522 ,-281 ,-478 ,-507 ,-616 ,-646 ,-139 ,80 ,-168 ,-344 ,-93 ,-122 ,-172 , 287 ,565 ,218 ,-174 ,72 ,491 ,580 ,272 ,230 ,307 ,343 ,636 ,690 ,609 ,643 , 680 ,734 ,904 ,736 ,586 ,594 ,697 ,948 ,692 ,535 ,506 ,826 ,1104 ,620 ,400 , 264 ,276 ,509 ,467 ,501 ,366 ,54 ,333 ,598 ,293 ,41 ,-51 ,154 ,366 ,178 , -2 ,-189 ,-371 ,-257 ,-284 ,-457 ,-408 ,-264 ,-426 ,-298 ,98 ,-282 ,-705 ,-812 ,-624 , -662 ,-501 ,-260 ,-649 ,-597 ,-550 ,-689 ,-910 ,-637 ,-226 ,-367 ,-452 ,-614 ,-573 ,-552 , -481 ,-276 ,-356 ,-543 ,-442 ,-251 ,-45 ,377 ,-8 ,-324 ,-96 ,-137 ,-35 ,-17 ,167 , 310 ,203 ,203 ,216 ,133 ,106 ,320 ,466 ,567 ,587 ,595 ,565 ,632 ,1011 ,773 , 169 ,155 ,329 ,493 ,609 ,762 ,749 ,603 ,564 ,476 ,953 ,693 ,164 ,323 ,141 , 371 ,443 ,147 ,177 ,475 ,412 ,99 ,28 ,219 ,440 ,-46 ,-76 ,212 ,-191 ,-223 , -219 ,-389 ,-70 ,-61 ,-373 ,-357 ,-142 ,-346 ,-508 ,-372 ,-414 ,-365 ,-496 ,-537 ,-572 , -648 ,-265 ,-154 ,-559 ,-720 ,-628 ,-382 ,-146 ,-441 ,-481 ,-367 ,-290 ,-59 ,-289 ,-404 , -483 ,-539 ,-454 ,-121 ,207 ,-3 ,6 ,-178 ,-221 ,-11 ,90 ,144 ,5 ,103 ,165 , 517 ,653 ,213 ,8 ,96 ,167 ,443 ,800 ,602 ,243 ,227 ,492 ,613 ,531 ,394 , 299 ,301 ,642 ,729 ,468 ,605 ,511 ,327 ,357 ,393 ,438 ,262 ,333 ,360 ,276 , 378 ,148 ,80 ,135 ,378 ,375 ,-15 ,102 ,170 ,33 ,-91 ,-253 ,-264 ,-46 ,-128 , -344 ,-289 ,-231 ,-178 ,-198 ,-208 ,-254 ,-188 ,47 ,-316 ,-758 ,-629 ,-529 ,-441 ,-343 , -88 ,-167 ,-537 ,-370 ,-401 ,-451 ,-449 ,-538 ,-468 ,-238 ,113 ,-54 ,-294 ,-428 ,-340 , -16 ,-157 ,-234 ,-167 ,31 ,302 ,172 ,9 ,-106 ,-39 ,87 ,50 ,169 ,340 ,192 , 175 ,298 ,154 ,209 ,326 ,344 ,449 ,661 ,588 ,334 ,93 ,234 ,509 ,394 ,482 , 307 ,379 ,498 ,387 ,411 ,330 ,352 ,162 ,182 ,294 ,489 ,573 ,308 ,135 ,57 , 151 ,136 ,-6 ,20 ,258 ,143 ,6 ,44 ,-76 ,-185 ,-231 ,49 ,118 ,-98 ,-201 , -189 ,-299 ,-321 ,-189 ,-278 ,-202 ,-228 ,-282 ,-345 ,-479 ,-348 ,-312 ,-233 ,-243 ,-233 , 34 ,-89 ,-380 ,-473 ,-488 ,-427 ,-262 ,-181 ,-191 ,-172 ,-174 ,-151 ,-122 ,-125 ,-192 , -62 ,-13 ,-26 ,57 ,-77 ,-58 ,106 ,278 ,186 ,13 ,94 ,103 ,256 ,326 ,225 , 167 ,219 ,212 ,166 ,424 ,447 ,265 ,190 ,360 ,493 ,308 ,191 ,215 ,497 ,577 , 296 ,138 ,116 ,252 ,288 ,325 ,306 ,304 ,520 ,357 ,140 ,57 ,2 ,27 ,-57 , -44 ,220 ,220 ,-32 ,55 ,15 ,-102 ,1 ,103 ,-64 ,-300 ,-157 ,-167 ,-196 ,-63 , -76 ,-260 ,-278 ,-204 ,-294 ,-183 ,-185 ,-251 ,-273 ,-377 ,-298 ,-148 ,-284 ,-215 ,-40 , -233 ,-228 ,-243 ,-245 ,-226 ,-313 ,-272 ,-62 ,102 ,-75 ,-120 ,-160 ,-189 ,-9 ,-32 , -16 ,62 ,-49 ,-22 ,190 ,103 ,44 ,207 ,177 ,134 ,138 ,144 ,153 ,245 ,264 , 96 ,239 ,393 ,310 ,234 ,182 ,314 ,345 ,190 ,183 ,256 ,326 ,322 ,298 ,452 , 459 ,234 ,105 ,143 ,163 ,118 ,151 ,207 ,160 ,142 ,116 ,18 ,140 ,132 ,95 , 75 ,-68 ,23 ,71 ,-108 ,-126 ,70 ,18 ,-118 ,-182 ,-115 ,-103 ,-246 ,-240 ,-201 , -166 ,-131 ,33 ,-21 ,-306 ,-294 ,-173 ,-190 ,-279 ,-253 ,-273 ,-292 ,-203 ,-202 ,-161 , -169 ,4 ,94 ,-144 ,-166 ,-243 ,-226 ,-80 ,-73 ,-63 ,-135 ,-43 ,7 ,-18 ,68 , 60 ,130 ,149 ,50 ,6 ,86 ,128 ,120 ,129 ,115 ,235 ,239 ,141 ,164 ,226 , 306 ,274 ,165 ,203 ,252 ,168 ,181 ,351 ,380 ,301 ,161 ,109 ,232 ,175 ,145 , 186 ,263 ,376 ,246 ,132 ,127 ,35 ,58 ,56 ,57 ,200 ,123 ,39 ,12 ,7 , 3 ,-49 ,-69 ,-92 ,-14 ,17 ,31 ,-19 ,-158 ,-169 ,-98 ,-95 ,-132 ,-179 ,-197 , -132 ,-124 ,-187 ,-238 ,-181 ,-103 ,-40 ,-120 ,-210 ,-155 ,-175 ,-201 ,-186 ,-176 ,-169 , -23 ,45 ,-53 ,-89 ,-127 ,-138 ,-61 ,-43 ,-21 ,-59 ,-55 ,20 ,8 ,133 ,70 , 33 ,87 ,69 ,127 ,87 ,32 ,44 ,235 ,229 ,98 ,127 ,154 ,200 ,215 ,219 , 227 ,207 ,298 ,296 ,157 ,167 ,154 ,142 ,148 ,230 ,302 ,194 ,76 ,56 ,168 , 165 ,129 ,112 ,53 ,139 ,155 ,104 ,61 ,-3 ,-21 ,12 ,42 ,52 ,53 ,27 , 177 ,135 ,-162 ,-204 ,-56 ,-28 ,-152 ,-162 ,-103 ,-114 ,-138 ,-107 ,-99 ,-74 ,-95 , -77 ,86 ,-28 ,-198 ,-221 ,-229 ,-214 ,-236 ,-110 ,31 ,-2 ,-111 ,-125 ,-148 ,-151 , 8 ,54 ,-46 ,-101 ,-23 ,-24 ,-41 ,26 ,49 ,7 ,8 ,100 ,68 ,53 ,71 , 61 ,41 ,58 ,194 ,189 ,79 ,79 ,202 ,209 ,123 ,144 ,125 ,173 ,208 ,163 , 164 ,153 ,147 ,138 ,99 ,113 ,169 ,173 ,291 ,334 ,181 ,42 ,31 ,83 ,76 , 95 ,71 ,89 ,105 ,47 ,-19 ,46 ,151 ,79 ,-31 ,-75 ,-11 ,-7 ,50 ,7 , -109 ,-95 ,-75 ,63 ,46 ,-70 ,-119 ,-180 ,-156 ,-57 ,-90 ,-166 ,-145 ,-72 ,45 , -36 ,-149 ,-139 ,-110 ,-150 ,-128 ,-37 ,-99 ,-71 ,-47 ,-61 ,-67 ,-78 ,-55 ,-46 , -29 ,-5 ,-30 ,-76 ,-36 ,-4 ,127 ,148 ,0 ,-33 ,109 ,159 ,13 ,-24 ,35 , 75 ,155 ,265 ,154 ,70 ,115 ,93 ,65 ,117 ,156 ,162 ,164 ,91 ,141 ,189 , 154 ,134 ,120 ,124 ,140 ,152 ,88 ,65 ,152 ,216 ,132 ,61 ,94 ,104 ,41 , -2 ,40 ,48 ,131 ,160 ,47 ,4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,64 , 109 ,53 ,77 ,145 ,127 ,62 ,37 ,116 ,125 ,71 ,68 ,104 ,85 ,79 ,86 , 77 ,71 ,74 ,80 ,35 ,78 ,105 ,56 ,52 ,32 ,12 ,34 ,61 ,41 ,-6 , -16 ,47 ,69 ,22 ,11 ,-16 ,-57 ,-54 ,-41 ,-9 ,-13 ,20 ,101 ,27 ,-81 , -87 ,-52 ,-69 ,-91 ,-72 ,-43 ,-12 ,-30 ,25 ,53 ,-58 ,-95 ,-62 ,-26 ,26 , 0 ,-68 ,-82 ,-2 ,55 ,1 ,-12 ,-25 ,-61 ,5 ,73 ,63 ,11 ,9 ,26 , 26 ,21 ,10 ,79 ,76 ,49 ,85 ,75 ,27 ,34 ,117 ,116 ,52 ,30 ,13 , -3 ,1 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , 0 ,0 ,0 ,0 ,282 ,-1133 ,-4903 ,-7187 ,-9285 ,-11203 ,-12816 ,-14273 ,-15338 ,-16233 ,-16704 , -16973 ,-16847 ,-16480 ,-15787 ,-14830 ,-13638 ,-12169 ,-10583 ,-8688 ,-6829 ,-4656 ,-2760 ,240 ,5825 ,10661 , 14721 ,18671 ,22054 ,25162 ,27693 ,29800 ,31318 ,32324 ,32760 ,32650 ,31999 ,30824 ,29162 ,27049 ,24534 , 21661 ,18501 ,15102 ,11544 ,7876 ,4186 ,518 ,-3035 ,-6448 ,-9624 ,-12547 ,-15139 ,-17371 ,-19236 ,-20663 , -21681 ,-22243 ,-22377 ,-22081 ,-21370 ,-20271 ,-18804 ,-17032 ,-14964 ,-12677 ,-10203 ,-7602 ,-4928 ,-2227 ,413 , 2988 ,5415 ,7658 ,9673 ,11414 ,12868 ,13990 ,14777 ,15199 ,15269 ,14977 ,14333 ,13364 ,12075 ,10517 , 8692 ,6667 ,4473 ,2140 ,-254 ,-2701 ,-5122 ,-7484 ,-9739 ,-11842 ,-13754 ,-15436 ,-16863 ,-17991 ,-18822 , -19321 ,-19489 ,-19323 ,-18814 ,-17991 ,-16848 ,-15422 ,-13722 ,-11788 ,-9658 ,-7359 ,-4939 ,-2430 ,102 ,2645 , 5133 ,7536 ,9814 ,11922 ,13837 ,15517 ,16948 ,18093 ,18957 ,19517 ,19766 ,19717 ,19359 ,18719 ,17796 , 16623 ,15221 ,13615 ,11836 ,9917 ,7903 ,5808 ,3697 ,1582 ,-483 ,-2463 ,-4358 ,-6100 ,-7687 ,-9079 , -10267 ,-11237 ,-11968 ,-12469 ,-12724 ,-12747 ,-12534 ,-12110 ,-11486 ,-10668 ,-9694 ,-8576 ,-7354 ,-6041 ,-4672 , -3278 ,-1881 ,-524 ,777 ,1994 ,3104 ,4086 ,4926 ,5603 ,6107 ,6435 ,6573 ,6535 ,6312 ,5919 , 5367 ,4663 ,3830 ,2881 ,1842 ,730 ,-420 ,-1595 ,-2767 ,-3903 ,-4999 ,-6010 ,-6922 ,-7721 ,-8390 , -8905 ,-9259 ,-9450 ,-9466 ,-9308 ,-8969 ,-8468 ,-7802 ,-6985 ,-6029 ,-4951 ,-3779 ,-2508 ,-1182 ,184 , 1567 ,2946 ,4298 ,5595 ,6824 ,7945 ,8971 ,9865 ,10616 ,11218 ,11652 ,11925 ,12020 ,11950 ,11707 , 11300 ,10744 ,10042 ,9210 ,8259 ,7216 ,6086 ,4896 ,3671 ,2412 ,1161 ,-72 ,-1266 ,-2409 ,-3480 , -4457 ,-5340 ,-6107 ,-6754 ,-7272 ,-7657 ,-7909 ,-8026 ,-8017 ,-7877 ,-7622 ,-7257 ,-6794 ,-6247 ,-5624 , -4947 ,-4229 ,-3484 ,-2729 ,-1983 ,-1250 ,-553 ,93 ,683 ,1206 ,1649 ,2010 ,2282 ,2458 ,2546 , 2538 ,2446 ,2265 ,2005 ,1683 ,1293 ,854 ,377 ,-120 ,-637 ,-1158 ,-1664 ,-2148 ,-2596 ,-2995 , -3338 ,-3617 ,-3822 ,-3951 ,-3990 ,-3946 ,-3813 ,-3593 ,-3290 ,-2904 ,-2443 ,-1916 ,-1326 ,-683 ,-6 , 703 ,1424 ,2155 ,2876 ,3580 ,4249 ,4870 ,5451 ,5955 ,6391 ,6750 ,7015 ,7195 ,7282 ,7272 , 7163 ,6963 ,6671 ,6295 ,5838 ,5305 ,4715 ,4064 ,3368 ,2634 ,1884 ,1117 ,348 ,-399 ,-1141 , -1842 ,-2506 ,-3119 ,-3673 ,-4164 ,-4584 ,-4935 ,-5202 ,-5401 ,-5517 ,-5556 ,-5519 ,-5414 ,-5242 ,-5004 , -4716 ,-4382 ,-4010 ,-3606 ,-3179 ,-2738 ,-2294 ,-1848 ,-1418 ,-1007 ,-615 ,-262 ,54 ,334 ,572 , 761 ,905 ,1002 ,1048 ,1054 ,1016 ,937 ,828 ,691 ,525 ,347 ,157 ,-36 ,-226 ,-415 , -589 ,-743 ,-871 ,-967 ,-1033 ,-1064 ,-1053 ,-1001 ,-908 ,-775 ,-601 ,-388 ,-145 ,127 ,431 , 760 ,1100 ,1452 ,1810 ,2168 ,2520 ,2849 ,3166 ,3453 ,3705 ,3925 ,4098 ,4232 ,4315 ,4345 , 4326 ,4255 ,4128 ,3949 ,3722 ,3447 ,3131 ,2771 ,2383 ,1965 ,1518 ,1058 ,583 ,107 ,-367 , -834 ,-1289 ,-1725 ,-2131 ,-2512 ,-2857 ,-3162 ,-3424 ,-3644 ,-3814 ,-3942 ,-4020 ,-4048 ,-4037 ,-3977 , -3876 ,-3736 ,-3565 ,-3357 ,-3121 ,-2867 ,-2595 ,-2313 ,-2015 ,-1722 ,-1430 ,-1140 ,-862 ,-595 ,-349 , -121 ,81 ,262 ,419 ,551 ,658 ,739 ,797 ,833 ,848 ,839 ,821 ,789 ,746 ,695 , 642 ,588 ,534 ,489 ,450 ,424 ,405 ,406 ,423 ,454 ,498 ,564 ,649 ,746 ,856 , 977 ,1112 ,1252 ,1401 ,1547 ,1698 ,1843 ,1981 ,2109 ,2223 ,2324 ,2401 ,2463 ,2498 ,2511 , 2494 ,2447 ,2379 ,2277 ,2149 ,1997 ,1819 ,1613 ,1388 ,1142 ,876 ,604 ,314 ,22 ,-269 , -566 ,-860 ,-1148 ,-1419 ,-1682 ,-1923 ,-2148 ,-2349 ,-2524 ,-2677 ,-2795 ,-2889 ,-2949 ,-2984 ,-2987 , -2960 ,-2906 ,-2825 ,-2722 ,-2591 ,-2444 ,-2275 ,-2094 ,-1902 ,-1698 ,-1488 ,-1268 ,-1052 ,-837 ,-626 , -423 ,-225 ,-41 ,129 ,291 ,435 ,563 ,684 ,782 ,868 ,938 ,997 ,1040 ,1072 ,1093 , 1104 ,1112 ,1107 ,1104 ,1093 ,1079 ,1067 ,1057 ,1052 ,1043 ,1047 ,1048 ,1056 ,1069 ,1084 , 1111 ,1134 ,1168 ,1199 ,1235 ,1273 ,1303 ,1336 ,1366 ,1390 ,1407 ,1416 ,1414 ,1407 ,1384 , 1349 ,1304 ,1241 ,1169 ,1081 ,978 ,863 ,735 ,595 ,443 ,286 ,117 ,-55 ,-231 ,-412 , -596 ,-774 ,-954 ,-1126 ,-1289 ,-1448 ,-1591 ,-1725 ,-1844 ,-1946 ,-2034 ,-2100 ,-2150 ,-2182 ,-2192 , -2183 ,-2159 ,-2113 ,-2051 ,-1973 ,-1877 ,-1769 ,-1645 ,-1514 ,-1371 ,-1218 ,-1060 ,-898 ,-730 ,-565 , -401 ,-236 ,-79 ,73 ,219 ,360 ,490 ,612 ,723 ,825 ,916 ,992 ,1064 ,1120 ,1172 , 1210 ,1240 ,1261 ,1270 ,1276 ,1274 ,1271 ,1257 ,1245 ,1226 ,1203 ,1185 ,1161 ,1135 ,1114 , 1091 ,1067 ,1047 ,1024 ,1000 ,976 ,956 ,931 ,901 ,877 ,845 ,811 ,778 ,736 ,689 , 645 ,590 ,528 ,463 ,395 ,320 ,237 ,151 ,61 ,-29 ,-126 ,-229 ,-333 ,-435 ,-540 , -646 ,-747 ,-850 ,-948 ,-1043 ,-1130 ,-1207 ,-1282 ,-1345 ,-1400 ,-1446 ,-1477 ,-1503 ,-1515 ,-1514 , -1505 ,-1482 ,-1449 ,-1401 ,-1347 ,-1282 ,-1204 ,-1123 ,-1027 ,-926 ,-822 ,-711 ,-594 ,-477 ,-360 , -238 ,-117 ,-4 ,109 ,223 ,330 ,431 ,529 ,620 ,702 ,780 ,849 ,913 ,966 ,1011 , 1050 ,1079 ,1101 ,1117 ,1128 ,1131 ,1124 ,1113 ,1101 ,1083 ,1059 ,1031 ,1001 ,969 ,936 , 898 ,858 ,820 ,778 ,737 ,694 ,651 ,606 ,560 ,517 ,467 ,422 ,375 ,323 ,276 , 227 ,175 ,122 ,68 ,16 ,-35 ,-93 ,-150 ,-209 ,-267 ,-329 ,-389 ,-447 ,-507 ,-565 , -620 ,-673 ,-724 ,-775 ,-821 ,-862 ,-902 ,-932 ,-959 ,-982 ,-999 ,-1009 ,-1012 ,-1011 ,-997 , -979 ,-955 ,-926 ,-889 ,-844 ,-795 ,-738 ,-679 ,-615 ,-543 ,-470 ,-395 ,-316 ,-233 ,-150 , -69 ,8 ,90 ,172 ,248 ,326 ,398 ,470 ,536 ,596 ,654 ,702 ,747 ,788 ,819 , 848 ,871 ,889 ,898 ,903 ,905 ,898 ,889 ,874 ,854 ,832 ,805 ,775 ,743 ,708 , 671 ,631 ,590 ,545 ,501 ,459 ,412 ,368 ,322 ,274 ,230 ,183 ,139 ,95 ,49 , 7 ,-34 ,-76 ,-118 ,-158 ,-200 ,-239 ,-276 ,-317 ,-354 ,-391 ,-424 ,-455 ,-488 ,-515 , -543 ,-568 ,-590 ,-613 ,-630 ,-645 ,-657 ,-665 ,-672 ,-672 ,-671 ,-668 ,-657 ,-645 ,-627 , -609 ,-586 ,-555 ,-525 ,-490 ,-451 ,-409 ,-364 ,-315 ,-267 ,-216 ,-163 ,-109 ,-52 ,-1 , 52 ,109 ,162 ,217 ,269 ,322 ,370 ,414 ,459 ,496 ,534 ,568 ,595 ,622 ,642 , 659 ,672 ,681 ,686 ,686 ,683 ,678 ,664 ,649 ,635 ,611 ,589 ,562 ,530 ,499 , 466 ,431 ,395 ,357 ,318 ,279 ,239 ,199 ,162 ,120 ,79 ,41 ,4 ,-30 ,-66 , -101 ,-136 ,-170 ,-201 ,-232 ,-259 ,-288 ,-314 ,-337 ,-359 ,-380 ,-397 ,-414 ,-432 ,-441 , -452 ,-462 ,-469 ,-476 ,-478 ,-479 ,-476 ,-473 ,-469 ,-459 ,-448 ,-436 ,-421 ,-405 ,-382 , -363 ,-338 ,-311 ,-286 ,-256 ,-225 ,-192 ,-158 ,-124 ,-88 ,-51 ,-16 ,17 ,54 ,92 , 128 ,164 ,199 ,234 ,268 ,299 ,329 ,357 ,384 ,408 ,429 ,447 ,465 ,477 ,488 , 497 ,503 ,504 ,504 ,502 ,495 ,487 ,475 ,462 ,445 ,426 ,406 ,383 ,359 ,332 , 306 ,279 ,248 ,218 ,187 ,156 ,124 ,92 ,62 ,30 ,1 ,-26 ,-55 ,-83 ,-110 , -137 ,-163 ,-185 ,-209 ,-230 ,-251 ,-268 ,-283 ,-297 ,-310 ,-322 ,-329 ,-337 ,-342 ,-346 , -350 ,-350 ,-349 ,-347 ,-342 ,-336 ,-328 ,-319 ,-311 ,-297 ,-283 ,-269 ,-252 ,-236 ,-219 , -198 ,-178 ,-158 ,-136 ,-114 ,-89 ,-66 ,-42 ,-18 ,3 ,27 ,51 ,75 ,98 ,120 , 145 ,165 ,185 ,205 ,223 ,241 ,256 ,272 ,286 ,297 ,307 ,315 ,323 ,327 ,329 , 332 ,332 ,328 ,325 ,319 ,311 ,302 ,292 ,280 ,267 ,252 ,236 ,219 ,202 ,184 , 164 ,143 ,124 ,104 ,82 ,61 ,40 ,20 ,0 ,-15 ,-35 ,-56 ,-73 ,-91 ,-106 , -123 ,-138 ,-150 ,-163 ,-175 ,-184 ,-194 ,-202 ,-207 ,-212 ,-216 ,-218 ,-220 ,-220 ,-221 , -219 ,-214 ,-212 ,-206 ,-200 ,-195 ,-186 ,-176 ,-168 ,-157 ,-146 ,-135 ,-124 ,-109 ,-96 , -83 ,-68 ,-53 ,-40 ,-26 ,-10 ,2 ,16 ,30 ,43 ,58 ,70 ,82 ,96 ,107 , 120 ,131 ,141 ,150 ,159 ,168 ,174 ,178 ,185 ,189 ,192 ,195 ,196 ,197 ,195 , 192 ,191 ,186 ,181 ,177 ,169 ,162 ,155 ,146 ,137 ,127 ,115 ,105 ,94 ,81 , 70 ,59 ,47 ,35 ,22 ,9 ,0 ,-11 ,-22 ,-34 ,-42 ,-53 ,-63 ,-72 ,-81 , -88 ,-95 ,-101 ,-107 ,-113 ,-116 ,-120 ,-122 ,-124 ,-125 ,-126 ,-127 ,-125 ,-122 ,-120 , -118 ,-115 ,-110 ,-104 ,-98 ,-91 ,-85 ,-77 ,-70 ,-63 ,-55 ,-47 ,-40 ,-33 ,-25 , -18 ,-10 ,-4 ,0 ,6 ,13 ,18 ,24 ,30 ,34 ,39 ,42 ,46 ,49 ,51 , 54 ,55 ,57 ,57 ,58 ,58 ,57 ,57 ,56 ,55 ,53 ,51 ,48 ,46 ,43 , 41 ,38 ,34 ,31 ,29 ,26 ,23 ,20 ,17 ,14 ,12 ,10 ,7 ,6 ,3 , 2 ,1 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,-12 ,-251 ,-9595 ,-14720 ,-14612 , -16474 ,-16717 ,-17875 ,-18139 ,-18685 ,-18842 ,-18833 ,-18792 ,-18286 ,-17999 ,-17055 ,-16496 ,-15220 ,-14329 ,-12790 , -11572 ,-9959 ,-8226 ,-6919 ,3277 ,12091 ,14960 ,18423 ,20680 ,23324 ,25298 ,27300 ,28912 ,30256 ,31391 , 32095 ,32650 ,32741 ,32686 ,32197 ,31544 ,30530 ,29320 ,27849 ,26190 ,24337 ,22323 ,20187 ,17939 ,15624 , 13259 ,10883 ,8507 ,6186 ,3891 ,1700 ,-394 ,-2377 ,-4236 ,-5949 ,-7508 ,-8912 ,-10161 ,-11255 ,-12193 , -12979 ,-13627 ,-14144 ,-14535 ,-14823 ,-15020 ,-15129 ,-15163 ,-15155 ,-15103 ,-15018 ,-14924 ,-14826 ,-14725 ,-14640 , -14573 ,-14530 ,-14509 ,-14510 ,-14532 ,-14569 ,-14629 ,-14689 ,-14749 ,-14791 ,-14815 ,-14810 ,-14755 ,-14648 ,-14465 , -14213 ,-13870 ,-13417 ,-12870 ,-12206 ,-11422 ,-10519 ,-9496 ,-8356 ,-7085 ,-5717 ,-4232 ,-2656 ,-997 ,739 , 2527 ,4365 ,6206 ,8075 ,9919 ,11726 ,13489 ,15169 ,16761 ,18247 ,19603 ,20818 ,21887 ,22775 ,23496 , 24023 ,24358 ,24505 ,24445 ,24198 ,23751 ,23121 ,22301 ,21320 ,20182 ,18886 ,17471 ,15928 ,14304 ,12584 , 10804 ,8987 ,7132 ,5279 ,3422 ,1600 ,-180 ,-1905 ,-3568 ,-5140 ,-6624 ,-8009 ,-9278 ,-10444 ,-11485 , -12411 ,-13216 ,-13906 ,-14478 ,-14947 ,-15299 ,-15556 ,-15725 ,-15795 ,-15801 ,-15721 ,-15588 ,-15401 ,-15161 ,-14879 , -14557 ,-14220 ,-13849 ,-13466 ,-13063 ,-12649 ,-12226 ,-11785 ,-11337 ,-10872 ,-10398 ,-9908 ,-9402 ,-8867 ,-8312 , -7725 ,-7110 ,-6457 ,-5760 ,-5033 ,-4256 ,-3437 ,-2570 ,-1672 ,-720 ,268 ,1286 ,2355 ,3437 ,4548 , 5666 ,6795 ,7921 ,9036 ,10132 ,11191 ,12217 ,13176 ,14087 ,14916 ,15675 ,16340 ,16901 ,17368 ,17705 , 17943 ,18044 ,18023 ,17882 ,17607 ,17212 ,16677 ,16033 ,15276 ,14407 ,13433 ,12372 ,11212 ,9981 ,8689 , 7342 ,5964 ,4543 ,3116 ,1675 ,257 ,-1152 ,-2535 ,-3874 ,-5167 ,-6381 ,-7549 ,-8635 ,-9638 ,-10549 , -11379 ,-12113 ,-12743 ,-13283 ,-13728 ,-14078 ,-14331 ,-14503 ,-14576 ,-14567 ,-14491 ,-14333 ,-14109 ,-13819 ,-13468 , -13067 ,-12621 ,-12128 ,-11598 ,-11044 ,-10453 ,-9849 ,-9212 ,-8560 ,-7903 ,-7221 ,-6539 ,-5842 ,-5139 ,-4428 , -3715 ,-2996 ,-2268 ,-1531 ,-801 ,-60 ,677 ,1418 ,2172 ,2914 ,3674 ,4419 ,5160 ,5898 ,6624 , 7333 ,8025 ,8707 ,9349 ,9966 ,10549 ,11096 ,11593 ,12045 ,12436 ,12768 ,13042 ,13244 ,13380 ,13439 , 13425 ,13322 ,13141 ,12884 ,12542 ,12117 ,11614 ,11034 ,10378 ,9658 ,8868 ,8021 ,7117 ,6158 ,5167 , 4129 ,3074 ,1994 ,907 ,-177 ,-1261 ,-2332 ,-3389 ,-4406 ,-5396 ,-6330 ,-7220 ,-8059 ,-8836 ,-9544 , -10179 ,-10758 ,-11239 ,-11658 ,-12001 ,-12255 ,-12438 ,-12539 ,-12569 ,-12522 ,-12403 ,-12213 ,-11969 ,-11659 ,-11293 , -10872 ,-10394 ,-9887 ,-9335 ,-8743 ,-8126 ,-7483 ,-6814 ,-6131 ,-5432 ,-4724 ,-4013 ,-3292 ,-2570 ,-1850 , -1137 ,-430 ,259 ,944 ,1621 ,2278 ,2927 ,3559 ,4170 ,4765 ,5336 ,5879 ,6415 ,6915 ,7387 , 7843 ,8255 ,8646 ,8996 ,9317 ,9597 ,9829 ,10038 ,10194 ,10308 ,10372 ,10390 ,10363 ,10276 ,10144 , 9958 ,9721 ,9429 ,9090 ,8687 ,8239 ,7756 ,7212 ,6628 ,5998 ,5337 ,4638 ,3902 ,3143 ,2366 , 1565 ,749 ,-62 ,-882 ,-1696 ,-2504 ,-3300 ,-4074 ,-4815 ,-5536 ,-6220 ,-6859 ,-7460 ,-8002 ,-8509 , -8949 ,-9332 ,-9665 ,-9932 ,-10143 ,-10288 ,-10367 ,-10387 ,-10345 ,-10244 ,-10082 ,-9864 ,-9602 ,-9278 ,-8906 , -8501 ,-8036 ,-7548 ,-7024 ,-6460 ,-5882 ,-5272 ,-4643 ,-4009 ,-3363 ,-2700 ,-2040 ,-1377 ,-722 ,-69 , 562 ,1188 ,1807 ,2396 ,2974 ,3527 ,4064 ,4572 ,5050 ,5507 ,5935 ,6328 ,6692 ,7025 ,7330 , 7594 ,7826 ,8021 ,8181 ,8318 ,8404 ,8454 ,8476 ,8456 ,8395 ,8304 ,8169 ,7995 ,7787 ,7546 , 7266 ,6942 ,6601 ,6218 ,5800 ,5358 ,4885 ,4383 ,3861 ,3308 ,2738 ,2159 ,1556 ,950 ,335 , -284 ,-905 ,-1525 ,-2136 ,-2739 ,-3326 ,-3899 ,-4457 ,-4978 ,-5476 ,-5942 ,-6378 ,-6782 ,-7133 ,-7457 , -7732 ,-7958 ,-8147 ,-8283 ,-8365 ,-8399 ,-8391 ,-8334 ,-8230 ,-8080 ,-7889 ,-7643 ,-7361 ,-7036 ,-6677 , -6284 ,-5855 ,-5407 ,-4920 ,-4416 ,-3895 ,-3353 ,-2804 ,-2242 ,-1673 ,-1106 ,-531 ,35 ,584 ,1137 , 1674 ,2193 ,2703 ,3186 ,3652 ,4093 ,4506 ,4895 ,5260 ,5595 ,5890 ,6158 ,6390 ,6596 ,6772 , 6903 ,7013 ,7085 ,7125 ,7126 ,7094 ,7042 ,6942 ,6819 ,6660 ,6474 ,6261 ,6020 ,5754 ,5454 , 5135 ,4794 ,4433 ,4040 ,3637 ,3219 ,2780 ,2324 ,1863 ,1392 ,911 ,431 ,-55 ,-537 ,-1022 , -1499 ,-1979 ,-2439 ,-2889 ,-3329 ,-3749 ,-4155 ,-4529 ,-4896 ,-5226 ,-5521 ,-5801 ,-6035 ,-6245 ,-6423 , -6556 ,-6669 ,-6739 ,-6771 ,-6764 ,-6718 ,-6636 ,-6516 ,-6373 ,-6177 ,-5955 ,-5708 ,-5414 ,-5106 ,-4767 , -4401 ,-4015 ,-3600 ,-3178 ,-2734 ,-2285 ,-1828 ,-1354 ,-882 ,-400 ,68 ,540 ,1000 ,1456 ,1901 , 2326 ,2743 ,3132 ,3515 ,3871 ,4197 ,4510 ,4791 ,5044 ,5272 ,5460 ,5632 ,5773 ,5878 ,5956 , 5997 ,6023 ,6006 ,5963 ,5899 ,5797 ,5665 ,5515 ,5337 ,5131 ,4910 ,4663 ,4395 ,4108 ,3801 , 3475 ,3138 ,2788 ,2419 ,2048 ,1672 ,1279 ,889 ,491 ,94 ,-297 ,-695 ,-1082 ,-1467 ,-1839 , -2206 ,-2559 ,-2899 ,-3224 ,-3530 ,-3822 ,-4097 ,-4347 ,-4572 ,-4780 ,-4956 ,-5111 ,-5234 ,-5336 ,-5412 , -5446 ,-5467 ,-5449 ,-5402 ,-5337 ,-5231 ,-5105 ,-4950 ,-4766 ,-4565 ,-4330 ,-4079 ,-3806 ,-3508 ,-3202 , -2865 ,-2523 ,-2167 ,-1800 ,-1425 ,-1037 ,-658 ,-261 ,117 ,498 ,879 ,1251 ,1624 ,1971 ,2318 , 2647 ,2957 ,3254 ,3527 ,3784 ,4015 ,4224 ,4413 ,4573 ,4718 ,4826 ,4914 ,4976 ,5003 ,5014 , 4994 ,4960 ,4887 ,4793 ,4686 ,4546 ,4382 ,4205 ,4003 ,3788 ,3556 ,3296 ,3037 ,2753 ,2458 , 2157 ,1847 ,1534 ,1207 ,885 ,552 ,218 ,-104 ,-430 ,-753 ,-1071 ,-1383 ,-1687 ,-1983 ,-2265 , -2531 ,-2789 ,-3035 ,-3264 ,-3467 ,-3655 ,-3827 ,-3976 ,-4112 ,-4223 ,-4311 ,-4372 ,-4417 ,-4439 ,-4434 , -4412 ,-4365 ,-4299 ,-4199 ,-4086 ,-3954 ,-3796 ,-3622 ,-3425 ,-3215 ,-2987 ,-2748 ,-2491 ,-2219 ,-1939 , -1646 ,-1351 ,-1043 ,-734 ,-420 ,-110 ,198 ,511 ,815 ,1123 ,1417 ,1703 ,1982 ,2248 ,2506 , 2743 ,2966 ,3167 ,3354 ,3530 ,3677 ,3810 ,3922 ,4008 ,4080 ,4125 ,4153 ,4155 ,4134 ,4095 , 4030 ,3952 ,3854 ,3737 ,3593 ,3439 ,3264 ,3078 ,2875 ,2651 ,2436 ,2197 ,1950 ,1694 ,1425 , 1162 ,891 ,614 ,339 ,66 ,-205 ,-474 ,-743 ,-1003 ,-1263 ,-1507 ,-1748 ,-1978 ,-2192 ,-2399 , -2589 ,-2769 ,-2929 ,-3080 ,-3208 ,-3316 ,-3416 ,-3498 ,-3559 ,-3598 ,-3628 ,-3636 ,-3617 ,-3583 ,-3540 , -3467 ,-3380 ,-3282 ,-3160 ,-3029 ,-2874 ,-2710 ,-2534 ,-2342 ,-2142 ,-1926 ,-1704 ,-1472 ,-1232 ,-986 , -739 ,-487 ,-226 ,26 ,273 ,529 ,778 ,1017 ,1264 ,1494 ,1707 ,1929 ,2134 ,2323 ,2509 , 2670 ,2821 ,2956 ,3073 ,3179 ,3261 ,3332 ,3383 ,3414 ,3436 ,3432 ,3408 ,3375 ,3318 ,3247 , 3160 ,3056 ,2938 ,2807 ,2656 ,2494 ,2324 ,2143 ,1953 ,1747 ,1542 ,1325 ,1109 ,882 ,654 , 423 ,187 ,-24 ,-258 ,-484 ,-703 ,-926 ,-1125 ,-1332 ,-1531 ,-1713 ,-1886 ,-2047 ,-2209 ,-2346 , -2473 ,-2589 ,-2687 ,-2777 ,-2849 ,-2906 ,-2946 ,-2974 ,-2991 ,-2990 ,-2962 ,-2925 ,-2880 ,-2819 ,-2741 , -2645 ,-2544 ,-2423 ,-2293 ,-2155 ,-2000 ,-1840 ,-1674 ,-1493 ,-1313 ,-1114 ,-923 ,-720 ,-507 ,-308 , -91 ,98 ,313 ,520 ,708 ,914 ,1107 ,1295 ,1469 ,1644 ,1801 ,1963 ,2101 ,2227 ,2355 , 2453 ,2551 ,2627 ,2695 ,2750 ,2789 ,2808 ,2823 ,2819 ,2792 ,2763 ,2712 ,2657 ,2581 ,2493 , 2385 ,2280 ,2158 ,2023 ,1888 ,1725 ,1570 ,1397 ,1226 ,1046 ,857 ,674 ,488 ,299 ,105 , -78 ,-262 ,-449 ,-633 ,-808 ,-982 ,-1150 ,-1308 ,-1458 ,-1597 ,-1731 ,-1855 ,-1968 ,-2069 ,-2163 , -2237 ,-2304 ,-2368 ,-2399 ,-2434 ,-2450 ,-2452 ,-2447 ,-2415 ,-2392 ,-2342 ,-2281 ,-2216 ,-2131 ,-2033 , -1943 ,-1829 ,-1701 ,-1580 ,-1441 ,-1296 ,-1145 ,-996 ,-829 ,-671 ,-505 ,-337 ,-166 ,3 ,158 , 335 ,496 ,658 ,821 ,978 ,1123 ,1264 ,1406 ,1528 ,1649 ,1766 ,1866 ,1955 ,2038 ,2107 , 2172 ,2214 ,2257 ,2289 ,2295 ,2300 ,2290 ,2278 ,2239 ,2197 ,2149 ,2075 ,2006 ,1925 ,1824 , 1721 ,1613 ,1496 ,1369 ,1234 ,1096 ,957 ,807 ,653 ,507 ,350 ,188 ,40 ,-115 ,-272 , -419 ,-567 ,-713 ,-858 ,-989 ,-1116 ,-1243 ,-1354 ,-1464 ,-1563 ,-1650 ,-1735 ,-1806 ,-1869 ,-1922 , -1966 ,-1990 ,-2007 ,-2020 ,-2016 ,-2007 ,-1986 ,-1956 ,-1912 ,-1862 ,-1797 ,-1724 ,-1645 ,-1558 ,-1465 , -1361 ,-1252 ,-1130 ,-1013 ,-882 ,-753 ,-625 ,-481 ,-345 ,-206 ,-70 ,59 ,198 ,337 ,479 , 610 ,736 ,860 ,976 ,1096 ,1202 ,1301 ,1392 ,1481 ,1556 ,1623 ,1689 ,1737 ,1782 ,1819 , 1848 ,1862 ,1862 ,1858 ,1853 ,1832 ,1796 ,1755 ,1709 ,1654 ,1585 ,1524 ,1440 ,1348 ,1257 , 1159 ,1056 ,946 ,837 ,717 ,597 ,475 ,354 ,232 ,109 ,-11 ,-129 ,-248 ,-366 ,-483 , -594 ,-703 ,-813 ,-908 ,-1001 ,-1090 ,-1171 ,-1248 ,-1317 ,-1382 ,-1430 ,-1472 ,-1514 ,-1539 ,-1565 , -1575 ,-1573 ,-1575 ,-1560 ,-1540 ,-1514 ,-1478 ,-1431 ,-1379 ,-1323 ,-1258 ,-1188 ,-1114 ,-1029 ,-937 , -844 ,-752 ,-648 ,-545 ,-440 ,-331 ,-224 ,-106 ,-15 ,94 ,207 ,308 ,424 ,518 ,621 , 715 ,804 ,896 ,978 ,1054 ,1127 ,1192 ,1251 ,1308 ,1352 ,1391 ,1424 ,1453 ,1470 ,1482 , 1484 ,1478 ,1463 ,1442 ,1418 ,1385 ,1344 ,1293 ,1246 ,1182 ,1120 ,1054 ,977 ,898 ,810 , 727 ,635 ,545 ,448 ,357 ,261 ,158 ,63 ,-32 ,-124 ,-217 ,-314 ,-407 ,-492 ,-578 , -662 ,-740 ,-812 ,-876 ,-947 ,-997 ,-1052 ,-1096 ,-1132 ,-1174 ,-1189 ,-1217 ,-1230 ,-1238 ,-1234 , -1224 ,-1219 ,-1195 ,-1170 ,-1140 ,-1099 ,-1056 ,-1014 ,-953 ,-899 ,-832 ,-765 ,-699 ,-616 ,-550 , -466 ,-380 ,-300 ,-214 ,-129 ,-46 ,29 ,119 ,203 ,289 ,368 ,443 ,519 ,593 ,668 , 727 ,787 ,846 ,900 ,949 ,991 ,1032 ,1063 ,1090 ,1118 ,1138 ,1143 ,1145 ,1142 ,1142 , 1131 ,1111 ,1087 ,1055 ,1029 ,986 ,948 ,900 ,844 ,792 ,733 ,677 ,605 ,542 ,475 , 396 ,332 ,257 ,181 ,107 ,30 ,-40 ,-115 ,-186 ,-255 ,-324 ,-389 ,-458 ,-522 ,-579 , -639 ,-685 ,-729 ,-775 ,-813 ,-851 ,-877 ,-900 ,-922 ,-938 ,-949 ,-947 ,-949 ,-946 ,-934 , -918 ,-892 ,-866 ,-839 ,-804 ,-764 ,-725 ,-675 ,-624 ,-572 ,-517 ,-459 ,-397 ,-337 ,-270 , -203 ,-138 ,-70 ,-9 ,55 ,122 ,188 ,256 ,319 ,381 ,443 ,495 ,552 ,607 ,646 , 693 ,732 ,767 ,804 ,828 ,855 ,873 ,887 ,901 ,911 ,912 ,907 ,901 ,884 ,867 , 846 ,822 ,795 ,762 ,728 ,685 ,644 ,599 ,550 ,502 ,445 ,393 ,334 ,274 ,221 , 160 ,101 ,40 ,-11 ,-69 ,-125 ,-177 ,-236 ,-286 ,-340 ,-389 ,-437 ,-477 ,-515 ,-559 , -588 ,-624 ,-648 ,-670 ,-698 ,-712 ,-726 ,-732 ,-736 ,-738 ,-734 ,-730 ,-720 ,-706 ,-688 , -664 ,-640 ,-609 ,-576 ,-547 ,-505 ,-470 ,-427 ,-382 ,-336 ,-285 ,-239 ,-185 ,-140 ,-83 , -39 ,6 ,66 ,113 ,166 ,214 ,264 ,311 ,357 ,400 ,443 ,484 ,519 ,554 ,584 , 614 ,635 ,657 ,676 ,691 ,708 ,709 ,713 ,719 ,711 ,706 ,700 ,683 ,666 ,644 , 625 ,600 ,570 ,539 ,501 ,475 ,436 ,390 ,351 ,304 ,262 ,214 ,168 ,123 ,76 , 29 ,-11 ,-52 ,-102 ,-143 ,-188 ,-230 ,-267 ,-307 ,-342 ,-380 ,-411 ,-442 ,-466 ,-490 , -515 ,-526 ,-543 ,-555 ,-560 ,-573 ,-577 ,-575 ,-575 ,-561 ,-550 ,-538 ,-522 ,-506 ,-481 , -459 ,-434 ,-402 ,-377 ,-345 ,-308 ,-276 ,-238 ,-200 ,-158 ,-121 ,-82 ,-35 ,-8 ,28 , 76 ,115 ,157 ,194 ,231 ,267 ,297 ,335 ,366 ,391 ,422 ,447 ,463 ,483 ,506 , 519 ,528 ,538 ,549 ,556 ,557 ,555 ,556 ,546 ,536 ,522 ,516 ,501 ,477 ,463 , 439 ,416 ,386 ,361 ,328 ,297 ,265 ,231 ,201 ,165 ,133 ,90 ,58 ,20 ,-10 , -38 ,-75 ,-109 ,-139 ,-167 ,-205 ,-233 ,-262 ,-285 ,-304 ,-330 ,-353 ,-370 ,-384 ,-397 , -407 ,-418 ,-426 ,-432 ,-432 ,-433 ,-431 ,-423 ,-417 ,-404 ,-392 ,-375 ,-363 ,-345 ,-321 , -302 ,-279 ,-255 ,-225 ,-199 ,-165 ,-135 ,-106 ,-72 ,-45 ,-13 ,10 ,45 ,78 ,106 , 137 ,165 ,196 ,224 ,250 ,272 ,293 ,319 ,337 ,354 ,373 ,385 ,398 ,410 ,418 , 422 ,428 ,432 ,431 ,429 ,422 ,418 ,410 ,400 ,385 ,374 ,360 ,338 ,323 ,301 , 278 ,259 ,235 ,208 ,184 ,159 ,132 ,105 ,75 ,53 ,22 ,0 ,-16 ,-48 ,-73 , -100 ,-124 ,-141 ,-168 ,-191 ,-204 ,-225 ,-243 ,-258 ,-270 ,-277 ,-296 ,-304 ,-303 ,-317 , -321 ,-321 ,-320 ,-319 ,-313 ,-301 ,-301 ,-290 ,-276 ,-267 ,-254 ,-238 ,-221 ,-207 ,-189 , -169 ,-147 ,-124 ,-107 ,-81 ,-59 ,-36 ,-11 ,0 ,26 ,53 ,76 ,96 ,118 ,146 , 164 ,188 ,205 ,224 ,244 ,257 ,271 ,285 ,296 ,310 ,320 ,324 ,331 ,332 ,339 , 338 ,337 ,338 ,330 ,324 ,318 ,314 ,299 ,290 ,276 ,264 ,249 ,231 ,216 ,194 , 181 ,158 ,135 ,118 ,98 ,73 ,52 ,32 ,8 ,-6 ,-25 ,-48 ,-64 ,-81 ,-107 , -121 ,-138 ,-156 ,-168 ,-187 ,-193 ,-204 ,-219 ,-224 ,-233 ,-239 ,-244 ,-248 ,-248 ,-249 , -247 ,-248 ,-244 ,-236 ,-231 ,-222 ,-216 ,-202 ,-190 ,-182 ,-170 ,-152 ,-135 ,-122 ,-105 , -91 ,-72 ,-55 ,-40 ,-18 ,-6 ,7 ,27 ,43 ,60 ,79 ,98 ,112 ,126 ,143 , 157 ,172 ,181 ,194 ,206 ,212 ,224 ,232 ,233 ,244 ,246 ,246 ,250 ,250 ,250 , 246 ,244 ,241 ,236 ,229 ,223 ,218 ,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 ,-22898 ,-14650 ,-3258 ,61 ,14015 , -6716 ,-14853 ,-4034 ,-2471 ,12068 ,3609 ,-8219 ,-10344 ,-11294 ,-6181 ,-399 ,12834 ,21758 ,4728 ,-15037 , -14441 ,-7119 ,-2158 ,852 ,2589 ,273 ,-1154 ,-1134 ,-2748 ,-6641 ,-8439 ,591 ,-783 ,-16296 ,-20662 , -9442 ,-1853 ,-10384 ,-21699 ,-17064 ,-6748 ,-455 ,506 ,461 ,-897 ,-1299 ,-1668 ,349 ,19080 ,-2729 , -13425 ,6344 ,-5623 ,-42 ,9500 ,10205 ,8967 ,19462 ,29951 ,14040 ,2513 ,-3974 ,-3387 ,6628 ,15054 , 18685 ,28403 ,24652 ,8843 ,-5671 ,-5930 ,10140 ,15334 ,19760 ,-2458 ,-971 ,9217 ,-5769 ,-3946 ,-2489 , 14520 ,5488 ,-17316 ,-10051 ,-6798 ,-1219 ,1853 ,-3733 ,6492 ,-6545 ,-10634 ,-7020 ,-18056 ,-1538 ,-3336 , -8374 ,-12993 ,-17146 ,-6349 ,-354 ,2722 ,907 ,-329 ,146 ,-2077 ,1577 ,-558 ,-7596 ,-6150 ,-4659 , 8486 ,5702 ,-12418 ,-6710 ,3446 ,-4169 ,-13796 ,-1277 ,13215 ,-7218 ,-10028 ,-731 ,-6687 ,100 ,-9725 , -7862 ,4254 ,-6768 ,-2656 ,11906 ,-2759 ,-15500 ,-8722 ,-3543 ,1032 ,2715 ,3390 ,1950 ,5865 ,16647 , 6183 ,-9535 ,-2429 ,-6649 ,-4786 ,4492 ,14843 ,23710 ,3772 ,-1674 ,3921 ,8936 ,10898 ,10941 ,10542 , 12390 ,22424 ,5395 ,-10433 ,-2487 ,6394 ,9232 ,6746 ,6684 ,19616 ,9659 ,-13439 ,-7817 ,-1540 ,3176 , 3702 ,2057 ,1065 ,-1086 ,-1651 ,-4368 ,-3228 ,-5499 ,-3342 ,-6492 ,-16 ,8688 ,-8927 ,-12459 ,-4433 , -13855 ,-14471 ,-3646 ,-8626 ,-10708 ,-4243 ,6188 ,5845 ,-9997 ,-7859 ,1861 ,-5226 ,-1616 ,6690 ,-2850 , -12749 ,-4495 ,6033 ,-7618 ,-11929 ,-3893 ,721 ,4373 ,13223 ,7688 ,-13079 ,-14246 ,-5797 ,48 ,2766 , 2268 ,1245 ,1033 ,-1456 ,9910 ,7711 ,-14343 ,-10443 ,2805 ,2021 ,-2725 ,-343 ,3183 ,2779 ,5458 , 4473 ,11858 ,13303 ,-9631 ,-11468 ,-464 ,5800 ,13575 ,9427 ,77 ,9817 ,15364 ,-1096 ,-6370 ,5112 , 18572 ,10538 ,-224 ,-2736 ,-5581 ,9364 ,11106 ,2159 ,7024 ,4911 ,-3422 ,-7022 ,98 ,5793 ,8412 , -626 ,-3357 ,-1106 ,-174 ,13383 ,-4509 ,-6933 ,-5130 ,-12062 ,-3532 ,-9250 ,-2495 ,-110 ,-4982 ,-6832 , -4231 ,-3700 ,-1588 ,-1724 ,-1977 ,5072 ,-13873 ,-8194 ,2555 ,-13702 ,-6062 ,430 ,-7722 ,-5762 ,-3168 , 2870 ,11674 ,-1393 ,-13494 ,-8278 ,6418 ,2391 ,-7743 ,6470 ,3220 ,-9505 ,-6067 ,-576 ,1291 ,2067 , 3675 ,5470 ,3414 ,-4055 ,778 ,12436 ,291 ,-13458 ,1282 ,8334 ,-3643 ,-5255 ,1345 ,3134 ,12498 , 15357 ,-3423 ,-8952 ,-2910 ,3856 ,6413 ,11823 ,8121 ,-1184 ,7321 ,3982 ,3367 ,1840 ,-4176 ,-2915 , 6628 ,11610 ,4812 ,3441 ,-5361 ,-44 ,11010 ,7292 ,-3016 ,-2500 ,8904 ,1168 ,-3584 ,1396 ,2024 , -3168 ,-5383 ,2781 ,4108 ,-2317 ,-8328 ,-7032 ,-1996 ,-986 ,5070 ,5433 ,-9214 ,-11099 ,-6260 ,-3248 , 7197 ,2088 ,-12377 ,-12411 ,-7289 ,-2923 ,-768 ,-2083 ,-990 ,-594 ,4289 ,-1235 ,-7891 ,-2588 ,-10624 , -8762 ,3706 ,-40 ,-5205 ,4445 ,7749 ,-2835 ,-7787 ,-6258 ,3932 ,7743 ,1269 ,-6646 ,-4193 ,6650 , 3478 ,3789 ,-771 ,-5173 ,-1922 ,2210 ,11101 ,4626 ,1755 ,2057 ,137 ,797 ,-770 ,-2389 ,-981 , 9415 ,9930 ,570 ,-4235 ,-1152 ,2932 ,6387 ,7915 ,2846 ,974 ,3028 ,4197 ,8367 ,5389 ,-6180 , -4635 ,451 ,3029 ,4385 ,3287 ,3967 ,2542 ,7496 ,7067 ,-5447 ,-8428 ,-4730 ,-2855 ,2391 ,837 , 3465 ,6829 ,245 ,-1124 ,-5586 ,-7838 ,-7234 ,-3246 ,-873 ,-664 ,144 ,372 ,4498 ,-4210 ,-10855 , -6741 ,-1529 ,2470 ,3557 ,-4653 ,-11817 ,-10074 ,-4148 ,-1370 ,686 ,7184 ,-945 ,-8311 ,-4728 ,4839 , -461 ,-7001 ,-3679 ,469 ,4236 ,1208 ,2512 ,-3496 ,-3010 ,-4856 ,1242 ,6376 ,-2853 ,-3650 ,-1290 , 6209 ,2222 ,5940 ,5451 ,-3614 ,-1231 ,1377 ,7455 ,3521 ,2014 ,2833 ,-4193 ,-3297 ,524 ,4659 , 7318 ,3349 ,1726 ,1971 ,2708 ,5852 ,2714 ,1361 ,5140 ,-964 ,-5377 ,-299 ,1558 ,3927 ,2762 , 6505 ,10365 ,-1186 ,-4194 ,-5303 ,-4939 ,152 ,4564 ,10650 ,-455 ,-7461 ,-3789 ,-1101 ,4756 ,1998 , -2722 ,-2646 ,-931 ,-1198 ,1520 ,12 ,-4173 ,-3076 ,-3108 ,5152 ,759 ,-11107 ,-6706 ,-2145 ,-1726 , -2004 ,-491 ,-2000 ,-3210 ,-285 ,-2816 ,2290 ,2715 ,-6939 ,-8231 ,-6338 ,-2376 ,22 ,886 ,482 , 1187 ,1429 ,4856 ,585 ,-9470 ,-6266 ,-1536 ,1601 ,2149 ,4206 ,8897 ,2514 ,-6006 ,-1248 ,-2038 , -3765 ,1188 ,2845 ,4269 ,3790 ,4101 ,2515 ,1340 ,2854 ,7242 ,1008 ,-5496 ,-430 ,1840 ,4441 , 719 ,5666 ,7805 ,1553 ,73 ,-5146 ,-4745 ,-263 ,8850 ,4323 ,1359 ,3469 ,-1105 ,2307 ,-1423 , -1828 ,-1452 ,810 ,8531 ,2855 ,-2627 ,-1246 ,-491 ,-310 ,-202 ,-2332 ,-4288 ,-1304 ,-691 ,1187 , 112 ,2085 ,5436 ,-3845 ,-6662 ,-4282 ,1856 ,3941 ,-3572 ,-3872 ,-2365 ,-6366 ,-4153 ,-946 ,938 , 2243 ,-2850 ,-3357 ,-1575 ,-671 ,-1967 ,-2530 ,-3846 ,-5386 ,-2390 ,-130 ,1129 ,960 ,955 ,1246 , -586 ,1770 ,3662 ,-2807 ,-6608 ,-5017 ,81 ,2120 ,2780 ,3189 ,2313 ,4127 ,-926 ,-5234 ,1107 , 3400 ,975 ,3768 ,1750 ,694 ,2552 ,287 ,1267 ,876 ,-1716 ,-687 ,1140 ,6838 ,5899 ,-681 , -350 ,1157 ,2193 ,2065 ,7543 ,3187 ,-2718 ,474 ,-3564 ,-1731 ,971 ,1714 ,3108 ,1577 ,4961 , 3424 ,-1702 ,-794 ,-4128 ,-5532 ,2529 ,4311 ,394 ,-716 ,-5257 ,-2946 ,3374 ,-892 ,-2917 ,-320 , 3006 ,3474 ,-2531 ,-6447 ,-5630 ,-1469 ,-765 ,1178 ,517 ,224 ,3315 ,-3380 ,-3617 ,-2343 ,-3399 , -3222 ,-1414 ,-486 ,-3663 ,-2006 ,-843 ,3814 ,3160 ,-4140 ,-4758 ,-1830 ,-1008 ,363 ,2905 ,2456 , -3018 ,-3912 ,3192 ,137 ,-1384 ,2470 ,1170 ,-1523 ,-2866 ,-1536 ,1536 ,5279 ,2523 ,-1446 ,1225 , 5699 ,3861 ,-2020 ,-3699 ,-1398 ,1456 ,2893 ,2758 ,3004 ,1732 ,3057 ,5479 ,-218 ,-3386 ,2946 , 2320 ,-1921 ,3185 ,3282 ,-608 ,-1181 ,-334 ,-185 ,-1366 ,896 ,1908 ,1804 ,6504 ,3645 ,-3204 , -3828 ,-3760 ,-1249 ,537 ,1305 ,864 ,1080 ,-158 ,2137 ,1695 ,-3863 ,-315 ,-40 ,-3642 ,-5390 , -132 ,2246 ,-1578 ,-3144 ,-3321 ,750 ,-867 ,385 ,3020 ,-2809 ,-4884 ,-405 ,1969 ,-661 ,-2410 , -2630 ,-2743 ,-3401 ,-1663 ,185 ,975 ,2174 ,-612 ,-1719 ,-1279 ,-353 ,240 ,1 ,3631 ,778 , -1680 ,449 ,-3929 ,-2345 ,3085 ,934 ,-343 ,-821 ,934 ,2754 ,-664 ,-1101 ,688 ,1588 ,2255 , 1989 ,1780 ,1622 ,1130 ,4740 ,1795 ,-2630 ,2277 ,538 ,-2527 ,345 ,1260 ,2553 ,3392 ,515 , -206 ,756 ,3382 ,1276 ,-2104 ,-794 ,3102 ,3015 ,-2849 ,-1192 ,-464 ,1378 ,2255 ,1419 ,2621 , -1266 ,-4496 ,-2888 ,1894 ,553 ,-1277 ,-1278 ,1397 ,2613 ,-2578 ,-2683 ,-2129 ,-28 ,2247 ,-1321 , -3929 ,-1005 ,1511 ,-1810 ,-2859 ,-1042 ,-443 ,-194 ,-689 ,542 ,2781 ,476 ,-2798 ,-3528 ,-5240 , -2354 ,2583 ,-322 ,-2354 ,-845 ,-358 ,733 ,4 ,1551 ,2841 ,564 ,-1278 ,-3524 ,-3053 ,1574 , 1423 ,-732 ,2512 ,1585 ,-91 ,-2115 ,-2329 ,1535 ,913 ,3655 ,3179 ,-1342 ,-1961 ,942 ,3801 , 351 ,-1001 ,852 ,1894 ,2490 ,2782 ,1986 ,250 ,-812 ,-563 ,422 ,-620 ,-989 ,679 ,1991 , 2650 ,1127 ,902 ,3813 ,1125 ,-3036 ,-1515 ,59 ,1014 ,534 ,394 ,1940 ,101 ,-986 ,-1681 , 1238 ,2417 ,-1988 ,-868 ,316 ,-1919 ,-3568 ,-1853 ,-572 ,2690 ,2133 ,-1533 ,196 ,-1310 ,-2051 , -1429 ,-2106 ,-1245 ,-1501 ,-1488 ,-375 ,6 ,316 ,-267 ,2337 ,643 ,-3669 ,-2911 ,-49 ,2702 , -2314 ,-2945 ,-1448 ,719 ,3005 ,-1077 ,-300 ,-845 ,-784 ,-64 ,-683 ,458 ,111 ,174 ,-193 , -985 ,-1013 ,382 ,1137 ,2337 ,3559 ,913 ,-261 ,652 ,-360 ,-387 ,-929 ,-609 ,1324 ,3528 , 2181 ,-1245 ,535 ,2067 ,1045 ,92 ,98 ,-913 ,1009 ,1584 ,1755 ,1855 ,-1125 ,879 ,1430 , 124 ,-1201 ,-956 ,272 ,1893 ,2085 ,-326 ,-373 ,1401 ,1170 ,-1162 ,-397 ,9 ,-509 ,-549 , -1349 ,-2421 ,442 ,1850 ,132 ,-581 ,-1582 ,241 ,-706 ,-2363 ,-1538 ,-323 ,28 ,-133 ,-72 , -379 ,-298 ,-722 ,1581 ,1021 ,-1529 ,-2641 ,-3652 ,-1752 ,-517 ,512 ,357 ,1067 ,2441 ,-1137 , -3104 ,-2174 ,-330 ,2661 ,1048 ,-2207 ,-1437 ,-583 ,1357 ,3289 ,172 ,-1780 ,-1595 ,-1129 ,1 , 822 ,1197 ,1270 ,2326 ,1838 ,29 ,-1781 ,-262 ,2408 ,1507 ,-769 ,-1699 ,-256 ,1048 ,1018 , 1392 ,3560 ,2151 ,-1841 ,-1558 ,-180 ,1108 ,2954 ,1796 ,282 ,-1070 ,-593 ,1257 ,108 ,-537 , -741 ,1219 ,2648 ,-304 ,-1196 ,1136 ,-157 ,-845 ,1422 ,527 ,-1135 ,-2179 ,-386 ,1339 ,87 , -709 ,-239 ,804 ,223 ,-1613 ,-1892 ,-1173 ,893 ,1736 ,-951 ,-2465 ,-1675 ,1090 ,245 ,-1101 , 848 ,-1382 ,-2315 ,-143 ,221 ,187 ,-1439 ,-1673 ,334 ,869 ,-441 ,-772 ,276 ,-1138 ,-1393 , -265 ,936 ,1329 ,-22 ,-1198 ,-523 ,321 ,-953 ,670 ,1793 ,333 ,-676 ,-402 ,716 ,155 , -445 ,-153 ,649 ,808 ,992 ,1169 ,1871 ,1561 ,-1285 ,-456 ,991 ,260 ,509 ,-211 ,-722 , 447 ,678 ,1211 ,1981 ,1482 ,842 ,-797 ,-1345 ,49 ,366 ,1278 ,2616 ,-178 ,-973 ,1194 , 334 ,-1512 ,-833 ,1292 ,449 ,-919 ,-36 ,646 ,472 ,-223 ,-1551 ,-1039 ,-245 ,217 ,240 , 184 ,71 ,75 ,1822 ,-563 ,-2803 ,-1808 ,-824 ,8 ,97 ,-132 ,-469 ,119 ,172 ,91 , -807 ,-1748 ,-1088 ,434 ,1513 ,-112 ,-2452 ,-1378 ,938 ,-388 ,-1292 ,27 ,783 ,480 ,-339 , -1042 ,-1207 ,-245 ,306 ,651 ,554 ,516 ,339 ,267 ,251 ,110 ,2206 ,1558 ,-706 ,-1671 , -2012 ,-498 ,661 ,1654 ,936 ,366 ,587 ,363 ,1728 ,1103 ,-648 ,-522 ,188 ,390 ,918 , 464 ,1145 ,2540 ,53 ,-1562 ,-1193 ,-130 ,122 ,1717 ,1664 ,-501 ,-168 ,-664 ,24 ,806 , 1371 ,-285 ,-676 ,32 ,-1300 ,-300 ,266 ,228 ,42 ,559 ,172 ,778 ,701 ,-1596 ,-1852 , -1104 ,-387 ,196 ,1864 ,181 ,-1757 ,-1589 ,-434 ,1568 ,304 ,-910 ,-1568 ,-1894 ,-757 ,-132 , 324 ,1534 ,318 ,-1356 ,-783 ,727 ,637 ,-1497 ,-634 ,-438 ,-170 ,1 ,24 ,638 ,-799 , 29 ,-635 ,228 ,1149 ,-481 ,-555 ,548 ,1555 ,-243 ,136 ,-23 ,-802 ,5 ,361 ,749 , 643 ,1011 ,964 ,572 ,-594 ,-454 ,241 ,1076 ,1798 ,-30 ,-1070 ,-206 ,1432 ,509 ,-259 , 763 ,-55 ,49 ,454 ,25 ,121 ,382 ,309 ,98 ,-120 ,325 ,-149 ,-286 ,923 ,-166 , -598 ,-146 ,275 ,1088 ,728 ,202 ,-493 ,-786 ,-1003 ,-1183 ,-336 ,-31 ,491 ,1572 ,418 , -752 ,-831 ,-1511 ,-1081 ,-637 ,184 ,1084 ,141 ,-832 ,-387 ,751 ,-288 ,-1418 ,-1208 ,43 , 1055 ,30 ,-958 ,-991 ,-347 ,158 ,-115 ,340 ,1320 ,-526 ,-492 ,58 ,-972 ,-292 ,-261 , 58 ,516 ,1284 ,862 ,-216 ,-1078 ,-669 ,904 ,165 ,-273 ,-147 ,168 ,501 ,600 ,580 , 513 ,598 ,731 ,1416 ,425 ,-721 ,-570 ,-198 ,653 ,-174 ,-19 ,930 ,136 ,631 ,669 , 327 ,194 ,11 ,-252 ,-646 ,-78 ,346 ,530 ,509 ,389 ,255 ,282 ,202 ,-140 ,-159 , 1033 ,273 ,-1413 ,-913 ,-532 ,115 ,-22 ,766 ,801 ,-857 ,-226 ,-73 ,-466 ,-353 ,-704 , -542 ,-377 ,-837 ,-424 ,-153 ,522 ,1276 ,74 ,-618 ,-693 ,-785 ,-302 ,-224 ,-716 ,-554 , -168 ,261 ,735 ,93 ,-452 ,1 ,265 ,475 ,457 ,-675 ,-1161 ,-466 ,35 ,104 ,271 , 261 ,226 ,1131 ,1158 ,-604 ,-941 ,143 ,43 ,-166 ,53 ,1174 ,1244 ,-122 ,-352 ,-198 , 371 ,433 ,190 ,-87 ,-97 ,48 ,51 ,434 ,514 ,654 ,486 ,536 ,327 ,55 ,58 , 0 ,-43 ,52 ,201 ,132 ,785 ,728 ,301 ,-109 ,-624 ,-1053 ,-296 ,203 ,21 ,713 , -193 ,-49 ,-132 ,-664 ,-208 ,-118 ,900 ,504 ,-253 ,-298 ,-585 ,-431 ,-536 ,-434 ,41 , -16 ,21 ,-150 ,-697 ,-339 ,319 ,28 ,-179 ,-298 ,-815 ,122 ,513 ,-510 ,-615 ,-142 , 67 ,138 ,-159 ,196 ,800 ,-468 ,-767 ,-288 ,-14 ,119 ,366 ,1079 ,-244 ,-165 ,98 , -417 ,12 ,-543 ,351 ,600 ,148 ,467 ,-85 ,-36 ,614 ,320 ,-195 ,166 ,79 ,-119 , 245 ,384 ,412 ,1012 ,863 ,35 ,-412 ,-541 ,-317 ,493 ,894 ,248 ,187 ,-139 ,-515 , -240 ,141 ,216 ,944 ,823 ,-344 ,169 ,-52 ,-626 ,-670 ,-183 ,837 ,499 ,-62 ,-315 , -700 ,-187 ,342 ,99 ,-39 ,-707 ,-233 ,479 ,-225 ,-342 ,-20 ,485 ,-354 ,-503 ,198 , -489 ,-485 ,-133 ,-192 ,-201 ,560 ,520 ,-341 ,-288 ,-408 ,-712 ,-109 ,462 ,-26 ,-205 , 0 ,-56 ,-73 ,-116 ,-351 ,-384 ,97 ,153 ,276 ,895 ,189 ,-564 ,-243 ,-83 ,189 , 145 ,681 ,547 ,-221 ,213 ,-166 ,-113 ,-78 ,46 ,887 ,473 ,-247 ,-413 ,-13 ,571 , 599 ,-218 ,-15 ,493 ,271 ,333 ,-31 ,5 ,-98 ,-130 ,318 ,-45 ,354 ,635 ,26 , -369 ,-320 ,473 ,731 ,-68 ,-328 ,75 ,-317 ,17 ,136 ,-351 ,-249 ,35 ,696 ,-30 , -273 ,191 ,-97 ,-352 ,-624 ,-40 ,457 ,20 ,-129 ,-189 ,-538 ,-100 ,-247 ,-360 ,185 , 41 ,-138 ,-382 ,215 ,262 ,-172 ,-306 ,-516 ,-376 ,-180 ,521 ,467 ,14 ,-464 ,-244 , 139 ,-48 ,208 ,49 ,-17 ,-9 ,-233 ,-121 ,237 ,-26 ,-109 ,501 ,428 ,95 ,50 , -41 ,18 ,-182 ,5 ,291 ,-6 ,99 ,187 ,806 ,546 ,-20 ,-68 ,-262 ,353 ,72 , -102 ,-40 ,194 ,710 ,160 ,-320 ,-4 ,258 ,244 ,350 ,-162 ,102 ,481 ,-19 ,-90 , -187 ,-158 ,-67 ,-110 ,60 ,355 ,284 ,-43 ,-323 ,-273 ,159 ,277 ,42 ,-43 ,-223 , -496 ,-258 ,-102 ,323 ,279 ,-142 ,140 ,-88 ,-131 ,-145 ,-288 ,-198 ,-191 ,-335 ,-321 , -108 ,129 ,628 ,145 ,-383 ,-283 ,-338 ,-185 ,-66 ,54 ,57 ,69 ,55 ,9 ,424 , 264 ,-408 ,-373 ,-181 ,51 ,513 ,332 ,-313 ,-347 ,232 ,63 ,-7 ,225 ,-132 ,-94 , -5 ,490 ,720 ,204 ,-57 ,-113 ,-21 ,-79 ,88 ,325 ,285 ,168 ,97 ,15 ,53 , -37 ,180 ,451 ,-111 ,178 ,218 ,44 ,278 ,-40 ,161 ,-37 ,-258 ,-132 ,222 ,429 , 164 ,69 ,-282 ,-287 ,-81 ,398 ,195 ,-256 ,178 ,-74 ,-116 ,-2 ,-331 ,-77 ,0 , -117 ,40 ,44 ,-226 ,-200 ,95 ,-257 ,-288 ,-135 ,124 ,332 ,-195 ,54 ,38 ,-342 , -347 ,2 ,392 ,47 ,-86 ,-302 ,-186 ,36 ,-36 ,-188 ,-196 ,292 ,190 ,-58 ,-108 , -31 ,196 ,234 ,-19 ,-208 ,-103 ,-6 ,83 ,138 ,182 ,177 ,181 ,217 ,275 ,327 , 121 ,-349 ,-176 ,169 ,55 ,-3 ,-100 ,-79 ,129 ,190 ,276 ,672 ,241 ,-163 ,152 , 22 ,-161 ,-287 ,-123 ,312 ,247 ,12 ,144 ,180 ,22 ,189 ,299 ,-101 ,-339 ,-319 , -71 ,72 ,163 ,484 ,191 ,-363 ,-232 ,206 ,-6 ,-53 ,-52 ,-169 ,-46 ,-43 ,-39 , -270 ,-76 ,156 ,36 ,-154 ,-163 ,1 ,-93 ,-39 ,-116 ,-255 ,-181 ,186 ,264 ,-149 , -28 ,6 ,-30 ,-111 ,-287 ,-204 ,-55 ,384 ,214 ,-205 ,-129 ,-43 ,105 ,427 ,145 , -166 ,-22 ,-35 ,85 ,0 ,-18 ,11 ,71 ,64 ,-4 ,141 ,109 ,-87 ,101 ,360 , 96 ,131 ,-22 ,13 ,210 ,-51 ,-2 ,78 ,116 ,413 ,472 ,-95 ,-280 ,-126 ,67 , 481 ,161 ,-194 ,123 ,102 ,-45 ,-27 ,-48 ,-14 ,-99 ,-89 ,-20 ,167 ,469 ,115 , -217 ,-52 ,4 ,-116 ,-294 ,-14 ,262 ,59 ,-234 ,-134 ,100 ,-112 ,-197 ,-47 ,84 , 235 ,124 ,-117 ,-167 ,-177 ,-135 ,-204 ,-78 ,202 ,-70 ,-197 ,97 ,154 ,-142 ,-221 , -102 ,-13 ,68 ,44 ,320 ,359 ,-29 ,-200 ,-198 ,-232 ,-131 ,107 ,120 ,155 ,94 , -138 ,-76 ,-13 ,179 ,470 ,183 ,-51 ,-88 ,-145 ,30 ,135 ,55 ,-51 ,108 ,271 , 158 ,59 ,-40 ,-127 ,-18 ,54 ,134 ,167 ,268 ,443 ,70 ,-234 ,-141 ,15 ,24 , 212 ,427 ,125 ,-71 ,-112 ,-174 ,-154 ,-22 ,23 ,306 ,360 ,-98 ,-20 ,-4 ,-227 , 99 ,202 ,-95 ,-10 ,6 ,-54 ,-105 ,-200 ,-85 ,-5 ,-2 ,76 ,273 ,136 ,-203 , -310 ,-228 ,69 ,155 ,56 ,-7 ,-124 ,-71 ,-142 ,-129 ,31 ,-106 ,-118 ,22 ,84 , 68 ,119 ,193 ,-49 ,-218 ,45 ,172 ,13 ,-56 ,-196 ,-139 ,-10 ,98 ,376 ,200 , -117 ,-22 ,216 ,52 ,-45 ,37 ,108 ,124 ,-80 ,43 ,88 ,77 ,111 ,49 ,10 , 27 ,65 ,-57 ,-25 ,67 ,111 ,146 ,115 ,104 ,69 ,75 ,256 ,111 ,-135 ,-115 , -70 ,203 ,233 ,46 ,-141 ,-158 ,101 ,6 ,-66 ,-127 ,-18 ,316 ,73 ,-70 ,25 , 7 ,-5 ,-126 ,-39 ,41 ,54 ,95 ,-30 ,-78 ,-122 ,-80 ,-64 ,138 ,265 ,-70 , -51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 ,-61 , -26 ,31 ,57 ,16 ,12 ,49 ,-3 ,-23 ,10 ,38 ,71 ,201 ,128 ,-41 ,-71 , 42 ,126 ,32 ,37 ,-20 ,-43 ,2 ,-3 ,3 ,-3 ,2 ,-1 ,1 ,0 ,0 , 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,-1293 ,878 , -292 ,-2564 ,9621 ,-5915 ,-7462 ,10982 ,3235 ,-15809 ,7820 ,10448 ,-16255 ,3586 ,8816 ,-3665 ,-7449 , 10026 ,328 ,-9978 ,5127 ,1963 ,-1122 ,-4484 ,3911 ,1668 ,-1079 ,129 ,624 ,271 ,-1971 ,2723 , -736 ,-1222 ,-2121 ,1557 ,1953 ,-1284 ,1089 ,-461 ,-4676 ,7343 ,1620 ,-7741 ,3067 ,472 ,6971 , -9033 ,-3787 ,6347 ,3132 ,-3094 ,-4936 ,15374 ,-15151 ,-3045 ,15408 ,-6537 ,-5558 ,4063 ,3305 ,-4595 , 6897 ,-3822 ,-7488 ,9726 ,2169 ,-10064 ,6545 ,-152 ,-2581 ,2638 ,-5205 ,11143 ,-10009 ,1541 ,6107 , -9761 ,8932 ,-2294 ,-4117 ,5229 ,-2477 ,-1675 ,1626 ,2250 ,5853 ,-15235 ,6472 ,9561 ,-15219 ,10362 , -836 ,-7556 ,7298 ,2009 ,-5862 ,475 ,4584 ,-5547 ,2030 ,1408 ,-278 ,222 ,-1416 ,7407 ,-9220 , -2423 ,8670 ,-1749 ,-1593 ,-710 ,5556 ,-7619 ,4599 ,7411 ,-17050 ,7709 ,6510 ,-10617 ,6782 ,506 , -6904 ,8104 ,424 ,-7828 ,5333 ,-29 ,-1819 ,-578 ,651 ,5638 ,-8332 ,6065 ,3981 ,-14323 ,9370 , 3735 ,-8677 ,5128 ,-321 ,-3506 ,2618 ,5257 ,-6410 ,-843 ,7135 ,-8164 ,3732 ,905 ,-1208 ,-1572 , 699 ,7940 ,-10072 ,166 ,7139 ,-4584 ,1390 ,624 ,-774 ,6157 ,-8939 ,-43 ,4118 ,-2170 ,4305 , -7243 ,4001 ,6293 ,-9773 ,861 ,8125 ,-4389 ,-3402 ,3772 ,63 ,-1659 ,-80 ,-584 ,7067 ,-3588 , -8293 ,7627 ,3825 ,-7807 ,1823 ,6699 ,-8428 ,2383 ,1020 ,1596 ,527 ,-8341 ,10361 ,-1437 ,-7787 , 6634 ,-1777 ,3438 ,-690 ,-5484 ,2849 ,-74 ,5542 ,-7924 ,2596 ,6577 ,-8251 ,1512 ,-1038 ,7238 , -4249 ,-6288 ,10001 ,-2341 ,-6252 ,4869 ,4886 ,-8610 ,879 ,8165 ,-7708 ,174 ,5487 ,-4586 ,506 , 216 ,3300 ,-1234 ,-5016 ,6475 ,-2277 ,-440 ,-795 ,328 ,1477 ,-67 ,4266 ,-7986 ,2961 ,241 , -507 ,3480 ,-5081 ,730 ,4887 ,-2246 ,-1516 ,2689 ,-5975 ,7762 ,-2181 ,-4428 ,5118 ,-5027 ,5028 , 910 ,-5073 ,3477 ,1108 ,-4022 ,-189 ,5829 ,-1572 ,-6169 ,5036 ,1540 ,-3917 ,5770 ,-2167 ,-5270 , 5015 ,-458 ,-2771 ,2526 ,3978 ,-6240 ,-487 ,5530 ,-2827 ,-1699 ,4082 ,-9 ,-5252 ,4945 ,-2332 , -1258 ,2294 ,312 ,681 ,-3344 ,7547 ,-7504 ,-982 ,9815 ,-9920 ,1108 ,5699 ,-1427 ,-6117 ,5889 , 2615 ,-8914 ,7640 ,-2098 ,-4024 ,4110 ,2567 ,-4859 ,115 ,5977 ,-6344 ,-283 ,3197 ,867 ,-3468 , 4573 ,-1722 ,-5871 ,8818 ,-4224 ,-3260 ,6489 ,-1004 ,-5421 ,3295 ,4668 ,-7083 ,2084 ,3713 ,-5802 , 2562 ,1633 ,877 ,-4283 ,2265 ,3596 ,-6236 ,5643 ,-5089 ,1612 ,3427 ,-4176 ,1518 ,-1680 ,6600 , -6633 ,-688 ,4694 ,-1657 ,-820 ,-170 ,6263 ,-10415 ,4180 ,5002 ,-7890 ,3201 ,2329 ,-342 ,-4491 , 5855 ,-870 ,-4082 ,2022 ,1623 ,475 ,-3321 ,3349 ,-3905 ,4322 ,1652 ,-6876 ,3607 ,3195 ,-3055 , -2586 ,6862 ,-4203 ,-1703 ,4421 ,-3926 ,1210 ,1289 ,758 ,-1859 ,-349 ,4795 ,-6382 ,3008 ,3099 , -7397 ,4318 ,254 ,464 ,-1529 ,1374 ,2602 ,-5946 ,2061 ,4786 ,-3598 ,-4105 ,7441 ,-2727 ,-2843 , 4736 ,-4169 ,1663 ,808 ,1302 ,-3198 ,1777 ,2562 ,-5699 ,6346 ,-5112 ,1119 ,3142 ,-4893 ,2152 , 2699 ,-711 ,-4380 ,4628 ,-933 ,-1683 ,735 ,2760 ,-1943 ,-2940 ,5489 ,-1747 ,-2392 ,617 ,4577 , -3936 ,-2141 ,5943 ,-4520 ,731 ,3417 ,-4215 ,1811 ,51 ,-1197 ,1280 ,-12 ,3206 ,-4328 ,-170 , 1590 ,-741 ,3434 ,-3518 ,410 ,1067 ,-1036 ,1295 ,-1456 ,407 ,2399 ,-850 ,-3818 ,4652 ,-49 , -2993 ,2383 ,-2068 ,2824 ,-994 ,-1411 ,421 ,2571 ,156 ,-4962 ,3294 ,2905 ,-4261 ,-17 ,4251 , -3778 ,903 ,976 ,-1389 ,561 ,186 ,1124 ,-898 ,184 ,618 ,47 ,-1411 ,2332 ,-317 ,-2884 , 2321 ,-1203 ,875 ,3188 ,-4556 ,324 ,2522 ,-2113 ,2833 ,-643 ,-3783 ,3725 ,402 ,-2054 ,884 , -1045 ,2963 ,-520 ,-4091 ,4234 ,633 ,-3404 ,2456 ,-1331 ,560 ,2106 ,-3554 ,1311 ,1568 ,-1619 , 2891 ,-1467 ,-2780 ,3082 ,-1088 ,340 ,304 ,-514 ,-660 ,2730 ,-410 ,-4432 ,5650 ,-1343 ,-3225 , 2658 ,116 ,-251 ,531 ,-283 ,486 ,-859 ,-302 ,620 ,-1206 ,3279 ,-1313 ,-2435 ,2063 ,1204 , -634 ,-1982 ,2053 ,1660 ,-3286 ,1020 ,368 ,-321 ,1513 ,-1786 ,776 ,171 ,-224 ,85 ,467 , -1140 ,1324 ,510 ,-1807 ,176 ,1952 ,215 ,-4075 ,4483 ,-536 ,-3421 ,3920 ,-843 ,-1882 ,2034 , 164 ,-1367 ,140 ,774 ,895 ,-965 ,-742 ,2412 ,-1251 ,-1596 ,3525 ,-2217 ,-852 ,1050 ,849 , 613 ,-1775 ,510 ,671 ,-596 ,-342 ,2275 ,-1447 ,-1711 ,2620 ,672 ,-2251 ,804 ,306 ,421 , -714 ,-250 ,1404 ,-740 ,2119 ,-2817 ,374 ,491 ,1189 ,373 ,-3363 ,3973 ,-1728 ,-456 ,300 , 1514 ,351 ,-3439 ,3064 ,-294 ,-908 ,-205 ,1955 ,-718 ,-2289 ,3083 ,222 ,-2494 ,577 ,3186 , -3298 ,299 ,2318 ,-1950 ,98 ,1333 ,-1130 ,-370 ,2748 ,-2715 ,402 ,152 ,1999 ,-1227 ,-2222 , 3085 ,-1554 ,1994 ,-1753 ,-878 ,1422 ,1281 ,-1492 ,-1153 ,3113 ,-2523 ,756 ,636 ,-804 ,335 , -795 ,2913 ,-2681 ,-226 ,3255 ,-3697 ,1239 ,353 ,1033 ,-424 ,-2060 ,2380 ,-1306 ,779 ,-321 , -137 ,-152 ,1154 ,425 ,-3110 ,3637 ,-1021 ,-1742 ,1119 ,908 ,-685 ,-93 ,2242 ,-4056 ,2422 , 938 ,-2656 ,1762 ,-504 ,894 ,465 ,-1069 ,-636 ,632 ,1141 ,-919 ,-922 ,1588 ,806 ,-2360 , 1205 ,1374 ,-2588 ,1429 ,1361 ,-1899 ,-385 ,2612 ,-1340 ,-1525 ,2929 ,-1156 ,-1777 ,2512 ,178 , -2511 ,2093 ,803 ,-2673 ,1595 ,1518 ,-2727 ,1152 ,197 ,600 ,836 ,-2763 ,1244 ,1237 ,-233 , -1164 ,101 ,1152 ,789 ,-2374 ,1124 ,1854 ,-2911 ,1992 ,-218 ,-1118 ,1149 ,839 ,-1187 ,-469 , 2519 ,-1831 ,-976 ,2198 ,-162 ,-1579 ,866 ,1735 ,-1807 ,-700 ,2389 ,-680 ,-1609 ,1896 ,467 , -2044 ,825 ,1797 ,-1671 ,-688 ,2328 ,-626 ,-1784 ,2359 ,-178 ,-2022 ,2338 ,-165 ,-1567 ,1209 , -86 ,453 ,228 ,-1036 ,1352 ,-497 ,-777 ,1119 ,-378 ,185 ,147 ,-455 ,1094 ,-574 ,-754 , 1629 ,-274 ,-1337 ,969 ,1501 ,-2293 ,828 ,1261 ,-1981 ,804 ,978 ,-208 ,-1540 ,1960 ,-109 , -1830 ,2070 ,-501 ,-457 ,-197 ,1608 ,-545 ,-1522 ,2453 ,-1001 ,-1231 ,1856 ,90 ,-1776 ,1769 , -489 ,-342 ,1024 ,-1052 ,623 ,-70 ,-85 ,-20 ,1042 ,-777 ,-696 ,1479 ,-409 ,-584 ,694 , -103 ,-30 ,-137 ,317 ,752 ,-1473 ,1093 ,191 ,-1184 ,1618 ,-515 ,-934 ,1082 ,580 ,-784 , -627 ,1260 ,237 ,-1060 ,747 ,110 ,-574 ,739 ,-292 ,181 ,40 ,-324 ,1275 ,-1415 ,598 , 895 ,-1358 ,1107 ,-251 ,-302 ,217 ,881 ,-495 ,-982 ,1915 ,-738 ,-682 ,856 ,124 ,2 , -193 ,600 ,55 ,-289 ,-690 ,872 ,502 ,-634 ,-247 ,668 ,717 ,-1094 ,-10 ,581 ,876 , -1414 ,488 ,1147 ,-1858 ,1127 ,949 ,-1274 ,-110 ,891 ,-38 ,-504 ,1331 ,-769 ,-1018 ,1824 , -1109 ,438 ,-163 ,201 ,762 ,-1602 ,1816 ,-916 ,-413 ,1604 ,-1238 ,288 ,386 ,-453 ,666 , -502 ,-29 ,976 ,-619 ,-453 ,738 ,654 ,-1158 ,164 ,924 ,-721 ,149 ,393 ,-307 ,294 , -427 ,429 ,784 ,-1187 ,574 ,156 ,-359 ,126 ,726 ,-102 ,-1022 ,960 ,313 ,-645 ,-123 , 1359 ,-821 ,-508 ,1236 ,-551 ,-96 ,0 ,680 ,-35 ,-768 ,503 ,864 ,-710 ,-325 ,786 , -448 ,153 ,522 ,-285 ,-427 ,978 ,-365 ,-117 ,264 ,-259 ,977 ,-1208 ,904 ,397 ,-1081 , 898 ,98 ,-377 ,-173 ,1061 ,-322 ,-747 ,643 ,765 ,-913 ,-68 ,956 ,-579 ,170 ,-282 , 828 ,-84 ,-661 ,731 ,-287 ,-25 ,530 ,-38 ,-707 ,638 ,560 ,-722 ,-267 ,980 ,-29 , -799 ,317 ,473 ,-151 ,-184 ,949 ,-809 ,-520 ,1305 ,-578 ,-186 ,524 ,-243 ,73 ,41 , 95 ,-375 ,793 ,-14 ,-922 ,966 ,-171 ,-308 ,78 ,709 ,-376 ,-584 ,1073 ,-638 ,0 , 778 ,-836 ,268 ,431 ,-261 ,-220 ,265 ,816 ,-1243 ,698 ,355 ,-786 ,408 ,362 ,209 , -1127 ,1211 ,109 ,-1150 ,888 ,470 ,-770 ,-24 ,757 ,-520 ,754 ,-243 ,-741 ,890 ,-242 , 94 ,-194 ,578 ,120 ,-796 ,866 ,-220 ,-240 ,267 ,286 ,-184 ,61 ,556 ,-681 ,347 , 66 ,-544 ,871 ,-12 ,-502 ,128 ,607 ,-8 ,-823 ,726 ,312 ,-595 ,74 ,590 ,-33 , -522 ,576 ,41 ,-461 ,694 ,69 ,-523 ,428 ,161 ,-409 ,337 ,535 ,-586 ,112 ,278 , -306 ,455 ,208 ,-545 ,257 ,341 ,-298 ,184 ,96 ,63 ,-226 ,412 ,307 ,-627 ,166 , 788 ,-585 ,-205 ,1018 ,-628 ,-257 ,748 ,147 ,-757 ,527 ,661 ,-1062 ,541 ,590 ,-779 , 332 ,481 ,-406 ,-46 ,379 ,18 ,9 ,521 ,-594 ,-140 ,756 ,-178 ,-351 ,478 ,400 , -809 ,540 ,224 ,-405 ,307 ,65 ,-44 ,-76 ,658 ,-418 ,-149 ,586 ,-176 ,-283 ,505 , 247 ,-657 ,476 ,244 ,-332 ,11 ,483 ,29 ,-527 ,413 ,516 ,-626 ,118 ,601 ,-452 , 107 ,306 ,-174 ,-3 ,437 ,-155 ,-229 ,395 ,43 ,87 ,-206 ,45 ,541 ,-370 ,148 , 40 ,5 ,432 ,-314 ,-51 ,287 ,325 ,-330 ,-173 ,637 ,-56 ,-287 ,195 ,14 ,372 , -241 ,-25 ,320 ,-65 ,-110 ,159 ,506 ,-641 ,318 ,267 ,-235 ,94 ,47 ,401 ,-289 , -125 ,529 ,-73 ,-208 ,298 ,-83 ,92 ,89 ,23 ,-107 ,238 ,340 ,-587 ,263 ,363 , -237 ,-18 ,52 ,452 ,-218 ,-158 ,425 ,-305 ,116 ,462 ,-375 ,117 ,75 ,-118 ,642 , -468 ,93 ,296 ,-318 ,286 ,-38 ,377 ,-144 ,-411 ,548 ,57 ,-271 ,264 ,42 ,-19 , 48 ,147 ,-118 ,101 ,294 ,-183 ,-5 ,94 ,390 ,-320 ,-33 ,535 ,-279 ,-191 ,598 , -144 ,-356 ,638 ,-69 ,-277 ,214 ,359 ,-255 ,147 ,70 ,104 ,274 ,-398 ,268 ,25 , 265 ,-107 ,9 ,207 ,-61 ,54 ,-5 ,566 ,-553 ,217 ,429 ,-583 ,464 ,268 ,-375 , 41 ,519 ,-267 ,-57 ,414 ,-195 ,132 ,70 ,74 ,-80 ,148 ,394 ,-401 ,180 ,15 , 65 ,452 ,-499 ,171 ,364 ,-278 ,58 ,178 ,141 ,-104 ,18 ,118 ,40 ,44 ,36 , 90 ,-102 ,334 ,-75 ,-81 ,223 ,-44 ,93 ,-107 ,333 ,-50 ,-118 ,190 ,-61 ,220 , -78 ,23 ,152 ,-140 ,206 ,162 ,-237 ,58 ,199 ,-14 ,210 ,-139 ,-104 ,236 ,-60 , 76 ,-72 ,132 ,141 ,-53 ,-123 ,86 ,291 ,-232 ,22 ,124 ,55 ,-9 ,-22 ,100 , -10 ,54 ,-12 ,58 ,42 ,-33 ,121 ,-41 ,73 ,72 ,29 ,-84 ,125 ,287 ,-280 , 123 ,-58 ,182 ,192 ,-292 ,68 ,206 ,60 ,-126 ,123 ,-62 ,298 ,-79 ,-200 ,418 , -111 ,-26 ,147 ,33 ,5 ,-23 ,235 ,18 ,-227 ,311 ,168 ,-278 ,101 ,288 ,-14 , -196 ,207 ,114 ,-175 ,314 ,-59 ,-71 ,255 ,-63 ,-67 ,215 ,209 ,-295 ,120 ,289 , -172 ,45 ,275 ,-140 ,-64 ,369 ,-93 ,-69 ,225 ,-27 ,62 ,43 ,95 ,-32 ,62 , 342 ,-304 ,98 ,343 ,-175 ,-86 ,379 ,-15 ,-235 ,444 ,-87 ,-126 ,331 ,35 ,-179 , 280 ,151 ,-206 ,105 ,202 ,52 ,-95 ,204 ,-24 ,-78 ,317 ,-76 ,31 ,219 ,-105 , -44 ,229 ,190 ,-214 ,141 ,244 ,-180 ,85 ,270 ,-104 ,-92 ,319 ,71 ,-215 ,191 , 264 ,-283 ,201 ,198 ,-130 ,99 ,33 ,161 ,-118 ,216 ,24 ,-128 ,398 ,-146 ,-46 , 274 ,-39 ,-13 ,124 ,42 ,-6 ,23 ,255 ,-103 ,-74 ,357 ,-157 ,35 ,194 ,-84 , 23 ,180 ,38 ,-146 ,220 ,177 ,-184 ,16 ,363 ,-148 ,-82 ,371 ,-98 ,-101 ,303 , 71 ,-220 ,263 ,150 ,-205 ,151 ,265 ,-184 ,16 ,311 ,-141 ,33 ,186 ,-91 ,91 , 238 ,-166 ,108 ,172 ,-101 ,113 ,64 ,41 ,-7 ,115 ,87 ,5 ,-24 ,228 ,83 , -160 ,247 ,-41 ,25 ,206 ,-107 ,39 ,217 ,-20 ,-82 ,196 ,105 ,-102 ,120 ,94 , -24 ,95 ,38 ,53 ,35 ,40 ,94 ,42 ,-66 ,205 ,109 ,-187 ,218 ,77 ,-80 , 94 ,57 ,134 ,30 ,-45 ,112 ,-2 ,85 ,154 ,-97 ,107 ,99 ,0 ,68 ,52 , 49 ,21 ,83 ,7 ,84 ,61 ,9 ,76 ,17 ,36 ,76 ,63 ,-47 ,94 ,47 , 11 ,19 ,66 ,116 ,-121 ,177 ,76 ,-56 ,99 ,50 ,62 ,10 ,91 ,47 ,-15 , 87 ,171 ,-101 ,31 ,243 ,-85 ,-4 ,196 ,7 ,-39 ,147 ,34 ,10 ,110 ,-22 , 112 ,160 ,-135 ,110 ,189 ,-92 ,77 ,136 ,-18 ,77 ,0 ,56 ,200 ,-128 ,95 , 124 ,-72 ,40 ,-25 ,16 ,-9 ,4 ,0 ,-2 ,4 ,-5 ,5 ,-5 ,5 ,-4 , 3 ,-2 ,1 ,0 ,0 ,0 ,0 ,0 ,0 ,-888 ,-209 ,-962 ,1660 ,2336 ,-654 , -5068 ,12901 ,-3674 ,-21849 ,22706 ,3318 ,-19942 ,10710 ,2685 ,-2632 ,6745 ,-10986 ,552 ,5457 ,-2563 , 8277 ,-11279 ,-985 ,13275 ,-12035 ,1485 ,9903 ,-15118 ,4801 ,14917 ,-15093 ,-7424 ,20179 ,-4975 ,-12725 , 7486 ,-1646 ,4605 ,-515 ,-1704 ,-3198 ,13017 ,-6360 ,-17715 ,23502 ,-8751 ,-7812 ,9370 ,8511 ,-14594 , -4372 ,24116 ,-17975 ,-6800 ,19306 ,-2393 ,-18315 ,13249 ,9216 ,-17549 ,2636 ,14713 ,-6872 ,-16694 ,20860 , -2223 ,-17171 ,24321 ,-10752 ,-12033 ,13444 ,447 ,-810 ,-8002 ,13228 ,-5193 ,-6551 ,8315 ,-8927 ,8747 , -1531 ,-5062 ,1546 ,7704 ,-4582 ,-10039 ,14745 ,-1156 ,-11982 ,16472 ,-3157 ,-21254 ,22719 ,672 ,-18367 , 10719 ,10581 ,-13690 ,-2438 ,14352 ,-11041 ,76 ,5587 ,-2680 ,-2642 ,-661 ,15503 ,-15723 ,-5870 ,24672 , -18430 ,-6842 ,19121 ,-3644 ,-15140 ,14762 ,1790 ,-17427 ,18973 ,-8376 ,-8363 ,19621 ,-10565 ,-10454 ,21131 , -7042 ,-15751 ,20093 ,-4220 ,-10567 ,5339 ,4002 ,5519 ,-14058 ,2644 ,16667 ,-20397 ,7840 ,9454 ,-21189 , 10302 ,12169 ,-15181 ,-2933 ,20890 ,-17185 ,-6131 ,18286 ,-4951 ,-9397 ,6725 ,10584 ,-19242 ,7953 ,4320 , -11378 ,9111 ,662 ,-118 ,-5581 ,12287 ,-7593 ,-14815 ,26788 ,-15464 ,-4254 ,20567 ,-19583 ,-1758 ,14626 , 237 ,-15222 ,9885 ,3809 ,-14805 ,16398 ,-344 ,-13291 ,2288 ,14329 ,-6689 ,-13367 ,13303 ,1922 ,-6462 , 2811 ,4860 ,-6203 ,-3685 ,5693 ,-712 ,-4239 ,7512 ,2619 ,-16400 ,12244 ,9395 ,-21814 ,11870 ,6802 , -15077 ,9913 ,-3918 ,-603 ,13202 ,-14813 ,-926 ,7114 ,-6403 ,6912 ,188 ,-5018 ,3177 ,2605 ,-4230 , -1829 ,9861 ,-8462 ,-1122 ,3261 ,-5012 ,15967 ,-15999 ,-3421 ,18070 ,-14745 ,-1145 ,16768 ,-9983 ,-12390 , 19854 ,-1726 ,-14044 ,3008 ,13474 ,-10411 ,-1643 ,14371 ,-20857 ,5536 ,14971 ,-10174 ,-9252 ,8978 ,7729 , -10257 ,-4742 ,14390 ,-409 ,-17183 ,7827 ,10707 ,-4770 ,-13120 ,13436 ,3741 ,-14518 ,9485 ,-2533 ,2129 , -3316 ,-3290 ,16847 ,-14332 ,-6961 ,20048 ,-9267 ,-9076 ,13599 ,-4668 ,-4785 ,7224 ,-3444 ,-391 ,1867 , -890 ,-2117 ,-473 ,6115 ,-770 ,-5935 ,4178 ,8336 ,-10854 ,-9345 ,14666 ,283 ,-3657 ,-3797 ,8524 , 6254 ,-25319 ,16922 ,5256 ,-15434 ,4652 ,11610 ,-6728 ,-10874 ,20523 ,-14707 ,-4966 ,15749 ,-1921 ,-13587 , 10446 ,4262 ,-14122 ,10478 ,-946 ,-4481 ,97 ,11006 ,-8460 ,-7979 ,11071 ,3356 ,-8879 ,1740 ,9015 , -16250 ,5491 ,11001 ,-11660 ,2565 ,13172 ,-19794 ,1483 ,18499 ,-22641 ,13414 ,6854 ,-19969 ,9598 ,7607 , -2501 ,-13054 ,14089 ,1451 ,-15067 ,12345 ,-4935 ,5133 ,-2373 ,-4619 ,6034 ,-7315 ,14655 ,-9960 ,-10158 , 22126 ,-10754 ,-8943 ,9148 ,3772 ,-2592 ,-6964 ,10784 ,-330 ,-13431 ,11123 ,-3703 ,-1761 ,4422 ,2158 , 4658 ,-19803 ,9901 ,5263 ,-3499 ,288 ,1002 ,52 ,-5176 ,12602 ,-13552 ,6518 ,-586 ,-7254 ,11204 , -7516 ,-1043 ,8988 ,-562 ,-12086 ,11969 ,-1692 ,-10550 ,7860 ,7606 ,-5445 ,-13030 ,14375 ,-1467 ,-5045 , 15736 ,-15538 ,-7065 ,13604 ,2987 ,-10623 ,521 ,12720 ,-13722 ,-259 ,13964 ,-9607 ,-3779 ,8120 ,-3193 , -2461 ,547 ,9039 ,-7707 ,-4677 ,6049 ,-2839 ,13532 ,-15327 ,-5133 ,18779 ,-8059 ,-8699 ,12000 ,2258 , -14885 ,5237 ,10967 ,-9308 ,-4789 ,6749 ,4005 ,-3592 ,-7780 ,19369 ,-12907 ,-12919 ,26884 ,-15522 ,-5367 , 11210 ,-1472 ,1018 ,-6358 ,6220 ,4176 ,-16345 ,11975 ,4874 ,-17832 ,12349 ,3004 ,-5946 ,818 ,5178 , -4206 ,-4076 ,9569 ,-4358 ,-5113 ,7393 ,6414 ,-17494 ,3749 ,11881 ,-14170 ,12021 ,-3891 ,-9673 ,19962 , -11545 ,-8734 ,11378 ,3439 ,-6701 ,-4142 ,15369 ,-12651 ,-4718 ,18873 ,-15376 ,-3004 ,17836 ,-11813 ,-5905 , 10337 ,3390 ,-11034 ,2472 ,15920 ,-23428 ,4955 ,12527 ,-8198 ,-226 ,1091 ,9625 ,-15992 ,3502 ,8166 , -5061 ,3550 ,-7297 ,8077 ,1861 ,-9770 ,-626 ,4481 ,9047 ,-7687 ,-9286 ,10257 ,6738 ,-12790 ,3317 , 7741 ,-14999 ,11725 ,4437 ,-17903 ,14378 ,4429 ,-14912 ,7250 ,-1320 ,-569 ,2817 ,5326 ,-3804 ,-14771 , 21372 ,-8170 ,-10095 ,13979 ,-1715 ,-4114 ,-3337 ,17062 ,-13180 ,-12575 ,25893 ,-12145 ,-11420 ,21514 ,-7592 , -12370 ,14249 ,2865 ,-14431 ,7894 ,9133 ,-14306 ,459 ,9157 ,-4913 ,-5118 ,13620 ,-8362 ,-8287 ,13824 , -1756 ,-5937 ,192 ,12210 ,-16661 ,7313 ,11920 ,-24859 ,10939 ,7368 ,-3607 ,-9080 ,16109 ,-3808 ,-20713 , 26367 ,-8615 ,-12833 ,16915 ,2517 ,-18841 ,11238 ,10667 ,-23402 ,12935 ,10878 ,-17597 ,-347 ,11407 ,-907 , -9275 ,9119 ,1060 ,-13430 ,7102 ,8962 ,-6938 ,-6698 ,13219 ,-5163 ,-8786 ,12770 ,-8551 ,2106 ,7989 , -14109 ,5746 ,12636 ,-13832 ,-7058 ,19437 ,-7313 ,-10603 ,14632 ,-8425 ,-2378 ,10223 ,255 ,-10302 ,1014 , 9893 ,-9813 ,-33 ,7509 ,-501 ,-6468 ,3357 ,8071 ,-8933 ,-4139 ,1714 ,7875 ,-648 ,-7670 ,9048 , -7560 ,-920 ,8618 ,-7061 ,1169 ,-2269 ,9129 ,-902 ,-12368 ,8730 ,-2380 ,2311 ,5545 ,-9700 ,1218 , 4584 ,-3636 ,1984 ,-4931 ,7895 ,3599 ,-14727 ,3880 ,11339 ,-2841 ,-15988 ,18168 ,830 ,-20391 ,17397 , 4433 ,-15853 ,6149 ,8640 ,-11903 ,2975 ,910 ,3750 ,2511 ,-14766 ,15879 ,-379 ,-16504 ,10984 ,3912 , 1223 ,-9295 ,-1101 ,6626 ,-1886 ,10201 ,-13510 ,-2031 ,12345 ,-9793 ,3583 ,-2960 ,4856 ,4139 ,-9532 , 4762 ,-1980 ,-2997 ,4442 ,9068 ,-14175 ,-1963 ,16407 ,-10033 ,-5523 ,12425 ,-1527 ,-12748 ,11051 ,-4723 , 2613 ,10430 ,-19035 ,2633 ,14427 ,-8867 ,-4583 ,5371 ,2040 ,1867 ,-9012 ,5424 ,-1115 ,-410 ,10424 , -17534 ,6348 ,13365 ,-15041 ,-3706 ,17069 ,-6069 ,-13046 ,17378 ,-6441 ,-8096 ,7997 ,6316 ,-8304 ,-5935 , 17165 ,-8786 ,-10865 ,13122 ,6475 ,-18078 ,8001 ,5335 ,-12378 ,9451 ,2055 ,-5204 ,-1192 ,8468 ,-6500 , -2733 ,3863 ,8871 ,-9986 ,-9183 ,12943 ,-5098 ,9711 ,-11014 ,4341 ,6922 ,-18020 ,13261 ,1062 ,-6977 , 3579 ,2364 ,-3773 ,124 ,-737 ,5717 ,1067 ,-11668 ,11217 ,-411 ,-12315 ,11400 ,5317 ,-13483 ,4523 , 5884 ,-7302 ,548 ,5930 ,-1235 ,-6586 ,6194 ,-829 ,-2129 ,192 ,-1132 ,7966 ,-3616 ,-3673 ,-47 , -919 ,9092 ,-4304 ,-7128 ,7688 ,-1909 ,-1490 ,2734 ,-1778 ,452 ,130 ,806 ,-4068 ,2273 ,11173 , -15778 ,-1092 ,20607 ,-18041 ,-2497 ,11670 ,-4319 ,750 ,4480 ,-5241 ,-11258 ,18998 ,-2795 ,-14386 ,9303 , 4055 ,-867 ,-8883 ,8078 ,8373 ,-19796 ,5906 ,14444 ,-18831 ,10753 ,1687 ,-14048 ,17872 ,-5949 ,-11023 , 18112 ,-7838 ,-10099 ,19135 ,-10668 ,-5780 ,7174 ,-160 ,3082 ,-5633 ,2020 ,5707 ,-7781 ,479 ,9107 , -9352 ,-2679 ,7143 ,-3389 ,-2246 ,13420 ,-9922 ,-8466 ,10085 ,4237 ,-1470 ,-17026 ,20355 ,-961 ,-19681 , 21421 ,-5395 ,-11948 ,13851 ,1774 ,-10711 ,427 ,12709 ,-5404 ,-12928 ,14245 ,653 ,-9990 ,6850 ,-419 , -6916 ,12425 ,-806 ,-15937 ,11036 ,5858 ,-8871 ,1753 ,2248 ,-2509 ,5987 ,-3459 ,-8368 ,6181 ,8125 , -6745 ,-4927 ,5616 ,2396 ,-1827 ,-3841 ,3822 ,-1014 ,-1647 ,7388 ,-10899 ,3653 ,13243 ,-19669 ,4916 , 8337 ,-5252 ,-1119 ,7574 ,-4830 ,-8761 ,19858 ,-15850 ,-5013 ,14806 ,-4002 ,-1688 ,-1418 ,3305 ,1226 , -4780 ,7269 ,-638 ,-16487 ,13839 ,7893 ,-19359 ,12607 ,5485 ,-17881 ,9569 ,2539 ,-1946 ,-1225 ,7807 , -9297 ,-3075 ,19776 ,-23423 ,2289 ,14153 ,-6137 ,-4806 ,3903 ,8574 ,-15849 ,7579 ,5803 ,-15653 ,16015 , -4012 ,-9675 ,7248 ,4806 ,-700 ,-13402 ,14744 ,696 ,-13619 ,6955 ,12082 ,-16282 ,-2638 ,19092 ,-15866 , -927 ,10375 ,-239 ,-11761 ,13894 ,-7122 ,-8731 ,22860 ,-20088 ,573 ,8828 ,4155 ,-10734 ,-4795 ,21024 , -17775 ,-1874 ,16874 ,-11078 ,-7852 ,18295 ,-7258 ,-13119 ,22041 ,-9682 ,-10661 ,13855 ,-1002 ,-4415 ,128 , 5140 ,-6116 ,6799 ,1530 ,-14287 ,12227 ,-2647 ,-4952 ,4504 ,-2180 ,10535 ,-9808 ,-7674 ,16035 ,-9110 , 3698 ,2717 ,-13618 ,14382 ,2985 ,-15128 ,3948 ,13576 ,-16503 ,5668 ,10055 ,-17637 ,7547 ,9541 ,-10111 , -3922 ,15155 ,-13827 ,-704 ,9169 ,-1309 ,1658 ,-12204 ,17097 ,-9123 ,-4806 ,6903 ,-4712 ,7159 ,-6626 , 11979 ,-11477 ,-6568 ,11436 ,4436 ,-7410 ,-8009 ,13668 ,-4631 ,4213 ,-7889 ,-765 ,8884 ,-7990 ,5324 , -6459 ,6442 ,3492 ,-11965 ,14130 ,-7160 ,-7895 ,14290 ,-6019 ,-2976 ,4150 ,-988 ,-830 ,-2328 ,6916 , 519 ,-9793 ,6851 ,-2648 ,1905 ,5603 ,-12412 ,6375 ,6160 ,-8059 ,-1569 ,5201 ,5253 ,-11676 ,1775 , 9787 ,-10981 ,10471 ,-5631 ,-5923 ,5802 ,2750 ,6332 ,-18355 ,8665 ,5846 ,-6110 ,2878 ,-143 ,1444 , -4287 ,4150 ,2378 ,-7604 ,-1332 ,4531 ,2375 ,-2596 ,1339 ,8479 ,-14725 ,701 ,10140 ,-9275 ,3188 , 9064 ,-9908 ,-3245 ,15066 ,-14208 ,-2001 ,15112 ,-6569 ,-4366 ,-564 ,4868 ,5379 ,-14025 ,6303 ,7590 , -10902 ,3474 ,131 ,4339 ,-1876 ,-7694 ,8450 ,2054 ,-12117 ,12617 ,-578 ,-9933 ,4493 ,1050 ,9234 , -16218 ,3817 ,11834 ,-10133 ,-2386 ,10213 ,-2076 ,-11846 ,14160 ,-5219 ,-5609 ,8170 ,-2805 ,-1919 ,3966 , -2901 ,-2577 ,4855 ,907 ,3781 ,-9134 ,-205 ,6688 ,-5263 ,3760 ,-4444 ,4004 ,6064 ,-13297 ,6851 , 3190 ,-5726 ,-1419 ,6466 ,5235 ,-14615 ,1979 ,11003 ,-5265 ,-6061 ,11151 ,-5473 ,-1347 ,6168 ,-11565 , 7951 ,742 ,-3956 ,3659 ,-5170 ,6775 ,-19 ,-9136 ,11089 ,346 ,-12972 ,7958 ,7247 ,-11231 ,-219 , 11042 ,-4744 ,-7216 ,5621 ,-1861 ,5663 ,-757 ,-9078 ,14936 ,-11440 ,-4291 ,15038 ,-9563 ,783 ,-632 , 2689 ,6053 ,-14513 ,5919 ,12866 ,-17201 ,384 ,17425 ,-15214 ,-3631 ,15730 ,-8217 ,-4220 ,4529 ,5293 , -7507 ,528 ,11429 ,-18508 ,3861 ,13622 ,-9127 ,-6661 ,10747 ,3459 ,-14868 ,10350 ,586 ,-9206 ,8094 , 4405 ,-9060 ,335 ,11105 ,-8111 ,-7844 ,11323 ,-140 ,-8545 ,10737 ,-9454 ,3110 ,10124 ,-16376 ,4982 , 11712 ,-10485 ,-4536 ,12885 ,-8355 ,-1080 ,6009 ,-3205 ,-2497 ,1663 ,2023 ,2186 ,-2148 ,-4895 ,15689 , -19380 ,2020 ,19082 ,-20134 ,2938 ,10349 ,-3843 ,-9071 ,15102 ,-4130 ,-16866 ,21073 ,-3247 ,-12346 ,11011 , 62 ,-8650 ,4804 ,8565 ,-8852 ,-7391 ,15024 ,-495 ,-15179 ,9828 ,2802 ,-4929 ,4393 ,-1459 ,-969 , -548 ,5751 ,-9930 ,3765 ,10067 ,-20907 ,14920 ,5409 ,-16645 ,5905 ,10676 ,-7605 ,-8149 ,15437 ,-7945 , -6943 ,9830 ,2132 ,-9782 ,8283 ,5888 ,-21268 ,11736 ,10913 ,-16103 ,1704 ,9497 ,-3957 ,-6736 ,10500 , 3077 ,-17805 ,8361 ,6556 ,-4921 ,184 ,-2029 ,3465 ,-2154 ,1669 ,-1560 ,-1705 ,7133 ,-5300 ,-4659 , 14505 ,-7635 ,-11750 ,16749 ,-2544 ,-9748 ,7231 ,3231 ,-9379 ,5226 ,6118 ,-10568 ,471 ,10829 ,-4989 , -8485 ,15407 ,-10116 ,-7187 ,16003 ,-2398 ,-13175 ,9720 ,8888 ,-18476 ,6647 ,6244 ,1437 ,-11411 ,1007 , 14475 ,-12769 ,-2417 ,8340 ,5339 ,-16274 ,11350 ,1462 ,-12966 ,17945 ,-12757 ,222 ,10109 ,-12456 ,6985 , 5317 ,-10573 ,729 ,6861 ,1268 ,-8876 ,-255 ,11695 ,-5767 ,-4755 ,7371 ,-7804 ,2461 ,10201 ,-11031 , -2845 ,10049 ,336 ,-13481 ,10980 ,6377 ,-15598 ,4546 ,8531 ,-946 ,-12575 ,9091 ,5203 ,-14726 ,9478 , 3093 ,-7279 ,6835 ,231 ,-5720 ,1787 ,-1355 ,2741 ,-269 ,-1652 ,2962 ,-5409 ,7543 ,-778 ,-7803 , 7041 ,-4825 ,7563 ,-1664 ,-10020 ,8061 ,5037 ,-3695 ,-9768 ,13033 ,-1991 ,-8664 ,8900 ,-4356 ,-2332 , 9267 ,-2245 ,-9766 ,10277 ,-3575 ,-2277 ,3873 ,-3363 ,6020 ,-6728 ,-2080 ,11121 ,-1351 ,-13213 ,6350 , 12747 ,-15982 ,1640 ,12616 ,-13635 ,583 ,9822 ,-1807 ,-9558 ,9209 ,3544 ,-13317 ,6700 ,3375 ,-1349 , -5343 ,5058 ,2534 ,-10603 ,11064 ,3299 ,-16240 ,10003 ,7054 ,-13824 ,5864 ,4197 ,-5891 ,1850 ,1847 , -5686 ,9974 ,-5834 ,-6792 ,18924 ,-14458 ,-5028 ,12689 ,-1561 ,-6051 ,1959 ,8566 ,-9779 ,-3783 ,13578 , -2505 ,-14309 ,9367 ,9798 ,-10696 ,-4978 ,7868 ,4054 ,-7390 ,2907 ,1913 ,-7783 ,3497 ,9712 ,-9265 , -3286 ,11438 ,-7977 ,-2397 ,3492 ,8024 ,-10042 ,-3831 ,15890 ,-12322 ,-1164 ,12358 ,-5676 ,-10645 ,12067 , -1826 ,-4120 ,2490 ,-878 ,7358 ,-9161 ,-663 ,2744 ,8463 ,-8785 ,-7018 ,16867 ,-7269 ,-7512 ,5829 , 1271 ,61 ,881 ,-1707 ,1662 ,-4517 ,11706 ,-6288 ,-15479 ,16566 ,3182 ,-9979 ,-4 ,12387 ,-11505 , -1510 ,9913 ,-9404 ,2528 ,2323 ,4555 ,-3221 ,-6525 ,5978 ,-2442 ,782 ,-3026 ,9214 ,-102 ,-15507 , 11011 ,2158 ,2409 ,-7754 ,-789 ,6890 ,-4950 ,1099 ,-1985 ,7904 ,-2831 ,-5127 ,2917 ,-2562 ,1680 , 6274 ,-6884 ,321 ,2321 ,1966 ,4968 ,-16333 ,4247 ,13628 ,-8711 ,-5864 ,8276 ,-2948 ,6199 ,-2551 , -13667 ,16131 ,324 ,-11116 ,2676 ,12276 ,-11273 ,-1800 ,9527 ,-8555 ,1815 ,1110 ,9927 ,-15097 ,3018 , 10572 ,-14229 ,5354 ,3855 ,-980 ,-4833 ,13054 ,-14322 ,415 ,15459 ,-20373 ,7784 ,9105 ,-9713 ,-1558 , 8870 ,-6322 ,-119 ,3810 ,-3029 ,-2968 ,6204 ,6196 ,-16248 ,4062 ,10827 ,-7878 ,-4055 ,15199 ,-14270 , -4720 ,21299 ,-16475 ,-3032 ,13909 ,-1728 ,-14480 ,10633 ,8284 ,-15933 ,3068 ,11727 ,-5258 ,-14008 ,18801 , -3664 ,-14037 ,14427 ,747 ,-8928 ,1624 ,12255 ,-14345 ,1547 ,5027 ,-2763 ,3950 ,-8832 ,6849 ,-139 , 5528 ,-8031 ,-6384 ,15114 ,-6804 ,-3488 ,4852 ,849 ,-7600 ,8925 ,877 ,-12345 ,9689 ,675 ,-1734 , -2053 ,7792 ,-3529 ,-14102 ,21553 ,-5326 ,-15151 ,11957 ,3558 ,-5909 ,-1506 ,13181 ,-13388 ,-6616 ,19550 , -8392 ,-8554 ,7840 ,7447 ,-11864 ,2228 ,9829 ,-16408 ,9281 ,8882 ,-15430 ,1562 ,13768 ,-9623 ,-4005 , 8326 ,-8131 ,7480 ,2406 ,-10122 ,1432 ,12151 ,-9093 ,-7609 ,17783 ,-10997 ,-5499 ,13715 ,-1935 ,-12208 , 8440 ,9632 ,-16038 ,358 ,12026 ,-1346 ,-12888 ,8048 ,10376 ,-17562 ,6197 ,8023 ,-10581 ,3092 ,3331 , -6755 ,5764 ,7876 ,-15931 ,3133 ,8465 ,-5786 ,2520 ,-972 ,1643 ,-2009 ,-570 ,10691 ,-13875 ,-5886 , 19981 ,-9459 ,-5005 ,8375 ,-5053 ,-1636 ,10893 ,-7432 ,-7480 ,16627 ,-11158 ,-5079 ,12618 ,-5039 ,354 , 4816 ,-9844 ,1413 ,7483 ,-6021 ,1374 ,2031 ,-1875 ,405 ,-2072 ,1327 ,6888 ,-6765 ,-4395 ,12590 , -5629 ,-8872 ,14302 ,-6485 ,-4873 ,7664 ,-3244 ,-2023 ,2022 ,10116 ,-16065 ,5473 ,4928 ,-11033 ,18313 , -15294 ,505 ,8995 ,-10798 ,10604 ,-5755 ,-4211 ,11937 ,-5444 ,-6702 ,8649 ,-3377 ,-751 ,2459 ,-4258 , 2902 ,1122 ,742 ,-3636 ,10087 ,-8460 ,-7654 ,15139 ,-10919 ,1701 ,8765 ,-7621 ,-1617 ,5607 ,-2607 , -1500 ,353 ,621 ,8281 ,-6590 ,-9030 ,10517 ,3536 ,-10492 ,1661 ,9345 ,-4250 ,-8644 ,13515 ,-5018 , -9005 ,13024 ,-5539 ,-4412 ,5383 ,6975 ,-11971 ,-751 ,14954 ,-13126 ,490 ,6472 ,-4477 ,929 ,893 , -123 ,-1161 ,2170 ,-3883 ,4076 ,3516 ,-11592 ,6773 ,8563 ,-14671 ,2171 ,13589 ,-11345 ,-4940 ,11419 , 1812 ,-13790 ,8526 ,6420 ,-12988 ,6507 ,2419 ,-5182 ,-1239 ,11245 ,-7452 ,-8044 ,13068 ,-3745 ,-3029 , 2517 ,2469 ,-3971 ,-1085 ,5302 ,-4366 ,5969 ,932 ,-16800 ,11469 ,8732 ,-16007 ,10290 ,3414 ,-15144 , 10961 ,3929 ,-9470 ,413 ,4955 ,2834 ,-7080 ,4629 ,1671 ,-8191 ,5986 ,375 ,-3280 ,262 ,4229 , 3132 ,-13604 ,12650 ,1789 ,-15866 ,10518 ,1114 ,4064 ,-9148 ,-97 ,5744 ,-4377 ,7223 ,-9270 ,1791 , 4547 ,-1452 ,3276 ,-6112 ,4003 ,2253 ,-7960 ,3377 ,3306 ,-3382 ,1662 ,33 ,-3349 ,7679 ,-2958 , -7469 ,6570 ,522 ,-384 ,-157 ,79 ,930 ,-1603 ,837 ,1764 ,-2255 ,515 ,2223 ,-5802 ,1882 , 3890 ,-3343 ,1463 ,-3515 ,5306 ,-1931 ,523 ,9236 ,-20508 ,13366 ,5052 ,-17682 ,15086 ,-3121 ,-1476 , 3813 ,-9227 ,4963 ,8732 ,-8919 ,-2615 ,3521 ,2030 ,3093 ,-10263 ,4307 ,10152 ,-11564 ,-513 ,8819 , -7006 ,-475 ,6281 ,-6923 ,2348 ,7274 ,-10572 ,3376 ,3150 ,-7099 ,7219 ,1069 ,-1301 ,-5266 ,1266 , 7085 ,-9324 ,3016 ,3672 ,-689 ,907 ,-4728 ,6412 ,-2849 ,-5799 ,6300 ,-2977 ,-35 ,8679 ,-11348 , 3991 ,9631 ,-18601 ,7896 ,4354 ,-1989 ,-1405 ,-409 ,12544 ,-21770 ,9376 ,9317 ,-18116 ,11361 ,309 , -279 ,-458 ,-2488 ,7178 ,-7492 ,-1489 ,5814 ,-5334 ,6201 ,80 ,-9636 ,6235 ,9746 ,-16465 ,6788 , 8502 ,-18467 ,12337 ,312 ,-2200 ,-2883 ,10083 ,-4310 ,-16623 ,24682 ,-10732 ,-9108 ,13856 ,-1706 ,-6481 , 2289 ,8539 ,-10423 ,-2206 ,13627 ,-8200 ,-9031 ,14495 ,121 ,-13648 ,8791 ,7808 ,-12801 ,804 ,8141 , -4359 ,2230 ,370 ,-7694 ,4617 ,2875 ,-1404 ,1041 ,-1209 ,2688 ,-4387 ,-2053 ,9145 ,-6863 ,-3455 , 10820 ,-9230 ,5884 ,4077 ,-15767 ,10608 ,3778 ,-4974 ,-3026 ,6504 ,3413 ,-14890 ,12749 ,-80 ,-11959 , 8620 ,5329 ,-6212 ,-4906 ,13318 ,-8284 ,-4723 ,9332 ,-5547 ,-1285 ,4922 ,5212 ,-14399 ,7177 ,10945 , -20975 ,11942 ,6043 ,-14797 ,6321 ,7709 ,-7646 ,-3864 ,15044 ,-11297 ,-7954 ,18326 ,-8031 ,-7748 ,14880 , -4411 ,-13560 ,17200 ,-3114 ,-11871 ,17626 ,-9516 ,-6693 ,9718 ,3606 ,-7117 ,-5394 ,13382 ,-6670 ,-6320 , 10936 ,1 ,-13417 ,12832 ,3721 ,-16284 ,8159 ,5151 ,-3946 ,-3584 ,12263 ,-11771 ,-5534 ,19729 ,-13244 , -3067 ,9990 ,-5603 ,-2272 ,10101 ,-6460 ,-6640 ,7530 ,5262 ,-7908 ,-3082 ,14015 ,-12012 ,385 ,5004 , -894 ,-1254 ,-2265 ,6994 ,-7408 ,5069 ,-3017 ,4144 ,154 ,-8689 ,5323 ,3941 ,456 ,-8754 ,3050 , 6042 ,410 ,-9753 ,4861 ,6435 ,-8199 ,-766 ,7127 ,527 ,-9556 ,3504 ,8526 ,-4000 ,-8728 ,6025 , 3595 ,-1374 ,-3914 ,4249 ,3294 ,-9172 ,5047 ,150 ,-4907 ,4791 ,917 ,-1295 ,4082 ,-3324 ,-3807 , 4473 ,-2553 ,1799 ,5 ,-2955 ,8424 ,-7740 ,-1076 ,2811 ,4017 ,1774 ,-15163 ,14961 ,-736 ,-13133 , 11971 ,2923 ,-10396 ,3116 ,6691 ,-8527 ,3333 ,2630 ,-3864 ,1966 ,-121 ,-417 ,2421 ,-5761 ,5087 , 4512 ,-12587 ,6105 ,5393 ,-6078 ,-868 ,7882 ,-4953 ,-5126 ,11247 ,-6581 ,-4296 ,4570 ,4297 ,-3608 , -5400 ,5661 ,5133 ,-4239 ,-7087 ,8517 ,-2382 ,-1134 ,2112 ,-1314 ,652 ,-3471 ,7961 ,-2990 ,-6612 , 3919 ,8221 ,-7860 ,-5900 ,11412 ,-2879 ,-3095 ,1844 ,3655 ,-4871 ,-1168 ,9352 ,-9978 ,-571 ,13569 , -15312 ,373 ,14854 ,-14739 ,3376 ,3113 ,2089 ,2013 ,-10838 ,8047 ,-4733 ,986 ,7253 ,-6480 ,-1632 , 7494 ,-1817 ,-9043 ,11560 ,-6089 ,-1651 ,4193 ,-4128 ,6833 ,-7525 ,8696 ,-4262 ,-5898 ,6762 ,-2609 , 6099 ,-8788 ,3319 ,612 ,3972 ,-2107 ,-8327 ,8121 ,696 ,-201 ,-4827 ,11418 ,-8589 ,-8564 ,13935 , -8 ,-8513 ,885 ,9579 ,-8571 ,2629 ,558 ,-5518 ,11046 ,-4211 ,-6333 ,3348 ,2029 ,4457 ,-7372 , 439 ,3791 ,-6166 ,5017 ,898 ,-1376 ,-615 ,1601 ,-248 ,-1636 ,3817 ,-5246 ,2267 ,3578 ,-6916 , 4138 ,5510 ,-6896 ,-2291 ,2815 ,911 ,124 ,-3010 ,6031 ,-1623 ,-6885 ,9418 ,-4577 ,-4276 ,12230 , -9492 ,-4227 ,15754 ,-10273 ,-7169 ,15531 ,-4986 ,-7100 ,4833 ,1859 ,-2566 ,-3077 ,11376 ,-7813 ,-7547 , 15061 ,-6067 ,-5526 ,3897 ,4763 ,-1717 ,-7252 ,7560 ,-2733 ,300 ,1238 ,-6060 ,12866 ,-7384 ,-7082 , 8119 ,2135 ,593 ,-10608 ,8163 ,1765 ,-9813 ,10515 ,1180 ,-11196 ,5067 ,9377 ,-11755 ,1189 ,7416 , -6371 ,285 ,4264 ,-4028 ,-1554 ,4660 ,-201 ,-707 ,-3966 ,12393 ,-8506 ,-11835 ,16606 ,-3786 ,-3098 , 1850 ,2754 ,-3012 ,-2272 ,7545 ,-4507 ,-4385 ,9518 ,-3761 ,-10128 ,12359 ,1352 ,-11122 ,8191 ,1050 , -9711 ,12410 ,-1933 ,-10910 ,8491 ,4784 ,-10121 ,4639 ,9426 ,-18631 ,8258 ,9048 ,-15761 ,6875 ,9646 , -12780 ,-1224 ,11012 ,-4538 ,-5061 ,6182 ,3204 ,-10815 ,7230 ,5145 ,-14686 ,6766 ,9971 ,-11923 ,-1018 , 7857 ,-3138 ,449 ,755 ,-1037 ,1802 ,-2548 ,2614 ,-1494 ,-2216 ,12000 ,-13951 ,-3217 ,14744 ,-9904 , 1414 ,3954 ,-4836 ,5608 ,-2647 ,-3953 ,2865 ,1762 ,1148 ,-4209 ,7962 ,-6622 ,-4935 ,14876 ,-10258 , -3866 ,9233 ,-4743 ,3 ,-1472 ,5954 ,2781 ,-15009 ,10452 ,5890 ,-13003 ,1970 ,12746 ,-10444 ,-4427 , 15087 ,-12012 ,-1892 ,10239 ,-4268 ,-1876 ,834 ,2845 ,-803 ,-5103 ,12574 ,-9503 ,-7904 ,14460 ,-8836 , 848 ,9716 ,-6622 ,-8868 ,13514 ,-761 ,-10875 ,9928 ,-4650 ,-1153 ,8074 ,-5131 ,-1207 ,1945 ,-2190 , 2277 ,-434 ,-462 ,-479 ,-2241 ,10537 ,-7288 ,-8008 ,14477 ,-2981 ,-9747 ,5140 ,9306 ,-9457 ,-4942 , 10275 ,220 ,-7130 ,3935 ,540 ,665 ,3980 ,-11357 ,3774 ,4145 ,1851 ,-1551 ,-5748 ,2361 ,4962 , 377 ,-10381 ,10198 ,2055 ,-12824 ,9225 ,1676 ,-6295 ,9382 ,-7236 ,-3889 ,10163 ,-7489 ,3214 ,3198 , -6849 ,3308 ,2144 ,-4245 ,-304 ,4974 ,-1001 ,-2141 ,-154 ,7077 ,-3402 ,-12804 ,13675 ,2066 ,-10231 , 4175 ,3568 ,-6508 ,4132 ,7195 ,-12776 ,1798 ,6064 ,1326 ,-7429 ,3172 ,7367 ,-11658 ,3474 ,3823 , -5756 ,3287 ,6493 ,-8788 ,-92 ,3017 ,3422 ,600 ,-12844 ,8250 ,8082 ,-10271 ,-2427 ,7410 ,3190 , -5324 ,-7851 ,14103 ,-3296 ,-11610 ,17024 ,-8385 ,-6545 ,12107 ,-1912 ,-6272 ,642 ,8718 ,-6181 ,-3442 , 9081 ,-6283 ,-1883 ,5180 ,-4705 ,2744 ,6803 ,-9496 ,324 ,548 ,6170 ,722 ,-13080 ,9815 ,1117 , 1145 ,-5802 ,2763 ,4095 ,-9257 ,7141 ,-2382 ,-2122 ,6451 ,965 ,-9795 ,3337 ,2956 ,2029 ,-3526 , -809 ,11073 ,-18455 ,9082 ,3839 ,-6201 ,12604 ,-17393 ,4432 ,9172 ,-8363 ,841 ,4342 ,-2718 ,-4339 , 10472 ,-5249 ,-6775 ,7743 ,2406 ,-5279 ,-975 ,4477 ,526 ,1268 ,-8084 ,1263 ,3417 ,590 ,6286 , -13567 ,4810 ,11319 ,-15281 ,1520 ,12958 ,-9890 ,-4018 ,11211 ,-5667 ,-4035 ,3717 ,6197 ,-5421 ,-7896 , 15019 ,-4834 ,-8454 ,6909 ,2042 ,795 ,-10444 ,8150 ,5217 ,-13327 ,6285 ,5580 ,-2690 ,-5880 ,4422 , -1718 ,727 ,6353 ,-10844 ,6358 ,-1423 ,-1434 ,7503 ,-8539 ,-1284 ,7895 ,200 ,-6888 ,3875 ,-2988 , 3062 ,4186 ,-8076 ,2261 ,-44 ,1762 ,987 ,-1661 ,153 ,4038 ,-4101 ,-4769 ,11083 ,-4556 ,-7829 , 12309 ,-3756 ,-8259 ,9245 ,-3491 ,-2275 ,6748 ,266 ,-8538 ,2883 ,8879 ,-8631 ,-4469 ,11331 ,-1756 , -9679 ,9764 ,-5234 ,2339 ,6369 ,-13122 ,4764 ,9323 ,-8706 ,-3088 ,9785 ,-5103 ,-5093 ,7547 ,4289 , -12139 ,2966 ,6792 ,-4329 ,422 ,1143 ,4315 ,-11730 ,7627 ,5565 ,-10891 ,6587 ,-3273 ,-741 ,3941 , -12 ,-3314 ,-1514 ,8883 ,-5077 ,-6573 ,9828 ,97 ,-8239 ,5677 ,1101 ,-6910 ,6892 ,4671 ,-12064 , 2417 ,12164 ,-14538 ,6197 ,7399 ,-15800 ,6960 ,5562 ,-3144 ,-5668 ,9477 ,675 ,-16059 ,14389 ,2576 , -12923 ,8147 ,2693 ,-6997 ,-279 ,9123 ,-3036 ,-9425 ,8895 ,2388 ,-8183 ,4147 ,8517 ,-14366 ,613 , 15717 ,-13873 ,-790 ,11308 ,-9367 ,-1457 ,7581 ,-1870 ,-2418 ,2224 ,3604 ,-7166 ,108 ,4395 ,-6198 , 9998 ,-1877 ,-10869 ,7155 ,5372 ,-6942 ,-163 ,10052 ,-12587 ,-1686 ,14683 ,-10684 ,-1019 ,11771 ,-11037 , -4034 ,12699 ,-2265 ,-11035 ,11515 ,1749 ,-13986 ,9749 ,2388 ,-4072 ,-731 ,2170 ,7837 ,-13591 ,-811 , 15692 ,-11830 ,-2517 ,10943 ,-6682 ,-1483 ,5064 ,-4673 ,344 ,7281 ,-4145 ,-5118 ,6315 ,-4921 ,2353 , 7478 ,-12609 ,7258 ,2622 ,-11273 ,9535 ,3439 ,-8481 ,4430 ,-1663 ,-1419 ,5788 ,-8396 ,7866 ,-617 , -9050 ,8775 ,3151 ,-8442 ,-1876 ,13213 ,-9405 ,-3345 ,10750 ,-7327 ,-3438 ,10345 ,-960 ,-11791 ,11196 , -252 ,-8093 ,5860 ,2762 ,-2857 ,-6081 ,8951 ,2104 ,-10460 ,5556 ,3814 ,-8067 ,5116 ,538 ,-3013 , 2492 ,-802 ,105 ,-3520 ,7811 ,-3121 ,-3288 ,6881 ,-8972 ,2809 ,7987 ,-7510 ,-1727 ,6594 ,-3722 , -1885 ,1661 ,4565 ,-1581 ,-7391 ,11383 ,-6959 ,-4899 ,12910 ,-8413 ,2234 ,-1175 ,-1255 ,3732 ,-1940 , 5563 ,-9071 ,1772 ,3157 ,1574 ,-662 ,-7404 ,8985 ,-1649 ,-4248 ,4515 ,-2658 ,-1463 ,5277 ,-3193 , 3122 ,1950 ,-9758 ,5258 ,1638 ,-1656 ,-1504 ,4190 ,1698 ,-10700 ,11210 ,-990 ,-8725 ,6095 ,1857 , 1402 ,-4036 ,-3083 ,4551 ,3909 ,-7018 ,1594 ,744 ,-390 ,7106 ,-8650 ,382 ,4534 ,-3716 ,-1332 , 6264 ,1669 ,-13133 ,9417 ,5519 ,-13287 ,7260 ,5395 ,-8411 ,1060 ,2876 ,-5010 ,8398 ,-916 ,-10457 , 8692 ,2289 ,-5454 ,-2471 ,7730 ,717 ,-9593 ,7121 ,171 ,-4574 ,5477 ,-4042 ,1798 ,953 ,-1936 , 368 ,-1379 ,8250 ,-10827 ,3052 ,7748 ,-11670 ,3904 ,8101 ,-7000 ,-4649 ,11812 ,-6274 ,-5561 ,6071 , 4616 ,-7087 ,990 ,4848 ,-8357 ,3751 ,2648 ,1240 ,-5242 ,2830 ,1535 ,-6692 ,5874 ,3635 ,-8514 , 813 ,9069 ,-6943 ,-2514 ,2146 ,7014 ,-5155 ,-7919 ,13545 ,-3829 ,-6183 ,3506 ,2688 ,338 ,-6016 , 3675 ,4061 ,-5875 ,977 ,3260 ,-3321 ,1731 ,-2161 ,4154 ,104 ,-7590 ,8448 ,-1472 ,-4706 ,1168 , 6479 ,-3034 ,-4466 ,7380 ,-8295 ,1698 ,10190 ,-9443 ,-4007 ,12990 ,-7059 ,-4070 ,4881 ,-2100 ,9311 , -11665 ,-792 ,12438 ,-11662 ,4564 ,5291 ,-11969 ,6845 ,4642 ,-8472 ,3880 ,-690 ,1841 ,964 ,-7401 , 5975 ,3310 ,-7933 ,6633 ,4334 ,-15895 ,9529 ,6575 ,-13041 ,7217 ,1677 ,-5721 ,1659 ,5038 ,-4826 , 2701 ,5776 ,-15979 ,11609 ,2840 ,-12311 ,7774 ,-531 ,2012 ,-2725 ,2072 ,1431 ,-5845 ,3918 ,4165 , -8176 ,3099 ,7407 ,-12373 ,2049 ,7154 ,895 ,-9494 ,6496 ,2550 ,-10728 ,14792 ,-7242 ,-6750 ,9566 , 2239 ,-10188 ,3701 ,10203 ,-16606 ,10145 ,4138 ,-14295 ,10470 ,4025 ,-10347 ,408 ,11912 ,-7280 ,-7545 , 9230 ,3814 ,-9966 ,1879 ,9972 ,-14188 ,7112 ,5850 ,-13416 ,7065 ,2087 ,-1310 ,-1291 ,2178 ,485 , -6465 ,12242 ,-5308 ,-12629 ,13876 ,3030 ,-11918 ,2852 ,10694 ,-9234 ,-2902 ,6325 ,3002 ,-4886 ,-4154 , 7782 ,-4647 ,2760 ,859 ,-8452 ,11548 ,-1071 ,-11176 ,8621 ,2112 ,-4105 ,-795 ,7196 ,-3480 ,-10320 , 14632 ,-1978 ,-11014 ,10121 ,-455 ,-6398 ,6243 ,-1287 ,-1998 ,2112 ,-219 ,-1580 ,-1668 ,9788 ,-6692 , -7034 ,11114 ,1376 ,-9825 ,1290 ,13299 ,-14380 ,-459 ,13549 ,-10004 ,-3592 ,9198 ,-70 ,-9593 ,12523 , -6046 ,-6625 ,9232 ,-2398 ,-2395 ,5154 ,1109 ,-13205 ,14456 ,-1583 ,-11349 ,9153 ,4391 ,-8573 ,-378 , 9431 ,-8973 ,1776 ,3570 ,-3090 ,-2956 ,8863 ,-2004 ,-10136 ,8187 ,3988 ,-8327 ,3445 ,7555 ,-14759 , 4776 ,10467 ,-10266 ,-2687 ,10699 ,-2238 ,-10118 ,6861 ,7090 ,-12616 ,6924 ,4131 ,-12840 ,14023 ,-5582 , -5517 ,6238 ,1044 ,-590 ,-4089 ,6113 ,-4166 ,-2049 ,5519 ,-6458 ,6762 ,1826 ,-11441 ,7449 ,122 , 5492 ,-7081 ,-5748 ,14849 ,-9211 ,-1904 ,6618 ,-2788 ,-2356 ,4036 ,-1842 ,-1739 ,491 ,4122 ,2121 , -10499 ,8928 ,-3724 ,-2704 ,11538 ,-10690 ,856 ,3411 ,-1107 ,-1807 ,1330 ,5346 ,-8032 ,3620 ,906 , -2172 ,2913 ,-4317 ,3850 ,1063 ,-4286 ,2632 ,-2347 ,1585 ,6017 ,-7386 ,-2930 ,10568 ,-1737 ,-9740 , 6377 ,-561 ,836 ,1651 ,-4417 ,966 ,2039 ,3167 ,-7290 ,3459 ,1605 ,-5510 ,8376 ,-2476 ,-5504 , 5110 ,-574 ,-1210 ,-270 ,-554 ,3035 ,268 ,-2556 ,749 ,2673 ,-2658 ,-1515 ,5881 ,-3564 ,-3310 , 3992 ,-1669 ,7146 ,-7680 ,-3567 ,6924 ,-2922 ,6856 ,-6726 ,-699 ,4688 ,-4121 ,2186 ,106 ,-2657 , 1376 ,6721 ,-5130 ,-6525 ,7059 ,2629 ,-4384 ,-1738 ,2276 ,3661 ,-3976 ,-2505 ,3139 ,5348 ,-5461 , -5572 ,10672 ,-3465 ,-4728 ,3227 ,4559 ,-5142 ,-4433 ,12563 ,-7099 ,-6108 ,9288 ,-430 ,-6941 ,8011 , 1885 ,-15168 ,12852 ,2224 ,-11342 ,7333 ,1888 ,-5682 ,391 ,8638 ,-7720 ,-1466 ,2758 ,952 ,5758 , -10954 ,696 ,9280 ,-2615 ,-6258 ,1364 ,5969 ,-3343 ,-4579 ,7252 ,2241 ,-11070 ,4920 ,8837 ,-12714 , 3043 ,5836 ,-4740 ,1412 ,977 ,5124 ,-9765 ,475 ,6057 ,-5845 ,2627 ,6003 ,-6715 ,-2369 ,10152 , -8354 ,-1780 ,4288 ,3988 ,-2012 ,-10191 ,10238 ,3695 ,-10284 ,1230 ,9831 ,-6313 ,-6670 ,13998 ,-9321 , -1626 ,11064 ,-11511 ,3174 ,651 ,3407 ,2233 ,-13361 ,11813 ,1504 ,-11470 ,11444 ,-6374 ,1165 ,5148 , -9895 ,5167 ,4266 ,-2688 ,-6244 ,10683 ,-4504 ,-7323 ,14561 ,-10844 ,-1475 ,11479 ,-7958 ,-2159 ,2907 , 4190 ,-1971 ,-5855 ,7800 ,-3831 ,-2006 ,4840 ,-3468 ,-717 ,2030 ,2993 ,-4043 ,135 ,2459 ,-1162 , 3147 ,-5162 ,3427 ,420 ,-9012 ,12304 ,-5725 ,15 ,8459 ,-14028 ,4778 ,3723 ,1814 ,-2574 ,-6132 , 8397 ,-3567 ,-57 ,832 ,-2999 ,8474 ,-4844 ,-5384 ,4370 ,3659 ,-2830 ,-49 ,3608 ,-7747 ,1515 , 5914 ,-1884 ,-4699 ,9812 ,-5949 ,-7975 ,14608 ,-6945 ,-2693 ,4803 ,-71 ,-4651 ,3396 ,4497 ,-8904 , 2243 ,4662 ,2094 ,-9302 ,1741 ,7674 ,-6727 ,6446 ,-3744 ,-7072 ,9938 ,-34 ,-9363 ,8481 ,3512 , -12541 ,7142 ,2620 ,-4007 ,1520 ,1956 ,-1358 ,-3561 ,9345 ,-6159 ,-7981 ,10522 ,2908 ,-9718 ,4596 , 2862 ,-7522 ,4821 ,2492 ,-1524 ,-4888 ,9398 ,-1662 ,-13732 ,14481 ,1575 ,-12769 ,6744 ,3566 ,-3260 , -1212 ,3194 ,962 ,-6809 ,10055 ,-3276 ,-11431 ,11580 ,3024 ,-10941 ,5805 ,4158 ,-7822 ,4473 ,2441 , -1067 ,-6110 ,3404 ,2208 ,-4212 ,7072 ,-4320 ,-4515 ,9244 ,-4352 ,-3862 ,9782 ,-7984 ,-2219 ,8304 , 40 ,-9572 ,4944 ,8209 ,-11509 ,1251 ,8310 ,-1810 ,-10890 ,9734 ,3628 ,-11225 ,3403 ,9082 ,-7052 , -5683 ,14325 ,-11299 ,-1844 ,10857 ,-4928 ,-5272 ,7282 ,2452 ,-11191 ,7121 ,1925 ,-7660 ,6146 ,-1221 , 2420 ,3911 ,-14888 ,10449 ,2832 ,-8944 ,2872 ,3893 ,2673 ,-9847 ,2120 ,7981 ,-2191 ,-9705 ,10328 , -137 ,-10879 ,12166 ,-145 ,-10342 ,6057 ,7782 ,-13402 ,3609 ,9388 ,-9750 ,-1611 ,9556 ,-3157 ,-6916 , 11343 ,-9462 ,-391 ,7500 ,-5086 ,6314 ,-8857 ,5612 ,2769 ,-10999 ,9044 ,1598 ,-6308 ,2327 ,3007 , -5487 ,3634 ,4595 ,-7975 ,1205 ,1671 ,1782 ,1129 ,-5343 ,5470 ,-1143 ,-4997 ,4749 ,-108 ,-3963 , 7102 ,-2699 ,-6741 ,12089 ,-9171 ,-677 ,11125 ,-10147 ,-1782 ,8327 ,57 ,-9512 ,7572 ,1681 ,-7505 , 3320 ,4159 ,-410 ,-8189 ,9668 ,-1430 ,-7821 ,7907 ,-2636 ,-2141 ,2404 ,5326 ,-8257 ,289 ,10875 , -12491 ,134 ,10529 ,-6063 ,-5763 ,9952 ,-766 ,-10689 ,10543 ,1040 ,-8786 ,5449 ,-1756 ,250 ,8209 , -11336 ,-558 ,12426 ,-10106 ,-1290 ,7949 ,-5205 ,-2776 ,7967 ,-1515 ,-5745 ,2126 ,646 ,5310 ,-7154 , -2014 ,9287 ,-7307 ,4668 ,3056 ,-10027 ,1455 ,6067 ,1436 ,-7534 ,3368 ,3772 ,-6386 ,3973 ,304 , -2146 ,1447 ,-3413 ,7698 ,-1752 ,-9583 ,8988 ,-429 ,906 ,-1456 ,-3324 ,3910 ,-4421 ,6567 ,-1193 , -5474 ,4731 ,-548 ,-578 ,-2181 ,3980 ,2608 ,-7613 ,2920 ,3024 ,-6403 ,7704 ,-1303 ,-6360 ,3757 , 525 ,6228 ,-9131 ,-2319 ,12056 ,-5662 ,-6635 ,8173 ,3701 ,-12329 ,5450 ,7680 ,-10732 ,1831 ,3582 , 1470 ,-3909 ,950 ,7817 ,-12957 ,1796 ,11006 ,-6357 ,-5190 ,4572 ,1304 ,136 ,1102 ,-4217 ,5331 , -3008 ,-3779 ,6082 ,-4109 ,2425 ,3372 ,-7457 ,4320 ,197 ,-4006 ,8105 ,-7412 ,3701 ,3296 ,-9722 , 7956 ,-971 ,-5280 ,5978 ,3196 ,-8005 ,1696 ,148 ,5386 ,-1168 ,-10448 ,13237 ,-3945 ,-6746 ,6984 , 3395 ,-8347 ,3356 ,5908 ,-12379 ,6750 ,6820 ,-9409 ,-1753 ,10426 ,-3551 ,-8471 ,8354 ,4028 ,-9421 , -839 ,11481 ,-7574 ,-4337 ,12775 ,-9097 ,-4178 ,12060 ,-5939 ,-4155 ,7033 ,-2552 ,-2068 ,3148 ,-1306 , -2682 ,4016 ,2147 ,-5417 ,803 ,3629 ,-772 ,-3132 ,3551 ,1599 ,-7007 ,2826 ,1427 ,-2600 ,9623 , -10664 ,523 ,11816 ,-15069 ,6235 ,462 ,4268 ,-1750 ,-10903 ,14465 ,-6029 ,-4871 ,8240 ,1166 ,-10088 , 7035 ,5170 ,-13783 ,7930 ,5159 ,-7254 ,-1083 ,5234 ,-1495 ,-4047 ,6353 ,-261 ,-5895 ,4152 ,266 , -1792 ,1592 ,-399 ,-259 ,345 ,445 ,-2181 ,761 ,2746 ,-226 ,-4224 ,7506 ,-3408 ,-8360 ,15131 , -6513 ,-9720 ,12417 ,521 ,-10143 ,6554 ,5823 ,-12661 ,4903 ,8315 ,-9192 ,-1750 ,6074 ,1599 ,-6710 , 6631 ,587 ,-11988 ,11256 ,2831 ,-10521 ,3708 ,7106 ,-7483 ,-1841 ,10663 ,-7053 ,-4563 ,8897 ,-6455 , 1692 ,7676 ,-11793 ,3319 ,4494 ,-2304 ,-1122 ,2326 ,6002 ,-14151 ,3725 ,11533 ,-10635 ,-2725 ,11681 , -5315 ,-7218 ,9453 ,-216 ,-5301 ,1801 ,6475 ,-8398 ,1808 ,6582 ,-11016 ,4085 ,8368 ,-8163 ,-3164 , 7694 ,-2101 ,1571 ,-2837 ,-2907 ,11665 ,-9142 ,-3651 ,7324 ,-3155 ,2909 ,-1611 ,-1975 ,2757 ,-530 , -2998 ,6451 ,-2745 ,-4882 ,7097 ,-5052 ,368 ,6713 ,-3333 ,-5828 ,4660 ,1381 ,-4685 ,5697 ,-251 , -4871 ,2910 ,985 ,-2054 ,-856 ,3070 ,1209 ,-2847 ,-1794 ,8435 ,-3758 ,-10789 ,14016 ,-2414 ,-8116 , 8424 ,-1213 ,-5261 ,5231 ,3344 ,-9585 ,4097 ,3379 ,-3565 ,6563 ,-6272 ,-2778 ,3109 ,3207 ,473 , -8381 ,5779 ,5400 ,-8290 ,-103 ,9122 ,-8821 ,366 ,5334 ,-4423 ,1847 ,-7 ,-2008 ,1243 ,7655 , -12305 ,3524 ,8232 ,-11526 ,3545 ,6807 ,-4855 ,-5292 ,10574 ,-4621 ,-5213 ,4060 ,3789 ,-754 ,-8393 , 6661 ,2718 ,-6814 ,6851 ,930 ,-11624 ,8877 ,1569 ,-7017 ,3024 ,4798 ,-1503 ,-9475 ,10309 ,1940 , -10433 ,4313 ,4044 ,1660 ,-7255 ,591 ,4456 ,-4502 ,6304 ,-2269 ,-4922 ,5106 ,-1449 ,-263 ,637 , 59 ,-764 ,-1183 ,6241 ,-7253 ,848 ,9497 ,-11426 ,708 ,10156 ,-8632 ,-2509 ,11532 ,-7375 ,-4310 , 9347 ,-2755 ,-7460 ,9408 ,-26 ,-8818 ,6615 ,617 ,1665 ,-5249 ,2461 ,2697 ,-6375 ,5489 ,-2253 , -1940 ,6547 ,-1441 ,-7844 ,6745 ,3270 ,-8063 ,4349 ,-804 ,-2430 ,8750 ,-6070 ,-4721 ,5679 ,1720 , -1121 ,-3408 ,2820 ,-221 ,-3130 ,6561 ,-2746 ,-4027 ,4950 ,-1182 ,-1575 ,-1042 ,6609 ,-2841 ,-7527 , 7901 ,3372 ,-7406 ,17 ,2292 ,1839 ,2028 ,-7200 ,2866 ,1266 ,1008 ,786 ,-5722 ,3313 ,365 , 1926 ,3003 ,-8785 ,3001 ,3483 ,-3541 ,1384 ,-926 ,5457 ,-6483 ,65 ,4137 ,-2141 ,4069 ,-6221 , 509 ,1882 ,4470 ,-2667 ,-8002 ,9334 ,1536 ,-8467 ,2970 ,7807 ,-8701 ,2684 ,1569 ,-5378 ,8273 , -8180 ,4645 ,1705 ,-7485 ,12150 ,-7825 ,-4718 ,11376 ,-4933 ,-3872 ,5493 ,-2610 ,-2523 ,7933 ,-2636 , -8268 ,7724 ,-444 ,336 ,213 ,-5912 ,10877 ,-4743 ,-9507 ,10580 ,2918 ,-10309 ,4623 ,2627 ,-2703 , 4619 ,-7866 ,3231 ,3287 ,-4298 ,2621 ,-829 ,-33 ,1217 ,-3929 ,4863 ,2674 ,-10859 ,7525 ,5084 , -11284 ,3046 ,8238 ,-6916 ,-3237 ,8752 ,-4701 ,-2546 ,5949 ,-6198 ,4803 ,2739 ,-8942 ,2823 ,6553 , -2302 ,-8636 ,9751 ,811 ,-11340 ,10797 ,519 ,-9192 ,4928 ,6121 ,-5281 ,-5472 ,7513 ,2141 ,-8568 , 7216 ,392 ,-10296 ,11769 ,-1775 ,-9173 ,10555 ,533 ,-10799 ,7456 ,5601 ,-10655 ,1366 ,6589 ,-4174 , 516 ,7233 ,-13512 ,4466 ,10310 ,-12868 ,2134 ,6193 ,678 ,-9128 ,4393 ,6090 ,-9055 ,3675 ,2581 , -4092 ,-542 ,7092 ,-2860 ,-8418 ,11267 ,-1046 ,-9947 ,11572 ,-2553 ,-8781 ,9092 ,2223 ,-8786 ,2479 , 7681 ,-7361 ,-1360 ,6383 ,-4810 ,2050 ,4776 ,-8136 ,157 ,5558 ,-2130 ,-3755 ,5989 ,314 ,-6877 , 2613 ,6879 ,-4647 ,-6763 ,13161 ,-7279 ,-5888 ,13459 ,-6299 ,-6270 ,7482 ,3717 ,-8344 ,-1042 ,11106 , -7507 ,-4076 ,11277 ,-8975 ,-940 ,7971 ,-1853 ,-7387 ,6600 ,4675 ,-11254 ,6831 ,-806 ,-4783 ,8140 , -536 ,-8517 ,7378 ,1306 ,-8169 ,5030 ,1397 ,27 ,-2921 ,3208 ,1820 ,-8120 ,6815 ,3165 ,-9702 , 5036 ,1877 ,-5739 ,4122 ,5035 ,-6222 ,-4844 ,12237 ,-5097 ,-6511 ,9795 ,-3979 ,-4836 ,6929 ,2914 , -9802 ,2889 ,4755 ,-3701 ,2289 ,-1235 ,1300 ,-1544 ,1303 ,1095 ,-2406 ,858 ,-4354 ,7024 ,-510 , -5703 ,2971 ,2069 ,2036 ,-7247 ,3149 ,4633 ,-5586 ,873 ,2911 ,-2475 ,-44 ,-683 ,2711 ,1638 , -5365 ,3597 ,-911 ,3221 ,-3386 ,-5814 ,8987 ,-1406 ,-1909 ,-1351 ,5061 ,1702 ,-12521 ,10023 ,2494 , -10357 ,7959 ,-618 ,-2832 ,154 ,1271 ,5179 ,-8921 ,1439 ,8486 ,-10995 ,9046 ,163 ,-11520 ,8713 , 1101 ,1605 ,-7424 ,4221 ,3026 ,-8693 ,8186 ,511 ,-5285 ,1178 ,2708 ,-2097 ,891 ,-1031 ,-836 , 5183 ,-715 ,-7606 ,5054 ,4394 ,-8841 ,6407 ,353 ,-5824 ,2926 ,5341 ,-4541 ,-3497 ,7043 ,-3993 , -1918 ,3051 ,3417 ,-6529 ,270 ,8055 ,-6394 ,-437 ,1561 ,467 ,-373 ,-1509 ,3957 ,-2255 ,-3606 , 5630 ,2605 ,-10105 ,6406 ,5776 ,-12116 ,4376 ,3373 ,-592 ,-1894 ,1144 ,2454 ,-5239 ,1903 ,1464 , -608 ,-370 ,726 ,-329 ,296 ,-333 ,614 ,-453 ,417 ,-1450 ,-285 ,7645 ,-8368 ,-1515 ,8380 , -3552 ,-4180 ,8172 ,-1422 ,-11403 ,12504 ,428 ,-10944 ,8657 ,2950 ,-10207 ,4441 ,6979 ,-7978 ,636 , 1552 ,2090 ,-2899 ,-900 ,6406 ,-9062 ,7069 ,2050 ,-11209 ,9727 ,-1328 ,-4593 ,7925 ,-6513 ,-352 , 6163 ,-3817 ,-1797 ,1186 ,5122 ,-7019 ,2899 ,5145 ,-11475 ,7187 ,4308 ,-6944 ,-1443 ,4947 ,4226 , -9125 ,273 ,6936 ,-1986 ,-4448 ,5976 ,34 ,-7511 ,4813 ,-23 ,2725 ,-3182 ,-847 ,2260 ,-2155 , 5169 ,-4371 ,-2399 ,7113 ,-3095 ,-3244 ,4562 ,-3399 ,3676 ,-1504 ,-2769 ,5305 ,-3966 ,-1386 ,6422 , -1912 ,-6605 ,5974 ,1360 ,-1393 ,-3317 ,1227 ,5412 ,-5088 ,-1834 ,5979 ,-2074 ,-5551 ,9424 ,-4147 , -5496 ,10128 ,-5525 ,-2668 ,8893 ,-6358 ,-1863 ,3496 ,-2176 ,6158 ,-5016 ,-2099 ,4381 ,-3145 ,-113 , 5999 ,-1804 ,-9220 ,9932 ,958 ,-9612 ,6202 ,4709 ,-5815 ,-3939 ,7640 ,1037 ,-7913 ,3301 ,6391 , -7106 ,-2450 ,10240 ,-6994 ,-2144 ,5838 ,-1957 ,4024 ,-7225 ,641 ,3540 ,-3817 ,8286 ,-5178 ,-7013 , 12456 ,-5738 ,-4519 ,8171 ,-4244 ,4355 ,-4330 ,-2116 ,5514 ,-3020 ,587 ,428 ,328 ,-1643 ,310 , 746 ,5845 ,-7406 ,-2406 ,10505 ,-9885 ,1782 ,4362 ,-1609 ,-1493 ,443 ,6134 ,-10777 ,5498 ,7007 , -15148 ,8691 ,5803 ,-11262 ,3530 ,5314 ,-2789 ,-4496 ,6828 ,688 ,-8803 ,7048 ,-458 ,-3912 ,4330 , -1490 ,-500 ,888 ,122 ,-2246 ,2727 ,3636 ,-9264 ,4769 ,6120 ,-10163 ,2335 ,6126 ,-2474 ,-6132 , 8021 ,611 ,-9664 ,8506 ,-1782 ,-3330 ,2319 ,4596 ,-4061 ,-4317 ,10634 ,-9204 ,209 ,4514 ,-1027 , 815 ,-2060 ,5628 ,-9248 ,4189 ,5024 ,-9191 ,5222 ,3693 ,-5580 ,-193 ,4758 ,-4008 ,1232 ,601 , -651 ,-1056 ,1426 ,5990 ,-10584 ,3982 ,5259 ,-8631 ,3527 ,5254 ,-4110 ,-5643 ,9561 ,-862 ,-9870 , 9353 ,1775 ,-10960 ,9535 ,1089 ,-9975 ,7687 ,-400 ,-733 ,-940 ,3491 ,-282 ,-8753 ,9194 ,-683 , -5109 ,3620 ,836 ,1582 ,-4234 ,-289 ,2324 ,-3779 ,7679 ,-3832 ,-5782 ,11516 ,-7044 ,-4451 ,8547 , 363 ,-8093 ,4411 ,5884 ,-10340 ,4460 ,3075 ,-7105 ,7046 ,-149 ,-8355 ,8694 ,1505 ,-9196 ,3439 , 6058 ,-5184 ,-2380 ,6558 ,-3533 ,-3548 ,8309 ,-1018 ,-10428 ,6547 ,3993 ,-3796 ,-1371 ,3434 ,1902 , -8721 ,9756 ,-2764 ,-7484 ,6451 ,3110 ,-2433 ,-5879 ,8961 ,-4314 ,-2564 ,2941 ,1916 ,-611 ,-6174 , 6271 ,-577 ,-1289 ,2478 ,-33 ,-2090 ,-959 ,-1286 ,4633 ,1346 ,-6691 ,4285 ,-934 ,-1815 ,3330 , -753 ,-211 ,-15 ,594 ,-234 ,-1029 ,2226 ,-612 ,-2179 ,3586 ,-621 ,-6287 ,4167 ,6110 ,-7216 , -1677 ,6045 ,1751 ,-6432 ,-928 ,10620 ,-8749 ,-3118 ,11243 ,-6986 ,-3797 ,7167 ,452 ,-5383 ,3993 , 210 ,-1719 ,996 ,-4675 ,7882 ,-2120 ,-5331 ,3854 ,70 ,5585 ,-8029 ,-995 ,9486 ,-7782 ,1233 , 1752 ,-1220 ,1793 ,-2382 ,2140 ,-3510 ,4636 ,2204 ,-9442 ,5165 ,5758 ,-7504 ,-1063 ,8520 ,-6826 , -364 ,4750 ,-3528 ,267 ,-708 ,6661 ,-5262 ,-3983 ,5245 ,231 ,-1386 ,1947 ,2777 ,-8802 ,5727 , 1638 ,-6974 ,4849 ,3779 ,-3014 ,-6212 ,7243 ,2216 ,-6094 ,-131 ,4458 ,2085 ,-8044 ,3049 ,3048 , -2191 ,1148 ,-3076 ,902 ,5403 ,-3247 ,-5341 ,9351 ,-4238 ,-4114 ,6420 ,-3806 ,-596 ,3290 ,626 , -3203 ,1482 ,302 ,-376 ,2295 ,-2583 ,118 ,-679 ,822 ,1161 ,-3266 ,5981 ,-4852 ,-773 ,8466 , -9472 ,2230 ,3692 ,-4051 ,2727 ,-1842 ,840 ,3033 ,-4772 ,199 ,5679 ,-4399 ,-1326 ,3978 ,-2335 , 212 ,-1526 ,3636 ,2458 ,-7560 ,639 ,7677 ,-3455 ,-5267 ,7504 ,-4891 ,-865 ,8061 ,-6612 ,-1522 , 5609 ,-3574 ,381 ,690 ,-2613 ,7812 ,-5445 ,-5051 ,9771 ,-2060 ,-6984 ,7499 ,-1746 ,-4859 ,5802 , -2089 ,3006 ,-3659 ,3080 ,1376 ,-10348 ,9281 ,2986 ,-8858 ,2216 ,7965 ,-7596 ,-1330 ,7762 ,-7367 , 709 ,7132 ,-3826 ,-5647 ,5091 ,4924 ,-6781 ,-1838 ,3996 ,3397 ,-2717 ,-5659 ,5295 ,3636 ,-4723 , -3198 ,4557 ,4158 ,-7313 ,636 ,7407 ,-7216 ,-470 ,5742 ,-3666 ,-1380 ,1807 ,3524 ,-4557 ,228 , 8098 ,-11070 ,37 ,10535 ,-6142 ,-4892 ,6989 ,2331 ,-10488 ,8956 ,1271 ,-9582 ,6520 ,-449 ,4592 , -6410 ,-3239 ,12514 ,-8887 ,-1430 ,6628 ,-6989 ,3817 ,4550 ,-8100 ,741 ,6463 ,-1814 ,-3291 ,-130 , 2621 ,-1258 ,1322 ,2478 ,-6511 ,3265 ,1373 ,-2185 ,-562 ,3134 ,2534 ,-8162 ,5081 ,1248 ,-4355 , 3704 ,-1365 ,-2333 ,6309 ,-1689 ,-8103 ,9318 ,788 ,-8664 ,4722 ,5602 ,-7772 ,-562 ,9910 ,-10236 , 1077 ,8513 ,-8051 ,-63 ,3149 ,-554 ,38 ,4147 ,-5288 ,-3526 ,8097 ,-1742 ,-4982 ,3040 ,2810 , -2567 ,-358 ,1694 ,362 ,-2937 ,2389 ,-236 ,-854 ,7403 ,-10413 ,-2600 ,11819 ,-4973 ,-5060 ,5826 , 2230 ,-6719 ,2356 ,6699 ,-8834 ,1431 ,6368 ,-7198 ,631 ,3203 ,2917 ,-6660 ,1364 ,6828 ,-8937 , 3462 ,1921 ,-2615 ,-591 ,4216 ,-356 ,-8066 ,9770 ,-1091 ,-7218 ,4638 ,3172 ,-1318 ,-5593 ,4886 , 1511 ,-5168 ,4151 ,-1057 ,-2828 ,5987 ,-1870 ,-6393 ,6999 ,2547 ,-8891 ,5424 ,2133 ,-7708 ,5257 , 4188 ,-6745 ,-946 ,8903 ,-6186 ,-5001 ,11352 ,-5112 ,-4308 ,4072 ,1684 ,-1515 ,-957 ,7033 ,-9849 , -406 ,7462 ,227 ,-5690 ,-627 ,10086 ,-10129 ,1440 ,5418 ,-4596 ,136 ,3101 ,-3080 ,-350 ,6388 , -6670 ,969 ,1993 ,-2926 ,5391 ,-1513 ,-6381 ,9119 ,-2262 ,-6711 ,5431 ,-75 ,2741 ,-4780 ,645 , 2542 ,-2172 ,1353 ,-366 ,-193 ,-1958 ,6278 ,-2889 ,-6643 ,8584 ,720 ,-7426 ,1820 ,7264 ,-4022 , -5506 ,4202 ,3326 ,-1782 ,-2638 ,1742 ,-1563 ,1310 ,2009 ,-2501 ,1475 ,927 ,-1563 ,-663 ,4561 , -4257 ,-2312 ,4292 ,-926 ,-1528 ,478 ,6384 ,-8402 ,636 ,6190 ,-5891 ,5347 ,-3102 ,-4022 ,7176 , 811 ,-7743 ,2849 ,3987 ,-1742 ,-2650 ,2569 ,3509 ,-8425 ,6504 ,1422 ,-8037 ,3169 ,6604 ,-5616 , -2828 ,9327 ,-7307 ,-2612 ,9741 ,-4353 ,-5501 ,9704 ,-4942 ,-5371 ,9074 ,-152 ,-7468 ,2776 ,3651 , -3092 ,2226 ,-1270 ,1112 ,-1052 ,1987 ,-2804 ,-2520 ,6745 ,-2880 ,-2992 ,3352 ,3872 ,-7610 ,2426 , 4945 ,-7777 ,3772 ,4946 ,-6101 ,-1420 ,6271 ,-3266 ,-1091 ,1393 ,-2046 ,5334 ,-1816 ,-5872 ,4982 , 4358 ,-7176 ,213 ,4121 ,967 ,-1389 ,-5771 ,6362 ,1232 ,-6280 ,3208 ,4385 ,-5536 ,63 ,3675 , -2335 ,-20 ,364 ,1635 ,-2103 ,-996 ,2400 ,2699 ,-3097 ,-1823 ,770 ,2212 ,1887 ,-5436 ,2713 , 1223 ,-2095 ,1494 ,-394 ,245 ,-476 ,622 ,28 ,-1941 ,3572 ,353 ,-5845 ,4590 ,2757 ,-6801 , 3670 ,3581 ,-7576 ,3406 ,4392 ,-7447 ,5626 ,280 ,-7012 ,9213 ,-4527 ,-3324 ,6836 ,-4380 ,3816 , -1295 ,-4917 ,5781 ,-1213 ,-1785 ,2170 ,-745 ,-181 ,281 ,16 ,214 ,-199 ,-1291 ,819 ,5618 , -6279 ,-3534 ,10459 ,-4924 ,-3963 ,5854 ,-4692 ,3874 ,907 ,-5956 ,8392 ,-5896 ,-1603 ,7404 ,-6721 , 1016 ,2676 ,-65 ,1036 ,-2073 ,-112 ,-967 ,-736 ,6247 ,-1951 ,-7463 ,6594 ,3766 ,-8128 ,1793 , 7043 ,-7439 ,-1175 ,7881 ,-4499 ,-4088 ,7886 ,-364 ,-8787 ,7706 ,2323 ,-8246 ,4140 ,3667 ,-6600 , 2996 ,3580 ,-7129 ,4242 ,933 ,-1365 ,-602 ,4465 ,-884 ,-9918 ,9412 ,2321 ,-8145 ,2369 ,6210 , -7032 ,1800 ,5510 ,-9296 ,4649 ,3882 ,-6208 ,538 ,6536 ,-5376 ,-3599 ,10430 ,-6569 ,-3099 ,5725 , -1567 ,148 ,106 ,40 ,-134 ,318 ,-1124 ,6676 ,-8710 ,-2131 ,10459 ,-7671 ,4897 ,-3369 ,-3398 , 9642 ,-5025 ,-3550 ,2527 ,5328 ,-3809 ,-5962 ,10744 ,-5164 ,-4750 ,6835 ,-2072 ,421 ,385 ,995 , -3320 ,2987 ,1976 ,-6754 ,2940 ,2035 ,-2533 ,-596 ,6626 ,-4934 ,-4789 ,10364 ,-5057 ,-5327 ,9384 , -1579 ,-8406 ,9006 ,124 ,-7940 ,4422 ,4431 ,-5488 ,-665 ,8357 ,-9004 ,-1415 ,9302 ,-3930 ,-5709 , 8165 ,-1623 ,-5796 ,8996 ,-5601 ,-2593 ,4553 ,2489 ,-5170 ,-721 ,8368 ,-7917 ,-274 ,5385 ,-3835 , -1654 ,6642 ,-3379 ,-4947 ,7096 ,-1392 ,-2825 ,2069 ,2212 ,-3798 ,64 ,6075 ,-5768 ,-3392 ,9074 , -4699 ,-2368 ,5441 ,-4624 ,3035 ,-2321 ,2141 ,2392 ,-7448 ,6160 ,-147 ,-5033 ,4609 ,3133 ,-6521 , -458 ,8249 ,-5412 ,-4178 ,7584 ,-693 ,-4977 ,1859 ,876 ,470 ,1287 ,-1491 ,-1558 ,4594 ,-2093 , -3935 ,6635 ,-4650 ,-427 ,3518 ,-2027 ,-58 ,-1216 ,5947 ,-3542 ,-5602 ,8988 ,-792 ,-9064 ,9554 , 69 ,-8570 ,5680 ,2877 ,-1489 ,-6478 ,7899 ,1540 ,-9089 ,5414 ,1098 ,-3024 ,-92 ,5033 ,-1672 , -3860 ,2873 ,-1684 ,347 ,5025 ,-5205 ,-673 ,5215 ,-3938 ,2475 ,-3742 ,900 ,5868 ,-6008 ,-775 , 3548 ,3058 ,-6150 ,-75 ,5414 ,-3400 ,-2005 ,4020 ,1910 ,-7879 ,5119 ,3157 ,-5162 ,-1260 ,4312 , 2870 ,-8817 ,4605 ,1500 ,-1362 ,-898 ,4240 ,-452 ,-9046 ,8778 ,-3314 ,-1861 ,7746 ,-4768 ,-4958 , 7836 ,-441 ,-5948 ,3414 ,1308 ,1381 ,-4487 ,1007 ,3350 ,-5530 ,5329 ,1326 ,-6895 ,2574 ,3844 , -3805 ,1898 ,5323 ,-10774 ,3985 ,4768 ,-7681 ,4975 ,4014 ,-6833 ,-1055 ,7604 ,-3691 ,-4256 ,5192 , 2401 ,-6293 ,2396 ,1927 ,-2901 ,300 ,4779 ,-3515 ,-3850 ,10194 ,-8400 ,-1536 ,7385 ,-2408 ,-2553 , 1310 ,4798 ,-7278 ,1715 ,7815 ,-10539 ,1306 ,7542 ,-5774 ,2009 ,-1289 ,-807 ,4913 ,-3779 ,-1094 , 1636 ,-609 ,3875 ,-4093 ,617 ,6078 ,-11611 ,6103 ,2363 ,-3178 ,6644 ,-10224 ,3275 ,2471 ,2265 , -1302 ,-7807 ,10591 ,-2911 ,-5123 ,5970 ,-1438 ,-1910 ,1939 ,220 ,-1879 ,756 ,3655 ,-4112 ,-1104 , 2789 ,-10 ,3753 ,-6453 ,-689 ,7962 ,-6139 ,-296 ,3883 ,-3928 ,3227 ,430 ,-4596 ,3777 ,2045 , -5166 ,3376 ,-2289 ,1945 ,3341 ,-8309 ,4650 ,1009 ,2226 ,-5975 ,1763 ,6111 ,-8917 ,3977 ,1484 , -2105 ,-982 ,5106 ,-2717 ,-4353 ,5116 ,2673 ,-4778 ,-3016 ,7733 ,-5106 ,3392 ,-647 ,-4102 ,8822 , -8527 ,1023 ,4196 ,-4384 ,4104 ,590 ,-5764 ,3273 ,3928 ,-4654 ,-947 ,2887 ,2313 ,-5961 ,2288 , 2283 ,-1137 ,-415 ,3165 ,502 ,-10502 ,9940 ,1322 ,-8239 ,3734 ,4064 ,-2042 ,-2602 ,1378 ,62 , 2115 ,-1997 ,-1088 ,1460 ,2481 ,-2244 ,-3398 ,6547 ,-2558 ,-4126 ,8462 ,-7073 ,647 ,7446 ,-9532 , 1933 ,6442 ,-3401 ,-5877 ,7733 ,1243 ,-9094 ,5676 ,4363 ,-8313 ,1744 ,7663 ,-6988 ,-2213 ,4691 , 3587 ,-7210 ,934 ,6820 ,-9962 ,5885 ,4089 ,-9775 ,4659 ,5110 ,-6789 ,-1566 ,8558 ,-3582 ,-6250 , 6588 ,-1149 ,1855 ,-753 ,-5121 ,2913 ,2635 ,915 ,-6215 ,4503 ,756 ,-4028 ,3978 ,-1766 ,250 , -2002 ,4437 ,-1168 ,-4623 ,9470 ,-7199 ,-3082 ,7304 ,-1945 ,-1112 ,-370 ,3747 ,-3852 ,-203 ,7385 , -9372 ,-1141 ,9903 ,-4907 ,-3604 ,3066 ,5136 ,-5870 ,-2846 ,8614 ,-6055 ,-668 ,3355 ,557 ,-3352 , 4618 ,739 ,-10164 ,9836 ,-1450 ,-4233 ,4061 ,-1407 ,-1871 ,4165 ,1379 ,-7747 ,3682 ,5117 ,-5044 , -2362 ,7744 ,-4445 ,-3343 ,6364 ,-4774 ,1303 ,4693 ,-5002 ,-2448 ,6063 ,905 ,-7103 ,2541 ,5980 , -4823 ,-3881 ,7136 ,65 ,-7600 ,8171 ,-613 ,-7984 ,6391 ,3355 ,-4776 ,-1549 ,3037 ,-1485 ,3398 , -613 ,-5960 ,5653 ,1729 ,-5921 ,1408 ,6033 ,-3739 ,-5682 ,8406 ,-284 ,-7342 ,6697 ,-978 ,-5075 , 6971 ,534 ,-7335 ,2726 ,4496 ,-3177 ,-1346 ,1900 ,2389 ,-3062 ,-240 ,3705 ,-5083 ,1558 ,2368 , -2183 ,-780 ,2557 ,3567 ,-8086 ,1327 ,7922 ,-7008 ,-572 ,5276 ,-6252 ,4117 ,3228 ,-7356 ,2255 , 2761 ,-1384 ,797 ,-876 ,-1068 ,5431 ,-5060 ,-3261 ,8054 ,-3914 ,-1146 ,2291 ,-3291 ,6578 ,-5050 , -1102 ,8147 ,-10502 ,3850 ,5699 ,-7236 ,-163 ,6768 ,-2458 ,-5636 ,4289 ,3870 ,-3290 ,-5438 ,9112 , -1975 ,-6262 ,7197 ,-4165 ,-57 ,5642 ,-4388 ,-2988 ,4483 ,2863 ,-5674 ,631 ,3134 ,-3489 ,2848 , -407 ,-1215 ,161 ,192 ,4087 ,-6119 ,764 ,3825 ,-2359 ,4738 ,-6747 ,578 ,6896 ,-7431 ,1751 , 2784 ,-2512 ,687 ,709 ,46 ,-1644 ,1577 ,1641 ,-3496 ,1988 ,438 ,-1734 ,111 ,2006 ,3658 , -7735 ,166 ,6134 ,-2482 ,-2167 ,2171 ,2772 ,-5712 ,2254 ,5242 ,-8076 ,2250 ,2842 ,-2226 ,-596 , 1577 ,2621 ,-6435 ,7931 ,-3562 ,-5106 ,5594 ,586 ,695 ,-5683 ,7526 ,-3648 ,-5045 ,8802 ,-1356 , -6411 ,5766 ,135 ,-3500 ,4426 ,-5572 ,3615 ,3788 ,-5965 ,-1036 ,6255 ,-1318 ,-5649 ,3345 ,3447 , -3939 ,225 ,6390 ,-7726 ,-1996 ,8533 ,-2133 ,-5461 ,3443 ,2705 ,-3827 ,3467 ,2336 ,-8176 ,995 , 7585 ,-4039 ,-3495 ,5348 ,-523 ,-5519 ,7052 ,-2178 ,-4358 ,8089 ,-6329 ,1773 ,3404 ,-6910 ,3984 , 3586 ,-3790 ,-858 ,1396 ,-169 ,1583 ,-2296 ,817 ,880 ,-2916 ,4791 ,156 ,-5778 ,4077 ,1283 , -4380 ,2818 ,-106 ,1496 ,478 ,-4761 ,1118 ,5553 ,-2521 ,-5661 ,8846 ,-4297 ,-2088 ,6162 ,-8051 , 5643 ,3188 ,-8957 ,4214 ,5036 ,-5305 ,-2288 ,4176 ,2763 ,-4815 ,-1557 ,4338 ,2342 ,-6404 ,2036 , 4334 ,-5615 ,1918 ,318 ,2567 ,-2638 ,-2342 ,5281 ,-1766 ,-3239 ,2486 ,609 ,982 ,467 ,-3390 , 2242 ,-2067 ,3104 ,-720 ,-3443 ,4888 ,-1177 ,-2867 ,1714 ,4164 ,-6438 ,2248 ,3261 ,-4998 ,3116 , -1331 ,2874 ,-3295 ,-1280 ,6592 ,-5422 ,-1848 ,6567 ,-1323 ,-6632 ,7214 ,-970 ,-4697 ,2403 ,3069 , -256 ,-6183 ,6723 ,-2154 ,-3990 ,6889 ,-1234 ,-4171 ,1112 ,3208 ,-3311 ,398 ,4432 ,-4986 ,221 , 4303 ,-4931 ,973 ,5488 ,-5009 ,-1474 ,5080 ,-4574 ,515 ,6261 ,-5711 ,-2998 ,7932 ,-2194 ,-6408 , 7986 ,-508 ,-7769 ,7163 ,1382 ,-6316 ,1651 ,4556 ,-1518 ,-5363 ,6476 ,983 ,-8558 ,5864 ,3933 , -7868 ,1738 ,4910 ,-2903 ,-2173 ,3247 ,2085 ,-7349 ,6167 ,486 ,-6121 ,6225 ,-3079 ,487 ,15 , 2332 ,-2900 ,-544 ,3200 ,-1180 ,3752 ,-6458 ,1067 ,1282 ,3185 ,-3273 ,-1083 ,6584 ,-7836 ,1340 , 4902 ,-833 ,-5669 ,3876 ,3981 ,-7241 ,1800 ,5938 ,-5024 ,-3382 ,7259 ,-485 ,-4646 ,189 ,4379 , -1044 ,-3685 ,4179 ,-2285 ,-1118 ,6074 ,-4335 ,-2231 ,5317 ,-3443 ,-2000 ,5697 ,-618 ,-4862 ,1259 , 6404 ,-6181 ,-1535 ,7913 ,-8477 ,4272 ,2632 ,-7141 ,5061 ,1311 ,-3617 ,-681 ,5501 ,-2653 ,-4313 , 5465 ,2140 ,-7576 ,3276 ,5592 ,-7791 ,1054 ,4661 ,-589 ,-5657 ,5472 ,1885 ,-8931 ,7983 ,481 , -7672 ,6893 ,770 ,-7313 ,7559 ,-1252 ,-5664 ,5383 ,-204 ,-965 ,-119 ,1109 ,-122 ,-1622 ,2124 , 788 ,-4016 ,4045 ,341 ,-5316 ,3512 ,1438 ,-2963 ,1208 ,3856 ,-5374 ,-658 ,6158 ,-3225 ,-1933 , 1788 ,2150 ,-175 ,-5497 ,5464 ,869 ,-7613 ,6522 ,1782 ,-5329 ,2168 ,509 ,-1723 ,1966 ,3226 , -4232 ,-2878 ,7020 ,-4474 ,-520 ,5628 ,-5144 ,-1404 ,5159 ,372 ,-6771 ,5405 ,1446 ,-4987 ,1524 , 1692 ,224 ,-2409 ,6478 ,-5874 ,-2852 ,8378 ,-5995 ,653 ,2895 ,-2347 ,617 ,470 ,42 ,-1748 , 2280 ,2386 ,-7069 ,4793 ,3160 ,-7477 ,2812 ,4126 ,-2525 ,-4595 ,8779 ,-4290 ,-5643 ,10785 ,-6513 , -2378 ,7589 ,-2153 ,-4349 ,1897 ,2011 ,817 ,-3174 ,796 ,1890 ,-3964 ,5588 ,-752 ,-6210 ,5229 , 3262 ,-7268 ,2564 ,3949 ,-4930 ,1247 ,1730 ,-3250 ,2826 ,3656 ,-8265 ,4320 ,2739 ,-6713 ,3863 , 4166 ,-6044 ,-270 ,6123 ,-5131 ,-1277 ,4059 ,1866 ,-6070 ,938 ,4566 ,-2006 ,-1897 ,1788 ,1209 , -3268 ,6812 ,-5114 ,-5037 ,6875 ,1739 ,-3604 ,-2573 ,5750 ,-2541 ,-1536 ,3092 ,-1845 ,493 ,61 , 506 ,-1414 ,693 ,3485 ,-4745 ,1134 ,1547 ,-2216 ,4005 ,-3182 ,-414 ,2309 ,-1431 ,314 ,-1400 , 2167 ,617 ,-1089 ,-1188 ,3847 ,362 ,-7355 ,3403 ,3187 ,664 ,-3488 ,-2491 ,6768 ,-1138 ,-4004 , 1641 ,420 ,2314 ,-2061 ,-2656 ,4926 ,-1093 ,-3012 ,3052 ,-387 ,-2383 ,2205 ,212 ,3154 ,-4237 , -4168 ,8563 ,-2010 ,-5252 ,4259 ,3077 ,-5886 ,1688 ,1981 ,-623 ,2907 ,-6419 ,1891 ,2926 ,-2485 , 1194 ,-92 ,-216 ,170 ,110 ,42 ,-305 ,-1078 ,3995 ,-2371 ,-3990 ,6619 ,-706 ,-5706 ,3482 , 4503 ,-6878 ,1394 ,4355 ,-5881 ,4731 ,-621 ,-4623 ,4042 ,137 ,479 ,-2884 ,3028 ,959 ,-5079 , 6746 ,-4461 ,-2778 ,4339 ,819 ,-2650 ,2712 ,2436 ,-8897 ,5528 ,667 ,82 ,-1120 ,-1416 ,2515 , -2036 ,4063 ,-4290 ,-40 ,4258 ,-2895 ,-1075 ,2648 ,-1278 ,-184 ,817 ,-438 ,-1442 ,1998 ,3971 , -7642 ,1430 ,4535 ,-2221 ,-1381 ,1595 ,2829 ,-6000 ,3263 ,2642 ,-7372 ,5943 ,1096 ,-5079 ,1431 , 3838 ,-326 ,-6290 ,5347 ,1905 ,-6656 ,3454 ,4630 ,-6488 ,-396 ,5955 ,-2338 ,-3816 ,4327 ,3064 , -7621 ,2126 ,3818 ,-3697 ,1048 ,1323 ,-2755 ,3591 ,-566 ,-3679 ,2254 ,2700 ,-734 ,-5483 ,7906 , -3812 ,-3043 ,7914 ,-7253 ,-12 ,6424 ,-2440 ,-5018 ,4289 ,2045 ,-3495 ,916 ,1731 ,-293 ,-3768 , 5375 ,977 ,-9774 ,9012 ,635 ,-7657 ,5236 ,1372 ,-2638 ,-265 ,4514 ,-3765 ,-1193 ,4995 ,-5153 , -354 ,6592 ,-4107 ,-3246 ,4686 ,-6 ,-2612 ,4863 ,-3974 ,-1670 ,7931 ,-8756 ,836 ,5362 ,-536 , -4952 ,1757 ,5197 ,-7808 ,5948 ,-338 ,-4499 ,2702 ,2744 ,-1025 ,-4925 ,3995 ,1587 ,-1998 ,-353 , 1225 ,-100 ,-441 ,1297 ,-1190 ,891 ,-15 ,-3775 ,4509 ,701 ,-4790 ,2321 ,1092 ,-152 ,141 , 89 ,298 ,-1007 ,1987 ,-1028 ,-2651 ,1329 ,853 ,3628 ,-5021 ,-75 ,4436 ,-4586 ,1850 ,2060 , -3402 ,-36 ,5637 ,-4303 ,-3021 ,4784 ,2105 ,-4826 ,-778 ,5560 ,-4624 ,1128 ,1413 ,-1016 ,-1438 , 2355 ,2717 ,-8059 ,6493 ,1753 ,-8270 ,6751 ,1624 ,-7494 ,4429 ,3361 ,-4611 ,647 ,1206 ,-675 , -505 ,4477 ,-4425 ,-1589 ,3114 ,-750 ,3525 ,-5297 ,1991 ,220 ,434 ,1457 ,-4155 ,1931 ,2616 , 93 ,-6116 ,7019 ,-855 ,-5305 ,4348 ,-1174 ,1868 ,-1293 ,888 ,-2888 ,2162 ,2631 ,-4991 ,1381 , 3130 ,1132 ,-7177 ,4454 ,3613 ,-6958 ,3451 ,1526 ,-3720 ,1506 ,1970 ,-214 ,-2811 ,3198 ,3352 , -10124 ,4810 ,2710 ,-2615 ,1819 ,-961 ,1093 ,-2797 ,7652 ,-7918 ,-2200 ,7999 ,-4478 ,3473 ,-4626 , 1945 ,1622 ,-1956 ,1132 ,-1563 ,3567 ,-3064 ,-1217 ,3540 ,1073 ,-5442 ,4106 ,3377 ,-9610 ,5155 , 4612 ,-6296 ,-852 ,6958 ,-2948 ,-5442 ,6174 ,1950 ,-7368 ,3913 ,4118 ,-8724 ,7057 ,-239 ,-5552 , 3522 ,1434 ,2030 ,-6891 ,2763 ,5788 ,-6537 ,1178 ,1531 ,-2252 ,3922 ,-1764 ,-2860 ,3829 ,-408 , -2931 ,3668 ,-682 ,-3667 ,4276 ,1760 ,-5452 ,568 ,6364 ,-4914 ,-2279 ,3189 ,1790 ,-2930 ,761 , 5200 ,-9545 ,4000 ,4347 ,-6605 ,2264 ,2538 ,1503 ,-6465 ,1813 ,5801 ,-5664 ,-1093 ,5669 ,-1509 , -4977 ,5541 ,-916 ,-2820 ,2955 ,-1084 ,-271 ,-298 ,574 ,1411 ,-517 ,-1806 ,3475 ,-1152 ,-4872 , 5262 ,-1211 ,-756 ,3079 ,-4672 ,2297 ,2865 ,-5487 ,1927 ,4086 ,-6209 ,4422 ,73 ,-5543 ,8259 , -5246 ,-577 ,4308 ,-4208 ,2047 ,74 ,-559 ,181 ,505 ,-564 ,430 ,-349 ,-1099 ,2413 ,-742 , 1805 ,-1813 ,-2205 ,2939 ,-742 ,143 ,-48 ,241 ,-1720 ,2601 ,2118 ,-4769 ,732 ,1668 ,-1657 , 2518 ,2321 ,-6622 ,902 ,6808 ,-5257 ,-2429 ,7505 ,-4657 ,-2983 ,5874 ,-2865 ,1484 ,-826 ,2174 , 52 ,-6761 ,5113 ,389 ,1450 ,-2044 ,-2661 ,4702 ,-2592 ,-530 ,1265 ,2304 ,-2663 ,-1493 ,5898 , -3818 ,-2888 ,4878 ,-2302 ,-1370 ,5169 ,-3916 ,-2562 ,7497 ,-3416 ,-4944 ,6162 ,-1041 ,-715 ,-609 , 2112 ,955 ,-6170 ,8269 ,-4157 ,-4655 ,6106 ,545 ,-2249 ,-1892 ,6563 ,-5416 ,-774 ,3949 ,-2476 , 800 ,108 ,-943 ,208 ,4884 ,-6657 ,446 ,7362 ,-8273 ,1337 ,6807 ,-6828 ,-962 ,7212 ,-4132 , -3388 ,4532 ,2070 ,-5095 ,838 ,5540 ,-5706 ,-1554 ,6108 ,-1150 ,-5627 ,4588 ,2925 ,-6407 ,1791 , 5543 ,-4711 ,-3405 ,7124 ,-1027 ,-6328 ,6430 ,808 ,-6518 ,5184 ,-716 ,-3061 ,3436 ,-637 ,127 , -146 ,389 ,-108 ,-312 ,975 ,115 ,-1430 ,-921 ,1683 ,-1471 ,4099 ,-2587 ,-3253 ,6842 ,-5344 , 587 ,2240 ,546 ,-1716 ,-1178 ,7127 ,-8159 ,-985 ,7535 ,-2606 ,-4793 ,5784 ,632 ,-6223 ,5454 , -1990 ,-1145 ,2238 ,2658 ,-4283 ,-2836 ,9252 ,-7015 ,-615 ,7422 ,-7118 ,46 ,6004 ,-4099 ,-1340 , 3697 ,-1564 ,-1881 ,2729 ,744 ,-3808 ,4484 ,-919 ,-3547 ,2427 ,150 ,2694 ,-4082 ,454 ,1652 , -1509 ,3951 ,-4287 ,-1071 ,5713 ,-2225 ,-3678 ,2727 ,3653 ,-4560 ,-1278 ,5642 ,-3651 ,-1767 ,3457 , 333 ,-2000 ,509 ,1412 ,-1937 ,1966 ,-133 ,434 ,-2482 ,-1747 ,5474 ,-2969 ,935 ,2329 ,-5516 , 2080 ,4808 ,-5540 ,-549 ,6552 ,-4445 ,-2640 ,5001 ,-933 ,-3474 ,3219 ,1318 ,-4193 ,3392 ,2563 , -6351 ,1590 ,3138 ,-2500 ,454 ,992 ,-1848 ,668 ,4163 ,-4422 ,-2776 ,7261 ,-1909 ,-4964 ,3548 , 2745 ,-3664 ,-488 ,6686 ,-6905 ,-1557 ,5313 ,-511 ,-1514 ,-781 ,4496 ,-5941 ,5285 ,-137 ,-6843 , 6374 ,-1346 ,308 ,533 ,-1263 ,-346 ,1218 ,-1225 ,1686 ,2360 ,-6408 ,2323 ,4984 ,-4478 ,-1047 , 1004 ,2616 ,667 ,-5900 ,3346 ,4577 ,-6427 ,380 ,5971 ,-5608 ,375 ,3030 ,-1946 ,-1125 ,2687 , 1284 ,-4759 ,2085 ,527 ,729 ,-1413 ,3354 ,-543 ,-7301 ,6918 ,1687 ,-6438 ,2824 ,4951 ,-6511 , -169 ,5352 ,-1983 ,-3125 ,3511 ,2438 ,-5733 ,419 ,2486 ,-526 ,1548 ,-449 ,-2579 ,3909 ,-1606 , -4049 ,5568 ,-84 ,-5304 ,4819 ,1866 ,-6101 ,2018 ,2959 ,-515 ,-4274 ,5607 ,-498 ,-7479 ,9713 , -3289 ,-5211 ,7099 ,-770 ,-4504 ,1923 ,4625 ,-5183 ,-762 ,5718 ,-5244 ,349 ,2616 ,-687 ,-135 , -1197 ,5437 ,-5322 ,-3985 ,8968 ,-2648 ,-5067 ,5934 ,-623 ,-3874 ,3421 ,-250 ,-1596 ,1721 ,-1201 , -326 ,3318 ,-1977 ,-3077 ,3880 ,-252 ,-3497 ,6528 ,-4958 ,-1503 ,7397 ,-6823 ,1637 ,1244 ,-1135 , 2082 ,-3177 ,701 ,4600 ,-4169 ,-1541 ,5087 ,-5173 ,2761 ,2282 ,-5830 ,4125 ,2180 ,-4852 ,-158 , 5545 ,-3180 ,-2367 ,2340 ,-522 ,4238 ,-4617 ,-1650 ,5809 ,-4917 ,649 ,5053 ,-4314 ,-1589 ,2871 , 1913 ,-2579 ,-2214 ,4245 ,-1455 ,-1461 ,560 ,1575 ,-900 ,2056 ,738 ,-6648 ,4852 ,190 ,-1421 , 694 ,478 ,638 ,-2571 ,3329 ,-2469 ,1141 ,701 ,-2751 ,5057 ,-2160 ,-4411 ,5546 ,-13 ,-3146 , 1004 ,122 ,2105 ,-2623 ,2935 ,-525 ,-4056 ,2949 ,2013 ,-883 ,-3686 ,2666 ,1749 ,-1430 ,-645 , 1726 ,-939 ,-1125 ,3963 ,-3256 ,-537 ,3320 ,-3773 ,1105 ,1645 ,-1417 ,-1014 ,3374 ,-26 ,-4753 , 6066 ,-3075 ,-2390 ,4927 ,-2616 ,-118 ,1015 ,149 ,-1794 ,1693 ,2398 ,-5256 ,1738 ,4858 ,-4699 , -2250 ,5782 ,26 ,-6047 ,3209 ,3098 ,-3151 ,-864 ,3736 ,-1884 ,-2545 ,7311 ,-6699 ,-2058 ,8342 , -5262 ,-621 ,3149 ,-1319 ,-1858 ,3096 ,557 ,-4331 ,2149 ,4048 ,-4282 ,-1929 ,6728 ,-6092 ,1581 , 4194 ,-5682 ,2392 ,553 ,-1338 ,-247 ,4476 ,-2633 ,-3992 ,3992 ,2845 ,-3950 ,-2174 ,5648 ,-2187 , -2479 ,3109 ,380 ,-2842 ,2180 ,263 ,-2478 ,1571 ,3733 ,-3948 ,-2669 ,6409 ,-3673 ,-2142 ,5025 , -368 ,-5161 ,5147 ,1047 ,-7877 ,7690 ,-372 ,-4892 ,2460 ,1872 ,1511 ,-7033 ,5907 ,546 ,-5550 , 4305 ,336 ,-729 ,-701 ,4355 ,-6097 ,283 ,4925 ,-3841 ,802 ,1536 ,-2215 ,545 ,4145 ,-5120 , -581 ,5586 ,-2004 ,-4470 ,5965 ,-1221 ,-4886 ,6686 ,-1620 ,-4789 ,5352 ,1558 ,-5861 ,1298 ,3496 , -440 ,-3738 ,3669 ,947 ,-4808 ,3094 ,802 ,-2871 ,2218 ,2865 ,-5621 ,903 ,5831 ,-4823 ,-2410 , 5885 ,-3183 ,1317 ,2713 ,-6649 ,2756 ,2699 ,-1716 ,-1045 ,1543 ,-286 ,-442 ,627 ,-105 ,-878 , 121 ,4150 ,-4354 ,-2010 ,5946 ,-951 ,-5483 ,4157 ,3211 ,-5114 ,-73 ,2215 ,1169 ,-1665 ,-953 , 1231 ,-845 ,1441 ,2734 ,-5652 ,735 ,6565 ,-6005 ,-879 ,4014 ,-1640 ,-815 ,1551 ,-526 ,-1505 , 3563 ,-1457 ,-3321 ,4650 ,-408 ,-3350 ,2989 ,-304 ,-2865 ,4343 ,826 ,-5767 ,2156 ,2926 ,-1761 , -633 ,961 ,1462 ,-3202 ,1834 ,2760 ,-4619 ,1083 ,2198 ,-3282 ,877 ,4447 ,-4340 ,-1534 ,4257 , -952 ,-1909 ,3835 ,-774 ,-5431 ,6037 ,-1134 ,-3969 ,4314 ,-1364 ,2361 ,-528 ,-5686 ,5854 ,646 , -4172 ,626 ,3323 ,116 ,-4387 ,1860 ,3112 ,-1203 ,-4645 ,4436 ,1981 ,-5636 ,2048 ,4371 ,-5272 , 11 ,5977 ,-6021 ,-22 ,3226 ,-1301 ,750 ,999 ,-3069 ,1981 ,1664 ,-4771 ,2932 ,607 ,-1413 , 1005 ,-1816 ,2105 ,2715 ,-5838 ,885 ,6158 ,-5681 ,415 ,2380 ,-3055 ,3842 ,-2096 ,-863 ,549 , 1227 ,2261 ,-6784 ,5521 ,882 ,-5255 ,3950 ,-1090 ,105 ,243 ,93 ,-1807 ,3158 ,1111 ,-6292 , 5029 ,1602 ,-5816 ,3256 ,3319 ,-5539 ,1212 ,1891 ,1371 ,-1064 ,-3891 ,5566 ,-3897 ,320 ,4961 , -4697 ,-12 ,2050 ,-1971 ,581 ,3704 ,-4185 ,59 ,1631 ,1735 ,225 ,-6455 ,5534 ,105 ,-2805 , 2645 ,-856 ,-125 ,-44 ,1049 ,-2093 ,1280 ,341 ,1433 ,471 ,-6488 ,5878 ,1798 ,-7216 ,5257 , 1924 ,-6531 ,4609 ,576 ,-3204 ,4738 ,-4580 ,678 ,3023 ,-2568 ,464 ,-801 ,2342 ,-1396 ,1718 , 400 ,-5557 ,4247 ,3314 ,-5180 ,-392 ,3113 ,-79 ,-872 ,-611 ,3224 ,-2245 ,-2107 ,2562 ,-933 , -822 ,3389 ,407 ,-5995 ,4243 ,2135 ,-4788 ,2584 ,892 ,-1770 ,845 ,381 ,-1720 ,1896 ,2543 , -5805 ,2315 ,4804 ,-6222 ,1364 ,2015 ,-1613 ,743 ,145 ,-570 ,-503 ,3103 ,-2017 ,-2842 ,5215 , -1651 ,-2301 ,2414 ,32 ,-1953 ,704 ,4424 ,-5243 ,-378 ,2629 ,1503 ,-694 ,-5128 ,4664 ,2091 , -4642 ,1226 ,3931 ,-4997 ,1247 ,1693 ,-1094 ,282 ,-611 ,2681 ,-3325 ,1446 ,600 ,-2327 ,3551 , -159 ,-3647 ,2799 ,-620 ,-1637 ,6112 ,-6150 ,141 ,5129 ,-5568 ,1044 ,4194 ,-1711 ,-4869 ,5199 , 1071 ,-5549 ,2948 ,3559 ,-3784 ,-2541 ,5968 ,-1429 ,-3835 ,3827 ,143 ,-4204 ,4728 ,1005 ,-5406 , 1911 ,3786 ,-2934 ,-1654 ,6331 ,-6616 ,-238 ,4764 ,-2921 ,1447 ,-210 ,489 ,-2023 ,2859 ,-79 , -3078 ,1646 ,68 ,90 ,217 ,51 ,-1343 ,3457 ,-1912 ,-2065 ,1929 ,363 ,3275 ,-6044 ,1154 , 5378 ,-6457 ,2240 ,3730 ,-4207 ,25 ,2012 ,-898 ,-938 ,3087 ,-1950 ,-1948 ,4252 ,-3015 ,-88 , 416 ,3284 ,-1601 ,-5466 ,8230 ,-3168 ,-3845 ,5062 ,1132 ,-5260 ,2273 ,4265 ,-6232 ,1018 ,3007 , 1049 ,-5329 ,3606 ,1489 ,-5772 ,7763 ,-4094 ,-1905 ,3610 ,-1247 ,410 ,-1426 ,1669 ,126 ,-1158 , 689 ,-81 ,-1256 ,4191 ,-2649 ,-2099 ,3885 ,-3004 ,585 ,1928 ,138 ,-3474 ,5176 ,-1095 ,-6178 , 5333 ,1322 ,-1056 ,-3334 ,3195 ,-315 ,-1257 ,1840 ,-1153 ,474 ,-805 ,2578 ,-3211 ,555 ,4634 , -5359 ,-343 ,5658 ,-3548 ,-1593 ,3123 ,-2776 ,2520 ,1144 ,-3940 ,1012 ,3260 ,-2111 ,-1547 ,2415 , -642 ,-1676 ,2195 ,2401 ,-5348 ,2030 ,2835 ,-4396 ,1244 ,1963 ,-187 ,-1542 ,330 ,2992 ,-4088 , 747 ,5322 ,-6070 ,-1680 ,5047 ,635 ,-5086 ,4429 ,1207 ,-7098 ,5468 ,2145 ,-5485 ,1449 ,4284 , -4295 ,-1051 ,4148 ,-848 ,-3687 ,3461 ,2389 ,-5523 ,2741 ,-266 ,-1201 ,3799 ,-2844 ,-1886 ,2600 , 2721 ,-4827 ,-484 ,6515 ,-5965 ,-324 ,6548 ,-6070 ,-894 ,6520 ,-3924 ,-3182 ,5907 ,-780 ,-5174 , 4229 ,2808 ,-6631 ,2376 ,4823 ,-5911 ,-99 ,3803 ,-1312 ,-471 ,-63 ,1153 ,-1024 ,511 ,3778 , -6895 ,2130 ,3111 ,-5547 ,5903 ,-606 ,-4255 ,3467 ,320 ,-2208 ,1625 ,-203 ,-314 ,577 ,-629 , 102 ,-1050 ,5083 ,-4315 ,-2073 ,6271 ,-4807 ,-457 ,4061 ,296 ,-4862 ,1118 ,4612 ,-2647 ,-3324 , 5576 ,-799 ,-5150 ,5599 ,-1645 ,-1331 ,304 ,3357 ,-2769 ,-2195 ,6578 ,-5920 ,1185 ,2018 ,167 , 668 ,-4796 ,4059 ,-495 ,-2336 ,4811 ,-2258 ,-3520 ,4544 ,1489 ,-5487 ,2454 ,3617 ,-5092 ,1560 , 303 ,-149 ,4071 ,-6266 ,1413 ,5380 ,-5853 ,-151 ,5183 ,-2389 ,-3550 ,5318 ,-1550 ,-2495 ,1750 , 240 ,3425 ,-5757 ,876 ,5353 ,-5833 ,1169 ,3497 ,-3410 ,630 ,1292 ,-1240 ,-64 ,745 ,2396 , -3593 ,504 ,1678 ,-1266 ,170 ,-669 ,4353 ,-4562 ,-887 ,3697 ,-786 ,-1071 ,571 ,4221 ,-7501 , 1502 ,5856 ,-5307 ,392 ,2947 ,-1954 ,-1528 ,4383 ,-2622 ,-1277 ,2854 ,-1595 ,-118 ,-506 ,3739 , -2234 ,-3166 ,5318 ,-2592 ,-1274 ,2983 ,-2817 ,1573 ,2516 ,-4909 ,1404 ,4464 ,-3292 ,-2580 ,2704 , 3008 ,-4389 ,-117 ,4474 ,-4240 ,-334 ,4754 ,-2878 ,-2895 ,5683 ,-1815 ,-3865 ,3849 ,2061 ,-4338 , -562 ,5749 ,-5178 ,1881 ,2628 ,-5423 ,2976 ,1640 ,-3277 ,1160 ,3387 ,-4215 ,816 ,1876 ,-2196 , 207 ,2966 ,-770 ,-4040 ,4717 ,-1470 ,-1704 ,2756 ,-1652 ,822 ,-1082 ,1310 ,1332 ,-3064 ,1384 , 478 ,-1954 ,3205 ,965 ,-5678 ,3199 ,4089 ,-6469 ,1914 ,3866 ,-5305 ,1049 ,4379 ,-2736 ,-3320 , 4071 ,1996 ,-4544 ,-350 ,4092 ,-1 ,-5154 ,4996 ,-637 ,-3596 ,6081 ,-5427 ,989 ,4988 ,-5165 , -744 ,4313 ,-402 ,-4492 ,3630 ,2107 ,-5745 ,3294 ,3298 ,-5946 ,1512 ,4519 ,-4478 ,-509 ,4220 , -3878 ,744 ,3508 ,-4138 ,-438 ,5025 ,-2025 ,-4152 ,3873 ,120 ,-926 ,903 ,-724 ,715 ,-639 , 630 ,253 ,-1215 ,690 ,623 ,-569 ,-324 ,1612 ,-1330 ,-162 ,535 ,1030 ,-157 ,-3292 ,5564 , -2190 ,-3725 ,3963 ,-503 ,-863 ,535 ,1548 ,-1844 ,-1482 ,3310 ,1296 ,-3988 ,-467 ,2886 ,1574 , -3055 ,-2108 ,5884 ,-1816 ,-3452 ,4275 ,-2792 ,5 ,4091 ,-3453 ,-1543 ,3274 ,869 ,-3093 ,244 , 1011 ,2538 ,-2293 ,-3416 ,7164 ,-4303 ,-1143 ,5227 ,-5193 ,444 ,3584 ,-510 ,-4565 ,4788 ,869 , -5090 ,1988 ,1707 ,1576 ,-5608 ,3752 ,1121 ,-2647 ,3030 ,-3390 ,1494 ,923 ,-1921 ,1025 ,2628 , -3823 ,-146 ,4183 ,-2635 ,-2305 ,3686 ,1441 ,-4908 ,1252 ,2292 ,91 ,-2332 ,1679 ,-53 ,-2672 , 4574 ,-2388 ,-2416 ,4411 ,-106 ,-4291 ,1985 ,2930 ,-3343 ,-40 ,4261 ,-3514 ,-1660 ,4047 ,-2600 , -663 ,1981 ,939 ,-2652 ,551 ,4855 ,-6654 ,457 ,4812 ,-4058 ,3749 ,-1219 ,-3818 ,3013 ,1930 , -2139 ,-1824 ,4198 ,-1491 ,-1804 ,755 ,2083 ,-492 ,-2643 ,2833 ,-1891 ,130 ,1611 ,-361 ,-525 , 273 ,689 ,-958 ,392 ,534 ,-39 ,-1782 ,3939 ,-3237 ,-428 ,3729 ,-5425 ,2381 ,2156 ,359 , -3911 ,345 ,5602 ,-5039 ,-991 ,5693 ,-4445 ,-1046 ,6415 ,-5308 ,-1358 ,5728 ,-2681 ,-2360 ,3572 , -2942 ,1767 ,2914 ,-5356 ,969 ,3470 ,-174 ,-4870 ,3432 ,2405 ,-4687 ,1918 ,1824 ,-3333 ,1605 , 3426 ,-4286 ,-1098 ,4097 ,480 ,-5031 ,4001 ,1230 ,-5704 ,4163 ,2222 ,-4300 ,228 ,4517 ,-3807 , -1779 ,5382 ,-2272 ,-1761 ,966 ,1226 ,1268 ,-2915 ,-434 ,2161 ,2408 ,-4309 ,-415 ,3505 ,-887 , -701 ,291 ,2436 ,-3526 ,31 ,2412 ,-1386 ,-491 ,2275 ,-121 ,-3710 ,3815 ,671 ,-3585 ,2206 , 997 ,-3043 ,1804 ,3043 ,-3980 ,-740 ,3259 ,702 ,-3581 ,-177 ,4243 ,-1164 ,-3764 ,3606 ,2243 , -6194 ,4046 ,-245 ,-97 ,1920 ,-4679 ,2273 ,612 ,1594 ,-3145 ,697 ,705 ,913 ,1789 ,-5475 , 3105 ,-40 ,901 ,-395 ,-1833 ,1534 ,-723 ,2954 ,-2276 ,-1217 ,2366 ,-1493 ,857 ,-749 ,908 , 826 ,-3201 ,3837 ,-826 ,-2484 ,2737 ,-1184 ,259 ,172 ,194 ,-1000 ,944 ,2264 ,-4745 ,2649 , 2325 ,-5176 ,3731 ,1611 ,-5043 ,2170 ,3616 ,-4487 ,435 ,2994 ,-2340 ,-103 ,1760 ,-1661 ,-511 , 4393 ,-3487 ,-1652 ,2622 ,1321 ,-1418 ,-1724 ,3970 ,-3866 ,534 ,4268 ,-5038 ,815 ,4247 ,-3274 , -1999 ,3423 ,1515 ,-4400 ,663 ,4639 ,-5405 ,1456 ,4476 ,-6425 ,3005 ,3003 ,-6048 ,2724 ,3174 , -4203 ,660 ,2601 ,-2359 ,423 ,1078 ,-1032 ,-642 ,1455 ,1229 ,-2220 ,-179 ,3268 ,-2477 ,-1778 , 5394 ,-4799 ,161 ,4707 ,-6082 ,2144 ,3794 ,-4107 ,-823 ,3094 ,-870 ,-222 ,417 ,306 ,2163 , -4437 ,401 ,1778 ,-786 ,3257 ,-3285 ,-488 ,2627 ,-1849 ,-676 ,3462 ,-1129 ,-3909 ,4224 ,1721 , -5071 ,905 ,5047 ,-4385 ,-1686 ,5437 ,-1561 ,-4242 ,4901 ,94 ,-4477 ,4152 ,-1132 ,-1053 ,228 , 2822 ,-236 ,-4762 ,3074 ,1583 ,-1487 ,-99 ,3174 ,-5132 ,898 ,5247 ,-6545 ,2726 ,3555 ,-5613 , 2243 ,2018 ,-3968 ,3732 ,-520 ,-2270 ,2050 ,-170 ,-800 ,-340 ,1477 ,128 ,-868 ,381 ,689 , -1000 ,664 ,-113 ,681 ,-2169 ,3611 ,358 ,-7758 ,7954 ,-663 ,-5353 ,4933 ,1194 ,-4637 ,1988 , 3072 ,-5230 ,2356 ,3468 ,-4724 ,3 ,2408 ,-735 ,3173 ,-5164 ,168 ,6141 ,-5921 ,609 ,3484 , -3022 ,702 ,-22 ,-594 ,3630 ,-3080 ,-2529 ,5901 ,-2769 ,-2847 ,6121 ,-4188 ,-767 ,3576 ,-2808 , 899 ,151 ,-1063 ,2924 ,-1412 ,-2180 ,2820 ,-2032 ,1955 ,-146 ,-2583 ,1522 ,2656 ,-2559 ,-2142 , 6516 ,-6500 ,1526 ,4889 ,-7011 ,3072 ,2384 ,-2657 ,-1231 ,3673 ,-1305 ,-2690 ,2922 ,-414 ,309 , -906 ,3723 ,-4102 ,-2046 ,7249 ,-5762 ,613 ,2564 ,-1711 ,-946 ,2652 ,327 ,-4395 ,4436 ,-568 , -2621 ,1183 ,3335 ,-2843 ,-2684 ,6272 ,-3382 ,-2434 ,4214 ,-825 ,-2739 ,3845 ,-78 ,-3983 ,3293 , -555 ,-705 ,863 ,-104 ,-283 ,-817 ,3083 ,-1642 ,-2619 ,4014 ,-213 ,-3783 ,3357 ,1460 ,-4747 , 2425 ,3003 ,-4584 ,911 ,2419 ,-1548 ,204 ,231 ,208 ,644 ,458 ,-2978 ,1173 ,1450 ,-828 , -480 ,337 ,2491 ,-3319 ,-404 ,3204 ,128 ,-3775 ,1894 ,3768 ,-4154 ,-833 ,2977 ,-2060 ,383 , 3594 ,-3545 ,-1782 ,3685 ,1284 ,-4875 ,2805 ,2013 ,-3756 ,385 ,2606 ,-396 ,-2665 ,4766 ,-4021 , 403 ,2667 ,-4625 ,4463 ,53 ,-4269 ,3359 ,1508 ,-2987 ,-602 ,2784 ,594 ,-3827 ,4084 ,-319 , -4821 ,4572 ,1562 ,-5140 ,3264 ,820 ,-3496 ,2282 ,1784 ,-766 ,-4159 ,5569 ,-464 ,-4858 ,2998 , 2828 ,-3005 ,-1610 ,5214 ,-3604 ,-1672 ,3925 ,341 ,-3178 ,1498 ,-456 ,257 ,3398 ,-5335 ,1457 , 3867 ,-4937 ,1958 ,3407 ,-5458 ,2028 ,2006 ,-2730 ,1653 ,-85 ,-273 ,-116 ,762 ,-702 ,-98 , 1004 ,-1266 ,2916 ,-2830 ,-1146 ,4702 ,-2969 ,-939 ,2070 ,-460 ,-353 ,47 ,637 ,-656 ,-440 , 2998 ,-3096 ,-141 ,2269 ,-1200 ,1408 ,-2041 ,1005 ,120 ,-582 ,1251 ,-1086 ,-866 ,3565 ,-1421 , -3124 ,4230 ,-2188 ,-1044 ,2422 ,1574 ,-3072 ,-1396 ,2951 ,-726 ,493 ,-35 ,4 ,-373 ,1065 , -139 ,-1110 ,260 ,-382 ,1183 ,-518 ,332 ,-928 ,531 ,2961 ,-3583 ,-786 ,3117 ,568 ,-2175 , -1681 ,3923 ,-238 ,-3731 ,2757 ,193 ,276 ,542 ,-3191 ,2525 ,111 ,-924 ,-364 ,1453 ,2158 , -5312 ,2342 ,3256 ,-4763 ,916 ,4347 ,-4445 ,-235 ,5174 ,-4901 ,-60 ,3403 ,-2017 ,-277 ,708 , -658 ,1956 ,-587 ,-2351 ,2409 ,-935 ,832 ,502 ,-2254 ,1776 ,703 ,-1678 ,849 ,218 ,-1762 , 3574 ,-896 ,-3909 ,4505 ,801 ,-4876 ,3088 ,2405 ,-5090 ,1655 ,4111 ,-4775 ,79 ,4797 ,-3726 , -1011 ,2016 ,1194 ,-679 ,-3249 ,4726 ,-882 ,-3922 ,5186 ,-3353 ,788 ,2955 ,-4057 ,509 ,2260 , 784 ,-3464 ,1724 ,-28 ,660 ,201 ,-2382 ,1904 ,1203 ,662 ,-4563 ,3206 ,826 ,-2825 ,2634 , -1100 ,190 ,-1261 ,2815 ,490 ,-4629 ,2651 ,2828 ,-3508 ,-944 ,5544 ,-4662 ,-1564 ,5860 ,-2955 , -1960 ,1526 ,3328 ,-3690 ,-1591 ,5674 ,-3757 ,-2123 ,5770 ,-2773 ,-2375 ,2464 ,831 ,-11 ,-2482 , 4303 ,-3937 ,-498 ,5323 ,-4955 ,897 ,1783 ,-1411 ,115 ,912 ,-1304 ,131 ,907 ,547 ,-1858 , 3535 ,-1252 ,-5427 ,7664 ,-4004 ,-1376 ,5398 ,-3572 ,-1329 ,1817 ,2612 ,-3859 ,-689 ,4905 ,-2655 , -2953 ,4303 ,853 ,-4847 ,2036 ,3601 ,-3994 ,-799 ,4004 ,-3094 ,2020 ,1866 ,-5632 ,2381 ,1338 , 837 ,-1952 ,-764 ,2628 ,-1609 ,351 ,207 ,-193 ,-1008 ,3331 ,-1670 ,-2499 ,3665 ,-1615 ,-395 , 1120 ,-388 ,-261 ,497 ,-1228 ,1449 ,627 ,-1012 ,-360 ,342 ,3212 ,-4509 ,-892 ,5416 ,-2392 , -2714 ,3987 ,-737 ,-3040 ,2672 ,1865 ,-2771 ,-1759 ,5384 ,-2355 ,-3113 ,4558 ,-1918 ,-1638 ,4010 , -1359 ,-3677 ,4662 ,270 ,-4401 ,2209 ,2769 ,-2226 ,-1754 ,2481 ,379 ,-1010 ,1166 ,-1492 ,-822 , 2978 ,-1978 ,-1077 ,4315 ,-2390 ,-2835 ,4425 ,-310 ,-2963 ,1129 ,2595 ,-2835 ,-599 ,4540 ,-3237 , -2180 ,4100 ,542 ,-4710 ,4167 ,55 ,-4740 ,5334 ,-149 ,-3601 ,773 ,3777 ,-1897 ,-2704 ,2092 , 2815 ,-3418 ,-866 ,4702 ,-4949 ,2474 ,1509 ,-3970 ,1753 ,2482 ,-1493 ,-2271 ,3809 ,-2716 ,-211 , 3281 ,-4107 ,2836 ,1232 ,-3979 ,1322 ,1694 ,773 ,-3281 ,2111 ,1818 ,-4723 ,2720 ,2300 ,-4222 , 1414 ,3503 ,-3508 ,-1266 ,2375 ,1949 ,-3052 ,-1414 ,5289 ,-2738 ,-2912 ,5195 ,-2211 ,-1588 ,2438 , -569 ,-1517 ,1453 ,1295 ,-2400 ,1929 ,-894 ,1396 ,-330 ,-3969 ,4335 ,1338 ,-4461 ,1933 ,992 , -94 ,533 ,-3520 ,4646 ,-2199 ,-1149 ,3191 ,-2971 ,790 ,1576 ,1052 ,-4214 ,2398 ,2445 ,-4944 , 2375 ,3015 ,-3761 ,-342 ,3921 ,-3270 ,467 ,1408 ,-1069 ,202 ,-613 ,2962 ,-3284 ,642 ,2710 , -3934 ,2045 ,1165 ,-1881 ,389 ,1085 ,-903 ,-50 ,-109 ,403 ,2869 ,-3116 ,-2294 ,4507 ,348 , -4093 ,1359 ,2957 ,-2274 ,-1126 ,2631 ,-1555 ,1472 ,1375 ,-5984 ,4028 ,2001 ,-4410 ,1971 ,1996 , -1627 ,-1078 ,1905 ,-1391 ,681 ,357 ,838 ,404 ,-3484 ,2590 ,268 ,-1139 ,757 ,122 ,-412 , 397 ,-898 ,365 ,3319 ,-4485 ,91 ,3664 ,-1584 ,-1224 ,216 ,2231 ,-2305 ,865 ,3090 ,-6004 , 1067 ,5103 ,-3823 ,-834 ,1921 ,1373 ,-500 ,-3092 ,2411 ,551 ,-1561 ,1687 ,-1550 ,1096 ,1275 , -1847 ,-459 ,1292 ,1028 ,-1905 ,253 ,314 ,1583 ,-964 ,-1295 ,492 ,1360 ,1139 ,-3516 ,2000 , 825 ,-1818 ,169 ,2807 ,-1494 ,-2773 ,4170 ,-812 ,-3313 ,4019 ,538 ,-4096 ,1745 ,1205 ,-174 , -1014 ,3430 ,-3024 ,-1955 ,4472 ,-3017 ,178 ,1335 ,1928 ,-2722 ,-1798 ,3073 ,1134 ,-2696 ,-141 , 3081 ,-3131 ,1210 ,414 ,-1095 ,2338 ,-2621 ,88 ,3438 ,-2589 ,-1971 ,3887 ,107 ,-4529 ,3875 , 1422 ,-4995 ,2414 ,2022 ,-1597 ,-1534 ,2758 ,287 ,-4073 ,4136 ,-83 ,-3821 ,3187 ,-409 ,-906 , -173 ,1710 ,1389 ,-4278 ,2098 ,-50 ,-220 ,2467 ,-3519 ,1386 ,813 ,-939 ,-338 ,558 ,2641 , -3752 ,284 ,3149 ,-3635 ,1307 ,2459 ,-3373 ,1068 ,1163 ,-2252 ,1465 ,2594 ,-3510 ,-1225 ,5030 , -2734 ,-1796 ,3003 ,-380 ,-1140 ,-345 ,2102 ,-584 ,-2537 ,2757 ,1715 ,-3972 ,136 ,4588 ,-3367 , -1728 ,4661 ,-2549 ,-1045 ,1354 ,1454 ,-1447 ,-1535 ,3943 ,-2809 ,-50 ,1716 ,-1430 ,-545 ,3011 , -331 ,-4745 ,5116 ,28 ,-4526 ,3471 ,1861 ,-3858 ,1756 ,635 ,-1689 ,2164 ,-2832 ,3172 ,14 , -3005 ,1790 ,-329 ,2624 ,-2916 ,-1410 ,4226 ,-1022 ,-3135 ,3329 ,-237 ,-2884 ,4484 ,-1934 ,-1850 , 969 ,2831 ,-1738 ,-2560 ,4861 ,-3386 ,-711 ,2986 ,714 ,-3708 ,504 ,4412 ,-4585 ,653 ,2408 , -1158 ,-2013 ,2840 ,633 ,-3022 ,939 ,928 ,1954 ,-3449 ,1256 ,-368 ,502 ,2657 ,-4226 ,698 , 2232 ,-326 ,-2033 ,4124 ,-2785 ,-2429 ,4969 ,-2293 ,-1560 ,3011 ,211 ,-3827 ,3567 ,120 ,-3345 , 3046 ,1386 ,-2996 ,-958 ,4075 ,-1124 ,-3527 ,3787 ,1066 ,-4898 ,3371 ,2244 ,-4883 ,1279 ,3724 , -2983 ,-1911 ,5120 ,-2922 ,-2188 ,5843 ,-4425 ,-707 ,5046 ,-4351 ,29 ,3151 ,-1610 ,-2130 ,2889 , 1377 ,-3870 ,639 ,2407 ,-627 ,-1572 ,3880 ,-3395 ,-2147 ,5185 ,-1703 ,-1925 ,1782 ,2299 ,-4792 , 1614 ,3906 ,-4916 ,504 ,3760 ,-2517 ,-1231 ,2739 ,-981 ,-1783 ,2456 ,712 ,-2826 ,2673 ,-979 , -2331 ,3926 ,-602 ,-2832 ,2457 ,316 ,-1807 ,1374 ,-17 ,-463 ,31 ,1071 ,-1030 ,-344 ,2057 , -1769 ,-937 ,3808 ,-1800 ,-2726 ,3014 ,351 ,-53 ,-2517 ,1434 ,2636 ,-3658 ,1150 ,1219 ,-1349 , 714 ,146 ,-297 ,95 ,518 ,-1216 ,948 ,2128 ,-3110 ,-248 ,2980 ,-1268 ,-1485 ,2172 ,-1224 , 863 ,21 ,-1903 ,3170 ,-2500 ,2284 ,294 ,-3810 ,3016 ,-1131 ,1322 ,326 ,-2520 ,2338 ,-678 , -103 ,262 ,-646 ,2120 ,-2062 ,269 ,1923 ,-2992 ,1476 ,2885 ,-4196 ,1001 ,2481 ,-2622 ,-446 , 3268 ,-1007 ,-3339 ,5288 ,-2398 ,-2170 ,2272 ,815 ,-210 ,-1924 ,1644 ,50 ,-1036 ,601 ,1874 , -2245 ,-145 ,568 ,1995 ,-1109 ,-3035 ,4537 ,-1011 ,-2728 ,2668 ,484 ,-3019 ,2361 ,1820 ,-4051 , 1125 ,3415 ,-3335 ,-439 ,2901 ,-1557 ,-1283 ,2356 ,-171 ,-2477 ,2058 ,662 ,-1103 ,-35 ,2007 , -1583 ,-1063 ,1807 ,-1286 ,846 ,-22 ,-609 ,-74 ,2533 ,-832 ,-3675 ,3391 ,1504 ,-3724 ,1275 , 3430 ,-5134 ,986 ,4365 ,-5194 ,2474 ,2102 ,-4542 ,1514 ,3471 ,-3307 ,-1049 ,4130 ,-2137 ,-1364 , 1008 ,1969 ,-1545 ,-1531 ,2055 ,1655 ,-2329 ,-1521 ,3766 ,-2507 ,779 ,1072 ,-3019 ,2776 ,1299 , -4348 ,3041 ,1590 ,-5163 ,3417 ,2065 ,-3935 ,228 ,4108 ,-3283 ,-1117 ,3883 ,-2868 ,42 ,539 , 1542 ,-722 ,-1972 ,3515 ,-3281 ,399 ,1527 ,-164 ,-475 ,733 ,1507 ,-5101 ,4285 ,-459 ,-2509 , 3440 ,-1910 ,-790 ,2527 ,242 ,-3796 ,3344 ,49 ,-2888 ,3139 ,-79 ,-2344 ,770 ,2804 ,-2676 , -1204 ,3792 ,-744 ,-3551 ,3501 ,1149 ,-5021 ,3976 ,698 ,-3535 ,1608 ,2380 ,-1666 ,-2475 ,4643 , -1436 ,-3387 ,3708 ,672 ,-3747 ,1916 ,2826 ,-4631 ,1735 ,1447 ,-1194 ,1681 ,-3113 ,3561 ,-1111 , -3538 ,4177 ,-1990 ,2553 ,-1023 ,-3058 ,2787 ,1557 ,-1913 ,-1784 ,4657 ,-2379 ,-1850 ,2963 ,-1828 , 669 ,1481 ,-2949 ,2311 ,439 ,-2706 ,3808 ,-2442 ,-1009 ,3445 ,-2768 ,1090 ,1190 ,-3270 ,3196 , 352 ,-3681 ,2816 ,1841 ,-3920 ,841 ,3437 ,-2610 ,-963 ,1931 ,-260 ,-1562 ,2514 ,96 ,-2969 , 1418 ,2677 ,-1841 ,-2530 ,3112 ,1032 ,-3270 ,1547 ,1974 ,-3711 ,3522 ,-427 ,-4136 ,4701 ,-1046 , -1484 ,1404 ,235 ,-1002 ,-114 ,2616 ,-2903 ,89 ,3857 ,-3787 ,-605 ,4360 ,-3650 ,307 ,3378 , -4220 ,1232 ,2431 ,-2169 ,-968 ,2588 ,3 ,-3044 ,2114 ,531 ,-651 ,632 ,-544 ,876 ,-1496 , 2191 ,1032 ,-5989 ,3006 ,3509 ,-3744 ,539 ,1294 ,-1549 ,1885 ,-1325 ,-867 ,3631 ,-2521 ,-897 , 970 ,1416 ,-256 ,-2883 ,3026 ,171 ,-1959 ,116 ,2124 ,265 ,-3150 ,2770 ,-827 ,-1649 ,4181 , -2450 ,-1887 ,2481 ,927 ,-1696 ,-1015 ,4059 ,-2129 ,-3417 ,4940 ,-780 ,-3351 ,4040 ,-542 ,-3075 , 2210 ,2284 ,-3668 ,803 ,3420 ,-5300 ,3540 ,1022 ,-3742 ,1579 ,1840 ,-202 ,-3673 ,4908 ,-1752 , -2848 ,3512 ,-775 ,11 ,117 ,1135 ,-2595 ,1106 ,1250 ,-2121 ,943 ,2049 ,-1440 ,-2298 ,4402 , -1483 ,-3075 ,3202 ,1170 ,-3530 ,851 ,3494 ,-2969 ,-1579 ,4290 ,-1149 ,-3383 ,3589 ,-1456 ,1677 , 341 ,-4001 ,2337 ,1740 ,-468 ,-2214 ,1469 ,538 ,-834 ,596 ,-269 ,312 ,-204 ,168 ,103 , -431 ,873 ,-758 ,538 ,412 ,-1032 ,709 ,-71 ,-81 ,-881 ,3203 ,-2134 ,-1991 ,2759 ,265 , -82 ,-2779 ,3936 ,-754 ,-3465 ,3787 ,-1421 ,-718 ,2760 ,-1938 ,-871 ,1193 ,473 ,856 ,-2646 , 1961 ,1872 ,-4229 ,1987 ,1362 ,-2774 ,1653 ,1799 ,-2339 ,-171 ,1584 ,-879 ,415 ,-806 ,1342 , 730 ,-2914 ,2012 ,1161 ,-2049 ,430 ,1202 ,-2161 ,2417 ,-60 ,-2187 ,3435 ,-2502 ,-266 ,1912 , -2162 ,1529 ,1998 ,-3661 ,756 ,1985 ,-746 ,-370 ,-61 ,2304 ,-2677 ,-210 ,1701 ,-1070 ,655 , -19 ,-123 ,109 ,-978 ,1982 ,771 ,-3985 ,2647 ,2026 ,-4314 ,1991 ,2353 ,-3501 ,94 ,3272 , -1322 ,-2954 ,3249 ,994 ,-3703 ,1120 ,2628 ,-1342 ,-2665 ,3501 ,698 ,-4592 ,3741 ,-430 ,-2275 , 3576 ,-1812 ,-1659 ,2047 ,1808 ,-3925 ,1641 ,1936 ,-4273 ,4029 ,-356 ,-3111 ,1863 ,2295 ,-2693 , -1149 ,4183 ,-2448 ,-1234 ,2530 ,-888 ,-908 ,1534 ,-921 ,-380 ,546 ,1489 ,-1949 ,409 ,3337 , -5296 ,1451 ,1549 ,1258 ,-1915 ,-2371 ,3425 ,-376 ,1178 ,-3179 ,1292 ,1164 ,-1801 ,2413 ,-1170 , -1309 ,2313 ,-373 ,-1293 ,813 ,-561 ,914 ,743 ,-1375 ,17 ,2457 ,-2830 ,1573 ,66 ,-2619 , 3571 ,-2105 ,-3 ,1386 ,934 ,-2505 ,5 ,2545 ,-2091 ,299 ,-235 ,2765 ,-1739 ,-2726 ,4511 , -1304 ,-2624 ,3210 ,383 ,-3199 ,1666 ,2169 ,-2909 ,612 ,1483 ,-1280 ,112 ,856 ,-1017 ,-224 , 3106 ,-2676 ,-1452 ,3227 ,-1192 ,782 ,404 ,-3471 ,3357 ,486 ,-2516 ,922 ,430 ,1982 ,-3082 , 850 ,1459 ,-1451 ,-182 ,1458 ,557 ,-3358 ,3803 ,-1024 ,-2636 ,3422 ,550 ,-3408 ,869 ,3407 , -3020 ,-418 ,1402 ,1947 ,-2834 ,-396 ,2585 ,-2952 ,1660 ,821 ,-786 ,-196 ,684 ,180 ,-1075 , 1022 ,823 ,-2147 ,1474 ,1486 ,-4500 ,3389 ,1341 ,-3283 ,1067 ,254 ,806 ,-51 ,424 ,-466 , -1215 ,968 ,137 ,-880 ,2763 ,-1264 ,-2625 ,4243 ,-1982 ,-1195 ,2011 ,-497 ,-1224 ,1548 ,1464 , -3258 ,455 ,2741 ,-712 ,-3273 ,3436 ,1070 ,-4170 ,1662 ,3167 ,-3579 ,-178 ,3669 ,-3761 ,749 , 1264 ,1388 ,-2622 ,-826 ,4307 ,-4509 ,2626 ,801 ,-3225 ,2556 ,409 ,-1677 ,-497 ,3655 ,-2877 , -355 ,3279 ,-4430 ,2825 ,1835 ,-4668 ,2382 ,2391 ,-3480 ,133 ,2065 ,-103 ,-1146 ,2 ,2597 , -2905 ,215 ,2976 ,-2983 ,-732 ,3046 ,-665 ,-2529 ,3393 ,-711 ,-2825 ,3017 ,1043 ,-3637 ,1638 , 2983 ,-4759 ,1424 ,3255 ,-3197 ,-340 ,1185 ,1232 ,76 ,-3144 ,1820 ,2450 ,-2915 ,346 ,879 , -720 ,1501 ,-1931 ,225 ,2937 ,-2305 ,-1499 ,2225 ,1611 ,-3508 ,1569 ,1918 ,-3791 ,2618 ,488 , -1802 ,96 ,1894 ,411 ,-3746 ,3488 ,-258 ,-2730 ,3968 ,-2159 ,-1434 ,3048 ,-151 ,-2853 ,1710 , 2285 ,-3119 ,-236 ,2408 ,499 ,-3161 ,1770 ,2437 ,-3834 ,1335 ,977 ,-1101 ,910 ,-1185 ,1725 , -43 ,-1784 ,451 ,1517 ,799 ,-3636 ,2770 ,640 ,-2481 ,1152 ,651 ,837 ,-2593 ,1705 ,608 , -2460 ,3209 ,-192 ,-3566 ,3103 ,1328 ,-2678 ,-635 ,2621 ,451 ,-3000 ,1814 ,121 ,337 ,-182 , -1219 ,1381 ,-118 ,-1415 ,2717 ,-820 ,-2218 ,3763 ,-2562 ,-440 ,1135 ,1442 ,-1291 ,-1725 ,3374 , -2147 ,197 ,869 ,-632 ,93 ,-632 ,2084 ,-151 ,-3019 ,2926 ,1198 ,-4543 ,2746 ,1788 ,-3021 , 664 ,892 ,955 ,-1490 ,-672 ,1884 ,-653 ,-1135 ,1519 ,1300 ,-3262 ,972 ,2630 ,-2210 ,-1302 , 2325 ,1325 ,-3889 ,1435 ,3165 ,-4411 ,866 ,3237 ,-2581 ,-1303 ,2199 ,1209 ,-3596 ,3010 ,529 , -4204 ,4214 ,-1875 ,234 ,1655 ,-2629 ,1805 ,-911 ,1038 ,-178 ,-1740 ,2562 ,-1324 ,954 ,271 , -2649 ,2288 ,-54 ,-873 ,844 ,-720 ,186 ,1091 ,-330 ,-346 ,-1392 ,2136 ,608 ,-2800 ,1287 , 400 ,1287 ,-1999 ,835 ,1813 ,-4315 ,2276 ,2300 ,-2483 ,-784 ,1716 ,1609 ,-2486 ,-653 ,2224 , -782 ,-1071 ,1712 ,563 ,-2203 ,1369 ,66 ,-609 ,958 ,-807 ,-321 ,981 ,2019 ,-4158 ,1243 , 3445 ,-4582 ,1454 ,1701 ,-1600 ,302 ,1879 ,-1960 ,-283 ,1068 ,-1218 ,2105 ,-1143 ,-966 ,1077 , 1747 ,-2046 ,-963 ,1953 ,-183 ,233 ,-331 ,86 ,-831 ,1047 ,-73 ,-553 ,-216 ,2022 ,-294 , -3071 ,3522 ,-734 ,-1746 ,2138 ,-873 ,196 ,-556 ,385 ,1231 ,-1346 ,2331 ,-2603 ,-991 ,4213 , -2594 ,-491 ,1301 ,-1234 ,2226 ,-70 ,-2429 ,1489 ,-342 ,1215 ,-804 ,-1347 ,3446 ,-1625 ,-2047 , 2628 ,132 ,-1672 ,948 ,606 ,-1174 ,163 ,2134 ,-1598 ,-821 ,1429 ,-194 ,-879 ,846 ,1723 , -3453 ,1615 ,2460 ,-3716 ,613 ,2471 ,-1136 ,-1536 ,1999 ,792 ,-3095 ,2226 ,1589 ,-3730 ,1652 , -173 ,1123 ,-44 ,-876 ,1906 ,-3523 ,2934 ,135 ,-2405 ,2489 ,-656 ,-1523 ,2639 ,-163 ,-3391 , 3856 ,-411 ,-2924 ,2425 ,1753 ,-3839 ,1578 ,2382 ,-3721 ,1086 ,1463 ,815 ,-3614 ,2333 ,2054 , -4920 ,3135 ,1284 ,-2436 ,-413 ,2815 ,-605 ,-2635 ,2666 ,-147 ,-2060 ,2173 ,1140 ,-3678 ,2308 , 1692 ,-3527 ,1068 ,1542 ,663 ,-2590 ,227 ,1827 ,-1187 ,2193 ,-1844 ,-1242 ,2516 ,-1093 ,46 , 386 ,-62 ,-260 ,-117 ,1605 ,-1336 ,-1259 ,3136 ,-817 ,-2872 ,3982 ,-978 ,-3051 ,3918 ,-359 , -2999 ,2179 ,1884 ,-3500 ,833 ,3096 ,-3723 ,461 ,3310 ,-2645 ,-1301 ,2964 ,343 ,-3420 ,2352 , 1840 ,-4456 ,2882 ,1669 ,-3641 ,846 ,2262 ,-1121 ,-1493 ,3488 ,-2521 ,-1933 ,4797 ,-2589 ,-1529 , 4125 ,-2056 ,-2406 ,3484 ,313 ,-3167 ,2081 ,1297 ,-2689 ,1594 ,88 ,-667 ,-375 ,2374 ,-794 , -3128 ,4937 ,-2505 ,-1843 ,3422 ,-466 ,-1883 ,860 ,2485 ,-3312 ,126 ,3462 ,-2355 ,-1910 ,3553 , -602 ,-2224 ,2535 ,-1617 ,590 ,1826 ,-2578 ,196 ,1116 ,-192 ,985 ,-984 ,-531 ,2495 ,-2551 , -118 ,1757 ,-937 ,364 ,-85 ,-486 ,693 ,2044 ,-3638 ,858 ,3304 ,-4039 ,878 ,2731 ,-2215 , -802 ,2425 ,-1116 ,-781 ,1561 ,-917 ,460 ,-715 ,1050 ,622 ,-1924 ,1177 ,-429 ,1142 ,-574 , -707 ,544 ,222 ,933 ,-2003 ,932 ,1137 ,-1383 ,293 ,200 ,-758 ,2203 ,-512 ,-1780 ,755 , 748 ,-554 ,-282 ,2347 ,-2633 ,-725 ,3731 ,-2045 ,-1186 ,2216 ,-1677 ,502 ,413 ,737 ,602 , -4021 ,3264 ,888 ,-2576 ,1195 ,-635 ,1829 ,-860 ,-1495 ,1995 ,-817 ,-653 ,1584 ,-116 ,-2348 , 2404 ,1038 ,-3311 ,1761 ,1272 ,-2235 ,1053 ,587 ,-1506 ,1938 ,-540 ,-1008 ,722 ,-363 ,1869 , -1307 ,-1674 ,2939 ,-293 ,-1738 ,686 ,551 ,346 ,-351 ,-1223 ,1399 ,1466 ,-2363 ,-265 ,1294 , 1423 ,-2029 ,-9 ,968 ,-1522 ,3193 ,-2155 ,-1637 ,3392 ,-450 ,-2789 ,2084 ,1788 ,-3245 ,978 , 1984 ,-2577 ,405 ,2559 ,-2212 ,-441 ,1420 ,912 ,-1612 ,-831 ,2000 ,-712 ,-409 ,934 ,-898 , -44 ,2248 ,-2080 ,-1112 ,3033 ,-71 ,-2592 ,756 ,1192 ,1 ,115 ,-379 ,-961 ,540 ,2005 , -1888 ,-492 ,1154 ,895 ,-1091 ,-1025 ,2233 ,-847 ,-764 ,1073 ,-1141 ,1533 ,990 ,-3273 ,1244 , 2222 ,-2190 ,-91 ,1714 ,-1127 ,-34 ,672 ,-219 ,-794 ,1102 ,1356 ,-2317 ,-527 ,2534 ,178 , -2892 ,1643 ,1484 ,-2656 ,2648 ,278 ,-4241 ,4073 ,341 ,-3879 ,2955 ,1277 ,-3020 ,889 ,2236 , -3264 ,2358 ,344 ,-2725 ,2077 ,-415 ,2213 ,-2900 ,-144 ,2928 ,-3254 ,3035 ,-1948 ,-59 ,2500 , -2724 ,833 ,-179 ,2218 ,-1776 ,-1767 ,3689 ,-1221 ,-1950 ,1742 ,554 ,-1176 ,1454 ,-364 ,-1629 , 707 ,2054 ,-1241 ,-1124 ,1328 ,-1125 ,2201 ,-335 ,-3329 ,3842 ,-41 ,-3049 ,1994 ,-7 ,1576 , -1558 ,-1906 ,3459 ,-1107 ,-1116 ,1495 ,-956 ,9 ,1958 ,-1573 ,-1149 ,1784 ,1184 ,-2244 ,-277 , 2715 ,-1231 ,-1810 ,2016 ,1408 ,-3089 ,709 ,2803 ,-2746 ,-485 ,3522 ,-2100 ,-1532 ,2579 ,-890 , -407 ,946 ,-447 ,43 ,165 ,128 ,-474 ,-170 ,2277 ,-1312 ,-2028 ,2860 ,-411 ,-1979 ,2618 , -211 ,-2088 ,1757 ,44 ,-1446 ,2154 ,-389 ,-1974 ,2278 ,-133 ,-1741 ,967 ,2227 ,-2943 ,125 , 3364 ,-3581 ,210 ,1867 ,549 ,-2271 ,-80 ,3663 ,-3445 ,178 ,1287 ,546 ,178 ,-2586 ,1763 , -683 ,1633 ,46 ,-3142 ,3086 ,712 ,-2880 ,1105 ,2220 ,-2943 ,388 ,2498 ,-1736 ,-1485 ,2970 , -110 ,-3064 ,3437 ,-1783 ,120 ,1645 ,-2662 ,2390 ,-823 ,-338 ,186 ,412 ,962 ,-2284 ,1415 , 686 ,-1039 ,-228 ,1161 ,91 ,-2081 ,2606 ,94 ,-3095 ,2552 ,1382 ,-3145 ,594 ,2793 ,-1991 , -1704 ,3955 ,-1823 ,-2184 ,4046 ,-1819 ,-1657 ,2097 ,1229 ,-2172 ,-187 ,1583 ,-1498 ,511 ,2174 , -2287 ,-810 ,3599 ,-2493 ,-1432 ,2840 ,290 ,-2452 ,1629 ,301 ,-2245 ,3310 ,-821 ,-2370 ,2036 , 1588 ,-2941 ,347 ,3284 ,-3094 ,-1024 ,3609 ,-1670 ,-1247 ,3354 ,-2464 ,-1236 ,2587 ,332 ,-1642 , -978 ,2830 ,-263 ,-2347 ,2269 ,-863 ,-822 ,2751 ,-2356 ,276 ,710 ,-478 ,1006 ,-1101 ,-87 , 505 ,1031 ,-1286 ,-314 ,1258 ,-859 ,282 ,178 ,-221 ,280 ,-963 ,1405 ,813 ,-2935 ,1288 , 2413 ,-3046 ,89 ,3079 ,-2506 ,-793 ,1771 ,847 ,-1651 ,-1018 ,3675 ,-1814 ,-1561 ,1370 ,65 , 961 ,-1653 ,733 ,-143 ,-82 ,1641 ,-2263 ,213 ,2580 ,-1660 ,-1674 ,3233 ,-1464 ,-946 ,1620 , -596 ,-70 ,-167 ,48 ,655 ,1593 ,-3752 ,1755 ,2523 ,-4186 ,1480 ,2538 ,-2576 ,-640 ,3085 , -1978 ,-400 ,642 ,522 ,705 ,-1994 ,1119 ,115 ,-981 ,2240 ,-917 ,-1417 ,1605 ,-608 ,345 , -286 ,447 ,227 ,-1206 ,1409 ,-129 ,-797 ,776 ,-99 ,-27 ,-313 ,415 ,1157 ,-1945 ,506 , 1534 ,-1298 ,-333 ,1132 ,175 ,-1418 ,596 ,2049 ,-2331 ,60 ,1859 ,-1935 ,1612 ,-429 ,-725 , 215 ,1070 ,584 ,-2593 ,1989 ,70 ,-1085 ,1073 ,-422 ,-489 ,1639 ,-105 ,-2163 ,2197 ,-432 , -1453 ,2794 ,-1048 ,-1931 ,2188 ,1241 ,-3304 ,1448 ,2310 ,-2945 ,45 ,1606 ,966 ,-2801 ,1170 , 2240 ,-3219 ,554 ,2551 ,-2191 ,-707 ,3407 ,-2619 ,-758 ,2219 ,-24 ,-1131 ,-263 ,2971 ,-2995 , -129 ,2831 ,-3082 ,1326 ,725 ,-312 ,295 ,-1590 ,1216 ,755 ,-1232 ,429 ,516 ,-649 ,812 , -803 ,166 ,435 ,665 ,-295 ,-1287 ,621 ,397 ,1406 ,-2054 ,-309 ,1996 ,-19 ,-2127 ,972 , 2378 ,-2935 ,28 ,2213 ,-237 ,-2459 ,2203 ,1181 ,-3086 ,1568 ,271 ,-667 ,802 ,-72 ,-527 , 498 ,108 ,-328 ,445 ,-276 ,429 ,-790 ,1002 ,454 ,-1701 ,1643 ,-826 ,-453 ,2677 ,-2506 , -497 ,3060 ,-2096 ,-652 ,1338 ,1406 ,-2079 ,-608 ,2964 ,-2109 ,-682 ,1888 ,671 ,-2560 ,911 , 2467 ,-3191 ,373 ,2780 ,-2459 ,28 ,2138 ,-2642 ,1028 ,2023 ,-2631 ,918 ,304 ,-638 ,1612 , -1962 ,1483 ,181 ,-2275 ,2969 ,-505 ,-2004 ,1896 ,35 ,-1103 ,947 ,-50 ,-312 ,306 ,114 , -543 ,683 ,749 ,-2314 ,1664 ,1614 ,-2560 ,-306 ,2484 ,92 ,-3288 ,2727 ,771 ,-3059 ,1747 , 1923 ,-2597 ,-209 ,3091 ,-2562 ,-725 ,2564 ,-87 ,-2723 ,2452 ,929 ,-3869 ,3419 ,258 ,-2728 , 1457 ,799 ,-258 ,-709 ,826 ,336 ,-1050 ,538 ,1387 ,-1211 ,-1235 ,1234 ,-125 ,1290 ,-913 , -873 ,1565 ,-819 ,270 ,48 ,196 ,-415 ,164 ,1181 ,-1501 ,-388 ,2550 ,-1250 ,-1782 ,3409 , -1406 ,-2320 ,3441 ,-399 ,-2167 ,925 ,1866 ,-938 ,-2042 ,3254 ,-651 ,-2389 ,1814 ,1220 ,-1202 , -1305 ,2528 ,-1677 ,60 ,2294 ,-2564 ,78 ,1736 ,-768 ,33 ,-17 ,22 ,1821 ,-2789 ,-70 , 1932 ,-455 ,78 ,-99 ,491 ,-1232 ,756 ,259 ,-276 ,28 ,-205 ,1447 ,-1713 ,-259 ,2601 , -1545 ,-1589 ,2109 ,986 ,-2652 ,296 ,2855 ,-2270 ,-1189 ,3154 ,-1019 ,-2408 ,3032 ,-261 ,-2558 , 2610 ,626 ,-2597 ,503 ,1219 ,-85 ,-879 ,1008 ,768 ,-3044 ,2874 ,-87 ,-2736 ,2881 ,-543 , -1585 ,1658 ,1113 ,-3090 ,2073 ,1263 ,-3523 ,2059 ,1528 ,-2081 ,-797 ,3247 ,-1730 ,-1608 ,2980 , -1787 ,708 ,518 ,-1661 ,1357 ,223 ,-598 ,8 ,-392 ,1836 ,-515 ,-1911 ,1669 ,274 ,291 , -1368 ,474 ,874 ,-1644 ,2220 ,-148 ,-2018 ,929 ,929 ,59 ,-1389 ,125 ,2438 ,-1839 ,-1001 , 1490 ,495 ,314 ,-1985 ,1008 ,689 ,-835 ,423 ,-685 ,2064 ,-1178 ,-1072 ,1530 ,-1019 ,1396 , -1208 ,357 ,569 ,-791 ,1566 ,-1865 ,547 ,1067 ,-986 ,255 ,237 ,-857 ,1685 ,208 ,-2488 , 1306 ,1886 ,-1717 ,-1266 ,2417 ,-1268 ,1372 ,194 ,-2833 ,2147 ,-604 ,1400 ,-376 ,-1549 ,1829 , -864 ,157 ,-461 ,1469 ,73 ,-2172 ,1992 ,-256 ,-802 ,1027 ,-263 ,-356 ,658 ,-317 ,251 , -542 ,423 ,1427 ,-1535 ,-535 ,790 ,1402 ,-1123 ,-1709 ,2850 ,-88 ,-2934 ,3533 ,-1160 ,-1575 , 2899 ,-1871 ,-387 ,1344 ,504 ,-1220 ,-527 ,1273 ,1198 ,-2281 ,425 ,2129 ,-2578 ,431 ,2547 , -1999 ,-1054 ,1870 ,105 ,-607 ,-305 ,1440 ,-1092 ,-75 ,230 ,1501 ,-631 ,-2529 ,2401 ,-194 , 304 ,-786 ,467 ,-135 ,220 ,1004 ,-1929 ,1390 ,122 ,-575 ,203 ,-346 ,482 ,1421 ,-1939 , -303 ,3069 ,-2742 ,-153 ,2160 ,-1695 ,474 ,417 ,-227 ,-217 ,-139 ,1897 ,-1629 ,-916 ,2658 , -1255 ,-1104 ,2030 ,-581 ,-894 ,1142 ,-301 ,-173 ,376 ,-80 ,-33 ,186 ,5 ,-36 ,199 , -768 ,1422 ,323 ,-2561 ,2194 ,866 ,-2160 ,918 ,435 ,-558 ,-10 ,1257 ,-702 ,-1229 ,2267 , -1148 ,-610 ,2035 ,-2142 ,877 ,2032 ,-2968 ,326 ,2814 ,-2300 ,-693 ,2619 ,-1495 ,-561 ,1455 , -850 ,194 ,440 ,-529 ,369 ,-464 ,1048 ,-187 ,-1476 ,2270 ,-880 ,-1576 ,2976 ,-1271 ,-1773 , 3260 ,-1115 ,-2165 ,2600 ,633 ,-3118 ,2213 ,465 ,-2123 ,2685 ,-1584 ,-489 ,709 ,1189 ,-221 , -2679 ,2914 ,247 ,-2474 ,1755 ,549 ,-1431 ,778 ,177 ,-823 ,714 ,780 ,-755 ,-427 ,1281 , -118 ,-1813 ,2381 ,366 ,-2921 ,762 ,2089 ,-1041 ,-962 ,2594 ,-2194 ,-698 ,2627 ,-406 ,-1843 , 922 ,1487 ,-1994 ,1024 ,8 ,-605 ,327 ,1339 ,-422 ,-2487 ,3189 ,-371 ,-1998 ,1649 ,-519 , -309 ,1961 ,-1099 ,-1889 ,2877 ,-267 ,-2331 ,2019 ,938 ,-2306 ,531 ,2324 ,-2366 ,-219 ,2535 , -1725 ,-779 ,1573 ,853 ,-2327 ,837 ,2359 ,-3025 ,-109 ,2775 ,-1135 ,-1693 ,2871 ,-1648 ,-1132 , 3460 ,-2134 ,-930 ,1689 ,-99 ,-218 ,34 ,-382 ,435 ,-38 ,67 ,-130 ,-471 ,1655 ,-1378 , 472 ,938 ,-2399 ,1272 ,1612 ,-1761 ,-887 ,2515 ,-380 ,-2479 ,2115 ,1178 ,-2619 ,288 ,2555 , -1764 ,-1416 ,3255 ,-2052 ,-400 ,2473 ,-2237 ,-105 ,1165 ,597 ,-1488 ,189 ,1674 ,-1373 ,-509 , 2299 ,-1286 ,-1452 ,2172 ,-827 ,-512 ,1191 ,311 ,-1848 ,1198 ,925 ,-2196 ,2292 ,-337 ,-2215 , 2240 ,507 ,-1786 ,149 ,1287 ,-167 ,-1113 ,1806 ,128 ,-2553 ,1589 ,529 ,-1114 ,1107 ,-77 , -992 ,436 ,1844 ,-1547 ,-1417 ,2843 ,-885 ,-1393 ,1742 ,-347 ,-612 ,760 ,-220 ,-267 ,-50 , 1412 ,-239 ,-2352 ,2597 ,-429 ,-1554 ,2675 ,-1688 ,-501 ,1812 ,-694 ,-882 ,712 ,1301 ,-1630 , 51 ,1345 ,-1552 ,978 ,982 ,-1796 ,781 ,517 ,-966 ,1266 ,-502 ,-990 ,2034 ,-623 ,-1663 , 1814 ,863 ,-2449 ,962 ,1387 ,-1628 ,1783 ,-1401 ,-695 ,2681 ,-2046 ,-151 ,1744 ,-918 ,-47 , 44 ,-388 ,1736 ,-1103 ,-719 ,1345 ,-1270 ,1305 ,702 ,-2304 ,762 ,2134 ,-1832 ,-872 ,2650 , -1125 ,-1578 ,2259 ,-768 ,-848 ,2525 ,-2120 ,-477 ,2385 ,-1891 ,255 ,1956 ,-2033 ,-348 ,2103 , -1039 ,-849 ,1032 ,1396 ,-2369 ,405 ,1491 ,-1666 ,2533 ,-1892 ,-864 ,1332 ,822 ,-417 ,-2005 , 3214 ,-1151 ,-1457 ,1136 ,1297 ,-1003 ,-1500 ,2998 ,-1169 ,-1466 ,1697 ,124 ,-1021 ,196 ,1375 , 33 ,-1955 ,727 ,797 ,-215 ,1215 ,-1639 ,-349 ,1433 ,-700 ,-276 ,1599 ,-1342 ,-445 ,2285 , -2109 ,151 ,2407 ,-2506 ,229 ,1847 ,-1388 ,-136 ,211 ,1597 ,-1287 ,-805 ,1949 ,-1013 ,-284 , 467 ,1027 ,-1123 ,-814 ,2307 ,-775 ,-1868 ,2973 ,-759 ,-2297 ,3318 ,-1594 ,-881 ,2633 ,-1594 , -581 ,1428 ,-597 ,-233 ,405 ,-37 ,734 ,-807 ,-175 ,1210 ,-1302 ,292 ,1734 ,-1817 ,78 , 704 ,80 ,713 ,-1432 ,396 ,602 ,-105 ,-575 ,560 ,935 ,-1305 ,-335 ,1452 ,240 ,-1867 , 841 ,1937 ,-2179 ,-354 ,2675 ,-2084 ,128 ,522 ,-270 ,1188 ,-1392 ,-127 ,1277 ,652 ,-2097 , 534 ,968 ,228 ,-530 ,-759 ,1341 ,-538 ,86 ,82 ,204 ,-789 ,1181 ,-143 ,-438 ,1350 , -2083 ,1277 ,-70 ,-536 ,1931 ,-2116 ,111 ,2220 ,-2189 ,1065 ,893 ,-2306 ,1676 ,157 ,-1314 , 1306 ,872 ,-1679 ,-138 ,1636 ,-694 ,-1000 ,1695 ,224 ,-1810 ,562 ,1707 ,-1032 ,-1372 ,2388 , -820 ,-1395 ,2755 ,-1268 ,-1394 ,2433 ,-909 ,-1185 ,1996 ,-553 ,-819 ,853 ,143 ,-972 ,818 , 1319 ,-2572 ,1140 ,1445 ,-2002 ,332 ,1891 ,-943 ,-1611 ,2036 ,-678 ,-785 ,2076 ,-964 ,-1514 , 2181 ,-70 ,-1630 ,585 ,1544 ,-495 ,-2170 ,2353 ,494 ,-2654 ,1912 ,876 ,-2411 ,1040 ,977 , -318 ,-1306 ,1561 ,421 ,-2285 ,2567 ,-1352 ,-677 ,795 ,1112 ,-790 ,-1305 ,2798 ,-2304 ,178 , 1572 ,-1354 ,311 ,340 ,-128 ,-211 ,413 ,-255 ,-557 ,1815 ,-854 ,-1753 ,2631 ,-194 ,-2311 , 1675 ,1437 ,-2113 ,-467 ,2174 ,-360 ,-1961 ,2495 ,-217 ,-2772 ,2914 ,68 ,-2314 ,1824 ,743 , -2252 ,1134 ,1767 ,-2310 ,-111 ,1957 ,-533 ,-1361 ,1416 ,863 ,-2499 ,1650 ,987 ,-2418 ,1474 , -231 ,-269 ,1814 ,-1616 ,-853 ,1731 ,473 ,-1896 ,542 ,1913 ,-2122 ,79 ,2298 ,-1605 ,-1260 , 2302 ,-37 ,-1955 ,1167 ,1667 ,-2388 ,445 ,2160 ,-3232 ,2026 ,687 ,-2169 ,1135 ,1265 ,-514 , -2081 ,2725 ,-958 ,-986 ,1273 ,182 ,701 ,-1761 ,590 ,813 ,-1263 ,1039 ,942 ,-2171 ,1656 , 531 ,-2420 ,2370 ,-542 ,-1273 ,2456 ,-1607 ,-351 ,849 ,699 ,191 ,-2311 ,1240 ,957 ,-177 , -676 ,-514 ,963 ,889 ,-1053 ,-577 ,778 ,590 ,-294 ,-1216 ,1877 ,-209 ,-1807 ,1913 ,139 , -1335 ,788 ,489 ,-954 ,115 ,1927 ,-2270 ,597 ,1921 ,-2404 ,532 ,683 ,233 ,-461 ,-238 , 757 ,-525 ,-282 ,1405 ,-982 ,310 ,852 ,-1890 ,1372 ,94 ,-1078 ,1384 ,387 ,-1830 ,659 , 1280 ,-945 ,778 ,-597 ,-794 ,1341 ,-141 ,-492 ,374 ,252 ,-403 ,435 ,-467 ,302 ,1052 , -1975 ,1393 ,846 ,-2258 ,1536 ,299 ,-907 ,554 ,-426 ,950 ,-78 ,-1444 ,1331 ,1164 ,-2308 , 630 ,2016 ,-2011 ,-547 ,2024 ,34 ,-2267 ,2176 ,3 ,-1919 ,2461 ,-764 ,-1040 ,1254 ,-253 , -274 ,460 ,-211 ,94 ,295 ,-412 ,-369 ,1841 ,-1081 ,-1178 ,2635 ,-1546 ,-833 ,2057 ,-468 , -1230 ,1263 ,96 ,-834 ,209 ,902 ,417 ,-2290 ,1863 ,765 ,-2063 ,677 ,693 ,985 ,-2281 , 673 ,1868 ,-2265 ,1753 ,-712 ,-1049 ,2303 ,-1424 ,137 ,232 ,-176 ,1117 ,-1051 ,-32 ,553 , -548 ,327 ,1323 ,-1308 ,-578 ,883 ,589 ,-321 ,-947 ,1159 ,-121 ,-385 ,-236 ,1076 ,260 , -1712 ,529 ,1743 ,-1006 ,-1182 ,926 ,1268 ,-996 ,-1052 ,2809 ,-2496 ,291 ,2137 ,-2340 ,402 , 1310 ,75 ,-2121 ,2115 ,402 ,-2242 ,1638 ,182 ,-1152 ,732 ,1197 ,-1372 ,-756 ,2046 ,-168 , -1561 ,723 ,1050 ,135 ,-1384 ,262 ,765 ,-666 ,907 ,467 ,-1363 ,183 ,1010 ,-1032 ,478 , 1267 ,-1623 ,313 ,591 ,-1041 ,1851 ,-496 ,-1819 ,1863 ,556 ,-1985 ,1984 ,-68 ,-2164 ,2299 , -726 ,-484 ,563 ,92 ,1264 ,-1734 ,-468 ,2131 ,-692 ,-1316 ,1463 ,570 ,-1703 ,1015 ,373 , -1083 ,1375 ,-439 ,-667 ,784 ,-28 ,-122 ,-4 ,-218 ,1095 ,-608 ,-606 ,1088 ,-835 ,610 , 170 ,-659 ,525 ,29 ,-175 ,173 ,5 ,42 ,-72 ,247 ,-375 ,-121 ,1695 ,-1595 ,-742 , 2011 ,-66 ,-1830 ,687 ,2096 ,-2629 ,445 ,1982 ,-2196 ,71 ,1963 ,-840 ,-1752 ,2146 ,50 , -2043 ,1652 ,920 ,-2134 ,571 ,1773 ,-2399 ,949 ,1376 ,-2198 ,946 ,1001 ,-1777 ,883 ,1577 , -2628 ,1036 ,1543 ,-2033 ,109 ,1326 ,374 ,-2037 ,836 ,1904 ,-2342 ,248 ,1865 ,-1578 ,-60 , 1098 ,-733 ,-372 ,1230 ,354 ,-2287 ,1664 ,1133 ,-2457 ,1064 ,563 ,-155 ,-276 ,1215 ,-464 , -2415 ,2862 ,0 ,-1629 ,496 ,850 ,695 ,-2081 ,690 ,1862 ,-2166 ,545 ,926 ,-1356 ,1969 , -1245 ,-831 ,2481 ,-1411 ,-739 ,1520 ,-710 ,-225 ,1224 ,-715 ,-494 ,338 ,1224 ,-832 ,-782 , 1491 ,-941 ,-209 ,1757 ,-1126 ,-752 ,1600 ,-666 ,-647 ,853 ,1106 ,-1429 ,-840 ,2503 ,-789 , -1673 ,2147 ,-163 ,-1766 ,2054 ,228 ,-2222 ,1506 ,1224 ,-1878 ,172 ,935 ,283 ,-763 ,19 , 569 ,-364 ,284 ,-425 ,979 ,-251 ,-642 ,562 ,144 ,-233 ,-292 ,1353 ,-748 ,-1106 ,1766 , 409 ,-1671 ,-14 ,1639 ,-46 ,-1944 ,1805 ,465 ,-1912 ,1340 ,-104 ,-620 ,572 ,1217 ,-1490 , -704 ,2441 ,-994 ,-1498 ,1895 ,428 ,-1968 ,1203 ,840 ,-1431 ,326 ,959 ,-226 ,-1209 ,1134 , 1106 ,-1849 ,609 ,-178 ,720 ,429 ,-2045 ,2382 ,-868 ,-1006 ,1604 ,-600 ,348 ,-297 ,-129 , 583 ,-217 ,-25 ,175 ,64 ,-447 ,369 ,1298 ,-1826 ,1 ,2388 ,-2166 ,-277 ,2280 ,-1407 , -603 ,1505 ,-729 ,-100 ,502 ,-199 ,-38 ,-330 ,1464 ,-730 ,-813 ,579 ,469 ,472 ,-1385 , 848 ,262 ,-531 ,429 ,-70 ,106 ,-83 ,125 ,58 ,-34 ,91 ,18 ,49 ,-19 ,98 , 21 ,-340 ,842 ,-32 ,-1064 ,759 ,974 ,-1289 ,91 ,1008 ,-835 ,286 ,115 ,-63 ,287 , -409 ,-203 ,1394 ,-202 ,-1751 ,1080 ,1390 ,-1678 ,-133 ,1802 ,-1421 ,-88 ,998 ,-734 ,-65 , 1282 ,-903 ,-637 ,1519 ,-840 ,-32 ,401 ,-6 ,-262 ,377 ,-134 ,-406 ,1406 ,-914 ,-905 , 1808 ,-175 ,-1778 ,2402 ,-988 ,-1084 ,2377 ,-1516 ,-465 ,1185 ,603 ,-1275 ,8 ,652 ,158 , 62 ,-790 ,1015 ,-853 ,496 ,1240 ,-2010 ,544 ,1290 ,-542 ,-1038 ,1398 ,564 ,-2373 ,2085 , 72 ,-1438 ,887 ,171 ,376 ,-973 ,708 ,390 ,-814 ,446 ,240 ,-203 ,-366 ,580 ,1072 , -1258 ,-448 ,1319 ,-1098 ,980 ,524 ,-1719 ,815 ,688 ,-327 ,-220 ,955 ,-701 ,-626 ,1144 , -714 ,519 ,515 ,-1023 ,598 ,293 ,-898 ,1304 ,-227 ,-847 ,582 ,-6 ,904 ,-1268 ,-136 , 1475 ,-418 ,-835 ,604 ,954 ,-1613 ,679 ,1432 ,-1992 ,312 ,1228 ,-1192 ,305 ,991 ,-871 , -574 ,1335 ,482 ,-1949 ,672 ,1791 ,-2054 ,343 ,1272 ,-1789 ,1024 ,497 ,-921 ,1197 ,-1013 , -645 ,1666 ,-379 ,-1065 ,509 ,1133 ,-588 ,-1260 ,1331 ,588 ,-1568 ,750 ,635 ,-882 ,295 , 346 ,-317 ,-238 ,1074 ,-768 ,-687 ,1886 ,-695 ,-1397 ,1535 ,725 ,-2156 ,1256 ,832 ,-1601 , 787 ,307 ,-502 ,-177 ,1519 ,-1067 ,-539 ,1373 ,-907 ,321 ,153 ,26 ,-378 ,441 ,604 , -1116 ,11 ,1581 ,-711 ,-1389 ,2402 ,-1050 ,-1255 ,2138 ,-170 ,-1460 ,389 ,1902 ,-1870 ,172 , 1690 ,-1985 ,178 ,1898 ,-1283 ,-718 ,2258 ,-1472 ,-916 ,1891 ,159 ,-1726 ,777 ,1260 ,-1864 , 598 ,1507 ,-1372 ,-591 ,2007 ,-1329 ,-502 ,2159 ,-1585 ,-580 ,1998 ,-822 ,-1198 ,1787 ,125 , -1841 ,1516 ,394 ,-1358 ,926 ,32 ,-214 ,-390 ,1360 ,-741 ,-878 ,1945 ,-1311 ,-300 ,1376 , 129 ,-1470 ,555 ,949 ,-1034 ,158 ,1052 ,-558 ,-909 ,1541 ,-244 ,-908 ,881 ,59 ,-471 , 368 ,258 ,-296 ,-446 ,1306 ,8 ,-1491 ,867 ,202 ,939 ,-991 ,-712 ,1575 ,-859 ,218 , 138 ,-2 ,386 ,-948 ,892 ,846 ,-1748 ,451 ,1722 ,-1661 ,-114 ,1499 ,-889 ,-213 ,726 , -400 ,-211 ,1171 ,-379 ,-965 ,535 ,1225 ,-1073 ,-761 ,2199 ,-1204 ,-929 ,1725 ,131 ,-1607 , 673 ,1555 ,-1843 ,354 ,1160 ,-954 ,2 ,691 ,-431 ,119 ,160 ,-523 ,1175 ,-374 ,-918 , 614 ,1154 ,-1031 ,-299 ,713 ,-429 ,723 ,-773 ,609 ,104 ,-1017 ,1275 ,433 ,-1760 ,1120 , 591 ,-1348 ,1337 ,-520 ,-347 ,458 ,643 ,-613 ,-318 ,858 ,-529 ,327 ,-474 ,778 ,422 , -1618 ,927 ,1102 ,-1359 ,204 ,740 ,-636 ,354 ,84 ,-81 ,122 ,-1 ,124 ,-202 ,301 , 175 ,-667 ,607 ,819 ,-1606 ,764 ,1103 ,-1779 ,722 ,480 ,-94 ,-57 ,297 ,-44 ,-929 , 1916 ,-1516 ,-488 ,2167 ,-1295 ,-328 ,356 ,1332 ,-1323 ,-341 ,1795 ,-1514 ,117 ,509 ,748 , -1004 ,-34 ,886 ,-929 ,326 ,200 ,1087 ,-1265 ,-343 ,1123 ,-336 ,180 ,-664 ,581 ,1066 , -1776 ,411 ,1579 ,-1647 ,470 ,674 ,-881 ,206 ,1119 ,-789 ,-702 ,1535 ,-584 ,-456 ,761 , -585 ,400 ,731 ,-1145 ,491 ,341 ,-394 ,426 ,-468 ,152 ,1164 ,-909 ,-910 ,2178 ,-992 , -948 ,1644 ,-666 ,-576 ,947 ,656 ,-1609 ,712 ,1013 ,-1416 ,658 ,-242 ,847 ,189 ,-1294 , 747 ,-219 ,929 ,-708 ,-348 ,1403 ,-1236 ,220 ,846 ,-578 ,-94 ,544 ,-299 ,67 ,-118 , 283 ,787 ,-1119 ,172 ,580 ,-466 ,313 ,-66 ,-281 ,966 ,-468 ,-889 ,1196 ,575 ,-1409 , -163 ,1887 ,-948 ,-734 ,474 ,545 ,378 ,-1432 ,947 ,168 ,-956 ,1418 ,-371 ,-896 ,973 , -164 ,-226 ,-138 ,610 ,484 ,-1649 ,1094 ,773 ,-1823 ,1023 ,1078 ,-1872 ,537 ,1302 ,-1399 , 181 ,792 ,-588 ,79 ,321 ,-640 ,913 ,251 ,-1513 ,1231 ,296 ,-919 ,481 ,-26 ,364 , -257 ,-630 ,1555 ,-772 ,-780 ,1947 ,-1298 ,-662 ,1665 ,-201 ,-1266 ,1096 ,335 ,-1087 ,832 , -129 ,-353 ,241 ,1080 ,-1126 ,-475 ,1996 ,-1270 ,-653 ,1078 ,794 ,-1449 ,-36 ,933 ,-339 , 1118 ,-1625 ,287 ,1017 ,-688 ,44 ,-28 ,996 ,-1013 ,99 ,602 ,-537 ,-44 ,663 ,624 , -1576 ,279 ,1469 ,-892 ,-708 ,1578 ,-364 ,-1201 ,1214 ,-451 ,-90 ,1269 ,-1077 ,-536 ,1286 , 310 ,-1397 ,485 ,1176 ,-1183 ,228 ,598 ,-496 ,-242 ,1311 ,-631 ,-1007 ,1955 ,-820 ,-961 , 1439 ,49 ,-970 ,536 ,540 ,-876 ,351 ,1074 ,-1110 ,-386 ,1495 ,-260 ,-1383 ,1526 ,352 , -1797 ,1554 ,59 ,-1179 ,899 ,865 ,-1225 ,-126 ,1252 ,-628 ,-102 ,363 ,314 ,-880 ,1335 , -188 ,-2160 ,2466 ,-44 ,-1334 ,357 ,1117 ,-396 ,-1140 ,2001 ,-940 ,-1085 ,1984 ,-757 ,-1008 , 2006 ,-855 ,-898 ,1565 ,-598 ,-778 ,1424 ,-100 ,-1474 ,1959 ,-619 ,-1059 ,1066 ,625 ,-942 , -150 ,1785 ,-2035 ,544 ,1128 ,-1175 ,46 ,1032 ,16 ,-1317 ,714 ,731 ,-149 ,-1041 ,1224 , 394 ,-1901 ,1925 ,-167 ,-1590 ,1597 ,185 ,-1036 ,331 ,764 ,-342 ,-463 ,395 ,525 ,-196 , -812 ,746 ,770 ,-1111 ,184 ,104 ,735 ,51 ,-1510 ,1620 ,-29 ,-991 ,824 ,92 ,-667 , 586 ,785 ,-1153 ,-102 ,1263 ,-203 ,-1199 ,1184 ,245 ,-1294 ,1223 ,452 ,-1503 ,797 ,983 , -1149 ,-163 ,744 ,733 ,-1168 ,-338 ,1814 ,-1127 ,-370 ,1124 ,-450 ,-180 ,233 ,-178 ,359 , 1047 ,-1841 ,578 ,799 ,-1035 ,1570 ,-1235 ,-55 ,937 ,-580 ,103 ,239 ,-357 ,380 ,582 , -1070 ,566 ,151 ,-291 ,600 ,-467 ,-271 ,957 ,-83 ,-840 ,375 ,699 ,-214 ,-665 ,345 , 843 ,-556 ,-614 ,1017 ,-130 ,-456 ,381 ,123 ,-491 ,496 ,798 ,-1225 ,-42 ,1318 ,-319 , -1052 ,842 ,508 ,-950 ,652 ,-68 ,-363 ,1153 ,-782 ,-543 ,985 ,-203 ,206 ,367 ,-1020 , 1106 ,64 ,-1147 ,681 ,66 ,621 ,-560 ,-162 ,674 ,-368 ,114 ,179 ,-107 ,-68 ,91 , 595 ,-522 ,162 ,1036 ,-1548 ,0 ,1365 ,-632 ,-91 ,1211 ,-1376 ,1 ,1145 ,-782 ,110 , 22 ,971 ,-487 ,-986 ,986 ,616 ,-690 ,-454 ,664 ,323 ,-218 ,-504 ,360 ,627 ,-394 , -414 ,573 ,-408 ,160 ,1173 ,-1628 ,625 ,695 ,-1295 ,1236 ,-517 ,-219 ,846 ,-641 ,63 , 299 ,-441 ,571 ,295 ,-1056 ,460 ,922 ,-834 ,-709 ,1701 ,-619 ,-911 ,739 ,553 ,-202 , -1233 ,1894 ,-1018 ,-635 ,1498 ,-826 ,-285 ,427 ,887 ,-1208 ,33 ,718 ,352 ,-533 ,-741 , 1247 ,-894 ,423 ,773 ,-1275 ,1062 ,-43 ,-925 ,1202 ,-710 ,100 ,983 ,-1219 ,132 ,1260 , -556 ,-1101 ,1492 ,-114 ,-1096 ,1126 ,-207 ,436 ,-186 ,-805 ,939 ,-458 ,404 ,502 ,-1146 , 660 ,738 ,-1137 ,236 ,1024 ,-861 ,-18 ,492 ,57 ,-302 ,-39 ,750 ,-605 ,-282 ,912 , 348 ,-1296 ,267 ,1413 ,-1161 ,-299 ,1330 ,-637 ,-449 ,927 ,-627 ,419 ,162 ,-552 ,704 , -373 ,97 ,87 ,-79 ,521 ,-443 ,-188 ,948 ,-588 ,-320 ,1173 ,-767 ,-119 ,607 ,-296 , 103 ,84 ,69 ,-417 ,796 ,255 ,-1417 ,1305 ,380 ,-1513 ,969 ,764 ,-1171 ,211 ,989 , -1065 ,327 ,1091 ,-1209 ,82 ,440 ,201 ,60 ,-572 ,1367 ,-916 ,-946 ,1959 ,-672 ,-785 , 1200 ,-400 ,-413 ,1083 ,-549 ,-482 ,1045 ,-349 ,-521 ,941 ,-199 ,-845 ,1087 ,336 ,-1224 , 329 ,1158 ,-747 ,-740 ,1635 ,-615 ,-795 ,1193 ,-392 ,-272 ,119 ,894 ,-750 ,-369 ,1529 , -1311 ,-114 ,1417 ,-896 ,-505 ,1251 ,61 ,-1280 ,745 ,763 ,-1101 ,248 ,556 ,-54 ,75 , -22 ,-63 ,-274 ,443 ,-143 ,-107 ,858 ,-622 ,-444 ,1133 ,-266 ,-909 ,1150 ,240 ,-1250 , 665 ,1046 ,-1207 ,-226 ,1456 ,-565 ,-919 ,1100 ,489 ,-1367 ,847 ,771 ,-1614 ,681 ,986 , -785 ,-426 ,852 ,598 ,-1472 ,673 ,941 ,-1143 ,328 ,241 ,-50 ,77 ,52 ,-299 ,735 , 41 ,-980 ,1112 ,-180 ,-743 ,1095 ,89 ,-1067 ,819 ,321 ,-784 ,575 ,2 ,-168 ,-97 , 571 ,469 ,-1394 ,635 ,935 ,-1118 ,-28 ,1147 ,-335 ,-733 ,671 ,133 ,-418 ,123 ,872 , -664 ,-632 ,1451 ,-523 ,-545 ,832 ,-428 ,287 ,-272 ,250 ,646 ,-967 ,522 ,79 ,-280 , 395 ,-108 ,-25 ,146 ,5 ,51 ,-18 ,175 ,-348 ,348 ,656 ,-1311 ,1078 ,302 ,-1455 , 1439 ,-201 ,-707 ,1020 ,-415 ,-351 ,349 ,791 ,-540 ,-716 ,1181 ,-186 ,-686 ,734 ,234 , -830 ,791 ,126 ,-673 ,209 ,672 ,53 ,-1086 ,1093 ,332 ,-1261 ,693 ,701 ,-679 ,-286 , 601 ,428 ,-653 ,95 ,352 ,-258 ,280 ,-139 ,141 ,137 ,-145 ,182 ,-8 ,115 ,-127 , 56 ,466 ,-302 ,-152 ,168 ,244 ,307 ,-426 ,-395 ,942 ,73 ,-798 ,361 ,478 ,26 , -575 ,314 ,285 ,-215 ,3 ,94 ,529 ,-648 ,111 ,619 ,-614 ,76 ,275 ,206 ,-284 , 671 ,-287 ,-812 ,1253 ,-674 ,-9 ,281 ,-165 ,340 ,21 ,-1 ,-281 ,121 ,23 ,570 , -434 ,-473 ,809 ,265 ,-840 ,333 ,-26 ,-76 ,918 ,-1257 ,779 ,487 ,-1460 ,914 ,652 , -1080 ,187 ,853 ,-697 ,-254 ,848 ,-89 ,-587 ,423 ,18 ,2 ,-185 ,369 ,333 ,-827 , 555 ,63 ,-219 ,311 ,-403 ,534 ,169 ,-651 ,479 ,-53 ,-205 ,688 ,-372 ,-504 ,985 , 32 ,-803 ,475 ,158 ,-189 ,230 ,-100 ,134 ,-155 ,43 ,616 ,-435 ,-285 ,353 ,455 , -314 ,-478 ,748 ,216 ,-806 ,352 ,604 ,-617 ,110 ,400 ,-306 ,-28 ,661 ,-468 ,-246 , 802 ,-332 ,-180 ,-14 ,752 ,-113 ,-1006 ,1339 ,-330 ,-748 ,1258 ,-456 ,-640 ,1042 ,113 , -1112 ,946 ,219 ,-704 ,434 ,-48 ,-19 ,173 ,592 ,-629 ,-188 ,341 ,273 ,141 ,-627 , 566 ,-5 ,-152 ,259 ,-184 ,154 ,460 ,-544 ,-76 ,905 ,-385 ,-511 ,629 ,422 ,-770 , 288 ,474 ,-608 ,457 ,351 ,-811 ,476 ,682 ,-686 ,-255 ,606 ,521 ,-935 ,350 ,659 , -1060 ,600 ,704 ,-752 ,-326 ,830 ,293 ,-980 ,490 ,784 ,-1065 ,343 ,503 ,-693 ,696 , -51 ,-492 ,575 ,38 ,-349 ,79 ,814 ,-596 ,-362 ,1079 ,-729 ,-20 ,704 ,-395 ,-341 , 701 ,202 ,-1016 ,970 ,124 ,-945 ,764 ,338 ,-782 ,259 ,805 ,-618 ,-469 ,1030 ,42 , -992 ,743 ,59 ,284 ,-125 ,-568 ,444 ,-77 ,530 ,-385 ,-90 ,401 ,-284 ,2 ,743 , -356 ,-778 ,1205 ,-210 ,-833 ,947 ,262 ,-924 ,230 ,1073 ,-1001 ,-33 ,970 ,-828 ,561 , 27 ,-382 ,168 ,243 ,477 ,-849 ,156 ,830 ,-292 ,-633 ,517 ,649 ,-682 ,-19 ,396 , -273 ,348 ,119 ,-438 ,404 ,157 ,-466 ,572 ,-89 ,-331 ,623 ,-283 ,-19 ,-34 ,386 , 121 ,-564 ,503 ,-58 ,-104 ,-35 ,420 ,293 ,-1031 ,949 ,55 ,-887 ,1288 ,-546 ,-596 , 952 ,143 ,-842 ,418 ,808 ,-1090 ,359 ,581 ,-599 ,-40 ,691 ,-27 ,-780 ,589 ,90 , 239 ,-25 ,-729 ,849 ,73 ,-471 ,108 ,497 ,64 ,-538 ,330 ,249 ,-224 ,107 ,163 , -189 ,267 ,138 ,-247 ,-51 ,523 ,7 ,-408 ,318 ,45 ,-48 ,153 ,-108 ,-10 ,605 , -443 ,-36 ,103 ,159 ,538 ,-875 ,487 ,296 ,-594 ,583 ,215 ,-582 ,344 ,203 ,-225 , 67 ,-46 ,730 ,-421 ,-486 ,702 ,319 ,-642 ,25 ,839 ,-752 ,405 ,203 ,-652 ,919 , -60 ,-788 ,666 ,500 ,-882 ,487 ,194 ,-372 ,403 ,-188 ,248 ,-265 ,273 ,302 ,-469 , 233 ,-47 ,236 ,20 ,-164 ,-34 ,317 ,255 ,-623 ,142 ,616 ,-202 ,-636 ,681 ,361 , -845 ,426 ,434 ,-614 ,112 ,704 ,-768 ,87 ,758 ,-559 ,-80 ,194 ,224 ,-314 ,298 , 56 ,-352 ,294 ,18 ,81 ,-196 ,176 ,1 ,-29 ,34 ,122 ,-153 ,134 ,195 ,-347 , 437 ,-103 ,-275 ,191 ,527 ,-454 ,-244 ,769 ,-447 ,-31 ,314 ,-147 ,106 ,-222 ,511 , -26 ,-609 ,923 ,-329 ,-281 ,426 ,-317 ,610 ,-191 ,-451 ,635 ,-88 ,-142 ,8 ,242 , 234 ,-408 ,188 ,-70 ,393 ,128 ,-753 ,677 ,101 ,-342 ,73 ,145 ,401 ,-403 ,-297 , 770 ,54 ,-793 ,761 ,131 ,-706 ,495 ,456 ,-395 ,-227 ,560 ,-151 ,-109 ,249 ,-53 , 56 ,10 ,88 ,-19 ,84 ,-27 ,-112 ,428 ,-100 ,103 ,139 ,-606 ,455 ,550 ,-658 , 35 ,679 ,-448 ,-22 ,354 ,-334 ,424 ,43 ,-230 ,124 ,43 ,290 ,-194 ,-14 ,205 , -16 ,-209 ,504 ,-100 ,-178 ,623 ,-698 ,292 ,434 ,-364 ,97 ,221 ,-117 ,-88 ,618 , -396 ,-275 ,792 ,-128 ,-578 ,465 ,534 ,-691 ,39 ,825 ,-636 ,-129 ,733 ,-382 ,-257 , 686 ,22 ,-691 ,575 ,441 ,-818 ,372 ,542 ,-672 ,179 ,514 ,-395 ,-132 ,682 ,-178 , -499 ,642 ,49 ,-287 ,85 ,215 ,8 ,-92 ,152 ,-46 ,142 ,55 ,-84 ,-39 ,392 , -7 ,-402 ,530 ,-41 ,-354 ,566 ,31 ,-523 ,379 ,502 ,-643 ,69 ,705 ,-580 ,3 , 637 ,-336 ,-289 ,639 ,24 ,-471 ,196 ,521 ,-132 ,-558 ,698 ,67 ,-459 ,405 ,65 , -158 ,177 ,22 ,-85 ,345 ,-83 ,-276 ,422 ,182 ,-384 ,218 ,330 ,-283 ,-23 ,611 , -441 ,-281 ,943 ,-558 ,-262 ,833 ,-284 ,-353 ,542 ,157 ,-553 ,323 ,446 ,-437 ,-103 , 541 ,-8 ,-465 ,706 ,-120 ,-653 ,892 ,-116 ,-448 ,495 ,-28 ,-130 ,137 ,53 ,-126 , 84 ,503 ,-479 ,-138 ,789 ,-562 ,-32 ,621 ,-396 ,-146 ,348 ,276 ,-416 ,-30 ,705 , -576 ,-30 ,738 ,-645 ,-65 ,713 ,-288 ,-396 ,615 ,94 ,-487 ,174 ,478 ,-78 ,-415 , 349 ,158 ,-320 ,292 ,312 ,-404 ,169 ,172 ,-258 ,442 ,-36 ,-215 ,285 ,-128 ,150 , 184 ,-207 ,109 ,55 ,154 ,-63 ,-9 ,112 ,69 ,21 ,3 ,67 ,-127 ,417 ,-41 , -322 ,176 ,417 ,-185 ,-268 ,541 ,-210 ,-186 ,507 ,11 ,-399 ,394 ,137 ,-344 ,286 , 175 ,-230 ,23 ,553 ,-499 ,83 ,523 ,-497 ,255 ,32 ,2 ,143 ,-135 ,86 ,356 , -160 ,-266 ,426 ,-61 ,-56 ,72 ,77 ,127 ,-163 ,89 ,172 ,-91 ,17 ,131 ,-99 , 4 ,480 ,-354 ,-198 ,653 ,-307 ,-91 ,180 ,25 ,-36 ,46 ,155 ,-129 ,13 ,52 , 202 ,-171 ,-16 ,180 ,-33 ,-95 ,60 ,396 ,-386 ,-96 ,570 ,-253 ,-317 ,513 ,64 , -462 ,332 ,219 ,-390 ,160 ,409 ,-372 ,-49 ,447 ,-267 ,10 ,193 ,-74 ,64 ,12 , 96 ,-106 ,121 ,130 ,-80 ,100 ,-31 ,-111 ,301 ,158 ,-398 ,296 ,133 ,-178 ,4 , 297 ,55 ,-353 ,384 ,-4 ,-154 ,84 ,337 ,-68 ,-270 ,366 ,-186 ,69 ,343 ,-260 , -96 ,461 ,-123 ,-224 ,314 ,-18 ,44 ,-33 ,25 ,143 ,-47 ,-32 ,-25 ,16 ,-11 , 6 ,-3 ,0 ,1 ,-3 ,3 ,-4 ,4 ,-3 ,3 ,-2 ,1 ,0 ,0 ,0 , 0 ,0 ,0 ,0 ,-137 ,1352 ,7600 ,14684 ,20671 ,25482 ,28813 ,31066 ,32247 ,32757 ,32649 , 32190 ,31413 ,30455 ,29345 ,28132 ,26863 ,25536 ,24178 ,22781 ,21402 ,19965 ,18604 ,16998 ,14851 ,12654 , 10588 ,8646 ,6852 ,5171 ,3631 ,2167 ,809 ,-486 ,-1713 ,-2879 ,-4007 ,-5082 ,-6128 ,-7126 ,-8104 , -9042 ,-9954 ,-10829 ,-11691 ,-12520 ,-13317 ,-14104 ,-14850 ,-15586 ,-16278 ,-16966 ,-17622 ,-18245 ,-18852 ,-19421 , -19975 ,-20497 ,-20992 ,-21461 ,-21907 ,-22324 ,-22717 ,-23078 ,-23413 ,-23720 ,-23995 ,-24246 ,-24469 ,-24665 ,-24830 , -24964 ,-25069 ,-25151 ,-25205 ,-25230 ,-25229 ,-25200 ,-25144 ,-25065 ,-24958 ,-24830 ,-24675 ,-24493 ,-24287 ,-24060 , -23811 ,-23527 ,-23240 ,-22925 ,-22580 ,-22222 ,-21841 ,-21443 ,-21020 ,-20578 ,-20122 ,-19642 ,-19152 ,-18639 ,-18107 , -17564 ,-17002 ,-16426 ,-15831 ,-15236 ,-14620 ,-13994 ,-13358 ,-12709 ,-12052 ,-11384 ,-10707 ,-10017 ,-9326 ,-8615 , -7910 ,-7187 ,-6463 ,-5731 ,-4995 ,-4256 ,-3512 ,-2779 ,-2026 ,-1293 ,-549 ,179 ,902 ,1624 ,2332 , 3047 ,3747 ,4441 ,5116 ,5791 ,6450 ,7104 ,7753 ,8398 ,9034 ,9664 ,10303 ,10921 ,11550 ,12169 , 12780 ,13388 ,13987 ,14581 ,15162 ,15734 ,16298 ,16851 ,17384 ,17909 ,18420 ,18919 ,19406 ,19877 ,20341 , 20802 ,21243 ,21666 ,22082 ,22481 ,22862 ,23224 ,23581 ,23916 ,24227 ,24529 ,24808 ,25064 ,25306 ,25526 , 25726 ,25910 ,26068 ,26210 ,26330 ,26430 ,26506 ,26574 ,26627 ,26660 ,26678 ,26676 ,26661 ,26617 ,26556 , 26461 ,26332 ,26187 ,25996 ,25790 ,25549 ,25284 ,25014 ,24718 ,24413 ,24095 ,23756 ,23392 ,23022 ,22637 , 22227 ,21802 ,21361 ,20898 ,20407 ,19908 ,19379 ,18830 ,18248 ,17643 ,17024 ,16385 ,15734 ,15068 ,14404 , 13736 ,13059 ,12380 ,11704 ,11009 ,10316 ,9617 ,8914 ,8217 ,7514 ,6820 ,6122 ,5436 ,4751 ,4071 , 3399 ,2722 ,2047 ,1377 ,707 ,43 ,-616 ,-1277 ,-1926 ,-2581 ,-3225 ,-3866 ,-4512 ,-5153 ,-5796 , -6433 ,-7073 ,-7710 ,-8344 ,-8975 ,-9610 ,-10235 ,-10853 ,-11471 ,-12077 ,-12687 ,-13288 ,-13873 ,-14450 ,-15021 , -15577 ,-16118 ,-16639 ,-17152 ,-17658 ,-18140 ,-18620 ,-19089 ,-19534 ,-19972 ,-20392 ,-20800 ,-21200 ,-21579 ,-21952 , -22303 ,-22654 ,-22995 ,-23313 ,-23632 ,-23939 ,-24232 ,-24504 ,-24764 ,-25002 ,-25214 ,-25412 ,-25583 ,-25734 ,-25863 , -25963 ,-26047 ,-26100 ,-26134 ,-26145 ,-26132 ,-26098 ,-26038 ,-25963 ,-25853 ,-25720 ,-25565 ,-25380 ,-25186 ,-24977 , -24748 ,-24506 ,-24252 ,-23978 ,-23697 ,-23407 ,-23107 ,-22797 ,-22481 ,-22151 ,-21812 ,-21462 ,-21085 ,-20690 ,-20273 , -19824 ,-19357 ,-18870 ,-18356 ,-17826 ,-17279 ,-16725 ,-16155 ,-15571 ,-14975 ,-14364 ,-13733 ,-13098 ,-12455 ,-11802 , -11156 ,-10497 ,-9846 ,-9193 ,-8540 ,-7888 ,-7238 ,-6586 ,-5930 ,-5278 ,-4610 ,-3953 ,-3295 ,-2634 ,-1975 , -1311 ,-647 ,13 ,661 ,1310 ,1952 ,2592 ,3221 ,3839 ,4451 ,5054 ,5657 ,6252 ,6837 ,7422 , 8003 ,8579 ,9165 ,9738 ,10322 ,10900 ,11466 ,12042 ,12606 ,13169 ,13723 ,14275 ,14807 ,15331 ,15844 , 16347 ,16836 ,17301 ,17766 ,18212 ,18635 ,19054 ,19461 ,19846 ,20227 ,20593 ,20943 ,21278 ,21606 ,21919 , 22208 ,22483 ,22722 ,22942 ,23128 ,23282 ,23425 ,23533 ,23623 ,23692 ,23744 ,23784 ,23809 ,23829 ,23832 , 23829 ,23810 ,23785 ,23737 ,23670 ,23600 ,23503 ,23407 ,23285 ,23149 ,23005 ,22841 ,22655 ,22453 ,22239 , 21996 ,21750 ,21478 ,21181 ,20867 ,20529 ,20177 ,19797 ,19399 ,18988 ,18561 ,18119 ,17666 ,17199 ,16724 , 16249 ,15770 ,15287 ,14804 ,14322 ,13839 ,13356 ,12860 ,12362 ,11863 ,11344 ,10824 ,10298 ,9755 ,9199 , 8626 ,8043 ,7446 ,6835 ,6216 ,5587 ,4941 ,4296 ,3636 ,2973 ,2299 ,1611 ,941 ,253 ,-428 , -1111 ,-1796 ,-2477 ,-3155 ,-3818 ,-4494 ,-5150 ,-5807 ,-6459 ,-7107 ,-7765 ,-8408 ,-9037 ,-9658 ,-10262 , -10859 ,-11448 ,-12014 ,-12579 ,-13123 ,-13654 ,-14167 ,-14664 ,-15151 ,-15608 ,-16056 ,-16487 ,-16908 ,-17318 ,-17713 , -18097 ,-18469 ,-18831 ,-19185 ,-19519 ,-19839 ,-20144 ,-20424 ,-20690 ,-20932 ,-21154 ,-21349 ,-21530 ,-21692 ,-21835 , -21967 ,-22075 ,-22168 ,-22245 ,-22315 ,-22366 ,-22398 ,-22425 ,-22432 ,-22428 ,-22414 ,-22384 ,-22341 ,-22288 ,-22225 , -22144 ,-22044 ,-21935 ,-21807 ,-21662 ,-21498 ,-21309 ,-21117 ,-20901 ,-20664 ,-20419 ,-20147 ,-19864 ,-19558 ,-19241 , -18901 ,-18542 ,-18171 ,-17785 ,-17393 ,-16981 ,-16566 ,-16141 ,-15709 ,-15266 ,-14813 ,-14351 ,-13867 ,-13374 ,-12868 , -12351 ,-11816 ,-11282 ,-10729 ,-10164 ,-9595 ,-9018 ,-8424 ,-7814 ,-7217 ,-6601 ,-5993 ,-5384 ,-4779 ,-4188 , -3599 ,-3009 ,-2417 ,-1835 ,-1248 ,-671 ,-84 ,493 ,1070 ,1659 ,2236 ,2814 ,3389 ,3959 ,4529 , 5095 ,5648 ,6204 ,6754 ,7291 ,7825 ,8357 ,8883 ,9406 ,9919 ,10421 ,10912 ,11395 ,11865 ,12313 , 12753 ,13180 ,13596 ,13998 ,14384 ,14762 ,15121 ,15474 ,15819 ,16139 ,16447 ,16752 ,17034 ,17311 ,17580 , 17834 ,18083 ,18322 ,18548 ,18765 ,18976 ,19175 ,19359 ,19532 ,19695 ,19838 ,19970 ,20098 ,20204 ,20302 , 20379 ,20437 ,20478 ,20499 ,20506 ,20488 ,20463 ,20412 ,20346 ,20260 ,20146 ,20026 ,19878 ,19711 ,19534 , 19343 ,19134 ,18916 ,18691 ,18462 ,18237 ,17999 ,17763 ,17527 ,17278 ,17020 ,16759 ,16494 ,16220 ,15941 , 15662 ,15372 ,15069 ,14762 ,14430 ,14100 ,13752 ,13386 ,13016 ,12628 ,12231 ,11814 ,11397 ,10963 ,10520 , 10066 ,9607 ,9136 ,8643 ,8150 ,7636 ,7105 ,6566 ,6014 ,5452 ,4887 ,4316 ,3745 ,3166 ,2588 , 2003 ,1421 ,840 ,258 ,-312 ,-887 ,-1448 ,-2010 ,-2566 ,-3118 ,-3670 ,-4210 ,-4744 ,-5276 ,-5797 , -6315 ,-6824 ,-7319 ,-7820 ,-8303 ,-8796 ,-9285 ,-9771 ,-10265 ,-10742 ,-11218 ,-11680 ,-12137 ,-12578 ,-13012 , -13444 ,-13856 ,-14258 ,-14649 ,-15023 ,-15377 ,-15719 ,-16042 ,-16349 ,-16643 ,-16913 ,-17172 ,-17413 ,-17639 ,-17850 , -18034 ,-18206 ,-18361 ,-18501 ,-18623 ,-18719 ,-18809 ,-18883 ,-18946 ,-18987 ,-19013 ,-19033 ,-19032 ,-19016 ,-18986 , -18944 ,-18894 ,-18835 ,-18761 ,-18679 ,-18595 ,-18504 ,-18397 ,-18289 ,-18173 ,-18048 ,-17916 ,-17776 ,-17626 ,-17462 , -17296 ,-17109 ,-16917 ,-16716 ,-16495 ,-16268 ,-16022 ,-15768 ,-15496 ,-15210 ,-14918 ,-14611 ,-14296 ,-13969 ,-13629 , -13288 ,-12935 ,-12577 ,-12206 ,-11825 ,-11428 ,-11013 ,-10593 ,-10159 ,-9711 ,-9247 ,-8778 ,-8295 ,-7810 ,-7314 , -6807 ,-6300 ,-5788 ,-5275 ,-4760 ,-4253 ,-3738 ,-3223 ,-2715 ,-2201 ,-1686 ,-1178 ,-663 ,-153 ,353 , 874 ,1385 ,1909 ,2414 ,2921 ,3427 ,3912 ,4399 ,4861 ,5319 ,5764 ,6204 ,6638 ,7060 ,7477 , 7882 ,8288 ,8681 ,9075 ,9461 ,9837 ,10211 ,10572 ,10931 ,11276 ,11605 ,11923 ,12225 ,12520 ,12797 , 13063 ,13318 ,13565 ,13802 ,14028 ,14247 ,14457 ,14658 ,14853 ,15039 ,15211 ,15383 ,15545 ,15697 ,15839 , 15968 ,16092 ,16206 ,16315 ,16429 ,16538 ,16641 ,16737 ,16818 ,16895 ,16954 ,17005 ,17044 ,17067 ,17083 , 17082 ,17084 ,17073 ,17047 ,17021 ,16983 ,16934 ,16873 ,16803 ,16713 ,16601 ,16475 ,16332 ,16178 ,16001 , 15819 ,15632 ,15426 ,15214 ,14977 ,14736 ,14481 ,14204 ,13919 ,13614 ,13295 ,12953 ,12595 ,12221 ,11838 , 11447 ,11038 ,10623 ,10206 ,9779 ,9348 ,8920 ,8483 ,8044 ,7607 ,7172 ,6737 ,6300 ,5857 ,5420 , 4989 ,4552 ,4119 ,3689 ,3267 ,2842 ,2422 ,2006 ,1586 ,1167 ,753 ,338 ,-78 ,-492 ,-916 , -1336 ,-1761 ,-2183 ,-2608 ,-3033 ,-3450 ,-3877 ,-4304 ,-4732 ,-5161 ,-5598 ,-6038 ,-6479 ,-6914 ,-7344 , -7773 ,-8192 ,-8603 ,-9006 ,-9410 ,-9799 ,-10185 ,-10568 ,-10935 ,-11303 ,-11659 ,-12004 ,-12332 ,-12653 ,-12967 , -13265 ,-13551 ,-13817 ,-14067 ,-14300 ,-14524 ,-14734 ,-14924 ,-15105 ,-15281 ,-15442 ,-15594 ,-15733 ,-15865 ,-15994 , -16112 ,-16228 ,-16336 ,-16433 ,-16522 ,-16603 ,-16669 ,-16719 ,-16759 ,-16780 ,-16786 ,-16778 ,-16748 ,-16707 ,-16646 , -16562 ,-16465 ,-16348 ,-16219 ,-16074 ,-15922 ,-15764 ,-15586 ,-15410 ,-15221 ,-15023 ,-14822 ,-14606 ,-14393 ,-14166 , -13927 ,-13686 ,-13429 ,-13162 ,-12883 ,-12592 ,-12299 ,-11989 ,-11681 ,-11364 ,-11030 ,-10698 ,-10353 ,-9997 ,-9637 , -9273 ,-8900 ,-8517 ,-8132 ,-7747 ,-7357 ,-6969 ,-6590 ,-6202 ,-5822 ,-5443 ,-5059 ,-4678 ,-4284 ,-3885 , -3477 ,-3071 ,-2660 ,-2240 ,-1827 ,-1403 ,-980 ,-567 ,-150 ,265 ,682 ,1097 ,1516 ,1941 ,2357 , 2784 ,3204 ,3619 ,4039 ,4456 ,4870 ,5280 ,5695 ,6104 ,6509 ,6918 ,7318 ,7712 ,8100 ,8470 , 8838 ,9188 ,9533 ,9867 ,10186 ,10513 ,10821 ,11126 ,11421 ,11703 ,11975 ,12235 ,12500 ,12746 ,12988 , 13219 ,13442 ,13665 ,13871 ,14072 ,14269 ,14449 ,14621 ,14775 ,14919 ,15052 ,15167 ,15275 ,15371 ,15458 , 15535 ,15595 ,15641 ,15677 ,15696 ,15699 ,15691 ,15664 ,15623 ,15570 ,15505 ,15424 ,15331 ,15225 ,15110 , 14984 ,14848 ,14709 ,14563 ,14413 ,14249 ,14083 ,13928 ,13758 ,13585 ,13414 ,13229 ,13037 ,12838 ,12625 , 12398 ,12167 ,11915 ,11646 ,11365 ,11072 ,10765 ,10443 ,10126 ,9788 ,9450 ,9113 ,8763 ,8419 ,8070 , 7725 ,7381 ,7028 ,6680 ,6321 ,5962 ,5599 ,5229 ,4863 ,4492 ,4126 ,3757 ,3396 ,3032 ,2652 , 2281 ,1899 ,1509 ,1116 ,716 ,308 ,-94 ,-506 ,-923 ,-1340 ,-1755 ,-2165 ,-2570 ,-2962 ,-3362 , -3755 ,-4145 ,-4536 ,-4930 ,-5324 ,-5711 ,-6105 ,-6489 ,-6874 ,-7246 ,-7609 ,-7973 ,-8318 ,-8656 ,-8989 , -9314 ,-9632 ,-9934 ,-10232 ,-10527 ,-10813 ,-11097 ,-11376 ,-11645 ,-11911 ,-12163 ,-12408 ,-12639 ,-12856 ,-13077 , -13289 ,-13491 ,-13688 ,-13878 ,-14056 ,-14218 ,-14372 ,-14511 ,-14628 ,-14734 ,-14821 ,-14891 ,-14948 ,-14989 ,-15016 , -15026 ,-15024 ,-15004 ,-14969 ,-14931 ,-14881 ,-14817 ,-14748 ,-14667 ,-14575 ,-14476 ,-14369 ,-14244 ,-14105 ,-13965 , -13807 ,-13641 ,-13473 ,-13291 ,-13099 ,-12897 ,-12686 ,-12463 ,-12244 ,-12009 ,-11767 ,-11529 ,-11270 ,-11012 ,-10748 , -10481 ,-10210 ,-9927 ,-9644 ,-9354 ,-9058 ,-8745 ,-8430 ,-8114 ,-7783 ,-7449 ,-7121 ,-6788 ,-6459 ,-6136 , -5810 ,-5489 ,-5163 ,-4833 ,-4501 ,-4169 ,-3833 ,-3484 ,-3128 ,-2770 ,-2410 ,-2049 ,-1693 ,-1329 ,-967 , -601 ,-235 ,129 ,503 ,867 ,1230 ,1596 ,1963 ,2329 ,2695 ,3064 ,3422 ,3779 ,4139 ,4484 , 4817 ,5153 ,5483 ,5813 ,6139 ,6457 ,6769 ,7075 ,7390 ,7699 ,8004 ,8316 ,8611 ,8907 ,9201 , 9474 ,9743 ,10001 ,10254 ,10499 ,10726 ,10950 ,11168 ,11369 ,11567 ,11754 ,11929 ,12097 ,12250 ,12392 , 12532 ,12666 ,12783 ,12892 ,12986 ,13069 ,13145 ,13208 ,13263 ,13311 ,13359 ,13398 ,13437 ,13476 ,13504 , 13534 ,13558 ,13571 ,13574 ,13569 ,13557 ,13534 ,13505 ,13461 ,13405 ,13333 ,13251 ,13155 ,13050 ,12933 , 12801 ,12667 ,12505 ,12341 ,12162 ,11977 ,11785 ,11575 ,11369 ,11151 ,10930 ,10693 ,10453 ,10197 ,9932 , 9659 ,9370 ,9074 ,8761 ,8451 ,8121 ,7789 ,7460 ,7123 ,6790 ,6450 ,6107 ,5762 ,5419 ,5073 , 4732 ,4389 ,4047 ,3703 ,3357 ,3026 ,2686 ,2340 ,2007 ,1666 ,1326 ,994 ,655 ,312 ,-32 , -371 ,-725 ,-1080 ,-1433 ,-1794 ,-2142 ,-2495 ,-2842 ,-3183 ,-3518 ,-3846 ,-4176 ,-4489 ,-4800 ,-5108 , -5402 ,-5709 ,-6010 ,-6307 ,-6608 ,-6904 ,-7203 ,-7494 ,-7792 ,-8084 ,-8370 ,-8653 ,-8928 ,-9195 ,-9444 , -9688 ,-9921 ,-10144 ,-10358 ,-10567 ,-10768 ,-10951 ,-11133 ,-11305 ,-11476 ,-11637 ,-11784 ,-11939 ,-12078 ,-12207 , -12331 ,-12438 ,-12544 ,-12648 ,-12743 ,-12833 ,-12908 ,-12972 ,-13024 ,-13058 ,-13079 ,-13084 ,-13074 ,-13048 ,-13007 , -12952 ,-12880 ,-12802 ,-12709 ,-12597 ,-12483 ,-12366 ,-12242 ,-12115 ,-11988 ,-11856 ,-11725 ,-11585 ,-11440 ,-11288 , -11119 ,-10949 ,-10772 ,-10590 ,-10401 ,-10209 ,-10015 ,-9816 ,-9611 ,-9400 ,-9184 ,-8950 ,-8719 ,-8480 ,-8231 , -7986 ,-7729 ,-7469 ,-7206 ,-6937 ,-6663 ,-6384 ,-6102 ,-5815 ,-5526 ,-5225 ,-4928 ,-4618 ,-4301 ,-3990 , -3663 ,-3339 ,-3002 ,-2671 ,-2338 ,-1998 ,-1654 ,-1307 ,-966 ,-616 ,-267 ,85 ,434 ,787 ,1146 , 1500 ,1853 ,2205 ,2545 ,2885 ,3220 ,3540 ,3861 ,4167 ,4469 ,4759 ,5047 ,5331 ,5608 ,5886 , 6151 ,6421 ,6687 ,6945 ,7192 ,7432 ,7665 ,7895 ,8111 ,8318 ,8529 ,8726 ,8921 ,9111 ,9302 , 9487 ,9667 ,9844 ,10009 ,10172 ,10324 ,10467 ,10596 ,10714 ,10824 ,10922 ,11010 ,11093 ,11161 ,11221 , 11271 ,11311 ,11347 ,11370 ,11397 ,11416 ,11431 ,11442 ,11449 ,11456 ,11457 ,11461 ,11459 ,11467 ,11468 , 11459 ,11456 ,11445 ,11423 ,11390 ,11347 ,11292 ,11229 ,11155 ,11062 ,10961 ,10847 ,10720 ,10575 ,10421 , 10264 ,10090 ,9910 ,9722 ,9530 ,9334 ,9133 ,8929 ,8717 ,8506 ,8282 ,8055 ,7824 ,7583 ,7342 , 7091 ,6836 ,6576 ,6310 ,6041 ,5760 ,5475 ,5187 ,4897 ,4602 ,4311 ,4017 ,3719 ,3418 ,3123 , 2825 ,2528 ,2237 ,1942 ,1652 ,1351 ,1061 ,759 ,450 ,149 ,-154 ,-450 ,-755 ,-1047 ,-1334 , -1626 ,-1912 ,-2200 ,-2492 ,-2778 ,-3072 ,-3367 ,-3661 ,-3958 ,-4241 ,-4524 ,-4797 ,-5060 ,-5318 ,-5572 , -5822 ,-6059 ,-6307 ,-6544 ,-6774 ,-7013 ,-7235 ,-7458 ,-7675 ,-7879 ,-8093 ,-8292 ,-8488 ,-8686 ,-8872 , -9058 ,-9234 ,-9398 ,-9548 ,-9694 ,-9825 ,-9940 ,-10046 ,-10144 ,-10236 ,-10321 ,-10395 ,-10454 ,-10519 ,-10574 , -10623 ,-10661 ,-10696 ,-10731 ,-10753 ,-10782 ,-10802 ,-10822 ,-10831 ,-10837 ,-10843 ,-10837 ,-10833 ,-10818 ,-10784 , -10756 ,-10722 ,-10677 ,-10637 ,-10588 ,-10534 ,-10477 ,-10412 ,-10333 ,-10252 ,-10165 ,-10064 ,-9955 ,-9842 ,-9718 , -9583 ,-9444 ,-9286 ,-9123 ,-8956 ,-8773 ,-8585 ,-8392 ,-8188 ,-7974 ,-7757 ,-7528 ,-7294 ,-7055 ,-6806 , -6552 ,-6286 ,-6019 ,-5744 ,-5462 ,-5184 ,-4889 ,-4590 ,-4286 ,-3973 ,-3657 ,-3335 ,-3012 ,-2683 ,-2359 , -2029 ,-1700 ,-1370 ,-1046 ,-730 ,-407 ,-99 ,207 ,509 ,807 ,1099 ,1382 ,1665 ,1937 ,2207 , 2477 ,2747 ,3012 ,3284 ,3561 ,3836 ,4117 ,4400 ,4680 ,4955 ,5230 ,5497 ,5760 ,6012 ,6258 , 6495 ,6715 ,6929 ,7134 ,7326 ,7512 ,7690 ,7853 ,8018 ,8177 ,8328 ,8481 ,8629 ,8777 ,8914 , 9049 ,9178 ,9298 ,9417 ,9530 ,9635 ,9729 ,9814 ,9896 ,9972 ,10039 ,10104 ,10161 ,10216 ,10272 , 10327 ,10378 ,10430 ,10466 ,10495 ,10518 ,10519 ,10520 ,10503 ,10473 ,10434 ,10380 ,10324 ,10265 ,10189 , 10105 ,10020 ,9906 ,9798 ,9671 ,9533 ,9401 ,9254 ,9109 ,8960 ,8805 ,8650 ,8496 ,8324 ,8148 , 7971 ,7789 ,7599 ,7408 ,7211 ,7010 ,6813 ,6610 ,6405 ,6196 ,5990 ,5771 ,5561 ,5356 ,5135 , 4921 ,4700 ,4474 ,4241 ,4003 ,3757 ,3515 ,3273 ,3025 ,2787 ,2544 ,2300 ,2052 ,1804 ,1542 , 1279 ,1014 ,741 ,467 ,182 ,-86 ,-364 ,-645 ,-925 ,-1199 ,-1471 ,-1740 ,-2002 ,-2273 ,-2525 , -2785 ,-3042 ,-3294 ,-3546 ,-3789 ,-4040 ,-4286 ,-4518 ,-4748 ,-4976 ,-5194 ,-5422 ,-5643 ,-5856 ,-6071 , -6282 ,-6487 ,-6682 ,-6873 ,-7054 ,-7232 ,-7409 ,-7577 ,-7741 ,-7896 ,-8046 ,-8198 ,-8333 ,-8468 ,-8593 , -8712 ,-8826 ,-8926 ,-9027 ,-9113 ,-9195 ,-9270 ,-9341 ,-9409 ,-9463 ,-9513 ,-9553 ,-9589 ,-9615 ,-9635 , -9647 ,-9649 ,-9645 ,-9625 ,-9614 ,-9599 ,-9571 ,-9543 ,-9510 ,-9474 ,-9425 ,-9368 ,-9303 ,-9223 ,-9135 , -9049 ,-8941 ,-8827 ,-8716 ,-8591 ,-8467 ,-8334 ,-8200 ,-8060 ,-7914 ,-7767 ,-7615 ,-7453 ,-7287 ,-7120 , -6952 ,-6772 ,-6583 ,-6394 ,-6195 ,-5995 ,-5789 ,-5579 ,-5367 ,-5153 ,-4933 ,-4715 ,-4504 ,-4287 ,-4069 , -3851 ,-3634 ,-3418 ,-3202 ,-2977 ,-2748 ,-2521 ,-2291 ,-2058 ,-1822 ,-1580 ,-1337 ,-1098 ,-849 ,-609 , -365 ,-126 ,104 ,346 ,580 ,820 ,1059 ,1298 ,1539 ,1778 ,2026 ,2274 ,2519 ,2757 ,3005 , 3255 ,3491 ,3728 ,3962 ,4184 ,4404 ,4614 ,4821 ,5026 ,5227 ,5423 ,5611 ,5796 ,5972 ,6151 , 6319 ,6477 ,6634 ,6783 ,6929 ,7068 ,7198 ,7322 ,7443 ,7559 ,7672 ,7783 ,7884 ,7974 ,8069 , 8157 ,8234 ,8311 ,8383 ,8453 ,8510 ,8572 ,8621 ,8658 ,8689 ,8700 ,8719 ,8728 ,8730 ,8729 , 8720 ,8709 ,8695 ,8687 ,8670 ,8647 ,8626 ,8602 ,8572 ,8543 ,8510 ,8467 ,8423 ,8376 ,8321 , 8262 ,8197 ,8120 ,8042 ,7958 ,7862 ,7756 ,7647 ,7533 ,7411 ,7291 ,7165 ,7029 ,6890 ,6747 , 6590 ,6425 ,6258 ,6088 ,5905 ,5718 ,5533 ,5339 ,5143 ,4942 ,4738 ,4531 ,4317 ,4104 ,3877 , 3657 ,3436 ,3206 ,2979 ,2742 ,2503 ,2262 ,2023 ,1777 ,1532 ,1289 ,1040 ,793 ,547 ,298 , 53 ,-192 ,-439 ,-683 ,-934 ,-1174 ,-1416 ,-1658 ,-1894 ,-2129 ,-2360 ,-2589 ,-2817 ,-3035 ,-3248 , -3463 ,-3669 ,-3870 ,-4069 ,-4267 ,-4459 ,-4648 ,-4830 ,-5011 ,-5192 ,-5362 ,-5530 ,-5696 ,-5862 ,-6031 , -6196 ,-6359 ,-6525 ,-6689 ,-6856 ,-7011 ,-7164 ,-7316 ,-7452 ,-7585 ,-7708 ,-7829 ,-7939 ,-8039 ,-8132 , -8206 ,-8274 ,-8337 ,-8390 ,-8438 ,-8477 ,-8512 ,-8540 ,-8561 ,-8576 ,-8587 ,-8596 ,-8603 ,-8601 ,-8583 , -8568 ,-8540 ,-8505 ,-8459 ,-8406 ,-8348 ,-8275 ,-8204 ,-8125 ,-8042 ,-7949 ,-7860 ,-7772 ,-7672 ,-7577 , -7472 ,-7366 ,-7265 ,-7156 ,-7037 ,-6924 ,-6810 ,-6686 ,-6562 ,-6433 ,-6299 ,-6161 ,-6017 ,-5859 ,-5706 , -5542 ,-5362 ,-5183 ,-4998 ,-4801 ,-4608 ,-4410 ,-4202 ,-3998 ,-3786 ,-3575 ,-3361 ,-3149 ,-2947 ,-2743 , -2539 ,-2340 ,-2145 ,-1950 ,-1759 ,-1559 ,-1364 ,-1173 ,-973 ,-780 ,-582 ,-387 ,-190 ,9 ,203 , 411 ,614 ,821 ,1029 ,1229 ,1439 ,1644 ,1846 ,2054 ,2265 ,2472 ,2680 ,2885 ,3086 ,3288 , 3487 ,3680 ,3868 ,4052 ,4235 ,4424 ,4610 ,4792 ,4970 ,5145 ,5326 ,5500 ,5668 ,5835 ,6001 , 6162 ,6316 ,6463 ,6605 ,6743 ,6866 ,6991 ,7108 ,7213 ,7319 ,7415 ,7505 ,7589 ,7672 ,7744 , 7808 ,7872 ,7932 ,7983 ,8032 ,8077 ,8103 ,8130 ,8150 ,8158 ,8154 ,8137 ,8121 ,8094 ,8055 , 8012 ,7961 ,7905 ,7842 ,7771 ,7697 ,7620 ,7547 ,7466 ,7377 ,7295 ,7202 ,7110 ,7017 ,6919 , 6820 ,6721 ,6621 ,6512 ,6404 ,6297 ,6180 ,6060 ,5943 ,5816 ,5685 ,5551 ,5413 ,5273 ,5133 , 4985 ,4837 ,4693 ,4532 ,4379 ,4218 ,4050 ,3878 ,3704 ,3535 ,3352 ,3172 ,2988 ,2795 ,2588 , 2384 ,2172 ,1947 ,1721 ,1482 ,1247 ,1002 ,765 ,524 ,285 ,53 ,-174 ,-397 ,-625 ,-843 , -1068 ,-1280 ,-1493 ,-1703 ,-1904 ,-2107 ,-2300 ,-2486 ,-2675 ,-2856 ,-3021 ,-3190 ,-3353 ,-3514 ,-3666 , -3813 ,-3963 ,-4103 ,-4240 ,-4377 ,-4507 ,-4635 ,-4770 ,-4896 ,-5029 ,-5159 ,-5290 ,-5423 ,-5550 ,-5690 , -5823 ,-5956 ,-6086 ,-6221 ,-6350 ,-6474 ,-6604 ,-6722 ,-6846 ,-6961 ,-7066 ,-7162 ,-7253 ,-7329 ,-7398 , -7458 ,-7506 ,-7544 ,-7571 ,-7597 ,-7608 ,-7617 ,-7613 ,-7610 ,-7604 ,-7589 ,-7576 ,-7556 ,-7541 ,-7504 , -7466 ,-7428 ,-7381 ,-7331 ,-7273 ,-7215 ,-7149 ,-7085 ,-7018 ,-6943 ,-6862 ,-6781 ,-6690 ,-6593 ,-6494 , -6384 ,-6279 ,-6160 ,-6039 ,-5915 ,-5780 ,-5646 ,-5500 ,-5344 ,-5181 ,-5017 ,-4843 ,-4673 ,-4493 ,-4305 , -4119 ,-3925 ,-3730 ,-3539 ,-3343 ,-3145 ,-2948 ,-2741 ,-2544 ,-2336 ,-2135 ,-1932 ,-1726 ,-1536 ,-1333 , -1149 ,-965 ,-785 ,-611 ,-433 ,-258 ,-80 ,81 ,263 ,445 ,619 ,805 ,988 ,1182 ,1368 , 1568 ,1768 ,1966 ,2174 ,2372 ,2575 ,2776 ,2972 ,3169 ,3359 ,3538 ,3714 ,3881 ,4041 ,4200 , 4352 ,4501 ,4639 ,4770 ,4892 ,5005 ,5117 ,5216 ,5313 ,5403 ,5488 ,5571 ,5656 ,5736 ,5812 , 5886 ,5953 ,6021 ,6078 ,6134 ,6185 ,6228 ,6271 ,6297 ,6328 ,6353 ,6374 ,6396 ,6409 ,6429 , 6443 ,6457 ,6475 ,6486 ,6495 ,6508 ,6519 ,6530 ,6538 ,6543 ,6550 ,6549 ,6546 ,6536 ,6525 , 6499 ,6478 ,6443 ,6399 ,6356 ,6292 ,6234 ,6157 ,6083 ,6006 ,5920 ,5832 ,5740 ,5651 ,5555 , 5464 ,5373 ,5281 ,5190 ,5107 ,5015 ,4920 ,4830 ,4726 ,4620 ,4509 ,4387 ,4260 ,4129 ,3981 , 3839 ,3690 ,3541 ,3392 ,3226 ,3062 ,2895 ,2729 ,2560 ,2378 ,2197 ,2012 ,1812 ,1616 ,1408 , 1201 ,996 ,781 ,577 ,363 ,153 ,-47 ,-255 ,-456 ,-657 ,-855 ,-1051 ,-1242 ,-1430 ,-1618 , -1797 ,-1978 ,-2148 ,-2318 ,-2494 ,-2656 ,-2815 ,-2974 ,-3128 ,-3280 ,-3421 ,-3568 ,-3706 ,-3839 ,-3967 , -4084 ,-4203 ,-4306 ,-4408 ,-4505 ,-4601 ,-4689 ,-4776 ,-4862 ,-4952 ,-5041 ,-5124 ,-5220 ,-5309 ,-5402 , -5490 ,-5573 ,-5648 ,-5726 ,-5787 ,-5844 ,-5905 ,-5944 ,-5993 ,-6028 ,-6063 ,-6092 ,-6113 ,-6133 ,-6145 , -6167 ,-6179 ,-6188 ,-6200 ,-6208 ,-6209 ,-6205 ,-6192 ,-6180 ,-6166 ,-6142 ,-6120 ,-6093 ,-6057 ,-6020 , -5976 ,-5928 ,-5876 ,-5820 ,-5763 ,-5702 ,-5643 ,-5588 ,-5530 ,-5470 ,-5406 ,-5340 ,-5276 ,-5203 ,-5123 , -5040 ,-4951 ,-4863 ,-4766 ,-4664 ,-4561 ,-4449 ,-4329 ,-4211 ,-4089 ,-3964 ,-3839 ,-3711 ,-3586 ,-3452 , -3319 ,-3178 ,-3036 ,-2883 ,-2720 ,-2562 ,-2388 ,-2219 ,-2048 ,-1862 ,-1685 ,-1518 ,-1349 ,-1185 ,-1030 , -874 ,-721 ,-564 ,-410 ,-252 ,-89 ,70 ,242 ,413 ,584 ,765 ,933 ,1112 ,1289 ,1456 , 1634 ,1801 ,1969 ,2135 ,2300 ,2466 ,2630 ,2792 ,2944 ,3096 ,3244 ,3391 ,3533 ,3674 ,3809 , 3943 ,4076 ,4202 ,4334 ,4455 ,4574 ,4695 ,4807 ,4915 ,5017 ,5117 ,5211 ,5303 ,5392 ,5476 , 5557 ,5640 ,5725 ,5800 ,5866 ,5933 ,5991 ,6042 ,6086 ,6125 ,6169 ,6202 ,6234 ,6262 ,6286 , 6308 ,6325 ,6332 ,6336 ,6341 ,6332 ,6324 ,6303 ,6274 ,6244 ,6203 ,6152 ,6095 ,6037 ,5967 , 5897 ,5821 ,5736 ,5646 ,5552 ,5453 ,5354 ,5245 ,5128 ,5017 ,4900 ,4784 ,4661 ,4542 ,4422 , 4299 ,4179 ,4051 ,3929 ,3800 ,3671 ,3546 ,3415 ,3287 ,3151 ,3030 ,2899 ,2764 ,2643 ,2515 , 2403 ,2289 ,2179 ,2069 ,1953 ,1841 ,1726 ,1611 ,1495 ,1378 ,1246 ,1124 ,990 ,852 ,723 , 576 ,445 ,308 ,159 ,22 ,-118 ,-263 ,-414 ,-565 ,-721 ,-871 ,-1030 ,-1194 ,-1344 ,-1499 , -1652 ,-1799 ,-1938 ,-2073 ,-2208 ,-2340 ,-2469 ,-2600 ,-2731 ,-2863 ,-2994 ,-3124 ,-3262 ,-3400 ,-3535 , -3662 ,-3788 ,-3907 ,-4026 ,-4137 ,-4240 ,-4341 ,-4435 ,-4532 ,-4614 ,-4696 ,-4780 ,-4854 ,-4927 ,-4998 , -5060 ,-5123 ,-5181 ,-5228 ,-5275 ,-5314 ,-5350 ,-5385 ,-5412 ,-5434 ,-5461 ,-5480 ,-5506 ,-5527 ,-5548 , -5564 ,-5575 ,-5597 ,-5607 ,-5620 ,-5633 ,-5646 ,-5655 ,-5662 ,-5666 ,-5664 ,-5658 ,-5642 ,-5621 ,-5591 , -5552 ,-5506 ,-5454 ,-5392 ,-5331 ,-5268 ,-5196 ,-5123 ,-5048 ,-4959 ,-4879 ,-4794 ,-4693 ,-4597 ,-4492 , -4381 ,-4257 ,-4134 ,-4008 ,-3873 ,-3742 ,-3606 ,-3468 ,-3327 ,-3192 ,-3056 ,-2916 ,-2784 ,-2644 ,-2503 , -2359 ,-2213 ,-2065 ,-1910 ,-1762 ,-1603 ,-1455 ,-1303 ,-1155 ,-1012 ,-847 ,-695 ,-533 ,-368 ,-204 , -35 ,133 ,312 ,478 ,647 ,813 ,979 ,1140 ,1289 ,1442 ,1587 ,1737 ,1884 ,2033 ,2179 , 2323 ,2470 ,2605 ,2746 ,2877 ,3002 ,3126 ,3251 ,3377 ,3494 ,3615 ,3735 ,3854 ,3975 ,4093 , 4214 ,4324 ,4434 ,4537 ,4629 ,4720 ,4799 ,4880 ,4953 ,5028 ,5101 ,5166 ,5233 ,5294 ,5358 , 5413 ,5458 ,5504 ,5536 ,5556 ,5566 ,5566 ,5562 ,5541 ,5508 ,5473 ,5431 ,5379 ,5327 ,5270 , 5212 ,5156 ,5097 ,5037 ,4971 ,4911 ,4851 ,4785 ,4724 ,4665 ,4602 ,4548 ,4494 ,4437 ,4380 , 4324 ,4266 ,4203 ,4144 ,4078 ,4012 ,3941 ,3869 ,3794 ,3712 ,3629 ,3544 ,3455 ,3361 ,3275 , 3180 ,3088 ,2990 ,2893 ,2792 ,2688 ,2590 ,2478 ,2371 ,2264 ,2155 ,2049 ,1937 ,1828 ,1722 , 1607 ,1500 ,1395 ,1280 ,1173 ,1070 ,956 ,845 ,731 ,613 ,497 ,378 ,262 ,143 ,24 , -86 ,-204 ,-323 ,-440 ,-557 ,-672 ,-787 ,-897 ,-1007 ,-1117 ,-1222 ,-1327 ,-1437 ,-1543 ,-1647 , -1755 ,-1858 ,-1960 ,-2064 ,-2165 ,-2271 ,-2377 ,-2479 ,-2585 ,-2690 ,-2798 ,-2904 ,-3012 ,-3127 ,-3234 , -3350 ,-3458 ,-3563 ,-3674 ,-3769 ,-3870 ,-3964 ,-4056 ,-4141 ,-4216 ,-4296 ,-4358 ,-4423 ,-4482 ,-4536 , -4589 ,-4634 ,-4680 ,-4724 ,-4763 ,-4803 ,-4845 ,-4879 ,-4917 ,-4952 ,-4981 ,-5016 ,-5042 ,-5066 ,-5086 , -5099 ,-5110 ,-5112 ,-5110 ,-5105 ,-5092 ,-5076 ,-5057 ,-5037 ,-5008 ,-4974 ,-4932 ,-4881 ,-4829 ,-4768 , -4704 ,-4633 ,-4556 ,-4484 ,-4402 ,-4309 ,-4218 ,-4120 ,-4017 ,-3908 ,-3794 ,-3678 ,-3548 ,-3422 ,-3286 , -3147 ,-3006 ,-2861 ,-2722 ,-2581 ,-2441 ,-2303 ,-2164 ,-2033 ,-1903 ,-1771 ,-1641 ,-1515 ,-1390 ,-1265 , -1149 ,-1030 ,-911 ,-801 ,-684 ,-574 ,-468 ,-354 ,-246 ,-135 ,-26 ,79 ,193 ,308 ,428 , 550 ,670 ,787 ,906 ,1027 ,1139 ,1257 ,1371 ,1487 ,1603 ,1714 ,1831 ,1942 ,2056 ,2165 , 2269 ,2376 ,2479 ,2586 ,2692 ,2793 ,2901 ,3005 ,3107 ,3210 ,3311 ,3414 ,3517 ,3609 ,3701 , 3793 ,3876 ,3957 ,4031 ,4106 ,4179 ,4239 ,4297 ,4352 ,4403 ,4449 ,4496 ,4537 ,4569 ,4596 , 4618 ,4643 ,4651 ,4657 ,4663 ,4653 ,4647 ,4633 ,4615 ,4591 ,4571 ,4539 ,4499 ,4470 ,4432 , 4397 ,4363 ,4329 ,4296 ,4266 ,4235 ,4206 ,4179 ,4146 ,4119 ,4082 ,4044 ,4003 ,3959 ,3914 , 3866 ,3813 ,3751 ,3692 ,3623 ,3549 ,3477 ,3405 ,3334 ,3255 ,3174 ,3100 ,3023 ,2941 ,2861 , 2779 ,2694 ,2604 ,2505 ,2408 ,2309 ,2207 ,2104 ,2002 ,1901 ,1799 ,1697 ,1590 ,1481 ,1372 , 1262 ,1153 ,1040 ,922 ,803 ,687 ,561 ,430 ,300 ,161 ,29 ,-102 ,-237 ,-376 ,-514 , -651 ,-793 ,-921 ,-1056 ,-1183 ,-1305 ,-1431 ,-1545 ,-1664 ,-1779 ,-1887 ,-1997 ,-2099 ,-2197 ,-2300 , -2393 ,-2486 ,-2584 ,-2679 ,-2771 ,-2862 ,-2949 ,-3031 ,-3115 ,-3193 ,-3274 ,-3353 ,-3426 ,-3497 ,-3570 , -3639 ,-3699 ,-3761 ,-3819 ,-3876 ,-3926 ,-3979 ,-4029 ,-4071 ,-4115 ,-4150 ,-4184 ,-4206 ,-4233 ,-4252 , -4266 ,-4283 ,-4292 ,-4305 ,-4310 ,-4308 ,-4311 ,-4306 ,-4293 ,-4276 ,-4254 ,-4229 ,-4200 ,-4166 ,-4132 , -4095 ,-4056 ,-4020 ,-3983 ,-3951 ,-3915 ,-3875 ,-3840 ,-3794 ,-3749 ,-3696 ,-3643 ,-3588 ,-3529 ,-3463 , -3391 ,-3325 ,-3253 ,-3179 ,-3105 ,-3036 ,-2964 ,-2891 ,-2816 ,-2743 ,-2674 ,-2593 ,-2520 ,-2444 ,-2367 , -2286 ,-2204 ,-2130 ,-2047 ,-1969 ,-1889 ,-1798 ,-1706 ,-1610 ,-1511 ,-1409 ,-1298 ,-1188 ,-1076 ,-960 , -846 ,-736 ,-619 ,-509 ,-396 ,-278 ,-161 ,-46 ,63 ,190 ,311 ,432 ,552 ,674 ,801 , 915 ,1037 ,1148 ,1263 ,1372 ,1470 ,1567 ,1652 ,1739 ,1819 ,1901 ,1976 ,2046 ,2118 ,2184 , 2246 ,2304 ,2367 ,2424 ,2488 ,2550 ,2609 ,2677 ,2737 ,2803 ,2872 ,2937 ,2998 ,3061 ,3127 , 3192 ,3260 ,3331 ,3399 ,3469 ,3537 ,3605 ,3673 ,3738 ,3811 ,3874 ,3938 ,3999 ,4054 ,4105 , 4143 ,4180 ,4209 ,4234 ,4259 ,4274 ,4291 ,4305 ,4308 ,4314 ,4319 ,4322 ,4315 ,4305 ,4304 , 4283 ,4271 ,4252 ,4219 ,4191 ,4149 ,4116 ,4078 ,4033 ,3988 ,3941 ,3889 ,3835 ,3776 ,3704 , 3635 ,3548 ,3460 ,3371 ,3272 ,3174 ,3071 ,2975 ,2869 ,2765 ,2661 ,2550 ,2441 ,2334 ,2226 , 2111 ,2005 ,1897 ,1790 ,1687 ,1577 ,1469 ,1361 ,1248 ,1129 ,1009 ,887 ,756 ,628 ,498 , 363 ,240 ,108 ,-13 ,-128 ,-250 ,-363 ,-478 ,-588 ,-694 ,-803 ,-903 ,-1003 ,-1103 ,-1199 , -1294 ,-1389 ,-1477 ,-1568 ,-1663 ,-1746 ,-1837 ,-1926 ,-2011 ,-2096 ,-2177 ,-2254 ,-2332 ,-2403 ,-2475 , -2547 ,-2607 ,-2671 ,-2728 ,-2783 ,-2841 ,-2894 ,-2942 ,-2996 ,-3050 ,-3096 ,-3148 ,-3194 ,-3244 ,-3292 , -3340 ,-3387 ,-3431 ,-3477 ,-3514 ,-3548 ,-3584 ,-3610 ,-3634 ,-3653 ,-3663 ,-3676 ,-3675 ,-3673 ,-3668 , -3656 ,-3646 ,-3627 ,-3603 ,-3585 ,-3566 ,-3544 ,-3524 ,-3505 ,-3484 ,-3462 ,-3441 ,-3425 ,-3406 ,-3382 , -3362 ,-3342 ,-3325 ,-3297 ,-3277 ,-3251 ,-3212 ,-3185 ,-3145 ,-3108 ,-3065 ,-3017 ,-2974 ,-2924 ,-2875 , -2824 ,-2768 ,-2714 ,-2658 ,-2597 ,-2535 ,-2467 ,-2397 ,-2323 ,-2247 ,-2168 ,-2089 ,-2010 ,-1927 ,-1838 , -1750 ,-1662 ,-1574 ,-1494 ,-1410 ,-1324 ,-1238 ,-1154 ,-1062 ,-974 ,-881 ,-787 ,-693 ,-587 ,-489 , -386 ,-281 ,-180 ,-78 ,20 ,126 ,229 ,334 ,444 ,551 ,666 ,785 ,901 ,1017 ,1133 , 1256 ,1375 ,1488 ,1603 ,1713 ,1823 ,1933 ,2041 ,2145 ,2245 ,2345 ,2445 ,2541 ,2630 ,2714 , 2800 ,2871 ,2940 ,3001 ,3053 ,3107 ,3146 ,3190 ,3228 ,3265 ,3301 ,3336 ,3372 ,3398 ,3424 , 3439 ,3457 ,3468 ,3467 ,3467 ,3462 ,3454 ,3444 ,3434 ,3417 ,3393 ,3370 ,3347 ,3320 ,3292 , 3262 ,3232 ,3203 ,3173 ,3142 ,3111 ,3077 ,3044 ,3011 ,2972 ,2936 ,2902 ,2863 ,2830 ,2793 , 2756 ,2722 ,2691 ,2656 ,2620 ,2588 ,2554 ,2524 ,2492 ,2467 ,2442 ,2416 ,2388 ,2364 ,2343 , 2311 ,2287 ,2257 ,2218 ,2184 ,2145 ,2108 ,2067 ,2024 ,1982 ,1933 ,1887 ,1833 ,1774 ,1716 , 1650 ,1589 ,1524 ,1450 ,1377 ,1296 ,1212 ,1137 ,1048 ,965 ,882 ,795 ,709 ,615 ,530 , 438 ,343 ,249 ,157 ,65 ,-25 ,-116 ,-207 ,-297 ,-394 ,-478 ,-572 ,-662 ,-745 ,-838 , -931 ,-1026 ,-1117 ,-1213 ,-1308 ,-1402 ,-1497 ,-1592 ,-1687 ,-1775 ,-1868 ,-1956 ,-2042 ,-2132 ,-2217 , -2299 ,-2376 ,-2458 ,-2538 ,-2611 ,-2685 ,-2749 ,-2813 ,-2878 ,-2933 ,-2987 ,-3029 ,-3077 ,-3113 ,-3144 , -3179 ,-3202 ,-3223 ,-3238 ,-3252 ,-3260 ,-3258 ,-3250 ,-3235 ,-3219 ,-3206 ,-3187 ,-3167 ,-3145 ,-3128 , -3109 ,-3092 ,-3077 ,-3057 ,-3050 ,-3028 ,-3014 ,-3003 ,-2985 ,-2979 ,-2972 ,-2963 ,-2957 ,-2953 ,-2942 , -2935 ,-2926 ,-2911 ,-2900 ,-2881 ,-2859 ,-2833 ,-2808 ,-2777 ,-2734 ,-2693 ,-2636 ,-2583 ,-2518 ,-2447 , -2381 ,-2299 ,-2227 ,-2149 ,-2059 ,-1969 ,-1880 ,-1791 ,-1700 ,-1610 ,-1519 ,-1427 ,-1347 ,-1269 ,-1193 , -1123 ,-1048 ,-978 ,-906 ,-837 ,-768 ,-703 ,-637 ,-574 ,-505 ,-426 ,-354 ,-274 ,-193 ,-108 , -26 ,54 ,146 ,237 ,325 ,408 ,493 ,574 ,657 ,740 ,812 ,889 ,965 ,1035 ,1106 , 1176 ,1243 ,1309 ,1376 ,1437 ,1500 ,1563 ,1630 ,1694 ,1759 ,1827 ,1890 ,1956 ,2019 ,2084 , 2146 ,2215 ,2280 ,2337 ,2404 ,2465 ,2524 ,2584 ,2642 ,2704 ,2755 ,2804 ,2860 ,2902 ,2944 , 2978 ,3006 ,3038 ,3058 ,3082 ,3104 ,3117 ,3128 ,3138 ,3140 ,3144 ,3150 ,3157 ,3158 ,3148 , 3149 ,3145 ,3141 ,3136 ,3129 ,3123 ,3119 ,3104 ,3086 ,3066 ,3047 ,3030 ,3005 ,2985 ,2958 , 2931 ,2904 ,2871 ,2836 ,2804 ,2765 ,2722 ,2688 ,2643 ,2596 ,2547 ,2494 ,2443 ,2386 ,2331 , 2270 ,2208 ,2149 ,2082 ,2015 ,1948 ,1879 ,1812 ,1746 ,1682 ,1614 ,1545 ,1475 ,1399 ,1322 , 1249 ,1172 ,1088 ,1005 ,926 ,840 ,764 ,679 ,591 ,508 ,409 ,315 ,218 ,116 ,20 , -77 ,-176 ,-288 ,-391 ,-494 ,-596 ,-694 ,-794 ,-884 ,-979 ,-1063 ,-1145 ,-1222 ,-1293 ,-1368 , -1434 ,-1500 ,-1562 ,-1618 ,-1670 ,-1724 ,-1772 ,-1822 ,-1869 ,-1918 ,-1969 ,-2014 ,-2067 ,-2117 ,-2160 , -2213 ,-2265 ,-2310 ,-2360 ,-2404 ,-2446 ,-2490 ,-2532 ,-2573 ,-2613 ,-2654 ,-2692 ,-2724 ,-2751 ,-2779 , -2804 ,-2824 ,-2836 ,-2845 ,-2852 ,-2846 ,-2836 ,-2824 ,-2819 ,-2804 ,-2784 ,-2776 ,-2757 ,-2747 ,-2742 , -2731 ,-2731 ,-2721 ,-2710 ,-2709 ,-2697 ,-2681 ,-2673 ,-2662 ,-2647 ,-2627 ,-2608 ,-2595 ,-2578 ,-2559 , -2540 ,-2519 ,-2507 ,-2483 ,-2457 ,-2432 ,-2404 ,-2375 ,-2341 ,-2302 ,-2261 ,-2222 ,-2175 ,-2130 ,-2077 , -2018 ,-1959 ,-1891 ,-1831 ,-1761 ,-1686 ,-1615 ,-1541 ,-1470 ,-1396 ,-1324 ,-1252 ,-1175 ,-1094 ,-1016 , -942 ,-858 ,-772 ,-686 ,-602 ,-520 ,-430 ,-348 ,-264 ,-180 ,-98 ,-20 ,51 ,131 ,212 , 293 ,370 ,446 ,525 ,599 ,670 ,750 ,825 ,903 ,986 ,1065 ,1153 ,1237 ,1318 ,1404 , 1489 ,1567 ,1652 ,1727 ,1797 ,1871 ,1932 ,1996 ,2059 ,2109 ,2160 ,2207 ,2248 ,2285 ,2313 , 2347 ,2375 ,2403 ,2430 ,2451 ,2483 ,2510 ,2534 ,2565 ,2591 ,2612 ,2640 ,2661 ,2671 ,2690 , 2704 ,2710 ,2719 ,2727 ,2730 ,2735 ,2731 ,2726 ,2726 ,2708 ,2705 ,2690 ,2667 ,2660 ,2633 , 2613 ,2591 ,2566 ,2536 ,2508 ,2478 ,2445 ,2422 ,2388 ,2357 ,2322 ,2289 ,2256 ,2214 ,2177 , 2139 ,2096 ,2061 ,2020 ,1971 ,1933 ,1883 ,1834 ,1793 ,1746 ,1705 ,1660 ,1615 ,1578 ,1537 , 1495 ,1457 ,1412 ,1364 ,1317 ,1262 ,1204 ,1142 ,1078 ,1010 ,944 ,875 ,799 ,727 ,651 , 580 ,507 ,433 ,368 ,296 ,225 ,164 ,98 ,34 ,-20 ,-76 ,-135 ,-189 ,-245 ,-301 , -356 ,-416 ,-468 ,-527 ,-580 ,-630 ,-687 ,-740 ,-793 ,-838 ,-891 ,-938 ,-986 ,-1038 ,-1076 , -1120 ,-1161 ,-1203 ,-1240 ,-1280 ,-1321 ,-1353 ,-1395 ,-1431 ,-1468 ,-1502 ,-1534 ,-1572 ,-1608 ,-1653 , -1691 ,-1733 ,-1774 ,-1812 ,-1853 ,-1890 ,-1929 ,-1963 ,-1997 ,-2032 ,-2070 ,-2105 ,-2136 ,-2168 ,-2199 , -2224 ,-2247 ,-2272 ,-2288 ,-2312 ,-2331 ,-2347 ,-2362 ,-2378 ,-2399 ,-2412 ,-2428 ,-2438 ,-2449 ,-2462 , -2473 ,-2481 ,-2480 ,-2480 ,-2485 ,-2483 ,-2475 ,-2478 ,-2460 ,-2444 ,-2432 ,-2405 ,-2378 ,-2342 ,-2310 , -2271 ,-2231 ,-2184 ,-2129 ,-2077 ,-2019 ,-1958 ,-1889 ,-1827 ,-1765 ,-1696 ,-1630 ,-1559 ,-1486 ,-1423 , -1354 ,-1283 ,-1220 ,-1153 ,-1096 ,-1038 ,-981 ,-927 ,-872 ,-822 ,-768 ,-713 ,-662 ,-609 ,-554 , -501 ,-447 ,-391 ,-332 ,-273 ,-210 ,-147 ,-81 ,-19 ,38 ,101 ,162 ,226 ,290 ,359 , 425 ,488 ,551 ,606 ,662 ,715 ,765 ,811 ,857 ,898 ,939 ,981 ,1021 ,1065 ,1104 , 1150 ,1196 ,1242 ,1291 ,1340 ,1388 ,1434 ,1485 ,1527 ,1570 ,1615 ,1661 ,1708 ,1754 ,1799 , 1842 ,1884 ,1927 ,1973 ,2014 ,2060 ,2099 ,2137 ,2183 ,2225 ,2264 ,2305 ,2345 ,2387 ,2428 , 2468 ,2516 ,2560 ,2598 ,2636 ,2669 ,2694 ,2706 ,2719 ,2724 ,2713 ,2705 ,2686 ,2666 ,2645 , 2614 ,2585 ,2554 ,2520 ,2481 ,2446 ,2406 ,2366 ,2330 ,2291 ,2259 ,2220 ,2178 ,2141 ,2102 , 2059 ,2007 ,1961 ,1917 ,1865 ,1818 ,1772 ,1715 ,1660 ,1607 ,1547 ,1479 ,1413 ,1349 ,1276 , 1207 ,1133 ,1063 ,994 ,922 ,855 ,784 ,723 ,655 ,591 ,530 ,463 ,402 ,336 ,279 , 218 ,159 ,105 ,46 ,-4 ,-47 ,-101 ,-144 ,-191 ,-239 ,-280 ,-330 ,-371 ,-421 ,-470 , -519 ,-573 ,-627 ,-687 ,-748 ,-805 ,-865 ,-924 ,-975 ,-1031 ,-1083 ,-1138 ,-1186 ,-1235 ,-1287 , -1332 ,-1380 ,-1428 ,-1478 ,-1523 ,-1569 ,-1617 ,-1660 ,-1697 ,-1736 ,-1765 ,-1795 ,-1830 ,-1857 ,-1881 , -1906 ,-1931 ,-1949 ,-1970 ,-1985 ,-2000 ,-2020 ,-2033 ,-2052 ,-2061 ,-2065 ,-2075 ,-2077 ,-2077 ,-2082 , -2080 ,-2073 ,-2064 ,-2062 ,-2059 ,-2048 ,-2042 ,-2025 ,-2020 ,-2017 ,-2002 ,-1996 ,-1987 ,-1981 ,-1979 , -1968 ,-1954 ,-1945 ,-1945 ,-1931 ,-1913 ,-1908 ,-1895 ,-1876 ,-1859 ,-1838 ,-1817 ,-1791 ,-1761 ,-1736 , -1707 ,-1672 ,-1643 ,-1605 ,-1571 ,-1530 ,-1489 ,-1449 ,-1400 ,-1361 ,-1318 ,-1269 ,-1217 ,-1173 ,-1122 , -1067 ,-1022 ,-966 ,-912 ,-854 ,-790 ,-732 ,-674 ,-612 ,-551 ,-487 ,-425 ,-364 ,-303 ,-242 , -180 ,-129 ,-74 ,-23 ,22 ,83 ,130 ,181 ,236 ,289 ,341 ,394 ,450 ,499 ,554 , 603 ,655 ,712 ,761 ,813 ,865 ,912 ,962 ,1013 ,1056 ,1100 ,1146 ,1187 ,1224 ,1264 , 1296 ,1328 ,1360 ,1385 ,1420 ,1450 ,1480 ,1514 ,1542 ,1575 ,1605 ,1635 ,1668 ,1695 ,1724 , 1749 ,1780 ,1806 ,1834 ,1854 ,1885 ,1910 ,1925 ,1960 ,1974 ,1998 ,2017 ,2042 ,2059 ,2075 , 2100 ,2113 ,2133 ,2143 ,2163 ,2170 ,2184 ,2197 ,2204 ,2209 ,2206 ,2208 ,2205 ,2208 ,2203 , 2191 ,2176 ,2166 ,2151 ,2125 ,2096 ,2068 ,2034 ,1991 ,1950 ,1902 ,1853 ,1800 ,1744 ,1688 , 1628 ,1574 ,1521 ,1468 ,1416 ,1371 ,1328 ,1276 ,1233 ,1188 ,1138 ,1090 ,1036 ,983 ,929 , 872 ,815 ,757 ,701 ,643 ,590 ,535 ,484 ,433 ,384 ,333 ,286 ,241 ,188 ,146 , 101 ,53 ,16 ,-21 ,-62 ,-106 ,-140 ,-174 ,-217 ,-257 ,-293 ,-335 ,-374 ,-414 ,-455 , -496 ,-545 ,-592 ,-641 ,-695 ,-749 ,-801 ,-855 ,-908 ,-962 ,-1014 ,-1063 ,-1115 ,-1168 ,-1221 , -1265 ,-1317 ,-1366 ,-1411 ,-1457 ,-1495 ,-1543 ,-1582 ,-1622 ,-1661 ,-1688 ,-1726 ,-1758 ,-1790 ,-1825 , -1851 ,-1881 ,-1906 ,-1931 ,-1950 ,-1972 ,-1988 ,-1998 ,-2013 ,-2023 ,-2035 ,-2043 ,-2042 ,-2042 ,-2043 , -2034 ,-2021 ,-2017 ,-2000 ,-1984 ,-1972 ,-1948 ,-1925 ,-1903 ,-1879 ,-1845 ,-1817 ,-1789 ,-1761 ,-1733 , -1692 ,-1658 ,-1620 ,-1587 ,-1549 ,-1513 ,-1480 ,-1440 ,-1405 ,-1371 ,-1334 ,-1302 ,-1267 ,-1233 ,-1205 , -1166 ,-1137 ,-1100 ,-1066 ,-1038 ,-998 ,-964 ,-924 ,-885 ,-845 ,-807 ,-767 ,-725 ,-688 ,-648 , -613 ,-573 ,-539 ,-502 ,-461 ,-428 ,-390 ,-354 ,-320 ,-289 ,-253 ,-220 ,-180 ,-142 ,-112 , -63 ,-28 ,9 ,54 ,100 ,151 ,193 ,245 ,294 ,341 ,390 ,438 ,485 ,532 ,582 , 630 ,688 ,741 ,786 ,836 ,892 ,943 ,994 ,1047 ,1102 ,1156 ,1201 ,1246 ,1284 ,1327 , 1361 ,1387 ,1421 ,1450 ,1478 ,1503 ,1526 ,1552 ,1581 ,1596 ,1619 ,1637 ,1647 ,1657 ,1660 , 1668 ,1665 ,1663 ,1658 ,1658 ,1656 ,1645 ,1642 ,1641 ,1640 ,1637 ,1637 ,1636 ,1636 ,1635 , 1638 ,1639 ,1638 ,1644 ,1644 ,1649 ,1648 ,1641 ,1640 ,1637 ,1630 ,1616 ,1605 ,1596 ,1589 , 1571 ,1561 ,1550 ,1530 ,1511 ,1494 ,1476 ,1452 ,1433 ,1408 ,1383 ,1354 ,1320 ,1293 ,1258 , 1229 ,1202 ,1169 ,1144 ,1111 ,1081 ,1053 ,1022 ,992 ,957 ,926 ,891 ,859 ,820 ,775 , 737 ,691 ,643 ,600 ,553 ,501 ,451 ,402 ,354 ,307 ,260 ,212 ,163 ,114 ,64 , 14 ,-28 ,-72 ,-123 ,-168 ,-215 ,-262 ,-305 ,-350 ,-386 ,-424 ,-461 ,-499 ,-539 ,-575 , -615 ,-648 ,-684 ,-718 ,-747 ,-777 ,-804 ,-830 ,-851 ,-876 ,-900 ,-914 ,-930 ,-957 ,-973 , -997 ,-1021 ,-1044 ,-1072 ,-1098 ,-1133 ,-1160 ,-1194 ,-1226 ,-1257 ,-1304 ,-1337 ,-1380 ,-1420 ,-1455 , -1499 ,-1530 ,-1573 ,-1609 ,-1646 ,-1683 ,-1714 ,-1752 ,-1780 ,-1814 ,-1833 ,-1855 ,-1872 ,-1885 ,-1894 , -1889 ,-1893 ,-1886 ,-1873 ,-1863 ,-1847 ,-1830 ,-1814 ,-1792 ,-1768 ,-1746 ,-1720 ,-1692 ,-1673 ,-1640 , -1606 ,-1575 ,-1542 ,-1511 ,-1474 ,-1442 ,-1399 ,-1364 ,-1328 ,-1280 ,-1239 ,-1194 ,-1148 ,-1101 ,-1049 , -1002 ,-958 ,-906 ,-858 ,-806 ,-758 ,-711 ,-654 ,-605 ,-554 ,-501 ,-449 ,-398 ,-340 ,-288 , -245 ,-187 ,-137 ,-91 ,-39 ,-4 ,34 ,72 ,104 ,140 ,166 ,192 ,216 ,232 ,253 , 270 ,284 ,298 ,307 ,323 ,336 ,356 ,375 ,393 ,423 ,447 ,478 ,514 ,546 ,586 , 620 ,655 ,696 ,738 ,780 ,816 ,858 ,895 ,930 ,971 ,1013 ,1053 ,1091 ,1130 ,1176 , 1215 ,1247 ,1288 ,1318 ,1350 ,1377 ,1400 ,1429 ,1445 ,1466 ,1483 ,1500 ,1516 ,1521 ,1540 , 1553 ,1565 ,1584 ,1593 ,1599 ,1608 ,1616 ,1616 ,1616 ,1617 ,1610 ,1602 ,1594 ,1585 ,1566 , 1555 ,1538 ,1521 ,1514 ,1495 ,1482 ,1464 ,1450 ,1434 ,1413 ,1391 ,1369 ,1354 ,1327 ,1299 , 1276 ,1250 ,1222 ,1202 ,1178 ,1151 ,1130 ,1106 ,1084 ,1065 ,1046 ,1029 ,1006 ,986 ,966 , 938 ,916 ,889 ,864 ,834 ,799 ,766 ,731 ,697 ,664 ,625 ,589 ,557 ,516 ,480 , 443 ,406 ,368 ,331 ,297 ,257 ,226 ,192 ,158 ,126 ,91 ,65 ,32 ,1 ,-21 , -50 ,-76 ,-104 ,-133 ,-155 ,-183 ,-211 ,-235 ,-267 ,-294 ,-326 ,-366 ,-401 ,-438 ,-479 , -523 ,-568 ,-613 ,-661 ,-711 ,-763 ,-815 ,-869 ,-922 ,-972 ,-1025 ,-1075 ,-1126 ,-1171 ,-1215 , -1259 ,-1295 ,-1332 ,-1365 ,-1393 ,-1419 ,-1437 ,-1452 ,-1466 ,-1468 ,-1471 ,-1478 ,-1478 ,-1469 ,-1459 , -1457 ,-1451 ,-1447 ,-1441 ,-1435 ,-1432 ,-1431 ,-1432 ,-1430 ,-1431 ,-1433 ,-1438 ,-1445 ,-1447 ,-1450 , -1449 ,-1450 ,-1442 ,-1433 ,-1425 ,-1410 ,-1399 ,-1380 ,-1364 ,-1342 ,-1314 ,-1294 ,-1267 ,-1239 ,-1212 , -1186 ,-1156 ,-1124 ,-1088 ,-1061 ,-1030 ,-998 ,-972 ,-936 ,-910 ,-876 ,-844 ,-821 ,-790 ,-761 , -739 ,-707 ,-681 ,-656 ,-620 ,-598 ,-568 ,-540 ,-510 ,-483 ,-454 ,-424 ,-394 ,-360 ,-327 , -291 ,-259 ,-214 ,-175 ,-135 ,-86 ,-42 ,-13 ,26 ,68 ,102 ,145 ,178 ,215 ,246 , 281 ,307 ,339 ,375 ,401 ,438 ,463 ,494 ,525 ,552 ,582 ,605 ,636 ,665 ,692 , 720 ,744 ,769 ,795 ,823 ,847 ,873 ,899 ,924 ,949 ,975 ,1004 ,1031 ,1056 ,1082 , 1108 ,1135 ,1156 ,1181 ,1203 ,1224 ,1246 ,1261 ,1278 ,1298 ,1317 ,1332 ,1353 ,1367 ,1374 , 1391 ,1403 ,1407 ,1413 ,1423 ,1429 ,1431 ,1436 ,1437 ,1437 ,1435 ,1435 ,1433 ,1429 ,1423 , 1414 ,1411 ,1402 ,1397 ,1379 ,1370 ,1361 ,1338 ,1330 ,1305 ,1289 ,1271 ,1242 ,1220 ,1191 , 1163 ,1136 ,1106 ,1075 ,1055 ,1024 ,998 ,978 ,945 ,925 ,899 ,873 ,848 ,824 ,800 , 771 ,746 ,716 ,686 ,653 ,617 ,582 ,549 ,509 ,473 ,437 ,399 ,369 ,330 ,298 , 265 ,233 ,202 ,164 ,142 ,108 ,73 ,48 ,15 ,-5 ,-30 ,-57 ,-79 ,-110 ,-135 , -151 ,-173 ,-202 ,-226 ,-260 ,-286 ,-319 ,-356 ,-388 ,-431 ,-462 ,-505 ,-543 ,-580 ,-626 , -660 ,-708 ,-749 ,-792 ,-846 ,-887 ,-930 ,-972 ,-1016 ,-1054 ,-1089 ,-1128 ,-1153 ,-1181 ,-1208 , -1223 ,-1242 ,-1257 ,-1261 ,-1274 ,-1280 ,-1278 ,-1279 ,-1277 ,-1277 ,-1270 ,-1261 ,-1258 ,-1257 ,-1258 , -1255 ,-1242 ,-1240 ,-1239 ,-1235 ,-1236 ,-1232 ,-1230 ,-1233 ,-1229 ,-1231 ,-1230 ,-1219 ,-1220 ,-1219 , -1215 ,-1209 ,-1200 ,-1187 ,-1183 ,-1174 ,-1156 ,-1145 ,-1132 ,-1112 ,-1093 ,-1078 ,-1057 ,-1039 ,-1018 , -994 ,-974 ,-946 ,-916 ,-895 ,-866 ,-839 ,-819 ,-790 ,-769 ,-749 ,-726 ,-702 ,-678 ,-654 , -624 ,-597 ,-566 ,-535 ,-498 ,-466 ,-433 ,-398 ,-368 ,-328 ,-303 ,-270 ,-237 ,-210 ,-173 , -142 ,-107 ,-75 ,-37 ,-9 ,24 ,64 ,96 ,131 ,167 ,207 ,240 ,276 ,309 ,344 , 376 ,410 ,442 ,470 ,497 ,526 ,551 ,576 ,608 ,631 ,661 ,687 ,712 ,740 ,762 , 785 ,810 ,832 ,852 ,873 ,891 ,910 ,924 ,942 ,963 ,982 ,996 ,1015 ,1037 ,1053 , 1069 ,1079 ,1095 ,1103 ,1113 ,1125 ,1135 ,1142 ,1147 ,1155 ,1162 ,1178 ,1182 ,1198 ,1213 , 1214 ,1230 ,1241 ,1253 ,1260 ,1273 ,1284 ,1291 ,1293 ,1296 ,1303 ,1302 ,1311 ,1308 ,1300 , 1298 ,1293 ,1292 ,1285 ,1267 ,1256 ,1241 ,1222 ,1209 ,1190 ,1169 ,1141 ,1122 ,1092 ,1062 , 1027 ,991 ,954 ,906 ,872 ,827 ,791 ,752 ,714 ,681 ,642 ,609 ,573 ,542 ,504 , 476 ,444 ,412 ,383 ,348 ,318 ,291 ,260 ,225 ,199 ,164 ,139 ,114 ,79 ,56 , 31 ,4 ,-13 ,-41 ,-67 ,-88 ,-115 ,-133 ,-157 ,-173 ,-197 ,-222 ,-239 ,-268 ,-294 , -319 ,-342 ,-369 ,-397 ,-422 ,-450 ,-474 ,-494 ,-517 ,-537 ,-559 ,-580 ,-598 ,-616 ,-631 , -650 ,-671 ,-686 ,-705 ,-723 ,-738 ,-757 ,-773 ,-794 ,-813 ,-829 ,-845 ,-863 ,-883 ,-899 , -915 ,-926 ,-941 ,-955 ,-973 ,-986 ,-993 ,-1002 ,-1015 ,-1028 ,-1034 ,-1046 ,-1055 ,-1062 ,-1071 , -1079 ,-1088 ,-1101 ,-1104 ,-1113 ,-1128 ,-1132 ,-1143 ,-1146 ,-1146 ,-1151 ,-1153 ,-1155 ,-1151 ,-1148 , -1146 ,-1141 ,-1132 ,-1119 ,-1103 ,-1086 ,-1071 ,-1055 ,-1037 ,-1016 ,-993 ,-973 ,-944 ,-917 ,-896 , -862 ,-836 ,-810 ,-778 ,-748 ,-714 ,-679 ,-644 ,-615 ,-585 ,-551 ,-523 ,-494 ,-460 ,-431 , -399 ,-371 ,-345 ,-314 ,-292 ,-259 ,-228 ,-204 ,-173 ,-145 ,-113 ,-79 ,-42 ,-16 ,7 , 45 ,76 ,110 ,144 ,171 ,208 ,240 ,271 ,301 ,335 ,369 ,396 ,431 ,456 ,479 , 511 ,533 ,554 ,579 ,600 ,617 ,643 ,666 ,690 ,710 ,727 ,750 ,762 ,778 ,795 , 802 ,820 ,834 ,838 ,854 ,872 ,884 ,900 ,916 ,928 ,941 ,958 ,975 ,987 ,994 , 1014 ,1026 ,1035 ,1047 ,1055 ,1063 ,1065 ,1066 ,1065 ,1066 ,1065 ,1066 ,1065 ,1064 ,1062 , 1053 ,1050 ,1042 ,1031 ,1026 ,1015 ,1004 ,992 ,987 ,976 ,956 ,950 ,939 ,929 ,915 , 909 ,901 ,888 ,882 ,875 ,876 ,870 ,865 ,859 ,852 ,847 ,838 ,837 ,827 ,806 , 798 ,788 ,773 ,759 ,756 ,743 ,725 ,711 ,694 ,681 ,658 ,635 ,610 ,584 ,553 , 522 ,484 ,445 ,414 ,371 ,337 ,294 ,257 ,223 ,179 ,144 ,102 ,62 ,23 ,-10 , -46 ,-84 ,-118 ,-155 ,-189 ,-230 ,-265 ,-295 ,-334 ,-368 ,-398 ,-432 ,-464 ,-489 ,-514 , -537 ,-556 ,-574 ,-590 ,-603 ,-611 ,-620 ,-637 ,-649 ,-647 ,-658 ,-668 ,-671 ,-681 ,-685 , -685 ,-693 ,-700 ,-710 ,-724 ,-738 ,-753 ,-764 ,-781 ,-803 ,-825 ,-840 ,-853 ,-880 ,-895 , -909 ,-920 ,-928 ,-945 ,-955 ,-969 ,-975 ,-981 ,-986 ,-982 ,-988 ,-986 ,-976 ,-975 ,-968 , -956 ,-951 ,-941 ,-925 ,-914 ,-900 ,-886 ,-869 ,-848 ,-838 ,-828 ,-813 ,-800 ,-789 ,-770 , -764 ,-750 ,-731 ,-716 ,-693 ,-675 ,-651 ,-630 ,-605 ,-576 ,-548 ,-522 ,-489 ,-462 ,-437 , -405 ,-384 ,-356 ,-340 ,-317 ,-301 ,-290 ,-272 ,-264 ,-247 ,-239 ,-235 ,-228 ,-225 ,-215 , -213 ,-203 ,-191 ,-192 ,-183 ,-171 ,-159 ,-153 ,-148 ,-135 ,-128 ,-116 ,-98 ,-81 ,-64 , -45 ,-21 ,-6 ,7 ,40 ,59 ,86 ,111 ,132 ,163 ,186 ,211 ,237 ,268 ,296 , 322 ,356 ,384 ,413 ,447 ,473 ,508 ,536 ,560 ,589 ,607 ,633 ,650 ,666 ,684 , 694 ,710 ,720 ,727 ,741 ,754 ,756 ,757 ,763 ,773 ,778 ,778 ,790 ,797 ,800 , 815 ,823 ,832 ,834 ,840 ,847 ,850 ,866 ,875 ,877 ,882 ,886 ,895 ,897 ,902 , 910 ,910 ,913 ,912 ,919 ,930 ,929 ,930 ,938 ,946 ,949 ,950 ,949 ,951 ,939 , 930 ,927 ,918 ,909 ,896 ,882 ,864 ,847 ,829 ,811 ,790 ,767 ,748 ,725 ,703 , 684 ,664 ,644 ,625 ,602 ,578 ,552 ,529 ,504 ,480 ,454 ,426 ,401 ,374 ,345 , 315 ,287 ,257 ,227 ,196 ,162 ,132 ,104 ,72 ,43 ,16 ,-5 ,-26 ,-52 ,-79 , -104 ,-125 ,-145 ,-163 ,-186 ,-211 ,-230 ,-250 ,-275 ,-295 ,-313 ,-337 ,-360 ,-382 ,-399 , -426 ,-451 ,-465 ,-488 ,-507 ,-524 ,-539 ,-554 ,-569 ,-579 ,-592 ,-601 ,-612 ,-622 ,-637 , -647 ,-650 ,-665 ,-671 ,-679 ,-685 ,-686 ,-691 ,-695 ,-701 ,-705 ,-708 ,-710 ,-714 ,-713 , -716 ,-721 ,-725 ,-728 ,-727 ,-731 ,-737 ,-744 ,-745 ,-745 ,-746 ,-746 ,-747 ,-745 ,-744 , -740 ,-730 ,-726 ,-722 ,-711 ,-703 ,-695 ,-689 ,-686 ,-686 ,-680 ,-668 ,-669 ,-668 ,-661 , -653 ,-648 ,-648 ,-638 ,-628 ,-616 ,-610 ,-603 ,-583 ,-575 ,-561 ,-545 ,-533 ,-517 ,-504 , -487 ,-467 ,-457 ,-441 ,-421 ,-405 ,-384 ,-368 ,-347 ,-320 ,-302 ,-284 ,-263 ,-243 ,-225 , -210 ,-191 ,-173 ,-155 ,-140 ,-117 ,-98 ,-83 ,-56 ,-41 ,-16 ,-3 ,13 ,48 ,67 , 95 ,120 ,141 ,165 ,186 ,212 ,235 ,262 ,283 ,302 ,328 ,353 ,376 ,394 ,418 , 438 ,455 ,476 ,486 ,504 ,525 ,534 ,546 ,563 ,572 ,579 ,594 ,604 ,609 ,619 , 629 ,642 ,652 ,663 ,677 ,683 ,693 ,700 ,714 ,723 ,723 ,736 ,741 ,746 ,753 , 758 ,760 ,766 ,778 ,777 ,784 ,795 ,796 ,798 ,801 ,806 ,809 ,817 ,826 ,827 , 831 ,834 ,834 ,835 ,833 ,831 ,832 ,829 ,823 ,813 ,805 ,798 ,791 ,777 ,761 , 755 ,743 ,728 ,709 ,693 ,677 ,656 ,633 ,611 ,598 ,577 ,559 ,541 ,526 ,507 , 484 ,472 ,451 ,433 ,408 ,386 ,372 ,343 ,318 ,299 ,276 ,255 ,227 ,208 ,182 , 158 ,145 ,125 ,103 ,83 ,74 ,58 ,41 ,31 ,18 ,4 ,-1 ,-13 ,-31 ,-43 , -64 ,-76 ,-100 ,-116 ,-133 ,-153 ,-165 ,-189 ,-204 ,-224 ,-238 ,-256 ,-276 ,-294 ,-317 , -332 ,-356 ,-373 ,-394 ,-416 ,-434 ,-455 ,-470 ,-489 ,-504 ,-525 ,-537 ,-557 ,-573 ,-589 , -610 ,-614 ,-636 ,-652 ,-663 ,-678 ,-686 ,-699 ,-718 ,-722 ,-731 ,-746 ,-745 ,-757 ,-763 , -760 ,-768 ,-769 ,-767 ,-767 ,-764 ,-762 ,-761 ,-759 ,-754 ,-746 ,-746 ,-734 ,-726 ,-724 , -715 ,-704 ,-694 ,-688 ,-685 ,-686 ,-675 ,-668 ,-668 ,-665 ,-653 ,-647 ,-645 ,-631 ,-621 , -609 ,-603 ,-585 ,-567 ,-549 ,-529 ,-516 ,-491 ,-472 ,-452 ,-435 ,-413 ,-393 ,-380 ,-356 , -338 ,-316 ,-297 ,-279 ,-254 ,-235 ,-214 ,-193 ,-170 ,-153 ,-136 ,-113 ,-94 ,-76 ,-57 , -35 ,-15 ,-4 ,11 ,40 ,60 ,80 ,103 ,123 ,145 ,163 ,180 ,199 ,220 ,235 , 254 ,270 ,288 ,304 ,317 ,339 ,356 ,371 ,381 ,392 ,406 ,416 ,418 ,428 ,440 , 446 ,454 ,454 ,457 ,468 ,473 ,479 ,490 ,491 ,492 ,501 ,511 ,526 ,527 ,535 , 546 ,550 ,566 ,573 ,583 ,595 ,604 ,606 ,612 ,625 ,628 ,642 ,648 ,650 ,657 , 666 ,674 ,677 ,679 ,681 ,683 ,682 ,687 ,689 ,692 ,693 ,694 ,699 ,701 ,702 , 704 ,714 ,715 ,716 ,723 ,722 ,723 ,723 ,722 ,722 ,720 ,716 ,707 ,700 ,697 , 683 ,680 ,673 ,657 ,643 ,629 ,615 ,603 ,591 ,573 ,556 ,539 ,525 ,504 ,485 , 464 ,443 ,423 ,398 ,376 ,351 ,331 ,306 ,284 ,257 ,233 ,215 ,188 ,165 ,139 , 121 ,101 ,74 ,61 ,40 ,15 ,-2 ,-13 ,-36 ,-68 ,-90 ,-117 ,-148 ,-173 ,-201 , -232 ,-260 ,-287 ,-307 ,-330 ,-356 ,-376 ,-391 ,-411 ,-427 ,-445 ,-459 ,-460 ,-473 ,-489 , -495 ,-507 ,-517 ,-521 ,-531 ,-536 ,-535 ,-538 ,-544 ,-544 ,-544 ,-550 ,-554 ,-553 ,-557 , -565 ,-567 ,-569 ,-571 ,-571 ,-571 ,-574 ,-573 ,-578 ,-584 ,-591 ,-592 ,-594 ,-602 ,-601 , -606 ,-609 ,-609 ,-606 ,-608 ,-609 ,-598 ,-592 ,-593 ,-590 ,-579 ,-574 ,-568 ,-563 ,-554 , -545 ,-537 ,-535 ,-529 ,-516 ,-517 ,-507 ,-498 ,-497 ,-494 ,-494 ,-495 ,-491 ,-481 ,-477 , -472 ,-466 ,-463 ,-457 ,-445 ,-436 ,-426 ,-413 ,-398 ,-384 ,-374 ,-353 ,-339 ,-323 ,-305 , -295 ,-278 ,-260 ,-243 ,-222 ,-202 ,-184 ,-159 ,-144 ,-124 ,-95 ,-75 ,-57 ,-32 ,-7 , -3 ,15 ,44 ,64 ,75 ,91 ,109 ,115 ,132 ,141 ,150 ,165 ,181 ,191 ,202 , 223 ,232 ,251 ,267 ,278 ,298 ,304 ,317 ,334 ,345 ,363 ,376 ,383 ,399 ,414 , 426 ,438 ,450 ,458 ,469 ,483 ,491 ,508 ,525 ,532 ,540 ,558 ,572 ,574 ,592 , 601 ,611 ,622 ,630 ,645 ,646 ,651 ,657 ,664 ,667 ,674 ,675 ,673 ,676 ,675 , 680 ,674 ,676 ,678 ,676 ,672 ,669 ,667 ,662 ,663 ,651 ,649 ,650 ,643 ,646 , 640 ,644 ,637 ,625 ,625 ,621 ,617 ,608 ,606 ,604 ,593 ,580 ,568 ,552 ,539 , 525 ,507 ,497 ,479 ,455 ,436 ,409 ,383 ,366 ,340 ,314 ,295 ,275 ,257 ,232 , 217 ,202 ,180 ,170 ,152 ,145 ,137 ,120 ,109 ,83 ,71 ,69 ,64 ,57 ,46 , 41 ,34 ,26 ,13 ,4 ,-5 ,-10 ,-27 ,-40 ,-52 ,-71 ,-79 ,-104 ,-117 ,-137 , -151 ,-165 ,-190 ,-199 ,-220 ,-232 ,-247 ,-267 ,-276 ,-293 ,-305 ,-312 ,-328 ,-337 ,-345 , -360 ,-374 ,-380 ,-389 ,-410 ,-420 ,-432 ,-452 ,-463 ,-479 ,-490 ,-499 ,-514 ,-525 ,-535 , -538 ,-544 ,-555 ,-554 ,-555 ,-564 ,-565 ,-560 ,-564 ,-566 ,-561 ,-562 ,-556 ,-553 ,-552 , -547 ,-544 ,-537 ,-536 ,-536 ,-535 ,-534 ,-524 ,-517 ,-515 ,-518 ,-515 ,-507 ,-496 ,-495 , -494 ,-481 ,-474 ,-464 ,-460 ,-451 ,-443 ,-433 ,-420 ,-414 ,-391 ,-386 ,-374 ,-354 ,-343 , -326 ,-310 ,-295 ,-285 ,-268 ,-250 ,-240 ,-224 ,-214 ,-201 ,-187 ,-175 ,-159 ,-153 ,-146 , -136 ,-125 ,-116 ,-104 ,-90 ,-78 ,-73 ,-66 ,-49 ,-38 ,-29 ,-15 ,-3 ,-4 ,10 , 32 ,43 ,58 ,72 ,87 ,102 ,114 ,130 ,143 ,153 ,167 ,181 ,190 ,199 ,217 , 224 ,231 ,242 ,254 ,266 ,269 ,283 ,293 ,299 ,309 ,317 ,327 ,337 ,352 ,368 , 376 ,388 ,405 ,415 ,432 ,451 ,458 ,476 ,491 ,500 ,520 ,531 ,537 ,545 ,558 , 570 ,571 ,576 ,585 ,591 ,593 ,598 ,603 ,600 ,601 ,598 ,596 ,592 ,589 ,586 , 574 ,571 ,572 ,559 ,546 ,537 ,530 ,524 ,506 ,492 ,482 ,471 ,463 ,455 ,445 , 435 ,424 ,411 ,400 ,391 ,381 ,375 ,370 ,360 ,351 ,340 ,338 ,330 ,320 ,321 , 316 ,311 ,304 ,301 ,301 ,300 ,301 ,297 ,289 ,284 ,272 ,265 ,260 ,243 ,238 , 230 ,221 ,209 ,193 ,182 ,164 ,151 ,137 ,123 ,106 ,93 ,78 ,71 ,60 ,39 , 30 ,16 ,1 ,-2 ,-11 ,-26 ,-38 ,-51 ,-69 ,-81 ,-96 ,-115 ,-133 ,-149 ,-156 , -178 ,-192 ,-200 ,-220 ,-230 ,-240 ,-253 ,-267 ,-269 ,-279 ,-291 ,-296 ,-305 ,-310 ,-317 , -323 ,-328 ,-337 ,-342 ,-343 ,-344 ,-351 ,-361 ,-364 ,-365 ,-366 ,-374 ,-381 ,-380 ,-380 , -381 ,-383 ,-385 ,-391 ,-390 ,-396 ,-400 ,-400 ,-407 ,-413 ,-420 ,-423 ,-437 ,-441 ,-448 , -459 ,-462 ,-469 ,-473 ,-477 ,-477 ,-480 ,-476 ,-475 ,-477 ,-469 ,-463 ,-461 ,-458 ,-451 , -441 ,-435 ,-424 ,-418 ,-405 ,-388 ,-381 ,-369 ,-358 ,-343 ,-334 ,-317 ,-306 ,-301 ,-291 , -283 ,-269 ,-265 ,-248 ,-236 ,-227 ,-214 ,-203 ,-189 ,-178 ,-159 ,-153 ,-139 ,-126 ,-112 , -96 ,-85 ,-74 ,-63 ,-44 ,-38 ,-28 ,-19 ,-8 ,-1 ,-1 ,-4 ,6 ,34 ,34 , 51 ,67 ,78 ,92 ,103 ,114 ,122 ,143 ,146 ,153 ,160 ,170 ,183 ,190 ,204 , 210 ,221 ,229 ,234 ,249 ,263 ,268 ,284 ,298 ,306 ,325 ,338 ,358 ,374 ,387 , 405 ,423 ,443 ,452 ,461 ,476 ,492 ,496 ,509 ,523 ,521 ,529 ,531 ,531 ,531 , 529 ,529 ,530 ,531 ,531 ,532 ,531 ,532 ,531 ,532 ,531 ,532 ,531 ,530 ,529 , 521 ,517 ,508 ,500 ,491 ,493 ,487 ,473 ,470 ,458 ,451 ,442 ,430 ,419 ,408 , 397 ,385 ,376 ,373 ,366 ,356 ,348 ,339 ,338 ,334 ,323 ,319 ,316 ,310 ,301 , 300 ,301 ,294 ,290 ,290 ,282 ,274 ,268 ,264 ,252 ,241 ,238 ,224 ,220 ,205 , 189 ,182 ,166 ,152 ,145 ,141 ,123 ,111 ,104 ,85 ,72 ,65 ,49 ,32 ,22 , 6 ,-5 ,-15 ,-36 ,-51 ,-71 ,-95 ,-115 ,-136 ,-156 ,-178 ,-197 ,-220 ,-238 ,-258 , -284 ,-298 ,-307 ,-330 ,-343 ,-348 ,-363 ,-370 ,-379 ,-381 ,-383 ,-388 ,-390 ,-395 ,-397 , -399 ,-398 ,-400 ,-400 ,-400 ,-400 ,-399 ,-396 ,-400 ,-398 ,-396 ,-400 ,-403 ,-412 ,-415 , -419 ,-419 ,-422 ,-421 ,-422 ,-432 ,-434 ,-437 ,-427 ,-428 ,-431 ,-424 ,-421 ,-421 ,-420 , -418 ,-416 ,-412 ,-410 ,-403 ,-398 ,-394 ,-386 ,-379 ,-373 ,-361 ,-345 ,-338 ,-323 ,-311 , -302 ,-292 ,-281 ,-270 ,-264 ,-249 ,-235 ,-229 ,-218 ,-203 ,-193 ,-184 ,-166 ,-154 ,-144 , -131 ,-122 ,-113 ,-100 ,-85 ,-76 ,-73 ,-63 ,-57 ,-45 ,-35 ,-29 ,-17 ,-8 ,-1 , -2 ,-3 ,12 ,30 ,37 ,49 ,66 ,73 ,85 ,107 ,116 ,131 ,145 ,149 ,162 , 172 ,179 ,187 ,189 ,196 ,204 ,204 ,210 ,214 ,222 ,224 ,227 ,229 ,231 ,241 , 242 ,243 ,251 ,259 ,261 ,262 ,262 ,264 ,264 ,265 ,264 ,267 ,269 ,275 ,285 , 291 ,299 ,300 ,303 ,312 ,325 ,334 ,341 ,349 ,366 ,376 ,381 ,395 ,398 ,413 , 420 ,421 ,438 ,439 ,444 ,452 ,453 ,456 ,455 ,456 ,455 ,455 ,456 ,455 ,454 , 454 ,451 ,451 ,452 ,446 ,439 ,436 ,430 ,417 ,418 ,412 ,398 ,394 ,380 ,373 , 361 ,342 ,331 ,318 ,307 ,292 ,282 ,267 ,252 ,244 ,230 ,224 ,215 ,205 ,195 , 187 ,182 ,167 ,155 ,150 ,148 ,142 ,134 ,121 ,114 ,107 ,94 ,89 ,75 ,69 , 63 ,47 ,37 ,28 ,19 ,14 ,1 ,-3 ,-6 ,-20 ,-32 ,-39 ,-51 ,-68 ,-77 , -84 ,-99 ,-112 ,-119 ,-130 ,-136 ,-144 ,-152 ,-151 ,-155 ,-168 ,-177 ,-181 ,-184 ,-187 , -192 ,-190 ,-195 ,-199 ,-205 ,-211 ,-212 ,-216 ,-219 ,-227 ,-229 ,-231 ,-232 ,-235 ,-238 , -243 ,-249 ,-247 ,-254 ,-263 ,-263 ,-267 ,-269 ,-272 ,-277 ,-287 ,-287 ,-289 ,-299 ,-302 , -306 ,-303 ,-313 ,-320 ,-324 ,-336 ,-340 ,-345 ,-342 ,-344 ,-346 ,-354 ,-361 ,-361 ,-363 , -364 ,-363 ,-361 ,-363 ,-357 ,-353 ,-347 ,-343 ,-340 ,-329 ,-323 ,-316 ,-305 ,-305 ,-297 , -287 ,-286 ,-272 ,-267 ,-264 ,-249 ,-237 ,-234 ,-228 ,-219 ,-208 ,-194 ,-188 ,-168 ,-157 , -151 ,-142 ,-130 ,-113 ,-101 ,-82 ,-73 ,-61 ,-45 ,-30 ,-19 ,-6 ,0 ,-3 ,22 , 33 ,44 ,63 ,71 ,81 ,95 ,110 ,122 ,136 ,145 ,155 ,165 ,177 ,189 ,200 , 216 ,223 ,230 ,244 ,261 ,265 ,275 ,294 ,298 ,302 ,317 ,320 ,329 ,337 ,337 , 344 ,346 ,355 ,363 ,366 ,369 ,372 ,376 ,378 ,377 ,378 ,377 ,378 ,376 ,376 , 376 ,367 ,372 ,368 ,368 ,367 ,362 ,365 ,358 ,358 ,354 ,346 ,341 ,337 ,340 , 334 ,324 ,321 ,319 ,317 ,309 ,301 ,300 ,301 ,297 ,284 ,286 ,280 ,265 ,265 , 264 ,253 ,243 ,241 ,239 ,234 ,229 ,228 ,225 ,225 ,223 ,222 ,218 ,218 ,218 , 210 ,217 ,213 ,207 ,210 ,211 ,214 ,216 ,214 ,209 ,213 ,213 ,210 ,211 ,211 , 207 ,206 ,204 ,200 ,191 ,186 ,186 ,173 ,166 ,153 ,147 ,139 ,119 ,109 ,96 , 81 ,71 ,63 ,42 ,30 ,21 ,1 ,-3 ,-16 ,-26 ,-35 ,-52 ,-59 ,-71 ,-77 , -83 ,-94 ,-102 ,-113 ,-116 ,-129 ,-134 ,-139 ,-152 ,-150 ,-161 ,-171 ,-182 ,-192 ,-196 , -211 ,-221 ,-229 ,-234 ,-243 ,-256 ,-268 ,-271 ,-279 ,-287 ,-290 ,-302 ,-303 ,-305 ,-305 , -308 ,-316 ,-319 ,-317 ,-321 ,-318 ,-315 ,-317 ,-308 ,-305 ,-304 ,-305 ,-302 ,-299 ,-290 , -286 ,-289 ,-284 ,-287 ,-281 ,-275 ,-275 ,-270 ,-270 ,-269 ,-268 ,-266 ,-262 ,-257 ,-251 , -243 ,-242 ,-235 ,-228 ,-232 ,-226 ,-222 ,-215 ,-213 ,-207 ,-199 ,-191 ,-190 ,-186 ,-173 , -172 ,-166 ,-160 ,-156 ,-153 ,-150 ,-148 ,-146 ,-135 ,-134 ,-134 ,-124 ,-116 ,-115 ,-111 , -100 ,-87 ,-80 ,-75 ,-66 ,-59 ,-45 ,-37 ,-29 ,-14 ,-1 ,-4 ,3 ,27 ,34 , 46 ,66 ,68 ,84 ,104 ,113 ,131 ,146 ,157 ,176 ,190 ,204 ,220 ,230 ,240 , 244 ,253 ,262 ,266 ,270 ,268 ,275 ,283 ,283 ,286 ,293 ,294 ,296 ,299 ,299 , 301 ,299 ,301 ,300 ,300 ,301 ,300 ,301 ,300 ,301 ,300 ,300 ,300 ,293 ,294 , 290 ,283 ,282 ,272 ,271 ,265 ,263 ,265 ,261 ,260 ,248 ,243 ,245 ,243 ,243 , 245 ,246 ,250 ,262 ,260 ,260 ,266 ,264 ,265 ,264 ,267 ,267 ,266 ,269 ,265 , 267 ,266 ,265 ,267 ,265 ,265 ,266 ,266 ,267 ,266 ,265 ,264 ,265 ,263 ,257 , 258 ,246 ,241 ,241 ,234 ,230 ,226 ,225 ,220 ,216 ,206 ,198 ,188 ,188 ,180 , 166 ,159 ,148 ,146 ,134 ,121 ,107 ,94 ,79 ,68 ,60 ,40 ,34 ,21 ,6 , -2 ,-7 ,-14 ,-29 ,-37 ,-45 ,-60 ,-72 ,-75 ,-83 ,-91 ,-101 ,-111 ,-117 ,-122 , -130 ,-138 ,-144 ,-150 ,-152 ,-151 ,-152 ,-155 ,-161 ,-166 ,-166 ,-173 ,-173 ,-176 ,-183 , -185 ,-191 ,-188 ,-192 ,-195 ,-196 ,-205 ,-208 ,-213 ,-212 ,-216 ,-224 ,-226 ,-232 ,-230 , -230 ,-234 ,-238 ,-238 ,-235 ,-241 ,-241 ,-237 ,-238 ,-239 ,-237 ,-236 ,-238 ,-236 ,-234 , -234 ,-231 ,-230 ,-232 ,-230 ,-230 ,-232 ,-231 ,-234 ,-234 ,-236 ,-236 ,-237 ,-242 ,-237 , -243 ,-239 ,-235 ,-237 ,-232 ,-232 ,-230 ,-231 ,-227 ,-218 ,-211 ,-205 ,-194 ,-188 ,-179 , -159 ,-154 ,-146 ,-136 ,-126 ,-116 ,-110 ,-96 ,-85 ,-77 ,-72 ,-65 ,-57 ,-42 ,-37 , -31 ,-16 ,-9 ,-3 ,-3 ,-1 ,-4 ,2 ,17 ,26 ,34 ,35 ,40 ,52 ,56 , 62 ,69 ,69 ,78 ,87 ,93 ,100 ,107 ,111 ,114 ,123 ,131 ,135 ,145 ,148 , 151 ,164 ,165 ,179 ,188 ,186 ,191 ,200 ,206 ,206 ,217 ,222 ,223 ,227 ,226 , 234 ,238 ,243 ,253 ,261 ,266 ,268 ,279 ,285 ,292 ,301 ,301 ,304 ,317 ,322 , 320 ,332 ,338 ,338 ,338 ,339 ,340 ,341 ,341 ,337 ,339 ,338 ,332 ,325 ,322 , 319 ,320 ,320 ,312 ,310 ,309 ,307 ,307 ,303 ,300 ,302 ,301 ,300 ,301 ,300 , 301 ,300 ,301 ,298 ,296 ,290 ,282 ,271 ,266 ,264 ,248 ,238 ,228 ,219 ,207 , 192 ,185 ,170 ,163 ,154 ,143 ,140 ,125 ,112 ,106 ,90 ,76 ,71 ,60 ,44 , 35 ,25 ,13 ,1 ,-3 ,-7 ,-14 ,-26 ,-34 ,-36 ,-38 ,-37 ,-41 ,-40 ,-42 , -54 ,-51 ,-51 ,-56 ,-56 ,-58 ,-59 ,-59 ,-65 ,-70 ,-74 ,-75 ,-77 ,-83 ,-93 , -99 ,-111 ,-114 ,-119 ,-133 ,-137 ,-150 ,-151 ,-155 ,-170 ,-174 ,-185 ,-190 ,-189 ,-194 , -198 ,-206 ,-212 ,-211 ,-211 ,-212 ,-216 ,-220 ,-224 ,-227 ,-229 ,-231 ,-231 ,-230 ,-231 , -229 ,-230 ,-229 ,-225 ,-223 ,-216 ,-211 ,-212 ,-207 ,-196 ,-193 ,-189 ,-190 ,-188 ,-183 , -180 ,-170 ,-172 ,-172 ,-171 ,-168 ,-162 ,-163 ,-159 ,-158 ,-153 ,-152 ,-152 ,-152 ,-153 , -152 ,-152 ,-151 ,-152 ,-152 ,-151 ,-152 ,-151 ,-152 ,-151 ,-150 ,-148 ,-142 ,-134 ,-135 , -128 ,-117 ,-119 ,-110 ,-100 ,-90 ,-81 ,-75 ,-65 ,-57 ,-44 ,-34 ,-29 ,-20 ,-8 , -2 ,-2 ,-3 ,8 ,27 ,33 ,39 ,54 ,64 ,68 ,72 ,79 ,87 ,95 ,108 , 111 ,120 ,132 ,141 ,146 ,154 ,164 ,169 ,186 ,186 ,190 ,205 ,211 ,217 ,222 , 225 ,225 ,226 ,227 ,233 ,234 ,232 ,239 ,243 ,244 ,243 ,244 ,243 ,244 ,242 , 238 ,235 ,232 ,230 ,226 ,226 ,224 ,222 ,221 ,218 ,218 ,216 ,218 ,218 ,219 , 224 ,224 ,225 ,225 ,227 ,229 ,232 ,232 ,235 ,235 ,235 ,235 ,237 ,238 ,235 , 235 ,234 ,241 ,236 ,235 ,242 ,233 ,238 ,238 ,232 ,239 ,237 ,232 ,233 ,229 , 228 ,227 ,226 ,226 ,223 ,222 ,219 ,213 ,208 ,202 ,193 ,189 ,187 ,182 ,176 , 165 ,163 ,157 ,147 ,149 ,136 ,121 ,112 ,100 ,87 ,75 ,68 ,62 ,44 ,33 , 29 ,14 ,7 ,-1 ,-4 ,-2 ,-4 ,-8 ,-16 ,-24 ,-36 ,-38 ,-41 ,-54 ,-59 , -66 ,-75 ,-75 ,-79 ,-88 ,-92 ,-104 ,-112 ,-114 ,-118 ,-118 ,-125 ,-128 ,-128 ,-135 , -135 ,-142 ,-147 ,-149 ,-152 ,-151 ,-152 ,-151 ,-152 ,-151 ,-151 ,-153 ,-155 ,-159 ,-158 , -156 ,-158 ,-164 ,-165 ,-161 ,-162 ,-163 ,-162 ,-165 ,-159 ,-158 ,-159 ,-152 ,-151 ,-152 , -151 ,-151 ,-147 ,-140 ,-135 ,-134 ,-133 ,-125 ,-117 ,-116 ,-115 ,-115 ,-116 ,-115 ,-117 , -117 ,-116 ,-119 ,-118 ,-121 ,-120 ,-119 ,-119 ,-114 ,-117 ,-116 ,-115 ,-116 ,-114 ,-115 , -112 ,-107 ,-106 ,-102 ,-100 ,-98 ,-96 ,-97 ,-93 ,-86 ,-87 ,-83 ,-75 ,-76 ,-74 , -74 ,-72 ,-65 ,-60 ,-59 ,-56 ,-46 ,-47 ,-42 ,-37 ,-37 ,-38 ,-35 ,-23 ,-19 , -11 ,-6 ,-3 ,-1 ,-2 ,-1 ,-2 ,-1 ,-1 ,-2 ,1 ,13 ,15 ,16 ,27 , 32 ,32 ,33 ,35 ,41 ,51 ,60 ,64 ,70 ,72 ,73 ,88 ,90 ,100 ,111 , 110 ,118 ,131 ,139 ,147 ,147 ,155 ,165 ,171 ,183 ,188 ,196 ,202 ,218 ,224 , 220 ,228 ,229 ,240 ,242 ,240 ,252 ,258 ,265 ,265 ,264 ,266 ,268 ,269 ,276 , 279 ,276 ,281 ,278 ,280 ,286 ,284 ,285 ,284 ,285 ,285 ,283 ,281 ,273 ,271 , 268 ,265 ,265 ,264 ,265 ,263 ,264 ,252 ,242 ,244 ,239 ,232 ,228 ,227 ,223 , 222 ,220 ,213 ,200 ,192 ,189 ,186 ,180 ,168 ,164 ,159 ,148 ,146 ,149 ,139 , 131 ,129 ,116 ,113 ,113 ,112 ,109 ,100 ,94 ,93 ,85 ,81 ,75 ,71 ,71 , 67 ,66 ,57 ,50 ,36 ,35 ,31 ,19 ,11 ,-1 ,-2 ,-5 ,-10 ,-29 ,-36 , -40 ,-56 ,-63 ,-73 ,-75 ,-82 ,-92 ,-104 ,-114 ,-114 ,-122 ,-129 ,-137 ,-139 ,-146 , -153 ,-150 ,-153 ,-159 ,-163 ,-161 ,-165 ,-166 ,-170 ,-169 ,-168 ,-172 ,-165 ,-165 ,-164 , -165 ,-169 ,-165 ,-162 ,-161 ,-165 ,-161 ,-157 ,-157 ,-153 ,-152 ,-151 ,-152 ,-151 ,-152 , -151 ,-152 ,-151 ,-152 ,-151 ,-152 ,-151 ,-152 ,-149 ,-151 ,-147 ,-139 ,-142 ,-135 ,-135 , -127 ,-120 ,-117 ,-115 ,-116 ,-107 ,-105 ,-98 ,-94 ,-93 ,-90 ,-85 ,-81 ,-85 ,-81 , -76 ,-75 ,-76 ,-75 ,-74 ,-71 ,-70 ,-65 ,-57 ,-59 ,-59 ,-57 ,-54 ,-52 ,-46 , -39 ,-42 ,-40 ,-37 ,-38 ,-37 ,-38 ,-35 ,-29 ,-25 ,-21 ,-20 ,-15 ,-9 ,-10 , -5 ,-2 ,-2 ,-2 ,-1 ,-4 ,1 ,16 ,25 ,34 ,37 ,45 ,52 ,61 ,69 , 71 ,80 ,86 ,91 ,101 ,111 ,112 ,113 ,119 ,126 ,131 ,136 ,142 ,145 ,148 , 148 ,151 ,163 ,168 ,174 ,186 ,186 ,187 ,194 ,196 ,203 ,207 ,208 ,214 ,214 , 214 ,216 ,216 ,218 ,219 ,218 ,219 ,224 ,224 ,224 ,226 ,224 ,229 ,228 ,234 , 233 ,234 ,242 ,240 ,244 ,243 ,244 ,242 ,248 ,246 ,247 ,248 ,241 ,244 ,242 , 243 ,232 ,228 ,227 ,223 ,220 ,213 ,207 ,199 ,190 ,187 ,185 ,170 ,167 ,159 , 146 ,149 ,140 ,133 ,128 ,116 ,111 ,110 ,106 ,97 ,90 ,89 ,83 ,71 ,71 , 71 ,68 ,65 ,57 ,49 ,46 ,43 ,40 ,36 ,33 ,34 ,31 ,29 ,23 ,14 , 16 ,11 ,8 ,3 ,-3 ,-1 ,-2 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,-41 , 181 ,6726 ,10005 ,-787 ,-8824 ,-17442 ,-13549 ,1969 ,-6368 ,111 ,7120 ,-1594 ,1928 ,9334 ,20985 , 19844 ,12605 ,8925 ,4794 ,5418 ,4253 ,-4112 ,-10882 ,-11035 ,-7806 ,-8054 ,-8897 ,-5884 ,-6085 ,-4840 , -4894 ,-7100 ,-5779 ,711 ,6886 ,8156 ,9626 ,7950 ,3200 ,1391 ,2444 ,4598 ,-365 ,-4695 ,-540 , 3 ,-400 ,1462 ,-1955 ,-7419 ,-5898 ,-2808 ,577 ,3912 ,1955 ,-287 ,-1813 ,-2625 ,-2105 ,-1530 , -576 ,2172 ,2376 ,-1310 ,735 ,3809 ,2253 ,-1376 ,-2559 ,-774 ,-1561 ,-839 ,1562 ,1080 ,-2841 , -4394 ,-4817 ,-4753 ,-954 ,2464 ,4339 ,3417 ,2529 ,3865 ,3711 ,2083 ,1528 ,500 ,-2 ,960 , 739 ,-1214 ,-3898 ,-4665 ,-4310 ,-3698 ,-3076 ,-2975 ,209 ,2008 ,551 ,806 ,1612 ,2641 ,2529 , 442 ,-1121 ,-1170 ,-879 ,-401 ,557 ,1212 ,1324 ,1312 ,880 ,428 ,-374 ,-636 ,-128 ,-192 , -288 ,-698 ,-686 ,-1000 ,-519 ,-344 ,-1008 ,-853 ,-696 ,500 ,335 ,329 ,812 ,318 ,939 , 779 ,338 ,294 ,-99 ,46 ,306 ,204 ,349 ,60 ,-655 ,-294 ,-194 ,-588 ,-254 ,94 , 332 ,-72 ,-487 ,-287 ,89 ,37 ,-264 ,246 ,475 ,591 ,227 ,54 ,358 ,148 ,-78 , -344 ,32 ,103 ,-252 ,-479 ,-775 ,-705 ,-265 ,96 ,507 ,387 ,308 ,1030 ,713 ,435 , 283 ,-168 ,63 ,59 ,168 ,313 ,213 ,13 ,-225 ,-302 ,-264 ,-94 ,-430 ,-251 ,-79 , 152 ,69 ,-197 ,-217 ,-73 ,-20 ,-383 ,333 ,406 ,968 ,29 ,833 ,4 ,752 ,177 , 422 ,515 ,-825 ,20076 ,15152 ,-11721 ,-23383 ,-21524 ,-6347 ,-4237 ,-7986 ,3069 ,18105 ,7720 ,-2418 , 3620 ,5450 ,9324 ,12030 ,8497 ,6680 ,4201 ,-2378 ,-518 ,-3815 ,-11189 ,-5855 ,-11019 ,-12868 ,-7506 , -7197 ,-790 ,1749 ,11503 ,17260 ,14524 ,10793 ,4773 ,4920 ,670 ,3976 ,7624 ,-515 ,-7652 ,-14272 , -14454 ,-10811 ,-9009 ,-6486 ,-4098 ,-997 ,2145 ,6318 ,6994 ,7535 ,6146 ,974 ,-1520 ,-7137 ,-5909 , -2740 ,-5167 ,-1264 ,1738 ,-137 ,5383 ,12083 ,5300 ,-2271 ,-4144 ,-1517 ,1122 ,424 ,3910 ,5671 , 1833 ,-2611 ,-2337 ,-5178 ,-7932 ,-3874 ,-3142 ,-2142 ,969 ,908 ,3094 ,4844 ,-833 ,-2523 ,2064 , 4799 ,5702 ,5532 ,1447 ,-1838 ,-1583 ,-3762 ,-5918 ,-5145 ,-2161 ,-146 ,272 ,645 ,2116 ,2912 , 381 ,-2168 ,-461 ,2804 ,4381 ,3897 ,1087 ,-1143 ,-2605 ,-2362 ,-2883 ,-3522 ,-1601 ,-956 ,1654 , 4073 ,1257 ,-973 ,-667 ,-43 ,-150 ,38 ,-346 ,-1326 ,-2980 ,-2584 ,951 ,1725 ,2746 ,3882 , 1933 ,-2345 ,-2927 ,-491 ,10 ,95 ,806 ,1166 ,1201 ,2985 ,3291 ,1674 ,-349 ,-1160 ,-2532 , -3691 ,-3982 ,-3494 ,-1025 ,-108 ,318 ,2234 ,4451 ,3105 ,1735 ,1808 ,53 ,-876 ,-433 ,-294 , -1579 ,-2138 ,-1617 ,-1140 ,-852 ,-1528 ,-921 ,-327 ,52 ,1579 ,2930 ,2494 ,1382 ,1756 ,317 , -529 ,-140 ,-103 ,-476 ,-1367 ,-215 ,888 ,585 ,5 ,-377 ,-801 ,-921 ,-877 ,-830 ,-1873 , -1655 ,-453 ,-589 ,672 ,2132 ,2354 ,2081 ,2404 ,1457 ,349 ,372 ,-295 ,-1012 ,-1917 ,-1703 , -948 ,-531 ,184 ,24 ,-275 ,138 ,437 ,891 ,1237 ,737 ,526 ,406 ,-336 ,-665 ,-488 , -211 ,-324 ,-73 ,111 ,-257 ,-67 ,-138 ,-225 ,305 ,739 ,605 ,111 ,33 ,295 ,8 , -42 ,32 ,-370 ,-803 ,-791 ,-30 ,313 ,425 ,669 ,764 ,438 ,-56 ,-132 ,196 ,141 , 156 ,82 ,147 ,317 ,200 ,121 ,-599 ,-548 ,-749 ,305 ,-242 ,0 ,-481 ,176 ,507 , 145 ,12864 ,19444 ,12162 ,-3805 ,-8419 ,-6482 ,-15132 ,-7514 ,4398 ,5780 ,10095 ,6591 ,-4731 ,-3284 , -3468 ,-3198 ,780 ,-13626 ,-25141 ,-12662 ,1716 ,3718 ,3506 ,1605 ,5763 ,7355 ,3328 ,11149 ,8385 , 5624 ,8720 ,6505 ,5059 ,-3477 ,1814 ,9792 ,2884 ,-3334 ,-7420 ,-9156 ,-12417 ,-11419 ,-8378 ,-14274 , -9648 ,1489 ,6824 ,7598 ,3713 ,5643 ,5774 ,4562 ,764 ,-3321 ,344 ,2735 ,3313 ,1313 ,-2006 , -3392 ,-1549 ,-1143 ,-2651 ,377 ,167 ,-2490 ,2868 ,5546 ,2072 ,1848 ,720 ,1190 ,-3396 ,-9107 , -6690 ,-4647 ,-2091 ,-311 ,1646 ,-610 ,1017 ,7284 ,5539 ,4184 ,2866 ,742 ,446 ,424 ,-2037 , -3850 ,85 ,1418 ,-97 ,287 ,-991 ,-2996 ,-1782 ,-2596 ,-2595 ,2094 ,3346 ,3324 ,2385 ,188 , 175 ,65 ,-1365 ,-376 ,553 ,-504 ,-830 ,-2114 ,-3965 ,-5057 ,-2828 ,-1596 ,-390 ,1494 ,438 , 1901 ,4899 ,4654 ,2819 ,2975 ,1859 ,996 ,2090 ,689 ,-2205 ,-1510 ,286 ,-2932 ,-4342 ,-3163 , -2149 ,-314 ,-961 ,-970 ,1033 ,2100 ,2137 ,2298 ,1182 ,371 ,1535 ,1791 ,1386 ,-621 ,-2320 , -1835 ,-983 ,-1013 ,-898 ,-203 ,-1279 ,-1582 ,49 ,1616 ,1011 ,391 ,1270 ,1891 ,2385 ,544 , -593 ,176 ,370 ,-364 ,-1116 ,-1382 ,-2503 ,-1725 ,-614 ,-594 ,-316 ,451 ,1498 ,1069 ,241 , -129 ,717 ,1151 ,404 ,61 ,-379 ,-215 ,551 ,720 ,105 ,-850 ,-1384 ,-593 ,136 ,379 , 824 ,843 ,851 ,304 ,382 ,1145 ,337 ,-263 ,-926 ,-1315 ,-999 ,-644 ,-1062 ,-1000 ,347 , 133 ,973 ,621 ,1759 ,426 ,6517 ,21667 ,23651 ,12513 ,-6461 ,-24406 ,-32768 ,-21813 ,-9393 ,-410 , 11924 ,9325 ,22245 ,20850 ,7041 ,-57 ,-6382 ,-9327 ,-17459 ,-3365 ,8913 ,3838 ,156 ,-3316 ,-5924 , -6233 ,691 ,-4750 ,-7421 ,3651 ,12285 ,10403 ,2634 ,7703 ,1410 ,4104 ,7026 ,-11845 ,-12028 ,-13784 , -13279 ,-7294 ,-862 ,2808 ,10570 ,26894 ,15585 ,9017 ,5708 ,555 ,-7547 ,-27198 ,-31576 ,-24605 ,-7774 , 4790 ,16560 ,22407 ,8155 ,998 ,8543 ,10041 ,11392 ,14744 ,10637 ,2854 ,-6522 ,-9912 ,-12099 ,-12547 , -11944 ,-9894 ,-9011 ,-10157 ,-5349 ,8302 ,13512 ,1696 ,2567 ,3857 ,-2038 ,-3644 ,3713 ,5967 ,-4187 , 928 ,8301 ,-443 ,-8798 ,-4454 ,6130 ,10216 ,3636 ,3376 ,10554 ,7164 ,-9605 ,-21292 ,-20659 ,-16135 , -12355 ,-507 ,10709 ,3996 ,2125 ,4309 ,9545 ,16369 ,12935 ,12391 ,6760 ,974 ,350 ,-5238 ,-4681 , -4225 ,-3406 ,-3599 ,-13556 ,-12066 ,-3145 ,-1941 ,2015 ,13009 ,18058 ,6737 ,-6728 ,-12289 ,-14650 ,-10317 , -1299 ,-2005 ,2556 ,10173 ,9832 ,9528 ,9196 ,12896 ,4090 ,1805 ,-3975 ,-13866 ,-14078 ,-15894 ,-7047 , -2393 ,4231 ,6313 ,4492 ,-140 ,-7508 ,824 ,4908 ,-671 ,-3481 ,-3201 ,-765 ,1980 ,7872 ,10449 , 9240 ,4468 ,2058 ,8089 ,117 ,-1582 ,494 ,-6460 ,-7903 ,-13148 ,-15012 ,-10378 ,-4208 ,-1795 ,628 , 1823 ,5394 ,12127 ,10421 ,10540 ,7219 ,7253 ,6154 ,-1039 ,-858 ,-1315 ,-5783 ,-9017 ,-6483 ,-9959 , -5738 ,-6301 ,-10050 ,-507 ,555 ,2886 ,8628 ,13454 ,13035 ,12004 ,6829 ,-4470 ,-8442 ,-8509 ,-11068 , -3076 ,2633 ,-4944 ,1513 ,8145 ,2610 ,601 ,3546 ,1447 ,-24 ,-3126 ,-8987 ,-8671 ,-1510 ,1199 , -5072 ,-726 ,1663 ,-779 ,2685 ,7962 ,13273 ,5981 ,-3010 ,154 ,-3194 ,-5055 ,2375 ,2875 ,1444 , 2332 ,2791 ,-4732 ,-5181 ,525 ,-1854 ,606 ,-973 ,-3174 ,-2327 ,-5049 ,-3594 ,3099 ,6300 ,4230 , 8035 ,11260 ,5771 ,-2923 ,-7396 ,-10405 ,-14170 ,-8323 ,-800 ,2508 ,3507 ,4152 ,4458 ,3346 ,6967 , 7119 ,8 ,-3249 ,-2543 ,-4119 ,-2445 ,-274 ,-2867 ,-4414 ,-2221 ,-440 ,621 ,3335 ,2590 ,-1563 , -2595 ,-1884 ,-2830 ,1784 ,5752 ,877 ,4924 ,8993 ,1136 ,1965 ,4372 ,103 ,358 ,4546 ,-138 , -6271 ,-6579 ,-9123 ,-6119 ,-187 ,-2059 ,-1612 ,-5247 ,-13859 ,-4456 ,-76 ,2618 ,9629 ,12886 ,15380 , 10143 ,8073 ,5352 ,5015 ,6030 ,-834 ,-12767 ,-12658 ,-10215 ,-8971 ,-8104 ,-12957 ,-6411 ,-5887 ,-4980 , 4991 ,10619 ,11536 ,12020 ,10415 ,7230 ,9007 ,5287 ,66 ,232 ,-4765 ,-3165 ,-183 ,-9793 ,-6201 , -3584 ,-8098 ,-2499 ,-1088 ,-694 ,3831 ,1729 ,-5065 ,-3848 ,3660 ,7793 ,4646 ,6634 ,9102 ,3790 , 3727 ,3448 ,253 ,-4204 ,-9459 ,-11332 ,-9709 ,-7229 ,-7964 ,-8192 ,-2859 ,40 ,4901 ,16449 ,14413 , 8229 ,4569 ,1666 ,2601 ,-4442 ,-6966 ,-2697 ,-3 ,-1045 ,-2838 ,2228 ,5285 ,4168 ,2146 ,-4522 , -11223 ,-7707 ,-4921 ,-4450 ,0 ,1750 ,4847 ,5517 ,1913 ,56 ,4960 ,7581 ,362 ,1684 ,560 , -9126 ,-9945 ,-5346 ,678 ,5263 ,12258 ,8390 ,3038 ,4337 ,-2279 ,-4160 ,-5676 ,-5260 ,-3688 ,-393 , -2741 ,-4902 ,769 ,-257 ,2504 ,2691 ,5468 ,8357 ,5727 ,2167 ,-914 ,-1555 ,-4026 ,434 ,-2197 , -7935 ,-7547 ,-9193 ,-7594 ,-1987 ,4653 ,9275 ,11171 ,7957 ,2867 ,1111 ,-721 ,-5782 ,-6242 ,1458 , 4544 ,-558 ,-275 ,4169 ,4893 ,1412 ,-4601 ,-4090 ,-2719 ,-2106 ,-5341 ,-4793 ,2901 ,-1008 ,-1668 , 2378 ,2828 ,-83 ,-1842 ,2013 ,4802 ,1470 ,2 ,6109 ,3481 ,574 ,-2916 ,-6359 ,774 ,3507 , 2221 ,-181 ,-2178 ,104 ,1266 ,-163 ,-2393 ,-793 ,-300 ,-1084 ,1669 ,426 ,-682 ,-371 ,-2264 , -3208 ,-507 ,640 ,-2564 ,758 ,4214 ,917 ,881 ,200 ,-1541 ,1995 ,1178 ,-2008 ,-2697 ,-3859 , -3773 ,-3307 ,-2262 ,-1015 ,712 ,2397 ,2485 ,1772 ,4904 ,5914 ,3586 ,4522 ,2681 ,-75 ,-1365 , -2690 ,-436 ,4041 ,1229 ,-2223 ,-1669 ,-1545 ,-1871 ,-6502 ,-5587 ,-2062 ,-2513 ,-1975 ,-1194 ,1219 , 4768 ,6473 ,5648 ,4528 ,2756 ,98 ,752 ,794 ,-1325 ,2393 ,4654 ,1430 ,-2711 ,-5747 ,-5315 , -6509 ,-6979 ,-4347 ,-4007 ,-4298 ,-1017 ,2448 ,2811 ,3889 ,6198 ,7022 ,2419 ,-1392 ,503 ,2845 , 5252 ,4654 ,4794 ,2675 ,-2907 ,-4026 ,-5097 ,-5539 ,-5176 ,-7245 ,-6913 ,-2279 ,1082 ,3202 ,5376 , 2222 ,505 ,2592 ,2935 ,4561 ,2774 ,1964 ,3897 ,3933 ,1082 ,-2840 ,-2980 ,-3275 ,-4149 ,-3892 , -1083 ,-502 ,-1502 ,-2593 ,-2779 ,-1967 ,-1965 ,2478 ,4589 ,4883 ,5531 ,4075 ,843 ,-3285 ,-3013 , -1556 ,-514 ,-2407 ,-3046 ,380 ,-1307 ,-2350 ,-2244 ,-1867 ,-1802 ,-90 ,5344 ,4283 ,3536 ,2649 , -193 ,1875 ,1582 ,1897 ,3077 ,1896 ,3460 ,1270 ,394 ,-388 ,-4145 ,-4553 ,-5012 ,-3384 ,-3616 , -1456 ,661 ,-990 ,-668 ,-895 ,-9 ,-1854 ,-2877 ,-383 ,1226 ,1619 ,2217 ,5465 ,7058 ,5510 , 4067 ,3294 ,1817 ,-87 ,-1653 ,-2432 ,-2300 ,-2316 ,-3482 ,-3825 ,-5488 ,-7629 ,-6400 ,-2593 ,2518 , 4382 ,5891 ,5782 ,3534 ,2962 ,1767 ,165 ,-1040 ,-737 ,122 ,505 ,-2481 ,-6442 ,-6367 ,-3963 , -618 ,651 ,4041 ,6880 ,4199 ,1818 ,596 ,1942 ,1642 ,-453 ,1181 ,1679 ,-213 ,-1252 ,-2824 , -2446 ,-1870 ,-2524 ,-1925 ,-888 ,852 ,-556 ,352 ,3588 ,582 ,-2875 ,-1239 ,821 ,2065 ,3096 , 2310 ,705 ,-421 ,1313 ,1948 ,323 ,-1963 ,-3310 ,-3349 ,-1859 ,-981 ,-2731 ,-1611 ,-2819 ,-1509 , 866 ,1561 ,4599 ,4788 ,4464 ,1907 ,2608 ,2354 ,-326 ,879 ,865 ,-1010 ,-3486 ,-2950 ,-1447 , -403 ,-1459 ,-3176 ,-3800 ,-2181 ,2418 ,2086 ,917 ,1682 ,2855 ,2520 ,-1342 ,-1423 ,-64 ,-1104 , -2297 ,-1282 ,262 ,1476 ,3207 ,3669 ,3213 ,-514 ,-2753 ,-2283 ,-1378 ,-1637 ,-1798 ,-360 ,-1784 , -1042 ,997 ,734 ,1023 ,2640 ,2105 ,1838 ,3685 ,2032 ,-1113 ,-1313 ,-926 ,-1485 ,-818 ,-1 , -944 ,-1076 ,-1272 ,-3801 ,-3045 ,-2491 ,-1746 ,92 ,-888 ,708 ,2761 ,3905 ,4728 ,2911 ,1527 , 2880 ,3427 ,1794 ,140 ,-1080 ,-1970 ,-2853 ,-3175 ,-1983 ,-1935 ,-2630 ,-684 ,1312 ,898 ,-760 , -600 ,50 ,175 ,1423 ,2677 ,4410 ,3031 ,1119 ,842 ,-893 ,-2233 ,-1898 ,104 ,-1682 ,-3625 , -3892 ,-3064 ,493 ,994 ,956 ,2643 ,4368 ,3679 ,1122 ,-1232 ,-1632 ,-651 ,-1233 ,-2804 ,-2612 , -347 ,-92 ,1066 ,2095 ,1681 ,1470 ,715 ,79 ,-2536 ,-2904 ,-410 ,541 ,1224 ,1265 ,167 , 958 ,1074 ,909 ,3579 ,2365 ,310 ,550 ,-2271 ,-4019 ,-2218 ,-1943 ,-1471 ,-347 ,-771 ,-593 , -490 ,952 ,2440 ,3540 ,2227 ,-822 ,-529 ,-749 ,-968 ,290 ,1158 ,1980 ,1282 ,-1289 ,-1594 , -1185 ,-2185 ,-2497 ,-1524 ,445 ,1566 ,2016 ,2761 ,2973 ,1908 ,1965 ,670 ,-760 ,-867 ,-2824 , -3391 ,-3134 ,-1935 ,-561 ,143 ,137 ,-617 ,-478 ,752 ,2982 ,3299 ,1286 ,-426 ,-1097 ,-764 , 310 ,565 ,1794 ,1908 ,-17 ,-749 ,-1025 ,-1242 ,-1139 ,-848 ,-1668 ,-556 ,1548 ,624 ,1361 , 2584 ,1497 ,554 ,-569 ,299 ,1068 ,-1576 ,-3529 ,-2682 ,-2517 ,-1234 ,1554 ,1403 ,1334 ,1494 , 1276 ,1460 ,1268 ,1652 ,825 ,-1166 ,-972 ,235 ,-361 ,-557 ,33 ,-1214 ,-2143 ,-1498 ,-1395 , -1707 ,-272 ,1697 ,1933 ,2797 ,2542 ,1372 ,1190 ,-297 ,-634 ,-968 ,-1576 ,-528 ,-294 ,-482 , -818 ,-647 ,-326 ,-1216 ,-868 ,842 ,1145 ,1123 ,504 ,-102 ,781 ,125 ,-228 ,582 ,136 , -1036 ,-1292 ,-310 ,184 ,354 ,401 ,408 ,1026 ,609 ,-850 ,-1195 ,137 ,364 ,-113 ,134 , 53 ,2 ,-879 ,327 ,733 ,123 ,1705 ,1537 ,1561 ,57 ,-835 ,-425 ,-1292 ,-778 ,-952 , -862 ,-1266 ,-983 ,-261 ,-687 ,-158 ,710 ,1123 ,1510 ,2257 ,2374 ,2698 ,690 ,-310 ,-304 , -1514 ,-1421 ,-1169 ,-18 ,-947 ,-1582 ,-1468 ,-1498 ,-701 ,-64 ,1215 ,837 ,426 ,663 ,530 , 201 ,484 ,220 ,-324 ,856 ,1096 ,883 ,378 ,89 ,389 ,-356 ,-626 ,-491 ,-1249 ,-1333 , -641 ,-690 ,-342 ,989 ,1364 ,308 ,648 ,937 ,471 ,416 ,-123 ,-135 ,-171 ,-838 ,-1226 , -720 ,-34 ,712 ,1503 ,973 ,296 ,761 ,201 ,-749 ,-1083 ,-1022 ,-1056 ,-915 ,-1033 ,-1123 , -311 ,-328 ,811 ,1436 ,1503 ,861 ,674 ,537 ,164 ,1940 ,1386 ,1319 ,473 ,-825 ,-1316 , -1776 ,-395 ,-178 ,-167 ,-926 ,-1506 ,-939 ,-592 ,74 ,846 ,1261 ,547 ,-49 ,-286 ,-625 , 234 ,737 ,246 ,-273 ,-619 ,-680 ,-1 ,1058 ,959 ,1585 ,1354 ,153 ,138 ,-309 ,-541 , -433 ,56 ,808 ,152 ,-1084 ,-1350 ,-2002 ,-938 ,661 ,563 ,1033 ,480 ,107 ,-281 ,-656 , -150 ,-669 ,-722 ,387 ,712 ,164 ,538 ,1304 ,1043 ,1128 ,1551 ,905 ,752 ,-221 ,-1197 , -947 ,-1055 ,-1347 ,-1540 ,-1109 ,-731 ,604 ,676 ,-124 ,381 ,725 ,841 ,47 ,22 ,862 , 689 ,-70 ,-223 ,-310 ,-597 ,-899 ,-910 ,-58 ,794 ,972 ,258 ,-398 ,-609 ,275 ,761 , 131 ,634 ,591 ,356 ,779 ,443 ,142 ,-15 ,-595 ,-1622 ,-1737 ,-1010 ,-335 ,-467 ,-728 , -205 ,-36 ,903 ,887 ,641 ,1499 ,1341 ,818 ,613 ,1045 ,452 ,-308 ,-443 ,-811 ,-728 , -448 ,-438 ,-1214 ,-1156 ,-291 ,76 ,220 ,533 ,938 ,640 ,334 ,955 ,895 ,369 ,559 , -58 ,-214 ,-225 ,-167 ,66 ,-474 ,-481 ,-1350 ,-1337 ,-529 ,-454 ,-86 ,116 ,290 ,123 , -259 ,-475 ,225 ,620 ,644 ,1082 ,1361 ,1393 ,1029 ,790 ,-74 ,-775 ,-560 ,-505 ,-387 , -248 ,-989 ,-773 ,-77 ,69 ,446 ,234 ,294 ,-163 ,-18 ,589 ,-144 ,-466 ,-161 ,213 , 498 ,311 ,259 ,518 ,-105 ,-873 ,-956 ,-453 ,111 ,394 ,569 ,426 ,443 ,458 ,603 , -94 ,-731 ,25 ,-301 ,-594 ,-129 ,-106 ,-161 ,184 ,233 ,29 ,429 ,511 ,446 ,450 , 685 ,338 ,-108 ,-235 ,-728 ,-338 ,81 ,-380 ,-658 ,-202 ,-492 ,-1060 ,-350 ,358 ,898 , 978 ,962 ,960 ,137 ,261 ,478 ,9 ,-803 ,-978 ,-434 ,-1207 ,-1150 ,-214 ,219 ,631 , 849 ,1368 ,1619 ,824 ,286 ,407 ,61 ,-462 ,-781 ,-1145 ,-1244 ,-767 ,-47 ,134 ,-1 , 227 ,-143 ,-280 ,368 ,320 ,-381 ,-370 ,314 ,383 ,943 ,1313 ,719 ,585 ,390 ,-264 , -480 ,-276 ,-188 ,-197 ,-47 ,256 ,200 ,123 ,101 ,4 ,-255 ,-568 ,-951 ,-746 ,102 , 12 ,124 ,525 ,394 ,-266 ,-678 ,-121 ,215 ,346 ,8 ,-169 ,322 ,224 ,14 ,-4 , 246 ,500 ,39 ,-57 ,151 ,46 ,-130 ,-154 ,-5 ,-28 ,-127 ,9 ,261 ,425 ,384 , 38 ,-99 ,-200 ,-404 ,-503 ,-282 ,-14 ,55 ,313 ,424 ,479 ,321 ,363 ,510 ,226 , 10 ,-284 ,-453 ,-679 ,-830 ,-798 ,-652 ,-176 ,385 ,773 ,993 ,902 ,507 ,431 ,421 , 419 ,-98 ,-403 ,-377 ,-696 ,-465 ,-194 ,-526 ,-882 ,-693 ,-455 ,22 ,487 ,825 ,595 , 336 ,852 ,508 ,23 ,94 ,90 ,-116 ,-396 ,-242 ,42 ,-117 ,-226 ,25 ,187 ,487 , 468 ,92 ,28 ,-62 ,-72 ,-219 ,-81 ,241 ,323 ,473 ,258 ,-4 ,-299 ,-328 ,-168 , -264 ,-420 ,-428 ,-175 ,215 ,230 ,-84 ,199 ,388 ,122 ,-105 ,-149 ,21 ,150 ,-154 , -273 ,13 ,194 ,202 ,-4 ,417 ,456 ,228 ,411 ,275 ,131 ,-157 ,-493 ,-823 ,-293 , 355 ,268 ,101 ,-183 ,-29 ,-21 ,-119 ,35 ,115 ,249 ,266 ,61 ,151 ,327 ,36 , 21 ,293 ,326 ,152 ,-79 ,-388 ,-449 ,-404 ,-123 ,68 ,-32 ,127 ,51 ,95 ,29 , 184 ,360 ,149 ,-88 ,-800 ,-937 ,-649 ,-3 ,659 ,751 ,1181 ,1128 ,700 ,191 ,-40 , 7 ,-448 ,-347 ,-325 ,-703 ,-382 ,-32 ,-224 ,-299 ,-200 ,-15 ,239 ,49 ,-23 ,147 , 225 ,346 ,225 ,345 ,451 ,83 ,-207 ,-184 ,112 ,235 ,148 ,140 ,262 ,20 ,-254 , -177 ,-108 ,-118 ,-182 ,-94 ,-326 ,-397 ,65 ,227 ,99 ,98 ,236 ,291 ,236 ,384 , 403 ,8 ,-49 ,-22 ,16 ,138 ,164 ,147 ,-242 ,-353 ,-181 ,-257 ,-442 ,-291 ,-13 , -51 ,259 ,642 ,357 ,-55 ,10 ,-19 ,-83 ,169 ,195 ,208 ,137 ,11 ,138 ,9 , -20 ,169 ,166 ,70 ,-175 ,-217 ,-260 ,-201 ,93 ,-157 ,-244 ,-20 ,-81 ,-166 ,-191 , -50 ,70 ,212 ,533 ,535 ,338 ,328 ,283 ,139 ,37 ,-165 ,-423 ,-435 ,-216 ,111 , 78 ,-100 ,235 ,434 ,439 ,332 ,-6 ,130 ,-10 ,-402 ,-295 ,-232 ,-239 ,-307 ,-265 , -103 ,132 ,149 ,91 ,248 ,233 ,217 ,3 ,-5 ,113 ,207 ,461 ,380 ,22 ,-239 , -185 ,-151 ,-96 ,39 ,94 ,146 ,54 ,-84 ,58 ,202 ,179 ,-63 ,-157 ,-3 ,-4 , -23 ,-187 ,-128 ,-163 ,-198 ,-38 ,22 ,267 ,202 ,121 ,89 ,138 ,280 ,175 ,185 , 160 ,186 ,150 ,156 ,281 ,243 ,154 ,-230 ,-409 ,-336 ,-359 ,-318 ,-247 ,41 ,201 , -90 ,-271 ,-144 ,140 ,388 ,237 ,106 ,127 ,92 ,-136 ,-222 ,-189 ,-119 ,91 ,49 , 241 ,268 ,308 ,362 ,211 ,307 ,124 ,17 ,-74 ,-157 ,-165 ,-333 ,-349 ,-327 ,-154 , 12 ,122 ,162 ,-19 ,19 ,97 ,45 ,187 ,374 ,375 ,186 ,-202 ,-373 ,-281 ,-327 , -161 ,1 ,113 ,380 ,352 ,248 ,306 ,269 ,116 ,58 ,-85 ,-275 ,-434 ,-427 ,-91 , 17 ,-71 ,-127 ,68 ,467 ,477 ,399 ,194 ,-135 ,-165 ,-88 ,95 ,84 ,-63 ,-77 , -124 ,-153 ,-31 ,-35 ,6 ,75 ,28 ,279 ,376 ,384 ,163 ,-22 ,76 ,47 ,-146 , -461 ,-394 ,-291 ,-70 ,215 ,310 ,260 ,57 ,-78 ,-46 ,234 ,144 ,-16 ,-193 ,-422 , -291 ,-99 ,213 ,291 ,171 ,236 ,333 ,255 ,144 ,159 ,108 ,-51 ,-287 ,-230 ,-213 , -318 ,-61 ,48 ,-40 ,54 ,297 ,342 ,188 ,84 ,34 ,119 ,152 ,75 ,-48 ,-172 , -150 ,-27 ,48 ,83 ,47 ,2 ,87 ,58 ,35 ,36 ,-12 ,22 ,87 ,96 ,46 , 63 ,-54 ,-141 ,-144 ,-212 ,-96 ,-9 ,69 ,129 ,112 ,41 ,-58 ,11 ,106 ,264 , 313 ,364 ,282 ,88 ,55 ,-30 ,100 ,71 ,-259 ,-279 ,-79 ,-21 ,-31 ,-136 ,-155 , -59 ,-26 ,43 ,101 ,167 ,-104 ,-211 ,138 ,275 ,258 ,204 ,117 ,70 ,187 ,211 , 30 ,-104 ,40 ,129 ,-138 ,-188 ,-186 ,-149 ,34 ,-2 ,-63 ,46 ,121 ,165 ,148 , 105 ,215 ,66 ,13 ,107 ,-23 ,-19 ,-84 ,-148 ,-110 ,-61 ,-16 ,-70 ,-79 ,42 , 106 ,35 ,139 ,257 ,169 ,45 ,61 ,49 ,-29 ,4 ,20 ,62 ,102 ,67 ,30 , 5 ,-12 ,55 ,110 ,96 ,0 ,-126 ,-148 ,-113 ,40 ,7 ,-92 ,35 ,3 ,40 , 132 ,42 ,29 ,-9 ,115 ,192 ,156 ,212 ,152 ,17 ,-168 ,-190 ,-190 ,-155 ,-31 , 69 ,177 ,143 ,83 ,26 ,-32 ,-69 ,-115 ,49 ,190 ,110 ,186 ,246 ,103 ,-25 , 30 ,-15 ,-142 ,-28 ,-55 ,-130 ,-98 ,-20 ,80 ,39 ,-90 ,-128 ,23 ,110 ,162 , 201 ,125 ,220 ,228 ,93 ,48 ,-16 ,0 ,28 ,-57 ,-105 ,6 ,115 ,112 ,67 , 32 ,25 ,57 ,60 ,-11 ,-76 ,-113 ,-93 ,-41 ,-46 ,-129 ,-65 ,8 ,-4 ,139 , 199 ,162 ,88 ,66 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1815 ,-2100 , -2621 ,-3623 ,-4290 ,-4326 ,-4128 ,-3133 ,-2265 ,-445 ,461 ,4925 ,12698 ,13738 ,13518 ,11203 ,11621 , 16506 ,14267 ,8962 ,3420 ,-2233 ,-7243 ,-11652 ,-14975 ,-17262 ,-18368 ,-18206 ,-18405 ,-20058 ,-20143 ,-17726 , -13715 ,-8203 ,-1994 ,4531 ,10848 ,16351 ,21058 ,23964 ,26092 ,25510 ,28473 ,32405 ,26862 ,19512 ,10643 , 1955 ,-6829 ,-13617 ,-12216 ,-14679 ,-20476 ,-24479 ,-28768 ,-31033 ,-30960 ,-28348 ,-23996 ,-17901 ,-10943 ,-3291 , 4234 ,11353 ,17522 ,22345 ,25944 ,26471 ,30434 ,32286 ,26949 ,20533 ,13035 ,5543 ,-1830 ,-8492 ,-14191 , -18655 ,-21641 ,-23380 ,-24938 ,-24844 ,-22701 ,-19037 ,-13934 ,-8244 ,-1713 ,4064 ,14844 ,25264 ,27024 ,27323 , 25286 ,22437 ,23741 ,21039 ,13435 ,5670 ,-2466 ,-9682 ,-15975 ,-20932 ,-24178 ,-26020 ,-25764 ,-25106 ,-25052 , -23238 ,-19100 ,-13490 ,-6754 ,530 ,7676 ,14460 ,20020 ,24555 ,27139 ,28555 ,27495 ,26727 ,28282 ,24168 , 16716 ,8464 ,373 ,-8059 ,-12912 ,-13308 ,-17551 ,-22006 ,-24828 ,-26990 ,-27842 ,-26835 ,-23619 ,-19133 ,-13213 , -6789 ,38 ,6579 ,12495 ,17635 ,21159 ,23846 ,23258 ,24001 ,25914 ,22150 ,16560 ,10342 ,3791 ,-2316 , -8073 ,-12790 ,-16539 ,-18998 ,-20145 ,-20919 ,-20660 ,-18898 ,-15615 ,-11551 ,-6513 ,-1477 ,4176 ,13764 ,20007 , 21309 ,21526 ,20219 ,17622 ,17200 ,16591 ,11238 ,5272 ,-860 ,-6611 ,-11478 ,-15561 ,-18180 ,-19857 ,-19871 , -19570 ,-19529 ,-18200 ,-15139 ,-10866 ,-5796 ,-170 ,5266 ,10552 ,14857 ,18425 ,20579 ,21625 ,21272 ,19678 , 20428 ,18846 ,13430 ,7421 ,1211 ,-5128 ,-7773 ,-9053 ,-13337 ,-16796 ,-19247 ,-20671 ,-21425 ,-20855 ,-18599 , -15266 ,-10828 ,-5930 ,-684 ,4409 ,9058 ,13067 ,16044 ,17995 ,17813 ,17425 ,19144 ,17791 ,13573 ,9155 , 4153 ,-531 ,-5041 ,-8832 ,-11897 ,-14082 ,-15159 ,-15775 ,-15841 ,-14896 ,-12598 ,-9809 ,-5960 ,-2446 ,2706 , 10312 ,13982 ,15287 ,15474 ,14900 ,13113 ,11969 ,12425 ,9429 ,5150 ,722 ,-3579 ,-7288 ,-10468 ,-12661 , -14118 ,-14485 ,-14622 ,-14643 ,-13900 ,-11921 ,-8911 ,-5269 ,-1174 ,2942 ,6891 ,10318 ,13051 ,14986 ,15878 , 15949 ,14792 ,14596 ,14605 ,11115 ,6770 ,2114 ,-2464 ,-3789 ,-5767 ,-9486 ,-12377 ,-14584 ,-15706 ,-16448 , -16272 ,-14877 ,-12461 ,-9264 ,-5530 ,-1541 ,2431 ,6138 ,9334 ,11910 ,13369 ,13620 ,12966 ,14069 ,14277 , 11530 ,8286 ,4550 ,916 ,-2619 ,-5724 ,-8309 ,-10238 ,-11394 ,-11923 ,-12211 ,-11840 ,-10387 ,-8481 ,-5664 , -3089 ,1697 ,7387 ,9541 ,10789 ,11093 ,10821 ,9920 ,8586 ,9074 ,7998 ,4930 ,1789 ,-1446 ,-4327 , -6796 ,-8701 ,-9934 ,-10607 ,-11056 ,-11140 ,-10733 ,-9520 ,-7430 ,-4800 ,-1788 ,1347 ,4343 ,7087 ,9267 , 10951 ,11790 ,12085 ,11420 ,10730 ,11223 ,9367 ,6230 ,2622 ,-418 ,-1238 ,-3586 ,-6709 ,-9213 ,-11197 , -12209 ,-12875 ,-12936 ,-12140 ,-10397 ,-8059 ,-5199 ,-2082 ,1053 ,4097 ,6683 ,8944 ,10066 ,10520 ,10181 , 10541 ,11493 ,9953 ,7493 ,4745 ,1787 ,-989 ,-3606 ,-5800 ,-7517 ,-8702 ,-9243 ,-9621 ,-9562 ,-8736 , -7360 ,-5375 ,-3257 ,1077 ,5097 ,6573 ,7697 ,8063 ,8041 ,7612 ,6540 ,6618 ,6644 ,4722 ,2345 , -57 ,-2386 ,-4338 ,-6011 ,-7090 ,-7926 ,-8574 ,-8672 ,-8461 ,-7742 ,-6310 ,-4382 ,-2140 ,301 ,2621 , 4862 ,6663 ,8110 ,8968 ,9277 ,9093 ,8240 ,8600 ,7947 ,5687 ,2893 ,1023 ,273 ,-2180 ,-4787 , -7025 ,-8787 ,-9780 ,-10374 ,-10549 ,-10140 ,-8886 ,-7142 ,-4891 ,-2416 ,151 ,2661 ,4878 ,6778 ,7748 , 8263 ,8264 ,8248 ,9182 ,8722 ,6838 ,4751 ,2362 ,64 ,-2135 ,-4076 ,-5607 ,-6793 ,-7381 ,-7782 , -7888 ,-7517 ,-6469 ,-5151 ,-3128 ,714 ,3358 ,4543 ,5473 ,5946 ,6050 ,5894 ,5250 ,4915 ,5454 , 4448 ,2654 ,832 ,-1056 ,-2642 ,-4109 ,-5094 ,-6053 ,-6784 ,-6940 ,-6812 ,-6403 ,-5431 ,-3992 ,-2289 , -366 ,1509 ,3339 ,4882 ,6122 ,6955 ,7333 ,7337 ,6701 ,6669 ,6712 ,5232 ,3048 ,2127 ,1148 , -1216 ,-3455 ,-5475 ,-7030 ,-8051 ,-8563 ,-8786 ,-8603 ,-7716 ,-6359 ,-4574 ,-2543 ,-405 ,1716 ,3662 , 5228 ,6124 ,6635 ,6944 ,6765 ,7446 ,7683 ,6321 ,4694 ,2716 ,779 ,-1123 ,-2839 ,-4262 ,-5394 , -6049 ,-6455 ,-6639 ,-6562 ,-5763 ,-4896 ,-2821 ,391 ,2087 ,3146 ,3923 ,4421 ,4669 ,4638 ,4356 , 3881 ,4396 ,4177 ,2825 ,1406 ,-114 ,-1495 ,-2730 ,-3710 ,-4697 ,-5465 ,-5686 ,-5611 ,-5374 ,-4728 , -3654 ,-2321 ,-801 ,755 ,2270 ,3617 ,4701 ,5517 ,5919 ,6034 ,5677 ,5311 ,5661 ,4787 ,3244 , 2836 ,1609 ,-528 ,-2512 ,-4343 ,-5750 ,-6777 ,-7264 ,-7489 ,-7430 ,-6841 ,-5756 ,-4309 ,-2627 ,-777 , 1016 ,2765 ,4074 ,4924 ,5481 ,5889 ,5831 ,6120 ,6725 ,5943 ,4570 ,2985 ,1268 ,-378 ,-1936 , -3269 ,-4344 ,-5082 ,-5480 ,-5714 ,-5795 ,-5270 ,-4607 ,-2542 ,10 ,1161 ,2127 ,2797 ,3323 ,3659 , 3714 ,3684 ,3236 ,3546 ,3827 ,2958 ,1801 ,560 ,-653 ,-1729 ,-2708 ,-3700 ,-4457 ,-4765 ,-4740 , -4594 ,-4189 ,-3399 ,-2347 ,-1121 ,198 ,1475 ,2675 ,3662 ,4418 ,4897 ,5031 ,4942 ,4450 ,4731 , 4412 ,3468 ,3275 ,1920 ,14 ,-1794 ,-3476 ,-4773 ,-5796 ,-6294 ,-6529 ,-6529 ,-6158 ,-5284 ,-4104 , -2662 ,-1064 ,511 ,2080 ,3182 ,4023 ,4622 ,5087 ,5191 ,5229 ,5875 ,5619 ,4496 ,3167 ,1659 , 175 ,-1248 ,-2520 ,-3544 ,-4336 ,-4761 ,-5036 ,-5164 ,-4913 ,-4285 ,-2235 ,-382 ,467 ,1315 ,1929 , 2459 ,2851 ,3025 ,3100 ,2883 ,2890 ,3433 ,3052 ,2090 ,1117 ,-4 ,-933 ,-1951 ,-2945 ,-3666 , -4042 ,-4077 ,-3984 ,-3748 ,-3184 ,-2342 ,-1355 ,-223 ,869 ,1943 ,2845 ,3571 ,4077 ,4267 ,4329 , 3891 ,3976 ,3999 ,3798 ,3568 ,2108 ,417 ,-1278 ,-2816 ,-4056 ,-5030 ,-5578 ,-5804 ,-5825 ,-5604 , -4908 ,-3928 ,-2678 ,-1282 ,144 ,1517 ,2500 ,3303 ,3980 ,4430 ,4718 ,4664 ,5112 ,5302 ,4419 , 3314 ,1964 ,602 ,-708 ,-1943 ,-2929 ,-3765 ,-4224 ,-4537 ,-4661 ,-4655 ,-3940 ,-2038 ,-767 ,-57 , 667 ,1253 ,1801 ,2205 ,2495 ,2637 ,2616 ,2488 ,2990 ,3077 ,2331 ,1503 ,531 ,-344 ,-1350 , -2344 ,-3041 ,-3478 ,-3591 ,-3526 ,-3391 ,-3014 ,-2358 ,-1542 ,-584 ,381 ,1333 ,2181 ,2871 ,3401 , 3665 ,3770 ,3537 ,3353 ,3606 ,4028 ,3672 ,2270 ,724 ,-852 ,-2278 ,-3482 ,-4413 ,-5004 ,-5256 , -5281 ,-5150 ,-4633 ,-3796 ,-2718 ,-1486 ,-170 ,1020 ,1929 ,2718 ,3432 ,3924 ,4284 ,4291 ,4507 , 4921 ,4384 ,3390 ,2217 ,946 ,-278 ,-1452 ,-2443 ,-3267 ,-3802 ,-4147 ,-4264 ,-4416 ,-3571 ,-1935 , -1122 ,-478 ,121 ,703 ,1248 ,1678 ,2069 ,2238 ,2402 ,2253 ,2611 ,3014 ,2527 ,1821 ,983 , 132 ,-875 ,-1837 ,-2515 ,-2985 ,-3173 ,-3150 ,-3072 ,-2841 ,-2335 ,-1659 ,-851 ,10 ,865 ,1656 , 2346 ,2856 ,3206 ,3312 ,3278 ,2967 ,3303 ,4201 ,3704 ,2393 ,984 ,-510 ,-1823 ,-3003 ,-3884 , -4506 ,-4785 ,-4817 ,-4724 ,-4344 ,-3635 ,-2693 ,-1598 ,-397 ,622 ,1482 ,2262 ,3002 ,3528 ,3924 , 4053 ,4057 ,4523 ,4319 ,3458 ,2425 ,1243 ,81 ,-1044 ,-2027 ,-2845 ,-3439 ,-3803 ,-3952 ,-4122 , -3185 ,-1916 ,-1399 ,-829 ,-312 ,251 ,792 ,1260 ,1690 ,1952 ,2180 ,2157 ,2322 ,2850 ,2706 , 2064 ,1372 ,513 ,-456 ,-1377 ,-2065 ,-2551 ,-2817 ,-2841 ,-2804 ,-2665 ,-2311 ,-1751 ,-1069 ,-304 , 474 ,1217 ,1884 ,2393 ,2795 ,2925 ,3042 ,2708 ,3094 ,4180 ,3691 ,2507 ,1189 ,-197 ,-1436 , -2574 ,-3429 ,-4073 ,-4380 ,-4445 ,-4360 ,-4090 ,-3499 ,-2674 ,-1701 ,-611 ,277 ,1089 ,1884 ,2605 , 3198 ,3598 ,3829 ,3781 ,4089 ,4213 ,3517 ,2580 ,1510 ,379 ,-673 ,-1668 ,-2466 ,-3120 ,-3502 , -3712 ,-3784 ,-2832 ,-1958 ,-1615 ,-1125 ,-674 ,-133 ,395 ,895 ,1359 ,1699 ,1971 ,2090 ,2121 , 2626 ,2797 ,2286 ,1694 ,843 ,-102 ,-965 ,-1659 ,-2163 ,-2489 ,-2582 ,-2562 ,-2499 ,-2277 ,-1822 , -1253 ,-576 ,128 ,818 ,1466 ,1980 ,2412 ,2611 ,2764 ,2561 ,2992 ,4009 ,3635 ,2573 ,1367 , 76 ,-1101 ,-2186 ,-3036 ,-3676 ,-4031 ,-4120 ,-4035 ,-3845 ,-3368 ,-2664 ,-1778 ,-826 ,-36 ,743 , 1536 ,2258 ,2886 ,3310 ,3612 ,3604 ,3720 ,4005 ,3561 ,2718 ,1736 ,662 ,-348 ,-1335 ,-2136 , -2825 ,-3231 ,-3529 ,-3399 ,-2527 ,-2049 ,-1801 ,-1423 ,-1008 ,-495 ,19 ,562 ,1029 ,1475 ,1761 , 2014 ,2035 ,2367 ,2810 ,2495 ,1963 ,1146 ,221 ,-584 ,-1284 ,-1803 ,-2173 ,-2336 ,-2357 ,-2342 , -2221 ,-1884 ,-1420 ,-824 ,-197 ,457 ,1068 ,1602 ,2032 ,2327 ,2471 ,2487 ,3050 ,3711 ,3512 , 2636 ,1502 ,336 ,-804 ,-1814 ,-2669 ,-3293 ,-3689 ,-3820 ,-3741 ,-3590 ,-3215 ,-2620 ,-1823 ,-1030 , -322 ,425 ,1219 ,1941 ,2586 ,3056 ,3374 ,3478 ,3425 ,3728 ,3562 ,2816 ,1930 ,913 ,-70 , -1029 ,-1850 ,-2550 ,-2987 ,-3349 ,-2982 ,-2287 ,-2154 ,-1968 ,-1708 ,-1316 ,-832 ,-316 ,235 ,733 , 1230 ,1577 ,1896 ,2001 ,2179 ,2686 ,2665 ,2149 ,1388 ,507 ,-254 ,-945 ,-1490 ,-1890 ,-2137 , -2193 ,-2206 ,-2166 ,-1950 ,-1561 ,-1057 ,-491 ,120 ,692 ,1260 ,1665 ,2053 ,2179 ,2458 ,3100 , 3339 ,3316 ,2649 ,1614 ,563 ,-536 ,-1475 ,-2319 ,-2939 ,-3359 ,-3535 ,-3486 ,-3347 ,-3071 ,-2574 , -1877 ,-1220 ,-576 ,155 ,917 ,1649 ,2287 ,2804 ,3144 ,3325 ,3244 ,3398 ,3483 ,2912 ,2084 , 1163 ,192 ,-713 ,-1560 ,-2251 ,-2754 ,-3104 ,-2600 ,-2130 ,-2200 ,-2082 ,-1904 ,-1549 ,-1110 ,-597 , -32 ,487 ,1012 ,1425 ,1772 ,1986 ,2079 ,2525 ,2756 ,2316 ,1600 ,793 ,65 ,-601 ,-1165 , -1595 ,-1895 ,-2018 ,-2052 ,-2063 ,-1954 ,-1644 ,-1235 ,-719 ,-154 ,380 ,938 ,1363 ,1787 ,1938 , 2461 ,3138 ,3049 ,3061 ,2633 ,1705 ,749 ,-280 ,-1172 ,-1990 ,-2602 ,-3033 ,-3253 ,-3240 ,-3103 , -2895 ,-2487 ,-1905 ,-1365 ,-772 ,-71 ,672 ,1397 ,2037 ,2574 ,2925 ,3162 ,3120 ,3125 ,3316 , 2952 ,2190 ,1354 ,410 ,-452 ,-1294 ,-1969 ,-2545 ,-2799 ,-2244 ,-2022 ,-2199 ,-2173 ,-2055 ,-1739 , -1337 ,-827 ,-282 ,280 ,806 ,1285 ,1645 ,1940 ,2050 ,2332 ,2749 ,2424 ,1759 ,1049 ,337 , -293 ,-876 ,-1320 ,-1665 ,-1848 ,-1922 ,-1955 ,-1929 ,-1707 ,-1361 ,-912 ,-408 ,116 ,652 ,1097 , 1521 ,1747 ,2455 ,3082 ,2824 ,2769 ,2544 ,1791 ,899 ,-31 ,-895 ,-1669 ,-2283 ,-2723 ,-2969 , -3017 ,-2877 ,-2716 ,-2390 ,-1923 ,-1489 ,-939 ,-263 ,438 ,1151 ,1782 ,2330 ,2730 ,2958 ,3023 , 2913 ,3081 ,2946 ,2273 ,1520 ,619 ,-214 ,-1039 ,-1700 ,-2320 ,-2460 ,-1967 ,-1944 ,-2161 ,-2231 , -2155 ,-1892 ,-1528 ,-1035 ,-504 ,75 ,610 ,1126 ,1528 ,1866 ,2030 ,2191 ,2622 ,2490 ,1897 , 1271 ,596 ,-20 ,-588 ,-1062 ,-1432 ,-1678 ,-1790 ,-1844 ,-1879 ,-1738 ,-1469 ,-1078 ,-627 ,-115 , 363 ,845 ,1238 ,1610 ,2451 ,2931 ,2662 ,2466 ,2375 ,1830 ,1010 ,186 ,-648 ,-1365 ,-1974 , -2412 ,-2681 ,-2767 ,-2667 ,-2517 ,-2262 ,-1937 ,-1577 ,-1072 ,-435 ,240 ,917 ,1558 ,2096 ,2518 , 2768 ,2884 ,2765 ,2825 ,2859 ,2351 ,1628 ,817 ,-2 ,-789 ,-1456 ,-2084 ,-2065 ,-1740 ,-1886 , -2103 ,-2270 ,-2228 ,-2020 ,-1684 ,-1217 ,-697 ,-115 ,430 ,972 ,1411 ,1767 ,2009 ,2105 ,2441 , 2475 ,1994 ,1449 ,825 ,223 ,-328 ,-822 ,-1209 ,-1500 ,-1664 ,-1738 ,-1804 ,-1755 ,-1548 ,-1216 , -821 ,-342 ,114 ,612 ,970 ,1525 ,2423 ,2718 ,2519 ,2218 ,2136 ,1829 ,1096 ,361 ,-417 , -1085 ,-1680 ,-2123 ,-2403 ,-2534 ,-2475 ,-2333 ,-2134 ,-1937 ,-1640 ,-1177 ,-595 ,54 ,698 ,1326 , 1860 ,2298 ,2557 ,2714 ,2641 ,2574 ,2675 ,2352 ,1685 ,960 ,165 ,-575 ,-1263 ,-1818 ,-1692 , -1591 ,-1851 ,-2063 ,-2292 ,-2292 ,-2139 ,-1826 ,-1391 ,-877 ,-306 ,256 ,797 ,1275 ,1661 ,1942 , 2064 ,2234 ,2383 ,2071 ,1568 ,1019 ,434 ,-96 ,-604 ,-1011 ,-1338 ,-1546 ,-1654 ,-1734 ,-1749 , -1604 ,-1337 ,-984 ,-540 ,-113 ,386 ,737 ,1465 ,2326 ,2470 ,2375 ,2032 ,1903 ,1759 ,1162 , 501 ,-210 ,-847 ,-1414 ,-1840 ,-2140 ,-2290 ,-2284 ,-2149 ,-1998 ,-1909 ,-1663 ,-1243 ,-714 ,-103 , 514 ,1122 ,1651 ,2078 ,2381 ,2537 ,2536 ,2400 ,2465 ,2341 ,1747 ,1101 ,334 ,-355 ,-1050 , -1510 ,-1352 ,-1452 ,-1754 ,-1986 ,-2230 ,-2282 ,-2178 ,-1891 ,-1493 ,-994 ,-446 ,125 ,662 ,1165 , 1561 ,1873 ,2036 ,2074 ,2249 ,2114 ,1687 ,1189 ,640 ,122 ,-382 ,-803 ,-1158 ,-1399 ,-1541 , -1626 ,-1699 ,-1616 ,-1404 ,-1094 ,-706 ,-278 ,178 ,566 ,1422 ,2178 ,2253 ,2203 ,1904 ,1684 , 1637 ,1230 ,617 ,-5 ,-609 ,-1139 ,-1566 ,-1873 ,-2040 ,-2078 ,-1965 ,-1875 ,-1854 ,-1652 ,-1282 , -797 ,-225 ,355 ,935 ,1456 ,1877 ,2193 ,2355 ,2409 ,2264 ,2260 ,2246 ,1784 ,1181 ,478 , -169 ,-865 ,-1169 ,-1062 ,-1342 ,-1681 ,-1933 ,-2170 ,-2275 ,-2205 ,-1957 ,-1591 ,-1110 ,-580 ,-6 , 532 ,1037 ,1457 ,1780 ,1993 ,1934 ,2060 ,2113 ,1761 ,1330 ,814 ,310 ,-169 ,-615 ,-974 , -1259 ,-1440 ,-1534 ,-1634 ,-1609 ,-1463 ,-1186 ,-853 ,-437 ,-27 ,450 ,1389 ,1976 ,2035 ,2007 , 1760 ,1508 ,1469 ,1242 ,710 ,167 ,-389 ,-886 ,-1307 ,-1613 ,-1795 ,-1875 ,-1785 ,-1750 ,-1774 , -1623 ,-1295 ,-853 ,-336 ,214 ,755 ,1270 ,1681 ,2013 ,2181 ,2261 ,2154 ,2053 ,2105 ,1801 , 1246 ,618 ,-14 ,-649 ,-810 ,-821 ,-1227 ,-1581 ,-1870 ,-2090 ,-2229 ,-2197 ,-1986 ,-1653 ,-1192 , -686 ,-126 ,410 ,915 ,1355 ,1693 ,1910 ,1838 ,1886 ,2044 ,1825 ,1434 ,976 ,479 ,15 , -432 ,-810 ,-1119 ,-1332 ,-1452 ,-1558 ,-1586 ,-1492 ,-1263 ,-972 ,-574 ,-225 ,393 ,1317 ,1739 , 1827 ,1791 ,1630 ,1361 ,1277 ,1210 ,790 ,313 ,-195 ,-653 ,-1052 ,-1358 ,-1556 ,-1652 ,-1630 , -1644 ,-1672 ,-1570 ,-1293 ,-905 ,-425 ,88 ,593 ,1083 ,1484 ,1813 ,2009 ,2096 ,2041 ,1895 , 1902 ,1777 ,1288 ,735 ,122 ,-408 ,-451 ,-646 ,-1113 ,-1491 ,-1808 ,-2009 ,-2175 ,-2174 ,-2005 , -1691 ,-1275 ,-778 ,-243 ,291 ,792 ,1240 ,1592 ,1784 ,1758 ,1730 ,1930 ,1854 ,1512 ,1119 , 641 ,189 ,-260 ,-646 ,-977 ,-1221 ,-1375 ,-1476 ,-1557 ,-1509 ,-1327 ,-1080 ,-715 ,-381 ,375 , 1201 ,1478 ,1609 ,1567 ,1468 ,1240 ,1087 ,1114 ,843 ,420 ,-22 ,-443 ,-822 ,-1125 ,-1340 , -1448 ,-1493 ,-1561 ,-1581 ,-1520 ,-1295 ,-947 ,-527 ,-53 ,422 ,884 ,1276 ,1588 ,1807 ,1901 , 1905 ,1752 ,1696 ,1685 ,1300 ,822 ,229 ,-161 ,-179 ,-514 ,-994 ,-1406 ,-1736 ,-1931 ,-2098 , -2129 ,-2009 ,-1724 ,-1340 ,-868 ,-350 ,171 ,668 ,1113 ,1484 ,1641 ,1669 ,1626 ,1765 ,1845 , 1574 ,1227 ,790 ,340 ,-88 ,-492 ,-830 ,-1101 ,-1288 ,-1393 ,-1503 ,-1499 ,-1375 ,-1147 ,-842 , -475 ,349 ,1029 ,1253 ,1397 ,1371 ,1320 ,1151 ,963 ,997 ,883 ,533 ,145 ,-234 ,-588 , -884 ,-1108 ,-1233 ,-1339 ,-1445 ,-1464 ,-1421 ,-1256 ,-957 ,-581 ,-154 ,289 ,715 ,1108 ,1403 , 1640 ,1744 ,1766 ,1659 ,1538 ,1565 ,1319 ,890 ,354 ,98 ,44 ,-378 ,-860 ,-1292 ,-1628 , -1840 ,-1995 ,-2055 ,-1966 ,-1719 ,-1374 ,-928 ,-442 ,67 ,550 ,995 ,1358 ,1504 ,1578 ,1553 , 1629 ,1786 ,1627 ,1309 ,921 ,485 ,74 ,-328 ,-682 ,-969 ,-1190 ,-1302 ,-1426 ,-1453 ,-1388 , -1187 ,-941 ,-525 ,312 ,839 ,1044 ,1183 ,1200 ,1164 ,1058 ,889 ,863 ,887 ,619 ,294 , -50 ,-385 ,-655 ,-895 ,-1037 ,-1205 ,-1331 ,-1343 ,-1321 ,-1203 ,-958 ,-623 ,-239 ,167 ,564 , 932 ,1226 ,1462 ,1583 ,1632 ,1560 ,1419 ,1419 ,1303 ,940 ,481 ,367 ,220 ,-260 ,-730 , -1188 ,-1522 ,-1754 ,-1889 ,-1967 ,-1918 ,-1705 ,-1390 ,-979 ,-514 ,-27 ,442 ,879 ,1219 ,1368 , 1463 ,1503 ,1507 ,1679 ,1650 ,1370 ,1031 ,613 ,211 ,-192 ,-546 ,-849 ,-1088 ,-1230 ,-1343 , -1408 ,-1389 ,-1215 ,-1028 ,-504 ,268 ,642 ,850 ,968 ,1023 ,1007 ,949 ,822 ,746 ,835 , 694 ,422 ,112 ,-183 ,-451 ,-682 ,-853 ,-1067 ,-1214 ,-1235 ,-1208 ,-1136 ,-935 ,-655 ,-313 , 56 ,414 ,765 ,1050 ,1277 ,1420 ,1478 ,1453 ,1322 ,1251 ,1249 ,949 ,619 ,601 ,344 , -150 ,-622 ,-1072 ,-1415 ,-1660 ,-1784 ,-1870 ,-1838 ,-1671 ,-1389 ,-1008 ,-575 ,-108 ,344 ,771 , 1074 ,1243 ,1359 ,1440 ,1432 ,1553 ,1628 ,1412 ,1113 ,728 ,336 ,-51 ,-413 ,-719 ,-975 , -1152 ,-1255 ,-1348 ,-1361 ,-1234 ,-1062 ,-466 ,185 ,456 ,663 ,773 ,856 ,869 ,847 ,776 , 672 ,758 ,731 ,517 ,261 ,-12 ,-268 ,-480 ,-690 ,-929 ,-1088 ,-1127 ,-1100 ,-1055 ,-907 , -672 ,-373 ,-45 ,287 ,605 ,887 ,1109 ,1261 ,1335 ,1329 ,1240 ,1121 ,1151 ,950 ,765 , 777 ,435 ,-45 ,-521 ,-958 ,-1305 ,-1563 ,-1685 ,-1762 ,-1756 ,-1628 ,-1375 ,-1036 ,-625 ,-192 , 246 ,658 ,915 ,1101 ,1240 ,1350 ,1358 ,1426 ,1557 ,1423 ,1157 ,815 ,436 ,59 ,-297 , -626 ,-884 ,-1083 ,-1196 ,-1296 ,-1333 ,-1269 ,-1066 ,-436 ,58 ,265 ,454 ,566 ,662 ,709 , 715 ,686 ,602 ,640 ,723 ,580 ,365 ,130 ,-116 ,-316 ,-566 ,-814 ,-979 ,-1034 ,-1011 , -976 ,-871 ,-687 ,-429 ,-140 ,162 ,447 ,718 ,932 ,1089 ,1176 ,1193 ,1142 ,1005 ,1019 , 924 ,903 ,886 ,489 ,34 ,-434 ,-853 ,-1199 ,-1450 ,-1594 ,-1653 ,-1657 ,-1568 ,-1339 ,-1035 , -653 ,-253 ,162 ,540 ,777 ,974 ,1138 ,1257 ,1314 ,1327 ,1451 ,1427 ,1186 ,889 ,524 , 167 ,-187 ,-506 ,-771 ,-994 ,-1109 ,-1215 ,-1261 ,-1258 ,-998 ,-409 ,-49 ,132 ,299 ,423 , 522 ,589 ,623 ,633 ,587 ,575 ,699 ,651 ,472 ,269 ,45 ,-154 ,-421 ,-678 ,-840 , -919 ,-910 ,-876 ,-818 ,-666 ,-453 ,-199 ,72 ,332 ,583 ,788 ,951 ,1047 ,1088 ,1051 , 953 ,899 ,901 ,1029 ,951 ,557 ,120 ,-330 ,-734 ,-1072 ,-1327 ,-1482 ,-1535 ,-1549 ,-1482 , -1291 ,-1017 ,-669 ,-297 ,96 ,427 ,652 ,859 ,1042 ,1173 ,1257 ,1261 ,1343 ,1394 ,1207 , 940 ,610 ,261 ,-75 ,-399 ,-672 ,-895 ,-1038 ,-1136 ,-1194 ,-1227 ,-909 ,-399 ,-157 ,14 , 149 ,277 ,387 ,471 ,532 ,554 ,560 ,531 ,644 ,678 ,551 ,377 ,174 ,-27 ,-303 , -552 ,-719 ,-811 ,-818 ,-790 ,-753 ,-644 ,-468 ,-253 ,-19 ,220 ,457 ,653 ,817 ,923 , 971 ,959 ,901 ,794 ,884 ,1114 ,966 ,591 ,180 ,-254 ,-635 ,-970 ,-1211 ,-1374 ,-1425 , -1434 ,-1389 ,-1231 ,-986 ,-676 ,-328 ,38 ,322 ,544 ,753 ,951 ,1092 ,1195 ,1215 ,1250 , 1332 ,1211 ,971 ,666 ,337 ,7 ,-298 ,-576 ,-797 ,-961 ,-1057 ,-1116 ,-1163 ,-801 ,-402 , -243 ,-86 ,20 ,149 ,265 ,366 ,448 ,496 ,527 ,506 ,584 ,678 ,613 ,463 ,291 , 72 ,-203 ,-438 ,-606 ,-704 ,-731 ,-709 ,-679 ,-616 ,-478 ,-293 ,-86 ,124 ,332 ,526 , 678 ,791 ,855 ,858 ,838 ,712 ,867 ,1136 ,958 ,616 ,214 ,-186 ,-541 ,-869 ,-1101 , -1265 ,-1326 ,-1324 ,-1287 ,-1164 ,-949 ,-674 ,-346 ,-21 ,219 ,440 ,658 ,852 ,1006 ,1122 , 1158 ,1162 ,1237 ,1191 ,980 ,705 ,398 ,81 ,-212 ,-490 ,-708 ,-891 ,-981 ,-1060 ,-1059 , -695 ,-427 ,-317 ,-181 ,-83 ,44 ,156 ,266 ,362 ,428 ,490 ,491 ,531 ,658 ,644 , 528 ,380 ,150 ,-109 ,-332 ,-495 ,-602 ,-644 ,-629 ,-605 ,-568 ,-474 ,-323 ,-143 ,44 , 234 ,415 ,557 ,678 ,749 ,765 ,762 ,667 ,857 ,1099 ,927 ,623 ,248 ,-121 ,-465 , -773 ,-998 ,-1155 ,-1226 ,-1225 ,-1184 ,-1097 ,-913 ,-670 ,-374 ,-92 ,116 ,336 ,550 ,750 , 913 ,1021 ,1090 ,1083 ,1118 ,1126 ,961 ,716 ,432 ,133 ,-151 ,-425 ,-639 ,-824 ,-930 , -1011 ,-941 ,-627 ,-469 ,-388 ,-286 ,-192 ,-72 ,40 ,160 ,268 ,361 ,428 ,477 ,488 , 596 ,657 ,572 ,444 ,212 ,-31 ,-236 ,-394 ,-502 ,-567 ,-567 ,-543 ,-532 ,-472 ,-345 , -198 ,-31 ,131 ,302 ,441 ,561 ,639 ,675 ,671 ,648 ,863 ,1027 ,886 ,614 ,271 , -63 ,-392 ,-674 ,-893 ,-1047 ,-1124 ,-1119 ,-1078 ,-1009 ,-852 ,-642 ,-376 ,-142 ,43 ,256 , 470 ,671 ,838 ,956 ,1034 ,1037 ,1037 ,1068 ,953 ,734 ,476 ,196 ,-73 ,-334 ,-555 , -737 ,-851 ,-937 ,-787 ,-551 ,-488 ,-422 ,-358 ,-262 ,-150 ,-37 ,88 ,205 ,312 ,392 , 463 ,477 ,564 ,654 ,620 ,501 ,271 ,45 ,-138 ,-294 ,-408 ,-475 ,-491 ,-482 ,-474 , -442 ,-357 ,-231 ,-89 ,58 ,211 ,345 ,463 ,541 ,606 ,591 ,657 ,862 ,929 ,844 , 604 ,298 ,-10 ,-312 ,-566 ,-785 ,-927 ,-1012 ,-1021 ,-976 ,-914 ,-792 ,-614 ,-384 ,-188 , -22 ,182 ,395 ,591 ,765 ,888 ,970 ,992 ,967 ,994 ,928 ,744 ,511 ,245 ,-14 , -251 ,-480 ,-653 ,-782 ,-852 ,-653 ,-504 ,-496 ,-455 ,-415 ,-325 ,-226 ,-104 ,22 ,142 , 265 ,359 ,441 ,482 ,528 ,630 ,643 ,527 ,323 ,112 ,-59 ,-209 ,-314 ,-389 ,-425 , -422 ,-423 ,-409 ,-356 ,-253 ,-133 ,-5 ,127 ,257 ,373 ,455 ,528 ,528 ,675 ,857 , 840 ,778 ,586 ,309 ,32 ,-237 ,-479 ,-681 ,-824 ,-906 ,-917 ,-880 ,-819 ,-735 ,-574 , -381 ,-231 ,-69 ,122 ,330 ,525 ,693 ,822 ,902 ,942 ,916 ,911 ,886 ,736 ,525 , 287 ,37 ,-187 ,-411 ,-576 ,-725 ,-742 ,-532 ,-469 ,-493 ,-486 ,-463 ,-381 ,-286 ,-165 , -40 ,88 ,212 ,324 ,413 ,476 ,508 ,595 ,647 ,534 ,349 ,168 ,12 ,-127 ,-230 , -308 ,-363 ,-368 ,-366 ,-372 ,-351 ,-276 ,-175 ,-60 ,55 ,181 ,286 ,372 ,447 ,478 , 687 ,830 ,754 ,698 ,539 ,313 ,62 ,-184 ,-401 ,-587 ,-720 ,-802 ,-821 ,-794 ,-726 , -661 ,-532 ,-382 ,-264 ,-110 ,74 ,270 ,460 ,620 ,750 ,838 ,881 ,869 ,838 ,831 , 720 ,530 ,315 ,76 ,-134 ,-348 ,-504 ,-654 ,-629 ,-443 ,-438 ,-487 ,-501 ,-485 ,-420 , -333 ,-218 ,-89 ,42 ,170 ,293 ,383 ,466 ,497 ,557 ,632 ,531 ,370 ,217 ,61 , -61 ,-168 ,-251 ,-304 ,-334 ,-335 ,-348 ,-344 ,-299 ,-222 ,-109 ,-15 ,100 ,200 ,298 , 355 ,435 ,674 ,763 ,674 ,602 ,488 ,296 ,72 ,-146 ,-346 ,-517 ,-646 ,-722 ,-752 , -730 ,-669 ,-607 ,-511 ,-404 ,-306 ,-158 ,13 ,197 ,384 ,537 ,670 ,759 ,806 ,804 , 759 ,746 ,673 ,517 ,316 ,103 ,-98 ,-293 ,-454 ,-593 ,-522 ,-392 ,-419 ,-477 ,-520 , -504 ,-454 ,-373 ,-261 ,-137 ,-3 ,124 ,244 ,344 ,430 ,474 ,515 ,569 ,507 ,368 , 242 ,108 ,-5 ,-101 ,-187 ,-240 ,-284 ,-292 ,-301 ,-321 ,-292 ,-232 ,-150 ,-60 ,41 , 125 ,224 ,281 ,404 ,630 ,678 ,600 ,512 ,429 ,287 ,95 ,-83 ,-265 ,-406 ,-519 , -598 ,-630 ,-615 ,-557 ,-500 ,-433 ,-371 ,-290 ,-160 ,-9 ,146 ,311 ,462 ,576 ,666 , 707 ,718 ,676 ,647 ,608 ,484 ,315 ,130 ,-49 ,-212 ,-373 ,-473 ,-384 ,-324 ,-365 , -421 ,-481 ,-472 ,-439 ,-368 ,-267 ,-148 ,-29 ,89 ,210 ,306 ,391 ,444 ,473 ,494 , 461 ,370 ,266 ,156 ,49 ,-41 ,-117 ,-173 ,-218 ,-240 ,-251 ,-272 ,-266 ,-224 ,-171 , -90 ,-10 ,69 ,160 ,211 ,378 ,559 ,581 ,519 ,419 ,358 ,255 ,107 ,-41 ,-185 , -307 ,-415 ,-474 ,-507 ,-502 ,-459 ,-408 ,-369 ,-340 ,-274 ,-170 ,-36 ,104 ,246 ,379 , 488 ,571 ,615 ,631 ,595 ,557 ,530 ,441 ,303 ,152 ,-11 ,-149 ,-294 ,-362 ,-281 , -279 ,-323 ,-373 ,-437 ,-443 ,-420 ,-359 ,-271 ,-168 ,-53 ,61 ,169 ,267 ,340 ,400 , 426 ,419 ,409 ,348 ,266 ,181 ,87 ,8 ,-65 ,-119 ,-166 ,-196 ,-203 ,-230 ,-244 , -217 ,-178 ,-113 ,-45 ,22 ,95 ,164 ,345 ,485 ,485 ,446 ,357 ,290 ,227 ,117 , -9 ,-123 ,-230 ,-317 ,-376 ,-402 ,-400 ,-382 ,-328 ,-309 ,-307 ,-256 ,-163 ,-50 ,69 , 194 ,311 ,409 ,480 ,527 ,542 ,521 ,473 ,445 ,390 ,279 ,153 ,15 ,-105 ,-236 , -258 ,-205 ,-240 ,-283 ,-337 ,-390 ,-409 ,-391 ,-337 ,-265 ,-166 ,-66 ,38 ,137 ,234 , 303 ,360 ,388 ,359 ,351 ,322 ,262 ,193 ,114 ,45 ,-22 ,-80 ,-124 ,-158 ,-175 , -196 ,-215 ,-205 ,-180 ,-126 ,-73 ,-6 ,50 ,136 ,312 ,407 ,400 ,370 ,299 ,236 , 191 ,111 ,17 ,-76 ,-167 ,-234 ,-287 ,-316 ,-320 ,-304 ,-265 ,-264 ,-269 ,-228 ,-156 , -62 ,42 ,155 ,255 ,339 ,404 ,445 ,457 ,450 ,408 ,376 ,341 ,255 ,149 ,33 , -75 ,-178 ,-172 ,-151 ,-205 ,-251 ,-300 ,-344 ,-375 ,-363 ,-316 ,-254 ,-169 ,-78 ,15 , 107 ,193 ,262 ,314 ,331 ,299 ,288 ,283 ,241 ,182 ,118 ,54 ,-4 ,-55 ,-99 , -138 ,-159 ,-173 ,-200 ,-206 ,-187 ,-147 ,-104 ,-44 ,2 ,101 ,258 ,317 ,314 ,288 , 237 ,177 ,140 ,92 ,14 ,-50 ,-125 ,-186 ,-230 ,-254 ,-262 ,-255 ,-226 ,-231 ,-241 , -212 ,-154 ,-72 ,12 ,104 ,191 ,264 ,325 ,364 ,381 ,376 ,347 ,310 ,280 ,228 , 136 ,45 ,-50 ,-126 ,-111 ,-117 ,-174 ,-223 ,-260 ,-299 ,-329 ,-323 ,-290 ,-230 ,-162 , -76 ,6 ,83 ,163 ,224 ,272 ,286 ,257 ,244 ,251 ,228 ,183 ,133 ,78 ,25 , -22 ,-66 ,-101 ,-125 ,-140 ,-162 ,-178 ,-164 ,-139 ,-100 ,-52 ,-11 ,98 ,222 ,261 , 262 ,237 ,204 ,153 ,118 ,93 ,40 ,-17 ,-72 ,-122 ,-164 ,-185 ,-195 ,-193 ,-182 , -189 ,-199 ,-178 ,-134 ,-71 ,0 ,75 ,150 ,210 ,264 ,301 ,312 ,311 ,292 ,256 , 230 ,195 ,125 ,53 ,-26 ,-70 ,-54 ,-85 ,-136 ,-184 ,-222 ,-245 ,-277 ,-274 ,-252 , -203 ,-144 ,-75 ,-2 ,63 ,132 ,182 ,227 ,233 ,212 ,201 ,207 ,201 ,169 ,130 , 85 ,40 ,-2 ,-36 ,-69 ,-98 ,-112 ,-125 ,-144 ,-141 ,-127 ,-98 ,-62 ,-18 ,82 , 165 ,190 ,195 ,177 ,155 ,117 ,89 ,73 ,44 ,4 ,-35 ,-69 ,-102 ,-120 ,-130 , -131 ,-133 ,-148 ,-151 ,-139 ,-109 ,-61 ,-6 ,49 ,102 ,154 ,195 ,222 ,240 ,238 , 225 ,195 ,175 ,154 ,106 ,55 ,-5 ,-24 ,-19 ,-56 ,-98 ,-139 ,-171 ,-186 ,-207 , -212 ,-194 ,-163 ,-116 ,-62 ,-9 ,45 ,95 ,141 ,171 ,173 ,166 ,159 ,162 ,163 , 144 ,116 ,83 ,47 ,13 ,-17 ,-43 ,-65 ,-82 ,-93 ,-109 ,-111 ,-104 ,-85 ,-62 , -17 ,63 ,113 ,129 ,133 ,124 ,111 ,90 ,67 ,56 ,42 ,15 ,-9 ,-35 ,-56 , -73 ,-85 ,-87 ,-97 ,-108 ,-107 ,-103 ,-84 ,-50 ,-13 ,27 ,67 ,104 ,132 ,154 , 167 ,167 ,161 ,142 ,124 ,109 ,83 ,46 ,5 ,0 ,-5 ,-37 ,-70 ,-103 ,-125 , -138 ,-152 ,-155 ,-143 ,-123 ,-90 ,-50 ,-10 ,27 ,66 ,100 ,119 ,119 ,117 ,115 , 115 ,121 ,110 ,93 ,71 ,44 ,19 ,-5 ,-24 ,-43 ,-57 ,-66 ,-77 ,-83 ,-81 , -67 ,-50 ,-13 ,40 ,68 ,81 ,85 ,81 ,74 ,62 ,47 ,39 ,34 ,20 ,4 , -9 ,-24 ,-34 ,-40 ,-48 ,-59 ,-63 ,-61 ,-59 ,-47 ,-31 ,-10 ,9 ,31 ,50 , 64 ,77 ,81 ,82 ,78 ,69 ,58 ,48 ,39 ,21 ,8 ,8 ,1 ,-13 ,-28 , -41 ,-50 ,-54 ,-56 ,-58 ,-53 ,-44 ,-33 ,-19 ,-6 ,5 ,16 ,25 ,29 ,29 , 28 ,27 ,25 ,25 ,23 ,18 ,13 ,8 #if defined(AMY_WAVETABLE) // sounds/wavetables/111.WAV -1946 ,-2630 ,-3431 ,-4782 ,-5750 ,-5603 ,-6049 ,-7092 ,-7906 ,-8874 ,-9710 ,-10474 ,-11380 ,-12145 ,-12816 , -13661 ,-14707 ,-15744 ,-16562 ,-17128 ,-17702 ,-18435 ,-19120 ,-19628 ,-20182 ,-20911 ,-21622 ,-22240 ,-22823 ,-23323 , -23764 ,-24231 ,-24785 ,-25407 ,-25986 ,-26506 ,-27019 ,-27535 ,-27990 ,-28392 ,-28812 ,-29212 ,-29558 ,-29875 ,-30133 , -30354 ,-30576 ,-30741 ,-30881 ,-31055 ,-31270 ,-31520 ,-31739 ,-31881 ,-31935 ,-31987 ,-32106 ,-32254 ,-32377 ,-32425 , -32420 ,-32432 ,-32464 ,-32529 ,-32647 ,-32700 ,-32696 ,-32753 ,-32767 ,-32715 ,-32700 ,-32668 ,-32607 ,-32584 ,-32561 , -32513 ,-32483 ,-32325 ,-31953 ,-31583 ,-31242 ,-30790 ,-30323 ,-29905 ,-29400 ,-28882 ,-28458 ,-27969 ,-27417 ,-26895 , -26373 ,-25903 ,-25490 ,-25010 ,-24481 ,-23994 ,-23471 ,-22874 ,-22385 ,-21968 ,-21418 ,-20854 ,-20350 ,-19769 ,-19252 , -18817 ,-18212 ,-17689 ,-17360 ,-16835 ,-16297 ,-15832 ,-14942 ,-13851 ,-12962 ,-12080 ,-11252 ,-10396 ,-9277 ,-8191 , -7204 ,-6231 ,-5416 ,-4529 ,-3715 ,-2923 ,-2027 ,-1866 ,-1676 ,-911 ,-348 ,430 ,1273 ,1939 ,2748 , 3450 ,4055 ,4761 ,5490 ,6198 ,6975 ,7716 ,8281 ,8811 ,9387 ,9981 ,10627 ,11321 ,11975 ,12583 , 13214 ,13858 ,14495 ,15166 ,15844 ,16520 ,17212 ,17696 ,18015 ,18594 ,19330 ,19945 ,20549 ,21097 ,21595 , 22156 ,22473 ,22553 ,22863 ,23261 ,23603 ,24100 ,24522 ,24780 ,25053 ,25332 ,25624 ,25932 ,26217 ,26514 , 26834 ,27120 ,27392 ,27655 ,27892 ,28138 ,28381 ,28642 ,28936 ,29223 ,29476 ,29726 ,30018 ,30302 ,30511 , 30694 ,30931 ,31239 ,31636 ,32054 ,32317 ,32440 ,32596 ,32767 ,32753 ,32613 ,32659 ,32643 ,32093 ,31368 , 30863 ,30315 ,29645 ,29011 ,28329 ,27560 ,26798 ,26015 ,25192 ,24344 ,23487 ,22712 ,21990 ,21226 ,20479 , 19775 ,19051 ,18304 ,17532 ,16767 ,16063 ,15368 ,14714 ,14098 ,13377 ,12596 ,11835 ,11053 ,10296 ,9576 , 8856 ,8111 ,7257 ,6351 ,5512 ,4659 ,3814 ,3098 ,2530 ,2026 ,1394 ,691 ,135 ,-347 ,-928 , -1603 ,-726 ,-1355 ,-1967 ,-2508 ,-3027 ,-3538 ,-3970 ,-4384 ,-4892 ,-5435 ,-6014 ,-6659 ,-7334 ,-8065 , -8759 ,-9381 ,-9947 ,-10379 ,-10873 ,-11546 ,-12239 ,-12854 ,-13298 ,-13589 ,-13954 ,-14464 ,-15053 ,-15672 ,-16199 , -16696 ,-17197 ,-17628 ,-18097 ,-18589 ,-19050 ,-19517 ,-19935 ,-20323 ,-20757 ,-21170 ,-21547 ,-21960 ,-22363 ,-22745 , -23118 ,-23451 ,-23806 ,-24169 ,-24471 ,-24808 ,-25163 ,-25465 ,-25833 ,-26185 ,-26524 ,-26929 ,-27188 ,-27598 ,-27940 , -27981 ,-29121 ,-30827 ,-31209 ,-31176 ,-31577 ,-31665 ,-31720 ,-31959 ,-31937 ,-31993 ,-32153 ,-32204 ,-32378 ,-32457 , -32466 ,-32701 ,-32767 ,-32311 ,-31603 ,-30914 ,-30201 ,-29453 ,-28672 ,-27864 ,-27171 ,-26524 ,-25757 ,-24958 ,-24128 , -23185 ,-22373 ,-21782 ,-21127 ,-20428 ,-19771 ,-19047 ,-18366 ,-17717 ,-17016 ,-16402 ,-15765 ,-14966 ,-14184 ,-13447 , -12703 ,-12053 ,-11412 ,-10703 ,-10100 ,-9578 ,-8939 ,-8252 ,-7582 ,-6916 ,-6415 ,-6064 ,-5689 ,-5144 ,-4289 , -3330 ,-2583 ,-2011 ,-1507 ,-988 ,-502 ,137 ,704 ,489 ,472 ,1167 ,1660 ,2167 ,2800 ,3023 , 3216 ,3746 ,4216 ,4643 ,5176 ,5744 ,6337 ,6892 ,7465 ,8090 ,8693 ,9230 ,9702 ,10165 ,10655 , 11155 ,11667 ,12200 ,12751 ,13339 ,13973 ,14608 ,15180 ,15619 ,15978 ,16395 ,16870 ,17375 ,17897 ,18419 , 18973 ,19514 ,19996 ,20433 ,20881 ,21372 ,21881 ,22384 ,22824 ,23239 ,23691 ,24171 ,24700 ,25243 ,25734 , 26222 ,26737 ,27204 ,27707 ,28320 ,28907 ,29450 ,29992 ,30480 ,30992 ,31606 ,32237 ,32700 ,32767 ,32527 , 32222 ,31870 ,31513 ,31153 ,30750 ,30379 ,30030 ,29665 ,29315 ,28954 ,28509 ,28027 ,27622 ,27188 ,26590 , 25980 ,25452 ,24912 ,24335 ,23744 ,23135 ,22524 ,21911 ,21264 ,20612 ,19976 ,19354 ,18761 ,18162 ,17579 , 17029 ,16469 ,15878 ,15271 ,14682 ,14098 ,13510 ,12937 ,12368 ,11815 ,11263 ,10677 ,10086 ,9515 ,8937 , 8354 ,7808 ,7260 ,6674 ,6117 ,5571 ,5012 ,4500 ,3991 ,3494 ,3047 ,2561 ,2023 ,1500 ,1007 , 543 ,115 ,8078 ,7606 ,7060 ,6523 ,5992 ,5406 ,4787 ,4193 ,3625 ,3050 ,2497 ,2047 ,1786 , 1616 ,1314 ,923 ,506 ,46 ,-342 ,-699 ,-1132 ,-1628 ,-2138 ,-2664 ,-3301 ,-3955 ,-4533 ,-5138 , -5752 ,-6254 ,-6678 ,-7143 ,-7619 ,-8194 ,-8867 ,-9428 ,-9936 ,-10433 ,-10842 ,-11069 ,-11103 ,-11227 ,-11591 , -12308 ,-13199 ,-13772 ,-14446 ,-15101 ,-15427 ,-16280 ,-16888 ,-17283 ,-18365 ,-18593 ,-19175 ,-20310 ,-19778 ,-20792 , -21286 ,-19484 ,-24778 ,-32767 ,-32458 ,-30485 ,-31121 ,-30139 ,-29057 ,-28800 ,-27705 ,-26959 ,-26399 ,-25411 ,-24847 , -24192 ,-23383 ,-22801 ,-22097 ,-21429 ,-20810 ,-20122 ,-19502 ,-18855 ,-18182 ,-17557 ,-16922 ,-16257 ,-15584 ,-14909 , -14242 ,-13620 ,-12990 ,-12334 ,-11706 ,-11071 ,-10426 ,-9791 ,-9171 ,-8553 ,-7903 ,-7282 ,-6729 ,-6169 ,-5568 , -4959 ,-4314 ,-3656 ,-3044 ,-2436 ,-1796 ,-1105 ,-418 ,226 ,914 ,1590 ,2185 ,2801 ,3443 ,4080 , 4712 ,5321 ,5913 ,6400 ,6824 ,7304 ,7849 ,8365 ,8727 ,9156 ,9680 ,10164 ,10574 ,10881 ,11326 , 11604 ,11787 ,12337 ,12840 ,13292 ,13852 ,14406 ,15019 ,15638 ,16280 ,16937 ,17536 ,18076 ,18584 ,19105 , 19641 ,20149 ,20661 ,21198 ,21702 ,22214 ,22795 ,23414 ,24049 ,24661 ,25187 ,25660 ,26144 ,26635 ,27160 , 27711 ,28238 ,28754 ,29265 ,29767 ,30287 ,30819 ,31349 ,31808 ,32020 ,32072 ,32162 ,32242 ,32326 ,32445 , 32537 ,32636 ,32738 ,32734 ,32688 ,32721 ,32762 ,32767 ,32761 ,32707 ,32639 ,32618 ,32574 ,32403 ,32037 , 31519 ,30987 ,30484 ,30002 ,29526 ,29033 ,28543 ,28142 ,27823 ,27534 ,27290 ,27020 ,26702 ,26375 ,26048 , 25732 ,25416 ,25113 ,24833 ,24539 ,24222 ,23916 ,23615 ,23322 ,23033 ,22738 ,22442 ,22126 ,21825 ,21550 , 21281 ,21015 ,20736 ,20442 ,20147 ,19857 ,19575 ,19297 ,19015 ,18731 ,18454 ,18174 ,17883 ,17623 ,17369 , 17090 ,16842 ,16607 ,16380 ,16166 ,15868 ,15456 ,15077 ,14776 ,14416 ,14083 ,13852 ,13591 ,13337 ,13121 , 12956 ,12898 ,12821 ,14804 ,14784 ,14818 ,14773 ,14391 ,13888 ,13576 ,13355 ,13114 ,12859 ,12668 ,12599 , 12573 ,12462 ,12355 ,12334 ,12207 ,12092 ,12089 ,12004 ,11801 ,11443 ,11183 ,10946 ,10921 ,11423 ,11290 , 11314 ,11607 ,10610 ,10762 ,10861 ,9811 ,11568 ,10726 ,9027 ,12249 ,9135 ,10862 ,17085 ,-5794 ,-32470 , -31097 ,-28743 ,-32767 ,-30679 ,-29601 ,-30494 ,-28542 ,-28202 ,-28089 ,-26560 ,-26448 ,-25721 ,-24749 ,-24473 ,-23625 , -22980 ,-22463 ,-21704 ,-21131 ,-20516 ,-19834 ,-19206 ,-18580 ,-17984 ,-17379 ,-16766 ,-16163 ,-15558 ,-14950 ,-14357 , -13791 ,-13262 ,-12756 ,-12228 ,-11694 ,-11153 ,-10607 ,-10111 ,-9624 ,-9109 ,-8580 ,-8031 ,-7477 ,-6928 ,-6374 , -5810 ,-5273 ,-4776 ,-4287 ,-3809 ,-3302 ,-2742 ,-2173 ,-1655 ,-1195 ,-729 ,-254 ,230 ,739 ,1258 , 1743 ,2189 ,2654 ,3130 ,3567 ,4005 ,4487 ,5004 ,5518 ,6002 ,6512 ,7027 ,7510 ,8014 ,8515 , 9023 ,9481 ,9894 ,10362 ,10644 ,10741 ,10972 ,11307 ,11602 ,11862 ,12199 ,12580 ,12895 ,13221 ,13447 , 13668 ,14104 ,14532 ,14951 ,15420 ,15872 ,16379 ,16886 ,17364 ,17895 ,18460 ,18962 ,19429 ,19850 ,20129 , 20403 ,20758 ,21082 ,21418 ,21760 ,22024 ,22285 ,22589 ,22945 ,23350 ,23710 ,23996 ,24275 ,24572 ,24862 , 25145 ,25432 ,25721 ,26009 ,26298 ,26597 ,26874 ,27132 ,27418 ,27635 ,27633 ,27507 ,27405 ,27282 ,27139 , 27039 ,26958 ,26908 ,26882 ,26796 ,26683 ,26610 ,26553 ,26503 ,26477 ,26473 ,26466 ,26454 ,26446 ,26443 , 26447 ,26461 ,26463 ,26475 ,26527 ,26548 ,26563 ,26632 ,26720 ,26821 ,26917 ,26973 ,27007 ,27049 ,27066 , 27055 ,27089 ,27148 ,27176 ,27212 ,27273 ,27309 ,27296 ,27319 ,27421 ,27466 ,27472 ,27613 ,27849 ,28024 , 28091 ,28096 ,28114 ,28148 ,28144 ,28162 ,28175 ,28151 ,28141 ,28125 ,28224 ,28317 ,28283 ,28311 ,28408 , 28546 ,28661 ,28756 ,28827 ,28790 ,28716 ,28785 ,29134 ,29535 ,29874 ,30235 ,30615 ,31173 ,31411 ,31380 , 31618 ,31579 ,32135 ,32767 ,23633 ,24356 ,24464 ,23986 ,25440 ,24658 ,24621 ,26958 ,24204 ,26194 ,28719 , 23671 ,32767 ,26717 ,-14409 ,-32767 ,-25891 ,-28724 ,-31015 ,-28518 ,-29927 ,-29734 ,-27971 ,-28946 ,-28049 ,-27180 , -27654 ,-26621 ,-26424 ,-26320 ,-25537 ,-25406 ,-24981 ,-24454 ,-24219 ,-23757 ,-23319 ,-22966 ,-22586 ,-22247 ,-21917 , -21588 ,-21233 ,-20844 ,-20412 ,-19947 ,-19443 ,-18922 ,-18444 ,-17991 ,-17543 ,-17118 ,-16699 ,-16257 ,-15827 ,-15423 , -15015 ,-14612 ,-14174 ,-13708 ,-13269 ,-12832 ,-12397 ,-11989 ,-11551 ,-11075 ,-10629 ,-10188 ,-9782 ,-9455 ,-9125 , -8771 ,-8430 ,-8104 ,-7781 ,-7447 ,-7114 ,-6788 ,-6460 ,-6142 ,-5837 ,-5536 ,-5189 ,-4745 ,-4310 ,-3979 , -3676 ,-3373 ,-3087 ,-2768 ,-2473 ,-2243 ,-1935 ,-1534 ,-1141 ,-756 ,-362 ,-14 ,259 ,513 ,747 , 991 ,1277 ,1578 ,1939 ,2294 ,2594 ,2918 ,3245 ,3558 ,3859 ,4147 ,4497 ,4862 ,5205 ,5558 , 5859 ,6192 ,6463 ,6686 ,7151 ,7348 ,7213 ,7477 ,7614 ,7837 ,8550 ,7498 ,5281 ,5141 ,5734 , 5495 ,5749 ,6087 ,6139 ,6482 ,6660 ,6823 ,7210 ,7474 ,7754 ,8098 ,8457 ,8856 ,9200 ,9518 , 9782 ,9992 ,10174 ,10269 ,10317 ,10337 ,10385 ,10519 ,10633 ,10737 ,10903 ,11017 ,11171 ,11358 ,11491 , 11643 ,11658 ,11999 ,12594 ,12735 ,12863 ,13093 ,13216 ,13376 ,13538 ,13691 ,13810 ,13906 ,14029 ,14197 , 14403 ,14538 ,14579 ,14598 ,14628 ,14763 ,15010 ,15209 ,15373 ,15579 ,15760 ,15902 ,16028 ,16129 ,16256 , 16417 ,16550 ,16708 ,16875 ,16996 ,17175 ,17311 ,17274 ,17289 ,17442 ,17592 ,17780 ,18005 ,18203 ,18504 , 18897 ,19211 ,19427 ,19589 ,19733 ,19887 ,20066 ,20268 ,20402 ,20455 ,20529 ,20635 ,20732 ,20887 ,21104 , 21348 ,21604 ,21775 ,21929 ,22106 ,22230 ,22386 ,22554 ,22729 ,22979 ,23151 ,23184 ,23221 ,23312 ,23378 , 23508 ,23727 ,23888 ,23953 ,23848 ,23791 ,23778 ,23993 ,24679 ,24799 ,25163 ,26025 ,25699 ,26347 ,26884 , 25906 ,27412 ,27225 ,26304 ,29557 ,24294 ,25783 ,32767 ,10125 ,-22538 ,-22946 ,-17475 ,-22891 ,-22086 ,-20218 , -21325 ,-20354 ,-18300 ,-20029 ,-28148 ,-32767 ,-30811 ,-30781 ,-31493 ,-30409 ,-30426 ,-30071 ,-28942 ,-28900 ,-28492 , -28029 ,-27932 ,-27377 ,-27082 ,-26781 ,-26327 ,-26176 ,-25899 ,-25523 ,-25327 ,-25102 ,-24773 ,-24418 ,-24098 ,-23819 , -23451 ,-23026 ,-22678 ,-22313 ,-21893 ,-21518 ,-21124 ,-20716 ,-20374 ,-19969 ,-19526 ,-19137 ,-18684 ,-18206 ,-17812 , -17417 ,-17090 ,-16665 ,-15876 ,-15153 ,-14710 ,-14243 ,-13821 ,-13445 ,-12824 ,-12111 ,-11565 ,-11099 ,-10797 ,-10685 , -10491 ,-10247 ,-10117 ,-9953 ,-9710 ,-9527 ,-9315 ,-9054 ,-8847 ,-8598 ,-8349 ,-8214 ,-8055 ,-7805 ,-7560 , -7318 ,-7053 ,-6768 ,-6444 ,-6056 ,-5661 ,-5385 ,-5154 ,-4904 ,-4643 ,-4200 ,-3621 ,-3186 ,-2952 ,-2716 , -2412 ,-2189 ,-1994 ,-1733 ,-1462 ,-1200 ,-925 ,-638 ,-376 ,-80 ,185 ,467 ,892 ,1122 ,1417 , 1867 ,1985 ,2477 ,2813 ,2835 ,3864 ,3688 ,3670 ,6180 ,4938 ,2388 ,4289 ,1216 ,-5921 ,-6165 , -4805 ,-5892 ,-5189 ,-4620 ,-4676 ,-3996 ,-4031 ,-3987 ,-3633 ,-3701 ,-3455 ,-3158 ,-2938 ,-2481 ,-2113 , -1695 ,-1174 ,-824 ,-664 ,-646 ,-740 ,-891 ,-918 ,-750 ,-558 ,-373 ,-128 ,48 ,301 ,529 , 669 ,865 ,770 ,1441 ,2641 ,2857 ,3031 ,3388 ,3570 ,3855 ,4104 ,4367 ,4598 ,4786 ,5014 , 5324 ,5689 ,5875 ,5880 ,5804 ,5749 ,6010 ,6449 ,6761 ,7171 ,7680 ,8021 ,8284 ,8507 ,8624 , 8794 ,8985 ,9037 ,9141 ,9350 ,9509 ,9754 ,9989 ,9984 ,10002 ,10159 ,10304 ,10551 ,10860 ,11116 , 11449 ,11848 ,12198 ,12459 ,12645 ,12841 ,13036 ,13250 ,13513 ,13697 ,13769 ,13811 ,13913 ,14090 ,14272 , 14430 ,14647 ,14918 ,15124 ,15309 ,15463 ,15558 ,15718 ,15922 ,16165 ,16491 ,16731 ,16759 ,16767 ,16895 , 16991 ,17161 ,17464 ,17611 ,17619 ,17527 ,17397 ,17559 ,18032 ,18518 ,19276 ,19499 ,14245 ,3794 ,-1864 , -1764 ,-2315 ,-2383 ,-2656 ,-3366 ,-2121 ,2373 ,2737 ,5682 ,-4800 ,-19178 ,-18717 ,-15952 ,-17815 ,-16818 , -16129 ,-16620 ,-15711 ,-15619 ,-15597 ,-15076 ,-15216 ,-14955 ,-14498 ,-14307 ,-13960 ,-13675 ,-12976 ,-12060 ,-11736 , -11574 ,-11325 ,-11132 ,-10904 ,-10739 ,-10594 ,-10245 ,-9640 ,-9056 ,-8801 ,-8703 ,-8657 ,-8572 ,-7992 ,-7283 , -7042 ,-6848 ,-6502 ,-6268 ,-6108 ,-5884 ,-5585 ,-5281 ,-5021 ,-4761 ,-4416 ,-4059 ,-3686 ,-3215 ,-2774 , -2424 ,-2204 ,-2112 ,-1832 ,-1326 ,-893 ,-551 ,-424 ,-473 ,-282 ,-200 ,-395 ,-178 ,249 ,461 , 722 ,1070 ,1498 ,1913 ,2174 ,2570 ,3023 ,3267 ,3804 ,4083 ,4336 ,4860 ,4533 ,5467 ,4688 , 5292 ,6112 ,4249 ,10651 ,-3720 ,-30373 ,-28461 ,-28198 ,-32767 ,-29317 ,-31474 ,-31761 ,-30304 ,-32301 ,-30391 , -30176 ,-31166 ,-27636 ,-32563 ,-19688 ,8591 ,10467 ,8565 ,11605 ,10360 ,11842 ,11227 ,11480 ,12331 ,11127 , 11652 ,11408 ,10171 ,11585 ,10324 ,9181 ,11664 ,7489 ,9771 ,22512 ,14192 ,-3763 ,-2075 ,971 ,-2981 , -1564 ,-793 ,-2380 ,-703 ,-680 ,-2588 ,1978 ,10217 ,11923 ,10262 ,11247 ,11661 ,11425 ,12130 ,12224 , 12480 ,13132 ,13336 ,13596 ,13727 ,13777 ,13875 ,13645 ,13598 ,13776 ,13870 ,14129 ,14356 ,14474 ,14731 , 14995 ,15136 ,15193 ,15241 ,15382 ,15591 ,15816 ,16023 ,16126 ,16149 ,16192 ,16284 ,16497 ,16880 ,17260 , 17605 ,18002 ,18248 ,18524 ,19071 ,19354 ,19471 ,19994 ,20502 ,20910 ,21652 ,22363 ,22830 ,23281 ,23604 , 23821 ,24075 ,24195 ,24079 ,23918 ,23950 ,24222 ,24674 ,25129 ,25444 ,25739 ,26011 ,26190 ,26400 ,26631 , 26799 ,26920 ,27039 ,27148 ,27159 ,27095 ,27062 ,27135 ,27396 ,27703 ,27885 ,27980 ,28033 ,28146 ,28219 , 28093 ,28007 ,28139 ,28349 ,28530 ,28655 ,28619 ,28484 ,28472 ,28558 ,28684 ,28882 ,29104 ,29245 ,29341 , 29478 ,29559 ,29708 ,29989 ,30198 ,30454 ,30595 ,30721 ,31169 ,31498 ,31959 ,32767 ,32619 ,28759 ,20909 , 16963 ,18696 ,17818 ,19201 ,20247 ,18268 ,22812 ,10617 ,11744 ,15354 ,8216 ,-189 ,-19457 ,-32767 ,-27776 , -30176 ,-32243 ,-30032 ,-31438 ,-31136 ,-30524 ,-31164 ,-30686 ,-30558 ,-30759 ,-30429 ,-30470 ,-30326 ,-30304 ,-29683 , -30199 ,-29221 ,-23545 ,-21545 ,-22387 ,-21782 ,-21902 ,-21633 ,-21300 ,-21054 ,-20638 ,-20564 ,-20576 ,-20751 ,-20762 , -20539 ,-20381 ,-20253 ,-20069 ,-19905 ,-19766 ,-19654 ,-19668 ,-19717 ,-19748 ,-19798 ,-19817 ,-19827 ,-19924 ,-20154 , -20402 ,-20558 ,-20691 ,-20812 ,-20811 ,-20773 ,-20801 ,-20783 ,-20756 ,-20813 ,-20875 ,-20939 ,-21015 ,-20997 ,-20899 , -20833 ,-20741 ,-20541 ,-20396 ,-20398 ,-20382 ,-20296 ,-20148 ,-19922 ,-19670 ,-19508 ,-19569 ,-19640 ,-19558 ,-19551 , -19603 ,-19577 ,-19542 ,-19499 ,-19425 ,-19351 ,-19320 ,-19417 ,-19557 ,-19551 ,-19453 ,-19310 ,-19131 ,-18900 ,-18584 , -18282 ,-18015 ,-17876 ,-17840 ,-17763 ,-17686 ,-17626 ,-17552 ,-17350 ,-17060 ,-16886 ,-16823 ,-16691 ,-16570 ,-16690 , -16862 ,-17018 ,-17320 ,-17492 ,-17570 ,-17721 ,-17738 ,-17856 ,-17742 ,-17533 ,-17835 ,-17522 ,-17434 ,-17813 ,-17620 , -18147 ,-18525 ,-18076 ,-12999 ,-3005 ,-2255 ,-7304 ,3832 ,22149 ,24879 ,21483 ,23708 ,24122 ,23255 ,24276 , 23924 ,23585 ,23888 ,23536 ,23622 ,23768 ,23775 ,23739 ,23136 ,22983 ,23207 ,23057 ,23088 ,23154 ,23130 , 23424 ,23730 ,23769 ,23718 ,23669 ,23614 ,23607 ,23642 ,23659 ,23567 ,23359 ,23203 ,23111 ,23121 ,23287 , 23406 ,23589 ,23868 ,23905 ,24169 ,24890 ,25247 ,25313 ,25556 ,25720 ,25855 ,26040 ,26109 ,26190 ,26259 , 26247 ,26288 ,26306 ,26219 ,26066 ,25840 ,25693 ,25758 ,25933 ,26083 ,26181 ,26290 ,26422 ,26521 ,26549 , 26534 ,26515 ,26483 ,26485 ,26472 ,26344 ,26179 ,26032 ,25964 ,26032 ,26102 ,26107 ,26081 ,26073 ,26095 , 26011 ,25818 ,25591 ,25466 ,25515 ,25534 ,25515 ,25465 ,25329 ,25225 ,25155 ,25098 ,25111 ,25174 ,25181 , 25201 ,25247 ,25227 ,25267 ,25198 ,25232 ,25428 ,25270 ,25543 ,25682 ,25328 ,25987 ,25635 ,25351 ,26553 , 25209 ,25913 ,27064 ,24330 ,27463 ,27283 ,24830 ,32767 ,19740 ,-3608 ,-13875 ,-12751 ,-16606 ,-25914 ,-28548 , -27571 ,-28703 ,-28324 ,-28563 ,-28734 ,-28329 ,-28713 ,-28585 ,-28536 ,-28701 ,-28611 ,-28681 ,-28684 ,-28693 ,-28716 , -28669 ,-28813 ,-28425 ,-27136 ,-25802 ,-27963 ,-31833 ,-31994 ,-31556 ,-31877 ,-31549 ,-31574 ,-31560 ,-31583 ,-31639 , -31605 ,-31609 ,-31518 ,-31447 ,-31361 ,-31249 ,-31196 ,-31178 ,-31190 ,-31264 ,-31390 ,-31513 ,-31575 ,-31589 ,-31615 , -31671 ,-31737 ,-31780 ,-31811 ,-31837 ,-31821 ,-31807 ,-31826 ,-31845 ,-31881 ,-31925 ,-31967 ,-32014 ,-32057 ,-32108 , -32205 ,-32391 ,-32579 ,-32677 ,-32750 ,-32767 ,-32706 ,-32637 ,-32543 ,-32464 ,-32391 ,-32233 ,-32087 ,-32038 ,-32060 , -32109 ,-32081 ,-31960 ,-31850 ,-31770 ,-31701 ,-31684 ,-31644 ,-31573 ,-31562 ,-31513 ,-31531 ,-31577 ,-31459 ,-31388 , -31363 ,-31288 ,-31250 ,-31219 ,-31143 ,-31041 ,-30996 ,-30957 ,-30906 ,-30872 ,-30824 ,-30783 ,-30707 ,-30749 ,-30726 , -30551 ,-30691 ,-30537 ,-30403 ,-30679 ,-30240 ,-30380 ,-30620 ,-29937 ,-30390 ,-30293 ,-29671 ,-30380 ,-29844 ,-29256 , -30959 ,-29971 ,-30465 ,-29164 ,-107 ,31996 ,30729 ,27372 ,32767 ,30629 ,30540 ,31862 ,30268 ,30917 ,31012 , 30178 ,30687 ,30391 ,30102 ,30341 ,30001 ,29948 ,29957 ,29724 ,29703 ,29610 ,29458 ,29367 ,29260 ,29174 , 29085 ,29008 ,28940 ,28870 ,28820 ,28725 ,28592 ,28499 ,28403 ,28284 ,28188 ,28098 ,27995 ,27885 ,27782 , 27688 ,27585 ,27480 ,27353 ,27194 ,27067 ,26933 ,26756 ,26591 ,26426 ,26272 ,26127 ,25961 ,25820 ,25695 , 25564 ,25454 ,25329 ,25162 ,24986 ,24823 ,24698 ,24590 ,24445 ,24310 ,24225 ,24146 ,24044 ,23950 ,23903 , 23830 ,23697 ,23559 ,23435 ,23343 ,23254 ,23151 ,23064 ,22959 ,22845 ,22749 ,22623 ,22471 ,22354 ,22253 , 22150 ,22061 ,21967 ,21821 ,21696 ,21653 ,21560 ,21434 ,21363 ,21248 ,21080 ,20911 ,20718 ,20555 ,20501 , 20507 ,20509 ,20456 ,20306 ,20136 ,19993 ,19845 ,19671 ,19559 ,19448 ,19251 ,19194 ,18938 ,18702 ,18745 , 18269 ,18440 ,18245 ,17680 ,18468 ,17851 ,18839 ,20143 ,15194 ,3811 ,-14285 ,-21156 ,-17479 ,-18702 ,-19805 , -18676 ,-19608 ,-19561 ,-19346 ,-20011 ,-19899 ,-20013 ,-20368 ,-20324 ,-20555 ,-20740 ,-20729 ,-20807 ,-20842 ,-20957 , -21105 ,-21277 ,-21355 ,-21498 ,-21636 ,-21579 ,-22317 ,-23776 ,-24279 ,-23568 ,-25755 ,-29411 ,-29514 ,-29390 ,-29946 , -29753 ,-29863 ,-29867 ,-29875 ,-29940 ,-29949 ,-29973 ,-29992 ,-30093 ,-30140 ,-30127 ,-30110 ,-30079 ,-30054 ,-30003 , -29919 ,-29868 ,-29804 ,-29665 ,-29536 ,-29415 ,-29275 ,-29285 ,-29362 ,-29243 ,-29066 ,-29054 ,-29099 ,-29072 ,-29059 , -29062 ,-29044 ,-29063 ,-29052 ,-29009 ,-29031 ,-29070 ,-29102 ,-29162 ,-29240 ,-29335 ,-29388 ,-29389 ,-29398 ,-29421 , -29435 ,-29403 ,-29382 ,-29400 ,-29422 ,-29454 ,-29481 ,-29508 ,-29550 ,-29587 ,-29611 ,-29685 ,-29774 ,-29794 ,-29790 , -29806 ,-29850 ,-29896 ,-29918 ,-29943 ,-29978 ,-29997 ,-30024 ,-30077 ,-30111 ,-30143 ,-30170 ,-30186 ,-30277 ,-30335 , -30342 ,-30412 ,-30355 ,-30374 ,-30475 ,-30341 ,-30533 ,-30552 ,-30358 ,-30768 ,-30554 ,-30486 ,-31057 ,-30506 ,-30560 , -31757 ,-30957 ,-32767 ,-32523 ,-8535 ,23411 ,32240 ,30996 ,32732 ,32565 ,32578 ,32767 ,32124 ,32263 ,32100 , 31694 ,31724 ,31446 ,31235 ,31177 ,30916 ,30746 ,30605 ,30401 ,30235 ,30058 ,29863 ,29680 ,29513 ,29341 , 29165 ,29006 ,28844 ,28684 ,28514 ,28322 ,28136 ,27956 ,27775 ,27604 ,27451 ,27296 ,27126 ,26913 ,26687 , 26502 ,26310 ,26108 ,25924 ,25744 ,25548 ,25360 ,25179 ,24967 ,24764 ,24576 ,24372 ,24151 ,23895 ,23643 , 23423 ,23214 ,22996 ,22736 ,22453 ,22196 ,21992 ,21816 ,21620 ,21417 ,21226 ,21074 ,20965 ,20801 ,20588 , 20421 ,20256 ,20076 ,19890 ,19690 ,19540 ,19372 ,19141 ,18947 ,18758 ,18571 ,18419 ,18245 ,18079 ,17950 , 17807 ,17663 ,17517 ,17313 ,17150 ,17048 ,16891 ,16664 ,16422 ,16246 ,16097 ,15892 ,15689 ,15500 ,15299 , 15171 ,15135 ,15097 ,14981 ,14736 ,14488 ,14311 ,14006 ,13675 ,13412 ,13063 ,12833 ,12510 ,12130 ,12049 , 11622 ,11497 ,11466 ,10990 ,11480 ,11259 ,11616 ,12535 ,7392 ,-679 ,-6589 ,-9468 ,-10230 ,-10160 ,-10584 , -10713 ,-10741 ,-10923 ,-11042 ,-11173 ,-11405 ,-11613 ,-11803 ,-12044 ,-12253 ,-12383 ,-12452 ,-12578 ,-12836 ,-13126 , -13353 ,-13532 ,-13679 ,-13824 ,-14033 ,-14174 ,-14404 ,-14556 ,-14734 ,-15010 ,-14903 ,-15812 ,-16876 ,-17180 ,-17190 , -17398 ,-20350 ,-22436 ,-21964 ,-22231 ,-22324 ,-22341 ,-22544 ,-22552 ,-22697 ,-22733 ,-22754 ,-22754 ,-22718 ,-22720 , -22728 ,-22752 ,-22798 ,-22833 ,-22866 ,-22921 ,-22989 ,-23097 ,-23204 ,-23214 ,-23159 ,-23183 ,-23297 ,-23391 ,-23469 , -23592 ,-23731 ,-23844 ,-23941 ,-24048 ,-24157 ,-24201 ,-24214 ,-24215 ,-24223 ,-24329 ,-24440 ,-24528 ,-24683 ,-24846 , -24995 ,-25177 ,-25338 ,-25403 ,-25469 ,-25599 ,-25673 ,-25722 ,-25806 ,-25899 ,-26011 ,-26084 ,-26227 ,-26387 ,-26391 , -26462 ,-26612 ,-26719 ,-26832 ,-26933 ,-27031 ,-27128 ,-27224 ,-27312 ,-27405 ,-27488 ,-27582 ,-27724 ,-27809 ,-27964 , -28056 ,-28053 ,-28362 ,-28298 ,-28312 ,-28769 ,-28324 ,-28720 ,-29093 ,-28315 ,-29398 ,-29210 ,-28463 ,-30110 ,-29116 , -28302 ,-30961 ,-29001 ,-30344 ,-32767 ,-1907 ,32767 ,28117 ,23832 ,30541 ,27340 ,27243 ,28833 ,26597 ,27406 , 27394 ,26212 ,26838 ,26301 ,25828 ,26072 ,25503 ,25334 ,25246 ,24831 ,24713 ,24496 ,24203 ,24008 ,23773 , 23534 ,23298 ,23088 ,22888 ,22680 ,22460 ,22195 ,21944 ,21741 ,21540 ,21333 ,21128 ,20901 ,20634 ,20372 , 20166 ,19969 ,19753 ,19536 ,19308 ,19071 ,18835 ,18600 ,18358 ,18120 ,17897 ,17653 ,17401 ,17156 ,16903 , 16665 ,16439 ,16184 ,15893 ,15582 ,15279 ,15025 ,14801 ,14535 ,14237 ,13985 ,13768 ,13545 ,13332 ,13107 , 12891 ,12714 ,12503 ,12271 ,12056 ,11832 ,11628 ,11414 ,11138 ,10866 ,10614 ,10360 ,10134 ,9931 ,9759 , 9596 ,9417 ,9239 ,9032 ,8817 ,8630 ,8442 ,8197 ,7906 ,7655 ,7437 ,7207 ,6943 ,6655 ,6443 , 6297 ,6132 ,5950 ,5788 ,5597 ,5382 ,5227 ,4978 ,4682 ,4400 ,3950 ,3631 ,3317 ,2846 ,2786 , 2539 ,2143 ,2278 ,1790 ,1675 ,1943 ,1284 ,1804 ,971 ,-2442 ,-4185 ,-2982 ,-3095 ,-3189 ,-3627 , -3676 ,-3796 ,-3970 ,-4008 ,-4070 ,-4138 ,-4363 ,-4619 ,-4800 ,-5031 ,-5309 ,-5522 ,-5674 ,-5894 ,-6141 , -6333 ,-6636 ,-7044 ,-7335 ,-7536 ,-7762 ,-7929 ,-8037 ,-8184 ,-8369 ,-8514 ,-8635 ,-8891 ,-8994 ,-9204 , -9400 ,-9491 ,-10763 ,-11542 ,-11571 ,-11888 ,-11700 ,-13571 ,-15813 ,-15784 ,-15978 ,-16251 ,-16289 ,-16400 ,-16306 , -16400 ,-16521 ,-16638 ,-16795 ,-16918 ,-17056 ,-17194 ,-17335 ,-17508 ,-17674 ,-17791 ,-17868 ,-17929 ,-18051 ,-18250 , -18426 ,-18585 ,-18776 ,-18954 ,-19133 ,-19332 ,-19502 ,-19652 ,-19802 ,-19974 ,-20176 ,-20367 ,-20557 ,-20758 ,-20967 , -21194 ,-21411 ,-21612 ,-21825 ,-22043 ,-22200 ,-22348 ,-22548 ,-22734 ,-22921 ,-23104 ,-23268 ,-23381 ,-23534 ,-23819 , -23971 ,-24089 ,-24347 ,-24578 ,-24784 ,-24990 ,-25203 ,-25391 ,-25570 ,-25766 ,-25933 ,-26113 ,-26274 ,-26454 ,-26610 , -26756 ,-26973 ,-27023 ,-27241 ,-27413 ,-27316 ,-27771 ,-27648 ,-27614 ,-28354 ,-27751 ,-28287 ,-28922 ,-27851 ,-29131 , -29286 ,-27704 ,-29877 ,-29659 ,-28773 ,-32767 ,-14381 ,19703 ,22836 ,14558 ,19814 ,18692 ,15740 ,18155 ,16116 , 15525 ,24948 ,32767 ,31226 ,30235 ,31377 ,30518 ,30250 ,30277 ,29614 ,29544 ,29281 ,28792 ,28676 ,28283 , 27932 ,27742 ,27338 ,27052 ,26797 ,26469 ,26213 ,25946 ,25702 ,25462 ,25192 ,24937 ,24667 ,24393 ,24099 , 23784 ,23493 ,23199 ,22923 ,22700 ,22480 ,22260 ,22065 ,21866 ,21656 ,21482 ,21318 ,21118 ,20910 ,20701 , 20490 ,20303 ,20140 ,19972 ,19778 ,19574 ,19362 ,19157 ,18922 ,18619 ,18353 ,18167 ,18024 ,17900 ,17730 , 17583 ,17485 ,17428 ,17127 ,15201 ,11677 ,9508 ,9483 ,9350 ,8828 ,8679 ,8428 ,8091 ,7897 ,7606 , 7328 ,7102 ,6826 ,6597 ,6370 ,6126 ,5914 ,5686 ,5471 ,5264 ,5051 ,4837 ,4558 ,4214 ,3897 , 3708 ,3640 ,3568 ,3390 ,3113 ,2861 ,2609 ,2308 ,2068 ,1769 ,1509 ,1199 ,881 ,712 ,-3 , -317 ,-180 ,-717 ,-815 ,-860 ,-1396 ,-1749 ,-2024 ,-2292 ,-2761 ,-3147 ,-3196 ,-7745 ,-7755 ,-7840 , -7995 ,-8163 ,-8379 ,-8589 ,-8762 ,-8945 ,-9078 ,-9160 ,-9234 ,-9249 ,-9303 ,-9539 ,-9810 ,-10006 ,-10193 , -10302 ,-10379 ,-10613 ,-10919 ,-11137 ,-11309 ,-11427 ,-11580 ,-11734 ,-11671 ,-11565 ,-11450 ,-11623 ,-11722 ,-11746 , -13019 ,-14068 ,-14046 ,-14302 ,-14456 ,-14639 ,-14825 ,-14774 ,-15576 ,-16450 ,-16545 ,-16733 ,-16958 ,-17115 ,-17329 , -17472 ,-17634 ,-17790 ,-17925 ,-18070 ,-18224 ,-18381 ,-18561 ,-18810 ,-19098 ,-19350 ,-19515 ,-19613 ,-19720 ,-19871 , -20068 ,-20298 ,-20507 ,-20678 ,-20823 ,-20967 ,-21149 ,-21348 ,-21578 ,-21774 ,-21807 ,-21788 ,-21873 ,-21988 ,-22078 , -22215 ,-22345 ,-22456 ,-22615 ,-22730 ,-22848 ,-23074 ,-23292 ,-23486 ,-23703 ,-23917 ,-24155 ,-24401 ,-24642 ,-24902 , -25109 ,-25248 ,-25403 ,-25529 ,-25636 ,-25755 ,-25831 ,-25954 ,-26138 ,-26394 ,-26620 ,-26698 ,-26861 ,-27104 ,-27300 , -27473 ,-27670 ,-27847 ,-27918 ,-27968 ,-28048 ,-28152 ,-28226 ,-28320 ,-28470 ,-28526 ,-28691 ,-28798 ,-28789 ,-29102 , -29035 ,-29068 ,-29540 ,-29130 ,-29536 ,-29876 ,-29154 ,-30198 ,-29957 ,-29318 ,-30881 ,-29813 ,-29155 ,-31585 ,-29693 , -31187 ,-32767 ,-4841 ,23462 ,17718 ,15081 ,20669 ,17299 ,17850 ,18697 ,16682 ,17952 ,17136 ,16234 ,16843 , 15888 ,22311 ,32410 ,32767 ,30763 ,32147 ,31603 ,30967 ,31261 ,30599 ,30381 ,30316 ,29794 ,29667 ,29438 , 29042 ,28878 ,28597 ,28304 ,28110 ,27899 ,27758 ,27613 ,27447 ,27310 ,27155 ,27020 ,26895 ,26746 ,26607 , 26470 ,26319 ,26176 ,26082 ,25986 ,25831 ,25678 ,25532 ,25384 ,25213 ,25002 ,24846 ,24740 ,24644 ,24544 , 24406 ,24338 ,24266 ,24245 ,24039 ,22017 ,18351 ,16126 ,16025 ,16004 ,15486 ,15230 ,15238 ,14606 ,14365 , 14656 ,13693 ,14345 ,14379 ,9270 ,1386 ,-2516 ,24 ,-4740 ,-10092 ,-6259 ,-7968 ,-9418 ,-7701 ,-9341 , -8962 ,-8713 ,-9167 ,-8372 ,-8789 ,-9242 ,-9147 ,-9648 ,-9908 ,-10040 ,-10536 ,-10698 ,-10859 ,-11092 ,-11035 , -11512 ,-11787 ,-11655 ,-12104 ,-12158 ,-12105 ,-12486 ,-12658 ,-12956 ,-13176 ,-13111 ,-13198 ,-13157 ,-18904 ,-19204 , -19715 ,-19834 ,-19905 ,-20274 ,-20491 ,-20682 ,-20897 ,-20902 ,-21009 ,-20893 ,-21125 ,-21066 ,-21149 ,-21712 ,-18803 , -16264 ,-16992 ,-17025 ,-17227 ,-17572 ,-17605 ,-17941 ,-17972 ,-18091 ,-18333 ,-18477 ,-18624 ,-18726 ,-18875 ,-18937 , -18975 ,-19488 ,-19936 ,-20055 ,-20245 ,-20297 ,-20311 ,-20359 ,-20380 ,-20484 ,-20521 ,-20599 ,-20925 ,-21242 ,-21424 , -21633 ,-21799 ,-21878 ,-21985 ,-22093 ,-22183 ,-22324 ,-22504 ,-22689 ,-22839 ,-22936 ,-23001 ,-23028 ,-23083 ,-23190 , -23283 ,-23390 ,-23481 ,-23486 ,-23495 ,-23580 ,-23682 ,-23780 ,-23890 ,-23985 ,-24078 ,-24188 ,-24278 ,-24332 ,-24370 , -24461 ,-24587 ,-24695 ,-24823 ,-24944 ,-25056 ,-25177 ,-25284 ,-25404 ,-25538 ,-25668 ,-25753 ,-25810 ,-25871 ,-25993 , -26215 ,-26394 ,-26514 ,-26654 ,-26741 ,-26791 ,-26920 ,-27066 ,-27164 ,-27274 ,-27388 ,-27504 ,-27611 ,-27713 ,-27841 , -27929 ,-27955 ,-27984 ,-28040 ,-28097 ,-28178 ,-28270 ,-28340 ,-28416 ,-28535 ,-28677 ,-28710 ,-28729 ,-28826 ,-28891 , -28937 ,-28980 ,-29034 ,-29121 ,-29200 ,-29257 ,-29321 ,-29391 ,-29442 ,-29525 ,-29577 ,-29640 ,-29747 ,-29744 ,-29913 , -30029 ,-29952 ,-30270 ,-30204 ,-30164 ,-30627 ,-30197 ,-30508 ,-30973 ,-30170 ,-31074 ,-31183 ,-29969 ,-31904 ,-31703 , -31563 ,-32767 ,-11457 ,19729 ,22505 ,16506 ,21085 ,20320 ,19207 ,24892 ,29997 ,32767 ,32649 ,31670 ,32334 , 32015 ,31485 ,31720 ,31285 ,31078 ,31031 ,30693 ,30636 ,30487 ,30277 ,30182 ,29993 ,29871 ,29742 ,29574 , 29457 ,29276 ,29112 ,28974 ,28814 ,28701 ,28560 ,28402 ,28280 ,28134 ,27985 ,27860 ,27733 ,27599 ,27491 , 27372 ,27232 ,27144 ,26997 ,26870 ,26798 ,26554 ,26408 ,26230 ,25909 ,25886 ,25614 ,25326 ,25437 ,24673 , 24588 ,24982 ,23753 ,25089 ,24732 ,18773 ,10302 ,4342 ,8840 ,3278 ,-4179 ,4254 ,-2968 ,-12594 ,-15687 , -24841 ,-23287 ,-22507 ,-25255 ,-22919 ,-23973 ,-24529 ,-23654 ,-24619 ,-24508 ,-24338 ,-24929 ,-24787 ,-24799 ,-24940 , -24681 ,-24694 ,-24726 ,-24574 ,-24532 ,-24499 ,-24429 ,-24425 ,-24453 ,-24562 ,-24712 ,-24715 ,-24686 ,-24647 ,-27577 , -27754 ,-28015 ,-27990 ,-27952 ,-28063 ,-28059 ,-28094 ,-28164 ,-28193 ,-28390 ,-28423 ,-28524 ,-28431 ,-28407 ,-28689 , -27226 ,-25887 ,-26252 ,-26255 ,-26238 ,-26426 ,-26511 ,-26835 ,-26780 ,-26820 ,-27062 ,-25777 ,-24643 ,-24861 ,-24731 , -24640 ,-24690 ,-24616 ,-24661 ,-24757 ,-25013 ,-25223 ,-25326 ,-25385 ,-25399 ,-25450 ,-25474 ,-25514 ,-25716 ,-25963 , -26120 ,-26292 ,-26487 ,-26591 ,-26612 ,-26611 ,-26647 ,-26745 ,-26858 ,-26953 ,-27024 ,-27066 ,-27093 ,-27131 ,-27184 , -27263 ,-27335 ,-27395 ,-27473 ,-27508 ,-27538 ,-27618 ,-27676 ,-27732 ,-27791 ,-27845 ,-27899 ,-27919 ,-27928 ,-27927 , -27918 ,-27930 ,-27948 ,-27969 ,-27994 ,-28021 ,-28080 ,-28154 ,-28223 ,-28304 ,-28386 ,-28448 ,-28491 ,-28528 ,-28581 , -28662 ,-28752 ,-28810 ,-28863 ,-28930 ,-28974 ,-28982 ,-28992 ,-29030 ,-29088 ,-29137 ,-29177 ,-29253 ,-29367 ,-29486 , -29563 ,-29568 ,-29586 ,-29620 ,-29590 ,-29558 ,-29566 ,-29578 ,-29594 ,-29618 ,-29645 ,-29678 ,-29691 ,-29696 ,-29737 , -29772 ,-29782 ,-29805 ,-29855 ,-29877 ,-29859 ,-29873 ,-29876 ,-29857 ,-29873 ,-29877 ,-29865 ,-29876 ,-29893 ,-29899 , -29899 ,-29922 ,-29952 ,-30006 ,-30072 ,-30088 ,-30095 ,-30121 ,-30162 ,-30206 ,-30247 ,-30261 ,-30250 ,-30297 ,-30346 , -30337 ,-30414 ,-30407 ,-30392 ,-30497 ,-30415 ,-30863 ,-31553 ,-32767 ,-30766 ,-11623 ,18966 ,32767 ,29697 ,29864 , 31969 ,30820 ,30951 ,31190 ,30479 ,30705 ,30514 ,30163 ,30267 ,29965 ,29813 ,29783 ,29524 ,29426 ,29306 , 29113 ,29002 ,28822 ,28665 ,28562 ,28399 ,28304 ,28184 ,27993 ,27885 ,27757 ,27605 ,27490 ,27365 ,27222 , 27081 ,26924 ,26741 ,26613 ,26481 ,26370 ,26272 ,26119 ,26070 ,25903 ,25751 ,25746 ,25425 ,25432 ,25412 , 24875 ,25177 ,24913 ,24294 ,25291 ,24122 ,24014 ,25591 ,22840 ,25487 ,22472 ,13781 ,16722 ,6663 ,-7655 , -17160 ,-30539 ,-28739 ,-27909 ,-31854 ,-29303 ,-30449 ,-30840 ,-29747 ,-30657 ,-30327 ,-30069 ,-30522 ,-30304 ,-30298 , -30378 ,-29693 ,-28545 ,-27571 ,-27285 ,-27123 ,-26808 ,-26703 ,-26611 ,-26482 ,-26438 ,-26408 ,-26293 ,-26124 ,-26149 , -25992 ,-26048 ,-26036 ,-25717 ,-25514 ,-25405 ,-24965 ,-25868 ,-27970 ,-28486 ,-28135 ,-28413 ,-28422 ,-28309 ,-28406 , -28426 ,-28478 ,-28424 ,-28451 ,-28382 ,-28199 ,-28417 ,-28239 ,-28290 ,-28535 ,-27787 ,-28743 ,-31252 ,-31518 ,-30119 , -29511 ,-29657 ,-29732 ,-29667 ,-29571 ,-29612 ,-29747 ,-29881 ,-29985 ,-29990 ,-29991 ,-29989 ,-29994 ,-30004 ,-30030 , -30140 ,-30242 ,-30327 ,-30453 ,-30540 ,-30539 ,-30508 ,-30521 ,-30580 ,-30637 ,-30674 ,-30719 ,-30763 ,-30797 ,-30845 , -30883 ,-30915 ,-30954 ,-30976 ,-31016 ,-31061 ,-31089 ,-31119 ,-31139 ,-31178 ,-31221 ,-31260 ,-31296 ,-31237 ,-31038 , -30792 ,-30668 ,-30689 ,-30756 ,-30793 ,-30800 ,-30799 ,-30749 ,-30711 ,-30703 ,-30653 ,-30632 ,-30626 ,-30577 ,-30552 , -30530 ,-30493 ,-30491 ,-30451 ,-30393 ,-30526 ,-30780 ,-30880 ,-30849 ,-30850 ,-30876 ,-30871 ,-30847 ,-30821 ,-30814 , -30828 ,-30819 ,-30791 ,-30769 ,-30747 ,-30718 ,-30690 ,-30685 ,-30690 ,-30707 ,-30722 ,-30736 ,-30748 ,-30735 ,-30773 , -30803 ,-30753 ,-30717 ,-30703 ,-30692 ,-30680 ,-30666 ,-30651 ,-30626 ,-30622 ,-30619 ,-30597 ,-30584 ,-30582 ,-30555 , -30530 ,-30571 ,-30494 ,-30452 ,-30516 ,-30333 ,-30407 ,-30425 ,-30140 ,-30435 ,-30240 ,-30089 ,-30541 ,-29999 ,-30034 , -30461 ,-29611 ,-29982 ,-30877 ,-29803 ,-32767 ,-28526 ,637 ,27135 ,30927 ,31270 ,32621 ,32108 ,32767 ,32529 , 32145 ,32474 ,32106 ,31973 ,32034 ,31728 ,31686 ,31631 ,31468 ,31447 ,31340 ,31224 ,31186 ,30980 ,30525 , 30128 ,30026 ,29985 ,29652 ,29223 ,28999 ,28816 ,28629 ,28499 ,28360 ,28211 ,28074 ,27931 ,27789 ,27660 , 27471 ,27243 ,26968 ,26653 ,26482 ,26401 ,26334 ,26287 ,26175 ,26091 ,26002 ,25918 ,25914 ,25760 ,25720 , 25744 ,25409 ,25512 ,25542 ,25292 ,25851 ,25379 ,25384 ,26239 ,26165 ,26734 ,18051 ,-1132 ,-13195 ,-14502 , -15560 ,-20726 ,-24110 ,-24199 ,-24329 ,-24441 ,-24557 ,-24428 ,-24406 ,-24428 ,-24234 ,-24279 ,-24070 ,-23919 ,-23997 , -23822 ,-23796 ,-22809 ,-19973 ,-18063 ,-18196 ,-19467 ,-22455 ,-24913 ,-24802 ,-24717 ,-25257 ,-25228 ,-25294 ,-25436 , -25606 ,-24377 ,-24694 ,-24878 ,-24823 ,-24819 ,-24932 ,-24760 ,-25881 ,-28090 ,-28552 ,-28055 ,-28232 ,-28244 ,-28180 , -28271 ,-28252 ,-28266 ,-28186 ,-28200 ,-28108 ,-27986 ,-28201 ,-27861 ,-27775 ,-28105 ,-27215 ,-28153 ,-31697 ,-32767 , -31585 ,-30981 ,-31211 ,-31974 ,-30134 ,-25529 ,-24410 ,-24920 ,-23850 ,-27447 ,-31476 ,-30828 ,-30747 ,-30995 ,-30689 , -30780 ,-30720 ,-30646 ,-30609 ,-30575 ,-30494 ,-30458 ,-30402 ,-30327 ,-30315 ,-30267 ,-30218 ,-30180 ,-30139 ,-30109 , -30066 ,-30006 ,-29952 ,-29890 ,-29819 ,-29782 ,-29713 ,-29668 ,-29638 ,-29528 ,-29546 ,-29513 ,-29394 ,-29487 ,-29325 , -29200 ,-29369 ,-29078 ,-29285 ,-29140 ,-26105 ,-23420 ,-23801 ,-24009 ,-23483 ,-23725 ,-23724 ,-23482 ,-23459 ,-23200 , -23102 ,-23245 ,-23289 ,-23377 ,-23378 ,-23281 ,-23339 ,-23374 ,-23295 ,-23171 ,-23302 ,-24900 ,-27585 ,-28778 ,-28431 , -28442 ,-28618 ,-28479 ,-28498 ,-28496 ,-28383 ,-28380 ,-28312 ,-28224 ,-28213 ,-28159 ,-28116 ,-28076 ,-28008 ,-27977 , -27936 ,-27896 ,-27855 ,-27783 ,-27766 ,-27745 ,-27682 ,-27627 ,-27556 ,-27505 ,-27465 ,-27410 ,-27348 ,-27304 ,-27277 , -27202 ,-27137 ,-27107 ,-27072 ,-27046 ,-27017 ,-27033 ,-27012 ,-26950 ,-26982 ,-26892 ,-26878 ,-26966 ,-26770 ,-26894 , -26918 ,-26637 ,-26975 ,-26713 ,-26484 ,-27030 ,-26347 ,-26447 ,-27547 ,-26569 ,-28559 ,-28611 ,-8285 ,20389 ,31626 , 31502 ,32083 ,32604 ,32767 ,32708 ,32488 ,32569 ,32443 ,32272 ,32239 ,31848 ,31480 ,31356 ,30992 ,30740 , 30600 ,30254 ,30368 ,29852 ,27025 ,23900 ,22744 ,22634 ,22415 ,22163 ,21974 ,21778 ,21592 ,21399 ,21237 , 21070 ,20810 ,20555 ,20351 ,20195 ,20041 ,19911 ,19887 ,19818 ,19817 ,19835 ,19669 ,19706 ,19636 ,19391 , 19548 ,19363 ,19254 ,19636 ,19154 ,19472 ,20066 ,16629 ,12581 ,12511 ,13345 ,12505 ,12349 ,13351 ,12636 , 13466 ,9791 ,-4317 ,-13095 ,-13680 ,-14040 ,-14245 ,-14572 ,-14384 ,-14395 ,-14283 ,-14503 ,-14112 ,-11268 ,-10173 , -10870 ,-10276 ,-10097 ,-10216 ,-9731 ,-9702 ,-9580 ,-11599 ,-17389 ,-21143 ,-20539 ,-19928 ,-20535 ,-20049 ,-19055 , -19426 ,-18191 ,-15995 ,-19167 ,-21004 ,-26520 ,-32767 ,-31888 ,-31318 ,-32488 ,-31970 ,-31999 ,-32200 ,-31864 ,-31981 , -31987 ,-31776 ,-31863 ,-31795 ,-31678 ,-31725 ,-31623 ,-31577 ,-31631 ,-31502 ,-31503 ,-31525 ,-31325 ,-31426 ,-31362 , -31117 ,-31375 ,-31207 ,-31163 ,-31868 ,-29929 ,-25032 ,-23812 ,-24433 ,-23152 ,-27054 ,-31345 ,-30406 ,-30692 ,-30848 , -30477 ,-31590 ,-29165 ,-23117 ,-20007 ,-19904 ,-19328 ,-19069 ,-19044 ,-18633 ,-18666 ,-18449 ,-18020 ,-18051 ,-17601 , -17317 ,-17514 ,-16870 ,-16941 ,-17154 ,-16134 ,-16717 ,-16220 ,-14461 ,-21403 ,-31076 ,-30767 ,-29883 ,-31101 ,-30794 , -31306 ,-24493 ,-17976 ,-19195 ,-19193 ,-18738 ,-18064 ,-16806 ,-16665 ,-16909 ,-16914 ,-16817 ,-17447 ,-16912 ,-16560 , -17292 ,-15438 ,-16775 ,-24880 ,-28514 ,-26526 ,-27064 ,-27741 ,-26991 ,-27321 ,-27232 ,-26996 ,-27835 ,-28625 ,-28984 , -28964 ,-28817 ,-28900 ,-28878 ,-28794 ,-28818 ,-28789 ,-28770 ,-28761 ,-28722 ,-28713 ,-28695 ,-28690 ,-28696 ,-28681 , -28689 ,-28690 ,-28649 ,-28600 ,-28574 ,-28554 ,-28537 ,-28554 ,-28552 ,-28517 ,-28505 ,-28506 ,-28489 ,-28512 ,-28555 , -28533 ,-28523 ,-28488 ,-28442 ,-28457 ,-28349 ,-28338 ,-28345 ,-28128 ,-28240 ,-28213 ,-27999 ,-28328 ,-28009 ,-27818 , -28613 ,-28242 ,-29779 ,-31490 ,-17463 ,11496 ,30517 ,32157 ,31139 ,32581 ,32767 ,32497 ,32536 ,32432 ,32332 , 32129 ,32253 ,32043 ,31812 ,32199 ,31533 ,31632 ,32279 ,31078 ,32655 ,32217 ,22029 ,15040 ,17074 ,16983 , 15530 ,16321 ,15877 ,15517 ,15898 ,15484 ,15421 ,15437 ,15152 ,15110 ,14803 ,14464 ,14425 ,14243 ,14083 , 14076 ,13905 ,13807 ,13808 ,13535 ,13543 ,13536 ,13166 ,13587 ,13407 ,11637 ,10578 ,10516 ,10709 ,10526 , 10046 ,10577 ,10012 ,9535 ,11040 ,9752 ,10510 ,13012 ,2052 ,-11154 ,-10045 ,-8529 ,-10763 ,-10021 ,-10677 , -9386 ,-5133 ,-4994 ,-5844 ,-5118 ,-5137 ,-5301 ,-5248 ,-4913 ,-5298 ,-5399 ,-4726 ,-6510 ,-4487 ,3910 , 6705 ,5042 ,6178 ,6405 ,6886 ,7046 ,2420 ,-530 ,582 ,346 ,-245 ,-104 ,-369 ,-954 ,-809 , -41 ,-805 ,272 ,1019 ,-3338 ,-6096 ,-12843 ,-20089 ,-18499 ,-17500 ,-21717 ,-27834 ,-32511 ,-32748 ,-32074 , -32767 ,-32716 ,-32453 ,-32664 ,-32478 ,-32412 ,-32482 ,-32315 ,-32313 ,-32306 ,-32218 ,-32222 ,-32163 ,-32103 ,-32060 , -32004 ,-31962 ,-31886 ,-31878 ,-31808 ,-31747 ,-31798 ,-31609 ,-31595 ,-31634 ,-31358 ,-31556 ,-31430 ,-31137 ,-31638 , -31209 ,-31309 ,-32363 ,-29554 ,-24351 ,-21810 ,-21449 ,-22975 ,-20638 ,-10738 ,-10751 ,-20928 ,-22581 ,-21705 ,-23555 , -22941 ,-23059 ,-23753 ,-23198 ,-23658 ,-24021 ,-23526 ,-24203 ,-24138 ,-23507 ,-26744 ,-30659 ,-30475 ,-30075 ,-30396 , -30177 ,-30323 ,-27996 ,-25715 ,-26129 ,-26175 ,-26159 ,-26449 ,-26345 ,-26102 ,-26073 ,-26046 ,-26047 ,-26247 ,-26129 , -26183 ,-26233 ,-25619 ,-26137 ,-28667 ,-29950 ,-29255 ,-29348 ,-29623 ,-29315 ,-29394 ,-29385 ,-29240 ,-29294 ,-29243 , -29206 ,-29195 ,-29089 ,-29048 ,-29025 ,-28955 ,-28924 ,-28896 ,-28846 ,-28808 ,-28765 ,-28720 ,-28686 ,-28652 ,-28606 , -28583 ,-28598 ,-28550 ,-28483 ,-28474 ,-28383 ,-28322 ,-28306 ,-28195 ,-28237 ,-28181 ,-28042 ,-28208 ,-27991 ,-27882 , -28174 ,-27650 ,-27824 ,-28433 ,-28011 ,-30540 ,-29625 ,-10180 ,17923 ,31000 ,30453 ,30381 ,31655 ,31529 ,31414 , 31395 ,31339 ,31201 ,31054 ,31233 ,30812 ,30834 ,31110 ,30251 ,30917 ,31083 ,30086 ,32767 ,29445 ,15712 , 8989 ,10722 ,9546 ,8617 ,9376 ,8715 ,8835 ,9094 ,8521 ,8574 ,8473 ,8211 ,8316 ,8213 ,8155 , 8210 ,8107 ,8068 ,8077 ,7995 ,7926 ,7856 ,7708 ,7517 ,7279 ,7194 ,7199 ,7062 ,7082 ,7052 , 6898 ,7065 ,6903 ,6663 ,6814 ,6364 ,6350 ,6644 ,5936 ,6780 ,6643 ,1268 ,-2565 ,-1632 ,-1751 , -2566 ,-2060 ,-2171 ,-2410 ,-2130 ,-2340 ,-2567 ,-2363 ,-2845 ,-2468 ,1555 ,4051 ,2104 ,2818 ,3179 , 143 ,6309 ,17354 ,18128 ,16140 ,17734 ,17600 ,17340 ,17741 ,17563 ,17717 ,17526 ,17848 ,17750 ,17465 , 18822 ,16715 ,12358 ,11493 ,11481 ,12811 ,11685 ,1892 ,-4435 ,-2229 ,-2474 ,-3808 ,-2757 ,-3212 ,-3507 , -2918 ,-3510 ,-3413 ,-2904 ,-356 ,343 ,-1834 ,-9971 ,-15352 ,-14060 ,-14014 ,-18895 ,-26093 ,-31188 ,-31368 , -30614 ,-31356 ,-31234 ,-30984 ,-31274 ,-31060 ,-31018 ,-31102 ,-30923 ,-30931 ,-30912 ,-30834 ,-30833 ,-30763 ,-30710 , -30684 ,-30771 ,-30843 ,-30821 ,-30939 ,-30859 ,-30875 ,-30951 ,-30537 ,-30582 ,-30528 ,-30180 ,-30537 ,-30366 ,-30259 , -30594 ,-30250 ,-30350 ,-30453 ,-30059 ,-30434 ,-30615 ,-30200 ,-31706 ,-29080 ,-16186 ,-9273 ,-14714 ,-16911 ,-15628 , -16149 ,-15994 ,-15553 ,-15592 ,-15385 ,-14992 ,-15059 ,-14829 ,-14387 ,-14693 ,-14238 ,-13855 ,-14429 ,-13354 ,-13254 , -13699 ,-11351 ,-16786 ,-29666 ,-32767 ,-29988 ,-31602 ,-32084 ,-31311 ,-32094 ,-31805 ,-31602 ,-31962 ,-31659 ,-31720 , -31866 ,-31734 ,-31775 ,-31755 ,-31715 ,-31738 ,-31683 ,-31627 ,-31597 ,-31564 ,-31543 ,-31512 ,-31466 ,-31376 ,-31292 , -31249 ,-31188 ,-31119 ,-31053 ,-30976 ,-30896 ,-30814 ,-30734 ,-30679 ,-30640 ,-30596 ,-30547 ,-30454 ,-30336 ,-30269 , -30148 ,-29983 ,-29925 ,-29755 ,-29583 ,-29604 ,-29405 ,-29215 ,-29186 ,-28859 ,-28731 ,-28637 ,-28092 ,-28198 ,-28279 , -28399 ,-30653 ,-26553 ,-5388 ,19828 ,29047 ,27395 ,28134 ,29578 ,29027 ,29401 ,29742 ,29367 ,29861 ,29749 , 29473 ,30166 ,29631 ,29710 ,30481 ,29295 ,30275 ,30939 ,29286 ,32767 ,29193 ,11432 ,3724 ,7986 ,6750 , 5257 ,6540 ,5515 ,5654 ,6296 ,5674 ,6058 ,6211 ,5963 ,6226 ,6078 ,5958 ,6073 ,6064 ,6265 , 6449 ,6452 ,6465 ,6485 ,6503 ,6317 ,6016 ,5887 ,5751 ,5610 ,5541 ,5427 ,5378 ,5367 ,5291 , 5262 ,5250 ,5175 ,5111 ,4983 ,4760 ,4625 ,4429 ,4125 ,3967 ,3750 ,3554 ,3474 ,3146 ,3068 , 2929 ,2459 ,2677 ,2350 ,1880 ,2436 ,1479 ,1199 ,1648 ,-829 ,4379 ,19032 ,24504 ,21637 ,22676 , 23380 ,22134 ,22586 ,22234 ,21645 ,21982 ,21358 ,21307 ,21641 ,20954 ,21357 ,21336 ,20466 ,21535 ,21100 , 20998 ,23055 ,14638 ,121 ,-2296 ,252 ,-1628 ,-1761 ,-1163 ,-1927 ,-1433 ,-1422 ,-1763 ,-1257 ,-1493 , -1494 ,-1124 ,-1524 ,-1036 ,-501 ,2177 ,1334 ,-7551 ,-22420 ,-28156 ,-26097 ,-26512 ,-27066 ,-26227 ,-26417 , -26195 ,-25753 ,-25813 ,-25484 ,-25421 ,-25605 ,-25435 ,-25449 ,-25538 ,-25432 ,-25397 ,-25399 ,-25373 ,-25322 ,-25268 , -25274 ,-25371 ,-25565 ,-25670 ,-25783 ,-25908 ,-25839 ,-25962 ,-25910 ,-25630 ,-25786 ,-25485 ,-25479 ,-25845 ,-25342 , -26139 ,-25960 ,-25950 ,-27817 ,-23283 ,-18112 ,-16760 ,-18459 ,-27596 ,-31033 ,-27903 ,-27437 ,-19821 ,-7855 ,-4952 , -5801 ,-4945 ,-5823 ,-5994 ,-5754 ,-6733 ,-6556 ,-6783 ,-7573 ,-7164 ,-7846 ,-8433 ,-7586 ,-8896 ,-8522 , -6902 ,-14197 ,-23351 ,-25488 ,-28613 ,-31606 ,-30426 ,-30897 ,-31779 ,-31155 ,-31765 ,-32007 ,-31782 ,-32263 ,-32271 , -32325 ,-32617 ,-32527 ,-32603 ,-32738 ,-32714 ,-32731 ,-32716 ,-32750 ,-32767 ,-32752 ,-32747 ,-32626 ,-32507 ,-32436 , -32311 ,-32167 ,-32047 ,-31906 ,-31732 ,-31545 ,-31341 ,-31156 ,-30951 ,-30692 ,-30416 ,-30170 ,-29925 ,-29506 ,-29197 , -28912 ,-28256 ,-28040 ,-27744 ,-26974 ,-26948 ,-26256 ,-25690 ,-26122 ,-24617 ,-24486 ,-24920 ,-22326 ,-23824 ,-23720 , -20699 ,-27254 ,-18170 ,15120 ,27457 ,20725 ,24588 ,26878 ,24776 ,26955 ,26925 ,26581 ,27812 ,27663 ,27996 , 28431 ,28922 ,29091 ,29264 ,30495 ,29929 ,31337 ,32767 ,22911 ,12423 ,13236 ,14203 ,12496 ,13430 ,13806 , 13727 ,14447 ,14253 ,14332 ,14697 ,14481 ,14542 ,14583 ,14475 ,14561 ,14493 ,14429 ,14532 ,14633 ,14695 , 14654 ,14537 ,14409 ,14231 ,14004 ,13795 ,13585 ,13352 ,13126 ,12903 ,12652 ,12344 ,12049 ,11834 ,11637 , 11420 ,11169 ,10828 ,10428 ,10045 ,9616 ,9145 ,8655 ,8162 ,7813 ,7395 ,6870 ,6491 ,5980 ,5572 , 5228 ,4562 ,4382 ,3991 ,3241 ,3422 ,2641 ,1901 ,2419 ,200 ,941 ,10043 ,16126 ,15504 ,15948 , 16387 ,15497 ,15811 ,15738 ,15282 ,15535 ,14896 ,14347 ,14529 ,13785 ,13820 ,14221 ,13210 ,13889 ,14193 , 13165 ,15799 ,13006 ,674 ,-4338 ,-1465 ,-2433 ,-3387 ,-2389 ,-3032 ,-2897 ,-2419 ,-2895 ,-2410 ,-2188 , -2455 ,-1824 ,-1859 ,-1817 ,-688 ,-1149 ,996 ,-3713 ,-12607 ,-18334 ,-17212 ,-16437 ,-17112 ,-16295 ,-15822 , -15711 ,-15086 ,-14905 ,-14686 ,-14253 ,-14177 ,-14057 ,-13900 ,-13904 ,-13781 ,-13597 ,-13547 ,-13526 ,-13439 ,-13370 , -13324 ,-13346 ,-13504 ,-13582 ,-13649 ,-13819 ,-13825 ,-13832 ,-13854 ,-13808 ,-14028 ,-14115 ,-14191 ,-14686 ,-14765 , -15033 ,-15994 ,-15748 ,-16878 ,-16540 ,-8066 ,-2184 ,-1554 ,-3445 ,-12427 ,-15735 ,-13457 ,-16235 ,-13643 ,-5029 , -2529 ,-3594 ,-3518 ,-4351 ,-4849 ,-5149 ,-6075 ,-6412 ,-6880 ,-7694 ,-8047 ,-8706 ,-9419 ,-9471 ,-10223 , -10498 ,-11179 ,-17672 ,-25505 ,-26905 ,-26382 ,-27753 ,-28265 ,-28528 ,-29237 ,-29467 ,-29929 ,-30398 ,-30558 ,-30938 , -31266 ,-31528 ,-31850 ,-31972 ,-32110 ,-32378 ,-32482 ,-32478 ,-32554 ,-32692 ,-32767 ,-32726 ,-32680 ,-32586 ,-32383 , -32226 ,-32064 ,-31787 ,-31552 ,-31355 ,-31011 ,-30605 ,-30301 ,-29988 ,-29563 ,-29068 ,-28515 ,-28004 ,-27472 ,-26872 , -26348 ,-25682 ,-24918 ,-24150 ,-23291 ,-22660 ,-21760 ,-20731 ,-20276 ,-19270 ,-18361 ,-17823 ,-16187 ,-15860 ,-15476 , -13695 ,-15517 ,-11581 ,5358 ,16969 ,17454 ,18833 ,20303 ,20386 ,21911 ,22644 ,23162 ,24387 ,24875 ,25599 , 26633 ,27193 ,27925 ,28747 ,29375 ,30155 ,30938 ,31736 ,32767 ,32093 ,27895 ,23444 ,22538 ,23378 ,23550 , 23827 ,24389 ,24603 ,24865 ,25140 ,25193 ,25460 ,25815 ,25903 ,25899 ,25903 ,25825 ,25689 ,25606 ,25603 , 25555 ,25389 ,25200 ,25014 ,24623 ,23958 ,23371 ,23040 ,22677 ,22269 ,21897 ,21414 ,20953 ,20549 ,20041 , 19616 ,19332 ,18881 ,18174 ,17441 ,16775 ,16014 ,15175 ,14418 ,13728 ,12999 ,12235 ,11452 ,10642 ,9923 , 9137 ,8284 ,7727 ,7040 ,6206 ,5726 ,4918 ,4199 ,3963 ,2904 ,2245 ,2186 ,1398 ,3872 ,8975 , 9714 ,8215 ,8582 ,8372 ,7688 ,7558 ,7035 ,6540 ,6132 ,5729 ,5427 ,5296 ,5519 ,5133 ,5094 , 5754 ,5219 ,5536 ,5110 ,-490 ,-4720 ,-3532 ,-3233 ,-4061 ,-3472 ,-3430 ,-3504 ,-2963 ,-2947 ,-2675 , -2108 ,-2139 ,-1701 ,-1096 ,-1115 ,-32 ,6 ,-3071 ,-8018 ,-8722 ,-8223 ,-8193 ,-7663 ,-7226 ,-6814 , -6227 ,-5854 ,-5448 ,-5094 ,-4835 ,-4436 ,-4117 ,-3839 ,-3518 ,-3335 ,-3090 ,-2772 ,-2739 ,-2762 ,-2595 , -2549 ,-2624 ,-2703 ,-2901 ,-3059 ,-3076 ,-3146 ,-3350 ,-3412 ,-3288 ,-3399 ,-3618 ,-3699 ,-4122 ,-4469 , -4555 ,-5331 ,-5701 ,-6004 ,-6884 ,-4815 ,-1558 ,-1172 ,-1694 ,-2456 ,-3035 ,-2252 ,-2208 ,-2838 ,-2626 , -2920 ,-3768 ,-4254 ,-4993 ,-5801 ,-6507 ,-7418 ,-8118 ,-8792 ,-9711 ,-10536 ,-11322 ,-12170 ,-12876 ,-13595 , -14352 ,-15123 ,-17224 ,-20879 ,-23473 ,-24222 ,-24911 ,-25811 ,-26433 ,-27065 ,-27756 ,-28375 ,-28926 ,-29406 ,-29855 , -30313 ,-30802 ,-31215 ,-31455 ,-31702 ,-32046 ,-32242 ,-32295 ,-32427 ,-32611 ,-32765 ,-32767 ,-32676 ,-32614 ,-32419 , -32159 ,-31938 ,-31607 ,-31271 ,-31007 ,-30557 ,-30003 ,-29595 ,-29165 ,-28592 ,-27930 ,-27169 ,-26412 ,-25697 ,-24934 , -24124 ,-23231 ,-22309 ,-21356 ,-20262 ,-19231 ,-18132 ,-16820 ,-15734 ,-14637 ,-13393 ,-12253 ,-10930 ,-9923 ,-8950 , -7476 ,-6900 ,-4897 ,1536 ,7632 ,9827 ,10976 ,12197 ,13154 ,14402 ,15581 ,16708 ,17956 ,18953 ,19998 , 21232 ,22276 ,23226 ,24322 ,25373 ,26334 ,27450 ,28431 ,29100 ,29601 ,29223 ,28187 ,28212 ,29046 ,29476 , 30011 ,30704 ,31004 ,31371 ,31744 ,31807 ,32096 ,32570 ,32728 ,32718 ,32767 ,32713 ,32482 ,32325 ,32272 , 32163 ,32008 ,31720 ,31460 ,31317 ,30712 ,29875 ,29450 ,28962 ,28206 ,27587 ,26903 ,26033 ,25352 ,24739 , 23856 ,22992 ,22324 ,21456 ,20451 ,19728 ,18984 ,17841 ,16685 ,15792 ,14878 ,13841 ,12903 ,12089 ,11144 , 10045 ,9211 ,8629 ,7736 ,6770 ,6117 ,5234 ,4262 ,3809 ,3307 ,2346 ,1604 ,1688 ,2500 ,3048 , 2610 ,1984 ,1766 ,1490 ,1054 ,626 ,153 ,-255 ,-623 ,-1118 ,-1484 ,-1636 ,-1825 ,-2038 ,-2251 , -2306 ,-2047 ,-2230 ,-3434 ,-4640 ,-4855 ,-4609 ,-4504 ,-4372 ,-4271 ,-4240 ,-4038 ,-3720 ,-3467 ,-3382 , -3093 ,-2540 ,-2371 ,-1980 ,-1299 ,-1332 ,-671 ,83 ,-2832 ,-4834 ,-4178 ,-3623 ,-3854 ,-3514 ,-3082 , -2717 ,-2342 ,-2008 ,-1575 ,-1445 ,-1342 ,-881 ,-634 ,-485 ,-106 ,95 ,174 ,383 ,435 ,388 , 527 ,572 ,434 ,332 ,103 ,-118 ,-36 ,-99 ,-440 ,-544 ,-573 ,-946 ,-1463 ,-1759 ,-1986 , -2450 ,-2728 ,-2901 ,-3623 ,-4111 ,-4079 ,-4550 ,-5180 ,-5403 ,-5628 ,-6680 ,-7011 ,-5942 ,-5978 ,-5174 , -4212 ,-5538 ,-6026 ,-6052 ,-7067 ,-7919 ,-8472 ,-9363 ,-10409 ,-10705 ,-11152 ,-12464 ,-13388 ,-13773 ,-14698 , -15682 ,-15825 ,-16359 ,-18276 ,-20002 ,-20735 ,-21690 ,-22632 ,-22893 ,-23607 ,-24802 ,-25466 ,-26220 ,-27316 ,-27854 , -28077 ,-28738 ,-29649 ,-30164 ,-30240 ,-30640 ,-31357 ,-31636 ,-31807 ,-32221 ,-32410 ,-32521 ,-32707 ,-32737 ,-32767 , -32707 ,-32477 ,-32394 ,-32327 ,-32009 ,-31660 ,-31379 ,-30822 ,-30145 ,-29977 ,-29718 ,-28596 ,-27655 ,-27176 ,-26067 , -25001 ,-24726 ,-24071 ,-22526 ,-21134 ,-20683 ,-20036 ,-18083 ,-16479 ,-15696 ,-13838 ,-12061 ,-11740 ,-10596 ,-8388 , -7102 ,-5953 ,-3827 ,-2017 ,-687 ,1894 ,4685 ,5721 ,6922 ,9244 ,10384 ,10694 ,12288 ,14518 ,15522 , 15650 ,17048 ,19199 ,20039 ,21070 ,23125 ,23868 ,23953 ,25364 ,26646 ,26966 ,27790 ,28779 ,28866 ,29048 , 30004 ,30830 ,31225 ,31763 ,32247 ,32155 ,32057 ,32471 ,32767 ,32655 ,32581 ,32488 ,32141 ,31790 ,31537 , 31281 ,31156 ,30931 ,30315 ,29833 ,29429 ,28394 ,27516 ,27461 ,26911 ,25679 ,25042 ,24368 ,22927 ,22157 , 22225 ,21331 ,19836 ,19326 ,18668 ,17046 ,16452 ,16550 ,15092 ,13463 ,13059 ,12008 ,10468 ,10204 ,10078 , 8713 ,7232 ,7042 ,7245 ,6115 ,4865 ,4697 ,3768 ,2444 ,2776 ,3062 ,1893 ,1216 ,1234 ,415 , -418 ,-302 ,-448 ,-1161 ,-1380 ,-1455 ,-2015 ,-2343 ,-2234 ,-2363 ,-2754 ,-2935 ,-2882 ,-2925 ,-3184 , -3420 ,-3293 ,-3023 ,-2913 ,-2689 ,-2373 ,-2210 ,-2085 ,-1939 ,-1819 ,-1921 ,-2223 ,-2152 ,-1870 ,-2058 , -2162 ,-1700 ,-1554 ,-1724 ,-1366 ,-1018 ,-1083 ,-866 ,-651 ,-2122 ,-2307 ,-2205 ,-2120 ,-2306 ,-2771 , -2912 ,-3020 ,-3569 ,-3789 ,-3809 ,-4353 ,-4830 ,-4863 ,-5072 ,-5428 ,-5545 ,-5698 ,-6038 ,-6248 ,-6394 , -6600 ,-6652 ,-6864 ,-6944 ,-7020 ,-7237 ,-7236 ,-7738 ,-6343 ,-3938 ,-4042 ,-4399 ,-4895 ,-5883 ,-6046 , -6319 ,-6818 ,-7069 ,-7304 ,-7902 ,-8524 ,-8814 ,-9056 ,-9350 ,-9604 ,-9570 ,-10118 ,-10370 ,-10110 ,-10635 , -8589 ,-6397 ,-7471 ,-7634 ,-7201 ,-7858 ,-8614 ,-8837 ,-9028 ,-9866 ,-10069 ,-9974 ,-10967 ,-11828 ,-11829 , -12271 ,-12920 ,-12996 ,-13465 ,-14383 ,-14928 ,-15514 ,-16374 ,-17117 ,-17796 ,-18480 ,-19135 ,-20008 ,-21120 ,-22080 , -22836 ,-23549 ,-24132 ,-24835 ,-25681 ,-26183 ,-26757 ,-27777 ,-28504 ,-28881 ,-29489 ,-30084 ,-30455 ,-30954 ,-31532 , -31845 ,-31956 ,-32154 ,-32444 ,-32656 ,-32751 ,-32767 ,-32729 ,-32528 ,-32209 ,-32134 ,-32023 ,-31427 ,-30901 ,-30508 , -29721 ,-28936 ,-28379 ,-27720 ,-26798 ,-25676 ,-24930 ,-24344 ,-22845 ,-21090 ,-20192 ,-19121 ,-17335 ,-16193 ,-15325 , -13290 ,-11293 ,-10308 ,-8930 ,-7025 ,-5479 ,-4144 ,-2744 ,-831 ,1429 ,3154 ,4900 ,6846 ,7984 ,9266 , 11413 ,12906 ,14095 ,16284 ,18009 ,18579 ,19877 ,21763 ,22757 ,23836 ,25578 ,26591 ,27059 ,27990 ,29011 , 29686 ,30053 ,30562 ,31412 ,31825 ,32000 ,32606 ,32767 ,32395 ,32472 ,32556 ,32181 ,31936 ,31809 ,31398 , 30921 ,30488 ,29860 ,29175 ,28548 ,27844 ,27156 ,26382 ,25369 ,24525 ,23811 ,22667 ,21440 ,20651 ,19929 , 18970 ,17967 ,17178 ,16430 ,15295 ,14269 ,13761 ,12895 ,11750 ,11356 ,10997 ,9823 ,8921 ,8468 ,7285 , 6316 ,6678 ,6625 ,5507 ,5084 ,5037 ,4091 ,3641 ,4311 ,4170 ,3358 ,3459 ,3640 ,3244 ,3391 , 4004 ,4105 ,3880 ,4096 ,4613 ,4576 ,4264 ,4626 ,5097 ,5101 ,5581 ,6447 ,6534 ,6247 ,6371 , 6394 ,6238 ,6605 ,7090 ,6887 ,6534 ,6580 ,6614 ,6642 ,6826 ,6864 ,6858 ,6949 ,6790 ,6481 , 6372 ,6153 ,5741 ,5514 ,5194 ,4519 ,4043 ,3777 ,3145 ,2435 ,1484 ,944 ,-139 ,-855 ,-929 , -1833 ,-3628 ,-5353 ,-7109 ,-8998 ,-10687 ,-12106 ,-13564 ,-15130 ,-16640 ,-18022 ,-19269 ,-20370 ,-21493 ,-22603 , -23660 ,-24653 ,-25286 ,-26198 ,-26520 ,-26912 ,-27327 ,-27163 ,-28928 ,-24761 ,-17035 ,-16932 ,-17529 ,-16783 ,-17392 , -16411 ,-14795 ,-14303 ,-14252 ,-13976 ,-13886 ,-13863 ,-13536 ,-13047 ,-12864 ,-12641 ,-12050 ,-11773 ,-11631 ,-11166 , -10882 ,-10658 ,-9906 ,-9286 ,-9247 ,-8911 ,-8271 ,-8197 ,-8065 ,-7172 ,-6644 ,-6797 ,-6572 ,-6214 ,-6279 , -6226 ,-5842 ,-5636 ,-5955 ,-6284 ,-6126 ,-6268 ,-6847 ,-6889 ,-7105 ,-8162 ,-8687 ,-8711 ,-9575 ,-10660 , -11286 ,-12197 ,-13274 ,-13915 ,-14595 ,-15740 ,-16826 ,-17598 ,-18688 ,-19991 ,-20817 ,-21716 ,-22994 ,-23859 ,-24638 , -25854 ,-26810 ,-27485 ,-28319 ,-29039 ,-29679 ,-30419 ,-30982 ,-31357 ,-31798 ,-32188 ,-32325 ,-32449 ,-32712 ,-32767 , -32559 ,-32484 ,-32269 ,-31513 ,-30870 ,-30551 ,-29832 ,-28918 ,-28333 ,-27462 ,-26021 ,-24881 ,-23976 ,-22355 ,-20655 , -19663 ,-18242 ,-16098 ,-14517 ,-13157 ,-10961 ,-8830 ,-7589 ,-6035 ,-3587 ,-1322 ,652 ,2943 ,5046 ,6525 , 8214 ,10575 ,12549 ,13830 ,15682 ,17777 ,18923 ,20265 ,22357 ,23649 ,24476 ,26057 ,27493 ,28223 ,29082 , 30104 ,30695 ,30972 ,31482 ,32152 ,32361 ,32365 ,32729 ,32767 ,32220 ,31944 ,31731 ,31031 ,30427 ,30029 , 29258 ,28377 ,27666 ,26652 ,25443 ,24425 ,23357 ,22191 ,21042 ,19716 ,18384 ,17234 ,15866 ,14332 ,13027 , 11717 ,10266 ,9104 ,8208 ,6994 ,5665 ,4755 ,3881 ,2833 ,2063 ,1536 ,808 ,26 ,-248 ,-221 , -583 ,-1114 ,-1128 ,-932 ,-1047 ,-905 ,-376 ,-249 ,-90 ,715 ,1315 ,1615 ,2459 ,3487 ,4181 , 5018 ,6057 ,6756 ,7430 ,8690 ,9889 ,10425 ,11037 ,12149 ,13231 ,14114 ,15062 ,15932 ,16492 ,17040 , 17795 ,18552 ,19203 ,19876 ,20550 ,20821 ,20695 ,20759 ,20929 ,20809 ,20613 ,20407 ,20078 ,19729 ,19220 , 18451 ,17614 ,16672 ,15640 ,14714 ,13622 ,12234 ,10972 ,9637 ,7929 ,6366 ,5561 ,3909 ,2262 ,400 , -1074 ,-1529 ,-3131 ,-5810 ,-7673 ,-9753 ,-12289 ,-13995 ,-15242 ,-17124 ,-19170 ,-20723 ,-22304 ,-23871 ,-25026 , -26150 ,-27567 ,-28892 ,-29787 ,-30489 ,-31275 ,-31831 ,-32007 ,-32334 ,-32612 ,-32767 ,-32458 ,-32270 ,-32324 ,-31144 , -31401 ,-29636 ,-24918 ,-24907 ,-25420 ,-24166 ,-23921 ,-23184 ,-22609 ,-21993 ,-21113 ,-20192 ,-18985 ,-17914 ,-16925 , -15841 ,-14769 ,-13820 ,-12652 ,-11195 ,-10066 ,-9147 ,-7886 ,-6703 ,-5863 ,-4751 ,-3433 ,-2599 ,-2070 ,-1307 , -570 ,-151 ,274 ,751 ,964 ,1061 ,1239 ,1174 ,894 ,850 ,736 ,156 ,-425 ,-840 ,-1559 , -2566 ,-3570 ,-4585 ,-5578 ,-6609 ,-7905 ,-9331 ,-10598 ,-11821 ,-13240 ,-14646 ,-15894 ,-17323 ,-18868 ,-20114 , -21218 ,-22529 ,-23928 ,-25158 ,-26207 ,-27202 ,-28217 ,-29154 ,-29914 ,-30588 ,-31213 ,-31725 ,-32155 ,-32488 ,-32619 , -32604 ,-32538 ,-32372 ,-32068 ,-31660 ,-31105 ,-30365 ,-29533 ,-28600 ,-27562 ,-26434 ,-25018 ,-23486 ,-22076 ,-20441 , -18563 ,-16809 ,-14984 ,-12925 ,-10949 ,-8930 ,-6565 ,-4235 ,-2237 ,-107 ,2332 ,4577 ,6662 ,8936 ,11094 , 12941 ,14896 ,16949 ,18615 ,20131 ,21869 ,23402 ,24624 ,26031 ,27478 ,28512 ,29311 ,30156 ,30964 ,31552 , 31974 ,32481 ,32767 ,32588 ,32601 ,32754 ,32307 ,31678 ,31284 ,30510 ,29457 ,28708 ,27887 ,26786 ,25762 , 24608 ,23126 ,21693 ,20385 ,18950 ,17489 ,16012 ,14375 ,12750 ,11150 ,9460 ,7775 ,6051 ,4406 ,3147 , 1993 ,601 ,-721 ,-1750 ,-2636 ,-3470 ,-4281 ,-5029 ,-5665 ,-6125 ,-6320 ,-6389 ,-6472 ,-6553 ,-6435 , -5954 ,-5475 ,-5133 ,-4580 ,-3867 ,-3040 ,-1899 ,-675 ,388 ,1469 ,2783 ,4291 ,5784 ,7233 ,8710 , 10215 ,11878 ,13560 ,14865 ,16058 ,17530 ,18976 ,20211 ,21360 ,22457 ,23582 ,24613 ,25607 ,26851 ,27898 , 28521 ,29313 ,29954 ,29868 ,29841 ,30089 ,29881 ,29499 ,29138 ,28437 ,27694 ,26889 ,25665 ,24428 ,23233 , 21684 ,20106 ,18651 ,17135 ,15726 ,14113 ,12147 ,10250 ,8250 ,5925 ,3934 ,2334 ,944 ,-598 ,-1967 , -5388 ,-7061 ,-6336 ,-8328 ,-11228 ,-11851 ,-13290 ,-16192 ,-16892 ,-16510 ,-18350 ,-20317 ,-20756 ,-22094 ,-24001 , -24173 ,-24105 ,-25283 ,-26052 ,-26204 ,-26839 ,-27397 ,-27575 ,-27746 ,-27741 ,-27683 ,-27711 ,-27123 ,-26771 ,-26746 , -25333 ,-24874 ,-24667 ,-24373 ,-26778 ,-27196 ,-26042 ,-26285 ,-25362 ,-23980 ,-22724 ,-21536 ,-20505 ,-18859 ,-17200 , -16076 ,-14802 ,-13069 ,-11674 ,-10463 ,-8694 ,-7168 ,-6359 ,-5267 ,-3768 ,-2646 ,-1729 ,-543 ,409 ,848 , 1409 ,2161 ,2644 ,2956 ,3282 ,3448 ,3446 ,3353 ,3000 ,2598 ,2477 ,2089 ,1293 ,777 ,83 , -1311 ,-2253 ,-2654 ,-4021 ,-5767 ,-6700 ,-8205 ,-10385 ,-11297 ,-11968 ,-14049 ,-15917 ,-16919 ,-18654 ,-20611 , -21466 ,-22331 ,-24065 ,-25496 ,-26399 ,-27720 ,-28955 ,-29513 ,-30183 ,-31141 ,-31772 ,-32109 ,-32444 ,-32682 ,-32767 , -32709 ,-32329 ,-31914 ,-31832 ,-31383 ,-30302 ,-29509 ,-28659 ,-26927 ,-25534 ,-24994 ,-23510 ,-21133 ,-19634 ,-17943 , -14981 ,-13245 ,-12671 ,-10037 ,-6886 ,-5415 ,-2828 ,783 ,2337 ,3339 ,6168 ,9409 ,10922 ,11704 ,14313 , 17292 ,18526 ,20438 ,23141 ,23818 ,24280 ,26480 ,28112 ,28748 ,30034 ,31170 ,31377 ,31710 ,32333 ,32709 , 32767 ,32559 ,32473 ,32609 ,32359 ,31456 ,30600 ,30359 ,29754 ,28176 ,27001 ,26213 ,24426 ,22926 ,22691 , 21432 ,18974 ,17644 ,16471 ,14024 ,12543 ,12323 ,10622 ,8226 ,7196 ,5771 ,3352 ,2461 ,2373 ,706 , -994 ,-1446 ,-2363 ,-3617 ,-3811 ,-3860 ,-4581 ,-5085 ,-5083 ,-5067 ,-5120 ,-5101 ,-4861 ,-4118 ,-3227 , -3029 ,-2847 ,-1686 ,-682 ,-114 ,1670 ,3411 ,3139 ,3568 ,6011 ,7102 ,7350 ,9754 ,11562 ,10973 , 12068 ,14786 ,15589 ,16527 ,19085 ,20082 ,19736 ,20782 ,22605 ,23202 ,22711 ,23228 ,24748 ,25159 ,25340 , 26404 ,26462 ,25809 ,26079 ,26136 ,25762 ,25550 ,24375 ,23228 ,23156 ,22134 ,20704 ,20083 ,18279 ,16187 , 16018 ,15704 ,13437 ,11007 ,10517 ,10328 ,7793 ,5459 ,4853 ,2484 ,-259 ,-135 ,-378 ,-2372 ,-3441 , -4028 ,-5794 ,-6798 ,-6482 ,-7386 ,-9132 ,-9630 ,-10216 ,-11835 ,-12495 ,-12393 ,-13409 ,-14682 ,-15175 ,-15913 , -16932 ,-17330 ,-17561 ,-18148 ,-18690 ,-19162 ,-19713 ,-20183 ,-20679 ,-21087 ,-21062 ,-21056 ,-21458 ,-21551 ,-21228 , -21502 ,-21686 ,-20916 ,-20521 ,-20470 ,-19843 ,-18989 ,-19427 ,-21356 ,-21506 ,-19771 ,-18748 ,-18688 ,-18507 ,-16800 , -15109 ,-15062 ,-14507 ,-12670 ,-11486 ,-10740 ,-8906 ,-7486 ,-7413 ,-6660 ,-5227 ,-4482 ,-3754 ,-2687 ,-2051 , -1586 ,-879 ,-371 ,-66 ,321 ,590 ,681 ,751 ,613 ,241 ,88 ,-43 ,-633 ,-1018 ,-1180 , -2242 ,-3557 ,-4057 ,-4602 ,-5858 ,-7335 ,-8641 ,-9917 ,-11237 ,-12204 ,-13127 ,-14801 ,-16719 ,-18195 ,-19598 , -20955 ,-21998 ,-23150 ,-24647 ,-26033 ,-27141 ,-28208 ,-29156 ,-29896 ,-30605 ,-31372 ,-32070 ,-32493 ,-32682 ,-32767 , -32738 ,-32591 ,-32246 ,-31773 ,-31588 ,-31328 ,-30181 ,-28893 ,-28032 ,-26449 ,-24577 ,-23725 ,-22705 ,-20583 ,-18349 , -16413 ,-14662 ,-12972 ,-10910 ,-8615 ,-6228 ,-3467 ,-943 ,936 ,3089 ,5487 ,7537 ,10150 ,12904 ,14139 , 15425 ,18188 ,20344 ,21647 ,23773 ,25601 ,26169 ,27195 ,28936 ,29982 ,30677 ,31642 ,32170 ,32237 ,32484 , 32767 ,32739 ,32488 ,32201 ,31922 ,31516 ,30710 ,29559 ,28699 ,28144 ,27016 ,25468 ,24401 ,23203 ,21303 , 20008 ,19363 ,17705 ,15741 ,14677 ,13037 ,10907 ,10068 ,9484 ,7885 ,6126 ,5005 ,4391 ,3425 ,2235 , 1601 ,726 ,-354 ,-637 ,-1011 ,-1583 ,-1480 ,-1542 ,-1789 ,-1445 ,-1160 ,-1057 ,-703 ,-437 ,-59 , 844 ,1567 ,1957 ,2921 ,3835 ,3841 ,4486 ,6118 ,6876 ,7475 ,9199 ,10099 ,9821 ,10796 ,12454 , 12864 ,13418 ,14987 ,15421 ,14897 ,15812 ,17175 ,17232 ,17594 ,18645 ,18411 ,17784 ,18404 ,18752 ,18211 , 18341 ,18652 ,17946 ,17290 ,17210 ,16764 ,16159 ,15926 ,15524 ,14996 ,14723 ,13972 ,12909 ,12677 ,12201 , 10512 ,9396 ,8918 ,7363 ,5971 ,6102 ,5421 ,3289 ,2463 ,1844 ,76 ,-992 ,-1490 ,-1598 ,-2156 , -3188 ,-3135 ,-3007 ,-3896 ,-4306 ,-4315 ,-5064 ,-5598 ,-5330 ,-5607 ,-6435 ,-6813 ,-7149 ,-7881 ,-8400 , -8569 ,-8994 ,-9760 ,-10398 ,-10918 ,-11610 ,-12343 ,-12974 ,-13643 ,-14397 ,-15093 ,-15566 ,-15842 ,-16369 ,-17116 , -17355 ,-17388 ,-17858 ,-18032 ,-17858 ,-18284 ,-18744 ,-18390 ,-18172 ,-18428 ,-17749 ,-17169 ,-17406 ,-17195 ,-17383 , -17226 ,-16523 ,-16034 ,-14668 ,-14119 ,-14521 ,-13581 ,-12240 ,-11737 ,-11153 ,-10055 ,-9370 ,-8972 ,-7986 ,-7019 , -6616 ,-5980 ,-5080 ,-4638 ,-4336 ,-3814 ,-3406 ,-3067 ,-2704 ,-2634 ,-2699 ,-2540 ,-2713 ,-3262 ,-3037 , -2751 ,-3688 ,-4449 ,-4681 ,-5759 ,-6829 ,-7363 ,-8514 ,-9690 ,-10263 ,-11362 ,-13047 ,-14313 ,-15412 ,-17035 , -18516 ,-19407 ,-20774 ,-22593 ,-23716 ,-24671 ,-26049 ,-27056 ,-27834 ,-29026 ,-30109 ,-30767 ,-31414 ,-32093 ,-32558 , -32767 ,-32763 ,-32661 ,-32579 ,-32338 ,-31916 ,-31585 ,-30965 ,-29710 ,-28517 ,-27613 ,-26340 ,-24702 ,-23323 ,-21922 , -19596 ,-17265 ,-16164 ,-14557 ,-11536 ,-9252 ,-7518 ,-4485 ,-1658 ,-157 ,2067 ,5124 ,7235 ,9297 ,12258 , 14366 ,15534 ,17722 ,20281 ,21754 ,23364 ,25564 ,26775 ,27436 ,28857 ,30173 ,30828 ,31604 ,32322 ,32505 , 32596 ,32767 ,32715 ,32451 ,32042 ,31579 ,31213 ,30529 ,29360 ,28372 ,27524 ,26207 ,24796 ,23853 ,22878 , 21198 ,19436 ,18497 ,17470 ,15626 ,14225 ,13190 ,11355 ,9853 ,9430 ,8514 ,6845 ,5826 ,5234 ,4026 , 3061 ,2963 ,2449 ,1543 ,1363 ,1284 ,930 ,1043 ,1205 ,1137 ,1506 ,2036 ,2318 ,2683 ,3128 , 3581 ,4332 ,5238 ,5731 ,6005 ,6765 ,7641 ,8161 ,8981 ,10006 ,10345 ,10500 ,11302 ,12145 ,12521 , 13174 ,13969 ,13782 ,13533 ,14282 ,14549 ,14230 ,14753 ,15036 ,14339 ,14113 ,14446 ,14328 ,13754 ,13332 , 13132 ,12801 ,12621 ,12533 ,11851 ,11165 ,10846 ,10070 ,9239 ,8704 ,7832 ,7163 ,6981 ,6314 ,5329 , 4798 ,4095 ,2939 ,2561 ,2713 ,1926 ,1037 ,841 ,140 ,-783 ,-709 ,-616 ,-1523 ,-2116 ,-2011 , -2214 ,-2491 ,-2019 ,-1652 ,-1844 ,-1890 ,-1788 ,-1990 ,-2086 ,-2049 ,-2271 ,-2439 ,-2530 ,-2933 ,-3339 , -3402 ,-3360 ,-3446 ,-3817 ,-4477 ,-5084 ,-5612 ,-6313 ,-7010 ,-7540 ,-8055 ,-8703 ,-9473 ,-10078 ,-10529 , -11083 ,-11602 ,-12223 ,-12978 ,-13311 ,-13554 ,-14204 ,-14622 ,-14735 ,-15080 ,-15300 ,-15213 ,-15325 ,-15568 ,-15462 , -15237 ,-15253 ,-15098 ,-14734 ,-14577 ,-14722 ,-15130 ,-15287 ,-14845 ,-14435 ,-14367 ,-14324 ,-13750 ,-12438 ,-11425 , -10843 ,-10271 ,-9819 ,-9084 ,-8318 ,-7804 ,-7284 ,-6764 ,-6275 ,-5854 ,-5552 ,-5313 ,-5117 ,-5133 ,-5230 , -4997 ,-4845 ,-5284 ,-5708 ,-5953 ,-6655 ,-7511 ,-7999 ,-8650 ,-9759 ,-10738 ,-11573 ,-12848 ,-14205 ,-15161 , -16391 ,-18010 ,-19278 ,-20512 ,-22074 ,-23273 ,-24115 ,-25241 ,-26503 ,-27581 ,-28640 ,-29713 ,-30529 ,-31150 ,-31862 , -32445 ,-32649 ,-32720 ,-32767 ,-32696 ,-32537 ,-32212 ,-31667 ,-30967 ,-29942 ,-28742 ,-27846 ,-26739 ,-24921 ,-23252 , -21835 ,-19711 ,-17393 ,-15680 ,-13653 ,-11025 ,-8859 ,-6828 ,-4027 ,-1206 ,1069 ,3508 ,6106 ,8259 ,10435 , 13008 ,15254 ,17053 ,19036 ,21126 ,22908 ,24503 ,26107 ,27538 ,28670 ,29677 ,30671 ,31500 ,32055 ,32489 , 32767 ,32726 ,32641 ,32536 ,32050 ,31458 ,31062 ,30467 ,29514 ,28473 ,27395 ,26259 ,25027 ,23698 ,22540 , 21459 ,19987 ,18366 ,17127 ,15923 ,14479 ,13240 ,12113 ,10709 ,9446 ,8699 ,7908 ,6824 ,6014 ,5330 , 4436 ,3957 ,3798 ,3404 ,3256 ,3319 ,3260 ,3494 ,3740 ,3761 ,4115 ,4693 ,5193 ,5769 ,6301 , 6769 ,7460 ,8167 ,8661 ,9264 ,9956 ,10473 ,11086 ,11783 ,12243 ,12700 ,13092 ,13133 ,13369 ,13856 , 13964 ,14061 ,14275 ,13989 ,13619 ,13553 ,13241 ,12718 ,12357 ,11918 ,11354 ,10815 ,10100 ,9342 ,8749 , 7938 ,6892 ,6174 ,5550 ,4542 ,3660 ,3174 ,2615 ,1929 ,1309 ,746 ,227 ,-306 ,-753 ,-1023 , -1386 ,-1862 ,-2202 ,-2521 ,-2871 ,-2966 ,-2975 ,-3196 ,-3338 ,-3230 ,-3018 ,-2871 ,-2790 ,-2591 ,-2322 , -2369 ,-3189 ,-3551 ,-3417 ,-3453 ,-3626 ,-3689 ,-3753 ,-3672 ,-3448 ,-3427 ,-3485 ,-3265 ,-3116 ,-3133 , -2900 ,-2730 ,-2744 ,-2526 ,-2327 ,-2235 ,-2123 ,-2403 ,-2819 ,-2843 ,-2827 ,-2951 ,-3105 ,-3296 ,-3364 , -3546 ,-3769 ,-3760 ,-4595 ,-5891 ,-5904 ,-6070 ,-7294 ,-7721 ,-8193 ,-9549 ,-9623 ,-9096 ,-10111 ,-11293 , -11602 ,-12336 ,-13486 ,-13821 ,-13937 ,-14839 ,-15500 ,-15886 ,-16775 ,-17383 ,-17546 ,-17468 ,-17848 ,-18002 ,-16204 , -14832 ,-14683 ,-14240 ,-13886 ,-13248 ,-12487 ,-12098 ,-11520 ,-10737 ,-10231 ,-9857 ,-9249 ,-8785 ,-8682 ,-8520 , -8066 ,-7727 ,-7870 ,-7944 ,-7675 ,-7768 ,-8219 ,-8548 ,-8900 ,-9391 ,-10083 ,-10907 ,-11570 ,-12470 ,-13687 , -14438 ,-15158 ,-16578 ,-17916 ,-18939 ,-20324 ,-21597 ,-22420 ,-23756 ,-25589 ,-26805 ,-27673 ,-28988 ,-30075 ,-30502 , -31092 ,-31946 ,-32386 ,-32481 ,-32632 ,-32767 ,-32691 ,-32467 ,-32109 ,-31534 ,-30920 ,-30204 ,-29085 ,-27846 ,-26608 , -24973 ,-23438 ,-22359 ,-20485 ,-17888 ,-16027 ,-13941 ,-10863 ,-8872 ,-7741 ,-4870 ,-1455 ,478 ,2644 ,5469 , 7086 ,8304 ,11021 ,14225 ,15743 ,16552 ,19112 ,21909 ,23087 ,24938 ,27468 ,28072 ,28356 ,30089 ,31235 , 31508 ,32284 ,32767 ,32606 ,32558 ,32365 ,32083 ,31876 ,31143 ,30328 ,30061 ,29435 ,27973 ,26688 ,26132 , 25316 ,23605 ,22181 ,21275 ,19392 ,17200 ,16318 ,15400 ,13591 ,12510 ,11777 ,10316 ,9529 ,9497 ,8664 , 7645 ,7324 ,6889 ,6233 ,6082 ,6206 ,6089 ,6036 ,6306 ,6599 ,6875 ,7222 ,7560 ,8109 ,8902 , 9413 ,9735 ,10499 ,11194 ,11376 ,12126 ,13214 ,13168 ,13110 ,14206 ,14527 ,13753 ,13892 ,14409 ,14243 , 14331 ,14662 ,14657 ,14714 ,14683 ,14462 ,14480 ,14201 ,13506 ,13174 ,12652 ,11609 ,11119 ,11051 ,10474 , 9575 ,8998 ,8835 ,8307 ,7230 ,6604 ,6093 ,4940 ,4321 ,4285 ,3379 ,2462 ,2231 ,1424 ,661 , 628 ,-108 ,-1579 ,-1865 ,-789 ,-311 ,-444 ,-305 ,-560 ,-1037 ,-1076 ,-1013 ,-1147 ,-1421 ,-1560 , -1465 ,-1611 ,-2682 ,-2433 ,-2383 ,-2650 ,-2804 ,-2980 ,-3182 ,-3147 ,-2894 ,-3053 ,-3558 ,-3630 ,-3851 , -4303 ,-4477 ,-4994 ,-4915 ,-4342 ,-4887 ,-4570 ,-4435 ,-7947 ,-10804 ,-10147 ,-10027 ,-10975 ,-11305 ,-11276 , -11170 ,-11706 ,-12211 ,-12055 ,-12883 ,-13735 ,-13011 ,-12909 ,-13989 ,-14186 ,-14038 ,-14656 ,-14901 ,-14741 ,-15274 , -15941 ,-16242 ,-16540 ,-16937 ,-17483 ,-18152 ,-18150 ,-17851 ,-19210 ,-20676 ,-20628 ,-20535 ,-20542 ,-20326 ,-19997 , -20029 ,-19716 ,-18533 ,-18573 ,-19156 ,-18337 ,-17983 ,-18748 ,-18351 ,-17121 ,-16613 ,-16109 ,-15307 ,-14862 ,-14651 , -14236 ,-13486 ,-12912 ,-12777 ,-12372 ,-11630 ,-11182 ,-10988 ,-10868 ,-10695 ,-10394 ,-10554 ,-11124 ,-11214 ,-11476 , -12455 ,-12604 ,-12250 ,-13280 ,-14528 ,-14942 ,-16076 ,-17508 ,-18091 ,-19422 ,-21644 ,-22807 ,-23844 ,-26265 ,-28160 , -28401 ,-28787 ,-30010 ,-31028 ,-31437 ,-31742 ,-32297 ,-32733 ,-32767 ,-32669 ,-32607 ,-32643 ,-32367 ,-31354 ,-30529 , -30038 ,-28654 ,-27223 ,-26776 ,-25611 ,-23394 ,-21675 ,-19577 ,-16429 ,-14230 ,-13042 ,-10879 ,-7960 ,-5440 ,-3058 , -392 ,2080 ,3485 ,4348 ,6201 ,8468 ,10053 ,12008 ,14667 ,17076 ,19440 ,21888 ,23655 ,24830 ,26202 , 27871 ,29401 ,30482 ,31241 ,31898 ,32178 ,32197 ,32536 ,32767 ,32368 ,31949 ,31923 ,31678 ,30731 ,29730 , 29436 ,29007 ,27364 ,25806 ,25471 ,24318 ,21939 ,21072 ,20518 ,17571 ,14819 ,13992 ,13032 ,12055 ,11857 , 11577 ,11149 ,10683 ,10130 ,9914 ,9771 ,9603 ,9855 ,10050 ,10002 ,10332 ,10855 ,11286 ,11775 ,12183 , 12790 ,13654 ,14173 ,14889 ,15990 ,16603 ,17058 ,17581 ,17910 ,18170 ,18260 ,18582 ,18916 ,18894 ,19476 , 19119 ,16389 ,14798 ,15513 ,15620 ,15209 ,15323 ,15235 ,14959 ,14679 ,14226 ,13730 ,13132 ,12485 ,11931 , 11435 ,11065 ,10695 ,10355 ,10376 ,10329 ,9680 ,9114 ,8950 ,8300 ,7538 ,7711 ,7722 ,6723 ,6092 , 6036 ,5514 ,5036 ,5047 ,5102 ,4508 ,2353 ,127 ,-412 ,-606 ,-1106 ,-1323 ,-1701 ,-2303 ,-2552 , -2773 ,-3274 ,-3676 ,-5384 ,-5720 ,-5965 ,-7088 ,-7646 ,-7861 ,-8533 ,-7638 ,-7436 ,-7597 ,-4997 ,-7841 , -16288 ,-17625 ,-15478 ,-16931 ,-16535 ,-15154 ,-15995 ,-15896 ,-15264 ,-15535 ,-15568 ,-15281 ,-14792 ,-14677 ,-14981 , -14390 ,-13570 ,-13616 ,-13521 ,-13445 ,-14447 ,-15388 ,-15681 ,-16485 ,-17306 ,-17451 ,-17965 ,-18536 ,-18579 ,-19026 , -19225 ,-19083 ,-19552 ,-19516 ,-21109 ,-26588 ,-30117 ,-29013 ,-28627 ,-29501 ,-28885 ,-28445 ,-28705 ,-28764 ,-28868 , -28355 ,-28045 ,-26192 ,-22982 ,-22981 ,-23097 ,-22384 ,-25008 ,-27849 ,-27860 ,-27571 ,-27249 ,-26180 ,-25938 ,-25368 , -24117 ,-23767 ,-23114 ,-22264 ,-21831 ,-20914 ,-19882 ,-18956 ,-18021 ,-17219 ,-16354 ,-15606 ,-15038 ,-14399 ,-13948 , -13569 ,-13134 ,-13295 ,-13330 ,-12534 ,-12376 ,-12784 ,-12681 ,-12876 ,-13545 ,-14640 ,-16303 ,-17541 ,-19558 ,-23265 , -25975 ,-27138 ,-27736 ,-27773 ,-28845 ,-30505 ,-30863 ,-31482 ,-32668 ,-32665 ,-32368 ,-32673 ,-32767 ,-32493 ,-32143 , -31751 ,-31368 ,-30855 ,-29674 ,-28139 ,-27235 ,-26116 ,-23773 ,-21283 ,-18986 ,-15855 ,-12668 ,-11275 ,-9662 ,-5211 , -2224 ,-2896 ,-1562 ,1127 ,858 ,1712 ,5461 ,8084 ,9877 ,12503 ,15216 ,17609 ,20054 ,22887 ,25076 , 26062 ,27376 ,28978 ,29739 ,30557 ,31698 ,32056 ,32136 ,32560 ,32767 ,32726 ,32392 ,31945 ,32046 ,31850 , 30901 ,30332 ,29853 ,28597 ,27390 ,27352 ,27024 ,23839 ,19857 ,18036 ,16169 ,13786 ,13410 ,13559 ,12797 , 12720 ,13150 ,13219 ,13393 ,13721 ,13934 ,14088 ,14474 ,15152 ,15707 ,16208 ,16921 ,17792 ,18834 ,19703 , 20468 ,21619 ,22647 ,23678 ,25061 ,25743 ,25825 ,25917 ,26166 ,26773 ,26478 ,26538 ,27680 ,24614 ,19116 , 18303 ,18678 ,16684 ,15935 ,16094 ,15495 ,15305 ,15092 ,14614 ,14381 ,13743 ,12957 ,12406 ,11419 ,10472 , 10499 ,10877 ,10864 ,10808 ,10893 ,10968 ,11104 ,11167 ,11363 ,11532 ,10982 ,10871 ,11265 ,10775 ,11051 , 11543 ,10774 ,11853 ,11428 ,5408 ,2165 ,3811 ,3170 ,2053 ,2744 ,2376 ,1642 ,1293 ,706 ,205 , -281 ,-817 ,-1215 ,-1450 ,763 ,44 ,-355 ,-1279 ,-2323 ,-2847 ,-3472 ,-4167 ,-4779 ,-5672 ,-6375 , -6808 ,-7755 ,-8675 ,-9224 ,-9421 ,-8454 ,-7623 ,-7234 ,-6888 ,-11075 ,-18005 ,-19305 ,-17390 ,-17258 ,-16706 , -15980 ,-15899 ,-15141 ,-14596 ,-14220 ,-13401 ,-12899 ,-12303 ,-11516 ,-10879 ,-10055 ,-9400 ,-8640 ,-7784 ,-8119 , -9012 ,-9370 ,-9837 ,-10625 ,-11318 ,-11843 ,-12317 ,-12883 ,-13436 ,-13835 ,-14172 ,-14515 ,-14563 ,-15142 ,-19422 , -26797 ,-30979 ,-30925 ,-31227 ,-32020 ,-31882 ,-32166 ,-32767 ,-32618 ,-31807 ,-30400 ,-29127 ,-28271 ,-26834 ,-25301 , -24051 ,-22551 ,-20824 ,-19525 ,-19800 ,-19781 ,-18146 ,-16977 ,-16461 ,-15035 ,-13840 ,-14334 ,-14233 ,-13364 ,-12773 , -11772 ,-10851 ,-10206 ,-9710 ,-8782 ,-8330 ,-8548 ,-6798 ,-5820 ,-6466 ,-4444 ,-6683 ,-16103 ,-19906 ,-18017 , -19182 ,-20567 ,-20526 ,-20970 ,-20964 ,-21438 ,-22202 ,-22255 ,-22742 ,-23051 ,-22738 ,-22705 ,-22637 ,-22494 ,-22167 , -21385 ,-21008 ,-20916 ,-20228 ,-19258 ,-18402 ,-16831 ,-14162 ,-12227 ,-10879 ,-7978 ,-5336 ,-3719 ,-1479 ,432 , 3684 ,6784 ,3168 ,-1387 ,350 ,2637 ,4228 ,7415 ,9158 ,10879 ,13885 ,15537 ,17256 ,19976 ,21912 , 23319 ,24526 ,25086 ,25259 ,25570 ,26226 ,26651 ,26609 ,26663 ,26737 ,26660 ,26646 ,26341 ,25965 ,26139 , 25931 ,25137 ,24858 ,24499 ,23608 ,23208 ,23438 ,22637 ,18227 ,11649 ,8349 ,8882 ,9785 ,10467 ,11108 , 11621 ,12698 ,13542 ,13953 ,15095 ,16227 ,16751 ,17564 ,18610 ,19433 ,20301 ,21432 ,22547 ,23616 ,24951 , 26091 ,27147 ,28669 ,29700 ,30735 ,32287 ,32460 ,32230 ,32400 ,31887 ,32286 ,32094 ,31265 ,32767 ,29117 , 19283 ,16076 ,17773 ,16415 ,15583 ,15732 ,14789 ,14486 ,14056 ,13268 ,12961 ,12180 ,11324 ,10618 ,9607 , 9272 ,9679 ,10127 ,10821 ,11501 ,11697 ,12051 ,12846 ,13214 ,13587 ,14614 ,14933 ,14946 ,15642 ,15761 , 16388 ,17410 ,17158 ,18616 ,18300 ,10668 ,5417 ,7457 ,8120 ,7513 ,8609 ,8071 ,6834 ,6429 ,5516 , 4828 ,4309 ,3437 ,2738 ,2104 ,1060 ,-233 ,-1908 ,-2740 ,-3861 ,-5499 ,-5772 ,-5802 ,-7306 ,-8234 , -8650 ,-10279 ,-11207 ,-11257 ,-11423 ,-10666 ,-10138 ,-9249 ,-7131 ,-9752 ,-17276 ,-20578 ,-19102 ,-18581 ,-18253 , -16707 ,-16141 ,-16331 ,-15439 ,-13863 ,-13251 ,-13669 ,-12925 ,-11360 ,-11031 ,-10154 ,-8345 ,-7939 ,-7874 ,-7238 , -6860 ,-6699 ,-7428 ,-8355 ,-8360 ,-8833 ,-9694 ,-9880 ,-9877 ,-10493 ,-11567 ,-11601 ,-11941 ,-13252 ,-12479 , -14659 ,-23865 ,-29884 ,-29508 ,-30291 ,-31643 ,-31375 ,-31823 ,-32613 ,-32767 ,-32078 ,-30305 ,-29445 ,-29434 ,-27576 , -25359 ,-24482 ,-22785 ,-20742 ,-20146 ,-19307 ,-17573 ,-15714 ,-14168 ,-14167 ,-12479 ,-10525 ,-13315 ,-14715 ,-13276 , -12331 ,-11093 ,-10604 ,-9846 ,-8495 ,-7307 ,-6213 ,-5853 ,-4366 ,-2218 ,-2525 ,-3219 ,-5041 ,-11491 ,-15942 , -15020 ,-15092 ,-16089 ,-15870 ,-16076 ,-15960 ,-15653 ,-15979 ,-15955 ,-16044 ,-16303 ,-16089 ,-16017 ,-16020 ,-15837 , -15634 ,-15325 ,-15115 ,-14992 ,-14827 ,-14203 ,-12871 ,-11869 ,-10686 ,-8439 ,-6699 ,-5192 ,-2772 ,-566 ,1226 , 2639 ,3271 ,2785 ,31 ,-2172 ,-587 ,1207 ,1960 ,4567 ,7013 ,7425 ,8596 ,11288 ,13250 ,14407 , 16150 ,17425 ,17406 ,17548 ,17943 ,18016 ,18236 ,18311 ,18134 ,18199 ,18278 ,18377 ,18564 ,18524 ,18595 , 18660 ,18339 ,18303 ,18232 ,17897 ,18087 ,17954 ,17956 ,17642 ,12414 ,5178 ,3358 ,4448 ,5078 ,6609 , 7667 ,8625 ,10846 ,11687 ,11753 ,13558 ,15211 ,15747 ,17024 ,18900 ,19626 ,20093 ,22107 ,23863 ,24620 , 26559 ,28398 ,28700 ,29631 ,31548 ,32758 ,32767 ,32627 ,32637 ,31793 ,31535 ,31520 ,30009 ,30904 ,30640 , 21539 ,13501 ,13738 ,13426 ,11731 ,12106 ,11513 ,10589 ,10568 ,9800 ,9036 ,8873 ,8790 ,8280 ,6816 , 6115 ,7333 ,8462 ,8634 ,8938 ,9802 ,10994 ,11464 ,11267 ,12070 ,13078 ,13487 ,14343 ,14844 ,15140 , 15768 ,16089 ,17825 ,18246 ,13047 ,8055 ,6870 ,5945 ,6394 ,8275 ,8521 ,7989 ,7555 ,7141 ,6688 , 5344 ,4462 ,4109 ,2495 ,1286 ,1115 ,492 ,-190 ,-1337 ,-2804 ,-3872 ,-5155 ,-6824 ,-8442 ,-9860 , -10813 ,-11246 ,-11751 ,-12339 ,-12490 ,-12837 ,-13535 ,-13316 ,-12340 ,-11583 ,-11041 ,-9745 ,-6981 ,-6809 ,-11849 , -15515 ,-15231 ,-15293 ,-14922 ,-13879 ,-13997 ,-13413 ,-12953 ,-13610 ,-12872 ,-12300 ,-13167 ,-12601 ,-11646 ,-11906 , -11154 ,-9983 ,-9525 ,-8565 ,-8334 ,-8467 ,-7551 ,-8122 ,-9141 ,-8117 ,-7253 ,-7041 ,-7464 ,-8623 ,-8954 , -9572 ,-9573 ,-10083 ,-17043 ,-24250 ,-24962 ,-26572 ,-29424 ,-28807 ,-28824 ,-30420 ,-31344 ,-32572 ,-32767 ,-30785 , -28776 ,-27597 ,-25873 ,-23721 ,-23018 ,-22233 ,-19737 ,-18659 ,-18258 ,-15308 ,-13146 ,-13340 ,-12498 ,-11259 ,-11492 , -11170 ,-9545 ,-9011 ,-9956 ,-10455 ,-9029 ,-7238 ,-7014 ,-6086 ,-3737 ,-1123 ,-1802 ,-9063 ,-14868 ,-14818 , -15010 ,-15599 ,-14895 ,-14602 ,-14553 ,-14280 ,-13787 ,-13206 ,-13054 ,-12752 ,-12208 ,-11998 ,-11781 ,-11672 ,-11643 , -11202 ,-10998 ,-11175 ,-11058 ,-11080 ,-11390 ,-10623 ,-9014 ,-8957 ,-9085 ,-6416 ,-4272 ,-4530 ,-2696 ,458 , 1784 ,3440 ,4022 ,804 ,-1807 ,-636 ,1551 ,2699 ,3958 ,6520 ,8552 ,8409 ,9001 ,11805 ,13561 , 14180 ,15586 ,15764 ,14587 ,14481 ,14527 ,14108 ,14180 ,13854 ,13371 ,13558 ,13325 ,13017 ,13460 ,14169 , 14962 ,15128 ,15088 ,15620 ,15357 ,15370 ,16389 ,16453 ,17024 ,15782 ,8482 ,2660 ,3227 ,4276 ,4857 , 5890 ,6134 ,7886 ,9832 ,9196 ,9352 ,11661 ,13104 ,13028 ,13750 ,15999 ,17217 ,17846 ,20657 ,22917 , 23118 ,25181 ,27942 ,28353 ,29604 ,32319 ,32767 ,32024 ,32228 ,31851 ,31301 ,30977 ,29385 ,29210 ,29894 , 24620 ,16785 ,14122 ,13014 ,11154 ,11433 ,11319 ,9933 ,10074 ,10506 ,10009 ,10002 ,10511 ,10545 ,10539 , 10589 ,9734 ,9945 ,12134 ,12665 ,12079 ,13245 ,14126 ,13682 ,13446 ,13361 ,12989 ,13008 ,13808 ,13547 , 12287 ,13006 ,14116 ,13863 ,14366 ,13021 ,7852 ,4321 ,4470 ,5183 ,6203 ,7746 ,8193 ,7828 ,7523 , 6315 ,4980 ,5285 ,5168 ,3243 ,1609 ,823 ,-146 ,-2126 ,-3478 ,-3692 ,-6051 ,-9984 ,-11618 ,-12677 , -14780 ,-15073 ,-14125 ,-15475 ,-17401 ,-15924 ,-14217 ,-15516 ,-15006 ,-12374 ,-11651 ,-9922 ,-8046 ,-10429 ,-11993 , -10143 ,-10137 ,-11284 ,-10314 ,-9942 ,-11638 ,-11534 ,-9835 ,-11317 ,-13433 ,-12671 ,-13570 ,-15457 ,-13817 ,-12708 , -14134 ,-14184 ,-13306 ,-12329 ,-10222 ,-9253 ,-9321 ,-7459 ,-5858 ,-6437 ,-6196 ,-4770 ,-3842 ,-3584 ,-5296 , -7189 ,-5579 ,-5727 ,-12376 ,-17983 ,-18925 ,-21269 ,-25176 ,-26856 ,-27162 ,-27695 ,-29260 ,-31697 ,-32767 ,-31925 , -30361 ,-28330 ,-26407 ,-24717 ,-23013 ,-21747 ,-19834 ,-17823 ,-17788 ,-16742 ,-13433 ,-11867 ,-11341 ,-10491 ,-11648 , -12683 ,-11492 ,-11248 ,-12542 ,-13298 ,-14613 ,-15340 ,-14187 ,-14888 ,-14024 ,-10737 ,-11460 ,-11434 ,-10080 ,-14427 , -19207 ,-19188 ,-18254 ,-17561 ,-16393 ,-16220 ,-15708 ,-13442 ,-11861 ,-11314 ,-10176 ,-9098 ,-8585 ,-8433 ,-8559 , -8183 ,-7462 ,-7322 ,-7279 ,-7317 ,-8359 ,-8967 ,-8187 ,-8483 ,-9704 ,-8893 ,-6977 ,-6380 ,-6496 ,-5486 , -2689 ,296 ,2541 ,5422 ,6918 ,4393 ,2667 ,5549 ,8769 ,9967 ,11227 ,12148 ,12239 ,13528 ,15679 , 16640 ,16904 ,16906 ,15662 ,14050 ,13434 ,13217 ,12870 ,12344 ,11218 ,10603 ,11025 ,10288 ,9250 ,10748 , 13076 ,14094 ,14494 ,15013 ,15631 ,15757 ,16499 ,18417 ,18369 ,15877 ,12447 ,7786 ,5265 ,6758 ,7599 , 6427 ,5866 ,6454 ,7531 ,7846 ,7136 ,7556 ,9678 ,10754 ,10061 ,10811 ,13262 ,14575 ,16130 ,19424 , 21691 ,23111 ,25653 ,27646 ,29294 ,31866 ,32767 ,31870 ,31815 ,31990 ,31802 ,31518 ,30122 ,28814 ,28541 , 26559 ,22494 ,18292 ,14015 ,11672 ,12224 ,11725 ,10411 ,11181 ,11801 ,11544 ,12541 ,14197 ,14934 ,14846 , 16018 ,17565 ,16900 ,17281 ,19019 ,18348 ,18051 ,18867 ,18157 ,17507 ,16104 ,13785 ,13533 ,13408 ,12101 , 11103 ,10292 ,10607 ,10569 ,8646 ,8966 ,10423 ,7334 ,2810 ,2151 ,4085 ,6437 ,8281 ,8591 ,7846 , 6874 ,6005 ,6277 ,6479 ,4325 ,1916 ,1030 ,-87 ,-3195 ,-5674 ,-5077 ,-6596 ,-12944 ,-16202 ,-16179 , -18629 ,-20359 ,-18807 ,-19055 ,-21712 ,-20528 ,-16598 ,-16964 ,-18278 ,-14667 ,-12093 ,-12552 ,-8648 ,-3751 ,-4707 , -5865 ,-5175 ,-6902 ,-7200 ,-6054 ,-8934 ,-9986 ,-6811 ,-8881 ,-13749 ,-13253 ,-13310 ,-16577 ,-15952 ,-14219 , -16544 ,-17845 ,-16843 ,-16127 ,-13354 ,-10907 ,-10879 ,-7636 ,-4003 ,-5402 ,-5474 ,-2357 ,-685 ,191 ,-975 , -3995 ,-3076 ,-1992 ,-7733 ,-13844 ,-14484 ,-15798 ,-21016 ,-24717 ,-24993 ,-25512 ,-27637 ,-30494 ,-32767 ,-32594 , -30588 ,-28292 ,-25905 ,-23915 ,-22164 ,-20642 ,-19327 ,-17262 ,-16306 ,-16355 ,-13463 ,-10046 ,-9727 ,-10220 ,-11122 , -12835 ,-13789 ,-14371 ,-14956 ,-16300 ,-19392 ,-20792 ,-20443 ,-21786 ,-22735 ,-23087 ,-23978 ,-25639 ,-23824 ,-17369 , -17363 ,-20323 ,-20494 ,-21235 ,-19791 ,-19122 ,-19072 ,-15561 ,-12058 ,-10539 ,-9100 ,-7309 ,-5864 ,-5140 ,-5928 , -6250 ,-4767 ,-4228 ,-4532 ,-4369 ,-5657 ,-7739 ,-7839 ,-8030 ,-10270 ,-10689 ,-8949 ,-9406 ,-10150 ,-8657 , -7202 ,-4373 ,-192 ,1815 ,4993 ,9479 ,8795 ,7525 ,11805 ,15389 ,15408 ,15569 ,15728 ,16073 ,17598 , 18424 ,18335 ,17801 ,15670 ,13166 ,11770 ,10774 ,10440 ,10151 ,8253 ,6540 ,6759 ,6474 ,4640 ,4984 , 8793 ,11667 ,12248 ,13253 ,14184 ,14492 ,15728 ,17761 ,19644 ,18764 ,14043 ,9848 ,8143 ,8232 ,9802 , 8555 ,4524 ,4003 ,5674 ,5047 ,3737 ,3627 ,4669 ,5930 ,5758 ,5719 ,7722 ,9396 ,10656 ,14348 , 18092 ,19996 ,23089 ,25952 ,27169 ,30285 ,32767 ,31276 ,30125 ,30548 ,30818 ,31236 ,29526 ,26838 ,26782 , 24853 ,20203 ,18683 ,16240 ,10589 ,9783 ,11307 ,9212 ,9114 ,11454 ,11468 ,12003 ,14962 ,17091 ,17488 , 19412 ,22365 ,21918 ,21957 ,25009 ,24146 ,21935 ,23241 ,22890 ,21259 ,19763 ,15543 ,12384 ,12153 ,11217 , 8693 ,6080 ,6101 ,6612 ,3746 ,2261 ,3524 ,1978 ,-712 ,-1436 ,-1047 ,1751 ,5552 ,6825 ,6845 , 6513 ,4578 ,3933 ,5714 ,4536 ,1266 ,-850 ,-3179 ,-3017 ,-2194 ,-11373 ,-17463 ,-19906 ,-24668 ,-28173 , -31351 ,-32767 ,-30615 ,-31190 ,-28817 ,-20487 ,-20385 ,-25789 ,-22731 ,-14766 ,-11785 ,-13269 ,-8785 ,2219 ,6843 , 4214 ,1978 ,1930 ,3961 ,3552 ,663 ,1083 ,-2349 ,-11175 ,-10767 ,-6040 ,-10541 ,-15124 ,-15887 ,-20004 , -22114 ,-22246 ,-23037 ,-17292 ,-11645 ,-10039 ,-3261 ,1130 ,-220 ,2859 ,6354 ,7786 ,9490 ,6697 ,3815 , 5036 ,3791 ,-161 ,-3099 ,-6344 ,-10739 ,-14692 ,-19059 ,-23880 ,-23308 ,-20184 ,-24649 ,-30992 ,-31999 ,-32048 , -28699 ,-22138 ,-19439 ,-16114 ,-11636 ,-13276 ,-14581 ,-11433 ,-11452 ,-11527 ,-6492 ,-3450 ,-4417 ,-5778 ,-9275 , -12748 ,-13023 ,-14656 ,-18168 ,-19893 ,-21555 ,-23568 ,-23744 ,-24108 ,-25160 ,-24498 ,-23292 ,-20270 ,-15736 ,-12549 , -11590 ,-9784 ,-2085 ,-5812 ,-18006 ,-16427 ,-15227 ,-15815 ,-10312 ,-7801 ,-7195 ,-5434 ,-3197 ,-2052 ,-3004 , -4018 ,-3276 ,-2295 ,-3528 ,-3263 ,-1310 ,-3299 ,-4889 ,-3157 ,-4884 ,-7784 ,-5737 ,-3866 ,-4891 ,-5018 , -5710 ,-5714 ,-2401 ,-1846 ,-3111 ,717 ,3510 ,1759 ,2739 ,5110 ,6695 ,10469 ,12763 ,15071 ,20728 , 21388 ,18273 ,20407 ,23298 ,22320 ,20506 ,18932 ,17678 ,16948 ,16300 ,15532 ,14521 ,12467 ,8239 ,5082 , 6384 ,8580 ,9556 ,10097 ,8515 ,6978 ,8624 ,10510 ,11052 ,11837 ,12568 ,12909 ,12588 ,11887 ,13669 , 16258 ,14218 ,10437 ,10237 ,10599 ,8962 ,7286 ,5460 ,5364 ,8831 ,8543 ,2234 ,-192 ,1887 ,1802 , 2147 ,3491 ,3363 ,6017 ,8516 ,6254 ,7849 ,12585 ,11298 ,12545 ,21218 ,24332 ,21719 ,23854 ,28409 , 30779 ,31503 ,29348 ,25971 ,24093 ,23190 ,24073 ,24252 ,20591 ,18180 ,18348 ,16822 ,15538 ,15230 ,13523 , 12698 ,13616 ,12722 ,10609 ,13256 ,18144 ,16478 ,14793 ,21357 ,26514 ,27204 ,30900 ,32767 ,29015 ,27709 , 29156 ,27746 ,26124 ,25580 ,24001 ,23692 ,21003 ,12528 ,7999 ,7384 ,1893 ,-1313 ,1053 ,-716 ,-5619 , -7158 ,-5716 ,-4009 ,-4788 ,-6609 ,-4368 ,971 ,3782 ,4369 ,6765 ,-4075 ,-6395 ,-4285 ,-4474 ,-3661 , -5272 ,-9556 ,-12845 ,-30608 ,-30479 ,-13560 ,-17555 ,-15189 ,-8368 ,-10702 ,-8152 ,-10201 ,-13278 ,-9253 ,-9907 , -11865 ,-9672 ,-12388 ,-17709 ,-18959 ,-19860 ,-21957 ,-23101 ,-23953 ,-25712 ,-28300 ,-29141 ,-23684 ,-15933 ,-15040 , -15457 ,-10173 ,-7261 ,-7126 ,-5663 ,-10287 ,-16538 ,-15805 ,-17078 ,-21543 ,-22622 ,-23636 ,-23805 ,-22180 ,-24350 , -28954 ,-30979 ,-30144 ,-30246 ,-32647 ,-32767 ,-30975 ,-30795 ,-30806 ,-31044 ,-29268 ,-22663 ,-17365 ,-13686 ,-6822 , -1686 ,-122 ,2889 ,8407 ,12097 ,8411 ,737 ,-2949 ,-2967 ,-3815 ,-7724 ,-10892 ,-9789 ,-12065 ,-19157 , -21115 ,-20711 ,-23803 ,-24432 ,-22510 ,-22936 ,-22653 ,-19721 ,-16716 ,-13122 ,-9214 ,-6598 ,-1572 ,5197 ,5809 , 3267 ,6203 ,11298 ,12857 ,11610 ,9933 ,10331 ,10620 ,5852 ,-355 ,-2474 ,-4518 ,-8605 ,-10705 ,-13028 , -15326 ,-14716 ,-15627 ,-18222 ,-20029 ,-17098 ,-10821 ,-9399 ,-7540 ,-3899 ,-4626 ,-3487 ,1049 ,2127 ,2007 , 1857 ,-2380 ,-5239 ,-6663 ,-13729 ,-17503 ,-15338 ,-19517 ,-23962 ,-22520 ,-24517 ,-24135 ,-19681 ,-22537 ,-21238 , -11929 ,-12453 ,-15562 ,-9907 ,-5156 ,-2708 ,-324 ,-838 ,-876 ,326 ,942 ,2703 ,3381 ,-189 ,-5271 , -7952 ,-9452 ,-11734 ,-12035 ,-12636 ,-18526 ,-22859 ,-21244 ,-21335 ,-23641 ,-23011 ,-20433 ,-16429 ,-12736 ,-11809 , -9069 ,-4961 ,-4107 ,-1628 ,2611 ,1932 ,629 ,2557 ,2185 ,1561 ,5479 ,6275 ,32 ,-3268 ,-1238 , -1685 ,-3769 ,-4460 ,-6068 ,-6249 ,-5327 ,-8284 ,-9543 ,-5713 ,-6278 ,-6590 ,1215 ,4069 ,7690 ,15908 , 10008 ,4538 ,8428 ,8445 ,9714 ,12007 ,12493 ,15001 ,17700 ,17636 ,15916 ,15484 ,15452 ,14741 ,14658 , 13939 ,13211 ,14476 ,13017 ,9820 ,11575 ,12405 ,8985 ,8959 ,13524 ,17670 ,17121 ,18212 ,25221 ,25282 , 25535 ,32767 ,18401 ,-7460 ,-8723 ,-2082 ,-3496 ,-4502 ,-9103 ,-12405 ,-11219 ,-14444 ,-15939 ,-13849 ,-15417 , -17687 ,-19950 ,-21518 ,-18877 ,-17657 ,-19845 ,-19300 ,-16872 ,-16295 ,-16204 ,-16137 ,-13003 ,-10430 ,-5765 ,-4710 , -2330 ,199 ,-665 ,524 ,-4895 ,-17436 ,-23599 ,-23834 ,-22219 ,-20798 ,-20643 ,-19811 ,-19166 ,-22237 ,-26086 , -24948 ,-22611 ,-23813 ,-26048 ,-26422 ,-25271 ,-24740 ,-24996 ,-25028 ,-23666 ,-20263 ,-19544 ,-19568 ,-12869 ,-7031 , -5436 ,-1361 ,1287 ,5191 ,9184 ,-2473 ,-16209 ,-13611 ,-11157 ,-14991 ,-15255 ,-15677 ,-17044 ,-16376 ,-17514 , -19465 ,-20152 ,-20887 ,-21096 ,-19777 ,-18403 ,-19763 ,-16619 ,-8751 ,-5652 ,-4326 ,-3572 ,1846 ,12079 ,14251 , 14244 ,15944 ,12653 ,12629 ,17725 ,16963 ,14217 ,14086 ,8956 ,3652 ,3409 ,-3754 ,-17112 ,-22370 ,-22755 , -28274 ,-32767 ,-28422 ,-24062 ,-27493 ,-30049 ,-27700 ,-25558 ,-22898 ,-19822 ,-16253 ,-11157 ,-8835 ,-4334 ,5846 , 9563 ,7605 ,8779 ,7869 ,6233 ,9971 ,10858 ,5606 ,3477 ,3361 ,-1872 ,-4753 ,-1106 ,-4863 ,-16042 , -19589 ,-18132 ,-18153 ,-16841 ,-15520 ,-11653 ,-3974 ,-1607 ,-2136 ,2158 ,5776 ,7550 ,12086 ,15647 ,16000 , 16003 ,14897 ,13300 ,13571 ,10298 ,3716 ,5289 ,8735 ,1232 ,-5413 ,-4279 ,-3830 ,-3713 ,-6997 ,-17378 , -22067 ,-17397 ,-18461 ,-21914 ,-18305 ,-15871 ,-13528 ,-9316 ,-7829 ,-5579 ,-1726 ,376 ,720 ,1693 ,2876 , 1713 ,-1148 ,-3657 ,-4440 ,-4155 ,-6431 ,-10923 ,-13398 ,-15207 ,-17466 ,-16496 ,-15176 ,-16118 ,-14391 ,-13662 , -15985 ,-12076 ,-7190 ,-6689 ,1215 ,11251 ,11868 ,12460 ,16550 ,18868 ,21003 ,22143 ,22435 ,23336 ,22409 , 23049 ,24166 ,17568 ,9898 ,8391 ,6491 ,3677 ,2170 ,-2 ,298 ,373 ,-2038 ,-544 ,1849 ,7870 , 13828 ,6700 ,2297 ,4808 ,6066 ,12736 ,17482 ,17024 ,18366 ,21174 ,23886 ,24118 ,23612 ,25076 ,24641 , 23387 ,24607 ,25965 ,27338 ,25037 ,18040 ,15300 ,14688 ,11634 ,11371 ,14075 ,17227 ,16874 ,15808 ,21719 , 24189 ,25134 ,32767 ,21983 ,-746 ,-546 ,6069 ,3304 ,4487 ,4431 ,1941 ,4060 ,4848 ,2865 ,1033 , 1447 ,2401 ,-209 ,733 ,1094 ,-10605 ,-18848 ,-15609 ,-14587 ,-14291 ,-11458 ,-11139 ,-4248 ,-723 ,1043 , 3010 ,5969 ,8154 ,9881 ,11168 ,10916 ,8444 ,4629 ,2651 ,3299 ,2231 ,-871 ,-582 ,1921 ,-835 , -4550 ,-3325 ,-3243 ,-2198 ,-2674 ,-589 ,2496 ,-17937 ,-32767 ,-24701 ,-24465 ,-23815 ,-19516 ,-20532 ,-17601 , -13511 ,-13000 ,-11338 ,-10223 ,-10373 ,-9435 ,-12564 ,-17353 ,-16090 ,-13468 ,-13720 ,-14001 ,-13619 ,-12580 ,-11485 , -11520 ,-11099 ,-9250 ,-6378 ,-3982 ,-3327 ,-493 ,2631 ,-4794 ,-20623 ,-30009 ,-30432 ,-30165 ,-29775 ,-28223 , -27050 ,-25027 ,-24996 ,-28222 ,-29019 ,-27464 ,-27232 ,-27475 ,-27402 ,-26551 ,-25140 ,-24442 ,-22480 ,-19472 ,-18747 , -18471 ,-15411 ,-11217 ,-9216 ,-7248 ,-3089 ,-2034 ,-1040 ,2437 ,-7761 ,-26818 ,-29854 ,-24456 ,-25255 ,-25290 , -24539 ,-25443 ,-24025 ,-22692 ,-22208 ,-20856 ,-20818 ,-20822 ,-19625 ,-19429 ,-18392 ,-15442 ,-13873 ,-12518 ,-8930 , -6262 ,-5484 ,-3291 ,121 ,2016 ,2487 ,3659 ,5336 ,6259 ,7367 ,8310 ,8900 ,10505 ,10561 ,9034 , 9858 ,10737 ,10191 ,11360 ,12682 ,12840 ,13372 ,14053 ,16087 ,18409 ,18209 ,17925 ,20541 ,22714 ,24362 , 25907 ,25964 ,29698 ,20105 ,85 ,145 ,6218 ,7233 ,10554 ,12536 ,13765 ,14834 ,16310 ,16999 ,17425 , 20087 ,21179 ,19814 ,19410 ,18187 ,15505 ,15517 ,17155 ,16402 ,13966 ,13609 ,16008 ,16224 ,13706 ,13838 , 15564 ,15943 ,16567 ,17298 ,18839 ,21759 ,22005 ,20699 ,21687 ,21773 ,21278 ,23400 ,24496 ,24593 ,24713 , 22202 ,23342 ,25718 ,16205 ,5900 ,7465 ,8359 ,5655 ,7133 ,8320 ,8288 ,10260 ,10357 ,10392 ,12933 , 13243 ,13908 ,17136 ,18352 ,20526 ,20918 ,12592 ,7393 ,10871 ,11632 ,11048 ,13628 ,14396 ,14756 ,16584 , 15986 ,14737 ,16196 ,18502 ,19579 ,17918 ,13603 ,10695 ,10580 ,10494 ,10548 ,11951 ,13603 ,14677 ,15679 , 17102 ,17752 ,18002 ,20286 ,22819 ,24116 ,25744 ,26455 ,26743 ,27985 ,28019 ,27773 ,29096 ,30219 ,29741 , 28802 ,29606 ,30479 ,30371 ,32621 ,32767 ,25973 ,21995 ,25519 ,27255 ,26810 ,29284 ,29845 ,18075 ,19831 , 19672 ,21304 ,22450 ,20627 ,25294 ,23926 ,26112 ,32767 ,23179 ,10126 ,-15337 ,-28008 ,-17457 ,-22339 ,-22578 , -18741 ,-22274 ,-18983 ,-18466 ,-19552 ,-17066 ,-16053 ,-15381 ,-17867 ,-20460 ,-18509 ,-17235 ,-16627 ,-15736 ,-15595 , -14060 ,-12153 ,-12397 ,-12267 ,-10504 ,-10038 ,-9444 ,-8221 ,-8267 ,-6022 ,-5888 ,-16178 ,-27013 ,-28782 ,-27601 , -27567 ,-27687 ,-27241 ,-25758 ,-24895 ,-24334 ,-22769 ,-21929 ,-21963 ,-21917 ,-22351 ,-22849 ,-22132 ,-20510 ,-20343 , -20728 ,-18895 ,-17642 ,-17366 ,-15630 ,-14986 ,-14249 ,-13040 ,-13065 ,-9146 ,-9754 ,-23851 ,-32767 ,-30285 ,-30080 , -29902 ,-27783 ,-27936 ,-26422 ,-24761 ,-25784 ,-24884 ,-22701 ,-22079 ,-21114 ,-19253 ,-18524 ,-18983 ,-18104 ,-16296 , -15838 ,-14939 ,-12819 ,-12232 ,-12492 ,-11211 ,-9804 ,-9500 ,-8417 ,-6571 ,-6248 ,-6190 ,-4320 ,-2836 ,-2421 , -871 ,600 ,550 ,889 ,2284 ,3287 ,3324 ,3571 ,4919 ,5936 ,6225 ,7546 ,8952 ,8891 ,9297 , 10931 ,11789 ,12093 ,13377 ,14347 ,14318 ,15396 ,16465 ,16386 ,17981 ,18803 ,16617 ,15749 ,14488 ,10837 , 11773 ,16496 ,18319 ,14987 ,4586 ,-3471 ,-2426 ,-1608 ,-2474 ,-1409 ,-523 ,-92 ,365 ,1090 ,2791 , 3959 ,4657 ,6429 ,7402 ,7202 ,8582 ,10932 ,12115 ,12939 ,14055 ,14549 ,14733 ,15359 ,15917 ,16335 , 17243 ,18002 ,17819 ,17992 ,19261 ,18651 ,13801 ,8104 ,6063 ,6588 ,6851 ,7501 ,8738 ,9107 ,9555 , 11087 ,12162 ,12417 ,13225 ,14310 ,14839 ,15361 ,15796 ,15812 ,16388 ,17321 ,17439 ,17132 ,17255 ,17609 , 17397 ,17228 ,17788 ,18116 ,19060 ,18925 ,11546 ,732 ,-2959 ,-965 ,-54 ,52 ,812 ,1771 ,2676 , 3125 ,3691 ,4745 ,5492 ,6156 ,6895 ,7176 ,7413 ,7816 ,7986 ,8362 ,9272 ,9752 ,9460 ,9637 , 10568 ,11087 ,11006 ,11164 ,11848 ,12557 ,12983 ,13793 ,15091 ,15738 ,16152 ,17513 ,18715 ,19119 ,20024 , 21266 ,21737 ,22011 ,22786 ,23423 ,23892 ,24798 ,25427 ,25442 ,25914 ,26817 ,27072 ,26962 ,27895 ,24062 , 23255 ,24764 ,25423 ,24564 ,26616 ,26230 ,28098 ,32767 ,21853 ,-1342 ,-21412 ,-32767 ,-32702 ,-30450 ,-31818 , -30831 ,-29449 ,-28835 ,-27254 ,-26920 ,-26164 ,-24531 ,-23872 ,-22850 ,-21405 ,-20692 ,-20006 ,-18786 ,-17549 ,-16928 , -16068 ,-14425 ,-13854 ,-13444 ,-11776 ,-11100 ,-10082 ,-8181 ,-8049 ,-6129 ,-5317 ,-13636 ,-21973 ,-22488 ,-22271 , -22443 ,-21099 ,-20461 ,-19199 ,-17456 ,-16992 ,-16027 ,-14312 ,-13318 ,-12493 ,-10718 ,-9224 ,-8813 ,-7459 ,-8100 , -13753 ,-16721 ,-14234 ,-13407 ,-13663 ,-11822 ,-10435 ,-9751 ,-8889 ,-7940 ,-6382 ,-7470 ,-12948 ,-16799 ,-16365 , -15727 ,-15515 ,-14581 ,-13923 ,-13052 ,-11930 ,-11663 ,-11341 ,-10282 ,-9307 ,-8829 ,-8429 ,-7483 ,-6538 ,-6141 , -5316 ,-4264 ,-4048 ,-3640 ,-2491 ,-1959 ,-1742 ,-716 ,81 ,-1 ,412 ,1580 ,2250 ,2666 ,3968 , 4930 ,4619 ,5602 ,6934 ,3593 ,-2348 ,-4643 ,-3686 ,-3003 ,-2614 ,-1551 ,-746 ,-600 ,72 ,1314 , 1959 ,1987 ,1959 ,1907 ,2183 ,2902 ,3754 ,4411 ,4734 ,5942 ,6469 ,6879 ,8852 ,8024 ,1326 , -10321 ,-8939 ,6852 ,8916 ,-304 ,-5650 ,-6671 ,-5857 ,-5393 ,-4235 ,-3726 ,-2965 ,-1747 ,-1911 ,-1309 , 109 ,732 ,1466 ,2768 ,3412 ,3471 ,4252 ,5417 ,6059 ,6854 ,8078 ,8664 ,8726 ,9739 ,11096 , 11301 ,12044 ,13617 ,13624 ,14065 ,16102 ,14586 ,8229 ,2622 ,1092 ,1796 ,2218 ,2544 ,3464 ,3822 , 3921 ,4958 ,5734 ,6021 ,6782 ,7489 ,7943 ,8303 ,8931 ,9707 ,9791 ,10627 ,11644 ,11388 ,13015 , 13210 ,6968 ,2044 ,1708 ,1442 ,2789 ,1741 ,-4439 ,-6997 ,-6013 ,-5986 ,-5270 ,-4610 ,-4063 ,-2935 , -2797 ,-2710 ,-1597 ,-849 ,-459 ,312 ,785 ,1000 ,1722 ,2331 ,2666 ,3668 ,4530 ,5277 ,6409 , 4559 ,691 ,764 ,2464 ,1909 ,2669 ,4027 ,1930 ,-112 ,768 ,1456 ,1401 ,1978 ,2304 ,2461 , 3129 ,3505 ,3553 ,3894 ,4158 ,4379 ,4987 ,5438 ,5680 ,6127 ,6455 ,6912 ,7302 ,7374 ,8033 , 8217 ,7808 ,8884 ,8689 ,8838 ,10471 ,9568 ,11357 ,10769 ,369 ,-7909 ,-11215 ,-12316 ,-10770 ,-10339 , -9888 ,-8566 ,-7816 ,-6458 ,-5936 ,-9006 ,-12691 ,-13036 ,-11733 ,-10991 ,-10152 ,-9137 ,-8546 ,-7814 ,-6712 , -5865 ,-5182 ,-4308 ,-3394 ,-2434 ,-1552 ,-882 ,160 ,1143 ,1686 ,3217 ,3825 ,1447 ,436 ,1979 , 2620 ,3364 ,4980 ,5973 ,7266 ,8948 ,9851 ,10590 ,11779 ,13070 ,14138 ,15047 ,16168 ,17394 ,18509 , 19168 ,19873 ,20597 ,21194 ,22984 ,23573 ,25602 ,26637 ,29091 ,32767 ,14547 ,-1204 ,-7706 ,-27943 ,-32767 , -28661 ,-30993 ,-28841 ,-27894 ,-27155 ,-25429 ,-24556 ,-23694 ,-22568 ,-21188 ,-20252 ,-19089 ,-17833 ,-16830 ,-15829 , -14732 ,-13294 ,-12244 ,-11571 ,-10113 ,-9046 ,-8256 ,-6438 ,-5577 ,-4849 ,-3210 ,-2800 ,-644 ,839 ,-5533 , -10941 ,-8511 ,-6774 ,-6838 ,-5295 ,-4444 ,-3505 ,-1967 ,-1277 ,-10 ,1423 ,1885 ,2999 ,4530 ,5340 , 6782 ,7494 ,3194 ,-3733 ,-6248 ,-4385 ,-3048 ,-2328 ,-392 ,678 ,1101 ,3285 ,4255 ,4787 ,7306 , 4701 ,671 ,2343 ,2805 ,4766 ,5593 ,-1098 ,-3328 ,-1323 ,-1161 ,-43 ,829 ,1257 ,2053 ,2819 , 3550 ,4438 ,5612 ,6509 ,7017 ,7584 ,8518 ,9364 ,9786 ,10675 ,11637 ,11753 ,12524 ,13594 ,13925 , 14976 ,15472 ,16044 ,18022 ,17766 ,19352 ,20973 ,7765 ,-9042 ,-9970 ,-7151 ,-9095 ,-8263 ,-7219 ,-7602 , -6527 ,-6068 ,-5793 ,-4771 ,-4266 ,-3761 ,-3114 ,-2467 ,-1900 ,-1333 ,-517 ,-130 ,600 ,1470 ,1871 , 3776 ,3501 ,-2924 ,-8400 ,-8554 ,-7734 ,-7014 ,-5952 ,-5195 ,-4547 ,-4791 ,-4691 ,-3464 ,-2636 ,-1703 , -464 ,90 ,820 ,2361 ,2989 ,3560 ,5269 ,5503 ,6201 ,8290 ,8001 ,9743 ,11424 ,3710 ,-2206 , 1154 ,-80 ,-5200 ,-4266 ,-2290 ,-2605 ,-1330 ,73 ,-1759 ,-4560 ,-4629 ,-3488 ,-3269 ,-2688 ,-1848 , -1359 ,-498 ,268 ,781 ,1486 ,2009 ,2535 ,3318 ,4053 ,4754 ,5426 ,6125 ,6892 ,7486 ,8176 , 8889 ,11311 ,11905 ,12962 ,13372 ,14472 ,15713 ,15747 ,16937 ,17113 ,14575 ,14915 ,16327 ,16093 ,18020 , 18641 ,19055 ,21925 ,13634 ,-1786 ,-2869 ,-774 ,-4303 ,-3184 ,-7850 ,-14046 ,-12166 ,-11496 ,-10658 ,-9383 , -9255 ,-8205 ,-7119 ,-6359 ,-5765 ,-4401 ,-3776 ,-3535 ,-1550 ,-980 ,-674 ,783 ,-5499 ,-15780 ,-16575 , -13748 ,-14290 ,-13773 ,-14505 ,-17266 ,-17209 ,-16192 ,-16188 ,-15894 ,-15519 ,-14996 ,-14707 ,-14675 ,-13999 ,-13749 , -14132 ,-13708 ,-13021 ,-12795 ,-12425 ,-12063 ,-11915 ,-11758 ,-11689 ,-10957 ,-10467 ,-11425 ,-11125 ,-10103 ,-10089 , -8896 ,-7971 ,-7354 ,-5762 ,-8981 ,-15067 ,-14608 ,-11661 ,-11757 ,-10303 ,-8727 ,-8679 ,-5982 ,-4837 ,-4605 , 251 ,-3438 ,-18230 ,-23774 ,-20746 ,-20805 ,-19944 ,-18121 ,-18134 ,-16623 ,-14806 ,-13927 ,-12542 ,-11485 ,-10047 , -8306 ,-7456 ,-6140 ,-4660 ,-3812 ,-2432 ,-708 ,467 ,1791 ,3367 ,3634 ,3551 ,4986 ,6495 ,7221 , 8211 ,9610 ,10515 ,11048 ,12385 ,13402 ,14032 ,15448 ,16048 ,16971 ,18197 ,18243 ,20492 ,21172 ,20167 , 23905 ,22712 ,23269 ,28983 ,23570 ,27669 ,26049 ,-1931 ,-11779 ,-7135 ,-7798 ,-5590 ,-5253 ,-4407 ,-2610 , -2015 ,-739 ,682 ,2126 ,3061 ,4108 ,5383 ,6260 ,7500 ,8964 ,10072 ,11258 ,12209 ,13386 ,14904 , 15757 ,17265 ,18516 ,19198 ,21796 ,23113 ,24519 ,22560 ,-705 ,-29566 ,-32767 ,-26918 ,-29419 ,-28377 ,-25274 , -24650 ,-22580 ,-20776 ,-19077 ,-17249 ,-15629 ,-13135 ,-12048 ,-9471 ,-7404 ,-14104 ,-19453 ,-16123 ,-14435 ,-14256 , -11863 ,-10950 ,-9732 ,-7465 ,-6570 ,-5207 ,-3369 ,-2228 ,-555 ,1026 ,1526 ,1579 ,1977 ,3444 ,5131 , 6157 ,7678 ,9419 ,10683 ,12352 ,13533 ,14758 ,16824 ,17299 ,18682 ,21195 ,21078 ,24152 ,26005 ,16284 , 9454 ,12908 ,14278 ,14521 ,16519 ,17832 ,19578 ,20003 ,22223 ,23533 ,21810 ,25256 ,24313 ,25891 ,32767 , 20817 ,5813 ,883 ,-1446 ,-403 ,-895 ,-623 ,194 ,-624 ,-307 ,-45 ,88 ,1089 ,2395 ,3239 , 4464 ,4895 ,-3499 ,-2484 ,39 ,-792 ,-2072 ,-2084 ,-1008 ,1630 ,1676 ,2377 ,2347 ,-10871 ,-23601 , -20817 ,-19853 ,-23788 ,-21895 ,-22692 ,-27322 ,-27544 ,-27541 ,-26697 ,-23759 ,-26674 ,-29632 ,-27324 ,-26559 ,-26346 , -24867 ,-24710 ,-24917 ,-23448 ,-22297 ,-22572 ,-21027 ,-18882 ,-19274 ,-19236 ,-17834 ,-18077 ,-18144 ,-17632 ,-20007 , -21897 ,-20784 ,-19807 ,-18283 ,-17940 ,-18706 ,-15013 ,-12924 ,-14064 ,-10472 ,-9013 ,-10239 ,-6740 ,-3433 ,1081 , -1342 ,-21182 ,-32767 ,-27867 ,-27727 ,-28201 ,-25724 ,-26029 ,-22722 ,-19990 ,-20640 ,-16937 ,-13910 ,-15054 ,-15249 , -13572 ,-10648 ,-9851 ,-10986 ,-7774 ,-3652 ,-4309 ,-4042 ,-216 ,1754 ,2857 ,6012 ,5912 ,3772 ,7358 , 10582 ,9993 ,12757 ,16407 ,15650 ,14194 ,18805 ,18399 ,9224 ,8106 ,9983 ,9748 ,11301 ,11439 ,12232 , 13300 ,13704 ,14187 ,14918 ,16172 ,15894 ,16769 ,18803 ,18665 ,20345 ,15420 ,-4086 ,-16366 ,-12760 ,-10889 , -12065 ,-11139 ,-11578 ,-11989 ,-11300 ,-11208 ,-10719 ,-8965 ,-7242 ,-7956 ,-8602 ,-6249 ,-5407 ,-6037 ,-3596 , -1897 ,-3990 ,-4292 ,-994 ,1504 ,-599 ,-9485 ,-18953 ,-21189 ,-19906 ,-19925 ,-19513 ,-18113 ,-17901 ,-17471 , -15400 ,-17258 ,-25310 ,-31228 ,-30921 ,-29756 ,-29400 ,-28034 ,-27187 ,-26949 ,-25647 ,-24586 ,-24469 ,-23894 ,-22759 , -21678 ,-21116 ,-20708 ,-19475 ,-18174 ,-17440 ,-16387 ,-15322 ,-14948 ,-14271 ,-12442 ,-11300 ,-11919 ,-11821 ,-11206 , -10843 ,-8862 ,-7976 ,-7968 ,-5094 ,-3354 ,-2648 ,-788 ,-518 ,2776 ,3703 ,-7941 ,-16170 ,-12155 ,-8838 , -7498 ,-5687 ,-4495 ,-1942 ,-57 ,1395 ,1002 ,-5938 ,-11925 ,-11216 ,-9248 ,-8144 ,-7477 ,-6123 ,-3789 , -2935 ,-1856 ,42 ,376 ,899 ,2263 ,3594 ,5109 ,5682 ,6407 ,8197 ,9060 ,9923 ,11567 ,11785 , 11769 ,13516 ,14578 ,14566 ,15723 ,16722 ,17461 ,19073 ,20210 ,22355 ,22903 ,23314 ,27379 ,24516 ,26125 , 32767 ,20180 ,6241 ,3402 ,2621 ,3211 ,2538 ,3482 ,3799 ,3648 ,6227 ,6892 ,3744 ,-4246 ,-12820 , -13992 ,-11972 ,-12613 ,-1205 ,947 ,-281 ,-770 ,1242 ,822 ,1207 ,5238 ,5623 ,3003 ,3150 ,791 , -3861 ,-3996 ,-2697 ,-1973 ,-2173 ,-79 ,-148 ,-17211 ,-32767 ,-32747 ,-31568 ,-25276 ,-19188 ,-24985 ,-25647 , -19308 ,-22164 ,-23239 ,-17582 ,-22438 ,-27586 ,-21164 ,-20734 ,-24842 ,-21901 ,-22119 ,-20951 ,-9814 ,-8374 ,-17371 , -14014 ,-4940 ,-3806 ,-3628 ,-4547 ,-3806 ,5870 ,4770 ,-8488 ,-5604 ,336 ,-4185 ,2575 ,8555 ,1816 , 1916 ,664 ,-6516 ,-3133 ,5384 ,14376 ,21612 ,19650 ,19316 ,22919 ,20696 ,20432 ,23791 ,13847 ,-6636 , -10743 ,-2414 ,-3350 ,2415 ,11060 ,-75 ,68 ,12858 ,2375 ,-7567 ,-4037 ,-3752 ,3850 ,5913 ,-4303 , -62 ,8207 ,8048 ,10249 ,7962 ,3200 ,6598 ,11233 ,8906 ,4339 ,6197 ,4864 ,3762 ,19972 ,24177 , 11453 ,19942 ,24422 ,10452 ,15779 ,23742 ,15455 ,14999 ,22997 ,29512 ,30083 ,24978 ,22854 ,18383 ,16247 , 25590 ,26038 ,13563 ,5442 ,564 ,-2419 ,-2325 ,-2021 ,4404 ,9823 ,-1261 ,-10079 ,-2367 ,-777 ,-2970 , 4209 ,5214 ,-3194 ,-2795 ,8026 ,8307 ,4325 ,11702 ,13790 ,10871 ,14951 ,12788 ,7030 ,12402 ,15860 , 14615 ,19381 ,11772 ,-13732 ,-27776 ,-27089 ,-29916 ,-30051 ,-23246 ,-21181 ,-21742 ,-20759 ,-20071 ,-15207 ,-13640 , -20437 ,-19891 ,-15838 ,-18719 ,-15038 ,-8891 ,-11703 ,-11638 ,-10246 ,-13277 ,-10428 ,-4784 ,-741 ,6002 ,9451 , 8114 ,8142 ,9513 ,9856 ,8978 ,9407 ,8144 ,3627 ,3151 ,6086 ,12270 ,17341 ,9315 ,6913 ,18559 , 17130 ,9466 ,9893 ,10505 ,18062 ,22278 ,12590 ,10047 ,11179 ,6190 ,6373 ,6268 ,2353 ,3965 ,9020 , 9330 ,4984 ,5900 ,6782 ,3517 ,13796 ,22279 ,14336 ,19049 ,25834 ,14742 ,14487 ,22527 ,18047 ,15480 , 22206 ,29889 ,30155 ,24288 ,23059 ,19831 ,15908 ,24474 ,27735 ,18077 ,15644 ,17248 ,14546 ,12986 ,11311 , 15058 ,24892 ,20135 ,8605 ,16658 ,24023 ,15763 ,22167 ,32767 ,19664 ,11380 ,19271 ,22213 ,17703 ,9423 , 6193 ,9416 ,9176 ,7777 ,3268 ,2421 ,-4333 ,-9380 ,-8673 ,-7062 ,-5666 ,-6019 ,-11799 ,-15772 ,-13335 , -14019 ,-13979 ,-6660 ,-4517 ,-5304 ,-2907 ,-5031 ,-4706 ,-4206 ,-13961 ,-20191 ,-18185 ,-14109 ,-8134 ,-8705 , -8446 ,-1591 ,-11230 ,-25196 ,-18674 ,-19182 ,-32767 ,-29644 ,-19570 ,-20428 ,-25153 ,-29458 ,-24178 ,-12531 ,-18439 , -28115 ,-19670 ,-14100 ,-14562 ,-9862 ,-14376 ,-18121 ,-7813 ,-8980 ,-19687 ,-14506 ,-7817 ,-13605 ,-14883 ,-11625 , -17741 ,-20125 ,-10116 ,-9046 ,-17462 ,-16242 ,-10762 ,-9822 ,-11088 ,-10243 ,-3137 ,-2529 ,-8616 ,-2887 ,-1892 , -12949 ,-6593 ,7501 ,3681 ,-4376 ,-5851 ,-11589 ,-21963 ,-23315 ,-20209 ,-25570 ,-23200 ,-11424 ,-14320 ,-17257 , -6216 ,-4906 ,-12511 ,-13208 ,-11154 ,-8241 ,-9471 ,-16995 ,-14006 ,-3222 ,-4240 ,-8014 ,-2179 ,2305 ,5174 , 9436 ,728 ,-8700 ,2093 ,6983 ,-1108 ,7280 ,14262 ,2811 ,1424 ,8160 ,9237 ,13214 ,11157 ,6317 , 16216 ,22521 ,13178 ,7252 ,9578 ,12116 ,13148 ,14267 ,18919 ,22727 ,16267 ,-2335 ,-18284 ,-20694 ,-18108 , -7781 ,-7610 ,-20986 ,-13910 ,-3296 ,-554 ,-2763 ,-10485 ,-2791 ,-646 ,-6776 ,2946 ,-1229 ,-16699 ,-11336 , -9600 ,-17884 ,-14552 ,-14296 ,-14157 ,2694 ,7496 ,-9269 ,-12136 ,-1326 ,2315 ,3861 ,1296 ,-1647 ,11083 , 13744 ,-9412 ,-14504 ,-273 ,-2630 ,-2908 ,4753 ,477 ,-2458 ,-5214 ,-11850 ,-5459 ,4841 ,12310 ,22760 , 23128 ,14865 ,13683 ,18742 ,22314 ,17858 ,7045 ,-853 ,-3932 ,-5908 ,-5753 ,1422 ,7104 ,890 ,-988 , 7130 ,7324 ,1742 ,-4232 ,-8310 ,191 ,5338 ,-5502 ,-12246 ,-7184 ,3787 ,9005 ,471 ,-2307 ,6046 , 11502 ,13253 ,4371 ,-7391 ,-3155 ,2510 ,5138 ,14493 ,16300 ,11940 ,11928 ,8913 ,9710 ,16835 ,13065 , 5513 ,15635 ,32767 ,29783 ,13147 ,7961 ,8383 ,6302 ,13751 ,20028 ,12886 ,7452 ,4441 ,-2499 ,-5083 , -4267 ,2487 ,14591 ,8127 ,-5725 ,4840 ,13132 ,197 ,188 ,6403 ,-4311 ,-8002 ,-6423 ,-11799 ,-6644 , -4066 ,-9956 ,-2407 ,1354 ,-5481 ,2288 ,4094 ,-5758 ,7235 ,12596 ,-1548 ,7921 ,10428 ,-19379 ,-21922 , 1418 ,-2621 ,-10194 ,-318 ,-2457 ,-11300 ,-14227 ,-19174 ,-19038 ,1556 ,18170 ,2566 ,-6132 ,3404 ,5234 , 4415 ,5290 ,9373 ,5434 ,-8912 ,-12766 ,-9377 ,-11187 ,-12190 ,-13471 ,-21358 ,-24645 ,-24028 ,-25577 ,-14750 , -6919 ,-15423 ,-9930 ,-1973 ,-8033 ,-1014 ,-595 ,-18762 ,-17550 ,-10604 ,-14432 ,-5757 ,1771 ,-3904 ,-6133 , -10318 ,-13721 ,-8318 ,-17890 ,-32767 ,-18772 ,-3320 ,-13842 ,-26972 ,-25279 ,-7491 ,-958 ,-23765 ,-27695 ,-7584 , -4834 ,-2932 ,-3061 ,-14162 ,-628 ,9388 ,-13696 ,-16224 ,868 ,-7343 ,-17136 ,-8720 ,-11743 ,-24757 ,-17959 , -2834 ,-3365 ,-11275 ,-18210 ,-17573 ,-5521 ,-360 ,131 ,3397 ,-5071 ,-7254 ,-1210 ,-15310 ,-13535 ,17879 , 19211 ,-3977 ,-8417 ,-8943 ,-17036 ,-16342 ,-8896 ,-11486 ,-23554 ,-19985 ,-815 ,1934 ,2412 ,18028 ,5183 , -21567 ,-7785 ,5853 ,-8872 ,-15613 ,-12265 ,-298 ,10868 ,353 ,-52 ,14378 ,15186 ,14470 ,2154 ,-18095 , -3722 ,11023 ,-4683 ,1423 ,19736 ,2936 ,-9270 ,9144 ,19705 ,16590 ,13893 ,11763 ,18580 ,30026 ,30223 , 16018 ,-599 ,1193 ,12714 ,13805 ,19016 ,30705 ,28607 ,15008 ,-2782 ,-16947 ,-9837 ,802 ,-2259 ,-3344 , -7208 ,-5708 ,-10055 ,-32049 ,-11259 ,17805 ,-12976 ,-29708 ,-4984 ,1583 ,-8923 ,-11293 ,8544 ,24503 ,3229 , 1913 ,18270 ,-10599 ,-19836 ,18652 ,31028 ,10620 ,-14183 ,-16648 ,-1750 ,-8777 ,-15249 ,-17173 ,-26987 ,-3817 , 9711 ,-12708 ,5756 ,28642 ,2471 ,-9966 ,-1163 ,-61 ,-1180 ,-16474 ,-26967 ,-7234 ,7546 ,250 ,-569 , 12117 ,22861 ,24174 ,8250 ,-12079 ,-2475 ,11257 ,-2353 ,7978 ,32767 ,10635 ,-6681 ,10003 ,10171 ,11429 , 18744 ,3461 ,5805 ,29832 ,24497 ,-940 ,-11589 ,-2520 ,9037 ,7366 ,6279 ,16151 ,16788 ,2409 ,-3492 , 2828 ,1750 ,910 ,11046 ,8836 ,-2618 ,5329 ,14470 ,2540 ,-9455 ,-12971 ,-12521 ,-4820 ,-11173 ,-26896 , -14662 ,-2554 ,-13209 ,-12600 ,-14957 ,-23712 ,-8802 ,-9854 ,-10088 ,11684 ,12825 ,1822 ,11493 ,8522 ,-4651 , -1618 ,-1860 ,-8447 ,-7394 ,-2819 ,-66 ,-2794 ,-5368 ,-3445 ,-8049 ,-80 ,18467 ,1300 ,-18160 ,-1365 , 10254 ,1779 ,-8107 ,-8055 ,5318 ,6622 ,-13708 ,-14494 ,2187 ,1701 ,-558 ,-3739 ,-14119 ,-7292 ,-114 , -8101 ,-5546 ,3990 ,4528 ,-1570 ,-2739 ,366 ,-9680 ,-12407 ,-3071 ,-9458 ,-10628 ,-1150 ,-4806 ,-6752 , 1075 ,55 ,-1697 ,2325 ,-8061 ,-19260 ,-11057 ,4215 ,12991 ,1060 ,-10434 ,6399 ,7916 ,-11637 ,-4944 , -3635 ,-20639 ,-12287 ,-9191 ,-25457 ,-18163 ,-14405 ,-26260 ,-7999 ,7211 ,-14451 ,-17860 ,1898 ,3422 ,2249 , 1665 ,-3907 ,15360 ,20661 ,-18104 ,-23341 ,-3912 ,-17459 ,-9437 ,12385 ,-4880 ,-14681 ,-13893 ,-27721 ,-24846 , -9205 ,7590 ,21868 ,17563 ,12307 ,9593 ,4580 ,8860 ,4916 ,-2595 ,-35 ,-5643 ,-11073 ,-4758 ,13617 , 24639 ,-7331 ,-22136 ,13924 ,9104 ,-24442 ,-25229 ,-22194 ,-5010 ,11032 ,-20387 ,-32767 ,2287 ,13541 ,-4095 , -10825 ,-9350 ,-10351 ,-4560 ,-323 ,-11349 ,-16199 ,-22292 ,-28909 ,9368 ,23173 ,-21243 ,-3675 ,27237 ,-10401 , -4471 ,27678 ,3662 ,-6708 ,7764 ,16509 ,32767 ,30135 ,13292 ,5633 ,-3602 ,-1196 ,7643 ,358 ,-7580 , -6236 ,800 ,-1517 ,-11912 ,2010 ,13487 ,8821 ,15917 ,20890 ,22526 ,20343 ,11855 ,6534 ,4100 ,241 , -9413 ,-5216 ,2287 ,82 ,15333 ,15332 ,-3361 ,12070 ,14697 ,-13792 ,-18007 ,-14918 ,-8895 ,2343 ,-13159 , -18433 ,-3842 ,-4713 ,2992 ,7538 ,-11107 ,-10749 ,3768 ,662 ,-9327 ,-7860 ,-68 ,-5362 ,-1064 ,19561 , 9352 ,-1593 ,16343 ,11932 ,3327 ,12789 ,3580 ,-2651 ,9463 ,17394 ,20342 ,12278 ,7999 ,10471 ,-3613 , 831 ,21971 ,9282 ,-3378 ,3606 ,-1054 ,-2446 ,-1990 ,-8866 ,3709 ,12274 ,-4994 ,-4846 ,9613 ,4201 , 7560 ,27302 ,15406 ,-12153 ,-4016 ,8660 ,-5479 ,-6285 ,7901 ,2942 ,-5418 ,-3664 ,636 ,10413 ,8588 , -4385 ,3261 ,16470 ,8322 ,-7788 ,-14506 ,-15520 ,-13673 ,-10741 ,-6433 ,-6365 ,-5147 ,-4679 ,-2427 ,-1887 , -9 ,-280 ,-8605 ,-3734 ,8613 ,11928 ,13735 ,9916 ,5950 ,7756 ,665 ,24 ,13443 ,9501 ,-1025 , 9778 ,22551 ,17958 ,-4467 ,-24908 ,-6211 ,21894 ,3770 ,-21363 ,-11833 ,5855 ,14994 ,4371 ,-17433 ,-6607 , 20411 ,15472 ,-4898 ,-4942 ,12569 ,17708 ,6009 ,104 ,-3202 ,-5944 ,-2158 ,1294 ,2278 ,-4153 ,-10039 , 3462 ,21793 ,14420 ,-4005 ,-1294 ,8228 ,8455 ,10244 ,12931 ,11596 ,7390 ,-2837 ,-14536 ,-9915 ,13520 , 22515 ,-1670 ,-21749 ,-16055 ,-12641 ,-12829 ,-1572 ,-4539 ,-22744 ,-13003 ,13546 ,18090 ,21745 ,32767 ,15271 , -13172 ,-12333 ,3925 ,8390 ,-8497 ,-23293 ,-1921 ,19044 ,1710 ,-9295 ,6940 ,21110 ,17722 ,-10659 ,-32767 , -14751 ,-406 ,-5463 ,8804 ,13577 ,-9010 ,-11943 ,1452 ,7737 ,12039 ,8096 ,4801 ,14350 ,20746 ,22765 , 18252 ,-4974 ,-21220 ,-13412 ,1032 ,5577 ,2307 ,9587 ,12908 ,6276 ,16346 ,26981 ,12762 ,117 ,9783 , 8962 ,-7976 ,-3435 ,14961 ,12653 ,-4229 ,-2595 ,11729 ,12021 ,14966 ,18597 ,6488 ,12483 ,20796 ,-5292 , -20623 ,-17653 ,-25166 ,-16818 ,1488 ,7609 ,18307 ,15301 ,-5980 ,781 ,22620 ,13567 ,-13624 ,-26023 ,-11388 , 10167 ,6083 ,1408 ,20754 ,20015 ,4050 ,19010 ,24015 ,-9491 ,-23469 ,-1870 ,16867 ,9351 ,-19069 ,-15711 , 22319 ,15187 ,-11549 ,7364 ,12885 ,-389 ,21194 ,23627 ,-3750 ,7216 ,24067 ,2193 ,-5533 ,18374 ,18586 , -1127 ,-516 ,-5650 ,-14848 ,7912 ,9799 ,-22112 ,-14553 ,9167 ,-455 ,-8638 ,5455 ,23448 ,22977 ,10740 , 16102 ,15119 ,-8421 ,-11980 ,9775 ,23517 ,6150 ,-19852 ,-6694 ,10841 ,-3488 ,-11874 ,-14481 ,-11007 ,3820 , -8495 ,-14253 ,14981 ,24640 ,18819 ,14218 ,2544 ,6383 ,2822 ,-20188 ,-15843 ,4406 ,7734 ,1654 ,-3010 , 1523 ,9508 ,12554 ,5007 ,-8122 ,3830 ,17995 ,1994 ,6206 ,24669 ,5979 ,-10485 ,-2710 ,3684 ,11259 , 7143 ,-3777 ,9878 ,23171 ,13381 ,5491 ,13061 ,12752 ,-9061 ,-11500 ,-16910 ,-26516 ,-21394 ,-25020 ,-28449 , -20799 ,-22955 ,-22058 ,-7377 ,1232 ,516 ,2960 ,737 ,-9251 ,-12410 ,-13025 ,-16659 ,-11180 ,1271 ,11930 , 20493 ,21307 ,18099 ,15902 ,1248 ,-17376 ,-10983 ,10967 ,16025 ,2125 ,-7770 ,-1012 ,6175 ,-3910 ,-12924 , -1295 ,12599 ,7633 ,-9398 ,-14022 ,2917 ,11025 ,-2244 ,-1203 ,11685 ,353 ,-14560 ,-6022 ,-2465 ,-11024 , -321 ,17325 ,10669 ,-4970 ,-11540 ,-12554 ,-7571 ,-1377 ,1341 ,-1104 ,-6842 ,-1263 ,5012 ,-2257 ,-1022 , 10165 ,16913 ,16325 ,-2656 ,-23783 ,-21954 ,-18271 ,-20052 ,-11479 ,-11068 ,-17924 ,-14800 ,-10882 ,-9226 ,-12305 , -14770 ,-13187 ,-16705 ,-14644 ,-10353 ,-20208 ,-23216 ,-6535 ,4395 ,3769 ,4914 ,7414 ,12584 ,13886 ,-16 , -10569 ,-6266 ,-6540 ,-14734 ,-16459 ,-10541 ,-11897 ,-24915 ,-28739 ,-24526 ,-26679 ,-11228 ,18139 ,23643 ,17646 , 17213 ,11972 ,4899 ,-2616 ,-5716 ,977 ,-3256 ,-14046 ,-7354 ,1449 ,6880 ,13027 ,-2569 ,-19262 ,-8172 , -6557 ,-25143 ,-30567 ,-21175 ,-3951 ,1877 ,-18522 ,-21407 ,-1336 ,-3174 ,-9056 ,-4494 ,-11551 ,-9466 ,20 , -12606 ,-19818 ,-19750 ,-32767 ,-17130 ,10733 ,2060 ,7071 ,26417 ,4442 ,-15394 ,-4328 ,311 ,-3059 ,-6750 , 338 ,26982 ,32767 ,9977 ,763 ,-2373 ,-12471 ,-6151 ,1116 ,-8605 ,-6947 ,3911 ,-161 ,-5885 ,-30 , 9305 ,8725 ,-4297 ,-8473 ,3778 ,12940 ,12355 ,15672 ,26713 ,23376 ,3653 ,-647 ,4883 ,-3371 ,-5470 , 5142 ,3630 ,-5615 ,-5704 ,2688 ,8953 ,1323 ,-11503 ,-14786 ,-11514 ,-5103 ,6484 ,16791 ,16564 ,10506 , 9672 ,14260 ,14038 ,3216 ,-7701 ,-8146 ,-7138 ,-13542 ,-19707 ,-17961 ,-10212 ,-8991 ,-19385 ,-22369 ,-15292 , -15540 ,-17443 ,-14549 ,-5979 ,11118 ,15571 ,10081 ,14056 ,-2007 ,-31402 ,-23078 ,-1072 ,-2085 ,-4579 ,-6031 , -16965 ,-21564 ,-21603 ,-28431 ,-19760 ,9659 ,20472 ,8535 ,7171 ,14862 ,11362 ,-237 ,-6553 ,-3337 ,-493 , -7602 ,-12355 ,-5158 ,-838 ,-3593 ,-879 ,5270 ,7684 ,6057 ,2320 ,-11279 ,-13506 ,-7621 ,-6869 ,-13871 , -19115 ,-13782 ,-4862 ,835 ,5881 ,3810 ,-2680 ,1966 ,1433 ,-14018 ,-19495 ,-17739 ,-13636 ,-7576 ,-8224 , -754 ,9019 ,9129 ,7436 ,3748 ,669 ,279 ,2125 ,11106 ,26592 ,30624 ,12105 ,-4076 ,-1247 ,2392 , 3931 ,13917 ,20087 ,12116 ,4491 ,12030 ,17656 ,-113 ,-14828 ,-806 ,15395 ,7175 ,-14634 ,-17283 ,2991 , 9613 ,6382 ,12437 ,5372 ,-347 ,11713 ,3160 ,-12456 ,-353 ,6198 ,-5979 ,-3403 ,11630 ,9602 ,-257 , 4585 ,4060 ,-4515 ,4502 ,8002 ,-5809 ,-5807 ,-2963 ,-9192 ,-5152 ,2732 ,8814 ,8292 ,-1138 ,851 , -4076 ,-22787 ,-16788 ,3115 ,9674 ,1517 ,-16243 ,-16700 ,-4516 ,-5137 ,429 ,5033 ,-8193 ,-5450 ,8579 , 9813 ,19725 ,29350 ,13343 ,-8344 ,-16027 ,-8890 ,-4311 ,-22969 ,-32767 ,-11125 ,360 ,-998 ,14350 ,24694 , 21148 ,21888 ,7393 ,-18131 ,-11496 ,2699 ,-8476 ,-5245 ,4978 ,-11512 ,-16203 ,-4192 ,-859 ,7049 ,5571 , -2918 ,10912 ,21908 ,15793 ,7831 ,-6985 ,-20493 ,-19228 ,-12578 ,-1036 ,12099 ,9948 ,10988 ,22780 ,14639 , -8099 ,-20096 ,-24252 ,-27089 ,-16664 ,6250 ,18202 ,14060 ,9480 ,8757 ,7558 ,4802 ,-6454 ,-25080 ,-28465 , -11486 ,412 ,3950 ,20030 ,32767 ,17974 ,7195 ,15120 ,6954 ,-4814 ,7947 ,23773 ,25652 ,8367 ,-8989 , 6259 ,11929 ,-15897 ,-17240 ,4752 ,12967 ,22634 ,26709 ,17687 ,20550 ,27529 ,18293 ,8945 ,17776 ,25362 , 14453 ,5587 ,251 ,-11924 ,-1841 ,21869 ,10247 ,-13383 ,-9967 ,-5222 ,-8960 ,-1437 ,6628 ,7828 ,13137 , 12882 ,4647 ,5084 ,6649 ,6706 ,21858 ,25865 ,-1765 ,-14113 ,4501 ,15048 ,9546 ,-3117 ,-12912 ,-109 , 14963 ,3707 ,-6195 ,8103 ,19427 ,6762 ,-10534 ,-7386 ,6420 ,5308 ,-7223 ,-9120 ,-1202 ,140 ,-654 , 5975 ,12601 ,18713 ,19644 ,2079 ,-11199 ,-558 ,8120 ,9276 ,16178 ,13559 ,1587 ,601 ,3931 ,-1095 , -9768 ,-12718 ,-4355 ,2656 ,-5300 ,-12206 ,-7945 ,-6505 ,-8449 ,-8775 ,-14986 ,-10334 ,-3776 ,-7354 ,-10056 , -9163 ,-15172 ,-9521 ,8741 ,7272 ,63 ,9090 ,10052 ,5792 ,6993 ,-4260 ,-17027 ,-16309 ,-2586 ,8290 , -536 ,-7003 ,-8161 ,-15275 ,-13477 ,-3527 ,-381 ,-5406 ,-7167 ,2964 ,13904 ,7364 ,-7216 ,-8541 ,-801 , 2126 ,-1933 ,-3242 ,4215 ,8850 ,9246 ,15000 ,11810 ,-6507 ,-15770 ,-10952 ,-6966 ,-8481 ,-15681 ,-17030 , -3312 ,6079 ,2753 ,3962 ,8728 ,7520 ,9752 ,12593 ,2033 ,-10492 ,-12965 ,-17092 ,-21265 ,-7357 ,-1893 , -20255 ,-21298 ,-13849 ,-21635 ,-24711 ,-20225 ,-14936 ,-6923 ,-1939 ,-11774 ,-22186 ,-6886 ,8680 ,1943 ,1869 , 8316 ,4628 ,530 ,-5850 ,-9184 ,-5351 ,-8867 ,-9508 ,-7123 ,-12478 ,-12758 ,-17271 ,-28261 ,-30647 ,-32767 , -18136 ,16026 ,28027 ,20457 ,12544 ,5785 ,7543 ,2453 ,-9145 ,-5893 ,-5670 ,-13755 ,-9035 ,1343 ,8135 , 8120 ,-2371 ,-2916 ,5865 ,-5694 ,-24747 ,-29159 ,-25079 ,-10682 ,-6925 ,-25415 ,-19657 ,921 ,-7333 ,-11706 , -3035 ,-9566 ,-8103 ,912 ,-10304 ,-20130 ,-19991 ,-25669 ,-16846 ,5043 ,2814 ,-9003 ,-943 ,4785 ,-1647 , 2097 ,10469 ,2406 ,-10850 ,13 ,27727 ,32767 ,15776 ,7147 ,-1093 ,-13979 ,-7081 ,2890 ,-8762 ,-13337 , -1275 ,2166 ,-3036 ,-11843 ,-15747 ,3674 ,19755 ,6611 ,1383 ,11377 ,1587 ,137 ,29110 ,27263 ,-7494 , -7365 ,6065 ,-7966 ,-10797 ,2232 ,-1473 ,-4321 ,989 ,1221 ,12160 ,19315 ,6219 ,-228 ,-3670 ,-10103 , -2617 ,8380 ,14552 ,16365 ,8331 ,8153 ,19428 ,18126 ,9549 ,-2336 ,-21026 ,-21406 ,-12425 ,-20283 ,-21248 , -10501 ,-12006 ,-11524 ,-2037 ,-8446 ,-20248 ,-10619 ,-469 ,-4063 ,3410 ,14872 ,14802 ,14643 ,1893 ,-21378 , -19947 ,-3869 ,-148 ,-1642 ,-7968 ,-19537 ,-21719 ,-21985 ,-28664 ,-24605 ,-4334 ,17215 ,24034 ,12637 ,2978 , 7419 ,8556 ,398 ,-3395 ,-3422 ,-5380 ,-8223 ,-10259 ,-1236 ,12057 ,1096 ,-14043 ,5702 ,25611 ,6756 , -21687 ,-27888 ,-12562 ,-1774 ,-16695 ,-27888 ,-15586 ,-6325 ,-5063 ,-5353 ,-9258 ,-2554 ,5218 ,-8799 ,-18880 , -7249 ,-4802 ,-15801 ,-11618 ,-5404 ,-14971 ,-9562 ,9238 ,6340 ,-1718 ,978 ,-2756 ,-9126 ,-7637 ,7198 , 22750 ,13108 ,2814 ,2599 ,-16178 ,-16793 ,15404 ,19007 ,-2404 ,-7870 ,-4041 ,-2588 ,-5592 ,-8119 ,-5269 , -3593 ,61 ,3227 ,-1539 ,1350 ,12392 ,11756 ,3265 ,-1270 ,-1458 ,-3674 ,-16570 ,-24773 ,-10050 ,1163 , -8683 ,-8363 ,6852 ,10678 ,10842 ,8376 ,-8413 ,-4712 ,14240 ,-3369 ,-20160 ,-5520 ,-11902 ,-24763 ,-6981 , 674 ,-6615 ,-5982 ,-8919 ,-4159 ,529 ,-9987 ,-12523 ,-13146 ,-17715 ,-17912 ,-20762 ,-10864 ,5570 ,2122 , -3706 ,-2078 ,-1709 ,1611 ,3837 ,2922 ,171 ,-1798 ,6737 ,8353 ,1720 ,2091 ,-15835 ,-29813 ,-26293 , -27583 ,-16044 ,-9472 ,-6687 ,-6367 ,-13993 ,254 ,10361 ,10246 ,12970 ,6943 ,9454 ,5996 ,-21377 ,-23524 , 9072 ,17320 ,-8308 ,-26158 ,-10367 ,19616 ,8933 ,-25819 ,-16670 ,5006 ,416 ,4428 ,1844 ,-13101 ,5187 , 15156 ,-13781 ,-9988 ,18231 ,5836 ,-10492 ,-4627 ,-19685 ,-32684 ,-7672 ,6970 ,-5959 ,-10805 ,-9879 ,-7834 , -5303 ,-7915 ,6907 ,15622 ,-4409 ,821 ,5418 ,-26657 ,-12109 ,32767 ,20314 ,-6726 ,-8465 ,-10965 ,-12632 , -7564 ,-4190 ,-12152 ,-21164 ,-6608 ,7480 ,2137 ,14978 ,31458 ,7839 ,-14676 ,-2869 ,4554 ,-9991 ,-31476 , -32767 ,-3628 ,3331 ,-17141 ,-4332 ,15505 ,7894 ,9383 ,608 ,-24840 ,-6841 ,10061 ,-19999 ,-15336 ,10632 , -10827 ,-20099 ,-1793 ,-3356 ,-4076 ,-3676 ,-9129 ,4206 ,15164 ,6214 ,-10060 ,-22469 ,-17530 ,-15466 ,-19155 , -789 ,10908 ,17 ,-3377 ,-3813 ,-8713 ,-6395 ,2461 ,5885 ,-837 ,1694 ,13509 ,9954 ,-4664 ,-11563 , -6142 ,2495 ,25 ,-12229 ,-15639 ,-14362 ,-18266 ,-3116 ,14473 ,1607 ,-4114 ,2560 ,-1014 ,11013 ,14048 , -13315 ,-18367 ,-9173 ,-14563 ,-9626 ,-2861 ,-3817 ,3438 ,5331 ,3574 ,4428 ,-15903 ,-28298 ,2061 ,19750 , -5241 ,-26685 ,-16585 ,12260 ,14771 ,-13140 ,-14963 ,-6399 ,-11390 ,5227 ,7040 ,-13127 ,8307 ,23203 ,-5697 , -7099 ,10841 ,2132 ,-8715 ,-6511 ,-1579 ,1900 ,245 ,-3512 ,-6199 ,-9607 ,-10899 ,-5756 ,-4349 ,-10078 , 501 ,12427 ,-2021 ,-7032 ,-3399 ,-16143 ,-2061 ,24344 ,14031 ,1031 ,-2573 ,-4709 ,6347 ,-1258 ,-20277 , -11887 ,-6501 ,-13106 ,-7235 ,-1832 ,5120 ,15662 ,5711 ,-7501 ,1809 ,10717 ,2228 ,-14114 ,-27813 ,-20133 , -6104 ,-19497 ,-22390 ,-664 ,-3819 ,-7709 ,3219 ,-15490 ,-22832 ,1353 ,-6468 ,-12159 ,12708 ,5096 ,-7986 , 6655 ,-2492 ,-19806 ,-10612 ,-2594 ,-1685 ,63 ,-4908 ,-14037 ,-22976 ,-29391 ,-32431 ,-29916 ,-11529 ,13758 , 19470 ,8611 ,5102 ,9799 ,7497 ,6 ,1709 ,4393 ,-6354 ,-11226 ,-4577 ,-597 ,8208 ,2074 ,-17663 , -3334 ,14362 ,-9910 ,-32767 ,-29054 ,-23650 ,-15236 ,-14687 ,-21808 ,-5297 ,3319 ,-6088 ,-1253 ,-6803 ,-20369 , -10219 ,-227 ,-10333 ,-20760 ,-20849 ,-18243 ,-7917 ,5437 ,-3801 ,-9406 ,13548 ,15470 ,-2747 ,2335 ,4538 , -7307 ,-4473 ,10548 ,23372 ,19585 ,5139 ,-1269 ,-10527 ,-10929 ,6159 ,-948 ,-17106 ,-3423 ,4774 ,-4314 , -7240 ,-11772 ,-3675 ,20288 ,15102 ,-3090 ,5716 ,4656 ,-5993 ,20156 ,32767 ,-4185 ,-15407 ,4426 ,-5206 , -15953 ,-3623 ,-4533 ,-8468 ,1157 ,2409 ,8802 ,23659 ,9130 ,-7793 ,9410 ,15854 ,-3525 ,-17394 ,-22790 , -21864 ,-23718 ,-17626 ,8333 ,2762 ,-18237 ,406 ,12326 ,17040 ,29819 ,-1995 ,-24389 ,-3944 ,-10165 ,-15900 , 601 ,-810 ,-17339 ,-25990 ,-17282 ,-21857 ,-29758 ,-7546 ,-3756 ,-14299 ,3021 ,-4979 ,-27333 ,-6195 ,761 , -13111 ,6522 ,17442 ,5662 ,6907 ,-3721 ,-27384 ,-23553 ,-3852 ,-1140 ,-8418 ,-10711 ,-13491 ,-14372 ,-14148 , -25547 ,-23241 ,8619 ,25162 ,16720 ,10666 ,2364 ,1025 ,17970 ,22414 ,6780 ,-957 ,-4641 ,-17786 ,-16986 , 5292 ,14159 ,-346 ,-10883 ,-9012 ,-6594 ,-8722 ,-16494 ,-23335 ,-17852 ,-5153 ,-3350 ,-14361 ,-13686 ,3395 , 6894 ,-7669 ,-17461 ,-8975 ,7646 ,3084 ,-9502 ,-9778 ,-22290 ,-19900 ,8562 ,-827 ,-16188 ,8486 ,7175 , -3833 ,10445 ,12298 ,2655 ,-1088 ,2295 ,21328 ,32767 ,21419 ,5936 ,-8538 ,-18576 ,-14263 ,-1598 ,3986 , 2875 ,6138 ,3280 ,-5857 ,474 ,6335 ,3943 ,15941 ,20290 ,12490 ,20552 ,19173 ,10115 ,18091 ,821 , -24673 ,-9303 ,-4477 ,-16038 ,-10732 ,-10653 ,-7827 ,-3250 ,-9715 ,-8735 ,-7119 ,-7539 ,6581 ,14218 ,-3691 , -13762 ,-6509 ,-8607 ,-9072 ,-5619 ,-14903 ,-12886 ,-1146 ,-11130 ,-17192 ,-4543 ,-4478 ,-6008 ,1042 ,-6846 , -11644 ,-1739 ,-4298 ,-7042 ,2158 ,-4291 ,-16700 ,-9224 ,158 ,226 ,591 ,-3891 ,-12704 ,-18255 ,-22670 , -16115 ,5867 ,17101 ,6150 ,-5565 ,-8692 ,-11943 ,-13396 ,-10685 ,-12831 ,-18293 ,-16383 ,-3387 ,14406 ,18376 , 9597 ,6691 ,-3781 ,-21372 ,-19288 ,-16973 ,-22566 ,-9453 ,650 ,-4944 ,2017 ,12594 ,11628 ,8358 ,386 , -11515 ,-16737 ,-14149 ,-11541 ,-14355 ,-15970 ,-14606 ,-15856 ,-12986 ,-1603 ,10776 ,13806 ,4822 ,2876 ,15822 , 20373 ,11541 ,3907 ,-5765 ,-16669 ,-14939 ,-5709 ,644 ,8831 ,11976 ,-98 ,-8018 ,3808 ,16356 ,14576 , 9755 ,11443 ,16100 ,21894 ,25865 ,21503 ,10894 ,-2287 ,-9577 ,-5637 ,-9506 ,-16663 ,-9918 ,-265 ,6109 , 5549 ,6474 ,13185 ,13386 ,6183 ,-6687 ,-15175 ,-24243 ,-32767 ,-14709 ,8564 ,10184 ,14819 ,19954 ,8158 , 6995 ,6671 ,-17519 ,-15205 ,13575 ,3342 ,-17852 ,-1429 ,22869 ,27775 ,17952 ,10401 ,8499 ,-2349 ,-2433 , 19206 ,29592 ,27845 ,20834 ,-1030 ,-1691 ,23771 ,18859 ,-1924 ,738 ,7707 ,19113 ,22202 ,-6250 ,-7055 , 22047 ,7042 ,-9105 ,16932 ,21451 ,5432 ,5196 ,-8123 ,-22619 ,-1575 ,20405 ,13842 ,-1389 ,-6014 ,4349 , 10189 ,3967 ,7229 ,9549 ,4296 ,7958 ,-4450 ,-26650 ,-7507 ,24147 ,17184 ,-4850 ,-13547 ,-14984 ,-13749 , -6392 ,273 ,-7290 ,-16294 ,-2602 ,18044 ,23515 ,29323 ,31338 ,1902 ,-25965 ,-8035 ,14104 ,-2211 ,-25144 , -25629 ,-9911 ,3155 ,-2107 ,-3725 ,9979 ,14525 ,16177 ,12216 ,-6063 ,1991 ,17877 ,-2136 ,-14698 ,-14717 , -19468 ,-10653 ,7668 ,13009 ,9354 ,1218 ,3730 ,6894 ,9 ,9320 ,11259 ,-15129 ,-26900 ,-20106 ,-18985 , -13554 ,595 ,3416 ,-7093 ,-9377 ,452 ,7974 ,5420 ,-1987 ,-4610 ,-1564 ,5339 ,10527 ,4774 ,-2098 , -6231 ,-10478 ,-9827 ,-18253 ,-21419 ,-14476 ,-25564 ,-28140 ,-14669 ,-12237 ,-16653 ,-27235 ,-29760 ,-4211 ,12722 , -1104 ,-8454 ,-3993 ,-305 ,1930 ,-10229 ,-18417 ,-9309 ,-10127 ,-13586 ,-5215 ,-6306 ,-13701 ,-15664 ,-25805 , -32756 ,-18081 ,-8268 ,-17602 ,-18220 ,-8519 ,-12350 ,-24961 ,-27084 ,-15781 ,-3681 ,-1121 ,-2350 ,-4844 ,-17997 , -32767 ,-23703 ,1289 ,3877 ,-15701 ,-23347 ,-17928 ,-16639 ,-18602 ,-20701 ,-18473 ,-11142 ,-12454 ,-16594 ,-5181 , 7594 ,6804 ,861 ,-9813 ,-17177 ,-11149 ,-15239 ,-30975 ,-24811 ,-8338 ,-8899 ,-9077 ,737 ,5539 ,5251 , -18 ,-12215 ,-16314 ,-9965 ,-6868 ,-5183 ,-3388 ,-9423 ,-18274 ,-19007 ,-10227 ,-2224 ,-5930 ,-10969 ,-2283 , 7476 ,2522 ,-5466 ,-5219 ,-4150 ,-13376 ,-21929 ,-14210 ,-9547 ,164 ,18543 ,3180 ,-15399 ,1186 ,15473 , 14253 ,12408 ,3280 ,-11904 ,-10019 ,9763 ,19172 ,9715 ,-4198 ,-14067 ,-18376 ,-22444 ,-26626 ,-19864 ,-1569 , 15501 ,18033 ,10888 ,14188 ,23920 ,17688 ,967 ,-8059 ,-10778 ,-11559 ,-12689 ,-8321 ,5873 ,12048 ,11120 , 16353 ,22554 ,28219 ,17085 ,-12635 ,-22382 ,-18371 ,-23451 ,-20394 ,-12391 ,-11165 ,-12310 ,-11929 ,-424 ,7666 , 2031 ,4601 ,3271 ,-11274 ,-12968 ,-9311 ,-8383 ,999 ,7120 ,11339 ,21905 ,25954 ,24023 ,19086 ,9043 , 4826 ,3855 ,3447 ,18496 ,32767 ,19978 ,1997 ,862 ,2413 ,3526 ,11273 ,13254 ,5390 ,1438 ,4739 , 6669 ,-2634 ,-16080 ,-6732 ,20502 ,24990 ,5253 ,-5340 ,-5581 ,-5654 ,2913 ,9439 ,-1850 ,-15459 ,-18045 , -13765 ,-10886 ,-15748 ,-16155 ,-7695 ,-4094 ,3046 ,15039 ,16465 ,15203 ,11137 ,4630 ,10926 ,5629 ,-18449 , -20703 ,-12926 ,-19041 ,-13290 ,-5018 ,-19673 ,-27016 ,-11047 ,3909 ,14227 ,19414 ,10836 ,5479 ,4910 ,-11799 , -20214 ,-3751 ,10473 ,12680 ,15274 ,10339 ,2727 ,1785 ,-12634 ,-25283 ,-3529 ,10041 ,-5692 ,-12208 ,-12360 , -20652 ,-21843 ,-9980 ,-2140 ,-1661 ,-1048 ,-4456 ,-5449 ,-5755 ,-14095 ,-19894 ,-23703 ,-23231 ,-11547 ,-8302 , -8237 ,3310 ,3088 ,-5995 ,-6631 ,-8390 ,-11240 ,-17078 ,-20747 ,-5577 ,3504 ,-10455 ,-19040 ,-11812 ,-1661 , -1538 ,-10264 ,-10429 ,-3996 ,-1738 ,-4210 ,-11160 ,-10060 ,-2505 ,-6562 ,-8720 ,-3135 ,-10744 ,-18998 ,-16220 , -24464 ,-32767 ,-18866 ,-9544 ,-20617 ,-26913 ,-19584 ,-13676 ,-17934 ,-23533 ,-18326 ,-10191 ,-8697 ,-7087 ,-5012 , -11203 ,-21931 ,-21082 ,-9643 ,-10243 ,-21357 ,-21786 ,-16762 ,-14929 ,-11918 ,-14853 ,-18921 ,-9651 ,-3642 ,-11793 , -14362 ,-8448 ,-4300 ,-2765 ,-9493 ,-17847 ,-14918 ,-16399 ,-26721 ,-23045 ,-11543 ,-9818 ,-8509 ,-5568 ,-6622 , -3758 ,-1295 ,-5478 ,-4412 ,-281 ,-1206 ,867 ,1617 ,-6258 ,-11943 ,-12084 ,-9769 ,-4662 ,-4321 ,-7603 , -4121 ,-2122 ,-6834 ,-9812 ,-9483 ,-3082 ,539 ,-1278 ,914 ,-4229 ,-3492 ,11802 ,10745 ,2464 ,6796 , 9025 ,9359 ,10435 ,-1205 ,-15720 ,-15194 ,-8135 ,-4151 ,-2746 ,-6651 ,-12599 ,-8193 ,6616 ,11151 ,232 , -566 ,14875 ,22796 ,17702 ,14057 ,16441 ,17994 ,11885 ,-370 ,-7356 ,-2629 ,2266 ,942 ,3815 ,6800 , 3726 ,4889 ,3027 ,-2896 ,8423 ,22394 ,18734 ,14882 ,14536 ,10616 ,12079 ,13521 ,8045 ,10271 ,17310 , 10425 ,781 ,5857 ,15842 ,16194 ,3683 ,-5776 ,3161 ,9584 ,-340 ,-7847 ,-4385 ,8580 ,17525 ,6693 , 32 ,11305 ,15959 ,11379 ,4887 ,-1102 ,8368 ,17787 ,6752 ,1700 ,3745 ,-5731 ,1169 ,19880 ,15997 , 16653 ,29385 ,18107 ,2128 ,5998 ,10787 ,9020 ,4990 ,9099 ,27434 ,32767 ,16669 ,7852 ,7526 ,4105 , 4650 ,3188 ,-2578 ,3012 ,11725 ,10423 ,9387 ,10176 ,10245 ,11999 ,5417 ,-1295 ,8488 ,14040 ,11891 , 23655 ,20935 ,-8853 ,-12397 ,11489 ,12259 ,-3240 ,-4828 ,2080 ,5541 ,2319 ,-2652 ,1536 ,8940 ,8286 , 5030 ,3874 ,3097 ,1124 ,-6515 ,-14594 ,-17677 ,-21790 ,-16550 ,-1391 ,-1129 ,-9297 ,-12543 ,-16465 ,-15688 , -9283 ,-6732 ,-6931 ,-5612 ,-6599 ,-8979 ,-9513 ,-12429 ,-18740 ,-22354 ,-19209 ,-13678 ,-11106 ,-8190 ,-3550 , -5207 ,-11349 ,-12240 ,-14325 ,-18505 ,-13671 ,-8828 ,-7514 ,-4547 ,-13029 ,-21995 ,-17689 ,-23613 ,-32767 ,-24338 , -17350 ,-16196 ,-12124 ,-13112 ,-14893 ,-13118 ,-13883 ,-14976 ,-15354 ,-16032 ,-16731 ,-20462 ,-26525 ,-32145 ,-31514 , -21959 ,-19045 ,-28130 ,-31143 ,-26048 ,-24859 ,-25277 ,-22430 ,-20427 ,-21293 ,-21637 ,-21166 ,-21269 ,-19491 ,-17297 , -17250 ,-16975 ,-21120 ,-30865 ,-32584 ,-24370 ,-18856 ,-20128 ,-24201 ,-24863 ,-21322 ,-22232 ,-25613 ,-21410 ,-16336 , -18015 ,-19735 ,-18589 ,-14151 ,-9323 ,-16211 ,-27842 ,-27895 ,-24421 ,-23544 ,-21376 ,-21168 ,-17069 ,-8898 ,-10377 , -14181 ,-10023 ,-7112 ,-7471 ,-8683 ,-12314 ,-12483 ,-9925 ,-12338 ,-14518 ,-12747 ,-13728 ,-14133 ,-8336 ,-3432 , -3442 ,-6248 ,-7592 ,-4575 ,-3364 ,-3097 ,-480 ,2071 ,5014 ,2088 ,-2346 ,2964 ,8261 ,10804 ,15538 , 13560 ,7702 ,5831 ,1483 ,-5071 ,-8584 ,-8878 ,-6501 ,-4186 ,-2266 ,-2678 ,-1315 ,12668 ,22087 ,11599 , 4978 ,13083 ,21384 ,22165 ,16774 ,15376 ,17871 ,15805 ,15572 ,14645 ,7923 ,7793 ,11787 ,10940 ,10505 , 10269 ,8106 ,3627 ,-154 ,9988 ,27723 ,32767 ,30093 ,28585 ,25090 ,25453 ,30376 ,28165 ,22232 ,21785 , 18167 ,11268 ,17935 ,28771 ,23113 ,13840 ,13585 ,13645 ,12359 ,9626 ,6710 ,12230 ,19325 ,17291 ,14022 , 18293 ,26455 ,26934 ,16233 ,9587 ,15597 ,21264 ,17312 ,10730 ,8538 ,8772 ,9136 ,11132 ,13370 ,12480 , 10258 ,10184 ,11703 ,14982 ,21485 ,23651 ,14920 ,10581 ,20820 ,27950 ,25952 ,24525 ,18950 ,10895 ,9034 , 6614 ,3979 ,7339 ,10006 ,11172 ,13198 ,9980 ,4803 ,6689 ,11373 ,11139 ,10145 ,12182 ,10681 ,8098 , 14008 ,19572 ,15188 ,10744 ,9822 ,4906 ,50 ,1918 ,3600 ,-245 ,-2394 ,-476 ,883 ,3048 ,2878 , -1529 ,-2386 ,-1198 ,-2910 ,-5361 ,-9012 ,-15634 ,-15810 ,-4552 ,1404 ,1153 ,1262 ,-4289 ,-10039 ,-7782 , -2961 ,-5732 ,-11354 ,-12045 ,-12303 ,-13043 ,-12961 ,-13073 ,-14335 ,-18481 ,-17982 ,-9982 ,-6316 ,-6660 ,-6912 , -11589 ,-15014 ,-15069 ,-17739 ,-18339 ,-14413 ,-12162 ,-14243 ,-15437 ,-12711 ,-16217 ,-25006 ,-26068 ,-25727 ,-28268 , -28497 ,-30283 ,-26788 ,-17430 ,-18475 ,-23892 ,-23559 ,-22495 ,-21075 ,-22896 ,-27931 ,-27840 ,-27570 ,-31370 ,-31873 , -28321 ,-26833 ,-29466 ,-30394 ,-27436 ,-27807 ,-30229 ,-28411 ,-25636 ,-25034 ,-26231 ,-28299 ,-28100 ,-26192 ,-25137 , -23977 ,-23200 ,-25064 ,-28829 ,-32298 ,-32767 ,-27756 ,-22393 ,-23768 ,-26913 ,-26775 ,-27018 ,-26509 ,-23224 ,-20837 , -21956 ,-25277 ,-24302 ,-19626 ,-19509 ,-20712 ,-21064 ,-24833 ,-26787 ,-24711 ,-22485 ,-21871 ,-23242 ,-19636 ,-13334 , -15079 ,-15977 ,-10864 ,-10265 ,-11901 ,-12664 ,-15727 ,-15609 ,-13107 ,-14305 ,-14574 ,-12594 ,-13104 ,-12244 ,-7633 , -5302 ,-5126 ,-6501 ,-7796 ,-3184 ,922 ,-274 ,-4983 ,-8168 ,-5103 ,-3727 ,-2082 ,3724 ,4133 ,1413 , 3205 ,6529 ,7660 ,6074 ,3890 ,4211 ,5556 ,7384 ,9978 ,9366 ,5927 ,3222 ,3831 ,8597 ,8457 , 2197 ,4405 ,12578 ,14270 ,13104 ,11618 ,8024 ,7733 ,11022 ,12921 ,14947 ,18139 ,19000 ,18425 ,17640 , 13116 ,10386 ,16590 ,20613 ,17326 ,18273 ,20713 ,17368 ,15208 ,15340 ,15645 ,21163 ,28276 ,28771 ,25559 , 25270 ,26082 ,24021 ,23074 ,23398 ,20375 ,18603 ,18574 ,17517 ,21057 ,24610 ,23821 ,26771 ,30701 ,32572 , 32767 ,23576 ,14084 ,15512 ,17416 ,16269 ,16056 ,16279 ,16958 ,16369 ,19211 ,25214 ,24359 ,22231 ,21986 , 16473 ,13644 ,16446 ,17201 ,18570 ,21120 ,22788 ,26044 ,28211 ,27600 ,25913 ,22361 ,19582 ,18762 ,17588 , 20656 ,26731 ,24485 ,17515 ,15553 ,13711 ,11708 ,15590 ,18357 ,14923 ,12053 ,12300 ,12868 ,10598 ,4929 , 4238 ,12562 ,17540 ,11809 ,5423 ,4288 ,3820 ,4589 ,7087 ,5137 ,-482 ,-3364 ,-2769 ,-1775 ,-3272 , -4528 ,-2904 ,-2535 ,526 ,3292 ,3841 ,2509 ,676 ,483 ,406 ,-1305 ,-2690 ,-5175 ,-7483 ,-9952 , -13083 ,-11361 ,-7785 ,-8286 ,-9141 ,-8994 ,-10748 ,-12352 ,-12364 ,-13993 ,-17351 ,-18602 ,-17516 ,-16203 ,-14367 , -12874 ,-13880 ,-15300 ,-14708 ,-16132 ,-20485 ,-20824 ,-17777 ,-16153 ,-15008 ,-17763 ,-23388 ,-23517 ,-23426 ,-27319 , -26577 ,-22633 ,-21962 ,-22331 ,-22116 ,-22363 ,-22955 ,-22927 ,-22641 ,-23136 ,-23010 ,-23510 ,-25847 ,-26789 ,-28907 , -32767 ,-30071 ,-24579 ,-26646 ,-31368 ,-31626 ,-30405 ,-30160 ,-29656 ,-29076 ,-29061 ,-28043 ,-26391 ,-27542 ,-29307 , -27808 ,-25788 ,-24559 ,-24751 ,-28179 ,-29585 ,-27197 ,-25837 ,-25099 ,-25590 ,-27430 ,-26837 ,-25324 ,-23816 ,-22372 , -22527 ,-21403 ,-21392 ,-23596 ,-22093 ,-21949 ,-24874 ,-23706 ,-23058 ,-23938 ,-21897 ,-21764 ,-22431 ,-20130 ,-18176 , -17139 ,-17761 ,-18814 ,-15892 ,-12936 ,-12622 ,-11668 ,-11819 ,-12595 ,-10883 ,-9875 ,-10400 ,-9634 ,-8857 ,-7975 , -6084 ,-6649 ,-7832 ,-7520 ,-7657 ,-4707 ,-1777 ,-2259 ,-1796 ,-1822 ,-1400 ,1479 ,2695 ,2642 ,4642 , 5936 ,6258 ,10066 ,12939 ,10661 ,8840 ,8410 ,7153 ,7708 ,8730 ,8168 ,8769 ,9166 ,8809 ,11307 , 12139 ,8689 ,9576 ,14652 ,16931 ,19327 ,21589 ,18725 ,17073 ,20181 ,21059 ,20853 ,22889 ,23081 ,21545 , 20474 ,19894 ,20616 ,20875 ,20619 ,20337 ,18558 ,20896 ,27783 ,29499 ,27017 ,26618 ,28390 ,30706 ,30225 , 28615 ,29638 ,28756 ,25504 ,24738 ,25720 ,28404 ,30735 ,27258 ,23452 ,26059 ,28308 ,25243 ,22565 ,24537 , 28789 ,29978 ,26663 ,25286 ,29589 ,32767 ,29167 ,24285 ,25142 ,28622 ,28055 ,24568 ,22939 ,23144 ,23322 , 23800 ,24328 ,23698 ,22459 ,21736 ,21620 ,22479 ,24872 ,26694 ,23980 ,19900 ,22103 ,26658 ,26479 ,25076 , 23243 ,19067 ,16810 ,15718 ,13485 ,13813 ,15353 ,15493 ,16098 ,15313 ,12244 ,11288 ,13057 ,13589 ,12512 , 12552 ,12230 ,10270 ,10822 ,13229 ,12281 ,9806 ,8896 ,7258 ,4771 ,4134 ,4519 ,3495 ,2089 ,1940 , 1871 ,1779 ,1608 ,296 , // sounds/wavetables/BRAIDS01.WAV -5257 ,-7083 ,-6068 ,-5581 ,-4992 ,-5231 ,-5330 ,-4957 ,-4573 ,-4235 ,-4085 ,-3790 ,-3386 ,-3096 ,-3000 , -2928 ,-2617 ,-2064 ,-1499 ,-1150 ,-1045 ,-1049 ,-1009 ,-840 ,-528 ,-122 ,278 ,573 ,739 ,859 , 1055 ,1378 ,1764 ,2101 ,2321 ,2446 ,2558 ,2745 ,3056 ,3465 ,3874 ,4167 ,4300 ,4345 ,4416 , 4575 ,4794 ,5011 ,5187 ,5297 ,5321 ,5257 ,5157 ,5096 ,5105 ,5134 ,5113 ,5022 ,4888 ,4738 , 4572 ,4374 ,4140 ,3863 ,3539 ,3188 ,2855 ,2566 ,2275 ,1876 ,1298 ,556 ,-262 ,-1063 ,-1795 , -2448 ,-3065 ,-3747 ,-4614 ,-5704 ,-6910 ,-8039 ,-8953 ,-9655 ,-10254 ,-10856 ,-11500 ,-12170 ,-12821 ,-13389 , -13804 ,-14025 ,-14094 ,-14095 ,-14066 ,-13933 ,-13584 ,-12994 ,-12264 ,-11522 ,-10787 ,-9954 ,-8912 ,-7641 ,-6202 , -4652 ,-3009 ,-1290 ,450 ,2168 ,3894 ,5706 ,7635 ,9617 ,11557 ,13437 ,15321 ,17266 ,19249 ,21185 , 22967 ,24495 ,25697 ,26628 ,27522 ,28659 ,30092 ,31493 ,32361 ,32431 ,31885 ,31165 ,30593 ,30189 ,29795 , 29278 ,28597 ,27736 ,26671 ,25412 ,24034 ,22637 ,21262 ,19877 ,18423 ,16897 ,15363 ,13904 ,12541 ,11193 , 9733 ,8103 ,6389 ,4763 ,3346 ,2125 ,1001 ,-114 ,-1253 ,-2420 ,-3609 ,-4784 ,-5871 ,-6823 ,-7686 , -8560 ,-9477 ,-10335 ,-10994 ,-11434 ,-11792 ,-12231 ,-12787 ,-13359 ,-13828 ,-14151 ,-14341 ,-14398 ,-14324 ,-14179 , -14092 ,-14155 ,-14326 ,-14436 ,-14339 ,-14015 ,-13571 ,-13139 ,-12794 ,-12530 ,-12291 ,-11982 ,-11521 ,-10902 ,-10230 , -9654 ,-9234 ,-8876 ,-8427 ,-7832 ,-7185 ,-6612 ,-6137 ,-5667 ,-5115 ,-4487 ,-3857 ,-3285 ,-2792 ,-2386 , -2071 ,-1809 ,-1520 ,-1153 ,-775 ,-534 ,-513 ,-641 ,-761 ,-787 ,-775 ,-838 ,-1020 ,-1273 ,-1533 , -1790 ,-2055 ,-2317 ,-2554 ,-2786 ,-3073 ,-3446 ,-3846 ,-4160 ,-4339 ,-4454 ,-4622 ,-4869 ,-5109 ,-5264 , -5387 ,-5592 ,-5863 ,-6019 ,-5953 ,-5849 ,-6004 ,-6404 ,-6643 ,-6424 ,-6039 ,-6083 ,-6613 ,-6828 ,-5859 , -3822 ,-1837 ,-915 ,-1023 ,-1373 ,-1444 ,-1437 ,-1747 ,-2321 ,-2742 ,-2807 ,-2728 ,-2760 ,-2846 ,-2771 , -2554 ,-2496 ,-2822 ,-3391 ,-3822 ,-3869 ,-3615 ,-3344 ,-3290 ,-3500 ,-3875 ,-4271 ,-4583 ,-4777 ,-4874 , -4904 ,-4866 ,-4750 ,-4596 ,-4519 ,-4626 ,-4885 ,-5099 ,-5037 ,-4632 ,-4050 ,-3554 ,-3271 ,-3111 ,-2886 , -2509 ,-2045 ,-1600 ,-1181 ,-692 ,-56 ,687 ,1386 ,1872 ,2053 ,1976 ,1828 ,1851 ,2191 ,2771 , 3331 ,3616 ,3563 ,3308 ,3035 ,2828 ,2672 ,2554 ,2509 ,2560 ,2631 ,2567 ,2267 ,1775 ,1243 , 799 ,467 ,210 ,-4 ,-199 ,-439 ,-832 ,-1449 ,-2239 ,-3030 ,-3642 ,-4025 ,-4307 ,-4717 ,-5400 , -6292 ,-7169 ,-7862 ,-8418 ,-9027 ,-9784 ,-10570 ,-11186 ,-11576 ,-11866 ,-12174 ,-12451 ,-12540 ,-12375 ,-12055 , -11699 ,-11266 ,-10560 ,-9421 ,-7882 ,-6143 ,-4399 ,-2706 ,-983 ,899 ,3042 ,5489 ,8198 ,11038 ,13857 , 16564 ,19111 ,21383 ,23189 ,24496 ,25643 ,27153 ,29184 ,31180 ,32230 ,31864 ,30484 ,28968 ,27908 ,27250 , 26572 ,25556 ,24163 ,22482 ,20588 ,18564 ,16566 ,14787 ,13363 ,12301 ,11479 ,10698 ,9765 ,8617 ,7389 , 6338 ,5665 ,5383 ,5347 ,5387 ,5397 ,5320 ,5110 ,4759 ,4347 ,4016 ,3859 ,3835 ,3809 ,3661 , 3366 ,2969 ,2520 ,2047 ,1573 ,1130 ,736 ,379 ,24 ,-360 ,-785 ,-1255 ,-1783 ,-2385 ,-3075 , -3835 ,-4610 ,-5318 ,-5881 ,-6296 ,-6668 ,-7169 ,-7915 ,-8852 ,-9759 ,-10402 ,-10708 ,-10787 ,-10807 ,-10857 , -10945 ,-11090 ,-11321 ,-11593 ,-11730 ,-11550 ,-11031 ,-10351 ,-9728 ,-9264 ,-8940 ,-8698 ,-8478 ,-8174 ,-7648 , -6848 ,-5912 ,-5099 ,-4598 ,-4398 ,-4345 ,-4278 ,-4118 ,-3861 ,-3551 ,-3269 ,-3108 ,-3122 ,-3295 ,-3564 , -3865 ,-4143 ,-4338 ,-4406 ,-4351 ,-4229 ,-4114 ,-4052 ,-4061 ,-4116 ,-4146 ,-4053 ,-3780 ,-3359 ,-2875 , -2406 ,-2007 ,-1719 ,-1532 ,-1354 ,-1107 ,-876 ,-828 ,-927 ,-840 ,-348 ,205 ,162 ,-566 ,-1054 , -152 ,2217 ,4778 ,6093 ,5894 ,5112 ,4726 ,4880 ,5117 ,5126 ,4995 ,4858 ,4638 ,4255 ,3863 , 3711 ,3799 ,3846 ,3616 ,3183 ,2803 ,2621 ,2557 ,2467 ,2314 ,2158 ,2040 ,1931 ,1793 ,1643 , 1544 ,1520 ,1520 ,1459 ,1302 ,1113 ,995 ,997 ,1062 ,1078 ,978 ,783 ,565 ,371 ,199 , 18 ,-197 ,-470 ,-824 ,-1262 ,-1740 ,-2195 ,-2605 ,-3026 ,-3547 ,-4199 ,-4893 ,-5478 ,-5866 ,-6121 , -6412 ,-6863 ,-7420 ,-7905 ,-8189 ,-8318 ,-8452 ,-8687 ,-8960 ,-9145 ,-9204 ,-9209 ,-9244 ,-9323 ,-9428 , -9573 ,-9783 ,-10017 ,-10183 ,-10245 ,-10290 ,-10440 ,-10718 ,-11026 ,-11278 ,-11499 ,-11780 ,-12147 ,-12527 ,-12838 , -13076 ,-13300 ,-13552 ,-13820 ,-14084 ,-14346 ,-14600 ,-14790 ,-14829 ,-14670 ,-14362 ,-14030 ,-13794 ,-13683 ,-13596 , -13347 ,-12774 ,-11861 ,-10775 ,-9759 ,-8937 ,-8182 ,-7192 ,-5728 ,-3811 ,-1720 ,224 ,1879 ,3359 ,4940 , 6890 ,9313 ,12034 ,14630 ,16663 ,18031 ,19148 ,20654 ,22858 ,25406 ,27558 ,28809 ,29268 ,29468 ,29883 , 30632 ,31522 ,32241 ,32512 ,32206 ,31448 ,30597 ,30014 ,29778 ,29619 ,29162 ,28229 ,26934 ,25544 ,24303 , 23325 ,22551 ,21751 ,20658 ,19189 ,17562 ,16144 ,15116 ,14325 ,13445 ,12282 ,10901 ,9500 ,8226 ,7115 , 6132 ,5192 ,4176 ,2987 ,1653 ,345 ,-756 ,-1620 ,-2392 ,-3255 ,-4289 ,-5439 ,-6585 ,-7624 ,-8506 , -9271 ,-10040 ,-10948 ,-12021 ,-13121 ,-14057 ,-14778 ,-15430 ,-16196 ,-17077 ,-17856 ,-18323 ,-18481 ,-18529 ,-18654 , -18845 ,-18961 ,-18899 ,-18679 ,-18356 ,-17923 ,-17342 ,-16631 ,-15876 ,-15117 ,-14288 ,-13294 ,-12156 ,-11023 ,-10042 , -9209 ,-8380 ,-7416 ,-6302 ,-5146 ,-4100 ,-3285 ,-2735 ,-2358 ,-1983 ,-1476 ,-862 ,-316 ,-6 ,50 , -12 ,-32 ,70 ,263 ,455 ,531 ,431 ,214 ,42 ,55 ,243 ,456 ,563 ,555 ,510 , 489 ,546 ,769 ,1225 ,1805 ,2225 ,2295 ,2183 ,2283 ,2773 ,3403 ,3804 ,3953 ,4161 ,4561 , 4794 ,4351 ,3186 ,1809 ,740 ,2 ,-732 ,-1585 ,-2268 ,-2449 ,-2200 ,-1968 ,-2119 ,-2584 ,-2951 , -2831 ,-2161 ,-1244 ,-526 ,-300 ,-490 ,-728 ,-665 ,-285 ,75 ,15 ,-595 ,-1537 ,-2446 ,-3084 , -3474 ,-3814 ,-4285 ,-4902 ,-5499 ,-5837 ,-5739 ,-5182 ,-4288 ,-3259 ,-2268 ,-1350 ,-379 ,838 ,2366 , 4029 ,5485 ,6463 ,6937 ,7108 ,7193 ,7224 ,7022 ,6347 ,5092 ,3380 ,1489 ,-309 ,-1884 ,-3273 , -4600 ,-5947 ,-7269 ,-8381 ,-9028 ,-9036 ,-8457 ,-7597 ,-6814 ,-6228 ,-5599 ,-4532 ,-2856 ,-826 ,1046 , 2332 ,2935 ,3083 ,3168 ,3531 ,4235 ,4955 ,5150 ,4485 ,3184 ,1930 ,1373 ,1656 ,2374 ,2932 , 2997 ,2734 ,2730 ,3624 ,5616 ,8190 ,10381 ,11489 ,11673 ,11826 ,12783 ,14535 ,16147 ,16440 ,14834 , 11724 ,8165 ,5169 ,3055 ,1224 ,-1454 ,-5817 ,-11629 ,-17498 ,-21709 ,-23440 ,-23381 ,-23158 ,-24004 ,-25740 , -26874 ,-25685 ,-21467 ,-15062 ,-8358 ,-3057 ,488 ,3507 ,7805 ,14211 ,21745 ,28246 ,31951 ,32689 ,31810 , 31065 ,31392 ,32386 ,32626 ,30632 ,25915 ,19496 ,13383 ,9206 ,7032 ,5371 ,2452 ,-2300 ,-7822 ,-12276 , -14417 ,-14364 ,-13341 ,-12764 ,-13326 ,-14619 ,-15478 ,-14845 ,-12595 ,-9690 ,-7491 ,-6737 ,-7044 ,-7303 ,-6583 , -4755 ,-2465 ,-615 ,214 ,117 ,-154 ,366 ,2158 ,4791 ,7191 ,8487 ,8707 ,8687 ,9302 ,10764 , 12534 ,13798 ,14003 ,13106 ,11530 ,9902 ,8673 ,7791 ,6695 ,4735 ,1712 ,-1918 ,-5365 ,-8051 ,-9934 , -11429 ,-13077 ,-15162 ,-17490 ,-19427 ,-20265 ,-19714 ,-18163 ,-16396 ,-14977 ,-13801 ,-12246 ,-9753 ,-6324 ,-2533 , 896 ,3551 ,5516 ,7213 ,9070 ,11201 ,13274 ,14674 ,14908 ,13977 ,12408 ,10871 ,9674 ,8578 ,7049 , 4730 ,1737 ,-1390 ,-4018 ,-5798 ,-6870 ,-7743 ,-8912 ,-10461 ,-11968 ,-12806 ,-12608 ,-11543 ,-10197 ,-9164 , -8630 ,-8267 ,-7514 ,-6054 ,-4080 ,-2138 ,-713 ,70 ,431 ,738 ,1317 ,2277 ,3347 ,3928 ,3548 , 2421 ,1492 ,1703 ,3136 ,4956 ,6238 ,6786 ,7091 ,7604 ,8261 ,8719 ,8882 ,8997 ,9286 ,9656 , 9855 ,9813 ,9695 ,9643 ,9575 ,9291 ,8747 ,8127 ,7627 ,7226 ,6691 ,5834 ,4726 ,3633 ,2750 , 2007 ,1156 ,31 ,-1291 ,-2581 ,-3676 ,-4597 ,-5477 ,-6403 ,-7342 ,-8193 ,-8894 ,-9470 ,-9992 ,-10495 , -10943 ,-11271 ,-11450 ,-11501 ,-11451 ,-11296 ,-11034 ,-10704 ,-10370 ,-10048 ,-9664 ,-9139 ,-8478 ,-7761 ,-7051 , -6322 ,-5527 ,-4676 ,-3831 ,-3018 ,-2192 ,-1318 ,-453 ,282 ,827 ,1260 ,1731 ,2321 ,2978 ,3568 , 3964 ,4110 ,4032 ,3830 ,3646 ,3586 ,3621 ,3592 ,3326 ,2799 ,2155 ,1556 ,1033 ,497 ,-117 , -768 ,-1393 ,-2025 ,-2764 ,-3633 ,-4519 ,-5304 ,-6007 ,-6743 ,-7560 ,-8355 ,-9012 ,-9560 ,-10162 ,-10932 , -11806 ,-12603 ,-13181 ,-13523 ,-13713 ,-13854 ,-14038 ,-14315 ,-14646 ,-14862 ,-14720 ,-14071 ,-12995 ,-11778 ,-10689 , -9729 ,-8595 ,-6908 ,-4549 ,-1797 ,855 ,3077 ,4952 ,6911 ,9401 ,12537 ,15994 ,19212 ,21747 ,23529 , 24853 ,26140 ,27663 ,29403 ,31075 ,32293 ,32766 ,32469 ,31665 ,30758 ,30016 ,29404 ,28635 ,27417 ,25668 , 23531 ,21237 ,18957 ,16745 ,14578 ,12418 ,10259 ,8144 ,6110 ,4128 ,2101 ,-17 ,-2123 ,-4010 ,-5537 , -6748 ,-7784 ,-8740 ,-9627 ,-10471 ,-11347 ,-12250 ,-13002 ,-13371 ,-13329 ,-13127 ,-13074 ,-13257 ,-13520 ,-13663 , -13631 ,-13476 ,-13245 ,-12946 ,-12602 ,-12274 ,-11989 ,-11689 ,-11289 ,-10778 ,-10228 ,-9711 ,-9218 ,-8660 ,-7936 , -7002 ,-5889 ,-4702 ,-3580 ,-2618 ,-1797 ,-978 ,2 ,1210 ,2565 ,3908 ,5106 ,6111 ,6932 ,7602 , 8167 ,8695 ,9242 ,9786 ,10216 ,10397 ,10257 ,9829 ,9206 ,8474 ,7680 ,6826 ,5896 ,4889 ,3825 , 2724 ,1552 ,226 ,-1295 ,-2900 ,-4344 ,-5419 ,-6139 ,-6732 ,-7443 ,-8319 ,-9183 ,-9795 ,-10027 ,-9932 , -9681 ,-9438 ,-9259 ,-9055 ,-8668 ,-8019 ,-7194 ,-6367 ,-5610 ,-4822 ,-3868 ,-2780 ,-1746 ,-880 ,-73 , 859 ,1895 ,2800 ,3458 ,4128 ,5256 ,6965 ,8831 ,10224 ,10860 ,10968 ,10930 ,10855 ,10541 ,9793 , 8685 ,7491 ,6400 ,5350 ,4106 ,2478 ,500 ,-1555 ,-3318 ,-4513 ,-5127 ,-5435 ,-5885 ,-6859 ,-8442 , -10344 ,-12048 ,-13134 ,-13538 ,-13557 ,-13612 ,-13952 ,-14533 ,-15067 ,-15170 ,-14517 ,-12985 ,-10755 ,-8260 ,-5953 , -4034 ,-2347 ,-566 ,1482 ,3627 ,5456 ,6626 ,7113 ,7182 ,7111 ,6914 ,6333 ,5100 ,3226 ,1058 , -915 ,-2345 ,-3206 ,-3800 ,-4589 ,-5916 ,-7759 ,-9719 ,-11299 ,-12276 ,-12830 ,-13341 ,-14074 ,-15063 ,-16220 , -17450 ,-18604 ,-19417 ,-19581 ,-18968 ,-17775 ,-16372 ,-15000 ,-13562 ,-11725 ,-9237 ,-6197 ,-3040 ,-242 ,2012 , 3892 ,5666 ,7359 ,8679 ,9258 ,8971 ,8000 ,6662 ,5210 ,3818 ,2646 ,1824 ,1339 ,988 ,509 , -222 ,-1089 ,-1816 ,-2150 ,-2038 ,-1736 ,-1785 ,-2804 ,-5146 ,-8575 ,-12241 ,-15075 ,-16449 ,-16666 ,-16814 , -17938 ,-20055 ,-21885 ,-21672 ,-18569 ,-13388 ,-8035 ,-4035 ,-1398 ,1233 ,5346 ,11300 ,18025 ,23775 ,27277 , 28445 ,28275 ,28127 ,28887 ,30490 ,32050 ,32488 ,31253 ,28685 ,25781 ,23542 ,22387 ,22022 ,21761 ,20978 , 19360 ,16914 ,13889 ,10729 ,7954 ,5909 ,4521 ,3316 ,1774 ,-260 ,-2467 ,-4330 ,-5495 ,-5925 ,-5797 , -5331 ,-4678 ,-3883 ,-2871 ,-1501 ,272 ,2281 ,4218 ,5901 ,7459 ,9207 ,11310 ,13580 ,15616 ,17132 , 18119 ,18710 ,18980 ,18919 ,18589 ,18193 ,17908 ,17655 ,17093 ,15865 ,13874 ,11283 ,8315 ,5089 ,1674 , -1752 ,-4920 ,-7725 ,-10473 ,-13776 ,-18024 ,-22826 ,-26984 ,-29147 ,-28739 ,-26389 ,-23489 ,-21238 ,-19925 ,-18940 , -17364 ,-14598 ,-10614 ,-5887 ,-1162 ,2827 ,5653 ,7402 ,8583 ,9755 ,11131 ,12519 ,13622 ,14349 ,14818 , 15107 ,15090 ,14572 ,13557 ,12318 ,11172 ,10208 ,9229 ,7961 ,6297 ,4336 ,2230 ,9 ,-2420 ,-5132 , -8016 ,-10727 ,-12788 ,-13864 ,-14071 ,-14035 ,-14492 ,-15630 ,-16839 ,-17217 ,-16377 ,-14639 ,-12493 ,-10128 ,-7708 , -5786 ,-4863 ,-4387 ,-2693 ,1432 ,7126 ,11870 ,13758 ,13112 ,11681 ,10634 ,9822 ,8842 ,8049 ,8014 , 8379 ,7960 ,6169 ,3885 ,2541 ,2522 ,2824 ,2287 ,830 ,-682 ,-1552 ,-1930 ,-2443 ,-3427 ,-4672 , -5766 ,-6528 ,-7092 ,-7697 ,-8437 ,-9202 ,-9845 ,-10394 ,-11034 ,-11800 ,-12365 ,-12342 ,-11876 ,-11724 ,-12480 , -13759 ,-14412 ,-13750 ,-12406 ,-11761 ,-12525 ,-14041 ,-15005 ,-14712 ,-13524 ,-12321 ,-11726 ,-11835 ,-12396 ,-13046 , -13438 ,-13326 ,-12661 ,-11642 ,-10672 ,-10217 ,-10521 ,-11308 ,-11810 ,-11319 ,-9898 ,-8473 ,-8052 ,-8790 ,-9867 , -10302 ,-9812 ,-8880 ,-8167 ,-8011 ,-8397 ,-9125 ,-9852 ,-10153 ,-9802 ,-9081 ,-8660 ,-9029 ,-10024 ,-10954 , -11199 ,-10729 ,-10094 ,-9959 ,-10577 ,-11581 ,-12285 ,-12259 ,-11688 ,-11176 ,-11189 ,-11689 ,-12278 ,-12562 ,-12358 , -11714 ,-10913 ,-10422 ,-10571 ,-11113 ,-11252 ,-10343 ,-8619 ,-7085 ,-6594 ,-7067 ,-7647 ,-7467 ,-6237 ,-4260 , -2197 ,-819 ,-589 ,-1145 ,-1257 ,268 ,3357 ,6460 ,7878 ,7433 ,6706 ,7523 ,10229 ,13517 ,15825 , 16729 ,16991 ,17515 ,18566 ,19909 ,21362 ,22930 ,24489 ,25653 ,26157 ,26262 ,26604 ,27575 ,28936 ,30095 , 30694 ,30875 ,31029 ,31390 ,31906 ,32376 ,32635 ,32621 ,32367 ,31989 ,31633 ,31365 ,31092 ,30622 ,29814 , 28713 ,27548 ,26586 ,25929 ,25385 ,24525 ,22974 ,20758 ,18407 ,16648 ,15832 ,15570 ,14924 ,13142 ,10349 , 7553 ,5817 ,5280 ,4969 ,3661 ,1016 ,-2127 ,-4559 ,-5785 ,-6319 ,-7056 ,-8455 ,-10302 ,-12100 ,-13556 , -14731 ,-15841 ,-16967 ,-17973 ,-18679 ,-19145 ,-19734 ,-20760 ,-22074 ,-23066 ,-23230 ,-22687 ,-22082 ,-21921 ,-22133 , -22316 ,-22246 ,-21983 ,-21551 ,-20792 ,-19678 ,-18567 ,-17901 ,-17612 ,-17086 ,-15834 ,-14108 ,-12650 ,-11865 ,-11371 , -10454 ,-8864 ,-7067 ,-5744 ,-5108 ,-4714 ,-3869 ,-2250 ,-201 ,1544 ,2473 ,2746 ,3043 ,3964 ,5533 , 7267 ,8629 ,9381 ,9601 ,9580 ,9768 ,10612 ,12154 ,13734 ,14360 ,13653 ,12395 ,11914 ,12784 ,14265 , 15158 ,15086 ,14671 ,14435 ,13902 ,12138 ,9140 ,6298 ,5201 ,6031 ,7346 ,7464 ,5970 ,3882 ,2533 , 2447 ,3145 ,3747 ,3619 ,2621 ,1043 ,-551 ,-1531 ,-1518 ,-683 ,264 ,509 ,-293 ,-1796 ,-3265 , -4108 ,-4172 ,-3676 ,-3002 ,-2550 ,-2605 ,-3158 ,-3835 ,-4122 ,-3801 ,-3142 ,-2636 ,-2543 ,-2717 ,-2829 , -2668 ,-2192 ,-1429 ,-474 ,411 ,835 ,606 ,56 ,-89 ,687 ,2127 ,3325 ,3523 ,2874 ,2338 , 2729 ,3838 ,4575 ,4071 ,2636 ,1575 ,2000 ,3806 ,5739 ,6414 ,5326 ,3082 ,918 ,-26 ,705 , 2586 ,4272 ,4347 ,2337 ,-801 ,-3268 ,-3765 ,-2478 ,-876 ,-563 ,-2179 ,-5119 ,-8061 ,-9751 ,-9615 , -8037 ,-6241 ,-5717 ,-7337 ,-10680 ,-14162 ,-16025 ,-15535 ,-13481 ,-11595 ,-11345 ,-12994 ,-15538 ,-17445 ,-17630 , -16121 ,-14060 ,-13033 ,-13990 ,-16423 ,-18514 ,-18393 ,-15642 ,-11794 ,-9259 ,-9485 ,-11874 ,-14288 ,-14651 ,-12362 , -8569 ,-5292 ,-4065 ,-4942 ,-6453 ,-6594 ,-4293 ,-297 ,3298 ,4633 ,3559 ,1774 ,1510 ,3858 ,8071 , 12263 ,14774 ,15132 ,14099 ,13026 ,13109 ,14871 ,17950 ,21232 ,23365 ,23558 ,22193 ,20726 ,20792 ,23057 , 26657 ,29657 ,30294 ,28218 ,24878 ,22704 ,23479 ,26964 ,30877 ,32429 ,30413 ,26176 ,22622 ,21969 ,24070 , 26650 ,27181 ,24815 ,20877 ,17672 ,16697 ,17659 ,18895 ,18682 ,16407 ,12816 ,9347 ,7137 ,6395 ,6446 , 6310 ,5318 ,3377 ,827 ,-1840 ,-4145 ,-5697 ,-6370 ,-6562 ,-7173 ,-9024 ,-12048 ,-15070 ,-16613 ,-16185 , -14869 ,-14548 ,-16383 ,-19824 ,-23009 ,-24197 ,-23097 ,-21080 ,-20145 ,-21396 ,-24141 ,-26364 ,-26306 ,-23930 ,-21017 , -19711 ,-20750 ,-22943 ,-24263 ,-23510 ,-21075 ,-18348 ,-16545 ,-15991 ,-16213 ,-16442 ,-16062 ,-14814 ,-12837 ,-10600 , -8693 ,-7537 ,-7158 ,-7159 ,-6935 ,-6009 ,-4320 ,-2281 ,-548 ,393 ,548 ,430 ,733 ,1857 ,3621 , 5359 ,6359 ,6343 ,5679 ,5180 ,5582 ,6995 ,8742 ,9825 ,9733 ,8863 ,8094 ,7930 ,8180 ,8470 , 8782 ,9249 ,9599 ,9289 ,8398 ,7994 ,9114 ,11401 ,13155 ,12927 ,10801 ,7949 ,5266 ,2896 ,892 , -384 ,-911 ,-1657 ,-3885 ,-7652 ,-11361 ,-13116 ,-12478 ,-10783 ,-9829 ,-10396 ,-11852 ,-12849 ,-12306 ,-10042 , -6808 ,-3759 ,-1698 ,-640 ,-74 ,457 ,1119 ,2028 ,3434 ,5401 ,7395 ,8487 ,8140 ,6741 ,5236 , 4296 ,3945 ,3898 ,3991 ,4131 ,3977 ,2974 ,832 ,-2073 ,-4862 ,-6738 ,-7489 ,-7569 ,-7821 ,-9013 , -11404 ,-14555 ,-17528 ,-19334 ,-19295 ,-17229 ,-13538 ,-9274 ,-5832 ,-4157 ,-3979 ,-3925 ,-2618 ,245 ,3884 , 7299 ,9902 ,11301 ,10917 ,8326 ,4079 ,-165 ,-2696 ,-3089 ,-2495 ,-2741 ,-5158 ,-9987 ,-16328 ,-22317 , -25696 ,-25052 ,-21103 ,-16748 ,-15280 ,-17930 ,-22849 ,-26540 ,-26556 ,-23169 ,-18753 ,-15701 ,-14791 ,-15157 ,-15396 , -14583 ,-12530 ,-9576 ,-6406 ,-3873 ,-2534 ,-2116 ,-1610 ,-220 ,1676 ,2709 ,1845 ,-463 ,-2578 ,-3149 , -2279 ,-1306 ,-1609 ,-3596 ,-6506 ,-8860 ,-9189 ,-6918 ,-3041 ,131 ,461 ,-2202 ,-5600 ,-6697 ,-4081 , 961 ,5563 ,7440 ,6251 ,3397 ,907 ,386 ,2397 ,6242 ,10193 ,12346 ,11768 ,9162 ,6451 ,5571 , 7353 ,11174 ,15422 ,18385 ,19169 ,18236 ,17133 ,17434 ,19518 ,22260 ,23968 ,23803 ,22375 ,21047 ,20642 , 20778 ,20290 ,18268 ,14804 ,10992 ,8222 ,7263 ,7647 ,7825 ,6188 ,2387 ,-2100 ,-4803 ,-4055 ,-283 , 4348 ,7650 ,8908 ,8907 ,8813 ,9244 ,10353 ,12316 ,15231 ,18531 ,20930 ,21399 ,20174 ,18549 ,17573 , 17185 ,16645 ,15516 ,13835 ,11483 ,7990 ,3325 ,-1468 ,-4971 ,-6820 ,-7997 ,-9445 ,-10744 ,-10710 ,-9279 , -8213 ,-9454 ,-12877 ,-16068 ,-16416 ,-13259 ,-8047 ,-2812 ,1232 ,3953 ,5909 ,8017 ,11199 ,15754 ,20894 , 25142 ,27372 ,27431 ,25718 ,22415 ,17478 ,11396 ,5582 ,1603 ,-187 ,-1246 ,-3956 ,-9894 ,-18512 ,-27161 , -32485 ,-32426 ,-27627 ,-21215 ,-16941 ,-16864 ,-20167 ,-23926 ,-25134 ,-22541 ,-17132 ,-11172 ,-6623 ,-4060 ,-2666 , -1075 ,1733 ,6054 ,11480 ,16946 ,20861 ,21740 ,19270 ,14838 ,10693 ,8274 ,7261 ,6282 ,4441 ,2048 , 8 ,-1218 ,-1899 ,-2497 ,-3140 ,-3636 ,-3826 ,-3760 ,-3569 ,-3290 ,-2841 ,-2098 ,-1000 ,377 ,1774 , 2791 ,3083 ,2613 ,1791 ,1321 ,1778 ,3179 ,4897 ,6048 ,6088 ,5154 ,3913 ,3121 ,3248 ,4326 , 5958 ,7455 ,8146 ,7820 ,6923 ,6228 ,6167 ,6449 ,6351 ,5376 ,3643 ,1681 ,-51 ,-1465 ,-2789 , -4356 ,-6392 ,-8847 ,-11308 ,-13121 ,-13745 ,-13102 ,-11619 ,-9950 ,-8599 ,-7697 ,-7008 ,-6087 ,-4532 ,-2244 , 468 ,3022 ,4871 ,5741 ,5663 ,4890 ,3771 ,2631 ,1636 ,715 ,-379 ,-1899 ,-3960 ,-6512 ,-9351 , -12140 ,-14467 ,-16013 ,-16747 ,-16954 ,-17067 ,-17397 ,-17981 ,-18594 ,-18899 ,-18623 ,-17690 ,-16253 ,-14576 ,-12883 , -11270 ,-9768 ,-8447 ,-7454 ,-6909 ,-6746 ,-6658 ,-6259 ,-5380 ,-4282 ,-3566 ,-3805 ,-5158 ,-7256 ,-9407 , -10962 ,-11608 ,-11497 ,-11159 ,-11198 ,-11887 ,-12939 ,-13719 ,-13766 ,-13143 ,-12241 ,-11195 ,-9531 ,-6452 ,-1554 , 4649 ,10838 ,15577 ,18100 ,18727 ,18733 ,19665 ,22441 ,26670 ,30696 ,32466 ,30745 ,25886 ,19628 ,14065 , 10512 ,8958 ,8311 ,7182 ,4707 ,1003 ,-2941 ,-5868 ,-6994 ,-6412 ,-4906 ,-3329 ,-2034 ,-751 ,1039 , 3551 ,6394 ,8752 ,9935 ,9925 ,9455 ,9534 ,10729 ,12739 ,14571 ,15156 ,13996 ,11484 ,8716 ,6924 , 6816 ,8205 ,10190 ,11738 ,12269 ,11828 ,10869 ,9930 ,9420 ,9514 ,10084 ,10733 ,10975 ,10484 ,9197 , 7208 ,4652 ,1731 ,-1210 ,-3771 ,-5739 ,-7229 ,-8553 ,-9942 ,-11410 ,-12817 ,-13964 ,-14594 ,-14420 ,-13301 , -11423 ,-9219 ,-7035 ,-4881 ,-2546 ,46 ,2677 ,5043 ,7090 ,9061 ,11205 ,13451 ,15382 ,16508 ,16589 , 15744 ,14328 ,12669 ,10885 ,8835 ,6245 ,2936 ,-967 ,-4970 ,-8422 ,-10926 ,-12677 ,-14384 ,-16721 ,-19699 , -22513 ,-24044 ,-23638 ,-21537 ,-18676 ,-16094 ,-14418 ,-13588 ,-12877 ,-11244 ,-8035 ,-3641 ,604 ,3482 ,4959 , 6079 ,7729 ,9758 ,11536 ,13048 ,14777 ,16326 ,15848 ,11734 ,4948 ,-1003 ,-3006 ,-1162 ,1585 ,2478 , 1254 ,-439 ,-1211 ,-1060 ,-713 ,-575 ,-607 ,-787 ,-1216 ,-1753 ,-1868 ,-1050 ,736 ,3078 ,5502 , 7683 ,9308 ,9988 ,9498 ,8170 ,6910 ,6694 ,7923 ,10195 ,12626 ,14374 ,14959 ,14315 ,12724 ,10747 , 9032 ,7963 ,7411 ,6870 ,5928 ,4656 ,3543 ,3026 ,3064 ,3109 ,2509 ,996 ,-1101 ,-3051 ,-4194 , -4369 ,-4004 ,-3821 ,-4360 ,-5658 ,-7249 ,-8408 ,-8492 ,-7226 ,-4875 ,-2224 ,-288 ,158 ,-1018 ,-3217 , -5389 ,-6517 ,-6069 ,-4240 ,-1837 ,160 ,1138 ,1095 ,422 ,-552 ,-1823 ,-3574 ,-5859 ,-8435 ,-10841 , -12569 ,-13194 ,-12516 ,-10769 ,-8725 ,-7482 ,-7926 ,-10200 ,-13567 ,-16816 ,-18951 ,-19722 ,-19699 ,-19821 ,-20750 , -22413 ,-24043 ,-24684 ,-23833 ,-21778 ,-19420 ,-17720 ,-17191 ,-17780 ,-19159 ,-21058 ,-23327 ,-25707 ,-27630 ,-28315 , -27128 ,-23933 ,-19232 ,-14057 ,-9669 ,-7099 ,-6737 ,-8151 ,-10398 ,-12581 ,-14167 ,-15096 ,-14984 ,-13239 ,-8832 , -1039 ,9196 ,20665 ,29407 ,32767 ,32397 ,26689 ,18753 ,13365 ,12319 ,16202 ,22761 ,28804 ,32024 ,31768 , 29459 ,27198 ,26574 ,27657 ,28996 ,28601 ,25257 ,19450 ,13146 ,8572 ,6828 ,7305 ,8257 ,8075 ,6362 , 4093 ,2819 ,3479 ,5667 ,7859 ,8374 ,6358 ,2153 ,-2992 ,-7549 ,-10284 ,-10622 ,-8719 ,-5236 ,-964 , 3412 ,7269 ,9941 ,10874 ,9984 ,7845 ,5412 ,3501 ,2504 ,2483 ,3384 ,5095 ,7383 ,9904 ,12308 , 14260 ,15362 ,15181 ,13550 ,10902 ,8212 ,6439 ,5877 ,5948 ,5627 ,4151 ,1558 ,-1235 ,-2848 ,-2188 , 799 ,4854 ,7919 ,8242 ,5370 ,323 ,-5089 ,-9238 ,-11316 ,-11403 ,-10174 ,-8484 ,-6980 ,-5839 ,-4803 , -3543 ,-2096 ,-1002 ,-994 ,-2462 ,-5132 ,-8152 ,-10499 ,-11427 ,-10737 ,-8805 ,-6424 ,-4521 ,-3808 ,-4454 , -5926 ,-7171 ,-7121 ,-5332 ,-2364 ,419 ,1610 ,675 ,-1621 ,-3658 ,-4011 ,-2352 ,447 ,2975 ,4114 , 3548 ,1843 ,203 ,-137 ,1261 ,3549 ,5102 ,4835 ,3166 ,1595 ,1273 ,1998 ,2619 ,2310 ,1361 , 829 ,1589 ,3705 ,6480 ,8906 ,10163 ,9982 ,8784 ,7464 ,6881 ,7360 ,8564 ,9802 ,10532 ,10677 , 10566 ,10563 ,10714 ,10697 ,10139 ,8998 ,7653 ,6635 ,6246 ,6403 ,6757 ,6923 ,6648 ,5866 ,4687 , 3357 ,2150 ,1245 ,658 ,296 ,72 ,-45 ,-90 ,-206 ,-645 ,-1589 ,-2945 ,-4298 ,-5134 ,-5169 , -4553 ,-3801 ,-3476 ,-3864 ,-4816 ,-5881 ,-6628 ,-6902 ,-6843 ,-6679 ,-6524 ,-6369 ,-6222 ,-6178 ,-6329 , -6622 ,-6869 ,-6942 ,-6942 ,-7143 ,-7712 ,-8466 ,-8929 ,-8693 ,-7817 ,-6914 ,-6799 ,-7945 ,-10129 ,-12523 , -14143 ,-14366 ,-13245 ,-11482 ,-10111 ,-10022 ,-11546 ,-14301 ,-17376 ,-19741 ,-20656 ,-19939 ,-18037 ,-15899 ,-14644 , -15070 ,-17213 ,-20266 ,-22971 ,-24264 ,-23762 ,-21821 ,-19275 ,-17088 ,-16037 ,-16440 ,-17956 ,-19669 ,-20534 ,-19991 , -18260 ,-16122 ,-14355 ,-13305 ,-12790 ,-12296 ,-11239 ,-9215 ,-6224 ,-2800 ,103 ,1499 ,909 ,-1222 ,-3475 , -3915 ,-997 ,5463 ,13832 ,21152 ,24512 ,22623 ,16667 ,9893 ,6053 ,7507 ,13984 ,22710 ,29868 ,32571 , 30259 ,24779 ,19205 ,16169 ,16633 ,19680 ,23257 ,25360 ,24996 ,22523 ,19299 ,16887 ,16224 ,17168 ,18619 , 19181 ,17927 ,14859 ,10839 ,7167 ,5046 ,5106 ,7078 ,9756 ,11431 ,10712 ,7329 ,2349 ,-2374 ,-5165 , -5316 ,-3290 ,-362 ,2020 ,2832 ,1811 ,-557 ,-3342 ,-5588 ,-6645 ,-6324 ,-4876 ,-2870 ,-1008 ,117 , 235 ,-484 ,-1509 ,-2194 ,-2083 ,-1130 ,299 ,1654 ,2511 ,2767 ,2609 ,2344 ,2261 ,2570 ,3358 , 4500 ,5619 ,6250 ,6138 ,5436 ,4628 ,4241 ,4582 ,5610 ,6932 ,7912 ,7931 ,6772 ,4843 ,3013 , 2096 ,2379 ,3515 ,4785 ,5456 ,5049 ,3504 ,1245 ,-956 ,-2345 ,-2611 ,-2028 ,-1246 ,-892 ,-1302 , -2463 ,-4081 ,-5666 ,-6665 ,-6709 ,-5889 ,-4823 ,-4334 ,-4878 ,-6180 ,-7430 ,-7891 ,-7365 ,-6172 ,-4835 , -3872 ,-3719 ,-4466 ,-5545 ,-5923 ,-5012 ,-3382 ,-2224 ,-1884 ,-1176 ,1463 ,6091 ,10810 ,13337 ,12931 , 10761 ,8702 ,8074 ,9312 ,12150 ,15678 ,18465 ,19263 ,17982 ,15891 ,14658 ,15046 ,16472 ,17721 ,18034 , 17630 ,17358 ,17917 ,19237 ,20522 ,20851 ,19885 ,18069 ,16245 ,15062 ,14703 ,14973 ,15522 ,15963 ,15959 , 15348 ,14242 ,12929 ,11630 ,10324 ,8823 ,7054 ,5289 ,4084 ,3889 ,4587 ,5369 ,5147 ,3294 ,129 , -3252 ,-5708 ,-6771 ,-6840 ,-6761 ,-7167 ,-8119 ,-9263 ,-10282 ,-11196 ,-12272 ,-13693 ,-15351 ,-16937 ,-18203 , -19091 ,-19672 ,-19982 ,-20009 ,-19815 ,-19677 ,-19995 ,-21010 ,-22541 ,-24067 ,-25107 ,-25563 ,-25676 ,-25667 ,-25490 , -24985 ,-24231 ,-23682 ,-23869 ,-24934 ,-26422 ,-27550 ,-27779 ,-27237 ,-26608 ,-26499 ,-26817 ,-26777 ,-25654 ,-23610 , -21788 ,-21486 ,-23117 ,-25834 ,-28059 ,-28461 ,-26692 ,-23493 ,-20197 ,-17964 ,-17226 ,-17651 ,-18569 ,-19416 ,-19885 , -19815 ,-19105 ,-17739 ,-15831 ,-13568 ,-11165 ,-8884 ,-7029 ,-5778 ,-4970 ,-4143 ,-2939 ,-1545 ,-683 ,-966 , -2055 ,-2405 ,-72 ,5768 ,13730 ,20571 ,23017 ,19889 ,13108 ,6728 ,4695 ,8628 ,16934 ,25973 ,31878 , 32767 ,29621 ,24764 ,21164 ,20780 ,23502 ,27652 ,30900 ,31696 ,30139 ,27722 ,26278 ,26781 ,28890 ,31338 , 32766 ,32397 ,30250 ,26996 ,23623 ,21122 ,20262 ,21382 ,24163 ,27495 ,29672 ,29101 ,25259 ,19251 ,13443 , 10222 ,10638 ,13801 ,17441 ,19261 ,18233 ,15003 ,11265 ,8580 ,7510 ,7523 ,7572 ,6828 ,5105 ,2892 , 1071 ,439 ,1185 ,2633 ,3516 ,2742 ,168 ,-3254 ,-6116 ,-7498 ,-7477 ,-6834 ,-6335 ,-6232 ,-6355 , -6547 ,-6937 ,-7821 ,-9303 ,-11083 ,-12575 ,-13280 ,-13133 ,-12530 ,-12009 ,-11830 ,-11829 ,-11687 ,-11340 ,-11122 , -11507 ,-12665 ,-14241 ,-15506 ,-15753 ,-14694 ,-12638 ,-10396 ,-8914 ,-8802 ,-9982 ,-11676 ,-12813 ,-12646 ,-11222 , -9365 ,-8130 ,-8049 ,-8723 ,-9097 ,-8278 ,-6264 ,-3998 ,-2698 ,-2988 ,-4472 ,-5973 ,-6260 ,-4825 ,-2250 , 206 ,1607 ,2049 ,2296 ,2705 ,2820 ,2268 ,1770 ,2612 ,4869 ,6691 ,5994 ,2808 ,-610 ,-2180 , -2067 ,-2016 ,-3052 ,-4480 ,-5087 ,-4612 ,-3648 ,-2609 ,-1526 ,-715 ,-864 ,-2025 ,-2995 ,-2418 ,-509 , 905 ,428 ,-1110 ,-1417 ,673 ,3756 ,5256 ,4089 ,1628 ,111 ,462 ,1868 ,3106 ,3765 ,4105 , 4241 ,3977 ,3328 ,2711 ,2400 ,2142 ,1665 ,1354 ,1857 ,2909 ,3148 ,1704 ,-248 ,-378 ,1924 , 4125 ,2888 ,-1968 ,-6529 ,-6447 ,-1515 ,3869 ,4908 ,853 ,-4732 ,-7611 ,-6387 ,-2796 ,526 ,2077 , 1828 ,516 ,-900 ,-1459 ,-533 ,1675 ,4044 ,5226 ,4683 ,3268 ,2767 ,4545 ,8183 ,11284 ,11075 , 6905 ,1443 ,-1092 ,1351 ,6372 ,8957 ,6170 ,168 ,-3793 ,-2651 ,1274 ,2619 ,-1499 ,-8537 ,-13174 , -12621 ,-9092 ,-7212 ,-9439 ,-14173 ,-17946 ,-18934 ,-18277 ,-18408 ,-20503 ,-23549 ,-25586 ,-25667 ,-24640 ,-24159 , -25037 ,-26613 ,-27687 ,-27845 ,-27595 ,-27225 ,-25983 ,-22949 ,-18773 ,-15934 ,-16540 ,-19682 ,-21475 ,-18435 ,-11110 , -4094 ,-1962 ,-4883 ,-8256 ,-6861 ,363 ,9385 ,14732 ,14192 ,10377 ,8067 ,10156 ,15733 ,21595 ,25266 , 26430 ,26423 ,26160 ,25844 ,25701 ,26207 ,28729 ,31689 ,32767 ,32237 ,28483 ,24569 ,24071 ,26060 ,27815 , 26586 ,22754 ,19335 ,18501 ,19539 ,19364 ,15802 ,9849 ,4955 ,3975 ,6513 ,9116 ,8140 ,2868 ,-3845 , -8005 ,-7889 ,-5398 ,-4163 ,-6239 ,-10430 ,-13658 ,-13868 ,-11718 ,-9722 ,-9915 ,-12239 ,-14884 ,-15982 ,-15064 , -13145 ,-11593 ,-10952 ,-10751 ,-10296 ,-9449 ,-8609 ,-8095 ,-7841 ,-7744 ,-7962 ,-8480 ,-8467 ,-6679 ,-3052 , 265 ,278 ,-3767 ,-8788 ,-10083 ,-5761 ,1074 ,5000 ,3392 ,-1230 ,-3984 ,-2498 ,1250 ,3668 ,3433 , 2283 ,2400 ,3872 ,5075 ,5005 ,4468 ,4847 ,6241 ,7322 ,6911 ,5297 ,3901 ,3900 ,5339 ,7332 , 8766 ,8854 ,7440 ,5167 ,3314 ,3072 ,4629 ,6872 ,8140 ,7502 ,5471 ,3465 ,2510 ,2454 ,2462 , 2167 ,2016 ,2346 ,2496 ,1436 ,-632 ,-1982 ,-1316 ,267 ,182 ,-2360 ,-4673 ,-3079 ,2967 ,9956 , 13845 ,13977 ,13054 ,13673 ,15713 ,17237 ,17162 ,16349 ,16352 ,17710 ,19666 ,21093 ,21413 ,20828 ,20060 , 19865 ,20529 ,21654 ,22490 ,22562 ,21998 ,21280 ,20792 ,20641 ,20739 ,20871 ,20729 ,20067 ,18955 ,17813 , 17066 ,16772 ,16605 ,16215 ,15493 ,14537 ,13451 ,12326 ,11294 ,10450 ,9644 ,8518 ,6926 ,5274 ,4230 , 3961 ,3768 ,2703 ,587 ,-1722 ,-3175 ,-3576 ,-3703 ,-4458 ,-6054 ,-7986 ,-9599 ,-10532 ,-10786 ,-10654 , -10664 ,-11394 ,-13065 ,-15223 ,-16946 ,-17525 ,-17082 ,-16567 ,-16975 ,-18431 ,-19955 ,-20328 ,-19338 ,-18188 ,-18465 , -20631 ,-23503 ,-25271 ,-24998 ,-23270 ,-21625 ,-21407 ,-22868 ,-24985 ,-26148 ,-25451 ,-23634 ,-22607 ,-23680 ,-26139 , -27772 ,-26981 ,-24345 ,-22033 ,-21723 ,-23172 ,-24731 ,-25035 ,-24120 ,-23027 ,-22568 ,-22587 ,-22334 ,-21407 ,-20179 , -19314 ,-19008 ,-18829 ,-18268 ,-17244 ,-15984 ,-14533 ,-12688 ,-10508 ,-8664 ,-7970 ,-8389 ,-8627 ,-7037 ,-3183 , 1407 ,4239 ,3932 ,1615 ,288 ,2522 ,8303 ,14837 ,18539 ,17722 ,13942 ,10908 ,11765 ,16756 ,23121 , 27282 ,27550 ,25156 ,22939 ,23034 ,25522 ,28852 ,31257 ,31896 ,31114 ,29981 ,29555 ,30226 ,31509 ,32463 , 32487 ,31794 ,31118 ,30933 ,30966 ,30482 ,29066 ,27140 ,25720 ,25566 ,26452 ,27193 ,26494 ,23977 ,20548 , 17772 ,16739 ,17279 ,18122 ,17802 ,15685 ,12401 ,9432 ,8074 ,8455 ,9340 ,8993 ,6528 ,2691 ,-643 , -1920 ,-1137 ,157 ,94 ,-2073 ,-5448 ,-8241 ,-9164 ,-8407 ,-7461 ,-7923 ,-10210 ,-13198 ,-15135 ,-15099 , -13783 ,-12930 ,-13881 ,-16459 ,-19114 ,-20201 ,-19317 ,-17598 ,-16736 ,-17556 ,-19402 ,-20841 ,-21005 ,-20276 ,-19719 , -19921 ,-20464 ,-20503 ,-19712 ,-18598 ,-17944 ,-18070 ,-18630 ,-19001 ,-18768 ,-17930 ,-16801 ,-15795 ,-15194 ,-14969 , -14773 ,-14197 ,-13105 ,-11782 ,-10726 ,-10253 ,-10247 ,-10241 ,-9729 ,-8472 ,-6653 ,-4819 ,-3590 ,-3216 ,-3305 , -3038 ,-1860 ,-9 ,1688 ,2595 ,2795 ,2854 ,3245 ,4181 ,5817 ,8143 ,10432 ,11143 ,8965 ,4169 , -1308 ,-5367 ,-7294 ,-7744 ,-7453 ,-6336 ,-3894 ,-120 ,4251 ,8223 ,10966 ,11874 ,10730 ,8194 ,5934 , 5747 ,8142 ,11798 ,14642 ,15639 ,15556 ,15963 ,17483 ,19049 ,18847 ,16004 ,11369 ,6797 ,3738 ,2461 , 2387 ,2910 ,3783 ,4854 ,5665 ,5486 ,3823 ,908 ,-2294 ,-4619 ,-5386 ,-4723 ,-3315 ,-1832 ,-524 , 690 ,1797 ,2421 ,2057 ,613 ,-1307 ,-2726 ,-3028 ,-2442 ,-1851 ,-2083 ,-3260 ,-4710 ,-5445 ,-4871 , -3263 ,-1719 ,-1594 ,-3677 ,-7630 ,-12086 ,-15402 ,-16604 ,-15837 ,-14018 ,-12057 ,-10306 ,-8693 ,-7289 ,-6642 , -7480 ,-10032 ,-13606 ,-16805 ,-18250 ,-17281 ,-14262 ,-10336 ,-6809 ,-4521 ,-3637 ,-3942 ,-5231 ,-7284 ,-9476 , -10688 ,-10005 ,-7689 ,-5319 ,-4647 ,-6097 ,-8372 ,-9616 ,-9061 ,-7636 ,-7051 ,-8328 ,-11134 ,-14381 ,-17280 , -19748 ,-21878 ,-23235 ,-22938 ,-20531 ,-16712 ,-13061 ,-10966 ,-10755 ,-11792 ,-13194 ,-14329 ,-14763 ,-14091 ,-12157 , -9445 ,-6961 ,-5420 ,-4424 ,-2510 ,1829 ,8918 ,17430 ,24846 ,28525 ,26916 ,20284 ,11203 ,3487 ,862 , 5063 ,14359 ,25342 ,32519 ,32767 ,28108 ,19248 ,10290 ,5259 ,4481 ,6907 ,10059 ,11957 ,12026 ,10809 , 9701 ,9800 ,11329 ,13389 ,14498 ,13564 ,10601 ,6771 ,3733 ,2815 ,4451 ,8081 ,12458 ,16185 ,18242 , 18285 ,16591 ,13738 ,10269 ,6575 ,3060 ,391 ,-516 ,1044 ,4879 ,9541 ,12774 ,12658 ,8735 ,2338 , -4132 ,-8475 ,-9683 ,-8153 ,-5178 ,-2147 ,74 ,1336 ,1958 ,2248 ,2150 ,1329 ,-363 ,-2504 ,-4249 , -4957 ,-4698 ,-4122 ,-3769 ,-3498 ,-2607 ,-561 ,2325 ,4859 ,5635 ,3898 ,-28 ,-4955 ,-9424 ,-12219 , -12603 ,-10437 ,-6339 ,-1739 ,1483 ,1833 ,-988 ,-5896 ,-11021 ,-14644 ,-15880 ,-14823 ,-12263 ,-9207 ,-6433 , -4239 ,-2526 ,-1156 ,-286 ,-327 ,-1510 ,-3445 ,-5148 ,-5586 ,-4314 ,-1685 ,1481 ,4416 ,6729 ,8372 , 9393 ,9657 ,8762 ,6329 ,2562 ,-1453 ,-4206 ,-4715 ,-3068 ,-75 ,3410 ,6570 ,8271 ,7275 ,3390 , -1720 ,-5397 ,-6045 ,-4288 ,-2007 ,-438 ,607 ,1884 ,3604 ,5361 ,6827 ,8111 ,9426 ,10711 ,11729 , 12405 ,12909 ,13414 ,13905 ,14240 ,14323 ,14186 ,13946 ,13693 ,13406 ,12963 ,12259 ,11319 ,10270 ,9203 , 8092 ,6885 ,5623 ,4412 ,3301 ,2218 ,1067 ,-156 ,-1352 ,-2403 ,-3266 ,-4011 ,-4782 ,-5692 ,-6708 , -7655 ,-8385 ,-8946 ,-9542 ,-10291 ,-11083 ,-11692 ,-12015 ,-12135 ,-12181 ,-12181 ,-12085 ,-11870 ,-11566 ,-11198 , -10765 ,-10263 ,-9684 ,-8987 ,-8120 ,-7089 ,-5952 ,-4734 ,-3387 ,-1889 ,-340 ,1107 ,2429 ,3744 ,5136 , 6536 ,7827 ,9014 ,10176 ,11293 ,12234 ,12935 ,13498 ,14029 ,14451 ,14578 ,14352 ,13867 ,13186 ,12250 , 11042 ,9722 ,8475 ,7243 ,5771 ,3940 ,1928 ,-23 ,-1902 ,-3876 ,-6000 ,-8129 ,-10140 ,-12085 ,-14035 , -15858 ,-17321 ,-18383 ,-19251 ,-20077 ,-20753 ,-21087 ,-21133 ,-21172 ,-21371 ,-21588 ,-21596 ,-21375 ,-21065 ,-20669 , -19951 ,-18679 ,-16864 ,-14665 ,-12167 ,-9352 ,-6291 ,-3213 ,-308 ,2437 ,5150 ,7831 ,10340 ,12609 ,14793 , 17125 ,19669 ,22264 ,24708 ,26904 ,28830 ,30429 ,31597 ,32288 ,32556 ,32481 ,32068 ,31254 ,30007 ,28394 , 26550 ,24593 ,22568 ,20462 ,18242 ,15888 ,13385 ,10736 ,7967 ,5133 ,2295 ,-524 ,-3336 ,-6132 ,-8828 , -11278 ,-13368 ,-15084 ,-16497 ,-17687 ,-18671 ,-19427 ,-19943 ,-20258 ,-20416 ,-20438 ,-20305 ,-20017 ,-19613 ,-19136 , -18550 ,-17741 ,-16629 ,-15263 ,-13810 ,-12397 ,-11022 ,-9610 ,-8158 ,-6772 ,-5554 ,-4506 ,-3554 ,-2635 ,-1711 , -729 ,364 ,1532 ,2635 ,3557 ,4346 ,5166 ,6116 ,7119 ,8022 ,8738 ,9287 ,9720 ,10092 ,10469 , 10898 ,11327 ,11615 ,11685 ,11632 ,11624 ,11688 ,11678 ,11461 ,11080 ,10661 ,10209 ,9583 ,8686 ,7594 , 6465 ,5365 ,4248 ,3085 ,1919 ,779 ,-386 ,-1639 ,-2955 ,-4245 ,-5466 ,-6661 ,-7879 ,-9100 ,-10262 , -11330 ,-12299 ,-13139 ,-13784 ,-14191 ,-14400 ,-14494 ,-14503 ,-14351 ,-13935 ,-13247 ,-12411 ,-11549 ,-10645 ,-9567 , -8291 ,-7068 ,-6293 ,-6172 ,-6531 ,-6984 ,-7253 ,-7285 ,-7134 ,-6827 ,-6380 ,-5829 ,-5185 ,-4406 ,-3494 , -2597 ,-1877 ,-1264 ,-466 ,706 ,2069 ,3279 ,4245 ,5206 ,6337 ,7445 ,8185 ,8513 ,8750 ,9175 , 9679 ,9925 ,9743 ,9273 ,8750 ,8275 ,7810 ,7277 ,6609 ,5775 ,4838 ,3945 ,3152 ,2304 ,1171 , -250 ,-1685 ,-2886 ,-3921 ,-5053 ,-6360 ,-7593 ,-8437 ,-8841 ,-9016 ,-9177 ,-9386 ,-9613 ,-9823 ,-9957 , -9901 ,-9569 ,-9011 ,-8360 ,-7674 ,-6870 ,-5841 ,-4578 ,-3172 ,-1733 ,-365 ,847 ,1865 ,2734 ,3528 , 4263 ,4928 ,5573 ,6299 ,7109 ,7849 ,8371 ,8698 ,8940 ,9069 ,8929 ,8495 ,7960 ,7452 ,6763 , 5565 ,3921 ,2364 ,1357 ,758 ,-20 ,-1354 ,-3058 ,-4691 ,-6029 ,-7181 ,-8346 ,-9637 ,-11093 ,-12681 , -14227 ,-15466 ,-16267 ,-16766 ,-17194 ,-17581 ,-17772 ,-17686 ,-17495 ,-17440 ,-17595 ,-17841 ,-18072 ,-18279 ,-18419 , -18320 ,-17778 ,-16743 ,-15299 ,-13481 ,-11169 ,-8263 ,-4907 ,-1477 ,1694 ,4557 ,7289 ,10029 ,12735 ,15329 , 17853 ,20485 ,23233 ,25893 ,28224 ,30087 ,31648 ,32641 ,32767 ,32272 ,30980 ,29397 ,27962 ,26388 ,24460 , 22217 ,20048 ,18282 ,16837 ,15455 ,13984 ,12502 ,11103 ,9726 ,8250 ,6685 ,5214 ,4055 ,3298 ,2852 , 2544 ,2286 ,2154 ,2293 ,2697 ,3120 ,3250 ,2984 ,2481 ,1915 ,1262 ,365 ,-821 ,-2154 ,-3474 , -4734 ,-5949 ,-7093 ,-8149 ,-9217 ,-10449 ,-11862 ,-13308 ,-14672 ,-16006 ,-17404 ,-18782 ,-19917 ,-20665 ,-21063 , -21169 ,-20931 ,-20266 ,-19213 ,-17909 ,-16440 ,-14836 ,-13166 ,-11543 ,-9961 ,-8263 ,-6346 ,-4330 ,-2409 ,-566 , 1400 ,3530 ,5536 ,7096 ,8228 ,9236 ,10283 ,11179 ,11646 ,11667 ,11470 ,11247 ,11006 ,10684 ,10259 , 9705 ,8961 ,8044 ,7107 ,6289 ,5526 ,4633 ,3589 ,2612 ,1880 ,1291 ,613 ,-170 ,-841 ,-1290 , -1715 ,-2314 ,-2910 ,-3127 ,-2978 ,-3009 ,-3626 ,-4446 ,-4687 ,-4270 ,-4088 ,-4839 ,-5851 ,-5742 ,-4456 , -4080 ,-6919 ,-12731 ,-18420 ,-20833 ,-19617 ,-17064 ,-15377 ,-14618 ,-13341 ,-10649 ,-7066 ,-3590 ,-482 ,2717 , 6294 ,9933 ,13201 ,16117 ,19018 ,21965 ,24555 ,26400 ,27580 ,28459 ,29099 ,29111 ,28136 ,26321 ,24161 , 21946 ,19585 ,16952 ,14170 ,11434 ,8709 ,5844 ,2925 ,264 ,-1997 ,-4054 ,-6086 ,-7899 ,-9169 ,-9932 , -10582 ,-11340 ,-11981 ,-12230 ,-12236 ,-12385 ,-12745 ,-12993 ,-12940 ,-12850 ,-13071 ,-13546 ,-13954 ,-14253 ,-14762 , -15627 ,-16498 ,-16928 ,-16940 ,-16916 ,-16996 ,-16844 ,-16119 ,-14894 ,-13470 ,-11900 ,-9972 ,-7589 ,-4925 ,-2145 , 810 ,3995 ,7210 ,10173 ,12883 ,15567 ,18248 ,20591 ,22301 ,23479 ,24411 ,25087 ,25180 ,24498 ,23205 , 21508 ,19349 ,16624 ,13555 ,10580 ,7845 ,5061 ,1983 ,-1160 ,-3899 ,-6080 ,-7959 ,-9780 ,-11478 ,-12901 , -14074 ,-15066 ,-15724 ,-15807 ,-15368 ,-14767 ,-14217 ,-13540 ,-12537 ,-11456 ,-10837 ,-10914 ,-11419 ,-12044 ,-12850 , -14031 ,-15415 ,-16493 ,-16957 ,-16957 ,-16724 ,-16141 ,-14895 ,-12975 ,-10784 ,-8725 ,-6856 ,-5012 ,-3096 ,-1070 , 1226 ,4016 ,7328 ,10929 ,14573 ,18174 ,21621 ,24582 ,26692 ,27929 ,28622 ,29021 ,29001 ,28310 ,26993 , 25396 ,23784 ,22144 ,20402 ,18662 ,17055 ,15470 ,13610 ,11359 ,8930 ,6597 ,4413 ,2312 ,383 ,-1125 , -2086 ,-2617 ,-2870 ,-2825 ,-2427 ,-1852 ,-1462 ,-1486 ,-1856 ,-2382 ,-2978 ,-3627 ,-4255 ,-4802 ,-5380 , -6199 ,-7265 ,-8293 ,-9028 ,-9567 ,-10234 ,-11186 ,-12272 ,-13313 ,-14326 ,-15396 ,-16461 ,-17395 ,-18253 ,-19215 , -20261 ,-21023 ,-21098 ,-20416 ,-19177 ,-17507 ,-15335 ,-12621 ,-9495 ,-6087 ,-2325 ,1916 ,6498 ,11021 ,15166 , 18905 ,22303 ,25255 ,27534 ,29083 ,30110 ,30891 ,31573 ,32182 ,32649 ,32714 ,31924 ,29933 ,26868 ,23258 , 19552 ,15798 ,11861 ,7835 ,4053 ,721 ,-2260 ,-5032 ,-7516 ,-9531 ,-11081 ,-12336 ,-13358 ,-14048 ,-14419 , -14716 ,-15123 ,-15489 ,-15547 ,-15333 ,-15136 ,-15068 ,-14945 ,-14735 ,-14785 ,-15320 ,-15958 ,-16177 ,-16262 ,-17163 , -19054 ,-20398 ,-19193 ,-15252 ,-10794 ,-8377 ,-8484 ,-9400 ,-9270 ,-7823 ,-6041 ,-4674 ,-3480 ,-1767 ,746 , 3709 ,6546 ,8902 ,10786 ,12445 ,14078 ,15595 ,16640 ,16900 ,16360 ,15223 ,13629 ,11577 ,9106 ,6419 , 3740 ,1127 ,-1466 ,-3976 ,-6210 ,-8064 ,-9633 ,-11029 ,-12184 ,-12951 ,-13336 ,-13479 ,-13368 ,-12742 ,-11395 , -9518 ,-7587 ,-5911 ,-4443 ,-3070 ,-1920 ,-1228 ,-960 ,-791 ,-500 ,-245 ,-333 ,-806 ,-1422 ,-2011 , -2677 ,-3557 ,-4524 ,-5270 ,-5653 ,-5818 ,-5942 ,-5984 ,-5762 ,-5180 ,-4281 ,-3095 ,-1569 ,297 ,2325 , 4238 ,5858 ,7175 ,8247 ,9085 ,9635 ,9827 ,9610 ,8982 ,8005 ,6773 ,5355 ,3770 ,2025 ,122 , -1989 ,-4426 ,-7251 ,-10305 ,-13221 ,-15655 ,-17488 ,-18799 ,-19651 ,-19994 ,-19741 ,-18918 ,-17665 ,-16165 ,-14564 , -12947 ,-11304 ,-9551 ,-7641 ,-5678 ,-3860 ,-2273 ,-781 ,790 ,2358 ,3551 ,3999 ,3639 ,2696 ,1404 , -165 ,-1994 ,-3915 ,-5568 ,-6582 ,-6781 ,-6231 ,-5101 ,-3471 ,-1256 ,1646 ,5096 ,8627 ,11704 ,14132 , 16167 ,18133 ,19930 ,21041 ,21052 ,20152 ,18979 ,18015 ,17212 ,16271 ,15156 ,14187 ,13656 ,13493 ,13422 , 13324 ,13337 ,13639 ,14269 ,15194 ,16415 ,17915 ,19561 ,21188 ,22727 ,24151 ,25279 ,25779 ,25440 ,24335 , 22626 ,20301 ,17261 ,13627 ,9769 ,5947 ,2086 ,-1946 ,-5959 ,-9522 ,-12418 ,-14795 ,-16805 ,-18284 ,-18975 , -18994 ,-18767 ,-18497 ,-17871 ,-16465 ,-14288 ,-11772 ,-9285 ,-6881 ,-4561 ,-2578 ,-1288 ,-807 ,-974 ,-1666 , -2989 ,-5090 ,-7869 ,-10932 ,-13789 ,-16044 ,-17450 ,-17920 ,-17482 ,-16183 ,-14054 ,-11183 ,-7801 ,-4163 ,-319 , 3852 ,8298 ,12630 ,16374 ,19511 ,22357 ,25151 ,27742 ,29746 ,31353 ,32450 ,32767 ,32207 ,29537 ,25019 , 19809 ,14444 ,9121 ,3634 ,-1932 ,-7123 ,-11588 ,-15204 ,-18029 ,-20100 ,-21490 ,-22374 ,-22887 ,-22991 ,-22583 , -21728 ,-20624 ,-19313 ,-17565 ,-15175 ,-12312 ,-9437 ,-6929 ,-4907 ,-3396 ,-2460 ,-2064 ,-1988 ,-2118 ,-2760 , -4328 ,-6566 ,-8281 ,-8200 ,-6171 ,-3356 ,-1149 ,18 ,756 ,1823 ,3363 ,5019 ,6498 ,7854 ,9272 , 10772 ,12185 ,13332 ,14169 ,14810 ,15439 ,16158 ,16886 ,17397 ,17538 ,17389 ,17159 ,16945 ,16625 ,16050 , 15254 ,14436 ,13707 ,12943 ,11929 ,10612 ,9169 ,7824 ,6636 ,5476 ,4185 ,2730 ,1226 ,-185 ,-1449 , -2618 ,-3750 ,-4812 ,-5715 ,-6456 ,-7197 ,-8121 ,-9182 ,-10080 ,-10540 ,-10628 ,-10677 ,-10894 ,-11128 ,-11124 , -10926 ,-10856 ,-11058 ,-11229 ,-10941 ,-10182 ,-9377 ,-8862 ,-8501 ,-7945 ,-7149 ,-6450 ,-6128 ,-6072 ,-5965 , -5687 ,-5416 ,-5371 ,-5561 ,-5819 ,-5986 ,-6045 ,-6124 ,-6403 ,-6980 ,-7771 ,-8581 ,-9293 ,-9974 ,-10748 , -11621 ,-12494 ,-13320 ,-14157 ,-15020 ,-15792 ,-16340 ,-16696 ,-17018 ,-17391 ,-17723 ,-17885 ,-17865 ,-17746 ,-17568 , -17281 ,-16841 ,-16287 ,-15660 ,-14914 ,-13949 ,-12767 ,-11500 ,-10225 ,-8796 ,-6991 ,-4875 ,-2919 ,-1574 ,-734 , 236 ,1801 ,3717 ,5364 ,6578 ,7900 ,9852 ,12155 ,13962 ,14869 ,15422 ,16471 ,18163 ,19795 ,20640 , 20690 ,20558 ,20784 ,21421 ,22178 ,22792 ,23203 ,23503 ,23811 ,24198 ,24661 ,25161 ,25676 ,26189 ,26635 , 26921 ,27037 ,27111 ,27305 ,27678 ,28184 ,28781 ,29449 ,30130 ,30700 ,31066 ,31222 ,31204 ,31046 ,30803 , 30548 ,30253 ,29736 ,28850 ,27715 ,26627 ,25673 ,24590 ,23095 ,21279 ,19486 ,17835 ,16054 ,13856 ,11334 , 8810 ,6367 ,3745 ,746 ,-2416 ,-5298 ,-7703 ,-9848 ,-12066 ,-14447 ,-16840 ,-19093 ,-21188 ,-23151 ,-24944 , -26499 ,-27834 ,-29058 ,-30250 ,-31353 ,-32202 ,-32635 ,-32593 ,-32145 ,-31426 ,-30546 ,-29534 ,-28366 ,-27043 ,-25601 , -24044 ,-22323 ,-20445 ,-18574 ,-16925 ,-15527 ,-14158 ,-12595 ,-10868 ,-9173 ,-7578 ,-5955 ,-4249 ,-2693 ,-1598 , -972 ,-504 ,38 ,522 ,645 ,350 ,-65 ,-269 ,-236 ,-228 ,-508 ,-1097 ,-1811 ,-2469 ,-3037 , -3579 ,-4149 ,-4787 ,-5578 ,-6540 ,-7426 ,-7852 ,-7828 ,-7969 ,-8782 ,-9775 ,-9814 ,-8707 ,-7852 ,-8484 , -9555 ,-8544 ,-5152 ,-3201 ,-7309 ,-17522 ,-28087 ,-32767 ,-30695 ,-25906 ,-22514 ,-20689 ,-17897 ,-12991 ,-7402 , -2911 ,558 ,4355 ,9004 ,13563 ,16883 ,18833 ,20024 ,20748 ,20606 ,19153 ,16574 ,13585 ,10776 ,8156 , 5376 ,2333 ,-530 ,-2566 ,-3552 ,-3892 ,-4133 ,-4340 ,-4068 ,-2972 ,-1287 ,438 ,2027 ,3890 ,6441 , 9422 ,11989 ,13509 ,14100 ,14268 ,14093 ,13006 ,10451 ,6620 ,2363 ,-1635 ,-5428 ,-9450 ,-13796 ,-17973 , -21508 ,-24508 ,-27375 ,-30214 ,-32263 ,-32767 ,-31911 ,-30067 ,-27752 ,-24882 ,-20842 ,-15561 ,-9618 ,-3721 ,1900 , 7414 ,12749 ,17416 ,20974 ,23548 ,25673 ,27621 ,29073 ,29508 ,28789 ,27249 ,25229 ,22723 ,19560 ,15826 , 11925 ,8178 ,4471 ,442 ,-3978 ,-8310 ,-11880 ,-14382 ,-16016 ,-17122 ,-17803 ,-17988 ,-17729 ,-17291 ,-16882 , -16453 ,-15840 ,-15075 ,-14389 ,-13921 ,-13508 ,-12900 ,-12088 ,-11262 ,-10435 ,-9275 ,-7511 ,-5467 ,-3959 ,-3473 , -3529 ,-3070 ,-1535 ,650 ,2784 ,4942 ,7959 ,12254 ,16918 ,20322 ,21673 ,21702 ,21643 ,21659 ,20566 , 17167 ,11675 ,5695 ,920 ,-2022 ,-3554 ,-4324 ,-4562 ,-4081 ,-2664 ,-364 ,2432 ,5192 ,7566 ,9639 , 11837 ,14520 ,17685 ,21070 ,24453 ,27679 ,30424 ,32154 ,32470 ,31420 ,29266 ,25969 ,21159 ,14754 ,7481 , 528 ,-5387 ,-10440 ,-15130 ,-19434 ,-22742 ,-24619 ,-25367 ,-25690 ,-25868 ,-25489 ,-24009 ,-21384 ,-17994 ,-14062 , -9405 ,-3896 ,2016 ,7492 ,12015 ,15737 ,18998 ,21632 ,22972 ,22532 ,20521 ,17569 ,14092 ,10089 ,5554 , 814 ,-3707 ,-7944 ,-12196 ,-16611 ,-20820 ,-24219 ,-26528 ,-27918 ,-28517 ,-27982 ,-25761 ,-21780 ,-16706 ,-11385 , -6112 ,-631 ,5112 ,10436 ,14349 ,16480 ,17347 ,17612 ,17292 ,15952 ,13590 ,10959 ,8752 ,6691 ,3766 , -548 ,-5589 ,-10221 ,-14045 ,-17560 ,-21118 ,-24099 ,-25396 ,-24580 ,-22242 ,-19152 ,-15425 ,-10753 ,-5215 ,528 , 5852 ,10649 ,15011 ,18746 ,21520 ,23336 ,24534 ,25268 ,25291 ,24317 ,22254 ,18971 ,14307 ,8696 ,3318 , -1207 ,-6110 ,-13224 ,-21689 ,-26832 ,-23945 ,-13631 ,-2335 ,3290 ,2249 ,-1046 ,-2245 ,-1100 ,-124 ,-733 , -1914 ,-2232 ,-1795 ,-1746 ,-2608 ,-3850 ,-4864 ,-5697 ,-6717 ,-7998 ,-9296 ,-10409 ,-11302 ,-11976 ,-12410 , -12642 ,-12741 ,-12671 ,-12316 ,-11681 ,-10983 ,-10437 ,-10027 ,-9551 ,-8876 ,-8071 ,-7307 ,-6688 ,-6196 ,-5723 , -5136 ,-4368 ,-3503 ,-2737 ,-2178 ,-1710 ,-1120 ,-366 ,341 ,768 ,932 ,1072 ,1392 ,1883 ,2424 , 2953 ,3485 ,4001 ,4438 ,4814 ,5294 ,6042 ,6993 ,7853 ,8370 ,8586 ,8766 ,9082 ,9439 ,9653 , 9720 ,9818 ,10034 ,10215 ,10154 ,9869 ,9573 ,9376 ,9123 ,8587 ,7740 ,6728 ,5622 ,4325 ,2768 , 1100 ,-413 ,-1646 ,-2693 ,-3700 ,-4720 ,-5746 ,-6786 ,-7847 ,-8866 ,-9759 ,-10536 ,-11288 ,-12053 ,-12742 , -13227 ,-13457 ,-13454 ,-13248 ,-12868 ,-12404 ,-11992 ,-11711 ,-11551 ,-11476 ,-11474 ,-11531 ,-11604 ,-11696 ,-11891 , -12222 ,-12494 ,-12336 ,-11506 ,-10075 ,-8253 ,-6094 ,-3501 ,-524 ,2481 ,5100 ,7221 ,9045 ,10740 ,12171 , 13022 ,13123 ,12619 ,11853 ,11156 ,10731 ,10621 ,10729 ,10881 ,10939 ,10870 ,10695 ,10391 ,9908 ,9308 , 8852 ,8871 ,9547 ,10849 ,12674 ,14990 ,17777 ,20865 ,23941 ,26735 ,29151 ,31113 ,32337 ,32396 ,31096 , 28740 ,25918 ,23026 ,20053 ,16846 ,13489 ,10346 ,7747 ,5734 ,4123 ,2748 ,1616 ,813 ,321 ,-33 , -454 ,-990 ,-1501 ,-1843 ,-2037 ,-2216 ,-2407 ,-2448 ,-2206 ,-1831 ,-1699 ,-2088 ,-2983 ,-4234 ,-5820 , -7863 ,-10416 ,-13337 ,-16401 ,-19457 ,-22409 ,-25073 ,-27160 ,-28424 ,-28806 ,-28420 ,-27408 ,-25824 ,-23675 ,-21057 , -18227 ,-15504 ,-13069 ,-10920 ,-9018 ,-7442 ,-6332 ,-5690 ,-5317 ,-4987 ,-4627 ,-4294 ,-4035 ,-3852 ,-3776 , -3845 ,-4004 ,-4106 ,-4080 ,-4037 ,-4111 ,-4232 ,-4139 ,-3609 ,-2590 ,-1098 ,873 ,3233 ,5700 ,7972 , 10015 ,12014 ,14001 ,15653 ,16589 ,16810 ,16640 ,16266 ,15508 ,14167 ,12418 ,10643 ,8938 ,7101 ,5193 , 3776 ,3238 ,3029 ,2114 ,430 ,-478 ,1162 ,5274 ,9625 ,11831 ,11497 ,10168 ,9429 ,9477 ,9557 , 9234 ,8811 ,8675 ,8711 ,8533 ,8001 ,7292 ,6581 ,5877 ,5156 ,4477 ,3870 ,3236 ,2454 ,1551 , 694 ,12 ,-510 ,-981 ,-1470 ,-1967 ,-2434 ,-2886 ,-3392 ,-3989 ,-4600 ,-5072 ,-5338 ,-5499 ,-5702 , -5943 ,-6060 ,-5947 ,-5709 ,-5560 ,-5579 ,-5652 ,-5646 ,-5596 ,-5662 ,-5935 ,-6324 ,-6641 ,-6777 ,-6772 , -6744 ,-6777 ,-6873 ,-7006 ,-7150 ,-7258 ,-7247 ,-7063 ,-6770 ,-6509 ,-6345 ,-6183 ,-5898 ,-5503 ,-5136 , -4865 ,-4586 ,-4159 ,-3591 ,-3029 ,-2581 ,-2192 ,-1734 ,-1174 ,-611 ,-165 ,147 ,386 ,565 ,570 , 269 ,-291 ,-856 ,-1195 ,-1369 ,-1671 ,-2290 ,-3093 ,-3797 ,-4287 ,-4679 ,-5104 ,-5569 ,-6068 ,-6668 , -7380 ,-8007 ,-8303 ,-8273 ,-8187 ,-8216 ,-8190 ,-7820 ,-7103 ,-6325 ,-5659 ,-4902 ,-3753 ,-2278 ,-965 , -283 ,-249 ,-479 ,-603 ,-551 ,-427 ,-212 ,294 ,1229 ,2449 ,3654 ,4712 ,5783 ,7038 ,8345 , 9330 ,9773 ,9858 ,9993 ,10442 ,11216 ,12265 ,13629 ,15355 ,17360 ,19458 ,21510 ,23437 ,25135 ,26496 , 27539 ,28438 ,29339 ,30179 ,30785 ,31136 ,31431 ,31846 ,32320 ,32631 ,32676 ,32560 ,32375 ,31980 ,31077 , 29535 ,27573 ,25600 ,23848 ,22218 ,20473 ,18544 ,16599 ,14810 ,13154 ,11494 ,9823 ,8325 ,7132 ,6088 , 4849 ,3218 ,1332 ,-505 ,-2122 ,-3587 ,-5033 ,-6465 ,-7771 ,-8884 ,-9895 ,-10957 ,-12112 ,-13250 ,-14276 , -15267 ,-16402 ,-17763 ,-19239 ,-20700 ,-22149 ,-23634 ,-25047 ,-26145 ,-26820 ,-27270 ,-27789 ,-28432 ,-28975 ,-29209 , -29174 ,-29055 ,-28916 ,-28649 ,-28172 ,-27598 ,-27123 ,-26781 ,-26372 ,-25652 ,-24574 ,-23303 ,-22004 ,-20679 ,-19230 , -17648 ,-16059 ,-14580 ,-13179 ,-11755 ,-10296 ,-8912 ,-7713 ,-6697 ,-5759 ,-4756 ,-3551 ,-2087 ,-459 ,1112 , 2428 ,3454 ,4300 ,5092 ,5883 ,6623 ,7206 ,7585 ,7913 ,8438 ,9144 ,9606 ,9489 ,9158 ,9397 , 10319 ,10970 ,10561 ,9851 ,10431 ,12283 ,12796 ,9233 ,2180 ,-4308 ,-6456 ,-4269 ,-910 ,924 ,1273 , 1729 ,2999 ,4323 ,4838 ,4666 ,4451 ,4354 ,3946 ,2926 ,1562 ,352 ,-540 ,-1359 ,-2369 ,-3507 , -4447 ,-4950 ,-5070 ,-5010 ,-4800 ,-4251 ,-3261 ,-2081 ,-1139 ,-561 ,-15 ,902 ,2175 ,3378 ,4115 , 4355 ,4305 ,4065 ,3488 ,2338 ,529 ,-1810 ,-4443 ,-7183 ,-9964 ,-12737 ,-15304 ,-17271 ,-18228 ,-17989 , -16639 ,-14334 ,-11147 ,-7103 ,-2321 ,2950 ,8405 ,13732 ,18584 ,22598 ,25480 ,27060 ,27240 ,25952 ,23232 , 19314 ,14581 ,9412 ,4110 ,-1026 ,-5645 ,-9409 ,-12067 ,-13428 ,-13315 ,-11619 ,-8422 ,-4017 ,1199 ,6831 , 12486 ,17769 ,22344 ,25953 ,28333 ,29156 ,28149 ,25282 ,20788 ,14999 ,8277 ,1039 ,-6188 ,-13011 ,-19295 , -24882 ,-29437 ,-32193 ,-32767 ,-31694 ,-29235 ,-25712 ,-21242 ,-15886 ,-10293 ,-5213 ,-996 ,2483 ,5388 ,7433 , 8064 ,6943 ,4291 ,716 ,-3192 ,-7107 ,-10895 ,-14396 ,-17330 ,-19407 ,-20471 ,-20499 ,-19487 ,-17432 ,-14461 , -10917 ,-7195 ,-3500 ,178 ,3844 ,7331 ,10410 ,12968 ,14995 ,16443 ,17229 ,17379 ,17069 ,16437 ,15482 , 14216 ,12867 ,11764 ,11021 ,10451 ,9890 ,9500 ,9632 ,10409 ,11570 ,12745 ,13796 ,14826 ,15899 ,16844 , 17360 ,17282 ,16720 ,15969 ,15231 ,14423 ,13241 ,11469 ,9222 ,6860 ,4667 ,2648 ,648 ,-1398 ,-3414 , -5319 ,-7115 ,-8804 ,-10281 ,-11376 ,-11981 ,-12108 ,-11854 ,-11333 ,-10630 ,-9751 ,-8621 ,-7203 ,-5663 ,-4361 , -3599 ,-3394 ,-3535 ,-3858 ,-4420 ,-5392 ,-6840 ,-8636 ,-10556 ,-12398 ,-14046 ,-15465 ,-16635 ,-17453 ,-17710 , -17223 ,-16040 ,-14435 ,-12658 ,-10689 ,-8326 ,-5496 ,-2406 ,622 ,3384 ,5782 ,7691 ,8974 ,9637 ,9833 , 9639 ,8906 ,7452 ,5378 ,3078 ,911 ,-1034 ,-2818 ,-4369 ,-5436 ,-5820 ,-5541 ,-4739 ,-3503 ,-1853 , 138 ,2316 ,4529 ,6668 ,8566 ,9973 ,10746 ,11008 ,10953 ,10480 ,9254 ,7273 ,5112 ,3274 ,1432 , -1147 ,-4255 ,-6464 ,-6848 ,-6619 ,-7947 ,-10706 ,-11341 ,-6166 ,4184 ,14549 ,19971 ,20102 ,18533 ,18380 , 19535 ,20099 ,19271 ,17951 ,17042 ,16281 ,14955 ,13092 ,11410 ,10404 ,9956 ,9777 ,9755 ,9768 ,9516 , 8834 ,7983 ,7332 ,6818 ,6008 ,4731 ,3367 ,2315 ,1396 ,55 ,-1841 ,-3711 ,-4876 ,-5299 ,-5541 , -6072 ,-6859 ,-7634 ,-8348 ,-9196 ,-10271 ,-11389 ,-12300 ,-12958 ,-13521 ,-14109 ,-14668 ,-15059 ,-15252 ,-15355 , -15499 ,-15714 ,-15963 ,-16232 ,-16562 ,-16942 ,-17225 ,-17160 ,-16560 ,-15418 ,-13917 ,-12322 ,-10893 ,-9851 ,-9357 , -9464 ,-10060 ,-10899 ,-11753 ,-12536 ,-13263 ,-13884 ,-14215 ,-14099 ,-13593 ,-12900 ,-12102 ,-11040 ,-9571 ,-7915 , -6634 ,-6158 ,-6347 ,-6616 ,-6536 ,-6237 ,-6161 ,-6453 ,-6767 ,-6721 ,-6398 ,-6210 ,-6290 ,-6283 ,-5880 , -5383 ,-5449 ,-6288 ,-7347 ,-7938 ,-7958 ,-7775 ,-7493 ,-6676 ,-4953 ,-2645 ,-503 ,1171 ,2857 ,5099 , 7616 ,9367 ,9552 ,8389 ,6799 ,5488 ,4534 ,3814 ,3540 ,4157 ,5833 ,8288 ,11141 ,14185 ,17193 , 19623 ,20800 ,20452 ,18989 ,17153 ,15498 ,14235 ,13470 ,13386 ,14152 ,15727 ,17866 ,20246 ,22558 ,24459 , 25590 ,25754 ,25076 ,23913 ,22541 ,20981 ,19201 ,17464 ,16340 ,16293 ,17257 ,18690 ,20039 ,21073 ,21773 , 21995 ,21402 ,19776 ,17337 ,14668 ,12269 ,10224 ,8308 ,6383 ,4633 ,3412 ,2927 ,3090 ,3572 ,3938 , 3765 ,2821 ,1180 ,-863 ,-3063 ,-5331 ,-7578 ,-9556 ,-10995 ,-11867 ,-12375 ,-12668 ,-12683 ,-12353 ,-11866 , -11636 ,-12024 ,-13122 ,-14714 ,-16375 ,-17733 ,-18787 ,-19928 ,-21408 ,-22792 ,-23201 ,-22329 ,-20978 ,-20280 ,-20442 , -20654 ,-20368 ,-20241 ,-21391 ,-23901 ,-26598 ,-28464 ,-29751 ,-31236 ,-32605 ,-32286 ,-29133 ,-23893 ,-18564 ,-14460 , -11367 ,-8597 ,-6322 ,-5441 ,-6330 ,-8228 ,-9983 ,-11049 ,-11533 ,-11466 ,-10422 ,-7957 ,-4234 ,-33 ,3829 , 7010 ,9587 ,11600 ,12781 ,12821 ,11863 ,10599 ,9751 ,9515 ,9695 ,10319 ,11806 ,14334 ,17285 ,19736 , 21442 ,22871 ,24143 ,24469 ,23234 ,21326 ,20430 ,20644 ,19577 ,14808 ,7272 ,1286 ,653 ,5059 ,10732 , 14327 ,15535 ,15997 ,16665 ,16935 ,15989 ,14045 ,12009 ,10375 ,8968 ,7603 ,6551 ,6228 ,6679 ,7557 , 8546 ,9641 ,10995 ,12584 ,14093 ,15112 ,15417 ,15037 ,14055 ,12424 ,10030 ,6953 ,3605 ,552 ,-1777 , -3188 ,-3587 ,-2887 ,-1139 ,1287 ,3758 ,5691 ,6804 ,7036 ,6277 ,4312 ,1109 ,-2870 ,-6772 ,-9835 , -11739 ,-12521 ,-12261 ,-10965 ,-8742 ,-5969 ,-3195 ,-933 ,443 ,694 ,-260 ,-2266 ,-4964 ,-7924 ,-10763 , -13122 ,-14631 ,-14984 ,-14099 ,-12202 ,-9739 ,-7203 ,-5035 ,-3596 ,-3147 ,-3777 ,-5352 ,-7543 ,-9930 ,-12104 , -13729 ,-14595 ,-14653 ,-13990 ,-12721 ,-10934 ,-8786 ,-6636 ,-4985 ,-4202 ,-4286 ,-4941 ,-5858 ,-6891 ,-7970 , -8942 ,-9583 ,-9767 ,-9569 ,-9165 ,-8656 ,-7992 ,-7061 ,-5834 ,-4396 ,-2859 ,-1289 ,278 ,1773 ,3090 , 4133 ,4781 ,4821 ,4010 ,2341 ,237 ,-1617 ,-2681 ,-2794 ,-2040 ,-521 ,1628 ,4059 ,6230 ,7664 , 8156 ,7714 ,6411 ,4437 ,2299 ,815 ,777 ,2541 ,5876 ,10102 ,14338 ,17743 ,19734 ,20141 ,19129 , 16976 ,13952 ,10512 ,7487 ,5895 ,6394 ,8897 ,12770 ,17329 ,22050 ,26357 ,29428 ,30457 ,29140 ,25850 , 21360 ,16459 ,11841 ,8192 ,6150 ,6077 ,7867 ,10993 ,14712 ,18236 ,20823 ,21893 ,21208 ,18952 ,15591 , 11631 ,7528 ,3753 ,824 ,-860 ,-1229 ,-535 ,864 ,2626 ,4358 ,5555 ,5797 ,5009 ,3481 ,1592 , -440 ,-2549 ,-4684 ,-6742 ,-8589 ,-10098 ,-11191 ,-11927 ,-12524 ,-13152 ,-13687 ,-13753 ,-13095 ,-11879 ,-10536 , -9398 ,-8609 ,-8355 ,-9091 ,-11215 ,-14696 ,-19009 ,-23445 ,-27644 ,-30997 ,-32767 ,-32497 ,-29446 ,-24188 ,-18048 , -12007 ,-6856 ,-3223 ,-1854 ,-3294 ,-7325 ,-13010 ,-19135 ,-24665 ,-28709 ,-30364 ,-28934 ,-24399 ,-17616 ,-9937 , -2597 ,3579 ,8026 ,10194 ,9606 ,6253 ,907 ,-5050 ,-10241 ,-13810 ,-15380 ,-14678 ,-11473 ,-6016 ,636 , 7054 ,12251 ,15908 ,17814 ,17501 ,14821 ,10764 ,7039 ,4469 ,2040 ,-1980 ,-7855 ,-13650 ,-16840 ,-16460 , -13513 ,-9548 ,-5295 ,-772 ,3773 ,7522 ,9665 ,10011 ,8872 ,6546 ,3140 ,-1122 ,-5604 ,-9402 ,-11803 , -12598 ,-11977 ,-10195 ,-7373 ,-3629 ,679 ,4922 ,8466 ,10921 ,12114 ,11903 ,10160 ,6995 ,2923 ,-1322 , -5134 ,-8179 ,-10233 ,-11005 ,-10235 ,-7942 ,-4510 ,-511 ,3527 ,7174 ,9992 ,11509 ,11360 ,9482 ,6187 , 2042 ,-2332 ,-6403 ,-9752 ,-12013 ,-12857 ,-12068 ,-9691 ,-6088 ,-1832 ,2485 ,6354 ,9304 ,10861 ,10659 , 8651 ,5210 ,976 ,-3412 ,-7440 ,-10676 ,-12690 ,-13127 ,-11875 ,-9144 ,-5377 ,-1100 ,3132 ,6740 ,9189 , 10151 ,9604 ,7767 ,4942 ,1460 ,-2242 ,-5577 ,-7952 ,-8984 ,-8595 ,-6921 ,-4194 ,-725 ,3045 ,6583 , 9388 ,11104 ,11541 ,10640 ,8462 ,5238 ,1405 ,-2420 ,-5581 ,-7572 ,-8191 ,-7518 ,-5741 ,-2993 ,615 , 4801 ,8971 ,12332 ,14210 ,14312 ,12729 ,9727 ,5569 ,543 ,-4881 ,-10050 ,-14367 ,-17563 ,-19654 ,-20603 , -20099 ,-17788 ,-13734 ,-8565 ,-3099 ,2131 ,6910 ,10970 ,13748 ,14585 ,13131 ,9508 ,4194 ,-2089 ,-8375 , -13552 ,-16653 ,-17116 ,-14746 ,-9576 ,-1923 ,7348 ,16790 ,24848 ,30356 ,32767 ,31952 ,27869 ,20900 ,12053 , 2786 ,-5358 ,-11171 ,-13894 ,-13173 ,-9088 ,-2196 ,6471 ,15544 ,23531 ,29068 ,31203 ,29616 ,24640 ,17103 , 8097 ,-1196 ,-9612 ,-16099 ,-19841 ,-20385 ,-17786 ,-12648 ,-6016 ,902 ,7028 ,11562 ,13982 ,14002 ,11594 , 7046 ,974 ,-5771 ,-12263 ,-17692 ,-21502 ,-23405 ,-23315 ,-21302 ,-17627 ,-12787 ,-7468 ,-2392 ,1832 ,4759 , 6123 ,5857 ,4088 ,1045 ,-3028 ,-7833 ,-12879 ,-17468 ,-20885 ,-22614 ,-22385 ,-20084 ,-15765 ,-9791 ,-2896 , 3991 ,10021 ,14516 ,16910 ,16773 ,14012 ,9033 ,2674 ,-4050 ,-10133 ,-14626 ,-16727 ,-15983 ,-12458 ,-6709 , 415 ,7963 ,14965 ,20471 ,23661 ,24006 ,21423 ,16320 ,9519 ,2088 ,-4877 ,-10425 ,-13848 ,-14731 ,-12989 , -8912 ,-3188 ,3184 ,9134 ,13800 ,16656 ,17419 ,15913 ,12197 ,6824 ,833 ,-4753 ,-9518 ,-13672 ,-17427 , -20409 ,-21750 ,-20751 ,-17366 ,-12075 ,-5470 ,1892 ,9296 ,15729 ,20107 ,21672 ,20200 ,15938 ,9481 ,1745 , -6080 ,-12789 ,-17438 ,-19402 ,-18256 ,-13694 ,-5984 ,3802 ,13937 ,22717 ,29262 ,32724 ,32767 ,29553 ,22494 , 12814 ,2482 ,-7116 ,-14706 ,-19391 ,-20430 ,-17572 ,-11407 ,-3036 ,6255 ,15168 ,22285 ,26247 ,26308 ,22646 , 16091 ,7606 ,-1878 ,-11269 ,-19271 ,-24732 ,-27016 ,-26043 ,-22116 ,-15867 ,-8332 ,-817 ,5482 ,9797 ,11758 , 11191 ,8103 ,2885 ,-3606 ,-10308 ,-16346 ,-21172 ,-24356 ,-25430 ,-24055 ,-20376 ,-15133 ,-9332 ,-3766 ,1141 , 5121 ,7835 ,8925 ,8262 ,6064 ,2787 ,-1042 ,-4880 ,-8175 ,-10442 ,-11371 ,-10826 ,-8773 ,-5300 ,-743 , 4295 ,9150 ,13337 ,16545 ,18440 ,18618 ,16859 ,13428 ,9004 ,4331 ,-28 ,-3608 ,-5902 ,-6442 ,-5043 , -1875 ,2667 ,8050 ,13527 ,18136 ,20988 ,21614 ,19975 ,16208 ,10525 ,3424 ,-4203 ,-11376 ,-17451 ,-22100 , -24895 ,-25191 ,-22627 ,-17677 ,-11476 ,-5034 ,1249 ,7224 ,12342 ,15576 ,16027 ,13477 ,8339 ,1295 ,-6832 , -14921 ,-21583 ,-25583 ,-26258 ,-23513 ,-17563 ,-8893 ,1486 ,11955 ,20750 ,26641 ,29173 ,28364 ,24351 ,17477 , 8621 ,-769 ,-9066 ,-14951 ,-17627 ,-16777 ,-12516 ,-5421 ,3510 ,12988 ,21600 ,27992 ,31133 ,30606 ,26698 , 20178 ,11996 ,3177 ,-5133 ,-11759 ,-15810 ,-16922 ,-15203 ,-11030 ,-5003 ,1942 ,8596 ,13833 ,16969 ,17796 , 16360 ,12844 ,7642 ,1424 ,-5026 ,-11023 ,-16007 ,-19436 ,-20830 ,-20019 ,-17320 ,-13373 ,-8797 ,-4009 ,618 , 4533 ,7052 ,7660 ,6266 ,3178 ,-1152 ,-6314 ,-11897 ,-17339 ,-21905 ,-24859 ,-25689 ,-24185 ,-20413 ,-14706 , -7721 ,-411 ,6166 ,11107 ,13808 ,13959 ,11541 ,6891 ,727 ,-5982 ,-12218 ,-17028 ,-19553 ,-19163 ,-15755 , -9907 ,-2679 ,4855 ,11879 ,17732 ,21685 ,22996 ,21285 ,16831 ,10483 ,3325 ,-3585 ,-9255 ,-12795 ,-13640 , -11785 ,-7751 ,-2272 ,3954 ,10155 ,15300 ,18341 ,18867 ,17408 ,14780 ,11072 ,5546 ,-2118 ,-10590 ,-17411 , -21030 ,-22123 ,-22542 ,-23098 ,-22873 ,-20807 ,-17358 ,-14020 ,-11493 ,-9162 ,-6538 ,-4363 ,-3515 ,-3205 ,-1359 , 2854 ,7658 ,10626 ,11694 ,13385 ,17829 ,24208 ,29600 ,31999 ,31926 ,31180 ,30701 ,30000 ,28331 ,25816 , 23246 ,21016 ,18582 ,15097 ,10518 ,5861 ,2246 ,-190 ,-2184 ,-4181 ,-5697 ,-6101 ,-5787 ,-6040 ,-7694 , -10358 ,-13204 ,-16133 ,-19661 ,-23757 ,-27360 ,-29252 ,-29047 ,-27017 ,-23257 ,-17636 ,-10665 ,-3939 ,786 ,2932 , 3256 ,2706 ,1417 ,-914 ,-3878 ,-6018 ,-5898 ,-3422 ,174 ,3659 ,6903 ,10403 ,13873 ,15773 ,14591 , 10491 ,5405 ,1394 ,-880 ,-1982 ,-2431 ,-2096 ,-911 ,353 ,496 ,-960 ,-3424 ,-6107 ,-8866 ,-11878 , -14672 ,-16023 ,-15032 ,-12070 ,-8392 ,-4935 ,-1868 ,699 ,2030 ,1264 ,-1426 ,-4557 ,-6445 ,-6443 ,-4895 , -2032 ,2627 ,9471 ,17557 ,24593 ,28398 ,28348 ,25306 ,20341 ,13890 ,6262 ,-1498 ,-7841 ,-11947 ,-14318 , -15813 ,-16302 ,-14822 ,-11191 ,-6968 ,-4267 ,-3651 ,-3661 ,-2592 ,-350 ,1763 ,2771 ,2872 ,2479 ,1118 , -2022 ,-6635 ,-11094 ,-13987 ,-15350 ,-15858 ,-15116 ,-11550 ,-4321 ,5149 ,14080 ,20610 ,24705 ,26890 ,26723 , 23068 ,15707 ,6194 ,-3044 ,-10231 ,-14762 ,-16502 ,-15043 ,-9914 ,-1484 ,8507 ,17503 ,23386 ,25345 ,23698 , 19103 ,12133 ,3530 ,-5515 ,-13657 ,-19929 ,-23768 ,-24596 ,-21817 ,-15560 ,-7284 ,773 ,6910 ,10687 ,12405 , 12213 ,10040 ,6226 ,1770 ,-2297 ,-5599 ,-8243 ,-10050 ,-10329 ,-8608 ,-5439 ,-2150 ,307 ,2132 ,4144 , 6602 ,8773 ,9766 ,9555 ,8897 ,8248 ,7043 ,4299 ,-229 ,-5735 ,-11197 ,-16142 ,-20341 ,-23018 ,-22938 , -19518 ,-13579 ,-6681 ,135 ,6568 ,12025 ,14954 ,13753 ,8323 ,319 ,-8264 ,-16353 ,-23386 ,-28076 ,-28441 , -23496 ,-14536 ,-4226 ,5541 ,14441 ,22356 ,27930 ,29156 ,25359 ,18007 ,9430 ,1233 ,-5764 ,-10609 ,-12118 , -9801 ,-4362 ,2888 ,10633 ,17416 ,21698 ,22870 ,21869 ,19844 ,16235 ,9472 ,312 ,-6576 ,-6102 ,1808 , 11189 ,14939 ,10282 ,-587 ,-13577 ,-24656 ,-29353 ,-23272 ,-5761 ,16689 ,32488 ,32488 ,16959 ,-4199 ,-18414 , -19099 ,-9426 ,1329 ,5620 ,3260 ,404 ,3189 ,11835 ,20174 ,20637 ,10322 ,-6440 ,-20536 ,-23696 ,-13634 , 4481 ,21157 ,28273 ,23566 ,11168 ,-1666 ,-9128 ,-9863 ,-6766 ,-3994 ,-3401 ,-3200 ,-65 ,7136 ,15381 , 19219 ,14796 ,2902 ,-11129 ,-20377 ,-20216 ,-10925 ,2415 ,12843 ,15665 ,11066 ,3337 ,-2620 ,-4640 ,-4025 , -3553 ,-4758 ,-6676 ,-6760 ,-3058 ,3888 ,10734 ,13000 ,7960 ,-2994 ,-14359 ,-19478 ,-14839 ,-2721 ,10006 , 16360 ,13769 ,5234 ,-3517 ,-8298 ,-8747 ,-7294 ,-6419 ,-6705 ,-6808 ,-4733 ,591 ,8086 ,14275 ,14810 , 7549 ,-4979 ,-16408 ,-20755 ,-16647 ,-7784 ,536 ,5322 ,6837 ,6692 ,5830 ,4224 ,1646 ,-1950 ,-6506 , -11473 ,-15013 ,-14234 ,-7278 ,4266 ,15295 ,20234 ,16824 ,7404 ,-3100 ,-10419 ,-12895 ,-11473 ,-8568 ,-6509 , -5950 ,-5165 ,-1409 ,6090 ,14231 ,17674 ,13100 ,2270 ,-8963 ,-14685 ,-12520 ,-4426 ,4991 ,11023 ,11063 , 5833 ,-1057 ,-5407 ,-5346 ,-2589 ,-788 ,-2254 ,-5898 ,-8204 ,-6343 ,-695 ,5270 ,7542 ,4489 ,-1911 , -7303 ,-7811 ,-2727 ,4753 ,9479 ,7803 ,107 ,-9472 ,-15803 ,-15879 ,-10238 ,-2161 ,4517 ,7629 ,7655 , 6751 ,6460 ,6106 ,3587 ,-2081 ,-9122 ,-14080 ,-14455 ,-10229 ,-3207 ,4400 ,10600 ,13654 ,12547 ,7744 , 1058 ,-5570 ,-10960 ,-14247 ,-14051 ,-8959 ,721 ,11854 ,19510 ,19584 ,11163 ,-2627 ,-15652 ,-21556 ,-17326 , -5496 ,7146 ,13994 ,12926 ,7017 ,1373 ,-978 ,-863 ,-1461 ,-5021 ,-10315 ,-12867 ,-8275 ,3555 ,16906 , 23506 ,18469 ,4113 ,-11511 ,-20112 ,-18360 ,-9289 ,526 ,5740 ,5739 ,4425 ,6318 ,12035 ,17091 ,15324 , 4124 ,-12822 ,-27251 ,-31024 ,-20833 ,-529 ,20357 ,31689 ,28958 ,15905 ,1155 ,-8362 ,-12385 ,-14372 ,-17336 , -19252 ,-14701 ,-2358 ,17121 ,31909 ,32767 ,24552 ,2274 ,-21580 ,-32767 ,-32231 ,-17666 ,2200 ,16323 ,20985 , 15535 ,5398 ,-3462 ,-7763 ,-7746 ,-5953 ,-3679 ,-768 ,2732 ,5120 ,4166 ,-429 ,-6268 ,-9764 ,-8302 , -1601 ,7747 ,14730 ,14305 ,5263 ,-7587 ,-15929 ,-13966 ,-2940 ,9811 ,16284 ,13194 ,3522 ,-6193 ,-10384 , -7655 ,-821 ,5657 ,8585 ,7355 ,3481 ,-700 ,-3368 ,-4131 ,-3840 ,-3182 ,-1506 ,2321 ,7557 ,10829 , 8788 ,1759 ,-5844 ,-9207 ,-7170 ,-2590 ,831 ,1707 ,1286 ,1329 ,2111 ,2466 ,1527 ,33 ,-439 , 485 ,1284 ,328 ,-1981 ,-3575 ,-3175 ,-1550 ,-42 ,1237 ,2810 ,3998 ,3152 ,103 ,-2770 ,-2979 , -924 ,592 ,-155 ,-1859 ,-2061 ,-140 ,2319 ,3584 ,3152 ,1188 ,-2066 ,-5411 ,-6027 ,-1442 ,6961 , 13204 ,11110 ,360 ,-12108 ,-17584 ,-12981 ,-2844 ,5628 ,8881 ,8218 ,6027 ,2726 ,-1948 ,-6185 ,-6743 , -2800 ,2184 ,3628 ,608 ,-3344 ,-4055 ,-534 ,4900 ,9023 ,9461 ,5205 ,-2667 ,-10291 ,-12609 ,-7457 , 1678 ,7948 ,6977 ,573 ,-5238 ,-5565 ,-355 ,6053 ,8178 ,3005 ,-7713 ,-17683 ,-19598 ,-10472 ,5282 , 18276 ,20660 ,11397 ,-3701 ,-16350 ,-20639 ,-15421 ,-4010 ,7846 ,14793 ,14299 ,7398 ,-2443 ,-11074 ,-14931 , -12080 ,-3453 ,6845 ,13595 ,13867 ,8580 ,715 ,-7320 ,-13906 ,-16521 ,-11872 ,650 ,15788 ,24272 ,19486 , 3180 ,-15138 ,-24686 ,-20296 ,-4742 ,13808 ,26172 ,25871 ,11854 ,-9907 ,-27874 ,-30979 ,-16366 ,7609 ,26793 , 30914 ,19279 ,-1021 ,-20453 ,-30748 ,-26780 ,-9076 ,14245 ,30452 ,30348 ,14853 ,-6327 ,-22173 ,-26531 ,-19045 , -3503 ,13195 ,22667 ,19389 ,5234 ,-10938 ,-19420 ,-16198 ,-4535 ,8323 ,15567 ,13889 ,4831 ,-5974 ,-12146 , -10837 ,-4382 ,2258 ,5612 ,5485 ,3563 ,1232 ,-1109 ,-3245 ,-4289 ,-2931 ,1145 ,5922 ,7667 ,4016 , -3112 ,-8430 ,-8006 ,-2940 ,2235 ,4480 ,4504 ,4172 ,3380 ,977 ,-1988 ,-2204 ,1685 ,6029 ,5082 , -2681 ,-11998 ,-15156 ,-8822 ,3311 ,13892 ,17419 ,13116 ,3965 ,-5853 ,-12715 ,-14190 ,-9611 ,-880 ,7682 , 11421 ,8235 ,-310 ,-10661 ,-19911 ,-26809 ,-30847 ,-31425 ,-28450 ,-23346 ,-18706 ,-16625 ,-17410 ,-19770 ,-21908 , -22341 ,-20250 ,-15735 ,-9991 ,-4828 ,-1509 ,186 ,1744 ,4625 ,9038 ,13798 ,17292 ,18627 ,18069 ,16560 , 14926 ,13442 ,11976 ,10341 ,8482 ,6448 ,4347 ,2360 ,727 ,-332 ,-664 ,-173 ,1097 ,2732 ,3851 , 3509 ,1445 ,-1474 ,-3681 ,-3960 ,-2259 ,368 ,2552 ,3449 ,3055 ,1945 ,796 ,76 ,-22 ,424 , 1013 ,1080 ,77 ,-1943 ,-4270 ,-6095 ,-7134 ,-7587 ,-7570 ,-6863 ,-5401 ,-3813 ,-3081 ,-3530 ,-4363 , -4451 ,-3509 ,-2302 ,-1695 ,-1743 ,-1815 ,-1446 ,-784 ,-244 ,14 ,134 ,276 ,560 ,1215 ,2448 , 3933 ,4625 ,3496 ,684 ,-2257 ,-3517 ,-2544 ,-337 ,1715 ,3104 ,4207 ,5262 ,5783 ,5161 ,3650 , 2377 ,2292 ,3299 ,4579 ,5625 ,6686 ,8195 ,10000 ,11330 ,11417 ,9962 ,7123 ,3397 ,-314 ,-2807 , -3198 ,-1650 ,613 ,2144 ,2174 ,780 ,-1588 ,-4527 ,-7731 ,-10890 ,-13663 ,-15617 ,-16123 ,-14564 ,-10955 , -6442 ,-2881 ,-1613 ,-2524 ,-4313 ,-5604 ,-5788 ,-4971 ,-3480 ,-1609 ,295 ,1814 ,2653 ,2810 ,2515 , 2083 ,1824 ,1945 ,2377 ,2755 ,2722 ,2268 ,1641 ,880 ,-302 ,-1938 ,-3222 ,-2942 ,-778 ,1980 , 3367 ,2541 ,564 ,-666 ,-138 ,1641 ,3462 ,4498 ,4605 ,4011 ,3123 ,2542 ,2827 ,3973 ,5232 , 5657 ,4845 ,3097 ,1017 ,-779 ,-1610 ,-835 ,1565 ,4548 ,6489 ,6305 ,4099 ,755 ,-2830 ,-5990 , -8078 ,-8543 ,-7418 ,-5526 ,-3945 ,-3253 ,-3334 ,-3790 ,-4329 ,-4812 ,-5194 ,-5532 ,-5853 ,-5858 ,-4931 , -2760 ,-2 ,1955 ,2172 ,1108 ,289 ,988 ,3211 ,5846 ,7647 ,8079 ,7403 ,6137 ,4513 ,2439 , -64 ,-2560 ,-4494 ,-5794 ,-6914 ,-8074 ,-8620 ,-7563 ,-4896 ,-2075 ,-812 ,-1390 ,-2423 ,-2303 ,-588 , 2189 ,5688 ,10148 ,15463 ,20342 ,22882 ,22071 ,18609 ,14370 ,11327 ,10933 ,13626 ,18203 ,21654 ,20563 , 14119 ,4779 ,-3152 ,-7850 ,-11445 ,-16429 ,-24603 ,-31365 ,-32767 ,-32481 ,-28595 ,-23652 ,-21299 ,-20570 ,-21122 , -21803 ,-21337 ,-18840 ,-13876 ,-7608 ,-1780 ,2248 ,4406 ,5697 ,7214 ,9398 ,11880 ,13897 ,14830 ,14531 , 13340 ,11809 ,10379 ,9217 ,8264 ,7381 ,6418 ,5207 ,3608 ,1659 ,-283 ,-1614 ,-1794 ,-731 ,1040 , 2560 ,2964 ,2014 ,276 ,-1217 ,-1586 ,-598 ,1270 ,3177 ,4369 ,4493 ,3636 ,2163 ,524 ,-872 , -1732 ,-1966 ,-1774 ,-1586 ,-1803 ,-2549 ,-3650 ,-4835 ,-5909 ,-6717 ,-7068 ,-6834 ,-6158 ,-5454 ,-5089 , -5055 ,-5009 ,-4652 ,-4004 ,-3305 ,-2691 ,-2055 ,-1230 ,-255 ,591 ,1020 ,990 ,781 ,842 ,1515 , 2767 ,4120 ,4874 ,4591 ,3478 ,2305 ,1852 ,2326 ,3278 ,4051 ,4309 ,4158 ,3851 ,3512 ,3154 , 2891 ,2965 ,3511 ,4323 ,4935 ,4985 ,4534 ,4023 ,3923 ,4361 ,5023 ,5365 ,4980 ,3868 ,2423 , 1169 ,411 ,75 ,-169 ,-624 ,-1359 ,-2220 ,-2992 ,-3597 ,-4187 ,-5039 ,-6291 ,-7682 ,-8579 ,-8378 , -7011 ,-5087 ,-3511 ,-2876 ,-3121 ,-3707 ,-4064 ,-3927 ,-3350 ,-2505 ,-1516 ,-465 ,487 ,1072 ,1061 , 489 ,-308 ,-930 ,-1213 ,-1291 ,-1359 ,-1443 ,-1450 ,-1419 ,-1624 ,-2296 ,-3242 ,-3819 ,-3411 ,-2030 , -431 ,432 ,176 ,-697 ,-1200 ,-629 ,945 ,2812 ,4170 ,4619 ,4286 ,3622 ,3129 ,3155 ,3792 , 4853 ,5929 ,6543 ,6359 ,5359 ,3885 ,2506 ,1738 ,1771 ,2371 ,3033 ,3243 ,2700 ,1383 ,-467 , -2426 ,-4035 ,-4981 ,-5236 ,-5013 ,-4600 ,-4202 ,-3904 ,-3725 ,-3660 ,-3717 ,-3910 ,-4194 ,-4362 ,-4023 , -2824 ,-818 ,1371 ,2848 ,3073 ,2283 ,1329 ,1038 ,1615 ,2548 ,3042 ,2573 ,1161 ,-789 ,-2811 , -4574 ,-5891 ,-6708 ,-7169 ,-7602 ,-8280 ,-9066 ,-9330 ,-8312 ,-5703 ,-1952 ,1950 ,5038 ,6890 ,7764 , 8344 ,9369 ,11441 ,14983 ,20057 ,25930 ,30819 ,32490 ,29704 ,23492 ,16988 ,13487 ,13958 ,16037 ,15683 , 10564 ,2318 ,-4703 ,-7514 ,-7551 ,-9331 ,-15729 ,-24708 ,-30982 ,-30798 ,-24818 ,-16628 ,-9367 ,-4355 ,-2180 , -3554 ,-8314 ,-14205 ,-17840 ,-17378 ,-14034 ,-10704 ,-9216 ,-9012 ,-8174 ,-5283 ,-313 ,5704 ,11345 ,15220 , 16313 ,14443 ,10514 ,6154 ,2878 ,1418 ,1638 ,2878 ,4335 ,5338 ,5578 ,5254 ,4971 ,5341 ,6511 , 7988 ,8876 ,8372 ,6204 ,2814 ,-805 ,-3526 ,-4598 ,-3976 ,-2283 ,-452 ,712 ,794 ,-165 ,-1725 , -3188 ,-3912 ,-3720 ,-3058 ,-2655 ,-2943 ,-3799 ,-4842 ,-5851 ,-6750 ,-7294 ,-7017 ,-5681 ,-3674 ,-1798 , -638 ,-234 ,-337 ,-766 ,-1378 ,-1850 ,-1787 ,-1155 ,-435 ,-182 ,-456 ,-811 ,-825 ,-470 ,103 , 963 ,2301 ,3922 ,5069 ,5030 ,3953 ,2889 ,2887 ,4065 ,5614 ,6630 ,6832 ,6479 ,5847 ,5001 , 4070 ,3461 ,3608 ,4483 ,5505 ,5990 ,5670 ,4788 ,3766 ,2873 ,2143 ,1482 ,799 ,69 ,-625 , -1125 ,-1299 ,-1134 ,-726 ,-198 ,336 ,765 ,990 ,979 ,719 ,78 ,-1191 ,-3161 ,-5406 ,-7093 , -7533 ,-6691 ,-5147 ,-3607 ,-2501 ,-1959 ,-1975 ,-2455 ,-3183 ,-3900 ,-4454 ,-4821 ,-4989 ,-4917 ,-4677 , -4524 ,-4673 ,-4991 ,-5026 ,-4437 ,-3355 ,-2250 ,-1479 ,-1060 ,-882 ,-995 ,-1533 ,-2330 ,-2784 ,-2280 , -833 ,751 ,1479 ,1033 ,81 ,-263 ,701 ,2833 ,5413 ,7636 ,8890 ,8789 ,7262 ,4733 ,2074 , 170 ,-595 ,-446 ,116 ,699 ,1129 ,1377 ,1551 ,1904 ,2670 ,3784 ,4788 ,5121 ,4515 ,3115 , 1293 ,-582 ,-2195 ,-3252 ,-3509 ,-2879 ,-1499 ,291 ,1996 ,3076 ,3114 ,2002 ,-16 ,-2479 ,-4879 , -6759 ,-7816 ,-8082 ,-8024 ,-8296 ,-9174 ,-10149 ,-10183 ,-8529 ,-5417 ,-1962 ,607 ,1690 ,1434 ,375 , -832 ,-1395 ,-497 ,2112 ,5528 ,7984 ,8087 ,5930 ,3004 ,1164 ,1756 ,5355 ,11508 ,18226 ,22337 , 21561 ,16871 ,12252 ,11214 ,13378 ,15036 ,13266 ,8855 ,4746 ,2356 ,720 ,-645 ,331 ,5651 ,12996 , 16083 ,10850 ,1235 ,-4265 ,-786 ,6571 ,7476 ,-2342 ,-19427 ,-31670 ,-32767 ,-29359 ,-21458 ,-13636 ,-10009 , -9843 ,-14069 ,-21068 ,-27505 ,-30154 ,-27339 ,-20314 ,-11304 ,-2572 ,4201 ,8191 ,9860 ,10901 ,12852 ,15653 , 17777 ,17934 ,16349 ,14228 ,12284 ,10266 ,7793 ,5077 ,2551 ,144 ,-2553 ,-5425 ,-7583 ,-8219 ,-7526 , -6530 ,-6113 ,-6412 ,-7121 ,-7983 ,-8762 ,-8898 ,-7586 ,-4403 ,167 ,4897 ,8503 ,10222 ,9923 ,7940 , 4973 ,2063 ,341 ,461 ,2115 ,4204 ,5625 ,5967 ,5412 ,4082 ,1762 ,-1560 ,-5070 ,-7410 ,-7771 , -6605 ,-5135 ,-4258 ,-4074 ,-4313 ,-4834 ,-5537 ,-6050 ,-5905 ,-5032 ,-3836 ,-2696 ,-1598 ,-413 ,690 , 1436 ,1981 ,2874 ,4299 ,5631 ,6107 ,5864 ,5941 ,7114 ,8971 ,10368 ,10606 ,9896 ,8765 ,7429 , 5913 ,4463 ,3432 ,2798 ,2141 ,1188 ,140 ,-687 ,-1326 ,-1963 ,-2397 ,-2116 ,-1038 ,100 ,405 , -185 ,-856 ,-842 ,-158 ,677 ,1361 ,1981 ,2602 ,3043 ,3148 ,2990 ,2606 ,1685 ,-125 ,-2572 , -4713 ,-5690 ,-5499 ,-4889 ,-4553 ,-4609 ,-4831 ,-5150 ,-5752 ,-6767 ,-8001 ,-8986 ,-9189 ,-8241 ,-6167 , -3530 ,-1231 ,23 ,158 ,-375 ,-1122 ,-1935 ,-2776 ,-3383 ,-3322 ,-2421 ,-1061 ,73 ,561 ,583 , 725 ,1432 ,2581 ,3523 ,3595 ,2707 ,1485 ,807 ,1116 ,2138 ,3199 ,3776 ,3739 ,3218 ,2394 , 1463 ,673 ,228 ,114 ,82 ,-144 ,-616 ,-1101 ,-1232 ,-725 ,451 ,2031 ,3562 ,4611 ,4956 , 4607 ,3681 ,2313 ,706 ,-789 ,-1768 ,-2018 ,-1662 ,-1052 ,-555 ,-500 ,-1284 ,-3308 ,-6618 ,-10557 , -13907 ,-15516 ,-14911 ,-12407 ,-8796 ,-5011 ,-1878 ,187 ,1509 ,3079 ,5837 ,9790 ,13830 ,16514 ,17084 , 15795 ,13430 ,10779 ,8633 ,7963 ,9501 ,12700 ,15242 ,14267 ,8777 ,997 ,-5074 ,-7058 ,-6364 ,-6819 , -10874 ,-16981 ,-20634 ,-18046 ,-9117 ,2595 ,12411 ,17243 ,16636 ,12055 ,5639 ,-415 ,-3729 ,-1953 ,5823 , 17291 ,27068 ,29928 ,24913 ,16207 ,9274 ,5783 ,2537 ,-4451 ,-15157 ,-25119 ,-29541 ,-27369 ,-21478 ,-15733 , -12468 ,-12256 ,-14799 ,-19163 ,-23497 ,-25475 ,-23645 ,-18398 ,-11521 ,-4863 ,584 ,4624 ,7388 ,9152 ,10467 , 12154 ,14875 ,18505 ,21873 ,23268 ,21567 ,17150 ,11699 ,6911 ,3261 ,40 ,-3428 ,-6773 ,-8868 ,-8993 , -7559 ,-5712 ,-4493 ,-4428 ,-5641 ,-7927 ,-10590 ,-12525 ,-12800 ,-11272 ,-8605 ,-5658 ,-2907 ,-439 ,1681 , 3206 ,3925 ,4008 ,4040 ,4651 ,6016 ,7680 ,8855 ,8919 ,7710 ,5447 ,2563 ,-339 ,-2495 ,-3258 , -2559 ,-1054 ,322 ,995 ,944 ,350 ,-724 ,-2192 ,-3644 ,-4442 ,-4225 ,-3223 ,-1995 ,-922 ,-42 , 740 ,1476 ,2254 ,3236 ,4468 ,5686 ,6502 ,6797 ,6810 ,6766 ,6539 ,5788 ,4402 ,2676 ,1057 , -164 ,-882 ,-1082 ,-846 ,-441 ,-210 ,-342 ,-820 ,-1606 ,-2719 ,-4017 ,-5034 ,-5250 ,-4610 ,-3630 , -2891 ,-2505 ,-2180 ,-1705 ,-1157 ,-616 ,102 ,1207 ,2522 ,3513 ,3800 ,3493 ,2930 ,2201 ,1113 , -374 ,-1860 ,-2750 ,-2739 ,-1986 ,-878 ,254 ,1179 ,1683 ,1592 ,880 ,-277 ,-1553 ,-2556 ,-2938 , -2565 ,-1663 ,-743 ,-262 ,-317 ,-648 ,-919 ,-941 ,-661 ,-82 ,697 ,1388 ,1588 ,1018 ,-311 , -2124 ,-4019 ,-5538 ,-6260 ,-5995 ,-4957 ,-3655 ,-2508 ,-1593 ,-794 ,-161 ,22 ,-434 ,-1318 ,-2130 , -2491 ,-2364 ,-1900 ,-1165 ,-111 ,1235 ,2642 ,3802 ,4543 ,4927 ,5180 ,5532 ,6078 ,6682 ,6989 , 6591 ,5287 ,3233 ,867 ,-1355 ,-3177 ,-4560 ,-5525 ,-5977 ,-5735 ,-4771 ,-3490 ,-2700 ,-3149 ,-4907 , -7118 ,-8412 ,-7688 ,-4731 ,-302 ,4239 ,7533 ,8823 ,8278 ,6862 ,5840 ,6279 ,8759 ,13100 ,18048 , 21424 ,21262 ,17347 ,11555 ,6263 ,2242 ,-1682 ,-6807 ,-12689 ,-17359 ,-19212 ,-18285 ,-15796 ,-12973 ,-10724 , -9966 ,-11396 ,-14490 ,-17097 ,-16599 ,-11845 ,-3994 ,4387 ,10971 ,14685 ,15634 ,14670 ,12987 ,12081 ,13490 , 17974 ,24806 ,30938 ,32767 ,28986 ,20936 ,12720 ,7338 ,3564 ,-2206 ,-11979 ,-23521 ,-31621 ,-32767 ,-27974 , -20810 ,-15181 ,-13083 ,-14367 ,-18027 ,-22507 ,-25937 ,-26702 ,-24237 ,-19334 ,-13420 ,-7632 ,-2415 ,2203 ,6229 , 9637 ,12465 ,14778 ,16468 ,17177 ,16545 ,14587 ,11874 ,9298 ,7588 ,6893 ,6728 ,6305 ,5079 ,3120 , 1031 ,-601 ,-1765 ,-3071 ,-5175 ,-8078 ,-10937 ,-12551 ,-12102 ,-9604 ,-5832 ,-1896 ,1252 ,3149 ,3829 , 3569 ,2614 ,1175 ,-348 ,-1268 ,-905 ,928 ,3712 ,6482 ,8309 ,8629 ,7333 ,4754 ,1592 ,-1319 , -3352 ,-4310 ,-4346 ,-3742 ,-2823 ,-2013 ,-1765 ,-2250 ,-3132 ,-3770 ,-3746 ,-3162 ,-2423 ,-1772 ,-1154 , -479 ,141 ,549 ,861 ,1441 ,2489 ,3732 ,4674 ,5109 ,5293 ,5532 ,5756 ,5609 ,4941 ,4036 , 3305 ,2865 ,2548 ,2245 ,2065 ,2081 ,2058 ,1584 ,450 ,-1180 ,-2947 ,-4513 ,-5561 ,-5748 ,-4889 , -3251 ,-1533 ,-446 ,-256 ,-747 ,-1524 ,-2291 ,-2842 ,-2967 ,-2526 ,-1611 ,-542 ,371 ,1041 ,1526 , 1794 ,1657 ,1005 ,52 ,-740 ,-1017 ,-795 ,-365 ,17 ,296 ,508 ,611 ,503 ,216 ,20 , 247 ,994 ,2006 ,2858 ,3230 ,3006 ,2193 ,872 ,-731 ,-2203 ,-3127 ,-3371 ,-3153 ,-2827 ,-2647 , -2769 ,-3337 ,-4409 ,-5756 ,-6874 ,-7348 ,-7164 ,-6575 ,-5687 ,-4336 ,-2458 ,-474 ,892 ,1250 ,912 , 563 ,623 ,1041 ,1688 ,2735 ,4430 ,6528 ,8162 ,8476 ,7387 ,5611 ,3947 ,2668 ,1633 ,770 , 173 ,-246 ,-911 ,-2156 ,-3769 ,-5185 ,-6114 ,-6761 ,-7302 ,-7350 ,-6184 ,-3531 ,5 ,3294 ,5346 , 5693 ,4468 ,2418 ,773 ,755 ,2968 ,7172 ,12502 ,17687 ,21134 ,21399 ,18249 ,13359 ,9367 ,7626 , 6843 ,4345 ,-1057 ,-7560 ,-11912 ,-12421 ,-10407 ,-8837 ,-9814 ,-13353 ,-18057 ,-22392 ,-25246 ,-25846 ,-23876 , -19931 ,-15544 ,-12250 ,-10341 ,-8533 ,-4971 ,1282 ,9529 ,17931 ,24556 ,28114 ,28152 ,25075 ,20241 ,15870 , 14304 ,16755 ,22328 ,28198 ,31124 ,29421 ,23992 ,17521 ,12248 ,8064 ,2727 ,-5758 ,-16676 ,-26485 ,-31353 , -30029 ,-24492 ,-18157 ,-13678 ,-12161 ,-13623 ,-17403 ,-22089 ,-25713 ,-26665 ,-24627 ,-20553 ,-15758 ,-11116 ,-6988 , -3499 ,-613 ,1947 ,4515 ,7052 ,9015 ,9798 ,9326 ,8159 ,6999 ,6155 ,5453 ,4599 ,3555 ,2583 , 1969 ,1737 ,1664 ,1634 ,1955 ,3183 ,5433 ,7864 ,9065 ,8246 ,6090 ,4286 ,4029 ,4968 ,5653 , 4961 ,3001 ,723 ,-1093 ,-2289 ,-2972 ,-3091 ,-2530 ,-1477 ,-438 ,131 ,79 ,-569 ,-1815 ,-3591 , -5500 ,-6866 ,-7132 ,-6198 ,-4358 ,-2008 ,454 ,2548 ,3751 ,3826 ,3064 ,2075 ,1257 ,488 ,-639 , -2297 ,-4163 ,-5612 ,-6098 ,-5428 ,-3798 ,-1713 ,198 ,1439 ,1898 ,1894 ,1952 ,2466 ,3478 ,4681 , 5595 ,5841 ,5390 ,4628 ,4105 ,4095 ,4357 ,4343 ,3703 ,2565 ,1335 ,265 ,-723 ,-1816 ,-3006 , -4064 ,-4781 ,-5145 ,-5296 ,-5376 ,-5470 ,-5591 ,-5608 ,-5207 ,-4063 ,-2178 ,6 ,1900 ,3205 ,3981 , 4345 ,4244 ,3652 ,2871 ,2429 ,2562 ,2940 ,3021 ,2684 ,2384 ,2654 ,3496 ,4319 ,4427 ,3553 , 2001 ,384 ,-759 ,-1237 ,-1249 ,-1185 ,-1348 ,-1806 ,-2463 ,-3206 ,-3950 ,-4592 ,-5013 ,-5185 ,-5205 , -5176 ,-5071 ,-4796 ,-4357 ,-3911 ,-3618 ,-3507 ,-3528 ,-3626 ,-3636 ,-3153 ,-1767 ,373 ,2321 ,2948 , 1991 ,418 ,-436 ,-151 ,450 ,247 ,-1009 ,-2559 ,-3533 ,-3763 ,-3702 ,-3762 ,-3935 ,-3942 ,-3490 , -2301 ,-141 ,2930 ,6374 ,9445 ,11691 ,13057 ,13499 ,12754 ,10760 ,8207 ,6381 ,6338 ,8310 ,11795 , 15830 ,18967 ,19464 ,16381 ,10779 ,5349 ,2180 ,839 ,-956 ,-4684 ,-9346 ,-12580 ,-13022 ,-11197 ,-8434 , -5722 ,-3912 ,-4261 ,-7741 ,-13534 ,-18840 ,-20839 ,-19002 ,-15363 ,-12582 ,-11925 ,-12909 ,-14309 ,-15074 ,-14511 , -12280 ,-8694 ,-4867 ,-2101 ,-791 ,61 ,2098 ,6232 ,11967 ,17927 ,22859 ,26008 ,26770 ,24613 ,19904 , 14715 ,12200 ,14410 ,20514 ,27429 ,31952 ,32767 ,30457 ,25777 ,19532 ,12538 ,5347 ,-1955 ,-9639 ,-17205 , -22776 ,-24291 ,-21540 ,-16865 ,-13511 ,-13329 ,-15978 ,-19907 ,-23584 ,-25888 ,-26008 ,-23634 ,-19308 ,-14262 ,-9651 , -5917 ,-2847 ,-74 ,2549 ,4948 ,6953 ,8345 ,8899 ,8538 ,7498 ,6270 ,5292 ,4623 ,3931 ,2855 , 1447 ,236 ,-186 ,347 ,1507 ,2841 ,4063 ,4921 ,4970 ,3793 ,1619 ,-449 ,-1067 ,370 ,3371 , 6867 ,9895 ,11769 ,11947 ,10176 ,6894 ,3236 ,373 ,-1208 ,-1728 ,-1548 ,-795 ,407 ,1566 ,1916 , 959 ,-1150 ,-3722 ,-5968 ,-7340 ,-7676 ,-7206 ,-6441 ,-5881 ,-5693 ,-5620 ,-5246 ,-4371 ,-3169 ,-2031 , -1289 ,-1032 ,-1116 ,-1287 ,-1301 ,-999 ,-310 ,725 ,1903 ,2872 ,3322 ,3268 ,3123 ,3379 ,4111 , 4835 ,4906 ,4096 ,2731 ,1310 ,60 ,-1079 ,-2101 ,-2748 ,-2729 ,-2116 ,-1415 ,-1222 ,-1784 ,-2857 , -3935 ,-4589 ,-4636 ,-4092 ,-3032 ,-1562 ,101 ,1578 ,2495 ,2767 ,2721 ,2859 ,3447 ,4333 ,5148 , 5611 ,5626 ,5188 ,4377 ,3473 ,2915 ,2951 ,3329 ,3454 ,2933 ,1884 ,671 ,-543 ,-1825 ,-3110 , -4032 ,-4256 ,-3854 ,-3196 ,-2498 ,-1678 ,-740 ,-69 ,-112 ,-766 ,-1332 ,-1212 ,-564 ,-122 ,-390 , -1129 ,-1689 ,-1687 ,-1288 ,-896 ,-749 ,-859 ,-1232 ,-1998 ,-3263 ,-4876 ,-6363 ,-7187 ,-7149 ,-6616 , -6300 ,-6705 ,-7703 ,-8661 ,-8970 ,-8466 ,-7364 ,-5913 ,-4196 ,-2219 ,-56 ,2151 ,4294 ,6364 ,8458 , 10732 ,13232 ,15666 ,17402 ,17873 ,17122 ,15867 ,14993 ,14946 ,15587 ,16416 ,16771 ,15973 ,13675 ,10284 , 6752 ,3600 ,188 ,-4620 ,-10811 ,-16434 ,-18902 ,-17255 ,-13084 ,-9215 ,-7595 ,-8373 ,-10538 ,-12905 ,-14439 , -14246 ,-11942 ,-8234 ,-4787 ,-3083 ,-3252 ,-4045 ,-3992 ,-2626 ,-699 ,572 ,382 ,-1323 ,-4015 ,-6887 , -9088 ,-9996 ,-9514 ,-8189 ,-6884 ,-6131 ,-5679 ,-4647 ,-2200 ,1868 ,7099 ,12692 ,17667 ,20841 ,21181 , 18626 ,14863 ,12465 ,13280 ,17200 ,22452 ,27706 ,31494 ,32767 ,31313 ,25547 ,16788 ,7850 ,-145 ,-7465 , -14881 ,-21426 ,-24673 ,-23370 ,-18989 ,-14783 ,-13116 ,-14196 ,-16920 ,-20217 ,-23332 ,-25328 ,-25117 ,-22236 ,-17365 , -11895 ,-7002 ,-3122 ,-77 ,2544 ,5103 ,7733 ,10248 ,12223 ,13287 ,13367 ,12674 ,11483 ,9965 ,8207 , 6300 ,4357 ,2476 ,744 ,-718 ,-1750 ,-2260 ,-2363 ,-2396 ,-2739 ,-3523 ,-4444 ,-4878 ,-4247 ,-2376 , 400 ,3425 ,5996 ,7563 ,7848 ,6914 ,5175 ,3294 ,2036 ,2086 ,3807 ,6912 ,10309 ,12454 ,12201 , 9527 ,5458 ,1256 ,-2362 ,-5263 ,-7405 ,-8527 ,-8426 ,-7392 ,-6200 ,-5597 ,-5811 ,-6528 ,-7249 ,-7637 , -7609 ,-7249 ,-6706 ,-6128 ,-5606 ,-5134 ,-4607 ,-3880 ,-2839 ,-1484 ,40 ,1511 ,2765 ,3790 ,4660 , 5386 ,5843 ,5869 ,5406 ,4519 ,3314 ,1909 ,510 ,-560 ,-1012 ,-818 ,-269 ,198 ,262 ,-174 , -1015 ,-2025 ,-2845 ,-3083 ,-2510 ,-1258 ,190 ,1258 ,1611 ,1349 ,948 ,997 ,1862 ,3465 ,5319 , 6796 ,7464 ,7252 ,6375 ,5149 ,3856 ,2694 ,1777 ,1140 ,795 ,759 ,978 ,1170 ,832 ,-414 , -2378 ,-4232 ,-5052 ,-4520 ,-3112 ,-1614 ,-516 ,111 ,314 ,54 ,-622 ,-1403 ,-1900 ,-2054 ,-2214 , -2713 ,-3420 ,-3803 ,-3472 ,-2623 ,-1934 ,-2052 ,-3152 ,-4921 ,-6864 ,-8617 ,-10001 ,-10871 ,-11018 ,-10310 , -8926 ,-7338 ,-5939 ,-4660 ,-3018 ,-596 ,2523 ,5764 ,8442 ,10135 ,10828 ,10830 ,10584 ,10470 ,10764 , 11791 ,13981 ,17453 ,21388 ,24062 ,23942 ,20946 ,16407 ,11647 ,6794 ,1272 ,-4686 ,-9502 ,-11511 ,-10550 , -8080 ,-5919 ,-5174 ,-6284 ,-9394 ,-14083 ,-18850 ,-21530 ,-20715 ,-16816 ,-11638 ,-6977 ,-3663 ,-1680 ,-699 , -234 ,414 ,1852 ,3984 ,5871 ,6471 ,5589 ,4047 ,2868 ,2355 ,1963 ,955 ,-945 ,-3495 ,-6304 , -9064 ,-11439 ,-12943 ,-13156 ,-12152 ,-10615 ,-9332 ,-8467 ,-7345 ,-5017 ,-1057 ,4196 ,9980 ,15485 ,19694 , 21434 ,20101 ,16429 ,12778 ,11095 ,12330 ,16053 ,21316 ,28116 ,32515 ,32767 ,30375 ,21439 ,10525 ,2322 , -4864 ,-12684 ,-21645 ,-28536 ,-29645 ,-25209 ,-19016 ,-15488 ,-16121 ,-19598 ,-23862 ,-27471 ,-29453 ,-28851 ,-25198 , -19211 ,-12574 ,-6864 ,-2671 ,399 ,3115 ,6029 ,9195 ,12181 ,14367 ,15373 ,15292 ,14532 ,13421 ,12036 , 10347 ,8407 ,6324 ,4131 ,1852 ,-293 ,-1853 ,-2464 ,-2228 ,-1726 ,-1635 ,-2275 ,-3464 ,-4667 ,-5249 , -4715 ,-2950 ,-370 ,2206 ,3996 ,4675 ,4406 ,3541 ,2435 ,1579 ,1679 ,3251 ,5973 ,8596 ,9757 , 8973 ,6811 ,4178 ,1656 ,-410 ,-1504 ,-1102 ,650 ,2667 ,3616 ,2890 ,806 ,-2021 ,-5186 ,-8319 , -10715 ,-11574 ,-10725 ,-8940 ,-7366 ,-6682 ,-6818 ,-7363 ,-8005 ,-8553 ,-8749 ,-8304 ,-7150 ,-5542 ,-3822 , -2135 ,-415 ,1378 ,3098 ,4494 ,5389 ,5757 ,5664 ,5251 ,4756 ,4461 ,4515 ,4783 ,4927 ,4658 , 3905 ,2790 ,1542 ,527 ,279 ,1257 ,3406 ,5933 ,7679 ,7861 ,6540 ,4454 ,2466 ,1165 ,804 , 1388 ,2692 ,4274 ,5594 ,6172 ,5657 ,3869 ,961 ,-2387 ,-5101 ,-6278 ,-5768 ,-4235 ,-2638 ,-1661 , -1528 ,-2150 ,-3236 ,-4294 ,-4719 ,-4102 ,-2525 ,-555 ,1081 ,1876 ,1733 ,907 ,-222 ,-1394 ,-2600 , -3998 ,-5684 ,-7511 ,-9120 ,-10152 ,-10489 ,-10340 ,-10106 ,-10114 ,-10390 ,-10661 ,-10553 ,-9775 ,-8112 ,-5365 , -1489 ,3086 ,7358 ,10218 ,11187 ,10767 ,10042 ,9975 ,11080 ,13583 ,17499 ,22228 ,26161 ,27224 ,24339 , 18543 ,12423 ,8123 ,5773 ,3890 ,1286 ,-1597 ,-3318 ,-3238 ,-2464 ,-2935 ,-5694 ,-10105 ,-14581 ,-17794 , -19164 ,-18578 ,-16173 ,-12628 ,-9348 ,-7865 ,-8663 ,-10569 ,-11481 ,-9894 ,-5896 ,-881 ,3567 ,6531 ,7852 , 7799 ,6869 ,5766 ,5215 ,5501 ,6158 ,6279 ,5287 ,3431 ,1526 ,178 ,-708 ,-1738 ,-3445 ,-5930 , -8920 ,-11986 ,-14609 ,-16187 ,-16241 ,-14772 ,-12412 ,-10062 ,-8262 ,-6853 ,-5186 ,-2588 ,1399 ,6913 ,13603 , 20200 ,24738 ,25747 ,23189 ,19199 ,15798 ,14570 ,16130 ,20019 ,27137 ,32365 ,32767 ,31187 ,21896 ,10179 , 2297 ,-4043 ,-11146 ,-20470 ,-28725 ,-31039 ,-26672 ,-19120 ,-13399 ,-11726 ,-13283 ,-16402 ,-19991 ,-23175 ,-24574 , -22959 ,-18439 ,-12552 ,-7035 ,-2679 ,717 ,3645 ,6369 ,8895 ,11075 ,12651 ,13363 ,13143 ,12220 ,10982 , 9752 ,8680 ,7734 ,6710 ,5335 ,3523 ,1575 ,44 ,-704 ,-772 ,-549 ,-304 ,-73 ,100 ,22 , -398 ,-817 ,-608 ,528 ,2152 ,3356 ,3455 ,2362 ,413 ,-1963 ,-4270 ,-5835 ,-5975 ,-4489 ,-1928 , 718 ,2644 ,3522 ,3303 ,1980 ,-281 ,-2864 ,-4811 ,-5400 ,-4659 ,-3325 ,-2279 ,-1987 ,-2287 ,-2554 , -2108 ,-711 ,1115 ,2297 ,1945 ,65 ,-2471 ,-4680 ,-6200 ,-7238 ,-7922 ,-7887 ,-6633 ,-4193 ,-1323 , 1021 ,2343 ,2787 ,2803 ,2757 ,2789 ,2871 ,2882 ,2721 ,2467 ,2423 ,2918 ,3985 ,5285 ,6369 , 6976 ,7018 ,6368 ,4847 ,2565 ,199 ,-1273 ,-1253 ,-3 ,1565 ,2546 ,2525 ,1571 ,-18 ,-1844 , -3381 ,-4037 ,-3418 ,-1586 ,927 ,3355 ,4983 ,5382 ,4564 ,3030 ,1568 ,842 ,1015 ,1696 ,2240 , 2151 ,1345 ,160 ,-842 ,-1204 ,-884 ,-302 ,-51 ,-502 ,-1654 ,-3301 ,-5278 ,-7487 ,-9741 ,-11685 , -12910 ,-13161 ,-12433 ,-10902 ,-8785 ,-6230 ,-3316 ,-204 ,2666 ,4592 ,4982 ,3832 ,1837 ,6 ,-806 , 32 ,3040 ,8349 ,14986 ,20652 ,22858 ,20764 ,15932 ,10988 ,7403 ,4675 ,1647 ,-1698 ,-4060 ,-4330 , -2872 ,-1150 ,-331 ,-578 ,-1585 ,-3277 ,-5629 ,-8011 ,-9237 ,-8590 ,-6673 ,-5006 ,-4684 ,-5485 ,-6258 , -6014 ,-4545 ,-2214 ,494 ,3013 ,4516 ,4140 ,1695 ,-1841 ,-4728 ,-5562 ,-4135 ,-1374 ,1397 ,3182 , 3577 ,2703 ,1100 ,-408 ,-1058 ,-602 ,491 ,1357 ,1393 ,699 ,-52 ,-191 ,407 ,1217 ,1410 , 315 ,-2255 ,-5942 ,-9949 ,-13260 ,-14967 ,-14650 ,-12597 ,-9647 ,-6695 ,-4213 ,-2140 ,-100 ,2379 ,5705 , 10021 ,14759 ,18528 ,19901 ,18252 ,14827 ,11425 ,9886 ,11454 ,15878 ,23610 ,30537 ,32767 ,31672 ,23925 , 13708 ,6374 ,736 ,-5472 ,-13916 ,-22145 ,-25655 ,-22931 ,-16504 ,-10962 ,-9032 ,-10597 ,-14195 ,-18477 ,-22320 , -24387 ,-23562 ,-19847 ,-14498 ,-9103 ,-4577 ,-947 ,2209 ,5266 ,8299 ,11033 ,12972 ,13733 ,13355 ,12276 , 11009 ,9860 ,8920 ,8174 ,7490 ,6558 ,5048 ,2918 ,570 ,-1398 ,-2586 ,-2979 ,-2833 ,-2483 ,-2241 , -2318 ,-2661 ,-2877 ,-2430 ,-1074 ,873 ,2695 ,3752 ,3836 ,3139 ,1996 ,731 ,-311 ,-768 ,-473 , 294 ,883 ,699 ,-416 ,-2219 ,-4395 ,-6739 ,-8999 ,-10685 ,-11251 ,-10538 ,-9002 ,-7408 ,-6279 ,-5626 , -5154 ,-4630 ,-4012 ,-3286 ,-2342 ,-1094 ,328 ,1643 ,2759 ,3945 ,5522 ,7359 ,8805 ,9261 ,8765 , 7880 ,7006 ,5985 ,4529 ,2909 ,1959 ,2287 ,3582 ,4816 ,5089 ,4184 ,2412 ,154 ,-2284 ,-4519 , -6037 ,-6458 ,-5826 ,-4586 ,-3289 ,-2292 ,-1673 ,-1320 ,-1050 ,-706 ,-209 ,435 ,1162 ,1880 ,2505 , 2977 ,3274 ,3422 ,3523 ,3755 ,4306 ,5188 ,6069 ,6358 ,5595 ,3852 ,1750 ,14 ,-1028 ,-1568 , -2038 ,-2779 ,-3917 ,-5402 ,-7030 ,-8444 ,-9241 ,-9194 ,-8405 ,-7212 ,-5956 ,-4801 ,-3732 ,-2640 ,-1350 , 356 ,2617 ,5242 ,7597 ,8883 ,8707 ,7448 ,6043 ,5398 ,5991 ,7896 ,10815 ,13837 ,15364 ,13886 , 9300 ,3409 ,-1321 ,-3793 ,-5032 ,-6818 ,-9668 ,-12301 ,-13043 ,-11543 ,-9033 ,-7148 ,-6689 ,-7415 ,-8643 , -9773 ,-10342 ,-9908 ,-8162 ,-5215 ,-1679 ,1639 ,4211 ,6042 ,7486 ,8801 ,9841 ,10149 ,9351 ,7506 , 5144 ,2998 ,1663 ,1345 ,1770 ,2246 ,1938 ,311 ,-2502 ,-5689 ,-8169 ,-9150 ,-8453 ,-6477 ,-3958 , -1702 ,-348 ,-97 ,-564 ,-928 ,-412 ,1190 ,3361 ,5201 ,5987 ,5562 ,4318 ,2876 ,1720 ,970 , 384 ,-464 ,-1937 ,-4141 ,-6869 ,-9684 ,-12074 ,-13614 ,-14085 ,-13515 ,-12099 ,-10041 ,-7440 ,-4301 ,-620 , 3567 ,8097 ,12489 ,15820 ,17056 ,15839 ,13031 ,10347 ,9331 ,10741 ,14721 ,20930 ,27921 ,32723 ,32212 , 25772 ,16351 ,8020 ,2188 ,-3259 ,-10694 ,-19145 ,-24690 ,-24463 ,-19642 ,-14229 ,-11431 ,-11681 ,-13716 ,-16443 , -19276 ,-21315 ,-21227 ,-18285 ,-13208 ,-7689 ,-3115 ,172 ,2602 ,4723 ,6837 ,9003 ,11125 ,12968 ,14180 , 14415 ,13490 ,11538 ,9025 ,6560 ,4541 ,2924 ,1360 ,-386 ,-2150 ,-3518 ,-4219 ,-4354 ,-4264 ,-4248 , -4405 ,-4664 ,-4838 ,-4657 ,-3845 ,-2303 ,-263 ,1734 ,3086 ,3430 ,2795 ,1564 ,283 ,-532 ,-544 , 315 ,1826 ,3525 ,4833 ,5223 ,4376 ,2269 ,-780 ,-4119 ,-6911 ,-8483 ,-8700 ,-8075 ,-7422 ,-7296 , -7699 ,-8263 ,-8660 ,-8767 ,-8518 ,-7745 ,-6314 ,-4377 ,-2387 ,-782 ,314 ,1081 ,1773 ,2611 ,3816 , 5556 ,7732 ,9925 ,11726 ,13117 ,14345 ,15334 ,15418 ,13943 ,11122 ,8083 ,5846 ,4330 ,2561 ,-142 , -3327 ,-5826 ,-6878 ,-6733 ,-6237 ,-6039 ,-6239 ,-6601 ,-6879 ,-6925 ,-6642 ,-5968 ,-4907 ,-3537 ,-1992 , -437 ,968 ,2137 ,3120 ,4064 ,5086 ,6132 ,6929 ,7058 ,6145 ,4099 ,1261 ,-1693 ,-4065 ,-5466 , -5923 ,-5750 ,-5346 ,-5023 ,-4880 ,-4717 ,-4101 ,-2628 ,-224 ,2730 ,5564 ,7634 ,8563 ,8332 ,7248 , 5902 ,5112 ,5724 ,8126 ,11685 ,14712 ,15391 ,13172 ,9302 ,5738 ,3348 ,1260 ,-1900 ,-6248 ,-10339 , -12559 ,-12584 ,-11365 ,-10010 ,-9042 ,-8655 ,-9156 ,-10689 ,-12625 ,-13633 ,-12671 ,-9910 ,-6576 ,-3919 ,-2351 , -1476 ,-735 ,108 ,987 ,1813 ,2609 ,3435 ,4288 ,5129 ,5966 ,6826 ,7589 ,7892 ,7270 ,5516 , 2960 ,378 ,-1419 ,-1994 ,-1395 ,-1 ,1640 ,2858 ,2988 ,1688 ,-708 ,-3203 ,-4645 ,-4374 ,-2538 , 92 ,2542 ,4015 ,4122 ,2991 ,1235 ,-304 ,-955 ,-524 ,673 ,2029 ,2933 ,3000 ,2168 ,670 , -1132 ,-2964 ,-4762 ,-6606 ,-8548 ,-10486 ,-12185 ,-13391 ,-13935 ,-13767 ,-12935 ,-11524 ,-9596 ,-7165 ,-4236 , -840 ,2985 ,7190 ,11559 ,15470 ,17931 ,18166 ,16339 ,13686 ,11798 ,11801 ,14157 ,18842 ,25080 ,30736 , 32766 ,29244 ,21233 ,12133 ,4587 ,-1778 ,-9058 ,-17690 ,-25003 ,-27537 ,-24518 ,-18632 ,-13590 ,-11419 ,-12021 , -14420 ,-17625 ,-20451 ,-21409 ,-19482 ,-14985 ,-9392 ,-4241 ,-279 ,2515 ,4451 ,5859 ,7062 ,8275 ,9416 , 10132 ,10107 ,9318 ,7979 ,6324 ,4543 ,2855 ,1489 ,509 ,-266 ,-1046 ,-1801 ,-2269 ,-2295 ,-2082 , -2026 ,-2279 ,-2543 ,-2316 ,-1329 ,256 ,2024 ,3591 ,4696 ,5113 ,4604 ,3073 ,798 ,-1530 ,-3084 , -3342 ,-2371 ,-748 ,804 ,1769 ,1946 ,1302 ,-157 ,-2322 ,-4799 ,-6901 ,-7943 ,-7684 ,-6498 ,-5120 , -4168 ,-3840 ,-3980 ,-4348 ,-4776 ,-5130 ,-5219 ,-4848 ,-3979 ,-2833 ,-1808 ,-1268 ,-1335 ,-1788 ,-2131 , -1822 ,-553 ,1599 ,4280 ,7069 ,9579 ,11391 ,12068 ,11381 ,9566 ,7291 ,5329 ,4276 ,4462 ,5889 , 8032 ,9817 ,10119 ,8529 ,5606 ,2284 ,-893 ,-3841 ,-6336 ,-7705 ,-7356 ,-5540 ,-3366 ,-1974 ,-1784 , -2542 ,-3852 ,-5466 ,-7105 ,-8321 ,-8682 ,-8061 ,-6653 ,-4772 ,-2764 ,-1063 ,-106 ,-11 ,-372 ,-469 , 269 ,2003 ,4541 ,7436 ,9978 ,11313 ,10922 ,9094 ,6849 ,5301 ,5103 ,6451 ,9264 ,12979 ,16192 , 17047 ,14574 ,9725 ,4776 ,1391 ,-703 ,-3010 ,-6331 ,-9750 ,-11553 ,-10979 ,-8949 ,-7240 ,-7141 ,-8830 , -11625 ,-14519 ,-16529 ,-16927 ,-15512 ,-12790 ,-9775 ,-7428 ,-6093 ,-5369 ,-4472 ,-2830 ,-467 ,2071 ,4128 , 5345 ,5768 ,5667 ,5298 ,4827 ,4392 ,4131 ,4123 ,4317 ,4597 ,4902 ,5251 ,5581 ,5611 ,4936 , 3370 ,1179 ,-1034 ,-2686 ,-3453 ,-3221 ,-2012 ,-105 ,1783 ,2683 ,1963 ,-157 ,-2719 ,-4665 ,-5401 , -4843 ,-3179 ,-768 ,1760 ,3583 ,4092 ,3312 ,1877 ,558 ,-192 ,-337 ,-66 ,365 ,684 ,642 , 107 ,-895 ,-2268 ,-3958 ,-5939 ,-8098 ,-10169 ,-11838 ,-12889 ,-13281 ,-13114 ,-12547 ,-11692 ,-10505 ,-8753 , -6142 ,-2511 ,2071 ,7369 ,12999 ,18269 ,22095 ,23407 ,21940 ,18738 ,15633 ,14220 ,15200 ,18478 ,23588 , 29128 ,32767 ,32294 ,26673 ,17762 ,8699 ,1008 ,-6065 ,-13901 ,-21983 ,-27710 ,-28779 ,-25378 ,-20029 ,-15536 , -13383 ,-13729 ,-16107 ,-19633 ,-22817 ,-23917 ,-21922 ,-17259 ,-11428 ,-5941 ,-1565 ,1676 ,4086 ,5999 ,7703 , 9377 ,10990 ,12261 ,12806 ,12374 ,11009 ,9037 ,6911 ,4984 ,3321 ,1683 ,-237 ,-2476 ,-4639 ,-6131 , -6615 ,-6281 ,-5676 ,-5256 ,-5079 ,-4882 ,-4384 ,-3490 ,-2285 ,-950 ,252 ,991 ,1017 ,378 ,-502 , -1026 ,-776 ,272 ,1791 ,3352 ,4622 ,5414 ,5601 ,5038 ,3630 ,1516 ,-826 ,-2743 ,-3777 ,-3947 , -3640 ,-3223 ,-2778 ,-2210 ,-1548 ,-1061 ,-1040 ,-1521 ,-2264 ,-2949 ,-3381 ,-3538 ,-3534 ,-3577 ,-3871 , -4457 ,-5123 ,-5507 ,-5331 ,-4524 ,-3157 ,-1367 ,632 ,2513 ,3954 ,4828 ,5268 ,5517 ,5750 ,6058 , 6508 ,7138 ,7875 ,8494 ,8711 ,8302 ,7210 ,5677 ,4276 ,3647 ,3922 ,4368 ,3782 ,1484 ,-2038 , -5550 ,-8146 ,-9839 ,-11099 ,-11983 ,-11922 ,-10334 ,-7265 ,-3326 ,830 ,4746 ,7912 ,9588 ,9218 ,7074 , 4343 ,2458 ,2347 ,4275 ,8103 ,13289 ,18550 ,21945 ,21899 ,18455 ,13378 ,8752 ,5396 ,2656 ,-379 , -3698 ,-6445 ,-7865 ,-7940 ,-7214 ,-6399 ,-6278 ,-7631 ,-10723 ,-14722 ,-17890 ,-18726 ,-17068 ,-14110 ,-11366 , -9659 ,-8898 ,-8523 ,-7967 ,-6852 ,-5112 ,-3108 ,-1546 ,-1008 ,-1432 ,-2053 ,-1953 ,-765 ,1092 ,2812 , 3828 ,4101 ,3930 ,3580 ,3121 ,2563 ,2038 ,1789 ,1978 ,2566 ,3389 ,4344 ,5442 ,6662 ,7792 , 8448 ,8277 ,7156 ,5230 ,2841 ,472 ,-1317 ,-2075 ,-1751 ,-821 ,-36 ,78 ,-489 ,-1392 ,-2307 , -3089 ,-3598 ,-3563 ,-2794 ,-1545 ,-531 ,-423 ,-1273 ,-2476 ,-3319 ,-3538 ,-3347 ,-3017 ,-2537 ,-1757 , -788 ,-157 ,-500 ,-2085 ,-4611 ,-7437 ,-9986 ,-11963 ,-13306 ,-14022 ,-14084 ,-13433 ,-12031 ,-9902 ,-7168 , -4047 ,-761 ,2594 ,6118 ,10020 ,14392 ,19011 ,23186 ,25891 ,26300 ,24285 ,21018 ,18147 ,17155 ,18636 , 21906 ,26747 ,31009 ,32767 ,32302 ,26818 ,17952 ,9249 ,1565 ,-5470 ,-13225 ,-21237 ,-26888 ,-27998 ,-24776 , -19982 ,-16534 ,-15657 ,-16875 ,-19110 ,-21387 ,-22707 ,-22047 ,-18952 ,-14084 ,-8900 ,-4600 ,-1396 ,1286 ,4026 , 6895 ,9537 ,11532 ,12595 ,12552 ,11349 ,9177 ,6508 ,3909 ,1723 ,-91 ,-1827 ,-3739 ,-5821 ,-7772 , -9155 ,-9657 ,-9312 ,-8488 ,-7621 ,-6909 ,-6229 ,-5343 ,-4128 ,-2619 ,-919 ,842 ,2475 ,3769 ,4631 , 5172 ,5568 ,5864 ,5974 ,5883 ,5783 ,5914 ,6284 ,6621 ,6616 ,6173 ,5388 ,4334 ,2973 ,1286 , -566 ,-2305 ,-3740 ,-4859 ,-5693 ,-6160 ,-6121 ,-5602 ,-4896 ,-4392 ,-4297 ,-4564 ,-5050 ,-5671 ,-6355 , -6884 ,-6906 ,-6162 ,-4692 ,-2801 ,-827 ,999 ,2525 ,3630 ,4314 ,4785 ,5330 ,6002 ,6473 ,6256 , 5108 ,3228 ,1128 ,-658 ,-1781 ,-2196 ,-2168 ,-2095 ,-2191 ,-2330 ,-2298 ,-2210 ,-2517 ,-3467 ,-4606 , -4974 ,-3836 ,-1136 ,2755 ,7473 ,12586 ,17171 ,19898 ,19897 ,17583 ,14412 ,11819 ,10456 ,10419 ,11750 , 14233 ,16732 ,17325 ,14719 ,9597 ,4210 ,325 ,-2357 ,-5517 ,-10016 ,-14621 ,-17036 ,-16079 ,-12707 ,-9096 , -7005 ,-6972 ,-8568 ,-10884 ,-12742 ,-13009 ,-11264 ,-8292 ,-5663 ,-4544 ,-4837 ,-5455 ,-5368 ,-4352 ,-2873 , -1522 ,-666 ,-458 ,-900 ,-1778 ,-2676 ,-3235 ,-3457 ,-3691 ,-4243 ,-5003 ,-5460 ,-5093 ,-3781 ,-1895 , -37 ,1328 ,2066 ,2314 ,2304 ,2239 ,2290 ,2625 ,3350 ,4416 ,5605 ,6662 ,7454 ,8010 ,8416 , 8688 ,8739 ,8431 ,7639 ,6284 ,4399 ,2223 ,205 ,-1178 ,-1742 ,-1769 ,-1833 ,-2406 ,-3555 ,-5007 , -6414 ,-7535 ,-8189 ,-8181 ,-7421 ,-6138 ,-4867 ,-4092 ,-3840 ,-3664 ,-3072 ,-1988 ,-756 ,256 ,990 , 1600 ,2114 ,2309 ,1948 ,1052 ,-133 ,-1397 ,-2680 ,-3984 ,-5293 ,-6661 ,-8201 ,-9835 ,-11093 ,-11390 , -10575 ,-9037 ,-7139 ,-4713 ,-1334 ,3014 ,7857 ,12813 ,17782 ,22230 ,24730 ,24035 ,20816 ,17716 ,17023 , 18363 ,19239 ,17871 ,15010 ,12699 ,11794 ,11294 ,9955 ,7795 ,5691 ,4010 ,2252 ,-47 ,-2590 ,-4714 , -6197 ,-7384 ,-8648 ,-10006 ,-11263 ,-12301 ,-13142 ,-13882 ,-14668 ,-15663 ,-16901 ,-18211 ,-19386 ,-20396 ,-21352 , -22258 ,-22924 ,-23188 ,-23136 ,-23016 ,-22976 ,-22992 ,-23051 ,-23283 ,-23845 ,-24729 ,-25772 ,-26859 ,-28015 ,-29288 , -30589 ,-31691 ,-32385 ,-32598 ,-32388 ,-31859 ,-31081 ,-30071 ,-28839 ,-27474 ,-26179 ,-25173 ,-24521 ,-24069 ,-23593 , -23023 ,-22486 ,-22107 ,-21802 ,-21307 ,-20431 ,-19241 ,-17968 ,-16763 ,-15570 ,-14262 ,-12834 ,-11437 ,-10221 ,-9185 , -8195 ,-7115 ,-5899 ,-4550 ,-3050 ,-1368 ,485 ,2432 ,4382 ,6293 ,8160 ,9948 ,11553 ,12851 ,13785 , 14415 ,14896 ,15403 ,16066 ,16932 ,17992 ,19225 ,20655 ,22312 ,24142 ,25965 ,27576 ,28895 ,30004 ,30974 , 31710 ,32000 ,31752 ,31141 ,30472 ,29917 ,29415 ,28835 ,28187 ,27643 ,27363 ,27336 ,27411 ,27439 ,27378 , 27268 ,27137 ,26946 ,26632 ,26166 ,25575 ,24888 ,24099 ,23197 ,22220 ,21242 ,20284 ,19272 ,18107 ,16790 , 15427 ,14099 ,12736 ,11158 ,9270 ,7221 ,5335 ,3876 ,2839 ,1974 ,1023 ,-46 ,-1053 ,-1842 ,-2496 , -3291 ,-4453 ,-5999 ,-7801 ,-9728 ,-11679 ,-13535 ,-15193 ,-16667 ,-18070 ,-19439 ,-20618 ,-21409 ,-21826 ,-22117 , -22510 ,-23016 ,-23525 ,-24026 ,-24625 ,-25352 ,-26055 ,-26570 ,-26920 ,-27261 ,-27629 ,-27833 ,-27634 ,-27005 ,-26150 , -25298 ,-24512 ,-23720 ,-22860 ,-21975 ,-21158 ,-20448 ,-19807 ,-19186 ,-18584 ,-18037 ,-17511 ,-16881 ,-16029 ,-14985 , -13905 ,-12917 ,-11972 ,-10929 ,-9760 ,-8618 ,-7674 ,-6912 ,-6130 ,-5131 ,-3862 ,-2382 ,-750 ,999 ,2815 , 4621 ,6378 ,8096 ,9774 ,11352 ,12730 ,13841 ,14677 ,15283 ,15783 ,16378 ,17225 ,18304 ,19409 ,20374 , 21250 ,22226 ,23337 ,24357 ,25005 ,25227 ,25195 ,25044 ,24709 ,24062 ,23160 ,22272 ,21643 ,21295 ,21100 , 21009 ,21141 ,21622 ,22372 ,23135 ,23715 ,24112 ,24383 ,24429 ,24047 ,23219 ,22217 ,21299 ,20354 ,19058 , 17458 ,16229 ,16126 ,17152 ,18415 ,18923 ,18430 ,17432 ,16425 ,15331 ,13734 ,11466 ,8830 ,6264 ,3954 , 1840 ,-122 ,-1835 ,-3183 ,-4150 ,-4779 ,-5101 ,-5189 ,-5251 ,-5561 ,-6255 ,-7261 ,-8461 ,-9851 ,-11478 , -13235 ,-14852 ,-16161 ,-17272 ,-18426 ,-19656 ,-20729 ,-21466 ,-22012 ,-22734 ,-23829 ,-25127 ,-26320 ,-27301 ,-28224 , -29263 ,-30386 ,-31383 ,-32076 ,-32419 ,-32438 ,-32145 ,-31551 ,-30745 ,-29888 ,-29118 ,-28482 ,-27969 ,-27565 ,-27253 , -26979 ,-26658 ,-26247 ,-25765 ,-25218 ,-24545 ,-23673 ,-22643 ,-21627 ,-20781 ,-20119 ,-19546 ,-19020 ,-18607 ,-18379 , -18292 ,-18203 ,-18000 ,-17650 ,-17140 ,-16388 ,-15291 ,-13821 ,-12081 ,-10242 ,-8471 ,-6911 ,-5685 ,-4860 ,-4384 , -4110 ,-3920 ,-3812 ,-3828 ,-3880 ,-3701 ,-3025 ,-1818 ,-301 ,1275 ,2851 ,4533 ,6382 ,8272 ,9981 , 11394 ,12566 ,13610 ,14552 ,15332 ,15925 ,16445 ,17083 ,17960 ,19023 ,20122 ,21155 ,22143 ,23140 ,24121 , 24982 ,25659 ,26207 ,26738 ,27308 ,27896 ,28476 ,29062 ,29651 ,30165 ,30495 ,30584 ,30428 ,30002 ,29225 , 28052 ,26564 ,24904 ,23111 ,21101 ,18863 ,16657 ,14926 ,13927 ,13499 ,13229 ,12856 ,12462 ,12240 ,12140 , 11826 ,10994 ,9662 ,8096 ,6488 ,4805 ,2959 ,1052 ,-636 ,-1887 ,-2697 ,-3191 ,-3456 ,-3514 ,-3438 , -3383 ,-3494 ,-3830 ,-4427 ,-5393 ,-6840 ,-8683 ,-10575 ,-12129 ,-13218 ,-14014 ,-14695 ,-15192 ,-15254 ,-14768 , -13916 ,-13012 ,-12218 ,-11497 ,-10792 ,-10168 ,-9713 ,-9371 ,-8956 ,-8362 ,-7693 ,-7120 ,-6641 ,-6040 ,-5137 , -4027 ,-3050 ,-2486 ,-2336 ,-2395 ,-2512 ,-2724 ,-3137 ,-3722 ,-4274 ,-4555 ,-4432 ,-3894 ,-3002 ,-1850 , -559 ,767 ,2062 ,3238 ,4115 ,4487 ,4308 ,3768 ,3125 ,2471 ,1751 ,1007 ,522 ,609 ,1314 , 2421 ,3755 ,5360 ,7299 ,9361 ,11101 ,12208 ,12717 ,12831 ,12643 ,12131 ,11375 ,10636 ,10194 ,10206 , 10725 ,11741 ,13142 ,14756 ,16539 ,18582 ,20761 ,22544 ,23456 ,23742 ,24104 ,24577 ,24164 ,22224 ,19957 , 19465 ,20840 ,20955 ,16339 ,7328 ,-1502 ,-5599 ,-4683 ,-2283 ,-1570 ,-2558 ,-3375 ,-3177 ,-2914 ,-3668 , -5228 ,-6634 ,-7498 ,-8256 ,-9328 ,-10527 ,-11398 ,-11798 ,-11940 ,-12030 ,-12078 ,-12046 ,-12016 ,-12148 ,-12546 , -13206 ,-14081 ,-15144 ,-16378 ,-17756 ,-19210 ,-20653 ,-21992 ,-23155 ,-24097 ,-24802 ,-25299 ,-25649 ,-25901 ,-26050 , -26068 ,-25978 ,-25886 ,-25912 ,-26091 ,-26357 ,-26628 ,-26882 ,-27142 ,-27404 ,-27627 ,-27788 ,-27931 ,-28124 ,-28378 , -28609 ,-28716 ,-28685 ,-28615 ,-28625 ,-28733 ,-28843 ,-28857 ,-28788 ,-28743 ,-28789 ,-28855 ,-28787 ,-28481 ,-27962 , -27329 ,-26644 ,-25910 ,-25111 ,-24266 ,-23415 ,-22580 ,-21755 ,-20931 ,-20104 ,-19266 ,-18417 ,-17588 ,-16841 ,-16205 , -15632 ,-15030 ,-14348 ,-13630 ,-12933 ,-12239 ,-11457 ,-10530 ,-9496 ,-8424 ,-7324 ,-6161 ,-4956 ,-3824 ,-2873 , -2065 ,-1228 ,-237 ,837 ,1771 ,2414 ,2838 ,3260 ,3815 ,4422 ,4898 ,5166 ,5326 ,5506 ,5703 , 5814 ,5793 ,5731 ,5749 ,5861 ,6014 ,6210 ,6529 ,7011 ,7564 ,8072 ,8538 ,9063 ,9671 ,10215 , 10520 ,10569 ,10496 ,10400 ,10225 ,9843 ,9232 ,8530 ,7929 ,7554 ,7411 ,7415 ,7462 ,7510 ,7615 , 7868 ,8280 ,8739 ,9113 ,9371 ,9578 ,9768 ,9888 ,9881 ,9801 ,9786 ,9941 ,10277 ,10760 ,11364 , 12055 ,12777 ,13522 ,14374 ,15412 ,16563 ,17620 ,18469 ,19216 ,20059 ,21009 ,21868 ,22469 ,22897 ,23385 , 24034 ,24718 ,25277 ,25717 ,26184 ,26767 ,27406 ,27995 ,28532 ,29113 ,29797 ,30506 ,31089 ,31467 ,31718 , 31990 ,32319 ,32545 ,32444 ,31937 ,31158 ,30290 ,29375 ,28316 ,27059 ,25695 ,24384 ,23213 ,22185 ,21299 , 20568 ,19951 ,19345 ,18666 ,17934 ,17198 ,16436 ,15555 ,14514 ,13370 ,12190 ,10968 ,9693 ,8459 ,7431 , 6677 ,6101 ,5581 ,5146 ,4933 ,4966 ,5045 ,4895 ,4420 ,3743 ,3016 ,2240 ,1332 ,327 ,-578 , -1236 ,-1691 ,-2038 ,-2189 ,-1954 ,-1382 ,-798 ,-356 ,236 ,1222 ,2136 ,2125 ,1146 ,326 ,526 , 838 ,-536 ,-3483 ,-4887 ,-1435 ,6435 ,14224 ,17523 ,16055 ,13185 ,11922 ,12236 ,12255 ,11032 ,9372 , 8355 ,7995 ,7583 ,6782 ,5879 ,5171 ,4555 ,3791 ,2852 ,1879 ,915 ,-135 ,-1336 ,-2641 ,-3976 , -5319 ,-6665 ,-7981 ,-9240 ,-10455 ,-11656 ,-12837 ,-13970 ,-15072 ,-16207 ,-17427 ,-18701 ,-19964 ,-21207 ,-22508 , -23924 ,-25384 ,-26720 ,-27841 ,-28817 ,-29768 ,-30683 ,-31412 ,-31845 ,-32062 ,-32245 ,-32462 ,-32605 ,-32540 ,-32284 , -31984 ,-31735 ,-31491 ,-31153 ,-30716 ,-30286 ,-29955 ,-29702 ,-29426 ,-29074 ,-28690 ,-28365 ,-28132 ,-27934 ,-27677 , -27311 ,-26842 ,-26288 ,-25641 ,-24880 ,-24012 ,-23069 ,-22072 ,-21017 ,-19902 ,-18777 ,-17731 ,-16830 ,-16059 ,-15354 , -14655 ,-13950 ,-13255 ,-12561 ,-11822 ,-10968 ,-9948 ,-8761 ,-7448 ,-6054 ,-4596 ,-3078 ,-1536 ,-56 ,1269 , 2397 ,3346 ,4153 ,4843 ,5425 ,5905 ,6302 ,6647 ,6999 ,7419 ,7926 ,8471 ,8980 ,9427 ,9855 , 10306 ,10764 ,11178 ,11533 ,11874 ,12256 ,12697 ,13178 ,13664 ,14118 ,14509 ,14842 ,15167 ,15517 ,15829 , 15978 ,15891 ,15638 ,15355 ,15109 ,14842 ,14489 ,14086 ,13750 ,13569 ,13530 ,13554 ,13578 ,13597 ,13651 , 13778 ,13968 ,14135 ,14169 ,14016 ,13725 ,13376 ,12982 ,12490 ,11894 ,11295 ,10821 ,10495 ,10227 ,9950 , 9698 ,9539 ,9461 ,9380 ,9243 ,9064 ,8861 ,8599 ,8232 ,7773 ,7293 ,6839 ,6398 ,5934 ,5421 , 4848 ,4216 ,3572 ,3008 ,2593 ,2293 ,2002 ,1664 ,1328 ,1089 ,984 ,984 ,1047 ,1152 ,1277 , 1398 ,1516 ,1665 ,1828 ,1895 ,1748 ,1413 ,1065 ,853 ,737 ,561 ,272 ,20 ,-1 ,221 , 504 ,681 ,779 ,953 ,1274 ,1617 ,1790 ,1726 ,1549 ,1450 ,1510 ,1669 ,1829 ,1989 ,2256 , 2730 ,3387 ,4107 ,4796 ,5474 ,6217 ,7037 ,7862 ,8614 ,9283 ,9890 ,10449 ,10979 ,11532 ,12156 , 12833 ,13522 ,14250 ,15087 ,16001 ,16839 ,17521 ,18142 ,18791 ,19309 ,19456 ,19317 ,19279 ,19447 ,19343 , 18547 ,17538 ,17326 ,17988 ,17957 ,15430 ,10520 ,5570 ,2984 ,2977 ,3724 ,3500 ,2205 ,808 ,-142 , -1010 ,-2307 ,-3952 ,-5475 ,-6640 ,-7628 ,-8678 ,-9782 ,-10781 ,-11594 ,-12276 ,-12915 ,-13559 ,-14215 ,-14870 , -15499 ,-16097 ,-16718 ,-17437 ,-18280 ,-19170 ,-20007 ,-20759 ,-21483 ,-22248 ,-23054 ,-23828 ,-24500 ,-25064 ,-25584 , -26134 ,-26739 ,-27362 ,-27941 ,-28447 ,-28911 ,-29399 ,-29943 ,-30508 ,-31019 ,-31434 ,-31768 ,-32054 ,-32292 ,-32454 , -32535 ,-32560 ,-32548 ,-32471 ,-32292 ,-32021 ,-31728 ,-31482 ,-31311 ,-31216 ,-31199 ,-31259 ,-31360 ,-31447 ,-31494 , -31531 ,-31599 ,-31698 ,-31778 ,-31782 ,-31676 ,-31454 ,-31131 ,-30741 ,-30331 ,-29938 ,-29563 ,-29184 ,-28794 ,-28419 , -28107 ,-27892 ,-27761 ,-27660 ,-27534 ,-27376 ,-27234 ,-27145 ,-27065 ,-26873 ,-26467 ,-25852 ,-25117 ,-24329 ,-23472 , -22509 ,-21479 ,-20501 ,-19658 ,-18921 ,-18189 ,-17427 ,-16704 ,-16108 ,-15622 ,-15123 ,-14511 ,-13798 ,-13063 ,-12320 , -11482 ,-10456 ,-9256 ,-7977 ,-6683 ,-5340 ,-3885 ,-2329 ,-756 ,777 ,2296 ,3846 ,5407 ,6894 ,8251 , 9493 ,10663 ,11760 ,12740 ,13571 ,14267 ,14859 ,15372 ,15845 ,16345 ,16934 ,17627 ,18383 ,19175 ,20018 , 20946 ,21964 ,23035 ,24107 ,25136 ,26074 ,26855 ,27418 ,27745 ,27885 ,27921 ,27904 ,27825 ,27663 ,27464 , 27353 ,27438 ,27706 ,28036 ,28337 ,28636 ,29013 ,29459 ,29864 ,30133 ,30281 ,30375 ,30408 ,30295 ,29977 , 29494 ,28925 ,28302 ,27626 ,26953 ,26399 ,26038 ,25818 ,25616 ,25374 ,25154 ,25064 ,25147 ,25354 ,25605 , 25856 ,26105 ,26352 ,26558 ,26647 ,26566 ,26333 ,26012 ,25638 ,25170 ,24532 ,23717 ,22825 ,21975 ,21210 , 20480 ,19741 ,19021 ,18412 ,17973 ,17672 ,17422 ,17149 ,16861 ,16636 ,16560 ,16643 ,16799 ,16890 ,16834 , 16645 ,16394 ,16120 ,15795 ,15370 ,14855 ,14320 ,13818 ,13335 ,12817 ,12258 ,11726 ,11296 ,10976 ,10723 , 10545 ,10506 ,10620 ,10768 ,10799 ,10705 ,10608 ,10562 ,10457 ,10180 ,9807 ,9482 ,9138 ,8536 ,7671 , 6940 ,6659 ,6529 ,5920 ,4849 ,4348 ,5482 ,8012 ,10371 ,11131 ,10304 ,9041 ,8252 ,7835 ,7205 , 6161 ,4985 ,3909 ,2821 ,1535 ,78 ,-1410 ,-2926 ,-4566 ,-6297 ,-7920 ,-9287 ,-10443 ,-11487 ,-12392 , -13055 ,-13488 ,-13842 ,-14224 ,-14572 ,-14772 ,-14854 ,-15004 ,-15373 ,-15943 ,-16605 ,-17333 ,-18224 ,-19357 ,-20679 , -22044 ,-23347 ,-24587 ,-25811 ,-27026 ,-28191 ,-29255 ,-30181 ,-30938 ,-31511 ,-31922 ,-32224 ,-32446 ,-32549 ,-32468 , -32203 ,-31854 ,-31550 ,-31339 ,-31157 ,-30902 ,-30543 ,-30154 ,-29864 ,-29751 ,-29783 ,-29850 ,-29864 ,-29821 ,-29773 , -29730 ,-29628 ,-29382 ,-28974 ,-28454 ,-27875 ,-27258 ,-26631 ,-26057 ,-25604 ,-25285 ,-25074 ,-24987 ,-25092 ,-25416 , -25862 ,-26277 ,-26598 ,-26881 ,-27173 ,-27383 ,-27347 ,-26992 ,-26403 ,-25683 ,-24809 ,-23677 ,-22271 ,-20730 ,-19218 , -17778 ,-16351 ,-14929 ,-13602 ,-12463 ,-11490 ,-10593 ,-9748 ,-9021 ,-8438 ,-7879 ,-7173 ,-6286 ,-5366 ,-4568 , -3861 ,-3054 ,-2010 ,-786 ,460 ,1658 ,2875 ,4189 ,5578 ,6948 ,8229 ,9409 ,10481 ,11431 ,12280 , 13084 ,13851 ,14470 ,14811 ,14889 ,14880 ,14949 ,15086 ,15152 ,15097 ,15038 ,15136 ,15426 ,15817 ,16238 , 16703 ,17252 ,17858 ,18455 ,18989 ,19424 ,19688 ,19698 ,19451 ,19072 ,18712 ,18420 ,18136 ,17799 ,17452 , 17196 ,17113 ,17208 ,17431 ,17695 ,17915 ,18052 ,18153 ,18293 ,18479 ,18620 ,18615 ,18468 ,18264 ,18062 , 17821 ,17467 ,16990 ,16478 ,16043 ,15770 ,15680 ,15731 ,15827 ,15883 ,15894 ,15948 ,16119 ,16382 ,16640 , 16866 ,17149 ,17598 ,18184 ,18755 ,19180 ,19475 ,19737 ,20005 ,20194 ,20196 ,19990 ,19637 ,19183 ,18617 , 17926 ,17158 ,16380 ,15615 ,14855 ,14132 ,13544 ,13141 ,12847 ,12535 ,12213 ,12036 ,12129 ,12416 ,12691 , 12834 ,12903 ,12970 ,12972 ,12766 ,12340 ,11861 ,11501 ,11257 ,10994 ,10640 ,10275 ,10028 ,9936 ,9947 , 10038 ,10267 ,10694 ,11266 ,11838 ,12314 ,12729 ,13173 ,13642 ,14028 ,14269 ,14441 ,14626 ,14742 ,14617 , 14269 ,13968 ,13889 ,13776 ,13207 ,12242 ,11634 ,12144 ,13665 ,15223 ,15916 ,15731 ,15349 ,15304 ,15507 , 15586 ,15422 ,15222 ,15164 ,15162 ,15007 ,14585 ,13914 ,13036 ,11976 ,10774 ,9494 ,8181 ,6869 ,5625 , 4531 ,3609 ,2790 ,2010 ,1314 ,811 ,504 ,214 ,-268 ,-991 ,-1813 ,-2582 ,-3295 ,-4083 ,-5045 , -6152 ,-7302 ,-8440 ,-9582 ,-10765 ,-11999 ,-13287 ,-14663 ,-16160 ,-17766 ,-19416 ,-21031 ,-22569 ,-24007 ,-25301 , -26378 ,-27169 ,-27654 ,-27876 ,-27930 ,-27917 ,-27904 ,-27898 ,-27886 ,-27900 ,-28044 ,-28418 ,-29014 ,-29692 ,-30284 , -30715 ,-31019 ,-31240 ,-31338 ,-31212 ,-30815 ,-30234 ,-29635 ,-29144 ,-28770 ,-28463 ,-28214 ,-28101 ,-28199 ,-28481 , -28821 ,-29107 ,-29326 ,-29519 ,-29660 ,-29610 ,-29227 ,-28496 ,-27548 ,-26547 ,-25580 ,-24639 ,-23687 ,-22730 ,-21826 , -21029 ,-20338 ,-19686 ,-18983 ,-18188 ,-17312 ,-16382 ,-15393 ,-14328 ,-13192 ,-12044 ,-10955 ,-9973 ,-9128 ,-8453 , -7975 ,-7686 ,-7525 ,-7404 ,-7235 ,-6946 ,-6484 ,-5842 ,-5053 ,-4149 ,-3133 ,-1994 ,-766 ,463 ,1600 , 2599 ,3438 ,4072 ,4455 ,4615 ,4693 ,4870 ,5258 ,5872 ,6688 ,7700 ,8894 ,10224 ,11628 ,13061 , 14495 ,15879 ,17125 ,18152 ,18938 ,19490 ,19817 ,19923 ,19863 ,19759 ,19750 ,19917 ,20269 ,20779 ,21431 , 22234 ,23205 ,24345 ,25602 ,26861 ,27993 ,28937 ,29734 ,30451 ,31073 ,31505 ,31691 ,31708 ,31714 ,31794 , 31895 ,31928 ,31881 ,31829 ,31837 ,31902 ,31989 ,32096 ,32242 ,32416 ,32558 ,32593 ,32476 ,32185 ,31705 , 31028 ,30165 ,29141 ,27972 ,26653 ,25170 ,23528 ,21772 ,19982 ,18251 ,16627 ,15092 ,13578 ,12038 ,10483 , 8951 ,7442 ,5913 ,4328 ,2698 ,1049 ,-621 ,-2325 ,-4026 ,-5621 ,-7013 ,-8187 ,-9182 ,-10008 ,-10615 , -10965 ,-11090 ,-11066 ,-10931 ,-10686 ,-10361 ,-10050 ,-9831 ,-9666 ,-9425 ,-9012 ,-8461 ,-7893 ,-7394 ,-6943 , -6454 ,-5872 ,-5232 ,-4600 ,-3991 ,-3366 ,-2742 ,-2236 ,-1919 ,-1619 ,-1000 ,64 ,1288 ,2313 ,3220 , 4467 ,6221 ,7998 ,9259 ,10243 ,11721 ,13725 ,14927 ,13828 ,10623 ,7418 ,6327 ,7521 ,9402 ,10497 , 10793 ,11187 ,12132 ,13223 ,13933 ,14287 ,14644 ,15089 ,15331 ,15135 ,14615 ,14059 ,13573 ,13054 ,12422 , 11797 ,11377 ,11229 ,11247 ,11306 ,11423 ,11728 ,12262 ,12854 ,13227 ,13252 ,13056 ,12863 ,12730 ,12480 , 11918 ,11065 ,10157 ,9428 ,8913 ,8474 ,7979 ,7417 ,6869 ,6389 ,5937 ,5402 ,4696 ,3798 ,2745 , 1592 ,386 ,-835 ,-2046 ,-3251 ,-4477 ,-5711 ,-6871 ,-7864 ,-8704 ,-9527 ,-10463 ,-11488 ,-12463 ,-13316 , -14150 ,-15121 ,-16250 ,-17370 ,-18296 ,-18991 ,-19576 ,-20170 ,-20774 ,-21297 ,-21678 ,-21970 ,-22310 ,-22816 ,-23505 , -24297 ,-25095 ,-25863 ,-26626 ,-27394 ,-28108 ,-28654 ,-28942 ,-28953 ,-28739 ,-28379 ,-27933 ,-27435 ,-26895 ,-26316 , -25717 ,-25139 ,-24639 ,-24264 ,-24020 ,-23861 ,-23710 ,-23496 ,-23197 ,-22836 ,-22434 ,-21960 ,-21342 ,-20536 ,-19589 , -18625 ,-17744 ,-16965 ,-16240 ,-15537 ,-14852 ,-14165 ,-13395 ,-12457 ,-11332 ,-10065 ,-8672 ,-7101 ,-5311 ,-3375 , -1465 ,281 ,1856 ,3321 ,4684 ,5882 ,6869 ,7691 ,8449 ,9207 ,9973 ,10753 ,11593 ,12552 ,13646 , 14827 ,16023 ,17185 ,18304 ,19408 ,20506 ,21561 ,22492 ,23225 ,23750 ,24142 ,24525 ,24998 ,25579 ,26203 , 26783 ,27298 ,27833 ,28498 ,29309 ,30135 ,30812 ,31284 ,31632 ,31964 ,32290 ,32527 ,32600 ,32505 ,32290 , 31998 ,31649 ,31228 ,30688 ,29962 ,29012 ,27876 ,26646 ,25383 ,24083 ,22728 ,21352 ,20028 ,18791 ,17601 , 16395 ,15158 ,13932 ,12759 ,11638 ,10518 ,9313 ,7932 ,6334 ,4597 ,2882 ,1299 ,-211 ,-1812 ,-3576 , -5364 ,-6939 ,-8190 ,-9230 ,-10258 ,-11373 ,-12509 ,-13535 ,-14384 ,-15105 ,-15818 ,-16612 ,-17456 ,-18188 ,-18655 , -18853 ,-18948 ,-19088 ,-19226 ,-19187 ,-18881 ,-18428 ,-18011 ,-17671 ,-17293 ,-16794 ,-16253 ,-15809 ,-15490 ,-15170 , -14700 ,-14028 ,-13235 ,-12461 ,-11805 ,-11216 ,-10521 ,-9614 ,-8628 ,-7828 ,-7266 ,-6676 ,-5816 ,-4835 ,-4075 , -3521 ,-2743 ,-1540 ,-371 ,246 ,656 ,1826 ,3887 ,5317 ,4196 ,397 ,-3939 ,-6382 ,-6453 ,-5650 , -5500 ,-6096 ,-6581 ,-6534 ,-6406 ,-6754 ,-7534 ,-8317 ,-8930 ,-9588 ,-10496 ,-11558 ,-12541 ,-13362 ,-14098 , -14782 ,-15329 ,-15674 ,-15903 ,-16192 ,-16612 ,-17071 ,-17424 ,-17657 ,-17910 ,-18340 ,-18949 ,-19558 ,-19962 ,-20076 , -19971 ,-19753 ,-19453 ,-19026 ,-18426 ,-17687 ,-16906 ,-16189 ,-15597 ,-15156 ,-14870 ,-14755 ,-14819 ,-15049 ,-15390 , -15766 ,-16092 ,-16315 ,-16422 ,-16426 ,-16341 ,-16172 ,-15915 ,-15603 ,-15312 ,-15142 ,-15147 ,-15310 ,-15576 ,-15934 , -16410 ,-17009 ,-17653 ,-18231 ,-18678 ,-19007 ,-19226 ,-19294 ,-19157 ,-18849 ,-18479 ,-18149 ,-17870 ,-17625 ,-17449 , -17434 ,-17632 ,-18002 ,-18448 ,-18927 ,-19446 ,-19991 ,-20479 ,-20816 ,-20995 ,-21105 ,-21239 ,-21400 ,-21513 ,-21528 , -21486 ,-21472 ,-21526 ,-21622 ,-21727 ,-21859 ,-22053 ,-22288 ,-22483 ,-22571 ,-22570 ,-22538 ,-22486 ,-22346 ,-22051 , -21635 ,-21213 ,-20856 ,-20510 ,-20052 ,-19423 ,-18689 ,-17948 ,-17208 ,-16361 ,-15314 ,-14090 ,-12801 ,-11523 ,-10246 , -8942 ,-7644 ,-6428 ,-5328 ,-4322 ,-3396 ,-2584 ,-1901 ,-1271 ,-567 ,265 ,1157 ,2022 ,2888 ,3878 , 5060 ,6356 ,7609 ,8750 ,9839 ,10961 ,12092 ,13105 ,13908 ,14536 ,15103 ,15678 ,16254 ,16825 ,17462 , 18247 ,19178 ,20154 ,21104 ,22068 ,23132 ,24289 ,25413 ,26367 ,27110 ,27673 ,28086 ,28365 ,28556 ,28732 , 28928 ,29120 ,29292 ,29489 ,29782 ,30174 ,30594 ,30982 ,31356 ,31758 ,32164 ,32475 ,32607 ,32558 ,32398 , 32198 ,31996 ,31801 ,31615 ,31427 ,31231 ,31030 ,30839 ,30666 ,30488 ,30253 ,29904 ,29399 ,28733 ,27934 , 27041 ,26085 ,25087 ,24082 ,23123 ,22255 ,21478 ,20749 ,20054 ,19440 ,18987 ,18701 ,18476 ,18163 ,17703 , 17156 ,16622 ,16134 ,15640 ,15082 ,14466 ,13862 ,13353 ,13004 ,12847 ,12857 ,12946 ,13000 ,12958 ,12845 , 12707 ,12511 ,12151 ,11539 ,10698 ,9715 ,8636 ,7438 ,6131 ,4843 ,3736 ,2836 ,2034 ,1281 ,712 , 456 ,372 ,153 ,-255 ,-540 ,-516 ,-598 ,-1420 ,-2853 ,-3732 ,-2961 ,-910 ,656 ,230 ,-2008 , -4576 ,-6312 ,-7331 ,-8435 ,-9987 ,-11640 ,-12985 ,-14074 ,-15228 ,-16576 ,-17971 ,-19288 ,-20576 ,-21934 ,-23331 , -24628 ,-25721 ,-26599 ,-27305 ,-27899 ,-28439 ,-28948 ,-29378 ,-29661 ,-29816 ,-29990 ,-30352 ,-30930 ,-31569 ,-32045 , -32243 ,-32205 ,-32043 ,-31792 ,-31371 ,-30669 ,-29668 ,-28458 ,-27153 ,-25821 ,-24509 ,-23317 ,-22377 ,-21747 ,-21340 , -20993 ,-20613 ,-20221 ,-19854 ,-19459 ,-18916 ,-18165 ,-17283 ,-16400 ,-15589 ,-14826 ,-14067 ,-13333 ,-12708 ,-12272 , -12056 ,-12036 ,-12144 ,-12299 ,-12436 ,-12514 ,-12497 ,-12334 ,-11981 ,-11461 ,-10872 ,-10303 ,-9751 ,-9154 ,-8522 , -7987 ,-7695 ,-7646 ,-7691 ,-7697 ,-7666 ,-7675 ,-7719 ,-7682 ,-7476 ,-7159 ,-6871 ,-6679 ,-6529 ,-6361 , -6215 ,-6195 ,-6344 ,-6600 ,-6890 ,-7221 ,-7643 ,-8147 ,-8636 ,-8991 ,-9168 ,-9198 ,-9125 ,-8965 ,-8725 , -8456 ,-8248 ,-8171 ,-8200 ,-8225 ,-8130 ,-7892 ,-7573 ,-7219 ,-6769 ,-6091 ,-5110 ,-3886 ,-2562 ,-1247 , 28 ,1264 ,2453 ,3582 ,4652 ,5648 ,6503 ,7144 ,7588 ,7960 ,8400 ,8942 ,9504 ,9991 ,10389 , 10755 ,11133 ,11509 ,11830 ,12043 ,12112 ,12026 ,11810 ,11515 ,11173 ,10767 ,10268 ,9704 ,9169 ,8732 , 8352 ,7909 ,7329 ,6677 ,6083 ,5620 ,5242 ,4867 ,4472 ,4102 ,3800 ,3572 ,3412 ,3344 ,3401 , 3566 ,3751 ,3858 ,3861 ,3821 ,3818 ,3859 ,3880 ,3819 ,3696 ,3606 ,3642 ,3817 ,4079 ,4374 , 4702 ,5099 ,5591 ,6162 ,6775 ,7410 ,8063 ,8712 ,9292 ,9726 ,10007 ,10232 ,10545 ,11024 ,11628 , 12264 ,12900 ,13594 ,14411 ,15336 ,16279 ,17170 ,18027 ,18929 ,19927 ,20998 ,22062 ,23032 ,23863 ,24585 , 25293 ,26091 ,27002 ,27935 ,28753 ,29389 ,29874 ,30269 ,30607 ,30904 ,31204 ,31555 ,31924 ,32197 ,32295 , 32293 ,32346 ,32488 ,32537 ,32272 ,31677 ,30944 ,30182 ,29243 ,27917 ,26272 ,24625 ,23144 ,21636 ,19903 , 18165 ,16840 ,15909 ,14849 ,13390 ,12024 ,11305 ,10778 ,9277 ,6659 ,4744 ,5751 ,9703 ,13974 ,15774 , 14808 ,13119 ,12568 ,13057 ,13262 ,12453 ,11065 ,9738 ,8445 ,6738 ,4477 ,1980 ,-430 ,-2718 ,-4952 , -7055 ,-8836 ,-10191 ,-11173 ,-11922 ,-12599 ,-13365 ,-14303 ,-15356 ,-16406 ,-17452 ,-18663 ,-20213 ,-22042 ,-23848 , -25312 ,-26311 ,-26907 ,-27180 ,-27115 ,-26665 ,-25857 ,-24793 ,-23570 ,-22256 ,-20946 ,-19805 ,-19012 ,-18634 ,-18601 , -18774 ,-19038 ,-19332 ,-19613 ,-19858 ,-20061 ,-20238 ,-20391 ,-20503 ,-20557 ,-20587 ,-20668 ,-20888 ,-21300 ,-21922 , -22744 ,-23741 ,-24852 ,-25950 ,-26873 ,-27514 ,-27892 ,-28101 ,-28181 ,-28053 ,-27619 ,-26917 ,-26132 ,-25431 ,-24824 , -24208 ,-23535 ,-22878 ,-22313 ,-21796 ,-21181 ,-20350 ,-19281 ,-18006 ,-16550 ,-14918 ,-13143 ,-11280 ,-9396 ,-7579 , -5948 ,-4602 ,-3541 ,-2650 ,-1820 ,-1063 ,-494 ,-179 ,-10 ,245 ,775 ,1592 ,2553 ,3495 ,4364 , 5217 ,6123 ,7069 ,7969 ,8751 ,9422 ,10026 ,10563 ,11014 ,11437 ,12006 ,12891 ,14109 ,15520 ,16992 , 18517 ,20169 ,21946 ,23730 ,25387 ,26859 ,28139 ,29193 ,29946 ,30361 ,30484 ,30405 ,30173 ,29780 ,29220 , 28548 ,27864 ,27243 ,26657 ,25975 ,25060 ,23883 ,22543 ,21152 ,19705 ,18070 ,16123 ,13891 ,11528 ,9187 , 6902 ,4619 ,2312 ,47 ,-2050 ,-3870 ,-5383 ,-6626 ,-7662 ,-8533 ,-9243 ,-9787 ,-10207 ,-10598 ,-11043 , -11540 ,-11997 ,-12337 ,-12574 ,-12790 ,-13032 ,-13246 ,-13329 ,-13239 ,-13046 ,-12875 ,-12802 ,-12803 ,-12805 ,-12777 , -12788 ,-12954 ,-13328 ,-13834 ,-14319 ,-14668 ,-14859 ,-14913 ,-14844 ,-14642 ,-14329 ,-13966 ,-13583 ,-13128 ,-12525 , -11785 ,-11024 ,-10347 ,-9717 ,-8965 ,-7938 ,-6625 ,-5127 ,-3522 ,-1779 ,217 ,2544 ,5170 ,7950 ,10705 , 13304 ,15707 ,17914 ,19888 ,21521 ,22719 ,23518 ,24088 ,24618 ,25195 ,25805 ,26446 ,27187 ,28095 ,29129 , 30151 ,31025 ,31705 ,32209 ,32524 ,32542 ,32123 ,31221 ,29981 ,28645 ,27327 ,25916 ,24306 ,22706 ,21557 , 21032 ,20762 ,20290 ,19746 ,19704 ,20234 ,20488 ,19697 ,18401 ,17993 ,18692 ,18549 ,15225 ,8849 ,2424 , -954 ,-989 ,27 ,-34 ,-1255 ,-2486 ,-3243 ,-4186 ,-5981 ,-8415 ,-10818 ,-12938 ,-15032 ,-17243 ,-19301 , -20866 ,-21929 ,-22705 ,-23288 ,-23577 ,-23524 ,-23302 ,-23173 ,-23271 ,-23585 ,-24088 ,-24821 ,-25831 ,-27079 ,-28436 , -29762 ,-30950 ,-31912 ,-32538 ,-32731 ,-32479 ,-31868 ,-31004 ,-29931 ,-28648 ,-27227 ,-25863 ,-24778 ,-24073 ,-23690 , -23515 ,-23488 ,-23611 ,-23877 ,-24238 ,-24616 ,-24924 ,-25072 ,-24987 ,-24660 ,-24158 ,-23569 ,-22955 ,-22356 ,-21824 , -21425 ,-21200 ,-21151 ,-21272 ,-21564 ,-22008 ,-22529 ,-23030 ,-23461 ,-23824 ,-24119 ,-24294 ,-24283 ,-24087 ,-23795 , -23531 ,-23370 ,-23305 ,-23289 ,-23297 ,-23359 ,-23531 ,-23810 ,-24102 ,-24274 ,-24261 ,-24105 ,-23877 ,-23591 ,-23219 , -22775 ,-22340 ,-21985 ,-21702 ,-21456 ,-21283 ,-21281 ,-21486 ,-21788 ,-22015 ,-22083 ,-22021 ,-21850 ,-21499 ,-20870 , -19956 ,-18862 ,-17691 ,-16494 ,-15311 ,-14238 ,-13373 ,-12726 ,-12224 ,-11825 ,-11573 ,-11497 ,-11484 ,-11299 ,-10766 , -9873 ,-8709 ,-7309 ,-5613 ,-3584 ,-1302 ,1059 ,3347 ,5481 ,7412 ,9095 ,10499 ,11636 ,12546 ,13262 , 13819 ,14304 ,14850 ,15548 ,16388 ,17279 ,18164 ,19054 ,19983 ,20913 ,21740 ,22375 ,22797 ,23018 ,23035 , 22849 ,22514 ,22133 ,21788 ,21485 ,21202 ,20954 ,20788 ,20716 ,20680 ,20617 ,20528 ,20465 ,20437 ,20387 , 20256 ,20074 ,19938 ,19920 ,19992 ,20088 ,20201 ,20405 ,20751 ,21169 ,21492 ,21599 ,21503 ,21292 ,21001 , 20570 ,19946 ,19194 ,18457 ,17846 ,17379 ,17055 ,16916 ,17033 ,17398 ,17906 ,18421 ,18865 ,19226 ,19503 , 19666 ,19675 ,19513 ,19217 ,18875 ,18606 ,18501 ,18596 ,18877 ,19343 ,20018 ,20913 ,21984 ,23148 ,24321 , 25431 ,26392 ,27120 ,27592 ,27858 ,27983 ,27970 ,27801 ,27516 ,27249 ,27146 ,27271 ,27590 ,28015 ,28453 , 28829 ,29099 ,29258 ,29291 ,29131 ,28687 ,27930 ,26943 ,25847 ,24711 ,23544 ,22368 ,21258 ,20285 ,19444 , 18673 ,17922 ,17176 ,16388 ,15465 ,14323 ,12983 ,11532 ,10026 ,8438 ,6760 ,5124 ,3760 ,2819 ,2234 , 1784 ,1297 ,778 ,329 ,-7 ,-323 ,-766 ,-1424 ,-2299 ,-3365 ,-4618 ,-6063 ,-7668 ,-9352 ,-11019 , -12601 ,-14072 ,-15426 ,-16639 ,-17661 ,-18439 ,-18994 ,-19436 ,-19916 ,-20504 ,-21143 ,-21731 ,-22252 ,-22806 ,-23498 , -24301 ,-25055 ,-25609 ,-25934 ,-26105 ,-26176 ,-26112 ,-25838 ,-25342 ,-24708 ,-24064 ,-23497 ,-23037 ,-22702 ,-22527 , -22555 ,-22782 ,-23143 ,-23550 ,-23944 ,-24318 ,-24696 ,-25089 ,-25483 ,-25849 ,-26155 ,-26374 ,-26508 ,-26612 ,-26790 , -27146 ,-27708 ,-28402 ,-29099 ,-29706 ,-30221 ,-30708 ,-31222 ,-31749 ,-32208 ,-32505 ,-32599 ,-32513 ,-32298 ,-31998 , -31632 ,-31230 ,-30832 ,-30460 ,-30096 ,-29701 ,-29283 ,-28910 ,-28640 ,-28442 ,-28211 ,-27861 ,-27408 ,-26930 ,-26481 , -26051 ,-25608 ,-25148 ,-24691 ,-24261 ,-23885 ,-23598 ,-23408 ,-23263 ,-23077 ,-22796 ,-22431 ,-22017 ,-21547 ,-20975 , -20277 ,-19474 ,-18595 ,-17648 ,-16644 ,-15618 ,-14602 ,-13583 ,-12532 ,-11486 ,-10551 ,-9774 ,-9040 ,-8143 ,-6988 , -5671 ,-4347 ,-3053 ,-1706 ,-247 ,1275 ,2777 ,4242 ,5695 ,7105 ,8370 ,9426 ,10321 ,11153 ,11957 , 12700 ,13374 ,14048 ,14798 ,15617 ,16421 ,17164 ,17888 ,18666 ,19479 ,20208 ,20716 ,20961 ,21001 ,20913 , 20735 ,20486 ,20207 ,19953 ,19743 ,19561 ,19407 ,19359 ,19514 ,19897 ,20411 ,20912 ,21316 ,21639 ,21947 , 22273 ,22586 ,22830 ,22993 ,23131 ,23318 ,23563 ,23812 ,24030 ,24279 ,24655 ,25159 ,25659 ,26010 ,26181 , 26228 ,26177 ,25987 ,25640 ,25202 ,24739 ,24223 ,23583 ,22848 ,22179 ,21725 ,21464 ,21251 ,20994 ,20751 , 20643 ,20706 ,20865 ,21020 ,21131 ,21224 ,21343 ,21514 ,21740 ,22016 ,22351 ,22765 ,23267 ,23839 ,24441 , 25039 ,25619 ,26171 ,26665 ,27060 ,27328 ,27477 ,27538 ,27549 ,27535 ,27494 ,27413 ,27285 ,27133 ,26976 , 26796 ,26539 ,26161 ,25664 ,25050 ,24274 ,23270 ,22040 ,20712 ,19442 ,18284 ,17157 ,15992 ,14843 ,13847 , 13055 ,12394 ,11794 ,11296 ,10949 ,10631 ,10106 ,9318 ,8497 ,7853 ,7208 ,6167 ,4750 ,3672 ,3739 , 4926 ,6245 ,6652 ,6000 ,4998 ,4313 ,3912 ,3279 ,2071 ,386 ,-1512 ,-3523 ,-5685 ,-7955 ,-10136 , -12033 ,-13585 ,-14841 ,-15855 ,-16643 ,-17226 ,-17661 ,-18036 ,-18433 ,-18896 ,-19454 ,-20136 ,-20992 ,-22054 ,-23292 , -24603 ,-25856 ,-26963 ,-27899 ,-28654 ,-29188 ,-29447 ,-29431 ,-29220 ,-28934 ,-28655 ,-28409 ,-28221 ,-28156 ,-28298 , -28680 ,-29256 ,-29931 ,-30618 ,-31258 ,-31806 ,-32219 ,-32470 ,-32550 ,-32462 ,-32213 ,-31810 ,-31269 ,-30620 ,-29917 , -29242 ,-28695 ,-28335 ,-28145 ,-28034 ,-27906 ,-27701 ,-27395 ,-26958 ,-26357 ,-25568 ,-24585 ,-23402 ,-22005 ,-20410 , -18693 ,-16977 ,-15358 ,-13876 ,-12539 ,-11388 ,-10507 ,-9960 ,-9710 ,-9613 ,-9495 ,-9260 ,-8933 ,-8587 ,-8220 , -7705 ,-6886 ,-5729 ,-4371 ,-3014 ,-1783 ,-693 ,258 ,1020 ,1525 ,1765 ,1806 ,1717 ,1525 ,1265 , 1024 ,926 ,1039 ,1339 ,1760 ,2266 ,2864 ,3556 ,4291 ,4963 ,5445 ,5646 ,5559 ,5278 ,4936 , 4607 ,4286 ,3948 ,3639 ,3472 ,3545 ,3868 ,4374 ,4979 ,5628 ,6284 ,6898 ,7399 ,7709 ,7783 , 7639 ,7342 ,6962 ,6534 ,6091 ,5695 ,5425 ,5317 ,5337 ,5446 ,5655 ,5989 ,6396 ,6739 ,6895 , 6854 ,6691 ,6452 ,6095 ,5570 ,4919 ,4277 ,3784 ,3494 ,3382 ,3401 ,3536 ,3788 ,4137 ,4513 , 4831 ,5040 ,5142 ,5161 ,5112 ,5001 ,4856 ,4724 ,4632 ,4577 ,4568 ,4658 ,4914 ,5334 ,5836 , 6313 ,6701 ,6978 ,7137 ,7187 ,7179 ,7177 ,7177 ,7099 ,6888 ,6613 ,6432 ,6447 ,6622 ,6872 , 7196 ,7693 ,8428 ,9330 ,10255 ,11133 ,12017 ,13000 ,14097 ,15239 ,16358 ,17437 ,18462 ,19394 ,20190 , 20878 ,21531 ,22181 ,22766 ,23214 ,23548 ,23889 ,24342 ,24915 ,25551 ,26220 ,26945 ,27748 ,28590 ,29386 , 30036 ,30463 ,30633 ,30560 ,30283 ,29812 ,29121 ,28213 ,27169 ,26101 ,25090 ,24194 ,23502 ,23084 ,22869 , 22678 ,22426 ,22206 ,22083 ,21862 ,21278 ,20387 ,19510 ,18656 ,17320 ,15182 ,12905 ,11621 ,11361 ,10425 , 6951 ,1173 ,-4384 ,-7246 ,-7286 ,-6448 ,-6470 ,-7373 ,-8151 ,-8342 ,-8448 ,-9051 ,-10074 ,-11050 ,-11786 , -12472 ,-13264 ,-14046 ,-14633 ,-15023 ,-15346 ,-15648 ,-15856 ,-15920 ,-15907 ,-15939 ,-16083 ,-16339 ,-16681 ,-17107 , -17626 ,-18252 ,-18971 ,-19735 ,-20459 ,-21063 ,-21511 ,-21818 ,-22021 ,-22156 ,-22246 ,-22297 ,-22314 ,-22338 ,-22466 , -22802 ,-23366 ,-24059 ,-24756 ,-25436 ,-26177 ,-27017 ,-27854 ,-28519 ,-28949 ,-29224 ,-29444 ,-29610 ,-29663 ,-29596 , -29487 ,-29411 ,-29384 ,-29399 ,-29486 ,-29672 ,-29917 ,-30120 ,-30222 ,-30243 ,-30206 ,-30051 ,-29686 ,-29104 ,-28421 , -27760 ,-27136 ,-26494 ,-25838 ,-25266 ,-24859 ,-24572 ,-24281 ,-23933 ,-23586 ,-23298 ,-23013 ,-22604 ,-22026 ,-21368 , -20736 ,-20124 ,-19447 ,-18678 ,-17925 ,-17322 ,-16899 ,-16596 ,-16362 ,-16215 ,-16165 ,-16151 ,-16075 ,-15903 ,-15674 , -15406 ,-15048 ,-14530 ,-13867 ,-13161 ,-12519 ,-11978 ,-11522 ,-11126 ,-10774 ,-10462 ,-10195 ,-9980 ,-9790 ,-9544 , -9143 ,-8539 ,-7752 ,-6830 ,-5826 ,-4814 ,-3880 ,-3060 ,-2294 ,-1510 ,-742 ,-137 ,195 ,303 ,347 , 453 ,657 ,962 ,1397 ,1985 ,2707 ,3526 ,4441 ,5473 ,6596 ,7715 ,8728 ,9577 ,10253 ,10779 , 11216 ,11646 ,12107 ,12559 ,12963 ,13373 ,13919 ,14664 ,15531 ,16391 ,17211 ,18045 ,18917 ,19753 ,20468 , 21053 ,21545 ,21939 ,22205 ,22383 ,22602 ,22970 ,23478 ,24043 ,24633 ,25298 ,26070 ,26893 ,27668 ,28343 , 28920 ,29389 ,29690 ,29780 ,29703 ,29560 ,29430 ,29317 ,29185 ,29035 ,28930 ,28959 ,29171 ,29538 ,29969 , 30367 ,30695 ,30978 ,31252 ,31513 ,31725 ,31879 ,32007 ,32141 ,32254 ,32290 ,32246 ,32208 ,32265 ,32403 , 32501 ,32450 ,32257 ,32007 ,31746 ,31423 ,30962 ,30366 ,29713 ,29061 ,28393 ,27666 ,26897 ,26177 ,25581 , 25088 ,24589 ,23989 ,23282 ,22530 ,21769 ,20945 ,19959 ,18763 ,17409 ,15995 ,14600 ,13261 ,12010 ,10857 , 9762 ,8678 ,7645 ,6789 ,6156 ,5595 ,4911 ,4126 ,3437 ,2855 ,2071 ,868 ,-419 ,-1198 ,-1510 , -2345 ,-4705 ,-8330 ,-11676 ,-13335 ,-13344 ,-12932 ,-13143 ,-13984 ,-14871 ,-15538 ,-16246 ,-17255 ,-18457 ,-19570 , -20527 ,-21464 ,-22444 ,-23316 ,-23898 ,-24164 ,-24236 ,-24219 ,-24134 ,-23968 ,-23745 ,-23526 ,-23345 ,-23179 ,-22999 , -22839 ,-22808 ,-22981 ,-23285 ,-23526 ,-23544 ,-23348 ,-23053 ,-22714 ,-22256 ,-21589 ,-20741 ,-19834 ,-18953 ,-18065 , -17124 ,-16186 ,-15402 ,-14869 ,-14535 ,-14242 ,-13891 ,-13520 ,-13234 ,-13061 ,-12886 ,-12538 ,-11940 ,-11162 ,-10334 , -9505 ,-8609 ,-7584 ,-6494 ,-5510 ,-4772 ,-4279 ,-3930 ,-3658 ,-3493 ,-3503 ,-3675 ,-3890 ,-4004 ,-3934 , -3677 ,-3264 ,-2722 ,-2078 ,-1371 ,-642 ,86 ,797 ,1458 ,2005 ,2373 ,2531 ,2501 ,2338 ,2098 , 1813 ,1497 ,1155 ,795 ,411 ,-12 ,-491 ,-1024 ,-1614 ,-2296 ,-3124 ,-4107 ,-5152 ,-6137 ,-7032 , -7932 ,-8935 ,-10001 ,-10970 ,-11742 ,-12397 ,-13103 ,-13931 ,-14792 ,-15551 ,-16183 ,-16762 ,-17358 ,-17956 ,-18466 , -18805 ,-18923 ,-18798 ,-18435 ,-17869 ,-17163 ,-16382 ,-15589 ,-14824 ,-14119 ,-13500 ,-13009 ,-12699 ,-12592 ,-12644 , -12753 ,-12830 ,-12836 ,-12753 ,-12517 ,-12039 ,-11277 ,-10297 ,-9214 ,-8089 ,-6905 ,-5642 ,-4364 ,-3211 ,-2287 , -1591 ,-1048 ,-597 ,-221 ,105 ,465 ,956 ,1594 ,2300 ,3009 ,3762 ,4668 ,5744 ,6862 ,7867 , 8739 ,9586 ,10476 ,11331 ,12042 ,12641 ,13300 ,14146 ,15126 ,16116 ,17106 ,18219 ,19526 ,20911 ,22178 , 23241 ,24168 ,25024 ,25751 ,26234 ,26455 ,26521 ,26556 ,26605 ,26660 ,26734 ,26870 ,27091 ,27373 ,27669 , 27937 ,28163 ,28371 ,28625 ,28967 ,29352 ,29666 ,29843 ,29957 ,30151 ,30479 ,30859 ,31191 ,31480 ,31799 , 32154 ,32444 ,32577 ,32573 ,32523 ,32458 ,32314 ,32035 ,31644 ,31210 ,30748 ,30218 ,29595 ,28915 ,28202 , 27410 ,26455 ,25305 ,24001 ,22584 ,21045 ,19381 ,17658 ,15950 ,14247 ,12477 ,10667 ,8992 ,7600 ,6415 , 5238 ,4034 ,2973 ,2130 ,1291 ,206 ,-1018 ,-2111 ,-3097 ,-4346 ,-6007 ,-7383 ,-8099 ,-8455 ,-9624 , -11810 ,-12696 ,-11159 ,-5862 , // sounds/wavetables/PPG_WA00.WAV 768 ,768 ,2304 ,2304 ,4096 ,4096 ,5376 ,5376 ,6912 ,6912 ,7936 ,7936 ,9216 ,9216 ,10752 , 10752 ,11776 ,11776 ,13312 ,13312 ,14848 ,14848 ,16128 ,16128 ,17407 ,17407 ,18687 ,18687 ,19711 ,19711 , 20991 ,20991 ,22015 ,22015 ,23039 ,23039 ,23551 ,23551 ,24319 ,24319 ,25087 ,25087 ,26111 ,26111 ,26623 , 26623 ,27391 ,27391 ,27647 ,27647 ,28415 ,28415 ,28671 ,28671 ,29183 ,29183 ,29439 ,29439 ,29695 ,29695 , 29951 ,29951 ,29951 ,29951 ,29951 ,29951 ,29951 ,29951 ,29695 ,29695 ,29439 ,29439 ,29183 ,29183 ,28671 , 28671 ,28415 ,28415 ,27647 ,27647 ,27391 ,27391 ,26623 ,26623 ,26111 ,26111 ,25087 ,25087 ,24319 ,24319 , 23551 ,23551 ,23039 ,23039 ,22015 ,22015 ,20991 ,20991 ,19711 ,19711 ,18687 ,18687 ,17407 ,17407 ,16128 , 16128 ,14848 ,14848 ,13312 ,13312 ,11776 ,11776 ,10752 ,10752 ,9216 ,9216 ,7936 ,7936 ,6912 ,6912 , 5376 ,5376 ,4096 ,4096 ,2304 ,2304 ,768 ,768 ,-1024 ,-1024 ,-2560 ,-2560 ,-4352 ,-4352 ,-5632 , -5632 ,-7168 ,-7168 ,-8192 ,-8192 ,-9472 ,-9472 ,-11008 ,-11008 ,-12032 ,-12032 ,-13568 ,-13568 ,-15104 ,-15104 , -16384 ,-16384 ,-17663 ,-17663 ,-18943 ,-18943 ,-19967 ,-19967 ,-21247 ,-21247 ,-22271 ,-22271 ,-23295 ,-23295 ,-23807 , -23807 ,-24575 ,-24575 ,-25343 ,-25343 ,-26367 ,-26367 ,-26879 ,-26879 ,-27647 ,-27647 ,-27903 ,-27903 ,-28671 ,-28671 , -28927 ,-28927 ,-29439 ,-29439 ,-29695 ,-29695 ,-29951 ,-29951 ,-30207 ,-30207 ,-30207 ,-30207 ,-30207 ,-30207 ,-30207 , -30207 ,-29951 ,-29951 ,-29695 ,-29695 ,-29439 ,-29439 ,-28927 ,-28927 ,-28671 ,-28671 ,-27903 ,-27903 ,-27647 ,-27647 , -26879 ,-26879 ,-26367 ,-26367 ,-25343 ,-25343 ,-24575 ,-24575 ,-23807 ,-23807 ,-23295 ,-23295 ,-22271 ,-22271 ,-21247 , -21247 ,-19967 ,-19967 ,-18943 ,-18943 ,-17663 ,-17663 ,-16384 ,-16384 ,-15104 ,-15104 ,-13568 ,-13568 ,-12032 ,-12032 , -11008 ,-11008 ,-9472 ,-9472 ,-8192 ,-8192 ,-7168 ,-7168 ,-5632 ,-5632 ,-4352 ,-4352 ,-2560 ,-2560 ,-1024 , -1024 ,512 ,512 ,2304 ,2304 ,4096 ,4096 ,5376 ,5376 ,6912 ,6912 ,8192 ,8192 ,9472 ,9472 , 11008 ,11008 ,12032 ,12032 ,13568 ,13568 ,15104 ,15104 ,16384 ,16384 ,17663 ,17663 ,18943 ,18943 ,19967 , 19967 ,21247 ,21247 ,22015 ,22015 ,23039 ,23039 ,23551 ,23551 ,24063 ,24063 ,24831 ,24831 ,25599 ,25599 , 25855 ,25855 ,26623 ,26623 ,26623 ,26623 ,27135 ,27135 ,27391 ,27391 ,27647 ,27647 ,27647 ,27647 ,27647 , 27647 ,27903 ,27903 ,27647 ,27647 ,27391 ,27391 ,27135 ,27135 ,26879 ,26879 ,26367 ,26367 ,26111 ,26111 , 25343 ,25343 ,25087 ,25087 ,24063 ,24063 ,23807 ,23807 ,23039 ,23039 ,22271 ,22271 ,21247 ,21247 ,20479 , 20479 ,19711 ,19711 ,19199 ,19199 ,18175 ,18175 ,17407 ,17407 ,16128 ,16128 ,15360 ,15360 ,14080 ,14080 , 13056 ,13056 ,12032 ,12032 ,10752 ,10752 ,9216 ,9216 ,8448 ,8448 ,7168 ,7168 ,6144 ,6144 ,5376 , 5376 ,4096 ,4096 ,3072 ,3072 ,1536 ,1536 ,512 ,512 ,-768 ,-768 ,-1792 ,-1792 ,-3328 ,-3328 , -4352 ,-4352 ,-5632 ,-5632 ,-6400 ,-6400 ,-7424 ,-7424 ,-8704 ,-8704 ,-9472 ,-9472 ,-11008 ,-11008 ,-12288 , -12288 ,-13312 ,-13312 ,-14336 ,-14336 ,-15616 ,-15616 ,-16384 ,-16384 ,-17663 ,-17663 ,-18431 ,-18431 ,-19455 ,-19455 , -19967 ,-19967 ,-20735 ,-20735 ,-21503 ,-21503 ,-22527 ,-22527 ,-23295 ,-23295 ,-24063 ,-24063 ,-24319 ,-24319 ,-25343 , -25343 ,-25599 ,-25599 ,-26367 ,-26367 ,-26623 ,-26623 ,-27135 ,-27135 ,-27391 ,-27391 ,-27647 ,-27647 ,-27903 ,-27903 , -28159 ,-28159 ,-27903 ,-27903 ,-27903 ,-27903 ,-27903 ,-27903 ,-27647 ,-27647 ,-27391 ,-27391 ,-26879 ,-26879 ,-26879 , -26879 ,-26111 ,-26111 ,-25855 ,-25855 ,-25087 ,-25087 ,-24319 ,-24319 ,-23807 ,-23807 ,-23295 ,-23295 ,-22271 ,-22271 , -21503 ,-21503 ,-20223 ,-20223 ,-19199 ,-19199 ,-17919 ,-17919 ,-16639 ,-16639 ,-15360 ,-15360 ,-13824 ,-13824 ,-12288 , -12288 ,-11264 ,-11264 ,-9728 ,-9728 ,-8448 ,-8448 ,-7168 ,-7168 ,-5632 ,-5632 ,-4352 ,-4352 ,-2560 ,-2560 , -768 ,-768 ,512 ,512 ,2304 ,2304 ,4352 ,4352 ,5632 ,5632 ,7168 ,7168 ,8448 ,8448 ,9728 , 9728 ,11520 ,11520 ,12544 ,12544 ,14080 ,14080 ,15616 ,15616 ,16895 ,16895 ,18175 ,18175 ,19199 ,19199 , 20223 ,20223 ,21503 ,21503 ,22271 ,22271 ,23039 ,23039 ,23551 ,23551 ,24063 ,24063 ,24575 ,24575 ,25087 , 25087 ,25343 ,25343 ,25855 ,25855 ,25855 ,25855 ,26111 ,26111 ,26111 ,26111 ,26111 ,26111 ,26111 ,26111 , 25855 ,25855 ,25855 ,25855 ,25343 ,25343 ,25087 ,25087 ,24575 ,24575 ,24063 ,24063 ,23551 ,23551 ,23039 , 23039 ,22271 ,22271 ,21759 ,21759 ,20735 ,20735 ,20223 ,20223 ,19455 ,19455 ,18687 ,18687 ,17663 ,17663 , 16895 ,16895 ,16128 ,16128 ,15616 ,15616 ,14592 ,14592 ,13824 ,13824 ,12800 ,12800 ,12032 ,12032 ,11008 , 11008 ,9984 ,9984 ,9216 ,9216 ,8192 ,8192 ,6912 ,6912 ,6400 ,6400 ,5376 ,5376 ,4608 ,4608 , 4096 ,4096 ,3072 ,3072 ,2304 ,2304 ,1024 ,1024 ,256 ,256 ,-512 ,-512 ,-1280 ,-1280 ,-2560 , -2560 ,-3328 ,-3328 ,-4352 ,-4352 ,-4864 ,-4864 ,-5632 ,-5632 ,-6656 ,-6656 ,-7168 ,-7168 ,-8448 ,-8448 , -9472 ,-9472 ,-10240 ,-10240 ,-11264 ,-11264 ,-12288 ,-12288 ,-13056 ,-13056 ,-14080 ,-14080 ,-14848 ,-14848 ,-15872 , -15872 ,-16384 ,-16384 ,-17151 ,-17151 ,-17919 ,-17919 ,-18943 ,-18943 ,-19711 ,-19711 ,-20479 ,-20479 ,-20991 ,-20991 , -22015 ,-22015 ,-22527 ,-22527 ,-23295 ,-23295 ,-23807 ,-23807 ,-24319 ,-24319 ,-24831 ,-24831 ,-25343 ,-25343 ,-25599 , -25599 ,-26111 ,-26111 ,-26111 ,-26111 ,-26367 ,-26367 ,-26367 ,-26367 ,-26367 ,-26367 ,-26367 ,-26367 ,-26111 ,-26111 , -26111 ,-26111 ,-25599 ,-25599 ,-25343 ,-25343 ,-24831 ,-24831 ,-24319 ,-24319 ,-23807 ,-23807 ,-23295 ,-23295 ,-22527 , -22527 ,-21759 ,-21759 ,-20479 ,-20479 ,-19455 ,-19455 ,-18431 ,-18431 ,-17151 ,-17151 ,-15872 ,-15872 ,-14336 ,-14336 , -12800 ,-12800 ,-11776 ,-11776 ,-9984 ,-9984 ,-8704 ,-8704 ,-7424 ,-7424 ,-5888 ,-5888 ,-4608 ,-4608 ,-2560 , -2560 ,-768 ,-768 ,512 ,512 ,2304 ,2304 ,4352 ,4352 ,5632 ,5632 ,7424 ,7424 ,8704 ,8704 , 9984 ,9984 ,11776 ,11776 ,13056 ,13056 ,14592 ,14592 ,15872 ,15872 ,17151 ,17151 ,18431 ,18431 ,19455 , 19455 ,20479 ,20479 ,21759 ,21759 ,22271 ,22271 ,23039 ,23039 ,23551 ,23551 ,23807 ,23807 ,24319 ,24319 , 24575 ,24575 ,24831 ,24831 ,25087 ,25087 ,25087 ,25087 ,25087 ,25087 ,24831 ,24831 ,24575 ,24575 ,24319 , 24319 ,24063 ,24063 ,23807 ,23807 ,23039 ,23039 ,22527 ,22527 ,22015 ,22015 ,21247 ,21247 ,20735 ,20735 , 19967 ,19967 ,18943 ,18943 ,18431 ,18431 ,17407 ,17407 ,16639 ,16639 ,15872 ,15872 ,15104 ,15104 ,14080 , 14080 ,13312 ,13312 ,12544 ,12544 ,11776 ,11776 ,11008 ,11008 ,10240 ,10240 ,9216 ,9216 ,8704 ,8704 , 7680 ,7680 ,6912 ,6912 ,6400 ,6400 ,5632 ,5632 ,4608 ,4608 ,4096 ,4096 ,3328 ,3328 ,2816 , 2816 ,2560 ,2560 ,2048 ,2048 ,1536 ,1536 ,512 ,512 ,0 ,0 ,-256 ,-256 ,-768 ,-768 , -1792 ,-1792 ,-2304 ,-2304 ,-2816 ,-2816 ,-3072 ,-3072 ,-3584 ,-3584 ,-4352 ,-4352 ,-4864 ,-4864 ,-5888 , -5888 ,-6656 ,-6656 ,-7168 ,-7168 ,-7936 ,-7936 ,-8960 ,-8960 ,-9472 ,-9472 ,-10496 ,-10496 ,-11264 ,-11264 , -12032 ,-12032 ,-12800 ,-12800 ,-13568 ,-13568 ,-14336 ,-14336 ,-15360 ,-15360 ,-16128 ,-16128 ,-16895 ,-16895 ,-17663 , -17663 ,-18687 ,-18687 ,-19199 ,-19199 ,-20223 ,-20223 ,-20991 ,-20991 ,-21503 ,-21503 ,-22271 ,-22271 ,-22783 ,-22783 , -23295 ,-23295 ,-24063 ,-24063 ,-24319 ,-24319 ,-24575 ,-24575 ,-24831 ,-24831 ,-25087 ,-25087 ,-25343 ,-25343 ,-25343 , -25343 ,-25343 ,-25343 ,-25087 ,-25087 ,-24831 ,-24831 ,-24575 ,-24575 ,-24063 ,-24063 ,-23807 ,-23807 ,-23295 ,-23295 , -22527 ,-22527 ,-22015 ,-22015 ,-20735 ,-20735 ,-19711 ,-19711 ,-18687 ,-18687 ,-17407 ,-17407 ,-16128 ,-16128 ,-14848 , -14848 ,-13312 ,-13312 ,-12032 ,-12032 ,-10240 ,-10240 ,-8960 ,-8960 ,-7680 ,-7680 ,-5888 ,-5888 ,-4608 ,-4608 , -2560 ,-2560 ,-768 ,-768 ,512 ,512 ,2560 ,2560 ,4608 ,4608 ,5888 ,5888 ,7680 ,7680 ,9216 , 9216 ,10496 ,10496 ,12288 ,12288 ,13568 ,13568 ,15104 ,15104 ,16384 ,16384 ,17663 ,17663 ,18943 ,18943 , 19967 ,19967 ,20991 ,20991 ,22015 ,22015 ,22527 ,22527 ,23295 ,23295 ,23551 ,23551 ,23807 ,23807 ,24063 , 24063 ,24319 ,24319 ,24319 ,24319 ,24575 ,24575 ,24319 ,24319 ,24063 ,24063 ,23551 ,23551 ,23295 ,23295 , 22783 ,22783 ,22271 ,22271 ,21759 ,21759 ,20991 ,20991 ,20223 ,20223 ,19455 ,19455 ,18687 ,18687 ,17919 , 17919 ,16895 ,16895 ,15872 ,15872 ,15104 ,15104 ,14080 ,14080 ,13056 ,13056 ,12288 ,12288 ,11520 ,11520 , 10496 ,10496 ,9728 ,9728 ,8960 ,8960 ,8192 ,8192 ,7424 ,7424 ,6656 ,6656 ,5888 ,5888 ,5376 , 5376 ,4608 ,4608 ,4096 ,4096 ,3584 ,3584 ,3072 ,3072 ,2304 ,2304 ,2048 ,2048 ,1536 ,1536 , 1280 ,1280 ,1280 ,1280 ,1024 ,1024 ,768 ,768 ,0 ,0 ,0 ,0 ,-256 ,-256 ,-256 , -256 ,-1024 ,-1024 ,-1280 ,-1280 ,-1536 ,-1536 ,-1536 ,-1536 ,-1792 ,-1792 ,-2304 ,-2304 ,-2560 ,-2560 , -3328 ,-3328 ,-3840 ,-3840 ,-4352 ,-4352 ,-4864 ,-4864 ,-5632 ,-5632 ,-6144 ,-6144 ,-6912 ,-6912 ,-7680 , -7680 ,-8448 ,-8448 ,-9216 ,-9216 ,-9984 ,-9984 ,-10752 ,-10752 ,-11776 ,-11776 ,-12544 ,-12544 ,-13312 ,-13312 , -14336 ,-14336 ,-15360 ,-15360 ,-16128 ,-16128 ,-17151 ,-17151 ,-18175 ,-18175 ,-18943 ,-18943 ,-19711 ,-19711 ,-20479 , -20479 ,-21247 ,-21247 ,-22015 ,-22015 ,-22527 ,-22527 ,-23039 ,-23039 ,-23551 ,-23551 ,-23807 ,-23807 ,-24319 ,-24319 , -24575 ,-24575 ,-24831 ,-24831 ,-24575 ,-24575 ,-24575 ,-24575 ,-24319 ,-24319 ,-24063 ,-24063 ,-23807 ,-23807 ,-23551 , -23551 ,-22783 ,-22783 ,-22271 ,-22271 ,-21247 ,-21247 ,-20223 ,-20223 ,-19199 ,-19199 ,-17919 ,-17919 ,-16639 ,-16639 , -15360 ,-15360 ,-13824 ,-13824 ,-12544 ,-12544 ,-10752 ,-10752 ,-9472 ,-9472 ,-7936 ,-7936 ,-6144 ,-6144 ,-4864 , -4864 ,-2816 ,-2816 ,-768 ,-768 ,512 ,512 ,2560 ,2560 ,4608 ,4608 ,5888 ,5888 ,7680 ,7680 , 9472 ,9472 ,10752 ,10752 ,12544 ,12544 ,14080 ,14080 ,15360 ,15360 ,16639 ,16639 ,17919 ,17919 ,19199 , 19199 ,20223 ,20223 ,21247 ,21247 ,22271 ,22271 ,22527 ,22527 ,23295 ,23295 ,23551 ,23551 ,23551 ,23551 , 23807 ,23807 ,23807 ,23807 ,23551 ,23551 ,23807 ,23807 ,23295 ,23295 ,23039 ,23039 ,22271 ,22271 ,21759 , 21759 ,20991 ,20991 ,20479 ,20479 ,19711 ,19711 ,18687 ,18687 ,17663 ,17663 ,16639 ,16639 ,15872 ,15872 , 14848 ,14848 ,13824 ,13824 ,12544 ,12544 ,11776 ,11776 ,10496 ,10496 ,9472 ,9472 ,8704 ,8704 ,7680 , 7680 ,6656 ,6656 ,5888 ,5888 ,5120 ,5120 ,4352 ,4352 ,3584 ,3584 ,3072 ,3072 ,2304 ,2304 , 2048 ,2048 ,1280 ,1280 ,1024 ,1024 ,768 ,768 ,512 ,512 ,0 ,0 ,-256 ,-256 ,-512 , -512 ,-512 ,-512 ,-256 ,-256 ,-256 ,-256 ,0 ,0 ,-512 ,-512 ,-256 ,-256 ,0 ,0 , 256 ,256 ,-256 ,-256 ,0 ,0 ,0 ,0 ,256 ,256 ,256 ,256 ,0 ,0 ,-256 , -256 ,-768 ,-768 ,-1024 ,-1024 ,-1280 ,-1280 ,-1536 ,-1536 ,-2304 ,-2304 ,-2560 ,-2560 ,-3328 ,-3328 , -3840 ,-3840 ,-4608 ,-4608 ,-5376 ,-5376 ,-6144 ,-6144 ,-6912 ,-6912 ,-7936 ,-7936 ,-8960 ,-8960 ,-9728 , -9728 ,-10752 ,-10752 ,-12032 ,-12032 ,-12800 ,-12800 ,-14080 ,-14080 ,-15104 ,-15104 ,-16128 ,-16128 ,-16895 ,-16895 , -17919 ,-17919 ,-18943 ,-18943 ,-19967 ,-19967 ,-20735 ,-20735 ,-21247 ,-21247 ,-22015 ,-22015 ,-22527 ,-22527 ,-23295 , -23295 ,-23551 ,-23551 ,-24063 ,-24063 ,-23807 ,-23807 ,-24063 ,-24063 ,-24063 ,-24063 ,-23807 ,-23807 ,-23807 ,-23807 , -23551 ,-23551 ,-22783 ,-22783 ,-22527 ,-22527 ,-21503 ,-21503 ,-20479 ,-20479 ,-19455 ,-19455 ,-18175 ,-18175 ,-16895 , -16895 ,-15616 ,-15616 ,-14336 ,-14336 ,-12800 ,-12800 ,-11008 ,-11008 ,-9728 ,-9728 ,-7936 ,-7936 ,-6144 ,-6144 , -4864 ,-4864 ,-2816 ,-2816 ,-768 ,-768 ,512 ,512 ,2560 ,2560 ,4864 ,4864 ,6144 ,6144 ,7936 , 7936 ,9728 ,9728 ,11264 ,11264 ,13056 ,13056 ,14592 ,14592 ,15872 ,15872 ,17151 ,17151 ,18431 ,18431 , 19711 ,19711 ,20479 ,20479 ,21503 ,21503 ,22527 ,22527 ,22783 ,22783 ,23295 ,23295 ,23551 ,23551 ,23551 , 23551 ,23551 ,23551 ,23551 ,23551 ,23039 ,23039 ,23039 ,23039 ,22527 ,22527 ,22015 ,22015 ,20991 ,20991 , 20479 ,20479 ,19455 ,19455 ,18687 ,18687 ,17663 ,17663 ,16384 ,16384 ,15360 ,15360 ,14080 ,14080 ,13056 , 13056 ,12032 ,12032 ,10752 ,10752 ,9472 ,9472 ,8448 ,8448 ,7168 ,7168 ,5888 ,5888 ,5120 ,5120 , 4096 ,4096 ,3072 ,3072 ,2304 ,2304 ,1536 ,1536 ,768 ,768 ,0 ,0 ,-512 ,-512 ,-1024 , -1024 ,-1280 ,-1280 ,-1792 ,-1792 ,-1792 ,-1792 ,-2048 ,-2048 ,-2048 ,-2048 ,-2304 ,-2304 ,-2304 ,-2304 , -2304 ,-2304 ,-2048 ,-2048 ,-1536 ,-1536 ,-1280 ,-1280 ,-768 ,-768 ,-1024 ,-1024 ,-512 ,-512 ,256 , 256 ,768 ,768 ,512 ,512 ,1024 ,1024 ,1280 ,1280 ,1792 ,1792 ,2048 ,2048 ,2048 ,2048 , 2048 ,2048 ,1792 ,1792 ,1792 ,1792 ,1536 ,1536 ,1536 ,1536 ,1024 ,1024 ,768 ,768 ,256 , 256 ,-256 ,-256 ,-1024 ,-1024 ,-1792 ,-1792 ,-2560 ,-2560 ,-3328 ,-3328 ,-4352 ,-4352 ,-5376 ,-5376 , -6144 ,-6144 ,-7424 ,-7424 ,-8704 ,-8704 ,-9728 ,-9728 ,-11008 ,-11008 ,-12288 ,-12288 ,-13312 ,-13312 ,-14336 , -14336 ,-15616 ,-15616 ,-16639 ,-16639 ,-17919 ,-17919 ,-18943 ,-18943 ,-19711 ,-19711 ,-20735 ,-20735 ,-21247 ,-21247 , -22271 ,-22271 ,-22783 ,-22783 ,-23295 ,-23295 ,-23295 ,-23295 ,-23807 ,-23807 ,-23807 ,-23807 ,-23807 ,-23807 ,-23807 , -23807 ,-23551 ,-23551 ,-23039 ,-23039 ,-22783 ,-22783 ,-21759 ,-21759 ,-20735 ,-20735 ,-19967 ,-19967 ,-18687 ,-18687 , -17407 ,-17407 ,-16128 ,-16128 ,-14848 ,-14848 ,-13312 ,-13312 ,-11520 ,-11520 ,-9984 ,-9984 ,-8192 ,-8192 ,-6400 , -6400 ,-5120 ,-5120 ,-2816 ,-2816 ,-768 ,-768 ,512 ,512 ,2560 ,2560 ,4864 ,4864 ,6400 ,6400 , 8192 ,8192 ,9984 ,9984 ,11520 ,11520 ,13312 ,13312 ,15104 ,15104 ,16384 ,16384 ,17663 ,17663 ,18943 , 18943 ,19967 ,19967 ,20735 ,20735 ,21759 ,21759 ,22783 ,22783 ,23039 ,23039 ,23295 ,23295 ,23551 ,23551 , 23551 ,23551 ,23295 ,23295 ,23039 ,23039 ,22527 ,22527 ,22271 ,22271 ,21759 ,21759 ,20991 ,20991 ,19711 , 19711 ,18943 ,18943 ,17663 ,17663 ,16895 ,16895 ,15616 ,15616 ,14080 ,14080 ,13056 ,13056 ,11520 ,11520 , 10240 ,10240 ,9216 ,9216 ,7680 ,7680 ,6144 ,6144 ,5120 ,5120 ,3840 ,3840 ,2304 ,2304 ,1536 , 1536 ,512 ,512 ,-512 ,-512 ,-1280 ,-1280 ,-2048 ,-2048 ,-2816 ,-2816 ,-3584 ,-3584 ,-4096 ,-4096 , -4352 ,-4352 ,-4608 ,-4608 ,-4864 ,-4864 ,-4864 ,-4864 ,-4864 ,-4864 ,-4608 ,-4608 ,-4608 ,-4608 ,-4608 , -4608 ,-4096 ,-4096 ,-3584 ,-3584 ,-3072 ,-3072 ,-2304 ,-2304 ,-1536 ,-1536 ,-1536 ,-1536 ,-768 ,-768 , 512 ,512 ,1280 ,1280 ,1280 ,1280 ,2048 ,2048 ,2816 ,2816 ,3328 ,3328 ,3840 ,3840 ,4352 , 4352 ,4352 ,4352 ,4352 ,4352 ,4608 ,4608 ,4608 ,4608 ,4608 ,4608 ,4352 ,4352 ,4096 ,4096 , 3840 ,3840 ,3328 ,3328 ,2560 ,2560 ,1792 ,1792 ,1024 ,1024 ,256 ,256 ,-768 ,-768 ,-1792 , -1792 ,-2560 ,-2560 ,-4096 ,-4096 ,-5376 ,-5376 ,-6400 ,-6400 ,-7936 ,-7936 ,-9472 ,-9472 ,-10496 ,-10496 , -11776 ,-11776 ,-13312 ,-13312 ,-14336 ,-14336 ,-15872 ,-15872 ,-17151 ,-17151 ,-17919 ,-17919 ,-19199 ,-19199 ,-19967 , -19967 ,-21247 ,-21247 ,-22015 ,-22015 ,-22527 ,-22527 ,-22783 ,-22783 ,-23295 ,-23295 ,-23551 ,-23551 ,-23807 ,-23807 , -23807 ,-23807 ,-23551 ,-23551 ,-23295 ,-23295 ,-23039 ,-23039 ,-22015 ,-22015 ,-20991 ,-20991 ,-20223 ,-20223 ,-19199 , -19199 ,-17919 ,-17919 ,-16639 ,-16639 ,-15360 ,-15360 ,-13568 ,-13568 ,-11776 ,-11776 ,-10240 ,-10240 ,-8448 ,-8448 , -6656 ,-6656 ,-5120 ,-5120 ,-2816 ,-2816 ,-768 ,-768 ,512 ,512 ,2816 ,2816 ,5120 ,5120 ,6656 , 6656 ,8448 ,8448 ,10496 ,10496 ,12032 ,12032 ,13824 ,13824 ,15616 ,15616 ,16895 ,16895 ,18175 ,18175 , 19455 ,19455 ,20479 ,20479 ,21247 ,21247 ,22271 ,22271 ,23039 ,23039 ,23295 ,23295 ,23551 ,23551 ,23551 , 23551 ,23551 ,23551 ,23039 ,23039 ,22783 ,22783 ,22015 ,22015 ,21759 ,21759 ,20991 ,20991 ,19967 ,19967 , 18687 ,18687 ,17663 ,17663 ,16128 ,16128 ,15104 ,15104 ,13824 ,13824 ,12032 ,12032 ,10752 ,10752 ,8960 , 8960 ,7680 ,7680 ,6400 ,6400 ,4864 ,4864 ,3072 ,3072 ,2048 ,2048 ,512 ,512 ,-1024 ,-1024 , -1792 ,-1792 ,-3072 ,-3072 ,-4096 ,-4096 ,-4864 ,-4864 ,-5632 ,-5632 ,-6400 ,-6400 ,-7168 ,-7168 ,-7424 , -7424 ,-7680 ,-7680 ,-7936 ,-7936 ,-7936 ,-7936 ,-7680 ,-7680 ,-7680 ,-7680 ,-7168 ,-7168 ,-6912 ,-6912 , -6656 ,-6656 ,-5888 ,-5888 ,-5120 ,-5120 ,-4352 ,-4352 ,-3328 ,-3328 ,-2304 ,-2304 ,-2048 ,-2048 ,-768 , -768 ,512 ,512 ,1792 ,1792 ,2048 ,2048 ,3072 ,3072 ,4096 ,4096 ,4864 ,4864 ,5632 ,5632 , 6400 ,6400 ,6656 ,6656 ,6912 ,6912 ,7424 ,7424 ,7424 ,7424 ,7680 ,7680 ,7680 ,7680 ,7424 , 7424 ,7168 ,7168 ,6912 ,6912 ,6144 ,6144 ,5376 ,5376 ,4608 ,4608 ,3840 ,3840 ,2816 ,2816 , 1536 ,1536 ,768 ,768 ,-768 ,-768 ,-2304 ,-2304 ,-3328 ,-3328 ,-5120 ,-5120 ,-6656 ,-6656 ,-7936 , -7936 ,-9216 ,-9216 ,-11008 ,-11008 ,-12288 ,-12288 ,-14080 ,-14080 ,-15360 ,-15360 ,-16384 ,-16384 ,-17919 ,-17919 , -18943 ,-18943 ,-20223 ,-20223 ,-21247 ,-21247 ,-22015 ,-22015 ,-22271 ,-22271 ,-23039 ,-23039 ,-23295 ,-23295 ,-23807 , -23807 ,-23807 ,-23807 ,-23807 ,-23807 ,-23551 ,-23551 ,-23295 ,-23295 ,-22527 ,-22527 ,-21503 ,-21503 ,-20735 ,-20735 , -19711 ,-19711 ,-18431 ,-18431 ,-17151 ,-17151 ,-15872 ,-15872 ,-14080 ,-14080 ,-12288 ,-12288 ,-10752 ,-10752 ,-8704 , -8704 ,-6912 ,-6912 ,-5376 ,-5376 ,-3072 ,-3072 ,-768 ,-768 ,512 ,512 ,2816 ,2816 ,5120 ,5120 , 6912 ,6912 ,8704 ,8704 ,10752 ,10752 ,12288 ,12288 ,14336 ,14336 ,15872 ,15872 ,17151 ,17151 ,18431 , 18431 ,19711 ,19711 ,20735 ,20735 ,21247 ,21247 ,22271 ,22271 ,22783 ,22783 ,22783 ,22783 ,23039 ,23039 , 22783 ,22783 ,22527 ,22527 ,21759 ,21759 ,21503 ,21503 ,20479 ,20479 ,20223 ,20223 ,19199 ,19199 ,18175 , 18175 ,16895 ,16895 ,15616 ,15616 ,14336 ,14336 ,13312 ,13312 ,12032 ,12032 ,10496 ,10496 ,9216 ,9216 , 7680 ,7680 ,6656 ,6656 ,5632 ,5632 ,4352 ,4352 ,3072 ,3072 ,2304 ,2304 ,1024 ,1024 ,0 , 0 ,-512 ,-512 ,-1280 ,-1280 ,-2048 ,-2048 ,-2560 ,-2560 ,-3072 ,-3072 ,-3328 ,-3328 ,-3840 ,-3840 , -4096 ,-4096 ,-4096 ,-4096 ,-4352 ,-4352 ,-4352 ,-4352 ,-4096 ,-4096 ,-4096 ,-4096 ,-3840 ,-3840 ,-3584 , -3584 ,-3584 ,-3584 ,-3072 ,-3072 ,-2816 ,-2816 ,-2304 ,-2304 ,-1792 ,-1792 ,-1024 ,-1024 ,-1280 ,-1280 , -512 ,-512 ,256 ,256 ,1024 ,1024 ,768 ,768 ,1536 ,1536 ,2048 ,2048 ,2560 ,2560 ,2816 , 2816 ,3328 ,3328 ,3328 ,3328 ,3584 ,3584 ,3840 ,3840 ,3840 ,3840 ,4096 ,4096 ,4096 ,4096 , 3840 ,3840 ,3840 ,3840 ,3584 ,3584 ,3072 ,3072 ,2816 ,2816 ,2304 ,2304 ,1792 ,1792 ,1024 , 1024 ,256 ,256 ,-256 ,-256 ,-1280 ,-1280 ,-2560 ,-2560 ,-3328 ,-3328 ,-4608 ,-4608 ,-5888 ,-5888 , -6912 ,-6912 ,-7936 ,-7936 ,-9472 ,-9472 ,-10752 ,-10752 ,-12288 ,-12288 ,-13568 ,-13568 ,-14592 ,-14592 ,-15872 , -15872 ,-17151 ,-17151 ,-18431 ,-18431 ,-19455 ,-19455 ,-20479 ,-20479 ,-20735 ,-20735 ,-21759 ,-21759 ,-22015 ,-22015 , -22783 ,-22783 ,-23039 ,-23039 ,-23295 ,-23295 ,-23039 ,-23039 ,-23039 ,-23039 ,-22527 ,-22527 ,-21503 ,-21503 ,-20991 , -20991 ,-19967 ,-19967 ,-18687 ,-18687 ,-17407 ,-17407 ,-16128 ,-16128 ,-14592 ,-14592 ,-12544 ,-12544 ,-11008 ,-11008 , -8960 ,-8960 ,-7168 ,-7168 ,-5376 ,-5376 ,-3072 ,-3072 ,-768 ,-768 ,512 ,512 ,2816 ,2816 ,5376 , 5376 ,7168 ,7168 ,9216 ,9216 ,11264 ,11264 ,12800 ,12800 ,14848 ,14848 ,16384 ,16384 ,17663 ,17663 , 18943 ,18943 ,20223 ,20223 ,20991 ,20991 ,21503 ,21503 ,22271 ,22271 ,22527 ,22527 ,22527 ,22527 ,22527 , 22527 ,22015 ,22015 ,21759 ,21759 ,20735 ,20735 ,20223 ,20223 ,19199 ,19199 ,18687 ,18687 ,17663 ,17663 , 16384 ,16384 ,15104 ,15104 ,13824 ,13824 ,12544 ,12544 ,11520 ,11520 ,10496 ,10496 ,8960 ,8960 ,7936 , 7936 ,6656 ,6656 ,5888 ,5888 ,5120 ,5120 ,4096 ,4096 ,3072 ,3072 ,2560 ,2560 ,1792 ,1792 , 1280 ,1280 ,1024 ,1024 ,512 ,512 ,0 ,0 ,0 ,0 ,-256 ,-256 ,-256 ,-256 ,-512 , -512 ,-512 ,-512 ,-512 ,-512 ,-512 ,-512 ,-512 ,-512 ,-256 ,-256 ,-256 ,-256 ,-256 ,-256 , -256 ,-256 ,-512 ,-512 ,-256 ,-256 ,-256 ,-256 ,-256 ,-256 ,0 ,0 ,256 ,256 ,-512 , -512 ,0 ,0 ,-256 ,-256 ,256 ,256 ,-512 ,-512 ,-256 ,-256 ,0 ,0 ,0 ,0 , 0 ,0 ,256 ,256 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,256 ,256 ,256 , 256 ,256 ,256 ,256 ,256 ,256 ,256 ,0 ,0 ,0 ,0 ,-256 ,-256 ,-256 ,-256 , -768 ,-768 ,-1280 ,-1280 ,-1536 ,-1536 ,-2048 ,-2048 ,-2816 ,-2816 ,-3328 ,-3328 ,-4352 ,-4352 ,-5376 , -5376 ,-6144 ,-6144 ,-6912 ,-6912 ,-8192 ,-8192 ,-9216 ,-9216 ,-10752 ,-10752 ,-11776 ,-11776 ,-12800 ,-12800 , -14080 ,-14080 ,-15360 ,-15360 ,-16639 ,-16639 ,-17919 ,-17919 ,-18943 ,-18943 ,-19455 ,-19455 ,-20479 ,-20479 ,-20991 , -20991 ,-22015 ,-22015 ,-22271 ,-22271 ,-22783 ,-22783 ,-22783 ,-22783 ,-22783 ,-22783 ,-22527 ,-22527 ,-21759 ,-21759 , -21247 ,-21247 ,-20479 ,-20479 ,-19199 ,-19199 ,-17919 ,-17919 ,-16639 ,-16639 ,-15104 ,-15104 ,-13056 ,-13056 ,-11520 , -11520 ,-9472 ,-9472 ,-7424 ,-7424 ,-5632 ,-5632 ,-3072 ,-3072 ,-768 ,-768 ,512 ,512 ,2816 ,2816 , 5632 ,5632 ,7424 ,7424 ,9472 ,9472 ,11520 ,11520 ,13312 ,13312 ,15360 ,15360 ,16895 ,16895 ,18175 , 18175 ,19455 ,19455 ,20479 ,20479 ,21247 ,21247 ,21503 ,21503 ,22271 ,22271 ,22271 ,22271 ,22271 ,22271 , 22015 ,22015 ,21247 ,21247 ,20735 ,20735 ,19711 ,19711 ,18943 ,18943 ,17663 ,17663 ,17151 ,17151 ,15872 , 15872 ,14592 ,14592 ,13312 ,13312 ,12032 ,12032 ,10752 ,10752 ,9728 ,9728 ,8704 ,8704 ,7424 ,7424 , 6656 ,6656 ,5632 ,5632 ,4864 ,4864 ,4352 ,4352 ,3840 ,3840 ,3072 ,3072 ,2816 ,2816 ,2560 , 2560 ,2304 ,2304 ,2304 ,2304 ,2304 ,2304 ,2048 ,2048 ,2560 ,2560 ,2560 ,2560 ,2816 ,2816 , 2816 ,2816 ,3072 ,3072 ,3072 ,3072 ,3072 ,3072 ,3328 ,3328 ,3328 ,3328 ,3328 ,3328 ,3328 , 3328 ,3072 ,3072 ,2560 ,2560 ,2560 ,2560 ,2304 ,2304 ,1792 ,1792 ,1536 ,1536 ,1536 ,1536 , 256 ,256 ,256 ,256 ,-512 ,-512 ,-512 ,-512 ,-1792 ,-1792 ,-1792 ,-1792 ,-2048 ,-2048 ,-2560 , -2560 ,-2816 ,-2816 ,-2816 ,-2816 ,-3328 ,-3328 ,-3584 ,-3584 ,-3584 ,-3584 ,-3584 ,-3584 ,-3584 ,-3584 , -3328 ,-3328 ,-3328 ,-3328 ,-3328 ,-3328 ,-3072 ,-3072 ,-3072 ,-3072 ,-2816 ,-2816 ,-2816 ,-2816 ,-2304 , -2304 ,-2560 ,-2560 ,-2560 ,-2560 ,-2560 ,-2560 ,-2816 ,-2816 ,-3072 ,-3072 ,-3328 ,-3328 ,-4096 ,-4096 , -4608 ,-4608 ,-5120 ,-5120 ,-5888 ,-5888 ,-6912 ,-6912 ,-7680 ,-7680 ,-8960 ,-8960 ,-9984 ,-9984 ,-11008 , -11008 ,-12288 ,-12288 ,-13568 ,-13568 ,-14848 ,-14848 ,-16128 ,-16128 ,-17407 ,-17407 ,-17919 ,-17919 ,-19199 ,-19199 , -19967 ,-19967 ,-20991 ,-20991 ,-21503 ,-21503 ,-22271 ,-22271 ,-22527 ,-22527 ,-22527 ,-22527 ,-22527 ,-22527 ,-21759 , -21759 ,-21503 ,-21503 ,-20735 ,-20735 ,-19711 ,-19711 ,-18431 ,-18431 ,-17151 ,-17151 ,-15616 ,-15616 ,-13568 ,-13568 , -11776 ,-11776 ,-9728 ,-9728 ,-7680 ,-7680 ,-5888 ,-5888 ,-3072 ,-3072 ,-768 ,-768 ,512 ,512 ,3072 , 3072 ,5888 ,5888 ,7680 ,7680 ,9984 ,9984 ,12032 ,12032 ,13824 ,13824 ,15872 ,15872 ,17407 ,17407 , 18687 ,18687 ,19967 ,19967 ,20991 ,20991 ,21503 ,21503 ,21759 ,21759 ,22271 ,22271 ,22271 ,22271 ,22015 , 22015 ,21503 ,21503 ,20735 ,20735 ,19967 ,19967 ,18687 ,18687 ,17663 ,17663 ,16384 ,16384 ,15616 ,15616 , 14336 ,14336 ,13056 ,13056 ,11520 ,11520 ,10240 ,10240 ,9216 ,9216 ,8192 ,8192 ,7168 ,7168 ,6144 , 6144 ,5376 ,5376 ,4608 ,4608 ,4096 ,4096 ,3840 ,3840 ,3584 ,3584 ,3072 ,3072 ,3328 ,3328 , 3328 ,3328 ,3584 ,3584 ,3840 ,3840 ,4096 ,4096 ,4352 ,4352 ,5120 ,5120 ,5376 ,5376 ,5888 , 5888 ,6144 ,6144 ,6656 ,6656 ,6912 ,6912 ,6912 ,6912 ,7168 ,7168 ,7168 ,7168 ,7168 ,7168 , 6912 ,6912 ,6400 ,6400 ,5888 ,5888 ,5376 ,5376 ,4864 ,4864 ,4096 ,4096 ,3328 ,3328 ,2816 , 2816 ,1280 ,1280 ,768 ,768 ,-1024 ,-1024 ,-1536 ,-1536 ,-3072 ,-3072 ,-3584 ,-3584 ,-4352 ,-4352 , -5120 ,-5120 ,-5632 ,-5632 ,-6144 ,-6144 ,-6656 ,-6656 ,-7168 ,-7168 ,-7424 ,-7424 ,-7424 ,-7424 ,-7424 , -7424 ,-7168 ,-7168 ,-7168 ,-7168 ,-6912 ,-6912 ,-6400 ,-6400 ,-6144 ,-6144 ,-5632 ,-5632 ,-5376 ,-5376 , -4608 ,-4608 ,-4352 ,-4352 ,-4096 ,-4096 ,-3840 ,-3840 ,-3584 ,-3584 ,-3584 ,-3584 ,-3328 ,-3328 ,-3840 , -3840 ,-4096 ,-4096 ,-4352 ,-4352 ,-4864 ,-4864 ,-5632 ,-5632 ,-6400 ,-6400 ,-7424 ,-7424 ,-8448 ,-8448 , -9472 ,-9472 ,-10496 ,-10496 ,-11776 ,-11776 ,-13312 ,-13312 ,-14592 ,-14592 ,-15872 ,-15872 ,-16639 ,-16639 ,-17919 , -17919 ,-18943 ,-18943 ,-20223 ,-20223 ,-20991 ,-20991 ,-21759 ,-21759 ,-22271 ,-22271 ,-22527 ,-22527 ,-22527 ,-22527 , -22015 ,-22015 ,-21759 ,-21759 ,-21247 ,-21247 ,-20223 ,-20223 ,-18943 ,-18943 ,-17663 ,-17663 ,-16128 ,-16128 ,-14080 , -14080 ,-12288 ,-12288 ,-10240 ,-10240 ,-7936 ,-7936 ,-6144 ,-6144 ,-3328 ,-3328 ,-768 ,-768 ,512 ,512 , 3072 ,3072 ,5888 ,5888 ,7936 ,7936 ,10240 ,10240 ,12288 ,12288 ,14336 ,14336 ,16384 ,16384 ,17663 , 17663 ,19199 ,19199 ,20479 ,20479 ,21247 ,21247 ,21759 ,21759 ,21759 ,21759 ,22271 ,22271 ,22015 ,22015 , 21503 ,21503 ,20991 ,20991 ,19967 ,19967 ,18943 ,18943 ,17663 ,17663 ,16384 ,16384 ,14848 ,14848 ,14080 , 14080 ,12544 ,12544 ,11264 ,11264 ,9728 ,9728 ,8448 ,8448 ,7424 ,7424 ,6400 ,6400 ,5376 ,5376 , 4608 ,4608 ,3840 ,3840 ,3328 ,3328 ,3072 ,3072 ,3072 ,3072 ,3072 ,3072 ,3072 ,3072 ,3584 , 3584 ,3840 ,3840 ,4608 ,4608 ,5120 ,5120 ,5888 ,5888 ,6400 ,6400 ,7424 ,7424 ,8192 ,8192 , 8960 ,8960 ,9472 ,9472 ,9984 ,9984 ,10496 ,10496 ,10496 ,10496 ,10752 ,10752 ,10752 ,10752 ,10752 , 10752 ,10240 ,10240 ,9728 ,9728 ,8960 ,8960 ,8192 ,8192 ,7168 ,7168 ,6144 ,6144 ,4864 ,4864 , 4096 ,4096 ,2048 ,2048 ,1024 ,1024 ,-1280 ,-1280 ,-2304 ,-2304 ,-4352 ,-4352 ,-5120 ,-5120 ,-6400 , -6400 ,-7424 ,-7424 ,-8448 ,-8448 ,-9216 ,-9216 ,-9984 ,-9984 ,-10496 ,-10496 ,-11008 ,-11008 ,-11008 ,-11008 , -11008 ,-11008 ,-10752 ,-10752 ,-10752 ,-10752 ,-10240 ,-10240 ,-9728 ,-9728 ,-9216 ,-9216 ,-8448 ,-8448 ,-7680 , -7680 ,-6656 ,-6656 ,-6144 ,-6144 ,-5376 ,-5376 ,-4864 ,-4864 ,-4096 ,-4096 ,-3840 ,-3840 ,-3328 ,-3328 , -3328 ,-3328 ,-3328 ,-3328 ,-3328 ,-3328 ,-3584 ,-3584 ,-4096 ,-4096 ,-4864 ,-4864 ,-5632 ,-5632 ,-6656 , -6656 ,-7680 ,-7680 ,-8704 ,-8704 ,-9984 ,-9984 ,-11520 ,-11520 ,-12800 ,-12800 ,-14336 ,-14336 ,-15104 ,-15104 , -16639 ,-16639 ,-17919 ,-17919 ,-19199 ,-19199 ,-20223 ,-20223 ,-21247 ,-21247 ,-21759 ,-21759 ,-22271 ,-22271 ,-22527 , -22527 ,-22015 ,-22015 ,-22015 ,-22015 ,-21503 ,-21503 ,-20735 ,-20735 ,-19455 ,-19455 ,-17919 ,-17919 ,-16639 ,-16639 , -14592 ,-14592 ,-12544 ,-12544 ,-10496 ,-10496 ,-8192 ,-8192 ,-6144 ,-6144 ,-3328 ,-3328 ,-768 ,-768 ,512 , 512 ,3328 ,3328 ,6144 ,6144 ,8192 ,8192 ,10752 ,10752 ,12800 ,12800 ,14848 ,14848 ,16895 ,16895 , 18175 ,18175 ,19711 ,19711 ,20991 ,20991 ,21759 ,21759 ,22015 ,22015 ,22015 ,22015 ,22271 ,22271 ,21759 , 21759 ,21247 ,21247 ,20479 ,20479 ,19199 ,19199 ,18175 ,18175 ,16639 ,16639 ,15104 ,15104 ,13568 ,13568 , 12544 ,12544 ,11008 ,11008 ,9472 ,9472 ,7936 ,7936 ,6656 ,6656 ,5632 ,5632 ,4608 ,4608 ,3840 , 3840 ,3072 ,3072 ,2560 ,2560 ,2304 ,2304 ,2304 ,2304 ,2560 ,2560 ,2816 ,2816 ,3072 ,3072 , 4096 ,4096 ,4608 ,4608 ,5888 ,5888 ,6656 ,6656 ,7680 ,7680 ,8704 ,8704 ,9984 ,9984 ,11008 , 11008 ,12032 ,12032 ,12800 ,12800 ,13568 ,13568 ,14080 ,14080 ,14336 ,14336 ,14592 ,14592 ,14592 ,14592 , 14592 ,14592 ,13824 ,13824 ,13056 ,13056 ,12288 ,12288 ,11008 ,11008 ,9728 ,9728 ,8448 ,8448 ,6656 , 6656 ,5376 ,5376 ,3072 ,3072 ,1536 ,1536 ,-1792 ,-1792 ,-3328 ,-3328 ,-5632 ,-5632 ,-6912 ,-6912 , -8704 ,-8704 ,-9984 ,-9984 ,-11264 ,-11264 ,-12544 ,-12544 ,-13312 ,-13312 ,-14080 ,-14080 ,-14848 ,-14848 ,-14848 , -14848 ,-14848 ,-14848 ,-14592 ,-14592 ,-14336 ,-14336 ,-13824 ,-13824 ,-13056 ,-13056 ,-12288 ,-12288 ,-11264 ,-11264 , -10240 ,-10240 ,-8960 ,-8960 ,-7936 ,-7936 ,-6912 ,-6912 ,-6144 ,-6144 ,-4864 ,-4864 ,-4352 ,-4352 ,-3328 , -3328 ,-3072 ,-3072 ,-2816 ,-2816 ,-2560 ,-2560 ,-2560 ,-2560 ,-2816 ,-2816 ,-3328 ,-3328 ,-4096 ,-4096 , -4864 ,-4864 ,-5888 ,-5888 ,-6912 ,-6912 ,-8192 ,-8192 ,-9728 ,-9728 ,-11264 ,-11264 ,-12800 ,-12800 ,-13824 , -13824 ,-15360 ,-15360 ,-16895 ,-16895 ,-18431 ,-18431 ,-19455 ,-19455 ,-20735 ,-20735 ,-21503 ,-21503 ,-22015 ,-22015 , -22527 ,-22527 ,-22271 ,-22271 ,-22271 ,-22271 ,-22015 ,-22015 ,-21247 ,-21247 ,-19967 ,-19967 ,-18431 ,-18431 ,-17151 , -17151 ,-15104 ,-15104 ,-13056 ,-13056 ,-11008 ,-11008 ,-8448 ,-8448 ,-6400 ,-6400 ,-3584 ,-3584 ,-768 ,-768 , 512 ,512 ,3328 ,3328 ,6400 ,6400 ,8448 ,8448 ,11008 ,11008 ,13312 ,13312 ,15360 ,15360 ,17407 , 17407 ,18687 ,18687 ,20223 ,20223 ,21503 ,21503 ,22015 ,22015 ,22271 ,22271 ,22271 ,22271 ,22271 ,22271 , 21503 ,21503 ,20991 ,20991 ,19967 ,19967 ,18431 ,18431 ,17151 ,17151 ,15616 ,15616 ,13824 ,13824 ,12288 , 12288 ,11008 ,11008 ,9216 ,9216 ,7680 ,7680 ,6144 ,6144 ,4864 ,4864 ,3840 ,3840 ,2816 ,2816 , 2304 ,2304 ,1536 ,1536 ,1280 ,1280 ,1280 ,1280 ,1280 ,1280 ,2048 ,2048 ,2560 ,2560 ,3072 , 3072 ,4352 ,4352 ,5376 ,5376 ,6912 ,6912 ,7936 ,7936 ,9472 ,9472 ,10752 ,10752 ,12544 ,12544 , 13824 ,13824 ,15104 ,15104 ,16128 ,16128 ,17151 ,17151 ,17663 ,17663 ,18175 ,18175 ,18431 ,18431 ,18431 , 18431 ,18175 ,18175 ,17407 ,17407 ,16384 ,16384 ,15360 ,15360 ,13824 ,13824 ,12288 ,12288 ,10496 ,10496 , 8448 ,8448 ,6656 ,6656 ,3840 ,3840 ,1792 ,1792 ,-2048 ,-2048 ,-4096 ,-4096 ,-6912 ,-6912 ,-8704 , -8704 ,-10752 ,-10752 ,-12544 ,-12544 ,-14080 ,-14080 ,-15616 ,-15616 ,-16639 ,-16639 ,-17663 ,-17663 ,-18431 ,-18431 , -18687 ,-18687 ,-18687 ,-18687 ,-18431 ,-18431 ,-17919 ,-17919 ,-17407 ,-17407 ,-16384 ,-16384 ,-15360 ,-15360 ,-14080 , -14080 ,-12800 ,-12800 ,-11008 ,-11008 ,-9728 ,-9728 ,-8192 ,-8192 ,-7168 ,-7168 ,-5632 ,-5632 ,-4608 ,-4608 , -3328 ,-3328 ,-2816 ,-2816 ,-2304 ,-2304 ,-1536 ,-1536 ,-1536 ,-1536 ,-1536 ,-1536 ,-1792 ,-1792 ,-2560 , -2560 ,-3072 ,-3072 ,-4096 ,-4096 ,-5120 ,-5120 ,-6400 ,-6400 ,-7936 ,-7936 ,-9472 ,-9472 ,-11264 ,-11264 , -12544 ,-12544 ,-14080 ,-14080 ,-15872 ,-15872 ,-17407 ,-17407 ,-18687 ,-18687 ,-20223 ,-20223 ,-21247 ,-21247 ,-21759 , -21759 ,-22527 ,-22527 ,-22527 ,-22527 ,-22527 ,-22527 ,-22271 ,-22271 ,-21759 ,-21759 ,-20479 ,-20479 ,-18943 ,-18943 , -17663 ,-17663 ,-15616 ,-15616 ,-13568 ,-13568 ,-11264 ,-11264 ,-8704 ,-8704 ,-6656 ,-6656 ,-3584 ,-3584 ,-768 , -768 ,512 ,512 ,3584 ,3584 ,6656 ,6656 ,8960 ,8960 ,11520 ,11520 ,13824 ,13824 ,15872 ,15872 , 17919 ,17919 ,19199 ,19199 ,20735 ,20735 ,22015 ,22015 ,22527 ,22527 ,22527 ,22527 ,22527 ,22527 ,22271 , 22271 ,21503 ,21503 ,20735 ,20735 ,19455 ,19455 ,17919 ,17919 ,16384 ,16384 ,14592 ,14592 ,12800 ,12800 , 11008 ,11008 ,9472 ,9472 ,7680 ,7680 ,6144 ,6144 ,4352 ,4352 ,3072 ,3072 ,2304 ,2304 ,1280 , 1280 ,768 ,768 ,256 ,256 ,0 ,0 ,256 ,256 ,512 ,512 ,1536 ,1536 ,2304 ,2304 , 3328 ,3328 ,4864 ,4864 ,6144 ,6144 ,8192 ,8192 ,9472 ,9472 ,11520 ,11520 ,13056 ,13056 ,15104 , 15104 ,16639 ,16639 ,18431 ,18431 ,19711 ,19711 ,20735 ,20735 ,21503 ,21503 ,22015 ,22015 ,22271 ,22271 , 22271 ,22271 ,22015 ,22015 ,20991 ,20991 ,19711 ,19711 ,18687 ,18687 ,16639 ,16639 ,14848 ,14848 ,12800 , 12800 ,10240 ,10240 ,7936 ,7936 ,4864 ,4864 ,2304 ,2304 ,-2560 ,-2560 ,-5120 ,-5120 ,-8192 ,-8192 , -10496 ,-10496 ,-13056 ,-13056 ,-15104 ,-15104 ,-16895 ,-16895 ,-18943 ,-18943 ,-19967 ,-19967 ,-21247 ,-21247 ,-22271 , -22271 ,-22527 ,-22527 ,-22527 ,-22527 ,-22271 ,-22271 ,-21759 ,-21759 ,-20991 ,-20991 ,-19967 ,-19967 ,-18687 ,-18687 , -16895 ,-16895 ,-15360 ,-15360 ,-13312 ,-13312 ,-11776 ,-11776 ,-9728 ,-9728 ,-8448 ,-8448 ,-6400 ,-6400 ,-5120 , -5120 ,-3584 ,-3584 ,-2560 ,-2560 ,-1792 ,-1792 ,-768 ,-768 ,-512 ,-512 ,-256 ,-256 ,-512 ,-512 , -1024 ,-1024 ,-1536 ,-1536 ,-2560 ,-2560 ,-3328 ,-3328 ,-4608 ,-4608 ,-6400 ,-6400 ,-7936 ,-7936 ,-9728 , -9728 ,-11264 ,-11264 ,-13056 ,-13056 ,-14848 ,-14848 ,-16639 ,-16639 ,-18175 ,-18175 ,-19711 ,-19711 ,-20991 ,-20991 , -21759 ,-21759 ,-22527 ,-22527 ,-22783 ,-22783 ,-22783 ,-22783 ,-22783 ,-22783 ,-22271 ,-22271 ,-20991 ,-20991 ,-19455 , -19455 ,-18175 ,-18175 ,-16128 ,-16128 ,-14080 ,-14080 ,-11776 ,-11776 ,-9216 ,-9216 ,-6912 ,-6912 ,-3840 ,-3840 , -768 ,-768 ,512 ,512 ,3584 ,3584 ,6656 ,6656 ,8960 ,8960 ,11776 ,11776 ,14080 ,14080 ,16128 , 16128 ,17919 ,17919 ,19199 ,19199 ,20735 ,20735 ,21759 ,21759 ,22015 ,22015 ,22015 ,22015 ,21759 ,21759 , 21247 ,21247 ,20223 ,20223 ,19199 ,19199 ,17919 ,17919 ,16384 ,16384 ,14592 ,14592 ,12800 ,12800 ,11264 , 11264 ,9472 ,9472 ,7936 ,7936 ,6400 ,6400 ,5120 ,5120 ,3840 ,3840 ,2816 ,2816 ,2560 ,2560 , 1792 ,1792 ,1792 ,1792 ,1536 ,1536 ,1792 ,1792 ,2304 ,2304 ,2816 ,2816 ,4096 ,4096 ,4864 , 4864 ,6144 ,6144 ,7424 ,7424 ,8704 ,8704 ,10496 ,10496 ,11520 ,11520 ,13312 ,13312 ,14336 ,14336 , 15872 ,15872 ,16895 ,16895 ,18175 ,18175 ,18687 ,18687 ,19199 ,19199 ,19455 ,19455 ,19455 ,19455 ,19455 , 19455 ,18943 ,18943 ,18431 ,18431 ,17407 ,17407 ,16128 ,16128 ,15104 ,15104 ,13312 ,13312 ,11776 ,11776 , 9984 ,9984 ,7936 ,7936 ,6144 ,6144 ,3584 ,3584 ,1536 ,1536 ,-1792 ,-1792 ,-3840 ,-3840 ,-6400 , -6400 ,-8192 ,-8192 ,-10240 ,-10240 ,-12032 ,-12032 ,-13568 ,-13568 ,-15360 ,-15360 ,-16384 ,-16384 ,-17663 ,-17663 , -18687 ,-18687 ,-19199 ,-19199 ,-19711 ,-19711 ,-19711 ,-19711 ,-19711 ,-19711 ,-19455 ,-19455 ,-18943 ,-18943 ,-18431 , -18431 ,-17151 ,-17151 ,-16128 ,-16128 ,-14592 ,-14592 ,-13568 ,-13568 ,-11776 ,-11776 ,-10752 ,-10752 ,-8960 ,-8960 , -7680 ,-7680 ,-6400 ,-6400 ,-5120 ,-5120 ,-4352 ,-4352 ,-3072 ,-3072 ,-2560 ,-2560 ,-2048 ,-2048 ,-1792 , -1792 ,-2048 ,-2048 ,-2048 ,-2048 ,-2816 ,-2816 ,-3072 ,-3072 ,-4096 ,-4096 ,-5376 ,-5376 ,-6656 ,-6656 , -8192 ,-8192 ,-9728 ,-9728 ,-11520 ,-11520 ,-13056 ,-13056 ,-14848 ,-14848 ,-16639 ,-16639 ,-18175 ,-18175 ,-19455 , -19455 ,-20479 ,-20479 ,-21503 ,-21503 ,-22015 ,-22015 ,-22271 ,-22271 ,-22271 ,-22271 ,-22015 ,-22015 ,-20991 ,-20991 , -19455 ,-19455 ,-18175 ,-18175 ,-16384 ,-16384 ,-14336 ,-14336 ,-12032 ,-12032 ,-9216 ,-9216 ,-6912 ,-6912 ,-3840 , -3840 ,-768 ,-768 ,512 ,512 ,3584 ,3584 ,6912 ,6912 ,9216 ,9216 ,12032 ,12032 ,14336 ,14336 , 16384 ,16384 ,18175 ,18175 ,19455 ,19455 ,20735 ,20735 ,21503 ,21503 ,21759 ,21759 ,21503 ,21503 ,20991 , 20991 ,20223 ,20223 ,19199 ,19199 ,17919 ,17919 ,16384 ,16384 ,14848 ,14848 ,13056 ,13056 ,11264 ,11264 , 9728 ,9728 ,7936 ,7936 ,6656 ,6656 ,5376 ,5376 ,4352 ,4352 ,3328 ,3328 ,2816 ,2816 ,2816 , 2816 ,2560 ,2560 ,2816 ,2816 ,3072 ,3072 ,3584 ,3584 ,4608 ,4608 ,5376 ,5376 ,6656 ,6656 , 7680 ,7680 ,8960 ,8960 ,10240 ,10240 ,11520 ,11520 ,13056 ,13056 ,13824 ,13824 ,15104 ,15104 ,15616 , 15616 ,16639 ,16639 ,17151 ,17151 ,17919 ,17919 ,17919 ,17919 ,17919 ,17919 ,17663 ,17663 ,17151 ,17151 , 16639 ,16639 ,15872 ,15872 ,15104 ,15104 ,13824 ,13824 ,12544 ,12544 ,11520 ,11520 ,9984 ,9984 ,8704 , 8704 ,7424 ,7424 ,5632 ,5632 ,4352 ,4352 ,2560 ,2560 ,1024 ,1024 ,-1280 ,-1280 ,-2816 ,-2816 , -4608 ,-4608 ,-5888 ,-5888 ,-7680 ,-7680 ,-8960 ,-8960 ,-10240 ,-10240 ,-11776 ,-11776 ,-12800 ,-12800 ,-14080 , -14080 ,-15360 ,-15360 ,-16128 ,-16128 ,-16895 ,-16895 ,-17407 ,-17407 ,-17919 ,-17919 ,-18175 ,-18175 ,-18175 ,-18175 , -18175 ,-18175 ,-17407 ,-17407 ,-16895 ,-16895 ,-15872 ,-15872 ,-15360 ,-15360 ,-14080 ,-14080 ,-13312 ,-13312 ,-11776 , -11776 ,-10496 ,-10496 ,-9216 ,-9216 ,-7936 ,-7936 ,-6912 ,-6912 ,-5632 ,-5632 ,-4864 ,-4864 ,-3840 ,-3840 , -3328 ,-3328 ,-3072 ,-3072 ,-2816 ,-2816 ,-3072 ,-3072 ,-3072 ,-3072 ,-3584 ,-3584 ,-4608 ,-4608 ,-5632 , -5632 ,-6912 ,-6912 ,-8192 ,-8192 ,-9984 ,-9984 ,-11520 ,-11520 ,-13312 ,-13312 ,-15104 ,-15104 ,-16639 ,-16639 , -18175 ,-18175 ,-19455 ,-19455 ,-20479 ,-20479 ,-21247 ,-21247 ,-21759 ,-21759 ,-22015 ,-22015 ,-21759 ,-21759 ,-20991 , -20991 ,-19711 ,-19711 ,-18431 ,-18431 ,-16639 ,-16639 ,-14592 ,-14592 ,-12288 ,-12288 ,-9472 ,-9472 ,-7168 ,-7168 , -3840 ,-3840 ,-768 ,-768 ,512 ,512 ,3584 ,3584 ,6912 ,6912 ,9472 ,9472 ,12288 ,12288 ,14592 , 14592 ,16639 ,16639 ,18431 ,18431 ,19455 ,19455 ,20735 ,20735 ,21247 ,21247 ,21247 ,21247 ,20991 ,20991 , 20223 ,20223 ,19199 ,19199 ,17919 ,17919 ,16639 ,16639 ,14848 ,14848 ,13312 ,13312 ,11520 ,11520 ,9472 , 9472 ,8192 ,8192 ,6400 ,6400 ,5376 ,5376 ,4096 ,4096 ,3584 ,3584 ,2816 ,2816 ,2560 ,2560 , 3072 ,3072 ,3072 ,3072 ,3840 ,3840 ,4608 ,4608 ,5376 ,5376 ,6656 ,6656 ,7680 ,7680 ,9216 , 9216 ,10496 ,10496 ,11776 ,11776 ,13056 ,13056 ,14080 ,14080 ,15360 ,15360 ,15872 ,15872 ,16895 ,16895 , 16895 ,16895 ,17407 ,17407 ,17407 ,17407 ,17663 ,17663 ,17151 ,17151 ,16384 ,16384 ,15616 ,15616 ,14848 , 14848 ,13824 ,13824 ,12800 ,12800 ,11776 ,11776 ,10240 ,10240 ,8960 ,8960 ,7936 ,7936 ,6656 ,6656 , 5632 ,5632 ,4608 ,4608 ,3328 ,3328 ,2560 ,2560 ,1280 ,1280 ,512 ,512 ,-768 ,-768 ,-1536 , -1536 ,-2816 ,-2816 ,-3584 ,-3584 ,-4864 ,-4864 ,-5888 ,-5888 ,-6912 ,-6912 ,-8192 ,-8192 ,-9216 ,-9216 , -10496 ,-10496 ,-12032 ,-12032 ,-13056 ,-13056 ,-14080 ,-14080 ,-15104 ,-15104 ,-15872 ,-15872 ,-16639 ,-16639 ,-17407 , -17407 ,-17919 ,-17919 ,-17663 ,-17663 ,-17663 ,-17663 ,-17151 ,-17151 ,-17151 ,-17151 ,-16128 ,-16128 ,-15616 ,-15616 , -14336 ,-14336 ,-13312 ,-13312 ,-12032 ,-12032 ,-10752 ,-10752 ,-9472 ,-9472 ,-7936 ,-7936 ,-6912 ,-6912 ,-5632 , -5632 ,-4864 ,-4864 ,-4096 ,-4096 ,-3328 ,-3328 ,-3328 ,-3328 ,-2816 ,-2816 ,-3072 ,-3072 ,-3840 ,-3840 , -4352 ,-4352 ,-5632 ,-5632 ,-6656 ,-6656 ,-8448 ,-8448 ,-9728 ,-9728 ,-11776 ,-11776 ,-13568 ,-13568 ,-15104 , -15104 ,-16895 ,-16895 ,-18175 ,-18175 ,-19455 ,-19455 ,-20479 ,-20479 ,-21247 ,-21247 ,-21503 ,-21503 ,-21503 ,-21503 , -20991 ,-20991 ,-19711 ,-19711 ,-18687 ,-18687 ,-16895 ,-16895 ,-14848 ,-14848 ,-12544 ,-12544 ,-9728 ,-9728 ,-7168 , -7168 ,-3840 ,-3840 ,-768 ,-768 ,512 ,512 ,3840 ,3840 ,7168 ,7168 ,9728 ,9728 ,12544 ,12544 , 14848 ,14848 ,16895 ,16895 ,18687 ,18687 ,19711 ,19711 ,20735 ,20735 ,21247 ,21247 ,20991 ,20991 ,20479 , 20479 ,19711 ,19711 ,18431 ,18431 ,16895 ,16895 ,15360 ,15360 ,13568 ,13568 ,11776 ,11776 ,9984 ,9984 , 7936 ,7936 ,6656 ,6656 ,5120 ,5120 ,4096 ,4096 ,3072 ,3072 ,2816 ,2816 ,2560 ,2560 ,2560 , 2560 ,3328 ,3328 ,3840 ,3840 ,4864 ,4864 ,6144 ,6144 ,7424 ,7424 ,8960 ,8960 ,10240 ,10240 , 12032 ,12032 ,13312 ,13312 ,14592 ,14592 ,15872 ,15872 ,16895 ,16895 ,17919 ,17919 ,18175 ,18175 ,18687 , 18687 ,18431 ,18431 ,18431 ,18431 ,17919 ,17919 ,17407 ,17407 ,16384 ,16384 ,15104 ,15104 ,13824 ,13824 , 12544 ,12544 ,11008 ,11008 ,9728 ,9728 ,8448 ,8448 ,6912 ,6912 ,5632 ,5632 ,4608 ,4608 ,3584 , 3584 ,2816 ,2816 ,2048 ,2048 ,1280 ,1280 ,1024 ,1024 ,256 ,256 ,0 ,0 ,-256 ,-256 , -512 ,-512 ,-1280 ,-1280 ,-1536 ,-1536 ,-2304 ,-2304 ,-3072 ,-3072 ,-3840 ,-3840 ,-4864 ,-4864 ,-5888 , -5888 ,-7168 ,-7168 ,-8704 ,-8704 ,-9984 ,-9984 ,-11264 ,-11264 ,-12800 ,-12800 ,-14080 ,-14080 ,-15360 ,-15360 , -16639 ,-16639 ,-17663 ,-17663 ,-18175 ,-18175 ,-18687 ,-18687 ,-18687 ,-18687 ,-18943 ,-18943 ,-18431 ,-18431 ,-18175 , -18175 ,-17151 ,-17151 ,-16128 ,-16128 ,-14848 ,-14848 ,-13568 ,-13568 ,-12288 ,-12288 ,-10496 ,-10496 ,-9216 ,-9216 , -7680 ,-7680 ,-6400 ,-6400 ,-5120 ,-5120 ,-4096 ,-4096 ,-3584 ,-3584 ,-2816 ,-2816 ,-2816 ,-2816 ,-3072 , -3072 ,-3328 ,-3328 ,-4352 ,-4352 ,-5376 ,-5376 ,-6912 ,-6912 ,-8192 ,-8192 ,-10240 ,-10240 ,-12032 ,-12032 , -13824 ,-13824 ,-15616 ,-15616 ,-17151 ,-17151 ,-18687 ,-18687 ,-19967 ,-19967 ,-20735 ,-20735 ,-21247 ,-21247 ,-21503 , -21503 ,-20991 ,-20991 ,-19967 ,-19967 ,-18943 ,-18943 ,-17151 ,-17151 ,-15104 ,-15104 ,-12800 ,-12800 ,-9984 ,-9984 , -7424 ,-7424 ,-4096 ,-4096 ,-768 ,-768 ,512 ,512 ,3840 ,3840 ,7168 ,7168 ,9984 ,9984 ,12800 , 12800 ,15104 ,15104 ,17151 ,17151 ,18943 ,18943 ,19711 ,19711 ,20735 ,20735 ,20991 ,20991 ,20479 ,20479 , 19967 ,19967 ,18943 ,18943 ,17407 ,17407 ,15616 ,15616 ,14080 ,14080 ,12032 ,12032 ,10240 ,10240 ,8192 , 8192 ,6144 ,6144 ,5120 ,5120 ,3584 ,3584 ,2816 ,2816 ,1792 ,1792 ,2048 ,2048 ,2048 ,2048 , 2304 ,2304 ,3584 ,3584 ,4352 ,4352 ,5888 ,5888 ,7424 ,7424 ,9216 ,9216 ,11008 ,11008 ,12544 , 12544 ,14592 ,14592 ,16128 ,16128 ,17407 ,17407 ,18687 ,18687 ,19455 ,19455 ,20223 ,20223 ,20223 ,20223 , 20479 ,20479 ,19711 ,19711 ,19199 ,19199 ,18175 ,18175 ,17151 ,17151 ,15360 ,15360 ,13568 ,13568 ,11776 , 11776 ,10240 ,10240 ,8192 ,8192 ,6400 ,6400 ,5120 ,5120 ,3328 ,3328 ,2048 ,2048 ,1024 ,1024 , 256 ,256 ,-256 ,-256 ,-768 ,-768 ,-1024 ,-1024 ,-768 ,-768 ,-1024 ,-1024 ,-768 ,-768 ,512 , 512 ,768 ,768 ,512 ,512 ,768 ,768 ,512 ,512 ,0 ,0 ,-512 ,-512 ,-1280 ,-1280 , -2304 ,-2304 ,-3584 ,-3584 ,-5376 ,-5376 ,-6656 ,-6656 ,-8448 ,-8448 ,-10496 ,-10496 ,-12032 ,-12032 ,-13824 , -13824 ,-15616 ,-15616 ,-17407 ,-17407 ,-18431 ,-18431 ,-19455 ,-19455 ,-19967 ,-19967 ,-20735 ,-20735 ,-20479 ,-20479 , -20479 ,-20479 ,-19711 ,-19711 ,-18943 ,-18943 ,-17663 ,-17663 ,-16384 ,-16384 ,-14848 ,-14848 ,-12800 ,-12800 ,-11264 , -11264 ,-9472 ,-9472 ,-7680 ,-7680 ,-6144 ,-6144 ,-4608 ,-4608 ,-3840 ,-3840 ,-2560 ,-2560 ,-2304 ,-2304 , -2304 ,-2304 ,-2048 ,-2048 ,-3072 ,-3072 ,-3840 ,-3840 ,-5376 ,-5376 ,-6400 ,-6400 ,-8448 ,-8448 ,-10496 , -10496 ,-12288 ,-12288 ,-14336 ,-14336 ,-15872 ,-15872 ,-17663 ,-17663 ,-19199 ,-19199 ,-20223 ,-20223 ,-20735 ,-20735 , -21247 ,-21247 ,-20991 ,-20991 ,-19967 ,-19967 ,-19199 ,-19199 ,-17407 ,-17407 ,-15360 ,-15360 ,-13056 ,-13056 ,-10240 , -10240 ,-7424 ,-7424 ,-4096 ,-4096 ,-768 ,-768 ,512 ,512 ,4096 ,4096 ,7424 ,7424 ,10240 ,10240 , 13056 ,13056 ,15360 ,15360 ,17407 ,17407 ,19199 ,19199 ,19967 ,19967 ,20735 ,20735 ,20991 ,20991 ,20223 , 20223 ,19455 ,19455 ,18175 ,18175 ,16639 ,16639 ,14592 ,14592 ,12800 ,12800 ,10752 ,10752 ,8704 ,8704 , 6656 ,6656 ,4608 ,4608 ,3584 ,3584 ,2304 ,2304 ,1536 ,1536 ,768 ,768 ,1280 ,1280 ,1536 , 1536 ,2304 ,2304 ,3840 ,3840 ,5120 ,5120 ,6912 ,6912 ,8960 ,8960 ,11008 ,11008 ,13312 ,13312 , 15104 ,15104 ,17407 ,17407 ,18943 ,18943 ,20223 ,20223 ,21503 ,21503 ,22271 ,22271 ,22783 ,22783 ,22527 , 22527 ,22271 ,22271 ,21247 ,21247 ,20223 ,20223 ,18431 ,18431 ,16895 ,16895 ,14592 ,14592 ,12288 ,12288 , 9984 ,9984 ,7936 ,7936 ,5376 ,5376 ,3328 ,3328 ,1792 ,1792 ,0 ,0 ,-1536 ,-1536 ,-2304 , -2304 ,-3072 ,-3072 ,-3328 ,-3328 ,-3328 ,-3328 ,-3328 ,-3328 ,-2560 ,-2560 ,-2048 ,-2048 ,-1280 ,-1280 , 1024 ,1024 ,1792 ,1792 ,2304 ,2304 ,3072 ,3072 ,3072 ,3072 ,3072 ,3072 ,2816 ,2816 ,2048 , 2048 ,1280 ,1280 ,-256 ,-256 ,-2048 ,-2048 ,-3584 ,-3584 ,-5632 ,-5632 ,-8192 ,-8192 ,-10240 ,-10240 , -12544 ,-12544 ,-14848 ,-14848 ,-17151 ,-17151 ,-18687 ,-18687 ,-20479 ,-20479 ,-21503 ,-21503 ,-22527 ,-22527 ,-22783 , -22783 ,-23039 ,-23039 ,-22527 ,-22527 ,-21759 ,-21759 ,-20479 ,-20479 ,-19199 ,-19199 ,-17663 ,-17663 ,-15360 ,-15360 , -13568 ,-13568 ,-11264 ,-11264 ,-9216 ,-9216 ,-7168 ,-7168 ,-5376 ,-5376 ,-4096 ,-4096 ,-2560 ,-2560 ,-1792 , -1792 ,-1536 ,-1536 ,-1024 ,-1024 ,-1792 ,-1792 ,-2560 ,-2560 ,-3840 ,-3840 ,-4864 ,-4864 ,-6912 ,-6912 , -8960 ,-8960 ,-11008 ,-11008 ,-13056 ,-13056 ,-14848 ,-14848 ,-16895 ,-16895 ,-18431 ,-18431 ,-19711 ,-19711 ,-20479 , -20479 ,-21247 ,-21247 ,-20991 ,-20991 ,-20223 ,-20223 ,-19455 ,-19455 ,-17663 ,-17663 ,-15616 ,-15616 ,-13312 ,-13312 , -10496 ,-10496 ,-7680 ,-7680 ,-4352 ,-4352 ,-768 ,-768 ,512 ,512 ,4096 ,4096 ,7680 ,7680 ,10496 , 10496 ,13312 ,13312 ,15616 ,15616 ,17663 ,17663 ,19455 ,19455 ,20223 ,20223 ,20735 ,20735 ,20735 ,20735 , 19967 ,19967 ,18943 ,18943 ,17407 ,17407 ,15616 ,15616 ,13568 ,13568 ,11520 ,11520 ,9216 ,9216 ,7168 , 7168 ,5120 ,5120 ,3072 ,3072 ,2048 ,2048 ,768 ,768 ,256 ,256 ,-256 ,-256 ,512 ,512 , 1024 ,1024 ,2304 ,2304 ,4096 ,4096 ,5888 ,5888 ,7936 ,7936 ,10496 ,10496 ,12800 ,12800 ,15616 , 15616 ,17663 ,17663 ,19967 ,19967 ,21759 ,21759 ,23039 ,23039 ,24319 ,24319 ,24831 ,24831 ,25343 ,25343 , 24575 ,24575 ,24063 ,24063 ,22527 ,22527 ,20991 ,20991 ,18687 ,18687 ,16639 ,16639 ,13824 ,13824 ,11008 , 11008 ,8192 ,8192 ,5632 ,5632 ,2560 ,2560 ,256 ,256 ,-1536 ,-1536 ,-3584 ,-3584 ,-5120 ,-5120 , -5888 ,-5888 ,-6400 ,-6400 ,-6400 ,-6400 ,-5888 ,-5888 ,-5632 ,-5632 ,-4352 ,-4352 ,-3328 ,-3328 ,-1792 , -1792 ,1536 ,1536 ,3072 ,3072 ,4096 ,4096 ,5376 ,5376 ,5632 ,5632 ,6144 ,6144 ,6144 ,6144 , 5632 ,5632 ,4864 ,4864 ,3328 ,3328 ,1280 ,1280 ,-512 ,-512 ,-2816 ,-2816 ,-5888 ,-5888 ,-8448 , -8448 ,-11264 ,-11264 ,-14080 ,-14080 ,-16895 ,-16895 ,-18943 ,-18943 ,-21247 ,-21247 ,-22783 ,-22783 ,-24319 ,-24319 , -24831 ,-24831 ,-25599 ,-25599 ,-25087 ,-25087 ,-24575 ,-24575 ,-23295 ,-23295 ,-22015 ,-22015 ,-20223 ,-20223 ,-17919 , -17919 ,-15872 ,-15872 ,-13056 ,-13056 ,-10752 ,-10752 ,-8192 ,-8192 ,-6144 ,-6144 ,-4352 ,-4352 ,-2560 ,-2560 , -1280 ,-1280 ,-768 ,-768 ,0 ,0 ,-512 ,-512 ,-1024 ,-1024 ,-2304 ,-2304 ,-3328 ,-3328 ,-5376 , -5376 ,-7424 ,-7424 ,-9472 ,-9472 ,-11776 ,-11776 ,-13824 ,-13824 ,-15872 ,-15872 ,-17663 ,-17663 ,-19199 ,-19199 , -20223 ,-20223 ,-20991 ,-20991 ,-20991 ,-20991 ,-20479 ,-20479 ,-19711 ,-19711 ,-17919 ,-17919 ,-15872 ,-15872 ,-13568 , -13568 ,-10752 ,-10752 ,-7936 ,-7936 ,-4352 ,-4352 ,-768 ,-768 ,512 ,512 ,4352 ,4352 ,7936 ,7936 , 10752 ,10752 ,13824 ,13824 ,15872 ,15872 ,17919 ,17919 ,19711 ,19711 ,20479 ,20479 ,20735 ,20735 ,20735 , 20735 ,19711 ,19711 ,18431 ,18431 ,16895 ,16895 ,14848 ,14848 ,12544 ,12544 ,10240 ,10240 ,7936 ,7936 , 5632 ,5632 ,3584 ,3584 ,1536 ,1536 ,512 ,512 ,-512 ,-512 ,-1024 ,-1024 ,-1280 ,-1280 ,-256 , -256 ,768 ,768 ,2304 ,2304 ,4352 ,4352 ,6656 ,6656 ,9216 ,9216 ,12032 ,12032 ,14848 ,14848 , 17919 ,17919 ,20223 ,20223 ,22783 ,22783 ,24575 ,24575 ,25855 ,25855 ,27135 ,27135 ,27647 ,27647 ,27903 , 27903 ,26879 ,26879 ,25855 ,25855 ,24063 ,24063 ,22015 ,22015 ,19199 ,19199 ,16384 ,16384 ,13056 ,13056 , 9728 ,9728 ,6400 ,6400 ,3328 ,3328 ,0 ,0 ,-2816 ,-2816 ,-4864 ,-4864 ,-6912 ,-6912 ,-8448 , -8448 ,-9216 ,-9216 ,-9472 ,-9472 ,-9216 ,-9216 ,-8448 ,-8448 ,-7680 ,-7680 ,-5888 ,-5888 ,-4352 ,-4352 , -2304 ,-2304 ,2048 ,2048 ,4096 ,4096 ,5632 ,5632 ,7424 ,7424 ,8192 ,8192 ,8960 ,8960 ,9216 , 9216 ,8960 ,8960 ,8192 ,8192 ,6656 ,6656 ,4608 ,4608 ,2560 ,2560 ,-256 ,-256 ,-3584 ,-3584 , -6656 ,-6656 ,-9984 ,-9984 ,-13312 ,-13312 ,-16639 ,-16639 ,-19455 ,-19455 ,-22271 ,-22271 ,-24319 ,-24319 ,-26111 , -26111 ,-27135 ,-27135 ,-28159 ,-28159 ,-27903 ,-27903 ,-27391 ,-27391 ,-26111 ,-26111 ,-24831 ,-24831 ,-23039 ,-23039 , -20479 ,-20479 ,-18175 ,-18175 ,-15104 ,-15104 ,-12288 ,-12288 ,-9472 ,-9472 ,-6912 ,-6912 ,-4608 ,-4608 ,-2560 , -2560 ,-1024 ,-1024 ,0 ,0 ,1024 ,1024 ,768 ,768 ,256 ,256 ,-768 ,-768 ,-1792 ,-1792 , -3840 ,-3840 ,-5888 ,-5888 ,-8192 ,-8192 ,-10496 ,-10496 ,-12800 ,-12800 ,-15104 ,-15104 ,-17151 ,-17151 ,-18687 , -18687 ,-19967 ,-19967 ,-20991 ,-20991 ,-20991 ,-20991 ,-20735 ,-20735 ,-19967 ,-19967 ,-18175 ,-18175 ,-16128 ,-16128 , -14080 ,-14080 ,-11008 ,-11008 ,-8192 ,-8192 ,-4608 ,-4608 ,-768 ,-768 ,512 ,512 ,4352 ,4352 ,7936 , 7936 ,10752 ,10752 ,13824 ,13824 ,15872 ,15872 ,17919 ,17919 ,19711 ,19711 ,20223 ,20223 ,20223 ,20223 , 19967 ,19967 ,18943 ,18943 ,17407 ,17407 ,15616 ,15616 ,13568 ,13568 ,11264 ,11264 ,8960 ,8960 ,6656 , 6656 ,4608 ,4608 ,2560 ,2560 ,1024 ,1024 ,256 ,256 ,-256 ,-256 ,-256 ,-256 ,-256 ,-256 , 1280 ,1280 ,2560 ,2560 ,4352 ,4352 ,6656 ,6656 ,8960 ,8960 ,11264 ,11264 ,14080 ,14080 ,16639 , 16639 ,19199 ,19199 ,20991 ,20991 ,23039 ,23039 ,24063 ,24063 ,24831 ,24831 ,25599 ,25599 ,25343 ,25343 , 25343 ,25343 ,23807 ,23807 ,22783 ,22783 ,20735 ,20735 ,18943 ,18943 ,16384 ,16384 ,13824 ,13824 ,11008 , 11008 ,8448 ,8448 ,5888 ,5888 ,3584 ,3584 ,1024 ,1024 ,-1280 ,-1280 ,-2560 ,-2560 ,-4096 ,-4096 , -5376 ,-5376 ,-5888 ,-5888 ,-6144 ,-6144 ,-5888 ,-5888 ,-5376 ,-5376 ,-5120 ,-5120 ,-3840 ,-3840 ,-3072 , -3072 ,-1792 ,-1792 ,1536 ,1536 ,2816 ,2816 ,3584 ,3584 ,4864 ,4864 ,5120 ,5120 ,5632 ,5632 , 5888 ,5888 ,5632 ,5632 ,5120 ,5120 ,3840 ,3840 ,2304 ,2304 ,1024 ,1024 ,-1280 ,-1280 ,-3840 , -3840 ,-6144 ,-6144 ,-8704 ,-8704 ,-11264 ,-11264 ,-14080 ,-14080 ,-16639 ,-16639 ,-19199 ,-19199 ,-20991 ,-20991 , -23039 ,-23039 ,-24063 ,-24063 ,-25599 ,-25599 ,-25599 ,-25599 ,-25855 ,-25855 ,-25087 ,-25087 ,-24319 ,-24319 ,-23295 , -23295 ,-21247 ,-21247 ,-19455 ,-19455 ,-16895 ,-16895 ,-14336 ,-14336 ,-11520 ,-11520 ,-9216 ,-9216 ,-6912 ,-6912 , -4608 ,-4608 ,-2816 ,-2816 ,-1536 ,-1536 ,0 ,0 ,0 ,0 ,0 ,0 ,-512 ,-512 ,-1280 , -1280 ,-2816 ,-2816 ,-4864 ,-4864 ,-6912 ,-6912 ,-9216 ,-9216 ,-11520 ,-11520 ,-13824 ,-13824 ,-15872 ,-15872 , -17663 ,-17663 ,-19199 ,-19199 ,-20223 ,-20223 ,-20479 ,-20479 ,-20479 ,-20479 ,-19967 ,-19967 ,-18175 ,-18175 ,-16128 , -16128 ,-14080 ,-14080 ,-11008 ,-11008 ,-8192 ,-8192 ,-4608 ,-4608 ,-768 ,-768 ,512 ,512 ,4352 ,4352 , 8192 ,8192 ,11008 ,11008 ,14080 ,14080 ,16128 ,16128 ,18175 ,18175 ,19711 ,19711 ,19967 ,19967 ,19967 , 19967 ,19455 ,19455 ,18175 ,18175 ,16384 ,16384 ,14592 ,14592 ,12288 ,12288 ,9984 ,9984 ,7680 ,7680 , 5376 ,5376 ,3584 ,3584 ,1792 ,1792 ,512 ,512 ,256 ,256 ,0 ,0 ,512 ,512 ,1024 , 1024 ,2816 ,2816 ,4352 ,4352 ,6400 ,6400 ,8960 ,8960 ,11264 ,11264 ,13568 ,13568 ,16128 ,16128 , 18431 ,18431 ,20479 ,20479 ,21759 ,21759 ,23295 ,23295 ,23807 ,23807 ,23807 ,23807 ,24063 ,24063 ,23295 , 23295 ,22783 ,22783 ,20991 ,20991 ,19711 ,19711 ,17663 ,17663 ,15872 ,15872 ,13568 ,13568 ,11520 ,11520 , 9216 ,9216 ,7168 ,7168 ,5376 ,5376 ,3840 ,3840 ,2048 ,2048 ,512 ,512 ,-256 ,-256 ,-1280 , -1280 ,-2048 ,-2048 ,-2304 ,-2304 ,-2560 ,-2560 ,-2560 ,-2560 ,-2304 ,-2304 ,-2304 ,-2304 ,-1536 ,-1536 , -1536 ,-1536 ,-1024 ,-1024 ,768 ,768 ,1280 ,1280 ,1280 ,1280 ,2048 ,2048 ,2048 ,2048 ,2304 , 2304 ,2304 ,2304 ,2048 ,2048 ,1792 ,1792 ,1024 ,1024 ,0 ,0 ,-768 ,-768 ,-2304 ,-2304 , -4096 ,-4096 ,-5632 ,-5632 ,-7424 ,-7424 ,-9472 ,-9472 ,-11776 ,-11776 ,-13824 ,-13824 ,-16128 ,-16128 ,-17919 , -17919 ,-19967 ,-19967 ,-21247 ,-21247 ,-23039 ,-23039 ,-23551 ,-23551 ,-24319 ,-24319 ,-24063 ,-24063 ,-24063 ,-24063 , -23551 ,-23551 ,-22015 ,-22015 ,-20735 ,-20735 ,-18687 ,-18687 ,-16384 ,-16384 ,-13824 ,-13824 ,-11520 ,-11520 ,-9216 , -9216 ,-6656 ,-6656 ,-4608 ,-4608 ,-3072 ,-3072 ,-1280 ,-1280 ,-768 ,-768 ,-256 ,-256 ,-512 ,-512 , -768 ,-768 ,-2048 ,-2048 ,-3840 ,-3840 ,-5632 ,-5632 ,-7936 ,-7936 ,-10240 ,-10240 ,-12544 ,-12544 ,-14848 , -14848 ,-16639 ,-16639 ,-18431 ,-18431 ,-19711 ,-19711 ,-20223 ,-20223 ,-20223 ,-20223 ,-19967 ,-19967 ,-18431 ,-18431 , -16384 ,-16384 ,-14336 ,-14336 ,-11264 ,-11264 ,-8448 ,-8448 ,-4608 ,-4608 ,-768 ,-768 ,512 ,512 ,4352 , 4352 ,8192 ,8192 ,11264 ,11264 ,14336 ,14336 ,16384 ,16384 ,18175 ,18175 ,19711 ,19711 ,19711 ,19711 , 19455 ,19455 ,18943 ,18943 ,17407 ,17407 ,15360 ,15360 ,13568 ,13568 ,11008 ,11008 ,8704 ,8704 ,6400 , 6400 ,4096 ,4096 ,2560 ,2560 ,1024 ,1024 ,0 ,0 ,0 ,0 ,256 ,256 ,1280 ,1280 , 2048 ,2048 ,4352 ,4352 ,6144 ,6144 ,8448 ,8448 ,11264 ,11264 ,13568 ,13568 ,15872 ,15872 ,18175 , 18175 ,20223 ,20223 ,21759 ,21759 ,22527 ,22527 ,23551 ,23551 ,23551 ,23551 ,22783 ,22783 ,22527 ,22527 , 21247 ,21247 ,20223 ,20223 ,18175 ,18175 ,16639 ,16639 ,14592 ,14592 ,12800 ,12800 ,10752 ,10752 ,8960 , 8960 ,7424 ,7424 ,5888 ,5888 ,4864 ,4864 ,4096 ,4096 ,3072 ,3072 ,2304 ,2304 ,2048 ,2048 , 1536 ,1536 ,1280 ,1280 ,1024 ,1024 ,1024 ,1024 ,768 ,768 ,768 ,768 ,512 ,512 ,512 , 512 ,0 ,0 ,-256 ,-256 ,0 ,0 ,-256 ,-256 ,-768 ,-768 ,-768 ,-768 ,-1024 ,-1024 , -1024 ,-1024 ,-1280 ,-1280 ,-1280 ,-1280 ,-1536 ,-1536 ,-1792 ,-1792 ,-2304 ,-2304 ,-2560 ,-2560 ,-3328 , -3328 ,-4352 ,-4352 ,-5120 ,-5120 ,-6144 ,-6144 ,-7680 ,-7680 ,-9216 ,-9216 ,-11008 ,-11008 ,-13056 ,-13056 , -14848 ,-14848 ,-16895 ,-16895 ,-18431 ,-18431 ,-20479 ,-20479 ,-21503 ,-21503 ,-22783 ,-22783 ,-23039 ,-23039 ,-23807 , -23807 ,-23807 ,-23807 ,-22783 ,-22783 ,-22015 ,-22015 ,-20479 ,-20479 ,-18431 ,-18431 ,-16128 ,-16128 ,-13824 ,-13824 , -11520 ,-11520 ,-8704 ,-8704 ,-6400 ,-6400 ,-4608 ,-4608 ,-2304 ,-2304 ,-1536 ,-1536 ,-512 ,-512 ,-256 , -256 ,-256 ,-256 ,-1280 ,-1280 ,-2816 ,-2816 ,-4352 ,-4352 ,-6656 ,-6656 ,-8960 ,-8960 ,-11264 ,-11264 , -13824 ,-13824 ,-15616 ,-15616 ,-17663 ,-17663 ,-19199 ,-19199 ,-19711 ,-19711 ,-19967 ,-19967 ,-19967 ,-19967 ,-18431 , -18431 ,-16639 ,-16639 ,-14592 ,-14592 ,-11520 ,-11520 ,-8448 ,-8448 ,-4608 ,-4608 ,-768 ,-768 ,512 ,512 , 4608 ,4608 ,8448 ,8448 ,11520 ,11520 ,14592 ,14592 ,16639 ,16639 ,18431 ,18431 ,19711 ,19711 ,19711 , 19711 ,19199 ,19199 ,18431 ,18431 ,16639 ,16639 ,14592 ,14592 ,12544 ,12544 ,9984 ,9984 ,7424 ,7424 , 5120 ,5120 ,3072 ,3072 ,1536 ,1536 ,256 ,256 ,-256 ,-256 ,0 ,0 ,512 ,512 ,2048 , 2048 ,3328 ,3328 ,5888 ,5888 ,8192 ,8192 ,10752 ,10752 ,13568 ,13568 ,15872 ,15872 ,18175 ,18175 , 20223 ,20223 ,22015 ,22015 ,23039 ,23039 ,23551 ,23551 ,23807 ,23807 ,23295 ,23295 ,22015 ,22015 ,20991 , 20991 ,19199 ,19199 ,17663 ,17663 ,15360 ,15360 ,13568 ,13568 ,11520 ,11520 ,9728 ,9728 ,7936 ,7936 , 6656 ,6656 ,5632 ,5632 ,4864 ,4864 ,4352 ,4352 ,4352 ,4352 ,4096 ,4096 ,4096 ,4096 ,4352 , 4352 ,4608 ,4608 ,4608 ,4608 ,4608 ,4608 ,4608 ,4608 ,4352 ,4352 ,4096 ,4096 ,3328 ,3328 , 2816 ,2816 ,1536 ,1536 ,512 ,512 ,-768 ,-768 ,-1792 ,-1792 ,-3072 ,-3072 ,-3584 ,-3584 ,-4352 , -4352 ,-4608 ,-4608 ,-4864 ,-4864 ,-4864 ,-4864 ,-4864 ,-4864 ,-4864 ,-4864 ,-4608 ,-4608 ,-4352 ,-4352 , -4352 ,-4352 ,-4608 ,-4608 ,-4608 ,-4608 ,-5120 ,-5120 ,-5888 ,-5888 ,-6912 ,-6912 ,-8192 ,-8192 ,-9984 , -9984 ,-11776 ,-11776 ,-13824 ,-13824 ,-15616 ,-15616 ,-17919 ,-17919 ,-19455 ,-19455 ,-21247 ,-21247 ,-22271 ,-22271 , -23551 ,-23551 ,-24063 ,-24063 ,-23807 ,-23807 ,-23295 ,-23295 ,-22271 ,-22271 ,-20479 ,-20479 ,-18431 ,-18431 ,-16128 , -16128 ,-13824 ,-13824 ,-11008 ,-11008 ,-8448 ,-8448 ,-6144 ,-6144 ,-3584 ,-3584 ,-2304 ,-2304 ,-768 ,-768 , -256 ,-256 ,0 ,0 ,-512 ,-512 ,-1792 ,-1792 ,-3328 ,-3328 ,-5376 ,-5376 ,-7680 ,-7680 ,-10240 , -10240 ,-12800 ,-12800 ,-14848 ,-14848 ,-16895 ,-16895 ,-18687 ,-18687 ,-19455 ,-19455 ,-19967 ,-19967 ,-19967 ,-19967 , -18687 ,-18687 ,-16895 ,-16895 ,-14848 ,-14848 ,-11776 ,-11776 ,-8704 ,-8704 ,-4864 ,-4864 ,-768 ,-768 ,512 , 512 ,4608 ,4608 ,8448 ,8448 ,11776 ,11776 ,14592 ,14592 ,16895 ,16895 ,18431 ,18431 ,19711 ,19711 , 19455 ,19455 ,18687 ,18687 ,17919 ,17919 ,15872 ,15872 ,13568 ,13568 ,11264 ,11264 ,8704 ,8704 ,6144 , 6144 ,3840 ,3840 ,1792 ,1792 ,512 ,512 ,-512 ,-512 ,-768 ,-768 ,-256 ,-256 ,768 ,768 , 2816 ,2816 ,4352 ,4352 ,7424 ,7424 ,9984 ,9984 ,12800 ,12800 ,15872 ,15872 ,18175 ,18175 ,20479 , 20479 ,22271 ,22271 ,23807 ,23807 ,24319 ,24319 ,24319 ,24319 ,24063 ,24063 ,22783 ,22783 ,20991 ,20991 , 19455 ,19455 ,16895 ,16895 ,15104 ,15104 ,12288 ,12288 ,10496 ,10496 ,8192 ,8192 ,6656 ,6656 ,5120 , 5120 ,4096 ,4096 ,3840 ,3840 ,3584 ,3584 ,3840 ,3840 ,4608 ,4608 ,5120 ,5120 ,5632 ,5632 , 6656 ,6656 ,7424 ,7424 ,7680 ,7680 ,7936 ,7936 ,8192 ,8192 ,7680 ,7680 ,7168 ,7168 ,5888 , 5888 ,4864 ,4864 ,3072 ,3072 ,1280 ,1280 ,-1536 ,-1536 ,-3328 ,-3328 ,-5120 ,-5120 ,-6144 ,-6144 , -7424 ,-7424 ,-7936 ,-7936 ,-8448 ,-8448 ,-8192 ,-8192 ,-7936 ,-7936 ,-7680 ,-7680 ,-6912 ,-6912 ,-5888 , -5888 ,-5376 ,-5376 ,-4864 ,-4864 ,-4096 ,-4096 ,-3840 ,-3840 ,-4096 ,-4096 ,-4352 ,-4352 ,-5376 ,-5376 , -6912 ,-6912 ,-8448 ,-8448 ,-10752 ,-10752 ,-12544 ,-12544 ,-15360 ,-15360 ,-17151 ,-17151 ,-19711 ,-19711 ,-21247 , -21247 ,-23039 ,-23039 ,-24319 ,-24319 ,-24575 ,-24575 ,-24575 ,-24575 ,-24063 ,-24063 ,-22527 ,-22527 ,-20735 ,-20735 , -18431 ,-18431 ,-16128 ,-16128 ,-13056 ,-13056 ,-10240 ,-10240 ,-7680 ,-7680 ,-4608 ,-4608 ,-3072 ,-3072 ,-1024 , -1024 ,0 ,0 ,512 ,512 ,256 ,256 ,-768 ,-768 ,-2048 ,-2048 ,-4096 ,-4096 ,-6400 ,-6400 , -8960 ,-8960 ,-11520 ,-11520 ,-13824 ,-13824 ,-16128 ,-16128 ,-18175 ,-18175 ,-18943 ,-18943 ,-19711 ,-19711 ,-19967 , -19967 ,-18687 ,-18687 ,-17151 ,-17151 ,-14848 ,-14848 ,-12032 ,-12032 ,-8704 ,-8704 ,-4864 ,-4864 ,-768 ,-768 , 512 ,512 ,4608 ,4608 ,8704 ,8704 ,12032 ,12032 ,14848 ,14848 ,17151 ,17151 ,18687 ,18687 ,19711 , 19711 ,19455 ,19455 ,18431 ,18431 ,17407 ,17407 ,15104 ,15104 ,12544 ,12544 ,10240 ,10240 ,7424 ,7424 , 4864 ,4864 ,2560 ,2560 ,768 ,768 ,-512 ,-512 ,-1280 ,-1280 ,-1280 ,-1280 ,-256 ,-256 ,1024 , 1024 ,3584 ,3584 ,5632 ,5632 ,8960 ,8960 ,12032 ,12032 ,15104 ,15104 ,18175 ,18175 ,20479 ,20479 , 22783 ,22783 ,24319 ,24319 ,25599 ,25599 ,25599 ,25599 ,25087 ,25087 ,24319 ,24319 ,22527 ,22527 ,20223 , 20223 ,17919 ,17919 ,14848 ,14848 ,12544 ,12544 ,9472 ,9472 ,7424 ,7424 ,5120 ,5120 ,3584 ,3584 , 2304 ,2304 ,1792 ,1792 ,2048 ,2048 ,2304 ,2304 ,3328 ,3328 ,4864 ,4864 ,6144 ,6144 ,7424 , 7424 ,8960 ,8960 ,10240 ,10240 ,11008 ,11008 ,11520 ,11520 ,11776 ,11776 ,11264 ,11264 ,10240 ,10240 , 8704 ,8704 ,7168 ,7168 ,4608 ,4608 ,2048 ,2048 ,-2304 ,-2304 ,-4864 ,-4864 ,-7424 ,-7424 ,-8960 , -8960 ,-10496 ,-10496 ,-11520 ,-11520 ,-12032 ,-12032 ,-11776 ,-11776 ,-11264 ,-11264 ,-10496 ,-10496 ,-9216 ,-9216 , -7680 ,-7680 ,-6400 ,-6400 ,-5120 ,-5120 ,-3584 ,-3584 ,-2560 ,-2560 ,-2304 ,-2304 ,-2048 ,-2048 ,-2560 , -2560 ,-3840 ,-3840 ,-5376 ,-5376 ,-7680 ,-7680 ,-9728 ,-9728 ,-12800 ,-12800 ,-15104 ,-15104 ,-18175 ,-18175 , -20479 ,-20479 ,-22783 ,-22783 ,-24575 ,-24575 ,-25343 ,-25343 ,-25855 ,-25855 ,-25855 ,-25855 ,-24575 ,-24575 ,-23039 , -23039 ,-20735 ,-20735 ,-18431 ,-18431 ,-15360 ,-15360 ,-12288 ,-12288 ,-9216 ,-9216 ,-5888 ,-5888 ,-3840 ,-3840 , -1280 ,-1280 ,0 ,0 ,1024 ,1024 ,1024 ,1024 ,256 ,256 ,-1024 ,-1024 ,-2816 ,-2816 ,-5120 , -5120 ,-7680 ,-7680 ,-10496 ,-10496 ,-12800 ,-12800 ,-15360 ,-15360 ,-17663 ,-17663 ,-18687 ,-18687 ,-19711 ,-19711 , -19967 ,-19967 ,-18943 ,-18943 ,-17407 ,-17407 ,-15104 ,-15104 ,-12288 ,-12288 ,-8960 ,-8960 ,-4864 ,-4864 ,-768 , -768 ,512 ,512 ,4608 ,4608 ,8960 ,8960 ,12288 ,12288 ,15104 ,15104 ,17407 ,17407 ,18943 ,18943 , 19711 ,19711 ,19199 ,19199 ,18175 ,18175 ,16895 ,16895 ,14336 ,14336 ,11520 ,11520 ,9216 ,9216 ,6144 , 6144 ,3584 ,3584 ,1280 ,1280 ,-512 ,-512 ,-1536 ,-1536 ,-2048 ,-2048 ,-1792 ,-1792 ,-256 ,-256 , 1280 ,1280 ,4352 ,4352 ,6912 ,6912 ,10496 ,10496 ,13824 ,13824 ,17151 ,17151 ,20479 ,20479 ,22783 , 22783 ,25087 ,25087 ,26367 ,26367 ,27391 ,27391 ,26879 ,26879 ,25855 ,25855 ,24575 ,24575 ,22271 ,22271 , 19199 ,19199 ,16384 ,16384 ,12800 ,12800 ,9984 ,9984 ,6656 ,6656 ,4352 ,4352 ,2048 ,2048 ,512 , 512 ,-512 ,-512 ,-512 ,-512 ,256 ,256 ,1024 ,1024 ,2816 ,2816 ,5120 ,5120 ,7168 ,7168 , 9216 ,9216 ,11264 ,11264 ,13056 ,13056 ,14336 ,14336 ,15104 ,15104 ,15360 ,15360 ,14592 ,14592 ,13312 , 13312 ,11520 ,11520 ,9216 ,9216 ,6144 ,6144 ,2816 ,2816 ,-3072 ,-3072 ,-6400 ,-6400 ,-9472 ,-9472 , -11776 ,-11776 ,-13568 ,-13568 ,-14848 ,-14848 ,-15616 ,-15616 ,-15360 ,-15360 ,-14592 ,-14592 ,-13312 ,-13312 ,-11520 , -11520 ,-9472 ,-9472 ,-7424 ,-7424 ,-5376 ,-5376 ,-3072 ,-3072 ,-1280 ,-1280 ,-512 ,-512 ,256 ,256 , 256 ,256 ,-768 ,-768 ,-2304 ,-2304 ,-4608 ,-4608 ,-6912 ,-6912 ,-10240 ,-10240 ,-13056 ,-13056 ,-16639 , -16639 ,-19455 ,-19455 ,-22527 ,-22527 ,-24831 ,-24831 ,-26111 ,-26111 ,-27135 ,-27135 ,-27647 ,-27647 ,-26623 ,-26623 , -25343 ,-25343 ,-23039 ,-23039 ,-20735 ,-20735 ,-17407 ,-17407 ,-14080 ,-14080 ,-10752 ,-10752 ,-7168 ,-7168 ,-4608 , -4608 ,-1536 ,-1536 ,0 ,0 ,1536 ,1536 ,1792 ,1792 ,1280 ,1280 ,256 ,256 ,-1536 ,-1536 , -3840 ,-3840 ,-6400 ,-6400 ,-9472 ,-9472 ,-11776 ,-11776 ,-14592 ,-14592 ,-17151 ,-17151 ,-18431 ,-18431 ,-19455 , -19455 ,-19967 ,-19967 ,-19199 ,-19199 ,-17663 ,-17663 ,-15360 ,-15360 ,-12544 ,-12544 ,-9216 ,-9216 ,-4864 ,-4864 , -768 ,-768 ,512 ,512 ,4864 ,4864 ,9216 ,9216 ,12544 ,12544 ,15360 ,15360 ,17663 ,17663 ,19199 , 19199 ,19711 ,19711 ,19199 ,19199 ,17919 ,17919 ,16384 ,16384 ,13568 ,13568 ,10752 ,10752 ,8192 ,8192 , 5120 ,5120 ,2304 ,2304 ,0 ,0 ,-1536 ,-1536 ,-2560 ,-2560 ,-2816 ,-2816 ,-2048 ,-2048 ,-256 , -256 ,1792 ,1792 ,5120 ,5120 ,8192 ,8192 ,12032 ,12032 ,15872 ,15872 ,19455 ,19455 ,22783 ,22783 , 25343 ,25343 ,27391 ,27391 ,28671 ,28671 ,29183 ,29183 ,28415 ,28415 ,26879 ,26879 ,24831 ,24831 ,22015 , 22015 ,18431 ,18431 ,14848 ,14848 ,10752 ,10752 ,7680 ,7680 ,3840 ,3840 ,1280 ,1280 ,-1024 ,-1024 , -2560 ,-2560 ,-3328 ,-3328 ,-2816 ,-2816 ,-1536 ,-1536 ,0 ,0 ,2304 ,2304 ,5376 ,5376 ,8192 , 8192 ,11008 ,11008 ,13824 ,13824 ,16128 ,16128 ,17663 ,17663 ,18687 ,18687 ,18943 ,18943 ,18175 ,18175 , 16639 ,16639 ,14336 ,14336 ,11520 ,11520 ,7680 ,7680 ,3584 ,3584 ,-3840 ,-3840 ,-7936 ,-7936 ,-11776 , -11776 ,-14592 ,-14592 ,-16895 ,-16895 ,-18431 ,-18431 ,-19199 ,-19199 ,-18943 ,-18943 ,-17919 ,-17919 ,-16384 ,-16384 , -14080 ,-14080 ,-11264 ,-11264 ,-8448 ,-8448 ,-5632 ,-5632 ,-2560 ,-2560 ,-256 ,-256 ,1280 ,1280 ,2560 , 2560 ,3072 ,3072 ,2304 ,2304 ,768 ,768 ,-1536 ,-1536 ,-4096 ,-4096 ,-7936 ,-7936 ,-11008 ,-11008 , -15104 ,-15104 ,-18687 ,-18687 ,-22271 ,-22271 ,-25087 ,-25087 ,-27135 ,-27135 ,-28671 ,-28671 ,-29439 ,-29439 ,-28927 , -28927 ,-27647 ,-27647 ,-25599 ,-25599 ,-23039 ,-23039 ,-19711 ,-19711 ,-16128 ,-16128 ,-12288 ,-12288 ,-8448 ,-8448 , -5376 ,-5376 ,-2048 ,-2048 ,0 ,0 ,1792 ,1792 ,2560 ,2560 ,2304 ,2304 ,1280 ,1280 ,-256 , -256 ,-2560 ,-2560 ,-5376 ,-5376 ,-8448 ,-8448 ,-11008 ,-11008 ,-13824 ,-13824 ,-16639 ,-16639 ,-18175 ,-18175 , -19455 ,-19455 ,-19967 ,-19967 ,-19455 ,-19455 ,-17919 ,-17919 ,-15616 ,-15616 ,-12800 ,-12800 ,-9472 ,-9472 ,-5120 , -5120 ,-768 ,-768 ,512 ,512 ,4864 ,4864 ,9216 ,9216 ,12544 ,12544 ,15360 ,15360 ,17663 ,17663 , 18943 ,18943 ,19455 ,19455 ,18687 ,18687 ,17151 ,17151 ,15360 ,15360 ,12544 ,12544 ,9728 ,9728 ,6912 , 6912 ,4096 ,4096 ,1536 ,1536 ,-512 ,-512 ,-1792 ,-1792 ,-2304 ,-2304 ,-2304 ,-2304 ,-1024 ,-1024 , 1024 ,1024 ,3584 ,3584 ,6912 ,6912 ,9984 ,9984 ,13824 ,13824 ,17407 ,17407 ,20479 ,20479 ,23295 , 23295 ,25343 ,25343 ,26623 ,26623 ,27391 ,27391 ,27135 ,27135 ,26111 ,26111 ,24063 ,24063 ,22015 ,22015 , 19199 ,19199 ,15872 ,15872 ,12800 ,12800 ,9472 ,9472 ,6912 ,6912 ,4096 ,4096 ,2304 ,2304 ,768 , 768 ,-256 ,-256 ,-512 ,-512 ,256 ,256 ,1536 ,1536 ,3072 ,3072 ,4864 ,4864 ,7168 ,7168 , 9216 ,9216 ,11264 ,11264 ,13056 ,13056 ,14336 ,14336 ,15104 ,15104 ,15616 ,15616 ,15360 ,15360 ,14592 , 14592 ,13056 ,13056 ,11008 ,11008 ,8960 ,8960 ,5632 ,5632 ,2560 ,2560 ,-2816 ,-2816 ,-5888 ,-5888 , -9216 ,-9216 ,-11264 ,-11264 ,-13312 ,-13312 ,-14848 ,-14848 ,-15616 ,-15616 ,-15872 ,-15872 ,-15360 ,-15360 ,-14592 , -14592 ,-13312 ,-13312 ,-11520 ,-11520 ,-9472 ,-9472 ,-7424 ,-7424 ,-5120 ,-5120 ,-3328 ,-3328 ,-1792 ,-1792 , -512 ,-512 ,256 ,256 ,0 ,0 ,-1024 ,-1024 ,-2560 ,-2560 ,-4352 ,-4352 ,-7168 ,-7168 ,-9728 , -9728 ,-13056 ,-13056 ,-16128 ,-16128 ,-19455 ,-19455 ,-22271 ,-22271 ,-24319 ,-24319 ,-26367 ,-26367 ,-27391 ,-27391 , -27647 ,-27647 ,-26879 ,-26879 ,-25599 ,-25599 ,-23551 ,-23551 ,-20735 ,-20735 ,-17663 ,-17663 ,-14080 ,-14080 ,-10240 , -10240 ,-7168 ,-7168 ,-3840 ,-3840 ,-1280 ,-1280 ,768 ,768 ,2048 ,2048 ,2048 ,2048 ,1536 ,1536 , 256 ,256 ,-1792 ,-1792 ,-4352 ,-4352 ,-7168 ,-7168 ,-9984 ,-9984 ,-12800 ,-12800 ,-15616 ,-15616 ,-17407 , -17407 ,-18943 ,-18943 ,-19711 ,-19711 ,-19199 ,-19199 ,-17919 ,-17919 ,-15616 ,-15616 ,-12800 ,-12800 ,-9472 ,-9472 , -5120 ,-5120 ,-768 ,-768 ,512 ,512 ,4864 ,4864 ,9472 ,9472 ,12800 ,12800 ,15616 ,15616 ,17663 , 17663 ,18943 ,18943 ,19199 ,19199 ,18175 ,18175 ,16639 ,16639 ,14592 ,14592 ,11520 ,11520 ,8704 ,8704 , 5888 ,5888 ,3072 ,3072 ,768 ,768 ,-1024 ,-1024 ,-2048 ,-2048 ,-2048 ,-2048 ,-1536 ,-1536 ,0 , 0 ,2560 ,2560 ,5376 ,5376 ,8960 ,8960 ,12032 ,12032 ,15616 ,15616 ,18943 ,18943 ,21503 ,21503 , 23807 ,23807 ,25343 ,25343 ,26111 ,26111 ,26111 ,26111 ,25343 ,25343 ,23807 ,23807 ,21503 ,21503 ,19199 , 19199 ,16639 ,16639 ,13568 ,13568 ,11008 ,11008 ,8192 ,8192 ,6400 ,6400 ,4352 ,4352 ,3328 ,3328 , 2560 ,2560 ,2304 ,2304 ,2560 ,2560 ,3584 ,3584 ,4864 ,4864 ,6144 ,6144 ,7424 ,7424 ,9216 , 9216 ,10496 ,10496 ,11520 ,11520 ,12288 ,12288 ,12800 ,12800 ,12800 ,12800 ,12544 ,12544 ,12032 ,12032 , 11008 ,11008 ,9728 ,9728 ,7936 ,7936 ,6400 ,6400 ,3840 ,3840 ,1792 ,1792 ,-2048 ,-2048 ,-4096 , -4096 ,-6656 ,-6656 ,-8192 ,-8192 ,-9984 ,-9984 ,-11264 ,-11264 ,-12288 ,-12288 ,-12800 ,-12800 ,-13056 ,-13056 , -13056 ,-13056 ,-12544 ,-12544 ,-11776 ,-11776 ,-10752 ,-10752 ,-9472 ,-9472 ,-7680 ,-7680 ,-6400 ,-6400 ,-5120 , -5120 ,-3840 ,-3840 ,-2816 ,-2816 ,-2560 ,-2560 ,-2816 ,-2816 ,-3584 ,-3584 ,-4608 ,-4608 ,-6656 ,-6656 , -8448 ,-8448 ,-11264 ,-11264 ,-13824 ,-13824 ,-16895 ,-16895 ,-19455 ,-19455 ,-21759 ,-21759 ,-24063 ,-24063 ,-25599 , -25599 ,-26367 ,-26367 ,-26367 ,-26367 ,-25599 ,-25599 ,-24063 ,-24063 ,-21759 ,-21759 ,-19199 ,-19199 ,-15872 ,-15872 , -12288 ,-12288 ,-9216 ,-9216 ,-5632 ,-5632 ,-2816 ,-2816 ,-256 ,-256 ,1280 ,1280 ,1792 ,1792 ,1792 , 1792 ,768 ,768 ,-1024 ,-1024 ,-3328 ,-3328 ,-6144 ,-6144 ,-8960 ,-8960 ,-11776 ,-11776 ,-14848 ,-14848 , -16895 ,-16895 ,-18431 ,-18431 ,-19455 ,-19455 ,-19199 ,-19199 ,-17919 ,-17919 ,-15872 ,-15872 ,-13056 ,-13056 ,-9728 , -9728 ,-5120 ,-5120 ,-768 ,-768 ,512 ,512 ,4864 ,4864 ,9472 ,9472 ,12800 ,12800 ,15616 ,15616 , 17663 ,17663 ,18943 ,18943 ,18943 ,18943 ,17663 ,17663 ,15872 ,15872 ,13824 ,13824 ,10496 ,10496 ,7680 , 7680 ,4864 ,4864 ,2048 ,2048 ,0 ,0 ,-1536 ,-1536 ,-2304 ,-2304 ,-1792 ,-1792 ,-768 ,-768 , 1024 ,1024 ,4096 ,4096 ,7168 ,7168 ,10752 ,10752 ,14080 ,14080 ,17407 ,17407 ,20479 ,20479 ,22527 , 22527 ,24319 ,24319 ,25343 ,25343 ,25343 ,25343 ,24831 ,24831 ,23551 ,23551 ,21503 ,21503 ,18943 ,18943 , 16384 ,16384 ,13824 ,13824 ,11008 ,11008 ,8960 ,8960 ,6912 ,6912 ,5888 ,5888 ,4608 ,4608 ,4352 , 4352 ,4352 ,4352 ,4864 ,4864 ,5632 ,5632 ,6912 ,6912 ,7936 ,7936 ,9216 ,9216 ,9984 ,9984 , 11008 ,11008 ,11520 ,11520 ,11776 ,11776 ,11520 ,11520 ,11264 ,11264 ,10240 ,10240 ,9472 ,9472 ,8704 , 8704 ,7424 ,7424 ,6144 ,6144 ,4864 ,4864 ,3840 ,3840 ,2048 ,2048 ,768 ,768 ,-1024 ,-1024 , -2304 ,-2304 ,-4096 ,-4096 ,-5120 ,-5120 ,-6400 ,-6400 ,-7680 ,-7680 ,-8960 ,-8960 ,-9728 ,-9728 ,-10496 , -10496 ,-11520 ,-11520 ,-11776 ,-11776 ,-12032 ,-12032 ,-11776 ,-11776 ,-11264 ,-11264 ,-10240 ,-10240 ,-9472 ,-9472 , -8192 ,-8192 ,-7168 ,-7168 ,-5888 ,-5888 ,-5120 ,-5120 ,-4608 ,-4608 ,-4608 ,-4608 ,-4864 ,-4864 ,-6144 , -6144 ,-7168 ,-7168 ,-9216 ,-9216 ,-11264 ,-11264 ,-14080 ,-14080 ,-16639 ,-16639 ,-19199 ,-19199 ,-21759 ,-21759 , -23807 ,-23807 ,-25087 ,-25087 ,-25599 ,-25599 ,-25599 ,-25599 ,-24575 ,-24575 ,-22783 ,-22783 ,-20735 ,-20735 ,-17663 , -17663 ,-14336 ,-14336 ,-11008 ,-11008 ,-7424 ,-7424 ,-4352 ,-4352 ,-1280 ,-1280 ,512 ,512 ,1536 ,1536 , 2048 ,2048 ,1280 ,1280 ,-256 ,-256 ,-2304 ,-2304 ,-5120 ,-5120 ,-7936 ,-7936 ,-10752 ,-10752 ,-14080 , -14080 ,-16128 ,-16128 ,-17919 ,-17919 ,-19199 ,-19199 ,-19199 ,-19199 ,-17919 ,-17919 ,-15872 ,-15872 ,-13056 ,-13056 , -9728 ,-9728 ,-5120 ,-5120 ,-768 ,-768 ,512 ,512 ,5120 ,5120 ,9728 ,9728 ,13056 ,13056 ,15872 , 15872 ,17919 ,17919 ,18943 ,18943 ,18687 ,18687 ,17407 ,17407 ,15360 ,15360 ,13056 ,13056 ,9728 ,9728 , 6656 ,6656 ,3840 ,3840 ,1280 ,1280 ,-768 ,-768 ,-2048 ,-2048 ,-2304 ,-2304 ,-1536 ,-1536 ,0 , 0 ,2304 ,2304 ,5632 ,5632 ,8960 ,8960 ,12800 ,12800 ,16128 ,16128 ,19199 ,19199 ,22015 ,22015 , 23807 ,23807 ,25087 ,25087 ,25343 ,25343 ,24831 ,24831 ,23551 ,23551 ,21759 ,21759 ,19199 ,19199 ,16384 , 16384 ,13824 ,13824 ,11264 ,11264 ,8704 ,8704 ,7168 ,7168 ,5632 ,5632 ,5376 ,5376 ,5120 ,5120 , 5632 ,5632 ,6400 ,6400 ,7424 ,7424 ,8704 ,8704 ,10240 ,10240 ,11264 ,11264 ,12288 ,12288 ,12800 , 12800 ,13056 ,13056 ,12800 ,12800 ,12032 ,12032 ,11008 ,11008 ,9728 ,9728 ,7936 ,7936 ,6656 ,6656 , 5376 ,5376 ,3840 ,3840 ,2816 ,2816 ,1792 ,1792 ,1280 ,1280 ,256 ,256 ,0 ,0 ,-256 , -256 ,-512 ,-512 ,-1536 ,-1536 ,-2048 ,-2048 ,-3072 ,-3072 ,-4096 ,-4096 ,-5632 ,-5632 ,-6912 ,-6912 , -8192 ,-8192 ,-9984 ,-9984 ,-11264 ,-11264 ,-12288 ,-12288 ,-13056 ,-13056 ,-13312 ,-13312 ,-13056 ,-13056 ,-12544 , -12544 ,-11520 ,-11520 ,-10496 ,-10496 ,-8960 ,-8960 ,-7680 ,-7680 ,-6656 ,-6656 ,-5888 ,-5888 ,-5376 ,-5376 , -5632 ,-5632 ,-5888 ,-5888 ,-7424 ,-7424 ,-8960 ,-8960 ,-11520 ,-11520 ,-14080 ,-14080 ,-16639 ,-16639 ,-19455 , -19455 ,-22015 ,-22015 ,-23807 ,-23807 ,-25087 ,-25087 ,-25599 ,-25599 ,-25343 ,-25343 ,-24063 ,-24063 ,-22271 ,-22271 , -19455 ,-19455 ,-16384 ,-16384 ,-13056 ,-13056 ,-9216 ,-9216 ,-5888 ,-5888 ,-2560 ,-2560 ,-256 ,-256 ,1280 , 1280 ,2048 ,2048 ,1792 ,1792 ,512 ,512 ,-1536 ,-1536 ,-4096 ,-4096 ,-6912 ,-6912 ,-9984 ,-9984 , -13312 ,-13312 ,-15616 ,-15616 ,-17663 ,-17663 ,-18943 ,-18943 ,-19199 ,-19199 ,-18175 ,-18175 ,-16128 ,-16128 ,-13312 , -13312 ,-9984 ,-9984 ,-5376 ,-5376 ,-768 ,-768 ,512 ,512 ,5120 ,5120 ,9728 ,9728 ,13056 ,13056 , 15872 ,15872 ,17919 ,17919 ,18687 ,18687 ,18431 ,18431 ,16895 ,16895 ,14592 ,14592 ,12032 ,12032 ,8704 , 8704 ,5632 ,5632 ,2560 ,2560 ,256 ,256 ,-1536 ,-1536 ,-2560 ,-2560 ,-2560 ,-2560 ,-1280 ,-1280 , 512 ,512 ,3328 ,3328 ,6912 ,6912 ,10752 ,10752 ,14592 ,14592 ,17919 ,17919 ,20991 ,20991 ,23551 , 23551 ,24831 ,24831 ,25599 ,25599 ,25343 ,25343 ,24063 ,24063 ,22271 ,22271 ,19711 ,19711 ,16895 ,16895 , 13824 ,13824 ,11008 ,11008 ,8448 ,8448 ,6144 ,6144 ,5120 ,5120 ,4352 ,4352 ,4864 ,4864 ,5376 , 5376 ,6656 ,6656 ,8192 ,8192 ,9984 ,9984 ,11776 ,11776 ,13312 ,13312 ,14336 ,14336 ,15360 ,15360 , 15360 ,15360 ,14848 ,14848 ,13824 ,13824 ,12288 ,12288 ,10240 ,10240 ,7936 ,7936 ,5376 ,5376 ,3584 , 3584 ,1792 ,1792 ,256 ,256 ,-768 ,-768 ,-1280 ,-1280 ,-1280 ,-1280 ,-1536 ,-1536 ,-1024 ,-1024 , 768 ,768 ,1280 ,1280 ,1024 ,1024 ,1024 ,1024 ,512 ,512 ,-512 ,-512 ,-2048 ,-2048 ,-3840 , -3840 ,-5632 ,-5632 ,-8192 ,-8192 ,-10496 ,-10496 ,-12544 ,-12544 ,-14080 ,-14080 ,-15104 ,-15104 ,-15616 ,-15616 , -15616 ,-15616 ,-14592 ,-14592 ,-13568 ,-13568 ,-12032 ,-12032 ,-10240 ,-10240 ,-8448 ,-8448 ,-6912 ,-6912 ,-5632 , -5632 ,-5120 ,-5120 ,-4608 ,-4608 ,-5376 ,-5376 ,-6400 ,-6400 ,-8704 ,-8704 ,-11264 ,-11264 ,-14080 ,-14080 , -17151 ,-17151 ,-19967 ,-19967 ,-22527 ,-22527 ,-24319 ,-24319 ,-25599 ,-25599 ,-25855 ,-25855 ,-25087 ,-25087 ,-23807 , -23807 ,-21247 ,-21247 ,-18175 ,-18175 ,-14848 ,-14848 ,-11008 ,-11008 ,-7168 ,-7168 ,-3584 ,-3584 ,-768 ,-768 , 1024 ,1024 ,2304 ,2304 ,2304 ,2304 ,1280 ,1280 ,-512 ,-512 ,-2816 ,-2816 ,-5888 ,-5888 ,-8960 , -8960 ,-12288 ,-12288 ,-14848 ,-14848 ,-17151 ,-17151 ,-18687 ,-18687 ,-18943 ,-18943 ,-18175 ,-18175 ,-16128 ,-16128 , -13312 ,-13312 ,-9984 ,-9984 ,-5376 ,-5376 ,-768 ,-768 ,512 ,512 ,5376 ,5376 ,9984 ,9984 ,13312 , 13312 ,16128 ,16128 ,18175 ,18175 ,18687 ,18687 ,18175 ,18175 ,16639 ,16639 ,14080 ,14080 ,11264 ,11264 , 7936 ,7936 ,4608 ,4608 ,1536 ,1536 ,-768 ,-768 ,-2304 ,-2304 ,-3072 ,-3072 ,-2560 ,-2560 ,-1024 , -1024 ,1280 ,1280 ,4608 ,4608 ,8448 ,8448 ,12544 ,12544 ,16639 ,16639 ,19967 ,19967 ,22783 ,22783 , 25087 ,25087 ,26111 ,26111 ,26367 ,26367 ,25343 ,25343 ,23551 ,23551 ,20991 ,20991 ,17919 ,17919 ,14592 , 14592 ,11264 ,11264 ,8448 ,8448 ,5888 ,5888 ,3840 ,3840 ,3328 ,3328 ,3072 ,3072 ,4352 ,4352 , 5632 ,5632 ,7680 ,7680 ,10240 ,10240 ,12544 ,12544 ,14848 ,14848 ,16639 ,16639 ,17663 ,17663 ,18431 , 18431 ,18175 ,18175 ,16895 ,16895 ,15104 ,15104 ,12544 ,12544 ,9472 ,9472 ,6400 ,6400 ,3072 ,3072 , 512 ,512 ,-1536 ,-1536 ,-3328 ,-3328 ,-4096 ,-4096 ,-4352 ,-4352 ,-3840 ,-3840 ,-3328 ,-3328 ,-1792 , -1792 ,1536 ,1536 ,3072 ,3072 ,3584 ,3584 ,4096 ,4096 ,3840 ,3840 ,3072 ,3072 ,1280 ,1280 , -768 ,-768 ,-3328 ,-3328 ,-6656 ,-6656 ,-9728 ,-9728 ,-12800 ,-12800 ,-15360 ,-15360 ,-17151 ,-17151 ,-18431 , -18431 ,-18687 ,-18687 ,-17919 ,-17919 ,-16895 ,-16895 ,-15104 ,-15104 ,-12800 ,-12800 ,-10496 ,-10496 ,-7936 ,-7936 , -5888 ,-5888 ,-4608 ,-4608 ,-3328 ,-3328 ,-3584 ,-3584 ,-4096 ,-4096 ,-6144 ,-6144 ,-8704 ,-8704 ,-11520 , -11520 ,-14848 ,-14848 ,-18175 ,-18175 ,-21247 ,-21247 ,-23807 ,-23807 ,-25599 ,-25599 ,-26623 ,-26623 ,-26367 ,-26367 , -25343 ,-25343 ,-23039 ,-23039 ,-20223 ,-20223 ,-16895 ,-16895 ,-12800 ,-12800 ,-8704 ,-8704 ,-4864 ,-4864 ,-1536 , -1536 ,768 ,768 ,2304 ,2304 ,2816 ,2816 ,2048 ,2048 ,512 ,512 ,-1792 ,-1792 ,-4864 ,-4864 , -8192 ,-8192 ,-11520 ,-11520 ,-14336 ,-14336 ,-16895 ,-16895 ,-18431 ,-18431 ,-18943 ,-18943 ,-18431 ,-18431 ,-16384 , -16384 ,-13568 ,-13568 ,-10240 ,-10240 ,-5632 ,-5632 ,-768 ,-768 ,512 ,512 ,5376 ,5376 ,9984 ,9984 , 13568 ,13568 ,16384 ,16384 ,18175 ,18175 ,18687 ,18687 ,17919 ,17919 ,16128 ,16128 ,13568 ,13568 ,10496 , 10496 ,6912 ,6912 ,3584 ,3584 ,512 ,512 ,-1792 ,-1792 ,-3072 ,-3072 ,-3584 ,-3584 ,-2816 ,-2816 , -768 ,-768 ,2048 ,2048 ,5632 ,5632 ,9984 ,9984 ,14336 ,14336 ,18687 ,18687 ,22015 ,22015 ,24575 , 24575 ,26623 ,26623 ,27135 ,27135 ,26879 ,26879 ,25343 ,25343 ,23039 ,23039 ,19711 ,19711 ,16128 ,16128 , 12288 ,12288 ,8704 ,8704 ,5632 ,5632 ,3328 ,3328 ,1536 ,1536 ,1536 ,1536 ,1792 ,1792 ,3840 , 3840 ,5888 ,5888 ,8704 ,8704 ,12032 ,12032 ,15104 ,15104 ,17919 ,17919 ,19967 ,19967 ,20991 ,20991 , 21503 ,21503 ,20735 ,20735 ,18943 ,18943 ,16128 ,16128 ,12800 ,12800 ,8704 ,8704 ,4864 ,4864 ,768 , 768 ,-2560 ,-2560 ,-4864 ,-4864 ,-6912 ,-6912 ,-7680 ,-7680 ,-7424 ,-7424 ,-6400 ,-6400 ,-5120 ,-5120 , -2816 ,-2816 ,2560 ,2560 ,4864 ,4864 ,6144 ,6144 ,7168 ,7168 ,7424 ,7424 ,6656 ,6656 ,4608 , 4608 ,2304 ,2304 ,-1024 ,-1024 ,-5120 ,-5120 ,-8960 ,-8960 ,-13056 ,-13056 ,-16384 ,-16384 ,-19199 ,-19199 , -20991 ,-20991 ,-21759 ,-21759 ,-21247 ,-21247 ,-20223 ,-20223 ,-18175 ,-18175 ,-15360 ,-15360 ,-12288 ,-12288 ,-8960 , -8960 ,-6144 ,-6144 ,-4096 ,-4096 ,-2048 ,-2048 ,-1792 ,-1792 ,-1792 ,-1792 ,-3584 ,-3584 ,-5888 ,-5888 , -8960 ,-8960 ,-12544 ,-12544 ,-16384 ,-16384 ,-19967 ,-19967 ,-23295 ,-23295 ,-25599 ,-25599 ,-27135 ,-27135 ,-27391 , -27391 ,-26879 ,-26879 ,-24831 ,-24831 ,-22271 ,-22271 ,-18943 ,-18943 ,-14592 ,-14592 ,-10240 ,-10240 ,-5888 ,-5888 , -2304 ,-2304 ,512 ,512 ,2560 ,2560 ,3328 ,3328 ,2816 ,2816 ,1536 ,1536 ,-768 ,-768 ,-3840 , -3840 ,-7168 ,-7168 ,-10752 ,-10752 ,-13824 ,-13824 ,-16384 ,-16384 ,-18175 ,-18175 ,-18943 ,-18943 ,-18431 ,-18431 , -16639 ,-16639 ,-13824 ,-13824 ,-10240 ,-10240 ,-5632 ,-5632 ,-768 ,-768 ,512 ,512 ,5632 ,5632 ,10240 , 10240 ,13824 ,13824 ,16639 ,16639 ,18431 ,18431 ,18687 ,18687 ,17919 ,17919 ,15872 ,15872 ,13056 ,13056 , 9728 ,9728 ,6144 ,6144 ,2560 ,2560 ,-512 ,-512 ,-2560 ,-2560 ,-3840 ,-3840 ,-4096 ,-4096 ,-2816 , -2816 ,-512 ,-512 ,2816 ,2816 ,6912 ,6912 ,11520 ,11520 ,16128 ,16128 ,20735 ,20735 ,24063 ,24063 , 26623 ,26623 ,28159 ,28159 ,28415 ,28415 ,27647 ,27647 ,25343 ,25343 ,22527 ,22527 ,18431 ,18431 ,14336 , 14336 ,9984 ,9984 ,6144 ,6144 ,3072 ,3072 ,768 ,768 ,-768 ,-768 ,-256 ,-256 ,768 ,768 , 3328 ,3328 ,6400 ,6400 ,9984 ,9984 ,14080 ,14080 ,17663 ,17663 ,20991 ,20991 ,23295 ,23295 ,24319 , 24319 ,24575 ,24575 ,23551 ,23551 ,20991 ,20991 ,17407 ,17407 ,13056 ,13056 ,8192 ,8192 ,3328 ,3328 , -1536 ,-1536 ,-5376 ,-5376 ,-8192 ,-8192 ,-10496 ,-10496 ,-11008 ,-11008 ,-10496 ,-10496 ,-8960 ,-8960 ,-6912 , -6912 ,-3584 ,-3584 ,3328 ,3328 ,6656 ,6656 ,8704 ,8704 ,10240 ,10240 ,10752 ,10752 ,10240 ,10240 , 7936 ,7936 ,5120 ,5120 ,1280 ,1280 ,-3584 ,-3584 ,-8448 ,-8448 ,-13312 ,-13312 ,-17663 ,-17663 ,-21247 , -21247 ,-23807 ,-23807 ,-24831 ,-24831 ,-24575 ,-24575 ,-23551 ,-23551 ,-21247 ,-21247 ,-17919 ,-17919 ,-14336 ,-14336 , -10240 ,-10240 ,-6656 ,-6656 ,-3584 ,-3584 ,-1024 ,-1024 ,0 ,0 ,512 ,512 ,-1024 ,-1024 ,-3328 , -3328 ,-6400 ,-6400 ,-10240 ,-10240 ,-14592 ,-14592 ,-18687 ,-18687 ,-22783 ,-22783 ,-25599 ,-25599 ,-27903 ,-27903 , -28671 ,-28671 ,-28415 ,-28415 ,-26879 ,-26879 ,-24319 ,-24319 ,-20991 ,-20991 ,-16384 ,-16384 ,-11776 ,-11776 ,-7168 , -7168 ,-3072 ,-3072 ,256 ,256 ,2560 ,2560 ,3840 ,3840 ,3584 ,3584 ,2304 ,2304 ,256 ,256 , -2816 ,-2816 ,-6400 ,-6400 ,-9984 ,-9984 ,-13312 ,-13312 ,-16128 ,-16128 ,-18175 ,-18175 ,-18943 ,-18943 ,-18687 , -18687 ,-16895 ,-16895 ,-14080 ,-14080 ,-10496 ,-10496 ,-5888 ,-5888 ,-768 ,-768 ,512 ,512 ,5632 ,5632 , 10496 ,10496 ,14080 ,14080 ,17151 ,17151 ,18687 ,18687 ,18687 ,18687 ,17663 ,17663 ,15104 ,15104 ,12032 , 12032 ,8704 ,8704 ,4864 ,4864 ,1280 ,1280 ,-1536 ,-1536 ,-3072 ,-3072 ,-3840 ,-3840 ,-3584 ,-3584 , -1792 ,-1792 ,768 ,768 ,4352 ,4352 ,8704 ,8704 ,13056 ,13056 ,17407 ,17407 ,21503 ,21503 ,24319 , 24319 ,26367 ,26367 ,27135 ,27135 ,26879 ,26879 ,25343 ,25343 ,22783 ,22783 ,19967 ,19967 ,16128 ,16128 , 12544 ,12544 ,8704 ,8704 ,5632 ,5632 ,3584 ,3584 ,2048 ,2048 ,1280 ,1280 ,2304 ,2304 ,3584 , 3584 ,6144 ,6144 ,8960 ,8960 ,11776 ,11776 ,15104 ,15104 ,17663 ,17663 ,19967 ,19967 ,21247 ,21247 , 21759 ,21759 ,21503 ,21503 ,20223 ,20223 ,17663 ,17663 ,14592 ,14592 ,11008 ,11008 ,7168 ,7168 ,3328 , 3328 ,-512 ,-512 ,-3584 ,-3584 ,-5632 ,-5632 ,-7424 ,-7424 ,-7936 ,-7936 ,-7680 ,-7680 ,-6400 ,-6400 , -5120 ,-5120 ,-2816 ,-2816 ,2560 ,2560 ,4864 ,4864 ,6144 ,6144 ,7424 ,7424 ,7680 ,7680 ,7168 , 7168 ,5376 ,5376 ,3328 ,3328 ,256 ,256 ,-3584 ,-3584 ,-7424 ,-7424 ,-11264 ,-11264 ,-14848 ,-14848 , -17919 ,-17919 ,-20479 ,-20479 ,-21759 ,-21759 ,-22015 ,-22015 ,-21503 ,-21503 ,-20223 ,-20223 ,-17919 ,-17919 ,-15360 , -15360 ,-12032 ,-12032 ,-9216 ,-9216 ,-6400 ,-6400 ,-3840 ,-3840 ,-2560 ,-2560 ,-1536 ,-1536 ,-2304 ,-2304 , -3840 ,-3840 ,-5888 ,-5888 ,-8960 ,-8960 ,-12800 ,-12800 ,-16384 ,-16384 ,-20223 ,-20223 ,-23039 ,-23039 ,-25599 , -25599 ,-27135 ,-27135 ,-27391 ,-27391 ,-26623 ,-26623 ,-24575 ,-24575 ,-21759 ,-21759 ,-17663 ,-17663 ,-13312 ,-13312 , -8960 ,-8960 ,-4608 ,-4608 ,-1024 ,-1024 ,1536 ,1536 ,3328 ,3328 ,3584 ,3584 ,2816 ,2816 ,1280 , 1280 ,-1536 ,-1536 ,-5120 ,-5120 ,-8960 ,-8960 ,-12288 ,-12288 ,-15360 ,-15360 ,-17919 ,-17919 ,-18943 ,-18943 , -18943 ,-18943 ,-17407 ,-17407 ,-14336 ,-14336 ,-10752 ,-10752 ,-5888 ,-5888 ,-768 ,-768 ,512 ,512 ,5888 , 5888 ,11008 ,11008 ,14592 ,14592 ,17663 ,17663 ,18943 ,18943 ,18687 ,18687 ,17407 ,17407 ,14592 ,14592 , 11264 ,11264 ,7680 ,7680 ,3840 ,3840 ,256 ,256 ,-2304 ,-2304 ,-3584 ,-3584 ,-3840 ,-3840 ,-3072 , -3072 ,-768 ,-768 ,2304 ,2304 ,6144 ,6144 ,10496 ,10496 ,14848 ,14848 ,18943 ,18943 ,22527 ,22527 , 24831 ,24831 ,26111 ,26111 ,26111 ,26111 ,25343 ,25343 ,23295 ,23295 ,20479 ,20479 ,17663 ,17663 ,13824 , 13824 ,10752 ,10752 ,7680 ,7680 ,5376 ,5376 ,4096 ,4096 ,3328 ,3328 ,3328 ,3328 ,5120 ,5120 , 6656 ,6656 ,8960 ,8960 ,11520 ,11520 ,13824 ,13824 ,16128 ,16128 ,17919 ,17919 ,19199 ,19199 ,19455 , 19455 ,19199 ,19199 ,18431 ,18431 ,16895 ,16895 ,14592 ,14592 ,12032 ,12032 ,9216 ,9216 ,6144 ,6144 , 3328 ,3328 ,512 ,512 ,-1536 ,-1536 ,-2816 ,-2816 ,-4352 ,-4352 ,-4608 ,-4608 ,-4608 ,-4608 ,-3840 , -3840 ,-3328 ,-3328 ,-1792 ,-1792 ,1536 ,1536 ,3072 ,3072 ,3584 ,3584 ,4352 ,4352 ,4352 ,4352 , 4096 ,4096 ,2560 ,2560 ,1280 ,1280 ,-768 ,-768 ,-3584 ,-3584 ,-6400 ,-6400 ,-9472 ,-9472 ,-12288 , -12288 ,-14848 ,-14848 ,-17151 ,-17151 ,-18687 ,-18687 ,-19455 ,-19455 ,-19711 ,-19711 ,-19455 ,-19455 ,-18175 ,-18175 , -16384 ,-16384 ,-14080 ,-14080 ,-11776 ,-11776 ,-9216 ,-9216 ,-6912 ,-6912 ,-5376 ,-5376 ,-3584 ,-3584 ,-3584 , -3584 ,-4352 ,-4352 ,-5632 ,-5632 ,-7936 ,-7936 ,-11008 ,-11008 ,-14080 ,-14080 ,-17919 ,-17919 ,-20735 ,-20735 , -23551 ,-23551 ,-25599 ,-25599 ,-26367 ,-26367 ,-26367 ,-26367 ,-25087 ,-25087 ,-22783 ,-22783 ,-19199 ,-19199 ,-15104 , -15104 ,-10752 ,-10752 ,-6400 ,-6400 ,-2560 ,-2560 ,512 ,512 ,2816 ,2816 ,3584 ,3584 ,3328 ,3328 , 2048 ,2048 ,-512 ,-512 ,-4096 ,-4096 ,-7936 ,-7936 ,-11520 ,-11520 ,-14848 ,-14848 ,-17663 ,-17663 ,-18943 , -18943 ,-19199 ,-19199 ,-17919 ,-17919 ,-14848 ,-14848 ,-11264 ,-11264 ,-6144 ,-6144 ,-768 ,-768 ,512 ,512 , 6144 ,6144 ,11264 ,11264 ,15104 ,15104 ,18175 ,18175 ,19199 ,19199 ,18687 ,18687 ,17151 ,17151 ,14080 , 14080 ,10496 ,10496 ,6656 ,6656 ,2560 ,2560 ,-768 ,-768 ,-3072 ,-3072 ,-4096 ,-4096 ,-3840 ,-3840 , -2560 ,-2560 ,256 ,256 ,3584 ,3584 ,7680 ,7680 ,12288 ,12288 ,16639 ,16639 ,20223 ,20223 ,23551 , 23551 ,25087 ,25087 ,25855 ,25855 ,25087 ,25087 ,23807 ,23807 ,21247 ,21247 ,18175 ,18175 ,15104 ,15104 , 11520 ,11520 ,8960 ,8960 ,6656 ,6656 ,4864 ,4864 ,4608 ,4608 ,4608 ,4608 ,5376 ,5376 ,7680 , 7680 ,9472 ,9472 ,11776 ,11776 ,14080 ,14080 ,15616 ,15616 ,17151 ,17151 ,17919 ,17919 ,18175 ,18175 , 17663 ,17663 ,16639 ,16639 ,15360 ,15360 ,13568 ,13568 ,11520 ,11520 ,9216 ,9216 ,7168 ,7168 ,5120 , 5120 ,3328 ,3328 ,1536 ,1536 ,512 ,512 ,-256 ,-256 ,-1280 ,-1280 ,-1280 ,-1280 ,-1536 ,-1536 , -1280 ,-1280 ,-1536 ,-1536 ,-1024 ,-1024 ,768 ,768 ,1280 ,1280 ,1024 ,1024 ,1280 ,1280 ,1024 , 1024 ,1024 ,1024 ,0 ,0 ,-768 ,-768 ,-1792 ,-1792 ,-3584 ,-3584 ,-5376 ,-5376 ,-7424 ,-7424 , -9472 ,-9472 ,-11776 ,-11776 ,-13824 ,-13824 ,-15616 ,-15616 ,-16895 ,-16895 ,-17919 ,-17919 ,-18431 ,-18431 ,-18175 , -18175 ,-17407 ,-17407 ,-15872 ,-15872 ,-14336 ,-14336 ,-12032 ,-12032 ,-9728 ,-9728 ,-7936 ,-7936 ,-5632 ,-5632 , -4864 ,-4864 ,-4864 ,-4864 ,-5120 ,-5120 ,-6912 ,-6912 ,-9216 ,-9216 ,-11776 ,-11776 ,-15360 ,-15360 ,-18431 , -18431 ,-21503 ,-21503 ,-24063 ,-24063 ,-25343 ,-25343 ,-26111 ,-26111 ,-25343 ,-25343 ,-23807 ,-23807 ,-20479 ,-20479 , -16895 ,-16895 ,-12544 ,-12544 ,-7936 ,-7936 ,-3840 ,-3840 ,-512 ,-512 ,2304 ,2304 ,3584 ,3584 ,3840 , 3840 ,2816 ,2816 ,512 ,512 ,-2816 ,-2816 ,-6912 ,-6912 ,-10752 ,-10752 ,-14336 ,-14336 ,-17407 ,-17407 , -18943 ,-18943 ,-19455 ,-19455 ,-18431 ,-18431 ,-15360 ,-15360 ,-11520 ,-11520 ,-6400 ,-6400 ,-768 ,-768 ,512 , 512 ,6400 ,6400 ,11776 ,11776 ,15616 ,15616 ,18687 ,18687 ,19455 ,19455 ,18943 ,18943 ,16895 ,16895 , 13568 ,13568 ,9728 ,9728 ,5632 ,5632 ,1536 ,1536 ,-1792 ,-1792 ,-3840 ,-3840 ,-4608 ,-4608 ,-3840 , -3840 ,-2048 ,-2048 ,1280 ,1280 ,5120 ,5120 ,9472 ,9472 ,14080 ,14080 ,18431 ,18431 ,21759 ,21759 , 24575 ,24575 ,25599 ,25599 ,25599 ,25599 ,24319 ,24319 ,22271 ,22271 ,19199 ,19199 ,15872 ,15872 ,12800 , 12800 ,9472 ,9472 ,7168 ,7168 ,5632 ,5632 ,4608 ,4608 ,5120 ,5120 ,6144 ,6144 ,7680 ,7680 , 10496 ,10496 ,12544 ,12544 ,14592 ,14592 ,16639 ,16639 ,17663 ,17663 ,18431 ,18431 ,18175 ,18175 ,17407 , 17407 ,15872 ,15872 ,14080 ,14080 ,12288 ,12288 ,10496 ,10496 ,8448 ,8448 ,6656 ,6656 ,5376 ,5376 , 4352 ,4352 ,3584 ,3584 ,2816 ,2816 ,2560 ,2560 ,2560 ,2560 ,2048 ,2048 ,2048 ,2048 ,1536 , 1536 ,1280 ,1280 ,512 ,512 ,0 ,0 ,-256 ,-256 ,-768 ,-768 ,-1536 ,-1536 ,-1792 ,-1792 , -2304 ,-2304 ,-2304 ,-2304 ,-2816 ,-2816 ,-2816 ,-2816 ,-3072 ,-3072 ,-3840 ,-3840 ,-4608 ,-4608 ,-5632 , -5632 ,-6912 ,-6912 ,-8704 ,-8704 ,-10752 ,-10752 ,-12544 ,-12544 ,-14336 ,-14336 ,-16128 ,-16128 ,-17663 ,-17663 , -18431 ,-18431 ,-18687 ,-18687 ,-17919 ,-17919 ,-16895 ,-16895 ,-14848 ,-14848 ,-12800 ,-12800 ,-10752 ,-10752 ,-7936 , -7936 ,-6400 ,-6400 ,-5376 ,-5376 ,-4864 ,-4864 ,-5888 ,-5888 ,-7424 ,-7424 ,-9728 ,-9728 ,-13056 ,-13056 , -16128 ,-16128 ,-19455 ,-19455 ,-22527 ,-22527 ,-24575 ,-24575 ,-25855 ,-25855 ,-25855 ,-25855 ,-24831 ,-24831 ,-22015 , -22015 ,-18687 ,-18687 ,-14336 ,-14336 ,-9728 ,-9728 ,-5376 ,-5376 ,-1536 ,-1536 ,1792 ,1792 ,3584 ,3584 , 4352 ,4352 ,3584 ,3584 ,1536 ,1536 ,-1792 ,-1792 ,-5888 ,-5888 ,-9984 ,-9984 ,-13824 ,-13824 ,-17151 , -17151 ,-19199 ,-19199 ,-19711 ,-19711 ,-18943 ,-18943 ,-15872 ,-15872 ,-12032 ,-12032 ,-6656 ,-6656 ,-768 ,-768 , 512 ,512 ,6656 ,6656 ,12032 ,12032 ,16128 ,16128 ,19199 ,19199 ,19711 ,19711 ,18943 ,18943 ,16639 , 16639 ,13056 ,13056 ,8704 ,8704 ,4608 ,4608 ,256 ,256 ,-3072 ,-3072 ,-4864 ,-4864 ,-5120 ,-5120 , -3840 ,-3840 ,-1536 ,-1536 ,2304 ,2304 ,6400 ,6400 ,11008 ,11008 ,15872 ,15872 ,19967 ,19967 ,23039 , 23039 ,25343 ,25343 ,25855 ,25855 ,25343 ,25343 ,23295 ,23295 ,20735 ,20735 ,17151 ,17151 ,13568 ,13568 , 10240 ,10240 ,7168 ,7168 ,5376 ,5376 ,4352 ,4352 ,4096 ,4096 ,5632 ,5632 ,7424 ,7424 ,9728 , 9728 ,13056 ,13056 ,15360 ,15360 ,17407 ,17407 ,19199 ,19199 ,19455 ,19455 ,19455 ,19455 ,18175 ,18175 , 16384 ,16384 ,14080 ,14080 ,11520 ,11520 ,9216 ,9216 ,7168 ,7168 ,5120 ,5120 ,3840 ,3840 ,3328 , 3328 ,3328 ,3328 ,3584 ,3584 ,3840 ,3840 ,4352 ,4352 ,5120 ,5120 ,5120 ,5120 ,5120 ,5120 , 4608 ,4608 ,3840 ,3840 ,2304 ,2304 ,768 ,768 ,-1024 ,-1024 ,-2560 ,-2560 ,-4096 ,-4096 ,-4864 , -4864 ,-5376 ,-5376 ,-5376 ,-5376 ,-5376 ,-5376 ,-4608 ,-4608 ,-4096 ,-4096 ,-3840 ,-3840 ,-3584 ,-3584 , -3584 ,-3584 ,-4096 ,-4096 ,-5376 ,-5376 ,-7424 ,-7424 ,-9472 ,-9472 ,-11776 ,-11776 ,-14336 ,-14336 ,-16639 , -16639 ,-18431 ,-18431 ,-19711 ,-19711 ,-19711 ,-19711 ,-19455 ,-19455 ,-17663 ,-17663 ,-15616 ,-15616 ,-13312 ,-13312 , -9984 ,-9984 ,-7680 ,-7680 ,-5888 ,-5888 ,-4352 ,-4352 ,-4608 ,-4608 ,-5632 ,-5632 ,-7424 ,-7424 ,-10496 , -10496 ,-13824 ,-13824 ,-17407 ,-17407 ,-20991 ,-20991 ,-23551 ,-23551 ,-25599 ,-25599 ,-26111 ,-26111 ,-25599 ,-25599 , -23295 ,-23295 ,-20223 ,-20223 ,-16128 ,-16128 ,-11264 ,-11264 ,-6656 ,-6656 ,-2560 ,-2560 ,1280 ,1280 ,3584 , 3584 ,4864 ,4864 ,4608 ,4608 ,2816 ,2816 ,-512 ,-512 ,-4864 ,-4864 ,-8960 ,-8960 ,-13312 ,-13312 , -16895 ,-16895 ,-19199 ,-19199 ,-19967 ,-19967 ,-19455 ,-19455 ,-16384 ,-16384 ,-12288 ,-12288 ,-6912 ,-6912 ,-768 , -768 ,512 ,512 ,6912 ,6912 ,12544 ,12544 ,16639 ,16639 ,19711 ,19711 ,19967 ,19967 ,18943 ,18943 , 16384 ,16384 ,12544 ,12544 ,7936 ,7936 ,3584 ,3584 ,-768 ,-768 ,-4096 ,-4096 ,-5632 ,-5632 ,-5632 , -5632 ,-3840 ,-3840 ,-1024 ,-1024 ,3328 ,3328 ,7936 ,7936 ,12800 ,12800 ,17663 ,17663 ,21759 ,21759 , 24575 ,24575 ,26367 ,26367 ,26367 ,26367 ,25087 ,25087 ,22271 ,22271 ,19199 ,19199 ,15104 ,15104 ,11264 , 11264 ,7936 ,7936 ,5120 ,5120 ,3584 ,3584 ,3328 ,3328 ,3840 ,3840 ,6144 ,6144 ,8704 ,8704 , 12032 ,12032 ,15872 ,15872 ,18431 ,18431 ,20223 ,20223 ,21759 ,21759 ,21503 ,21503 ,20479 ,20479 ,18431 , 18431 ,15616 ,15616 ,12288 ,12288 ,8960 ,8960 ,6144 ,6144 ,3840 ,3840 ,2048 ,2048 ,1280 ,1280 , 1536 ,1536 ,2560 ,2560 ,3840 ,3840 ,5120 ,5120 ,6400 ,6400 ,7936 ,7936 ,8192 ,8192 ,8448 , 8448 ,7680 ,7680 ,6400 ,6400 ,4352 ,4352 ,1792 ,1792 ,-2048 ,-2048 ,-4608 ,-4608 ,-6656 ,-6656 , -7936 ,-7936 ,-8704 ,-8704 ,-8448 ,-8448 ,-8192 ,-8192 ,-6656 ,-6656 ,-5376 ,-5376 ,-4096 ,-4096 ,-2816 , -2816 ,-1792 ,-1792 ,-1536 ,-1536 ,-2304 ,-2304 ,-4096 ,-4096 ,-6400 ,-6400 ,-9216 ,-9216 ,-12544 ,-12544 , -15872 ,-15872 ,-18687 ,-18687 ,-20735 ,-20735 ,-21759 ,-21759 ,-22015 ,-22015 ,-20479 ,-20479 ,-18687 ,-18687 ,-16128 , -16128 ,-12288 ,-12288 ,-8960 ,-8960 ,-6400 ,-6400 ,-4096 ,-4096 ,-3584 ,-3584 ,-3840 ,-3840 ,-5376 ,-5376 , -8192 ,-8192 ,-11520 ,-11520 ,-15360 ,-15360 ,-19455 ,-19455 ,-22527 ,-22527 ,-25343 ,-25343 ,-26623 ,-26623 ,-26623 , -26623 ,-24831 ,-24831 ,-22015 ,-22015 ,-17919 ,-17919 ,-13056 ,-13056 ,-8192 ,-8192 ,-3584 ,-3584 ,768 ,768 , 3584 ,3584 ,5376 ,5376 ,5376 ,5376 ,3840 ,3840 ,512 ,512 ,-3840 ,-3840 ,-8192 ,-8192 ,-12800 , -12800 ,-16639 ,-16639 ,-19199 ,-19199 ,-20223 ,-20223 ,-19967 ,-19967 ,-16895 ,-16895 ,-12800 ,-12800 ,-7168 ,-7168 , -768 ,-768 ,512 ,512 ,7168 ,7168 ,13056 ,13056 ,17151 ,17151 ,20223 ,20223 ,20223 ,20223 ,18943 , 18943 ,16128 ,16128 ,12032 ,12032 ,7168 ,7168 ,2560 ,2560 ,-1792 ,-1792 ,-5120 ,-5120 ,-6400 ,-6400 , -6144 ,-6144 ,-3840 ,-3840 ,-512 ,-512 ,4352 ,4352 ,9216 ,9216 ,14592 ,14592 ,19455 ,19455 ,23551 , 23551 ,25855 ,25855 ,27391 ,27391 ,26623 ,26623 ,24831 ,24831 ,21247 ,21247 ,17663 ,17663 ,13056 ,13056 , 8960 ,8960 ,5632 ,5632 ,2816 ,2816 ,1792 ,1792 ,2304 ,2304 ,3584 ,3584 ,6656 ,6656 ,9984 , 9984 ,14080 ,14080 ,18431 ,18431 ,21247 ,21247 ,23039 ,23039 ,24319 ,24319 ,23551 ,23551 ,21503 ,21503 , 18687 ,18687 ,14848 ,14848 ,10496 ,10496 ,6400 ,6400 ,3072 ,3072 ,512 ,512 ,-1024 ,-1024 ,-1280 , -1280 ,-256 ,-256 ,1536 ,1536 ,3840 ,3840 ,6144 ,6144 ,8448 ,8448 ,10752 ,10752 ,11264 ,11264 , 11776 ,11776 ,10752 ,10752 ,8960 ,8960 ,6144 ,6144 ,2816 ,2816 ,-3072 ,-3072 ,-6400 ,-6400 ,-9216 , -9216 ,-11008 ,-11008 ,-12032 ,-12032 ,-11520 ,-11520 ,-11008 ,-11008 ,-8704 ,-8704 ,-6400 ,-6400 ,-4096 ,-4096 , -1792 ,-1792 ,0 ,0 ,1024 ,1024 ,768 ,768 ,-768 ,-768 ,-3328 ,-3328 ,-6656 ,-6656 ,-10752 , -10752 ,-15104 ,-15104 ,-18943 ,-18943 ,-21759 ,-21759 ,-23807 ,-23807 ,-24575 ,-24575 ,-23295 ,-23295 ,-21503 ,-21503 , -18687 ,-18687 ,-14336 ,-14336 ,-10240 ,-10240 ,-6912 ,-6912 ,-3840 ,-3840 ,-2560 ,-2560 ,-2048 ,-2048 ,-3072 , -3072 ,-5888 ,-5888 ,-9216 ,-9216 ,-13312 ,-13312 ,-17919 ,-17919 ,-21503 ,-21503 ,-25087 ,-25087 ,-26879 ,-26879 , -27647 ,-27647 ,-26111 ,-26111 ,-23807 ,-23807 ,-19711 ,-19711 ,-14848 ,-14848 ,-9472 ,-9472 ,-4608 ,-4608 ,256 , 256 ,3584 ,3584 ,5888 ,5888 ,6144 ,6144 ,4864 ,4864 ,1536 ,1536 ,-2816 ,-2816 ,-7424 ,-7424 , -12288 ,-12288 ,-16384 ,-16384 ,-19199 ,-19199 ,-20479 ,-20479 ,-20479 ,-20479 ,-17407 ,-17407 ,-13312 ,-13312 ,-7424 , -7424 ,-768 ,-768 ,512 ,512 ,7424 ,7424 ,13568 ,13568 ,17663 ,17663 ,20735 ,20735 ,20735 ,20735 , 19199 ,19199 ,15872 ,15872 ,11520 ,11520 ,6400 ,6400 ,1536 ,1536 ,-2816 ,-2816 ,-6144 ,-6144 ,-7168 , -7168 ,-6400 ,-6400 ,-3840 ,-3840 ,0 ,0 ,5376 ,5376 ,10752 ,10752 ,16384 ,16384 ,21503 ,21503 , 25343 ,25343 ,27391 ,27391 ,28415 ,28415 ,27135 ,27135 ,24575 ,24575 ,20479 ,20479 ,16128 ,16128 ,11008 , 11008 ,6656 ,6656 ,3328 ,3328 ,768 ,768 ,0 ,0 ,1280 ,1280 ,3328 ,3328 ,7168 ,7168 , 11520 ,11520 ,16384 ,16384 ,21247 ,21247 ,24319 ,24319 ,26111 ,26111 ,26879 ,26879 ,25599 ,25599 ,22783 , 22783 ,18943 ,18943 ,14080 ,14080 ,8704 ,8704 ,4096 ,4096 ,0 ,0 ,-2560 ,-2560 ,-4096 ,-4096 , -3840 ,-3840 ,-2048 ,-2048 ,768 ,768 ,4096 ,4096 ,7424 ,7424 ,10496 ,10496 ,13568 ,13568 ,14592 , 14592 ,15104 ,15104 ,13824 ,13824 ,11520 ,11520 ,8192 ,8192 ,3840 ,3840 ,-4096 ,-4096 ,-8448 ,-8448 , -11776 ,-11776 ,-14080 ,-14080 ,-15360 ,-15360 ,-14848 ,-14848 ,-13824 ,-13824 ,-10752 ,-10752 ,-7680 ,-7680 ,-4352 , -4352 ,-1024 ,-1024 ,1792 ,1792 ,3584 ,3584 ,3840 ,3840 ,2304 ,2304 ,-256 ,-256 ,-4352 ,-4352 , -8960 ,-8960 ,-14336 ,-14336 ,-19199 ,-19199 ,-23039 ,-23039 ,-25855 ,-25855 ,-27135 ,-27135 ,-26367 ,-26367 ,-24575 , -24575 ,-21503 ,-21503 ,-16639 ,-16639 ,-11776 ,-11776 ,-7424 ,-7424 ,-3584 ,-3584 ,-1536 ,-1536 ,-256 ,-256 , -1024 ,-1024 ,-3584 ,-3584 ,-6912 ,-6912 ,-11264 ,-11264 ,-16384 ,-16384 ,-20735 ,-20735 ,-24831 ,-24831 ,-27391 , -27391 ,-28671 ,-28671 ,-27647 ,-27647 ,-25599 ,-25599 ,-21759 ,-21759 ,-16639 ,-16639 ,-11008 ,-11008 ,-5632 ,-5632 , -256 ,-256 ,3584 ,3584 ,6144 ,6144 ,6912 ,6912 ,5888 ,5888 ,2560 ,2560 ,-1792 ,-1792 ,-6656 , -6656 ,-11776 ,-11776 ,-16128 ,-16128 ,-19455 ,-19455 ,-20991 ,-20991 ,-20991 ,-20991 ,-17919 ,-17919 ,-13824 ,-13824 , -7680 ,-7680 ,-768 ,-768 ,512 ,512 ,7424 ,7424 ,13568 ,13568 ,17663 ,17663 ,20735 ,20735 ,20479 , 20479 ,18687 ,18687 ,15104 ,15104 ,10496 ,10496 ,5376 ,5376 ,512 ,512 ,-3584 ,-3584 ,-6400 ,-6400 , -7168 ,-7168 ,-5888 ,-5888 ,-2816 ,-2816 ,1280 ,1280 ,6912 ,6912 ,12288 ,12288 ,17407 ,17407 ,22015 , 22015 ,25343 ,25343 ,26879 ,26879 ,27135 ,27135 ,25343 ,25343 ,22271 ,22271 ,18175 ,18175 ,14080 ,14080 , 9472 ,9472 ,5888 ,5888 ,3328 ,3328 ,1792 ,1792 ,1792 ,1792 ,3584 ,3584 ,5888 ,5888 ,9472 , 9472 ,13568 ,13568 ,17663 ,17663 ,21503 ,21503 ,23551 ,23551 ,24319 ,24319 ,24319 ,24319 ,22527 ,22527 , 19711 ,19711 ,16128 ,16128 ,12032 ,12032 ,7936 ,7936 ,4352 ,4352 ,1280 ,1280 ,-512 ,-512 ,-1280 , -1280 ,-1024 ,-1024 ,768 ,768 ,2816 ,2816 ,5376 ,5376 ,7680 ,7680 ,9728 ,9728 ,11776 ,11776 , 12032 ,12032 ,12032 ,12032 ,10752 ,10752 ,8960 ,8960 ,6144 ,6144 ,2816 ,2816 ,-3072 ,-3072 ,-6400 , -6400 ,-9216 ,-9216 ,-11008 ,-11008 ,-12288 ,-12288 ,-12288 ,-12288 ,-12032 ,-12032 ,-9984 ,-9984 ,-7936 ,-7936 , -5632 ,-5632 ,-3072 ,-3072 ,-1024 ,-1024 ,768 ,768 ,1024 ,1024 ,256 ,256 ,-1536 ,-1536 ,-4608 , -4608 ,-8192 ,-8192 ,-12288 ,-12288 ,-16384 ,-16384 ,-19967 ,-19967 ,-22783 ,-22783 ,-24575 ,-24575 ,-24575 ,-24575 , -23807 ,-23807 ,-21759 ,-21759 ,-17919 ,-17919 ,-13824 ,-13824 ,-9728 ,-9728 ,-6144 ,-6144 ,-3840 ,-3840 ,-2048 , -2048 ,-2048 ,-2048 ,-3584 ,-3584 ,-6144 ,-6144 ,-9728 ,-9728 ,-14336 ,-14336 ,-18431 ,-18431 ,-22527 ,-22527 , -25599 ,-25599 ,-27391 ,-27391 ,-27135 ,-27135 ,-25599 ,-25599 ,-22271 ,-22271 ,-17663 ,-17663 ,-12544 ,-12544 ,-7168 , -7168 ,-1536 ,-1536 ,2560 ,2560 ,5632 ,5632 ,6912 ,6912 ,6144 ,6144 ,3328 ,3328 ,-768 ,-768 , -5632 ,-5632 ,-10752 ,-10752 ,-15360 ,-15360 ,-18943 ,-18943 ,-20735 ,-20735 ,-20991 ,-20991 ,-17919 ,-17919 ,-13824 , -13824 ,-7680 ,-7680 ,-768 ,-768 ,512 ,512 ,7424 ,7424 ,13568 ,13568 ,17663 ,17663 ,20735 ,20735 , 20479 ,20479 ,18431 ,18431 ,14848 ,14848 ,9984 ,9984 ,4864 ,4864 ,0 ,0 ,-3840 ,-3840 ,-6656 , -6656 ,-7168 ,-7168 ,-5632 ,-5632 ,-2304 ,-2304 ,2048 ,2048 ,7680 ,7680 ,13056 ,13056 ,17919 ,17919 , 22271 ,22271 ,25343 ,25343 ,26623 ,26623 ,26367 ,26367 ,24319 ,24319 ,21247 ,21247 ,17151 ,17151 ,13056 , 13056 ,8704 ,8704 ,5376 ,5376 ,3328 ,3328 ,2304 ,2304 ,2560 ,2560 ,4608 ,4608 ,7168 ,7168 , 10752 ,10752 ,14592 ,14592 ,18175 ,18175 ,21503 ,21503 ,23039 ,23039 ,23551 ,23551 ,23039 ,23039 ,20991 , 20991 ,18175 ,18175 ,14848 ,14848 ,11008 ,11008 ,7424 ,7424 ,4352 ,4352 ,1792 ,1792 ,512 ,512 , 0 ,0 ,512 ,512 ,2048 ,2048 ,3840 ,3840 ,5888 ,5888 ,7680 ,7680 ,9216 ,9216 ,10752 , 10752 ,10752 ,10752 ,10496 ,10496 ,9216 ,9216 ,7680 ,7680 ,5120 ,5120 ,2304 ,2304 ,-2560 ,-2560 , -5376 ,-5376 ,-7936 ,-7936 ,-9472 ,-9472 ,-10752 ,-10752 ,-11008 ,-11008 ,-11008 ,-11008 ,-9472 ,-9472 ,-7936 , -7936 ,-6144 ,-6144 ,-4096 ,-4096 ,-2304 ,-2304 ,-768 ,-768 ,-256 ,-256 ,-768 ,-768 ,-2048 ,-2048 , -4608 ,-4608 ,-7680 ,-7680 ,-11264 ,-11264 ,-15104 ,-15104 ,-18431 ,-18431 ,-21247 ,-21247 ,-23295 ,-23295 ,-23807 , -23807 ,-23295 ,-23295 ,-21759 ,-21759 ,-18431 ,-18431 ,-14848 ,-14848 ,-11008 ,-11008 ,-7424 ,-7424 ,-4864 ,-4864 , -2816 ,-2816 ,-2560 ,-2560 ,-3584 ,-3584 ,-5632 ,-5632 ,-8960 ,-8960 ,-13312 ,-13312 ,-17407 ,-17407 ,-21503 , -21503 ,-24575 ,-24575 ,-26623 ,-26623 ,-26879 ,-26879 ,-25599 ,-25599 ,-22527 ,-22527 ,-18175 ,-18175 ,-13312 ,-13312 , -7936 ,-7936 ,-2304 ,-2304 ,2048 ,2048 ,5376 ,5376 ,6912 ,6912 ,6400 ,6400 ,3584 ,3584 ,-256 , -256 ,-5120 ,-5120 ,-10240 ,-10240 ,-15104 ,-15104 ,-18687 ,-18687 ,-20735 ,-20735 ,-20991 ,-20991 ,-17919 ,-17919 , -13824 ,-13824 ,-7680 ,-7680 ,-768 ,-768 ,512 ,512 ,7424 ,7424 ,13824 ,13824 ,17919 ,17919 ,20735 , 20735 ,20479 ,20479 ,18431 ,18431 ,14592 ,14592 ,9728 ,9728 ,4608 ,4608 ,-256 ,-256 ,-4096 ,-4096 , -6656 ,-6656 ,-6912 ,-6912 ,-5120 ,-5120 ,-1792 ,-1792 ,2816 ,2816 ,8448 ,8448 ,13824 ,13824 ,18687 , 18687 ,22783 ,22783 ,25599 ,25599 ,26367 ,26367 ,25855 ,25855 ,23551 ,23551 ,20223 ,20223 ,16128 ,16128 , 12288 ,12288 ,7936 ,7936 ,5120 ,5120 ,3584 ,3584 ,2816 ,2816 ,3584 ,3584 ,5888 ,5888 ,8704 , 8704 ,12032 ,12032 ,15616 ,15616 ,18943 ,18943 ,21759 ,21759 ,22783 ,22783 ,22783 ,22783 ,21759 ,21759 , 19711 ,19711 ,16895 ,16895 ,13568 ,13568 ,10240 ,10240 ,7168 ,7168 ,4608 ,4608 ,2560 ,2560 ,1792 , 1792 ,1536 ,1536 ,2048 ,2048 ,3584 ,3584 ,5120 ,5120 ,6656 ,6656 ,7936 ,7936 ,8960 ,8960 , 9984 ,9984 ,9472 ,9472 ,9216 ,9216 ,7936 ,7936 ,6400 ,6400 ,4352 ,4352 ,1792 ,1792 ,-2048 , -2048 ,-4608 ,-4608 ,-6656 ,-6656 ,-8192 ,-8192 ,-9472 ,-9472 ,-9728 ,-9728 ,-10240 ,-10240 ,-9216 ,-9216 , -8192 ,-8192 ,-6912 ,-6912 ,-5376 ,-5376 ,-3840 ,-3840 ,-2304 ,-2304 ,-1792 ,-1792 ,-2048 ,-2048 ,-2816 , -2816 ,-4864 ,-4864 ,-7424 ,-7424 ,-10496 ,-10496 ,-13824 ,-13824 ,-17151 ,-17151 ,-19967 ,-19967 ,-22015 ,-22015 , -23039 ,-23039 ,-23039 ,-23039 ,-22015 ,-22015 ,-19199 ,-19199 ,-15872 ,-15872 ,-12288 ,-12288 ,-8960 ,-8960 ,-6144 , -6144 ,-3840 ,-3840 ,-3072 ,-3072 ,-3840 ,-3840 ,-5376 ,-5376 ,-8192 ,-8192 ,-12544 ,-12544 ,-16384 ,-16384 , -20479 ,-20479 ,-23807 ,-23807 ,-26111 ,-26111 ,-26623 ,-26623 ,-25855 ,-25855 ,-23039 ,-23039 ,-18943 ,-18943 ,-14080 , -14080 ,-8704 ,-8704 ,-3072 ,-3072 ,1536 ,1536 ,4864 ,4864 ,6656 ,6656 ,6400 ,6400 ,3840 ,3840 , 0 ,0 ,-4864 ,-4864 ,-9984 ,-9984 ,-14848 ,-14848 ,-18687 ,-18687 ,-20735 ,-20735 ,-20991 ,-20991 ,-18175 , -18175 ,-14080 ,-14080 ,-7680 ,-7680 ,-768 ,-768 ,512 ,512 ,7424 ,7424 ,14080 ,14080 ,17919 ,17919 , 20735 ,20735 ,20223 ,20223 ,17919 ,17919 ,13824 ,13824 ,8960 ,8960 ,3584 ,3584 ,-1280 ,-1280 ,-4864 , -4864 ,-6912 ,-6912 ,-6656 ,-6656 ,-4608 ,-4608 ,-768 ,-768 ,4096 ,4096 ,9984 ,9984 ,15360 ,15360 , 19967 ,19967 ,23551 ,23551 ,25599 ,25599 ,25855 ,25855 ,24575 ,24575 ,21759 ,21759 ,18175 ,18175 ,13824 , 13824 ,10240 ,10240 ,6400 ,6400 ,4352 ,4352 ,3584 ,3584 ,3840 ,3840 ,5376 ,5376 ,8192 ,8192 , 11264 ,11264 ,14592 ,14592 ,17663 ,17663 ,20223 ,20223 ,22015 ,22015 ,22015 ,22015 ,20991 ,20991 ,19199 , 19199 ,16895 ,16895 ,13824 ,13824 ,11008 ,11008 ,8448 ,8448 ,6400 ,6400 ,4864 ,4864 ,3840 ,3840 , 4096 ,4096 ,4352 ,4352 ,5120 ,5120 ,6400 ,6400 ,7168 ,7168 ,7936 ,7936 ,8192 ,8192 ,8192 , 8192 ,8192 ,8192 ,6912 ,6912 ,6400 ,6400 ,5120 ,5120 ,3840 ,3840 ,2304 ,2304 ,768 ,768 , -1024 ,-1024 ,-2560 ,-2560 ,-4096 ,-4096 ,-5376 ,-5376 ,-6656 ,-6656 ,-7168 ,-7168 ,-8448 ,-8448 ,-8448 , -8448 ,-8448 ,-8448 ,-8192 ,-8192 ,-7424 ,-7424 ,-6656 ,-6656 ,-5376 ,-5376 ,-4608 ,-4608 ,-4352 ,-4352 , -4096 ,-4096 ,-5120 ,-5120 ,-6656 ,-6656 ,-8704 ,-8704 ,-11264 ,-11264 ,-14080 ,-14080 ,-17151 ,-17151 ,-19455 , -19455 ,-21247 ,-21247 ,-22271 ,-22271 ,-22271 ,-22271 ,-20479 ,-20479 ,-17919 ,-17919 ,-14848 ,-14848 ,-11520 ,-11520 , -8448 ,-8448 ,-5632 ,-5632 ,-4096 ,-4096 ,-3840 ,-3840 ,-4608 ,-4608 ,-6656 ,-6656 ,-10496 ,-10496 ,-14080 , -14080 ,-18431 ,-18431 ,-22015 ,-22015 ,-24831 ,-24831 ,-26111 ,-26111 ,-25855 ,-25855 ,-23807 ,-23807 ,-20223 ,-20223 , -15616 ,-15616 ,-10240 ,-10240 ,-4352 ,-4352 ,512 ,512 ,4352 ,4352 ,6400 ,6400 ,6656 ,6656 ,4608 , 4608 ,1024 ,1024 ,-3840 ,-3840 ,-9216 ,-9216 ,-14080 ,-14080 ,-18175 ,-18175 ,-20479 ,-20479 ,-20991 ,-20991 , -18175 ,-18175 ,-14336 ,-14336 ,-7680 ,-7680 ,-768 ,-768 ,512 ,512 ,7424 ,7424 ,14080 ,14080 ,17919 , 17919 ,20735 ,20735 ,20223 ,20223 ,17663 ,17663 ,13568 ,13568 ,8448 ,8448 ,3072 ,3072 ,-1792 ,-1792 , -5120 ,-5120 ,-7168 ,-7168 ,-6656 ,-6656 ,-4352 ,-4352 ,-256 ,-256 ,4864 ,4864 ,10752 ,10752 ,16128 , 16128 ,20479 ,20479 ,23807 ,23807 ,25599 ,25599 ,25599 ,25599 ,24063 ,24063 ,20735 ,20735 ,17151 ,17151 , 12800 ,12800 ,9216 ,9216 ,5632 ,5632 ,4096 ,4096 ,3584 ,3584 ,4352 ,4352 ,6400 ,6400 ,9472 , 9472 ,12544 ,12544 ,15872 ,15872 ,18687 ,18687 ,20735 ,20735 ,22271 ,22271 ,21503 ,21503 ,20223 ,20223 , 17919 ,17919 ,15360 ,15360 ,12288 ,12288 ,9728 ,9728 ,7424 ,7424 ,5888 ,5888 ,4864 ,4864 ,4608 , 4608 ,5120 ,5120 ,5888 ,5888 ,6656 ,6656 ,7680 ,7680 ,8192 ,8192 ,8704 ,8704 ,8192 ,8192 , 7680 ,7680 ,7168 ,7168 ,5632 ,5632 ,4864 ,4864 ,3584 ,3584 ,2560 ,2560 ,1280 ,1280 ,256 , 256 ,-512 ,-512 ,-1536 ,-1536 ,-2816 ,-2816 ,-3840 ,-3840 ,-5120 ,-5120 ,-5888 ,-5888 ,-7424 ,-7424 , -7936 ,-7936 ,-8448 ,-8448 ,-8960 ,-8960 ,-8448 ,-8448 ,-7936 ,-7936 ,-6912 ,-6912 ,-6144 ,-6144 ,-5376 , -5376 ,-4864 ,-4864 ,-5120 ,-5120 ,-6144 ,-6144 ,-7680 ,-7680 ,-9984 ,-9984 ,-12544 ,-12544 ,-15616 ,-15616 , -18175 ,-18175 ,-20479 ,-20479 ,-21759 ,-21759 ,-22527 ,-22527 ,-20991 ,-20991 ,-18943 ,-18943 ,-16128 ,-16128 ,-12800 , -12800 ,-9728 ,-9728 ,-6656 ,-6656 ,-4608 ,-4608 ,-3840 ,-3840 ,-4352 ,-4352 ,-5888 ,-5888 ,-9472 ,-9472 , -13056 ,-13056 ,-17407 ,-17407 ,-20991 ,-20991 ,-24319 ,-24319 ,-25855 ,-25855 ,-25855 ,-25855 ,-24063 ,-24063 ,-20735 , -20735 ,-16384 ,-16384 ,-11008 ,-11008 ,-5120 ,-5120 ,0 ,0 ,4096 ,4096 ,6400 ,6400 ,6912 ,6912 , 4864 ,4864 ,1536 ,1536 ,-3328 ,-3328 ,-8704 ,-8704 ,-13824 ,-13824 ,-17919 ,-17919 ,-20479 ,-20479 ,-20991 , -20991 ,-18175 ,-18175 ,-14336 ,-14336 ,-7680 ,-7680 ,-768 ,-768 ,512 ,512 ,7680 ,7680 ,14336 ,14336 , 18175 ,18175 ,20735 ,20735 ,20223 ,20223 ,17663 ,17663 ,13312 ,13312 ,8192 ,8192 ,2816 ,2816 ,-2048 , -2048 ,-5376 ,-5376 ,-7168 ,-7168 ,-6400 ,-6400 ,-3840 ,-3840 ,512 ,512 ,5632 ,5632 ,11520 ,11520 , 16895 ,16895 ,21247 ,21247 ,24319 ,24319 ,25855 ,25855 ,25343 ,25343 ,23551 ,23551 ,19967 ,19967 ,16128 , 16128 ,11776 ,11776 ,8448 ,8448 ,5120 ,5120 ,3840 ,3840 ,3840 ,3840 ,4864 ,4864 ,7424 ,7424 , 10752 ,10752 ,14080 ,14080 ,17151 ,17151 ,19967 ,19967 ,21503 ,21503 ,22527 ,22527 ,21247 ,21247 ,19455 , 19455 ,16895 ,16895 ,14080 ,14080 ,11008 ,11008 ,8448 ,8448 ,6656 ,6656 ,5632 ,5632 ,5120 ,5120 , 5376 ,5376 ,6400 ,6400 ,7424 ,7424 ,8192 ,8192 ,9216 ,9216 ,9472 ,9472 ,9472 ,9472 ,8448 , 8448 ,7424 ,7424 ,6400 ,6400 ,4608 ,4608 ,3584 ,3584 ,2304 ,2304 ,1536 ,1536 ,512 ,512 , -256 ,-256 ,0 ,0 ,-768 ,-768 ,-1792 ,-1792 ,-2560 ,-2560 ,-3840 ,-3840 ,-4864 ,-4864 ,-6656 , -6656 ,-7680 ,-7680 ,-8704 ,-8704 ,-9728 ,-9728 ,-9728 ,-9728 ,-9472 ,-9472 ,-8448 ,-8448 ,-7680 ,-7680 , -6656 ,-6656 ,-5632 ,-5632 ,-5376 ,-5376 ,-5888 ,-5888 ,-6912 ,-6912 ,-8704 ,-8704 ,-11264 ,-11264 ,-14336 , -14336 ,-17151 ,-17151 ,-19711 ,-19711 ,-21503 ,-21503 ,-22783 ,-22783 ,-21759 ,-21759 ,-20223 ,-20223 ,-17407 ,-17407 , -14336 ,-14336 ,-11008 ,-11008 ,-7680 ,-7680 ,-5120 ,-5120 ,-4096 ,-4096 ,-4096 ,-4096 ,-5376 ,-5376 ,-8704 , -8704 ,-12032 ,-12032 ,-16384 ,-16384 ,-20223 ,-20223 ,-23807 ,-23807 ,-25599 ,-25599 ,-26111 ,-26111 ,-24575 ,-24575 , -21503 ,-21503 ,-17151 ,-17151 ,-11776 ,-11776 ,-5888 ,-5888 ,-768 ,-768 ,3584 ,3584 ,6144 ,6144 ,6912 , 6912 ,5120 ,5120 ,1792 ,1792 ,-3072 ,-3072 ,-8448 ,-8448 ,-13568 ,-13568 ,-17919 ,-17919 ,-20479 ,-20479 , -20991 ,-20991 ,-18431 ,-18431 ,-14592 ,-14592 ,-7936 ,-7936 ,-768 ,-768 ,512 ,512 ,7680 ,7680 ,14336 , 14336 ,18175 ,18175 ,20735 ,20735 ,19967 ,19967 ,17151 ,17151 ,12544 ,12544 ,7168 ,7168 ,1792 ,1792 , -3072 ,-3072 ,-6144 ,-6144 ,-7424 ,-7424 ,-6400 ,-6400 ,-3328 ,-3328 ,1536 ,1536 ,6912 ,6912 ,13056 , 13056 ,18431 ,18431 ,22527 ,22527 ,25087 ,25087 ,25855 ,25855 ,24831 ,24831 ,22271 ,22271 ,18175 ,18175 , 14080 ,14080 ,9472 ,9472 ,6400 ,6400 ,3584 ,3584 ,3072 ,3072 ,3840 ,3840 ,5888 ,5888 ,9216 , 9216 ,13056 ,13056 ,16639 ,16639 ,19711 ,19711 ,22015 ,22015 ,22783 ,22783 ,22783 ,22783 ,20479 ,20479 , 17663 ,17663 ,14336 ,14336 ,11008 ,11008 ,7936 ,7936 ,5632 ,5632 ,4864 ,4864 ,4864 ,4864 ,5376 , 5376 ,6656 ,6656 ,8704 ,8704 ,10240 ,10240 ,11008 ,11008 ,12032 ,12032 ,11520 ,11520 ,10752 ,10752 , 8704 ,8704 ,6656 ,6656 ,4608 ,4608 ,2048 ,2048 ,768 ,768 ,-512 ,-512 ,-1024 ,-1024 ,-1536 , -1536 ,-1280 ,-1280 ,1024 ,1024 ,1280 ,1280 ,768 ,768 ,256 ,256 ,-1024 ,-1024 ,-2304 ,-2304 , -4864 ,-4864 ,-6912 ,-6912 ,-8960 ,-8960 ,-11008 ,-11008 ,-11776 ,-11776 ,-12288 ,-12288 ,-11264 ,-11264 ,-10496 , -10496 ,-8960 ,-8960 ,-6912 ,-6912 ,-5632 ,-5632 ,-5120 ,-5120 ,-5120 ,-5120 ,-5888 ,-5888 ,-8192 ,-8192 , -11264 ,-11264 ,-14592 ,-14592 ,-17919 ,-17919 ,-20735 ,-20735 ,-23039 ,-23039 ,-23039 ,-23039 ,-22271 ,-22271 ,-19967 , -19967 ,-16895 ,-16895 ,-13312 ,-13312 ,-9472 ,-9472 ,-6144 ,-6144 ,-4096 ,-4096 ,-3328 ,-3328 ,-3840 ,-3840 , -6656 ,-6656 ,-9728 ,-9728 ,-14336 ,-14336 ,-18431 ,-18431 ,-22527 ,-22527 ,-25087 ,-25087 ,-26111 ,-26111 ,-25343 , -25343 ,-22783 ,-22783 ,-18687 ,-18687 ,-13312 ,-13312 ,-7168 ,-7168 ,-1792 ,-1792 ,3072 ,3072 ,6144 ,6144 , 7168 ,7168 ,5888 ,5888 ,2816 ,2816 ,-2048 ,-2048 ,-7424 ,-7424 ,-12800 ,-12800 ,-17407 ,-17407 ,-20223 , -20223 ,-20991 ,-20991 ,-18431 ,-18431 ,-14592 ,-14592 ,-7936 ,-7936 ,-768 ,-768 ,512 ,512 ,7680 ,7680 , 14336 ,14336 ,18175 ,18175 ,20735 ,20735 ,19967 ,19967 ,16895 ,16895 ,12288 ,12288 ,6656 ,6656 ,1280 , 1280 ,-3584 ,-3584 ,-6400 ,-6400 ,-7680 ,-7680 ,-6400 ,-6400 ,-3072 ,-3072 ,2048 ,2048 ,7680 ,7680 , 13824 ,13824 ,19199 ,19199 ,23039 ,23039 ,25343 ,25343 ,25855 ,25855 ,24575 ,24575 ,21503 ,21503 ,17151 , 17151 ,13056 ,13056 ,8448 ,8448 ,5376 ,5376 ,2816 ,2816 ,2816 ,2816 ,3840 ,3840 ,6400 ,6400 , 9984 ,9984 ,14080 ,14080 ,17919 ,17919 ,20991 ,20991 ,23039 ,23039 ,23295 ,23295 ,22783 ,22783 ,19967 , 19967 ,16895 ,16895 ,13056 ,13056 ,9472 ,9472 ,6400 ,6400 ,4352 ,4352 ,3840 ,3840 ,4352 ,4352 , 5376 ,5376 ,7168 ,7168 ,9728 ,9728 ,11520 ,11520 ,12544 ,12544 ,13312 ,13312 ,12544 ,12544 ,11264 , 11264 ,8704 ,8704 ,6144 ,6144 ,3584 ,3584 ,768 ,768 ,-768 ,-768 ,-2048 ,-2048 ,-2304 ,-2304 , -2560 ,-2560 ,-1792 ,-1792 ,1536 ,1536 ,2304 ,2304 ,2048 ,2048 ,1792 ,1792 ,512 ,512 ,-1024 , -1024 ,-3840 ,-3840 ,-6400 ,-6400 ,-8960 ,-8960 ,-11520 ,-11520 ,-12800 ,-12800 ,-13568 ,-13568 ,-12800 ,-12800 , -11776 ,-11776 ,-9984 ,-9984 ,-7424 ,-7424 ,-5632 ,-5632 ,-4608 ,-4608 ,-4096 ,-4096 ,-4608 ,-4608 ,-6656 , -6656 ,-9728 ,-9728 ,-13312 ,-13312 ,-17151 ,-17151 ,-20223 ,-20223 ,-23039 ,-23039 ,-23551 ,-23551 ,-23295 ,-23295 , -21247 ,-21247 ,-18175 ,-18175 ,-14336 ,-14336 ,-10240 ,-10240 ,-6656 ,-6656 ,-4096 ,-4096 ,-3072 ,-3072 ,-3072 , -3072 ,-5632 ,-5632 ,-8704 ,-8704 ,-13312 ,-13312 ,-17407 ,-17407 ,-21759 ,-21759 ,-24831 ,-24831 ,-26111 ,-26111 , -25599 ,-25599 ,-23295 ,-23295 ,-19455 ,-19455 ,-14080 ,-14080 ,-7936 ,-7936 ,-2304 ,-2304 ,2816 ,2816 ,6144 , 6144 ,7424 ,7424 ,6144 ,6144 ,3328 ,3328 ,-1536 ,-1536 ,-6912 ,-6912 ,-12544 ,-12544 ,-17151 ,-17151 , -20223 ,-20223 ,-20991 ,-20991 ,-18431 ,-18431 ,-14592 ,-14592 ,-7936 ,-7936 ,-768 ,-768 ,512 ,512 ,7936 , 7936 ,14592 ,14592 ,18431 ,18431 ,20735 ,20735 ,19967 ,19967 ,16895 ,16895 ,12032 ,12032 ,6400 ,6400 , 1024 ,1024 ,-3840 ,-3840 ,-6656 ,-6656 ,-7680 ,-7680 ,-6144 ,-6144 ,-2560 ,-2560 ,2816 ,2816 ,8448 , 8448 ,14592 ,14592 ,19967 ,19967 ,23807 ,23807 ,25855 ,25855 ,26111 ,26111 ,24319 ,24319 ,20991 ,20991 , 16384 ,16384 ,12032 ,12032 ,7424 ,7424 ,4608 ,4608 ,2304 ,2304 ,2560 ,2560 ,4096 ,4096 ,6912 , 6912 ,11008 ,11008 ,15360 ,15360 ,19455 ,19455 ,22271 ,22271 ,24063 ,24063 ,24063 ,24063 ,23039 ,23039 , 19711 ,19711 ,16128 ,16128 ,12032 ,12032 ,8192 ,8192 ,5120 ,5120 ,3072 ,3072 ,3072 ,3072 ,4096 , 4096 ,5632 ,5632 ,7936 ,7936 ,11008 ,11008 ,13056 ,13056 ,14080 ,14080 ,14848 ,14848 ,13824 ,13824 , 12032 ,12032 ,8960 ,8960 ,5888 ,5888 ,2816 ,2816 ,-512 ,-512 ,-2048 ,-2048 ,-3328 ,-3328 ,-3328 , -3328 ,-3328 ,-3328 ,-2304 ,-2304 ,2048 ,2048 ,3072 ,3072 ,3072 ,3072 ,3072 ,3072 ,1792 ,1792 , 256 ,256 ,-3072 ,-3072 ,-6144 ,-6144 ,-9216 ,-9216 ,-12288 ,-12288 ,-14080 ,-14080 ,-15104 ,-15104 ,-14336 , -14336 ,-13312 ,-13312 ,-11264 ,-11264 ,-8192 ,-8192 ,-5888 ,-5888 ,-4352 ,-4352 ,-3328 ,-3328 ,-3328 ,-3328 , -5376 ,-5376 ,-8448 ,-8448 ,-12288 ,-12288 ,-16384 ,-16384 ,-19967 ,-19967 ,-23295 ,-23295 ,-24319 ,-24319 ,-24319 , -24319 ,-22527 ,-22527 ,-19711 ,-19711 ,-15616 ,-15616 ,-11264 ,-11264 ,-7168 ,-7168 ,-4352 ,-4352 ,-2816 ,-2816 , -2560 ,-2560 ,-4864 ,-4864 ,-7680 ,-7680 ,-12288 ,-12288 ,-16639 ,-16639 ,-21247 ,-21247 ,-24575 ,-24575 ,-26367 , -26367 ,-26111 ,-26111 ,-24063 ,-24063 ,-20223 ,-20223 ,-14848 ,-14848 ,-8704 ,-8704 ,-3072 ,-3072 ,2304 ,2304 , 5888 ,5888 ,7424 ,7424 ,6400 ,6400 ,3584 ,3584 ,-1280 ,-1280 ,-6656 ,-6656 ,-12288 ,-12288 ,-17151 , -17151 ,-20223 ,-20223 ,-20991 ,-20991 ,-18687 ,-18687 ,-14848 ,-14848 ,-8192 ,-8192 ,-768 ,-768 ,512 ,512 , 7936 ,7936 ,14848 ,14848 ,18431 ,18431 ,20735 ,20735 ,19711 ,19711 ,16384 ,16384 ,11520 ,11520 ,5632 , 5632 ,0 ,0 ,-4608 ,-4608 ,-7424 ,-7424 ,-7936 ,-7936 ,-5888 ,-5888 ,-1792 ,-1792 ,3840 ,3840 , 9728 ,9728 ,16128 ,16128 ,21503 ,21503 ,25087 ,25087 ,26623 ,26623 ,26111 ,26111 ,23807 ,23807 ,19711 , 19711 ,14592 ,14592 ,9984 ,9984 ,5120 ,5120 ,2560 ,2560 ,768 ,768 ,1792 ,1792 ,4352 ,4352 , 7936 ,7936 ,12800 ,12800 ,17663 ,17663 ,22015 ,22015 ,24831 ,24831 ,26111 ,26111 ,25343 ,25343 ,23295 , 23295 ,18943 ,18943 ,14592 ,14592 ,9472 ,9472 ,5376 ,5376 ,2048 ,2048 ,512 ,512 ,1280 ,1280 , 3328 ,3328 ,5888 ,5888 ,9216 ,9216 ,13312 ,13312 ,15872 ,15872 ,17151 ,17151 ,17663 ,17663 ,16128 , 16128 ,13312 ,13312 ,9216 ,9216 ,5120 ,5120 ,1024 ,1024 ,-3072 ,-3072 ,-4864 ,-4864 ,-6144 ,-6144 , -5888 ,-5888 ,-5376 ,-5376 ,-3328 ,-3328 ,3072 ,3072 ,5120 ,5120 ,5632 ,5632 ,5888 ,5888 ,4608 , 4608 ,2816 ,2816 ,-1280 ,-1280 ,-5376 ,-5376 ,-9472 ,-9472 ,-13568 ,-13568 ,-16384 ,-16384 ,-17919 ,-17919 , -17407 ,-17407 ,-16128 ,-16128 ,-13568 ,-13568 ,-9472 ,-9472 ,-6144 ,-6144 ,-3584 ,-3584 ,-1536 ,-1536 ,-768 , -768 ,-2304 ,-2304 ,-5632 ,-5632 ,-9728 ,-9728 ,-14848 ,-14848 ,-19199 ,-19199 ,-23551 ,-23551 ,-25599 ,-25599 , -26367 ,-26367 ,-25087 ,-25087 ,-22271 ,-22271 ,-17919 ,-17919 ,-13056 ,-13056 ,-8192 ,-8192 ,-4608 ,-4608 ,-2048 , -2048 ,-1024 ,-1024 ,-2816 ,-2816 ,-5376 ,-5376 ,-10240 ,-10240 ,-14848 ,-14848 ,-19967 ,-19967 ,-24063 ,-24063 , -26367 ,-26367 ,-26879 ,-26879 ,-25343 ,-25343 ,-21759 ,-21759 ,-16384 ,-16384 ,-9984 ,-9984 ,-4096 ,-4096 ,1536 , 1536 ,5632 ,5632 ,7680 ,7680 ,7168 ,7168 ,4352 ,4352 ,-256 ,-256 ,-5888 ,-5888 ,-11776 ,-11776 , -16639 ,-16639 ,-19967 ,-19967 ,-20991 ,-20991 ,-18687 ,-18687 ,-15104 ,-15104 ,-8192 ,-8192 ,-768 ,-768 ,512 , 512 ,7936 ,7936 ,14848 ,14848 ,18431 ,18431 ,20735 ,20735 ,19711 ,19711 ,16128 ,16128 ,11264 ,11264 , 5120 ,5120 ,-512 ,-512 ,-5120 ,-5120 ,-7680 ,-7680 ,-8192 ,-8192 ,-5888 ,-5888 ,-1536 ,-1536 ,4352 , 4352 ,10496 ,10496 ,16895 ,16895 ,22271 ,22271 ,25599 ,25599 ,26879 ,26879 ,26111 ,26111 ,23551 ,23551 , 19199 ,19199 ,13824 ,13824 ,8960 ,8960 ,4096 ,4096 ,1536 ,1536 ,0 ,0 ,1536 ,1536 ,4352 , 4352 ,8448 ,8448 ,13824 ,13824 ,18943 ,18943 ,23295 ,23295 ,26111 ,26111 ,27135 ,27135 ,26111 ,26111 , 23551 ,23551 ,18687 ,18687 ,13824 ,13824 ,8192 ,8192 ,3840 ,3840 ,512 ,512 ,-768 ,-768 ,256 , 256 ,2816 ,2816 ,6144 ,6144 ,9984 ,9984 ,14336 ,14336 ,17407 ,17407 ,18687 ,18687 ,18943 ,18943 , 17151 ,17151 ,14080 ,14080 ,9216 ,9216 ,4864 ,4864 ,0 ,0 ,-4352 ,-4352 ,-6400 ,-6400 ,-7680 , -7680 ,-7168 ,-7168 ,-6400 ,-6400 ,-3840 ,-3840 ,3584 ,3584 ,6144 ,6144 ,6912 ,6912 ,7424 ,7424 , 6144 ,6144 ,4096 ,4096 ,-256 ,-256 ,-5120 ,-5120 ,-9472 ,-9472 ,-14336 ,-14336 ,-17407 ,-17407 ,-19199 , -19199 ,-18943 ,-18943 ,-17663 ,-17663 ,-14592 ,-14592 ,-10240 ,-10240 ,-6400 ,-6400 ,-3072 ,-3072 ,-512 ,-512 , 512 ,512 ,-768 ,-768 ,-4096 ,-4096 ,-8448 ,-8448 ,-14080 ,-14080 ,-18943 ,-18943 ,-23807 ,-23807 ,-26367 , -26367 ,-27391 ,-27391 ,-26367 ,-26367 ,-23551 ,-23551 ,-19199 ,-19199 ,-14080 ,-14080 ,-8704 ,-8704 ,-4608 ,-4608 , -1792 ,-1792 ,-256 ,-256 ,-1792 ,-1792 ,-4352 ,-4352 ,-9216 ,-9216 ,-14080 ,-14080 ,-19455 ,-19455 ,-23807 , -23807 ,-26367 ,-26367 ,-27135 ,-27135 ,-25855 ,-25855 ,-22527 ,-22527 ,-17151 ,-17151 ,-10752 ,-10752 ,-4608 ,-4608 , 1280 ,1280 ,5632 ,5632 ,7936 ,7936 ,7424 ,7424 ,4864 ,4864 ,256 ,256 ,-5376 ,-5376 ,-11520 , -11520 ,-16384 ,-16384 ,-19967 ,-19967 ,-20991 ,-20991 ,-18687 ,-18687 ,-15104 ,-15104 ,-8192 ,-8192 ,-768 ,-768 , 0 ,512 ,1024 ,1536 ,2048 ,2560 ,3072 ,3584 ,4096 ,4608 ,5120 ,5632 ,6144 ,6656 ,7168 , 7680 ,8192 ,8704 ,9216 ,9728 ,10240 ,10752 ,11264 ,11776 ,12288 ,12800 ,13312 ,13824 ,14336 ,14848 , 15360 ,15872 ,16384 ,16895 ,17407 ,17919 ,18431 ,18943 ,19455 ,19967 ,20479 ,20991 ,21503 ,22015 ,22527 , 23039 ,23551 ,24063 ,24575 ,25087 ,25599 ,26111 ,26623 ,27135 ,27647 ,28159 ,28671 ,29183 ,29695 ,30207 , 30719 ,31231 ,31743 ,32255 ,32766 ,32254 ,31742 ,31230 ,30718 ,30206 ,29694 ,29182 ,28670 ,28158 ,27646 , 27134 ,26622 ,26110 ,25598 ,25086 ,24574 ,24062 ,23550 ,23038 ,22526 ,22014 ,21502 ,20990 ,20478 ,19966 , 19454 ,18942 ,18430 ,17918 ,17406 ,16894 ,16383 ,15871 ,15359 ,14847 ,14335 ,13823 ,13311 ,12799 ,12287 , 11775 ,11263 ,10751 ,10239 ,9727 ,9215 ,8703 ,8191 ,7679 ,7167 ,6655 ,6143 ,5631 ,5119 ,4607 , 4095 ,3583 ,3071 ,2559 ,2047 ,1535 ,1023 ,511 ,0 ,-512 ,-1024 ,-1536 ,-2048 ,-2560 ,-3072 , -3584 ,-4096 ,-4608 ,-5120 ,-5632 ,-6144 ,-6656 ,-7168 ,-7680 ,-8192 ,-8704 ,-9216 ,-9728 ,-10240 ,-10752 , -11264 ,-11776 ,-12288 ,-12800 ,-13312 ,-13824 ,-14336 ,-14848 ,-15360 ,-15872 ,-16384 ,-16895 ,-17407 ,-17919 ,-18431 , -18943 ,-19455 ,-19967 ,-20479 ,-20991 ,-21503 ,-22015 ,-22527 ,-23039 ,-23551 ,-24063 ,-24575 ,-25087 ,-25599 ,-26111 , -26623 ,-27135 ,-27647 ,-28159 ,-28671 ,-29183 ,-29695 ,-30207 ,-30719 ,-31231 ,-31743 ,-32255 ,-32766 ,-32254 ,-31742 , -31230 ,-30718 ,-30206 ,-29694 ,-29182 ,-28670 ,-28158 ,-27646 ,-27134 ,-26622 ,-26110 ,-25598 ,-25086 ,-24574 ,-24062 , -23550 ,-23038 ,-22526 ,-22014 ,-21502 ,-20990 ,-20478 ,-19966 ,-19454 ,-18942 ,-18430 ,-17918 ,-17406 ,-16894 ,-16383 , -15871 ,-15359 ,-14847 ,-14335 ,-13823 ,-13311 ,-12799 ,-12287 ,-11775 ,-11263 ,-10751 ,-10239 ,-9727 ,-9215 ,-8703 , -8191 ,-7679 ,-7167 ,-6655 ,-6143 ,-5631 ,-5119 ,-4607 ,-4095 ,-3583 ,-3071 ,-2559 ,-2047 ,-1535 ,-1023 , -511 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 , -32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 , -32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 , -32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 , -32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 , -32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 , -32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 , -32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 , -32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 , -32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 , -32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 , -32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 , -32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 , -32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 , -32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 , -32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 , -32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 , 32766 ,32766 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 , -32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 , -32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 , -32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 , -32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 , -32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 , -32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 , -32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 , -32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,-32767 ,32766 ,32766 ,32766 ,32766 ,32766 , 32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 , 32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 , 32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 , 32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 , 32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 , 32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 , 32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 , 32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 , 32766 ,32766 ,32766 ,-32767 ,-32511 ,-32255 ,-31999 ,-31743 ,-31487 ,-31231 ,-30975 ,-30719 ,-30463 ,-30207 ,-29951 , -29695 ,-29439 ,-29183 ,-28927 ,-28671 ,-28415 ,-28159 ,-27903 ,-27647 ,-27391 ,-27135 ,-26879 ,-26623 ,-26367 ,-26111 , -25855 ,-25599 ,-25343 ,-25087 ,-24831 ,-24575 ,-24319 ,-24063 ,-23807 ,-23551 ,-23295 ,-23039 ,-22783 ,-22527 ,-22271 , -22015 ,-21759 ,-21503 ,-21247 ,-20991 ,-20735 ,-20479 ,-20223 ,-19967 ,-19711 ,-19455 ,-19199 ,-18943 ,-18687 ,-18431 , -18175 ,-17919 ,-17663 ,-17407 ,-17151 ,-16895 ,-16639 ,-16384 ,-16128 ,-15872 ,-15616 ,-15360 ,-15104 ,-14848 ,-14592 , -14336 ,-14080 ,-13824 ,-13568 ,-13312 ,-13056 ,-12800 ,-12544 ,-12288 ,-12032 ,-11776 ,-11520 ,-11264 ,-11008 ,-10752 , -10496 ,-10240 ,-9984 ,-9728 ,-9472 ,-9216 ,-8960 ,-8704 ,-8448 ,-8192 ,-7936 ,-7680 ,-7424 ,-7168 ,-6912 , -6656 ,-6400 ,-6144 ,-5888 ,-5632 ,-5376 ,-5120 ,-4864 ,-4608 ,-4352 ,-4096 ,-3840 ,-3584 ,-3328 ,-3072 , -2816 ,-2560 ,-2304 ,-2048 ,-1792 ,-1536 ,-1280 ,-1024 ,-768 ,-512 ,-256 ,0 ,256 ,512 ,768 , 1024 ,1280 ,1536 ,1792 ,2048 ,2304 ,2560 ,2816 ,3072 ,3328 ,3584 ,3840 ,4096 ,4352 ,4608 , 4864 ,5120 ,5376 ,5632 ,5888 ,6144 ,6400 ,6656 ,6912 ,7168 ,7424 ,7680 ,7936 ,8192 ,8448 , 8704 ,8960 ,9216 ,9472 ,9728 ,9984 ,10240 ,10496 ,10752 ,11008 ,11264 ,11520 ,11776 ,12032 ,12288 , 12544 ,12800 ,13056 ,13312 ,13568 ,13824 ,14080 ,14336 ,14592 ,14848 ,15104 ,15360 ,15616 ,15872 ,16128 , 16384 ,16639 ,16895 ,17151 ,17407 ,17663 ,17919 ,18175 ,18431 ,18687 ,18943 ,19199 ,19455 ,19711 ,19967 , 20223 ,20479 ,20735 ,20991 ,21247 ,21503 ,21759 ,22015 ,22271 ,22527 ,22783 ,23039 ,23295 ,23551 ,23807 , 24063 ,24319 ,24575 ,24831 ,25087 ,25343 ,25599 ,25855 ,26111 ,26367 ,26623 ,26879 ,27135 ,27391 ,27647 , 27903 ,28159 ,28415 ,28671 ,28927 ,29183 ,29439 ,29695 ,29951 ,30207 ,30463 ,30719 ,30975 ,31231 ,31487 , 31743 ,31999 ,32255 ,32511 , // sounds/wavetables/SINE2SAW.WAV 0 ,804 ,1607 ,2410 ,3211 ,4011 ,4807 ,5601 ,6392 ,7179 ,7961 ,8739 ,9511 ,10278 ,11038 , 11792 ,12539 ,13278 ,14009 ,14732 ,15446 ,16150 ,16844 ,17529 ,18203 ,18866 ,19518 ,20158 ,20786 ,21401 , 22003 ,22593 ,23168 ,23730 ,24277 ,24810 ,25328 ,25830 ,26317 ,26788 ,27243 ,27682 ,28104 ,28509 ,28896 , 29267 ,29620 ,29954 ,30271 ,30570 ,30850 ,31112 ,31355 ,31579 ,31784 ,31969 ,32136 ,32283 ,32411 ,32519 , 32608 ,32677 ,32726 ,32756 ,32766 ,32756 ,32726 ,32677 ,32608 ,32519 ,32411 ,32283 ,32136 ,31969 ,31784 , 31579 ,31355 ,31112 ,30850 ,30570 ,30271 ,29954 ,29620 ,29267 ,28896 ,28509 ,28104 ,27682 ,27243 ,26788 , 26317 ,25830 ,25328 ,24810 ,24277 ,23730 ,23168 ,22593 ,22003 ,21401 ,20786 ,20158 ,19518 ,18866 ,18203 , 17529 ,16844 ,16150 ,15446 ,14732 ,14009 ,13278 ,12539 ,11792 ,11038 ,10278 ,9511 ,8739 ,7961 ,7179 , 6392 ,5601 ,4807 ,4011 ,3211 ,2410 ,1607 ,804 ,0 ,-804 ,-1607 ,-2410 ,-3211 ,-4011 ,-4807 , -5601 ,-6392 ,-7179 ,-7961 ,-8739 ,-9511 ,-10278 ,-11038 ,-11792 ,-12539 ,-13278 ,-14009 ,-14732 ,-15446 ,-16150 , -16844 ,-17529 ,-18203 ,-18866 ,-19518 ,-20158 ,-20786 ,-21401 ,-22003 ,-22593 ,-23168 ,-23730 ,-24277 ,-24810 ,-25328 , -25830 ,-26317 ,-26788 ,-27243 ,-27682 ,-28104 ,-28509 ,-28896 ,-29267 ,-29620 ,-29954 ,-30271 ,-30570 ,-30850 ,-31112 , -31355 ,-31579 ,-31784 ,-31969 ,-32136 ,-32283 ,-32411 ,-32519 ,-32608 ,-32677 ,-32726 ,-32756 ,-32766 ,-32756 ,-32726 , -32677 ,-32608 ,-32519 ,-32411 ,-32283 ,-32136 ,-31969 ,-31784 ,-31579 ,-31355 ,-31112 ,-30850 ,-30570 ,-30271 ,-29954 , -29620 ,-29267 ,-28896 ,-28509 ,-28104 ,-27682 ,-27243 ,-26788 ,-26317 ,-25830 ,-25328 ,-24810 ,-24277 ,-23730 ,-23168 , -22593 ,-22003 ,-21401 ,-20786 ,-20158 ,-19518 ,-18866 ,-18203 ,-17529 ,-16844 ,-16150 ,-15446 ,-14732 ,-14009 ,-13278 , -12539 ,-11792 ,-11038 ,-10278 ,-9511 ,-8739 ,-7961 ,-7179 ,-6392 ,-5601 ,-4807 ,-4011 ,-3211 ,-2410 ,-1607 , -804 ,2065 ,2866 ,3411 ,4211 ,5010 ,5808 ,6346 ,7139 ,7928 ,8731 ,9256 ,10033 ,10805 ,11316 , 12077 ,12831 ,13563 ,14048 ,14781 ,15507 ,16225 ,16676 ,17359 ,18049 ,18730 ,19127 ,19786 ,20418 ,21055 , 21663 ,22003 ,22605 ,23176 ,23735 ,24023 ,24555 ,25072 ,25575 ,26064 ,26282 ,26740 ,27184 ,27595 ,28007 , 28386 ,28510 ,28856 ,29202 ,29515 ,29811 ,30090 ,30351 ,30339 ,30565 ,30774 ,30946 ,31119 ,31274 ,31393 , 31511 ,31594 ,31402 ,31448 ,31476 ,31486 ,31476 ,31448 ,31402 ,31338 ,31255 ,31137 ,31018 ,30863 ,30690 , 30518 ,30309 ,30083 ,29839 ,29578 ,29299 ,29003 ,28690 ,28344 ,27998 ,27618 ,27239 ,26827 ,26416 ,25972 , 25514 ,25040 ,24551 ,24048 ,23531 ,22999 ,22711 ,22152 ,21581 ,20979 ,20383 ,19775 ,19138 ,18506 ,17847 , 17194 ,16513 ,16080 ,15397 ,14689 ,13971 ,13245 ,12512 ,11771 ,11039 ,10541 ,9780 ,9013 ,8241 ,7464 , 6683 ,5880 ,5347 ,4554 ,3760 ,2962 ,2163 ,1363 ,562 ,0 ,-819 ,-1620 ,-2420 ,-3219 ,-4017 , -4811 ,-5347 ,-6137 ,-6940 ,-7721 ,-8498 ,-9270 ,-10037 ,-10541 ,-11296 ,-12028 ,-12769 ,-13502 ,-14228 ,-14946 , -15654 ,-16337 ,-16770 ,-17451 ,-18104 ,-18763 ,-19395 ,-20032 ,-20640 ,-21236 ,-21838 ,-22409 ,-22712 ,-23256 ,-23788 , -24305 ,-24808 ,-25297 ,-25770 ,-26229 ,-26673 ,-27084 ,-27496 ,-27874 ,-28255 ,-28601 ,-28947 ,-29260 ,-29556 ,-29835 , -30096 ,-30340 ,-30566 ,-30775 ,-30947 ,-31120 ,-31275 ,-31394 ,-31512 ,-31595 ,-31659 ,-31705 ,-31733 ,-31742 ,-31733 , -31705 ,-31659 ,-31595 ,-31768 ,-31650 ,-31531 ,-31376 ,-31203 ,-31031 ,-30822 ,-30596 ,-30352 ,-30347 ,-30068 ,-29772 , -29459 ,-29113 ,-28767 ,-28642 ,-28264 ,-27852 ,-27441 ,-26997 ,-26538 ,-26321 ,-25832 ,-25329 ,-24812 ,-24280 ,-23992 , -23433 ,-22862 ,-22260 ,-21664 ,-21312 ,-20675 ,-20043 ,-19384 ,-18987 ,-18306 ,-17616 ,-16933 ,-16481 ,-15764 ,-15038 , -14305 ,-13820 ,-13088 ,-12333 ,-11573 ,-11062 ,-10290 ,-9513 ,-8732 ,-8185 ,-7395 ,-6603 ,-6065 ,-5267 ,-4468 , -3668 ,-3123 ,4130 ,4929 ,5471 ,6269 ,6810 ,7606 ,8142 ,8933 ,9464 ,10283 ,10807 ,11328 ,12099 , 12610 ,13372 ,13871 ,14587 ,15074 ,15810 ,16283 ,17003 ,17460 ,18130 ,18570 ,19257 ,19644 ,20311 ,20678 , 21325 ,21926 ,22260 ,22874 ,23184 ,23740 ,24026 ,24556 ,25073 ,25321 ,25811 ,26032 ,26494 ,26943 ,27087 , 27506 ,27876 ,28009 ,28349 ,28707 ,28760 ,29053 ,29330 ,29591 ,29580 ,29808 ,30020 ,30180 ,30103 ,30265 , 30376 ,30503 ,30581 ,30384 ,30427 ,30453 ,30462 ,30453 ,30427 ,30384 ,30069 ,29991 ,29864 ,29753 ,29591 , 29412 ,29252 ,29040 ,28812 ,28567 ,28306 ,28029 ,27736 ,27427 ,27069 ,26729 ,26340 ,25970 ,25551 ,25151 , 24958 ,24496 ,24019 ,23529 ,23025 ,22508 ,21978 ,21692 ,21136 ,20570 ,19956 ,19366 ,18765 ,18374 ,17751 , 17084 ,16441 ,15755 ,15315 ,14645 ,13932 ,13211 ,12738 ,12002 ,11259 ,10543 ,10044 ,9282 ,8515 ,7744 , 7223 ,6443 ,5624 ,5093 ,4302 ,3510 ,2714 ,2173 ,1375 ,577 ,0 ,-834 ,-1632 ,-2430 ,-2971 , -3767 ,-4559 ,-5093 ,-5881 ,-6700 ,-7480 ,-8001 ,-8772 ,-9539 ,-10044 ,-10800 ,-11516 ,-12259 ,-12995 ,-13468 , -14189 ,-14902 ,-15572 ,-16012 ,-16698 ,-17341 ,-18008 ,-18631 ,-19022 ,-19623 ,-20213 ,-20827 ,-21393 ,-21693 ,-22235 , -22765 ,-23282 ,-23786 ,-24276 ,-24752 ,-25215 ,-25408 ,-25808 ,-26227 ,-26596 ,-26986 ,-27326 ,-27684 ,-27993 ,-28286 , -28563 ,-28824 ,-29069 ,-29297 ,-29509 ,-29669 ,-29848 ,-30010 ,-30121 ,-30248 ,-30326 ,-30641 ,-30684 ,-30710 ,-30718 , -30710 ,-30684 ,-30641 ,-30582 ,-30760 ,-30633 ,-30522 ,-30360 ,-30437 ,-30277 ,-30065 ,-29837 ,-29592 ,-29587 ,-29310 , -29017 ,-28964 ,-28606 ,-28266 ,-28132 ,-27763 ,-27344 ,-27200 ,-26751 ,-26288 ,-26068 ,-25578 ,-25330 ,-24813 ,-24283 , -23997 ,-23441 ,-23131 ,-22517 ,-21927 ,-21582 ,-20935 ,-20568 ,-19901 ,-19514 ,-18827 ,-18387 ,-17717 ,-17260 ,-16539 , -16067 ,-15331 ,-14844 ,-14128 ,-13628 ,-12867 ,-12356 ,-11585 ,-11064 ,-10284 ,-9721 ,-9189 ,-8399 ,-7863 ,-7067 , -6526 ,-5728 ,-5186 ,6451 ,6991 ,7531 ,8327 ,8866 ,9403 ,9938 ,10471 ,11257 ,11835 ,12359 ,12879 , 13394 ,13905 ,14667 ,15167 ,15611 ,16100 ,16838 ,17314 ,17782 ,18243 ,18902 ,19347 ,19784 ,20161 ,20836 , 21194 ,21594 ,22189 ,22517 ,22886 ,23449 ,23745 ,24029 ,24558 ,24818 ,25322 ,25558 ,25782 ,26248 ,26446 , 26834 ,27005 ,27366 ,27509 ,27842 ,27956 ,28261 ,28295 ,28570 ,28831 ,28821 ,29051 ,29010 ,29158 ,29343 , 29256 ,29358 ,29496 ,29567 ,29366 ,29406 ,29430 ,29438 ,29430 ,29150 ,29110 ,29055 ,28984 ,28846 ,28744 , 28575 ,28390 ,27986 ,27771 ,27541 ,27295 ,27034 ,26759 ,26469 ,26164 ,26050 ,25717 ,25318 ,24957 ,24530 , 24142 ,23688 ,23222 ,22998 ,22506 ,22002 ,21486 ,20957 ,20673 ,20121 ,19558 ,18933 ,18605 ,18010 ,17354 , 16740 ,16322 ,15689 ,14996 ,14551 ,13892 ,13175 ,12707 ,11975 ,11492 ,10747 ,10047 ,9547 ,8785 ,8018 , 7503 ,6727 ,6203 ,5369 ,4839 ,4050 ,3259 ,2722 ,1927 ,1387 ,591 ,0 ,-848 ,-1388 ,-2184 , -2979 ,-3516 ,-4307 ,-4839 ,-5626 ,-6204 ,-6983 ,-7759 ,-8275 ,-9042 ,-9547 ,-10304 ,-11004 ,-11493 ,-12231 , -12963 ,-13432 ,-14149 ,-14807 ,-15253 ,-15946 ,-16578 ,-16997 ,-17611 ,-18267 ,-18606 ,-19190 ,-19815 ,-20378 ,-20674 , -21214 ,-21742 ,-22259 ,-22763 ,-22999 ,-23478 ,-23945 ,-24398 ,-24787 ,-25214 ,-25574 ,-25718 ,-26051 ,-26421 ,-26726 , -27016 ,-27291 ,-27552 ,-27798 ,-28028 ,-28243 ,-28391 ,-28576 ,-28745 ,-29103 ,-29241 ,-29312 ,-29367 ,-29406 ,-29430 , -29694 ,-29686 ,-29662 ,-29623 ,-29568 ,-29753 ,-29615 ,-29513 ,-29600 ,-29415 ,-29267 ,-29308 ,-29078 ,-28832 ,-28827 , -28552 ,-28518 ,-28213 ,-28099 ,-27766 ,-27622 ,-27262 ,-27091 ,-26702 ,-26505 ,-26038 ,-25815 ,-25323 ,-25075 ,-24814 , -24286 ,-24002 ,-23450 ,-23143 ,-22774 ,-22190 ,-21851 ,-21451 ,-20837 ,-20418 ,-20041 ,-19604 ,-18902 ,-18500 ,-18039 , -17570 ,-16838 ,-16357 ,-15868 ,-15424 ,-14667 ,-14162 ,-13651 ,-13135 ,-12615 ,-11836 ,-11258 ,-10727 ,-10195 ,-9660 , -9123 ,-8328 ,-7788 ,-7248 ,8516 ,9054 ,9592 ,10129 ,10665 ,11201 ,11733 ,12265 ,12793 ,13388 ,13654 , 14173 ,14688 ,15199 ,15706 ,16207 ,16635 ,17125 ,17610 ,18089 ,18562 ,19027 ,19417 ,19868 ,20311 ,20678 , 21105 ,21455 ,21864 ,22451 ,22773 ,23155 ,23457 ,23750 ,24031 ,24303 ,24819 ,25068 ,25306 ,25532 ,25746 , 26204 ,26326 ,26503 ,26856 ,27008 ,27079 ,27461 ,27505 ,27793 ,27811 ,28071 ,28061 ,28038 ,28257 ,28392 , 28327 ,28503 ,28341 ,28488 ,28554 ,28348 ,28384 ,28406 ,28158 ,28150 ,28128 ,28092 ,27786 ,27720 ,27573 , 27479 ,27303 ,27112 ,26977 ,26758 ,26525 ,26279 ,26019 ,25745 ,25457 ,25157 ,24775 ,24448 ,24040 ,23687 , 23254 ,22876 ,22674 ,22204 ,21722 ,21228 ,20979 ,20463 ,19935 ,19654 ,19105 ,18547 ,18165 ,17587 ,17000 , 16591 ,15986 ,15303 ,14936 ,14237 ,13786 ,13140 ,12675 ,11946 ,11467 ,10726 ,10236 ,9551 ,9050 ,8287 , 7776 ,7005 ,6486 ,5708 ,5113 ,4585 ,3797 ,3265 ,2473 ,1937 ,1144 ,606 ,0 ,-863 ,-1401 , -2194 ,-2730 ,-3522 ,-4054 ,-4585 ,-5370 ,-5965 ,-6743 ,-7262 ,-8033 ,-8544 ,-9050 ,-9808 ,-10493 ,-10983 , -11724 ,-12203 ,-12932 ,-13397 ,-14043 ,-14494 ,-15193 ,-15560 ,-16243 ,-16848 ,-17257 ,-17844 ,-18422 ,-18804 ,-19362 , -19655 ,-20192 ,-20720 ,-21236 ,-21485 ,-21979 ,-22460 ,-22931 ,-23133 ,-23511 ,-23944 ,-24296 ,-24705 ,-25032 ,-25414 , -25714 ,-26002 ,-26276 ,-26536 ,-26782 ,-27015 ,-27234 ,-27369 ,-27560 ,-27736 ,-27830 ,-27977 ,-28043 ,-28349 ,-28385 , -28407 ,-28414 ,-28663 ,-28641 ,-28605 ,-28555 ,-28745 ,-28598 ,-28760 ,-28584 ,-28649 ,-28514 ,-28295 ,-28318 ,-28072 , -28068 ,-28050 ,-27762 ,-27718 ,-27336 ,-27265 ,-27112 ,-26760 ,-26583 ,-26461 ,-26003 ,-25788 ,-25563 ,-25325 ,-25076 , -24560 ,-24288 ,-24007 ,-23714 ,-23412 ,-23030 ,-22452 ,-22121 ,-21712 ,-21362 ,-20935 ,-20568 ,-20125 ,-19674 ,-19284 , -18819 ,-18346 ,-17867 ,-17382 ,-16892 ,-16463 ,-15962 ,-15456 ,-14945 ,-14430 ,-13911 ,-13389 ,-13050 ,-12521 ,-11990 , -11458 ,-10922 ,-10386 ,-9849 ,-9311 ,10837 ,11373 ,11652 ,12187 ,12721 ,12999 ,13529 ,14059 ,14330 ,14940 , 15205 ,15724 ,16239 ,16493 ,17000 ,17502 ,17915 ,18152 ,18639 ,19121 ,19341 ,19810 ,20188 ,20645 ,20838 , 21195 ,21630 ,21971 ,22390 ,22714 ,23030 ,23168 ,23466 ,23755 ,24034 ,24304 ,24564 ,24814 ,25053 ,25282 , 25500 ,25707 ,26074 ,26258 ,26346 ,26508 ,26572 ,26710 ,27006 ,27035 ,27051 ,27311 ,27302 ,27281 ,27503 , 27370 ,27567 ,27494 ,27580 ,27481 ,27540 ,27330 ,27363 ,27383 ,27134 ,27127 ,27107 ,26818 ,26772 ,26713 , 26556 ,26214 ,26031 ,25834 ,25711 ,25489 ,25254 ,25007 ,24747 ,24475 ,24190 ,23894 ,23500 ,23180 ,23018 , 22674 ,22234 ,21867 ,21404 ,21186 ,20701 ,20206 ,19956 ,19440 ,18914 ,18635 ,18090 ,17536 ,17142 ,16570 , 16247 ,15572 ,15231 ,14540 ,14183 ,13478 ,13021 ,12387 ,11918 ,11442 ,10704 ,10217 ,9724 ,9055 ,8553 , 7790 ,7279 ,6764 ,5989 ,5468 ,4858 ,4331 ,3545 ,3015 ,2481 ,1691 ,1156 ,621 ,0 ,-621 , -1413 ,-1948 ,-2482 ,-3271 ,-3802 ,-4331 ,-5115 ,-5725 ,-6246 ,-6765 ,-7535 ,-8047 ,-8553 ,-9312 ,-9725 , -10473 ,-10961 ,-11443 ,-12175 ,-12644 ,-13278 ,-13735 ,-14184 ,-14797 ,-15231 ,-15829 ,-16247 ,-16827 ,-17399 ,-17792 , -18346 ,-18636 ,-19171 ,-19697 ,-19957 ,-20462 ,-20958 ,-21186 ,-21660 ,-22124 ,-22490 ,-22675 ,-23018 ,-23436 ,-23757 , -24150 ,-24447 ,-24732 ,-25004 ,-25264 ,-25511 ,-25746 ,-25968 ,-26091 ,-26288 ,-26471 ,-26556 ,-26714 ,-27029 ,-27075 , -27108 ,-27384 ,-27390 ,-27384 ,-27620 ,-27587 ,-27541 ,-27738 ,-27580 ,-27751 ,-27568 ,-27627 ,-27504 ,-27538 ,-27559 , -27312 ,-27308 ,-27292 ,-27007 ,-26966 ,-26829 ,-26764 ,-26602 ,-26259 ,-26074 ,-25964 ,-25756 ,-25538 ,-25310 ,-25070 , -24821 ,-24561 ,-24291 ,-24012 ,-23722 ,-23424 ,-23031 ,-22715 ,-22390 ,-22228 ,-21886 ,-21452 ,-21095 ,-20646 ,-20445 , -20067 ,-19598 ,-19122 ,-18896 ,-18408 ,-17916 ,-17503 ,-17256 ,-16750 ,-16239 ,-15981 ,-15462 ,-14941 ,-14587 ,-14059 , -13786 ,-13255 ,-12722 ,-12444 ,-11909 ,-11373 ,12902 ,13435 ,13712 ,14245 ,14521 ,14796 ,15325 ,15597 ,16122 , 16491 ,16756 ,17018 ,17532 ,17787 ,18295 ,18542 ,18939 ,19178 ,19668 ,19897 ,20120 ,20594 ,20960 ,21166 , 21365 ,21712 ,22154 ,22231 ,22659 ,22977 ,23031 ,23436 ,23730 ,23760 ,24037 ,24306 ,24565 ,24815 ,24800 , 25032 ,25253 ,25466 ,25565 ,25757 ,25836 ,26007 ,26065 ,26214 ,26251 ,26277 ,26291 ,26551 ,26543 ,26524 , 26493 ,26604 ,26551 ,26485 ,26562 ,26473 ,26527 ,26312 ,26342 ,26104 ,26110 ,26104 ,25830 ,25800 ,25503 , 25449 ,25282 ,25205 ,25015 ,24812 ,24445 ,24220 ,23983 ,23735 ,23475 ,23205 ,22923 ,22630 ,22481 ,22167 , 21740 ,21405 ,20957 ,20602 ,20389 ,19912 ,19680 ,19183 ,18677 ,18418 ,17893 ,17616 ,17074 ,16524 ,16120 , 15810 ,15236 ,14808 ,14219 ,13777 ,13174 ,12719 ,12257 ,11635 ,11161 ,10682 ,10197 ,9707 ,8956 ,8559 , 8056 ,7292 ,6781 ,6267 ,5749 ,5228 ,4602 ,4077 ,3293 ,2764 ,2233 ,1701 ,1168 ,379 ,0 , -636 ,-1169 ,-1958 ,-2490 ,-3021 ,-3550 ,-4077 ,-4859 ,-5229 ,-6005 ,-6523 ,-7038 ,-7549 ,-8056 ,-8816 , -9213 ,-9708 ,-10453 ,-10938 ,-11418 ,-11892 ,-12513 ,-12976 ,-13431 ,-14034 ,-14476 ,-15065 ,-15493 ,-15811 ,-16377 , -16781 ,-17331 ,-17617 ,-18150 ,-18674 ,-18934 ,-19440 ,-19681 ,-20168 ,-20646 ,-20858 ,-21214 ,-21662 ,-21996 ,-22168 , -22482 ,-22887 ,-23180 ,-23462 ,-23732 ,-23992 ,-24240 ,-24477 ,-24702 ,-24813 ,-25016 ,-25206 ,-25539 ,-25706 ,-25760 , -26057 ,-26086 ,-26104 ,-26366 ,-26360 ,-26598 ,-26569 ,-26528 ,-26730 ,-26819 ,-26742 ,-26808 ,-26861 ,-26750 ,-26781 , -26800 ,-26552 ,-26548 ,-26534 ,-26508 ,-26471 ,-26322 ,-26264 ,-26092 ,-26014 ,-25822 ,-25722 ,-25510 ,-25288 ,-25057 , -24816 ,-24822 ,-24562 ,-24294 ,-24017 ,-23731 ,-23693 ,-23288 ,-22978 ,-22916 ,-22488 ,-22155 ,-21969 ,-21622 ,-21423 , -20960 ,-20851 ,-20377 ,-20153 ,-19668 ,-19435 ,-19196 ,-18799 ,-18295 ,-18044 ,-17789 ,-17274 ,-17012 ,-16492 ,-16123 , -15853 ,-15582 ,-15053 ,-14778 ,-14246 ,-13969 ,-13692 ,15223 ,15498 ,15772 ,16047 ,16321 ,16593 ,17120 ,17390 , 17658 ,18043 ,18307 ,18568 ,18826 ,19082 ,19334 ,19582 ,19963 ,20204 ,20440 ,20672 ,20899 ,21377 ,21475 , 21687 ,21892 ,22229 ,22423 ,22747 ,22929 ,23240 ,23288 ,23449 ,23738 ,23765 ,24040 ,24307 ,24310 ,24561 , 24547 ,24782 ,25007 ,24968 ,25057 ,25256 ,25326 ,25506 ,25558 ,25463 ,25496 ,25519 ,25531 ,25791 ,25784 , 25767 ,25739 ,25582 ,25535 ,25476 ,25545 ,25466 ,25513 ,25294 ,25320 ,25080 ,25086 ,24824 ,24808 ,24526 , 24489 ,24186 ,24009 ,23940 ,23743 ,23534 ,23179 ,22951 ,22712 ,22463 ,22203 ,21935 ,21656 ,21367 ,21206 , 20898 ,20462 ,20136 ,19937 ,19592 ,19119 ,18894 ,18403 ,18161 ,17654 ,17395 ,16872 ,16597 ,16059 ,15514 , 15097 ,14793 ,14226 ,13788 ,13464 ,13014 ,12421 ,11960 ,11492 ,10882 ,10404 ,9921 ,9433 ,8941 ,8444 , 8063 ,7559 ,6795 ,6283 ,5769 ,5252 ,4732 ,4347 ,3823 ,3041 ,2514 ,1985 ,1455 ,924 ,394 , 0 ,-651 ,-1181 ,-1712 ,-2242 ,-2771 ,-3298 ,-3823 ,-4604 ,-4989 ,-5509 ,-6026 ,-6540 ,-7052 ,-7559 , -8320 ,-8701 ,-9198 ,-9690 ,-10178 ,-10661 ,-11139 ,-11749 ,-12217 ,-12678 ,-13271 ,-13721 ,-14045 ,-14483 ,-15050 , -15354 ,-15771 ,-16316 ,-16598 ,-17129 ,-17652 ,-17911 ,-18418 ,-18660 ,-19150 ,-19376 ,-19849 ,-20194 ,-20393 ,-20718 , -21155 ,-21463 ,-21624 ,-21913 ,-22192 ,-22460 ,-22720 ,-22969 ,-23208 ,-23436 ,-23791 ,-24000 ,-24197 ,-24266 ,-24443 , -24746 ,-24783 ,-25065 ,-25081 ,-25342 ,-25337 ,-25577 ,-25551 ,-25514 ,-25723 ,-25802 ,-25733 ,-25792 ,-25839 ,-25996 , -26024 ,-26041 ,-25792 ,-25788 ,-25776 ,-25753 ,-25720 ,-25815 ,-25763 ,-25582 ,-25513 ,-25314 ,-25225 ,-25264 ,-25038 , -24804 ,-24818 ,-24567 ,-24564 ,-24297 ,-24022 ,-23995 ,-23706 ,-23545 ,-23241 ,-23186 ,-23004 ,-22680 ,-22486 ,-22149 , -21944 ,-21732 ,-21634 ,-21156 ,-20929 ,-20697 ,-20461 ,-20220 ,-19839 ,-19590 ,-19339 ,-19083 ,-18825 ,-18564 ,-18044 , -17915 ,-17646 ,-17377 ,-16850 ,-16577 ,-16304 ,-16029 ,-15755 ,17287 ,17559 ,17832 ,18104 ,18375 ,18646 ,18659 , 18928 ,19194 ,19596 ,19602 ,19863 ,20121 ,20376 ,20629 ,20878 ,20988 ,21230 ,21469 ,21704 ,21935 ,21905 , 22246 ,22463 ,22676 ,22746 ,22948 ,23008 ,23198 ,23502 ,23544 ,23717 ,23747 ,24026 ,24042 ,24052 ,24311 , 24306 ,24551 ,24532 ,24505 ,24727 ,24804 ,24754 ,24816 ,24750 ,24795 ,24968 ,24996 ,25016 ,25028 ,25030 , 24768 ,24753 ,24730 ,24816 ,24774 ,24724 ,24527 ,24458 ,24500 ,24276 ,24043 ,24057 ,23806 ,23801 ,23531 , 23508 ,23220 ,23178 ,22991 ,22676 ,22470 ,22256 ,22170 ,21937 ,21696 ,21446 ,21188 ,20920 ,20644 ,20360 , 19931 ,19630 ,19440 ,19122 ,18660 ,18327 ,18105 ,17620 ,17383 ,16882 ,16631 ,16117 ,15851 ,15579 ,15044 , 14758 ,14329 ,13775 ,13471 ,13025 ,12453 ,11995 ,11669 ,11200 ,10727 ,10386 ,9904 ,9417 ,8926 ,8431 , 7933 ,7311 ,7062 ,6553 ,6042 ,5528 ,5011 ,4493 ,3835 ,3569 ,3044 ,2519 ,1992 ,1465 ,937 , 408 ,0 ,-665 ,-1194 ,-1722 ,-2249 ,-2776 ,-3301 ,-3569 ,-4092 ,-4750 ,-5268 ,-5785 ,-6299 ,-6810 , -7062 ,-7568 ,-8190 ,-8688 ,-9183 ,-9674 ,-10161 ,-10643 ,-10984 ,-11457 ,-11926 ,-12252 ,-12710 ,-13282 ,-13728 , -14032 ,-14586 ,-15015 ,-15301 ,-15580 ,-16108 ,-16374 ,-16888 ,-17139 ,-17640 ,-17876 ,-18362 ,-18584 ,-18917 ,-19379 , -19696 ,-19887 ,-20188 ,-20617 ,-20901 ,-21177 ,-21445 ,-21703 ,-21953 ,-22194 ,-22427 ,-22513 ,-22727 ,-22933 ,-23248 , -23435 ,-23477 ,-23765 ,-23788 ,-24058 ,-24062 ,-24314 ,-24300 ,-24533 ,-24501 ,-24715 ,-24784 ,-24981 ,-25031 ,-25073 , -24987 ,-25010 ,-25025 ,-25031 ,-25285 ,-25273 ,-25253 ,-25225 ,-25052 ,-25007 ,-25072 ,-25011 ,-25061 ,-24984 ,-24762 , -24788 ,-24808 ,-24563 ,-24568 ,-24309 ,-24299 ,-24283 ,-24004 ,-23974 ,-23801 ,-23503 ,-23455 ,-23265 ,-23205 ,-23003 , -22933 ,-22720 ,-22503 ,-22162 ,-22192 ,-21961 ,-21726 ,-21487 ,-21245 ,-21135 ,-20885 ,-20633 ,-20378 ,-20120 ,-19859 , -19597 ,-19451 ,-19184 ,-18916 ,-18903 ,-18632 ,-18361 ,-18089 ,-17816 ,19608 ,19622 ,19892 ,20162 ,20175 ,20444 , 20455 ,20722 ,20987 ,21148 ,21154 ,21414 ,21415 ,21671 ,21924 ,21918 ,22012 ,22256 ,22498 ,22480 ,22714 , 22688 ,23018 ,22984 ,23203 ,23263 ,23473 ,23524 ,23468 ,23765 ,23801 ,23730 ,24011 ,24031 ,24045 ,24054 , 24056 ,24308 ,24298 ,24282 ,24259 ,24230 ,24296 ,24253 ,24306 ,24249 ,24288 ,24217 ,24241 ,24258 ,24268 , 24270 ,24009 ,23996 ,23976 ,23794 ,23758 ,23715 ,23510 ,23451 ,23486 ,23258 ,23022 ,23034 ,22782 ,22778 , 22510 ,22234 ,22206 ,21915 ,21718 ,21667 ,21454 ,21234 ,20904 ,20668 ,20425 ,20174 ,19916 ,19650 ,19377 , 19097 ,18912 ,18617 ,18162 ,17853 ,17640 ,17318 ,16835 ,16602 ,16363 ,15861 ,15609 ,15095 ,14830 ,14560 , 14028 ,13747 ,13306 ,13014 ,12461 ,12005 ,11698 ,11232 ,10916 ,10441 ,9963 ,9633 ,9147 ,8657 ,8163 , 7921 ,7421 ,6815 ,6565 ,6056 ,5544 ,5031 ,4515 ,4253 ,3580 ,3315 ,2792 ,2269 ,1744 ,1219 , 949 ,423 ,0 ,-680 ,-950 ,-1476 ,-2001 ,-2526 ,-3049 ,-3315 ,-3837 ,-4254 ,-4771 ,-5287 ,-5801 , -6313 ,-6565 ,-7072 ,-7678 ,-7922 ,-8419 ,-8913 ,-9404 ,-9890 ,-10219 ,-10698 ,-11173 ,-11489 ,-11955 ,-12262 , -12718 ,-13015 ,-13563 ,-14004 ,-14285 ,-14561 ,-15087 ,-15351 ,-15866 ,-16118 ,-16364 ,-16858 ,-17092 ,-17574 ,-17897 , -18110 ,-18418 ,-18618 ,-18913 ,-19354 ,-19634 ,-19907 ,-20173 ,-20431 ,-20682 ,-20925 ,-21161 ,-21235 ,-21455 ,-21668 , -21975 ,-22172 ,-22463 ,-22491 ,-22766 ,-22778 ,-23038 ,-23290 ,-23278 ,-23515 ,-23487 ,-23708 ,-23767 ,-23972 ,-24015 , -24051 ,-24233 ,-24253 ,-24266 ,-24271 ,-24525 ,-24515 ,-24498 ,-24474 ,-24545 ,-24506 ,-24562 ,-24510 ,-24553 ,-24486 , -24516 ,-24538 ,-24555 ,-24309 ,-24313 ,-24310 ,-24302 ,-24288 ,-24012 ,-23987 ,-24058 ,-23766 ,-23725 ,-23781 ,-23474 , -23520 ,-23460 ,-23241 ,-23018 ,-22945 ,-22971 ,-22736 ,-22498 ,-22513 ,-22269 ,-22175 ,-21924 ,-21928 ,-21672 ,-21670 , -21410 ,-21149 ,-20988 ,-20978 ,-20712 ,-20701 ,-20432 ,-20163 ,-20149 ,-19879 ,21673 ,21941 ,21952 ,21964 ,22231 , 22242 ,22251 ,22516 ,22523 ,22700 ,22705 ,22708 ,22966 ,22965 ,22963 ,23214 ,23292 ,23283 ,23270 ,23511 , 23493 ,23472 ,23533 ,23761 ,23730 ,23780 ,23742 ,23784 ,23994 ,24028 ,24058 ,23999 ,24020 ,24036 ,24048 , 24055 ,24057 ,24054 ,24045 ,24032 ,24013 ,23988 ,24044 ,24008 ,23796 ,23749 ,23781 ,23722 ,23742 ,23500 , 23508 ,23510 ,23250 ,23239 ,23222 ,23028 ,22998 ,22706 ,22749 ,22443 ,22473 ,22240 ,22000 ,22010 ,21758 , 21498 ,21488 ,21216 ,20937 ,20907 ,20701 ,20402 ,20182 ,19956 ,19638 ,19399 ,19154 ,18902 ,18644 ,18380 , 18110 ,17834 ,17637 ,17349 ,17140 ,16840 ,16365 ,16053 ,15822 ,15585 ,15086 ,14839 ,14586 ,14072 ,13809 , 13541 ,13013 ,12736 ,12283 ,11997 ,11707 ,11241 ,10943 ,10469 ,10163 ,9682 ,9198 ,8881 ,8390 ,8152 , 7655 ,7156 ,6909 ,6319 ,6068 ,5558 ,5047 ,4789 ,4274 ,3757 ,3324 ,3061 ,2540 ,2019 ,1752 , 1229 ,705 ,438 ,0 ,-438 ,-962 ,-1486 ,-1753 ,-2275 ,-2797 ,-3061 ,-3581 ,-4014 ,-4531 ,-4790 , -5303 ,-5815 ,-6068 ,-6576 ,-6910 ,-7412 ,-7912 ,-8153 ,-8647 ,-9138 ,-9455 ,-9939 ,-10164 ,-10726 ,-10943 , -11498 ,-11707 ,-12254 ,-12540 ,-12992 ,-13269 ,-13542 ,-14066 ,-14329 ,-14587 ,-15095 ,-15343 ,-15585 ,-16078 ,-16310 , -16620 ,-16841 ,-17140 ,-17605 ,-17894 ,-18090 ,-18367 ,-18637 ,-18901 ,-19159 ,-19411 ,-19656 ,-19895 ,-20213 ,-20439 , -20659 ,-20701 ,-20908 ,-21194 ,-21473 ,-21489 ,-21755 ,-22014 ,-22011 ,-22257 ,-22497 ,-22474 ,-22700 ,-22749 ,-22963 , -22999 ,-23285 ,-23223 ,-23496 ,-23507 ,-23511 ,-23765 ,-23757 ,-23743 ,-23978 ,-24038 ,-24005 ,-24052 ,-24009 ,-24044 , -24245 ,-24269 ,-24288 ,-24302 ,-24310 ,-24314 ,-24312 ,-24305 ,-24293 ,-24276 ,-24255 ,-24059 ,-24029 ,-23994 ,-24041 , -23998 ,-24037 ,-23987 ,-23762 ,-23790 ,-23729 ,-23750 ,-23512 ,-23527 ,-23539 ,-23293 ,-23215 ,-23219 ,-23222 ,-22966 , -22965 ,-22962 ,-22701 ,-22780 ,-22516 ,-22508 ,-22498 ,-22232 ,-22221 ,-22209 ,-21941 ,23994 ,24003 ,24012 ,24022 , 24031 ,24039 ,24047 ,24054 ,24060 ,24252 ,24256 ,24259 ,24260 ,24260 ,24258 ,24254 ,24316 ,24309 ,24299 , 24287 ,24272 ,24255 ,24304 ,24282 ,24257 ,24297 ,24266 ,24300 ,24263 ,24291 ,24059 ,24011 ,24028 ,24041 , 24051 ,24056 ,23802 ,23799 ,23792 ,23782 ,23766 ,23491 ,23535 ,23507 ,23286 ,23248 ,23274 ,22970 ,22987 , 22742 ,22748 ,22750 ,22491 ,22482 ,22212 ,22006 ,21982 ,21697 ,21731 ,21436 ,21459 ,21222 ,20979 ,20731 , 20734 ,20475 ,20211 ,19942 ,19923 ,19644 ,19427 ,19137 ,18910 ,18678 ,18372 ,18130 ,17883 ,17630 ,17372 , 17110 ,16843 ,16570 ,16363 ,16081 ,15863 ,15572 ,15344 ,15044 ,14551 ,14311 ,14065 ,13816 ,13307 ,13049 , 12788 ,12522 ,11997 ,11724 ,11260 ,10980 ,10696 ,10221 ,9931 ,9706 ,9154 ,8923 ,8433 ,8128 ,7633 , 7392 ,6892 ,6646 ,6141 ,5823 ,5571 ,5061 ,4549 ,4292 ,3777 ,3517 ,3069 ,2807 ,2288 ,1768 , 1504 ,983 ,717 ,196 ,0 ,-453 ,-974 ,-1240 ,-1761 ,-2025 ,-2545 ,-2807 ,-3326 ,-3774 ,-4034 , -4549 ,-4806 ,-5318 ,-5571 ,-6080 ,-6398 ,-6903 ,-7149 ,-7649 ,-7890 ,-8385 ,-8690 ,-9180 ,-9411 ,-9963 , -10188 ,-10478 ,-10953 ,-11237 ,-11517 ,-11981 ,-12254 ,-12523 ,-13045 ,-13306 ,-13564 ,-14073 ,-14322 ,-14567 ,-14808 , -15301 ,-15601 ,-15829 ,-16119 ,-16338 ,-16619 ,-16827 ,-17100 ,-17367 ,-17629 ,-17887 ,-18140 ,-18387 ,-18629 ,-18935 , -19167 ,-19394 ,-19684 ,-19901 ,-20180 ,-20199 ,-20468 ,-20732 ,-20990 ,-20988 ,-21236 ,-21479 ,-21460 ,-21693 ,-21988 , -21954 ,-22239 ,-22263 ,-22469 ,-22739 ,-22748 ,-22751 ,-23005 ,-22999 ,-23244 ,-23227 ,-23531 ,-23505 ,-23542 ,-23764 , -23792 ,-23748 ,-24023 ,-24038 ,-24049 ,-24056 ,-24059 ,-24313 ,-24308 ,-24298 ,-24285 ,-24268 ,-24316 ,-24292 ,-24520 , -24557 ,-24523 ,-24554 ,-24514 ,-24539 ,-24561 ,-24512 ,-24529 ,-24544 ,-24556 ,-24566 ,-24573 ,-24511 ,-24514 ,-24517 , -24517 ,-24516 ,-24513 ,-24253 ,-24317 ,-24310 ,-24304 ,-24296 ,-24288 ,-24279 ,-24269 ,-24260 ,26059 ,26066 ,26073 , 26080 ,25830 ,25837 ,25842 ,25848 ,25852 ,25805 ,25552 ,25554 ,25554 ,25554 ,25553 ,25294 ,25341 ,25335 , 25328 ,25063 ,25052 ,25039 ,25076 ,24803 ,24784 ,24814 ,24791 ,24561 ,24533 ,24553 ,24315 ,24280 ,24292 , 24046 ,24053 ,23802 ,23803 ,23801 ,23540 ,23532 ,23264 ,23250 ,23027 ,23005 ,22776 ,22747 ,22511 ,22475 , 22231 ,22240 ,21989 ,21990 ,21731 ,21469 ,21459 ,21240 ,20966 ,20944 ,20714 ,20428 ,20446 ,20204 ,19958 , 19708 ,19454 ,19452 ,19190 ,18924 ,18654 ,18380 ,18154 ,18128 ,17894 ,17656 ,17363 ,17117 ,16867 ,16614 , 16358 ,16097 ,15832 ,15564 ,15344 ,15068 ,14585 ,14302 ,14068 ,13779 ,13537 ,13293 ,13045 ,12538 ,12284 , 12027 ,11766 ,11503 ,10981 ,10713 ,10492 ,10218 ,9686 ,9458 ,9176 ,8687 ,8401 ,8164 ,7669 ,7376 , 7133 ,6632 ,6385 ,6136 ,5630 ,5327 ,5074 ,4563 ,4307 ,3795 ,3537 ,3278 ,2813 ,2553 ,2035 , 1774 ,1255 ,993 ,730 ,211 ,0 ,-468 ,-731 ,-1250 ,-1512 ,-2031 ,-2292 ,-2553 ,-3070 ,-3279 , -3793 ,-4051 ,-4564 ,-4820 ,-5074 ,-5584 ,-5887 ,-6137 ,-6641 ,-6888 ,-7390 ,-7633 ,-7925 ,-8421 ,-8658 , -8944 ,-9433 ,-9715 ,-9943 ,-10219 ,-10749 ,-10970 ,-11238 ,-11504 ,-12023 ,-12283 ,-12541 ,-12795 ,-13046 ,-13549 , -13794 ,-14035 ,-14325 ,-14559 ,-14841 ,-15069 ,-15345 ,-15821 ,-16089 ,-16354 ,-16614 ,-16871 ,-17124 ,-17374 ,-17620 , -17657 ,-17895 ,-18129 ,-18411 ,-18637 ,-18911 ,-19181 ,-19446 ,-19452 ,-19710 ,-19964 ,-20214 ,-20461 ,-20447 ,-20685 , -20971 ,-21201 ,-21223 ,-21497 ,-21716 ,-21726 ,-21988 ,-21991 ,-22246 ,-22497 ,-22488 ,-22732 ,-22768 ,-23004 ,-23032 , -23262 ,-23284 ,-23506 ,-23521 ,-23788 ,-23797 ,-23802 ,-24060 ,-24058 ,-24310 ,-24303 ,-24293 ,-24537 ,-24572 ,-24554 , -24790 ,-24818 ,-24792 ,-25071 ,-25041 ,-25060 ,-25076 ,-25296 ,-25309 ,-25319 ,-25328 ,-25592 ,-25598 ,-25551 ,-25553 , -25811 ,-25811 ,-25810 ,-25808 ,-25806 ,-25853 ,-26104 ,-26099 ,-26094 ,-26087 ,-26081 ,-26330 ,-26323 ,28380 ,28128 , 28133 ,27882 ,27886 ,27634 ,27638 ,27386 ,27389 ,27357 ,27103 ,27104 ,26849 ,26849 ,26592 ,26590 ,26365 , 26361 ,26100 ,26094 ,25831 ,25822 ,25591 ,25580 ,25311 ,25331 ,25060 ,25077 ,24802 ,24816 ,24572 ,24292 , 24301 ,24051 ,24056 ,23803 ,23548 ,23546 ,23287 ,23282 ,23018 ,22752 ,22774 ,22504 ,22266 ,22247 ,22004 , 21724 ,21732 ,21482 ,21229 ,21230 ,20972 ,20712 ,20449 ,20218 ,20206 ,19935 ,19696 ,19421 ,19432 ,19186 , 18936 ,18684 ,18430 ,18172 ,17912 ,17650 ,17640 ,17373 ,17136 ,16863 ,16622 ,16379 ,16098 ,15849 ,15597 , 15343 ,15086 ,14827 ,14565 ,14301 ,14069 ,13800 ,13563 ,13289 ,13047 ,12769 ,12267 ,12019 ,11768 ,11515 , 11261 ,11004 ,10745 ,10484 ,9966 ,9701 ,9469 ,9201 ,8931 ,8438 ,8165 ,7924 ,7648 ,7405 ,6904 , 6623 ,6376 ,6127 ,5621 ,5370 ,5118 ,4831 ,4577 ,4066 ,3810 ,3553 ,3040 ,2782 ,2558 ,2299 , 1783 ,1523 ,1263 ,747 ,486 ,225 ,0 ,-482 ,-743 ,-1004 ,-1520 ,-1780 ,-2040 ,-2299 ,-2815 , -3039 ,-3297 ,-3810 ,-4067 ,-4323 ,-4577 ,-5088 ,-5375 ,-5627 ,-5878 ,-6384 ,-6633 ,-6880 ,-7161 ,-7662 , -7905 ,-8181 ,-8422 ,-8695 ,-9188 ,-9458 ,-9726 ,-9958 ,-10223 ,-10485 ,-11002 ,-11261 ,-11518 ,-11772 ,-12025 , -12275 ,-12524 ,-13026 ,-13304 ,-13546 ,-13819 ,-14057 ,-14326 ,-14558 ,-14822 ,-15084 ,-15343 ,-15600 ,-15854 ,-16106 , -16355 ,-16635 ,-16879 ,-17120 ,-17393 ,-17630 ,-17897 ,-17907 ,-18169 ,-18429 ,-18686 ,-18941 ,-19193 ,-19443 ,-19433 , -19678 ,-19953 ,-20192 ,-20463 ,-20475 ,-20706 ,-20969 ,-21229 ,-21231 ,-21486 ,-21739 ,-21989 ,-21981 ,-22261 ,-22504 , -22522 ,-22761 ,-23031 ,-23009 ,-23275 ,-23538 ,-23544 ,-23803 ,-23805 ,-24060 ,-24313 ,-24308 ,-24558 ,-24549 ,-24829 , -24817 ,-25059 ,-25334 ,-25317 ,-25588 ,-25568 ,-25837 ,-25848 ,-26079 ,-26088 ,-26351 ,-26357 ,-26618 ,-26622 ,-26847 , -26848 ,-27106 ,-27106 ,-27361 ,-27360 ,-27358 ,-27646 ,-27642 ,-27895 ,-27891 ,-28143 ,-28139 ,-28390 ,-28385 ,30445 , 30191 ,30193 ,29940 ,29686 ,29432 ,29434 ,29180 ,28925 ,28909 ,28654 ,28399 ,28143 ,28143 ,27887 ,27630 , 27389 ,27387 ,27129 ,26870 ,26610 ,26606 ,26362 ,26101 ,25838 ,25848 ,25585 ,25337 ,25072 ,25079 ,24829 , 24561 ,24309 ,24056 ,24059 ,23804 ,23549 ,23292 ,23034 ,23032 ,22772 ,22511 ,22266 ,22003 ,21756 ,21746 , 21497 ,21229 ,20977 ,20724 ,20469 ,20470 ,20213 ,19955 ,19695 ,19452 ,19190 ,18926 ,18679 ,18413 ,18419 , 18168 ,17915 ,17661 ,17406 ,17149 ,16891 ,16632 ,16372 ,16110 ,15864 ,15599 ,15351 ,15101 ,14832 ,14580 , 14326 ,14071 ,13814 ,13557 ,13298 ,13038 ,12794 ,12531 ,12285 ,12020 ,11771 ,11504 ,11253 ,11001 ,10747 , 10493 ,10238 ,9981 ,9724 ,9465 ,8950 ,8690 ,8446 ,8184 ,7921 ,7674 ,7410 ,7161 ,6895 ,6646 , 6139 ,5871 ,5619 ,5367 ,5114 ,4860 ,4606 ,4335 ,4080 ,3568 ,3312 ,3056 ,2799 ,2542 ,2302 , 2045 ,1531 ,1273 ,1015 ,757 ,498 ,240 ,0 ,-497 ,-755 ,-1014 ,-1272 ,-1530 ,-1788 ,-2045 , -2559 ,-2799 ,-3056 ,-3313 ,-3569 ,-3825 ,-4080 ,-4592 ,-4863 ,-5117 ,-5371 ,-5624 ,-5876 ,-6128 ,-6396 , -6903 ,-7152 ,-7418 ,-7667 ,-7931 ,-8178 ,-8441 ,-8703 ,-8947 ,-9207 ,-9466 ,-9981 ,-10238 ,-10495 ,-10750 , -11004 ,-11257 ,-11510 ,-11761 ,-12028 ,-12277 ,-12541 ,-12788 ,-13051 ,-13295 ,-13555 ,-13814 ,-14071 ,-14328 ,-14583 , -14837 ,-15089 ,-15358 ,-15608 ,-15856 ,-16121 ,-16367 ,-16628 ,-16889 ,-17148 ,-17406 ,-17662 ,-17918 ,-18172 ,-18425 , -18420 ,-18670 ,-18936 ,-19183 ,-19447 ,-19709 ,-19952 ,-20212 ,-20470 ,-20471 ,-20726 ,-20981 ,-21234 ,-21486 ,-21754 , -22003 ,-22012 ,-22260 ,-22523 ,-22768 ,-23029 ,-23288 ,-23291 ,-23549 ,-23806 ,-24061 ,-24316 ,-24313 ,-24566 ,-24818 , -25086 ,-25080 ,-25329 ,-25594 ,-25842 ,-26105 ,-26095 ,-26358 ,-26619 ,-26863 ,-26867 ,-27127 ,-27386 ,-27644 ,-27646 , -27887 ,-28143 ,-28400 ,-28400 ,-28656 ,-28911 ,-28910 ,-29182 ,-29436 ,-29691 ,-29689 ,-29943 ,-30197 ,-30450 ,-30448 , 32766 ,32510 ,32254 ,31998 ,31742 ,31486 ,31230 ,30974 ,30718 ,30462 ,30206 ,29950 ,29694 ,29438 ,29182 , 28926 ,28670 ,28414 ,28158 ,27902 ,27646 ,27390 ,27134 ,26878 ,26622 ,26366 ,26110 ,25854 ,25598 ,25342 , 25086 ,24830 ,24574 ,24318 ,24062 ,23806 ,23550 ,23294 ,23038 ,22782 ,22526 ,22270 ,22014 ,21758 ,21502 , 21246 ,20990 ,20734 ,20478 ,20222 ,19966 ,19710 ,19454 ,19198 ,18942 ,18686 ,18430 ,18174 ,17918 ,17662 , 17406 ,17150 ,16894 ,16638 ,16383 ,16127 ,15871 ,15615 ,15359 ,15103 ,14847 ,14591 ,14335 ,14079 ,13823 , 13567 ,13311 ,13055 ,12799 ,12543 ,12287 ,12031 ,11775 ,11519 ,11263 ,11007 ,10751 ,10495 ,10239 ,9983 , 9727 ,9471 ,9215 ,8959 ,8703 ,8447 ,8191 ,7935 ,7679 ,7423 ,7167 ,6911 ,6655 ,6399 ,6143 , 5887 ,5631 ,5375 ,5119 ,4863 ,4607 ,4351 ,4095 ,3839 ,3583 ,3327 ,3071 ,2815 ,2559 ,2303 , 2047 ,1791 ,1535 ,1279 ,1023 ,767 ,511 ,255 ,0 ,-255 ,-511 ,-767 ,-1023 ,-1279 ,-1535 , -1791 ,-2047 ,-2303 ,-2559 ,-2815 ,-3071 ,-3327 ,-3583 ,-3839 ,-4095 ,-4351 ,-4607 ,-4863 ,-5119 ,-5375 , -5631 ,-5887 ,-6143 ,-6399 ,-6655 ,-6911 ,-7167 ,-7423 ,-7679 ,-7935 ,-8191 ,-8447 ,-8703 ,-8959 ,-9215 , -9471 ,-9727 ,-9983 ,-10239 ,-10495 ,-10751 ,-11007 ,-11263 ,-11519 ,-11775 ,-12031 ,-12287 ,-12543 ,-12799 ,-13055 , -13311 ,-13567 ,-13823 ,-14079 ,-14335 ,-14591 ,-14847 ,-15103 ,-15359 ,-15615 ,-15871 ,-16127 ,-16383 ,-16638 ,-16894 , -17150 ,-17406 ,-17662 ,-17918 ,-18174 ,-18430 ,-18686 ,-18942 ,-19198 ,-19454 ,-19710 ,-19966 ,-20222 ,-20478 ,-20734 , -20990 ,-21246 ,-21502 ,-21758 ,-22014 ,-22270 ,-22526 ,-22782 ,-23038 ,-23294 ,-23550 ,-23806 ,-24062 ,-24318 ,-24574 , -24830 ,-25086 ,-25342 ,-25598 ,-25854 ,-26110 ,-26366 ,-26622 ,-26878 ,-27134 ,-27390 ,-27646 ,-27902 ,-28158 ,-28414 , -28670 ,-28926 ,-29182 ,-29438 ,-29694 ,-29950 ,-30206 ,-30462 ,-30718 ,-30974 ,-31230 ,-31486 ,-31742 ,-31998 ,-32254 , -32510 ,30445 ,30206 ,29950 ,29950 ,29694 ,29438 ,29182 ,28926 ,28926 ,28670 ,28414 ,28158 ,27902 ,27902 , 27646 ,27390 ,27134 ,26878 ,26878 ,26622 ,26366 ,26110 ,25854 ,25854 ,25598 ,25342 ,25086 ,24830 ,24830 , 24574 ,24318 ,24062 ,23805 ,23805 ,23549 ,23293 ,23037 ,22781 ,22781 ,22525 ,22269 ,22013 ,21757 ,21757 , 21501 ,21245 ,20989 ,20733 ,20733 ,20477 ,20221 ,19965 ,19709 ,19709 ,19453 ,19197 ,18941 ,18685 ,18685 , 18429 ,18173 ,17917 ,17661 ,17661 ,17405 ,17149 ,16893 ,16637 ,16382 ,15870 ,15614 ,15358 ,15102 ,14846 , 14590 ,14334 ,14078 ,13822 ,13566 ,13310 ,13054 ,12798 ,12542 ,12286 ,11774 ,11518 ,11262 ,11006 ,10750 , 10494 ,10238 ,9982 ,9726 ,9470 ,9214 ,8958 ,8703 ,8447 ,8191 ,7679 ,7423 ,7167 ,6911 ,6655 , 6399 ,6143 ,5887 ,5631 ,5375 ,5119 ,4863 ,4607 ,4351 ,4095 ,3583 ,3327 ,3071 ,2815 ,2559 , 2303 ,2047 ,1791 ,1535 ,1279 ,1023 ,767 ,511 ,255 ,0 ,-511 ,-767 ,-1023 ,-1279 ,-1535 , -1791 ,-2047 ,-2303 ,-2559 ,-2815 ,-3071 ,-3327 ,-3583 ,-3839 ,-4095 ,-4607 ,-4863 ,-5119 ,-5375 ,-5631 , -5887 ,-6143 ,-6399 ,-6655 ,-6911 ,-7167 ,-7423 ,-7679 ,-7935 ,-8191 ,-8703 ,-8959 ,-9215 ,-9471 ,-9727 , -9983 ,-10239 ,-10495 ,-10751 ,-11007 ,-11263 ,-11519 ,-11775 ,-12031 ,-12287 ,-12799 ,-13055 ,-13311 ,-13567 ,-13823 , -14079 ,-14335 ,-14591 ,-14847 ,-15103 ,-15359 ,-15615 ,-15871 ,-16127 ,-16383 ,-16894 ,-17150 ,-17406 ,-17662 ,-17918 , -17918 ,-18174 ,-18430 ,-18686 ,-18942 ,-18942 ,-19198 ,-19454 ,-19710 ,-19966 ,-19966 ,-20222 ,-20478 ,-20734 ,-20990 , -20990 ,-21246 ,-21502 ,-21758 ,-22014 ,-22014 ,-22270 ,-22526 ,-22782 ,-23038 ,-23038 ,-23294 ,-23550 ,-23806 ,-24062 , -24062 ,-24318 ,-24574 ,-24830 ,-25086 ,-25086 ,-25342 ,-25598 ,-25854 ,-26110 ,-26110 ,-26366 ,-26622 ,-26878 ,-27134 , -27134 ,-27390 ,-27646 ,-27902 ,-28158 ,-28158 ,-28414 ,-28670 ,-28926 ,-29182 ,-29182 ,-29438 ,-29694 ,-29950 ,-30206 , -30206 ,-30462 ,28380 ,28158 ,27902 ,27902 ,27646 ,27390 ,27390 ,27134 ,27134 ,26878 ,26622 ,26622 ,26366 , 26366 ,26110 ,25854 ,25854 ,25598 ,25598 ,25342 ,25086 ,25086 ,24830 ,24830 ,24574 ,24318 ,24318 ,24062 , 24062 ,23806 ,23550 ,23550 ,23293 ,23293 ,23037 ,22781 ,22781 ,22525 ,22525 ,22269 ,22013 ,22013 ,21757 , 21757 ,21501 ,21245 ,21245 ,20989 ,20989 ,20733 ,20477 ,20477 ,20221 ,20221 ,19965 ,19709 ,19709 ,19453 , 19453 ,19197 ,18941 ,18941 ,18685 ,18685 ,18429 ,18173 ,17917 ,17661 ,17405 ,16893 ,16637 ,16382 ,16126 , 15870 ,15614 ,15358 ,14846 ,14590 ,14334 ,14078 ,13822 ,13566 ,13310 ,13054 ,12542 ,12286 ,12030 ,11774 , 11518 ,11262 ,11006 ,10494 ,10238 ,9982 ,9726 ,9470 ,9215 ,8959 ,8703 ,8191 ,7935 ,7679 ,7423 , 7167 ,6911 ,6655 ,6143 ,5887 ,5631 ,5375 ,5119 ,4863 ,4607 ,4351 ,3839 ,3583 ,3327 ,3071 , 2815 ,2559 ,2303 ,1791 ,1535 ,1279 ,1023 ,767 ,511 ,255 ,0 ,-511 ,-767 ,-1023 ,-1279 , -1535 ,-1791 ,-2047 ,-2559 ,-2815 ,-3071 ,-3327 ,-3583 ,-3839 ,-4095 ,-4351 ,-4863 ,-5119 ,-5375 ,-5631 , -5887 ,-6143 ,-6399 ,-6911 ,-7167 ,-7423 ,-7679 ,-7935 ,-8191 ,-8447 ,-8703 ,-9215 ,-9471 ,-9727 ,-9983 , -10239 ,-10495 ,-10751 ,-11263 ,-11519 ,-11775 ,-12031 ,-12287 ,-12543 ,-12799 ,-13055 ,-13567 ,-13823 ,-14079 ,-14335 , -14591 ,-14847 ,-15103 ,-15615 ,-15871 ,-16127 ,-16383 ,-16638 ,-16894 ,-17150 ,-17406 ,-17918 ,-18174 ,-18430 ,-18686 , -18942 ,-18942 ,-19198 ,-19198 ,-19454 ,-19710 ,-19710 ,-19966 ,-19966 ,-20222 ,-20478 ,-20478 ,-20734 ,-20734 ,-20990 , -21246 ,-21246 ,-21502 ,-21502 ,-21758 ,-22014 ,-22014 ,-22270 ,-22270 ,-22526 ,-22782 ,-22782 ,-23038 ,-23038 ,-23294 , -23550 ,-23550 ,-23806 ,-23806 ,-24062 ,-24318 ,-24318 ,-24574 ,-24574 ,-24830 ,-25086 ,-25086 ,-25342 ,-25342 ,-25598 , -25854 ,-25854 ,-26110 ,-26110 ,-26366 ,-26622 ,-26622 ,-26878 ,-26878 ,-27134 ,-27390 ,-27390 ,-27646 ,-27646 ,-27902 , -28158 ,-28158 ,-28414 ,26059 ,26110 ,25854 ,25854 ,25598 ,25598 ,25598 ,25342 ,25342 ,25086 ,25086 ,25086 , 24830 ,24830 ,24574 ,24574 ,24574 ,24318 ,24318 ,24062 ,24062 ,24062 ,23806 ,23806 ,23550 ,23550 ,23550 , 23294 ,23294 ,23038 ,23038 ,23038 ,22781 ,22781 ,22525 ,22525 ,22525 ,22269 ,22269 ,22013 ,22013 ,22013 , 21757 ,21757 ,21501 ,21501 ,21501 ,21245 ,21245 ,20989 ,20989 ,20989 ,20733 ,20733 ,20477 ,20477 ,20477 , 20221 ,20221 ,19965 ,19965 ,19965 ,19709 ,19709 ,19453 ,19197 ,18941 ,18685 ,18429 ,17917 ,17661 ,17405 , 17149 ,16893 ,16382 ,16126 ,15870 ,15614 ,15358 ,14846 ,14590 ,14334 ,14078 ,13822 ,13310 ,13054 ,12798 , 12542 ,12286 ,11774 ,11518 ,11262 ,11006 ,10750 ,10238 ,9982 ,9727 ,9471 ,9215 ,8703 ,8447 ,8191 , 7935 ,7679 ,7167 ,6911 ,6655 ,6399 ,6143 ,5631 ,5375 ,5119 ,4863 ,4607 ,4095 ,3839 ,3583 , 3327 ,3071 ,2559 ,2303 ,2047 ,1791 ,1535 ,1023 ,767 ,511 ,255 ,0 ,-511 ,-767 ,-1023 , -1279 ,-1535 ,-2047 ,-2303 ,-2559 ,-2815 ,-3071 ,-3583 ,-3839 ,-4095 ,-4351 ,-4607 ,-5119 ,-5375 ,-5631 , -5887 ,-6143 ,-6655 ,-6911 ,-7167 ,-7423 ,-7679 ,-8191 ,-8447 ,-8703 ,-8959 ,-9215 ,-9727 ,-9983 ,-10239 , -10495 ,-10751 ,-11263 ,-11519 ,-11775 ,-12031 ,-12287 ,-12799 ,-13055 ,-13311 ,-13567 ,-13823 ,-14335 ,-14591 ,-14847 , -15103 ,-15359 ,-15871 ,-16127 ,-16383 ,-16638 ,-16894 ,-17406 ,-17662 ,-17918 ,-18174 ,-18430 ,-18942 ,-19198 ,-19454 , -19710 ,-19966 ,-19966 ,-19966 ,-20222 ,-20222 ,-20478 ,-20478 ,-20478 ,-20734 ,-20734 ,-20990 ,-20990 ,-20990 ,-21246 , -21246 ,-21502 ,-21502 ,-21502 ,-21758 ,-21758 ,-22014 ,-22014 ,-22014 ,-22270 ,-22270 ,-22526 ,-22526 ,-22526 ,-22782 , -22782 ,-23038 ,-23038 ,-23038 ,-23294 ,-23294 ,-23550 ,-23550 ,-23550 ,-23806 ,-23806 ,-24062 ,-24062 ,-24062 ,-24318 , -24318 ,-24574 ,-24574 ,-24574 ,-24830 ,-24830 ,-25086 ,-25086 ,-25086 ,-25342 ,-25342 ,-25598 ,-25598 ,-25598 ,-25854 , -25854 ,-26110 ,-26110 ,-26110 ,23994 ,23806 ,23806 ,23806 ,23806 ,23550 ,23550 ,23550 ,23550 ,23550 ,23294 , 23294 ,23294 ,23294 ,23294 ,23038 ,23038 ,23038 ,23038 ,23038 ,22782 ,22782 ,22782 ,22782 ,22782 ,22526 , 22526 ,22526 ,22526 ,22526 ,22270 ,22270 ,22269 ,22269 ,22269 ,22013 ,22013 ,22013 ,22013 ,22013 ,21757 , 21757 ,21757 ,21757 ,21757 ,21501 ,21501 ,21501 ,21501 ,21501 ,21245 ,21245 ,21245 ,21245 ,21245 ,20989 , 20989 ,20989 ,20989 ,20989 ,20733 ,20733 ,20733 ,20733 ,20733 ,20221 ,19965 ,19709 ,19453 ,18941 ,18685 , 18429 ,17917 ,17661 ,17405 ,17149 ,16637 ,16382 ,16126 ,15870 ,15358 ,15102 ,14846 ,14590 ,14078 ,13822 , 13566 ,13054 ,12798 ,12542 ,12286 ,11774 ,11518 ,11262 ,11006 ,10494 ,10239 ,9983 ,9727 ,9215 ,8959 , 8703 ,8191 ,7935 ,7679 ,7423 ,6911 ,6655 ,6399 ,6143 ,5631 ,5375 ,5119 ,4863 ,4351 ,4095 , 3839 ,3327 ,3071 ,2815 ,2559 ,2047 ,1791 ,1535 ,1279 ,767 ,511 ,255 ,0 ,-511 ,-767 , -1023 ,-1535 ,-1791 ,-2047 ,-2303 ,-2815 ,-3071 ,-3327 ,-3583 ,-4095 ,-4351 ,-4607 ,-4863 ,-5375 ,-5631 , -5887 ,-6399 ,-6655 ,-6911 ,-7167 ,-7679 ,-7935 ,-8191 ,-8447 ,-8959 ,-9215 ,-9471 ,-9727 ,-10239 ,-10495 , -10751 ,-11263 ,-11519 ,-11775 ,-12031 ,-12543 ,-12799 ,-13055 ,-13311 ,-13823 ,-14079 ,-14335 ,-14591 ,-15103 ,-15359 , -15615 ,-16127 ,-16383 ,-16638 ,-16894 ,-17406 ,-17662 ,-17918 ,-18174 ,-18686 ,-18942 ,-19198 ,-19454 ,-19966 ,-20222 , -20478 ,-20990 ,-20990 ,-20990 ,-20990 ,-20990 ,-21246 ,-21246 ,-21246 ,-21246 ,-21246 ,-21502 ,-21502 ,-21502 ,-21502 , -21502 ,-21758 ,-21758 ,-21758 ,-21758 ,-21758 ,-22014 ,-22014 ,-22014 ,-22014 ,-22014 ,-22270 ,-22270 ,-22270 ,-22270 , -22270 ,-22526 ,-22526 ,-22526 ,-22526 ,-22526 ,-22782 ,-22782 ,-22782 ,-22782 ,-22782 ,-23038 ,-23038 ,-23038 ,-23038 , -23038 ,-23294 ,-23294 ,-23294 ,-23294 ,-23294 ,-23550 ,-23550 ,-23550 ,-23550 ,-23550 ,-23806 ,-23806 ,-23806 ,-23806 , -23806 ,-24062 ,-24062 ,-24062 ,-24062 ,21673 ,21758 ,21758 ,21758 ,21758 ,21758 ,21758 ,21758 ,21758 ,21758 , 21758 ,21758 ,21758 ,21758 ,21758 ,21758 ,21758 ,21758 ,21758 ,21758 ,21758 ,21758 ,21758 ,21758 ,21758 , 21758 ,21758 ,21758 ,21758 ,21758 ,21758 ,21758 ,21757 ,21757 ,21757 ,21757 ,21757 ,21757 ,21757 ,21757 , 21757 ,21757 ,21757 ,21757 ,21757 ,21757 ,21757 ,21757 ,21757 ,21757 ,21757 ,21757 ,21757 ,21757 ,21757 , 21757 ,21757 ,21757 ,21757 ,21757 ,21757 ,21757 ,21757 ,21757 ,21757 ,21501 ,20989 ,20733 ,20477 ,19965 , 19709 ,19453 ,18941 ,18685 ,18429 ,17917 ,17661 ,17405 ,16893 ,16637 ,16382 ,15870 ,15614 ,15358 ,14846 , 14590 ,14334 ,13822 ,13566 ,13310 ,12798 ,12542 ,12286 ,11774 ,11518 ,11262 ,10751 ,10495 ,10239 ,9727 , 9471 ,9215 ,8703 ,8447 ,8191 ,7679 ,7423 ,7167 ,6655 ,6399 ,6143 ,5631 ,5375 ,5119 ,4607 , 4351 ,4095 ,3583 ,3327 ,3071 ,2559 ,2303 ,2047 ,1535 ,1279 ,1023 ,511 ,255 ,0 ,-511 , -767 ,-1023 ,-1535 ,-1791 ,-2047 ,-2559 ,-2815 ,-3071 ,-3583 ,-3839 ,-4095 ,-4607 ,-4863 ,-5119 ,-5631 , -5887 ,-6143 ,-6655 ,-6911 ,-7167 ,-7679 ,-7935 ,-8191 ,-8703 ,-8959 ,-9215 ,-9727 ,-9983 ,-10239 ,-10751 , -11007 ,-11263 ,-11775 ,-12031 ,-12287 ,-12799 ,-13055 ,-13311 ,-13823 ,-14079 ,-14335 ,-14847 ,-15103 ,-15359 ,-15871 , -16127 ,-16383 ,-16894 ,-17150 ,-17406 ,-17918 ,-18174 ,-18430 ,-18942 ,-19198 ,-19454 ,-19966 ,-20222 ,-20478 ,-20990 , -21246 ,-21502 ,-22014 ,-22014 ,-22014 ,-22014 ,-22014 ,-22014 ,-22014 ,-22014 ,-22014 ,-22014 ,-22014 ,-22014 ,-22014 , -22014 ,-22014 ,-22014 ,-22014 ,-22014 ,-22014 ,-22014 ,-22014 ,-22014 ,-22014 ,-22014 ,-22014 ,-22014 ,-22014 ,-22014 , -22014 ,-22014 ,-22014 ,-22014 ,-22014 ,-22014 ,-22014 ,-22014 ,-22014 ,-22014 ,-22014 ,-22014 ,-22014 ,-22014 ,-22014 , -22014 ,-22014 ,-22014 ,-22014 ,-22014 ,-22014 ,-22014 ,-22014 ,-22014 ,-22014 ,-22014 ,-22014 ,-22014 ,-22014 ,-22014 , -22014 ,-22014 ,-22014 ,-22014 ,-22014 ,-22014 ,19608 ,19710 ,19710 ,19710 ,19710 ,19710 ,19966 ,19966 ,19966 , 19966 ,19966 ,20222 ,20222 ,20222 ,20222 ,20222 ,20478 ,20478 ,20478 ,20478 ,20478 ,20734 ,20734 ,20734 , 20734 ,20734 ,20990 ,20990 ,20990 ,20990 ,20990 ,21246 ,21245 ,21245 ,21245 ,21245 ,21501 ,21501 ,21501 , 21501 ,21501 ,21757 ,21757 ,21757 ,21757 ,21757 ,22013 ,22013 ,22013 ,22013 ,22013 ,22269 ,22269 ,22269 , 22269 ,22269 ,22525 ,22525 ,22525 ,22525 ,22525 ,22781 ,22781 ,22781 ,22781 ,22525 ,22013 ,21757 ,21501 , 20989 ,20733 ,20221 ,19965 ,19709 ,19197 ,18941 ,18429 ,18173 ,17917 ,17405 ,17149 ,16637 ,16382 ,16126 , 15614 ,15358 ,14846 ,14590 ,14334 ,13822 ,13566 ,13054 ,12798 ,12542 ,12030 ,11774 ,11263 ,11007 ,10751 , 10239 ,9983 ,9471 ,9215 ,8959 ,8447 ,8191 ,7679 ,7423 ,7167 ,6655 ,6399 ,5887 ,5631 ,5375 , 4863 ,4607 ,4095 ,3839 ,3583 ,3071 ,2815 ,2303 ,2047 ,1791 ,1279 ,1023 ,511 ,255 ,0 , -511 ,-767 ,-1279 ,-1535 ,-1791 ,-2303 ,-2559 ,-3071 ,-3327 ,-3583 ,-4095 ,-4351 ,-4863 ,-5119 ,-5375 , -5887 ,-6143 ,-6655 ,-6911 ,-7167 ,-7679 ,-7935 ,-8447 ,-8703 ,-8959 ,-9471 ,-9727 ,-10239 ,-10495 ,-10751 , -11263 ,-11519 ,-12031 ,-12287 ,-12543 ,-13055 ,-13311 ,-13823 ,-14079 ,-14335 ,-14847 ,-15103 ,-15615 ,-15871 ,-16127 , -16638 ,-16894 ,-17406 ,-17662 ,-17918 ,-18430 ,-18686 ,-19198 ,-19454 ,-19710 ,-20222 ,-20478 ,-20990 ,-21246 ,-21502 , -22014 ,-22270 ,-22782 ,-23038 ,-23038 ,-23038 ,-22782 ,-22782 ,-22782 ,-22782 ,-22782 ,-22526 ,-22526 ,-22526 ,-22526 , -22526 ,-22270 ,-22270 ,-22270 ,-22270 ,-22270 ,-22014 ,-22014 ,-22014 ,-22014 ,-22014 ,-21758 ,-21758 ,-21758 ,-21758 , -21758 ,-21502 ,-21502 ,-21502 ,-21502 ,-21502 ,-21246 ,-21246 ,-21246 ,-21246 ,-21246 ,-20990 ,-20990 ,-20990 ,-20990 , -20990 ,-20734 ,-20734 ,-20734 ,-20734 ,-20734 ,-20478 ,-20478 ,-20478 ,-20478 ,-20478 ,-20222 ,-20222 ,-20222 ,-20222 , -20222 ,-19966 ,-19966 ,-19966 ,-19966 ,-19966 ,-19710 ,17287 ,17406 ,17662 ,17662 ,17662 ,17918 ,17918 ,18174 , 18174 ,18174 ,18430 ,18430 ,18686 ,18686 ,18686 ,18942 ,18942 ,19198 ,19198 ,19198 ,19454 ,19454 ,19710 , 19710 ,19710 ,19966 ,19966 ,20222 ,20222 ,20222 ,20478 ,20478 ,20733 ,20733 ,20733 ,20989 ,20989 ,21245 , 21245 ,21245 ,21501 ,21501 ,21757 ,21757 ,21757 ,22013 ,22013 ,22269 ,22269 ,22269 ,22525 ,22525 ,22781 , 22781 ,22781 ,23037 ,23037 ,23293 ,23293 ,23293 ,23549 ,23549 ,23805 ,23805 ,23805 ,23549 ,23037 ,22781 , 22525 ,22013 ,21757 ,21245 ,20989 ,20477 ,20221 ,19709 ,19453 ,18941 ,18685 ,18173 ,17917 ,17405 ,17149 , 16893 ,16382 ,16126 ,15614 ,15358 ,14846 ,14590 ,14078 ,13822 ,13310 ,13054 ,12542 ,12286 ,11775 ,11519 , 11263 ,10751 ,10495 ,9983 ,9727 ,9215 ,8959 ,8447 ,8191 ,7679 ,7423 ,6911 ,6655 ,6143 ,5887 , 5631 ,5119 ,4863 ,4351 ,4095 ,3583 ,3327 ,2815 ,2559 ,2047 ,1791 ,1279 ,1023 ,511 ,255 , 0 ,-511 ,-767 ,-1279 ,-1535 ,-2047 ,-2303 ,-2815 ,-3071 ,-3583 ,-3839 ,-4351 ,-4607 ,-5119 ,-5375 , -5631 ,-6143 ,-6399 ,-6911 ,-7167 ,-7679 ,-7935 ,-8447 ,-8703 ,-9215 ,-9471 ,-9983 ,-10239 ,-10751 ,-11007 , -11263 ,-11775 ,-12031 ,-12543 ,-12799 ,-13311 ,-13567 ,-14079 ,-14335 ,-14847 ,-15103 ,-15615 ,-15871 ,-16383 ,-16638 , -16894 ,-17406 ,-17662 ,-18174 ,-18430 ,-18942 ,-19198 ,-19710 ,-19966 ,-20478 ,-20734 ,-21246 ,-21502 ,-22014 ,-22270 , -22526 ,-23038 ,-23294 ,-23806 ,-24062 ,-24062 ,-24062 ,-23806 ,-23806 ,-23550 ,-23550 ,-23550 ,-23294 ,-23294 ,-23038 , -23038 ,-23038 ,-22782 ,-22782 ,-22526 ,-22526 ,-22526 ,-22270 ,-22270 ,-22014 ,-22014 ,-22014 ,-21758 ,-21758 ,-21502 , -21502 ,-21502 ,-21246 ,-21246 ,-20990 ,-20990 ,-20990 ,-20734 ,-20734 ,-20478 ,-20478 ,-20478 ,-20222 ,-20222 ,-19966 , -19966 ,-19966 ,-19710 ,-19710 ,-19454 ,-19454 ,-19454 ,-19198 ,-19198 ,-18942 ,-18942 ,-18942 ,-18686 ,-18686 ,-18430 , -18430 ,-18430 ,-18174 ,-18174 ,-17918 ,-17918 ,-17918 ,-17662 ,15223 ,15359 ,15359 ,15615 ,15871 ,15871 ,16127 , 16127 ,16383 ,16638 ,16638 ,16894 ,16894 ,17150 ,17406 ,17406 ,17662 ,17662 ,17918 ,18174 ,18174 ,18430 , 18430 ,18686 ,18942 ,18942 ,19198 ,19198 ,19454 ,19710 ,19710 ,19966 ,19965 ,20221 ,20477 ,20477 ,20733 , 20733 ,20989 ,21245 ,21245 ,21501 ,21501 ,21757 ,22013 ,22013 ,22269 ,22269 ,22525 ,22781 ,22781 ,23037 , 23037 ,23293 ,23549 ,23549 ,23805 ,23805 ,24061 ,24317 ,24317 ,24573 ,24573 ,24829 ,25085 ,24573 ,24317 , 23805 ,23549 ,23037 ,22525 ,22269 ,21757 ,21501 ,20989 ,20733 ,20221 ,19965 ,19453 ,19197 ,18685 ,18429 , 17917 ,17661 ,17149 ,16637 ,16382 ,15870 ,15614 ,15102 ,14846 ,14334 ,14078 ,13566 ,13310 ,12798 ,12543 , 12031 ,11775 ,11263 ,10751 ,10495 ,9983 ,9727 ,9215 ,8959 ,8447 ,8191 ,7679 ,7423 ,6911 ,6655 , 6143 ,5887 ,5375 ,4863 ,4607 ,4095 ,3839 ,3327 ,3071 ,2559 ,2303 ,1791 ,1535 ,1023 ,767 , 255 ,0 ,-511 ,-1023 ,-1279 ,-1791 ,-2047 ,-2559 ,-2815 ,-3327 ,-3583 ,-4095 ,-4351 ,-4863 ,-5119 , -5631 ,-5887 ,-6399 ,-6911 ,-7167 ,-7679 ,-7935 ,-8447 ,-8703 ,-9215 ,-9471 ,-9983 ,-10239 ,-10751 ,-11007 , -11519 ,-11775 ,-12287 ,-12799 ,-13055 ,-13567 ,-13823 ,-14335 ,-14591 ,-15103 ,-15359 ,-15871 ,-16127 ,-16638 ,-16894 , -17406 ,-17662 ,-18174 ,-18686 ,-18942 ,-19454 ,-19710 ,-20222 ,-20478 ,-20990 ,-21246 ,-21758 ,-22014 ,-22526 ,-22782 , -23294 ,-23550 ,-24062 ,-24574 ,-24830 ,-25342 ,-25086 ,-24830 ,-24830 ,-24574 ,-24574 ,-24318 ,-24062 ,-24062 ,-23806 , -23806 ,-23550 ,-23294 ,-23294 ,-23038 ,-23038 ,-22782 ,-22526 ,-22526 ,-22270 ,-22270 ,-22014 ,-21758 ,-21758 ,-21502 , -21502 ,-21246 ,-20990 ,-20990 ,-20734 ,-20734 ,-20478 ,-20222 ,-20222 ,-19966 ,-19966 ,-19710 ,-19454 ,-19454 ,-19198 , -19198 ,-18942 ,-18686 ,-18686 ,-18430 ,-18430 ,-18174 ,-17918 ,-17918 ,-17662 ,-17662 ,-17406 ,-17150 ,-17150 ,-16894 , -16894 ,-16638 ,-16383 ,-16383 ,-16127 ,-16127 ,-15871 ,-15615 ,-15615 ,12902 ,13311 ,13311 ,13567 ,13823 ,14079 , 14335 ,14335 ,14591 ,14847 ,15103 ,15359 ,15359 ,15615 ,15871 ,16127 ,16383 ,16383 ,16638 ,16894 ,17150 , 17406 ,17406 ,17662 ,17918 ,18174 ,18430 ,18430 ,18686 ,18942 ,19198 ,19454 ,19453 ,19709 ,19965 ,20221 , 20477 ,20477 ,20733 ,20989 ,21245 ,21501 ,21501 ,21757 ,22013 ,22269 ,22525 ,22525 ,22781 ,23037 ,23293 , 23549 ,23549 ,23805 ,24061 ,24317 ,24573 ,24573 ,24829 ,25085 ,25341 ,25597 ,25597 ,25853 ,26109 ,25597 , 25341 ,24829 ,24573 ,24061 ,23549 ,23293 ,22781 ,22525 ,22013 ,21501 ,21245 ,20733 ,20477 ,19965 ,19453 , 19197 ,18685 ,18429 ,17917 ,17405 ,17149 ,16637 ,16382 ,15870 ,15358 ,15102 ,14590 ,14334 ,13822 ,13310 , 13055 ,12543 ,12287 ,11775 ,11263 ,11007 ,10495 ,10239 ,9727 ,9215 ,8959 ,8447 ,8191 ,7679 ,7167 , 6911 ,6399 ,6143 ,5631 ,5119 ,4863 ,4351 ,4095 ,3583 ,3071 ,2815 ,2303 ,2047 ,1535 ,1023 , 767 ,255 ,0 ,-511 ,-1023 ,-1279 ,-1791 ,-2047 ,-2559 ,-3071 ,-3327 ,-3839 ,-4095 ,-4607 ,-5119 , -5375 ,-5887 ,-6143 ,-6655 ,-7167 ,-7423 ,-7935 ,-8191 ,-8703 ,-9215 ,-9471 ,-9983 ,-10239 ,-10751 ,-11263 , -11519 ,-12031 ,-12287 ,-12799 ,-13311 ,-13567 ,-14079 ,-14335 ,-14847 ,-15359 ,-15615 ,-16127 ,-16383 ,-16894 ,-17406 , -17662 ,-18174 ,-18430 ,-18942 ,-19454 ,-19710 ,-20222 ,-20478 ,-20990 ,-21502 ,-21758 ,-22270 ,-22526 ,-23038 ,-23550 , -23806 ,-24318 ,-24574 ,-25086 ,-25598 ,-25854 ,-26366 ,-26110 ,-25854 ,-25598 ,-25598 ,-25342 ,-25086 ,-24830 ,-24574 , -24574 ,-24318 ,-24062 ,-23806 ,-23550 ,-23550 ,-23294 ,-23038 ,-22782 ,-22526 ,-22526 ,-22270 ,-22014 ,-21758 ,-21502 , -21502 ,-21246 ,-20990 ,-20734 ,-20478 ,-20478 ,-20222 ,-19966 ,-19710 ,-19454 ,-19454 ,-19198 ,-18942 ,-18686 ,-18430 , -18430 ,-18174 ,-17918 ,-17662 ,-17406 ,-17406 ,-17150 ,-16894 ,-16638 ,-16383 ,-16383 ,-16127 ,-15871 ,-15615 ,-15359 , -15359 ,-15103 ,-14847 ,-14591 ,-14335 ,-14335 ,-14079 ,-13823 ,-13567 ,-13311 ,10837 ,11007 ,11263 ,11519 ,11775 , 12031 ,12287 ,12543 ,12799 ,13055 ,13311 ,13567 ,13823 ,14079 ,14335 ,14591 ,14847 ,15103 ,15359 ,15615 , 15871 ,16127 ,16383 ,16638 ,16894 ,17150 ,17406 ,17662 ,17918 ,18174 ,18430 ,18686 ,18941 ,19197 ,19453 , 19709 ,19965 ,20221 ,20477 ,20733 ,20989 ,21245 ,21501 ,21757 ,22013 ,22269 ,22525 ,22781 ,23037 ,23293 , 23549 ,23805 ,24061 ,24317 ,24573 ,24829 ,25085 ,25341 ,25597 ,25853 ,26109 ,26365 ,26621 ,26877 ,27133 , 26877 ,26365 ,25853 ,25597 ,25085 ,24573 ,24317 ,23805 ,23293 ,23037 ,22525 ,22013 ,21757 ,21245 ,20733 , 20477 ,19965 ,19453 ,19197 ,18685 ,18173 ,17917 ,17405 ,16893 ,16637 ,16126 ,15614 ,15358 ,14846 ,14334 , 14078 ,13567 ,13055 ,12799 ,12287 ,11775 ,11519 ,11007 ,10495 ,10239 ,9727 ,9215 ,8959 ,8447 ,7935 , 7679 ,7167 ,6655 ,6399 ,5887 ,5375 ,5119 ,4607 ,4095 ,3839 ,3327 ,2815 ,2559 ,2047 ,1535 , 1279 ,767 ,255 ,0 ,-511 ,-1023 ,-1279 ,-1791 ,-2303 ,-2559 ,-3071 ,-3583 ,-3839 ,-4351 ,-4863 , -5119 ,-5631 ,-6143 ,-6399 ,-6911 ,-7423 ,-7679 ,-8191 ,-8703 ,-8959 ,-9471 ,-9983 ,-10239 ,-10751 ,-11263 , -11519 ,-12031 ,-12543 ,-12799 ,-13311 ,-13823 ,-14079 ,-14591 ,-15103 ,-15359 ,-15871 ,-16383 ,-16638 ,-17150 ,-17662 , -17918 ,-18430 ,-18942 ,-19198 ,-19710 ,-20222 ,-20478 ,-20990 ,-21502 ,-21758 ,-22270 ,-22782 ,-23038 ,-23550 ,-24062 , -24318 ,-24830 ,-25342 ,-25598 ,-26110 ,-26622 ,-26878 ,-27390 ,-27134 ,-26878 ,-26622 ,-26366 ,-26110 ,-25854 ,-25598 , -25342 ,-25086 ,-24830 ,-24574 ,-24318 ,-24062 ,-23806 ,-23550 ,-23294 ,-23038 ,-22782 ,-22526 ,-22270 ,-22014 ,-21758 , -21502 ,-21246 ,-20990 ,-20734 ,-20478 ,-20222 ,-19966 ,-19710 ,-19454 ,-19198 ,-18942 ,-18686 ,-18430 ,-18174 ,-17918 , -17662 ,-17406 ,-17150 ,-16894 ,-16638 ,-16383 ,-16127 ,-15871 ,-15615 ,-15359 ,-15103 ,-14847 ,-14591 ,-14335 ,-14079 , -13823 ,-13567 ,-13311 ,-13055 ,-12799 ,-12543 ,-12287 ,-12031 ,-11775 ,-11519 ,-11263 ,8516 ,8959 ,9215 ,9471 , 9727 ,10239 ,10495 ,10751 ,11007 ,11263 ,11775 ,12031 ,12287 ,12543 ,12799 ,13311 ,13567 ,13823 ,14079 , 14335 ,14847 ,15103 ,15359 ,15615 ,15871 ,16383 ,16638 ,16894 ,17150 ,17406 ,17918 ,18174 ,18429 ,18685 , 18941 ,19453 ,19709 ,19965 ,20221 ,20477 ,20989 ,21245 ,21501 ,21757 ,22013 ,22525 ,22781 ,23037 ,23293 , 23549 ,24061 ,24317 ,24573 ,24829 ,25085 ,25597 ,25853 ,26109 ,26365 ,26621 ,27133 ,27389 ,27645 ,27901 , 28157 ,27901 ,27389 ,26877 ,26621 ,26109 ,25597 ,25085 ,24829 ,24317 ,23805 ,23293 ,23037 ,22525 ,22013 , 21501 ,21245 ,20733 ,20221 ,19965 ,19453 ,18941 ,18429 ,18173 ,17661 ,17149 ,16637 ,16382 ,15870 ,15358 , 14846 ,14590 ,14079 ,13567 ,13311 ,12799 ,12287 ,11775 ,11519 ,11007 ,10495 ,9983 ,9727 ,9215 ,8703 , 8191 ,7935 ,7423 ,6911 ,6655 ,6143 ,5631 ,5119 ,4863 ,4351 ,3839 ,3327 ,3071 ,2559 ,2047 , 1535 ,1279 ,767 ,255 ,0 ,-511 ,-1023 ,-1535 ,-1791 ,-2303 ,-2815 ,-3327 ,-3583 ,-4095 ,-4607 , -5119 ,-5375 ,-5887 ,-6399 ,-6655 ,-7167 ,-7679 ,-8191 ,-8447 ,-8959 ,-9471 ,-9983 ,-10239 ,-10751 ,-11263 , -11775 ,-12031 ,-12543 ,-13055 ,-13311 ,-13823 ,-14335 ,-14847 ,-15103 ,-15615 ,-16127 ,-16638 ,-16894 ,-17406 ,-17918 , -18430 ,-18686 ,-19198 ,-19710 ,-19966 ,-20478 ,-20990 ,-21502 ,-21758 ,-22270 ,-22782 ,-23294 ,-23550 ,-24062 ,-24574 , -25086 ,-25342 ,-25854 ,-26366 ,-26622 ,-27134 ,-27646 ,-28158 ,-28414 ,-28158 ,-27902 ,-27646 ,-27390 ,-26878 ,-26622 , -26366 ,-26110 ,-25854 ,-25342 ,-25086 ,-24830 ,-24574 ,-24318 ,-23806 ,-23550 ,-23294 ,-23038 ,-22782 ,-22270 ,-22014 , -21758 ,-21502 ,-21246 ,-20734 ,-20478 ,-20222 ,-19966 ,-19710 ,-19198 ,-18942 ,-18686 ,-18430 ,-18174 ,-17662 ,-17406 , -17150 ,-16894 ,-16638 ,-16127 ,-15871 ,-15615 ,-15359 ,-15103 ,-14591 ,-14335 ,-14079 ,-13823 ,-13567 ,-13055 ,-12799 , -12543 ,-12287 ,-12031 ,-11519 ,-11263 ,-11007 ,-10751 ,-10495 ,-9983 ,-9727 ,-9471 ,-9215 ,6451 ,6911 ,7167 , 7423 ,7935 ,8191 ,8703 ,8959 ,9215 ,9727 ,9983 ,10495 ,10751 ,11007 ,11519 ,11775 ,12287 ,12543 , 12799 ,13311 ,13567 ,14079 ,14335 ,14591 ,15103 ,15359 ,15871 ,16127 ,16383 ,16894 ,17150 ,17662 ,17917 , 18173 ,18685 ,18941 ,19453 ,19709 ,19965 ,20477 ,20733 ,21245 ,21501 ,21757 ,22269 ,22525 ,23037 ,23293 , 23549 ,24061 ,24317 ,24829 ,25085 ,25341 ,25853 ,26109 ,26621 ,26877 ,27133 ,27645 ,27901 ,28413 ,28669 , 28925 ,29437 ,28925 ,28413 ,27901 ,27645 ,27133 ,26621 ,26109 ,25597 ,25341 ,24829 ,24317 ,23805 ,23293 , 23037 ,22525 ,22013 ,21501 ,20989 ,20733 ,20221 ,19709 ,19197 ,18685 ,18429 ,17917 ,17405 ,16893 ,16382 , 16126 ,15614 ,15102 ,14591 ,14079 ,13823 ,13311 ,12799 ,12287 ,11775 ,11519 ,11007 ,10495 ,9983 ,9471 , 9215 ,8703 ,8191 ,7679 ,7167 ,6911 ,6399 ,5887 ,5375 ,4863 ,4607 ,4095 ,3583 ,3071 ,2559 , 2303 ,1791 ,1279 ,767 ,255 ,0 ,-511 ,-1023 ,-1535 ,-2047 ,-2303 ,-2815 ,-3327 ,-3839 ,-4351 , -4607 ,-5119 ,-5631 ,-6143 ,-6655 ,-6911 ,-7423 ,-7935 ,-8447 ,-8959 ,-9215 ,-9727 ,-10239 ,-10751 ,-11263 , -11519 ,-12031 ,-12543 ,-13055 ,-13567 ,-13823 ,-14335 ,-14847 ,-15359 ,-15871 ,-16127 ,-16638 ,-17150 ,-17662 ,-18174 , -18430 ,-18942 ,-19454 ,-19966 ,-20478 ,-20734 ,-21246 ,-21758 ,-22270 ,-22782 ,-23038 ,-23550 ,-24062 ,-24574 ,-25086 , -25342 ,-25854 ,-26366 ,-26878 ,-27390 ,-27646 ,-28158 ,-28670 ,-29182 ,-29694 ,-29182 ,-28926 ,-28414 ,-28158 ,-27902 , -27390 ,-27134 ,-26622 ,-26366 ,-26110 ,-25598 ,-25342 ,-24830 ,-24574 ,-24318 ,-23806 ,-23550 ,-23038 ,-22782 ,-22526 , -22014 ,-21758 ,-21246 ,-20990 ,-20734 ,-20222 ,-19966 ,-19454 ,-19198 ,-18942 ,-18430 ,-18174 ,-17662 ,-17406 ,-17150 , -16638 ,-16383 ,-15871 ,-15615 ,-15359 ,-14847 ,-14591 ,-14079 ,-13823 ,-13567 ,-13055 ,-12799 ,-12287 ,-12031 ,-11775 , -11263 ,-11007 ,-10495 ,-10239 ,-9983 ,-9471 ,-9215 ,-8703 ,-8447 ,-8191 ,-7679 ,-7423 ,-6911 ,4130 ,4607 , 5119 ,5375 ,5887 ,6399 ,6655 ,7167 ,7423 ,7935 ,8447 ,8703 ,9215 ,9471 ,9983 ,10495 ,10751 , 11263 ,11519 ,12031 ,12543 ,12799 ,13311 ,13567 ,14079 ,14591 ,14847 ,15359 ,15615 ,16127 ,16638 ,16894 , 17405 ,17661 ,18173 ,18685 ,18941 ,19453 ,19709 ,20221 ,20733 ,20989 ,21501 ,21757 ,22269 ,22781 ,23037 , 23549 ,23805 ,24317 ,24829 ,25085 ,25597 ,25853 ,26365 ,26877 ,27133 ,27645 ,27901 ,28413 ,28925 ,29181 , 29693 ,29949 ,30461 ,29949 ,29437 ,28925 ,28669 ,28157 ,27645 ,27133 ,26621 ,26109 ,25597 ,25085 ,24829 , 24317 ,23805 ,23293 ,22781 ,22269 ,21757 ,21501 ,20989 ,20477 ,19965 ,19453 ,18941 ,18429 ,17917 ,17661 , 17149 ,16637 ,16126 ,15614 ,15103 ,14591 ,14335 ,13823 ,13311 ,12799 ,12287 ,11775 ,11263 ,10751 ,10495 , 9983 ,9471 ,8959 ,8447 ,7935 ,7423 ,7167 ,6655 ,6143 ,5631 ,5119 ,4607 ,4095 ,3583 ,3327 , 2815 ,2303 ,1791 ,1279 ,767 ,255 ,0 ,-511 ,-1023 ,-1535 ,-2047 ,-2559 ,-3071 ,-3583 ,-3839 , -4351 ,-4863 ,-5375 ,-5887 ,-6399 ,-6911 ,-7167 ,-7679 ,-8191 ,-8703 ,-9215 ,-9727 ,-10239 ,-10751 ,-11007 , -11519 ,-12031 ,-12543 ,-13055 ,-13567 ,-14079 ,-14335 ,-14847 ,-15359 ,-15871 ,-16383 ,-16894 ,-17406 ,-17918 ,-18174 , -18686 ,-19198 ,-19710 ,-20222 ,-20734 ,-21246 ,-21502 ,-22014 ,-22526 ,-23038 ,-23550 ,-24062 ,-24574 ,-25086 ,-25342 , -25854 ,-26366 ,-26878 ,-27390 ,-27902 ,-28414 ,-28670 ,-29182 ,-29694 ,-30206 ,-30718 ,-30206 ,-29950 ,-29438 ,-29182 , -28670 ,-28158 ,-27902 ,-27390 ,-27134 ,-26622 ,-26110 ,-25854 ,-25342 ,-25086 ,-24574 ,-24062 ,-23806 ,-23294 ,-23038 , -22526 ,-22014 ,-21758 ,-21246 ,-20990 ,-20478 ,-19966 ,-19710 ,-19198 ,-18942 ,-18430 ,-17918 ,-17662 ,-17150 ,-16894 , -16383 ,-15871 ,-15615 ,-15103 ,-14847 ,-14335 ,-13823 ,-13567 ,-13055 ,-12799 ,-12287 ,-11775 ,-11519 ,-11007 ,-10751 , -10239 ,-9727 ,-9471 ,-8959 ,-8703 ,-8191 ,-7679 ,-7423 ,-6911 ,-6655 ,-6143 ,-5631 ,-5375 ,-4863 ,2065 , 2559 ,3071 ,3327 ,3839 ,4351 ,4863 ,5375 ,5631 ,6143 ,6655 ,7167 ,7679 ,7935 ,8447 ,8959 , 9471 ,9983 ,10239 ,10751 ,11263 ,11775 ,12287 ,12543 ,13055 ,13567 ,14079 ,14591 ,14847 ,15359 ,15871 , 16383 ,16893 ,17149 ,17661 ,18173 ,18685 ,19197 ,19453 ,19965 ,20477 ,20989 ,21501 ,21757 ,22269 ,22781 , 23293 ,23805 ,24061 ,24573 ,25085 ,25597 ,26109 ,26365 ,26877 ,27389 ,27901 ,28413 ,28669 ,29181 ,29693 , 30205 ,30717 ,30973 ,31485 ,30973 ,30461 ,29949 ,29693 ,29181 ,28669 ,28157 ,27645 ,27133 ,26621 ,26109 , 25597 ,25085 ,24573 ,24061 ,23549 ,23037 ,22525 ,22269 ,21757 ,21245 ,20733 ,20221 ,19709 ,19197 ,18685 , 18173 ,17661 ,17149 ,16637 ,16126 ,15615 ,15103 ,14847 ,14335 ,13823 ,13311 ,12799 ,12287 ,11775 ,11263 , 10751 ,10239 ,9727 ,9215 ,8703 ,8191 ,7679 ,7423 ,6911 ,6399 ,5887 ,5375 ,4863 ,4351 ,3839 , 3327 ,2815 ,2303 ,1791 ,1279 ,767 ,255 ,0 ,-511 ,-1023 ,-1535 ,-2047 ,-2559 ,-3071 ,-3583 , -4095 ,-4607 ,-5119 ,-5631 ,-6143 ,-6655 ,-7167 ,-7423 ,-7935 ,-8447 ,-8959 ,-9471 ,-9983 ,-10495 ,-11007 , -11519 ,-12031 ,-12543 ,-13055 ,-13567 ,-14079 ,-14591 ,-14847 ,-15359 ,-15871 ,-16383 ,-16894 ,-17406 ,-17918 ,-18430 , -18942 ,-19454 ,-19966 ,-20478 ,-20990 ,-21502 ,-22014 ,-22270 ,-22782 ,-23294 ,-23806 ,-24318 ,-24830 ,-25342 ,-25854 , -26366 ,-26878 ,-27390 ,-27902 ,-28414 ,-28926 ,-29438 ,-29694 ,-30206 ,-30718 ,-31230 ,-31742 ,-31230 ,-30974 ,-30462 , -29950 ,-29438 ,-28926 ,-28670 ,-28158 ,-27646 ,-27134 ,-26622 ,-26366 ,-25854 ,-25342 ,-24830 ,-24318 ,-24062 ,-23550 , -23038 ,-22526 ,-22014 ,-21758 ,-21246 ,-20734 ,-20222 ,-19710 ,-19454 ,-18942 ,-18430 ,-17918 ,-17406 ,-17150 ,-16638 , -16127 ,-15615 ,-15103 ,-14847 ,-14335 ,-13823 ,-13311 ,-12799 ,-12543 ,-12031 ,-11519 ,-11007 ,-10495 ,-10239 ,-9727 , -9215 ,-8703 ,-8191 ,-7935 ,-7423 ,-6911 ,-6399 ,-5887 ,-5631 ,-5119 ,-4607 ,-4095 ,-3583 ,-3327 ,-2815 , 0 ,511 ,1023 ,1535 ,2047 ,2559 ,3071 ,3583 ,4095 ,4607 ,5119 ,5631 ,6143 ,6655 ,7167 , 7679 ,8191 ,8703 ,9215 ,9727 ,10239 ,10751 ,11263 ,11775 ,12287 ,12799 ,13311 ,13823 ,14335 ,14847 , 15359 ,15871 ,16382 ,16893 ,17405 ,17917 ,18429 ,18941 ,19453 ,19965 ,20477 ,20989 ,21501 ,22013 ,22525 , 23037 ,23549 ,24061 ,24573 ,25085 ,25597 ,26109 ,26621 ,27133 ,27645 ,28157 ,28669 ,29181 ,29693 ,30205 , 30717 ,31229 ,31741 ,32253 ,32765 ,32253 ,31741 ,31229 ,30717 ,30205 ,29693 ,29181 ,28669 ,28157 ,27645 , 27133 ,26621 ,26109 ,25597 ,25085 ,24573 ,24061 ,23549 ,23037 ,22525 ,22013 ,21501 ,20989 ,20477 ,19965 , 19453 ,18941 ,18429 ,17917 ,17405 ,16893 ,16383 ,15871 ,15359 ,14847 ,14335 ,13823 ,13311 ,12799 ,12287 , 11775 ,11263 ,10751 ,10239 ,9727 ,9215 ,8703 ,8191 ,7679 ,7167 ,6655 ,6143 ,5631 ,5119 ,4607 , 4095 ,3583 ,3071 ,2559 ,2047 ,1535 ,1023 ,511 ,0 ,-511 ,-1023 ,-1535 ,-2047 ,-2559 ,-3071 , -3583 ,-4095 ,-4607 ,-5119 ,-5631 ,-6143 ,-6655 ,-7167 ,-7679 ,-8191 ,-8703 ,-9215 ,-9727 ,-10239 ,-10751 , -11263 ,-11775 ,-12287 ,-12799 ,-13311 ,-13823 ,-14335 ,-14847 ,-15359 ,-15871 ,-16382 ,-16893 ,-17405 ,-17917 ,-18429 , -18941 ,-19453 ,-19965 ,-20477 ,-20989 ,-21501 ,-22013 ,-22525 ,-23037 ,-23549 ,-24061 ,-24573 ,-25085 ,-25597 ,-26109 , -26621 ,-27133 ,-27645 ,-28157 ,-28669 ,-29181 ,-29693 ,-30205 ,-30717 ,-31229 ,-31741 ,-32253 ,-32765 ,-32253 ,-31741 , -31229 ,-30717 ,-30205 ,-29693 ,-29181 ,-28669 ,-28157 ,-27645 ,-27133 ,-26621 ,-26109 ,-25597 ,-25085 ,-24573 ,-24061 , -23549 ,-23037 ,-22525 ,-22013 ,-21501 ,-20989 ,-20477 ,-19965 ,-19453 ,-18941 ,-18429 ,-17917 ,-17405 ,-16893 ,-16383 , -15871 ,-15359 ,-14847 ,-14335 ,-13823 ,-13311 ,-12799 ,-12287 ,-11775 ,-11263 ,-10751 ,-10239 ,-9727 ,-9215 ,-8703 , -8191 ,-7679 ,-7167 ,-6655 ,-6143 ,-5631 ,-5119 ,-4607 ,-4095 ,-3583 ,-3071 ,-2559 ,-2047 ,-1535 ,-1023 , -511 ,2065 ,2559 ,3071 ,3583 ,4095 ,4351 ,4863 ,5375 ,5887 ,6399 ,6911 ,7423 ,7679 ,8191 , 8703 ,9215 ,9727 ,10239 ,10751 ,11263 ,11519 ,12031 ,12543 ,13055 ,13567 ,14079 ,14591 ,14847 ,15359 , 15871 ,16383 ,16894 ,17405 ,17917 ,18429 ,18685 ,19197 ,19709 ,20221 ,20733 ,21245 ,21757 ,22013 ,22525 , 23037 ,23549 ,24061 ,24573 ,25085 ,25597 ,25853 ,26365 ,26877 ,27389 ,27901 ,28413 ,28925 ,29181 ,29693 , 30205 ,30717 ,31229 ,31741 ,32253 ,32765 ,32253 ,31741 ,31229 ,30717 ,30205 ,29693 ,29181 ,28925 ,28413 , 27901 ,27389 ,26877 ,26365 ,25853 ,25597 ,25085 ,24573 ,24061 ,23549 ,23037 ,22525 ,22013 ,21757 ,21245 , 20733 ,20221 ,19709 ,19197 ,18685 ,18429 ,17917 ,17406 ,16894 ,16383 ,15871 ,15359 ,14847 ,14591 ,14079 , 13567 ,13055 ,12543 ,12031 ,11519 ,11263 ,10751 ,10239 ,9727 ,9215 ,8703 ,8191 ,7679 ,7423 ,6911 , 6399 ,5887 ,5375 ,4863 ,4351 ,4095 ,3583 ,3071 ,2559 ,2048 ,-2815 ,-3327 ,-3839 ,-4095 ,-4607 , -5119 ,-5631 ,-6143 ,-6655 ,-7167 ,-7679 ,-7935 ,-8447 ,-8959 ,-9471 ,-9983 ,-10495 ,-11007 ,-11263 ,-11775 , -12287 ,-12799 ,-13311 ,-13823 ,-14335 ,-14847 ,-15103 ,-15615 ,-16127 ,-16638 ,-17150 ,-17662 ,-18174 ,-18430 ,-18942 , -19454 ,-19966 ,-20478 ,-20990 ,-21502 ,-22014 ,-22270 ,-22782 ,-23294 ,-23806 ,-24318 ,-24830 ,-25342 ,-25598 ,-26110 , -26622 ,-27134 ,-27646 ,-28158 ,-28670 ,-29182 ,-29438 ,-29950 ,-30462 ,-30974 ,-31486 ,-31998 ,-32510 ,-32766 ,-32510 , -31998 ,-31486 ,-30974 ,-30462 ,-29950 ,-29438 ,-29182 ,-28670 ,-28158 ,-27646 ,-27134 ,-26622 ,-26110 ,-25598 ,-25342 , -24830 ,-24318 ,-23806 ,-23294 ,-22782 ,-22270 ,-22014 ,-21502 ,-20990 ,-20478 ,-19966 ,-19454 ,-18942 ,-18430 ,-18174 , -17662 ,-17150 ,-16638 ,-16127 ,-15615 ,-15103 ,-14847 ,-14335 ,-13823 ,-13311 ,-12799 ,-12287 ,-11775 ,-11263 ,-11007 , -10495 ,-9983 ,-9471 ,-8959 ,-8447 ,-7935 ,-7679 ,-7167 ,-6655 ,-6143 ,-5631 ,-5119 ,-4607 ,-4095 ,-3839 , -3327 ,-2815 ,4130 ,4607 ,5119 ,5631 ,6143 ,6399 ,6911 ,7423 ,7679 ,8191 ,8703 ,9215 ,9471 , 9983 ,10495 ,11007 ,11263 ,11775 ,12287 ,12799 ,13055 ,13567 ,14079 ,14335 ,14847 ,15359 ,15871 ,16127 , 16638 ,17150 ,17662 ,17918 ,18429 ,18941 ,19453 ,19709 ,20221 ,20733 ,20989 ,21501 ,22013 ,22525 ,22781 , 23293 ,23805 ,24317 ,24573 ,25085 ,25597 ,26109 ,26365 ,26877 ,27389 ,27645 ,28157 ,28669 ,29181 ,29437 , 29949 ,30461 ,30973 ,31229 ,31741 ,32253 ,32765 ,32253 ,31741 ,31229 ,30973 ,30461 ,29949 ,29437 ,29181 , 28669 ,28157 ,27645 ,27389 ,26877 ,26365 ,26109 ,25597 ,25085 ,24573 ,24317 ,23805 ,23293 ,22781 ,22525 , 22013 ,21501 ,20989 ,20733 ,20221 ,19709 ,19453 ,18941 ,18430 ,17918 ,17662 ,17150 ,16638 ,16127 ,15871 , 15359 ,14847 ,14335 ,14079 ,13567 ,13055 ,12799 ,12287 ,11775 ,11263 ,11007 ,10495 ,9983 ,9471 ,9215 , 8703 ,8191 ,7679 ,7423 ,6911 ,6399 ,6143 ,5631 ,5119 ,4607 ,4352 ,-4863 ,-5375 ,-5887 ,-6143 , -6655 ,-7167 ,-7679 ,-7935 ,-8447 ,-8959 ,-9471 ,-9727 ,-10239 ,-10751 ,-11263 ,-11519 ,-12031 ,-12543 ,-12799 , -13311 ,-13823 ,-14335 ,-14591 ,-15103 ,-15615 ,-16127 ,-16383 ,-16894 ,-17406 ,-17918 ,-18174 ,-18686 ,-19198 ,-19454 , -19966 ,-20478 ,-20990 ,-21246 ,-21758 ,-22270 ,-22782 ,-23038 ,-23550 ,-24062 ,-24574 ,-24830 ,-25342 ,-25854 ,-26110 , -26622 ,-27134 ,-27646 ,-27902 ,-28414 ,-28926 ,-29438 ,-29694 ,-30206 ,-30718 ,-31230 ,-31486 ,-31998 ,-32510 ,-32766 , -32510 ,-31998 ,-31486 ,-31230 ,-30718 ,-30206 ,-29694 ,-29438 ,-28926 ,-28414 ,-27902 ,-27646 ,-27134 ,-26622 ,-26110 , -25854 ,-25342 ,-24830 ,-24574 ,-24062 ,-23550 ,-23038 ,-22782 ,-22270 ,-21758 ,-21246 ,-20990 ,-20478 ,-19966 ,-19454 , -19198 ,-18686 ,-18174 ,-17918 ,-17406 ,-16894 ,-16383 ,-16127 ,-15615 ,-15103 ,-14591 ,-14335 ,-13823 ,-13311 ,-12799 , -12543 ,-12031 ,-11519 ,-11263 ,-10751 ,-10239 ,-9727 ,-9471 ,-8959 ,-8447 ,-7935 ,-7679 ,-7167 ,-6655 ,-6143 , -5887 ,-5375 ,-4863 ,6451 ,6911 ,7167 ,7679 ,8191 ,8447 ,8959 ,9215 ,9727 ,10239 ,10495 ,11007 , 11263 ,11775 ,12287 ,12543 ,13055 ,13311 ,13823 ,14335 ,14591 ,15103 ,15359 ,15871 ,16383 ,16638 ,17150 , 17406 ,17918 ,18430 ,18686 ,19198 ,19453 ,19965 ,20477 ,20733 ,21245 ,21501 ,22013 ,22525 ,22781 ,23293 , 23549 ,24061 ,24573 ,24829 ,25341 ,25597 ,26109 ,26621 ,26877 ,27389 ,27645 ,28157 ,28669 ,28925 ,29437 , 29693 ,30205 ,30717 ,30973 ,31485 ,31741 ,32253 ,32765 ,32253 ,31741 ,31485 ,30973 ,30717 ,30205 ,29693 , 29437 ,28925 ,28669 ,28157 ,27645 ,27389 ,26877 ,26621 ,26109 ,25597 ,25341 ,24829 ,24573 ,24061 ,23549 , 23293 ,22781 ,22525 ,22013 ,21501 ,21245 ,20733 ,20477 ,19965 ,19454 ,19198 ,18686 ,18430 ,17918 ,17406 , 17150 ,16638 ,16383 ,15871 ,15359 ,15103 ,14591 ,14335 ,13823 ,13311 ,13055 ,12543 ,12287 ,11775 ,11263 , 11007 ,10495 ,10239 ,9727 ,9215 ,8959 ,8447 ,8191 ,7679 ,7167 ,6911 ,6400 ,-7167 ,-7423 ,-7935 , -8191 ,-8703 ,-9215 ,-9471 ,-9983 ,-10239 ,-10751 ,-11263 ,-11519 ,-12031 ,-12287 ,-12799 ,-13311 ,-13567 ,-14079 , -14335 ,-14847 ,-15359 ,-15615 ,-16127 ,-16383 ,-16894 ,-17406 ,-17662 ,-18174 ,-18430 ,-18942 ,-19454 ,-19710 ,-20222 , -20478 ,-20990 ,-21502 ,-21758 ,-22270 ,-22526 ,-23038 ,-23550 ,-23806 ,-24318 ,-24574 ,-25086 ,-25598 ,-25854 ,-26366 , -26622 ,-27134 ,-27646 ,-27902 ,-28414 ,-28670 ,-29182 ,-29694 ,-29950 ,-30462 ,-30718 ,-31230 ,-31742 ,-31998 ,-32510 , -32766 ,-32510 ,-31998 ,-31742 ,-31230 ,-30718 ,-30462 ,-29950 ,-29694 ,-29182 ,-28670 ,-28414 ,-27902 ,-27646 ,-27134 , -26622 ,-26366 ,-25854 ,-25598 ,-25086 ,-24574 ,-24318 ,-23806 ,-23550 ,-23038 ,-22526 ,-22270 ,-21758 ,-21502 ,-20990 , -20478 ,-20222 ,-19710 ,-19454 ,-18942 ,-18430 ,-18174 ,-17662 ,-17406 ,-16894 ,-16383 ,-16127 ,-15615 ,-15359 ,-14847 , -14335 ,-14079 ,-13567 ,-13311 ,-12799 ,-12287 ,-12031 ,-11519 ,-11263 ,-10751 ,-10239 ,-9983 ,-9471 ,-9215 ,-8703 , -8191 ,-7935 ,-7423 ,-7167 ,8516 ,8959 ,9471 ,9727 ,10239 ,10495 ,10751 ,11263 ,11519 ,12031 ,12287 , 12799 ,13055 ,13567 ,13823 ,14335 ,14591 ,15103 ,15359 ,15871 ,16127 ,16383 ,16894 ,17150 ,17662 ,17918 , 18430 ,18686 ,19198 ,19454 ,19966 ,20222 ,20733 ,20989 ,21501 ,21757 ,22013 ,22525 ,22781 ,23293 ,23549 , 24061 ,24317 ,24829 ,25085 ,25597 ,25853 ,26365 ,26621 ,27133 ,27389 ,27645 ,28157 ,28413 ,28925 ,29181 , 29693 ,29949 ,30461 ,30717 ,31229 ,31485 ,31997 ,32253 ,32765 ,32253 ,31997 ,31485 ,31229 ,30717 ,30461 , 29949 ,29693 ,29181 ,28925 ,28413 ,28157 ,27645 ,27389 ,27133 ,26621 ,26365 ,25853 ,25597 ,25085 ,24829 , 24317 ,24061 ,23549 ,23293 ,22781 ,22525 ,22013 ,21757 ,21501 ,20989 ,20734 ,20222 ,19966 ,19454 ,19198 , 18686 ,18430 ,17918 ,17662 ,17150 ,16894 ,16383 ,16127 ,15871 ,15359 ,15103 ,14591 ,14335 ,13823 ,13567 , 13055 ,12799 ,12287 ,12031 ,11519 ,11263 ,10751 ,10495 ,10239 ,9727 ,9471 ,8959 ,8704 ,-9215 ,-9727 , -9983 ,-10239 ,-10751 ,-11007 ,-11519 ,-11775 ,-12287 ,-12543 ,-13055 ,-13311 ,-13823 ,-14079 ,-14591 ,-14847 ,-15359 , -15615 ,-15871 ,-16383 ,-16638 ,-17150 ,-17406 ,-17918 ,-18174 ,-18686 ,-18942 ,-19454 ,-19710 ,-20222 ,-20478 ,-20990 , -21246 ,-21502 ,-22014 ,-22270 ,-22782 ,-23038 ,-23550 ,-23806 ,-24318 ,-24574 ,-25086 ,-25342 ,-25854 ,-26110 ,-26622 , -26878 ,-27134 ,-27646 ,-27902 ,-28414 ,-28670 ,-29182 ,-29438 ,-29950 ,-30206 ,-30718 ,-30974 ,-31486 ,-31742 ,-32254 , -32510 ,-32766 ,-32510 ,-32254 ,-31742 ,-31486 ,-30974 ,-30718 ,-30206 ,-29950 ,-29438 ,-29182 ,-28670 ,-28414 ,-27902 , -27646 ,-27134 ,-26878 ,-26622 ,-26110 ,-25854 ,-25342 ,-25086 ,-24574 ,-24318 ,-23806 ,-23550 ,-23038 ,-22782 ,-22270 , -22014 ,-21502 ,-21246 ,-20990 ,-20478 ,-20222 ,-19710 ,-19454 ,-18942 ,-18686 ,-18174 ,-17918 ,-17406 ,-17150 ,-16638 , -16383 ,-15871 ,-15615 ,-15359 ,-14847 ,-14591 ,-14079 ,-13823 ,-13311 ,-13055 ,-12543 ,-12287 ,-11775 ,-11519 ,-11007 , -10751 ,-10239 ,-9983 ,-9727 ,-9215 ,10837 ,11263 ,11519 ,11775 ,12287 ,12543 ,12799 ,13311 ,13567 ,13823 , 14335 ,14591 ,14847 ,15359 ,15615 ,15871 ,16383 ,16638 ,16894 ,17406 ,17662 ,17918 ,18430 ,18686 ,18942 , 19454 ,19710 ,19966 ,20478 ,20734 ,20990 ,21502 ,21757 ,22013 ,22525 ,22781 ,23037 ,23549 ,23805 ,24061 , 24573 ,24829 ,25085 ,25597 ,25853 ,26109 ,26621 ,26877 ,27133 ,27645 ,27901 ,28157 ,28669 ,28925 ,29181 , 29693 ,29949 ,30205 ,30717 ,30973 ,31229 ,31741 ,31997 ,32253 ,32765 ,32253 ,31997 ,31741 ,31229 ,30973 , 30717 ,30205 ,29949 ,29693 ,29181 ,28925 ,28669 ,28157 ,27901 ,27645 ,27133 ,26877 ,26621 ,26109 ,25853 , 25597 ,25085 ,24829 ,24573 ,24061 ,23805 ,23549 ,23037 ,22781 ,22525 ,22013 ,21758 ,21502 ,20990 ,20734 , 20478 ,19966 ,19710 ,19454 ,18942 ,18686 ,18430 ,17918 ,17662 ,17406 ,16894 ,16638 ,16383 ,15871 ,15615 , 15359 ,14847 ,14591 ,14335 ,13823 ,13567 ,13311 ,12799 ,12543 ,12287 ,11775 ,11519 ,11263 ,10752 ,-11263 , -11775 ,-12031 ,-12287 ,-12799 ,-13055 ,-13311 ,-13823 ,-14079 ,-14335 ,-14847 ,-15103 ,-15359 ,-15871 ,-16127 ,-16383 , -16894 ,-17150 ,-17406 ,-17918 ,-18174 ,-18430 ,-18942 ,-19198 ,-19454 ,-19966 ,-20222 ,-20478 ,-20990 ,-21246 ,-21502 , -22014 ,-22270 ,-22526 ,-23038 ,-23294 ,-23550 ,-24062 ,-24318 ,-24574 ,-25086 ,-25342 ,-25598 ,-26110 ,-26366 ,-26622 , -27134 ,-27390 ,-27646 ,-28158 ,-28414 ,-28670 ,-29182 ,-29438 ,-29694 ,-30206 ,-30462 ,-30718 ,-31230 ,-31486 ,-31742 , -32254 ,-32510 ,-32766 ,-32510 ,-32254 ,-31742 ,-31486 ,-31230 ,-30718 ,-30462 ,-30206 ,-29694 ,-29438 ,-29182 ,-28670 , -28414 ,-28158 ,-27646 ,-27390 ,-27134 ,-26622 ,-26366 ,-26110 ,-25598 ,-25342 ,-25086 ,-24574 ,-24318 ,-24062 ,-23550 , -23294 ,-23038 ,-22526 ,-22270 ,-22014 ,-21502 ,-21246 ,-20990 ,-20478 ,-20222 ,-19966 ,-19454 ,-19198 ,-18942 ,-18430 , -18174 ,-17918 ,-17406 ,-17150 ,-16894 ,-16383 ,-16127 ,-15871 ,-15359 ,-15103 ,-14847 ,-14335 ,-14079 ,-13823 ,-13311 , -13055 ,-12799 ,-12287 ,-12031 ,-11775 ,-11263 ,12902 ,13311 ,13567 ,13823 ,14335 ,14591 ,14847 ,15103 ,15359 , 15871 ,16127 ,16383 ,16638 ,16894 ,17406 ,17662 ,17918 ,18174 ,18430 ,18942 ,19198 ,19454 ,19710 ,19966 , 20478 ,20734 ,20990 ,21246 ,21502 ,22014 ,22270 ,22526 ,22781 ,23037 ,23549 ,23805 ,24061 ,24317 ,24573 , 25085 ,25341 ,25597 ,25853 ,26109 ,26621 ,26877 ,27133 ,27389 ,27645 ,28157 ,28413 ,28669 ,28925 ,29181 , 29693 ,29949 ,30205 ,30461 ,30717 ,31229 ,31485 ,31741 ,31997 ,32253 ,32765 ,32253 ,31997 ,31741 ,31485 , 31229 ,30717 ,30461 ,30205 ,29949 ,29693 ,29181 ,28925 ,28669 ,28413 ,28157 ,27645 ,27389 ,27133 ,26877 , 26621 ,26109 ,25853 ,25597 ,25341 ,25085 ,24573 ,24317 ,24061 ,23805 ,23549 ,23037 ,22782 ,22526 ,22270 , 22014 ,21502 ,21246 ,20990 ,20734 ,20478 ,19966 ,19710 ,19454 ,19198 ,18942 ,18430 ,18174 ,17918 ,17662 , 17406 ,16894 ,16638 ,16383 ,16127 ,15871 ,15359 ,15103 ,14847 ,14591 ,14335 ,13823 ,13567 ,13311 ,13056 , -13567 ,-13823 ,-14079 ,-14335 ,-14847 ,-15103 ,-15359 ,-15615 ,-15871 ,-16383 ,-16638 ,-16894 ,-17150 ,-17406 ,-17918 , -18174 ,-18430 ,-18686 ,-18942 ,-19454 ,-19710 ,-19966 ,-20222 ,-20478 ,-20990 ,-21246 ,-21502 ,-21758 ,-22014 ,-22526 , -22782 ,-23038 ,-23294 ,-23550 ,-24062 ,-24318 ,-24574 ,-24830 ,-25086 ,-25598 ,-25854 ,-26110 ,-26366 ,-26622 ,-27134 , -27390 ,-27646 ,-27902 ,-28158 ,-28670 ,-28926 ,-29182 ,-29438 ,-29694 ,-30206 ,-30462 ,-30718 ,-30974 ,-31230 ,-31742 , -31998 ,-32254 ,-32510 ,-32766 ,-32510 ,-32254 ,-31998 ,-31742 ,-31230 ,-30974 ,-30718 ,-30462 ,-30206 ,-29694 ,-29438 , -29182 ,-28926 ,-28670 ,-28158 ,-27902 ,-27646 ,-27390 ,-27134 ,-26622 ,-26366 ,-26110 ,-25854 ,-25598 ,-25086 ,-24830 , -24574 ,-24318 ,-24062 ,-23550 ,-23294 ,-23038 ,-22782 ,-22526 ,-22014 ,-21758 ,-21502 ,-21246 ,-20990 ,-20478 ,-20222 , -19966 ,-19710 ,-19454 ,-18942 ,-18686 ,-18430 ,-18174 ,-17918 ,-17406 ,-17150 ,-16894 ,-16638 ,-16383 ,-15871 ,-15615 , -15359 ,-15103 ,-14847 ,-14335 ,-14079 ,-13823 ,-13567 ,15224 ,15360 ,15616 ,15872 ,16384 ,16640 ,16896 ,17152 , 17408 ,17664 ,17920 ,18176 ,18432 ,18688 ,18944 ,19200 ,19456 ,19712 ,19968 ,20480 ,20736 ,20992 ,21248 , 21504 ,21760 ,22016 ,22272 ,22528 ,22784 ,23040 ,23296 ,23552 ,23807 ,24063 ,24575 ,24831 ,25087 ,25343 , 25599 ,25855 ,26111 ,26367 ,26623 ,26879 ,27135 ,27391 ,27647 ,27903 ,28159 ,28671 ,28927 ,29183 ,29439 , 29695 ,29951 ,30207 ,30463 ,30719 ,30975 ,31231 ,31487 ,31743 ,31999 ,32255 ,32767 ,32255 ,31999 ,31743 , 31487 ,31231 ,30975 ,30719 ,30463 ,30207 ,29951 ,29695 ,29439 ,29183 ,28927 ,28671 ,28159 ,27903 ,27647 , 27391 ,27135 ,26879 ,26623 ,26367 ,26111 ,25855 ,25599 ,25343 ,25087 ,24831 ,24575 ,24063 ,23808 ,23552 , 23296 ,23040 ,22784 ,22528 ,22272 ,22016 ,21760 ,21504 ,21248 ,20992 ,20736 ,20480 ,19968 ,19712 ,19456 , 19200 ,18944 ,18688 ,18432 ,18176 ,17920 ,17664 ,17408 ,17152 ,16896 ,16640 ,16384 ,15872 ,15616 ,15360 , 15105 ,-15615 ,-15871 ,-16127 ,-16383 ,-16895 ,-17151 ,-17407 ,-17663 ,-17919 ,-18175 ,-18431 ,-18687 ,-18943 ,-19199 , -19455 ,-19711 ,-19967 ,-20223 ,-20479 ,-20991 ,-21247 ,-21503 ,-21759 ,-22015 ,-22271 ,-22527 ,-22783 ,-23039 ,-23295 , -23551 ,-23807 ,-24063 ,-24319 ,-24575 ,-25087 ,-25343 ,-25599 ,-25855 ,-26111 ,-26367 ,-26623 ,-26879 ,-27135 ,-27391 , -27647 ,-27903 ,-28159 ,-28415 ,-28671 ,-29183 ,-29439 ,-29695 ,-29951 ,-30207 ,-30463 ,-30719 ,-30975 ,-31231 ,-31487 , -31743 ,-31999 ,-32255 ,-32511 ,-32767 ,-32511 ,-32255 ,-31999 ,-31743 ,-31487 ,-31231 ,-30975 ,-30719 ,-30463 ,-30207 , -29951 ,-29695 ,-29439 ,-29183 ,-28671 ,-28415 ,-28159 ,-27903 ,-27647 ,-27391 ,-27135 ,-26879 ,-26623 ,-26367 ,-26111 , -25855 ,-25599 ,-25343 ,-25087 ,-24575 ,-24319 ,-24063 ,-23807 ,-23551 ,-23295 ,-23039 ,-22783 ,-22527 ,-22271 ,-22015 , -21759 ,-21503 ,-21247 ,-20991 ,-20479 ,-20223 ,-19967 ,-19711 ,-19455 ,-19199 ,-18943 ,-18687 ,-18431 ,-18175 ,-17919 , -17663 ,-17407 ,-17151 ,-16895 ,-16383 ,-16127 ,-15871 ,-15615 ,17287 ,17662 ,17918 ,18174 ,18430 ,18430 ,18686 , 18942 ,19198 ,19454 ,19710 ,19966 ,20222 ,20478 ,20734 ,20990 ,21246 ,21502 ,21758 ,22014 ,22014 ,22270 , 22526 ,22782 ,23038 ,23294 ,23550 ,23806 ,24062 ,24318 ,24574 ,24830 ,25085 ,25341 ,25597 ,25597 ,25853 , 26109 ,26365 ,26621 ,26877 ,27133 ,27389 ,27645 ,27901 ,28157 ,28413 ,28669 ,28925 ,29181 ,29181 ,29437 , 29693 ,29949 ,30205 ,30461 ,30717 ,30973 ,31229 ,31485 ,31741 ,31997 ,32253 ,32509 ,32765 ,32509 ,32253 , 31997 ,31741 ,31485 ,31229 ,30973 ,30717 ,30461 ,30205 ,29949 ,29693 ,29437 ,29181 ,29181 ,28925 ,28669 , 28413 ,28157 ,27901 ,27645 ,27389 ,27133 ,26877 ,26621 ,26365 ,26109 ,25853 ,25597 ,25597 ,25341 ,25086 , 24830 ,24574 ,24318 ,24062 ,23806 ,23550 ,23294 ,23038 ,22782 ,22526 ,22270 ,22014 ,22014 ,21758 ,21502 , 21246 ,20990 ,20734 ,20478 ,20222 ,19966 ,19710 ,19454 ,19198 ,18942 ,18686 ,18430 ,18430 ,18174 ,17918 , 17662 ,17407 ,-17918 ,-18174 ,-18430 ,-18430 ,-18686 ,-18942 ,-19198 ,-19454 ,-19710 ,-19966 ,-20222 ,-20478 ,-20734 , -20990 ,-21246 ,-21502 ,-21758 ,-22014 ,-22014 ,-22270 ,-22526 ,-22782 ,-23038 ,-23294 ,-23550 ,-23806 ,-24062 ,-24318 , -24574 ,-24830 ,-25086 ,-25342 ,-25598 ,-25598 ,-25854 ,-26110 ,-26366 ,-26622 ,-26878 ,-27134 ,-27390 ,-27646 ,-27902 , -28158 ,-28414 ,-28670 ,-28926 ,-29182 ,-29182 ,-29438 ,-29694 ,-29950 ,-30206 ,-30462 ,-30718 ,-30974 ,-31230 ,-31486 , -31742 ,-31998 ,-32254 ,-32510 ,-32766 ,-32766 ,-32766 ,-32510 ,-32254 ,-31998 ,-31742 ,-31486 ,-31230 ,-30974 ,-30718 , -30462 ,-30206 ,-29950 ,-29694 ,-29438 ,-29182 ,-29182 ,-28926 ,-28670 ,-28414 ,-28158 ,-27902 ,-27646 ,-27390 ,-27134 , -26878 ,-26622 ,-26366 ,-26110 ,-25854 ,-25598 ,-25598 ,-25342 ,-25086 ,-24830 ,-24574 ,-24318 ,-24062 ,-23806 ,-23550 , -23294 ,-23038 ,-22782 ,-22526 ,-22270 ,-22014 ,-22014 ,-21758 ,-21502 ,-21246 ,-20990 ,-20734 ,-20478 ,-20222 ,-19966 , -19710 ,-19454 ,-19198 ,-18942 ,-18686 ,-18430 ,-18430 ,-18174 ,-17918 ,19608 ,19710 ,19966 ,20222 ,20478 ,20478 , 20734 ,20990 ,21246 ,21502 ,21502 ,21758 ,22014 ,22270 ,22526 ,22526 ,22782 ,23038 ,23294 ,23550 ,23550 , 23806 ,24062 ,24318 ,24574 ,24574 ,24830 ,25086 ,25342 ,25598 ,25598 ,25854 ,26109 ,26365 ,26621 ,26621 , 26877 ,27133 ,27389 ,27645 ,27645 ,27901 ,28157 ,28413 ,28669 ,28669 ,28925 ,29181 ,29437 ,29693 ,29693 , 29949 ,30205 ,30461 ,30717 ,30717 ,30973 ,31229 ,31485 ,31741 ,31741 ,31997 ,32253 ,32509 ,32765 ,32509 , 32253 ,31997 ,31741 ,31741 ,31485 ,31229 ,30973 ,30717 ,30717 ,30461 ,30205 ,29949 ,29693 ,29693 ,29437 , 29181 ,28925 ,28669 ,28669 ,28413 ,28157 ,27901 ,27645 ,27645 ,27389 ,27133 ,26877 ,26621 ,26621 ,26365 , 26110 ,25854 ,25598 ,25598 ,25342 ,25086 ,24830 ,24574 ,24574 ,24318 ,24062 ,23806 ,23550 ,23550 ,23294 , 23038 ,22782 ,22526 ,22526 ,22270 ,22014 ,21758 ,21502 ,21502 ,21246 ,20990 ,20734 ,20478 ,20478 ,20222 , 19966 ,19710 ,19455 ,-19966 ,-20222 ,-20478 ,-20478 ,-20734 ,-20990 ,-21246 ,-21502 ,-21502 ,-21758 ,-22014 ,-22270 , -22526 ,-22526 ,-22782 ,-23038 ,-23294 ,-23550 ,-23550 ,-23806 ,-24062 ,-24318 ,-24574 ,-24574 ,-24830 ,-25086 ,-25342 , -25598 ,-25598 ,-25854 ,-26110 ,-26366 ,-26622 ,-26622 ,-26878 ,-27134 ,-27390 ,-27646 ,-27646 ,-27902 ,-28158 ,-28414 , -28670 ,-28670 ,-28926 ,-29182 ,-29438 ,-29694 ,-29694 ,-29950 ,-30206 ,-30462 ,-30718 ,-30718 ,-30974 ,-31230 ,-31486 , -31742 ,-31742 ,-31998 ,-32254 ,-32510 ,-32766 ,-32766 ,-32766 ,-32510 ,-32254 ,-31998 ,-31742 ,-31742 ,-31486 ,-31230 , -30974 ,-30718 ,-30718 ,-30462 ,-30206 ,-29950 ,-29694 ,-29694 ,-29438 ,-29182 ,-28926 ,-28670 ,-28670 ,-28414 ,-28158 , -27902 ,-27646 ,-27646 ,-27390 ,-27134 ,-26878 ,-26622 ,-26622 ,-26366 ,-26110 ,-25854 ,-25598 ,-25598 ,-25342 ,-25086 , -24830 ,-24574 ,-24574 ,-24318 ,-24062 ,-23806 ,-23550 ,-23550 ,-23294 ,-23038 ,-22782 ,-22526 ,-22526 ,-22270 ,-22014 , -21758 ,-21502 ,-21502 ,-21246 ,-20990 ,-20734 ,-20478 ,-20478 ,-20222 ,-19966 ,21673 ,22014 ,22014 ,22270 ,22526 , 22526 ,22782 ,23038 ,23038 ,23294 ,23550 ,23550 ,23806 ,24062 ,24062 ,24318 ,24574 ,24574 ,24830 ,25086 , 25086 ,25342 ,25598 ,25598 ,25854 ,26110 ,26110 ,26366 ,26622 ,26622 ,26878 ,27134 ,27133 ,27389 ,27645 , 27645 ,27901 ,28157 ,28157 ,28413 ,28669 ,28669 ,28925 ,29181 ,29181 ,29437 ,29693 ,29693 ,29949 ,30205 , 30205 ,30461 ,30717 ,30717 ,30973 ,31229 ,31229 ,31485 ,31741 ,31741 ,31997 ,32253 ,32253 ,32509 ,32765 , 32509 ,32253 ,32253 ,31997 ,31741 ,31741 ,31485 ,31229 ,31229 ,30973 ,30717 ,30717 ,30461 ,30205 ,30205 , 29949 ,29693 ,29693 ,29437 ,29181 ,29181 ,28925 ,28669 ,28669 ,28413 ,28157 ,28157 ,27901 ,27645 ,27645 , 27389 ,27134 ,27134 ,26878 ,26622 ,26622 ,26366 ,26110 ,26110 ,25854 ,25598 ,25598 ,25342 ,25086 ,25086 , 24830 ,24574 ,24574 ,24318 ,24062 ,24062 ,23806 ,23550 ,23550 ,23294 ,23038 ,23038 ,22782 ,22526 ,22526 , 22270 ,22014 ,22014 ,21759 ,-22014 ,-22270 ,-22526 ,-22526 ,-22782 ,-23038 ,-23038 ,-23294 ,-23550 ,-23550 ,-23806 , -24062 ,-24062 ,-24318 ,-24574 ,-24574 ,-24830 ,-25086 ,-25086 ,-25342 ,-25598 ,-25598 ,-25854 ,-26110 ,-26110 ,-26366 , -26622 ,-26622 ,-26878 ,-27134 ,-27134 ,-27390 ,-27646 ,-27646 ,-27902 ,-28158 ,-28158 ,-28414 ,-28670 ,-28670 ,-28926 , -29182 ,-29182 ,-29438 ,-29694 ,-29694 ,-29950 ,-30206 ,-30206 ,-30462 ,-30718 ,-30718 ,-30974 ,-31230 ,-31230 ,-31486 , -31742 ,-31742 ,-31998 ,-32254 ,-32254 ,-32510 ,-32766 ,-32766 ,-32766 ,-32510 ,-32254 ,-32254 ,-31998 ,-31742 ,-31742 , -31486 ,-31230 ,-31230 ,-30974 ,-30718 ,-30718 ,-30462 ,-30206 ,-30206 ,-29950 ,-29694 ,-29694 ,-29438 ,-29182 ,-29182 , -28926 ,-28670 ,-28670 ,-28414 ,-28158 ,-28158 ,-27902 ,-27646 ,-27646 ,-27390 ,-27134 ,-27134 ,-26878 ,-26622 ,-26622 , -26366 ,-26110 ,-26110 ,-25854 ,-25598 ,-25598 ,-25342 ,-25086 ,-25086 ,-24830 ,-24574 ,-24574 ,-24318 ,-24062 ,-24062 , -23806 ,-23550 ,-23550 ,-23294 ,-23038 ,-23038 ,-22782 ,-22526 ,-22526 ,-22270 ,-22014 ,23994 ,24062 ,24062 ,24318 , 24574 ,24574 ,24830 ,24830 ,25086 ,25086 ,25342 ,25342 ,25598 ,25598 ,25854 ,25854 ,26110 ,26110 ,26366 , 26622 ,26622 ,26878 ,26878 ,27134 ,27134 ,27390 ,27390 ,27646 ,27646 ,27902 ,27902 ,28158 ,28157 ,28413 , 28669 ,28669 ,28925 ,28925 ,29181 ,29181 ,29437 ,29437 ,29693 ,29693 ,29949 ,29949 ,30205 ,30205 ,30461 , 30717 ,30717 ,30973 ,30973 ,31229 ,31229 ,31485 ,31485 ,31741 ,31741 ,31997 ,31997 ,32253 ,32253 ,32509 , 32765 ,32509 ,32253 ,32253 ,31997 ,31997 ,31741 ,31741 ,31485 ,31485 ,31229 ,31229 ,30973 ,30973 ,30717 , 30717 ,30461 ,30205 ,30205 ,29949 ,29949 ,29693 ,29693 ,29437 ,29437 ,29181 ,29181 ,28925 ,28925 ,28669 , 28669 ,28413 ,28158 ,28158 ,27902 ,27902 ,27646 ,27646 ,27390 ,27390 ,27134 ,27134 ,26878 ,26878 ,26622 , 26622 ,26366 ,26110 ,26110 ,25854 ,25854 ,25598 ,25598 ,25342 ,25342 ,25086 ,25086 ,24830 ,24830 ,24574 , 24574 ,24318 ,24062 ,24062 ,23807 ,-24318 ,-24318 ,-24574 ,-24574 ,-24830 ,-25086 ,-25086 ,-25342 ,-25342 ,-25598 , -25598 ,-25854 ,-25854 ,-26110 ,-26110 ,-26366 ,-26366 ,-26622 ,-26622 ,-26878 ,-27134 ,-27134 ,-27390 ,-27390 ,-27646 , -27646 ,-27902 ,-27902 ,-28158 ,-28158 ,-28414 ,-28414 ,-28670 ,-28670 ,-28926 ,-29182 ,-29182 ,-29438 ,-29438 ,-29694 , -29694 ,-29950 ,-29950 ,-30206 ,-30206 ,-30462 ,-30462 ,-30718 ,-30718 ,-30974 ,-31230 ,-31230 ,-31486 ,-31486 ,-31742 , -31742 ,-31998 ,-31998 ,-32254 ,-32254 ,-32510 ,-32510 ,-32766 ,-32766 ,-32766 ,-32510 ,-32510 ,-32254 ,-32254 ,-31998 , -31998 ,-31742 ,-31742 ,-31486 ,-31486 ,-31230 ,-31230 ,-30974 ,-30718 ,-30718 ,-30462 ,-30462 ,-30206 ,-30206 ,-29950 , -29950 ,-29694 ,-29694 ,-29438 ,-29438 ,-29182 ,-29182 ,-28926 ,-28670 ,-28670 ,-28414 ,-28414 ,-28158 ,-28158 ,-27902 , -27902 ,-27646 ,-27646 ,-27390 ,-27390 ,-27134 ,-27134 ,-26878 ,-26622 ,-26622 ,-26366 ,-26366 ,-26110 ,-26110 ,-25854 , -25854 ,-25598 ,-25598 ,-25342 ,-25342 ,-25086 ,-25086 ,-24830 ,-24574 ,-24574 ,-24318 ,-24318 ,26059 ,26110 ,26366 , 26366 ,26622 ,26622 ,26622 ,26878 ,26878 ,27134 ,27134 ,27134 ,27390 ,27390 ,27646 ,27646 ,27646 ,27902 , 27902 ,28158 ,28158 ,28158 ,28414 ,28414 ,28670 ,28670 ,28670 ,28926 ,28926 ,29182 ,29182 ,29182 ,29437 , 29437 ,29693 ,29693 ,29693 ,29949 ,29949 ,30205 ,30205 ,30205 ,30461 ,30461 ,30717 ,30717 ,30717 ,30973 , 30973 ,31229 ,31229 ,31229 ,31485 ,31485 ,31741 ,31741 ,31741 ,31997 ,31997 ,32253 ,32253 ,32253 ,32509 , 32509 ,32765 ,32509 ,32509 ,32253 ,32253 ,32253 ,31997 ,31997 ,31741 ,31741 ,31741 ,31485 ,31485 ,31229 , 31229 ,31229 ,30973 ,30973 ,30717 ,30717 ,30717 ,30461 ,30461 ,30205 ,30205 ,30205 ,29949 ,29949 ,29693 , 29693 ,29693 ,29437 ,29438 ,29182 ,29182 ,29182 ,28926 ,28926 ,28670 ,28670 ,28670 ,28414 ,28414 ,28158 , 28158 ,28158 ,27902 ,27902 ,27646 ,27646 ,27646 ,27390 ,27390 ,27134 ,27134 ,27134 ,26878 ,26878 ,26622 , 26622 ,26622 ,26366 ,26366 ,26110 ,26111 ,-26366 ,-26622 ,-26622 ,-26622 ,-26878 ,-26878 ,-27134 ,-27134 ,-27134 , -27390 ,-27390 ,-27646 ,-27646 ,-27646 ,-27902 ,-27902 ,-28158 ,-28158 ,-28158 ,-28414 ,-28414 ,-28670 ,-28670 ,-28670 , -28926 ,-28926 ,-29182 ,-29182 ,-29182 ,-29438 ,-29438 ,-29694 ,-29694 ,-29694 ,-29950 ,-29950 ,-30206 ,-30206 ,-30206 , -30462 ,-30462 ,-30718 ,-30718 ,-30718 ,-30974 ,-30974 ,-31230 ,-31230 ,-31230 ,-31486 ,-31486 ,-31742 ,-31742 ,-31742 , -31998 ,-31998 ,-32254 ,-32254 ,-32254 ,-32510 ,-32510 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32510 ,-32510 ,-32254 , -32254 ,-32254 ,-31998 ,-31998 ,-31742 ,-31742 ,-31742 ,-31486 ,-31486 ,-31230 ,-31230 ,-31230 ,-30974 ,-30974 ,-30718 , -30718 ,-30718 ,-30462 ,-30462 ,-30206 ,-30206 ,-30206 ,-29950 ,-29950 ,-29694 ,-29694 ,-29694 ,-29438 ,-29438 ,-29182 , -29182 ,-29182 ,-28926 ,-28926 ,-28670 ,-28670 ,-28670 ,-28414 ,-28414 ,-28158 ,-28158 ,-28158 ,-27902 ,-27902 ,-27646 , -27646 ,-27646 ,-27390 ,-27390 ,-27134 ,-27134 ,-27134 ,-26878 ,-26878 ,-26622 ,-26622 ,-26622 ,-26366 ,28380 ,28414 , 28414 ,28414 ,28670 ,28670 ,28670 ,28670 ,28926 ,28926 ,28926 ,28926 ,29182 ,29182 ,29182 ,29182 ,29438 , 29438 ,29438 ,29694 ,29694 ,29694 ,29694 ,29950 ,29950 ,29950 ,29950 ,30206 ,30206 ,30206 ,30206 ,30462 , 30461 ,30461 ,30717 ,30717 ,30717 ,30717 ,30973 ,30973 ,30973 ,30973 ,31229 ,31229 ,31229 ,31229 ,31485 , 31485 ,31485 ,31741 ,31741 ,31741 ,31741 ,31997 ,31997 ,31997 ,31997 ,32253 ,32253 ,32253 ,32253 ,32509 , 32509 ,32509 ,32765 ,32509 ,32509 ,32509 ,32253 ,32253 ,32253 ,32253 ,31997 ,31997 ,31997 ,31997 ,31741 , 31741 ,31741 ,31741 ,31485 ,31485 ,31485 ,31229 ,31229 ,31229 ,31229 ,30973 ,30973 ,30973 ,30973 ,30717 , 30717 ,30717 ,30717 ,30461 ,30462 ,30462 ,30206 ,30206 ,30206 ,30206 ,29950 ,29950 ,29950 ,29950 ,29694 , 29694 ,29694 ,29694 ,29438 ,29438 ,29438 ,29182 ,29182 ,29182 ,29182 ,28926 ,28926 ,28926 ,28926 ,28670 , 28670 ,28670 ,28670 ,28414 ,28414 ,28414 ,28159 ,-28670 ,-28670 ,-28670 ,-28670 ,-28926 ,-28926 ,-28926 ,-29182 , -29182 ,-29182 ,-29182 ,-29438 ,-29438 ,-29438 ,-29438 ,-29694 ,-29694 ,-29694 ,-29694 ,-29950 ,-29950 ,-29950 ,-30206 , -30206 ,-30206 ,-30206 ,-30462 ,-30462 ,-30462 ,-30462 ,-30718 ,-30718 ,-30718 ,-30718 ,-30974 ,-30974 ,-30974 ,-31230 , -31230 ,-31230 ,-31230 ,-31486 ,-31486 ,-31486 ,-31486 ,-31742 ,-31742 ,-31742 ,-31742 ,-31998 ,-31998 ,-31998 ,-32254 , -32254 ,-32254 ,-32254 ,-32510 ,-32510 ,-32510 ,-32510 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32510 , -32510 ,-32510 ,-32510 ,-32254 ,-32254 ,-32254 ,-32254 ,-31998 ,-31998 ,-31998 ,-31742 ,-31742 ,-31742 ,-31742 ,-31486 , -31486 ,-31486 ,-31486 ,-31230 ,-31230 ,-31230 ,-31230 ,-30974 ,-30974 ,-30974 ,-30718 ,-30718 ,-30718 ,-30718 ,-30462 , -30462 ,-30462 ,-30462 ,-30206 ,-30206 ,-30206 ,-30206 ,-29950 ,-29950 ,-29950 ,-29694 ,-29694 ,-29694 ,-29694 ,-29438 , -29438 ,-29438 ,-29438 ,-29182 ,-29182 ,-29182 ,-29182 ,-28926 ,-28926 ,-28926 ,-28670 ,-28670 ,-28670 ,-28670 ,30445 , 30462 ,30462 ,30462 ,30718 ,30718 ,30718 ,30718 ,30718 ,30718 ,30718 ,30718 ,30974 ,30974 ,30974 ,30974 , 30974 ,30974 ,30974 ,31230 ,31230 ,31230 ,31230 ,31230 ,31230 ,31230 ,31230 ,31486 ,31486 ,31486 ,31486 , 31486 ,31485 ,31485 ,31741 ,31741 ,31741 ,31741 ,31741 ,31741 ,31741 ,31741 ,31997 ,31997 ,31997 ,31997 , 31997 ,31997 ,31997 ,32253 ,32253 ,32253 ,32253 ,32253 ,32253 ,32253 ,32253 ,32509 ,32509 ,32509 ,32509 , 32509 ,32509 ,32509 ,32765 ,32509 ,32509 ,32509 ,32509 ,32509 ,32509 ,32509 ,32253 ,32253 ,32253 ,32253 , 32253 ,32253 ,32253 ,32253 ,31997 ,31997 ,31997 ,31997 ,31997 ,31997 ,31997 ,31741 ,31741 ,31741 ,31741 , 31741 ,31741 ,31741 ,31741 ,31485 ,31486 ,31486 ,31486 ,31486 ,31486 ,31486 ,31230 ,31230 ,31230 ,31230 , 31230 ,31230 ,31230 ,31230 ,30974 ,30974 ,30974 ,30974 ,30974 ,30974 ,30974 ,30718 ,30718 ,30718 ,30718 , 30718 ,30718 ,30718 ,30718 ,30462 ,30462 ,30462 ,30463 ,-30718 ,-30718 ,-30718 ,-30718 ,-30974 ,-30974 ,-30974 , -30974 ,-30974 ,-30974 ,-30974 ,-31230 ,-31230 ,-31230 ,-31230 ,-31230 ,-31230 ,-31230 ,-31230 ,-31486 ,-31486 ,-31486 , -31486 ,-31486 ,-31486 ,-31486 ,-31742 ,-31742 ,-31742 ,-31742 ,-31742 ,-31742 ,-31742 ,-31742 ,-31998 ,-31998 ,-31998 , -31998 ,-31998 ,-31998 ,-31998 ,-32254 ,-32254 ,-32254 ,-32254 ,-32254 ,-32254 ,-32254 ,-32254 ,-32510 ,-32510 ,-32510 , -32510 ,-32510 ,-32510 ,-32510 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32510 ,-32510 ,-32510 ,-32510 ,-32510 ,-32510 ,-32510 ,-32254 ,-32254 ,-32254 ,-32254 , -32254 ,-32254 ,-32254 ,-32254 ,-31998 ,-31998 ,-31998 ,-31998 ,-31998 ,-31998 ,-31998 ,-31742 ,-31742 ,-31742 ,-31742 , -31742 ,-31742 ,-31742 ,-31742 ,-31486 ,-31486 ,-31486 ,-31486 ,-31486 ,-31486 ,-31486 ,-31230 ,-31230 ,-31230 ,-31230 , -31230 ,-31230 ,-31230 ,-31230 ,-30974 ,-30974 ,-30974 ,-30974 ,-30974 ,-30974 ,-30974 ,-30718 ,-30718 ,-30718 ,-30718 , 32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 , 32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 , 32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 , 32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 , 32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 , 32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 , 32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 , 32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 , 32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 , 32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 , 32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 , 32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 , 32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 , 32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 , 32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 , 32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 , 32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 , 32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 , 32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 , 32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 , 32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 , 32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 , 32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 , 32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 , 32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 , 32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 , 32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 , 32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 , 32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 , 32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 , 32766 ,32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 , 32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 , 32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 , 32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 , 32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 , 32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 , 32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 , 32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 , 32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 , 32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 , 32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 , 32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 , 32766 ,32766 ,32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 , 32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 , 32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 , 32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 , 32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 , 32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 , 32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 , 32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 , 32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 , 32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 , 32766 ,32766 ,32766 ,32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 , 32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 , 32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 , 32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 , 32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 , 32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 , 32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 , 32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 , 32766 ,32766 ,32766 ,32766 ,32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,32766 ,32766 ,32766 ,32766 ,32766 , 32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 , 32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 , 32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,32766 ,32766 ,32766 ,32766 , 32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 , 32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 , 32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,32766 ,32766 ,32766 , 32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 , 32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,32766 ,32766 , 32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 , 32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,32766 , 32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , 32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 ,-32766 , -32766 ,32765 ,32765 ,32765 ,32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 , -32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 , -32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 , -32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 , -32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 , -32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 , -32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 , -32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 , -32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 , -32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 , -32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 , -32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 , -32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 , -32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 , -32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 , -32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 , -32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 , -32765 ,-32765 ,32765 ,32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 , -32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 , -32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 , -32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 , -32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 , -32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 , -32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 , -32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 , -32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 , -32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 , -32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 , -32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 , -32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 , -32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 , -32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 , -32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 , -32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 , -32765 ,-32765 ,-32765 ,32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 , -32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 , -32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 , -32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 , -32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 , -32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 , -32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 , -32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 , -32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 , -32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 , -32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 , -32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 , -32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 , -32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 , -32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 , -32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 , -32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 ,-32765 , -32765 ,-32765 ,-32765 ,-32765 , // sounds/wavetables/VIRAL.WAV 1 ,802 ,1602 ,2403 ,3202 ,4000 ,4795 ,5587 ,6375 ,7160 ,7940 ,8716 ,9485 ,10250 ,11010 , 11760 ,12507 ,13243 ,13973 ,14694 ,15406 ,16110 ,16803 ,17487 ,18159 ,18822 ,19472 ,20111 ,20739 ,21355 , 21956 ,22544 ,23121 ,23682 ,24229 ,24761 ,25279 ,25784 ,26270 ,26742 ,27197 ,27638 ,28060 ,28466 ,28855 , 29227 ,29581 ,29916 ,30234 ,30535 ,30818 ,31081 ,31325 ,31552 ,31759 ,31946 ,32115 ,32265 ,32396 ,32506 , 32597 ,32669 ,32722 ,32753 ,32766 ,32760 ,32734 ,32687 ,32621 ,32535 ,32431 ,32306 ,32161 ,31998 ,31817 , 31615 ,31394 ,31155 ,30898 ,30621 ,30325 ,30011 ,29680 ,29332 ,28964 ,28580 ,28179 ,27761 ,27324 ,26871 , 26404 ,25922 ,25421 ,24906 ,24377 ,23834 ,23275 ,22703 ,22116 ,21517 ,20904 ,20279 ,19642 ,18993 ,18332 , 17660 ,16979 ,16287 ,15584 ,14872 ,14151 ,13422 ,12685 ,11940 ,11188 ,10429 ,9664 ,8893 ,8117 ,7336 , 6550 ,5760 ,4966 ,4170 ,3370 ,2570 ,1767 ,964 ,162 ,-640 ,-1444 ,-2247 ,-3049 ,-3849 ,-4647 , -5441 ,-6234 ,-7021 ,-7805 ,-8584 ,-9357 ,-10125 ,-10887 ,-11643 ,-12391 ,-13133 ,-13865 ,-14590 ,-15307 ,-16013 , -16710 ,-17397 ,-18074 ,-18739 ,-19393 ,-20036 ,-20667 ,-21286 ,-21890 ,-22482 ,-23061 ,-23627 ,-24176 ,-24712 ,-25234 , -25740 ,-26229 ,-26703 ,-27162 ,-27606 ,-28031 ,-28438 ,-28829 ,-29205 ,-29560 ,-29898 ,-30219 ,-30522 ,-30806 ,-31069 , -31316 ,-31544 ,-31753 ,-31940 ,-32111 ,-32262 ,-32394 ,-32504 ,-32595 ,-32667 ,-32721 ,-32753 ,-32766 ,-32759 ,-32733 , -32686 ,-32618 ,-32533 ,-32428 ,-32302 ,-32157 ,-31993 ,-31810 ,-31608 ,-31385 ,-31144 ,-30885 ,-30606 ,-30309 ,-29993 , -29660 ,-29309 ,-28939 ,-28552 ,-28149 ,-27728 ,-27289 ,-26835 ,-26364 ,-25879 ,-25375 ,-24858 ,-24325 ,-23779 ,-23217 , -22641 ,-22051 ,-21449 ,-20832 ,-20204 ,-19563 ,-18910 ,-18247 ,-17571 ,-16885 ,-16191 ,-15483 ,-14768 ,-14043 ,-13312 , -12570 ,-11822 ,-11066 ,-10304 ,-9535 ,-8760 ,-7981 ,-7196 ,-6407 ,-5614 ,-4816 ,-4017 ,-3215 ,-2412 ,-1606 , -801 ,401 ,946 ,1495 ,2040 ,2580 ,3118 ,3657 ,4191 ,4722 ,5253 ,5780 ,6305 ,6828 ,7349 , 7864 ,8380 ,8893 ,9402 ,9910 ,10415 ,10919 ,11421 ,11918 ,12415 ,12909 ,13401 ,13889 ,14377 ,14862 , 15345 ,15824 ,16300 ,16775 ,17250 ,17722 ,18192 ,18656 ,19122 ,19584 ,20043 ,20501 ,20955 ,21410 ,21862 , 22311 ,22760 ,23204 ,23647 ,24088 ,24528 ,24964 ,25398 ,25831 ,26259 ,26689 ,27115 ,27539 ,27962 ,28383 , 28802 ,29218 ,29633 ,30044 ,30454 ,30861 ,31264 ,31668 ,32069 ,32469 ,32766 ,32669 ,32257 ,31833 ,31388 , 30925 ,30443 ,29944 ,29432 ,28908 ,28369 ,27820 ,27262 ,26698 ,26126 ,25545 ,24961 ,24370 ,23776 ,23179 , 22578 ,21975 ,21371 ,20766 ,20159 ,19549 ,18940 ,18332 ,17724 ,17114 ,16506 ,15899 ,15292 ,14688 ,14082 , 13480 ,12880 ,12279 ,11681 ,11085 ,10490 ,9897 ,9309 ,8719 ,8132 ,7547 ,6966 ,6385 ,5809 ,5233 , 4660 ,4089 ,3521 ,2955 ,2392 ,1834 ,1274 ,717 ,167 ,-381 ,-928 ,-1474 ,-2017 ,-2559 ,-3101 , -3644 ,-4180 ,-4711 ,-5239 ,-5764 ,-6289 ,-6810 ,-7328 ,-7847 ,-8361 ,-8872 ,-9381 ,-9887 ,-10391 ,-10893 , -11391 ,-11891 ,-12384 ,-12877 ,-13367 ,-13853 ,-14339 ,-14823 ,-15301 ,-15780 ,-16256 ,-16730 ,-17200 ,-17667 ,-18134 , -18599 ,-19061 ,-19521 ,-19978 ,-20437 ,-20889 ,-21339 ,-21789 ,-22236 ,-22679 ,-23123 ,-23562 ,-24001 ,-24435 ,-24868 , -25300 ,-25726 ,-26151 ,-26577 ,-27000 ,-27421 ,-27840 ,-28256 ,-28671 ,-29085 ,-29498 ,-29902 ,-30312 ,-30715 ,-31118 , -31520 ,-31920 ,-32316 ,-32698 ,-32766 ,-32348 ,-31924 ,-31483 ,-31019 ,-30538 ,-30039 ,-29523 ,-28998 ,-28459 ,-27909 , -27347 ,-26780 ,-26206 ,-25624 ,-25037 ,-24446 ,-23853 ,-23253 ,-22649 ,-22044 ,-21434 ,-20825 ,-20218 ,-19606 ,-18993 , -18381 ,-17770 ,-17160 ,-16550 ,-15941 ,-15332 ,-14725 ,-14121 ,-13509 ,-12906 ,-12306 ,-11705 ,-11109 ,-10513 ,-9918 , -9323 ,-8735 ,-8148 ,-7562 ,-6979 ,-6399 ,-5819 ,-5243 ,-4671 ,-4097 ,-3530 ,-2962 ,-2398 ,-1837 ,-1278 , -722 ,-170 ,5756 ,6205 ,6555 ,6694 ,6658 ,6874 ,7693 ,8914 ,9709 ,8995 ,7364 ,6479 ,7710 , 10825 ,13663 ,14441 ,13011 ,10870 ,10030 ,11202 ,13423 ,14901 ,14156 ,12278 ,11104 ,11881 ,13728 ,14445 , 13120 ,10691 ,9488 ,10571 ,13141 ,15434 ,15639 ,13945 ,11982 ,11546 ,13772 ,16870 ,18875 ,18754 ,17368 , 16412 ,16357 ,16834 ,17241 ,17477 ,17756 ,18139 ,18631 ,19152 ,19666 ,19890 ,19778 ,19776 ,20104 ,20636 , 21161 ,21837 ,22729 ,23365 ,23048 ,21815 ,20851 ,21299 ,23326 ,25983 ,27376 ,26627 ,24141 ,22048 ,22134 , 24334 ,26915 ,27753 ,26600 ,25054 ,24752 ,26328 ,28402 ,29274 ,28456 ,26935 ,26733 ,28394 ,31056 ,32766 , 32201 ,30126 ,28363 ,28391 ,30205 ,31977 ,32400 ,31232 ,29091 ,27071 ,25688 ,25226 ,25825 ,26807 ,27613 , 27854 ,27210 ,25886 ,24433 ,23569 ,23676 ,24120 ,23859 ,22336 ,20149 ,18660 ,18374 ,18554 ,17907 ,15871 , 13361 ,11731 ,11732 ,12768 ,12870 ,10941 ,7316 ,4261 ,3454 ,4974 ,7275 ,8246 ,7169 ,4809 ,2706 , 2422 ,3607 ,5025 ,5631 ,5170 ,4607 ,4604 ,5307 ,6268 ,6826 ,6619 ,5988 ,5705 ,6471 ,8014 , 9547 ,10073 ,9312 ,8006 ,7363 ,8265 ,10682 ,12946 ,13398 ,11140 ,7228 ,4212 ,3535 ,4899 ,6136 , 5554 ,3489 ,1967 ,3453 ,7779 ,12402 ,14642 ,12831 ,9756 ,8833 ,11736 ,16199 ,17528 ,13264 ,5087 , -2631 ,-5535 ,-3563 ,-374 ,-745 ,-6847 ,-14876 ,-20225 ,-19747 ,-15345 ,-12041 ,-13006 ,-17452 ,-21680 ,-21915 , -18718 ,-15229 ,-15661 ,-20117 ,-25750 ,-28720 ,-26946 ,-23241 ,-21520 ,-23619 ,-28523 ,-32248 ,-32766 ,-30265 ,-27220 , -26090 ,-27558 ,-30299 ,-32415 ,-32603 ,-31412 ,-29954 ,-29120 ,-29145 ,-29500 ,-29783 ,-29620 ,-29121 ,-28480 ,-28181 , -28256 ,-28607 ,-28392 ,-27207 ,-24974 ,-22575 ,-21150 ,-21189 ,-21991 ,-21998 ,-20152 ,-17015 ,-14232 ,-13341 ,-14122 , -14899 ,-14547 ,-12693 ,-10276 ,-8127 ,-6684 ,-5702 ,-4741 ,-3451 ,-2158 ,-1347 ,-931 ,-69 ,1623 ,3637 , 4964 ,5401 ,5519 ,11971 ,11626 ,11533 ,11988 ,12921 ,14602 ,17243 ,20141 ,22658 ,24220 ,24996 ,25495 , 25844 ,25362 ,23343 ,20287 ,17250 ,15763 ,16172 ,17619 ,19165 ,20519 ,22112 ,24025 ,25736 ,26674 ,26631 , 25941 ,25396 ,25256 ,25399 ,25413 ,25069 ,24693 ,25270 ,26932 ,28334 ,27842 ,24205 ,18817 ,14582 ,12925 , 14196 ,16973 ,19765 ,22327 ,24718 ,27106 ,29083 ,30029 ,29779 ,28824 ,27849 ,27145 ,26773 ,26427 ,25973 , 25372 ,24948 ,24852 ,24705 ,24401 ,24112 ,24339 ,25346 ,26816 ,28036 ,28528 ,28605 ,28871 ,29718 ,30592 , 30188 ,28030 ,24811 ,22139 ,20990 ,21044 ,21976 ,22882 ,23436 ,23900 ,24364 ,24848 ,25131 ,25236 ,25463 , 26119 ,27201 ,28410 ,29287 ,29397 ,29099 ,28736 ,28404 ,28088 ,27929 ,28035 ,28345 ,28635 ,28614 ,28033 , 27216 ,26510 ,26000 ,25464 ,25100 ,24970 ,24988 ,25308 ,25860 ,26717 ,27959 ,29111 ,29768 ,29775 ,29303 , 28581 ,28025 ,27795 ,27765 ,28061 ,28742 ,29303 ,29743 ,30016 ,29979 ,29462 ,29368 ,29924 ,30953 ,32184 , 32765 ,31194 ,27182 ,20773 ,12832 ,3596 ,-6696 ,-16566 ,-25209 ,-30692 ,-32765 ,-32369 ,-30519 ,-28584 ,-27030 , -25241 ,-22766 ,-19911 ,-17464 ,-15995 ,-15419 ,-15140 ,-14659 ,-13958 ,-13702 ,-14158 ,-14915 ,-15158 ,-14410 ,-12890 , -11586 ,-10822 ,-10198 ,-9277 ,-7807 ,-6776 ,-7664 ,-11173 ,-15844 ,-19304 ,-20334 ,-19065 ,-16621 ,-14127 ,-11787 , -9201 ,-6462 ,-3959 ,-2347 ,-1888 ,-2434 ,-2846 ,-2585 ,-1985 ,-1201 ,-510 ,-48 ,299 ,694 ,1057 , 1215 ,1041 ,754 ,529 ,624 ,924 ,947 ,698 ,776 ,1529 ,2666 ,3185 ,2512 ,2213 ,2493 , 2917 ,3030 ,2514 ,1922 ,1813 ,2419 ,3403 ,4568 ,5680 ,6643 ,7243 ,7529 ,7628 ,7982 ,8823 , 9697 ,10496 ,10971 ,10917 ,10473 ,9774 ,9057 ,8768 ,8771 ,8481 ,7718 ,6682 ,5798 ,5292 ,5225 , 5345 ,5694 ,6334 ,7097 ,7548 ,7778 ,8142 ,8873 ,9979 ,10899 ,11209 ,11175 ,10967 ,10587 ,10328 , 10435 ,10951 ,11598 ,12005 ,11391 ,11098 ,11600 ,13102 ,15204 ,16746 ,17300 ,17588 ,18605 ,20551 ,21453 , 19327 ,14800 ,11223 ,11257 ,14134 ,17399 ,19111 ,19692 ,20695 ,22640 ,24383 ,24502 ,23675 ,23076 ,23499 , 25327 ,27669 ,29403 ,29482 ,27963 ,26537 ,26485 ,27779 ,28975 ,29020 ,28328 ,28256 ,29872 ,32093 ,32766 , 30616 ,26274 ,22468 ,20763 ,20529 ,20340 ,19885 ,19933 ,20820 ,21885 ,22057 ,21041 ,19382 ,18275 ,18516 , 19690 ,21050 ,22003 ,22204 ,21853 ,21195 ,20291 ,19267 ,18615 ,18525 ,19093 ,20645 ,22488 ,23947 ,24701 , 24599 ,23578 ,21662 ,19131 ,16696 ,15313 ,14917 ,14925 ,14926 ,14554 ,13832 ,13105 ,12784 ,12784 ,12417 , 12172 ,12745 ,14679 ,17006 ,18732 ,18585 ,16808 ,15212 ,14567 ,14466 ,13727 ,12567 ,11777 ,11952 ,12896 , 13491 ,12872 ,11299 ,10057 ,10039 ,11089 ,12637 ,13843 ,14108 ,13467 ,12681 ,12373 ,11761 ,9695 ,6825 , 4618 ,4164 ,5233 ,6432 ,6249 ,4399 ,2500 ,1355 ,1218 ,1093 ,270 ,-391 ,469 ,2668 ,4515 , 5369 ,5366 ,4809 ,3886 ,3019 ,3020 ,4669 ,7592 ,10763 ,13518 ,16090 ,19138 ,22027 ,23491 ,23016 , 22418 ,23711 ,26609 ,28919 ,28985 ,27491 ,24678 ,19868 ,12753 ,5564 ,264 ,-2652 ,-3879 ,-4296 ,-3742 , -2497 ,-2294 ,-4256 ,-6811 ,-7507 ,-6297 ,-5146 ,-4639 ,-4773 ,-5669 ,-7307 ,-9289 ,-10868 ,-11778 ,-11853 , -11613 ,-11267 ,-11165 ,-11291 ,-11955 ,-13613 ,-16044 ,-18280 ,-19815 ,-20808 ,-21935 ,-23124 ,-23762 ,-23851 ,-24134 , -25232 ,-26840 ,-28620 ,-30436 ,-32023 ,-32766 ,-32608 ,-31898 ,-30989 ,-30352 ,-30196 ,-30423 ,-30394 ,-30056 ,-29436 , -28898 ,-28478 ,-27988 ,-27796 ,-28140 ,-28740 ,-29261 ,-29670 ,-29775 ,-28793 ,-26382 ,-23337 ,-20341 ,-17906 ,-16198 , -14796 ,-13411 ,-11808 ,-10129 ,-8853 ,-8370 ,-8336 ,-8070 ,-7470 ,-6949 ,-6749 ,-6990 ,-7169 ,-7035 ,-6759 , -6596 ,-6840 ,-7555 ,-8185 ,-7953 ,-6094 ,-3152 ,-339 ,888 ,508 ,486 ,1394 ,2838 ,3360 ,3281 , 3719 ,5605 ,8251 ,10615 ,11613 ,-2389 ,-1480 ,-294 ,867 ,1783 ,2548 ,3604 ,5237 ,7474 ,9875 , 11768 ,13089 ,13915 ,14692 ,15810 ,17322 ,18914 ,20116 ,20284 ,19487 ,18041 ,16493 ,15189 ,14359 ,13705 , 12538 ,10126 ,6524 ,2450 ,-1174 ,-3596 ,-4661 ,-4721 ,-4529 ,-4851 ,-6061 ,-8049 ,-10173 ,-11637 ,-11984 , -11280 ,-10043 ,-9143 ,-8838 ,-8852 ,-8402 ,-6846 ,-4123 ,-801 ,2374 ,4416 ,4985 ,4213 ,2877 ,2195 , 3053 ,5432 ,8606 ,11397 ,12884 ,12938 ,11916 ,10429 ,9026 ,7931 ,7049 ,5933 ,4123 ,1658 ,-921 , -2836 ,-2992 ,-1610 ,721 ,2860 ,3634 ,2812 ,995 ,-820 ,-1001 ,989 ,5147 ,10587 ,15957 ,19796 , 22023 ,23030 ,24104 ,26145 ,28873 ,31447 ,32765 ,31814 ,28936 ,25203 ,22190 ,21009 ,21361 ,22106 ,21665 , 17859 ,10830 ,1754 ,-7296 ,-13207 ,-15868 ,-15912 ,-14967 ,-14891 ,-16536 ,-19661 ,-23077 ,-25481 ,-26052 ,-25120 , -23453 ,-22183 ,-21955 ,-22458 ,-22778 ,-21617 ,-18510 ,-14260 ,-10119 ,-7367 ,-6676 ,-7300 ,-8378 ,-8912 ,-8324 , -6915 ,-5064 ,-3828 ,-4196 ,-5723 ,-7894 ,-10050 ,-11980 ,-13808 ,-15712 ,-17700 ,-19540 ,-20958 ,-21748 ,-21908 , -21216 ,-19884 ,-18302 ,-16961 ,-16012 ,-15368 ,-14562 ,-13491 ,-12146 ,-11125 ,-10136 ,-8437 ,-6302 ,-3697 ,-1045 , 1580 ,3952 ,5263 ,4638 ,2908 ,299 ,-2759 ,-5987 ,-9258 ,-12578 ,-15778 ,-18744 ,-20866 ,-21665 ,-22229 , -22712 ,-23236 ,-24083 ,-25599 ,-27734 ,-30192 ,-32097 ,-32765 ,-32419 ,-31148 ,-29289 ,-27561 ,-26624 ,-26481 ,-26917 , -27345 ,-27162 ,-26248 ,-24894 ,-23488 ,-22351 ,-21607 ,-21051 ,-20132 ,-18087 ,-14946 ,-11240 ,-8051 ,-6555 ,-6755 , -7877 ,-8938 ,-9032 ,-7933 ,-5985 ,-4025 ,-3164 ,-4145 ,-6715 ,-10004 ,-12557 ,-13552 ,-13157 ,-12188 ,-11597 , -11843 ,-12681 ,-13514 ,-13675 ,-12633 ,-10743 ,-8520 ,-6897 ,-6727 ,-7789 ,-9353 ,-10295 ,-9652 ,-7621 ,-4849 , -2174 ,-443 ,294 ,340 ,154 ,237 ,807 ,1620 ,2261 ,2169 ,1406 ,351 ,-364 ,-367 ,228 , 798 ,887 ,243 ,-945 ,-2037 ,-2596 ,-5266 ,-4943 ,-4970 ,-5193 ,-5749 ,-6634 ,-7572 ,-7953 ,-7404 , -5906 ,-3819 ,-1748 ,266 ,2197 ,4221 ,6133 ,7884 ,9164 ,9885 ,10243 ,10629 ,11298 ,12264 ,13037 , 13261 ,12875 ,12141 ,11613 ,11539 ,11938 ,12464 ,12806 ,12922 ,13104 ,13798 ,15142 ,16791 ,18257 ,18966 , 18659 ,17716 ,16570 ,15683 ,14908 ,13889 ,12289 ,10192 ,7887 ,5926 ,4519 ,3721 ,3211 ,2452 ,1289 , -85 ,-1121 ,-1600 ,-1724 ,-1919 ,-2409 ,-3144 ,-3836 ,-4181 ,-3935 ,-3222 ,-2382 ,-1723 ,-1322 ,-931 , -417 ,215 ,659 ,719 ,87 ,-687 ,-966 ,-827 ,-496 ,-117 ,178 ,325 ,287 ,16 ,-718 , -2288 ,-4520 ,-6903 ,-8755 ,-9693 ,-9883 ,-9837 ,-9829 ,-10018 ,-10220 ,-10162 ,-9668 ,-8919 ,-8545 ,-8830 , -9585 ,-10002 ,-9327 ,-7583 ,-5232 ,-3143 ,-2065 ,-1804 ,-1811 ,-1461 ,-475 ,361 ,617 ,259 ,2 , 540 ,2161 ,4383 ,6239 ,6955 ,6467 ,5384 ,4539 ,4362 ,4402 ,4115 ,3219 ,2118 ,1472 ,1786 , 2967 ,4235 ,4576 ,3731 ,2038 ,611 ,156 ,701 ,1711 ,2598 ,3355 ,4089 ,5112 ,6321 ,7407 , 7926 ,7707 ,6871 ,5962 ,5284 ,5112 ,5689 ,7047 ,9111 ,11570 ,13761 ,14869 ,14706 ,13470 ,12048 , 11092 ,10734 ,10336 ,9260 ,7361 ,5663 ,5316 ,7185 ,10521 ,13276 ,13975 ,12278 ,9792 ,9088 ,11480 , 16572 ,22179 ,25660 ,26662 ,26298 ,27009 ,29303 ,32143 ,32765 ,28584 ,19718 ,8729 ,-1120 ,-6928 ,-8962 , -9695 ,-11648 ,-15977 ,-21044 ,-24352 ,-24242 ,-21177 ,-17852 ,-17270 ,-20326 ,-25817 ,-30493 ,-32219 ,-30717 ,-27720 , -26078 ,-27147 ,-30187 ,-32765 ,-31975 ,-27559 ,-20745 ,-13974 ,-9171 ,-6293 ,-3907 ,-455 ,4616 ,9808 ,12805 , 11762 ,6324 ,-1286 ,-8622 ,-14019 ,-17198 ,-19308 ,-21599 ,-24310 ,-26743 ,-27570 ,-26423 ,-23856 ,-21376 ,-20578 , -21751 ,-24280 ,-26904 ,-28452 ,-28844 ,-28724 ,-28857 ,-29730 ,-30666 ,-31036 ,-30329 ,-28662 ,-26646 ,-24926 ,-23604 , -22307 ,-20365 ,-17504 ,-13955 ,-10473 ,-7813 ,-6119 ,16677 ,16674 ,18382 ,21870 ,26468 ,30743 ,32765 ,30973 , 24568 ,14472 ,4145 ,-3674 ,-7489 ,-6224 ,-1782 ,3789 ,8480 ,10673 ,10559 ,8836 ,6416 ,4148 ,2513 , 1701 ,1581 ,1960 ,2568 ,3199 ,3758 ,4001 ,4089 ,4073 ,4202 ,4615 ,5395 ,6436 ,7588 ,8782 , 9758 ,10602 ,11360 ,12025 ,12667 ,13282 ,14020 ,14880 ,15803 ,16834 ,17872 ,18702 ,19268 ,19667 ,19839 , 19727 ,19451 ,19193 ,19020 ,18813 ,18693 ,18671 ,18740 ,18814 ,18755 ,18930 ,18963 ,18862 ,18909 ,19122 , 19153 ,19378 ,19665 ,20148 ,20509 ,20827 ,21302 ,21818 ,22346 ,22682 ,23022 ,23349 ,23531 ,23677 ,23869 , 23854 ,23931 ,23952 ,23991 ,24165 ,24306 ,24376 ,24437 ,24589 ,24675 ,24880 ,25313 ,25709 ,26009 ,26124 , 25942 ,25456 ,24883 ,24400 ,24201 ,24258 ,24642 ,25135 ,25698 ,26277 ,26905 ,27680 ,28215 ,28069 ,27808 , 27680 ,27438 ,27095 ,26900 ,26708 ,26186 ,25475 ,24541 ,23330 ,21713 ,19964 ,18320 ,17593 ,18469 ,21297 , 25474 ,29403 ,31298 ,29315 ,22437 ,11832 ,886 ,-7261 ,-10762 ,-8492 ,-2503 ,4944 ,10824 ,14868 ,16189 , 15194 ,12721 ,9170 ,5023 ,401 ,-4647 ,-9999 ,-15397 ,-20401 ,-24916 ,-28504 ,-30977 ,-32429 ,-32765 ,-31861 , -30114 ,-27878 ,-25439 ,-23082 ,-21325 ,-19975 ,-19046 ,-18354 ,-17891 ,-17482 ,-17027 ,-16416 ,-15821 ,-15181 ,-14586 , -14137 ,-13931 ,-13883 ,-13776 ,-13550 ,-13101 ,-12633 ,-12063 ,-11668 ,-11317 ,-10982 ,-10788 ,-10600 ,-10400 ,-10051 , -9818 ,-9591 ,-9355 ,-9001 ,-8499 ,-7849 ,-7009 ,-6048 ,-5005 ,-3898 ,-2677 ,-1449 ,-250 ,907 ,1985 , 3011 ,3950 ,4790 ,5636 ,6435 ,7190 ,7926 ,8738 ,9660 ,10471 ,11261 ,11914 ,12492 ,13026 ,13606 , 14239 ,14880 ,15392 ,15604 ,15535 ,15144 ,14702 ,14307 ,14199 ,14300 ,14677 ,15072 ,15398 ,15638 ,15904 , 16244 ,16565 ,16975 ,17314 ,17675 ,17976 ,18294 ,18776 ,19289 ,19680 ,20160 ,20656 ,20908 ,21283 ,21754 , 22261 ,22330 ,22227 ,22006 ,21333 ,20397 ,19074 ,17720 ,-1396 ,854 ,5052 ,8110 ,6223 ,5522 ,8404 , 8896 ,7667 ,8921 ,9953 ,9730 ,10253 ,11379 ,11934 ,12643 ,13763 ,14779 ,15688 ,16711 ,17747 ,18722 , 19723 ,20745 ,21737 ,22696 ,23649 ,24561 ,25484 ,26320 ,27075 ,27685 ,28209 ,28692 ,29103 ,29513 ,29928 , 30339 ,30833 ,31365 ,31954 ,32563 ,32765 ,31306 ,27304 ,24754 ,27887 ,29734 ,27596 ,27613 ,29721 ,29360 , 28865 ,29844 ,30245 ,29814 ,29923 ,30046 ,29694 ,29284 ,28938 ,28420 ,27868 ,27422 ,27017 ,26629 ,26285 , 26007 ,25783 ,25570 ,25392 ,25088 ,24773 ,24502 ,24296 ,24154 ,23908 ,23594 ,23219 ,22722 ,22064 ,21293 , 20394 ,19352 ,18235 ,17079 ,15929 ,14807 ,13739 ,12728 ,11785 ,10869 ,9976 ,9084 ,8232 ,7391 ,6671 , 6057 ,5605 ,5335 ,5297 ,5413 ,5575 ,5786 ,5960 ,5917 ,5541 ,4758 ,3558 ,2054 ,236 ,-1905 , -4285 ,-6624 ,-8948 ,-11201 ,-13263 ,-15116 ,-16789 ,-18269 ,-19464 ,-20386 ,-21033 ,-21397 ,-21583 ,-21564 ,-21183 , -20429 ,-18951 ,-15892 ,-12690 ,-12953 ,-16173 ,-16663 ,-17296 ,-20896 ,-24000 ,-25814 ,-28516 ,-30758 ,-31729 ,-32377 , -32765 ,-32565 ,-32225 ,-32025 ,-31831 ,-31702 ,-31701 ,-31721 ,-31696 ,-31658 ,-31554 ,-31388 ,-31166 ,-30883 ,-30520 , -30144 ,-29796 ,-29510 ,-29239 ,-28986 ,-28693 ,-28306 ,-27764 ,-27070 ,-26108 ,-24983 ,-23712 ,-22353 ,-21346 ,-22041 , -25431 ,-27221 ,-23286 ,-21429 ,-23258 ,-22396 ,-20196 ,-20605 ,-20497 ,-19157 ,-18809 ,-18787 ,-18169 ,-17790 ,-17729 , -17505 ,-17257 ,-17136 ,-16872 ,-16436 ,-15949 ,-15368 ,-14731 ,-14021 ,-13267 ,-12550 ,-11824 ,-11236 ,-10763 ,-10309 , -9929 ,-9561 ,-9301 ,-9071 ,-8934 ,-8848 ,-8799 ,-8806 ,-8896 ,-9090 ,-9337 ,-9609 ,-9865 ,-10083 ,-10218 , -10265 ,-10170 ,-9999 ,-9807 ,-9582 ,-9339 ,-9179 ,-9008 ,-8908 ,-8846 ,-8843 ,-8870 ,-8871 ,-8957 ,-8999 , -9001 ,-9032 ,-9091 ,-9239 ,-9388 ,-9469 ,-9549 ,-9678 ,-9896 ,-9925 ,-9881 ,-9773 ,-9484 ,-9075 ,-8592 , -8050 ,-7483 ,-6920 ,-6339 ,-5787 ,-5262 ,-4768 ,-4074 ,-3017 ,6053 ,6338 ,6562 ,6530 ,6572 ,6505 , 6390 ,6219 ,6010 ,5738 ,5437 ,5134 ,4832 ,4523 ,4187 ,3848 ,3488 ,3114 ,2715 ,2319 ,1937 , 1576 ,1255 ,963 ,708 ,467 ,250 ,28 ,-186 ,-397 ,-584 ,-768 ,-914 ,-1050 ,-1153 ,-1259 , -1363 ,-1468 ,-1562 ,-1648 ,-1712 ,-1754 ,-1751 ,-1684 ,-1560 ,-1382 ,-1164 ,-906 ,-658 ,-410 ,-162 , 111 ,427 ,801 ,1217 ,1669 ,2121 ,2557 ,2956 ,3331 ,3711 ,4109 ,4548 ,5030 ,5553 ,6080 , 6617 ,7126 ,7610 ,8057 ,8503 ,8954 ,9447 ,10012 ,10676 ,11433 ,12264 ,13100 ,13910 ,14642 ,15302 , 15973 ,16716 ,17600 ,18633 ,19750 ,20849 ,21828 ,22576 ,23104 ,23481 ,23799 ,24143 ,24565 ,25046 ,25562 , 26039 ,26440 ,26775 ,27039 ,27259 ,27468 ,27706 ,27976 ,28318 ,28770 ,29347 ,30035 ,30835 ,31664 ,32367 , 32765 ,32603 ,31510 ,29197 ,25453 ,20119 ,13369 ,5920 ,-1346 ,-7644 ,-12212 ,-14749 ,-15301 ,-13905 ,-10807 , -6619 ,-2267 ,1660 ,4439 ,5743 ,5665 ,4347 ,2068 ,-756 ,-3555 ,-6080 ,-8032 ,-9323 ,-10107 ,-10533 , -10840 ,-11269 ,-12035 ,-13216 ,-14869 ,-16896 ,-19148 ,-21438 ,-23624 ,-25538 ,-27120 ,-28359 ,-29275 ,-29901 ,-30339 , -30708 ,-31029 ,-31331 ,-31623 ,-31899 ,-32136 ,-32323 ,-32449 ,-32556 ,-32632 ,-32701 ,-32739 ,-32765 ,-32744 ,-32687 , -32576 ,-32434 ,-32260 ,-32090 ,-31936 ,-31795 ,-31684 ,-31575 ,-31480 ,-31354 ,-31193 ,-30981 ,-30733 ,-30430 ,-30109 , -29770 ,-29433 ,-29075 ,-28722 ,-28330 ,-27905 ,-27448 ,-26954 ,-26404 ,-25828 ,-25270 ,-24698 ,-24131 ,-23543 ,-22951 , -22309 ,-21649 ,-20924 ,-20172 ,-19389 ,-18602 ,-17805 ,-17021 ,-16240 ,-15463 ,-14685 ,-13902 ,-13117 ,-12336 ,-11568 , -10815 ,-10113 ,-9424 ,-8783 ,-8149 ,-7534 ,-6895 ,-6262 ,-5598 ,-4964 ,-4297 ,-3736 ,-3223 ,-2607 ,-2061 , -1502 ,-973 ,-430 ,115 ,675 ,1226 ,1760 ,2267 ,2720 ,3140 ,3492 ,3811 ,4098 ,4354 ,4583 , 4802 ,5005 ,5196 ,5365 ,5498 ,5625 ,5726 ,5837 ,5895 ,5991 ,6469 ,7301 ,8144 ,8969 ,9749 , 10505 ,11206 ,11847 ,12459 ,12988 ,13491 ,13942 ,14357 ,14770 ,15151 ,15515 ,15828 ,16148 ,16429 ,16681 , 16915 ,17091 ,17247 ,17342 ,17398 ,17447 ,17423 ,17368 ,17301 ,17207 ,17114 ,17010 ,16919 ,16818 ,16715 , 16640 ,16541 ,16453 ,16312 ,16188 ,16050 ,15860 ,15661 ,15431 ,15191 ,14904 ,14641 ,14338 ,14018 ,13724 , 13446 ,13175 ,12936 ,12673 ,12484 ,12274 ,12063 ,11876 ,11659 ,11450 ,11226 ,10987 ,10701 ,10436 ,10131 , 9835 ,9527 ,9237 ,8936 ,8667 ,8397 ,8173 ,7925 ,7701 ,7492 ,7289 ,7045 ,6789 ,6597 ,6409 , 6206 ,6023 ,5814 ,5572 ,5406 ,5248 ,5047 ,4915 ,4772 ,4673 ,4604 ,4592 ,4609 ,4666 ,4740 , 4827 ,4956 ,5085 ,5213 ,5360 ,5507 ,5654 ,5804 ,5952 ,6143 ,6329 ,6553 ,6803 ,7096 ,7427 , 7784 ,8157 ,8594 ,9165 ,10613 ,16163 ,23485 ,23987 ,23603 ,24166 ,24728 ,25326 ,25874 ,26424 ,26951 , 27466 ,27982 ,28486 ,28973 ,29424 ,29848 ,30231 ,30575 ,30870 ,31115 ,31300 ,31467 ,31600 ,31714 ,31821 , 31941 ,32074 ,32209 ,32349 ,32492 ,32618 ,32712 ,32765 ,32746 ,32679 ,32505 ,32260 ,31952 ,31591 ,31154 , 30698 ,30227 ,29762 ,29307 ,28851 ,28412 ,27981 ,27521 ,27034 ,26502 ,25891 ,25213 ,24452 ,23666 ,22836 , 21974 ,21100 ,20228 ,19353 ,18454 ,17503 ,16459 ,15290 ,13916 ,12293 ,10344 ,8036 ,5237 ,1986 ,-1625 , -5434 ,-9246 ,-12789 ,-15887 ,-18462 ,-20414 ,-21688 ,-22491 ,-22941 ,-23102 ,-23214 ,-23240 ,-23307 ,-23390 ,-23523 , -23628 ,-23729 ,-23775 ,-23705 ,-23569 ,-23350 ,-23086 ,-22910 ,-22862 ,-23065 ,-23581 ,-24212 ,-21349 ,-15160 ,-18298 , -22351 ,-25510 ,-28437 ,-30709 ,-32135 ,-32765 ,-32704 ,-32198 ,-31458 ,-30415 ,-29348 ,-28176 ,-26931 ,-25731 ,-24577 , -23503 ,-22479 ,-21553 ,-20665 ,-19828 ,-19029 ,-18248 ,-17470 ,-16689 ,-15899 ,-15136 ,-14363 ,-13650 ,-12959 ,-12303 , -11585 ,-10881 ,-9853 ,-5996 ,833 ,2547 ,2392 ,3217 ,3993 ,4837 ,5666 ,6682 ,7430 ,8074 ,7377 , 6085 ,6026 ,6817 ,6174 ,6576 ,8444 ,8133 ,7739 ,8914 ,8103 ,8405 ,10073 ,9442 ,8722 ,10183 , 9712 ,8066 ,7570 ,7334 ,7257 ,7031 ,6349 ,6678 ,7699 ,7181 ,7018 ,8515 ,8562 ,7342 ,8843 , 10223 ,9966 ,11071 ,11496 ,10066 ,10722 ,13071 ,12054 ,11526 ,12929 ,11754 ,10690 ,10907 ,11388 ,11196 , 10293 ,8992 ,9738 ,11539 ,10448 ,11020 ,12214 ,10135 ,10827 ,13346 ,13304 ,12120 ,13607 ,12436 ,10587 , 13486 ,14293 ,12641 ,12926 ,13828 ,13653 ,13734 ,15030 ,15052 ,14797 ,15859 ,16849 ,18278 ,18478 ,18868 , 20236 ,20922 ,21671 ,22564 ,22952 ,22475 ,22585 ,23649 ,22725 ,21741 ,22289 ,22436 ,22693 ,23865 ,24792 , 24170 ,23873 ,25712 ,26355 ,26837 ,27856 ,26943 ,26230 ,27053 ,27394 ,27565 ,28058 ,28739 ,28607 ,30538 , 31566 ,31059 ,32765 ,32261 ,30829 ,31080 ,29857 ,27434 ,24560 ,21874 ,17648 ,14239 ,11800 ,8181 ,6919 , 4602 ,2098 ,1686 ,201 ,-3 ,290 ,134 ,-758 ,-719 ,-80 ,-1395 ,-970 ,-981 ,-2656 ,-2390 , -2740 ,-4209 ,-6967 ,-9765 ,-12165 ,-15369 ,-18077 ,-21368 ,-24507 ,-27853 ,-30806 ,-30650 ,-31369 ,-32341 ,-32632 , -32765 ,-31071 ,-29162 ,-28700 ,-29736 ,-29431 ,-27961 ,-27728 ,-26600 ,-26205 ,-26911 ,-27411 ,-27268 ,-25327 ,-23580 , -22468 ,-22789 ,-22290 ,-19642 ,-18726 ,-19090 ,-19450 ,-19010 ,-17955 ,-17740 ,-17834 ,-18308 ,-18079 ,-18112 ,-17283 , -14690 ,-13595 ,-12779 ,-12041 ,-11177 ,-8878 ,-6880 ,-7249 ,-7883 ,-5787 ,-3658 ,-3517 ,-3683 ,-4111 ,-4292 , -4029 ,-3285 ,-2152 ,-1654 ,-2533 ,-3510 ,-3016 ,-1735 ,-484 ,30 ,-441 ,199 ,2152 ,2399 ,1222 , 1794 ,2477 ,1812 ,1511 ,1928 ,1541 ,559 ,-229 ,-300 ,552 ,1068 ,801 ,1714 ,2603 ,3442 , 4168 ,3779 ,4172 ,6293 ,7465 ,7278 ,7718 ,8136 ,6877 ,6563 ,7510 ,8600 ,8641 ,7027 ,6219 , 6106 ,5563 ,5684 ,5520 ,4931 ,4873 ,5785 ,5422 ,5617 ,7055 ,6435 ,5645 ,17983 ,19051 ,15815 , 9722 ,4363 ,2591 ,3945 ,5628 ,5384 ,3665 ,3186 ,5156 ,8678 ,11297 ,11709 ,10553 ,9042 ,7634 , 6111 ,3863 ,1553 ,847 ,3100 ,7690 ,11820 ,12398 ,10412 ,8417 ,8697 ,11028 ,13640 ,14535 ,13182 , 10535 ,8629 ,8432 ,9634 ,11763 ,14627 ,17347 ,18821 ,17948 ,15091 ,12451 ,11692 ,13974 ,17831 ,20621 , 20741 ,18362 ,16564 ,17339 ,20776 ,24500 ,25089 ,21916 ,16422 ,11507 ,9881 ,10512 ,11378 ,11277 ,10749 , 11136 ,12117 ,13555 ,14337 ,14468 ,14012 ,13031 ,11285 ,8176 ,5026 ,3090 ,3637 ,7702 ,13217 ,17214 , 18522 ,18313 ,19367 ,21921 ,23618 ,22247 ,18265 ,14055 ,12614 ,14665 ,18001 ,18940 ,17677 ,18492 ,23328 , 29743 ,32728 ,29402 ,20841 ,13346 ,12278 ,14715 ,15436 ,10290 ,-431 ,-8872 ,-9902 ,-5548 ,-20 ,2443 , -530 ,-5299 ,-9548 ,-12075 ,-10965 ,-8211 ,-6291 ,-4601 ,-2998 ,-972 ,1091 ,3889 ,8049 ,14234 ,20456 , 24133 ,22892 ,20280 ,20142 ,24175 ,29636 ,32765 ,31793 ,27135 ,24092 ,25098 ,26735 ,26048 ,20664 ,12021 , 6194 ,3927 ,2890 ,1140 ,-1518 ,-4761 ,-6093 ,-5747 ,-5603 ,-6479 ,-9683 ,-15115 ,-19225 ,-20873 ,-20720 , -21503 ,-23602 ,-24939 ,-22830 ,-16334 ,-8025 ,-944 ,3711 ,5312 ,5437 ,4555 ,2857 ,898 ,304 ,1703 , 4019 ,3803 ,1897 ,341 ,-206 ,2861 ,8199 ,9674 ,6295 ,-2933 ,-14562 ,-20745 ,-20551 ,-19574 ,-20711 , -25418 ,-31043 ,-32765 ,-30237 ,-26478 ,-22107 ,-19935 ,-20559 ,-21025 ,-19963 ,-18052 ,-16919 ,-17081 ,-16441 ,-13802 , -9840 ,-6858 ,-5394 ,-4275 ,-2355 ,369 ,2248 ,1868 ,-1607 ,-6059 ,-8345 ,-7471 ,-5450 ,-5192 ,-6874 , -8720 ,-9311 ,-8922 ,-8683 ,-10128 ,-12851 ,-14905 ,-14110 ,-11498 ,-9979 ,-11346 ,-12870 ,-10992 ,-4932 ,2175 , 5120 ,2399 ,-4182 ,-9549 ,-9634 ,-5173 ,21 ,1761 ,55 ,-1670 ,-571 ,3307 ,8274 ,12049 ,13670 , 13154 ,11035 ,7923 ,4343 ,1532 ,1615 ,4435 ,7773 ,9755 ,9087 ,8241 ,9567 ,13623 ,-4062 ,-2646 , -900 ,1838 ,5506 ,9608 ,13744 ,17554 ,20356 ,22293 ,24024 ,25967 ,28080 ,30283 ,31933 ,32765 ,32615 , 31578 ,30395 ,29459 ,28879 ,28467 ,28000 ,27024 ,25382 ,23459 ,21473 ,19998 ,18869 ,17996 ,16765 ,15438 , 13793 ,12115 ,10474 ,9320 ,8690 ,8469 ,8288 ,8094 ,8078 ,8259 ,8742 ,9621 ,10976 ,12918 ,14939 , 16917 ,18685 ,20608 ,22360 ,24034 ,25622 ,27291 ,28781 ,29820 ,30372 ,30614 ,30587 ,30438 ,30404 ,30463 , 30495 ,30229 ,29560 ,28470 ,27119 ,25755 ,24510 ,23360 ,22090 ,20614 ,18567 ,16054 ,13044 ,10274 ,7818 , 5817 ,4074 ,2323 ,283 ,-2060 ,-4122 ,-5348 ,-5537 ,-4791 ,-3468 ,-2141 ,-932 ,244 ,1368 ,3065 , 5742 ,8843 ,11994 ,14691 ,16188 ,16882 ,17292 ,18006 ,19249 ,20655 ,21506 ,21096 ,19605 ,17469 ,15220 , 13402 ,12169 ,10948 ,9246 ,6729 ,3614 ,943 ,-1840 ,-5411 ,-8569 ,-10817 ,-12817 ,-14989 ,-17677 ,-20921 , -23675 ,-25496 ,-26241 ,-26238 ,-25358 ,-24429 ,-23827 ,-23514 ,-22799 ,-21337 ,-18676 ,-15111 ,-11643 ,-8532 ,-6348 , -4992 ,-3709 ,-2195 ,-495 ,1073 ,2065 ,2169 ,1349 ,-297 ,-2035 ,-3607 ,-4847 ,-6050 ,-7246 ,-9167 , -11679 ,-14375 ,-16764 ,-18660 ,-20133 ,-21283 ,-22417 ,-23698 ,-25467 ,-27461 ,-29039 ,-30176 ,-30914 ,-31502 ,-31820 , -32103 ,-32430 ,-32765 ,-32539 ,-31860 ,-30712 ,-29061 ,-27063 ,-25184 ,-23230 ,-21052 ,-18877 ,-16858 ,-14801 ,-12612 , -10590 ,-9116 ,-8047 ,-7338 ,-6894 ,-6623 ,-6286 ,-5889 ,-5632 ,-5671 ,-6190 ,-7206 ,-8420 ,-9546 ,-10339 , -10929 ,-11558 ,-12466 ,-13803 ,-15822 ,-18219 ,-20271 ,-21688 ,-22598 ,-23447 ,-24703 ,-26223 ,-27802 ,-29236 ,-30024 , -29627 ,-28135 ,-26078 ,-23967 ,-22170 ,-20248 ,-18207 ,-15473 ,-11384 ,-6859 ,-2125 ,2011 ,4777 ,6735 ,8283 , 10108 ,12424 ,14816 ,16697 ,17547 ,17128 ,15906 ,14309 ,12952 ,12429 ,12050 ,11327 ,9793 ,7406 ,5204 , 3211 ,822 ,-1300 ,-2540 ,-3272 ,-4058 ,-5599 ,-7796 ,-10160 ,-11843 ,-11836 ,-10365 ,-8172 ,-5839 ,356 , 2412 ,4099 ,5943 ,8820 ,12785 ,17268 ,21499 ,25080 ,27295 ,27358 ,25602 ,22602 ,19592 ,17773 ,17656 , 19883 ,23957 ,28611 ,32089 ,32708 ,29760 ,22522 ,13558 ,6942 ,3336 ,-2093 ,-10737 ,-19766 ,-26267 ,-27465 , -24814 ,-20098 ,-15148 ,-12367 ,-12163 ,-14420 ,-18358 ,-22950 ,-26971 ,-28892 ,-28124 ,-24766 ,-20006 ,-14750 ,-9961 , -6645 ,-4671 ,-3371 ,-2197 ,-612 ,1477 ,4060 ,6800 ,9003 ,10095 ,9786 ,8248 ,5810 ,3049 ,520 , -1356 ,-1989 ,-1105 ,646 ,2745 ,4713 ,6250 ,7334 ,8010 ,8161 ,7843 ,7606 ,7744 ,8298 ,9108 , 9898 ,10630 ,11387 ,12218 ,13063 ,13825 ,14388 ,14652 ,14534 ,14069 ,13212 ,11856 ,9708 ,6676 ,3174 , -523 ,-4115 ,-7392 ,-10147 ,-12246 ,-13538 ,-14162 ,-14295 ,-14150 ,-13771 ,-13071 ,-12144 ,-11216 ,-10431 ,-9687 , -8849 ,-7819 ,-6738 ,-5880 ,-5324 ,-4923 ,-4625 ,-4512 ,-4325 ,-3745 ,-2583 ,-946 ,717 ,1972 ,2380 , 1728 ,121 ,-2472 ,-5648 ,-8771 ,-11072 ,-12101 ,-11739 ,-9912 ,-7440 ,-4773 ,-2318 ,-299 ,1416 ,3114 , 5480 ,9277 ,14202 ,19586 ,24554 ,28152 ,29350 ,27932 ,24552 ,20224 ,16612 ,14888 ,15786 ,19475 ,24772 , 29873 ,32765 ,31847 ,25743 ,16137 ,7109 ,1565 ,-3386 ,-11635 ,-21448 ,-29558 ,-32765 ,-31521 ,-27487 ,-22393 , -18531 ,-16967 ,-17833 ,-20780 ,-24774 ,-28589 ,-30887 ,-30828 ,-28343 ,-24041 ,-18846 ,-13602 ,-9471 ,-6814 ,-4892 , -2965 ,-457 ,2664 ,6156 ,9894 ,13266 ,15632 ,16586 ,16107 ,14550 ,12500 ,10876 ,9810 ,9398 ,9884 , 11007 ,12276 ,13100 ,13089 ,12260 ,10864 ,9308 ,7888 ,6843 ,6262 ,6154 ,6306 ,6335 ,6124 ,5733 , 5282 ,4876 ,4404 ,3708 ,2838 ,2091 ,1740 ,1715 ,1839 ,1687 ,1071 ,25 ,-1202 ,-2277 ,-3168 , -3923 ,-4617 ,-5261 ,-5693 ,-5772 ,-5680 ,-5753 ,-6229 ,-7125 ,-8351 ,-9900 ,-11343 ,-12307 ,-12494 ,-11842 , -10764 ,-9658 ,-9119 ,-9118 ,-9621 ,-10671 ,-12138 ,-13627 ,-14289 ,-13850 ,-12288 ,-9832 ,-7034 ,-4074 ,-1279 , 2244 ,5446 ,8662 ,11827 ,15085 ,18468 ,21704 ,24414 ,26386 ,27591 ,28430 ,29275 ,30279 ,31355 ,32213 , 32735 ,32765 ,32161 ,30762 ,28524 ,25419 ,21611 ,17569 ,14096 ,11830 ,11160 ,11968 ,13446 ,15165 ,16903 , 18731 ,20559 ,22117 ,22866 ,22386 ,21261 ,20268 ,19742 ,19323 ,18353 ,16579 ,14124 ,11415 ,8971 ,6859 , 4917 ,2964 ,1001 ,-1128 ,-3798 ,-7565 ,-12502 ,-18134 ,-23555 ,-27674 ,-29634 ,-29700 ,-28426 ,-26577 ,-25057 , -24430 ,-24687 ,-25340 ,-25545 ,-24938 ,-23570 ,-21479 ,-18462 ,-14596 ,-10261 ,-6072 ,-2809 ,-499 ,1039 ,2106 , 2892 ,3435 ,3548 ,3038 ,1898 ,312 ,-1553 ,-3764 ,-6319 ,-9030 ,-11388 ,-12878 ,-13066 ,-11929 ,-10052 , -8128 ,-6722 ,-5946 ,-5123 ,-3683 ,-1608 ,479 ,1932 ,2869 ,3846 ,5446 ,7259 ,8512 ,8586 ,7295 , 5233 ,2912 ,493 ,-1994 ,-4229 ,-5678 ,-5933 ,-5031 ,-3723 ,-2934 ,-3259 ,-4806 ,-6761 ,-8139 ,-8532 , -8178 ,-7664 ,-7212 ,-6731 ,-6007 ,-4825 ,-3119 ,-909 ,1770 ,4725 ,7738 ,10478 ,12775 ,14750 ,16490 , 18116 ,19670 ,20990 ,21998 ,22852 ,23801 ,25068 ,26438 ,27550 ,27988 ,27450 ,25921 ,23784 ,21344 ,18850 , 16481 ,14386 ,12731 ,11728 ,11724 ,12712 ,14493 ,16524 ,18313 ,19824 ,21286 ,22689 ,23575 ,23563 ,22761 , 21620 ,20585 ,19703 ,18689 ,17267 ,15339 ,13175 ,10948 ,8554 ,5563 ,1890 ,-2170 ,-6246 ,-10199 ,-14134 , -18325 ,-22796 ,-27094 ,-30370 ,-32251 ,-32765 ,-32263 ,-31294 ,-30495 ,-30212 ,-30389 ,-30617 ,-30405 ,-29523 ,-27902 , -25389 ,-21962 ,-17686 ,-12783 ,-7719 ,-3062 ,797 ,3615 ,5352 ,6257 ,6676 ,6723 ,6442 ,5850 ,5013 , 3913 ,2462 ,499 ,-1804 ,-4089 ,-5815 ,-6503 ,-6288 ,-5472 ,-4511 ,-3817 ,-3480 ,-3258 ,-2731 ,-1376 , 540 ,2472 ,3909 ,4845 ,5691 ,6612 ,7366 ,7421 ,6495 ,4590 ,2012 ,-848 ,-3678 ,-6208 ,-8024 , -8689 ,-8100 ,-6909 ,-5849 ,-5733 ,-6785 ,-8352 ,-9697 ,-10296 ,-9966 ,-8965 ,-7496 ,-5852 ,-4253 ,-2549 , -439 ,8670 ,10275 ,10197 ,9639 ,8747 ,6935 ,4032 ,995 ,-696 ,405 ,3736 ,7700 ,11035 ,13571 , 16044 ,18608 ,20409 ,20230 ,17197 ,12444 ,7661 ,4918 ,5048 ,7033 ,9364 ,10474 ,9507 ,7589 ,6351 , 7048 ,9556 ,11645 ,11358 ,7938 ,3201 ,257 ,513 ,2900 ,5327 ,6211 ,5180 ,3974 ,4559 ,7104 , 10309 ,13129 ,14931 ,15635 ,15449 ,14464 ,12829 ,11218 ,10053 ,9178 ,8508 ,8292 ,8983 ,10589 ,12623 , 14260 ,15472 ,16704 ,18563 ,20492 ,21298 ,20448 ,18373 ,16543 ,16398 ,17975 ,19873 ,20168 ,18425 ,15416 , 12370 ,10332 ,9240 ,8430 ,7609 ,7092 ,7586 ,9508 ,12849 ,17126 ,21182 ,23750 ,23866 ,21665 ,18691 , 16592 ,15790 ,15393 ,14284 ,13295 ,14064 ,17641 ,22856 ,27049 ,28505 ,27372 ,24955 ,22537 ,20256 ,19511 , 19970 ,21221 ,22755 ,24025 ,24887 ,25556 ,25842 ,25189 ,22745 ,18114 ,12554 ,7787 ,5815 ,7121 ,10463 , 14478 ,17690 ,19271 ,19549 ,18832 ,17156 ,14686 ,11872 ,9284 ,7456 ,6296 ,5296 ,5498 ,8323 ,14447 , 21213 ,25700 ,26044 ,22910 ,19483 ,18392 ,20166 ,23627 ,26265 ,26580 ,24639 ,22089 ,21618 ,24323 ,28578 , 30153 ,26183 ,18003 ,9757 ,6889 ,12348 ,21809 ,29711 ,32216 ,29344 ,26309 ,26575 ,30181 ,32765 ,29923 , 20795 ,8393 ,-1620 ,-5260 ,-3090 ,1504 ,4162 ,3136 ,284 ,-1914 ,-920 ,2366 ,5463 ,5814 ,2764 , -1868 ,-4732 ,-4425 ,-1600 ,529 ,223 ,-2229 ,-5104 ,-6648 ,-7055 ,-6904 ,-6583 ,-5368 ,-2578 ,1552 , 5598 ,7671 ,7269 ,5729 ,4593 ,4914 ,5522 ,4980 ,1944 ,-2275 ,-4529 ,-2023 ,5202 ,14424 ,20794 , 22156 ,19053 ,14875 ,13700 ,15735 ,18371 ,17708 ,11441 ,2023 ,-6494 ,-10318 ,-8802 ,-6214 ,-7042 ,-12358 , -20501 ,-25636 ,-24758 ,-18104 ,-9828 ,-4304 ,-2794 ,-3521 ,-3894 ,-2595 ,-1554 ,-3362 ,-9842 ,-19118 ,-27712 , -32765 ,-32745 ,-30107 ,-27413 ,-25753 ,-24414 ,-22829 ,-20516 ,-18169 ,-16888 ,-17458 ,-18988 ,-19784 ,-17807 ,-11867 , -3898 ,3630 ,6893 ,12578 ,18381 ,24013 ,29501 ,32765 ,32400 ,29195 ,24727 ,20444 ,17273 ,15819 ,15534 , 15706 ,16194 ,16986 ,17566 ,17942 ,18594 ,19433 ,20395 ,21712 ,23438 ,24929 ,26106 ,27160 ,27704 ,27363 , 26662 ,26066 ,25509 ,25214 ,25325 ,25396 ,24959 ,24698 ,24560 ,24119 ,23547 ,23368 ,23223 ,22917 ,22745 , 22363 ,21562 ,20867 ,20634 ,20125 ,19073 ,17227 ,13525 ,7969 ,2996 ,598 ,857 ,2529 ,3961 ,4060 , 2498 ,294 ,-1747 ,-3453 ,-4443 ,-3895 ,-2701 ,-1991 ,-2144 ,-3407 ,-5681 ,-8545 ,-11650 ,-15835 ,-20918 , -25589 ,-28827 ,-29844 ,-28544 ,-26411 ,-25580 ,-26699 ,-28459 ,-30140 ,-31416 ,-31081 ,-28892 ,-26208 ,-24300 ,-24119 , -26393 ,-29122 ,-29158 ,-25067 ,-17248 ,-7633 ,1321 ,5856 ,3126 ,-3052 ,-8436 ,-10415 ,-8002 ,-3782 ,-388 , 1294 ,2168 ,3246 ,4460 ,5862 ,7135 ,7833 ,8144 ,8725 ,10052 ,12237 ,14480 ,14617 ,9960 ,677 , -9050 ,-15107 ,-14224 ,-6088 ,4361 ,12162 ,15103 ,14123 ,11619 ,8487 ,5359 ,3598 ,3967 ,6976 ,11938 , 17227 ,22278 ,27493 ,31716 ,32600 ,30401 ,26595 ,22373 ,19005 ,17353 ,16725 ,16376 ,16164 ,16137 ,15938 , 15719 ,16134 ,17388 ,19340 ,22008 ,25090 ,27455 ,28906 ,29674 ,29720 ,28892 ,27954 ,27232 ,26458 ,25748 , 25431 ,25333 ,25146 ,25297 ,25416 ,25059 ,24557 ,24482 ,24499 ,24519 ,24790 ,24981 ,24602 ,23947 ,23331 , 22248 ,20741 ,18792 ,15398 ,9877 ,4104 ,355 ,-808 ,117 ,1901 ,3022 ,2634 ,1251 ,-509 ,-2345 , -3682 ,-3854 ,-3325 ,-3106 ,-3420 ,-4387 ,-6331 ,-8855 ,-11813 ,-16006 ,-21375 ,-26109 ,-28799 ,-28944 ,-26929 , -25113 ,-25448 ,-27634 ,-30090 ,-31867 ,-32765 ,-31911 ,-29046 ,-24601 ,-18464 ,-9649 ,313 ,6492 ,6253 ,726 , -5946 ,-9175 ,-7955 ,-3841 ,159 ,2242 ,3388 ,4498 ,5674 ,7118 ,8423 ,9007 ,8963 ,8951 ,9361 , 10671 ,12929 ,14194 ,11409 ,4073 ,-5179 ,-11754 ,-11089 ,-3929 ,5668 ,12591 ,14505 ,13627 ,11232 ,7740 , 4202 ,2423 ,3218 ,-638 ,1296 ,4283 ,8402 ,13370 ,18960 ,24181 ,28510 ,31650 ,32765 ,32544 ,31064 , 28791 ,26195 ,23635 ,21475 ,19789 ,18826 ,18305 ,18246 ,18508 ,18882 ,19274 ,19583 ,19814 ,19969 ,20012 , 20053 ,20123 ,20294 ,20519 ,20788 ,21066 ,21302 ,21433 ,21382 ,21191 ,20900 ,20452 ,19915 ,19284 ,18601 , 17848 ,16972 ,15894 ,14436 ,12289 ,9141 ,5075 ,351 ,-4336 ,-8515 ,-11554 ,-13046 ,-13295 ,-11806 ,-9627 , -6913 ,-4055 ,-1465 ,854 ,2662 ,3921 ,4446 ,4629 ,4489 ,4192 ,3863 ,3546 ,3267 ,3051 ,2930 , 2848 ,2792 ,2754 ,2790 ,2864 ,2949 ,3048 ,3189 ,3414 ,3696 ,4132 ,4909 ,6448 ,8938 ,12463 , 16893 ,21698 ,26130 ,29403 ,31457 ,31380 ,30049 ,27521 ,24169 ,20686 ,17370 ,14508 ,12247 ,10628 ,9581 , 8877 ,8378 ,7953 ,7524 ,7049 ,6468 ,5884 ,5355 ,4925 ,4612 ,4435 ,4421 ,4515 ,4673 ,4821 , 4961 ,5080 ,5136 ,5130 ,5061 ,5005 ,4948 ,4867 ,4746 ,4564 ,4263 ,3604 ,2397 ,274 ,-2948 , -7193 ,-12673 ,-18287 ,-23570 ,-27771 ,-30383 ,-31181 ,-30413 ,-28372 ,-25447 ,-22311 ,-19376 ,-16857 ,-15277 ,-14340 , -14132 ,-14408 ,-14971 ,-15720 ,-16414 ,-16962 ,-17312 ,-17522 ,-17618 ,-17620 ,-17611 ,-17635 ,-17730 ,-17823 ,-17908 , -17962 ,-17967 ,-17891 ,-17706 ,-17447 ,-17153 ,-16865 ,-16583 ,-16340 ,-16227 ,-16194 ,-16224 ,-16299 ,-16355 ,-16260 , -15752 ,-14464 ,-12114 ,-8792 ,-4781 ,-471 ,3126 ,5682 ,6883 ,6313 ,4546 ,1673 ,-1646 ,-4998 ,-7916 , -10235 ,-11837 ,-12740 ,-12904 ,-12636 ,-12078 ,-11335 ,-10519 ,-9738 ,-9068 ,-8518 ,-8131 ,-7869 ,-7752 ,-7751 , -7787 ,-7838 ,-7906 ,-8001 ,-8126 ,-8310 ,-8752 ,-9610 ,-11451 ,-14175 ,-17933 ,-22287 ,-26536 ,-30027 ,-32182 , -32765 ,-31946 ,-29471 ,-26262 ,-22601 ,-19102 ,-15953 ,-13537 ,-11796 ,-10656 ,-10215 ,-10000 ,-9947 ,-9928 ,-9814 , -9579 ,-9198 ,-8753 ,-8288 ,-7837 ,-7419 ,-7050 ,-6797 ,-6556 ,-6325 ,-6085 ,-5838 ,-5553 ,-5187 ,-4741 , -4234 ,-3630 ,-2908 ,-1994 ,4734 ,7549 ,10120 ,12489 ,14572 ,16294 ,17652 ,18663 ,19543 ,20661 ,22283 , 24255 ,26349 ,28073 ,29219 ,29785 ,30103 ,30568 ,31348 ,32253 ,32765 ,31849 ,26748 ,16781 ,4998 ,-2613 , -1933 ,4312 ,12027 ,17493 ,18851 ,17402 ,14464 ,10977 ,7595 ,4477 ,1870 ,-330 ,-2261 ,-4342 ,-6744 , -9398 ,-11960 ,-14024 ,-15654 ,-17032 ,-18552 ,-20223 ,-22009 ,-23709 ,-25328 ,-26877 ,-28291 ,-29373 ,-29945 ,-30113 , -29805 ,-28237 ,-23040 ,-12713 ,-1553 ,4931 ,4040 ,-2653 ,-9732 ,-14031 ,-14569 ,-11796 ,-7856 ,-3727 ,34 , 3432 ,6523 ,9329 ,11785 ,13872 ,15736 ,17483 ,19231 ,20983 ,22908 ,24896 ,26809 ,28349 ,29452 ,30185 , 30635 ,30619 ,28834 ,23307 ,13657 ,3591 ,-666 ,2187 ,9501 ,17162 ,21325 ,21863 ,19868 ,16761 ,13744 , 11160 ,9002 ,7006 ,5168 ,3496 ,2128 ,988 ,-56 ,-1311 ,-2845 ,-4567 ,-6312 ,-7894 ,-9288 ,-10319 , -11017 ,-11226 ,-10523 ,-7139 ,702 ,10883 ,17723 ,18067 ,12522 ,4767 ,-977 ,-3368 ,-2720 ,-337 ,2367 , 4997 ,7659 ,10419 ,13117 ,15537 ,17483 ,18916 ,19876 ,20639 ,21388 ,22560 ,24218 ,26238 ,28232 ,28731 , 24877 ,16275 ,5163 ,-2877 ,-3398 ,1879 ,9223 ,14723 ,16434 ,15449 ,13149 ,10414 ,7471 ,4371 ,1267 , -1489 ,-3768 ,-5758 ,-7804 ,-9997 ,-12376 ,-14652 ,-16754 ,-18728 ,-20696 ,-22702 ,-24596 ,-26263 ,-27503 ,-28605 , -29725 ,-30915 ,-31912 ,-32547 ,-32765 ,-32382 ,-30181 ,-23515 ,-12826 ,-2207 ,2959 ,341 ,-6353 ,-12929 ,-16543 , -15882 ,-12651 ,-8374 ,-4081 ,-386 ,2904 ,5848 ,8535 ,10740 ,12642 ,14325 ,15974 ,17661 ,19505 ,21533 , 23584 ,25461 ,26936 ,28105 ,28944 ,29473 ,29352 ,27561 ,22031 ,12374 ,2911 ,-1237 ,1517 ,8630 ,15802 , 19984 ,20826 ,19138 ,16282 ,13355 ,10781 ,8574 ,6614 ,4842 ,3274 ,2039 ,997 ,-24 ,-1333 ,-2935 , -4766 ,-6494 ,-8014 ,-9237 ,-10066 ,-10535 ,-10762 ,-10874 ,-9509 ,-3693 ,6308 ,15933 ,19698 ,15843 ,8278 , 1087 ,-3019 ,-3185 ,-1142 ,1818 ,-2953 ,2215 ,7440 ,9964 ,8486 ,5232 ,4639 ,9251 ,17496 ,25510 , 30688 ,32765 ,32376 ,30161 ,27697 ,26670 ,27643 ,29536 ,30254 ,29203 ,26780 ,23358 ,20011 ,18087 ,17990 , 17922 ,15854 ,12036 ,6762 ,734 ,-3110 ,-2305 ,1939 ,5131 ,4128 ,1403 ,-1230 ,-3448 ,-5394 ,-6061 , -4989 ,-3088 ,-2660 ,-4439 ,-7080 ,-8404 ,-7689 ,-6826 ,-7571 ,-9571 ,-10921 ,-10376 ,-9424 ,-10306 ,-13519 , -17049 ,-19125 ,-20770 ,-23446 ,-26510 ,-27464 ,-25328 ,-21457 ,-18838 ,-19108 ,-22437 ,-27634 ,-31812 ,-32765 ,-31107 , -28720 ,-26561 ,-25580 ,-26994 ,-30565 ,-32387 ,-29693 ,-25233 ,-22311 ,-21211 ,-20649 ,-20284 ,-20100 ,-18477 ,-15016 , -11720 ,-9869 ,-9864 ,-11103 ,-11987 ,-11160 ,-9006 ,-7960 ,-8316 ,-7680 ,-5374 ,-3930 ,-5048 ,-7068 ,-7752 , -6668 ,-5025 ,-4014 ,-5194 ,-8787 ,-11855 ,-11929 ,-9554 ,-7581 ,-6969 ,-7715 ,-10104 ,-13553 ,-15936 ,-16509 , -16473 ,-16921 ,-16643 ,-15356 ,-13769 ,-12109 ,-8891 ,-4233 ,-764 ,-993 ,-4151 ,-6268 ,-6404 ,-5974 ,-6280 , -5657 ,-2549 ,2073 ,5646 ,6946 ,6323 ,4727 ,2862 ,1525 ,1671 ,3530 ,5671 ,5830 ,4197 ,2969 , 3542 ,4515 ,4844 ,4781 ,5514 ,7113 ,8754 ,9325 ,8731 ,8049 ,7717 ,5751 ,1231 ,-3108 ,-4961 , -6361 ,-6613 ,-5490 ,-5107 ,-6422 ,-9056 ,-11866 ,-14153 ,-15095 ,-14712 ,-14511 ,-14958 ,-14270 ,-10926 ,-6428 , -4652 ,-6134 ,-8941 ,-10690 ,-10859 ,-9475 ,-6485 ,-3783 ,-3299 ,-4090 ,-4052 ,-2331 ,-34 ,1955 ,3583 , 4935 ,7461 ,11069 ,14008 ,14802 ,13381 ,10763 ,7265 ,4571 ,6408 ,11082 ,14460 ,15619 ,17514 ,21672 , 24875 ,25346 ,23697 ,19476 ,11630 ,2390 ,-1963 ,1255 ,6635 ,8733 ,5346 ,-1698 ,-9056 ,-14371 ,-15588 , -11825 ,-5840 ,-1244 ,-176 ,-2457 ,-5509 ,-8084 ,-9093 ,-7720 ,-5312 ,-3500 ,-2360 ,-2467 ,-4377 ,-6601 , -6702 ,-3742 ,-556 ,373 ,-2108 ,-8853 ,-16651 ,-20728 ,-20287 ,-18032 ,-17320 ,-18663 ,-21549 ,-24998 ,-26024 , -23560 ,-19098 ,-14356 ,-10560 ,-8020 ,-5910 ,-4279 ,-1757 ,1184 ,4221 ,6197 ,5763 ,3787 ,2345 ,3117 , 7633 ,14724 ,21527 ,25886 ,27325 ,27542 ,28195 ,29883 ,31745 ,32765 ,32651 ,31230 ,28158 ,23693 ,19243 , 15761 ,13004 ,10897 ,10134 ,10853 ,12568 ,14080 ,15543 ,17033 ,18205 ,18119 ,16663 ,14109 ,10792 ,7072 , 3806 ,1513 ,26 ,-1149 ,-1979 ,-1995 ,-1459 ,-755 ,-38 ,497 ,77 ,-2224 ,-5759 ,-8696 ,-10055 , -10094 ,-10052 ,-10707 ,-12130 ,-14598 ,-18118 ,-21909 ,-24598 ,-25301 ,-23911 ,-21594 ,-19179 ,-17092 ,-15839 ,-15401 , -15784 ,-16133 ,-15646 ,-13946 ,-11162 ,-7970 ,-6192 ,-6636 ,-8317 ,-9491 ,-10128 ,-11572 ,-13616 ,-15582 ,-16653 , -16366 ,-15093 ,-13954 ,-14569 ,-17020 ,-19078 ,-19658 ,-18851 ,-17703 ,-17566 ,-18581 ,-19724 ,-20141 ,-20605 ,-21611 , -22567 ,-22288 ,-22169 ,-22982 ,-23725 ,-23525 ,-22790 ,-22105 ,-21356 ,-20491 ,-20504 ,-21941 ,-24682 ,-28145 ,-30219 , -30535 ,-29911 ,-29576 ,-29878 ,-30659 ,-31548 ,-32491 ,-32765 ,-32163 ,-30964 ,-29833 ,-28821 ,-26766 ,-22984 ,-18143 , -14778 ,-13671 ,-13696 ,-13228 ,-12207 ,-11808 ,-12046 ,-12362 ,-12936 ,-12592 ,-10373 ,-6832 ,-4451 ,-4312 ,-4132 , -2578 ,-170 ,2648 ,5272 ,6812 ,7125 ,7276 ,7945 ,7921 ,6296 ,4321 ,2374 ,260 ,-1017 ,-273 , 1457 ,3263 ,4733 ,5661 ,4302 ,541 ,-3436 ,-6303 ,-8942 ,-11514 ,-13223 ,-13563 ,-13966 ,-15192 ,-16135 , -15803 ,-13751 ,-11106 ,-9579 ,-10476 ,-12392 ,-12940 ,-11578 ,-9778 ,-8259 ,-6187 ,-3853 ,-2330 ,-2244 ,-2257 , -2148 ,-2653 ,-2458 ,-616 ,1613 ,2744 ,3260 ,5237 ,7942 ,8735 ,7509 ,6426 ,7196 ,9772 ,12942 , 15688 ,18242 ,20812 ,22503 ,22141 ,20446 ,19647 ,20465 ,21638 ,22188 ,22391 ,22355 ,20710 ,15925 ,8244 , -535 ,-7892 ,-13370 ,-17303 ,-20127 ,-21944 ,-22662 ,-21949 ,-19693 ,-17111 ,-15170 ,-13128 ,-10022 ,-6481 ,-4362 , -4844 ,-7920 ,-12758 ,-18027 ,-22109 ,-23665 ,-21570 ,-17074 ,-12701 ,-10233 ,-9145 ,-8465 ,-8060 ,-7757 ,-7480 , -7754 ,-8548 ,-8975 ,-8327 ,-7300 ,-6830 ,-5884 ,4328 ,5175 ,6400 ,8340 ,11204 ,14741 ,17500 ,18514 , 18250 ,18834 ,21195 ,24460 ,27198 ,28585 ,28389 ,27098 ,25858 ,25561 ,26557 ,28543 ,30338 ,29783 ,25671 , 19512 ,13495 ,8866 ,6820 ,7533 ,10847 ,15853 ,20905 ,23725 ,24124 ,23577 ,24111 ,25878 ,28365 ,31071 , 32765 ,32498 ,31336 ,30421 ,28846 ,25972 ,23108 ,22449 ,23826 ,24911 ,24745 ,23667 ,22015 ,20274 ,19373 , 19966 ,20663 ,19306 ,15894 ,11812 ,7669 ,3010 ,-1174 ,-3942 ,-4999 ,-4917 ,-4358 ,-3948 ,-4684 ,-6674 , -8133 ,-8634 ,-8228 ,-7157 ,-5218 ,-2931 ,-1665 ,-2936 ,-5920 ,-8811 ,-10654 ,-11588 ,-11836 ,-11157 ,-9845 , -8954 ,-8954 ,-9333 ,-9600 ,-9002 ,-7406 ,-5696 ,-5140 ,-5967 ,-7061 ,-7560 ,-7899 ,-8738 ,-10390 ,-12222 , -13827 ,-15397 ,-17282 ,-19233 ,-20394 ,-20310 ,-19114 ,-17931 ,-17197 ,-17232 ,-17833 ,-18682 ,-19440 ,-20252 ,-20889 , -20684 ,-19393 ,-17484 ,-15266 ,-13257 ,-11959 ,-11314 ,-10489 ,-9049 ,-8096 ,-7257 ,-4818 ,-867 ,2162 ,3761 , 4941 ,5876 ,4945 ,2978 ,1194 ,143 ,-265 ,-99 ,81 ,-31 ,-769 ,-1818 ,-2323 ,-1885 ,-2005 , -2893 ,-3504 ,-2872 ,-2108 ,-2319 ,-2878 ,-3033 ,-2709 ,-1358 ,1455 ,4861 ,6609 ,6009 ,4505 ,3681 , 4684 ,6463 ,7772 ,8143 ,8206 ,8340 ,8321 ,8223 ,9245 ,11103 ,12202 ,12042 ,11994 ,13096 ,13800 , 12655 ,10079 ,7150 ,4049 ,1299 ,-57 ,166 ,349 ,464 ,1278 ,2783 ,4250 ,5473 ,6579 ,7276 , 7262 ,6943 ,6248 ,4520 ,2580 ,1851 ,3378 ,6375 ,9061 ,10640 ,11054 ,10429 ,9461 ,8722 ,8490 , 8950 ,10859 ,14187 ,17799 ,20123 ,20937 ,21237 ,21301 ,21098 ,20773 ,20835 ,21576 ,23256 ,25570 ,27779 , 28868 ,28365 ,26586 ,24968 ,24097 ,23649 ,21795 ,17253 ,9995 ,1694 ,-4734 ,-8132 ,-9394 ,-9406 ,-8150 , -6308 ,-4918 ,-5050 ,-7031 ,-10462 ,-14188 ,-16851 ,-18007 ,-19441 ,-22587 ,-27195 ,-31187 ,-32765 ,-31773 ,-28178 , -21954 ,-14267 ,-7792 ,-3851 ,-1850 ,-102 ,1666 ,3075 ,4720 ,-2190 ,-8106 ,-2074 ,5145 ,6154 ,5762 , 8391 ,8844 ,-634 ,-11047 ,-9913 ,-6413 ,-6232 ,-5882 ,653 ,6118 ,689 ,-7002 ,-8522 ,-7565 ,-5847 , -3616 ,-2268 ,-1515 ,-3008 ,-5342 ,-9672 ,-12069 ,-4572 ,5116 ,6652 ,4207 ,-1367 ,-6700 ,-3560 ,796 , -4620 ,-11803 ,-8126 ,-921 ,2775 ,4585 ,1856 ,-1605 ,1345 ,6280 ,8119 ,9367 ,14042 ,17323 ,2903 , -15977 ,-15823 ,-8255 ,-3916 ,-1735 ,-5437 ,-9224 ,-6401 ,-2057 ,1719 ,3541 ,-1042 ,-6207 ,-6209 ,-5950 , -10146 ,-14331 ,-12809 ,-9468 ,-5233 ,-908 ,4081 ,8513 ,10593 ,11504 ,9025 ,5336 ,78 ,-4075 ,1532 , 9344 ,11502 ,11221 ,3774 ,-3550 ,-2830 ,379 ,216 ,459 ,5915 ,11473 ,4723 ,-3585 ,707 ,8048 , 5904 ,488 ,-4486 ,-8963 ,-10018 ,-8999 ,-5406 ,-1609 ,-2015 ,-4035 ,-5017 ,-5617 ,-4900 ,-3205 ,612 , 3957 ,-1001 ,-5936 ,5805 ,17725 ,13002 ,5449 ,2211 ,925 ,2726 ,5343 ,5698 ,5750 ,6353 ,7173 , 8271 ,9984 ,13442 ,17056 ,19863 ,23435 ,28617 ,32765 ,17977 ,2341 ,-21 ,-211 ,-17175 ,-32765 ,-30184 , -23878 ,-21315 ,-19888 ,-16097 ,-13178 ,-11562 ,-10969 ,-10063 ,-9629 ,-9110 ,-8582 ,-6026 ,-3855 ,-6191 ,-10790 , -17111 ,-21878 ,-9966 ,3200 ,-673 ,-8552 ,-5529 ,140 ,1995 ,2563 ,2315 ,1406 ,215 ,-489 ,3288 , 7886 ,8913 ,8285 ,4116 ,-1319 ,-5652 ,-8166 ,-2981 ,3386 ,-2932 ,-12073 ,-8379 ,-725 ,146 ,-833 , 1428 ,3598 ,-2820 ,-11849 ,-13024 ,-9825 ,-2499 ,2579 ,-1673 ,-7979 ,-11489 ,-13588 ,-12825 ,-10983 ,-6182 , -1045 ,3790 ,7940 ,10972 ,12158 ,8634 ,4488 ,4668 ,4869 ,-52 ,-5084 ,-2506 ,2353 ,6186 ,8818 , 5300 ,1200 ,3903 ,8949 ,14430 ,16018 ,256 ,-17904 ,-16748 ,-9535 ,-8024 ,-7746 ,-3682 ,48 ,-2615 , -6712 ,-4860 ,-391 ,5338 ,9917 ,4826 ,-2344 ,514 ,5560 ,1032 ,-6370 ,-8029 ,-6531 ,1553 ,10762 , 9298 ,3819 ,1344 ,181 ,926 ,2600 ,5122 ,6964 ,6898 ,-31566 ,-31267 ,-8046 ,29782 ,26236 ,20602 , 23845 ,21780 ,-15294 ,-30074 ,-8789 ,22187 ,26476 ,26553 ,20904 ,13736 ,5774 ,2845 ,9045 ,20972 ,32766 , 30516 ,19262 ,-20354 ,-26707 ,-21265 ,6300 ,25196 ,6879 ,-7502 ,24681 ,31174 ,30744 ,10938 ,-8093 ,-16209 , -791 ,12935 ,-5154 ,-23803 ,-29653 ,-32714 ,-10508 ,9614 ,-20613 ,30910 ,32270 ,26462 ,10543 ,3486 ,23752 , 31685 ,24994 ,9557 ,-12658 ,-19641 ,2487 ,21334 ,19331 ,22327 ,32760 ,24131 ,26693 ,31330 ,31501 ,21534 , -3988 ,-23312 ,-31602 ,-32758 ,-31491 ,-23272 ,4266 ,21413 ,-9585 ,-31706 ,-31450 ,-31465 ,-19322 ,10601 ,5094 , -4287 ,285 ,-2685 ,-30163 ,-30794 ,-20145 ,10256 ,-18281 ,-32766 ,-30560 ,-16632 ,8525 ,27180 ,31043 ,30638 , 20031 ,6250 ,10282 ,18420 ,23245 ,26683 ,25810 ,21182 ,923 ,-10908 ,21699 ,30953 ,-25880 ,-20051 ,-32442 , -23805 ,-11361 ,-4022 ,-13581 ,-21530 ,-22514 ,-22732 ,-25089 ,-26843 ,-29722 ,-32281 ,-28807 ,-14800 ,10315 ,32059 , 17851 ,32707 ,31127 ,-28227 ,-27459 ,-31768 ,31468 ,-18232 ,-11830 ,9041 ,10618 ,15689 ,27623 ,32167 ,32762 , 32675 ,32250 ,31911 ,31661 ,30578 ,21658 ,12868 ,23233 ,32661 ,5911 ,-20245 ,32435 ,-5765 ,19997 ,32738 , 27314 ,9371 ,-224 ,-4949 ,-5310 ,-1688 ,5388 ,7612 ,-14879 ,-29835 ,-32571 ,-32650 ,-25523 ,-4752 ,18611 , 27239 ,-388 ,-22727 ,15376 ,32431 ,27075 ,1727 ,595 ,992 ,-16447 ,-24359 ,10050 ,32762 ,31579 ,32391 , 6786 ,-13494 ,8176 ,29031 ,32314 ,26557 ,24932 ,27689 ,32524 ,22768 ,-255 ,-20668 ,-31916 ,-32742 ,-29449 , -20380 ,-24849 ,-23726 ,2456 ,22985 ,11471 ,-7629 ,-26107 ,-31558 ,-20616 ,-6979 ,-22055 ,-32765 ,-6817 ,2134 , -10268 ,26990 ,31105 ,30444 ,30616 ,30183 ,14938 ,1335 ,18167 ,30064 ,24910 ,8566 ,-22998 ,-32509 ,-16655 , 9965 ,-12044 ,-27352 ,-4060 ,25773 ,31354 ,29941 ,-8000 ,-32737 ,-30968 ,-18751 ,-9068 ,-3068 ,-6333 ,-14013 , -25364 ,-30708 ,-31748 ,-27399 ,8279 ,27823 ,346 ,-24836 ,-27703 ,-29768 ,21270 ,22734 ,24025 ,25575 ,28419 , 31278 ,32706 ,32531 ,30941 ,29222 ,28463 ,28402 ,28396 ,28424 ,29132 ,30089 ,30731 ,31065 ,31454 ,31921 , 32428 ,32763 ,32765 ,32677 ,32552 ,32156 ,31698 ,31249 ,30992 ,30833 ,30666 ,30441 ,30276 ,29884 ,29426 , 29005 ,28447 ,27915 ,27504 ,27399 ,27444 ,27486 ,27285 ,27145 ,26969 ,26795 ,26485 ,26804 ,27506 ,26678 , 25709 ,27031 ,27474 ,25761 ,24761 ,24682 ,24920 ,25176 ,25163 ,24714 ,24500 ,24323 ,24020 ,23951 ,24415 , 25223 ,25848 ,26106 ,26474 ,26911 ,26729 ,26152 ,25793 ,25840 ,25878 ,25951 ,26575 ,27070 ,26650 ,25807 , 25751 ,25849 ,25238 ,25173 ,26629 ,27860 ,28552 ,29634 ,30259 ,29773 ,28884 ,28391 ,28497 ,29219 ,29794 , 29760 ,29015 ,28106 ,27293 ,26858 ,26174 ,25376 ,25620 ,26910 ,28339 ,29347 ,29960 ,30348 ,30746 ,30600 , 29928 ,29039 ,28440 ,27857 ,27571 ,27820 ,28270 ,27764 ,26335 ,25285 ,25276 ,25517 ,24617 ,22098 ,17643 , 11048 ,3006 ,-5268 ,-12606 ,-18541 ,-20996 ,-16115 ,-8529 ,-5553 ,-7526 ,-11263 ,-13629 ,-17246 ,-23436 ,-28871 , -32014 ,-32475 ,-30503 ,-28654 ,-28121 ,-27724 ,-27102 ,-27174 ,-28115 ,-29165 ,-30451 ,-31671 ,-32584 ,-32765 ,-31885 , -29374 ,-25340 ,-19842 ,-14007 ,-8684 ,-4355 ,-1913 ,-4181 ,-8488 ,-10053 ,-9115 ,-6566 ,-4053 ,-1405 ,2171 , 5331 ,7744 ,8667 ,6898 ,5129 ,6075 ,7348 ,7581 ,7657 ,8787 ,10872 ,12626 ,13194 ,13920 ,14801 , 14248 ,12266 ,10271 ,8701 ,6991 ,5407 ,5099 ,6686 ,8317 ,8712 ,8043 ,7317 ,6371 ,4890 ,3121 , 1848 ,1396 ,1645 ,2575 ,3443 ,3674 ,3448 ,3491 ,3291 ,2329 ,936 ,-141 ,-101 ,401 ,279 , -464 ,-173 ,1057 ,2046 ,2702 ,3193 ,2983 ,2379 ,2113 ,1910 ,1314 ,795 ,971 ,1865 ,2573 , 2504 ,2380 ,2060 ,1323 ,212 ,-589 ,-1205 ,-1440 ,-1251 ,-596 ,231 ,990 ,1394 ,1610 ,1771 , 2604 ,4607 ,8604 ,12831 ,17741 ,23138 ,27524 ,30684 ,28802 ,23903 ,21178 ,660 ,10845 ,8228 ,1292 , 179 ,1036 ,1718 ,1944 ,1700 ,1480 ,2953 ,9990 ,20291 ,19795 ,14906 ,14262 ,19783 ,32765 ,26989 , 17995 ,17603 ,16020 ,15730 ,16051 ,15780 ,14453 ,12505 ,11334 ,11748 ,11654 ,4392 ,-3156 ,-699 ,2530 , 1253 ,354 ,-1011 ,-9545 ,-20789 ,-10855 ,-5420 ,-6921 ,-6696 ,-8815 ,-11937 ,-13449 ,-13175 ,-12328 ,-12180 , -13269 ,-15813 ,-19402 ,-19856 ,-15482 ,-12309 ,-11865 ,-10605 ,-186 ,12056 ,2955 ,-44 ,991 ,-487 ,-1173 , -497 ,779 ,1303 ,-325 ,-2110 ,-1766 ,1262 ,4052 ,3011 ,-1576 ,-7925 ,-13535 ,-12832 ,-7997 ,-5607 , -4505 ,-2556 ,-356 ,2274 ,1579 ,-121 ,-367 ,97 ,-598 ,-3200 ,-6210 ,-7973 ,-8481 ,-8313 ,-7340 , -4145 ,1528 ,6265 ,6634 ,3062 ,643 ,4714 ,11733 ,18205 ,22509 ,5824 ,-3157 ,12019 ,21380 ,26522 , 24212 ,15853 ,16575 ,21736 ,22314 ,24127 ,29503 ,28779 ,28206 ,28709 ,24867 ,23191 ,22717 ,20938 ,19583 , 18192 ,7739 ,5029 ,10979 ,256 ,-10141 ,-17029 ,-18364 ,-14593 ,-10055 ,-8297 ,-9436 ,-11713 ,-13476 ,-14491 , -15356 ,-15771 ,-11187 ,-975 ,1067 ,-2402 ,2057 ,18987 ,24618 ,19621 ,18387 ,10040 ,1187 ,-3422 ,-2763 , -3688 ,-9033 ,-7073 ,-1583 ,-934 ,-725 ,-14 ,363 ,-150 ,-1390 ,-3391 ,-6175 ,-14287 ,-28228 ,-23813 , -23195 ,-32765 ,-28629 ,-24252 ,-22670 ,-21587 ,-22237 ,-21912 ,-20430 ,-19075 ,-19432 ,-21805 ,-24951 ,-26605 ,-25575 , -22881 ,-19596 ,-11245 ,-137 ,-8676 ,-12525 ,-10209 ,-8844 ,-436 ,6386 ,2222 ,29 ,1052 ,1162 ,2220 , 9786 ,15231 ,13411 ,12128 ,12041 ,10444 ,8155 ,6336 ,5277 ,5700 ,7047 ,6175 ,3524 ,1217 ,1693 , 2612 ,3579 ,4140 ,3948 ,3305 ,2509 ,1774 ,1164 ,846 ,1054 ,2280 ,3884 ,5140 ,4934 ,-1276 , -15564 ,-23990 ,-17612 ,-1689 ,-378 ,-6460 ,4355 ,206 ,-4136 ,-1255 ,-504 ,-36 ,898 ,1963 ,2977 , 3411 ,2961 ,2368 ,2067 ,2146 ,2362 ,1788 ,-3388 ,-18705 ,-13622 ,-4476 ,-5193 ,-871 ,-568 ,9191 , 17174 ,13153 ,8606 ,19390 ,28916 ,20582 ,18317 ,18358 ,18242 ,17869 ,17505 ,15616 ,4013 ,-5924 ,1171 , 4155 ,2393 ,1989 ,400 ,366 ,-13737 ,-20800 ,-10559 ,-12855 ,-10472 ,-14012 ,-13364 ,-27939 ,-32571 ,-28515 , -24454 ,-24310 ,-23383 ,-26084 ,-23474 ,-26253 ,-22561 ,-25650 ,-4606 ,-4113 ,-16868 ,-13178 ,-14655 ,-13294 ,-13777 , -13256 ,-12423 ,-12186 ,-11092 ,-8272 ,6693 ,9032 ,770 ,-1650 ,-687 ,-14751 ,-11451 ,12357 ,12655 ,9342 , 6098 ,7993 ,7415 ,8643 ,8201 ,9062 ,8749 ,8824 ,8776 ,9565 ,9383 ,9697 ,9791 ,9813 ,10221 , 9805 ,10522 ,9547 ,8254 ,-6450 ,-2467 ,3839 ,-1740 ,1106 ,-1144 ,374 ,-7878 ,-24354 ,-32765 ,-26158 , -24384 ,-24471 ,-13592 ,2229 ,-9301 ,-9126 ,7320 ,3590 ,-3199 ,478 ,-2155 ,366 ,-1406 ,486 ,-1014 , 628 ,-772 ,768 ,-591 ,830 ,-373 ,793 ,-66 ,-5251 ,-14773 ,7094 ,9524 ,620 ,2069 ,1616 , 2052 ,2002 ,1807 ,2158 ,2131 ,10171 ,21266 ,17840 ,12344 ,11777 ,18656 ,32765 ,24937 ,19177 ,20541 , 19661 ,19583 ,19015 ,18542 ,18063 ,16940 ,15898 ,14995 ,12954 ,2155 ,-9318 ,-1813 ,-8718 ,-22933 ,-14187 , -11960 ,-13039 ,-14143 ,-13770 ,-14952 ,-14415 ,-15115 ,-14330 ,-15953 ,-14838 ,-16547 ,-15092 ,-17037 ,-14839 ,-17584 , -5284 ,-4177 ,-10942 ,-8340 ,-9029 ,-8115 ,-7881 ,-3612 ,-257 ,-3294 ,-3622 ,-4024 ,-3440 ,-5016 ,-4011 , -5617 ,-4888 ,-17349 ,-17423 ,-7456 ,-9836 ,-7987 ,-9095 ,-8073 ,-13508 ,-14613 ,-12745 ,-11034 ,-11635 ,-11354 , -10763 ,-4915 ,-3240 ,-3651 ,-3272 ,-3118 ,-2986 ,-2754 ,-2702 ,-2487 ,-2450 ,-2265 ,-2247 ,-2089 ,-2103 , -1939 ,-1964 ,-1829 ,-1846 ,-1729 ,-1759 ,-1644 ,-1669 ,-1585 ,-1607 ,-1526 ,-1558 ,-1496 ,-1513 ,-1452 , -1478 ,-1424 ,-1443 ,-1403 ,-1418 ,-1382 ,-1389 ,-1368 ,-1353 ,-1349 ,-1337 ,-1327 ,-1311 ,-1331 ,-1284 , -1318 ,-1265 ,-1324 ,-1248 ,-1328 ,-1219 ,-1345 ,-1194 ,-1380 ,-1150 ,-1429 ,-1075 ,-1540 ,8055 ,7772 , 7270 ,6084 ,3973 ,693 ,-2497 ,-4449 ,-4378 ,-2707 ,-137 ,2957 ,5805 ,8651 ,11070 ,12667 ,13117 , 12371 ,10212 ,7308 ,5290 ,4827 ,5934 ,8377 ,11691 ,14441 ,17167 ,19523 ,20954 ,22613 ,23766 ,23658 , 22364 ,20270 ,17810 ,15666 ,14232 ,13645 ,13597 ,13852 ,13132 ,11383 ,9579 ,7366 ,5779 ,5117 ,4488 , 3414 ,1879 ,444 ,169 ,570 ,1307 ,1058 ,-667 ,-2783 ,-4757 ,-6093 ,-6538 ,-5851 ,-5284 ,-5548 , -6359 ,-7109 ,-7150 ,-6716 ,-6024 ,-4708 ,-3043 ,-1960 ,-1501 ,-1517 ,-1064 ,543 ,3110 ,4964 ,5778 , 5691 ,4742 ,5287 ,6962 ,9486 ,11418 ,11481 ,9963 ,7902 ,5413 ,3102 ,1764 ,506 ,-1193 ,-2314 , -1633 ,1351 ,5705 ,9972 ,13283 ,13552 ,11800 ,10049 ,8076 ,6443 ,4878 ,4035 ,4967 ,6565 ,6764 , 5827 ,6169 ,9706 ,17217 ,24490 ,27281 ,25465 ,22002 ,20729 ,21547 ,21769 ,19898 ,17121 ,15686 ,16512 , 18886 ,22917 ,27382 ,30958 ,32206 ,29789 ,24805 ,20963 ,20872 ,24231 ,28915 ,32197 ,32765 ,31520 ,28745 , 24912 ,17867 ,6172 ,-8541 ,-21721 ,-30094 ,-32765 ,-30825 ,-26712 ,-22568 ,-17943 ,-12146 ,-6441 ,-3442 ,-4651 , -9018 ,-13640 ,-15242 ,-12240 ,-5616 ,4002 ,13730 ,19796 ,18950 ,11573 ,2240 ,-4792 ,-8077 ,-9144 ,-11040 , -12955 ,-12698 ,-8429 ,-1841 ,3980 ,6462 ,5636 ,2724 ,-376 ,-2717 ,-5456 ,-8298 ,-10594 ,-13400 ,-16849 , -20732 ,-23605 ,-24318 ,-21686 ,-17048 ,-12428 ,-8970 ,-7818 ,-8748 ,-10768 ,-12489 ,-13507 ,-14320 ,-15355 ,-15408 , -14636 ,-13201 ,-10746 ,-7907 ,-4750 ,-2388 ,-344 ,1686 ,4269 ,7104 ,9393 ,11611 ,12838 ,13462 ,13855 , 13959 ,14630 ,15191 ,15733 ,15587 ,14543 ,13129 ,11427 ,9685 ,8840 ,8956 ,9058 ,9167 ,8620 ,8020 , 8170 ,8956 ,10289 ,10624 ,9821 ,9139 ,8586 ,8620 ,10178 ,12447 ,14554 ,15467 ,13805 ,10785 ,6696 , 2472 ,-487 ,-2066 ,-2497 ,-1928 ,123 ,3338 ,6420 ,8795 ,10983 ,11786 ,11214 ,9706 ,8505 ,-7485 , -5558 ,-3734 ,-2038 ,-547 ,698 ,1738 ,2563 ,3264 ,3821 ,4402 ,4979 ,5660 ,6374 ,7224 ,8095 , 9036 ,9953 ,10898 ,11838 ,12820 ,13867 ,15045 ,16374 ,17836 ,19450 ,21150 ,22939 ,24709 ,26482 ,28100 , 29598 ,30831 ,31852 ,32490 ,32765 ,32631 ,32045 ,30934 ,29318 ,27224 ,24677 ,21706 ,18365 ,14801 ,11020 , 7290 ,3608 ,171 ,-3073 ,-5961 ,-8495 ,-10682 ,-12539 ,-14021 ,-15080 ,-15789 ,-16099 ,-16043 ,-15576 ,-14849 , -13871 ,-12765 ,-11510 ,-10276 ,-9039 ,-7892 ,-6824 ,-5896 ,-5119 ,-4546 ,-4236 ,-4179 ,-4402 ,-4857 ,-5597 , -6480 ,-7531 ,-8637 ,-9821 ,-10950 ,-12048 ,-13043 ,-13946 ,-14650 ,-15214 ,-15601 ,-15818 ,-15827 ,-15596 ,-15153 , -14402 ,-13354 ,-11997 ,-10414 ,-8594 ,-6686 ,-4732 ,-2876 ,-1120 ,352 ,1564 ,2468 ,3097 ,3416 ,3479 , 3353 ,3061 ,2655 ,2114 ,1533 ,870 ,202 ,-524 ,-1262 ,-1995 ,-2686 ,-3347 ,-3922 ,-4423 ,-4809 , -5063 ,-5232 ,-5295 ,-5319 ,-5268 ,-5262 ,-5262 ,-5382 ,-5597 ,-5982 ,-6520 ,-7265 ,-8219 ,-9409 ,-10789 , -12346 ,-14074 ,-15897 ,-17770 ,-19628 ,-21451 ,-23113 ,-24654 ,-26003 ,-27182 ,-28116 ,-28876 ,-29413 ,-29779 ,-29892 , -29792 ,-29481 ,-28921 ,-28111 ,-27074 ,-25867 ,-24492 ,-23088 ,-21662 ,-20356 ,-19156 ,-18258 ,-17591 ,-17228 ,-17141 , -17428 ,-18002 ,-18851 ,-19943 ,-21247 ,-22749 ,-24321 ,-25948 ,-27521 ,-29039 ,-30359 ,-31464 ,-32238 ,-32692 ,-32765 , -32480 ,-31803 ,-30738 ,-29353 ,-27668 ,-25687 ,-23383 ,-20873 ,-18165 ,-15380 ,-12521 ,-9748 ,-7105 ,-4750 ,-2643 , -824 ,667 ,1790 ,2574 ,3027 ,3125 ,2919 ,2378 ,1594 ,537 ,-664 ,-2076 ,-3525 ,-5059 ,-6551 , -8013 ,-9384 ,-10665 ,-11807 ,-12830 ,-13729 ,-14477 ,-15067 ,-15456 ,-15657 ,-15609 ,-15394 ,-14944 ,-14407 ,-13748 , -13096 ,-12460 ,-11956 ,-11594 ,-11407 ,-11409 ,-11626 ,-12067 ,-12667 ,-13451 ,-14311 ,-15289 ,-16248 ,-17218 ,-18058 , -18777 ,-19314 ,-19711 ,-19858 ,-19832 ,-19621 ,-19249 ,-18708 ,-17935 ,-17004 ,-15833 ,-14496 ,-12914 ,-11207 ,-9361 , -1827 ,1003 ,3006 ,4165 ,4429 ,3714 ,2224 ,175 ,-2216 ,-4672 ,-6848 ,-8614 ,-9840 ,-10474 ,-10554 , -10176 ,-9247 ,-7720 ,-5611 ,-3167 ,-517 ,2085 ,4495 ,6614 ,8363 ,9653 ,10274 ,10215 ,9340 ,7732 , 5541 ,3341 ,1511 ,539 ,775 ,2051 ,4106 ,6595 ,9108 ,11333 ,13108 ,14364 ,15053 ,15268 ,15169 , 14834 ,14381 ,13878 ,13369 ,12771 ,12005 ,10994 ,9853 ,8691 ,7732 ,7244 ,7321 ,7920 ,8881 ,10027 , 11158 ,12190 ,12954 ,13332 ,13191 ,12450 ,11064 ,9169 ,7146 ,5419 ,4261 ,3968 ,4400 ,5345 ,6535 , 7777 ,9010 ,10268 ,11615 ,13002 ,14339 ,15449 ,16221 ,16551 ,16551 ,16320 ,15942 ,15405 ,14705 ,13883 , 13008 ,12260 ,11901 ,12090 ,12824 ,14049 ,15548 ,17118 ,18553 ,19849 ,20927 ,21807 ,22436 ,22739 ,22639 , 22147 ,21461 ,20804 ,20458 ,20577 ,21176 ,22144 ,23397 ,24747 ,26135 ,27528 ,28963 ,30335 ,31562 ,32452 , 32765 ,32196 ,30611 ,27848 ,23761 ,18220 ,11590 ,4325 ,-2990 ,-9331 ,-14142 ,-16942 ,-17666 ,-16264 ,-13556 , -10127 ,-6501 ,-3098 ,-78 ,2531 ,4775 ,6669 ,8236 ,9412 ,10169 ,10268 ,9547 ,7901 ,5319 ,1786 , -2324 ,-6540 ,-10376 ,-13427 ,-15455 ,-16631 ,-17263 ,-17649 ,-18127 ,-18718 ,-19389 ,-20018 ,-20521 ,-20884 ,-21176 , -21415 ,-21673 ,-21865 ,-21877 ,-21631 ,-21029 ,-20109 ,-18891 ,-17460 ,-15807 ,-14025 ,-12201 ,-10538 ,-9244 ,-8637 , -8771 ,-9696 ,-11309 ,-13429 ,-15789 ,-18263 ,-20779 ,-23271 ,-25708 ,-28062 ,-30270 ,-31919 ,-32765 ,-32635 ,-31505 , -29351 ,-26636 ,-23624 ,-20697 ,-18245 ,-16434 ,-15295 ,-14801 ,-14850 ,-15193 ,-15695 ,-16231 ,-16838 ,-17526 ,-18374 , -19360 ,-20475 ,-21555 ,-22483 ,-23058 ,-23191 ,-22757 ,-21904 ,-20757 ,-19528 ,-18424 ,-17649 ,-17372 ,-17638 ,-18486 , -19646 ,-20891 ,-21918 ,-22464 ,-22439 ,-21935 ,-21063 ,-20073 ,-19141 ,-18399 ,-17870 ,-17526 ,-17343 ,-17301 ,-17428 , -17709 ,-18201 ,-18812 ,-19504 ,-20195 ,-20876 ,-21434 ,-21834 ,-21882 ,-21372 ,-20189 ,-18235 ,-15513 ,-12111 ,-8428 , -4768 ,-5562 ,-4649 ,-3902 ,-3472 ,-3368 ,-3671 ,-4204 ,-4885 ,-5574 ,-6279 ,-7042 ,-7831 ,-8601 ,-9245 , -9641 ,-9652 ,-9352 ,-8752 ,-8080 ,-7362 ,-6614 ,-5639 ,-4366 ,-2655 ,-616 ,1643 ,3924 ,6029 ,7978 , 9797 ,11634 ,13410 ,15213 ,16845 ,18192 ,19088 ,19621 ,19727 ,19492 ,18918 ,18004 ,16678 ,15006 ,13188 , 11385 ,9814 ,8507 ,7514 ,6662 ,5860 ,5082 ,4572 ,4378 ,4666 ,5362 ,6404 ,7533 ,8598 ,9517 , 10305 ,11088 ,11768 ,12265 ,12440 ,12396 ,12108 ,11770 ,11468 ,11348 ,11312 ,11256 ,11018 ,10692 ,10295 , 9999 ,10021 ,10444 ,11132 ,11921 ,12678 ,13204 ,13624 ,13933 ,14368 ,14861 ,15490 ,16130 ,16785 ,17409 , 18117 ,18892 ,19729 ,20561 ,21234 ,21769 ,22130 ,22554 ,23114 ,23964 ,25002 ,26187 ,27191 ,27939 ,28362 , 28657 ,28978 ,29478 ,30176 ,31016 ,31827 ,32423 ,32759 ,32765 ,32481 ,31781 ,30630 ,28858 ,26532 ,23732 , 20710 ,17596 ,14539 ,11460 ,8315 ,5020 ,1672 ,-1457 ,-4101 ,-5999 ,-6937 ,-7065 ,-6649 ,-5815 ,-4779 , -3590 ,-2367 ,-1124 ,-85 ,667 ,998 ,917 ,421 ,-439 ,-1554 ,-3081 ,-5083 ,-7742 ,-10855 ,-14229 , -17514 ,-20425 ,-22827 ,-24775 ,-26380 ,-27827 ,-29233 ,-30562 ,-31661 ,-32375 ,-32735 ,-32765 ,-32657 ,-32424 ,-32237 , -32044 ,-31907 ,-31733 ,-31661 ,-31661 ,-31804 ,-32005 ,-32199 ,-32247 ,-32087 ,-31764 ,-31356 ,-31028 ,-30820 ,-30758 , -30663 ,-30477 ,-30080 ,-29493 ,-28650 ,-27922 ,-27350 ,-27031 ,-26824 ,-26604 ,-26440 ,-26291 ,-26225 ,-26200 ,-26346 , -26581 ,-26871 ,-27022 ,-27191 ,-27451 ,-28032 ,-28770 ,-29553 ,-30189 ,-30511 ,-30450 ,-30067 ,-29541 ,-28978 ,-28496 , -27957 ,-27310 ,-26447 ,-25418 ,-24299 ,-23347 ,-22570 ,-22099 ,-21803 ,-21647 ,-21606 ,-21742 ,-22179 ,-22943 ,-23997 , -25071 ,-26077 ,-26894 ,-27623 ,-28161 ,-28754 ,-29372 ,-30013 ,-30471 ,-30684 ,-30586 ,-30330 ,-29990 ,-29625 ,-29311 , -28932 ,-28413 ,-27576 ,-26543 ,-25320 ,-24084 ,-22763 ,-21418 ,-19907 ,-18205 ,-16210 ,-14146 ,-12137 ,-10310 ,-8770 , -7433 ,-6285 ,4508 ,5284 ,5726 ,6062 ,6376 ,6827 ,7428 ,8282 ,9462 ,10691 ,11771 ,12372 ,12405 , 12043 ,11678 ,11520 ,11571 ,11688 ,11849 ,12155 ,12848 ,13636 ,14256 ,14219 ,13522 ,12299 ,10907 ,9628 , 8602 ,8048 ,7742 ,7633 ,7421 ,7377 ,6979 ,6456 ,6053 ,5985 ,6695 ,7870 ,9474 ,11619 ,14119 , 16914 ,19139 ,20536 ,20386 ,19552 ,18358 ,17418 ,17154 ,17461 ,18236 ,19254 ,20329 ,21196 ,21769 ,22112 , 22501 ,23291 ,24539 ,26111 ,27925 ,29888 ,31776 ,32765 ,32758 ,30485 ,27720 ,24888 ,23532 ,23431 ,24743 , 26221 ,27500 ,28301 ,28732 ,28749 ,28373 ,27531 ,26648 ,25917 ,25392 ,24811 ,23836 ,22360 ,20271 ,17456 , 14188 ,10923 ,8099 ,6717 ,6443 ,7384 ,8579 ,9757 ,10421 ,10982 ,11377 ,11575 ,11534 ,11404 ,11523 , 12116 ,13070 ,14134 ,15006 ,15626 ,15737 ,15672 ,15504 ,15503 ,15876 ,16747 ,17850 ,18763 ,19294 ,19084 , 18608 ,17957 ,17098 ,16010 ,14669 ,13469 ,12636 ,12540 ,12831 ,13276 ,13633 ,13693 ,13642 ,13561 ,13575 , 13717 ,14128 ,14862 ,15816 ,16906 ,17921 ,18879 ,19850 ,20484 ,20642 ,20037 ,18900 ,17532 ,16291 ,15023 , 13544 ,11281 ,8259 ,4465 ,288 ,-4040 ,-8345 ,-12420 ,-15823 ,-18519 ,-19834 ,-20534 ,-20643 ,-20411 ,-20172 , -20121 ,-20458 ,-20841 ,-20946 ,-20218 ,-18719 ,-16634 ,-14553 ,-12716 ,-11318 ,-10139 ,-9008 ,-7849 ,-6716 ,-5444 , -3810 ,-1737 ,379 ,2133 ,2739 ,2323 ,656 ,-1791 ,-4558 ,-6964 ,-8579 ,-9261 ,-8987 ,-8476 ,-7973 , -7802 ,-7770 ,-7711 ,-7465 ,-7135 ,-6714 ,-5986 ,-4992 ,-3859 ,-3172 ,-3423 ,-4860 ,-7122 ,-9684 ,-12124 , -13668 ,-14371 ,-14287 ,-13528 ,-12791 ,-12443 ,-12875 ,-13852 ,-15409 ,-17025 ,-18751 ,-20547 ,-22175 ,-23536 ,-24556 , -25516 ,-26736 ,-28504 ,-30408 ,-32105 ,-32765 ,-32451 ,-31142 ,-29118 ,-26793 ,-24402 ,-22191 ,-20501 ,-19206 ,-18343 , -17480 ,-16581 ,-15595 ,-14453 ,-13029 ,-11208 ,-9308 ,-7561 ,-6370 ,-5650 ,-5179 ,-4389 ,-3241 ,-1754 ,-287 , 1040 ,2181 ,3329 ,5319 ,8332 ,10988 ,12926 ,13749 ,13831 ,13104 ,12120 ,11018 ,10382 ,10190 ,10724 , 12213 ,14295 ,17055 ,19681 ,22010 ,23213 ,23643 ,22976 ,21392 ,19322 ,16975 ,14955 ,13346 ,12444 ,11957 , 12028 ,12543 ,13367 ,14541 ,15646 ,16604 ,17201 ,17571 ,17707 ,17786 ,17736 ,17442 ,17025 ,16504 ,15943 , 15377 ,14925 ,14784 ,15078 ,15981 ,17201 ,18657 ,20187 ,21734 ,23219 ,24503 ,25389 ,25730 ,25358 ,24496 , 23344 ,22221 ,21199 ,20364 ,19842 ,19680 ,20082 ,20802 ,21752 ,22843 ,24000 ,25109 ,25941 ,26433 ,26449 , 26255 ,25905 ,25450 ,24910 ,24297 ,23842 ,23649 ,24211 ,25250 ,26770 ,28350 ,29871 ,31133 ,32129 ,32765 , 32626 ,31909 ,30496 ,28645 ,26459 ,23828 ,21089 ,18569 ,16978 ,15688 ,14573 ,13691 ,13285 ,13407 ,14254 , 15629 ,17423 ,19423 ,21305 ,22800 ,23659 ,23865 ,23062 ,21501 ,19287 ,16742 ,14310 ,12287 ,10851 ,9937 , 9833 ,10155 ,10800 ,11479 ,12093 ,12563 ,12784 ,12716 ,12021 ,11095 ,10045 ,9279 ,8900 ,9001 ,9270 , 9557 ,9666 ,9947 ,10532 ,11655 ,12976 ,14344 ,15480 ,16408 ,17059 ,17416 ,17414 ,16967 ,15936 ,14217 , 11970 ,9625 ,7636 ,6832 ,7120 ,8408 ,9961 ,11426 ,12339 ,12794 ,12822 ,12089 ,10444 ,7482 ,3381 , -1461 ,-6021 ,-9810 ,-12630 ,-14061 ,-14838 ,-15247 ,-15644 ,-16073 ,-16424 ,-16639 ,-16743 ,-17339 ,-18575 ,-20814 , -23615 ,-26551 ,-28634 ,-29980 ,-30597 ,-30843 ,-30892 ,-30742 ,-30203 ,-29371 ,-28324 ,-27469 ,-26962 ,-27152 ,-27726 , -28634 ,-29444 ,-30160 ,-30736 ,-31383 ,-32076 ,-32633 ,-32765 ,-32182 ,-30964 ,-29315 ,-27455 ,-25761 ,-24212 ,-22630 , -20939 ,-19143 ,-17539 ,-16259 ,-15525 ,-15335 ,-15671 ,-16429 ,-17266 ,-17954 ,-18252 ,-18149 ,-17603 ,-16602 ,-15266 , -13729 ,-12213 ,-10849 ,-9879 ,-9365 ,-9343 ,-9815 ,-10564 ,-11474 ,-12286 ,-12837 ,-12614 ,-11657 ,-9998 ,-7864 , -5562 ,-3279 ,-1134 ,873 ,2533 ,3848 ,4780 ,4949 ,4591 ,3623 ,2287 ,729 ,-827 ,-2068 ,-2840 , -2549 ,-1558 ,401 ,3001 ,2393 ,4418 ,6355 ,7960 ,9190 ,9784 ,10091 ,10205 ,10334 ,10767 ,11544 , 12767 ,14381 ,16166 ,17897 ,19364 ,20497 ,21026 ,21211 ,21053 ,20872 ,20884 ,21334 ,22275 ,23688 ,25480 , 27393 ,29153 ,30592 ,31356 ,31574 ,31099 ,30264 ,29278 ,28463 ,27996 ,28014 ,28594 ,29577 ,30761 ,31828 , 32513 ,32765 ,32368 ,31499 ,30270 ,28934 ,27735 ,26828 ,26382 ,26279 ,26562 ,26795 ,26814 ,26436 ,25457 , 24008 ,22206 ,20495 ,19089 ,18388 ,18500 ,19245 ,20971 ,22856 ,24761 ,26205 ,26947 ,26833 ,25913 ,24373 , 22428 ,20565 ,19040 ,17950 ,17850 ,18231 ,19141 ,20202 ,21187 ,21806 ,21958 ,21620 ,20785 ,19865 ,19039 , 18515 ,18588 ,19226 ,20475 ,22021 ,23682 ,25030 ,25985 ,26395 ,26048 ,25268 ,24118 ,22950 ,21899 ,21107 , 20610 ,20246 ,19878 ,19026 ,17664 ,15529 ,12346 ,8421 ,3630 ,-1198 ,-5742 ,-9158 ,-11176 ,-11558 ,-10532 , -8521 ,-6010 ,-3738 ,-2258 ,-1524 ,-2240 ,-3616 ,-5545 ,-7568 ,-9322 ,-10474 ,-10927 ,-10837 ,-10119 ,-9355 , -8742 ,-8460 ,-8858 ,-9723 ,-11021 ,-12465 ,-13860 ,-14677 ,-14950 ,-14789 ,-14447 ,-14062 ,-13900 ,-14096 ,-14780 , -15894 ,-17189 ,-18454 ,-19257 ,-19629 ,-19362 ,-18423 ,-17056 ,-15356 ,-13735 ,-12339 ,-11457 ,-11068 ,-11203 ,-11623 , -12137 ,-12598 ,-12806 ,-12716 ,-12366 ,-11863 ,-11494 ,-11429 ,-11924 ,-12943 ,-14774 ,-16996 ,-19511 ,-22133 ,-24533 , -26601 ,-28262 ,-29448 ,-30307 ,-30934 ,-31432 ,-31859 ,-32244 ,-32562 ,-32765 ,-32646 ,-32200 ,-31315 ,-30048 ,-28455 , -26588 ,-24772 ,-23204 ,-21972 ,-21440 ,-21405 ,-21900 ,-22707 ,-23575 ,-24194 ,-24394 ,-24148 ,-23146 ,-21753 ,-20073 , -18399 ,-17021 ,-16063 ,-15650 ,-15741 ,-16170 ,-16718 ,-17129 ,-17278 ,-16802 ,-15912 ,-14499 ,-12903 ,-11302 ,-9898 , -8843 ,-8228 ,-8024 ,-8020 ,-8000 ,-7805 ,-7167 ,-6155 ,-4561 ,-2754 ,-892 ,608 ,1663 ,2093 ,1801 , 941 ,-370 ,-1708 ,-2834 ,-3617 ,-3713 ,-3316 ,-2477 ,-1430 ,-453 ,258 ,517 ,379 ,-304 ,-1079 , -1793 ,-2227 ,-2046 ,-1274 ,111 ,1996 ,5139 ,7252 ,7218 ,5435 ,3848 ,4665 ,8589 ,14402 ,19702 , 22587 ,23544 ,24135 ,26045 ,29122 ,31865 ,32765 ,31097 ,28118 ,25883 ,25609 ,27175 ,28960 ,29409 ,28510 , 27429 ,27753 ,29227 ,30594 ,30198 ,27041 ,22434 ,18311 ,16293 ,16801 ,17892 ,17837 ,16106 ,13521 ,11779 , 11630 ,12863 ,14148 ,14110 ,12664 ,10915 ,10238 ,11022 ,12341 ,13272 ,13228 ,12501 ,11809 ,11523 ,11671 , 11533 ,10592 ,8719 ,6665 ,5579 ,5863 ,7010 ,8158 ,8283 ,7356 ,5622 ,3611 ,2187 ,1561 ,1376 , 796 ,-584 ,-2286 ,-3427 ,-3586 ,-2563 ,-894 ,675 ,1341 ,886 ,-2 ,-597 ,-840 ,-1261 ,-2147 , -3276 ,-4032 ,-3842 ,-2228 ,263 ,2697 ,3803 ,3209 ,2067 ,1590 ,2317 ,3610 ,4214 ,3420 ,1468 , -754 ,-2026 ,-1957 ,-991 ,-513 ,-1322 ,-3063 ,-4486 ,-4553 ,-3519 ,-2418 ,-1941 ,-2009 ,-1914 ,-1047 , 505 ,1986 ,2034 ,216 ,-2905 ,-5750 ,-6852 ,-6326 ,-5284 ,-4798 ,-5357 ,-6283 ,-6764 ,-6258 ,-4869 , -3791 ,-3823 ,-5170 ,-7141 ,-8903 ,-9938 ,-10349 ,-10164 ,-9631 ,-8818 ,-7714 ,-6306 ,-4774 ,-3556 ,-2954 , -3186 ,-3961 ,-4734 ,-4892 ,-4114 ,-2234 ,45 ,1958 ,2702 ,2345 ,1959 ,2348 ,3649 ,5077 ,5645 , 4986 ,3692 ,3350 ,5047 ,8423 ,12035 ,13873 ,13800 ,12630 ,11537 ,11084 ,10721 ,9486 ,7032 ,4545 , 4164 ,6886 ,11676 ,16158 ,17924 ,16933 ,14552 ,12808 ,12673 ,12882 ,11538 ,7579 ,1937 ,-2741 ,-4758 , -3940 ,-1956 ,-1641 ,-3987 ,-7387 ,-9327 ,-9081 ,-8043 ,-7270 ,-8487 ,-11441 ,-14163 ,-14513 ,-11450 ,-7241 , -4775 ,-5712 ,-9396 ,-13216 ,-15073 ,-14640 ,-13302 ,-13368 ,-15670 ,-18974 ,-20877 ,-19446 ,-16044 ,-13194 ,-13337 , -17203 ,-22434 ,-26651 ,-28661 ,-28815 ,-29136 ,-30564 ,-32528 ,-32765 ,-29732 ,-24084 ,-18055 ,-14809 ,-14778 ,-16412 , -17455 ,-16271 ,-13266 ,-10525 ,-9829 ,-11465 ,-13349 ,-13333 ,-10969 ,-7461 ,-5124 ,-5021 ,-6682 ,-8322 ,-7980 , -5440 ,-2088 ,267 ,388 ,-413 ,-452 ,6372 ,10816 ,15329 ,18753 ,20717 ,21547 ,22496 ,24065 ,25898 , 26959 ,26746 ,25719 ,24658 ,24515 ,25331 ,26639 ,27576 ,27709 ,27396 ,27585 ,28585 ,29978 ,30785 ,30594 , 29356 ,27975 ,27197 ,27243 ,27882 ,28478 ,28307 ,27485 ,26669 ,26351 ,26759 ,27236 ,27455 ,27192 ,26746 , 26588 ,27187 ,28510 ,29932 ,30707 ,30812 ,30700 ,30855 ,31446 ,32175 ,32765 ,32688 ,32030 ,31147 ,30670 , 30743 ,31048 ,30902 ,30165 ,29181 ,28565 ,28479 ,28691 ,28845 ,28528 ,27887 ,27077 ,26430 ,25938 ,25441 , 24676 ,23691 ,22720 ,22112 ,21843 ,21861 ,21959 ,21937 ,21731 ,21312 ,20696 ,19844 ,18964 ,18213 ,17758 , 17258 ,16514 ,15500 ,14552 ,13951 ,13871 ,14124 ,14240 ,13631 ,12558 ,11511 ,10838 ,10602 ,10441 ,10227 , 9925 ,10020 ,10841 ,12641 ,14993 ,17162 ,18564 ,19317 ,19876 ,20654 ,21557 ,22011 ,21584 ,20103 ,18189 , 16537 ,15693 ,15488 ,15388 ,14786 ,13726 ,12636 ,12110 ,12042 ,11982 ,11317 ,9463 ,6952 ,4460 ,2739 , 1866 ,1123 ,-117 ,-1715 ,-3217 ,-4062 ,-4143 ,-3654 ,-3352 ,-3867 ,-5080 ,-6260 ,-6445 ,-5637 ,-4524 , -3844 ,-3691 ,-3602 ,-2806 ,-1134 ,993 ,2444 ,2710 ,1885 ,684 ,-266 ,-1079 ,-2396 ,-4848 ,-8443 , -12168 ,-15040 ,-16749 ,-17686 ,-18996 ,-20972 ,-23387 ,-25342 ,-26541 ,-27211 ,-27995 ,-29330 ,-30910 ,-32169 ,-32754 , -32765 ,-32571 ,-32420 ,-32152 ,-31447 ,-29892 ,-27738 ,-25465 ,-23792 ,-22642 ,-21633 ,-20411 ,-19156 ,-18345 ,-18197 , -18546 ,-18957 ,-19004 ,-18565 ,-17961 ,-17505 ,-17464 ,-17283 ,-16651 ,-15505 ,-14593 ,-14468 ,-15159 ,-16111 ,-16658 , -16515 ,-15857 ,-15139 ,-14845 ,-15063 ,-15136 ,-14559 ,-13154 ,-11778 ,-11039 ,-11076 ,-11305 ,-11192 ,-10683 ,-10021 , -9520 ,-9512 ,-9741 ,-9513 ,-8218 ,-5647 ,-2982 ,-1093 ,-407 ,-367 ,-157 ,553 ,1450 ,1836 ,1029 , -833 ,-2995 ,-4182 ,-3943 ,-3027 ,-2339 ,-2517 ,-3008 ,-3033 ,-2062 ,-533 ,495 ,164 ,-1345 ,-3123 , -3691 ,-2818 ,-1092 ,394 ,1145 ,1969 ,3845 ,2919 ,3627 ,4307 ,4884 ,5350 ,5720 ,6005 ,6435 , 7044 ,8001 ,9063 ,10167 ,11172 ,11872 ,12225 ,12229 ,12005 ,11658 ,11376 ,11227 ,11231 ,11435 ,11650 , 11819 ,11802 ,11604 ,11148 ,10660 ,10174 ,9740 ,9508 ,9419 ,9337 ,9104 ,8677 ,8002 ,7034 ,5816 , 4497 ,3247 ,2178 ,1402 ,899 ,830 ,974 ,1269 ,1611 ,1876 ,2006 ,1977 ,1781 ,1479 ,1173 , 987 ,943 ,1213 ,1754 ,2603 ,3775 ,5125 ,6609 ,8072 ,9427 ,10364 ,10992 ,11260 ,11180 ,10893 , 10516 ,10241 ,10145 ,10240 ,10480 ,10815 ,11201 ,11464 ,11615 ,11604 ,11487 ,11322 ,11131 ,11056 ,11143 , 11516 ,12090 ,12856 ,13708 ,14572 ,15403 ,16117 ,16776 ,17419 ,18216 ,19382 ,20824 ,22607 ,24490 ,26323 , 27850 ,29110 ,29949 ,30627 ,31184 ,31764 ,32281 ,32668 ,32765 ,32364 ,31443 ,29993 ,28233 ,26244 ,24003 , 21621 ,19079 ,16306 ,13423 ,10532 ,7867 ,5485 ,3528 ,1797 ,269 ,-1141 ,-2444 ,-3621 ,-4628 ,-5489 , -6235 ,-6856 ,-7405 ,-7875 ,-8247 ,-8552 ,-8757 ,-8881 ,-8902 ,-8728 ,-8416 ,-7952 ,-7355 ,-6711 ,-6027 , -5300 ,-4495 ,-3619 ,-2742 ,-1821 ,-856 ,-66 ,509 ,728 ,721 ,521 ,23 ,-510 ,-1033 ,-1406 , -1578 ,-1436 ,-863 ,347 ,2353 ,5159 ,8685 ,12774 ,17296 ,21734 ,25757 ,28737 ,30881 ,31740 ,31963 , 31745 ,31351 ,30606 ,28990 ,25566 ,19462 ,10252 ,-1054 ,-12659 ,-23355 ,-29788 ,-32765 ,-32164 ,-29063 ,-25314 , -22235 ,-20639 ,-20064 ,-20675 ,-20917 ,-20673 ,-19636 ,-18157 ,-16469 ,-15228 ,-14665 ,-14969 ,-15908 ,-17237 ,-18769 , -20084 ,-21151 ,-21831 ,-22214 ,-22417 ,-22411 ,-22304 ,-22119 ,-21909 ,-21651 ,-21369 ,-21136 ,-20972 ,-20915 ,-20860 , -20758 ,-20571 ,-20134 ,-19450 ,-18462 ,-17174 ,-15710 ,-14131 ,-12518 ,-10896 ,-9407 ,-7998 ,-6705 ,-5555 ,-4545 , -3695 ,-2933 ,-2280 ,-1756 ,-1459 ,-1267 ,-1101 ,-887 ,-661 ,-454 ,-310 ,-204 ,-164 ,-72 ,117 , 535 ,1012 ,1493 ,1808 ,2022 ,2134 ,2253 ,2490 ,6543 ,7260 ,8078 ,8917 ,9803 ,10613 ,11391 , 12113 ,12819 ,13517 ,14212 ,14942 ,15659 ,16422 ,17137 ,17864 ,18489 ,19111 ,19614 ,20082 ,20464 ,20774 , 21019 ,21173 ,21287 ,21294 ,21310 ,21279 ,21250 ,21221 ,21246 ,21301 ,21391 ,21536 ,21696 ,21931 ,22178 , 22494 ,22775 ,23124 ,23435 ,23757 ,24008 ,24208 ,24371 ,24467 ,24559 ,24561 ,24571 ,24544 ,24543 ,24521 , 24525 ,24520 ,24521 ,24525 ,24522 ,24544 ,24564 ,24628 ,24691 ,24795 ,24853 ,24943 ,24998 ,25059 ,25064 , 25067 ,25083 ,25070 ,25059 ,25001 ,24986 ,24915 ,24846 ,24709 ,24608 ,24483 ,24310 ,24096 ,23837 ,23594 , 23316 ,23073 ,22818 ,22638 ,22467 ,22329 ,22170 ,22003 ,21819 ,21625 ,21468 ,21267 ,21020 ,20658 ,20202 , 19623 ,18780 ,17112 ,14182 ,10765 ,8241 ,7993 ,11179 ,16827 ,22861 ,27346 ,28838 ,27752 ,24708 ,20192 , 15067 ,11002 ,9107 ,9512 ,11505 ,13700 ,15274 ,16225 ,16743 ,17168 ,18414 ,20942 ,24749 ,28718 ,31604 , 32765 ,32305 ,30846 ,29371 ,28462 ,28252 ,28821 ,29718 ,30702 ,31523 ,32100 ,32363 ,32363 ,32166 ,31857 , 31470 ,30894 ,30173 ,29416 ,28827 ,28390 ,28111 ,27414 ,24781 ,19573 ,12873 ,7112 ,4393 ,4498 ,6315 , 8503 ,9780 ,9965 ,9169 ,7852 ,6448 ,5309 ,4481 ,3863 ,3424 ,3055 ,2687 ,2141 ,1422 ,576 , -381 ,-1554 ,-2902 ,-4433 ,-6671 ,-10254 ,-15201 ,-19899 ,-23005 ,-24218 ,-24267 ,-24116 ,-24315 ,-24859 ,-25677 , -26610 ,-27457 ,-28144 ,-28644 ,-29124 ,-29554 ,-29977 ,-30362 ,-30831 ,-31298 ,-31716 ,-32069 ,-32342 ,-32548 ,-32649 , -32705 ,-32703 ,-32751 ,-32761 ,-32765 ,-32729 ,-32688 ,-32615 ,-32501 ,-32339 ,-32109 ,-31860 ,-31524 ,-31198 ,-30788 , -30379 ,-29907 ,-29453 ,-29001 ,-28562 ,-28145 ,-27732 ,-27385 ,-27045 ,-26752 ,-26448 ,-26212 ,-25969 ,-25708 ,-25399 , -25088 ,-24741 ,-24350 ,-23909 ,-23183 ,-21613 ,-18318 ,-13324 ,-7673 ,-3245 ,-899 ,-597 ,-1674 ,-2942 ,-3646 , -3450 ,-2450 ,-856 ,782 ,2283 ,3475 ,4386 ,5125 ,5819 ,3574 ,3965 ,4372 ,4833 ,5225 ,5544 , 5781 ,6044 ,6328 ,6687 ,7008 ,7296 ,7478 ,7640 ,7736 ,7814 ,7888 ,7968 ,8065 ,8152 ,8258 , 8348 ,8497 ,8688 ,8984 ,9304 ,9688 ,9984 ,10261 ,10491 ,10707 ,10908 ,11076 ,11193 ,11206 ,11168 , 11051 ,10908 ,10753 ,10675 ,10633 ,10680 ,10712 ,10776 ,10871 ,11020 ,11187 ,11357 ,11545 ,11760 ,12013 , 12265 ,12513 ,12733 ,12999 ,13266 ,13605 ,13915 ,14188 ,14328 ,14388 ,14393 ,14423 ,14523 ,14722 ,14992 , 15302 ,15618 ,15892 ,16143 ,16302 ,16436 ,16503 ,16572 ,16636 ,16749 ,16872 ,17029 ,17227 ,17510 ,17788 , 18004 ,18110 ,18094 ,17956 ,17723 ,17437 ,17134 ,16860 ,16487 ,15856 ,14796 ,13362 ,11695 ,10049 ,8583 , 7542 ,6938 ,6753 ,6902 ,7299 ,7741 ,8122 ,8342 ,8321 ,8165 ,7911 ,7636 ,7325 ,7003 ,6613 , 6156 ,5614 ,5005 ,4321 ,3597 ,2806 ,1980 ,1313 ,1370 ,3291 ,8172 ,15304 ,23063 ,29458 ,32624 , 32765 ,30608 ,27397 ,24380 ,22316 ,21356 ,21352 ,22000 ,22847 ,23616 ,24167 ,24481 ,24620 ,24709 ,24809 , 24982 ,25067 ,24819 ,23990 ,22529 ,20581 ,18505 ,16535 ,14957 ,13933 ,13431 ,13408 ,13776 ,14438 ,15249 , 16077 ,16764 ,17224 ,17408 ,17332 ,16848 ,15626 ,13474 ,10390 ,6574 ,2420 ,-1576 ,-5023 ,-7673 ,-9313 , -10014 ,-9968 ,-9365 ,-8460 ,-7470 ,-6735 ,-6482 ,-7101 ,-8733 ,-11273 ,-14497 ,-18138 ,-21753 ,-24965 ,-27482 , -29123 ,-29872 ,-30026 ,-29849 ,-29522 ,-29310 ,-29258 ,-29454 ,-29781 ,-30230 ,-30707 ,-31165 ,-31515 ,-31886 ,-32215 , -32506 ,-32705 ,-32765 ,-32523 ,-31537 ,-29305 ,-25491 ,-20941 ,-16777 ,-13934 ,-12863 ,-13366 ,-14602 ,-15991 ,-16941 , -17143 ,-16713 ,-15842 ,-14807 ,-13823 ,-13010 ,-12311 ,-11711 ,-11137 ,-10607 ,-10085 ,-9661 ,-9236 ,-8881 ,-8488 , -8080 ,-7602 ,-7038 ,-6377 ,-5641 ,-4884 ,-4144 ,-3490 ,-2899 ,-2409 ,-1972 ,-1617 ,-1289 ,-1030 ,-766 , -521 ,-237 ,34 ,334 ,710 ,1190 ,1754 ,2305 ,2806 ,3210 ,1192 ,2636 ,4025 ,5305 ,5656 , 1662 ,2788 ,3509 ,403 ,344 ,1207 ,2137 ,3072 ,4015 ,4938 ,5860 ,6779 ,7684 ,8570 ,9454 , 10269 ,9867 ,5895 ,6607 ,7034 ,3489 ,6501 ,22335 ,28522 ,28841 ,29566 ,30177 ,30703 ,31147 ,31522 , 31853 ,32145 ,32402 ,32599 ,32765 ,32471 ,31119 ,31256 ,31116 ,29636 ,29209 ,29252 ,29308 ,29362 ,29405 , 29446 ,29472 ,29488 ,29501 ,29495 ,29447 ,27845 ,15695 ,9793 ,9944 ,9298 ,5349 ,4938 ,4972 ,5177 , 5447 ,5765 ,6119 ,6508 ,6928 ,7369 ,7850 ,8316 ,8734 ,6919 ,3573 ,4301 ,4122 ,73 ,434 , 828 ,1326 ,1873 ,3217 ,12822 ,20467 ,20516 ,21116 ,21598 ,22029 ,22393 ,21720 ,19986 ,20452 ,20379 , 17711 ,18005 ,18225 ,18481 ,18724 ,18960 ,19186 ,19397 ,19598 ,19796 ,19972 ,20137 ,20251 ,18919 ,16877 , 17120 ,16818 ,13647 ,9472 ,-2955 ,-5757 ,-5563 ,-5425 ,-5214 ,-4941 ,-4616 ,-4228 ,-3804 ,-3338 ,-3001 , -5583 ,-8139 ,-7450 ,-7648 ,-11657 ,-11163 ,-10698 ,-10127 ,-9526 ,-8875 ,-8198 ,-7503 ,-6776 ,-6053 ,-5277 , -3968 ,9067 ,11980 ,11019 ,11728 ,11651 ,9354 ,9769 ,10334 ,10886 ,11418 ,11938 ,12417 ,12879 ,13319 , 13741 ,14136 ,14509 ,14586 ,12563 ,11323 ,11590 ,10748 ,8197 ,8246 ,8568 ,8899 ,9233 ,9573 ,9798 , 5870 ,-7676 ,-8732 ,-8656 ,-8377 ,-8661 ,-12216 ,-13239 ,-13011 ,-14455 ,-16940 ,-16907 ,-20954 ,-31275 ,-31006 , -31464 ,-31747 ,-31941 ,-32078 ,-32151 ,-32149 ,-32083 ,-32040 ,-32640 ,-32765 ,-32646 ,-32724 ,-32530 ,-25937 ,-23306 , -22300 ,-21263 ,-20208 ,-19148 ,-18066 ,-16979 ,-15895 ,-14812 ,-13746 ,-13219 ,-16759 ,-16222 ,-15498 ,-16867 ,-18119 , -17462 ,-16630 ,-15758 ,-14869 ,-13952 ,-13013 ,-12049 ,-11083 ,-10100 ,-9118 ,-8151 ,-7836 ,-16499 ,-24701 ,-24180 , -24735 ,-25344 ,-25274 ,-25128 ,-24916 ,-24637 ,-24316 ,-23922 ,-23475 ,-22978 ,-22435 ,-21834 ,-21203 ,-20719 ,-22430 , -22328 ,-21821 ,-22305 ,-22915 ,-22408 ,-21893 ,-21322 ,-20703 ,-19943 ,-16161 ,-2306 ,2810 ,4099 ,4607 ,4277 , 3437 ,2587 ,1828 ,1384 ,1560 ,2838 ,4876 ,7226 ,9761 ,12123 ,13971 ,15580 ,16851 ,17877 ,19187 , 20768 ,22599 ,24966 ,27444 ,29692 ,31450 ,32376 ,32188 ,31244 ,29591 ,27707 ,25939 ,24286 ,23015 ,22237 , 21619 ,20940 ,19975 ,18597 ,16616 ,14176 ,11679 ,9461 ,7741 ,6480 ,5928 ,6091 ,6400 ,6518 ,6341 , 5741 ,4675 ,3219 ,1642 ,234 ,-578 ,-558 ,-24 ,831 ,1799 ,2462 ,2637 ,2296 ,1368 ,269 , -557 ,-1799 ,-3311 ,-4345 ,-4769 ,-4801 ,-4736 ,-4962 ,-5416 ,-6253 ,-7674 ,-9394 ,-10833 ,-11826 ,-12322 , -11865 ,-10400 ,-8355 ,-5747 ,-2850 ,-233 ,1753 ,3446 ,5025 ,6176 ,7075 ,8189 ,9405 ,10621 ,11644 , 12223 ,11990 ,10389 ,7731 ,4291 ,248 ,-4389 ,-8910 ,-12897 ,-15433 ,-17779 ,-20410 ,-22742 ,-24745 ,-26739 , -28650 ,-30551 ,-31986 ,-32419 ,-31815 ,-30210 ,-27402 ,-23819 ,-19940 ,-16067 ,-12397 ,-9221 ,-7130 ,-5659 ,-4273 , -3078 ,-1951 ,-502 ,1152 ,2898 ,4298 ,4905 ,4655 ,3812 ,2684 ,1709 ,1210 ,1441 ,2685 ,4671 , 7114 ,9843 ,12389 ,14544 ,16368 ,17720 ,18933 ,20244 ,21620 ,23340 ,25607 ,28079 ,30344 ,31972 ,32765 , 32666 ,31743 ,30058 ,28032 ,26026 ,24222 ,22775 ,21798 ,21213 ,20547 ,19496 ,18164 ,16330 ,13966 ,11476 , 9078 ,7225 ,5961 ,5289 ,5277 ,5574 ,5801 ,5898 ,5553 ,4607 ,3351 ,1938 ,646 ,-32 ,12 , 600 ,1483 ,2471 ,3384 ,3907 ,3635 ,2619 ,1522 ,487 ,-817 ,-2294 ,-3607 ,-4391 ,-4689 ,-4823 , -5129 ,-5606 ,-6427 ,-7703 ,-9180 ,-10521 ,-11515 ,-11970 ,-11450 ,-9946 ,-7690 ,-4756 ,-1595 ,1068 ,3276 , 5425 ,7033 ,7896 ,8637 ,9500 ,10383 ,11225 ,11827 ,11944 ,11262 ,9447 ,6612 ,2941 ,-1629 ,-6657 , -11408 ,-14929 ,-17697 ,-20869 ,-23567 ,-25515 ,-27315 ,-28794 ,-30305 ,-31764 ,-32715 ,-32765 ,-31881 ,-30110 ,-27252 , -23513 ,-19281 ,-14946 ,-10973 ,-7916 ,-5796 ,-4102 ,-2861 ,-2039 ,-1221 ,-97 ,1262 ,1780 ,13227 ,20300 , 23754 ,26160 ,28706 ,31317 ,32765 ,32480 ,29664 ,23474 ,15316 ,10061 ,9616 ,9960 ,9183 ,7619 ,6676 , 7309 ,10180 ,15134 ,18518 ,18072 ,18149 ,18804 ,19033 ,19069 ,19227 ,19826 ,21186 ,22854 ,22234 ,20258 , 20469 ,21781 ,22589 ,23244 ,23997 ,24834 ,26038 ,26695 ,23695 ,18225 ,15595 ,14445 ,13195 ,12100 ,10980 , 9803 ,9930 ,13726 ,19320 ,21751 ,21741 ,21362 ,20492 ,19431 ,18307 ,17333 ,15472 ,10716 ,2008 ,-6706 , -10857 ,-13350 ,-15121 ,-16557 ,-18510 ,-20998 ,-22725 ,-21898 ,-17348 ,-12591 ,-10985 ,-11667 ,-13665 ,-15626 ,-16275 , -15251 ,-14865 ,-18721 ,-25689 ,-30582 ,-31964 ,-32484 ,-32695 ,-32726 ,-32765 ,-32240 ,-31017 ,-30826 ,-31506 ,-30055 , -28535 ,-28138 ,-28032 ,-27420 ,-26150 ,-24037 ,-21250 ,-20692 ,-21590 ,-20532 ,-18425 ,-17405 ,-16779 ,-15789 ,-13611 , -9233 ,-3910 ,-2237 ,-5361 ,-8799 ,-9953 ,-9733 ,-9103 ,-9719 ,-13014 ,-18430 ,-23324 ,-25447 ,-25284 ,-23591 , -22171 ,-21512 ,-19977 ,-16281 ,-9355 ,1283 ,12740 ,19942 ,23614 ,25879 ,28434 ,31054 ,32591 ,32407 ,29674 , 23648 ,15548 ,10111 ,9556 ,10005 ,9275 ,7738 ,6755 ,7281 ,10019 ,14884 ,18341 ,18086 ,18045 ,18766 , 19002 ,19032 ,19166 ,19725 ,21034 ,22749 ,22243 ,20177 ,20322 ,21695 ,22489 ,23120 ,23853 ,24763 ,25950 , 26634 ,23826 ,18356 ,15629 ,14455 ,13201 ,12075 ,10956 ,9765 ,9817 ,13496 ,19004 ,21648 ,21673 ,21279 , 20436 ,19396 ,18283 ,17289 ,15469 ,10915 ,2369 ,-6536 ,-10829 ,-13289 ,-15101 ,-16536 ,-18452 ,-20910 ,-22628 , -22011 ,-17525 ,-12692 ,-10946 ,-11537 ,-13416 ,-15382 ,-16129 ,-15287 ,-14804 ,-18459 ,-25346 ,-30471 ,-31881 ,-32424 , -32660 ,-32693 ,-32681 ,-32228 ,-31026 ,-30699 ,-31397 ,-30084 ,-28470 ,-28029 ,-27951 ,-27397 ,-26162 ,-24086 ,-21296 , -20596 ,-21547 ,-20544 ,-18492 ,-17455 ,-16833 ,-15846 ,-13773 ,-9439 ,-4073 ,-2203 ,-5139 ,-8579 ,-9793 ,-9604 , -8916 ,-9489 ,-12702 ,-18072 ,-23036 ,-25334 ,-25250 ,-23672 ,-22224 ,-21605 ,-20134 ,-16562 ,-9851 ,-180 ,8843 , 7202 ,-1296 ,-7299 ,-6504 ,-1732 ,6326 ,17414 ,26806 ,27822 ,21076 ,11971 ,5774 ,5655 ,11007 ,20243 , 28596 ,32601 ,31268 ,26334 ,19893 ,11985 ,4526 ,425 ,2814 ,8445 ,12722 ,16247 ,21150 ,25858 ,26210 , 22224 ,17205 ,11911 ,6082 ,1198 ,-1221 ,-746 ,924 ,5678 ,13231 ,20678 ,26057 ,29576 ,29872 ,25388 , 17974 ,11444 ,4102 ,-5091 ,-11639 ,-12039 ,-8139 ,-3438 ,1073 ,5991 ,8176 ,6592 ,2308 ,-3156 ,-10337 , -18750 ,-21231 ,-16737 ,-9134 ,-3340 ,2313 ,10299 ,16625 ,15857 ,8459 ,927 ,-3864 ,-7512 ,-9503 ,-7443 , -1752 ,5197 ,10387 ,14304 ,14113 ,8265 ,-1946 ,-10641 ,-16777 ,-23599 ,-29516 ,-29430 ,-24000 ,-17561 ,-12526 , -8361 ,-5977 ,-7200 ,-10549 ,-15216 ,-20778 ,-26293 ,-29959 ,-30899 ,-29691 ,-25935 ,-19050 ,-12496 ,-8306 ,-5516 , -2934 ,-2769 ,-7206 ,-14324 ,-20950 ,-26710 ,-30815 ,-32646 ,-30766 ,-25317 ,-17978 ,-10473 ,-5127 ,-3657 ,-7323 , -14433 ,-22400 ,-27434 ,-26982 ,-21594 ,-10988 ,1860 ,9163 ,5865 ,-2738 ,-7832 ,-5998 ,-522 ,8294 ,19498 , 27740 ,27046 ,19429 ,10528 ,5378 ,6364 ,12411 ,21561 ,29457 ,32765 ,30794 ,25700 ,18953 ,10925 ,3691 , 432 ,3676 ,9070 ,13076 ,16764 ,22039 ,26282 ,25896 ,21569 ,16708 ,11260 ,5464 ,811 ,-1151 ,-578 , 1375 ,6645 ,14337 ,21528 ,26714 ,29909 ,29619 ,24505 ,17076 ,10663 ,2848 ,-6484 ,-12158 ,-11719 ,-7620 , -3022 ,1717 ,6551 ,8099 ,6159 ,1678 ,-3855 ,-11570 ,-19657 ,-20921 ,-15669 ,-8191 ,-2823 ,3340 ,11658 , 17181 ,15139 ,7376 ,235 ,-4202 ,-8021 ,-9538 ,-6892 ,-782 ,5953 ,11065 ,14640 ,13618 ,6920 ,-3541 , -11510 ,-17704 ,-24798 ,-30344 ,-29106 ,-23195 ,-16891 ,-12047 ,-7875 ,-5927 ,-7505 ,-11033 ,-15841 ,-21545 ,-26902 , -30293 ,-30952 ,-29532 ,-25298 ,-18085 ,-11856 ,-7996 ,-5203 ,-2593 ,-2974 ,-8091 ,-15339 ,-21844 ,-27529 ,-31320 , -32765 ,-30244 ,-24522 ,-16941 ,-9556 ,-4607 ,-3732 ,-8073 ,-15580 ,-23430 ,-27798 ,-26687 ,-20521 ,-9145 ,591 , 3451 ,6242 ,9151 ,11965 ,14864 ,17747 ,20681 ,23110 ,25471 ,27395 ,28957 ,30126 ,31139 ,31843 ,32341 , 32597 ,32765 ,32686 ,32363 ,31845 ,31287 ,30591 ,29484 ,28170 ,26378 ,24354 ,22011 ,19591 ,16665 ,13932 , 11054 ,8338 ,6709 ,5443 ,2894 ,-170 ,-3016 ,-5609 ,-8237 ,-10777 ,-13352 ,-15583 ,-17574 ,-19349 ,-21035 , -22556 ,-23713 ,-24777 ,-25622 ,-26429 ,-26997 ,-27508 ,-27757 ,-27691 ,-27370 ,-26730 ,-25815 ,-24560 ,-23410 ,-22010 , -20315 ,-18350 ,-16624 ,-14709 ,-12995 ,-11143 ,-9287 ,-7076 ,-4987 ,-2741 ,-918 ,1152 ,3149 ,5222 ,6966 , 8876 ,10592 ,12204 ,13446 ,14550 ,15244 ,15815 ,16231 ,16700 ,17016 ,17342 ,17295 ,17015 ,16630 ,16138 , 15790 ,15180 ,14432 ,13304 ,12266 ,10906 ,9277 ,7368 ,5653 ,4035 ,2842 ,1860 ,1060 ,106 ,-658 , -1538 ,-2069 ,-2709 ,-3361 ,-4126 ,-4926 ,-5742 ,-6483 ,-6988 ,-7508 ,-7775 ,-7480 ,-6926 ,-6189 ,-5335 , -4448 ,-3534 ,-2454 ,-1537 ,-535 ,192 ,691 ,1529 ,2394 ,3335 ,4053 ,4796 ,5382 ,6112 ,6892 , 7567 ,8098 ,8334 ,8500 ,8657 ,8355 ,8027 ,7340 ,6915 ,5990 ,5329 ,4560 ,3723 ,2657 ,1646 , 664 ,-330 ,-1317 ,-2471 ,-3936 ,-5494 ,-7409 ,-8773 ,-10183 ,-11399 ,-12831 ,-13928 ,-14979 ,-16062 ,-16960 , -17520 ,-17914 ,-18042 ,-17830 ,-17491 ,-17116 ,-16686 ,-16230 ,-15610 ,-14669 ,-13675 ,-12387 ,-11245 ,-9618 ,-7997 , -6044 ,-4337 ,-2211 ,65 ,2439 ,4628 ,6969 ,9024 ,10966 ,12698 ,14623 ,16238 ,18079 ,19482 ,21038 , 22616 ,24226 ,25440 ,26401 ,27144 ,27610 ,27889 ,27753 ,27417 ,26798 ,26108 ,25092 ,23903 ,22497 ,21122 , 19394 ,17758 ,15706 ,13737 ,11351 ,9124 ,6600 ,3951 ,586 ,-1848 ,-3306 ,-4705 ,-7977 ,-11039 ,-14058 , -16650 ,-19405 ,-21606 ,-23723 ,-25465 ,-27101 ,-28284 ,-29273 ,-30101 ,-31010 ,-31776 ,-32207 ,-32548 ,-32706 ,-32765 , -32373 ,-31737 ,-30663 ,-29396 ,-27503 ,-25407 ,-22941 ,-20577 ,-17945 ,-15429 ,-12619 ,-10210 ,-7493 ,-4995 ,-2166 , -1130 ,12172 ,19582 ,15951 ,4121 ,-1356 ,-1032 ,-1521 ,-127 ,6657 ,18104 ,26921 ,31666 ,32657 ,30794 , 26482 ,19868 ,11742 ,6763 ,10801 ,20390 ,22314 ,16806 ,14568 ,16921 ,14387 ,5491 ,-1276 ,-4975 ,-6794 , -7866 ,-7342 ,-2820 ,7299 ,18349 ,22396 ,21748 ,22545 ,20484 ,11302 ,279 ,-706 ,7477 ,14218 ,17354 , 17537 ,16818 ,14567 ,9847 ,2024 ,-6665 ,-12673 ,-16872 ,-20764 ,-23008 ,-15182 ,-43 ,7303 ,6639 ,1561 , -6902 ,-15894 ,-22357 ,-22675 ,-16705 ,-6241 ,3419 ,7412 ,8577 ,13034 ,20809 ,17671 ,7639 ,3473 ,730 , -2593 ,-4862 ,-3478 ,1650 ,8795 ,14691 ,17838 ,18397 ,16722 ,10574 ,-4534 ,-24596 ,-32397 ,-30392 ,-29572 , -26663 ,-21304 ,-13569 ,-7212 ,-4653 ,-6437 ,-10471 ,-15366 ,-20513 ,-25641 ,-28807 ,-21952 ,-7792 ,-1392 ,-368 , 476 ,-319 ,-3834 ,-9124 ,-15619 ,-23415 ,-29706 ,-32087 ,-30978 ,-26868 ,-18114 ,-7075 ,-6043 ,-10875 ,-11092 , -12524 ,-18115 ,-25565 ,-30856 ,-32140 ,-29170 ,-22532 ,-12364 ,653 ,13366 ,19427 ,14374 ,2617 ,-1368 ,-1126 , -1578 ,447 ,8158 ,19629 ,27902 ,32161 ,32765 ,30520 ,25822 ,18846 ,10827 ,6869 ,12226 ,21573 ,22310 , 16810 ,15217 ,17248 ,13532 ,4415 ,-2016 ,-5399 ,-7083 ,-8024 ,-7030 ,-1729 ,8992 ,19452 ,22504 ,21861 , 22729 ,19828 ,9733 ,-538 ,189 ,8687 ,15287 ,17974 ,17928 ,16957 ,14267 ,8990 ,660 ,-7948 ,-13773 , -18002 ,-21895 ,-22925 ,-12286 ,2355 ,7485 ,6185 ,76 ,-8776 ,-17643 ,-23253 ,-22279 ,-14909 ,-4068 ,4706 , 7520 ,8863 ,14731 ,21793 ,15689 ,6496 ,3313 ,162 ,-3280 ,-5223 ,-3094 ,2742 ,10126 ,15670 ,18371 , 18460 ,16214 ,8448 ,-9031 ,-28564 ,-32600 ,-30803 ,-29957 ,-26539 ,-20447 ,-12559 ,-6540 ,-4784 ,-7056 ,-11346 , -16519 ,-21802 ,-27082 ,-29238 ,-19602 ,-5626 ,-1385 ,-376 ,218 ,-1017 ,-4996 ,-10270 ,-17249 ,-25204 ,-31036 , -32765 ,-31054 ,-26071 ,-16025 ,-5491 ,-7001 ,-11293 ,-10929 ,-13340 ,-19708 ,-27373 ,-31928 ,-32469 ,-28733 ,-21259 , -10126 ,5675 ,7865 ,8250 ,17528 ,27041 ,30809 ,27726 ,26742 ,28266 ,22369 ,5882 ,-1625 ,-1205 ,-869 , 1734 ,5223 ,14705 ,25812 ,24898 ,20510 ,27281 ,32164 ,32230 ,32335 ,30323 ,25942 ,17394 ,2329 ,-4551 , -3592 ,-5601 ,-1876 ,7296 ,15939 ,18213 ,16727 ,12667 ,16593 ,15539 ,6071 ,2743 ,1680 ,2124 ,-3596 , -10270 ,-11187 ,-11753 ,-13908 ,-13929 ,-12950 ,-9547 ,-2954 ,1671 ,1891 ,3130 ,-3125 ,-10858 ,-10792 ,-17919 , -23952 ,-23553 ,-19054 ,-13997 ,-12493 ,-10333 ,2060 ,16566 ,20262 ,20765 ,20409 ,20328 ,16440 ,3435 ,-5630 , -1511 ,-6003 ,-14345 ,-20631 ,-24595 ,-21655 ,-17970 ,-13933 ,219 ,16404 ,17744 ,17675 ,14033 ,7415 ,1871 , -5353 ,-10177 ,-6750 ,-8847 ,-19031 ,-19910 ,-20041 ,-21942 ,-20305 ,-14684 ,-3416 ,6051 ,5983 ,6182 ,5222 , 1569 ,-9121 ,-22036 ,-28784 ,-29205 ,-30544 ,-32442 ,-24293 ,-17841 ,-12578 ,-6913 ,-4889 ,-2469 ,-2756 ,-3451 , -863 ,-3343 ,-11200 ,-15859 ,-15851 ,-17414 ,-19417 ,-18094 ,-10354 ,5479 ,7942 ,8424 ,17621 ,27177 ,31581 , 27949 ,26952 ,28480 ,23036 ,6605 ,-1681 ,-1415 ,-729 ,1657 ,5203 ,14582 ,26087 ,25546 ,20597 ,27449 , 32765 ,32575 ,32743 ,30703 ,26347 ,17791 ,2563 ,-4353 ,-3666 ,-5784 ,-1907 ,7144 ,16186 ,18367 ,17116 , 13054 ,16277 ,15720 ,6414 ,2605 ,1699 ,2304 ,-3577 ,-10408 ,-11326 ,-11607 ,-14197 ,-13989 ,-13163 ,-9575 , -3005 ,1694 ,2051 ,3185 ,-3199 ,-11012 ,-10744 ,-18420 ,-24230 ,-24033 ,-19396 ,-14281 ,-12580 ,-10610 ,1699 , 16423 ,20456 ,21051 ,20580 ,20597 ,16754 ,3751 ,-5908 ,-1812 ,-5655 ,-14541 ,-20744 ,-24838 ,-21972 ,-18148 , -14307 ,-190 ,16629 ,17533 ,17928 ,14106 ,7535 ,2013 ,-5225 ,-10086 ,-6699 ,-8975 ,-18833 ,-20019 ,-20338 , -21994 ,-20554 ,-14932 ,-3666 ,6225 ,6047 ,6088 ,5433 ,1627 ,-8887 ,-21974 ,-28818 ,-29312 ,-30687 ,-32765 , -24217 ,-18209 ,-12926 ,-6878 ,-5044 ,-2429 ,-2715 ,-3349 ,-917 ,-3283 ,-11246 ,-15941 ,-15794 ,-17515 ,-19418 , -18134 ,-10618 ,1076 ,9846 ,13358 ,11807 ,11524 ,11278 ,11246 ,11140 ,11843 ,13366 ,14667 ,17102 ,21059 , 22537 ,25984 ,29846 ,31568 ,32675 ,32765 ,31827 ,29760 ,27831 ,23582 ,13267 ,181 ,-5193 ,-6137 ,-7996 , -9941 ,-10485 ,-9374 ,-8046 ,-5572 ,-2297 ,-929 ,-395 ,2055 ,2475 ,3483 ,4846 ,4258 ,3432 ,3087 , 3191 ,3419 ,6010 ,14689 ,22985 ,23973 ,23379 ,23696 ,26070 ,28034 ,27776 ,26948 ,26750 ,27307 ,30008 , 32561 ,31830 ,30417 ,25943 ,22591 ,23537 ,25522 ,26746 ,25979 ,23377 ,17430 ,8211 ,2510 ,2974 ,4005 , 4952 ,2813 ,299 ,-391 ,1320 ,2587 ,1586 ,-1742 ,-4394 ,-4079 ,-12 ,7532 ,10644 ,10463 ,7332 , 2134 ,-1671 ,-2432 ,404 ,4617 ,5225 ,4160 ,2186 ,1150 ,3546 ,6219 ,8667 ,7606 ,5251 ,4488 , 5822 ,6084 ,1885 ,-8067 ,-18695 ,-23298 ,-26902 ,-28664 ,-28187 ,-26343 ,-26506 ,-28989 ,-30941 ,-30756 ,-31067 , -29692 ,-29240 ,-31116 ,-31798 ,-32672 ,-32765 ,-31264 ,-30010 ,-30374 ,-29344 ,-23032 ,-9217 ,1184 ,6523 ,12133 , 16628 ,19720 ,21398 ,22604 ,23230 ,22349 ,21247 ,21114 ,17841 ,16646 ,17214 ,16596 ,16945 ,17820 ,18944 , 20240 ,22556 ,23069 ,17186 ,7056 ,3223 ,2908 ,914 ,-1455 ,-3051 ,-2944 ,-2890 ,-1931 ,-246 ,-601 , -1778 ,-692 ,-1371 ,-1091 ,-170 ,-1491 ,-3228 ,-5005 ,-6557 ,-7977 ,-7201 ,-380 ,6394 ,6295 ,4472 , 3251 ,4464 ,5380 ,4111 ,2253 ,1389 ,1556 ,4073 ,6773 ,6244 ,4333 ,-1057 ,-5691 ,-6464 ,-5625 , -5076 ,-6203 ,-8762 ,-14320 ,-22940 ,-28462 ,-27674 ,-26258 ,-25215 ,-27047 ,-29459 ,-29945 ,-27705 ,-25646 ,-25619 , -27892 ,-29648 ,-28403 ,-23447 ,-15015 ,-10358 ,-9101 ,-10362 ,-13355 ,-14816 ,-13135 ,-7949 ,-1808 ,155 ,6 , -1052 ,-1695 ,1429 ,5195 ,8879 ,9638 ,8789 ,9560 ,12407 ,14244 ,11819 ,3545 ,-6039 ,-9793 ,-13214 , -15690 ,-16422 ,-15953 ,-16979 ,-19774 ,-21299 ,-19751 ,-17816 ,-13373 ,-9488 ,-8299 ,-6206 ,-5053 ,-3764 ,-1606 , -156 ,-1090 ,-2062 ,442 ,5171 ,8389 ,10505 ,10692 ,7735 ,3601 ,993 ,529 ,2147 ,5767 ,8429 , 7927 ,5610 ,3211 ,1647 ,1169 ,1447 ,1652 ,2861 ,9096 ,21702 ,30314 ,31104 ,30547 ,29975 ,28559 , 26778 ,25488 ,25401 ,27193 ,30027 ,32367 ,32765 ,31109 ,26226 ,15670 ,4464 ,1609 ,4003 ,7677 ,11649 , 15784 ,20070 ,23493 ,24668 ,21622 ,13609 ,3650 ,-3414 ,-6211 ,-5400 ,-1689 ,3854 ,10215 ,16365 ,20635 , 19983 ,11837 ,695 ,-4994 ,-7698 ,-11670 ,-15826 ,-19684 ,-23328 ,-26470 ,-28263 ,-28583 ,-27560 ,-25404 ,-22944 , -19593 ,-11237 ,2585 ,10052 ,7704 ,2307 ,-4368 ,-11381 ,-17682 ,-22453 ,-24868 ,-23948 ,-19130 ,-12492 ,-7823 , -6347 ,-7412 ,-11416 ,-16857 ,-21692 ,-25495 ,-28115 ,-28252 ,-23958 ,-15207 ,-7917 ,-4621 ,-3284 ,-4358 ,-7781 , -10832 ,-12165 ,-11931 ,-10720 ,-9137 ,-7376 ,-5373 ,-3700 ,-5160 ,-14076 ,-25548 ,-26994 ,-22567 ,-17958 ,-13612 , -9759 ,-6699 ,-5236 ,-6212 ,-10348 ,-16412 ,-21727 ,-24237 ,-23685 ,-18468 ,-8694 ,406 ,5569 ,8675 ,10291 , 9924 ,6866 ,3027 ,937 ,1265 ,4173 ,9485 ,13744 ,14123 ,11359 ,7034 ,2497 ,-1527 ,-4528 ,-6203 , -5131 ,2399 ,17123 ,27839 ,30128 ,30426 ,31065 ,31515 ,31649 ,31483 ,31041 ,30630 ,30483 ,30158 ,29409 , 28611 ,25809 ,17459 ,7374 ,3683 ,4049 ,5234 ,6862 ,9502 ,12973 ,16303 ,18316 ,17397 ,12699 ,6783 , 3621 ,3917 ,6480 ,10253 ,13957 ,16578 ,17388 ,15864 ,10161 ,-1582 ,-14594 ,-20574 ,-20928 ,-20098 ,-17598 , -14389 ,-11971 ,-10894 ,-10903 ,-11792 ,-13567 ,-16426 ,-20684 ,-24321 ,-22079 ,-12576 ,-6107 ,-7148 ,-9687 ,-11660 , -12902 ,-13571 ,-13781 ,-13369 ,-11665 ,-7955 ,-3839 ,-2585 ,-4951 ,-9356 ,-15615 ,-22403 ,-27792 ,-31247 ,-32765 , -31138 ,-24639 ,-14031 ,-5769 ,-2852 ,-3215 ,-6225 ,-10783 ,-13455 ,-12763 ,-9565 ,-5946 ,-3201 ,-1844 ,-1347 , -1297 ,-4137 ,-13870 ,-25958 ,-29159 ,-27263 ,-25041 ,-21630 ,-16607 ,-10805 ,-5997 ,-3766 ,-5664 ,-10564 ,-15875 , -19429 ,-20261 ,-16467 ,-8001 ,2045 ,3017 ,3975 ,4903 ,5846 ,6906 ,7941 ,8547 ,8258 ,7765 ,10345 , 18543 ,28627 ,32765 ,31472 ,29634 ,28843 ,28877 ,28955 ,28839 ,28390 ,27703 ,26779 ,25746 ,24606 ,23274 , 21327 ,18176 ,13025 ,5872 ,196 ,1198 ,8684 ,16515 ,19925 ,20736 ,19773 ,17698 ,15847 ,15037 ,15471 , 17010 ,19491 ,22524 ,25864 ,29171 ,31729 ,32461 ,29964 ,23231 ,13868 ,7304 ,5975 ,6997 ,6493 ,4119 , 2008 ,1319 ,1375 ,848 ,-146 ,-732 ,22 ,2909 ,7460 ,13116 ,18978 ,23505 ,25121 ,22760 ,16952 , 10564 ,6433 ,5117 ,6433 ,10495 ,15484 ,18938 ,19547 ,17001 ,11752 ,5722 ,1591 ,1314 ,4623 ,9885 , 15706 ,20952 ,24493 ,26007 ,25710 ,24482 ,23833 ,24437 ,25779 ,26344 ,25409 ,24653 ,25047 ,24902 ,19978 , 10976 ,2386 ,-2401 ,-2868 ,-1205 ,1396 ,4238 ,6783 ,8700 ,9793 ,9798 ,8285 ,5227 ,1031 ,-3255 , -5844 ,-5202 ,-928 ,5524 ,8403 ,3032 ,-5728 ,-12913 ,-17544 ,-20520 ,-22686 ,-24414 ,-25870 ,-27107 ,-28180 , -29076 ,-29744 ,-30104 ,-30216 ,-30596 ,-31725 ,-32765 ,-30457 ,-22384 ,-12327 ,-8215 ,-9360 ,-10840 ,-11108 ,-10426 , -9524 ,-8792 ,-8253 ,-8007 ,-7975 ,-8072 ,-8302 ,-8838 ,-10105 ,-12692 ,-17387 ,-24270 ,-29769 ,-28597 ,-20898 , -13137 ,-10020 ,-9680 ,-11157 ,-13758 ,-16281 ,-17638 ,-17705 ,-16591 ,-14445 ,-11585 ,-8324 ,-4971 ,-2142 ,-1071 , -3145 ,-9355 ,-18070 ,-23853 ,-24267 ,-22352 ,-22003 ,-23557 ,-24942 ,-24919 ,-24251 ,-24242 ,-24812 ,-25047 ,-24014 , -20958 ,-16300 ,-10598 ,-4754 ,-331 ,1098 ,-1473 ,-7403 ,-13914 ,-17970 ,-19020 ,-17305 ,-12711 ,-6915 ,-2614 , -976 ,-2444 ,-6597 ,-11418 ,-14283 ,-13149 ,-8475 ,-2018 ,4995 ,11297 ,15742 ,17973 ,18249 ,17443 ,17058 , 17796 ,19181 ,19674 ,18488 ,17340 ,17368 ,16889 ,11701 ,2234 ,-6929 ,-12208 ,-13072 ,-11495 ,-8898 ,-5904 , -3013 ,-620 ,1039 ,1745 ,1198 ,-846 ,-3862 ,-6749 ,-7843 ,-5506 ,711 ,9456 ,15075 ,12279 ,6211 , 1774 ,-112 ,-313 ,180 ,1047 ,1862 ,3995 ,4030 ,3955 ,1630 ,1653 ,2482 ,2115 ,-38 ,-328 , 2752 ,1582 ,210 ,5647 ,8112 ,8975 ,9199 ,10768 ,13296 ,15087 ,16244 ,16866 ,13643 ,2304 ,-15027 , -20777 ,-18090 ,-17700 ,-20636 ,-24249 ,-24765 ,-24920 ,-24823 ,-25302 ,-23365 ,-16940 ,-3322 ,11155 ,5736 ,-3967 , -6666 ,-3282 ,2715 ,5339 ,3951 ,2199 ,1623 ,-2950 ,-13021 ,-13449 ,5316 ,15365 ,16658 ,19106 ,22998 , 23138 ,18778 ,14876 ,15825 ,23479 ,30781 ,28592 ,10219 ,-6789 ,-8745 ,-6631 ,-5847 ,-8049 ,-6228 ,497 , 8092 ,8520 ,3224 ,2492 ,16784 ,29560 ,26608 ,28292 ,30252 ,27867 ,24070 ,21953 ,23304 ,24453 ,22104 , 17664 ,16783 ,21959 ,24636 ,24760 ,29783 ,31120 ,30149 ,28243 ,24952 ,21696 ,19175 ,20095 ,24175 ,26021 , 15127 ,8624 ,10918 ,4586 ,4073 ,7939 ,13274 ,14547 ,11824 ,11659 ,15505 ,18936 ,10479 ,-25 ,5962 , 8051 ,1954 ,2289 ,2811 ,4063 ,3075 ,2282 ,2747 ,2768 ,1636 ,6114 ,23464 ,31491 ,26803 ,29618 , 29654 ,30029 ,29492 ,31631 ,32765 ,31895 ,28496 ,25862 ,29252 ,23188 ,10139 ,15625 ,19898 ,18561 ,14575 , 13774 ,17604 ,20114 ,18802 ,16075 ,18265 ,19610 ,6611 ,9 ,2280 ,58 ,-1816 ,-3658 ,-3106 ,-3372 , -3437 ,-4429 ,-5466 ,-9912 ,-12893 ,-1436 ,5701 ,4202 ,2705 ,2594 ,280 ,-7245 ,-15178 ,-18871 ,-15806 , -9016 ,-6174 ,-4216 ,3610 ,-2956 ,-9970 ,-9575 ,-4167 ,2781 ,6770 ,8252 ,8310 ,7252 ,1737 ,-6653 , -15882 ,-14319 ,-7341 ,-4401 ,-3002 ,-6307 ,-8292 ,-8714 ,-6673 ,-5059 ,-3883 ,-378 ,5143 ,-2150 ,-14908 , -13207 ,-11798 ,-14926 ,-20908 ,-23773 ,-22171 ,-20554 ,-23591 ,-28457 ,-26578 ,-9470 ,7941 ,7277 ,3463 ,471 , 2195 ,6218 ,8488 ,7387 ,4373 ,4027 ,2251 ,-8624 ,-25845 ,-30950 ,-28037 ,-28888 ,-27401 ,-26775 ,-25244 , -25645 ,-27253 ,-27026 ,-23413 ,-18488 ,-18698 ,-25239 ,-28029 ,-29615 ,-31897 ,-31370 ,-31678 ,-31946 ,-32765 ,-31900 , -31093 ,-31655 ,-29605 ,-20294 ,-7104 ,-316 ,1888 ,11636 ,13436 ,10761 ,7870 ,10329 ,17140 ,23568 ,27995 , 29982 ,30063 ,29140 ,28446 ,29388 ,32077 ,32765 ,30707 ,29043 ,26227 ,20184 ,14984 ,16433 ,21790 ,23564 , 16247 ,1666 ,-10786 ,-12820 ,-6999 ,-1257 ,-3218 ,-10482 ,-17272 ,-22180 ,-22124 ,-19541 ,-21742 ,-27366 ,-31907 , -32057 ,-30633 ,-31631 ,-32765 ,-28931 ,-22470 ,-18587 ,-18815 ,-23081 ,-27343 ,-25952 ,-19371 ,-12469 ,-6544 ,-3597 , -2146 ,1969 ,8133 ,9699 ,2496 ,-2868 ,1984 ,15794 ,25548 ,23662 ,19367 ,16685 ,18912 ,24672 ,29871 , 31568 ,29607 ,22992 ,16164 ,13879 ,16296 ,22040 ,25890 ,26511 ,22994 ,13365 ,1529 ,-4409 ,-3173 ,1271 , 5747 ,6527 ,519 ,-10218 ,-15005 ,-11175 ,-4592 ,-6235 ,-17826 ,-25750 ,-23645 ,-17347 ,-14792 ,-18659 ,-21224 , -17412 ,-14079 ,-14687 ,-15267 ,-13857 ,-11765 ,-11749 ,-11957 ,-8842 ,-2871 ,1362 ,3058 ,2422 ,663 ,-148 , -327 ,178 ,2568 ,7927 ,11084 ,8582 ,2795 ,-530 ,1668 ,8155 ,11301 ,4647 ,-3998 ,-5688 ,1585 , 6331 ,4003 ,-1250 ,-6423 ,-8486 ,-6729 ,-3278 ,-735 ,-325 ,-1031 ,142 ,5034 ,10518 ,11625 ,9912 , 9134 ,10836 ,11714 ,9632 ,8955 ,14350 ,21721 ,26287 ,24852 ,16597 ,8621 ,10054 ,17319 ,20222 ,8343 , -6355 ,-10829 ,-5919 ,1931 ,5608 ,1510 ,-7617 ,-18598 ,-26805 ,-29677 ,-30504 ,-31493 ,-30372 ,-28530 ,-28626 , -30697 ,-31385 ,-25587 ,-14703 ,-7298 ,-8281 ,-16288 ,-24164 ,-25056 ,-17193 ,-719 ,13999 ,13795 ,7248 ,8212 , 16449 ,23011 ,22117 ,19399 ,15909 ,13068 ,12726 ,14312 ,15759 ,19798 ,24681 ,25282 ,21024 ,12710 ,4212 , 1671 ,2115 ,690 ,-2817 ,-5328 ,-4908 ,-3504 ,-1335 ,3295 ,7466 ,5196 ,-1868 ,-4224 ,-1615 ,664 , -1159 ,-4477 ,-2243 ,4883 ,12706 ,15311 ,9873 ,2231 ,-1842 ,-1412 ,290 ,1171 ,83 ,-1609 ,-5550 , -10081 ,-11178 ,-8210 ,-6558 ,-9493 ,-16054 ,-21811 ,-25141 ,-27705 ,-29654 ,-28238 ,-21116 ,-15608 ,-18633 ,-25669 , -27057 ,-21227 ,-10893 ,-5021 ,-7966 ,-12521 ,-10153 ,1751 ,6761 ,11163 ,14157 ,15426 ,15289 ,14672 ,14296 , 14856 ,16846 ,20085 ,24268 ,28591 ,31605 ,32765 ,31899 ,28991 ,24550 ,19261 ,14523 ,11202 ,9604 ,9715 , 10790 ,11889 ,12352 ,11520 ,9191 ,5744 ,2019 ,-896 ,-2395 ,-2136 ,95 ,4116 ,8788 ,13513 ,17257 , 18764 ,18345 ,16553 ,14046 ,11809 ,10502 ,10498 ,11604 ,13478 ,15312 ,16164 ,15056 ,11611 ,6749 ,1644 , -3020 ,-8239 ,-13548 ,-17215 ,-18625 ,-18037 ,-16365 ,-14769 ,-13906 ,-14069 ,-15698 ,-18287 ,-21046 ,-23320 ,-23782 , -22029 ,-18399 ,-13420 ,-8112 ,-3789 ,-1023 ,-198 ,-1373 ,-3932 ,-7376 ,-10570 ,-12426 ,-12658 ,-11664 ,-10084 , -8586 ,-8198 ,-9655 ,-12992 ,-17664 ,-22956 ,-27970 ,-31398 ,-32765 ,-31662 ,-28520 ,-24238 ,-20070 ,-16843 ,-15035 , -14538 ,-15021 ,-15769 ,-15820 ,-14482 ,-11531 ,-7379 ,-2875 ,1861 ,6125 ,9084 ,10462 ,10200 ,8329 ,5723 , 3201 ,1281 ,637 ,1235 ,2396 ,3826 ,4230 ,3039 ,603 ,-2456 ,-5460 ,-7505 ,-7822 ,-6392 ,-3197 , 1037 ,5459 ,9512 ,12531 ,14207 ,14595 ,14350 ,14137 ,14631 ,16195 ,18832 ,22165 ,25641 ,28624 ,30022 , 29694 ,27538 ,23895 ,19522 ,15325 ,12075 ,10136 ,9596 ,10080 ,10974 ,11362 ,10762 ,9050 ,6398 ,3255 , 583 ,-1114 ,-1209 ,418 ,3511 ,7488 ,11573 ,14923 ,16771 ,16960 ,15811 ,13886 ,11828 ,10532 ,10216 , 10851 ,12258 ,13791 ,14608 ,13973 ,11314 ,7348 ,2891 ,-1863 ,-6316 ,-10953 ,-14776 ,-16677 ,-16670 ,-15671 , -14343 ,-13399 ,-13429 ,-14507 ,-16526 ,-19007 ,-21067 ,-21746 ,-20611 ,-17787 ,-13758 ,-9011 ,-4816 ,-1808 ,-400 , -1102 ,-3167 ,-5876 ,-8688 ,-10727 ,-11388 ,-10830 ,-9614 ,-8343 ,-7848 ,-8832 ,-11381 ,-15419 ,-20158 ,-24824 , -28570 ,-30310 ,-29740 ,-27493 ,-23979 ,-20067 ,-16768 ,-14609 ,-13758 ,-13905 ,-14396 ,-14510 ,-13513 ,-11002 ,-6831 , -1472 ,4062 ,8681 ,11582 ,12347 ,11200 ,8735 ,5553 ,2575 ,528 ,7 ,1285 ,3595 ,5255 ,5150 , 3331 ,77 ,-3687 ,-6993 ,-9105 ,-8964 ,-6702 ,-2744 ,5776 ,15999 ,20758 ,23080 ,23898 ,24299 ,24542 , 25038 ,25205 ,23288 ,18225 ,13508 ,14078 ,20368 ,24379 ,17742 ,6686 ,-2514 ,-9591 ,-13865 ,-13566 ,-8294 , -350 ,6744 ,11598 ,15176 ,20417 ,25317 ,23845 ,15459 ,11141 ,16143 ,23770 ,28379 ,29543 ,29755 ,28855 , 26623 ,22578 ,17237 ,11380 ,5962 ,1576 ,981 ,9667 ,25005 ,32765 ,29879 ,22610 ,15932 ,12295 ,9938 , 8751 ,8303 ,8558 ,9031 ,10110 ,12860 ,17590 ,19803 ,16612 ,8751 ,244 ,1713 ,5089 ,7536 ,12485 , 19897 ,27079 ,31741 ,32598 ,29497 ,24307 ,18531 ,11940 ,4594 ,2922 ,5546 ,4387 ,3624 ,1878 ,-1077 , -1818 ,-2166 ,-2127 ,-2090 ,-1763 ,-1119 ,666 ,4433 ,9430 ,13064 ,18599 ,25115 ,27121 ,28928 ,25222 , 16491 ,8580 ,2314 ,-609 ,-601 ,1720 ,5136 ,9297 ,14379 ,19531 ,22050 ,22557 ,21327 ,18561 ,21743 , 25023 ,25145 ,25713 ,26645 ,27831 ,28940 ,29612 ,29027 ,26317 ,20161 ,9738 ,-2441 ,-6671 ,-490 ,4649 , 8256 ,9580 ,10209 ,11457 ,11482 ,10867 ,9844 ,9129 ,8634 ,8967 ,11796 ,17299 ,21272 ,19265 ,10985 , 5037 ,6397 ,7192 ,3078 ,-2631 ,-5851 ,-4801 ,836 ,8258 ,14279 ,16870 ,14504 ,6797 ,-489 ,-11 , 7335 ,10082 ,5047 ,-1179 ,-4436 ,-5400 ,-6887 ,-9063 ,-12396 ,-17236 ,-23190 ,-28291 ,-29409 ,-22378 ,-11290 , -6091 ,-7608 ,-6613 ,-2488 ,851 ,1496 ,-508 ,-2159 ,-3265 ,-3769 ,-3934 ,-3945 ,-4844 ,-8253 ,-14538 , -19155 ,-20207 ,-18563 ,-18679 ,-27303 ,-32765 ,-31482 ,-26301 ,-18856 ,-12016 ,-7905 ,-7573 ,-10890 ,-15963 ,-20900 , -23258 ,-22888 ,-26597 ,-31640 ,-31807 ,-32059 ,-30093 ,-27831 ,-27341 ,-27210 ,-27306 ,-27176 ,-27023 ,-26353 ,-25422 , -24326 ,-21312 ,-14335 ,-8583 ,-3726 ,1079 ,-992 ,-4012 ,-8216 ,-14268 ,-18958 ,-20443 ,-18846 ,-15293 ,-10765 , -6901 ,-5219 ,-4700 ,-2692 ,-728 ,2878 ,6274 ,2782 ,822 ,1826 ,2445 ,3426 ,4558 ,6041 ,7037 , 7074 ,5244 ,1453 ,-1976 ,-3642 ,-8391 ,-15994 ,-14771 ,-6106 ,8526 ,9002 ,9222 ,10455 ,9530 ,4397 , -2999 ,-5180 ,-39 ,6064 ,8162 ,-1082 ,-10688 ,-5869 ,283 ,4936 ,7976 ,8945 ,6507 ,5237 ,8716 , 11144 ,11901 ,17578 ,22383 ,19427 ,7153 ,-5366 ,-10765 ,-4679 ,16423 ,27450 ,25287 ,20533 ,16051 ,16921 , 19616 ,22078 ,21975 ,19805 ,14922 ,3635 ,-7907 ,1563 ,17070 ,20254 ,16765 ,12643 ,15247 ,20812 ,26042 , 26617 ,26539 ,31878 ,32765 ,20614 ,12635 ,10691 ,10727 ,12066 ,12621 ,11462 ,9457 ,9374 ,10571 ,11387 , 11686 ,11942 ,14271 ,18063 ,20367 ,15908 ,4400 ,-1734 ,1810 ,1413 ,2672 ,6178 ,7450 ,7742 ,6724 , 2710 ,4349 ,18910 ,30790 ,23894 ,11195 ,8215 ,4348 ,2188 ,1854 ,3108 ,2846 ,408 ,-1595 ,-981 , 6586 ,23862 ,32562 ,28662 ,25388 ,16580 ,9496 ,8528 ,7347 ,7058 ,11690 ,16804 ,12965 ,7043 ,4408 , 5259 ,9240 ,17578 ,27460 ,28605 ,19041 ,18504 ,22153 ,24420 ,28426 ,25186 ,19931 ,17164 ,14653 ,10650 , 7367 ,15213 ,29990 ,28030 ,23965 ,20186 ,14642 ,11692 ,13537 ,17149 ,21021 ,22717 ,11857 ,-669 ,115 , 12766 ,20550 ,25352 ,28823 ,29530 ,26966 ,25583 ,28806 ,29559 ,26098 ,21949 ,13137 ,6357 ,7466 ,7234 , 782 ,-3364 ,1575 ,6298 ,5854 ,4291 ,3006 ,5434 ,8874 ,12228 ,14606 ,16976 ,17916 ,10902 ,-3461 , -6851 ,-8283 ,-8561 ,2427 ,13467 ,16609 ,12689 ,5535 ,-2326 ,-6919 ,-4167 ,-4543 ,-18187 ,-27834 ,-30498 , -29950 ,-24111 ,-12273 ,768 ,2122 ,-13688 ,-27641 ,-26812 ,-17064 ,-2588 ,6330 ,9482 ,9290 ,2340 ,-11025 , -18864 ,-17759 ,-22504 ,-27448 ,-30607 ,-32765 ,-31784 ,-26996 ,-18079 ,-13375 ,-13608 ,-8980 ,-14831 ,-27250 ,-27153 , -26357 ,-25419 ,-24293 ,-21951 ,-21149 ,-21924 ,-21965 ,-20620 ,-17700 ,-8513 ,-1777 ,-3367 ,-7813 ,-9694 ,-14927 , -24907 ,-26224 ,-22815 ,-16794 ,-11334 ,-14666 ,-20407 ,-22793 ,-22204 ,-19378 ,-12816 ,-2761 ,2227 ,-6393 ,-9988 , -1191 ,4832 ,346 ,-2181 ,-4911 ,-10179 ,-13370 ,-15773 ,-17098 ,-7543 ,5315 ,8099 ,7728 ,5273 ,6884 , 10443 ,11733 ,17778 ,22689 ,16416 ,1965 ,-9341 ,-9061 ,10579 ,27036 ,25853 ,20146 ,16325 ,18089 ,21185 , 22658 ,20928 ,15478 ,3355 ,-7002 ,5348 ,19306 ,19200 ,14029 ,13879 ,19983 ,25680 ,26713 ,27016 ,32765 , 27774 ,15917 ,10944 ,10632 ,11887 ,12559 ,11066 ,9325 ,9761 ,10966 ,11503 ,11774 ,13961 ,18081 ,19722 , 12758 ,872 ,-434 ,1251 ,1368 ,5360 ,7129 ,7526 ,5735 ,2185 ,11010 ,27412 ,27748 ,13736 ,7703 , 3579 ,1697 ,1762 ,2608 ,1008 ,-1677 ,-1309 ,6774 ,25041 ,32618 ,28110 ,21426 ,11983 ,8563 ,7453 , 7133 ,11855 ,15651 ,10820 ,5403 ,4412 ,7525 ,15607 ,26082 ,26834 ,19027 ,20390 ,23300 ,26456 ,26552 , 20889 ,17294 ,14282 ,9544 ,6885 ,20315 ,28646 ,25451 ,21415 ,15291 ,11924 ,13964 ,18119 ,21864 ,17181 , 3185 ,-1445 ,10860 ,20389 ,25731 ,29098 ,28801 ,26000 ,27368 ,29641 ,26668 ,21518 ,12572 ,6871 ,8188 , 4751 ,-1779 ,-87 ,5728 ,5684 ,3770 ,3171 ,6339 ,10159 ,13400 ,16128 ,17977 ,10816 ,-3501 ,-7215 , -9053 ,-4360 ,8504 ,15762 ,13458 ,5895 ,-2610 ,-6447 ,-4127 ,-10557 ,-24584 ,-30156 ,-30488 ,-25087 ,-12253 , -213 ,-3342 ,-21704 ,-29248 ,-20905 ,-6293 ,5353 ,9006 ,7752 ,-1362 ,-15969 ,-19480 ,-21014 ,-26361 ,-30451 , -32765 ,-31385 ,-25069 ,-15980 ,-13575 ,-10827 ,-12931 ,-26344 ,-27762 ,-26318 ,-25318 ,-23560 ,-21535 ,-21691 ,-22154 , -20926 ,-17834 ,-8401 ,-2665 ,-5247 ,-9244 ,-11974 ,-20996 ,-25688 ,-23119 ,-16594 ,-12579 ,-16891 ,-21945 ,-22610 , -20137 ,-14092 ,-3573 ,1201 ,-6956 ,-7494 ,1791 ,2618 ,-1364 ,-4280 ,-9804 ,-13418 ,-15924 ,-14380 ,-1169 , 8828 ,8556 ,10053 ,9075 ,3727 ,-3760 ,-4224 ,1943 ,8126 ,3615 ,-7896 ,-6976 ,-672 ,-5632 ,-13355 , -19756 ,-20664 ,-14143 ,225 ,15963 ,16490 ,1636 ,-5931 ,-991 ,4687 ,2641 ,-3078 ,-10931 ,-18846 ,-22837 , -20116 ,-8236 ,3535 ,121 ,-10548 ,-15228 ,-9087 ,2275 ,3023 ,900 ,747 ,4100 ,29583 ,32765 ,30110 , 31470 ,32639 ,32155 ,31250 ,30303 ,29364 ,28267 ,27151 ,25764 ,24523 ,22968 ,21527 ,19836 ,18497 ,16729 , 15178 ,13488 ,12056 ,10209 ,8469 ,6496 ,4785 ,2959 ,1208 ,-700 ,-2304 ,-4239 ,-5908 ,-7796 ,-9318 , -11303 ,-13083 ,-15162 ,-16946 ,-18748 ,-20242 ,-22001 ,-23548 ,-24930 ,-16343 ,10349 ,28672 ,28651 ,26040 ,25816 , 25372 ,24471 ,23559 ,22458 ,21434 ,20033 ,18804 ,17414 ,16058 ,14400 ,13015 ,11458 ,9894 ,8010 ,6523 , 4789 ,3310 ,1503 ,-36 ,-2088 ,-3868 ,-5784 ,-7514 ,-9396 ,-11010 ,-12781 ,-14403 ,-16356 ,-18175 ,-20013 , -21625 ,-23480 ,-25047 ,-26671 ,-28078 ,-29818 ,-31362 ,-32765 ,-23915 ,8660 ,28039 ,28498 ,25901 ,26293 ,25930 , 25205 ,24488 ,23476 ,22519 ,21285 ,20252 ,18764 ,17442 ,15853 ,14567 ,13012 ,11505 ,9797 ,8297 ,6476 , 4766 ,3010 ,1401 ,-422 ,-2043 ,-3767 ,-5329 ,-7199 ,-8906 ,-10693 ,-12411 ,-14478 ,-16248 ,-17862 ,-19369 , -21159 ,-22737 ,-24455 ,-22823 ,-2048 ,23774 ,29333 ,26851 ,27246 ,28341 ,27953 ,26950 ,26021 ,24947 ,23720 , 22381 ,21092 ,19777 ,18371 ,16858 ,15208 ,13722 ,12026 ,10434 ,8790 ,7149 ,5324 ,3581 ,1714 ,47 , -1692 ,-3428 ,-5231 ,-6910 ,-8631 ,-10381 ,-12194 ,-13982 ,-15647 ,-17330 ,-19128 ,-21030 ,-22736 ,-24255 ,-25884 , -27777 ,-29366 ,-25842 ,-1077 ,27137 ,31926 ,28772 ,28157 ,28091 ,27613 ,26778 ,25886 ,24798 ,23577 ,22292 , 21002 ,19632 ,18224 ,16811 ,15366 ,13903 ,12290 ,10693 ,9113 ,7419 ,5653 ,3868 ,1981 ,278 ,-1423 , -3116 ,-4872 ,-6520 ,-8238 ,-9927 ,-11896 ,-13929 ,-15768 ,-17353 ,-19057 ,-20655 ,-22199 ,-23720 ,-25380 ,-27032 , -27028 ,-9668 ,17292 ,26086 ,23679 ,22766 ,22598 ,21997 ,21006 ,20282 ,19029 ,17884 ,16640 ,15430 ,13880 , 12548 ,11093 ,9711 ,8189 ,6694 ,5022 ,3501 ,1701 ,-20 ,-1843 ,-3424 ,-5235 ,-6762 ,-8462 ,-10004 , -11780 ,-13369 ,-15067 ,-16840 ,-18774 ,-20453 ,-22090 ,-23534 ,-25137 ,-26612 ,-28006 ,-23009 ,655 ,6223 ,11459 , 16767 ,22481 ,27890 ,31526 ,31796 ,27788 ,20165 ,12221 ,5912 ,1695 ,-1044 ,-3185 ,-4818 ,-5168 ,-2651 , 3225 ,9480 ,12595 ,11728 ,9217 ,6364 ,3030 ,-1597 ,-8433 ,-16897 ,-25052 ,-30201 ,-30248 ,-26872 ,-22022 , -17050 ,-12639 ,-8643 ,-4646 ,-443 ,3203 ,4605 ,2116 ,-3873 ,-9892 ,-12984 ,-13687 ,-13188 ,-12142 ,-10194 , -6035 ,1664 ,11921 ,20800 ,26324 ,28903 ,29762 ,29544 ,28454 ,26238 ,22443 ,16889 ,10605 ,5505 ,3921 , 7051 ,12232 ,16876 ,19896 ,21676 ,23339 ,25432 ,26907 ,24606 ,17451 ,8319 ,486 ,-4866 ,-8847 ,-12397 , -15536 ,-17425 ,-16841 ,-13111 ,-6989 ,-906 ,2434 ,2494 ,84 ,-3425 ,-6953 ,-10531 ,-14744 ,-20301 ,-26967 , -32179 ,-32765 ,-28474 ,-22350 ,-17142 ,-12696 ,-7734 ,-1184 ,6119 ,11772 ,13461 ,10744 ,6606 ,3198 ,1238 , 429 ,69 ,-245 ,-424 ,137 ,2391 ,6586 ,11440 ,13868 ,11742 ,6841 ,1612 ,-2842 ,-6997 ,-11850 , -17999 ,-23907 ,-25160 ,-20701 ,-12893 ,-4483 ,3368 ,10478 ,17056 ,23114 ,27826 ,29716 ,27296 ,19869 ,8453 , -3519 ,-13515 ,-20850 ,-25929 ,-29211 ,-30840 ,-30029 ,-25068 ,-15402 ,-4620 ,3669 ,8438 ,11668 ,14580 ,16694 , 17176 ,14705 ,9928 ,4598 ,1653 ,2877 ,6715 ,11343 ,15310 ,17933 ,19655 ,20876 ,21822 ,21911 ,19456 , 12808 ,2510 ,-7828 ,-15108 ,-19852 ,-23235 ,-25847 ,-27367 ,-26250 ,-21253 ,-13367 ,-6648 ,-3169 ,-2321 ,-3010 , -4428 ,-6396 ,-9182 ,-13297 ,-18984 ,-25048 ,-29590 ,-30137 ,-25510 ,-18600 ,-12072 ,-6994 ,-3005 ,1136 ,5851 , 10197 ,10707 ,6386 ,97 ,-4594 ,-6683 ,-7396 ,-7509 ,-7194 ,-5701 ,-1702 ,5441 ,14891 ,24043 ,30220 , 32765 ,32639 ,31136 ,29132 ,26665 ,23140 ,17767 ,10626 ,4549 ,2638 ,5190 ,8808 ,10867 ,11690 ,12558 , 14502 ,16728 ,17012 ,13075 ,4623 ,-5150 ,-13678 ,-20349 ,-25043 ,-28422 ,-30746 ,-31815 ,-30887 ,-26860 ,-19724 , -11027 ,-4081 ,-1284 ,-1090 ,-1277 ,-1093 ,-1458 ,-3577 ,-8008 ,-13172 ,-14752 ,-11468 ,-5471 ,1036 ,4920 , 3067 ,-1309 ,-7194 ,-15242 ,-11098 ,8966 ,16140 ,5533 ,-468 ,-3916 ,-1267 ,8202 ,16947 ,20512 ,22557 , 25087 ,26552 ,18549 ,1262 ,816 ,18763 ,27537 ,30904 ,31235 ,32056 ,32762 ,27932 ,17105 ,11557 ,14125 , 22690 ,31851 ,25840 ,10535 ,7996 ,12882 ,15419 ,19591 ,23030 ,22468 ,15930 ,7954 ,3680 ,3704 ,6299 , 15887 ,26726 ,23042 ,11455 ,7957 ,4917 ,1226 ,-1002 ,-952 ,-2039 ,-3903 ,-3265 ,-1152 ,-3993 ,-7361 , 443 ,14891 ,19432 ,17627 ,14859 ,15700 ,16290 ,10273 ,2177 ,1860 ,6108 ,6126 ,59 ,-9428 ,-16089 , -18132 ,-20450 ,-24179 ,-23807 ,-23412 ,-24091 ,-18096 ,-5643 ,1171 ,1066 ,-728 ,-920 ,-983 ,-5350 ,-10486 , -7759 ,-1554 ,557 ,-1506 ,-3913 ,-11361 ,-24489 ,-31025 ,-27151 ,-24115 ,-21061 ,-16977 ,-12969 ,-12362 ,-17776 , -26743 ,-30826 ,-30778 ,-30589 ,-25171 ,-11592 ,-4172 ,-11353 ,-19205 ,-22219 ,-24846 ,-27184 ,-26244 ,-18902 ,-5246 , 4468 ,6954 ,7806 ,4232 ,-8854 ,-19262 ,-9567 ,4479 ,10639 ,14592 ,16062 ,16402 ,9583 ,-5051 ,-14167 , -13914 ,-11316 ,-3585 ,8978 ,19736 ,12594 ,-3989 ,-8733 ,-6380 ,-5476 ,-3986 ,2976 ,15692 ,24041 ,24221 , 21028 ,17098 ,10572 ,3853 ,10006 ,28003 ,32765 ,29072 ,27646 ,29733 ,29757 ,21955 ,16498 ,18279 ,21840 , 25520 ,29051 ,32115 ,28547 ,15224 ,6948 ,9697 ,9825 ,6101 ,4785 ,8826 ,10891 ,7342 ,3721 ,2352 , 1202 ,769 ,5967 ,18468 ,28151 ,25316 ,22782 ,25397 ,27735 ,25088 ,23270 ,22950 ,18497 ,11626 ,8252 , 8547 ,7283 ,-1645 ,-10146 ,-9633 ,-5254 ,-7089 ,-12701 ,-14409 ,-8895 ,1961 ,8548 ,8240 ,8951 ,10270 , 7358 ,4642 ,4612 ,2615 ,-2291 ,-6234 ,-7302 ,-10229 ,-20338 ,-26470 ,-18104 ,-7713 ,-5998 ,-10026 ,-17849 , -23156 ,-23522 ,-21369 ,-17371 ,-13775 ,-10588 ,-6653 ,-9267 ,-23702 ,-32296 ,-26592 ,-23213 ,-25663 ,-31515 ,-32765 , -30226 ,-29901 ,-31651 ,-32145 ,-29394 ,-21129 ,-7198 ,-5462 ,-21007 ,-29080 ,-28280 ,-27473 ,-22361 ,-10617 ,2326 , 13833 ,20882 ,22668 ,22834 ,21061 ,17290 ,14555 ,15497 ,17340 ,13790 ,5436 ,-419 ,2 ,4496 ,9959 , 13144 ,12613 ,7720 ,1066 ,-1205 ,1738 ,3230 ,3172 ,3747 ,4858 ,4772 ,5729 ,11313 ,20617 ,26708 , 28023 ,26366 ,23316 ,22164 ,24252 ,28678 ,32765 ,31832 ,27659 ,25435 ,26488 ,28289 ,28292 ,26259 ,21858 , 14813 ,7782 ,3952 ,2954 ,2316 ,1798 ,1403 ,1316 ,2439 ,5823 ,11448 ,17271 ,20598 ,21457 ,21899 , 23103 ,24647 ,25005 ,24094 ,21536 ,17251 ,12747 ,9301 ,5718 ,907 ,-4030 ,-7373 ,-9376 ,-10648 ,-10738 , -9517 ,-7465 ,-4176 ,1214 ,6712 ,9803 ,10655 ,10785 ,10530 ,9341 ,6472 ,986 ,-7978 ,-17512 ,-23939 , -27146 ,-29170 ,-31020 ,-32566 ,-32765 ,-29124 ,-20894 ,-11507 ,-6209 ,-4846 ,-4515 ,-4413 ,-3814 ,-3754 ,-7249 , -15938 ,-25811 ,-29984 ,-30546 ,-30769 ,-30763 ,-31201 ,-31077 ,-26835 ,-15879 ,-3763 ,1667 ,4601 ,8137 ,10805 , 12164 ,11808 ,6591 ,-5597 ,-16086 ,-18770 ,-19300 ,-21753 ,-24002 ,-24426 ,-22221 ,-14994 ,-1614 ,8037 ,9581 , 10382 ,14702 ,19646 ,22399 ,21442 ,14656 ,4056 ,-678 ,2639 ,5006 ,2968 ,-850 ,-3529 ,-1769 ,5977 , 15604 ,18813 ,14684 ,12140 ,12906 ,15451 ,17574 ,15739 ,9584 ,3308 ,4077 ,11452 ,17055 ,19440 ,19433 , 18503 ,19532 ,23651 ,27628 ,25305 ,18656 ,13305 ,10291 ,9285 ,9112 ,7596 ,3600 ,-314 ,187 ,3631 , 6643 ,8618 ,9237 ,8974 ,9031 ,10606 ,12124 ,10789 ,7163 ,3053 ,-1438 ,-5923 ,-9650 ,-12887 ,-16783 , -20660 ,-22783 ,-23109 ,-22651 ,-20927 ,-17597 ,-13628 ,-10141 ,-6699 ,-3371 ,-1164 ,-331 ,29 ,213 ,-993 , -4642 ,-9394 ,-13812 ,-17653 ,-20030 ,-20646 ,-21259 ,-23818 ,-27947 ,-29888 ,-28433 ,-25558 ,-23102 ,-22488 ,-23364 , -23969 ,-22135 ,-16152 ,-8171 ,-2416 ,-508 ,-175 ,371 ,888 ,792 ,959 ,754 ,-3441 ,-11543 ,-18021 , -20344 ,-19711 ,-16729 ,-13243 ,-13064 ,-17168 ,-22232 ,-22234 ,-16380 ,-11680 ,-10441 ,-11449 ,-11406 ,-9351 ,-5278 , -1630 ,-476 ,253 ,780 ,1098 ,131 ,-1276 ,-2947 ,-4107 ,-4057 ,-1946 ,2196 ,6923 ,10483 ,9229 , 5494 ,1366 ,3449 ,8596 ,14810 ,15751 ,12985 ,7891 ,7034 ,10298 ,16698 ,20727 ,22193 ,21200 ,19619 , 17978 ,16567 ,15759 ,15592 ,16312 ,17140 ,18382 ,20251 ,22806 ,25503 ,27773 ,29010 ,28994 ,27364 ,24765 , 22444 ,22613 ,25965 ,30253 ,32082 ,30110 ,26532 ,24791 ,25867 ,28876 ,32074 ,32765 ,31431 ,29480 ,27958 , 26680 ,25476 ,25738 ,27033 ,27707 ,27761 ,27502 ,27364 ,26952 ,26499 ,26594 ,27564 ,28972 ,29833 ,29706 , 28950 ,28644 ,28441 ,28063 ,27386 ,27450 ,27873 ,27511 ,26972 ,26739 ,26867 ,26422 ,25300 ,24488 ,24148 , 24503 ,25596 ,25632 ,24596 ,23887 ,23945 ,24357 ,23845 ,23268 ,23024 ,22783 ,22474 ,21943 ,21402 ,20761 , 19523 ,17131 ,14288 ,12543 ,13624 ,16142 ,17964 ,16727 ,13369 ,9825 ,7982 ,9078 ,12279 ,14110 ,12734 , 8296 ,4358 ,1863 ,1251 ,2562 ,4748 ,6414 ,6836 ,6685 ,6479 ,5876 ,4835 ,3307 ,1069 ,-1913 , -5322 ,-8351 ,-9443 ,-8095 ,-4959 ,-2032 ,-1574 ,-5127 ,-10445 ,-14478 ,-13504 ,-9299 ,-5941 ,-7302 ,-12597 , -18065 ,-19172 ,-16425 ,-12056 ,-9997 ,-10498 ,-13074 ,-16541 ,-19760 ,-22037 ,-23492 ,-24423 ,-25088 ,-25436 ,-25342 , -24707 ,-23286 ,-21409 ,-19596 ,-18990 ,-20554 ,-24199 ,-27956 ,-30014 ,-29138 ,-26375 ,-23824 ,-23239 ,-26170 ,-30195 , -32147 ,-30693 ,-27499 ,-25630 ,-25678 ,-27602 ,-30742 ,-32531 ,-32765 ,-31980 ,-32004 ,-32652 ,-32733 ,-32584 ,-32444 , -32500 ,-32281 ,-31911 ,-31753 ,-31822 ,-31655 ,-30674 ,-29509 ,-28948 ,-30051 ,-30868 ,-30791 ,-29722 ,-29381 ,-29652 , -29292 ,-28804 ,-28467 ,-28300 ,-28359 ,-28554 ,-28566 ,-28096 ,-27206 ,-26468 ,-24934 ,-22996 ,-22597 ,-22985 ,-23325 , -22600 ,-21729 ,-21043 ,-19890 ,-18802 ,-18203 ,-18910 ,-20431 ,-22207 ,-22945 ,-22533 ,-20903 ,-18112 ,-15411 ,-13710 , -16355 ,-19424 ,-20453 ,-16991 ,-12380 ,-9615 ,-9837 ,-12429 ,-16119 ,-16693 ,-15248 ,-12521 ,-10164 ,-7677 ,-4659 , -2761 ,678 ,7880 ,7168 ,5400 ,3587 ,3295 ,2588 ,3648 ,9782 ,11813 ,10000 ,6874 ,9650 ,15231 , 12538 ,11032 ,12636 ,20872 ,21036 ,13045 ,11292 ,13805 ,19114 ,20627 ,22212 ,24858 ,21769 ,19105 ,19515 , 24767 ,26954 ,22302 ,22535 ,25744 ,29473 ,24054 ,18464 ,22623 ,27295 ,28797 ,24359 ,23338 ,25079 ,27661 , 30022 ,31289 ,29227 ,28257 ,28977 ,31233 ,30732 ,28602 ,30746 ,32765 ,32693 ,27697 ,25609 ,27422 ,28222 , 28710 ,29426 ,31593 ,32614 ,30744 ,29472 ,29555 ,31203 ,30509 ,29435 ,29186 ,30114 ,30481 ,28651 ,27519 , 27320 ,28355 ,28126 ,27497 ,27657 ,27611 ,27150 ,26265 ,26490 ,27115 ,26118 ,25066 ,24358 ,24637 ,24249 , 23666 ,24661 ,25224 ,24668 ,23626 ,23284 ,23702 ,22517 ,20595 ,18420 ,17688 ,18230 ,19305 ,17583 ,15696 , 15898 ,16758 ,15394 ,10343 ,11405 ,15145 ,18119 ,16294 ,13152 ,12843 ,10586 ,7192 ,4859 ,7262 ,10563 , 8078 ,4177 ,2345 ,6687 ,5720 ,152 ,575 ,4843 ,9220 ,1558 ,-3626 ,-2763 ,381 ,2050 ,389 , -1523 ,-4940 ,-9486 ,-7262 ,-4721 ,-5185 ,-10133 ,-12184 ,-6894 ,-8413 ,-14152 ,-19819 ,-15341 ,-9504 ,-11701 , -15666 ,-18797 ,-19136 ,-18748 ,-17549 ,-14428 ,-16032 ,-20401 ,-21265 ,-18876 ,-16961 ,-22210 ,-23263 ,-18567 ,-17293 , -22181 ,-31079 ,-28125 ,-25356 ,-25208 ,-25286 ,-23623 ,-20900 ,-24121 ,-27812 ,-27884 ,-24807 ,-23988 ,-28041 ,-27829 , -25693 ,-24271 ,-28458 ,-32765 ,-30154 ,-28621 ,-28715 ,-30810 ,-30202 ,-28352 ,-27605 ,-27468 ,-27763 ,-28352 ,-28126 , -27414 ,-27893 ,-28431 ,-28405 ,-26512 ,-26330 ,-27888 ,-27638 ,-26475 ,-25233 ,-25996 ,-26388 ,-25786 ,-26231 ,-26370 , -25633 ,-24649 ,-24512 ,-25792 ,-24971 ,-23385 ,-22501 ,-24223 ,-25110 ,-22428 ,-19570 ,-17843 ,-18375 ,-18180 ,-17906 , -19647 ,-21271 ,-21605 ,-18687 ,-16772 ,-16878 ,-19324 ,-18317 ,-14544 ,-14794 ,-16740 ,-18451 ,-10889 ,-7083 ,-9430 , -12875 ,-12596 ,-7157 ,-5398 ,-6173 ,-8696 ,-10520 ,-9693 ,-5492 ,-4112 ,-4949 ,-7467 ,-3487 ,666 ,-3331 , -6815 ,-6074 ,2793 ,13795 ,20681 ,17060 ,13269 ,10560 ,3953 ,-3615 ,-9736 ,-1343 ,2819 ,1182 ,3940 , 12598 ,25386 ,24640 ,20556 ,19883 ,22646 ,17738 ,859 ,-1848 ,2310 ,9446 ,8390 ,8593 ,23463 ,28709 , 25582 ,16862 ,21997 ,30772 ,26181 ,12644 ,-535 ,5379 ,10509 ,13357 ,18048 ,25125 ,30718 ,20081 ,14109 , 19352 ,31079 ,32765 ,18258 ,7355 ,4372 ,10504 ,16154 ,22313 ,28522 ,25751 ,17784 ,7907 ,13725 ,26175 , 32643 ,26152 ,14433 ,6988 ,8055 ,15021 ,24702 ,28140 ,25616 ,12703 ,5239 ,5792 ,16854 ,25678 ,28216 , 23384 ,14816 ,6846 ,11326 ,20282 ,29603 ,24602 ,14591 ,2341 ,33 ,3892 ,14046 ,22150 ,26034 ,23176 , 14507 ,8305 ,11686 ,19806 ,25059 ,17885 ,5718 ,-6289 ,-4990 ,-134 ,8082 ,16372 ,21493 ,21087 ,13217 , 7967 ,8568 ,15178 ,16974 ,11760 ,-2123 ,-11206 ,-11487 ,-6798 ,-615 ,6034 ,14105 ,17236 ,11080 ,6120 , 5099 ,9626 ,9057 ,3046 ,-9323 ,-16455 ,-18709 ,-13919 ,-10926 ,-6609 ,4556 ,9830 ,8420 ,1692 ,487 , 3785 ,2224 ,-5476 ,-17122 ,-22232 ,-22012 ,-17728 ,-20327 ,-19563 ,-10645 ,1798 ,6470 ,-2439 ,-4053 ,-3026 , -2036 ,-13424 ,-24594 ,-26799 ,-20784 ,-15690 ,-23532 ,-27583 ,-23781 ,-6258 ,-635 ,-3310 ,-7726 ,-8857 ,-10373 , -22113 ,-28983 ,-29121 ,-16508 ,-13841 ,-22638 ,-32444 ,-31066 ,-16504 ,-6632 ,-4218 ,-9881 ,-14955 ,-21452 ,-29392 , -29457 ,-22883 ,-10192 ,-13138 ,-22952 ,-32765 ,-30483 ,-20770 ,-10125 ,-8044 ,-12871 ,-22905 ,-29809 ,-31125 ,-22608 , -12452 ,-4793 ,-15287 ,-25488 ,-32576 ,-29518 ,-21291 ,-11997 ,-11387 ,-19017 ,-30889 ,-31024 ,-22761 ,-9205 ,-4902 , -7929 ,-19274 ,-28013 ,-31947 ,-26474 ,-17578 ,-11944 ,-16731 ,-25707 ,-29635 ,-20951 ,-8078 ,847 ,-3820 ,-12671 , -22615 ,-27649 ,-26916 ,-20569 ,-12565 ,-13862 ,-21232 ,-23841 ,-16123 ,-1511 ,5193 ,2839 ,-6699 ,-14562 ,-20493 , -20581 ,-12593 ,-9024 ,-13962 ,-15560 ,-9630 ,5120 ,11551 ,10938 ,4065 ,-1993 ,-8276 ,-14830 ,-13257 ,-7965 , -4303 ,-6008 ,-6863 ,1419 ,9552 ,16995 ,18996 ,17668 ,15752 ,17750 ,21861 ,23959 ,24602 ,23734 ,21213 , 16947 ,12366 ,10824 ,9095 ,6832 ,4161 ,2760 ,2763 ,2662 ,2611 ,2686 ,3072 ,3636 ,4499 ,8066 , 13939 ,21876 ,27961 ,29830 ,25075 ,20457 ,17853 ,19971 ,20114 ,20202 ,21512 ,25430 ,29602 ,32301 ,32765 , 31133 ,26238 ,21288 ,16829 ,14170 ,11819 ,9920 ,8512 ,7842 ,7845 ,8450 ,10375 ,13591 ,19061 ,24757 , 29700 ,30920 ,29451 ,25299 ,20778 ,16143 ,11905 ,9250 ,7981 ,7669 ,7751 ,8702 ,10971 ,14641 ,18774 , 22828 ,25848 ,27720 ,28014 ,27405 ,25613 ,22561 ,18353 ,14200 ,11278 ,10349 ,10736 ,12566 ,14773 ,17267 , 19743 ,21715 ,23024 ,23618 ,23071 ,21110 ,16849 ,10484 ,2967 ,-2894 ,-6114 ,-6568 ,-6727 ,-7531 ,-8749 , -8382 ,-6940 ,-4644 ,-1999 ,777 ,3527 ,5526 ,7494 ,9551 ,11329 ,12673 ,13232 ,13368 ,12867 ,11554 , 9761 ,8056 ,6937 ,6932 ,7597 ,8701 ,9462 ,9797 ,9112 ,7611 ,4586 ,-810 ,-8171 ,-15594 ,-19861 , -19580 ,-16791 ,-16596 ,-18129 ,-20542 ,-21237 ,-22775 ,-25199 ,-26711 ,-26261 ,-23468 ,-20655 ,-18282 ,-16553 ,-14440 , -11926 ,-9080 ,-7043 ,-5325 ,-3893 ,-2817 ,-2167 ,-2190 ,-2194 ,-2233 ,-2345 ,-3030 ,-4515 ,-7141 ,-11792 , -17713 ,-24396 ,-28545 ,-29816 ,-25155 ,-21357 ,-19083 ,-19170 ,-18122 ,-16304 ,-15627 ,-16446 ,-18337 ,-20492 ,-23786 , -28005 ,-31456 ,-32765 ,-31052 ,-27172 ,-23132 ,-19898 ,-17267 ,-14645 ,-11840 ,-10516 ,-10088 ,-10589 ,-11972 ,-14361 , -18179 ,-22499 ,-26711 ,-29792 ,-30831 ,-29233 ,-25058 ,-19921 ,-14947 ,-11080 ,-8280 ,-6337 ,-6083 ,-6770 ,-8298 , -10739 ,-13970 ,-17741 ,-21352 ,-24476 ,-26842 ,-28079 ,-27533 ,-25472 ,-21942 ,-18475 ,-15530 ,-14366 ,-14769 ,-16974 , -19773 ,-22352 ,-24066 ,-24831 ,-24078 ,-21743 ,-15769 ,-8604 ,-1471 ,3844 ,4272 ,4405 ,4622 ,5725 ,4814 , 1698 ,-1793 ,-4583 ,-6658 ,-9235 ,-11708 ,-13817 ,-14528 ,-14492 ,-13502 ,-11751 ,-9866 ,-8526 ,-8684 ,-9661 , -10845 ,-10471 ,-8645 ,-4977 , #endif }; #endif // __PCM_SAMPLES_H ================================================ FILE: src/pcm_tiny.h ================================================ // Automatically generated by amy.headers.generate_pcm_header() #ifndef __PCM_H #define __PCM_H #define PCM_AMY_SAMPLE_RATE 22050 #define PCM_BASE_SAMPLES 11 #define PCM_BASE_LENGTH 51053 #if defined(AMY_WAVETABLE) #define PCM_WAVETABLE_BASE PCM_BASE_SAMPLES #define PCM_WAVETABLE_SAMPLES 5 #define PCM_WAVETABLE_LEN 16384 #define PCM_LENGTH (PCM_BASE_LENGTH + (PCM_WAVETABLE_SAMPLES * PCM_WAVETABLE_LEN)) #define PCM_MAP_ENTRIES (PCM_BASE_SAMPLES + PCM_WAVETABLE_SAMPLES) #else #define PCM_WAVETABLE_BASE PCM_BASE_SAMPLES #define PCM_WAVETABLE_SAMPLES 0 #define PCM_WAVETABLE_LEN 0 #define PCM_LENGTH PCM_BASE_LENGTH #define PCM_MAP_ENTRIES PCM_BASE_SAMPLES #endif #include "pcm_samples_tiny.h" const uint16_t pcm_samples = PCM_MAP_ENTRIES; const uint16_t pcm_wavetable_base = PCM_WAVETABLE_BASE; const uint16_t pcm_wavetable_samples = PCM_WAVETABLE_SAMPLES; const uint32_t pcm_wavetable_len = PCM_WAVETABLE_LEN; const pcm_map_t pcm_map[PCM_MAP_ENTRIES] PROGMEM = { /* [0] 0 */ {0, 707, 342, 684, 89}, /* 808-MARACA-D */ /* [1] 3 */ {707, 8186, 4282, 7439, 39}, /* 808-KIK 4-D */ /* [2] 8 */ {8893, 2766, 1377, 2744, 45}, /* 808-SNR 4-D */ /* [3] 11 */ {11659, 1311, 898, 1288, 52}, /* 808-SNR 7-D */ /* [4] 14 */ {12970, 2276, 1164, 2254, 51}, /* 808-SNR 10D */ /* [5] 16 */ {15246, 2872, 1430, 2849, 41}, /* 808-SNR 12-D */ /* [6] 17 */ {18118, 1751, 888, 1728, 53}, /* 808-C-HAT1-D */ /* [7] 18 */ {19869, 15400, 7815, 15377, 56}, /* 808-O-HAT1-D */ /* [8] 20 */ {35269, 8995, 4588, 8973, 61}, /* 808-LTOM M-D */ /* [9] 23 */ {44264, 3027, 1504, 3004, 94}, /* 808-DRYCLP-D */ /* [10] 25 */ {47291, 3762, 22, 1871, 69}, /* 808-CWBELL-D */ #if defined(AMY_WAVETABLE) /* [11] WT */ {51053, 16384, 0, 16384, 69}, /* 111.WAV */ /* [12] WT */ {67437, 16384, 0, 16384, 69}, /* BRAIDS01.WAV */ /* [13] WT */ {83821, 16384, 0, 16384, 69}, /* PPG_WA00.WAV */ /* [14] WT */ {100205, 16384, 0, 16384, 69}, /* SINE2SAW.WAV */ /* [15] WT */ {116589, 16384, 0, 16384, 69}, /* VIRAL.WAV */ #endif }; #endif // __PCM_H ================================================ FILE: src/pico-audio/audio.cpp ================================================ #if (defined PICO_RP2350) || (defined PICO_RP2040) /* * Copyright (c) 2020 Raspberry Pi (Trading) Ltd. * * SPDX-License-Identifier: BSD-3-Clause */ #include #include "audio.h" #include "sample_conversion.h" // ====================== // == DEBUGGING ========= #define ENABLE_AUDIO_ASSERTIONS #ifdef ENABLE_AUDIO_ASSERTIONS #define audio_assert(x) assert(x) #else #define audio_assert(x) (void)0 #endif inline static audio_buffer_t *list_remove_head(audio_buffer_t **phead) { audio_buffer_t *ab = *phead; if (ab) { *phead = ab->next; ab->next = NULL; } return ab; } inline static audio_buffer_t *list_remove_head_with_tail(audio_buffer_t **phead, audio_buffer_t **ptail) { audio_buffer_t *ab = *phead; if (ab) { *phead = ab->next; if (!ab->next) { audio_assert(*ptail == ab); *ptail = NULL; } else { ab->next = NULL; } } return ab; } inline static void list_prepend(audio_buffer_t **phead, audio_buffer_t *ab) { audio_assert(ab->next == NULL); audio_assert(ab != *phead); ab->next = *phead; *phead = ab; } // todo add a tail for these already sorted lists as we generally insert on the end inline static void list_append_with_tail(audio_buffer_t **phead, audio_buffer_t **ptail, audio_buffer_t *ab) { audio_assert(ab->next == NULL); audio_assert(ab != *phead); audio_assert(ab != *ptail); if (!*phead) { audio_assert(!*ptail); *ptail = ab; // insert at the beginning list_prepend(phead, ab); } else { // insert at end (*ptail)->next = ab; *ptail = ab; } } audio_buffer_t *get_free_audio_buffer(audio_buffer_pool_t *context, bool block) { audio_buffer_t *ab; do { uint32_t save = spin_lock_blocking(context->free_list_spin_lock); ab = list_remove_head(&context->free_list); spin_unlock(context->free_list_spin_lock, save); if (ab || !block) break; __wfe(); } while (true); return ab; } void queue_free_audio_buffer(audio_buffer_pool_t *context, audio_buffer_t *ab) { assert(!ab->next); uint32_t save = spin_lock_blocking(context->free_list_spin_lock); list_prepend(&context->free_list, ab); spin_unlock(context->free_list_spin_lock, save); __sev(); } audio_buffer_t *get_full_audio_buffer(audio_buffer_pool_t *context, bool block) { audio_buffer_t *ab; do { uint32_t save = spin_lock_blocking(context->prepared_list_spin_lock); ab = list_remove_head_with_tail(&context->prepared_list, &context->prepared_list_tail); spin_unlock(context->prepared_list_spin_lock, save); if (ab || !block) break; __wfe(); } while (true); return ab; } void queue_full_audio_buffer(audio_buffer_pool_t *context, audio_buffer_t *ab) { assert(!ab->next); uint32_t save = spin_lock_blocking(context->prepared_list_spin_lock); list_append_with_tail(&context->prepared_list, &context->prepared_list_tail, ab); spin_unlock(context->prepared_list_spin_lock, save); __sev(); } void producer_pool_give_buffer_default(audio_connection_t *connection, audio_buffer_t *buffer) { queue_full_audio_buffer(connection->producer_pool, buffer); } audio_buffer_t *producer_pool_take_buffer_default(audio_connection_t *connection, bool block) { return get_free_audio_buffer(connection->producer_pool, block); } void consumer_pool_give_buffer_default(audio_connection_t *connection, audio_buffer_t *buffer) { queue_free_audio_buffer(connection->consumer_pool, buffer); } audio_buffer_t *consumer_pool_take_buffer_default(audio_connection_t *connection, bool block) { return get_full_audio_buffer(connection->consumer_pool, block); } static audio_connection_t connection_default = { .producer_pool_take = producer_pool_take_buffer_default, .producer_pool_give = producer_pool_give_buffer_default, .consumer_pool_take = consumer_pool_take_buffer_default, .consumer_pool_give = consumer_pool_give_buffer_default, }; audio_buffer_t *audio_new_buffer(audio_buffer_format_t *format, int buffer_sample_count) { audio_buffer_t *buffer = (audio_buffer_t *) calloc(1, sizeof(audio_buffer_t)); audio_init_buffer(buffer, format, buffer_sample_count); return buffer; } void audio_init_buffer(audio_buffer_t *audio_buffer, audio_buffer_format_t *format, int buffer_sample_count) { audio_buffer->format = format; audio_buffer->buffer = pico_buffer_alloc(buffer_sample_count * format->sample_stride); audio_buffer->max_sample_count = buffer_sample_count; audio_buffer->sample_count = 0; } audio_buffer_pool_t * audio_new_buffer_pool(audio_buffer_format_t *format, int buffer_count, int buffer_sample_count) { audio_buffer_pool_t *ac = (audio_buffer_pool_t *) calloc(1, sizeof(audio_buffer_pool_t)); audio_buffer_t *audio_buffers = buffer_count ? (audio_buffer_t *) calloc(buffer_count, sizeof(audio_buffer_t)) : 0; ac->format = format->format; for (int i = 0; i < buffer_count; i++) { audio_init_buffer(audio_buffers + i, format, buffer_sample_count); audio_buffers[i].next = i != buffer_count - 1 ? &audio_buffers[i + 1] : NULL; } // todo one per channel? ac->free_list_spin_lock = spin_lock_init(SPINLOCK_ID_AUDIO_FREE_LIST_LOCK); ac->free_list = audio_buffers; ac->prepared_list_spin_lock = spin_lock_init(SPINLOCK_ID_AUDIO_PREPARED_LISTS_LOCK); ac->prepared_list = NULL; ac->prepared_list_tail = NULL; ac->connection = &connection_default; return ac; } audio_buffer_t *audio_new_wrapping_buffer(audio_buffer_format_t *format, mem_buffer_t *buffer) { audio_buffer_t *audio_buffer = (audio_buffer_t *) calloc(1, sizeof(audio_buffer_t)); if (audio_buffer) { audio_buffer->format = format; audio_buffer->buffer = buffer; audio_buffer->max_sample_count = buffer->size / format->sample_stride; audio_buffer->sample_count = 0; audio_buffer->next = 0; } return audio_buffer; } audio_buffer_pool_t * audio_new_producer_pool(audio_buffer_format_t *format, int buffer_count, int buffer_sample_count) { audio_buffer_pool_t *ac = audio_new_buffer_pool(format, buffer_count, buffer_sample_count); ac->type = audio_buffer_pool::ac_producer; return ac; } audio_buffer_pool_t * audio_new_consumer_pool(audio_buffer_format_t *format, int buffer_count, int buffer_sample_count) { audio_buffer_pool_t *ac = audio_new_buffer_pool(format, buffer_count, buffer_sample_count); ac->type = audio_buffer_pool::ac_consumer; return ac; } void audio_complete_connection(audio_connection_t *connection, audio_buffer_pool_t *producer_pool, audio_buffer_pool_t *consumer_pool) { assert(producer_pool->type == audio_buffer_pool::ac_producer); assert(consumer_pool->type == audio_buffer_pool::ac_consumer); producer_pool->connection = connection; consumer_pool->connection = connection; connection->producer_pool = producer_pool; connection->consumer_pool = consumer_pool; } void give_audio_buffer(audio_buffer_pool_t *ac, audio_buffer_t *buffer) { buffer->user_data = 0; assert(ac->connection); if (ac->type == audio_buffer_pool::ac_producer) ac->connection->producer_pool_give(ac->connection, buffer); else ac->connection->consumer_pool_give(ac->connection, buffer); } audio_buffer_t *take_audio_buffer(audio_buffer_pool_t *ac, bool block) { assert(ac->connection); if (ac->type == audio_buffer_pool::ac_producer) return ac->connection->producer_pool_take(ac->connection, block); else return ac->connection->consumer_pool_take(ac->connection, block); } // todo rename this - this is s16 to s16 audio_buffer_t *mono_to_mono_consumer_take(audio_connection_t *connection, bool block) { return consumer_pool_take, Mono>(connection, block); } // todo rename this - this is s16 to s16 audio_buffer_t *stereo_to_stereo_consumer_take(audio_connection_t *connection, bool block) { return consumer_pool_take, Stereo>(connection, block); } // todo rename this - this is s16 to s16 audio_buffer_t *mono_to_stereo_consumer_take(audio_connection_t *connection, bool block) { return consumer_pool_take, Mono>(connection, block); } audio_buffer_t *mono_s8_to_mono_consumer_take(audio_connection_t *connection, bool block) { return consumer_pool_take, Mono>(connection, block); } audio_buffer_t *mono_s8_to_stereo_consumer_take(audio_connection_t *connection, bool block) { return consumer_pool_take, Mono>(connection, block); } void stereo_to_stereo_producer_give(audio_connection_t *connection, audio_buffer_t *buffer) { return producer_pool_blocking_give, Stereo>(connection, buffer); } #endif ================================================ FILE: src/pico-audio/audio.h ================================================ #if (defined PICO_RP2350) || (defined PICO_RP2040) /* * Copyright (c) 2020 Raspberry Pi (Trading) Ltd. * * SPDX-License-Identifier: BSD-3-Clause */ #ifndef _PICO_AUDIO_H #define _PICO_AUDIO_H #include "pico.h" #include "buffer.h" #include "hardware/sync.h" #ifdef __cplusplus extern "C" { #endif /** \file audio.h * \defgroup pico_audio pico_audio * * Common API for audio output * */ // PICO_CONFIG: SPINLOCK_ID_AUDIO_FREE_LIST_LOCK, Spinlock number for the audio free list, min=0, max=31, default=6, group=audio #ifndef SPINLOCK_ID_AUDIO_FREE_LIST_LOCK #define SPINLOCK_ID_AUDIO_FREE_LIST_LOCK 6 #endif // PICO_CONFIG: SPINLOCK_ID_AUDIO_PREPARED_LISTS_LOCK, Spinlock number for the audio prepared list, min=0, max=31, default=7, group=audio #ifndef SPINLOCK_ID_AUDIO_PREPARED_LISTS_LOCK #define SPINLOCK_ID_AUDIO_PREPARED_LISTS_LOCK 7 #endif // PICO_CONFIG: PICO_AUDIO_NOOP, Enable/disable audio by forcing NOOPS, type=bool, default=0, group=audio #ifndef PICO_AUDIO_NOOP #define PICO_AUDIO_NOOP 0 #endif #define AUDIO_BUFFER_FORMAT_PCM_S16 1 ///< signed 16bit PCM #define AUDIO_BUFFER_FORMAT_PCM_S8 2 ///< signed 8bit PCM #define AUDIO_BUFFER_FORMAT_PCM_U16 3 ///< unsigned 16bit PCM #define AUDIO_BUFFER_FORMAT_PCM_U8 4 ///< unsigned 8bit PCM /** \brief Audio format definition */ typedef struct audio_format { uint32_t sample_freq; ///< Sample frequency in Hz uint16_t format; ///< Audio format \ref audio_formats uint16_t channel_count; ///< Number of channels } audio_format_t; /** \brief Audio buffer format definition */ typedef struct audio_buffer_format { const audio_format_t *format; ///< Audio format uint16_t sample_stride; ///< Sample stride } audio_buffer_format_t; /** \brief Audio buffer definition */ typedef struct audio_buffer { mem_buffer_t *buffer; const audio_buffer_format_t *format; uint32_t sample_count; uint32_t max_sample_count; uint32_t user_data; // only valid while the user has the buffer // private - todo make an internal version struct audio_buffer *next; } audio_buffer_t; typedef struct audio_connection audio_connection_t; typedef struct audio_buffer_pool { enum { ac_producer, ac_consumer } type; const audio_format_t *format; // private audio_connection_t *connection; spin_lock_t *free_list_spin_lock; // ----- begin protected by free_list_spin_lock ----- audio_buffer_t *free_list; spin_lock_t *prepared_list_spin_lock; audio_buffer_t *prepared_list; audio_buffer_t *prepared_list_tail; } audio_buffer_pool_t; typedef struct audio_connection audio_connection_t; struct audio_connection { audio_buffer_t *(*producer_pool_take)(audio_connection_t *connection, bool block); void (*producer_pool_give)(audio_connection_t *connection, audio_buffer_t *buffer); audio_buffer_t *(*consumer_pool_take)(audio_connection_t *connection, bool block); void (*consumer_pool_give)(audio_connection_t *connection, audio_buffer_t *buffer); audio_buffer_pool_t *producer_pool; audio_buffer_pool_t *consumer_pool; }; /*! \brief Allocate and initialise an audio producer pool * \ingroup pico_audio * * \param format Format of the audio buffer * \param buffer_count \todo * \param buffer_sample_count \todo * \return Pointer to an audio_buffer_pool */ audio_buffer_pool_t *audio_new_producer_pool(audio_buffer_format_t *format, int buffer_count, int buffer_sample_count); /*! \brief Allocate and initialise an audio consumer pool * \ingroup pico_audio * * \param format Format of the audio buffer * \param buffer_count * \param buffer_sample_count * \return Pointer to an audio_buffer_pool */ audio_buffer_pool_t *audio_new_consumer_pool(audio_buffer_format_t *format, int buffer_count, int buffer_sample_count); /*! \brief Allocate and initialise an audio wrapping buffer * \ingroup pico_audio * * \param format Format of the audio buffer * \param buffer \todo * \return Pointer to an audio_buffer */ audio_buffer_t *audio_new_wrapping_buffer(audio_buffer_format_t *format, mem_buffer_t *buffer); /*! \brief Allocate and initialise an new audio buffer * \ingroup pico_audio * * \param format Format of the audio buffer * \param buffer_sample_count \todo * \return Pointer to an audio_buffer */ audio_buffer_t *audio_new_buffer(audio_buffer_format_t *format, int buffer_sample_count); /*! \brief Initialise an audio buffer * \ingroup pico_audio * * \param audio_buffer Pointer to an audio_buffer * \param format Format of the audio buffer * \param buffer_sample_count \todo */ void audio_init_buffer(audio_buffer_t *audio_buffer, audio_buffer_format_t *format, int buffer_sample_count); /*! \brief \todo * \ingroup pico_audio * * \param ac \todo * \param buffer \todo * \return Pointer to an audio_buffer */ void give_audio_buffer(audio_buffer_pool_t *ac, audio_buffer_t *buffer); /*! \brief \todo * \ingroup pico_audio * * \return Pointer to an audio_buffer */ audio_buffer_t *take_audio_buffer(audio_buffer_pool_t *ac, bool block); /*! \brief \todo * \ingroup pico_audio * */ static inline void release_audio_buffer(audio_buffer_pool_t *ac, audio_buffer_t *buffer) { buffer->sample_count = 0; give_audio_buffer(ac, buffer); } /*! \brief \todo * \ingroup pico_audio * * todo we are currently limited to 4095+1 input samples * step is fraction of an input sample per output sample * 0x1000 and should be < 0x1000 i.e. we we are up-sampling (otherwise results are undefined) */ void audio_upsample(int16_t *input, int16_t *output, uint output_count, uint32_t step); /*! \brief \todo * \ingroup pico_audio * similar but the output buffer is word aligned, and we output an even number of samples.. this is slightly faster than the above * todo we are currently limited to 4095+1 input samples * step is fraction of an input sample per output sample * 0x1000 and should be < 0x1000 i.e. we we are up-sampling (otherwise results are undefined) */ void audio_upsample_words(int16_t *input, int16_t *output_aligned, uint output_word_count, uint32_t step); /*! \brief \todo * \ingroup pico_audio */ void audio_upsample_double(int16_t *input, int16_t *output, uint output_count, uint32_t step); /*! \brief \todo * \ingroup pico_audio */ void audio_complete_connection(audio_connection_t *connection, audio_buffer_pool_t *producer, audio_buffer_pool_t *consumer); /*! \brief \todo * \ingroup pico_audio */ audio_buffer_t *get_free_audio_buffer(audio_buffer_pool_t *context, bool block); /*! \brief \todo * \ingroup pico_audio */ void queue_free_audio_buffer(audio_buffer_pool_t *context, audio_buffer_t *ab); /*! \brief \todo * \ingroup pico_audio */ audio_buffer_t *get_full_audio_buffer(audio_buffer_pool_t *context, bool block); /*! \brief \todo * \ingroup pico_audio */ void queue_full_audio_buffer(audio_buffer_pool_t *context, audio_buffer_t *ab); /*! \brief \todo * \ingroup pico_audio * * generally an pico_audio connection uses 3 of the defaults and does the hard work in one of them */ void consumer_pool_give_buffer_default(audio_connection_t *connection, audio_buffer_t *buffer); /*! \brief \todo * \ingroup pico_audio */ audio_buffer_t *consumer_pool_take_buffer_default(audio_connection_t *connection, bool block); /*! \brief \todo * \ingroup pico_audio */ void producer_pool_give_buffer_default(audio_connection_t *connection, audio_buffer_t *buffer); /*! \brief \todo * \ingroup pico_audio */ audio_buffer_t *producer_pool_take_buffer_default(audio_connection_t *connection, bool block); enum audio_correction_mode { none, fixed_dither, dither, noise_shaped_dither, }; struct buffer_copying_on_consumer_take_connection { struct audio_connection core; audio_buffer_t *current_producer_buffer; uint32_t current_producer_buffer_pos; }; struct producer_pool_blocking_give_connection { audio_connection_t core; audio_buffer_t *current_consumer_buffer; uint32_t current_consumer_buffer_pos; }; /*! \brief \todo * \ingroup pico_audio */ audio_buffer_t *mono_to_mono_consumer_take(audio_connection_t *connection, bool block); /*! \brief \todo * \ingroup pico_audio */ audio_buffer_t *mono_s8_to_mono_consumer_take(audio_connection_t *connection, bool block); /*! \brief \todo * \ingroup pico_audio */ audio_buffer_t *stereo_to_stereo_consumer_take(audio_connection_t *connection, bool block); /*! \brief \todo * \ingroup pico_audio */ audio_buffer_t *mono_to_stereo_consumer_take(audio_connection_t *connection, bool block); /*! \brief \todo * \ingroup pico_audio */ audio_buffer_t *mono_s8_to_stereo_consumer_take(audio_connection_t *connection, bool block); /*! \brief \todo * \ingroup pico_audio */ void stereo_to_stereo_producer_give(audio_connection_t *connection, audio_buffer_t *buffer); // not worth a separate header for now typedef struct __packed pio_audio_channel_config { uint8_t base_pin; uint8_t dma_channel; uint8_t pio_sm; } pio_audio_channel_config_t; #ifdef __cplusplus } #endif #endif //_AUDIO_H #endif ================================================ FILE: src/pico-audio/audio_i2s.c ================================================ /* * Copyright (c) 2020 Raspberry Pi (Trading) Ltd. * * SPDX-License-Identifier: BSD-3-Clause */ #if (defined ARDUINO_ARCH_RP2040) || (defined ARDUINO_ARCH_RP2350) #include #include "audio_i2s.h" #include "audio_i2s.pio.h" #include "hardware/pio.h" #include "hardware/gpio.h" #include "hardware/dma.h" #include "hardware/irq.h" #include "hardware/clocks.h" CU_REGISTER_DEBUG_PINS(audio_timing) // ---- select at most one --- //CU_SELECT_DEBUG_PINS(audio_timing) #if PICO_AUDIO_I2S_MONO_OUTPUT #define i2s_dma_configure_size DMA_SIZE_16 #else #define i2s_dma_configure_size DMA_SIZE_32 #endif #define audio_pio __CONCAT(pio, PICO_AUDIO_I2S_PIO) #define GPIO_FUNC_PIOx __CONCAT(GPIO_FUNC_PIO, PICO_AUDIO_I2S_PIO) #define DREQ_PIOx_TX0 __CONCAT(__CONCAT(DREQ_PIO, PICO_AUDIO_I2S_PIO), _TX0) struct { audio_buffer_t *playing_buffer; uint32_t freq; uint8_t pio_sm; uint8_t dma_channel; } shared_state; audio_format_t pio_i2s_consumer_format; audio_buffer_format_t pio_i2s_consumer_buffer_format = { .format = &pio_i2s_consumer_format, }; static void __isr __time_critical_func(audio_i2s_dma_irq_handler)(); const audio_format_t *audio_i2s_setup(const audio_format_t *intended_audio_format, const audio_i2s_config_t *config) { uint func = GPIO_FUNC_PIOx; gpio_set_function(config->data_pin, func); gpio_set_function(config->clock_pin_base, func); gpio_set_function(config->clock_pin_base + 1, func); #if PICO_PIO_USE_GPIO_BASE if(config->data_pin >= 32 || config->clock_pin_base + 1 >= 32) { assert(config->data_pin >= 16 && config->clock_pin_base >= 16); pio_set_gpio_base(audio_pio, 16); } #endif uint8_t sm = shared_state.pio_sm = config->pio_sm; pio_sm_claim(audio_pio, sm); const struct pio_program *program = #if PICO_AUDIO_I2S_CLOCK_PINS_SWAPPED &audio_i2s_swapped_program #else &audio_i2s_program #endif ; uint offset = pio_add_program(audio_pio, program); audio_i2s_program_init(audio_pio, sm, offset, config->data_pin, config->clock_pin_base); __mem_fence_release(); uint8_t dma_channel = config->dma_channel; dma_channel_claim(dma_channel); shared_state.dma_channel = dma_channel; dma_channel_config dma_config = dma_channel_get_default_config(dma_channel); channel_config_set_dreq(&dma_config, DREQ_PIOx_TX0 + sm ); channel_config_set_transfer_data_size(&dma_config, i2s_dma_configure_size); dma_channel_configure(dma_channel, &dma_config, &audio_pio->txf[sm], // dest NULL, // src 0, // count false // trigger ); irq_add_shared_handler(DMA_IRQ_0 + PICO_AUDIO_I2S_DMA_IRQ, audio_i2s_dma_irq_handler, PICO_SHARED_IRQ_HANDLER_DEFAULT_ORDER_PRIORITY); dma_irqn_set_channel_enabled(PICO_AUDIO_I2S_DMA_IRQ, dma_channel, 1); return intended_audio_format; } static audio_buffer_pool_t *audio_i2s_consumer; static void update_pio_frequency(uint32_t sample_freq) { uint32_t system_clock_frequency = clock_get_hz(clk_sys); assert(system_clock_frequency < 0x40000000); uint32_t divider = system_clock_frequency * 4 / sample_freq; // avoid arithmetic overflow assert(divider < 0x1000000); pio_sm_set_clkdiv_int_frac(audio_pio, shared_state.pio_sm, divider >> 8u, divider & 0xffu); shared_state.freq = sample_freq; } static audio_buffer_t *wrap_consumer_take(audio_connection_t *connection, bool block) { // support dynamic frequency shifting if (connection->producer_pool->format->sample_freq != shared_state.freq) { update_pio_frequency(connection->producer_pool->format->sample_freq); } #if PICO_AUDIO_I2S_MONO_INPUT #if PICO_AUDIO_I2S_MONO_OUTPUT return mono_to_mono_consumer_take(connection, block); #else return mono_to_stereo_consumer_take(connection, block); #endif #else #if PICO_AUDIO_I2S_MONO_OUTPUT unsupported; #else return stereo_to_stereo_consumer_take(connection, block); #endif #endif } static void wrap_producer_give(audio_connection_t *connection, audio_buffer_t *buffer) { // support dynamic frequency shifting if (connection->producer_pool->format->sample_freq != shared_state.freq) { update_pio_frequency(connection->producer_pool->format->sample_freq); } #if PICO_AUDIO_I2S_MONO_INPUT #if PICO_AUDIO_I2S_MONO_OUTPUT assert(false); // return mono_to_mono_producer_give(connection, block); #else assert(false); //return mono_to_stereo_producer_give(connection, buffer); #endif #else #if PICO_AUDIO_I2S_MONO_OUTPUT unsupported; #else return stereo_to_stereo_producer_give(connection, buffer); #endif #endif } static struct buffer_copying_on_consumer_take_connection m2s_audio_i2s_ct_connection = { .core = { .consumer_pool_take = wrap_consumer_take, .consumer_pool_give = consumer_pool_give_buffer_default, .producer_pool_take = producer_pool_take_buffer_default, .producer_pool_give = producer_pool_give_buffer_default, } }; static struct producer_pool_blocking_give_connection m2s_audio_i2s_pg_connection = { .core = { .consumer_pool_take = consumer_pool_take_buffer_default, .consumer_pool_give = consumer_pool_give_buffer_default, .producer_pool_take = producer_pool_take_buffer_default, .producer_pool_give = wrap_producer_give, } }; static void pass_thru_producer_give(audio_connection_t *connection, audio_buffer_t *buffer) { queue_full_audio_buffer(connection->consumer_pool, buffer); } static void pass_thru_consumer_give(audio_connection_t *connection, audio_buffer_t *buffer) { queue_free_audio_buffer(connection->producer_pool, buffer); } static struct producer_pool_blocking_give_connection audio_i2s_pass_thru_connection = { .core = { .consumer_pool_take = consumer_pool_take_buffer_default, .consumer_pool_give = pass_thru_consumer_give, .producer_pool_take = producer_pool_take_buffer_default, .producer_pool_give = pass_thru_producer_give, } }; bool audio_i2s_connect_thru(audio_buffer_pool_t *producer, audio_connection_t *connection) { return audio_i2s_connect_extra(producer, false, 2, 256, connection); } bool audio_i2s_connect(audio_buffer_pool_t *producer) { return audio_i2s_connect_thru(producer, NULL); } bool audio_i2s_connect_extra(audio_buffer_pool_t *producer, bool buffer_on_give, uint buffer_count, uint samples_per_buffer, audio_connection_t *connection) { printf("Connecting PIO I2S audio\n"); // todo we need to pick a connection based on the frequency - e.g. 22050 can be more simply upsampled to 44100 assert(producer->format->format == AUDIO_BUFFER_FORMAT_PCM_S16); pio_i2s_consumer_format.format = AUDIO_BUFFER_FORMAT_PCM_S16; // todo we could do mono // todo we can't match exact, so we should return what we can do pio_i2s_consumer_format.sample_freq = producer->format->sample_freq; #if PICO_AUDIO_I2S_MONO_OUTPUT pio_i2s_consumer_format.channel_count = 1; pio_i2s_consumer_buffer_format.sample_stride = 2; #else pio_i2s_consumer_format.channel_count = 2; pio_i2s_consumer_buffer_format.sample_stride = 4; #endif audio_i2s_consumer = audio_new_consumer_pool(&pio_i2s_consumer_buffer_format, buffer_count, samples_per_buffer); update_pio_frequency(producer->format->sample_freq); // todo cleanup threading __mem_fence_release(); if (!connection) { if (producer->format->channel_count == 2) { #if PICO_AUDIO_I2S_MONO_INPUT panic("need to merge channels down\n"); #else #if PICO_AUDIO_I2S_MONO_OUTPUT panic("trying to play stereo thru mono not yet supported"); #else printf("Copying stereo to stereo at %d Hz\n", (int) producer->format->sample_freq); #endif #endif } else { #if PICO_AUDIO_I2S_MONO_OUTPUT printf("Copying mono to mono at %d Hz\n", (int) producer->format->sample_freq); #else printf("Converting mono to stereo at %d Hz\n", (int) producer->format->sample_freq); #endif } if (!buffer_count) connection = &audio_i2s_pass_thru_connection.core; else connection = buffer_on_give ? &m2s_audio_i2s_pg_connection.core : &m2s_audio_i2s_ct_connection.core; } audio_complete_connection(connection, producer, audio_i2s_consumer); return true; } static struct buffer_copying_on_consumer_take_connection m2s_audio_i2s_connection_s8 = { .core = { #if PICO_AUDIO_I2S_MONO_OUTPUT .consumer_pool_take = mono_s8_to_mono_consumer_take, #else .consumer_pool_take = mono_s8_to_stereo_consumer_take, #endif .consumer_pool_give = consumer_pool_give_buffer_default, .producer_pool_take = producer_pool_take_buffer_default, .producer_pool_give = producer_pool_give_buffer_default, } }; bool audio_i2s_connect_s8(audio_buffer_pool_t *producer) { printf("Connecting PIO I2S audio (U8)\n"); // todo we need to pick a connection based on the frequency - e.g. 22050 can be more simply upsampled to 44100 assert(producer->format->format == AUDIO_BUFFER_FORMAT_PCM_S8); pio_i2s_consumer_format.format = AUDIO_BUFFER_FORMAT_PCM_S16; // todo we could do mono // todo we can't match exact, so we should return what we can do pio_i2s_consumer_format.sample_freq = producer->format->sample_freq; #if PICO_AUDIO_I2S_MONO_OUTPUT pio_i2s_consumer_format.channel_count = 1; pio_i2s_consumer_buffer_format.sample_stride = 2; #else pio_i2s_consumer_format.channel_count = 2; pio_i2s_consumer_buffer_format.sample_stride = 4; #endif // we do this on take so should do it quickly... uint samples_per_buffer = 256; // todo with take we really only need 1 buffer audio_i2s_consumer = audio_new_consumer_pool(&pio_i2s_consumer_buffer_format, 2, samples_per_buffer); // todo we need a method to calculate this in clocks uint32_t system_clock_frequency = clock_get_hz(clk_sys); // uint32_t divider = system_clock_frequency * 256 / producer->format->sample_freq * 16 * 4; uint32_t divider = system_clock_frequency * 4 / producer->format->sample_freq; // avoid arithmetic overflow pio_sm_set_clkdiv_int_frac(audio_pio, shared_state.pio_sm, divider >> 8u, divider & 0xffu); // todo cleanup threading __mem_fence_release(); audio_connection_t *connection; if (producer->format->channel_count == 2) { #if PICO_AUDIO_I2S_MONO_OUTPUT panic("trying to play stereo thru mono not yet supported"); #endif // todo we should support pass thru option anyway printf("TODO... not completing stereo audio connection properly!\n"); connection = &m2s_audio_i2s_connection_s8.core; } else { #if PICO_AUDIO_I2S_MONO_OUTPUT printf("Copying mono to mono at %d Hz\n", (int) producer->format->sample_freq); #else printf("Converting mono to stereo at %d Hz\n", (int) producer->format->sample_freq); #endif connection = &m2s_audio_i2s_connection_s8.core; } audio_complete_connection(connection, producer, audio_i2s_consumer); return true; } static inline void audio_start_dma_transfer() { assert(!shared_state.playing_buffer); audio_buffer_t *ab = take_audio_buffer(audio_i2s_consumer, false); shared_state.playing_buffer = ab; if (!ab) { DEBUG_PINS_XOR(audio_timing, 1); DEBUG_PINS_XOR(audio_timing, 2); DEBUG_PINS_XOR(audio_timing, 1); //DEBUG_PINS_XOR(audio_timing, 2); // just play some silence static uint32_t zero; dma_channel_config c = dma_get_channel_config(shared_state.dma_channel); channel_config_set_read_increment(&c, false); dma_channel_set_config(shared_state.dma_channel, &c, false); dma_channel_transfer_from_buffer_now(shared_state.dma_channel, &zero, PICO_AUDIO_I2S_SILENCE_BUFFER_SAMPLE_LENGTH); return; } assert(ab->sample_count); // todo better naming of format->format->format!! assert(ab->format->format->format == AUDIO_BUFFER_FORMAT_PCM_S16); #if PICO_AUDIO_I2S_MONO_OUTPUT assert(ab->format->format->channel_count == 1); assert(ab->format->sample_stride == 2); #else assert(ab->format->format->channel_count == 2); assert(ab->format->sample_stride == 4); #endif dma_channel_config c = dma_get_channel_config(shared_state.dma_channel); channel_config_set_read_increment(&c, true); dma_channel_set_config(shared_state.dma_channel, &c, false); dma_channel_transfer_from_buffer_now(shared_state.dma_channel, ab->buffer->bytes, ab->sample_count); } // irq handler for DMA void __isr __time_critical_func(audio_i2s_dma_irq_handler)() { #if PICO_AUDIO_I2S_NOOP assert(false); #else uint dma_channel = shared_state.dma_channel; if (dma_irqn_get_channel_status(PICO_AUDIO_I2S_DMA_IRQ, dma_channel)) { dma_irqn_acknowledge_channel(PICO_AUDIO_I2S_DMA_IRQ, dma_channel); DEBUG_PINS_SET(audio_timing, 4); // free the buffer we just finished if (shared_state.playing_buffer) { give_audio_buffer(audio_i2s_consumer, shared_state.playing_buffer); #ifndef NDEBUG shared_state.playing_buffer = NULL; #endif } audio_start_dma_transfer(); DEBUG_PINS_CLR(audio_timing, 4); } #endif } static bool audio_enabled; void audio_i2s_set_enabled(bool enabled) { if (enabled != audio_enabled) { #ifndef NDEBUG if (enabled) { puts("Enabling PIO I2S audio\n"); printf("(on core %d\n", get_core_num()); } #endif irq_set_enabled(DMA_IRQ_0 + PICO_AUDIO_I2S_DMA_IRQ, enabled); if (enabled) { audio_start_dma_transfer(); } else { // if there was a buffer in flight, it will not be freed by DMA IRQ, let's do it manually if (shared_state.playing_buffer) { give_audio_buffer(audio_i2s_consumer, shared_state.playing_buffer); shared_state.playing_buffer = NULL; } } pio_sm_set_enabled(audio_pio, shared_state.pio_sm, enabled); audio_enabled = enabled; } } #endif ================================================ FILE: src/pico-audio/audio_i2s.h ================================================ /* * Copyright (c) 2020 Raspberry Pi (Trading) Ltd. * * SPDX-License-Identifier: BSD-3-Clause */ #if (defined ARDUINO_ARCH_RP2040) || (defined ARDUINO_ARCH_RP2350) #ifndef _PICO_AUDIO_I2S_H #define _PICO_AUDIO_I2S_H #include "audio.h" /** \file audio_i2s.h * \defgroup pico_audio_i2s pico_audio_i2s * I2S audio output using the PIO * * This library uses the \ref hardware_pio system to implement a I2S audio interface * * \todo Must be more we need to say here. * \todo certainly need an example * */ #ifdef __cplusplus extern "C" { #endif #ifndef PICO_AUDIO_I2S_DMA_IRQ #ifdef PICO_AUDIO_DMA_IRQ #define PICO_AUDIO_I2S_DMA_IRQ PICO_AUDIO_DMA_IRQ #else #define PICO_AUDIO_I2S_DMA_IRQ 0 #endif #endif #ifndef PICO_AUDIO_I2S_PIO #ifdef PICO_AUDIO_PIO #define PICO_AUDIO_I2S_PIO PICO_AUDIO_PIO #else #define PICO_AUDIO_I2S_PIO 0 #endif #endif #if !(PICO_AUDIO_I2S_DMA_IRQ == 0 || PICO_AUDIO_I2S_DMA_IRQ == 1) #error PICO_AUDIO_I2S_DMA_IRQ must be 0 or 1 #endif #if !(PICO_AUDIO_I2S_PIO == 0 || PICO_AUDIO_I2S_PIO == 1) #error PICO_AUDIO_I2S_PIO ust be 0 or 1 #endif #ifndef PICO_AUDIO_I2S_MAX_CHANNELS #ifdef PICO_AUDIO_MAX_CHANNELS #define PICO_AUDIO_I2S_MAX_CHANNELS PICO_AUDIO_MAX_CHANNELS #else #define PICO_AUDIO_I2S_MAX_CHANNELS 2u #endif #endif #ifndef PICO_AUDIO_I2S_BUFFERS_PER_CHANNEL #ifdef PICO_AUDIO_BUFFERS_PER_CHANNEL #define PICO_AUDIO_I2S_BUFFERS_PER_CHANNEL PICO_AUDIO_BUFFERS_PER_CHANNEL #else #define PICO_AUDIO_I2S_BUFFERS_PER_CHANNEL 3u #endif #endif #ifndef PICO_AUDIO_I2S_BUFFER_SAMPLE_LENGTH #ifdef PICO_AUDIO_BUFFER_SAMPLE_LENGTH #define PICO_AUDIO_I2S_BUFFER_SAMPLE_LENGTH PICO_AUDIO_BUFFER_SAMPLE_LENGTH #else #define PICO_AUDIO_I2S_BUFFER_SAMPLE_LENGTH 576u #endif #endif #ifndef PICO_AUDIO_I2S_SILENCE_BUFFER_SAMPLE_LENGTH #ifdef PICO_AUDIO_I2S_SILENCE_BUFFER_SAMPLE_LENGTH #define PICO_AUDIO_I2S_SILENCE_BUFFER_SAMPLE_LENGTH PICO_AUDIO_SILENCE_BUFFER_SAMPLE_LENGTH #else #define PICO_AUDIO_I2S_SILENCE_BUFFER_SAMPLE_LENGTH 256u #endif #endif // Allow use of pico_audio driver without actually doing anything much #ifndef PICO_AUDIO_I2S_NOOP #ifdef PICO_AUDIO_NOOP #define PICO_AUDIO_I2S_NOOP PICO_AUDIO_NOOP #else #define PICO_AUDIO_I2S_NOOP 0 #endif #endif #ifndef PICO_AUDIO_I2S_MONO_INPUT #define PICO_AUDIO_I2S_MONO_INPUT 0 #endif #ifndef PICO_AUDIO_I2S_MONO_OUTPUT #define PICO_AUDIO_I2S_MONO_OUTPUT 0 #endif #ifndef PICO_AUDIO_I2S_DATA_PIN //#warning PICO_AUDIO_I2S_DATA_PIN should be defined when using AUDIO_I2S #define PICO_AUDIO_I2S_DATA_PIN 28 #endif #ifndef PICO_AUDIO_I2S_CLOCK_PIN_BASE //#warning PICO_AUDIO_I2S_CLOCK_PIN_BASE should be defined when using AUDIO_I2S #define PICO_AUDIO_I2S_CLOCK_PIN_BASE 26 #endif // The default order is CLOCK_PIN_BASE=LRCLK, CLOCK_PIN_BASE+1=BCLK // The swapped order is CLOCK_PIN_BASE=BCLK, CLOCK_PIN_BASE+1=LRCLK #ifndef PICO_AUDIO_I2S_CLOCK_PINS_SWAPPED #define PICO_AUDIO_I2S_CLOCK_PINS_SWAPPED 0 #endif // todo this needs to come from a build config /** \brief Base configuration structure used when setting up * \ingroup pico_audio_i2s */ typedef struct audio_i2s_config { uint8_t data_pin; uint8_t clock_pin_base; uint8_t dma_channel; uint8_t pio_sm; } audio_i2s_config_t; /** \brief Set up system to output I2S audio * \ingroup pico_audio_i2s * * \param intended_audio_format \todo * \param config The configuration to apply. */ const audio_format_t *audio_i2s_setup(const audio_format_t *intended_audio_format, const audio_i2s_config_t *config); /** \brief \todo * \ingroup pico_audio_i2s * * \param producer * \param connection */ bool audio_i2s_connect_thru(audio_buffer_pool_t *producer, audio_connection_t *connection); /** \brief \todo * \ingroup pico_audio_i2s * * \param producer * * todo make a common version (or a macro) .. we don't want to pull in unnecessary code by default */ bool audio_i2s_connect(audio_buffer_pool_t *producer); /** \brief \todo * \ingroup pico_audio_i2s * * \param producer */ bool audio_i2s_connect_s8(audio_buffer_pool_t *producer); /** \brief \todo * \ingroup pico_audio_i2s * * \param producer * \param buffer_on_give * \param buffer_count * \param samples_per_buffer * \param connection * \return */ bool audio_i2s_connect_extra(audio_buffer_pool_t *producer, bool buffer_on_give, uint buffer_count, uint samples_per_buffer, audio_connection_t *connection); /** \brief Set up system to output I2S audio * \ingroup pico_audio_i2s * * \param enable true to enable I2S audio, false to disable. */ void audio_i2s_set_enabled(bool enabled); #ifdef __cplusplus } #endif #endif //_AUDIO_I2S_H #endif ================================================ FILE: src/pico-audio/audio_i2s.pio ================================================ ; ; Copyright (c) 2020 Raspberry Pi (Trading) Ltd. ; ; SPDX-License-Identifier: BSD-3-Clause ; ; Transmit a mono or stereo I2S audio stream as stereo ; This is 16 bits per sample; can be altered by modifying the "set" params, ; or made programmable by replacing "set x" with "mov x, y" and using Y as a config register. ; ; Autopull must be enabled, with threshold set to 32. ; Since I2S is MSB-first, shift direction should be to left. ; Hence the format of the FIFO word is: ; ; | 31 : 16 | 15 : 0 | ; | sample ws=0 | sample ws=1 | ; ; Data is output at 1 bit per clock. Use clock divider to adjust frequency. ; Fractional divider will probably be needed to get correct bit clock period, ; but for common syslck freqs this should still give a constant word select period. ; ; One output pin is used for the data output. ; Two side-set pins are used. Two versions of the program are provided, so that ; the clock and word select pins can be in either order. ; Send 16 bit words to the PIO for mono, 32 bit words for stereo .program audio_i2s .side_set 2 ; /--- LRCLK ; |/-- BCLK bitloop1: ; || out pins, 1 side 0b10 jmp x-- bitloop1 side 0b11 out pins, 1 side 0b00 set x, 14 side 0b01 bitloop0: out pins, 1 side 0b00 jmp x-- bitloop0 side 0b01 out pins, 1 side 0b10 public entry_point: set x, 14 side 0b11 .program audio_i2s_swapped .side_set 2 ; /--- BCLK ; |/-- LRCLK bitloop1: ; || out pins, 1 side 0b01 jmp x-- bitloop1 side 0b11 out pins, 1 side 0b00 set x, 14 side 0b10 bitloop0: out pins, 1 side 0b00 jmp x-- bitloop0 side 0b10 out pins, 1 side 0b01 public entry_point: set x, 14 side 0b11 % c-sdk { static inline void audio_i2s_program_init(PIO pio, uint sm, uint offset, uint data_pin, uint clock_pin_base) { pio_sm_config sm_config = audio_i2s_program_get_default_config(offset); sm_config_set_out_pins(&sm_config, data_pin, 1); sm_config_set_sideset_pins(&sm_config, clock_pin_base); sm_config_set_out_shift(&sm_config, false, true, 32); sm_config_set_fifo_join(&sm_config, PIO_FIFO_JOIN_TX); pio_sm_init(pio, sm, offset, &sm_config); #if PICO_PIO_USE_GPIO_BASE uint64_t pin_mask = (1ull << data_pin) | (3ull << clock_pin_base); pio_sm_set_pindirs_with_mask64(pio, sm, pin_mask, pin_mask); #else uint32_t pin_mask = (1u << data_pin) | (3u << clock_pin_base); pio_sm_set_pindirs_with_mask(pio, sm, pin_mask, pin_mask); #endif pio_sm_set_pins(pio, sm, 0); // clear pins pio_sm_exec(pio, sm, pio_encode_jmp(offset + audio_i2s_offset_entry_point)); } %} ================================================ FILE: src/pico-audio/audio_i2s.pio.h ================================================ #if (defined PICO_RP2350) || (defined PICO_RP2040) // -------------------------------------------------- // // This file is autogenerated by pioasm; do not edit! // // -------------------------------------------------- // #pragma once #if !PICO_NO_HARDWARE #include "hardware/pio.h" #endif // --------- // // audio_i2s // // --------- // #define audio_i2s_wrap_target 0 #define audio_i2s_wrap 7 #define audio_i2s_offset_entry_point 7u static const uint16_t audio_i2s_program_instructions[] = { // .wrap_target 0x7001, // 0: out pins, 1 side 2 0x1840, // 1: jmp x--, 0 side 3 0x6001, // 2: out pins, 1 side 0 0xe82e, // 3: set x, 14 side 1 0x6001, // 4: out pins, 1 side 0 0x0844, // 5: jmp x--, 4 side 1 0x7001, // 6: out pins, 1 side 2 0xf82e, // 7: set x, 14 side 3 // .wrap }; #if !PICO_NO_HARDWARE static const struct pio_program audio_i2s_program = { .instructions = audio_i2s_program_instructions, .length = 8, .origin = -1, }; static inline pio_sm_config audio_i2s_program_get_default_config(uint offset) { pio_sm_config c = pio_get_default_sm_config(); sm_config_set_wrap(&c, offset + audio_i2s_wrap_target, offset + audio_i2s_wrap); sm_config_set_sideset(&c, 2, false, false); return c; } #endif // ----------------- // // audio_i2s_swapped // // ----------------- // #define audio_i2s_swapped_wrap_target 0 #define audio_i2s_swapped_wrap 7 #define audio_i2s_swapped_offset_entry_point 7u static const uint16_t audio_i2s_swapped_program_instructions[] = { // .wrap_target 0x6801, // 0: out pins, 1 side 1 0x1840, // 1: jmp x--, 0 side 3 0x6001, // 2: out pins, 1 side 0 0xf02e, // 3: set x, 14 side 2 0x6001, // 4: out pins, 1 side 0 0x1044, // 5: jmp x--, 4 side 2 0x6801, // 6: out pins, 1 side 1 0xf82e, // 7: set x, 14 side 3 // .wrap }; #if !PICO_NO_HARDWARE static const struct pio_program audio_i2s_swapped_program = { .instructions = audio_i2s_swapped_program_instructions, .length = 8, .origin = -1, }; static inline pio_sm_config audio_i2s_swapped_program_get_default_config(uint offset) { pio_sm_config c = pio_get_default_sm_config(); sm_config_set_wrap(&c, offset + audio_i2s_swapped_wrap_target, offset + audio_i2s_swapped_wrap); sm_config_set_sideset(&c, 2, false, false); return c; } static inline void audio_i2s_program_init(PIO pio, uint sm, uint offset, uint data_pin, uint clock_pin_base) { pio_sm_config sm_config = audio_i2s_program_get_default_config(offset); sm_config_set_out_pins(&sm_config, data_pin, 1); sm_config_set_sideset_pins(&sm_config, clock_pin_base); sm_config_set_out_shift(&sm_config, false, true, 32); sm_config_set_fifo_join(&sm_config, PIO_FIFO_JOIN_TX); pio_sm_init(pio, sm, offset, &sm_config); #if PICO_PIO_USE_GPIO_BASE uint64_t pin_mask = (1ull << data_pin) | (3ull << clock_pin_base); pio_sm_set_pindirs_with_mask64(pio, sm, pin_mask, pin_mask); #else uint32_t pin_mask = (1u << data_pin) | (3u << clock_pin_base); pio_sm_set_pindirs_with_mask(pio, sm, pin_mask, pin_mask); #endif pio_sm_set_pins(pio, sm, 0); // clear pins pio_sm_exec(pio, sm, pio_encode_jmp(offset + audio_i2s_offset_entry_point)); } #endif #endif ================================================ FILE: src/pico-audio/buffer.c ================================================ #if (defined PICO_RP2350) || (defined PICO_RP2040) #if 1 /* * Copyright (c) 2020 Raspberry Pi (Trading) Ltd. * * SPDX-License-Identifier: BSD-3-Clause */ #ifdef ARDUINO_ARCH_RP2040 #include "buffer.h" #ifdef PICO_BUFFER_USB_ALLOC_HACK #include uint8_t *usb_ram_alloc_ptr = (uint8_t *)(USBCTRL_DPRAM_BASE + USB_DPRAM_MAX); static void __attribute__((constructor)) _clear_usb_ram() { memset(usb_ram_alloc_ptr, 0, USB_DPRAM_SIZE - USB_DPRAM_MAX); } #endif #endif #endif #endif ================================================ FILE: src/pico-audio/buffer.h ================================================ /* * Copyright (c) 2020 Raspberry Pi (Trading) Ltd. * * SPDX-License-Identifier: BSD-3-Clause */ #if 1 #ifdef ARDUINO_ARCH_RP2040 #ifndef _PICO_UTIL_BUFFER_H #define _PICO_UTIL_BUFFER_H #include "pico/types.h" /** \file buffer.h * \defgroup util_buffer buffer * \brief Buffer management * \ingroup pico_util */ #ifdef PICO_BUFFER_USB_ALLOC_HACK #include "hardware/address_mapped.h" #endif #ifdef __cplusplus extern "C" { #endif #ifdef DEBUG_MALLOC #include #endif #include /** \struct mem_buffer * \ingroup util_buffer * \brief Wrapper structure around a memory buffer * * Wrapper could be around static or allocated memory * * \todo This module needs to be checked - think there are issues with the free function */ typedef struct mem_buffer { size_t size; uint8_t *bytes; uint8_t flags; } mem_buffer_t; #ifdef PICO_BUFFER_USB_ALLOC_HACK #if !defined(USB_DPRAM_MAX) || (USB_DPRAM_MAX > 0) #include "hardware/structs/usb.h" #else #define USB_DPRAM_SIZE 4096 #endif #endif inline static bool pico_buffer_alloc_in_place(mem_buffer_t *buffer, size_t size) { #ifdef PICO_BUFFER_USB_ALLOC_HACK extern uint8_t *usb_ram_alloc_ptr; if ((usb_ram_alloc_ptr + size) <= (uint8_t *)USBCTRL_DPRAM_BASE + USB_DPRAM_SIZE) { buffer->bytes = usb_ram_alloc_ptr; buffer->size = size; #ifdef DEBUG_MALLOC printf("balloc %d %p->%p\n", size, buffer->bytes, ((uint8_t *)buffer->bytes) + size); #endif usb_ram_alloc_ptr += size; return true; } #endif // inline for now buffer->bytes = (uint8_t *) calloc(1, size); if (buffer->bytes) { buffer->size = size; return true; } buffer->size = 0; return false; } inline static mem_buffer_t *pico_buffer_wrap(uint8_t *bytes, size_t size) { mem_buffer_t *buffer = (mem_buffer_t *) malloc(sizeof(mem_buffer_t)); if (buffer) { buffer->bytes = bytes; buffer->size = size; } return buffer; } inline static mem_buffer_t *pico_buffer_alloc(size_t size) { mem_buffer_t *b = (mem_buffer_t *) malloc(sizeof(mem_buffer_t)); if (b) { if (!pico_buffer_alloc_in_place(b, size)) { free(b); b = NULL; } } return b; } #ifdef __cplusplus } #endif #endif #endif #endif ================================================ FILE: src/pico-audio/sample_conversion.h ================================================ /* * Copyright (c) 2020 Raspberry Pi (Trading) Ltd. * * SPDX-License-Identifier: BSD-3-Clause */ #if (defined PICO_RP2350) || (defined PICO_RP2040) #ifndef SOFTWARE_SAMPLE_CONVERSION_H #define SOFTWARE_SAMPLE_CONVERSION_H #include #include #include "audio.h" #include "buffer.h" template struct FmtDetails { public: static const uint channel_count = 1; static const uint frame_stride = channel_count * sizeof(_sample_t); typedef _sample_t sample_t; }; struct FmtU8 : public FmtDetails { }; struct FmtS8 : public FmtDetails { }; struct FmtU16 : public FmtDetails { }; struct FmtS16 : public FmtDetails { }; // Multi-channel is just N samples back to back template struct MultiChannelFmt { static const uint channel_count = ChannelCount; static const uint frame_stride = ChannelCount * Fmt::frame_stride; typedef typename Fmt::sample_t sample_t; }; // define Mono details as one channel template using Mono = MultiChannelFmt; // define Stereo details as two channels template using Stereo = MultiChannelFmt; template struct sample_converter { static typename ToFmt::sample_t convert_sample(const typename FromFmt::sample_t &sample); }; // noop conversion template struct sample_converter { static typename Fmt::sample_t convert_sample(const typename Fmt::sample_t &sample) { return sample; } }; // converters to S16 template<> struct sample_converter { static int16_t convert_sample(const uint16_t &sample) { return sample ^ 0x8000u; } }; template<> struct sample_converter { static int16_t convert_sample(const int8_t &sample) { return sample << 8u; } }; template<> struct sample_converter { static int16_t convert_sample(const uint8_t &sample) { return (sample << 8u) ^ 0x8000u; } }; // converters to U16 template<> struct sample_converter { static uint16_t convert_sample(const int8_t &sample) { return (sample << 8u) ^ 0x8000u; } }; template<> struct sample_converter { static uint16_t convert_sample(const uint8_t &sample) { return sample << 8u; } }; template<> struct sample_converter { static uint16_t convert_sample(const int16_t &sample) { return sample ^ 0x8000u; } }; // converters to S8 template<> struct sample_converter { static int8_t convert_sample(const uint16_t &sample) { return (sample ^ 0x8000u) >> 8u; } }; template<> struct sample_converter { static int8_t convert_sample(const uint8_t &sample) { return sample ^ 0x80; } }; template<> struct sample_converter { static int8_t convert_sample(const int16_t &sample) { return sample >> 8u; } }; // converters to U8 template<> struct sample_converter { static uint8_t convert_sample(const uint16_t &sample) { return sample >> 8u; } }; template<> struct sample_converter { static uint8_t convert_sample(const int8_t &sample) { return sample ^ 0x80; } }; template<> struct sample_converter { static uint8_t convert_sample(const int16_t &sample) { return (sample ^ 0x8000u) >> 8u; } }; // template type for doing sample conversion template struct converting_copy { static void copy(typename ToFmt::sample_t *dest, const typename FromFmt::sample_t *src, uint sample_count); }; // Efficient copies of same sample type template struct converting_copy, MultiChannelFmt> { static void copy(typename MultiChannelFmt::sample_t *dest, const typename MultiChannelFmt::sample_t *src, uint sample_count) { memcpy((void *) dest, (const void *) src, sample_count * MultiChannelFmt::frame_stride); } }; // N channel to N channel template struct converting_copy, MultiChannelFmt> { static void copy(typename ToFmt::sample_t *dest, const typename FromFmt::sample_t *src, uint sample_count) { for (uint i = 0; i < sample_count * NumChannels; i++) { *dest++ = sample_converter::convert_sample(*src++); } } }; // mono->stereo conversion template struct converting_copy, Mono> { static void copy(typename ToFmt::sample_t *dest, const typename FromFmt::sample_t *src, uint sample_count) { for (; sample_count; sample_count--) { typename ToFmt::sample_t mono_sample = sample_converter::convert_sample(*src++); *dest++ = mono_sample; *dest++ = mono_sample; } } }; // stereo->mono conversion template struct converting_copy, Stereo> { static void copy(typename ToFmt::sample_t *dest, const typename FromFmt::sample_t *src, uint sample_count) { for (; sample_count; sample_count--) { // average first in case precision is better in source typename FromFmt::sample_t averaged_sample = (src[0] + src[1]) / 2; src += 2; *dest++ = sample_converter::convert_sample(averaged_sample); } } }; template audio_buffer_t *consumer_pool_take(audio_connection_t *connection, bool block) { struct buffer_copying_on_consumer_take_connection *cc = (struct buffer_copying_on_consumer_take_connection *) connection; // for now we block until we have all the data in consumer buffers audio_buffer_t *buffer = get_free_audio_buffer(cc->core.consumer_pool, block); if (!buffer) return NULL; assert(buffer->format->sample_stride == ToFmt::frame_stride); uint32_t pos = 0; while (pos < buffer->max_sample_count) { if (!cc->current_producer_buffer) { cc->current_producer_buffer = get_full_audio_buffer(cc->core.producer_pool, block); if (!cc->current_producer_buffer) { assert(!block); if (!pos) { queue_free_audio_buffer(cc->core.consumer_pool, buffer); return NULL; } break; } assert(cc->current_producer_buffer->format->format->channel_count == FromFmt::channel_count); assert(cc->current_producer_buffer->format->sample_stride == FromFmt::frame_stride); cc->current_producer_buffer_pos = 0; } uint sample_count = std::min(buffer->max_sample_count - pos, cc->current_producer_buffer->sample_count - cc->current_producer_buffer_pos); converting_copy::copy( ((typename ToFmt::sample_t *) buffer->buffer->bytes) + pos * ToFmt::channel_count, ((typename FromFmt::sample_t *) cc->current_producer_buffer->buffer->bytes) + cc->current_producer_buffer_pos * FromFmt::channel_count, sample_count); pos += sample_count; cc->current_producer_buffer_pos += sample_count; if (cc->current_producer_buffer_pos == cc->current_producer_buffer->sample_count) { queue_free_audio_buffer(cc->core.producer_pool, cc->current_producer_buffer); cc->current_producer_buffer = NULL; } } buffer->sample_count = pos; return buffer; } template void producer_pool_blocking_give(audio_connection_t *connection, audio_buffer_t *buffer) { struct producer_pool_blocking_give_connection *pbc = (struct producer_pool_blocking_give_connection *) connection; // for now we block until we have all the data in consumer buffers uint32_t pos = 0; while (pos < buffer->sample_count) { if (!pbc->current_consumer_buffer) { pbc->current_consumer_buffer = get_free_audio_buffer(pbc->core.consumer_pool, true); pbc->current_consumer_buffer_pos = 0; } uint sample_count = std::min(buffer->sample_count - pos, pbc->current_consumer_buffer->max_sample_count - pbc->current_consumer_buffer_pos); assert(buffer->format->sample_stride == FromFmt::frame_stride); assert(buffer->format->format->channel_count == FromFmt::channel_count); converting_copy::copy( ((typename ToFmt::sample_t *) pbc->current_consumer_buffer->buffer->bytes) + pbc->current_consumer_buffer_pos * ToFmt::channel_count, ((typename FromFmt::sample_t *) buffer->buffer->bytes) + pos * FromFmt::channel_count, sample_count); pos += sample_count; pbc->current_consumer_buffer_pos += sample_count; if (pbc->current_consumer_buffer_pos == pbc->current_consumer_buffer->max_sample_count) { pbc->current_consumer_buffer->sample_count = pbc->current_consumer_buffer->max_sample_count; queue_full_audio_buffer(pbc->core.consumer_pool, pbc->current_consumer_buffer); pbc->current_consumer_buffer = NULL; } } // todo this should be a connection configuration (or a seaparate connection type) #ifdef BLOCKING_GIVE_SYNCHRONIZE_BUFFERS if (pbc->current_consumer_buffer) { pbc->current_consumer_buffer->sample_count = pbc->current_consumer_buffer_pos; queue_full_audio_buffer(pbc->core.consumer_pool, pbc->current_consumer_buffer); pbc->current_consumer_buffer = NULL; } #endif assert(pos == buffer->sample_count); queue_free_audio_buffer(pbc->core.producer_pool, buffer); } #endif //SOFTWARE_SAMPLE_CONVERSION_H #endif ================================================ FILE: src/pico_extras_import.cmake ================================================ # This is a copy of /external/pico_extras_import.cmake # This can be dropped into an external project to help locate pico-extras # It should be include()ed prior to project() if (DEFINED ENV{PICO_EXTRAS_PATH} AND (NOT PICO_EXTRAS_PATH)) set(PICO_EXTRAS_PATH $ENV{PICO_EXTRAS_PATH}) message("Using PICO_EXTRAS_PATH from environment ('${PICO_EXTRAS_PATH}')") endif () if (DEFINED ENV{PICO_EXTRAS_FETCH_FROM_GIT} AND (NOT PICO_EXTRAS_FETCH_FROM_GIT)) set(PICO_EXTRAS_FETCH_FROM_GIT $ENV{PICO_EXTRAS_FETCH_FROM_GIT}) message("Using PICO_EXTRAS_FETCH_FROM_GIT from environment ('${PICO_EXTRAS_FETCH_FROM_GIT}')") endif () if (DEFINED ENV{PICO_EXTRAS_FETCH_FROM_GIT_PATH} AND (NOT PICO_EXTRAS_FETCH_FROM_GIT_PATH)) set(PICO_EXTRAS_FETCH_FROM_GIT_PATH $ENV{PICO_EXTRAS_FETCH_FROM_GIT_PATH}) message("Using PICO_EXTRAS_FETCH_FROM_GIT_PATH from environment ('${PICO_EXTRAS_FETCH_FROM_GIT_PATH}')") endif () if (NOT PICO_EXTRAS_PATH) if (PICO_EXTRAS_FETCH_FROM_GIT) include(FetchContent) set(FETCHCONTENT_BASE_DIR_SAVE ${FETCHCONTENT_BASE_DIR}) if (PICO_EXTRAS_FETCH_FROM_GIT_PATH) get_filename_component(FETCHCONTENT_BASE_DIR "${PICO_EXTRAS_FETCH_FROM_GIT_PATH}" REALPATH BASE_DIR "${CMAKE_SOURCE_DIR}") endif () FetchContent_Declare( PICO_EXTRAS GIT_REPOSITORY https://github.com/raspberrypi/pico-extras GIT_TAG master ) if (NOT PICO_EXTRAS) message("Downloading PICO EXTRAS") FetchContent_Populate(PICO_EXTRAS) set(PICO_EXTRAS_PATH ${PICO_EXTRAS_SOURCE_DIR}) endif () set(FETCHCONTENT_BASE_DIR ${FETCHCONTENT_BASE_DIR_SAVE}) else () if (PICO_SDK_PATH AND EXISTS "${PICO_SDK_PATH}/../pico-extras") set(PICO_EXTRAS_PATH ${PICO_SDK_PATH}/../pico-extras) message("Defaulting PICO_EXTRAS_PATH as sibling of PICO_SDK_PATH: ${PICO_EXTRAS_PATH}") else() message(FATAL_ERROR "PICO EXTRAS location was not specified. Please set PICO_EXTRAS_PATH or set PICO_EXTRAS_FETCH_FROM_GIT to on to fetch from git." ) endif() endif () endif () set(PICO_EXTRAS_PATH "${PICO_EXTRAS_PATH}" CACHE PATH "Path to the PICO EXTRAS") set(PICO_EXTRAS_FETCH_FROM_GIT "${PICO_EXTRAS_FETCH_FROM_GIT}" CACHE BOOL "Set to ON to fetch copy of PICO EXTRAS from git if not otherwise locatable") set(PICO_EXTRAS_FETCH_FROM_GIT_PATH "${PICO_EXTRAS_FETCH_FROM_GIT_PATH}" CACHE FILEPATH "location to download EXTRAS") get_filename_component(PICO_EXTRAS_PATH "${PICO_EXTRAS_PATH}" REALPATH BASE_DIR "${CMAKE_BINARY_DIR}") if (NOT EXISTS ${PICO_EXTRAS_PATH}) message(FATAL_ERROR "Directory '${PICO_EXTRAS_PATH}' not found") endif () set(PICO_EXTRAS_PATH ${PICO_EXTRAS_PATH} CACHE PATH "Path to the PICO EXTRAS" FORCE) add_subdirectory(${PICO_EXTRAS_PATH} pico_extras) ================================================ FILE: src/pico_sdk_import.cmake ================================================ # This is a copy of /external/pico_sdk_import.cmake # This can be dropped into an external project to help locate this SDK # It should be include()ed prior to project() if (DEFINED ENV{PICO_SDK_PATH} AND (NOT PICO_SDK_PATH)) set(PICO_SDK_PATH $ENV{PICO_SDK_PATH}) message("Using PICO_SDK_PATH from environment ('${PICO_SDK_PATH}')") endif () if (DEFINED ENV{PICO_SDK_FETCH_FROM_GIT} AND (NOT PICO_SDK_FETCH_FROM_GIT)) set(PICO_SDK_FETCH_FROM_GIT $ENV{PICO_SDK_FETCH_FROM_GIT}) message("Using PICO_SDK_FETCH_FROM_GIT from environment ('${PICO_SDK_FETCH_FROM_GIT}')") endif () if (DEFINED ENV{PICO_SDK_FETCH_FROM_GIT_PATH} AND (NOT PICO_SDK_FETCH_FROM_GIT_PATH)) set(PICO_SDK_FETCH_FROM_GIT_PATH $ENV{PICO_SDK_FETCH_FROM_GIT_PATH}) message("Using PICO_SDK_FETCH_FROM_GIT_PATH from environment ('${PICO_SDK_FETCH_FROM_GIT_PATH}')") endif () set(PICO_SDK_PATH "${PICO_SDK_PATH}" CACHE PATH "Path to the Raspberry Pi Pico SDK") set(PICO_SDK_FETCH_FROM_GIT "${PICO_SDK_FETCH_FROM_GIT}" CACHE BOOL "Set to ON to fetch copy of SDK from git if not otherwise locatable") set(PICO_SDK_FETCH_FROM_GIT_PATH "${PICO_SDK_FETCH_FROM_GIT_PATH}" CACHE FILEPATH "location to download SDK") if (NOT PICO_SDK_PATH) if (PICO_SDK_FETCH_FROM_GIT) include(FetchContent) set(FETCHCONTENT_BASE_DIR_SAVE ${FETCHCONTENT_BASE_DIR}) if (PICO_SDK_FETCH_FROM_GIT_PATH) get_filename_component(FETCHCONTENT_BASE_DIR "${PICO_SDK_FETCH_FROM_GIT_PATH}" REALPATH BASE_DIR "${CMAKE_SOURCE_DIR}") endif () # GIT_SUBMODULES_RECURSE was added in 3.17 if (${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.17.0") FetchContent_Declare( pico_sdk GIT_REPOSITORY https://github.com/raspberrypi/pico-sdk GIT_TAG master GIT_SUBMODULES_RECURSE FALSE ) else () FetchContent_Declare( pico_sdk GIT_REPOSITORY https://github.com/raspberrypi/pico-sdk GIT_TAG master ) endif () if (NOT pico_sdk) message("Downloading Raspberry Pi Pico SDK") FetchContent_Populate(pico_sdk) set(PICO_SDK_PATH ${pico_sdk_SOURCE_DIR}) endif () set(FETCHCONTENT_BASE_DIR ${FETCHCONTENT_BASE_DIR_SAVE}) else () message(FATAL_ERROR "SDK location was not specified. Please set PICO_SDK_PATH or set PICO_SDK_FETCH_FROM_GIT to on to fetch from git." ) endif () endif () get_filename_component(PICO_SDK_PATH "${PICO_SDK_PATH}" REALPATH BASE_DIR "${CMAKE_BINARY_DIR}") if (NOT EXISTS ${PICO_SDK_PATH}) message(FATAL_ERROR "Directory '${PICO_SDK_PATH}' not found") endif () set(PICO_SDK_INIT_CMAKE_FILE ${PICO_SDK_PATH}/pico_sdk_init.cmake) if (NOT EXISTS ${PICO_SDK_INIT_CMAKE_FILE}) message(FATAL_ERROR "Directory '${PICO_SDK_PATH}' does not appear to contain the Raspberry Pi Pico SDK") endif () set(PICO_SDK_PATH ${PICO_SDK_PATH} CACHE PATH "Path to the Raspberry Pi Pico SDK" FORCE) include(${PICO_SDK_INIT_CMAKE_FILE}) ================================================ FILE: src/pico_support.cpp ================================================ // pico_support.cpp #if (defined ARDUINO_ARCH_RP2040) || (defined ARDUINO_ARCH_RP2350) // ------------- I2S ------------------- #include #include // Create the I2S port using a PIO state machine I2S i2s(INPUT_PULLUP); extern "C" { void pico_setup_i2s(amy_config_t *config); void pico_teardown_i2s(amy_config_t *config); void pico_i2s_read_write_buffer(int16_t *in_samples, const int16_t *out_samples, int nframes); } // Setting of system clock/sampling rate. // On RPi Pico, the system clock rate needs to be a multiple of 512.Fs so the PIO clock can generate 256.Fs MCLK without jitter. // The sysclk also has to be divided down from a multiple of 12 MHz in the range 750..1600 MHz, and the divider is implemented by two div(1..7) dividers. // As a result, we can't hit 44,100 exactly (but we can get within 0.2%), and the exact sys_clk and sample_rate vary. // We predefine settings for each of the possible clock rates from Arduino menu - 50 100 120 125 128 133 150 176 200 225 240 250 276 300 #if AMY_SAMPLE_RATE != 44100 #error "Pico clock setting logic is defined only for sample_rate == 44100." #endif #ifndef F_CPU #define F_CPU 276000000 #endif #if F_CPU == 300000000 || F_CPU == 276000000 // works #define F_CPU_MOD_KHZ 271200 #define F_SAMP 44140 #define VCO_FREQ 1356000000 #define PLL_PD1 5 #define PLL_PD2 1 #elif F_CPU == 250000000 || F_CPU == 240000000 // works #define F_CPU_MOD_KHZ 248000 #define F_SAMP 44034 #define VCO_FREQ 1488000000 #define PLL_PD1 6 #define PLL_PD2 1 #elif F_CPU == 225000000 // works #define F_CPU_MOD_KHZ 226000 #define F_SAMP 44140 #define VCO_FREQ 1356000000 #define PLL_PD1 6 #define PLL_PD2 1 #elif F_CPU == 200000000 // works. LRCK is 43.9 kHz #define F_CPU_MOD_KHZ 203143 #define F_SAMP 44084 #define VCO_FREQ 1422000000 #define PLL_PD1 7 #define PLL_PD2 1 #elif F_CPU == 176000000 // works. LRCK is 43.9 kHz #define F_CPU_MOD_KHZ 180750 #define F_SAMP 44128 #define VCO_FREQ 1446000000 #define PLL_PD1 4 #define PLL_PD2 2 #elif F_CPU == 150000000 // works as long as CPU clock is modified *before* MIDI UART is initialized. LRCK is 44.1 kHz. MCLK is sync'd // If MIDI UART is initialized *before* sys_set_clock_pll in pico_setup_i2s, baud rates are wrong and MIDI doesn't work. #define F_CPU_MOD_KHZ 158000 #define F_SAMP 44084 #define VCO_FREQ 948000000 #define PLL_PD1 6 #define PLL_PD2 1 #elif F_CPU == 133000000 || F_CPU == 128000000 || F_CPU == 125000000 // works #define F_CPU_MOD_KHZ 135428 #define F_SAMP 44084 #define VCO_FREQ 948000000 #define PLL_PD1 7 #define PLL_PD2 1 #elif F_CPU == 120000000 || F_CPU == 100000000 // works #define F_CPU_MOD_KHZ 112800 #define F_SAMP 44062 #define VCO_FREQ 1128000000 #define PLL_PD1 5 #define PLL_PD2 2 #elif F_CPU == 50000000 // works. rp2350 can only run 2 simultaneous juno patch 0s. #define F_CPU_MOD_KHZ 45142 #define F_SAMP 44084 #define VCO_FREQ 948000000 #define PLL_PD1 7 #define PLL_PD2 3 #endif void pico_setup_i2s(amy_config_t *config) { // Hardware limitation to pico assert(config->i2s_lrc == config->i2s_bclk + 1); i2s.setDOUT(config->i2s_dout); if (config->i2s_din != -1) i2s.setDIN(config->i2s_din); i2s.setBCLK(config->i2s_bclk); // mlck must be set before setFrequency() and i2s.begin() if (config->i2s_mclk != -1) { i2s.setMCLK(config->i2s_mclk); // MCLK_mult must be set before i2s.begin() i2s.setMCLKmult(config->i2s_mclk_mult); } i2s.setBitsPerSample(32); // We always run with 32 bit I2S words. // Buffer size is in units of 32 bit words, our I2S samples are 32 bits. i2s.setBuffers(6, AMY_BLOCK_SIZE * AMY_NCHANS, 0); // Set the system clock to a compatible value to the samplerate. // Best to do this before starting anything clock-dependent. // The system clock rate must be an integer multiple of Fs * MCLKmult * 2, e.g. 22.58 MHz // but it also has to be something we can generate with the sysclk PLL i.e. a multiple of // 12 MHz in range 750..1600 MHz, which then divides down by two dividers of 1..7. //set_sys_clock_khz(F_CPU_MOD_KHZ, false); // VCO_FREQ, PLL_PD1, PLL_PD2 from e.g. python pico-sdk/src/rp2_common/hardware_clocks/scripts/vcocalc.py 135.428 set_sys_clock_pll(VCO_FREQ, PLL_PD1, PLL_PD2); // start I2S at the sample rate //i2s.setFrequency(AMY_SAMPLE_RATE); i2s.setFrequency(F_SAMP); // Requested sample rate must be <= effective sample rate coming from sysclk because of int division (?). i2s.begin(); } void pico_teardown_i2s(amy_config_t *config) { i2s.end(); } static int32_t buffer32[AMY_BLOCK_SIZE * AMY_NCHANS]; void pico_i2s_read_write_buffer(int16_t *in_samples, const int16_t *out_samples, int nframes) { // write the same sample twice, once for left and once for the right channel assert(nframes <= AMY_BLOCK_SIZE); i2s.read((uint8_t *)buffer32, (size_t)(nframes * AMY_NCHANS * sizeof(int32_t))); for (int i = 0; i < nframes * AMY_NCHANS; ++i) { in_samples[i] = (int16_t)(buffer32[i] >> 16L); } for (int i = 0; i < nframes * AMY_NCHANS; ++i) { buffer32[i] = (((int32_t)out_samples[i]) << 16); } while (i2s.availableForWrite() == 0) ; // block. i2s.write((const uint8_t *)buffer32, (size_t)(nframes * AMY_NCHANS * sizeof(int32_t))); } // ---- USB gadget ---- //#include //#include #ifdef USE_TUSB #include #endif extern "C" { void check_tusb_midi(); void pico_setup_midi() { #ifdef USE_TUSB if (!TinyUSBDevice.isInitialized()) { TinyUSBDevice.begin(0); } //usb_midi.setStringDescriptor("AMY Synthesizer"); #endif } void pico_teardown_midi() { #ifdef USE_TUSB // There's no TinUSBDevice.end(), so just leave it initialized. #endif } void pico_process_midi() { #ifdef USE_TUSB #ifdef TINYUSB_NEED_POLLING_TASK // Manual call tud_task since it isn't called by Core's background TinyUSBDevice.task(); #endif check_tusb_midi(); #endif } } #endif ================================================ FILE: src/pyamy.c ================================================ #if !defined(ESP_PLATFORM) && !defined(PICO_ON_DEVICE) && !defined(ARDUINO) #include #include #include #include #include "amy.h" #include "amy_midi.h" #include "libminiaudio-audio.h" // Python module wrapper for AMY commands static PyObject * send_wrapper(PyObject *self, PyObject *args) { char *arg1; if (! PyArg_ParseTuple(args, "s", &arg1)) { return NULL; } amy_add_message(arg1); return Py_None; } // Like send_wire but marks the message as coming from an external sysex // source, so file transfer routing (transfer_flag) applies. Used by // amy.transfer_file() to send chunked base64 data after the zT header. static PyObject * send_wire_from_sysex_wrapper(PyObject *self, PyObject *args) { char *arg1; if (! PyArg_ParseTuple(args, "s", &arg1)) { return NULL; } amy_add_message_from_sysex(arg1); return Py_None; } static int parse_live_kwarg(amy_config_t *cfg, const char *key, PyObject *value) { long lv = 0; long long llv = 0; if (strcmp(key, "chorus") == 0) { lv = PyLong_AsLong(value); if (PyErr_Occurred()) return -1; cfg->features.chorus = (lv != 0); return 0; } else if (strcmp(key, "reverb") == 0) { lv = PyLong_AsLong(value); if (PyErr_Occurred()) return -1; cfg->features.reverb = (lv != 0); return 0; } else if (strcmp(key, "echo") == 0) { lv = PyLong_AsLong(value); if (PyErr_Occurred()) return -1; cfg->features.echo = (lv != 0); return 0; } else if (strcmp(key, "audio_in") == 0) { lv = PyLong_AsLong(value); if (PyErr_Occurred()) return -1; cfg->features.audio_in = (lv != 0); return 0; } else if (strcmp(key, "default_synths") == 0) { lv = PyLong_AsLong(value); if (PyErr_Occurred()) return -1; cfg->features.default_synths = (lv != 0); return 0; } else if (strcmp(key, "partials") == 0) { lv = PyLong_AsLong(value); if (PyErr_Occurred()) return -1; cfg->features.partials = (lv != 0); return 0; } else if (strcmp(key, "custom") == 0) { lv = PyLong_AsLong(value); if (PyErr_Occurred()) return -1; cfg->features.custom = (lv != 0); return 0; } else if (strcmp(key, "startup_bleep") == 0) { lv = PyLong_AsLong(value); if (PyErr_Occurred()) return -1; cfg->features.startup_bleep = (lv != 0); return 0; } else if (strcmp(key, "max_oscs") == 0) { lv = PyLong_AsLong(value); if (PyErr_Occurred()) return -1; if (lv < 0 || lv > UINT16_MAX) { PyErr_SetString(PyExc_ValueError, "max_oscs must be in range [0, 65535]"); return -1; } cfg->max_oscs = (uint16_t)lv; return 0; } else if (strcmp(key, "ks_oscs") == 0) { lv = PyLong_AsLong(value); if (PyErr_Occurred()) return -1; if (lv < 0 || lv > UINT8_MAX) { PyErr_SetString(PyExc_ValueError, "ks_oscs must be in range [0, 255]"); return -1; } cfg->ks_oscs = (uint8_t)lv; return 0; } else if (strcmp(key, "max_sequencer_tags") == 0) { llv = PyLong_AsLongLong(value); if (PyErr_Occurred()) return -1; if (llv < 0 || (unsigned long long)llv > UINT32_MAX) { PyErr_SetString(PyExc_ValueError, "max_sequencer_tags must be in range [0, 4294967295]"); return -1; } cfg->max_sequencer_tags = (uint32_t)llv; return 0; } else if (strcmp(key, "max_voices") == 0) { llv = PyLong_AsLongLong(value); if (PyErr_Occurred()) return -1; if (llv < 0 || (unsigned long long)llv > UINT32_MAX) { PyErr_SetString(PyExc_ValueError, "max_voices must be in range [0, 4294967295]"); return -1; } cfg->max_voices = (uint32_t)llv; return 0; } else if (strcmp(key, "max_synths") == 0) { llv = PyLong_AsLongLong(value); if (PyErr_Occurred()) return -1; if (llv < 0 || (unsigned long long)llv > UINT32_MAX) { PyErr_SetString(PyExc_ValueError, "max_synths must be in range [0, 4294967295]"); return -1; } cfg->max_synths = (uint32_t)llv; return 0; } else if (strcmp(key, "max_memory_patches") == 0) { llv = PyLong_AsLongLong(value); if (PyErr_Occurred()) return -1; if (llv < 0 || (unsigned long long)llv > UINT32_MAX) { PyErr_SetString(PyExc_ValueError, "max_memory_patches must be in range [0, 4294967295]"); return -1; } cfg->max_memory_patches = (uint32_t)llv; return 0; } else if (strcmp(key, "capture_device_id") == 0) { lv = PyLong_AsLong(value); if (PyErr_Occurred()) return -1; if (lv < INT8_MIN || lv > INT8_MAX) { PyErr_SetString(PyExc_ValueError, "capture_device_id must be in range [-128, 127]"); return -1; } cfg->capture_device_id = (int8_t)lv; return 0; } else if (strcmp(key, "playback_device_id") == 0) { lv = PyLong_AsLong(value); if (PyErr_Occurred()) return -1; if (lv < INT8_MIN || lv > INT8_MAX) { PyErr_SetString(PyExc_ValueError, "playback_device_id must be in range [-128, 127]"); return -1; } cfg->playback_device_id = (int8_t)lv; return 0; } PyErr_Format(PyExc_TypeError, "live() got an unexpected keyword argument '%s'", key); return -1; } static PyObject * live_wrapper(PyObject *self, PyObject *args, PyObject *kwargs) { amy_stop(); amy_config_t amy_config = amy_global.config; Py_ssize_t pos = 0; PyObject *key_obj = NULL; PyObject *value_obj = NULL; if (PyTuple_Size(args) != 0) { PyErr_SetString(PyExc_TypeError, "live() no longer accepts positional args; use keyword args like live(playback_device_id=..., capture_device_id=...)"); return NULL; } amy_config.features.audio_in = 1; while (kwargs != NULL && PyDict_Next(kwargs, &pos, &key_obj, &value_obj)) { const char *key = PyUnicode_AsUTF8(key_obj); if (key == NULL) return NULL; if (parse_live_kwarg(&amy_config, key, value_obj) != 0) { return NULL; } } amy_config.audio = AMY_AUDIO_IS_MINIAUDIO; amy_start(amy_config); // initializes amy Py_RETURN_NONE; } static PyObject * amystop_wrapper(PyObject *self, PyObject *args) { amy_stop(); return Py_None; } static PyObject * amystart_wrapper(PyObject *self, PyObject *args) { int default_synths = 0; if(PyTuple_Size(args) == 1) { PyArg_ParseTuple(args, "i", &default_synths); } amy_config_t amy_config = amy_global.config; // amy_default_config(); amy_config.features.default_synths = default_synths; amy_start(amy_config); // initializes amy return Py_None; } static PyObject * config_wrapper(PyObject *self, PyObject *args) { PyObject* ret = PyList_New(5); PyList_SetItem(ret, 0, Py_BuildValue("i", AMY_BLOCK_SIZE)); PyList_SetItem(ret, 1, Py_BuildValue("i", AMY_CORES)); PyList_SetItem(ret, 2, Py_BuildValue("i", AMY_NCHANS)); PyList_SetItem(ret, 3, Py_BuildValue("i", AMY_SAMPLE_RATE)); PyList_SetItem(ret, 4, Py_BuildValue("i", AMY_OSCS)); return ret; } static PyObject * render_wrapper(PyObject *self, PyObject *args) { int16_t * result = amy_simple_fill_buffer(); // Create a python list of ints (they are signed shorts that come back) uint16_t bs = AMY_BLOCK_SIZE; if(AMY_NCHANS == 2) { bs = AMY_BLOCK_SIZE*2; } PyObject* ret = PyList_New(bs); for (int i = 0; i < bs; i++) { PyObject* python_int = Py_BuildValue("i", result[i]); PyList_SetItem(ret, i, python_int); } return ret; } static PyObject * inject_midi_wrapper(PyObject *self, PyObject *args) { #define MAX_MIDI_ARGS 16 int data[MAX_MIDI_ARGS]; uint8_t byte_data[MAX_MIDI_ARGS]; uint32_t time = AMY_UNSET_VALUE(time); // But for now we accept only exactly 3 or 4 values: [time,] midi_bytes0..2 if (! PyArg_ParseTuple(args, "iiii", &time, &data[0], &data[1], &data[2])) if (! PyArg_ParseTuple(args, "iii", &data[0], &data[1], &data[2])) return NULL; uint8_t sysex = 0; for (int i = 0; i < 3; ++i) byte_data[i] = (uint8_t)data[i]; amy_event_midi_message_received(byte_data, 3, sysex, time); return Py_None; } static PyObject * get_synth_commands_wrapper(PyObject *self, PyObject *args) { char s[MAX_MESSAGE_LEN]; void *state = NULL; int synth, include_fx; if(!(PyTuple_Size(args) == 1 || PyTuple_Size(args) == 2)) { return NULL; } if (PyTuple_Size(args) == 1) { if (!PyArg_ParseTuple(args, "i", &synth)) return NULL; include_fx = 1; } else { // 2 args if (!PyArg_ParseTuple(args, "ip", &synth, &include_fx)) return NULL; } PyObject* list_obj = PyList_New(0); do { state = yield_synth_commands(synth, s, MAX_MESSAGE_LEN, include_fx, state); int slen = strlen(s); if (slen) PyList_Append(list_obj, PyUnicode_FromString(s)); } while (state != NULL); return list_obj; } static PyMethodDef c_amyMethods[] = { {"render_to_list", render_wrapper, METH_VARARGS, "Render audio"}, {"send_wire", send_wrapper, METH_VARARGS, "Send a message"}, {"send_wire_from_sysex", send_wire_from_sysex_wrapper, METH_VARARGS, "Send a message as if from sysex (for transfer_file)"}, {"live", (PyCFunction)live_wrapper, METH_VARARGS | METH_KEYWORDS, "Live AMY"}, {"start", amystart_wrapper, METH_VARARGS, "Start AMY"}, {"stop", amystop_wrapper, METH_VARARGS, "Stop AMY"}, {"config", config_wrapper, METH_VARARGS, "Return config"}, {"inject_midi", inject_midi_wrapper, METH_VARARGS, "Inject a MIDI message"}, {"get_synth_commands", get_synth_commands_wrapper, METH_VARARGS, "Read synth configuration commands"}, { NULL, NULL, 0, NULL } }; static struct PyModuleDef c_amyDef = { PyModuleDef_HEAD_INIT, "c_amy", /* name of module */ "", /* module documentation, may be NULL */ -1, /* size of per-interpreter state of the module, or -1 if the module keeps state in global variables. */ c_amyMethods }; PyMODINIT_FUNC PyInit_c_amy(void) { // This is the first time it's called, so there's nothing in amy_global. // But for later calls, we copy the existing amy_global.config. amy_config_t amy_config = amy_default_config(); amy_start(amy_config); return PyModule_Create(&c_amyDef); } #endif ================================================ FILE: src/saw_lutset_fxpt.h ================================================ // Automatically-generated LUTset #ifndef LUTSET_SAW_FXPT_DEFINED #define LUTSET_SAW_FXPT_DEFINED #ifndef LUTENTRY_FXPT_DEFINED #define LUTENTRY_FXPT_DEFINED typedef struct { const int16_t *table; int table_size; int log_2_table_size; int highest_harmonic; float scale_factor; } lut_entry_fxpt; #endif // LUTENTRY_FXPT_DEFINED const int16_t saw_fxpt_lutable_0[2048] PROGMEM = { 0,-13422,-24246,-30779,-32768,-31341,-28424,-25913, -24958,-25672,-27313,-28823,-29405,-28879,-27680,-26538, -26055,-26400,-27275,-28123,-28462,-28139,-27380,-26631, -26296,-26513,-27101,-27688,-27927,-27693,-27135,-26574, -26311,-26462,-26901,-27347,-27531,-27348,-26906,-26453, -26233,-26344,-26691,-27050,-27200,-27049,-26682,-26301, -26109,-26193,-26478,-26777,-26903,-26775,-26460,-26130, -25959,-26024,-26263,-26519,-26627,-26516,-26240,-25947, -25791,-25842,-26047,-26270,-26365,-26266,-26020,-25757, -25613,-25652,-25831,-26027,-26112,-26024,-25801,-25561, -25426,-25456,-25614,-25790,-25866,-25785,-25583,-25361, -25234,-25257,-25397,-25555,-25625,-25551,-25364,-25159, -25038,-25054,-25180,-25324,-25387,-25319,-25146,-24954, -24838,-24849,-24962,-25094,-25152,-25089,-24927,-24747, -24636,-24643,-24745,-24866,-24920,-24861,-24709,-24539, -24432,-24434,-24527,-24639,-24689,-24634,-24491,-24329, -24226,-24225,-24309,-24413,-24460,-24408,-24273,-24119, -24019,-24015,-24092,-24188,-24232,-24183,-24055,-23907, -23810,-23803,-23874,-23964,-24006,-23959,-23837,-23695, -23601,-23591,-23656,-23741,-23780,-23736,-23619,-23483, -23390,-23379,-23439,-23518,-23555,-23513,-23401,-23270, -23179,-23166,-23221,-23295,-23330,-23290,-23183,-23056, -22968,-22953,-23003,-23073,-23106,-23068,-22965,-22843, -22756,-22739,-22785,-22852,-22883,-22846,-22747,-22628, -22543,-22525,-22567,-22630,-22660,-22625,-22529,-22414, -22330,-22310,-22350,-22409,-22438,-22404,-22311,-22199, -22117,-22096,-22132,-22188,-22216,-22183,-22094,-21984, -21903,-21881,-21914,-21967,-21994,-21962,-21876,-21769, -21689,-21666,-21696,-21747,-21772,-21742,-21658,-21554, -21475,-21450,-21478,-21526,-21551,-21521,-21440,-21338, -21260,-21235,-21261,-21306,-21330,-21301,-21222,-21123, -21046,-21019,-21043,-21086,-21109,-21081,-21004,-20907, -20831,-20803,-20825,-20866,-20888,-20861,-20786,-20691, -20616,-20588,-20607,-20647,-20667,-20641,-20568,-20475, -20401,-20372,-20389,-20427,-20447,-20422,-20350,-20259, -20185,-20156,-20171,-20207,-20226,-20202,-20133,-20043, -19970,-19939,-19954,-19988,-20006,-19982,-19915,-19827, -19754,-19723,-19736,-19768,-19786,-19763,-19697,-19610, -19538,-19507,-19518,-19549,-19566,-19544,-19479,-19394, -19323,-19290,-19300,-19330,-19346,-19324,-19261,-19178, -19107,-19074,-19082,-19111,-19127,-19105,-19043,-18961, -18891,-18857,-18864,-18891,-18907,-18886,-18825,-18744, -18675,-18641,-18646,-18672,-18687,-18667,-18607,-18528, -18459,-18424,-18429,-18453,-18468,-18448,-18390,-18311, -18242,-18207,-18211,-18234,-18248,-18229,-18172,-18094, -18026,-17991,-17993,-18015,-18029,-18010,-17954,-17878, -17810,-17774,-17775,-17796,-17810,-17791,-17736,-17661, -17593,-17557,-17557,-17578,-17590,-17572,-17518,-17444, -17377,-17340,-17339,-17359,-17371,-17353,-17300,-17227, -17160,-17123,-17122,-17140,-17152,-17135,-17082,-17010, -16944,-16906,-16904,-16921,-16933,-16916,-16864,-16793, -16727,-16689,-16686,-16702,-16714,-16697,-16647,-16576, -16511,-16472,-16468,-16484,-16495,-16478,-16429,-16359, -16294,-16255,-16250,-16265,-16276,-16260,-16211,-16142, -16077,-16038,-16032,-16046,-16057,-16041,-15993,-15925, -15860,-15821,-15814,-15828,-15838,-15822,-15775,-15708, -15644,-15604,-15597,-15609,-15619,-15604,-15557,-15491, -15427,-15387,-15379,-15391,-15400,-15385,-15339,-15273, -15210,-15170,-15161,-15172,-15181,-15167,-15122,-15056, -14993,-14953,-14943,-14953,-14962,-14948,-14904,-14839, -14776,-14736,-14725,-14735,-14743,-14730,-14686,-14622, -14559,-14518,-14507,-14516,-14525,-14511,-14468,-14405, -14342,-14301,-14289,-14298,-14306,-14293,-14250,-14187, -14125,-14084,-14072,-14079,-14087,-14074,-14032,-13970, -13908,-13867,-13854,-13861,-13868,-13856,-13814,-13753, -13691,-13649,-13636,-13643,-13650,-13637,-13597,-13536, -13474,-13432,-13418,-13424,-13431,-13419,-13379,-13318, -13257,-13215,-13200,-13206,-13212,-13200,-13161,-13101, -13040,-12998,-12982,-12987,-12994,-12982,-12943,-12884, -12823,-12780,-12764,-12769,-12775,-12763,-12725,-12666, -12606,-12563,-12547,-12550,-12556,-12545,-12507,-12449, -12389,-12346,-12329,-12332,-12338,-12327,-12289,-12232, -12172,-12128,-12111,-12114,-12119,-12108,-12072,-12014, -11955,-11911,-11893,-11895,-11901,-11890,-11854,-11797, -11737,-11693,-11675,-11677,-11682,-11672,-11636,-11580, -11520,-11476,-11457,-11459,-11464,-11453,-11418,-11362, -11303,-11259,-11239,-11240,-11245,-11235,-11200,-11145, -11086,-11041,-11022,-11022,-11027,-11017,-10982,-10927, -10869,-10824,-10804,-10804,-10808,-10798,-10764,-10710, -10651,-10607,-10586,-10585,-10590,-10580,-10546,-10493, -10434,-10389,-10368,-10367,-10371,-10362,-10329,-10275, -10217,-10172,-10150,-10149,-10153,-10143,-10111,-10058, -10000,-9954,-9932,-9931,-9934,-9925,-9893,-9840, -9782,-9737,-9714,-9712,-9716,-9707,-9675,-9623, -9565,-9519,-9497,-9494,-9497,-9489,-9457,-9405, -9348,-9302,-9279,-9276,-9279,-9270,-9239,-9188, -9130,-9084,-9061,-9058,-9061,-9052,-9021,-8970, -8913,-8867,-8843,-8839,-8842,-8834,-8804,-8753, -8696,-8649,-8625,-8621,-8624,-8616,-8586,-8536, -8479,-8432,-8407,-8403,-8405,-8397,-8368,-8318, -8261,-8215,-8189,-8185,-8187,-8179,-8150,-8101, -8044,-7997,-7972,-7966,-7969,-7961,-7932,-7883, -7827,-7780,-7754,-7748,-7750,-7743,-7714,-7666, -7609,-7562,-7536,-7530,-7532,-7524,-7496,-7448, -7392,-7345,-7318,-7312,-7313,-7306,-7279,-7231, -7174,-7127,-7100,-7093,-7095,-7088,-7061,-7013, -6957,-6910,-6882,-6875,-6877,-6870,-6843,-6796, -6740,-6692,-6664,-6657,-6658,-6652,-6625,-6578, -6522,-6475,-6447,-6439,-6440,-6433,-6407,-6361, -6305,-6257,-6229,-6221,-6222,-6215,-6189,-6143, -6088,-6040,-6011,-6002,-6003,-5997,-5971,-5926, -5870,-5822,-5793,-5784,-5785,-5779,-5754,-5708, -5653,-5604,-5575,-5566,-5567,-5561,-5536,-5490, -5435,-5387,-5357,-5348,-5348,-5342,-5318,-5273, -5218,-5169,-5139,-5130,-5130,-5124,-5100,-5055, -5001,-4952,-4922,-4911,-4912,-4906,-4882,-4838, -4783,-4734,-4704,-4693,-4693,-4688,-4664,-4620, -4566,-4517,-4486,-4475,-4475,-4470,-4446,-4403, -4348,-4299,-4268,-4257,-4257,-4252,-4229,-4185, -4131,-4082,-4050,-4039,-4038,-4033,-4011,-3968, -3914,-3864,-3832,-3821,-3820,-3815,-3793,-3750, -3696,-3647,-3614,-3602,-3602,-3597,-3575,-3533, -3479,-3429,-3397,-3384,-3383,-3379,-3357,-3315, -3261,-3212,-3179,-3166,-3165,-3161,-3139,-3098, -3044,-2994,-2961,-2948,-2947,-2942,-2921,-2880, -2827,-2776,-2743,-2730,-2729,-2724,-2704,-2662, -2609,-2559,-2525,-2512,-2510,-2506,-2486,-2445, -2392,-2341,-2307,-2293,-2292,-2288,-2268,-2227, -2174,-2124,-2089,-2075,-2074,-2070,-2050,-2010, -1957,-1906,-1872,-1857,-1855,-1852,-1832,-1792, -1739,-1689,-1654,-1639,-1637,-1634,-1614,-1575, -1522,-1471,-1436,-1421,-1419,-1415,-1396,-1357, -1305,-1254,-1218,-1203,-1201,-1197,-1179,-1140, -1087,-1036,-1000,-984,-982,-979,-961,-922, -870,-818,-782,-766,-764,-761,-743,-704, -652,-601,-564,-548,-546,-543,-525,-487, -435,-383,-347,-330,-327,-325,-307,-269, -217,-166,-129,-112,-109,-106,-89,-52, 0,52,89,106,109,112,129,166, 217,269,307,325,327,330,347,383, 435,487,525,543,546,548,564,601, 652,704,743,761,764,766,782,818, 870,922,961,979,982,984,1000,1036, 1087,1140,1179,1197,1201,1203,1218,1254, 1305,1357,1396,1415,1419,1421,1436,1471, 1522,1575,1614,1634,1637,1639,1654,1689, 1739,1792,1832,1852,1855,1857,1872,1906, 1957,2010,2050,2070,2074,2075,2089,2124, 2174,2227,2268,2288,2292,2293,2307,2341, 2392,2445,2486,2506,2510,2512,2525,2559, 2609,2662,2704,2724,2729,2730,2743,2776, 2827,2880,2921,2942,2947,2948,2961,2994, 3044,3098,3139,3161,3165,3166,3179,3212, 3261,3315,3357,3379,3383,3384,3397,3429, 3479,3533,3575,3597,3602,3602,3614,3647, 3696,3750,3793,3815,3820,3821,3832,3864, 3914,3968,4011,4033,4038,4039,4050,4082, 4131,4185,4229,4252,4257,4257,4268,4299, 4348,4403,4446,4470,4475,4475,4486,4517, 4566,4620,4664,4688,4693,4693,4704,4734, 4783,4838,4882,4906,4912,4911,4922,4952, 5001,5055,5100,5124,5130,5130,5139,5169, 5218,5273,5318,5342,5348,5348,5357,5387, 5435,5490,5536,5561,5567,5566,5575,5604, 5653,5708,5754,5779,5785,5784,5793,5822, 5870,5926,5971,5997,6003,6002,6011,6040, 6088,6143,6189,6215,6222,6221,6229,6257, 6305,6361,6407,6433,6440,6439,6447,6475, 6522,6578,6625,6652,6658,6657,6664,6692, 6740,6796,6843,6870,6877,6875,6882,6910, 6957,7013,7061,7088,7095,7093,7100,7127, 7174,7231,7279,7306,7313,7312,7318,7345, 7392,7448,7496,7524,7532,7530,7536,7562, 7609,7666,7714,7743,7750,7748,7754,7780, 7827,7883,7932,7961,7969,7966,7972,7997, 8044,8101,8150,8179,8187,8185,8189,8215, 8261,8318,8368,8397,8405,8403,8407,8432, 8479,8536,8586,8616,8624,8621,8625,8649, 8696,8753,8804,8834,8842,8839,8843,8867, 8913,8970,9021,9052,9061,9058,9061,9084, 9130,9188,9239,9270,9279,9276,9279,9302, 9348,9405,9457,9489,9497,9494,9497,9519, 9565,9623,9675,9707,9716,9712,9714,9737, 9782,9840,9893,9925,9934,9931,9932,9954, 10000,10058,10111,10143,10153,10149,10150,10172, 10217,10275,10329,10362,10371,10367,10368,10389, 10434,10493,10546,10580,10590,10585,10586,10607, 10651,10710,10764,10798,10808,10804,10804,10824, 10869,10927,10982,11017,11027,11022,11022,11041, 11086,11145,11200,11235,11245,11240,11239,11259, 11303,11362,11418,11453,11464,11459,11457,11476, 11520,11580,11636,11672,11682,11677,11675,11693, 11737,11797,11854,11890,11901,11895,11893,11911, 11955,12014,12072,12108,12119,12114,12111,12128, 12172,12232,12289,12327,12338,12332,12329,12346, 12389,12449,12507,12545,12556,12550,12547,12563, 12606,12666,12725,12763,12775,12769,12764,12780, 12823,12884,12943,12982,12994,12987,12982,12998, 13040,13101,13161,13200,13212,13206,13200,13215, 13257,13318,13379,13419,13431,13424,13418,13432, 13474,13536,13597,13637,13650,13643,13636,13649, 13691,13753,13814,13856,13868,13861,13854,13867, 13908,13970,14032,14074,14087,14079,14072,14084, 14125,14187,14250,14293,14306,14298,14289,14301, 14342,14405,14468,14511,14525,14516,14507,14518, 14559,14622,14686,14730,14743,14735,14725,14736, 14776,14839,14904,14948,14962,14953,14943,14953, 14993,15056,15122,15167,15181,15172,15161,15170, 15210,15273,15339,15385,15400,15391,15379,15387, 15427,15491,15557,15604,15619,15609,15597,15604, 15644,15708,15775,15822,15838,15828,15814,15821, 15860,15925,15993,16041,16057,16046,16032,16038, 16077,16142,16211,16260,16276,16265,16250,16255, 16294,16359,16429,16478,16495,16484,16468,16472, 16511,16576,16647,16697,16714,16702,16686,16689, 16727,16793,16864,16916,16933,16921,16904,16906, 16944,17010,17082,17135,17152,17140,17122,17123, 17160,17227,17300,17353,17371,17359,17339,17340, 17377,17444,17518,17572,17590,17578,17557,17557, 17593,17661,17736,17791,17810,17796,17775,17774, 17810,17878,17954,18010,18029,18015,17993,17991, 18026,18094,18172,18229,18248,18234,18211,18207, 18242,18311,18390,18448,18468,18453,18429,18424, 18459,18528,18607,18667,18687,18672,18646,18641, 18675,18744,18825,18886,18907,18891,18864,18857, 18891,18961,19043,19105,19127,19111,19082,19074, 19107,19178,19261,19324,19346,19330,19300,19290, 19323,19394,19479,19544,19566,19549,19518,19507, 19538,19610,19697,19763,19786,19768,19736,19723, 19754,19827,19915,19982,20006,19988,19954,19939, 19970,20043,20133,20202,20226,20207,20171,20156, 20185,20259,20350,20422,20447,20427,20389,20372, 20401,20475,20568,20641,20667,20647,20607,20588, 20616,20691,20786,20861,20888,20866,20825,20803, 20831,20907,21004,21081,21109,21086,21043,21019, 21046,21123,21222,21301,21330,21306,21261,21235, 21260,21338,21440,21521,21551,21526,21478,21450, 21475,21554,21658,21742,21772,21747,21696,21666, 21689,21769,21876,21962,21994,21967,21914,21881, 21903,21984,22094,22183,22216,22188,22132,22096, 22117,22199,22311,22404,22438,22409,22350,22310, 22330,22414,22529,22625,22660,22630,22567,22525, 22543,22628,22747,22846,22883,22852,22785,22739, 22756,22843,22965,23068,23106,23073,23003,22953, 22968,23056,23183,23290,23330,23295,23221,23166, 23179,23270,23401,23513,23555,23518,23439,23379, 23390,23483,23619,23736,23780,23741,23656,23591, 23601,23695,23837,23959,24006,23964,23874,23803, 23810,23907,24055,24183,24232,24188,24092,24015, 24019,24119,24273,24408,24460,24413,24309,24225, 24226,24329,24491,24634,24689,24639,24527,24434, 24432,24539,24709,24861,24920,24866,24745,24643, 24636,24747,24927,25089,25152,25094,24962,24849, 24838,24954,25146,25319,25387,25324,25180,25054, 25038,25159,25364,25551,25625,25555,25397,25257, 25234,25361,25583,25785,25866,25790,25614,25456, 25426,25561,25801,26024,26112,26027,25831,25652, 25613,25757,26020,26266,26365,26270,26047,25842, 25791,25947,26240,26516,26627,26519,26263,26024, 25959,26130,26460,26775,26903,26777,26478,26193, 26109,26301,26682,27049,27200,27050,26691,26344, 26233,26453,26906,27348,27531,27347,26901,26462, 26311,26574,27135,27693,27927,27688,27101,26513, 26296,26631,27380,28139,28462,28123,27275,26400, 26055,26538,27680,28879,29405,28823,27313,25672, 24958,25913,28424,31341,32767,30779,24246,13422, }; const int16_t saw_fxpt_lutable_1[2048] PROGMEM = { 0,-9680,-18396,-25357,-30080,-32461,-32768,-31558, -29546,-27445,-25831,-25039,-25135,-25944,-27128,-28297, -29119,-29397,-29108,-28386,-27474,-26641,-26109,-25997, -26293,-26870,-27533,-28077,-28346,-28274,-27896,-27335, -26756,-26320,-26137,-26238,-26570,-27014,-27429,-27687, -27712,-27501,-27119,-26678,-26300,-26086,-26083,-26275, -26589,-26920,-27164,-27243,-27133,-26865,-26516,-26184, -25956,-25888,-25987,-26210,-26479,-26705,-26816,-26773, -26588,-26310,-26016,-25785,-25676,-25708,-25860,-26077, -26283,-26411,-26417,-26295,-26075,-25817,-25590,-25453, -25435,-25530,-25701,-25885,-26022,-26062,-25989,-25819, -25595,-25378,-25223,-25167,-25215,-25344,-25505,-25642, -25707,-25674,-25547,-25357,-25153,-24988,-24903,-24912, -25003,-25139,-25272,-25353,-25352,-25263,-25104,-24917, -24749,-24642,-24618,-24674,-24785,-24909,-25000,-25024, -24967,-24839,-24671,-24505,-24383,-24331,-24357,-24442, -24553,-24649,-24692,-24664,-24564,-24417,-24257,-24125, -24051,-24049,-24109,-24205,-24299,-24357,-24352,-24280, -24153,-24004,-23867,-23776,-23749,-23784,-23863,-23953, -24019,-24035,-23987,-23882,-23745,-23608,-23504,-23456, -23468,-23528,-23610,-23681,-23712,-23686,-23603,-23481, -23348,-23235,-23168,-23159,-23200,-23271,-23343,-23386, -23379,-23317,-23211,-23084,-22967,-22886,-22856,-22879, -22937,-23006,-23057,-23067,-23024,-22935,-22818,-22700, -22608,-22560,-22564,-22608,-22671,-22727,-22750,-22725, -22653,-22547,-22431,-22332,-22270,-22255,-22284,-22339, -22396,-22429,-22420,-22366,-22273,-22162,-22058,-21983, -21952,-21965,-22010,-22065,-22105,-22111,-22072,-21993, -21890,-21785,-21701,-21655,-21652,-21685,-21735,-21779, -21796,-21773,-21709,-21615,-21511,-21421,-21362,-21344, -21364,-21407,-21453,-21479,-21470,-21420,-21337,-21237, -21143,-21073,-21041,-21048,-21082,-21126,-21159,-21161, -21126,-21055,-20961,-20866,-20788,-20743,-20736,-20760, -20801,-20837,-20849,-20827,-20769,-20683,-20589,-20505, -20449,-20428,-20442,-20476,-20513,-20534,-20524,-20478, -20403,-20311,-20224,-20158,-20125,-20127,-20154,-20190, -20216,-20217,-20184,-20118,-20033,-19944,-19871,-19827, -19816,-19834,-19867,-19897,-19906,-19885,-19831,-19752, -19665,-19586,-19532,-19509,-19517,-19545,-19576,-19592, -19582,-19539,-19469,-19385,-19303,-19240,-19207,-19204, -19225,-19255,-19276,-19275,-19244,-19183,-19104,-19021, -18951,-18908,-18894,-18907,-18934,-18959,-18966,-18945, -18894,-18821,-18739,-18665,-18612,-18588,-18592,-18614, -18640,-18653,-18642,-18602,-18537,-18458,-18380,-18320, -18285,-18280,-18296,-18320,-18338,-18336,-18306,-18249, -18175,-18097,-18030,-17986,-17971,-17979,-18001,-18022, -18027,-18007,-17959,-17891,-17813,-17742,-17690,-17665, -17665,-17683,-17705,-17716,-17704,-17666,-17605,-17530, -17456,-17397,-17363,-17354,-17366,-17387,-17402,-17399, -17370,-17316,-17246,-17171,-17107,-17064,-17046,-17051, -17069,-17087,-17090,-17070,-17025,-16960,-16887,-16818, -16767,-16741,-16738,-16753,-16771,-16779,-16768,-16731, -16673,-16602,-16531,-16474,-16439,-16428,-16437,-16454, -16466,-16462,-16435,-16384,-16316,-16245,-16183,-16140, -16121,-16123,-16138,-16152,-16154,-16135,-16092,-16030, -15959,-15893,-15843,-15816,-15811,-15822,-15837,-15844, -15832,-15797,-15742,-15674,-15605,-15549,-15514,-15501, -15507,-15522,-15532,-15527,-15500,-15451,-15387,-15318, -15258,-15215,-15194,-15194,-15206,-15218,-15219,-15200, -15159,-15100,-15032,-14968,-14918,-14890,-14883,-14891, -14904,-14909,-14898,-14864,-14810,-14745,-14679,-14624, -14588,-14574,-14577,-14589,-14598,-14592,-14566,-14520, -14458,-14391,-14332,-14289,-14267,-14265,-14275,-14285, -14285,-14266,-14226,-14169,-14104,-14041,-13993,-13963, -13955,-13961,-13971,-13975,-13964,-13931,-13880,-13816, -13752,-13698,-13662,-13646,-13648,-13657,-13664,-13658, -13633,-13588,-13528,-13464,-13406,-13363,-13340,-13336, -13343,-13352,-13351,-13333,-13294,-13239,-13176,-13115, -13066,-13036,-13026,-13030,-13039,-13042,-13030,-12999, -12949,-12888,-12825,-12772,-12735,-12718,-12718,-12726, -12731,-12725,-12700,-12657,-12599,-12536,-12479,-12436, -12413,-12407,-12412,-12419,-12418,-12400,-12363,-12309, -12248,-12188,-12139,-12109,-12097,-12100,-12107,-12109, -12097,-12066,-12018,-11959,-11898,-11845,-11808,-11790, -11788,-11794,-11799,-11792,-11768,-11726,-11670,-11608, -11552,-11509,-11485,-11477,-11481,-11487,-11485,-11467, -11431,-11379,-11319,-11260,-11212,-11181,-11168,-11169, -11175,-11176,-11164,-11135,-11088,-11030,-10970,-10918, -10880,-10861,-10858,-10863,-10866,-10859,-10836,-10795, -10740,-10680,-10624,-10582,-10556,-10548,-10550,-10555, -10552,-10535,-10500,-10450,-10391,-10333,-10285,-10253, -10239,-10239,-10243,-10244,-10232,-10203,-10158,-10101, -10042,-9990,-9953,-9932,-9928,-9931,-9934,-9927, -9904,-9864,-9811,-9752,-9697,-9654,-9628,-9618, -9619,-9623,-9620,-9603,-9569,-9520,-9462,-9405, -9357,-9325,-9310,-9308,-9312,-9312,-9300,-9272, -9227,-9172,-9114,-9062,-9024,-9003,-8997,-9000, -9002,-8995,-8973,-8934,-8881,-8823,-8769,-8726, -8699,-8688,-8688,-8691,-8688,-8671,-8638,-8590, -8533,-8477,-8429,-8397,-8380,-8377,-8380,-8380, -8368,-8341,-8297,-8243,-8186,-8134,-8096,-8074, -8067,-8069,-8070,-8063,-8041,-8003,-7952,-7895, -7841,-7798,-7770,-7758,-7758,-7760,-7756,-7740, -7707,-7660,-7604,-7548,-7501,-7468,-7451,-7447, -7449,-7448,-7437,-7410,-7367,-7314,-7257,-7206, -7168,-7145,-7137,-7138,-7139,-7132,-7110,-7073, -7023,-6966,-6912,-6869,-6841,-6828,-6827,-6828, -6825,-6809,-6777,-6731,-6676,-6620,-6573,-6539, -6521,-6516,-6518,-6517,-6505,-6479,-6437,-6385, -6329,-6278,-6239,-6216,-6207,-6207,-6207,-6200, -6179,-6143,-6093,-6038,-5984,-5940,-5912,-5898, -5896,-5897,-5893,-5878,-5846,-5801,-5747,-5692, -5644,-5610,-5591,-5586,-5586,-5585,-5574,-5548, -5508,-5456,-5400,-5349,-5310,-5286,-5276,-5276, -5276,-5269,-5248,-5213,-5164,-5109,-5055,-5012, -4982,-4968,-4965,-4966,-4962,-4947,-4916,-4871, -4818,-4763,-4715,-4681,-4661,-4655,-4655,-4654, -4643,-4618,-4578,-4526,-4471,-4420,-4381,-4356, -4346,-4345,-4345,-4338,-4318,-4283,-4235,-4180, -4127,-4083,-4053,-4038,-4034,-4035,-4031,-4016, -3986,-3942,-3889,-3834,-3786,-3751,-3731,-3724, -3724,-3723,-3712,-3687,-3648,-3597,-3542,-3492, -3452,-3427,-3415,-3414,-3413,-3407,-3387,-3353, -3305,-3251,-3198,-3154,-3123,-3108,-3103,-3103, -3100,-3085,-3056,-3013,-2960,-2905,-2857,-2822, -2801,-2794,-2793,-2792,-2781,-2757,-2718,-2668, -2614,-2563,-2522,-2497,-2485,-2483,-2482,-2476, -2457,-2423,-2376,-2322,-2269,-2225,-2194,-2177, -2173,-2172,-2169,-2155,-2126,-2083,-2031,-1977, -1928,-1892,-1871,-1863,-1862,-1860,-1851,-1827, -1789,-1739,-1685,-1634,-1593,-1567,-1554,-1552, -1551,-1545,-1526,-1493,-1447,-1393,-1340,-1295, -1264,-1247,-1242,-1241,-1238,-1224,-1196,-1154, -1102,-1048,-999,-963,-941,-932,-931,-930, -920,-897,-859,-810,-756,-705,-663,-636, -624,-621,-620,-614,-596,-564,-518,-464, -411,-366,-334,-316,-311,-310,-307,-294, -266,-225,-173,-119,-70,-33,-11,-1, 0,1,11,33,70,119,173,225, 266,294,307,310,311,316,334,366, 411,464,518,564,596,614,620,621, 624,636,663,705,756,810,859,897, 920,930,931,932,941,963,999,1048, 1102,1154,1196,1224,1238,1241,1242,1247, 1264,1295,1340,1393,1447,1493,1526,1545, 1551,1552,1554,1567,1593,1634,1685,1739, 1789,1827,1851,1860,1862,1863,1871,1892, 1928,1977,2031,2083,2126,2155,2169,2172, 2173,2177,2194,2225,2269,2322,2376,2423, 2457,2476,2482,2483,2485,2497,2522,2563, 2614,2668,2718,2757,2781,2792,2793,2794, 2801,2822,2857,2905,2960,3013,3056,3085, 3100,3103,3103,3108,3123,3154,3198,3251, 3305,3353,3387,3407,3413,3414,3415,3427, 3452,3492,3542,3597,3648,3687,3712,3723, 3724,3724,3731,3751,3786,3834,3889,3942, 3986,4016,4031,4035,4034,4038,4053,4083, 4127,4180,4235,4283,4318,4338,4345,4345, 4346,4356,4381,4420,4471,4526,4578,4618, 4643,4654,4655,4655,4661,4681,4715,4763, 4818,4871,4916,4947,4962,4966,4965,4968, 4982,5012,5055,5109,5164,5213,5248,5269, 5276,5276,5276,5286,5310,5349,5400,5456, 5508,5548,5574,5585,5586,5586,5591,5610, 5644,5692,5747,5801,5846,5878,5893,5897, 5896,5898,5912,5940,5984,6038,6093,6143, 6179,6200,6207,6207,6207,6216,6239,6278, 6329,6385,6437,6479,6505,6517,6518,6516, 6521,6539,6573,6620,6676,6731,6777,6809, 6825,6828,6827,6828,6841,6869,6912,6966, 7023,7073,7110,7132,7139,7138,7137,7145, 7168,7206,7257,7314,7367,7410,7437,7448, 7449,7447,7451,7468,7501,7548,7604,7660, 7707,7740,7756,7760,7758,7758,7770,7798, 7841,7895,7952,8003,8041,8063,8070,8069, 8067,8074,8096,8134,8186,8243,8297,8341, 8368,8380,8380,8377,8380,8397,8429,8477, 8533,8590,8638,8671,8688,8691,8688,8688, 8699,8726,8769,8823,8881,8934,8973,8995, 9002,9000,8997,9003,9024,9062,9114,9172, 9227,9272,9300,9312,9312,9308,9310,9325, 9357,9405,9462,9520,9569,9603,9620,9623, 9619,9618,9628,9654,9697,9752,9811,9864, 9904,9927,9934,9931,9928,9932,9953,9990, 10042,10101,10158,10203,10232,10244,10243,10239, 10239,10253,10285,10333,10391,10450,10500,10535, 10552,10555,10550,10548,10556,10582,10624,10680, 10740,10795,10836,10859,10866,10863,10858,10861, 10880,10918,10970,11030,11088,11135,11164,11176, 11175,11169,11168,11181,11212,11260,11319,11379, 11431,11467,11485,11487,11481,11477,11485,11509, 11552,11608,11670,11726,11768,11792,11799,11794, 11788,11790,11808,11845,11898,11959,12018,12066, 12097,12109,12107,12100,12097,12109,12139,12188, 12248,12309,12363,12400,12418,12419,12412,12407, 12413,12436,12479,12536,12599,12657,12700,12725, 12731,12726,12718,12718,12735,12772,12825,12888, 12949,12999,13030,13042,13039,13030,13026,13036, 13066,13115,13176,13239,13294,13333,13351,13352, 13343,13336,13340,13363,13406,13464,13528,13588, 13633,13658,13664,13657,13648,13646,13662,13698, 13752,13816,13880,13931,13964,13975,13971,13961, 13955,13963,13993,14041,14104,14169,14226,14266, 14285,14285,14275,14265,14267,14289,14332,14391, 14458,14520,14566,14592,14598,14589,14577,14574, 14588,14624,14679,14745,14810,14864,14898,14909, 14904,14891,14883,14890,14918,14968,15032,15100, 15159,15200,15219,15218,15206,15194,15194,15215, 15258,15318,15387,15451,15500,15527,15532,15522, 15507,15501,15514,15549,15605,15674,15742,15797, 15832,15844,15837,15822,15811,15816,15843,15893, 15959,16030,16092,16135,16154,16152,16138,16123, 16121,16140,16183,16245,16316,16384,16435,16462, 16466,16454,16437,16428,16439,16474,16531,16602, 16673,16731,16768,16779,16771,16753,16738,16741, 16767,16818,16887,16960,17025,17070,17090,17087, 17069,17051,17046,17064,17107,17171,17246,17316, 17370,17399,17402,17387,17366,17354,17363,17397, 17456,17530,17605,17666,17704,17716,17705,17683, 17665,17665,17690,17742,17813,17891,17959,18007, 18027,18022,18001,17979,17971,17986,18030,18097, 18175,18249,18306,18336,18338,18320,18296,18280, 18285,18320,18380,18458,18537,18602,18642,18653, 18640,18614,18592,18588,18612,18665,18739,18821, 18894,18945,18966,18959,18934,18907,18894,18908, 18951,19021,19104,19183,19244,19275,19276,19255, 19225,19204,19207,19240,19303,19385,19469,19539, 19582,19592,19576,19545,19517,19509,19532,19586, 19665,19752,19831,19885,19906,19897,19867,19834, 19816,19827,19871,19944,20033,20118,20184,20217, 20216,20190,20154,20127,20125,20158,20224,20311, 20403,20478,20524,20534,20513,20476,20442,20428, 20449,20505,20589,20683,20769,20827,20849,20837, 20801,20760,20736,20743,20788,20866,20961,21055, 21126,21161,21159,21126,21082,21048,21041,21073, 21143,21237,21337,21420,21470,21479,21453,21407, 21364,21344,21362,21421,21511,21615,21709,21773, 21796,21779,21735,21685,21652,21655,21701,21785, 21890,21993,22072,22111,22105,22065,22010,21965, 21952,21983,22058,22162,22273,22366,22420,22429, 22396,22339,22284,22255,22270,22332,22431,22547, 22653,22725,22750,22727,22671,22608,22564,22560, 22608,22700,22818,22935,23024,23067,23057,23006, 22937,22879,22856,22886,22967,23084,23211,23317, 23379,23386,23343,23271,23200,23159,23168,23235, 23348,23481,23603,23686,23712,23681,23610,23528, 23468,23456,23504,23608,23745,23882,23987,24035, 24019,23953,23863,23784,23749,23776,23867,24004, 24153,24280,24352,24357,24299,24205,24109,24049, 24051,24125,24257,24417,24564,24664,24692,24649, 24553,24442,24357,24331,24383,24505,24671,24839, 24967,25024,25000,24909,24785,24674,24618,24642, 24749,24917,25104,25263,25352,25353,25272,25139, 25003,24912,24903,24988,25153,25357,25547,25674, 25707,25642,25505,25344,25215,25167,25223,25378, 25595,25819,25989,26062,26022,25885,25701,25530, 25435,25453,25590,25817,26075,26295,26417,26411, 26283,26077,25860,25708,25676,25785,26016,26310, 26588,26773,26816,26705,26479,26210,25987,25888, 25956,26184,26516,26865,27133,27243,27164,26920, 26589,26275,26083,26086,26300,26678,27119,27501, 27712,27687,27429,27014,26570,26238,26137,26320, 26756,27335,27896,28274,28346,28077,27533,26870, 26293,25997,26109,26641,27474,28386,29108,29397, 29119,28297,27128,25944,25135,25039,25831,27445, 29546,31558,32767,32461,30080,25357,18396,9680, }; const int16_t saw_fxpt_lutable_2[1024] PROGMEM = { 0,-13415,-24237,-30775,-32768,-31333,-28390,-25833, -24824,-25487,-27096,-28594,-29174,-28644,-27425,-26242, -25705,-26000,-26839,-27672,-28010,-27683,-26905,-26118, -25730,-25895,-26447,-27017,-27254,-27017,-26441,-25841, -25526,-25625,-26027,-26456,-26638,-26452,-25992,-25502, -25230,-25289,-25598,-25939,-26086,-25933,-25549,-25131, -24888,-24919,-25166,-25447,-25569,-25439,-25108,-24741, -24518,-24531,-24731,-24968,-25074,-24960,-24668,-24340, -24132,-24130,-24296,-24500,-24592,-24491,-24229,-23930, -23735,-23721,-23860,-24038,-24119,-24028,-23791,-23516, -23330,-23307,-23424,-23580,-23653,-23571,-23353,-23097, -22919,-22888,-22988,-23126,-23191,-23116,-22915,-22675, -22504,-22467,-22551,-22675,-22734,-22665,-22478,-22251, -22085,-22043,-22114,-22225,-22280,-22215,-22040,-21825, -21664,-21617,-21678,-21778,-21827,-21767,-21603,-21398, -21241,-21190,-21241,-21331,-21377,-21321,-21165,-20970, -20816,-20762,-20804,-20886,-20928,-20875,-20728,-20540, -20390,-20332,-20367,-20441,-20480,-20431,-20290,-20110, -19963,-19902,-19930,-19997,-20034,-19987,-19853,-19679, -19535,-19471,-19493,-19554,-19588,-19544,-19416,-19248, -19106,-19040,-19056,-19112,-19143,-19101,-18979,-18816, -18676,-18608,-18619,-18670,-18699,-18659,-18541,-18383, -18245,-18175,-18181,-18228,-18256,-18217,-18104,-17950, -17814,-17742,-17744,-17786,-17813,-17776,-17667,-17517, -17383,-17309,-17307,-17345,-17370,-17335,-17230,-17084, -16951,-16876,-16870,-16905,-16927,-16894,-16792,-16650, -16519,-16442,-16433,-16464,-16485,-16453,-16355,-16216, -16086,-16008,-15996,-16024,-16044,-16013,-15918,-15782, -15654,-15574,-15559,-15584,-15602,-15573,-15481,-15348, -15220,-15140,-15122,-15144,-15161,-15133,-15043,-14914, -14787,-14706,-14684,-14704,-14720,-14693,-14606,-14479, -14354,-14271,-14247,-14264,-14279,-14253,-14169,-14044, -13920,-13836,-13810,-13824,-13839,-13814,-13732,-13609, -13486,-13402,-13373,-13385,-13398,-13374,-13295,-13175, -13052,-12967,-12936,-12946,-12958,-12935,-12857,-12740, -12618,-12532,-12499,-12506,-12518,-12495,-12420,-12304, -12184,-12097,-12062,-12067,-12078,-12056,-11983,-11869, -11749,-11661,-11624,-11628,-11638,-11617,-11546,-11434, -11315,-11226,-11187,-11189,-11198,-11178,-11109,-10999, -10880,-10791,-10750,-10750,-10759,-10739,-10671,-10563, -10446,-10355,-10313,-10311,-10319,-10300,-10234,-10128, -10011,-9920,-9876,-9872,-9879,-9861,-9797,-9692, -9576,-9484,-9439,-9433,-9440,-9423,-9360,-9257, -9141,-9049,-9001,-8995,-9000,-8984,-8923,-8821, -8706,-8613,-8564,-8556,-8561,-8545,-8486,-8385, -8271,-8178,-8127,-8117,-8122,-8106,-8048,-7950, -7836,-7742,-7690,-7678,-7682,-7668,-7611,-7514, -7401,-7306,-7253,-7240,-7243,-7229,-7174,-7078, -6966,-6871,-6816,-6801,-6804,-6790,-6737,-6643, -6531,-6435,-6378,-6363,-6365,-6352,-6300,-6207, -6096,-5999,-5941,-5924,-5926,-5913,-5862,-5771, -5660,-5563,-5504,-5486,-5487,-5475,-5425,-5335, -5225,-5127,-5067,-5047,-5048,-5036,-4988,-4899, -4790,-4691,-4630,-4609,-4609,-4598,-4551,-4463, -4354,-4256,-4193,-4170,-4170,-4159,-4114,-4027, -3919,-3820,-3755,-3732,-3731,-3721,-3677,-3591, -3484,-3384,-3318,-3293,-3292,-3283,-3239,-3156, -3048,-2948,-2881,-2855,-2853,-2844,-2802,-2720, -2613,-2512,-2444,-2417,-2414,-2406,-2365,-2284, -2177,-2076,-2007,-1978,-1975,-1967,-1928,-1848, -1742,-1640,-1570,-1540,-1536,-1529,-1491,-1412, -1306,-1204,-1132,-1101,-1097,-1091,-1053,-976, -871,-768,-695,-663,-658,-652,-616,-540, -435,-332,-258,-225,-219,-214,-179,-104, 0,104,179,214,219,225,258,332, 435,540,616,652,658,663,695,768, 871,976,1053,1091,1097,1101,1132,1204, 1306,1412,1491,1529,1536,1540,1570,1640, 1742,1848,1928,1967,1975,1978,2007,2076, 2177,2284,2365,2406,2414,2417,2444,2512, 2613,2720,2802,2844,2853,2855,2881,2948, 3048,3156,3239,3283,3292,3293,3318,3384, 3484,3591,3677,3721,3731,3732,3755,3820, 3919,4027,4114,4159,4170,4170,4193,4256, 4354,4463,4551,4598,4609,4609,4630,4691, 4790,4899,4988,5036,5048,5047,5067,5127, 5225,5335,5425,5475,5487,5486,5504,5563, 5660,5771,5862,5913,5926,5924,5941,5999, 6096,6207,6300,6352,6365,6363,6378,6435, 6531,6643,6737,6790,6804,6801,6816,6871, 6966,7078,7174,7229,7243,7240,7253,7306, 7401,7514,7611,7668,7682,7678,7690,7742, 7836,7950,8048,8106,8122,8117,8127,8178, 8271,8385,8486,8545,8561,8556,8564,8613, 8706,8821,8923,8984,9000,8995,9001,9049, 9141,9257,9360,9423,9440,9433,9439,9484, 9576,9692,9797,9861,9879,9872,9876,9920, 10011,10128,10234,10300,10319,10311,10313,10355, 10446,10563,10671,10739,10759,10750,10750,10791, 10880,10999,11109,11178,11198,11189,11187,11226, 11315,11434,11546,11617,11638,11628,11624,11661, 11749,11869,11983,12056,12078,12067,12062,12097, 12184,12304,12420,12495,12518,12506,12499,12532, 12618,12740,12857,12935,12958,12946,12936,12967, 13052,13175,13295,13374,13398,13385,13373,13402, 13486,13609,13732,13814,13839,13824,13810,13836, 13920,14044,14169,14253,14279,14264,14247,14271, 14354,14479,14606,14693,14720,14704,14684,14706, 14787,14914,15043,15133,15161,15144,15122,15140, 15220,15348,15481,15573,15602,15584,15559,15574, 15654,15782,15918,16013,16044,16024,15996,16008, 16086,16216,16355,16453,16485,16464,16433,16442, 16519,16650,16792,16894,16927,16905,16870,16876, 16951,17084,17230,17335,17370,17345,17307,17309, 17383,17517,17667,17776,17813,17786,17744,17742, 17814,17950,18104,18217,18256,18228,18181,18175, 18245,18383,18541,18659,18699,18670,18619,18608, 18676,18816,18979,19101,19143,19112,19056,19040, 19106,19248,19416,19544,19588,19554,19493,19471, 19535,19679,19853,19987,20034,19997,19930,19902, 19963,20110,20290,20431,20480,20441,20367,20332, 20390,20540,20728,20875,20928,20886,20804,20762, 20816,20970,21165,21321,21377,21331,21241,21190, 21241,21398,21603,21767,21827,21778,21678,21617, 21664,21825,22040,22215,22280,22225,22114,22043, 22085,22251,22478,22665,22734,22675,22551,22467, 22504,22675,22915,23116,23191,23126,22988,22888, 22919,23097,23353,23571,23653,23580,23424,23307, 23330,23516,23791,24028,24119,24038,23860,23721, 23735,23930,24229,24491,24592,24500,24296,24130, 24132,24340,24668,24960,25074,24968,24731,24531, 24518,24741,25108,25439,25569,25447,25166,24919, 24888,25131,25549,25933,26086,25939,25598,25289, 25230,25502,25992,26452,26638,26456,26027,25625, 25526,25841,26441,27017,27254,27017,26447,25895, 25730,26118,26905,27683,28010,27672,26839,26000, 25705,26242,27425,28644,29174,28594,27096,25487, 24824,25833,28390,31333,32767,30775,24237,13415, }; const int16_t saw_fxpt_lutable_3[1024] PROGMEM = { 0,-9730,-18483,-25459,-30169,-32514,-32768,-31500, -29435,-27296,-25659,-24860,-24957,-25764,-26936,-28079, -28860,-29086,-28742,-27970,-27020,-26165,-25625,-25511, -25805,-26372,-27012,-27518,-27736,-27609,-27180,-26578, -25973,-25525,-25340,-25441,-25765,-26190,-26570,-26780, -26751,-26487,-26061,-25589,-25195,-24976,-24973,-25160, -25459,-25761,-25961,-25987,-25822,-25507,-25123,-24769, -24534,-24466,-24563,-24774,-25018,-25204,-25264,-25167, -24931,-24613,-24294,-24052,-23940,-23971,-24116,-24313, -24484,-24564,-24516,-24340,-24076,-23788,-23546,-23404, -23386,-23477,-23632,-23786,-23878,-23866,-23738,-23520, -23261,-23024,-22862,-22804,-22851,-22969,-23105,-23202, -23216,-23128,-22950,-22719,-22491,-22315,-22227,-22235, -22319,-22436,-22533,-22567,-22511,-22368,-22165,-21948, -21764,-21653,-21629,-21681,-21777,-21871,-21918,-21889, -21777,-21601,-21397,-21211,-21081,-21029,-21052,-21127, -21214,-21269,-21262,-21178,-21027,-20839,-20654,-20511, -20435,-20432,-20485,-20562,-20622,-20631,-20572,-20446, -20275,-20094,-19942,-19846,-19819,-19851,-19915,-19976, -19998,-19960,-19857,-19704,-19531,-19373,-19261,-19212, -19223,-19273,-19331,-19363,-19343,-19261,-19127,-18963, -18804,-18680,-18611,-18602,-18637,-18689,-18727,-18722, -18660,-18544,-18392,-18234,-18101,-18015,-17986,-18006, -18050,-18090,-18097,-18053,-17955,-17817,-17663,-17523, -17424,-17377,-17379,-17414,-17454,-17470,-17442,-17361, -17237,-17089,-16947,-16836,-16772,-16758,-16781,-16818, -16841,-16826,-16762,-16652,-16514,-16371,-16250,-16172, -16142,-16152,-16184,-16210,-16206,-16158,-16064,-15935, -15794,-15667,-15576,-15530,-15527,-15552,-15579,-15584, -15550,-15470,-15353,-15216,-15086,-14983,-14923,-14907, -14922,-14947,-14959,-14938,-14873,-14767,-14637,-14505, -14394,-14320,-14290,-14295,-14317,-14333,-14322,-14270, -14178,-14056,-13925,-13807,-13722,-13677,-13671,-13687, -13705,-13703,-13664,-13585,-13472,-13344,-13222,-13126, -13069,-13050,-13060,-13077,-13081,-13054,-12988,-12886, -12763,-12638,-12534,-12464,-12433,-12434,-12449,-12458, -12441,-12387,-12296,-12179,-12055,-11944,-11863,-11820, -11811,-11822,-11833,-11825,-11783,-11704,-11595,-11472, -11356,-11266,-11211,-11191,-11196,-11208,-11206,-11175, -11107,-11007,-10889,-10770,-10671,-10605,-10574,-10572, -10582,-10585,-10563,-10507,-10418,-10304,-10185,-10079, -10002,-9960,-9949,-9956,-9962,-9949,-9904,-9825, -9718,-9600,-9489,-9403,-9350,-9329,-9331,-9338, -9332,-9297,-9229,-9130,-9015,-8901,-8807,-8743, -8712,-8708,-8714,-8713,-8688,-8630,-8540,-8430, -8314,-8213,-8139,-8098,-8086,-8090,-8092,-8075, -8028,-7948,-7843,-7728,-7621,-7538,-7487,-7466, -7466,-7469,-7459,-7422,-7352,-7255,-7142,-7032, -6940,-6879,-6849,-6843,-6846,-6842,-6813,-6754, -6665,-6556,-6444,-6345,-6274,-6234,-6221,-6223, -6222,-6202,-6153,-6072,-5969,-5856,-5753,-5672, -5622,-5601,-5600,-5601,-5588,-5548,-5477,-5380, -5269,-5162,-5073,-5013,-4984,-4977,-4979,-4971, -4941,-4880,-4790,-4683,-4572,-4477,-4407,-4369, -4356,-4356,-4353,-4330,-4279,-4198,-4095,-3984, -3883,-3804,-3756,-3736,-3733,-3732,-3717,-3676, -3604,-3506,-3397,-3291,-3204,-3146,-3118,-3111, -3111,-3102,-3069,-3007,-2917,-2809,-2701,-2607, -2540,-2502,-2490,-2489,-2484,-2460,-2407,-2325, -2222,-2112,-2012,-1936,-1889,-1870,-1867,-1865, -1848,-1804,-1731,-1633,-1524,-1420,-1335,-1279, -1251,-1245,-1244,-1233,-1198,-1134,-1043,-936, -829,-737,-671,-635,-623,-622,-616,-590, -535,-452,-349,-240,-141,-66,-21,-3, 0,3,21,66,141,240,349,452, 535,590,616,622,623,635,671,737, 829,936,1043,1134,1198,1233,1244,1245, 1251,1279,1335,1420,1524,1633,1731,1804, 1848,1865,1867,1870,1889,1936,2012,2112, 2222,2325,2407,2460,2484,2489,2490,2502, 2540,2607,2701,2809,2917,3007,3069,3102, 3111,3111,3118,3146,3204,3291,3397,3506, 3604,3676,3717,3732,3733,3736,3756,3804, 3883,3984,4095,4198,4279,4330,4353,4356, 4356,4369,4407,4477,4572,4683,4790,4880, 4941,4971,4979,4977,4984,5013,5073,5162, 5269,5380,5477,5548,5588,5601,5600,5601, 5622,5672,5753,5856,5969,6072,6153,6202, 6222,6223,6221,6234,6274,6345,6444,6556, 6665,6754,6813,6842,6846,6843,6849,6879, 6940,7032,7142,7255,7352,7422,7459,7469, 7466,7466,7487,7538,7621,7728,7843,7948, 8028,8075,8092,8090,8086,8098,8139,8213, 8314,8430,8540,8630,8688,8713,8714,8708, 8712,8743,8807,8901,9015,9130,9229,9297, 9332,9338,9331,9329,9350,9403,9489,9600, 9718,9825,9904,9949,9962,9956,9949,9960, 10002,10079,10185,10304,10418,10507,10563,10585, 10582,10572,10574,10605,10671,10770,10889,11007, 11107,11175,11206,11208,11196,11191,11211,11266, 11356,11472,11595,11704,11783,11825,11833,11822, 11811,11820,11863,11944,12055,12179,12296,12387, 12441,12458,12449,12434,12433,12464,12534,12638, 12763,12886,12988,13054,13081,13077,13060,13050, 13069,13126,13222,13344,13472,13585,13664,13703, 13705,13687,13671,13677,13722,13807,13925,14056, 14178,14270,14322,14333,14317,14295,14290,14320, 14394,14505,14637,14767,14873,14938,14959,14947, 14922,14907,14923,14983,15086,15216,15353,15470, 15550,15584,15579,15552,15527,15530,15576,15667, 15794,15935,16064,16158,16206,16210,16184,16152, 16142,16172,16250,16371,16514,16652,16762,16826, 16841,16818,16781,16758,16772,16836,16947,17089, 17237,17361,17442,17470,17454,17414,17379,17377, 17424,17523,17663,17817,17955,18053,18097,18090, 18050,18006,17986,18015,18101,18234,18392,18544, 18660,18722,18727,18689,18637,18602,18611,18680, 18804,18963,19127,19261,19343,19363,19331,19273, 19223,19212,19261,19373,19531,19704,19857,19960, 19998,19976,19915,19851,19819,19846,19942,20094, 20275,20446,20572,20631,20622,20562,20485,20432, 20435,20511,20654,20839,21027,21178,21262,21269, 21214,21127,21052,21029,21081,21211,21397,21601, 21777,21889,21918,21871,21777,21681,21629,21653, 21764,21948,22165,22368,22511,22567,22533,22436, 22319,22235,22227,22315,22491,22719,22950,23128, 23216,23202,23105,22969,22851,22804,22862,23024, 23261,23520,23738,23866,23878,23786,23632,23477, 23386,23404,23546,23788,24076,24340,24516,24564, 24484,24313,24116,23971,23940,24052,24294,24613, 24931,25167,25264,25204,25018,24774,24563,24466, 24534,24769,25123,25507,25822,25987,25961,25761, 25459,25160,24973,24976,25195,25589,26061,26487, 26751,26780,26570,26190,25765,25441,25340,25525, 25973,26578,27180,27609,27736,27518,27012,26372, 25805,25511,25625,26165,27020,27970,28742,29086, 28860,28079,26936,25764,24957,24860,25659,27296, 29435,31500,32767,32514,30169,25459,18483,9730, }; const int16_t saw_fxpt_lutable_4[512] PROGMEM = { 0,-13401,-24220,-30767,-32768,-31318,-28322,-25673, -24553,-25116,-26659,-28130,-28708,-28170,-26910,-25646, -25002,-25193,-25960,-26761,-27094,-26761,-25947,-25081, -24588,-24648,-25124,-25660,-25891,-25649,-25039,-24365, -23945,-23938,-24261,-24654,-24829,-24639,-24147,-23584, -23208,-23160,-23390,-23692,-23832,-23675,-23261,-22772, -22425,-22349,-22514,-22755,-22870,-22736,-22377,-21940, -21615,-21519,-21637,-21832,-21929,-21813,-21494,-21097, -20788,-20677,-20759,-20919,-21002,-20899,-20612,-20246, -19950,-19826,-19880,-20012,-20084,-19992,-19731,-19390, -19103,-18970,-19001,-19110,-19172,-19090,-18850,-18530, -18251,-18110,-18121,-18212,-18266,-18191,-17969,-17666, -17395,-17247,-17241,-17316,-17364,-17295,-17088,-16801, -16536,-16382,-16361,-16422,-16464,-16401,-16207,-15933, -15674,-15514,-15482,-15530,-15567,-15508,-15327,-15064, -14810,-14645,-14602,-14639,-14671,-14617,-14446,-14194, -13944,-13775,-13722,-13749,-13777,-13727,-13566,-13323, -13077,-12905,-12842,-12860,-12884,-12838,-12685,-12452, -12208,-12033,-11961,-11971,-11993,-11950,-11805,-11579, -11339,-11160,-11081,-11084,-11102,-11062,-10925,-10706, -10469,-10287,-10201,-10196,-10212,-10175,-10044,-9833, -9599,-9414,-9321,-9309,-9322,-9288,-9164,-8959, -8728,-8540,-8441,-8423,-8433,-8401,-8284,-8085, -7856,-7666,-7561,-7537,-7544,-7515,-7403,-7210, -6984,-6792,-6681,-6651,-6656,-6629,-6523,-6336, -6112,-5917,-5800,-5765,-5768,-5744,-5643,-5461, -5239,-5042,-4920,-4880,-4880,-4858,-4763,-4586, -4366,-4167,-4040,-3994,-3993,-3973,-3882,-3711, -3493,-3292,-3160,-3109,-3105,-3087,-3002,-2835, -2620,-2417,-2279,-2224,-2218,-2202,-2122,-1960, -1747,-1541,-1399,-1338,-1331,-1317,-1241,-1085, -873,-666,-519,-453,-444,-432,-361,-209, 0,209,361,432,444,453,519,666, 873,1085,1241,1317,1331,1338,1399,1541, 1747,1960,2122,2202,2218,2224,2279,2417, 2620,2835,3002,3087,3105,3109,3160,3292, 3493,3711,3882,3973,3993,3994,4040,4167, 4366,4586,4763,4858,4880,4880,4920,5042, 5239,5461,5643,5744,5768,5765,5800,5917, 6112,6336,6523,6629,6656,6651,6681,6792, 6984,7210,7403,7515,7544,7537,7561,7666, 7856,8085,8284,8401,8433,8423,8441,8540, 8728,8959,9164,9288,9322,9309,9321,9414, 9599,9833,10044,10175,10212,10196,10201,10287, 10469,10706,10925,11062,11102,11084,11081,11160, 11339,11579,11805,11950,11993,11971,11961,12033, 12208,12452,12685,12838,12884,12860,12842,12905, 13077,13323,13566,13727,13777,13749,13722,13775, 13944,14194,14446,14617,14671,14639,14602,14645, 14810,15064,15327,15508,15567,15530,15482,15514, 15674,15933,16207,16401,16464,16422,16361,16382, 16536,16801,17088,17295,17364,17316,17241,17247, 17395,17666,17969,18191,18266,18212,18121,18110, 18251,18530,18850,19090,19172,19110,19001,18970, 19103,19390,19731,19992,20084,20012,19880,19826, 19950,20246,20612,20899,21002,20919,20759,20677, 20788,21097,21494,21813,21929,21832,21637,21519, 21615,21940,22377,22736,22870,22755,22514,22349, 22425,22772,23261,23675,23832,23692,23390,23160, 23208,23584,24147,24639,24829,24654,24261,23938, 23945,24365,25039,25649,25891,25660,25124,24648, 24588,25081,25947,26761,27094,26761,25960,25193, 25002,25646,26910,28170,28708,28130,26659,25116, 24553,25673,28322,31318,32767,30767,24220,13401, }; const int16_t saw_fxpt_lutable_5[512] PROGMEM = { 0,-9600,-18263,-25211,-29965,-32404,-32768,-31582, -29534,-27325,-25536,-24530,-24408,-25032,-26093,-27213, -28050,-28378,-28136,-27420,-26446,-25478,-24754,-24422, -24511,-24931,-25507,-26036,-26341,-26322,-25973,-25385, -24705,-24100,-23706,-23589,-23737,-24062,-24431,-24705, -24781,-24615,-24233,-23724,-23205,-22794,-22570,-22559, -22724,-22977,-23213,-23333,-23275,-23031,-22646,-22202, -21798,-21515,-21399,-21445,-21605,-21795,-21930,-21941, -21795,-21509,-21136,-20754,-20440,-20252,-20208,-20284, -20425,-20555,-20607,-20535,-20331,-20025,-19676,-19353, -19116,-19000,-19003,-19091,-19203,-19275,-19256,-19121, -18879,-18570,-18252,-17986,-17815,-17754,-17787,-17871, -17948,-17965,-17886,-17703,-17439,-17139,-16859,-16647, -16531,-16511,-16558,-16628,-16666,-16630,-16500,-16283, -16011,-15730,-15491,-15330,-15259,-15266,-15317,-15363, -15359,-15276,-15105,-14866,-14597,-14343,-14146,-14030, -13995,-14018,-14061,-14078,-14032,-13906,-13705,-13455, -13198,-12976,-12820,-12743,-12734,-12764,-12790,-12773, -12687,-12525,-12302,-12052,-11815,-11627,-11511,-11466, -11474,-11499,-11502,-11450,-11326,-11135,-10901,-10659, -10448,-10296,-10215,-10196,-10211,-10223,-10198,-10110, -9954,-9742,-9505,-9279,-9098,-8981,-8930,-8927, -8941,-8934,-8878,-8756,-8572,-8348,-8116,-7913, -7763,-7679,-7652,-7658,-7662,-7631,-7542,-7389, -7185,-6957,-6738,-6561,-6444,-6388,-6378,-6384, -6372,-6313,-6192,-6013,-5796,-5571,-5372,-5224, -5138,-5106,-5105,-5104,-5069,-4980,-4830,-4630, -4407,-4193,-4018,-3901,-3843,-3828,-3829,-3813, -3753,-3634,-3458,-3244,-3023,-2826,-2679,-2591, -2557,-2553,-2548,-2512,-2423,-2274,-2078,-1857, -1646,-1472,-1354,-1294,-1277,-1276,-1258,-1198, -1079,-905,-693,-474,-278,-130,-42,-5, 0,5,42,130,278,474,693,905, 1079,1198,1258,1276,1277,1294,1354,1472, 1646,1857,2078,2274,2423,2512,2548,2553, 2557,2591,2679,2826,3023,3244,3458,3634, 3753,3813,3829,3828,3843,3901,4018,4193, 4407,4630,4830,4980,5069,5104,5105,5106, 5138,5224,5372,5571,5796,6013,6192,6313, 6372,6384,6378,6388,6444,6561,6738,6957, 7185,7389,7542,7631,7662,7658,7652,7679, 7763,7913,8116,8348,8572,8756,8878,8934, 8941,8927,8930,8981,9098,9279,9505,9742, 9954,10110,10198,10223,10211,10196,10215,10296, 10448,10659,10901,11135,11326,11450,11502,11499, 11474,11466,11511,11627,11815,12052,12302,12525, 12687,12773,12790,12764,12734,12743,12820,12976, 13198,13455,13705,13906,14032,14078,14061,14018, 13995,14030,14146,14343,14597,14866,15105,15276, 15359,15363,15317,15266,15259,15330,15491,15730, 16011,16283,16500,16630,16666,16628,16558,16511, 16531,16647,16859,17139,17439,17703,17886,17965, 17948,17871,17787,17754,17815,17986,18252,18570, 18879,19121,19256,19275,19203,19091,19003,19000, 19116,19353,19676,20025,20331,20535,20607,20555, 20425,20284,20208,20252,20440,20754,21136,21509, 21795,21941,21930,21795,21605,21445,21399,21515, 21798,22202,22646,23031,23275,23333,23213,22977, 22724,22559,22570,22794,23205,23724,24233,24615, 24781,24705,24431,24062,23737,23589,23706,24100, 24705,25385,25973,26322,26341,26036,25507,24931, 24511,24422,24754,25478,26446,27420,28136,28378, 28050,27213,26093,25032,24408,24530,25536,27325, 29534,31582,32767,32404,29965,25211,18263,9600, }; const int16_t saw_fxpt_lutable_6[256] PROGMEM = { 0,-13373,-24186,-30752,-32768,-31289,-28184,-25350, -24004,-24361,-25766,-27181,-27753,-27200,-25861,-24435, -23574,-23552,-24165,-24896,-25218,-24874,-23992,-22976, -22269,-22112,-22426,-22882,-23099,-22850,-22180,-21362, -20732,-20505,-20659,-20965,-21122,-20928,-20383,-19684, -19101,-18830,-18883,-19093,-19212,-19053,-18592,-17973, -17422,-17120,-17103,-17245,-17337,-17204,-16804,-16243, -15716,-15392,-15321,-15411,-15483,-15370,-15017,-14502, -13993,-13651,-13539,-13588,-13642,-13546,-13230,-12753, -12260,-11903,-11755,-11770,-11811,-11728,-11445,-10999, -10518,-10149,-9971,-9957,-9986,-9914,-9659,-9241, -8772,-8391,-8187,-8147,-8165,-8104,-7874,-7480, -7021,-6631,-6403,-6340,-6348,-6297,-6089,-5718, -5268,-4868,-4619,-4533,-4533,-4490,-4304,-3954, -3513,-3105,-2835,-2728,-2719,-2685,-2519,-2189, -1757,-1340,-1050,-924,-906,-881,-735,-425, 0,425,735,881,906,924,1050,1340, 1757,2189,2519,2685,2719,2728,2835,3105, 3513,3954,4304,4490,4533,4533,4619,4868, 5268,5718,6089,6297,6348,6340,6403,6631, 7021,7480,7874,8104,8165,8147,8187,8391, 8772,9241,9659,9914,9986,9957,9971,10149, 10518,10999,11445,11728,11811,11770,11755,11903, 12260,12753,13230,13546,13642,13588,13539,13651, 13993,14502,15017,15370,15483,15411,15321,15392, 15716,16243,16804,17204,17337,17245,17103,17120, 17422,17973,18592,19053,19212,19093,18883,18830, 19101,19684,20383,20928,21122,20965,20659,20505, 20732,21362,22180,22850,23099,22882,22426,22112, 22269,22976,23992,24874,25218,24896,24165,23552, 23574,24435,25861,27200,27753,27181,25766,24361, 24004,25350,28184,31289,32767,30752,24186,13373, }; const int16_t saw_fxpt_lutable_7[256] PROGMEM = { 0,-9802,-18615,-25623,-30329,-32620,-32768,-31341, -29070,-26692,-24803,-23757,-23631,-24251,-25274,-26298, -26975,-27094,-26621,-25688,-24542,-23463,-22686,-22342, -22429,-22822,-23321,-23711,-23822,-23576,-23002,-22221, -21405,-20725,-20306,-20188,-20324,-20597,-20853,-20955, -20814,-20416,-19823,-19149,-18528,-18072,-17843,-17831, -17966,-18137,-18227,-18146,-17857,-17386,-16809,-16233, -15759,-15458,-15345,-15382,-15488,-15564,-15520,-15308, -14926,-14425,-13887,-13406,-13055,-12866,-12827,-12877, -12935,-12916,-12760,-12450,-12013,-11513,-11031,-10643, -10395,-10290,-10291,-10328,-10324,-10212,-9962,-9582, -9118,-8642,-8228,-7931,-7769,-7722,-7735,-7738, -7662,-7464,-7136,-6709,-6244,-5812,-5473,-5259, -5166,-5153,-5157,-5109,-4956,-4677,-4289,-3840, -3396,-3021,-2760,-2621,-2579,-2578,-2551,-2439, -2208,-1860,-1431,-981,-577,-271,-87,-11, 0,11,87,271,577,981,1431,1860, 2208,2439,2551,2578,2579,2621,2760,3021, 3396,3840,4289,4677,4956,5109,5157,5153, 5166,5259,5473,5812,6244,6709,7136,7464, 7662,7738,7735,7722,7769,7931,8228,8642, 9118,9582,9962,10212,10324,10328,10291,10290, 10395,10643,11031,11513,12013,12450,12760,12916, 12935,12877,12827,12866,13055,13406,13887,14425, 14926,15308,15520,15564,15488,15382,15345,15458, 15759,16233,16809,17386,17857,18146,18227,18137, 17966,17831,17843,18072,18528,19149,19823,20416, 20814,20955,20853,20597,20324,20188,20306,20725, 21405,22221,23002,23576,23822,23711,23321,22822, 22429,22342,22686,23463,24542,25688,26621,27094, 26975,26298,25274,24251,23631,23757,24803,26692, 29070,31341,32767,32620,30329,25623,18615,9802, }; const int16_t saw_fxpt_lutable_8[128] PROGMEM = { 0,-13316,-24119,-30721,-32768,-31229,-27906,-24693, -22880,-22802,-23908,-25193,-25746,-25167,-23681,-21937, -20632,-20155,-20426,-20986,-21273,-20919,-19924,-18622, -17485,-16860,-16801,-17057,-17227,-16980,-16225,-15150, -14101,-13395,-13148,-13226,-13326,-13144,-12543,-11614, -10623,-9862,-9486,-9439,-9489,-9355,-8866,-8046, -7100,-6296,-5819,-5674,-5683,-5588,-5192,-4464, -3555,-2714,-2150,-1919,-1893,-1833,-1520,-875, 0,875,1520,1833,1893,1919,2150,2714, 3555,4464,5192,5588,5683,5674,5819,6296, 7100,8046,8866,9355,9489,9439,9486,9862, 10623,11614,12543,13144,13326,13226,13148,13395, 14101,15150,16225,16980,17227,17057,16801,16860, 17485,18622,19924,20919,21273,20986,20426,20155, 20632,21937,23681,25167,25746,25193,23908,22802, 22880,24693,27906,31229,32767,30721,24119,13316, }; const int16_t saw_fxpt_lutable_9[128] PROGMEM = { 0,-9287,-17732,-24627,-29495,-32164,-32768,-31706, -29555,-26956,-24496,-22619,-21558,-21327,-21748,-22518, -23292,-23764,-23737,-23150,-22087,-20737,-19342,-18136, -17288,-16866,-16828,-17039,-17314,-17459,-17328,-16849, -16042,-15007,-13899,-12882,-12090,-11596,-11394,-11405, -11498,-11526,-11365,-10940,-10247,-9350,-8362,-7419, -6640,-6101,-5814,-5727,-5739,-5722,-5561,-5178, -4551,-3724,-2791,-1870,-1079,-500,-158,-21, 0,21,158,500,1079,1870,2791,3724, 4551,5178,5561,5722,5739,5727,5814,6101, 6640,7419,8362,9350,10247,10940,11365,11526, 11498,11405,11394,11596,12090,12882,13899,15007, 16042,16849,17328,17459,17314,17039,16828,16866, 17288,18136,19342,20737,22087,23150,23737,23764, 23292,22518,21748,21327,21558,22619,24496,26956, 29555,31706,32767,32164,29495,24627,17732,9287, }; const int16_t saw_fxpt_lutable_10[64] PROGMEM = { 0,-13204,-23984,-30659,-32768,-31107,-27335,-23326, -20510,-19462,-19863,-20806,-21293,-20689,-18957,-16600, -14361,-12851,-12269,-12344,-12507,-12184,-11078,-9298, -7283,-5569,-4520,-4153,-4141,-3983,-3266,-1863, 0,1863,3266,3983,4141,4153,4520,5569, 7283,9298,11078,12184,12507,12344,12269,12851, 14361,16600,18957,20689,21293,20806,19863,19462, 20510,23326,27335,31107,32767,30659,23984,13204, }; const int16_t saw_fxpt_lutable_11[64] PROGMEM = { 0,-10023,-19010,-26098,-30737,-32768,-32426,-30267, -27046,-23557,-20481,-18276,-17111,-16873,-17235,-17758, -18012,-17680,-16630,-14927,-12807,-10597,-8628,-7150, -6264,-5907,-5877,-5888,-5650,-4951,-3709,-1992, 0,1992,3709,4951,5650,5888,5877,5907, 6264,7150,8628,10597,12807,14927,16630,17680, 18012,17758,17235,16873,17111,18276,20481,23557, 27046,30267,32426,32767,30737,26098,19010,10023, }; const int16_t saw_fxpt_lutable_12[32] PROGMEM = { 0,-12982,-23715,-30534,-32768,-30852,-26115,-20326, -15141,-11635,-10056,-9869,-10057,-9551,-7656,-4291, 0,4291,7656,9551,10057,9869,10056,11635, 15141,20326,26115,30852,32767,30534,23715,12982, }; const int16_t saw_fxpt_lutable_13[16] PROGMEM = { 0,-18886,-30964,-32768,-25651,-14630,-5313,-747, 0,747,5313,14630,25651,32767,30964,18886, }; const int16_t saw_fxpt_lutable_14[8] PROGMEM = { 0,-23170,-32768,-23170,0,23170,32767,23170, }; lut_entry_fxpt saw_fxpt_lutset[16] = { {saw_fxpt_lutable_0, 2048, 11, 255, 1.845797}, {saw_fxpt_lutable_1, 2048, 11, 180, 1.837728}, {saw_fxpt_lutable_2, 1024, 10, 127, 1.839649}, {saw_fxpt_lutable_3, 1024, 10, 90, 1.828025}, {saw_fxpt_lutable_4, 512, 9, 63, 1.827329}, {saw_fxpt_lutable_5, 512, 9, 44, 1.812372}, {saw_fxpt_lutable_6, 256, 8, 31, 1.802594}, {saw_fxpt_lutable_7, 256, 8, 22, 1.774038}, {saw_fxpt_lutable_8, 128, 7, 15, 1.752739}, {saw_fxpt_lutable_9, 128, 7, 10, 1.705475}, {saw_fxpt_lutable_10, 64, 6, 7, 1.651493}, {saw_fxpt_lutable_11, 64, 6, 5, 1.576708}, {saw_fxpt_lutable_12, 32, 5, 3, 1.442809}, {saw_fxpt_lutable_13, 16, 4, 2, 1.277433}, {saw_fxpt_lutable_14, 8, 3, 1, 1.000000}, {NULL, 0, 0, 0, 0.0}, }; #endif // LUTSET_x_DEFINED ================================================ FILE: src/sequencer.c ================================================ #include "sequencer.h" #include "amy.h" #ifdef __EMSCRIPTEN__ #include #endif uint32_t sequencer_ticks() { return amy_global.sequencer_tick_count; } typedef struct sequence_info_t { struct delta *deltas; //uint32_t tag; // tag is implicit, it's its index in the table uint32_t tick; // 0 means not used uint32_t period; // 0 means not used } sequence_info_t; struct sequence_info_t *sequences = NULL; // An array indexed by tag. int32_t max_sequences = 0; int32_t highest_tag = -1; static volatile bool sequencer_running = true; static volatile bool sequencer_external_clock = false; // Declared per-platform below. void _sequencer_start(); void _sequencer_stop(); void sequencer_init(int max_sequencer_tags) { max_sequences = max_sequencer_tags; sequences = (struct sequence_info_t *)malloc_caps(max_sequences * sizeof(struct sequence_info_t), amy_global.config.ram_caps_synth); for (int32_t i = 0; i < max_sequences; ++i) { sequences[i].deltas = NULL; sequences[i].tick = 0; sequences[i].period = 0; } // We are read to go. //sequencer_start(); sequencer_recompute(); _sequencer_start(); } void sequencer_reset() { // Remove all events for (int32_t i = 0; i < max_sequences; ++i) { if (sequences[i].deltas) { delta_release_list(sequences[i].deltas); sequences[i].deltas = NULL; sequences[i].tick = 0; sequences[i].period = 0; } } highest_tag = -1; } void sequencer_deinit() { _sequencer_stop(); sequencer_reset(); if (sequences != NULL) free(sequences); max_sequences = 0; } void sequencer_debug() { fprintf(stderr, "sequencer: max_sequences %" PRIi32" highest_tag %" PRIi32 "\n", max_sequences, highest_tag); for (int32_t tag = 0; tag < max_sequences; ++tag) { if (sequences[tag].deltas) { fprintf(stderr, "sequence tag %" PRIu32" tick %" PRIu32 " period %"PRIu32 " num_deltas %"PRIu32 "\n", tag, sequences[tag].tick, sequences[tag].period, delta_list_len(sequences[tag].deltas)); } } } void sequencer_recompute() { amy_global.us_per_tick = (uint32_t) (1000000.0 / ((amy_global.tempo/60.0) * (float)AMY_SEQUENCER_PPQ)); amy_global.next_amy_tick_us = (((uint64_t)amy_sysclock()) * 1000L) + (uint64_t)amy_global.us_per_tick; } static void sequencer_process_tick(void) { amy_global.sequencer_tick_count++; // Scan through LL looking for matches for (int32_t tag = 0; tag <= highest_tag; ++tag) { if (sequences[tag].deltas != NULL) { bool hit = false; bool delete = false; if(sequences[tag].period != 0) { // period set uint32_t offset = amy_global.sequencer_tick_count % sequences[tag].period; if (offset == sequences[tag].tick) hit = true; } else { // Test for absolute tick (no period set) if (sequences[tag].tick == amy_global.sequencer_tick_count) { hit = true; delete = true; } } if(hit) { struct delta *d = sequences[tag].deltas; while(d) { // assume the d->time is 0 and that's good. add_delta_to_queue(d, &amy_global.delta_queue); d = d->next; } // Delete absolute tick addressed sequence entry if sent if(delete) { delta_release_list(sequences[tag].deltas); sequences[tag].deltas = NULL; } } } } // call the right hook: #ifdef __EMSCRIPTEN__ EM_ASM({ if(typeof amy_sequencer_js_hook === 'function') { amy_sequencer_js_hook($0); } }, amy_global.sequencer_tick_count); #endif if(amy_global.config.amy_external_sequencer_hook != NULL) { amy_global.config.amy_external_sequencer_hook(amy_global.sequencer_tick_count); } } void sequencer_midi_start() { // MIDI "Start" restarts the sequencer. // If external clock was not previously enabled, keep using internal clock // so the sequencer advances on its own without needing F8 ticks. if (sequencer_external_clock) { amy_global.sequencer_tick_count = 0; } // Reset the tick timer to now so sequencer_check_and_fill doesn't try to // catch up all the ticks that elapsed while stopped. amy_global.next_amy_tick_us = (uint64_t)amy_sysclock() * 1000L; sequencer_running = true; } void sequencer_midi_stop() { sequencer_running = false; } void sequencer_midi_clock_tick() { sequencer_external_clock = true; if (!sequencer_running) return; for (uint8_t i = 0; i < AMY_SEQUENCER_PPQ/MIDI_SEQUENCER_PPQ; ++i) { sequencer_process_tick(); } } uint8_t sequencer_add_event(amy_event *e) { // add this event to the list of sequencer events in the LL. // e->sequence is set up. // if the tag already exists - if there's tick/period, overwrite, if there's no tick / period, we should remove the entry //fprintf(stderr, "sequencer_add_event: e->instrument %d e->note %.0f e->vel %.2f tick %d period %d tag %d\n", e->instrument, e->midi_note, e->velocity, e->sequence[SEQUENCE_TICK], e->sequence[SEQUENCE_PERIOD], e->sequence[SEQUENCE_TAG]); int32_t tag = e->sequence[SEQUENCE_TAG]; if (tag > max_sequences) { fprintf(stderr, "sequencer tag %" PRIi32" (with tick %" PRIu32", period %" PRIu32") is greater than or eq max_sequences %" PRIi32"\n", tag, e->sequence[SEQUENCE_TICK], e->sequence[SEQUENCE_PERIOD], max_sequences); // ignore return 0; } // Release any existing deltas for this tag, even if we're just going to rewrite them. delta_release_list(sequences[tag].deltas); sequences[tag].deltas = NULL; if(e->sequence[SEQUENCE_TICK] == 0 && e->sequence[SEQUENCE_PERIOD] == 0) return 0; // Ignore non-schedulable event. if(e->sequence[SEQUENCE_TICK] != 0 && e->sequence[SEQUENCE_PERIOD] == 0 && e->sequence[SEQUENCE_TICK] <= amy_global.sequencer_tick_count) return 0; // don't schedule things in the past. // Save the tick & period. sequences[tag].tick = e->sequence[SEQUENCE_TICK]; sequences[tag].period = e->sequence[SEQUENCE_PERIOD]; // Copy all the deltas for this event to the sequences entry. amy_event_to_deltas_queue(e, 0, &sequences[tag].deltas); if (tag > highest_tag) highest_tag = tag; // To limit scanning through tags. return 1; } void sequencer_check_and_fill() { if (!sequencer_running || sequencer_external_clock) return; // If we've fallen behind by more than 1 second (e.g. sequencer was stopped // and restarted, or a long blocking operation occurred), skip ahead instead // of processing hundreds of backed-up ticks at once. uint64_t now_us = (uint64_t)amy_sysclock() * 1000L; if (now_us > amy_global.next_amy_tick_us + 1000000ULL) { amy_global.next_amy_tick_us = now_us; } // The while is in case the timer fires later than a tick; (on esp this would be due to SPI or wifi ops) while(amy_sysclock() >= (uint32_t)(amy_global.next_amy_tick_us / 1000L)) { sequencer_process_tick(); amy_global.next_amy_tick_us = amy_global.next_amy_tick_us + (uint64_t)amy_global.us_per_tick; } } ///// Sequencers per platform #ifdef ESP_PLATFORM // ESP: do it with hardware timer #include "esp_timer.h" esp_timer_handle_t periodic_timer = NULL; static void sequencer_timer_callback(void* arg) { sequencer_check_and_fill(); } void _sequencer_start() { const esp_timer_create_args_t periodic_timer_args = { .callback = &sequencer_timer_callback, //.dispatch_method = ESP_TIMER_ISR, .name = "sequencer" }; ESP_ERROR_CHECK(esp_timer_create(&periodic_timer_args, &periodic_timer)); // 500us = 0.5ms ESP_ERROR_CHECK(esp_timer_start_periodic(periodic_timer, 500)); } void _sequencer_stop() { if (periodic_timer) { ESP_ERROR_CHECK(esp_timer_stop(periodic_timer)); ESP_ERROR_CHECK(esp_timer_delete(periodic_timer)); periodic_timer = NULL; } } #elif defined(PICO_RP2350) || defined(PICO_RP2040) // pico: do it with a hardware timer #include "pico/time.h" repeating_timer_t pico_sequencer_timer; static bool sequencer_timer_callback(repeating_timer_t *rt) { sequencer_check_and_fill(); return true; } void _sequencer_start() { add_repeating_timer_us(-500, sequencer_timer_callback, NULL, &pico_sequencer_timer); } void _sequencer_stop() { cancel_repeating_timer(&pico_sequencer_timer); } #elif defined _POSIX_THREADS #include static volatile bool sequencer_thread_should_exit = false; // posix: threads void * sequencer_thread(void *vargs) { // Loop forever, checking for time and sleeping while(!sequencer_thread_should_exit) { sequencer_check_and_fill(); // 500000ns = 500us = 0.5ms nanosleep((const struct timespec[]){{0, 500000L}}, NULL); } return NULL; } pthread_t sequencer_thread_id; void _sequencer_start() { sequencer_thread_should_exit = false; pthread_create(&sequencer_thread_id, NULL, sequencer_thread, NULL); } void _sequencer_stop() { //pthread_cancel(sequencer_thread_id); sequencer_thread_should_exit = true; } #elif defined AMY_DAISY void _sequencer_start() { // Set up in DaisyMain.cc } void _sequencer_stop() { // Not supported on Daisy. } #else void _sequencer_start() { fprintf(stderr, "No sequencer support for this chip / platform\n"); } void _sequencer_stop() { fprintf(stderr, "No sequencer support for this chip / platform\n"); } #endif ================================================ FILE: src/sequencer.h ================================================ // sequencer.h #ifndef __SEQUENCERH #define __SEQUENCERH #include "amy.h" #define MIDI_SEQUENCER_PPQ 24 // MIDI clocks per quarter note uint32_t sequencer_ticks(); void sequencer_init(int max_num_sequences); void sequencer_deinit(); void sequencer_reset(); void sequencer_debug(); void sequencer_recompute(); uint8_t sequencer_add_event(amy_event *e); void sequencer_midi_clock_tick(); void sequencer_midi_start(); void sequencer_midi_stop(); #endif ================================================ FILE: src/sine_lutset_fxpt.h ================================================ // Automatically-generated LUTset #ifndef LUTSET_SINE_FXPT_DEFINED #define LUTSET_SINE_FXPT_DEFINED #ifndef LUTENTRY_FXPT_DEFINED #define LUTENTRY_FXPT_DEFINED typedef struct { const int16_t *table; int table_size; int log_2_table_size; int highest_harmonic; float scale_factor; } lut_entry_fxpt; #endif // LUTENTRY_FXPT_DEFINED const int16_t sine_fxpt_lutable_0[256] PROGMEM = { 0,804,1608,2411,3212,4011,4808,5602, 6393,7180,7962,8740,9512,10279,11039,11793, 12540,13279,14010,14733,15447,16151,16846,17531, 18205,18868,19520,20160,20788,21403,22006,22595, 23170,23732,24279,24812,25330,25833,26320,26791, 27246,27684,28106,28511,28899,29269,29622,29957, 30274,30572,30853,31114,31357,31581,31786,31972, 32138,32286,32413,32522,32610,32679,32729,32758, 32767,32758,32729,32679,32610,32522,32413,32286, 32138,31972,31786,31581,31357,31114,30853,30572, 30274,29957,29622,29269,28899,28511,28106,27684, 27246,26791,26320,25833,25330,24812,24279,23732, 23170,22595,22006,21403,20788,20160,19520,18868, 18205,17531,16846,16151,15447,14733,14010,13279, 12540,11793,11039,10279,9512,8740,7962,7180, 6393,5602,4808,4011,3212,2411,1608,804, 0,-804,-1608,-2411,-3212,-4011,-4808,-5602, -6393,-7180,-7962,-8740,-9512,-10279,-11039,-11793, -12540,-13279,-14010,-14733,-15447,-16151,-16846,-17531, -18205,-18868,-19520,-20160,-20788,-21403,-22006,-22595, -23170,-23732,-24279,-24812,-25330,-25833,-26320,-26791, -27246,-27684,-28106,-28511,-28899,-29269,-29622,-29957, -30274,-30572,-30853,-31114,-31357,-31581,-31786,-31972, -32138,-32286,-32413,-32522,-32610,-32679,-32729,-32758, -32768,-32758,-32729,-32679,-32610,-32522,-32413,-32286, -32138,-31972,-31786,-31581,-31357,-31114,-30853,-30572, -30274,-29957,-29622,-29269,-28899,-28511,-28106,-27684, -27246,-26791,-26320,-25833,-25330,-24812,-24279,-23732, -23170,-22595,-22006,-21403,-20788,-20160,-19520,-18868, -18205,-17531,-16846,-16151,-15447,-14733,-14010,-13279, -12540,-11793,-11039,-10279,-9512,-8740,-7962,-7180, -6393,-5602,-4808,-4011,-3212,-2411,-1608,-804, }; lut_entry_fxpt sine_fxpt_lutset[2] = { {sine_fxpt_lutable_0, 256, 8, 1, 1.000000}, {NULL, 0, 0, 0, 0.0}, }; #endif // LUTSET_x_DEFINED ================================================ FILE: src/teensy_support.cpp ================================================ // teensy_support.cpp #ifdef __IMXRT1062__ #include "teensy_support.h" #include #include "amy.h" AudioOutputPT8211 i2s1; //AudioOutputI2S unused; AudioPlayQueue queue_l; AudioPlayQueue queue_r; #if defined(USB_AUDIO) || defined(USB_MIDI_AUDIO_SERIAL) || defined(USB_MIDI16_AUDIO_SERIAL) AudioOutputUSB usb_out; AudioConnection patchCord1(queue_r, 0, usb_out, 1); AudioConnection patchCord2(queue_l, 0, usb_out, 0); #endif AudioConnection patchCord3(queue_r, 0, i2s1, 1); AudioConnection patchCord4(queue_l, 0, i2s1, 0); int16_t * samples_l = NULL; int16_t * samples_r = NULL; extern "C" { #include "usb_names.h" // Edit these lines to create your own name. The length must // match the number of characters in your custom name. #define MIDI_NAME {'A','M','Y',' ','S','y','n','t','h','e','s','i','z','e','r'} #define MIDI_NAME_LEN 15 #define SPSS_NAME {'S','P','S','S'} #define SPSS_NAME_LEN 4 // Do not change this part. This exact format is required by USB. struct usb_string_descriptor_struct usb_string_product_name = { 2 + MIDI_NAME_LEN * 2, 3, MIDI_NAME }; struct usb_string_descriptor_struct usb_string_manufacturer_name = { 2 + SPSS_NAME_LEN * 2, 3, SPSS_NAME }; void teensy_setup_i2s() { if (samples_l == NULL) { samples_l = (int16_t*)malloc(sizeof(int16_t)*AMY_BLOCK_SIZE); samples_r = (int16_t*)malloc(sizeof(int16_t)*AMY_BLOCK_SIZE); AudioMemory(16); queue_l.setMaxBuffers(4); queue_r.setMaxBuffers(4); } } void teensy_teardown_i2s() { if (samples_l != NULL) { free(samples_l); free(samples_r); samples_l = NULL; samples_r = NULL; } } size_t teensy_i2s_write(const uint8_t *buffer, size_t nbytes) { int16_t *samples = (int16_t *)buffer; for(int16_t i=0;i #include #include "transfer.h" #include "amy_midi.h" // for midi_out, MAX_SYSEX_BYTES #include "sequencer.h" // for sequencer_midi_stop/start #include #include #include #include #ifdef __EMSCRIPTEN__ #include "emscripten.h" #endif // per platform file reading / writing // posix (linux, mac) // micropython / littlefs - tulip & amybard // (later) arduino / SPIFFS / SD // if yours isnt' here, you just write your own amy_external_fopen_hook etc // mac / linux / generic posix #if defined(__unix__) || defined(__APPLE__) || defined(_POSIX_VERSION) // Map from FILE * to a uint32_t handle to pass to AMY static FILE *g_files[MAX_OPEN_FILES]; // index 1..MAX_OPEN_FILES-1 used #ifdef __EMSCRIPTEN__ static uint32_t g_em_handle[MAX_OPEN_FILES]; static uint32_t g_em_pos[MAX_OPEN_FILES]; #endif #ifndef __EMSCRIPTEN__ static uint32_t alloc_handle(FILE *f) { for (uint32_t i = 1; i < MAX_OPEN_FILES; i++) { if (g_files[i] == NULL) { g_files[i] = f; return i; } } return HANDLE_INVALID; // table full } static FILE *lookup_handle(uint32_t h) { if (h == 0 || h >= MAX_OPEN_FILES) return NULL; return g_files[h]; } #endif static void free_handle(uint32_t h) { if (h == 0 || h >= MAX_OPEN_FILES) return; g_files[h] = NULL; #ifdef __EMSCRIPTEN__ g_em_handle[h] = 0; g_em_pos[h] = 0; #endif } // These should map to // uint32_t (*amy_external_fopen_hook)(char * filename, char * mode) = NULL; // uint32_t (*amy_external_fwrite_hook)(uint32_t fptr, uint8_t * bytes, uint32_t len) = NULL; // uint32_t (*amy_external_fread_hook)(uint32_t fptr, uint8_t * bytes, uint32_t len) = NULL; // void (*amy_external_fclose_hook)(uint32_t fptr) = NULL; uint32_t posix_external_fopen_hook(char * filename, const char *mode) { #ifdef __EMSCRIPTEN__ uint32_t js_handle = EM_ASM_INT({ if (typeof amy_shared_open === 'function') { return amy_shared_open(UTF8ToString($0), UTF8ToString($1)); } return 0; }, filename, mode); if (js_handle == 0) { return HANDLE_INVALID; } for (uint32_t i = 1; i < MAX_OPEN_FILES; i++) { if (g_em_handle[i] == 0) { g_em_handle[i] = js_handle; g_em_pos[i] = 0; return i; } } EM_ASM({ if (typeof amy_shared_close === 'function') { amy_shared_close($0); } }, js_handle); return HANDLE_INVALID; #else FILE *f = fopen(filename, mode); if (!f) { return HANDLE_INVALID; } uint32_t h = alloc_handle(f); if (h == HANDLE_INVALID) { fclose(f); return HANDLE_INVALID; } return h; #endif } uint32_t posix_external_fread_hook(uint32_t h, uint8_t *buf, uint32_t len) { #ifdef __EMSCRIPTEN__ if (h == 0 || h >= MAX_OPEN_FILES) { return 0; } uint32_t js_handle = g_em_handle[h]; if (js_handle == 0) { return 0; } uint32_t pos = g_em_pos[h]; uint32_t r = EM_ASM_INT({ if (typeof amy_shared_read === 'function') { return amy_shared_read($0, $1, $2, $3); } return 0; }, js_handle, pos, buf, len); g_em_pos[h] += r; return r; #else FILE *f = lookup_handle(h); if (!f) { return 0; } uint32_t r = fread(buf, 1, len, f); return r; #endif } void posix_external_fseek_hook(uint32_t h, uint32_t pos) { #ifdef __EMSCRIPTEN__ if (h == 0 || h >= MAX_OPEN_FILES) { return; } g_em_pos[h] = pos; return; #else FILE *f = lookup_handle(h); if (!f) { return; } fseek(f, pos, SEEK_SET); #endif } uint32_t posix_external_fwrite_hook(uint32_t h, uint8_t *buf, uint32_t n) { #ifdef __EMSCRIPTEN__ if (h == 0 || h >= MAX_OPEN_FILES || g_em_handle[h] == 0) { return 0; } uint32_t written = EM_ASM_INT({ if (typeof amy_shared_write === 'function') { return amy_shared_write($0, $1, $2); } return 0; }, g_em_handle[h], buf, n); g_em_pos[h] += written; return written; #else FILE *f = lookup_handle(h); if (!f) { return 0; } uint32_t w = fwrite(buf, 1, n, f); return w; #endif } void posix_external_fclose_hook(uint32_t h) { #ifdef __EMSCRIPTEN__ if (h == 0 || h >= MAX_OPEN_FILES) { return; } uint32_t js_handle = g_em_handle[h]; if (js_handle != 0) { EM_ASM({ if (typeof amy_shared_close === 'function') { amy_shared_close($0); } }, js_handle); free_handle(h); } #else FILE *f = lookup_handle(h); if (f) { fclose(f); free_handle(h); } #endif } #endif // We keep one decbuf around and reuse it during transfer b64_buffer_t decbuf; // signals to AMY that i'm now receiving a transfer of length (bytes!) into allocated storage void start_receiving_transfer(uint32_t length, uint8_t * storage) { amy_global.transfer_flag = AMY_TRANSFER_TYPE_AUDIO; amy_global.transfer_storage = storage; amy_global.transfer_length_bytes = length; amy_global.transfer_stored_bytes = 0; amy_global.transfer_file_handle = 0; amy_global.transfer_filename[0] = '\0'; b64_buf_malloc(&decbuf); } void start_receiving_sample(uint32_t frames, uint8_t bus, int16_t *storage) { amy_global.transfer_flag = AMY_TRANSFER_TYPE_SAMPLE; amy_global.transfer_storage = (uint8_t *)storage; amy_global.transfer_length_bytes = frames*sizeof(int16_t)*AMY_NCHANS; amy_global.transfer_stored_bytes = 0; amy_global.transfer_file_handle = bus; // use file handle to store bus number amy_global.transfer_filename[0] = '\0'; } void stop_receiving_sample() { amy_global.transfer_file_handle = 0; amy_global.transfer_flag = AMY_TRANSFER_TYPE_NONE; amy_global.transfer_stored_bytes = 0; amy_global.transfer_length_bytes = 0; } // signals to AMY that i'm now receiving a file transfer of length (bytes!) to filename void start_receiving_file_transfer(uint32_t length, const char *filename) { if (filename == NULL || filename[0] == '\0') { return; } if (amy_global.config.amy_external_fopen_hook == NULL || amy_global.config.amy_external_fwrite_hook == NULL || amy_global.config.amy_external_fclose_hook == NULL) { fprintf(stderr, "file transfer hooks not enabled on platform\n"); return; } uint32_t handle = amy_global.config.amy_external_fopen_hook((char *)filename, "wb"); if (handle == HANDLE_INVALID) { fprintf(stderr, "could not open file for transfer: %s\n", filename); return; } amy_global.transfer_flag = AMY_TRANSFER_TYPE_FILE; amy_global.transfer_storage = NULL; amy_global.transfer_length_bytes = length; amy_global.transfer_stored_bytes = 0; amy_global.transfer_file_handle = handle; strncpy(amy_global.transfer_filename, filename, sizeof(amy_global.transfer_filename) - 1); amy_global.transfer_filename[sizeof(amy_global.transfer_filename) - 1] = '\0'; b64_buf_malloc(&decbuf); } // takes a wire message and adds it to storage after decoding it. stops transfer when it's done void parse_transfer_message(char * message, uint16_t len) { size_t decoded = 0; uint8_t * block = b64_decode_ex (message, len, &decbuf, &decoded); if (amy_global.transfer_flag == AMY_TRANSFER_TYPE_FILE) { if (amy_global.config.amy_external_fwrite_hook != NULL && amy_global.transfer_file_handle != HANDLE_INVALID) { uint32_t wrote = amy_global.config.amy_external_fwrite_hook(amy_global.transfer_file_handle, block, (uint32_t)decoded); amy_global.transfer_stored_bytes += wrote; } } else { for (uint16_t i = 0; i < decoded; i++) { amy_global.transfer_storage[amy_global.transfer_stored_bytes++] = block[i]; } } if (amy_global.transfer_stored_bytes >= amy_global.transfer_length_bytes) { // we're done if (amy_global.transfer_flag == AMY_TRANSFER_TYPE_FILE) { if (amy_global.config.amy_external_fclose_hook != NULL && amy_global.transfer_file_handle != HANDLE_INVALID) { amy_global.config.amy_external_fclose_hook(amy_global.transfer_file_handle); } // Pair the sequencer_midi_stop() that zT's start handler fired in // amy_parse_transfer_layer_message(). Do it BEFORE the done hook so // the hook can observe a running sequencer if it needs to, and so // any platform that uses zT without a platform-specific restart in // its file_transfer_done_hook doesn't leave playback wedged. sequencer_midi_start(); if (amy_global.config.amy_external_file_transfer_done_hook != NULL) { amy_global.config.amy_external_file_transfer_done_hook(amy_global.transfer_filename); } amy_global.transfer_file_handle = 0; amy_global.transfer_filename[0] = '\0'; } amy_global.transfer_flag = AMY_TRANSFER_TYPE_NONE; free(decbuf.ptr); } } int b64_buf_malloc(b64_buffer_t * buf) { buf->ptr = malloc(B64_BUFFER_SIZE); if (!buf->ptr) return -1; buf->bufc = 1; return 0; } // We don't do encoding in AMY, we rely on python for that, but we'll leave it here if you want it in C // Just like decode you pass it an allocated encbuf. char * b64_encode (const unsigned char *src, b64_buffer_t * encbuf, size_t len) { int i = 0; int j = 0; size_t size = 0; unsigned char buf[4]; unsigned char tmp[3]; // parse until end of source while (len--) { // read up to 3 bytes at a time into `tmp' tmp[i++] = *(src++); // if 3 bytes read then encode into `buf' if (3 == i) { buf[0] = (tmp[0] & 0xfc) >> 2; buf[1] = ((tmp[0] & 0x03) << 4) + ((tmp[1] & 0xf0) >> 4); buf[2] = ((tmp[1] & 0x0f) << 2) + ((tmp[2] & 0xc0) >> 6); buf[3] = tmp[2] & 0x3f; // allocate 4 new byts for `enc` and // then translate each encoded buffer // part by index from the base 64 index table // into `encbuf.ptr' unsigned char array for (i = 0; i < 4; ++i) { encbuf->ptr[size++] = b64_table[buf[i]]; } // reset index i = 0; } } // remainder if (i > 0) { // fill `tmp' with `\0' at most 3 times for (j = i; j < 3; ++j) { tmp[j] = '\0'; } // perform same codec as above buf[0] = (tmp[0] & 0xfc) >> 2; buf[1] = ((tmp[0] & 0x03) << 4) + ((tmp[1] & 0xf0) >> 4); buf[2] = ((tmp[1] & 0x0f) << 2) + ((tmp[2] & 0xc0) >> 6); buf[3] = tmp[2] & 0x3f; // perform same write to `encbuf->ptr` with new allocation for (j = 0; (j < i + 1); ++j) { encbuf->ptr[size++] = b64_table[buf[j]]; } // while there is still a remainder // append `=' to `encbuf.ptr' while ((i++ < 3)) { encbuf->ptr[size++] = '='; } } // Make sure we have enough space to add '\0' character at end. encbuf->ptr[size] = '\0'; return encbuf->ptr; } unsigned char * b64_decode_ex (const char *src, size_t len, b64_buffer_t * decbuf, size_t *decsize) { int i = 0; int j = 0; int l = 0; size_t size = 0; unsigned char buf[3]; unsigned char tmp[4]; // alloc //if (b64_buf_malloc(&decbuf) == -1) { return NULL; } // parse until end of source while (len--) { // break if char is `=' or not base64 char if ('=' == src[j]) { break; } if (!(isalnum((unsigned char)src[j]) || '+' == src[j] || '/' == src[j])) { break; } // read up to 4 bytes at a time into `tmp' tmp[i++] = src[j++]; // if 4 bytes read then decode into `buf' if (4 == i) { // translate values in `tmp' from table for (i = 0; i < 4; ++i) { // find translation char in `b64_table' for (l = 0; l < 64; ++l) { if (tmp[i] == b64_table[l]) { tmp[i] = l; break; } } } // decode buf[0] = (tmp[0] << 2) + ((tmp[1] & 0x30) >> 4); buf[1] = ((tmp[1] & 0xf) << 4) + ((tmp[2] & 0x3c) >> 2); buf[2] = ((tmp[2] & 0x3) << 6) + tmp[3]; // write decoded buffer to `decbuf.ptr' //if (b64_buf_realloc(&decbuf, size + 3) == -1) return NULL; for (i = 0; i < 3; ++i) { ((unsigned char*)decbuf->ptr)[size++] = buf[i]; } // reset i = 0; } } // remainder if (i > 0) { // fill `tmp' with `\0' at most 4 times for (j = i; j < 4; ++j) { tmp[j] = '\0'; } // translate remainder for (j = 0; j < 4; ++j) { // find translation char in `b64_table' for (l = 0; l < 64; ++l) { if (tmp[j] == b64_table[l]) { tmp[j] = l; break; } } } // decode remainder buf[0] = (tmp[0] << 2) + ((tmp[1] & 0x30) >> 4); buf[1] = ((tmp[1] & 0xf) << 4) + ((tmp[2] & 0x3c) >> 2); buf[2] = ((tmp[2] & 0x3) << 6) + tmp[3]; // write remainer decoded buffer to `decbuf.ptr' //if (b64_buf_realloc(&decbuf, size + (i - 1)) == -1) return NULL; for (j = 0; (j < i - 1); ++j) { ((unsigned char*)decbuf->ptr)[size++] = buf[j]; } } // Make sure we have enough space to add '\0' character at end. //if (b64_buf_realloc(&decbuf, size + 1) == -1) return NULL; ((unsigned char*)decbuf->ptr)[size] = '\0'; // Return back the size of decoded string if demanded. if (decsize != NULL) { *decsize = size; } return (unsigned char*) decbuf->ptr; } // ── State dump helpers ────────────────────────────────────────────────────── // Walk all active instruments and emit one wire-command line per callback. static void amy_emit_state_lines(void (*cb)(const char *line, int len, void *ctx), void *ctx) { char buf[1024]; char line[1100]; bool include_fx = true; for (int inst = 0; inst < instruments_max_instruments(); inst++) { if (instrument_number_exists(inst, NULL)) { uint16_t voices[MAX_VOICES_PER_INSTRUMENT]; int num_voices = instrument_get_num_voices(inst, voices); if (num_voices < 1) continue; // should never happen. int oscs_per_voice = instrument_get_oscs_per_voice(inst); int n = snprintf(line, sizeof(line), "i%dic255Z", inst); cb(line, n, ctx); n = snprintf(line, sizeof(line), "i%div%din%dZ", inst, num_voices, oscs_per_voice); cb(line, n, ctx); void *state = NULL; do { state = yield_synth_commands((uint8_t)inst, buf, sizeof(buf), include_fx, state); if (buf[0] == '\0') continue; n = snprintf(line, sizeof(line), "i%d%s", inst, buf); // Prepends to FX as well, that's OK. cb(line, n, ctx); } while (state); // We include FX only in the first osc. include_fx = false; } } } typedef struct { char *buf; int pos; int cap; } _string_ctx; static void _dump_string_cb(const char *line, int len, void *ctx) { _string_ctx *c = (_string_ctx *)ctx; if (c->pos + len + 1 > c->cap) return; memcpy(c->buf + c->pos, line, len); c->pos += len; c->buf[c->pos++] = '\n'; } char *amy_dump_state_to_string(int *out_len) { int cap = 16384; char *buf = (char *)malloc_caps(cap, amy_global.config.ram_caps_sysex); if (!buf) { *out_len = 0; return NULL; } _string_ctx ctx = { buf, 0, cap }; amy_emit_state_lines(_dump_string_cb, &ctx); buf[ctx.pos] = '\0'; *out_len = ctx.pos; return buf; } // Max base64 chars per sysex chunk. Empirically Chrome's Web MIDI has trouble // delivering sysex messages above a few KB reliably, so we split large dumps // into multiple smaller sysex frames. 1024 base64 chars → ~1030-byte sysex // frame including header/footer, well within the "reliably delivered" band. #define ZDUMP_CHUNK_B64_MAX 1024 // Raw bytes per streamed chunk. 768 = 3 * 256 → exactly 1024 base64 chars with // no padding, so non-final chunks can be concatenated on the receiver and // decoded as one base64 string. Only the final chunk may emit '=' padding // (which is fine: it's appended last). #define ZDUMP_STREAM_RAW_CHUNK 768 // Streaming sysex dump state. Lets amy_dump_state_to_sysex and // amy_dump_file_to_sysex produce arbitrarily-large dumps without holding the // whole payload in RAM. Each ZDUMP_STREAM_RAW_CHUNK bytes of raw data is // base64-encoded and emitted as one sysex frame (marker 'C' if more follow, // 'E' or '0' on the last frame). The effective upper bound is now the // web-side reassembler's SYSEX_REASM_MAX rather than MAX_SYSEX_BYTES. typedef struct { uint8_t *raw_buf; // ZDUMP_STREAM_RAW_CHUNK-byte raw accumulator int raw_pos; // current fill of raw_buf uint8_t *enc; // base64 scratch: b64(raw_buf) uint8_t *frame; // sysex frame scratch: F0 00 03 45 F7 int frames_sent; int bytes_sent; // raw bytes drained so far, for logging bool ok; } _zdump_stream; static int _zdump_stream_init(_zdump_stream *c) { c->raw_buf = NULL; c->enc = NULL; c->frame = NULL; c->raw_pos = 0; c->frames_sent = 0; c->bytes_sent = 0; c->ok = false; c->raw_buf = (uint8_t *)malloc_caps(ZDUMP_STREAM_RAW_CHUNK, amy_global.config.ram_caps_sysex); c->enc = (uint8_t *)malloc_caps(ZDUMP_CHUNK_B64_MAX + 4, amy_global.config.ram_caps_sysex); c->frame = (uint8_t *)malloc_caps(ZDUMP_CHUNK_B64_MAX + 6, amy_global.config.ram_caps_sysex); if (!c->raw_buf || !c->enc || !c->frame) { fprintf(stderr, "zD: stream init malloc failed (raw=%p enc=%p frame=%p)\n", (void *)c->raw_buf, (void *)c->enc, (void *)c->frame); return -1; } c->ok = true; return 0; } static void _zdump_stream_destroy(_zdump_stream *c) { if (c->raw_buf) { free(c->raw_buf); c->raw_buf = NULL; } if (c->enc) { free(c->enc); c->enc = NULL; } if (c->frame) { free(c->frame); c->frame = NULL; } c->ok = false; } // Emit one sysex frame carrying b64(raw_buf[0..raw_pos]). If is_last is false // the marker is 'C' (more frames follow); otherwise it's 'E' when we've // already sent at least one frame, or '0' for a single-frame dump. static void _zdump_stream_drain(_zdump_stream *c, bool is_last) { if (!c->ok) return; uint8_t marker; if (is_last) { marker = (c->frames_sent == 0) ? '0' : 'E'; } else { marker = 'C'; } b64_buffer_t bb = { (char *)c->enc, 1 }; b64_encode(c->raw_buf, &bb, (size_t)c->raw_pos); int enc_len = (int)strlen((char *)c->enc); c->frame[0] = 0xF0; c->frame[1] = 0x00; c->frame[2] = 0x03; c->frame[3] = 0x45; c->frame[4] = marker; memcpy(c->frame + 5, c->enc, enc_len); c->frame[5 + enc_len] = 0xF7; midi_out(c->frame, 6 + enc_len); c->bytes_sent += c->raw_pos; c->frames_sent++; c->raw_pos = 0; } // Append `len` bytes from `data` to the raw accumulator, draining as 'C' // frames whenever the accumulator is full and more data arrives. The last // (possibly partial) chunk is held until _zdump_stream_finish is called. static void _zdump_stream_write(_zdump_stream *c, const uint8_t *data, int len) { if (!c->ok) return; while (len > 0) { if (c->raw_pos == ZDUMP_STREAM_RAW_CHUNK) { _zdump_stream_drain(c, false); } int space = ZDUMP_STREAM_RAW_CHUNK - c->raw_pos; int take = len < space ? len : space; memcpy(c->raw_buf + c->raw_pos, data, take); c->raw_pos += take; data += take; len -= take; } } // Emit any buffered data as the final frame. Always emits at least one frame // so the receiver sees a well-formed '0' (empty-payload) dump response for // empty inputs. static void _zdump_stream_finish(_zdump_stream *c) { if (!c->ok) return; _zdump_stream_drain(c, true); } // amy_emit_state_lines callback: forward each wire-command line (plus '\n') // into the stream. static void _zdump_state_line_cb(const char *line, int len, void *ctx) { _zdump_stream *c = (_zdump_stream *)ctx; _zdump_stream_write(c, (const uint8_t *)line, len); uint8_t nl = '\n'; _zdump_stream_write(c, &nl, 1); } void amy_dump_state_to_sysex(void) { if (!amy_global.config.midi) return; sequencer_midi_stop(); _zdump_stream stream; if (_zdump_stream_init(&stream) != 0) { sequencer_midi_start(); return; } amy_emit_state_lines(_zdump_state_line_cb, &stream); _zdump_stream_finish(&stream); _zdump_stream_destroy(&stream); sequencer_midi_start(); } void amy_dump_file_to_sysex(const char *filename) { // Only meaningful on platforms with MIDI sysex output (hardware, emscripten). // On desktop, midi_out can overflow its stack buffer with large sysex. if (!amy_global.config.midi) return; sequencer_midi_stop(); if (!amy_global.config.amy_external_fopen_hook || !amy_global.config.amy_external_fread_hook || !amy_global.config.amy_external_fclose_hook) { fprintf(stderr, "zD: file I/O hooks unavailable\n"); sequencer_midi_start(); return; } uint32_t fh = amy_global.config.amy_external_fopen_hook((char *)filename, "r"); if (!fh) { fprintf(stderr, "zD: could not open '%s'\n", filename); sequencer_midi_start(); return; } _zdump_stream stream; if (_zdump_stream_init(&stream) != 0) { amy_global.config.amy_external_fclose_hook(fh); sequencer_midi_start(); return; } uint8_t *read_buf = (uint8_t *)malloc_caps(ZDUMP_STREAM_RAW_CHUNK, amy_global.config.ram_caps_sysex); if (!read_buf) { fprintf(stderr, "zD: malloc read_buf(%d) FAILED\n", ZDUMP_STREAM_RAW_CHUNK); _zdump_stream_destroy(&stream); amy_global.config.amy_external_fclose_hook(fh); sequencer_midi_start(); return; } while (1) { uint32_t n = amy_global.config.amy_external_fread_hook(fh, read_buf, ZDUMP_STREAM_RAW_CHUNK); if (n == 0) break; _zdump_stream_write(&stream, read_buf, (int)n); } free(read_buf); _zdump_stream_finish(&stream); _zdump_stream_destroy(&stream); amy_global.config.amy_external_fclose_hook(fh); sequencer_midi_start(); } // ── End state dump helpers ────────────────────────────────────────────────── void transfer_init() { #ifdef __EMSCRIPTEN__ #endif #if defined(_POSIX_VERSION) amy_global.config.amy_external_fopen_hook = posix_external_fopen_hook; amy_global.config.amy_external_fread_hook = posix_external_fread_hook; amy_global.config.amy_external_fwrite_hook = posix_external_fwrite_hook; amy_global.config.amy_external_fclose_hook = posix_external_fclose_hook; amy_global.config.amy_external_fseek_hook = posix_external_fseek_hook; #endif } static uint16_t read_u16_le(const uint8_t *buf) { return (uint16_t)buf[0] | ((uint16_t)buf[1] << 8); } static uint32_t read_u32_le(const uint8_t *buf) { return (uint32_t)buf[0] | ((uint32_t)buf[1] << 8) | ((uint32_t)buf[2] << 16) | ((uint32_t)buf[3] << 24); } static int read_exact(uint32_t handle, uint8_t *buf, uint32_t len) { if (amy_global.config.amy_external_fread_hook == NULL) { return 0; } uint32_t offset = 0; while (offset < len) { uint32_t got = amy_global.config.amy_external_fread_hook(handle, buf + offset, len - offset); if (got == 0) { return 0; } offset += got; } return 1; } static int skip_bytes(uint32_t handle, uint32_t len) { uint8_t scratch[64]; while (len > 0) { uint32_t chunk = len > sizeof(scratch) ? sizeof(scratch) : len; if (!read_exact(handle, scratch, chunk)) { return 0; } len -= chunk; } return 1; } int wave_parse_header(uint32_t handle, wave_info_t *info, uint32_t *data_bytes) { if (info == NULL || data_bytes == NULL) { return 0; } uint8_t riff_header[12]; if (!read_exact(handle, riff_header, sizeof(riff_header))) { return 0; } if (memcmp(riff_header, "RIFF", 4) != 0 || memcmp(riff_header + 8, "WAVE", 4) != 0) { return 0; } uint8_t fmt_found = 0; wave_info_t tmp_info = {0}; while (1) { uint8_t chunk_header[8]; if (!read_exact(handle, chunk_header, sizeof(chunk_header))) { return 0; } uint32_t chunk_size = read_u32_le(chunk_header + 4); if (memcmp(chunk_header, "fmt ", 4) == 0) { if (chunk_size < 16) { return 0; } uint8_t fmt_chunk[16]; if (!read_exact(handle, fmt_chunk, sizeof(fmt_chunk))) { return 0; } uint16_t audio_format = read_u16_le(fmt_chunk); tmp_info.channels = read_u16_le(fmt_chunk + 2); tmp_info.sample_rate = read_u32_le(fmt_chunk + 4); if (audio_format != 1 || tmp_info.channels == 0 || tmp_info.channels > 2) { return 0; } if (!skip_bytes(handle, chunk_size - sizeof(fmt_chunk))) { return 0; } if (chunk_size & 1) { if (!skip_bytes(handle, 1)) { return 0; } } fmt_found = 1; continue; } if (memcmp(chunk_header, "data", 4) == 0) { if (!fmt_found) { return 0; } *info = tmp_info; *data_bytes = chunk_size; return 1; } if (!skip_bytes(handle, chunk_size)) { return 0; } if (chunk_size & 1) { if (!skip_bytes(handle, 1)) { return 0; } } } return 0; } uint32_t wave_read_pcm_frames_s16(uint32_t handle, uint16_t channels, uint32_t *bytes_remaining, int16_t *dest, uint32_t max_frames) { if (dest == NULL || bytes_remaining == 0 || channels == 0 || channels > 2) { return 0; } uint32_t bytes_per_frame = channels * 2; if (*bytes_remaining < bytes_per_frame) { return 0; } uint32_t max_bytes = max_frames * bytes_per_frame; if (max_bytes > *bytes_remaining) { max_bytes = *bytes_remaining - (*bytes_remaining % bytes_per_frame); } uint32_t frames_to_read = max_bytes / bytes_per_frame; if (frames_to_read == 0) { return 0; } uint8_t raw_buf[(AMY_BLOCK_SIZE * PCM_FILE_BUFFER_MULT + 1) * 4]; if (max_bytes > sizeof(raw_buf)) { max_bytes = sizeof(raw_buf) - (sizeof(raw_buf) % bytes_per_frame); frames_to_read = max_bytes / bytes_per_frame; } if (amy_global.config.amy_external_fread_hook == NULL) { return 0; } uint32_t got = amy_global.config.amy_external_fread_hook(handle, raw_buf, max_bytes); got -= got % bytes_per_frame; if (got == 0) { return 0; } frames_to_read = got / bytes_per_frame; *bytes_remaining -= got; if (channels == 1) { for (uint32_t i = 0; i < frames_to_read; i++) { dest[i] = (int16_t)read_u16_le(raw_buf + i * 2); } } else { for (uint32_t i = 0; i < frames_to_read; i++) { dest[i * 2] = (int16_t)read_u16_le(raw_buf + i * 4); dest[i * 2 + 1] = (int16_t)read_u16_le(raw_buf + i * 4 + 2); } } return frames_to_read; } ================================================ FILE: src/transfer.h ================================================ // transfer.h // data transfer over AMY messages // b64 stuff from https://github.com/jwerle/b64.c // bytes -> b64 length: 4 * n / 3 gives unpadded length. // ((4 * n / 3) + 3) & ~3 gives padded length // so if max AMY message is 255 chars, 252 bytes of b64 is max = 189 bytes of pcm #ifndef TRANSFER_H #define TRANSFER_H 1 #include #include "amy.h" #define MAX_OPEN_FILES 64 #define HANDLE_INVALID 0 typedef struct b64_buffer { char * ptr; int bufc; } b64_buffer_t; void transfer_init(); typedef struct { uint16_t channels; uint32_t sample_rate; } wave_info_t; int wave_parse_header(uint32_t handle, wave_info_t *info, uint32_t *data_bytes); uint32_t wave_read_pcm_frames_s16(uint32_t handle, uint16_t channels, uint32_t *bytes_remaining, int16_t *dest, uint32_t max_frames); // How much memory to allocate per buffer #define B64_BUFFER_SIZE (256) // Start buffered memory int b64_buf_malloc(b64_buffer_t * buffer); /** * Base64 index table. */ static const char b64_table[] = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/' }; void start_receiving_transfer(uint32_t length, uint8_t * storage); void start_receiving_file_transfer(uint32_t length, const char *filename); void parse_transfer_message(char * message, uint16_t len) ; void start_receiving_sample(uint32_t frames, uint8_t bus, int16_t *storage); void stop_receiving_sample(); // State dump functions (used by zD wire command in parse.c) void amy_dump_state_to_sysex(void); void amy_dump_file_to_sysex(const char *filename); char *amy_dump_state_to_string(int *out_len); /** * Encode `unsigned char *' source with `size_t' size. * Returns a `char *' base64 encoded string. */ char * b64_encode (const unsigned char *src, b64_buffer_t * encbuf, size_t len); /** * Decode `char *' source with `size_t' size. * Returns a `unsigned char *' base64 decoded string + size of decoded string. */ unsigned char * b64_decode_ex (const char *, size_t, b64_buffer_t * decbuf, size_t *); #endif ================================================ FILE: src/triangle_lutset_fxpt.h ================================================ // Automatically-generated LUTset #ifndef LUTSET_TRIANGLE_FXPT_DEFINED #define LUTSET_TRIANGLE_FXPT_DEFINED #ifndef LUTENTRY_FXPT_DEFINED #define LUTENTRY_FXPT_DEFINED typedef struct { const int16_t *table; int table_size; int log_2_table_size; int highest_harmonic; float scale_factor; } lut_entry_fxpt; #endif // LUTENTRY_FXPT_DEFINED const int16_t triangle_fxpt_lutable_0[512] PROGMEM = { 0,255,512,771,1031,1290,1549,1806, 2061,2316,2573,2832,3092,3352,3610,3867, 4122,4377,4634,4893,5153,5413,5671,5928, 6183,6438,6695,6954,7214,7474,7732,7989, 8244,8499,8756,9015,9275,9535,9794,10050, 10305,10560,10817,11076,11336,11596,11855,12111, 12366,12621,12878,13136,13397,13657,13916,14173, 14427,14682,14938,15197,15458,15719,15978,16234, 16488,16743,16999,17258,17519,17780,18039,18295, 18549,18803,19059,19319,19580,19842,20101,20357, 20610,20864,21120,21379,21641,21903,22163,22418, 22671,22924,23180,23440,23703,23966,24225,24480, 24732,24984,25239,25499,25764,26028,26289,26543, 26793,27042,27297,27559,27826,28093,28354,28606, 28852,29098,29352,29616,29889,30162,30425,30672, 30907,31143,31394,31672,31971,32268,32527,32705, 32767,32705,32527,32268,31971,31672,31394,31143, 30907,30672,30425,30162,29889,29616,29352,29098, 28852,28606,28354,28093,27826,27559,27297,27042, 26793,26543,26289,26028,25764,25499,25239,24984, 24732,24480,24225,23966,23703,23440,23180,22924, 22671,22418,22163,21903,21641,21379,21120,20864, 20610,20357,20101,19842,19580,19319,19059,18803, 18549,18295,18039,17780,17519,17258,16999,16743, 16488,16234,15978,15719,15458,15197,14938,14682, 14427,14173,13916,13657,13397,13136,12878,12621, 12366,12111,11855,11596,11336,11076,10817,10560, 10305,10050,9794,9535,9275,9015,8756,8499, 8244,7989,7732,7474,7214,6954,6695,6438, 6183,5928,5671,5413,5153,4893,4634,4377, 4122,3867,3610,3352,3092,2832,2573,2316, 2061,1806,1549,1290,1031,771,512,255, 0,-255,-512,-771,-1031,-1290,-1549,-1806, -2061,-2316,-2573,-2832,-3092,-3352,-3610,-3867, -4122,-4377,-4634,-4893,-5153,-5413,-5671,-5928, -6183,-6438,-6695,-6954,-7214,-7474,-7732,-7989, -8244,-8499,-8756,-9015,-9275,-9535,-9794,-10050, -10305,-10560,-10817,-11076,-11336,-11596,-11855,-12111, -12366,-12621,-12878,-13136,-13397,-13657,-13916,-14173, -14427,-14682,-14938,-15197,-15458,-15719,-15978,-16234, -16488,-16743,-16999,-17258,-17519,-17780,-18039,-18295, -18549,-18803,-19059,-19319,-19580,-19842,-20101,-20357, -20610,-20864,-21120,-21379,-21641,-21903,-22163,-22418, -22671,-22924,-23180,-23440,-23703,-23966,-24225,-24480, -24732,-24984,-25239,-25499,-25764,-26028,-26289,-26543, -26793,-27042,-27297,-27559,-27826,-28093,-28354,-28606, -28852,-29098,-29352,-29616,-29889,-30162,-30425,-30672, -30907,-31143,-31394,-31672,-31971,-32268,-32527,-32705, -32768,-32705,-32527,-32268,-31971,-31672,-31394,-31143, -30907,-30672,-30425,-30162,-29889,-29616,-29352,-29098, -28852,-28606,-28354,-28093,-27826,-27559,-27297,-27042, -26793,-26543,-26289,-26028,-25764,-25499,-25239,-24984, -24732,-24480,-24225,-23966,-23703,-23440,-23180,-22924, -22671,-22418,-22163,-21903,-21641,-21379,-21120,-20864, -20610,-20357,-20101,-19842,-19580,-19319,-19059,-18803, -18549,-18295,-18039,-17780,-17519,-17258,-16999,-16743, -16488,-16234,-15978,-15719,-15458,-15197,-14938,-14682, -14427,-14173,-13916,-13657,-13397,-13136,-12878,-12621, -12366,-12111,-11855,-11596,-11336,-11076,-10817,-10560, -10305,-10050,-9794,-9535,-9275,-9015,-8756,-8499, -8244,-7989,-7732,-7474,-7214,-6954,-6695,-6438, -6183,-5928,-5671,-5413,-5153,-4893,-4634,-4377, -4122,-3867,-3610,-3352,-3092,-2832,-2573,-2316, -2061,-1806,-1549,-1290,-1031,-771,-512,-255, }; const int16_t triangle_fxpt_lutable_1[512] PROGMEM = { 0,255,511,768,1028,1289,1551,1813, 2073,2332,2589,2844,3099,3354,3611,3869, 4129,4391,4653,4915,5175,5433,5689,5944, 6198,6454,6711,6970,7231,7493,7755,8016, 8276,8533,8788,9043,9297,9553,9811,10071, 10332,10595,10857,11118,11377,11633,11888,12142, 12396,12652,12911,13172,13434,13697,13959,14220, 14477,14733,14987,15240,15495,15752,16011,16273, 16537,16800,17062,17322,17578,17832,18085,18338, 18593,18851,19112,19375,19640,19904,20165,20424, 20679,20931,21183,21435,21691,21950,22213,22478, 22744,23008,23269,23526,23779,24029,24278,24530, 24787,25048,25314,25583,25851,26116,26376,26629, 26877,27123,27369,27621,27879,28146,28419,28694, 28967,29233,29488,29733,29969,30202,30441,30692, 30961,31248,31549,31853,32141,32396,32596,32724, 32767,32724,32596,32396,32141,31853,31549,31248, 30961,30692,30441,30202,29969,29733,29488,29233, 28967,28694,28419,28146,27879,27621,27369,27123, 26877,26629,26376,26116,25851,25583,25314,25048, 24787,24530,24278,24029,23779,23526,23269,23008, 22744,22478,22213,21950,21691,21435,21183,20931, 20679,20424,20165,19904,19640,19375,19112,18851, 18593,18338,18085,17832,17578,17322,17062,16800, 16537,16273,16011,15752,15495,15240,14987,14733, 14477,14220,13959,13697,13434,13172,12911,12652, 12396,12142,11888,11633,11377,11118,10857,10595, 10332,10071,9811,9553,9297,9043,8788,8533, 8276,8016,7755,7493,7231,6970,6711,6454, 6198,5944,5689,5433,5175,4915,4653,4391, 4129,3869,3611,3354,3099,2844,2589,2332, 2073,1813,1551,1289,1028,768,511,255, 0,-255,-511,-768,-1028,-1289,-1551,-1813, -2073,-2332,-2589,-2844,-3099,-3354,-3611,-3869, -4129,-4391,-4653,-4915,-5175,-5433,-5689,-5944, -6198,-6454,-6711,-6970,-7231,-7493,-7755,-8016, -8276,-8533,-8788,-9043,-9297,-9553,-9811,-10071, -10332,-10595,-10857,-11118,-11377,-11633,-11888,-12142, -12396,-12652,-12911,-13172,-13434,-13697,-13959,-14220, -14477,-14733,-14987,-15240,-15495,-15752,-16011,-16273, -16537,-16800,-17062,-17322,-17578,-17832,-18085,-18338, -18593,-18851,-19112,-19375,-19640,-19904,-20165,-20424, -20679,-20931,-21183,-21435,-21691,-21950,-22213,-22478, -22744,-23008,-23269,-23526,-23779,-24029,-24278,-24530, -24787,-25048,-25314,-25583,-25851,-26116,-26376,-26629, -26877,-27123,-27369,-27621,-27879,-28146,-28419,-28694, -28967,-29233,-29488,-29733,-29969,-30202,-30441,-30692, -30961,-31248,-31549,-31853,-32141,-32396,-32596,-32724, -32768,-32724,-32596,-32396,-32141,-31853,-31549,-31248, -30961,-30692,-30441,-30202,-29969,-29733,-29488,-29233, -28967,-28694,-28419,-28146,-27879,-27621,-27369,-27123, -26877,-26629,-26376,-26116,-25851,-25583,-25314,-25048, -24787,-24530,-24278,-24029,-23779,-23526,-23269,-23008, -22744,-22478,-22213,-21950,-21691,-21435,-21183,-20931, -20679,-20424,-20165,-19904,-19640,-19375,-19112,-18851, -18593,-18338,-18085,-17832,-17578,-17322,-17062,-16800, -16537,-16273,-16011,-15752,-15495,-15240,-14987,-14733, -14477,-14220,-13959,-13697,-13434,-13172,-12911,-12652, -12396,-12142,-11888,-11633,-11377,-11118,-10857,-10595, -10332,-10071,-9811,-9553,-9297,-9043,-8788,-8533, -8276,-8016,-7755,-7493,-7231,-6970,-6711,-6454, -6198,-5944,-5689,-5433,-5175,-4915,-4653,-4391, -4129,-3869,-3611,-3354,-3099,-2844,-2589,-2332, -2073,-1813,-1551,-1289,-1028,-768,-511,-255, }; const int16_t triangle_fxpt_lutable_2[256] PROGMEM = { 0,509,1024,1546,2074,2602,3125,3639, 4148,4657,5172,5695,6223,6751,7274,7788, 8297,8805,9320,9843,10372,10901,11424,11938, 12445,12952,13466,13990,14521,15051,15575,16088, 16593,17098,17612,18137,18670,19203,19727,20239, 20740,21242,21755,22282,22820,23358,23884,24392, 24886,25381,25891,26424,26974,27523,28052,28550, 29023,29496,30002,30561,31163,31762,32283,32641, 32767,32641,32283,31762,31163,30561,30002,29496, 29023,28550,28052,27523,26974,26424,25891,25381, 24886,24392,23884,23358,22820,22282,21755,21242, 20740,20239,19727,19203,18670,18137,17612,17098, 16593,16088,15575,15051,14521,13990,13466,12952, 12445,11938,11424,10901,10372,9843,9320,8805, 8297,7788,7274,6751,6223,5695,5172,4657, 4148,3639,3125,2602,2074,1546,1024,509, 0,-509,-1024,-1546,-2074,-2602,-3125,-3639, -4148,-4657,-5172,-5695,-6223,-6751,-7274,-7788, -8297,-8805,-9320,-9843,-10372,-10901,-11424,-11938, -12445,-12952,-13466,-13990,-14521,-15051,-15575,-16088, -16593,-17098,-17612,-18137,-18670,-19203,-19727,-20239, -20740,-21242,-21755,-22282,-22820,-23358,-23884,-24392, -24886,-25381,-25891,-26424,-26974,-27523,-28052,-28550, -29023,-29496,-30002,-30561,-31163,-31762,-32283,-32641, -32768,-32641,-32283,-31762,-31163,-30561,-30002,-29496, -29023,-28550,-28052,-27523,-26974,-26424,-25891,-25381, -24886,-24392,-23884,-23358,-22820,-22282,-21755,-21242, -20740,-20239,-19727,-19203,-18670,-18137,-17612,-17098, -16593,-16088,-15575,-15051,-14521,-13990,-13466,-12952, -12445,-11938,-11424,-10901,-10372,-9843,-9320,-8805, -8297,-7788,-7274,-6751,-6223,-5695,-5172,-4657, -4148,-3639,-3125,-2602,-2074,-1546,-1024,-509, }; const int16_t triangle_fxpt_lutable_3[256] PROGMEM = { 0,536,1068,1593,2109,2620,3126,3634, 4146,4666,5194,5729,6266,6801,7331,7853, 8366,8873,9379,9887,10401,10924,11456,11994, 12533,13068,13596,14114,14623,15125,15628,16135, 16652,17181,17719,18262,18805,19341,19866,20377, 20877,21371,21868,22375,22897,23435,23987,24543, 25095,25632,26148,26641,27117,27588,28069,28576, 29119,29700,30307,30920,31503,32017,32421,32679, 32767,32679,32421,32017,31503,30920,30307,29700, 29119,28576,28069,27588,27117,26641,26148,25632, 25095,24543,23987,23435,22897,22375,21868,21371, 20877,20377,19866,19341,18805,18262,17719,17181, 16652,16135,15628,15125,14623,14114,13596,13068, 12533,11994,11456,10924,10401,9887,9379,8873, 8366,7853,7331,6801,6266,5729,5194,4666, 4146,3634,3126,2620,2109,1593,1068,536, 0,-536,-1068,-1593,-2109,-2620,-3126,-3634, -4146,-4666,-5194,-5729,-6266,-6801,-7331,-7853, -8366,-8873,-9379,-9887,-10401,-10924,-11456,-11994, -12533,-13068,-13596,-14114,-14623,-15125,-15628,-16135, -16652,-17181,-17719,-18262,-18805,-19341,-19866,-20377, -20877,-21371,-21868,-22375,-22897,-23435,-23987,-24543, -25095,-25632,-26148,-26641,-27117,-27588,-28069,-28576, -29119,-29700,-30307,-30920,-31503,-32017,-32421,-32679, -32768,-32679,-32421,-32017,-31503,-30920,-30307,-29700, -29119,-28576,-28069,-27588,-27117,-26641,-26148,-25632, -25095,-24543,-23987,-23435,-22897,-22375,-21868,-21371, -20877,-20377,-19866,-19341,-18805,-18262,-17719,-17181, -16652,-16135,-15628,-15125,-14623,-14114,-13596,-13068, -12533,-11994,-11456,-10924,-10401,-9887,-9379,-8873, -8366,-7853,-7331,-6801,-6266,-5729,-5194,-4666, -4146,-3634,-3126,-2620,-2109,-1593,-1068,-536, }; const int16_t triangle_fxpt_lutable_4[128] PROGMEM = { 0,1013,2048,3115,4204,5292,6358,7392, 8402,9412,10446,11516,12612,13707,14775,15803, 16801,17799,18830,19910,21027,22144,23217,24224, 25180,26137,27162,28294,29514,30730,31786,32510, 32767,32510,31786,30730,29514,28294,27162,26137, 25180,24224,23217,22144,21027,19910,18830,17799, 16801,15803,14775,13707,12612,11516,10446,9412, 8402,7392,6358,5292,4204,3115,2048,1013, 0,-1013,-2048,-3115,-4204,-5292,-6358,-7392, -8402,-9412,-10446,-11516,-12612,-13707,-14775,-15803, -16801,-17799,-18830,-19910,-21027,-22144,-23217,-24224, -25180,-26137,-27162,-28294,-29514,-30730,-31786,-32510, -32768,-32510,-31786,-30730,-29514,-28294,-27162,-26137, -25180,-24224,-23217,-22144,-21027,-19910,-18830,-17799, -16801,-15803,-14775,-13707,-12612,-11516,-10446,-9412, -8402,-7392,-6358,-5292,-4204,-3115,-2048,-1013, }; const int16_t triangle_fxpt_lutable_5[128] PROGMEM = { 0,1132,2248,3337,4393,5418,6422,7419, 8427,9459,10526,11630,12763,13911,15054,16174, 17255,18290,19282,20246,21204,22186,23216,24315, 25488,26720,27979,29215,30363,31353,32118,32602, 32767,32602,32118,31353,30363,29215,27979,26720, 25488,24315,23216,22186,21204,20246,19282,18290, 17255,16174,15054,13911,12763,11630,10526,9459, 8427,7419,6422,5418,4393,3337,2248,1132, 0,-1132,-2248,-3337,-4393,-5418,-6422,-7419, -8427,-9459,-10526,-11630,-12763,-13911,-15054,-16174, -17255,-18290,-19282,-20246,-21204,-22186,-23216,-24315, -25488,-26720,-27979,-29215,-30363,-31353,-32118,-32602, -32768,-32602,-32118,-31353,-30363,-29215,-27979,-26720, -25488,-24315,-23216,-22186,-21204,-20246,-19282,-18290, -17255,-16174,-15054,-13911,-12763,-11630,-10526,-9459, -8427,-7419,-6422,-5418,-4393,-3337,-2248,-1132, }; const int16_t triangle_fxpt_lutable_6[64] PROGMEM = { 0,2005,4101,6327,8648,10968,13184,15247, 17193,19142,21236,23561,26075,28578,30750,32238, 32767,32238,30750,28578,26075,23561,21236,19142, 17193,15247,13184,10968,8648,6327,4101,2005, 0,-2005,-4101,-6327,-8648,-10968,-13184,-15247, -17193,-19142,-21236,-23561,-26075,-28578,-30750,-32238, -32768,-32238,-30750,-28578,-26075,-23561,-21236,-19142, -17193,-15247,-13184,-10968,-8648,-6327,-4101,-2005, }; const int16_t triangle_fxpt_lutable_7[64] PROGMEM = { 0,2409,4743,6952,9023,10994,12935,14939, 17087,19424,21935,24535,27074,29359,31182,32360, 32767,32360,31182,29359,27074,24535,21935,19424, 17087,14939,12935,10994,9023,6952,4743,2409, 0,-2409,-4743,-6952,-9023,-10994,-12935,-14939, -17087,-19424,-21935,-24535,-27074,-29359,-31182,-32360, -32768,-32360,-31182,-29359,-27074,-24535,-21935,-19424, -17087,-14939,-12935,-10994,-9023,-6952,-4743,-2409, }; const int16_t triangle_fxpt_lutable_8[32] PROGMEM = { 0,3933,8258,13171,18536,23882,28500,31649, 32767,31649,28500,23882,18536,13171,8258,3933, 0,-3933,-8258,-13171,-18536,-23882,-28500,-31649, -32768,-31649,-28500,-23882,-18536,-13171,-8258,-3933, }; const int16_t triangle_fxpt_lutable_9[16] PROGMEM = { 0,12540,23170,30274,32767,30274,23170,12540, 0,-12540,-23170,-30274,-32768,-30274,-23170,-12540, }; const int16_t triangle_fxpt_lutable_10[8] PROGMEM = { 0,23170,32767,23170,0,-23170,-32768,-23170, }; lut_entry_fxpt triangle_fxpt_lutset[12] = { {triangle_fxpt_lutable_0, 512, 9, 63, 1.225889}, {triangle_fxpt_lutable_1, 512, 9, 44, 1.222339}, {triangle_fxpt_lutable_2, 256, 8, 31, 1.218081}, {triangle_fxpt_lutable_3, 256, 8, 22, 1.210989}, {triangle_fxpt_lutable_4, 128, 7, 15, 1.202491}, {triangle_fxpt_lutable_5, 128, 7, 10, 1.183865}, {triangle_fxpt_lutable_6, 64, 6, 7, 1.171519}, {triangle_fxpt_lutable_7, 64, 6, 5, 1.151111}, {triangle_fxpt_lutable_8, 32, 5, 3, 1.111111}, {triangle_fxpt_lutable_9, 16, 4, 2, 1.000000}, {triangle_fxpt_lutable_10, 8, 3, 1, 1.000000}, {NULL, 0, 0, 0, 0.0}, }; #endif // LUTSET_x_DEFINED ================================================ FILE: src/usb.c ================================================ // usb.c // tinyusb stuff #include "amy.h" #if defined(AMY_MCU) && (!defined(ARDUINO) || defined(AMYBOARD_ARDUINO)) #define CONFIG_TOTAL_LEN_MIDI (TUD_CONFIG_DESC_LEN + TUD_MIDI_DESC_LEN + TUD_CDC_DESC_LEN) // For AMYBOARD_ARDUINO, provide defaults for MicroPython-originated macros #ifdef AMYBOARD_ARDUINO #ifndef MICROPY_HW_USB_VID #define MICROPY_HW_USB_VID (0xCAF0) #endif #ifndef MICROPY_HW_USB_PID #define MICROPY_HW_USB_PID (0x0001) #endif #ifndef MICROPY_HW_USB_DESC_STR_MAX #define MICROPY_HW_USB_DESC_STR_MAX (32) #endif #ifndef MICROPY_HW_USB_MANUFACTURER_STRING #define MICROPY_HW_USB_MANUFACTURER_STRING "AMYboard" #endif #ifndef MICROPY_HW_USB_PRODUCT_FS_STRING #define MICROPY_HW_USB_PRODUCT_FS_STRING "AMYboard" #endif #ifndef MICROPY_HW_USB_CDC_INTERFACE_STRING #define MICROPY_HW_USB_CDC_INTERFACE_STRING "AMYboard" #endif #ifndef MICROPY_HW_ENABLE_USB_RUNTIME_DEVICE #define MICROPY_HW_ENABLE_USB_RUNTIME_DEVICE (0) #endif #ifndef MICROPY_HW_USB_MSC_INTERFACE_STRING #define MICROPY_HW_USB_MSC_INTERFACE_STRING "AMYboard" #endif #define USBD_STR_MANUF (0x01) #define USBD_STR_PRODUCT (0x02) #define USBD_STR_SERIAL (0x03) #define USBD_STR_CDC (0x04) #define USBD_STR_MSC (0x05) #endif // AMYBOARD_ARDUINO #include "usb.h" #include "tusb.h" #define USBD_CDC_CMD_MAX_SIZE (8) #define USBD_CDC_IN_OUT_MAX_SIZE ((CFG_TUD_MAX_SPEED == OPT_MODE_HIGH_SPEED) ? 512 : 64) const tusb_desc_device_t amy_usbd_builtin_desc_dev = { .bLength = sizeof(tusb_desc_device_t), .bDescriptorType = TUSB_DESC_DEVICE, .bcdUSB = 0x0200, .bDeviceClass = TUSB_CLASS_MISC, .bDeviceSubClass = MISC_SUBCLASS_COMMON, .bDeviceProtocol = MISC_PROTOCOL_IAD, .bMaxPacketSize0 = CFG_TUD_ENDPOINT0_SIZE, .idVendor = MICROPY_HW_USB_VID, .idProduct = MICROPY_HW_USB_PID, .bcdDevice = 0x0100, .iManufacturer = USBD_STR_MANUF, .iProduct = USBD_STR_PRODUCT, .iSerialNumber = USBD_STR_SERIAL, .bNumConfigurations = 1, }; enum { ITF_NUM_CDC = 0, ITF_NUM_CDC_DATA, ITF_NUM_MIDI, ITF_NUM_MIDI_STREAMING, ITF_NUM_TOTAL }; #define EPNUM_CDC_NOTIF 0x81 #define EPNUM_CDC_OUT 0x02 #define EPNUM_CDC_IN 0x82 #define EPNUM_MIDI 0x04 const uint8_t amy_usbd_builtin_desc_cfg[CONFIG_TOTAL_LEN_MIDI] = { // Config number, interface count, string index, total length, attribute, power in mA TUD_CONFIG_DESCRIPTOR(1, ITF_NUM_TOTAL, 0, CONFIG_TOTAL_LEN_MIDI, TUSB_DESC_CONFIG_ATT_REMOTE_WAKEUP, 100), // Interface number, string index, EP Out & EP In address, EP size TUD_CDC_DESCRIPTOR(ITF_NUM_CDC, 4, EPNUM_CDC_NOTIF, 8, EPNUM_CDC_OUT, EPNUM_CDC_IN, 64), TUD_MIDI_DESCRIPTOR(ITF_NUM_MIDI, 0, EPNUM_MIDI, 0x80 | EPNUM_MIDI, 64), }; const uint16_t *tud_descriptor_string_cb(uint8_t index, uint16_t langid) { char serial_buf[MICROPY_HW_USB_DESC_STR_MAX + 1]; // Includes terminating NUL byte static uint16_t desc_wstr[MICROPY_HW_USB_DESC_STR_MAX + 1]; // Includes prefix uint16_t const char *desc_str = NULL; uint16_t desc_len; #if MICROPY_HW_ENABLE_USB_RUNTIME_DEVICE desc_str = amy_usbd_runtime_string_cb(index); #endif if (index == 0) { // String descriptor 0 is special, see USB 2.0 section 9.6.7 String // // Expect any runtime value in desc_str to be a fully formed descriptor if (desc_str == NULL) { desc_str = "\x04\x03\x09\x04"; // Descriptor for "English" } if (desc_str[0] < sizeof(desc_wstr)) { memcpy(desc_wstr, desc_str, desc_str[0]); return desc_wstr; } return NULL; // Descriptor length too long (or malformed), stall endpoint } // Otherwise, generate a "UNICODE" string descriptor from the C string if (desc_str == NULL) { // Fall back to the "static" string switch (index) { case USBD_STR_SERIAL: amy_usbd_port_get_serial_number(serial_buf); desc_str = serial_buf; break; case USBD_STR_MANUF: desc_str = MICROPY_HW_USB_MANUFACTURER_STRING; break; case USBD_STR_PRODUCT: desc_str = MICROPY_HW_USB_PRODUCT_FS_STRING; break; #if CFG_TUD_CDC case USBD_STR_CDC: desc_str = MICROPY_HW_USB_CDC_INTERFACE_STRING; break; #endif #if CFG_TUD_MSC case USBD_STR_MSC: desc_str = MICROPY_HW_USB_MSC_INTERFACE_STRING; break; #endif default: break; } } if (desc_str == NULL) { return NULL; // No string, STALL the endpoint } // Convert from narrow string to wide string desc_len = 2; for (int i = 0; i < MICROPY_HW_USB_DESC_STR_MAX && desc_str[i] != 0; i++) { desc_wstr[1 + i] = desc_str[i]; desc_len += 2; } // first byte is length (including header), second byte is string type desc_wstr[0] = (TUSB_DESC_STRING << 8) | desc_len; return desc_wstr; } #ifdef AMYBOARD_ARDUINO #include "esp_mac.h" #include "esp32-hal-tinyusb.h" // Override Arduino's weak descriptor callbacks with amy's MIDI+CDC descriptors uint8_t const *tud_descriptor_device_cb(void) { return (uint8_t const *)&amy_usbd_builtin_desc_dev; } uint8_t const *tud_descriptor_configuration_cb(uint8_t index) { (void)index; return amy_usbd_builtin_desc_cfg; } // Provide serial number from ESP32 MAC address void amy_usbd_port_get_serial_number(char *buf) { uint8_t mac[8]; esp_efuse_mac_get_default(mac); amy_usbd_hex_str(buf, mac, sizeof(mac)); } void amy_usbd_hex_str(char *out_str, const uint8_t *bytes, size_t bytes_len) { for (size_t i = 0; i < bytes_len; i++) { uint8_t b = bytes[i]; uint8_t hi = b >> 4; uint8_t lo = b & 0x0F; out_str[i * 2] = hi < 10 ? '0' + hi : 'A' + hi - 10; out_str[i * 2 + 1] = lo < 10 ? '0' + lo : 'A' + lo - 10; } out_str[bytes_len * 2] = '\0'; } void amy_arduino_usb_setup(void) { // Use Arduino's tinyusb_init which handles USB PHY setup, tusb_init(), // and creates the TinyUSB device task. Our non-weak descriptor callbacks // above ensure the host sees amy's MIDI+CDC descriptors. tinyusb_device_config_t cfg = { .vid = MICROPY_HW_USB_VID, .pid = MICROPY_HW_USB_PID, .product_name = MICROPY_HW_USB_PRODUCT_FS_STRING, .manufacturer_name = MICROPY_HW_USB_MANUFACTURER_STRING, .serial_number = "", .fw_version = 0x0100, .usb_version = 0x0200, .usb_class = TUSB_CLASS_MISC, .usb_subclass = MISC_SUBCLASS_COMMON, .usb_protocol = MISC_PROTOCOL_IAD, .usb_attributes = TUSB_DESC_CONFIG_ATT_REMOTE_WAKEUP, .usb_power_ma = 100, .webusb_enabled = false, .webusb_url = "", }; tinyusb_init(&cfg); } #endif // AMYBOARD_ARDUINO #endif // AMY_MCU ================================================ FILE: src/usb.h ================================================ // usb.h // tinyusb stuff #if defined(AMY_MCU) && (!defined(ARDUINO) || defined(AMYBOARD_ARDUINO)) #include "class/audio/audio.h" #include "class/midi/midi.h" #include "tusb.h" #include "device/dcd.h" // Initialise TinyUSB device (MicroPython path only) #ifndef AMYBOARD_ARDUINO static inline void amy_usbd_init_tud(void) { tusb_init(); tud_cdc_configure_fifo_t cfg = { .rx_persistent = 0, .tx_persistent = 1 }; tud_cdc_configure_fifo(&cfg); } // Run the TinyUSB device task void amy_usbd_task(void); // Schedule a call to mp_usbd_task(), even if no USB interrupt has occurred void amy_usbd_schedule_task(void); #endif extern void amy_usbd_port_get_serial_number(char *buf); // Most ports need to write a hexadecimal serial number from a byte array. This // is a helper function for this. out_str must be long enough to hold a string of total // length (2 * bytes_len + 1) (including NUL terminator). void amy_usbd_hex_str(char *out_str, const uint8_t *bytes, size_t bytes_len); // Built-in USB device and configuration descriptor values extern const tusb_desc_device_t amy_usbd_builtin_desc_dev; extern const uint8_t amy_usbd_builtin_desc_cfg[]; #ifdef AMYBOARD_ARDUINO // Arduino: initialize TinyUSB with amy's MIDI+CDC descriptors void amy_arduino_usb_setup(void); void amy_usbd_port_get_serial_number(char *buf); void amy_usbd_hex_str(char *out_str, const uint8_t *bytes, size_t bytes_len); #else static inline void amy_usbd_init(void) { mp_usbd_init_tud(); } #endif #endif ================================================ FILE: valgrind.suppressions ================================================ { libpulse_common Memcheck:Leak match-leak-kinds: reachable ... obj:/usr/lib/aarch64-linux-gnu/pulseaudio/libpulsecommon-16.1.so ... } { miniaudio_run Memcheck:Leak match-leak-kinds: reachable ... fun:miniaudio_run ... } { dlopen_catch_exception Memcheck:Leak match-leak-kinds: reachable ... fun:_dl_catch_exception ... } { pthread_create Memcheck:Leak match-leak-kinds: possible ... fun:pthread_create@@GLIBC_2.34 ... } ================================================ FILE: windows/CMakeLists.txt ================================================ cmake_minimum_required(VERSION 3.10) project(amy_sine C) set(CMAKE_C_STANDARD 11) set(AMY_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../src") set(AMY_SOURCES ${AMY_SRC_DIR}/algorithms.c ${AMY_SRC_DIR}/amy.c ${AMY_SRC_DIR}/envelope.c ${AMY_SRC_DIR}/examples.c ${AMY_SRC_DIR}/parse.c ${AMY_SRC_DIR}/filters.c ${AMY_SRC_DIR}/oscillators.c ${AMY_SRC_DIR}/pcm.c ${AMY_SRC_DIR}/interp_partials.c ${AMY_SRC_DIR}/custom.c ${AMY_SRC_DIR}/delay.c ${AMY_SRC_DIR}/log2_exp2.c ${AMY_SRC_DIR}/patches.c ${AMY_SRC_DIR}/transfer.c ${AMY_SRC_DIR}/sequencer.c ${AMY_SRC_DIR}/libminiaudio-audio.c ${AMY_SRC_DIR}/instrument.c ${AMY_SRC_DIR}/amy_midi.c ${AMY_SRC_DIR}/api.c ${AMY_SRC_DIR}/midi_mappings.c ) add_executable(amy_sine amy_sine.c ${AMY_SOURCES}) target_include_directories(amy_sine PRIVATE ${AMY_SRC_DIR}) target_compile_definitions(amy_sine PRIVATE AMY_WAVETABLE _CRT_SECURE_NO_WARNINGS) if(MSVC) target_compile_options(amy_sine PRIVATE /O2 /W3 /std:c11) else() target_compile_options(amy_sine PRIVATE -O3 -Wall -Wno-strict-aliasing -Wextra -Wno-unused-parameter -Wpointer-arith -Wno-float-conversion -Wno-missing-declarations ) target_link_libraries(amy_sine PRIVATE m pthread) endif() ================================================ FILE: windows/README.md ================================================ # AMY on Windows A minimal example that plays a 440Hz sine wave using AMY on Windows. ## Prerequisites Install **Visual Studio Build Tools 2022** (free) with the C++ workload: ``` winget install Microsoft.VisualStudio.2022.BuildTools --override "--add Microsoft.VisualStudio.Workload.VCTools --includeRecommended --passive" ``` Or download from https://visualstudio.microsoft.com/visual-cpp-build-tools/ and select **Desktop development with C++**. ## Build Open a **Developer Command Prompt for VS 2022** (search for it in the Start menu), then: ```cmd cd path\to\amy\windows build.bat ``` This produces `amy_sine.exe`. ## Run ```cmd amy_sine.exe ``` You should hear a 440Hz sine wave. Press Enter to quit. ## CMake (alternative) If you have CMake installed, you can also build from a Developer Command Prompt: ```cmd cd windows mkdir build && cd build cmake .. cmake --build . --config Release ``` ================================================ FILE: windows/amy_sine.c ================================================ // amy_sine.c - simplest possible AMY example for Windows // Plays a 440Hz sine wave through your default audio device. #include "amy.h" #include "libminiaudio-audio.h" // Required by examples.c but not used in this simple app. #ifdef _WIN32 #include void delay_ms(uint32_t ms) { Sleep(ms); } #else #include void delay_ms(uint32_t ms) { usleep(ms * 1000); } #endif int main(void) { amy_config_t config = amy_default_config(); config.audio = AMY_AUDIO_IS_MINIAUDIO; config.features.default_synths = 1; amy_start(config); // Play a 440Hz sine wave amy_event e = amy_default_event(); e.wave = SINE; e.freq_coefs[COEF_CONST] = 440.0f; e.amp_coefs[COEF_CONST] = 1.0f; e.velocity = 1.0f; amy_add_event(&e); printf("Playing 440Hz sine wave. Press Enter to quit.\n"); getchar(); amy_stop(); return 0; } ================================================ FILE: windows/build.bat ================================================ @echo off call "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Auxiliary\Build\vcvarsall.bat" x64 if errorlevel 1 ( echo Failed to set up MSVC environment exit /b 1 ) cd /d "%~dp0" cl /O2 /W3 /std:c11 /D_CRT_SECURE_NO_WARNINGS /DAMY_WAVETABLE /I..\src ^ amy_sine.c ^ ..\src\algorithms.c ^ ..\src\amy.c ^ ..\src\envelope.c ^ ..\src\examples.c ^ ..\src\parse.c ^ ..\src\filters.c ^ ..\src\oscillators.c ^ ..\src\pcm.c ^ ..\src\interp_partials.c ^ ..\src\custom.c ^ ..\src\delay.c ^ ..\src\log2_exp2.c ^ ..\src\patches.c ^ ..\src\transfer.c ^ ..\src\sequencer.c ^ ..\src\libminiaudio-audio.c ^ ..\src\instrument.c ^ ..\src\amy_midi.c ^ ..\src\api.c ^ ..\src\midi_mappings.c ^ /Fe:amy_sine.exe